@namzu/sdk 4.0.0 → 5.0.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 (84) hide show
  1. package/CHANGELOG.md +180 -0
  2. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  3. package/dist/agents/SupervisorAgent.js +6 -0
  4. package/dist/agents/SupervisorAgent.js.map +1 -1
  5. package/dist/agents/__tests__/run-agent.test.d.ts +2 -0
  6. package/dist/agents/__tests__/run-agent.test.d.ts.map +1 -0
  7. package/dist/agents/__tests__/run-agent.test.js +143 -0
  8. package/dist/agents/__tests__/run-agent.test.js.map +1 -0
  9. package/dist/agents/index.d.ts +2 -0
  10. package/dist/agents/index.d.ts.map +1 -1
  11. package/dist/agents/index.js +1 -0
  12. package/dist/agents/index.js.map +1 -1
  13. package/dist/agents/runAgent.d.ts +104 -0
  14. package/dist/agents/runAgent.d.ts.map +1 -0
  15. package/dist/agents/runAgent.js +92 -0
  16. package/dist/agents/runAgent.js.map +1 -0
  17. package/dist/provider/__tests__/thinking-support.test.d.ts +2 -0
  18. package/dist/provider/__tests__/thinking-support.test.d.ts.map +1 -0
  19. package/dist/provider/__tests__/thinking-support.test.js +47 -0
  20. package/dist/provider/__tests__/thinking-support.test.js.map +1 -0
  21. package/dist/provider/thinking-support.d.ts +30 -0
  22. package/dist/provider/thinking-support.d.ts.map +1 -0
  23. package/dist/provider/thinking-support.js +32 -0
  24. package/dist/provider/thinking-support.js.map +1 -0
  25. package/dist/public-runtime.d.ts +4 -1
  26. package/dist/public-runtime.d.ts.map +1 -1
  27. package/dist/public-runtime.js +10 -1
  28. package/dist/public-runtime.js.map +1 -1
  29. package/dist/public-types.d.ts +1 -1
  30. package/dist/public-types.d.ts.map +1 -1
  31. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.d.ts +2 -0
  32. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.d.ts.map +1 -0
  33. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.js +94 -0
  34. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.js.map +1 -0
  35. package/dist/runtime/query/__tests__/steering.test.d.ts +2 -0
  36. package/dist/runtime/query/__tests__/steering.test.d.ts.map +1 -0
  37. package/dist/runtime/query/__tests__/steering.test.js +92 -0
  38. package/dist/runtime/query/__tests__/steering.test.js.map +1 -0
  39. package/dist/runtime/query/index.d.ts +10 -0
  40. package/dist/runtime/query/index.d.ts.map +1 -1
  41. package/dist/runtime/query/index.js +1 -0
  42. package/dist/runtime/query/index.js.map +1 -1
  43. package/dist/runtime/query/iteration/phases/context.d.ts +8 -0
  44. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  45. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  46. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  47. package/dist/runtime/query/iteration/phases/tool-review.js +7 -1
  48. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  49. package/dist/runtime/query/steering.d.ts +81 -0
  50. package/dist/runtime/query/steering.d.ts.map +1 -0
  51. package/dist/runtime/query/steering.js +77 -0
  52. package/dist/runtime/query/steering.js.map +1 -0
  53. package/dist/types/agent/manager.d.ts +11 -4
  54. package/dist/types/agent/manager.d.ts.map +1 -1
  55. package/dist/types/agent/supervisor.d.ts +9 -0
  56. package/dist/types/agent/supervisor.d.ts.map +1 -1
  57. package/dist/types/common/index.d.ts +12 -0
  58. package/dist/types/common/index.d.ts.map +1 -1
  59. package/dist/types/common/index.js +7 -0
  60. package/dist/types/common/index.js.map +1 -1
  61. package/dist/types/provider/chat.d.ts +57 -5
  62. package/dist/types/provider/chat.d.ts.map +1 -1
  63. package/dist/types/provider/index.d.ts +1 -1
  64. package/dist/types/provider/index.d.ts.map +1 -1
  65. package/package.json +1 -1
  66. package/src/agents/SupervisorAgent.ts +6 -0
  67. package/src/agents/__tests__/run-agent.test.ts +165 -0
  68. package/src/agents/index.ts +2 -0
  69. package/src/agents/runAgent.ts +179 -0
  70. package/src/provider/__tests__/thinking-support.test.ts +60 -0
  71. package/src/provider/thinking-support.ts +37 -0
  72. package/src/public-runtime.ts +10 -0
  73. package/src/public-types.ts +7 -1
  74. package/src/runtime/query/__tests__/steering-reaches-the-model.test.ts +117 -0
  75. package/src/runtime/query/__tests__/steering.test.ts +121 -0
  76. package/src/runtime/query/index.ts +12 -0
  77. package/src/runtime/query/iteration/phases/context.ts +9 -0
  78. package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
  79. package/src/runtime/query/steering.ts +135 -0
  80. package/src/types/agent/manager.ts +11 -4
  81. package/src/types/agent/supervisor.ts +10 -0
  82. package/src/types/common/index.ts +20 -0
  83. package/src/types/provider/chat.ts +61 -5
  84. package/src/types/provider/index.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,185 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 1cd1094: Thinking is now resolved per model, `effort` is sendable, and thinking tokens
8
+ are reported.
9
+
10
+ **Thinking on a current model was a failed request, not a degraded one.** The
11
+ driver mapped `type: 'enabled'` straight to the wire and everything else to
12
+ `disabled`. The vendor rejects a mismatched mode with a 400 rather than
13
+ falling back: `thinking.type.enabled` is refused from Claude 4.7 onward,
14
+ `adaptive` is refused on 4.5 and earlier, and the always-on models refuse
15
+ `disabled`. One body for every model does not compromise quality, it fails.
16
+
17
+ `ThinkingConfig.type` gains `'adaptive'`, and the Anthropic driver resolves the
18
+ declared intent against the model it is about to call — sending the mode that
19
+ model accepts, dropping a budget where budgets have no meaning, and omitting
20
+ the field entirely rather than asking an always-on model to stop thinking. An
21
+ unrecognised model is treated as manual-only, which is the previous behaviour
22
+ and keeps a gateway serving an older model working.
23
+
24
+ **`ThinkingConfig.display` is narrowed to `'summarized' | 'omitted'`**, and now
25
+ actually reaches the wire. It was `'full' | 'summarized'`: `'full'` is not a
26
+ value any vendor accepts — a declared option that could only ever have been
27
+ rejected — and `'omitted'` was missing. It also was not serialized at all,
28
+ which matters more than it sounds: `display` defaults to `'omitted'` on newer
29
+ models, so a caller wanting to show reasoning received thinking blocks with
30
+ empty text and nothing to explain why.
31
+
32
+ **`effort` is new on `ChatCompletionParams`** — `'low' | 'medium' | 'high' |
33
+ 'xhigh' | 'max'`. It goes out as `output_config.effort`, a _sibling_ of
34
+ `thinking` rather than a field inside it, because it shapes the whole response
35
+ and one manual-mode model accepts it alongside a token budget; nesting it would
36
+ have made that combination unsayable. It is dropped on models that do not
37
+ accept it, and refused in the one combination the vendor rejects — thinking
38
+ disabled at `xhigh`/`max`.
39
+
40
+ **`TokenUsage.reasoningTokens`** carries `output_tokens_details.thinking_tokens`
41
+ when the vendor reports it. It is a _subset_ of `completionTokens`, not an
42
+ addition — reasoning is billed as output, so summing it into a total would
43
+ double-count. Absent means not reported, never zero: coercing would claim every
44
+ turn on every silent driver did no thinking, and streamed events carry the
45
+ breakdown only on the final delta.
46
+
47
+ **Migration.** `display: 'full'` no longer compiles — use `'summarized'`, which
48
+ is what it meant. Code passing `thinking: { type: 'enabled', budgetTokens }`
49
+ keeps working and is now translated per model instead of rejected by newer
50
+ ones. `assertThinkingSupported` in `@namzu/openai` refuses `'adaptive'` as it
51
+ already refused `'enabled'`, since that driver implements neither.
52
+
53
+ Not changed: a report accompanying this work claimed `temperature`, `top_p` and
54
+ `top_k` are rejected on 5-series models and should be dropped by the driver.
55
+ The Messages reference, the extended-thinking page and the thinking
56
+ troubleshooting page document no such restriction, so nothing was implemented —
57
+ silently dropping sampling parameters that would have worked is its own defect.
58
+
59
+ ### Minor Changes
60
+
61
+ - 19d6a0f: A host can now steer a turn that is already running.
62
+
63
+ `AgentManager.queueMessage` and `drainMessages` have existed for a while and
64
+ nothing in the iteration loop ever read them — the type said so outright. So a
65
+ host watching a run go the wrong way had two options, both worse than they
66
+ sound: cancel and start over, throwing away every tool result already paid
67
+ for; or reject through the review gate, which only works when a call happens
68
+ to be pending approval and says "no" when the host meant "yes, but read this
69
+ first".
70
+
71
+ `SteeringChannel` is the delivery that was missing. A host holds one, passes
72
+ it as `steering` on `drainQuery` params or `SupervisorAgentConfig`, and calls
73
+ `steer(text)` whenever it likes. Anything queued while a tool batch is running
74
+ is appended to that batch's **last tool result**.
75
+
76
+ That slot is not a stylistic choice. A `tool_use` block must be answered by a
77
+ `tool_result` with the same id, so a user message wedged between them is
78
+ rejected by the provider — there is no legal place to insert one mid-batch.
79
+ The tool result is the slot that already exists, and this SDK had already
80
+ reached that conclusion for the neighbouring case: a denied call carries its
81
+ reason inside the `tool_result`, precisely because that is where the model
82
+ looks for tool outcomes. Steering is the same delivery with the refusal taken
83
+ out.
84
+
85
+ It deliberately does not interrupt. The batch in flight finishes and the
86
+ guidance lands where the model reads next; a host that wants the current work
87
+ stopped wants `AbortSignal`, which is a different question. Conflating them is
88
+ how "also check the tests" ends up killing a half-written file.
89
+
90
+ Details worth knowing:
91
+
92
+ - Repeated calls before a drain accumulate in order rather than replacing each
93
+ other — two corrections typed a second apart are two things the model should
94
+ see.
95
+ - Guidance is labelled as coming from the operator. Unlabelled it would read
96
+ as something the tool said, so "stop and ask me first" would look like
97
+ output from `bash`. This is not the untrusted-content envelope: the operator
98
+ is the one party whose words the agent _should_ act on.
99
+ - A turn that called no tools has nothing in flight, so guidance stays queued
100
+ for the next one instead of being dropped.
101
+
102
+ Absent, the loop is byte-identical to before.
103
+
104
+ - 1500973: Every driver that cannot think now says so instead of dropping the request.
105
+
106
+ `thinking` sits on `ChatCompletionParams`, so every driver accepts it. Five of
107
+ them — Bedrock, OpenRouter, HTTP, Ollama, LM Studio — implemented none of it
108
+ and dropped the field: the caller got an ordinary completion with an empty
109
+ `reasoning` array, which is indistinguishable from a model that simply chose
110
+ not to reason. The request looked honoured and the answer looked like an
111
+ answer.
112
+
113
+ The OpenAI driver already refused instead, with the reasoning written out
114
+ beside it. So the rule had been decided once and applied once, while five
115
+ siblings went on being silent. It moves to `@namzu/sdk` as
116
+ `assertThinkingUnsupported(driverName, params)`, and a new driver now inherits
117
+ it rather than re-deciding it.
118
+
119
+ The error names the driver, which in a multi-provider setup is the difference
120
+ between a bug report about the model and a one-line configuration fix.
121
+
122
+ **Turning thinking off stays a no-op** on all of them, because that is the
123
+ state a driver without thinking is already in — a config shared across
124
+ providers saying `{ type: 'disabled' }` should not fail on the ones that were
125
+ never going to think.
126
+
127
+ `assertThinkingSupported` in `@namzu/openai` is unchanged as an export and now
128
+ delegates to the shared helper. Its message changed: it no longer says
129
+ "extended thinking", because `adaptive` is refused too and calling that
130
+ extended would be wrong.
131
+
132
+ **Migration.** If you passed `thinking` to any of the five and relied on it
133
+ being ignored, remove it — you were receiving a non-thinking answer either way,
134
+ and now you find out at the call instead of by inspecting an empty array.
135
+
136
+ Not in this change: implementing thinking natively on Bedrock, which serves the
137
+ same Claude models through a different wire and deserves the per-model
138
+ resolution the Anthropic driver just gained. That needs the Converse request
139
+ and response shapes verified against the reference first, and is not something
140
+ to guess at.
141
+
142
+ - a2cedfd: Adds `runAgent` — a provider, a model and a prompt is now a complete agent run.
143
+
144
+ `drainQuery` is the kernel's entry point and takes eleven required parameters,
145
+ four of which are identity fields that throw when missing. That is the right
146
+ shape for a kernel: a run with no tenant is a run no auditor can attribute. It
147
+ is the wrong shape for the first thing anybody writes, and the proof was
148
+ in-tree — the eval suites, the test files and the CLI each hand-assembled the
149
+ same block, which is what a missing front door looks like from the inside.
150
+
151
+ ```ts
152
+ const { output } = await runAgent({
153
+ provider,
154
+ model,
155
+ prompt: "What is 2 + 2?",
156
+ });
157
+ ```
158
+
159
+ It supplies an environment rather than a new engine: it generates the session
160
+ identity a single-tenant local run has no opinion about, defaults the budgets,
161
+ and points the working directory at the process's own. Everything it fills in
162
+ is an ordinary `drainQuery` parameter, so there is no second code path — a
163
+ caller who outgrows it passes more options until they are calling `drainQuery`
164
+ in all but name.
165
+
166
+ The identity comes back on the result, and that pairing is the point.
167
+ Generating one silently would make each call its own session — right for a
168
+ one-shot and wrong for a conversation, where turn two would start with no
169
+ history and nothing would say so. Spread `result.identity` into the next call
170
+ to continue the same session.
171
+
172
+ `model` stays required. `LLMProvider` carries no model — a driver may have been
173
+ constructed with one, but the interface does not expose it, so anything
174
+ inferred here would be a guess billed to the caller.
175
+
176
+ Defaults are safe rather than generous, because nobody reads them before their
177
+ first runaway loop: 16 iterations, a 200k token budget, a 5-minute timeout.
178
+ Each is overridable and named on the option.
179
+
180
+ The README quick start now shows this instead of a bare `provider.chat()` call
181
+ — that example demonstrated an HTTP client, not the kernel.
182
+
3
183
  ## 4.0.0
4
184
 
5
185
  ### Major Changes
@@ -1 +1 @@
1
- {"version":3,"file":"SupervisorAgent.d.ts","sourceRoot":"","sources":["../../src/agents/SupervisorAgent.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,KAAK,EACX,UAAU,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAW,KAAK,EAAU,MAAM,uBAAuB,CAAA;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACpC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,KAAK,EAAE,KAAK,EACZ,GAAG,GAAE,MAAmB,GACtB,eAAe,EAAE,CAcnB;AAED,4DAA4D;AAC5D,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,CAEnF;AAED,qBAAa,eAAgB,SAAQ,aAAa,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAC/F,QAAQ,CAAC,IAAI,EAAG,YAAY,CAAS;gBAEzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,CAAC;IAalE;;;;;;;;OAQG;IACG,GAAG,CACR,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,CAAC;YAMnB,YAAY;CA4O1B"}
1
+ {"version":3,"file":"SupervisorAgent.d.ts","sourceRoot":"","sources":["../../src/agents/SupervisorAgent.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,KAAK,EACX,UAAU,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAW,KAAK,EAAU,MAAM,uBAAuB,CAAA;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACpC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,KAAK,EAAE,KAAK,EACZ,GAAG,GAAE,MAAmB,GACtB,eAAe,EAAE,CAcnB;AAED,4DAA4D;AAC5D,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,CAEnF;AAED,qBAAa,eAAgB,SAAQ,aAAa,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAC/F,QAAQ,CAAC,IAAI,EAAG,YAAY,CAAS;gBAEzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,CAAC;IAalE;;;;;;;;OAQG;IACG,GAAG,CACR,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,CAAC;YAMnB,YAAY;CAkP1B"}
@@ -253,6 +253,12 @@ export class SupervisorAgent extends AbstractAgent {
253
253
  // auto-approve. drainQuery falls back to autoApproveHandler
254
254
  // when resumeHandler is omitted (= same behaviour as before).
255
255
  ...(config.resumeHandler ? { resumeHandler: config.resumeHandler } : {}),
256
+ // Forwarded for the same reason the handler is. A capability the
257
+ // kernel honours in `drainQuery` but that never reaches the
258
+ // surface a host actually constructs is a capability nobody can
259
+ // use — which is the shape of defect this file has already been
260
+ // corrected for twice.
261
+ ...(config.steering ? { steering: config.steering } : {}),
256
262
  ...(config.verificationGate ? { verificationGate: config.verificationGate } : {}),
257
263
  ...(config.sandboxProvider ? { sandboxProvider: config.sandboxProvider } : {}),
258
264
  // Working-memory / compaction seam (optional; absent => unchanged
@@ -1 +1 @@
1
- {"version":3,"file":"SupervisorAgent.js","sourceRoot":"","sources":["../../src/agents/SupervisorAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAEtD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAWrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAG/D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,qBAAqB,CACpC,WAAkC,EAClC,KAAY,EACZ,MAAc,IAAI,CAAC,GAAG,EAAE;IAExB,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC1C,OAAO,EAAE,MAAM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ceRoot":"","sources":["../../../src/agents/__tests__/run-agent.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,143 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { z } from 'zod';
3
+ import { MockLLMProvider, registerMock } from '../../provider/index.js';
4
+ import { ToolRegistry } from '../../registry/index.js';
5
+ import { runAgent } from '../runAgent.js';
6
+ /**
7
+ * `drainQuery` takes eleven required parameters, four of which throw when
8
+ * missing. That is right for a kernel and wrong for the first thing anybody
9
+ * writes — and the proof was in this repo, where the eval suites, the test
10
+ * files and the CLI each hand-assembled the same block.
11
+ *
12
+ * These pin the two things a front door has to get right: that the short form
13
+ * works at all, and that the identity it invents comes back, because a
14
+ * generated session that a caller cannot recover is a conversation that
15
+ * silently restarts on turn two.
16
+ */
17
+ registerMock();
18
+ describe('running an agent through the front door', () => {
19
+ it('runs from a provider, a model and a prompt', async () => {
20
+ const { output, run } = await runAgent({
21
+ provider: new MockLLMProvider({ turns: [{ text: 'four' }] }),
22
+ model: 'mock-model',
23
+ prompt: 'What is 2 + 2?',
24
+ });
25
+ expect(output).toBe('four');
26
+ expect(run.status).toBe('completed');
27
+ expect(run.stopReason).toBe('end_turn');
28
+ });
29
+ it('hands back the identity it generated, so a second turn can continue', async () => {
30
+ const first = await runAgent({
31
+ provider: new MockLLMProvider({ turns: [{ text: 'noted' }] }),
32
+ model: 'mock-model',
33
+ prompt: 'My name is Ada.',
34
+ });
35
+ expect(first.identity.sessionId).toBeTruthy();
36
+ expect(first.identity.tenantId).toBeTruthy();
37
+ const second = await runAgent({
38
+ provider: new MockLLMProvider({ turns: [{ text: 'Ada' }] }),
39
+ model: 'mock-model',
40
+ prompt: 'What is my name?',
41
+ ...first.identity,
42
+ });
43
+ // The same session, not a new one that happens to work.
44
+ expect(second.identity).toEqual(first.identity);
45
+ });
46
+ it('generates a distinct identity per run when none is given', async () => {
47
+ const a = await runAgent({
48
+ provider: new MockLLMProvider({ turns: [{ text: 'a' }] }),
49
+ model: 'mock-model',
50
+ prompt: 'x',
51
+ });
52
+ const b = await runAgent({
53
+ provider: new MockLLMProvider({ turns: [{ text: 'b' }] }),
54
+ model: 'mock-model',
55
+ prompt: 'y',
56
+ });
57
+ expect(a.identity.sessionId).not.toBe(b.identity.sessionId);
58
+ });
59
+ it('carries prior messages when the prompt is a history', async () => {
60
+ const provider = new MockLLMProvider({ turns: [{ text: 'Ada' }] });
61
+ await runAgent({
62
+ provider,
63
+ model: 'mock-model',
64
+ prompt: [
65
+ { role: 'user', content: 'My name is Ada.' },
66
+ { role: 'assistant', content: 'Noted.' },
67
+ { role: 'user', content: 'What is my name?' },
68
+ ],
69
+ });
70
+ const sent = provider.requests[0]?.messages.map((m) => m.content) ?? [];
71
+ expect(sent).toContain('My name is Ada.');
72
+ expect(sent).toContain('What is my name?');
73
+ });
74
+ it('passes instructions through as the system prompt', async () => {
75
+ const provider = new MockLLMProvider({ turns: [{ text: 'ok' }] });
76
+ await runAgent({
77
+ provider,
78
+ model: 'mock-model',
79
+ prompt: 'hello',
80
+ instructions: 'You only answer in haiku.',
81
+ });
82
+ const system = JSON.stringify(provider.requests[0]?.messages ?? []);
83
+ expect(system).toContain('You only answer in haiku.');
84
+ });
85
+ it('runs tools when given a registry', async () => {
86
+ const tools = new ToolRegistry();
87
+ let ran = false;
88
+ tools.register({
89
+ name: 'ping',
90
+ description: 'pings',
91
+ inputSchema: z.object({}),
92
+ category: 'custom',
93
+ permissions: [],
94
+ readOnly: true,
95
+ destructive: false,
96
+ concurrencySafe: true,
97
+ execute: async () => {
98
+ ran = true;
99
+ return { success: true, output: 'pong' };
100
+ },
101
+ });
102
+ const { output } = await runAgent({
103
+ provider: new MockLLMProvider({
104
+ turns: [{ toolCalls: [{ id: 'c1', name: 'ping', rawArguments: '{}' }] }, { text: 'done' }],
105
+ }),
106
+ model: 'mock-model',
107
+ prompt: 'ping it',
108
+ tools,
109
+ });
110
+ expect(ran).toBe(true);
111
+ expect(output).toBe('done');
112
+ });
113
+ it('caps a runaway loop on its own default', async () => {
114
+ const tools = new ToolRegistry();
115
+ tools.register({
116
+ name: 'again',
117
+ description: 'always asks for more',
118
+ inputSchema: z.object({}),
119
+ category: 'custom',
120
+ permissions: [],
121
+ readOnly: true,
122
+ destructive: false,
123
+ concurrencySafe: true,
124
+ execute: async () => ({ success: true, output: 'and again' }),
125
+ });
126
+ // The point of a default budget is that a caller who set none is still
127
+ // protected. Two iterations here rather than the default sixteen, so
128
+ // the test pins the mechanism without paying for it.
129
+ const { run } = await runAgent({
130
+ provider: new MockLLMProvider({
131
+ turns: Array.from({ length: 10 }, () => ({
132
+ toolCalls: [{ id: 'c', name: 'again', rawArguments: '{}' }],
133
+ })),
134
+ }),
135
+ model: 'mock-model',
136
+ prompt: 'loop',
137
+ tools,
138
+ maxIterations: 2,
139
+ });
140
+ expect(run.currentIteration).toBeLessThanOrEqual(2);
141
+ });
142
+ });
143
+ //# sourceMappingURL=run-agent.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-agent.test.js","sourceRoot":"","sources":["../../../src/agents/__tests__/run-agent.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC;;;;;;;;;;GAUG;AAEH,YAAY,EAAE,CAAA;AAEd,QAAQ,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACxD,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC3D,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,QAAQ,CAAC;YACtC,QAAQ,EAAE,IAAI,eAAe,CAAC,EAAE,KAAK,EA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G,EAAE,CAAC,CAAC;oBACxC,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;iBAC3D,CAAC,CAAC;aACH,CAAC;YACF,KAAK,EAAE,YAAY;YACnB,MAAM,EAAE,MAAM;YACd,KAAK;YACL,aAAa,EAAE,CAAC;SAChB,CAAC,CAAA;QAEF,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAA;IACpD,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -7,4 +7,6 @@ export { defineAgent } from './defineAgent.js';
7
7
  export type { DefineAgentOptions } from './defineAgent.js';
8
8
  export { InvocationLock, ConcurrentInvocationError } from './lock.js';
9
9
  export type { Disposable } from './lock.js';
10
+ export { runAgent } from './runAgent.js';
11
+ export type { AgentIdentity, RunAgentOptions, RunAgentResult } from './runAgent.js';
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA;AACrE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA;AACrE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA"}
@@ -5,4 +5,5 @@ export { RouterAgent } from './RouterAgent.js';
5
5
  export { SupervisorAgent } from './SupervisorAgent.js';
6
6
  export { defineAgent } from './defineAgent.js';
7
7
  export { InvocationLock, ConcurrentInvocationError } from './lock.js';
8
+ export { runAgent } from './runAgent.js';
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,104 @@
1
+ import type { ProjectId, SessionId, TenantId, ThreadId } from '../types/ids/index.js';
2
+ import type { Message } from '../types/message/index.js';
3
+ import type { LLMProvider } from '../types/provider/index.js';
4
+ import type { Run, RunEventListener } from '../types/run/index.js';
5
+ import type { ToolRegistryContract } from '../types/tool/index.js';
6
+ /**
7
+ * The session a run belongs to.
8
+ *
9
+ * Every field is generated when absent, and the generated values come back on
10
+ * the result so a second turn can be handed the same ones. That pairing is the
11
+ * point: auto-generating alone would make each call its own session, which is
12
+ * right for a one-shot and silently wrong for a conversation — the second turn
13
+ * would start with no history and no shared budget, and nothing would say so.
14
+ */
15
+ export interface AgentIdentity {
16
+ sessionId?: SessionId;
17
+ threadId?: ThreadId;
18
+ projectId?: ProjectId;
19
+ tenantId?: TenantId;
20
+ }
21
+ export interface RunAgentOptions extends AgentIdentity {
22
+ /** The model driver. The one thing with no sensible default. */
23
+ provider: LLMProvider;
24
+ /** What to ask. A string is turned into a single user message. */
25
+ prompt: string | Message[];
26
+ /** The system prompt. */
27
+ instructions?: string;
28
+ /**
29
+ * Model id.
30
+ *
31
+ * Required, and not defaulted from the provider, because `LLMProvider`
32
+ * carries no model — a driver may have been constructed with one, but the
33
+ * interface does not expose it, so anything this function picked would be
34
+ * a guess billed to the caller. Two required options is a shape someone
35
+ * can hold in their head; a wrong model quietly used is not.
36
+ */
37
+ model: string;
38
+ tools?: ToolRegistryContract;
39
+ /** Defaults to the current working directory. */
40
+ workingDirectory?: string;
41
+ maxIterations?: number;
42
+ tokenBudget?: number;
43
+ timeoutMs?: number;
44
+ temperature?: number;
45
+ /** Names the agent in traces and events. Defaults to `Agent`. */
46
+ name?: string;
47
+ signal?: AbortSignal;
48
+ listener?: RunEventListener;
49
+ }
50
+ export interface RunAgentResult {
51
+ /** The model's final text, or `undefined` if it produced none. */
52
+ readonly output: string | undefined;
53
+ /** The full run — usage, cost, steps, stop reason, every message. */
54
+ readonly run: Run;
55
+ /**
56
+ * The identity this run used, with anything generated filled in.
57
+ *
58
+ * Pass it straight back into the next call to continue the same session.
59
+ */
60
+ readonly identity: Required<AgentIdentity>;
61
+ }
62
+ /**
63
+ * Run an agent, without assembling a kernel by hand.
64
+ *
65
+ * `drainQuery` is the kernel's real entry point and takes eleven required
66
+ * parameters, four of which are identity fields that throw when missing. That
67
+ * is the correct shape for a kernel — a run with no tenant is a run no auditor
68
+ * can attribute — and it is the wrong shape for the first thing anybody
69
+ * writes. The proof was in this repo: the eval suites, the test files and the
70
+ * CLI each hand-assemble the same block, which is what a missing front door
71
+ * looks like from the inside.
72
+ *
73
+ * So this supplies an environment rather than a new engine. It generates the
74
+ * identity a single-tenant local run has no opinion about, defaults the
75
+ * budgets, points the working directory at the process's own, and hands back
76
+ * both the answer and the identity it used. Everything it fills in is a normal
77
+ * `drainQuery` parameter; there is no second code path, and a caller who
78
+ * outgrows it passes more options until they are calling `drainQuery` in all
79
+ * but name.
80
+ *
81
+ * ```ts
82
+ * const { output } = await runAgent({
83
+ * provider,
84
+ * model: 'claude-sonnet-4-5',
85
+ * prompt: 'What is 2 + 2?',
86
+ * })
87
+ * ```
88
+ *
89
+ * A second turn in the same session is the identity handed back, and the
90
+ * previous messages carried forward:
91
+ *
92
+ * ```ts
93
+ * const first = await runAgent({ provider, model, prompt: 'My name is Ada.' })
94
+ *
95
+ * const second = await runAgent({
96
+ * provider,
97
+ * model,
98
+ * ...first.identity,
99
+ * prompt: [...first.run.messages, createUserMessage('What is my name?')],
100
+ * })
101
+ * ```
102
+ */
103
+ export declare function runAgent(options: RunAgentOptions): Promise<RunAgentResult>;
104
+ //# sourceMappingURL=runAgent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runAgent.d.ts","sourceRoot":"","sources":["../../src/agents/runAgent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAQlE;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC7B,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACnB;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACrD,gEAAgE;IAChE,QAAQ,EAAE,WAAW,CAAA;IAErB,kEAAkE;IAClE,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,CAAA;IAE1B,yBAAyB;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb,KAAK,CAAC,EAAE,oBAAoB,CAAA;IAE5B,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,QAAQ,CAAC,EAAE,gBAAgB,CAAA;CAC3B;AAED,MAAM,WAAW,cAAc;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAEnC,qEAAqE;IACrE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;IAEjB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAA;CAC1C;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAyChF"}
@@ -0,0 +1,92 @@
1
+ import { ToolRegistry } from '../registry/tool/execute.js';
2
+ import { drainQuery } from '../runtime/query/index.js';
3
+ import { generateProjectId, generateSessionId, generateTenantId, generateThreadId, } from '../utils/id.js';
4
+ /**
5
+ * Defaults chosen to be safe rather than generous.
6
+ *
7
+ * A front door exists so a first run works without a decision, and the cost of
8
+ * that convenience is that nobody reads these numbers before their first
9
+ * runaway loop. So: a budget that ends a stuck run in seconds rather than
10
+ * dollars, and an iteration cap that stops a tool-calling loop well before a
11
+ * context window does. Every one is overridable and named on the option.
12
+ */
13
+ const DEFAULT_MAX_ITERATIONS = 16;
14
+ const DEFAULT_TOKEN_BUDGET = 200_000;
15
+ const DEFAULT_TIMEOUT_MS = 300_000;
16
+ /**
17
+ * Run an agent, without assembling a kernel by hand.
18
+ *
19
+ * `drainQuery` is the kernel's real entry point and takes eleven required
20
+ * parameters, four of which are identity fields that throw when missing. That
21
+ * is the correct shape for a kernel — a run with no tenant is a run no auditor
22
+ * can attribute — and it is the wrong shape for the first thing anybody
23
+ * writes. The proof was in this repo: the eval suites, the test files and the
24
+ * CLI each hand-assemble the same block, which is what a missing front door
25
+ * looks like from the inside.
26
+ *
27
+ * So this supplies an environment rather than a new engine. It generates the
28
+ * identity a single-tenant local run has no opinion about, defaults the
29
+ * budgets, points the working directory at the process's own, and hands back
30
+ * both the answer and the identity it used. Everything it fills in is a normal
31
+ * `drainQuery` parameter; there is no second code path, and a caller who
32
+ * outgrows it passes more options until they are calling `drainQuery` in all
33
+ * but name.
34
+ *
35
+ * ```ts
36
+ * const { output } = await runAgent({
37
+ * provider,
38
+ * model: 'claude-sonnet-4-5',
39
+ * prompt: 'What is 2 + 2?',
40
+ * })
41
+ * ```
42
+ *
43
+ * A second turn in the same session is the identity handed back, and the
44
+ * previous messages carried forward:
45
+ *
46
+ * ```ts
47
+ * const first = await runAgent({ provider, model, prompt: 'My name is Ada.' })
48
+ *
49
+ * const second = await runAgent({
50
+ * provider,
51
+ * model,
52
+ * ...first.identity,
53
+ * prompt: [...first.run.messages, createUserMessage('What is my name?')],
54
+ * })
55
+ * ```
56
+ */
57
+ export async function runAgent(options) {
58
+ const identity = {
59
+ sessionId: options.sessionId ?? generateSessionId(),
60
+ threadId: options.threadId ?? generateThreadId(),
61
+ projectId: options.projectId ?? generateProjectId(),
62
+ tenantId: options.tenantId ?? generateTenantId(),
63
+ };
64
+ const messages = typeof options.prompt === 'string'
65
+ ? [{ role: 'user', content: options.prompt, timestamp: Date.now() }]
66
+ : options.prompt;
67
+ const run = await drainQuery({
68
+ provider: options.provider,
69
+ tools: options.tools ?? new ToolRegistry(),
70
+ messages,
71
+ workingDirectory: options.workingDirectory ?? process.cwd(),
72
+ runConfig: {
73
+ model: options.model,
74
+ maxIterations: options.maxIterations ?? DEFAULT_MAX_ITERATIONS,
75
+ tokenBudget: options.tokenBudget ?? DEFAULT_TOKEN_BUDGET,
76
+ timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
77
+ ...(options.temperature !== undefined ? { temperature: options.temperature } : {}),
78
+ },
79
+ // One option covers both. `drainQuery` separates the id from the
80
+ // display name because a fleet needs a stable key and a readable
81
+ // label; a single agent has no such tension, and asking for two
82
+ // strings that will always be the same is the kind of ceremony this
83
+ // function exists to remove.
84
+ agentId: options.name ?? 'agent',
85
+ agentName: options.name ?? 'Agent',
86
+ ...(options.instructions ? { systemPrompt: options.instructions } : {}),
87
+ ...(options.signal ? { signal: options.signal } : {}),
88
+ ...identity,
89
+ }, options.listener);
90
+ return { output: run.result, run, identity };
91
+ }
92
+ //# sourceMappingURL=runAgent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runAgent.js","sourceRoot":"","sources":["../../src/agents/runAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAMtD,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,gBAAgB,CAAA;AAuEvB;;;;;;;;GAQG;AACH,MAAM,sBAAsB,GAAG,EAAE,CAAA;AACjC,MAAM,oBAAoB,GAAG,OAAO,CAAA;AACpC,MAAM,kBAAkB,GAAG,OAAO,CAAA;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAwB;IACtD,MAAM,QAAQ,GAA4B;QACzC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,iBAAiB,EAAE;QACnD,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,gBAAgB,EAAE;QAChD,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,iBAAiB,EAAE;QACnD,QAAQ,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