@qwen-code/qwen-code 0.18.1 → 0.18.2
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/README.md +2 -1
- package/bundled/qc-helper/docs/common-workflow.md +4 -4
- package/bundled/qc-helper/docs/configuration/model-providers.md +1 -1
- package/bundled/qc-helper/docs/configuration/settings.md +77 -77
- package/bundled/qc-helper/docs/features/channels/feishu.md +16 -0
- package/bundled/qc-helper/docs/features/mcp.md +1 -1
- package/bundled/qc-helper/docs/features/sub-agents.md +3 -3
- package/bundled/qc-helper/docs/qwen-serve.md +24 -12
- package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +30 -30
- package/bundled/review/SKILL.md +10 -4
- package/bundled/simplify/SKILL.md +1 -1
- package/chunks/{agent-XT7NHZ5H.js → agent-P5U6QLWL.js} +5 -5
- package/chunks/{agent-headless-LNRE63ZL.js → agent-headless-24356DC7.js} +5 -5
- package/chunks/{anthropicContentGenerator-DCI26OQF.js → anthropicContentGenerator-KLBHYGH6.js} +1 -1
- package/chunks/{askUserQuestion-ITYUTWLR.js → askUserQuestion-QPZXR3UO.js} +1 -1
- package/chunks/{chunk-RON7LFNH.js → chunk-25FFAMED.js} +6 -6
- package/chunks/{chunk-7KPZFE5A.js → chunk-C64WAJOC.js} +1 -1
- package/chunks/{chunk-6T7Y7USE.js → chunk-EQ5NHJBY.js} +1354 -1028
- package/chunks/{chunk-IS7UA4W3.js → chunk-JZEKEWO5.js} +4 -4
- package/chunks/{chunk-XZTNBSMW.js → chunk-M7OBURJM.js} +1 -1
- package/chunks/{chunk-3NRO6NHX.js → chunk-MN5RAXVB.js} +3 -3
- package/chunks/{chunk-WJ3SND6W.js → chunk-NGDXHX3A.js} +2 -2
- package/chunks/{chunk-BXYRCW2C.js → chunk-QFJ67S5R.js} +10 -5
- package/chunks/{chunk-Y7KMDUEP.js → chunk-QP4R5FTG.js} +1 -1
- package/chunks/{chunk-QILTEBWS.js → chunk-RTTAC5VW.js} +1 -1
- package/chunks/{chunk-HQUWWSSP.js → chunk-VIEIRAK3.js} +1 -1
- package/chunks/{chunk-HED55F43.js → chunk-VU6A2OBJ.js} +15 -5
- package/chunks/{chunk-DHZREJTG.js → chunk-YJDVHAGL.js} +1 -1
- package/chunks/{chunk-A2ZIEEGJ.js → chunk-ZNUMXPNK.js} +592 -43
- package/chunks/{computer-use-4YX3JGBV.js → computer-use-EGW2I2HZ.js} +5 -5
- package/chunks/{contextCommand-KS2H7MW5.js → contextCommand-HI2X2Y7I.js} +7 -7
- package/chunks/{cron-create-CAPUKK7I.js → cron-create-DQKRQMCP.js} +1 -1
- package/chunks/{cron-delete-G3KAR26Q.js → cron-delete-DOFPHFTI.js} +1 -1
- package/chunks/{cron-list-ZA4ZIUS5.js → cron-list-RCVOO3CB.js} +1 -1
- package/chunks/{dist-VEGFONCF.js → dist-2UCAYOX7.js} +2 -2
- package/chunks/{dist-X4EXN7W6.js → dist-33LHH26D.js} +1 -1
- package/chunks/{dist-YLS6NI7H.js → dist-KF43SZZV.js} +1 -1
- package/chunks/{dist-7YWFWOCJ.js → dist-UH7CYT7F.js} +2 -2
- package/chunks/{edit-2ARPEO4B.js → edit-FJSOCDO2.js} +7 -9
- package/chunks/{enter-worktree-IXNXNAW5.js → enter-worktree-X6MVFDLR.js} +5 -5
- package/chunks/{enterPlanMode-TAKAGAYP.js → enterPlanMode-MZAEQZH3.js} +5 -5
- package/chunks/{exit-worktree-LHTRV7ML.js → exit-worktree-RM2UPOYQ.js} +5 -5
- package/chunks/{exitPlanMode-MK5UAITL.js → exitPlanMode-7BVY3CWJ.js} +7 -6
- package/chunks/{geminiContentGenerator-HFJIGO77.js → geminiContentGenerator-A6JHLUHK.js} +1 -1
- package/chunks/{glob-I2USLUSC.js → glob-L3AZLCV6.js} +5 -5
- package/chunks/{grep-WBIF7THR.js → grep-SNCPCXIP.js} +5 -5
- package/chunks/{ls-2R5RHLX5.js → ls-TRD77UTS.js} +1 -1
- package/chunks/{lsp-XKH6ZIAN.js → lsp-2VFWQPZS.js} +1 -1
- package/chunks/{monitor-WU7UFATU.js → monitor-TS6WL6DN.js} +5 -5
- package/chunks/{notebook-edit-KUHYPXEM.js → notebook-edit-26RNH24J.js} +6 -6
- package/chunks/{openaiContentGenerator-5PLHYJQL.js → openaiContentGenerator-7CA63X5G.js} +5 -5
- package/chunks/{qwenContentGenerator-TSKW73KY.js → qwenContentGenerator-4WJTJXFZ.js} +7 -7
- package/chunks/{read-file-VIPF2PS6.js → read-file-EUIHK6HD.js} +3 -3
- package/chunks/{ripGrep-XLIZTYE7.js → ripGrep-7J5B22W2.js} +5 -5
- package/chunks/{scheduler-O66SLJGU.js → scheduler-J3OUGTTS.js} +5 -5
- package/chunks/{send-message-CTME7DXD.js → send-message-QZOC5GA2.js} +1 -1
- package/chunks/{serve-BWOLYT62.js → serve-VF4ZNUJP.js} +709 -26
- package/chunks/{shell-XE7UYKOO.js → shell-G6XCJAG3.js} +5 -5
- package/chunks/{skill-RZWM6XMC.js → skill-7OVC6JIH.js} +3 -3
- package/chunks/{src-L5P7K4MH.js → src-XV5MLRND.js} +11 -5
- package/chunks/{syntheticOutput-ZJGSU7OQ.js → syntheticOutput-WJSUK4SZ.js} +2 -2
- package/chunks/{task-create-EE6JEM7G.js → task-create-GGSC27HO.js} +2 -2
- package/chunks/{task-list-EESYAC65.js → task-list-EDHHHSK4.js} +1 -1
- package/chunks/{task-stop-XZVCFFYY.js → task-stop-WR5PDVZY.js} +1 -1
- package/chunks/{task-update-EIO4HNE3.js → task-update-UR7NUHBV.js} +2 -2
- package/chunks/{team-create-R2H7Y3SG.js → team-create-JXSC7ROC.js} +5 -5
- package/chunks/{team-delete-A7LXPGV7.js → team-delete-FC33URJK.js} +1 -1
- package/chunks/{todoWrite-VRKSGAWM.js → todoWrite-GO2ME7ZV.js} +1 -1
- package/chunks/{tool-search-USSQMTMS.js → tool-search-YRWSWA2H.js} +3 -3
- package/chunks/{web-fetch-GHAZUA54.js → web-fetch-NLLATYIL.js} +2 -2
- package/chunks/{workflow-5LNNLNUR.js → workflow-ZN3DYFMU.js} +249 -24
- package/chunks/{write-file-2I7HP24C.js → write-file-355M4V7Z.js} +6 -6
- package/cli.js +1092 -491
- package/package.json +2 -2
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
generateAgentWorktreeSlug,
|
|
9
9
|
rebuildToolRegistryOnOverride,
|
|
10
10
|
writeWorktreeSessionMarker
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-EQ5NHJBY.js";
|
|
12
12
|
import "./chunk-K5PGHDBN.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-VIEIRAK3.js";
|
|
14
14
|
import "./chunk-O4PICXES.js";
|
|
15
15
|
import "./chunk-TW522KN6.js";
|
|
16
16
|
import "./chunk-BJ5HQ23U.js";
|
|
@@ -24,7 +24,7 @@ import "./chunk-CPVI5J2L.js";
|
|
|
24
24
|
import "./chunk-ZMIBJS45.js";
|
|
25
25
|
import "./chunk-77WXWU44.js";
|
|
26
26
|
import "./chunk-B4ZF2KSI.js";
|
|
27
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-25FFAMED.js";
|
|
28
28
|
import "./chunk-3PJXIDKI.js";
|
|
29
29
|
import "./chunk-UWCTAVOD.js";
|
|
30
30
|
import "./chunk-OFEVLU4C.js";
|
|
@@ -32,13 +32,13 @@ import "./chunk-IQHSD7K5.js";
|
|
|
32
32
|
import "./chunk-LYRSMKLS.js";
|
|
33
33
|
import {
|
|
34
34
|
SyntheticOutputTool
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-RTTAC5VW.js";
|
|
36
36
|
import {
|
|
37
37
|
BaseDeclarativeTool,
|
|
38
38
|
BaseToolInvocation,
|
|
39
39
|
ToolDisplayNames,
|
|
40
40
|
ToolNames
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-ZNUMXPNK.js";
|
|
42
42
|
import "./chunk-IDYDPBBN.js";
|
|
43
43
|
import "./chunk-FIQECJTQ.js";
|
|
44
44
|
import {
|
|
@@ -75,10 +75,10 @@ import * as os from "node:os";
|
|
|
75
75
|
// packages/core/src/agents/runtime/workflow-sandbox.ts
|
|
76
76
|
init_esbuild_shims();
|
|
77
77
|
import * as vm from "node:vm";
|
|
78
|
-
function
|
|
78
|
+
function findMetaBlockBounds(source) {
|
|
79
79
|
const re = /^\s*export\s+const\s+meta\s*=\s*\{/;
|
|
80
80
|
const match = re.exec(source);
|
|
81
|
-
if (!match) return
|
|
81
|
+
if (!match) return null;
|
|
82
82
|
const exportIdx = match.index;
|
|
83
83
|
const startBrace = source.indexOf("{", exportIdx);
|
|
84
84
|
let depth = 1;
|
|
@@ -136,10 +136,114 @@ function stripExportMeta(source) {
|
|
|
136
136
|
"stripExportMeta: unbalanced braces in export const meta declaration \u2014 the workflow script cannot be safely stripped. Check the meta block syntax."
|
|
137
137
|
);
|
|
138
138
|
}
|
|
139
|
+
const endBraceIncl = i - 1;
|
|
139
140
|
while (i < source.length && /[\s;]/.test(source[i])) i++;
|
|
140
|
-
return
|
|
141
|
+
return { exportIdx, startBrace, endBraceIncl, afterMeta: i };
|
|
141
142
|
}
|
|
142
|
-
__name(
|
|
143
|
+
__name(findMetaBlockBounds, "findMetaBlockBounds");
|
|
144
|
+
function extractAndStripMeta(source) {
|
|
145
|
+
const bounds = findMetaBlockBounds(source);
|
|
146
|
+
if (!bounds) return { stripped: source, meta: null };
|
|
147
|
+
const metaSource = source.slice(bounds.startBrace, bounds.endBraceIncl + 1);
|
|
148
|
+
const stripped = source.slice(0, bounds.exportIdx) + source.slice(bounds.afterMeta);
|
|
149
|
+
const metaContext = vm.createContext(/* @__PURE__ */ Object.create(null));
|
|
150
|
+
let raw;
|
|
151
|
+
try {
|
|
152
|
+
raw = new vm.Script(`(${metaSource})`).runInContext(metaContext);
|
|
153
|
+
} catch (e) {
|
|
154
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
155
|
+
throw new Error(
|
|
156
|
+
`extractAndStripMeta: failed to evaluate meta object literal: ${msg}`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
rejectThenablesInMeta(raw);
|
|
160
|
+
const meta = validateMeta(raw);
|
|
161
|
+
return { stripped, meta };
|
|
162
|
+
}
|
|
163
|
+
__name(extractAndStripMeta, "extractAndStripMeta");
|
|
164
|
+
function rejectThenablesInMeta(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
165
|
+
if (value === null || typeof value !== "object") return;
|
|
166
|
+
if (seen.has(value)) return;
|
|
167
|
+
seen.add(value);
|
|
168
|
+
const maybeThen = value.then;
|
|
169
|
+
if (typeof maybeThen === "function") {
|
|
170
|
+
try {
|
|
171
|
+
value.catch(() => {
|
|
172
|
+
});
|
|
173
|
+
} catch {
|
|
174
|
+
}
|
|
175
|
+
throw new Error(
|
|
176
|
+
"extractAndStripMeta: meta values must not be Promises (no async / dynamic import allowed in meta literal)"
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
if (Array.isArray(value)) {
|
|
180
|
+
for (const v of value) rejectThenablesInMeta(v, seen);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
for (const v of Object.values(value)) {
|
|
184
|
+
rejectThenablesInMeta(v, seen);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
__name(rejectThenablesInMeta, "rejectThenablesInMeta");
|
|
188
|
+
function validateMeta(value) {
|
|
189
|
+
if (value === null || typeof value !== "object") {
|
|
190
|
+
throw new Error("meta must be an object");
|
|
191
|
+
}
|
|
192
|
+
const obj = value;
|
|
193
|
+
if (typeof obj["name"] !== "string" || obj["name"].length === 0) {
|
|
194
|
+
throw new Error("meta.name must be a non-empty string");
|
|
195
|
+
}
|
|
196
|
+
if (typeof obj["description"] !== "string" || obj["description"].length === 0) {
|
|
197
|
+
throw new Error("meta.description must be a non-empty string");
|
|
198
|
+
}
|
|
199
|
+
if (obj["whenToUse"] !== void 0 && typeof obj["whenToUse"] !== "string") {
|
|
200
|
+
throw new Error("meta.whenToUse must be a string");
|
|
201
|
+
}
|
|
202
|
+
let phases;
|
|
203
|
+
if (obj["phases"] !== void 0) {
|
|
204
|
+
if (!Array.isArray(obj["phases"])) {
|
|
205
|
+
throw new Error("meta.phases must be an array");
|
|
206
|
+
}
|
|
207
|
+
phases = [];
|
|
208
|
+
for (const p of obj["phases"]) {
|
|
209
|
+
if (p === null || typeof p !== "object") {
|
|
210
|
+
throw new Error("meta.phases entries must be objects");
|
|
211
|
+
}
|
|
212
|
+
const ph = p;
|
|
213
|
+
if (typeof ph["title"] !== "string" || ph["title"].length === 0) {
|
|
214
|
+
throw new Error("meta.phases[].title must be a non-empty string");
|
|
215
|
+
}
|
|
216
|
+
const phase = {
|
|
217
|
+
title: ph["title"]
|
|
218
|
+
};
|
|
219
|
+
if (ph["detail"] !== void 0) {
|
|
220
|
+
if (typeof ph["detail"] !== "string") {
|
|
221
|
+
throw new Error("meta.phases[].detail must be a string");
|
|
222
|
+
}
|
|
223
|
+
phase.detail = ph["detail"];
|
|
224
|
+
}
|
|
225
|
+
if (ph["model"] !== void 0) {
|
|
226
|
+
if (typeof ph["model"] !== "string") {
|
|
227
|
+
throw new Error("meta.phases[].model must be a string");
|
|
228
|
+
}
|
|
229
|
+
phase.model = ph["model"];
|
|
230
|
+
}
|
|
231
|
+
phases.push(phase);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const out = {
|
|
235
|
+
name: obj["name"],
|
|
236
|
+
description: obj["description"]
|
|
237
|
+
};
|
|
238
|
+
if (obj["whenToUse"] !== void 0) {
|
|
239
|
+
out.whenToUse = obj["whenToUse"];
|
|
240
|
+
}
|
|
241
|
+
if (phases !== void 0) {
|
|
242
|
+
out.phases = phases;
|
|
243
|
+
}
|
|
244
|
+
return out;
|
|
245
|
+
}
|
|
246
|
+
__name(validateMeta, "validateMeta");
|
|
143
247
|
function isRegexContext(source, i) {
|
|
144
248
|
let j = i - 1;
|
|
145
249
|
while (j >= 0 && /\s/.test(source[j])) j--;
|
|
@@ -202,14 +306,27 @@ function createWorkflowSandbox(opts) {
|
|
|
202
306
|
const logs = [];
|
|
203
307
|
const safeLog = /* @__PURE__ */ __name((msg) => {
|
|
204
308
|
if (logs.length < MAX_LOG_LINES) {
|
|
205
|
-
|
|
309
|
+
const line = String(msg);
|
|
310
|
+
logs.push(line);
|
|
311
|
+
try {
|
|
312
|
+
opts.emitter?.logAppended?.(line);
|
|
313
|
+
} catch (e) {
|
|
314
|
+
debugLogger.warn("emitter.logAppended threw:", e);
|
|
315
|
+
}
|
|
206
316
|
} else if (logs.length === MAX_LOG_LINES) {
|
|
207
317
|
logs.push(`[workflow log truncated at ${MAX_LOG_LINES} lines]`);
|
|
208
318
|
}
|
|
209
319
|
}, "safeLog");
|
|
210
320
|
const safePhase = /* @__PURE__ */ __name((title) => {
|
|
211
321
|
if (phases.length < MAX_PHASE_ENTRIES) {
|
|
212
|
-
|
|
322
|
+
const t = String(title);
|
|
323
|
+
if (phases[phases.length - 1] === t) return;
|
|
324
|
+
phases.push(t);
|
|
325
|
+
try {
|
|
326
|
+
opts.emitter?.phaseStarted?.(t);
|
|
327
|
+
} catch (e) {
|
|
328
|
+
debugLogger.warn("emitter.phaseStarted threw:", e);
|
|
329
|
+
}
|
|
213
330
|
} else if (phases.length === MAX_PHASE_ENTRIES) {
|
|
214
331
|
phases.push(
|
|
215
332
|
`[workflow phases truncated at ${MAX_PHASE_ENTRIES} entries]`
|
|
@@ -569,9 +686,11 @@ function createWorkflowSandbox(opts) {
|
|
|
569
686
|
{ filename: "workflow-sandbox-init.js" }
|
|
570
687
|
);
|
|
571
688
|
const maxWallClockMs = resolveMaxWallClockMs(opts);
|
|
689
|
+
let extractedMeta = null;
|
|
572
690
|
return {
|
|
573
691
|
async run(scriptSource) {
|
|
574
|
-
const stripped =
|
|
692
|
+
const { stripped, meta } = extractAndStripMeta(scriptSource);
|
|
693
|
+
extractedMeta = meta;
|
|
575
694
|
const wrapped = `(async () => {
|
|
576
695
|
${stripped}
|
|
577
696
|
})()`;
|
|
@@ -601,7 +720,8 @@ ${stripped}
|
|
|
601
720
|
}
|
|
602
721
|
},
|
|
603
722
|
getPhases: /* @__PURE__ */ __name(() => [...phases], "getPhases"),
|
|
604
|
-
getLogs: /* @__PURE__ */ __name(() => [...logs], "getLogs")
|
|
723
|
+
getLogs: /* @__PURE__ */ __name(() => [...logs], "getLogs"),
|
|
724
|
+
getMeta: /* @__PURE__ */ __name(() => extractedMeta, "getMeta")
|
|
605
725
|
};
|
|
606
726
|
}
|
|
607
727
|
__name(createWorkflowSandbox, "createWorkflowSandbox");
|
|
@@ -718,10 +838,11 @@ var WORKFLOW_SUBAGENT_DISALLOWED_TOOLS = [
|
|
|
718
838
|
ToolNames.EXIT_PLAN_MODE
|
|
719
839
|
];
|
|
720
840
|
var WorkflowExecutionError = class extends Error {
|
|
721
|
-
constructor(message, phases, logs) {
|
|
841
|
+
constructor(message, phases, logs, meta = null) {
|
|
722
842
|
super(message);
|
|
723
843
|
this.phases = phases;
|
|
724
844
|
this.logs = logs;
|
|
845
|
+
this.meta = meta;
|
|
725
846
|
}
|
|
726
847
|
static {
|
|
727
848
|
__name(this, "WorkflowExecutionError");
|
|
@@ -738,7 +859,7 @@ function sanitizeForErrorMessage(value) {
|
|
|
738
859
|
__name(sanitizeForErrorMessage, "sanitizeForErrorMessage");
|
|
739
860
|
function createProductionDispatch(config, signal) {
|
|
740
861
|
return async (prompt, opts) => {
|
|
741
|
-
const { AgentHeadless, ContextState } = await import("./agent-headless-
|
|
862
|
+
const { AgentHeadless, ContextState } = await import("./agent-headless-24356DC7.js");
|
|
742
863
|
const ctx = new ContextState();
|
|
743
864
|
ctx.set("task_prompt", prompt);
|
|
744
865
|
if (opts.agentType === void 0 && opts.model === void 0 && opts.isolation === void 0 && opts.schema === void 0) {
|
|
@@ -1134,11 +1255,12 @@ var WorkflowOrchestrator = class {
|
|
|
1134
1255
|
__name(this, "WorkflowOrchestrator");
|
|
1135
1256
|
}
|
|
1136
1257
|
async run(req) {
|
|
1137
|
-
const runId = generateRunId();
|
|
1258
|
+
const runId = req.runId ?? generateRunId();
|
|
1138
1259
|
const maxAgents = resolveMaxAgentsPerRun();
|
|
1139
1260
|
const signal = req.abortOnTimeout?.signal;
|
|
1140
1261
|
const limiter = createConcurrencyLimiter(resolveConcurrencyLimit(), signal);
|
|
1141
1262
|
let agentCount = 0;
|
|
1263
|
+
const emitter = req.emitter;
|
|
1142
1264
|
const countedDispatch = /* @__PURE__ */ __name((prompt, opts) => {
|
|
1143
1265
|
agentCount += 1;
|
|
1144
1266
|
if (agentCount > maxAgents) {
|
|
@@ -1148,7 +1270,31 @@ var WorkflowOrchestrator = class {
|
|
|
1148
1270
|
)
|
|
1149
1271
|
);
|
|
1150
1272
|
}
|
|
1151
|
-
|
|
1273
|
+
const label = typeof opts.label === "string" ? opts.label : void 0;
|
|
1274
|
+
try {
|
|
1275
|
+
emitter?.agentDispatched?.(label);
|
|
1276
|
+
} catch (e) {
|
|
1277
|
+
debugLogger.warn("emitter.agentDispatched threw:", e);
|
|
1278
|
+
}
|
|
1279
|
+
return limiter.run(() => this.dispatch(prompt, opts)).then(
|
|
1280
|
+
(result) => {
|
|
1281
|
+
try {
|
|
1282
|
+
emitter?.agentCompleted?.(label);
|
|
1283
|
+
} catch (e) {
|
|
1284
|
+
debugLogger.warn("emitter.agentCompleted threw:", e);
|
|
1285
|
+
}
|
|
1286
|
+
return result;
|
|
1287
|
+
},
|
|
1288
|
+
(err) => {
|
|
1289
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1290
|
+
try {
|
|
1291
|
+
emitter?.agentCompleted?.(label, msg);
|
|
1292
|
+
} catch (e) {
|
|
1293
|
+
debugLogger.warn("emitter.agentCompleted threw:", e);
|
|
1294
|
+
}
|
|
1295
|
+
throw err;
|
|
1296
|
+
}
|
|
1297
|
+
);
|
|
1152
1298
|
}, "countedDispatch");
|
|
1153
1299
|
const parallelImpl = makeParallelImpl(signal);
|
|
1154
1300
|
const pipelineImpl = makePipelineImpl(signal);
|
|
@@ -1157,7 +1303,8 @@ var WorkflowOrchestrator = class {
|
|
|
1157
1303
|
dispatch: countedDispatch,
|
|
1158
1304
|
parallel: parallelImpl,
|
|
1159
1305
|
pipeline: pipelineImpl,
|
|
1160
|
-
abortOnTimeout: req.abortOnTimeout
|
|
1306
|
+
abortOnTimeout: req.abortOnTimeout,
|
|
1307
|
+
emitter
|
|
1161
1308
|
});
|
|
1162
1309
|
try {
|
|
1163
1310
|
const result = await sandbox.run(req.script);
|
|
@@ -1165,13 +1312,15 @@ var WorkflowOrchestrator = class {
|
|
|
1165
1312
|
runId,
|
|
1166
1313
|
result,
|
|
1167
1314
|
phases: sandbox.getPhases(),
|
|
1168
|
-
logs: sandbox.getLogs()
|
|
1315
|
+
logs: sandbox.getLogs(),
|
|
1316
|
+
meta: sandbox.getMeta()
|
|
1169
1317
|
};
|
|
1170
1318
|
} catch (err) {
|
|
1171
1319
|
throw new WorkflowExecutionError(
|
|
1172
1320
|
extractErrorMessage(err),
|
|
1173
1321
|
sandbox.getPhases(),
|
|
1174
|
-
sandbox.getLogs()
|
|
1322
|
+
sandbox.getLogs(),
|
|
1323
|
+
sandbox.getMeta()
|
|
1175
1324
|
);
|
|
1176
1325
|
}
|
|
1177
1326
|
}
|
|
@@ -1258,6 +1407,7 @@ function extractErrorMessage(err) {
|
|
|
1258
1407
|
__name(extractErrorMessage, "extractErrorMessage");
|
|
1259
1408
|
|
|
1260
1409
|
// packages/core/src/tools/workflow/workflow.ts
|
|
1410
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
1261
1411
|
var WORKFLOW_PARAM_SCHEMA = {
|
|
1262
1412
|
type: "object",
|
|
1263
1413
|
properties: {
|
|
@@ -1289,19 +1439,58 @@ var WorkflowToolInvocation = class extends BaseToolInvocation {
|
|
|
1289
1439
|
getDefaultPermission() {
|
|
1290
1440
|
return Promise.resolve("ask");
|
|
1291
1441
|
}
|
|
1292
|
-
async execute(signal,
|
|
1442
|
+
async execute(signal, updateOutput, _shellExecutionConfig) {
|
|
1293
1443
|
const dispatchController = createChildAbortController(signal);
|
|
1294
1444
|
const dispatch = this.toolOptions.dispatch ?? createProductionDispatch(this.config, dispatchController.signal);
|
|
1295
1445
|
const orchestrator = new WorkflowOrchestrator(dispatch);
|
|
1446
|
+
const runId = `wf_${randomBytes2(8).toString("hex")}`;
|
|
1447
|
+
const registry = this.config.getWorkflowRunRegistry?.();
|
|
1448
|
+
const registryEntry = registry?.register({
|
|
1449
|
+
runId,
|
|
1450
|
+
meta: null,
|
|
1451
|
+
// populated after meta parses; safe default until then
|
|
1452
|
+
status: "running",
|
|
1453
|
+
startTime: Date.now(),
|
|
1454
|
+
outputFile: "",
|
|
1455
|
+
// P4b reserves the field but doesn't materialize
|
|
1456
|
+
abortController: dispatchController
|
|
1457
|
+
});
|
|
1458
|
+
const emitter = {
|
|
1459
|
+
phaseStarted: /* @__PURE__ */ __name((title) => {
|
|
1460
|
+
registry?.onPhaseStarted(runId, title);
|
|
1461
|
+
safeEmitUpdate(updateOutput, registryEntry);
|
|
1462
|
+
}, "phaseStarted"),
|
|
1463
|
+
agentDispatched: /* @__PURE__ */ __name(() => {
|
|
1464
|
+
registry?.onAgentDispatched(runId);
|
|
1465
|
+
safeEmitUpdate(updateOutput, registryEntry);
|
|
1466
|
+
}, "agentDispatched"),
|
|
1467
|
+
agentCompleted: /* @__PURE__ */ __name(() => {
|
|
1468
|
+
registry?.onAgentCompleted(runId);
|
|
1469
|
+
safeEmitUpdate(updateOutput, registryEntry);
|
|
1470
|
+
}, "agentCompleted"),
|
|
1471
|
+
logAppended: /* @__PURE__ */ __name(() => {
|
|
1472
|
+
}, "logAppended")
|
|
1473
|
+
};
|
|
1296
1474
|
try {
|
|
1297
1475
|
const outcome = await orchestrator.run({
|
|
1298
1476
|
script: this.params.script,
|
|
1299
1477
|
args: this.params.args,
|
|
1300
|
-
abortOnTimeout: dispatchController
|
|
1478
|
+
abortOnTimeout: dispatchController,
|
|
1479
|
+
runId,
|
|
1480
|
+
emitter
|
|
1301
1481
|
});
|
|
1482
|
+
if (registryEntry) {
|
|
1483
|
+
registryEntry.meta = outcome.meta;
|
|
1484
|
+
if (outcome.meta?.name && registryEntry.description === runId) {
|
|
1485
|
+
registryEntry.description = outcome.meta.name;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
registry?.setRecentLogs(runId, outcome.logs);
|
|
1489
|
+
registry?.complete(runId, outcome.result, Date.now());
|
|
1302
1490
|
const llmText = safeStringifyResult(outcome.result);
|
|
1303
1491
|
const displayJson = safeStringifyDisplayPayload({
|
|
1304
1492
|
runId: outcome.runId,
|
|
1493
|
+
...outcome.meta ? { meta: outcome.meta } : {},
|
|
1305
1494
|
phases: outcome.phases,
|
|
1306
1495
|
logs: outcome.logs,
|
|
1307
1496
|
result: outcome.result
|
|
@@ -1314,9 +1503,20 @@ var WorkflowToolInvocation = class extends BaseToolInvocation {
|
|
|
1314
1503
|
const message = extractErrorMessage2(err);
|
|
1315
1504
|
const phases = err instanceof WorkflowExecutionError ? err.phases : void 0;
|
|
1316
1505
|
const logs = err instanceof WorkflowExecutionError ? err.logs : void 0;
|
|
1317
|
-
const
|
|
1506
|
+
const meta = err instanceof WorkflowExecutionError ? err.meta : void 0;
|
|
1507
|
+
if (registryEntry) {
|
|
1508
|
+
if (meta && !registryEntry.meta) registryEntry.meta = meta;
|
|
1509
|
+
}
|
|
1510
|
+
if (logs) registry?.setRecentLogs(runId, logs);
|
|
1511
|
+
if (signal.aborted) {
|
|
1512
|
+
registry?.cancel(runId, Date.now());
|
|
1513
|
+
} else {
|
|
1514
|
+
registry?.fail(runId, message, Date.now());
|
|
1515
|
+
}
|
|
1516
|
+
const display = phases || logs || meta ? `Workflow failed: ${message}
|
|
1318
1517
|
|
|
1319
1518
|
${safeStringifyDisplayPayload({
|
|
1519
|
+
...meta ? { meta } : {},
|
|
1320
1520
|
phases: phases ?? [],
|
|
1321
1521
|
logs: logs ?? []
|
|
1322
1522
|
})}` : `Workflow failed: ${message}`;
|
|
@@ -1333,6 +1533,31 @@ ${safeStringifyDisplayPayload({
|
|
|
1333
1533
|
}
|
|
1334
1534
|
}
|
|
1335
1535
|
};
|
|
1536
|
+
function buildLivePhaseTreeDisplay(entry) {
|
|
1537
|
+
const payload = {
|
|
1538
|
+
runId: entry.runId,
|
|
1539
|
+
...entry.meta ? { meta: entry.meta } : {},
|
|
1540
|
+
status: entry.status,
|
|
1541
|
+
currentPhase: entry.currentPhase,
|
|
1542
|
+
phases: entry.phases,
|
|
1543
|
+
agentsDispatched: entry.agentsDispatched,
|
|
1544
|
+
agentsCompleted: entry.agentsCompleted
|
|
1545
|
+
};
|
|
1546
|
+
try {
|
|
1547
|
+
return "```json\n" + JSON.stringify(payload, null, 2) + "\n```";
|
|
1548
|
+
} catch {
|
|
1549
|
+
return `Workflow ${entry.runId} \u2014 ${entry.status} \u2014 ${entry.phases.length} phase(s)`;
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
__name(buildLivePhaseTreeDisplay, "buildLivePhaseTreeDisplay");
|
|
1553
|
+
function safeEmitUpdate(updateOutput, entry) {
|
|
1554
|
+
if (!updateOutput || !entry) return;
|
|
1555
|
+
try {
|
|
1556
|
+
updateOutput(buildLivePhaseTreeDisplay(entry));
|
|
1557
|
+
} catch {
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
__name(safeEmitUpdate, "safeEmitUpdate");
|
|
1336
1561
|
function safeStringifyResult(result) {
|
|
1337
1562
|
if (result === void 0) return "(workflow returned no value)";
|
|
1338
1563
|
if (typeof result === "string") return result;
|
|
@@ -1386,7 +1611,7 @@ var WorkflowTool = class extends BaseDeclarativeTool {
|
|
|
1386
1611
|
/* isOutputMarkdown */
|
|
1387
1612
|
true,
|
|
1388
1613
|
/* canUpdateOutput */
|
|
1389
|
-
|
|
1614
|
+
true
|
|
1390
1615
|
);
|
|
1391
1616
|
this.config = config;
|
|
1392
1617
|
this.toolOptions = toolOptions;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import {
|
|
4
4
|
StructuredToolError,
|
|
5
5
|
checkPriorRead
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-C64WAJOC.js";
|
|
7
7
|
import {
|
|
8
8
|
CommitAttributionService,
|
|
9
9
|
DEFAULT_DIFF_OPTIONS,
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
detectLineEnding,
|
|
13
13
|
getDiffStat,
|
|
14
14
|
needsUtf8Bom
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-EQ5NHJBY.js";
|
|
16
16
|
import "./chunk-K5PGHDBN.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-VIEIRAK3.js";
|
|
18
18
|
import "./chunk-O4PICXES.js";
|
|
19
19
|
import "./chunk-TW522KN6.js";
|
|
20
20
|
import "./chunk-BJ5HQ23U.js";
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
getLanguageFromFilePath,
|
|
35
35
|
getSpecificMimeType,
|
|
36
36
|
logFileOperation
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-25FFAMED.js";
|
|
38
38
|
import "./chunk-3PJXIDKI.js";
|
|
39
39
|
import "./chunk-UWCTAVOD.js";
|
|
40
40
|
import "./chunk-OFEVLU4C.js";
|
|
@@ -42,13 +42,13 @@ import {
|
|
|
42
42
|
isAnyAutoMemPath
|
|
43
43
|
} from "./chunk-IQHSD7K5.js";
|
|
44
44
|
import "./chunk-LYRSMKLS.js";
|
|
45
|
-
import "./chunk-
|
|
45
|
+
import "./chunk-RTTAC5VW.js";
|
|
46
46
|
import {
|
|
47
47
|
BaseDeclarativeTool,
|
|
48
48
|
BaseToolInvocation,
|
|
49
49
|
ToolDisplayNames,
|
|
50
50
|
ToolNames
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-ZNUMXPNK.js";
|
|
52
52
|
import "./chunk-IDYDPBBN.js";
|
|
53
53
|
import "./chunk-FIQECJTQ.js";
|
|
54
54
|
import "./chunk-64WXLC72.js";
|