@qwen-code/qwen-code 0.18.0-preview.2 → 0.18.1-nightly.20260616.a68b2e1e7
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/common-workflow.md +4 -4
- package/bundled/qc-helper/docs/configuration/auth.md +1 -1
- package/bundled/qc-helper/docs/configuration/model-providers.md +13 -6
- package/bundled/qc-helper/docs/configuration/settings.md +90 -89
- 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 +250 -31
- package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +30 -30
- package/chunks/{agent-QB7TZ4HW.js → agent-PXMT2XR5.js} +25 -24
- package/chunks/agent-headless-SY7VJUHV.js +51 -0
- package/chunks/{anthropicContentGenerator-M45EVVRM.js → anthropicContentGenerator-DCI26OQF.js} +7 -7
- package/chunks/{askUserQuestion-WM2KHM3K.js → askUserQuestion-NDNFGC35.js} +45 -3
- package/chunks/{ca-BARBRL6N.js → ca-RK4QPLIX.js} +18 -1
- package/chunks/{chunk-CNSMKPK6.js → chunk-26QELEL2.js} +1 -1
- package/chunks/{chunk-CWV3SJZS.js → chunk-3NRO6NHX.js} +2 -2
- package/chunks/{chunk-BNESGOSJ.js → chunk-55ZMG67I.js} +1 -1
- package/chunks/{chunk-2ZTWI7KH.js → chunk-6WPY6ES3.js} +62 -22
- package/chunks/{chunk-ZK4AMNIU.js → chunk-A3OEZT2F.js} +1294 -314
- package/chunks/{chunk-HXJE7VOG.js → chunk-ABRZC6FA.js} +1074 -144
- package/chunks/{chunk-JUGRPQAB.js → chunk-B4ZF2KSI.js} +1 -1
- package/chunks/chunk-BJ5HQ23U.js +178 -0
- package/chunks/{chunk-ICOI4E4S.js → chunk-CPVI5J2L.js} +101 -23
- package/chunks/{chunk-GX7VH5JQ.js → chunk-FIQECJTQ.js} +1 -1
- package/chunks/{chunk-QCG6KPNM.js → chunk-H4ZDM3N6.js} +18039 -11622
- package/chunks/{chunk-SZOEIL6S.js → chunk-H6BD2ELD.js} +1 -0
- package/chunks/{chunk-JXAZUMDW.js → chunk-HA2UEYZP.js} +7 -4
- package/chunks/{chunk-MVIVIPCU.js → chunk-IDYDPBBN.js} +361 -583
- package/chunks/{chunk-JVQOQ3OU.js → chunk-IQHSD7K5.js} +1 -1
- package/chunks/{chunk-CNHFPN7T.js → chunk-JZFEL3RB.js} +1 -1
- 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-AVW55ZCO.js → chunk-M5PJ5QAF.js} +37 -16
- package/chunks/{chunk-LR62TEET.js → chunk-NNIYWQIS.js} +1 -1
- package/chunks/chunk-OMX7CUOE.js +356 -0
- package/chunks/{chunk-HV3ZZ7G4.js → chunk-OT6JA3KQ.js} +2 -2
- package/chunks/{chunk-C6WMLUNB.js → chunk-QP4R5FTG.js} +1 -1
- package/chunks/chunk-QQDPRDVW.js +25 -0
- package/chunks/chunk-SFRV6BGY.js +243 -0
- package/chunks/{chunk-NW5QBUYO.js → chunk-TSBXGR73.js} +14 -14
- package/chunks/{chunk-7YKXFA3D.js → chunk-UOB6KPGG.js} +11 -11
- package/chunks/{chunk-USE2VQ5P.js → chunk-VU6A2OBJ.js} +41 -6
- package/chunks/{chunk-PAEBHDIO.js → chunk-VXHYMZXW.js} +1 -1
- package/chunks/{chunk-HGJPQK33.js → chunk-WPTCDQN6.js} +188 -534
- 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-7SEQDSHB.js +2052 -0
- package/chunks/contextCommand-KM5OWV65.js +53 -0
- package/chunks/cron-create-7CXEAJ2K.js +184 -0
- package/chunks/{cron-delete-ZGUXWBTG.js → cron-delete-2FQYYNQ6.js} +28 -5
- package/chunks/{cron-list-QNNZGMN3.js → cron-list-QCAJ73XE.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-R2SXPG74.js → dist-2UCAYOX7.js} +2 -2
- package/chunks/{dist-TE5QKMGR.js → dist-33LHH26D.js} +1 -1
- package/chunks/{dist-BXDUQ2QY.js → dist-KF43SZZV.js} +1 -1
- package/chunks/{dist-ZMQ4TXD5.js → dist-PF2IYSMD.js} +2 -2
- package/chunks/{edit-6UBTS2J5.js → edit-BMUKPLA7.js} +27 -28
- package/chunks/{en-HSQQNQUB.js → en-VP6XPGEC.js} +9 -2
- package/chunks/{enter-worktree-NN7LIXCM.js → enter-worktree-LXJ5WJ5A.js} +25 -24
- package/chunks/enterPlanMode-QWRZ54ZF.js +159 -0
- package/chunks/{exit-worktree-GGSS5KIE.js → exit-worktree-5HTQPNZO.js} +25 -24
- package/chunks/exitPlanMode-5WQAXNDA.js +743 -0
- package/chunks/{fr-JXBKPJKQ.js → fr-ATYBVCLT.js} +18 -1
- package/chunks/{geminiContentGenerator-I4H2NLJG.js → geminiContentGenerator-CAKHT5YE.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-5DN6NSCD.js} +25 -24
- package/chunks/{grep-7HXIMDOW.js → grep-BJILOLCD.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-XVGXRYWD.js} +4 -4
- package/chunks/{lsp-JZSJOVT7.js → lsp-S6SHPULC.js} +3 -3
- package/chunks/{monitor-SQO7MVAV.js → monitor-SUEMSRN3.js} +25 -24
- package/chunks/{notebook-edit-72L3EBAL.js → notebook-edit-6F6Z5P6U.js} +26 -25
- package/chunks/{openaiContentGenerator-FTR7CDWF.js → openaiContentGenerator-DO27LL6O.js} +15 -15
- package/chunks/{pt-TIBG6BIO.js → pt-ZKEWJFBW.js} +18 -1
- package/chunks/{qwenContentGenerator-U5UFQ566.js → qwenContentGenerator-DQLGLQSH.js} +27 -26
- package/chunks/{qwenOAuth2-EFSECGHF.js → qwenOAuth2-KK433U33.js} +6 -5
- package/chunks/{read-file-UA64EEQC.js → read-file-3TBLYTOQ.js} +11 -11
- package/chunks/ripGrep-3INYT3QV.js +49 -0
- package/chunks/{ru-JBCHCK4L.js → ru-VEKTPJ74.js} +18 -1
- package/chunks/{scheduler-VBASHOCA.js → scheduler-23KQW6CX.js} +25 -24
- package/chunks/{send-message-OYJZ5TPG.js → send-message-SMNR5DBG.js} +3 -3
- package/chunks/{serve-A7E2OJDR.js → serve-Y5E4LKUI.js} +13164 -3840
- package/chunks/{shell-3NFOT6F5.js → shell-4H6XQXVY.js} +25 -24
- package/chunks/{skill-RA5YUREY.js → skill-SE6FECZR.js} +64 -113
- package/chunks/{src-NFCMARMT.js → src-76DUBH3A.js} +176 -44
- package/chunks/{syntheticOutput-DETQ2YM6.js → syntheticOutput-KMNF7YG6.js} +4 -4
- package/chunks/{task-create-Y3ZKTJIG.js → task-create-LIJHK75G.js} +8 -7
- package/chunks/{task-list-ONXJ3I3A.js → task-list-S4GNSILM.js} +7 -6
- package/chunks/{task-stop-UHDC4N5B.js → task-stop-3GBRYJHM.js} +3 -3
- package/chunks/{task-update-TCNOU3P5.js → task-update-F3UTVJMS.js} +21 -9
- package/chunks/{team-create-6SR4OVRG.js → team-create-Q5DTDDH4.js} +28 -26
- package/chunks/{team-delete-EJ4U4DDP.js → team-delete-54434EB7.js} +9 -6
- package/chunks/{todoWrite-TEYDRS5L.js → todoWrite-4ENGSBUX.js} +5 -5
- package/chunks/{tool-search-OD435A3X.js → tool-search-ABZMSDTU.js} +11 -11
- package/chunks/{web-fetch-6W67H5PO.js → web-fetch-RHZMF3MP.js} +5 -5
- package/chunks/workflow-NEMDQB75.js +1414 -0
- package/chunks/{write-file-475L5OPP.js → write-file-VAEHZPSL.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 +11155 -6656
- 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
|
@@ -1,708 +0,0 @@
|
|
|
1
|
-
// Force strict mode and setup for ESM
|
|
2
|
-
"use strict";
|
|
3
|
-
import "./chunk-SKBPNJEW.js";
|
|
4
|
-
import {
|
|
5
|
-
createChildAbortController
|
|
6
|
-
} from "./chunk-64WXLC72.js";
|
|
7
|
-
import {
|
|
8
|
-
BaseDeclarativeTool,
|
|
9
|
-
BaseToolInvocation,
|
|
10
|
-
ToolDisplayNames,
|
|
11
|
-
ToolNames
|
|
12
|
-
} from "./chunk-2ZTWI7KH.js";
|
|
13
|
-
import "./chunk-JXAZUMDW.js";
|
|
14
|
-
import "./chunk-WFVXF3OM.js";
|
|
15
|
-
import {
|
|
16
|
-
init_esbuild_shims
|
|
17
|
-
} from "./chunk-A4BMJM77.js";
|
|
18
|
-
import {
|
|
19
|
-
__name
|
|
20
|
-
} from "./chunk-J2S4EL5Y.js";
|
|
21
|
-
|
|
22
|
-
// packages/core/src/tools/workflow/workflow.ts
|
|
23
|
-
init_esbuild_shims();
|
|
24
|
-
|
|
25
|
-
// packages/core/src/agents/runtime/workflow-orchestrator.ts
|
|
26
|
-
init_esbuild_shims();
|
|
27
|
-
import { randomBytes } from "node:crypto";
|
|
28
|
-
|
|
29
|
-
// packages/core/src/agents/runtime/workflow-sandbox.ts
|
|
30
|
-
init_esbuild_shims();
|
|
31
|
-
import * as vm from "node:vm";
|
|
32
|
-
function stripExportMeta(source) {
|
|
33
|
-
const re = /^\s*export\s+const\s+meta\s*=\s*\{/;
|
|
34
|
-
const match = re.exec(source);
|
|
35
|
-
if (!match) return source;
|
|
36
|
-
const exportIdx = match.index;
|
|
37
|
-
const startBrace = source.indexOf("{", exportIdx);
|
|
38
|
-
let depth = 1;
|
|
39
|
-
let i = startBrace + 1;
|
|
40
|
-
while (i < source.length && depth > 0) {
|
|
41
|
-
const ch = source[i];
|
|
42
|
-
const next = source[i + 1];
|
|
43
|
-
if (ch === "/" && next === "/") {
|
|
44
|
-
i += 2;
|
|
45
|
-
while (i < source.length && source[i] !== "\n") i++;
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (ch === "/" && next === "*") {
|
|
49
|
-
i += 2;
|
|
50
|
-
while (i < source.length && !(source[i] === "*" && source[i + 1] === "/"))
|
|
51
|
-
i++;
|
|
52
|
-
i += 2;
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (ch === "/" && isRegexContext(source, i)) {
|
|
56
|
-
i++;
|
|
57
|
-
let inClass = false;
|
|
58
|
-
while (i < source.length && (inClass || source[i] !== "/") && source[i] !== "\n") {
|
|
59
|
-
if (source[i] === "\\") i += 2;
|
|
60
|
-
else if (source[i] === "[") {
|
|
61
|
-
inClass = true;
|
|
62
|
-
i++;
|
|
63
|
-
} else if (source[i] === "]") {
|
|
64
|
-
inClass = false;
|
|
65
|
-
i++;
|
|
66
|
-
} else {
|
|
67
|
-
i++;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
i++;
|
|
71
|
-
while (i < source.length && /[gimsuy]/.test(source[i])) i++;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (ch === '"' || ch === "'" || ch === "`") {
|
|
75
|
-
const q = ch;
|
|
76
|
-
i++;
|
|
77
|
-
while (i < source.length && source[i] !== q) {
|
|
78
|
-
if (source[i] === "\\") i++;
|
|
79
|
-
i++;
|
|
80
|
-
}
|
|
81
|
-
i++;
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (ch === "{") depth++;
|
|
85
|
-
else if (ch === "}") depth--;
|
|
86
|
-
i++;
|
|
87
|
-
}
|
|
88
|
-
if (depth !== 0) {
|
|
89
|
-
throw new Error(
|
|
90
|
-
"stripExportMeta: unbalanced braces in export const meta declaration \u2014 the workflow script cannot be safely stripped. Check the meta block syntax."
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
while (i < source.length && /[\s;]/.test(source[i])) i++;
|
|
94
|
-
return source.slice(0, exportIdx) + source.slice(i);
|
|
95
|
-
}
|
|
96
|
-
__name(stripExportMeta, "stripExportMeta");
|
|
97
|
-
function isRegexContext(source, i) {
|
|
98
|
-
let j = i - 1;
|
|
99
|
-
while (j >= 0 && /\s/.test(source[j])) j--;
|
|
100
|
-
if (j < 0) return true;
|
|
101
|
-
const prev = source[j];
|
|
102
|
-
return /[{[(,;:=!&|?+\-*/%^~<>]/.test(prev);
|
|
103
|
-
}
|
|
104
|
-
__name(isRegexContext, "isRegexContext");
|
|
105
|
-
var MAX_LOG_LINES = 1e4;
|
|
106
|
-
var MAX_PHASE_ENTRIES = 1e4;
|
|
107
|
-
var ARGS_MAX_DEPTH = 64;
|
|
108
|
-
var DEFAULT_MAX_WALL_CLOCK_MS = 30 * 60 * 1e3;
|
|
109
|
-
function resolveMaxWallClockMs(opts) {
|
|
110
|
-
if (typeof opts.maxWallClockMs === "number" && opts.maxWallClockMs > 0) {
|
|
111
|
-
return opts.maxWallClockMs;
|
|
112
|
-
}
|
|
113
|
-
const envSec = Number(process.env["QWEN_CODE_MAX_WORKFLOW_SECONDS"]);
|
|
114
|
-
if (Number.isFinite(envSec) && envSec > 0) return envSec * 1e3;
|
|
115
|
-
return DEFAULT_MAX_WALL_CLOCK_MS;
|
|
116
|
-
}
|
|
117
|
-
__name(resolveMaxWallClockMs, "resolveMaxWallClockMs");
|
|
118
|
-
function validateArgs(val, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
|
|
119
|
-
if (depth > ARGS_MAX_DEPTH) {
|
|
120
|
-
throw new Error(
|
|
121
|
-
`WorkflowSandbox: args exceeded max nesting depth of ${ARGS_MAX_DEPTH}`
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
if (val === null) return;
|
|
125
|
-
const t = typeof val;
|
|
126
|
-
if (t === "function") {
|
|
127
|
-
throw new Error(
|
|
128
|
-
"WorkflowSandbox: args must be JSON-serializable (functions are not allowed)."
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
if (t === "bigint") {
|
|
132
|
-
throw new Error(
|
|
133
|
-
"WorkflowSandbox: args must be JSON-serializable (BigInt is not allowed \u2014 pass as string)."
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
if (t !== "object") return;
|
|
137
|
-
const obj = val;
|
|
138
|
-
if (seen.has(obj)) {
|
|
139
|
-
throw new Error(
|
|
140
|
-
"WorkflowSandbox: args must be JSON-serializable (circular reference detected)."
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
seen.add(obj);
|
|
144
|
-
if (Array.isArray(val)) {
|
|
145
|
-
for (const item of val) validateArgs(item, depth + 1, seen);
|
|
146
|
-
} else {
|
|
147
|
-
for (const v of Object.values(val)) {
|
|
148
|
-
validateArgs(v, depth + 1, seen);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
__name(validateArgs, "validateArgs");
|
|
153
|
-
function createWorkflowSandbox(opts) {
|
|
154
|
-
const phases = [];
|
|
155
|
-
const logs = [];
|
|
156
|
-
const safeLog = /* @__PURE__ */ __name((msg) => {
|
|
157
|
-
if (logs.length < MAX_LOG_LINES) {
|
|
158
|
-
logs.push(String(msg));
|
|
159
|
-
} else if (logs.length === MAX_LOG_LINES) {
|
|
160
|
-
logs.push(`[workflow log truncated at ${MAX_LOG_LINES} lines]`);
|
|
161
|
-
}
|
|
162
|
-
}, "safeLog");
|
|
163
|
-
const safePhase = /* @__PURE__ */ __name((title) => {
|
|
164
|
-
if (phases.length < MAX_PHASE_ENTRIES) {
|
|
165
|
-
phases.push(String(title));
|
|
166
|
-
} else if (phases.length === MAX_PHASE_ENTRIES) {
|
|
167
|
-
phases.push(
|
|
168
|
-
`[workflow phases truncated at ${MAX_PHASE_ENTRIES} entries]`
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
}, "safePhase");
|
|
172
|
-
if (opts.args !== void 0) validateArgs(opts.args);
|
|
173
|
-
const argsJson = opts.args === void 0 ? null : JSON.stringify(opts.args);
|
|
174
|
-
const bridge = {
|
|
175
|
-
argsJson,
|
|
176
|
-
pushPhase: safePhase,
|
|
177
|
-
pushLog: safeLog,
|
|
178
|
-
lastPhase: /* @__PURE__ */ __name(() => phases[phases.length - 1], "lastPhase"),
|
|
179
|
-
hostAgent: opts.dispatch,
|
|
180
|
-
// The truthy flags distinguish "injected" from "default stub" inside the
|
|
181
|
-
// init script without leaking the host function itself when not used.
|
|
182
|
-
hasParallel: !!opts.parallel,
|
|
183
|
-
hasPipeline: !!opts.pipeline,
|
|
184
|
-
hasBudget: !!opts.budget,
|
|
185
|
-
hostParallel: opts.parallel,
|
|
186
|
-
hostPipeline: opts.pipeline,
|
|
187
|
-
budgetTotal: opts.budget ? opts.budget.total : null,
|
|
188
|
-
hostBudgetSpent: opts.budget ? opts.budget.spent.bind(opts.budget) : null,
|
|
189
|
-
hostBudgetRemaining: opts.budget ? opts.budget.remaining.bind(opts.budget) : null
|
|
190
|
-
};
|
|
191
|
-
Object.setPrototypeOf(bridge, null);
|
|
192
|
-
const sandboxGlobals = Object.assign(
|
|
193
|
-
/* @__PURE__ */ Object.create(null),
|
|
194
|
-
{ __workflowBridge: bridge }
|
|
195
|
-
);
|
|
196
|
-
const ctx = vm.createContext(sandboxGlobals);
|
|
197
|
-
vm.runInContext(
|
|
198
|
-
`(() => {
|
|
199
|
-
const __b = globalThis.__workflowBridge;
|
|
200
|
-
delete globalThis.__workflowBridge;
|
|
201
|
-
|
|
202
|
-
// --- Math (vm-realm, random throws) ---
|
|
203
|
-
const realMath = Math;
|
|
204
|
-
const safeMath = Object.create(null);
|
|
205
|
-
for (const k of Object.getOwnPropertyNames(realMath)) {
|
|
206
|
-
if (k === 'random' || k === 'constructor') continue;
|
|
207
|
-
safeMath[k] = realMath[k];
|
|
208
|
-
}
|
|
209
|
-
safeMath.random = () => {
|
|
210
|
-
throw new Error(
|
|
211
|
-
'Math.random() is unavailable in workflow scripts (breaks resume). ' +
|
|
212
|
-
'For N independent samples, include the index in the agent label or prompt.'
|
|
213
|
-
);
|
|
214
|
-
};
|
|
215
|
-
globalThis.Math = safeMath;
|
|
216
|
-
|
|
217
|
-
// --- Date (vm-realm function that throws on any access) ---
|
|
218
|
-
const dateMsg = 'Date.now() / new Date() are unavailable in workflow ' +
|
|
219
|
-
'scripts (breaks resume). Stamp results after the workflow returns, ' +
|
|
220
|
-
'or pass timestamps via args.';
|
|
221
|
-
const safeDate = function Date() { throw new Error(dateMsg); };
|
|
222
|
-
safeDate.now = () => { throw new Error(dateMsg); };
|
|
223
|
-
safeDate.UTC = () => { throw new Error(dateMsg); };
|
|
224
|
-
safeDate.parse = () => { throw new Error(dateMsg); };
|
|
225
|
-
Object.setPrototypeOf(safeDate, null);
|
|
226
|
-
Object.defineProperty(safeDate, 'constructor', {
|
|
227
|
-
value: undefined, writable: false, configurable: false,
|
|
228
|
-
});
|
|
229
|
-
globalThis.Date = safeDate;
|
|
230
|
-
|
|
231
|
-
// --- args (parsed via vm-realm JSON \u2192 vm-realm objects/arrays) ---
|
|
232
|
-
// FIX-Round1-T2: vm-realm arrays keep their vm-realm Array.prototype,
|
|
233
|
-
// so for...of, .map, .forEach, spread, destructuring all work \u2014 and
|
|
234
|
-
// their inherited methods' constructors are vm-realm Function, which
|
|
235
|
-
// cannot reach host process.
|
|
236
|
-
globalThis.args = __b.argsJson === null ? undefined : JSON.parse(__b.argsJson);
|
|
237
|
-
|
|
238
|
-
// --- Wrap a host async function so it returns a vm-realm Promise ---
|
|
239
|
-
// FIX-Round1-T1/T8/T14: success and failure both cross the boundary
|
|
240
|
-
// as vm-realm values: resolve with the host's value (a primitive
|
|
241
|
-
// string for dispatch; vm-realm arrays for parallel/pipeline because
|
|
242
|
-
// those wrappers will produce vm-realm results); reject with a
|
|
243
|
-
// freshly-constructed vm-realm Error so e.constructor.constructor
|
|
244
|
-
// stays in the vm realm.
|
|
245
|
-
function vmAsync(hostFn) {
|
|
246
|
-
return function (...vmArgs) {
|
|
247
|
-
return new Promise(function (resolve, reject) {
|
|
248
|
-
try {
|
|
249
|
-
const hostPromise = hostFn.apply(null, vmArgs);
|
|
250
|
-
hostPromise.then(
|
|
251
|
-
function (value) { resolve(value); },
|
|
252
|
-
function (hostErr) {
|
|
253
|
-
const msg = (hostErr && hostErr.message != null)
|
|
254
|
-
? String(hostErr.message)
|
|
255
|
-
: String(hostErr);
|
|
256
|
-
reject(new Error(msg));
|
|
257
|
-
}
|
|
258
|
-
);
|
|
259
|
-
} catch (hostErr) {
|
|
260
|
-
const msg = (hostErr && hostErr.message != null)
|
|
261
|
-
? String(hostErr.message)
|
|
262
|
-
: String(hostErr);
|
|
263
|
-
reject(new Error(msg));
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// --- phase / log ---
|
|
270
|
-
globalThis.phase = function phase(title) {
|
|
271
|
-
__b.pushPhase(String(title));
|
|
272
|
-
};
|
|
273
|
-
globalThis.log = function log(msg) {
|
|
274
|
-
__b.pushLog(msg);
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
// --- console (object with hardened methods, all in vm-realm) ---
|
|
278
|
-
const safeConsole = Object.create(null);
|
|
279
|
-
safeConsole.log = function () {
|
|
280
|
-
const parts = [];
|
|
281
|
-
for (let i = 0; i < arguments.length; i++) parts.push(String(arguments[i]));
|
|
282
|
-
__b.pushLog(parts.join(' '));
|
|
283
|
-
};
|
|
284
|
-
safeConsole.warn = safeConsole.log;
|
|
285
|
-
safeConsole.error = safeConsole.log;
|
|
286
|
-
globalThis.console = safeConsole;
|
|
287
|
-
|
|
288
|
-
// --- agent (with runtime allowlist + named throws, all vm-realm) ---
|
|
289
|
-
// FIX-Round1-T13: throw on any opts key not in the allowlist \u2014 catches
|
|
290
|
-
// typos like { scema: ... } that previously slipped through the
|
|
291
|
-
// [key:string]: unknown index signature.
|
|
292
|
-
const KNOWN_AGENT_OPTS = ['label', 'phase', 'schema', 'model', 'isolation', 'agentType'];
|
|
293
|
-
globalThis.agent = vmAsync(function (prompt, agentOpts) {
|
|
294
|
-
agentOpts = agentOpts || {};
|
|
295
|
-
const keys = Object.keys(agentOpts);
|
|
296
|
-
for (let i = 0; i < keys.length; i++) {
|
|
297
|
-
const k = keys[i];
|
|
298
|
-
if (KNOWN_AGENT_OPTS.indexOf(k) === -1) {
|
|
299
|
-
throw new Error(
|
|
300
|
-
"agent({" + k + "}): unknown option. " +
|
|
301
|
-
"Known options are: " + KNOWN_AGENT_OPTS.join(', ') + "."
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
if (agentOpts.schema !== undefined) {
|
|
306
|
-
throw new Error(
|
|
307
|
-
'agent({schema}) is not supported in P1. ' +
|
|
308
|
-
'Schema enforcement / StructuredOutput contract is scheduled for P3.'
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
if (agentOpts.isolation !== undefined) {
|
|
312
|
-
throw new Error(
|
|
313
|
-
"agent({isolation: '" + agentOpts.isolation + "'}) is not supported in P1. " +
|
|
314
|
-
'Worktree / remote isolation is scheduled for a later phase.'
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
if (agentOpts.model !== undefined) {
|
|
318
|
-
throw new Error(
|
|
319
|
-
'agent({model}) is not supported in P1. Model override is scheduled for a later phase.'
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
if (agentOpts.agentType !== undefined) {
|
|
323
|
-
throw new Error('agent({agentType}) is not supported in P1.');
|
|
324
|
-
}
|
|
325
|
-
if (typeof agentOpts.phase === 'string' && agentOpts.phase.length > 0) {
|
|
326
|
-
if (__b.lastPhase() !== agentOpts.phase) {
|
|
327
|
-
__b.pushPhase(agentOpts.phase);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
return __b.hostAgent(prompt, agentOpts);
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
// --- parallel / pipeline ---
|
|
334
|
-
if (__b.hasParallel) {
|
|
335
|
-
globalThis.parallel = vmAsync(function (thunks) {
|
|
336
|
-
return __b.hostParallel(thunks);
|
|
337
|
-
});
|
|
338
|
-
} else {
|
|
339
|
-
globalThis.parallel = function parallel() {
|
|
340
|
-
return new Promise(function (_, reject) {
|
|
341
|
-
reject(new Error(
|
|
342
|
-
'parallel() is not supported in P1. Sequential agent() is the only ' +
|
|
343
|
-
'execution mode in P1. Concurrent fan-out is scheduled for P2.'
|
|
344
|
-
));
|
|
345
|
-
});
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
if (__b.hasPipeline) {
|
|
349
|
-
globalThis.pipeline = vmAsync(function (items) {
|
|
350
|
-
const stages = [];
|
|
351
|
-
for (let i = 1; i < arguments.length; i++) stages.push(arguments[i]);
|
|
352
|
-
return __b.hostPipeline.apply(null, [items].concat(stages));
|
|
353
|
-
});
|
|
354
|
-
} else {
|
|
355
|
-
globalThis.pipeline = function pipeline() {
|
|
356
|
-
return new Promise(function (_, reject) {
|
|
357
|
-
reject(new Error(
|
|
358
|
-
'pipeline() is not supported in P1. Staggered multi-stage execution ' +
|
|
359
|
-
'is scheduled for P2.'
|
|
360
|
-
));
|
|
361
|
-
});
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
// workflow() always throws in P1.
|
|
365
|
-
globalThis.workflow = function workflow() {
|
|
366
|
-
return new Promise(function (_, reject) {
|
|
367
|
-
reject(new Error(
|
|
368
|
-
'workflow() (nested workflow invocation) is not supported in P1. ' +
|
|
369
|
-
'Scheduled for a later phase.'
|
|
370
|
-
));
|
|
371
|
-
});
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
// --- budget ---
|
|
375
|
-
const safeBudget = Object.create(null);
|
|
376
|
-
Object.defineProperty(safeBudget, 'total', {
|
|
377
|
-
value: __b.budgetTotal,
|
|
378
|
-
writable: false, configurable: false,
|
|
379
|
-
});
|
|
380
|
-
if (__b.hasBudget) {
|
|
381
|
-
Object.defineProperty(safeBudget, 'spent', {
|
|
382
|
-
value: function spent() { return __b.hostBudgetSpent(); },
|
|
383
|
-
writable: false, configurable: false,
|
|
384
|
-
});
|
|
385
|
-
Object.defineProperty(safeBudget, 'remaining', {
|
|
386
|
-
value: function remaining() { return __b.hostBudgetRemaining(); },
|
|
387
|
-
writable: false, configurable: false,
|
|
388
|
-
});
|
|
389
|
-
} else {
|
|
390
|
-
Object.defineProperty(safeBudget, 'spent', {
|
|
391
|
-
value: function spent() {
|
|
392
|
-
throw new Error(
|
|
393
|
-
'budget.spent() is not supported in P1. Token tracking is scheduled for P5.'
|
|
394
|
-
);
|
|
395
|
-
},
|
|
396
|
-
writable: false, configurable: false,
|
|
397
|
-
});
|
|
398
|
-
Object.defineProperty(safeBudget, 'remaining', {
|
|
399
|
-
value: function remaining() {
|
|
400
|
-
throw new Error(
|
|
401
|
-
'budget.remaining() is not supported in P1. Token tracking is scheduled for P5.'
|
|
402
|
-
);
|
|
403
|
-
},
|
|
404
|
-
writable: false, configurable: false,
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
globalThis.budget = safeBudget;
|
|
408
|
-
})();`,
|
|
409
|
-
ctx,
|
|
410
|
-
{ filename: "workflow-sandbox-init.js" }
|
|
411
|
-
);
|
|
412
|
-
const maxWallClockMs = resolveMaxWallClockMs(opts);
|
|
413
|
-
return {
|
|
414
|
-
async run(scriptSource) {
|
|
415
|
-
const stripped = stripExportMeta(scriptSource);
|
|
416
|
-
const wrapped = `(async () => {
|
|
417
|
-
${stripped}
|
|
418
|
-
})()`;
|
|
419
|
-
const script = new vm.Script(wrapped, {
|
|
420
|
-
filename: "workflow.js"
|
|
421
|
-
});
|
|
422
|
-
const runOpts = {
|
|
423
|
-
timeout: 3e4
|
|
424
|
-
};
|
|
425
|
-
const result = script.runInContext(ctx, runOpts);
|
|
426
|
-
let timer;
|
|
427
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
428
|
-
timer = setTimeout(() => {
|
|
429
|
-
opts.abortOnTimeout?.abort();
|
|
430
|
-
reject(
|
|
431
|
-
new Error(
|
|
432
|
-
`Workflow execution timed out after ${maxWallClockMs} ms wall clock. Override via SandboxOptions.maxWallClockMs or QWEN_CODE_MAX_WORKFLOW_SECONDS env var.`
|
|
433
|
-
)
|
|
434
|
-
);
|
|
435
|
-
}, maxWallClockMs);
|
|
436
|
-
timer.unref?.();
|
|
437
|
-
});
|
|
438
|
-
try {
|
|
439
|
-
return await Promise.race([result, timeoutPromise]);
|
|
440
|
-
} finally {
|
|
441
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
442
|
-
}
|
|
443
|
-
},
|
|
444
|
-
getPhases: /* @__PURE__ */ __name(() => [...phases], "getPhases"),
|
|
445
|
-
getLogs: /* @__PURE__ */ __name(() => [...logs], "getLogs")
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
__name(createWorkflowSandbox, "createWorkflowSandbox");
|
|
449
|
-
|
|
450
|
-
// packages/core/src/agents/runtime/workflow-prompts.ts
|
|
451
|
-
init_esbuild_shims();
|
|
452
|
-
var WORKFLOW_SUBAGENT_SYSTEM_PROMPT = 'You are a subagent spawned by a workflow orchestration script. Use the tools available to complete the task.\nCRITICAL: Your final text response is returned **verbatim** as a string to the calling script \u2014 it is your return value, not a message to a human.\n- Output the literal result (data, JSON, text). Do NOT output confirmations like "Done." or "Sent."\n- If asked for JSON, return ONLY the raw JSON \u2014 no code fences, no prose, no markdown.\n- Do NOT use SendUserMessage to deliver your answer. Put your answer in your final text response.\n- Be concise. The script will parse your output.';
|
|
453
|
-
|
|
454
|
-
// packages/core/src/agents/runtime/workflow-orchestrator.ts
|
|
455
|
-
var WORKFLOW_SUBAGENT_MAX_TURNS = 50;
|
|
456
|
-
var WORKFLOW_SUBAGENT_MAX_TIME_MINUTES = 10;
|
|
457
|
-
var WORKFLOW_SUBAGENT_DISALLOWED_TOOLS = [
|
|
458
|
-
ToolNames.SEND_MESSAGE,
|
|
459
|
-
ToolNames.EXIT_PLAN_MODE
|
|
460
|
-
];
|
|
461
|
-
var WorkflowExecutionError = class extends Error {
|
|
462
|
-
constructor(message, phases, logs) {
|
|
463
|
-
super(message);
|
|
464
|
-
this.phases = phases;
|
|
465
|
-
this.logs = logs;
|
|
466
|
-
}
|
|
467
|
-
static {
|
|
468
|
-
__name(this, "WorkflowExecutionError");
|
|
469
|
-
}
|
|
470
|
-
name = "WorkflowExecutionError";
|
|
471
|
-
};
|
|
472
|
-
function generateRunId() {
|
|
473
|
-
return `wf_${randomBytes(8).toString("hex")}`;
|
|
474
|
-
}
|
|
475
|
-
__name(generateRunId, "generateRunId");
|
|
476
|
-
function createProductionDispatch(config, signal) {
|
|
477
|
-
return async (prompt, opts) => {
|
|
478
|
-
const { AgentHeadless, ContextState } = await import("./agent-headless-APVHH7QM.js");
|
|
479
|
-
const ctx = new ContextState();
|
|
480
|
-
ctx.set("task_prompt", prompt);
|
|
481
|
-
const subagent = await AgentHeadless.create(
|
|
482
|
-
opts.label ?? "workflow-agent",
|
|
483
|
-
config,
|
|
484
|
-
{
|
|
485
|
-
systemPrompt: WORKFLOW_SUBAGENT_SYSTEM_PROMPT,
|
|
486
|
-
initialMessages: []
|
|
487
|
-
},
|
|
488
|
-
{},
|
|
489
|
-
// T11 (PR #4732 R1): bound resource ceiling so a single agent() call
|
|
490
|
-
// cannot loop the model indefinitely. Without this, runConfig was {}
|
|
491
|
-
// and the loop guards never tripped — combined with the cancellation
|
|
492
|
-
// bug below, workflows were effectively unkillable.
|
|
493
|
-
{
|
|
494
|
-
max_turns: WORKFLOW_SUBAGENT_MAX_TURNS,
|
|
495
|
-
max_time_minutes: WORKFLOW_SUBAGENT_MAX_TIME_MINUTES
|
|
496
|
-
},
|
|
497
|
-
// T11 (PR #4732 R1): disallow SendMessage / ExitPlanMode to align with
|
|
498
|
-
// upstream Tg8 — closes the back-channel that would let a subagent
|
|
499
|
-
// deliver its answer via user message instead of the script's read.
|
|
500
|
-
{ tools: ["*"], disallowedTools: WORKFLOW_SUBAGENT_DISALLOWED_TOOLS }
|
|
501
|
-
);
|
|
502
|
-
await subagent.execute(ctx, signal);
|
|
503
|
-
const mode = subagent.getTerminateMode();
|
|
504
|
-
if (mode !== "GOAL" /* GOAL */) {
|
|
505
|
-
throw new Error(
|
|
506
|
-
`Workflow subagent did not complete (terminate mode: ${mode}).`
|
|
507
|
-
);
|
|
508
|
-
}
|
|
509
|
-
return subagent.getFinalText();
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
__name(createProductionDispatch, "createProductionDispatch");
|
|
513
|
-
var WorkflowOrchestrator = class {
|
|
514
|
-
constructor(dispatch) {
|
|
515
|
-
this.dispatch = dispatch;
|
|
516
|
-
}
|
|
517
|
-
static {
|
|
518
|
-
__name(this, "WorkflowOrchestrator");
|
|
519
|
-
}
|
|
520
|
-
async run(req) {
|
|
521
|
-
const runId = generateRunId();
|
|
522
|
-
const sandbox = createWorkflowSandbox({
|
|
523
|
-
args: req.args,
|
|
524
|
-
dispatch: this.dispatch,
|
|
525
|
-
abortOnTimeout: req.abortOnTimeout
|
|
526
|
-
});
|
|
527
|
-
try {
|
|
528
|
-
const result = await sandbox.run(req.script);
|
|
529
|
-
return {
|
|
530
|
-
runId,
|
|
531
|
-
result,
|
|
532
|
-
phases: sandbox.getPhases(),
|
|
533
|
-
logs: sandbox.getLogs()
|
|
534
|
-
};
|
|
535
|
-
} catch (err) {
|
|
536
|
-
throw new WorkflowExecutionError(
|
|
537
|
-
extractErrorMessage(err),
|
|
538
|
-
sandbox.getPhases(),
|
|
539
|
-
sandbox.getLogs()
|
|
540
|
-
);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
function extractErrorMessage(err) {
|
|
545
|
-
if (err && typeof err === "object" && "message" in err) {
|
|
546
|
-
const m = err.message;
|
|
547
|
-
if (typeof m === "string") return m;
|
|
548
|
-
return String(m);
|
|
549
|
-
}
|
|
550
|
-
return String(err);
|
|
551
|
-
}
|
|
552
|
-
__name(extractErrorMessage, "extractErrorMessage");
|
|
553
|
-
|
|
554
|
-
// packages/core/src/tools/workflow/workflow.ts
|
|
555
|
-
var WORKFLOW_PARAM_SCHEMA = {
|
|
556
|
-
type: "object",
|
|
557
|
-
properties: {
|
|
558
|
-
script: {
|
|
559
|
-
type: "string",
|
|
560
|
-
description: "JavaScript source of the workflow. Wrapped as an async IIFE. May call the injected globals `phase(title)`, `log(msg)`, `agent(prompt, { label? })`, and read `args`. P1 ships sequential primitives only \u2014 `parallel()` and `pipeline()` arrive in P2. Writing `Promise.all([agent(), agent()])` spawns concurrent subagents that share Config and may race on file edits; prefer `await agent(...)` for ordered execution. `Date.now()` and `Math.random()` both throw \u2014 workflow scripts must be deterministic for resume. `export const meta = {...}` declarations are stripped before execution."
|
|
561
|
-
},
|
|
562
|
-
args: {
|
|
563
|
-
description: "Optional structured value bound to the `args` global. Pass actual JSON, not a stringified value."
|
|
564
|
-
}
|
|
565
|
-
},
|
|
566
|
-
required: ["script"]
|
|
567
|
-
};
|
|
568
|
-
var WorkflowToolInvocation = class extends BaseToolInvocation {
|
|
569
|
-
constructor(config, toolOptions, params) {
|
|
570
|
-
super(params);
|
|
571
|
-
this.config = config;
|
|
572
|
-
this.toolOptions = toolOptions;
|
|
573
|
-
}
|
|
574
|
-
static {
|
|
575
|
-
__name(this, "WorkflowToolInvocation");
|
|
576
|
-
}
|
|
577
|
-
getDescription() {
|
|
578
|
-
return `Run a workflow script (${this.params.script.length} chars)`;
|
|
579
|
-
}
|
|
580
|
-
toolLocations() {
|
|
581
|
-
return [];
|
|
582
|
-
}
|
|
583
|
-
getDefaultPermission() {
|
|
584
|
-
return Promise.resolve("ask");
|
|
585
|
-
}
|
|
586
|
-
async execute(signal, _updateOutput, _shellExecutionConfig) {
|
|
587
|
-
const dispatchController = createChildAbortController(signal);
|
|
588
|
-
const dispatch = this.toolOptions.dispatch ?? createProductionDispatch(this.config, dispatchController.signal);
|
|
589
|
-
const orchestrator = new WorkflowOrchestrator(dispatch);
|
|
590
|
-
try {
|
|
591
|
-
const outcome = await orchestrator.run({
|
|
592
|
-
script: this.params.script,
|
|
593
|
-
args: this.params.args,
|
|
594
|
-
abortOnTimeout: dispatchController
|
|
595
|
-
});
|
|
596
|
-
const llmText = safeStringifyResult(outcome.result);
|
|
597
|
-
const displayJson = safeStringifyDisplayPayload({
|
|
598
|
-
runId: outcome.runId,
|
|
599
|
-
phases: outcome.phases,
|
|
600
|
-
logs: outcome.logs,
|
|
601
|
-
result: outcome.result
|
|
602
|
-
});
|
|
603
|
-
return {
|
|
604
|
-
llmContent: [{ text: llmText }],
|
|
605
|
-
returnDisplay: "```json\n" + displayJson + "\n```"
|
|
606
|
-
};
|
|
607
|
-
} catch (err) {
|
|
608
|
-
const message = extractErrorMessage2(err);
|
|
609
|
-
const phases = err instanceof WorkflowExecutionError ? err.phases : void 0;
|
|
610
|
-
const logs = err instanceof WorkflowExecutionError ? err.logs : void 0;
|
|
611
|
-
const display = phases || logs ? `Workflow failed: ${message}
|
|
612
|
-
|
|
613
|
-
${safeStringifyDisplayPayload({
|
|
614
|
-
phases: phases ?? [],
|
|
615
|
-
logs: logs ?? []
|
|
616
|
-
})}` : `Workflow failed: ${message}`;
|
|
617
|
-
return {
|
|
618
|
-
llmContent: [{ text: `Workflow failed: ${message}` }],
|
|
619
|
-
returnDisplay: display,
|
|
620
|
-
// FIX-10 (REUSE-I1): use the standard ToolErrorType.EXECUTION_FAILED
|
|
621
|
-
// code so error routing / dashboards can classify workflow failures
|
|
622
|
-
// the same way as other execution-time tool errors.
|
|
623
|
-
error: { message, type: "execution_failed" /* EXECUTION_FAILED */ }
|
|
624
|
-
};
|
|
625
|
-
} finally {
|
|
626
|
-
dispatchController.abort();
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
function safeStringifyResult(result) {
|
|
631
|
-
if (result === void 0) return "(workflow returned no value)";
|
|
632
|
-
if (typeof result === "string") return result;
|
|
633
|
-
try {
|
|
634
|
-
return JSON.stringify(result, null, 2);
|
|
635
|
-
} catch {
|
|
636
|
-
return `(workflow returned a non-JSON-serializable value of type ${typeof result})`;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
__name(safeStringifyResult, "safeStringifyResult");
|
|
640
|
-
function safeStringifyDisplayPayload(payload) {
|
|
641
|
-
try {
|
|
642
|
-
return JSON.stringify(payload, null, 2);
|
|
643
|
-
} catch {
|
|
644
|
-
if (payload && typeof payload === "object") {
|
|
645
|
-
const sanitized = {};
|
|
646
|
-
for (const [key, value] of Object.entries(payload)) {
|
|
647
|
-
try {
|
|
648
|
-
JSON.stringify(value);
|
|
649
|
-
sanitized[key] = value;
|
|
650
|
-
} catch {
|
|
651
|
-
sanitized[key] = `(non-JSON-serializable value of type ${typeof value})`;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
try {
|
|
655
|
-
return JSON.stringify(sanitized, null, 2);
|
|
656
|
-
} catch {
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
return "(display payload not JSON-serializable)";
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
__name(safeStringifyDisplayPayload, "safeStringifyDisplayPayload");
|
|
663
|
-
function extractErrorMessage2(err) {
|
|
664
|
-
if (err && typeof err === "object" && "message" in err) {
|
|
665
|
-
const m = err.message;
|
|
666
|
-
if (typeof m === "string") return m;
|
|
667
|
-
return String(m);
|
|
668
|
-
}
|
|
669
|
-
return String(err);
|
|
670
|
-
}
|
|
671
|
-
__name(extractErrorMessage2, "extractErrorMessage");
|
|
672
|
-
var WorkflowTool = class extends BaseDeclarativeTool {
|
|
673
|
-
constructor(config, toolOptions = {}) {
|
|
674
|
-
super(
|
|
675
|
-
ToolNames.WORKFLOW,
|
|
676
|
-
ToolDisplayNames.WORKFLOW,
|
|
677
|
-
"Execute a workflow script that orchestrates subagents sequentially. P1 supports `phase`, `log`, and sequential `agent` only. No parallel, no pipeline, no schema, no resume, no background execution. Scripts run in a node:vm sandbox without access to the filesystem or shell; all I/O happens through the spawned agents.",
|
|
678
|
-
"other" /* Other */,
|
|
679
|
-
WORKFLOW_PARAM_SCHEMA,
|
|
680
|
-
/* isOutputMarkdown */
|
|
681
|
-
true,
|
|
682
|
-
/* canUpdateOutput */
|
|
683
|
-
false
|
|
684
|
-
);
|
|
685
|
-
this.config = config;
|
|
686
|
-
this.toolOptions = toolOptions;
|
|
687
|
-
}
|
|
688
|
-
static {
|
|
689
|
-
__name(this, "WorkflowTool");
|
|
690
|
-
}
|
|
691
|
-
validateToolParamValues(params) {
|
|
692
|
-
if (typeof params.script !== "string" || params.script.length === 0) {
|
|
693
|
-
return "WorkflowTool: `script` parameter is required and must be a non-empty string.";
|
|
694
|
-
}
|
|
695
|
-
return null;
|
|
696
|
-
}
|
|
697
|
-
createInvocation(params) {
|
|
698
|
-
return new WorkflowToolInvocation(this.config, this.toolOptions, params);
|
|
699
|
-
}
|
|
700
|
-
};
|
|
701
|
-
export {
|
|
702
|
-
WorkflowTool
|
|
703
|
-
};
|
|
704
|
-
/**
|
|
705
|
-
* @license
|
|
706
|
-
* Copyright 2025 Qwen
|
|
707
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
708
|
-
*/
|