evented works

This commit is contained in:
Ramnique Singh 2026-04-14 00:53:58 +05:30
parent 5b16a0a42e
commit 570a315b36
10 changed files with 445 additions and 50 deletions

View file

@ -22,7 +22,7 @@ export type TrackSchedule = z.infer<typeof TrackScheduleSchema>;
export const TrackBlockSchema = z.object({
trackId: z.string().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).describe('Kebab-case identifier, unique within the note file'),
instruction: z.string().min(1).describe('What the agent should produce each run — specific, single-focus, imperative'),
matchCriteria: z.string().optional().describe('Optional filter for event-driven tracks'),
eventMatchCriteria: z.string().optional().describe('When set, this track participates in event-based triggering. Describe what kinds of events should consider this track for an update (e.g. "Emails about Q3 planning"). Omit to disable event triggers — the track will only run on schedule or manually.'),
active: z.boolean().default(true).describe('Set false to pause without deleting'),
schedule: TrackScheduleSchema.optional(),
lastRunAt: z.string().optional().describe('Runtime-managed — never write this yourself'),
@ -30,6 +30,39 @@ export const TrackBlockSchema = z.object({
lastRunSummary: z.string().optional().describe('Runtime-managed — never write this yourself'),
});
// ---------------------------------------------------------------------------
// Knowledge events (event-driven track triggering pipeline)
// ---------------------------------------------------------------------------
export const KnowledgeEventSchema = z.object({
id: z.string().describe('Monotonically increasing ID; also the filename in events/pending/'),
source: z.string().describe('Producer of the event (e.g. "gmail", "calendar")'),
type: z.string().describe('Event type (e.g. "email.synced")'),
createdAt: z.string().describe('ISO timestamp when the event was produced'),
payload: z.string().describe('Human-readable event body, usually markdown'),
targetTrackId: z.string().optional().describe('If set, skip routing and target this track directly (used for re-runs)'),
targetFilePath: z.string().optional(),
// Enriched on move from pending/ to done/
processedAt: z.string().optional(),
candidates: z.array(z.object({
trackId: z.string(),
filePath: z.string(),
})).optional(),
runIds: z.array(z.string()).optional(),
error: z.string().optional(),
});
export type KnowledgeEvent = z.infer<typeof KnowledgeEventSchema>;
export const Pass1OutputSchema = z.object({
candidates: z.array(z.object({
trackId: z.string().describe('The track block identifier'),
filePath: z.string().describe('The note file path the track lives in'),
})).describe('Tracks that may be relevant to this event. trackIds are only unique within a file, so always return both fields.'),
});
export type Pass1Output = z.infer<typeof Pass1OutputSchema>;
// Track bus events
export const TrackRunStartEvent = z.object({
type: z.literal('track_run_start'),