@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
|
@@ -10695,7 +10695,7 @@ function createRunRegistry(options) {
|
|
|
10695
10695
|
|
|
10696
10696
|
//#endregion
|
|
10697
10697
|
//#region src/process/supervisor/supervisor.ts
|
|
10698
|
-
const log$
|
|
10698
|
+
const log$8 = createSubsystemLogger("process/supervisor");
|
|
10699
10699
|
function clampTimeout(value) {
|
|
10700
10700
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return;
|
|
10701
10701
|
return Math.max(1, Math.floor(value));
|
|
@@ -10881,7 +10881,7 @@ function createProcessSupervisor() {
|
|
|
10881
10881
|
exitCode: null,
|
|
10882
10882
|
exitSignal: null
|
|
10883
10883
|
});
|
|
10884
|
-
log$
|
|
10884
|
+
log$8.warn(`spawn failed: runId=${runId} reason=${String(err)}`);
|
|
10885
10885
|
throw err;
|
|
10886
10886
|
}
|
|
10887
10887
|
};
|
|
@@ -28903,7 +28903,7 @@ async function resolveAnnounceTarget(params) {
|
|
|
28903
28903
|
|
|
28904
28904
|
//#endregion
|
|
28905
28905
|
//#region src/agents/tools/sessions-send-tool.a2a.ts
|
|
28906
|
-
const log$
|
|
28906
|
+
const log$7 = createSubsystemLogger("agents/sessions-send");
|
|
28907
28907
|
async function runSessionsSendA2AFlow(params) {
|
|
28908
28908
|
const runContextId = params.waitRunId ?? "unknown";
|
|
28909
28909
|
try {
|
|
@@ -28994,7 +28994,7 @@ async function runSessionsSendA2AFlow(params) {
|
|
|
28994
28994
|
timeoutMs: 1e4
|
|
28995
28995
|
});
|
|
28996
28996
|
} catch (err) {
|
|
28997
|
-
log$
|
|
28997
|
+
log$7.warn("sessions_send announce delivery failed", {
|
|
28998
28998
|
runId: runContextId,
|
|
28999
28999
|
channel: announceTarget.channel,
|
|
29000
29000
|
to: announceTarget.to,
|
|
@@ -29002,7 +29002,7 @@ async function runSessionsSendA2AFlow(params) {
|
|
|
29002
29002
|
});
|
|
29003
29003
|
}
|
|
29004
29004
|
} catch (err) {
|
|
29005
|
-
log$
|
|
29005
|
+
log$7.warn("sessions_send announce flow failed", {
|
|
29006
29006
|
runId: runContextId,
|
|
29007
29007
|
error: formatErrorMessage(err)
|
|
29008
29008
|
});
|
|
@@ -32032,7 +32032,7 @@ function resolveRunWorkspaceDir(params) {
|
|
|
32032
32032
|
|
|
32033
32033
|
//#endregion
|
|
32034
32034
|
//#region src/agents/cli-runner.ts
|
|
32035
|
-
const log$
|
|
32035
|
+
const log$6 = createSubsystemLogger("agent/claude-cli");
|
|
32036
32036
|
async function runCliAgent(params) {
|
|
32037
32037
|
const started = Date.now();
|
|
32038
32038
|
const workspaceResolution = resolveRunWorkspaceDir({
|
|
@@ -32045,7 +32045,7 @@ async function runCliAgent(params) {
|
|
|
32045
32045
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
32046
32046
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
32047
32047
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
32048
|
-
if (workspaceResolution.usedFallback) log$
|
|
32048
|
+
if (workspaceResolution.usedFallback) log$6.warn(`[workspace-fallback] caller=runCliAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
|
|
32049
32049
|
const workspaceDir = resolvedWorkspace;
|
|
32050
32050
|
const backendResolved = resolveCliBackendConfig(params.provider, params.config);
|
|
32051
32051
|
if (!backendResolved) throw new Error(`Unknown CLI backend: ${params.provider}`);
|
|
@@ -32062,7 +32062,7 @@ async function runCliAgent(params) {
|
|
|
32062
32062
|
sessionId: params.sessionId,
|
|
32063
32063
|
warn: makeBootstrapWarn({
|
|
32064
32064
|
sessionLabel,
|
|
32065
|
-
warn: (message) => log$
|
|
32065
|
+
warn: (message) => log$6.warn(message)
|
|
32066
32066
|
})
|
|
32067
32067
|
});
|
|
32068
32068
|
const { defaultAgentId, sessionAgentId } = resolveSessionAgentIds({
|
|
@@ -32128,7 +32128,7 @@ async function runCliAgent(params) {
|
|
|
32128
32128
|
const queueKey = backend.serialize ?? true ? backendResolved.id : `${backendResolved.id}:${params.runId}`;
|
|
32129
32129
|
try {
|
|
32130
32130
|
const output = await enqueueCliRun(queueKey, async () => {
|
|
32131
|
-
log$
|
|
32131
|
+
log$6.info(`cli exec: provider=${params.provider} model=${normalizedModel} promptChars=${params.prompt.length}`);
|
|
32132
32132
|
const logOutputText = isTruthyEnvValue(process.env.SYMI_CLAUDE_CLI_LOG_OUTPUT);
|
|
32133
32133
|
if (logOutputText) {
|
|
32134
32134
|
const logArgs = [];
|
|
@@ -32161,7 +32161,7 @@ async function runCliAgent(params) {
|
|
|
32161
32161
|
const promptIndex = logArgs.indexOf(argsPrompt);
|
|
32162
32162
|
if (promptIndex >= 0) logArgs[promptIndex] = `<prompt:${argsPrompt.length} chars>`;
|
|
32163
32163
|
}
|
|
32164
|
-
log$
|
|
32164
|
+
log$6.info(`cli argv: ${backend.command} ${logArgs.join(" ")}`);
|
|
32165
32165
|
}
|
|
32166
32166
|
const env = (() => {
|
|
32167
32167
|
const next = {
|
|
@@ -32199,17 +32199,17 @@ async function runCliAgent(params) {
|
|
|
32199
32199
|
const stdout = result.stdout.trim();
|
|
32200
32200
|
const stderr = result.stderr.trim();
|
|
32201
32201
|
if (logOutputText) {
|
|
32202
|
-
if (stdout) log$
|
|
32203
|
-
if (stderr) log$
|
|
32202
|
+
if (stdout) log$6.info(`cli stdout:\n${stdout}`);
|
|
32203
|
+
if (stderr) log$6.info(`cli stderr:\n${stderr}`);
|
|
32204
32204
|
}
|
|
32205
32205
|
if (shouldLogVerbose()) {
|
|
32206
|
-
if (stdout) log$
|
|
32207
|
-
if (stderr) log$
|
|
32206
|
+
if (stdout) log$6.debug(`cli stdout:\n${stdout}`);
|
|
32207
|
+
if (stderr) log$6.debug(`cli stderr:\n${stderr}`);
|
|
32208
32208
|
}
|
|
32209
32209
|
if (result.exitCode !== 0 || result.reason !== "exit") {
|
|
32210
32210
|
if (result.reason === "no-output-timeout" || result.noOutputTimedOut) {
|
|
32211
32211
|
const timeoutReason = `CLI produced no output for ${Math.round(noOutputTimeoutMs / 1e3)}s and was terminated.`;
|
|
32212
|
-
log$
|
|
32212
|
+
log$6.warn(`cli watchdog timeout: provider=${params.provider} model=${modelId} session=${cliSessionIdToSend ?? params.sessionId} noOutputTimeoutMs=${noOutputTimeoutMs} pid=${managedRun.pid ?? "unknown"}`);
|
|
32213
32213
|
throw new FailoverError(timeoutReason, {
|
|
32214
32214
|
reason: "timeout",
|
|
32215
32215
|
provider: params.provider,
|
|
@@ -32528,7 +32528,7 @@ function resolveEmbeddedSessionLane(key) {
|
|
|
32528
32528
|
|
|
32529
32529
|
//#endregion
|
|
32530
32530
|
//#region src/agents/pi-embedded-runner/logger.ts
|
|
32531
|
-
const log$
|
|
32531
|
+
const log$5 = createSubsystemLogger("agent/embedded");
|
|
32532
32532
|
|
|
32533
32533
|
//#endregion
|
|
32534
32534
|
//#region src/utils/safe-json.ts
|
|
@@ -32574,7 +32574,7 @@ function getQueuedFileWriter(writers, filePath) {
|
|
|
32574
32574
|
//#endregion
|
|
32575
32575
|
//#region src/agents/anthropic-payload-log.ts
|
|
32576
32576
|
const writers$1 = /* @__PURE__ */ new Map();
|
|
32577
|
-
const log$
|
|
32577
|
+
const log$4 = createSubsystemLogger("agent/anthropic-payload");
|
|
32578
32578
|
function resolvePayloadLogConfig(env) {
|
|
32579
32579
|
const enabled = parseBooleanValue$1(env.SYMI_ANTHROPIC_PAYLOAD_LOG) ?? false;
|
|
32580
32580
|
const fileOverride = env.SYMI_ANTHROPIC_PAYLOAD_LOG_FILE?.trim();
|
|
@@ -32664,13 +32664,13 @@ function createAnthropicPayloadLogger(params) {
|
|
|
32664
32664
|
usage,
|
|
32665
32665
|
error: errorMessage
|
|
32666
32666
|
});
|
|
32667
|
-
log$
|
|
32667
|
+
log$4.info("anthropic usage", {
|
|
32668
32668
|
runId: params.runId,
|
|
32669
32669
|
sessionId: params.sessionId,
|
|
32670
32670
|
usage
|
|
32671
32671
|
});
|
|
32672
32672
|
};
|
|
32673
|
-
log$
|
|
32673
|
+
log$4.info("anthropic payload logger enabled", { filePath: writer.filePath });
|
|
32674
32674
|
return {
|
|
32675
32675
|
enabled: true,
|
|
32676
32676
|
wrapStreamFn,
|
|
@@ -34762,7 +34762,7 @@ function createEmbeddedPiSessionEventHandler(ctx) {
|
|
|
34762
34762
|
//#region src/agents/pi-embedded-subscribe.ts
|
|
34763
34763
|
const THINKING_TAG_SCAN_RE = /<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\s*>/gi;
|
|
34764
34764
|
const FINAL_TAG_SCAN_RE = /<\s*(\/?)\s*final\s*>/gi;
|
|
34765
|
-
const log$
|
|
34765
|
+
const log$3 = createSubsystemLogger("agent/embedded");
|
|
34766
34766
|
function subscribeEmbeddedPiSession(params) {
|
|
34767
34767
|
const reasoningMode = params.reasoningMode ?? "off";
|
|
34768
34768
|
const useMarkdown = (params.toolResultFormat ?? "markdown") === "markdown";
|
|
@@ -34919,7 +34919,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
34919
34919
|
state.compactionRetryReject = reject;
|
|
34920
34920
|
});
|
|
34921
34921
|
state.compactionRetryPromise.catch((err) => {
|
|
34922
|
-
log$
|
|
34922
|
+
log$3.debug(`compaction promise rejected (no waiter): ${String(err)}`);
|
|
34923
34923
|
});
|
|
34924
34924
|
}
|
|
34925
34925
|
};
|
|
@@ -35071,7 +35071,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
35071
35071
|
if (!chunk) return;
|
|
35072
35072
|
if (chunk === state.lastBlockReplyText) return;
|
|
35073
35073
|
if (isMessagingToolDuplicateNormalized(normalizeTextForComparison(chunk), messagingToolSentTextsNormalized)) {
|
|
35074
|
-
log$
|
|
35074
|
+
log$3.debug(`Skipping block reply - already sent via messaging tool: ${chunk.slice(0, 50)}...`);
|
|
35075
35075
|
return;
|
|
35076
35076
|
}
|
|
35077
35077
|
if (shouldSkipAssistantText(chunk)) return;
|
|
@@ -35149,7 +35149,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
35149
35149
|
const ctx = {
|
|
35150
35150
|
params,
|
|
35151
35151
|
state,
|
|
35152
|
-
log: log$
|
|
35152
|
+
log: log$3,
|
|
35153
35153
|
blockChunking,
|
|
35154
35154
|
blockChunker,
|
|
35155
35155
|
hookRunner: params.hookRunner,
|
|
@@ -35182,7 +35182,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
35182
35182
|
if (state.unsubscribed) return;
|
|
35183
35183
|
state.unsubscribed = true;
|
|
35184
35184
|
if (state.compactionRetryPromise) {
|
|
35185
|
-
log$
|
|
35185
|
+
log$3.debug(`unsubscribe: rejecting compaction wait runId=${params.runId}`);
|
|
35186
35186
|
const reject = state.compactionRetryReject;
|
|
35187
35187
|
state.compactionRetryResolve = void 0;
|
|
35188
35188
|
state.compactionRetryReject = void 0;
|
|
@@ -35192,11 +35192,11 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
35192
35192
|
reject?.(abortErr);
|
|
35193
35193
|
}
|
|
35194
35194
|
if (params.session.isCompacting) {
|
|
35195
|
-
log$
|
|
35195
|
+
log$3.debug(`unsubscribe: aborting in-flight compaction runId=${params.runId}`);
|
|
35196
35196
|
try {
|
|
35197
35197
|
params.session.abortCompaction();
|
|
35198
35198
|
} catch (err) {
|
|
35199
|
-
log$
|
|
35199
|
+
log$3.warn(`unsubscribe: compaction abort failed runId=${params.runId} err=${String(err)}`);
|
|
35200
35200
|
}
|
|
35201
35201
|
}
|
|
35202
35202
|
sessionUnsubscribe();
|
|
@@ -35245,7 +35245,7 @@ function subscribeEmbeddedPiSession(params) {
|
|
|
35245
35245
|
|
|
35246
35246
|
//#endregion
|
|
35247
35247
|
//#region src/agents/pi-tools.before-tool-call.ts
|
|
35248
|
-
const log$
|
|
35248
|
+
const log$2 = createSubsystemLogger("agents/tools");
|
|
35249
35249
|
const BEFORE_TOOL_CALL_WRAPPED = Symbol("beforeToolCallWrapped");
|
|
35250
35250
|
const adjustedParamsByToolCallId = /* @__PURE__ */ new Map();
|
|
35251
35251
|
const MAX_TRACKED_ADJUSTED_PARAMS = 1024;
|
|
@@ -35279,7 +35279,7 @@ async function recordLoopOutcome(args) {
|
|
|
35279
35279
|
config: args.ctx.loopDetection
|
|
35280
35280
|
});
|
|
35281
35281
|
} catch (err) {
|
|
35282
|
-
log$
|
|
35282
|
+
log$2.warn(`tool loop outcome tracking failed: tool=${args.toolName} error=${String(err)}`);
|
|
35283
35283
|
}
|
|
35284
35284
|
}
|
|
35285
35285
|
async function runBeforeToolCallHook(args) {
|
|
@@ -35296,7 +35296,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
35296
35296
|
const loopResult = detectToolCallLoop(sessionState, toolName, params, args.ctx.loopDetection);
|
|
35297
35297
|
if (loopResult.stuck) {
|
|
35298
35298
|
if (loopResult.level === "critical") {
|
|
35299
|
-
log$
|
|
35299
|
+
log$2.error(`Blocking ${toolName} due to critical loop: ${loopResult.message}`);
|
|
35300
35300
|
logToolLoopAction({
|
|
35301
35301
|
sessionKey: args.ctx.sessionKey,
|
|
35302
35302
|
sessionId: args.ctx?.agentId,
|
|
@@ -35313,7 +35313,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
35313
35313
|
reason: loopResult.message
|
|
35314
35314
|
};
|
|
35315
35315
|
} else if (shouldEmitLoopWarning(sessionState, loopResult.warningKey ?? `${loopResult.detector}:${toolName}`, loopResult.count)) {
|
|
35316
|
-
log$
|
|
35316
|
+
log$2.warn(`Loop warning for ${toolName}: ${loopResult.message}`);
|
|
35317
35317
|
logToolLoopAction({
|
|
35318
35318
|
sessionKey: args.ctx.sessionKey,
|
|
35319
35319
|
sessionId: args.ctx?.agentId,
|
|
@@ -35363,7 +35363,7 @@ async function runBeforeToolCallHook(args) {
|
|
|
35363
35363
|
}
|
|
35364
35364
|
} catch (err) {
|
|
35365
35365
|
const toolCallId = args.toolCallId ? ` toolCallId=${args.toolCallId}` : "";
|
|
35366
|
-
log$
|
|
35366
|
+
log$2.warn(`before_tool_call hook failed: tool=${toolName}${toolCallId} error=${String(err)}`);
|
|
35367
35367
|
}
|
|
35368
35368
|
return {
|
|
35369
35369
|
blocked: false,
|
|
@@ -35607,10 +35607,27 @@ function validateShellCommand(command) {
|
|
|
35607
35607
|
|
|
35608
35608
|
//#endregion
|
|
35609
35609
|
//#region src/agents/pi-tools.validate-wrapper.ts
|
|
35610
|
+
const log$1 = createSubsystemLogger("agents/tool-validate");
|
|
35610
35611
|
const EXEC_TOOL_NAMES = new Set(["exec", "bash"]);
|
|
35612
|
+
const FILE_TOOL_NAMES = new Set([
|
|
35613
|
+
"write",
|
|
35614
|
+
"read",
|
|
35615
|
+
"edit",
|
|
35616
|
+
"patch",
|
|
35617
|
+
"file_write",
|
|
35618
|
+
"file_edit",
|
|
35619
|
+
"write_file",
|
|
35620
|
+
"edit_file",
|
|
35621
|
+
"create_file"
|
|
35622
|
+
]);
|
|
35623
|
+
const FILE_PATH_KEYS = [
|
|
35624
|
+
"file_path",
|
|
35625
|
+
"path",
|
|
35626
|
+
"filePath"
|
|
35627
|
+
];
|
|
35611
35628
|
/**
|
|
35612
|
-
* Wrap tools with argument validation.
|
|
35613
|
-
* Other tools pass through unchanged.
|
|
35629
|
+
* Wrap tools with argument validation. Exec/bash commands and file paths
|
|
35630
|
+
* are validated. Other tools pass through unchanged.
|
|
35614
35631
|
*
|
|
35615
35632
|
* Call this AFTER tools are created and the model profile is resolved.
|
|
35616
35633
|
*/
|
|
@@ -35619,24 +35636,64 @@ function wrapToolsWithArgValidation(tools, profile) {
|
|
|
35619
35636
|
return tools.map((tool) => wrapToolWithArgValidation(tool));
|
|
35620
35637
|
}
|
|
35621
35638
|
/**
|
|
35622
|
-
*
|
|
35639
|
+
* Clean a file path by stripping control token fragments.
|
|
35640
|
+
* Returns null if the path is irreparably corrupted (empty after cleanup).
|
|
35641
|
+
*/
|
|
35642
|
+
function cleanFilePath(filePath) {
|
|
35643
|
+
let cleaned = filePath.replace(/<\|[^|>]*(?:\|>)?/g, "");
|
|
35644
|
+
cleaned = cleanResidualTokenFragments(cleaned);
|
|
35645
|
+
cleaned = cleaned.trim();
|
|
35646
|
+
if (!cleaned || !/[a-zA-Z0-9/._~-]/.test(cleaned)) return {
|
|
35647
|
+
valid: false,
|
|
35648
|
+
cleaned
|
|
35649
|
+
};
|
|
35650
|
+
return {
|
|
35651
|
+
valid: true,
|
|
35652
|
+
cleaned
|
|
35653
|
+
};
|
|
35654
|
+
}
|
|
35655
|
+
/**
|
|
35656
|
+
* Wrap a single tool with argument validation.
|
|
35623
35657
|
*/
|
|
35624
35658
|
function wrapToolWithArgValidation(tool) {
|
|
35625
35659
|
const toolName = (tool.name ?? "").toLowerCase().trim();
|
|
35626
|
-
|
|
35660
|
+
const isExecTool = EXEC_TOOL_NAMES.has(toolName);
|
|
35661
|
+
const isFileTool = FILE_TOOL_NAMES.has(toolName);
|
|
35662
|
+
if (!isExecTool && !isFileTool) return tool;
|
|
35627
35663
|
const originalExecute = tool.execute;
|
|
35628
35664
|
return {
|
|
35629
35665
|
...tool,
|
|
35630
35666
|
execute(toolCallId, params, ...rest) {
|
|
35631
|
-
|
|
35632
|
-
|
|
35633
|
-
|
|
35634
|
-
|
|
35635
|
-
|
|
35667
|
+
if (isExecTool) {
|
|
35668
|
+
const command = params.command ?? params.cmd;
|
|
35669
|
+
if (typeof command !== "string") {
|
|
35670
|
+
log$1.debug(`[validate] exec called without string command: keys=${Object.keys(params).join(",")}`);
|
|
35671
|
+
return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
35672
|
+
}
|
|
35673
|
+
const result = validateShellCommand(command);
|
|
35674
|
+
if (!result.valid) {
|
|
35675
|
+
log$1.warn(`[validate] exec command rejected: reason=${result.reason} raw=${command.slice(0, 100)}`);
|
|
35676
|
+
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.` });
|
|
35677
|
+
}
|
|
35678
|
+
if (result.cleaned !== command) {
|
|
35679
|
+
log$1.debug(`[validate] exec command cleaned: raw=${command.slice(0, 80)} → cleaned=${result.cleaned.slice(0, 80)}`);
|
|
35680
|
+
return originalExecute.call(tool, toolCallId, {
|
|
35681
|
+
...params,
|
|
35682
|
+
command: result.cleaned
|
|
35683
|
+
}, ...rest);
|
|
35684
|
+
}
|
|
35685
|
+
return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
35686
|
+
}
|
|
35687
|
+
const pathKey = FILE_PATH_KEYS.find((k) => typeof params[k] === "string");
|
|
35688
|
+
if (!pathKey) return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
35689
|
+
const rawPath = params[pathKey];
|
|
35690
|
+
if (!rawPath.includes("<|") && !rawPath.includes("|>") && !/^[<"|]/.test(rawPath)) return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
35691
|
+
const pathResult = cleanFilePath(rawPath);
|
|
35692
|
+
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.` });
|
|
35693
|
+
return originalExecute.call(tool, toolCallId, {
|
|
35636
35694
|
...params,
|
|
35637
|
-
|
|
35695
|
+
[pathKey]: pathResult.cleaned
|
|
35638
35696
|
}, ...rest);
|
|
35639
|
-
return originalExecute.call(tool, toolCallId, params, ...rest);
|
|
35640
35697
|
}
|
|
35641
35698
|
};
|
|
35642
35699
|
}
|
|
@@ -35995,7 +36052,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
35995
36052
|
const textLength = getToolResultTextLength(msg);
|
|
35996
36053
|
if (textLength > maxChars) {
|
|
35997
36054
|
oversizedIndices.push(i);
|
|
35998
|
-
log$
|
|
36055
|
+
log$5.info(`[tool-result-truncation] Found oversized tool result: entry=${entry.id} chars=${textLength} maxChars=${maxChars} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
35999
36056
|
}
|
|
36000
36057
|
}
|
|
36001
36058
|
if (oversizedIndices.length === 0) return {
|
|
@@ -36017,7 +36074,7 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
36017
36074
|
message = truncateToolResultMessage(message, maxChars);
|
|
36018
36075
|
truncatedCount++;
|
|
36019
36076
|
const newLength = getToolResultTextLength(message);
|
|
36020
|
-
log$
|
|
36077
|
+
log$5.info(`[tool-result-truncation] Truncated tool result: originalEntry=${entry.id} newChars=${newLength} sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
36021
36078
|
}
|
|
36022
36079
|
sessionManager.appendMessage(message);
|
|
36023
36080
|
} else if (entry.type === "compaction") sessionManager.appendCompaction(entry.summary, entry.firstKeptEntryId, entry.tokensBefore, entry.details, entry.fromHook);
|
|
@@ -36031,14 +36088,14 @@ async function truncateOversizedToolResultsInSession(params) {
|
|
|
36031
36088
|
if (entry.name) sessionManager.appendSessionInfo(entry.name);
|
|
36032
36089
|
}
|
|
36033
36090
|
}
|
|
36034
|
-
log$
|
|
36091
|
+
log$5.info(`[tool-result-truncation] Truncated ${truncatedCount} tool result(s) in session (contextWindow=${contextWindowTokens} maxChars=${maxChars}) sessionKey=${params.sessionKey ?? params.sessionId ?? "unknown"}`);
|
|
36035
36092
|
return {
|
|
36036
36093
|
truncated: true,
|
|
36037
36094
|
truncatedCount
|
|
36038
36095
|
};
|
|
36039
36096
|
} catch (err) {
|
|
36040
36097
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
36041
|
-
log$
|
|
36098
|
+
log$5.warn(`[tool-result-truncation] Failed to truncate: ${errMsg}`);
|
|
36042
36099
|
return {
|
|
36043
36100
|
truncated: false,
|
|
36044
36101
|
truncatedCount: 0,
|
|
@@ -37696,7 +37753,7 @@ function resolveAnthropicBetas(extraParams, provider, modelId) {
|
|
|
37696
37753
|
for (const beta of configured) if (typeof beta === "string" && beta.trim()) betas.add(beta.trim());
|
|
37697
37754
|
}
|
|
37698
37755
|
if (extraParams?.context1m === true) if (isAnthropic1MModel(modelId)) betas.add(ANTHROPIC_CONTEXT_1M_BETA);
|
|
37699
|
-
else log$
|
|
37756
|
+
else log$5.warn(`ignoring context1m for non-opus/sonnet model: ${provider}/${modelId}`);
|
|
37700
37757
|
return betas.size > 0 ? [...betas] : void 0;
|
|
37701
37758
|
}
|
|
37702
37759
|
function mergeAnthropicBetaHeader(headers, betas) {
|
|
@@ -38307,14 +38364,14 @@ function logToolSchemasForGoogle(params) {
|
|
|
38307
38364
|
if (params.provider !== "google-antigravity" && params.provider !== "google-gemini-cli") return;
|
|
38308
38365
|
const toolNames = params.tools.map((tool, index) => `${index}:${tool.name}`);
|
|
38309
38366
|
const tools = sanitizeToolsForGoogle(params);
|
|
38310
|
-
log$
|
|
38367
|
+
log$5.info("google tool schema snapshot", {
|
|
38311
38368
|
provider: params.provider,
|
|
38312
38369
|
toolCount: tools.length,
|
|
38313
38370
|
tools: toolNames
|
|
38314
38371
|
});
|
|
38315
38372
|
for (const [index, tool] of tools.entries()) {
|
|
38316
38373
|
const violations = findUnsupportedSchemaKeywords(tool.parameters, `${tool.name}.parameters`);
|
|
38317
|
-
if (violations.length > 0) log$
|
|
38374
|
+
if (violations.length > 0) log$5.warn("google tool schema has unsupported keywords", {
|
|
38318
38375
|
index,
|
|
38319
38376
|
tool: tool.name,
|
|
38320
38377
|
violations: violations.slice(0, 12),
|
|
@@ -38326,7 +38383,7 @@ const compactionFailureEmitter = new EventEmitter();
|
|
|
38326
38383
|
registerUnhandledRejectionHandler((reason) => {
|
|
38327
38384
|
const message = describeUnknownError(reason);
|
|
38328
38385
|
if (!isCompactionFailureError(message)) return false;
|
|
38329
|
-
log$
|
|
38386
|
+
log$5.error(`Auto-compaction failed (unhandled): ${message}`);
|
|
38330
38387
|
compactionFailureEmitter.emit("failure", message);
|
|
38331
38388
|
return true;
|
|
38332
38389
|
});
|
|
@@ -38378,7 +38435,7 @@ function applyGoogleTurnOrderingFix(params) {
|
|
|
38378
38435
|
const sanitized = sanitizeGoogleTurnOrdering(params.messages);
|
|
38379
38436
|
const didPrepend = sanitized !== params.messages;
|
|
38380
38437
|
if (didPrepend && !hasGoogleTurnOrderingMarker(params.sessionManager)) {
|
|
38381
|
-
(params.warn ?? ((message) => log$
|
|
38438
|
+
(params.warn ?? ((message) => log$5.warn(message)))(`google turn ordering fixup: prepended user bootstrap (sessionId=${params.sessionId})`);
|
|
38382
38439
|
markGoogleTurnOrderingMarker(params.sessionManager);
|
|
38383
38440
|
}
|
|
38384
38441
|
return {
|
|
@@ -38989,7 +39046,7 @@ function isImageExtension(filePath) {
|
|
|
38989
39046
|
}
|
|
38990
39047
|
async function sanitizeImagesWithLog(images, label, imageSanitization) {
|
|
38991
39048
|
const { images: sanitized, dropped } = await sanitizeImageBlocks(images, label, imageSanitization);
|
|
38992
|
-
if (dropped > 0) log$
|
|
39049
|
+
if (dropped > 0) log$5.warn(`Native image: dropped ${dropped} image(s) after sanitization (${label}).`);
|
|
38993
39050
|
return sanitized;
|
|
38994
39051
|
}
|
|
38995
39052
|
/**
|
|
@@ -39064,7 +39121,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
39064
39121
|
try {
|
|
39065
39122
|
let targetPath = ref.resolved;
|
|
39066
39123
|
if (ref.type === "url") {
|
|
39067
|
-
log$
|
|
39124
|
+
log$5.debug(`Native image: rejecting remote URL (local-only): ${ref.resolved}`);
|
|
39068
39125
|
return null;
|
|
39069
39126
|
}
|
|
39070
39127
|
if (ref.type === "path") {
|
|
@@ -39074,7 +39131,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
39074
39131
|
cwd: options.sandbox.root
|
|
39075
39132
|
}).hostPath;
|
|
39076
39133
|
} catch (err) {
|
|
39077
|
-
log$
|
|
39134
|
+
log$5.debug(`Native image: sandbox validation failed for ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
39078
39135
|
return null;
|
|
39079
39136
|
}
|
|
39080
39137
|
else if (!path.isAbsolute(targetPath)) targetPath = path.resolve(workspaceDir, targetPath);
|
|
@@ -39088,7 +39145,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
39088
39145
|
})
|
|
39089
39146
|
}) : await loadWebMedia(targetPath, options?.maxBytes);
|
|
39090
39147
|
if (media.kind !== "image") {
|
|
39091
|
-
log$
|
|
39148
|
+
log$5.debug(`Native image: not an image file: ${targetPath} (got ${media.kind})`);
|
|
39092
39149
|
return null;
|
|
39093
39150
|
}
|
|
39094
39151
|
const mimeType = media.contentType ?? "image/jpeg";
|
|
@@ -39098,7 +39155,7 @@ async function loadImageFromRef(ref, workspaceDir, options) {
|
|
|
39098
39155
|
mimeType
|
|
39099
39156
|
};
|
|
39100
39157
|
} catch (err) {
|
|
39101
|
-
log$
|
|
39158
|
+
log$5.debug(`Native image: failed to load ${ref.resolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
39102
39159
|
return null;
|
|
39103
39160
|
}
|
|
39104
39161
|
}
|
|
@@ -39197,7 +39254,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
39197
39254
|
loadedCount: 0,
|
|
39198
39255
|
skippedCount: 0
|
|
39199
39256
|
};
|
|
39200
|
-
log$
|
|
39257
|
+
log$5.debug(`Native image: detected ${allRefs.length} image refs (${promptRefs.length} in prompt, ${uniqueHistoryRefs.length} in history)`);
|
|
39201
39258
|
const promptImages = [...params.existingImages ?? []];
|
|
39202
39259
|
const historyImagesByIndex = /* @__PURE__ */ new Map();
|
|
39203
39260
|
let loadedCount = 0;
|
|
@@ -39214,7 +39271,7 @@ async function detectAndLoadPromptImages(params) {
|
|
|
39214
39271
|
else historyImagesByIndex.set(ref.messageIndex, [image]);
|
|
39215
39272
|
} else promptImages.push(image);
|
|
39216
39273
|
loadedCount++;
|
|
39217
|
-
log$
|
|
39274
|
+
log$5.debug(`Native image: loaded ${ref.type} ${ref.resolved}`);
|
|
39218
39275
|
} else skippedCount++;
|
|
39219
39276
|
}
|
|
39220
39277
|
const imageSanitization = { maxDimensionPx: params.maxDimensionPx };
|
|
@@ -39310,7 +39367,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
39310
39367
|
const resolvedWorkspace = resolveUserPath(params.workspaceDir);
|
|
39311
39368
|
const prevCwd = process.cwd();
|
|
39312
39369
|
const runAbortController = new AbortController();
|
|
39313
|
-
log$
|
|
39370
|
+
log$5.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"}`);
|
|
39314
39371
|
await fs$1.mkdir(resolvedWorkspace, { recursive: true });
|
|
39315
39372
|
const sandboxSessionKey = params.sessionKey?.trim() || params.sessionId;
|
|
39316
39373
|
const sandbox = await resolveSandboxContext({
|
|
@@ -39346,7 +39403,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
39346
39403
|
sessionId: params.sessionId,
|
|
39347
39404
|
warn: makeBootstrapWarn({
|
|
39348
39405
|
sessionLabel,
|
|
39349
|
-
warn: (message) => log$
|
|
39406
|
+
warn: (message) => log$5.warn(message)
|
|
39350
39407
|
})
|
|
39351
39408
|
});
|
|
39352
39409
|
const workspaceNotes = hookAdjustedBootstrapFiles.some((file) => file.name === DEFAULT_BOOTSTRAP_FILENAME && !file.missing) ? ["Reminder: commit your changes in this workspace after edits."] : void 0;
|
|
@@ -39545,7 +39602,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
39545
39602
|
try {
|
|
39546
39603
|
await repairSessionFileIfNeeded({
|
|
39547
39604
|
sessionFile: params.sessionFile,
|
|
39548
|
-
warn: (message) => log$
|
|
39605
|
+
warn: (message) => log$5.warn(message)
|
|
39549
39606
|
});
|
|
39550
39607
|
const hadSessionFile = await fs$1.stat(params.sessionFile).then(() => true).catch(() => false);
|
|
39551
39608
|
const transcriptPolicy = resolveTranscriptPolicy({
|
|
@@ -39554,7 +39611,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
39554
39611
|
modelId: params.modelId
|
|
39555
39612
|
});
|
|
39556
39613
|
const versionCheck = await handleSessionVersion(params.sessionFile);
|
|
39557
|
-
if (versionCheck.archived) log$
|
|
39614
|
+
if (versionCheck.archived) log$5.warn(`session archived: created by ${versionCheck.poisonVersion}, known corruption range → ${versionCheck.archivePath}`);
|
|
39558
39615
|
await prewarmSessionFile(params.sessionFile);
|
|
39559
39616
|
sessionManager = guardSessionManager(SessionManager.open(params.sessionFile), {
|
|
39560
39617
|
agentId: sessionAgentId,
|
|
@@ -39806,6 +39863,9 @@ async function runEmbeddedAttempt(params) {
|
|
|
39806
39863
|
});
|
|
39807
39864
|
};
|
|
39808
39865
|
const streamMonitor = createStreamMonitor(modelProfile);
|
|
39866
|
+
const TOOL_ERROR_ABORT_THRESHOLD = 5;
|
|
39867
|
+
const TOOL_ERROR_WARN_THRESHOLD = 3;
|
|
39868
|
+
let consecutiveToolErrors = 0;
|
|
39809
39869
|
const subscription = subscribeEmbeddedPiSession({
|
|
39810
39870
|
session: activeSession,
|
|
39811
39871
|
runId: params.runId,
|
|
@@ -39827,9 +39887,25 @@ async function runEmbeddedAttempt(params) {
|
|
|
39827
39887
|
onAgentEvent: (evt) => {
|
|
39828
39888
|
armSymipulseTimer();
|
|
39829
39889
|
params.onAgentEvent?.(evt);
|
|
39890
|
+
if (evt.stream === "tool" && !aborted) {
|
|
39891
|
+
const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
|
|
39892
|
+
const isError = evt.data?.isError === true;
|
|
39893
|
+
if (phase === "result") {
|
|
39894
|
+
if (isError) consecutiveToolErrors++;
|
|
39895
|
+
else consecutiveToolErrors = 0;
|
|
39896
|
+
if (consecutiveToolErrors >= TOOL_ERROR_ABORT_THRESHOLD) {
|
|
39897
|
+
const toolName = typeof evt.data?.name === "string" ? evt.data.name : "unknown";
|
|
39898
|
+
log$5.error(`Agent-loop circuit breaker: ${consecutiveToolErrors} consecutive tool errors (last: ${toolName}). Aborting run ${params.runId}.`);
|
|
39899
|
+
abortRun(false, /* @__PURE__ */ new Error(`${consecutiveToolErrors} consecutive tool errors. The model may be generating corrupted tool arguments. Run aborted to prevent infinite loop.`));
|
|
39900
|
+
} else if (consecutiveToolErrors === TOOL_ERROR_WARN_THRESHOLD) {
|
|
39901
|
+
const toolName = typeof evt.data?.name === "string" ? evt.data.name : "unknown";
|
|
39902
|
+
log$5.warn(`Agent-loop tool error warning: ${consecutiveToolErrors} consecutive failures (last: ${toolName}). runId=${params.runId}`);
|
|
39903
|
+
}
|
|
39904
|
+
}
|
|
39905
|
+
}
|
|
39830
39906
|
if (evt.stream === "assistant" && typeof evt.data?.text === "string" && !aborted) {
|
|
39831
39907
|
streamMonitor.onChunk(evt.data.text);
|
|
39832
|
-
if (streamMonitor.shouldStop()) log$
|
|
39908
|
+
if (streamMonitor.shouldStop()) log$5.debug(`stream monitor detection (log-only, no abort): runId=${params.runId} reason=${streamMonitor.getStopReason()}`);
|
|
39833
39909
|
}
|
|
39834
39910
|
},
|
|
39835
39911
|
enforceFinalTag: params.enforceFinalTag,
|
|
@@ -39849,7 +39925,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
39849
39925
|
let abortWarnTimer;
|
|
39850
39926
|
const isProbeSession = params.sessionId?.startsWith("probe-") ?? false;
|
|
39851
39927
|
const abortTimer = setTimeout(() => {
|
|
39852
|
-
if (!isProbeSession) log$
|
|
39928
|
+
if (!isProbeSession) log$5.warn(`embedded run timeout: runId=${params.runId} sessionId=${params.sessionId} timeoutMs=${params.timeoutMs}`);
|
|
39853
39929
|
if (shouldFlagCompactionTimeout({
|
|
39854
39930
|
isTimeout: true,
|
|
39855
39931
|
isCompactionPendingOrRetrying: subscription.isCompacting(),
|
|
@@ -39858,7 +39934,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
39858
39934
|
abortRun(true);
|
|
39859
39935
|
if (!abortWarnTimer) abortWarnTimer = setTimeout(() => {
|
|
39860
39936
|
if (!activeSession.isStreaming) return;
|
|
39861
|
-
if (!isProbeSession) log$
|
|
39937
|
+
if (!isProbeSession) log$5.warn(`embedded run abort still streaming: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
39862
39938
|
}, 1e4);
|
|
39863
39939
|
}, Math.max(1, params.timeoutMs));
|
|
39864
39940
|
armSymipulseTimer = () => {
|
|
@@ -39866,7 +39942,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
39866
39942
|
clearSymipulseTimer();
|
|
39867
39943
|
symipulseTimer = setTimeout(() => {
|
|
39868
39944
|
if (aborted) return;
|
|
39869
|
-
if (!isProbeSession) log$
|
|
39945
|
+
if (!isProbeSession) log$5.warn(`symipulse timeout: runId=${params.runId} sessionId=${params.sessionId} symipulseMs=${symipulseMs} (no activity)`);
|
|
39870
39946
|
if (shouldFlagCompactionTimeout({
|
|
39871
39947
|
isTimeout: true,
|
|
39872
39948
|
isCompactionPendingOrRetrying: subscription.isCompacting(),
|
|
@@ -39910,13 +39986,13 @@ async function runEmbeddedAttempt(params) {
|
|
|
39910
39986
|
prompt: params.prompt,
|
|
39911
39987
|
messages: activeSession.messages
|
|
39912
39988
|
}, hookCtx).catch((hookErr) => {
|
|
39913
|
-
log$
|
|
39989
|
+
log$5.warn(`before_prompt_build hook failed: ${String(hookErr)}`);
|
|
39914
39990
|
}) : void 0;
|
|
39915
39991
|
const legacyResult = hookRunner?.hasHooks("before_agent_start") ? await hookRunner.runBeforeAgentStart({
|
|
39916
39992
|
prompt: params.prompt,
|
|
39917
39993
|
messages: activeSession.messages
|
|
39918
39994
|
}, hookCtx).catch((hookErr) => {
|
|
39919
|
-
log$
|
|
39995
|
+
log$5.warn(`before_agent_start hook (legacy prompt build path) failed: ${String(hookErr)}`);
|
|
39920
39996
|
}) : void 0;
|
|
39921
39997
|
const hookResult = {
|
|
39922
39998
|
systemPrompt: promptBuildResult?.systemPrompt ?? legacyResult?.systemPrompt,
|
|
@@ -39924,7 +40000,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
39924
40000
|
};
|
|
39925
40001
|
if (hookResult?.prependContext) {
|
|
39926
40002
|
effectivePrompt = `${hookResult.prependContext}\n\n${params.prompt}`;
|
|
39927
|
-
log$
|
|
40003
|
+
log$5.debug(`hooks: prepended context to prompt (${hookResult.prependContext.length} chars)`);
|
|
39928
40004
|
}
|
|
39929
40005
|
{
|
|
39930
40006
|
const autoRecallAgentId = normalizeAgentId(params.sessionKey);
|
|
@@ -39941,11 +40017,11 @@ async function runEmbeddedAttempt(params) {
|
|
|
39941
40017
|
if (recallResults.length > 0) {
|
|
39942
40018
|
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>`;
|
|
39943
40019
|
effectivePrompt = `${recallBlock}\n\n${effectivePrompt}`;
|
|
39944
|
-
log$
|
|
40020
|
+
log$5.debug(`auto-recall: injected ${recallResults.length} snippets (${recallBlock.length} chars)`);
|
|
39945
40021
|
}
|
|
39946
40022
|
}
|
|
39947
40023
|
} catch (recallErr) {
|
|
39948
|
-
log$
|
|
40024
|
+
log$5.debug(`auto-recall: skipped (${String(recallErr)})`);
|
|
39949
40025
|
}
|
|
39950
40026
|
}
|
|
39951
40027
|
{
|
|
@@ -39957,10 +40033,10 @@ async function runEmbeddedAttempt(params) {
|
|
|
39957
40033
|
if (planResult.enter) {
|
|
39958
40034
|
if (planResult.stripped != null) effectivePrompt = planResult.stripped;
|
|
39959
40035
|
effectivePrompt = `${PLAN_MODE_SYSTEM_PROMPT}\n\n${effectivePrompt}`;
|
|
39960
|
-
log$
|
|
40036
|
+
log$5.info(`plan-mode: activated (${planResult.reason}) for runId=${params.runId}`);
|
|
39961
40037
|
} else if (planResult.stripped != null) effectivePrompt = planResult.stripped;
|
|
39962
40038
|
}
|
|
39963
|
-
log$
|
|
40039
|
+
log$5.debug(`embedded run prompt start: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
39964
40040
|
cacheTrace?.recordStage("prompt:before", {
|
|
39965
40041
|
prompt: effectivePrompt,
|
|
39966
40042
|
messages: activeSession.messages
|
|
@@ -39972,7 +40048,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
39972
40048
|
const sessionContext = sessionManager.buildSessionContext();
|
|
39973
40049
|
const sanitizedOrphan = transcriptPolicy.sanitizeThinkingSignatures ? sanitizeAntigravityThinkingBlocks(sessionContext.messages) : sessionContext.messages;
|
|
39974
40050
|
activeSession.agent.replaceMessages(sanitizedOrphan);
|
|
39975
|
-
log$
|
|
40051
|
+
log$5.warn(`Removed orphaned user message to prevent consecutive user turns. runId=${params.runId} sessionId=${params.sessionId}`);
|
|
39976
40052
|
}
|
|
39977
40053
|
try {
|
|
39978
40054
|
const imageResult = await detectAndLoadPromptImages({
|
|
@@ -39994,12 +40070,12 @@ async function runEmbeddedAttempt(params) {
|
|
|
39994
40070
|
messages: activeSession.messages,
|
|
39995
40071
|
note: `images: prompt=${imageResult.images.length} history=${imageResult.historyImagesByIndex.size}`
|
|
39996
40072
|
});
|
|
39997
|
-
if (log$
|
|
40073
|
+
if (log$5.isEnabled("debug")) {
|
|
39998
40074
|
const msgCount = activeSession.messages.length;
|
|
39999
40075
|
const systemLen = systemPromptText?.length ?? 0;
|
|
40000
40076
|
const promptLen = effectivePrompt.length;
|
|
40001
40077
|
const sessionSummary = summarizeSessionContext(activeSession.messages);
|
|
40002
|
-
log$
|
|
40078
|
+
log$5.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}`);
|
|
40003
40079
|
}
|
|
40004
40080
|
if (hookRunner?.hasHooks("llm_input")) hookRunner.runLlmInput({
|
|
40005
40081
|
runId: params.runId,
|
|
@@ -40017,7 +40093,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
40017
40093
|
workspaceDir: params.workspaceDir,
|
|
40018
40094
|
messageProvider: params.messageProvider ?? void 0
|
|
40019
40095
|
}).catch((err) => {
|
|
40020
|
-
log$
|
|
40096
|
+
log$5.warn(`llm_input hook failed: ${String(err)}`);
|
|
40021
40097
|
});
|
|
40022
40098
|
if (imageResult.images.length > 0) await abortable(activeSession.prompt(effectivePrompt, { images: imageResult.images }));
|
|
40023
40099
|
else await abortable(activeSession.prompt(effectivePrompt));
|
|
@@ -40025,7 +40101,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
40025
40101
|
promptError = err;
|
|
40026
40102
|
promptErrorSource = "prompt";
|
|
40027
40103
|
} finally {
|
|
40028
|
-
log$
|
|
40104
|
+
log$5.debug(`embedded run prompt end: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - promptStartedAt}`);
|
|
40029
40105
|
}
|
|
40030
40106
|
const wasCompactingBefore = activeSession.isCompacting;
|
|
40031
40107
|
const snapshot = activeSession.messages.slice();
|
|
@@ -40040,7 +40116,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
40040
40116
|
promptError = err;
|
|
40041
40117
|
promptErrorSource = "compaction";
|
|
40042
40118
|
}
|
|
40043
|
-
if (!isProbeSession) log$
|
|
40119
|
+
if (!isProbeSession) log$5.debug(`compaction wait aborted: runId=${params.runId} sessionId=${params.sessionId}`);
|
|
40044
40120
|
} else throw err;
|
|
40045
40121
|
}
|
|
40046
40122
|
if (!timedOutDuringCompaction) {
|
|
@@ -40058,7 +40134,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
40058
40134
|
currentSessionId: activeSession.sessionId
|
|
40059
40135
|
});
|
|
40060
40136
|
if (timedOutDuringCompaction) {
|
|
40061
|
-
if (!isProbeSession) log$
|
|
40137
|
+
if (!isProbeSession) log$5.warn(`using ${snapshotSelection.source} snapshot: timed out during compaction runId=${params.runId} sessionId=${params.sessionId}`);
|
|
40062
40138
|
}
|
|
40063
40139
|
messagesSnapshot = snapshotSelection.messagesSnapshot;
|
|
40064
40140
|
sessionIdUsed = snapshotSelection.sessionIdUsed;
|
|
@@ -40073,7 +40149,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
40073
40149
|
error: describeUnknownError(promptError)
|
|
40074
40150
|
});
|
|
40075
40151
|
} catch (entryErr) {
|
|
40076
|
-
log$
|
|
40152
|
+
log$5.warn(`failed to persist prompt error entry: ${String(entryErr)}`);
|
|
40077
40153
|
}
|
|
40078
40154
|
cacheTrace?.recordStage("session:after", {
|
|
40079
40155
|
messages: messagesSnapshot,
|
|
@@ -40092,17 +40168,17 @@ async function runEmbeddedAttempt(params) {
|
|
|
40092
40168
|
workspaceDir: params.workspaceDir,
|
|
40093
40169
|
messageProvider: params.messageProvider ?? void 0
|
|
40094
40170
|
}).catch((err) => {
|
|
40095
|
-
log$
|
|
40171
|
+
log$5.warn(`agent_end hook failed: ${err}`);
|
|
40096
40172
|
});
|
|
40097
40173
|
} finally {
|
|
40098
40174
|
clearTimeout(abortTimer);
|
|
40099
40175
|
clearSymipulseTimer();
|
|
40100
40176
|
if (abortWarnTimer) clearTimeout(abortWarnTimer);
|
|
40101
|
-
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$
|
|
40177
|
+
if (!isProbeSession && (aborted || timedOut) && !timedOutDuringCompaction) log$5.debug(`run cleanup: runId=${params.runId} sessionId=${params.sessionId} aborted=${aborted} timedOut=${timedOut}`);
|
|
40102
40178
|
try {
|
|
40103
40179
|
unsubscribe();
|
|
40104
40180
|
} catch (err) {
|
|
40105
|
-
log$
|
|
40181
|
+
log$5.error(`CRITICAL: unsubscribe failed, possible resource leak: runId=${params.runId} ${String(err)}`);
|
|
40106
40182
|
}
|
|
40107
40183
|
clearActiveEmbeddedRun(params.sessionId, queueHandle, params.sessionKey);
|
|
40108
40184
|
params.abortSignal?.removeEventListener?.("abort", onAbort);
|
|
@@ -40127,7 +40203,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
40127
40203
|
workspaceDir: params.workspaceDir,
|
|
40128
40204
|
messageProvider: params.messageProvider ?? void 0
|
|
40129
40205
|
}).catch((err) => {
|
|
40130
|
-
log$
|
|
40206
|
+
log$5.warn(`llm_output hook failed: ${String(err)}`);
|
|
40131
40207
|
});
|
|
40132
40208
|
return {
|
|
40133
40209
|
aborted,
|
|
@@ -40388,7 +40464,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40388
40464
|
const redactedSessionId = redactRunIdentifier(params.sessionId);
|
|
40389
40465
|
const redactedSessionKey = redactRunIdentifier(params.sessionKey);
|
|
40390
40466
|
const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
|
|
40391
|
-
if (workspaceResolution.usedFallback) log$
|
|
40467
|
+
if (workspaceResolution.usedFallback) log$5.warn(`[workspace-fallback] caller=runEmbeddedPiAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
|
|
40392
40468
|
const prevCwd = process.cwd();
|
|
40393
40469
|
let provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
40394
40470
|
let modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
@@ -40407,7 +40483,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40407
40483
|
if (hookRunner?.hasHooks("before_model_resolve")) try {
|
|
40408
40484
|
modelResolveOverride = await hookRunner.runBeforeModelResolve({ prompt: params.prompt }, hookCtx);
|
|
40409
40485
|
} catch (hookErr) {
|
|
40410
|
-
log$
|
|
40486
|
+
log$5.warn(`before_model_resolve hook failed: ${String(hookErr)}`);
|
|
40411
40487
|
}
|
|
40412
40488
|
if (hookRunner?.hasHooks("before_agent_start")) try {
|
|
40413
40489
|
const legacyResult = await hookRunner.runBeforeAgentStart({ prompt: params.prompt }, hookCtx);
|
|
@@ -40416,15 +40492,15 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40416
40492
|
modelOverride: modelResolveOverride?.modelOverride ?? legacyResult?.modelOverride
|
|
40417
40493
|
};
|
|
40418
40494
|
} catch (hookErr) {
|
|
40419
|
-
log$
|
|
40495
|
+
log$5.warn(`before_agent_start hook (legacy model resolve path) failed: ${String(hookErr)}`);
|
|
40420
40496
|
}
|
|
40421
40497
|
if (modelResolveOverride?.providerOverride) {
|
|
40422
40498
|
provider = modelResolveOverride.providerOverride;
|
|
40423
|
-
log$
|
|
40499
|
+
log$5.info(`[hooks] provider overridden to ${provider}`);
|
|
40424
40500
|
}
|
|
40425
40501
|
if (modelResolveOverride?.modelOverride) {
|
|
40426
40502
|
modelId = modelResolveOverride.modelOverride;
|
|
40427
|
-
log$
|
|
40503
|
+
log$5.info(`[hooks] model overridden to ${modelId}`);
|
|
40428
40504
|
}
|
|
40429
40505
|
const { model, error, authStorage, modelRegistry } = resolveModel(provider, modelId, agentDir, params.config);
|
|
40430
40506
|
if (!model) throw new FailoverError(error ?? `Unknown model: ${provider}/${modelId}`, {
|
|
@@ -40444,9 +40520,9 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40444
40520
|
warnBelowTokens: CONTEXT_WINDOW_WARN_BELOW_TOKENS,
|
|
40445
40521
|
hardMinTokens: CONTEXT_WINDOW_HARD_MIN_TOKENS
|
|
40446
40522
|
});
|
|
40447
|
-
if (ctxGuard.shouldWarn) log$
|
|
40523
|
+
if (ctxGuard.shouldWarn) log$5.warn(`low context window: ${provider}/${modelId} ctx=${ctxGuard.tokens} (warn<${CONTEXT_WINDOW_WARN_BELOW_TOKENS}) source=${ctxGuard.source}`);
|
|
40448
40524
|
if (ctxGuard.shouldBlock) {
|
|
40449
|
-
log$
|
|
40525
|
+
log$5.error(`blocked model (context window too small): ${provider}/${modelId} ctx=${ctxGuard.tokens} (min=${CONTEXT_WINDOW_HARD_MIN_TOKENS}) source=${ctxGuard.source}`);
|
|
40450
40526
|
throw new FailoverError(`Model context window too small (${ctxGuard.tokens} tokens). Minimum is ${CONTEXT_WINDOW_HARD_MIN_TOKENS}.`, {
|
|
40451
40527
|
reason: "unknown",
|
|
40452
40528
|
provider,
|
|
@@ -40576,7 +40652,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40576
40652
|
while (true) {
|
|
40577
40653
|
if (runLoopIterations >= MAX_RUN_LOOP_ITERATIONS) {
|
|
40578
40654
|
const message = `Exceeded retry limit after ${runLoopIterations} attempts (max=${MAX_RUN_LOOP_ITERATIONS}).`;
|
|
40579
|
-
log$
|
|
40655
|
+
log$5.error(`[run-retry-limit] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} attempts=${runLoopIterations} maxAttempts=${MAX_RUN_LOOP_ITERATIONS}`);
|
|
40580
40656
|
return {
|
|
40581
40657
|
payloads: [{
|
|
40582
40658
|
text: "Request failed after repeated internal retries. Please try again, or use /new to start a fresh session.",
|
|
@@ -40697,18 +40773,18 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40697
40773
|
const overflowDiagId = createCompactionDiagId$1();
|
|
40698
40774
|
const errorText = contextOverflowError.text;
|
|
40699
40775
|
const msgCount = attempt.messagesSnapshot?.length ?? 0;
|
|
40700
|
-
log$
|
|
40776
|
+
log$5.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)}`);
|
|
40701
40777
|
const isCompactionFailure = isCompactionFailureError(errorText);
|
|
40702
40778
|
const hadAttemptLevelCompaction = attemptCompactionCount > 0;
|
|
40703
40779
|
if (!isCompactionFailure && hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
40704
40780
|
overflowCompactionAttempts++;
|
|
40705
|
-
log$
|
|
40781
|
+
log$5.warn(`context overflow persisted after in-attempt compaction (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); retrying prompt without additional compaction for ${provider}/${modelId}`);
|
|
40706
40782
|
continue;
|
|
40707
40783
|
}
|
|
40708
40784
|
if (!isCompactionFailure && !hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
|
|
40709
|
-
if (log$
|
|
40785
|
+
if (log$5.isEnabled("debug")) log$5.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=compact isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts + 1} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
40710
40786
|
overflowCompactionAttempts++;
|
|
40711
|
-
log$
|
|
40787
|
+
log$5.warn(`context overflow detected (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); attempting auto-compaction for ${provider}/${modelId}`);
|
|
40712
40788
|
const compactResult = await compactEmbeddedPiSessionDirect({
|
|
40713
40789
|
sessionId: params.sessionId,
|
|
40714
40790
|
sessionKey: params.sessionKey,
|
|
@@ -40737,10 +40813,10 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40737
40813
|
});
|
|
40738
40814
|
if (compactResult.compacted) {
|
|
40739
40815
|
autoCompactionCount += 1;
|
|
40740
|
-
log$
|
|
40816
|
+
log$5.info(`auto-compaction succeeded for ${provider}/${modelId}; retrying prompt`);
|
|
40741
40817
|
continue;
|
|
40742
40818
|
}
|
|
40743
|
-
log$
|
|
40819
|
+
log$5.warn(`auto-compaction failed for ${provider}/${modelId}: ${compactResult.reason ?? "nothing to compact"}`);
|
|
40744
40820
|
}
|
|
40745
40821
|
if (!toolResultTruncationAttempted) {
|
|
40746
40822
|
const contextWindowTokens = ctxInfo.tokens;
|
|
@@ -40749,9 +40825,9 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40749
40825
|
contextWindowTokens
|
|
40750
40826
|
}) : false;
|
|
40751
40827
|
if (hasOversized) {
|
|
40752
|
-
if (log$
|
|
40828
|
+
if (log$5.isEnabled("debug")) log$5.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=truncate_tool_results isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=${hasOversized} attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
40753
40829
|
toolResultTruncationAttempted = true;
|
|
40754
|
-
log$
|
|
40830
|
+
log$5.warn(`[context-overflow-recovery] Attempting tool result truncation for ${provider}/${modelId} (contextWindow=${contextWindowTokens} tokens)`);
|
|
40755
40831
|
const truncResult = await truncateOversizedToolResultsInSession({
|
|
40756
40832
|
sessionFile: params.sessionFile,
|
|
40757
40833
|
contextWindowTokens,
|
|
@@ -40759,13 +40835,13 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40759
40835
|
sessionKey: params.sessionKey
|
|
40760
40836
|
});
|
|
40761
40837
|
if (truncResult.truncated) {
|
|
40762
|
-
log$
|
|
40838
|
+
log$5.info(`[context-overflow-recovery] Truncated ${truncResult.truncatedCount} tool result(s); retrying prompt`);
|
|
40763
40839
|
continue;
|
|
40764
40840
|
}
|
|
40765
|
-
log$
|
|
40766
|
-
} else if (log$
|
|
40841
|
+
log$5.warn(`[context-overflow-recovery] Tool result truncation did not help: ${truncResult.reason ?? "unknown"}`);
|
|
40842
|
+
} else if (log$5.isEnabled("debug")) log$5.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=${hasOversized} attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
40767
40843
|
}
|
|
40768
|
-
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$
|
|
40844
|
+
if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS || toolResultTruncationAttempted) && log$5.isEnabled("debug")) log$5.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
|
|
40769
40845
|
const kind = isCompactionFailure ? "compaction_failure" : "context_overflow";
|
|
40770
40846
|
return {
|
|
40771
40847
|
payloads: [{
|
|
@@ -40846,7 +40922,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40846
40922
|
attempted: attemptedThinking
|
|
40847
40923
|
});
|
|
40848
40924
|
if (fallbackThinking) {
|
|
40849
|
-
log$
|
|
40925
|
+
log$5.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
40850
40926
|
thinkLevel = fallbackThinking;
|
|
40851
40927
|
continue;
|
|
40852
40928
|
}
|
|
@@ -40864,7 +40940,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40864
40940
|
attempted: attemptedThinking
|
|
40865
40941
|
});
|
|
40866
40942
|
if (fallbackThinking && !aborted) {
|
|
40867
|
-
log$
|
|
40943
|
+
log$5.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
|
|
40868
40944
|
thinkLevel = fallbackThinking;
|
|
40869
40945
|
continue;
|
|
40870
40946
|
}
|
|
@@ -40881,7 +40957,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40881
40957
|
imageDimensionError.contentIndex !== void 0 ? `content=${imageDimensionError.contentIndex}` : null,
|
|
40882
40958
|
imageDimensionError.maxDimensionPx !== void 0 ? `limit=${imageDimensionError.maxDimensionPx}px` : null
|
|
40883
40959
|
].filter(Boolean).join(" ");
|
|
40884
|
-
log$
|
|
40960
|
+
log$5.warn(`Profile ${lastProfileId} rejected image payload${details ? ` (${details})` : ""}.`);
|
|
40885
40961
|
}
|
|
40886
40962
|
const isLocalOllamaTimeout = timedOut && model.api === "ollama";
|
|
40887
40963
|
if (!aborted && failoverFailure || timedOut && !timedOutDuringCompaction && !isLocalOllamaTimeout) {
|
|
@@ -40893,8 +40969,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40893
40969
|
cfg: params.config,
|
|
40894
40970
|
agentDir: params.agentDir
|
|
40895
40971
|
});
|
|
40896
|
-
if (timedOut && !isProbeSession) log$
|
|
40897
|
-
if (cloudCodeAssistFormatError) log$
|
|
40972
|
+
if (timedOut && !isProbeSession) log$5.warn(`Profile ${lastProfileId} timed out (possible rate limit). Trying next account...`);
|
|
40973
|
+
if (cloudCodeAssistFormatError) log$5.warn(`Profile ${lastProfileId} hit Cloud Code Assist format error. Tool calls will be sanitized on retry.`);
|
|
40898
40974
|
}
|
|
40899
40975
|
if (await advanceAuthProfile()) continue;
|
|
40900
40976
|
if (fallbackConfigured) {
|
|
@@ -40960,7 +41036,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
40960
41036
|
const hasCodeBlocks = attempt.assistantTexts.some((text) => /```[\s\S]*?```/.test(text));
|
|
40961
41037
|
if (hasCodeToolUsage || hasCodeBlocks) {
|
|
40962
41038
|
verificationPassCompleted = true;
|
|
40963
|
-
log$
|
|
41039
|
+
log$5.debug(`[verification] starting verification pass: runId=${params.runId} sessionId=${params.sessionId} trigger=${hasCodeToolUsage ? "tool_usage" : "code_blocks"}`);
|
|
40964
41040
|
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.";
|
|
40965
41041
|
try {
|
|
40966
41042
|
const verifyAttempt = await runEmbeddedAttempt({
|
|
@@ -41046,10 +41122,10 @@ async function runEmbeddedPiAgent(params) {
|
|
|
41046
41122
|
payloads.length = 0;
|
|
41047
41123
|
payloads.push(...verifyPayloads);
|
|
41048
41124
|
}
|
|
41049
|
-
log$
|
|
41050
|
-
} else log$
|
|
41125
|
+
log$5.debug(`[verification] verification produced corrections: runId=${params.runId} tools=${verifyAttempt.toolMetas.length} texts=${verifyAttempt.assistantTexts.length}`);
|
|
41126
|
+
} else log$5.debug(`[verification] verification confirmed original response: runId=${params.runId}`);
|
|
41051
41127
|
} catch (verifyErr) {
|
|
41052
|
-
log$
|
|
41128
|
+
log$5.warn(`[verification] verification pass failed, keeping original response: runId=${params.runId} error=${String(verifyErr)}`);
|
|
41053
41129
|
}
|
|
41054
41130
|
}
|
|
41055
41131
|
}
|
|
@@ -41070,7 +41146,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
41070
41146
|
messagingToolSentTargets: attempt.messagingToolSentTargets,
|
|
41071
41147
|
successfulCronAdds: attempt.successfulCronAdds
|
|
41072
41148
|
};
|
|
41073
|
-
log$
|
|
41149
|
+
log$5.debug(`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`);
|
|
41074
41150
|
if (lastProfileId) {
|
|
41075
41151
|
await markAuthProfileGood({
|
|
41076
41152
|
store: authStore,
|
|
@@ -52942,7 +53018,7 @@ function isVoiceChannelType(type) {
|
|
|
52942
53018
|
function createDefaultDeps() {
|
|
52943
53019
|
return {
|
|
52944
53020
|
sendMessageWhatsApp: async (...args) => {
|
|
52945
|
-
const { sendMessageWhatsApp } = await import("./web-
|
|
53021
|
+
const { sendMessageWhatsApp } = await import("./web-CQ2F1f3a.js");
|
|
52946
53022
|
return await sendMessageWhatsApp(...args);
|
|
52947
53023
|
},
|
|
52948
53024
|
sendMessageTelegram: async (...args) => {
|
|
@@ -68256,7 +68332,7 @@ function loadWebLoginQr() {
|
|
|
68256
68332
|
return webLoginQrPromise;
|
|
68257
68333
|
}
|
|
68258
68334
|
function loadWebChannel() {
|
|
68259
|
-
webChannelPromise ??= import("./web-
|
|
68335
|
+
webChannelPromise ??= import("./web-CQ2F1f3a.js");
|
|
68260
68336
|
return webChannelPromise;
|
|
68261
68337
|
}
|
|
68262
68338
|
function loadWhatsAppActions() {
|
|
@@ -70394,7 +70470,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
70394
70470
|
const provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
|
|
70395
70471
|
const modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
|
|
70396
70472
|
const fail = (reason) => {
|
|
70397
|
-
log$
|
|
70473
|
+
log$5.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}`);
|
|
70398
70474
|
return {
|
|
70399
70475
|
ok: false,
|
|
70400
70476
|
compacted: false,
|
|
@@ -70462,7 +70538,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
70462
70538
|
sessionId: params.sessionId,
|
|
70463
70539
|
warn: makeBootstrapWarn({
|
|
70464
70540
|
sessionLabel,
|
|
70465
|
-
warn: (message) => log$
|
|
70541
|
+
warn: (message) => log$5.warn(message)
|
|
70466
70542
|
})
|
|
70467
70543
|
});
|
|
70468
70544
|
const runAbortController = new AbortController();
|
|
@@ -70602,7 +70678,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
70602
70678
|
try {
|
|
70603
70679
|
await repairSessionFileIfNeeded({
|
|
70604
70680
|
sessionFile: params.sessionFile,
|
|
70605
|
-
warn: (message) => log$
|
|
70681
|
+
warn: (message) => log$5.warn(message)
|
|
70606
70682
|
});
|
|
70607
70683
|
await prewarmSessionFile(params.sessionFile);
|
|
70608
70684
|
const transcriptPolicy = resolveTranscriptPolicy({
|
|
@@ -70687,13 +70763,13 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
70687
70763
|
messages: preCompactionMessages,
|
|
70688
70764
|
sessionFile: params.sessionFile
|
|
70689
70765
|
}, hookCtx).catch((hookErr) => {
|
|
70690
|
-
log$
|
|
70766
|
+
log$5.warn(`before_compaction hook failed: ${String(hookErr)}`);
|
|
70691
70767
|
});
|
|
70692
|
-
const diagEnabled = log$
|
|
70768
|
+
const diagEnabled = log$5.isEnabled("debug");
|
|
70693
70769
|
const preMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
70694
70770
|
if (diagEnabled && preMetrics) {
|
|
70695
|
-
log$
|
|
70696
|
-
log$
|
|
70771
|
+
log$5.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"}`);
|
|
70772
|
+
log$5.debug(`[compaction-diag] contributors diagId=${diagId} top=${JSON.stringify(preMetrics.contributors)}`);
|
|
70697
70773
|
}
|
|
70698
70774
|
const compactStartedAt = Date.now();
|
|
70699
70775
|
const result = await compactWithSafetyTimeout(() => session.compact(params.customInstructions));
|
|
@@ -70711,10 +70787,10 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
70711
70787
|
compactedCount: limited.length - session.messages.length,
|
|
70712
70788
|
sessionFile: params.sessionFile
|
|
70713
70789
|
}, hookCtx).catch((hookErr) => {
|
|
70714
|
-
log$
|
|
70790
|
+
log$5.warn(`after_compaction hook failed: ${hookErr}`);
|
|
70715
70791
|
});
|
|
70716
70792
|
const postMetrics = diagEnabled ? summarizeCompactionMessages(session.messages) : void 0;
|
|
70717
|
-
if (diagEnabled && preMetrics && postMetrics) log$
|
|
70793
|
+
if (diagEnabled && preMetrics && postMetrics) log$5.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"}`);
|
|
70718
70794
|
return {
|
|
70719
70795
|
ok: true,
|
|
70720
70796
|
compacted: true,
|