@qwen-code/qwen-code 0.18.0 → 0.18.1
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/bundled/loop/SKILL.md +2 -1
- package/bundled/qc-helper/docs/configuration/auth.md +1 -1
- package/bundled/qc-helper/docs/configuration/model-providers.md +12 -5
- package/bundled/qc-helper/docs/configuration/settings.md +30 -27
- package/bundled/qc-helper/docs/features/dual-output.md +37 -3
- package/bundled/qc-helper/docs/features/skills.md +29 -3
- package/bundled/qc-helper/docs/features/sub-agents.md +2 -1
- package/bundled/qc-helper/docs/qwen-serve.md +26 -18
- package/chunks/{agent-LOTJK6AH.js → agent-XT7NHZ5H.js} +21 -20
- package/chunks/{agent-headless-TU3EPMYU.js → agent-headless-LNRE63ZL.js} +21 -20
- package/chunks/{anthropicContentGenerator-2HBRNQ3B.js → anthropicContentGenerator-DCI26OQF.js} +4 -4
- package/chunks/{askUserQuestion-OGCMIBQM.js → askUserQuestion-ITYUTWLR.js} +2 -2
- package/chunks/{ca-BARBRL6N.js → ca-RK4QPLIX.js} +18 -1
- package/chunks/{chunk-ZTZ4DDQE.js → chunk-3NRO6NHX.js} +2 -2
- package/chunks/{chunk-IWAYOW5Q.js → chunk-6T7Y7USE.js} +6566 -4195
- package/chunks/{chunk-MFBBBTNY.js → chunk-7KPZFE5A.js} +1 -1
- package/chunks/{chunk-XV4HCEVI.js → chunk-A2ZIEEGJ.js} +9 -22
- package/chunks/{chunk-A7B4ISQP.js → chunk-B4ZF2KSI.js} +1 -1
- package/chunks/chunk-BJ5HQ23U.js +178 -0
- package/chunks/{chunk-LBP46COL.js → chunk-BXYRCW2C.js} +83 -15
- package/chunks/{chunk-OHEGWO4L.js → chunk-CPVI5J2L.js} +1 -1
- package/chunks/{chunk-R7ODSGTK.js → chunk-DHZREJTG.js} +2 -2
- package/chunks/{chunk-SEGYWKIH.js → chunk-FIQECJTQ.js} +1 -1
- package/chunks/{chunk-HR7SV7AY.js → chunk-HA2UEYZP.js} +6 -2
- package/chunks/{chunk-JTQAQBTV.js → chunk-HED55F43.js} +5 -1
- package/chunks/{chunk-HLPLOD42.js → chunk-HQUWWSSP.js} +1 -1
- package/chunks/{chunk-2Y5SYSD3.js → chunk-IDYDPBBN.js} +3 -3
- package/chunks/{chunk-3HTIVKZE.js → chunk-IQHSD7K5.js} +1 -1
- package/chunks/{chunk-LEJ42GNY.js → chunk-IS7UA4W3.js} +6 -6
- package/chunks/{chunk-B7HXHOHU.js → chunk-LXYWINWF.js} +1 -1
- package/chunks/{chunk-IDX6COTE.js → chunk-LYRSMKLS.js} +2 -2
- package/chunks/{chunk-M6VTDSVR.js → chunk-LYSND7KR.js} +9 -4
- package/chunks/{chunk-EYENRK4D.js → chunk-NNIYWQIS.js} +1 -1
- package/chunks/chunk-OMX7CUOE.js +356 -0
- package/chunks/{chunk-BIVG75CP.js → chunk-QILTEBWS.js} +1 -1
- package/chunks/{chunk-6YIUGZTC.js → chunk-RON7LFNH.js} +281 -132
- package/chunks/{chunk-3DHXZ6EV.js → chunk-SFRV6BGY.js} +6 -4
- package/chunks/{chunk-7BCMOPIM.js → chunk-WJ3SND6W.js} +31 -12
- package/chunks/{chunk-J5MDQKJL.js → chunk-WPTCDQN6.js} +2 -347
- package/chunks/{chunk-PL3MVCWD.js → chunk-XZTNBSMW.js} +11 -11
- package/chunks/{chunk-72LDN5PP.js → chunk-Y7KMDUEP.js} +1 -1
- package/chunks/{chunk-SNGELLWX.js → chunk-ZMIBJS45.js} +1 -1
- package/chunks/{chunk-XBY7E2FX.js → chunk-ZOFNJQNJ.js} +6 -4
- package/chunks/computer-use-4YX3JGBV.js +2052 -0
- package/chunks/{contextCommand-K347QT6O.js → contextCommand-KS2H7MW5.js} +23 -22
- package/chunks/cron-create-CAPUKK7I.js +184 -0
- package/chunks/{cron-delete-WKWSJZQA.js → cron-delete-G3KAR26Q.js} +27 -4
- package/chunks/{cron-list-B52XEXAZ.js → cron-list-ZA4ZIUS5.js} +39 -6
- package/chunks/{de-YGKK2BC4.js → de-FGPM4KW5.js} +18 -1
- package/chunks/{dist-KAZ3SEBX.js → dist-7YWFWOCJ.js} +1 -1
- package/chunks/{dist-4LXD6L6X.js → dist-VEGFONCF.js} +2 -2
- package/chunks/{dist-H6ONXVLG.js → dist-X4EXN7W6.js} +1 -1
- package/chunks/{dist-PK7DFCAW.js → dist-YLS6NI7H.js} +1 -1
- package/chunks/{edit-KU4PJGEX.js → edit-2ARPEO4B.js} +22 -21
- package/chunks/{en-DHGYHIHX.js → en-VP6XPGEC.js} +5 -2
- package/chunks/{enter-worktree-PPYIDCWI.js → enter-worktree-IXNXNAW5.js} +21 -20
- package/chunks/{enterPlanMode-5CZDMCB4.js → enterPlanMode-TAKAGAYP.js} +21 -20
- package/chunks/{exit-worktree-UY3CGHKC.js → exit-worktree-LHTRV7ML.js} +21 -20
- package/chunks/{exitPlanMode-3DN4QNSG.js → exitPlanMode-MK5UAITL.js} +71 -31
- package/chunks/{fr-JXBKPJKQ.js → fr-ATYBVCLT.js} +18 -1
- package/chunks/{geminiContentGenerator-7A6I2RWB.js → geminiContentGenerator-HFJIGO77.js} +4 -4
- package/chunks/{glob-OFNQSS52.js → glob-I2USLUSC.js} +21 -20
- package/chunks/{grep-6J2MSUM5.js → grep-WBIF7THR.js} +30 -26
- package/chunks/{ja-TGPZSP2B.js → ja-W2QEA2OI.js} +18 -1
- package/chunks/{keychain-token-storage-6IU6ORQN.js → keychain-token-storage-QSTRHKKL.js} +2 -2
- package/chunks/{ls-V3O6A5PT.js → ls-2R5RHLX5.js} +3 -3
- package/chunks/{lsp-G2OCIFUA.js → lsp-XKH6ZIAN.js} +2 -2
- package/chunks/{monitor-FKLHV423.js → monitor-WU7UFATU.js} +21 -20
- package/chunks/{notebook-edit-KTBYFKWG.js → notebook-edit-KUHYPXEM.js} +22 -21
- package/chunks/{openaiContentGenerator-L5KSWQY7.js → openaiContentGenerator-5PLHYJQL.js} +11 -11
- package/chunks/{pt-TIBG6BIO.js → pt-ZKEWJFBW.js} +18 -1
- package/chunks/{qwenContentGenerator-PYOXLMBW.js → qwenContentGenerator-TSKW73KY.js} +23 -22
- package/chunks/{qwenOAuth2-2KCKWDCF.js → qwenOAuth2-KK433U33.js} +4 -4
- package/chunks/{read-file-JQVRK4NU.js → read-file-VIPF2PS6.js} +8 -8
- package/chunks/{ripGrep-2L4LPNAJ.js → ripGrep-XLIZTYE7.js} +21 -20
- package/chunks/{ru-JBCHCK4L.js → ru-VEKTPJ74.js} +18 -1
- package/chunks/{scheduler-FGNXY4JQ.js → scheduler-O66SLJGU.js} +21 -20
- package/chunks/{send-message-SZFWNOCL.js → send-message-CTME7DXD.js} +2 -2
- package/chunks/{serve-N2IBLA3G.js → serve-BWOLYT62.js} +998 -278
- package/chunks/{shell-PTEG6UX4.js → shell-XE7UYKOO.js} +21 -20
- package/chunks/{skill-X4NTK4NH.js → skill-RZWM6XMC.js} +10 -10
- package/chunks/{src-GLLQ3R5W.js → src-L5P7K4MH.js} +42 -26
- package/chunks/{syntheticOutput-IKAY5F6X.js → syntheticOutput-ZJGSU7OQ.js} +3 -3
- package/chunks/{task-create-MQICOJFV.js → task-create-EE6JEM7G.js} +7 -6
- package/chunks/{task-list-RIHJCH32.js → task-list-EESYAC65.js} +6 -5
- package/chunks/{task-stop-FWZRFANS.js → task-stop-XZVCFFYY.js} +2 -2
- package/chunks/{task-update-2LHPXOYM.js → task-update-EIO4HNE3.js} +7 -6
- package/chunks/{team-create-2E4PF4KN.js → team-create-R2H7Y3SG.js} +21 -20
- package/chunks/{team-delete-DAUDQS4J.js → team-delete-A7LXPGV7.js} +6 -5
- package/chunks/{todoWrite-HTUACZES.js → todoWrite-VRKSGAWM.js} +4 -4
- package/chunks/{tool-search-KTVULRES.js → tool-search-USSQMTMS.js} +8 -8
- package/chunks/{web-fetch-CZ7LLKPE.js → web-fetch-GHAZUA54.js} +4 -4
- package/chunks/{workflow-L2ZUUDT2.js → workflow-5LNNLNUR.js} +503 -49
- package/chunks/{write-file-ZEB2JDYH.js → write-file-2I7HP24C.js} +22 -21
- package/chunks/{zh-7H5OQC4I.js → zh-OIXDDQHB.js} +5 -2
- package/chunks/{zh-TW-P4IDHD3M.js → zh-TW-6YFNCKTA.js} +5 -2
- package/cli-entry.js +19 -0
- package/cli.js +6547 -4938
- package/locales/ca.js +20 -2
- package/locales/de.js +21 -2
- package/locales/en.js +7 -4
- package/locales/fr.js +22 -2
- package/locales/ja.js +22 -2
- package/locales/pt.js +21 -2
- package/locales/ru.js +20 -2
- package/locales/zh-TW.js +6 -4
- package/locales/zh.js +6 -4
- package/package.json +4 -3
- package/chunks/chunk-SKBPNJEW.js +0 -45
- package/chunks/computer-use-3RH2DOM6.js +0 -825
- package/chunks/cron-create-YJL3KFWI.js +0 -140
|
@@ -20,19 +20,22 @@ import {
|
|
|
20
20
|
} from "./chunk-OFEVLU4C.js";
|
|
21
21
|
import {
|
|
22
22
|
isAnyAutoMemPath
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-IQHSD7K5.js";
|
|
24
24
|
import {
|
|
25
25
|
InstallationManager
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-LYRSMKLS.js";
|
|
27
27
|
import {
|
|
28
28
|
STRUCTURED_OUTPUT_REDACTED_ARGS
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-QILTEBWS.js";
|
|
30
30
|
import {
|
|
31
31
|
BaseDeclarativeTool,
|
|
32
32
|
BaseToolInvocation,
|
|
33
33
|
ToolDisplayNames,
|
|
34
34
|
ToolNames
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-A2ZIEEGJ.js";
|
|
36
|
+
import {
|
|
37
|
+
atomicWriteFile
|
|
38
|
+
} from "./chunk-LXYWINWF.js";
|
|
36
39
|
import {
|
|
37
40
|
DEFAULT_OPENAI_BASE_URL,
|
|
38
41
|
convertSchema,
|
|
@@ -40,7 +43,7 @@ import {
|
|
|
40
43
|
runtimeDiagnostics,
|
|
41
44
|
safeJsonParse,
|
|
42
45
|
tokenLimit
|
|
43
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-LYSND7KR.js";
|
|
44
47
|
import {
|
|
45
48
|
FinishReason,
|
|
46
49
|
GenerateContentResponse
|
|
@@ -49,6 +52,8 @@ import {
|
|
|
49
52
|
FatalConfigError,
|
|
50
53
|
Storage,
|
|
51
54
|
createDebugLogger,
|
|
55
|
+
formatTraceparent,
|
|
56
|
+
getActiveSpanTraceContext,
|
|
52
57
|
getCurrentSessionId,
|
|
53
58
|
getErrorMessage,
|
|
54
59
|
getErrorStatus,
|
|
@@ -60,7 +65,7 @@ import {
|
|
|
60
65
|
setShellTracePropagation,
|
|
61
66
|
shortenPath,
|
|
62
67
|
unescapePath
|
|
63
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-HA2UEYZP.js";
|
|
64
69
|
import {
|
|
65
70
|
require_dist
|
|
66
71
|
} from "./chunk-ZERZSAZL.js";
|
|
@@ -20117,13 +20122,13 @@ var require_path = __commonJS({
|
|
|
20117
20122
|
"use strict";
|
|
20118
20123
|
init_esbuild_shims();
|
|
20119
20124
|
var path8 = exports;
|
|
20120
|
-
var
|
|
20125
|
+
var isAbsolute3 = (
|
|
20121
20126
|
/**
|
|
20122
20127
|
* Tests if the specified path is absolute.
|
|
20123
20128
|
* @param {string} path Path to test
|
|
20124
20129
|
* @returns {boolean} `true` if path is absolute
|
|
20125
20130
|
*/
|
|
20126
|
-
path8.isAbsolute = /* @__PURE__ */ __name(function
|
|
20131
|
+
path8.isAbsolute = /* @__PURE__ */ __name(function isAbsolute4(path9) {
|
|
20127
20132
|
return /^(?:\/|\w+:)/.test(path9);
|
|
20128
20133
|
}, "isAbsolute")
|
|
20129
20134
|
);
|
|
@@ -20135,7 +20140,7 @@ var require_path = __commonJS({
|
|
|
20135
20140
|
*/
|
|
20136
20141
|
path8.normalize = /* @__PURE__ */ __name(function normalize4(path9) {
|
|
20137
20142
|
path9 = path9.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
|
|
20138
|
-
var parts = path9.split("/"), absolute =
|
|
20143
|
+
var parts = path9.split("/"), absolute = isAbsolute3(path9), prefix = "";
|
|
20139
20144
|
if (absolute)
|
|
20140
20145
|
prefix = parts.shift() + "/";
|
|
20141
20146
|
for (var i = 0; i < parts.length; ) {
|
|
@@ -20157,7 +20162,7 @@ var require_path = __commonJS({
|
|
|
20157
20162
|
path8.resolve = /* @__PURE__ */ __name(function resolve2(originPath, includePath, alreadyNormalized) {
|
|
20158
20163
|
if (!alreadyNormalized)
|
|
20159
20164
|
includePath = normalize3(includePath);
|
|
20160
|
-
if (
|
|
20165
|
+
if (isAbsolute3(includePath))
|
|
20161
20166
|
return includePath;
|
|
20162
20167
|
if (!alreadyNormalized)
|
|
20163
20168
|
originPath = normalize3(originPath);
|
|
@@ -63710,6 +63715,10 @@ init_esbuild_shims();
|
|
|
63710
63715
|
import * as fs3 from "node:fs/promises";
|
|
63711
63716
|
import * as path4 from "node:path";
|
|
63712
63717
|
import * as crypto2 from "node:crypto";
|
|
63718
|
+
var debugLogger3 = createDebugLogger("TRUNCATION");
|
|
63719
|
+
var PREVIEW_SIZE_CHARS = 2e3;
|
|
63720
|
+
var MAX_FILE_SIZE_BYTES = 50 * 1024 * 1024;
|
|
63721
|
+
var MAX_SESSION_BYTES = 500 * 1024 * 1024;
|
|
63713
63722
|
var TOOL_OUTPUT_TRUNCATED_PREFIX = "Tool output was too large and has been truncated";
|
|
63714
63723
|
async function truncateAndSaveToFile(content, fileName, projectTempDir, threshold, truncateLines, keep = "both") {
|
|
63715
63724
|
if (content.length <= threshold && !Number.isFinite(truncateLines)) {
|
|
@@ -63785,7 +63794,11 @@ ${truncatedContent}`;
|
|
|
63785
63794
|
content: wrappedMessage,
|
|
63786
63795
|
outputFile
|
|
63787
63796
|
};
|
|
63788
|
-
} catch (
|
|
63797
|
+
} catch (error) {
|
|
63798
|
+
debugLogger3.warn(
|
|
63799
|
+
`Failed to save truncated output to ${outputFile}:`,
|
|
63800
|
+
error
|
|
63801
|
+
);
|
|
63789
63802
|
return {
|
|
63790
63803
|
content: truncatedContent + `
|
|
63791
63804
|
[Note: Could not save full output to file]`
|
|
@@ -63869,9 +63882,118 @@ async function truncateLlmContent(config, toolName, content, limits, promptId) {
|
|
|
63869
63882
|
};
|
|
63870
63883
|
}
|
|
63871
63884
|
__name(truncateLlmContent, "truncateLlmContent");
|
|
63885
|
+
function isAlreadyTruncated(content) {
|
|
63886
|
+
return content.includes("... [CONTENT TRUNCATED] ...") || content.startsWith("<persisted-output>");
|
|
63887
|
+
}
|
|
63888
|
+
__name(isAlreadyTruncated, "isAlreadyTruncated");
|
|
63889
|
+
function generatePreview(content) {
|
|
63890
|
+
let text = content.length <= PREVIEW_SIZE_CHARS ? content : (() => {
|
|
63891
|
+
const slice = content.slice(0, PREVIEW_SIZE_CHARS);
|
|
63892
|
+
const lastNewline = slice.lastIndexOf("\n");
|
|
63893
|
+
return (lastNewline > 0 ? slice.slice(0, lastNewline) : slice) + "\n...";
|
|
63894
|
+
})();
|
|
63895
|
+
text = text.replace(/<\/?persisted-output>/g, (m) => `<${m.slice(1, -1)}>`).replace(/<\/?system-reminder>/g, (m) => `<${m.slice(1, -1)}>`);
|
|
63896
|
+
return text;
|
|
63897
|
+
}
|
|
63898
|
+
__name(generatePreview, "generatePreview");
|
|
63899
|
+
async function persistAndTruncateToolResult(callId, toolName, content, config) {
|
|
63900
|
+
const byteSize = Buffer.byteLength(content, "utf-8");
|
|
63901
|
+
if (byteSize > MAX_FILE_SIZE_BYTES) {
|
|
63902
|
+
debugLogger3.warn(
|
|
63903
|
+
`Tool result for ${toolName} exceeds ${MAX_FILE_SIZE_BYTES} bytes (${byteSize}), skipping disk persistence`
|
|
63904
|
+
);
|
|
63905
|
+
return {
|
|
63906
|
+
content: buildStub(content, byteSize, "(file too large to persist)"),
|
|
63907
|
+
bytesWritten: 0
|
|
63908
|
+
};
|
|
63909
|
+
}
|
|
63910
|
+
const budgetUsed = config.getToolResultBytesWritten();
|
|
63911
|
+
if (budgetUsed + byteSize > MAX_SESSION_BYTES) {
|
|
63912
|
+
debugLogger3.warn(
|
|
63913
|
+
`Session tool result budget exhausted (${budgetUsed} + ${byteSize} > ${MAX_SESSION_BYTES}), skipping disk persistence`
|
|
63914
|
+
);
|
|
63915
|
+
return {
|
|
63916
|
+
content: buildStub(
|
|
63917
|
+
content,
|
|
63918
|
+
byteSize,
|
|
63919
|
+
"(session disk budget exhausted)"
|
|
63920
|
+
),
|
|
63921
|
+
bytesWritten: 0
|
|
63922
|
+
};
|
|
63923
|
+
}
|
|
63924
|
+
config.trackToolResultBytes(byteSize);
|
|
63925
|
+
const safeCallId = path4.basename(callId).replace(/\x00/g, "_");
|
|
63926
|
+
if (!safeCallId || safeCallId === "." || safeCallId === "..") {
|
|
63927
|
+
debugLogger3.warn(`Invalid callId for disk persistence: ${JSON.stringify(callId)}`);
|
|
63928
|
+
config.trackToolResultBytes(-byteSize);
|
|
63929
|
+
return {
|
|
63930
|
+
content: buildStub(content, byteSize, "(invalid callId)"),
|
|
63931
|
+
bytesWritten: 0
|
|
63932
|
+
};
|
|
63933
|
+
}
|
|
63934
|
+
const toolResultsDir = config.storage.getToolResultsDir();
|
|
63935
|
+
const outputFile = path4.join(toolResultsDir, `${safeCallId}.txt`);
|
|
63936
|
+
try {
|
|
63937
|
+
await fs3.mkdir(toolResultsDir, { recursive: true });
|
|
63938
|
+
await atomicWriteFile(outputFile, content, {
|
|
63939
|
+
mode: 384,
|
|
63940
|
+
forceMode: true,
|
|
63941
|
+
noFollow: true,
|
|
63942
|
+
flush: false
|
|
63943
|
+
});
|
|
63944
|
+
return {
|
|
63945
|
+
content: buildStub(content, byteSize, outputFile),
|
|
63946
|
+
outputFile,
|
|
63947
|
+
bytesWritten: byteSize
|
|
63948
|
+
};
|
|
63949
|
+
} catch (error) {
|
|
63950
|
+
config.trackToolResultBytes(-byteSize);
|
|
63951
|
+
debugLogger3.warn(
|
|
63952
|
+
`Failed to persist tool result to ${outputFile}:`,
|
|
63953
|
+
error
|
|
63954
|
+
);
|
|
63955
|
+
try {
|
|
63956
|
+
const fallback = await truncateAndSaveToFile(
|
|
63957
|
+
content,
|
|
63958
|
+
`${toolName}_${crypto2.randomBytes(6).toString("hex")}`,
|
|
63959
|
+
config.storage.getProjectTempDir(),
|
|
63960
|
+
config.getTruncateToolOutputThreshold(),
|
|
63961
|
+
config.getTruncateToolOutputLines()
|
|
63962
|
+
);
|
|
63963
|
+
return { content: fallback.content, bytesWritten: 0 };
|
|
63964
|
+
} catch (fallbackError) {
|
|
63965
|
+
debugLogger3.warn("Fallback truncation also failed:", fallbackError);
|
|
63966
|
+
return {
|
|
63967
|
+
content: buildStub(content, byteSize, "(disk persistence unavailable)"),
|
|
63968
|
+
bytesWritten: 0
|
|
63969
|
+
};
|
|
63970
|
+
}
|
|
63971
|
+
}
|
|
63972
|
+
}
|
|
63973
|
+
__name(persistAndTruncateToolResult, "persistAndTruncateToolResult");
|
|
63974
|
+
function buildStub(content, byteSize, filePathOrNote) {
|
|
63975
|
+
const preview = generatePreview(content);
|
|
63976
|
+
const sizeKb = Math.round(byteSize / 1024);
|
|
63977
|
+
const isFilePath = path4.isAbsolute(filePathOrNote);
|
|
63978
|
+
if (isFilePath) {
|
|
63979
|
+
return `<persisted-output>
|
|
63980
|
+
Output too large (${sizeKb} KB). Full output saved to: ${filePathOrNote}
|
|
63981
|
+
Note: this file may be cleaned up after 24 hours.
|
|
63982
|
+
To read the complete output, use the ${ReadFileTool.Name} tool with the absolute file path above.
|
|
63983
|
+
|
|
63984
|
+
Preview (up to ${PREVIEW_SIZE_CHARS} chars):
|
|
63985
|
+
${preview}
|
|
63986
|
+
</persisted-output>`;
|
|
63987
|
+
}
|
|
63988
|
+
return `Output too large (${sizeKb} KB). ${filePathOrNote}
|
|
63989
|
+
|
|
63990
|
+
Preview (up to ${PREVIEW_SIZE_CHARS} chars):
|
|
63991
|
+
${preview}`;
|
|
63992
|
+
}
|
|
63993
|
+
__name(buildStub, "buildStub");
|
|
63872
63994
|
|
|
63873
63995
|
// packages/core/src/tools/mcp-tool.ts
|
|
63874
|
-
var
|
|
63996
|
+
var debugLogger4 = createDebugLogger("MCP_TOOL");
|
|
63875
63997
|
var DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends BaseToolInvocation {
|
|
63876
63998
|
constructor(mcpTool, serverName, serverToolName, displayName, trust, params = {}, cliConfig, mcpClient, mcpTimeout, annotations, retryCount = 0) {
|
|
63877
63999
|
super(params);
|
|
@@ -63941,7 +64063,7 @@ var DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends Bas
|
|
|
63941
64063
|
return null;
|
|
63942
64064
|
}
|
|
63943
64065
|
try {
|
|
63944
|
-
|
|
64066
|
+
debugLogger4.info(
|
|
63945
64067
|
`Attempting to reconnect MCP server '${this.serverName}'...`
|
|
63946
64068
|
);
|
|
63947
64069
|
const toolRegistry = this.cliConfig.getToolRegistry();
|
|
@@ -63950,23 +64072,23 @@ var DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends Bas
|
|
|
63950
64072
|
`mcp__${this.serverName}__${this.serverToolName}`
|
|
63951
64073
|
);
|
|
63952
64074
|
if (newTool instanceof DiscoveredMCPTool) {
|
|
63953
|
-
|
|
64075
|
+
debugLogger4.info(
|
|
63954
64076
|
`Successfully reconnected to MCP server '${this.serverName}'`
|
|
63955
64077
|
);
|
|
63956
64078
|
return newTool;
|
|
63957
64079
|
}
|
|
63958
64080
|
return null;
|
|
63959
64081
|
} catch (error) {
|
|
63960
|
-
|
|
64082
|
+
debugLogger4.error(
|
|
63961
64083
|
`Failed to reconnect MCP server '${this.serverName}': ${error}`
|
|
63962
64084
|
);
|
|
63963
64085
|
return null;
|
|
63964
64086
|
}
|
|
63965
64087
|
}
|
|
63966
64088
|
async handleReconnectOnError(error, signal, updateOutput) {
|
|
63967
|
-
|
|
64089
|
+
debugLogger4.error(`MCP server error '${this.serverName}': ${error}`);
|
|
63968
64090
|
if (this.retryCount < _DiscoveredMCPToolInvocation.MAX_RECONNECT_RETRIES) {
|
|
63969
|
-
|
|
64091
|
+
debugLogger4.info(
|
|
63970
64092
|
`Reconnection attempt ${this.retryCount + 1}/${_DiscoveredMCPToolInvocation.MAX_RECONNECT_RETRIES} for MCP server '${this.serverName}'`
|
|
63971
64093
|
);
|
|
63972
64094
|
const newTool = await this.attemptReconnect();
|
|
@@ -63987,7 +64109,7 @@ var DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends Bas
|
|
|
63987
64109
|
return newInvocation.execute(signal, updateOutput);
|
|
63988
64110
|
}
|
|
63989
64111
|
} else if (this.retryCount >= _DiscoveredMCPToolInvocation.MAX_RECONNECT_RETRIES) {
|
|
63990
|
-
|
|
64112
|
+
debugLogger4.error(
|
|
63991
64113
|
`Max reconnection attempts (${_DiscoveredMCPToolInvocation.MAX_RECONNECT_RETRIES}) reached for MCP server '${this.serverName}'`
|
|
63992
64114
|
);
|
|
63993
64115
|
}
|
|
@@ -65404,7 +65526,7 @@ init_esbuild_shims();
|
|
|
65404
65526
|
|
|
65405
65527
|
// packages/core/src/core/openaiContentGenerator/taggedThinkingParser.ts
|
|
65406
65528
|
init_esbuild_shims();
|
|
65407
|
-
var
|
|
65529
|
+
var debugLogger5 = createDebugLogger("TAGGED_THINKING_PARSER");
|
|
65408
65530
|
var OPEN_TAGS = ["<think>", "<thinking>"];
|
|
65409
65531
|
var CLOSE_TAGS = ["</think>", "</thinking>"];
|
|
65410
65532
|
var MAX_TAG_LENGTH = Math.max(
|
|
@@ -65445,7 +65567,7 @@ var TaggedThinkingParser = class {
|
|
|
65445
65567
|
const activeTags = this.mode === "text" ? OPEN_TAGS : CLOSE_TAGS;
|
|
65446
65568
|
const matchedTag = findMatchingTag(lower, index, activeTags);
|
|
65447
65569
|
if (matchedTag) {
|
|
65448
|
-
|
|
65570
|
+
debugLogger5.debug(
|
|
65449
65571
|
`taggedThinking: detected tag "${matchedTag}" at offset ${index}`
|
|
65450
65572
|
);
|
|
65451
65573
|
appendPart(parts, segment, this.mode);
|
|
@@ -65463,19 +65585,19 @@ var TaggedThinkingParser = class {
|
|
|
65463
65585
|
if (index < this.buffer.length) {
|
|
65464
65586
|
appendPart(parts, segment, this.mode);
|
|
65465
65587
|
this.buffer = this.buffer.slice(index);
|
|
65466
|
-
|
|
65588
|
+
debugLogger5.debug(
|
|
65467
65589
|
`taggedThinking: emitted ${parts.length} part(s), buffered ${this.buffer.length} char(s)`
|
|
65468
65590
|
);
|
|
65469
65591
|
return parts;
|
|
65470
65592
|
}
|
|
65471
65593
|
this.buffer = "";
|
|
65472
65594
|
if (this.mode === "thought" && segment) {
|
|
65473
|
-
|
|
65595
|
+
debugLogger5.warn(
|
|
65474
65596
|
`taggedThinking: flushing ${segment.length} chars of unclosed thought on stream end`
|
|
65475
65597
|
);
|
|
65476
65598
|
}
|
|
65477
65599
|
appendPart(parts, segment, this.mode);
|
|
65478
|
-
|
|
65600
|
+
debugLogger5.debug(
|
|
65479
65601
|
`taggedThinking: emitted ${parts.length} part(s), flush complete`
|
|
65480
65602
|
);
|
|
65481
65603
|
return parts;
|
|
@@ -65487,7 +65609,7 @@ function parseTaggedThinkingText(text) {
|
|
|
65487
65609
|
__name(parseTaggedThinkingText, "parseTaggedThinkingText");
|
|
65488
65610
|
|
|
65489
65611
|
// packages/core/src/core/openaiContentGenerator/converter.ts
|
|
65490
|
-
var
|
|
65612
|
+
var debugLogger6 = createDebugLogger("CONVERTER");
|
|
65491
65613
|
var SPLIT_TOOL_MEDIA_TEXT = "(attached media from previous tool call)";
|
|
65492
65614
|
var CUMULATIVE_DELTA_EXACT_REPEAT_MIN_LENGTH = 64;
|
|
65493
65615
|
var CUMULATIVE_DETECTION_WINDOW_BYTES = 1024;
|
|
@@ -65508,12 +65630,12 @@ function normalizeStreamingTextDelta(rawDelta, state) {
|
|
|
65508
65630
|
return suffix;
|
|
65509
65631
|
}
|
|
65510
65632
|
if (state.emittedText.startsWith(rawDelta)) {
|
|
65511
|
-
|
|
65633
|
+
debugLogger6.debug(
|
|
65512
65634
|
`normalizeStreamingTextDelta: cumulative rewind suppression (emitted=${state.emittedText.length}b, chunk=${rawDelta.length}b)`
|
|
65513
65635
|
);
|
|
65514
65636
|
return "";
|
|
65515
65637
|
}
|
|
65516
|
-
|
|
65638
|
+
debugLogger6.debug(
|
|
65517
65639
|
"normalizeStreamingTextDelta: exiting cumulative mode (chunk does not match prior accumulated text)"
|
|
65518
65640
|
);
|
|
65519
65641
|
state.cumulativeMode = false;
|
|
@@ -65530,7 +65652,7 @@ function normalizeStreamingTextDelta(rawDelta, state) {
|
|
|
65530
65652
|
state.emittedText = rawDelta;
|
|
65531
65653
|
state.emittedLength = rawDelta.length;
|
|
65532
65654
|
state.cumulativeMode = true;
|
|
65533
|
-
|
|
65655
|
+
debugLogger6.debug(
|
|
65534
65656
|
`normalizeStreamingTextDelta: entered cumulative mode (prefix overlap, baseline=${baselineLen}b sliceFrom=${sliceFrom}b -> curr=${rawDelta.length}b)`
|
|
65535
65657
|
);
|
|
65536
65658
|
return suffix;
|
|
@@ -65539,7 +65661,7 @@ function normalizeStreamingTextDelta(rawDelta, state) {
|
|
|
65539
65661
|
if (rawDelta === state.emittedText) {
|
|
65540
65662
|
if (rawDelta.length >= CUMULATIVE_DELTA_EXACT_REPEAT_MIN_LENGTH) {
|
|
65541
65663
|
state.cumulativeMode = true;
|
|
65542
|
-
|
|
65664
|
+
debugLogger6.debug(
|
|
65543
65665
|
`normalizeStreamingTextDelta: entered cumulative mode (exact repeat, ${rawDelta.length}b)`
|
|
65544
65666
|
);
|
|
65545
65667
|
return "";
|
|
@@ -65759,6 +65881,8 @@ function processContent(content, messages, requestContext) {
|
|
|
65759
65881
|
const reasoningParts = [];
|
|
65760
65882
|
const toolCalls = [];
|
|
65761
65883
|
let toolCallIndex = 0;
|
|
65884
|
+
const emittedFunctionCallIds = /* @__PURE__ */ new Set();
|
|
65885
|
+
const emittedFunctionResponseIds = /* @__PURE__ */ new Set();
|
|
65762
65886
|
const accumulatedSplitMedia = [];
|
|
65763
65887
|
for (const part of parts) {
|
|
65764
65888
|
if (typeof part === "string") {
|
|
@@ -65778,8 +65902,18 @@ function processContent(content, messages, requestContext) {
|
|
|
65778
65902
|
contentParts.push(mediaPart);
|
|
65779
65903
|
}
|
|
65780
65904
|
if ("functionCall" in part && part.functionCall && role === "assistant") {
|
|
65905
|
+
const callId = part.functionCall.id;
|
|
65906
|
+
if (callId) {
|
|
65907
|
+
if (emittedFunctionCallIds.has(callId)) {
|
|
65908
|
+
debugLogger6.debug(
|
|
65909
|
+
`Dropping duplicate functionCall id=${callId} while converting content`
|
|
65910
|
+
);
|
|
65911
|
+
continue;
|
|
65912
|
+
}
|
|
65913
|
+
emittedFunctionCallIds.add(callId);
|
|
65914
|
+
}
|
|
65781
65915
|
toolCalls.push({
|
|
65782
|
-
id:
|
|
65916
|
+
id: callId || `call_${toolCallIndex}`,
|
|
65783
65917
|
type: "function",
|
|
65784
65918
|
function: {
|
|
65785
65919
|
name: part.functionCall.name || "",
|
|
@@ -65789,6 +65923,13 @@ function processContent(content, messages, requestContext) {
|
|
|
65789
65923
|
toolCallIndex += 1;
|
|
65790
65924
|
}
|
|
65791
65925
|
if (part.functionResponse && role === "user") {
|
|
65926
|
+
const responseId = part.functionResponse.id;
|
|
65927
|
+
if (responseId) {
|
|
65928
|
+
if (emittedFunctionResponseIds.has(responseId)) {
|
|
65929
|
+
continue;
|
|
65930
|
+
}
|
|
65931
|
+
emittedFunctionResponseIds.add(responseId);
|
|
65932
|
+
}
|
|
65792
65933
|
const toolMessage = createToolMessage(
|
|
65793
65934
|
part.functionResponse,
|
|
65794
65935
|
requestContext
|
|
@@ -66048,7 +66189,7 @@ function createMediaContentPart(part, requestContext) {
|
|
|
66048
66189
|
}
|
|
66049
66190
|
__name(createMediaContentPart, "createMediaContentPart");
|
|
66050
66191
|
function unsupportedModalityPlaceholder(modality, displayName, requestContext) {
|
|
66051
|
-
|
|
66192
|
+
debugLogger6.warn(
|
|
66052
66193
|
`Model '${requestContext.model}' does not support ${modality} input. Replacing with text placeholder: ${displayName}`
|
|
66053
66194
|
);
|
|
66054
66195
|
let hint;
|
|
@@ -66372,16 +66513,27 @@ function isSplitToolMediaMessage(message) {
|
|
|
66372
66513
|
__name(isSplitToolMediaMessage, "isSplitToolMediaMessage");
|
|
66373
66514
|
function cleanOrphanedToolCalls(messages) {
|
|
66374
66515
|
const cleaned = [];
|
|
66375
|
-
const
|
|
66516
|
+
const validToolCallsByAssistant = /* @__PURE__ */ new Map();
|
|
66376
66517
|
const validToolResponseIndexesByAssistant = /* @__PURE__ */ new Map();
|
|
66377
66518
|
const splitMediaIndexesByAssistant = /* @__PURE__ */ new Map();
|
|
66378
66519
|
const emittedWithAssistant = /* @__PURE__ */ new Set();
|
|
66520
|
+
const survivingToolCallIds = /* @__PURE__ */ new Set();
|
|
66379
66521
|
for (let index = 0; index < messages.length; index += 1) {
|
|
66380
66522
|
const message = messages[index];
|
|
66381
66523
|
if (hasToolCalls(message)) {
|
|
66382
|
-
const
|
|
66383
|
-
|
|
66384
|
-
)
|
|
66524
|
+
const candidateToolCalls = [];
|
|
66525
|
+
const candidateToolCallIds = /* @__PURE__ */ new Set();
|
|
66526
|
+
for (const toolCall of message.tool_calls) {
|
|
66527
|
+
const id = toolCall.id;
|
|
66528
|
+
if (!id || survivingToolCallIds.has(id)) {
|
|
66529
|
+
continue;
|
|
66530
|
+
}
|
|
66531
|
+
if (candidateToolCallIds.has(id)) {
|
|
66532
|
+
continue;
|
|
66533
|
+
}
|
|
66534
|
+
candidateToolCallIds.add(id);
|
|
66535
|
+
candidateToolCalls.push(toolCall);
|
|
66536
|
+
}
|
|
66385
66537
|
const adjacentToolResponseIds = /* @__PURE__ */ new Set();
|
|
66386
66538
|
const toolResponseIndexes = [];
|
|
66387
66539
|
const splitMediaIndexes = [];
|
|
@@ -66393,7 +66545,7 @@ function cleanOrphanedToolCalls(messages) {
|
|
|
66393
66545
|
lastToolResponseMatchesAssistant = false;
|
|
66394
66546
|
continue;
|
|
66395
66547
|
}
|
|
66396
|
-
if (
|
|
66548
|
+
if (candidateToolCallIds.has(nextMessage.tool_call_id) && !adjacentToolResponseIds.has(nextMessage.tool_call_id)) {
|
|
66397
66549
|
adjacentToolResponseIds.add(nextMessage.tool_call_id);
|
|
66398
66550
|
toolResponseIndexes.push(nextIndex);
|
|
66399
66551
|
lastToolResponseMatchesAssistant = true;
|
|
@@ -66413,7 +66565,13 @@ function cleanOrphanedToolCalls(messages) {
|
|
|
66413
66565
|
}
|
|
66414
66566
|
break;
|
|
66415
66567
|
}
|
|
66416
|
-
|
|
66568
|
+
const validToolCalls = candidateToolCalls.filter(
|
|
66569
|
+
(toolCall) => adjacentToolResponseIds.has(toolCall.id)
|
|
66570
|
+
);
|
|
66571
|
+
for (const toolCall of validToolCalls) {
|
|
66572
|
+
survivingToolCallIds.add(toolCall.id);
|
|
66573
|
+
}
|
|
66574
|
+
validToolCallsByAssistant.set(index, validToolCalls);
|
|
66417
66575
|
validToolResponseIndexesByAssistant.set(index, toolResponseIndexes);
|
|
66418
66576
|
splitMediaIndexesByAssistant.set(index, splitMediaIndexes);
|
|
66419
66577
|
}
|
|
@@ -66425,10 +66583,7 @@ function cleanOrphanedToolCalls(messages) {
|
|
|
66425
66583
|
const message = messages[index];
|
|
66426
66584
|
if (hasToolCalls(message)) {
|
|
66427
66585
|
const reasoningContent = message.reasoning_content;
|
|
66428
|
-
const
|
|
66429
|
-
const validToolCalls = message.tool_calls.filter(
|
|
66430
|
-
(toolCall) => toolCall.id && adjacentToolResponseIds.has(toolCall.id)
|
|
66431
|
-
);
|
|
66586
|
+
const validToolCalls = validToolCallsByAssistant.get(index) ?? [];
|
|
66432
66587
|
if (validToolCalls.length > 0) {
|
|
66433
66588
|
const cleanedMessage = { ...message };
|
|
66434
66589
|
cleanedMessage.tool_calls = validToolCalls;
|
|
@@ -66454,16 +66609,16 @@ function cleanOrphanedToolCalls(messages) {
|
|
|
66454
66609
|
delete cleanedMessage.tool_calls;
|
|
66455
66610
|
cleaned.push(cleanedMessage);
|
|
66456
66611
|
} else {
|
|
66457
|
-
|
|
66612
|
+
debugLogger6.debug(
|
|
66458
66613
|
`cleanOrphanedToolCalls: dropping assistant with ${message.tool_calls.length} orphaned tool call(s) and no text/reasoning content`
|
|
66459
66614
|
);
|
|
66460
66615
|
}
|
|
66461
66616
|
} else if (message.role === "tool" && "tool_call_id" in message) {
|
|
66462
|
-
|
|
66617
|
+
debugLogger6.debug(
|
|
66463
66618
|
`cleanOrphanedToolCalls: dropping orphaned tool response ${message.tool_call_id || "<empty>"}`
|
|
66464
66619
|
);
|
|
66465
66620
|
} else if (isSplitToolMediaMessage(message)) {
|
|
66466
|
-
|
|
66621
|
+
debugLogger6.debug(
|
|
66467
66622
|
"cleanOrphanedToolCalls: dropping orphaned split tool media message"
|
|
66468
66623
|
);
|
|
66469
66624
|
} else {
|
|
@@ -66591,7 +66746,7 @@ var v4_default = v4;
|
|
|
66591
66746
|
|
|
66592
66747
|
// packages/core/src/utils/openaiLogger.ts
|
|
66593
66748
|
import * as os2 from "os";
|
|
66594
|
-
var
|
|
66749
|
+
var debugLogger7 = createDebugLogger("OPENAI_LOGGER");
|
|
66595
66750
|
var MAIN_SESSION_PROMPT_ID_DELIMITER = "########";
|
|
66596
66751
|
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
66597
66752
|
function resolveOpenAILogDir(customLogDir, cwd) {
|
|
@@ -66687,7 +66842,7 @@ var OpenAILogger = class {
|
|
|
66687
66842
|
await fs4.mkdir(this.logDir, { recursive: true });
|
|
66688
66843
|
this.initialized = true;
|
|
66689
66844
|
} catch (error) {
|
|
66690
|
-
|
|
66845
|
+
debugLogger7.error("Failed to initialize OpenAI logger:", error);
|
|
66691
66846
|
throw new Error(`Failed to initialize OpenAI logger: ${error}`);
|
|
66692
66847
|
}
|
|
66693
66848
|
}
|
|
@@ -66729,7 +66884,7 @@ var OpenAILogger = class {
|
|
|
66729
66884
|
await fs4.writeFile(filePath, JSON.stringify(logData, null, 2), "utf-8");
|
|
66730
66885
|
return filePath;
|
|
66731
66886
|
} catch (writeError) {
|
|
66732
|
-
|
|
66887
|
+
debugLogger7.error("Failed to write OpenAI log file:", writeError);
|
|
66733
66888
|
throw new Error(`Failed to write OpenAI log file: ${writeError}`);
|
|
66734
66889
|
}
|
|
66735
66890
|
}
|
|
@@ -66750,7 +66905,7 @@ var OpenAILogger = class {
|
|
|
66750
66905
|
if (error.code === "ENOENT") {
|
|
66751
66906
|
return [];
|
|
66752
66907
|
}
|
|
66753
|
-
|
|
66908
|
+
debugLogger7.error("Failed to read OpenAI log directory:", error);
|
|
66754
66909
|
return [];
|
|
66755
66910
|
}
|
|
66756
66911
|
}
|
|
@@ -66764,7 +66919,7 @@ var OpenAILogger = class {
|
|
|
66764
66919
|
const content = await fs4.readFile(filePath, "utf-8");
|
|
66765
66920
|
return JSON.parse(content);
|
|
66766
66921
|
} catch (error) {
|
|
66767
|
-
|
|
66922
|
+
debugLogger7.error(`Failed to read log file ${filePath}:`, error);
|
|
66768
66923
|
throw new Error(`Failed to read log file: ${error}`);
|
|
66769
66924
|
}
|
|
66770
66925
|
}
|
|
@@ -67036,7 +67191,7 @@ function clearDetailedSpanState() {
|
|
|
67036
67191
|
__name(clearDetailedSpanState, "clearDetailedSpanState");
|
|
67037
67192
|
|
|
67038
67193
|
// packages/core/src/telemetry/session-tracing.ts
|
|
67039
|
-
var
|
|
67194
|
+
var debugLogger8 = createDebugLogger("SESSION_TRACING");
|
|
67040
67195
|
function resolveParentContext(parent) {
|
|
67041
67196
|
if (parent) {
|
|
67042
67197
|
return trace.setSpan(context.active(), parent.span);
|
|
@@ -67117,18 +67272,18 @@ function sweepStaleSpans(now) {
|
|
|
67117
67272
|
} : {}
|
|
67118
67273
|
});
|
|
67119
67274
|
} catch (error) {
|
|
67120
|
-
|
|
67275
|
+
debugLogger8.warn(
|
|
67121
67276
|
`Failed to stamp TTL attrs on stale span ${spanId}: ${error instanceof Error ? error.message : String(error)}`
|
|
67122
67277
|
);
|
|
67123
67278
|
}
|
|
67124
67279
|
const ctxLabel = toolName && callId ? `${ctx.type} (tool.name=${toolName}, tool.call_id=${callId})` : ctx.type;
|
|
67125
|
-
|
|
67280
|
+
debugLogger8.warn(
|
|
67126
67281
|
`Stale ${ctxLabel} span ended by TTL safety net (age=${ageMs}ms, spanId=${spanId})`
|
|
67127
67282
|
);
|
|
67128
67283
|
try {
|
|
67129
67284
|
ctx.span.end();
|
|
67130
67285
|
} catch (error) {
|
|
67131
|
-
|
|
67286
|
+
debugLogger8.warn(
|
|
67132
67287
|
`Failed to end stale span ${spanId}: ${error instanceof Error ? error.message : String(error)}`
|
|
67133
67288
|
);
|
|
67134
67289
|
}
|
|
@@ -67198,7 +67353,7 @@ function endInteractionSpan(status, metadata) {
|
|
|
67198
67353
|
const spanCtx = interactionContext.getStore() ?? lastInteractionCtx;
|
|
67199
67354
|
if (!spanCtx) return;
|
|
67200
67355
|
if (spanCtx.ended) {
|
|
67201
|
-
|
|
67356
|
+
debugLogger8.debug(
|
|
67202
67357
|
`endInteractionSpan: span ${getSpanId(spanCtx.span)} already ended (possible TTL sweep race)`
|
|
67203
67358
|
);
|
|
67204
67359
|
return;
|
|
@@ -67339,7 +67494,7 @@ function endLLMRequestSpan(span, metadata) {
|
|
|
67339
67494
|
const spanCtx = activeSpans.get(spanId)?.deref();
|
|
67340
67495
|
if (!spanCtx) return;
|
|
67341
67496
|
if (spanCtx.ended) {
|
|
67342
|
-
|
|
67497
|
+
debugLogger8.debug(
|
|
67343
67498
|
`endLLMRequestSpan: span ${spanId} already ended (possible TTL sweep race)`
|
|
67344
67499
|
);
|
|
67345
67500
|
return;
|
|
@@ -67419,14 +67574,14 @@ function endLLMRequestSpan(span, metadata) {
|
|
|
67419
67574
|
});
|
|
67420
67575
|
}
|
|
67421
67576
|
} catch (error) {
|
|
67422
|
-
|
|
67577
|
+
debugLogger8.warn(
|
|
67423
67578
|
`Failed to update LLM request span attributes/status: ${error instanceof Error ? error.message : String(error)}`
|
|
67424
67579
|
);
|
|
67425
67580
|
}
|
|
67426
67581
|
try {
|
|
67427
67582
|
spanCtx.span.end();
|
|
67428
67583
|
} catch (error) {
|
|
67429
|
-
|
|
67584
|
+
debugLogger8.warn(
|
|
67430
67585
|
`Failed to end LLM request span: ${error instanceof Error ? error.message : String(error)}`
|
|
67431
67586
|
);
|
|
67432
67587
|
}
|
|
@@ -67476,7 +67631,7 @@ function endToolSpan(span, metadata) {
|
|
|
67476
67631
|
const spanCtx = activeSpans.get(spanId)?.deref();
|
|
67477
67632
|
if (!spanCtx) return;
|
|
67478
67633
|
if (spanCtx.ended) {
|
|
67479
|
-
|
|
67634
|
+
debugLogger8.debug(
|
|
67480
67635
|
`endToolSpan: span ${spanId} already ended (possible TTL sweep race)`
|
|
67481
67636
|
);
|
|
67482
67637
|
return;
|
|
@@ -67503,14 +67658,14 @@ function endToolSpan(span, metadata) {
|
|
|
67503
67658
|
}
|
|
67504
67659
|
}
|
|
67505
67660
|
} catch (error) {
|
|
67506
|
-
|
|
67661
|
+
debugLogger8.warn(
|
|
67507
67662
|
`Failed to update tool span attributes/status: ${error instanceof Error ? error.message : String(error)}`
|
|
67508
67663
|
);
|
|
67509
67664
|
}
|
|
67510
67665
|
try {
|
|
67511
67666
|
spanCtx.span.end();
|
|
67512
67667
|
} catch (error) {
|
|
67513
|
-
|
|
67668
|
+
debugLogger8.warn(
|
|
67514
67669
|
`Failed to end tool span: ${error instanceof Error ? error.message : String(error)}`
|
|
67515
67670
|
);
|
|
67516
67671
|
}
|
|
@@ -67524,7 +67679,7 @@ function startToolExecutionSpan() {
|
|
|
67524
67679
|
}
|
|
67525
67680
|
const parentCtx = toolContext.getStore();
|
|
67526
67681
|
if (!parentCtx) {
|
|
67527
|
-
|
|
67682
|
+
debugLogger8.warn(
|
|
67528
67683
|
"startToolExecutionSpan called outside runInToolSpanContext \u2014 span will not be parented to tool span"
|
|
67529
67684
|
);
|
|
67530
67685
|
}
|
|
@@ -67557,7 +67712,7 @@ function endToolExecutionSpan(span, metadata) {
|
|
|
67557
67712
|
const spanCtx = activeSpans.get(spanId)?.deref();
|
|
67558
67713
|
if (!spanCtx) return;
|
|
67559
67714
|
if (spanCtx.ended) {
|
|
67560
|
-
|
|
67715
|
+
debugLogger8.debug(
|
|
67561
67716
|
`endToolExecutionSpan: span ${spanId} already ended (possible TTL sweep race)`
|
|
67562
67717
|
);
|
|
67563
67718
|
return;
|
|
@@ -67584,14 +67739,14 @@ function endToolExecutionSpan(span, metadata) {
|
|
|
67584
67739
|
}
|
|
67585
67740
|
}
|
|
67586
67741
|
} catch (error) {
|
|
67587
|
-
|
|
67742
|
+
debugLogger8.warn(
|
|
67588
67743
|
`Failed to update tool execution span attributes/status: ${error instanceof Error ? error.message : String(error)}`
|
|
67589
67744
|
);
|
|
67590
67745
|
}
|
|
67591
67746
|
try {
|
|
67592
67747
|
spanCtx.span.end();
|
|
67593
67748
|
} catch (error) {
|
|
67594
|
-
|
|
67749
|
+
debugLogger8.warn(
|
|
67595
67750
|
`Failed to end tool execution span: ${error instanceof Error ? error.message : String(error)}`
|
|
67596
67751
|
);
|
|
67597
67752
|
}
|
|
@@ -67607,12 +67762,16 @@ function startToolBlockedOnUserSpan(toolSpan, attrs) {
|
|
|
67607
67762
|
const parentSpanId = getSpanId(toolSpan);
|
|
67608
67763
|
const parentSpanCtx = activeSpans.get(parentSpanId)?.deref();
|
|
67609
67764
|
if (!parentSpanCtx) {
|
|
67610
|
-
|
|
67765
|
+
debugLogger8.debug(
|
|
67611
67766
|
"startToolBlockedOnUserSpan: tool span not in activeSpans (already ended?) \u2014 using resolveParentContext fallback"
|
|
67612
67767
|
);
|
|
67613
67768
|
}
|
|
67614
67769
|
const ctx = parentSpanCtx ? trace.setSpan(context.active(), parentSpanCtx.span) : resolveParentContext(void 0);
|
|
67615
|
-
const
|
|
67770
|
+
const sessionParentCtx = parentSpanCtx ?? subagentContext.getStore() ?? interactionContext.getStore() ?? void 0;
|
|
67771
|
+
const sessionId = resolveSessionId(sessionParentCtx);
|
|
67772
|
+
const attributes = {
|
|
67773
|
+
...sessionId ? { "session.id": sessionId } : {}
|
|
67774
|
+
};
|
|
67616
67775
|
if (attrs?.tool_name !== void 0) attributes["tool.name"] = attrs.tool_name;
|
|
67617
67776
|
if (attrs?.call_id !== void 0) attributes["tool.call_id"] = attrs.call_id;
|
|
67618
67777
|
const span = getTracer().startSpan(
|
|
@@ -67637,7 +67796,7 @@ function endToolBlockedOnUserSpan(span, metadata) {
|
|
|
67637
67796
|
const spanCtx = activeSpans.get(spanId)?.deref();
|
|
67638
67797
|
if (!spanCtx) return;
|
|
67639
67798
|
if (spanCtx.ended) {
|
|
67640
|
-
|
|
67799
|
+
debugLogger8.debug(
|
|
67641
67800
|
`endToolBlockedOnUserSpan: span ${spanId} already ended (possible TTL sweep race)`
|
|
67642
67801
|
);
|
|
67643
67802
|
return;
|
|
@@ -67652,14 +67811,14 @@ function endToolBlockedOnUserSpan(span, metadata) {
|
|
|
67652
67811
|
endAttributes["source"] = metadata.source;
|
|
67653
67812
|
spanCtx.span.setAttributes(endAttributes);
|
|
67654
67813
|
} catch (error) {
|
|
67655
|
-
|
|
67814
|
+
debugLogger8.warn(
|
|
67656
67815
|
`Failed to update blocked_on_user span attributes: ${error instanceof Error ? error.message : String(error)}`
|
|
67657
67816
|
);
|
|
67658
67817
|
}
|
|
67659
67818
|
try {
|
|
67660
67819
|
spanCtx.span.end();
|
|
67661
67820
|
} catch (error) {
|
|
67662
|
-
|
|
67821
|
+
debugLogger8.warn(
|
|
67663
67822
|
`Failed to end blocked_on_user span: ${error instanceof Error ? error.message : String(error)}`
|
|
67664
67823
|
);
|
|
67665
67824
|
}
|
|
@@ -67674,7 +67833,9 @@ function startHookSpan(opts) {
|
|
|
67674
67833
|
ensureCleanupInterval();
|
|
67675
67834
|
const parentCtx = toolContext.getStore() ?? subagentContext.getStore() ?? interactionContext.getStore() ?? void 0;
|
|
67676
67835
|
const ctx = resolveParentContext(parentCtx);
|
|
67836
|
+
const sessionId = resolveSessionId(parentCtx);
|
|
67677
67837
|
const attributes = {
|
|
67838
|
+
...sessionId ? { "session.id": sessionId } : {},
|
|
67678
67839
|
hook_event: opts.hookEvent,
|
|
67679
67840
|
"tool.name": opts.toolName
|
|
67680
67841
|
};
|
|
@@ -67703,7 +67864,7 @@ function endHookSpan(span, metadata) {
|
|
|
67703
67864
|
const spanCtx = activeSpans.get(spanId)?.deref();
|
|
67704
67865
|
if (!spanCtx) return;
|
|
67705
67866
|
if (spanCtx.ended) {
|
|
67706
|
-
|
|
67867
|
+
debugLogger8.debug(
|
|
67707
67868
|
`endHookSpan: span ${spanId} already ended (possible TTL sweep race)`
|
|
67708
67869
|
);
|
|
67709
67870
|
return;
|
|
@@ -67740,14 +67901,14 @@ function endHookSpan(span, metadata) {
|
|
|
67740
67901
|
});
|
|
67741
67902
|
}
|
|
67742
67903
|
} catch (error) {
|
|
67743
|
-
|
|
67904
|
+
debugLogger8.warn(
|
|
67744
67905
|
`Failed to update hook span attributes/status: ${error instanceof Error ? error.message : String(error)}`
|
|
67745
67906
|
);
|
|
67746
67907
|
}
|
|
67747
67908
|
try {
|
|
67748
67909
|
spanCtx.span.end();
|
|
67749
67910
|
} catch (error) {
|
|
67750
|
-
|
|
67911
|
+
debugLogger8.warn(
|
|
67751
67912
|
`Failed to end hook span: ${error instanceof Error ? error.message : String(error)}`
|
|
67752
67913
|
);
|
|
67753
67914
|
}
|
|
@@ -67830,14 +67991,14 @@ function endSubagentSpan(span, metadata) {
|
|
|
67830
67991
|
const spanCtx = activeSpans.get(spanId)?.deref();
|
|
67831
67992
|
if (!spanCtx) {
|
|
67832
67993
|
if (isTelemetrySdkInitialized()) {
|
|
67833
|
-
|
|
67994
|
+
debugLogger8.warn(
|
|
67834
67995
|
`endSubagentSpan: span ${spanId} not found in activeSpans (already swept?) \u2014 intended status=${metadata.status}, reason=${metadata.terminateReason ?? "none"}`
|
|
67835
67996
|
);
|
|
67836
67997
|
}
|
|
67837
67998
|
return;
|
|
67838
67999
|
}
|
|
67839
68000
|
if (spanCtx.ended) {
|
|
67840
|
-
|
|
68001
|
+
debugLogger8.warn(
|
|
67841
68002
|
`endSubagentSpan: span ${spanId} already ended \u2014 intended status=${metadata.status}, reason=${metadata.terminateReason ?? "none"} (possible TTL sweep race)`
|
|
67842
68003
|
);
|
|
67843
68004
|
return;
|
|
@@ -67873,14 +68034,14 @@ function endSubagentSpan(span, metadata) {
|
|
|
67873
68034
|
});
|
|
67874
68035
|
}
|
|
67875
68036
|
} catch (error) {
|
|
67876
|
-
|
|
68037
|
+
debugLogger8.warn(
|
|
67877
68038
|
`Failed to update subagent span attributes/status: ${error instanceof Error ? error.message : String(error)}`
|
|
67878
68039
|
);
|
|
67879
68040
|
}
|
|
67880
68041
|
try {
|
|
67881
68042
|
spanCtx.span.end();
|
|
67882
68043
|
} catch (error) {
|
|
67883
|
-
|
|
68044
|
+
debugLogger8.warn(
|
|
67884
68045
|
`Failed to end subagent span: ${error instanceof Error ? error.message : String(error)}`
|
|
67885
68046
|
);
|
|
67886
68047
|
}
|
|
@@ -68208,7 +68369,7 @@ __name(hrTimeDiff, "hrTimeDiff");
|
|
|
68208
68369
|
init_esbuild_shims();
|
|
68209
68370
|
init_esm();
|
|
68210
68371
|
var tracer = trace.getTracer(SERVICE_NAME);
|
|
68211
|
-
var
|
|
68372
|
+
var debugLogger9 = createDebugLogger("OTEL_TRACER");
|
|
68212
68373
|
var TELEMETRY_WARNING_INTERVAL_MS = 3e4;
|
|
68213
68374
|
var API_CALL_FAILED_SPAN_STATUS_MESSAGE = "API call failed";
|
|
68214
68375
|
var API_CALL_ABORTED_SPAN_STATUS_MESSAGE = "API call aborted";
|
|
@@ -68224,7 +68385,7 @@ function warnTelemetryOperationFailed(operation, error) {
|
|
|
68224
68385
|
suppressedTelemetryWarnings = 0;
|
|
68225
68386
|
lastTelemetryWarningMs = now;
|
|
68226
68387
|
try {
|
|
68227
|
-
|
|
68388
|
+
debugLogger9.warn(
|
|
68228
68389
|
`OTel span ${operation} failed: ${error instanceof Error ? error.message : String(error)}${suppressedSuffix}`
|
|
68229
68390
|
);
|
|
68230
68391
|
} catch {
|
|
@@ -68263,13 +68424,13 @@ __name(createSessionRootContext, "createSessionRootContext");
|
|
|
68263
68424
|
|
|
68264
68425
|
// packages/core/src/telemetry/sdk.ts
|
|
68265
68426
|
function createTelemetryDiagLogger() {
|
|
68266
|
-
const
|
|
68427
|
+
const debugLogger13 = createDebugLogger("OTEL");
|
|
68267
68428
|
return {
|
|
68268
|
-
error: /* @__PURE__ */ __name((message, ...args) =>
|
|
68269
|
-
warn: /* @__PURE__ */ __name((message, ...args) =>
|
|
68270
|
-
info: /* @__PURE__ */ __name((message, ...args) =>
|
|
68271
|
-
debug: /* @__PURE__ */ __name((message, ...args) =>
|
|
68272
|
-
verbose: /* @__PURE__ */ __name((message, ...args) =>
|
|
68429
|
+
error: /* @__PURE__ */ __name((message, ...args) => debugLogger13.error(message, ...args), "error"),
|
|
68430
|
+
warn: /* @__PURE__ */ __name((message, ...args) => debugLogger13.warn(message, ...args), "warn"),
|
|
68431
|
+
info: /* @__PURE__ */ __name((message, ...args) => debugLogger13.info(message, ...args), "info"),
|
|
68432
|
+
debug: /* @__PURE__ */ __name((message, ...args) => debugLogger13.debug(message, ...args), "debug"),
|
|
68433
|
+
verbose: /* @__PURE__ */ __name((message, ...args) => debugLogger13.debug(message, ...args), "verbose")
|
|
68273
68434
|
};
|
|
68274
68435
|
}
|
|
68275
68436
|
__name(createTelemetryDiagLogger, "createTelemetryDiagLogger");
|
|
@@ -68372,7 +68533,7 @@ function initializeTelemetry(config) {
|
|
|
68372
68533
|
if (telemetryInitialized || !config.getTelemetryEnabled()) {
|
|
68373
68534
|
return;
|
|
68374
68535
|
}
|
|
68375
|
-
const
|
|
68536
|
+
const debugLogger13 = createDebugLogger("OTEL");
|
|
68376
68537
|
const userAttrs = config.getTelemetryResourceAttributes() ?? {};
|
|
68377
68538
|
const userServiceName = userAttrs["service.name"];
|
|
68378
68539
|
const {
|
|
@@ -68421,7 +68582,7 @@ function initializeTelemetry(config) {
|
|
|
68421
68582
|
const metricsUrl = validateUrl(
|
|
68422
68583
|
config.getTelemetryOtlpMetricsEndpoint() ?? (parsedEndpoint ? resolveHttpOtlpUrl(parsedEndpoint, "metrics") : void 0)
|
|
68423
68584
|
);
|
|
68424
|
-
|
|
68585
|
+
debugLogger13.debug(
|
|
68425
68586
|
`OTLP HTTP endpoints: traces=${tracesUrl ?? "none"}, logs=${logsUrl ?? "none"}, metrics=${metricsUrl ?? "none"}`
|
|
68426
68587
|
);
|
|
68427
68588
|
if (tracesUrl) {
|
|
@@ -68446,7 +68607,7 @@ function initializeTelemetry(config) {
|
|
|
68446
68607
|
// trade-off, since falling back to stderr would re-introduce the
|
|
68447
68608
|
// TUI pollution this injection was added to prevent.
|
|
68448
68609
|
...config.isInteractive() && {
|
|
68449
|
-
diagnosticsSink: /* @__PURE__ */ __name((message) =>
|
|
68610
|
+
diagnosticsSink: /* @__PURE__ */ __name((message) => debugLogger13.warn(message), "diagnosticsSink")
|
|
68450
68611
|
}
|
|
68451
68612
|
}
|
|
68452
68613
|
);
|
|
@@ -68461,7 +68622,7 @@ function initializeTelemetry(config) {
|
|
|
68461
68622
|
if (!parsedEndpoint) {
|
|
68462
68623
|
const warning = 'Per-signal OTLP endpoints are only supported with HTTP protocol. Set otlpProtocol to "http" or provide a base otlpEndpoint for gRPC. Telemetry SDK startup was skipped because no supported gRPC endpoint was configured.';
|
|
68463
68624
|
diag.warn(warning);
|
|
68464
|
-
|
|
68625
|
+
debugLogger13.warn(warning);
|
|
68465
68626
|
return;
|
|
68466
68627
|
} else {
|
|
68467
68628
|
spanExporter = new import_exporter_trace_otlp_grpc.OTLPTraceExporter({
|
|
@@ -68583,7 +68744,7 @@ function initializeTelemetry(config) {
|
|
|
68583
68744
|
});
|
|
68584
68745
|
try {
|
|
68585
68746
|
sdk.start();
|
|
68586
|
-
|
|
68747
|
+
debugLogger13.debug("OpenTelemetry SDK started successfully.");
|
|
68587
68748
|
telemetryInitialized = true;
|
|
68588
68749
|
activeMetricReader = metricReader;
|
|
68589
68750
|
const sessionId = config.getSessionId();
|
|
@@ -68593,7 +68754,7 @@ function initializeTelemetry(config) {
|
|
|
68593
68754
|
);
|
|
68594
68755
|
initializeMetrics(config);
|
|
68595
68756
|
} catch (error) {
|
|
68596
|
-
|
|
68757
|
+
debugLogger13.error("Error starting OpenTelemetry SDK:", error);
|
|
68597
68758
|
}
|
|
68598
68759
|
}
|
|
68599
68760
|
__name(initializeTelemetry, "initializeTelemetry");
|
|
@@ -68615,7 +68776,7 @@ async function shutdownTelemetry() {
|
|
|
68615
68776
|
}
|
|
68616
68777
|
endInteractionSpan("cancelled");
|
|
68617
68778
|
const currentSdk = sdk;
|
|
68618
|
-
const
|
|
68779
|
+
const debugLogger13 = createDebugLogger("OTEL");
|
|
68619
68780
|
telemetryShutdownPromise = (async () => {
|
|
68620
68781
|
let timer;
|
|
68621
68782
|
let timedOut = false;
|
|
@@ -68623,7 +68784,7 @@ async function shutdownTelemetry() {
|
|
|
68623
68784
|
const sdkShutdown = Promise.resolve(currentSdk.shutdown());
|
|
68624
68785
|
sdkShutdown.catch((err) => {
|
|
68625
68786
|
if (timedOut) {
|
|
68626
|
-
|
|
68787
|
+
debugLogger13.warn(
|
|
68627
68788
|
"SDK shutdown rejected after timeout:",
|
|
68628
68789
|
err instanceof Error ? err.message : err
|
|
68629
68790
|
);
|
|
@@ -68641,14 +68802,14 @@ async function shutdownTelemetry() {
|
|
|
68641
68802
|
if (result === "timeout") {
|
|
68642
68803
|
const msg = `Telemetry shutdown timed out after ${SHUTDOWN_TIMEOUT_MS}ms.`;
|
|
68643
68804
|
diag.warn(msg);
|
|
68644
|
-
|
|
68805
|
+
debugLogger13.warn(msg);
|
|
68645
68806
|
} else {
|
|
68646
|
-
|
|
68807
|
+
debugLogger13.debug("OpenTelemetry SDK shut down successfully.");
|
|
68647
68808
|
}
|
|
68648
68809
|
} catch (error) {
|
|
68649
68810
|
clearTimeout(timer);
|
|
68650
68811
|
diag.error("Error shutting down SDK:", error);
|
|
68651
|
-
|
|
68812
|
+
debugLogger13.error("Error shutting down SDK:", error);
|
|
68652
68813
|
} finally {
|
|
68653
68814
|
telemetryInitialized = false;
|
|
68654
68815
|
sdk = void 0;
|
|
@@ -69127,13 +69288,6 @@ function errorType(error) {
|
|
|
69127
69288
|
__name(errorType, "errorType");
|
|
69128
69289
|
var INVALID_TRACE_ID = "0".repeat(32);
|
|
69129
69290
|
var INVALID_SPAN_ID = "0".repeat(16);
|
|
69130
|
-
function activeSpanContextIsValid() {
|
|
69131
|
-
const span = trace.getSpan(context.active());
|
|
69132
|
-
if (!span) return false;
|
|
69133
|
-
const ctx = span.spanContext();
|
|
69134
|
-
return ctx.traceId !== INVALID_TRACE_ID && ctx.spanId !== INVALID_SPAN_ID;
|
|
69135
|
-
}
|
|
69136
|
-
__name(activeSpanContextIsValid, "activeSpanContextIsValid");
|
|
69137
69291
|
function stripReservedTraceMeta(meta) {
|
|
69138
69292
|
if (!meta || typeof meta !== "object" || Array.isArray(meta)) return {};
|
|
69139
69293
|
const record = meta;
|
|
@@ -69264,18 +69418,11 @@ async function runWithDaemonTelemetryContext(captured, fn) {
|
|
|
69264
69418
|
__name(runWithDaemonTelemetryContext, "runWithDaemonTelemetryContext");
|
|
69265
69419
|
function injectDaemonTraceContext(request4) {
|
|
69266
69420
|
const currentMeta = request4._meta;
|
|
69267
|
-
if (!activeSpanContextIsValid()) {
|
|
69268
|
-
return currentMeta ? { ...request4, _meta: stripReservedTraceMeta(currentMeta) } : request4;
|
|
69269
|
-
}
|
|
69270
69421
|
const nextMeta = stripReservedTraceMeta(currentMeta);
|
|
69271
69422
|
try {
|
|
69272
|
-
const
|
|
69273
|
-
|
|
69274
|
-
|
|
69275
|
-
nextMeta[DAEMON_TRACEPARENT_META_KEY] = carrier["traceparent"];
|
|
69276
|
-
}
|
|
69277
|
-
if (carrier["tracestate"]) {
|
|
69278
|
-
nextMeta[DAEMON_TRACESTATE_META_KEY] = carrier["tracestate"];
|
|
69423
|
+
const ctx = getActiveSpanTraceContext();
|
|
69424
|
+
if (ctx) {
|
|
69425
|
+
nextMeta[DAEMON_TRACEPARENT_META_KEY] = formatTraceparent(ctx);
|
|
69279
69426
|
}
|
|
69280
69427
|
} catch {
|
|
69281
69428
|
}
|
|
@@ -69618,7 +69765,7 @@ function snapshotRetryMetadata() {
|
|
|
69618
69765
|
};
|
|
69619
69766
|
}
|
|
69620
69767
|
__name(snapshotRetryMetadata, "snapshotRetryMetadata");
|
|
69621
|
-
var
|
|
69768
|
+
var debugLogger10 = createDebugLogger("LOGGING_CONTENT_GENERATOR");
|
|
69622
69769
|
var MAX_RESPONSE_TEXT_LENGTH = 4096;
|
|
69623
69770
|
var RESPONSE_TEXT_TRUNCATION_SUFFIX = "...[truncated]";
|
|
69624
69771
|
var MAX_RESPONSE_TEXT_PREFIX_LENGTH = MAX_RESPONSE_TEXT_LENGTH - RESPONSE_TEXT_TRUNCATION_SUFFIX.length;
|
|
@@ -69699,7 +69846,7 @@ var LoggingContentGenerator = class {
|
|
|
69699
69846
|
try {
|
|
69700
69847
|
this._logApiError(responseId, durationMs, error, model, prompt_id);
|
|
69701
69848
|
} catch (loggingError) {
|
|
69702
|
-
|
|
69849
|
+
debugLogger10.warn("Failed to log API error:", loggingError);
|
|
69703
69850
|
}
|
|
69704
69851
|
}
|
|
69705
69852
|
safelyLogApiResponse(responseId, durationMs, model, prompt_id, usageMetadata, responseText) {
|
|
@@ -69713,7 +69860,7 @@ var LoggingContentGenerator = class {
|
|
|
69713
69860
|
responseText
|
|
69714
69861
|
);
|
|
69715
69862
|
} catch (loggingError) {
|
|
69716
|
-
|
|
69863
|
+
debugLogger10.warn("Failed to log API response:", loggingError);
|
|
69717
69864
|
}
|
|
69718
69865
|
}
|
|
69719
69866
|
async generateContent(req, userPromptId) {
|
|
@@ -69776,7 +69923,7 @@ var LoggingContentGenerator = class {
|
|
|
69776
69923
|
userPromptId
|
|
69777
69924
|
);
|
|
69778
69925
|
} catch (loggingError) {
|
|
69779
|
-
|
|
69926
|
+
debugLogger10.warn("Failed to log OpenAI interaction:", loggingError);
|
|
69780
69927
|
}
|
|
69781
69928
|
return result;
|
|
69782
69929
|
});
|
|
@@ -69815,7 +69962,7 @@ var LoggingContentGenerator = class {
|
|
|
69815
69962
|
userPromptId
|
|
69816
69963
|
);
|
|
69817
69964
|
} catch (loggingError) {
|
|
69818
|
-
|
|
69965
|
+
debugLogger10.warn("Failed to log OpenAI interaction:", loggingError);
|
|
69819
69966
|
}
|
|
69820
69967
|
});
|
|
69821
69968
|
throw error;
|
|
@@ -69886,7 +70033,7 @@ var LoggingContentGenerator = class {
|
|
|
69886
70033
|
userPromptId
|
|
69887
70034
|
);
|
|
69888
70035
|
} catch (loggingError) {
|
|
69889
|
-
|
|
70036
|
+
debugLogger10.warn("Failed to log OpenAI interaction:", loggingError);
|
|
69890
70037
|
}
|
|
69891
70038
|
throw error;
|
|
69892
70039
|
}
|
|
@@ -69895,7 +70042,7 @@ var LoggingContentGenerator = class {
|
|
|
69895
70042
|
try {
|
|
69896
70043
|
resolvedRequest = await session.resolve(req);
|
|
69897
70044
|
} catch (loggingError) {
|
|
69898
|
-
|
|
70045
|
+
debugLogger10.warn("Failed to resolve OpenAI request:", loggingError);
|
|
69899
70046
|
}
|
|
69900
70047
|
}
|
|
69901
70048
|
return context.with(
|
|
@@ -70129,7 +70276,7 @@ var LoggingContentGenerator = class {
|
|
|
70129
70276
|
try {
|
|
70130
70277
|
await this.logOpenAIInteraction(openaiRequest, response, error, promptId);
|
|
70131
70278
|
} catch (loggingError) {
|
|
70132
|
-
|
|
70279
|
+
debugLogger10.warn("Failed to log OpenAI interaction:", loggingError);
|
|
70133
70280
|
}
|
|
70134
70281
|
}
|
|
70135
70282
|
convertGeminiResponseToOpenAIForLogging(response, openaiRequest) {
|
|
@@ -70598,7 +70745,7 @@ var QWEN_OAUTH_ALLOWED_MODELS = QWEN_OAUTH_MODELS.map(
|
|
|
70598
70745
|
);
|
|
70599
70746
|
|
|
70600
70747
|
// packages/core/src/models/modelRegistry.ts
|
|
70601
|
-
var
|
|
70748
|
+
var debugLogger11 = createDebugLogger("MODEL_REGISTRY");
|
|
70602
70749
|
function validateAuthTypeKey(key) {
|
|
70603
70750
|
if (Object.values(AuthType).includes(key)) {
|
|
70604
70751
|
return key;
|
|
@@ -70636,7 +70783,7 @@ var ModelRegistry = class {
|
|
|
70636
70783
|
for (const [rawKey, models] of Object.entries(modelProvidersConfig)) {
|
|
70637
70784
|
const authType = validateAuthTypeKey(rawKey);
|
|
70638
70785
|
if (!authType) {
|
|
70639
|
-
|
|
70786
|
+
debugLogger11.warn(
|
|
70640
70787
|
`Invalid authType key "${rawKey}" in modelProviders config. Expected one of: ${Object.values(AuthType).join(", ")}. Skipping.`
|
|
70641
70788
|
);
|
|
70642
70789
|
continue;
|
|
@@ -70659,7 +70806,7 @@ var ModelRegistry = class {
|
|
|
70659
70806
|
for (const config of models) {
|
|
70660
70807
|
const key = modelRegistryKey(config.id, config.baseUrl);
|
|
70661
70808
|
if (modelMap.has(key)) {
|
|
70662
|
-
|
|
70809
|
+
debugLogger11.warn(
|
|
70663
70810
|
`Duplicate model id "${config.id}"${config.baseUrl ? ` with baseUrl "${config.baseUrl}"` : ""} for authType "${authType}". Using the first registered config.`
|
|
70664
70811
|
);
|
|
70665
70812
|
continue;
|
|
@@ -70774,7 +70921,7 @@ var ModelRegistry = class {
|
|
|
70774
70921
|
for (const [rawKey, models] of Object.entries(modelProvidersConfig)) {
|
|
70775
70922
|
const authType = validateAuthTypeKey(rawKey);
|
|
70776
70923
|
if (!authType) {
|
|
70777
|
-
|
|
70924
|
+
debugLogger11.warn(
|
|
70778
70925
|
`Invalid authType key "${rawKey}" in modelProviders config. Expected one of: ${Object.values(AuthType).join(", ")}. Skipping.`
|
|
70779
70926
|
);
|
|
70780
70927
|
continue;
|
|
@@ -71857,11 +72004,11 @@ async function createContentGenerator(generatorConfig, config, isInitialAuth) {
|
|
|
71857
72004
|
let baseGenerator;
|
|
71858
72005
|
try {
|
|
71859
72006
|
if (authType === "openai" /* USE_OPENAI */) {
|
|
71860
|
-
const { createOpenAIContentGenerator } = await import("./openaiContentGenerator-
|
|
72007
|
+
const { createOpenAIContentGenerator } = await import("./openaiContentGenerator-5PLHYJQL.js");
|
|
71861
72008
|
baseGenerator = createOpenAIContentGenerator(generatorConfig, config);
|
|
71862
72009
|
} else if (authType === "qwen-oauth" /* QWEN_OAUTH */) {
|
|
71863
|
-
const { getQwenOAuthClient: getQwenOauthClient } = await import("./qwenOAuth2-
|
|
71864
|
-
const { QwenContentGenerator } = await import("./qwenContentGenerator-
|
|
72010
|
+
const { getQwenOAuthClient: getQwenOauthClient } = await import("./qwenOAuth2-KK433U33.js");
|
|
72011
|
+
const { QwenContentGenerator } = await import("./qwenContentGenerator-TSKW73KY.js");
|
|
71865
72012
|
try {
|
|
71866
72013
|
const qwenClient = await getQwenOauthClient(
|
|
71867
72014
|
config,
|
|
@@ -71879,10 +72026,10 @@ async function createContentGenerator(generatorConfig, config, isInitialAuth) {
|
|
|
71879
72026
|
throw new Error(error instanceof Error ? error.message : String(error));
|
|
71880
72027
|
}
|
|
71881
72028
|
} else if (authType === "anthropic" /* USE_ANTHROPIC */) {
|
|
71882
|
-
const { createAnthropicContentGenerator } = await import("./anthropicContentGenerator-
|
|
72029
|
+
const { createAnthropicContentGenerator } = await import("./anthropicContentGenerator-DCI26OQF.js");
|
|
71883
72030
|
baseGenerator = createAnthropicContentGenerator(generatorConfig, config);
|
|
71884
72031
|
} else if (authType === "gemini" /* USE_GEMINI */ || authType === "vertex-ai" /* USE_VERTEX_AI */) {
|
|
71885
|
-
const { createGeminiContentGenerator } = await import("./geminiContentGenerator-
|
|
72032
|
+
const { createGeminiContentGenerator } = await import("./geminiContentGenerator-HFJIGO77.js");
|
|
71886
72033
|
baseGenerator = createGeminiContentGenerator(generatorConfig, config);
|
|
71887
72034
|
} else {
|
|
71888
72035
|
throw new Error(
|
|
@@ -73675,7 +73822,7 @@ function memoryFreshnessNote(mtimeMs) {
|
|
|
73675
73822
|
__name(memoryFreshnessNote, "memoryFreshnessNote");
|
|
73676
73823
|
|
|
73677
73824
|
// packages/core/src/tools/read-file.ts
|
|
73678
|
-
var
|
|
73825
|
+
var debugLogger12 = createDebugLogger("READ_FILE_CACHE");
|
|
73679
73826
|
var ReadFileToolInvocation = class extends BaseToolInvocation {
|
|
73680
73827
|
constructor(config, params) {
|
|
73681
73828
|
super(params);
|
|
@@ -73744,7 +73891,7 @@ var ReadFileToolInvocation = class extends BaseToolInvocation {
|
|
|
73744
73891
|
try {
|
|
73745
73892
|
stats = await fs7.stat(absPath);
|
|
73746
73893
|
} catch (err) {
|
|
73747
|
-
|
|
73894
|
+
debugLogger12.debug("stat-failed", {
|
|
73748
73895
|
path: absPath,
|
|
73749
73896
|
code: err.code
|
|
73750
73897
|
});
|
|
@@ -73754,10 +73901,10 @@ var ReadFileToolInvocation = class extends BaseToolInvocation {
|
|
|
73754
73901
|
if (status.state === "fresh" && status.entry.lastReadAt !== void 0 && status.entry.lastReadWasFull && status.entry.lastReadCacheable && // Only quote-back if that read is still in history (issue
|
|
73755
73902
|
// #4239: idle microcompaction flips this off when it blanks it).
|
|
73756
73903
|
status.entry.readResidentInHistory && (status.entry.lastWriteAt === void 0 || status.entry.lastReadAt > status.entry.lastWriteAt)) {
|
|
73757
|
-
|
|
73904
|
+
debugLogger12.debug("hit", { path: absPath });
|
|
73758
73905
|
return this.unchangedResult(absPath);
|
|
73759
73906
|
}
|
|
73760
|
-
|
|
73907
|
+
debugLogger12.debug("miss", { path: absPath, state: status.state });
|
|
73761
73908
|
}
|
|
73762
73909
|
const result = await processSingleFileContent(
|
|
73763
73910
|
this.params.file_path,
|
|
@@ -74131,6 +74278,8 @@ export {
|
|
|
74131
74278
|
TOOL_OUTPUT_TRUNCATED_PREFIX,
|
|
74132
74279
|
truncateToolOutput,
|
|
74133
74280
|
truncateLlmContent,
|
|
74281
|
+
isAlreadyTruncated,
|
|
74282
|
+
persistAndTruncateToolResult,
|
|
74134
74283
|
DiscoveredMCPTool,
|
|
74135
74284
|
generateValidName,
|
|
74136
74285
|
StartSessionEvent,
|