@bike4mind/cli 0.2.11-cli-cancel-pending-message.17326 → 0.2.11-cli-cancel-pending-message.17327
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/dist/index.js +69 -17
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -3093,6 +3093,21 @@ ${options.context}` : this.getSystemPrompt()
|
|
|
3093
3093
|
let finalAnswer = "";
|
|
3094
3094
|
let reachedMaxIterations = false;
|
|
3095
3095
|
while (iterations < maxIterations) {
|
|
3096
|
+
if (options.signal?.aborted) {
|
|
3097
|
+
this.context.logger.info("[ReActAgent] Operation aborted by user");
|
|
3098
|
+
const result2 = {
|
|
3099
|
+
finalAnswer: "Interrupted",
|
|
3100
|
+
steps: this.steps,
|
|
3101
|
+
completionInfo: {
|
|
3102
|
+
totalTokens: this.totalTokens,
|
|
3103
|
+
iterations,
|
|
3104
|
+
toolCalls: this.toolCallCount,
|
|
3105
|
+
reachedMaxIterations: false
|
|
3106
|
+
}
|
|
3107
|
+
};
|
|
3108
|
+
this.emit("complete", result2);
|
|
3109
|
+
return result2;
|
|
3110
|
+
}
|
|
3096
3111
|
iterations++;
|
|
3097
3112
|
this.context.logger.debug(`[ReActAgent] Starting iteration ${iterations}/${maxIterations}`);
|
|
3098
3113
|
let iterationComplete = false;
|
|
@@ -3106,7 +3121,8 @@ ${options.context}` : this.getSystemPrompt()
|
|
|
3106
3121
|
stream: false,
|
|
3107
3122
|
tools: this.context.tools,
|
|
3108
3123
|
maxTokens,
|
|
3109
|
-
temperature
|
|
3124
|
+
temperature,
|
|
3125
|
+
abortSignal: options.signal
|
|
3110
3126
|
},
|
|
3111
3127
|
async (texts, completionInfo) => {
|
|
3112
3128
|
for (const text of texts) {
|
|
@@ -3249,6 +3265,9 @@ ${options.context}` : this.getSystemPrompt()
|
|
|
3249
3265
|
this.emit("final_answer", finalStep);
|
|
3250
3266
|
}
|
|
3251
3267
|
}
|
|
3268
|
+
if (options.signal?.aborted && !finalAnswer) {
|
|
3269
|
+
finalAnswer = "Interrupted";
|
|
3270
|
+
}
|
|
3252
3271
|
const result = {
|
|
3253
3272
|
finalAnswer,
|
|
3254
3273
|
steps: this.steps,
|
|
@@ -11301,6 +11320,10 @@ var ServerLlmBackend = class {
|
|
|
11301
11320
|
*/
|
|
11302
11321
|
async complete(model, messages, options, callback) {
|
|
11303
11322
|
logger.debug(`[ServerLlmBackend] Starting complete() with model: ${model}`);
|
|
11323
|
+
if (options.abortSignal?.aborted) {
|
|
11324
|
+
logger.debug("[ServerLlmBackend] Request aborted before start");
|
|
11325
|
+
return;
|
|
11326
|
+
}
|
|
11304
11327
|
return new Promise(async (resolve3, reject) => {
|
|
11305
11328
|
try {
|
|
11306
11329
|
logger.debug("[ServerLlmBackend] Making streaming request...");
|
|
@@ -11401,7 +11424,25 @@ var ServerLlmBackend = class {
|
|
|
11401
11424
|
}
|
|
11402
11425
|
}
|
|
11403
11426
|
});
|
|
11427
|
+
if (options.abortSignal) {
|
|
11428
|
+
const abortHandler = () => {
|
|
11429
|
+
logger.debug("[ServerLlmBackend] Abort signal received, destroying stream");
|
|
11430
|
+
response.data.destroy();
|
|
11431
|
+
resolve3();
|
|
11432
|
+
};
|
|
11433
|
+
if (options.abortSignal.aborted) {
|
|
11434
|
+
abortHandler();
|
|
11435
|
+
return;
|
|
11436
|
+
}
|
|
11437
|
+
options.abortSignal.addEventListener("abort", abortHandler, { once: true });
|
|
11438
|
+
response.data.on("close", () => {
|
|
11439
|
+
options.abortSignal?.removeEventListener("abort", abortHandler);
|
|
11440
|
+
});
|
|
11441
|
+
}
|
|
11404
11442
|
response.data.on("data", (chunk) => {
|
|
11443
|
+
if (options.abortSignal?.aborted) {
|
|
11444
|
+
return;
|
|
11445
|
+
}
|
|
11405
11446
|
parser.feed(chunk.toString());
|
|
11406
11447
|
});
|
|
11407
11448
|
response.data.on("end", () => {
|
|
@@ -11413,9 +11454,23 @@ var ServerLlmBackend = class {
|
|
|
11413
11454
|
}
|
|
11414
11455
|
});
|
|
11415
11456
|
response.data.on("error", (error) => {
|
|
11457
|
+
if (options.abortSignal?.aborted) {
|
|
11458
|
+
resolve3();
|
|
11459
|
+
return;
|
|
11460
|
+
}
|
|
11416
11461
|
reject(error);
|
|
11417
11462
|
});
|
|
11418
11463
|
} catch (error) {
|
|
11464
|
+
if (options.abortSignal?.aborted) {
|
|
11465
|
+
logger.debug("[ServerLlmBackend] Request was aborted, resolving gracefully");
|
|
11466
|
+
resolve3();
|
|
11467
|
+
return;
|
|
11468
|
+
}
|
|
11469
|
+
if (isAxiosError(error) && error.code === "ERR_CANCELED") {
|
|
11470
|
+
logger.debug("[ServerLlmBackend] Request was canceled, resolving gracefully");
|
|
11471
|
+
resolve3();
|
|
11472
|
+
return;
|
|
11473
|
+
}
|
|
11419
11474
|
logger.error("LLM completion failed", error);
|
|
11420
11475
|
if (isAxiosError(error)) {
|
|
11421
11476
|
logger.debug(
|
|
@@ -11566,8 +11621,10 @@ var ServerLlmBackend = class {
|
|
|
11566
11621
|
logger.debug(` Body: ${logger.formatBytes(bodySize)}`);
|
|
11567
11622
|
logger.debug(` Preview: ${bodyStr.substring(0, 200)}`);
|
|
11568
11623
|
const response = await axiosInstance.post(this.completionsEndpoint, requestBody, {
|
|
11569
|
-
responseType: "stream"
|
|
11624
|
+
responseType: "stream",
|
|
11570
11625
|
// Auth header is automatically injected by ApiClient interceptor
|
|
11626
|
+
// Pass abort signal to cancel request if user presses ESC
|
|
11627
|
+
signal: options.abortSignal
|
|
11571
11628
|
});
|
|
11572
11629
|
logger.debug(`\u2190 ${response.status} ${response.statusText}`);
|
|
11573
11630
|
return response;
|
|
@@ -11711,7 +11768,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
|
|
|
11711
11768
|
// package.json
|
|
11712
11769
|
var package_default = {
|
|
11713
11770
|
name: "@bike4mind/cli",
|
|
11714
|
-
version: "0.2.11-cli-cancel-pending-message.
|
|
11771
|
+
version: "0.2.11-cli-cancel-pending-message.17327+02457534d",
|
|
11715
11772
|
type: "module",
|
|
11716
11773
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
11717
11774
|
license: "UNLICENSED",
|
|
@@ -11815,10 +11872,10 @@ var package_default = {
|
|
|
11815
11872
|
},
|
|
11816
11873
|
devDependencies: {
|
|
11817
11874
|
"@bike4mind/agents": "0.1.0",
|
|
11818
|
-
"@bike4mind/common": "2.40.1-cli-cancel-pending-message.
|
|
11819
|
-
"@bike4mind/mcp": "1.20.5-cli-cancel-pending-message.
|
|
11820
|
-
"@bike4mind/services": "2.35.1-cli-cancel-pending-message.
|
|
11821
|
-
"@bike4mind/utils": "2.1.5-cli-cancel-pending-message.
|
|
11875
|
+
"@bike4mind/common": "2.40.1-cli-cancel-pending-message.17327+02457534d",
|
|
11876
|
+
"@bike4mind/mcp": "1.20.5-cli-cancel-pending-message.17327+02457534d",
|
|
11877
|
+
"@bike4mind/services": "2.35.1-cli-cancel-pending-message.17327+02457534d",
|
|
11878
|
+
"@bike4mind/utils": "2.1.5-cli-cancel-pending-message.17327+02457534d",
|
|
11822
11879
|
"@types/better-sqlite3": "^7.6.13",
|
|
11823
11880
|
"@types/diff": "^5.0.9",
|
|
11824
11881
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -11831,7 +11888,7 @@ var package_default = {
|
|
|
11831
11888
|
typescript: "^5.9.3",
|
|
11832
11889
|
vitest: "^3.2.4"
|
|
11833
11890
|
},
|
|
11834
|
-
gitHead: "
|
|
11891
|
+
gitHead: "02457534dd28d3297ce20026e3a9735d658e67f1"
|
|
11835
11892
|
};
|
|
11836
11893
|
|
|
11837
11894
|
// src/config/constants.ts
|
|
@@ -12270,7 +12327,7 @@ function CliApp() {
|
|
|
12270
12327
|
logger.debug("[ABORT] ESC pressed - aborting current operation...");
|
|
12271
12328
|
state.abortController.abort();
|
|
12272
12329
|
setState((prev) => ({ ...prev, abortController: null }));
|
|
12273
|
-
|
|
12330
|
+
useCliStore.getState().setIsThinking(false);
|
|
12274
12331
|
}
|
|
12275
12332
|
return;
|
|
12276
12333
|
}
|
|
@@ -12536,13 +12593,16 @@ ${contextResult.mergedContent}` : "";
|
|
|
12536
12593
|
}
|
|
12537
12594
|
};
|
|
12538
12595
|
agent.on("thought", stepHandler);
|
|
12596
|
+
agent.on("observation", stepHandler);
|
|
12539
12597
|
agent.on("action", stepHandler);
|
|
12540
12598
|
orchestrator.setBeforeRunCallback((subagent, _subagentType) => {
|
|
12541
12599
|
subagent.on("thought", stepHandler);
|
|
12600
|
+
subagent.on("observation", stepHandler);
|
|
12542
12601
|
subagent.on("action", stepHandler);
|
|
12543
12602
|
});
|
|
12544
12603
|
orchestrator.setAfterRunCallback((subagent, _subagentType) => {
|
|
12545
12604
|
subagent.off("thought", stepHandler);
|
|
12605
|
+
subagent.off("observation", stepHandler);
|
|
12546
12606
|
subagent.off("action", stepHandler);
|
|
12547
12607
|
});
|
|
12548
12608
|
setState((prev) => ({
|
|
@@ -12653,10 +12713,6 @@ ${contextResult.mergedContent}` : "";
|
|
|
12653
12713
|
previousMessages: previousMessages.length > 0 ? previousMessages : void 0,
|
|
12654
12714
|
signal: abortController.signal
|
|
12655
12715
|
});
|
|
12656
|
-
if (abortController.signal.aborted) {
|
|
12657
|
-
logger.debug("[ABORT] Custom command was cancelled, discarding result");
|
|
12658
|
-
return;
|
|
12659
|
-
}
|
|
12660
12716
|
const permissionDenied = result.finalAnswer.startsWith("Permission denied for tool");
|
|
12661
12717
|
if (permissionDenied) {
|
|
12662
12718
|
console.log("\n\u26A0\uFE0F Action denied by user\n");
|
|
@@ -12829,10 +12885,6 @@ ${contextResult.mergedContent}` : "";
|
|
|
12829
12885
|
previousMessages: previousMessages.length > 0 ? previousMessages : void 0,
|
|
12830
12886
|
signal: abortController.signal
|
|
12831
12887
|
});
|
|
12832
|
-
if (abortController.signal.aborted) {
|
|
12833
|
-
logger.debug("[ABORT] Operation was cancelled, discarding result");
|
|
12834
|
-
return;
|
|
12835
|
-
}
|
|
12836
12888
|
const permissionDenied = result.finalAnswer.startsWith("Permission denied for tool");
|
|
12837
12889
|
if (permissionDenied) {
|
|
12838
12890
|
console.log("\n\u26A0\uFE0F Action denied by user\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bike4mind/cli",
|
|
3
|
-
"version": "0.2.11-cli-cancel-pending-message.
|
|
3
|
+
"version": "0.2.11-cli-cancel-pending-message.17327+02457534d",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -104,10 +104,10 @@
|
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
106
|
"@bike4mind/agents": "0.1.0",
|
|
107
|
-
"@bike4mind/common": "2.40.1-cli-cancel-pending-message.
|
|
108
|
-
"@bike4mind/mcp": "1.20.5-cli-cancel-pending-message.
|
|
109
|
-
"@bike4mind/services": "2.35.1-cli-cancel-pending-message.
|
|
110
|
-
"@bike4mind/utils": "2.1.5-cli-cancel-pending-message.
|
|
107
|
+
"@bike4mind/common": "2.40.1-cli-cancel-pending-message.17327+02457534d",
|
|
108
|
+
"@bike4mind/mcp": "1.20.5-cli-cancel-pending-message.17327+02457534d",
|
|
109
|
+
"@bike4mind/services": "2.35.1-cli-cancel-pending-message.17327+02457534d",
|
|
110
|
+
"@bike4mind/utils": "2.1.5-cli-cancel-pending-message.17327+02457534d",
|
|
111
111
|
"@types/better-sqlite3": "^7.6.13",
|
|
112
112
|
"@types/diff": "^5.0.9",
|
|
113
113
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"typescript": "^5.9.3",
|
|
121
121
|
"vitest": "^3.2.4"
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "02457534dd28d3297ce20026e3a9735d658e67f1"
|
|
124
124
|
}
|