@vercel/factory 0.0.17 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/api-contracts.d.mts +665 -715
  3. package/dist/api-contracts.mjs +91 -4
  4. package/dist/api-contracts.mjs.map +1 -1
  5. package/dist/api-task-graph.mjs +14 -5
  6. package/dist/api-task-graph.mjs.map +1 -1
  7. package/dist/api.d.mts +58 -11
  8. package/dist/api.mjs +715 -399
  9. package/dist/api.mjs.map +1 -1
  10. package/dist/approval-access.d.mts +1 -1
  11. package/dist/approval-contracts.d.mts +3 -4
  12. package/dist/approval-contracts.mjs +1 -2
  13. package/dist/approval-contracts.mjs.map +1 -1
  14. package/dist/blob/index.d.mts +1 -1
  15. package/dist/budget.mjs +20 -3
  16. package/dist/budget.mjs.map +1 -1
  17. package/dist/change-verification/brief.d.mts +1 -1
  18. package/dist/change-verification/dispatch.mjs +8 -1
  19. package/dist/change-verification/dispatch.mjs.map +1 -1
  20. package/dist/changes/eve-record-change.mjs +4 -1
  21. package/dist/changes/eve-record-change.mjs.map +1 -1
  22. package/dist/client-stream.d.mts +19 -2
  23. package/dist/client-stream.mjs +115 -53
  24. package/dist/client-stream.mjs.map +1 -1
  25. package/dist/client-transcript.d.mts +25 -2
  26. package/dist/client-transcript.mjs +95 -13
  27. package/dist/client-transcript.mjs.map +1 -1
  28. package/dist/client.d.mts +145 -19
  29. package/dist/client.mjs +89 -16
  30. package/dist/client.mjs.map +1 -1
  31. package/dist/code-review/contracts.d.mts +1 -0
  32. package/dist/code-review/eve-post-review.d.mts +4 -2
  33. package/dist/code-review/eve-post-review.mjs +8 -0
  34. package/dist/code-review/eve-post-review.mjs.map +1 -1
  35. package/dist/code-review/github-reporter.d.mts +6 -2
  36. package/dist/code-review/github-reporter.mjs +86 -35
  37. package/dist/code-review/github-reporter.mjs.map +1 -1
  38. package/dist/code-review/preparation.d.mts +2 -1
  39. package/dist/code-review/preparation.mjs +2 -1
  40. package/dist/code-review/preparation.mjs.map +1 -1
  41. package/dist/code-review/stall.mjs +11 -2
  42. package/dist/code-review/stall.mjs.map +1 -1
  43. package/dist/connectors/github.d.mts +1 -1
  44. package/dist/connectors/index.d.mts +1 -1
  45. package/dist/connectors/slack.d.mts +1 -1
  46. package/dist/delivery-metrics/metrics.d.mts +1 -1
  47. package/dist/dispatch.mjs +3 -3
  48. package/dist/dispatch.mjs.map +1 -1
  49. package/dist/eve/index.d.mts +1 -1
  50. package/dist/eve/index.mjs +8 -1
  51. package/dist/eve/index.mjs.map +1 -1
  52. package/dist/eve/task-execution.d.mts +4 -4
  53. package/dist/eve/transcript.d.mts +3 -1
  54. package/dist/eve/transcript.mjs.map +1 -1
  55. package/dist/finding-remediation/admission.d.mts +1 -1
  56. package/dist/finding-remediation/brief.d.mts +1 -1
  57. package/dist/github-app.d.mts +1 -1
  58. package/dist/github-publication.d.mts +1 -1
  59. package/dist/github.d.mts +9 -1
  60. package/dist/github.mjs +29 -11
  61. package/dist/github.mjs.map +1 -1
  62. package/dist/index.d.mts +1 -1
  63. package/dist/intake-contracts.d.mts +1 -0
  64. package/dist/intake-contracts.mjs +2 -1
  65. package/dist/intake-contracts.mjs.map +1 -1
  66. package/dist/integrations/github-issues.d.mts +53 -0
  67. package/dist/integrations/github-issues.mjs +170 -0
  68. package/dist/integrations/github-issues.mjs.map +1 -0
  69. package/dist/integrations/github.d.mts +2 -1
  70. package/dist/integrations/github.mjs +2 -1
  71. package/dist/multi-repository-changes/coordination.mjs +1 -1
  72. package/dist/planning/reconcile.mjs +15 -2
  73. package/dist/planning/reconcile.mjs.map +1 -1
  74. package/dist/postgres/index.d.mts +2 -1
  75. package/dist/postgres/index.mjs +11 -5
  76. package/dist/postgres/index.mjs.map +1 -1
  77. package/dist/postgres/indexed-codec.mjs +137 -0
  78. package/dist/postgres/indexed-codec.mjs.map +1 -0
  79. package/dist/postgres/indexed-schema.mjs +99 -0
  80. package/dist/postgres/indexed-schema.mjs.map +1 -0
  81. package/dist/postgres/indexed.d.mts +28 -0
  82. package/dist/postgres/indexed.mjs +277 -0
  83. package/dist/postgres/indexed.mjs.map +1 -0
  84. package/dist/postgres/record-predicates.mjs +23 -0
  85. package/dist/postgres/record-predicates.mjs.map +1 -0
  86. package/dist/presets/software-development/deepsec-brief.d.mts +1 -1
  87. package/dist/presets/software-development/dispatch.mjs +1 -1
  88. package/dist/presets/software-development/dispatch.mjs.map +1 -1
  89. package/dist/presets/software-development/recovery.mjs +9 -2
  90. package/dist/presets/software-development/recovery.mjs.map +1 -1
  91. package/dist/pull-requests/eve-fetch.d.mts +4 -1
  92. package/dist/pull-requests/eve-fetch.mjs +9 -0
  93. package/dist/pull-requests/eve-fetch.mjs.map +1 -1
  94. package/dist/pull-requests/github-publisher.d.mts +1 -1
  95. package/dist/pull-requests/github-publisher.mjs +19 -7
  96. package/dist/pull-requests/github-publisher.mjs.map +1 -1
  97. package/dist/repositories.mjs +20 -13
  98. package/dist/repositories.mjs.map +1 -1
  99. package/dist/sandbox/execution-run-ledger.d.mts +2 -2
  100. package/dist/sandbox/execution-run-ledger.mjs.map +1 -1
  101. package/dist/sandbox/execution.d.mts +2 -2
  102. package/dist/sandbox/execution.mjs.map +1 -1
  103. package/dist/schema/catalog.mjs +1 -1
  104. package/dist/schema/change.d.mts +1 -1
  105. package/dist/schema/communication.d.mts +2 -2
  106. package/dist/schema/factory-config.d.mts +1 -1
  107. package/dist/schema/outbox.d.mts +6 -6
  108. package/dist/schema/session-summary.d.mts +218 -0
  109. package/dist/schema/session-summary.mjs +68 -0
  110. package/dist/schema/session-summary.mjs.map +1 -0
  111. package/dist/schema/session.d.mts +39 -59
  112. package/dist/schema/session.mjs +6 -6
  113. package/dist/schema/session.mjs.map +1 -1
  114. package/dist/schema/task-graph.d.mts +24 -24
  115. package/dist/schema/transcript.d.mts +141 -3
  116. package/dist/schema/transcript.mjs +19 -3
  117. package/dist/schema/transcript.mjs.map +1 -1
  118. package/dist/schema/transitions.d.mts +1 -1
  119. package/dist/schema/transitions.mjs +1 -1
  120. package/dist/schema/transitions.mjs.map +1 -1
  121. package/dist/signals.d.mts +1 -1
  122. package/dist/stall.mjs +10 -2
  123. package/dist/stall.mjs.map +1 -1
  124. package/dist/storage.d.mts +10 -1
  125. package/dist/storage.mjs +7 -1
  126. package/dist/store/approvals.d.mts +14 -0
  127. package/dist/store/approvals.mjs +78 -0
  128. package/dist/store/approvals.mjs.map +1 -0
  129. package/dist/store/conversations.d.mts +59 -0
  130. package/dist/store/conversations.mjs +549 -0
  131. package/dist/store/conversations.mjs.map +1 -0
  132. package/dist/store/driver.d.mts +1 -1
  133. package/dist/store/driver.mjs.map +1 -1
  134. package/dist/store/engine.d.mts +38 -16
  135. package/dist/store/engine.mjs +229 -106
  136. package/dist/store/engine.mjs.map +1 -1
  137. package/dist/store/indexed-engine.d.mts +57 -0
  138. package/dist/store/indexed-engine.mjs +155 -0
  139. package/dist/store/indexed-engine.mjs.map +1 -0
  140. package/dist/store/indexed-memory.d.mts +7 -0
  141. package/dist/store/indexed-memory.mjs +200 -0
  142. package/dist/store/indexed-memory.mjs.map +1 -0
  143. package/dist/store/indexed-projections.d.mts +280 -0
  144. package/dist/store/indexed-projections.mjs +481 -0
  145. package/dist/store/indexed-projections.mjs.map +1 -0
  146. package/dist/store/indexed.d.mts +101 -0
  147. package/dist/store/indexed.mjs +19 -0
  148. package/dist/store/indexed.mjs.map +1 -0
  149. package/dist/store/iterate.d.mts +9 -0
  150. package/dist/store/iterate.mjs +23 -0
  151. package/dist/store/iterate.mjs.map +1 -0
  152. package/dist/store/query-scope.mjs +62 -0
  153. package/dist/store/query-scope.mjs.map +1 -0
  154. package/dist/store/query.d.mts +32 -0
  155. package/dist/store/query.mjs +103 -0
  156. package/dist/store/query.mjs.map +1 -0
  157. package/dist/store/session-history.mjs +24 -0
  158. package/dist/store/session-history.mjs.map +1 -0
  159. package/dist/store/slack-pr-notifications.d.mts +2 -2
  160. package/dist/store/slack-pr-notifications.mjs.map +1 -1
  161. package/dist/store/state.d.mts +26 -0
  162. package/dist/store/state.mjs +95 -0
  163. package/dist/store/state.mjs.map +1 -0
  164. package/dist/store/task-effects.d.mts +1 -1
  165. package/dist/store/task-graphs.d.mts +1 -1
  166. package/dist/store/task-messages.d.mts +1 -1
  167. package/dist/store/task-work.d.mts +1 -1
  168. package/dist/store/task-work.mjs +1 -1
  169. package/dist/store/transcripts.mjs +308 -0
  170. package/dist/store/transcripts.mjs.map +1 -0
  171. package/dist/sweep.d.mts +1 -1
  172. package/dist/sweep.mjs +12 -7
  173. package/dist/sweep.mjs.map +1 -1
  174. package/dist/task-communication.mjs +15 -1
  175. package/dist/task-communication.mjs.map +1 -1
  176. package/dist/task-protocols.d.mts +3 -3
  177. package/dist/tasks.d.mts +1 -1
  178. package/dist/vercel.d.mts +1 -1
  179. package/dist/work-triage/find-existing-work.d.mts +1 -1
  180. package/dist/work-triage/find-existing-work.mjs +12 -2
  181. package/dist/work-triage/find-existing-work.mjs.map +1 -1
  182. package/docs/index.md +4 -0
  183. package/docs/recipes/persistence-recovery.md +15 -9
  184. package/docs/recipes/postgres-indexed-engine.md +108 -0
  185. package/docs/recipes/postgres-indexed-storage.md +145 -0
  186. package/package.json +3 -1
@@ -0,0 +1,68 @@
1
+ import { taskIdSchema } from "./id.mjs";
2
+ import { executionReferenceSchema, taskSchema } from "./task.mjs";
3
+ import { agentSessionBaseSchema } from "./session.mjs";
4
+ import { z } from "zod";
5
+ //#region src/schema/session-summary.ts
6
+ /** Conversation-wide operator status derived from current work and human-action gates. */
7
+ const conversationStatusSchema = z.enum([
8
+ "working",
9
+ "delegated",
10
+ "verifying",
11
+ "needs_input",
12
+ "awaiting_approval",
13
+ "ready",
14
+ "failed",
15
+ "stalled"
16
+ ]);
17
+ /** Compact Task fields needed to render a conversation card, without execution inputs or outputs. */
18
+ const sessionTaskSummarySchema = z.object(taskSchema.shape).pick({
19
+ id: true,
20
+ kind: true,
21
+ state: true,
22
+ rootTaskId: true,
23
+ parentTaskId: true,
24
+ repositoryIds: true,
25
+ replyTo: true,
26
+ approval: true,
27
+ attempt: true,
28
+ changeId: true,
29
+ createdAt: true,
30
+ updatedAt: true,
31
+ needsHumanAction: true,
32
+ stalledReason: true
33
+ }).strip().extend({ work: z.object({
34
+ title: z.string().max(256),
35
+ route: taskSchema.shape.work.shape.route
36
+ }).describe("Display title and exact route; excludes input and output.") });
37
+ /** A conversation card deliberately excludes canonical Task bodies, histories, and transcript content. */
38
+ const conversationSummarySchema = z.object({
39
+ session: agentSessionBaseSchema.strip().extend({ message: z.string().max(256).describe("Truncated initial request for display.") }).describe("Compact conversation binding; fetch the session for the complete request."),
40
+ task: sessionTaskSummarySchema.nullable().describe("Selected Task display state."),
41
+ question: z.object(taskSchema.shape).pick({
42
+ id: true,
43
+ updatedAt: true,
44
+ question: true
45
+ }).strip().nullable().describe("Current validated workflow question."),
46
+ execution: executionReferenceSchema.nullable().describe("Current provider execution."),
47
+ activeAgent: z.string().optional().describe("Current executing agent."),
48
+ source: z.string().optional().describe("Automatic work origin."),
49
+ prUrl: z.string().optional().describe("Associated pull request."),
50
+ attention: z.enum([
51
+ "question",
52
+ "failed",
53
+ "stalled",
54
+ "review",
55
+ "conversation"
56
+ ]).optional().describe("Deduplicated conversation attention reason."),
57
+ status: conversationStatusSchema.optional().describe("Current conversation-wide work and human-action status."),
58
+ statusRevision: z.string().length(64).optional().describe("Opaque revision that changes when status-relevant conversation work changes."),
59
+ hasWorkflowFailure: z.boolean().optional().describe("Delegated workflow failure."),
60
+ canCancel: z.boolean().optional().describe("Whether this conversation has cancellable work."),
61
+ canFollowUp: z.boolean().optional().describe("Whether follow-up discussion is configured."),
62
+ dependencyTaskIds: z.array(taskIdSchema).readonly().optional().describe("Current graph dependencies."),
63
+ relatedTasks: z.array(sessionTaskSummarySchema).readonly().optional().describe("Optional bounded related Task summaries.")
64
+ });
65
+ //#endregion
66
+ export { conversationStatusSchema, conversationSummarySchema, sessionTaskSummarySchema };
67
+
68
+ //# sourceMappingURL=session-summary.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-summary.mjs","names":[],"sources":["../../src/schema/session-summary.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { agentSessionBaseSchema } from \"./session\";\nimport { taskSchema, executionReferenceSchema } from \"./task\";\nimport { taskIdSchema } from \"./id\";\n\n/** Conversation-wide operator status derived from current work and human-action gates. */\nexport const conversationStatusSchema = z.enum([\n \"working\",\n \"delegated\",\n \"verifying\",\n \"needs_input\",\n \"awaiting_approval\",\n \"ready\",\n \"failed\",\n \"stalled\",\n]);\n/** Conversation-wide operator status, independent of provider transcript vocabulary. */\nexport type ConversationStatus = z.infer<typeof conversationStatusSchema>;\n\n/** Compact Task fields needed to render a conversation card, without execution inputs or outputs. */\nexport const sessionTaskSummarySchema = z\n .object(taskSchema.shape)\n .pick({\n id: true,\n kind: true,\n state: true,\n rootTaskId: true,\n parentTaskId: true,\n repositoryIds: true,\n replyTo: true,\n approval: true,\n attempt: true,\n changeId: true,\n createdAt: true,\n updatedAt: true,\n needsHumanAction: true,\n stalledReason: true,\n })\n .strip()\n .extend({\n work: z\n .object({ title: z.string().max(256), route: taskSchema.shape.work.shape.route })\n .describe(\"Display title and exact route; excludes input and output.\"),\n });\n/** Compact Task state on an operator conversation card. */\nexport type SessionTaskSummary = z.infer<typeof sessionTaskSummarySchema>;\n\n/** A conversation card deliberately excludes canonical Task bodies, histories, and transcript content. */\nexport const conversationSummarySchema = z.object({\n session: agentSessionBaseSchema\n .strip()\n .extend({\n message: z.string().max(256).describe(\"Truncated initial request for display.\"),\n })\n .describe(\"Compact conversation binding; fetch the session for the complete request.\"),\n task: sessionTaskSummarySchema.nullable().describe(\"Selected Task display state.\"),\n question: z\n .object(taskSchema.shape)\n .pick({ id: true, updatedAt: true, question: true })\n .strip()\n .nullable()\n .describe(\"Current validated workflow question.\"),\n execution: executionReferenceSchema.nullable().describe(\"Current provider execution.\"),\n activeAgent: z.string().optional().describe(\"Current executing agent.\"),\n source: z.string().optional().describe(\"Automatic work origin.\"),\n prUrl: z.string().optional().describe(\"Associated pull request.\"),\n attention: z\n .enum([\"question\", \"failed\", \"stalled\", \"review\", \"conversation\"])\n .optional()\n .describe(\"Deduplicated conversation attention reason.\"),\n status: conversationStatusSchema\n .optional()\n .describe(\"Current conversation-wide work and human-action status.\"),\n statusRevision: z\n .string()\n .length(64)\n .optional()\n .describe(\"Opaque revision that changes when status-relevant conversation work changes.\"),\n hasWorkflowFailure: z.boolean().optional().describe(\"Delegated workflow failure.\"),\n canCancel: z.boolean().optional().describe(\"Whether this conversation has cancellable work.\"),\n canFollowUp: z.boolean().optional().describe(\"Whether follow-up discussion is configured.\"),\n dependencyTaskIds: z\n .array(taskIdSchema)\n .readonly()\n .optional()\n .describe(\"Current graph dependencies.\"),\n relatedTasks: z\n .array(sessionTaskSummarySchema)\n .readonly()\n .optional()\n .describe(\"Optional bounded related Task summaries.\"),\n});\n/** Stored conversation card before request-time operator enrichment. */\nexport type ConversationSummary = z.infer<typeof conversationSummarySchema>;\n"],"mappings":";;;;;;AAMA,MAAa,2BAA2B,EAAE,KAAK;CAC7C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAKD,MAAa,2BAA2B,EACrC,OAAO,WAAW,KAAK,CAAC,CACxB,KAAK;CACJ,IAAI;CACJ,MAAM;CACN,OAAO;CACP,YAAY;CACZ,cAAc;CACd,eAAe;CACf,SAAS;CACT,UAAU;CACV,SAAS;CACT,UAAU;CACV,WAAW;CACX,WAAW;CACX,kBAAkB;CAClB,eAAe;AACjB,CAAC,CAAC,CACD,MAAM,CAAC,CACP,OAAO,EACN,MAAM,EACH,OAAO;CAAE,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,GAAG;CAAG,OAAO,WAAW,MAAM,KAAK,MAAM;AAAM,CAAC,CAAC,CAChF,SAAS,2DAA2D,EACzE,CAAC;;AAKH,MAAa,4BAA4B,EAA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C/B,SAAS,CAAC,CACV,SAAS,CAAC,CACV,SAAS,0CAA0C;AACxD,CAAC"}
@@ -4,6 +4,38 @@ import { z } from "zod";
4
4
  declare const agentSessionIdSchema: z.ZodType<`ses_${string}`, string>;
5
5
  /** Stable Factory interaction identifier independent of provider session IDs. */
6
6
  type AgentSessionId = z.infer<typeof agentSessionIdSchema>;
7
+ /** Validates one separately stored, idempotent conversation follow-up. */
8
+ declare const sessionContinuationSchema: z.ZodReadonly<z.ZodObject<{
9
+ operationId: z.ZodString;
10
+ taskId: z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
11
+ parentTaskId: z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
12
+ agent: z.ZodString;
13
+ message: z.ZodString;
14
+ attachments: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
15
+ id: z.ZodType<`img_${string}`, string, z.core.$ZodTypeInternals<`img_${string}`, string>>;
16
+ filename: z.ZodString;
17
+ mediaType: z.ZodEnum<{
18
+ "image/png": "image/png";
19
+ "image/jpeg": "image/jpeg";
20
+ "image/webp": "image/webp";
21
+ }>;
22
+ size: z.ZodNumber;
23
+ }, z.core.$strict>>>>;
24
+ contextAttachments: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
25
+ id: z.ZodType<`img_${string}`, string, z.core.$ZodTypeInternals<`img_${string}`, string>>;
26
+ filename: z.ZodString;
27
+ mediaType: z.ZodEnum<{
28
+ "image/png": "image/png";
29
+ "image/jpeg": "image/jpeg";
30
+ "image/webp": "image/webp";
31
+ }>;
32
+ size: z.ZodNumber;
33
+ }, z.core.$strict>>>>;
34
+ context: z.ZodOptional<z.ZodString>;
35
+ createdAt: z.ZodISODateTime;
36
+ }, z.core.$strict>>;
37
+ /** One durable follow-up intent, including its separately persisted recovery context. */
38
+ type SessionContinuation = z.infer<typeof sessionContinuationSchema>;
7
39
  /** Base object fields used to decode current and legacy session snapshots. */
8
40
  declare const agentSessionBaseSchema: z.ZodObject<{
9
41
  schemaVersion: z.ZodLiteral<1>;
@@ -30,35 +62,7 @@ declare const agentSessionBaseSchema: z.ZodObject<{
30
62
  changeId: z.ZodOptional<z.ZodType<`chg_${string}`, string, z.core.$ZodTypeInternals<`chg_${string}`, string>>>;
31
63
  taskId: z.ZodOptional<z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>>;
32
64
  attached: z.ZodOptional<z.ZodBoolean>;
33
- continuations: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
34
- operationId: z.ZodString;
35
- taskId: z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
36
- parentTaskId: z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
37
- agent: z.ZodString;
38
- message: z.ZodString;
39
- attachments: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
40
- id: z.ZodType<`img_${string}`, string, z.core.$ZodTypeInternals<`img_${string}`, string>>;
41
- filename: z.ZodString;
42
- mediaType: z.ZodEnum<{
43
- "image/png": "image/png";
44
- "image/jpeg": "image/jpeg";
45
- "image/webp": "image/webp";
46
- }>;
47
- size: z.ZodNumber;
48
- }, z.core.$strict>>>>;
49
- contextAttachments: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
50
- id: z.ZodType<`img_${string}`, string, z.core.$ZodTypeInternals<`img_${string}`, string>>;
51
- filename: z.ZodString;
52
- mediaType: z.ZodEnum<{
53
- "image/png": "image/png";
54
- "image/jpeg": "image/jpeg";
55
- "image/webp": "image/webp";
56
- }>;
57
- size: z.ZodNumber;
58
- }, z.core.$strict>>>>;
59
- context: z.ZodOptional<z.ZodString>;
60
- createdAt: z.ZodISODateTime;
61
- }, z.core.$strict>>>>>;
65
+ latestContinuationId: z.ZodOptional<z.ZodString>;
62
66
  execution: z.ZodOptional<z.ZodObject<{
63
67
  provider: z.ZodString;
64
68
  sessionId: z.ZodString;
@@ -74,42 +78,18 @@ declare const agentSessionBaseSchema: z.ZodObject<{
74
78
  repositoryIds: z.ZodReadonly<z.ZodTuple<[z.ZodType<`repo_${string}`, string, z.core.$ZodTypeInternals<`repo_${string}`, string>>], z.ZodType<`repo_${string}`, string, z.core.$ZodTypeInternals<`repo_${string}`, string>>>>;
75
79
  url: z.ZodOptional<z.ZodURL>;
76
80
  }, z.core.$strict>>>;
77
- notifications: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodObject<{
78
- eventId: z.ZodString;
79
- repositoryIds: z.ZodReadonly<z.ZodTuple<[z.ZodType<`repo_${string}`, string, z.core.$ZodTypeInternals<`repo_${string}`, string>>], z.ZodType<`repo_${string}`, string, z.core.$ZodTypeInternals<`repo_${string}`, string>>>>;
80
- taskId: z.ZodOptional<z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>>;
81
- changeId: z.ZodOptional<z.ZodType<`chg_${string}`, string, z.core.$ZodTypeInternals<`chg_${string}`, string>>>;
82
- replyTo: z.ZodObject<{
83
- channel: z.ZodString;
84
- address: z.ZodString;
85
- }, z.core.$strict>;
86
- outcome: z.ZodEnum<{
87
- message: "message";
88
- succeeded: "succeeded";
89
- failed: "failed";
90
- needs_human: "needs_human";
91
- cancelled: "cancelled";
92
- accepted: "accepted";
93
- question: "question";
94
- rolled_back: "rolled_back";
95
- started: "started";
96
- digest: "digest";
97
- budget_warning: "budget_warning";
98
- budget_exhausted: "budget_exhausted";
99
- }>;
100
- data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
101
- }, z.core.$strict>>>>;
81
+ latestNotificationId: z.ZodOptional<z.ZodString>;
102
82
  createdAt: z.ZodISODateTime;
103
83
  }, z.core.$strict>;
104
84
  type AgentSessionBase = Readonly<z.infer<typeof agentSessionBaseSchema>>;
105
- type BindingKeys = "taskId" | "execution" | "external" | "route" | "continuations";
85
+ type BindingKeys = "taskId" | "execution" | "external" | "route" | "latestContinuationId";
106
86
  /** Durable session bound to workflow-owned Task work. */
107
87
  type TaskAgentSession = Readonly<Omit<AgentSessionBase, BindingKeys> & {
108
88
  taskId: NonNullable<AgentSessionBase["taskId"]>;
109
89
  execution?: never;
110
90
  external?: never;
111
91
  route?: AgentSessionBase["route"];
112
- continuations?: AgentSessionBase["continuations"];
92
+ latestContinuationId?: AgentSessionBase["latestContinuationId"];
113
93
  }>;
114
94
  /** Durable internal conversation whose provider execution is stored directly. */
115
95
  type DirectAgentSession = Readonly<Omit<AgentSessionBase, BindingKeys> & {
@@ -117,7 +97,7 @@ type DirectAgentSession = Readonly<Omit<AgentSessionBase, BindingKeys> & {
117
97
  execution?: AgentSessionBase["execution"];
118
98
  external?: never;
119
99
  route?: AgentSessionBase["route"];
120
- continuations?: AgentSessionBase["continuations"];
100
+ latestContinuationId?: AgentSessionBase["latestContinuationId"];
121
101
  }>;
122
102
  /** Durable external conversation with a required direct provider execution. */
123
103
  type ExternalAgentSession = Readonly<Omit<AgentSessionBase, BindingKeys> & {
@@ -125,12 +105,12 @@ type ExternalAgentSession = Readonly<Omit<AgentSessionBase, BindingKeys> & {
125
105
  execution: NonNullable<AgentSessionBase["execution"]>;
126
106
  external: NonNullable<AgentSessionBase["external"]>;
127
107
  route?: never;
128
- continuations?: never;
108
+ latestContinuationId?: never;
129
109
  }>;
130
110
  /** Durable interaction whose binding fields identify task, direct, or external ownership. */
131
111
  type AgentSession = TaskAgentSession | DirectAgentSession | ExternalAgentSession;
132
112
  /** Validates a persisted session and rejects contradictory task, execution, and external bindings. */
133
113
  declare const agentSessionSchema: z.ZodType<AgentSession>;
134
114
  //#endregion
135
- export { AgentSession, AgentSessionId, DirectAgentSession, ExternalAgentSession, TaskAgentSession, agentSessionBaseSchema, agentSessionIdSchema, agentSessionSchema };
115
+ export { AgentSession, AgentSessionId, DirectAgentSession, ExternalAgentSession, SessionContinuation, TaskAgentSession, agentSessionBaseSchema, agentSessionIdSchema, agentSessionSchema, sessionContinuationSchema };
136
116
  //# sourceMappingURL=session.d.mts.map
@@ -3,14 +3,14 @@ import { isoDateTimeSchema, replyToSchema, schemaVersionSchema } from "./common.
3
3
  import { agentRouteBindingSchema } from "./agent-route.mjs";
4
4
  import { executionReferenceSchema } from "./task.mjs";
5
5
  import { hasMessageContent, imageAttachmentsSchema } from "../image-input.mjs";
6
- import { communicationEventSchema } from "./communication.mjs";
7
6
  import { z } from "zod";
8
7
  //#region src/schema/session.ts
9
8
  /** Validates a stable Factory interaction identifier distinct from provider sessions. */
10
9
  const agentSessionIdSchema = z.string().regex(/^ses_[a-z0-9]{6,64}$/u, "Expected ses_ followed by 6 to 64 lowercase letters or digits").describe("Stable Factory interaction ID; independent of provider session IDs.");
11
10
  /** Validates the initial human request retained by a Factory session. */
12
11
  const agentSessionMessageSchema = z.string().max(16e3).describe("Initial request, retained for idempotent admission and recovery.");
13
- const continuationSchema = z.strictObject({
12
+ /** Validates one separately stored, idempotent conversation follow-up. */
13
+ const sessionContinuationSchema = z.strictObject({
14
14
  operationId: z.string().min(1).max(200).describe("Idempotency key for this follow-up."),
15
15
  taskId: taskIdSchema.describe("Budgeted investigation answering this follow-up."),
16
16
  parentTaskId: taskIdSchema.describe("Earlier work being discussed."),
@@ -40,15 +40,15 @@ const agentSessionBaseSchema = z.strictObject({
40
40
  changeId: changeIdSchema.optional().describe("Existing change selected for this work."),
41
41
  taskId: taskIdSchema.optional().describe("Workflow-owned task and authoritative execution binding."),
42
42
  attached: z.boolean().optional().describe("Operator view of existing work that preserves its original origin and reply destination."),
43
- continuations: z.array(continuationSchema).readonly().optional().describe("Ordered immutable follow-up intents, each with separate work and usage."),
43
+ latestContinuationId: z.string().regex(/^scont_[a-f0-9]{32}$/u).optional().describe("Latest committed follow-up intent; earlier intents are separately paginated."),
44
44
  execution: executionReferenceSchema.optional().describe("Provider reference for taskless conversations only."),
45
45
  external: externalConversationSchema.optional().describe("Read-only projection of an externally admitted taskless conversation."),
46
- notifications: z.array(communicationEventSchema).readonly().default([]).describe("Durable connector deliveries, deduplicated by eventId."),
46
+ latestNotificationId: z.string().regex(/^snotice_[a-f0-9]{32}$/u).optional().describe("Latest notification identity; notification bodies are separately paginated."),
47
47
  createdAt: isoDateTimeSchema
48
48
  });
49
49
  /** Validates a persisted session and rejects contradictory task, execution, and external bindings. */
50
- const agentSessionSchema = agentSessionBaseSchema.refine(hasMessageContent, "Enter a message or attach an image").refine((session) => session.taskId === void 0 || session.execution === void 0, "A session binds either a task or a conversation execution").refine((session) => session.external === void 0 || session.execution !== void 0 && session.taskId === void 0 && session.continuations === void 0 && session.route === void 0, "An external conversation requires an execution and cannot bind a Task, route, or continuations");
50
+ const agentSessionSchema = agentSessionBaseSchema.refine(hasMessageContent, "Enter a message or attach an image").refine((session) => session.taskId === void 0 || session.execution === void 0, "A session binds either a task or a conversation execution").refine((session) => session.external === void 0 || session.execution !== void 0 && session.taskId === void 0 && session.latestContinuationId === void 0 && session.route === void 0, "An external conversation requires an execution and cannot bind a Task, route, or continuations");
51
51
  //#endregion
52
- export { agentSessionBaseSchema, agentSessionIdSchema, agentSessionMessageSchema, agentSessionSchema };
52
+ export { agentSessionBaseSchema, agentSessionIdSchema, agentSessionMessageSchema, agentSessionSchema, sessionContinuationSchema };
53
53
 
54
54
  //# sourceMappingURL=session.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.mjs","names":[],"sources":["../../src/schema/session.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { hasMessageContent, imageAttachmentsSchema } from \"../image-input\";\nimport { communicationEventSchema } from \"./communication\";\nimport { isoDateTimeSchema, replyToSchema, schemaVersionSchema } from \"./common\";\nimport { changeIdSchema, repositoryIdSchema, repositoryIdsSchema, taskIdSchema } from \"./id\";\nimport { agentRouteBindingSchema } from \"./agent-route\";\nimport { executionReferenceSchema } from \"./task\";\n\n/** Validates a stable Factory interaction identifier distinct from provider sessions. */\nexport const agentSessionIdSchema = z\n .string()\n .regex(/^ses_[a-z0-9]{6,64}$/u, \"Expected ses_ followed by 6 to 64 lowercase letters or digits\")\n .describe(\"Stable Factory interaction ID; independent of provider session IDs.\") as z.ZodType<\n `ses_${string}`,\n string\n>;\n/** Stable Factory interaction identifier independent of provider session IDs. */\nexport type AgentSessionId = z.infer<typeof agentSessionIdSchema>;\n\n/** Validates the initial human request retained by a Factory session. */\nexport const agentSessionMessageSchema = z\n .string()\n .max(16000)\n .describe(\"Initial request, retained for idempotent admission and recovery.\");\n\nconst continuationSchema = z\n .strictObject({\n operationId: z.string().min(1).max(200).describe(\"Idempotency key for this follow-up.\"),\n taskId: taskIdSchema.describe(\"Budgeted investigation answering this follow-up.\"),\n parentTaskId: taskIdSchema.describe(\"Earlier work being discussed.\"),\n agent: z.string().min(1).describe(\"Conversation agent handling this follow-up.\"),\n message: z.string().max(16000).describe(\"Operator's follow-up request.\"),\n attachments: imageAttachmentsSchema.optional().describe(\"Images accompanying this follow-up.\"),\n contextAttachments: imageAttachmentsSchema\n .optional()\n .describe(\"Earlier images selected with the cached conversation context.\"),\n context: z\n .string()\n .max(80000)\n .optional()\n .describe(\"Bounded conversation context captured before launch and retained for recovery.\"),\n createdAt: isoDateTimeSchema,\n })\n .refine(hasMessageContent, \"Enter a message or attach an image\")\n .readonly();\n\nconst externalConversationSchema = z\n .strictObject({\n replyTo: replyToSchema.describe(\n \"Original external conversation destination; never rewritten by the console.\",\n ),\n repositoryIds: repositoryIdsSchema.describe(\n \"Repositories authorized for this external conversation.\",\n ),\n url: z\n .url({ protocol: /^https$/u })\n .optional()\n .describe(\"HTTPS link to the original conversation.\"),\n })\n .readonly();\n\n/** Base object fields used to decode current and legacy session snapshots. */\nexport const agentSessionBaseSchema = z.strictObject({\n schemaVersion: schemaVersionSchema,\n id: agentSessionIdSchema,\n owner: z.string().min(1).describe(\"Authenticated principal owning this interaction.\"),\n agent: z\n .string()\n .regex(/^[a-z][a-z0-9-]{0,31}$/u)\n .describe(\"Selected application agent.\"),\n repositoryId: repositoryIdSchema\n .optional()\n .describe(\"Configured repository selected for this interaction.\"),\n route: agentRouteBindingSchema\n .optional()\n .describe(\"Exact specialist route selected when this session was admitted.\"),\n message: agentSessionMessageSchema,\n model: z\n .string()\n .trim()\n .min(1)\n .max(200)\n .optional()\n .describe(\"Opaque model selected at admission; unchanged by later repository defaults.\"),\n attachments: imageAttachmentsSchema\n .optional()\n .describe(\"Images accompanying the initial request.\"),\n changeId: changeIdSchema.optional().describe(\"Existing change selected for this work.\"),\n taskId: taskIdSchema\n .optional()\n .describe(\"Workflow-owned task and authoritative execution binding.\"),\n attached: z\n .boolean()\n .optional()\n .describe(\n \"Operator view of existing work that preserves its original origin and reply destination.\",\n ),\n continuations: z\n .array(continuationSchema)\n .readonly()\n .optional()\n .describe(\"Ordered immutable follow-up intents, each with separate work and usage.\"),\n execution: executionReferenceSchema\n .optional()\n .describe(\"Provider reference for taskless conversations only.\"),\n external: externalConversationSchema\n .optional()\n .describe(\"Read-only projection of an externally admitted taskless conversation.\"),\n notifications: z\n .array(communicationEventSchema)\n .readonly()\n .default([])\n .describe(\"Durable connector deliveries, deduplicated by eventId.\"),\n createdAt: isoDateTimeSchema,\n});\n\ntype AgentSessionBase = Readonly<z.infer<typeof agentSessionBaseSchema>>;\ntype BindingKeys = \"taskId\" | \"execution\" | \"external\" | \"route\" | \"continuations\";\n\n/** Durable session bound to workflow-owned Task work. */\nexport type TaskAgentSession = Readonly<\n Omit<AgentSessionBase, BindingKeys> & {\n taskId: NonNullable<AgentSessionBase[\"taskId\"]>;\n execution?: never;\n external?: never;\n route?: AgentSessionBase[\"route\"];\n continuations?: AgentSessionBase[\"continuations\"];\n }\n>;\n\n/** Durable internal conversation whose provider execution is stored directly. */\nexport type DirectAgentSession = Readonly<\n Omit<AgentSessionBase, BindingKeys> & {\n taskId?: never;\n execution?: AgentSessionBase[\"execution\"];\n external?: never;\n route?: AgentSessionBase[\"route\"];\n continuations?: AgentSessionBase[\"continuations\"];\n }\n>;\n\n/** Durable external conversation with a required direct provider execution. */\nexport type ExternalAgentSession = Readonly<\n Omit<AgentSessionBase, BindingKeys> & {\n taskId?: never;\n execution: NonNullable<AgentSessionBase[\"execution\"]>;\n external: NonNullable<AgentSessionBase[\"external\"]>;\n route?: never;\n continuations?: never;\n }\n>;\n\n/** Durable interaction whose binding fields identify task, direct, or external ownership. */\nexport type AgentSession = TaskAgentSession | DirectAgentSession | ExternalAgentSession;\n\n/** Validates a persisted session and rejects contradictory task, execution, and external bindings. */\nexport const agentSessionSchema = agentSessionBaseSchema\n .refine(hasMessageContent, \"Enter a message or attach an image\")\n .refine(\n (session) => session.taskId === undefined || session.execution === undefined,\n \"A session binds either a task or a conversation execution\",\n )\n .refine(\n (session) =>\n session.external === undefined ||\n (session.execution !== undefined &&\n session.taskId === undefined &&\n session.continuations === undefined &&\n session.route === undefined),\n \"An external conversation requires an execution and cannot bind a Task, route, or continuations\",\n ) as z.ZodType<AgentSession>;\n"],"mappings":";;;;;;;;;AASA,MAAa,uBAAuB,EACjC,OAAO,CAAC,CACR,MAAM,yBAAyB,+DAA+D,CAAC,CAC/F,SAAS,qEAAqE;;AAQjF,MAAa,4BAA4B,EACtC,OAAO,CAAC,CACR,IAAI,IAAK,CAAC,CACV,SAAS,kEAAkE;AAE9E,MAAM,qBAAqB,EACxB,aAAa;CACZ,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS,qCAAqC;CACtF,QAAQ,aAAa,SAAS,kDAAkD;CAChF,cAAc,aAAa,SAAS,+BAA+B;CACnE,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,6CAA6C;CAC/E,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,IAAK,CAAC,CAAC,SAAS,+BAA+B;CACvE,aAAa,uBAAuB,SAAS,CAAC,CAAC,SAAS,qCAAqC;CAC7F,oBAAoB,uBACjB,SAAS,CAAC,CACV,SAAS,+DAA+D;CAC3E,SAAS,EACN,OAAO,CAAC,C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CAAC,CAC/B,SAAS,CAAC,CACV,QAAQ,CAAC,CAAC,CAAC,CACX,SAAS,wDAAwD;CACpE,WAAW;AACb,CAAC;;AA0CD,MAAa,qBAAqB,uBAC/B,OAAO,mBAAmB,oCAAoC,CAAC,CAC/D,QACE,YAAY,QAAQ,WAAW,KAAA,KAAa,QAAQ,cAAc,KAAA,GACnE,2DACF,CAAC,CACA,QACE,YACC,QAAQ,aAAa,KAAA,KACpB,QAAQ,cAAc,KAAA,KACrB,QAAQ,WAAW,KAAA,KACnB,QAAQ,kBAAkB,KAAA,KAC1B,QAAQ,UAAU,KAAA,GACtB,gGACF"}
1
+ {"version":3,"file":"session.mjs","names":[],"sources":["../../src/schema/session.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { hasMessageContent, imageAttachmentsSchema } from \"../image-input\";\nimport { isoDateTimeSchema, replyToSchema, schemaVersionSchema } from \"./common\";\nimport { changeIdSchema, repositoryIdSchema, repositoryIdsSchema, taskIdSchema } from \"./id\";\nimport { agentRouteBindingSchema } from \"./agent-route\";\nimport { executionReferenceSchema } from \"./task\";\n\n/** Validates a stable Factory interaction identifier distinct from provider sessions. */\nexport const agentSessionIdSchema = z\n .string()\n .regex(/^ses_[a-z0-9]{6,64}$/u, \"Expected ses_ followed by 6 to 64 lowercase letters or digits\")\n .describe(\"Stable Factory interaction ID; independent of provider session IDs.\") as z.ZodType<\n `ses_${string}`,\n string\n>;\n/** Stable Factory interaction identifier independent of provider session IDs. */\nexport type AgentSessionId = z.infer<typeof agentSessionIdSchema>;\n\n/** Validates the initial human request retained by a Factory session. */\nexport const agentSessionMessageSchema = z\n .string()\n .max(16000)\n .describe(\"Initial request, retained for idempotent admission and recovery.\");\n\n/** Validates one separately stored, idempotent conversation follow-up. */\nexport const sessionContinuationSchema = z\n .strictObject({\n operationId: z.string().min(1).max(200).describe(\"Idempotency key for this follow-up.\"),\n taskId: taskIdSchema.describe(\"Budgeted investigation answering this follow-up.\"),\n parentTaskId: taskIdSchema.describe(\"Earlier work being discussed.\"),\n agent: z.string().min(1).describe(\"Conversation agent handling this follow-up.\"),\n message: z.string().max(16000).describe(\"Operator's follow-up request.\"),\n attachments: imageAttachmentsSchema.optional().describe(\"Images accompanying this follow-up.\"),\n contextAttachments: imageAttachmentsSchema\n .optional()\n .describe(\"Earlier images selected with the cached conversation context.\"),\n context: z\n .string()\n .max(80000)\n .optional()\n .describe(\"Bounded conversation context captured before launch and retained for recovery.\"),\n createdAt: isoDateTimeSchema,\n })\n .refine(hasMessageContent, \"Enter a message or attach an image\")\n .readonly();\n\n/** One durable follow-up intent, including its separately persisted recovery context. */\nexport type SessionContinuation = z.infer<typeof sessionContinuationSchema>;\n\nconst externalConversationSchema = z\n .strictObject({\n replyTo: replyToSchema.describe(\n \"Original external conversation destination; never rewritten by the console.\",\n ),\n repositoryIds: repositoryIdsSchema.describe(\n \"Repositories authorized for this external conversation.\",\n ),\n url: z\n .url({ protocol: /^https$/u })\n .optional()\n .describe(\"HTTPS link to the original conversation.\"),\n })\n .readonly();\n\n/** Base object fields used to decode current and legacy session snapshots. */\nexport const agentSessionBaseSchema = z.strictObject({\n schemaVersion: schemaVersionSchema,\n id: agentSessionIdSchema,\n owner: z.string().min(1).describe(\"Authenticated principal owning this interaction.\"),\n agent: z\n .string()\n .regex(/^[a-z][a-z0-9-]{0,31}$/u)\n .describe(\"Selected application agent.\"),\n repositoryId: repositoryIdSchema\n .optional()\n .describe(\"Configured repository selected for this interaction.\"),\n route: agentRouteBindingSchema\n .optional()\n .describe(\"Exact specialist route selected when this session was admitted.\"),\n message: agentSessionMessageSchema,\n model: z\n .string()\n .trim()\n .min(1)\n .max(200)\n .optional()\n .describe(\"Opaque model selected at admission; unchanged by later repository defaults.\"),\n attachments: imageAttachmentsSchema\n .optional()\n .describe(\"Images accompanying the initial request.\"),\n changeId: changeIdSchema.optional().describe(\"Existing change selected for this work.\"),\n taskId: taskIdSchema\n .optional()\n .describe(\"Workflow-owned task and authoritative execution binding.\"),\n attached: z\n .boolean()\n .optional()\n .describe(\n \"Operator view of existing work that preserves its original origin and reply destination.\",\n ),\n latestContinuationId: z\n .string()\n .regex(/^scont_[a-f0-9]{32}$/u)\n .optional()\n .describe(\"Latest committed follow-up intent; earlier intents are separately paginated.\"),\n execution: executionReferenceSchema\n .optional()\n .describe(\"Provider reference for taskless conversations only.\"),\n external: externalConversationSchema\n .optional()\n .describe(\"Read-only projection of an externally admitted taskless conversation.\"),\n latestNotificationId: z\n .string()\n .regex(/^snotice_[a-f0-9]{32}$/u)\n .optional()\n .describe(\"Latest notification identity; notification bodies are separately paginated.\"),\n createdAt: isoDateTimeSchema,\n});\n\ntype AgentSessionBase = Readonly<z.infer<typeof agentSessionBaseSchema>>;\ntype BindingKeys = \"taskId\" | \"execution\" | \"external\" | \"route\" | \"latestContinuationId\";\n\n/** Durable session bound to workflow-owned Task work. */\nexport type TaskAgentSession = Readonly<\n Omit<AgentSessionBase, BindingKeys> & {\n taskId: NonNullable<AgentSessionBase[\"taskId\"]>;\n execution?: never;\n external?: never;\n route?: AgentSessionBase[\"route\"];\n latestContinuationId?: AgentSessionBase[\"latestContinuationId\"];\n }\n>;\n\n/** Durable internal conversation whose provider execution is stored directly. */\nexport type DirectAgentSession = Readonly<\n Omit<AgentSessionBase, BindingKeys> & {\n taskId?: never;\n execution?: AgentSessionBase[\"execution\"];\n external?: never;\n route?: AgentSessionBase[\"route\"];\n latestContinuationId?: AgentSessionBase[\"latestContinuationId\"];\n }\n>;\n\n/** Durable external conversation with a required direct provider execution. */\nexport type ExternalAgentSession = Readonly<\n Omit<AgentSessionBase, BindingKeys> & {\n taskId?: never;\n execution: NonNullable<AgentSessionBase[\"execution\"]>;\n external: NonNullable<AgentSessionBase[\"external\"]>;\n route?: never;\n latestContinuationId?: never;\n }\n>;\n\n/** Durable interaction whose binding fields identify task, direct, or external ownership. */\nexport type AgentSession = TaskAgentSession | DirectAgentSession | ExternalAgentSession;\n\n/** Validates a persisted session and rejects contradictory task, execution, and external bindings. */\nexport const agentSessionSchema = agentSessionBaseSchema\n .refine(hasMessageContent, \"Enter a message or attach an image\")\n .refine(\n (session) => session.taskId === undefined || session.execution === undefined,\n \"A session binds either a task or a conversation execution\",\n )\n .refine(\n (session) =>\n session.external === undefined ||\n (session.execution !== undefined &&\n session.taskId === undefined &&\n session.latestContinuationId === undefined &&\n session.route === undefined),\n \"An external conversation requires an execution and cannot bind a Task, route, or continuations\",\n ) as z.ZodType<AgentSession>;\n"],"mappings":";;;;;;;;AAQA,MAAa,uBAAuB,EACjC,OAAO,CAAC,CACR,MAAM,yBAAyB,+DAA+D,CAAC,CAC/F,SAAS,qEAAqE;;AAQjF,MAAa,4BAA4B,EACtC,OAAO,CAAC,CACR,IAAI,IAAK,CAAC,CACV,SAAS,kEAAkE;;AAG9E,MAAa,4BAA4B,EACtC,aAAa;CACZ,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS,qCAAqC;CACtF,QAAQ,aAAa,SAAS,kDAAkD;CAChF,cAAc,aAAa,SAAS,+BAA+B;CACnE,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,6CAA6C;CAC/E,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,IAAK,CAAC,CAAC,SAAS,+BAA+B;CACvE,aAAa,uBAAuB,SAAS,CAAC,CAAC,SAAS,qCAAqC;CAC7F,oBAAoB,uBACjB,SAAS,CAAC,CACV,SAAS,+DAA+D;CAC3E,SAAS,EACN,OAAO,CAAC,CACR,IAAI,GAAK,CAAC,CACV,SAAS,CAAC,CACV,SAAS,gFAAgF;CAC5F,WAAW;AACb,CAAC,CAAC,CACD,OAAO,mBAAmB,oCAAoC,CAAC,CAC/D,SAAS;AAKZ,MAAM,6BAA6B,EAChC,aAAa;CACZ,SAAS,cAAc,SACrB,6EACF;CACA,eAAe,oBAAoB,SACjC,yDACF;CACA,KAAK,EACF,IAAI,EAAE,UAAU,WA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