@probelabs/probe 0.6.0-rc278 → 0.6.0-rc279
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/bin/binaries/probe-v0.6.0-rc279-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc279-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/{probe-v0.6.0-rc278-x86_64-apple-darwin.tar.gz → probe-v0.6.0-rc279-x86_64-apple-darwin.tar.gz} +0 -0
- package/bin/binaries/probe-v0.6.0-rc279-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc279-x86_64-unknown-linux-musl.tar.gz +0 -0
- package/build/agent/ProbeAgent.js +63 -2
- package/build/agent/index.js +98 -13
- package/build/delegate.js +40 -11
- package/build/tools/analyzeAll.js +8 -4
- package/build/tools/vercel.js +7 -4
- package/cjs/agent/ProbeAgent.cjs +101 -14
- package/cjs/index.cjs +98 -13
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +63 -2
- package/src/delegate.js +40 -11
- package/src/tools/analyzeAll.js +8 -4
- package/src/tools/vercel.js +7 -4
- package/bin/binaries/probe-v0.6.0-rc278-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc278-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc278-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc278-x86_64-unknown-linux-musl.tar.gz +0 -0
package/cjs/agent/ProbeAgent.cjs
CHANGED
|
@@ -31241,12 +31241,17 @@ async function delegate({
|
|
|
31241
31241
|
mcpConfigPath = null,
|
|
31242
31242
|
delegationManager = null,
|
|
31243
31243
|
// Optional per-instance manager, falls back to default singleton
|
|
31244
|
-
concurrencyLimiter = null
|
|
31244
|
+
concurrencyLimiter = null,
|
|
31245
31245
|
// Optional global AI concurrency limiter
|
|
31246
|
+
parentAbortSignal = null
|
|
31247
|
+
// Optional AbortSignal from parent to cancel this delegation
|
|
31246
31248
|
}) {
|
|
31247
31249
|
if (!task || typeof task !== "string") {
|
|
31248
31250
|
throw new Error("Task parameter is required and must be a string");
|
|
31249
31251
|
}
|
|
31252
|
+
if (parentAbortSignal?.aborted) {
|
|
31253
|
+
throw new Error("Delegation cancelled: parent operation was aborted");
|
|
31254
|
+
}
|
|
31250
31255
|
const hasExplicitTimeout = Object.prototype.hasOwnProperty.call(arguments?.[0] ?? {}, "timeout");
|
|
31251
31256
|
if (!hasExplicitTimeout) {
|
|
31252
31257
|
const envTimeoutMs = parseInt(process.env.DELEGATION_TIMEOUT_MS || "", 10);
|
|
@@ -31331,12 +31336,37 @@ async function delegate({
|
|
|
31331
31336
|
}
|
|
31332
31337
|
const timeoutPromise = new Promise((_, reject2) => {
|
|
31333
31338
|
timeoutId = setTimeout(() => {
|
|
31339
|
+
subagent.cancel();
|
|
31334
31340
|
reject2(new Error(`Delegation timed out after ${timeout} seconds`));
|
|
31335
31341
|
}, timeout * 1e3);
|
|
31336
31342
|
});
|
|
31343
|
+
let parentAbortHandler;
|
|
31344
|
+
const parentAbortPromise = new Promise((_, reject2) => {
|
|
31345
|
+
if (parentAbortSignal) {
|
|
31346
|
+
if (parentAbortSignal.aborted) {
|
|
31347
|
+
subagent.cancel();
|
|
31348
|
+
reject2(new Error("Delegation cancelled: parent operation was aborted"));
|
|
31349
|
+
return;
|
|
31350
|
+
}
|
|
31351
|
+
parentAbortHandler = () => {
|
|
31352
|
+
subagent.cancel();
|
|
31353
|
+
reject2(new Error("Delegation cancelled: parent operation was aborted"));
|
|
31354
|
+
};
|
|
31355
|
+
parentAbortSignal.addEventListener("abort", parentAbortHandler, { once: true });
|
|
31356
|
+
}
|
|
31357
|
+
});
|
|
31337
31358
|
const answerOptions = schema ? { schema } : void 0;
|
|
31338
31359
|
const answerPromise = answerOptions ? subagent.answer(task, [], answerOptions) : subagent.answer(task);
|
|
31339
|
-
const
|
|
31360
|
+
const racers = [answerPromise, timeoutPromise];
|
|
31361
|
+
if (parentAbortSignal) racers.push(parentAbortPromise);
|
|
31362
|
+
let response;
|
|
31363
|
+
try {
|
|
31364
|
+
response = await Promise.race(racers);
|
|
31365
|
+
} finally {
|
|
31366
|
+
if (parentAbortHandler && parentAbortSignal) {
|
|
31367
|
+
parentAbortSignal.removeEventListener("abort", parentAbortHandler);
|
|
31368
|
+
}
|
|
31369
|
+
}
|
|
31340
31370
|
if (timeoutId !== null) {
|
|
31341
31371
|
clearTimeout(timeoutId);
|
|
31342
31372
|
timeoutId = null;
|
|
@@ -31749,8 +31779,9 @@ Instructions:
|
|
|
31749
31779
|
promptType: "code-researcher",
|
|
31750
31780
|
allowedTools: ["extract"],
|
|
31751
31781
|
maxIterations: 5,
|
|
31752
|
-
delegationManager: options.delegationManager
|
|
31782
|
+
delegationManager: options.delegationManager,
|
|
31753
31783
|
// Per-instance delegation limits
|
|
31784
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
31754
31785
|
// timeout removed - inherit default from delegate (300s)
|
|
31755
31786
|
});
|
|
31756
31787
|
return { chunk, result };
|
|
@@ -31849,8 +31880,9 @@ Organize all findings into clear categories with items listed under each.${compl
|
|
|
31849
31880
|
promptType: "code-researcher",
|
|
31850
31881
|
allowedTools: [],
|
|
31851
31882
|
maxIterations: 5,
|
|
31852
|
-
delegationManager: options.delegationManager
|
|
31883
|
+
delegationManager: options.delegationManager,
|
|
31853
31884
|
// Per-instance delegation limits
|
|
31885
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
31854
31886
|
// timeout removed - inherit default from delegate (300s)
|
|
31855
31887
|
});
|
|
31856
31888
|
return result;
|
|
@@ -31914,8 +31946,9 @@ CRITICAL: Do NOT guess keywords. Actually run searches and see what returns resu
|
|
|
31914
31946
|
promptType: "code-researcher",
|
|
31915
31947
|
// Full tool access for exploration and experimentation
|
|
31916
31948
|
maxIterations: 15,
|
|
31917
|
-
delegationManager: options.delegationManager
|
|
31949
|
+
delegationManager: options.delegationManager,
|
|
31918
31950
|
// Per-instance delegation limits
|
|
31951
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
31919
31952
|
// timeout removed - inherit default from delegate (300s)
|
|
31920
31953
|
});
|
|
31921
31954
|
const plan = parsePlanningResult(stripResultTags(result));
|
|
@@ -31972,8 +32005,9 @@ When done, use the attempt_completion tool with your answer as the result.`;
|
|
|
31972
32005
|
promptType: "code-researcher",
|
|
31973
32006
|
allowedTools: [],
|
|
31974
32007
|
maxIterations: 5,
|
|
31975
|
-
delegationManager: options.delegationManager
|
|
32008
|
+
delegationManager: options.delegationManager,
|
|
31976
32009
|
// Per-instance delegation limits
|
|
32010
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
31977
32011
|
// timeout removed - inherit default from delegate (300s)
|
|
31978
32012
|
});
|
|
31979
32013
|
return stripResultTags(result);
|
|
@@ -36657,7 +36691,8 @@ var init_vercel = __esm({
|
|
|
36657
36691
|
promptType: "code-searcher",
|
|
36658
36692
|
allowedTools: ["search", "extract", "listFiles", "attempt_completion"],
|
|
36659
36693
|
searchDelegate: false,
|
|
36660
|
-
schema: CODE_SEARCH_SCHEMA
|
|
36694
|
+
schema: CODE_SEARCH_SCHEMA,
|
|
36695
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
36661
36696
|
});
|
|
36662
36697
|
const delegateResult = options.tracer?.withSpan ? await options.tracer.withSpan("search.delegate", runDelegation, {
|
|
36663
36698
|
"search.query": searchQuery,
|
|
@@ -36871,7 +36906,7 @@ var init_vercel = __esm({
|
|
|
36871
36906
|
name: "delegate",
|
|
36872
36907
|
description: delegateDescription,
|
|
36873
36908
|
inputSchema: delegateSchema,
|
|
36874
|
-
execute: async ({ task, currentIteration, maxIterations, parentSessionId, path: path9, provider, model, tracer, searchDelegate }) => {
|
|
36909
|
+
execute: async ({ task, currentIteration, maxIterations, parentSessionId, path: path9, provider, model, tracer, searchDelegate, parentAbortSignal }) => {
|
|
36875
36910
|
if (!task || typeof task !== "string") {
|
|
36876
36911
|
throw new Error("Task parameter is required and must be a non-empty string");
|
|
36877
36912
|
}
|
|
@@ -36929,8 +36964,9 @@ var init_vercel = __esm({
|
|
|
36929
36964
|
enableMcp,
|
|
36930
36965
|
mcpConfig,
|
|
36931
36966
|
mcpConfigPath,
|
|
36932
|
-
delegationManager
|
|
36967
|
+
delegationManager,
|
|
36933
36968
|
// Per-instance delegation limits
|
|
36969
|
+
parentAbortSignal
|
|
36934
36970
|
});
|
|
36935
36971
|
return result;
|
|
36936
36972
|
}
|
|
@@ -36968,8 +37004,9 @@ var init_vercel = __esm({
|
|
|
36968
37004
|
provider: options.provider,
|
|
36969
37005
|
model: options.model,
|
|
36970
37006
|
tracer: options.tracer,
|
|
36971
|
-
delegationManager
|
|
37007
|
+
delegationManager,
|
|
36972
37008
|
// Per-instance delegation limits
|
|
37009
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
36973
37010
|
});
|
|
36974
37011
|
return result;
|
|
36975
37012
|
} catch (error2) {
|
|
@@ -108714,9 +108751,24 @@ __export(ProbeAgent_exports, {
|
|
|
108714
108751
|
ENGINE_ACTIVITY_TIMEOUT_DEFAULT: () => ENGINE_ACTIVITY_TIMEOUT_DEFAULT,
|
|
108715
108752
|
ENGINE_ACTIVITY_TIMEOUT_MAX: () => ENGINE_ACTIVITY_TIMEOUT_MAX,
|
|
108716
108753
|
ENGINE_ACTIVITY_TIMEOUT_MIN: () => ENGINE_ACTIVITY_TIMEOUT_MIN,
|
|
108717
|
-
ProbeAgent: () => ProbeAgent
|
|
108754
|
+
ProbeAgent: () => ProbeAgent,
|
|
108755
|
+
debugLogToolResults: () => debugLogToolResults,
|
|
108756
|
+
debugTruncate: () => debugTruncate
|
|
108718
108757
|
});
|
|
108719
108758
|
module.exports = __toCommonJS(ProbeAgent_exports);
|
|
108759
|
+
function debugTruncate(s5, limit = 200) {
|
|
108760
|
+
if (s5.length <= limit) return s5;
|
|
108761
|
+
const half = Math.floor(limit / 2);
|
|
108762
|
+
return s5.substring(0, half) + ` ... [${s5.length} chars] ... ` + s5.substring(s5.length - half);
|
|
108763
|
+
}
|
|
108764
|
+
function debugLogToolResults(toolResults) {
|
|
108765
|
+
if (!toolResults || toolResults.length === 0) return;
|
|
108766
|
+
for (const tr of toolResults) {
|
|
108767
|
+
const argsStr = JSON.stringify(tr.args || {});
|
|
108768
|
+
const resultStr = typeof tr.result === "string" ? tr.result : JSON.stringify(tr.result || "");
|
|
108769
|
+
console.log(`[DEBUG] tool: ${tr.toolName} | args: ${debugTruncate(argsStr)} | result: ${debugTruncate(resultStr)}`);
|
|
108770
|
+
}
|
|
108771
|
+
}
|
|
108720
108772
|
var import_dotenv2, import_anthropic2, import_openai2, import_google2, import_ai6, import_crypto9, import_events4, import_fs15, import_promises6, import_path18, ENGINE_ACTIVITY_TIMEOUT_DEFAULT, ENGINE_ACTIVITY_TIMEOUT_MIN, ENGINE_ACTIVITY_TIMEOUT_MAX, MAX_TOOL_ITERATIONS, MAX_HISTORY_MESSAGES, MAX_IMAGE_FILE_SIZE, ProbeAgent;
|
|
108721
108773
|
var init_ProbeAgent = __esm({
|
|
108722
108774
|
"src/agent/ProbeAgent.js"() {
|
|
@@ -108835,6 +108887,7 @@ var init_ProbeAgent = __esm({
|
|
|
108835
108887
|
this.enableExecutePlan = !!options.enableExecutePlan;
|
|
108836
108888
|
this.debug = options.debug || process.env.DEBUG === "1";
|
|
108837
108889
|
this.cancelled = false;
|
|
108890
|
+
this._abortController = new AbortController();
|
|
108838
108891
|
this.tracer = options.tracer || null;
|
|
108839
108892
|
this.outline = !!options.outline;
|
|
108840
108893
|
this.searchDelegate = options.searchDelegate !== void 0 ? !!options.searchDelegate : true;
|
|
@@ -109280,6 +109333,8 @@ var init_ProbeAgent = __esm({
|
|
|
109280
109333
|
searchDelegateModel: this.searchDelegateModel,
|
|
109281
109334
|
delegationManager: this.delegationManager,
|
|
109282
109335
|
// Per-instance delegation limits
|
|
109336
|
+
parentAbortSignal: this._abortController.signal,
|
|
109337
|
+
// Propagate cancellation to delegations
|
|
109283
109338
|
outputBuffer: this._outputBuffer,
|
|
109284
109339
|
concurrencyLimiter: this.concurrencyLimiter,
|
|
109285
109340
|
// Global AI concurrency limiter
|
|
@@ -109727,6 +109782,15 @@ var init_ProbeAgent = __esm({
|
|
|
109727
109782
|
}
|
|
109728
109783
|
const controller = new AbortController();
|
|
109729
109784
|
const timeoutState = { timeoutId: null };
|
|
109785
|
+
if (this._abortController.signal.aborted) {
|
|
109786
|
+
controller.abort();
|
|
109787
|
+
} else {
|
|
109788
|
+
const onAgentAbort = () => controller.abort();
|
|
109789
|
+
this._abortController.signal.addEventListener("abort", onAgentAbort, { once: true });
|
|
109790
|
+
controller.signal.addEventListener("abort", () => {
|
|
109791
|
+
this._abortController.signal.removeEventListener("abort", onAgentAbort);
|
|
109792
|
+
}, { once: true });
|
|
109793
|
+
}
|
|
109730
109794
|
if (this.maxOperationTimeout && this.maxOperationTimeout > 0) {
|
|
109731
109795
|
timeoutState.timeoutId = setTimeout(() => {
|
|
109732
109796
|
controller.abort();
|
|
@@ -110030,7 +110094,8 @@ var init_ProbeAgent = __esm({
|
|
|
110030
110094
|
allowEdit: this.allowEdit,
|
|
110031
110095
|
allowedTools: allowedToolsForDelegate,
|
|
110032
110096
|
debug: this.debug,
|
|
110033
|
-
tracer: this.tracer
|
|
110097
|
+
tracer: this.tracer,
|
|
110098
|
+
parentAbortSignal: this._abortController.signal
|
|
110034
110099
|
};
|
|
110035
110100
|
if (this.debug) {
|
|
110036
110101
|
console.log(`[DEBUG] Executing delegate tool`);
|
|
@@ -111347,6 +111412,10 @@ You are working with a workspace. Available paths: ${workspaceDesc}
|
|
|
111347
111412
|
completionResult = result;
|
|
111348
111413
|
completionAttempted = true;
|
|
111349
111414
|
}, toolContext);
|
|
111415
|
+
if (this.debug) {
|
|
111416
|
+
const toolNames = Object.keys(tools2);
|
|
111417
|
+
console.log(`[DEBUG] Agent tools registered (${toolNames.length}): ${toolNames.join(", ")}`);
|
|
111418
|
+
}
|
|
111350
111419
|
let maxResponseTokens = this.maxResponseTokens;
|
|
111351
111420
|
if (!maxResponseTokens) {
|
|
111352
111421
|
maxResponseTokens = 4e3;
|
|
@@ -111386,6 +111455,7 @@ You are working with a workspace. Available paths: ${workspaceDesc}
|
|
|
111386
111455
|
}
|
|
111387
111456
|
if (this.debug) {
|
|
111388
111457
|
console.log(`[DEBUG] Step ${currentIteration}/${maxIterations} finished (reason: ${finishReason}, tools: ${toolResults?.length || 0})`);
|
|
111458
|
+
debugLogToolResults(toolResults);
|
|
111389
111459
|
}
|
|
111390
111460
|
}
|
|
111391
111461
|
};
|
|
@@ -111542,6 +111612,7 @@ Double-check your response based on the criteria above. If everything looks good
|
|
|
111542
111612
|
}
|
|
111543
111613
|
if (this.debug) {
|
|
111544
111614
|
console.log(`[DEBUG] Completion prompt step finished (reason: ${finishReason}, tools: ${toolResults?.length || 0})`);
|
|
111615
|
+
debugLogToolResults(toolResults);
|
|
111545
111616
|
}
|
|
111546
111617
|
}
|
|
111547
111618
|
};
|
|
@@ -112252,6 +112323,9 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
112252
112323
|
* Clean up resources (including MCP connections)
|
|
112253
112324
|
*/
|
|
112254
112325
|
async cleanup() {
|
|
112326
|
+
if (!this._abortController.signal.aborted) {
|
|
112327
|
+
this._abortController.abort();
|
|
112328
|
+
}
|
|
112255
112329
|
if (this.mcpBridge) {
|
|
112256
112330
|
try {
|
|
112257
112331
|
await this.mcpBridge.cleanup();
|
|
@@ -112275,14 +112349,25 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
112275
112349
|
this.clearHistory();
|
|
112276
112350
|
}
|
|
112277
112351
|
/**
|
|
112278
|
-
* Cancel the current request
|
|
112352
|
+
* Cancel the current request and all in-flight delegations.
|
|
112353
|
+
* Aborts the internal AbortController so streamText, subagents,
|
|
112354
|
+
* and any code checking the signal will stop.
|
|
112279
112355
|
*/
|
|
112280
112356
|
cancel() {
|
|
112281
112357
|
this.cancelled = true;
|
|
112358
|
+
this._abortController.abort();
|
|
112282
112359
|
if (this.debug) {
|
|
112283
112360
|
console.log(`[DEBUG] Agent cancelled for session ${this.sessionId}`);
|
|
112284
112361
|
}
|
|
112285
112362
|
}
|
|
112363
|
+
/**
|
|
112364
|
+
* Get the abort signal for this agent.
|
|
112365
|
+
* Delegations and subagents should check this signal.
|
|
112366
|
+
* @returns {AbortSignal}
|
|
112367
|
+
*/
|
|
112368
|
+
get abortSignal() {
|
|
112369
|
+
return this._abortController.signal;
|
|
112370
|
+
}
|
|
112286
112371
|
};
|
|
112287
112372
|
}
|
|
112288
112373
|
});
|
|
@@ -112292,7 +112377,9 @@ init_ProbeAgent();
|
|
|
112292
112377
|
ENGINE_ACTIVITY_TIMEOUT_DEFAULT,
|
|
112293
112378
|
ENGINE_ACTIVITY_TIMEOUT_MAX,
|
|
112294
112379
|
ENGINE_ACTIVITY_TIMEOUT_MIN,
|
|
112295
|
-
ProbeAgent
|
|
112380
|
+
ProbeAgent,
|
|
112381
|
+
debugLogToolResults,
|
|
112382
|
+
debugTruncate
|
|
112296
112383
|
});
|
|
112297
112384
|
/*! Bundled license information:
|
|
112298
112385
|
|
package/cjs/index.cjs
CHANGED
|
@@ -105965,8 +105965,23 @@ __export(ProbeAgent_exports, {
|
|
|
105965
105965
|
ENGINE_ACTIVITY_TIMEOUT_DEFAULT: () => ENGINE_ACTIVITY_TIMEOUT_DEFAULT,
|
|
105966
105966
|
ENGINE_ACTIVITY_TIMEOUT_MAX: () => ENGINE_ACTIVITY_TIMEOUT_MAX,
|
|
105967
105967
|
ENGINE_ACTIVITY_TIMEOUT_MIN: () => ENGINE_ACTIVITY_TIMEOUT_MIN,
|
|
105968
|
-
ProbeAgent: () => ProbeAgent
|
|
105968
|
+
ProbeAgent: () => ProbeAgent,
|
|
105969
|
+
debugLogToolResults: () => debugLogToolResults,
|
|
105970
|
+
debugTruncate: () => debugTruncate
|
|
105969
105971
|
});
|
|
105972
|
+
function debugTruncate(s5, limit = 200) {
|
|
105973
|
+
if (s5.length <= limit) return s5;
|
|
105974
|
+
const half = Math.floor(limit / 2);
|
|
105975
|
+
return s5.substring(0, half) + ` ... [${s5.length} chars] ... ` + s5.substring(s5.length - half);
|
|
105976
|
+
}
|
|
105977
|
+
function debugLogToolResults(toolResults) {
|
|
105978
|
+
if (!toolResults || toolResults.length === 0) return;
|
|
105979
|
+
for (const tr of toolResults) {
|
|
105980
|
+
const argsStr = JSON.stringify(tr.args || {});
|
|
105981
|
+
const resultStr = typeof tr.result === "string" ? tr.result : JSON.stringify(tr.result || "");
|
|
105982
|
+
console.log(`[DEBUG] tool: ${tr.toolName} | args: ${debugTruncate(argsStr)} | result: ${debugTruncate(resultStr)}`);
|
|
105983
|
+
}
|
|
105984
|
+
}
|
|
105970
105985
|
var import_dotenv, import_anthropic2, import_openai2, import_google2, import_ai4, import_crypto8, import_events4, import_fs10, import_promises6, import_path15, ENGINE_ACTIVITY_TIMEOUT_DEFAULT, ENGINE_ACTIVITY_TIMEOUT_MIN, ENGINE_ACTIVITY_TIMEOUT_MAX, MAX_TOOL_ITERATIONS, MAX_HISTORY_MESSAGES, MAX_IMAGE_FILE_SIZE, ProbeAgent;
|
|
105971
105986
|
var init_ProbeAgent = __esm({
|
|
105972
105987
|
"src/agent/ProbeAgent.js"() {
|
|
@@ -106086,6 +106101,7 @@ var init_ProbeAgent = __esm({
|
|
|
106086
106101
|
this.enableExecutePlan = !!options.enableExecutePlan;
|
|
106087
106102
|
this.debug = options.debug || process.env.DEBUG === "1";
|
|
106088
106103
|
this.cancelled = false;
|
|
106104
|
+
this._abortController = new AbortController();
|
|
106089
106105
|
this.tracer = options.tracer || null;
|
|
106090
106106
|
this.outline = !!options.outline;
|
|
106091
106107
|
this.searchDelegate = options.searchDelegate !== void 0 ? !!options.searchDelegate : true;
|
|
@@ -106531,6 +106547,8 @@ var init_ProbeAgent = __esm({
|
|
|
106531
106547
|
searchDelegateModel: this.searchDelegateModel,
|
|
106532
106548
|
delegationManager: this.delegationManager,
|
|
106533
106549
|
// Per-instance delegation limits
|
|
106550
|
+
parentAbortSignal: this._abortController.signal,
|
|
106551
|
+
// Propagate cancellation to delegations
|
|
106534
106552
|
outputBuffer: this._outputBuffer,
|
|
106535
106553
|
concurrencyLimiter: this.concurrencyLimiter,
|
|
106536
106554
|
// Global AI concurrency limiter
|
|
@@ -106978,6 +106996,15 @@ var init_ProbeAgent = __esm({
|
|
|
106978
106996
|
}
|
|
106979
106997
|
const controller = new AbortController();
|
|
106980
106998
|
const timeoutState = { timeoutId: null };
|
|
106999
|
+
if (this._abortController.signal.aborted) {
|
|
107000
|
+
controller.abort();
|
|
107001
|
+
} else {
|
|
107002
|
+
const onAgentAbort = () => controller.abort();
|
|
107003
|
+
this._abortController.signal.addEventListener("abort", onAgentAbort, { once: true });
|
|
107004
|
+
controller.signal.addEventListener("abort", () => {
|
|
107005
|
+
this._abortController.signal.removeEventListener("abort", onAgentAbort);
|
|
107006
|
+
}, { once: true });
|
|
107007
|
+
}
|
|
106981
107008
|
if (this.maxOperationTimeout && this.maxOperationTimeout > 0) {
|
|
106982
107009
|
timeoutState.timeoutId = setTimeout(() => {
|
|
106983
107010
|
controller.abort();
|
|
@@ -107281,7 +107308,8 @@ var init_ProbeAgent = __esm({
|
|
|
107281
107308
|
allowEdit: this.allowEdit,
|
|
107282
107309
|
allowedTools: allowedToolsForDelegate,
|
|
107283
107310
|
debug: this.debug,
|
|
107284
|
-
tracer: this.tracer
|
|
107311
|
+
tracer: this.tracer,
|
|
107312
|
+
parentAbortSignal: this._abortController.signal
|
|
107285
107313
|
};
|
|
107286
107314
|
if (this.debug) {
|
|
107287
107315
|
console.log(`[DEBUG] Executing delegate tool`);
|
|
@@ -108598,6 +108626,10 @@ You are working with a workspace. Available paths: ${workspaceDesc}
|
|
|
108598
108626
|
completionResult = result;
|
|
108599
108627
|
completionAttempted = true;
|
|
108600
108628
|
}, toolContext);
|
|
108629
|
+
if (this.debug) {
|
|
108630
|
+
const toolNames = Object.keys(tools2);
|
|
108631
|
+
console.log(`[DEBUG] Agent tools registered (${toolNames.length}): ${toolNames.join(", ")}`);
|
|
108632
|
+
}
|
|
108601
108633
|
let maxResponseTokens = this.maxResponseTokens;
|
|
108602
108634
|
if (!maxResponseTokens) {
|
|
108603
108635
|
maxResponseTokens = 4e3;
|
|
@@ -108637,6 +108669,7 @@ You are working with a workspace. Available paths: ${workspaceDesc}
|
|
|
108637
108669
|
}
|
|
108638
108670
|
if (this.debug) {
|
|
108639
108671
|
console.log(`[DEBUG] Step ${currentIteration}/${maxIterations} finished (reason: ${finishReason}, tools: ${toolResults?.length || 0})`);
|
|
108672
|
+
debugLogToolResults(toolResults);
|
|
108640
108673
|
}
|
|
108641
108674
|
}
|
|
108642
108675
|
};
|
|
@@ -108793,6 +108826,7 @@ Double-check your response based on the criteria above. If everything looks good
|
|
|
108793
108826
|
}
|
|
108794
108827
|
if (this.debug) {
|
|
108795
108828
|
console.log(`[DEBUG] Completion prompt step finished (reason: ${finishReason}, tools: ${toolResults?.length || 0})`);
|
|
108829
|
+
debugLogToolResults(toolResults);
|
|
108796
108830
|
}
|
|
108797
108831
|
}
|
|
108798
108832
|
};
|
|
@@ -109503,6 +109537,9 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
109503
109537
|
* Clean up resources (including MCP connections)
|
|
109504
109538
|
*/
|
|
109505
109539
|
async cleanup() {
|
|
109540
|
+
if (!this._abortController.signal.aborted) {
|
|
109541
|
+
this._abortController.abort();
|
|
109542
|
+
}
|
|
109506
109543
|
if (this.mcpBridge) {
|
|
109507
109544
|
try {
|
|
109508
109545
|
await this.mcpBridge.cleanup();
|
|
@@ -109526,14 +109563,25 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
109526
109563
|
this.clearHistory();
|
|
109527
109564
|
}
|
|
109528
109565
|
/**
|
|
109529
|
-
* Cancel the current request
|
|
109566
|
+
* Cancel the current request and all in-flight delegations.
|
|
109567
|
+
* Aborts the internal AbortController so streamText, subagents,
|
|
109568
|
+
* and any code checking the signal will stop.
|
|
109530
109569
|
*/
|
|
109531
109570
|
cancel() {
|
|
109532
109571
|
this.cancelled = true;
|
|
109572
|
+
this._abortController.abort();
|
|
109533
109573
|
if (this.debug) {
|
|
109534
109574
|
console.log(`[DEBUG] Agent cancelled for session ${this.sessionId}`);
|
|
109535
109575
|
}
|
|
109536
109576
|
}
|
|
109577
|
+
/**
|
|
109578
|
+
* Get the abort signal for this agent.
|
|
109579
|
+
* Delegations and subagents should check this signal.
|
|
109580
|
+
* @returns {AbortSignal}
|
|
109581
|
+
*/
|
|
109582
|
+
get abortSignal() {
|
|
109583
|
+
return this._abortController.signal;
|
|
109584
|
+
}
|
|
109537
109585
|
};
|
|
109538
109586
|
}
|
|
109539
109587
|
});
|
|
@@ -109566,12 +109614,17 @@ async function delegate({
|
|
|
109566
109614
|
mcpConfigPath = null,
|
|
109567
109615
|
delegationManager = null,
|
|
109568
109616
|
// Optional per-instance manager, falls back to default singleton
|
|
109569
|
-
concurrencyLimiter = null
|
|
109617
|
+
concurrencyLimiter = null,
|
|
109570
109618
|
// Optional global AI concurrency limiter
|
|
109619
|
+
parentAbortSignal = null
|
|
109620
|
+
// Optional AbortSignal from parent to cancel this delegation
|
|
109571
109621
|
}) {
|
|
109572
109622
|
if (!task || typeof task !== "string") {
|
|
109573
109623
|
throw new Error("Task parameter is required and must be a string");
|
|
109574
109624
|
}
|
|
109625
|
+
if (parentAbortSignal?.aborted) {
|
|
109626
|
+
throw new Error("Delegation cancelled: parent operation was aborted");
|
|
109627
|
+
}
|
|
109575
109628
|
const hasExplicitTimeout = Object.prototype.hasOwnProperty.call(arguments?.[0] ?? {}, "timeout");
|
|
109576
109629
|
if (!hasExplicitTimeout) {
|
|
109577
109630
|
const envTimeoutMs = parseInt(process.env.DELEGATION_TIMEOUT_MS || "", 10);
|
|
@@ -109656,12 +109709,37 @@ async function delegate({
|
|
|
109656
109709
|
}
|
|
109657
109710
|
const timeoutPromise = new Promise((_, reject2) => {
|
|
109658
109711
|
timeoutId = setTimeout(() => {
|
|
109712
|
+
subagent.cancel();
|
|
109659
109713
|
reject2(new Error(`Delegation timed out after ${timeout} seconds`));
|
|
109660
109714
|
}, timeout * 1e3);
|
|
109661
109715
|
});
|
|
109716
|
+
let parentAbortHandler;
|
|
109717
|
+
const parentAbortPromise = new Promise((_, reject2) => {
|
|
109718
|
+
if (parentAbortSignal) {
|
|
109719
|
+
if (parentAbortSignal.aborted) {
|
|
109720
|
+
subagent.cancel();
|
|
109721
|
+
reject2(new Error("Delegation cancelled: parent operation was aborted"));
|
|
109722
|
+
return;
|
|
109723
|
+
}
|
|
109724
|
+
parentAbortHandler = () => {
|
|
109725
|
+
subagent.cancel();
|
|
109726
|
+
reject2(new Error("Delegation cancelled: parent operation was aborted"));
|
|
109727
|
+
};
|
|
109728
|
+
parentAbortSignal.addEventListener("abort", parentAbortHandler, { once: true });
|
|
109729
|
+
}
|
|
109730
|
+
});
|
|
109662
109731
|
const answerOptions = schema ? { schema } : void 0;
|
|
109663
109732
|
const answerPromise = answerOptions ? subagent.answer(task, [], answerOptions) : subagent.answer(task);
|
|
109664
|
-
const
|
|
109733
|
+
const racers = [answerPromise, timeoutPromise];
|
|
109734
|
+
if (parentAbortSignal) racers.push(parentAbortPromise);
|
|
109735
|
+
let response;
|
|
109736
|
+
try {
|
|
109737
|
+
response = await Promise.race(racers);
|
|
109738
|
+
} finally {
|
|
109739
|
+
if (parentAbortHandler && parentAbortSignal) {
|
|
109740
|
+
parentAbortSignal.removeEventListener("abort", parentAbortHandler);
|
|
109741
|
+
}
|
|
109742
|
+
}
|
|
109665
109743
|
if (timeoutId !== null) {
|
|
109666
109744
|
clearTimeout(timeoutId);
|
|
109667
109745
|
timeoutId = null;
|
|
@@ -110074,8 +110152,9 @@ Instructions:
|
|
|
110074
110152
|
promptType: "code-researcher",
|
|
110075
110153
|
allowedTools: ["extract"],
|
|
110076
110154
|
maxIterations: 5,
|
|
110077
|
-
delegationManager: options.delegationManager
|
|
110155
|
+
delegationManager: options.delegationManager,
|
|
110078
110156
|
// Per-instance delegation limits
|
|
110157
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
110079
110158
|
// timeout removed - inherit default from delegate (300s)
|
|
110080
110159
|
});
|
|
110081
110160
|
return { chunk, result };
|
|
@@ -110174,8 +110253,9 @@ Organize all findings into clear categories with items listed under each.${compl
|
|
|
110174
110253
|
promptType: "code-researcher",
|
|
110175
110254
|
allowedTools: [],
|
|
110176
110255
|
maxIterations: 5,
|
|
110177
|
-
delegationManager: options.delegationManager
|
|
110256
|
+
delegationManager: options.delegationManager,
|
|
110178
110257
|
// Per-instance delegation limits
|
|
110258
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
110179
110259
|
// timeout removed - inherit default from delegate (300s)
|
|
110180
110260
|
});
|
|
110181
110261
|
return result;
|
|
@@ -110239,8 +110319,9 @@ CRITICAL: Do NOT guess keywords. Actually run searches and see what returns resu
|
|
|
110239
110319
|
promptType: "code-researcher",
|
|
110240
110320
|
// Full tool access for exploration and experimentation
|
|
110241
110321
|
maxIterations: 15,
|
|
110242
|
-
delegationManager: options.delegationManager
|
|
110322
|
+
delegationManager: options.delegationManager,
|
|
110243
110323
|
// Per-instance delegation limits
|
|
110324
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
110244
110325
|
// timeout removed - inherit default from delegate (300s)
|
|
110245
110326
|
});
|
|
110246
110327
|
const plan = parsePlanningResult(stripResultTags(result));
|
|
@@ -110297,8 +110378,9 @@ When done, use the attempt_completion tool with your answer as the result.`;
|
|
|
110297
110378
|
promptType: "code-researcher",
|
|
110298
110379
|
allowedTools: [],
|
|
110299
110380
|
maxIterations: 5,
|
|
110300
|
-
delegationManager: options.delegationManager
|
|
110381
|
+
delegationManager: options.delegationManager,
|
|
110301
110382
|
// Per-instance delegation limits
|
|
110383
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
110302
110384
|
// timeout removed - inherit default from delegate (300s)
|
|
110303
110385
|
});
|
|
110304
110386
|
return stripResultTags(result);
|
|
@@ -110746,7 +110828,8 @@ var init_vercel = __esm({
|
|
|
110746
110828
|
promptType: "code-searcher",
|
|
110747
110829
|
allowedTools: ["search", "extract", "listFiles", "attempt_completion"],
|
|
110748
110830
|
searchDelegate: false,
|
|
110749
|
-
schema: CODE_SEARCH_SCHEMA
|
|
110831
|
+
schema: CODE_SEARCH_SCHEMA,
|
|
110832
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
110750
110833
|
});
|
|
110751
110834
|
const delegateResult = options.tracer?.withSpan ? await options.tracer.withSpan("search.delegate", runDelegation, {
|
|
110752
110835
|
"search.query": searchQuery,
|
|
@@ -110960,7 +111043,7 @@ var init_vercel = __esm({
|
|
|
110960
111043
|
name: "delegate",
|
|
110961
111044
|
description: delegateDescription,
|
|
110962
111045
|
inputSchema: delegateSchema,
|
|
110963
|
-
execute: async ({ task, currentIteration, maxIterations, parentSessionId, path: path9, provider, model, tracer, searchDelegate }) => {
|
|
111046
|
+
execute: async ({ task, currentIteration, maxIterations, parentSessionId, path: path9, provider, model, tracer, searchDelegate, parentAbortSignal }) => {
|
|
110964
111047
|
if (!task || typeof task !== "string") {
|
|
110965
111048
|
throw new Error("Task parameter is required and must be a non-empty string");
|
|
110966
111049
|
}
|
|
@@ -111018,8 +111101,9 @@ var init_vercel = __esm({
|
|
|
111018
111101
|
enableMcp,
|
|
111019
111102
|
mcpConfig,
|
|
111020
111103
|
mcpConfigPath,
|
|
111021
|
-
delegationManager
|
|
111104
|
+
delegationManager,
|
|
111022
111105
|
// Per-instance delegation limits
|
|
111106
|
+
parentAbortSignal
|
|
111023
111107
|
});
|
|
111024
111108
|
return result;
|
|
111025
111109
|
}
|
|
@@ -111057,8 +111141,9 @@ var init_vercel = __esm({
|
|
|
111057
111141
|
provider: options.provider,
|
|
111058
111142
|
model: options.model,
|
|
111059
111143
|
tracer: options.tracer,
|
|
111060
|
-
delegationManager
|
|
111144
|
+
delegationManager,
|
|
111061
111145
|
// Per-instance delegation limits
|
|
111146
|
+
parentAbortSignal: options.parentAbortSignal || null
|
|
111062
111147
|
});
|
|
111063
111148
|
return result;
|
|
111064
111149
|
} catch (error2) {
|