@bike4mind/cli 0.2.30-feat-cli-websocket-streaming.19243 → 0.2.30-feat-webhook-audit-logs.19256
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-VCJRMWC5.js} +1 -1
- package/dist/{chunk-55ZDRTGQ.js → chunk-45Q7FLIF.js} +12 -67
- package/dist/{chunk-KBRR7H2K.js → chunk-LFB6SJ7Y.js} +2 -2
- package/dist/{chunk-7EEPLDUG.js → chunk-P52TOUHT.js} +1 -1
- package/dist/{chunk-K5IURWQT.js → chunk-QXUVNDDS.js} +2 -2
- package/dist/{chunk-XXYKIX5X.js → chunk-VCXLXFTQ.js} +2 -2
- package/dist/{create-IUID2337.js → create-2FTWOMAQ.js} +3 -3
- package/dist/index.js +35 -503
- package/dist/{llmMarkdownGenerator-Q3PRX6UR.js → llmMarkdownGenerator-FFGKSM6F.js} +1 -1
- package/dist/{markdownGenerator-TFFIS7MF.js → markdownGenerator-7VHAZMM3.js} +1 -1
- package/dist/{mementoService-5ZUSQ4B4.js → mementoService-Q24DG2GC.js} +3 -3
- package/dist/{src-QWRGDJYC.js → src-DV4DJWDS.js} +3 -13
- package/dist/{src-LLWYZKB2.js → src-PULJETCV.js} +2 -2
- package/dist/{subtractCredits-LXVQL26O.js → subtractCredits-S3YYDR66.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-45Q7FLIF.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;
|
|
@@ -1075,6 +1075,15 @@ var WebhookDeliveryStatus;
|
|
|
1075
1075
|
WebhookDeliveryStatus2["Pending"] = "pending";
|
|
1076
1076
|
})(WebhookDeliveryStatus || (WebhookDeliveryStatus = {}));
|
|
1077
1077
|
|
|
1078
|
+
// ../../b4m-core/packages/common/dist/src/types/entities/WebhookAuditLogTypes.js
|
|
1079
|
+
var WebhookAuditStatus;
|
|
1080
|
+
(function(WebhookAuditStatus2) {
|
|
1081
|
+
WebhookAuditStatus2["Received"] = "received";
|
|
1082
|
+
WebhookAuditStatus2["Processing"] = "processing";
|
|
1083
|
+
WebhookAuditStatus2["Completed"] = "completed";
|
|
1084
|
+
WebhookAuditStatus2["Failed"] = "failed";
|
|
1085
|
+
})(WebhookAuditStatus || (WebhookAuditStatus = {}));
|
|
1086
|
+
|
|
1078
1087
|
// ../../b4m-core/packages/common/dist/src/types/common.js
|
|
1079
1088
|
var SupportedFabFileMimeTypes;
|
|
1080
1089
|
(function(SupportedFabFileMimeTypes2) {
|
|
@@ -1181,29 +1190,6 @@ var VoiceSessionSendTranscriptAction = z10.object({
|
|
|
1181
1190
|
conversationItemId: z10.string(),
|
|
1182
1191
|
timestamp: z10.coerce.date().optional()
|
|
1183
1192
|
});
|
|
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
1193
|
var VoiceSessionEndedAction = z10.object({
|
|
1208
1194
|
action: z10.literal("voice_session_ended"),
|
|
1209
1195
|
userId: z10.string(),
|
|
@@ -1492,36 +1478,6 @@ var VoiceCreditsExhaustedAction = z10.object({
|
|
|
1492
1478
|
creditsUsed: z10.number(),
|
|
1493
1479
|
clientId: z10.string().optional()
|
|
1494
1480
|
});
|
|
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
1481
|
var SessionCreatedAction = shareableDocumentSchema.extend({
|
|
1526
1482
|
action: z10.literal("session.created"),
|
|
1527
1483
|
id: z10.string(),
|
|
@@ -1556,9 +1512,7 @@ var MessageDataToServer = z10.discriminatedUnion("action", [
|
|
|
1556
1512
|
DataUnsubscribeRequestAction,
|
|
1557
1513
|
HeartbeatAction,
|
|
1558
1514
|
VoiceSessionSendTranscriptAction,
|
|
1559
|
-
VoiceSessionEndedAction
|
|
1560
|
-
CliCompletionRequestAction,
|
|
1561
|
-
CliToolRequestAction
|
|
1515
|
+
VoiceSessionEndedAction
|
|
1562
1516
|
]);
|
|
1563
1517
|
var MessageDataToClient = z10.discriminatedUnion("action", [
|
|
1564
1518
|
DataSubscriptionUpdateAction,
|
|
@@ -1584,11 +1538,7 @@ var MessageDataToClient = z10.discriminatedUnion("action", [
|
|
|
1584
1538
|
PiHistoryCompleteAction,
|
|
1585
1539
|
PiHistoryErrorAction,
|
|
1586
1540
|
SessionCreatedAction,
|
|
1587
|
-
VoiceCreditsExhaustedAction
|
|
1588
|
-
CliCompletionChunkAction,
|
|
1589
|
-
CliCompletionDoneAction,
|
|
1590
|
-
CliCompletionErrorAction,
|
|
1591
|
-
CliToolResponseAction
|
|
1541
|
+
VoiceCreditsExhaustedAction
|
|
1592
1542
|
]);
|
|
1593
1543
|
|
|
1594
1544
|
// ../../b4m-core/packages/common/dist/src/schemas/cliCompletions.js
|
|
@@ -8775,6 +8725,7 @@ export {
|
|
|
8775
8725
|
isPlaceholderValue,
|
|
8776
8726
|
SecretAuditEvents,
|
|
8777
8727
|
WebhookDeliveryStatus,
|
|
8728
|
+
WebhookAuditStatus,
|
|
8778
8729
|
SupportedFabFileMimeTypes,
|
|
8779
8730
|
REASONING_EFFORT_LABELS,
|
|
8780
8731
|
REASONING_EFFORT_DESCRIPTIONS,
|
|
@@ -8783,8 +8734,6 @@ export {
|
|
|
8783
8734
|
DataUnsubscribeRequestAction,
|
|
8784
8735
|
HeartbeatAction,
|
|
8785
8736
|
VoiceSessionSendTranscriptAction,
|
|
8786
|
-
CliCompletionRequestAction,
|
|
8787
|
-
CliToolRequestAction,
|
|
8788
8737
|
VoiceSessionEndedAction,
|
|
8789
8738
|
DataSubscriptionUpdateAction,
|
|
8790
8739
|
LLMStatusUpdateAction,
|
|
@@ -8809,10 +8758,6 @@ export {
|
|
|
8809
8758
|
ImportHistoryJobProgressUpdateAction,
|
|
8810
8759
|
ResearchModeStreamAction,
|
|
8811
8760
|
VoiceCreditsExhaustedAction,
|
|
8812
|
-
CliCompletionChunkAction,
|
|
8813
|
-
CliCompletionDoneAction,
|
|
8814
|
-
CliCompletionErrorAction,
|
|
8815
|
-
CliToolResponseAction,
|
|
8816
8761
|
SessionCreatedAction,
|
|
8817
8762
|
MessageDataToServer,
|
|
8818
8763
|
MessageDataToClient,
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
getSettingsByNames,
|
|
7
7
|
obfuscateApiKey,
|
|
8
8
|
secureParameters
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-P52TOUHT.js";
|
|
10
10
|
import {
|
|
11
11
|
ApiKeyType,
|
|
12
12
|
MementoTier,
|
|
13
13
|
isSupportedEmbeddingModel
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-45Q7FLIF.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
getSettingsMap,
|
|
8
8
|
getSettingsValue,
|
|
9
9
|
secureParameters
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-P52TOUHT.js";
|
|
11
11
|
import {
|
|
12
12
|
KnowledgeType,
|
|
13
13
|
SupportedFabFileMimeTypes
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-45Q7FLIF.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/fabFileService/create.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BadRequestError,
|
|
4
4
|
secureParameters
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-P52TOUHT.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-45Q7FLIF.js";
|
|
16
16
|
|
|
17
17
|
// ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
|
|
18
18
|
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-QXUVNDDS.js";
|
|
6
|
+
import "./chunk-P52TOUHT.js";
|
|
7
|
+
import "./chunk-45Q7FLIF.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-LFB6SJ7Y.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-VCXLXFTQ.js";
|
|
19
|
+
import "./chunk-QXUVNDDS.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-P52TOUHT.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-45Q7FLIF.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";
|
|
@@ -12537,10 +12537,6 @@ var ServerToolExecutor = class {
|
|
|
12537
12537
|
};
|
|
12538
12538
|
|
|
12539
12539
|
// src/llm/ToolRouter.ts
|
|
12540
|
-
var wsToolExecutor = null;
|
|
12541
|
-
function setWebSocketToolExecutor(executor) {
|
|
12542
|
-
wsToolExecutor = executor;
|
|
12543
|
-
}
|
|
12544
12540
|
var SERVER_TOOLS = ["weather_info", "web_search", "web_fetch"];
|
|
12545
12541
|
var LOCAL_TOOLS = [
|
|
12546
12542
|
"file_read",
|
|
@@ -12563,15 +12559,7 @@ function isLocalTool(toolName) {
|
|
|
12563
12559
|
}
|
|
12564
12560
|
async function executeTool(toolName, input, apiClient, localToolFn) {
|
|
12565
12561
|
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`);
|
|
12562
|
+
logger.debug(`[ToolRouter] Routing ${toolName} to server`);
|
|
12575
12563
|
const executor = new ServerToolExecutor(apiClient);
|
|
12576
12564
|
return await executor.executeTool(toolName, input);
|
|
12577
12565
|
} else if (isLocalTool(toolName)) {
|
|
@@ -14533,173 +14521,6 @@ var ServerLlmBackend = class {
|
|
|
14533
14521
|
}
|
|
14534
14522
|
};
|
|
14535
14523
|
|
|
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
14524
|
// src/llm/NotifyingLlmBackend.ts
|
|
14704
14525
|
var NotifyingLlmBackend = class {
|
|
14705
14526
|
constructor(inner, backgroundManager) {
|
|
@@ -14734,253 +14555,6 @@ Please acknowledge these background agent results and incorporate them into your
|
|
|
14734
14555
|
}
|
|
14735
14556
|
};
|
|
14736
14557
|
|
|
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
14558
|
// src/auth/ApiClient.ts
|
|
14985
14559
|
import axios11 from "axios";
|
|
14986
14560
|
var ApiClient = class {
|
|
@@ -15118,7 +14692,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
|
|
|
15118
14692
|
// package.json
|
|
15119
14693
|
var package_default = {
|
|
15120
14694
|
name: "@bike4mind/cli",
|
|
15121
|
-
version: "0.2.30-feat-
|
|
14695
|
+
version: "0.2.30-feat-webhook-audit-logs.19256+29ac365f7",
|
|
15122
14696
|
type: "module",
|
|
15123
14697
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
15124
14698
|
license: "UNLICENSED",
|
|
@@ -15229,10 +14803,10 @@ var package_default = {
|
|
|
15229
14803
|
},
|
|
15230
14804
|
devDependencies: {
|
|
15231
14805
|
"@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-
|
|
14806
|
+
"@bike4mind/common": "2.51.1-feat-webhook-audit-logs.19256+29ac365f7",
|
|
14807
|
+
"@bike4mind/mcp": "1.30.1-feat-webhook-audit-logs.19256+29ac365f7",
|
|
14808
|
+
"@bike4mind/services": "2.49.1-feat-webhook-audit-logs.19256+29ac365f7",
|
|
14809
|
+
"@bike4mind/utils": "2.6.1-feat-webhook-audit-logs.19256+29ac365f7",
|
|
15236
14810
|
"@types/better-sqlite3": "^7.6.13",
|
|
15237
14811
|
"@types/diff": "^5.0.9",
|
|
15238
14812
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -15253,7 +14827,7 @@ var package_default = {
|
|
|
15253
14827
|
optionalDependencies: {
|
|
15254
14828
|
"@vscode/ripgrep": "^1.17.0"
|
|
15255
14829
|
},
|
|
15256
|
-
gitHead: "
|
|
14830
|
+
gitHead: "29ac365f7b571e6ba8d509032ad00fb8a39a8bca"
|
|
15257
14831
|
};
|
|
15258
14832
|
|
|
15259
14833
|
// src/agents/toolFilter.ts
|
|
@@ -17027,8 +16601,7 @@ function CliApp() {
|
|
|
17027
16601
|
agentStore: null,
|
|
17028
16602
|
abortController: null,
|
|
17029
16603
|
contextContent: "",
|
|
17030
|
-
backgroundManager: null
|
|
17031
|
-
wsManager: null
|
|
16604
|
+
backgroundManager: null
|
|
17032
16605
|
});
|
|
17033
16606
|
const [isInitialized, setIsInitialized] = useState10(false);
|
|
17034
16607
|
const [initError, setInitError] = useState10(null);
|
|
@@ -17056,10 +16629,6 @@ function CliApp() {
|
|
|
17056
16629
|
})
|
|
17057
16630
|
);
|
|
17058
16631
|
}
|
|
17059
|
-
if (state.wsManager) {
|
|
17060
|
-
state.wsManager.disconnect();
|
|
17061
|
-
setWebSocketToolExecutor(null);
|
|
17062
|
-
}
|
|
17063
16632
|
if (state.agent) {
|
|
17064
16633
|
state.agent.removeAllListeners();
|
|
17065
16634
|
}
|
|
@@ -17078,7 +16647,7 @@ function CliApp() {
|
|
|
17078
16647
|
setTimeout(() => {
|
|
17079
16648
|
process.exit(0);
|
|
17080
16649
|
}, 100);
|
|
17081
|
-
}, [state.session, state.sessionStore, state.mcpManager, state.agent, state.imageStore
|
|
16650
|
+
}, [state.session, state.sessionStore, state.mcpManager, state.agent, state.imageStore]);
|
|
17082
16651
|
useInput9((input, key) => {
|
|
17083
16652
|
if (key.escape) {
|
|
17084
16653
|
const store = useCliStore.getState();
|
|
@@ -17153,7 +16722,7 @@ function CliApp() {
|
|
|
17153
16722
|
if (!isAuthenticated) {
|
|
17154
16723
|
console.log("\u2139\uFE0F AI features disabled. Available commands: /login, /help, /config\n");
|
|
17155
16724
|
const minimalSession = {
|
|
17156
|
-
id:
|
|
16725
|
+
id: uuidv411(),
|
|
17157
16726
|
name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
|
|
17158
16727
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17159
16728
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17181,45 +16750,10 @@ function CliApp() {
|
|
|
17181
16750
|
console.log(`\u{1F30D} API Environment: ${envName} (${apiBaseURL})`);
|
|
17182
16751
|
}
|
|
17183
16752
|
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
|
-
}
|
|
16753
|
+
const llm = new ServerLlmBackend({
|
|
16754
|
+
apiClient,
|
|
16755
|
+
model: config.defaultModel
|
|
16756
|
+
});
|
|
17223
16757
|
const models = await llm.getModelInfo();
|
|
17224
16758
|
if (models.length === 0) {
|
|
17225
16759
|
throw new Error("No models available from server.");
|
|
@@ -17232,7 +16766,7 @@ function CliApp() {
|
|
|
17232
16766
|
}
|
|
17233
16767
|
llm.currentModel = modelInfo.id;
|
|
17234
16768
|
const newSession = {
|
|
17235
|
-
id:
|
|
16769
|
+
id: uuidv411(),
|
|
17236
16770
|
name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
|
|
17237
16771
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17238
16772
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17446,10 +16980,8 @@ function CliApp() {
|
|
|
17446
16980
|
// Store agent store for agent management commands
|
|
17447
16981
|
contextContent: contextResult.mergedContent,
|
|
17448
16982
|
// Store raw context for compact instructions
|
|
17449
|
-
backgroundManager
|
|
16983
|
+
backgroundManager
|
|
17450
16984
|
// Store for grouped notification turn tracking
|
|
17451
|
-
wsManager
|
|
17452
|
-
// WebSocket connection manager (null if using SSE fallback)
|
|
17453
16985
|
}));
|
|
17454
16986
|
setStoreSession(newSession);
|
|
17455
16987
|
const bannerLines = [
|
|
@@ -17544,13 +17076,13 @@ function CliApp() {
|
|
|
17544
17076
|
messageContent = multimodalMessage.content;
|
|
17545
17077
|
}
|
|
17546
17078
|
const userMessage = {
|
|
17547
|
-
id:
|
|
17079
|
+
id: uuidv411(),
|
|
17548
17080
|
role: "user",
|
|
17549
17081
|
content: userMessageContent,
|
|
17550
17082
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
17551
17083
|
};
|
|
17552
17084
|
const pendingAssistantMessage = {
|
|
17553
|
-
id:
|
|
17085
|
+
id: uuidv411(),
|
|
17554
17086
|
role: "assistant",
|
|
17555
17087
|
content: "...",
|
|
17556
17088
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17763,13 +17295,13 @@ function CliApp() {
|
|
|
17763
17295
|
userMessageContent = message;
|
|
17764
17296
|
}
|
|
17765
17297
|
const userMessage = {
|
|
17766
|
-
id:
|
|
17298
|
+
id: uuidv411(),
|
|
17767
17299
|
role: "user",
|
|
17768
17300
|
content: userMessageContent,
|
|
17769
17301
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
17770
17302
|
};
|
|
17771
17303
|
const pendingAssistantMessage = {
|
|
17772
|
-
id:
|
|
17304
|
+
id: uuidv411(),
|
|
17773
17305
|
role: "assistant",
|
|
17774
17306
|
content: "...",
|
|
17775
17307
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17849,7 +17381,7 @@ function CliApp() {
|
|
|
17849
17381
|
const currentSession = useCliStore.getState().session;
|
|
17850
17382
|
if (currentSession) {
|
|
17851
17383
|
const cancelMessage = {
|
|
17852
|
-
id:
|
|
17384
|
+
id: uuidv411(),
|
|
17853
17385
|
role: "assistant",
|
|
17854
17386
|
content: "\u26A0\uFE0F Operation cancelled by user",
|
|
17855
17387
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17894,7 +17426,7 @@ function CliApp() {
|
|
|
17894
17426
|
setState((prev) => ({ ...prev, abortController }));
|
|
17895
17427
|
try {
|
|
17896
17428
|
const pendingAssistantMessage = {
|
|
17897
|
-
id:
|
|
17429
|
+
id: uuidv411(),
|
|
17898
17430
|
role: "assistant",
|
|
17899
17431
|
content: "...",
|
|
17900
17432
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17922,7 +17454,7 @@ function CliApp() {
|
|
|
17922
17454
|
const currentSession = useCliStore.getState().session;
|
|
17923
17455
|
if (!currentSession) return;
|
|
17924
17456
|
const continuationMessage = {
|
|
17925
|
-
id:
|
|
17457
|
+
id: uuidv411(),
|
|
17926
17458
|
role: "assistant",
|
|
17927
17459
|
content: "---\n\n**Background Agent Results:**\n\n" + result.finalAnswer,
|
|
17928
17460
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17983,13 +17515,13 @@ function CliApp() {
|
|
|
17983
17515
|
isError = true;
|
|
17984
17516
|
}
|
|
17985
17517
|
const userMessage = {
|
|
17986
|
-
id:
|
|
17518
|
+
id: uuidv411(),
|
|
17987
17519
|
role: "user",
|
|
17988
17520
|
content: `$ ${command}`,
|
|
17989
17521
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
17990
17522
|
};
|
|
17991
17523
|
const assistantMessage = {
|
|
17992
|
-
id:
|
|
17524
|
+
id: uuidv411(),
|
|
17993
17525
|
role: "assistant",
|
|
17994
17526
|
content: isError ? `\u274C Error:
|
|
17995
17527
|
${output}` : output.trim() || "(no output)",
|
|
@@ -18458,7 +17990,7 @@ Keyboard Shortcuts:
|
|
|
18458
17990
|
console.clear();
|
|
18459
17991
|
const model = state.session?.model || state.config?.defaultModel || "claude-sonnet";
|
|
18460
17992
|
const newSession = {
|
|
18461
|
-
id:
|
|
17993
|
+
id: uuidv411(),
|
|
18462
17994
|
name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
|
|
18463
17995
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18464
17996
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -18963,9 +18495,9 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
18963
18495
|
return { ...prev, config: updatedConfig };
|
|
18964
18496
|
});
|
|
18965
18497
|
if (modelChanged && state.agent) {
|
|
18966
|
-
const
|
|
18967
|
-
if (
|
|
18968
|
-
|
|
18498
|
+
const llm = state.agent.context.llm;
|
|
18499
|
+
if (llm) {
|
|
18500
|
+
llm.currentModel = updatedConfig.defaultModel;
|
|
18969
18501
|
}
|
|
18970
18502
|
}
|
|
18971
18503
|
};
|
|
@@ -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-LFB6SJ7Y.js";
|
|
6
|
+
import "./chunk-P52TOUHT.js";
|
|
7
|
+
import "./chunk-45Q7FLIF.js";
|
|
8
8
|
import "./chunk-OCYRD7D6.js";
|
|
9
9
|
export {
|
|
10
10
|
findMostSimilarMemento,
|
|
@@ -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,
|
|
@@ -316,6 +310,7 @@ import {
|
|
|
316
310
|
VoyageAIEmbeddingModel,
|
|
317
311
|
WEBSITE_URL,
|
|
318
312
|
WHATS_NEW_VALIDATION_LIMITS,
|
|
313
|
+
WebhookAuditStatus,
|
|
319
314
|
WebhookDeliveryStatus,
|
|
320
315
|
WhatsNewConfigSchema,
|
|
321
316
|
WhatsNewSyncConfigSchema,
|
|
@@ -425,7 +420,7 @@ import {
|
|
|
425
420
|
validateReactArtifactV2,
|
|
426
421
|
validateSvgArtifactV2,
|
|
427
422
|
wikiMarkupToAdf
|
|
428
|
-
} from "./chunk-
|
|
423
|
+
} from "./chunk-45Q7FLIF.js";
|
|
429
424
|
export {
|
|
430
425
|
ALL_IMAGE_MODELS,
|
|
431
426
|
ALL_IMAGE_SIZES,
|
|
@@ -469,12 +464,6 @@ export {
|
|
|
469
464
|
ChatModels,
|
|
470
465
|
CitableSourceSchema,
|
|
471
466
|
ClaudeArtifactMimeTypes,
|
|
472
|
-
CliCompletionChunkAction,
|
|
473
|
-
CliCompletionDoneAction,
|
|
474
|
-
CliCompletionErrorAction,
|
|
475
|
-
CliCompletionRequestAction,
|
|
476
|
-
CliToolRequestAction,
|
|
477
|
-
CliToolResponseAction,
|
|
478
467
|
CollectionType,
|
|
479
468
|
CompletionApiUsageTransaction,
|
|
480
469
|
CompletionRequestSchema,
|
|
@@ -744,6 +733,7 @@ export {
|
|
|
744
733
|
VoyageAIEmbeddingModel,
|
|
745
734
|
WEBSITE_URL,
|
|
746
735
|
WHATS_NEW_VALIDATION_LIMITS,
|
|
736
|
+
WebhookAuditStatus,
|
|
747
737
|
WebhookDeliveryStatus,
|
|
748
738
|
WhatsNewConfigSchema,
|
|
749
739
|
WhatsNewSyncConfigSchema,
|
|
@@ -134,12 +134,12 @@ import {
|
|
|
134
134
|
validateMermaidSyntax,
|
|
135
135
|
warmUpSettingsCache,
|
|
136
136
|
withRetry
|
|
137
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-P52TOUHT.js";
|
|
138
138
|
import {
|
|
139
139
|
buildRateLimitLogEntry,
|
|
140
140
|
isNearLimit,
|
|
141
141
|
parseRateLimitHeaders
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-45Q7FLIF.js";
|
|
143
143
|
import {
|
|
144
144
|
Logger,
|
|
145
145
|
NotificationDeduplicator,
|
|
@@ -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-VCXLXFTQ.js";
|
|
6
|
+
import "./chunk-P52TOUHT.js";
|
|
7
|
+
import "./chunk-45Q7FLIF.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-webhook-audit-logs.19256+29ac365f7",
|
|
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-webhook-audit-logs.19256+29ac365f7",
|
|
115
|
+
"@bike4mind/mcp": "1.30.1-feat-webhook-audit-logs.19256+29ac365f7",
|
|
116
|
+
"@bike4mind/services": "2.49.1-feat-webhook-audit-logs.19256+29ac365f7",
|
|
117
|
+
"@bike4mind/utils": "2.6.1-feat-webhook-audit-logs.19256+29ac365f7",
|
|
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": "29ac365f7b571e6ba8d509032ad00fb8a39a8bca"
|
|
139
139
|
}
|