feat: add syncing update for graph building on the UI

This commit is contained in:
tusharmagar 2026-02-05 16:05:10 +05:30
parent 6425dbcf28
commit eefc6a9700
13 changed files with 1093 additions and 163 deletions

View file

@ -6,4 +6,5 @@ export * as workspace from './workspace.js';
export * as mcp from './mcp.js';
export * as agentSchedule from './agent-schedule.js';
export * as agentScheduleState from './agent-schedule-state.js';
export * as serviceEvents from './service-events.js';
export { PrefixLogger };

View file

@ -5,6 +5,7 @@ import { AskHumanResponsePayload, CreateRunOptions, Run, ListRunsResponse, ToolP
import { LlmModelConfig } from './models.js';
import { AgentScheduleConfig, AgentScheduleEntry } from './agent-schedule.js';
import { AgentScheduleState } from './agent-schedule-state.js';
import { ServiceEvent } from './service-events.js';
// ============================================================================
// Runtime Validation Schemas (Single Source of Truth)
@ -176,6 +177,10 @@ const ipcSchemas = {
req: z.null(),
res: z.null(),
},
'services:events': {
req: ServiceEvent,
res: z.null(),
},
'models:list': {
req: z.null(),
res: z.object({

View file

@ -0,0 +1,65 @@
import z from 'zod';
export const ServiceName = z.enum([
'graph',
'gmail',
'calendar',
'fireflies',
'granola',
'voice_memo',
]);
const ServiceEventBase = z.object({
service: ServiceName,
runId: z.string(),
ts: z.iso.datetime(),
level: z.enum(['info', 'warn', 'error']),
message: z.string(),
});
export const ServiceRunStartEvent = ServiceEventBase.extend({
type: z.literal('run_start'),
trigger: z.enum(['timer', 'manual', 'startup']).optional(),
config: z.record(z.string(), z.unknown()).optional(),
});
export const ServiceChangesIdentifiedEvent = ServiceEventBase.extend({
type: z.literal('changes_identified'),
counts: z.record(z.string(), z.number()).optional(),
items: z.array(z.string()).optional(),
truncated: z.boolean().optional(),
});
export const ServiceProgressEvent = ServiceEventBase.extend({
type: z.literal('progress'),
step: z.string().optional(),
current: z.number().optional(),
total: z.number().optional(),
details: z.record(z.string(), z.unknown()).optional(),
});
export const ServiceRunCompleteEvent = ServiceEventBase.extend({
type: z.literal('run_complete'),
durationMs: z.number(),
outcome: z.enum(['ok', 'idle', 'skipped', 'error']),
summary: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
items: z.array(z.string()).optional(),
truncated: z.boolean().optional(),
});
export const ServiceErrorEvent = ServiceEventBase.extend({
type: z.literal('error'),
error: z.string(),
context: z.record(z.string(), z.unknown()).optional(),
});
export const ServiceEvent = z.union([
ServiceRunStartEvent,
ServiceChangesIdentifiedEvent,
ServiceProgressEvent,
ServiceRunCompleteEvent,
ServiceErrorEvent,
]);
export type ServiceNameType = z.infer<typeof ServiceName>;
export type ServiceEventType = z.infer<typeof ServiceEvent>;