@qwen-code/qwen-code 0.18.0-preview.2 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled/loop/SKILL.md +2 -1
- package/bundled/qc-helper/docs/_meta.ts +1 -0
- package/bundled/qc-helper/docs/configuration/auth.md +1 -1
- package/bundled/qc-helper/docs/configuration/model-providers.md +12 -5
- package/bundled/qc-helper/docs/configuration/settings.md +33 -32
- 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/dual-output.md +37 -3
- package/bundled/qc-helper/docs/features/followup-suggestions.md +2 -2
- package/bundled/qc-helper/docs/features/skills.md +29 -3
- package/bundled/qc-helper/docs/features/sub-agents.md +34 -12
- package/bundled/qc-helper/docs/qwen-serve-deploy-local.md +221 -0
- package/bundled/qc-helper/docs/qwen-serve.md +246 -28
- package/chunks/{agent-QB7TZ4HW.js → agent-XT7NHZ5H.js} +25 -24
- package/chunks/agent-headless-LNRE63ZL.js +51 -0
- package/chunks/{anthropicContentGenerator-M45EVVRM.js → anthropicContentGenerator-DCI26OQF.js} +7 -7
- package/chunks/{askUserQuestion-WM2KHM3K.js → askUserQuestion-ITYUTWLR.js} +45 -3
- package/chunks/{ca-BARBRL6N.js → ca-RK4QPLIX.js} +18 -1
- package/chunks/{chunk-CWV3SJZS.js → chunk-3NRO6NHX.js} +2 -2
- package/chunks/{chunk-BNESGOSJ.js → chunk-55ZMG67I.js} +1 -1
- package/chunks/{chunk-QCG6KPNM.js → chunk-6T7Y7USE.js} +18017 -11621
- package/chunks/{chunk-CNHFPN7T.js → chunk-7KPZFE5A.js} +1 -1
- package/chunks/{chunk-2ZTWI7KH.js → chunk-A2ZIEEGJ.js} +30 -22
- package/chunks/{chunk-JUGRPQAB.js → chunk-B4ZF2KSI.js} +1 -1
- package/chunks/chunk-BJ5HQ23U.js +178 -0
- package/chunks/{chunk-HXJE7VOG.js → chunk-BXYRCW2C.js} +1074 -144
- package/chunks/{chunk-ICOI4E4S.js → chunk-CPVI5J2L.js} +101 -23
- package/chunks/{chunk-HV3ZZ7G4.js → chunk-DHZREJTG.js} +2 -2
- package/chunks/{chunk-GX7VH5JQ.js → chunk-FIQECJTQ.js} +1 -1
- package/chunks/{chunk-SZOEIL6S.js → chunk-H6BD2ELD.js} +1 -0
- package/chunks/{chunk-JXAZUMDW.js → chunk-HA2UEYZP.js} +7 -4
- package/chunks/{chunk-USE2VQ5P.js → chunk-HED55F43.js} +26 -1
- package/chunks/{chunk-PAEBHDIO.js → chunk-HQUWWSSP.js} +1 -1
- package/chunks/{chunk-MVIVIPCU.js → chunk-IDYDPBBN.js} +361 -583
- package/chunks/{chunk-JVQOQ3OU.js → chunk-IQHSD7K5.js} +1 -1
- package/chunks/{chunk-NW5QBUYO.js → chunk-IS7UA4W3.js} +14 -14
- package/chunks/{chunk-UAMOBVVW.js → chunk-LXYWINWF.js} +1 -1
- package/chunks/{chunk-P4J26VDS.js → chunk-LYRSMKLS.js} +2 -2
- package/chunks/{chunk-Y7R6H6FT.js → chunk-LYSND7KR.js} +9 -4
- package/chunks/{chunk-LR62TEET.js → chunk-NNIYWQIS.js} +1 -1
- package/chunks/chunk-OMX7CUOE.js +356 -0
- package/chunks/{chunk-CNSMKPK6.js → chunk-QILTEBWS.js} +1 -1
- package/chunks/chunk-QQDPRDVW.js +25 -0
- package/chunks/{chunk-ZK4AMNIU.js → chunk-RON7LFNH.js} +1294 -314
- package/chunks/chunk-SFRV6BGY.js +243 -0
- package/chunks/{chunk-AVW55ZCO.js → chunk-WJ3SND6W.js} +37 -16
- package/chunks/{chunk-HGJPQK33.js → chunk-WPTCDQN6.js} +188 -534
- package/chunks/{chunk-7YKXFA3D.js → chunk-XZTNBSMW.js} +11 -11
- package/chunks/{chunk-C6WMLUNB.js → chunk-Y7KMDUEP.js} +1 -1
- package/chunks/{chunk-WFVXF3OM.js → chunk-Z2Z3GUXZ.js} +1 -0
- package/chunks/{chunk-KC6ZMJ5X.js → chunk-ZMIBJS45.js} +1 -1
- package/chunks/chunk-ZOFNJQNJ.js +607 -0
- package/chunks/computer-use-4YX3JGBV.js +2052 -0
- package/chunks/contextCommand-KS2H7MW5.js +53 -0
- package/chunks/cron-create-CAPUKK7I.js +184 -0
- package/chunks/{cron-delete-ZGUXWBTG.js → cron-delete-G3KAR26Q.js} +28 -5
- package/chunks/{cron-list-QNNZGMN3.js → cron-list-ZA4ZIUS5.js} +40 -7
- package/chunks/{de-YGKK2BC4.js → de-FGPM4KW5.js} +18 -1
- package/chunks/{devtools-IXE4UP72.js → devtools-FM6GJPYG.js} +1 -1
- package/chunks/{dist-ZMQ4TXD5.js → dist-7YWFWOCJ.js} +2 -2
- package/chunks/{dist-R2SXPG74.js → dist-VEGFONCF.js} +2 -2
- package/chunks/{dist-TE5QKMGR.js → dist-X4EXN7W6.js} +1 -1
- package/chunks/{dist-BXDUQ2QY.js → dist-YLS6NI7H.js} +1 -1
- package/chunks/{edit-6UBTS2J5.js → edit-2ARPEO4B.js} +26 -25
- package/chunks/{en-HSQQNQUB.js → en-VP6XPGEC.js} +9 -2
- package/chunks/{enter-worktree-NN7LIXCM.js → enter-worktree-IXNXNAW5.js} +25 -24
- package/chunks/enterPlanMode-TAKAGAYP.js +159 -0
- package/chunks/{exit-worktree-GGSS5KIE.js → exit-worktree-LHTRV7ML.js} +25 -24
- package/chunks/exitPlanMode-MK5UAITL.js +743 -0
- package/chunks/{fr-JXBKPJKQ.js → fr-ATYBVCLT.js} +18 -1
- package/chunks/{geminiContentGenerator-I4H2NLJG.js → geminiContentGenerator-HFJIGO77.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-I2USLUSC.js} +25 -24
- package/chunks/{grep-7HXIMDOW.js → grep-WBIF7THR.js} +37 -30
- package/chunks/{ja-TGPZSP2B.js → ja-W2QEA2OI.js} +18 -1
- package/chunks/{keychain-token-storage-LB46DAEK.js → keychain-token-storage-QSTRHKKL.js} +3 -3
- package/chunks/{ls-6PEZUK6O.js → ls-2R5RHLX5.js} +4 -4
- package/chunks/{lsp-JZSJOVT7.js → lsp-XKH6ZIAN.js} +3 -3
- package/chunks/{monitor-SQO7MVAV.js → monitor-WU7UFATU.js} +25 -24
- package/chunks/{notebook-edit-72L3EBAL.js → notebook-edit-KUHYPXEM.js} +26 -25
- package/chunks/{openaiContentGenerator-FTR7CDWF.js → openaiContentGenerator-5PLHYJQL.js} +15 -15
- package/chunks/{pt-TIBG6BIO.js → pt-ZKEWJFBW.js} +18 -1
- package/chunks/{qwenContentGenerator-U5UFQ566.js → qwenContentGenerator-TSKW73KY.js} +27 -26
- package/chunks/{qwenOAuth2-EFSECGHF.js → qwenOAuth2-KK433U33.js} +6 -5
- package/chunks/{read-file-UA64EEQC.js → read-file-VIPF2PS6.js} +11 -11
- package/chunks/ripGrep-XLIZTYE7.js +49 -0
- package/chunks/{ru-JBCHCK4L.js → ru-VEKTPJ74.js} +18 -1
- package/chunks/{scheduler-VBASHOCA.js → scheduler-O66SLJGU.js} +25 -24
- package/chunks/{send-message-OYJZ5TPG.js → send-message-CTME7DXD.js} +3 -3
- package/chunks/{serve-A7E2OJDR.js → serve-BWOLYT62.js} +13164 -3840
- package/chunks/{shell-3NFOT6F5.js → shell-XE7UYKOO.js} +25 -24
- package/chunks/{skill-RA5YUREY.js → skill-RZWM6XMC.js} +64 -113
- package/chunks/{src-NFCMARMT.js → src-L5P7K4MH.js} +176 -44
- package/chunks/{syntheticOutput-DETQ2YM6.js → syntheticOutput-ZJGSU7OQ.js} +4 -4
- package/chunks/{task-create-Y3ZKTJIG.js → task-create-EE6JEM7G.js} +8 -7
- package/chunks/{task-list-ONXJ3I3A.js → task-list-EESYAC65.js} +7 -6
- package/chunks/{task-stop-UHDC4N5B.js → task-stop-XZVCFFYY.js} +3 -3
- package/chunks/{task-update-TCNOU3P5.js → task-update-EIO4HNE3.js} +21 -9
- package/chunks/{team-create-6SR4OVRG.js → team-create-R2H7Y3SG.js} +28 -26
- package/chunks/{team-delete-EJ4U4DDP.js → team-delete-A7LXPGV7.js} +9 -6
- package/chunks/{todoWrite-TEYDRS5L.js → todoWrite-VRKSGAWM.js} +5 -5
- package/chunks/{tool-search-OD435A3X.js → tool-search-USSQMTMS.js} +11 -11
- package/chunks/{web-fetch-6W67H5PO.js → web-fetch-GHAZUA54.js} +5 -5
- package/chunks/workflow-5LNNLNUR.js +1414 -0
- package/chunks/{write-file-475L5OPP.js → write-file-2I7HP24C.js} +26 -25
- package/chunks/{zh-VCLWO26Y.js → zh-OIXDDQHB.js} +10 -3
- package/chunks/{zh-TW-G3HFHVVT.js → zh-TW-6YFNCKTA.js} +10 -3
- package/cli-entry.js +19 -0
- package/cli.js +11064 -6628
- 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/ca.js +20 -2
- package/locales/de.js +21 -2
- package/locales/en.js +13 -4
- package/locales/fr.js +22 -2
- package/locales/ja.js +22 -2
- package/locales/pt.js +21 -2
- package/locales/ru.js +20 -2
- package/locales/zh-TW.js +11 -4
- package/locales/zh.js +11 -4
- package/package.json +5 -3
- package/chunks/agent-headless-APVHH7QM.js +0 -50
- package/chunks/chunk-AJIR24J2.js +0 -59
- package/chunks/chunk-SKBPNJEW.js +0 -45
- package/chunks/chunk-XBFVXFB2.js +0 -216
- package/chunks/computer-use-B7VIUI7F.js +0 -825
- package/chunks/contextCommand-63RZ3O5R.js +0 -52
- package/chunks/cron-create-FI5LJVUS.js +0 -140
- package/chunks/exitPlanMode-H323NHB2.js +0 -235
- package/chunks/ripGrep-WSYCWZVK.js +0 -48
- package/chunks/workflow-62DHH4EO.js +0 -708
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import {
|
|
4
|
+
getInboxesDir,
|
|
5
|
+
require_proper_lockfile
|
|
6
|
+
} from "./chunk-WPTCDQN6.js";
|
|
7
|
+
import {
|
|
8
|
+
Mutex
|
|
9
|
+
} from "./chunk-OMX7CUOE.js";
|
|
10
|
+
import {
|
|
11
|
+
atomicWriteJSON
|
|
12
|
+
} from "./chunk-LXYWINWF.js";
|
|
13
|
+
import {
|
|
14
|
+
createDebugLogger,
|
|
15
|
+
isNodeError
|
|
16
|
+
} from "./chunk-HA2UEYZP.js";
|
|
17
|
+
import {
|
|
18
|
+
init_esbuild_shims
|
|
19
|
+
} from "./chunk-A4BMJM77.js";
|
|
20
|
+
import {
|
|
21
|
+
__name,
|
|
22
|
+
__toESM
|
|
23
|
+
} from "./chunk-J2S4EL5Y.js";
|
|
24
|
+
|
|
25
|
+
// packages/core/src/agents/team/leaderPermissionBridge.ts
|
|
26
|
+
init_esbuild_shims();
|
|
27
|
+
var leaderCallbacks = null;
|
|
28
|
+
function registerLeader(callbacks) {
|
|
29
|
+
leaderCallbacks = callbacks;
|
|
30
|
+
}
|
|
31
|
+
__name(registerLeader, "registerLeader");
|
|
32
|
+
function getLeader() {
|
|
33
|
+
return leaderCallbacks;
|
|
34
|
+
}
|
|
35
|
+
__name(getLeader, "getLeader");
|
|
36
|
+
function unregisterLeader() {
|
|
37
|
+
leaderCallbacks = null;
|
|
38
|
+
}
|
|
39
|
+
__name(unregisterLeader, "unregisterLeader");
|
|
40
|
+
function forwardApproval(teammateName, teammateColor, details) {
|
|
41
|
+
if (!leaderCallbacks) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
leaderCallbacks.enqueueApproval({
|
|
45
|
+
teammateName,
|
|
46
|
+
teammateColor,
|
|
47
|
+
details
|
|
48
|
+
});
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
__name(forwardApproval, "forwardApproval");
|
|
52
|
+
function wrapConfirmWithBadge(original, teammateName, respond, _teammateColor) {
|
|
53
|
+
return {
|
|
54
|
+
...original,
|
|
55
|
+
title: `[${teammateName}] ${original.title}`,
|
|
56
|
+
onConfirm: /* @__PURE__ */ __name(async (outcome, payload) => {
|
|
57
|
+
await respond(outcome, payload);
|
|
58
|
+
}, "onConfirm")
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
__name(wrapConfirmWithBadge, "wrapConfirmWithBadge");
|
|
62
|
+
|
|
63
|
+
// packages/core/src/agents/team/mailbox.ts
|
|
64
|
+
init_esbuild_shims();
|
|
65
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
66
|
+
import * as fs from "node:fs/promises";
|
|
67
|
+
import * as path from "node:path";
|
|
68
|
+
var debug = createDebugLogger("AGENTS_TEAM_MAILBOX");
|
|
69
|
+
var LOCK_OPTIONS = {
|
|
70
|
+
retries: {
|
|
71
|
+
retries: 10,
|
|
72
|
+
minTimeout: 5,
|
|
73
|
+
maxTimeout: 100,
|
|
74
|
+
factor: 2,
|
|
75
|
+
// Jitter the backoff so cross-process contenders don't retry in
|
|
76
|
+
// lockstep (thundering herd) and starve each other out of the
|
|
77
|
+
// retry budget.
|
|
78
|
+
randomize: true
|
|
79
|
+
},
|
|
80
|
+
stale: 5e3,
|
|
81
|
+
// Stale locks from crashed processes are expected in multi-agent
|
|
82
|
+
// scenarios; log at debug level for traceability without noise.
|
|
83
|
+
onCompromised: /* @__PURE__ */ __name((err) => {
|
|
84
|
+
debug.debug("mailbox lock compromised:", err?.message ?? err);
|
|
85
|
+
}, "onCompromised")
|
|
86
|
+
};
|
|
87
|
+
var inboxLocks = /* @__PURE__ */ new Map();
|
|
88
|
+
function getInboxLock(inboxPath) {
|
|
89
|
+
let lock = inboxLocks.get(inboxPath);
|
|
90
|
+
if (!lock) {
|
|
91
|
+
lock = new Mutex();
|
|
92
|
+
inboxLocks.set(inboxPath, lock);
|
|
93
|
+
}
|
|
94
|
+
return lock;
|
|
95
|
+
}
|
|
96
|
+
__name(getInboxLock, "getInboxLock");
|
|
97
|
+
function disposeInboxLocks(teamName) {
|
|
98
|
+
const dir = getInboxesDir(teamName);
|
|
99
|
+
let evicted = 0;
|
|
100
|
+
for (const key of inboxLocks.keys()) {
|
|
101
|
+
if (path.dirname(key) === dir) {
|
|
102
|
+
inboxLocks.delete(key);
|
|
103
|
+
evicted++;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return evicted;
|
|
107
|
+
}
|
|
108
|
+
__name(disposeInboxLocks, "disposeInboxLocks");
|
|
109
|
+
async function withInboxLock(inboxPath, fn) {
|
|
110
|
+
return getInboxLock(inboxPath).runExclusive(async () => {
|
|
111
|
+
const release = await import_proper_lockfile.default.lock(inboxPath, LOCK_OPTIONS);
|
|
112
|
+
try {
|
|
113
|
+
return await fn();
|
|
114
|
+
} finally {
|
|
115
|
+
await release();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
__name(withInboxLock, "withInboxLock");
|
|
120
|
+
function getInboxPath(teamName, agentName) {
|
|
121
|
+
return path.join(getInboxesDir(teamName), `${agentName}.json`);
|
|
122
|
+
}
|
|
123
|
+
__name(getInboxPath, "getInboxPath");
|
|
124
|
+
async function readInbox(teamName, agentName) {
|
|
125
|
+
const inboxPath = getInboxPath(teamName, agentName);
|
|
126
|
+
try {
|
|
127
|
+
const raw = await fs.readFile(inboxPath, "utf-8");
|
|
128
|
+
return JSON.parse(raw);
|
|
129
|
+
} catch (err) {
|
|
130
|
+
if (isNodeError(err) && err.code === "ENOENT") return [];
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
__name(readInbox, "readInbox");
|
|
135
|
+
var READ_RETENTION_MS = 5 * 60 * 1e3;
|
|
136
|
+
async function writeMessage(teamName, toAgentName, message) {
|
|
137
|
+
const inboxPath = getInboxPath(teamName, toAgentName);
|
|
138
|
+
await ensureInboxFile(inboxPath);
|
|
139
|
+
await withInboxLock(inboxPath, async () => {
|
|
140
|
+
const messages = await readInboxRaw(inboxPath);
|
|
141
|
+
const cutoff = Date.now() - READ_RETENTION_MS;
|
|
142
|
+
const compacted = messages.filter((m) => {
|
|
143
|
+
if (!m.read) return true;
|
|
144
|
+
const ts = Date.parse(m.timestamp);
|
|
145
|
+
return Number.isNaN(ts) || ts >= cutoff;
|
|
146
|
+
});
|
|
147
|
+
compacted.push(message);
|
|
148
|
+
await atomicWriteJSON(inboxPath, compacted);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
__name(writeMessage, "writeMessage");
|
|
152
|
+
async function consumeUnread(teamName, agentName, type) {
|
|
153
|
+
const inboxPath = getInboxPath(teamName, agentName);
|
|
154
|
+
await ensureInboxFile(inboxPath);
|
|
155
|
+
return withInboxLock(inboxPath, async () => {
|
|
156
|
+
const messages = await readInboxRaw(inboxPath);
|
|
157
|
+
const predicate = /* @__PURE__ */ __name((m) => !m.read && (type === void 0 || m.type === type), "predicate");
|
|
158
|
+
const matching = messages.filter(predicate);
|
|
159
|
+
if (matching.length === 0) return [];
|
|
160
|
+
const updated = messages.map(
|
|
161
|
+
(m) => predicate(m) ? { ...m, read: true } : m
|
|
162
|
+
);
|
|
163
|
+
await atomicWriteJSON(inboxPath, updated);
|
|
164
|
+
return matching;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
__name(consumeUnread, "consumeUnread");
|
|
168
|
+
async function clearInbox(teamName, agentName) {
|
|
169
|
+
const inboxPath = getInboxPath(teamName, agentName);
|
|
170
|
+
try {
|
|
171
|
+
await fs.unlink(inboxPath);
|
|
172
|
+
} catch (err) {
|
|
173
|
+
if (!isNodeError(err) || err.code !== "ENOENT") throw err;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
__name(clearInbox, "clearInbox");
|
|
177
|
+
async function clearAllInboxes(teamName) {
|
|
178
|
+
const dir = getInboxesDir(teamName);
|
|
179
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
180
|
+
disposeInboxLocks(teamName);
|
|
181
|
+
}
|
|
182
|
+
__name(clearAllInboxes, "clearAllInboxes");
|
|
183
|
+
async function sendStructuredMessage(teamName, toAgentName, opts) {
|
|
184
|
+
await writeMessage(teamName, toAgentName, {
|
|
185
|
+
from: opts.from,
|
|
186
|
+
text: opts.text,
|
|
187
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
188
|
+
read: false,
|
|
189
|
+
type: opts.type,
|
|
190
|
+
color: opts.color,
|
|
191
|
+
summary: opts.summary
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
__name(sendStructuredMessage, "sendStructuredMessage");
|
|
195
|
+
async function ensureInboxFile(inboxPath) {
|
|
196
|
+
await fs.mkdir(path.dirname(inboxPath), { recursive: true });
|
|
197
|
+
try {
|
|
198
|
+
await fs.writeFile(inboxPath, "[]\n", { flag: "wx" });
|
|
199
|
+
} catch (err) {
|
|
200
|
+
if (!isNodeError(err) || err.code !== "EEXIST") throw err;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
__name(ensureInboxFile, "ensureInboxFile");
|
|
204
|
+
async function readInboxRaw(inboxPath) {
|
|
205
|
+
try {
|
|
206
|
+
const raw = await fs.readFile(inboxPath, "utf-8");
|
|
207
|
+
return JSON.parse(raw);
|
|
208
|
+
} catch (err) {
|
|
209
|
+
if (isNodeError(err) && err.code === "ENOENT") return [];
|
|
210
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
211
|
+
debug.warn(`Quarantining corrupt inbox at ${inboxPath}: ${errMsg}`);
|
|
212
|
+
try {
|
|
213
|
+
await fs.rename(inboxPath, `${inboxPath}.corrupt-${Date.now()}`);
|
|
214
|
+
} catch (renameErr) {
|
|
215
|
+
const renameMsg = renameErr instanceof Error ? renameErr.message : String(renameErr);
|
|
216
|
+
debug.warn(`Failed to quarantine ${inboxPath}: ${renameMsg}`);
|
|
217
|
+
throw err instanceof Error ? err : new Error(`Failed to read inbox at ${inboxPath}: ${errMsg}`);
|
|
218
|
+
}
|
|
219
|
+
return [];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
__name(readInboxRaw, "readInboxRaw");
|
|
223
|
+
|
|
224
|
+
export {
|
|
225
|
+
registerLeader,
|
|
226
|
+
getLeader,
|
|
227
|
+
unregisterLeader,
|
|
228
|
+
forwardApproval,
|
|
229
|
+
wrapConfirmWithBadge,
|
|
230
|
+
disposeInboxLocks,
|
|
231
|
+
getInboxPath,
|
|
232
|
+
readInbox,
|
|
233
|
+
writeMessage,
|
|
234
|
+
consumeUnread,
|
|
235
|
+
clearInbox,
|
|
236
|
+
clearAllInboxes,
|
|
237
|
+
sendStructuredMessage
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* @license
|
|
241
|
+
* Copyright 2025 Qwen
|
|
242
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
243
|
+
*/
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
import {
|
|
4
4
|
RequestTokenizer
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
createChildAbortController
|
|
8
|
-
} from "./chunk-64WXLC72.js";
|
|
5
|
+
} from "./chunk-3NRO6NHX.js";
|
|
9
6
|
import {
|
|
10
7
|
OpenAIContentConverter,
|
|
11
8
|
TaggedThinkingParser,
|
|
12
9
|
openaiRequestCaptureContext
|
|
13
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RON7LFNH.js";
|
|
11
|
+
import {
|
|
12
|
+
createChildAbortController
|
|
13
|
+
} from "./chunk-64WXLC72.js";
|
|
14
14
|
import {
|
|
15
15
|
buildRuntimeFetchOptions,
|
|
16
16
|
redactProxyError
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-NNIYWQIS.js";
|
|
18
18
|
import {
|
|
19
19
|
CAPPED_DEFAULT_MAX_TOKENS,
|
|
20
20
|
DASHSCOPE_PROXY_BASE_URL,
|
|
@@ -25,14 +25,14 @@ import {
|
|
|
25
25
|
runtimeDiagnostics,
|
|
26
26
|
safeJsonParse,
|
|
27
27
|
tokenLimit
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-LYSND7KR.js";
|
|
29
29
|
import {
|
|
30
30
|
GenerateContentResponse
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-55ZMG67I.js";
|
|
32
32
|
import {
|
|
33
33
|
createDebugLogger,
|
|
34
34
|
isAbortError
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-HA2UEYZP.js";
|
|
36
36
|
import {
|
|
37
37
|
init_esbuild_shims
|
|
38
38
|
} from "./chunk-A4BMJM77.js";
|
|
@@ -7608,6 +7608,7 @@ init_esbuild_shims();
|
|
|
7608
7608
|
|
|
7609
7609
|
// packages/core/src/core/openaiContentGenerator/streamingToolCallParser.ts
|
|
7610
7610
|
init_esbuild_shims();
|
|
7611
|
+
var debugLogger2 = createDebugLogger("STREAMING_TOOL_CALL_PARSER");
|
|
7611
7612
|
var StreamingToolCallParser = class {
|
|
7612
7613
|
static {
|
|
7613
7614
|
__name(this, "StreamingToolCallParser");
|
|
@@ -7644,6 +7645,7 @@ var StreamingToolCallParser = class {
|
|
|
7644
7645
|
*/
|
|
7645
7646
|
addChunk(index, chunk, id, name) {
|
|
7646
7647
|
let actualIndex = index;
|
|
7648
|
+
const isKnownId = Boolean(id && this.idToIndexMap.has(id));
|
|
7647
7649
|
if (id) {
|
|
7648
7650
|
if (this.idToIndexMap.has(id)) {
|
|
7649
7651
|
actualIndex = this.idToIndexMap.get(id);
|
|
@@ -7685,11 +7687,21 @@ var StreamingToolCallParser = class {
|
|
|
7685
7687
|
this.escapes.set(actualIndex, false);
|
|
7686
7688
|
this.toolCallMeta.set(actualIndex, {});
|
|
7687
7689
|
}
|
|
7690
|
+
const currentBuffer = this.buffers.get(actualIndex);
|
|
7691
|
+
const currentDepth = this.depths.get(actualIndex);
|
|
7692
|
+
if (isKnownId && currentBuffer.trim() && currentDepth === 0) {
|
|
7693
|
+
try {
|
|
7694
|
+
JSON.parse(currentBuffer);
|
|
7695
|
+
debugLogger2.debug(
|
|
7696
|
+
`Ignoring replay chunk for completed toolCall id=${id}`
|
|
7697
|
+
);
|
|
7698
|
+
return { complete: false };
|
|
7699
|
+
} catch {
|
|
7700
|
+
}
|
|
7701
|
+
}
|
|
7688
7702
|
const meta = this.toolCallMeta.get(actualIndex);
|
|
7689
7703
|
if (id) meta.id = id;
|
|
7690
7704
|
if (name) meta.name = name;
|
|
7691
|
-
const currentBuffer = this.buffers.get(actualIndex);
|
|
7692
|
-
const currentDepth = this.depths.get(actualIndex);
|
|
7693
7705
|
const currentInString = this.inStrings.get(actualIndex);
|
|
7694
7706
|
const currentEscape = this.escapes.get(actualIndex);
|
|
7695
7707
|
const newBuffer = currentBuffer + chunk;
|
|
@@ -7758,9 +7770,16 @@ var StreamingToolCallParser = class {
|
|
|
7758
7770
|
*/
|
|
7759
7771
|
getCompletedToolCalls() {
|
|
7760
7772
|
const completed = [];
|
|
7773
|
+
const emittedIds = /* @__PURE__ */ new Set();
|
|
7761
7774
|
for (const [index, buffer] of this.buffers.entries()) {
|
|
7762
7775
|
const meta = this.toolCallMeta.get(index);
|
|
7763
7776
|
if (meta?.name && buffer.trim()) {
|
|
7777
|
+
if (meta.id) {
|
|
7778
|
+
if (emittedIds.has(meta.id)) {
|
|
7779
|
+
continue;
|
|
7780
|
+
}
|
|
7781
|
+
emittedIds.add(meta.id);
|
|
7782
|
+
}
|
|
7764
7783
|
let args = {};
|
|
7765
7784
|
try {
|
|
7766
7785
|
args = JSON.parse(buffer);
|
|
@@ -8127,6 +8146,8 @@ var ContentGenerationPipeline = class {
|
|
|
8127
8146
|
if (isStreaming) {
|
|
8128
8147
|
baseRequest.stream = true;
|
|
8129
8148
|
baseRequest.stream_options = { include_usage: true };
|
|
8149
|
+
} else {
|
|
8150
|
+
baseRequest.stream = false;
|
|
8130
8151
|
}
|
|
8131
8152
|
if (request.config?.tools && request.config.tools.length > 0) {
|
|
8132
8153
|
baseRequest.tools = await OpenAIContentConverter.convertGeminiToolsToOpenAI(
|
|
@@ -8267,7 +8288,7 @@ var ContentGenerationPipeline = class {
|
|
|
8267
8288
|
|
|
8268
8289
|
// packages/core/src/core/openaiContentGenerator/errorHandler.ts
|
|
8269
8290
|
init_esbuild_shims();
|
|
8270
|
-
var
|
|
8291
|
+
var debugLogger3 = createDebugLogger("OPENAI_ERROR");
|
|
8271
8292
|
var EnhancedErrorHandler = class {
|
|
8272
8293
|
constructor(shouldSuppressLogging = () => false) {
|
|
8273
8294
|
this.shouldSuppressLogging = shouldSuppressLogging;
|
|
@@ -8284,7 +8305,7 @@ var EnhancedErrorHandler = class {
|
|
|
8284
8305
|
isTimeoutError
|
|
8285
8306
|
);
|
|
8286
8307
|
if (!this.shouldSuppressErrorLogging(redactedError, request)) {
|
|
8287
|
-
|
|
8308
|
+
debugLogger3.error("OpenAI API Error:", errorMessage);
|
|
8288
8309
|
}
|
|
8289
8310
|
if (isTimeoutError) {
|
|
8290
8311
|
throw new Error(
|
|
@@ -8324,7 +8345,7 @@ ${tips.join("\n")}`;
|
|
|
8324
8345
|
};
|
|
8325
8346
|
|
|
8326
8347
|
// packages/core/src/core/openaiContentGenerator/openaiContentGenerator.ts
|
|
8327
|
-
var
|
|
8348
|
+
var debugLogger4 = createDebugLogger("OPENAI");
|
|
8328
8349
|
var OpenAIContentGenerator = class {
|
|
8329
8350
|
static {
|
|
8330
8351
|
__name(this, "OpenAIContentGenerator");
|
|
@@ -8367,7 +8388,7 @@ var OpenAIContentGenerator = class {
|
|
|
8367
8388
|
totalTokens: result.totalTokens
|
|
8368
8389
|
};
|
|
8369
8390
|
} catch (error) {
|
|
8370
|
-
|
|
8391
|
+
debugLogger4.warn(
|
|
8371
8392
|
"Failed to calculate tokens with new tokenizer, falling back to simple method:",
|
|
8372
8393
|
error
|
|
8373
8394
|
);
|
|
@@ -8414,7 +8435,7 @@ var OpenAIContentGenerator = class {
|
|
|
8414
8435
|
};
|
|
8415
8436
|
} catch (error) {
|
|
8416
8437
|
const redactedError = redactProxyError(error);
|
|
8417
|
-
|
|
8438
|
+
debugLogger4.error("OpenAI API Embedding Error:", redactedError);
|
|
8418
8439
|
throw new Error(
|
|
8419
8440
|
`OpenAI API error: ${redactedError instanceof Error ? redactedError.message : String(redactedError)}`
|
|
8420
8441
|
);
|