@vercel/factory 0.0.16 → 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 +52 -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 +6 -1
@@ -1 +1 @@
1
- {"version":3,"file":"driver.mjs","names":[],"sources":["../../src/store/driver.ts"],"sourcesContent":["/** Closed set of persistence collections understood by Factory store drivers. */\nexport type CollectionName =\n | \"repositories\"\n | \"signals\"\n | \"tasks\"\n | \"changes\"\n | \"receipts\"\n | \"budgets\"\n | \"answers\"\n | \"sessions\"\n | \"externalSessions\"\n | \"transcripts\"\n | \"images\"\n | \"questionRoutes\"\n | \"taskCatalogs\"\n | \"changeCatalogs\"\n | \"sessionCatalogs\"\n | \"externalSessionCatalogs\"\n | \"taskRoutes\"\n | \"outboxQueues\"\n | \"outboxDeliveries\"\n | \"communicationSettings\"\n | \"taskGraphs\"\n | \"taskMessages\"\n | \"taskEffects\"\n | \"taskInboxes\"\n | \"taskMessageProcessing\"\n | \"taskMessageDecisions\"\n | \"taskMessageDiscards\"\n | \"plannerActivations\"\n | \"plannerCancellations\";\n\n/** Opaque persisted value paired with its compare-and-swap version. */\nexport interface StoredRecord {\n readonly value: unknown;\n readonly version: number;\n}\n\n/** Collection-listing entry containing its storage key and versioned record. */\nexport interface StoredEntry {\n readonly id: string;\n readonly record: StoredRecord;\n}\n\n/** Collection, storage key, and opaque value for one insert-only write. */\nexport interface InsertStoreRecordInput {\n readonly collection: CollectionName;\n readonly id: string;\n readonly value: unknown;\n}\n\n/** Collection, storage key, opaque value, and compare-and-swap version for one update. */\nexport interface UpdateStoreRecordInput extends InsertStoreRecordInput {\n readonly expectedVersion: number;\n}\n\n/** Error raised when an insert targets an already occupied storage key. */\nexport class RecordExistsError extends Error {\n constructor(collection: CollectionName, id: string) {\n super(`record \"${id}\" already exists in \"${collection}\"`);\n this.name = \"RecordExistsError\";\n }\n}\n\n/** Error raised when an operation requires a storage record that does not exist. */\nexport class RecordNotFoundError extends Error {\n constructor(collection: CollectionName, id: string) {\n super(`record \"${id}\" not found in \"${collection}\"`);\n this.name = \"RecordNotFoundError\";\n }\n}\n\n/** Error raised when atomic update loses its expected-version comparison. */\nexport class VersionConflictError extends Error {\n constructor(collection: CollectionName, id: string, expectedVersion: number) {\n super(`record \"${id}\" in \"${collection}\" changed since version ${expectedVersion} was read`);\n this.name = \"VersionConflictError\";\n }\n}\n\n/**\n * A transient infrastructure failure (network error, 5xx/429 response) that\n * a driver's own bounded, backed-off low-level retries could not resolve.\n * Distinct from VersionConflictError (a concurrent writer legitimately won)\n * and from validation or \"already exists\" errors (the request itself is\n * rejected): the same operation may still succeed if retried again later,\n * but every caller retrying on this error must keep its own bound so a real\n * outage surfaces as a failure instead of hanging a dispatch cycle.\n */\nexport class TransientStoreError extends Error {\n constructor(collection: CollectionName, id: string, cause: unknown) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n super(\n `record \"${id}\" in \"${collection}\" failed after transient retries were exhausted: ${reason}`,\n { cause: cause instanceof Error ? cause : undefined },\n );\n this.name = \"TransientStoreError\";\n }\n}\n\n/**\n * Raw persistence contract. Drivers store opaque values and enforce nothing\n * about their content; every invariant lives in the engine above. `update`\n * must be an atomic compare-and-swap on `expectedVersion`. A driver may\n * throw TransientStoreError for a read or write that failed only because of\n * infrastructure trouble (network errors, 5xx/429 responses); it must not\n * use TransientStoreError for version conflicts or malformed input.\n */\nexport interface StoreDriver {\n readonly name: string;\n get(collection: CollectionName, id: string): Promise<StoredRecord | null>;\n insert(input: InsertStoreRecordInput): Promise<void>;\n update(input: UpdateStoreRecordInput): Promise<void>;\n list(collection: CollectionName): Promise<readonly StoredEntry[]>;\n}\n"],"mappings":";;AAyDA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,YAAY,YAA4B,IAAY;EAClD,MAAM,WAAW,GAAG,uBAAuB,WAAW,EAAE;EACxD,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,sBAAb,cAAyC,MAAM;CAC7C,YAAY,YAA4B,IAAY;EAClD,MAAM,WAAW,GAAG,kBAAkB,WAAW,EAAE;EACnD,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,uBAAb,cAA0C,MAAM;CAC9C,YAAY,YAA4B,IAAY,iBAAyB;EAC3E,MAAM,WAAW,GAAG,QAAQ,WAAW,0BAA0B,gBAAgB,UAAU;EAC3F,KAAK,OAAO;CACd;AACF;;;;;;;;;;AAWA,IAAa,sBAAb,cAAyC,MAAM;CAC7C,YAAY,YAA4B,IAAY,OAAgB;EAClE,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACpE,MACE,WAAW,GAAG,QAAQ,WAAW,mDAAmD,UACpF,EAAE,OAAO,iBAAiB,QAAQ,QAAQ,KAAA,EAAU,CACtD;EACA,KAAK,OAAO;CACd;AACF"}
1
+ {"version":3,"file":"driver.mjs","names":[],"sources":["../../src/store/driver.ts"],"sourcesContent":["/** Closed set of persistence collections understood by Factory store drivers. */\nexport type CollectionName =\n | \"approvalRecords\"\n | \"applicationState\"\n | \"applicationChunks\"\n | \"conversations\"\n | \"conversationQuestions\"\n | \"conversationExecutions\"\n | \"repositories\"\n | \"signals\"\n | \"tasks\"\n | \"changes\"\n | \"receipts\"\n | \"budgets\"\n | \"answers\"\n | \"sessions\"\n | \"externalSessions\"\n | \"sessionContinuations\"\n | \"sessionNotifications\"\n | \"transcripts\"\n | \"transcriptBlocks\"\n | \"transcriptChunks\"\n | \"images\"\n | \"questionRoutes\"\n | \"taskCatalogs\"\n | \"changeCatalogs\"\n | \"sessionCatalogs\"\n | \"externalSessionCatalogs\"\n | \"taskRoutes\"\n | \"outboxQueues\"\n | \"outboxDeliveries\"\n | \"communicationSettings\"\n | \"taskGraphs\"\n | \"taskMessages\"\n | \"taskEffects\"\n | \"taskInboxes\"\n | \"taskMessageProcessing\"\n | \"taskMessageDecisions\"\n | \"taskMessageDiscards\"\n | \"plannerActivations\"\n | \"plannerCancellations\";\n\n/** Opaque persisted value paired with its compare-and-swap version. */\nexport interface StoredRecord {\n readonly value: unknown;\n readonly version: number;\n}\n\n/** Collection-listing entry containing its storage key and versioned record. */\nexport interface StoredEntry {\n readonly id: string;\n readonly record: StoredRecord;\n}\n\n/** Collection, storage key, and opaque value for one insert-only write. */\nexport interface InsertStoreRecordInput {\n readonly collection: CollectionName;\n readonly id: string;\n readonly value: unknown;\n}\n\n/** Collection, storage key, opaque value, and compare-and-swap version for one update. */\nexport interface UpdateStoreRecordInput extends InsertStoreRecordInput {\n readonly expectedVersion: number;\n}\n\n/** Error raised when an insert targets an already occupied storage key. */\nexport class RecordExistsError extends Error {\n constructor(collection: CollectionName, id: string) {\n super(`record \"${id}\" already exists in \"${collection}\"`);\n this.name = \"RecordExistsError\";\n }\n}\n\n/** Error raised when an operation requires a storage record that does not exist. */\nexport class RecordNotFoundError extends Error {\n constructor(collection: CollectionName, id: string) {\n super(`record \"${id}\" not found in \"${collection}\"`);\n this.name = \"RecordNotFoundError\";\n }\n}\n\n/** Error raised when atomic update loses its expected-version comparison. */\nexport class VersionConflictError extends Error {\n constructor(collection: CollectionName, id: string, expectedVersion: number) {\n super(`record \"${id}\" in \"${collection}\" changed since version ${expectedVersion} was read`);\n this.name = \"VersionConflictError\";\n }\n}\n\n/**\n * A transient infrastructure failure (network error, 5xx/429 response) that\n * a driver's own bounded, backed-off low-level retries could not resolve.\n * Distinct from VersionConflictError (a concurrent writer legitimately won)\n * and from validation or \"already exists\" errors (the request itself is\n * rejected): the same operation may still succeed if retried again later,\n * but every caller retrying on this error must keep its own bound so a real\n * outage surfaces as a failure instead of hanging a dispatch cycle.\n */\nexport class TransientStoreError extends Error {\n constructor(collection: CollectionName, id: string, cause: unknown) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n super(\n `record \"${id}\" in \"${collection}\" failed after transient retries were exhausted: ${reason}`,\n { cause: cause instanceof Error ? cause : undefined },\n );\n this.name = \"TransientStoreError\";\n }\n}\n\n/**\n * Raw persistence contract. Drivers store opaque values and enforce nothing\n * about their content; every invariant lives in the engine above. `update`\n * must be an atomic compare-and-swap on `expectedVersion`. A driver may\n * throw TransientStoreError for a read or write that failed only because of\n * infrastructure trouble (network errors, 5xx/429 responses); it must not\n * use TransientStoreError for version conflicts or malformed input.\n */\nexport interface StoreDriver {\n readonly name: string;\n get(collection: CollectionName, id: string): Promise<StoredRecord | null>;\n insert(input: InsertStoreRecordInput): Promise<void>;\n update(input: UpdateStoreRecordInput): Promise<void>;\n list(collection: CollectionName): Promise<readonly StoredEntry[]>;\n}\n"],"mappings":";;AAmEA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,YAAY,YAA4B,IAAY;EAClD,MAAM,WAAW,GAAG,uBAAuB,WAAW,EAAE;EACxD,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,sBAAb,cAAyC,MAAM;CAC7C,YAAY,YAA4B,IAAY;EAClD,MAAM,WAAW,GAAG,kBAAkB,WAAW,EAAE;EACnD,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,uBAAb,cAA0C,MAAM;CAC9C,YAAY,YAA4B,IAAY,iBAAyB;EAC3E,MAAM,WAAW,GAAG,QAAQ,WAAW,0BAA0B,gBAAgB,UAAU;EAC3F,KAAK,OAAO;CACd;AACF;;;;;;;;;;AAWA,IAAa,sBAAb,cAAyC,MAAM;CAC7C,YAAY,YAA4B,IAAY,OAAgB;EAClE,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACpE,MACE,WAAW,GAAG,QAAQ,WAAW,mDAAmD,UACpF,EAAE,OAAO,iBAAiB,QAAQ,QAAQ,KAAA,EAAU,CACtD;EACA,KAAK,OAAO;CACd;AACF"}
@@ -1,25 +1,27 @@
1
- import { Signal, SignalOutcome, SignalSource, SignalTriage } from "../schema/signal.mjs";
2
1
  import { AnswerId, ChangeId, FactoryId, OutboxId, ReceiptId, RepositoryId, RepositoryIds, SignalId, TaskId } from "../schema/id.mjs";
3
- import { Repository } from "../schema/repository.mjs";
2
+ import { FactoryRecordPage, FactoryRecordQuery } from "./query.mjs";
3
+ import { StoreDriver } from "./driver.mjs";
4
+ import "./indexed.mjs";
4
5
  import { ExecutionReference, Task, TaskOrigin, TaskQuestion, TaskState } from "../schema/task.mjs";
5
6
  import { WorkflowRegistry } from "../workflows.mjs";
6
7
  import { TaskMessageProtocols } from "../schema/task-message.mjs";
7
8
  import { WorkNotifications } from "./work-notifications.mjs";
8
9
  import { IsoDateTimeClock, ReplyTo } from "../schema/common.mjs";
9
- import { StoreDriver } from "./driver.mjs";
10
10
  import { TaskMessageAuthorize, TaskMessageStore } from "./task-messages.mjs";
11
11
  import { TaskGraphStore } from "./task-graphs.mjs";
12
12
  import { TaskEffectStore } from "./task-effects.mjs";
13
13
  import { TaskWorkStore } from "./task-work.mjs";
14
14
  import { ImageAttachment, ImageId, imageUploadSchema } from "../image-input.mjs";
15
15
  import { AnswerEvent } from "../schema/answer.mjs";
16
- import { AgentSession, AgentSessionId } from "../schema/session.mjs";
16
+ import { AgentSession, AgentSessionId, SessionContinuation } from "../schema/session.mjs";
17
17
  import { CommunicationEvent } from "../schema/communication.mjs";
18
18
  import { Budget, BudgetMonth } from "../schema/budget.mjs";
19
19
  import { Change, ChangeInState, ChangeLevel, ChangeState } from "../schema/change.mjs";
20
20
  import { OutboxMessage } from "../schema/outbox.mjs";
21
- import { TranscriptSnapshot } from "../schema/transcript.mjs";
21
+ import { TranscriptBlock, TranscriptPage, TranscriptPageQuery, TranscriptSnapshot } from "../schema/transcript.mjs";
22
22
  import { Cost, Receipt, ReceiptDelivery, ReceiptKind, ReceiptPhase, ReceiptState, StandardReceiptKind, StandardReceiptPhase, StandardReceiptState } from "../schema/receipt.mjs";
23
+ import { Repository } from "../schema/repository.mjs";
24
+ import { Signal, SignalOutcome, SignalSource, SignalTriage } from "../schema/signal.mjs";
23
25
  import { z } from "zod";
24
26
  //#region src/store/engine.d.ts
25
27
  declare const storedImageSchema: z.ZodObject<{
@@ -364,6 +366,14 @@ interface FactoryStores {
364
366
  /** Materialized transcript snapshots keyed by exact provider execution. */
365
367
  transcripts: {
366
368
  get(execution: ExecutionReference): Promise<TranscriptSnapshot | null>;
369
+ /** Current metadata without replaying or loading the transcript body. */
370
+ head(execution: ExecutionReference): Promise<(TranscriptSnapshot & {
371
+ blockCount: number;
372
+ }) | null>;
373
+ /** A bounded page, with large blocks represented by explicit content references. */
374
+ page(execution: ExecutionReference, query: TranscriptPageQuery): Promise<TranscriptPage | null>;
375
+ /** Full content of one authorized execution's block, requested explicitly. */
376
+ block(execution: ExecutionReference, blockId: string): Promise<TranscriptBlock | null>;
367
377
  /** Persist only forward progress; safe to repeat from response-boundary hooks. */
368
378
  put(execution: ExecutionReference, snapshot: TranscriptSnapshot): Promise<TranscriptSnapshot>;
369
379
  };
@@ -377,7 +387,7 @@ interface FactoryStores {
377
387
  sessions: {
378
388
  /** Looks up an admitted session without recomputing defaults on a repeated operation. */
379
389
  getByOperation(owner: string, operationId: string): Promise<AgentSession | null>;
380
- create(input: Omit<AgentSession, "schemaVersion" | "id" | "createdAt" | "execution" | "taskId" | "notifications" | "attached" | "continuations" | "external"> & {
390
+ create(input: Omit<AgentSession, "schemaVersion" | "id" | "createdAt" | "execution" | "taskId" | "latestNotificationId" | "attached" | "latestContinuationId" | "external"> & {
381
391
  operationId: string;
382
392
  }): Promise<AgentSession>;
383
393
  attachTask(input: {
@@ -403,9 +413,11 @@ interface FactoryStores {
403
413
  attachments?: readonly ImageAttachment[];
404
414
  }): Promise<AgentSession>;
405
415
  get(id: AgentSessionId): Promise<AgentSession | null>;
406
- list(): Promise<readonly AgentSession[]>;
407
- /** Compact session snapshots from fixed shards for discovery; large cached continuation context is omitted. */
408
- summaries(): Promise<readonly AgentSession[]>;
416
+ getContinuation(id: AgentSessionId, taskId: TaskId): Promise<SessionContinuation | null>;
417
+ getContinuationByOperation(id: AgentSessionId, operationId: string): Promise<SessionContinuation | null>;
418
+ listContinuations(id: AgentSessionId, query: FactoryRecordQuery): Promise<FactoryRecordPage<SessionContinuation>>;
419
+ listNotifications(id: AgentSessionId, query: FactoryRecordQuery): Promise<FactoryRecordPage<CommunicationEvent>>;
420
+ list(query: FactoryRecordQuery): Promise<FactoryRecordPage<AgentSession>>;
409
421
  bind(id: AgentSessionId, reference: AgentSessionBinding): Promise<AgentSession>;
410
422
  notify(event: CommunicationEvent): Promise<void>;
411
423
  };
@@ -418,7 +430,7 @@ interface FactoryStores {
418
430
  }): Promise<Repository>;
419
431
  put(repository: Repository): Promise<Repository>;
420
432
  get(id: RepositoryId): Promise<Repository | null>;
421
- list(): Promise<readonly Repository[]>;
433
+ list(query: FactoryRecordQuery): Promise<FactoryRecordPage<Repository>>;
422
434
  };
423
435
  /** External intake records and their explicit triage lifecycle. */
424
436
  signals: {
@@ -432,7 +444,7 @@ interface FactoryStores {
432
444
  }): Promise<Signal>;
433
445
  updateTriage(id: SignalId, attempt: number, observation: Pick<SignalTriage, "state" | "failure" | "sessionId">): Promise<Signal>;
434
446
  decide(id: SignalId, input: DecideSignalInput): Promise<Signal>;
435
- list(): Promise<readonly Signal[]>;
447
+ list(query: FactoryRecordQuery): Promise<FactoryRecordPage<Signal>>;
436
448
  };
437
449
  /** Canonical Task lifecycle operations. */
438
450
  tasks: {
@@ -557,9 +569,7 @@ interface FactoryStores {
557
569
  at?: string;
558
570
  attempt?: number;
559
571
  }): Promise<Task>;
560
- /** Tasks addressed to one connector or operator conversation without a collection scan. */
561
- forReplyTo(replyTo: ReplyTo): Promise<readonly Task[]>;
562
- list(): Promise<readonly Task[]>;
572
+ list(query: FactoryRecordQuery): Promise<FactoryRecordPage<Task>>;
563
573
  };
564
574
  /** Canonical software Change admission and lifecycle operations. */
565
575
  changes: {
@@ -568,7 +578,7 @@ interface FactoryStores {
568
578
  /** Save evidence without inventing a lifecycle transition; reject a changed snapshot. */
569
579
  updateEvidence(id: ChangeId, input: UpdateChangeEvidenceInput): Promise<Change>;
570
580
  transition<To extends ChangeState>(id: ChangeId, to: To, ...args: ChangeTransitionArguments<NoInfer<To>>): Promise<ChangeInState<To>>;
571
- list(): Promise<readonly Change[]>;
581
+ list(query: FactoryRecordQuery): Promise<FactoryRecordPage<Change>>;
572
582
  };
573
583
  /** Immutable audit evidence appended by engine and application policy. */
574
584
  receipts: {
@@ -578,7 +588,7 @@ interface FactoryStores {
578
588
  phase?: Phase;
579
589
  }): Promise<Receipt>;
580
590
  get(id: ReceiptId): Promise<Receipt | null>;
581
- list(): Promise<readonly Receipt[]>;
591
+ list(query: FactoryRecordQuery): Promise<FactoryRecordPage<Receipt>>;
582
592
  };
583
593
  /** Monthly budget snapshots, limits, and once-only notification stamps. */
584
594
  budgets: {
@@ -617,6 +627,18 @@ interface CreateStoresOptions {
617
627
  * callback and never rolls back the canonical write.
618
628
  */
619
629
  workNotifications?: WorkNotifications;
630
+ /**
631
+ * Pure application predicate opting child Tasks into durable lifecycle communication.
632
+ * Defaults to excluding children. Root notifications and human questions keep their existing
633
+ * behavior; this predicate only selects among otherwise communicable lifecycle receipts.
634
+ *
635
+ * A child Task delegated directly from a `conversation`-route parent (an interactive chat's
636
+ * own handoff to a planner or specialist) is always treated as communicable regardless of this
637
+ * predicate: it is the user-requested delegation itself, not an internal worker child. This
638
+ * predicate still gates deeper descendants (e.g. a planner's own delegations to workers), so
639
+ * ordinary internal work stays quiet.
640
+ */
641
+ includeChildTaskCommunication?: (task: Task, state: ReceiptState) => boolean;
620
642
  /** ISO timestamp source used for engine-owned records. Defaults to the current wall clock. */
621
643
  now?: IsoDateTimeClock;
622
644
  /**