zidane 5.0.5 → 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/README.md +37 -1
- package/dist/{agent-JhicgLOV.d.ts → agent-B0vrSTQ9.d.ts} +162 -4
- package/dist/agent-B0vrSTQ9.d.ts.map +1 -0
- package/dist/chat.d.ts +536 -92
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/contexts/docker.d.ts +7 -0
- package/dist/contexts/docker.d.ts.map +1 -0
- package/dist/{contexts-3Arvn7yR.js → contexts/docker.js} +2 -128
- package/dist/contexts/docker.js.map +1 -0
- package/dist/contexts-BwiHIr2w.js +129 -0
- package/dist/contexts-BwiHIr2w.js.map +1 -0
- package/dist/contexts.d.ts +3 -2
- package/dist/contexts.js +2 -2
- package/dist/index-CFxhms_B.d.ts +1303 -0
- package/dist/index-CFxhms_B.d.ts.map +1 -0
- package/dist/index-DYcymRtr.d.ts +26 -0
- package/dist/index-DYcymRtr.d.ts.map +1 -0
- package/dist/{index-t_W9i7Ql.d.ts → index-X6Q9PN_A.d.ts} +3 -3
- package/dist/{index-t_W9i7Ql.d.ts.map → index-X6Q9PN_A.d.ts.map} +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/login-BiuHyuEh.js +1276 -0
- package/dist/login-BiuHyuEh.js.map +1 -0
- package/dist/{mcp-Dw-fRPVk.js → mcp-BgwK6ySj.js} +184 -9
- package/dist/mcp-BgwK6ySj.js.map +1 -0
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +1 -1
- package/dist/{messages-xaYMMFlb.js → messages-BAFLvH_z.js} +1 -1
- package/dist/{messages-xaYMMFlb.js.map → messages-BAFLvH_z.js.map} +1 -1
- package/dist/{presets-BRFH2qsQ.js → presets-CI8_fyvX.js} +2 -2
- package/dist/{presets-BRFH2qsQ.js.map → presets-CI8_fyvX.js.map} +1 -1
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +1 -1
- package/dist/{providers-BCbdv99U.js → providers-C6-vhaVu.js} +2 -2
- package/dist/{providers-BCbdv99U.js.map → providers-C6-vhaVu.js.map} +1 -1
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +2 -2
- package/dist/session/sqlite.d.ts +1 -1
- package/dist/{session-791hhrFa.js → session-pS4Vt4dl.js} +1 -1
- package/dist/{session-791hhrFa.js.map → session-pS4Vt4dl.js.map} +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/session.js +2 -2
- package/dist/skills.d.ts +2 -2
- package/dist/{stats-DZIsGqzu.js → stats-DvCtBRwK.js} +1 -1
- package/dist/{stats-DZIsGqzu.js.map → stats-DvCtBRwK.js.map} +1 -1
- package/dist/{theme-C3JHZ5y9.d.ts → theme-CcGLMJrn.d.ts} +732 -20
- package/dist/theme-CcGLMJrn.d.ts.map +1 -0
- package/dist/{tools-CLazLRb4.js → tools-d1yeA6xK.js} +399 -13
- package/dist/tools-d1yeA6xK.js.map +1 -0
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +1 -1
- package/dist/tui.d.ts +421 -39
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +5761 -2374
- package/dist/tui.js.map +1 -1
- package/dist/{turn-operations-DZ3TrljX.js → turn-operations-BzOIM6Of.js} +2036 -129
- package/dist/turn-operations-BzOIM6Of.js.map +1 -0
- package/dist/types-Bx_F8jet.js.map +1 -1
- package/dist/{index-CXVvqTQj.d.ts → types-OtrV6LJT.d.ts} +2 -27
- package/dist/types-OtrV6LJT.d.ts.map +1 -0
- package/dist/types.d.ts +4 -3
- package/dist/types.js +1 -1
- package/package.json +5 -1
- package/dist/agent-JhicgLOV.d.ts.map +0 -1
- package/dist/contexts-3Arvn7yR.js.map +0 -1
- package/dist/index-2yLUyTbc.d.ts +0 -430
- package/dist/index-2yLUyTbc.d.ts.map +0 -1
- package/dist/index-CXVvqTQj.d.ts.map +0 -1
- package/dist/mcp-Dw-fRPVk.js.map +0 -1
- package/dist/theme-C3JHZ5y9.d.ts.map +0 -1
- package/dist/tools-CLazLRb4.js.map +0 -1
- package/dist/turn-operations-DZ3TrljX.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-CcGLMJrn.d.ts","names":[],"sources":["../src/chat/agents.ts","../src/chat/providers.ts","../src/chat/auth.ts","../src/chat/completion.ts","../src/chat/keybindings.ts","../src/chat/types.ts","../src/chat/store.ts","../src/chat/config.ts","../src/chat/enabled-toggle-set.ts","../src/chat/interactions.tsx","../src/chat/mcps-discovery.ts","../src/chat/prompt-segments.ts","../src/chat/safe-mode-context.tsx","../src/chat/session-export.ts","../src/chat/theme.ts"],"mappings":";;;;;;;;;;;;KAyBY,WAAA;AAAA,UAEK,YAAA;EAeN;EAbT,EAAA;EAaoB;EAXpB,KAAA;EAcuB;EAZvB,WAAA;EAYkD;;;;;;EALlD,MAAA,EAAQ,MAAA;EAK0C;EAHlD,MAAA,GAAS,WAAA;AAAA;AAAA,KAGC,aAAA,GAAgB,QAAA,CAAS,MAAA,SAAe,YAAA;;;;;AAwFpD;;;;;AAqBA;;;;;AAkBA;;;;;AAMA;cAzGa,6BAAA;;;;AAiHb;;;;;;;;cArDa,WAAA,EAAa,YAAA;;AAwE1B;;;;;cAnDa,UAAA,EAAY,YAAA;;;;;;cAkBZ,cAAA,EAAgB,aAAA;AChJ7B;AAAA,cDsJa,gBAAA;;;;;;;iBAQG,cAAA,CACd,QAAA,EAAU,aAAA,EACV,WAAA,sBACA,SAAA;;;;;;;iBAgBc,mBAAA,CAAoB,MAAA,EAAQ,MAAA,GAAS,aAAA;;;;AAlLrD;;;;;;;;;;;UCCiB,SAAA;EACf,EAAA;EACA,IAAA;EACA,aAAA;EACA,SAAA;EACA,SAAA;EACA,KAAA;EACA,IAAA;IAAS,KAAA;IAAe,MAAA;IAAgB,SAAA;IAAoB,UAAA;EAAA;EAC5D,QAAA;AAAA;AAAA,UAGe,k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AAA;EACA,QAAA;EACA,SAAA;EACA,YAAA;EACA,eAAA;EACA,KAAA;EACA,QAAA;AAAA;;;;AbhCF;UauCiB,gBAAA;EACf,EAAA;EACA,EAAA;EACA,IAAA;EACA,MAAA;EACA,SAAA;EACA,GAAA;AAAA;;AbhCF;;;;;AAWA;;;;;AAYA;KawBY,YAAA,GAAe,MAAA,SAAe,gBAAA;;UAGzB,KAAA;EbpBhB;EasBC,EAAA;EbbD;EaeC,KAAA;EACA,MAAA,EAAQ,WAAA;EACR,MAAA,EAAQ,WAAA;EACR,QAAA,EAAU,aAAA;EACV,MAAA,EAAQ,YAAA;AAAA;AAAA,cAmDG,aAAA,EAAe,KAAA;;;;;;;;;;Ab1C5B;ca4Ka,cAAA,EAAgB,QAAA,CAAS,MAAA,SAAe,KAAA;;iBAUrC,YAAA,CAAa,EAAA,uBAAyB,KAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { n as createProcessContext } from "./contexts-
|
|
1
|
+
import { n as createProcessContext } from "./contexts-BwiHIr2w.js";
|
|
2
2
|
import { r as AgentProviderError, s as toTypedError, t as AgentAbortedError } from "./errors-D1lhd6mX.js";
|
|
3
3
|
import { t as toolOutputByteLength } from "./types-Bx_F8jet.js";
|
|
4
|
-
import { t as connectMcpServers } from "./mcp-
|
|
4
|
+
import { t as connectMcpServers } from "./mcp-BgwK6ySj.js";
|
|
5
5
|
import { _ as validateResourcePath, b as createSkillActivationState, d as escapeXml, n as resolveSkills, p as installAllowedToolsGate, t as interpolateShellCommands, u as buildCatalog } from "./interpolate-Ck970-61.js";
|
|
6
|
-
import { n as formatTokenUsage, t as flattenTurns } from "./stats-
|
|
6
|
+
import { n as formatTokenUsage, t as flattenTurns } from "./stats-DvCtBRwK.js";
|
|
7
7
|
import { createHooks } from "hookable";
|
|
8
|
-
import { stat } from "node:fs/promises";
|
|
9
|
-
import { resolve } from "node:path";
|
|
8
|
+
import { mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
9
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
10
10
|
import { Buffer } from "node:buffer";
|
|
11
11
|
//#region src/aliasing.ts
|
|
12
12
|
/**
|
|
@@ -204,6 +204,256 @@ function installDedupToolsGate(hooks, getDedupTools, getSession) {
|
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
//#endregion
|
|
207
|
+
//#region src/loop-persistence.ts
|
|
208
|
+
/**
|
|
209
|
+
* Bytes of head content included in the inline preview block. 2 KiB matches
|
|
210
|
+
* Claude Code's `PREVIEW_SIZE_BYTES` — enough for the model to identify the
|
|
211
|
+
* content class (error output / structured data / log shape) and decide
|
|
212
|
+
* whether to call `read_file` on the persisted path for the full payload.
|
|
213
|
+
*
|
|
214
|
+
* Tail-priority preview (matching `shell`'s truncation strategy) was
|
|
215
|
+
* considered but rejected: most "what is this?" decisions get made from
|
|
216
|
+
* the head, and the path is in the stub for the rare case where the tail
|
|
217
|
+
* matters.
|
|
218
|
+
*/
|
|
219
|
+
const PERSISTENCE_PREVIEW_BYTES = 2 * 1024;
|
|
220
|
+
/**
|
|
221
|
+
* Byte-stable prefix every {@link buildPersistedStub} output starts with.
|
|
222
|
+
* Exported so wire-level passes (tail compaction, future stale-output
|
|
223
|
+
* elision) can recognize a persisted stub and preserve its path attribute
|
|
224
|
+
* rather than replacing the stub with their own — losing the pointer to
|
|
225
|
+
* the on-disk blob.
|
|
226
|
+
*
|
|
227
|
+
* Bound to the literal opening of the XML tag; changing the stub format
|
|
228
|
+
* requires updating this constant in lockstep (and shipping a migration
|
|
229
|
+
* for in-flight sessions).
|
|
230
|
+
*/
|
|
231
|
+
const PERSISTED_STUB_PREFIX = "<persisted-output tool=\"";
|
|
232
|
+
/**
|
|
233
|
+
* Characters that are safe to use verbatim as a filesystem segment under
|
|
234
|
+
* `persistDir`. Alphanumeric + `_` + `-` + `.` covers every real-world
|
|
235
|
+
* `tool_use.id` we've seen (Anthropic `toolu_…`, OpenAI `call_…`, Bun
|
|
236
|
+
* `crypto.randomUUID()` style, our own short ids).
|
|
237
|
+
*
|
|
238
|
+
* Anything else — slashes, `..`, control chars, spaces, unicode — is
|
|
239
|
+
* rejected by {@link maybePersistToolResult} so a malformed or hostile
|
|
240
|
+
* `callId` can't escape `persistDir` via path traversal.
|
|
241
|
+
*/
|
|
242
|
+
const SAFE_CALL_ID = /^[\w.-]+$/;
|
|
243
|
+
/**
|
|
244
|
+
* Resolve the per-session persistence directory under `<userDir>/tool-results/<sessionId>/`.
|
|
245
|
+
*
|
|
246
|
+
* The chat layer calls this at session activation and forwards the result
|
|
247
|
+
* via `behavior.persistDir`. Exposed as a public helper so SDK consumers
|
|
248
|
+
* pick the same layout — single source of truth for "where do blobs live".
|
|
249
|
+
*/
|
|
250
|
+
function resolvePersistDir(opts) {
|
|
251
|
+
if (!isAbsolute(opts.userDir)) throw new Error(`resolvePersistDir: userDir must be absolute, got "${opts.userDir}"`);
|
|
252
|
+
if (!opts.sessionId) throw new Error("resolvePersistDir: sessionId must be a non-empty string");
|
|
253
|
+
return join(opts.userDir, "tool-results", opts.sessionId);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Decide-and-persist for a single tool result. Pure decision + filesystem
|
|
257
|
+
* side-effect; returns the new wire-level `output` string when substitution
|
|
258
|
+
* happened, otherwise tells the caller to leave the result alone.
|
|
259
|
+
*
|
|
260
|
+
* Atomicity: writes go through `<path>.tmp` + `rename` so a concurrent
|
|
261
|
+
* read (or a crash mid-write) never sees a half-written blob.
|
|
262
|
+
*
|
|
263
|
+
* `ToolResultContent[]` results (images, structured blocks) currently bypass
|
|
264
|
+
* persistence — the inline image bytes are the point of the call, and a
|
|
265
|
+
* mixed text/image array isn't representable as a single `.txt` file. We
|
|
266
|
+
* may revisit if a tool starts returning very large text-only arrays.
|
|
267
|
+
*/
|
|
268
|
+
async function maybePersistToolResult(input) {
|
|
269
|
+
if (!input.threshold || input.threshold <= 0) return {
|
|
270
|
+
kind: "skip",
|
|
271
|
+
reason: "disabled"
|
|
272
|
+
};
|
|
273
|
+
if (input.excludeTools?.includes(input.toolName)) return {
|
|
274
|
+
kind: "skip",
|
|
275
|
+
reason: "excluded"
|
|
276
|
+
};
|
|
277
|
+
if (typeof input.output !== "string") return {
|
|
278
|
+
kind: "skip",
|
|
279
|
+
reason: "unsupported-shape"
|
|
280
|
+
};
|
|
281
|
+
if (!isAbsolute(input.persistDir)) return {
|
|
282
|
+
kind: "skip",
|
|
283
|
+
reason: "invalid-persist-dir"
|
|
284
|
+
};
|
|
285
|
+
if (!SAFE_CALL_ID.test(input.callId) || input.callId.includes("..")) return {
|
|
286
|
+
kind: "skip",
|
|
287
|
+
reason: "unsafe-call-id"
|
|
288
|
+
};
|
|
289
|
+
const originalBytes = toolOutputByteLength(input.output);
|
|
290
|
+
if (originalBytes <= input.threshold) return {
|
|
291
|
+
kind: "skip",
|
|
292
|
+
reason: "under-threshold"
|
|
293
|
+
};
|
|
294
|
+
const persistedPath = join(input.persistDir, `${input.callId}.txt`);
|
|
295
|
+
try {
|
|
296
|
+
await writeAtomic(persistedPath, input.output);
|
|
297
|
+
} catch (err) {
|
|
298
|
+
return {
|
|
299
|
+
kind: "error",
|
|
300
|
+
reason: "write-failed",
|
|
301
|
+
error: err instanceof Error ? err : new Error(String(err))
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
kind: "persisted",
|
|
306
|
+
output: buildPersistedStub({
|
|
307
|
+
toolName: input.toolName,
|
|
308
|
+
originalBytes,
|
|
309
|
+
persistedPath,
|
|
310
|
+
output: input.output
|
|
311
|
+
}),
|
|
312
|
+
originalBytes,
|
|
313
|
+
persistedPath
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Render the byte-stable `<persisted-output>` stub the model sees in place
|
|
318
|
+
* of the original `tool_result`.
|
|
319
|
+
*
|
|
320
|
+
* Format choices:
|
|
321
|
+
* - XML wrapper because models reliably parse it as structural.
|
|
322
|
+
* - Byte count + path in attributes so the model can decide whether to
|
|
323
|
+
* `read_file` the persisted blob without scanning the preview.
|
|
324
|
+
* - Preview always shows the head — `shell`'s tail-priority truncation is
|
|
325
|
+
* irrelevant here because the model has the full path if it needs the
|
|
326
|
+
* tail.
|
|
327
|
+
* - No timestamps, no random UUIDs inside the stub: every byte must be
|
|
328
|
+
* reproducible from the inputs, otherwise re-emission on subsequent
|
|
329
|
+
* turns would bust the prompt cache.
|
|
330
|
+
*
|
|
331
|
+
* Exported for tests (asserting the byte-stable contract) and for SDK
|
|
332
|
+
* consumers wiring their own persistence middleware against the same
|
|
333
|
+
* surface.
|
|
334
|
+
*/
|
|
335
|
+
function buildPersistedStub(input) {
|
|
336
|
+
const { slice: previewSlice, bytes: previewBytes } = sliceFirstBytes(input.output, PERSISTENCE_PREVIEW_BYTES);
|
|
337
|
+
const previewMarker = previewSlice.length < input.output.length ? `\n…(${input.originalBytes - previewBytes} more bytes in persisted file)` : "";
|
|
338
|
+
return [
|
|
339
|
+
`${PERSISTED_STUB_PREFIX}${escapeAttr(input.toolName)}" bytes="${input.originalBytes}" path="${escapeAttr(input.persistedPath)}">`,
|
|
340
|
+
`${previewSlice}${previewMarker}`,
|
|
341
|
+
"</persisted-output>"
|
|
342
|
+
].join("\n");
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Remove every persisted blob belonging to a session. Called by the chat
|
|
346
|
+
* layer from its session-delete path so closing a session frees the disk
|
|
347
|
+
* footprint alongside the SQLite row.
|
|
348
|
+
*
|
|
349
|
+
* Idempotent — missing directory (session never persisted anything) is a
|
|
350
|
+
* no-op, not an error. Wraps the `rm -rf` so a permissions blip on one
|
|
351
|
+
* blob doesn't propagate to the caller; the chat layer can't usefully
|
|
352
|
+
* recover from "couldn't unlink a result file" mid-delete.
|
|
353
|
+
*/
|
|
354
|
+
async function cleanupPersistedSession(persistRoot) {
|
|
355
|
+
if (!isAbsolute(persistRoot)) throw new Error(`cleanupPersistedSession: persistRoot must be absolute, got "${persistRoot}"`);
|
|
356
|
+
try {
|
|
357
|
+
await rm(persistRoot, {
|
|
358
|
+
recursive: true,
|
|
359
|
+
force: true
|
|
360
|
+
});
|
|
361
|
+
} catch (err) {
|
|
362
|
+
if (process.env.ZIDANE_DEBUG) {
|
|
363
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
364
|
+
process.stderr.write(`[zidane/persistence] cleanup "${persistRoot}" failed: ${msg}\n`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Write-then-rename for atomicity. A concurrent reader (or a crash mid-
|
|
370
|
+
* write) never observes a partial file: the rename is atomic on every
|
|
371
|
+
* POSIX FS, and the destination is either the fully-written file or
|
|
372
|
+
* absent. Creates the parent directory on demand so the caller doesn't
|
|
373
|
+
* have to track which sessions have already initialized their dir.
|
|
374
|
+
*
|
|
375
|
+
* On write failure (disk full, permissions, signal), removes the `.tmp`
|
|
376
|
+
* file so it doesn't accumulate as debris alongside successful blobs.
|
|
377
|
+
* The unlink itself is best-effort — if we can't write to the dir we
|
|
378
|
+
* likely can't unlink from it either, and the original error is what
|
|
379
|
+
* the caller needs to see.
|
|
380
|
+
*
|
|
381
|
+
* Same idiom we use elsewhere (state-store snapshots, session export).
|
|
382
|
+
*/
|
|
383
|
+
async function writeAtomic(path, content) {
|
|
384
|
+
await mkdir(dirname(path), { recursive: true });
|
|
385
|
+
const tmp = `${path}.tmp`;
|
|
386
|
+
try {
|
|
387
|
+
await writeFile(tmp, content, "utf8");
|
|
388
|
+
await rename(tmp, path);
|
|
389
|
+
} catch (err) {
|
|
390
|
+
await rm(tmp, { force: true }).catch(() => {});
|
|
391
|
+
throw err;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Byte length of a UTF-8 string. `Buffer.byteLength` is the canonical
|
|
396
|
+
* answer; pulling it through a small helper keeps `node:buffer` out of
|
|
397
|
+
* call sites that don't otherwise need it.
|
|
398
|
+
*/
|
|
399
|
+
function byteLength(text) {
|
|
400
|
+
return Buffer.byteLength(text, "utf8");
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Take the first `cap` bytes of `text` without splitting a UTF-8
|
|
404
|
+
* codepoint. Returns the substring AND its exact UTF-8 byte length so
|
|
405
|
+
* the caller doesn't repeat the byte walk (the truncation marker in
|
|
406
|
+
* {@link buildPersistedStub} needs both pieces).
|
|
407
|
+
*
|
|
408
|
+
* Iterates with `for...of` so each step yields a full Unicode codepoint
|
|
409
|
+
* (not a UTF-16 code unit). This matters for content above the BMP —
|
|
410
|
+
* emoji, supplementary-plane characters, anything encoded as a surrogate
|
|
411
|
+
* pair in UTF-16. A naive `text[i]` walk would slice mid-pair, leaving a
|
|
412
|
+
* lone surrogate that re-encodes to the UTF-8 replacement character
|
|
413
|
+
* (garbled preview, off-by-one byte accounting).
|
|
414
|
+
*
|
|
415
|
+
* The `ch.length` advance handles both BMP chars (length 1) and surrogate
|
|
416
|
+
* pairs (length 2) uniformly, since `ch` is whatever `for...of` yielded.
|
|
417
|
+
*
|
|
418
|
+
* Returns the original string when it already fits — no allocation when
|
|
419
|
+
* the cap doesn't bite.
|
|
420
|
+
*/
|
|
421
|
+
function sliceFirstBytes(text, cap) {
|
|
422
|
+
if (cap <= 0) return {
|
|
423
|
+
slice: "",
|
|
424
|
+
bytes: 0
|
|
425
|
+
};
|
|
426
|
+
const total = byteLength(text);
|
|
427
|
+
if (total <= cap) return {
|
|
428
|
+
slice: text,
|
|
429
|
+
bytes: total
|
|
430
|
+
};
|
|
431
|
+
let bytes = 0;
|
|
432
|
+
let charIdx = 0;
|
|
433
|
+
for (const ch of text) {
|
|
434
|
+
const chBytes = byteLength(ch);
|
|
435
|
+
if (bytes + chBytes > cap) break;
|
|
436
|
+
bytes += chBytes;
|
|
437
|
+
charIdx += ch.length;
|
|
438
|
+
}
|
|
439
|
+
return {
|
|
440
|
+
slice: text.slice(0, charIdx),
|
|
441
|
+
bytes
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Escape `&`, `"`, and `<` for safe inclusion in an XML attribute. The
|
|
446
|
+
* stub format embeds tool names and filesystem paths verbatim — both
|
|
447
|
+
* theoretically could contain one of these (Windows paths can't, but a
|
|
448
|
+
* tool alias is user-controlled). Keeping the attribute well-formed
|
|
449
|
+
* prevents a malicious or unusual tool name from breaking the wrapper
|
|
450
|
+
* parse. `&` is escaped first so the subsequent replacements don't
|
|
451
|
+
* double-encode the entities we just emitted.
|
|
452
|
+
*/
|
|
453
|
+
function escapeAttr(text) {
|
|
454
|
+
return text.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
455
|
+
}
|
|
456
|
+
//#endregion
|
|
207
457
|
//#region src/tools/validation.ts
|
|
208
458
|
const TRUE_STRINGS = new Set([
|
|
209
459
|
"true",
|
|
@@ -417,6 +667,101 @@ function turnsToMessages(turns) {
|
|
|
417
667
|
}));
|
|
418
668
|
}
|
|
419
669
|
/**
|
|
670
|
+
* Wire-level cutoff for {@link SessionContentBlock}'s `compact-summary`
|
|
671
|
+
* markers.
|
|
672
|
+
*
|
|
673
|
+
* Walks `turns` to find the latest marker block. When found:
|
|
674
|
+
*
|
|
675
|
+
* 1. Turns whose id appears in the marker's `replacesTurnIds` are
|
|
676
|
+
* dropped from the wire-level list (the model sees the summary
|
|
677
|
+
* instead of those turns).
|
|
678
|
+
* 2. The marker turn itself is replaced with a synthesized plain
|
|
679
|
+
* user-text turn whose text is the summary — providers don't know
|
|
680
|
+
* about the `compact-summary` block type, so we always normalize
|
|
681
|
+
* before they see it.
|
|
682
|
+
* 3. The synthetic marker is positioned at the slot of the **first
|
|
683
|
+
* replaced turn**, so the summary appears CHRONOLOGICALLY where
|
|
684
|
+
* the content it summarizes used to live. This keeps the wire-
|
|
685
|
+
* level conversation in correct narrative order:
|
|
686
|
+
* - older unreplaced turns (PTL head-drops) come first
|
|
687
|
+
* - then the synthesized summary
|
|
688
|
+
* - then later unreplaced turns (preserved tail + new prompts)
|
|
689
|
+
* 4. Every other turn is passed through by reference. This includes:
|
|
690
|
+
* - turns BEFORE the marker that aren't in `replacesTurnIds`
|
|
691
|
+
* (e.g. head turns dropped by `compactConversation`'s PTL retry
|
|
692
|
+
* path — the harness keeps them visible to the model verbatim
|
|
693
|
+
* because the summary doesn't describe them)
|
|
694
|
+
* - turns AFTER the marker (preserved tail + any new prompts the
|
|
695
|
+
* user appended after compaction)
|
|
696
|
+
*
|
|
697
|
+
* If no marker exists, the input array is returned unchanged.
|
|
698
|
+
*
|
|
699
|
+
* Only the latest `compact-summary` block is honored — sessions
|
|
700
|
+
* compacted twice cascade only if the newer marker's `replacesTurnIds`
|
|
701
|
+
* explicitly subsumes the older marker's id (which the runner does
|
|
702
|
+
* when re-compacting because its `turnsToMessages` inlines older
|
|
703
|
+
* markers into the summary scope).
|
|
704
|
+
*
|
|
705
|
+
* Note on role-alternation: when the marker is immediately followed by
|
|
706
|
+
* a new user turn (the common case — user submits a prompt right after
|
|
707
|
+
* compacting), the wire output ends in `[…, synthetic_user, new_user]`.
|
|
708
|
+
* Anthropic folds adjacent same-role messages server-side; other
|
|
709
|
+
* providers tolerate them via their own normalization passes. The
|
|
710
|
+
* harness does NOT fold them here — keeping them separate preserves
|
|
711
|
+
* the per-turn `turnId` tags that the TUI's select-turn mode relies on.
|
|
712
|
+
*
|
|
713
|
+
* Pure: a fresh array is returned only when a marker is found. Input
|
|
714
|
+
* turns are never mutated; the synthetic marker is the only new
|
|
715
|
+
* `SessionTurn` allocated.
|
|
716
|
+
*/
|
|
717
|
+
function applyCompactSummaryCutoff(turns) {
|
|
718
|
+
if (turns.length === 0) return turns;
|
|
719
|
+
let markerIdx = -1;
|
|
720
|
+
let markerSummary = "";
|
|
721
|
+
let markerReplacesIds = [];
|
|
722
|
+
for (let i = turns.length - 1; i >= 0; i--) {
|
|
723
|
+
const block = turns[i].content.find((b) => b.type === "compact-summary");
|
|
724
|
+
if (block && block.type === "compact-summary") {
|
|
725
|
+
markerIdx = i;
|
|
726
|
+
markerSummary = block.summary;
|
|
727
|
+
markerReplacesIds = block.replacesTurnIds;
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
if (markerIdx < 0) return turns;
|
|
732
|
+
const markerTurn = turns[markerIdx];
|
|
733
|
+
const synthetic = {
|
|
734
|
+
id: markerTurn.id,
|
|
735
|
+
role: "user",
|
|
736
|
+
content: [{
|
|
737
|
+
type: "text",
|
|
738
|
+
text: markerSummary
|
|
739
|
+
}],
|
|
740
|
+
createdAt: markerTurn.createdAt,
|
|
741
|
+
...markerTurn.runId ? { runId: markerTurn.runId } : {}
|
|
742
|
+
};
|
|
743
|
+
const replacedSet = new Set(markerReplacesIds);
|
|
744
|
+
const out = [];
|
|
745
|
+
let syntheticInserted = false;
|
|
746
|
+
for (let i = 0; i < turns.length; i++) {
|
|
747
|
+
if (i === markerIdx) continue;
|
|
748
|
+
if (replacedSet.has(turns[i].id)) {
|
|
749
|
+
if (!syntheticInserted) {
|
|
750
|
+
out.push(synthetic);
|
|
751
|
+
syntheticInserted = true;
|
|
752
|
+
}
|
|
753
|
+
continue;
|
|
754
|
+
}
|
|
755
|
+
out.push(turns[i]);
|
|
756
|
+
}
|
|
757
|
+
if (!syntheticInserted) {
|
|
758
|
+
let insertAt = 0;
|
|
759
|
+
for (let i = 0; i < markerIdx; i++) if (!replacedSet.has(turns[i].id)) insertAt++;
|
|
760
|
+
out.splice(insertAt, 0, synthetic);
|
|
761
|
+
}
|
|
762
|
+
return out;
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
420
765
|
* Flatten image blocks inside previously-stored `tool_result` outputs to text
|
|
421
766
|
* markers when the provider reports no vision capability. This handles the
|
|
422
767
|
* session-resume / mid-session-provider-switch case:
|
|
@@ -465,6 +810,7 @@ function applyTailCompaction(messages, threshold, keepTurns) {
|
|
|
465
810
|
const newContent = msg.content.map((block) => {
|
|
466
811
|
if (block.type !== "tool_result") return block;
|
|
467
812
|
if (toolOutputByteLength(block.output) <= 86) return block;
|
|
813
|
+
if (typeof block.output === "string" && block.output.startsWith("<persisted-output tool=\"")) return block;
|
|
468
814
|
msgChanged = true;
|
|
469
815
|
changed = true;
|
|
470
816
|
return {
|
|
@@ -685,7 +1031,7 @@ function wrapProviderError(err, ctx) {
|
|
|
685
1031
|
}
|
|
686
1032
|
async function executeTurn(ctx, turn) {
|
|
687
1033
|
const turnId = await ctx.generateTurnId();
|
|
688
|
-
let canonicalMessages = turnsToMessages(ctx.turns);
|
|
1034
|
+
let canonicalMessages = turnsToMessages(applyCompactSummaryCutoff(ctx.turns));
|
|
689
1035
|
if (ctx.elideStaleReads === true) canonicalMessages = applyStaleReadElision(canonicalMessages);
|
|
690
1036
|
const wireMessages = rewriteMessagesToWire(canonicalMessages, ctx.aliasMaps);
|
|
691
1037
|
let sanitizedMessages = sanitizeStoredToolResults(ctx.provider, wireMessages);
|
|
@@ -750,6 +1096,7 @@ async function executeTurn(ctx, turn) {
|
|
|
750
1096
|
}
|
|
751
1097
|
});
|
|
752
1098
|
} catch (err) {
|
|
1099
|
+
const wasAborted = ctx.signal.aborted || err instanceof Error && err.name === "AbortError";
|
|
753
1100
|
const errorUsage = {
|
|
754
1101
|
input: 0,
|
|
755
1102
|
output: 0
|
|
@@ -759,7 +1106,7 @@ async function executeTurn(ctx, turn) {
|
|
|
759
1106
|
text: currentText
|
|
760
1107
|
}] : [{
|
|
761
1108
|
type: "text",
|
|
762
|
-
text: "[
|
|
1109
|
+
text: wasAborted ? "[⏹ Streaming was aborted.]" : "[✗ Streaming failed before any output.]"
|
|
763
1110
|
}];
|
|
764
1111
|
const errorTurn = {
|
|
765
1112
|
id: turnId,
|
|
@@ -822,7 +1169,7 @@ async function executeTurn(ctx, turn) {
|
|
|
822
1169
|
description: "Return the final structured output matching the required schema.",
|
|
823
1170
|
inputSchema: ctx.schema
|
|
824
1171
|
};
|
|
825
|
-
const schemaMessages = rewriteMessagesToWire(turnsToMessages(ctx.turns), ctx.aliasMaps);
|
|
1172
|
+
const schemaMessages = rewriteMessagesToWire(turnsToMessages(applyCompactSummaryCutoff(ctx.turns)), ctx.aliasMaps);
|
|
826
1173
|
let schemaResult;
|
|
827
1174
|
try {
|
|
828
1175
|
schemaResult = await ctx.provider.stream({
|
|
@@ -1126,6 +1473,20 @@ async function emitToolResult(ctx, params) {
|
|
|
1126
1473
|
await ctx.hooks.callHook("tool:transform", transformCtx);
|
|
1127
1474
|
output = transformCtx.result;
|
|
1128
1475
|
isError = transformCtx.isError;
|
|
1476
|
+
const threshold = ctx.persistThreshold;
|
|
1477
|
+
const persistDir = ctx.persistDir;
|
|
1478
|
+
if (threshold && threshold > 0 && persistDir) {
|
|
1479
|
+
const outcome = await maybePersistToolResult({
|
|
1480
|
+
toolName: name,
|
|
1481
|
+
callId,
|
|
1482
|
+
output,
|
|
1483
|
+
threshold,
|
|
1484
|
+
persistDir,
|
|
1485
|
+
...ctx.persistExcludeTools ? { excludeTools: ctx.persistExcludeTools } : {}
|
|
1486
|
+
});
|
|
1487
|
+
if (outcome.kind === "persisted") output = outcome.output;
|
|
1488
|
+
else if (outcome.kind === "error" && process.env.ZIDANE_DEBUG) process.stderr.write(`[zidane/loop] persistence write failed for ${name}/${callId}: ${outcome.error.message}\n`);
|
|
1489
|
+
}
|
|
1129
1490
|
output = stripImagesForNonVision(ctx.provider, output);
|
|
1130
1491
|
await ctx.hooks.callHook("tool:after", {
|
|
1131
1492
|
turnId,
|
|
@@ -1790,6 +2151,10 @@ const HOOK_EVENT_SET = new Set([
|
|
|
1790
2151
|
"mcp:close",
|
|
1791
2152
|
"mcp:bootstrap:start",
|
|
1792
2153
|
"mcp:bootstrap:end",
|
|
2154
|
+
"mcp:auth:required",
|
|
2155
|
+
"mcp:auth:url",
|
|
2156
|
+
"mcp:auth:success",
|
|
2157
|
+
"mcp:auth:error",
|
|
1793
2158
|
"mcp:tools:filter",
|
|
1794
2159
|
"mcp:tool:gate",
|
|
1795
2160
|
"mcp:tool:before",
|
|
@@ -1874,7 +2239,10 @@ function resolveBehavior(agentBehavior, runBehavior) {
|
|
|
1874
2239
|
readLineNumbers: runBehavior?.readLineNumbers ?? agentBehavior?.readLineNumbers,
|
|
1875
2240
|
elideStaleReads: runBehavior?.elideStaleReads ?? agentBehavior?.elideStaleReads,
|
|
1876
2241
|
toolDisclosure: runBehavior?.toolDisclosure ?? agentBehavior?.toolDisclosure ?? "eager",
|
|
1877
|
-
toolSearch: runBehavior?.toolSearch ?? agentBehavior?.toolSearch
|
|
2242
|
+
toolSearch: runBehavior?.toolSearch ?? agentBehavior?.toolSearch,
|
|
2243
|
+
persistThreshold: runBehavior?.persistThreshold ?? agentBehavior?.persistThreshold,
|
|
2244
|
+
persistExcludeTools: runBehavior?.persistExcludeTools ?? agentBehavior?.persistExcludeTools,
|
|
2245
|
+
persistDir: runBehavior?.persistDir ?? agentBehavior?.persistDir
|
|
1878
2246
|
};
|
|
1879
2247
|
}
|
|
1880
2248
|
/**
|
|
@@ -2157,7 +2525,7 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
|
|
|
2157
2525
|
const thinking = options.thinking ?? "off";
|
|
2158
2526
|
const model = options.model ?? provider.meta.defaultModel;
|
|
2159
2527
|
const resolvedBehavior = resolveBehavior(agentBehavior, options.behavior);
|
|
2160
|
-
const { toolExecution, maxTurns, maxTokens, thinkingBudget, schema, cache, toolOutputBudget, compactStrategy, compactThreshold, compactKeepTurns, thinkingDecay, dedupTools, toolBudgets, elideStaleReads, toolDisclosure, toolSearch } = resolvedBehavior;
|
|
2528
|
+
const { toolExecution, maxTurns, maxTokens, thinkingBudget, schema, cache, toolOutputBudget, compactStrategy, compactThreshold, compactKeepTurns, thinkingDecay, dedupTools, toolBudgets, elideStaleReads, toolDisclosure, toolSearch, persistThreshold, persistExcludeTools, persistDir } = resolvedBehavior;
|
|
2161
2529
|
let system = options.system || agentSystem || "You are a helpful assistant.";
|
|
2162
2530
|
if (skillsCatalog) system = `${system}\n\n${skillsCatalog}`;
|
|
2163
2531
|
const runBaseTools = options.tools !== void 0 ? options.tools : mcpConnection ? {
|
|
@@ -2341,6 +2709,9 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
|
|
|
2341
2709
|
compactKeepTurns,
|
|
2342
2710
|
...elideStaleReads !== void 0 ? { elideStaleReads } : {},
|
|
2343
2711
|
...thinkingDecay !== void 0 ? { thinkingDecay } : {},
|
|
2712
|
+
...persistThreshold !== void 0 ? { persistThreshold } : {},
|
|
2713
|
+
...persistExcludeTools !== void 0 ? { persistExcludeTools } : {},
|
|
2714
|
+
...persistDir !== void 0 ? { persistDir } : {},
|
|
2344
2715
|
runStartMs,
|
|
2345
2716
|
runToolCounts: {}
|
|
2346
2717
|
});
|
|
@@ -3985,7 +4356,22 @@ function createSpawnTool(options = {}) {
|
|
|
3985
4356
|
execution: ctx.execution,
|
|
3986
4357
|
...options.persist && ctx.session ? { session: ctx.session } : {}
|
|
3987
4358
|
});
|
|
3988
|
-
if (forwardHooks)
|
|
4359
|
+
if (forwardHooks) {
|
|
4360
|
+
const unregisterEnricher = agent.hooks.hook("tool:before", async (toolCtx) => {
|
|
4361
|
+
if (toolCtx.name !== "write_file") return;
|
|
4362
|
+
if (!agent.handle) return;
|
|
4363
|
+
const inputPath = toolCtx.input?.path;
|
|
4364
|
+
if (typeof inputPath !== "string") return;
|
|
4365
|
+
try {
|
|
4366
|
+
toolCtx.priorContent = await agent.execution.readFile(agent.handle, inputPath);
|
|
4367
|
+
} catch {}
|
|
4368
|
+
});
|
|
4369
|
+
const unbubbleInner = bubbleHooks(agent.hooks, ctx.hooks, id, childDepth);
|
|
4370
|
+
unbubble = () => {
|
|
4371
|
+
unregisterEnricher();
|
|
4372
|
+
unbubbleInner();
|
|
4373
|
+
};
|
|
4374
|
+
}
|
|
3989
4375
|
options.onSpawn?.(child);
|
|
3990
4376
|
await ctx.hooks.callHook("spawn:before", {
|
|
3991
4377
|
id,
|
|
@@ -4143,6 +4529,6 @@ const writeFile$1 = {
|
|
|
4143
4529
|
}
|
|
4144
4530
|
};
|
|
4145
4531
|
//#endregion
|
|
4146
|
-
export { multiEdit as a, grep as c, createAgent as d, createToolSearchTool as f, validateToolArgs as g, createSkillsReadTool as h, readFile$1 as i, glob as l, createSkillsRunScriptTool as m, createSpawnTool as n, listFiles as o, createSkillsUseTool as p, shell as r, createInteractionTool as s, writeFile$1 as t, edit as u };
|
|
4532
|
+
export { getReadState as C, resolvePersistDir as S, PERSISTED_STUB_PREFIX as _, multiEdit as a, cleanupPersistedSession as b, grep as c, createAgent as d, createToolSearchTool as f, validateToolArgs as g, createSkillsReadTool as h, readFile$1 as i, glob as l, createSkillsRunScriptTool as m, createSpawnTool as n, listFiles as o, createSkillsUseTool as p, shell as r, createInteractionTool as s, writeFile$1 as t, edit as u, PERSISTENCE_PREVIEW_BYTES as v, maybePersistToolResult as x, buildPersistedStub as y };
|
|
4147
4533
|
|
|
4148
|
-
//# sourceMappingURL=tools-
|
|
4534
|
+
//# sourceMappingURL=tools-d1yeA6xK.js.map
|