diff --git a/src/shared/agent-session-answered-turn-schema.ts b/src/shared/agent-session-answered-turn-schema.ts new file mode 100644 index 00000000000..44f574d9ec1 --- /dev/null +++ b/src/shared/agent-session-answered-turn-schema.ts @@ -0,0 +1,7 @@ +import { z } from 'zod' + +/** A submission's answered turn as published. `via` is a string, as `dispatchState` is: a newer + * host may name another way of joining. null: the host recorded no turn. */ +export const AgentJournalAnsweredTurnSchema = z + .object({ turnItemId: z.string().min(1), via: z.string().min(1) }) + .nullable() diff --git a/src/shared/agent-session-journal-schemas.ts b/src/shared/agent-session-journal-schemas.ts index 39ee0b45c5f..1bbaee0330c 100644 --- a/src/shared/agent-session-journal-schemas.ts +++ b/src/shared/agent-session-journal-schemas.ts @@ -16,6 +16,7 @@ import { z } from 'zod' import { AgentSessionContextUsageSchema } from './agent-session-context-usage-schema' import { AgentSessionFailureFactSchema } from './agent-session-failure-fact-schema' +import { AgentJournalAnsweredTurnSchema } from './agent-session-answered-turn-schema' import type { AgentJournalItemBody, AgentJournalMessageItem, @@ -319,11 +320,7 @@ export const AgentJournalSubmissionSchema = z.object({ submittedAt: z.number(), resolvedAt: z.number().nullable(), submittedSequence: z.number().int().optional(), - // `via` is a string, as `dispatchState` is: a newer host may name another way of joining. - answeredInTurn: z - .object({ turnItemId: z.string().min(1), via: z.string().min(1) }) - .nullable() - .optional(), + answeredInTurn: AgentJournalAnsweredTurnSchema.optional(), recovered: z.literal(true).optional(), handoverRecorded: z.literal(true).optional(), handedOverAt: z.number().optional(),