@bike4mind/cli 0.2.13 → 0.2.14-feat-cli-mcp-management.17477

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,22 +4,24 @@ import {
4
4
  getEffectiveApiKey,
5
5
  getOpenWeatherKey,
6
6
  getSerperKey
7
- } from "./chunk-3MT5HI3G.js";
8
- import "./chunk-PMY7IPOC.js";
9
- import "./chunk-K44CDTQN.js";
7
+ } from "./chunk-SKGB6N3S.js";
8
+ import {
9
+ ConfigStore
10
+ } from "./chunk-FFJX3FF3.js";
11
+ import "./chunk-TOMWAKIL.js";
12
+ import "./chunk-B6HTF2IE.js";
10
13
  import {
11
14
  BFLImageService,
12
15
  BaseStorage,
13
16
  GeminiImageService,
17
+ MAX_DESCRIPTION_LENGTH,
18
+ MAX_GOAL_LENGTH,
19
+ MAX_TAG_LENGTH,
14
20
  NotFoundError,
15
21
  OpenAIBackend,
16
22
  OpenAIImageService,
17
23
  XAIImageService
18
- } from "./chunk-SZXO7HOF.js";
19
- import {
20
- Logger
21
- } from "./chunk-OCYRD7D6.js";
22
- import "./chunk-BPFEGDC7.js";
24
+ } from "./chunk-GFL7CMSL.js";
23
25
  import {
24
26
  AiEvents,
25
27
  ApiKeyEvents,
@@ -74,16 +76,20 @@ import {
74
76
  b4mLLMTools,
75
77
  getMcpProviderMetadata
76
78
  } from "./chunk-A7POWM75.js";
79
+ import {
80
+ Logger
81
+ } from "./chunk-OCYRD7D6.js";
82
+ import "./chunk-BPFEGDC7.js";
77
83
 
78
84
  // src/index.tsx
79
- import React17, { useState as useState8, useEffect as useEffect3, useCallback, useRef as useRef2 } from "react";
80
- import { render, Box as Box16, Text as Text16, useApp, useInput as useInput6 } from "ink";
85
+ import React18, { useState as useState8, useEffect as useEffect3, useCallback, useRef as useRef2 } from "react";
86
+ import { render, Box as Box17, Text as Text17, useApp, useInput as useInput8 } from "ink";
81
87
  import { execSync } from "child_process";
82
- import { v4 as uuidv410 } from "uuid";
88
+ import { v4 as uuidv49 } from "uuid";
83
89
 
84
90
  // src/components/App.tsx
85
- import React11, { useState as useState4 } from "react";
86
- import { Box as Box10, Text as Text10, Static } from "ink";
91
+ import React12, { useState as useState4 } from "react";
92
+ import { Box as Box11, Text as Text11, Static, useInput as useInput5 } from "ink";
87
93
 
88
94
  // src/components/StatusBar.tsx
89
95
  import React from "react";
@@ -511,6 +517,11 @@ var COMMANDS = [
511
517
  {
512
518
  name: "commands:reload",
513
519
  description: "Reload custom commands from disk"
520
+ },
521
+ {
522
+ name: "mcp",
523
+ description: "Show MCP server status and connected tools",
524
+ aliases: ["mcp:list"]
514
525
  }
515
526
  ];
516
527
  function getAllCommandNames() {
@@ -1056,6 +1067,9 @@ var useCliStore = create((set) => ({
1056
1067
  // Config editor
1057
1068
  showConfigEditor: false,
1058
1069
  setShowConfigEditor: (show) => set({ showConfigEditor: show }),
1070
+ // MCP viewer
1071
+ showMcpViewer: false,
1072
+ setShowMcpViewer: (show) => set({ showMcpViewer: show }),
1059
1073
  // Exit handling
1060
1074
  exitRequested: false,
1061
1075
  setExitRequested: (requested) => set({ exitRequested: requested })
@@ -1342,24 +1356,84 @@ function ConfigEditor({ config, availableModels, onSave, onClose }) {
1342
1356
  })), /* @__PURE__ */ React9.createElement(Box8, { borderStyle: "single", borderColor: "gray", paddingX: 1 }, /* @__PURE__ */ React9.createElement(Text8, { dimColor: true }, "\u2191/\u2193: Navigate | Space/\u2190/\u2192: Change | q/Esc: Save & Exit")));
1343
1357
  }
1344
1358
 
1345
- // src/components/MessageItem.tsx
1359
+ // src/components/McpViewer.tsx
1346
1360
  import React10 from "react";
1347
- import { Box as Box9, Text as Text9 } from "ink";
1361
+ import { Box as Box9, Text as Text9, useInput as useInput4 } from "ink";
1362
+ function McpViewer({ config, mcpManager, onClose }) {
1363
+ useInput4((input, key) => {
1364
+ if (key.escape || input === "q") {
1365
+ onClose();
1366
+ }
1367
+ });
1368
+ if (config.mcpServers.length === 0) {
1369
+ return /* @__PURE__ */ React10.createElement(Box9, { flexDirection: "column", paddingX: 2, paddingY: 1 }, /* @__PURE__ */ React10.createElement(Box9, { marginBottom: 1 }, /* @__PURE__ */ React10.createElement(Text9, { bold: true, color: "cyan" }, "\u{1F4E1} MCP Server Status")), /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, "No MCP servers configured."), /* @__PURE__ */ React10.createElement(Box9, { marginTop: 1 }, /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, "To add MCP servers, edit your config file:")), /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, " Global: ~/.bike4mind/config.json"), /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, " Project: .bike4mind/config.json"), /* @__PURE__ */ React10.createElement(Box9, { marginTop: 2 }, /* @__PURE__ */ React10.createElement(Text9, { dimColor: true, italic: true }, "Press Esc or q to close")));
1370
+ }
1371
+ const enabledServers = config.mcpServers.filter((s) => s.enabled);
1372
+ return /* @__PURE__ */ React10.createElement(Box9, { flexDirection: "column", paddingX: 2, paddingY: 1 }, /* @__PURE__ */ React10.createElement(Box9, { marginBottom: 1 }, /* @__PURE__ */ React10.createElement(Text9, { bold: true, color: "cyan" }, "\u{1F4E1} MCP Server Status")), /* @__PURE__ */ React10.createElement(Box9, { flexDirection: "column", marginBottom: 2 }, /* @__PURE__ */ React10.createElement(Text9, { bold: true, dimColor: true }, "Configured Servers:"), config.mcpServers.map((server) => {
1373
+ const status = server.enabled ? "\u2705 Enabled" : "\u23F8\uFE0F Disabled";
1374
+ const commandInfo = server.command ? `${server.command} ${(server.args || []).join(" ")}` : "(internal)";
1375
+ return /* @__PURE__ */ React10.createElement(Box9, { key: server.name, flexDirection: "column", marginTop: 1, marginLeft: 2 }, /* @__PURE__ */ React10.createElement(Text9, null, "\u2022 ", /* @__PURE__ */ React10.createElement(Text9, { bold: true }, server.name), " - ", /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, status)), /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, " Command: ", commandInfo), Object.keys(server.env).length > 0 && /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, " Env vars: ", Object.keys(server.env).join(", ")));
1376
+ })), enabledServers.length > 0 && mcpManager && /* @__PURE__ */ React10.createElement(Box9, { flexDirection: "column", marginBottom: 2 }, /* @__PURE__ */ React10.createElement(Text9, { bold: true, dimColor: true }, "Connection Status:"), enabledServers.map((server) => {
1377
+ const state = mcpManager.getConnectionState(server.name);
1378
+ let icon;
1379
+ let statusText;
1380
+ let color;
1381
+ switch (state) {
1382
+ case "connected":
1383
+ icon = "\u2714";
1384
+ statusText = "connected";
1385
+ color = "green";
1386
+ break;
1387
+ case "connecting":
1388
+ icon = "\u25EF";
1389
+ statusText = "connecting\u2026";
1390
+ color = "yellow";
1391
+ break;
1392
+ case "failed":
1393
+ icon = "\u2717";
1394
+ statusText = "failed";
1395
+ color = "red";
1396
+ break;
1397
+ default:
1398
+ icon = "\u25EF";
1399
+ statusText = "connecting\u2026";
1400
+ color = "gray";
1401
+ }
1402
+ const toolCounts = mcpManager.getToolCount();
1403
+ const serverTools = toolCounts.find((t) => t.serverName === server.name);
1404
+ const toolCount = serverTools?.count || 0;
1405
+ const toolInfo = state === "connected" && toolCount > 0 ? ` (${toolCount} tool${toolCount === 1 ? "" : "s"})` : "";
1406
+ return /* @__PURE__ */ React10.createElement(Box9, { key: server.name, marginTop: 1, marginLeft: 2 }, /* @__PURE__ */ React10.createElement(Text9, null, "\u2022 ", /* @__PURE__ */ React10.createElement(Text9, { bold: true }, server.name), " \xB7 ", /* @__PURE__ */ React10.createElement(Text9, { color }, icon), " ", /* @__PURE__ */ React10.createElement(Text9, { color }, statusText), toolInfo && /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, toolInfo)));
1407
+ }), /* @__PURE__ */ React10.createElement(Box9, { marginTop: 1, marginLeft: 2 }, (() => {
1408
+ const toolCounts = mcpManager.getToolCount();
1409
+ const totalTools = toolCounts.reduce((sum2, s) => sum2 + s.count, 0);
1410
+ if (totalTools > 0) {
1411
+ return /* @__PURE__ */ React10.createElement(Text9, { bold: true, color: "green" }, "Total: ", totalTools, " MCP tool", totalTools === 1 ? "" : "s", " available");
1412
+ } else {
1413
+ return /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, "No MCP tools available yet (servers still connecting)");
1414
+ }
1415
+ })())), enabledServers.length === 0 && /* @__PURE__ */ React10.createElement(Box9, { marginBottom: 2 }, /* @__PURE__ */ React10.createElement(Text9, { color: "yellow" }, "\u26A0\uFE0F No MCP servers enabled"), /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, " Use `b4m mcp enable <name>` to enable a server")), /* @__PURE__ */ React10.createElement(Box9, { marginTop: 1 }, /* @__PURE__ */ React10.createElement(Text9, { dimColor: true, italic: true }, "Press Esc or q to close")));
1416
+ }
1417
+
1418
+ // src/components/MessageItem.tsx
1419
+ import React11 from "react";
1420
+ import { Box as Box10, Text as Text10 } from "ink";
1348
1421
  function MessageItem({ message }) {
1349
1422
  const isUser = message.role === "user";
1350
- return /* @__PURE__ */ React10.createElement(Box9, { flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ React10.createElement(Box9, null, /* @__PURE__ */ React10.createElement(Text9, { bold: true, color: isUser ? "cyan" : "green" }, isUser ? "\u{1F464} You" : "\u{1F916} Assistant"), isUser && /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, " \u2022 ", new Date(message.timestamp).toLocaleTimeString())), isUser && message.content && /* @__PURE__ */ React10.createElement(Box9, { paddingLeft: 2 }, /* @__PURE__ */ React10.createElement(Text9, { backgroundColor: "whiteBright", color: "black" }, " ", message.content, " ")), !isUser && message.metadata?.steps && message.metadata.steps.length > 0 && /* @__PURE__ */ React10.createElement(Box9, { paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React10.createElement(Text9, { dimColor: true, bold: true }, "\u{1F527} Agent Reasoning Trace (", message.metadata.steps.filter((s) => s.type === "action").length, " ", "tools used, ", message.metadata.steps.length, " total steps)", message.metadata.tokenUsage && ` \u2022 ${message.metadata.tokenUsage.total} tokens`), /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, "Step types: ", message.metadata.steps.map((s) => s.type).join(", ")), message.metadata.steps.map((step, idx) => {
1423
+ const isSystem = message.role === "system";
1424
+ return /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ React11.createElement(Box10, null, /* @__PURE__ */ React11.createElement(Text10, { bold: true, color: isUser ? "cyan" : isSystem ? "gray" : "green" }, isUser ? "\u{1F464} You" : isSystem ? "\u2139\uFE0F System" : "\u{1F916} Assistant"), isUser && /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, " \u2022 ", new Date(message.timestamp).toLocaleTimeString())), isUser && message.content && /* @__PURE__ */ React11.createElement(Box10, { paddingLeft: 2 }, /* @__PURE__ */ React11.createElement(Text10, { backgroundColor: "whiteBright", color: "black" }, " ", message.content, " ")), !isUser && message.metadata?.steps && message.metadata.steps.length > 0 && /* @__PURE__ */ React11.createElement(Box10, { paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React11.createElement(Text10, { dimColor: true, bold: true }, "\u{1F527} Agent Reasoning Trace (", message.metadata.steps.filter((s) => s.type === "action").length, " ", "tools used, ", message.metadata.steps.length, " total steps)", message.metadata.tokenUsage && ` \u2022 ${message.metadata.tokenUsage.total} tokens`), /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, "Step types: ", message.metadata.steps.map((s) => s.type).join(", ")), message.metadata.steps.map((step, idx) => {
1351
1425
  if (step.type === "thought") {
1352
- return /* @__PURE__ */ React10.createElement(Box9, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React10.createElement(Text9, { color: "blue" }, "\u{1F4AD} Thought:"), /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, ` ${step.content}`));
1426
+ return /* @__PURE__ */ React11.createElement(Box10, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React11.createElement(Text10, { color: "blue" }, "\u{1F4AD} Thought:"), /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, ` ${step.content}`));
1353
1427
  }
1354
1428
  if (step.type === "action") {
1355
1429
  const toolName = step.metadata?.toolName || "unknown";
1356
1430
  const toolInput = step.metadata?.toolInput;
1357
1431
  const observationStep = message.metadata.steps[idx + 1];
1358
1432
  const result = observationStep?.type === "observation" ? observationStep.content : null;
1359
- return /* @__PURE__ */ React10.createElement(Box9, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React10.createElement(Text9, { color: "yellow" }, "\u{1F527} Action: ", toolName), toolInput && /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, ` Input: ${typeof toolInput === "string" ? toolInput : JSON.stringify(toolInput).slice(0, 100)}`), result && /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, ` Result: ${typeof result === "string" ? result.slice(0, 200) : JSON.stringify(result).slice(0, 200)}${(typeof result === "string" ? result.length : JSON.stringify(result).length) > 200 ? "..." : ""}`));
1433
+ return /* @__PURE__ */ React11.createElement(Box10, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React11.createElement(Text10, { color: "yellow" }, "\u{1F527} Action: ", toolName), toolInput && /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, ` Input: ${typeof toolInput === "string" ? toolInput : JSON.stringify(toolInput).slice(0, 100)}`), result && /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, ` Result: ${typeof result === "string" ? result.slice(0, 200) : JSON.stringify(result).slice(0, 200)}${(typeof result === "string" ? result.length : JSON.stringify(result).length) > 200 ? "..." : ""}`));
1360
1434
  }
1361
1435
  return null;
1362
- }).filter(Boolean)), !isUser && message.content !== "..." && /* @__PURE__ */ React10.createElement(Box9, { paddingLeft: 2, marginTop: message.metadata?.steps?.length ? 1 : 0 }, message.metadata?.permissionDenied ? /* @__PURE__ */ React10.createElement(Text9, { color: "yellow" }, "\u26A0\uFE0F ", message.content) : /* @__PURE__ */ React10.createElement(Text9, null, message.content)), message.metadata?.tokenUsage && (!message.metadata.steps || message.metadata.steps.length === 0) && /* @__PURE__ */ React10.createElement(Box9, { paddingLeft: 2 }, /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, `${message.metadata.tokenUsage.total} tokens`)));
1436
+ }).filter(Boolean)), !isUser && message.content !== "..." && /* @__PURE__ */ React11.createElement(Box10, { paddingLeft: 2, marginTop: message.metadata?.steps?.length ? 1 : 0 }, message.metadata?.permissionDenied ? /* @__PURE__ */ React11.createElement(Text10, { color: "yellow" }, "\u26A0\uFE0F ", message.content) : /* @__PURE__ */ React11.createElement(Text10, null, message.content)), message.metadata?.tokenUsage && (!message.metadata.steps || message.metadata.steps.length === 0) && /* @__PURE__ */ React11.createElement(Box10, { paddingLeft: 2 }, /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, `${message.metadata.tokenUsage.total} tokens`)));
1363
1437
  }
1364
1438
 
1365
1439
  // src/utils/processFileReferences.ts
@@ -1489,7 +1563,10 @@ function App({
1489
1563
  availableModels = [],
1490
1564
  onSaveConfig,
1491
1565
  prefillInput,
1492
- onPrefillConsumed
1566
+ onPrefillConsumed,
1567
+ commandOutput,
1568
+ onCommandOutputDismiss,
1569
+ mcpManager
1493
1570
  }) {
1494
1571
  const messages = useCliStore((state) => state.session?.messages || []);
1495
1572
  const pendingMessages = useCliStore((state) => state.pendingMessages);
@@ -1500,13 +1577,23 @@ function App({
1500
1577
  const permissionPrompt = useCliStore((state) => state.permissionPrompt);
1501
1578
  const showConfigEditor = useCliStore((state) => state.showConfigEditor);
1502
1579
  const setShowConfigEditor = useCliStore((state) => state.setShowConfigEditor);
1580
+ const showMcpViewer = useCliStore((state) => state.showMcpViewer);
1581
+ const setShowMcpViewer = useCliStore((state) => state.setShowMcpViewer);
1503
1582
  const exitRequested = useCliStore((state) => state.exitRequested);
1504
1583
  const setIsThinking = useCliStore((state) => state.setIsThinking);
1505
1584
  const [isBashMode, setIsBashMode] = useState4(false);
1506
- const handleSubmit = React11.useCallback(
1585
+ useInput5((input, key) => {
1586
+ if (key.escape && commandOutput && onCommandOutputDismiss) {
1587
+ onCommandOutputDismiss();
1588
+ }
1589
+ });
1590
+ const handleSubmit = React12.useCallback(
1507
1591
  async (input) => {
1508
1592
  const trimmed = input.trim();
1509
1593
  if (!trimmed) return;
1594
+ if (commandOutput && onCommandOutputDismiss) {
1595
+ onCommandOutputDismiss();
1596
+ }
1510
1597
  if (trimmed.startsWith("/") && !trimmed.match(/^\/[A-Z]/)) {
1511
1598
  const [command, ...args] = trimmed.slice(1).split(" ");
1512
1599
  await onCommand(command, args);
@@ -1530,9 +1617,9 @@ ${errorBlock}`;
1530
1617
  setIsThinking(false);
1531
1618
  }
1532
1619
  },
1533
- [onMessage, onCommand, setIsThinking]
1620
+ [onMessage, onCommand, setIsThinking, commandOutput, onCommandOutputDismiss]
1534
1621
  );
1535
- return /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column" }, showConfigEditor && config && onSaveConfig ? /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(
1622
+ return /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column" }, showConfigEditor && config && onSaveConfig ? /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React12.createElement(
1536
1623
  ConfigEditor,
1537
1624
  {
1538
1625
  config,
@@ -1540,7 +1627,10 @@ ${errorBlock}`;
1540
1627
  onSave: onSaveConfig,
1541
1628
  onClose: () => setShowConfigEditor(false)
1542
1629
  }
1543
- )) : /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Static, { items: messages }, (message) => /* @__PURE__ */ React11.createElement(Box10, { key: message.id, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(MessageItem, { message }))), /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column" }, pendingMessages.map((message) => /* @__PURE__ */ React11.createElement(Box10, { key: message.id, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(MessageItem, { message })))), permissionPrompt && /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(
1630
+ )) : showMcpViewer && config ? (
1631
+ /* MCP Viewer - full screen takeover */
1632
+ /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React12.createElement(McpViewer, { config, mcpManager, onClose: () => setShowMcpViewer(false) }))
1633
+ ) : /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(Static, { items: messages }, (message) => /* @__PURE__ */ React12.createElement(Box11, { key: message.id, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React12.createElement(MessageItem, { message }))), /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column" }, pendingMessages.map((message) => /* @__PURE__ */ React12.createElement(Box11, { key: message.id, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React12.createElement(MessageItem, { message })))), permissionPrompt && /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React12.createElement(
1544
1634
  PermissionPrompt,
1545
1635
  {
1546
1636
  toolName: permissionPrompt.toolName,
@@ -1549,7 +1639,7 @@ ${errorBlock}`;
1549
1639
  canBeTrusted: permissionPrompt.canBeTrusted,
1550
1640
  onResponse: onPermissionResponse
1551
1641
  }
1552
- )), !permissionPrompt && /* @__PURE__ */ React11.createElement(AgentThinking, null), exitRequested && /* @__PURE__ */ React11.createElement(Box10, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React11.createElement(Text10, { color: "yellow", bold: true }, "Press Ctrl+C again to exit")), /* @__PURE__ */ React11.createElement(Box10, { borderStyle: "single", borderColor: isBashMode ? "yellow" : "cyan", paddingX: 1 }, /* @__PURE__ */ React11.createElement(
1642
+ )), !permissionPrompt && /* @__PURE__ */ React12.createElement(AgentThinking, null), exitRequested && /* @__PURE__ */ React12.createElement(Box11, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React12.createElement(Text11, { color: "yellow", bold: true }, "Press Ctrl+C again to exit")), commandOutput && /* @__PURE__ */ React12.createElement(Box11, { paddingX: 1, marginBottom: 1, flexDirection: "column", borderStyle: "round", borderColor: "gray" }, /* @__PURE__ */ React12.createElement(Text11, { dimColor: true }, commandOutput), /* @__PURE__ */ React12.createElement(Text11, { dimColor: true, italic: true }, "Press Esc to dismiss")), /* @__PURE__ */ React12.createElement(Box11, { borderStyle: "single", borderColor: isBashMode ? "yellow" : "cyan", paddingX: 1 }, /* @__PURE__ */ React12.createElement(
1553
1643
  InputPrompt,
1554
1644
  {
1555
1645
  onSubmit: handleSubmit,
@@ -1562,24 +1652,24 @@ ${errorBlock}`;
1562
1652
  onPrefillConsumed,
1563
1653
  onBashModeChange: setIsBashMode
1564
1654
  }
1565
- )), /* @__PURE__ */ React11.createElement(StatusBar, { sessionName, model: currentModel, tokenUsage: totalTokens })));
1655
+ )), /* @__PURE__ */ React12.createElement(StatusBar, { sessionName, model: currentModel, tokenUsage: totalTokens })));
1566
1656
  }
1567
1657
 
1568
1658
  // src/components/MessageList.tsx
1569
- import React12 from "react";
1570
- import { Box as Box11, Text as Text11 } from "ink";
1659
+ import React13 from "react";
1660
+ import { Box as Box12, Text as Text12 } from "ink";
1571
1661
  function stripThinkingTags(content) {
1572
1662
  return content.replace(/<think>[\s\S]*?<\/think>/g, "").trim();
1573
1663
  }
1574
- var MessageList = React12.memo(
1664
+ var MessageList = React13.memo(
1575
1665
  function MessageList2({ messages }) {
1576
1666
  if (messages.length === 0) {
1577
- return /* @__PURE__ */ React12.createElement(Box11, { paddingY: 1 }, /* @__PURE__ */ React12.createElement(Text11, { dimColor: true }, "No messages yet. Type a message to start!"));
1667
+ return /* @__PURE__ */ React13.createElement(Box12, { paddingY: 1 }, /* @__PURE__ */ React13.createElement(Text12, { dimColor: true }, "No messages yet. Type a message to start!"));
1578
1668
  }
1579
- return /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column", gap: 1, paddingY: 1 }, messages.map((message, index) => /* @__PURE__ */ React12.createElement(Box11, { key: index, flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ React12.createElement(Box11, null, /* @__PURE__ */ React12.createElement(Text11, { bold: true, color: message.role === "user" ? "cyan" : "green" }, message.role === "user" ? "\u{1F464} You" : "\u{1F916} Assistant"), /* @__PURE__ */ React12.createElement(Text11, { dimColor: true }, " \u2022 ", new Date(message.timestamp).toLocaleTimeString())), /* @__PURE__ */ React12.createElement(Box11, { paddingLeft: 2 }, message.metadata?.permissionDenied ? /* @__PURE__ */ React12.createElement(Text11, { color: "yellow" }, "\u26A0\uFE0F ", stripThinkingTags(message.content)) : /* @__PURE__ */ React12.createElement(Text11, null, stripThinkingTags(message.content))), message.metadata?.steps && message.metadata.steps.length > 0 && /* @__PURE__ */ React12.createElement(Box11, { paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React12.createElement(Text11, { dimColor: true, bold: true }, "\u{1F527} Agent Reasoning Trace (", message.metadata.steps.filter((s) => s.type === "action").length, " tools used,", " ", message.metadata.steps.length, " total steps)", message.metadata.tokenUsage && ` \u2022 ${message.metadata.tokenUsage.total} tokens`), /* @__PURE__ */ React12.createElement(Text11, { dimColor: true }, "Step types: ", message.metadata.steps.map((s) => s.type).join(", ")), message.metadata.steps.map((step, idx) => {
1669
+ return /* @__PURE__ */ React13.createElement(Box12, { flexDirection: "column", gap: 1, paddingY: 1 }, messages.map((message, index) => /* @__PURE__ */ React13.createElement(Box12, { key: index, flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ React13.createElement(Box12, null, /* @__PURE__ */ React13.createElement(Text12, { bold: true, color: message.role === "user" ? "cyan" : "green" }, message.role === "user" ? "\u{1F464} You" : "\u{1F916} Assistant"), /* @__PURE__ */ React13.createElement(Text12, { dimColor: true }, " \u2022 ", new Date(message.timestamp).toLocaleTimeString())), /* @__PURE__ */ React13.createElement(Box12, { paddingLeft: 2 }, message.metadata?.permissionDenied ? /* @__PURE__ */ React13.createElement(Text12, { color: "yellow" }, "\u26A0\uFE0F ", stripThinkingTags(message.content)) : /* @__PURE__ */ React13.createElement(Text12, null, stripThinkingTags(message.content))), message.metadata?.steps && message.metadata.steps.length > 0 && /* @__PURE__ */ React13.createElement(Box12, { paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React13.createElement(Text12, { dimColor: true, bold: true }, "\u{1F527} Agent Reasoning Trace (", message.metadata.steps.filter((s) => s.type === "action").length, " tools used,", " ", message.metadata.steps.length, " total steps)", message.metadata.tokenUsage && ` \u2022 ${message.metadata.tokenUsage.total} tokens`), /* @__PURE__ */ React13.createElement(Text12, { dimColor: true }, "Step types: ", message.metadata.steps.map((s) => s.type).join(", ")), message.metadata.steps.map((step, idx) => {
1580
1670
  if (step.type === "thought") {
1581
- return /* @__PURE__ */ React12.createElement(Box11, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React12.createElement(Text11, { color: "blue" }, "\u{1F4AD} Thought:"), /* @__PURE__ */ React12.createElement(
1582
- Text11,
1671
+ return /* @__PURE__ */ React13.createElement(Box12, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React13.createElement(Text12, { color: "blue" }, "\u{1F4AD} Thought:"), /* @__PURE__ */ React13.createElement(
1672
+ Text12,
1583
1673
  {
1584
1674
  dimColor: true
1585
1675
  },
@@ -1591,10 +1681,10 @@ var MessageList = React12.memo(
1591
1681
  const toolInput = step.metadata?.toolInput;
1592
1682
  const observationStep = message.metadata.steps[idx + 1];
1593
1683
  const result = observationStep?.type === "observation" ? observationStep.content : null;
1594
- return /* @__PURE__ */ React12.createElement(Box11, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React12.createElement(Text11, { color: "yellow" }, "\u{1F527} Action: ", toolName), toolInput && /* @__PURE__ */ React12.createElement(Text11, { dimColor: true }, ` Input: ${typeof toolInput === "string" ? toolInput : JSON.stringify(toolInput).slice(0, 100)}`), result && /* @__PURE__ */ React12.createElement(Text11, { dimColor: true }, ` Result: ${typeof result === "string" ? result.slice(0, 200) : JSON.stringify(result).slice(0, 200)}${(typeof result === "string" ? result.length : JSON.stringify(result).length) > 200 ? "..." : ""}`));
1684
+ return /* @__PURE__ */ React13.createElement(Box12, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React13.createElement(Text12, { color: "yellow" }, "\u{1F527} Action: ", toolName), toolInput && /* @__PURE__ */ React13.createElement(Text12, { dimColor: true }, ` Input: ${typeof toolInput === "string" ? toolInput : JSON.stringify(toolInput).slice(0, 100)}`), result && /* @__PURE__ */ React13.createElement(Text12, { dimColor: true }, ` Result: ${typeof result === "string" ? result.slice(0, 200) : JSON.stringify(result).slice(0, 200)}${(typeof result === "string" ? result.length : JSON.stringify(result).length) > 200 ? "..." : ""}`));
1595
1685
  }
1596
1686
  return null;
1597
- }).filter(Boolean)), message.metadata?.tokenUsage && (!message.metadata.steps || message.metadata.steps.length === 0) && /* @__PURE__ */ React12.createElement(Box11, { paddingLeft: 2 }, /* @__PURE__ */ React12.createElement(Text11, { dimColor: true }, `${message.metadata.tokenUsage.total} tokens`)))));
1687
+ }).filter(Boolean)), message.metadata?.tokenUsage && (!message.metadata.steps || message.metadata.steps.length === 0) && /* @__PURE__ */ React13.createElement(Box12, { paddingLeft: 2 }, /* @__PURE__ */ React13.createElement(Text12, { dimColor: true }, `${message.metadata.tokenUsage.total} tokens`)))));
1598
1688
  },
1599
1689
  (prevProps, nextProps) => {
1600
1690
  if (prevProps.messages.length !== nextProps.messages.length) {
@@ -1605,8 +1695,8 @@ var MessageList = React12.memo(
1605
1695
  );
1606
1696
 
1607
1697
  // src/components/TrustLocationSelector.tsx
1608
- import React13 from "react";
1609
- import { Box as Box12, Text as Text12 } from "ink";
1698
+ import React14 from "react";
1699
+ import { Box as Box13, Text as Text13 } from "ink";
1610
1700
  import SelectInput2 from "ink-select-input";
1611
1701
  function TrustLocationSelector({ inProject, onSelect, onCancel }) {
1612
1702
  const items = [];
@@ -1627,24 +1717,24 @@ function TrustLocationSelector({ inProject, onSelect, onCancel }) {
1627
1717
  const handleSelect = (item) => {
1628
1718
  onSelect(item.value);
1629
1719
  };
1630
- return /* @__PURE__ */ React13.createElement(Box12, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React13.createElement(Box12, { marginBottom: 1 }, /* @__PURE__ */ React13.createElement(Text12, { bold: true }, "Where should this rule be saved?")), /* @__PURE__ */ React13.createElement(
1720
+ return /* @__PURE__ */ React14.createElement(Box13, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React14.createElement(Box13, { marginBottom: 1 }, /* @__PURE__ */ React14.createElement(Text13, { bold: true }, "Where should this rule be saved?")), /* @__PURE__ */ React14.createElement(
1631
1721
  SelectInput2,
1632
1722
  {
1633
1723
  items,
1634
1724
  onSelect: handleSelect,
1635
- itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React13.createElement(Box12, null, /* @__PURE__ */ React13.createElement(Text12, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
1725
+ itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React14.createElement(Box13, null, /* @__PURE__ */ React14.createElement(Text13, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
1636
1726
  }
1637
- ), /* @__PURE__ */ React13.createElement(Box12, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(Text12, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Ctrl+C to cancel")));
1727
+ ), /* @__PURE__ */ React14.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React14.createElement(Text13, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Ctrl+C to cancel")));
1638
1728
  }
1639
1729
 
1640
1730
  // src/components/RewindSelector.tsx
1641
- import React14, { useState as useState5 } from "react";
1642
- import { Box as Box13, Text as Text13, useInput as useInput4 } from "ink";
1731
+ import React15, { useState as useState5 } from "react";
1732
+ import { Box as Box14, Text as Text14, useInput as useInput6 } from "ink";
1643
1733
  import SelectInput3 from "ink-select-input";
1644
1734
  function RewindSelector({ messages, onSelect, onCancel }) {
1645
1735
  const [step, setStep] = useState5("selection");
1646
1736
  const [selectedMessageIndex, setSelectedMessageIndex] = useState5(null);
1647
- useInput4((input, key) => {
1737
+ useInput6((input, key) => {
1648
1738
  if (key.escape) {
1649
1739
  if (step === "confirmation") {
1650
1740
  setStep("selection");
@@ -1681,14 +1771,14 @@ function RewindSelector({ messages, onSelect, onCancel }) {
1681
1771
  return sum2 + (msg.metadata?.tokenUsage?.total || 0);
1682
1772
  }, 0);
1683
1773
  if (step === "selection") {
1684
- return /* @__PURE__ */ React14.createElement(Box13, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React14.createElement(Box13, { marginBottom: 1 }, /* @__PURE__ */ React14.createElement(Text13, { bold: true }, "Select a point to rewind to:")), /* @__PURE__ */ React14.createElement(
1774
+ return /* @__PURE__ */ React15.createElement(Box14, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React15.createElement(Box14, { marginBottom: 1 }, /* @__PURE__ */ React15.createElement(Text14, { bold: true }, "Select a point to rewind to:")), /* @__PURE__ */ React15.createElement(
1685
1775
  SelectInput3,
1686
1776
  {
1687
1777
  items,
1688
1778
  onSelect: handleSelectionSelect,
1689
- itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React14.createElement(Box13, null, /* @__PURE__ */ React14.createElement(Text13, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
1779
+ itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React15.createElement(Box14, null, /* @__PURE__ */ React15.createElement(Text14, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
1690
1780
  }
1691
- ), /* @__PURE__ */ React14.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React14.createElement(Text13, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Esc to cancel")));
1781
+ ), /* @__PURE__ */ React15.createElement(Box14, { marginTop: 1 }, /* @__PURE__ */ React15.createElement(Text14, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Esc to cancel")));
1692
1782
  }
1693
1783
  const confirmationItems = [
1694
1784
  { label: "Yes, rewind to this point", value: "confirm" },
@@ -1696,24 +1786,24 @@ function RewindSelector({ messages, onSelect, onCancel }) {
1696
1786
  ];
1697
1787
  const selectedMessage = selectedMessageIndex !== null && selectedMessageIndex >= 0 && selectedMessageIndex < messages.length ? messages[selectedMessageIndex] : null;
1698
1788
  const selectedPreview = selectedMessage ? selectedMessage.content.length > 50 ? selectedMessage.content.substring(0, 50) + "..." : selectedMessage.content : "";
1699
- return /* @__PURE__ */ React14.createElement(Box13, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React14.createElement(Box13, { marginBottom: 1, flexDirection: "column" }, /* @__PURE__ */ React14.createElement(Text13, { bold: true }, "Confirm rewind operation:"), /* @__PURE__ */ React14.createElement(Text13, { dimColor: true }, "Message: ", selectedPreview), /* @__PURE__ */ React14.createElement(Text13, { color: "yellow" }, "This will remove ", messagesToRemove.length, " message(s) (", tokensToRemove.toLocaleString(), " tokens)"), /* @__PURE__ */ React14.createElement(Text13, { color: "cyan" }, "The selected message will be placed in your input for editing.")), /* @__PURE__ */ React14.createElement(
1789
+ return /* @__PURE__ */ React15.createElement(Box14, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React15.createElement(Box14, { marginBottom: 1, flexDirection: "column" }, /* @__PURE__ */ React15.createElement(Text14, { bold: true }, "Confirm rewind operation:"), /* @__PURE__ */ React15.createElement(Text14, { dimColor: true }, "Message: ", selectedPreview), /* @__PURE__ */ React15.createElement(Text14, { color: "yellow" }, "This will remove ", messagesToRemove.length, " message(s) (", tokensToRemove.toLocaleString(), " tokens)"), /* @__PURE__ */ React15.createElement(Text14, { color: "cyan" }, "The selected message will be placed in your input for editing.")), /* @__PURE__ */ React15.createElement(
1700
1790
  SelectInput3,
1701
1791
  {
1702
1792
  items: confirmationItems,
1703
1793
  onSelect: handleConfirmationSelect,
1704
- itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React14.createElement(Box13, null, /* @__PURE__ */ React14.createElement(Text13, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
1794
+ itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React15.createElement(Box14, null, /* @__PURE__ */ React15.createElement(Text14, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
1705
1795
  }
1706
- ), /* @__PURE__ */ React14.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React14.createElement(Text13, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Esc to go back")));
1796
+ ), /* @__PURE__ */ React15.createElement(Box14, { marginTop: 1 }, /* @__PURE__ */ React15.createElement(Text14, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Esc to go back")));
1707
1797
  }
1708
1798
 
1709
1799
  // src/components/SessionSelector.tsx
1710
- import React15, { useState as useState6 } from "react";
1711
- import { Box as Box14, Text as Text14, useInput as useInput5 } from "ink";
1800
+ import React16, { useState as useState6 } from "react";
1801
+ import { Box as Box15, Text as Text15, useInput as useInput7 } from "ink";
1712
1802
  import SelectInput4 from "ink-select-input";
1713
1803
  function SessionSelector({ sessions, currentSession, onSelect, onCancel }) {
1714
1804
  const [step, setStep] = useState6("selection");
1715
1805
  const [selectedSession, setSelectedSession] = useState6(null);
1716
- useInput5((input, key) => {
1806
+ useInput7((input, key) => {
1717
1807
  if (key.escape) {
1718
1808
  if (step === "confirmation") {
1719
1809
  setStep("selection");
@@ -1746,32 +1836,32 @@ function SessionSelector({ sessions, currentSession, onSelect, onCancel }) {
1746
1836
  }
1747
1837
  };
1748
1838
  if (step === "selection") {
1749
- return /* @__PURE__ */ React15.createElement(Box14, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React15.createElement(Box14, { marginBottom: 1 }, /* @__PURE__ */ React15.createElement(Text14, { bold: true }, "Select a session to resume:")), /* @__PURE__ */ React15.createElement(
1839
+ return /* @__PURE__ */ React16.createElement(Box15, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React16.createElement(Box15, { marginBottom: 1 }, /* @__PURE__ */ React16.createElement(Text15, { bold: true }, "Select a session to resume:")), /* @__PURE__ */ React16.createElement(
1750
1840
  SelectInput4,
1751
1841
  {
1752
1842
  items,
1753
1843
  onSelect: handleSelectionSelect,
1754
- itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React15.createElement(Box14, null, /* @__PURE__ */ React15.createElement(Text14, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
1844
+ itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React16.createElement(Box15, null, /* @__PURE__ */ React16.createElement(Text15, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
1755
1845
  }
1756
- ), /* @__PURE__ */ React15.createElement(Box14, { marginTop: 1 }, /* @__PURE__ */ React15.createElement(Text14, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Esc to cancel")));
1846
+ ), /* @__PURE__ */ React16.createElement(Box15, { marginTop: 1 }, /* @__PURE__ */ React16.createElement(Text15, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Esc to cancel")));
1757
1847
  }
1758
1848
  const confirmationItems = [
1759
1849
  { label: "Yes, resume this session", value: "confirm" },
1760
1850
  { label: "No, go back to selection", value: "cancel" }
1761
1851
  ];
1762
- return /* @__PURE__ */ React15.createElement(Box14, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React15.createElement(Box14, { marginBottom: 1, flexDirection: "column" }, /* @__PURE__ */ React15.createElement(Text14, { bold: true }, 'Resume session: "', selectedSession?.name, '"'), /* @__PURE__ */ React15.createElement(Text14, { dimColor: true }, selectedSession?.messages.length, " messages | ", selectedSession?.model, " |", " ", selectedSession?.metadata?.totalTokens?.toLocaleString() ?? 0, " tokens"), hasUnsavedWork && /* @__PURE__ */ React15.createElement(Text14, { color: "yellow" }, "Warning: Your current session has unsaved messages. Use /save first if needed.")), /* @__PURE__ */ React15.createElement(
1852
+ return /* @__PURE__ */ React16.createElement(Box15, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React16.createElement(Box15, { marginBottom: 1, flexDirection: "column" }, /* @__PURE__ */ React16.createElement(Text15, { bold: true }, 'Resume session: "', selectedSession?.name, '"'), /* @__PURE__ */ React16.createElement(Text15, { dimColor: true }, selectedSession?.messages.length, " messages | ", selectedSession?.model, " |", " ", selectedSession?.metadata?.totalTokens?.toLocaleString() ?? 0, " tokens"), hasUnsavedWork && /* @__PURE__ */ React16.createElement(Text15, { color: "yellow" }, "Warning: Your current session has unsaved messages. Use /save first if needed.")), /* @__PURE__ */ React16.createElement(
1763
1853
  SelectInput4,
1764
1854
  {
1765
1855
  items: confirmationItems,
1766
1856
  onSelect: handleConfirmationSelect,
1767
- itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React15.createElement(Box14, null, /* @__PURE__ */ React15.createElement(Text14, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
1857
+ itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React16.createElement(Box15, null, /* @__PURE__ */ React16.createElement(Text15, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
1768
1858
  }
1769
- ), /* @__PURE__ */ React15.createElement(Box14, { marginTop: 1 }, /* @__PURE__ */ React15.createElement(Text14, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Esc to go back")));
1859
+ ), /* @__PURE__ */ React16.createElement(Box15, { marginTop: 1 }, /* @__PURE__ */ React16.createElement(Text15, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Esc to go back")));
1770
1860
  }
1771
1861
 
1772
1862
  // src/components/LoginFlow.tsx
1773
- import React16, { useState as useState7, useEffect as useEffect2 } from "react";
1774
- import { Box as Box15, Text as Text15 } from "ink";
1863
+ import React17, { useState as useState7, useEffect as useEffect2 } from "react";
1864
+ import { Box as Box16, Text as Text16 } from "ink";
1775
1865
  import Spinner2 from "ink-spinner";
1776
1866
  import jwt from "jsonwebtoken";
1777
1867
  import open from "open";
@@ -1934,15 +2024,15 @@ function LoginFlow({ apiUrl = "http://localhost:3000", configStore, onSuccess, o
1934
2024
  }
1935
2025
  }, [deviceFlow, status]);
1936
2026
  if (status === "initiating") {
1937
- return /* @__PURE__ */ React16.createElement(Box15, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React16.createElement(Box15, null, /* @__PURE__ */ React16.createElement(Text15, { color: "cyan" }, /* @__PURE__ */ React16.createElement(Spinner2, { type: "dots" }), " Initiating device authorization...")));
2027
+ return /* @__PURE__ */ React17.createElement(Box16, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React17.createElement(Box16, null, /* @__PURE__ */ React17.createElement(Text16, { color: "cyan" }, /* @__PURE__ */ React17.createElement(Spinner2, { type: "dots" }), " Initiating device authorization...")));
1938
2028
  }
1939
2029
  if (status === "error") {
1940
- return /* @__PURE__ */ React16.createElement(Box15, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React16.createElement(Box15, { marginBottom: 1 }, /* @__PURE__ */ React16.createElement(Text15, { color: "red", bold: true }, "\u2716 Authentication Failed")), /* @__PURE__ */ React16.createElement(Box15, null, /* @__PURE__ */ React16.createElement(Text15, { color: "red" }, error)));
2030
+ return /* @__PURE__ */ React17.createElement(Box16, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React17.createElement(Box16, { marginBottom: 1 }, /* @__PURE__ */ React17.createElement(Text16, { color: "red", bold: true }, "\u2716 Authentication Failed")), /* @__PURE__ */ React17.createElement(Box16, null, /* @__PURE__ */ React17.createElement(Text16, { color: "red" }, error)));
1941
2031
  }
1942
2032
  if (status === "success") {
1943
- return /* @__PURE__ */ React16.createElement(Box15, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React16.createElement(Box15, { marginBottom: 1 }, /* @__PURE__ */ React16.createElement(Text15, { color: "green", bold: true }, "\u2714 Successfully authenticated!")), /* @__PURE__ */ React16.createElement(Box15, null, /* @__PURE__ */ React16.createElement(Text15, { dimColor: true }, "You can now use B4M CLI with your account.")));
2033
+ return /* @__PURE__ */ React17.createElement(Box16, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React17.createElement(Box16, { marginBottom: 1 }, /* @__PURE__ */ React17.createElement(Text16, { color: "green", bold: true }, "\u2714 Successfully authenticated!")), /* @__PURE__ */ React17.createElement(Box16, null, /* @__PURE__ */ React17.createElement(Text16, { dimColor: true }, "You can now use B4M CLI with your account.")));
1944
2034
  }
1945
- return /* @__PURE__ */ React16.createElement(Box15, { flexDirection: "column", padding: 1, borderStyle: "round", borderColor: "cyan" }, /* @__PURE__ */ React16.createElement(Box15, { marginBottom: 1 }, /* @__PURE__ */ React16.createElement(Text15, { color: "cyan", bold: true }, "\u{1F510} Device Authorization")), /* @__PURE__ */ React16.createElement(Box15, { marginBottom: 1 }, /* @__PURE__ */ React16.createElement(Text15, null, "Opening browser automatically... If it doesn't open, please visit:")), /* @__PURE__ */ React16.createElement(Box15, { marginBottom: 1, paddingLeft: 2 }, /* @__PURE__ */ React16.createElement(Text15, { color: "blue", bold: true }, deviceFlow?.verification_uri)), /* @__PURE__ */ React16.createElement(Box15, { marginBottom: 1 }, /* @__PURE__ */ React16.createElement(Text15, null, "And enter this code when prompted:")), /* @__PURE__ */ React16.createElement(Box15, { marginBottom: 1, paddingLeft: 2 }, /* @__PURE__ */ React16.createElement(Text15, { color: "yellow", bold: true }, deviceFlow?.user_code)), /* @__PURE__ */ React16.createElement(Box15, { marginTop: 1 }, /* @__PURE__ */ React16.createElement(Text15, { color: "cyan" }, /* @__PURE__ */ React16.createElement(Spinner2, { type: "dots" }), " ", statusMessage)), /* @__PURE__ */ React16.createElement(Box15, { marginTop: 1 }, /* @__PURE__ */ React16.createElement(Text15, { dimColor: true }, "Expires in ", deviceFlow ? Math.floor(deviceFlow.expires_in / 60) : 0, " minutes")));
2035
+ return /* @__PURE__ */ React17.createElement(Box16, { flexDirection: "column", padding: 1, borderStyle: "round", borderColor: "cyan" }, /* @__PURE__ */ React17.createElement(Box16, { marginBottom: 1 }, /* @__PURE__ */ React17.createElement(Text16, { color: "cyan", bold: true }, "\u{1F510} Device Authorization")), /* @__PURE__ */ React17.createElement(Box16, { marginBottom: 1 }, /* @__PURE__ */ React17.createElement(Text16, null, "Opening browser automatically... If it doesn't open, please visit:")), /* @__PURE__ */ React17.createElement(Box16, { marginBottom: 1, paddingLeft: 2 }, /* @__PURE__ */ React17.createElement(Text16, { color: "blue", bold: true }, deviceFlow?.verification_uri)), /* @__PURE__ */ React17.createElement(Box16, { marginBottom: 1 }, /* @__PURE__ */ React17.createElement(Text16, null, "And enter this code when prompted:")), /* @__PURE__ */ React17.createElement(Box16, { marginBottom: 1, paddingLeft: 2 }, /* @__PURE__ */ React17.createElement(Text16, { color: "yellow", bold: true }, deviceFlow?.user_code)), /* @__PURE__ */ React17.createElement(Box16, { marginTop: 1 }, /* @__PURE__ */ React17.createElement(Text16, { color: "cyan" }, /* @__PURE__ */ React17.createElement(Spinner2, { type: "dots" }), " ", statusMessage)), /* @__PURE__ */ React17.createElement(Box16, { marginTop: 1 }, /* @__PURE__ */ React17.createElement(Text16, { dimColor: true }, "Expires in ", deviceFlow ? Math.floor(deviceFlow.expires_in / 60) : 0, " minutes")));
1946
2036
  }
1947
2037
 
1948
2038
  // src/storage/SessionStore.ts
@@ -2078,629 +2168,23 @@ var SessionStore = class {
2078
2168
  }
2079
2169
  };
2080
2170
 
2081
- // src/storage/ConfigStore.ts
2082
- import { promises as fs4, existsSync as existsSync3 } from "fs";
2171
+ // src/storage/CommandHistoryStore.ts
2172
+ import { promises as fs4 } from "fs";
2083
2173
  import path4 from "path";
2084
2174
  import { homedir as homedir2 } from "os";
2085
- import { v4 as uuidv42 } from "uuid";
2086
- import { z } from "zod";
2087
- var AuthTokensSchema = z.object({
2088
- accessToken: z.string(),
2089
- refreshToken: z.string(),
2090
- expiresAt: z.string(),
2091
- userId: z.string()
2092
- });
2093
- var ApiConfigSchema = z.object({
2094
- customUrl: z.string().url().optional()
2095
- });
2096
- var CliConfigSchema = z.object({
2097
- version: z.string(),
2098
- userId: z.string(),
2099
- auth: AuthTokensSchema.optional(),
2100
- defaultModel: z.string(),
2101
- apiConfig: ApiConfigSchema.optional(),
2102
- toolApiKeys: z.object({
2103
- openweather: z.string().optional(),
2104
- serper: z.string().optional()
2105
- }).optional(),
2106
- mcpServers: z.array(
2107
- z.object({
2108
- name: z.string(),
2109
- command: z.string().optional(),
2110
- args: z.array(z.string()).optional(),
2111
- env: z.record(z.string()),
2112
- enabled: z.boolean()
2113
- })
2114
- ),
2115
- preferences: z.object({
2116
- maxTokens: z.number(),
2117
- temperature: z.number(),
2118
- autoSave: z.boolean(),
2119
- theme: z.enum(["light", "dark"]),
2120
- exportFormat: z.enum(["markdown", "json"]),
2121
- maxIterations: z.number().nullable().default(10)
2122
- }),
2123
- tools: z.object({
2124
- enabled: z.array(z.string()),
2125
- disabled: z.array(z.string()),
2126
- config: z.record(z.any())
2127
- }),
2128
- trustedTools: z.array(z.string()).optional().default([])
2129
- });
2130
- var ProjectConfigSchema = z.object({
2131
- tools: z.object({
2132
- enabled: z.array(z.string()).optional(),
2133
- denied: z.array(z.string()).optional(),
2134
- config: z.record(z.any()).optional()
2135
- }).optional(),
2136
- defaultModel: z.string().optional(),
2137
- mcpServers: z.array(
2138
- z.object({
2139
- name: z.string(),
2140
- command: z.string().optional(),
2141
- args: z.array(z.string()).optional(),
2142
- env: z.record(z.string()),
2143
- enabled: z.boolean()
2144
- })
2145
- ).optional(),
2146
- preferences: z.object({
2147
- maxTokens: z.number().optional(),
2148
- temperature: z.number().optional(),
2149
- autoSave: z.boolean().optional(),
2150
- theme: z.enum(["light", "dark"]).optional(),
2151
- exportFormat: z.enum(["markdown", "json"]).optional()
2152
- }).optional()
2153
- });
2154
- var ProjectLocalConfigSchema = z.object({
2155
- trustedTools: z.array(z.string()).optional(),
2156
- toolApiKeys: z.object({
2157
- openweather: z.string().optional(),
2158
- serper: z.string().optional()
2159
- }).optional(),
2160
- preferences: z.object({
2161
- maxTokens: z.number().optional(),
2162
- temperature: z.number().optional(),
2163
- autoSave: z.boolean().optional(),
2164
- theme: z.enum(["light", "dark"]).optional(),
2165
- exportFormat: z.enum(["markdown", "json"]).optional()
2166
- }).optional(),
2167
- mcpServers: z.array(
2168
- z.object({
2169
- name: z.string(),
2170
- command: z.string().optional(),
2171
- args: z.array(z.string()).optional(),
2172
- env: z.record(z.string()),
2173
- enabled: z.boolean()
2174
- })
2175
- ).optional()
2176
- });
2177
- var DEFAULT_CONFIG = {
2178
- version: "0.1.0",
2179
- userId: uuidv42(),
2180
- defaultModel: "claude-sonnet-4-5-20250929",
2181
- toolApiKeys: {
2182
- openweather: void 0,
2183
- serper: void 0
2184
- },
2185
- mcpServers: [],
2186
- preferences: {
2187
- maxTokens: 4096,
2188
- temperature: 0.7,
2189
- autoSave: true,
2190
- theme: "dark",
2191
- exportFormat: "markdown",
2192
- maxIterations: 10
2193
- },
2194
- tools: {
2195
- enabled: [],
2196
- disabled: ["blog_publish", "blog_edit", "blog_draft"],
2197
- // Web-only tools
2198
- config: {}
2199
- },
2200
- trustedTools: []
2201
- // No tools trusted by default
2202
- };
2203
- function findProjectConfigDir(startDir = process.cwd()) {
2204
- let currentDir = startDir;
2205
- const { root } = path4.parse(currentDir);
2206
- while (currentDir !== root) {
2207
- const gitPath = path4.join(currentDir, ".git");
2208
- try {
2209
- if (existsSync3(gitPath)) {
2210
- return currentDir;
2211
- }
2212
- } catch {
2213
- }
2214
- currentDir = path4.dirname(currentDir);
2215
- }
2216
- return process.cwd();
2217
- }
2218
- async function loadProjectConfig(projectDir) {
2219
- const configPath = path4.join(projectDir, ".bike4mind", "config.json");
2220
- try {
2221
- const data = await fs4.readFile(configPath, "utf-8");
2222
- const rawConfig = JSON.parse(data);
2223
- const validated = ProjectConfigSchema.parse(rawConfig);
2224
- return validated;
2225
- } catch (error) {
2226
- if (error.code === "ENOENT") {
2227
- return null;
2228
- }
2229
- if (error instanceof z.ZodError) {
2230
- console.error("Project config validation error:", error.errors);
2231
- return null;
2232
- }
2233
- console.error("Failed to load project config:", error);
2234
- return null;
2235
- }
2236
- }
2237
- async function loadProjectLocalConfig(projectDir) {
2238
- const configPath = path4.join(projectDir, ".bike4mind", "local.json");
2239
- try {
2240
- const data = await fs4.readFile(configPath, "utf-8");
2241
- const rawConfig = JSON.parse(data);
2242
- const validated = ProjectLocalConfigSchema.parse(rawConfig);
2243
- return validated;
2244
- } catch (error) {
2245
- if (error.code === "ENOENT") {
2246
- return null;
2247
- }
2248
- if (error instanceof z.ZodError) {
2249
- console.error("Project local config validation error:", error.errors);
2250
- return null;
2251
- }
2252
- console.error("Failed to load project local config:", error);
2253
- return null;
2254
- }
2255
- }
2256
- function mergeMcpServers(...serverArrays) {
2257
- const serverMap = /* @__PURE__ */ new Map();
2258
- for (const servers of serverArrays) {
2259
- if (servers) {
2260
- for (const server of servers) {
2261
- serverMap.set(server.name, server);
2262
- }
2263
- }
2264
- }
2265
- return Array.from(serverMap.values());
2266
- }
2267
- function mergeConfigs(global, project, local) {
2268
- const merged = { ...global };
2269
- if (project) {
2270
- if (project.defaultModel) {
2271
- merged.defaultModel = project.defaultModel;
2272
- }
2273
- if (project.preferences) {
2274
- merged.preferences = {
2275
- ...merged.preferences,
2276
- ...project.preferences
2277
- };
2278
- }
2279
- if (project.tools) {
2280
- merged.tools = {
2281
- ...merged.tools,
2282
- enabled: [...merged.tools.enabled || [], ...project.tools.enabled || []],
2283
- disabled: [...merged.tools.disabled, ...project.tools.denied || []],
2284
- config: {
2285
- ...merged.tools.config,
2286
- ...project.tools.config
2287
- }
2288
- };
2289
- }
2290
- if (project.mcpServers) {
2291
- merged.mcpServers = mergeMcpServers(merged.mcpServers, project.mcpServers);
2292
- }
2293
- }
2294
- if (local) {
2295
- if (local.trustedTools) {
2296
- const trustedSet = /* @__PURE__ */ new Set([...merged.trustedTools || [], ...local.trustedTools]);
2297
- merged.trustedTools = Array.from(trustedSet);
2298
- }
2299
- if (local.toolApiKeys) {
2300
- merged.toolApiKeys = {
2301
- ...merged.toolApiKeys,
2302
- ...local.toolApiKeys
2303
- };
2304
- }
2305
- if (local.preferences) {
2306
- merged.preferences = {
2307
- ...merged.preferences,
2308
- ...local.preferences
2309
- };
2310
- }
2311
- if (local.mcpServers) {
2312
- merged.mcpServers = mergeMcpServers(merged.mcpServers, local.mcpServers);
2313
- }
2314
- }
2315
- return merged;
2316
- }
2317
- var ConfigStore = class {
2318
- constructor(configPath) {
2319
- this.config = null;
2320
- this.projectConfigDir = null;
2321
- this.configPath = configPath || path4.join(homedir2(), ".bike4mind", "config.json");
2322
- }
2323
- /**
2324
- * Initialize config directory
2325
- */
2326
- async init() {
2327
- const dir = path4.dirname(this.configPath);
2328
- try {
2329
- await fs4.mkdir(dir, { recursive: true });
2330
- } catch (error) {
2331
- console.error("Failed to initialize config directory:", error);
2332
- throw error;
2333
- }
2334
- }
2335
- /**
2336
- * Load configuration from disk with Zod validation
2337
- * Merges global → project → local configs
2338
- */
2339
- async load() {
2340
- if (this.config) {
2341
- return this.config;
2342
- }
2343
- try {
2344
- let globalConfig;
2345
- try {
2346
- try {
2347
- const stats = await fs4.stat(this.configPath);
2348
- const mode = stats.mode & 511;
2349
- if (mode !== 384) {
2350
- console.warn(`\u26A0\uFE0F Config file has insecure permissions (${mode.toString(8)}). Setting to 0600...`);
2351
- await fs4.chmod(this.configPath, 384);
2352
- }
2353
- } catch (statError) {
2354
- }
2355
- const data = await fs4.readFile(this.configPath, "utf-8");
2356
- const rawConfig = JSON.parse(data);
2357
- if (rawConfig.apiConfig && "environment" in rawConfig.apiConfig) {
2358
- const oldApiConfig = rawConfig.apiConfig;
2359
- if (oldApiConfig.environment === "custom" && oldApiConfig.customUrl) {
2360
- rawConfig.apiConfig = { customUrl: oldApiConfig.customUrl };
2361
- } else {
2362
- rawConfig.apiConfig = {};
2363
- }
2364
- }
2365
- const validated = CliConfigSchema.parse(rawConfig);
2366
- globalConfig = {
2367
- ...DEFAULT_CONFIG,
2368
- ...validated,
2369
- auth: validated.auth,
2370
- // Explicitly preserve auth field
2371
- preferences: {
2372
- ...DEFAULT_CONFIG.preferences,
2373
- ...validated.preferences
2374
- },
2375
- tools: {
2376
- ...DEFAULT_CONFIG.tools,
2377
- ...validated.tools
2378
- },
2379
- toolApiKeys: {
2380
- ...DEFAULT_CONFIG.toolApiKeys,
2381
- ...validated.toolApiKeys || {}
2382
- },
2383
- trustedTools: validated.trustedTools || []
2384
- };
2385
- } catch (error) {
2386
- if (error.code === "ENOENT") {
2387
- globalConfig = { ...DEFAULT_CONFIG };
2388
- } else if (error instanceof z.ZodError) {
2389
- console.error("Global config validation error:", error.errors);
2390
- console.error("Using default configuration");
2391
- globalConfig = { ...DEFAULT_CONFIG };
2392
- } else {
2393
- throw error;
2394
- }
2395
- }
2396
- let projectConfig = null;
2397
- let projectLocalConfig = null;
2398
- if (process.env.B4M_NO_PROJECT_CONFIG !== "1") {
2399
- this.projectConfigDir = findProjectConfigDir();
2400
- if (this.projectConfigDir) {
2401
- projectConfig = await loadProjectConfig(this.projectConfigDir);
2402
- projectLocalConfig = await loadProjectLocalConfig(this.projectConfigDir);
2403
- if (projectConfig) {
2404
- console.log(`\u{1F4C1} Project config loaded from: ${this.projectConfigDir}/.bike4mind/`);
2405
- }
2406
- }
2407
- } else {
2408
- this.projectConfigDir = null;
2409
- }
2410
- this.config = mergeConfigs(globalConfig, projectConfig, projectLocalConfig);
2411
- return this.config;
2412
- } catch (error) {
2413
- if (error.code === "ENOENT") {
2414
- return this.reset();
2415
- }
2416
- if (error instanceof z.ZodError) {
2417
- console.error("Config validation error:", error.errors);
2418
- console.error("Resetting to default configuration");
2419
- return this.reset();
2420
- }
2421
- console.error("Failed to load config:", error);
2422
- throw error;
2423
- }
2424
- }
2425
- /**
2426
- * Save configuration to disk
2427
- */
2428
- async save(config) {
2429
- await this.init();
2430
- if (config) {
2431
- const existingConfig = await this.load();
2432
- this.config = {
2433
- ...existingConfig,
2434
- ...config,
2435
- auth: config.auth !== void 0 ? config.auth : existingConfig.auth,
2436
- preferences: {
2437
- ...existingConfig.preferences,
2438
- ...config.preferences || {}
2439
- },
2440
- tools: {
2441
- ...existingConfig.tools,
2442
- ...config.tools || {}
2443
- },
2444
- toolApiKeys: {
2445
- ...existingConfig.toolApiKeys,
2446
- ...config.toolApiKeys || {}
2447
- }
2448
- };
2449
- }
2450
- if (!this.config) {
2451
- throw new Error("No configuration to save");
2452
- }
2453
- try {
2454
- await fs4.writeFile(this.configPath, JSON.stringify(this.config, null, 2), "utf-8");
2455
- await fs4.chmod(this.configPath, 384);
2456
- } catch (error) {
2457
- console.error("Failed to save config:", error);
2458
- throw error;
2459
- }
2460
- }
2461
- /**
2462
- * Reset configuration to defaults
2463
- */
2464
- async reset() {
2465
- this.config = { ...DEFAULT_CONFIG, userId: uuidv42() };
2466
- await this.save();
2467
- return this.config;
2468
- }
2469
- /**
2470
- * Get current configuration
2471
- */
2472
- async get() {
2473
- return this.load();
2474
- }
2475
- /**
2476
- * Update a specific configuration value
2477
- */
2478
- async update(updates) {
2479
- await this.save(updates);
2480
- }
2481
- /**
2482
- * Add MCP server configuration
2483
- */
2484
- async addMcpServer(server) {
2485
- const config = await this.load();
2486
- config.mcpServers = config.mcpServers.filter((s) => s.name !== server.name);
2487
- config.mcpServers.push(server);
2488
- await this.save(config);
2489
- }
2490
- /**
2491
- * Remove MCP server configuration
2492
- */
2493
- async removeMcpServer(name) {
2494
- const config = await this.load();
2495
- config.mcpServers = config.mcpServers.filter((s) => s.name !== name);
2496
- await this.save(config);
2497
- }
2498
- /**
2499
- * Enable/disable MCP server
2500
- */
2501
- async toggleMcpServer(name, enabled) {
2502
- const config = await this.load();
2503
- const server = config.mcpServers.find((s) => s.name === name);
2504
- if (server) {
2505
- server.enabled = enabled;
2506
- await this.save(config);
2507
- }
2508
- }
2509
- /**
2510
- * Add a tool to trusted tools list
2511
- */
2512
- async trustTool(toolName) {
2513
- const config = await this.load();
2514
- if (!config.trustedTools) {
2515
- config.trustedTools = [];
2516
- }
2517
- if (!config.trustedTools.includes(toolName)) {
2518
- config.trustedTools.push(toolName);
2519
- await this.save(config);
2520
- }
2521
- }
2522
- /**
2523
- * Remove a tool from trusted tools list
2524
- */
2525
- async untrustTool(toolName) {
2526
- const config = await this.load();
2527
- if (config.trustedTools) {
2528
- config.trustedTools = config.trustedTools.filter((t) => t !== toolName);
2529
- await this.save(config);
2530
- }
2531
- }
2532
- /**
2533
- * Get list of trusted tools
2534
- */
2535
- async getTrustedTools() {
2536
- const config = await this.load();
2537
- return config.trustedTools || [];
2538
- }
2539
- /**
2540
- * Clear all trusted tools
2541
- */
2542
- async clearTrustedTools() {
2543
- const config = await this.load();
2544
- config.trustedTools = [];
2545
- await this.save(config);
2546
- }
2547
- /**
2548
- * Get authentication tokens
2549
- */
2550
- async getAuthTokens() {
2551
- const config = await this.load();
2552
- return config.auth || null;
2553
- }
2554
- /**
2555
- * Set authentication tokens
2556
- */
2557
- async setAuthTokens(tokens) {
2558
- const config = await this.load();
2559
- config.auth = tokens;
2560
- await this.save(config);
2561
- }
2562
- /**
2563
- * Clear authentication tokens (logout)
2564
- */
2565
- async clearAuthTokens() {
2566
- const config = await this.load();
2567
- config.auth = void 0;
2568
- await this.save(config);
2569
- }
2570
- /**
2571
- * Check if user is authenticated
2572
- */
2573
- async isAuthenticated() {
2574
- const tokens = await this.getAuthTokens();
2575
- if (!tokens) return false;
2576
- const expiresAt = new Date(tokens.expiresAt);
2577
- return expiresAt > /* @__PURE__ */ new Date();
2578
- }
2579
- /**
2580
- * Get API configuration
2581
- */
2582
- async getApiConfig() {
2583
- const config = await this.load();
2584
- return config.apiConfig;
2585
- }
2586
- /**
2587
- * Set custom API URL for self-hosted Bike4Mind instance
2588
- * Pass null to reset to Bike4Mind main service
2589
- */
2590
- async setCustomApiUrl(url) {
2591
- const config = await this.load();
2592
- if (url === null) {
2593
- config.apiConfig = void 0;
2594
- } else {
2595
- config.apiConfig = { customUrl: url };
2596
- }
2597
- await this.save(config);
2598
- }
2599
- /**
2600
- * Get project config directory (if any)
2601
- */
2602
- getProjectConfigDir() {
2603
- return this.projectConfigDir;
2604
- }
2605
- /**
2606
- * Initialize project config directory
2607
- * Creates .bike4mind/ directory and ensures local.json is gitignored
2608
- * Does NOT auto-create config.json (user creates that manually)
2609
- */
2610
- async initProjectConfig() {
2611
- const projectDir = this.projectConfigDir || findProjectConfigDir();
2612
- if (!projectDir) {
2613
- return;
2614
- }
2615
- const configDir = path4.join(projectDir, ".bike4mind");
2616
- await fs4.mkdir(configDir, { recursive: true });
2617
- await this.ensureGitignore(projectDir);
2618
- }
2619
- /**
2620
- * Ensure .gitignore includes .bike4mind/local.json
2621
- */
2622
- async ensureGitignore(projectDir) {
2623
- const gitignorePath = path4.join(projectDir, ".gitignore");
2624
- const entryToAdd = ".bike4mind/local.json";
2625
- try {
2626
- let gitignoreContent = "";
2627
- try {
2628
- gitignoreContent = await fs4.readFile(gitignorePath, "utf-8");
2629
- } catch {
2630
- }
2631
- if (gitignoreContent.includes(entryToAdd)) {
2632
- return;
2633
- }
2634
- const newContent = gitignoreContent.trim() + (gitignoreContent ? "\n" : "") + `
2635
- # Bike4Mind local config (developer-specific)
2636
- ${entryToAdd}
2637
- `;
2638
- await fs4.writeFile(gitignorePath, newContent, "utf-8");
2639
- console.log(`\u2705 Added ${entryToAdd} to .gitignore`);
2640
- } catch (error) {
2641
- console.warn(`\u26A0\uFE0F Failed to update .gitignore:`, error);
2642
- }
2643
- }
2644
- /**
2645
- * Save project config to .bike4mind/config.json
2646
- */
2647
- async saveProjectConfig(config, projectDir) {
2648
- const targetDir = projectDir || this.projectConfigDir || process.cwd();
2649
- const configPath = path4.join(targetDir, ".bike4mind", "config.json");
2650
- await fs4.mkdir(path4.dirname(configPath), { recursive: true });
2651
- const validated = ProjectConfigSchema.parse(config);
2652
- await fs4.writeFile(configPath, JSON.stringify(validated, null, 2), "utf-8");
2653
- console.log(`\u2705 Saved project config to: ${configPath}`);
2654
- }
2655
- /**
2656
- * Save project-local config to .bike4mind/local.json
2657
- */
2658
- async saveProjectLocalConfig(config, projectDir) {
2659
- const targetDir = projectDir || this.projectConfigDir || process.cwd();
2660
- const configPath = path4.join(targetDir, ".bike4mind", "local.json");
2661
- await fs4.mkdir(path4.dirname(configPath), { recursive: true });
2662
- const validated = ProjectLocalConfigSchema.parse(config);
2663
- await fs4.writeFile(configPath, JSON.stringify(validated, null, 2), "utf-8");
2664
- await fs4.chmod(configPath, 384);
2665
- console.log(`\u2705 Saved project-local config to: ${configPath}`);
2666
- }
2667
- /**
2668
- * Load raw project config (without merging)
2669
- */
2670
- async loadRawProjectConfig() {
2671
- if (!this.projectConfigDir) {
2672
- return null;
2673
- }
2674
- return loadProjectConfig(this.projectConfigDir);
2675
- }
2676
- /**
2677
- * Load raw project-local config (without merging)
2678
- */
2679
- async loadRawProjectLocalConfig() {
2680
- if (!this.projectConfigDir) {
2681
- return null;
2682
- }
2683
- return loadProjectLocalConfig(this.projectConfigDir);
2684
- }
2685
- };
2686
-
2687
- // src/storage/CommandHistoryStore.ts
2688
- import { promises as fs5 } from "fs";
2689
- import path5 from "path";
2690
- import { homedir as homedir3 } from "os";
2691
2175
  var MAX_HISTORY_ENTRIES = 1e3;
2692
2176
  var CommandHistoryStore = class {
2693
2177
  constructor(historyPath) {
2694
2178
  this.history = null;
2695
- this.historyPath = historyPath || path5.join(homedir3(), ".bike4mind", "history.jsonl");
2179
+ this.historyPath = historyPath || path4.join(homedir2(), ".bike4mind", "history.jsonl");
2696
2180
  }
2697
2181
  /**
2698
2182
  * Initialize history directory
2699
2183
  */
2700
2184
  async init() {
2701
- const dir = path5.dirname(this.historyPath);
2185
+ const dir = path4.dirname(this.historyPath);
2702
2186
  try {
2703
- await fs5.mkdir(dir, { recursive: true });
2187
+ await fs4.mkdir(dir, { recursive: true });
2704
2188
  } catch (error) {
2705
2189
  console.error("Failed to initialize history directory:", error);
2706
2190
  throw error;
@@ -2715,7 +2199,7 @@ var CommandHistoryStore = class {
2715
2199
  return this.history;
2716
2200
  }
2717
2201
  try {
2718
- const data = await fs5.readFile(this.historyPath, "utf-8");
2202
+ const data = await fs4.readFile(this.historyPath, "utf-8");
2719
2203
  const lines = data.trim().split("\n").filter((line) => line.length > 0);
2720
2204
  const entries = lines.map((line) => {
2721
2205
  try {
@@ -2752,7 +2236,7 @@ var CommandHistoryStore = class {
2752
2236
  };
2753
2237
  await this.init();
2754
2238
  const line = JSON.stringify(entry) + "\n";
2755
- await fs5.appendFile(this.historyPath, line, "utf-8");
2239
+ await fs4.appendFile(this.historyPath, line, "utf-8");
2756
2240
  this.history = [command, ...this.history || []];
2757
2241
  if (this.history.length > MAX_HISTORY_ENTRIES) {
2758
2242
  await this.trim();
@@ -2775,7 +2259,7 @@ var CommandHistoryStore = class {
2775
2259
  };
2776
2260
  return JSON.stringify(entry);
2777
2261
  }).join("\n");
2778
- await fs5.writeFile(this.historyPath, lines + "\n", "utf-8");
2262
+ await fs4.writeFile(this.historyPath, lines + "\n", "utf-8");
2779
2263
  this.history = trimmedCommands;
2780
2264
  }
2781
2265
  /**
@@ -2783,7 +2267,7 @@ var CommandHistoryStore = class {
2783
2267
  */
2784
2268
  async clear() {
2785
2269
  try {
2786
- await fs5.unlink(this.historyPath);
2270
+ await fs4.unlink(this.historyPath);
2787
2271
  } catch (error) {
2788
2272
  if (error.code !== "ENOENT") {
2789
2273
  throw error;
@@ -2800,23 +2284,23 @@ var CommandHistoryStore = class {
2800
2284
  };
2801
2285
 
2802
2286
  // src/storage/CustomCommandStore.ts
2803
- import fs6 from "fs/promises";
2804
- import path6 from "path";
2287
+ import fs5 from "fs/promises";
2288
+ import path5 from "path";
2805
2289
  import os from "os";
2806
2290
 
2807
2291
  // src/utils/commandParser.ts
2808
2292
  import matter from "gray-matter";
2809
- import { z as z2 } from "zod";
2810
- var FrontmatterSchema = z2.object({
2811
- description: z2.string().optional(),
2812
- "argument-hint": z2.string().optional(),
2813
- model: z2.string().optional(),
2293
+ import { z } from "zod";
2294
+ var FrontmatterSchema = z.object({
2295
+ description: z.string().optional(),
2296
+ "argument-hint": z.string().optional(),
2297
+ model: z.string().optional(),
2814
2298
  // Future fields (ignored for now):
2815
- "allowed-tools": z2.any().optional(),
2816
- context: z2.any().optional(),
2817
- agent: z2.any().optional(),
2818
- "disable-model-invocation": z2.any().optional(),
2819
- hooks: z2.any().optional()
2299
+ "allowed-tools": z.any().optional(),
2300
+ context: z.any().optional(),
2301
+ agent: z.any().optional(),
2302
+ "disable-model-invocation": z.any().optional(),
2303
+ hooks: z.any().optional()
2820
2304
  });
2821
2305
  function extractDescriptionFromBody(body) {
2822
2306
  const lines = body.trim().split("\n");
@@ -2877,8 +2361,8 @@ function extractCommandName(filename) {
2877
2361
  var CustomCommandStore = class {
2878
2362
  constructor(projectRoot) {
2879
2363
  this.commands = /* @__PURE__ */ new Map();
2880
- this.globalCommandsDir = path6.join(os.homedir(), ".bike4mind", "commands");
2881
- this.projectCommandsDir = path6.join(projectRoot || process.cwd(), ".bike4mind", "commands");
2364
+ this.globalCommandsDir = path5.join(os.homedir(), ".bike4mind", "commands");
2365
+ this.projectCommandsDir = path5.join(projectRoot || process.cwd(), ".bike4mind", "commands");
2882
2366
  }
2883
2367
  /**
2884
2368
  * Loads all custom commands from both global and project directories
@@ -2897,7 +2381,7 @@ var CustomCommandStore = class {
2897
2381
  */
2898
2382
  async loadCommandsFromDirectory(directory, source) {
2899
2383
  try {
2900
- const stats = await fs6.stat(directory);
2384
+ const stats = await fs5.stat(directory);
2901
2385
  if (!stats.isDirectory()) {
2902
2386
  return;
2903
2387
  }
@@ -2930,9 +2414,9 @@ var CustomCommandStore = class {
2930
2414
  async findCommandFiles(directory) {
2931
2415
  const files = [];
2932
2416
  try {
2933
- const entries = await fs6.readdir(directory, { withFileTypes: true });
2417
+ const entries = await fs5.readdir(directory, { withFileTypes: true });
2934
2418
  for (const entry of entries) {
2935
- const fullPath = path6.join(directory, entry.name);
2419
+ const fullPath = path5.join(directory, entry.name);
2936
2420
  if (entry.isDirectory()) {
2937
2421
  const subFiles = await this.findCommandFiles(fullPath);
2938
2422
  files.push(...subFiles);
@@ -2952,13 +2436,13 @@ var CustomCommandStore = class {
2952
2436
  * @param source - Source identifier ('global' or 'project')
2953
2437
  */
2954
2438
  async loadCommandFile(filePath, source) {
2955
- const filename = path6.basename(filePath);
2439
+ const filename = path5.basename(filePath);
2956
2440
  const commandName = extractCommandName(filename);
2957
2441
  if (!commandName) {
2958
2442
  console.warn(`Invalid command filename: ${filename} (must end with .md and have valid name)`);
2959
2443
  return;
2960
2444
  }
2961
- const fileContent = await fs6.readFile(filePath, "utf-8");
2445
+ const fileContent = await fs5.readFile(filePath, "utf-8");
2962
2446
  const command = parseCommandFile(fileContent, filePath, commandName, source);
2963
2447
  const existing = this.commands.get(commandName);
2964
2448
  if (existing && existing.source === "project" && source === "global") {
@@ -3025,16 +2509,16 @@ var CustomCommandStore = class {
3025
2509
  */
3026
2510
  async createCommandFile(name, isGlobal = false) {
3027
2511
  const targetDir = isGlobal ? this.globalCommandsDir : this.projectCommandsDir;
3028
- const filePath = path6.join(targetDir, `${name}.md`);
2512
+ const filePath = path5.join(targetDir, `${name}.md`);
3029
2513
  try {
3030
- await fs6.access(filePath);
2514
+ await fs5.access(filePath);
3031
2515
  throw new Error(`Command file already exists: ${filePath}`);
3032
2516
  } catch (error) {
3033
2517
  if (error.code !== "ENOENT") {
3034
2518
  throw error;
3035
2519
  }
3036
2520
  }
3037
- await fs6.mkdir(targetDir, { recursive: true });
2521
+ await fs5.mkdir(targetDir, { recursive: true });
3038
2522
  const template = `---
3039
2523
  description: ${name} command
3040
2524
  argument-hint: [args]
@@ -3049,7 +2533,7 @@ You can use:
3049
2533
  - $1, $2, etc. for positional arguments
3050
2534
  - @filename for file references
3051
2535
  `;
3052
- await fs6.writeFile(filePath, template, "utf-8");
2536
+ await fs5.writeFile(filePath, template, "utf-8");
3053
2537
  return filePath;
3054
2538
  }
3055
2539
  };
@@ -3459,38 +2943,38 @@ Remember: Use context from previous messages to understand follow-up questions.$
3459
2943
  // ../../b4m-core/packages/services/dist/src/referService/generateCodes.js
3460
2944
  import { randomBytes } from "crypto";
3461
2945
  import range from "lodash/range.js";
3462
- import { z as z3 } from "zod";
3463
- var generateReferralCodesSchema = z3.object({
3464
- count: z3.number().optional(),
3465
- unlimitedUse: z3.boolean().optional(),
3466
- expiresAt: z3.date().optional()
2946
+ import { z as z2 } from "zod";
2947
+ var generateReferralCodesSchema = z2.object({
2948
+ count: z2.number().optional(),
2949
+ unlimitedUse: z2.boolean().optional(),
2950
+ expiresAt: z2.date().optional()
3467
2951
  });
3468
2952
 
3469
2953
  // ../../b4m-core/packages/services/dist/src/referService/delete.js
3470
- import { z as z4 } from "zod";
3471
- var deleteInviteCodesSchema = z4.object({
3472
- ids: z4.array(z4.string())
2954
+ import { z as z3 } from "zod";
2955
+ var deleteInviteCodesSchema = z3.object({
2956
+ ids: z3.array(z3.string())
3473
2957
  });
3474
2958
 
3475
2959
  // ../../b4m-core/packages/services/dist/src/userService/login.js
3476
- import { z as z5 } from "zod";
2960
+ import { z as z4 } from "zod";
3477
2961
  import bcrypt from "bcryptjs";
3478
- var loginUserSchema = z5.object({
3479
- usernameOrEmail: z5.string(),
3480
- password: z5.string(),
3481
- metadata: z5.object({
3482
- loginTime: z5.date(),
3483
- userAgent: z5.string(),
3484
- browser: z5.string(),
3485
- operatingSystem: z5.string(),
3486
- deviceType: z5.string(),
3487
- screenResolution: z5.string(),
3488
- viewportSize: z5.string(),
3489
- colorDepth: z5.number(),
3490
- pixelDepth: z5.number(),
3491
- devicePixelRatio: z5.number(),
3492
- ip: z5.string().optional().default(""),
3493
- location: z5.string().optional()
2962
+ var loginUserSchema = z4.object({
2963
+ usernameOrEmail: z4.string(),
2964
+ password: z4.string(),
2965
+ metadata: z4.object({
2966
+ loginTime: z4.date(),
2967
+ userAgent: z4.string(),
2968
+ browser: z4.string(),
2969
+ operatingSystem: z4.string(),
2970
+ deviceType: z4.string(),
2971
+ screenResolution: z4.string(),
2972
+ viewportSize: z4.string(),
2973
+ colorDepth: z4.number(),
2974
+ pixelDepth: z4.number(),
2975
+ devicePixelRatio: z4.number(),
2976
+ ip: z4.string().optional().default(""),
2977
+ location: z4.string().optional()
3494
2978
  }).optional()
3495
2979
  });
3496
2980
 
@@ -3500,78 +2984,78 @@ import escapeRegExp from "lodash/escapeRegExp.js";
3500
2984
 
3501
2985
  // ../../b4m-core/packages/services/dist/src/userService/forgotPassword.js
3502
2986
  import { randomUUID } from "crypto";
3503
- import { z as z6 } from "zod";
3504
- var forgotPasswordUserSchema = z6.object({
3505
- email: z6.string().email()
2987
+ import { z as z5 } from "zod";
2988
+ var forgotPasswordUserSchema = z5.object({
2989
+ email: z5.string().email()
3506
2990
  });
3507
2991
 
3508
2992
  // ../../b4m-core/packages/services/dist/src/userService/update.js
3509
2993
  import bcrypt3 from "bcryptjs";
3510
- import { z as z7 } from "zod";
3511
- var updateUserSchema = z7.object({
3512
- name: z7.string().optional(),
3513
- username: z7.string().optional(),
2994
+ import { z as z6 } from "zod";
2995
+ var updateUserSchema = z6.object({
2996
+ name: z6.string().optional(),
2997
+ username: z6.string().optional(),
3514
2998
  // email field removed - users must use the secure email change verification flow
3515
2999
  // See requestEmailChange and verifyEmailChange in userService
3516
- password: z7.string().nullable().optional(),
3517
- team: z7.string().nullable().optional(),
3518
- role: z7.string().nullable().optional(),
3519
- phone: z7.string().nullable().optional(),
3520
- preferredLanguage: z7.string().nullable().optional(),
3521
- preferredContact: z7.string().nullable().optional(),
3522
- preferredVoice: z7.string().nullable().optional(),
3523
- tshirtSize: z7.string().nullable().optional(),
3524
- geoLocation: z7.string().nullable().optional(),
3525
- lastNotebookId: z7.string().nullable().optional(),
3526
- tags: z7.array(z7.string()).nullable().optional(),
3527
- lastCreditsPurchasedAt: z7.date().nullable().optional(),
3528
- systemFiles: z7.array(z7.object({
3529
- fileId: z7.string(),
3530
- enabled: z7.boolean()
3000
+ password: z6.string().nullable().optional(),
3001
+ team: z6.string().nullable().optional(),
3002
+ role: z6.string().nullable().optional(),
3003
+ phone: z6.string().nullable().optional(),
3004
+ preferredLanguage: z6.string().nullable().optional(),
3005
+ preferredContact: z6.string().nullable().optional(),
3006
+ preferredVoice: z6.string().nullable().optional(),
3007
+ tshirtSize: z6.string().nullable().optional(),
3008
+ geoLocation: z6.string().nullable().optional(),
3009
+ lastNotebookId: z6.string().nullable().optional(),
3010
+ tags: z6.array(z6.string()).nullable().optional(),
3011
+ lastCreditsPurchasedAt: z6.date().nullable().optional(),
3012
+ systemFiles: z6.array(z6.object({
3013
+ fileId: z6.string(),
3014
+ enabled: z6.boolean()
3531
3015
  })).nullable().optional(),
3532
- securityQuestions: z7.array(z7.object({ question: z7.string(), answer: z7.string() })).nullable().optional(),
3533
- photoUrl: z7.string().nullable().optional(),
3534
- showCreditsUsed: z7.boolean().optional()
3016
+ securityQuestions: z6.array(z6.object({ question: z6.string(), answer: z6.string() })).nullable().optional(),
3017
+ photoUrl: z6.string().nullable().optional(),
3018
+ showCreditsUsed: z6.boolean().optional()
3535
3019
  });
3536
3020
 
3537
3021
  // ../../b4m-core/packages/services/dist/src/userService/adminUpdate.js
3538
- import { z as z9 } from "zod";
3022
+ import { z as z8 } from "zod";
3539
3023
 
3540
3024
  // ../../b4m-core/packages/services/dist/src/friendshipService/sendFriendRequest.js
3541
- import { z as z8 } from "zod";
3542
- var sendFriendRequestSchema = z8.object({
3543
- requesterId: z8.string(),
3544
- recipientId: z8.string(),
3545
- message: z8.string().optional()
3025
+ import { z as z7 } from "zod";
3026
+ var sendFriendRequestSchema = z7.object({
3027
+ requesterId: z7.string(),
3028
+ recipientId: z7.string(),
3029
+ message: z7.string().optional()
3546
3030
  });
3547
3031
 
3548
3032
  // ../../b4m-core/packages/services/dist/src/userService/adminUpdate.js
3549
3033
  var adminUpdateUserSchema = updateUserSchema.extend({
3550
- id: z9.string(),
3034
+ id: z8.string(),
3551
3035
  // Admins can directly update email addresses without verification
3552
- email: z9.string().email().optional(),
3553
- role: z9.string().optional().nullable(),
3554
- isAdmin: z9.boolean().optional(),
3555
- organizationId: z9.string().optional().nullable(),
3556
- storageLimit: z9.number().optional(),
3557
- currentCredits: z9.number().optional(),
3558
- isBanned: z9.boolean().optional(),
3559
- isModerated: z9.boolean().optional(),
3560
- subscribedUntil: z9.string().optional().nullable(),
3561
- systemFiles: z9.array(z9.object({ fileId: z9.string(), enabled: z9.boolean() })).optional(),
3562
- level: z9.enum(["DemoUser", "PaidUser", "VIPUser", "ManagerUser", "AdminUser"]).optional(),
3563
- lastNotebookId: z9.string().optional().nullable(),
3564
- userNotes: z9.array(z9.object({ timestamp: z9.string(), note: z9.string(), userName: z9.string() })).optional(),
3565
- numReferralsAvailable: z9.number().optional()
3036
+ email: z8.string().email().optional(),
3037
+ role: z8.string().optional().nullable(),
3038
+ isAdmin: z8.boolean().optional(),
3039
+ organizationId: z8.string().optional().nullable(),
3040
+ storageLimit: z8.number().optional(),
3041
+ currentCredits: z8.number().optional(),
3042
+ isBanned: z8.boolean().optional(),
3043
+ isModerated: z8.boolean().optional(),
3044
+ subscribedUntil: z8.string().optional().nullable(),
3045
+ systemFiles: z8.array(z8.object({ fileId: z8.string(), enabled: z8.boolean() })).optional(),
3046
+ level: z8.enum(["DemoUser", "PaidUser", "VIPUser", "ManagerUser", "AdminUser"]).optional(),
3047
+ lastNotebookId: z8.string().optional().nullable(),
3048
+ userNotes: z8.array(z8.object({ timestamp: z8.string(), note: z8.string(), userName: z8.string() })).optional(),
3049
+ numReferralsAvailable: z8.number().optional()
3566
3050
  });
3567
3051
 
3568
3052
  // ../../b4m-core/packages/services/dist/src/userService/register.js
3569
- import { z as z11 } from "zod";
3053
+ import { z as z10 } from "zod";
3570
3054
  import bcrypt4 from "bcryptjs";
3571
3055
 
3572
3056
  // ../../b4m-core/packages/services/dist/src/creditService/addCredits.js
3573
- import { z as z10 } from "zod";
3574
- var AddCreditsSchema = z10.discriminatedUnion("type", [
3057
+ import { z as z9 } from "zod";
3058
+ var AddCreditsSchema = z9.discriminatedUnion("type", [
3575
3059
  PurchaseTransaction.omit({ createdAt: true, updatedAt: true }),
3576
3060
  SubscriptionCreditTransaction.omit({ createdAt: true, updatedAt: true }),
3577
3061
  GenericCreditAddTransaction.omit({ createdAt: true, updatedAt: true }),
@@ -3579,57 +3063,57 @@ var AddCreditsSchema = z10.discriminatedUnion("type", [
3579
3063
  ]);
3580
3064
 
3581
3065
  // ../../b4m-core/packages/services/dist/src/userService/register.js
3582
- var registerUserSchema = z11.object({
3583
- username: z11.string(),
3584
- email: z11.string(),
3585
- name: z11.string(),
3586
- inviteCode: z11.string(),
3587
- password: z11.string(),
3588
- metadata: z11.object({
3589
- loginTime: z11.date(),
3590
- userAgent: z11.string(),
3591
- browser: z11.string(),
3592
- operatingSystem: z11.string(),
3593
- deviceType: z11.string(),
3594
- screenResolution: z11.string(),
3595
- viewportSize: z11.string(),
3596
- colorDepth: z11.number(),
3597
- pixelDepth: z11.number(),
3598
- devicePixelRatio: z11.number(),
3599
- ip: z11.string().optional().default(""),
3600
- location: z11.string().optional()
3066
+ var registerUserSchema = z10.object({
3067
+ username: z10.string(),
3068
+ email: z10.string(),
3069
+ name: z10.string(),
3070
+ inviteCode: z10.string(),
3071
+ password: z10.string(),
3072
+ metadata: z10.object({
3073
+ loginTime: z10.date(),
3074
+ userAgent: z10.string(),
3075
+ browser: z10.string(),
3076
+ operatingSystem: z10.string(),
3077
+ deviceType: z10.string(),
3078
+ screenResolution: z10.string(),
3079
+ viewportSize: z10.string(),
3080
+ colorDepth: z10.number(),
3081
+ pixelDepth: z10.number(),
3082
+ devicePixelRatio: z10.number(),
3083
+ ip: z10.string().optional().default(""),
3084
+ location: z10.string().optional()
3601
3085
  }).optional()
3602
3086
  });
3603
3087
 
3604
3088
  // ../../b4m-core/packages/services/dist/src/userService/adminDelete.js
3605
- import { z as z12 } from "zod";
3606
- var adminDeleteUserSchema = z12.object({
3607
- id: z12.string()
3089
+ import { z as z11 } from "zod";
3090
+ var adminDeleteUserSchema = z11.object({
3091
+ id: z11.string()
3608
3092
  });
3609
3093
 
3610
3094
  // ../../b4m-core/packages/services/dist/src/userService/searchUserCollection.js
3611
- import { z as z13 } from "zod";
3612
- var searchUserCollectionSchema = z13.object({
3613
- userId: z13.string(),
3614
- page: z13.coerce.number().optional().default(1),
3615
- limit: z13.coerce.number().optional().default(10),
3616
- search: z13.string().optional().default(""),
3617
- type: z13.nativeEnum(CollectionType).optional()
3095
+ import { z as z12 } from "zod";
3096
+ var searchUserCollectionSchema = z12.object({
3097
+ userId: z12.string(),
3098
+ page: z12.coerce.number().optional().default(1),
3099
+ limit: z12.coerce.number().optional().default(10),
3100
+ search: z12.string().optional().default(""),
3101
+ type: z12.nativeEnum(CollectionType).optional()
3618
3102
  });
3619
3103
 
3620
3104
  // ../../b4m-core/packages/services/dist/src/userService/recalculateUserStorage.js
3621
- import { z as z14 } from "zod";
3622
- var recalculateUserStorageSchema = z14.object({
3105
+ import { z as z13 } from "zod";
3106
+ var recalculateUserStorageSchema = z13.object({
3623
3107
  /**
3624
3108
  * The user to recalculate the storage for
3625
3109
  */
3626
- userId: z14.string()
3110
+ userId: z13.string()
3627
3111
  });
3628
3112
 
3629
3113
  // ../../b4m-core/packages/services/dist/src/userService/listRecentActivities.js
3630
- import { z as z15 } from "zod";
3631
- var listRecentActivitiesSchema = z15.object({
3632
- coverage: z15.enum(["all", "important"]).default("important")
3114
+ import { z as z14 } from "zod";
3115
+ var listRecentActivitiesSchema = z14.object({
3116
+ coverage: z14.enum(["all", "important"]).default("important")
3633
3117
  });
3634
3118
  var IMPORTANT_COUNTER_NAMES = [
3635
3119
  SessionEvents.CREATE_SESSION,
@@ -3643,82 +3127,82 @@ var IMPORTANT_COUNTER_NAMES = [
3643
3127
 
3644
3128
  // ../../b4m-core/packages/services/dist/src/userService/sendEmailVerification.js
3645
3129
  import { randomUUID as randomUUID2 } from "crypto";
3646
- import { z as z16 } from "zod";
3647
- var sendEmailVerificationSchema = z16.object({
3648
- userId: z16.string()
3130
+ import { z as z15 } from "zod";
3131
+ var sendEmailVerificationSchema = z15.object({
3132
+ userId: z15.string()
3649
3133
  });
3650
3134
 
3651
3135
  // ../../b4m-core/packages/services/dist/src/userService/verifyEmailToken.js
3652
- import { z as z17 } from "zod";
3136
+ import { z as z16 } from "zod";
3653
3137
 
3654
3138
  // ../../b4m-core/packages/services/dist/src/utils/crypto.js
3655
3139
  import crypto from "crypto";
3656
3140
 
3657
3141
  // ../../b4m-core/packages/services/dist/src/userService/verifyEmailToken.js
3658
- var verifyEmailTokenSchema = z17.object({
3659
- token: z17.string()
3142
+ var verifyEmailTokenSchema = z16.object({
3143
+ token: z16.string()
3660
3144
  });
3661
3145
 
3662
3146
  // ../../b4m-core/packages/services/dist/src/userService/resendEmailVerification.js
3663
3147
  import { randomUUID as randomUUID3 } from "crypto";
3664
- import { z as z18 } from "zod";
3665
- var resendEmailVerificationSchema = z18.object({
3666
- userId: z18.string()
3148
+ import { z as z17 } from "zod";
3149
+ var resendEmailVerificationSchema = z17.object({
3150
+ userId: z17.string()
3667
3151
  });
3668
3152
 
3669
3153
  // ../../b4m-core/packages/services/dist/src/userService/requestEmailChange.js
3670
3154
  import { randomUUID as randomUUID4 } from "crypto";
3671
- import { z as z19 } from "zod";
3672
- var requestEmailChangeSchema = z19.object({
3673
- userId: z19.string(),
3674
- newEmail: z19.string().email(),
3675
- password: z19.string()
3155
+ import { z as z18 } from "zod";
3156
+ var requestEmailChangeSchema = z18.object({
3157
+ userId: z18.string(),
3158
+ newEmail: z18.string().email(),
3159
+ password: z18.string()
3676
3160
  });
3677
3161
 
3678
3162
  // ../../b4m-core/packages/services/dist/src/userService/verifyEmailChange.js
3679
- import { z as z20 } from "zod";
3680
- var verifyEmailChangeSchema = z20.object({
3681
- token: z20.string()
3163
+ import { z as z19 } from "zod";
3164
+ var verifyEmailChangeSchema = z19.object({
3165
+ token: z19.string()
3682
3166
  });
3683
3167
 
3684
3168
  // ../../b4m-core/packages/services/dist/src/userService/cancelEmailChange.js
3685
- import { z as z21 } from "zod";
3686
- var cancelEmailChangeSchema = z21.object({
3687
- userId: z21.string()
3169
+ import { z as z20 } from "zod";
3170
+ var cancelEmailChangeSchema = z20.object({
3171
+ userId: z20.string()
3688
3172
  });
3689
3173
 
3690
3174
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/create.js
3691
3175
  import { randomBytes as randomBytes2 } from "crypto";
3692
3176
  import bcrypt5 from "bcryptjs";
3693
- import { z as z22 } from "zod";
3694
- var createUserApiKeySchema = z22.object({
3695
- name: z22.string().min(1).max(100),
3696
- scopes: z22.array(z22.nativeEnum(ApiKeyScope)).min(1),
3697
- expiresAt: z22.date().optional(),
3698
- rateLimit: z22.object({
3699
- requestsPerMinute: z22.number().min(1).max(1e3).default(60),
3700
- requestsPerDay: z22.number().min(1).max(1e4).default(1e3)
3177
+ import { z as z21 } from "zod";
3178
+ var createUserApiKeySchema = z21.object({
3179
+ name: z21.string().min(1).max(100),
3180
+ scopes: z21.array(z21.nativeEnum(ApiKeyScope)).min(1),
3181
+ expiresAt: z21.date().optional(),
3182
+ rateLimit: z21.object({
3183
+ requestsPerMinute: z21.number().min(1).max(1e3).default(60),
3184
+ requestsPerDay: z21.number().min(1).max(1e4).default(1e3)
3701
3185
  }).optional(),
3702
- metadata: z22.object({
3703
- clientIP: z22.string().optional(),
3704
- userAgent: z22.string().optional(),
3705
- createdFrom: z22.enum(["dashboard", "cli", "api"])
3186
+ metadata: z21.object({
3187
+ clientIP: z21.string().optional(),
3188
+ userAgent: z21.string().optional(),
3189
+ createdFrom: z21.enum(["dashboard", "cli", "api"])
3706
3190
  })
3707
3191
  });
3708
3192
 
3709
3193
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/revoke.js
3710
- import { z as z23 } from "zod";
3711
- var revokeUserApiKeySchema = z23.object({
3712
- keyId: z23.string(),
3713
- reason: z23.string().optional()
3194
+ import { z as z22 } from "zod";
3195
+ var revokeUserApiKeySchema = z22.object({
3196
+ keyId: z22.string(),
3197
+ reason: z22.string().optional()
3714
3198
  });
3715
3199
 
3716
3200
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/rotate.js
3717
3201
  import { randomBytes as randomBytes3 } from "crypto";
3718
3202
  import bcrypt6 from "bcryptjs";
3719
- import { z as z24 } from "zod";
3720
- var rotateUserApiKeySchema = z24.object({
3721
- keyId: z24.string()
3203
+ import { z as z23 } from "zod";
3204
+ var rotateUserApiKeySchema = z23.object({
3205
+ keyId: z23.string()
3722
3206
  });
3723
3207
 
3724
3208
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/validate.js
@@ -3865,29 +3349,29 @@ var EVENT_GROUPS = [
3865
3349
  ];
3866
3350
 
3867
3351
  // ../../b4m-core/packages/services/dist/src/countersService/generateReport.js
3868
- import { z as z26 } from "zod";
3352
+ import { z as z25 } from "zod";
3869
3353
 
3870
3354
  // ../../b4m-core/packages/services/dist/src/countersService/getAllCounterFrom24Hours.js
3871
- import { z as z25 } from "zod";
3355
+ import { z as z24 } from "zod";
3872
3356
  import dayjs2 from "dayjs";
3873
- var getCounterTotalsForLast24HoursSchema = z25.object({
3874
- date: z25.string(),
3875
- endDate: z25.string().optional()
3357
+ var getCounterTotalsForLast24HoursSchema = z24.object({
3358
+ date: z24.string(),
3359
+ endDate: z24.string().optional()
3876
3360
  });
3877
3361
 
3878
3362
  // ../../b4m-core/packages/services/dist/src/countersService/generateReport.js
3879
- var generateDailyReportSchema = z26.object({
3880
- date: z26.string(),
3881
- startDate: z26.string().optional(),
3882
- endDate: z26.string().optional()
3363
+ var generateDailyReportSchema = z25.object({
3364
+ date: z25.string(),
3365
+ startDate: z25.string().optional(),
3366
+ endDate: z25.string().optional()
3883
3367
  });
3884
3368
 
3885
3369
  // ../../b4m-core/packages/services/dist/src/countersService/incrementUserCounter.js
3886
- import { z as z27 } from "zod";
3887
- var incrementUserCounterSchema = z27.object({
3888
- action: z27.string(),
3889
- increment: z27.coerce.number().default(1).optional(),
3890
- metadata: z27.record(z27.unknown()).optional()
3370
+ import { z as z26 } from "zod";
3371
+ var incrementUserCounterSchema = z26.object({
3372
+ action: z26.string(),
3373
+ increment: z26.coerce.number().default(1).optional(),
3374
+ metadata: z26.record(z26.unknown()).optional()
3891
3375
  });
3892
3376
 
3893
3377
  // ../../b4m-core/packages/services/dist/src/countersService/sendSlackReport.js
@@ -3903,47 +3387,47 @@ import { GoogleGenerativeAI } from "@google/generative-ai";
3903
3387
  import OpenAI2 from "openai";
3904
3388
 
3905
3389
  // ../../b4m-core/packages/services/dist/src/importHistoryService/index.js
3906
- import fs7, { unlinkSync } from "fs";
3390
+ import fs6, { unlinkSync } from "fs";
3907
3391
  import yauzl from "yauzl";
3908
3392
  import axios3 from "axios";
3909
3393
 
3910
3394
  // ../../b4m-core/packages/services/dist/src/importHistoryService/importOpenaiHistory.js
3911
- import { z as z28 } from "zod";
3395
+ import { z as z27 } from "zod";
3912
3396
  import last from "lodash/last.js";
3913
- var epochDate = () => z28.preprocess((val) => new Date(Number(val) * 1e3), z28.date());
3914
- var openaiConversationSchema = z28.object({
3915
- id: z28.string(),
3916
- title: z28.string(),
3397
+ var epochDate = () => z27.preprocess((val) => new Date(Number(val) * 1e3), z27.date());
3398
+ var openaiConversationSchema = z27.object({
3399
+ id: z27.string(),
3400
+ title: z27.string(),
3917
3401
  create_time: epochDate(),
3918
3402
  update_time: epochDate().nullable(),
3919
- mapping: z28.record(
3920
- z28.string(),
3921
- z28.object({
3922
- id: z28.string(),
3923
- parent: z28.string().nullable(),
3924
- children: z28.array(z28.string()),
3925
- message: z28.object({
3926
- id: z28.string(),
3403
+ mapping: z27.record(
3404
+ z27.string(),
3405
+ z27.object({
3406
+ id: z27.string(),
3407
+ parent: z27.string().nullable(),
3408
+ children: z27.array(z27.string()),
3409
+ message: z27.object({
3410
+ id: z27.string(),
3927
3411
  create_time: epochDate(),
3928
3412
  update_time: epochDate().nullable(),
3929
- author: z28.object({
3930
- role: z28.string(),
3931
- name: z28.string().nullable(),
3932
- metadata: z28.any()
3413
+ author: z27.object({
3414
+ role: z27.string(),
3415
+ name: z27.string().nullable(),
3416
+ metadata: z27.any()
3933
3417
  // Accept any metadata structure
3934
3418
  }).passthrough(),
3935
3419
  // Allow extra fields in author
3936
- content: z28.object({
3937
- content_type: z28.string(),
3938
- parts: z28.array(z28.any()).optional()
3420
+ content: z27.object({
3421
+ content_type: z27.string(),
3422
+ parts: z27.array(z27.any()).optional()
3939
3423
  // Accept any type in parts array (strings, objects, etc.)
3940
3424
  }).passthrough(),
3941
3425
  // Allow extra fields in content
3942
- status: z28.string(),
3943
- end_turn: z28.boolean().nullable(),
3944
- metadata: z28.any(),
3426
+ status: z27.string(),
3427
+ end_turn: z27.boolean().nullable(),
3428
+ metadata: z27.any(),
3945
3429
  // Accept any metadata structure since it varies widely
3946
- recipient: z28.string()
3430
+ recipient: z27.string()
3947
3431
  }).passthrough().nullable()
3948
3432
  }).passthrough()
3949
3433
  // Allow extra fields in mapping node
@@ -3951,38 +3435,38 @@ var openaiConversationSchema = z28.object({
3951
3435
  }).passthrough();
3952
3436
 
3953
3437
  // ../../b4m-core/packages/services/dist/src/importHistoryService/importClaudeHistory.js
3954
- import { z as z29 } from "zod";
3955
- var claudeChatMessageSchema = z29.object({
3956
- uuid: z29.string().uuid(),
3957
- text: z29.string(),
3958
- content: z29.array(
3959
- z29.object({
3960
- type: z29.string(),
3438
+ import { z as z28 } from "zod";
3439
+ var claudeChatMessageSchema = z28.object({
3440
+ uuid: z28.string().uuid(),
3441
+ text: z28.string(),
3442
+ content: z28.array(
3443
+ z28.object({
3444
+ type: z28.string(),
3961
3445
  // Accept any type: "text", "image", "tool_result", etc.
3962
- text: z29.string().optional()
3446
+ text: z28.string().optional()
3963
3447
  // Make text optional since tool_result may not have it
3964
3448
  }).passthrough()
3965
3449
  // Allow all other fields
3966
3450
  ),
3967
- sender: z29.enum(["human", "assistant"]),
3968
- created_at: z29.coerce.date(),
3969
- updated_at: z29.coerce.date(),
3970
- attachments: z29.array(z29.any()),
3451
+ sender: z28.enum(["human", "assistant"]),
3452
+ created_at: z28.coerce.date(),
3453
+ updated_at: z28.coerce.date(),
3454
+ attachments: z28.array(z28.any()),
3971
3455
  // Accept any attachment structure
3972
- files: z29.array(z29.any())
3456
+ files: z28.array(z28.any())
3973
3457
  // Accept any file structure
3974
3458
  }).passthrough();
3975
- var claudeConversationSchema = z29.object({
3976
- uuid: z29.string().uuid(),
3977
- name: z29.string(),
3978
- summary: z29.string().optional(),
3459
+ var claudeConversationSchema = z28.object({
3460
+ uuid: z28.string().uuid(),
3461
+ name: z28.string(),
3462
+ summary: z28.string().optional(),
3979
3463
  // Summary field is optional
3980
- created_at: z29.coerce.date(),
3981
- updated_at: z29.coerce.date(),
3982
- account: z29.object({
3983
- uuid: z29.string().uuid()
3464
+ created_at: z28.coerce.date(),
3465
+ updated_at: z28.coerce.date(),
3466
+ account: z28.object({
3467
+ uuid: z28.string().uuid()
3984
3468
  }),
3985
- chat_messages: z29.array(claudeChatMessageSchema)
3469
+ chat_messages: z28.array(claudeChatMessageSchema)
3986
3470
  }).passthrough();
3987
3471
 
3988
3472
  // ../../b4m-core/packages/services/dist/src/importHistoryService/index.js
@@ -3993,357 +3477,357 @@ var ImportSource;
3993
3477
  })(ImportSource || (ImportSource = {}));
3994
3478
 
3995
3479
  // ../../b4m-core/packages/services/dist/src/sessionService/create.js
3996
- import { z as z30 } from "zod";
3997
- var createSessionParametersSchema = z30.object({
3998
- name: z30.string(),
3999
- knowledgeIds: z30.array(z30.string()).optional(),
4000
- artifactIds: z30.array(z30.string()).optional(),
4001
- agentIds: z30.array(z30.string()).optional(),
4002
- tags: z30.array(z30.object({ name: z30.string(), strength: z30.number() })).optional(),
4003
- summary: z30.string().optional(),
4004
- summaryAt: z30.date().optional(),
4005
- clonedSourceId: z30.string().optional().nullable(),
4006
- forkedSourceId: z30.string().optional().nullable(),
4007
- projectId: z30.string().optional(),
4008
- lastUsedModel: z30.string().optional().nullable()
3480
+ import { z as z29 } from "zod";
3481
+ var createSessionParametersSchema = z29.object({
3482
+ name: z29.string(),
3483
+ knowledgeIds: z29.array(z29.string()).optional(),
3484
+ artifactIds: z29.array(z29.string()).optional(),
3485
+ agentIds: z29.array(z29.string()).optional(),
3486
+ tags: z29.array(z29.object({ name: z29.string(), strength: z29.number() })).optional(),
3487
+ summary: z29.string().optional(),
3488
+ summaryAt: z29.date().optional(),
3489
+ clonedSourceId: z29.string().optional().nullable(),
3490
+ forkedSourceId: z29.string().optional().nullable(),
3491
+ projectId: z29.string().optional(),
3492
+ lastUsedModel: z29.string().optional().nullable()
4009
3493
  });
4010
3494
 
4011
3495
  // ../../b4m-core/packages/services/dist/src/sessionService/delete.js
4012
- import { z as z31 } from "zod";
4013
- var deleteSessionSchema = z31.object({
4014
- id: z31.string()
3496
+ import { z as z30 } from "zod";
3497
+ var deleteSessionSchema = z30.object({
3498
+ id: z30.string()
4015
3499
  });
4016
3500
 
4017
3501
  // ../../b4m-core/packages/services/dist/src/sessionService/sumarize.js
4018
- import { z as z32 } from "zod";
4019
- var sumarizeSessionSchema = z32.object({
4020
- id: z32.string()
3502
+ import { z as z31 } from "zod";
3503
+ var sumarizeSessionSchema = z31.object({
3504
+ id: z31.string()
4021
3505
  });
4022
3506
 
4023
3507
  // ../../b4m-core/packages/services/dist/src/projectService/create.js
4024
- import { z as z33 } from "zod";
4025
- var createProjectSchema = z33.object({
4026
- name: z33.string().min(1),
4027
- description: z33.string().min(1),
4028
- sessionIds: z33.array(z33.string()).optional(),
4029
- fileIds: z33.array(z33.string()).optional()
3508
+ import { z as z32 } from "zod";
3509
+ var createProjectSchema = z32.object({
3510
+ name: z32.string().min(1),
3511
+ description: z32.string().min(1),
3512
+ sessionIds: z32.array(z32.string()).optional(),
3513
+ fileIds: z32.array(z32.string()).optional()
4030
3514
  });
4031
3515
 
4032
3516
  // ../../b4m-core/packages/services/dist/src/projectService/search.js
4033
- import { z as z34 } from "zod";
4034
- var searchProjectsSchema = z34.object({
4035
- search: z34.string().optional(),
4036
- filters: z34.object({
4037
- favorite: z34.coerce.boolean().optional(),
4038
- scope: z34.record(z34.any()).optional()
3517
+ import { z as z33 } from "zod";
3518
+ var searchProjectsSchema = z33.object({
3519
+ search: z33.string().optional(),
3520
+ filters: z33.object({
3521
+ favorite: z33.coerce.boolean().optional(),
3522
+ scope: z33.record(z33.any()).optional()
4039
3523
  }).optional(),
4040
- pagination: z34.object({
4041
- page: z34.coerce.number().optional(),
4042
- limit: z34.coerce.number().optional()
3524
+ pagination: z33.object({
3525
+ page: z33.coerce.number().optional(),
3526
+ limit: z33.coerce.number().optional()
4043
3527
  }).optional(),
4044
- orderBy: z34.object({
4045
- by: z34.enum(["createdAt", "updatedAt"]).optional(),
4046
- direction: z34.enum(["asc", "desc"]).optional()
3528
+ orderBy: z33.object({
3529
+ by: z33.enum(["createdAt", "updatedAt"]).optional(),
3530
+ direction: z33.enum(["asc", "desc"]).optional()
4047
3531
  }).optional()
4048
3532
  });
4049
3533
 
4050
3534
  // ../../b4m-core/packages/services/dist/src/projectService/addSessions.js
4051
- import { z as z45 } from "zod";
3535
+ import { z as z44 } from "zod";
4052
3536
  import uniq2 from "lodash/uniq.js";
4053
3537
 
4054
3538
  // ../../b4m-core/packages/services/dist/src/sharingService/accept.js
4055
- import { z as z35 } from "zod";
4056
- var acceptInviteSchema = z35.object({
4057
- id: z35.string()
3539
+ import { z as z34 } from "zod";
3540
+ var acceptInviteSchema = z34.object({
3541
+ id: z34.string()
4058
3542
  });
4059
3543
 
4060
3544
  // ../../b4m-core/packages/services/dist/src/sharingService/cancel.js
4061
- import { z as z36 } from "zod";
4062
- var cancelInviteSchema = z36.object({
4063
- id: z36.string(),
4064
- type: z36.nativeEnum(InviteType),
4065
- email: z36.string().email().optional()
3545
+ import { z as z35 } from "zod";
3546
+ var cancelInviteSchema = z35.object({
3547
+ id: z35.string(),
3548
+ type: z35.nativeEnum(InviteType),
3549
+ email: z35.string().email().optional()
4066
3550
  });
4067
3551
 
4068
3552
  // ../../b4m-core/packages/services/dist/src/sharingService/cancelOwnDocument.js
4069
- import { z as z37 } from "zod";
4070
- var cancelOwnDocumentInvitesSchema = z37.object({
4071
- documentId: z37.string(),
4072
- type: z37.nativeEnum(InviteType)
3553
+ import { z as z36 } from "zod";
3554
+ var cancelOwnDocumentInvitesSchema = z36.object({
3555
+ documentId: z36.string(),
3556
+ type: z36.nativeEnum(InviteType)
4073
3557
  });
4074
3558
 
4075
3559
  // ../../b4m-core/packages/services/dist/src/sharingService/create.js
4076
- import { z as z38 } from "zod";
3560
+ import { z as z37 } from "zod";
4077
3561
  var defaultExpiration = () => new Date((/* @__PURE__ */ new Date()).getFullYear() + 100, (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate());
4078
3562
  var DEFAULT_AVAILABLE = 1;
4079
- var createInviteSchema = z38.object({
4080
- id: z38.string(),
4081
- type: z38.nativeEnum(InviteType),
4082
- permissions: z38.array(z38.nativeEnum(Permission)),
4083
- recipients: z38.string().array().optional(),
4084
- description: z38.string().optional(),
4085
- expiresAt: z38.date().optional().default(defaultExpiration()),
4086
- available: z38.number().optional().default(DEFAULT_AVAILABLE)
3563
+ var createInviteSchema = z37.object({
3564
+ id: z37.string(),
3565
+ type: z37.nativeEnum(InviteType),
3566
+ permissions: z37.array(z37.nativeEnum(Permission)),
3567
+ recipients: z37.string().array().optional(),
3568
+ description: z37.string().optional(),
3569
+ expiresAt: z37.date().optional().default(defaultExpiration()),
3570
+ available: z37.number().optional().default(DEFAULT_AVAILABLE)
4087
3571
  });
4088
3572
 
4089
3573
  // ../../b4m-core/packages/services/dist/src/sharingService/get.js
4090
- import { z as z39 } from "zod";
4091
- var getInviteSchema = z39.object({
4092
- id: z39.string(),
4093
- withUsername: z39.boolean().optional()
3574
+ import { z as z38 } from "zod";
3575
+ var getInviteSchema = z38.object({
3576
+ id: z38.string(),
3577
+ withUsername: z38.boolean().optional()
4094
3578
  });
4095
3579
 
4096
3580
  // ../../b4m-core/packages/services/dist/src/sharingService/listByDocumentIdAndType.js
4097
- import { z as z40 } from "zod";
4098
- var listInviteByDocumentIdAndTypeSchema = z40.object({
4099
- documentId: z40.string(),
4100
- type: z40.nativeEnum(InviteType)
3581
+ import { z as z39 } from "zod";
3582
+ var listInviteByDocumentIdAndTypeSchema = z39.object({
3583
+ documentId: z39.string(),
3584
+ type: z39.nativeEnum(InviteType)
4101
3585
  });
4102
3586
 
4103
3587
  // ../../b4m-core/packages/services/dist/src/sharingService/listOwnPending.js
4104
- import { z as z41 } from "zod";
4105
- var listOwnPendingInvitesSchema = z41.object({
4106
- limit: z41.number().min(1).max(100).default(20),
4107
- page: z41.number().min(1).default(1)
3588
+ import { z as z40 } from "zod";
3589
+ var listOwnPendingInvitesSchema = z40.object({
3590
+ limit: z40.number().min(1).max(100).default(20),
3591
+ page: z40.number().min(1).default(1)
4108
3592
  });
4109
3593
 
4110
3594
  // ../../b4m-core/packages/services/dist/src/sharingService/refuse.js
4111
- import { z as z42 } from "zod";
4112
- var refuseInviteSchema = z42.object({
4113
- id: z42.string()
3595
+ import { z as z41 } from "zod";
3596
+ var refuseInviteSchema = z41.object({
3597
+ id: z41.string()
4114
3598
  });
4115
3599
 
4116
3600
  // ../../b4m-core/packages/services/dist/src/sharingService/revoke.js
4117
- import { z as z43 } from "zod";
4118
- var revokeSharingSchema = z43.object({
4119
- id: z43.string(),
4120
- type: z43.enum(["files", "sessions", "projects"]),
4121
- userId: z43.string(),
4122
- projectId: z43.string().optional()
3601
+ import { z as z42 } from "zod";
3602
+ var revokeSharingSchema = z42.object({
3603
+ id: z42.string(),
3604
+ type: z42.enum(["files", "sessions", "projects"]),
3605
+ userId: z42.string(),
3606
+ projectId: z42.string().optional()
4123
3607
  });
4124
3608
 
4125
3609
  // ../../b4m-core/packages/services/dist/src/projectService/addFiles.js
4126
- import { z as z44 } from "zod";
3610
+ import { z as z43 } from "zod";
4127
3611
  import uniq from "lodash/uniq.js";
4128
- var addFilesProjectSchema = z44.object({
4129
- projectId: z44.string().nonempty(),
4130
- fileIds: z44.array(z44.string().nonempty())
3612
+ var addFilesProjectSchema = z43.object({
3613
+ projectId: z43.string().nonempty(),
3614
+ fileIds: z43.array(z43.string().nonempty())
4131
3615
  });
4132
3616
 
4133
3617
  // ../../b4m-core/packages/services/dist/src/projectService/addSessions.js
4134
- var addSessionsProjectSchema = z45.object({
4135
- projectId: z45.string().nonempty(),
4136
- sessionIds: z45.array(z45.string().nonempty())
3618
+ var addSessionsProjectSchema = z44.object({
3619
+ projectId: z44.string().nonempty(),
3620
+ sessionIds: z44.array(z44.string().nonempty())
4137
3621
  });
4138
3622
 
4139
3623
  // ../../b4m-core/packages/services/dist/src/projectService/get.js
4140
- import { z as z46 } from "zod";
4141
- var getProjectSchema = z46.object({
4142
- id: z46.string()
3624
+ import { z as z45 } from "zod";
3625
+ var getProjectSchema = z45.object({
3626
+ id: z45.string()
4143
3627
  });
4144
3628
 
4145
3629
  // ../../b4m-core/packages/services/dist/src/projectService/update.js
4146
- import { z as z47 } from "zod";
4147
- var updateProjectSchema = z47.object({
4148
- id: z47.string(),
4149
- name: z47.string().optional(),
4150
- description: z47.string().optional()
3630
+ import { z as z46 } from "zod";
3631
+ var updateProjectSchema = z46.object({
3632
+ id: z46.string(),
3633
+ name: z46.string().optional(),
3634
+ description: z46.string().optional()
4151
3635
  });
4152
3636
 
4153
3637
  // ../../b4m-core/packages/services/dist/src/projectService/delete.js
4154
- import { z as z48 } from "zod";
4155
- var deleteProjectSchema = z48.object({
4156
- id: z48.string()
3638
+ import { z as z47 } from "zod";
3639
+ var deleteProjectSchema = z47.object({
3640
+ id: z47.string()
4157
3641
  });
4158
3642
 
4159
3643
  // ../../b4m-core/packages/services/dist/src/projectService/removeFiles.js
3644
+ import { z as z48 } from "zod";
3645
+ var removeProjectFilesSchema = z48.object({
3646
+ projectId: z48.string(),
3647
+ fileIds: z48.array(z48.string())
3648
+ });
3649
+
3650
+ // ../../b4m-core/packages/services/dist/src/projectService/removeSessions.js
4160
3651
  import { z as z49 } from "zod";
4161
- var removeProjectFilesSchema = z49.object({
3652
+ var removeProjectSessionsSchema = z49.object({
4162
3653
  projectId: z49.string(),
4163
- fileIds: z49.array(z49.string())
3654
+ sessionIds: z49.array(z49.string())
4164
3655
  });
4165
3656
 
4166
- // ../../b4m-core/packages/services/dist/src/projectService/removeSessions.js
3657
+ // ../../b4m-core/packages/services/dist/src/projectService/listSessions.js
4167
3658
  import { z as z50 } from "zod";
4168
- var removeProjectSessionsSchema = z50.object({
4169
- projectId: z50.string(),
4170
- sessionIds: z50.array(z50.string())
3659
+ var listProjectSessionsSchema = z50.object({
3660
+ projectId: z50.string()
4171
3661
  });
4172
3662
 
4173
- // ../../b4m-core/packages/services/dist/src/projectService/listSessions.js
3663
+ // ../../b4m-core/packages/services/dist/src/projectService/listFiles.js
4174
3664
  import { z as z51 } from "zod";
4175
- var listProjectSessionsSchema = z51.object({
3665
+ var listProjectFilesSchema = z51.object({
4176
3666
  projectId: z51.string()
4177
3667
  });
4178
3668
 
4179
- // ../../b4m-core/packages/services/dist/src/projectService/listFiles.js
3669
+ // ../../b4m-core/packages/services/dist/src/projectService/listInvites.js
4180
3670
  import { z as z52 } from "zod";
4181
- var listProjectFilesSchema = z52.object({
4182
- projectId: z52.string()
3671
+ var listProjectInvitesParamsSchema = z52.object({
3672
+ id: z52.string(),
3673
+ statuses: z52.string().optional().default(""),
3674
+ limit: z52.coerce.number().optional().default(10),
3675
+ page: z52.coerce.number().optional().default(1)
4183
3676
  });
4184
3677
 
4185
- // ../../b4m-core/packages/services/dist/src/projectService/listInvites.js
3678
+ // ../../b4m-core/packages/services/dist/src/projectService/addSystemPrompts.js
4186
3679
  import { z as z53 } from "zod";
4187
- var listProjectInvitesParamsSchema = z53.object({
4188
- id: z53.string(),
4189
- statuses: z53.string().optional().default(""),
4190
- limit: z53.coerce.number().optional().default(10),
4191
- page: z53.coerce.number().optional().default(1)
3680
+ var addSystemPromptsSchema = z53.object({
3681
+ projectId: z53.string(),
3682
+ fileIds: z53.array(z53.string())
4192
3683
  });
4193
3684
 
4194
- // ../../b4m-core/packages/services/dist/src/projectService/addSystemPrompts.js
3685
+ // ../../b4m-core/packages/services/dist/src/projectService/toggleSystemPrompt.js
4195
3686
  import { z as z54 } from "zod";
4196
- var addSystemPromptsSchema = z54.object({
3687
+ var toggleSystemPromptSchema = z54.object({
4197
3688
  projectId: z54.string(),
4198
- fileIds: z54.array(z54.string())
3689
+ fileId: z54.string()
4199
3690
  });
4200
3691
 
4201
- // ../../b4m-core/packages/services/dist/src/projectService/toggleSystemPrompt.js
3692
+ // ../../b4m-core/packages/services/dist/src/projectService/removeSystemPrompt.js
4202
3693
  import { z as z55 } from "zod";
4203
- var toggleSystemPromptSchema = z55.object({
3694
+ var removeSystemPromptSchema = z55.object({
4204
3695
  projectId: z55.string(),
4205
3696
  fileId: z55.string()
4206
3697
  });
4207
3698
 
4208
- // ../../b4m-core/packages/services/dist/src/projectService/removeSystemPrompt.js
4209
- import { z as z56 } from "zod";
4210
- var removeSystemPromptSchema = z56.object({
4211
- projectId: z56.string(),
4212
- fileId: z56.string()
4213
- });
4214
-
4215
3699
  // ../../b4m-core/packages/services/dist/src/projectService/addFavorite.js
4216
- import { z as z59 } from "zod";
3700
+ import { z as z58 } from "zod";
4217
3701
 
4218
3702
  // ../../b4m-core/packages/services/dist/src/favoriteService/create.js
4219
- import { z as z57 } from "zod";
4220
- var createFavoriteParametersSchema = z57.object({
4221
- documentId: z57.string(),
4222
- documentType: z57.nativeEnum(FavoriteDocumentType)
3703
+ import { z as z56 } from "zod";
3704
+ var createFavoriteParametersSchema = z56.object({
3705
+ documentId: z56.string(),
3706
+ documentType: z56.nativeEnum(FavoriteDocumentType)
4223
3707
  });
4224
3708
 
4225
3709
  // ../../b4m-core/packages/services/dist/src/favoriteService/delete.js
4226
- import { z as z58 } from "zod";
4227
- var deleteFavoriteParametersSchema = z58.object({
4228
- documentId: z58.string(),
4229
- documentType: z58.nativeEnum(FavoriteDocumentType)
3710
+ import { z as z57 } from "zod";
3711
+ var deleteFavoriteParametersSchema = z57.object({
3712
+ documentId: z57.string(),
3713
+ documentType: z57.nativeEnum(FavoriteDocumentType)
4230
3714
  });
4231
3715
 
4232
3716
  // ../../b4m-core/packages/services/dist/src/projectService/addFavorite.js
4233
- var addFavoriteParametersSchema = z59.object({
4234
- projectId: z59.string()
3717
+ var addFavoriteParametersSchema = z58.object({
3718
+ projectId: z58.string()
4235
3719
  });
4236
3720
 
4237
3721
  // ../../b4m-core/packages/services/dist/src/projectService/deleteFavorite.js
4238
- import { z as z60 } from "zod";
4239
- var deleteFavoriteParametersSchema2 = z60.object({
4240
- projectId: z60.string()
3722
+ import { z as z59 } from "zod";
3723
+ var deleteFavoriteParametersSchema2 = z59.object({
3724
+ projectId: z59.string()
4241
3725
  });
4242
3726
 
4243
3727
  // ../../b4m-core/packages/services/dist/src/projectService/removeNonExistentFiles.js
4244
- import { z as z61 } from "zod";
4245
- var removeNonExistentFilesSchema = z61.object({
4246
- projectId: z61.string()
3728
+ import { z as z60 } from "zod";
3729
+ var removeNonExistentFilesSchema = z60.object({
3730
+ projectId: z60.string()
4247
3731
  });
4248
3732
 
4249
3733
  // ../../b4m-core/packages/services/dist/src/projectService/leaveProject.js
4250
- import { z as z62 } from "zod";
4251
- var leaveProjectParamsSchema = z62.object({
4252
- id: z62.string(),
4253
- userIdToRemove: z62.string().optional()
3734
+ import { z as z61 } from "zod";
3735
+ var leaveProjectParamsSchema = z61.object({
3736
+ id: z61.string(),
3737
+ userIdToRemove: z61.string().optional()
4254
3738
  // Optional: if provided, this is a removal by owner
4255
3739
  });
4256
3740
 
4257
3741
  // ../../b4m-core/packages/services/dist/src/sessionService/update.js
4258
3742
  import uniq3 from "lodash/uniq.js";
4259
3743
  import isEqual from "lodash/isEqual.js";
4260
- import { z as z63 } from "zod";
4261
- var updateSessionParamtersSchema = z63.object({
4262
- id: z63.string(),
4263
- name: z63.string().optional(),
4264
- knowledgeIds: z63.array(z63.string()).optional(),
4265
- artifactIds: z63.array(z63.string()).optional(),
4266
- tags: z63.array(z63.object({ name: z63.string(), strength: z63.number() })).optional(),
4267
- lastUsedModel: z63.string().optional()
3744
+ import { z as z62 } from "zod";
3745
+ var updateSessionParamtersSchema = z62.object({
3746
+ id: z62.string(),
3747
+ name: z62.string().optional(),
3748
+ knowledgeIds: z62.array(z62.string()).optional(),
3749
+ artifactIds: z62.array(z62.string()).optional(),
3750
+ tags: z62.array(z62.object({ name: z62.string(), strength: z62.number() })).optional(),
3751
+ lastUsedModel: z62.string().optional()
4268
3752
  });
4269
3753
 
4270
3754
  // ../../b4m-core/packages/services/dist/src/sessionService/clone.js
4271
- import { z as z64 } from "zod";
4272
- var cloneSessionSchema = z64.object({
4273
- id: z64.string()
3755
+ import { z as z63 } from "zod";
3756
+ var cloneSessionSchema = z63.object({
3757
+ id: z63.string()
4274
3758
  });
4275
3759
 
4276
3760
  // ../../b4m-core/packages/services/dist/src/sessionService/fork.js
3761
+ import { z as z64 } from "zod";
3762
+ var forkSessionSchema = z64.object({
3763
+ sessionId: z64.string(),
3764
+ messageId: z64.string()
3765
+ });
3766
+
3767
+ // ../../b4m-core/packages/services/dist/src/sessionService/snip.js
4277
3768
  import { z as z65 } from "zod";
4278
- var forkSessionSchema = z65.object({
3769
+ var snipSessionSchema = z65.object({
4279
3770
  sessionId: z65.string(),
4280
3771
  messageId: z65.string()
4281
3772
  });
4282
3773
 
4283
- // ../../b4m-core/packages/services/dist/src/sessionService/snip.js
3774
+ // ../../b4m-core/packages/services/dist/src/sessionService/get.js
4284
3775
  import { z as z66 } from "zod";
4285
- var snipSessionSchema = z66.object({
4286
- sessionId: z66.string(),
4287
- messageId: z66.string()
3776
+ var getSessionSchema = z66.object({
3777
+ id: z66.string()
4288
3778
  });
4289
3779
 
4290
- // ../../b4m-core/packages/services/dist/src/sessionService/get.js
3780
+ // ../../b4m-core/packages/services/dist/src/sessionService/deleteMessage.js
4291
3781
  import { z as z67 } from "zod";
4292
- var getSessionSchema = z67.object({
4293
- id: z67.string()
3782
+ var deleteSessionMessageSchema = z67.object({
3783
+ sessionId: z67.string(),
3784
+ messageId: z67.string()
4294
3785
  });
4295
3786
 
4296
- // ../../b4m-core/packages/services/dist/src/sessionService/deleteMessage.js
3787
+ // ../../b4m-core/packages/services/dist/src/sessionService/addFavorite.js
4297
3788
  import { z as z68 } from "zod";
4298
- var deleteSessionMessageSchema = z68.object({
4299
- sessionId: z68.string(),
4300
- messageId: z68.string()
3789
+ var addFavoriteParametersSchema2 = z68.object({
3790
+ sessionId: z68.string()
4301
3791
  });
4302
3792
 
4303
- // ../../b4m-core/packages/services/dist/src/sessionService/addFavorite.js
3793
+ // ../../b4m-core/packages/services/dist/src/sessionService/deleteFavorite.js
4304
3794
  import { z as z69 } from "zod";
4305
- var addFavoriteParametersSchema2 = z69.object({
3795
+ var deleteFavoriteParametersSchema3 = z69.object({
4306
3796
  sessionId: z69.string()
4307
3797
  });
4308
3798
 
4309
- // ../../b4m-core/packages/services/dist/src/sessionService/deleteFavorite.js
4310
- import { z as z70 } from "zod";
4311
- var deleteFavoriteParametersSchema3 = z70.object({
4312
- sessionId: z70.string()
4313
- });
4314
-
4315
3799
  // ../../b4m-core/packages/services/dist/src/sessionService/autoName.js
4316
- import { z as z71 } from "zod";
4317
- var autoNameParameterSchema = z71.object({
4318
- sessionId: z71.string(),
3800
+ import { z as z70 } from "zod";
3801
+ var autoNameParameterSchema = z70.object({
3802
+ sessionId: z70.string(),
4319
3803
  /** The maximum number of words to include in the title */
4320
- maxWords: z71.number().optional()
3804
+ maxWords: z70.number().optional()
4321
3805
  });
4322
3806
 
4323
3807
  // ../../b4m-core/packages/services/dist/src/organizationService/search.js
4324
- import { z as z72 } from "zod";
4325
- var searchSchema2 = z72.object({
3808
+ import { z as z71 } from "zod";
3809
+ var searchSchema2 = z71.object({
4326
3810
  /**
4327
3811
  * Text search query (searches in name and description)
4328
3812
  */
4329
- query: z72.string().optional(),
3813
+ query: z71.string().optional(),
4330
3814
  /**
4331
3815
  * Filter by personal organizations
4332
3816
  */
4333
- filters: z72.object({
4334
- personal: z72.union([z72.enum(["true", "false"]).transform((val) => val === "true"), z72.boolean()]).optional(),
4335
- userId: z72.string().optional()
3817
+ filters: z71.object({
3818
+ personal: z71.union([z71.enum(["true", "false"]).transform((val) => val === "true"), z71.boolean()]).optional(),
3819
+ userId: z71.string().optional()
4336
3820
  }).default({}),
4337
- pagination: z72.object({
4338
- page: z72.coerce.number().int().positive().default(1),
4339
- limit: z72.coerce.number().int().positive().max(100).default(10)
3821
+ pagination: z71.object({
3822
+ page: z71.coerce.number().int().positive().default(1),
3823
+ limit: z71.coerce.number().int().positive().max(100).default(10)
4340
3824
  }).default({
4341
3825
  page: 1,
4342
3826
  limit: 10
4343
3827
  }),
4344
- orderBy: z72.object({
4345
- field: z72.enum(["name", "createdAt", "updatedAt"]).default("name"),
4346
- direction: z72.enum(["asc", "desc"]).default("asc")
3828
+ orderBy: z71.object({
3829
+ field: z71.enum(["name", "createdAt", "updatedAt"]).default("name"),
3830
+ direction: z71.enum(["asc", "desc"]).default("asc")
4347
3831
  }).default({
4348
3832
  field: "name",
4349
3833
  direction: "asc"
@@ -4351,355 +3835,355 @@ var searchSchema2 = z72.object({
4351
3835
  });
4352
3836
 
4353
3837
  // ../../b4m-core/packages/services/dist/src/organizationService/get.js
4354
- import { z as z73 } from "zod";
4355
- var getSchema = z73.object({
3838
+ import { z as z72 } from "zod";
3839
+ var getSchema = z72.object({
4356
3840
  /**
4357
3841
  * Organization ID
4358
3842
  */
4359
- id: z73.string().min(1)
3843
+ id: z72.string().min(1)
4360
3844
  });
4361
3845
 
4362
3846
  // ../../b4m-core/packages/services/dist/src/organizationService/addMember.js
4363
- import { z as z74 } from "zod";
4364
- var addMemberSchema = z74.object({
4365
- userId: z74.string().optional(),
4366
- email: z74.string().optional(),
4367
- organizationId: z74.string(),
4368
- force: z74.boolean().optional()
3847
+ import { z as z73 } from "zod";
3848
+ var addMemberSchema = z73.object({
3849
+ userId: z73.string().optional(),
3850
+ email: z73.string().optional(),
3851
+ organizationId: z73.string(),
3852
+ force: z73.boolean().optional()
4369
3853
  // If true, add the user to the organization even if it's at full capacity
4370
3854
  });
4371
3855
 
4372
3856
  // ../../b4m-core/packages/services/dist/src/organizationService/getUsers.js
4373
- import { z as z75 } from "zod";
4374
- var getUsersSchema = z75.object({
4375
- id: z75.string()
3857
+ import { z as z74 } from "zod";
3858
+ var getUsersSchema = z74.object({
3859
+ id: z74.string()
4376
3860
  });
4377
3861
 
4378
3862
  // ../../b4m-core/packages/services/dist/src/organizationService/create.js
4379
- import { z as z76 } from "zod";
4380
- var createSchema = z76.object({
4381
- name: z76.string(),
4382
- personal: z76.boolean().default(false),
4383
- seats: z76.number().default(1),
4384
- stripeCustomerId: z76.string().nullable(),
4385
- billingOwnerId: z76.string().optional(),
3863
+ import { z as z75 } from "zod";
3864
+ var createSchema = z75.object({
3865
+ name: z75.string(),
3866
+ personal: z75.boolean().default(false),
3867
+ seats: z75.number().default(1),
3868
+ stripeCustomerId: z75.string().nullable(),
3869
+ billingOwnerId: z75.string().optional(),
4386
3870
  // Optional billing owner (defaults to user if not provided)
4387
- managerId: z76.string().optional()
3871
+ managerId: z75.string().optional()
4388
3872
  // Optional team manager
4389
3873
  });
4390
3874
 
4391
3875
  // ../../b4m-core/packages/services/dist/src/organizationService/update.js
4392
- import { z as z77 } from "zod";
4393
- var updateSchema = z77.object({
4394
- id: z77.string(),
4395
- name: z77.string().optional(),
4396
- description: z77.string().optional(),
4397
- billingContact: z77.string().optional(),
4398
- currentCredits: z77.coerce.number().optional()
3876
+ import { z as z76 } from "zod";
3877
+ var updateSchema = z76.object({
3878
+ id: z76.string(),
3879
+ name: z76.string().optional(),
3880
+ description: z76.string().optional(),
3881
+ billingContact: z76.string().optional(),
3882
+ currentCredits: z76.coerce.number().optional()
4399
3883
  });
4400
3884
 
4401
3885
  // ../../b4m-core/packages/services/dist/src/organizationService/delete.js
4402
- import { z as z78 } from "zod";
4403
- var deleteSchema = z78.object({
3886
+ import { z as z77 } from "zod";
3887
+ var deleteSchema = z77.object({
4404
3888
  /**
4405
3889
  * Organization ID
4406
3890
  */
4407
- id: z78.string().min(1)
3891
+ id: z77.string().min(1)
4408
3892
  });
4409
3893
 
4410
3894
  // ../../b4m-core/packages/services/dist/src/organizationService/listPendingUsers.js
4411
- import { z as z79 } from "zod";
4412
- var listPendingUsersSchema = z79.object({
4413
- organizationId: z79.string()
3895
+ import { z as z78 } from "zod";
3896
+ var listPendingUsersSchema = z78.object({
3897
+ organizationId: z78.string()
4414
3898
  });
4415
3899
 
4416
3900
  // ../../b4m-core/packages/services/dist/src/organizationService/revokeAccess.js
4417
- import { z as z80 } from "zod";
4418
- var revokeAccessSchema = z80.object({
4419
- id: z80.string(),
4420
- userId: z80.string()
3901
+ import { z as z79 } from "zod";
3902
+ var revokeAccessSchema = z79.object({
3903
+ id: z79.string(),
3904
+ userId: z79.string()
4421
3905
  });
4422
3906
 
4423
3907
  // ../../b4m-core/packages/services/dist/src/organizationService/leave.js
4424
- import { z as z81 } from "zod";
4425
- var organizationLeaveSchema = z81.object({
4426
- id: z81.string()
3908
+ import { z as z80 } from "zod";
3909
+ var organizationLeaveSchema = z80.object({
3910
+ id: z80.string()
4427
3911
  });
4428
3912
 
4429
3913
  // ../../b4m-core/packages/services/dist/src/apiKeyService/create.js
4430
- import { z as z82 } from "zod";
4431
- var createApiKeySchema = z82.object({
4432
- apiKey: z82.string().min(6),
4433
- description: z82.string().optional().default(""),
4434
- isActive: z82.boolean().optional().default(true),
4435
- type: z82.nativeEnum(ApiKeyType),
4436
- expireDays: z82.number().min(1).max(365).default(90)
3914
+ import { z as z81 } from "zod";
3915
+ var createApiKeySchema = z81.object({
3916
+ apiKey: z81.string().min(6),
3917
+ description: z81.string().optional().default(""),
3918
+ isActive: z81.boolean().optional().default(true),
3919
+ type: z81.nativeEnum(ApiKeyType),
3920
+ expireDays: z81.number().min(1).max(365).default(90)
4437
3921
  // Default 90-day expiration
4438
3922
  });
4439
3923
 
4440
3924
  // ../../b4m-core/packages/services/dist/src/apiKeyService/set.js
4441
- import { z as z83 } from "zod";
4442
- var setApiKeySchema = z83.object({
4443
- id: z83.string(),
4444
- type: z83.nativeEnum(ApiKeyType)
3925
+ import { z as z82 } from "zod";
3926
+ var setApiKeySchema = z82.object({
3927
+ id: z82.string(),
3928
+ type: z82.nativeEnum(ApiKeyType)
4445
3929
  });
4446
3930
 
4447
3931
  // ../../b4m-core/packages/services/dist/src/apiKeyService/delete.js
4448
- import { z as z84 } from "zod";
4449
- var deleteApiKeySchema = z84.object({
4450
- id: z84.string()
3932
+ import { z as z83 } from "zod";
3933
+ var deleteApiKeySchema = z83.object({
3934
+ id: z83.string()
4451
3935
  });
4452
3936
 
4453
3937
  // ../../b4m-core/packages/services/dist/src/fabFileService/get.js
4454
- import { z as z85 } from "zod";
4455
- var getFabFileSchema = z85.object({
4456
- id: z85.string()
3938
+ import { z as z84 } from "zod";
3939
+ var getFabFileSchema = z84.object({
3940
+ id: z84.string()
4457
3941
  });
4458
3942
 
4459
3943
  // ../../b4m-core/packages/services/dist/src/fabFileService/list.js
4460
- import { z as z86 } from "zod";
4461
- var listFabFilesSchema = z86.object({
4462
- ids: z86.array(z86.string()).optional()
3944
+ import { z as z85 } from "zod";
3945
+ var listFabFilesSchema = z85.object({
3946
+ ids: z85.array(z85.string()).optional()
4463
3947
  });
4464
3948
 
4465
3949
  // ../../b4m-core/packages/services/dist/src/fabFileService/update.js
4466
3950
  import mime from "mime-types";
4467
- import { v4 as uuidv43 } from "uuid";
4468
- import { z as z87 } from "zod";
4469
- var updateFabFileSchema = z87.object({
4470
- id: z87.string(),
4471
- fileName: z87.string(),
4472
- mimeType: z87.string(),
4473
- fileContent: z87.string().optional(),
4474
- type: z87.nativeEnum(KnowledgeType),
4475
- system: z87.boolean().optional(),
4476
- systemPriority: z87.number().min(0).max(999).optional(),
4477
- sessionId: z87.string().optional(),
4478
- notes: z87.string().optional(),
4479
- primaryTag: z87.string().optional(),
4480
- tags: z87.array(z87.object({
4481
- name: z87.string(),
4482
- strength: z87.number()
3951
+ import { v4 as uuidv42 } from "uuid";
3952
+ import { z as z86 } from "zod";
3953
+ var updateFabFileSchema = z86.object({
3954
+ id: z86.string(),
3955
+ fileName: z86.string(),
3956
+ mimeType: z86.string(),
3957
+ fileContent: z86.string().optional(),
3958
+ type: z86.nativeEnum(KnowledgeType),
3959
+ system: z86.boolean().optional(),
3960
+ systemPriority: z86.number().min(0).max(999).optional(),
3961
+ sessionId: z86.string().optional(),
3962
+ notes: z86.string().optional(),
3963
+ primaryTag: z86.string().optional(),
3964
+ tags: z86.array(z86.object({
3965
+ name: z86.string(),
3966
+ strength: z86.number()
4483
3967
  })).optional(),
4484
- error: z87.string().nullable().optional()
3968
+ error: z86.string().nullable().optional()
4485
3969
  });
4486
3970
 
4487
3971
  // ../../b4m-core/packages/services/dist/src/fabFileService/delete.js
4488
- import { z as z88 } from "zod";
4489
- var deleteFabFileSchema = z88.object({
4490
- id: z88.string()
3972
+ import { z as z87 } from "zod";
3973
+ var deleteFabFileSchema = z87.object({
3974
+ id: z87.string()
4491
3975
  });
4492
3976
 
4493
3977
  // ../../b4m-core/packages/services/dist/src/fabFileService/chunk.js
4494
- import { z as z89 } from "zod";
4495
- var chunkFileSchema = z89.object({
4496
- fabFileId: z89.string(),
4497
- embeddingModel: z89.string()
3978
+ import { z as z88 } from "zod";
3979
+ var chunkFileSchema = z88.object({
3980
+ fabFileId: z88.string(),
3981
+ embeddingModel: z88.string()
4498
3982
  });
4499
3983
 
4500
3984
  // ../../b4m-core/packages/services/dist/src/fabFileService/vectorize.js
4501
- import { z as z90 } from "zod";
4502
- var vectorizeFabFileChunkSchema = z90.object({
4503
- fabFileId: z90.string(),
4504
- chunkId: z90.string()
3985
+ import { z as z89 } from "zod";
3986
+ var vectorizeFabFileChunkSchema = z89.object({
3987
+ fabFileId: z89.string(),
3988
+ chunkId: z89.string()
4505
3989
  });
4506
3990
 
4507
3991
  // ../../b4m-core/packages/services/dist/src/fabFileService/listBySession.js
4508
- import { z as z91 } from "zod";
4509
- var listFabFilesBySessionSchema = z91.object({
4510
- sessionId: z91.string()
3992
+ import { z as z90 } from "zod";
3993
+ var listFabFilesBySessionSchema = z90.object({
3994
+ sessionId: z90.string()
4511
3995
  });
4512
3996
 
4513
3997
  // ../../b4m-core/packages/services/dist/src/fabFileService/listByQuest.js
4514
- import { z as z92 } from "zod";
4515
- var listFabFilesByQuestSchema = z92.object({
4516
- questId: z92.string()
3998
+ import { z as z91 } from "zod";
3999
+ var listFabFilesByQuestSchema = z91.object({
4000
+ questId: z91.string()
4517
4001
  });
4518
4002
 
4519
4003
  // ../../b4m-core/packages/services/dist/src/fabFileService/createByUrl.js
4520
- import { z as z93 } from "zod";
4521
- var createFabFileByUrlSchema = z93.object({
4522
- url: z93.string().regex(/^(?!https?:\/\/(drive|docs)\.google\.com\/(?:file\/d\/|open\?id=|uc\?id=|document\/d\/|spreadsheets\/d\/|presentation\/d\/|forms\/d\/|drive\/folders\/)([a-zA-Z0-9_-]{10,})).+/)
4004
+ import { z as z92 } from "zod";
4005
+ var createFabFileByUrlSchema = z92.object({
4006
+ url: z92.string().regex(/^(?!https?:\/\/(drive|docs)\.google\.com\/(?:file\/d\/|open\?id=|uc\?id=|document\/d\/|spreadsheets\/d\/|presentation\/d\/|forms\/d\/|drive\/folders\/)([a-zA-Z0-9_-]{10,})).+/)
4523
4007
  });
4524
4008
 
4525
4009
  // ../../b4m-core/packages/services/dist/src/fabFileService/search.js
4526
- import { z as z94 } from "zod";
4527
- var searchFabFilesSchema = z94.object({
4528
- search: z94.string().optional(),
4529
- filters: z94.object({
4530
- tags: z94.array(z94.string()).optional(),
4531
- type: z94.enum(["text", "pdf", "url", "image", "excel", "word", "json", "csv", "markdown", "code"]).optional(),
4532
- shared: z94.coerce.boolean().optional(),
4010
+ import { z as z93 } from "zod";
4011
+ var searchFabFilesSchema = z93.object({
4012
+ search: z93.string().optional(),
4013
+ filters: z93.object({
4014
+ tags: z93.array(z93.string()).optional(),
4015
+ type: z93.enum(["text", "pdf", "url", "image", "excel", "word", "json", "csv", "markdown", "code"]).optional(),
4016
+ shared: z93.coerce.boolean().optional(),
4533
4017
  // Indicates if the user is searching for shared files
4534
- curated: z94.coerce.boolean().optional(),
4018
+ curated: z93.coerce.boolean().optional(),
4535
4019
  // Indicates if the user is searching for curated notebook files
4536
- projectId: z94.string().optional(),
4537
- ids: z94.array(z94.string()).optional()
4020
+ projectId: z93.string().optional(),
4021
+ ids: z93.array(z93.string()).optional()
4538
4022
  // Add support for filtering by IDs
4539
4023
  }).optional(),
4540
- pagination: z94.object({
4541
- page: z94.coerce.number(),
4542
- limit: z94.coerce.number()
4024
+ pagination: z93.object({
4025
+ page: z93.coerce.number(),
4026
+ limit: z93.coerce.number()
4543
4027
  }).optional(),
4544
- order: z94.object({
4545
- by: z94.enum(["createdAt", "fileName", "fileSize"]),
4546
- direction: z94.enum(["asc", "desc"])
4028
+ order: z93.object({
4029
+ by: z93.enum(["createdAt", "fileName", "fileSize"]),
4030
+ direction: z93.enum(["asc", "desc"])
4547
4031
  }).optional(),
4548
- options: z94.object({
4549
- includeShared: z94.coerce.boolean().optional()
4032
+ options: z93.object({
4033
+ includeShared: z93.coerce.boolean().optional()
4550
4034
  }).optional()
4551
4035
  });
4552
4036
 
4553
4037
  // ../../b4m-core/packages/services/dist/src/fabFileService/addFavorite.js
4554
- import { z as z95 } from "zod";
4555
- var addFavoriteParametersSchema3 = z95.object({
4556
- fileId: z95.string()
4038
+ import { z as z94 } from "zod";
4039
+ var addFavoriteParametersSchema3 = z94.object({
4040
+ fileId: z94.string()
4557
4041
  });
4558
4042
 
4559
4043
  // ../../b4m-core/packages/services/dist/src/fabFileService/deleteFavorite.js
4560
- import { z as z96 } from "zod";
4561
- var deleteFavoriteParametersSchema4 = z96.object({
4562
- fileId: z96.string()
4044
+ import { z as z95 } from "zod";
4045
+ var deleteFavoriteParametersSchema4 = z95.object({
4046
+ fileId: z95.string()
4563
4047
  });
4564
4048
 
4565
4049
  // ../../b4m-core/packages/services/dist/src/fabFileService/toggleTags.js
4566
- import { z as z97 } from "zod";
4567
- var fabFileToggleTagsSchema = z97.object({
4568
- ids: z97.array(z97.string()),
4569
- tags: z97.array(z97.string())
4050
+ import { z as z96 } from "zod";
4051
+ var fabFileToggleTagsSchema = z96.object({
4052
+ ids: z96.array(z96.string()),
4053
+ tags: z96.array(z96.string())
4570
4054
  });
4571
4055
 
4572
4056
  // ../../b4m-core/packages/services/dist/src/fabFileService/edit.js
4573
- import { z as z98 } from "zod";
4057
+ import { z as z97 } from "zod";
4574
4058
  import { diffLines } from "diff";
4575
- var editFabFileSchema = z98.object({
4576
- id: z98.string(),
4577
- instruction: z98.string(),
4578
- selection: z98.object({
4579
- start: z98.number(),
4580
- end: z98.number()
4059
+ var editFabFileSchema = z97.object({
4060
+ id: z97.string(),
4061
+ instruction: z97.string(),
4062
+ selection: z97.object({
4063
+ start: z97.number(),
4064
+ end: z97.number()
4581
4065
  }).optional(),
4582
- preserveFormatting: z98.boolean().optional().default(true),
4583
- applyImmediately: z98.boolean().optional().default(false)
4066
+ preserveFormatting: z97.boolean().optional().default(true),
4067
+ applyImmediately: z97.boolean().optional().default(false)
4584
4068
  });
4585
4069
 
4586
4070
  // ../../b4m-core/packages/services/dist/src/fabFileService/applyEdit.js
4587
4071
  import mime2 from "mime-types";
4588
- import { v4 as uuidv44 } from "uuid";
4589
- import { z as z99 } from "zod";
4590
- var applyEditSchema = z99.object({
4591
- id: z99.string(),
4592
- modifiedContent: z99.string(),
4593
- createBackup: z99.boolean().optional().default(true)
4072
+ import { v4 as uuidv43 } from "uuid";
4073
+ import { z as z98 } from "zod";
4074
+ var applyEditSchema = z98.object({
4075
+ id: z98.string(),
4076
+ modifiedContent: z98.string(),
4077
+ createBackup: z98.boolean().optional().default(true)
4594
4078
  });
4595
4079
 
4596
4080
  // ../../b4m-core/packages/services/dist/src/friendshipService/respondToFriendRequest.js
4597
- import { z as z100 } from "zod";
4598
- var respondToFriendRequestSchema = z100.object({
4599
- id: z100.string(),
4081
+ import { z as z99 } from "zod";
4082
+ var respondToFriendRequestSchema = z99.object({
4083
+ id: z99.string(),
4600
4084
  /** The user ID of the recipient of the friend request */
4601
- userId: z100.string(),
4602
- accept: z100.boolean()
4085
+ userId: z99.string(),
4086
+ accept: z99.boolean()
4603
4087
  });
4604
4088
 
4605
4089
  // ../../b4m-core/packages/services/dist/src/friendshipService/unfriend.js
4606
- import { z as z101 } from "zod";
4607
- var unfriendSchema = z101.object({
4608
- friendshipId: z101.string(),
4090
+ import { z as z100 } from "zod";
4091
+ var unfriendSchema = z100.object({
4092
+ friendshipId: z100.string(),
4609
4093
  /** The user ID of the user who wants to unfriend the other user */
4610
- userId: z101.string()
4094
+ userId: z100.string()
4611
4095
  });
4612
4096
 
4613
4097
  // ../../b4m-core/packages/services/dist/src/friendshipService/list.js
4614
- import { z as z102 } from "zod";
4615
- var listFriendsSchema = z102.object({
4616
- userId: z102.string()
4098
+ import { z as z101 } from "zod";
4099
+ var listFriendsSchema = z101.object({
4100
+ userId: z101.string()
4617
4101
  });
4618
- var listPendingFriendRequestsSchema = z102.object({
4619
- userId: z102.string()
4102
+ var listPendingFriendRequestsSchema = z101.object({
4103
+ userId: z101.string()
4620
4104
  });
4621
4105
 
4622
4106
  // ../../b4m-core/packages/services/dist/src/adminService/loginAs.js
4623
- import { z as z103 } from "zod";
4624
- var loginAsSchema = z103.object({
4625
- targetUserId: z103.string()
4107
+ import { z as z102 } from "zod";
4108
+ var loginAsSchema = z102.object({
4109
+ targetUserId: z102.string()
4626
4110
  });
4627
4111
 
4628
4112
  // ../../b4m-core/packages/services/dist/src/cacheService/get.js
4629
- import { z as z104 } from "zod";
4630
- var getParamsSchema = z104.object({
4631
- key: z104.string()
4113
+ import { z as z103 } from "zod";
4114
+ var getParamsSchema = z103.object({
4115
+ key: z103.string()
4632
4116
  });
4633
4117
 
4634
4118
  // ../../b4m-core/packages/services/dist/src/cacheService/set.js
4635
- import { z as z105 } from "zod";
4636
- var setParamsSchema = z105.object({
4637
- key: z105.string(),
4638
- value: z105.any(),
4119
+ import { z as z104 } from "zod";
4120
+ var setParamsSchema = z104.object({
4121
+ key: z104.string(),
4122
+ value: z104.any(),
4639
4123
  /**
4640
4124
  * Time to live in milliseconds
4641
4125
  */
4642
- ttl: z105.number(),
4643
- recache: z105.boolean().optional()
4126
+ ttl: z104.number(),
4127
+ recache: z104.boolean().optional()
4644
4128
  });
4645
4129
 
4646
4130
  // ../../b4m-core/packages/services/dist/src/cacheService/ttl.js
4647
- import { z as z106 } from "zod";
4648
- var ttlParamsSchema = z106.object({
4649
- key: z106.string()
4131
+ import { z as z105 } from "zod";
4132
+ var ttlParamsSchema = z105.object({
4133
+ key: z105.string()
4650
4134
  });
4651
4135
 
4652
4136
  // ../../b4m-core/packages/services/dist/src/cacheService/weeklyReports.js
4653
- import { z as z107 } from "zod";
4137
+ import { z as z106 } from "zod";
4654
4138
  import dayjs3 from "dayjs";
4655
- var weeklyReportSchema = z107.object({
4656
- startDate: z107.string(),
4657
- endDate: z107.string(),
4658
- report: z107.string(),
4659
- aiInsights: z107.string().nullable()
4139
+ var weeklyReportSchema = z106.object({
4140
+ startDate: z106.string(),
4141
+ endDate: z106.string(),
4142
+ report: z106.string(),
4143
+ aiInsights: z106.string().nullable()
4660
4144
  });
4661
4145
 
4662
4146
  // ../../b4m-core/packages/services/dist/src/embeddingCacheService/generateCacheKey.js
4663
4147
  import crypto2 from "crypto";
4664
4148
 
4665
4149
  // ../../b4m-core/packages/services/dist/src/researchAgentService/create.js
4150
+ import { z as z107 } from "zod";
4151
+ var researchAgentCreateSchema = z107.object({
4152
+ name: z107.string().min(1),
4153
+ description: z107.string().min(1)
4154
+ });
4155
+
4156
+ // ../../b4m-core/packages/services/dist/src/researchAgentService/update.js
4666
4157
  import { z as z108 } from "zod";
4667
- var researchAgentCreateSchema = z108.object({
4158
+ var researchAgentUpdateSchema = z108.object({
4159
+ id: z108.string(),
4668
4160
  name: z108.string().min(1),
4669
4161
  description: z108.string().min(1)
4670
4162
  });
4671
4163
 
4672
- // ../../b4m-core/packages/services/dist/src/researchAgentService/update.js
4164
+ // ../../b4m-core/packages/services/dist/src/researchAgentService/remove.js
4673
4165
  import { z as z109 } from "zod";
4674
- var researchAgentUpdateSchema = z109.object({
4675
- id: z109.string(),
4676
- name: z109.string().min(1),
4677
- description: z109.string().min(1)
4166
+ var researchAgentRemoveSchema = z109.object({
4167
+ id: z109.string()
4678
4168
  });
4679
4169
 
4680
- // ../../b4m-core/packages/services/dist/src/researchAgentService/remove.js
4170
+ // ../../b4m-core/packages/services/dist/src/researchAgentService/get.js
4681
4171
  import { z as z110 } from "zod";
4682
- var researchAgentRemoveSchema = z110.object({
4172
+ var researchAgentGetSchema = z110.object({
4683
4173
  id: z110.string()
4684
4174
  });
4685
4175
 
4686
- // ../../b4m-core/packages/services/dist/src/researchAgentService/get.js
4687
- import { z as z111 } from "zod";
4688
- var researchAgentGetSchema = z111.object({
4689
- id: z111.string()
4690
- });
4691
-
4692
4176
  // ../../b4m-core/packages/services/dist/src/researchAgentService/listFiles.js
4693
- import { z as z112 } from "zod";
4694
- var researchAgentListFilesSchema = z112.object({
4177
+ import { z as z111 } from "zod";
4178
+ var researchAgentListFilesSchema = z111.object({
4695
4179
  /**
4696
4180
  * The ID of the research agent
4697
4181
  */
4698
- id: z112.string()
4182
+ id: z111.string()
4699
4183
  });
4700
4184
 
4701
4185
  // ../../b4m-core/packages/services/dist/src/researchTaskService/process.js
4702
- import { z as z113 } from "zod";
4186
+ import { z as z112 } from "zod";
4703
4187
 
4704
4188
  // ../../b4m-core/packages/services/dist/src/lib/turndown.js
4705
4189
  import turndown from "turndown";
@@ -5090,316 +4574,316 @@ var deepResearchTool = {
5090
4574
  };
5091
4575
 
5092
4576
  // ../../b4m-core/packages/services/dist/src/researchTaskService/process.js
5093
- var ResearchTaskProcessSchema = z113.object({
5094
- id: z113.string()
4577
+ var ResearchTaskProcessSchema = z112.object({
4578
+ id: z112.string()
5095
4579
  });
5096
4580
 
5097
4581
  // ../../b4m-core/packages/services/dist/src/researchTaskService/create.js
5098
- import { z as z114 } from "zod";
5099
- var researchTaskCreateSchema = z114.object({
5100
- researchAgentId: z114.string(),
5101
- title: z114.string().max(100),
5102
- description: z114.string().max(500),
5103
- prompt: z114.string().max(500).optional(),
5104
- type: z114.nativeEnum(ResearchTaskType),
5105
- executionType: z114.nativeEnum(ResearchTaskExecutionType).default(ResearchTaskExecutionType.ON_DEMAND),
5106
- fileTagId: z114.string().optional(),
5107
- autoGeneratedTag: z114.object({
5108
- name: z114.string(),
5109
- icon: z114.string(),
5110
- color: z114.string()
4582
+ import { z as z113 } from "zod";
4583
+ var researchTaskCreateSchema = z113.object({
4584
+ researchAgentId: z113.string(),
4585
+ title: z113.string().max(100),
4586
+ description: z113.string().max(500),
4587
+ prompt: z113.string().max(500).optional(),
4588
+ type: z113.nativeEnum(ResearchTaskType),
4589
+ executionType: z113.nativeEnum(ResearchTaskExecutionType).default(ResearchTaskExecutionType.ON_DEMAND),
4590
+ fileTagId: z113.string().optional(),
4591
+ autoGeneratedTag: z113.object({
4592
+ name: z113.string(),
4593
+ icon: z113.string(),
4594
+ color: z113.string()
5111
4595
  }).optional()
5112
4596
  });
5113
4597
  var researchTaskScrapeCreateSchema = researchTaskCreateSchema.extend({
5114
- urls: z114.array(z114.string().url()).min(1),
5115
- canDiscoverLinks: z114.boolean()
4598
+ urls: z113.array(z113.string().url()).min(1),
4599
+ canDiscoverLinks: z113.boolean()
5116
4600
  });
5117
4601
  var researchTaskPeriodicCreateSchema = researchTaskCreateSchema.extend({
5118
- executionPeriodicStartAt: z114.coerce.date(),
5119
- executionPeriodicEndAt: z114.coerce.date(),
5120
- executionPeriodicFrequency: z114.nativeEnum(ResearchTaskPeriodicFrequencyType)
4602
+ executionPeriodicStartAt: z113.coerce.date(),
4603
+ executionPeriodicEndAt: z113.coerce.date(),
4604
+ executionPeriodicFrequency: z113.nativeEnum(ResearchTaskPeriodicFrequencyType)
5121
4605
  });
5122
4606
  var researchTaskScheduledCreateSchema = researchTaskCreateSchema.extend({
5123
- executionScheduledAt: z114.coerce.date()
4607
+ executionScheduledAt: z113.coerce.date()
5124
4608
  });
5125
4609
  var researchTaskDeepResearchCreateSchema = researchTaskCreateSchema.extend({
5126
- maxDepth: z114.number().min(1).max(10).optional()
4610
+ maxDepth: z113.number().min(1).max(10).optional()
5127
4611
  });
5128
4612
 
5129
4613
  // ../../b4m-core/packages/services/dist/src/researchTaskService/search.js
5130
- import { z as z115 } from "zod";
5131
- var searchResearchTasksSchema = z115.object({
5132
- search: z115.string().optional(),
4614
+ import { z as z114 } from "zod";
4615
+ var searchResearchTasksSchema = z114.object({
4616
+ search: z114.string().optional(),
5133
4617
  // ADD FILTERS SCHEMA HERE
5134
4618
  // filters: z
5135
4619
  // .object({
5136
4620
  // userId: z.string().optional(),
5137
4621
  // })
5138
4622
  // .optional(),
5139
- pagination: z115.object({
5140
- page: z115.coerce.number().optional(),
5141
- limit: z115.coerce.number().optional()
4623
+ pagination: z114.object({
4624
+ page: z114.coerce.number().optional(),
4625
+ limit: z114.coerce.number().optional()
5142
4626
  }).optional(),
5143
- orderBy: z115.object({
5144
- by: z115.enum(["createdAt", "updatedAt"]).optional(),
5145
- direction: z115.enum(["asc", "desc"]).optional()
4627
+ orderBy: z114.object({
4628
+ by: z114.enum(["createdAt", "updatedAt"]).optional(),
4629
+ direction: z114.enum(["asc", "desc"]).optional()
5146
4630
  }).optional()
5147
4631
  });
5148
4632
 
5149
4633
  // ../../b4m-core/packages/services/dist/src/researchTaskService/get.js
5150
- import { z as z116 } from "zod";
5151
- var getResearchTaskSchema = z116.object({
5152
- id: z116.string().min(1)
4634
+ import { z as z115 } from "zod";
4635
+ var getResearchTaskSchema = z115.object({
4636
+ id: z115.string().min(1)
5153
4637
  });
5154
4638
 
5155
4639
  // ../../b4m-core/packages/services/dist/src/researchTaskService/update.js
5156
- import { z as z117 } from "zod";
5157
- var updateResearchTaskSchema = z117.object({
5158
- id: z117.string(),
5159
- title: z117.string(),
5160
- description: z117.string(),
5161
- type: z117.nativeEnum(ResearchTaskType)
4640
+ import { z as z116 } from "zod";
4641
+ var updateResearchTaskSchema = z116.object({
4642
+ id: z116.string(),
4643
+ title: z116.string(),
4644
+ description: z116.string(),
4645
+ type: z116.nativeEnum(ResearchTaskType)
5162
4646
  });
5163
4647
  var researchTaskScrapeUpdateSchema = updateResearchTaskSchema.extend({
5164
- urls: z117.array(z117.string().url()).min(1),
5165
- canDiscoverLinks: z117.boolean()
4648
+ urls: z116.array(z116.string().url()).min(1),
4649
+ canDiscoverLinks: z116.boolean()
5166
4650
  });
5167
4651
 
5168
4652
  // ../../b4m-core/packages/services/dist/src/researchTaskService/listByAgentId.js
5169
- import { z as z118 } from "zod";
5170
- var listByAgentIdSchema = z118.object({
5171
- researchAgentId: z118.string()
4653
+ import { z as z117 } from "zod";
4654
+ var listByAgentIdSchema = z117.object({
4655
+ researchAgentId: z117.string()
5172
4656
  });
5173
4657
 
5174
4658
  // ../../b4m-core/packages/services/dist/src/researchTaskService/remove.js
5175
- import { z as z119 } from "zod";
5176
- var researchTaskRemoveSchema = z119.object({
5177
- id: z119.string().min(1)
4659
+ import { z as z118 } from "zod";
4660
+ var researchTaskRemoveSchema = z118.object({
4661
+ id: z118.string().min(1)
5178
4662
  });
5179
4663
 
5180
4664
  // ../../b4m-core/packages/services/dist/src/researchTaskService/retry.js
5181
- import { z as z120 } from "zod";
5182
- var researchTaskRetrySchema = z120.object({
5183
- id: z120.string(),
5184
- userId: z120.string()
4665
+ import { z as z119 } from "zod";
4666
+ var researchTaskRetrySchema = z119.object({
4667
+ id: z119.string(),
4668
+ userId: z119.string()
5185
4669
  });
5186
4670
 
5187
4671
  // ../../b4m-core/packages/services/dist/src/researchTaskService/processDiscoveredLinks.js
5188
4672
  import axios4 from "axios";
5189
- import { z as z121 } from "zod";
4673
+ import { z as z120 } from "zod";
5190
4674
  import plimit from "p-limit";
5191
4675
  import pLimit2 from "p-limit";
5192
- var researchTaskProcessDiscoveredLinksSchema = z121.object({
5193
- id: z121.string()
4676
+ var researchTaskProcessDiscoveredLinksSchema = z120.object({
4677
+ id: z120.string()
5194
4678
  });
5195
4679
 
5196
4680
  // ../../b4m-core/packages/services/dist/src/researchTaskService/downloadRelevantLinks.js
5197
- import { z as z122 } from "zod";
4681
+ import { z as z121 } from "zod";
5198
4682
  import plimit2 from "p-limit";
5199
4683
  import axios5 from "axios";
5200
4684
  import { fileTypeFromBuffer } from "file-type";
5201
- var researchTaskDownloadRelevantLinksSchema = z122.object({
5202
- id: z122.string()
4685
+ var researchTaskDownloadRelevantLinksSchema = z121.object({
4686
+ id: z121.string()
5203
4687
  });
5204
4688
 
5205
4689
  // ../../b4m-core/packages/services/dist/src/researchData/remove.js
5206
- import { z as z123 } from "zod";
5207
- var researchDataRemoveSchema = z123.object({
5208
- id: z123.string(),
5209
- researchAgentId: z123.string()
4690
+ import { z as z122 } from "zod";
4691
+ var researchDataRemoveSchema = z122.object({
4692
+ id: z122.string(),
4693
+ researchAgentId: z122.string()
5210
4694
  });
5211
4695
 
5212
4696
  // ../../b4m-core/packages/services/dist/src/taskSchedulerService/create.js
5213
- import { z as z124 } from "zod";
5214
- var researchTaskPayload = z124.object({
5215
- id: z124.string(),
5216
- userId: z124.string()
4697
+ import { z as z123 } from "zod";
4698
+ var researchTaskPayload = z123.object({
4699
+ id: z123.string(),
4700
+ userId: z123.string()
5217
4701
  });
5218
- var customTaskPayload = z124.object({
5219
- test: z124.string()
4702
+ var customTaskPayload = z123.object({
4703
+ test: z123.string()
5220
4704
  });
5221
- var taskSchedulerCreate = z124.discriminatedUnion("handler", [
5222
- z124.object({
5223
- handler: z124.literal(TaskScheduleHandler.RESEARCH_TASK_PROCESS),
4705
+ var taskSchedulerCreate = z123.discriminatedUnion("handler", [
4706
+ z123.object({
4707
+ handler: z123.literal(TaskScheduleHandler.RESEARCH_TASK_PROCESS),
5224
4708
  payload: researchTaskPayload,
5225
- processDate: z124.date()
4709
+ processDate: z123.date()
5226
4710
  }),
5227
- z124.object({
5228
- handler: z124.literal(TaskScheduleHandler.CUSTOM_TASK_PROCESS),
4711
+ z123.object({
4712
+ handler: z123.literal(TaskScheduleHandler.CUSTOM_TASK_PROCESS),
5229
4713
  payload: customTaskPayload,
5230
- processDate: z124.date()
4714
+ processDate: z123.date()
5231
4715
  })
5232
4716
  ]);
5233
4717
 
5234
4718
  // ../../b4m-core/packages/services/dist/src/tagService/createFileTag.js
4719
+ import { z as z124 } from "zod";
4720
+ var tagCreateFileTagSchema = z124.object({
4721
+ name: z124.string(),
4722
+ icon: z124.string().optional(),
4723
+ color: z124.string().optional(),
4724
+ description: z124.string().optional()
4725
+ });
4726
+
4727
+ // ../../b4m-core/packages/services/dist/src/tagService/create.js
5235
4728
  import { z as z125 } from "zod";
5236
- var tagCreateFileTagSchema = z125.object({
4729
+ var tagCreateSchema = z125.object({
5237
4730
  name: z125.string(),
5238
4731
  icon: z125.string().optional(),
4732
+ description: z125.string().optional(),
5239
4733
  color: z125.string().optional(),
5240
- description: z125.string().optional()
4734
+ type: z125.nativeEnum(TagType)
5241
4735
  });
5242
4736
 
5243
- // ../../b4m-core/packages/services/dist/src/tagService/create.js
4737
+ // ../../b4m-core/packages/services/dist/src/tagService/update.js
5244
4738
  import { z as z126 } from "zod";
5245
- var tagCreateSchema = z126.object({
5246
- name: z126.string(),
4739
+ var tagUpdateSchema = z126.object({
4740
+ id: z126.string(),
4741
+ name: z126.string().optional(),
5247
4742
  icon: z126.string().optional(),
5248
4743
  description: z126.string().optional(),
5249
- color: z126.string().optional(),
5250
- type: z126.nativeEnum(TagType)
5251
- });
5252
-
5253
- // ../../b4m-core/packages/services/dist/src/tagService/update.js
5254
- import { z as z127 } from "zod";
5255
- var tagUpdateSchema = z127.object({
5256
- id: z127.string(),
5257
- name: z127.string().optional(),
5258
- icon: z127.string().optional(),
5259
- description: z127.string().optional(),
5260
- color: z127.string().optional()
4744
+ color: z126.string().optional()
5261
4745
  });
5262
4746
 
5263
4747
  // ../../b4m-core/packages/services/dist/src/tagService/remove.js
5264
- import { z as z128 } from "zod";
5265
- var tagRemoveSchema = z128.object({
5266
- id: z128.string()
4748
+ import { z as z127 } from "zod";
4749
+ var tagRemoveSchema = z127.object({
4750
+ id: z127.string()
5267
4751
  });
5268
4752
 
5269
4753
  // ../../b4m-core/packages/services/dist/src/artifactService/create.js
5270
- import { z as z129 } from "zod";
5271
- var createArtifactSchema = z129.object({
5272
- id: z129.string().optional(),
4754
+ import { z as z128 } from "zod";
4755
+ var createArtifactSchema = z128.object({
4756
+ id: z128.string().optional(),
5273
4757
  // Allow custom ID for AI-generated artifacts
5274
- type: z129.enum(["mermaid", "recharts", "python", "react", "html", "svg", "code", "quest", "file", "questmaster"]),
5275
- title: z129.string().min(1).max(255),
5276
- description: z129.string().max(1e3).optional(),
5277
- content: z129.string().min(1),
5278
- projectId: z129.string().optional(),
5279
- organizationId: z129.string().optional(),
5280
- visibility: z129.enum(["private", "project", "organization", "public"]).default("private"),
5281
- tags: z129.array(z129.string().max(50)).max(20).default([]),
5282
- versionTag: z129.string().max(100).optional(),
5283
- sourceQuestId: z129.string().optional(),
5284
- sessionId: z129.string().optional(),
5285
- parentArtifactId: z129.string().optional(),
5286
- permissions: z129.object({
5287
- canRead: z129.array(z129.string()).default([]),
5288
- canWrite: z129.array(z129.string()).default([]),
5289
- canDelete: z129.array(z129.string()).default([]),
5290
- isPublic: z129.boolean().default(false),
5291
- inheritFromProject: z129.boolean().default(true)
4758
+ type: z128.enum(["mermaid", "recharts", "python", "react", "html", "svg", "code", "quest", "file", "questmaster"]),
4759
+ title: z128.string().min(1).max(255),
4760
+ description: z128.string().max(1e3).optional(),
4761
+ content: z128.string().min(1),
4762
+ projectId: z128.string().optional(),
4763
+ organizationId: z128.string().optional(),
4764
+ visibility: z128.enum(["private", "project", "organization", "public"]).default("private"),
4765
+ tags: z128.array(z128.string().max(50)).max(20).default([]),
4766
+ versionTag: z128.string().max(100).optional(),
4767
+ sourceQuestId: z128.string().optional(),
4768
+ sessionId: z128.string().optional(),
4769
+ parentArtifactId: z128.string().optional(),
4770
+ permissions: z128.object({
4771
+ canRead: z128.array(z128.string()).default([]),
4772
+ canWrite: z128.array(z128.string()).default([]),
4773
+ canDelete: z128.array(z128.string()).default([]),
4774
+ isPublic: z128.boolean().default(false),
4775
+ inheritFromProject: z128.boolean().default(true)
5292
4776
  }).optional(),
5293
- metadata: z129.record(z129.unknown()).default({})
4777
+ metadata: z128.record(z128.unknown()).default({})
5294
4778
  });
5295
4779
 
5296
4780
  // ../../b4m-core/packages/services/dist/src/artifactService/get.js
5297
- import { z as z130 } from "zod";
5298
- var getArtifactSchema = z130.object({
5299
- id: z130.string(),
5300
- includeContent: z130.boolean().default(false),
5301
- includeVersions: z130.boolean().default(false),
5302
- version: z130.number().optional()
4781
+ import { z as z129 } from "zod";
4782
+ var getArtifactSchema = z129.object({
4783
+ id: z129.string(),
4784
+ includeContent: z129.boolean().default(false),
4785
+ includeVersions: z129.boolean().default(false),
4786
+ version: z129.number().optional()
5303
4787
  });
5304
4788
 
5305
4789
  // ../../b4m-core/packages/services/dist/src/artifactService/list.js
5306
- import { z as z131 } from "zod";
5307
- var listArtifactsSchema = z131.object({
5308
- type: z131.string().optional(),
5309
- status: z131.enum(["draft", "review", "published", "archived"]).optional(),
5310
- visibility: z131.enum(["private", "project", "organization", "public"]).optional(),
5311
- projectId: z131.string().optional(),
5312
- sessionId: z131.string().optional(),
5313
- tags: z131.array(z131.string()).optional(),
5314
- search: z131.string().optional(),
5315
- limit: z131.number().min(1).max(100).default(20),
5316
- offset: z131.number().min(0).default(0),
5317
- sortBy: z131.enum(["createdAt", "updatedAt", "title", "type"]).default("updatedAt"),
5318
- sortOrder: z131.enum(["asc", "desc"]).default("desc"),
5319
- includeDeleted: z131.boolean().default(false)
4790
+ import { z as z130 } from "zod";
4791
+ var listArtifactsSchema = z130.object({
4792
+ type: z130.string().optional(),
4793
+ status: z130.enum(["draft", "review", "published", "archived"]).optional(),
4794
+ visibility: z130.enum(["private", "project", "organization", "public"]).optional(),
4795
+ projectId: z130.string().optional(),
4796
+ sessionId: z130.string().optional(),
4797
+ tags: z130.array(z130.string()).optional(),
4798
+ search: z130.string().optional(),
4799
+ limit: z130.number().min(1).max(100).default(20),
4800
+ offset: z130.number().min(0).default(0),
4801
+ sortBy: z130.enum(["createdAt", "updatedAt", "title", "type"]).default("updatedAt"),
4802
+ sortOrder: z130.enum(["asc", "desc"]).default("desc"),
4803
+ includeDeleted: z130.boolean().default(false)
5320
4804
  });
5321
4805
 
5322
4806
  // ../../b4m-core/packages/services/dist/src/artifactService/update.js
5323
- import { z as z132 } from "zod";
5324
- var updateArtifactSchema = z132.object({
5325
- id: z132.string(),
5326
- title: z132.string().min(1).max(255).optional(),
5327
- description: z132.string().max(1e3).optional(),
5328
- content: z132.string().optional(),
5329
- visibility: z132.enum(["private", "project", "organization", "public"]).optional(),
5330
- status: z132.enum(["draft", "review", "published", "archived"]).optional(),
5331
- tags: z132.array(z132.string().max(50)).max(20).optional(),
5332
- versionTag: z132.string().max(100).optional(),
5333
- permissions: z132.object({
5334
- canRead: z132.array(z132.string()).optional(),
5335
- canWrite: z132.array(z132.string()).optional(),
5336
- canDelete: z132.array(z132.string()).optional(),
5337
- isPublic: z132.boolean().optional(),
5338
- inheritFromProject: z132.boolean().optional()
4807
+ import { z as z131 } from "zod";
4808
+ var updateArtifactSchema = z131.object({
4809
+ id: z131.string(),
4810
+ title: z131.string().min(1).max(255).optional(),
4811
+ description: z131.string().max(1e3).optional(),
4812
+ content: z131.string().optional(),
4813
+ visibility: z131.enum(["private", "project", "organization", "public"]).optional(),
4814
+ status: z131.enum(["draft", "review", "published", "archived"]).optional(),
4815
+ tags: z131.array(z131.string().max(50)).max(20).optional(),
4816
+ versionTag: z131.string().max(100).optional(),
4817
+ permissions: z131.object({
4818
+ canRead: z131.array(z131.string()).optional(),
4819
+ canWrite: z131.array(z131.string()).optional(),
4820
+ canDelete: z131.array(z131.string()).optional(),
4821
+ isPublic: z131.boolean().optional(),
4822
+ inheritFromProject: z131.boolean().optional()
5339
4823
  }).optional(),
5340
- metadata: z132.record(z132.unknown()).optional(),
5341
- changes: z132.array(z132.string()).optional(),
5342
- changeDescription: z132.string().max(1e3).optional(),
5343
- createNewVersion: z132.boolean().optional(),
5344
- versionMessage: z132.string().max(500).optional()
4824
+ metadata: z131.record(z131.unknown()).optional(),
4825
+ changes: z131.array(z131.string()).optional(),
4826
+ changeDescription: z131.string().max(1e3).optional(),
4827
+ createNewVersion: z131.boolean().optional(),
4828
+ versionMessage: z131.string().max(500).optional()
5345
4829
  });
5346
4830
 
5347
4831
  // ../../b4m-core/packages/services/dist/src/artifactService/delete.js
5348
- import { z as z133 } from "zod";
5349
- var deleteArtifactSchema = z133.object({
5350
- id: z133.string(),
5351
- hardDelete: z133.boolean().default(false)
4832
+ import { z as z132 } from "zod";
4833
+ var deleteArtifactSchema = z132.object({
4834
+ id: z132.string(),
4835
+ hardDelete: z132.boolean().default(false)
5352
4836
  // For future implementation
5353
4837
  });
5354
4838
 
5355
4839
  // ../../b4m-core/packages/services/dist/src/questMasterService/create.js
5356
- import { z as z134 } from "zod";
5357
- var questSchema = z134.object({
5358
- id: z134.string(),
5359
- title: z134.string().min(1).max(255),
5360
- description: z134.string().max(1e3),
5361
- status: z134.enum(["not_started", "in_progress", "completed", "blocked"]).default("not_started"),
5362
- order: z134.number().min(0),
5363
- dependencies: z134.array(z134.string()).default([]),
5364
- estimatedTime: z134.string().optional()
5365
- });
5366
- var questResourceSchema = z134.object({
5367
- title: z134.string().min(1).max(255),
5368
- url: z134.string().url(),
5369
- type: z134.enum(["documentation", "tutorial", "reference", "example"])
5370
- });
5371
- var createQuestMasterSchema = z134.object({
5372
- title: z134.string().min(1).max(255),
5373
- description: z134.string().max(1e3).optional(),
5374
- goal: z134.string().min(1).max(1e3),
5375
- complexity: z134.enum(["beginner", "intermediate", "advanced", "expert"]),
5376
- estimatedTotalTime: z134.string().optional(),
5377
- prerequisites: z134.array(z134.string().max(200)).default([]),
5378
- quests: z134.array(questSchema).min(1),
5379
- resources: z134.array(questResourceSchema).default([]),
5380
- projectId: z134.string().optional(),
5381
- organizationId: z134.string().optional(),
5382
- visibility: z134.enum(["private", "project", "organization", "public"]).default("private"),
5383
- tags: z134.array(z134.string().max(50)).max(20).default([]),
5384
- permissions: z134.object({
5385
- canRead: z134.array(z134.string()).default([]),
5386
- canWrite: z134.array(z134.string()).default([]),
5387
- canDelete: z134.array(z134.string()).default([]),
5388
- isPublic: z134.boolean().default(false),
5389
- inheritFromProject: z134.boolean().default(true)
4840
+ import { z as z133 } from "zod";
4841
+ var questSchema = z133.object({
4842
+ id: z133.string(),
4843
+ title: z133.string().min(1).max(255),
4844
+ description: z133.string().max(MAX_DESCRIPTION_LENGTH),
4845
+ status: z133.enum(["not_started", "in_progress", "completed", "blocked"]).default("not_started"),
4846
+ order: z133.number().min(0),
4847
+ dependencies: z133.array(z133.string()).default([]),
4848
+ estimatedTime: z133.string().optional()
4849
+ });
4850
+ var questResourceSchema = z133.object({
4851
+ title: z133.string().min(1).max(255),
4852
+ url: z133.string().url(),
4853
+ type: z133.enum(["documentation", "tutorial", "reference", "example"])
4854
+ });
4855
+ var createQuestMasterSchema = z133.object({
4856
+ title: z133.string().min(1).max(255),
4857
+ description: z133.string().max(MAX_DESCRIPTION_LENGTH).optional(),
4858
+ goal: z133.string().min(1).max(MAX_GOAL_LENGTH),
4859
+ complexity: z133.enum(["beginner", "intermediate", "advanced", "expert"]),
4860
+ estimatedTotalTime: z133.string().optional(),
4861
+ prerequisites: z133.array(z133.string().max(200)).default([]),
4862
+ quests: z133.array(questSchema).min(1),
4863
+ resources: z133.array(questResourceSchema).default([]),
4864
+ projectId: z133.string().optional(),
4865
+ organizationId: z133.string().optional(),
4866
+ visibility: z133.enum(["private", "project", "organization", "public"]).default("private"),
4867
+ tags: z133.array(z133.string().max(MAX_TAG_LENGTH)).max(20).default([]),
4868
+ permissions: z133.object({
4869
+ canRead: z133.array(z133.string()).default([]),
4870
+ canWrite: z133.array(z133.string()).default([]),
4871
+ canDelete: z133.array(z133.string()).default([]),
4872
+ isPublic: z133.boolean().default(false),
4873
+ inheritFromProject: z133.boolean().default(true)
5390
4874
  }).optional(),
5391
- sourceQuestId: z134.string().optional(),
5392
- sessionId: z134.string().optional(),
5393
- metadata: z134.record(z134.unknown()).default({})
4875
+ sourceQuestId: z133.string().optional(),
4876
+ sessionId: z133.string().optional(),
4877
+ metadata: z133.record(z133.unknown()).default({})
5394
4878
  });
5395
4879
 
5396
4880
  // ../../b4m-core/packages/services/dist/src/questMasterService/updateQuestStatus.js
5397
- import { z as z135 } from "zod";
5398
- var updateQuestStatusSchema = z135.object({
5399
- artifactId: z135.string(),
5400
- questId: z135.string(),
5401
- status: z135.enum(["not_started", "in_progress", "completed", "blocked"]),
5402
- completionNote: z135.string().max(500).optional()
4881
+ import { z as z134 } from "zod";
4882
+ var updateQuestStatusSchema = z134.object({
4883
+ artifactId: z134.string(),
4884
+ questId: z134.string(),
4885
+ status: z134.enum(["not_started", "in_progress", "completed", "blocked"]),
4886
+ completionNote: z134.string().max(500).optional()
5403
4887
  });
5404
4888
 
5405
4889
  // ../../b4m-core/packages/services/dist/src/dataLakeService/opensearchClient.js
@@ -5413,69 +4897,69 @@ import { toFile } from "openai/uploads";
5413
4897
  import { Readable } from "stream";
5414
4898
  import { TranscribeClient, StartTranscriptionJobCommand, GetTranscriptionJobCommand, LanguageCode, MediaFormat } from "@aws-sdk/client-transcribe";
5415
4899
  import { S3Client, PutObjectCommand, GetObjectCommand, DeleteObjectCommand } from "@aws-sdk/client-s3";
5416
- import { v4 as uuidv45 } from "uuid";
4900
+ import { v4 as uuidv44 } from "uuid";
5417
4901
 
5418
4902
  // ../../b4m-core/packages/services/dist/src/emailIngestionService/processIngestedEmail.js
5419
4903
  import { randomUUID as randomUUID5 } from "crypto";
5420
4904
 
5421
4905
  // ../../b4m-core/packages/services/dist/src/emailIngestionService/types.js
5422
- import { z as z136 } from "zod";
5423
- var processIngestedEmailOptionsSchema = z136.object({
5424
- platformDomain: z136.string().optional(),
5425
- isNewsletter: z136.boolean().optional()
4906
+ import { z as z135 } from "zod";
4907
+ var processIngestedEmailOptionsSchema = z135.object({
4908
+ platformDomain: z135.string().optional(),
4909
+ isNewsletter: z135.boolean().optional()
5426
4910
  }).optional();
5427
- var emailAttachmentSchema = z136.object({
5428
- filename: z136.string().optional(),
5429
- contentType: z136.string().optional(),
5430
- contentDisposition: z136.string().optional(),
5431
- size: z136.number().min(0),
5432
- content: z136.instanceof(Buffer),
5433
- related: z136.boolean().optional()
5434
- });
5435
- var parsedEmailObjectSchema = z136.object({
5436
- messageId: z136.string().optional(),
5437
- inReplyTo: z136.string().optional(),
5438
- references: z136.union([z136.string(), z136.array(z136.string())]).optional(),
5439
- from: z136.any().optional(),
4911
+ var emailAttachmentSchema = z135.object({
4912
+ filename: z135.string().optional(),
4913
+ contentType: z135.string().optional(),
4914
+ contentDisposition: z135.string().optional(),
4915
+ size: z135.number().min(0),
4916
+ content: z135.instanceof(Buffer),
4917
+ related: z135.boolean().optional()
4918
+ });
4919
+ var parsedEmailObjectSchema = z135.object({
4920
+ messageId: z135.string().optional(),
4921
+ inReplyTo: z135.string().optional(),
4922
+ references: z135.union([z135.string(), z135.array(z135.string())]).optional(),
4923
+ from: z135.any().optional(),
5440
4924
  // Complex email address object
5441
- to: z136.any().optional(),
5442
- cc: z136.any().optional(),
5443
- bcc: z136.any().optional(),
5444
- subject: z136.string().optional(),
5445
- date: z136.date().optional(),
5446
- text: z136.string().optional(),
5447
- html: z136.string().optional(),
5448
- attachments: z136.array(emailAttachmentSchema).optional()
5449
- });
5450
- var processIngestedEmailSchema = z136.object({
4925
+ to: z135.any().optional(),
4926
+ cc: z135.any().optional(),
4927
+ bcc: z135.any().optional(),
4928
+ subject: z135.string().optional(),
4929
+ date: z135.date().optional(),
4930
+ text: z135.string().optional(),
4931
+ html: z135.string().optional(),
4932
+ attachments: z135.array(emailAttachmentSchema).optional()
4933
+ });
4934
+ var processIngestedEmailSchema = z135.object({
5451
4935
  parsedEmail: parsedEmailObjectSchema,
5452
- rawEmailS3Key: z136.string().min(1, "rawEmailS3Key cannot be empty"),
4936
+ rawEmailS3Key: z135.string().min(1, "rawEmailS3Key cannot be empty"),
5453
4937
  options: processIngestedEmailOptionsSchema
5454
4938
  });
5455
4939
 
5456
4940
  // ../../b4m-core/packages/services/dist/src/emailAnalysisService/types.js
5457
- import { z as z137 } from "zod";
5458
- var llmAnalysisResponseSchema = z137.object({
5459
- summary: z137.string().min(1, "Summary cannot be empty"),
5460
- entities: z137.object({
5461
- companies: z137.array(z137.string()).default([]),
5462
- people: z137.array(z137.string()).default([]),
5463
- products: z137.array(z137.string()).default([]),
5464
- technologies: z137.array(z137.string()).default([])
4941
+ import { z as z136 } from "zod";
4942
+ var llmAnalysisResponseSchema = z136.object({
4943
+ summary: z136.string().min(1, "Summary cannot be empty"),
4944
+ entities: z136.object({
4945
+ companies: z136.array(z136.string()).default([]),
4946
+ people: z136.array(z136.string()).default([]),
4947
+ products: z136.array(z136.string()).default([]),
4948
+ technologies: z136.array(z136.string()).default([])
5465
4949
  }),
5466
- sentiment: z137.enum(["positive", "neutral", "negative", "urgent"]),
5467
- actionItems: z137.array(z137.object({
5468
- description: z137.string(),
5469
- deadline: z137.string().optional()
4950
+ sentiment: z136.enum(["positive", "neutral", "negative", "urgent"]),
4951
+ actionItems: z136.array(z136.object({
4952
+ description: z136.string(),
4953
+ deadline: z136.string().optional()
5470
4954
  // ISO date string from LLM
5471
4955
  })).default([]),
5472
- privacyRecommendation: z137.enum(["public", "team", "private"]),
5473
- embargoDetected: z137.boolean().default(false),
5474
- suggestedTags: z137.array(z137.string()).default([])
4956
+ privacyRecommendation: z136.enum(["public", "team", "private"]),
4957
+ embargoDetected: z136.boolean().default(false),
4958
+ suggestedTags: z136.array(z136.string()).default([])
5475
4959
  });
5476
4960
 
5477
4961
  // ../../b4m-core/packages/services/dist/src/llm/ChatCompletion.js
5478
- import { z as z139 } from "zod";
4962
+ import { z as z138 } from "zod";
5479
4963
 
5480
4964
  // ../../b4m-core/packages/services/dist/src/llm/ChatCompletionInvoke.js
5481
4965
  import { fromZodError } from "zod-validation-error";
@@ -5484,7 +4968,7 @@ import { fromZodError } from "zod-validation-error";
5484
4968
  var BUILT_IN_TOOL_SET = new Set(b4mLLMTools.options);
5485
4969
 
5486
4970
  // ../../b4m-core/packages/services/dist/src/llm/tools/ToolCacheManager.js
5487
- var DEFAULT_CONFIG2 = {
4971
+ var DEFAULT_CONFIG = {
5488
4972
  ttl: 5 * 60 * 1e3,
5489
4973
  // 5 minutes
5490
4974
  maxFailures: 3
@@ -5574,7 +5058,7 @@ var weatherTool = {
5574
5058
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/imageGeneration/index.js
5575
5059
  import axios6 from "axios";
5576
5060
  import { fileTypeFromBuffer as fileTypeFromBuffer2 } from "file-type";
5577
- import { v4 as uuidv46 } from "uuid";
5061
+ import { v4 as uuidv45 } from "uuid";
5578
5062
  async function downloadImage(url) {
5579
5063
  if (url.startsWith("data:image/")) {
5580
5064
  const base64Data = url.split(",")[1];
@@ -5588,9 +5072,9 @@ async function processAndStoreImages(images, context) {
5588
5072
  return Promise.all(images.map(async (image) => {
5589
5073
  const buffer = await downloadImage(image);
5590
5074
  const fileType = await fileTypeFromBuffer2(buffer);
5591
- const filename = `${uuidv46()}.${fileType?.ext}`;
5592
- const path17 = await context.imageGenerateStorage.upload(buffer, filename, {});
5593
- return path17;
5075
+ const filename = `${uuidv45()}.${fileType?.ext}`;
5076
+ const path16 = await context.imageGenerateStorage.upload(buffer, filename, {});
5077
+ return path16;
5594
5078
  }));
5595
5079
  }
5596
5080
  async function updateQuestAndReturnMarkdown(storedImageUrls, context) {
@@ -6563,17 +6047,17 @@ var rechartsTool = {
6563
6047
  };
6564
6048
 
6565
6049
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/editFile/index.js
6566
- import { z as z138 } from "zod";
6050
+ import { z as z137 } from "zod";
6567
6051
  import { diffLines as diffLines2 } from "diff";
6568
- var editFileSchema = z138.object({
6569
- fileId: z138.string().describe("The ID of the file to edit"),
6570
- instruction: z138.string().describe("Natural language instruction describing the changes to make"),
6571
- selection: z138.object({
6572
- start: z138.number().describe("Starting character position of the selection"),
6573
- end: z138.number().describe("Ending character position of the selection")
6052
+ var editFileSchema = z137.object({
6053
+ fileId: z137.string().describe("The ID of the file to edit"),
6054
+ instruction: z137.string().describe("Natural language instruction describing the changes to make"),
6055
+ selection: z137.object({
6056
+ start: z137.number().describe("Starting character position of the selection"),
6057
+ end: z137.number().describe("Ending character position of the selection")
6574
6058
  }).optional().describe("Optional selection range to edit within the file"),
6575
- preserveFormatting: z138.boolean().optional().default(true).describe("Whether to preserve the original formatting style"),
6576
- returnDiff: z138.boolean().optional().default(true).describe("Whether to return a diff of the changes")
6059
+ preserveFormatting: z137.boolean().optional().default(true).describe("Whether to preserve the original formatting style"),
6060
+ returnDiff: z137.boolean().optional().default(true).describe("Whether to return a diff of the changes")
6577
6061
  });
6578
6062
  function generateSimpleDiff(original, modified) {
6579
6063
  const differences = diffLines2(original, modified);
@@ -6757,7 +6241,7 @@ Return only the edited content without any markdown code blocks or explanations.
6757
6241
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/imageEdit/index.js
6758
6242
  import axios7 from "axios";
6759
6243
  import { fileTypeFromBuffer as fileTypeFromBuffer3 } from "file-type";
6760
- import { v4 as uuidv47 } from "uuid";
6244
+ import { v4 as uuidv46 } from "uuid";
6761
6245
  async function downloadImage2(url) {
6762
6246
  if (url.startsWith("data:image/")) {
6763
6247
  const base64Data = url.split(",")[1];
@@ -6801,9 +6285,9 @@ async function getImageFromFileId(fileId, context) {
6801
6285
  async function processAndStoreImage(imageUrl, context) {
6802
6286
  const buffer = await downloadImage2(imageUrl);
6803
6287
  const fileType = await fileTypeFromBuffer3(buffer);
6804
- const filename = `${uuidv47()}.${fileType?.ext}`;
6805
- const path17 = await context.imageGenerateStorage.upload(buffer, filename, {});
6806
- return path17;
6288
+ const filename = `${uuidv46()}.${fileType?.ext}`;
6289
+ const path16 = await context.imageGenerateStorage.upload(buffer, filename, {});
6290
+ return path16;
6807
6291
  }
6808
6292
  async function updateQuestAndReturnMarkdown2(storedImagePath, context) {
6809
6293
  await context.onFinish?.("edit_image", storedImagePath);
@@ -8332,8 +7816,8 @@ var getHeliocentricCoords = (planet, T) => {
8332
7816
  const sinNode = Math.sin(longNode);
8333
7817
  const x = r * (cosNode * cosOmega - sinNode * sinOmega * cosI);
8334
7818
  const y = r * (sinNode * cosOmega + cosNode * sinOmega * cosI);
8335
- const z145 = r * sinOmega * sinI;
8336
- return { x, y, z: z145, r };
7819
+ const z144 = r * sinOmega * sinI;
7820
+ return { x, y, z: z144, r };
8337
7821
  };
8338
7822
  var getGeocentricEcliptic = (planet, earth) => {
8339
7823
  const dx = planet.x - earth.x;
@@ -8640,19 +8124,19 @@ var planetVisibilityTool = {
8640
8124
  };
8641
8125
 
8642
8126
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/fileRead/index.js
8643
- import { promises as fs8 } from "fs";
8644
- import { existsSync as existsSync4, statSync as statSync4 } from "fs";
8645
- import path7 from "path";
8127
+ import { promises as fs7 } from "fs";
8128
+ import { existsSync as existsSync3, statSync as statSync4 } from "fs";
8129
+ import path6 from "path";
8646
8130
  var MAX_FILE_SIZE2 = 10 * 1024 * 1024;
8647
8131
  async function readFileContent(params) {
8648
8132
  const { path: filePath, encoding = "utf-8", maxLines } = params;
8649
- const normalizedPath = path7.normalize(filePath);
8650
- const resolvedPath = path7.resolve(process.cwd(), normalizedPath);
8651
- const cwd = path7.resolve(process.cwd());
8133
+ const normalizedPath = path6.normalize(filePath);
8134
+ const resolvedPath = path6.resolve(process.cwd(), normalizedPath);
8135
+ const cwd = path6.resolve(process.cwd());
8652
8136
  if (!resolvedPath.startsWith(cwd)) {
8653
8137
  throw new Error(`Access denied: Cannot read files outside of current working directory`);
8654
8138
  }
8655
- if (!existsSync4(resolvedPath)) {
8139
+ if (!existsSync3(resolvedPath)) {
8656
8140
  throw new Error(`File not found: ${filePath}`);
8657
8141
  }
8658
8142
  const stats = statSync4(resolvedPath);
@@ -8666,7 +8150,7 @@ async function readFileContent(params) {
8666
8150
  if (isBinary && encoding === "utf-8") {
8667
8151
  throw new Error(`File appears to be binary. Use encoding 'base64' to read binary files, or specify a different encoding.`);
8668
8152
  }
8669
- const content = await fs8.readFile(resolvedPath, encoding);
8153
+ const content = await fs7.readFile(resolvedPath, encoding);
8670
8154
  if (maxLines && typeof content === "string") {
8671
8155
  const lines = content.split("\n");
8672
8156
  if (lines.length > maxLines) {
@@ -8681,7 +8165,7 @@ ${content}`;
8681
8165
  }
8682
8166
  async function checkIfBinary(filePath) {
8683
8167
  const buffer = Buffer.alloc(8192);
8684
- const fd = await fs8.open(filePath, "r");
8168
+ const fd = await fs7.open(filePath, "r");
8685
8169
  try {
8686
8170
  const { bytesRead } = await fd.read(buffer, 0, 8192, 0);
8687
8171
  const chunk = buffer.slice(0, bytesRead);
@@ -8698,7 +8182,7 @@ var fileReadTool = {
8698
8182
  context.logger.info("\u{1F4C4} FileRead: Reading file", { path: params.path });
8699
8183
  try {
8700
8184
  const content = await readFileContent(params);
8701
- const stats = statSync4(path7.resolve(process.cwd(), path7.normalize(params.path)));
8185
+ const stats = statSync4(path6.resolve(process.cwd(), path6.normalize(params.path)));
8702
8186
  context.logger.info("\u2705 FileRead: Success", {
8703
8187
  path: params.path,
8704
8188
  size: stats.size,
@@ -8738,25 +8222,25 @@ var fileReadTool = {
8738
8222
  };
8739
8223
 
8740
8224
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/createFile/index.js
8741
- import { promises as fs9 } from "fs";
8742
- import { existsSync as existsSync5 } from "fs";
8743
- import path8 from "path";
8225
+ import { promises as fs8 } from "fs";
8226
+ import { existsSync as existsSync4 } from "fs";
8227
+ import path7 from "path";
8744
8228
  async function createFile(params) {
8745
8229
  const { path: filePath, content, createDirectories = true } = params;
8746
- const normalizedPath = path8.normalize(filePath);
8747
- const resolvedPath = path8.resolve(process.cwd(), normalizedPath);
8748
- const cwd = path8.resolve(process.cwd());
8230
+ const normalizedPath = path7.normalize(filePath);
8231
+ const resolvedPath = path7.resolve(process.cwd(), normalizedPath);
8232
+ const cwd = path7.resolve(process.cwd());
8749
8233
  if (!resolvedPath.startsWith(cwd)) {
8750
8234
  throw new Error(`Access denied: Cannot create files outside of current working directory`);
8751
8235
  }
8752
- const fileExists = existsSync5(resolvedPath);
8236
+ const fileExists = existsSync4(resolvedPath);
8753
8237
  const action = fileExists ? "overwritten" : "created";
8754
8238
  if (createDirectories) {
8755
- const dir = path8.dirname(resolvedPath);
8756
- await fs9.mkdir(dir, { recursive: true });
8239
+ const dir = path7.dirname(resolvedPath);
8240
+ await fs8.mkdir(dir, { recursive: true });
8757
8241
  }
8758
- await fs9.writeFile(resolvedPath, content, "utf-8");
8759
- const stats = await fs9.stat(resolvedPath);
8242
+ await fs8.writeFile(resolvedPath, content, "utf-8");
8243
+ const stats = await fs8.stat(resolvedPath);
8760
8244
  const lines = content.split("\n").length;
8761
8245
  return `File ${action} successfully: ${filePath}
8762
8246
  Size: ${stats.size} bytes
@@ -8767,7 +8251,7 @@ var createFileTool = {
8767
8251
  implementation: (context) => ({
8768
8252
  toolFn: async (value) => {
8769
8253
  const params = value;
8770
- const fileExists = existsSync5(path8.resolve(process.cwd(), path8.normalize(params.path)));
8254
+ const fileExists = existsSync4(path7.resolve(process.cwd(), path7.normalize(params.path)));
8771
8255
  context.logger.info(`\u{1F4DD} CreateFile: ${fileExists ? "Overwriting" : "Creating"} file`, {
8772
8256
  path: params.path,
8773
8257
  size: params.content.length
@@ -8809,7 +8293,7 @@ var createFileTool = {
8809
8293
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/globFiles/index.js
8810
8294
  import { glob } from "glob";
8811
8295
  import { stat } from "fs/promises";
8812
- import path9 from "path";
8296
+ import path8 from "path";
8813
8297
  var DEFAULT_IGNORE_PATTERNS2 = [
8814
8298
  "**/node_modules/**",
8815
8299
  "**/.git/**",
@@ -8825,7 +8309,7 @@ var DEFAULT_IGNORE_PATTERNS2 = [
8825
8309
  async function findFiles(params) {
8826
8310
  const { pattern, dir_path, case_sensitive = true, respect_git_ignore = true } = params;
8827
8311
  const baseCwd = process.cwd();
8828
- const targetDir = dir_path ? path9.resolve(baseCwd, path9.normalize(dir_path)) : baseCwd;
8312
+ const targetDir = dir_path ? path8.resolve(baseCwd, path8.normalize(dir_path)) : baseCwd;
8829
8313
  if (!targetDir.startsWith(baseCwd)) {
8830
8314
  throw new Error(`Access denied: Cannot search outside of current working directory`);
8831
8315
  }
@@ -8865,7 +8349,7 @@ async function findFiles(params) {
8865
8349
  const summary = `Found ${filesWithStats.length} file(s)${truncated ? ` (showing first ${MAX_RESULTS})` : ""} matching: ${pattern}`;
8866
8350
  const dirInfo = dir_path ? `
8867
8351
  Directory: ${dir_path}` : "";
8868
- const filesList = results.map((file) => path9.relative(baseCwd, file.path)).join("\n");
8352
+ const filesList = results.map((file) => path8.relative(baseCwd, file.path)).join("\n");
8869
8353
  return `${summary}${dirInfo}
8870
8354
 
8871
8355
  ${filesList}`;
@@ -8920,7 +8404,7 @@ var globFilesTool = {
8920
8404
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/grepSearch/index.js
8921
8405
  import { globStream } from "glob";
8922
8406
  import { readFile, stat as stat2 } from "fs/promises";
8923
- import path10 from "path";
8407
+ import path9 from "path";
8924
8408
  var MAX_FILE_SIZE3 = 10 * 1024 * 1024;
8925
8409
  var DEFAULT_IGNORE_PATTERNS3 = [
8926
8410
  "**/node_modules/**",
@@ -8949,14 +8433,14 @@ async function isBinaryFile2(filePath) {
8949
8433
  }
8950
8434
  }
8951
8435
  function isPathWithinWorkspace(targetPath, baseCwd) {
8952
- const resolvedTarget = path10.resolve(targetPath);
8953
- const resolvedBase = path10.resolve(baseCwd);
8436
+ const resolvedTarget = path9.resolve(targetPath);
8437
+ const resolvedBase = path9.resolve(baseCwd);
8954
8438
  return resolvedTarget.startsWith(resolvedBase);
8955
8439
  }
8956
8440
  async function searchFiles2(params) {
8957
8441
  const { pattern, dir_path, include } = params;
8958
8442
  const baseCwd = process.cwd();
8959
- const targetDir = dir_path ? path10.resolve(baseCwd, dir_path) : baseCwd;
8443
+ const targetDir = dir_path ? path9.resolve(baseCwd, dir_path) : baseCwd;
8960
8444
  if (!isPathWithinWorkspace(targetDir, baseCwd)) {
8961
8445
  throw new Error(`Path validation failed: "${dir_path}" resolves outside the allowed workspace directory`);
8962
8446
  }
@@ -9009,7 +8493,7 @@ async function searchFiles2(params) {
9009
8493
  lines.forEach((line, index) => {
9010
8494
  if (allMatches.length < maxMatches && searchRegex.test(line)) {
9011
8495
  allMatches.push({
9012
- filePath: path10.relative(targetDir, fileAbsPath) || path10.basename(fileAbsPath),
8496
+ filePath: path9.relative(targetDir, fileAbsPath) || path9.basename(fileAbsPath),
9013
8497
  lineNumber: index + 1,
9014
8498
  line
9015
8499
  });
@@ -9102,18 +8586,18 @@ var grepSearchTool = {
9102
8586
  };
9103
8587
 
9104
8588
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/deleteFile/index.js
9105
- import { promises as fs10 } from "fs";
9106
- import { existsSync as existsSync6, statSync as statSync5 } from "fs";
9107
- import path11 from "path";
8589
+ import { promises as fs9 } from "fs";
8590
+ import { existsSync as existsSync5, statSync as statSync5 } from "fs";
8591
+ import path10 from "path";
9108
8592
  async function deleteFile(params) {
9109
8593
  const { path: filePath, recursive = false } = params;
9110
- const normalizedPath = path11.normalize(filePath);
9111
- const resolvedPath = path11.resolve(process.cwd(), normalizedPath);
9112
- const cwd = path11.resolve(process.cwd());
8594
+ const normalizedPath = path10.normalize(filePath);
8595
+ const resolvedPath = path10.resolve(process.cwd(), normalizedPath);
8596
+ const cwd = path10.resolve(process.cwd());
9113
8597
  if (!resolvedPath.startsWith(cwd)) {
9114
8598
  throw new Error(`Access denied: Cannot delete files outside of current working directory`);
9115
8599
  }
9116
- if (!existsSync6(resolvedPath)) {
8600
+ if (!existsSync5(resolvedPath)) {
9117
8601
  throw new Error(`File or directory not found: ${filePath}`);
9118
8602
  }
9119
8603
  const stats = statSync5(resolvedPath);
@@ -9123,10 +8607,10 @@ async function deleteFile(params) {
9123
8607
  throw new Error(`Path is a directory: ${filePath}. Use recursive=true to delete directories and their contents.`);
9124
8608
  }
9125
8609
  if (isDirectory) {
9126
- await fs10.rm(resolvedPath, { recursive: true, force: true });
8610
+ await fs9.rm(resolvedPath, { recursive: true, force: true });
9127
8611
  return `Directory deleted successfully: ${filePath}`;
9128
8612
  } else {
9129
- await fs10.unlink(resolvedPath);
8613
+ await fs9.unlink(resolvedPath);
9130
8614
  return `File deleted successfully: ${filePath}
9131
8615
  Size: ${size} bytes`;
9132
8616
  }
@@ -9136,8 +8620,8 @@ var deleteFileTool = {
9136
8620
  implementation: (context) => ({
9137
8621
  toolFn: async (value) => {
9138
8622
  const params = value;
9139
- const resolvedPath = path11.resolve(process.cwd(), path11.normalize(params.path));
9140
- const isDirectory = existsSync6(resolvedPath) && statSync5(resolvedPath).isDirectory();
8623
+ const resolvedPath = path10.resolve(process.cwd(), path10.normalize(params.path));
8624
+ const isDirectory = existsSync5(resolvedPath) && statSync5(resolvedPath).isDirectory();
9141
8625
  context.logger.info(`\u{1F5D1}\uFE0F DeleteFile: Deleting ${isDirectory ? "directory" : "file"}`, {
9142
8626
  path: params.path,
9143
8627
  recursive: params.recursive
@@ -9174,7 +8658,7 @@ var deleteFileTool = {
9174
8658
 
9175
8659
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/bashExecute/index.js
9176
8660
  import { spawn } from "child_process";
9177
- import path12 from "path";
8661
+ import path11 from "path";
9178
8662
  var DEFAULT_TIMEOUT_MS = 6e4;
9179
8663
  var MAX_OUTPUT_SIZE = 100 * 1024;
9180
8664
  var DANGEROUS_PATTERNS = [
@@ -9358,7 +8842,7 @@ async function executeBashCommand(params) {
9358
8842
  };
9359
8843
  }
9360
8844
  const baseCwd = process.cwd();
9361
- const targetCwd = relativeCwd ? path12.resolve(baseCwd, relativeCwd) : baseCwd;
8845
+ const targetCwd = relativeCwd ? path11.resolve(baseCwd, relativeCwd) : baseCwd;
9362
8846
  const effectiveTimeout = Math.min(timeout, 5 * 60 * 1e3);
9363
8847
  return new Promise((resolve3) => {
9364
8848
  let stdout = "";
@@ -9548,9 +9032,9 @@ BLOCKED OPERATIONS:
9548
9032
  };
9549
9033
 
9550
9034
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/editLocalFile/index.js
9551
- import { promises as fs11 } from "fs";
9552
- import { existsSync as existsSync7 } from "fs";
9553
- import path13 from "path";
9035
+ import { promises as fs10 } from "fs";
9036
+ import { existsSync as existsSync6 } from "fs";
9037
+ import path12 from "path";
9554
9038
  import { diffLines as diffLines3 } from "diff";
9555
9039
  function generateDiff(original, modified) {
9556
9040
  const differences = diffLines3(original, modified);
@@ -9574,16 +9058,16 @@ function generateDiff(original, modified) {
9574
9058
  }
9575
9059
  async function editLocalFile(params) {
9576
9060
  const { path: filePath, old_string, new_string } = params;
9577
- const normalizedPath = path13.normalize(filePath);
9578
- const resolvedPath = path13.resolve(process.cwd(), normalizedPath);
9579
- const cwd = path13.resolve(process.cwd());
9061
+ const normalizedPath = path12.normalize(filePath);
9062
+ const resolvedPath = path12.resolve(process.cwd(), normalizedPath);
9063
+ const cwd = path12.resolve(process.cwd());
9580
9064
  if (!resolvedPath.startsWith(cwd)) {
9581
9065
  throw new Error(`Access denied: Cannot edit files outside of current working directory`);
9582
9066
  }
9583
- if (!existsSync7(resolvedPath)) {
9067
+ if (!existsSync6(resolvedPath)) {
9584
9068
  throw new Error(`File not found: ${filePath}`);
9585
9069
  }
9586
- const currentContent = await fs11.readFile(resolvedPath, "utf-8");
9070
+ const currentContent = await fs10.readFile(resolvedPath, "utf-8");
9587
9071
  if (!currentContent.includes(old_string)) {
9588
9072
  const preview = old_string.length > 100 ? old_string.substring(0, 100) + "..." : old_string;
9589
9073
  throw new Error(`String to replace not found in file. Make sure the old_string matches exactly (including whitespace and line endings). Searched for: "${preview}"`);
@@ -9593,7 +9077,7 @@ async function editLocalFile(params) {
9593
9077
  throw new Error(`Found ${occurrences} occurrences of the string to replace. Please provide a more specific old_string that matches exactly one location.`);
9594
9078
  }
9595
9079
  const newContent = currentContent.replace(old_string, new_string);
9596
- await fs11.writeFile(resolvedPath, newContent, "utf-8");
9080
+ await fs10.writeFile(resolvedPath, newContent, "utf-8");
9597
9081
  const diffResult = generateDiff(old_string, new_string);
9598
9082
  return `File edited successfully: ${filePath}
9599
9083
  Changes: +${diffResult.additions} lines, -${diffResult.deletions} lines
@@ -9729,7 +9213,7 @@ var generateMcpTools = async (mcpData) => {
9729
9213
  };
9730
9214
  const optionTools = {
9731
9215
  toolFn: async (args) => {
9732
- console.log(`Calling ${name} tool via ${mcpData.serverName}`, args);
9216
+ Logger.debug(`Calling ${name} tool via ${mcpData.serverName}`, args);
9733
9217
  try {
9734
9218
  const toolResult = await mcpData.callTool(name, args);
9735
9219
  const contentBlocks = toolResult?.content;
@@ -9740,11 +9224,11 @@ var generateMcpTools = async (mcpData) => {
9740
9224
  }
9741
9225
  return JSON.stringify(entry);
9742
9226
  }).join("\n");
9743
- console.log(`[Tool Result] ${name}:`, normalized);
9227
+ Logger.debug(`[Tool Result] ${name}:`, normalized);
9744
9228
  return normalized;
9745
9229
  }
9746
9230
  const serialized = typeof toolResult === "string" ? toolResult : JSON.stringify(toolResult);
9747
- console.warn(`[Tool Result] Unexpected format for ${name}, returning serialized output`);
9231
+ Logger.debug(`[Tool Result] Unexpected format for ${name}, returning serialized output`);
9748
9232
  return serialized;
9749
9233
  } catch (error) {
9750
9234
  const serverName2 = mcpData.serverName?.toLowerCase();
@@ -9773,7 +9257,7 @@ var generateMcpTools = async (mcpData) => {
9773
9257
  // Mark as MCP tool to enable tool chaining
9774
9258
  };
9775
9259
  }, {});
9776
- console.log(`\u{1F527} generateMcpTools: Generated ${result.length} tool implementations for ${mcpData.serverName}`);
9260
+ Logger.debug(`\u{1F527} generateMcpTools: Generated ${result.length} tool implementations for ${mcpData.serverName}`);
9777
9261
  return result;
9778
9262
  };
9779
9263
 
@@ -9791,52 +9275,73 @@ var DISABLE_SERVER_THROTTLING = process.env.DISABLE_SERVER_THROTTLING === "true"
9791
9275
  var questSaveMutex = new Mutex();
9792
9276
 
9793
9277
  // ../../b4m-core/packages/services/dist/src/llm/ChatCompletion.js
9794
- var QuestStartBodySchema = z139.object({
9795
- userId: z139.string(),
9796
- sessionId: z139.string(),
9797
- questId: z139.string(),
9798
- message: z139.string(),
9799
- messageFileIds: z139.array(z139.string()),
9800
- historyCount: z139.number(),
9801
- fabFileIds: z139.array(z139.string()),
9278
+ var QuestStartBodySchema = z138.object({
9279
+ userId: z138.string(),
9280
+ sessionId: z138.string(),
9281
+ questId: z138.string(),
9282
+ message: z138.string(),
9283
+ messageFileIds: z138.array(z138.string()),
9284
+ historyCount: z138.number(),
9285
+ fabFileIds: z138.array(z138.string()),
9802
9286
  params: ChatCompletionCreateInputSchema,
9803
9287
  dashboardParams: DashboardParamsSchema.optional(),
9804
- enableQuestMaster: z139.boolean().optional(),
9805
- enableMementos: z139.boolean().optional(),
9806
- enableArtifacts: z139.boolean().optional(),
9807
- enableAgents: z139.boolean().optional(),
9288
+ enableQuestMaster: z138.boolean().optional(),
9289
+ enableMementos: z138.boolean().optional(),
9290
+ enableArtifacts: z138.boolean().optional(),
9291
+ enableAgents: z138.boolean().optional(),
9808
9292
  promptMeta: PromptMetaZodSchema,
9809
- tools: z139.array(z139.union([b4mLLMTools, z139.string()])).optional(),
9810
- mcpServers: z139.array(z139.string()).optional(),
9811
- projectId: z139.string().optional(),
9812
- organizationId: z139.string().nullable().optional(),
9293
+ tools: z138.array(z138.union([b4mLLMTools, z138.string()])).optional(),
9294
+ mcpServers: z138.array(z138.string()).optional(),
9295
+ projectId: z138.string().optional(),
9296
+ organizationId: z138.string().nullable().optional(),
9813
9297
  questMaster: QuestMasterParamsSchema.optional(),
9814
- toolPromptId: z139.string().optional(),
9298
+ toolPromptId: z138.string().optional(),
9815
9299
  researchMode: ResearchModeParamsSchema.optional(),
9816
- fallbackModel: z139.string().optional(),
9817
- embeddingModel: z139.string().optional(),
9818
- queryComplexity: z139.string(),
9300
+ fallbackModel: z138.string().optional(),
9301
+ embeddingModel: z138.string().optional(),
9302
+ queryComplexity: z138.string(),
9819
9303
  imageConfig: GenerateImageToolCallSchema.optional(),
9820
- deepResearchConfig: z139.object({
9821
- maxDepth: z139.number().optional(),
9822
- duration: z139.number().optional(),
9304
+ deepResearchConfig: z138.object({
9305
+ maxDepth: z138.number().optional(),
9306
+ duration: z138.number().optional(),
9823
9307
  // Note: searchers are passed via ToolContext and not through this API schema
9824
- searchers: z139.array(z139.any()).optional()
9308
+ searchers: z138.array(z138.any()).optional()
9825
9309
  }).optional(),
9826
- extraContextMessages: z139.array(z139.object({
9827
- role: z139.enum(["user", "assistant", "system", "function", "tool"]),
9828
- content: z139.union([z139.string(), z139.array(z139.any())]),
9829
- fabFileIds: z139.array(z139.string()).optional()
9310
+ extraContextMessages: z138.array(z138.object({
9311
+ role: z138.enum(["user", "assistant", "system", "function", "tool"]),
9312
+ content: z138.union([z138.string(), z138.array(z138.any())]),
9313
+ fabFileIds: z138.array(z138.string()).optional()
9830
9314
  })).optional()
9831
9315
  });
9832
9316
 
9833
9317
  // ../../b4m-core/packages/services/dist/src/llm/ImageGeneration.js
9834
9318
  import axios8 from "axios";
9835
9319
  import { fileTypeFromBuffer as fileTypeFromBuffer4 } from "file-type";
9836
- import { v4 as uuidv48 } from "uuid";
9837
- import { z as z140 } from "zod";
9320
+ import { v4 as uuidv47 } from "uuid";
9321
+ import { z as z139 } from "zod";
9838
9322
  import { fromZodError as fromZodError2 } from "zod-validation-error";
9839
9323
  var ImageGenerationBodySchema = OpenAIImageGenerationInput.extend({
9324
+ sessionId: z139.string(),
9325
+ questId: z139.string(),
9326
+ userId: z139.string(),
9327
+ prompt: z139.string(),
9328
+ safety_tolerance: z139.number().min(BFL_SAFETY_TOLERANCE.MIN).max(BFL_SAFETY_TOLERANCE.MAX).optional().default(BFL_SAFETY_TOLERANCE.DEFAULT),
9329
+ prompt_upsampling: z139.boolean().optional().default(false),
9330
+ seed: z139.number().nullable().optional(),
9331
+ output_format: z139.enum(["jpeg", "png"]).nullable().optional().default("png"),
9332
+ width: z139.number().optional(),
9333
+ height: z139.number().optional(),
9334
+ aspect_ratio: z139.string().optional(),
9335
+ fabFileIds: z139.array(z139.string()).optional()
9336
+ });
9337
+
9338
+ // ../../b4m-core/packages/services/dist/src/llm/ImageEdit.js
9339
+ import axios9 from "axios";
9340
+ import { fileTypeFromBuffer as fileTypeFromBuffer5 } from "file-type";
9341
+ import { v4 as uuidv48 } from "uuid";
9342
+ import { z as z140 } from "zod";
9343
+ import { fromZodError as fromZodError3 } from "zod-validation-error";
9344
+ var ImageEditBodySchema = OpenAIImageGenerationInput.extend({
9840
9345
  sessionId: z140.string(),
9841
9346
  questId: z140.string(),
9842
9347
  userId: z140.string(),
@@ -9844,56 +9349,35 @@ var ImageGenerationBodySchema = OpenAIImageGenerationInput.extend({
9844
9349
  safety_tolerance: z140.number().min(BFL_SAFETY_TOLERANCE.MIN).max(BFL_SAFETY_TOLERANCE.MAX).optional().default(BFL_SAFETY_TOLERANCE.DEFAULT),
9845
9350
  prompt_upsampling: z140.boolean().optional().default(false),
9846
9351
  seed: z140.number().nullable().optional(),
9847
- output_format: z140.enum(["jpeg", "png"]).nullable().optional().default("png"),
9352
+ output_format: z140.enum(["jpeg", "png"]).optional().default("png"),
9848
9353
  width: z140.number().optional(),
9849
9354
  height: z140.number().optional(),
9850
9355
  aspect_ratio: z140.string().optional(),
9851
- fabFileIds: z140.array(z140.string()).optional()
9852
- });
9853
-
9854
- // ../../b4m-core/packages/services/dist/src/llm/ImageEdit.js
9855
- import axios9 from "axios";
9856
- import { fileTypeFromBuffer as fileTypeFromBuffer5 } from "file-type";
9857
- import { v4 as uuidv49 } from "uuid";
9858
- import { z as z141 } from "zod";
9859
- import { fromZodError as fromZodError3 } from "zod-validation-error";
9860
- var ImageEditBodySchema = OpenAIImageGenerationInput.extend({
9861
- sessionId: z141.string(),
9862
- questId: z141.string(),
9863
- userId: z141.string(),
9864
- prompt: z141.string(),
9865
- safety_tolerance: z141.number().min(BFL_SAFETY_TOLERANCE.MIN).max(BFL_SAFETY_TOLERANCE.MAX).optional().default(BFL_SAFETY_TOLERANCE.DEFAULT),
9866
- prompt_upsampling: z141.boolean().optional().default(false),
9867
- seed: z141.number().nullable().optional(),
9868
- output_format: z141.enum(["jpeg", "png"]).optional().default("png"),
9869
- width: z141.number().optional(),
9870
- height: z141.number().optional(),
9871
- aspect_ratio: z141.string().optional(),
9872
- size: z141.string().optional(),
9873
- fabFileIds: z141.array(z141.string()).optional(),
9874
- image: z141.string()
9356
+ size: z140.string().optional(),
9357
+ fabFileIds: z140.array(z140.string()).optional(),
9358
+ image: z140.string()
9875
9359
  });
9876
9360
 
9877
9361
  // ../../b4m-core/packages/services/dist/src/llm/refineText.js
9878
- import { z as z142 } from "zod";
9879
- var refineTextLLMSchema = z142.object({
9880
- text: z142.string(),
9881
- context: z142.string().optional()
9362
+ import { z as z141 } from "zod";
9363
+ var refineTextLLMSchema = z141.object({
9364
+ text: z141.string(),
9365
+ context: z141.string().optional()
9882
9366
  // tone: z.enum(['formal', 'informal', 'neutral']).optional(),
9883
9367
  // style: z.enum(['technical', 'creative', 'academic', 'business', 'narrative']).optional(),
9884
9368
  });
9885
9369
 
9886
9370
  // ../../b4m-core/packages/services/dist/src/llm/MementoEvaluationService.js
9887
- import { z as z143 } from "zod";
9888
- var SingleMementoEvalSchema = z143.object({
9889
- importance: z143.number().min(1).max(10),
9371
+ import { z as z142 } from "zod";
9372
+ var SingleMementoEvalSchema = z142.object({
9373
+ importance: z142.number().min(1).max(10),
9890
9374
  // 1-10 scale for personal info importance
9891
- summary: z143.string(),
9892
- tags: z143.array(z143.string()).optional()
9375
+ summary: z142.string(),
9376
+ tags: z142.array(z142.string()).optional()
9893
9377
  });
9894
- var MementoEvalResponseSchema = z143.object({
9895
- isPersonal: z143.boolean(),
9896
- mementos: z143.array(SingleMementoEvalSchema).optional()
9378
+ var MementoEvalResponseSchema = z142.object({
9379
+ isPersonal: z142.boolean(),
9380
+ mementos: z142.array(SingleMementoEvalSchema).optional()
9897
9381
  // Array of distinct personal information
9898
9382
  });
9899
9383
 
@@ -9914,10 +9398,10 @@ var ToolErrorType;
9914
9398
  // src/utils/diffPreview.ts
9915
9399
  import * as Diff from "diff";
9916
9400
  import { readFile as readFile2 } from "fs/promises";
9917
- import { existsSync as existsSync8 } from "fs";
9401
+ import { existsSync as existsSync7 } from "fs";
9918
9402
  async function generateFileDiffPreview(args) {
9919
9403
  try {
9920
- if (!existsSync8(args.path)) {
9404
+ if (!existsSync7(args.path)) {
9921
9405
  const lines2 = args.content.split("\n");
9922
9406
  const preview = lines2.slice(0, 20).join("\n");
9923
9407
  const hasMore = lines2.length > 20;
@@ -9955,10 +9439,10 @@ ${diffLines4.join("\n")}`;
9955
9439
  }
9956
9440
  async function generateFileDeletePreview(args) {
9957
9441
  try {
9958
- if (!existsSync8(args.path)) {
9442
+ if (!existsSync7(args.path)) {
9959
9443
  return `[File does not exist: ${args.path}]`;
9960
9444
  }
9961
- const stats = await import("fs/promises").then((fs14) => fs14.stat(args.path));
9445
+ const stats = await import("fs/promises").then((fs13) => fs13.stat(args.path));
9962
9446
  return `[File will be deleted]
9963
9447
 
9964
9448
  Path: ${args.path}
@@ -9970,8 +9454,8 @@ Last modified: ${stats.mtime.toLocaleString()}`;
9970
9454
  }
9971
9455
 
9972
9456
  // src/utils/Logger.ts
9973
- import fs12 from "fs/promises";
9974
- import path14 from "path";
9457
+ import fs11 from "fs/promises";
9458
+ import path13 from "path";
9975
9459
  import os2 from "os";
9976
9460
  var Logger2 = class _Logger {
9977
9461
  constructor() {
@@ -9994,9 +9478,9 @@ var Logger2 = class _Logger {
9994
9478
  */
9995
9479
  async initialize(sessionId) {
9996
9480
  this.sessionId = sessionId;
9997
- const debugDir = path14.join(os2.homedir(), ".bike4mind", "debug");
9998
- await fs12.mkdir(debugDir, { recursive: true });
9999
- this.logFilePath = path14.join(debugDir, `${sessionId}.txt`);
9481
+ const debugDir = path13.join(os2.homedir(), ".bike4mind", "debug");
9482
+ await fs11.mkdir(debugDir, { recursive: true });
9483
+ this.logFilePath = path13.join(debugDir, `${sessionId}.txt`);
10000
9484
  await this.writeToFile("INFO", "=== CLI SESSION START ===");
10001
9485
  }
10002
9486
  /**
@@ -10060,7 +9544,7 @@ var Logger2 = class _Logger {
10060
9544
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").substring(0, 19);
10061
9545
  const logEntry = `[${timestamp}] [${level}] ${message}
10062
9546
  `;
10063
- await fs12.appendFile(this.logFilePath, logEntry, "utf-8");
9547
+ await fs11.appendFile(this.logFilePath, logEntry, "utf-8");
10064
9548
  } catch (error) {
10065
9549
  console.error("File logging failed:", error);
10066
9550
  }
@@ -10206,15 +9690,15 @@ var Logger2 = class _Logger {
10206
9690
  async cleanupOldLogs() {
10207
9691
  if (!this.fileLoggingEnabled) return;
10208
9692
  try {
10209
- const debugDir = path14.join(os2.homedir(), ".bike4mind", "debug");
10210
- const files = await fs12.readdir(debugDir);
9693
+ const debugDir = path13.join(os2.homedir(), ".bike4mind", "debug");
9694
+ const files = await fs11.readdir(debugDir);
10211
9695
  const now = Date.now();
10212
9696
  const thirtyDaysAgo = now - 30 * 24 * 60 * 60 * 1e3;
10213
9697
  for (const file of files) {
10214
- const filePath = path14.join(debugDir, file);
10215
- const stats = await fs12.stat(filePath);
9698
+ const filePath = path13.join(debugDir, file);
9699
+ const stats = await fs11.stat(filePath);
10216
9700
  if (stats.mtime.getTime() < thirtyDaysAgo) {
10217
- await fs12.unlink(filePath);
9701
+ await fs11.unlink(filePath);
10218
9702
  }
10219
9703
  }
10220
9704
  } catch (error) {
@@ -10308,21 +9792,21 @@ var NoOpStorage = class extends BaseStorage {
10308
9792
  async upload(input, destination, options) {
10309
9793
  return `/tmp/${destination}`;
10310
9794
  }
10311
- async download(path17) {
9795
+ async download(path16) {
10312
9796
  throw new Error("Download not supported in CLI");
10313
9797
  }
10314
- async delete(path17) {
9798
+ async delete(path16) {
10315
9799
  }
10316
- async getSignedUrl(path17) {
10317
- return `/tmp/${path17}`;
9800
+ async getSignedUrl(path16) {
9801
+ return `/tmp/${path16}`;
10318
9802
  }
10319
- getPublicUrl(path17) {
10320
- return `/tmp/${path17}`;
9803
+ getPublicUrl(path16) {
9804
+ return `/tmp/${path16}`;
10321
9805
  }
10322
- async getPreview(path17) {
10323
- return `/tmp/${path17}`;
9806
+ async getPreview(path16) {
9807
+ return `/tmp/${path16}`;
10324
9808
  }
10325
- async getMetadata(path17) {
9809
+ async getMetadata(path16) {
10326
9810
  return { size: 0, contentType: "application/octet-stream" };
10327
9811
  }
10328
9812
  };
@@ -10534,8 +10018,8 @@ function generateCliTools(userId, llm, model, permissionManager, showPermissionP
10534
10018
  }
10535
10019
 
10536
10020
  // src/config/toolSafety.ts
10537
- import { z as z144 } from "zod";
10538
- var ToolCategorySchema = z144.enum([
10021
+ import { z as z143 } from "zod";
10022
+ var ToolCategorySchema = z143.enum([
10539
10023
  "auto_approve",
10540
10024
  // Safe tools that run automatically without permission
10541
10025
  "prompt_always",
@@ -10543,9 +10027,9 @@ var ToolCategorySchema = z144.enum([
10543
10027
  "prompt_default"
10544
10028
  // Tools that prompt by default but can be trusted
10545
10029
  ]);
10546
- var ToolSafetyConfigSchema = z144.object({
10547
- categories: z144.record(z144.string(), ToolCategorySchema),
10548
- trustedTools: z144.array(z144.string())
10030
+ var ToolSafetyConfigSchema = z143.object({
10031
+ categories: z143.record(z143.string(), ToolCategorySchema),
10032
+ trustedTools: z143.array(z143.string())
10549
10033
  });
10550
10034
  var DEFAULT_TOOL_CATEGORIES = {
10551
10035
  // ===== AUTO APPROVE (Safe tools) =====
@@ -10726,9 +10210,9 @@ function getEnvironmentName(configApiConfig) {
10726
10210
  }
10727
10211
 
10728
10212
  // src/utils/contextLoader.ts
10729
- import * as fs13 from "fs";
10730
- import * as path15 from "path";
10731
- import { homedir as homedir4 } from "os";
10213
+ import * as fs12 from "fs";
10214
+ import * as path14 from "path";
10215
+ import { homedir as homedir3 } from "os";
10732
10216
  var CONTEXT_FILE_SIZE_LIMIT = 100 * 1024;
10733
10217
  var PROJECT_CONTEXT_FILES = [
10734
10218
  "CLAUDE.local.md",
@@ -10748,9 +10232,9 @@ function formatFileSize2(bytes) {
10748
10232
  return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
10749
10233
  }
10750
10234
  function tryReadContextFile(dir, filename, source) {
10751
- const filePath = path15.join(dir, filename);
10235
+ const filePath = path14.join(dir, filename);
10752
10236
  try {
10753
- const stats = fs13.lstatSync(filePath);
10237
+ const stats = fs12.lstatSync(filePath);
10754
10238
  if (stats.isDirectory()) {
10755
10239
  return null;
10756
10240
  }
@@ -10764,7 +10248,7 @@ function tryReadContextFile(dir, filename, source) {
10764
10248
  error: `${source === "global" ? "Global" : "Project"} ${filename} exceeds 100KB limit (${formatFileSize2(stats.size)})`
10765
10249
  };
10766
10250
  }
10767
- const content = fs13.readFileSync(filePath, "utf-8");
10251
+ const content = fs12.readFileSync(filePath, "utf-8");
10768
10252
  return {
10769
10253
  filename,
10770
10254
  content,
@@ -10816,7 +10300,7 @@ ${project.content}`;
10816
10300
  }
10817
10301
  async function loadContextFiles(projectDir) {
10818
10302
  const errors = [];
10819
- const globalDir = path15.join(homedir4(), ".bike4mind");
10303
+ const globalDir = path14.join(homedir3(), ".bike4mind");
10820
10304
  const projectDirectory = projectDir || process.cwd();
10821
10305
  const [globalResult, projectResult] = await Promise.all([
10822
10306
  Promise.resolve(findContextFile(globalDir, GLOBAL_CONTEXT_FILES, "global")),
@@ -10928,8 +10412,8 @@ function substituteArguments(template, args) {
10928
10412
  // ../../b4m-core/packages/mcp/dist/src/client.js
10929
10413
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
10930
10414
  import { Client as Client2 } from "@modelcontextprotocol/sdk/client/index.js";
10931
- import path16 from "path";
10932
- import { existsSync as existsSync9, readdirSync as readdirSync3 } from "fs";
10415
+ import path15 from "path";
10416
+ import { existsSync as existsSync8, readdirSync as readdirSync3 } from "fs";
10933
10417
  var MCPClient = class {
10934
10418
  // Note: This class handles MCP server communication with repository filtering
10935
10419
  mcp;
@@ -10937,14 +10421,16 @@ var MCPClient = class {
10937
10421
  envVariables;
10938
10422
  customCommand;
10939
10423
  customArgs;
10424
+ suppressStderr;
10940
10425
  tools = [];
10941
10426
  serverName;
10942
- constructor({ envVariables, name, selectedRepositories, command, args }) {
10427
+ constructor({ envVariables, name, selectedRepositories, command, args, suppressStderr = false }) {
10943
10428
  this.mcp = new Client2({ name: "mcp-client-cli", version: "1.0.0" });
10944
10429
  this.envVariables = [...envVariables];
10945
10430
  this.serverName = name;
10946
10431
  this.customCommand = command;
10947
10432
  this.customArgs = args;
10433
+ this.suppressStderr = suppressStderr;
10948
10434
  if (name === "github" && selectedRepositories) {
10949
10435
  const reposJson = JSON.stringify(selectedRepositories);
10950
10436
  this.envVariables.push({
@@ -10969,18 +10455,18 @@ var MCPClient = class {
10969
10455
  const root = process.env.INIT_CWD || process.cwd();
10970
10456
  const candidatePaths = [
10971
10457
  // When running from SST Lambda with node_modules structure (copyFiles)
10972
- path16.join(root, `node_modules/@bike4mind/mcp/dist/src/${this.serverName}/index.js`),
10458
+ path15.join(root, `node_modules/@bike4mind/mcp/dist/src/${this.serverName}/index.js`),
10973
10459
  // When running from SST Lambda deployed environment (/var/task)
10974
- path16.join(root, `b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10460
+ path15.join(root, `b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10975
10461
  // When running from SST Lambda (.sst/artifacts/mcpHandler-dev), navigate to monorepo root (3 levels up)
10976
- path16.join(root, `../../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10462
+ path15.join(root, `../../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10977
10463
  // When running from packages/client (Next.js app), navigate to monorepo root (2 levels up)
10978
- path16.join(root, `../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10464
+ path15.join(root, `../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10979
10465
  // Original paths (backward compatibility)
10980
- path16.join(root, `/b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10981
- path16.join(root, "core", "mcp", "servers", this.serverName, "dist", "index.js")
10466
+ path15.join(root, `/b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10467
+ path15.join(root, "core", "mcp", "servers", this.serverName, "dist", "index.js")
10982
10468
  ];
10983
- const serverScriptPath = candidatePaths.find((p) => existsSync9(p));
10469
+ const serverScriptPath = candidatePaths.find((p) => existsSync8(p));
10984
10470
  if (!serverScriptPath) {
10985
10471
  const getDirectories = (source) => readdirSync3(source, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
10986
10472
  console.error(`[MCP] Server script not found. Tried paths:`, candidatePaths);
@@ -10991,25 +10477,20 @@ var MCPClient = class {
10991
10477
  args = [serverScriptPath];
10992
10478
  console.log(`[MCP] Using server: ${this.serverName} at ${serverScriptPath}`);
10993
10479
  }
10994
- this.transport = new StdioClientTransport({
10480
+ const transportConfig = {
10995
10481
  command,
10996
10482
  args,
10997
10483
  env: {
10998
10484
  ...Object.fromEntries(Object.entries(process.env).filter((entry) => entry[1] !== void 0)),
10999
10485
  ...envVarsObject
11000
- }
11001
- });
10486
+ },
10487
+ // Suppress stderr in CLI context to prevent MCP server startup logs from breaking layout
10488
+ ...this.suppressStderr && { stderr: "ignore" }
10489
+ };
10490
+ this.transport = new StdioClientTransport(transportConfig);
11002
10491
  this.transport.onerror = (error) => {
11003
10492
  console.error(`[MCP] Transport error for ${this.serverName}:`, error);
11004
10493
  };
11005
- this.mcp.onerror = (error) => {
11006
- const isExpectedError = error.message.includes("Connection closed") || error.message.includes("-32000") || error.message.includes("EPIPE") || error.message.includes("ECONNRESET");
11007
- if (isExpectedError) {
11008
- console.log(`[MCP] Expected connection close for ${this.serverName}:`, error.message);
11009
- } else {
11010
- console.error(`[MCP] Unexpected client error for ${this.serverName}:`, error);
11011
- }
11012
- };
11013
10494
  await this.mcp.connect(this.transport);
11014
10495
  await new Promise((resolve3) => setTimeout(resolve3, 100));
11015
10496
  const toolsResult = await this.mcp.listTools();
@@ -11070,6 +10551,7 @@ var MCPClient = class {
11070
10551
  var McpManager = class {
11071
10552
  constructor(config) {
11072
10553
  this.servers = /* @__PURE__ */ new Map();
10554
+ this.connectionStates = /* @__PURE__ */ new Map();
11073
10555
  this.config = config;
11074
10556
  }
11075
10557
  /**
@@ -11078,24 +10560,25 @@ var McpManager = class {
11078
10560
  async initialize() {
11079
10561
  const enabledServers = this.config.mcpServers.filter((s) => s.enabled);
11080
10562
  if (enabledServers.length === 0) {
11081
- logger.info("\u{1F4E1} No MCP servers enabled");
10563
+ logger.debug("\u{1F4E1} No MCP servers enabled");
11082
10564
  return;
11083
10565
  }
11084
- logger.info(`\u{1F4E1} Initializing ${enabledServers.length} MCP server(s)...`);
10566
+ logger.debug(`\u{1F4E1} Initializing ${enabledServers.length} MCP server(s)...`);
11085
10567
  const results = await Promise.allSettled(enabledServers.map((serverConfig) => this.connectServer(serverConfig)));
11086
10568
  const successful = results.filter((r) => r.status === "fulfilled").length;
11087
10569
  const failed = results.filter((r) => r.status === "rejected").length;
11088
10570
  if (successful > 0) {
11089
- logger.info(`\u2705 Connected to ${successful} MCP server(s)`);
10571
+ logger.debug(`\u2705 Connected to ${successful} MCP server(s)`);
11090
10572
  }
11091
10573
  if (failed > 0) {
11092
- logger.warn(`\u26A0\uFE0F Failed to connect to ${failed} MCP server(s)`);
10574
+ logger.debug(`\u26A0\uFE0F Failed to connect to ${failed} MCP server(s)`);
11093
10575
  }
11094
10576
  }
11095
10577
  /**
11096
10578
  * Connect to a single MCP server
11097
10579
  */
11098
10580
  async connectServer(serverConfig) {
10581
+ this.connectionStates.set(serverConfig.name, "connecting");
11099
10582
  try {
11100
10583
  logger.debug(`\u{1F504} Connecting to ${serverConfig.name}...`);
11101
10584
  const envVariables = Object.entries(serverConfig.env).map(([key, value]) => ({
@@ -11106,7 +10589,8 @@ var McpManager = class {
11106
10589
  envVariables,
11107
10590
  name: serverConfig.name,
11108
10591
  command: serverConfig.command,
11109
- args: serverConfig.args
10592
+ args: serverConfig.args,
10593
+ suppressStderr: true
11110
10594
  });
11111
10595
  await client.connectToServer();
11112
10596
  const mcpData = {
@@ -11120,10 +10604,11 @@ var McpManager = class {
11120
10604
  client,
11121
10605
  tools: tools2
11122
10606
  });
11123
- logger.info(`\u2705 Connected to ${serverConfig.name} (${tools2.length} tools)`);
10607
+ this.connectionStates.set(serverConfig.name, "connected");
10608
+ logger.debug(`\u2705 Connected to ${serverConfig.name} (${tools2.length} tools)`);
11124
10609
  } catch (error) {
11125
- logger.error(`\u274C Failed to connect to ${serverConfig.name}:`, error);
11126
- throw error;
10610
+ this.connectionStates.set(serverConfig.name, "failed");
10611
+ logger.debug(`\u274C Failed to connect to ${serverConfig.name}: ${error}`);
11127
10612
  }
11128
10613
  }
11129
10614
  /**
@@ -11176,6 +10661,16 @@ var McpManager = class {
11176
10661
  getServerNames() {
11177
10662
  return Array.from(this.servers.keys());
11178
10663
  }
10664
+ /**
10665
+ * Get connection state for a server
10666
+ */
10667
+ getConnectionState(serverName) {
10668
+ const serverConfig = this.config.mcpServers.find((s) => s.name === serverName);
10669
+ if (!serverConfig?.enabled) {
10670
+ return "disabled";
10671
+ }
10672
+ return this.connectionStates.get(serverName) || "connecting";
10673
+ }
11179
10674
  };
11180
10675
 
11181
10676
  // src/utils/imageRenderer.ts
@@ -11828,7 +11323,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
11828
11323
  // package.json
11829
11324
  var package_default = {
11830
11325
  name: "@bike4mind/cli",
11831
- version: "0.2.13",
11326
+ version: "0.2.14-feat-cli-mcp-management.17477+50a7d8e58",
11832
11327
  type: "module",
11833
11328
  description: "Interactive CLI tool for Bike4Mind with ReAct agents",
11834
11329
  license: "UNLICENSED",
@@ -11933,11 +11428,11 @@ var package_default = {
11933
11428
  zustand: "^4.5.4"
11934
11429
  },
11935
11430
  devDependencies: {
11936
- "@bike4mind/agents": "workspace:*",
11937
- "@bike4mind/common": "workspace:*",
11938
- "@bike4mind/mcp": "workspace:*",
11939
- "@bike4mind/services": "workspace:*",
11940
- "@bike4mind/utils": "workspace:*",
11431
+ "@bike4mind/agents": "0.1.0",
11432
+ "@bike4mind/common": "2.42.1-feat-cli-mcp-management.17477+50a7d8e58",
11433
+ "@bike4mind/mcp": "1.21.3-feat-cli-mcp-management.17477+50a7d8e58",
11434
+ "@bike4mind/services": "2.37.1-feat-cli-mcp-management.17477+50a7d8e58",
11435
+ "@bike4mind/utils": "2.1.8-feat-cli-mcp-management.17477+50a7d8e58",
11941
11436
  "@types/better-sqlite3": "^7.6.13",
11942
11437
  "@types/diff": "^5.0.9",
11943
11438
  "@types/jsonwebtoken": "^9.0.4",
@@ -11950,7 +11445,8 @@ var package_default = {
11950
11445
  tsx: "^4.21.0",
11951
11446
  typescript: "^5.9.3",
11952
11447
  vitest: "^3.2.4"
11953
- }
11448
+ },
11449
+ gitHead: "50a7d8e58345e84ae2bed8bbc91bb61108f58879"
11954
11450
  };
11955
11451
 
11956
11452
  // src/config/constants.ts
@@ -12472,6 +11968,7 @@ function CliApp() {
12472
11968
  const setStoreSession = useCliStore((state2) => state2.setSession);
12473
11969
  const setPermissionPrompt = useCliStore((state2) => state2.setPermissionPrompt);
12474
11970
  const setShowConfigEditor = useCliStore((state2) => state2.setShowConfigEditor);
11971
+ const setShowMcpViewer = useCliStore((state2) => state2.setShowMcpViewer);
12475
11972
  const setExitRequested = useCliStore((state2) => state2.setExitRequested);
12476
11973
  const performCleanup = useCallback(async () => {
12477
11974
  const cleanupTasks = [];
@@ -12508,7 +12005,7 @@ function CliApp() {
12508
12005
  process.exit(0);
12509
12006
  }, 100);
12510
12007
  }, [state.session, state.sessionStore, state.mcpManager, state.agent, state.imageStore]);
12511
- useInput6((input, key) => {
12008
+ useInput8((input, key) => {
12512
12009
  if (key.escape) {
12513
12010
  if (state.abortController) {
12514
12011
  logger.debug("[ABORT] ESC pressed - aborting current operation...");
@@ -12572,7 +12069,7 @@ function CliApp() {
12572
12069
  if (!isAuthenticated) {
12573
12070
  console.log("\u2139\uFE0F AI features disabled. Available commands: /login, /help, /config\n");
12574
12071
  const minimalSession = {
12575
- id: uuidv410(),
12072
+ id: uuidv49(),
12576
12073
  name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
12577
12074
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
12578
12075
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -12616,7 +12113,7 @@ function CliApp() {
12616
12113
  }
12617
12114
  llm.currentModel = modelInfo.id;
12618
12115
  const newSession = {
12619
- id: uuidv410(),
12116
+ id: uuidv49(),
12620
12117
  name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
12621
12118
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
12622
12119
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -12684,10 +12181,10 @@ function CliApp() {
12684
12181
  await mcpManager.initialize();
12685
12182
  const mcpTools = mcpManager.getTools();
12686
12183
  if (mcpTools.length > 0) {
12687
- const toolCounts = mcpManager.getToolCount();
12688
- toolCounts.forEach(({ serverName, count }) => {
12689
- console.log(` \u{1F4E1} ${serverName}: ${count} tool(s)`);
12690
- });
12184
+ const toolNames = mcpTools.map((t) => t.toolSchema.name).join(", ");
12185
+ console.log(`\u{1F4E1} Loaded ${mcpTools.length} MCP tool(s): ${toolNames}`);
12186
+ } else {
12187
+ console.log(`\u{1F4E1} No MCP tools loaded`);
12691
12188
  }
12692
12189
  const subagentConfigs = getDefaultSubagentConfigs();
12693
12190
  if (config.subagents) {
@@ -12719,6 +12216,9 @@ function CliApp() {
12719
12216
  const writeTodosTool = createWriteTodosTool(todoStore);
12720
12217
  const allTools = [...b4mTools, ...mcpTools, subagentDelegateTool, writeTodosTool];
12721
12218
  console.log(`\u{1F916} Subagent delegation enabled (explore, plan, review)`);
12219
+ logger.debug(
12220
+ `Total tools available to agent: ${allTools.length} (${b4mTools.length} B4M + ${mcpTools.length} MCP + 2 CLI)`
12221
+ );
12722
12222
  const projectDir = state.configStore.getProjectConfigDir();
12723
12223
  const contextResult = await loadContextFiles(projectDir);
12724
12224
  if (contextResult.globalContext) {
@@ -12858,13 +12358,13 @@ ${contextResult.mergedContent}` : "";
12858
12358
  messageContent = multimodalMessage.content;
12859
12359
  }
12860
12360
  const userMessage = {
12861
- id: uuidv410(),
12361
+ id: uuidv49(),
12862
12362
  role: "user",
12863
12363
  content: userMessageContent,
12864
12364
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
12865
12365
  };
12866
12366
  const pendingAssistantMessage = {
12867
- id: uuidv410(),
12367
+ id: uuidv49(),
12868
12368
  role: "assistant",
12869
12369
  content: "...",
12870
12370
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -13029,13 +12529,13 @@ ${contextResult.mergedContent}` : "";
13029
12529
  userMessageContent = message;
13030
12530
  }
13031
12531
  const userMessage = {
13032
- id: uuidv410(),
12532
+ id: uuidv49(),
13033
12533
  role: "user",
13034
12534
  content: userMessageContent,
13035
12535
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
13036
12536
  };
13037
12537
  const pendingAssistantMessage = {
13038
- id: uuidv410(),
12538
+ id: uuidv49(),
13039
12539
  role: "assistant",
13040
12540
  content: "...",
13041
12541
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -13103,7 +12603,7 @@ ${contextResult.mergedContent}` : "";
13103
12603
  const currentSession = useCliStore.getState().session;
13104
12604
  if (currentSession) {
13105
12605
  const cancelMessage = {
13106
- id: uuidv410(),
12606
+ id: uuidv49(),
13107
12607
  role: "assistant",
13108
12608
  content: "\u26A0\uFE0F Operation cancelled by user",
13109
12609
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -13154,13 +12654,13 @@ ${contextResult.mergedContent}` : "";
13154
12654
  isError = true;
13155
12655
  }
13156
12656
  const userMessage = {
13157
- id: uuidv410(),
12657
+ id: uuidv49(),
13158
12658
  role: "user",
13159
12659
  content: `$ ${command}`,
13160
12660
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
13161
12661
  };
13162
12662
  const assistantMessage = {
13163
- id: uuidv410(),
12663
+ id: uuidv49(),
13164
12664
  role: "assistant",
13165
12665
  content: isError ? `\u274C Error:
13166
12666
  ${output}` : output.trim() || "(no output)",
@@ -13570,7 +13070,7 @@ Custom Commands:
13570
13070
  console.clear();
13571
13071
  const model = state.session?.model || state.config?.defaultModel || "claude-sonnet";
13572
13072
  const newSession = {
13573
- id: uuidv410(),
13073
+ id: uuidv49(),
13574
13074
  name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
13575
13075
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
13576
13076
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -13862,6 +13362,11 @@ No usage data available for the last ${USAGE_DAYS} days.`);
13862
13362
  }
13863
13363
  break;
13864
13364
  }
13365
+ case "mcp":
13366
+ case "mcp:list": {
13367
+ setShowMcpViewer(true);
13368
+ break;
13369
+ }
13865
13370
  default:
13866
13371
  console.log(`Unknown command: /${command}`);
13867
13372
  console.log("Type /help for available commands");
@@ -13893,12 +13398,12 @@ No usage data available for the last ${USAGE_DAYS} days.`);
13893
13398
  }
13894
13399
  };
13895
13400
  if (initError) {
13896
- return /* @__PURE__ */ React17.createElement(Box16, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React17.createElement(Text16, { color: "red", bold: true }, "\u274C Initialization Error"), /* @__PURE__ */ React17.createElement(Text16, null, initError), /* @__PURE__ */ React17.createElement(Text16, { dimColor: true }, "\n", "Tip: Run /config to set up your API keys"));
13401
+ return /* @__PURE__ */ React18.createElement(Box17, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React18.createElement(Text17, { color: "red", bold: true }, "\u274C Initialization Error"), /* @__PURE__ */ React18.createElement(Text17, null, initError), /* @__PURE__ */ React18.createElement(Text17, { dimColor: true }, "\n", "Tip: Run /config to set up your API keys"));
13897
13402
  }
13898
13403
  if (state.trustLocationSelector) {
13899
13404
  const projectDir = state.configStore.getProjectConfigDir();
13900
13405
  const inProject = projectDir !== null;
13901
- return /* @__PURE__ */ React17.createElement(
13406
+ return /* @__PURE__ */ React18.createElement(
13902
13407
  TrustLocationSelector,
13903
13408
  {
13904
13409
  inProject,
@@ -13916,7 +13421,7 @@ No usage data available for the last ${USAGE_DAYS} days.`);
13916
13421
  );
13917
13422
  }
13918
13423
  if (state.rewindSelector && state.session) {
13919
- return /* @__PURE__ */ React17.createElement(
13424
+ return /* @__PURE__ */ React18.createElement(
13920
13425
  RewindSelector,
13921
13426
  {
13922
13427
  messages: state.session.messages,
@@ -13934,7 +13439,7 @@ No usage data available for the last ${USAGE_DAYS} days.`);
13934
13439
  );
13935
13440
  }
13936
13441
  if (state.sessionSelector) {
13937
- return /* @__PURE__ */ React17.createElement(
13442
+ return /* @__PURE__ */ React18.createElement(
13938
13443
  SessionSelector,
13939
13444
  {
13940
13445
  sessions: state.sessionSelector.sessions,
@@ -13954,7 +13459,7 @@ No usage data available for the last ${USAGE_DAYS} days.`);
13954
13459
  }
13955
13460
  if (state.showLoginFlow) {
13956
13461
  const loginApiUrl = getApiUrl(state.config?.apiConfig);
13957
- return /* @__PURE__ */ React17.createElement(
13462
+ return /* @__PURE__ */ React18.createElement(
13958
13463
  LoginFlow,
13959
13464
  {
13960
13465
  apiUrl: loginApiUrl,
@@ -13977,10 +13482,10 @@ No usage data available for the last ${USAGE_DAYS} days.`);
13977
13482
  );
13978
13483
  }
13979
13484
  if (!isInitialized) {
13980
- return /* @__PURE__ */ React17.createElement(Box16, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React17.createElement(Text16, null, "\u{1F680} Initializing..."));
13485
+ return /* @__PURE__ */ React18.createElement(Box17, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React18.createElement(Text17, null, "\u{1F680} Initializing..."));
13981
13486
  }
13982
13487
  const allCommands = mergeCommands(state.customCommandStore.getAllCommands());
13983
- return /* @__PURE__ */ React17.createElement(
13488
+ return /* @__PURE__ */ React18.createElement(
13984
13489
  App,
13985
13490
  {
13986
13491
  onMessage: handleMessage,
@@ -13996,6 +13501,7 @@ No usage data available for the last ${USAGE_DAYS} days.`);
13996
13501
  onPrefillConsumed: () => {
13997
13502
  setState((prev) => ({ ...prev, prefillInput: void 0 }));
13998
13503
  },
13504
+ mcpManager: state.mcpManager ?? void 0,
13999
13505
  onPermissionResponse: (response) => {
14000
13506
  if (state.permissionPrompt) {
14001
13507
  state.permissionPrompt.resolve({ action: response });
@@ -14021,6 +13527,6 @@ var isDevMode = import.meta.url.includes("/src/") || process.env.NODE_ENV === "d
14021
13527
  if (isDevMode) {
14022
13528
  logger.debug("\u{1F527} Running in development mode (using TypeScript source)\n");
14023
13529
  }
14024
- render(/* @__PURE__ */ React17.createElement(CliApp, null), {
13530
+ render(/* @__PURE__ */ React18.createElement(CliApp, null), {
14025
13531
  exitOnCtrlC: false
14026
13532
  });