@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
|
@@ -20367,7 +20367,7 @@ function createRunRegistry(options) {
|
|
|
20367
20367
|
|
|
20368
20368
|
//#endregion
|
|
20369
20369
|
//#region src/process/supervisor/supervisor.ts
|
|
20370
|
-
const log$
|
|
20370
|
+
const log$9 = createSubsystemLogger("process/supervisor");
|
|
20371
20371
|
function clampTimeout(value) {
|
|
20372
20372
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return;
|
|
20373
20373
|
return Math.max(1, Math.floor(value));
|
|
@@ -20553,7 +20553,7 @@ function createProcessSupervisor() {
|
|
|
20553
20553
|
exitCode: null,
|
|
20554
20554
|
exitSignal: null
|
|
20555
20555
|
});
|
|
20556
|
-
log$
|
|
20556
|
+
log$9.warn(`spawn failed: runId=${runId} reason=${String(err)}`);
|
|
20557
20557
|
throw err;
|
|
20558
20558
|
}
|
|
20559
20559
|
};
|
|
@@ -21852,7 +21852,7 @@ function resolveRunWorkspaceDir(params) {
|
|
|
21852
21852
|
|
|
21853
21853
|
//#endregion
|
|
21854
21854
|
//#region src/agents/cli-runner.ts
|
|
21855
|
-
const log$
|
|
21855
|
+
const log$8 = createSubsystemLogger("agent/claude-cli");
|
|
21856
21856
|
async function runCliAgent(params) {
|
|
21857
21857
|
const started = Date.now();
|
|
21858
21858
|
const workspaceResolution = resolveRunWorkspaceDir({
|
|
@@ -21865,7 +21865,7 @@ async function runCliAgent(params) {
|
|
|
21865
21865
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
21866
21866
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
21867
21867
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
21868
|
-
if (workspaceResolution.usedFallback) log$
|
|
21868
|
+
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}`);
|
|
21869
21869
|
const workspaceDir = resolvedWorkspace;
|
|
21870
21870
|
const backendResolved = resolveCliBackendConfig(params.provider, params.config);
|
|
21871
21871
|
if (!backendResolved) throw new Error(`Unknown CLI backend: ${params.provider}`);
|
|
@@ -21882,7 +21882,7 @@ async function runCliAgent(params) {
|
|
|
21882
21882
|
sessionId: params.sessionId,
|
|
21883
21883
|
warn: makeBootstrapWarn({
|
|
21884
21884
|
sessionLabel,
|
|
21885
|
-
warn: (message) => log$
|
|
21885
|
+
warn: (message) => log$8.warn(message)
|
|
21886
21886
|
})
|
|
21887
21887
|
});
|
|
21888
21888
|
const { defaultAgentId, sessionAgentId } = resolveSessionAgentIds({
|
|
@@ -21948,7 +21948,7 @@ async function runCliAgent(params) {
|
|
|
21948
21948
|
const queueKey = backend.serialize ?? true ? backendResolved.id : `${backendResolved.id}:${params.runId}`;
|
|
21949
21949
|
try {
|
|
21950
21950
|
const output = await enqueueCliRun(queueKey, async () => {
|
|
21951
|
-
log$
|
|
21951
|
+
log$8.info(`cli exec: provider=${params.provider} model=${normalizedModel} promptChars=${params.prompt.length}`);
|
|
21952
21952
|
const logOutputText = isTruthyEnvValue(process.env.SYMI_CLAUDE_CLI_LOG_OUTPUT);
|
|
21953
21953
|
if (logOutputText) {
|
|
21954
21954
|
const logArgs = [];
|
|
@@ -21981,7 +21981,7 @@ async function runCliAgent(params) {
|
|
|
21981
21981
|
const promptIndex = logArgs.indexOf(argsPrompt);
|
|
21982
21982
|
if (promptIndex >= 0) logArgs[promptIndex] = `<prompt:${argsPrompt.length} chars>`;
|
|
21983
21983
|
}
|
|
21984
|
-
log$
|
|
21984
|
+
log$8.info(`cli argv: ${backend.command} ${logArgs.join(" ")}`);
|
|
21985
21985
|
}
|
|
21986
21986
|
const env = (() => {
|
|
21987
21987
|
const next = {
|
|
@@ -22019,17 +22019,17 @@ async function runCliAgent(params) {
|
|
|
22019
22019
|
const stdout = result.stdout.trim();
|
|
22020
22020
|
const stderr = result.stderr.trim();
|
|
22021
22021
|
if (logOutputText) {
|
|
22022
|
-
if (stdout) log$
|
|
22023
|
-
if (stderr) log$
|
|
22022
|
+
if (stdout) log$8.info(`cli stdout:\n${stdout}`);
|
|
22023
|
+
if (stderr) log$8.info(`cli stderr:\n${stderr}`);
|
|
22024
22024
|
}
|
|
22025
22025
|
if (shouldLogVerbose()) {
|
|
22026
|
-
if (stdout) log$
|
|
22027
|
-
if (stderr) log$
|
|
22026
|
+
if (stdout) log$8.debug(`cli stdout:\n${stdout}`);
|
|
22027
|
+
if (stderr) log$8.debug(`cli stderr:\n${stderr}`);
|
|
22028
22028
|
}
|
|
22029
22029
|
if (result.exitCode !== 0 || result.reason !== "exit") {
|
|
22030
22030
|
if (result.reason === "no-output-timeout" || result.noOutputTimedOut) {
|
|
22031
22031
|
const timeoutReason = `CLI produced no output for ${Math.round(noOutputTimeoutMs / 1e3)}s and was terminated.`;
|
|
22032
|
-
log$
|
|
22032
|
+
log$8.warn(`cli watchdog timeout: provider=${params.provider} model=${modelId} session=${cliSessionIdToSend ?? params.sessionId} noOutputTimeoutMs=${noOutputTimeoutMs} pid=${managedRun.pid ?? "unknown"}`);
|
|
22033
22033
|
throw new FailoverError(timeoutReason, {
|
|
22034
22034
|
reason: "timeout",
|
|
22035
22035
|
provider: params.provider,
|
|
@@ -22603,7 +22603,7 @@ function resolveEmbeddedSessionLane(key) {
|
|
|
22603
22603
|
|
|
22604
22604
|
//#endregion
|
|
22605
22605
|
//#region src/agents/pi-embedded-runner/logger.ts
|
|
22606
|
-
const log$
|
|
22606
|
+
const log$7 = createSubsystemLogger("agent/embedded");
|
|
22607
22607
|
|
|
22608
22608
|
//#endregion
|
|
22609
22609
|
//#region src/utils/safe-json.ts
|
|
@@ -22649,7 +22649,7 @@ function getQueuedFileWriter(writers, filePath) {
|
|
|
22649
22649
|
//#endregion
|
|
22650
22650
|
//#region src/agents/anthropic-payload-log.ts
|
|
22651
22651
|
const writers$1 = /* @__PURE__ */ new Map();
|
|
22652
|
-
const log$
|
|
22652
|
+
const log$6 = createSubsystemLogger("agent/anthropic-payload");
|
|
22653
22653
|
function resolvePayloadLogConfig(env) {
|
|
22654
22654
|
const enabled = parseBooleanValue$1(env.SYMI_ANTHROPIC_PAYLOAD_LOG) ?? false;
|
|
22655
22655
|
const fileOverride = env.SYMI_ANTHROPIC_PAYLOAD_LOG_FILE?.trim();
|
|
@@ -22739,13 +22739,13 @@ function createAnthropicPayloadLogger(params) {
|
|
|
22739
22739
|
usage,
|
|
22740
22740
|
error: errorMessage
|
|
22741
22741
|
});
|
|
22742
|
-
log$
|
|
22742
|
+
log$6.info("anthropic usage", {
|
|
22743
22743
|
runId: params.runId,
|
|
22744
22744
|
sessionId: params.sessionId,
|
|
22745
22745
|
usage
|
|
22746
22746
|
});
|
|
22747
22747
|
};
|
|
22748
|
-
log$
|
|
22748
|
+
log$6.info("anthropic payload logger enabled", { filePath: writer.filePath });
|
|
22749
22749
|
return {
|
|
22750
22750
|
enabled: true,
|
|
22751
22751
|
wrapStreamFn,
|
|
@@ -24627,7 +24627,7 @@ function createEmbeddedPiSessionEventHandler(ctx) {
|
|
|
24627
24627
|
//#region src/agents/pi-embedded-subscribe.ts
|
|
24628
24628
|
const THINKING_TAG_SCAN_RE = /<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\s*>/gi;
|
|
24629
24629
|
const FINAL_TAG_SCAN_RE = /<\s*(\/?)\s*final\s*>/gi;
|
|
24630
|
-
const log$
|
|
24630
|
+
const log$5 = createSubsystemLogger("agent/embedded");
|
|
24631
24631
|
function subscribeEmbeddedPiSession(params) {
|
|
24632
24632
|
const reasoningMode = params.reasoningMode ?? "off";
|
|
24633
24633
|
const useMarkdown = (params.toolResultFormat ?? "markdown") === "markdown";
|
|
@@ -24784,7 +24784,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
24784
24784
|
state.compactionRetryReject = reject;
|
|
24785
24785
|
});
|
|
24786
24786
|
state.compactionRetryPromise.catch((err) => {
|
|
24787
|
-
log$
|
|
24787
|
+
log$5.debug(`compaction promise rejected (no waiter): ${String(err)}`);
|
|
24788
24788
|
});
|
|
24789
24789
|
}
|
|
24790
24790
|
};
|
|
@@ -24936,7 +24936,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
24936
24936
|
if (!chunk) return;
|
|
24937
24937
|
if (chunk === state.lastBlockReplyText) return;
|
|
24938
24938
|
if (isMessagingToolDuplicateNormalized(normalizeTextForComparison(chunk), messagingToolSentTextsNormalized)) {
|
|
24939
|
-
log$
|
|
24939
|
+
log$5.debug(`Skipping block reply - already sent via messaging tool: ${chunk.slice(0, 50)}...`);
|
|
24940
24940
|
return;
|
|
24941
24941
|
}
|
|
24942
24942
|
if (shouldSkipAssistantText(chunk)) return;
|
|
@@ -25014,7 +25014,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
25014
25014
|
const ctx = {
|
|
25015
25015
|
params,
|
|
25016
25016
|
state,
|
|
25017
|
-
log: log$
|
|
25017
|
+
log: log$5,
|
|
25018
25018
|
blockChunking,
|
|
25019
25019
|
blockChunker,
|
|
25020
25020
|
hookRunner: params.hookRunner,
|
|
@@ -25047,7 +25047,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
25047
25047
|
if (state.unsubscribed) return;
|
|
25048
25048
|
state.unsubscribed = true;
|
|
25049
25049
|
if (state.compactionRetryPromise) {
|
|
25050
|
-
log$
|
|
25050
|
+
log$5.debug(`unsubscribe: rejecting compaction wait runId=${params.runId}`);
|
|
25051
25051
|
const reject = state.compactionRetryReject;
|
|
25052
25052
|
state.compactionRetryResolve = void 0;
|
|
25053
25053
|
state.compactionRetryReject = void 0;
|
|
@@ -25057,11 +25057,11 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
25057
25057
|
reject?.(abortErr);
|
|
25058
25058
|
}
|
|
25059
25059
|
if (params.session.isCompacting) {
|
|
25060
|
-
log$
|
|
25060
|
+
log$5.debug(`unsubscribe: aborting in-flight compaction runId=${params.runId}`);
|
|
25061
25061
|
try {
|
|
25062
25062
|
params.session.abortCompaction();
|
|
25063
25063
|
} catch (err) {
|
|
25064
|
-
log$
|
|
25064
|
+
log$5.warn(`unsubscribe: compaction abort failed runId=${params.runId} err=${String(err)}`);
|
|
25065
25065
|
}
|
|
25066
25066
|
}
|
|
25067
25067
|
sessionUnsubscribe();
|
|
@@ -25110,7 +25110,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
25110
25110
|
|
|
25111
25111
|
//#endregion
|
|
25112
25112
|
//#region src/agents/pi-tools.before-tool-call.ts
|
|
25113
|
-
const log$
|
|
25113
|
+
const log$4 = createSubsystemLogger("agents/tools");
|
|
25114
25114
|
const BEFORE_TOOL_CALL_WRAPPED = Symbol("beforeToolCallWrapped");
|
|
25115
25115
|
const adjustedParamsByToolCallId = /* @__PURE__ */ new Map();
|
|
25116
25116
|
const MAX_TRACKED_ADJUSTED_PARAMS = 1024;
|
|
@@ -25144,7 +25144,7 @@ async function recordLoopOutcome(args) {
|
|
|
25144
25144
|
config: args.ctx.loopDetection
|
|
25145
25145
|
});
|
|
25146
25146
|
} catch (err) {
|
|
25147
|
-
log$
|
|
25147
|
+
log$4.warn(`tool loop outcome tracking failed: tool=${args.toolName} error=${String(err)}`);
|
|
25148
25148
|
}
|
|
25149
25149
|
}
|
|
25150
25150
|
async function runBeforeToolCallHook(args) {
|
|
@@ -25161,7 +25161,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
25161
25161
|
const loopResult = detectToolCallLoop(sessionState, toolName, params, args.ctx.loopDetection);
|
|
25162
25162
|
if (loopResult.stuck) {
|
|
25163
25163
|
if (loopResult.level === "critical") {
|
|
25164
|
-
log$
|
|
25164
|
+
log$4.error(`Blocking ${toolName} due to critical loop: ${loopResult.message}`);
|
|
25165
25165
|
logToolLoopAction({
|
|
25166
25166
|
sessionKey: args.ctx.sessionKey,
|
|
25167
25167
|
sessionId: args.ctx?.agentId,
|
|
@@ -25178,7 +25178,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
25178
25178
|
reason: loopResult.message
|
|
25179
25179
|
};
|
|
25180
25180
|
} else if (shouldEmitLoopWarning(sessionState, loopResult.warningKey ?? `${loopResult.detector}:${toolName}`, loopResult.count)) {
|
|
25181
|
-
log$
|
|
25181
|
+
log$4.warn(`Loop warning for ${toolName}: ${loopResult.message}`);
|
|
25182
25182
|
logToolLoopAction({
|
|
25183
25183
|
sessionKey: args.ctx.sessionKey,
|
|
25184
25184
|
sessionId: args.ctx?.agentId,
|
|
@@ -25228,7 +25228,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
25228
25228
|
}
|
|
25229
25229
|
} catch (err) {
|
|
25230
25230
|
const toolCallId = args.toolCallId ? ` toolCallId=${args.toolCallId}` : "";
|
|
25231
|
-
log$
|
|
25231
|
+
log$4.warn(`before_tool_call hook failed: tool=${toolName}${toolCallId} error=${String(err)}`);
|
|
25232
25232
|
}
|
|
25233
25233
|
return {
|
|
25234
25234
|
blocked: false,
|
|
@@ -25472,10 +25472,27 @@ function validateShellCommand(command) {
|
|
|
25472
25472
|
|
|
25473
25473
|
//#endregion
|
|
25474
25474
|
//#region src/agents/pi-tools.validate-wrapper.ts
|
|
25475
|
+
const log$3 = createSubsystemLogger("agents/tool-validate");
|
|
25475
25476
|
const EXEC_TOOL_NAMES = new Set(["exec", "bash"]);
|
|
25477
|
+
const FILE_TOOL_NAMES = new Set([
|
|
25478
|
+
"write",
|
|
25479
|
+
"read",
|
|
25480
|
+
"edit",
|
|
25481
|
+
"patch",
|
|
25482
|
+
"file_write",
|
|
25483
|
+
"file_edit",
|
|
25484
|
+
"write_file",
|
|
25485
|
+
"edit_file",
|
|
25486
|
+
"create_file"
|
|
25487
|
+
]);
|
|
25488
|
+
const FILE_PATH_KEYS = [
|
|
25489
|
+
"file_path",
|
|
25490
|
+
"path",
|
|
25491
|
+
"filePath"
|
|
25492
|
+
];
|
|
25476
25493
|
/**
|
|
25477
|
-
* Wrap tools with argument validation.
|
|
25478
|
-
* Other tools pass through unchanged.
|
|
25494
|
+
* Wrap tools with argument validation. Exec/bash commands and file paths
|
|
25495
|
+
* are validated. Other tools pass through unchanged.
|
|
25479
25496
|
*
|
|
25480
25497
|
* Call this AFTER tools are created and the model profile is resolved.
|
|
25481
25498
|
*/
|
|
@@ -25484,24 +25501,64 @@ function wrapToolsWithArgValidation(tools, profile) {
|
|
|
25484
25501
|
return tools.map((tool) => wrapToolWithArgValidation(tool));
|
|
25485
25502
|
}
|
|
25486
25503
|
/**
|
|
25487
|
-
*
|
|
25504
|
+
* Clean a file path by stripping control token fragments.
|
|
25505
|
+
* Returns null if the path is irreparably corrupted (empty after cleanup).
|
|
25506
|
+
*/
|
|
25507
|
+
function cleanFilePath(filePath) {
|
|
25508
|
+
let cleaned = filePath.replace(/<\|[^|>]*(?:\|>)?/g, "");
|
|
25509
|
+
cleaned = cleanResidualTokenFragments(cleaned);
|
|
25510
|
+
cleaned = cleaned.trim();
|
|
25511
|
+
if (!cleaned || !/[a-zA-Z0-9/._~-]/.test(cleaned)) return {
|
|
25512
|
+
valid: false,
|
|
25513
|
+
cleaned
|
|
25514
|
+
};
|
|
25515
|
+
return {
|
|
25516
|
+
valid: true,
|
|
25517
|
+
cleaned
|
|
25518
|
+
};
|
|
25519
|
+
}
|
|
25520
|
+
/**
|
|
25521
|
+
* Wrap a single tool with argument validation.
|
|
25488
25522
|
*/
|
|
25489
25523
|
function wrapToolWithArgValidation(tool) {
|
|
25490
25524
|
const toolName = (tool.name ?? "").toLowerCase().trim();
|
|
25491
|
-
|
|
25525
|
+
const isExecTool = EXEC_TOOL_NAMES.has(toolName);
|
|
25526
|
+
const isFileTool = FILE_TOOL_NAMES.has(toolName);
|
|
25527
|
+
if (!isExecTool && !isFileTool) return tool;
|
|
25492
25528
|
const originalExecute = tool.execute;
|
|
25493
25529
|
return {
|
|
25494
25530
|
...tool,
|
|
25495
25531
|
execute(toolCallId, params, ...rest) {
|
|
25496
|
-
|
|
25497
|
-
|
|
25498
|
-
|
|
25499
|
-
|
|
25500
|
-
|
|
25532
|
+
if (isExecTool) {
|
|
25533
|
+
const command = params.command ?? params.cmd;
|
|
25534
|
+
if (typeof command !== "string") {
|
|
25535
|
+
log$3.debug(`[validate] exec called without string command: keys=${Object.keys(params).join(",")}`);
|
|
25536
|
+
return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
25537
|
+
}
|
|
25538
|
+
const result = validateShellCommand(command);
|
|
25539
|
+
if (!result.valid) {
|
|
25540
|
+
log$3.warn(`[validate] exec command rejected: reason=${result.reason} raw=${command.slice(0, 100)}`);
|
|
25541
|
+
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.` });
|
|
25542
|
+
}
|
|
25543
|
+
if (result.cleaned !== command) {
|
|
25544
|
+
log$3.debug(`[validate] exec command cleaned: raw=${command.slice(0, 80)} → cleaned=${result.cleaned.slice(0, 80)}`);
|
|
25545
|
+
return originalExecute.call(tool, toolCallId, {
|
|
25546
|
+
...params,
|
|
25547
|
+
command: result.cleaned
|
|
25548
|
+
}, ...rest);
|
|
25549
|
+
}
|
|
25550
|
+
return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
25551
|
+
}
|
|
25552
|
+
const pathKey = FILE_PATH_KEYS.find((k) => typeof params[k] === "string");
|
|
25553
|
+
if (!pathKey) return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
25554
|
+
const rawPath = params[pathKey];
|
|
25555
|
+
if (!rawPath.includes("<|") && !rawPath.includes("|>") && !/^[<"|]/.test(rawPath)) return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
25556
|
+
const pathResult = cleanFilePath(rawPath);
|
|
25557
|
+
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.` });
|
|
25558
|
+
return originalExecute.call(tool, toolCallId, {
|
|
25501
25559
|
...params,
|
|
25502
|
-
|
|
25560
|
+
[pathKey]: pathResult.cleaned
|
|
25503
25561
|
}, ...rest);
|
|
25504
|
-
return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
25505
25562
|
}
|
|
25506
25563
|
};
|
|
25507
25564
|
}
|
|
@@ -25860,7 +25917,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
25860
25917
|
const textLength = getToolResultTextLength(msg);
|
|
25861
25918
|
if (textLength > maxChars) {
|
|
25862
25919
|
oversizedIndices.push(i);
|
|
25863
|
-
log$
|
|
25920
|
+
log$7.info(`[tool-result-truncation] Found oversized tool result: entry=${entry.id} chars=${textLength} maxChars=${maxChars} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
25864
25921
|
}
|
|
25865
25922
|
}
|
|
25866
25923
|
if (oversizedIndices.length === 0) return {
|
|
@@ -25882,7 +25939,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
25882
25939
|
message = truncateToolResultMessage(message, maxChars);
|
|
25883
25940
|
truncatedCount++;
|
|
25884
25941
|
const newLength = getToolResultTextLength(message);
|
|
25885
|
-
log$
|
|
25942
|
+
log$7.info(`[tool-result-truncation] Truncated tool result: originalEntry=${entry.id} newChars=${newLength} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
25886
25943
|
}
|
|
25887
25944
|
sessionManager.appendMessage(message);
|
|
25888
25945
|
} else if (entry.type === "compaction") sessionManager.appendCompaction(entry.summary, entry.firstKeptEntryId, entry.tokensBefore, entry.details, entry.fromHook);
|
|
@@ -25896,14 +25953,14 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
25896
25953
|
if (entry.name) sessionManager.appendSessionInfo(entry.name);
|
|
25897
25954
|
}
|
|
25898
25955
|
}
|
|
25899
|
-
log$
|
|
25956
|
+
log$7.info(`[tool-result-truncation] Truncated ${truncatedCount} tool result(s) in session (contextWindow=${contextWindowTokens} maxChars=${maxChars}) sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
25900
25957
|
return {
|
|
25901
25958
|
truncated: true,
|
|
25902
25959
|
truncatedCount
|
|
25903
25960
|
};
|
|
25904
25961
|
} catch (err) {
|
|
25905
25962
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
25906
|
-
log$
|
|
25963
|
+
log$7.warn(`[tool-result-truncation] Failed to truncate: ${errMsg}`);
|
|
25907
25964
|
return {
|
|
25908
25965
|
truncated: false,
|
|
25909
25966
|
truncatedCount: 0,
|
|
@@ -27679,7 +27736,7 @@ function resolveAnthropicBetas(extraParams, provider, modelId) {
|
|
|
27679
27736
|
for (const beta of configured) if (typeof beta === "string" && beta.trim()) betas.add(beta.trim());
|
|
27680
27737
|
}
|
|
27681
27738
|
if (extraParams?.context1m === true) if (isAnthropic1MModel(modelId)) betas.add(ANTHROPIC_CONTEXT_1M_BETA);
|
|
27682
|
-
else log$
|
|
27739
|
+
else log$7.warn(`ignoring context1m for non-opus/sonnet model: ${provider}/${modelId}`);
|
|
27683
27740
|
return betas.size > 0 ? [...betas] : void 0;
|
|
27684
27741
|
}
|
|
27685
27742
|
function mergeAnthropicBetaHeader(headers, betas) {
|
|
@@ -28290,14 +28347,14 @@ function logToolSchemasForGoogle(params) {
|
|
|
28290
28347
|
if (params.provider !== "google-antigravity" && params.provider !== "google-gemini-cli") return;
|
|
28291
28348
|
const toolNames = params.tools.map((tool, index) => `${index}:${tool.name}`);
|
|
28292
28349
|
const tools = sanitizeToolsForGoogle(params);
|
|
28293
|
-
log$
|
|
28350
|
+
log$7.info("google tool schema snapshot", {
|
|
28294
28351
|
provider: params.provider,
|
|
28295
28352
|
toolCount: tools.length,
|
|
28296
28353
|
tools: toolNames
|
|
28297
28354
|
});
|
|
28298
28355
|
for (const [index, tool] of tools.entries()) {
|
|
28299
28356
|
const violations = findUnsupportedSchemaKeywords(tool.parameters, `${tool.name}.parameters`);
|
|
28300
|
-
if (violations.length > 0) log$
|
|
28357
|
+
if (violations.length > 0) log$7.warn("google tool schema has unsupported keywords", {
|
|
28301
28358
|
index,
|
|
28302
28359
|
tool: tool.name,
|
|
28303
28360
|
violations: violations.slice(0, 12),
|
|
@@ -28309,7 +28366,7 @@ const compactionFailureEmitter = new EventEmitter();
|
|
|
28309
28366
|
registerUnhandledRejectionHandler((reason) => {
|
|
28310
28367
|
const message = describeUnknownError(reason);
|
|
28311
28368
|
if (!isCompactionFailureError(message)) return false;
|
|
28312
|
-
log$
|
|
28369
|
+
log$7.error(`Auto-compaction failed (unhandled): ${message}`);
|
|
28313
28370
|
compactionFailureEmitter.emit("failure", message);
|
|
28314
28371
|
return true;
|
|
28315
28372
|
});
|
|
@@ -28361,7 +28418,7 @@ function applyGoogleTurnOrderingFix(params) {
|
|
|
28361
28418
|
const sanitized = sanitizeGoogleTurnOrdering(params.messages);
|
|
28362
28419
|
const didPrepend = sanitized !== params.messages;
|
|
28363
28420
|
if (didPrepend && !hasGoogleTurnOrderingMarker(params.sessionManager)) {
|
|
28364
|
-
(params.warn ?? ((message) => log$
|
|
28421
|
+
(params.warn ?? ((message) => log$7.warn(message)))(`google turn ordering fixup: prepended user bootstrap (sessionId=${params.sessionId})`);
|
|
28365
28422
|
markGoogleTurnOrderingMarker(params.sessionManager);
|
|
28366
28423
|
}
|
|
28367
28424
|
return {
|
|
@@ -28984,7 +29041,7 @@ function isImageExtension(filePath) {
|
|
|
28984
29041
|
}
|
|
28985
29042
|
async function sanitizeImagesWithLog(images, label, imageSanitization) {
|
|
28986
29043
|
const { images: sanitized, dropped } = await sanitizeImageBlocks(images, label, imageSanitization);
|
|
28987
|
-
if (dropped > 0) log$
|
|
29044
|
+
if (dropped > 0) log$7.warn(`Native image: dropped ${dropped} image(s) after sanitization (${label}).`);
|
|
28988
29045
|
return sanitized;
|
|
28989
29046
|
}
|
|
28990
29047
|
/**
|
|
@@ -29059,7 +29116,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
29059
29116
|
try {
|
|
29060
29117
|
let targetPath = ref.resolved;
|
|
29061
29118
|
if (ref.type === "url") {
|
|
29062
|
-
log$
|
|
29119
|
+
log$7.debug(`Native image: rejecting remote URL (local-only): ${ref.resolved}`);
|
|
29063
29120
|
return null;
|
|
29064
29121
|
}
|
|
29065
29122
|
if (ref.type === "path") {
|
|
@@ -29069,7 +29126,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
29069
29126
|
cwd: options.sandbox.root
|
|
29070
29127
|
}).hostPath;
|
|
29071
29128
|
} catch (err) {
|
|
29072
|
-
log$
|
|
29129
|
+
log$7.debug(`Native image: sandbox validation failed for ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
29073
29130
|
return null;
|
|
29074
29131
|
}
|
|
29075
29132
|
else if (!path.isAbsolute(targetPath)) targetPath = path.resolve(workspaceDir, targetPath);
|
|
@@ -29083,7 +29140,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
29083
29140
|
})
|
|
29084
29141
|
}) : await loadWebMedia(targetPath, options?.maxBytes);
|
|
29085
29142
|
if (media.kind !== "image") {
|
|
29086
|
-
log$
|
|
29143
|
+
log$7.debug(`Native image: not an image file: ${targetPath} (got ${media.kind})`);
|
|
29087
29144
|
return null;
|
|
29088
29145
|
}
|
|
29089
29146
|
const mimeType = media.contentType ?? "image/jpeg";
|
|
@@ -29093,7 +29150,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
29093
29150
|
mimeType
|
|
29094
29151
|
};
|
|
29095
29152
|
} catch (err) {
|
|
29096
|
-
log$
|
|
29153
|
+
log$7.debug(`Native image: failed to load ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
29097
29154
|
return null;
|
|
29098
29155
|
}
|
|
29099
29156
|
}
|
|
@@ -29192,7 +29249,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
29192
29249
|
loadedCount: 0,
|
|
29193
29250
|
skippedCount: 0
|
|
29194
29251
|
};
|
|
29195
|
-
log$
|
|
29252
|
+
log$7.debug(`Native image: detected ${allRefs.length} image refs (${promptRefs.length} in prompt, ${uniqueHistoryRefs.length} in history)`);
|
|
29196
29253
|
const promptImages = [...params.existingImages ?? []];
|
|
29197
29254
|
const historyImagesByIndex = /* @__PURE__ */ new Map();
|
|
29198
29255
|
let loadedCount = 0;
|
|
@@ -29209,7 +29266,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
29209
29266
|
else historyImagesByIndex.set(ref.messageIndex, [image]);
|
|
29210
29267
|
} else promptImages.push(image);
|
|
29211
29268
|
loadedCount++;
|
|
29212
|
-
log$
|
|
29269
|
+
log$7.debug(`Native image: loaded ${ref.type} ${ref.resolved}`);
|
|
29213
29270
|
} else skippedCount++;
|
|
29214
29271
|
}
|
|
29215
29272
|
const imageSanitization = { maxDimensionPx: params.maxDimensionPx };
|
|
@@ -29305,7 +29362,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
29305
29362
|
const resolvedWorkspace = resolveUserPath(params.workspaceDir);
|
|
29306
29363
|
const prevCwd = process.cwd();
|
|
29307
29364
|
const runAbortController = new AbortController();
|
|
29308
|
-
log$
|
|
29365
|
+
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"}`);
|
|
29309
29366
|
await fs$1.mkdir(resolvedWorkspace, { recursive: true });
|
|
29310
29367
|
const sandboxSessionKey = params.sessionKey?.trim() || params.sessionId;
|
|
29311
29368
|
const sandbox = await resolveSandboxContext({
|
|
@@ -29341,7 +29398,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
29341
29398
|
sessionId: params.sessionId,
|
|
29342
29399
|
warn: makeBootstrapWarn({
|
|
29343
29400
|
sessionLabel,
|
|
29344
|
-
warn: (message) => log$
|
|
29401
|
+
warn: (message) => log$7.warn(message)
|
|
29345
29402
|
})
|
|
29346
29403
|
});
|
|
29347
29404
|
const workspaceNotes = hookAdjustedBootstrapFiles.some((file) => file.name === DEFAULT_BOOTSTRAP_FILENAME && !file.missing) ? ["Reminder: commit your changes in this workspace after edits."] : void 0;
|
|
@@ -29540,7 +29597,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
29540
29597
|
try {
|
|
29541
29598
|
await repairSessionFileIfNeeded({
|
|
29542
29599
|
sessionFile: params.sessionFile,
|
|
29543
|
-
warn: (message) => log$
|
|
29600
|
+
warn: (message) => log$7.warn(message)
|
|
29544
29601
|
});
|
|
29545
29602
|
const hadSessionFile = await fs$1.stat(params.sessionFile).then(() => true).catch(() => false);
|
|
29546
29603
|
const transcriptPolicy = resolveTranscriptPolicy({
|
|
@@ -29549,7 +29606,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
29549
29606
|
modelId: params.modelId
|
|
29550
29607
|
});
|
|
29551
29608
|
const versionCheck = await handleSessionVersion(params.sessionFile);
|
|
29552
|
-
if (versionCheck.archived) log$
|
|
29609
|
+
if (versionCheck.archived) log$7.warn(`session archived: created by ${versionCheck.poisonVersion}, known corruption range → ${versionCheck.archivePath}`);
|
|
29553
29610
|
await prewarmSessionFile(params.sessionFile);
|
|
29554
29611
|
sessionManager = guardSessionManager(SessionManager.open(params.sessionFile), {
|
|
29555
29612
|
agentId: sessionAgentId,
|
|
@@ -29801,6 +29858,9 @@ async function runEmbeddedAttempt(params) {
|
|
|
29801
29858
|
});
|
|
29802
29859
|
};
|
|
29803
29860
|
const streamMonitor = createStreamMonitor(modelProfile);
|
|
29861
|
+
const TOOL_ERROR_ABORT_THRESHOLD = 5;
|
|
29862
|
+
const TOOL_ERROR_WARN_THRESHOLD = 3;
|
|
29863
|
+
let consecutiveToolErrors = 0;
|
|
29804
29864
|
const subscription = subscribeEmbeddedPiSession({
|
|
29805
29865
|
session: activeSession,
|
|
29806
29866
|
runId: params.runId,
|
|
@@ -29822,9 +29882,25 @@ async function runEmbeddedAttempt(params) {
|
|
|
29822
29882
|
onAgentEvent: (evt) => {
|
|
29823
29883
|
armSymipulseTimer();
|
|
29824
29884
|
params.onAgentEvent?.(evt);
|
|
29885
|
+
if (evt.stream === "tool" && !aborted) {
|
|
29886
|
+
const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
|
|
29887
|
+
const isError = evt.data?.isError === true;
|
|
29888
|
+
if (phase === "result") {
|
|
29889
|
+
if (isError) consecutiveToolErrors++;
|
|
29890
|
+
else consecutiveToolErrors = 0;
|
|
29891
|
+
if (consecutiveToolErrors >= TOOL_ERROR_ABORT_THRESHOLD) {
|
|
29892
|
+
const toolName = typeof evt.data?.name === "string" ? evt.data.name : "unknown";
|
|
29893
|
+
log$7.error(`Agent-loop circuit breaker: ${consecutiveToolErrors} consecutive tool errors (last: ${toolName}). Aborting run ${params.runId}.`);
|
|
29894
|
+
abortRun(false, /* @__PURE__ */ new Error(`${consecutiveToolErrors} consecutive tool errors. The model may be generating corrupted tool arguments. Run aborted to prevent infinite loop.`));
|
|
29895
|
+
} else if (consecutiveToolErrors === TOOL_ERROR_WARN_THRESHOLD) {
|
|
29896
|
+
const toolName = typeof evt.data?.name === "string" ? evt.data.name : "unknown";
|
|
29897
|
+
log$7.warn(`Agent-loop tool error warning: ${consecutiveToolErrors} consecutive failures (last: ${toolName}). runId=${params.runId}`);
|
|
29898
|
+
}
|
|
29899
|
+
}
|
|
29900
|
+
}
|
|
29825
29901
|
if (evt.stream === "assistant" && typeof evt.data?.text === "string" && !aborted) {
|
|
29826
29902
|
streamMonitor.onChunk(evt.data.text);
|
|
29827
|
-
if (streamMonitor.shouldStop()) log$
|
|
29903
|
+
if (streamMonitor.shouldStop()) log$7.debug(`stream monitor detection (log-only, no abort): runId=${params.runId} reason=${streamMonitor.getStopReason()}`);
|
|
29828
29904
|
}
|
|
29829
29905
|
},
|
|
29830
29906
|
enforceFinalTag: params.enforceFinalTag,
|
|
@@ -29844,7 +29920,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
29844
29920
|
let abortWarnTimer;
|
|
29845
29921
|
const isProbeSession = params.sessionId?.startsWith("probe-") ?? false;
|
|
29846
29922
|
const abortTimer = setTimeout(() => {
|
|
29847
|
-
if (!isProbeSession) log$
|
|
29923
|
+
if (!isProbeSession) log$7.warn(`embedded run timeout: runId=${params.runId} sessionId=${params.sessionId} timeoutMs=${params.timeoutMs}`);
|
|
29848
29924
|
if (shouldFlagCompactionTimeout({
|
|
29849
29925
|
isTimeout: true,
|
|
29850
29926
|
isCompactionPendingOrRetrying: subscription.isCompacting(),
|
|
@@ -29853,7 +29929,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
29853
29929
|
abortRun(true);
|
|
29854
29930
|
if (!abortWarnTimer) abortWarnTimer = setTimeout(() => {
|
|
29855
29931
|
if (!activeSession.isStreaming) return;
|
|
29856
|
-
if (!isProbeSession) log$
|
|
29932
|
+
if (!isProbeSession) log$7.warn(`embedded run abort still streaming: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
29857
29933
|
}, 1e4);
|
|
29858
29934
|
}, Math.max(1, params.timeoutMs));
|
|
29859
29935
|
armSymipulseTimer = () => {
|
|
@@ -29861,7 +29937,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
29861
29937
|
clearSymipulseTimer();
|
|
29862
29938
|
symipulseTimer = setTimeout(() => {
|
|
29863
29939
|
if (aborted) return;
|
|
29864
|
-
if (!isProbeSession) log$
|
|
29940
|
+
if (!isProbeSession) log$7.warn(`symipulse timeout: runId=${params.runId} sessionId=${params.sessionId} symipulseMs=${symipulseMs} (no activity)`);
|
|
29865
29941
|
if (shouldFlagCompactionTimeout({
|
|
29866
29942
|
isTimeout: true,
|
|
29867
29943
|
isCompactionPendingOrRetrying: subscription.isCompacting(),
|
|
@@ -29905,13 +29981,13 @@ async function runEmbeddedAttempt(params) {
|
|
|
29905
29981
|
prompt: params.prompt,
|
|
29906
29982
|
messages: activeSession.messages
|
|
29907
29983
|
}, hookCtx).catch((hookErr) => {
|
|
29908
|
-
log$
|
|
29984
|
+
log$7.warn(`before_prompt_build hook failed: ${String(hookErr)}`);
|
|
29909
29985
|
}) : void 0;
|
|
29910
29986
|
const legacyResult = hookRunner?.hasHooks("before_agent_start") ? await hookRunner.runBeforeAgentStart({
|
|
29911
29987
|
prompt: params.prompt,
|
|
29912
29988
|
messages: activeSession.messages
|
|
29913
29989
|
}, hookCtx).catch((hookErr) => {
|
|
29914
|
-
log$
|
|
29990
|
+
log$7.warn(`before_agent_start hook (legacy prompt build path) failed: ${String(hookErr)}`);
|
|
29915
29991
|
}) : void 0;
|
|
29916
29992
|
const hookResult = {
|
|
29917
29993
|
systemPrompt: promptBuildResult?.systemPrompt ?? legacyResult?.systemPrompt,
|
|
@@ -29919,7 +29995,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
29919
29995
|
};
|
|
29920
29996
|
if (hookResult?.prependContext) {
|
|
29921
29997
|
effectivePrompt = `${hookResult.prependContext}\n\n${params.prompt}`;
|
|
29922
|
-
log$
|
|
29998
|
+
log$7.debug(`hooks: prepended context to prompt (${hookResult.prependContext.length} chars)`);
|
|
29923
29999
|
}
|
|
29924
30000
|
{
|
|
29925
30001
|
const autoRecallAgentId = normalizeAgentId(params.sessionKey);
|
|
@@ -29936,11 +30012,11 @@ async function runEmbeddedAttempt(params) {
|
|
|
29936
30012
|
if (recallResults.length > 0) {
|
|
29937
30013
|
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>`;
|
|
29938
30014
|
effectivePrompt = `${recallBlock}\n\n${effectivePrompt}`;
|
|
29939
|
-
log$
|
|
30015
|
+
log$7.debug(`auto-recall: injected ${recallResults.length} snippets (${recallBlock.length} chars)`);
|
|
29940
30016
|
}
|
|
29941
30017
|
}
|
|
29942
30018
|
} catch (recallErr) {
|
|
29943
|
-
log$
|
|
30019
|
+
log$7.debug(`auto-recall: skipped (${String(recallErr)})`);
|
|
29944
30020
|
}
|
|
29945
30021
|
}
|
|
29946
30022
|
{
|
|
@@ -29952,10 +30028,10 @@ async function runEmbeddedAttempt(params) {
|
|
|
29952
30028
|
if (planResult.enter) {
|
|
29953
30029
|
if (planResult.stripped != null) effectivePrompt = planResult.stripped;
|
|
29954
30030
|
effectivePrompt = `${PLAN_MODE_SYSTEM_PROMPT}\n\n${effectivePrompt}`;
|
|
29955
|
-
log$
|
|
30031
|
+
log$7.info(`plan-mode: activated (${planResult.reason}) for runId=${params.runId}`);
|
|
29956
30032
|
} else if (planResult.stripped != null) effectivePrompt = planResult.stripped;
|
|
29957
30033
|
}
|
|
29958
|
-
log$
|
|
30034
|
+
log$7.debug(`embedded run prompt start: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
29959
30035
|
cacheTrace?.recordStage("prompt:before", {
|
|
29960
30036
|
prompt: effectivePrompt,
|
|
29961
30037
|
messages: activeSession.messages
|
|
@@ -29967,7 +30043,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
29967
30043
|
const sessionContext = sessionManager.buildSessionContext();
|
|
29968
30044
|
const sanitizedOrphan = transcriptPolicy.sanitizeThinkingSignatures ? sanitizeAntigravityThinkingBlocks(sessionContext.messages) : sessionContext.messages;
|
|
29969
30045
|
activeSession.agent.replaceMessages(sanitizedOrphan);
|
|
29970
|
-
log$
|
|
30046
|
+
log$7.warn(`Removed orphaned user message to prevent consecutive user turns. runId=${params.runId} sessionId=${params.sessionId}`);
|
|
29971
30047
|
}
|
|
29972
30048
|
try {
|
|
29973
30049
|
const imageResult = await detectAndLoadPromptImages({
|
|
@@ -29989,12 +30065,12 @@ async function runEmbeddedAttempt(params) {
|
|
|
29989
30065
|
messages: activeSession.messages,
|
|
29990
30066
|
note: `images: prompt=${imageResult.images.length} history=${imageResult.historyImagesByIndex.size}`
|
|
29991
30067
|
});
|
|
29992
|
-
if (log$
|
|
30068
|
+
if (log$7.isEnabled("debug")) {
|
|
29993
30069
|
const msgCount = activeSession.messages.length;
|
|
29994
30070
|
const systemLen = systemPromptText?.length ?? 0;
|
|
29995
30071
|
const promptLen = effectivePrompt.length;
|
|
29996
30072
|
const sessionSummary = summarizeSessionContext(activeSession.messages);
|
|
29997
|
-
log$
|
|
30073
|
+
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}`);
|
|
29998
30074
|
}
|
|
29999
30075
|
if (hookRunner?.hasHooks("llm_input")) hookRunner.runLlmInput({
|
|
30000
30076
|
runId: params.runId,
|
|
@@ -30012,7 +30088,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
30012
30088
|
workspaceDir: params.workspaceDir,
|
|
30013
30089
|
messageProvider: params.messageProvider ?? void 0
|
|
30014
30090
|
}).catch((err) => {
|
|
30015
|
-
log$
|
|
30091
|
+
log$7.warn(`llm_input hook failed: ${String(err)}`);
|
|
30016
30092
|
});
|
|
30017
30093
|
if (imageResult.images.length > 0) await abortable(activeSession.prompt(effectivePrompt, { images: imageResult.images }));
|
|
30018
30094
|
else await abortable(activeSession.prompt(effectivePrompt));
|
|
@@ -30020,7 +30096,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
30020
30096
|
promptError = err;
|
|
30021
30097
|
promptErrorSource = "prompt";
|
|
30022
30098
|
} finally {
|
|
30023
|
-
log$
|
|
30099
|
+
log$7.debug(`embedded run prompt end: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - promptStartedAt}`);
|
|
30024
30100
|
}
|
|
30025
30101
|
const wasCompactingBefore = activeSession.isCompacting;
|
|
30026
30102
|
const snapshot = activeSession.messages.slice();
|
|
@@ -30035,7 +30111,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
30035
30111
|
promptError = err;
|
|
30036
30112
|
promptErrorSource = "compaction";
|
|
30037
30113
|
}
|
|
30038
|
-
if (!isProbeSession) log$
|
|
30114
|
+
if (!isProbeSession) log$7.debug(`compaction wait aborted: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
30039
30115
|
} else throw err;
|
|
30040
30116
|
}
|
|
30041
30117
|
if (!timedOutDuringCompaction) {
|
|
@@ -30053,7 +30129,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
30053
30129
|
currentSessionId: activeSession.sessionId
|
|
30054
30130
|
});
|
|
30055
30131
|
if (timedOutDuringCompaction) {
|
|
30056
|
-
if (!isProbeSession) log$
|
|
30132
|
+
if (!isProbeSession) log$7.warn(`using ${snapshotSelection.source} snapshot: timed out during compaction runId=${params.runId} sessionId=${params.sessionId}`);
|
|
30057
30133
|
}
|
|
30058
30134
|
messagesSnapshot = snapshotSelection.messagesSnapshot;
|
|
30059
30135
|
sessionIdUsed = snapshotSelection.sessionIdUsed;
|
|
@@ -30068,7 +30144,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
30068
30144
|
error: describeUnknownError(promptError)
|
|
30069
30145
|
});
|
|
30070
30146
|
} catch (entryErr) {
|
|
30071
|
-
log$
|
|
30147
|
+
log$7.warn(`failed to persist prompt error entry: ${String(entryErr)}`);
|
|
30072
30148
|
}
|
|
30073
30149
|
cacheTrace?.recordStage("session:after", {
|
|
30074
30150
|
messages: messagesSnapshot,
|
|
@@ -30087,17 +30163,17 @@ async function runEmbeddedAttempt(params) {
|
|
|
30087
30163
|
workspaceDir: params.workspaceDir,
|
|
30088
30164
|
messageProvider: params.messageProvider ?? void 0
|
|
30089
30165
|
}).catch((err) => {
|
|
30090
|
-
log$
|
|
30166
|
+
log$7.warn(`agent_end hook failed: ${err}`);
|
|
30091
30167
|
});
|
|
30092
30168
|
} finally {
|
|
30093
30169
|
clearTimeout(abortTimer);
|
|
30094
30170
|
clearSymipulseTimer();
|
|
30095
30171
|
if (abortWarnTimer) clearTimeout(abortWarnTimer);
|
|
30096
|
-
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$
|
|
30172
|
+
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$7.debug(`run cleanup: runId=${params.runId} sessionId=${params.sessionId} aborted=${aborted} timedOut=${timedOut}`);
|
|
30097
30173
|
try {
|
|
30098
30174
|
unsubscribe();
|
|
30099
30175
|
} catch (err) {
|
|
30100
|
-
log$
|
|
30176
|
+
log$7.error(`CRITICAL: unsubscribe failed, possible resource leak: runId=${params.runId} ${String(err)}`);
|
|
30101
30177
|
}
|
|
30102
30178
|
clearActiveEmbeddedRun(params.sessionId, queueHandle, params.sessionKey);
|
|
30103
30179
|
params.abortSignal?.removeEventListener?.("abort", onAbort);
|
|
@@ -30122,7 +30198,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
30122
30198
|
workspaceDir: params.workspaceDir,
|
|
30123
30199
|
messageProvider: params.messageProvider ?? void 0
|
|
30124
30200
|
}).catch((err) => {
|
|
30125
|
-
log$
|
|
30201
|
+
log$7.warn(`llm_output hook failed: ${String(err)}`);
|
|
30126
30202
|
});
|
|
30127
30203
|
return {
|
|
30128
30204
|
aborted,
|
|
@@ -30383,7 +30459,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30383
30459
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
30384
30460
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
30385
30461
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
30386
|
-
if (workspaceResolution.usedFallback) log$
|
|
30462
|
+
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}`);
|
|
30387
30463
|
const prevCwd = process.cwd();
|
|
30388
30464
|
let provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
30389
30465
|
let modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
@@ -30402,7 +30478,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30402
30478
|
if (hookRunner?.hasHooks("before_model_resolve")) try {
|
|
30403
30479
|
modelResolveOverride = await hookRunner.runBeforeModelResolve({ prompt: params.prompt }, hookCtx);
|
|
30404
30480
|
} catch (hookErr) {
|
|
30405
|
-
log$
|
|
30481
|
+
log$7.warn(`before_model_resolve hook failed: ${String(hookErr)}`);
|
|
30406
30482
|
}
|
|
30407
30483
|
if (hookRunner?.hasHooks("before_agent_start")) try {
|
|
30408
30484
|
const legacyResult = await hookRunner.runBeforeAgentStart({ prompt: params.prompt }, hookCtx);
|
|
@@ -30411,15 +30487,15 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30411
30487
|
modelOverride: modelResolveOverride?.modelOverride ?? legacyResult?.modelOverride
|
|
30412
30488
|
};
|
|
30413
30489
|
} catch (hookErr) {
|
|
30414
|
-
log$
|
|
30490
|
+
log$7.warn(`before_agent_start hook (legacy model resolve path) failed: ${String(hookErr)}`);
|
|
30415
30491
|
}
|
|
30416
30492
|
if (modelResolveOverride?.providerOverride) {
|
|
30417
30493
|
provider = modelResolveOverride.providerOverride;
|
|
30418
|
-
log$
|
|
30494
|
+
log$7.info(`[hooks] provider overridden to ${provider}`);
|
|
30419
30495
|
}
|
|
30420
30496
|
if (modelResolveOverride?.modelOverride) {
|
|
30421
30497
|
modelId = modelResolveOverride.modelOverride;
|
|
30422
|
-
log$
|
|
30498
|
+
log$7.info(`[hooks] model overridden to ${modelId}`);
|
|
30423
30499
|
}
|
|
30424
30500
|
const { model, error, authStorage, modelRegistry } = resolveModel(provider, modelId, agentDir, params.config);
|
|
30425
30501
|
if (!model) throw new FailoverError(error ?? `Unknown model: ${provider}/${modelId}`, {
|
|
@@ -30439,9 +30515,9 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30439
30515
|
warnBelowTokens: CONTEXT_WINDOW_WARN_BELOW_TOKENS,
|
|
30440
30516
|
hardMinTokens: CONTEXT_WINDOW_HARD_MIN_TOKENS
|
|
30441
30517
|
});
|
|
30442
|
-
if (ctxGuard.shouldWarn) log$
|
|
30518
|
+
if (ctxGuard.shouldWarn) log$7.warn(`low context window: ${provider}/${modelId} ctx=${ctxGuard.tokens} (warn<${CONTEXT_WINDOW_WARN_BELOW_TOKENS}) source=${ctxGuard.source}`);
|
|
30443
30519
|
if (ctxGuard.shouldBlock) {
|
|
30444
|
-
log$
|
|
30520
|
+
log$7.error(`blocked model (context window too small): ${provider}/${modelId} ctx=${ctxGuard.tokens} (min=${CONTEXT_WINDOW_HARD_MIN_TOKENS}) source=${ctxGuard.source}`);
|
|
30445
30521
|
throw new FailoverError(`Model context window too small (${ctxGuard.tokens} tokens). Minimum is ${CONTEXT_WINDOW_HARD_MIN_TOKENS}.`, {
|
|
30446
30522
|
reason: "unknown",
|
|
30447
30523
|
provider,
|
|
@@ -30571,7 +30647,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30571
30647
|
while (true) {
|
|
30572
30648
|
if (runLoopIterations >= MAX_RUN_LOOP_ITERATIONS) {
|
|
30573
30649
|
const message = `Exceeded retry limit after ${runLoopIterations} attempts (max=${MAX_RUN_LOOP_ITERATIONS}).`;
|
|
30574
|
-
log$
|
|
30650
|
+
log$7.error(`[run-retry-limit] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} attempts=${runLoopIterations} maxAttempts=${MAX_RUN_LOOP_ITERATIONS}`);
|
|
30575
30651
|
return {
|
|
30576
30652
|
payloads: [{
|
|
30577
30653
|
text: "Request failed after repeated internal retries. Please try again, or use /new to start a fresh session.",
|
|
@@ -30692,18 +30768,18 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30692
30768
|
const overflowDiagId = createCompactionDiagId$1();
|
|
30693
30769
|
const errorText = contextOverflowError.text;
|
|
30694
30770
|
const msgCount = attempt.messagesSnapshot?.length ?? 0;
|
|
30695
|
-
log$
|
|
30771
|
+
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)}`);
|
|
30696
30772
|
const isCompactionFailure = isCompactionFailureError(errorText);
|
|
30697
30773
|
const hadAttemptLevelCompaction = attemptCompactionCount > 0;
|
|
30698
30774
|
if (!isCompactionFailure && hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
30699
30775
|
overflowCompactionAttempts++;
|
|
30700
|
-
log$
|
|
30776
|
+
log$7.warn(`context overflow persisted after in-attempt compaction (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); retrying prompt without additional compaction for ${provider}/${modelId}`);
|
|
30701
30777
|
continue;
|
|
30702
30778
|
}
|
|
30703
30779
|
if (!isCompactionFailure && !hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
30704
|
-
if (log$
|
|
30780
|
+
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}`);
|
|
30705
30781
|
overflowCompactionAttempts++;
|
|
30706
|
-
log$
|
|
30782
|
+
log$7.warn(`context overflow detected (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); attempting auto-compaction for ${provider}/${modelId}`);
|
|
30707
30783
|
const compactResult = await compactEmbeddedPiSessionDirect({
|
|
30708
30784
|
sessionId: params.sessionId,
|
|
30709
30785
|
sessionKey: params.sessionKey,
|
|
@@ -30732,10 +30808,10 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30732
30808
|
});
|
|
30733
30809
|
if (compactResult.compacted) {
|
|
30734
30810
|
autoCompactionCount += 1;
|
|
30735
|
-
log$
|
|
30811
|
+
log$7.info(`auto-compaction succeeded for ${provider}/${modelId}; retrying prompt`);
|
|
30736
30812
|
continue;
|
|
30737
30813
|
}
|
|
30738
|
-
log$
|
|
30814
|
+
log$7.warn(`auto-compaction failed for ${provider}/${modelId}: ${compactResult.reason ?? "nothing to compact"}`);
|
|
30739
30815
|
}
|
|
30740
30816
|
if (!toolResultTruncationAttempted) {
|
|
30741
30817
|
const contextWindowTokens = ctxInfo.tokens;
|
|
@@ -30744,9 +30820,9 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30744
30820
|
contextWindowTokens
|
|
30745
30821
|
}) : false;
|
|
30746
30822
|
if (hasOversized) {
|
|
30747
|
-
if (log$
|
|
30823
|
+
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}`);
|
|
30748
30824
|
toolResultTruncationAttempted = true;
|
|
30749
|
-
log$
|
|
30825
|
+
log$7.warn(`[context-overflow-recovery] Attempting tool result truncation for ${provider}/${modelId} (contextWindow=${contextWindowTokens} tokens)`);
|
|
30750
30826
|
const truncResult = await truncateOversizedToolResultsInSession({
|
|
30751
30827
|
sessionFile: params.sessionFile,
|
|
30752
30828
|
contextWindowTokens,
|
|
@@ -30754,13 +30830,13 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30754
30830
|
sessionKey: params.sessionKey
|
|
30755
30831
|
});
|
|
30756
30832
|
if (truncResult.truncated) {
|
|
30757
|
-
log$
|
|
30833
|
+
log$7.info(`[context-overflow-recovery] Truncated ${truncResult.truncatedCount} tool result(s); retrying prompt`);
|
|
30758
30834
|
continue;
|
|
30759
30835
|
}
|
|
30760
|
-
log$
|
|
30761
|
-
} else if (log$
|
|
30836
|
+
log$7.warn(`[context-overflow-recovery] Tool result truncation did not help: ${truncResult.reason ?? "unknown"}`);
|
|
30837
|
+
} 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}`);
|
|
30762
30838
|
}
|
|
30763
|
-
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$
|
|
30839
|
+
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}`);
|
|
30764
30840
|
const kind = isCompactionFailure ? "compaction_failure" : "context_overflow";
|
|
30765
30841
|
return {
|
|
30766
30842
|
payloads: [{
|
|
@@ -30841,7 +30917,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30841
30917
|
attempted: attemptedThinking
|
|
30842
30918
|
});
|
|
30843
30919
|
if (fallbackThinking) {
|
|
30844
|
-
log$
|
|
30920
|
+
log$7.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
30845
30921
|
thinkLevel = fallbackThinking;
|
|
30846
30922
|
continue;
|
|
30847
30923
|
}
|
|
@@ -30859,7 +30935,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30859
30935
|
attempted: attemptedThinking
|
|
30860
30936
|
});
|
|
30861
30937
|
if (fallbackThinking && !aborted) {
|
|
30862
|
-
log$
|
|
30938
|
+
log$7.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
30863
30939
|
thinkLevel = fallbackThinking;
|
|
30864
30940
|
continue;
|
|
30865
30941
|
}
|
|
@@ -30876,7 +30952,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30876
30952
|
imageDimensionError.contentIndex !== void 0 ? `content=${imageDimensionError.contentIndex}` : null,
|
|
30877
30953
|
imageDimensionError.maxDimensionPx !== void 0 ? `limit=${imageDimensionError.maxDimensionPx}px` : null
|
|
30878
30954
|
].filter(Boolean).join(" ");
|
|
30879
|
-
log$
|
|
30955
|
+
log$7.warn(`Profile ${lastProfileId} rejected image payload${details ? ` (${details})` : ""}.`);
|
|
30880
30956
|
}
|
|
30881
30957
|
const isLocalOllamaTimeout = timedOut && model.api === "ollama";
|
|
30882
30958
|
if (!aborted && failoverFailure || timedOut && !timedOutDuringCompaction && !isLocalOllamaTimeout) {
|
|
@@ -30888,8 +30964,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30888
30964
|
cfg: params.config,
|
|
30889
30965
|
agentDir: params.agentDir
|
|
30890
30966
|
});
|
|
30891
|
-
if (timedOut && !isProbeSession) log$
|
|
30892
|
-
if (cloudCodeAssistFormatError) log$
|
|
30967
|
+
if (timedOut && !isProbeSession) log$7.warn(`Profile ${lastProfileId} timed out (possible rate limit). Trying next account...`);
|
|
30968
|
+
if (cloudCodeAssistFormatError) log$7.warn(`Profile ${lastProfileId} hit Cloud Code Assist format error. Tool calls will be sanitized on retry.`);
|
|
30893
30969
|
}
|
|
30894
30970
|
if (await advanceAuthProfile()) continue;
|
|
30895
30971
|
if (fallbackConfigured) {
|
|
@@ -30955,7 +31031,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
30955
31031
|
const hasCodeBlocks = attempt.assistantTexts.some((text) => /```[\s\S]*?```/.test(text));
|
|
30956
31032
|
if (hasCodeToolUsage || hasCodeBlocks) {
|
|
30957
31033
|
verificationPassCompleted = true;
|
|
30958
|
-
log$
|
|
31034
|
+
log$7.debug(`[verification] starting verification pass: runId=${params.runId} sessionId=${params.sessionId} trigger=${hasCodeToolUsage ? "tool_usage" : "code_blocks"}`);
|
|
30959
31035
|
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.";
|
|
30960
31036
|
try {
|
|
30961
31037
|
const verifyAttempt = await runEmbeddedAttempt({
|
|
@@ -31041,10 +31117,10 @@ async function runEmbeddedPiAgent(params) {
|
|
|
31041
31117
|
payloads.length = 0;
|
|
31042
31118
|
payloads.push(...verifyPayloads);
|
|
31043
31119
|
}
|
|
31044
|
-
log$
|
|
31045
|
-
} else log$
|
|
31120
|
+
log$7.debug(`[verification] verification produced corrections: runId=${params.runId} tools=${verifyAttempt.toolMetas.length} texts=${verifyAttempt.assistantTexts.length}`);
|
|
31121
|
+
} else log$7.debug(`[verification] verification confirmed original response: runId=${params.runId}`);
|
|
31046
31122
|
} catch (verifyErr) {
|
|
31047
|
-
log$
|
|
31123
|
+
log$7.warn(`[verification] verification pass failed, keeping original response: runId=${params.runId} error=${String(verifyErr)}`);
|
|
31048
31124
|
}
|
|
31049
31125
|
}
|
|
31050
31126
|
}
|
|
@@ -31065,7 +31141,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
31065
31141
|
messagingToolSentTargets: attempt.messagingToolSentTargets,
|
|
31066
31142
|
successfulCronAdds: attempt.successfulCronAdds
|
|
31067
31143
|
};
|
|
31068
|
-
log$
|
|
31144
|
+
log$7.debug(`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`);
|
|
31069
31145
|
if (lastProfileId) {
|
|
31070
31146
|
await markAuthProfileGood({
|
|
31071
31147
|
store: authStore,
|
|
@@ -31317,7 +31393,7 @@ async function runAgentTurn(params) {
|
|
|
31317
31393
|
function createDefaultDeps() {
|
|
31318
31394
|
return {
|
|
31319
31395
|
sendMessageWhatsApp: async (...args) => {
|
|
31320
|
-
const { sendMessageWhatsApp } = await import("./web-
|
|
31396
|
+
const { sendMessageWhatsApp } = await import("./web-DoRGusTq.js");
|
|
31321
31397
|
return await sendMessageWhatsApp(...args);
|
|
31322
31398
|
},
|
|
31323
31399
|
sendMessageTelegram: async (...args) => {
|
|
@@ -49748,7 +49824,7 @@ function loadWebLoginQr() {
|
|
|
49748
49824
|
return webLoginQrPromise;
|
|
49749
49825
|
}
|
|
49750
49826
|
function loadWebChannel() {
|
|
49751
|
-
webChannelPromise ??= import("./web-
|
|
49827
|
+
webChannelPromise ??= import("./web-DoRGusTq.js");
|
|
49752
49828
|
return webChannelPromise;
|
|
49753
49829
|
}
|
|
49754
49830
|
function loadWhatsAppActions() {
|
|
@@ -64599,7 +64675,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
64599
64675
|
const provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
64600
64676
|
const modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
64601
64677
|
const fail = (reason) => {
|
|
64602
|
-
log$
|
|
64678
|
+
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}`);
|
|
64603
64679
|
return {
|
|
64604
64680
|
ok: false,
|
|
64605
64681
|
compacted: false,
|
|
@@ -64667,7 +64743,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
64667
64743
|
sessionId: params.sessionId,
|
|
64668
64744
|
warn: makeBootstrapWarn({
|
|
64669
64745
|
sessionLabel,
|
|
64670
|
-
warn: (message) => log$
|
|
64746
|
+
warn: (message) => log$7.warn(message)
|
|
64671
64747
|
})
|
|
64672
64748
|
});
|
|
64673
64749
|
const runAbortController = new AbortController();
|
|
@@ -64807,7 +64883,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
64807
64883
|
try {
|
|
64808
64884
|
await repairSessionFileIfNeeded({
|
|
64809
64885
|
sessionFile: params.sessionFile,
|
|
64810
|
-
warn: (message) => log$
|
|
64886
|
+
warn: (message) => log$7.warn(message)
|
|
64811
64887
|
});
|
|
64812
64888
|
await prewarmSessionFile(params.sessionFile);
|
|
64813
64889
|
const transcriptPolicy = resolveTranscriptPolicy({
|
|
@@ -64892,13 +64968,13 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
64892
64968
|
messages: preCompactionMessages,
|
|
64893
64969
|
sessionFile: params.sessionFile
|
|
64894
64970
|
}, hookCtx).catch((hookErr) => {
|
|
64895
|
-
log$
|
|
64971
|
+
log$7.warn(`before_compaction hook failed: ${String(hookErr)}`);
|
|
64896
64972
|
});
|
|
64897
|
-
const diagEnabled = log$
|
|
64973
|
+
const diagEnabled = log$7.isEnabled("debug");
|
|
64898
64974
|
const preMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
64899
64975
|
if (diagEnabled && preMetrics) {
|
|
64900
|
-
log$
|
|
64901
|
-
log$
|
|
64976
|
+
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"}`);
|
|
64977
|
+
log$7.debug(`[compaction-diag] contributors diagId=${diagId} top=${JSON.stringify(preMetrics.contributors)}`);
|
|
64902
64978
|
}
|
|
64903
64979
|
const compactStartedAt = Date.now();
|
|
64904
64980
|
const result = await compactWithSafetyTimeout(() => session.compact(params.customInstructions));
|
|
@@ -64916,10 +64992,10 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
64916
64992
|
compactedCount: limited.length - session.messages.length,
|
|
64917
64993
|
sessionFile: params.sessionFile
|
|
64918
64994
|
}, hookCtx).catch((hookErr) => {
|
|
64919
|
-
log$
|
|
64995
|
+
log$7.warn(`after_compaction hook failed: ${hookErr}`);
|
|
64920
64996
|
});
|
|
64921
64997
|
const postMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
64922
|
-
if (diagEnabled && preMetrics && postMetrics) log$
|
|
64998
|
+
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"}`);
|
|
64923
64999
|
return {
|
|
64924
65000
|
ok: true,
|
|
64925
65001
|
compacted: true,
|