@qwen-code/qwen-code 0.18.0-preview.2 → 0.18.0
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/qc-helper/docs/_meta.ts +1 -0
- package/bundled/qc-helper/docs/configuration/settings.md +3 -5
- package/bundled/qc-helper/docs/features/approval-mode.md +10 -14
- package/bundled/qc-helper/docs/features/commands.md +33 -11
- package/bundled/qc-helper/docs/features/followup-suggestions.md +2 -2
- package/bundled/qc-helper/docs/features/sub-agents.md +32 -11
- package/bundled/qc-helper/docs/qwen-serve-deploy-local.md +221 -0
- package/bundled/qc-helper/docs/qwen-serve.md +234 -24
- package/chunks/{agent-QB7TZ4HW.js → agent-LOTJK6AH.js} +23 -23
- package/chunks/{agent-headless-APVHH7QM.js → agent-headless-TU3EPMYU.js} +23 -23
- package/chunks/{anthropicContentGenerator-M45EVVRM.js → anthropicContentGenerator-2HBRNQ3B.js} +7 -7
- package/chunks/{askUserQuestion-WM2KHM3K.js → askUserQuestion-OGCMIBQM.js} +45 -3
- package/chunks/{chunk-MVIVIPCU.js → chunk-2Y5SYSD3.js} +361 -583
- package/chunks/chunk-3DHXZ6EV.js +241 -0
- package/chunks/{chunk-JVQOQ3OU.js → chunk-3HTIVKZE.js} +1 -1
- package/chunks/{chunk-BNESGOSJ.js → chunk-55ZMG67I.js} +1 -1
- package/chunks/{chunk-ZK4AMNIU.js → chunk-6YIUGZTC.js} +1041 -210
- package/chunks/{chunk-C6WMLUNB.js → chunk-72LDN5PP.js} +1 -1
- package/chunks/{chunk-AVW55ZCO.js → chunk-7BCMOPIM.js} +11 -9
- package/chunks/{chunk-JUGRPQAB.js → chunk-A7B4ISQP.js} +1 -1
- package/chunks/{chunk-UAMOBVVW.js → chunk-B7HXHOHU.js} +1 -1
- package/chunks/{chunk-CNSMKPK6.js → chunk-BIVG75CP.js} +1 -1
- package/chunks/{chunk-LR62TEET.js → chunk-EYENRK4D.js} +1 -1
- package/chunks/{chunk-SZOEIL6S.js → chunk-H6BD2ELD.js} +1 -0
- package/chunks/{chunk-PAEBHDIO.js → chunk-HLPLOD42.js} +1 -1
- package/chunks/{chunk-JXAZUMDW.js → chunk-HR7SV7AY.js} +1 -2
- package/chunks/{chunk-P4J26VDS.js → chunk-IDX6COTE.js} +2 -2
- package/chunks/{chunk-QCG6KPNM.js → chunk-IWAYOW5Q.js} +14760 -10735
- package/chunks/{chunk-HGJPQK33.js → chunk-J5MDQKJL.js} +518 -519
- package/chunks/{chunk-USE2VQ5P.js → chunk-JTQAQBTV.js} +21 -0
- package/chunks/{chunk-HXJE7VOG.js → chunk-LBP46COL.js} +1001 -139
- package/chunks/{chunk-NW5QBUYO.js → chunk-LEJ42GNY.js} +14 -14
- package/chunks/{chunk-Y7R6H6FT.js → chunk-M6VTDSVR.js} +1 -1
- package/chunks/{chunk-CNHFPN7T.js → chunk-MFBBBTNY.js} +1 -1
- package/chunks/{chunk-ICOI4E4S.js → chunk-OHEGWO4L.js} +101 -23
- package/chunks/{chunk-7YKXFA3D.js → chunk-PL3MVCWD.js} +5 -5
- package/chunks/chunk-QQDPRDVW.js +25 -0
- package/chunks/{chunk-HV3ZZ7G4.js → chunk-R7ODSGTK.js} +2 -2
- package/chunks/{chunk-GX7VH5JQ.js → chunk-SEGYWKIH.js} +1 -1
- package/chunks/{chunk-KC6ZMJ5X.js → chunk-SNGELLWX.js} +1 -1
- package/chunks/chunk-XBY7E2FX.js +605 -0
- package/chunks/{chunk-2ZTWI7KH.js → chunk-XV4HCEVI.js} +22 -1
- package/chunks/{chunk-WFVXF3OM.js → chunk-Z2Z3GUXZ.js} +1 -0
- package/chunks/{chunk-CWV3SJZS.js → chunk-ZTZ4DDQE.js} +2 -2
- package/chunks/{computer-use-B7VIUI7F.js → computer-use-3RH2DOM6.js} +23 -23
- package/chunks/contextCommand-K347QT6O.js +52 -0
- package/chunks/{cron-create-FI5LJVUS.js → cron-create-YJL3KFWI.js} +3 -3
- package/chunks/{cron-delete-ZGUXWBTG.js → cron-delete-WKWSJZQA.js} +3 -3
- package/chunks/{cron-list-QNNZGMN3.js → cron-list-B52XEXAZ.js} +3 -3
- package/chunks/{devtools-IXE4UP72.js → devtools-FM6GJPYG.js} +1 -1
- package/chunks/{dist-R2SXPG74.js → dist-4LXD6L6X.js} +2 -2
- package/chunks/{dist-TE5QKMGR.js → dist-H6ONXVLG.js} +1 -1
- package/chunks/{dist-ZMQ4TXD5.js → dist-KAZ3SEBX.js} +2 -2
- package/chunks/{dist-BXDUQ2QY.js → dist-PK7DFCAW.js} +1 -1
- package/chunks/{edit-6UBTS2J5.js → edit-KU4PJGEX.js} +24 -24
- package/chunks/{en-HSQQNQUB.js → en-DHGYHIHX.js} +4 -0
- package/chunks/{enter-worktree-NN7LIXCM.js → enter-worktree-PPYIDCWI.js} +23 -23
- package/chunks/enterPlanMode-5CZDMCB4.js +158 -0
- package/chunks/{exit-worktree-GGSS5KIE.js → exit-worktree-UY3CGHKC.js} +23 -23
- package/chunks/exitPlanMode-3DN4QNSG.js +703 -0
- package/chunks/{geminiContentGenerator-I4H2NLJG.js → geminiContentGenerator-7A6I2RWB.js} +7 -7
- package/chunks/{getMachineId-bsd-F7GNPTER.js → getMachineId-bsd-4CASPIU4.js} +1 -1
- package/chunks/{getMachineId-darwin-T73DJL27.js → getMachineId-darwin-HPQPEMZR.js} +1 -1
- package/chunks/{getMachineId-linux-MKQTFPQM.js → getMachineId-linux-AUARKYHL.js} +1 -1
- package/chunks/{getMachineId-unsupported-MUR5KOQE.js → getMachineId-unsupported-S32ZDA2T.js} +1 -1
- package/chunks/{getMachineId-win-CDYFC6ZM.js → getMachineId-win-4EFLHYIJ.js} +1 -1
- package/chunks/{glob-OLCX57MD.js → glob-OFNQSS52.js} +23 -23
- package/chunks/{grep-7HXIMDOW.js → grep-6J2MSUM5.js} +26 -23
- package/chunks/{keychain-token-storage-LB46DAEK.js → keychain-token-storage-6IU6ORQN.js} +3 -3
- package/chunks/{ls-6PEZUK6O.js → ls-V3O6A5PT.js} +4 -4
- package/chunks/{lsp-JZSJOVT7.js → lsp-G2OCIFUA.js} +3 -3
- package/chunks/{monitor-SQO7MVAV.js → monitor-FKLHV423.js} +23 -23
- package/chunks/{notebook-edit-72L3EBAL.js → notebook-edit-KTBYFKWG.js} +24 -24
- package/chunks/{openaiContentGenerator-FTR7CDWF.js → openaiContentGenerator-L5KSWQY7.js} +15 -15
- package/chunks/{qwenContentGenerator-U5UFQ566.js → qwenContentGenerator-PYOXLMBW.js} +25 -25
- package/chunks/{qwenOAuth2-EFSECGHF.js → qwenOAuth2-2KCKWDCF.js} +6 -5
- package/chunks/{read-file-UA64EEQC.js → read-file-JQVRK4NU.js} +11 -11
- package/chunks/{ripGrep-WSYCWZVK.js → ripGrep-2L4LPNAJ.js} +23 -23
- package/chunks/{scheduler-VBASHOCA.js → scheduler-FGNXY4JQ.js} +23 -23
- package/chunks/{send-message-OYJZ5TPG.js → send-message-SZFWNOCL.js} +3 -3
- package/chunks/{serve-A7E2OJDR.js → serve-N2IBLA3G.js} +13581 -4977
- package/chunks/{shell-3NFOT6F5.js → shell-PTEG6UX4.js} +23 -23
- package/chunks/{skill-RA5YUREY.js → skill-X4NTK4NH.js} +64 -113
- package/chunks/{src-NFCMARMT.js → src-GLLQ3R5W.js} +154 -38
- package/chunks/{syntheticOutput-DETQ2YM6.js → syntheticOutput-IKAY5F6X.js} +4 -4
- package/chunks/{task-create-Y3ZKTJIG.js → task-create-MQICOJFV.js} +7 -7
- package/chunks/{task-list-ONXJ3I3A.js → task-list-RIHJCH32.js} +6 -6
- package/chunks/{task-stop-UHDC4N5B.js → task-stop-FWZRFANS.js} +3 -3
- package/chunks/{task-update-TCNOU3P5.js → task-update-2LHPXOYM.js} +20 -9
- package/chunks/{team-create-6SR4OVRG.js → team-create-2E4PF4KN.js} +26 -25
- package/chunks/{team-delete-EJ4U4DDP.js → team-delete-DAUDQS4J.js} +8 -6
- package/chunks/{todoWrite-TEYDRS5L.js → todoWrite-HTUACZES.js} +5 -5
- package/chunks/{tool-search-OD435A3X.js → tool-search-KTVULRES.js} +11 -11
- package/chunks/{web-fetch-6W67H5PO.js → web-fetch-CZ7LLKPE.js} +5 -5
- package/chunks/{workflow-62DHH4EO.js → workflow-L2ZUUDT2.js} +268 -16
- package/chunks/{write-file-475L5OPP.js → write-file-ZEB2JDYH.js} +24 -24
- package/chunks/{zh-VCLWO26Y.js → zh-7H5OQC4I.js} +5 -1
- package/chunks/{zh-TW-G3HFHVVT.js → zh-TW-P4IDHD3M.js} +5 -1
- package/cli.js +5955 -3128
- package/examples/starter/QWEN.md +30 -0
- package/examples/starter/README.md +59 -0
- package/examples/starter/agents/diary.md +86 -0
- package/examples/starter/commands/writing/polish.md +13 -0
- package/examples/starter/example.ts +64 -0
- package/examples/starter/package.json +18 -0
- package/examples/starter/qwen-extension.json +12 -0
- package/examples/starter/skills/synonyms/SKILL.md +48 -0
- package/examples/starter/tsconfig.json +13 -0
- package/fzfWorker.js +1083 -0
- package/locales/en.js +6 -0
- package/locales/zh-TW.js +5 -0
- package/locales/zh.js +5 -0
- package/package.json +3 -2
- package/chunks/chunk-AJIR24J2.js +0 -59
- package/chunks/chunk-XBFVXFB2.js +0 -216
- package/chunks/contextCommand-63RZ3O5R.js +0 -52
- package/chunks/exitPlanMode-H323NHB2.js +0 -235
|
@@ -20,19 +20,19 @@ import {
|
|
|
20
20
|
} from "./chunk-OFEVLU4C.js";
|
|
21
21
|
import {
|
|
22
22
|
isAnyAutoMemPath
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-3HTIVKZE.js";
|
|
24
24
|
import {
|
|
25
25
|
InstallationManager
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-IDX6COTE.js";
|
|
27
27
|
import {
|
|
28
28
|
STRUCTURED_OUTPUT_REDACTED_ARGS
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-BIVG75CP.js";
|
|
30
30
|
import {
|
|
31
31
|
BaseDeclarativeTool,
|
|
32
32
|
BaseToolInvocation,
|
|
33
33
|
ToolDisplayNames,
|
|
34
34
|
ToolNames
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-XV4HCEVI.js";
|
|
36
36
|
import {
|
|
37
37
|
DEFAULT_OPENAI_BASE_URL,
|
|
38
38
|
convertSchema,
|
|
@@ -40,11 +40,11 @@ import {
|
|
|
40
40
|
runtimeDiagnostics,
|
|
41
41
|
safeJsonParse,
|
|
42
42
|
tokenLimit
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-M6VTDSVR.js";
|
|
44
44
|
import {
|
|
45
45
|
FinishReason,
|
|
46
46
|
GenerateContentResponse
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-55ZMG67I.js";
|
|
48
48
|
import {
|
|
49
49
|
FatalConfigError,
|
|
50
50
|
Storage,
|
|
@@ -53,7 +53,6 @@ import {
|
|
|
53
53
|
getErrorMessage,
|
|
54
54
|
getErrorStatus,
|
|
55
55
|
getErrorType,
|
|
56
|
-
getSessionContext,
|
|
57
56
|
isNodeError,
|
|
58
57
|
isSubpaths,
|
|
59
58
|
makeRelative,
|
|
@@ -61,7 +60,7 @@ import {
|
|
|
61
60
|
setShellTracePropagation,
|
|
62
61
|
shortenPath,
|
|
63
62
|
unescapePath
|
|
64
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-HR7SV7AY.js";
|
|
65
64
|
import {
|
|
66
65
|
require_dist
|
|
67
66
|
} from "./chunk-ZERZSAZL.js";
|
|
@@ -81,8 +80,9 @@ import {
|
|
|
81
80
|
init_esm,
|
|
82
81
|
isSpanContextValid,
|
|
83
82
|
metrics,
|
|
83
|
+
propagation,
|
|
84
84
|
trace
|
|
85
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-Z2Z3GUXZ.js";
|
|
86
86
|
import {
|
|
87
87
|
__qwen_dirname,
|
|
88
88
|
init_esbuild_shims
|
|
@@ -17034,7 +17034,7 @@ var require_load_balancer_child_handler = __commonJS({
|
|
|
17034
17034
|
createSubchannel(subchannelAddress, subchannelArgs) {
|
|
17035
17035
|
return this.parent.channelControlHelper.createSubchannel(subchannelAddress, subchannelArgs);
|
|
17036
17036
|
}
|
|
17037
|
-
updateState(connectivityState, picker,
|
|
17037
|
+
updateState(connectivityState, picker, errorMessage2) {
|
|
17038
17038
|
var _a;
|
|
17039
17039
|
if (this.calledByPendingChild()) {
|
|
17040
17040
|
if (connectivityState === connectivity_state_1.ConnectivityState.CONNECTING) {
|
|
@@ -17046,7 +17046,7 @@ var require_load_balancer_child_handler = __commonJS({
|
|
|
17046
17046
|
} else if (!this.calledByCurrentChild()) {
|
|
17047
17047
|
return;
|
|
17048
17048
|
}
|
|
17049
|
-
this.parent.channelControlHelper.updateState(connectivityState, picker,
|
|
17049
|
+
this.parent.channelControlHelper.updateState(connectivityState, picker, errorMessage2);
|
|
17050
17050
|
}
|
|
17051
17051
|
requestReresolution() {
|
|
17052
17052
|
var _a;
|
|
@@ -17280,11 +17280,11 @@ var require_resolving_load_balancer = __commonJS({
|
|
|
17280
17280
|
this.updateResolution();
|
|
17281
17281
|
}
|
|
17282
17282
|
}, "requestReresolution"),
|
|
17283
|
-
updateState: /* @__PURE__ */ __name((newState, picker,
|
|
17283
|
+
updateState: /* @__PURE__ */ __name((newState, picker, errorMessage2) => {
|
|
17284
17284
|
this.latestChildState = newState;
|
|
17285
17285
|
this.latestChildPicker = picker;
|
|
17286
|
-
this.latestChildErrorMessage =
|
|
17287
|
-
this.updateState(newState, picker,
|
|
17286
|
+
this.latestChildErrorMessage = errorMessage2;
|
|
17287
|
+
this.updateState(newState, picker, errorMessage2);
|
|
17288
17288
|
}, "updateState"),
|
|
17289
17289
|
addChannelzChild: channelControlHelper.addChannelzChild.bind(channelControlHelper),
|
|
17290
17290
|
removeChannelzChild: channelControlHelper.removeChannelzChild.bind(channelControlHelper)
|
|
@@ -17350,13 +17350,13 @@ var require_resolving_load_balancer = __commonJS({
|
|
|
17350
17350
|
}
|
|
17351
17351
|
this.backoffTimeout.runOnce();
|
|
17352
17352
|
}
|
|
17353
|
-
updateState(connectivityState, picker,
|
|
17353
|
+
updateState(connectivityState, picker, errorMessage2) {
|
|
17354
17354
|
trace2((0, uri_parser_1.uriToString)(this.target) + " " + connectivity_state_1.ConnectivityState[this.currentState] + " -> " + connectivity_state_1.ConnectivityState[connectivityState]);
|
|
17355
17355
|
if (connectivityState === connectivity_state_1.ConnectivityState.IDLE) {
|
|
17356
17356
|
picker = new picker_1.QueuePicker(this, picker);
|
|
17357
17357
|
}
|
|
17358
17358
|
this.currentState = connectivityState;
|
|
17359
|
-
this.channelControlHelper.updateState(connectivityState, picker,
|
|
17359
|
+
this.channelControlHelper.updateState(connectivityState, picker, errorMessage2);
|
|
17360
17360
|
}
|
|
17361
17361
|
handleResolutionFailure(error) {
|
|
17362
17362
|
if (this.latestChildState === connectivity_state_1.ConnectivityState.IDLE) {
|
|
@@ -27641,13 +27641,13 @@ var require_subchannel = __commonJS({
|
|
|
27641
27641
|
* @param newState The state to transition to
|
|
27642
27642
|
* @returns True if the state changed, false otherwise
|
|
27643
27643
|
*/
|
|
27644
|
-
transitionToState(oldStates, newState,
|
|
27644
|
+
transitionToState(oldStates, newState, errorMessage2) {
|
|
27645
27645
|
var _a, _b;
|
|
27646
27646
|
if (oldStates.indexOf(this.connectivityState) === -1) {
|
|
27647
27647
|
return false;
|
|
27648
27648
|
}
|
|
27649
|
-
if (
|
|
27650
|
-
this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState] + ' with error "' +
|
|
27649
|
+
if (errorMessage2) {
|
|
27650
|
+
this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState] + ' with error "' + errorMessage2 + '"');
|
|
27651
27651
|
} else {
|
|
27652
27652
|
this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState]);
|
|
27653
27653
|
}
|
|
@@ -27688,7 +27688,7 @@ var require_subchannel = __commonJS({
|
|
|
27688
27688
|
throw new Error(`Invalid state: unknown ConnectivityState ${newState}`);
|
|
27689
27689
|
}
|
|
27690
27690
|
for (const listener of this.stateListeners) {
|
|
27691
|
-
listener(this, previousState, newState, this.keepaliveTime,
|
|
27691
|
+
listener(this, previousState, newState, this.keepaliveTime, errorMessage2);
|
|
27692
27692
|
}
|
|
27693
27693
|
return true;
|
|
27694
27694
|
}
|
|
@@ -29257,18 +29257,18 @@ var require_transport = __commonJS({
|
|
|
29257
29257
|
setImmediate(() => {
|
|
29258
29258
|
if (!reportedError) {
|
|
29259
29259
|
reportedError = true;
|
|
29260
|
-
reject(`${
|
|
29260
|
+
reject(`${errorMessage2.trim()} (${(/* @__PURE__ */ new Date()).toISOString()})`);
|
|
29261
29261
|
}
|
|
29262
29262
|
});
|
|
29263
29263
|
}, "closeHandler");
|
|
29264
29264
|
const errorHandler = /* @__PURE__ */ __name((error) => {
|
|
29265
29265
|
var _a;
|
|
29266
29266
|
(_a = this.session) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
29267
|
-
|
|
29268
|
-
this.trace("connection failed with error " +
|
|
29267
|
+
errorMessage2 = error.message;
|
|
29268
|
+
this.trace("connection failed with error " + errorMessage2);
|
|
29269
29269
|
if (!reportedError) {
|
|
29270
29270
|
reportedError = true;
|
|
29271
|
-
reject(`${
|
|
29271
|
+
reject(`${errorMessage2} (${(/* @__PURE__ */ new Date()).toISOString()})`);
|
|
29272
29272
|
}
|
|
29273
29273
|
}, "errorHandler");
|
|
29274
29274
|
const sessionOptions = {
|
|
@@ -29283,7 +29283,7 @@ var require_transport = __commonJS({
|
|
|
29283
29283
|
}
|
|
29284
29284
|
const session = http2.connect(`${scheme}://${targetPath}`, sessionOptions);
|
|
29285
29285
|
this.session = session;
|
|
29286
|
-
let
|
|
29286
|
+
let errorMessage2 = "Failed to connect";
|
|
29287
29287
|
let reportedError = false;
|
|
29288
29288
|
session.unref();
|
|
29289
29289
|
session.once("remoteSettings", () => {
|
|
@@ -34699,8 +34699,8 @@ var require_load_balancer_pick_first = __commonJS({
|
|
|
34699
34699
|
this.currentState = connectivity_state_1.ConnectivityState.IDLE;
|
|
34700
34700
|
this.currentSubchannelIndex = 0;
|
|
34701
34701
|
this.currentPick = null;
|
|
34702
|
-
this.subchannelStateListener = (subchannel, previousState, newState, keepaliveTime,
|
|
34703
|
-
this.onSubchannelStateUpdate(subchannel, previousState, newState,
|
|
34702
|
+
this.subchannelStateListener = (subchannel, previousState, newState, keepaliveTime, errorMessage2) => {
|
|
34703
|
+
this.onSubchannelStateUpdate(subchannel, previousState, newState, errorMessage2);
|
|
34704
34704
|
};
|
|
34705
34705
|
this.pickedSubchannelHealthListener = () => this.calculateAndReportNewState();
|
|
34706
34706
|
this.stickyTransientFailureMode = false;
|
|
@@ -34722,26 +34722,26 @@ var require_load_balancer_pick_first = __commonJS({
|
|
|
34722
34722
|
var _a;
|
|
34723
34723
|
if (this.currentPick) {
|
|
34724
34724
|
if (this.reportHealthStatus && !this.currentPick.isHealthy()) {
|
|
34725
|
-
const
|
|
34725
|
+
const errorMessage2 = `Picked subchannel ${this.currentPick.getAddress()} is unhealthy`;
|
|
34726
34726
|
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
|
|
34727
|
-
details:
|
|
34728
|
-
}),
|
|
34727
|
+
details: errorMessage2
|
|
34728
|
+
}), errorMessage2);
|
|
34729
34729
|
} else {
|
|
34730
34730
|
this.updateState(connectivity_state_1.ConnectivityState.READY, new PickFirstPicker(this.currentPick), null);
|
|
34731
34731
|
}
|
|
34732
34732
|
} else if (((_a = this.latestAddressList) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
34733
|
-
const
|
|
34733
|
+
const errorMessage2 = `No connection established. Last error: ${this.lastError}`;
|
|
34734
34734
|
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
|
|
34735
|
-
details:
|
|
34736
|
-
}),
|
|
34735
|
+
details: errorMessage2
|
|
34736
|
+
}), errorMessage2);
|
|
34737
34737
|
} else if (this.children.length === 0) {
|
|
34738
34738
|
this.updateState(connectivity_state_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this), null);
|
|
34739
34739
|
} else {
|
|
34740
34740
|
if (this.stickyTransientFailureMode) {
|
|
34741
|
-
const
|
|
34741
|
+
const errorMessage2 = `No connection established. Last error: ${this.lastError}`;
|
|
34742
34742
|
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
|
|
34743
|
-
details:
|
|
34744
|
-
}),
|
|
34743
|
+
details: errorMessage2
|
|
34744
|
+
}), errorMessage2);
|
|
34745
34745
|
} else {
|
|
34746
34746
|
this.updateState(connectivity_state_1.ConnectivityState.CONNECTING, new picker_1.QueuePicker(this), null);
|
|
34747
34747
|
}
|
|
@@ -34775,7 +34775,7 @@ var require_load_balancer_pick_first = __commonJS({
|
|
|
34775
34775
|
this.currentPick = null;
|
|
34776
34776
|
}
|
|
34777
34777
|
}
|
|
34778
|
-
onSubchannelStateUpdate(subchannel, previousState, newState,
|
|
34778
|
+
onSubchannelStateUpdate(subchannel, previousState, newState, errorMessage2) {
|
|
34779
34779
|
var _a;
|
|
34780
34780
|
if ((_a = this.currentPick) === null || _a === void 0 ? void 0 : _a.realSubchannelEquals(subchannel)) {
|
|
34781
34781
|
if (newState !== connectivity_state_1.ConnectivityState.READY) {
|
|
@@ -34791,8 +34791,8 @@ var require_load_balancer_pick_first = __commonJS({
|
|
|
34791
34791
|
}
|
|
34792
34792
|
if (newState === connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE) {
|
|
34793
34793
|
child.hasReportedTransientFailure = true;
|
|
34794
|
-
if (
|
|
34795
|
-
this.lastError =
|
|
34794
|
+
if (errorMessage2) {
|
|
34795
|
+
this.lastError = errorMessage2;
|
|
34796
34796
|
}
|
|
34797
34797
|
this.maybeEnterStickyTransientFailureMode();
|
|
34798
34798
|
if (index === this.currentSubchannelIndex) {
|
|
@@ -34857,10 +34857,10 @@ var require_load_balancer_pick_first = __commonJS({
|
|
|
34857
34857
|
clearTimeout(this.connectionDelayTimeout);
|
|
34858
34858
|
this.calculateAndReportNewState();
|
|
34859
34859
|
}
|
|
34860
|
-
updateState(newState, picker,
|
|
34860
|
+
updateState(newState, picker, errorMessage2) {
|
|
34861
34861
|
trace2(connectivity_state_1.ConnectivityState[this.currentState] + " -> " + connectivity_state_1.ConnectivityState[newState]);
|
|
34862
34862
|
this.currentState = newState;
|
|
34863
|
-
this.channelControlHelper.updateState(newState, picker,
|
|
34863
|
+
this.channelControlHelper.updateState(newState, picker, errorMessage2);
|
|
34864
34864
|
}
|
|
34865
34865
|
resetSubchannelList() {
|
|
34866
34866
|
for (const child of this.children) {
|
|
@@ -34944,10 +34944,10 @@ var require_load_balancer_pick_first = __commonJS({
|
|
|
34944
34944
|
this.options = options;
|
|
34945
34945
|
this.latestState = connectivity_state_1.ConnectivityState.IDLE;
|
|
34946
34946
|
const childChannelControlHelper = (0, load_balancer_1.createChildChannelControlHelper)(channelControlHelper, {
|
|
34947
|
-
updateState: /* @__PURE__ */ __name((connectivityState, picker,
|
|
34947
|
+
updateState: /* @__PURE__ */ __name((connectivityState, picker, errorMessage2) => {
|
|
34948
34948
|
this.latestState = connectivityState;
|
|
34949
34949
|
this.latestPicker = picker;
|
|
34950
|
-
channelControlHelper.updateState(connectivityState, picker,
|
|
34950
|
+
channelControlHelper.updateState(connectivityState, picker, errorMessage2);
|
|
34951
34951
|
}, "updateState")
|
|
34952
34952
|
});
|
|
34953
34953
|
this.pickFirstBalancer = new PickFirstLoadBalancer(childChannelControlHelper);
|
|
@@ -35459,12 +35459,12 @@ var require_load_balancer_round_robin = __commonJS({
|
|
|
35459
35459
|
this.updatesPaused = false;
|
|
35460
35460
|
this.lastError = null;
|
|
35461
35461
|
this.childChannelControlHelper = (0, load_balancer_1.createChildChannelControlHelper)(channelControlHelper, {
|
|
35462
|
-
updateState: /* @__PURE__ */ __name((connectivityState, picker,
|
|
35462
|
+
updateState: /* @__PURE__ */ __name((connectivityState, picker, errorMessage2) => {
|
|
35463
35463
|
if (this.currentState === connectivity_state_1.ConnectivityState.READY && connectivityState !== connectivity_state_1.ConnectivityState.READY) {
|
|
35464
35464
|
this.channelControlHelper.requestReresolution();
|
|
35465
35465
|
}
|
|
35466
|
-
if (
|
|
35467
|
-
this.lastError =
|
|
35466
|
+
if (errorMessage2) {
|
|
35467
|
+
this.lastError = errorMessage2;
|
|
35468
35468
|
}
|
|
35469
35469
|
this.calculateAndUpdateState();
|
|
35470
35470
|
}, "updateState")
|
|
@@ -35494,10 +35494,10 @@ var require_load_balancer_round_robin = __commonJS({
|
|
|
35494
35494
|
} else if (this.countChildrenWithState(connectivity_state_1.ConnectivityState.CONNECTING) > 0) {
|
|
35495
35495
|
this.updateState(connectivity_state_1.ConnectivityState.CONNECTING, new picker_1.QueuePicker(this), null);
|
|
35496
35496
|
} else if (this.countChildrenWithState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE) > 0) {
|
|
35497
|
-
const
|
|
35497
|
+
const errorMessage2 = `round_robin: No connection established. Last error: ${this.lastError}`;
|
|
35498
35498
|
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
|
|
35499
|
-
details:
|
|
35500
|
-
}),
|
|
35499
|
+
details: errorMessage2
|
|
35500
|
+
}), errorMessage2);
|
|
35501
35501
|
} else {
|
|
35502
35502
|
this.updateState(connectivity_state_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this), null);
|
|
35503
35503
|
}
|
|
@@ -35507,7 +35507,7 @@ var require_load_balancer_round_robin = __commonJS({
|
|
|
35507
35507
|
}
|
|
35508
35508
|
}
|
|
35509
35509
|
}
|
|
35510
|
-
updateState(newState, picker,
|
|
35510
|
+
updateState(newState, picker, errorMessage2) {
|
|
35511
35511
|
trace2(connectivity_state_1.ConnectivityState[this.currentState] + " -> " + connectivity_state_1.ConnectivityState[newState]);
|
|
35512
35512
|
if (newState === connectivity_state_1.ConnectivityState.READY) {
|
|
35513
35513
|
this.currentReadyPicker = picker;
|
|
@@ -35515,7 +35515,7 @@ var require_load_balancer_round_robin = __commonJS({
|
|
|
35515
35515
|
this.currentReadyPicker = null;
|
|
35516
35516
|
}
|
|
35517
35517
|
this.currentState = newState;
|
|
35518
|
-
this.channelControlHelper.updateState(newState, picker,
|
|
35518
|
+
this.channelControlHelper.updateState(newState, picker, errorMessage2);
|
|
35519
35519
|
}
|
|
35520
35520
|
resetSubchannelList() {
|
|
35521
35521
|
for (const child of this.children) {
|
|
@@ -35830,11 +35830,11 @@ var require_load_balancer_outlier_detection = __commonJS({
|
|
|
35830
35830
|
mapEntry === null || mapEntry === void 0 ? void 0 : mapEntry.subchannelWrappers.push(subchannelWrapper);
|
|
35831
35831
|
return subchannelWrapper;
|
|
35832
35832
|
}, "createSubchannel"),
|
|
35833
|
-
updateState: /* @__PURE__ */ __name((connectivityState, picker,
|
|
35833
|
+
updateState: /* @__PURE__ */ __name((connectivityState, picker, errorMessage2) => {
|
|
35834
35834
|
if (connectivityState === connectivity_state_1.ConnectivityState.READY) {
|
|
35835
|
-
channelControlHelper.updateState(connectivityState, new OutlierDetectionPicker(picker, this.isCountingEnabled()),
|
|
35835
|
+
channelControlHelper.updateState(connectivityState, new OutlierDetectionPicker(picker, this.isCountingEnabled()), errorMessage2);
|
|
35836
35836
|
} else {
|
|
35837
|
-
channelControlHelper.updateState(connectivityState, picker,
|
|
35837
|
+
channelControlHelper.updateState(connectivityState, picker, errorMessage2);
|
|
35838
35838
|
}
|
|
35839
35839
|
}, "updateState")
|
|
35840
35840
|
}));
|
|
@@ -40578,8 +40578,8 @@ var require_root2 = __commonJS({
|
|
|
40578
40578
|
return metrics2;
|
|
40579
40579
|
}();
|
|
40580
40580
|
collector.logs = function() {
|
|
40581
|
-
var
|
|
40582
|
-
|
|
40581
|
+
var logs3 = {};
|
|
40582
|
+
logs3.v1 = function() {
|
|
40583
40583
|
var v1 = {};
|
|
40584
40584
|
v1.LogsService = function() {
|
|
40585
40585
|
function LogsService(rpcImpl, requestDelimited, responseDelimited) {
|
|
@@ -40923,7 +40923,7 @@ var require_root2 = __commonJS({
|
|
|
40923
40923
|
}();
|
|
40924
40924
|
return v1;
|
|
40925
40925
|
}();
|
|
40926
|
-
return
|
|
40926
|
+
return logs3;
|
|
40927
40927
|
}();
|
|
40928
40928
|
return collector;
|
|
40929
40929
|
}();
|
|
@@ -44405,8 +44405,8 @@ var require_root2 = __commonJS({
|
|
|
44405
44405
|
return metrics2;
|
|
44406
44406
|
}();
|
|
44407
44407
|
proto.logs = function() {
|
|
44408
|
-
var
|
|
44409
|
-
|
|
44408
|
+
var logs3 = {};
|
|
44409
|
+
logs3.v1 = function() {
|
|
44410
44410
|
var v1 = {};
|
|
44411
44411
|
v1.LogsData = function() {
|
|
44412
44412
|
function LogsData(properties) {
|
|
@@ -45348,7 +45348,7 @@ var require_root2 = __commonJS({
|
|
|
45348
45348
|
}();
|
|
45349
45349
|
return v1;
|
|
45350
45350
|
}();
|
|
45351
|
-
return
|
|
45351
|
+
return logs3;
|
|
45352
45352
|
}();
|
|
45353
45353
|
return proto;
|
|
45354
45354
|
}();
|
|
@@ -48134,19 +48134,19 @@ var require_getMachineId = __commonJS({
|
|
|
48134
48134
|
if (!getMachineIdImpl) {
|
|
48135
48135
|
switch (process3.platform) {
|
|
48136
48136
|
case "darwin":
|
|
48137
|
-
getMachineIdImpl = (await import("./getMachineId-darwin-
|
|
48137
|
+
getMachineIdImpl = (await import("./getMachineId-darwin-HPQPEMZR.js")).getMachineId;
|
|
48138
48138
|
break;
|
|
48139
48139
|
case "linux":
|
|
48140
|
-
getMachineIdImpl = (await import("./getMachineId-linux-
|
|
48140
|
+
getMachineIdImpl = (await import("./getMachineId-linux-AUARKYHL.js")).getMachineId;
|
|
48141
48141
|
break;
|
|
48142
48142
|
case "freebsd":
|
|
48143
|
-
getMachineIdImpl = (await import("./getMachineId-bsd-
|
|
48143
|
+
getMachineIdImpl = (await import("./getMachineId-bsd-4CASPIU4.js")).getMachineId;
|
|
48144
48144
|
break;
|
|
48145
48145
|
case "win32":
|
|
48146
|
-
getMachineIdImpl = (await import("./getMachineId-win-
|
|
48146
|
+
getMachineIdImpl = (await import("./getMachineId-win-4EFLHYIJ.js")).getMachineId;
|
|
48147
48147
|
break;
|
|
48148
48148
|
default:
|
|
48149
|
-
getMachineIdImpl = (await import("./getMachineId-unsupported-
|
|
48149
|
+
getMachineIdImpl = (await import("./getMachineId-unsupported-S32ZDA2T.js")).getMachineId;
|
|
48150
48150
|
break;
|
|
48151
48151
|
}
|
|
48152
48152
|
}
|
|
@@ -51706,8 +51706,8 @@ var require_ConsoleLogRecordExporter = __commonJS({
|
|
|
51706
51706
|
* @param logs
|
|
51707
51707
|
* @param resultCallback
|
|
51708
51708
|
*/
|
|
51709
|
-
export(
|
|
51710
|
-
this._sendLogRecords(
|
|
51709
|
+
export(logs3, resultCallback) {
|
|
51710
|
+
this._sendLogRecords(logs3, resultCallback);
|
|
51711
51711
|
}
|
|
51712
51712
|
/**
|
|
51713
51713
|
* Shutdown the exporter.
|
|
@@ -51824,14 +51824,14 @@ var require_InMemoryLogRecordExporter = __commonJS({
|
|
|
51824
51824
|
* When false, exported log records will not be stored in-memory.
|
|
51825
51825
|
*/
|
|
51826
51826
|
_stopped = false;
|
|
51827
|
-
export(
|
|
51827
|
+
export(logs3, resultCallback) {
|
|
51828
51828
|
if (this._stopped) {
|
|
51829
51829
|
return resultCallback({
|
|
51830
51830
|
code: core_1.ExportResultCode.FAILED,
|
|
51831
51831
|
error: new Error("Exporter has been stopped")
|
|
51832
51832
|
});
|
|
51833
51833
|
}
|
|
51834
|
-
this._finishedLogRecords.push(...
|
|
51834
|
+
this._finishedLogRecords.push(...logs3);
|
|
51835
51835
|
resultCallback({ code: core_1.ExportResultCode.SUCCESS });
|
|
51836
51836
|
}
|
|
51837
51837
|
shutdown() {
|
|
@@ -61212,7 +61212,12 @@ function setGeminiMdFilename(newFilename) {
|
|
|
61212
61212
|
__name(setGeminiMdFilename, "setGeminiMdFilename");
|
|
61213
61213
|
function getCurrentGeminiMdFilename() {
|
|
61214
61214
|
if (Array.isArray(currentGeminiMdFilename)) {
|
|
61215
|
-
|
|
61215
|
+
for (const entry of currentGeminiMdFilename) {
|
|
61216
|
+
if (typeof entry === "string" && entry.trim() !== "") {
|
|
61217
|
+
return entry.trim();
|
|
61218
|
+
}
|
|
61219
|
+
}
|
|
61220
|
+
return DEFAULT_CONTEXT_FILENAME;
|
|
61216
61221
|
}
|
|
61217
61222
|
return currentGeminiMdFilename;
|
|
61218
61223
|
}
|
|
@@ -62678,12 +62683,12 @@ async function processSingleFileContent(filePath, config, offset, limit, pages)
|
|
|
62678
62683
|
}
|
|
62679
62684
|
}
|
|
62680
62685
|
} catch (error) {
|
|
62681
|
-
const
|
|
62686
|
+
const errorMessage2 = error instanceof Error ? error.message : String(error);
|
|
62682
62687
|
const displayPath = path2.relative(rootDirectory, filePath).replace(/\\/g, "/");
|
|
62683
62688
|
return {
|
|
62684
|
-
llmContent: `Error reading file ${displayPath}: ${
|
|
62685
|
-
returnDisplay: `Error reading file ${displayPath}: ${
|
|
62686
|
-
error: `Error reading file ${filePath}: ${
|
|
62689
|
+
llmContent: `Error reading file ${displayPath}: ${errorMessage2}`,
|
|
62690
|
+
returnDisplay: `Error reading file ${displayPath}: ${errorMessage2}`,
|
|
62691
|
+
error: `Error reading file ${filePath}: ${errorMessage2}`,
|
|
62687
62692
|
errorType: "read_content_failure" /* READ_CONTENT_FAILURE */
|
|
62688
62693
|
};
|
|
62689
62694
|
}
|
|
@@ -63588,7 +63593,7 @@ __name(getProgrammingLanguage, "getProgrammingLanguage");
|
|
|
63588
63593
|
|
|
63589
63594
|
// packages/core/src/telemetry/loggers.ts
|
|
63590
63595
|
init_esbuild_shims();
|
|
63591
|
-
var
|
|
63596
|
+
var import_api_logs2 = __toESM(require_src2(), 1);
|
|
63592
63597
|
init_esm2();
|
|
63593
63598
|
|
|
63594
63599
|
// packages/core/src/utils/internalPromptIds.ts
|
|
@@ -63705,17 +63710,31 @@ init_esbuild_shims();
|
|
|
63705
63710
|
import * as fs3 from "node:fs/promises";
|
|
63706
63711
|
import * as path4 from "node:path";
|
|
63707
63712
|
import * as crypto2 from "node:crypto";
|
|
63708
|
-
|
|
63713
|
+
var TOOL_OUTPUT_TRUNCATED_PREFIX = "Tool output was too large and has been truncated";
|
|
63714
|
+
async function truncateAndSaveToFile(content, fileName, projectTempDir, threshold, truncateLines, keep = "both") {
|
|
63715
|
+
if (content.length <= threshold && !Number.isFinite(truncateLines)) {
|
|
63716
|
+
return { content };
|
|
63717
|
+
}
|
|
63709
63718
|
const lines = content.split("\n");
|
|
63710
63719
|
if (content.length <= threshold && lines.length <= truncateLines) {
|
|
63711
63720
|
return { content };
|
|
63712
63721
|
}
|
|
63713
63722
|
const effectiveLines = Math.min(truncateLines, lines.length);
|
|
63714
|
-
|
|
63715
|
-
|
|
63723
|
+
let headCount;
|
|
63724
|
+
let tailCount;
|
|
63725
|
+
if (keep === "head") {
|
|
63726
|
+
headCount = effectiveLines;
|
|
63727
|
+
tailCount = 0;
|
|
63728
|
+
} else if (keep === "tail") {
|
|
63729
|
+
headCount = 0;
|
|
63730
|
+
tailCount = effectiveLines;
|
|
63731
|
+
} else {
|
|
63732
|
+
headCount = Math.max(Math.floor(effectiveLines / 5), 1);
|
|
63733
|
+
tailCount = effectiveLines - headCount;
|
|
63734
|
+
}
|
|
63716
63735
|
const separator = "\n\n---\n... [CONTENT TRUNCATED] ...\n---\n\n";
|
|
63717
63736
|
const ellipsis = "...";
|
|
63718
|
-
const headBudget = Math.floor(threshold / 5);
|
|
63737
|
+
const headBudget = keep === "head" ? threshold : keep === "tail" ? 0 : Math.floor(threshold / 5);
|
|
63719
63738
|
const beginning = [];
|
|
63720
63739
|
let headChars = 0;
|
|
63721
63740
|
for (let i = 0; i < Math.min(headCount, lines.length); i++) {
|
|
@@ -63730,7 +63749,7 @@ async function truncateAndSaveToFile(content, fileName, projectTempDir, threshol
|
|
|
63730
63749
|
beginning.push(lines[i]);
|
|
63731
63750
|
headChars += lines[i].length + 1;
|
|
63732
63751
|
}
|
|
63733
|
-
const tailBudget = Math.max(threshold - headChars - separator.length, 0);
|
|
63752
|
+
const tailBudget = keep === "head" ? 0 : Math.max(threshold - headChars - separator.length, 0);
|
|
63734
63753
|
const end = [];
|
|
63735
63754
|
let tailChars = 0;
|
|
63736
63755
|
const tailStart = Math.max(lines.length - tailCount, beginning.length);
|
|
@@ -63739,27 +63758,31 @@ async function truncateAndSaveToFile(content, fileName, projectTempDir, threshol
|
|
|
63739
63758
|
if (remaining <= 0) break;
|
|
63740
63759
|
if (lines[i].length + 1 > remaining) {
|
|
63741
63760
|
const sliceLen = Math.max(remaining - ellipsis.length, 0);
|
|
63742
|
-
end.unshift(ellipsis + lines[i].slice(-sliceLen));
|
|
63761
|
+
end.unshift(ellipsis + (sliceLen > 0 ? lines[i].slice(-sliceLen) : ""));
|
|
63743
63762
|
tailChars = tailBudget;
|
|
63744
63763
|
break;
|
|
63745
63764
|
}
|
|
63746
63765
|
end.unshift(lines[i]);
|
|
63747
63766
|
tailChars += lines[i].length + 1;
|
|
63748
63767
|
}
|
|
63749
|
-
const truncatedContent = beginning.join("\n") + separator + end.join("\n");
|
|
63768
|
+
const truncatedContent = keep === "head" ? beginning.join("\n") + separator : keep === "tail" ? separator + end.join("\n") : beginning.join("\n") + separator + end.join("\n");
|
|
63750
63769
|
const safeFileName = `${path4.basename(fileName)}.output`;
|
|
63751
63770
|
const outputFile = path4.join(projectTempDir, safeFileName);
|
|
63752
|
-
|
|
63753
|
-
await fs3.mkdir(projectTempDir, { recursive: true });
|
|
63754
|
-
await fs3.writeFile(outputFile, content);
|
|
63755
|
-
return {
|
|
63756
|
-
content: `Tool output was too large and has been truncated.
|
|
63771
|
+
const wrappedMessage = `${TOOL_OUTPUT_TRUNCATED_PREFIX}.
|
|
63757
63772
|
The full output has been saved to: ${outputFile}
|
|
63758
63773
|
To read the complete output, use the ${ReadFileTool.Name} tool with the absolute file path above.
|
|
63759
63774
|
The truncated output below shows the beginning and end of the content. The marker '... [CONTENT TRUNCATED] ...' indicates where content was removed.
|
|
63760
63775
|
|
|
63761
63776
|
Truncated part of the output:
|
|
63762
|
-
${truncatedContent}
|
|
63777
|
+
${truncatedContent}`;
|
|
63778
|
+
if (wrappedMessage.length >= content.length) {
|
|
63779
|
+
return { content };
|
|
63780
|
+
}
|
|
63781
|
+
try {
|
|
63782
|
+
await fs3.mkdir(projectTempDir, { recursive: true });
|
|
63783
|
+
await fs3.writeFile(outputFile, content, { mode: 384 });
|
|
63784
|
+
return {
|
|
63785
|
+
content: wrappedMessage,
|
|
63763
63786
|
outputFile
|
|
63764
63787
|
};
|
|
63765
63788
|
} catch (_error) {
|
|
@@ -63770,12 +63793,16 @@ ${truncatedContent}`,
|
|
|
63770
63793
|
}
|
|
63771
63794
|
}
|
|
63772
63795
|
__name(truncateAndSaveToFile, "truncateAndSaveToFile");
|
|
63773
|
-
async function truncateToolOutput(config, toolName, content) {
|
|
63774
|
-
const threshold = config.getTruncateToolOutputThreshold();
|
|
63775
|
-
const lines = config.getTruncateToolOutputLines();
|
|
63796
|
+
async function truncateToolOutput(config, toolName, content, limits, promptId) {
|
|
63797
|
+
const threshold = limits?.threshold ?? config.getTruncateToolOutputThreshold();
|
|
63798
|
+
const lines = limits?.lines ?? config.getTruncateToolOutputLines();
|
|
63799
|
+
const keep = limits?.keep ?? "both";
|
|
63776
63800
|
if (threshold <= 0 || lines <= 0) {
|
|
63777
63801
|
return { content };
|
|
63778
63802
|
}
|
|
63803
|
+
if (content.length <= threshold && !Number.isFinite(lines)) {
|
|
63804
|
+
return { content };
|
|
63805
|
+
}
|
|
63779
63806
|
const originalLength = content.length;
|
|
63780
63807
|
const fileName = `${toolName}_${crypto2.randomBytes(6).toString("hex")}`;
|
|
63781
63808
|
const result = await truncateAndSaveToFile(
|
|
@@ -63783,23 +63810,65 @@ async function truncateToolOutput(config, toolName, content) {
|
|
|
63783
63810
|
fileName,
|
|
63784
63811
|
config.storage.getProjectTempDir(),
|
|
63785
63812
|
threshold,
|
|
63786
|
-
lines
|
|
63813
|
+
lines,
|
|
63814
|
+
keep
|
|
63787
63815
|
);
|
|
63788
63816
|
if (result.outputFile) {
|
|
63789
|
-
|
|
63790
|
-
|
|
63791
|
-
|
|
63792
|
-
|
|
63793
|
-
|
|
63794
|
-
|
|
63795
|
-
|
|
63796
|
-
|
|
63797
|
-
|
|
63798
|
-
|
|
63817
|
+
try {
|
|
63818
|
+
logToolOutputTruncated(
|
|
63819
|
+
config,
|
|
63820
|
+
new ToolOutputTruncatedEvent(promptId ?? "", {
|
|
63821
|
+
toolName,
|
|
63822
|
+
originalContentLength: originalLength,
|
|
63823
|
+
truncatedContentLength: result.content.length,
|
|
63824
|
+
threshold,
|
|
63825
|
+
lines
|
|
63826
|
+
})
|
|
63827
|
+
);
|
|
63828
|
+
} catch {
|
|
63829
|
+
}
|
|
63799
63830
|
}
|
|
63800
63831
|
return result;
|
|
63801
63832
|
}
|
|
63802
63833
|
__name(truncateToolOutput, "truncateToolOutput");
|
|
63834
|
+
async function truncateLlmContent(config, toolName, content, limits, promptId) {
|
|
63835
|
+
if (typeof content === "string") {
|
|
63836
|
+
if (content.trim() === "") {
|
|
63837
|
+
return { content: `(${toolName} completed with no output)` };
|
|
63838
|
+
}
|
|
63839
|
+
if (content.startsWith(TOOL_OUTPUT_TRUNCATED_PREFIX)) {
|
|
63840
|
+
return { content };
|
|
63841
|
+
}
|
|
63842
|
+
return truncateToolOutput(config, toolName, content, limits, promptId);
|
|
63843
|
+
}
|
|
63844
|
+
const parts = (Array.isArray(content) ? content : [content]).map(
|
|
63845
|
+
(p) => typeof p === "string" ? { text: p } : p
|
|
63846
|
+
);
|
|
63847
|
+
const textParts = parts.filter((p) => p.text !== void 0);
|
|
63848
|
+
const mediaParts = parts.filter((p) => p.text === void 0);
|
|
63849
|
+
const combined = textParts.map((p) => p.text).join("\n");
|
|
63850
|
+
if (combined.trim() === "" && mediaParts.length === 0) {
|
|
63851
|
+
return { content: `(${toolName} completed with no output)` };
|
|
63852
|
+
}
|
|
63853
|
+
if (textParts.some((p) => p.text?.startsWith(TOOL_OUTPUT_TRUNCATED_PREFIX))) {
|
|
63854
|
+
return { content };
|
|
63855
|
+
}
|
|
63856
|
+
const result = await truncateToolOutput(
|
|
63857
|
+
config,
|
|
63858
|
+
toolName,
|
|
63859
|
+
combined,
|
|
63860
|
+
limits,
|
|
63861
|
+
promptId
|
|
63862
|
+
);
|
|
63863
|
+
if (result.content === combined) {
|
|
63864
|
+
return { content };
|
|
63865
|
+
}
|
|
63866
|
+
return {
|
|
63867
|
+
content: [{ text: result.content }, ...mediaParts],
|
|
63868
|
+
outputFile: result.outputFile
|
|
63869
|
+
};
|
|
63870
|
+
}
|
|
63871
|
+
__name(truncateLlmContent, "truncateLlmContent");
|
|
63803
63872
|
|
|
63804
63873
|
// packages/core/src/tools/mcp-tool.ts
|
|
63805
63874
|
var debugLogger3 = createDebugLogger("MCP_TOOL");
|
|
@@ -63853,8 +63922,7 @@ var DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends Bas
|
|
|
63853
63922
|
};
|
|
63854
63923
|
return confirmationDetails;
|
|
63855
63924
|
}
|
|
63856
|
-
//
|
|
63857
|
-
// This is needed because CallToolResults should return errors inside the response.
|
|
63925
|
+
// MCP spec: errors are returned inside the CallToolResult, not as exceptions.
|
|
63858
63926
|
// ref: https://modelcontextprotocol.io/specification/2025-06-18/schema#calltoolresult
|
|
63859
63927
|
isMCPToolError(rawResponseParts) {
|
|
63860
63928
|
const functionResponse = rawResponseParts?.[0]?.functionResponse;
|
|
@@ -63966,15 +64034,15 @@ var DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends Bas
|
|
|
63966
64034
|
callToolResult
|
|
63967
64035
|
);
|
|
63968
64036
|
if (this.isMCPToolError(rawResponseParts)) {
|
|
63969
|
-
const
|
|
64037
|
+
const errorMessage2 = `MCP tool '${this.serverToolName}' reported tool error for function call: ${safeJsonStringify({
|
|
63970
64038
|
name: this.serverToolName,
|
|
63971
64039
|
args: this.params
|
|
63972
64040
|
})} with response: ${safeJsonStringify(rawResponseParts)}`;
|
|
63973
64041
|
return {
|
|
63974
|
-
llmContent:
|
|
64042
|
+
llmContent: errorMessage2,
|
|
63975
64043
|
returnDisplay: `Error: MCP tool '${this.serverToolName}' reported an error.`,
|
|
63976
64044
|
error: {
|
|
63977
|
-
message:
|
|
64045
|
+
message: errorMessage2,
|
|
63978
64046
|
type: "mcp_tool_error" /* MCP_TOOL_ERROR */
|
|
63979
64047
|
}
|
|
63980
64048
|
};
|
|
@@ -64027,14 +64095,14 @@ var DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends Bas
|
|
|
64027
64095
|
});
|
|
64028
64096
|
});
|
|
64029
64097
|
if (this.isMCPToolError(rawResponseParts)) {
|
|
64030
|
-
const
|
|
64098
|
+
const errorMessage2 = `MCP tool '${this.serverToolName}' reported tool error for function call: ${safeJsonStringify(
|
|
64031
64099
|
functionCalls[0]
|
|
64032
64100
|
)} with response: ${safeJsonStringify(rawResponseParts)}`;
|
|
64033
64101
|
return {
|
|
64034
|
-
llmContent:
|
|
64102
|
+
llmContent: errorMessage2,
|
|
64035
64103
|
returnDisplay: `Error: MCP tool '${this.serverToolName}' reported an error.`,
|
|
64036
64104
|
error: {
|
|
64037
|
-
message:
|
|
64105
|
+
message: errorMessage2,
|
|
64038
64106
|
type: "mcp_tool_error" /* MCP_TOOL_ERROR */
|
|
64039
64107
|
}
|
|
64040
64108
|
};
|
|
@@ -64063,7 +64131,14 @@ var DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends Bas
|
|
|
64063
64131
|
const truncated = await truncateToolOutput(
|
|
64064
64132
|
this.cliConfig,
|
|
64065
64133
|
`mcp__${this.serverName}__${this.serverToolName}`,
|
|
64066
|
-
part.text
|
|
64134
|
+
part.text,
|
|
64135
|
+
// Per-tool char budget; mirrors DiscoveredMCPTool.maxOutputChars
|
|
64136
|
+
// (10x the global default, since MCP servers return large structured
|
|
64137
|
+
// output). char-only (lines: Infinity) so the global line cap can't
|
|
64138
|
+
// undercut the 500k char budget — many short lines (structured JSON,
|
|
64139
|
+
// tables) would otherwise truncate while chars remain. Consistent
|
|
64140
|
+
// with the shell tool's in-tool truncation.
|
|
64141
|
+
{ threshold: 5e5, lines: Number.POSITIVE_INFINITY }
|
|
64067
64142
|
);
|
|
64068
64143
|
result.push({ text: truncated.content });
|
|
64069
64144
|
} else {
|
|
@@ -64110,6 +64185,12 @@ var DiscoveredMCPTool = class _DiscoveredMCPTool extends BaseDeclarativeTool {
|
|
|
64110
64185
|
static {
|
|
64111
64186
|
__name(this, "DiscoveredMCPTool");
|
|
64112
64187
|
}
|
|
64188
|
+
// MCP servers often return large structured payloads; allow 10x the global
|
|
64189
|
+
// budget (mirrors Claude Code's MCP `maxResultSizeChars`) before the
|
|
64190
|
+
// scheduler offloads. truncateTextParts uses the same ceiling per text part.
|
|
64191
|
+
get maxOutputChars() {
|
|
64192
|
+
return 5e5;
|
|
64193
|
+
}
|
|
64113
64194
|
asFullyQualifiedTool() {
|
|
64114
64195
|
return new _DiscoveredMCPTool(
|
|
64115
64196
|
this.mcpTool,
|
|
@@ -64125,6 +64206,40 @@ var DiscoveredMCPTool = class _DiscoveredMCPTool extends BaseDeclarativeTool {
|
|
|
64125
64206
|
this.annotations
|
|
64126
64207
|
);
|
|
64127
64208
|
}
|
|
64209
|
+
/**
|
|
64210
|
+
* Return a clone of this tool with a different `trust` value while
|
|
64211
|
+
* keeping every other field (including the shared underlying
|
|
64212
|
+
* `CallableTool` / MCP transport) identical.
|
|
64213
|
+
*
|
|
64214
|
+
* pool path: a single shared pool entry produces one
|
|
64215
|
+
* `DiscoveredMCPTool` snapshot; each `SessionMcpView` clones with
|
|
64216
|
+
* its own per-session trust before registering into its session's
|
|
64217
|
+
* `ToolRegistry`. Without this clone, mutating `trust` on the shared
|
|
64218
|
+
* instance would cross-contaminate sessions.
|
|
64219
|
+
*
|
|
64220
|
+
* Trust is the only field that legitimately varies per session;
|
|
64221
|
+
* everything else (transport, schema, name) is transport-level.
|
|
64222
|
+
*/
|
|
64223
|
+
withTrust(trust) {
|
|
64224
|
+
if (trust === this.trust) return this;
|
|
64225
|
+
return new _DiscoveredMCPTool(
|
|
64226
|
+
this.mcpTool,
|
|
64227
|
+
this.serverName,
|
|
64228
|
+
this.serverToolName,
|
|
64229
|
+
this.description,
|
|
64230
|
+
this.parameterSchema,
|
|
64231
|
+
trust,
|
|
64232
|
+
// Preserve the original name (do NOT re-call generateValidName)
|
|
64233
|
+
// — equal-by-name is the registry's deduplication key, and a
|
|
64234
|
+
// different name would race-register two tools in the same
|
|
64235
|
+
// session.
|
|
64236
|
+
this.name,
|
|
64237
|
+
this.cliConfig,
|
|
64238
|
+
this.mcpClient,
|
|
64239
|
+
this.mcpTimeout,
|
|
64240
|
+
this.annotations
|
|
64241
|
+
);
|
|
64242
|
+
}
|
|
64128
64243
|
createInvocation(params) {
|
|
64129
64244
|
return new DiscoveredMCPToolInvocation(
|
|
64130
64245
|
this.mcpTool,
|
|
@@ -66718,8 +66833,8 @@ var FileLogExporter = class extends FileExporter {
|
|
|
66718
66833
|
static {
|
|
66719
66834
|
__name(this, "FileLogExporter");
|
|
66720
66835
|
}
|
|
66721
|
-
export(
|
|
66722
|
-
const data =
|
|
66836
|
+
export(logs3, resultCallback) {
|
|
66837
|
+
const data = logs3.map((log) => this.serialize(log)).join("");
|
|
66723
66838
|
this.writeStream.write(data, (err) => {
|
|
66724
66839
|
resultCallback({
|
|
66725
66840
|
code: err ? import_core3.ExportResultCode.FAILED : import_core3.ExportResultCode.SUCCESS,
|
|
@@ -66926,11 +67041,7 @@ function resolveParentContext(parent) {
|
|
|
66926
67041
|
if (parent) {
|
|
66927
67042
|
return trace.setSpan(context.active(), parent.span);
|
|
66928
67043
|
}
|
|
66929
|
-
|
|
66930
|
-
if (trace.getSpan(active)) {
|
|
66931
|
-
return active;
|
|
66932
|
-
}
|
|
66933
|
-
return getSessionContext() ?? active;
|
|
67044
|
+
return context.active();
|
|
66934
67045
|
}
|
|
66935
67046
|
__name(resolveParentContext, "resolveParentContext");
|
|
66936
67047
|
var NOOP_SPAN = trace.wrapSpanContext({
|
|
@@ -66946,6 +67057,11 @@ function isInNativeSubagentSpan() {
|
|
|
66946
67057
|
return ctx !== void 0 && !ctx.ended;
|
|
66947
67058
|
}
|
|
66948
67059
|
__name(isInNativeSubagentSpan, "isInNativeSubagentSpan");
|
|
67060
|
+
function resolveSessionId(parentCtx) {
|
|
67061
|
+
const fromParent = parentCtx?.attributes?.["session.id"];
|
|
67062
|
+
return typeof fromParent === "string" && fromParent ? fromParent : getCurrentSessionId();
|
|
67063
|
+
}
|
|
67064
|
+
__name(resolveSessionId, "resolveSessionId");
|
|
66949
67065
|
var activeSpans = /* @__PURE__ */ new Map();
|
|
66950
67066
|
var strongSpans = /* @__PURE__ */ new Map();
|
|
66951
67067
|
var interactionSequence = 0;
|
|
@@ -67060,11 +67176,10 @@ function startInteractionSpan(config, options) {
|
|
|
67060
67176
|
"qwen-code.approval_mode": config.getApprovalMode(),
|
|
67061
67177
|
"interaction.sequence": interactionSequence
|
|
67062
67178
|
};
|
|
67063
|
-
const sessionCtx = getSessionContext() ?? context.active();
|
|
67064
67179
|
const span = getTracer().startSpan(
|
|
67065
67180
|
SPAN_INTERACTION,
|
|
67066
67181
|
{ kind: SpanKind.INTERNAL, attributes },
|
|
67067
|
-
|
|
67182
|
+
ROOT_CONTEXT
|
|
67068
67183
|
);
|
|
67069
67184
|
const spanId = getSpanId(span);
|
|
67070
67185
|
const spanContextObj = {
|
|
@@ -67110,13 +67225,90 @@ function endInteractionSpan(status, metadata) {
|
|
|
67110
67225
|
interactionContext.enterWith(void 0);
|
|
67111
67226
|
}
|
|
67112
67227
|
__name(endInteractionSpan, "endInteractionSpan");
|
|
67228
|
+
async function withInteractionSpan(config, options, fn, getResultStatus) {
|
|
67229
|
+
if (!isTelemetrySdkInitialized()) return await fn();
|
|
67230
|
+
ensureCleanupInterval();
|
|
67231
|
+
interactionSequence++;
|
|
67232
|
+
const attributes = {
|
|
67233
|
+
"session.id": config.getSessionId(),
|
|
67234
|
+
"qwen-code.prompt_id": options.promptId,
|
|
67235
|
+
"qwen-code.message_type": options.messageType,
|
|
67236
|
+
"qwen-code.model": options.model,
|
|
67237
|
+
"qwen-code.approval_mode": config.getApprovalMode(),
|
|
67238
|
+
"interaction.sequence": interactionSequence
|
|
67239
|
+
};
|
|
67240
|
+
const parentContext = options.parentContext ?? ROOT_CONTEXT;
|
|
67241
|
+
const span = getTracer().startSpan(
|
|
67242
|
+
SPAN_INTERACTION,
|
|
67243
|
+
{
|
|
67244
|
+
kind: SpanKind.INTERNAL,
|
|
67245
|
+
attributes
|
|
67246
|
+
},
|
|
67247
|
+
parentContext
|
|
67248
|
+
);
|
|
67249
|
+
const spanId = getSpanId(span);
|
|
67250
|
+
const spanContextObj = {
|
|
67251
|
+
span,
|
|
67252
|
+
startTime: Date.now(),
|
|
67253
|
+
attributes,
|
|
67254
|
+
type: "interaction"
|
|
67255
|
+
};
|
|
67256
|
+
activeSpans.set(spanId, new WeakRef(spanContextObj));
|
|
67257
|
+
strongSpans.set(spanId, spanContextObj);
|
|
67258
|
+
const activeContext = trace.setSpan(parentContext, span);
|
|
67259
|
+
return await context.with(
|
|
67260
|
+
activeContext,
|
|
67261
|
+
async () => interactionContext.run(spanContextObj, async () => {
|
|
67262
|
+
let terminalStatus = "ok";
|
|
67263
|
+
let errorStatusSet = false;
|
|
67264
|
+
try {
|
|
67265
|
+
const result = await fn();
|
|
67266
|
+
terminalStatus = getResultStatus?.(result) ?? "ok";
|
|
67267
|
+
return result;
|
|
67268
|
+
} catch (error) {
|
|
67269
|
+
terminalStatus = "error";
|
|
67270
|
+
span.setStatus({
|
|
67271
|
+
code: SpanStatusCode.ERROR,
|
|
67272
|
+
message: truncateSpanError(
|
|
67273
|
+
error instanceof Error ? error.message : String(error)
|
|
67274
|
+
)
|
|
67275
|
+
});
|
|
67276
|
+
errorStatusSet = true;
|
|
67277
|
+
throw error;
|
|
67278
|
+
} finally {
|
|
67279
|
+
if (!spanContextObj.ended) {
|
|
67280
|
+
spanContextObj.ended = true;
|
|
67281
|
+
const duration = Date.now() - spanContextObj.startTime;
|
|
67282
|
+
span.setAttributes({
|
|
67283
|
+
"interaction.duration_ms": duration,
|
|
67284
|
+
"qwen-code.turn_status": terminalStatus
|
|
67285
|
+
});
|
|
67286
|
+
if (terminalStatus === "ok") {
|
|
67287
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
67288
|
+
} else if (terminalStatus === "error" && !errorStatusSet) {
|
|
67289
|
+
span.setStatus({
|
|
67290
|
+
code: SpanStatusCode.ERROR,
|
|
67291
|
+
message: "interaction error"
|
|
67292
|
+
});
|
|
67293
|
+
}
|
|
67294
|
+
span.end();
|
|
67295
|
+
activeSpans.delete(spanId);
|
|
67296
|
+
strongSpans.delete(spanId);
|
|
67297
|
+
}
|
|
67298
|
+
}
|
|
67299
|
+
})
|
|
67300
|
+
);
|
|
67301
|
+
}
|
|
67302
|
+
__name(withInteractionSpan, "withInteractionSpan");
|
|
67113
67303
|
function startLLMRequestSpan(model, promptId) {
|
|
67114
67304
|
if (!isTelemetrySdkInitialized()) {
|
|
67115
67305
|
return NOOP_SPAN;
|
|
67116
67306
|
}
|
|
67117
67307
|
const parentCtx = subagentContext.getStore() ?? interactionContext.getStore();
|
|
67118
67308
|
const ctx = resolveParentContext(parentCtx);
|
|
67309
|
+
const sessionId = resolveSessionId(parentCtx);
|
|
67119
67310
|
const attributes = {
|
|
67311
|
+
...sessionId ? { "session.id": sessionId } : {},
|
|
67120
67312
|
"qwen-code.model": model,
|
|
67121
67313
|
"qwen-code.prompt_id": promptId,
|
|
67122
67314
|
"llm_request.context": subagentContext.getStore() ? "subagent" : interactionContext.getStore() ? "interaction" : "standalone",
|
|
@@ -67192,6 +67384,30 @@ function endLLMRequestSpan(span, metadata) {
|
|
|
67192
67384
|
endAttributes["success"] = metadata.success;
|
|
67193
67385
|
if (metadata.error !== void 0)
|
|
67194
67386
|
endAttributes["error"] = truncateSpanError(metadata.error);
|
|
67387
|
+
if (metadata.responseId !== void 0) {
|
|
67388
|
+
endAttributes["response_id"] = metadata.responseId;
|
|
67389
|
+
endAttributes["gen_ai.response.id"] = metadata.responseId;
|
|
67390
|
+
}
|
|
67391
|
+
if (metadata.finishReason !== void 0) {
|
|
67392
|
+
endAttributes["finish_reason"] = metadata.finishReason;
|
|
67393
|
+
endAttributes["gen_ai.response.finish_reasons"] = [
|
|
67394
|
+
metadata.finishReason
|
|
67395
|
+
];
|
|
67396
|
+
}
|
|
67397
|
+
if (metadata.thoughtsTokenCount !== void 0) {
|
|
67398
|
+
endAttributes["thoughts_token_count"] = metadata.thoughtsTokenCount;
|
|
67399
|
+
endAttributes["gen_ai.usage.reasoning_tokens"] = metadata.thoughtsTokenCount;
|
|
67400
|
+
}
|
|
67401
|
+
if (metadata.subagentName !== void 0) {
|
|
67402
|
+
endAttributes["subagent_name"] = metadata.subagentName;
|
|
67403
|
+
}
|
|
67404
|
+
if (metadata.errorType !== void 0) {
|
|
67405
|
+
endAttributes["error_type"] = metadata.errorType;
|
|
67406
|
+
endAttributes["error.type"] = metadata.errorType;
|
|
67407
|
+
}
|
|
67408
|
+
if (metadata.errorStatusCode !== void 0) {
|
|
67409
|
+
endAttributes["error_status_code"] = metadata.errorStatusCode;
|
|
67410
|
+
}
|
|
67195
67411
|
}
|
|
67196
67412
|
spanCtx.span.setAttributes(endAttributes);
|
|
67197
67413
|
if (metadata === void 0 || metadata.success) {
|
|
@@ -67224,7 +67440,9 @@ function startToolSpan(toolName, attrs) {
|
|
|
67224
67440
|
}
|
|
67225
67441
|
const parentCtx = subagentContext.getStore() ?? interactionContext.getStore();
|
|
67226
67442
|
const ctx = resolveParentContext(parentCtx);
|
|
67443
|
+
const sessionId = resolveSessionId(parentCtx);
|
|
67227
67444
|
const attributes = {
|
|
67445
|
+
...sessionId ? { "session.id": sessionId } : {},
|
|
67228
67446
|
"tool.name": toolName,
|
|
67229
67447
|
...attrs
|
|
67230
67448
|
};
|
|
@@ -67311,16 +67529,22 @@ function startToolExecutionSpan() {
|
|
|
67311
67529
|
);
|
|
67312
67530
|
}
|
|
67313
67531
|
const ctx = resolveParentContext(parentCtx);
|
|
67532
|
+
const sessionId = resolveSessionId(
|
|
67533
|
+
parentCtx ?? interactionContext.getStore()
|
|
67534
|
+
);
|
|
67314
67535
|
const span = getTracer().startSpan(
|
|
67315
67536
|
SPAN_TOOL_EXECUTION,
|
|
67316
|
-
{
|
|
67537
|
+
{
|
|
67538
|
+
kind: SpanKind.INTERNAL,
|
|
67539
|
+
attributes: sessionId ? { "session.id": sessionId } : {}
|
|
67540
|
+
},
|
|
67317
67541
|
ctx
|
|
67318
67542
|
);
|
|
67319
67543
|
const spanId = getSpanId(span);
|
|
67320
67544
|
const spanContextObj = {
|
|
67321
67545
|
span,
|
|
67322
67546
|
startTime: Date.now(),
|
|
67323
|
-
attributes: {},
|
|
67547
|
+
attributes: sessionId ? { "session.id": sessionId } : {},
|
|
67324
67548
|
type: "tool.execution"
|
|
67325
67549
|
};
|
|
67326
67550
|
activeSpans.set(spanId, new WeakRef(spanContextObj));
|
|
@@ -68080,6 +68304,7 @@ var NOOP_PROPAGATOR = {
|
|
|
68080
68304
|
var sdk;
|
|
68081
68305
|
var telemetryInitialized = false;
|
|
68082
68306
|
var telemetryShutdownPromise;
|
|
68307
|
+
var activeMetricReader;
|
|
68083
68308
|
function isTelemetrySdkInitialized() {
|
|
68084
68309
|
return telemetryInitialized;
|
|
68085
68310
|
}
|
|
@@ -68122,6 +68347,27 @@ function validateUrl(url) {
|
|
|
68122
68347
|
}
|
|
68123
68348
|
}
|
|
68124
68349
|
__name(validateUrl, "validateUrl");
|
|
68350
|
+
var SessionIdSpanProcessor = class {
|
|
68351
|
+
static {
|
|
68352
|
+
__name(this, "SessionIdSpanProcessor");
|
|
68353
|
+
}
|
|
68354
|
+
onStart(span) {
|
|
68355
|
+
try {
|
|
68356
|
+
if (span.attributes?.["session.id"]) return;
|
|
68357
|
+
const sessionId = getCurrentSessionId();
|
|
68358
|
+
if (sessionId) {
|
|
68359
|
+
span.setAttribute("session.id", sessionId);
|
|
68360
|
+
}
|
|
68361
|
+
} catch {
|
|
68362
|
+
}
|
|
68363
|
+
}
|
|
68364
|
+
onEnd(_span) {
|
|
68365
|
+
}
|
|
68366
|
+
async shutdown() {
|
|
68367
|
+
}
|
|
68368
|
+
async forceFlush() {
|
|
68369
|
+
}
|
|
68370
|
+
};
|
|
68125
68371
|
function initializeTelemetry(config) {
|
|
68126
68372
|
if (telemetryInitialized || !config.getTelemetryEnabled()) {
|
|
68127
68373
|
return;
|
|
@@ -68191,7 +68437,7 @@ function initializeTelemetry(config) {
|
|
|
68191
68437
|
// In interactive (TUI) mode, route bridge diagnostics to the OTEL
|
|
68192
68438
|
// debug log file so they don't break out of the Ink render area
|
|
68193
68439
|
// via raw stderr. In non-interactive mode, leave the default sink
|
|
68194
|
-
// alone so CI / scripts can still see export failures on stderr
|
|
68440
|
+
// alone so CI / scripts can still see export failures on stderr
|
|
68195
68441
|
// the canonical diagnostic channel for batch runs.
|
|
68196
68442
|
//
|
|
68197
68443
|
// Caveat for interactive mode: when the user has explicitly
|
|
@@ -68292,15 +68538,14 @@ function initializeTelemetry(config) {
|
|
|
68292
68538
|
// before the detectors settle (e.g. during HttpInstrumentation span creation).
|
|
68293
68539
|
autoDetectResources: false,
|
|
68294
68540
|
...textMapPropagator && { textMapPropagator },
|
|
68295
|
-
spanProcessors: spanExporter ? [new import_sdk_trace_node.BatchSpanProcessor(spanExporter)] : [],
|
|
68541
|
+
spanProcessors: spanExporter ? [new SessionIdSpanProcessor(), new import_sdk_trace_node.BatchSpanProcessor(spanExporter)] : [],
|
|
68296
68542
|
logRecordProcessors: logExporter ? [new import_sdk_logs.BatchLogRecordProcessor(logExporter)] : logToSpanProcessor ? [logToSpanProcessor] : [],
|
|
68297
68543
|
...metricReader && { metricReader },
|
|
68298
68544
|
instrumentations: [
|
|
68299
68545
|
new import_instrumentation_http.HttpInstrumentation({
|
|
68300
68546
|
// OTLP HTTP exporter uses node:http (patched here, not by undici).
|
|
68301
68547
|
// Without this, every OTLP upload batch creates a parasitic client
|
|
68302
|
-
// span that itself gets exported → feedback loop.
|
|
68303
|
-
// review feedback (wenshao).
|
|
68548
|
+
// span that itself gets exported → feedback loop.
|
|
68304
68549
|
ignoreOutgoingRequestHook: /* @__PURE__ */ __name((req) => {
|
|
68305
68550
|
if (otlpUrlPrefixes.length === 0) return false;
|
|
68306
68551
|
const proto = req.protocol ? String(req.protocol).replace(/:$/, "") : void 0;
|
|
@@ -68340,6 +68585,7 @@ function initializeTelemetry(config) {
|
|
|
68340
68585
|
sdk.start();
|
|
68341
68586
|
debugLogger12.debug("OpenTelemetry SDK started successfully.");
|
|
68342
68587
|
telemetryInitialized = true;
|
|
68588
|
+
activeMetricReader = metricReader;
|
|
68343
68589
|
const sessionId = config.getSessionId();
|
|
68344
68590
|
setSessionContext(createSessionRootContext(sessionId), sessionId);
|
|
68345
68591
|
setShellTracePropagation(
|
|
@@ -68406,6 +68652,7 @@ async function shutdownTelemetry() {
|
|
|
68406
68652
|
} finally {
|
|
68407
68653
|
telemetryInitialized = false;
|
|
68408
68654
|
sdk = void 0;
|
|
68655
|
+
activeMetricReader = void 0;
|
|
68409
68656
|
telemetryShutdownPromise = void 0;
|
|
68410
68657
|
setSessionContext(void 0);
|
|
68411
68658
|
setShellTracePropagation(false);
|
|
@@ -68414,6 +68661,31 @@ async function shutdownTelemetry() {
|
|
|
68414
68661
|
return telemetryShutdownPromise;
|
|
68415
68662
|
}
|
|
68416
68663
|
__name(shutdownTelemetry, "shutdownTelemetry");
|
|
68664
|
+
var FORCE_FLUSH_TIMEOUT_MS = 2e3;
|
|
68665
|
+
async function forceFlushMetrics() {
|
|
68666
|
+
if (!telemetryInitialized || !activeMetricReader) return;
|
|
68667
|
+
const flush = activeMetricReader.forceFlush();
|
|
68668
|
+
flush.catch(() => {
|
|
68669
|
+
});
|
|
68670
|
+
let timer;
|
|
68671
|
+
const timeout = new Promise((_, reject) => {
|
|
68672
|
+
timer = setTimeout(
|
|
68673
|
+
() => reject(
|
|
68674
|
+
new Error(
|
|
68675
|
+
`forceFlushMetrics timed out after ${FORCE_FLUSH_TIMEOUT_MS}ms`
|
|
68676
|
+
)
|
|
68677
|
+
),
|
|
68678
|
+
FORCE_FLUSH_TIMEOUT_MS
|
|
68679
|
+
);
|
|
68680
|
+
timer.unref?.();
|
|
68681
|
+
});
|
|
68682
|
+
try {
|
|
68683
|
+
await Promise.race([flush, timeout]);
|
|
68684
|
+
} finally {
|
|
68685
|
+
clearTimeout(timer);
|
|
68686
|
+
}
|
|
68687
|
+
}
|
|
68688
|
+
__name(forceFlushMetrics, "forceFlushMetrics");
|
|
68417
68689
|
|
|
68418
68690
|
// packages/core/src/telemetry/config.ts
|
|
68419
68691
|
init_esbuild_shims();
|
|
@@ -68655,27 +68927,24 @@ var createInitialMetrics = /* @__PURE__ */ __name(() => ({
|
|
|
68655
68927
|
totalLinesRemoved: 0
|
|
68656
68928
|
}
|
|
68657
68929
|
}), "createInitialMetrics");
|
|
68658
|
-
var UiTelemetryService = class extends EventEmitter {
|
|
68930
|
+
var UiTelemetryService = class _UiTelemetryService extends EventEmitter {
|
|
68659
68931
|
static {
|
|
68660
68932
|
__name(this, "UiTelemetryService");
|
|
68661
68933
|
}
|
|
68934
|
+
static #MAX_CLOSED_SESSIONS = 1e3;
|
|
68662
68935
|
#metrics = createInitialMetrics();
|
|
68936
|
+
#sessionMetrics = /* @__PURE__ */ new Map();
|
|
68937
|
+
#closedSessions = /* @__PURE__ */ new Set();
|
|
68663
68938
|
#lastPromptTokenCount = 0;
|
|
68664
68939
|
#lastCachedContentTokenCount = 0;
|
|
68665
68940
|
#sessionStartTime = /* @__PURE__ */ new Date();
|
|
68666
|
-
addEvent(event) {
|
|
68667
|
-
|
|
68668
|
-
|
|
68669
|
-
|
|
68670
|
-
|
|
68671
|
-
|
|
68672
|
-
|
|
68673
|
-
break;
|
|
68674
|
-
case EVENT_TOOL_CALL:
|
|
68675
|
-
this.processToolCall(event);
|
|
68676
|
-
break;
|
|
68677
|
-
default:
|
|
68678
|
-
return;
|
|
68941
|
+
addEvent(event, sessionId) {
|
|
68942
|
+
if (!this.#accumulateEvent(this.#metrics, event)) return;
|
|
68943
|
+
if (sessionId && !this.#closedSessions.has(sessionId)) {
|
|
68944
|
+
if (!this.#sessionMetrics.has(sessionId)) {
|
|
68945
|
+
this.#sessionMetrics.set(sessionId, createInitialMetrics());
|
|
68946
|
+
}
|
|
68947
|
+
this.#accumulateEvent(this.#sessionMetrics.get(sessionId), event);
|
|
68679
68948
|
}
|
|
68680
68949
|
this.emit("update", {
|
|
68681
68950
|
metrics: this.#metrics,
|
|
@@ -68685,6 +68954,9 @@ var UiTelemetryService = class extends EventEmitter {
|
|
|
68685
68954
|
getMetrics() {
|
|
68686
68955
|
return this.#metrics;
|
|
68687
68956
|
}
|
|
68957
|
+
getMetricsForSession(sessionId) {
|
|
68958
|
+
return this.#sessionMetrics.get(sessionId) ?? createInitialMetrics();
|
|
68959
|
+
}
|
|
68688
68960
|
getLastPromptTokenCount() {
|
|
68689
68961
|
return this.#lastPromptTokenCount;
|
|
68690
68962
|
}
|
|
@@ -68709,6 +68981,8 @@ var UiTelemetryService = class extends EventEmitter {
|
|
|
68709
68981
|
*/
|
|
68710
68982
|
reset() {
|
|
68711
68983
|
this.#metrics = createInitialMetrics();
|
|
68984
|
+
this.#sessionMetrics.clear();
|
|
68985
|
+
this.#closedSessions.clear();
|
|
68712
68986
|
this.#lastPromptTokenCount = 0;
|
|
68713
68987
|
this.#lastCachedContentTokenCount = 0;
|
|
68714
68988
|
this.#sessionStartTime = /* @__PURE__ */ new Date();
|
|
@@ -68717,21 +68991,36 @@ var UiTelemetryService = class extends EventEmitter {
|
|
|
68717
68991
|
lastPromptTokenCount: this.#lastPromptTokenCount
|
|
68718
68992
|
});
|
|
68719
68993
|
}
|
|
68720
|
-
|
|
68721
|
-
|
|
68722
|
-
|
|
68994
|
+
resetSession(sessionId) {
|
|
68995
|
+
this.#sessionMetrics.set(sessionId, createInitialMetrics());
|
|
68996
|
+
this.#closedSessions.delete(sessionId);
|
|
68997
|
+
}
|
|
68998
|
+
removeSession(sessionId) {
|
|
68999
|
+
this.#sessionMetrics.delete(sessionId);
|
|
69000
|
+
this.#closedSessions.add(sessionId);
|
|
69001
|
+
if (this.#closedSessions.size > _UiTelemetryService.#MAX_CLOSED_SESSIONS) {
|
|
69002
|
+
const oldest = this.#closedSessions.values().next().value;
|
|
69003
|
+
if (oldest) this.#closedSessions.delete(oldest);
|
|
68723
69004
|
}
|
|
68724
|
-
return this.#metrics.models[modelName];
|
|
68725
69005
|
}
|
|
68726
|
-
|
|
68727
|
-
|
|
68728
|
-
|
|
69006
|
+
#accumulateEvent(metrics2, event) {
|
|
69007
|
+
switch (event["event.name"]) {
|
|
69008
|
+
case EVENT_API_RESPONSE:
|
|
69009
|
+
this.#accumulateApiResponse(metrics2, event);
|
|
69010
|
+
return true;
|
|
69011
|
+
case EVENT_API_ERROR:
|
|
69012
|
+
this.#accumulateApiError(metrics2, event);
|
|
69013
|
+
return true;
|
|
69014
|
+
case EVENT_TOOL_CALL:
|
|
69015
|
+
this.#accumulateToolCall(metrics2, event);
|
|
69016
|
+
return true;
|
|
69017
|
+
default:
|
|
69018
|
+
return false;
|
|
68729
69019
|
}
|
|
68730
|
-
return modelMetrics.bySource[source];
|
|
68731
69020
|
}
|
|
68732
|
-
|
|
68733
|
-
const modelMetrics = this
|
|
68734
|
-
const sourceMetrics = this
|
|
69021
|
+
#accumulateApiResponse(metrics2, event) {
|
|
69022
|
+
const modelMetrics = this.#getOrCreateModelMetrics(metrics2, event.model);
|
|
69023
|
+
const sourceMetrics = this.#getOrCreateSourceMetrics(
|
|
68735
69024
|
modelMetrics,
|
|
68736
69025
|
event.subagent_name ?? MAIN_SOURCE
|
|
68737
69026
|
);
|
|
@@ -68745,9 +69034,9 @@ var UiTelemetryService = class extends EventEmitter {
|
|
|
68745
69034
|
bucket.tokens.thoughts += event.thoughts_token_count;
|
|
68746
69035
|
}
|
|
68747
69036
|
}
|
|
68748
|
-
|
|
68749
|
-
const modelMetrics = this
|
|
68750
|
-
const sourceMetrics = this
|
|
69037
|
+
#accumulateApiError(metrics2, event) {
|
|
69038
|
+
const modelMetrics = this.#getOrCreateModelMetrics(metrics2, event.model);
|
|
69039
|
+
const sourceMetrics = this.#getOrCreateSourceMetrics(
|
|
68751
69040
|
modelMetrics,
|
|
68752
69041
|
event.subagent_name ?? MAIN_SOURCE
|
|
68753
69042
|
);
|
|
@@ -68757,8 +69046,8 @@ var UiTelemetryService = class extends EventEmitter {
|
|
|
68757
69046
|
bucket.api.totalLatencyMs += event.duration_ms;
|
|
68758
69047
|
}
|
|
68759
69048
|
}
|
|
68760
|
-
|
|
68761
|
-
const { tools, files } =
|
|
69049
|
+
#accumulateToolCall(metrics2, event) {
|
|
69050
|
+
const { tools, files } = metrics2;
|
|
68762
69051
|
tools.totalCalls++;
|
|
68763
69052
|
tools.totalDurationMs += event.duration_ms;
|
|
68764
69053
|
if (event.success) {
|
|
@@ -68801,9 +69090,490 @@ var UiTelemetryService = class extends EventEmitter {
|
|
|
68801
69090
|
}
|
|
68802
69091
|
}
|
|
68803
69092
|
}
|
|
69093
|
+
#getOrCreateModelMetrics(metrics2, modelName) {
|
|
69094
|
+
if (!metrics2.models[modelName]) {
|
|
69095
|
+
metrics2.models[modelName] = createInitialModelMetrics();
|
|
69096
|
+
}
|
|
69097
|
+
return metrics2.models[modelName];
|
|
69098
|
+
}
|
|
69099
|
+
#getOrCreateSourceMetrics(modelMetrics, source) {
|
|
69100
|
+
if (!modelMetrics.bySource[source]) {
|
|
69101
|
+
modelMetrics.bySource[source] = createInitialModelMetricsCore();
|
|
69102
|
+
}
|
|
69103
|
+
return modelMetrics.bySource[source];
|
|
69104
|
+
}
|
|
68804
69105
|
};
|
|
68805
69106
|
var uiTelemetryService = new UiTelemetryService();
|
|
68806
69107
|
|
|
69108
|
+
// packages/core/src/telemetry/daemon-tracing.ts
|
|
69109
|
+
init_esbuild_shims();
|
|
69110
|
+
init_esm();
|
|
69111
|
+
var import_api_logs = __toESM(require_src2(), 1);
|
|
69112
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
69113
|
+
var DAEMON_TRACEPARENT_META_KEY = "qwen.telemetry.traceparent";
|
|
69114
|
+
var DAEMON_TRACESTATE_META_KEY = "qwen.telemetry.tracestate";
|
|
69115
|
+
var SPAN_DAEMON_REQUEST = "qwen-code.daemon.request";
|
|
69116
|
+
var SPAN_DAEMON_BRIDGE = "qwen-code.daemon.bridge";
|
|
69117
|
+
var EVENT_DAEMON_ERROR = "qwen-code.daemon.error";
|
|
69118
|
+
function errorMessage(error) {
|
|
69119
|
+
if (error instanceof Error) return error.message;
|
|
69120
|
+
return String(error);
|
|
69121
|
+
}
|
|
69122
|
+
__name(errorMessage, "errorMessage");
|
|
69123
|
+
function errorType(error) {
|
|
69124
|
+
if (error instanceof Error) return error.name || "Error";
|
|
69125
|
+
return typeof error;
|
|
69126
|
+
}
|
|
69127
|
+
__name(errorType, "errorType");
|
|
69128
|
+
var INVALID_TRACE_ID = "0".repeat(32);
|
|
69129
|
+
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
|
+
function stripReservedTraceMeta(meta) {
|
|
69138
|
+
if (!meta || typeof meta !== "object" || Array.isArray(meta)) return {};
|
|
69139
|
+
const record = meta;
|
|
69140
|
+
if (!(DAEMON_TRACEPARENT_META_KEY in record) && !(DAEMON_TRACESTATE_META_KEY in record)) {
|
|
69141
|
+
return { ...record };
|
|
69142
|
+
}
|
|
69143
|
+
const out = { ...record };
|
|
69144
|
+
delete out[DAEMON_TRACEPARENT_META_KEY];
|
|
69145
|
+
delete out[DAEMON_TRACESTATE_META_KEY];
|
|
69146
|
+
return out;
|
|
69147
|
+
}
|
|
69148
|
+
__name(stripReservedTraceMeta, "stripReservedTraceMeta");
|
|
69149
|
+
function hashDaemonWorkspace(workspace) {
|
|
69150
|
+
return createHash3("sha256").update(workspace).digest("hex").slice(0, 16);
|
|
69151
|
+
}
|
|
69152
|
+
__name(hashDaemonWorkspace, "hashDaemonWorkspace");
|
|
69153
|
+
async function withDaemonSpan(name, attributes, fn, options = {}) {
|
|
69154
|
+
if (!isTelemetrySdkInitialized()) {
|
|
69155
|
+
return await fn(void 0);
|
|
69156
|
+
}
|
|
69157
|
+
const autoOkOnSuccess = options.autoOkOnSuccess ?? true;
|
|
69158
|
+
const tracer2 = trace.getTracer(SERVICE_NAME);
|
|
69159
|
+
return await tracer2.startActiveSpan(
|
|
69160
|
+
name,
|
|
69161
|
+
{ kind: SpanKind.INTERNAL, attributes },
|
|
69162
|
+
async (span) => {
|
|
69163
|
+
try {
|
|
69164
|
+
const result = await fn(span);
|
|
69165
|
+
if (autoOkOnSuccess) {
|
|
69166
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
69167
|
+
}
|
|
69168
|
+
return result;
|
|
69169
|
+
} catch (error) {
|
|
69170
|
+
recordDaemonError(span, error);
|
|
69171
|
+
throw error;
|
|
69172
|
+
} finally {
|
|
69173
|
+
span.end();
|
|
69174
|
+
}
|
|
69175
|
+
}
|
|
69176
|
+
);
|
|
69177
|
+
}
|
|
69178
|
+
__name(withDaemonSpan, "withDaemonSpan");
|
|
69179
|
+
async function withDaemonRequestSpan(options, fn) {
|
|
69180
|
+
return await withDaemonSpan(
|
|
69181
|
+
SPAN_DAEMON_REQUEST,
|
|
69182
|
+
{
|
|
69183
|
+
"http.request.method": options.method,
|
|
69184
|
+
"http.route": options.route,
|
|
69185
|
+
"qwen-code.daemon.operation": "http_request",
|
|
69186
|
+
...options.workspaceHash ? { "qwen-code.workspace.hash": options.workspaceHash } : {},
|
|
69187
|
+
...options.sessionId ? { "session.id": options.sessionId } : {},
|
|
69188
|
+
...options.clientId ? { "qwen-code.client_id": options.clientId } : {},
|
|
69189
|
+
...options.permissionRequestId ? {
|
|
69190
|
+
"qwen-code.daemon.permission.request_id": options.permissionRequestId
|
|
69191
|
+
} : {}
|
|
69192
|
+
},
|
|
69193
|
+
fn,
|
|
69194
|
+
{ autoOkOnSuccess: false }
|
|
69195
|
+
);
|
|
69196
|
+
}
|
|
69197
|
+
__name(withDaemonRequestSpan, "withDaemonRequestSpan");
|
|
69198
|
+
async function withDaemonBridgeSpan(operation, attributes, fn) {
|
|
69199
|
+
return await withDaemonSpan(
|
|
69200
|
+
SPAN_DAEMON_BRIDGE,
|
|
69201
|
+
{
|
|
69202
|
+
"qwen-code.daemon.operation": operation,
|
|
69203
|
+
...attributes
|
|
69204
|
+
},
|
|
69205
|
+
async () => await fn()
|
|
69206
|
+
);
|
|
69207
|
+
}
|
|
69208
|
+
__name(withDaemonBridgeSpan, "withDaemonBridgeSpan");
|
|
69209
|
+
function recordDaemonHttpResponse(span, statusCode) {
|
|
69210
|
+
try {
|
|
69211
|
+
span?.setAttribute("http.response.status_code", statusCode);
|
|
69212
|
+
} catch {
|
|
69213
|
+
}
|
|
69214
|
+
}
|
|
69215
|
+
__name(recordDaemonHttpResponse, "recordDaemonHttpResponse");
|
|
69216
|
+
function addDaemonRequestAttribute(key, value) {
|
|
69217
|
+
try {
|
|
69218
|
+
trace.getSpan(context.active())?.setAttribute(key, value);
|
|
69219
|
+
} catch {
|
|
69220
|
+
}
|
|
69221
|
+
}
|
|
69222
|
+
__name(addDaemonRequestAttribute, "addDaemonRequestAttribute");
|
|
69223
|
+
function recordDaemonError(span, error, attributes = {}) {
|
|
69224
|
+
const target = span ?? trace.getSpan(context.active());
|
|
69225
|
+
if (!target) return;
|
|
69226
|
+
try {
|
|
69227
|
+
const message = truncateSpanError(errorMessage(error));
|
|
69228
|
+
target.recordException(error instanceof Error ? error : new Error(message));
|
|
69229
|
+
target.setAttributes({
|
|
69230
|
+
"error.type": errorType(error),
|
|
69231
|
+
"error.message": message,
|
|
69232
|
+
...attributes
|
|
69233
|
+
});
|
|
69234
|
+
target.setStatus({ code: SpanStatusCode.ERROR, message });
|
|
69235
|
+
} catch {
|
|
69236
|
+
}
|
|
69237
|
+
}
|
|
69238
|
+
__name(recordDaemonError, "recordDaemonError");
|
|
69239
|
+
function emitDaemonLog(body, attributes = {}, options) {
|
|
69240
|
+
if (!isTelemetrySdkInitialized()) return;
|
|
69241
|
+
try {
|
|
69242
|
+
import_api_logs.logs.getLogger(SERVICE_NAME).emit({
|
|
69243
|
+
body,
|
|
69244
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
69245
|
+
attributes: {
|
|
69246
|
+
"event.name": options?.eventName ?? EVENT_DAEMON_ERROR,
|
|
69247
|
+
...attributes
|
|
69248
|
+
},
|
|
69249
|
+
...options?.severityNumber != null ? { severityNumber: options.severityNumber } : {}
|
|
69250
|
+
});
|
|
69251
|
+
} catch {
|
|
69252
|
+
}
|
|
69253
|
+
}
|
|
69254
|
+
__name(emitDaemonLog, "emitDaemonLog");
|
|
69255
|
+
function captureDaemonTelemetryContext() {
|
|
69256
|
+
return { context: context.active() };
|
|
69257
|
+
}
|
|
69258
|
+
__name(captureDaemonTelemetryContext, "captureDaemonTelemetryContext");
|
|
69259
|
+
async function runWithDaemonTelemetryContext(captured, fn) {
|
|
69260
|
+
const ctx = captured && typeof captured === "object" && "context" in captured && captured.context ? captured.context : void 0;
|
|
69261
|
+
if (!ctx) return await fn();
|
|
69262
|
+
return await context.with(ctx, fn);
|
|
69263
|
+
}
|
|
69264
|
+
__name(runWithDaemonTelemetryContext, "runWithDaemonTelemetryContext");
|
|
69265
|
+
function injectDaemonTraceContext(request4) {
|
|
69266
|
+
const currentMeta = request4._meta;
|
|
69267
|
+
if (!activeSpanContextIsValid()) {
|
|
69268
|
+
return currentMeta ? { ...request4, _meta: stripReservedTraceMeta(currentMeta) } : request4;
|
|
69269
|
+
}
|
|
69270
|
+
const nextMeta = stripReservedTraceMeta(currentMeta);
|
|
69271
|
+
try {
|
|
69272
|
+
const carrier = {};
|
|
69273
|
+
propagation.inject(context.active(), carrier);
|
|
69274
|
+
if (carrier["traceparent"]) {
|
|
69275
|
+
nextMeta[DAEMON_TRACEPARENT_META_KEY] = carrier["traceparent"];
|
|
69276
|
+
}
|
|
69277
|
+
if (carrier["tracestate"]) {
|
|
69278
|
+
nextMeta[DAEMON_TRACESTATE_META_KEY] = carrier["tracestate"];
|
|
69279
|
+
}
|
|
69280
|
+
} catch {
|
|
69281
|
+
}
|
|
69282
|
+
if (!currentMeta && !nextMeta[DAEMON_TRACEPARENT_META_KEY]) {
|
|
69283
|
+
return request4;
|
|
69284
|
+
}
|
|
69285
|
+
return {
|
|
69286
|
+
...request4,
|
|
69287
|
+
_meta: nextMeta
|
|
69288
|
+
};
|
|
69289
|
+
}
|
|
69290
|
+
__name(injectDaemonTraceContext, "injectDaemonTraceContext");
|
|
69291
|
+
function extractDaemonTraceContext(source) {
|
|
69292
|
+
const meta = source?._meta;
|
|
69293
|
+
if (!meta || typeof meta !== "object" || Array.isArray(meta)) {
|
|
69294
|
+
return void 0;
|
|
69295
|
+
}
|
|
69296
|
+
const record = meta;
|
|
69297
|
+
const traceparent = record[DAEMON_TRACEPARENT_META_KEY];
|
|
69298
|
+
if (typeof traceparent !== "string" || traceparent.length === 0) {
|
|
69299
|
+
return void 0;
|
|
69300
|
+
}
|
|
69301
|
+
const carrier = { traceparent };
|
|
69302
|
+
const tracestate = record[DAEMON_TRACESTATE_META_KEY];
|
|
69303
|
+
if (typeof tracestate === "string" && tracestate.length > 0) {
|
|
69304
|
+
carrier["tracestate"] = tracestate;
|
|
69305
|
+
}
|
|
69306
|
+
const extracted = propagation.extract(ROOT_CONTEXT, carrier);
|
|
69307
|
+
if (trace.getSpanContext(extracted)) return extracted;
|
|
69308
|
+
const parts = traceparent.split("-");
|
|
69309
|
+
const traceId = parts[1];
|
|
69310
|
+
const spanId = parts[2];
|
|
69311
|
+
const flags = parts[3];
|
|
69312
|
+
if (parts[0] !== "00" || !traceId?.match(/^[0-9a-f]{32}$/) || !spanId?.match(/^[0-9a-f]{16}$/) || !flags?.match(/^[0-9a-f]{2}$/) || traceId === INVALID_TRACE_ID || spanId === INVALID_SPAN_ID) {
|
|
69313
|
+
return void 0;
|
|
69314
|
+
}
|
|
69315
|
+
return trace.setSpan(
|
|
69316
|
+
ROOT_CONTEXT,
|
|
69317
|
+
trace.wrapSpanContext({
|
|
69318
|
+
traceId,
|
|
69319
|
+
spanId,
|
|
69320
|
+
traceFlags: Number.parseInt(flags, 16),
|
|
69321
|
+
isRemote: true
|
|
69322
|
+
})
|
|
69323
|
+
);
|
|
69324
|
+
}
|
|
69325
|
+
__name(extractDaemonTraceContext, "extractDaemonTraceContext");
|
|
69326
|
+
function createDaemonBridgeTelemetry() {
|
|
69327
|
+
return {
|
|
69328
|
+
captureContext: captureDaemonTelemetryContext,
|
|
69329
|
+
runWithContext: runWithDaemonTelemetryContext,
|
|
69330
|
+
withSpan: withDaemonBridgeSpan,
|
|
69331
|
+
event(name, attributes) {
|
|
69332
|
+
if (!isTelemetrySdkInitialized()) return;
|
|
69333
|
+
try {
|
|
69334
|
+
const activeSpan = trace.getSpan(context.active());
|
|
69335
|
+
if (activeSpan) {
|
|
69336
|
+
activeSpan.addEvent(name, attributes);
|
|
69337
|
+
return;
|
|
69338
|
+
}
|
|
69339
|
+
const span = trace.getTracer(SERVICE_NAME).startSpan(SPAN_DAEMON_BRIDGE, {
|
|
69340
|
+
kind: SpanKind.INTERNAL,
|
|
69341
|
+
attributes: {
|
|
69342
|
+
"event.name": name,
|
|
69343
|
+
"qwen-code.daemon.operation": `event.${name}`,
|
|
69344
|
+
...attributes
|
|
69345
|
+
}
|
|
69346
|
+
});
|
|
69347
|
+
span.addEvent(name, attributes);
|
|
69348
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
69349
|
+
span.end();
|
|
69350
|
+
} catch {
|
|
69351
|
+
}
|
|
69352
|
+
},
|
|
69353
|
+
injectPromptContext: injectDaemonTraceContext
|
|
69354
|
+
};
|
|
69355
|
+
}
|
|
69356
|
+
__name(createDaemonBridgeTelemetry, "createDaemonBridgeTelemetry");
|
|
69357
|
+
|
|
69358
|
+
// packages/core/src/telemetry/daemon-metrics.ts
|
|
69359
|
+
init_esbuild_shims();
|
|
69360
|
+
init_esm();
|
|
69361
|
+
var DAEMON_HTTP_REQUEST_COUNT = `${SERVICE_NAME}.daemon.http.request.count`;
|
|
69362
|
+
var DAEMON_HTTP_REQUEST_DURATION = `${SERVICE_NAME}.daemon.http.request.duration`;
|
|
69363
|
+
var DAEMON_SESSION_ACTIVE = `${SERVICE_NAME}.daemon.session.active`;
|
|
69364
|
+
var DAEMON_SESSION_LIFECYCLE = `${SERVICE_NAME}.daemon.session.lifecycle`;
|
|
69365
|
+
var DAEMON_CHANNEL_LIFECYCLE = `${SERVICE_NAME}.daemon.channel.lifecycle`;
|
|
69366
|
+
var DAEMON_PROMPT_QUEUE_WAIT = `${SERVICE_NAME}.daemon.prompt.queue_wait`;
|
|
69367
|
+
var DAEMON_PROMPT_DURATION = `${SERVICE_NAME}.daemon.prompt.duration`;
|
|
69368
|
+
var DAEMON_BRIDGE_ERROR_COUNT = `${SERVICE_NAME}.daemon.bridge.error.count`;
|
|
69369
|
+
var DAEMON_CANCEL_COUNT = `${SERVICE_NAME}.daemon.cancel.count`;
|
|
69370
|
+
var DAEMON_SSE_ACTIVE = `${SERVICE_NAME}.daemon.sse.active`;
|
|
69371
|
+
var DAEMON_PROCESS_HEAP_USED = `${SERVICE_NAME}.daemon.process.heap_used`;
|
|
69372
|
+
var KNOWN_ERROR_TYPES = /* @__PURE__ */ new Set([
|
|
69373
|
+
"SessionNotFoundError",
|
|
69374
|
+
"WorkspaceMismatchError",
|
|
69375
|
+
"InvalidClientIdError",
|
|
69376
|
+
"SessionLimitExceededError",
|
|
69377
|
+
"RestoreInProgressError",
|
|
69378
|
+
"InvalidSessionScopeError",
|
|
69379
|
+
"TrustGateError",
|
|
69380
|
+
"WorkspaceInitConflictError",
|
|
69381
|
+
"WorkspaceInitPathEscapeError",
|
|
69382
|
+
"WorkspaceInitSymlinkError",
|
|
69383
|
+
"WorkspaceInitRaceError",
|
|
69384
|
+
"McpServerNotFoundError",
|
|
69385
|
+
"McpServerRestartFailedError",
|
|
69386
|
+
"PromptDeadlineExceededError",
|
|
69387
|
+
"InvalidSessionMetadataError",
|
|
69388
|
+
"SubscriberLimitExceededError",
|
|
69389
|
+
"BridgeChannelClosedError",
|
|
69390
|
+
"BridgeTimeoutError",
|
|
69391
|
+
"PermissionForbiddenError"
|
|
69392
|
+
]);
|
|
69393
|
+
var initialized = false;
|
|
69394
|
+
var httpRequestCounter;
|
|
69395
|
+
var httpRequestDurationHistogram;
|
|
69396
|
+
var sessionLifecycleCounter;
|
|
69397
|
+
var channelLifecycleCounter;
|
|
69398
|
+
var promptQueueWaitHistogram;
|
|
69399
|
+
var promptDurationHistogram;
|
|
69400
|
+
var bridgeErrorCounter;
|
|
69401
|
+
var cancelCounter;
|
|
69402
|
+
function normalizeErrorType(err) {
|
|
69403
|
+
const name = err instanceof Error ? err.name : typeof err;
|
|
69404
|
+
return KNOWN_ERROR_TYPES.has(name) ? name : "unknown";
|
|
69405
|
+
}
|
|
69406
|
+
__name(normalizeErrorType, "normalizeErrorType");
|
|
69407
|
+
function initializeDaemonMetrics() {
|
|
69408
|
+
if (initialized) return;
|
|
69409
|
+
const meter = getMeter();
|
|
69410
|
+
if (!meter) return;
|
|
69411
|
+
httpRequestCounter = meter.createCounter(DAEMON_HTTP_REQUEST_COUNT, {
|
|
69412
|
+
description: "Daemon HTTP request count by route and status class.",
|
|
69413
|
+
valueType: ValueType.INT
|
|
69414
|
+
});
|
|
69415
|
+
httpRequestDurationHistogram = meter.createHistogram(
|
|
69416
|
+
DAEMON_HTTP_REQUEST_DURATION,
|
|
69417
|
+
{
|
|
69418
|
+
description: "Daemon HTTP request duration in milliseconds.",
|
|
69419
|
+
unit: "ms",
|
|
69420
|
+
valueType: ValueType.DOUBLE,
|
|
69421
|
+
advice: {
|
|
69422
|
+
explicitBucketBoundaries: [
|
|
69423
|
+
1,
|
|
69424
|
+
2,
|
|
69425
|
+
5,
|
|
69426
|
+
10,
|
|
69427
|
+
25,
|
|
69428
|
+
50,
|
|
69429
|
+
100,
|
|
69430
|
+
250,
|
|
69431
|
+
500,
|
|
69432
|
+
1e3,
|
|
69433
|
+
2500,
|
|
69434
|
+
5e3,
|
|
69435
|
+
1e4,
|
|
69436
|
+
3e4
|
|
69437
|
+
]
|
|
69438
|
+
}
|
|
69439
|
+
}
|
|
69440
|
+
);
|
|
69441
|
+
sessionLifecycleCounter = meter.createCounter(DAEMON_SESSION_LIFECYCLE, {
|
|
69442
|
+
description: "Daemon session lifecycle events (spawn, close, die).",
|
|
69443
|
+
valueType: ValueType.INT
|
|
69444
|
+
});
|
|
69445
|
+
channelLifecycleCounter = meter.createCounter(DAEMON_CHANNEL_LIFECYCLE, {
|
|
69446
|
+
description: "Daemon ACP channel lifecycle events (spawn, exit).",
|
|
69447
|
+
valueType: ValueType.INT
|
|
69448
|
+
});
|
|
69449
|
+
promptQueueWaitHistogram = meter.createHistogram(DAEMON_PROMPT_QUEUE_WAIT, {
|
|
69450
|
+
description: "Time a prompt waited in the per-session FIFO queue.",
|
|
69451
|
+
unit: "ms",
|
|
69452
|
+
valueType: ValueType.DOUBLE,
|
|
69453
|
+
advice: {
|
|
69454
|
+
explicitBucketBoundaries: [
|
|
69455
|
+
1,
|
|
69456
|
+
5,
|
|
69457
|
+
10,
|
|
69458
|
+
50,
|
|
69459
|
+
100,
|
|
69460
|
+
500,
|
|
69461
|
+
1e3,
|
|
69462
|
+
5e3,
|
|
69463
|
+
1e4,
|
|
69464
|
+
3e4,
|
|
69465
|
+
6e4
|
|
69466
|
+
]
|
|
69467
|
+
}
|
|
69468
|
+
});
|
|
69469
|
+
promptDurationHistogram = meter.createHistogram(DAEMON_PROMPT_DURATION, {
|
|
69470
|
+
description: "End-to-end prompt duration from dispatch to completion.",
|
|
69471
|
+
unit: "ms",
|
|
69472
|
+
valueType: ValueType.DOUBLE,
|
|
69473
|
+
advice: {
|
|
69474
|
+
explicitBucketBoundaries: [
|
|
69475
|
+
100,
|
|
69476
|
+
500,
|
|
69477
|
+
1e3,
|
|
69478
|
+
2500,
|
|
69479
|
+
5e3,
|
|
69480
|
+
1e4,
|
|
69481
|
+
3e4,
|
|
69482
|
+
6e4,
|
|
69483
|
+
12e4,
|
|
69484
|
+
3e5,
|
|
69485
|
+
6e5
|
|
69486
|
+
]
|
|
69487
|
+
}
|
|
69488
|
+
});
|
|
69489
|
+
bridgeErrorCounter = meter.createCounter(DAEMON_BRIDGE_ERROR_COUNT, {
|
|
69490
|
+
description: "Daemon bridge error count by normalized error type.",
|
|
69491
|
+
valueType: ValueType.INT
|
|
69492
|
+
});
|
|
69493
|
+
cancelCounter = meter.createCounter(DAEMON_CANCEL_COUNT, {
|
|
69494
|
+
description: "Daemon cancel request count.",
|
|
69495
|
+
valueType: ValueType.INT
|
|
69496
|
+
});
|
|
69497
|
+
initialized = true;
|
|
69498
|
+
}
|
|
69499
|
+
__name(initializeDaemonMetrics, "initializeDaemonMetrics");
|
|
69500
|
+
var gaugesRegistered = false;
|
|
69501
|
+
function registerDaemonGaugeCallbacks(callbacks) {
|
|
69502
|
+
if (gaugesRegistered) return;
|
|
69503
|
+
const meter = getMeter();
|
|
69504
|
+
if (!meter) return;
|
|
69505
|
+
meter.createObservableGauge(DAEMON_SESSION_ACTIVE, {
|
|
69506
|
+
description: "Current number of active daemon sessions.",
|
|
69507
|
+
valueType: ValueType.INT
|
|
69508
|
+
}).addCallback((result) => {
|
|
69509
|
+
try {
|
|
69510
|
+
result.observe(callbacks.sessionCount());
|
|
69511
|
+
} catch {
|
|
69512
|
+
}
|
|
69513
|
+
});
|
|
69514
|
+
meter.createObservableGauge(DAEMON_SSE_ACTIVE, {
|
|
69515
|
+
description: "Current number of active SSE connections.",
|
|
69516
|
+
valueType: ValueType.INT
|
|
69517
|
+
}).addCallback((result) => {
|
|
69518
|
+
try {
|
|
69519
|
+
result.observe(callbacks.sseCount());
|
|
69520
|
+
} catch {
|
|
69521
|
+
}
|
|
69522
|
+
});
|
|
69523
|
+
meter.createObservableGauge(DAEMON_PROCESS_HEAP_USED, {
|
|
69524
|
+
description: "Daemon process heap memory usage in bytes.",
|
|
69525
|
+
unit: "bytes",
|
|
69526
|
+
valueType: ValueType.INT
|
|
69527
|
+
}).addCallback((result) => {
|
|
69528
|
+
try {
|
|
69529
|
+
result.observe(callbacks.heapUsed());
|
|
69530
|
+
} catch {
|
|
69531
|
+
}
|
|
69532
|
+
});
|
|
69533
|
+
gaugesRegistered = true;
|
|
69534
|
+
}
|
|
69535
|
+
__name(registerDaemonGaugeCallbacks, "registerDaemonGaugeCallbacks");
|
|
69536
|
+
function recordDaemonHttpRequest(durationMs, route, statusCode) {
|
|
69537
|
+
if (!initialized) return;
|
|
69538
|
+
const statusClass = `${Math.floor(statusCode / 100)}xx`;
|
|
69539
|
+
httpRequestCounter?.add(1, { route, status_class: statusClass });
|
|
69540
|
+
httpRequestDurationHistogram?.record(durationMs, { route });
|
|
69541
|
+
}
|
|
69542
|
+
__name(recordDaemonHttpRequest, "recordDaemonHttpRequest");
|
|
69543
|
+
function recordDaemonSessionLifecycle(action) {
|
|
69544
|
+
if (!initialized) return;
|
|
69545
|
+
sessionLifecycleCounter?.add(1, { action });
|
|
69546
|
+
}
|
|
69547
|
+
__name(recordDaemonSessionLifecycle, "recordDaemonSessionLifecycle");
|
|
69548
|
+
function recordDaemonChannelLifecycle(action, expected) {
|
|
69549
|
+
if (!initialized) return;
|
|
69550
|
+
channelLifecycleCounter?.add(1, {
|
|
69551
|
+
action,
|
|
69552
|
+
...expected != null ? { expected } : {}
|
|
69553
|
+
});
|
|
69554
|
+
}
|
|
69555
|
+
__name(recordDaemonChannelLifecycle, "recordDaemonChannelLifecycle");
|
|
69556
|
+
function recordDaemonPromptQueueWait(durationMs) {
|
|
69557
|
+
if (!initialized) return;
|
|
69558
|
+
promptQueueWaitHistogram?.record(durationMs);
|
|
69559
|
+
}
|
|
69560
|
+
__name(recordDaemonPromptQueueWait, "recordDaemonPromptQueueWait");
|
|
69561
|
+
function recordDaemonPromptDuration(durationMs) {
|
|
69562
|
+
if (!initialized) return;
|
|
69563
|
+
promptDurationHistogram?.record(durationMs);
|
|
69564
|
+
}
|
|
69565
|
+
__name(recordDaemonPromptDuration, "recordDaemonPromptDuration");
|
|
69566
|
+
function recordDaemonBridgeError(err) {
|
|
69567
|
+
if (!initialized) return;
|
|
69568
|
+
bridgeErrorCounter?.add(1, { error_type: normalizeErrorType(err) });
|
|
69569
|
+
}
|
|
69570
|
+
__name(recordDaemonBridgeError, "recordDaemonBridgeError");
|
|
69571
|
+
function recordDaemonCancel() {
|
|
69572
|
+
if (!initialized) return;
|
|
69573
|
+
cancelCounter?.add(1);
|
|
69574
|
+
}
|
|
69575
|
+
__name(recordDaemonCancel, "recordDaemonCancel");
|
|
69576
|
+
|
|
68807
69577
|
// packages/core/src/telemetry/index.ts
|
|
68808
69578
|
var TelemetryTarget = /* @__PURE__ */ ((TelemetryTarget2) => {
|
|
68809
69579
|
TelemetryTarget2["GCP"] = "gcp";
|
|
@@ -68906,8 +69676,8 @@ var LoggingContentGenerator = class {
|
|
|
68906
69676
|
);
|
|
68907
69677
|
}
|
|
68908
69678
|
_logApiError(responseId, durationMs, error, model, prompt_id) {
|
|
68909
|
-
const
|
|
68910
|
-
const
|
|
69679
|
+
const errorMessage2 = getErrorMessage(error);
|
|
69680
|
+
const errorType2 = getErrorType(error);
|
|
68911
69681
|
const errorResponseId = error?.requestID || error?.request_id || responseId;
|
|
68912
69682
|
const errorStatus = getErrorStatus(error);
|
|
68913
69683
|
logApiError(
|
|
@@ -68918,8 +69688,8 @@ var LoggingContentGenerator = class {
|
|
|
68918
69688
|
durationMs,
|
|
68919
69689
|
promptId: prompt_id,
|
|
68920
69690
|
authType: this.generatorAuthType,
|
|
68921
|
-
errorMessage,
|
|
68922
|
-
errorType,
|
|
69691
|
+
errorMessage: errorMessage2,
|
|
69692
|
+
errorType: errorType2,
|
|
68923
69693
|
statusCode: errorStatus,
|
|
68924
69694
|
subagentName: subagentNameContext.getStore()
|
|
68925
69695
|
})
|
|
@@ -69016,6 +69786,10 @@ var LoggingContentGenerator = class {
|
|
|
69016
69786
|
outputTokens: response.usageMetadata?.candidatesTokenCount,
|
|
69017
69787
|
cachedInputTokens: response.usageMetadata?.cachedContentTokenCount,
|
|
69018
69788
|
durationMs: Date.now() - startTime,
|
|
69789
|
+
responseId: response.responseId || void 0,
|
|
69790
|
+
finishReason: response.candidates?.[0]?.finishReason || void 0,
|
|
69791
|
+
thoughtsTokenCount: response.usageMetadata?.thoughtsTokenCount,
|
|
69792
|
+
subagentName: subagentNameContext.getStore() || void 0,
|
|
69019
69793
|
...retrySnapshot
|
|
69020
69794
|
});
|
|
69021
69795
|
return response;
|
|
@@ -69026,6 +69800,9 @@ var LoggingContentGenerator = class {
|
|
|
69026
69800
|
success: false,
|
|
69027
69801
|
durationMs,
|
|
69028
69802
|
error: aborted ? API_CALL_ABORTED_SPAN_STATUS_MESSAGE : API_CALL_FAILED_SPAN_STATUS_MESSAGE,
|
|
69803
|
+
errorType: getErrorType(error),
|
|
69804
|
+
errorStatusCode: getErrorStatus(error),
|
|
69805
|
+
subagentName: subagentNameContext.getStore() || void 0,
|
|
69029
69806
|
...retrySnapshot
|
|
69030
69807
|
});
|
|
69031
69808
|
await context.with(spanContext, async () => {
|
|
@@ -69096,6 +69873,9 @@ var LoggingContentGenerator = class {
|
|
|
69096
69873
|
success: false,
|
|
69097
69874
|
durationMs,
|
|
69098
69875
|
error: aborted ? API_CALL_ABORTED_SPAN_STATUS_MESSAGE : API_CALL_FAILED_SPAN_STATUS_MESSAGE,
|
|
69876
|
+
errorType: getErrorType(error),
|
|
69877
|
+
errorStatusCode: getErrorStatus(error),
|
|
69878
|
+
subagentName: subagentNameContext.getStore() || void 0,
|
|
69099
69879
|
...retrySnapshot
|
|
69100
69880
|
});
|
|
69101
69881
|
try {
|
|
@@ -69151,6 +69931,9 @@ var LoggingContentGenerator = class {
|
|
|
69151
69931
|
let firstModelVersion = "";
|
|
69152
69932
|
let lastUsageMetadata;
|
|
69153
69933
|
let errorOccurred = false;
|
|
69934
|
+
let lastFinishReason;
|
|
69935
|
+
let lastError;
|
|
69936
|
+
const subagentName = subagentNameContext.getStore();
|
|
69154
69937
|
let ttftMs;
|
|
69155
69938
|
let spanEndedByTimeout = false;
|
|
69156
69939
|
const runInSpan = /* @__PURE__ */ __name((fn) => spanContext ? context.with(spanContext, fn) : fn(), "runInSpan");
|
|
@@ -69168,6 +69951,8 @@ var LoggingContentGenerator = class {
|
|
|
69168
69951
|
success: false,
|
|
69169
69952
|
durationMs: Date.now() - startTime,
|
|
69170
69953
|
error: "Stream span timed out (idle)",
|
|
69954
|
+
responseId: firstResponseId || void 0,
|
|
69955
|
+
subagentName: subagentName || void 0,
|
|
69171
69956
|
...retrySnapshot
|
|
69172
69957
|
});
|
|
69173
69958
|
spanEndedByTimeout = true;
|
|
@@ -69189,6 +69974,10 @@ var LoggingContentGenerator = class {
|
|
|
69189
69974
|
if (response.usageMetadata) {
|
|
69190
69975
|
lastUsageMetadata = response.usageMetadata;
|
|
69191
69976
|
}
|
|
69977
|
+
const candidate = response.candidates?.[0];
|
|
69978
|
+
if (candidate?.finishReason) {
|
|
69979
|
+
lastFinishReason = candidate.finishReason;
|
|
69980
|
+
}
|
|
69192
69981
|
if (ttftMs === void 0 && hasUserVisibleContent(response)) {
|
|
69193
69982
|
ttftMs = Date.now() - startTime;
|
|
69194
69983
|
}
|
|
@@ -69227,6 +70016,7 @@ var LoggingContentGenerator = class {
|
|
|
69227
70016
|
}
|
|
69228
70017
|
} catch (error) {
|
|
69229
70018
|
errorOccurred = true;
|
|
70019
|
+
lastError = error;
|
|
69230
70020
|
if (!spanEndedByTimeout) {
|
|
69231
70021
|
const durationMs = Date.now() - startTime;
|
|
69232
70022
|
runInSpan(
|
|
@@ -69262,6 +70052,12 @@ var LoggingContentGenerator = class {
|
|
|
69262
70052
|
ttftMs,
|
|
69263
70053
|
durationMs: Date.now() - startTime,
|
|
69264
70054
|
error: errorOccurred ? aborted ? API_CALL_ABORTED_SPAN_STATUS_MESSAGE : API_CALL_FAILED_SPAN_STATUS_MESSAGE : void 0,
|
|
70055
|
+
responseId: firstResponseId || void 0,
|
|
70056
|
+
finishReason: lastFinishReason,
|
|
70057
|
+
thoughtsTokenCount: lastUsageMetadata?.thoughtsTokenCount,
|
|
70058
|
+
subagentName: subagentName || void 0,
|
|
70059
|
+
errorType: lastError ? getErrorType(lastError) : void 0,
|
|
70060
|
+
errorStatusCode: lastError ? getErrorStatus(lastError) : void 0,
|
|
69265
70061
|
...retrySnapshot
|
|
69266
70062
|
});
|
|
69267
70063
|
}
|
|
@@ -71061,11 +71857,11 @@ async function createContentGenerator(generatorConfig, config, isInitialAuth) {
|
|
|
71061
71857
|
let baseGenerator;
|
|
71062
71858
|
try {
|
|
71063
71859
|
if (authType === "openai" /* USE_OPENAI */) {
|
|
71064
|
-
const { createOpenAIContentGenerator } = await import("./openaiContentGenerator-
|
|
71860
|
+
const { createOpenAIContentGenerator } = await import("./openaiContentGenerator-L5KSWQY7.js");
|
|
71065
71861
|
baseGenerator = createOpenAIContentGenerator(generatorConfig, config);
|
|
71066
71862
|
} else if (authType === "qwen-oauth" /* QWEN_OAUTH */) {
|
|
71067
|
-
const { getQwenOAuthClient: getQwenOauthClient } = await import("./qwenOAuth2-
|
|
71068
|
-
const { QwenContentGenerator } = await import("./qwenContentGenerator-
|
|
71863
|
+
const { getQwenOAuthClient: getQwenOauthClient } = await import("./qwenOAuth2-2KCKWDCF.js");
|
|
71864
|
+
const { QwenContentGenerator } = await import("./qwenContentGenerator-PYOXLMBW.js");
|
|
71069
71865
|
try {
|
|
71070
71866
|
const qwenClient = await getQwenOauthClient(
|
|
71071
71867
|
config,
|
|
@@ -71083,10 +71879,10 @@ async function createContentGenerator(generatorConfig, config, isInitialAuth) {
|
|
|
71083
71879
|
throw new Error(error instanceof Error ? error.message : String(error));
|
|
71084
71880
|
}
|
|
71085
71881
|
} else if (authType === "anthropic" /* USE_ANTHROPIC */) {
|
|
71086
|
-
const { createAnthropicContentGenerator } = await import("./anthropicContentGenerator-
|
|
71882
|
+
const { createAnthropicContentGenerator } = await import("./anthropicContentGenerator-2HBRNQ3B.js");
|
|
71087
71883
|
baseGenerator = createAnthropicContentGenerator(generatorConfig, config);
|
|
71088
71884
|
} else if (authType === "gemini" /* USE_GEMINI */ || authType === "vertex-ai" /* USE_VERTEX_AI */) {
|
|
71089
|
-
const { createGeminiContentGenerator } = await import("./geminiContentGenerator-
|
|
71885
|
+
const { createGeminiContentGenerator } = await import("./geminiContentGenerator-7A6I2RWB.js");
|
|
71090
71886
|
baseGenerator = createGeminiContentGenerator(generatorConfig, config);
|
|
71091
71887
|
} else {
|
|
71092
71888
|
throw new Error(
|
|
@@ -71961,7 +72757,7 @@ function logStartSession(config, event) {
|
|
|
71961
72757
|
skills: event.skills,
|
|
71962
72758
|
subagents: event.subagents
|
|
71963
72759
|
};
|
|
71964
|
-
const logger =
|
|
72760
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
71965
72761
|
const logRecord = {
|
|
71966
72762
|
body: "CLI configuration loaded.",
|
|
71967
72763
|
attributes
|
|
@@ -71985,7 +72781,7 @@ function logUserPrompt(config, event) {
|
|
|
71985
72781
|
if (shouldLogUserPrompts(config)) {
|
|
71986
72782
|
attributes["prompt"] = event.prompt;
|
|
71987
72783
|
}
|
|
71988
|
-
const logger =
|
|
72784
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
71989
72785
|
const logRecord = {
|
|
71990
72786
|
body: `User prompt. Length: ${event.prompt_length}.`,
|
|
71991
72787
|
attributes
|
|
@@ -72002,7 +72798,7 @@ function logUserRetry(config, event) {
|
|
|
72002
72798
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString(),
|
|
72003
72799
|
prompt_id: event.prompt_id
|
|
72004
72800
|
};
|
|
72005
|
-
const logger =
|
|
72801
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72006
72802
|
const logRecord = {
|
|
72007
72803
|
body: `User retry.`,
|
|
72008
72804
|
attributes
|
|
@@ -72016,7 +72812,7 @@ function logToolCall(config, event) {
|
|
|
72016
72812
|
"event.name": EVENT_TOOL_CALL,
|
|
72017
72813
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72018
72814
|
};
|
|
72019
|
-
uiTelemetryService.addEvent(uiEvent);
|
|
72815
|
+
uiTelemetryService.addEvent(uiEvent, config.getSessionId());
|
|
72020
72816
|
if (!isInternalPromptId(event.prompt_id)) {
|
|
72021
72817
|
config.getChatRecordingService()?.recordUiTelemetryEvent(uiEvent);
|
|
72022
72818
|
}
|
|
@@ -72035,7 +72831,7 @@ function logToolCall(config, event) {
|
|
|
72035
72831
|
attributes["error.type"] = event.error_type;
|
|
72036
72832
|
}
|
|
72037
72833
|
}
|
|
72038
|
-
const logger =
|
|
72834
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72039
72835
|
const logRecord = {
|
|
72040
72836
|
body: `Tool call: ${event.function_name}${event.decision ? `. Decision: ${event.decision}` : ""}. Success: ${event.success}. Duration: ${event.duration_ms}ms.`,
|
|
72041
72837
|
attributes
|
|
@@ -72058,7 +72854,7 @@ function logToolOutputTruncated(config, event) {
|
|
|
72058
72854
|
"event.name": "tool_output_truncated",
|
|
72059
72855
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72060
72856
|
};
|
|
72061
|
-
const logger =
|
|
72857
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72062
72858
|
const logRecord = {
|
|
72063
72859
|
body: `Tool output truncated for ${event.tool_name}.`,
|
|
72064
72860
|
attributes
|
|
@@ -72088,7 +72884,7 @@ function logFileOperation(config, event) {
|
|
|
72088
72884
|
if (event.programming_language) {
|
|
72089
72885
|
attributes["programming_language"] = event.programming_language;
|
|
72090
72886
|
}
|
|
72091
|
-
const logger =
|
|
72887
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72092
72888
|
const logRecord = {
|
|
72093
72889
|
body: `File operation: ${event.operation}. Lines: ${event.lines}.`,
|
|
72094
72890
|
attributes
|
|
@@ -72111,7 +72907,7 @@ function logApiRequest(config, event) {
|
|
|
72111
72907
|
"event.name": EVENT_API_REQUEST,
|
|
72112
72908
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72113
72909
|
};
|
|
72114
|
-
const logger =
|
|
72910
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72115
72911
|
const logRecord = {
|
|
72116
72912
|
body: `API request to ${event.model}.`,
|
|
72117
72913
|
attributes
|
|
@@ -72128,7 +72924,7 @@ function logFlashFallback(config, event) {
|
|
|
72128
72924
|
"event.name": EVENT_FLASH_FALLBACK,
|
|
72129
72925
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72130
72926
|
};
|
|
72131
|
-
const logger =
|
|
72927
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72132
72928
|
const logRecord = {
|
|
72133
72929
|
body: `Switching to flash as Fallback.`,
|
|
72134
72930
|
attributes
|
|
@@ -72145,7 +72941,7 @@ function logRipgrepFallback(config, event) {
|
|
|
72145
72941
|
"event.name": EVENT_RIPGREP_FALLBACK,
|
|
72146
72942
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72147
72943
|
};
|
|
72148
|
-
const logger =
|
|
72944
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72149
72945
|
const logRecord = {
|
|
72150
72946
|
body: `Switching to grep as fallback.`,
|
|
72151
72947
|
attributes
|
|
@@ -72159,7 +72955,7 @@ function logApiError(config, event) {
|
|
|
72159
72955
|
"event.name": EVENT_API_ERROR,
|
|
72160
72956
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72161
72957
|
};
|
|
72162
|
-
uiTelemetryService.addEvent(uiEvent);
|
|
72958
|
+
uiTelemetryService.addEvent(uiEvent, config.getSessionId());
|
|
72163
72959
|
if (!isInternalPromptId(event.prompt_id)) {
|
|
72164
72960
|
config.getChatRecordingService()?.recordUiTelemetryEvent(uiEvent);
|
|
72165
72961
|
}
|
|
@@ -72180,7 +72976,7 @@ function logApiError(config, event) {
|
|
|
72180
72976
|
if (typeof event.status_code === "number") {
|
|
72181
72977
|
attributes[SemanticAttributes.HTTP_STATUS_CODE] = event.status_code;
|
|
72182
72978
|
}
|
|
72183
|
-
const logger =
|
|
72979
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72184
72980
|
const logRecord = {
|
|
72185
72981
|
body: `API error for ${event.model}. Error: ${event.error_message}. Duration: ${event.duration_ms}ms.`,
|
|
72186
72982
|
attributes
|
|
@@ -72199,7 +72995,7 @@ function logApiCancel(config, event) {
|
|
|
72199
72995
|
"event.name": EVENT_API_CANCEL,
|
|
72200
72996
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72201
72997
|
};
|
|
72202
|
-
uiTelemetryService.addEvent(uiEvent);
|
|
72998
|
+
uiTelemetryService.addEvent(uiEvent, config.getSessionId());
|
|
72203
72999
|
QwenLogger.getInstance(config)?.logApiCancelEvent(event);
|
|
72204
73000
|
if (!isTelemetrySdkInitialized()) return;
|
|
72205
73001
|
const attributes = {
|
|
@@ -72209,7 +73005,7 @@ function logApiCancel(config, event) {
|
|
|
72209
73005
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString(),
|
|
72210
73006
|
model_name: event.model
|
|
72211
73007
|
};
|
|
72212
|
-
const logger =
|
|
73008
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72213
73009
|
const logRecord = {
|
|
72214
73010
|
body: `API request cancelled for ${event.model}.`,
|
|
72215
73011
|
attributes
|
|
@@ -72223,7 +73019,7 @@ function logApiResponse(config, event) {
|
|
|
72223
73019
|
"event.name": EVENT_API_RESPONSE,
|
|
72224
73020
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72225
73021
|
};
|
|
72226
|
-
uiTelemetryService.addEvent(uiEvent);
|
|
73022
|
+
uiTelemetryService.addEvent(uiEvent, config.getSessionId());
|
|
72227
73023
|
if (!isInternalPromptId(event.prompt_id)) {
|
|
72228
73024
|
config.getChatRecordingService()?.recordUiTelemetryEvent(uiEvent);
|
|
72229
73025
|
}
|
|
@@ -72243,7 +73039,7 @@ function logApiResponse(config, event) {
|
|
|
72243
73039
|
attributes[SemanticAttributes.HTTP_STATUS_CODE] = event.status_code;
|
|
72244
73040
|
}
|
|
72245
73041
|
}
|
|
72246
|
-
const logger =
|
|
73042
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72247
73043
|
const logRecord = {
|
|
72248
73044
|
body: `API response from ${event.model}. Status: ${event.status_code || "N/A"}. Duration: ${event.duration_ms}ms.`,
|
|
72249
73045
|
attributes
|
|
@@ -72278,7 +73074,7 @@ function logLoopDetected(config, event) {
|
|
|
72278
73074
|
...getCommonAttributes(config),
|
|
72279
73075
|
...event
|
|
72280
73076
|
};
|
|
72281
|
-
const logger =
|
|
73077
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72282
73078
|
const logRecord = {
|
|
72283
73079
|
body: `Loop detected. Type: ${event.loop_type}.`,
|
|
72284
73080
|
attributes
|
|
@@ -72298,7 +73094,7 @@ function logNextSpeakerCheck(config, event) {
|
|
|
72298
73094
|
...event,
|
|
72299
73095
|
"event.name": EVENT_NEXT_SPEAKER_CHECK
|
|
72300
73096
|
};
|
|
72301
|
-
const logger =
|
|
73097
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72302
73098
|
const logRecord = {
|
|
72303
73099
|
body: `Next speaker check.`,
|
|
72304
73100
|
attributes
|
|
@@ -72314,7 +73110,7 @@ function logSlashCommand(config, event) {
|
|
|
72314
73110
|
...event,
|
|
72315
73111
|
"event.name": EVENT_SLASH_COMMAND
|
|
72316
73112
|
};
|
|
72317
|
-
const logger =
|
|
73113
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72318
73114
|
const logRecord = {
|
|
72319
73115
|
body: `Slash command: ${event.command}.`,
|
|
72320
73116
|
attributes
|
|
@@ -72330,7 +73126,7 @@ function logIdeConnection(config, event) {
|
|
|
72330
73126
|
...event,
|
|
72331
73127
|
"event.name": EVENT_IDE_CONNECTION
|
|
72332
73128
|
};
|
|
72333
|
-
const logger =
|
|
73129
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72334
73130
|
const logRecord = {
|
|
72335
73131
|
body: `Ide connection. Type: ${event.connection_type}.`,
|
|
72336
73132
|
attributes
|
|
@@ -72346,7 +73142,7 @@ function logConversationFinishedEvent(config, event) {
|
|
|
72346
73142
|
...event,
|
|
72347
73143
|
"event.name": EVENT_CONVERSATION_FINISHED
|
|
72348
73144
|
};
|
|
72349
|
-
const logger =
|
|
73145
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72350
73146
|
const logRecord = {
|
|
72351
73147
|
body: `Conversation finished.`,
|
|
72352
73148
|
attributes
|
|
@@ -72361,7 +73157,7 @@ function logChatCompression(config, event) {
|
|
|
72361
73157
|
...event,
|
|
72362
73158
|
"event.name": EVENT_CHAT_COMPRESSION
|
|
72363
73159
|
};
|
|
72364
|
-
const logger =
|
|
73160
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72365
73161
|
const logRecord = {
|
|
72366
73162
|
body: `Chat compression (Saved ${event.tokens_before - event.tokens_after} tokens)`,
|
|
72367
73163
|
attributes
|
|
@@ -72380,7 +73176,7 @@ function logKittySequenceOverflow(config, event) {
|
|
|
72380
73176
|
...getCommonAttributes(config),
|
|
72381
73177
|
...event
|
|
72382
73178
|
};
|
|
72383
|
-
const logger =
|
|
73179
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72384
73180
|
const logRecord = {
|
|
72385
73181
|
body: `Kitty sequence buffer overflow: ${event.sequence_length} bytes`,
|
|
72386
73182
|
attributes
|
|
@@ -72396,7 +73192,7 @@ function logContentRetry(config, event) {
|
|
|
72396
73192
|
...event,
|
|
72397
73193
|
"event.name": EVENT_CONTENT_RETRY
|
|
72398
73194
|
};
|
|
72399
|
-
const logger =
|
|
73195
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72400
73196
|
const logRecord = {
|
|
72401
73197
|
body: `Content retry attempt ${event.attempt_number} due to ${event.error_type}.`,
|
|
72402
73198
|
attributes
|
|
@@ -72413,7 +73209,7 @@ function logContentRetryFailure(config, event) {
|
|
|
72413
73209
|
...event,
|
|
72414
73210
|
"event.name": EVENT_CONTENT_RETRY_FAILURE
|
|
72415
73211
|
};
|
|
72416
|
-
const logger =
|
|
73212
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72417
73213
|
const logRecord = {
|
|
72418
73214
|
body: `All content retries failed after ${event.total_attempts} attempts.`,
|
|
72419
73215
|
attributes
|
|
@@ -72430,7 +73226,7 @@ function logApiRetry(config, event) {
|
|
|
72430
73226
|
...event,
|
|
72431
73227
|
"event.name": EVENT_API_RETRY
|
|
72432
73228
|
};
|
|
72433
|
-
const logger =
|
|
73229
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72434
73230
|
const logRecord = {
|
|
72435
73231
|
body: `API retry attempt ${event.attempt_number} for ${event.model} (status ${event.status_code ?? "unknown"}).`,
|
|
72436
73232
|
attributes
|
|
@@ -72448,7 +73244,7 @@ function logSubagentExecution(config, event) {
|
|
|
72448
73244
|
"event.name": EVENT_SUBAGENT_EXECUTION,
|
|
72449
73245
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72450
73246
|
};
|
|
72451
|
-
const logger =
|
|
73247
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72452
73248
|
const logRecord = {
|
|
72453
73249
|
body: `Subagent execution: ${event.subagent_name}.`,
|
|
72454
73250
|
attributes
|
|
@@ -72470,7 +73266,7 @@ function logModelSlashCommand(config, event) {
|
|
|
72470
73266
|
...event,
|
|
72471
73267
|
"event.name": EVENT_MODEL_SLASH_COMMAND
|
|
72472
73268
|
};
|
|
72473
|
-
const logger =
|
|
73269
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72474
73270
|
const logRecord = {
|
|
72475
73271
|
body: `Model slash command. Model: ${event.model_name}`,
|
|
72476
73272
|
attributes
|
|
@@ -72496,7 +73292,7 @@ function logExtensionInstallEvent(config, event) {
|
|
|
72496
73292
|
extension_source: event.extension_source,
|
|
72497
73293
|
status: event.status
|
|
72498
73294
|
};
|
|
72499
|
-
const logger =
|
|
73295
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72500
73296
|
const logRecord = {
|
|
72501
73297
|
body: `Installed extension ${event.extension_name}`,
|
|
72502
73298
|
attributes
|
|
@@ -72513,7 +73309,7 @@ function logExtensionUninstall(config, event) {
|
|
|
72513
73309
|
"event.name": EVENT_EXTENSION_UNINSTALL,
|
|
72514
73310
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72515
73311
|
};
|
|
72516
|
-
const logger =
|
|
73312
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72517
73313
|
const logRecord = {
|
|
72518
73314
|
body: `Uninstalled extension ${event.extension_name}`,
|
|
72519
73315
|
attributes
|
|
@@ -72534,7 +73330,7 @@ async function logExtensionUpdateEvent(config, event) {
|
|
|
72534
73330
|
extension_version: event.extension_version,
|
|
72535
73331
|
extension_source: event.extension_source
|
|
72536
73332
|
};
|
|
72537
|
-
const logger =
|
|
73333
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72538
73334
|
const logRecord = {
|
|
72539
73335
|
body: `Updated extension ${event.extension_name} from ${event.extension_previous_version} to ${event.extension_version}`,
|
|
72540
73336
|
attributes
|
|
@@ -72551,7 +73347,7 @@ function logExtensionEnable(config, event) {
|
|
|
72551
73347
|
"event.name": EVENT_EXTENSION_ENABLE,
|
|
72552
73348
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72553
73349
|
};
|
|
72554
|
-
const logger =
|
|
73350
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72555
73351
|
const logRecord = {
|
|
72556
73352
|
body: `Enabled extension ${event.extension_name}`,
|
|
72557
73353
|
attributes
|
|
@@ -72568,7 +73364,7 @@ function logExtensionDisable(config, event) {
|
|
|
72568
73364
|
"event.name": EVENT_EXTENSION_DISABLE,
|
|
72569
73365
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72570
73366
|
};
|
|
72571
|
-
const logger =
|
|
73367
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72572
73368
|
const logRecord = {
|
|
72573
73369
|
body: `Disabled extension ${event.extension_name}`,
|
|
72574
73370
|
attributes
|
|
@@ -72591,7 +73387,7 @@ function logAuth(config, event) {
|
|
|
72591
73387
|
if (event.error_message) {
|
|
72592
73388
|
attributes["error.message"] = event.error_message;
|
|
72593
73389
|
}
|
|
72594
|
-
const logger =
|
|
73390
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72595
73391
|
const logRecord = {
|
|
72596
73392
|
body: `Auth event: ${event.action_type} ${event.status} for ${event.auth_type}`,
|
|
72597
73393
|
attributes
|
|
@@ -72608,7 +73404,7 @@ function logSkillLaunch(config, event) {
|
|
|
72608
73404
|
"event.name": EVENT_SKILL_LAUNCH,
|
|
72609
73405
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72610
73406
|
};
|
|
72611
|
-
const logger =
|
|
73407
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72612
73408
|
const logRecord = {
|
|
72613
73409
|
body: `Skill launch: ${event.skill_name}. Success: ${event.success}.`,
|
|
72614
73410
|
attributes
|
|
@@ -72622,7 +73418,7 @@ function logUserFeedback(config, event) {
|
|
|
72622
73418
|
"event.name": EVENT_USER_FEEDBACK,
|
|
72623
73419
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72624
73420
|
};
|
|
72625
|
-
uiTelemetryService.addEvent(uiEvent);
|
|
73421
|
+
uiTelemetryService.addEvent(uiEvent, config.getSessionId());
|
|
72626
73422
|
config.getChatRecordingService()?.recordUiTelemetryEvent(uiEvent);
|
|
72627
73423
|
QwenLogger.getInstance(config)?.logUserFeedbackEvent(event);
|
|
72628
73424
|
if (!isTelemetrySdkInitialized()) return;
|
|
@@ -72632,7 +73428,7 @@ function logUserFeedback(config, event) {
|
|
|
72632
73428
|
"event.name": EVENT_USER_FEEDBACK,
|
|
72633
73429
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72634
73430
|
};
|
|
72635
|
-
const logger =
|
|
73431
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72636
73432
|
const logRecord = {
|
|
72637
73433
|
body: `User feedback: Rating ${event.rating} for session ${event.session_id}.`,
|
|
72638
73434
|
attributes
|
|
@@ -72650,7 +73446,7 @@ function logArenaSessionStarted(config, event) {
|
|
|
72650
73446
|
"event.name": EVENT_ARENA_SESSION_STARTED,
|
|
72651
73447
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72652
73448
|
};
|
|
72653
|
-
const logger =
|
|
73449
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72654
73450
|
const logRecord = {
|
|
72655
73451
|
body: `Arena session started. Agents: ${event.model_ids.length}.`,
|
|
72656
73452
|
attributes
|
|
@@ -72668,7 +73464,7 @@ function logArenaAgentCompleted(config, event) {
|
|
|
72668
73464
|
"event.name": EVENT_ARENA_AGENT_COMPLETED,
|
|
72669
73465
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72670
73466
|
};
|
|
72671
|
-
const logger =
|
|
73467
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72672
73468
|
const logRecord = {
|
|
72673
73469
|
body: `Arena agent ${event.agent_model_id} ${event.status}. Duration: ${event.duration_ms}ms. Tokens: ${event.total_tokens}.`,
|
|
72674
73470
|
attributes
|
|
@@ -72693,7 +73489,7 @@ function logArenaSessionEnded(config, event) {
|
|
|
72693
73489
|
"event.name": EVENT_ARENA_SESSION_ENDED,
|
|
72694
73490
|
"event.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
72695
73491
|
};
|
|
72696
|
-
const logger =
|
|
73492
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72697
73493
|
const logRecord = {
|
|
72698
73494
|
body: `Arena session ended: ${event.status}.${event.winner_model_id ? ` Winner: ${event.winner_model_id}.` : ""}`,
|
|
72699
73495
|
attributes
|
|
@@ -72743,7 +73539,7 @@ function logPromptSuggestion(config, event) {
|
|
|
72743
73539
|
if (event.reason) {
|
|
72744
73540
|
attributes["reason"] = event.reason;
|
|
72745
73541
|
}
|
|
72746
|
-
const logger =
|
|
73542
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72747
73543
|
const logRecord = {
|
|
72748
73544
|
body: `Prompt suggestion: ${event.outcome}.`,
|
|
72749
73545
|
attributes
|
|
@@ -72767,7 +73563,7 @@ function logSpeculation(config, event) {
|
|
|
72767
73563
|
if (event.boundary_type) {
|
|
72768
73564
|
attributes["boundary_type"] = event.boundary_type;
|
|
72769
73565
|
}
|
|
72770
|
-
const logger =
|
|
73566
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72771
73567
|
const logRecord = {
|
|
72772
73568
|
body: `Speculation: ${event.outcome}.`,
|
|
72773
73569
|
attributes
|
|
@@ -72790,7 +73586,7 @@ function logMemoryExtract(config, event) {
|
|
|
72790
73586
|
if (event.skipped_reason) {
|
|
72791
73587
|
attributes["skipped_reason"] = event.skipped_reason;
|
|
72792
73588
|
}
|
|
72793
|
-
const logger =
|
|
73589
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72794
73590
|
logger.emit({
|
|
72795
73591
|
body: `Memory extract: ${event.status}. Patches: ${event.patches_count}. Topics: ${event.touched_topics || "none"}.`,
|
|
72796
73592
|
attributes
|
|
@@ -72815,7 +73611,7 @@ function logMemoryDream(config, event) {
|
|
|
72815
73611
|
touched_topics: event.touched_topics,
|
|
72816
73612
|
duration_ms: event.duration_ms
|
|
72817
73613
|
};
|
|
72818
|
-
const logger =
|
|
73614
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72819
73615
|
logger.emit({
|
|
72820
73616
|
body: `Memory dream: ${event.status}. Deduped: ${event.deduped_entries}. Topics: ${event.touched_topics || "none"}.`,
|
|
72821
73617
|
attributes
|
|
@@ -72839,7 +73635,7 @@ function logMemoryRecall(config, event) {
|
|
|
72839
73635
|
strategy: event.strategy,
|
|
72840
73636
|
duration_ms: event.duration_ms
|
|
72841
73637
|
};
|
|
72842
|
-
const logger =
|
|
73638
|
+
const logger = import_api_logs2.logs.getLogger(SERVICE_NAME);
|
|
72843
73639
|
logger.emit({
|
|
72844
73640
|
body: `Memory recall: strategy=${event.strategy}. Selected ${event.docs_selected}/${event.docs_scanned} docs.`,
|
|
72845
73641
|
attributes
|
|
@@ -73100,6 +73896,13 @@ var ReadFileTool = class _ReadFileTool extends BaseDeclarativeTool {
|
|
|
73100
73896
|
__name(this, "ReadFileTool");
|
|
73101
73897
|
}
|
|
73102
73898
|
static Name = ToolNames.READ_FILE;
|
|
73899
|
+
// Self-managed: ReadFile controls its own size via line-based paging
|
|
73900
|
+
// (offset/limit, default 2000 lines), so it is exempt from the scheduler's
|
|
73901
|
+
// char-based truncation. Oversized reads are bounded by the per-message
|
|
73902
|
+
// batch budget instead.
|
|
73903
|
+
get maxOutputChars() {
|
|
73904
|
+
return Number.POSITIVE_INFINITY;
|
|
73905
|
+
}
|
|
73103
73906
|
validateToolParamValues(params) {
|
|
73104
73907
|
const filePath = unescapePath(params.file_path.trim());
|
|
73105
73908
|
params.file_path = filePath;
|
|
@@ -73258,6 +74061,7 @@ export {
|
|
|
73258
74061
|
truncateSpanError,
|
|
73259
74062
|
startInteractionSpan,
|
|
73260
74063
|
endInteractionSpan,
|
|
74064
|
+
withInteractionSpan,
|
|
73261
74065
|
startLLMRequestSpan,
|
|
73262
74066
|
endLLMRequestSpan,
|
|
73263
74067
|
startToolSpan,
|
|
@@ -73278,6 +74082,7 @@ export {
|
|
|
73278
74082
|
initializeTelemetry,
|
|
73279
74083
|
refreshSessionContext,
|
|
73280
74084
|
shutdownTelemetry,
|
|
74085
|
+
forceFlushMetrics,
|
|
73281
74086
|
logStartSession,
|
|
73282
74087
|
logUserPrompt,
|
|
73283
74088
|
logUserRetry,
|
|
@@ -73323,7 +74128,9 @@ export {
|
|
|
73323
74128
|
memoryAge,
|
|
73324
74129
|
memoryFreshnessText,
|
|
73325
74130
|
ReadFileTool,
|
|
74131
|
+
TOOL_OUTPUT_TRUNCATED_PREFIX,
|
|
73326
74132
|
truncateToolOutput,
|
|
74133
|
+
truncateLlmContent,
|
|
73327
74134
|
DiscoveredMCPTool,
|
|
73328
74135
|
generateValidName,
|
|
73329
74136
|
StartSessionEvent,
|
|
@@ -73382,6 +74189,30 @@ export {
|
|
|
73382
74189
|
parseBooleanEnvFlag,
|
|
73383
74190
|
parseTelemetryTargetValue,
|
|
73384
74191
|
resolveTelemetrySettings,
|
|
74192
|
+
DAEMON_TRACEPARENT_META_KEY,
|
|
74193
|
+
DAEMON_TRACESTATE_META_KEY,
|
|
74194
|
+
hashDaemonWorkspace,
|
|
74195
|
+
withDaemonSpan,
|
|
74196
|
+
withDaemonRequestSpan,
|
|
74197
|
+
withDaemonBridgeSpan,
|
|
74198
|
+
recordDaemonHttpResponse,
|
|
74199
|
+
addDaemonRequestAttribute,
|
|
74200
|
+
recordDaemonError,
|
|
74201
|
+
emitDaemonLog,
|
|
74202
|
+
captureDaemonTelemetryContext,
|
|
74203
|
+
runWithDaemonTelemetryContext,
|
|
74204
|
+
injectDaemonTraceContext,
|
|
74205
|
+
extractDaemonTraceContext,
|
|
74206
|
+
createDaemonBridgeTelemetry,
|
|
74207
|
+
initializeDaemonMetrics,
|
|
74208
|
+
registerDaemonGaugeCallbacks,
|
|
74209
|
+
recordDaemonHttpRequest,
|
|
74210
|
+
recordDaemonSessionLifecycle,
|
|
74211
|
+
recordDaemonChannelLifecycle,
|
|
74212
|
+
recordDaemonPromptQueueWait,
|
|
74213
|
+
recordDaemonPromptDuration,
|
|
74214
|
+
recordDaemonBridgeError,
|
|
74215
|
+
recordDaemonCancel,
|
|
73385
74216
|
TelemetryTarget,
|
|
73386
74217
|
DEFAULT_TELEMETRY_TARGET,
|
|
73387
74218
|
DEFAULT_OTLP_ENDPOINT,
|