@adonis-agora/agent 0.31.0 → 0.33.1

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 (238) hide show
  1. package/CHANGELOG.md +795 -0
  2. package/dist/assets/spa/assets/index-DjIMQOxi.js +9 -0
  3. package/dist/assets/spa/index.html +1 -1
  4. package/dist/providers/agent_provider.d.ts.map +1 -1
  5. package/dist/providers/agent_provider.js +140 -2
  6. package/dist/providers/agent_provider.js.map +1 -1
  7. package/dist/src/agent-deps-factory.d.ts +16 -2
  8. package/dist/src/agent-deps-factory.d.ts.map +1 -1
  9. package/dist/src/agent-deps-factory.js +8 -0
  10. package/dist/src/agent-deps-factory.js.map +1 -1
  11. package/dist/src/agent-deps.d.ts +21 -1
  12. package/dist/src/agent-deps.d.ts.map +1 -1
  13. package/dist/src/agent-deps.js.map +1 -1
  14. package/dist/src/agent-loop.d.ts +228 -9
  15. package/dist/src/agent-loop.d.ts.map +1 -1
  16. package/dist/src/agent-loop.js +1360 -209
  17. package/dist/src/agent-loop.js.map +1 -1
  18. package/dist/src/agent-service.d.ts +27 -0
  19. package/dist/src/agent-service.d.ts.map +1 -1
  20. package/dist/src/agent-service.js +29 -0
  21. package/dist/src/agent-service.js.map +1 -1
  22. package/dist/src/ai-sdk/ai-sdk-model.d.ts.map +1 -1
  23. package/dist/src/ai-sdk/ai-sdk-model.js +21 -1
  24. package/dist/src/ai-sdk/ai-sdk-model.js.map +1 -1
  25. package/dist/src/client/sse.d.ts +32 -2
  26. package/dist/src/client/sse.d.ts.map +1 -1
  27. package/dist/src/client/sse.js +45 -2
  28. package/dist/src/client/sse.js.map +1 -1
  29. package/dist/src/define_config.d.ts +41 -7
  30. package/dist/src/define_config.d.ts.map +1 -1
  31. package/dist/src/define_config.js.map +1 -1
  32. package/dist/src/durable/agent-run-workflow.d.ts +10 -11
  33. package/dist/src/durable/agent-run-workflow.d.ts.map +1 -1
  34. package/dist/src/durable/agent-run-workflow.js +49 -21
  35. package/dist/src/durable/agent-run-workflow.js.map +1 -1
  36. package/dist/src/durable/durable-agent-runner.d.ts +3 -2
  37. package/dist/src/durable/durable-agent-runner.d.ts.map +1 -1
  38. package/dist/src/durable/durable-agent-runner.js +2 -2
  39. package/dist/src/durable/durable-agent-runner.js.map +1 -1
  40. package/dist/src/elicitation.d.ts +207 -0
  41. package/dist/src/elicitation.d.ts.map +1 -0
  42. package/dist/src/elicitation.js +315 -0
  43. package/dist/src/elicitation.js.map +1 -0
  44. package/dist/src/evals/approval-prior.d.ts +58 -0
  45. package/dist/src/evals/approval-prior.d.ts.map +1 -0
  46. package/dist/src/evals/approval-prior.js +82 -0
  47. package/dist/src/evals/approval-prior.js.map +1 -0
  48. package/dist/src/evals/evaluate.d.ts +51 -0
  49. package/dist/src/evals/evaluate.d.ts.map +1 -0
  50. package/dist/src/evals/evaluate.js +76 -0
  51. package/dist/src/evals/evaluate.js.map +1 -0
  52. package/dist/src/evals/governance-sample-source.d.ts +23 -0
  53. package/dist/src/evals/governance-sample-source.d.ts.map +1 -0
  54. package/dist/src/evals/governance-sample-source.js +93 -0
  55. package/dist/src/evals/governance-sample-source.js.map +1 -0
  56. package/dist/src/evals/in-memory-score-store.d.ts +16 -0
  57. package/dist/src/evals/in-memory-score-store.d.ts.map +1 -0
  58. package/dist/src/evals/in-memory-score-store.js +57 -0
  59. package/dist/src/evals/in-memory-score-store.js.map +1 -0
  60. package/dist/src/evals/index.d.ts +15 -0
  61. package/dist/src/evals/index.d.ts.map +1 -0
  62. package/dist/src/evals/index.js +14 -0
  63. package/dist/src/evals/index.js.map +1 -0
  64. package/dist/src/evals/judge.d.ts +30 -0
  65. package/dist/src/evals/judge.d.ts.map +1 -0
  66. package/dist/src/evals/judge.js +53 -0
  67. package/dist/src/evals/judge.js.map +1 -0
  68. package/dist/src/evals/live-scoring.d.ts +42 -0
  69. package/dist/src/evals/live-scoring.d.ts.map +1 -0
  70. package/dist/src/evals/live-scoring.js +103 -0
  71. package/dist/src/evals/live-scoring.js.map +1 -0
  72. package/dist/src/evals/sample-source.d.ts +40 -0
  73. package/dist/src/evals/sample-source.d.ts.map +1 -0
  74. package/dist/src/evals/sample-source.js +33 -0
  75. package/dist/src/evals/sample-source.js.map +1 -0
  76. package/dist/src/evals/score-store.d.ts +54 -0
  77. package/dist/src/evals/score-store.d.ts.map +1 -0
  78. package/dist/src/evals/score-store.js +2 -0
  79. package/dist/src/evals/score-store.js.map +1 -0
  80. package/dist/src/evals/scorers/answer-relevancy.scorer.d.ts +28 -0
  81. package/dist/src/evals/scorers/answer-relevancy.scorer.d.ts.map +1 -0
  82. package/dist/src/evals/scorers/answer-relevancy.scorer.js +42 -0
  83. package/dist/src/evals/scorers/answer-relevancy.scorer.js.map +1 -0
  84. package/dist/src/evals/scorers/approval-outcome.scorer.d.ts +22 -0
  85. package/dist/src/evals/scorers/approval-outcome.scorer.d.ts.map +1 -0
  86. package/dist/src/evals/scorers/approval-outcome.scorer.js +60 -0
  87. package/dist/src/evals/scorers/approval-outcome.scorer.js.map +1 -0
  88. package/dist/src/evals/scorers/approval-risk.scorer.d.ts +28 -0
  89. package/dist/src/evals/scorers/approval-risk.scorer.d.ts.map +1 -0
  90. package/dist/src/evals/scorers/approval-risk.scorer.js +54 -0
  91. package/dist/src/evals/scorers/approval-risk.scorer.js.map +1 -0
  92. package/dist/src/evals/scorers/run-completion.scorer.d.ts +18 -0
  93. package/dist/src/evals/scorers/run-completion.scorer.d.ts.map +1 -0
  94. package/dist/src/evals/scorers/run-completion.scorer.js +55 -0
  95. package/dist/src/evals/scorers/run-completion.scorer.js.map +1 -0
  96. package/dist/src/evals/summarize.d.ts +44 -0
  97. package/dist/src/evals/summarize.d.ts.map +1 -0
  98. package/dist/src/evals/summarize.js +87 -0
  99. package/dist/src/evals/summarize.js.map +1 -0
  100. package/dist/src/evals/types.d.ts +81 -0
  101. package/dist/src/evals/types.d.ts.map +1 -0
  102. package/dist/src/evals/types.js +15 -0
  103. package/dist/src/evals/types.js.map +1 -0
  104. package/dist/src/history-window.d.ts +50 -11
  105. package/dist/src/history-window.d.ts.map +1 -1
  106. package/dist/src/history-window.js +84 -12
  107. package/dist/src/history-window.js.map +1 -1
  108. package/dist/src/index.d.ts +9 -2
  109. package/dist/src/index.d.ts.map +1 -1
  110. package/dist/src/index.js +9 -2
  111. package/dist/src/index.js.map +1 -1
  112. package/dist/src/mcp/server.d.ts +8 -0
  113. package/dist/src/mcp/server.d.ts.map +1 -1
  114. package/dist/src/mcp/server.js +27 -1
  115. package/dist/src/mcp/server.js.map +1 -1
  116. package/dist/src/mcp-client/importer.d.ts +75 -0
  117. package/dist/src/mcp-client/importer.d.ts.map +1 -0
  118. package/dist/src/mcp-client/importer.js +161 -0
  119. package/dist/src/mcp-client/importer.js.map +1 -0
  120. package/dist/src/mcp-client/index.d.ts +9 -0
  121. package/dist/src/mcp-client/index.d.ts.map +1 -0
  122. package/dist/src/mcp-client/index.js +8 -0
  123. package/dist/src/mcp-client/index.js.map +1 -0
  124. package/dist/src/mcp-client/options.d.ts +99 -0
  125. package/dist/src/mcp-client/options.d.ts.map +1 -0
  126. package/dist/src/mcp-client/options.js +2 -0
  127. package/dist/src/mcp-client/options.js.map +1 -0
  128. package/dist/src/mcp-client/tool-input.d.ts +39 -0
  129. package/dist/src/mcp-client/tool-input.d.ts.map +1 -0
  130. package/dist/src/mcp-client/tool-input.js +61 -0
  131. package/dist/src/mcp-client/tool-input.js.map +1 -0
  132. package/dist/src/mcp-client/tool-kind.d.ts +37 -0
  133. package/dist/src/mcp-client/tool-kind.d.ts.map +1 -0
  134. package/dist/src/mcp-client/tool-kind.js +20 -0
  135. package/dist/src/mcp-client/tool-kind.js.map +1 -0
  136. package/dist/src/mcp-client/tool-name.d.ts +22 -0
  137. package/dist/src/mcp-client/tool-name.d.ts.map +1 -0
  138. package/dist/src/mcp-client/tool-name.js +35 -0
  139. package/dist/src/mcp-client/tool-name.js.map +1 -0
  140. package/dist/src/mcp-client/tool-source.d.ts +75 -0
  141. package/dist/src/mcp-client/tool-source.d.ts.map +1 -0
  142. package/dist/src/mcp-client/tool-source.js +244 -0
  143. package/dist/src/mcp-client/tool-source.js.map +1 -0
  144. package/dist/src/mcp-client/transient.d.ts +28 -0
  145. package/dist/src/mcp-client/transient.d.ts.map +1 -0
  146. package/dist/src/mcp-client/transient.js +126 -0
  147. package/dist/src/mcp-client/transient.js.map +1 -0
  148. package/dist/src/mcp-client/unsafe-regex.d.ts +23 -0
  149. package/dist/src/mcp-client/unsafe-regex.d.ts.map +1 -0
  150. package/dist/src/mcp-client/unsafe-regex.js +194 -0
  151. package/dist/src/mcp-client/unsafe-regex.js.map +1 -0
  152. package/dist/src/memory.d.ts +448 -0
  153. package/dist/src/memory.d.ts.map +1 -0
  154. package/dist/src/memory.js +338 -0
  155. package/dist/src/memory.js.map +1 -0
  156. package/dist/src/processors.d.ts +134 -0
  157. package/dist/src/processors.d.ts.map +1 -0
  158. package/dist/src/processors.js +215 -0
  159. package/dist/src/processors.js.map +1 -0
  160. package/dist/src/rag/index.d.ts +1 -1
  161. package/dist/src/rag/index.d.ts.map +1 -1
  162. package/dist/src/rag/index.js +1 -1
  163. package/dist/src/rag/index.js.map +1 -1
  164. package/dist/src/rag/pg-vector-store.d.ts +41 -0
  165. package/dist/src/rag/pg-vector-store.d.ts.map +1 -1
  166. package/dist/src/rag/pg-vector-store.js +93 -15
  167. package/dist/src/rag/pg-vector-store.js.map +1 -1
  168. package/dist/src/replay-integrity.d.ts +17 -0
  169. package/dist/src/replay-integrity.d.ts.map +1 -0
  170. package/dist/src/replay-integrity.js +19 -0
  171. package/dist/src/replay-integrity.js.map +1 -0
  172. package/dist/src/runners/inline-agent-runner.d.ts +33 -7
  173. package/dist/src/runners/inline-agent-runner.d.ts.map +1 -1
  174. package/dist/src/runners/inline-agent-runner.js +113 -27
  175. package/dist/src/runners/inline-agent-runner.js.map +1 -1
  176. package/dist/src/skills.d.ts +291 -0
  177. package/dist/src/skills.d.ts.map +1 -0
  178. package/dist/src/skills.js +0 -0
  179. package/dist/src/skills.js.map +1 -0
  180. package/dist/src/spi/agent-runner.d.ts +20 -6
  181. package/dist/src/spi/agent-runner.d.ts.map +1 -1
  182. package/dist/src/spi/agent-store.d.ts +53 -0
  183. package/dist/src/spi/agent-store.d.ts.map +1 -1
  184. package/dist/src/spi/governance-queries.d.ts +5 -0
  185. package/dist/src/spi/governance-queries.d.ts.map +1 -1
  186. package/dist/src/spi/history-window.d.ts +64 -10
  187. package/dist/src/spi/history-window.d.ts.map +1 -1
  188. package/dist/src/spi/model-provider.d.ts +18 -0
  189. package/dist/src/spi/model-provider.d.ts.map +1 -1
  190. package/dist/src/spi/processors.d.ts +161 -0
  191. package/dist/src/spi/processors.d.ts.map +1 -0
  192. package/dist/src/spi/processors.js +57 -0
  193. package/dist/src/spi/processors.js.map +1 -0
  194. package/dist/src/spi/token-stream-sink.d.ts +43 -0
  195. package/dist/src/spi/token-stream-sink.d.ts.map +1 -1
  196. package/dist/src/spi/token-stream-sink.js +17 -1
  197. package/dist/src/spi/token-stream-sink.js.map +1 -1
  198. package/dist/src/sse.d.ts +5 -2
  199. package/dist/src/sse.d.ts.map +1 -1
  200. package/dist/src/sse.js +11 -2
  201. package/dist/src/sse.js.map +1 -1
  202. package/dist/src/stores/lucid-governance-queries.d.ts.map +1 -1
  203. package/dist/src/stores/lucid-governance-queries.js +3 -0
  204. package/dist/src/stores/lucid-governance-queries.js.map +1 -1
  205. package/dist/src/stores/lucid-schema.d.ts.map +1 -1
  206. package/dist/src/stores/lucid-schema.js +15 -0
  207. package/dist/src/stores/lucid-schema.js.map +1 -1
  208. package/dist/src/stores/lucid.d.ts +11 -3
  209. package/dist/src/stores/lucid.d.ts.map +1 -1
  210. package/dist/src/stores/lucid.js +65 -0
  211. package/dist/src/stores/lucid.js.map +1 -1
  212. package/dist/src/structured-output.d.ts +57 -0
  213. package/dist/src/structured-output.d.ts.map +1 -0
  214. package/dist/src/structured-output.js +80 -0
  215. package/dist/src/structured-output.js.map +1 -0
  216. package/dist/src/testing/fake-model-provider.d.ts +8 -4
  217. package/dist/src/testing/fake-model-provider.d.ts.map +1 -1
  218. package/dist/src/testing/fake-model-provider.js +6 -9
  219. package/dist/src/testing/fake-model-provider.js.map +1 -1
  220. package/dist/src/testing/in-memory-governance-queries.d.ts.map +1 -1
  221. package/dist/src/testing/in-memory-governance-queries.js +1 -0
  222. package/dist/src/testing/in-memory-governance-queries.js.map +1 -1
  223. package/dist/src/testing/in-memory-store.d.ts +4 -3
  224. package/dist/src/testing/in-memory-store.d.ts.map +1 -1
  225. package/dist/src/testing/in-memory-store.js +13 -7
  226. package/dist/src/testing/in-memory-store.js.map +1 -1
  227. package/dist/src/testing/index.d.ts +1 -1
  228. package/dist/src/testing/index.d.ts.map +1 -1
  229. package/dist/src/testing/index.js.map +1 -1
  230. package/dist/src/tool-registry.d.ts +9 -0
  231. package/dist/src/tool-registry.d.ts.map +1 -1
  232. package/dist/src/tool-registry.js +11 -0
  233. package/dist/src/tool-registry.js.map +1 -1
  234. package/dist/src/types.d.ts +70 -2
  235. package/dist/src/types.d.ts.map +1 -1
  236. package/package.json +38 -24
  237. package/skills/agent-personas-agents/SKILL.md +16 -12
  238. package/dist/assets/spa/assets/index-3Q2m5_Ax.js +0 -9
@@ -1 +1 @@
1
- {"version":3,"file":"agent-runner.d.ts","sourceRoot":"","sources":["../../../src/spi/agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE3D;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,8DAA8D;IAC9D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC"}
1
+ {"version":3,"file":"agent-runner.d.ts","sourceRoot":"","sources":["../../../src/spi/agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC"}
@@ -59,6 +59,14 @@ export interface RecordRunStartInput {
59
59
  actor: Actor;
60
60
  /** The agent that handled the run; `null`/omitted for the default agent. */
61
61
  agentName?: string;
62
+ /**
63
+ * The run that started this one, for a delegation's child run. The parent->child edge exists in
64
+ * the durable runtime's own journal, but only there: a governance surface reading run rows alone
65
+ * cannot roll a delegation's cost up to the turn that asked for it.
66
+ *
67
+ * Optional, and a store that persists nothing for it still works — it loses the tree, not the run.
68
+ */
69
+ parentRunId?: string;
62
70
  /** True when the run executes as a replay-safe durable workflow, false for the inline runner. */
63
71
  durable?: boolean;
64
72
  }
@@ -79,6 +87,40 @@ export interface RecordRunEndInput {
79
87
  costUsd?: number;
80
88
  error?: string;
81
89
  }
90
+ /** Which thread, and how many of its newest messages, {@link ThreadTurnReader.loadThreadForTurn} reads. */
91
+ export interface ThreadTurnQuery {
92
+ threadId: string;
93
+ /** Omitted reads every message; `0` reads none. */
94
+ messageLimit?: number;
95
+ }
96
+ /** What a turn reads off a thread — a bounded window, not the transcript. */
97
+ export interface ThreadTurnPage {
98
+ title: string;
99
+ /** Whether the THREAD has ever been answered, not whether {@link messages} holds an answer. */
100
+ hasAssistantMessage: boolean;
101
+ /** Oldest first, carrying only the fields a model turn reads. */
102
+ messages: StoredMessage[];
103
+ }
104
+ /**
105
+ * A store that can hand a turn the WINDOW it is about to send, instead of the thread's transcript.
106
+ *
107
+ * {@link AgentStore.getThread} materializes every message row, every attachment and every tool
108
+ * output a thread ever recorded, and `load:thread` then journals what it loaded — so a long thread
109
+ * pays for its whole history on every turn and again on every replay, to send a prompt bounded to
110
+ * its last few messages. This read is bounded by the database (`order by created_at desc limit ?`),
111
+ * projected to the columns a model turn actually reads.
112
+ *
113
+ * `hasAssistantMessage` is answered over the WHOLE thread, never the page: it answers "has this
114
+ * conversation been answered before?" — what a `thread-start` intake asks — and a thread whose
115
+ * window happens to hold only the user's last questions has still been answered. `null` for a thread
116
+ * that is unknown or soft-deleted, matching `getThread`.
117
+ *
118
+ * Probed STRUCTURALLY rather than declared on {@link AgentStore}: it is an optimization a store
119
+ * either offers or does not, and one that offers none still answers correctly through the full read.
120
+ */
121
+ export interface ThreadTurnReader {
122
+ loadThreadForTurn(query: ThreadTurnQuery): Promise<ThreadTurnPage | null>;
123
+ }
82
124
  /** ORM-agnostic persistence. Refs are string ids; adapters may add real relations. */
83
125
  export interface AgentStore {
84
126
  createThread(input: CreateThreadInput): Promise<ThreadSummary>;
@@ -95,6 +137,17 @@ export interface AgentStore {
95
137
  setTitle(threadId: string, title: string): Promise<void>;
96
138
  setActiveStream(threadId: string, runId: string | null): Promise<void>;
97
139
  appendMessage(input: AppendMessageInput): Promise<StoredMessage>;
140
+ /**
141
+ * Attach a turn's settled tool RESULTS to a message already appended, replacing whatever it held.
142
+ * A message's tool calls are known when it is written and their outputs are not, but a thread
143
+ * reader pairs the two off THAT MESSAGE — so an output that only ever reaches the tool-call table
144
+ * leaves every call on a reopened thread looking like a tool still running.
145
+ *
146
+ * Required rather than optional: a store that silently declines this renders a finished turn as a
147
+ * permanently in-flight one, with nothing logged and nothing to notice. A missing method should
148
+ * fail to compile instead.
149
+ */
150
+ setMessageToolResults(messageId: string, results: ToolResult[]): Promise<void>;
98
151
  truncateFrom(threadId: string, messageId: string): Promise<void>;
99
152
  recordToolCall(input: RecordToolCallInput): Promise<void>;
100
153
  updateToolCall(input: UpdateToolCallInput): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-store.d.ts","sourceRoot":"","sources":["../../../src/spi/agent-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,UAAU,EACV,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,eAAe,EAAE,CAAC;IAC9B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,wGAAwG;IACxG,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IA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AC;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE3E,2FAA2F;IAC3F,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D;;;;;OAKG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACtD,yGAAyG;IACzG,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD"}
@@ -95,6 +95,11 @@ export interface RunSummaryRow {
95
95
  actorLabel?: string;
96
96
  tenantRef: string | null;
97
97
  agentName: string | null;
98
+ /**
99
+ * The run that delegated this one, or `null` for a turn a person started. Without it a delegation's
100
+ * spend reads as an orphan turn on every surface built over these rows.
101
+ */
102
+ parentRunId: string | null;
98
103
  status: string;
99
104
  /** ISO timestamp. */
100
105
  startedAt: string;
@@ -1 +1 @@
1
- {"version":3,"file":"governance-queries.d.ts","sourceRoot":"","sources":["../../../src/spi/governance-queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEjE,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,yHAAyH;IACzH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IAC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AE,eAAe,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC/D,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC/D,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAC/D,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC/D,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAI3D;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3D,yGAAyG;IACzG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IACpD,2FAA2F;IAC3F,gBAAgB,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACjF,+FAA+F;IAC/F,YAAY,CAAC,KAAK,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAChE,2EAA2E;IAC3E,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAChE;;;;OAIG;IACH,YAAY,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;CACzE"}
@@ -1,24 +1,78 @@
1
- import type { Actor, ModelMessage } from '../types.js';
1
+ import type { Actor, MessageUsage, ModelMessage } from '../types.js';
2
2
  /** What a {@link HistoryWindow} needs to know about the run it's compacting history for. */
3
3
  export interface HistoryWindowContext {
4
4
  actor: Actor;
5
5
  threadId: string;
6
6
  }
7
+ /** How a window split the thread: what rides into the turn, and what the ceiling left out. */
8
+ export interface HistorySelection {
9
+ /** Sent to the model, oldest-first. */
10
+ keep: ModelMessage[];
11
+ /** Left out, oldest-first. Folded into a leading summary when the window implements `summarize`. */
12
+ drop: ModelMessage[];
13
+ }
14
+ /** A stand-in for the messages a window left out, plus what producing it cost. */
15
+ export interface HistorySummary {
16
+ /** Prose the loop folds into the window as a leading `system` message. */
17
+ text: string;
18
+ /**
19
+ * What the summarizer spent, when it called a model. Recorded as a `summary` usage row, so a
20
+ * ceiling on context cost cannot itself become spend nothing accounts for — the quota sums the
21
+ * whole ledger without filtering purpose, so this also counts against the daily cap. Omit for a
22
+ * summarizer that calls no model (a rollup of tool names, a digest the app already stored).
23
+ */
24
+ usage?: MessageUsage;
25
+ /** Accounting label for the model that produced it; falls back to `AgentLoopDeps.modelId`. */
26
+ modelId?: string;
27
+ }
7
28
  /**
8
29
  * Compaction seam for long-lived threads. The loop maps the ENTIRE persisted thread into
9
30
  * `ModelMessage[]` before every turn (see `runAgentLoop` in `agent-loop.ts`); with no window
10
31
  * configured that whole history rides every turn, so input tokens (cost + latency, and eventually
11
- * the model's context limit) grow without bound as a thread accumulates messages. A `HistoryWindow`
12
- * is a black box like {@link import('./retriever.js').Retriever} — the loop hands it the full
13
- * mapped history and uses whatever it returns, whether that's a plain truncation (this package
14
- * ships {@link import('../history-window.js').SlidingWindowHistory}) or a summarizing impl that
15
- * calls a model to fold dropped messages into a synthetic recap message.
32
+ * the model's context limit) grow without bound as a thread accumulates messages. This package
33
+ * ships {@link import('../history-window.js').SlidingWindowHistory}; anything satisfying the seam
34
+ * works.
16
35
  *
17
- * Applied inside `hooks.step` so durable replay reuses the SAME windowed result deterministically —
18
- * required for any impl that calls a model (its own cost must not be paid twice on resume) and
19
- * harmless for a pure truncator.
36
+ * The two halves run in deliberately different places, and that split is what lets a window exist
37
+ * without moving a single one of the loop's checkpoint positions — see each method.
20
38
  */
21
39
  export interface HistoryWindow {
22
- apply(messages: ModelMessage[], ctx: HistoryWindowContext): ModelMessage[] | Promise<ModelMessage[]>;
40
+ /**
41
+ * The most messages {@link select} can ever keep, where the ceiling can be stated as a row count.
42
+ *
43
+ * A hint the loop hands to the store, which then reads that many of the thread's newest rows
44
+ * rather than its whole transcript (see {@link import('./agent-store.js').ThreadTurnReader}).
45
+ * Declaring it is a PROMISE about `select`: that it keeps at most this many messages, and that
46
+ * they are the NEWEST ones — so a window of this size is indistinguishable, to `select`, from the
47
+ * full transcript. A window that can keep more than this, or something older than the newest
48
+ * `maxMessages`, must omit it rather than select over rows the store was never asked for.
49
+ *
50
+ * Omit where the ceiling is not a row count at all. Omitting costs only the bound on the READ; the
51
+ * prompt is identical either way.
52
+ */
53
+ readonly maxMessages?: number;
54
+ /**
55
+ * Decide what the model sees.
56
+ *
57
+ * MUST be a pure function of `messages`. The loop calls it OUTSIDE any checkpoint, which is safe
58
+ * only because its input already IS one (`load:thread`'s cached result), so a replay re-runs it
59
+ * over the same messages and reaches the same split. Read a clock, a feature flag or a database
60
+ * here and the resumed run windows differently from the one that suspended: the model gets a
61
+ * different prompt, and any step whose existence depends on the split lands at a position the
62
+ * history has no room for. Anything non-deterministic belongs in {@link summarize}.
63
+ *
64
+ * The newest message must always be in `keep` — dropping it leaves the turn with nothing to answer.
65
+ */
66
+ select(messages: ModelMessage[], ctx: HistoryWindowContext): HistorySelection;
67
+ /**
68
+ * Fold the dropped messages into prose the model reads in their place, prepended to the window as
69
+ * a `system` message. Optional — without it, dropped messages are simply gone.
70
+ *
71
+ * Runs inside the loop's `history:summarize` checkpoint, so it may call a model or hit the
72
+ * network: the first attempt's result is journaled and every replay reads it back instead of
73
+ * re-summarizing (and instead of paying for it twice). It runs once per RUN, not per model step,
74
+ * and only when `select` actually dropped something.
75
+ */
76
+ summarize?(dropped: ModelMessage[], ctx: HistoryWindowContext): Promise<HistorySummary>;
23
77
  }
24
78
  //# sourceMappingURL=history-window.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"history-window.d.ts","sourceRoot":"","sources":["../../../src/spi/history-window.ts"],"names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;IACH,SAAS,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACzF"}
@@ -1,3 +1,4 @@
1
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
1
2
  import type { MessageUsage, ModelMessage, ToolCallRequest, ToolDefinition } from '../types.js';
2
3
  import type { SinkWriter } from './token-stream-sink.js';
3
4
  export interface ModelTurnArgs {
@@ -7,6 +8,16 @@ export interface ModelTurnArgs {
7
8
  /** The model writes streamed text deltas here as it generates them. */
8
9
  sink: SinkWriter;
9
10
  abortSignal?: AbortSignal;
11
+ /**
12
+ * Constrain this call's reply to a schema. Set only by the loop's structured-output formatting
13
+ * pass, which is non-streamed and carries `tools: []` — most providers cannot serve a response
14
+ * format and a tool set in the same request.
15
+ *
16
+ * An adapter that can constrain generation should, and report what it parsed as
17
+ * {@link ModelTurnResult.object}. One that cannot may ignore it entirely: the loop validates the
18
+ * reply either way, reading the JSON out of the text when no `object` comes back.
19
+ */
20
+ outputSchema?: StandardSchemaV1;
10
21
  }
11
22
  /** The outcome of ONE assistant turn. The loop — not the model — drives tool execution. */
12
23
  export interface ModelTurnResult {
@@ -26,6 +37,13 @@ export interface ModelTurnResult {
26
37
  * governance read-model uses it verbatim; otherwise it estimates from tokens × the pricing table.
27
38
  */
28
39
  costUsd?: number;
40
+ /**
41
+ * What the provider parsed out of a reply it constrained to {@link ModelTurnArgs.outputSchema}.
42
+ * The loop VALIDATES it regardless — "the provider says it matched" is not the same claim as "it
43
+ * matches", and a provider that ignored the schema has to fail where the failure is repairable.
44
+ * Omit when the adapter did not constrain generation.
45
+ */
46
+ object?: unknown;
29
47
  }
30
48
  /**
31
49
  * Thin wrapper over the actual LLM. The concrete impl (e.g. Vercel AI SDK `streamText`
@@ -1 +1 @@
1
- {"version":3,"file":"model-provider.d.ts","sourceRoot":"","sources":["../../../src/spi/model-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAED,2FAA2F;AAC3F,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,KAAK,EAAE,YAAY,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACxD"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * The two seams that see a turn's traffic to and from the model: an {@link InputProcessor} rewrites
3
+ * the prompt on its way out, an {@link OutputProcessor} inspects the answer on its way back and may
4
+ * redact, replace or refuse it. Wire them as `AgentLoopDeps.inputProcessors` / `outputProcessors`.
5
+ *
6
+ * WHAT THESE ARE NOT: a second way to decide what enters the context. {@link
7
+ * import('./history-window.js').HistoryWindow} owns SELECTION — which of the thread's messages ride
8
+ * into the turn, and what stands in for the rest. Processors run on whatever selection produced and
9
+ * own TRANSFORMATION — what those messages say. The distinction is load-bearing rather than
10
+ * stylistic: `select` is contractually pure and runs outside any checkpoint, while a processor is
11
+ * allowed to call a model, runs in a checkpoint of its own per step, and rewrites a DERIVED prompt
12
+ * that never becomes the thread's own memory of what was said.
13
+ */
14
+ import type { Actor, ModelMessage, ToolCallRequest } from '../types.js';
15
+ /** Which turn, and which model step of it, a processor is looking at. */
16
+ export interface ProcessorContext {
17
+ threadId: string;
18
+ actor: Actor;
19
+ /** The agent running this turn. Undefined → the default/single agent. */
20
+ agentName?: string;
21
+ /** The persona the request selected, when it selected one. */
22
+ persona?: string;
23
+ /** 0-based model step within the run — the same index the `llm:<step>` checkpoint carries. */
24
+ step: number;
25
+ }
26
+ /** Everything the model is about to be sent, as the previous processor in the chain left it. */
27
+ export interface ProcessedPrompt {
28
+ /** The composed system prompt (agent base + persona + any injected retrieval block). */
29
+ system: string;
30
+ /** The turn's messages, oldest-first, already through the history ceiling. */
31
+ messages: ModelMessage[];
32
+ }
33
+ /**
34
+ * Rewrites the prompt before each model call of a turn — masking identifiers, stamping a policy
35
+ * preamble, collapsing an oversized tool result. Runs on EVERY step, not once per run, because the
36
+ * transcript grows between steps: a redactor that only saw the opening prompt would wave through
37
+ * whatever a tool result carried back.
38
+ *
39
+ * Runs inside the loop's `process:input:<step>` checkpoint and its result is journaled, so a
40
+ * processor may call a model or hit the network — a resumed run reads back the prompt the suspended
41
+ * attempt built rather than composing a different one.
42
+ */
43
+ export interface InputProcessor {
44
+ /** Identifies this processor in a failure. Keep it stable — it is user-visible on an error. */
45
+ readonly name: string;
46
+ process(prompt: ProcessedPrompt, ctx: ProcessorContext): ProcessedPrompt | Promise<ProcessedPrompt>;
47
+ }
48
+ /** One model step's answer, as the previous processor in the chain left it. */
49
+ export interface ModelAnswer {
50
+ /** The assembled assistant text for this step. */
51
+ text: string;
52
+ /**
53
+ * The tool calls the same step asked for. Read-only context — a processor cannot change them.
54
+ * A provider reports its calls when `runTurn` RETURNS, so on the incremental path (where the chain
55
+ * rules on a prefix while the call is still streaming) this is empty until the authoritative
56
+ * whole-answer pass, which always sees them.
57
+ */
58
+ toolCalls: readonly ToolCallRequest[];
59
+ }
60
+ /**
61
+ * What an {@link OutputProcessor} decided. `pass` hands the text to the next processor unchanged;
62
+ * `replace` hands it on rewritten (a redaction is a replacement); `reject` ends the chain AND the
63
+ * run — the text is never streamed, never persisted, and the caller gets an
64
+ * {@link OutputRejectedError} rather than an answer.
65
+ */
66
+ export type OutputVerdict = {
67
+ action: 'pass';
68
+ } | {
69
+ action: 'replace';
70
+ text: string;
71
+ } | {
72
+ action: 'reject';
73
+ reason: string;
74
+ };
75
+ /**
76
+ * Characters an incremental gate keeps holding at the end of the transformed answer, when a
77
+ * processor declares {@link IncrementalGating} without naming its own window. Wide enough for the
78
+ * patterns a redactor is usually written against — an SSN, an email address, a card number — and
79
+ * deliberately not wider: the window IS the answer's minimum latency tail, since those characters
80
+ * are only released once the whole-answer pass runs.
81
+ */
82
+ export declare const DEFAULT_INCREMENTAL_LOOKBACK_CHARS = 64;
83
+ /**
84
+ * A processor's statement that its verdict on a PREFIX of an answer is worth acting on, which is
85
+ * what lets the loop release that prefix to the reader instead of holding the whole answer.
86
+ *
87
+ * Declaring it is a promise about every prefix `P` of the final answer, and the loop takes it at
88
+ * face value on the streaming path:
89
+ *
90
+ * 1. REJECTION IS PREFIX-DECIDABLE. The refusal this processor would return for the whole answer is
91
+ * already returned for the first prefix that contains the reason. A refusal that only emerges
92
+ * from the complete answer still fails the run, but by then the reader has seen a prefix — there
93
+ * is no un-sending frames, and that is the cost of opting in.
94
+ * 2. REPLACEMENT IS PREFIX-STABLE UP TO THE WINDOW. Once a character of `process(P)`'s output is
95
+ * more than {@link IncrementalGating.lookbackChars} from the end of that output, it never changes
96
+ * as `P` grows.
97
+ *
98
+ * A broken second promise is caught, not tolerated: the whole-answer pass stays authoritative, and
99
+ * the loop raises a {@link ProcessorFailedError} when its result is not an extension of what the
100
+ * chain already released. So a window too short for a pattern fails loudly rather than streaming the
101
+ * text it was supposed to redact.
102
+ */
103
+ export interface IncrementalGating {
104
+ /**
105
+ * How many characters of this processor's own output stay held back. Undefined →
106
+ * {@link DEFAULT_INCREMENTAL_LOOKBACK_CHARS}. Set it to the length of the longest pattern the
107
+ * processor can act on — anything shorter is a run that fails on the pattern it was written for.
108
+ */
109
+ readonly lookbackChars?: number;
110
+ }
111
+ /**
112
+ * Inspects each model step's answer before anything downstream sees it — before it reaches the live
113
+ * stream, before it is persisted, before it becomes the next step's context.
114
+ *
115
+ * Gating an answer and streaming it as it is generated are mutually exclusive, so registering ANY
116
+ * output processor switches the turn's model call off the run's sink: nothing reaches the subscriber
117
+ * until this chain has ruled on it. How much of that costs the reader is what
118
+ * {@link OutputProcessor.incremental} decides.
119
+ *
120
+ * Runs inside the loop's `process:output:<step>` checkpoint (which also performs the release), so a
121
+ * processor may call a model — a moderation pass is the motivating case — and a replay reads the
122
+ * verdict back instead of re-deciding it.
123
+ */
124
+ export interface OutputProcessor {
125
+ /** Identifies this processor in a rejection or a failure. User-visible; keep it stable. */
126
+ readonly name: string;
127
+ /**
128
+ * Opt this processor into gating a PREFIX, so the turn keeps streaming — see
129
+ * {@link IncrementalGating} for what declaring it promises. Undefined means the whole answer,
130
+ * which is what a processor written against the complete text needs and therefore the only safe
131
+ * default; a chain is incremental only when EVERY member of it declares this, so a neighbour can
132
+ * never downgrade what another author was given.
133
+ */
134
+ readonly incremental?: IncrementalGating;
135
+ process(answer: ModelAnswer, ctx: ProcessorContext): OutputVerdict | Promise<OutputVerdict>;
136
+ }
137
+ /**
138
+ * The run ended because an output processor refused the answer — NOT because the model failed. The
139
+ * two must stay distinguishable: a model failure is worth retrying and worth paging someone about, a
140
+ * refusal is the control doing its job.
141
+ */
142
+ export declare class OutputRejectedError extends Error {
143
+ /** {@link OutputProcessor.name} of the processor that refused. */
144
+ readonly processor: string;
145
+ /** The reason it gave, verbatim. */
146
+ readonly reason: string;
147
+ constructor(processor: string, reason: string);
148
+ }
149
+ /**
150
+ * A processor threw. Wrapped so it can never be mistaken for the model call failing — the loop's
151
+ * only other source of failure at that point in the turn — and so the failure names the processor
152
+ * that produced it instead of surfacing a bare `TypeError` from someone else's code.
153
+ */
154
+ export declare class ProcessorFailedError extends Error {
155
+ /** Which seam it was on, so a reader knows whether the prompt or the answer was in flight. */
156
+ readonly phase: 'input' | 'output';
157
+ /** The processor's `name`. */
158
+ readonly processor: string;
159
+ constructor(phase: 'input' | 'output', processor: string, cause: unknown);
160
+ }
161
+ //# sourceMappingURL=processors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processors.d.ts","sourceRoot":"","sources":["../../../src/spi/processors.ts"],"names":[],"mappings":"AA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,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,eAAe;IAC9B,2FAA2F;IAC3F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IACzC,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,gBAAgB,GAAG,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7F;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,YAAY,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAK5C;CACF;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC;IACnC,8BAA8B;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,YAAY,KAAK,EAAE,OAAO,GAAG,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAQvE;CACF"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The two seams that see a turn's traffic to and from the model: an {@link InputProcessor} rewrites
3
+ * the prompt on its way out, an {@link OutputProcessor} inspects the answer on its way back and may
4
+ * redact, replace or refuse it. Wire them as `AgentLoopDeps.inputProcessors` / `outputProcessors`.
5
+ *
6
+ * WHAT THESE ARE NOT: a second way to decide what enters the context. {@link
7
+ * import('./history-window.js').HistoryWindow} owns SELECTION — which of the thread's messages ride
8
+ * into the turn, and what stands in for the rest. Processors run on whatever selection produced and
9
+ * own TRANSFORMATION — what those messages say. The distinction is load-bearing rather than
10
+ * stylistic: `select` is contractually pure and runs outside any checkpoint, while a processor is
11
+ * allowed to call a model, runs in a checkpoint of its own per step, and rewrites a DERIVED prompt
12
+ * that never becomes the thread's own memory of what was said.
13
+ */
14
+ /**
15
+ * Characters an incremental gate keeps holding at the end of the transformed answer, when a
16
+ * processor declares {@link IncrementalGating} without naming its own window. Wide enough for the
17
+ * patterns a redactor is usually written against — an SSN, an email address, a card number — and
18
+ * deliberately not wider: the window IS the answer's minimum latency tail, since those characters
19
+ * are only released once the whole-answer pass runs.
20
+ */
21
+ export const DEFAULT_INCREMENTAL_LOOKBACK_CHARS = 64;
22
+ /**
23
+ * The run ended because an output processor refused the answer — NOT because the model failed. The
24
+ * two must stay distinguishable: a model failure is worth retrying and worth paging someone about, a
25
+ * refusal is the control doing its job.
26
+ */
27
+ export class OutputRejectedError extends Error {
28
+ /** {@link OutputProcessor.name} of the processor that refused. */
29
+ processor;
30
+ /** The reason it gave, verbatim. */
31
+ reason;
32
+ constructor(processor, reason) {
33
+ super(`Output rejected by "${processor}": ${reason}`);
34
+ this.name = 'OutputRejectedError';
35
+ this.processor = processor;
36
+ this.reason = reason;
37
+ }
38
+ }
39
+ /**
40
+ * A processor threw. Wrapped so it can never be mistaken for the model call failing — the loop's
41
+ * only other source of failure at that point in the turn — and so the failure names the processor
42
+ * that produced it instead of surfacing a bare `TypeError` from someone else's code.
43
+ */
44
+ export class ProcessorFailedError extends Error {
45
+ /** Which seam it was on, so a reader knows whether the prompt or the answer was in flight. */
46
+ phase;
47
+ /** The processor's `name`. */
48
+ processor;
49
+ constructor(phase, processor, cause) {
50
+ super(`${phase} processor "${processor}" failed: ${cause instanceof Error ? cause.message : String(cause)}`);
51
+ this.name = 'ProcessorFailedError';
52
+ this.phase = phase;
53
+ this.processor = processor;
54
+ this.cause = cause;
55
+ }
56
+ }
57
+ //# sourceMappingURL=processors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processors.js","sourceRoot":"","sources":["../../../src/spi/processors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAmEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,EAAE,CAAC;AA0DrD;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,kEAAkE;IACzD,SAAS,CAAS;IAC3B,oCAAoC;IAC3B,MAAM,CAAS;IAExB,YAAY,SAAiB,EAAE,MAAc;QAC3C,KAAK,CAAC,uBAAuB,SAAS,MAAM,MAAM,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,8FAA8F;IACrF,KAAK,CAAqB;IACnC,8BAA8B;IACrB,SAAS,CAAS;IAE3B,YAAY,KAAyB,EAAE,SAAiB,EAAE,KAAc;QACtE,KAAK,CACH,GAAG,KAAK,eAAe,SAAS,aAAa,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACtG,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
@@ -1,3 +1,4 @@
1
+ import type { ElicitationRequest } from '../elicitation.js';
1
2
  /**
2
3
  * The "data plane": live token transport, decoupled from the durable control plane.
3
4
  *
@@ -13,6 +14,38 @@ export type StreamFrame = {
13
14
  t: 'component';
14
15
  name: string;
15
16
  data: unknown;
17
+ }
18
+ /**
19
+ * A question set the run is now parked on. Carries the whole request, so a client renders the form
20
+ * — and knows the total ("Question 1 of 3") — without a second fetch. Identical whether a
21
+ * configured intake or the model's `ask` authored it.
22
+ *
23
+ * `runId` is the run that is PARKED, which is not always the stream this frame arrived on: a
24
+ * delegated sub-agent forwards its frames into its top-level ancestor's stream so the human can
25
+ * see them, and answering it means addressing the CHILD's run. Without the id on the frame a
26
+ * watcher has the form and no way to reply to it.
27
+ */
28
+ | {
29
+ t: 'elicitation';
30
+ runId: string;
31
+ id: string;
32
+ request: ElicitationRequest;
33
+ }
34
+ /**
35
+ * An `action` tool call the run is now parked on, waiting for an approve/reject. Carries the tool
36
+ * and the arguments it was asked to run with, so a watcher can decide without a second fetch.
37
+ *
38
+ * `runId`, like the elicitation frame's, is the run that is PARKED rather than the stream this
39
+ * arrived on: a delegated sub-agent's action suspends its OWN run, and forwarding the frame into
40
+ * the ancestor's stream is the only way a human sees it — so the id has to ride along, or the
41
+ * watcher can see the approval and not make it.
42
+ */
43
+ | {
44
+ t: 'approval';
45
+ runId: string;
46
+ id: string;
47
+ toolName: string;
48
+ input: unknown;
16
49
  };
17
50
  export interface SinkWriter {
18
51
  write(frame: StreamFrame): void | Promise<void>;
@@ -27,4 +60,14 @@ export interface TokenStreamSink {
27
60
  /** Drop any buffer/resources for the run. */
28
61
  close(runId: string): void | Promise<void>;
29
62
  }
63
+ /**
64
+ * Wrap a {@link SinkWriter} so a DELEGATED run forwards its frames into its top-level ancestor's
65
+ * stream but never closes it.
66
+ *
67
+ * Forwarding is what makes a sub-agent visible at all: its own runId is not a stream anyone
68
+ * subscribed to, so a question set it parks on would otherwise be written where nobody reads it.
69
+ * The ancestor owns the stream's lifecycle across however many delegations it spans, so the child's
70
+ * `end()` is a no-op — ending the shared stream mid-parent-run would cut the human off.
71
+ */
72
+ export declare function childSinkWriter(inner: SinkWriter): SinkWriter;
30
73
  //# sourceMappingURL=token-stream-sink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-stream-sink.d.ts","sourceRoot":"","sources":["../../../src/spi/token-stream-sink.ts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C,OAAO,EAAE,kBAAkB,CAAA;CAAE;AAC9E;;;;;;;;GAQG;GACD;IAAE,CAAC,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnF,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,uDAAuD;IACvD,GAAG,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACtD,8EAA8E;IAC9E,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IACrD,6CAA6C;IAC7C,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAO7D"}
@@ -1,2 +1,18 @@
1
- export {};
1
+ /**
2
+ * Wrap a {@link SinkWriter} so a DELEGATED run forwards its frames into its top-level ancestor's
3
+ * stream but never closes it.
4
+ *
5
+ * Forwarding is what makes a sub-agent visible at all: its own runId is not a stream anyone
6
+ * subscribed to, so a question set it parks on would otherwise be written where nobody reads it.
7
+ * The ancestor owns the stream's lifecycle across however many delegations it spans, so the child's
8
+ * `end()` is a no-op — ending the shared stream mid-parent-run would cut the human off.
9
+ */
10
+ export function childSinkWriter(inner) {
11
+ return {
12
+ write: (chunk) => inner.write(chunk),
13
+ end: () => {
14
+ /* the top-level run owns end() */
15
+ },
16
+ };
17
+ }
2
18
  //# sourceMappingURL=token-stream-sink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-stream-sink.js","sourceRoot":"","sources":["../../../src/spi/token-stream-sink.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"token-stream-sink.js","sourceRoot":"","sources":["../../../src/spi/token-stream-sink.ts"],"names":[],"mappings":"AAkDA;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,OAAO;QACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;QACpC,GAAG,EAAE,GAAG,EAAE;YACR,kCAAkC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC"}
package/dist/src/sse.d.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  import type { StreamFrame } from './spi/token-stream-sink.js';
2
2
  /**
3
3
  * Serializes a {@link StreamFrame} into the provider's SSE envelope. A text frame becomes
4
- * `data: {"delta":...}` (byte-identical to the legacy text-only envelope); a component frame
5
- * becomes `event: component\ndata: {name,data}`.
4
+ * `data: {"delta":...}` (byte-identical to the text-only envelope); a component frame becomes
5
+ * `event: component\ndata: {name,data}`; a question set becomes `event: elicitation`, carrying the
6
+ * whole request so a client can render the form without a second fetch; a parked `action` becomes
7
+ * `event: approval`, carrying the tool and its arguments. Both of those also carry the `runId` to
8
+ * answer against, which for a delegated sub-agent is not the run this stream is keyed by.
6
9
  */
7
10
  export declare function frameToSse(frame: StreamFrame): string;
8
11
  //# sourceMappingURL=sse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/sse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAKrD"}
1
+ {"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/sse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAWrD"}