@rarebit-one/harness-kernel 0.7.0 → 0.9.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/README.md +83 -7
- package/dist/agent.d.ts +12 -3
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +191 -94
- package/dist/agent.js.map +1 -1
- package/dist/connectors/mcpClient.d.ts +6 -1
- package/dist/connectors/mcpClient.d.ts.map +1 -1
- package/dist/connectors/mcpClient.js +1 -1
- package/dist/connectors/mcpClient.js.map +1 -1
- package/dist/engines/acp.d.ts +22 -0
- package/dist/engines/acp.d.ts.map +1 -1
- package/dist/engines/acp.js +49 -10
- package/dist/engines/acp.js.map +1 -1
- package/dist/engines/acpDriver.d.ts +7 -0
- package/dist/engines/acpDriver.d.ts.map +1 -1
- package/dist/engines/acpDriver.js +60 -17
- package/dist/engines/acpDriver.js.map +1 -1
- package/dist/engines/claudeCode.d.ts +6 -0
- package/dist/engines/claudeCode.d.ts.map +1 -1
- package/dist/engines/claudeCode.js +36 -10
- package/dist/engines/claudeCode.js.map +1 -1
- package/dist/engines/claudeCodeDriver.d.ts +11 -0
- package/dist/engines/claudeCodeDriver.d.ts.map +1 -1
- package/dist/engines/claudeCodeDriver.js +35 -5
- package/dist/engines/claudeCodeDriver.js.map +1 -1
- package/dist/engines/codex.d.ts +12 -0
- package/dist/engines/codex.d.ts.map +1 -1
- package/dist/engines/codex.js +19 -1
- package/dist/engines/codex.js.map +1 -1
- package/dist/engines/codexDriver.d.ts.map +1 -1
- package/dist/engines/codexDriver.js +51 -12
- package/dist/engines/codexDriver.js.map +1 -1
- package/dist/engines/index.d.ts +7 -0
- package/dist/engines/index.d.ts.map +1 -1
- package/dist/engines/index.js +4 -1
- package/dist/engines/index.js.map +1 -1
- package/dist/engines/native.d.ts +9 -1
- package/dist/engines/native.d.ts.map +1 -1
- package/dist/engines/native.js +130 -5
- package/dist/engines/native.js.map +1 -1
- package/dist/engines/types.d.ts +29 -1
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/events.d.ts +61 -10
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/loop.d.ts +21 -2
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +7 -2
- package/dist/loop.js.map +1 -1
- package/dist/models/chat.d.ts +6 -2
- package/dist/models/chat.d.ts.map +1 -1
- package/dist/models/chat.js +15 -9
- package/dist/models/chat.js.map +1 -1
- package/dist/models/types.d.ts +15 -1
- package/dist/models/types.d.ts.map +1 -1
- package/dist/models/types.js.map +1 -1
- package/dist/primitives/codeExec.d.ts +7 -0
- package/dist/primitives/codeExec.d.ts.map +1 -1
- package/dist/primitives/codeExec.js +32 -4
- package/dist/primitives/codeExec.js.map +1 -1
- package/dist/primitives/http.d.ts +6 -0
- package/dist/primitives/http.d.ts.map +1 -1
- package/dist/primitives/http.js +28 -11
- package/dist/primitives/http.js.map +1 -1
- package/dist/private.d.ts +76 -0
- package/dist/private.d.ts.map +1 -0
- package/dist/private.js +245 -0
- package/dist/private.js.map +1 -0
- package/dist/processGroup.d.ts +16 -0
- package/dist/processGroup.d.ts.map +1 -0
- package/dist/processGroup.js +39 -0
- package/dist/processGroup.js.map +1 -0
- package/dist/providers/anthropic.d.ts +12 -2
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +30 -3
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/mock.d.ts +2 -2
- package/dist/providers/mock.d.ts.map +1 -1
- package/dist/providers/mock.js +5 -1
- package/dist/providers/mock.js.map +1 -1
- package/dist/providers/openai.d.ts +11 -2
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +25 -5
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/types.d.ts +21 -1
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/signals.d.ts +46 -0
- package/dist/signals.d.ts.map +1 -0
- package/dist/signals.js +72 -0
- package/dist/signals.js.map +1 -0
- package/dist/tools/metadata.d.ts +18 -2
- package/dist/tools/metadata.d.ts.map +1 -1
- package/dist/tools/metadata.js +7 -0
- package/dist/tools/metadata.js.map +1 -1
- package/dist/tools/modelTool.d.ts.map +1 -1
- package/dist/tools/modelTool.js +7 -3
- package/dist/tools/modelTool.js.map +1 -1
- package/dist/tools/registry.d.ts +24 -5
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +43 -12
- package/dist/tools/registry.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -31,8 +31,7 @@ build provenance attestation.
|
|
|
31
31
|
|
|
32
32
|
v0 is a mechanical extraction of a proven, already-provider-neutral agent core
|
|
33
33
|
into a standalone package — the mechanics are battle-tested, the packaging is
|
|
34
|
-
new.
|
|
35
|
-
input, middleware, context providers) is planned as an additive v0.2.
|
|
34
|
+
new.
|
|
36
35
|
|
|
37
36
|
## Install
|
|
38
37
|
|
|
@@ -48,12 +47,12 @@ ESM-only, Node >= 22.
|
|
|
48
47
|
|------|---------|
|
|
49
48
|
| **Model seam** | `ModelInvocation` — one arrow for every model kind, with declared capabilities, a uniform result envelope and `probe()` |
|
|
50
49
|
| **Providers** | `Provider` interface + `selectProvider()` over Anthropic, OpenAI, OpenRouter, a self-hosted `local` (any OpenAI-compatible server), and an offline `mock`; `chatModel()` puts any of them on the seam |
|
|
51
|
-
| **Agent loop** | `runAgent()` — a provider-neutral tool-use loop with step and wall-clock budgets |
|
|
50
|
+
| **Agent loop** | `runAgent()` — a provider-neutral tool-use loop with step and wall-clock budgets, cancellable through an `AbortSignal` |
|
|
52
51
|
| **Loop** | `Loop` + `nativeLoop` — the control loop as a seam; the kernel ships one and it is the loop `runAgent` has always run |
|
|
53
52
|
| **Run events** | `RunEvent` — an ordered, structured account of a run (turns, tool calls, budgets, outcome), emitted to an optional sink |
|
|
54
|
-
| **Tools** | `Tool
|
|
53
|
+
| **Tools** | `Tool` (+ `ToolContext`), `primitiveTools()` (`run_code`, `read_file`, `list_files`, `http_fetch`), `connectorTools()`, `modelAsTool()`, metadata + projections (`replaySafeTools`, …) |
|
|
55
54
|
| **Connectors** | `connectMcp()` — MCP clients over stdio / streamable HTTP / SSE |
|
|
56
|
-
| **Engines** | The `AgentEngine` seam + `native`, `claude-code`, and `
|
|
55
|
+
| **Engines** | The `AgentEngine` seam + `native`, `claude-code`, `codex`, and ACP (`eve`) harnesses, plus the capability *mechanism* (scope guards, a generic `write_file`, and MCP/stdio transports) — the capability *set* is yours to inject |
|
|
57
56
|
| **Routing** | `RouteResolver` + `StaticRouteResolver` — capability → model, prompt, tools |
|
|
58
57
|
| **Context** | `ContextProvider` chain, assembled in parallel and rendered into the prompt |
|
|
59
58
|
| **Secrets** | `secretsToEnv()` — resolved secret values into an exec environment |
|
|
@@ -102,14 +101,16 @@ const model = registry.resolve(route.model) // the resolver picks, the registry
|
|
|
102
101
|
const model = withMiddleware(anyModel, [correlationMiddleware(), loggingMiddleware()])
|
|
103
102
|
```
|
|
104
103
|
|
|
105
|
-
**4. Engines.** The `AgentEngine` seam — `native`, `claude-code`, `codex`,
|
|
106
|
-
your own. File mutations stay out of band.
|
|
104
|
+
**4. Engines.** The `AgentEngine` seam — `native`, `claude-code`, `codex`, an
|
|
105
|
+
ACP agent (`eve`), or your own. File mutations stay out of band.
|
|
107
106
|
|
|
108
107
|
**5. Context providers.** Replace a single pre-baked context string with a
|
|
109
108
|
chain, so a live source can inject fragments:
|
|
110
109
|
|
|
111
110
|
```ts
|
|
112
111
|
new NativeEngine({ contextProviders: [myLiveFeed] })
|
|
112
|
+
// or, through the selector:
|
|
113
|
+
selectEngine("native", { domainTools, contextProviders: [myLiveFeed] })
|
|
113
114
|
```
|
|
114
115
|
|
|
115
116
|
Providers run in parallel; one that fails is logged and skipped rather than
|
|
@@ -171,6 +172,12 @@ threw and never returned a result, so any number there would be invented. The
|
|
|
171
172
|
`model.turn` events already in the stream are the authoritative record of how
|
|
172
173
|
far it got.
|
|
173
174
|
|
|
175
|
+
A model call the loop **absorbs** rather than propagates emits
|
|
176
|
+
`model.turn.failed` (with a `phase`). Today that is only the tools-free summary
|
|
177
|
+
requested after the step budget runs out: if it fails, the run falls back to the
|
|
178
|
+
last assistant prose and still finishes `steps_exhausted`, and the event is what
|
|
179
|
+
tells a consumer the final text is not a summary.
|
|
180
|
+
|
|
174
181
|
Engines take the same sink through `EngineContext`:
|
|
175
182
|
|
|
176
183
|
```ts
|
|
@@ -190,6 +197,22 @@ carries the **raw tool arguments**, so any secret or PII a model passed as an
|
|
|
190
197
|
argument now reaches every attached sink. Nothing outside the model conversation
|
|
191
198
|
captured these before; a sink that persists or forwards events should redact.
|
|
192
199
|
|
|
200
|
+
**Private runs.** Set `RunSpec.private: true` when the run handles material
|
|
201
|
+
that must not leave the host. The native engine runs it only on the `local`
|
|
202
|
+
provider (`provider.preferred: "local"` with `LOCAL_MODEL_BASE_URL` set) and
|
|
203
|
+
refuses it otherwise, with no fallback to ambient cloud keys or the mock. It
|
|
204
|
+
also narrows both channels at
|
|
205
|
+
the source (`privateRunChannels`): `log` gets no free text, only one
|
|
206
|
+
`phase=<event> …` line per event, and every event is marked `redacted: true`
|
|
207
|
+
with its model text, tool arguments, error messages and final text withheld (a
|
|
208
|
+
tool name the run did not register becomes `(unregistered)`, and tool-call ids
|
|
209
|
+
become per-run `call-<n>` surrogates). Structure
|
|
210
|
+
survives: types, `seq`, steps, registered tool names, outcomes, budgets, usage
|
|
211
|
+
and result byte counts. A thrown error is replaced by a `PrivateRunError` that
|
|
212
|
+
carries neither the original message nor a `cause`. The claude-code, codex and
|
|
213
|
+
ACP engines refuse a private run in `supports()`. `EngineResult.text` is still
|
|
214
|
+
returned to the caller, which decides where it goes.
|
|
215
|
+
|
|
193
216
|
`run.finished` is always the last event, including when the loop throws — the
|
|
194
217
|
error propagates unchanged, but `outcome: "failed"` closes the stream first, so
|
|
195
218
|
a crashed run is never mistaken for one still in flight.
|
|
@@ -206,6 +229,59 @@ undoable but nothing recorded that the tool *ran*, so an application had nothing
|
|
|
206
229
|
concrete to undo. Deciding whether to undo remains policy, and stays in the
|
|
207
230
|
application.
|
|
208
231
|
|
|
232
|
+
### Cancellation, tool context and usage
|
|
233
|
+
|
|
234
|
+
Every entry point takes an optional `AbortSignal` — `runAgent({ signal })`,
|
|
235
|
+
`engine.run(spec, { log, signal })`, and `LoopContext.signal` for a custom loop:
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
const controller = new AbortController()
|
|
239
|
+
const result = await engine.run(spec, { log, signal: controller.signal })
|
|
240
|
+
// later: controller.abort("user canceled")
|
|
241
|
+
result.outcome // "completed" | "steps_exhausted" | "timed_out" | "canceled" | "failed"
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
The native loop merges it with its own wall-clock deadline and threads the
|
|
245
|
+
result into every model request (`Provider.converse(req, { signal })`, which the
|
|
246
|
+
Anthropic and OpenAI adapters hand to the SDK per request) and every tool call.
|
|
247
|
+
So neither a cancel nor the deadline waits for an in-flight step: `run_code`
|
|
248
|
+
kills its whole process group, `http_fetch` aborts the request, and MCP calls
|
|
249
|
+
send the server a cancellation. An abort is a **clean stop, not a throw** — the
|
|
250
|
+
run resolves with the prose it had, `outcome: "canceled"` (the caller's signal)
|
|
251
|
+
or `"timed_out"` (the deadline), and no summary call is spent. A model
|
|
252
|
+
that ignores the signal and answers anyway has its turn recorded and its prose
|
|
253
|
+
kept, but the outcome is still the stop's, and none of the tools it asked for
|
|
254
|
+
run; an unrelated error that merely coincides with the stop still propagates.
|
|
255
|
+
`EngineResult.outcome` carries the same value; the external engines map their
|
|
256
|
+
harness's ending onto it.
|
|
257
|
+
|
|
258
|
+
Tools receive a second argument, `ToolContext`:
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
const tool: Tool = {
|
|
262
|
+
spec,
|
|
263
|
+
meta: { replay: "safe" }, // idempotent: may be re-run after an interruption
|
|
264
|
+
execute: async (input, ctx) => {
|
|
265
|
+
// ctx.signal — stop when the run stops; ctx.callId — the model's call id
|
|
266
|
+
// (matches tool.called.callId); ctx.runId — when the caller supplied one
|
|
267
|
+
return doWork(input, { signal: ctx?.signal, idempotencyKey: ctx?.callId })
|
|
268
|
+
},
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
`ToolMetadata.replay` is `"safe"` or `"unsafe"`, and **absent means unsafe**.
|
|
273
|
+
It is copied onto `tool.called` / `tool.succeeded`, and `replaySafeTools()`
|
|
274
|
+
selects the tools that declared it. The kernel only records the claim; whether
|
|
275
|
+
to replay is the application's decision.
|
|
276
|
+
|
|
277
|
+
Token usage is reported where the provider's API returns it:
|
|
278
|
+
`ConverseResult.usage`, `ModelResult.usage` and `model.turn.usage` on the
|
|
279
|
+
event stream. A provider opts in with `reportsUsage: true` (the Anthropic and
|
|
280
|
+
OpenAI-compatible adapters do), and `chatModel` derives `caps.usage` from it, so
|
|
281
|
+
the mock and custom providers never advertise usage they do not deliver. `inputTokens` is all input processed, cached or not (so
|
|
282
|
+
`totalTokens = inputTokens + outputTokens`); `cacheReadTokens` /
|
|
283
|
+
`cacheWriteTokens` break out the prompt-cache share of it.
|
|
284
|
+
|
|
209
285
|
## Usage
|
|
210
286
|
|
|
211
287
|
```ts
|
package/dist/agent.d.ts
CHANGED
|
@@ -16,11 +16,20 @@ export interface RunAgentOptions {
|
|
|
16
16
|
tools: Tool[];
|
|
17
17
|
maxSteps?: number;
|
|
18
18
|
/**
|
|
19
|
-
* Wall-clock budget for the whole loop in ms.
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Wall-clock budget for the whole loop in ms. Enforced both between steps and
|
|
20
|
+
* mid-call (the in-flight model request and tool are aborted); when exceeded
|
|
21
|
+
* the loop stops cleanly and returns what's accumulated (with a note) rather
|
|
22
|
+
* than throwing. Defaults to `RUNNER_RUN_TIMEOUT_MS` if set, else 10min.
|
|
22
23
|
*/
|
|
23
24
|
maxDurationMs?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Cancels the run. On abort the in-flight model request and tool are
|
|
27
|
+
* stopped, no summary call is made, and the run resolves (never rejects)
|
|
28
|
+
* with the prose accumulated so far and `outcome: "canceled"`.
|
|
29
|
+
*/
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
/** The run's id, handed to tools on `ToolContext.runId`. */
|
|
32
|
+
runId?: string;
|
|
24
33
|
log?: (line: string) => void;
|
|
25
34
|
/**
|
|
26
35
|
* Structured event sink. Absent (the default) means the loop behaves exactly
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAA;AACpB,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAA;AACpB,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAG9D,OAAO,KAAK,EAAgB,QAAQ,EAAc,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAG5D,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,YAAY,CAAA;CACpB;AAYD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE;IACzC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAK9C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAG3C;AAqDD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBxE;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAgP/F"}
|
package/dist/agent.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { runEventEmitter, } from "./events.js";
|
|
2
2
|
import { nativeLoop, runWithEvents, } from "./loop.js";
|
|
3
3
|
import { asChatModel } from "./models/chat.js";
|
|
4
|
+
import { deadlineSignal, isAbortError } from "./signals.js";
|
|
4
5
|
import { executeTool } from "./tools/registry.js";
|
|
5
6
|
import { toToolSpecs } from "./tools/metadata.js";
|
|
6
7
|
const DEFAULT_MAX_STEPS = 12;
|
|
@@ -47,8 +48,18 @@ function undoFields(meta) {
|
|
|
47
48
|
...(meta?.reversible !== undefined ? { reversible: meta.reversible } : {}),
|
|
48
49
|
...(meta?.undoToolName !== undefined ? { undoToolName: meta.undoToolName } : {}),
|
|
49
50
|
...(meta?.undoWindowSeconds !== undefined ? { undoWindowSeconds: meta.undoWindowSeconds } : {}),
|
|
51
|
+
...(meta?.replay !== undefined ? { replay: meta.replay } : {}),
|
|
50
52
|
};
|
|
51
53
|
}
|
|
54
|
+
/** A short, human-readable rendering of an abort reason for the run note. */
|
|
55
|
+
function describeReason(reason) {
|
|
56
|
+
if (typeof reason === "string")
|
|
57
|
+
return reason;
|
|
58
|
+
// The DOMException a bare `abort()` produces says nothing a caller chose.
|
|
59
|
+
if (reason instanceof Error && reason.name !== "AbortError")
|
|
60
|
+
return reason.message;
|
|
61
|
+
return "";
|
|
62
|
+
}
|
|
52
63
|
/**
|
|
53
64
|
* A detached copy of a tool's arguments for the event stream.
|
|
54
65
|
*
|
|
@@ -88,7 +99,12 @@ export async function runAgent(options) {
|
|
|
88
99
|
userPrompt: options.userPrompt,
|
|
89
100
|
tools: options.tools,
|
|
90
101
|
limits: resolveLoopLimits(options),
|
|
91
|
-
}, {
|
|
102
|
+
}, {
|
|
103
|
+
log,
|
|
104
|
+
events: runEventEmitter(options.emit, log),
|
|
105
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
106
|
+
...(options.runId !== undefined ? { runId: options.runId } : {}),
|
|
107
|
+
});
|
|
92
108
|
return result.text;
|
|
93
109
|
}
|
|
94
110
|
/**
|
|
@@ -103,122 +119,176 @@ export async function runNativeLoop(req, loopCtx) {
|
|
|
103
119
|
const { model, system, userPrompt, tools } = req;
|
|
104
120
|
const { maxSteps, maxDurationMs } = req.limits;
|
|
105
121
|
const log = loopCtx.log;
|
|
106
|
-
|
|
122
|
+
// One signal for the whole run: the caller's cancel merged with the run's own
|
|
123
|
+
// deadline. It reaches every model call (through `InvokeContext.signal`, down
|
|
124
|
+
// to the provider's HTTP request) and every tool (through `ToolContext`), so
|
|
125
|
+
// neither a cancel nor the deadline has to wait for an in-flight step to end.
|
|
126
|
+
const deadline = deadlineSignal(maxDurationMs);
|
|
127
|
+
const signal = loopCtx.signal ? AbortSignal.any([loopCtx.signal, deadline]) : deadline;
|
|
128
|
+
const ctx = { log, signal, budget: { maxDurationMs } };
|
|
107
129
|
// The emitter is the caller's: `seq` is per RUN, not per loop, so a loop that
|
|
108
130
|
// made its own would restart the numbering mid-stream.
|
|
109
131
|
const events = loopCtx.events;
|
|
110
132
|
const byName = new Map(tools.map((t) => [t.spec.name, t]));
|
|
111
133
|
const specs = toToolSpecs(tools);
|
|
112
134
|
const messages = [{ role: "user", text: userPrompt }];
|
|
113
|
-
const
|
|
135
|
+
const deadlineAt = Date.now() + maxDurationMs;
|
|
114
136
|
let finalText = "";
|
|
115
137
|
let lastAssistantText = "";
|
|
116
138
|
let exhausted = false;
|
|
117
139
|
let timedOut = false;
|
|
118
140
|
let stepsTaken = 0;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
log(`reached run time budget (${maxDurationMs}ms)
|
|
141
|
+
let step = 0;
|
|
142
|
+
/**
|
|
143
|
+
* The run was stopped mid-flight. `signal.reason` says by whom: the deadline
|
|
144
|
+
* signal's own reason means the budget ran out (`timed_out`); anything else
|
|
145
|
+
* is the caller's (`canceled`). Either way it is a clean stop — the
|
|
146
|
+
* accumulated prose comes back with a note, no summary call is spent, and
|
|
147
|
+
* nothing is thrown, so `runWithEvents` never reports it as `failed`.
|
|
148
|
+
*/
|
|
149
|
+
const stopped = () => {
|
|
150
|
+
const accumulated = lastAssistantText || "(no output before the run was stopped)";
|
|
151
|
+
if (signal.reason === deadline.reason) {
|
|
152
|
+
log(`reached run time budget (${maxDurationMs}ms) during step ${step}; in-flight work aborted`);
|
|
131
153
|
events.emit({ type: "run.budget_exhausted", kind: "duration", step });
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const { value: turn } = await model.invoke({ system, messages, tools: specs }, ctx);
|
|
135
|
-
stepsTaken = step + 1;
|
|
136
|
-
messages.push({ role: "assistant", text: turn.text, toolCalls: turn.toolCalls });
|
|
137
|
-
if (turn.text)
|
|
138
|
-
lastAssistantText = turn.text;
|
|
139
|
-
events.emit({
|
|
140
|
-
type: "model.turn",
|
|
141
|
-
step,
|
|
142
|
-
text: turn.text,
|
|
143
|
-
toolCalls: turn.toolCalls.map((c) => ({ id: c.id, name: c.name })),
|
|
144
|
-
});
|
|
145
|
-
if (turn.toolCalls.length === 0) {
|
|
146
|
-
finalText = turn.text;
|
|
147
|
-
break;
|
|
154
|
+
const text = `${accumulated}\n\n[run stopped: wall-clock budget of ${maxDurationMs}ms exceeded]`;
|
|
155
|
+
return { text, steps: stepsTaken, outcome: "timed_out" };
|
|
148
156
|
}
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
error: `unknown tool: ${call.name}`,
|
|
166
|
-
});
|
|
167
|
-
continue;
|
|
157
|
+
const why = describeReason(signal.reason);
|
|
158
|
+
log(`run canceled during step ${step}${why ? `: ${why}` : ""}`);
|
|
159
|
+
const text = `${accumulated}\n\n[run stopped: canceled${why ? ` (${why})` : ""}]`;
|
|
160
|
+
return { text, steps: stepsTaken, outcome: "canceled" };
|
|
161
|
+
};
|
|
162
|
+
try {
|
|
163
|
+
for (; step < maxSteps; step += 1) {
|
|
164
|
+
// Wall-clock budget, checked between steps. The deadline signal also
|
|
165
|
+
// aborts an in-flight model request or tool, so a step can no longer
|
|
166
|
+
// overshoot the budget by its whole duration — only by however long a
|
|
167
|
+
// call that ignores its signal takes to return.
|
|
168
|
+
if (Date.now() >= deadlineAt) {
|
|
169
|
+
timedOut = true;
|
|
170
|
+
log(`reached run time budget (${maxDurationMs}ms) after ${step} step(s)`);
|
|
171
|
+
events.emit({ type: "run.budget_exhausted", kind: "duration", step });
|
|
172
|
+
break;
|
|
168
173
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
signal.throwIfAborted();
|
|
175
|
+
const turnResult = await model.invoke({ system, messages, tools: specs }, ctx);
|
|
176
|
+
const turn = turnResult.value;
|
|
177
|
+
stepsTaken = step + 1;
|
|
178
|
+
messages.push({ role: "assistant", text: turn.text, toolCalls: turn.toolCalls });
|
|
179
|
+
if (turn.text)
|
|
180
|
+
lastAssistantText = turn.text;
|
|
172
181
|
events.emit({
|
|
173
|
-
type: "
|
|
182
|
+
type: "model.turn",
|
|
174
183
|
step,
|
|
175
|
-
|
|
176
|
-
name:
|
|
177
|
-
|
|
178
|
-
...undoFields(tool.meta),
|
|
184
|
+
text: turn.text,
|
|
185
|
+
toolCalls: turn.toolCalls.map((c) => ({ id: c.id, name: c.name })),
|
|
186
|
+
...(turnResult.usage ? { usage: turnResult.usage } : {}),
|
|
179
187
|
});
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
//
|
|
193
|
-
//
|
|
188
|
+
// A model that ignored its signal can still answer after the stop. The
|
|
189
|
+
// turn happened, so it is recorded above and its prose is kept, but the
|
|
190
|
+
// outcome is the stop's — `canceled` or `timed_out`, never `completed` —
|
|
191
|
+
// and none of the tools it asked for run.
|
|
192
|
+
if (signal.aborted)
|
|
193
|
+
return stopped();
|
|
194
|
+
if (turn.toolCalls.length === 0) {
|
|
195
|
+
finalText = turn.text;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
const results = [];
|
|
199
|
+
for (const call of turn.toolCalls) {
|
|
200
|
+
// Never START a tool once the run is stopping: a side effect begun
|
|
201
|
+
// after a cancel is the one thing a cancel must prevent.
|
|
202
|
+
signal.throwIfAborted();
|
|
203
|
+
const tool = byName.get(call.name);
|
|
204
|
+
if (!tool) {
|
|
205
|
+
results.push({
|
|
206
|
+
toolCallId: call.id,
|
|
207
|
+
content: `unknown tool: ${call.name}`,
|
|
208
|
+
isError: true,
|
|
209
|
+
});
|
|
210
|
+
log(`tool ${call.name} (unknown)`);
|
|
211
|
+
events.emit({
|
|
212
|
+
type: "tool.failed",
|
|
213
|
+
step,
|
|
214
|
+
callId: call.id,
|
|
215
|
+
name: call.name,
|
|
216
|
+
reason: "unknown_tool",
|
|
217
|
+
error: `unknown tool: ${call.name}`,
|
|
218
|
+
});
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
// Emitted BEFORE execution: a process that dies mid-tool still leaves
|
|
222
|
+
// evidence that the effect may have started, which is the one case a
|
|
223
|
+
// rollback consumer cannot afford to infer from silence.
|
|
194
224
|
events.emit({
|
|
195
|
-
type: "tool.
|
|
225
|
+
type: "tool.called",
|
|
196
226
|
step,
|
|
197
227
|
callId: call.id,
|
|
198
228
|
name: call.name,
|
|
199
|
-
|
|
229
|
+
input: detach(call.input),
|
|
200
230
|
...undoFields(tool.meta),
|
|
201
231
|
});
|
|
232
|
+
try {
|
|
233
|
+
// Uses the tool's structured executor when it has one, so a typed
|
|
234
|
+
// payload survives alongside the string the model sees. Tools without
|
|
235
|
+
// one take the original string path unchanged.
|
|
236
|
+
const output = await executeTool(tool, call.input, {
|
|
237
|
+
signal,
|
|
238
|
+
callId: call.id,
|
|
239
|
+
...(loopCtx.runId !== undefined ? { runId: loopCtx.runId } : {}),
|
|
240
|
+
});
|
|
241
|
+
results.push({
|
|
242
|
+
toolCallId: call.id,
|
|
243
|
+
content: truncate(output.content),
|
|
244
|
+
...(output.structured !== undefined ? { structured: output.structured } : {}),
|
|
245
|
+
});
|
|
246
|
+
log(`tool ${call.name} ok (${output.content.length} bytes)`);
|
|
247
|
+
// Reversibility is copied from the tool's own metadata at call time —
|
|
248
|
+
// the tool set can differ per run, so a consumer reading the stream
|
|
249
|
+
// later must not have to reconstruct which registry was in play.
|
|
250
|
+
events.emit({
|
|
251
|
+
type: "tool.succeeded",
|
|
252
|
+
step,
|
|
253
|
+
callId: call.id,
|
|
254
|
+
name: call.name,
|
|
255
|
+
bytes: Buffer.byteLength(output.content, "utf8"),
|
|
256
|
+
...undoFields(tool.meta),
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
catch (err) {
|
|
260
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
261
|
+
results.push({ toolCallId: call.id, content: message, isError: true });
|
|
262
|
+
log(`tool ${call.name} error: ${message}`);
|
|
263
|
+
// Recorded even when the run is stopping: `tool.called` is already in
|
|
264
|
+
// the stream, and a call with no closing event looks like a crash.
|
|
265
|
+
events.emit({
|
|
266
|
+
type: "tool.failed",
|
|
267
|
+
step,
|
|
268
|
+
callId: call.id,
|
|
269
|
+
name: call.name,
|
|
270
|
+
// A tool stopped by the run's cancel/deadline did not break.
|
|
271
|
+
// Only when the error IS the stop, not a failure that coincided with it.
|
|
272
|
+
reason: isAbortError(err, signal) ? "aborted" : "threw",
|
|
273
|
+
error: message,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
202
276
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
events.emit({
|
|
208
|
-
type: "tool.failed",
|
|
209
|
-
step,
|
|
210
|
-
callId: call.id,
|
|
211
|
-
name: call.name,
|
|
212
|
-
reason: "threw",
|
|
213
|
-
error: message,
|
|
214
|
-
});
|
|
277
|
+
messages.push({ role: "tool", results });
|
|
278
|
+
if (step === maxSteps - 1) {
|
|
279
|
+
exhausted = true;
|
|
280
|
+
events.emit({ type: "run.budget_exhausted", kind: "steps", step });
|
|
215
281
|
}
|
|
216
282
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
283
|
+
}
|
|
284
|
+
catch (err) {
|
|
285
|
+
// Only an error that IS the abort (its reason, an SDK abort error, or
|
|
286
|
+
// `throwIfAborted` above) is a clean stop. A real failure that merely
|
|
287
|
+
// coincides with the abort propagates untouched, and `runWithEvents`
|
|
288
|
+
// closes the stream around it as `failed`.
|
|
289
|
+
if (isAbortError(err, signal))
|
|
290
|
+
return stopped();
|
|
291
|
+
throw err;
|
|
222
292
|
}
|
|
223
293
|
// Ran out of time mid-loop: don't spend more of the (already-blown) budget on
|
|
224
294
|
// a summary call — just return whatever prose we accumulated, clearly noted.
|
|
@@ -231,16 +301,43 @@ export async function runNativeLoop(req, loopCtx) {
|
|
|
231
301
|
// can summarize, falling back to its last prose rather than losing the work.
|
|
232
302
|
if (!finalText && exhausted) {
|
|
233
303
|
log(`reached max steps (${maxSteps}); requesting a final summary`);
|
|
304
|
+
// A run stopped while the last tools ran gets no summary call: the caller
|
|
305
|
+
// asked it to stop, or its time is already gone.
|
|
306
|
+
if (signal.aborted)
|
|
307
|
+
return stopped();
|
|
234
308
|
try {
|
|
235
|
-
const
|
|
309
|
+
const summaryResult = await model.invoke({ system, messages, tools: [] }, ctx);
|
|
310
|
+
const summary = summaryResult.value;
|
|
236
311
|
// Emitted like any other turn: `run.finished.text` can come from this
|
|
237
312
|
// call, and a terminal event whose text traces back to no turn in the
|
|
238
313
|
// transcript would break the stream's one promise.
|
|
239
|
-
events.emit({
|
|
314
|
+
events.emit({
|
|
315
|
+
type: "model.turn",
|
|
316
|
+
step: stepsTaken,
|
|
317
|
+
text: summary.text,
|
|
318
|
+
toolCalls: [],
|
|
319
|
+
...(summaryResult.usage ? { usage: summaryResult.usage } : {}),
|
|
320
|
+
});
|
|
240
321
|
finalText = summary.text || lastAssistantText;
|
|
322
|
+
// Same rule as a turn: a summary that arrives after the stop is kept,
|
|
323
|
+
// but the run still ends with the stop's outcome.
|
|
324
|
+
if (signal.aborted) {
|
|
325
|
+
if (summary.text)
|
|
326
|
+
lastAssistantText = summary.text;
|
|
327
|
+
return stopped();
|
|
328
|
+
}
|
|
241
329
|
}
|
|
242
330
|
catch (err) {
|
|
243
|
-
|
|
331
|
+
// Stopped during the summary itself: that is a cancel or a timeout, not
|
|
332
|
+
// a summary that failed and was absorbed.
|
|
333
|
+
if (isAbortError(err, signal))
|
|
334
|
+
return stopped();
|
|
335
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
336
|
+
log(`final summary failed: ${error}`);
|
|
337
|
+
// The stream must not be quieter than the log: without this, a
|
|
338
|
+
// `run.finished` whose text fell back to an earlier turn would look
|
|
339
|
+
// exactly like one whose summary succeeded.
|
|
340
|
+
events.emit({ type: "model.turn.failed", step: stepsTaken, phase: "summary", error });
|
|
244
341
|
finalText = lastAssistantText;
|
|
245
342
|
}
|
|
246
343
|
}
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,GAIhB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,UAAU,EACV,aAAa,GAId,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAA;AAG9D,OAAO,EAAE,WAAW,EAAa,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAqB,MAAM,qBAAqB,CAAA;AA8BpE,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAC5B,MAAM,wBAAwB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAE/C,8EAA8E;AAC9E,SAAS,oBAAoB;IAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;IACrD,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GA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AAI,CAAA;gBAClD,OAAO,OAAO,EAAE,CAAA;YAClB,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,wEAAwE;YACxE,0CAA0C;YAC1C,IAAI,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC;gBAAE,OAAO,OAAO,EAAE,CAAA;YAC/C,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAC9D,GAAG,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAA;YACrC,+DAA+D;YAC/D,oEAAoE;YACpE,4CAA4C;YAC5C,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA;YACrF,SAAS,GAAG,iBAAiB,CAAA;QAC/B,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,SAAS,IAAI,aAAa,CAAA;IACvC,6EAA6E;IAC7E,qEAAqE;IACrE,8EAA8E;IAC9E,mDAAmD;IACnD,MAAM,OAAO,GAAe,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,WAAW,CAAA;IAChG,6EAA6E;IAC7E,6EAA6E;IAC7E,yDAAyD;IACzD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,CAAA;AAC7C,CAAC"}
|
|
@@ -5,10 +5,15 @@ import type { ConnectorConfig } from "../types.js";
|
|
|
5
5
|
* with the connector's own name. Servers use it for logging and telemetry.
|
|
6
6
|
*/
|
|
7
7
|
export declare const MCP_CLIENT_NAME = "harness-kernel";
|
|
8
|
+
/** Per-call options for {@link McpConnection.callTool}. */
|
|
9
|
+
export interface McpCallOptions {
|
|
10
|
+
/** Aborts the request; the SDK notifies the server that the call was cancelled. */
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
}
|
|
8
13
|
/** A live MCP connection, narrowed to what the tool registry needs. */
|
|
9
14
|
export interface McpConnection {
|
|
10
15
|
listTools(): Promise<unknown>;
|
|
11
|
-
callTool(name: string, args?: Record<string, unknown
|
|
16
|
+
callTool(name: string, args?: Record<string, unknown>, opts?: McpCallOptions): Promise<unknown>;
|
|
12
17
|
close(): Promise<void>;
|
|
13
18
|
}
|
|
14
19
|
/** Connect to an MCP connector using the transport implied by its config. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpClient.d.ts","sourceRoot":"","sources":["../../src/connectors/mcpClient.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAA;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD;;;GAGG;AACH,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAE/C,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"mcpClient.d.ts","sourceRoot":"","sources":["../../src/connectors/mcpClient.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAA;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD;;;GAGG;AACH,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAE/C,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,mFAAmF;IACnF,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/F,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAwCD,6EAA6E;AAC7E,wBAAsB,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAEhF;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,aAAa,CAAC,CAcxB"}
|
|
@@ -56,7 +56,7 @@ export async function connectWithTransport(name, transport) {
|
|
|
56
56
|
await client.connect(transport);
|
|
57
57
|
return {
|
|
58
58
|
listTools: () => client.listTools(),
|
|
59
|
-
callTool: (toolName, args = {}) => client.callTool({ name: toolName, arguments: args }),
|
|
59
|
+
callTool: (toolName, args = {}, opts) => client.callTool({ name: toolName, arguments: args }, undefined, opts?.signal ? { signal: opts.signal } : undefined),
|
|
60
60
|
close: () => client.close(),
|
|
61
61
|
};
|
|
62
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpClient.js","sourceRoot":"","sources":["../../src/connectors/mcpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,2CAA2C,CAAA;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAA;AAClG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAI5E;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"mc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