@namzu/sdk 4.0.0 → 5.1.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.
- package/CHANGELOG.md +282 -0
- package/README.md +2 -2
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +6 -0
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/__tests__/run-agent.test.d.ts +2 -0
- package/dist/agents/__tests__/run-agent.test.d.ts.map +1 -0
- package/dist/agents/__tests__/run-agent.test.js +143 -0
- package/dist/agents/__tests__/run-agent.test.js.map +1 -0
- package/dist/agents/index.d.ts +2 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +1 -0
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/runAgent.d.ts +104 -0
- package/dist/agents/runAgent.d.ts.map +1 -0
- package/dist/agents/runAgent.js +92 -0
- package/dist/agents/runAgent.js.map +1 -0
- package/dist/provider/__tests__/thinking-support.test.d.ts +2 -0
- package/dist/provider/__tests__/thinking-support.test.d.ts.map +1 -0
- package/dist/provider/__tests__/thinking-support.test.js +47 -0
- package/dist/provider/__tests__/thinking-support.test.js.map +1 -0
- package/dist/provider/__tests__/typed-error-classification.test.d.ts +2 -0
- package/dist/provider/__tests__/typed-error-classification.test.d.ts.map +1 -0
- package/dist/provider/__tests__/typed-error-classification.test.js +123 -0
- package/dist/provider/__tests__/typed-error-classification.test.js.map +1 -0
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +23 -7
- package/dist/provider/retry.js.map +1 -1
- package/dist/provider/thinking-support.d.ts +30 -0
- package/dist/provider/thinking-support.d.ts.map +1 -0
- package/dist/provider/thinking-support.js +32 -0
- package/dist/provider/thinking-support.js.map +1 -0
- package/dist/public-runtime.d.ts +4 -1
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +10 -1
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +1 -0
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +4 -0
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +1 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/runtime/query/__tests__/steering-reaches-the-model.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/steering-reaches-the-model.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/steering-reaches-the-model.test.js +94 -0
- package/dist/runtime/query/__tests__/steering-reaches-the-model.test.js.map +1 -0
- package/dist/runtime/query/__tests__/steering.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/steering.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/steering.test.js +92 -0
- package/dist/runtime/query/__tests__/steering.test.js.map +1 -0
- package/dist/runtime/query/__tests__/stream-recovery.test.js +5 -0
- package/dist/runtime/query/__tests__/stream-recovery.test.js.map +1 -1
- package/dist/runtime/query/index.d.ts +10 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +1 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +8 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +7 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/steering.d.ts +81 -0
- package/dist/runtime/query/steering.d.ts.map +1 -0
- package/dist/runtime/query/steering.js +77 -0
- package/dist/runtime/query/steering.js.map +1 -0
- package/dist/types/agent/manager.d.ts +11 -4
- package/dist/types/agent/manager.d.ts.map +1 -1
- package/dist/types/agent/supervisor.d.ts +9 -0
- package/dist/types/agent/supervisor.d.ts.map +1 -1
- package/dist/types/common/index.d.ts +12 -0
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +7 -0
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +57 -5
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/errors.d.ts +0 -17
- package/dist/types/provider/errors.d.ts.map +1 -1
- package/dist/types/provider/errors.js +60 -0
- package/dist/types/provider/errors.js.map +1 -1
- package/dist/types/provider/index.d.ts +1 -1
- package/dist/types/provider/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agents/SupervisorAgent.ts +6 -0
- package/src/agents/__tests__/run-agent.test.ts +165 -0
- package/src/agents/index.ts +2 -0
- package/src/agents/runAgent.ts +179 -0
- package/src/provider/__tests__/thinking-support.test.ts +60 -0
- package/src/provider/__tests__/typed-error-classification.test.ts +143 -0
- package/src/provider/retry.ts +23 -7
- package/src/provider/thinking-support.ts +37 -0
- package/src/public-runtime.ts +10 -0
- package/src/public-tools.ts +4 -0
- package/src/public-types.ts +7 -1
- package/src/runtime/query/__tests__/steering-reaches-the-model.test.ts +117 -0
- package/src/runtime/query/__tests__/steering.test.ts +121 -0
- package/src/runtime/query/__tests__/stream-recovery.test.ts +5 -0
- package/src/runtime/query/index.ts +12 -0
- package/src/runtime/query/iteration/phases/context.ts +9 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
- package/src/runtime/query/steering.ts +135 -0
- package/src/types/agent/manager.ts +11 -4
- package/src/types/agent/supervisor.ts +10 -0
- package/src/types/common/index.ts +20 -0
- package/src/types/provider/chat.ts +61 -5
- package/src/types/provider/errors.ts +71 -0
- package/src/types/provider/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,287 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8dbb98b: Adds `@namzu/project` — a conventional agent directory, read into typed,
|
|
8
|
+
inspectable definitions.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
my-agent/agent/
|
|
12
|
+
├── agent.ts # optional — model, temperature, budgets
|
|
13
|
+
├── instructions.md # optional — the system prompt
|
|
14
|
+
├── tools/search.ts # default-exports defineTool(…)
|
|
15
|
+
└── skills/plan-a-trip/SKILL.md
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
const { manifest, ok, diagnostics } = await loadProject("./agent");
|
|
20
|
+
await runAgent(deriveRunOptions(manifest, { provider, prompt: "go" }));
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
A **loader, not a runner**, and not in `@namzu/sdk`: the kernel does not
|
|
24
|
+
mandate a directory layout any more than a kernel mandates `/etc/foo.conf`.
|
|
25
|
+
`deriveRunOptions` returns ordinary `RunAgentOptions`, so there is no second
|
|
26
|
+
code path and no behaviour reachable only through the convention.
|
|
27
|
+
|
|
28
|
+
**Importing a directory runs it.** `loadProject` imports every module-backed
|
|
29
|
+
file, in this process, with this process's privileges — a top-level side effect
|
|
30
|
+
in `tools/search.ts` happens during the load. There is no in-process boundary
|
|
31
|
+
that would change that, and `@namzu/sandbox` confines tool execution rather
|
|
32
|
+
than module import. For a directory whose author you are not,
|
|
33
|
+
`modules: 'skip'` imports nothing while still returning the full structural
|
|
34
|
+
truth: every path, the instructions, the skills, duplicate detection. That is
|
|
35
|
+
also the mode a CI gate and a UI file tree want.
|
|
36
|
+
|
|
37
|
+
**TypeScript without a build step.** Files load through `await import()`, so
|
|
38
|
+
`.ts` is handled by Node's own type stripping. Stripping erases types rather
|
|
39
|
+
than transforming code, so `enum`, decorators, parameter properties, runtime
|
|
40
|
+
`namespace`, extensionless relative imports and tsconfig `paths` aliases do not
|
|
41
|
+
work — the README tables each one against what to write instead, and the errors
|
|
42
|
+
name the remedy. A host that needs them passes `importModule` and hands in
|
|
43
|
+
`jiti` or a `tsx`-registered importer: three lines in the host, no bundler in
|
|
44
|
+
this dependency tree.
|
|
45
|
+
|
|
46
|
+
**Nothing fails silently.** A file that cannot load is reported with its path
|
|
47
|
+
and reason, never dropped. Two behaviours worth knowing: a symlink is refused
|
|
48
|
+
rather than followed, because the file that would be imported is not the file
|
|
49
|
+
that was listed; and a timed-out import is `'abandoned'`, not `'failed'`, since
|
|
50
|
+
`import()` cannot be cancelled — the module may still finish, and Node caches
|
|
51
|
+
it, so a later load in the same process can see the same file succeed.
|
|
52
|
+
|
|
53
|
+
`channels/` and `schedules/` are **not** in this version. A trigger of
|
|
54
|
+
`{ id, handler }` cannot express a signed webhook — verification needs the raw
|
|
55
|
+
body, and a handler receiving a parsed one can never check an HMAC — carries no
|
|
56
|
+
idempotency key while webhooks retry and schedules double-fire, and a cron
|
|
57
|
+
field with no timezone story is a declaration nothing drives. Each would be a
|
|
58
|
+
breaking change to a published type; the shape question gets its own pass.
|
|
59
|
+
|
|
60
|
+
`@namzu/sdk` additionally exports `resolveWithin`, `resolveWithinReal` and
|
|
61
|
+
`isWithin`, the containment helpers its own filesystem tools use. They were
|
|
62
|
+
internal while three call sites outside that file needed them.
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- 7ac89da: A driver that classified its own failure was being punished for it, in two
|
|
67
|
+
places, and both shipped in 5.0.0.
|
|
68
|
+
|
|
69
|
+
**`classifyProviderError` never read `kind`.** A `ProviderRequestError` — the
|
|
70
|
+
type first-party drivers throw when they have diagnosed a failure themselves —
|
|
71
|
+
fell through to the status heuristics, where a carefully-determined
|
|
72
|
+
`context_overflow` carrying a 400 became `invalid_request`. Three of the six
|
|
73
|
+
kinds landed wrong that way:
|
|
74
|
+
|
|
75
|
+
| kind | was | now |
|
|
76
|
+
| ------------------ | -------------------------------- | ---------------------------------------- |
|
|
77
|
+
| `context_overflow` | `invalid_request`, not retryable | `context_length_exceeded`, not retryable |
|
|
78
|
+
| `server` | `invalid_request`, not retryable | `server_error`, **retryable** |
|
|
79
|
+
| `network` | `invalid_request`, not retryable | `network`, **retryable** |
|
|
80
|
+
|
|
81
|
+
The overflow case was not cosmetic. The run loop reaches for compaction when it
|
|
82
|
+
sees `context_length_exceeded`, so relief — the one provider failure this
|
|
83
|
+
kernel can actually do something about — was unreachable for exactly the
|
|
84
|
+
drivers that had diagnosed the problem correctly.
|
|
85
|
+
|
|
86
|
+
**`withProviderRetry` rethrew such errors before the retry loop.** Its comment
|
|
87
|
+
justified preserving the driver's classification, which is right; the code also
|
|
88
|
+
skipped retrying, which is a separate decision nobody made. A first-party HTTP
|
|
89
|
+
or OpenRouter driver reporting a 429 as `kind: 'throttle'` got exactly one
|
|
90
|
+
attempt, while the identical failure from a driver that classified nothing got
|
|
91
|
+
the full backoff.
|
|
92
|
+
|
|
93
|
+
Retry is now decided the same way for both, from the classification's
|
|
94
|
+
`retryable`. The original error still escapes to the run boundary, so
|
|
95
|
+
`run.lastProviderError` keeps reporting the driver's own
|
|
96
|
+
`{ kind, status, retryAfterMs }` — wrapping there would have fixed the retry
|
|
97
|
+
and lost the vendor's `kind`, which the existing stream-recovery test caught.
|
|
98
|
+
|
|
99
|
+
**What changes for you.** A 429, a 5xx or a socket failure from
|
|
100
|
+
`@namzu/http` or `@namzu/openrouter` is now retried with backoff instead of
|
|
101
|
+
failing on the first attempt, and a context overflow from those drivers now
|
|
102
|
+
triggers compaction instead of failing the run. If you were relying on a typed
|
|
103
|
+
error failing fast, `retry: { maxRetries: 0 }` on `drainQuery` restores that.
|
|
104
|
+
|
|
105
|
+
## 5.0.0
|
|
106
|
+
|
|
107
|
+
### Major Changes
|
|
108
|
+
|
|
109
|
+
- 1cd1094: Thinking is now resolved per model, `effort` is sendable, and thinking tokens
|
|
110
|
+
are reported.
|
|
111
|
+
|
|
112
|
+
**Thinking on a current model was a failed request, not a degraded one.** The
|
|
113
|
+
driver mapped `type: 'enabled'` straight to the wire and everything else to
|
|
114
|
+
`disabled`. The vendor rejects a mismatched mode with a 400 rather than
|
|
115
|
+
falling back: `thinking.type.enabled` is refused from Claude 4.7 onward,
|
|
116
|
+
`adaptive` is refused on 4.5 and earlier, and the always-on models refuse
|
|
117
|
+
`disabled`. One body for every model does not compromise quality, it fails.
|
|
118
|
+
|
|
119
|
+
`ThinkingConfig.type` gains `'adaptive'`, and the Anthropic driver resolves the
|
|
120
|
+
declared intent against the model it is about to call — sending the mode that
|
|
121
|
+
model accepts, dropping a budget where budgets have no meaning, and omitting
|
|
122
|
+
the field entirely rather than asking an always-on model to stop thinking. An
|
|
123
|
+
unrecognised model is treated as manual-only, which is the previous behaviour
|
|
124
|
+
and keeps a gateway serving an older model working.
|
|
125
|
+
|
|
126
|
+
**`ThinkingConfig.display` is narrowed to `'summarized' | 'omitted'`**, and now
|
|
127
|
+
actually reaches the wire. It was `'full' | 'summarized'`: `'full'` is not a
|
|
128
|
+
value any vendor accepts — a declared option that could only ever have been
|
|
129
|
+
rejected — and `'omitted'` was missing. It also was not serialized at all,
|
|
130
|
+
which matters more than it sounds: `display` defaults to `'omitted'` on newer
|
|
131
|
+
models, so a caller wanting to show reasoning received thinking blocks with
|
|
132
|
+
empty text and nothing to explain why.
|
|
133
|
+
|
|
134
|
+
**`effort` is new on `ChatCompletionParams`** — `'low' | 'medium' | 'high' |
|
|
135
|
+
'xhigh' | 'max'`. It goes out as `output_config.effort`, a _sibling_ of
|
|
136
|
+
`thinking` rather than a field inside it, because it shapes the whole response
|
|
137
|
+
and one manual-mode model accepts it alongside a token budget; nesting it would
|
|
138
|
+
have made that combination unsayable. It is dropped on models that do not
|
|
139
|
+
accept it, and refused in the one combination the vendor rejects — thinking
|
|
140
|
+
disabled at `xhigh`/`max`.
|
|
141
|
+
|
|
142
|
+
**`TokenUsage.reasoningTokens`** carries `output_tokens_details.thinking_tokens`
|
|
143
|
+
when the vendor reports it. It is a _subset_ of `completionTokens`, not an
|
|
144
|
+
addition — reasoning is billed as output, so summing it into a total would
|
|
145
|
+
double-count. Absent means not reported, never zero: coercing would claim every
|
|
146
|
+
turn on every silent driver did no thinking, and streamed events carry the
|
|
147
|
+
breakdown only on the final delta.
|
|
148
|
+
|
|
149
|
+
**Migration.** `display: 'full'` no longer compiles — use `'summarized'`, which
|
|
150
|
+
is what it meant. Code passing `thinking: { type: 'enabled', budgetTokens }`
|
|
151
|
+
keeps working and is now translated per model instead of rejected by newer
|
|
152
|
+
ones. `assertThinkingSupported` in `@namzu/openai` refuses `'adaptive'` as it
|
|
153
|
+
already refused `'enabled'`, since that driver implements neither.
|
|
154
|
+
|
|
155
|
+
Not changed: a report accompanying this work claimed `temperature`, `top_p` and
|
|
156
|
+
`top_k` are rejected on 5-series models and should be dropped by the driver.
|
|
157
|
+
The Messages reference, the extended-thinking page and the thinking
|
|
158
|
+
troubleshooting page document no such restriction, so nothing was implemented —
|
|
159
|
+
silently dropping sampling parameters that would have worked is its own defect.
|
|
160
|
+
|
|
161
|
+
### Minor Changes
|
|
162
|
+
|
|
163
|
+
- 19d6a0f: A host can now steer a turn that is already running.
|
|
164
|
+
|
|
165
|
+
`AgentManager.queueMessage` and `drainMessages` have existed for a while and
|
|
166
|
+
nothing in the iteration loop ever read them — the type said so outright. So a
|
|
167
|
+
host watching a run go the wrong way had two options, both worse than they
|
|
168
|
+
sound: cancel and start over, throwing away every tool result already paid
|
|
169
|
+
for; or reject through the review gate, which only works when a call happens
|
|
170
|
+
to be pending approval and says "no" when the host meant "yes, but read this
|
|
171
|
+
first".
|
|
172
|
+
|
|
173
|
+
`SteeringChannel` is the delivery that was missing. A host holds one, passes
|
|
174
|
+
it as `steering` on `drainQuery` params or `SupervisorAgentConfig`, and calls
|
|
175
|
+
`steer(text)` whenever it likes. Anything queued while a tool batch is running
|
|
176
|
+
is appended to that batch's **last tool result**.
|
|
177
|
+
|
|
178
|
+
That slot is not a stylistic choice. A `tool_use` block must be answered by a
|
|
179
|
+
`tool_result` with the same id, so a user message wedged between them is
|
|
180
|
+
rejected by the provider — there is no legal place to insert one mid-batch.
|
|
181
|
+
The tool result is the slot that already exists, and this SDK had already
|
|
182
|
+
reached that conclusion for the neighbouring case: a denied call carries its
|
|
183
|
+
reason inside the `tool_result`, precisely because that is where the model
|
|
184
|
+
looks for tool outcomes. Steering is the same delivery with the refusal taken
|
|
185
|
+
out.
|
|
186
|
+
|
|
187
|
+
It deliberately does not interrupt. The batch in flight finishes and the
|
|
188
|
+
guidance lands where the model reads next; a host that wants the current work
|
|
189
|
+
stopped wants `AbortSignal`, which is a different question. Conflating them is
|
|
190
|
+
how "also check the tests" ends up killing a half-written file.
|
|
191
|
+
|
|
192
|
+
Details worth knowing:
|
|
193
|
+
|
|
194
|
+
- Repeated calls before a drain accumulate in order rather than replacing each
|
|
195
|
+
other — two corrections typed a second apart are two things the model should
|
|
196
|
+
see.
|
|
197
|
+
- Guidance is labelled as coming from the operator. Unlabelled it would read
|
|
198
|
+
as something the tool said, so "stop and ask me first" would look like
|
|
199
|
+
output from `bash`. This is not the untrusted-content envelope: the operator
|
|
200
|
+
is the one party whose words the agent _should_ act on.
|
|
201
|
+
- A turn that called no tools has nothing in flight, so guidance stays queued
|
|
202
|
+
for the next one instead of being dropped.
|
|
203
|
+
|
|
204
|
+
Absent, the loop is byte-identical to before.
|
|
205
|
+
|
|
206
|
+
- 1500973: Every driver that cannot think now says so instead of dropping the request.
|
|
207
|
+
|
|
208
|
+
`thinking` sits on `ChatCompletionParams`, so every driver accepts it. Five of
|
|
209
|
+
them — Bedrock, OpenRouter, HTTP, Ollama, LM Studio — implemented none of it
|
|
210
|
+
and dropped the field: the caller got an ordinary completion with an empty
|
|
211
|
+
`reasoning` array, which is indistinguishable from a model that simply chose
|
|
212
|
+
not to reason. The request looked honoured and the answer looked like an
|
|
213
|
+
answer.
|
|
214
|
+
|
|
215
|
+
The OpenAI driver already refused instead, with the reasoning written out
|
|
216
|
+
beside it. So the rule had been decided once and applied once, while five
|
|
217
|
+
siblings went on being silent. It moves to `@namzu/sdk` as
|
|
218
|
+
`assertThinkingUnsupported(driverName, params)`, and a new driver now inherits
|
|
219
|
+
it rather than re-deciding it.
|
|
220
|
+
|
|
221
|
+
The error names the driver, which in a multi-provider setup is the difference
|
|
222
|
+
between a bug report about the model and a one-line configuration fix.
|
|
223
|
+
|
|
224
|
+
**Turning thinking off stays a no-op** on all of them, because that is the
|
|
225
|
+
state a driver without thinking is already in — a config shared across
|
|
226
|
+
providers saying `{ type: 'disabled' }` should not fail on the ones that were
|
|
227
|
+
never going to think.
|
|
228
|
+
|
|
229
|
+
`assertThinkingSupported` in `@namzu/openai` is unchanged as an export and now
|
|
230
|
+
delegates to the shared helper. Its message changed: it no longer says
|
|
231
|
+
"extended thinking", because `adaptive` is refused too and calling that
|
|
232
|
+
extended would be wrong.
|
|
233
|
+
|
|
234
|
+
**Migration.** If you passed `thinking` to any of the five and relied on it
|
|
235
|
+
being ignored, remove it — you were receiving a non-thinking answer either way,
|
|
236
|
+
and now you find out at the call instead of by inspecting an empty array.
|
|
237
|
+
|
|
238
|
+
Not in this change: implementing thinking natively on Bedrock, which serves the
|
|
239
|
+
same Claude models through a different wire and deserves the per-model
|
|
240
|
+
resolution the Anthropic driver just gained. That needs the Converse request
|
|
241
|
+
and response shapes verified against the reference first, and is not something
|
|
242
|
+
to guess at.
|
|
243
|
+
|
|
244
|
+
- a2cedfd: Adds `runAgent` — a provider, a model and a prompt is now a complete agent run.
|
|
245
|
+
|
|
246
|
+
`drainQuery` is the kernel's entry point and takes eleven required parameters,
|
|
247
|
+
four of which are identity fields that throw when missing. That is the right
|
|
248
|
+
shape for a kernel: a run with no tenant is a run no auditor can attribute. It
|
|
249
|
+
is the wrong shape for the first thing anybody writes, and the proof was
|
|
250
|
+
in-tree — the eval suites, the test files and the CLI each hand-assembled the
|
|
251
|
+
same block, which is what a missing front door looks like from the inside.
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
const { output } = await runAgent({
|
|
255
|
+
provider,
|
|
256
|
+
model,
|
|
257
|
+
prompt: "What is 2 + 2?",
|
|
258
|
+
});
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
It supplies an environment rather than a new engine: it generates the session
|
|
262
|
+
identity a single-tenant local run has no opinion about, defaults the budgets,
|
|
263
|
+
and points the working directory at the process's own. Everything it fills in
|
|
264
|
+
is an ordinary `drainQuery` parameter, so there is no second code path — a
|
|
265
|
+
caller who outgrows it passes more options until they are calling `drainQuery`
|
|
266
|
+
in all but name.
|
|
267
|
+
|
|
268
|
+
The identity comes back on the result, and that pairing is the point.
|
|
269
|
+
Generating one silently would make each call its own session — right for a
|
|
270
|
+
one-shot and wrong for a conversation, where turn two would start with no
|
|
271
|
+
history and nothing would say so. Spread `result.identity` into the next call
|
|
272
|
+
to continue the same session.
|
|
273
|
+
|
|
274
|
+
`model` stays required. `LLMProvider` carries no model — a driver may have been
|
|
275
|
+
constructed with one, but the interface does not expose it, so anything
|
|
276
|
+
inferred here would be a guess billed to the caller.
|
|
277
|
+
|
|
278
|
+
Defaults are safe rather than generous, because nobody reads them before their
|
|
279
|
+
first runaway loop: 16 iterations, a 200k token budget, a 5-minute timeout.
|
|
280
|
+
Each is overridable and named on the option.
|
|
281
|
+
|
|
282
|
+
The README quick start now shows this instead of a bare `provider.chat()` call
|
|
283
|
+
— that example demonstrated an HTTP client, not the kernel.
|
|
284
|
+
|
|
3
285
|
## 4.0.0
|
|
4
286
|
|
|
5
287
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Namzu is a single-process TypeScript kernel with the following responsibilities:
|
|
|
29
29
|
- **Scheduling.** Per-run token, cost, wall-clock, and iteration budgets. Limit checker, task router (cheap model for compaction, expensive for coding), tool tiering (LLM learns to prefer cheaper tools first).
|
|
30
30
|
- **Signals.** `AbortController` tree spanning parent and children. `cancel(taskId)` and `cancelAll(parentRunId)` propagate. Runs can be paused and resumed, aborted cleanly, and emit lifecycle events for every transition.
|
|
31
31
|
- **Memory management.** Working memory via structured compaction to a typed `WorkingState`. Long-term memory via an indexed, tag/query/status-searchable store with disk persistence. No vector database required by default.
|
|
32
|
-
- **Durability.** Atomic per-iteration checkpoints,
|
|
32
|
+
- **Durability.** Atomic per-iteration checkpoints, an opt-in emergency core-dump on SIGINT/SIGTERM (`emergencySave: true` — a library must not seize a host process termination path by default), separate storage for runs, threads, conversations, activities, memories, and tasks.
|
|
33
33
|
- **IPC.** Native A2A (agent-to-agent) and MCP (Model Context Protocol) — both client and server, one SDK. An internal event bus with circuit breakers, file lock manager, and edit ownership tracking so concurrent agents do not stomp on each other.
|
|
34
34
|
- **Capability system.** Tools are first-class, typed, permissioned, and progressively disclosed. The LLM does not see the full tool catalog; tools start deferred, get activated on demand, and can be suspended. Each tool declares `readOnly`, `destructive`, `concurrencySafe`, `permissions`, `category`.
|
|
35
35
|
- **Syscall filtering.** Every tool call goes through a verification gate — allow / deny / ask, with built-in rules for read-only allowlist and dangerous pattern deny-list, plus custom regex rules. This is separate from sandbox isolation; it is the decision layer, the sandbox is the enforcement layer.
|
|
@@ -375,7 +375,7 @@ const result = await agent.run(
|
|
|
375
375
|
)
|
|
376
376
|
```
|
|
377
377
|
|
|
378
|
-
That is a complete, sandbox-isolated, checkpointed, telemetrized agent run with prompt caching, progressive tool disclosure, structured compaction
|
|
378
|
+
That is a complete, sandbox-isolated, checkpointed, telemetrized agent run with prompt caching, progressive tool disclosure, and structured compaction all wired in by default — those are not features you enable, they are how the kernel runs. Emergency save is the exception and is opt-in: pass `emergencySave: true` when the process owns its run end to end. Swap `registerOpenRouter()` for `registerOllama()`, `registerAnthropic()`, `registerBedrock()`, `registerOpenAI()`, `registerLMStudio()`, or `registerHttp()` — the code below the registration line stays identical.
|
|
379
379
|
|
|
380
380
|
Examples for `PipelineAgent`, `RouterAgent`, and `SupervisorAgent` are in `src/agents/`.
|
|
381
381
|
|
|
@@ -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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AeG;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":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AAC,CAAA;QAE7D,MAAM,cAAc,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAA;QAEvD,OAAO;YACN,KAAK,EAAE,GAAG,CAAC,EAAE;YACb,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ;YAC3D,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,KAAK,EAAE,GAAG,CAAC,UAAU;YACrB,IAAI,EAAE,GAAG,CAAC,QAAQ;YAClB,UAAU,EAAE,GAAG,CAAC,gBAAgB;YAChC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;YAClC,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,WAAW;YACX,cAAc;YACd,UAAU,EAAE,WAAW,CAAC,MAAM;SAC9B,CAAA;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-agent.test.d.ts","sourceRoot":"","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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,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,QAAQ,EAAE,QAAQ;YAClB,WAAW,EAAE,EAAE;YACf,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;YACrB,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;SACpD,CAAC,CAAA;QAEX,uEAAuE;QACvE,qEAAqE;QACrE,qDAAqD;QACrD,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,QAAQ,CAAC;YAC9B,QAAQ,EAAE,IAAI,eAAe,CAAC;gBAC7B,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,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"}
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -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"}
|
package/dist/agents/index.js
CHANGED
|
@@ -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
|
package/dist/agents/index.js.map
CHANGED
|
@@ -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"}
|