@adonis-agora/agent 0.31.0 → 0.33.0

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 (227) hide show
  1. package/CHANGELOG.md +752 -0
  2. package/dist/providers/agent_provider.d.ts.map +1 -1
  3. package/dist/providers/agent_provider.js +140 -2
  4. package/dist/providers/agent_provider.js.map +1 -1
  5. package/dist/src/agent-deps-factory.d.ts +16 -2
  6. package/dist/src/agent-deps-factory.d.ts.map +1 -1
  7. package/dist/src/agent-deps-factory.js +8 -0
  8. package/dist/src/agent-deps-factory.js.map +1 -1
  9. package/dist/src/agent-deps.d.ts +21 -1
  10. package/dist/src/agent-deps.d.ts.map +1 -1
  11. package/dist/src/agent-deps.js.map +1 -1
  12. package/dist/src/agent-loop.d.ts +226 -9
  13. package/dist/src/agent-loop.d.ts.map +1 -1
  14. package/dist/src/agent-loop.js +1311 -208
  15. package/dist/src/agent-loop.js.map +1 -1
  16. package/dist/src/agent-service.d.ts +27 -0
  17. package/dist/src/agent-service.d.ts.map +1 -1
  18. package/dist/src/agent-service.js +29 -0
  19. package/dist/src/agent-service.js.map +1 -1
  20. package/dist/src/ai-sdk/ai-sdk-model.d.ts.map +1 -1
  21. package/dist/src/ai-sdk/ai-sdk-model.js +21 -1
  22. package/dist/src/ai-sdk/ai-sdk-model.js.map +1 -1
  23. package/dist/src/client/sse.d.ts +32 -2
  24. package/dist/src/client/sse.d.ts.map +1 -1
  25. package/dist/src/client/sse.js +45 -2
  26. package/dist/src/client/sse.js.map +1 -1
  27. package/dist/src/define_config.d.ts +41 -7
  28. package/dist/src/define_config.d.ts.map +1 -1
  29. package/dist/src/define_config.js.map +1 -1
  30. package/dist/src/durable/agent-run-workflow.d.ts +10 -11
  31. package/dist/src/durable/agent-run-workflow.d.ts.map +1 -1
  32. package/dist/src/durable/agent-run-workflow.js +49 -21
  33. package/dist/src/durable/agent-run-workflow.js.map +1 -1
  34. package/dist/src/durable/durable-agent-runner.d.ts +3 -2
  35. package/dist/src/durable/durable-agent-runner.d.ts.map +1 -1
  36. package/dist/src/durable/durable-agent-runner.js +2 -2
  37. package/dist/src/durable/durable-agent-runner.js.map +1 -1
  38. package/dist/src/elicitation.d.ts +207 -0
  39. package/dist/src/elicitation.d.ts.map +1 -0
  40. package/dist/src/elicitation.js +315 -0
  41. package/dist/src/elicitation.js.map +1 -0
  42. package/dist/src/evals/approval-prior.d.ts +58 -0
  43. package/dist/src/evals/approval-prior.d.ts.map +1 -0
  44. package/dist/src/evals/approval-prior.js +82 -0
  45. package/dist/src/evals/approval-prior.js.map +1 -0
  46. package/dist/src/evals/evaluate.d.ts +51 -0
  47. package/dist/src/evals/evaluate.d.ts.map +1 -0
  48. package/dist/src/evals/evaluate.js +76 -0
  49. package/dist/src/evals/evaluate.js.map +1 -0
  50. package/dist/src/evals/governance-sample-source.d.ts +23 -0
  51. package/dist/src/evals/governance-sample-source.d.ts.map +1 -0
  52. package/dist/src/evals/governance-sample-source.js +93 -0
  53. package/dist/src/evals/governance-sample-source.js.map +1 -0
  54. package/dist/src/evals/in-memory-score-store.d.ts +16 -0
  55. package/dist/src/evals/in-memory-score-store.d.ts.map +1 -0
  56. package/dist/src/evals/in-memory-score-store.js +57 -0
  57. package/dist/src/evals/in-memory-score-store.js.map +1 -0
  58. package/dist/src/evals/index.d.ts +15 -0
  59. package/dist/src/evals/index.d.ts.map +1 -0
  60. package/dist/src/evals/index.js +14 -0
  61. package/dist/src/evals/index.js.map +1 -0
  62. package/dist/src/evals/judge.d.ts +30 -0
  63. package/dist/src/evals/judge.d.ts.map +1 -0
  64. package/dist/src/evals/judge.js +53 -0
  65. package/dist/src/evals/judge.js.map +1 -0
  66. package/dist/src/evals/live-scoring.d.ts +42 -0
  67. package/dist/src/evals/live-scoring.d.ts.map +1 -0
  68. package/dist/src/evals/live-scoring.js +103 -0
  69. package/dist/src/evals/live-scoring.js.map +1 -0
  70. package/dist/src/evals/sample-source.d.ts +40 -0
  71. package/dist/src/evals/sample-source.d.ts.map +1 -0
  72. package/dist/src/evals/sample-source.js +33 -0
  73. package/dist/src/evals/sample-source.js.map +1 -0
  74. package/dist/src/evals/score-store.d.ts +54 -0
  75. package/dist/src/evals/score-store.d.ts.map +1 -0
  76. package/dist/src/evals/score-store.js +2 -0
  77. package/dist/src/evals/score-store.js.map +1 -0
  78. package/dist/src/evals/scorers/answer-relevancy.scorer.d.ts +28 -0
  79. package/dist/src/evals/scorers/answer-relevancy.scorer.d.ts.map +1 -0
  80. package/dist/src/evals/scorers/answer-relevancy.scorer.js +42 -0
  81. package/dist/src/evals/scorers/answer-relevancy.scorer.js.map +1 -0
  82. package/dist/src/evals/scorers/approval-outcome.scorer.d.ts +22 -0
  83. package/dist/src/evals/scorers/approval-outcome.scorer.d.ts.map +1 -0
  84. package/dist/src/evals/scorers/approval-outcome.scorer.js +60 -0
  85. package/dist/src/evals/scorers/approval-outcome.scorer.js.map +1 -0
  86. package/dist/src/evals/scorers/approval-risk.scorer.d.ts +28 -0
  87. package/dist/src/evals/scorers/approval-risk.scorer.d.ts.map +1 -0
  88. package/dist/src/evals/scorers/approval-risk.scorer.js +54 -0
  89. package/dist/src/evals/scorers/approval-risk.scorer.js.map +1 -0
  90. package/dist/src/evals/scorers/run-completion.scorer.d.ts +18 -0
  91. package/dist/src/evals/scorers/run-completion.scorer.d.ts.map +1 -0
  92. package/dist/src/evals/scorers/run-completion.scorer.js +55 -0
  93. package/dist/src/evals/scorers/run-completion.scorer.js.map +1 -0
  94. package/dist/src/evals/summarize.d.ts +44 -0
  95. package/dist/src/evals/summarize.d.ts.map +1 -0
  96. package/dist/src/evals/summarize.js +87 -0
  97. package/dist/src/evals/summarize.js.map +1 -0
  98. package/dist/src/evals/types.d.ts +81 -0
  99. package/dist/src/evals/types.d.ts.map +1 -0
  100. package/dist/src/evals/types.js +15 -0
  101. package/dist/src/evals/types.js.map +1 -0
  102. package/dist/src/history-window.d.ts +50 -11
  103. package/dist/src/history-window.d.ts.map +1 -1
  104. package/dist/src/history-window.js +84 -12
  105. package/dist/src/history-window.js.map +1 -1
  106. package/dist/src/index.d.ts +9 -2
  107. package/dist/src/index.d.ts.map +1 -1
  108. package/dist/src/index.js +9 -2
  109. package/dist/src/index.js.map +1 -1
  110. package/dist/src/mcp/server.d.ts +8 -0
  111. package/dist/src/mcp/server.d.ts.map +1 -1
  112. package/dist/src/mcp/server.js +27 -1
  113. package/dist/src/mcp/server.js.map +1 -1
  114. package/dist/src/mcp-client/importer.d.ts +75 -0
  115. package/dist/src/mcp-client/importer.d.ts.map +1 -0
  116. package/dist/src/mcp-client/importer.js +161 -0
  117. package/dist/src/mcp-client/importer.js.map +1 -0
  118. package/dist/src/mcp-client/index.d.ts +9 -0
  119. package/dist/src/mcp-client/index.d.ts.map +1 -0
  120. package/dist/src/mcp-client/index.js +8 -0
  121. package/dist/src/mcp-client/index.js.map +1 -0
  122. package/dist/src/mcp-client/options.d.ts +99 -0
  123. package/dist/src/mcp-client/options.d.ts.map +1 -0
  124. package/dist/src/mcp-client/options.js +2 -0
  125. package/dist/src/mcp-client/options.js.map +1 -0
  126. package/dist/src/mcp-client/tool-input.d.ts +39 -0
  127. package/dist/src/mcp-client/tool-input.d.ts.map +1 -0
  128. package/dist/src/mcp-client/tool-input.js +61 -0
  129. package/dist/src/mcp-client/tool-input.js.map +1 -0
  130. package/dist/src/mcp-client/tool-kind.d.ts +37 -0
  131. package/dist/src/mcp-client/tool-kind.d.ts.map +1 -0
  132. package/dist/src/mcp-client/tool-kind.js +20 -0
  133. package/dist/src/mcp-client/tool-kind.js.map +1 -0
  134. package/dist/src/mcp-client/tool-name.d.ts +22 -0
  135. package/dist/src/mcp-client/tool-name.d.ts.map +1 -0
  136. package/dist/src/mcp-client/tool-name.js +35 -0
  137. package/dist/src/mcp-client/tool-name.js.map +1 -0
  138. package/dist/src/mcp-client/tool-source.d.ts +75 -0
  139. package/dist/src/mcp-client/tool-source.d.ts.map +1 -0
  140. package/dist/src/mcp-client/tool-source.js +244 -0
  141. package/dist/src/mcp-client/tool-source.js.map +1 -0
  142. package/dist/src/mcp-client/transient.d.ts +28 -0
  143. package/dist/src/mcp-client/transient.d.ts.map +1 -0
  144. package/dist/src/mcp-client/transient.js +126 -0
  145. package/dist/src/mcp-client/transient.js.map +1 -0
  146. package/dist/src/mcp-client/unsafe-regex.d.ts +23 -0
  147. package/dist/src/mcp-client/unsafe-regex.d.ts.map +1 -0
  148. package/dist/src/mcp-client/unsafe-regex.js +194 -0
  149. package/dist/src/mcp-client/unsafe-regex.js.map +1 -0
  150. package/dist/src/memory.d.ts +448 -0
  151. package/dist/src/memory.d.ts.map +1 -0
  152. package/dist/src/memory.js +330 -0
  153. package/dist/src/memory.js.map +1 -0
  154. package/dist/src/processors.d.ts +134 -0
  155. package/dist/src/processors.d.ts.map +1 -0
  156. package/dist/src/processors.js +215 -0
  157. package/dist/src/processors.js.map +1 -0
  158. package/dist/src/replay-integrity.d.ts +17 -0
  159. package/dist/src/replay-integrity.d.ts.map +1 -0
  160. package/dist/src/replay-integrity.js +19 -0
  161. package/dist/src/replay-integrity.js.map +1 -0
  162. package/dist/src/runners/inline-agent-runner.d.ts +33 -7
  163. package/dist/src/runners/inline-agent-runner.d.ts.map +1 -1
  164. package/dist/src/runners/inline-agent-runner.js +113 -27
  165. package/dist/src/runners/inline-agent-runner.js.map +1 -1
  166. package/dist/src/skills.d.ts +291 -0
  167. package/dist/src/skills.d.ts.map +1 -0
  168. package/dist/src/skills.js +0 -0
  169. package/dist/src/skills.js.map +1 -0
  170. package/dist/src/spi/agent-runner.d.ts +20 -6
  171. package/dist/src/spi/agent-runner.d.ts.map +1 -1
  172. package/dist/src/spi/agent-store.d.ts +53 -0
  173. package/dist/src/spi/agent-store.d.ts.map +1 -1
  174. package/dist/src/spi/governance-queries.d.ts +5 -0
  175. package/dist/src/spi/governance-queries.d.ts.map +1 -1
  176. package/dist/src/spi/history-window.d.ts +64 -10
  177. package/dist/src/spi/history-window.d.ts.map +1 -1
  178. package/dist/src/spi/model-provider.d.ts +18 -0
  179. package/dist/src/spi/model-provider.d.ts.map +1 -1
  180. package/dist/src/spi/processors.d.ts +161 -0
  181. package/dist/src/spi/processors.d.ts.map +1 -0
  182. package/dist/src/spi/processors.js +57 -0
  183. package/dist/src/spi/processors.js.map +1 -0
  184. package/dist/src/spi/token-stream-sink.d.ts +43 -0
  185. package/dist/src/spi/token-stream-sink.d.ts.map +1 -1
  186. package/dist/src/spi/token-stream-sink.js +17 -1
  187. package/dist/src/spi/token-stream-sink.js.map +1 -1
  188. package/dist/src/sse.d.ts +5 -2
  189. package/dist/src/sse.d.ts.map +1 -1
  190. package/dist/src/sse.js +11 -2
  191. package/dist/src/sse.js.map +1 -1
  192. package/dist/src/stores/lucid-governance-queries.d.ts.map +1 -1
  193. package/dist/src/stores/lucid-governance-queries.js +3 -0
  194. package/dist/src/stores/lucid-governance-queries.js.map +1 -1
  195. package/dist/src/stores/lucid-schema.d.ts.map +1 -1
  196. package/dist/src/stores/lucid-schema.js +15 -0
  197. package/dist/src/stores/lucid-schema.js.map +1 -1
  198. package/dist/src/stores/lucid.d.ts +11 -3
  199. package/dist/src/stores/lucid.d.ts.map +1 -1
  200. package/dist/src/stores/lucid.js +65 -0
  201. package/dist/src/stores/lucid.js.map +1 -1
  202. package/dist/src/structured-output.d.ts +57 -0
  203. package/dist/src/structured-output.d.ts.map +1 -0
  204. package/dist/src/structured-output.js +80 -0
  205. package/dist/src/structured-output.js.map +1 -0
  206. package/dist/src/testing/fake-model-provider.d.ts +8 -4
  207. package/dist/src/testing/fake-model-provider.d.ts.map +1 -1
  208. package/dist/src/testing/fake-model-provider.js +6 -9
  209. package/dist/src/testing/fake-model-provider.js.map +1 -1
  210. package/dist/src/testing/in-memory-governance-queries.d.ts.map +1 -1
  211. package/dist/src/testing/in-memory-governance-queries.js +1 -0
  212. package/dist/src/testing/in-memory-governance-queries.js.map +1 -1
  213. package/dist/src/testing/in-memory-store.d.ts +4 -3
  214. package/dist/src/testing/in-memory-store.d.ts.map +1 -1
  215. package/dist/src/testing/in-memory-store.js +13 -7
  216. package/dist/src/testing/in-memory-store.js.map +1 -1
  217. package/dist/src/testing/index.d.ts +1 -1
  218. package/dist/src/testing/index.d.ts.map +1 -1
  219. package/dist/src/testing/index.js.map +1 -1
  220. package/dist/src/tool-registry.d.ts +9 -0
  221. package/dist/src/tool-registry.d.ts.map +1 -1
  222. package/dist/src/tool-registry.js +11 -0
  223. package/dist/src/tool-registry.js.map +1 -1
  224. package/dist/src/types.d.ts +55 -2
  225. package/dist/src/types.d.ts.map +1 -1
  226. package/package.json +18 -8
  227. package/skills/agent-personas-agents/SKILL.md +16 -12
@@ -0,0 +1,215 @@
1
+ /**
2
+ * Running the processor chains, and the stream buffering an output gate requires. See
3
+ * `./spi/processors.ts` for the seams themselves and the boundary against `HistoryWindow`.
4
+ */
5
+ import { DEFAULT_INCREMENTAL_LOOKBACK_CHARS, ProcessorFailedError, } from './spi/processors.js';
6
+ export function createFrameBuffer() {
7
+ const frames = [];
8
+ return {
9
+ writer: {
10
+ write: (frame) => {
11
+ frames.push(frame);
12
+ },
13
+ end: () => { },
14
+ },
15
+ frames: () => frames,
16
+ };
17
+ }
18
+ /**
19
+ * The frames a passed gate releases to the live stream: the held ones, with every text frame
20
+ * collapsed into ONE carrying `text` — the answer as the chain left it, which is the only version
21
+ * anything downstream is allowed to see. The substitution happens in place, so the answer keeps its
22
+ * position relative to any non-text frame the provider interleaved with it.
23
+ */
24
+ export function releaseGatedFrames(args) {
25
+ const { frames, text } = args;
26
+ const released = [];
27
+ let emitted = false;
28
+ for (const frame of frames) {
29
+ if (frame.t === 'text') {
30
+ if (!emitted && text.length > 0) {
31
+ released.push({ t: 'text', v: text });
32
+ emitted = true;
33
+ }
34
+ continue;
35
+ }
36
+ released.push(frame);
37
+ }
38
+ if (!emitted && text.length > 0) {
39
+ released.push({ t: 'text', v: text });
40
+ }
41
+ return released;
42
+ }
43
+ /**
44
+ * Fold the prompt through each processor in order, every one seeing what the previous one produced.
45
+ * A throw is wrapped so it cannot read as the model call failing — see {@link ProcessorFailedError}.
46
+ */
47
+ export async function runInputProcessors(args) {
48
+ let current = args.prompt;
49
+ for (const processor of args.processors) {
50
+ try {
51
+ current = await processor.process(current, args.ctx);
52
+ }
53
+ catch (error) {
54
+ throw new ProcessorFailedError('input', processor.name, error);
55
+ }
56
+ }
57
+ return current;
58
+ }
59
+ /**
60
+ * Fold the answer through each processor in order. The FIRST rejection ends the chain: a later
61
+ * processor has nothing to add about text that is never going anywhere, and running it would bill a
62
+ * moderation call for a turn already refused.
63
+ */
64
+ export async function runOutputProcessors(args) {
65
+ const { processors, answer, ctx } = args;
66
+ let text = answer.text;
67
+ for (const processor of processors) {
68
+ let verdict;
69
+ try {
70
+ verdict = await processor.process({ text, toolCalls: answer.toolCalls }, ctx);
71
+ }
72
+ catch (error) {
73
+ throw new ProcessorFailedError('output', processor.name, error);
74
+ }
75
+ if (verdict.action === 'reject') {
76
+ return { text, rejection: { processor: processor.name, reason: verdict.reason } };
77
+ }
78
+ if (verdict.action === 'replace') {
79
+ text = verdict.text;
80
+ }
81
+ }
82
+ return { text };
83
+ }
84
+ /**
85
+ * ALL or nothing: one undeclared processor puts the whole chain on the whole-answer path. Its author
86
+ * wrote `process` against the complete text, and a chain that ran it on a prefix because a neighbour
87
+ * opted in would be handing it an input it never agreed to read.
88
+ */
89
+ export function resolveOutputGateMode(processors) {
90
+ if (processors.length === 0) {
91
+ return 'off';
92
+ }
93
+ return processors.every((processor) => processor.incremental !== undefined)
94
+ ? 'incremental'
95
+ : 'whole';
96
+ }
97
+ /**
98
+ * The chain's window is the WIDEST any member asked for: a release safe for the shortest-sighted
99
+ * processor is not safe for the one that matches longer patterns, and the gate makes one release
100
+ * decision for all of them.
101
+ *
102
+ * An undeclared processor contributes nothing rather than the default — it has no window, because a
103
+ * chain containing one never reaches the incremental path at all.
104
+ */
105
+ export function resolveGateLookback(processors) {
106
+ let lookback = 0;
107
+ for (const processor of processors) {
108
+ if (processor.incremental !== undefined) {
109
+ lookback = Math.max(lookback, processor.incremental.lookbackChars ?? DEFAULT_INCREMENTAL_LOOKBACK_CHARS);
110
+ }
111
+ }
112
+ return lookback;
113
+ }
114
+ /**
115
+ * Releases a model call's answer to `writer` as it arrives, holding back the last `lookbackChars`
116
+ * characters of what the chain produces so a processor can still change them.
117
+ *
118
+ * The chain runs over the whole PREFIX accumulated so far rather than over each new frame, so a
119
+ * processor always sees well-formed text and never has to reassemble a pattern split across frames —
120
+ * which is what makes {@link import('./spi/processors.js').IncrementalGating}'s promise a claim
121
+ * about prefixes. It runs once per streamed text frame.
122
+ *
123
+ * Only an EXTENSION of what the reader already has is ever written: a chain whose output stops
124
+ * agreeing with its earlier output has broken its promise, and the loop's whole-answer pass reports
125
+ * that rather than this gate papering over it by re-sending a different answer.
126
+ *
127
+ * Frames that are not text are forwarded live, in arrival order — they are not the answer, so the
128
+ * gate does not own them.
129
+ */
130
+ export function createIncrementalGate(args) {
131
+ const { processors, ctx, lookbackChars, writer } = args;
132
+ let raw = '';
133
+ let released = '';
134
+ let rejection;
135
+ /** A prefix the chain could not rule on. Text stops flowing; the whole-answer pass decides. */
136
+ let stalled = false;
137
+ // The model is free to write without awaiting, and a verdict is asynchronous — serialize, or two
138
+ // prefixes race and the reader gets the answer out of order.
139
+ let queue = Promise.resolve();
140
+ async function advance() {
141
+ if (raw.length === 0) {
142
+ return;
143
+ }
144
+ let settled;
145
+ try {
146
+ settled = await runOutputProcessors({
147
+ processors,
148
+ answer: { text: raw, toolCalls: [] },
149
+ ctx,
150
+ });
151
+ }
152
+ catch {
153
+ // Swallowed HERE only: a prefix pass is an early release, not the verdict. The whole-answer
154
+ // pass runs the same chain and surfaces the failure with the processor's name on it.
155
+ stalled = true;
156
+ return;
157
+ }
158
+ if (settled.rejection !== undefined) {
159
+ rejection = settled.rejection;
160
+ return;
161
+ }
162
+ // The window is trimmed off the chain's OUTPUT, not off the text fed to it: a processor that
163
+ // only saw `raw` minus a tail could not match a pattern straddling that cut, and would release
164
+ // the very text it exists to rewrite.
165
+ const candidate = settled.text.slice(0, Math.max(0, settled.text.length - lookbackChars));
166
+ if (candidate.length <= released.length || !candidate.startsWith(released)) {
167
+ return;
168
+ }
169
+ const delta = candidate.slice(released.length);
170
+ released = candidate;
171
+ await writer.write({ t: 'text', v: delta });
172
+ }
173
+ async function handle(frame) {
174
+ if (rejection !== undefined) {
175
+ return;
176
+ }
177
+ if (frame.t === 'text') {
178
+ raw += frame.v;
179
+ if (!stalled) {
180
+ await advance();
181
+ }
182
+ return;
183
+ }
184
+ await writer.write(frame);
185
+ }
186
+ return {
187
+ writer: {
188
+ write: (frame) => {
189
+ queue = queue.then(() => handle(frame));
190
+ return queue;
191
+ },
192
+ end: () => { },
193
+ },
194
+ settled: () => queue,
195
+ released: () => released,
196
+ rejection: () => rejection,
197
+ };
198
+ }
199
+ /**
200
+ * The tail an incremental gate still owes the reader once the whole-answer pass has settled: the
201
+ * authoritative text minus the prefix already released.
202
+ *
203
+ * Throws when the settled answer is not an extension of that prefix. That check is the reason the
204
+ * final pass stays authoritative for both the stream and the store rather than the stream being
205
+ * stitched together from per-prefix results: agreement between what was streamed and what was stored
206
+ * becomes structural instead of assumed.
207
+ */
208
+ export function gateTail(args) {
209
+ const { processors, released, text } = args;
210
+ if (!text.startsWith(released)) {
211
+ throw new ProcessorFailedError('output', processors.map((processor) => processor.name).join(' → '), new Error(`the gated answer is not an extension of the ${released.length} characters this chain already released — a processor that declares "incremental" promises its result on a prefix stays a prefix of its result on the whole answer, outside the last lookbackChars`));
212
+ }
213
+ return text.slice(released.length);
214
+ }
215
+ //# sourceMappingURL=processors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processors.js","sourceRoot":"","sources":["../../src/processors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,kCAAkC,EAOlC,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAiB7B,MAAM,UAAU,iBAAiB;IAC/B,MAAM,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,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO;QACL,MAAM,EAAE;YACN,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACf,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBACxC,OAAO,KAAK,CAAC;YACf,CAAC;YACD,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC;SACd;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK;QACpB,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ;QACxB,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS;KAC3B,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,IAIxB;IACC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,oBAAoB,CAC5B,QAAQ,EACR,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EACzD,IAAI,KAAK,CACP,+CAA+C,QAAQ,CAAC,MAAM,oMAAoM,CACnQ,CACF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Is this the durable runtime refusing a checkpoint position, rather than anything the agent did?
3
+ *
4
+ * Matched by NAME, and by suffix, because `@adonis-agora/durable` raises the same contract under two
5
+ * class names: the in-process engine throws `NonDeterminismError` and the remote replay context
6
+ * throws `WorkflowNondeterminismError`. Same cross-runtime reasoning as the `isControlFlowError`
7
+ * hook, and as `isControlFlowSignal`'s name check, which exist for exactly this reason on the
8
+ * suspend path.
9
+ *
10
+ * Callers must let these through untouched. Every `catch` in a workflow body reacts by writing more
11
+ * checkpoints (a toolfail, a run-end), and on a journal that has already diverged each of those asks
12
+ * for a position the history cannot supply — so the recovery attempt raises its own refusal, and
13
+ * THAT is the error the operator reads: a message pointing at the wrong seq, naming checkpoints from
14
+ * the recovery path rather than the two that actually disagreed.
15
+ */
16
+ export declare function isReplayIntegrityError(error: unknown): boolean;
17
+ //# sourceMappingURL=replay-integrity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-integrity.d.ts","sourceRoot":"","sources":["../../src/replay-integrity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE9D"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Is this the durable runtime refusing a checkpoint position, rather than anything the agent did?
3
+ *
4
+ * Matched by NAME, and by suffix, because `@adonis-agora/durable` raises the same contract under two
5
+ * class names: the in-process engine throws `NonDeterminismError` and the remote replay context
6
+ * throws `WorkflowNondeterminismError`. Same cross-runtime reasoning as the `isControlFlowError`
7
+ * hook, and as `isControlFlowSignal`'s name check, which exist for exactly this reason on the
8
+ * suspend path.
9
+ *
10
+ * Callers must let these through untouched. Every `catch` in a workflow body reacts by writing more
11
+ * checkpoints (a toolfail, a run-end), and on a journal that has already diverged each of those asks
12
+ * for a position the history cannot supply — so the recovery attempt raises its own refusal, and
13
+ * THAT is the error the operator reads: a message pointing at the wrong seq, naming checkpoints from
14
+ * the recovery path rather than the two that actually disagreed.
15
+ */
16
+ export function isReplayIntegrityError(error) {
17
+ return error instanceof Error && error.name.toLowerCase().endsWith('nondeterminismerror');
18
+ }
19
+ //# sourceMappingURL=replay-integrity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-integrity.js","sourceRoot":"","sources":["../../src/replay-integrity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAC5F,CAAC"}
@@ -1,13 +1,20 @@
1
1
  import type { AgentDepsFactory } from '../agent-deps-factory.js';
2
+ import { type HumanReply } from '../elicitation.js';
2
3
  import type { AgentRunner } from '../spi/agent-runner.js';
3
4
  import type { AgentStore } from '../spi/agent-store.js';
4
- import type { AgentRunInput, Decision } from '../types.js';
5
+ import type { AgentRunInput } from '../types.js';
5
6
  /**
6
- * Runs the agent turn in-process — the default runner (`durable: false`). HITL approval resolves a
7
- * pending promise keyed run-namespaced by `${runId}:${toolCallId}`, so one run's decision can never
8
- * satisfy another's pending action. Sub-agent delegation runs a nested loop; a nested sub-agent has
9
- * no human to prompt, so its action tools are auto-declined rather than hang. Single-replica only —
10
- * durable is the scaled path (deferred).
7
+ * Runs the agent turn in-process — the default runner (`durable: false`). A HITL wait resolves a
8
+ * pending promise keyed run-namespaced by `${runId}:${toolCallId}`, so one run's reply can never
9
+ * satisfy another's pending action.
10
+ *
11
+ * Sub-agent delegation runs a nested loop on a transient sub-thread, and that nested run parks on a
12
+ * human exactly as a top-level one does — under its OWN runId, which is what makes it answerable:
13
+ * the pending row it writes carries that runId, and its frames are forwarded into the top-level
14
+ * ancestor's stream (the only stream anyone subscribed to) carrying it too. The mirror of the
15
+ * durable runner's `sinkRunId`.
16
+ *
17
+ * Single-replica only — durable is the scaled path (deferred).
11
18
  */
12
19
  export declare class InlineAgentRunner implements AgentRunner {
13
20
  private readonly factory;
@@ -17,9 +24,28 @@ export declare class InlineAgentRunner implements AgentRunner {
17
24
  start(input: AgentRunInput): Promise<{
18
25
  runId: string;
19
26
  }>;
20
- signal(runId: string, toolCallId: string, decision: Decision): Promise<void>;
27
+ /**
28
+ * Deliver a human's reply to whichever wait this run is parked on.
29
+ *
30
+ * An approval wait takes a {@link Decision} only. Answers addressed there are refused rather than
31
+ * delivered: `approved` is absent on them, and the tool-call row would record a rejection the
32
+ * person never made. The refusal leaves the wait intact, so the approval is still there to make.
33
+ *
34
+ * The other direction IS delivered — a question set parks as a `pending_approval` action, so an
35
+ * operator pressing Approve on it is expected, and the loop reads that as "confirmed the
36
+ * pre-picked answers".
37
+ */
38
+ signal(runId: string, toolCallId: string, reply: HumanReply): Promise<void>;
21
39
  cancel(runId: string): Promise<void>;
22
40
  private topLevelHooks;
41
+ /**
42
+ * The two waits a run parks on, keyed by the run that is parked. Identical for a top-level run and
43
+ * for a delegated one: `signal(runId, …)` finds either, because the pending map belongs to the
44
+ * runner rather than to a run.
45
+ */
46
+ private humanHooks;
47
+ /** Hold a run at `key` until a human's reply arrives through {@link InlineAgentRunner.signal}. */
48
+ private park;
23
49
  /** Delegate to another agent as a nested in-process run (a transient sub-thread). */
24
50
  private runNested;
25
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"inline-agent-runner.d.ts","sourceRoot":"","sources":["../../../src/runners/inline-agent-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAS,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElE;;;;;;GAMG;AACH,qBAAa,iBAAkB,YAAW,WAAW;IAIjD,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmD;IAE3E,YACmB,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,UAAU,EAChC;IAEE,KAAK,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE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ED,OAAO,CAAC,aAAa;IAkCrB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAWlB,kGAAkG;IAClG,OAAO,CAAC,IAAI;IAMZ,qFAAqF;YACvE,SAAS;CAgExB"}
@@ -1,12 +1,20 @@
1
1
  import { utcDay } from '../agent-deps.js';
2
- import { runAgentLoop } from '../agent-loop.js';
2
+ import { runAgentLoop, settleAll } from '../agent-loop.js';
3
3
  import { spannedAgent } from '../diagnostics.js';
4
+ import { HumanReplyMismatchError, isHumanDecision, } from '../elicitation.js';
5
+ import { childSinkWriter } from '../spi/token-stream-sink.js';
4
6
  /**
5
- * Runs the agent turn in-process — the default runner (`durable: false`). HITL approval resolves a
6
- * pending promise keyed run-namespaced by `${runId}:${toolCallId}`, so one run's decision can never
7
- * satisfy another's pending action. Sub-agent delegation runs a nested loop; a nested sub-agent has
8
- * no human to prompt, so its action tools are auto-declined rather than hang. Single-replica only —
9
- * durable is the scaled path (deferred).
7
+ * Runs the agent turn in-process — the default runner (`durable: false`). A HITL wait resolves a
8
+ * pending promise keyed run-namespaced by `${runId}:${toolCallId}`, so one run's reply can never
9
+ * satisfy another's pending action.
10
+ *
11
+ * Sub-agent delegation runs a nested loop on a transient sub-thread, and that nested run parks on a
12
+ * human exactly as a top-level one does — under its OWN runId, which is what makes it answerable:
13
+ * the pending row it writes carries that runId, and its frames are forwarded into the top-level
14
+ * ancestor's stream (the only stream anyone subscribed to) carrying it too. The mirror of the
15
+ * durable runner's `sinkRunId`.
16
+ *
17
+ * Single-replica only — durable is the scaled path (deferred).
10
18
  */
11
19
  export class InlineAgentRunner {
12
20
  factory;
@@ -20,7 +28,19 @@ export class InlineAgentRunner {
20
28
  const runId = crypto.randomUUID();
21
29
  const day = input.day ?? utcDay();
22
30
  const deps = this.factory.forAgent(input.agentName);
23
- const hooks = this.topLevelHooks(runId, deps, input.actor, day);
31
+ const hooks = this.topLevelHooks({
32
+ runId,
33
+ deps,
34
+ actor: input.actor,
35
+ day,
36
+ // The chain this run sits on with its OWN agent appended — what lets a child recognise a
37
+ // delegation back to an agent the chain has already passed through.
38
+ chainBelow: [
39
+ ...(input.delegationPath ?? []),
40
+ ...(input.agentName !== undefined ? [input.agentName] : []),
41
+ ],
42
+ depth: input.delegationDepth ?? 0,
43
+ });
24
44
  // The root turn span — the trace's root, correlated to every child step span by traceId = runId.
25
45
  // Emitted by the runner (not the shared loop) because the inline runner executes the loop exactly
26
46
  // once; the durable runner's body replays, so it roots its trace by traceId instead. Zero-cost
@@ -38,13 +58,28 @@ export class InlineAgentRunner {
38
58
  });
39
59
  return { runId };
40
60
  }
41
- async signal(runId, toolCallId, decision) {
61
+ /**
62
+ * Deliver a human's reply to whichever wait this run is parked on.
63
+ *
64
+ * An approval wait takes a {@link Decision} only. Answers addressed there are refused rather than
65
+ * delivered: `approved` is absent on them, and the tool-call row would record a rejection the
66
+ * person never made. The refusal leaves the wait intact, so the approval is still there to make.
67
+ *
68
+ * The other direction IS delivered — a question set parks as a `pending_approval` action, so an
69
+ * operator pressing Approve on it is expected, and the loop reads that as "confirmed the
70
+ * pre-picked answers".
71
+ */
72
+ async signal(runId, toolCallId, reply) {
42
73
  const key = `${runId}:${toolCallId}`;
43
- const resolve = this.pending.get(key);
44
- if (resolve !== undefined) {
45
- this.pending.delete(key);
46
- resolve(decision);
74
+ const parked = this.pending.get(key);
75
+ if (parked === undefined) {
76
+ return;
47
77
  }
78
+ if (parked.on === 'approval' && !isHumanDecision(reply)) {
79
+ throw new HumanReplyMismatchError(runId, toolCallId);
80
+ }
81
+ this.pending.delete(key);
82
+ parked.resolve(reply);
48
83
  }
49
84
  async cancel(runId) {
50
85
  // Best-effort: settle the run `cancelled` (first-terminal, so a completed run stays completed),
@@ -54,38 +89,89 @@ export class InlineAgentRunner {
54
89
  const writer = await deps.sink.open(runId);
55
90
  await writer.end();
56
91
  }
57
- topLevelHooks(runId, deps, actor, day) {
92
+ topLevelHooks(args) {
93
+ const { runId, deps, actor, day, chainBelow, depth } = args;
58
94
  return {
59
95
  runId,
60
96
  durable: false,
61
97
  openSink: () => deps.sink.open(runId),
62
- awaitApproval: (call) => new Promise((resolve) => {
63
- // Run-namespaced key: `${runId}:${toolCallId}` — one run can't approve another's tool call.
64
- this.pending.set(`${runId}:${call.id}`, resolve);
65
- }),
98
+ ...this.humanHooks(runId),
66
99
  step: (_name, fn) => fn(),
67
- runAgent: (agentName, task) => this.runNested(agentName, task, actor, day),
100
+ // Nothing here records a position, so a turn's read tools can simply overlap.
101
+ parallel: settleAll,
102
+ runAgent: (agentName, task) => this.runNested({
103
+ agentName,
104
+ task,
105
+ actor,
106
+ day,
107
+ depth: depth + 1,
108
+ path: chainBelow,
109
+ parentRunId: runId,
110
+ // This run owns the stream a human subscribed to, so every delegation below it writes here.
111
+ sinkRunId: runId,
112
+ }),
68
113
  };
69
114
  }
115
+ /**
116
+ * The two waits a run parks on, keyed by the run that is parked. Identical for a top-level run and
117
+ * for a delegated one: `signal(runId, …)` finds either, because the pending map belongs to the
118
+ * runner rather than to a run.
119
+ */
120
+ humanHooks(runId) {
121
+ return {
122
+ awaitApproval: (call) =>
123
+ // Run-namespaced key: `${runId}:${toolCallId}` — one run can't approve another's tool call.
124
+ this.park(`${runId}:${call.id}`, 'approval'),
125
+ // An answer and an approval reach a parked run by the same channel, because a question set is
126
+ // itself a `pending_approval` row: `POST /agent/tool-call/answer` and `/approve` both land here.
127
+ awaitAnswers: (request) => this.park(`${runId}:${request.id}`, 'answers'),
128
+ };
129
+ }
130
+ /** Hold a run at `key` until a human's reply arrives through {@link InlineAgentRunner.signal}. */
131
+ park(key, on) {
132
+ return new Promise((resolve) => {
133
+ this.pending.set(key, { on, resolve });
134
+ });
135
+ }
70
136
  /** Delegate to another agent as a nested in-process run (a transient sub-thread). */
71
- async runNested(agentName, task, actor, day) {
137
+ async runNested(args) {
138
+ const { agentName, task, actor, day, depth, path, parentRunId, sinkRunId } = args;
72
139
  const subThread = await this.store.createThread({ actor, persona: 'default', transient: true });
73
140
  const runId = crypto.randomUUID();
74
141
  const deps = this.factory.forAgent(agentName);
75
142
  const hooks = {
76
143
  runId,
77
144
  durable: false,
78
- openSink: () => deps.sink.open(runId),
79
- // A nested sub-agent has no human to ask — decline action tools rather than hang.
80
- awaitApproval: async () => ({
81
- approved: false,
82
- reason: 'nested sub-agent cannot request human approval',
83
- }),
145
+ // Forward into the ancestor's stream but never end it: the top-level run owns that lifecycle
146
+ // across however many delegations it spans.
147
+ openSink: async () => childSinkWriter(await deps.sink.open(sinkRunId)),
148
+ // A delegated run parks on a human like any other, keyed by ITS OWN runId — which is the id
149
+ // its pending row and its forwarded frames both carry, so the wait can be answered.
150
+ ...this.humanHooks(runId),
84
151
  step: (_name, fn) => fn(),
85
- runAgent: (childName, childTask) => this.runNested(childName, childTask, actor, day),
152
+ parallel: settleAll,
153
+ runAgent: (childName, childTask) => this.runNested({
154
+ agentName: childName,
155
+ task: childTask,
156
+ actor,
157
+ day,
158
+ depth: depth + 1,
159
+ path: [...path, agentName],
160
+ parentRunId: runId,
161
+ sinkRunId,
162
+ }),
86
163
  };
87
164
  // A nested sub-agent run is its own trace (its own runId), rooted by the same turn span.
88
- return spannedAgent('turn', runId, { runId }, () => runAgentLoop({ ...deps, day }, { threadId: subThread.id, actor, userText: task, agentName, day }, hooks), (result) => ({ textLength: result.text.length }));
165
+ return spannedAgent('turn', runId, { runId }, () => runAgentLoop({ ...deps, day }, {
166
+ threadId: subThread.id,
167
+ actor,
168
+ userText: task,
169
+ agentName,
170
+ day,
171
+ parentRunId,
172
+ delegationDepth: depth,
173
+ delegationPath: path,
174
+ }, hooks), (result) => ({ textLength: result.text.length }));
89
175
  }
90
176
  }
91
177
  //# sourceMappingURL=inline-agent-runner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inline-agent-runner.js","sourceRoot":"","sources":["../../../src/runners/inline-agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAuB,YAAY,E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