@symerian/symi 2.6.1 → 2.6.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/{agents-DQIz-_on.js → agents-Dm0V9Z2G.js} +4 -4
- package/dist/{agents.config-CIJRaVWl.js → agents.config-DP0CLvIA.js} +1 -1
- package/dist/{agents.config-D8WPDf-m.js → agents.config-WdkJjM2-.js} +1 -1
- package/dist/{audio-preflight-BVaaZWkg.js → audio-preflight-DHTaS5U1.js} +4 -4
- package/dist/{auth-choice-DTDyJL1r.js → auth-choice-B9OnYICm.js} +1 -1
- package/dist/{auth-choice-BqFbNDuP.js → auth-choice-CXHi61T5.js} +1 -1
- package/dist/{banner-DYDCxnDL.js → banner-ToxTMzfL.js} +1 -1
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +6 -6
- package/dist/bundled/session-memory/handler.js +6 -6
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{channel-options-CvHSm_Kx.js → channel-options-CsGrHsjP.js} +1 -1
- package/dist/{channel-options-vBCJhJB7.js → channel-options-Jl8AKRLD.js} +1 -1
- package/dist/{channel-web-CM2LyWZW.js → channel-web-qFGaLytG.js} +1 -1
- package/dist/{channels-cli-DzOjNNFn.js → channels-cli-BFyOmW-R.js} +4 -4
- package/dist/{channels-cli-D5H3Wcho.js → channels-cli-DQTl2Pk5.js} +4 -4
- package/dist/{chrome-DkaXoP36.js → chrome-DYZwl5Gv.js} +7 -7
- package/dist/{cli-8hqssnRJ.js → cli-B4biLt2z.js} +1 -1
- package/dist/{cli-DNZwCDRe.js → cli-DQw_LEew.js} +1 -1
- package/dist/{command-registry-CHtN2HeK.js → command-registry-D1OePePk.js} +9 -9
- package/dist/{completion-cli-Cov6N3BO.js → completion-cli-CI-0hC_u.js} +2 -2
- package/dist/{completion-cli-C8y_J5KC.js → completion-cli-DW8a1WYc.js} +1 -1
- package/dist/{config-cli-BwO0xAbV.js → config-cli-CpiluXlO.js} +1 -1
- package/dist/{config-cli-B2REEd2l.js → config-cli-DHXt5cQZ.js} +1 -1
- package/dist/{configure-C6yNe33U.js → configure-CmVnpTNi.js} +3 -3
- package/dist/{configure-BWSYSi2-.js → configure-Ha9cu8Bu.js} +3 -3
- package/dist/{deliver-C46-vyqg.js → deliver-dODxSv3b.js} +1 -1
- package/dist/{doctor-completion-BKKzstt6.js → doctor-completion-CRNCOXcf.js} +1 -1
- package/dist/{doctor-completion-D7CDLFLg.js → doctor-completion-ve-JPlmN.js} +1 -1
- package/dist/entry.js +1 -1
- package/dist/extensionAPI.js +1 -1
- package/dist/{gateway-cli-Datohp3m.js → gateway-cli-BPsbjmUI.js} +9 -9
- package/dist/{gateway-cli-BhFM4Bkm.js → gateway-cli-Cc7N8N_E.js} +9 -9
- package/dist/{glass-ui-ws-BzqfD_wX.js → glass-ui-ws-1O1O2xC6.js} +7 -7
- package/dist/{glass-ui-ws-D9yvYULL.js → glass-ui-ws-CKwLnOwl.js} +7 -7
- package/dist/{health-BjwDRAdd.js → health-DTRWmRB8.js} +1 -1
- package/dist/{health-C5XJPwpt.js → health-tYyUNVp5.js} +1 -1
- package/dist/{hooks-cli-U12oVyLH.js → hooks-cli-Cp81vqRc.js} +2 -2
- package/dist/{hooks-cli-CafMq9Vr.js → hooks-cli-eC03ywfG.js} +2 -2
- package/dist/{image-CuzFLQWC.js → image-CXu8W39c.js} +1 -1
- package/dist/index.js +6 -6
- package/dist/llm-slug-generator.js +6 -6
- package/dist/{models-Bo4iHJy-.js → models-CuhnCX2U.js} +2 -2
- package/dist/{models-cli-B5vh-XK8.js → models-cli-BzwGQUdn.js} +3 -3
- package/dist/{models-cli-6aNi3eN9.js → models-cli-CFr_ZP5y.js} +2 -2
- package/dist/{onboard-f-GJ26Ix.js → onboard-B2g2Q6dd.js} +2 -2
- package/dist/{onboard-Bm-pmstf.js → onboard-CcB6pmEy.js} +2 -2
- package/dist/{onboard-channels-BRd1cXye.js → onboard-channels-CWd17q6h.js} +1 -1
- package/dist/{onboard-channels-CUl5U8kV.js → onboard-channels-DmRBC7VN.js} +1 -1
- package/dist/{onboarding-CvBDWlBJ.js → onboarding-DMqlt_p6.js} +3 -3
- package/dist/{onboarding-DIVKvosg.js → onboarding-DwvQIqR8.js} +3 -3
- package/dist/{onboarding.finalize-WSac-JKd.js → onboarding.finalize-BUSzTwhM.js} +5 -5
- package/dist/{onboarding.finalize-DJX6mSLa.js → onboarding.finalize-lJmZSE4C.js} +6 -6
- package/dist/{pi-embedded-BmbbC1Sb.js → pi-embedded-CT2JDfQr.js} +208 -132
- package/dist/{pi-embedded-helpers-CfqDGQ9J.js → pi-embedded-helpers-pubKo8HQ.js} +4 -4
- package/dist/{plugin-registry-5yf-hu_W.js → plugin-registry-DZdPnpP_.js} +1 -1
- package/dist/{plugin-registry-2zUJMasm.js → plugin-registry-vW2V1yCi.js} +1 -1
- package/dist/plugin-sdk/agents/pi-tools.validate-wrapper.d.ts +6 -6
- package/dist/plugin-sdk/{channel-web-DPyyTvFo.js → channel-web-38aqDKeT.js} +1 -1
- package/dist/plugin-sdk/index.js +2 -2
- package/dist/plugin-sdk/{reply-QAcAd9ev.js → reply-BjJZjZRr.js} +204 -128
- package/dist/plugin-sdk/{web-DaTTL9M0.js → web-BgKYnau3.js} +2 -2
- package/dist/{plugins-cli-D4eRESV2.js → plugins-cli-BTq9c2hZ.js} +2 -2
- package/dist/{plugins-cli-DksVl33N.js → plugins-cli-DkAx9r3h.js} +2 -2
- package/dist/{program-BjORH7Cc.js → program-DZx9PtyT.js} +7 -7
- package/dist/{program-context-DaNGrTOm.js → program-context-DyfuToE1.js} +17 -17
- package/dist/{prompt-select-styled-QaS2zul_.js → prompt-select-styled-CifWTOoY.js} +4 -4
- package/dist/{prompt-select-styled-YOj4xigd.js → prompt-select-styled-DNbD3v3G.js} +4 -4
- package/dist/{provider-auth-helpers-DCEbm2hz.js → provider-auth-helpers-BPIIDTwA.js} +1 -1
- package/dist/{provider-auth-helpers-BAGT_RXV.js → provider-auth-helpers-BzySaUp5.js} +1 -1
- package/dist/{push-apns-Bek3ANJa.js → push-apns-DbpeXPGR.js} +1 -1
- package/dist/{push-apns-BECodU1i.js → push-apns-IdD-dKZm.js} +1 -1
- package/dist/{pw-ai-m0mj2KWK.js → pw-ai-B5asscAD.js} +1 -1
- package/dist/{register.agent-DJHQo-Iq.js → register.agent-CfFcSvM1.js} +6 -6
- package/dist/{register.agent-B34lxx7F.js → register.agent-TFUcxDGN.js} +5 -5
- package/dist/{register.configure-DC_-t5kj.js → register.configure-BwRTNCws.js} +6 -6
- package/dist/{register.configure-BdhhIzb0.js → register.configure-D3BJejOC.js} +6 -6
- package/dist/{register.maintenance-cs-A4kHF.js → register.maintenance-B5350ddh.js} +7 -7
- package/dist/{register.maintenance-CITur3O_.js → register.maintenance-DkdVYwbj.js} +8 -8
- package/dist/{register.message-PIaHm2pZ.js → register.message-DTopCPGC.js} +2 -2
- package/dist/{register.message--RhtnEYn.js → register.message-FbCBAfJO.js} +2 -2
- package/dist/{register.onboard-DucZgrF7.js → register.onboard-DITZn8dx.js} +4 -4
- package/dist/{register.onboard-CTJQoDcK.js → register.onboard-GSv5xyA3.js} +4 -4
- package/dist/{register.setup-2ZiUN7ui.js → register.setup-BI6lILMU.js} +4 -4
- package/dist/{register.setup-DD4Rgkt9.js → register.setup-BuOeoBk0.js} +4 -4
- package/dist/{register.status-health-sessions-BqD7L8XL.js → register.status-health-sessions-C1RhWKxN.js} +3 -3
- package/dist/{register.status-health-sessions-sLgA92t7.js → register.status-health-sessions-EK4_odLb.js} +3 -3
- package/dist/{register.subclis-B2dGWFur.js → register.subclis-Bn_Mr_Wa.js} +9 -9
- package/dist/{reply-DYnTEYoa.js → reply-BGSd_cMI.js} +199 -123
- package/dist/{run-main-DWmu2b6D.js → run-main-Bu9IAm9E.js} +14 -14
- package/dist/{runner-CU9l0uJh.js → runner-WAG0M5s9.js} +1 -1
- package/dist/{server-methods-vDGoM3xL.js → server-methods-dxn6-zQz.js} +7 -7
- package/dist/{server-methods-C8EWZt2g.js → server-methods-tA9lkIQT.js} +7 -7
- package/dist/{server-node-events-CKi12bol.js → server-node-events-6jcJSpXA.js} +2 -2
- package/dist/{server-node-events-DFwGbkcO.js → server-node-events-CzcTGD9T.js} +2 -2
- package/dist/{status-B1_iHrOg.js → status-8176C-aV.js} +2 -2
- package/dist/{status-DiX0DAtH.js → status-CcQSl2sN.js} +1 -1
- package/dist/{status--iNVOTMO.js → status-DGKT6HnE.js} +2 -2
- package/dist/{status-BQcdARV4.js → status-DmPOSk-A.js} +1 -1
- package/dist/{subagent-registry-CXrOOgPW.js → subagent-registry-DqFKNTCX.js} +202 -126
- package/dist/{unified-runner-CulJZMxc.js → unified-runner-BbanUEmo.js} +227 -151
- package/dist/{update-cli-D1pLX3eo.js → update-cli-FMcGr7MA.js} +8 -8
- package/dist/{update-cli-560gprSp.js → update-cli-YCXB_6jz.js} +7 -7
- package/dist/{update-runner-CLKHrONW.js → update-runner-C8OkrKjW.js} +1 -1
- package/dist/{update-runner-BQxFFCGc.js → update-runner-DMP1rCS1.js} +1 -1
- package/dist/{web-hHX9a9YO.js → web-BsS1ia0M.js} +6 -6
- package/dist/{web-Bqrgp43v.js → web-CQ2F1f3a.js} +1 -1
- package/dist/{web-Dr5cOn-1.js → web-DoRGusTq.js} +2 -2
- package/dist/{web-D4qJ9XKP.js → web-LUMjboLF.js} +1 -1
- package/package.json +1 -1
|
@@ -11532,7 +11532,7 @@ function resolveMemoryBackendConfig(params) {
|
|
|
11532
11532
|
|
|
11533
11533
|
//#endregion
|
|
11534
11534
|
//#region src/memory/search-manager.ts
|
|
11535
|
-
const log$
|
|
11535
|
+
const log$10 = createSubsystemLogger("memory");
|
|
11536
11536
|
const QMD_MANAGER_CACHE = /* @__PURE__ */ new Map();
|
|
11537
11537
|
async function getMemorySearchManager(params) {
|
|
11538
11538
|
const resolved = resolveMemoryBackendConfig(params);
|
|
@@ -11565,7 +11565,7 @@ async function getMemorySearchManager(params) {
|
|
|
11565
11565
|
}
|
|
11566
11566
|
} catch (err) {
|
|
11567
11567
|
const message = err instanceof Error ? err.message : String(err);
|
|
11568
|
-
log$
|
|
11568
|
+
log$10.warn(`qmd memory unavailable; falling back to builtin: ${message}`);
|
|
11569
11569
|
}
|
|
11570
11570
|
}
|
|
11571
11571
|
try {
|
|
@@ -11592,7 +11592,7 @@ var FallbackMemoryManager = class {
|
|
|
11592
11592
|
} catch (err) {
|
|
11593
11593
|
this.primaryFailed = true;
|
|
11594
11594
|
this.lastError = err instanceof Error ? err.message : String(err);
|
|
11595
|
-
log$
|
|
11595
|
+
log$10.warn(`qmd memory failed; switching to builtin index: ${this.lastError}`);
|
|
11596
11596
|
await this.deps.primary.close?.().catch(() => {});
|
|
11597
11597
|
this.evictCacheEntry();
|
|
11598
11598
|
}
|
|
@@ -11672,12 +11672,12 @@ var FallbackMemoryManager = class {
|
|
|
11672
11672
|
try {
|
|
11673
11673
|
fallback = await this.deps.fallbackFactory();
|
|
11674
11674
|
if (!fallback) {
|
|
11675
|
-
log$
|
|
11675
|
+
log$10.warn("memory fallback requested but builtin index is unavailable");
|
|
11676
11676
|
return null;
|
|
11677
11677
|
}
|
|
11678
11678
|
} catch (err) {
|
|
11679
11679
|
const message = err instanceof Error ? err.message : String(err);
|
|
11680
|
-
log$
|
|
11680
|
+
log$10.warn(`memory fallback unavailable: ${message}`);
|
|
11681
11681
|
return null;
|
|
11682
11682
|
}
|
|
11683
11683
|
this.fallback = fallback;
|
|
@@ -25112,7 +25112,7 @@ function createRunRegistry(options) {
|
|
|
25112
25112
|
|
|
25113
25113
|
//#endregion
|
|
25114
25114
|
//#region src/process/supervisor/supervisor.ts
|
|
25115
|
-
const log$
|
|
25115
|
+
const log$9 = createSubsystemLogger("process/supervisor");
|
|
25116
25116
|
function clampTimeout(value) {
|
|
25117
25117
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return;
|
|
25118
25118
|
return Math.max(1, Math.floor(value));
|
|
@@ -25298,7 +25298,7 @@ function createProcessSupervisor() {
|
|
|
25298
25298
|
exitCode: null,
|
|
25299
25299
|
exitSignal: null
|
|
25300
25300
|
});
|
|
25301
|
-
log$
|
|
25301
|
+
log$9.warn(`spawn failed: runId=${runId} reason=${String(err)}`);
|
|
25302
25302
|
throw err;
|
|
25303
25303
|
}
|
|
25304
25304
|
};
|
|
@@ -26597,7 +26597,7 @@ function resolveRunWorkspaceDir(params) {
|
|
|
26597
26597
|
|
|
26598
26598
|
//#endregion
|
|
26599
26599
|
//#region src/agents/cli-runner.ts
|
|
26600
|
-
const log$
|
|
26600
|
+
const log$8 = createSubsystemLogger("agent/claude-cli");
|
|
26601
26601
|
async function runCliAgent(params) {
|
|
26602
26602
|
const started = Date.now();
|
|
26603
26603
|
const workspaceResolution = resolveRunWorkspaceDir({
|
|
@@ -26610,7 +26610,7 @@ async function runCliAgent(params) {
|
|
|
26610
26610
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
26611
26611
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
26612
26612
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
26613
|
-
if (workspaceResolution.usedFallback) log$
|
|
26613
|
+
if (workspaceResolution.usedFallback) log$8.warn(`[workspace-fallback] caller=runCliAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
|
|
26614
26614
|
const workspaceDir = resolvedWorkspace;
|
|
26615
26615
|
const backendResolved = resolveCliBackendConfig(params.provider, params.config);
|
|
26616
26616
|
if (!backendResolved) throw new Error(`Unknown CLI backend: ${params.provider}`);
|
|
@@ -26627,7 +26627,7 @@ async function runCliAgent(params) {
|
|
|
26627
26627
|
sessionId: params.sessionId,
|
|
26628
26628
|
warn: makeBootstrapWarn({
|
|
26629
26629
|
sessionLabel,
|
|
26630
|
-
warn: (message) => log$
|
|
26630
|
+
warn: (message) => log$8.warn(message)
|
|
26631
26631
|
})
|
|
26632
26632
|
});
|
|
26633
26633
|
const { defaultAgentId, sessionAgentId } = resolveSessionAgentIds({
|
|
@@ -26693,7 +26693,7 @@ async function runCliAgent(params) {
|
|
|
26693
26693
|
const queueKey = backend.serialize ?? true ? backendResolved.id : `${backendResolved.id}:${params.runId}`;
|
|
26694
26694
|
try {
|
|
26695
26695
|
const output = await enqueueCliRun(queueKey, async () => {
|
|
26696
|
-
log$
|
|
26696
|
+
log$8.info(`cli exec: provider=${params.provider} model=${normalizedModel} promptChars=${params.prompt.length}`);
|
|
26697
26697
|
const logOutputText = isTruthyEnvValue(process.env.SYMI_CLAUDE_CLI_LOG_OUTPUT);
|
|
26698
26698
|
if (logOutputText) {
|
|
26699
26699
|
const logArgs = [];
|
|
@@ -26726,7 +26726,7 @@ async function runCliAgent(params) {
|
|
|
26726
26726
|
const promptIndex = logArgs.indexOf(argsPrompt);
|
|
26727
26727
|
if (promptIndex >= 0) logArgs[promptIndex] = `<prompt:${argsPrompt.length} chars>`;
|
|
26728
26728
|
}
|
|
26729
|
-
log$
|
|
26729
|
+
log$8.info(`cli argv: ${backend.command} ${logArgs.join(" ")}`);
|
|
26730
26730
|
}
|
|
26731
26731
|
const env = (() => {
|
|
26732
26732
|
const next = {
|
|
@@ -26764,17 +26764,17 @@ async function runCliAgent(params) {
|
|
|
26764
26764
|
const stdout = result.stdout.trim();
|
|
26765
26765
|
const stderr = result.stderr.trim();
|
|
26766
26766
|
if (logOutputText) {
|
|
26767
|
-
if (stdout) log$
|
|
26768
|
-
if (stderr) log$
|
|
26767
|
+
if (stdout) log$8.info(`cli stdout:\n${stdout}`);
|
|
26768
|
+
if (stderr) log$8.info(`cli stderr:\n${stderr}`);
|
|
26769
26769
|
}
|
|
26770
26770
|
if (shouldLogVerbose()) {
|
|
26771
|
-
if (stdout) log$
|
|
26772
|
-
if (stderr) log$
|
|
26771
|
+
if (stdout) log$8.debug(`cli stdout:\n${stdout}`);
|
|
26772
|
+
if (stderr) log$8.debug(`cli stderr:\n${stderr}`);
|
|
26773
26773
|
}
|
|
26774
26774
|
if (result.exitCode !== 0 || result.reason !== "exit") {
|
|
26775
26775
|
if (result.reason === "no-output-timeout" || result.noOutputTimedOut) {
|
|
26776
26776
|
const timeoutReason = `CLI produced no output for ${Math.round(noOutputTimeoutMs / 1e3)}s and was terminated.`;
|
|
26777
|
-
log$
|
|
26777
|
+
log$8.warn(`cli watchdog timeout: provider=${params.provider} model=${modelId} session=${cliSessionIdToSend ?? params.sessionId} noOutputTimeoutMs=${noOutputTimeoutMs} pid=${managedRun.pid ?? "unknown"}`);
|
|
26778
26778
|
throw new FailoverError(timeoutReason, {
|
|
26779
26779
|
reason: "timeout",
|
|
26780
26780
|
provider: params.provider,
|
|
@@ -27404,7 +27404,7 @@ function resolveEmbeddedSessionLane(key) {
|
|
|
27404
27404
|
|
|
27405
27405
|
//#endregion
|
|
27406
27406
|
//#region src/agents/pi-embedded-runner/logger.ts
|
|
27407
|
-
const log$
|
|
27407
|
+
const log$7 = createSubsystemLogger("agent/embedded");
|
|
27408
27408
|
|
|
27409
27409
|
//#endregion
|
|
27410
27410
|
//#region src/utils/safe-json.ts
|
|
@@ -27450,7 +27450,7 @@ function getQueuedFileWriter(writers, filePath) {
|
|
|
27450
27450
|
//#endregion
|
|
27451
27451
|
//#region src/agents/anthropic-payload-log.ts
|
|
27452
27452
|
const writers$1 = /* @__PURE__ */ new Map();
|
|
27453
|
-
const log$
|
|
27453
|
+
const log$6 = createSubsystemLogger("agent/anthropic-payload");
|
|
27454
27454
|
function resolvePayloadLogConfig(env) {
|
|
27455
27455
|
const enabled = parseBooleanValue$1(env.SYMI_ANTHROPIC_PAYLOAD_LOG) ?? false;
|
|
27456
27456
|
const fileOverride = env.SYMI_ANTHROPIC_PAYLOAD_LOG_FILE?.trim();
|
|
@@ -27540,13 +27540,13 @@ function createAnthropicPayloadLogger(params) {
|
|
|
27540
27540
|
usage,
|
|
27541
27541
|
error: errorMessage
|
|
27542
27542
|
});
|
|
27543
|
-
log$
|
|
27543
|
+
log$6.info("anthropic usage", {
|
|
27544
27544
|
runId: params.runId,
|
|
27545
27545
|
sessionId: params.sessionId,
|
|
27546
27546
|
usage
|
|
27547
27547
|
});
|
|
27548
27548
|
};
|
|
27549
|
-
log$
|
|
27549
|
+
log$6.info("anthropic payload logger enabled", { filePath: writer.filePath });
|
|
27550
27550
|
return {
|
|
27551
27551
|
enabled: true,
|
|
27552
27552
|
wrapStreamFn,
|
|
@@ -29428,7 +29428,7 @@ function createEmbeddedPiSessionEventHandler(ctx) {
|
|
|
29428
29428
|
//#region src/agents/pi-embedded-subscribe.ts
|
|
29429
29429
|
const THINKING_TAG_SCAN_RE = /<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\s*>/gi;
|
|
29430
29430
|
const FINAL_TAG_SCAN_RE = /<\s*(\/?)\s*final\s*>/gi;
|
|
29431
|
-
const log$
|
|
29431
|
+
const log$5 = createSubsystemLogger("agent/embedded");
|
|
29432
29432
|
function subscribeEmbeddedPiSession(params) {
|
|
29433
29433
|
const reasoningMode = params.reasoningMode ?? "off";
|
|
29434
29434
|
const useMarkdown = (params.toolResultFormat ?? "markdown") === "markdown";
|
|
@@ -29585,7 +29585,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
29585
29585
|
state.compactionRetryReject = reject;
|
|
29586
29586
|
});
|
|
29587
29587
|
state.compactionRetryPromise.catch((err) => {
|
|
29588
|
-
log$
|
|
29588
|
+
log$5.debug(`compaction promise rejected (no waiter): ${String(err)}`);
|
|
29589
29589
|
});
|
|
29590
29590
|
}
|
|
29591
29591
|
};
|
|
@@ -29737,7 +29737,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
29737
29737
|
if (!chunk) return;
|
|
29738
29738
|
if (chunk === state.lastBlockReplyText) return;
|
|
29739
29739
|
if (isMessagingToolDuplicateNormalized(normalizeTextForComparison(chunk), messagingToolSentTextsNormalized)) {
|
|
29740
|
-
log$
|
|
29740
|
+
log$5.debug(`Skipping block reply - already sent via messaging tool: ${chunk.slice(0, 50)}...`);
|
|
29741
29741
|
return;
|
|
29742
29742
|
}
|
|
29743
29743
|
if (shouldSkipAssistantText(chunk)) return;
|
|
@@ -29815,7 +29815,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
29815
29815
|
const ctx = {
|
|
29816
29816
|
params,
|
|
29817
29817
|
state,
|
|
29818
|
-
log: log$
|
|
29818
|
+
log: log$5,
|
|
29819
29819
|
blockChunking,
|
|
29820
29820
|
blockChunker,
|
|
29821
29821
|
hookRunner: params.hookRunner,
|
|
@@ -29848,7 +29848,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
29848
29848
|
if (state.unsubscribed) return;
|
|
29849
29849
|
state.unsubscribed = true;
|
|
29850
29850
|
if (state.compactionRetryPromise) {
|
|
29851
|
-
log$
|
|
29851
|
+
log$5.debug(`unsubscribe: rejecting compaction wait runId=${params.runId}`);
|
|
29852
29852
|
const reject = state.compactionRetryReject;
|
|
29853
29853
|
state.compactionRetryResolve = void 0;
|
|
29854
29854
|
state.compactionRetryReject = void 0;
|
|
@@ -29858,11 +29858,11 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
29858
29858
|
reject?.(abortErr);
|
|
29859
29859
|
}
|
|
29860
29860
|
if (params.session.isCompacting) {
|
|
29861
|
-
log$
|
|
29861
|
+
log$5.debug(`unsubscribe: aborting in-flight compaction runId=${params.runId}`);
|
|
29862
29862
|
try {
|
|
29863
29863
|
params.session.abortCompaction();
|
|
29864
29864
|
} catch (err) {
|
|
29865
|
-
log$
|
|
29865
|
+
log$5.warn(`unsubscribe: compaction abort failed runId=${params.runId} err=${String(err)}`);
|
|
29866
29866
|
}
|
|
29867
29867
|
}
|
|
29868
29868
|
sessionUnsubscribe();
|
|
@@ -29911,7 +29911,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
29911
29911
|
|
|
29912
29912
|
//#endregion
|
|
29913
29913
|
//#region src/agents/pi-tools.before-tool-call.ts
|
|
29914
|
-
const log$
|
|
29914
|
+
const log$4 = createSubsystemLogger("agents/tools");
|
|
29915
29915
|
const BEFORE_TOOL_CALL_WRAPPED = Symbol("beforeToolCallWrapped");
|
|
29916
29916
|
const adjustedParamsByToolCallId = /* @__PURE__ */ new Map();
|
|
29917
29917
|
const MAX_TRACKED_ADJUSTED_PARAMS = 1024;
|
|
@@ -29945,7 +29945,7 @@ async function recordLoopOutcome(args) {
|
|
|
29945
29945
|
config: args.ctx.loopDetection
|
|
29946
29946
|
});
|
|
29947
29947
|
} catch (err) {
|
|
29948
|
-
log$
|
|
29948
|
+
log$4.warn(`tool loop outcome tracking failed: tool=${args.toolName} error=${String(err)}`);
|
|
29949
29949
|
}
|
|
29950
29950
|
}
|
|
29951
29951
|
async function runBeforeToolCallHook(args) {
|
|
@@ -29962,7 +29962,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
29962
29962
|
const loopResult = detectToolCallLoop(sessionState, toolName, params, args.ctx.loopDetection);
|
|
29963
29963
|
if (loopResult.stuck) {
|
|
29964
29964
|
if (loopResult.level === "critical") {
|
|
29965
|
-
log$
|
|
29965
|
+
log$4.error(`Blocking ${toolName} due to critical loop: ${loopResult.message}`);
|
|
29966
29966
|
logToolLoopAction({
|
|
29967
29967
|
sessionKey: args.ctx.sessionKey,
|
|
29968
29968
|
sessionId: args.ctx?.agentId,
|
|
@@ -29979,7 +29979,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
29979
29979
|
reason: loopResult.message
|
|
29980
29980
|
};
|
|
29981
29981
|
} else if (shouldEmitLoopWarning(sessionState, loopResult.warningKey ?? `${loopResult.detector}:${toolName}`, loopResult.count)) {
|
|
29982
|
-
log$
|
|
29982
|
+
log$4.warn(`Loop warning for ${toolName}: ${loopResult.message}`);
|
|
29983
29983
|
logToolLoopAction({
|
|
29984
29984
|
sessionKey: args.ctx.sessionKey,
|
|
29985
29985
|
sessionId: args.ctx?.agentId,
|
|
@@ -30029,7 +30029,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
30029
30029
|
}
|
|
30030
30030
|
} catch (err) {
|
|
30031
30031
|
const toolCallId = args.toolCallId ? ` toolCallId=${args.toolCallId}` : "";
|
|
30032
|
-
log$
|
|
30032
|
+
log$4.warn(`before_tool_call hook failed: tool=${toolName}${toolCallId} error=${String(err)}`);
|
|
30033
30033
|
}
|
|
30034
30034
|
return {
|
|
30035
30035
|
blocked: false,
|
|
@@ -30273,10 +30273,27 @@ function validateShellCommand(command) {
|
|
|
30273
30273
|
|
|
30274
30274
|
//#endregion
|
|
30275
30275
|
//#region src/agents/pi-tools.validate-wrapper.ts
|
|
30276
|
+
const log$3 = createSubsystemLogger("agents/tool-validate");
|
|
30276
30277
|
const EXEC_TOOL_NAMES = new Set(["exec", "bash"]);
|
|
30278
|
+
const FILE_TOOL_NAMES = new Set([
|
|
30279
|
+
"write",
|
|
30280
|
+
"read",
|
|
30281
|
+
"edit",
|
|
30282
|
+
"patch",
|
|
30283
|
+
"file_write",
|
|
30284
|
+
"file_edit",
|
|
30285
|
+
"write_file",
|
|
30286
|
+
"edit_file",
|
|
30287
|
+
"create_file"
|
|
30288
|
+
]);
|
|
30289
|
+
const FILE_PATH_KEYS = [
|
|
30290
|
+
"file_path",
|
|
30291
|
+
"path",
|
|
30292
|
+
"filePath"
|
|
30293
|
+
];
|
|
30277
30294
|
/**
|
|
30278
|
-
* Wrap tools with argument validation.
|
|
30279
|
-
* Other tools pass through unchanged.
|
|
30295
|
+
* Wrap tools with argument validation. Exec/bash commands and file paths
|
|
30296
|
+
* are validated. Other tools pass through unchanged.
|
|
30280
30297
|
*
|
|
30281
30298
|
* Call this AFTER tools are created and the model profile is resolved.
|
|
30282
30299
|
*/
|
|
@@ -30285,24 +30302,64 @@ function wrapToolsWithArgValidation(tools, profile) {
|
|
|
30285
30302
|
return tools.map((tool) => wrapToolWithArgValidation(tool));
|
|
30286
30303
|
}
|
|
30287
30304
|
/**
|
|
30288
|
-
*
|
|
30305
|
+
* Clean a file path by stripping control token fragments.
|
|
30306
|
+
* Returns null if the path is irreparably corrupted (empty after cleanup).
|
|
30307
|
+
*/
|
|
30308
|
+
function cleanFilePath(filePath) {
|
|
30309
|
+
let cleaned = filePath.replace(/<\|[^|>]*(?:\|>)?/g, "");
|
|
30310
|
+
cleaned = cleanResidualTokenFragments(cleaned);
|
|
30311
|
+
cleaned = cleaned.trim();
|
|
30312
|
+
if (!cleaned || !/[a-zA-Z0-9/._~-]/.test(cleaned)) return {
|
|
30313
|
+
valid: false,
|
|
30314
|
+
cleaned
|
|
30315
|
+
};
|
|
30316
|
+
return {
|
|
30317
|
+
valid: true,
|
|
30318
|
+
cleaned
|
|
30319
|
+
};
|
|
30320
|
+
}
|
|
30321
|
+
/**
|
|
30322
|
+
* Wrap a single tool with argument validation.
|
|
30289
30323
|
*/
|
|
30290
30324
|
function wrapToolWithArgValidation(tool) {
|
|
30291
30325
|
const toolName = (tool.name ?? "").toLowerCase().trim();
|
|
30292
|
-
|
|
30326
|
+
const isExecTool = EXEC_TOOL_NAMES.has(toolName);
|
|
30327
|
+
const isFileTool = FILE_TOOL_NAMES.has(toolName);
|
|
30328
|
+
if (!isExecTool && !isFileTool) return tool;
|
|
30293
30329
|
const originalExecute = tool.execute;
|
|
30294
30330
|
return {
|
|
30295
30331
|
...tool,
|
|
30296
30332
|
execute(toolCallId, params, ...rest) {
|
|
30297
|
-
|
|
30298
|
-
|
|
30299
|
-
|
|
30300
|
-
|
|
30301
|
-
|
|
30333
|
+
if (isExecTool) {
|
|
30334
|
+
const command = params.command ?? params.cmd;
|
|
30335
|
+
if (typeof command !== "string") {
|
|
30336
|
+
log$3.debug(`[validate] exec called without string command: keys=${Object.keys(params).join(",")}`);
|
|
30337
|
+
return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
30338
|
+
}
|
|
30339
|
+
const result = validateShellCommand(command);
|
|
30340
|
+
if (!result.valid) {
|
|
30341
|
+
log$3.warn(`[validate] exec command rejected: reason=${result.reason} raw=${command.slice(0, 100)}`);
|
|
30342
|
+
return Promise.resolve({ output: `Error: ${result.reason}. The command appears to contain model control tokens. Please provide a clean shell command without any <|, |>, or XML-like tags. Only valid shell syntax is accepted.` });
|
|
30343
|
+
}
|
|
30344
|
+
if (result.cleaned !== command) {
|
|
30345
|
+
log$3.debug(`[validate] exec command cleaned: raw=${command.slice(0, 80)} → cleaned=${result.cleaned.slice(0, 80)}`);
|
|
30346
|
+
return originalExecute.call(tool, toolCallId, {
|
|
30347
|
+
...params,
|
|
30348
|
+
command: result.cleaned
|
|
30349
|
+
}, ...rest);
|
|
30350
|
+
}
|
|
30351
|
+
return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
30352
|
+
}
|
|
30353
|
+
const pathKey = FILE_PATH_KEYS.find((k) => typeof params[k] === "string");
|
|
30354
|
+
if (!pathKey) return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
30355
|
+
const rawPath = params[pathKey];
|
|
30356
|
+
if (!rawPath.includes("<|") && !rawPath.includes("|>") && !/^[<"|]/.test(rawPath)) return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
30357
|
+
const pathResult = cleanFilePath(rawPath);
|
|
30358
|
+
if (!pathResult.valid) return Promise.resolve({ output: `Error: file path "${rawPath}" contains model control tokens and could not be cleaned. Please provide a clean file path without any <|, |>, or XML-like tags.` });
|
|
30359
|
+
return originalExecute.call(tool, toolCallId, {
|
|
30302
30360
|
...params,
|
|
30303
|
-
|
|
30361
|
+
[pathKey]: pathResult.cleaned
|
|
30304
30362
|
}, ...rest);
|
|
30305
|
-
return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
30306
30363
|
}
|
|
30307
30364
|
};
|
|
30308
30365
|
}
|
|
@@ -30661,7 +30718,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
30661
30718
|
const textLength = getToolResultTextLength(msg);
|
|
30662
30719
|
if (textLength > maxChars) {
|
|
30663
30720
|
oversizedIndices.push(i);
|
|
30664
|
-
log$
|
|
30721
|
+
log$7.info(`[tool-result-truncation] Found oversized tool result: entry=${entry.id} chars=${textLength} maxChars=${maxChars} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
30665
30722
|
}
|
|
30666
30723
|
}
|
|
30667
30724
|
if (oversizedIndices.length === 0) return {
|
|
@@ -30683,7 +30740,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
30683
30740
|
message = truncateToolResultMessage(message, maxChars);
|
|
30684
30741
|
truncatedCount++;
|
|
30685
30742
|
const newLength = getToolResultTextLength(message);
|
|
30686
|
-
log$
|
|
30743
|
+
log$7.info(`[tool-result-truncation] Truncated tool result: originalEntry=${entry.id} newChars=${newLength} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
30687
30744
|
}
|
|
30688
30745
|
sessionManager.appendMessage(message);
|
|
30689
30746
|
} else if (entry.type === "compaction") sessionManager.appendCompaction(entry.summary, entry.firstKeptEntryId, entry.tokensBefore, entry.details, entry.fromHook);
|
|
@@ -30697,14 +30754,14 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
30697
30754
|
if (entry.name) sessionManager.appendSessionInfo(entry.name);
|
|
30698
30755
|
}
|
|
30699
30756
|
}
|
|
30700
|
-
log$
|
|
30757
|
+
log$7.info(`[tool-result-truncation] Truncated ${truncatedCount} tool result(s) in session (contextWindow=${contextWindowTokens} maxChars=${maxChars}) sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
30701
30758
|
return {
|
|
30702
30759
|
truncated: true,
|
|
30703
30760
|
truncatedCount
|
|
30704
30761
|
};
|
|
30705
30762
|
} catch (err) {
|
|
30706
30763
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
30707
|
-
log$
|
|
30764
|
+
log$7.warn(`[tool-result-truncation] Failed to truncate: ${errMsg}`);
|
|
30708
30765
|
return {
|
|
30709
30766
|
truncated: false,
|
|
30710
30767
|
truncatedCount: 0,
|
|
@@ -32480,7 +32537,7 @@ function resolveAnthropicBetas(extraParams, provider, modelId) {
|
|
|
32480
32537
|
for (const beta of configured) if (typeof beta === "string" && beta.trim()) betas.add(beta.trim());
|
|
32481
32538
|
}
|
|
32482
32539
|
if (extraParams?.context1m === true) if (isAnthropic1MModel(modelId)) betas.add(ANTHROPIC_CONTEXT_1M_BETA);
|
|
32483
|
-
else log$
|
|
32540
|
+
else log$7.warn(`ignoring context1m for non-opus/sonnet model: ${provider}/${modelId}`);
|
|
32484
32541
|
return betas.size > 0 ? [...betas] : void 0;
|
|
32485
32542
|
}
|
|
32486
32543
|
function mergeAnthropicBetaHeader(headers, betas) {
|
|
@@ -33091,14 +33148,14 @@ function logToolSchemasForGoogle(params) {
|
|
|
33091
33148
|
if (params.provider !== "google-antigravity" && params.provider !== "google-gemini-cli") return;
|
|
33092
33149
|
const toolNames = params.tools.map((tool, index) => `${index}:${tool.name}`);
|
|
33093
33150
|
const tools = sanitizeToolsForGoogle(params);
|
|
33094
|
-
log$
|
|
33151
|
+
log$7.info("google tool schema snapshot", {
|
|
33095
33152
|
provider: params.provider,
|
|
33096
33153
|
toolCount: tools.length,
|
|
33097
33154
|
tools: toolNames
|
|
33098
33155
|
});
|
|
33099
33156
|
for (const [index, tool] of tools.entries()) {
|
|
33100
33157
|
const violations = findUnsupportedSchemaKeywords(tool.parameters, `${tool.name}.parameters`);
|
|
33101
|
-
if (violations.length > 0) log$
|
|
33158
|
+
if (violations.length > 0) log$7.warn("google tool schema has unsupported keywords", {
|
|
33102
33159
|
index,
|
|
33103
33160
|
tool: tool.name,
|
|
33104
33161
|
violations: violations.slice(0, 12),
|
|
@@ -33110,7 +33167,7 @@ const compactionFailureEmitter = new EventEmitter();
|
|
|
33110
33167
|
registerUnhandledRejectionHandler((reason) => {
|
|
33111
33168
|
const message = describeUnknownError(reason);
|
|
33112
33169
|
if (!isCompactionFailureError(message)) return false;
|
|
33113
|
-
log$
|
|
33170
|
+
log$7.error(`Auto-compaction failed (unhandled): ${message}`);
|
|
33114
33171
|
compactionFailureEmitter.emit("failure", message);
|
|
33115
33172
|
return true;
|
|
33116
33173
|
});
|
|
@@ -33162,7 +33219,7 @@ function applyGoogleTurnOrderingFix(params) {
|
|
|
33162
33219
|
const sanitized = sanitizeGoogleTurnOrdering(params.messages);
|
|
33163
33220
|
const didPrepend = sanitized !== params.messages;
|
|
33164
33221
|
if (didPrepend && !hasGoogleTurnOrderingMarker(params.sessionManager)) {
|
|
33165
|
-
(params.warn ?? ((message) => log$
|
|
33222
|
+
(params.warn ?? ((message) => log$7.warn(message)))(`google turn ordering fixup: prepended user bootstrap (sessionId=${params.sessionId})`);
|
|
33166
33223
|
markGoogleTurnOrderingMarker(params.sessionManager);
|
|
33167
33224
|
}
|
|
33168
33225
|
return {
|
|
@@ -33782,7 +33839,7 @@ function isImageExtension(filePath) {
|
|
|
33782
33839
|
}
|
|
33783
33840
|
async function sanitizeImagesWithLog(images, label, imageSanitization) {
|
|
33784
33841
|
const { images: sanitized, dropped } = await sanitizeImageBlocks(images, label, imageSanitization);
|
|
33785
|
-
if (dropped > 0) log$
|
|
33842
|
+
if (dropped > 0) log$7.warn(`Native image: dropped ${dropped} image(s) after sanitization (${label}).`);
|
|
33786
33843
|
return sanitized;
|
|
33787
33844
|
}
|
|
33788
33845
|
/**
|
|
@@ -33857,7 +33914,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
33857
33914
|
try {
|
|
33858
33915
|
let targetPath = ref.resolved;
|
|
33859
33916
|
if (ref.type === "url") {
|
|
33860
|
-
log$
|
|
33917
|
+
log$7.debug(`Native image: rejecting remote URL (local-only): ${ref.resolved}`);
|
|
33861
33918
|
return null;
|
|
33862
33919
|
}
|
|
33863
33920
|
if (ref.type === "path") {
|
|
@@ -33867,7 +33924,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
33867
33924
|
cwd: options.sandbox.root
|
|
33868
33925
|
}).hostPath;
|
|
33869
33926
|
} catch (err) {
|
|
33870
|
-
log$
|
|
33927
|
+
log$7.debug(`Native image: sandbox validation failed for ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
33871
33928
|
return null;
|
|
33872
33929
|
}
|
|
33873
33930
|
else if (!path.isAbsolute(targetPath)) targetPath = path.resolve(workspaceDir, targetPath);
|
|
@@ -33881,7 +33938,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
33881
33938
|
})
|
|
33882
33939
|
}) : await loadWebMedia(targetPath, options?.maxBytes);
|
|
33883
33940
|
if (media.kind !== "image") {
|
|
33884
|
-
log$
|
|
33941
|
+
log$7.debug(`Native image: not an image file: ${targetPath} (got ${media.kind})`);
|
|
33885
33942
|
return null;
|
|
33886
33943
|
}
|
|
33887
33944
|
const mimeType = media.contentType ?? "image/jpeg";
|
|
@@ -33891,7 +33948,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
33891
33948
|
mimeType
|
|
33892
33949
|
};
|
|
33893
33950
|
} catch (err) {
|
|
33894
|
-
log$
|
|
33951
|
+
log$7.debug(`Native image: failed to load ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
33895
33952
|
return null;
|
|
33896
33953
|
}
|
|
33897
33954
|
}
|
|
@@ -33990,7 +34047,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
33990
34047
|
loadedCount: 0,
|
|
33991
34048
|
skippedCount: 0
|
|
33992
34049
|
};
|
|
33993
|
-
log$
|
|
34050
|
+
log$7.debug(`Native image: detected ${allRefs.length} image refs (${promptRefs.length} in prompt, ${uniqueHistoryRefs.length} in history)`);
|
|
33994
34051
|
const promptImages = [...params.existingImages ?? []];
|
|
33995
34052
|
const historyImagesByIndex = /* @__PURE__ */ new Map();
|
|
33996
34053
|
let loadedCount = 0;
|
|
@@ -34007,7 +34064,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
34007
34064
|
else historyImagesByIndex.set(ref.messageIndex, [image]);
|
|
34008
34065
|
} else promptImages.push(image);
|
|
34009
34066
|
loadedCount++;
|
|
34010
|
-
log$
|
|
34067
|
+
log$7.debug(`Native image: loaded ${ref.type} ${ref.resolved}`);
|
|
34011
34068
|
} else skippedCount++;
|
|
34012
34069
|
}
|
|
34013
34070
|
const imageSanitization = { maxDimensionPx: params.maxDimensionPx };
|
|
@@ -34103,7 +34160,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34103
34160
|
const resolvedWorkspace = resolveUserPath(params.workspaceDir);
|
|
34104
34161
|
const prevCwd = process.cwd();
|
|
34105
34162
|
const runAbortController = new AbortController();
|
|
34106
|
-
log$
|
|
34163
|
+
log$7.debug(`embedded run start: runId=${params.runId} sessionId=${params.sessionId} provider=${params.provider} model=${params.modelId} thinking=${params.thinkLevel} messageChannel=${params.messageChannel ?? params.messageProvider ?? "unknown"}`);
|
|
34107
34164
|
await fs$1.mkdir(resolvedWorkspace, { recursive: true });
|
|
34108
34165
|
const sandboxSessionKey = params.sessionKey?.trim() || params.sessionId;
|
|
34109
34166
|
const sandbox = await resolveSandboxContext({
|
|
@@ -34139,7 +34196,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34139
34196
|
sessionId: params.sessionId,
|
|
34140
34197
|
warn: makeBootstrapWarn({
|
|
34141
34198
|
sessionLabel,
|
|
34142
|
-
warn: (message) => log$
|
|
34199
|
+
warn: (message) => log$7.warn(message)
|
|
34143
34200
|
})
|
|
34144
34201
|
});
|
|
34145
34202
|
const workspaceNotes = hookAdjustedBootstrapFiles.some((file) => file.name === DEFAULT_BOOTSTRAP_FILENAME && !file.missing) ? ["Reminder: commit your changes in this workspace after edits."] : void 0;
|
|
@@ -34338,7 +34395,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34338
34395
|
try {
|
|
34339
34396
|
await repairSessionFileIfNeeded({
|
|
34340
34397
|
sessionFile: params.sessionFile,
|
|
34341
|
-
warn: (message) => log$
|
|
34398
|
+
warn: (message) => log$7.warn(message)
|
|
34342
34399
|
});
|
|
34343
34400
|
const hadSessionFile = await fs$1.stat(params.sessionFile).then(() => true).catch(() => false);
|
|
34344
34401
|
const transcriptPolicy = resolveTranscriptPolicy({
|
|
@@ -34347,7 +34404,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34347
34404
|
modelId: params.modelId
|
|
34348
34405
|
});
|
|
34349
34406
|
const versionCheck = await handleSessionVersion(params.sessionFile);
|
|
34350
|
-
if (versionCheck.archived) log$
|
|
34407
|
+
if (versionCheck.archived) log$7.warn(`session archived: created by ${versionCheck.poisonVersion}, known corruption range → ${versionCheck.archivePath}`);
|
|
34351
34408
|
await prewarmSessionFile(params.sessionFile);
|
|
34352
34409
|
sessionManager = guardSessionManager(SessionManager.open(params.sessionFile), {
|
|
34353
34410
|
agentId: sessionAgentId,
|
|
@@ -34599,6 +34656,9 @@ async function runEmbeddedAttempt(params) {
|
|
|
34599
34656
|
});
|
|
34600
34657
|
};
|
|
34601
34658
|
const streamMonitor = createStreamMonitor(modelProfile);
|
|
34659
|
+
const TOOL_ERROR_ABORT_THRESHOLD = 5;
|
|
34660
|
+
const TOOL_ERROR_WARN_THRESHOLD = 3;
|
|
34661
|
+
let consecutiveToolErrors = 0;
|
|
34602
34662
|
const subscription = subscribeEmbeddedPiSession({
|
|
34603
34663
|
session: activeSession,
|
|
34604
34664
|
runId: params.runId,
|
|
@@ -34620,9 +34680,25 @@ async function runEmbeddedAttempt(params) {
|
|
|
34620
34680
|
onAgentEvent: (evt) => {
|
|
34621
34681
|
armSymipulseTimer();
|
|
34622
34682
|
params.onAgentEvent?.(evt);
|
|
34683
|
+
if (evt.stream === "tool" && !aborted) {
|
|
34684
|
+
const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
|
|
34685
|
+
const isError = evt.data?.isError === true;
|
|
34686
|
+
if (phase === "result") {
|
|
34687
|
+
if (isError) consecutiveToolErrors++;
|
|
34688
|
+
else consecutiveToolErrors = 0;
|
|
34689
|
+
if (consecutiveToolErrors >= TOOL_ERROR_ABORT_THRESHOLD) {
|
|
34690
|
+
const toolName = typeof evt.data?.name === "string" ? evt.data.name : "unknown";
|
|
34691
|
+
log$7.error(`Agent-loop circuit breaker: ${consecutiveToolErrors} consecutive tool errors (last: ${toolName}). Aborting run ${params.runId}.`);
|
|
34692
|
+
abortRun(false, /* @__PURE__ */ new Error(`${consecutiveToolErrors} consecutive tool errors. The model may be generating corrupted tool arguments. Run aborted to prevent infinite loop.`));
|
|
34693
|
+
} else if (consecutiveToolErrors === TOOL_ERROR_WARN_THRESHOLD) {
|
|
34694
|
+
const toolName = typeof evt.data?.name === "string" ? evt.data.name : "unknown";
|
|
34695
|
+
log$7.warn(`Agent-loop tool error warning: ${consecutiveToolErrors} consecutive failures (last: ${toolName}). runId=${params.runId}`);
|
|
34696
|
+
}
|
|
34697
|
+
}
|
|
34698
|
+
}
|
|
34623
34699
|
if (evt.stream === "assistant" && typeof evt.data?.text === "string" && !aborted) {
|
|
34624
34700
|
streamMonitor.onChunk(evt.data.text);
|
|
34625
|
-
if (streamMonitor.shouldStop()) log$
|
|
34701
|
+
if (streamMonitor.shouldStop()) log$7.debug(`stream monitor detection (log-only, no abort): runId=${params.runId} reason=${streamMonitor.getStopReason()}`);
|
|
34626
34702
|
}
|
|
34627
34703
|
},
|
|
34628
34704
|
enforceFinalTag: params.enforceFinalTag,
|
|
@@ -34642,7 +34718,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34642
34718
|
let abortWarnTimer;
|
|
34643
34719
|
const isProbeSession = params.sessionId?.startsWith("probe-") ?? false;
|
|
34644
34720
|
const abortTimer = setTimeout(() => {
|
|
34645
|
-
if (!isProbeSession) log$
|
|
34721
|
+
if (!isProbeSession) log$7.warn(`embedded run timeout: runId=${params.runId} sessionId=${params.sessionId} timeoutMs=${params.timeoutMs}`);
|
|
34646
34722
|
if (shouldFlagCompactionTimeout({
|
|
34647
34723
|
isTimeout: true,
|
|
34648
34724
|
isCompactionPendingOrRetrying: subscription.isCompacting(),
|
|
@@ -34651,7 +34727,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34651
34727
|
abortRun(true);
|
|
34652
34728
|
if (!abortWarnTimer) abortWarnTimer = setTimeout(() => {
|
|
34653
34729
|
if (!activeSession.isStreaming) return;
|
|
34654
|
-
if (!isProbeSession) log$
|
|
34730
|
+
if (!isProbeSession) log$7.warn(`embedded run abort still streaming: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
34655
34731
|
}, 1e4);
|
|
34656
34732
|
}, Math.max(1, params.timeoutMs));
|
|
34657
34733
|
armSymipulseTimer = () => {
|
|
@@ -34659,7 +34735,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34659
34735
|
clearSymipulseTimer();
|
|
34660
34736
|
symipulseTimer = setTimeout(() => {
|
|
34661
34737
|
if (aborted) return;
|
|
34662
|
-
if (!isProbeSession) log$
|
|
34738
|
+
if (!isProbeSession) log$7.warn(`symipulse timeout: runId=${params.runId} sessionId=${params.sessionId} symipulseMs=${symipulseMs} (no activity)`);
|
|
34663
34739
|
if (shouldFlagCompactionTimeout({
|
|
34664
34740
|
isTimeout: true,
|
|
34665
34741
|
isCompactionPendingOrRetrying: subscription.isCompacting(),
|
|
@@ -34703,13 +34779,13 @@ async function runEmbeddedAttempt(params) {
|
|
|
34703
34779
|
prompt: params.prompt,
|
|
34704
34780
|
messages: activeSession.messages
|
|
34705
34781
|
}, hookCtx).catch((hookErr) => {
|
|
34706
|
-
log$
|
|
34782
|
+
log$7.warn(`before_prompt_build hook failed: ${String(hookErr)}`);
|
|
34707
34783
|
}) : void 0;
|
|
34708
34784
|
const legacyResult = hookRunner?.hasHooks("before_agent_start") ? await hookRunner.runBeforeAgentStart({
|
|
34709
34785
|
prompt: params.prompt,
|
|
34710
34786
|
messages: activeSession.messages
|
|
34711
34787
|
}, hookCtx).catch((hookErr) => {
|
|
34712
|
-
log$
|
|
34788
|
+
log$7.warn(`before_agent_start hook (legacy prompt build path) failed: ${String(hookErr)}`);
|
|
34713
34789
|
}) : void 0;
|
|
34714
34790
|
const hookResult = {
|
|
34715
34791
|
systemPrompt: promptBuildResult?.systemPrompt ?? legacyResult?.systemPrompt,
|
|
@@ -34717,7 +34793,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34717
34793
|
};
|
|
34718
34794
|
if (hookResult?.prependContext) {
|
|
34719
34795
|
effectivePrompt = `${hookResult.prependContext}\n\n${params.prompt}`;
|
|
34720
|
-
log$
|
|
34796
|
+
log$7.debug(`hooks: prepended context to prompt (${hookResult.prependContext.length} chars)`);
|
|
34721
34797
|
}
|
|
34722
34798
|
{
|
|
34723
34799
|
const autoRecallAgentId = normalizeAgentId(params.sessionKey);
|
|
@@ -34734,11 +34810,11 @@ async function runEmbeddedAttempt(params) {
|
|
|
34734
34810
|
if (recallResults.length > 0) {
|
|
34735
34811
|
const recallBlock = `<memory_context>\nThe following memory snippets were automatically retrieved as relevant context:\n\n${recallResults.map((r) => `[${r.path}#L${r.startLine}-L${r.endLine}]\n${r.snippet}`).join("\n---\n")}\n</memory_context>`;
|
|
34736
34812
|
effectivePrompt = `${recallBlock}\n\n${effectivePrompt}`;
|
|
34737
|
-
log$
|
|
34813
|
+
log$7.debug(`auto-recall: injected ${recallResults.length} snippets (${recallBlock.length} chars)`);
|
|
34738
34814
|
}
|
|
34739
34815
|
}
|
|
34740
34816
|
} catch (recallErr) {
|
|
34741
|
-
log$
|
|
34817
|
+
log$7.debug(`auto-recall: skipped (${String(recallErr)})`);
|
|
34742
34818
|
}
|
|
34743
34819
|
}
|
|
34744
34820
|
{
|
|
@@ -34750,10 +34826,10 @@ async function runEmbeddedAttempt(params) {
|
|
|
34750
34826
|
if (planResult.enter) {
|
|
34751
34827
|
if (planResult.stripped != null) effectivePrompt = planResult.stripped;
|
|
34752
34828
|
effectivePrompt = `${PLAN_MODE_SYSTEM_PROMPT}\n\n${effectivePrompt}`;
|
|
34753
|
-
log$
|
|
34829
|
+
log$7.info(`plan-mode: activated (${planResult.reason}) for runId=${params.runId}`);
|
|
34754
34830
|
} else if (planResult.stripped != null) effectivePrompt = planResult.stripped;
|
|
34755
34831
|
}
|
|
34756
|
-
log$
|
|
34832
|
+
log$7.debug(`embedded run prompt start: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
34757
34833
|
cacheTrace?.recordStage("prompt:before", {
|
|
34758
34834
|
prompt: effectivePrompt,
|
|
34759
34835
|
messages: activeSession.messages
|
|
@@ -34765,7 +34841,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34765
34841
|
const sessionContext = sessionManager.buildSessionContext();
|
|
34766
34842
|
const sanitizedOrphan = transcriptPolicy.sanitizeThinkingSignatures ? sanitizeAntigravityThinkingBlocks(sessionContext.messages) : sessionContext.messages;
|
|
34767
34843
|
activeSession.agent.replaceMessages(sanitizedOrphan);
|
|
34768
|
-
log$
|
|
34844
|
+
log$7.warn(`Removed orphaned user message to prevent consecutive user turns. runId=${params.runId} sessionId=${params.sessionId}`);
|
|
34769
34845
|
}
|
|
34770
34846
|
try {
|
|
34771
34847
|
const imageResult = await detectAndLoadPromptImages({
|
|
@@ -34787,12 +34863,12 @@ async function runEmbeddedAttempt(params) {
|
|
|
34787
34863
|
messages: activeSession.messages,
|
|
34788
34864
|
note: `images: prompt=${imageResult.images.length} history=${imageResult.historyImagesByIndex.size}`
|
|
34789
34865
|
});
|
|
34790
|
-
if (log$
|
|
34866
|
+
if (log$7.isEnabled("debug")) {
|
|
34791
34867
|
const msgCount = activeSession.messages.length;
|
|
34792
34868
|
const systemLen = systemPromptText?.length ?? 0;
|
|
34793
34869
|
const promptLen = effectivePrompt.length;
|
|
34794
34870
|
const sessionSummary = summarizeSessionContext(activeSession.messages);
|
|
34795
|
-
log$
|
|
34871
|
+
log$7.debug(`[context-diag] pre-prompt: sessionKey=${params.sessionKey ?? params.sessionId} messages=${msgCount} roleCounts=${sessionSummary.roleCounts} historyTextChars=${sessionSummary.totalTextChars} maxMessageTextChars=${sessionSummary.maxMessageTextChars} historyImageBlocks=${sessionSummary.totalImageBlocks} systemPromptChars=${systemLen} promptChars=${promptLen} promptImages=${imageResult.images.length} historyImageMessages=${imageResult.historyImagesByIndex.size} provider=${params.provider}/${params.modelId} sessionFile=${params.sessionFile}`);
|
|
34796
34872
|
}
|
|
34797
34873
|
if (hookRunner?.hasHooks("llm_input")) hookRunner.runLlmInput({
|
|
34798
34874
|
runId: params.runId,
|
|
@@ -34810,7 +34886,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34810
34886
|
workspaceDir: params.workspaceDir,
|
|
34811
34887
|
messageProvider: params.messageProvider ?? void 0
|
|
34812
34888
|
}).catch((err) => {
|
|
34813
|
-
log$
|
|
34889
|
+
log$7.warn(`llm_input hook failed: ${String(err)}`);
|
|
34814
34890
|
});
|
|
34815
34891
|
if (imageResult.images.length > 0) await abortable(activeSession.prompt(effectivePrompt, { images: imageResult.images }));
|
|
34816
34892
|
else await abortable(activeSession.prompt(effectivePrompt));
|
|
@@ -34818,7 +34894,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34818
34894
|
promptError = err;
|
|
34819
34895
|
promptErrorSource = "prompt";
|
|
34820
34896
|
} finally {
|
|
34821
|
-
log$
|
|
34897
|
+
log$7.debug(`embedded run prompt end: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - promptStartedAt}`);
|
|
34822
34898
|
}
|
|
34823
34899
|
const wasCompactingBefore = activeSession.isCompacting;
|
|
34824
34900
|
const snapshot = activeSession.messages.slice();
|
|
@@ -34833,7 +34909,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34833
34909
|
promptError = err;
|
|
34834
34910
|
promptErrorSource = "compaction";
|
|
34835
34911
|
}
|
|
34836
|
-
if (!isProbeSession) log$
|
|
34912
|
+
if (!isProbeSession) log$7.debug(`compaction wait aborted: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
34837
34913
|
} else throw err;
|
|
34838
34914
|
}
|
|
34839
34915
|
if (!timedOutDuringCompaction) {
|
|
@@ -34851,7 +34927,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34851
34927
|
currentSessionId: activeSession.sessionId
|
|
34852
34928
|
});
|
|
34853
34929
|
if (timedOutDuringCompaction) {
|
|
34854
|
-
if (!isProbeSession) log$
|
|
34930
|
+
if (!isProbeSession) log$7.warn(`using ${snapshotSelection.source} snapshot: timed out during compaction runId=${params.runId} sessionId=${params.sessionId}`);
|
|
34855
34931
|
}
|
|
34856
34932
|
messagesSnapshot = snapshotSelection.messagesSnapshot;
|
|
34857
34933
|
sessionIdUsed = snapshotSelection.sessionIdUsed;
|
|
@@ -34866,7 +34942,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34866
34942
|
error: describeUnknownError(promptError)
|
|
34867
34943
|
});
|
|
34868
34944
|
} catch (entryErr) {
|
|
34869
|
-
log$
|
|
34945
|
+
log$7.warn(`failed to persist prompt error entry: ${String(entryErr)}`);
|
|
34870
34946
|
}
|
|
34871
34947
|
cacheTrace?.recordStage("session:after", {
|
|
34872
34948
|
messages: messagesSnapshot,
|
|
@@ -34885,17 +34961,17 @@ async function runEmbeddedAttempt(params) {
|
|
|
34885
34961
|
workspaceDir: params.workspaceDir,
|
|
34886
34962
|
messageProvider: params.messageProvider ?? void 0
|
|
34887
34963
|
}).catch((err) => {
|
|
34888
|
-
log$
|
|
34964
|
+
log$7.warn(`agent_end hook failed: ${err}`);
|
|
34889
34965
|
});
|
|
34890
34966
|
} finally {
|
|
34891
34967
|
clearTimeout(abortTimer);
|
|
34892
34968
|
clearSymipulseTimer();
|
|
34893
34969
|
if (abortWarnTimer) clearTimeout(abortWarnTimer);
|
|
34894
|
-
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$
|
|
34970
|
+
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$7.debug(`run cleanup: runId=${params.runId} sessionId=${params.sessionId} aborted=${aborted} timedOut=${timedOut}`);
|
|
34895
34971
|
try {
|
|
34896
34972
|
unsubscribe();
|
|
34897
34973
|
} catch (err) {
|
|
34898
|
-
log$
|
|
34974
|
+
log$7.error(`CRITICAL: unsubscribe failed, possible resource leak: runId=${params.runId} ${String(err)}`);
|
|
34899
34975
|
}
|
|
34900
34976
|
clearActiveEmbeddedRun(params.sessionId, queueHandle, params.sessionKey);
|
|
34901
34977
|
params.abortSignal?.removeEventListener?.("abort", onAbort);
|
|
@@ -34920,7 +34996,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
34920
34996
|
workspaceDir: params.workspaceDir,
|
|
34921
34997
|
messageProvider: params.messageProvider ?? void 0
|
|
34922
34998
|
}).catch((err) => {
|
|
34923
|
-
log$
|
|
34999
|
+
log$7.warn(`llm_output hook failed: ${String(err)}`);
|
|
34924
35000
|
});
|
|
34925
35001
|
return {
|
|
34926
35002
|
aborted,
|
|
@@ -35181,7 +35257,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35181
35257
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
35182
35258
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
35183
35259
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
35184
|
-
if (workspaceResolution.usedFallback) log$
|
|
35260
|
+
if (workspaceResolution.usedFallback) log$7.warn(`[workspace-fallback] caller=runEmbeddedPiAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
|
|
35185
35261
|
const prevCwd = process.cwd();
|
|
35186
35262
|
let provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
35187
35263
|
let modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
@@ -35200,7 +35276,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35200
35276
|
if (hookRunner?.hasHooks("before_model_resolve")) try {
|
|
35201
35277
|
modelResolveOverride = await hookRunner.runBeforeModelResolve({ prompt: params.prompt }, hookCtx);
|
|
35202
35278
|
} catch (hookErr) {
|
|
35203
|
-
log$
|
|
35279
|
+
log$7.warn(`before_model_resolve hook failed: ${String(hookErr)}`);
|
|
35204
35280
|
}
|
|
35205
35281
|
if (hookRunner?.hasHooks("before_agent_start")) try {
|
|
35206
35282
|
const legacyResult = await hookRunner.runBeforeAgentStart({ prompt: params.prompt }, hookCtx);
|
|
@@ -35209,15 +35285,15 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35209
35285
|
modelOverride: modelResolveOverride?.modelOverride ?? legacyResult?.modelOverride
|
|
35210
35286
|
};
|
|
35211
35287
|
} catch (hookErr) {
|
|
35212
|
-
log$
|
|
35288
|
+
log$7.warn(`before_agent_start hook (legacy model resolve path) failed: ${String(hookErr)}`);
|
|
35213
35289
|
}
|
|
35214
35290
|
if (modelResolveOverride?.providerOverride) {
|
|
35215
35291
|
provider = modelResolveOverride.providerOverride;
|
|
35216
|
-
log$
|
|
35292
|
+
log$7.info(`[hooks] provider overridden to ${provider}`);
|
|
35217
35293
|
}
|
|
35218
35294
|
if (modelResolveOverride?.modelOverride) {
|
|
35219
35295
|
modelId = modelResolveOverride.modelOverride;
|
|
35220
|
-
log$
|
|
35296
|
+
log$7.info(`[hooks] model overridden to ${modelId}`);
|
|
35221
35297
|
}
|
|
35222
35298
|
const { model, error, authStorage, modelRegistry } = resolveModel(provider, modelId, agentDir, params.config);
|
|
35223
35299
|
if (!model) throw new FailoverError(error ?? `Unknown model: ${provider}/${modelId}`, {
|
|
@@ -35237,9 +35313,9 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35237
35313
|
warnBelowTokens: CONTEXT_WINDOW_WARN_BELOW_TOKENS,
|
|
35238
35314
|
hardMinTokens: CONTEXT_WINDOW_HARD_MIN_TOKENS
|
|
35239
35315
|
});
|
|
35240
|
-
if (ctxGuard.shouldWarn) log$
|
|
35316
|
+
if (ctxGuard.shouldWarn) log$7.warn(`low context window: ${provider}/${modelId} ctx=${ctxGuard.tokens} (warn<${CONTEXT_WINDOW_WARN_BELOW_TOKENS}) source=${ctxGuard.source}`);
|
|
35241
35317
|
if (ctxGuard.shouldBlock) {
|
|
35242
|
-
log$
|
|
35318
|
+
log$7.error(`blocked model (context window too small): ${provider}/${modelId} ctx=${ctxGuard.tokens} (min=${CONTEXT_WINDOW_HARD_MIN_TOKENS}) source=${ctxGuard.source}`);
|
|
35243
35319
|
throw new FailoverError(`Model context window too small (${ctxGuard.tokens} tokens). Minimum is ${CONTEXT_WINDOW_HARD_MIN_TOKENS}.`, {
|
|
35244
35320
|
reason: "unknown",
|
|
35245
35321
|
provider,
|
|
@@ -35369,7 +35445,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35369
35445
|
while (true) {
|
|
35370
35446
|
if (runLoopIterations >= MAX_RUN_LOOP_ITERATIONS) {
|
|
35371
35447
|
const message = `Exceeded retry limit after ${runLoopIterations} attempts (max=${MAX_RUN_LOOP_ITERATIONS}).`;
|
|
35372
|
-
log$
|
|
35448
|
+
log$7.error(`[run-retry-limit] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} attempts=${runLoopIterations} maxAttempts=${MAX_RUN_LOOP_ITERATIONS}`);
|
|
35373
35449
|
return {
|
|
35374
35450
|
payloads: [{
|
|
35375
35451
|
text: "Request failed after repeated internal retries. Please try again, or use /new to start a fresh session.",
|
|
@@ -35490,18 +35566,18 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35490
35566
|
const overflowDiagId = createCompactionDiagId$1();
|
|
35491
35567
|
const errorText = contextOverflowError.text;
|
|
35492
35568
|
const msgCount = attempt.messagesSnapshot?.length ?? 0;
|
|
35493
|
-
log$
|
|
35569
|
+
log$7.warn(`[context-overflow-diag] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} source=${contextOverflowError.source} messages=${msgCount} sessionFile=${params.sessionFile} diagId=${overflowDiagId} compactionAttempts=${overflowCompactionAttempts} error=${errorText.slice(0, 200)}`);
|
|
35494
35570
|
const isCompactionFailure = isCompactionFailureError(errorText);
|
|
35495
35571
|
const hadAttemptLevelCompaction = attemptCompactionCount > 0;
|
|
35496
35572
|
if (!isCompactionFailure && hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
35497
35573
|
overflowCompactionAttempts++;
|
|
35498
|
-
log$
|
|
35574
|
+
log$7.warn(`context overflow persisted after in-attempt compaction (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); retrying prompt without additional compaction for ${provider}/${modelId}`);
|
|
35499
35575
|
continue;
|
|
35500
35576
|
}
|
|
35501
35577
|
if (!isCompactionFailure && !hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
35502
|
-
if (log$
|
|
35578
|
+
if (log$7.isEnabled("debug")) log$7.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=compact isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts + 1} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
35503
35579
|
overflowCompactionAttempts++;
|
|
35504
|
-
log$
|
|
35580
|
+
log$7.warn(`context overflow detected (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); attempting auto-compaction for ${provider}/${modelId}`);
|
|
35505
35581
|
const compactResult = await compactEmbeddedPiSessionDirect({
|
|
35506
35582
|
sessionId: params.sessionId,
|
|
35507
35583
|
sessionKey: params.sessionKey,
|
|
@@ -35530,10 +35606,10 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35530
35606
|
});
|
|
35531
35607
|
if (compactResult.compacted) {
|
|
35532
35608
|
autoCompactionCount += 1;
|
|
35533
|
-
log$
|
|
35609
|
+
log$7.info(`auto-compaction succeeded for ${provider}/${modelId}; retrying prompt`);
|
|
35534
35610
|
continue;
|
|
35535
35611
|
}
|
|
35536
|
-
log$
|
|
35612
|
+
log$7.warn(`auto-compaction failed for ${provider}/${modelId}: ${compactResult.reason ?? "nothing to compact"}`);
|
|
35537
35613
|
}
|
|
35538
35614
|
if (!toolResultTruncationAttempted) {
|
|
35539
35615
|
const contextWindowTokens = ctxInfo.tokens;
|
|
@@ -35542,9 +35618,9 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35542
35618
|
contextWindowTokens
|
|
35543
35619
|
}) : false;
|
|
35544
35620
|
if (hasOversized) {
|
|
35545
|
-
if (log$
|
|
35621
|
+
if (log$7.isEnabled("debug")) log$7.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=truncate_tool_results isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=${hasOversized} attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
35546
35622
|
toolResultTruncationAttempted = true;
|
|
35547
|
-
log$
|
|
35623
|
+
log$7.warn(`[context-overflow-recovery] Attempting tool result truncation for ${provider}/${modelId} (contextWindow=${contextWindowTokens} tokens)`);
|
|
35548
35624
|
const truncResult = await truncateOversizedToolResultsInSession({
|
|
35549
35625
|
sessionFile: params.sessionFile,
|
|
35550
35626
|
contextWindowTokens,
|
|
@@ -35552,13 +35628,13 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35552
35628
|
sessionKey: params.sessionKey
|
|
35553
35629
|
});
|
|
35554
35630
|
if (truncResult.truncated) {
|
|
35555
|
-
log$
|
|
35631
|
+
log$7.info(`[context-overflow-recovery] Truncated ${truncResult.truncatedCount} tool result(s); retrying prompt`);
|
|
35556
35632
|
continue;
|
|
35557
35633
|
}
|
|
35558
|
-
log$
|
|
35559
|
-
} else if (log$
|
|
35634
|
+
log$7.warn(`[context-overflow-recovery] Tool result truncation did not help: ${truncResult.reason ?? "unknown"}`);
|
|
35635
|
+
} else if (log$7.isEnabled("debug")) log$7.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=${hasOversized} attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
35560
35636
|
}
|
|
35561
|
-
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$
|
|
35637
|
+
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$7.isEnabled("debug")) log$7.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
35562
35638
|
const kind = isCompactionFailure ? "compaction_failure" : "context_overflow";
|
|
35563
35639
|
return {
|
|
35564
35640
|
payloads: [{
|
|
@@ -35639,7 +35715,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35639
35715
|
attempted: attemptedThinking
|
|
35640
35716
|
});
|
|
35641
35717
|
if (fallbackThinking) {
|
|
35642
|
-
log$
|
|
35718
|
+
log$7.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
35643
35719
|
thinkLevel = fallbackThinking;
|
|
35644
35720
|
continue;
|
|
35645
35721
|
}
|
|
@@ -35657,7 +35733,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35657
35733
|
attempted: attemptedThinking
|
|
35658
35734
|
});
|
|
35659
35735
|
if (fallbackThinking && !aborted) {
|
|
35660
|
-
log$
|
|
35736
|
+
log$7.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
35661
35737
|
thinkLevel = fallbackThinking;
|
|
35662
35738
|
continue;
|
|
35663
35739
|
}
|
|
@@ -35674,7 +35750,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35674
35750
|
imageDimensionError.contentIndex !== void 0 ? `content=${imageDimensionError.contentIndex}` : null,
|
|
35675
35751
|
imageDimensionError.maxDimensionPx !== void 0 ? `limit=${imageDimensionError.maxDimensionPx}px` : null
|
|
35676
35752
|
].filter(Boolean).join(" ");
|
|
35677
|
-
log$
|
|
35753
|
+
log$7.warn(`Profile ${lastProfileId} rejected image payload${details ? ` (${details})` : ""}.`);
|
|
35678
35754
|
}
|
|
35679
35755
|
const isLocalOllamaTimeout = timedOut && model.api === "ollama";
|
|
35680
35756
|
if (!aborted && failoverFailure || timedOut && !timedOutDuringCompaction && !isLocalOllamaTimeout) {
|
|
@@ -35686,8 +35762,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35686
35762
|
cfg: params.config,
|
|
35687
35763
|
agentDir: params.agentDir
|
|
35688
35764
|
});
|
|
35689
|
-
if (timedOut && !isProbeSession) log$
|
|
35690
|
-
if (cloudCodeAssistFormatError) log$
|
|
35765
|
+
if (timedOut && !isProbeSession) log$7.warn(`Profile ${lastProfileId} timed out (possible rate limit). Trying next account...`);
|
|
35766
|
+
if (cloudCodeAssistFormatError) log$7.warn(`Profile ${lastProfileId} hit Cloud Code Assist format error. Tool calls will be sanitized on retry.`);
|
|
35691
35767
|
}
|
|
35692
35768
|
if (await advanceAuthProfile()) continue;
|
|
35693
35769
|
if (fallbackConfigured) {
|
|
@@ -35753,7 +35829,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35753
35829
|
const hasCodeBlocks = attempt.assistantTexts.some((text) => /```[\s\S]*?```/.test(text));
|
|
35754
35830
|
if (hasCodeToolUsage || hasCodeBlocks) {
|
|
35755
35831
|
verificationPassCompleted = true;
|
|
35756
|
-
log$
|
|
35832
|
+
log$7.debug(`[verification] starting verification pass: runId=${params.runId} sessionId=${params.sessionId} trigger=${hasCodeToolUsage ? "tool_usage" : "code_blocks"}`);
|
|
35757
35833
|
const verificationPrompt = "Review your response against the original user request. Check: (1) Did you address every requirement? (2) Did you include tests if requested? (3) Did you run and verify the code works? If you missed anything, fix it now. If everything looks correct, briefly confirm.";
|
|
35758
35834
|
try {
|
|
35759
35835
|
const verifyAttempt = await runEmbeddedAttempt({
|
|
@@ -35839,10 +35915,10 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35839
35915
|
payloads.length = 0;
|
|
35840
35916
|
payloads.push(...verifyPayloads);
|
|
35841
35917
|
}
|
|
35842
|
-
log$
|
|
35843
|
-
} else log$
|
|
35918
|
+
log$7.debug(`[verification] verification produced corrections: runId=${params.runId} tools=${verifyAttempt.toolMetas.length} texts=${verifyAttempt.assistantTexts.length}`);
|
|
35919
|
+
} else log$7.debug(`[verification] verification confirmed original response: runId=${params.runId}`);
|
|
35844
35920
|
} catch (verifyErr) {
|
|
35845
|
-
log$
|
|
35921
|
+
log$7.warn(`[verification] verification pass failed, keeping original response: runId=${params.runId} error=${String(verifyErr)}`);
|
|
35846
35922
|
}
|
|
35847
35923
|
}
|
|
35848
35924
|
}
|
|
@@ -35863,7 +35939,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
35863
35939
|
messagingToolSentTargets: attempt.messagingToolSentTargets,
|
|
35864
35940
|
successfulCronAdds: attempt.successfulCronAdds
|
|
35865
35941
|
};
|
|
35866
|
-
log$
|
|
35942
|
+
log$7.debug(`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`);
|
|
35867
35943
|
if (lastProfileId) {
|
|
35868
35944
|
await markAuthProfileGood({
|
|
35869
35945
|
store: authStore,
|
|
@@ -36115,7 +36191,7 @@ async function runAgentTurn(params) {
|
|
|
36115
36191
|
function createDefaultDeps() {
|
|
36116
36192
|
return {
|
|
36117
36193
|
sendMessageWhatsApp: async (...args) => {
|
|
36118
|
-
const { sendMessageWhatsApp } = await import("./web-
|
|
36194
|
+
const { sendMessageWhatsApp } = await import("./web-BgKYnau3.js");
|
|
36119
36195
|
return await sendMessageWhatsApp(...args);
|
|
36120
36196
|
},
|
|
36121
36197
|
sendMessageTelegram: async (...args) => {
|
|
@@ -53553,7 +53629,7 @@ function loadWebLoginQr() {
|
|
|
53553
53629
|
return webLoginQrPromise;
|
|
53554
53630
|
}
|
|
53555
53631
|
function loadWebChannel() {
|
|
53556
|
-
webChannelPromise ??= import("./web-
|
|
53632
|
+
webChannelPromise ??= import("./web-BgKYnau3.js");
|
|
53557
53633
|
return webChannelPromise;
|
|
53558
53634
|
}
|
|
53559
53635
|
function loadWhatsAppActions() {
|
|
@@ -69764,7 +69840,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
69764
69840
|
const provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
69765
69841
|
const modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
69766
69842
|
const fail = (reason) => {
|
|
69767
|
-
log$
|
|
69843
|
+
log$7.warn(`[compaction-diag] end runId=${runId} sessionKey=${params.sessionKey ?? params.sessionId} diagId=${diagId} trigger=${trigger} provider=${provider}/${modelId} attempt=${attempt} maxAttempts=${maxAttempts} outcome=failed reason=${classifyCompactionReason(reason)} durationMs=${Date.now() - startedAt}`);
|
|
69768
69844
|
return {
|
|
69769
69845
|
ok: false,
|
|
69770
69846
|
compacted: false,
|
|
@@ -69832,7 +69908,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
69832
69908
|
sessionId: params.sessionId,
|
|
69833
69909
|
warn: makeBootstrapWarn({
|
|
69834
69910
|
sessionLabel,
|
|
69835
|
-
warn: (message) => log$
|
|
69911
|
+
warn: (message) => log$7.warn(message)
|
|
69836
69912
|
})
|
|
69837
69913
|
});
|
|
69838
69914
|
const runAbortController = new AbortController();
|
|
@@ -69972,7 +70048,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
69972
70048
|
try {
|
|
69973
70049
|
await repairSessionFileIfNeeded({
|
|
69974
70050
|
sessionFile: params.sessionFile,
|
|
69975
|
-
warn: (message) => log$
|
|
70051
|
+
warn: (message) => log$7.warn(message)
|
|
69976
70052
|
});
|
|
69977
70053
|
await prewarmSessionFile(params.sessionFile);
|
|
69978
70054
|
const transcriptPolicy = resolveTranscriptPolicy({
|
|
@@ -70057,13 +70133,13 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
70057
70133
|
messages: preCompactionMessages,
|
|
70058
70134
|
sessionFile: params.sessionFile
|
|
70059
70135
|
}, hookCtx).catch((hookErr) => {
|
|
70060
|
-
log$
|
|
70136
|
+
log$7.warn(`before_compaction hook failed: ${String(hookErr)}`);
|
|
70061
70137
|
});
|
|
70062
|
-
const diagEnabled = log$
|
|
70138
|
+
const diagEnabled = log$7.isEnabled("debug");
|
|
70063
70139
|
const preMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
70064
70140
|
if (diagEnabled && preMetrics) {
|
|
70065
|
-
log$
|
|
70066
|
-
log$
|
|
70141
|
+
log$7.debug(`[compaction-diag] start runId=${runId} sessionKey=${params.sessionKey ?? params.sessionId} diagId=${diagId} trigger=${trigger} provider=${provider}/${modelId} attempt=${attempt} maxAttempts=${maxAttempts} pre.messages=${preMetrics.messages} pre.historyTextChars=${preMetrics.historyTextChars} pre.toolResultChars=${preMetrics.toolResultChars} pre.estTokens=${preMetrics.estTokens ?? "unknown"}`);
|
|
70142
|
+
log$7.debug(`[compaction-diag] contributors diagId=${diagId} top=${JSON.stringify(preMetrics.contributors)}`);
|
|
70067
70143
|
}
|
|
70068
70144
|
const compactStartedAt = Date.now();
|
|
70069
70145
|
const result = await compactWithSafetyTimeout(() => session.compact(params.customInstructions));
|
|
@@ -70081,10 +70157,10 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
70081
70157
|
compactedCount: limited.length - session.messages.length,
|
|
70082
70158
|
sessionFile: params.sessionFile
|
|
70083
70159
|
}, hookCtx).catch((hookErr) => {
|
|
70084
|
-
log$
|
|
70160
|
+
log$7.warn(`after_compaction hook failed: ${hookErr}`);
|
|
70085
70161
|
});
|
|
70086
70162
|
const postMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
70087
|
-
if (diagEnabled && preMetrics && postMetrics) log$
|
|
70163
|
+
if (diagEnabled && preMetrics && postMetrics) log$7.debug(`[compaction-diag] end runId=${runId} sessionKey=${params.sessionKey ?? params.sessionId} diagId=${diagId} trigger=${trigger} provider=${provider}/${modelId} attempt=${attempt} maxAttempts=${maxAttempts} outcome=compacted reason=none durationMs=${Date.now() - compactStartedAt} retrying=false post.messages=${postMetrics.messages} post.historyTextChars=${postMetrics.historyTextChars} post.toolResultChars=${postMetrics.toolResultChars} post.estTokens=${postMetrics.estTokens ?? "unknown"} delta.messages=${postMetrics.messages - preMetrics.messages} delta.historyTextChars=${postMetrics.historyTextChars - preMetrics.historyTextChars} delta.toolResultChars=${postMetrics.toolResultChars - preMetrics.toolResultChars} delta.estTokens=${typeof preMetrics.estTokens === "number" && typeof postMetrics.estTokens === "number" ? postMetrics.estTokens - preMetrics.estTokens : "unknown"}`);
|
|
70088
70164
|
return {
|
|
70089
70165
|
ok: true,
|
|
70090
70166
|
compacted: true,
|