zidane 5.8.0 → 5.8.3
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/dist/{agent-DYghZGC8.d.ts → agent-CL4nT5Ti.d.ts} +155 -10
- package/dist/agent-CL4nT5Ti.d.ts.map +1 -0
- package/dist/chat/pure.d.ts +3 -3
- package/dist/chat.d.ts +6 -6
- package/dist/chat.js +2 -2
- package/dist/{headless-DnjYDckH.js → headless-BfEQtRfX.js} +4 -4
- package/dist/{headless-DnjYDckH.js.map → headless-BfEQtRfX.js.map} +1 -1
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +1 -1
- package/dist/{index-B2cMuK6S.d.ts → index-DdjlsREW.d.ts} +2 -2
- package/dist/{index-B2cMuK6S.d.ts.map → index-DdjlsREW.d.ts.map} +1 -1
- package/dist/{index-CVzpMtdq.d.ts → index-DtLfTUXt.d.ts} +2 -2
- package/dist/{index-CVzpMtdq.d.ts.map → index-DtLfTUXt.d.ts.map} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -296
- package/dist/index.js.map +1 -1
- package/dist/{login-D-3A5CK7.js → login-Ck6dmcMH.js} +301 -4
- package/dist/login-Ck6dmcMH.js.map +1 -0
- package/dist/{mcp-Kqzz-Rs_.js → mcp-Br3b1Xm3.js} +50 -8
- package/dist/mcp-Br3b1Xm3.js.map +1 -0
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +2 -2
- package/dist/{presets-B1gWui0v.js → presets-DIweYdlN.js} +2 -2
- package/dist/{presets-B1gWui0v.js.map → presets-DIweYdlN.js.map} +1 -1
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +1 -1
- package/dist/providers.d.ts +1 -1
- package/dist/restate.d.ts +1 -1
- package/dist/session/sqlite.d.ts +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/skills.d.ts +2 -2
- package/dist/{tool-formatters-0FEGRd6w.d.ts → tool-formatters-D-aWpu2N.d.ts} +2 -2
- package/dist/{tool-formatters-0FEGRd6w.d.ts.map → tool-formatters-D-aWpu2N.d.ts.map} +1 -1
- package/dist/tools/fetch-url.d.ts +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/{tools-BmPeBGU1.js → tools-DLRIhCl1.js} +109 -36
- package/dist/tools-DLRIhCl1.js.map +1 -0
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +1 -1
- package/dist/{transcript-anchors-D2erm5iS.d.ts → transcript-anchors-BJpOyLPm.d.ts} +5 -5
- package/dist/{transcript-anchors-D2erm5iS.d.ts.map → transcript-anchors-BJpOyLPm.d.ts.map} +1 -1
- package/dist/{transcript-anchors-Bp5bV0Bv.js → transcript-anchors-Dc0WlxnA.js} +18 -5
- package/dist/transcript-anchors-Dc0WlxnA.js.map +1 -0
- package/dist/tui.d.ts +14 -4
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +282 -76
- package/dist/tui.js.map +1 -1
- package/dist/{turn-operations-CeUrtsaM.d.ts → turn-operations-D-fypW6K.d.ts} +3 -3
- package/dist/{turn-operations-CeUrtsaM.d.ts.map → turn-operations-D-fypW6K.d.ts.map} +1 -1
- package/dist/types-BPw_i5vb.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/docs/ARCHITECTURE.md +2 -1
- package/package.json +1 -1
- package/dist/agent-DYghZGC8.d.ts.map +0 -1
- package/dist/login-D-3A5CK7.js.map +0 -1
- package/dist/mcp-Kqzz-Rs_.js.map +0 -1
- package/dist/tools-BmPeBGU1.js.map +0 -1
- package/dist/transcript-anchors-Bp5bV0Bv.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as resolveTasksDir, C as PERSISTED_STUB_PREFIX, D as maybePersistToolResult, E as cleanupPersistedSession, N as readStateKey, P as resolveReadStateMap, S as validateToolArgs, T as buildPersistedStub, a as multiEdit, b as TOOL_USE_CANCELLED_MESSAGE, c as grep, d as createAgent, g as createShellTool, h as createSkillsReadTool, j as getReadState, k as resolvePersistDir, l as glob, m as createSkillsRunScriptTool, n as createSpawnTool, p as createSkillsUseTool, s as createInteractionTool, u as edit, v as INTERRUPT_MESSAGE_FOR_TOOL_USE, w as PERSISTENCE_PREVIEW_BYTES, x as TOOL_USE_SKIPPED_MESSAGE, y as SHELL_CASCADE_CANCEL_MESSAGE } from "./tools-DLRIhCl1.js";
|
|
2
2
|
import { h as utf8ByteLength, m as estimateTokens, p as BYTES_PER_TOKEN } from "./edit-utils-DnfNoj16.js";
|
|
3
3
|
import { c as anthropic, l as applyAnthropicCacheBreakpoints, n as openai, r as local, s as cerebras, t as openrouter } from "./providers-h4HJPbbv.js";
|
|
4
4
|
import { a as AgentToolNotAllowedError, d as matchesContextExceeded, f as toTypedError, i as AgentProviderError, l as errorMessage, n as AgentBudgetExceededError, o as AgentToolPairingError, r as AgentContextExceededError, s as CONTEXT_EXCEEDED_MESSAGE_PATTERNS, t as AgentAbortedError } from "./errors-CoQnKRf1.js";
|
|
@@ -6,11 +6,11 @@ import { A as replaceDynamicSection, D as hasSystemPromptBoundary, E as appendSt
|
|
|
6
6
|
import { n as createProcessContext, t as createSandboxContext } from "./contexts-BD2U_xpi.js";
|
|
7
7
|
import { n as toolOutputByteLength, r as toolResultToText } from "./types-BPw_i5vb.js";
|
|
8
8
|
import { _ as validateSkillForWrite, a as discoverSkills, d as IMPLICITLY_ALLOWED_SKILL_TOOLS, f as installAllowedToolsGate, g as validateResourcePath, h as parseAllowedToolPattern, i as writeSkillsToDisk, l as parseSkillFile, m as matchesAllowedTool, n as resolveSkills, p as isToolAllowedByUnion, r as writeSkillToDisk, t as interpolateShellCommands, u as buildCatalog, v as validateSkillName, y as createSkillActivationState } from "./interpolate-TySiqKzc.js";
|
|
9
|
-
import { c as
|
|
9
|
+
import { a as resultToString, c as McpOAuthProvider, i as normalizeMcpServers, l as createMemoryMcpCredentialStore, n as connectMcpServers, r as normalizeMcpBlocks, u as hasAuthorizationHeader } from "./mcp-Br3b1Xm3.js";
|
|
10
10
|
import { i as statsByModel, n as flattenTurns } from "./stats-DAKBEKjc.js";
|
|
11
|
-
import { C as CompactPromptTooLongError,
|
|
12
|
-
import { i as basic_default, n as definePreset, r as basicTools } from "./presets-
|
|
13
|
-
import { i as createRunSummaryCollector, n as runHeadless, r as transcriptToOpenAIMessages, t as headlessEventToJsonl } from "./headless-
|
|
11
|
+
import { C as stripImagesFromTurns, D as CompactPromptTooLongError, E as CompactInvalidInputError, S as sliceForCompaction, T as truncateHeadForPtlRetry, _ as buildFullCompactPrompt, a as createLoggingHooks, b as ANCHOR_PREVIEW_MAX_CHARS, c as selectFilesFromReadState, d as compactConversation, f as BASE_INSTRUCTIONS, g as buildFromCompactPrompt, h as buildCompactPrompt, i as createLogger, l as selectFilesFromSession, m as TRAILER, n as startOAuthCallback, o as jsonSink, p as NO_TOOLS_PREAMBLE, r as consoleSink, s as buildPostCompactAttachments, t as loginMcpServer, u as selectRecentFiles, v as buildTailCompactPrompt, w as summaryToTurn, x as anchorPreviewFor, y as buildUpToCompactPrompt } from "./login-Ck6dmcMH.js";
|
|
12
|
+
import { i as basic_default, n as definePreset, r as basicTools } from "./presets-DIweYdlN.js";
|
|
13
|
+
import { i as createRunSummaryCollector, n as runHeadless, r as transcriptToOpenAIMessages, t as headlessEventToJsonl } from "./headless-BfEQtRfX.js";
|
|
14
14
|
import { a as createFileMapStore, i as createMemoryStore, n as loadSession, r as createRemoteStore, t as createSession } from "./session-BzLou2_-.js";
|
|
15
15
|
import { defineSkill } from "./skills.js";
|
|
16
16
|
//#region src/cache-telemetry.ts
|
|
@@ -174,297 +174,6 @@ function formatVerboseLine(input) {
|
|
|
174
174
|
return `[zidane:cache] turn=${input.turn} turnId=${input.turnId} system=${hex(s.systemHash)}(${s.systemBytes}b) tools=${hex(s.toolsHash)}(${s.toolsCount}) model=${s.model} thinking=${s.thinking}/${s.thinkingBudget}`;
|
|
175
175
|
}
|
|
176
176
|
//#endregion
|
|
177
|
-
//#region src/logger.ts
|
|
178
|
-
/**
|
|
179
|
-
* Build a Logger from a sink. Stateless and cheap; create one per agent
|
|
180
|
-
* (or per app) and use `.with()` to attach correlation ids per-call.
|
|
181
|
-
*/
|
|
182
|
-
function createLogger(sink, baseAttributes = {}) {
|
|
183
|
-
function emit(level, message, attrs) {
|
|
184
|
-
try {
|
|
185
|
-
sink.emit({
|
|
186
|
-
level,
|
|
187
|
-
timestamp: Date.now(),
|
|
188
|
-
message,
|
|
189
|
-
attrs: attrs ? {
|
|
190
|
-
...baseAttributes,
|
|
191
|
-
...attrs
|
|
192
|
-
} : { ...baseAttributes }
|
|
193
|
-
});
|
|
194
|
-
} catch {}
|
|
195
|
-
}
|
|
196
|
-
return {
|
|
197
|
-
debug: (m, a) => emit("debug", m, a),
|
|
198
|
-
info: (m, a) => emit("info", m, a),
|
|
199
|
-
warn: (m, a) => emit("warn", m, a),
|
|
200
|
-
error: (m, a) => emit("error", m, a),
|
|
201
|
-
with: (extra) => createLogger(sink, {
|
|
202
|
-
...baseAttributes,
|
|
203
|
-
...extra
|
|
204
|
-
}),
|
|
205
|
-
baseAttributes
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
const LEVEL_ORDER = {
|
|
209
|
-
debug: 0,
|
|
210
|
-
info: 1,
|
|
211
|
-
warn: 2,
|
|
212
|
-
error: 3
|
|
213
|
-
};
|
|
214
|
-
/**
|
|
215
|
-
* Human-readable terminal sink. Renders each record as
|
|
216
|
-
* `<ISO timestamp> <LEVEL> <message> <attrs as kv pairs>`.
|
|
217
|
-
*
|
|
218
|
-
* Honors `process.stderr` by default so log lines don't interleave with
|
|
219
|
-
* the agent's stdout-bound output (chat responses, JSON results).
|
|
220
|
-
*/
|
|
221
|
-
function consoleSink(options = {}) {
|
|
222
|
-
const min = LEVEL_ORDER[options.minLevel ?? "info"];
|
|
223
|
-
const stream = options.stream ?? process.stderr;
|
|
224
|
-
return { emit(record) {
|
|
225
|
-
if (LEVEL_ORDER[record.level] < min) return;
|
|
226
|
-
const ts = new Date(record.timestamp).toISOString();
|
|
227
|
-
const kv = Object.entries(record.attrs).filter(([, v]) => v !== void 0).map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(" ");
|
|
228
|
-
stream.write(`${ts} ${record.level.toUpperCase().padEnd(5)} ${record.message}${kv ? ` ${kv}` : ""}\n`);
|
|
229
|
-
} };
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* One-JSON-object-per-line sink. Suitable for piping into log aggregators
|
|
233
|
-
* (Datadog Agent, Fluent Bit, Loki, Vector) that expect JSONL.
|
|
234
|
-
*/
|
|
235
|
-
function jsonSink(options = {}) {
|
|
236
|
-
const min = LEVEL_ORDER[options.minLevel ?? "info"];
|
|
237
|
-
const stream = options.stream ?? process.stderr;
|
|
238
|
-
return { emit(record) {
|
|
239
|
-
if (LEVEL_ORDER[record.level] < min) return;
|
|
240
|
-
try {
|
|
241
|
-
stream.write(`${JSON.stringify(record)}\n`);
|
|
242
|
-
} catch {}
|
|
243
|
-
} };
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Install a bundle of hook handlers that emit a structured line per
|
|
247
|
-
* relevant lifecycle event, automatically attaching correlation ids
|
|
248
|
-
* (`runId`, `turnId`, `callId`, `childId`, `depth`, `agentName`).
|
|
249
|
-
*
|
|
250
|
-
* @example
|
|
251
|
-
* ```ts
|
|
252
|
-
* const logger = createLogger(consoleSink({ minLevel: 'debug' }), { service: 'tui' })
|
|
253
|
-
* const lh = createLoggingHooks({ logger })
|
|
254
|
-
* const uninstall = lh.install(agent.hooks)
|
|
255
|
-
* try { await agent.run({ prompt }) }
|
|
256
|
-
* finally { uninstall() }
|
|
257
|
-
* ```
|
|
258
|
-
*/
|
|
259
|
-
function createLoggingHooks(options) {
|
|
260
|
-
const root = options.logger;
|
|
261
|
-
const includeLifecycle = options.includeLifecycle ?? true;
|
|
262
|
-
const minLevel = LEVEL_ORDER[options.level ?? "info"];
|
|
263
|
-
/**
|
|
264
|
-
* Wrap a Logger so emissions below `minLevel` are dropped before they
|
|
265
|
-
* hit the sink. Lets us gate harness chatter without forcing every
|
|
266
|
-
* `LogSink` to re-implement level filtering. Preserves `.with()`
|
|
267
|
-
* composition (children inherit the filter).
|
|
268
|
-
*/
|
|
269
|
-
function gateLevel(logger) {
|
|
270
|
-
const skip = (level) => LEVEL_ORDER[level] < minLevel;
|
|
271
|
-
const wrap = (l) => ({
|
|
272
|
-
debug: (m, a) => {
|
|
273
|
-
if (!skip("debug")) l.debug(m, a);
|
|
274
|
-
},
|
|
275
|
-
info: (m, a) => {
|
|
276
|
-
if (!skip("info")) l.info(m, a);
|
|
277
|
-
},
|
|
278
|
-
warn: (m, a) => {
|
|
279
|
-
if (!skip("warn")) l.warn(m, a);
|
|
280
|
-
},
|
|
281
|
-
error: (m, a) => {
|
|
282
|
-
if (!skip("error")) l.error(m, a);
|
|
283
|
-
},
|
|
284
|
-
with: (extra) => wrap(l.with(extra)),
|
|
285
|
-
baseAttributes: l.baseAttributes
|
|
286
|
-
});
|
|
287
|
-
return wrap(logger);
|
|
288
|
-
}
|
|
289
|
-
return { install(hooks) {
|
|
290
|
-
const unregisters = [];
|
|
291
|
-
const gatedRoot = gateLevel(root);
|
|
292
|
-
let runLogger = gatedRoot;
|
|
293
|
-
let turnLogger = gatedRoot;
|
|
294
|
-
unregisters.push(hooks.hook("agent:start", (ctx) => {
|
|
295
|
-
runLogger = gatedRoot.with({
|
|
296
|
-
runId: ctx.runId,
|
|
297
|
-
...ctx.parentRunId ? { parentRunId: ctx.parentRunId } : {},
|
|
298
|
-
depth: ctx.depth,
|
|
299
|
-
...ctx.agentName ? { agentName: ctx.agentName } : {}
|
|
300
|
-
});
|
|
301
|
-
turnLogger = runLogger;
|
|
302
|
-
if (includeLifecycle) runLogger.debug("agent run started");
|
|
303
|
-
}));
|
|
304
|
-
unregisters.push(hooks.hook("agent:done", (stats) => {
|
|
305
|
-
runLogger.info("agent run completed", {
|
|
306
|
-
turns: stats.turns,
|
|
307
|
-
totalIn: stats.totalIn,
|
|
308
|
-
totalOut: stats.totalOut,
|
|
309
|
-
...typeof stats.cost === "number" ? { cost: stats.cost } : {},
|
|
310
|
-
elapsedMs: stats.elapsed,
|
|
311
|
-
...typeof stats.timeTillFirstTokenMs === "number" ? { ttftMs: stats.timeTillFirstTokenMs } : {}
|
|
312
|
-
});
|
|
313
|
-
}));
|
|
314
|
-
unregisters.push(hooks.hook("agent:abort", () => {
|
|
315
|
-
runLogger.warn("agent run aborted");
|
|
316
|
-
}));
|
|
317
|
-
unregisters.push(hooks.hook("turn:before", (ctx) => {
|
|
318
|
-
turnLogger = runLogger.with({
|
|
319
|
-
turnId: ctx.turnId,
|
|
320
|
-
turn: ctx.turn
|
|
321
|
-
});
|
|
322
|
-
if (includeLifecycle) turnLogger.debug("turn started");
|
|
323
|
-
}));
|
|
324
|
-
unregisters.push(hooks.hook("turn:after", (ctx) => {
|
|
325
|
-
turnLogger.debug("turn ended", {
|
|
326
|
-
inputTokens: ctx.usage.input,
|
|
327
|
-
outputTokens: ctx.usage.output,
|
|
328
|
-
...ctx.usage.finishReason ? { finishReason: ctx.usage.finishReason } : {},
|
|
329
|
-
...ctx.usage.modelId ? { modelId: ctx.usage.modelId } : {},
|
|
330
|
-
...typeof ctx.usage.timeToFirstTokenMs === "number" ? { ttftMs: ctx.usage.timeToFirstTokenMs } : {}
|
|
331
|
-
});
|
|
332
|
-
}));
|
|
333
|
-
unregisters.push(hooks.hook("stream:error", (ctx) => {
|
|
334
|
-
turnLogger.error("stream error", {
|
|
335
|
-
message: ctx.err instanceof Error ? ctx.err.message : String(ctx.err),
|
|
336
|
-
...ctx.statusCode !== void 0 ? { statusCode: ctx.statusCode } : {},
|
|
337
|
-
...ctx.requestId !== void 0 ? { requestId: ctx.requestId } : {}
|
|
338
|
-
});
|
|
339
|
-
}));
|
|
340
|
-
unregisters.push(hooks.hook("tool:before", (ctx) => {
|
|
341
|
-
if (!includeLifecycle) return;
|
|
342
|
-
turnLogger.debug("tool started", {
|
|
343
|
-
toolName: ctx.name,
|
|
344
|
-
displayName: ctx.displayName,
|
|
345
|
-
callId: ctx.callId
|
|
346
|
-
});
|
|
347
|
-
}));
|
|
348
|
-
unregisters.push(hooks.hook("tool:after", (ctx) => {
|
|
349
|
-
if (!includeLifecycle) return;
|
|
350
|
-
turnLogger.debug("tool ended", {
|
|
351
|
-
toolName: ctx.name,
|
|
352
|
-
callId: ctx.callId,
|
|
353
|
-
outputBytes: ctx.outputBytes
|
|
354
|
-
});
|
|
355
|
-
}));
|
|
356
|
-
unregisters.push(hooks.hook("tool:error", (ctx) => {
|
|
357
|
-
turnLogger.error("tool error", {
|
|
358
|
-
toolName: ctx.name,
|
|
359
|
-
callId: ctx.callId,
|
|
360
|
-
message: ctx.error.message
|
|
361
|
-
});
|
|
362
|
-
}));
|
|
363
|
-
unregisters.push(hooks.hook("tool:dispatched", (ctx) => {
|
|
364
|
-
const isAnomaly = ctx.outcome === "gate-block" || ctx.outcome === "unknown" || ctx.outcome === "invalid-input";
|
|
365
|
-
if (!isAnomaly && !includeLifecycle) return;
|
|
366
|
-
turnLogger[isAnomaly ? "warn" : "debug"]("tool dispatched", {
|
|
367
|
-
toolName: ctx.name,
|
|
368
|
-
callId: ctx.callId,
|
|
369
|
-
outcome: ctx.outcome,
|
|
370
|
-
...ctx.reason ? { reason: ctx.reason } : {}
|
|
371
|
-
});
|
|
372
|
-
}));
|
|
373
|
-
unregisters.push(hooks.hook("validation:reject", (ctx) => {
|
|
374
|
-
turnLogger.warn("tool input rejected", {
|
|
375
|
-
toolName: ctx.name,
|
|
376
|
-
callId: ctx.callId,
|
|
377
|
-
reason: ctx.reason
|
|
378
|
-
});
|
|
379
|
-
}));
|
|
380
|
-
unregisters.push(hooks.hook("budget:exceeded", (ctx) => {
|
|
381
|
-
turnLogger.warn("byte budget exceeded", {
|
|
382
|
-
bytes: ctx.bytes,
|
|
383
|
-
budget: ctx.budget
|
|
384
|
-
});
|
|
385
|
-
}));
|
|
386
|
-
unregisters.push(hooks.hook("tool-budget:exceeded", (ctx) => {
|
|
387
|
-
turnLogger.warn("tool budget exceeded", {
|
|
388
|
-
toolName: ctx.tool,
|
|
389
|
-
count: ctx.count,
|
|
390
|
-
max: ctx.max,
|
|
391
|
-
mode: ctx.mode
|
|
392
|
-
});
|
|
393
|
-
}));
|
|
394
|
-
unregisters.push(hooks.hook("mcp:bootstrap:end", (ctx) => {
|
|
395
|
-
if (ctx.ok) {
|
|
396
|
-
if (includeLifecycle) runLogger.debug("mcp bootstrap ok", {
|
|
397
|
-
server: ctx.name,
|
|
398
|
-
transport: ctx.transport,
|
|
399
|
-
durationMs: ctx.durationMs,
|
|
400
|
-
toolCount: ctx.toolCount,
|
|
401
|
-
...ctx.lazy ? { lazy: true } : {},
|
|
402
|
-
...ctx.cached ? { cached: true } : {}
|
|
403
|
-
});
|
|
404
|
-
} else runLogger.warn("mcp bootstrap failed", {
|
|
405
|
-
server: ctx.name,
|
|
406
|
-
transport: ctx.transport,
|
|
407
|
-
durationMs: ctx.durationMs,
|
|
408
|
-
message: ctx.error.message
|
|
409
|
-
});
|
|
410
|
-
}));
|
|
411
|
-
unregisters.push(hooks.hook("mcp:error", (ctx) => {
|
|
412
|
-
runLogger.error("mcp error", {
|
|
413
|
-
server: ctx.name,
|
|
414
|
-
message: ctx.error.message
|
|
415
|
-
});
|
|
416
|
-
}));
|
|
417
|
-
unregisters.push(hooks.hook("mcp:auth:required", (ctx) => {
|
|
418
|
-
runLogger.warn("mcp auth required", {
|
|
419
|
-
server: ctx.name,
|
|
420
|
-
transport: ctx.transport,
|
|
421
|
-
reason: ctx.reason
|
|
422
|
-
});
|
|
423
|
-
}));
|
|
424
|
-
unregisters.push(hooks.hook("mcp:tool:error", (ctx) => {
|
|
425
|
-
turnLogger.error("mcp tool error", {
|
|
426
|
-
server: ctx.server,
|
|
427
|
-
tool: ctx.displayName,
|
|
428
|
-
callId: ctx.callId,
|
|
429
|
-
message: ctx.error.message
|
|
430
|
-
});
|
|
431
|
-
}));
|
|
432
|
-
unregisters.push(hooks.hook("spawn:before", (ctx) => {
|
|
433
|
-
if (!includeLifecycle) return;
|
|
434
|
-
runLogger.debug("spawn started", {
|
|
435
|
-
childId: ctx.id,
|
|
436
|
-
depth: ctx.depth
|
|
437
|
-
});
|
|
438
|
-
}));
|
|
439
|
-
unregisters.push(hooks.hook("spawn:complete", (ctx) => {
|
|
440
|
-
runLogger.info("spawn completed", {
|
|
441
|
-
childId: ctx.id,
|
|
442
|
-
...ctx.depth ? { depth: ctx.depth } : {},
|
|
443
|
-
status: ctx.status ?? "completed",
|
|
444
|
-
turns: ctx.stats.turns,
|
|
445
|
-
totalIn: ctx.stats.totalIn,
|
|
446
|
-
totalOut: ctx.stats.totalOut,
|
|
447
|
-
...typeof ctx.stats.cost === "number" ? { cost: ctx.stats.cost } : {}
|
|
448
|
-
});
|
|
449
|
-
}));
|
|
450
|
-
unregisters.push(hooks.hook("spawn:error", (ctx) => {
|
|
451
|
-
runLogger.error("spawn error", {
|
|
452
|
-
childId: ctx.id,
|
|
453
|
-
...ctx.depth ? { depth: ctx.depth } : {},
|
|
454
|
-
message: ctx.error.message
|
|
455
|
-
});
|
|
456
|
-
}));
|
|
457
|
-
let disposed = false;
|
|
458
|
-
return function uninstall() {
|
|
459
|
-
if (disposed) return;
|
|
460
|
-
disposed = true;
|
|
461
|
-
for (const un of unregisters) try {
|
|
462
|
-
un();
|
|
463
|
-
} catch {}
|
|
464
|
-
};
|
|
465
|
-
} };
|
|
466
|
-
}
|
|
467
|
-
//#endregion
|
|
468
177
|
//#region src/metrics.ts
|
|
469
178
|
function prefixed$1(prefix, name) {
|
|
470
179
|
return prefix ? `${prefix}${name}` : name;
|