@bike4mind/cli 0.2.30-feat-cli-websocket-streaming.19243 → 0.2.30-feat-new-architecture.19278
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/{artifactExtractor-PK2WNCBH.js → artifactExtractor-7U23LA7G.js} +1 -1
- package/dist/{chunk-XXYKIX5X.js → chunk-6HFPBXKR.js} +2 -2
- package/dist/{chunk-KBRR7H2K.js → chunk-H6H5JFXR.js} +2 -2
- package/dist/{chunk-55ZDRTGQ.js → chunk-LNNVZDLN.js} +23 -75
- package/dist/{chunk-7EEPLDUG.js → chunk-WP3WMRSG.js} +1 -1
- package/dist/{chunk-K5IURWQT.js → chunk-ZX2SK6YL.js} +2 -2
- package/dist/{create-IUID2337.js → create-PTKEJ7VK.js} +3 -3
- package/dist/index.js +37 -504
- package/dist/{llmMarkdownGenerator-Q3PRX6UR.js → llmMarkdownGenerator-PUR2JBO6.js} +1 -1
- package/dist/{markdownGenerator-TFFIS7MF.js → markdownGenerator-5LUEGOKL.js} +1 -1
- package/dist/{mementoService-5ZUSQ4B4.js → mementoService-YDKHPMY5.js} +3 -3
- package/dist/{src-LLWYZKB2.js → src-L7KNOB2L.js} +2 -2
- package/dist/{src-QWRGDJYC.js → src-OYWNW52D.js} +1 -13
- package/dist/{subtractCredits-LXVQL26O.js → subtractCredits-OWBFQJK2.js} +3 -3
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
CurationArtifactType
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LNNVZDLN.js";
|
|
5
5
|
|
|
6
6
|
// ../../b4m-core/packages/services/dist/src/notebookCurationService/artifactExtractor.js
|
|
7
7
|
var ARTIFACT_TAG_REGEX = /<artifact\s+(.*?)>([\s\S]*?)<\/artifact>/gi;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BadRequestError,
|
|
4
4
|
secureParameters
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-WP3WMRSG.js";
|
|
6
6
|
import {
|
|
7
7
|
CompletionApiUsageTransaction,
|
|
8
8
|
GenericCreditDeductTransaction,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
TextGenerationUsageTransaction,
|
|
13
13
|
TransferCreditTransaction,
|
|
14
14
|
VideoGenerationUsageTransaction
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-LNNVZDLN.js";
|
|
16
16
|
|
|
17
17
|
// ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
|
|
18
18
|
import { z } from "zod";
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
getSettingsByNames,
|
|
7
7
|
obfuscateApiKey,
|
|
8
8
|
secureParameters
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WP3WMRSG.js";
|
|
10
10
|
import {
|
|
11
11
|
ApiKeyType,
|
|
12
12
|
MementoTier,
|
|
13
13
|
isSupportedEmbeddingModel
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LNNVZDLN.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -1181,29 +1181,6 @@ var VoiceSessionSendTranscriptAction = z10.object({
|
|
|
1181
1181
|
conversationItemId: z10.string(),
|
|
1182
1182
|
timestamp: z10.coerce.date().optional()
|
|
1183
1183
|
});
|
|
1184
|
-
var CliCompletionRequestAction = z10.object({
|
|
1185
|
-
action: z10.literal("cli_completion_request"),
|
|
1186
|
-
accessToken: z10.string(),
|
|
1187
|
-
requestId: z10.string().uuid(),
|
|
1188
|
-
model: z10.string(),
|
|
1189
|
-
messages: z10.array(z10.object({
|
|
1190
|
-
role: z10.enum(["user", "assistant", "system"]),
|
|
1191
|
-
content: z10.union([z10.string(), z10.array(z10.unknown())])
|
|
1192
|
-
})),
|
|
1193
|
-
options: z10.object({
|
|
1194
|
-
temperature: z10.number().optional(),
|
|
1195
|
-
maxTokens: z10.number().optional(),
|
|
1196
|
-
stream: z10.boolean().optional(),
|
|
1197
|
-
tools: z10.array(z10.unknown()).optional()
|
|
1198
|
-
}).optional()
|
|
1199
|
-
});
|
|
1200
|
-
var CliToolRequestAction = z10.object({
|
|
1201
|
-
action: z10.literal("cli_tool_request"),
|
|
1202
|
-
accessToken: z10.string(),
|
|
1203
|
-
requestId: z10.string().uuid(),
|
|
1204
|
-
toolName: z10.string(),
|
|
1205
|
-
input: z10.record(z10.unknown())
|
|
1206
|
-
});
|
|
1207
1184
|
var VoiceSessionEndedAction = z10.object({
|
|
1208
1185
|
action: z10.literal("voice_session_ended"),
|
|
1209
1186
|
userId: z10.string(),
|
|
@@ -1492,36 +1469,6 @@ var VoiceCreditsExhaustedAction = z10.object({
|
|
|
1492
1469
|
creditsUsed: z10.number(),
|
|
1493
1470
|
clientId: z10.string().optional()
|
|
1494
1471
|
});
|
|
1495
|
-
var CliCompletionChunkAction = z10.object({
|
|
1496
|
-
action: z10.literal("cli_completion_chunk"),
|
|
1497
|
-
requestId: z10.string(),
|
|
1498
|
-
chunk: z10.object({
|
|
1499
|
-
type: z10.enum(["content", "tool_use"]),
|
|
1500
|
-
text: z10.string(),
|
|
1501
|
-
tools: z10.array(z10.unknown()).optional(),
|
|
1502
|
-
usage: z10.object({
|
|
1503
|
-
inputTokens: z10.number().optional(),
|
|
1504
|
-
outputTokens: z10.number().optional()
|
|
1505
|
-
}).optional(),
|
|
1506
|
-
thinking: z10.array(z10.unknown()).optional()
|
|
1507
|
-
})
|
|
1508
|
-
});
|
|
1509
|
-
var CliCompletionDoneAction = z10.object({
|
|
1510
|
-
action: z10.literal("cli_completion_done"),
|
|
1511
|
-
requestId: z10.string()
|
|
1512
|
-
});
|
|
1513
|
-
var CliCompletionErrorAction = z10.object({
|
|
1514
|
-
action: z10.literal("cli_completion_error"),
|
|
1515
|
-
requestId: z10.string(),
|
|
1516
|
-
error: z10.string()
|
|
1517
|
-
});
|
|
1518
|
-
var CliToolResponseAction = z10.object({
|
|
1519
|
-
action: z10.literal("cli_tool_response"),
|
|
1520
|
-
requestId: z10.string(),
|
|
1521
|
-
success: z10.boolean(),
|
|
1522
|
-
content: z10.unknown().optional(),
|
|
1523
|
-
error: z10.string().optional()
|
|
1524
|
-
});
|
|
1525
1472
|
var SessionCreatedAction = shareableDocumentSchema.extend({
|
|
1526
1473
|
action: z10.literal("session.created"),
|
|
1527
1474
|
id: z10.string(),
|
|
@@ -1556,9 +1503,7 @@ var MessageDataToServer = z10.discriminatedUnion("action", [
|
|
|
1556
1503
|
DataUnsubscribeRequestAction,
|
|
1557
1504
|
HeartbeatAction,
|
|
1558
1505
|
VoiceSessionSendTranscriptAction,
|
|
1559
|
-
VoiceSessionEndedAction
|
|
1560
|
-
CliCompletionRequestAction,
|
|
1561
|
-
CliToolRequestAction
|
|
1506
|
+
VoiceSessionEndedAction
|
|
1562
1507
|
]);
|
|
1563
1508
|
var MessageDataToClient = z10.discriminatedUnion("action", [
|
|
1564
1509
|
DataSubscriptionUpdateAction,
|
|
@@ -1584,11 +1529,7 @@ var MessageDataToClient = z10.discriminatedUnion("action", [
|
|
|
1584
1529
|
PiHistoryCompleteAction,
|
|
1585
1530
|
PiHistoryErrorAction,
|
|
1586
1531
|
SessionCreatedAction,
|
|
1587
|
-
VoiceCreditsExhaustedAction
|
|
1588
|
-
CliCompletionChunkAction,
|
|
1589
|
-
CliCompletionDoneAction,
|
|
1590
|
-
CliCompletionErrorAction,
|
|
1591
|
-
CliToolResponseAction
|
|
1532
|
+
VoiceCreditsExhaustedAction
|
|
1592
1533
|
]);
|
|
1593
1534
|
|
|
1594
1535
|
// ../../b4m-core/packages/common/dist/src/schemas/cliCompletions.js
|
|
@@ -2528,6 +2469,8 @@ var SettingKeySchema = z21.enum([
|
|
|
2528
2469
|
"EnableEnhancedDateTime",
|
|
2529
2470
|
"EnableHistoricalFeatures",
|
|
2530
2471
|
"EnableAstronomyFeatures",
|
|
2472
|
+
// ARCHITECTURE TRANSITION
|
|
2473
|
+
"EnableArchitectureTransition",
|
|
2531
2474
|
// STREAMING RESILIENCE SETTINGS
|
|
2532
2475
|
"EnableStreamIdleTimeout",
|
|
2533
2476
|
"StreamIdleTimeoutSeconds",
|
|
@@ -2952,14 +2895,15 @@ var API_SERVICE_GROUPS = {
|
|
|
2952
2895
|
{ key: "EnableResearchEngine", order: 8 },
|
|
2953
2896
|
{ key: "EnableReactViewer", order: 9 },
|
|
2954
2897
|
{ key: "EnableDeepResearch", order: 10 },
|
|
2955
|
-
{ key: "
|
|
2956
|
-
{ key: "
|
|
2957
|
-
{ key: "
|
|
2958
|
-
{ key: "
|
|
2959
|
-
{ key: "
|
|
2960
|
-
{ key: "
|
|
2961
|
-
{ key: "
|
|
2962
|
-
{ key: "
|
|
2898
|
+
{ key: "EnableArchitectureTransition", order: 11 },
|
|
2899
|
+
{ key: "EnableLattice", order: 12 },
|
|
2900
|
+
{ key: "EnableKnowledgeBaseSearch", order: 13 },
|
|
2901
|
+
{ key: "EnableStreamIdleTimeout", order: 14 },
|
|
2902
|
+
{ key: "StreamIdleTimeoutSeconds", order: 15 },
|
|
2903
|
+
{ key: "EnableMcpToolFiltering", order: 16 },
|
|
2904
|
+
{ key: "McpToolFilteringMaxTools", order: 17 },
|
|
2905
|
+
{ key: "EnableParallelToolExecution", order: 18 },
|
|
2906
|
+
{ key: "EnableHelpChat", order: 19 }
|
|
2963
2907
|
]
|
|
2964
2908
|
},
|
|
2965
2909
|
NOTEBOOK: {
|
|
@@ -4072,6 +4016,16 @@ var settingsMap = {
|
|
|
4072
4016
|
group: API_SERVICE_GROUPS.DATETIME_ASTRONOMY.id,
|
|
4073
4017
|
order: 3
|
|
4074
4018
|
}),
|
|
4019
|
+
// Architecture Transition
|
|
4020
|
+
EnableArchitectureTransition: makeBooleanSetting({
|
|
4021
|
+
key: "EnableArchitectureTransition",
|
|
4022
|
+
name: "Enable Architecture Transition",
|
|
4023
|
+
defaultValue: false,
|
|
4024
|
+
description: "Enable the transition to the new Simplified Hexagonal Architecture pattern. When enabled, new features will use the core/infra separation pattern.",
|
|
4025
|
+
category: "Experimental",
|
|
4026
|
+
group: API_SERVICE_GROUPS.EXPERIMENTAL.id,
|
|
4027
|
+
order: 11
|
|
4028
|
+
}),
|
|
4075
4029
|
// Streaming Resilience Settings
|
|
4076
4030
|
EnableStreamIdleTimeout: makeBooleanSetting({
|
|
4077
4031
|
key: "EnableStreamIdleTimeout",
|
|
@@ -8783,8 +8737,6 @@ export {
|
|
|
8783
8737
|
DataUnsubscribeRequestAction,
|
|
8784
8738
|
HeartbeatAction,
|
|
8785
8739
|
VoiceSessionSendTranscriptAction,
|
|
8786
|
-
CliCompletionRequestAction,
|
|
8787
|
-
CliToolRequestAction,
|
|
8788
8740
|
VoiceSessionEndedAction,
|
|
8789
8741
|
DataSubscriptionUpdateAction,
|
|
8790
8742
|
LLMStatusUpdateAction,
|
|
@@ -8809,10 +8761,6 @@ export {
|
|
|
8809
8761
|
ImportHistoryJobProgressUpdateAction,
|
|
8810
8762
|
ResearchModeStreamAction,
|
|
8811
8763
|
VoiceCreditsExhaustedAction,
|
|
8812
|
-
CliCompletionChunkAction,
|
|
8813
|
-
CliCompletionDoneAction,
|
|
8814
|
-
CliCompletionErrorAction,
|
|
8815
|
-
CliToolResponseAction,
|
|
8816
8764
|
SessionCreatedAction,
|
|
8817
8765
|
MessageDataToServer,
|
|
8818
8766
|
MessageDataToClient,
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
getSettingsMap,
|
|
8
8
|
getSettingsValue,
|
|
9
9
|
secureParameters
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-WP3WMRSG.js";
|
|
11
11
|
import {
|
|
12
12
|
KnowledgeType,
|
|
13
13
|
SupportedFabFileMimeTypes
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LNNVZDLN.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/fabFileService/create.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createFabFile,
|
|
4
4
|
createFabFileSchema
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-ZX2SK6YL.js";
|
|
6
|
+
import "./chunk-WP3WMRSG.js";
|
|
7
|
+
import "./chunk-LNNVZDLN.js";
|
|
8
8
|
import "./chunk-OCYRD7D6.js";
|
|
9
9
|
export {
|
|
10
10
|
createFabFile,
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getEffectiveApiKey,
|
|
6
6
|
getOpenWeatherKey,
|
|
7
7
|
getSerperKey
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-H6H5JFXR.js";
|
|
9
9
|
import "./chunk-RUI6HNLO.js";
|
|
10
10
|
import {
|
|
11
11
|
ConfigStore,
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
selectActiveBackgroundAgents,
|
|
16
16
|
useCliStore
|
|
17
17
|
} from "./chunk-BYXFQJYT.js";
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-6HFPBXKR.js";
|
|
19
|
+
import "./chunk-ZX2SK6YL.js";
|
|
20
20
|
import {
|
|
21
21
|
BFLImageService,
|
|
22
22
|
BaseStorage,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
OpenAIBackend,
|
|
29
29
|
OpenAIImageService,
|
|
30
30
|
XAIImageService
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-WP3WMRSG.js";
|
|
32
32
|
import {
|
|
33
33
|
AiEvents,
|
|
34
34
|
ApiKeyEvents,
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
XAI_IMAGE_MODELS,
|
|
85
85
|
b4mLLMTools,
|
|
86
86
|
getMcpProviderMetadata
|
|
87
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-LNNVZDLN.js";
|
|
88
88
|
import {
|
|
89
89
|
Logger
|
|
90
90
|
} from "./chunk-OCYRD7D6.js";
|
|
@@ -94,7 +94,7 @@ import React21, { useState as useState10, useEffect as useEffect7, useCallback a
|
|
|
94
94
|
import { render, Box as Box20, Text as Text20, useApp, useInput as useInput9 } from "ink";
|
|
95
95
|
import { execSync } from "child_process";
|
|
96
96
|
import { randomBytes as randomBytes5 } from "crypto";
|
|
97
|
-
import { v4 as
|
|
97
|
+
import { v4 as uuidv411 } from "uuid";
|
|
98
98
|
|
|
99
99
|
// src/components/App.tsx
|
|
100
100
|
import React15, { useState as useState6, useEffect as useEffect5 } from "react";
|
|
@@ -4032,7 +4032,8 @@ var updateUserSchema = z7.object({
|
|
|
4032
4032
|
})).nullable().optional(),
|
|
4033
4033
|
securityQuestions: z7.array(z7.object({ question: z7.string(), answer: z7.string() })).nullable().optional(),
|
|
4034
4034
|
photoUrl: z7.string().nullable().optional(),
|
|
4035
|
-
showCreditsUsed: z7.boolean().optional()
|
|
4035
|
+
showCreditsUsed: z7.boolean().optional(),
|
|
4036
|
+
architectureTransitions: z7.record(z7.string(), z7.boolean()).optional()
|
|
4036
4037
|
});
|
|
4037
4038
|
|
|
4038
4039
|
// ../../b4m-core/packages/services/dist/src/userService/adminUpdate.js
|
|
@@ -12537,10 +12538,6 @@ var ServerToolExecutor = class {
|
|
|
12537
12538
|
};
|
|
12538
12539
|
|
|
12539
12540
|
// src/llm/ToolRouter.ts
|
|
12540
|
-
var wsToolExecutor = null;
|
|
12541
|
-
function setWebSocketToolExecutor(executor) {
|
|
12542
|
-
wsToolExecutor = executor;
|
|
12543
|
-
}
|
|
12544
12541
|
var SERVER_TOOLS = ["weather_info", "web_search", "web_fetch"];
|
|
12545
12542
|
var LOCAL_TOOLS = [
|
|
12546
12543
|
"file_read",
|
|
@@ -12563,15 +12560,7 @@ function isLocalTool(toolName) {
|
|
|
12563
12560
|
}
|
|
12564
12561
|
async function executeTool(toolName, input, apiClient, localToolFn) {
|
|
12565
12562
|
if (isServerTool(toolName)) {
|
|
12566
|
-
|
|
12567
|
-
logger.debug(`[ToolRouter] Routing ${toolName} to server via WebSocket`);
|
|
12568
|
-
const result = await wsToolExecutor.execute(toolName, input);
|
|
12569
|
-
if (!result.success) {
|
|
12570
|
-
return `Error executing ${toolName}: ${result.error || "Tool execution failed"}`;
|
|
12571
|
-
}
|
|
12572
|
-
return typeof result.content === "string" ? result.content : JSON.stringify(result.content ?? "");
|
|
12573
|
-
}
|
|
12574
|
-
logger.debug(`[ToolRouter] Routing ${toolName} to server via HTTP`);
|
|
12563
|
+
logger.debug(`[ToolRouter] Routing ${toolName} to server`);
|
|
12575
12564
|
const executor = new ServerToolExecutor(apiClient);
|
|
12576
12565
|
return await executor.executeTool(toolName, input);
|
|
12577
12566
|
} else if (isLocalTool(toolName)) {
|
|
@@ -14533,173 +14522,6 @@ var ServerLlmBackend = class {
|
|
|
14533
14522
|
}
|
|
14534
14523
|
};
|
|
14535
14524
|
|
|
14536
|
-
// src/llm/WebSocketLlmBackend.ts
|
|
14537
|
-
import { v4 as uuidv411 } from "uuid";
|
|
14538
|
-
function stripThinkingBlocks2(text) {
|
|
14539
|
-
return text.replace(/<think>[\s\S]*?<\/think>/g, "").trim();
|
|
14540
|
-
}
|
|
14541
|
-
var WebSocketLlmBackend = class {
|
|
14542
|
-
constructor(options) {
|
|
14543
|
-
this.wsManager = options.wsManager;
|
|
14544
|
-
this.apiClient = options.apiClient;
|
|
14545
|
-
this.currentModel = options.model;
|
|
14546
|
-
this.tokenGetter = options.tokenGetter;
|
|
14547
|
-
this.wsCompletionUrl = options.wsCompletionUrl;
|
|
14548
|
-
}
|
|
14549
|
-
/**
|
|
14550
|
-
* Send completion request via HTTP POST, receive streaming response via WebSocket.
|
|
14551
|
-
* Collects all streamed chunks, then calls callback once at completion
|
|
14552
|
-
* with the full accumulated content.
|
|
14553
|
-
*/
|
|
14554
|
-
async complete(model, messages, options, callback) {
|
|
14555
|
-
logger.debug(`[WebSocketLlmBackend] Starting complete() with model: ${model}`);
|
|
14556
|
-
if (options.abortSignal?.aborted) {
|
|
14557
|
-
logger.debug("[WebSocketLlmBackend] Request aborted before start");
|
|
14558
|
-
return;
|
|
14559
|
-
}
|
|
14560
|
-
if (!this.wsManager.isConnected) {
|
|
14561
|
-
throw new Error("WebSocket is not connected");
|
|
14562
|
-
}
|
|
14563
|
-
const requestId = uuidv411();
|
|
14564
|
-
return new Promise((resolve3, reject) => {
|
|
14565
|
-
const isVerbose = process.env.B4M_VERBOSE === "1";
|
|
14566
|
-
const isUltraVerbose = process.env.B4M_DEBUG_STREAM === "1";
|
|
14567
|
-
const streamLogger = new StreamLogger(logger, "WebSocketLlmBackend", isVerbose, isUltraVerbose);
|
|
14568
|
-
streamLogger.streamStart();
|
|
14569
|
-
let eventCount = 0;
|
|
14570
|
-
let accumulatedText = "";
|
|
14571
|
-
let lastUsageInfo = {};
|
|
14572
|
-
let toolsUsed = [];
|
|
14573
|
-
let thinkingBlocks = [];
|
|
14574
|
-
let settled = false;
|
|
14575
|
-
const settle = (action) => {
|
|
14576
|
-
if (settled) return;
|
|
14577
|
-
settled = true;
|
|
14578
|
-
this.wsManager.offRequest(requestId);
|
|
14579
|
-
this.wsManager.offDisconnect(onDisconnect);
|
|
14580
|
-
action();
|
|
14581
|
-
};
|
|
14582
|
-
const settleResolve = () => settle(() => resolve3());
|
|
14583
|
-
const settleReject = (err) => settle(() => reject(err));
|
|
14584
|
-
const onDisconnect = () => {
|
|
14585
|
-
logger.debug("[WebSocketLlmBackend] Connection dropped during completion");
|
|
14586
|
-
settleReject(new Error("WebSocket connection lost during completion"));
|
|
14587
|
-
};
|
|
14588
|
-
this.wsManager.onDisconnect(onDisconnect);
|
|
14589
|
-
if (options.abortSignal) {
|
|
14590
|
-
if (options.abortSignal.aborted) {
|
|
14591
|
-
settleResolve();
|
|
14592
|
-
return;
|
|
14593
|
-
}
|
|
14594
|
-
options.abortSignal.addEventListener(
|
|
14595
|
-
"abort",
|
|
14596
|
-
() => {
|
|
14597
|
-
logger.debug("[WebSocketLlmBackend] Abort signal received");
|
|
14598
|
-
settleResolve();
|
|
14599
|
-
},
|
|
14600
|
-
{ once: true }
|
|
14601
|
-
);
|
|
14602
|
-
}
|
|
14603
|
-
const updateUsage = (usage) => {
|
|
14604
|
-
if (usage) {
|
|
14605
|
-
lastUsageInfo = { inputTokens: usage.inputTokens, outputTokens: usage.outputTokens };
|
|
14606
|
-
}
|
|
14607
|
-
};
|
|
14608
|
-
this.wsManager.onRequest(requestId, (message) => {
|
|
14609
|
-
if (options.abortSignal?.aborted) return;
|
|
14610
|
-
const action = message.action;
|
|
14611
|
-
if (action === "cli_completion_chunk") {
|
|
14612
|
-
eventCount++;
|
|
14613
|
-
const chunk = message.chunk;
|
|
14614
|
-
streamLogger.onEvent(eventCount, JSON.stringify(chunk));
|
|
14615
|
-
const textChunk = chunk.text || "";
|
|
14616
|
-
if (textChunk) accumulatedText += textChunk;
|
|
14617
|
-
updateUsage(chunk.usage);
|
|
14618
|
-
if (chunk.type === "content") {
|
|
14619
|
-
streamLogger.onContent(eventCount, textChunk, accumulatedText);
|
|
14620
|
-
} else if (chunk.type === "tool_use") {
|
|
14621
|
-
streamLogger.onCriticalEvent(eventCount, "TOOL_USE", `tools: ${chunk.tools?.length}`);
|
|
14622
|
-
if (chunk.tools && chunk.tools.length > 0) toolsUsed = chunk.tools;
|
|
14623
|
-
if (chunk.thinking && chunk.thinking.length > 0) thinkingBlocks = chunk.thinking;
|
|
14624
|
-
}
|
|
14625
|
-
} else if (action === "cli_completion_done") {
|
|
14626
|
-
streamLogger.streamComplete(accumulatedText);
|
|
14627
|
-
const cleanedText = stripThinkingBlocks2(accumulatedText);
|
|
14628
|
-
if (!cleanedText && toolsUsed.length === 0) {
|
|
14629
|
-
settleResolve();
|
|
14630
|
-
return;
|
|
14631
|
-
}
|
|
14632
|
-
const info = {
|
|
14633
|
-
...lastUsageInfo,
|
|
14634
|
-
...toolsUsed.length > 0 && { toolsUsed },
|
|
14635
|
-
...thinkingBlocks.length > 0 && { thinking: thinkingBlocks }
|
|
14636
|
-
};
|
|
14637
|
-
callback([cleanedText], info).then(() => settleResolve()).catch((err) => settleReject(err));
|
|
14638
|
-
} else if (action === "cli_completion_error") {
|
|
14639
|
-
const errorMsg = message.error || "Server error";
|
|
14640
|
-
streamLogger.onCriticalEvent(eventCount, "ERROR", errorMsg);
|
|
14641
|
-
settleReject(new Error(errorMsg));
|
|
14642
|
-
}
|
|
14643
|
-
});
|
|
14644
|
-
const axiosInstance = this.apiClient.getAxiosInstance();
|
|
14645
|
-
axiosInstance.post(
|
|
14646
|
-
this.wsCompletionUrl,
|
|
14647
|
-
{
|
|
14648
|
-
requestId,
|
|
14649
|
-
model,
|
|
14650
|
-
messages,
|
|
14651
|
-
options: {
|
|
14652
|
-
temperature: options.temperature,
|
|
14653
|
-
maxTokens: options.maxTokens,
|
|
14654
|
-
stream: true,
|
|
14655
|
-
tools: options.tools || []
|
|
14656
|
-
}
|
|
14657
|
-
},
|
|
14658
|
-
{ signal: options.abortSignal }
|
|
14659
|
-
).catch((err) => {
|
|
14660
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
14661
|
-
settleReject(new Error(`HTTP request failed: ${msg}`));
|
|
14662
|
-
});
|
|
14663
|
-
});
|
|
14664
|
-
}
|
|
14665
|
-
/**
|
|
14666
|
-
* Get available models from server (REST call, not streaming).
|
|
14667
|
-
* Delegates to ApiClient -- same as ServerLlmBackend.
|
|
14668
|
-
*/
|
|
14669
|
-
async getModelInfo() {
|
|
14670
|
-
try {
|
|
14671
|
-
logger.debug("[WebSocketLlmBackend] Fetching models from /api/models");
|
|
14672
|
-
const response = await this.apiClient.get("/api/models");
|
|
14673
|
-
if (!response || typeof response !== "object" || !Array.isArray(response.models)) {
|
|
14674
|
-
logger.warn("[WebSocketLlmBackend] Invalid API response format, using fallback models");
|
|
14675
|
-
return this.getFallbackModels();
|
|
14676
|
-
}
|
|
14677
|
-
const filteredModels = response.models.filter(
|
|
14678
|
-
(model) => model.type === "text" && model.supportsTools === true
|
|
14679
|
-
);
|
|
14680
|
-
if (filteredModels.length === 0) {
|
|
14681
|
-
logger.warn("[WebSocketLlmBackend] No CLI-compatible models found, using fallback");
|
|
14682
|
-
return this.getFallbackModels();
|
|
14683
|
-
}
|
|
14684
|
-
logger.debug(`[WebSocketLlmBackend] Loaded ${filteredModels.length} models`);
|
|
14685
|
-
return filteredModels;
|
|
14686
|
-
} catch (error) {
|
|
14687
|
-
logger.warn(
|
|
14688
|
-
`[WebSocketLlmBackend] Failed to fetch models: ${error instanceof Error ? error.message : String(error)}`
|
|
14689
|
-
);
|
|
14690
|
-
return this.getFallbackModels();
|
|
14691
|
-
}
|
|
14692
|
-
}
|
|
14693
|
-
getFallbackModels() {
|
|
14694
|
-
return [
|
|
14695
|
-
{ id: "claude-sonnet-4-5-20250929", name: "Claude 4.5 Sonnet" },
|
|
14696
|
-
{ id: "claude-3-5-haiku-20241022", name: "Claude 3.5 Haiku" },
|
|
14697
|
-
{ id: "gpt-4o", name: "GPT-4o" },
|
|
14698
|
-
{ id: "gpt-4o-mini", name: "GPT-4o Mini" }
|
|
14699
|
-
];
|
|
14700
|
-
}
|
|
14701
|
-
};
|
|
14702
|
-
|
|
14703
14525
|
// src/llm/NotifyingLlmBackend.ts
|
|
14704
14526
|
var NotifyingLlmBackend = class {
|
|
14705
14527
|
constructor(inner, backgroundManager) {
|
|
@@ -14734,253 +14556,6 @@ Please acknowledge these background agent results and incorporate them into your
|
|
|
14734
14556
|
}
|
|
14735
14557
|
};
|
|
14736
14558
|
|
|
14737
|
-
// src/ws/WebSocketConnectionManager.ts
|
|
14738
|
-
var WebSocketConnectionManager = class {
|
|
14739
|
-
constructor(wsUrl, getToken) {
|
|
14740
|
-
this.ws = null;
|
|
14741
|
-
this.heartbeatInterval = null;
|
|
14742
|
-
this.reconnectAttempts = 0;
|
|
14743
|
-
this.maxReconnectDelay = 3e4;
|
|
14744
|
-
this.handlers = /* @__PURE__ */ new Map();
|
|
14745
|
-
this.disconnectHandlers = /* @__PURE__ */ new Set();
|
|
14746
|
-
this.reconnectTimer = null;
|
|
14747
|
-
this.connected = false;
|
|
14748
|
-
this.connecting = false;
|
|
14749
|
-
this.closed = false;
|
|
14750
|
-
this.wsUrl = wsUrl;
|
|
14751
|
-
this.getToken = getToken;
|
|
14752
|
-
}
|
|
14753
|
-
/**
|
|
14754
|
-
* Connect to the WebSocket server.
|
|
14755
|
-
* Resolves when connection is established, rejects on failure.
|
|
14756
|
-
*/
|
|
14757
|
-
async connect() {
|
|
14758
|
-
if (this.connected || this.connecting) return;
|
|
14759
|
-
this.connecting = true;
|
|
14760
|
-
const token = await this.getToken();
|
|
14761
|
-
if (!token) {
|
|
14762
|
-
this.connecting = false;
|
|
14763
|
-
throw new Error("No access token available for WebSocket connection");
|
|
14764
|
-
}
|
|
14765
|
-
return new Promise((resolve3, reject) => {
|
|
14766
|
-
logger.debug(`[WS] Connecting to ${this.wsUrl}...`);
|
|
14767
|
-
this.ws = new WebSocket(this.wsUrl, [`access_token.${token}`]);
|
|
14768
|
-
this.ws.onopen = () => {
|
|
14769
|
-
logger.debug("[WS] Connected");
|
|
14770
|
-
this.connected = true;
|
|
14771
|
-
this.connecting = false;
|
|
14772
|
-
this.reconnectAttempts = 0;
|
|
14773
|
-
this.startHeartbeat();
|
|
14774
|
-
resolve3();
|
|
14775
|
-
};
|
|
14776
|
-
this.ws.onmessage = (event) => {
|
|
14777
|
-
try {
|
|
14778
|
-
const data = typeof event.data === "string" ? event.data : event.data.toString();
|
|
14779
|
-
const message = JSON.parse(data);
|
|
14780
|
-
const requestId = message.requestId;
|
|
14781
|
-
if (requestId && this.handlers.has(requestId)) {
|
|
14782
|
-
this.handlers.get(requestId)(message);
|
|
14783
|
-
} else {
|
|
14784
|
-
logger.debug(`[WS] Unhandled message: ${message.action || "unknown"}`);
|
|
14785
|
-
}
|
|
14786
|
-
} catch (err) {
|
|
14787
|
-
logger.debug(`[WS] Failed to parse message: ${err}`);
|
|
14788
|
-
}
|
|
14789
|
-
};
|
|
14790
|
-
this.ws.onclose = () => {
|
|
14791
|
-
logger.debug("[WS] Connection closed");
|
|
14792
|
-
this.cleanup();
|
|
14793
|
-
this.notifyDisconnect();
|
|
14794
|
-
if (!this.closed) {
|
|
14795
|
-
this.scheduleReconnect();
|
|
14796
|
-
}
|
|
14797
|
-
};
|
|
14798
|
-
this.ws.onerror = (err) => {
|
|
14799
|
-
logger.debug(`[WS] Error: ${err}`);
|
|
14800
|
-
if (this.connecting) {
|
|
14801
|
-
this.connecting = false;
|
|
14802
|
-
this.connected = false;
|
|
14803
|
-
reject(new Error("WebSocket connection failed"));
|
|
14804
|
-
}
|
|
14805
|
-
};
|
|
14806
|
-
});
|
|
14807
|
-
}
|
|
14808
|
-
/** Whether the connection is currently established */
|
|
14809
|
-
get isConnected() {
|
|
14810
|
-
return this.connected;
|
|
14811
|
-
}
|
|
14812
|
-
/**
|
|
14813
|
-
* Send a JSON message over the WebSocket connection.
|
|
14814
|
-
*/
|
|
14815
|
-
send(data) {
|
|
14816
|
-
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
14817
|
-
throw new Error("WebSocket is not connected");
|
|
14818
|
-
}
|
|
14819
|
-
const payload = JSON.stringify(data);
|
|
14820
|
-
const sizeKB = (payload.length / 1024).toFixed(1);
|
|
14821
|
-
logger.debug(`[WS] Sending ${sizeKB} KB (action: ${data.action})`);
|
|
14822
|
-
if (payload.length > 32e3) {
|
|
14823
|
-
logger.warn(`[WS] Payload ${sizeKB} KB exceeds API Gateway 32 KB frame limit \u2014 connection will be closed`);
|
|
14824
|
-
}
|
|
14825
|
-
this.ws.send(payload);
|
|
14826
|
-
}
|
|
14827
|
-
/**
|
|
14828
|
-
* Register a handler for messages matching a specific requestId.
|
|
14829
|
-
*/
|
|
14830
|
-
onRequest(requestId, handler) {
|
|
14831
|
-
this.handlers.set(requestId, handler);
|
|
14832
|
-
}
|
|
14833
|
-
/**
|
|
14834
|
-
* Remove a handler for a specific requestId.
|
|
14835
|
-
*/
|
|
14836
|
-
offRequest(requestId) {
|
|
14837
|
-
this.handlers.delete(requestId);
|
|
14838
|
-
}
|
|
14839
|
-
/**
|
|
14840
|
-
* Register a handler that fires when the connection drops.
|
|
14841
|
-
*/
|
|
14842
|
-
onDisconnect(handler) {
|
|
14843
|
-
this.disconnectHandlers.add(handler);
|
|
14844
|
-
}
|
|
14845
|
-
/**
|
|
14846
|
-
* Remove a disconnect handler.
|
|
14847
|
-
*/
|
|
14848
|
-
offDisconnect(handler) {
|
|
14849
|
-
this.disconnectHandlers.delete(handler);
|
|
14850
|
-
}
|
|
14851
|
-
/**
|
|
14852
|
-
* Close the connection and stop all heartbeat/reconnect logic.
|
|
14853
|
-
*/
|
|
14854
|
-
disconnect() {
|
|
14855
|
-
this.closed = true;
|
|
14856
|
-
this.cleanup();
|
|
14857
|
-
if (this.ws) {
|
|
14858
|
-
this.ws.close();
|
|
14859
|
-
this.ws = null;
|
|
14860
|
-
}
|
|
14861
|
-
this.handlers.clear();
|
|
14862
|
-
this.disconnectHandlers.clear();
|
|
14863
|
-
}
|
|
14864
|
-
startHeartbeat() {
|
|
14865
|
-
this.stopHeartbeat();
|
|
14866
|
-
this.heartbeatInterval = setInterval(
|
|
14867
|
-
() => {
|
|
14868
|
-
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
14869
|
-
this.ws.send(JSON.stringify({ action: "heartbeat" }));
|
|
14870
|
-
logger.debug("[WS] Heartbeat sent");
|
|
14871
|
-
}
|
|
14872
|
-
},
|
|
14873
|
-
5 * 60 * 1e3
|
|
14874
|
-
);
|
|
14875
|
-
}
|
|
14876
|
-
stopHeartbeat() {
|
|
14877
|
-
if (this.heartbeatInterval) {
|
|
14878
|
-
clearInterval(this.heartbeatInterval);
|
|
14879
|
-
this.heartbeatInterval = null;
|
|
14880
|
-
}
|
|
14881
|
-
}
|
|
14882
|
-
cleanup() {
|
|
14883
|
-
this.connected = false;
|
|
14884
|
-
this.connecting = false;
|
|
14885
|
-
this.stopHeartbeat();
|
|
14886
|
-
if (this.reconnectTimer) {
|
|
14887
|
-
clearTimeout(this.reconnectTimer);
|
|
14888
|
-
this.reconnectTimer = null;
|
|
14889
|
-
}
|
|
14890
|
-
}
|
|
14891
|
-
notifyDisconnect() {
|
|
14892
|
-
for (const handler of this.disconnectHandlers) {
|
|
14893
|
-
try {
|
|
14894
|
-
handler();
|
|
14895
|
-
} catch {
|
|
14896
|
-
}
|
|
14897
|
-
}
|
|
14898
|
-
}
|
|
14899
|
-
scheduleReconnect() {
|
|
14900
|
-
if (this.closed) return;
|
|
14901
|
-
this.reconnectAttempts++;
|
|
14902
|
-
const delay = Math.min(1e3 * Math.pow(2, this.reconnectAttempts - 1), this.maxReconnectDelay);
|
|
14903
|
-
logger.debug(`[WS] Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts})`);
|
|
14904
|
-
this.reconnectTimer = setTimeout(async () => {
|
|
14905
|
-
this.reconnectTimer = null;
|
|
14906
|
-
if (this.closed) return;
|
|
14907
|
-
try {
|
|
14908
|
-
await this.connect();
|
|
14909
|
-
} catch {
|
|
14910
|
-
logger.debug("[WS] Reconnection failed");
|
|
14911
|
-
}
|
|
14912
|
-
}, delay);
|
|
14913
|
-
}
|
|
14914
|
-
};
|
|
14915
|
-
|
|
14916
|
-
// src/ws/WebSocketToolExecutor.ts
|
|
14917
|
-
import { v4 as uuidv412 } from "uuid";
|
|
14918
|
-
var WebSocketToolExecutor = class {
|
|
14919
|
-
constructor(wsManager, tokenGetter) {
|
|
14920
|
-
this.wsManager = wsManager;
|
|
14921
|
-
this.tokenGetter = tokenGetter;
|
|
14922
|
-
}
|
|
14923
|
-
/**
|
|
14924
|
-
* Execute a server-side tool via WebSocket.
|
|
14925
|
-
* Returns the tool result or throws on error.
|
|
14926
|
-
*/
|
|
14927
|
-
async execute(toolName, input, abortSignal) {
|
|
14928
|
-
if (!this.wsManager.isConnected) {
|
|
14929
|
-
throw new Error("WebSocket is not connected");
|
|
14930
|
-
}
|
|
14931
|
-
const token = await this.tokenGetter();
|
|
14932
|
-
if (!token) {
|
|
14933
|
-
throw new Error("No access token available");
|
|
14934
|
-
}
|
|
14935
|
-
const requestId = uuidv412();
|
|
14936
|
-
return new Promise((resolve3, reject) => {
|
|
14937
|
-
let settled = false;
|
|
14938
|
-
const settle = (action) => {
|
|
14939
|
-
if (settled) return;
|
|
14940
|
-
settled = true;
|
|
14941
|
-
this.wsManager.offRequest(requestId);
|
|
14942
|
-
this.wsManager.offDisconnect(onDisconnect);
|
|
14943
|
-
action();
|
|
14944
|
-
};
|
|
14945
|
-
const settleResolve = (result) => settle(() => resolve3(result));
|
|
14946
|
-
const settleReject = (err) => settle(() => reject(err));
|
|
14947
|
-
const onDisconnect = () => {
|
|
14948
|
-
settleReject(new Error("WebSocket connection lost during tool execution"));
|
|
14949
|
-
};
|
|
14950
|
-
this.wsManager.onDisconnect(onDisconnect);
|
|
14951
|
-
if (abortSignal) {
|
|
14952
|
-
if (abortSignal.aborted) {
|
|
14953
|
-
settleReject(new Error("Tool execution aborted"));
|
|
14954
|
-
return;
|
|
14955
|
-
}
|
|
14956
|
-
abortSignal.addEventListener("abort", () => settleReject(new Error("Tool execution aborted")), {
|
|
14957
|
-
once: true
|
|
14958
|
-
});
|
|
14959
|
-
}
|
|
14960
|
-
this.wsManager.onRequest(requestId, (message) => {
|
|
14961
|
-
if (message.action === "cli_tool_response") {
|
|
14962
|
-
settleResolve({
|
|
14963
|
-
success: message.success,
|
|
14964
|
-
content: message.content,
|
|
14965
|
-
error: message.error
|
|
14966
|
-
});
|
|
14967
|
-
}
|
|
14968
|
-
});
|
|
14969
|
-
try {
|
|
14970
|
-
this.wsManager.send({
|
|
14971
|
-
action: "cli_tool_request",
|
|
14972
|
-
accessToken: token,
|
|
14973
|
-
requestId,
|
|
14974
|
-
toolName,
|
|
14975
|
-
input
|
|
14976
|
-
});
|
|
14977
|
-
} catch (err) {
|
|
14978
|
-
settleReject(err instanceof Error ? err : new Error(String(err)));
|
|
14979
|
-
}
|
|
14980
|
-
});
|
|
14981
|
-
}
|
|
14982
|
-
};
|
|
14983
|
-
|
|
14984
14559
|
// src/auth/ApiClient.ts
|
|
14985
14560
|
import axios11 from "axios";
|
|
14986
14561
|
var ApiClient = class {
|
|
@@ -15118,7 +14693,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
|
|
|
15118
14693
|
// package.json
|
|
15119
14694
|
var package_default = {
|
|
15120
14695
|
name: "@bike4mind/cli",
|
|
15121
|
-
version: "0.2.30-feat-
|
|
14696
|
+
version: "0.2.30-feat-new-architecture.19278+592a62bc7",
|
|
15122
14697
|
type: "module",
|
|
15123
14698
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
15124
14699
|
license: "UNLICENSED",
|
|
@@ -15229,10 +14804,10 @@ var package_default = {
|
|
|
15229
14804
|
},
|
|
15230
14805
|
devDependencies: {
|
|
15231
14806
|
"@bike4mind/agents": "0.1.0",
|
|
15232
|
-
"@bike4mind/common": "2.51.1-feat-
|
|
15233
|
-
"@bike4mind/mcp": "1.30.1-feat-
|
|
15234
|
-
"@bike4mind/services": "2.49.1-feat-
|
|
15235
|
-
"@bike4mind/utils": "2.6.1-feat-
|
|
14807
|
+
"@bike4mind/common": "2.51.1-feat-new-architecture.19278+592a62bc7",
|
|
14808
|
+
"@bike4mind/mcp": "1.30.1-feat-new-architecture.19278+592a62bc7",
|
|
14809
|
+
"@bike4mind/services": "2.49.1-feat-new-architecture.19278+592a62bc7",
|
|
14810
|
+
"@bike4mind/utils": "2.6.1-feat-new-architecture.19278+592a62bc7",
|
|
15236
14811
|
"@types/better-sqlite3": "^7.6.13",
|
|
15237
14812
|
"@types/diff": "^5.0.9",
|
|
15238
14813
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -15253,7 +14828,7 @@ var package_default = {
|
|
|
15253
14828
|
optionalDependencies: {
|
|
15254
14829
|
"@vscode/ripgrep": "^1.17.0"
|
|
15255
14830
|
},
|
|
15256
|
-
gitHead: "
|
|
14831
|
+
gitHead: "592a62bc71d62dd7598efffcf6c15eedb1087cc7"
|
|
15257
14832
|
};
|
|
15258
14833
|
|
|
15259
14834
|
// src/agents/toolFilter.ts
|
|
@@ -17027,8 +16602,7 @@ function CliApp() {
|
|
|
17027
16602
|
agentStore: null,
|
|
17028
16603
|
abortController: null,
|
|
17029
16604
|
contextContent: "",
|
|
17030
|
-
backgroundManager: null
|
|
17031
|
-
wsManager: null
|
|
16605
|
+
backgroundManager: null
|
|
17032
16606
|
});
|
|
17033
16607
|
const [isInitialized, setIsInitialized] = useState10(false);
|
|
17034
16608
|
const [initError, setInitError] = useState10(null);
|
|
@@ -17056,10 +16630,6 @@ function CliApp() {
|
|
|
17056
16630
|
})
|
|
17057
16631
|
);
|
|
17058
16632
|
}
|
|
17059
|
-
if (state.wsManager) {
|
|
17060
|
-
state.wsManager.disconnect();
|
|
17061
|
-
setWebSocketToolExecutor(null);
|
|
17062
|
-
}
|
|
17063
16633
|
if (state.agent) {
|
|
17064
16634
|
state.agent.removeAllListeners();
|
|
17065
16635
|
}
|
|
@@ -17078,7 +16648,7 @@ function CliApp() {
|
|
|
17078
16648
|
setTimeout(() => {
|
|
17079
16649
|
process.exit(0);
|
|
17080
16650
|
}, 100);
|
|
17081
|
-
}, [state.session, state.sessionStore, state.mcpManager, state.agent, state.imageStore
|
|
16651
|
+
}, [state.session, state.sessionStore, state.mcpManager, state.agent, state.imageStore]);
|
|
17082
16652
|
useInput9((input, key) => {
|
|
17083
16653
|
if (key.escape) {
|
|
17084
16654
|
const store = useCliStore.getState();
|
|
@@ -17153,7 +16723,7 @@ function CliApp() {
|
|
|
17153
16723
|
if (!isAuthenticated) {
|
|
17154
16724
|
console.log("\u2139\uFE0F AI features disabled. Available commands: /login, /help, /config\n");
|
|
17155
16725
|
const minimalSession = {
|
|
17156
|
-
id:
|
|
16726
|
+
id: uuidv411(),
|
|
17157
16727
|
name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
|
|
17158
16728
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17159
16729
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17181,45 +16751,10 @@ function CliApp() {
|
|
|
17181
16751
|
console.log(`\u{1F30D} API Environment: ${envName} (${apiBaseURL})`);
|
|
17182
16752
|
}
|
|
17183
16753
|
const apiClient = new ApiClient(apiBaseURL, state.configStore);
|
|
17184
|
-
const
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
};
|
|
17188
|
-
let wsManager = null;
|
|
17189
|
-
let llm;
|
|
17190
|
-
try {
|
|
17191
|
-
const serverConfig = await apiClient.get(
|
|
17192
|
-
"/api/settings/serverConfig"
|
|
17193
|
-
);
|
|
17194
|
-
const wsUrl = serverConfig?.websocketUrl;
|
|
17195
|
-
const wsCompletionUrl = serverConfig?.wsCompletionUrl;
|
|
17196
|
-
if (wsUrl && wsCompletionUrl) {
|
|
17197
|
-
wsManager = new WebSocketConnectionManager(wsUrl, tokenGetter);
|
|
17198
|
-
await wsManager.connect();
|
|
17199
|
-
const wsToolExecutor2 = new WebSocketToolExecutor(wsManager, tokenGetter);
|
|
17200
|
-
setWebSocketToolExecutor(wsToolExecutor2);
|
|
17201
|
-
llm = new WebSocketLlmBackend({
|
|
17202
|
-
wsManager,
|
|
17203
|
-
apiClient,
|
|
17204
|
-
model: config.defaultModel,
|
|
17205
|
-
tokenGetter,
|
|
17206
|
-
wsCompletionUrl
|
|
17207
|
-
});
|
|
17208
|
-
logger.debug("\u{1F50C} Using WebSocket transport (bypasses CloudFront timeout)");
|
|
17209
|
-
} else {
|
|
17210
|
-
throw new Error("No websocketUrl or wsCompletionUrl in server config");
|
|
17211
|
-
}
|
|
17212
|
-
} catch (wsError) {
|
|
17213
|
-
logger.debug(
|
|
17214
|
-
`[WS] WebSocket unavailable, using SSE fallback: ${wsError instanceof Error ? wsError.message : String(wsError)}`
|
|
17215
|
-
);
|
|
17216
|
-
wsManager = null;
|
|
17217
|
-
setWebSocketToolExecutor(null);
|
|
17218
|
-
llm = new ServerLlmBackend({
|
|
17219
|
-
apiClient,
|
|
17220
|
-
model: config.defaultModel
|
|
17221
|
-
});
|
|
17222
|
-
}
|
|
16754
|
+
const llm = new ServerLlmBackend({
|
|
16755
|
+
apiClient,
|
|
16756
|
+
model: config.defaultModel
|
|
16757
|
+
});
|
|
17223
16758
|
const models = await llm.getModelInfo();
|
|
17224
16759
|
if (models.length === 0) {
|
|
17225
16760
|
throw new Error("No models available from server.");
|
|
@@ -17232,7 +16767,7 @@ function CliApp() {
|
|
|
17232
16767
|
}
|
|
17233
16768
|
llm.currentModel = modelInfo.id;
|
|
17234
16769
|
const newSession = {
|
|
17235
|
-
id:
|
|
16770
|
+
id: uuidv411(),
|
|
17236
16771
|
name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
|
|
17237
16772
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17238
16773
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17446,10 +16981,8 @@ function CliApp() {
|
|
|
17446
16981
|
// Store agent store for agent management commands
|
|
17447
16982
|
contextContent: contextResult.mergedContent,
|
|
17448
16983
|
// Store raw context for compact instructions
|
|
17449
|
-
backgroundManager
|
|
16984
|
+
backgroundManager
|
|
17450
16985
|
// Store for grouped notification turn tracking
|
|
17451
|
-
wsManager
|
|
17452
|
-
// WebSocket connection manager (null if using SSE fallback)
|
|
17453
16986
|
}));
|
|
17454
16987
|
setStoreSession(newSession);
|
|
17455
16988
|
const bannerLines = [
|
|
@@ -17544,13 +17077,13 @@ function CliApp() {
|
|
|
17544
17077
|
messageContent = multimodalMessage.content;
|
|
17545
17078
|
}
|
|
17546
17079
|
const userMessage = {
|
|
17547
|
-
id:
|
|
17080
|
+
id: uuidv411(),
|
|
17548
17081
|
role: "user",
|
|
17549
17082
|
content: userMessageContent,
|
|
17550
17083
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
17551
17084
|
};
|
|
17552
17085
|
const pendingAssistantMessage = {
|
|
17553
|
-
id:
|
|
17086
|
+
id: uuidv411(),
|
|
17554
17087
|
role: "assistant",
|
|
17555
17088
|
content: "...",
|
|
17556
17089
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17763,13 +17296,13 @@ function CliApp() {
|
|
|
17763
17296
|
userMessageContent = message;
|
|
17764
17297
|
}
|
|
17765
17298
|
const userMessage = {
|
|
17766
|
-
id:
|
|
17299
|
+
id: uuidv411(),
|
|
17767
17300
|
role: "user",
|
|
17768
17301
|
content: userMessageContent,
|
|
17769
17302
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
17770
17303
|
};
|
|
17771
17304
|
const pendingAssistantMessage = {
|
|
17772
|
-
id:
|
|
17305
|
+
id: uuidv411(),
|
|
17773
17306
|
role: "assistant",
|
|
17774
17307
|
content: "...",
|
|
17775
17308
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17849,7 +17382,7 @@ function CliApp() {
|
|
|
17849
17382
|
const currentSession = useCliStore.getState().session;
|
|
17850
17383
|
if (currentSession) {
|
|
17851
17384
|
const cancelMessage = {
|
|
17852
|
-
id:
|
|
17385
|
+
id: uuidv411(),
|
|
17853
17386
|
role: "assistant",
|
|
17854
17387
|
content: "\u26A0\uFE0F Operation cancelled by user",
|
|
17855
17388
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17894,7 +17427,7 @@ function CliApp() {
|
|
|
17894
17427
|
setState((prev) => ({ ...prev, abortController }));
|
|
17895
17428
|
try {
|
|
17896
17429
|
const pendingAssistantMessage = {
|
|
17897
|
-
id:
|
|
17430
|
+
id: uuidv411(),
|
|
17898
17431
|
role: "assistant",
|
|
17899
17432
|
content: "...",
|
|
17900
17433
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17922,7 +17455,7 @@ function CliApp() {
|
|
|
17922
17455
|
const currentSession = useCliStore.getState().session;
|
|
17923
17456
|
if (!currentSession) return;
|
|
17924
17457
|
const continuationMessage = {
|
|
17925
|
-
id:
|
|
17458
|
+
id: uuidv411(),
|
|
17926
17459
|
role: "assistant",
|
|
17927
17460
|
content: "---\n\n**Background Agent Results:**\n\n" + result.finalAnswer,
|
|
17928
17461
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17983,13 +17516,13 @@ function CliApp() {
|
|
|
17983
17516
|
isError = true;
|
|
17984
17517
|
}
|
|
17985
17518
|
const userMessage = {
|
|
17986
|
-
id:
|
|
17519
|
+
id: uuidv411(),
|
|
17987
17520
|
role: "user",
|
|
17988
17521
|
content: `$ ${command}`,
|
|
17989
17522
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
17990
17523
|
};
|
|
17991
17524
|
const assistantMessage = {
|
|
17992
|
-
id:
|
|
17525
|
+
id: uuidv411(),
|
|
17993
17526
|
role: "assistant",
|
|
17994
17527
|
content: isError ? `\u274C Error:
|
|
17995
17528
|
${output}` : output.trim() || "(no output)",
|
|
@@ -18458,7 +17991,7 @@ Keyboard Shortcuts:
|
|
|
18458
17991
|
console.clear();
|
|
18459
17992
|
const model = state.session?.model || state.config?.defaultModel || "claude-sonnet";
|
|
18460
17993
|
const newSession = {
|
|
18461
|
-
id:
|
|
17994
|
+
id: uuidv411(),
|
|
18462
17995
|
name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
|
|
18463
17996
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18464
17997
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -18963,9 +18496,9 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
18963
18496
|
return { ...prev, config: updatedConfig };
|
|
18964
18497
|
});
|
|
18965
18498
|
if (modelChanged && state.agent) {
|
|
18966
|
-
const
|
|
18967
|
-
if (
|
|
18968
|
-
|
|
18499
|
+
const llm = state.agent.context.llm;
|
|
18500
|
+
if (llm) {
|
|
18501
|
+
llm.currentModel = updatedConfig.defaultModel;
|
|
18969
18502
|
}
|
|
18970
18503
|
}
|
|
18971
18504
|
};
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
findMostSimilarMemento,
|
|
4
4
|
getRelevantMementos
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-H6H5JFXR.js";
|
|
6
|
+
import "./chunk-WP3WMRSG.js";
|
|
7
|
+
import "./chunk-LNNVZDLN.js";
|
|
8
8
|
import "./chunk-OCYRD7D6.js";
|
|
9
9
|
export {
|
|
10
10
|
findMostSimilarMemento,
|
|
@@ -134,12 +134,12 @@ import {
|
|
|
134
134
|
validateMermaidSyntax,
|
|
135
135
|
warmUpSettingsCache,
|
|
136
136
|
withRetry
|
|
137
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-WP3WMRSG.js";
|
|
138
138
|
import {
|
|
139
139
|
buildRateLimitLogEntry,
|
|
140
140
|
isNearLimit,
|
|
141
141
|
parseRateLimitHeaders
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-LNNVZDLN.js";
|
|
143
143
|
import {
|
|
144
144
|
Logger,
|
|
145
145
|
NotificationDeduplicator,
|
|
@@ -41,12 +41,6 @@ import {
|
|
|
41
41
|
ChatModels,
|
|
42
42
|
CitableSourceSchema,
|
|
43
43
|
ClaudeArtifactMimeTypes,
|
|
44
|
-
CliCompletionChunkAction,
|
|
45
|
-
CliCompletionDoneAction,
|
|
46
|
-
CliCompletionErrorAction,
|
|
47
|
-
CliCompletionRequestAction,
|
|
48
|
-
CliToolRequestAction,
|
|
49
|
-
CliToolResponseAction,
|
|
50
44
|
CollectionType,
|
|
51
45
|
CompletionApiUsageTransaction,
|
|
52
46
|
CompletionRequestSchema,
|
|
@@ -425,7 +419,7 @@ import {
|
|
|
425
419
|
validateReactArtifactV2,
|
|
426
420
|
validateSvgArtifactV2,
|
|
427
421
|
wikiMarkupToAdf
|
|
428
|
-
} from "./chunk-
|
|
422
|
+
} from "./chunk-LNNVZDLN.js";
|
|
429
423
|
export {
|
|
430
424
|
ALL_IMAGE_MODELS,
|
|
431
425
|
ALL_IMAGE_SIZES,
|
|
@@ -469,12 +463,6 @@ export {
|
|
|
469
463
|
ChatModels,
|
|
470
464
|
CitableSourceSchema,
|
|
471
465
|
ClaudeArtifactMimeTypes,
|
|
472
|
-
CliCompletionChunkAction,
|
|
473
|
-
CliCompletionDoneAction,
|
|
474
|
-
CliCompletionErrorAction,
|
|
475
|
-
CliCompletionRequestAction,
|
|
476
|
-
CliToolRequestAction,
|
|
477
|
-
CliToolResponseAction,
|
|
478
466
|
CollectionType,
|
|
479
467
|
CompletionApiUsageTransaction,
|
|
480
468
|
CompletionRequestSchema,
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
SubtractCreditsSchema,
|
|
4
4
|
subtractCredits
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-6HFPBXKR.js";
|
|
6
|
+
import "./chunk-WP3WMRSG.js";
|
|
7
|
+
import "./chunk-LNNVZDLN.js";
|
|
8
8
|
import "./chunk-OCYRD7D6.js";
|
|
9
9
|
export {
|
|
10
10
|
SubtractCreditsSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bike4mind/cli",
|
|
3
|
-
"version": "0.2.30-feat-
|
|
3
|
+
"version": "0.2.30-feat-new-architecture.19278+592a62bc7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -111,10 +111,10 @@
|
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
113
|
"@bike4mind/agents": "0.1.0",
|
|
114
|
-
"@bike4mind/common": "2.51.1-feat-
|
|
115
|
-
"@bike4mind/mcp": "1.30.1-feat-
|
|
116
|
-
"@bike4mind/services": "2.49.1-feat-
|
|
117
|
-
"@bike4mind/utils": "2.6.1-feat-
|
|
114
|
+
"@bike4mind/common": "2.51.1-feat-new-architecture.19278+592a62bc7",
|
|
115
|
+
"@bike4mind/mcp": "1.30.1-feat-new-architecture.19278+592a62bc7",
|
|
116
|
+
"@bike4mind/services": "2.49.1-feat-new-architecture.19278+592a62bc7",
|
|
117
|
+
"@bike4mind/utils": "2.6.1-feat-new-architecture.19278+592a62bc7",
|
|
118
118
|
"@types/better-sqlite3": "^7.6.13",
|
|
119
119
|
"@types/diff": "^5.0.9",
|
|
120
120
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -135,5 +135,5 @@
|
|
|
135
135
|
"optionalDependencies": {
|
|
136
136
|
"@vscode/ripgrep": "^1.17.0"
|
|
137
137
|
},
|
|
138
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "592a62bc71d62dd7598efffcf6c15eedb1087cc7"
|
|
139
139
|
}
|