@bike4mind/cli 0.2.10-feat-explore-subagent-implementation.17263 → 0.2.10-feat-cli-message-unique-ids.17271

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.
Files changed (2) hide show
  1. package/dist/index.js +1676 -1042
  2. package/package.json +7 -6
package/dist/index.js CHANGED
@@ -82,7 +82,7 @@ import {
82
82
  import React17, { useState as useState8, useEffect as useEffect3, useCallback, useRef as useRef2 } from "react";
83
83
  import { render, Box as Box16, Text as Text16, useApp, useInput as useInput6 } from "ink";
84
84
  import { execSync } from "child_process";
85
- import { v4 as uuidv49 } from "uuid";
85
+ import { v4 as uuidv410 } from "uuid";
86
86
 
87
87
  // src/components/App.tsx
88
88
  import React11, { useState as useState4 } from "react";
@@ -210,7 +210,8 @@ function CommandAutocomplete({ commands, selectedIndex }) {
210
210
  return /* @__PURE__ */ React3.createElement(Box2, { flexDirection: "column", marginLeft: 2, marginTop: 1 }, /* @__PURE__ */ React3.createElement(Box2, { marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, commands.length === 1 ? "1 command" : `${commands.length} commands`, " \u2022 Use \u2191\u2193 to navigate, Enter to select")), commands.map((cmd, index) => {
211
211
  const args = cmd.args ? ` ${cmd.args}` : "";
212
212
  const isSelected = index === selectedIndex;
213
- return /* @__PURE__ */ React3.createElement(Box2, { key: cmd.name, marginLeft: 1 }, /* @__PURE__ */ React3.createElement(Text3, { color: isSelected ? "cyan" : void 0, bold: isSelected }, isSelected ? "\u25B8 " : " ", "/", cmd.name, args, " - ", cmd.description));
213
+ const sourceIcon = cmd.source === "global" ? "\u{1F3E0} " : cmd.source === "project" ? "\u{1F4C1} " : cmd.source === "built-in" ? "\u{1F527} " : "";
214
+ return /* @__PURE__ */ React3.createElement(Box2, { key: cmd.name, marginLeft: 1 }, /* @__PURE__ */ React3.createElement(Text3, { color: isSelected ? "cyan" : void 0, bold: isSelected }, isSelected ? "\u25B8 " : " ", sourceIcon, "/", cmd.name, args, " - ", cmd.description));
214
215
  }));
215
216
  }
216
217
 
@@ -311,7 +312,7 @@ function searchFiles(query) {
311
312
  searchPool = files;
312
313
  }
313
314
  }
314
- const fuse2 = new Fuse(searchPool, {
315
+ const fuse = new Fuse(searchPool, {
315
316
  keys: [{ name: "path", weight: 1 }],
316
317
  threshold: 0.4,
317
318
  // Allow some fuzzy matching
@@ -320,7 +321,7 @@ function searchFiles(query) {
320
321
  // Use extended search for better path matching
321
322
  useExtendedSearch: false
322
323
  });
323
- const results = fuse2.search(query);
324
+ const results = fuse.search(query);
324
325
  return results.slice(0, 20).map((result) => result.item);
325
326
  }
326
327
  function isPathWithinCwd(filePath) {
@@ -495,11 +496,61 @@ var COMMANDS = [
495
496
  name: "rewind",
496
497
  description: "Rewind conversation to a previous point",
497
498
  aliases: ["undo"]
499
+ },
500
+ {
501
+ name: "project-config",
502
+ description: "Show merged project configuration"
503
+ },
504
+ {
505
+ name: "commands",
506
+ description: "List all custom commands"
507
+ },
508
+ {
509
+ name: "commands:new",
510
+ description: "Create a new custom command",
511
+ args: "<name>"
512
+ },
513
+ {
514
+ name: "commands:reload",
515
+ description: "Reload custom commands from disk"
498
516
  }
499
517
  ];
518
+ function getAllCommandNames() {
519
+ const names = [];
520
+ for (const cmd of COMMANDS) {
521
+ names.push(cmd.name);
522
+ if (cmd.aliases) {
523
+ names.push(...cmd.aliases);
524
+ }
525
+ }
526
+ return names;
527
+ }
528
+ function isBuiltInCommand(name) {
529
+ return getAllCommandNames().includes(name);
530
+ }
531
+ function customCommandToDefinition(customCommand) {
532
+ return {
533
+ name: customCommand.name,
534
+ description: customCommand.description,
535
+ args: customCommand.argumentHint,
536
+ source: customCommand.source
537
+ };
538
+ }
539
+ function mergeCommands(customCommands) {
540
+ const builtInCommands = COMMANDS.map((cmd) => ({ ...cmd, source: "built-in" }));
541
+ const customDefinitions = customCommands.filter((cmd) => !isBuiltInCommand(cmd.name)).map(customCommandToDefinition);
542
+ const conflicts = customCommands.filter((cmd) => isBuiltInCommand(cmd.name));
543
+ if (conflicts.length > 0) {
544
+ console.warn(
545
+ "Warning: The following custom commands have names that conflict with built-in commands and will be ignored:",
546
+ conflicts.map((cmd) => cmd.name).join(", ")
547
+ );
548
+ }
549
+ return [...builtInCommands, ...customDefinitions];
550
+ }
500
551
 
501
552
  // src/utils/fuzzySearch.ts
502
- var fuse = new Fuse2(COMMANDS, {
553
+ var fuseOptions = {
503
554
  keys: [
504
555
  { name: "name", weight: 0.7 },
505
556
  // Prioritize command name
@@ -510,11 +561,12 @@ var fuse = new Fuse2(COMMANDS, {
510
561
  // 0 = perfect match, 1 = match anything
511
562
  includeScore: true,
512
563
  minMatchCharLength: 1
513
- });
514
- function searchCommands(query) {
564
+ };
565
+ function searchCommands(query, commands = COMMANDS) {
515
566
  if (!query || query.trim() === "") {
516
- return COMMANDS;
567
+ return commands;
517
568
  }
569
+ const fuse = new Fuse2(commands, fuseOptions);
518
570
  const results = fuse.search(query);
519
571
  return results.map((result) => result.item);
520
572
  }
@@ -737,6 +789,7 @@ function InputPrompt({
737
789
  onImageDetected,
738
790
  disabled = false,
739
791
  history = [],
792
+ commands = [],
740
793
  prefillInput,
741
794
  onPrefillConsumed,
742
795
  onBashModeChange
@@ -762,8 +815,8 @@ function InputPrompt({
762
815
  const commandQuery = shouldShowCommandAutocomplete ? value.slice(1) : "";
763
816
  const filteredCommands = useMemo(() => {
764
817
  if (!shouldShowCommandAutocomplete) return [];
765
- return searchCommands(commandQuery);
766
- }, [shouldShowCommandAutocomplete, commandQuery]);
818
+ return searchCommands(commandQuery, commands);
819
+ }, [shouldShowCommandAutocomplete, commandQuery, commands]);
767
820
  const filteredFiles = useMemo(() => {
768
821
  if (!fileAutocomplete?.active) return [];
769
822
  return searchFiles(fileAutocomplete.query);
@@ -1414,6 +1467,7 @@ function App({
1414
1467
  onPermissionResponse,
1415
1468
  onImageDetected,
1416
1469
  commandHistory = [],
1470
+ commands = [],
1417
1471
  config,
1418
1472
  availableModels = [],
1419
1473
  onSaveConfig,
@@ -1469,7 +1523,7 @@ ${errorBlock}`;
1469
1523
  onSave: onSaveConfig,
1470
1524
  onClose: () => setShowConfigEditor(false)
1471
1525
  }
1472
- )) : permissionPrompt ? /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(
1526
+ )) : /* @__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(
1473
1527
  PermissionPrompt,
1474
1528
  {
1475
1529
  toolName: permissionPrompt.toolName,
@@ -1478,7 +1532,7 @@ ${errorBlock}`;
1478
1532
  canBeTrusted: permissionPrompt.canBeTrusted,
1479
1533
  onResponse: onPermissionResponse
1480
1534
  }
1481
- )) : /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Static, { items: messages }, (message, index) => /* @__PURE__ */ React11.createElement(Box10, { key: `${message.timestamp}-${message.role}-${index}`, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(MessageItem, { message }))), /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column" }, pendingMessages.map((message, index) => /* @__PURE__ */ React11.createElement(Box10, { key: `pending-${message.timestamp}-${index}`, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(MessageItem, { message })))), /* @__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(
1535
+ )), !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(
1482
1536
  InputPrompt,
1483
1537
  {
1484
1538
  onSubmit: handleSubmit,
@@ -1486,6 +1540,7 @@ ${errorBlock}`;
1486
1540
  onImageDetected,
1487
1541
  disabled: isThinking,
1488
1542
  history: commandHistory,
1543
+ commands,
1489
1544
  prefillInput,
1490
1545
  onPrefillConsumed,
1491
1546
  onBashModeChange: setIsBashMode
@@ -1877,6 +1932,7 @@ function LoginFlow({ apiUrl = "http://localhost:3000", configStore, onSuccess, o
1877
1932
  import { promises as fs3 } from "fs";
1878
1933
  import path3 from "path";
1879
1934
  import { homedir } from "os";
1935
+ import { v4 as uuidv4 } from "uuid";
1880
1936
  var SessionStore = class {
1881
1937
  constructor(basePath) {
1882
1938
  this.basePath = basePath || path3.join(homedir(), ".bike4mind", "sessions");
@@ -1912,7 +1968,14 @@ var SessionStore = class {
1912
1968
  const filePath = path3.join(this.basePath, `${id}.json`);
1913
1969
  try {
1914
1970
  const data = await fs3.readFile(filePath, "utf-8");
1915
- return JSON.parse(data);
1971
+ const session = JSON.parse(data);
1972
+ session.messages = session.messages.map((msg) => {
1973
+ if (!msg.id) {
1974
+ return { ...msg, id: uuidv4() };
1975
+ }
1976
+ return msg;
1977
+ });
1978
+ return session;
1916
1979
  } catch (error) {
1917
1980
  if (error.code === "ENOENT") {
1918
1981
  return null;
@@ -1941,7 +2004,14 @@ var SessionStore = class {
1941
2004
  jsonFiles.map(async (file) => {
1942
2005
  const filePath = path3.join(this.basePath, file);
1943
2006
  const data = await fs3.readFile(filePath, "utf-8");
1944
- return JSON.parse(data);
2007
+ const session = JSON.parse(data);
2008
+ session.messages = session.messages.map((msg) => {
2009
+ if (!msg.id) {
2010
+ return { ...msg, id: uuidv4() };
2011
+ }
2012
+ return msg;
2013
+ });
2014
+ return session;
1945
2015
  })
1946
2016
  );
1947
2017
  return sessions.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime());
@@ -1995,7 +2065,7 @@ var SessionStore = class {
1995
2065
  import { promises as fs4, existsSync as existsSync3 } from "fs";
1996
2066
  import path4 from "path";
1997
2067
  import { homedir as homedir2 } from "os";
1998
- import { v4 as uuidv4 } from "uuid";
2068
+ import { v4 as uuidv42 } from "uuid";
1999
2069
  import { z } from "zod";
2000
2070
  var AuthTokensSchema = z.object({
2001
2071
  accessToken: z.string(),
@@ -2089,7 +2159,7 @@ var ProjectLocalConfigSchema = z.object({
2089
2159
  });
2090
2160
  var DEFAULT_CONFIG = {
2091
2161
  version: "0.1.0",
2092
- userId: uuidv4(),
2162
+ userId: uuidv42(),
2093
2163
  defaultModel: "claude-sonnet-4-5-20250929",
2094
2164
  toolApiKeys: {
2095
2165
  openweather: void 0,
@@ -2371,7 +2441,7 @@ var ConfigStore = class {
2371
2441
  * Reset configuration to defaults
2372
2442
  */
2373
2443
  async reset() {
2374
- this.config = { ...DEFAULT_CONFIG, userId: uuidv4() };
2444
+ this.config = { ...DEFAULT_CONFIG, userId: uuidv42() };
2375
2445
  await this.save();
2376
2446
  return this.config;
2377
2447
  }
@@ -2708,6 +2778,261 @@ var CommandHistoryStore = class {
2708
2778
  }
2709
2779
  };
2710
2780
 
2781
+ // src/storage/CustomCommandStore.ts
2782
+ import fs6 from "fs/promises";
2783
+ import path6 from "path";
2784
+ import os from "os";
2785
+
2786
+ // src/utils/commandParser.ts
2787
+ import matter from "gray-matter";
2788
+ import { z as z2 } from "zod";
2789
+ var FrontmatterSchema = z2.object({
2790
+ description: z2.string().optional(),
2791
+ "argument-hint": z2.string().optional(),
2792
+ model: z2.string().optional(),
2793
+ // Future fields (ignored for now):
2794
+ "allowed-tools": z2.any().optional(),
2795
+ context: z2.any().optional(),
2796
+ agent: z2.any().optional(),
2797
+ "disable-model-invocation": z2.any().optional(),
2798
+ hooks: z2.any().optional()
2799
+ });
2800
+ function extractDescriptionFromBody(body) {
2801
+ const lines = body.trim().split("\n");
2802
+ for (const line of lines) {
2803
+ const trimmed = line.trim();
2804
+ if (trimmed && !trimmed.startsWith("#")) {
2805
+ return trimmed.length > 100 ? trimmed.substring(0, 97) + "..." : trimmed;
2806
+ }
2807
+ }
2808
+ return "Custom command";
2809
+ }
2810
+ function parseCommandFile(fileContent, filePath, commandName, source) {
2811
+ try {
2812
+ const { data: frontmatter, content: body } = matter(fileContent);
2813
+ const validationResult = FrontmatterSchema.safeParse(frontmatter);
2814
+ if (!validationResult.success) {
2815
+ console.warn(
2816
+ `Warning: Invalid frontmatter in ${filePath}:`,
2817
+ validationResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join(", ")
2818
+ );
2819
+ }
2820
+ const validFrontmatter = validationResult.success ? validationResult.data : {};
2821
+ const description = validFrontmatter.description || extractDescriptionFromBody(body) || "Custom command";
2822
+ return {
2823
+ name: commandName,
2824
+ description,
2825
+ argumentHint: validFrontmatter["argument-hint"],
2826
+ model: validFrontmatter.model,
2827
+ body: body.trim(),
2828
+ source,
2829
+ filePath
2830
+ };
2831
+ } catch (error) {
2832
+ throw new Error(
2833
+ `Failed to parse command file ${filePath}: ${error instanceof Error ? error.message : String(error)}`
2834
+ );
2835
+ }
2836
+ }
2837
+ function isValidCommandName(name) {
2838
+ if (!name || name.trim().length === 0) {
2839
+ return false;
2840
+ }
2841
+ const validPattern = /^[a-z0-9-_:]+$/i;
2842
+ return validPattern.test(name);
2843
+ }
2844
+ function extractCommandName(filename) {
2845
+ if (!filename.endsWith(".md")) {
2846
+ return null;
2847
+ }
2848
+ const name = filename.slice(0, -3);
2849
+ if (!isValidCommandName(name)) {
2850
+ return null;
2851
+ }
2852
+ return name;
2853
+ }
2854
+
2855
+ // src/storage/CustomCommandStore.ts
2856
+ var CustomCommandStore = class {
2857
+ constructor(projectRoot) {
2858
+ this.commands = /* @__PURE__ */ new Map();
2859
+ this.globalCommandsDir = path6.join(os.homedir(), ".bike4mind", "commands");
2860
+ this.projectCommandsDir = path6.join(projectRoot || process.cwd(), ".bike4mind", "commands");
2861
+ }
2862
+ /**
2863
+ * Loads all custom commands from both global and project directories
2864
+ * Project commands override global commands with the same name
2865
+ */
2866
+ async loadCommands() {
2867
+ this.commands.clear();
2868
+ await this.loadCommandsFromDirectory(this.globalCommandsDir, "global");
2869
+ await this.loadCommandsFromDirectory(this.projectCommandsDir, "project");
2870
+ }
2871
+ /**
2872
+ * Recursively scans a directory for .md files and loads them as commands
2873
+ *
2874
+ * @param directory - Directory to scan
2875
+ * @param source - Source identifier ('global' or 'project')
2876
+ */
2877
+ async loadCommandsFromDirectory(directory, source) {
2878
+ try {
2879
+ const stats = await fs6.stat(directory);
2880
+ if (!stats.isDirectory()) {
2881
+ return;
2882
+ }
2883
+ const commandFiles = await this.findCommandFiles(directory);
2884
+ for (const filePath of commandFiles) {
2885
+ try {
2886
+ await this.loadCommandFile(filePath, source);
2887
+ } catch (error) {
2888
+ console.warn(
2889
+ `Failed to load command from ${filePath}:`,
2890
+ error instanceof Error ? error.message : String(error)
2891
+ );
2892
+ }
2893
+ }
2894
+ } catch (error) {
2895
+ if (error.code !== "ENOENT") {
2896
+ console.warn(
2897
+ `Error accessing ${source} commands directory ${directory}:`,
2898
+ error instanceof Error ? error.message : String(error)
2899
+ );
2900
+ }
2901
+ }
2902
+ }
2903
+ /**
2904
+ * Recursively finds all .md files in a directory
2905
+ *
2906
+ * @param directory - Directory to search
2907
+ * @returns Array of full file paths to .md files
2908
+ */
2909
+ async findCommandFiles(directory) {
2910
+ const files = [];
2911
+ try {
2912
+ const entries = await fs6.readdir(directory, { withFileTypes: true });
2913
+ for (const entry of entries) {
2914
+ const fullPath = path6.join(directory, entry.name);
2915
+ if (entry.isDirectory()) {
2916
+ const subFiles = await this.findCommandFiles(fullPath);
2917
+ files.push(...subFiles);
2918
+ } else if (entry.isFile() && entry.name.endsWith(".md")) {
2919
+ files.push(fullPath);
2920
+ }
2921
+ }
2922
+ } catch (error) {
2923
+ console.warn(`Error reading directory ${directory}:`, error instanceof Error ? error.message : String(error));
2924
+ }
2925
+ return files;
2926
+ }
2927
+ /**
2928
+ * Loads a single command file
2929
+ *
2930
+ * @param filePath - Full path to the command file
2931
+ * @param source - Source identifier ('global' or 'project')
2932
+ */
2933
+ async loadCommandFile(filePath, source) {
2934
+ const filename = path6.basename(filePath);
2935
+ const commandName = extractCommandName(filename);
2936
+ if (!commandName) {
2937
+ console.warn(`Invalid command filename: ${filename} (must end with .md and have valid name)`);
2938
+ return;
2939
+ }
2940
+ const fileContent = await fs6.readFile(filePath, "utf-8");
2941
+ const command = parseCommandFile(fileContent, filePath, commandName, source);
2942
+ const existing = this.commands.get(commandName);
2943
+ if (existing && existing.source === "project" && source === "global") {
2944
+ return;
2945
+ }
2946
+ this.commands.set(commandName, command);
2947
+ }
2948
+ /**
2949
+ * Gets a command by name
2950
+ *
2951
+ * @param name - Command name
2952
+ * @returns CustomCommand if found, undefined otherwise
2953
+ */
2954
+ getCommand(name) {
2955
+ return this.commands.get(name);
2956
+ }
2957
+ /**
2958
+ * Gets all loaded commands
2959
+ *
2960
+ * @returns Array of all custom commands
2961
+ */
2962
+ getAllCommands() {
2963
+ return Array.from(this.commands.values());
2964
+ }
2965
+ /**
2966
+ * Gets commands filtered by source
2967
+ *
2968
+ * @param source - Filter by 'global' or 'project'
2969
+ * @returns Array of commands from the specified source
2970
+ */
2971
+ getCommandsBySource(source) {
2972
+ return this.getAllCommands().filter((cmd) => cmd.source === source);
2973
+ }
2974
+ /**
2975
+ * Checks if a command name exists
2976
+ *
2977
+ * @param name - Command name to check
2978
+ * @returns true if command exists
2979
+ */
2980
+ hasCommand(name) {
2981
+ return this.commands.has(name);
2982
+ }
2983
+ /**
2984
+ * Gets the number of loaded commands
2985
+ *
2986
+ * @returns Number of custom commands
2987
+ */
2988
+ getCommandCount() {
2989
+ return this.commands.size;
2990
+ }
2991
+ /**
2992
+ * Reloads all commands from directories
2993
+ * Useful for the /commands:reload command
2994
+ */
2995
+ async reloadCommands() {
2996
+ await this.loadCommands();
2997
+ }
2998
+ /**
2999
+ * Creates a new command file from a template
3000
+ *
3001
+ * @param name - Command name
3002
+ * @param isGlobal - If true, creates in global directory, otherwise project directory
3003
+ * @returns Path to the created file
3004
+ */
3005
+ async createCommandFile(name, isGlobal = false) {
3006
+ const targetDir = isGlobal ? this.globalCommandsDir : this.projectCommandsDir;
3007
+ const filePath = path6.join(targetDir, `${name}.md`);
3008
+ try {
3009
+ await fs6.access(filePath);
3010
+ throw new Error(`Command file already exists: ${filePath}`);
3011
+ } catch (error) {
3012
+ if (error.code !== "ENOENT") {
3013
+ throw error;
3014
+ }
3015
+ }
3016
+ await fs6.mkdir(targetDir, { recursive: true });
3017
+ const template = `---
3018
+ description: ${name} command
3019
+ argument-hint: [args]
3020
+ ---
3021
+
3022
+ # ${name}
3023
+
3024
+ Replace this with your command template.
3025
+
3026
+ You can use:
3027
+ - $ARGUMENTS for all arguments
3028
+ - $1, $2, etc. for positional arguments
3029
+ - @filename for file references
3030
+ `;
3031
+ await fs6.writeFile(filePath, template, "utf-8");
3032
+ return filePath;
3033
+ }
3034
+ };
3035
+
2711
3036
  // ../../b4m-core/packages/agents/src/ReActAgent.ts
2712
3037
  import { EventEmitter } from "events";
2713
3038
  var ReActAgent = class extends EventEmitter {
@@ -3021,38 +3346,38 @@ Remember: You are an autonomous AGENT. Act independently and solve problems proa
3021
3346
  // ../../b4m-core/packages/services/dist/src/referService/generateCodes.js
3022
3347
  import { randomBytes } from "crypto";
3023
3348
  import range from "lodash/range.js";
3024
- import { z as z2 } from "zod";
3025
- var generateReferralCodesSchema = z2.object({
3026
- count: z2.number().optional(),
3027
- unlimitedUse: z2.boolean().optional(),
3028
- expiresAt: z2.date().optional()
3349
+ import { z as z3 } from "zod";
3350
+ var generateReferralCodesSchema = z3.object({
3351
+ count: z3.number().optional(),
3352
+ unlimitedUse: z3.boolean().optional(),
3353
+ expiresAt: z3.date().optional()
3029
3354
  });
3030
3355
 
3031
3356
  // ../../b4m-core/packages/services/dist/src/referService/delete.js
3032
- import { z as z3 } from "zod";
3033
- var deleteInviteCodesSchema = z3.object({
3034
- ids: z3.array(z3.string())
3357
+ import { z as z4 } from "zod";
3358
+ var deleteInviteCodesSchema = z4.object({
3359
+ ids: z4.array(z4.string())
3035
3360
  });
3036
3361
 
3037
3362
  // ../../b4m-core/packages/services/dist/src/userService/login.js
3038
- import { z as z4 } from "zod";
3363
+ import { z as z5 } from "zod";
3039
3364
  import bcrypt from "bcryptjs";
3040
- var loginUserSchema = z4.object({
3041
- usernameOrEmail: z4.string(),
3042
- password: z4.string(),
3043
- metadata: z4.object({
3044
- loginTime: z4.date(),
3045
- userAgent: z4.string(),
3046
- browser: z4.string(),
3047
- operatingSystem: z4.string(),
3048
- deviceType: z4.string(),
3049
- screenResolution: z4.string(),
3050
- viewportSize: z4.string(),
3051
- colorDepth: z4.number(),
3052
- pixelDepth: z4.number(),
3053
- devicePixelRatio: z4.number(),
3054
- ip: z4.string().optional().default(""),
3055
- location: z4.string().optional()
3365
+ var loginUserSchema = z5.object({
3366
+ usernameOrEmail: z5.string(),
3367
+ password: z5.string(),
3368
+ metadata: z5.object({
3369
+ loginTime: z5.date(),
3370
+ userAgent: z5.string(),
3371
+ browser: z5.string(),
3372
+ operatingSystem: z5.string(),
3373
+ deviceType: z5.string(),
3374
+ screenResolution: z5.string(),
3375
+ viewportSize: z5.string(),
3376
+ colorDepth: z5.number(),
3377
+ pixelDepth: z5.number(),
3378
+ devicePixelRatio: z5.number(),
3379
+ ip: z5.string().optional().default(""),
3380
+ location: z5.string().optional()
3056
3381
  }).optional()
3057
3382
  });
3058
3383
 
@@ -3062,78 +3387,78 @@ import escapeRegExp from "lodash/escapeRegExp.js";
3062
3387
 
3063
3388
  // ../../b4m-core/packages/services/dist/src/userService/forgotPassword.js
3064
3389
  import { randomUUID } from "crypto";
3065
- import { z as z5 } from "zod";
3066
- var forgotPasswordUserSchema = z5.object({
3067
- email: z5.string().email()
3390
+ import { z as z6 } from "zod";
3391
+ var forgotPasswordUserSchema = z6.object({
3392
+ email: z6.string().email()
3068
3393
  });
3069
3394
 
3070
3395
  // ../../b4m-core/packages/services/dist/src/userService/update.js
3071
3396
  import bcrypt3 from "bcryptjs";
3072
- import { z as z6 } from "zod";
3073
- var updateUserSchema = z6.object({
3074
- name: z6.string().optional(),
3075
- username: z6.string().optional(),
3397
+ import { z as z7 } from "zod";
3398
+ var updateUserSchema = z7.object({
3399
+ name: z7.string().optional(),
3400
+ username: z7.string().optional(),
3076
3401
  // email field removed - users must use the secure email change verification flow
3077
3402
  // See requestEmailChange and verifyEmailChange in userService
3078
- password: z6.string().nullable().optional(),
3079
- team: z6.string().nullable().optional(),
3080
- role: z6.string().nullable().optional(),
3081
- phone: z6.string().nullable().optional(),
3082
- preferredLanguage: z6.string().nullable().optional(),
3083
- preferredContact: z6.string().nullable().optional(),
3084
- preferredVoice: z6.string().nullable().optional(),
3085
- tshirtSize: z6.string().nullable().optional(),
3086
- geoLocation: z6.string().nullable().optional(),
3087
- lastNotebookId: z6.string().nullable().optional(),
3088
- tags: z6.array(z6.string()).nullable().optional(),
3089
- lastCreditsPurchasedAt: z6.date().nullable().optional(),
3090
- systemFiles: z6.array(z6.object({
3091
- fileId: z6.string(),
3092
- enabled: z6.boolean()
3403
+ password: z7.string().nullable().optional(),
3404
+ team: z7.string().nullable().optional(),
3405
+ role: z7.string().nullable().optional(),
3406
+ phone: z7.string().nullable().optional(),
3407
+ preferredLanguage: z7.string().nullable().optional(),
3408
+ preferredContact: z7.string().nullable().optional(),
3409
+ preferredVoice: z7.string().nullable().optional(),
3410
+ tshirtSize: z7.string().nullable().optional(),
3411
+ geoLocation: z7.string().nullable().optional(),
3412
+ lastNotebookId: z7.string().nullable().optional(),
3413
+ tags: z7.array(z7.string()).nullable().optional(),
3414
+ lastCreditsPurchasedAt: z7.date().nullable().optional(),
3415
+ systemFiles: z7.array(z7.object({
3416
+ fileId: z7.string(),
3417
+ enabled: z7.boolean()
3093
3418
  })).nullable().optional(),
3094
- securityQuestions: z6.array(z6.object({ question: z6.string(), answer: z6.string() })).nullable().optional(),
3095
- photoUrl: z6.string().nullable().optional(),
3096
- showCreditsUsed: z6.boolean().optional()
3419
+ securityQuestions: z7.array(z7.object({ question: z7.string(), answer: z7.string() })).nullable().optional(),
3420
+ photoUrl: z7.string().nullable().optional(),
3421
+ showCreditsUsed: z7.boolean().optional()
3097
3422
  });
3098
3423
 
3099
3424
  // ../../b4m-core/packages/services/dist/src/userService/adminUpdate.js
3100
- import { z as z8 } from "zod";
3425
+ import { z as z9 } from "zod";
3101
3426
 
3102
3427
  // ../../b4m-core/packages/services/dist/src/friendshipService/sendFriendRequest.js
3103
- import { z as z7 } from "zod";
3104
- var sendFriendRequestSchema = z7.object({
3105
- requesterId: z7.string(),
3106
- recipientId: z7.string(),
3107
- message: z7.string().optional()
3428
+ import { z as z8 } from "zod";
3429
+ var sendFriendRequestSchema = z8.object({
3430
+ requesterId: z8.string(),
3431
+ recipientId: z8.string(),
3432
+ message: z8.string().optional()
3108
3433
  });
3109
3434
 
3110
3435
  // ../../b4m-core/packages/services/dist/src/userService/adminUpdate.js
3111
3436
  var adminUpdateUserSchema = updateUserSchema.extend({
3112
- id: z8.string(),
3437
+ id: z9.string(),
3113
3438
  // Admins can directly update email addresses without verification
3114
- email: z8.string().email().optional(),
3115
- role: z8.string().optional().nullable(),
3116
- isAdmin: z8.boolean().optional(),
3117
- organizationId: z8.string().optional().nullable(),
3118
- storageLimit: z8.number().optional(),
3119
- currentCredits: z8.number().optional(),
3120
- isBanned: z8.boolean().optional(),
3121
- isModerated: z8.boolean().optional(),
3122
- subscribedUntil: z8.string().optional().nullable(),
3123
- systemFiles: z8.array(z8.object({ fileId: z8.string(), enabled: z8.boolean() })).optional(),
3124
- level: z8.enum(["DemoUser", "PaidUser", "VIPUser", "ManagerUser", "AdminUser"]).optional(),
3125
- lastNotebookId: z8.string().optional().nullable(),
3126
- userNotes: z8.array(z8.object({ timestamp: z8.string(), note: z8.string(), userName: z8.string() })).optional(),
3127
- numReferralsAvailable: z8.number().optional()
3439
+ email: z9.string().email().optional(),
3440
+ role: z9.string().optional().nullable(),
3441
+ isAdmin: z9.boolean().optional(),
3442
+ organizationId: z9.string().optional().nullable(),
3443
+ storageLimit: z9.number().optional(),
3444
+ currentCredits: z9.number().optional(),
3445
+ isBanned: z9.boolean().optional(),
3446
+ isModerated: z9.boolean().optional(),
3447
+ subscribedUntil: z9.string().optional().nullable(),
3448
+ systemFiles: z9.array(z9.object({ fileId: z9.string(), enabled: z9.boolean() })).optional(),
3449
+ level: z9.enum(["DemoUser", "PaidUser", "VIPUser", "ManagerUser", "AdminUser"]).optional(),
3450
+ lastNotebookId: z9.string().optional().nullable(),
3451
+ userNotes: z9.array(z9.object({ timestamp: z9.string(), note: z9.string(), userName: z9.string() })).optional(),
3452
+ numReferralsAvailable: z9.number().optional()
3128
3453
  });
3129
3454
 
3130
3455
  // ../../b4m-core/packages/services/dist/src/userService/register.js
3131
- import { z as z10 } from "zod";
3456
+ import { z as z11 } from "zod";
3132
3457
  import bcrypt4 from "bcryptjs";
3133
3458
 
3134
3459
  // ../../b4m-core/packages/services/dist/src/creditService/addCredits.js
3135
- import { z as z9 } from "zod";
3136
- var AddCreditsSchema = z9.discriminatedUnion("type", [
3460
+ import { z as z10 } from "zod";
3461
+ var AddCreditsSchema = z10.discriminatedUnion("type", [
3137
3462
  PurchaseTransaction.omit({ createdAt: true, updatedAt: true }),
3138
3463
  SubscriptionCreditTransaction.omit({ createdAt: true, updatedAt: true }),
3139
3464
  GenericCreditAddTransaction.omit({ createdAt: true, updatedAt: true }),
@@ -3141,57 +3466,57 @@ var AddCreditsSchema = z9.discriminatedUnion("type", [
3141
3466
  ]);
3142
3467
 
3143
3468
  // ../../b4m-core/packages/services/dist/src/userService/register.js
3144
- var registerUserSchema = z10.object({
3145
- username: z10.string(),
3146
- email: z10.string(),
3147
- name: z10.string(),
3148
- inviteCode: z10.string(),
3149
- password: z10.string(),
3150
- metadata: z10.object({
3151
- loginTime: z10.date(),
3152
- userAgent: z10.string(),
3153
- browser: z10.string(),
3154
- operatingSystem: z10.string(),
3155
- deviceType: z10.string(),
3156
- screenResolution: z10.string(),
3157
- viewportSize: z10.string(),
3158
- colorDepth: z10.number(),
3159
- pixelDepth: z10.number(),
3160
- devicePixelRatio: z10.number(),
3161
- ip: z10.string().optional().default(""),
3162
- location: z10.string().optional()
3469
+ var registerUserSchema = z11.object({
3470
+ username: z11.string(),
3471
+ email: z11.string(),
3472
+ name: z11.string(),
3473
+ inviteCode: z11.string(),
3474
+ password: z11.string(),
3475
+ metadata: z11.object({
3476
+ loginTime: z11.date(),
3477
+ userAgent: z11.string(),
3478
+ browser: z11.string(),
3479
+ operatingSystem: z11.string(),
3480
+ deviceType: z11.string(),
3481
+ screenResolution: z11.string(),
3482
+ viewportSize: z11.string(),
3483
+ colorDepth: z11.number(),
3484
+ pixelDepth: z11.number(),
3485
+ devicePixelRatio: z11.number(),
3486
+ ip: z11.string().optional().default(""),
3487
+ location: z11.string().optional()
3163
3488
  }).optional()
3164
3489
  });
3165
3490
 
3166
3491
  // ../../b4m-core/packages/services/dist/src/userService/adminDelete.js
3167
- import { z as z11 } from "zod";
3168
- var adminDeleteUserSchema = z11.object({
3169
- id: z11.string()
3492
+ import { z as z12 } from "zod";
3493
+ var adminDeleteUserSchema = z12.object({
3494
+ id: z12.string()
3170
3495
  });
3171
3496
 
3172
3497
  // ../../b4m-core/packages/services/dist/src/userService/searchUserCollection.js
3173
- import { z as z12 } from "zod";
3174
- var searchUserCollectionSchema = z12.object({
3175
- userId: z12.string(),
3176
- page: z12.coerce.number().optional().default(1),
3177
- limit: z12.coerce.number().optional().default(10),
3178
- search: z12.string().optional().default(""),
3179
- type: z12.nativeEnum(CollectionType).optional()
3498
+ import { z as z13 } from "zod";
3499
+ var searchUserCollectionSchema = z13.object({
3500
+ userId: z13.string(),
3501
+ page: z13.coerce.number().optional().default(1),
3502
+ limit: z13.coerce.number().optional().default(10),
3503
+ search: z13.string().optional().default(""),
3504
+ type: z13.nativeEnum(CollectionType).optional()
3180
3505
  });
3181
3506
 
3182
3507
  // ../../b4m-core/packages/services/dist/src/userService/recalculateUserStorage.js
3183
- import { z as z13 } from "zod";
3184
- var recalculateUserStorageSchema = z13.object({
3508
+ import { z as z14 } from "zod";
3509
+ var recalculateUserStorageSchema = z14.object({
3185
3510
  /**
3186
3511
  * The user to recalculate the storage for
3187
3512
  */
3188
- userId: z13.string()
3513
+ userId: z14.string()
3189
3514
  });
3190
3515
 
3191
3516
  // ../../b4m-core/packages/services/dist/src/userService/listRecentActivities.js
3192
- import { z as z14 } from "zod";
3193
- var listRecentActivitiesSchema = z14.object({
3194
- coverage: z14.enum(["all", "important"]).default("important")
3517
+ import { z as z15 } from "zod";
3518
+ var listRecentActivitiesSchema = z15.object({
3519
+ coverage: z15.enum(["all", "important"]).default("important")
3195
3520
  });
3196
3521
  var IMPORTANT_COUNTER_NAMES = [
3197
3522
  SessionEvents.CREATE_SESSION,
@@ -3205,82 +3530,82 @@ var IMPORTANT_COUNTER_NAMES = [
3205
3530
 
3206
3531
  // ../../b4m-core/packages/services/dist/src/userService/sendEmailVerification.js
3207
3532
  import { randomUUID as randomUUID2 } from "crypto";
3208
- import { z as z15 } from "zod";
3209
- var sendEmailVerificationSchema = z15.object({
3210
- userId: z15.string()
3533
+ import { z as z16 } from "zod";
3534
+ var sendEmailVerificationSchema = z16.object({
3535
+ userId: z16.string()
3211
3536
  });
3212
3537
 
3213
3538
  // ../../b4m-core/packages/services/dist/src/userService/verifyEmailToken.js
3214
- import { z as z16 } from "zod";
3539
+ import { z as z17 } from "zod";
3215
3540
 
3216
3541
  // ../../b4m-core/packages/services/dist/src/utils/crypto.js
3217
3542
  import crypto from "crypto";
3218
3543
 
3219
3544
  // ../../b4m-core/packages/services/dist/src/userService/verifyEmailToken.js
3220
- var verifyEmailTokenSchema = z16.object({
3221
- token: z16.string()
3545
+ var verifyEmailTokenSchema = z17.object({
3546
+ token: z17.string()
3222
3547
  });
3223
3548
 
3224
3549
  // ../../b4m-core/packages/services/dist/src/userService/resendEmailVerification.js
3225
3550
  import { randomUUID as randomUUID3 } from "crypto";
3226
- import { z as z17 } from "zod";
3227
- var resendEmailVerificationSchema = z17.object({
3228
- userId: z17.string()
3551
+ import { z as z18 } from "zod";
3552
+ var resendEmailVerificationSchema = z18.object({
3553
+ userId: z18.string()
3229
3554
  });
3230
3555
 
3231
3556
  // ../../b4m-core/packages/services/dist/src/userService/requestEmailChange.js
3232
3557
  import { randomUUID as randomUUID4 } from "crypto";
3233
- import { z as z18 } from "zod";
3234
- var requestEmailChangeSchema = z18.object({
3235
- userId: z18.string(),
3236
- newEmail: z18.string().email(),
3237
- password: z18.string()
3558
+ import { z as z19 } from "zod";
3559
+ var requestEmailChangeSchema = z19.object({
3560
+ userId: z19.string(),
3561
+ newEmail: z19.string().email(),
3562
+ password: z19.string()
3238
3563
  });
3239
3564
 
3240
3565
  // ../../b4m-core/packages/services/dist/src/userService/verifyEmailChange.js
3241
- import { z as z19 } from "zod";
3242
- var verifyEmailChangeSchema = z19.object({
3243
- token: z19.string()
3566
+ import { z as z20 } from "zod";
3567
+ var verifyEmailChangeSchema = z20.object({
3568
+ token: z20.string()
3244
3569
  });
3245
3570
 
3246
3571
  // ../../b4m-core/packages/services/dist/src/userService/cancelEmailChange.js
3247
- import { z as z20 } from "zod";
3248
- var cancelEmailChangeSchema = z20.object({
3249
- userId: z20.string()
3572
+ import { z as z21 } from "zod";
3573
+ var cancelEmailChangeSchema = z21.object({
3574
+ userId: z21.string()
3250
3575
  });
3251
3576
 
3252
3577
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/create.js
3253
3578
  import { randomBytes as randomBytes2 } from "crypto";
3254
3579
  import bcrypt5 from "bcryptjs";
3255
- import { z as z21 } from "zod";
3256
- var createUserApiKeySchema = z21.object({
3257
- name: z21.string().min(1).max(100),
3258
- scopes: z21.array(z21.nativeEnum(ApiKeyScope)).min(1),
3259
- expiresAt: z21.date().optional(),
3260
- rateLimit: z21.object({
3261
- requestsPerMinute: z21.number().min(1).max(1e3).default(60),
3262
- requestsPerDay: z21.number().min(1).max(1e4).default(1e3)
3580
+ import { z as z22 } from "zod";
3581
+ var createUserApiKeySchema = z22.object({
3582
+ name: z22.string().min(1).max(100),
3583
+ scopes: z22.array(z22.nativeEnum(ApiKeyScope)).min(1),
3584
+ expiresAt: z22.date().optional(),
3585
+ rateLimit: z22.object({
3586
+ requestsPerMinute: z22.number().min(1).max(1e3).default(60),
3587
+ requestsPerDay: z22.number().min(1).max(1e4).default(1e3)
3263
3588
  }).optional(),
3264
- metadata: z21.object({
3265
- clientIP: z21.string().optional(),
3266
- userAgent: z21.string().optional(),
3267
- createdFrom: z21.enum(["dashboard", "cli", "api"])
3589
+ metadata: z22.object({
3590
+ clientIP: z22.string().optional(),
3591
+ userAgent: z22.string().optional(),
3592
+ createdFrom: z22.enum(["dashboard", "cli", "api"])
3268
3593
  })
3269
3594
  });
3270
3595
 
3271
3596
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/revoke.js
3272
- import { z as z22 } from "zod";
3273
- var revokeUserApiKeySchema = z22.object({
3274
- keyId: z22.string(),
3275
- reason: z22.string().optional()
3597
+ import { z as z23 } from "zod";
3598
+ var revokeUserApiKeySchema = z23.object({
3599
+ keyId: z23.string(),
3600
+ reason: z23.string().optional()
3276
3601
  });
3277
3602
 
3278
3603
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/rotate.js
3279
3604
  import { randomBytes as randomBytes3 } from "crypto";
3280
3605
  import bcrypt6 from "bcryptjs";
3281
- import { z as z23 } from "zod";
3282
- var rotateUserApiKeySchema = z23.object({
3283
- keyId: z23.string()
3606
+ import { z as z24 } from "zod";
3607
+ var rotateUserApiKeySchema = z24.object({
3608
+ keyId: z24.string()
3284
3609
  });
3285
3610
 
3286
3611
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/validate.js
@@ -3427,29 +3752,29 @@ var EVENT_GROUPS = [
3427
3752
  ];
3428
3753
 
3429
3754
  // ../../b4m-core/packages/services/dist/src/countersService/generateReport.js
3430
- import { z as z25 } from "zod";
3755
+ import { z as z26 } from "zod";
3431
3756
 
3432
3757
  // ../../b4m-core/packages/services/dist/src/countersService/getAllCounterFrom24Hours.js
3433
- import { z as z24 } from "zod";
3758
+ import { z as z25 } from "zod";
3434
3759
  import dayjs2 from "dayjs";
3435
- var getCounterTotalsForLast24HoursSchema = z24.object({
3436
- date: z24.string(),
3437
- endDate: z24.string().optional()
3760
+ var getCounterTotalsForLast24HoursSchema = z25.object({
3761
+ date: z25.string(),
3762
+ endDate: z25.string().optional()
3438
3763
  });
3439
3764
 
3440
3765
  // ../../b4m-core/packages/services/dist/src/countersService/generateReport.js
3441
- var generateDailyReportSchema = z25.object({
3442
- date: z25.string(),
3443
- startDate: z25.string().optional(),
3444
- endDate: z25.string().optional()
3766
+ var generateDailyReportSchema = z26.object({
3767
+ date: z26.string(),
3768
+ startDate: z26.string().optional(),
3769
+ endDate: z26.string().optional()
3445
3770
  });
3446
3771
 
3447
3772
  // ../../b4m-core/packages/services/dist/src/countersService/incrementUserCounter.js
3448
- import { z as z26 } from "zod";
3449
- var incrementUserCounterSchema = z26.object({
3450
- action: z26.string(),
3451
- increment: z26.coerce.number().default(1).optional(),
3452
- metadata: z26.record(z26.unknown()).optional()
3773
+ import { z as z27 } from "zod";
3774
+ var incrementUserCounterSchema = z27.object({
3775
+ action: z27.string(),
3776
+ increment: z27.coerce.number().default(1).optional(),
3777
+ metadata: z27.record(z27.unknown()).optional()
3453
3778
  });
3454
3779
 
3455
3780
  // ../../b4m-core/packages/services/dist/src/countersService/sendSlackReport.js
@@ -3465,47 +3790,47 @@ import { GoogleGenerativeAI } from "@google/generative-ai";
3465
3790
  import OpenAI2 from "openai";
3466
3791
 
3467
3792
  // ../../b4m-core/packages/services/dist/src/importHistoryService/index.js
3468
- import fs6, { unlinkSync } from "fs";
3793
+ import fs7, { unlinkSync } from "fs";
3469
3794
  import yauzl from "yauzl";
3470
3795
  import axios3 from "axios";
3471
3796
 
3472
3797
  // ../../b4m-core/packages/services/dist/src/importHistoryService/importOpenaiHistory.js
3473
- import { z as z27 } from "zod";
3798
+ import { z as z28 } from "zod";
3474
3799
  import last from "lodash/last.js";
3475
- var epochDate = () => z27.preprocess((val) => new Date(Number(val) * 1e3), z27.date());
3476
- var openaiConversationSchema = z27.object({
3477
- id: z27.string(),
3478
- title: z27.string(),
3800
+ var epochDate = () => z28.preprocess((val) => new Date(Number(val) * 1e3), z28.date());
3801
+ var openaiConversationSchema = z28.object({
3802
+ id: z28.string(),
3803
+ title: z28.string(),
3479
3804
  create_time: epochDate(),
3480
3805
  update_time: epochDate().nullable(),
3481
- mapping: z27.record(
3482
- z27.string(),
3483
- z27.object({
3484
- id: z27.string(),
3485
- parent: z27.string().nullable(),
3486
- children: z27.array(z27.string()),
3487
- message: z27.object({
3488
- id: z27.string(),
3806
+ mapping: z28.record(
3807
+ z28.string(),
3808
+ z28.object({
3809
+ id: z28.string(),
3810
+ parent: z28.string().nullable(),
3811
+ children: z28.array(z28.string()),
3812
+ message: z28.object({
3813
+ id: z28.string(),
3489
3814
  create_time: epochDate(),
3490
3815
  update_time: epochDate().nullable(),
3491
- author: z27.object({
3492
- role: z27.string(),
3493
- name: z27.string().nullable(),
3494
- metadata: z27.any()
3816
+ author: z28.object({
3817
+ role: z28.string(),
3818
+ name: z28.string().nullable(),
3819
+ metadata: z28.any()
3495
3820
  // Accept any metadata structure
3496
3821
  }).passthrough(),
3497
3822
  // Allow extra fields in author
3498
- content: z27.object({
3499
- content_type: z27.string(),
3500
- parts: z27.array(z27.any()).optional()
3823
+ content: z28.object({
3824
+ content_type: z28.string(),
3825
+ parts: z28.array(z28.any()).optional()
3501
3826
  // Accept any type in parts array (strings, objects, etc.)
3502
3827
  }).passthrough(),
3503
3828
  // Allow extra fields in content
3504
- status: z27.string(),
3505
- end_turn: z27.boolean().nullable(),
3506
- metadata: z27.any(),
3829
+ status: z28.string(),
3830
+ end_turn: z28.boolean().nullable(),
3831
+ metadata: z28.any(),
3507
3832
  // Accept any metadata structure since it varies widely
3508
- recipient: z27.string()
3833
+ recipient: z28.string()
3509
3834
  }).passthrough().nullable()
3510
3835
  }).passthrough()
3511
3836
  // Allow extra fields in mapping node
@@ -3513,38 +3838,38 @@ var openaiConversationSchema = z27.object({
3513
3838
  }).passthrough();
3514
3839
 
3515
3840
  // ../../b4m-core/packages/services/dist/src/importHistoryService/importClaudeHistory.js
3516
- import { z as z28 } from "zod";
3517
- var claudeChatMessageSchema = z28.object({
3518
- uuid: z28.string().uuid(),
3519
- text: z28.string(),
3520
- content: z28.array(
3521
- z28.object({
3522
- type: z28.string(),
3841
+ import { z as z29 } from "zod";
3842
+ var claudeChatMessageSchema = z29.object({
3843
+ uuid: z29.string().uuid(),
3844
+ text: z29.string(),
3845
+ content: z29.array(
3846
+ z29.object({
3847
+ type: z29.string(),
3523
3848
  // Accept any type: "text", "image", "tool_result", etc.
3524
- text: z28.string().optional()
3849
+ text: z29.string().optional()
3525
3850
  // Make text optional since tool_result may not have it
3526
3851
  }).passthrough()
3527
3852
  // Allow all other fields
3528
3853
  ),
3529
- sender: z28.enum(["human", "assistant"]),
3530
- created_at: z28.coerce.date(),
3531
- updated_at: z28.coerce.date(),
3532
- attachments: z28.array(z28.any()),
3854
+ sender: z29.enum(["human", "assistant"]),
3855
+ created_at: z29.coerce.date(),
3856
+ updated_at: z29.coerce.date(),
3857
+ attachments: z29.array(z29.any()),
3533
3858
  // Accept any attachment structure
3534
- files: z28.array(z28.any())
3859
+ files: z29.array(z29.any())
3535
3860
  // Accept any file structure
3536
3861
  }).passthrough();
3537
- var claudeConversationSchema = z28.object({
3538
- uuid: z28.string().uuid(),
3539
- name: z28.string(),
3540
- summary: z28.string().optional(),
3862
+ var claudeConversationSchema = z29.object({
3863
+ uuid: z29.string().uuid(),
3864
+ name: z29.string(),
3865
+ summary: z29.string().optional(),
3541
3866
  // Summary field is optional
3542
- created_at: z28.coerce.date(),
3543
- updated_at: z28.coerce.date(),
3544
- account: z28.object({
3545
- uuid: z28.string().uuid()
3867
+ created_at: z29.coerce.date(),
3868
+ updated_at: z29.coerce.date(),
3869
+ account: z29.object({
3870
+ uuid: z29.string().uuid()
3546
3871
  }),
3547
- chat_messages: z28.array(claudeChatMessageSchema)
3872
+ chat_messages: z29.array(claudeChatMessageSchema)
3548
3873
  }).passthrough();
3549
3874
 
3550
3875
  // ../../b4m-core/packages/services/dist/src/importHistoryService/index.js
@@ -3555,357 +3880,357 @@ var ImportSource;
3555
3880
  })(ImportSource || (ImportSource = {}));
3556
3881
 
3557
3882
  // ../../b4m-core/packages/services/dist/src/sessionService/create.js
3558
- import { z as z29 } from "zod";
3559
- var createSessionParametersSchema = z29.object({
3560
- name: z29.string(),
3561
- knowledgeIds: z29.array(z29.string()).optional(),
3562
- artifactIds: z29.array(z29.string()).optional(),
3563
- agentIds: z29.array(z29.string()).optional(),
3564
- tags: z29.array(z29.object({ name: z29.string(), strength: z29.number() })).optional(),
3565
- summary: z29.string().optional(),
3566
- summaryAt: z29.date().optional(),
3567
- clonedSourceId: z29.string().optional().nullable(),
3568
- forkedSourceId: z29.string().optional().nullable(),
3569
- projectId: z29.string().optional(),
3570
- lastUsedModel: z29.string().optional().nullable()
3883
+ import { z as z30 } from "zod";
3884
+ var createSessionParametersSchema = z30.object({
3885
+ name: z30.string(),
3886
+ knowledgeIds: z30.array(z30.string()).optional(),
3887
+ artifactIds: z30.array(z30.string()).optional(),
3888
+ agentIds: z30.array(z30.string()).optional(),
3889
+ tags: z30.array(z30.object({ name: z30.string(), strength: z30.number() })).optional(),
3890
+ summary: z30.string().optional(),
3891
+ summaryAt: z30.date().optional(),
3892
+ clonedSourceId: z30.string().optional().nullable(),
3893
+ forkedSourceId: z30.string().optional().nullable(),
3894
+ projectId: z30.string().optional(),
3895
+ lastUsedModel: z30.string().optional().nullable()
3571
3896
  });
3572
3897
 
3573
3898
  // ../../b4m-core/packages/services/dist/src/sessionService/delete.js
3574
- import { z as z30 } from "zod";
3575
- var deleteSessionSchema = z30.object({
3576
- id: z30.string()
3899
+ import { z as z31 } from "zod";
3900
+ var deleteSessionSchema = z31.object({
3901
+ id: z31.string()
3577
3902
  });
3578
3903
 
3579
3904
  // ../../b4m-core/packages/services/dist/src/sessionService/sumarize.js
3580
- import { z as z31 } from "zod";
3581
- var sumarizeSessionSchema = z31.object({
3582
- id: z31.string()
3905
+ import { z as z32 } from "zod";
3906
+ var sumarizeSessionSchema = z32.object({
3907
+ id: z32.string()
3583
3908
  });
3584
3909
 
3585
3910
  // ../../b4m-core/packages/services/dist/src/projectService/create.js
3586
- import { z as z32 } from "zod";
3587
- var createProjectSchema = z32.object({
3588
- name: z32.string().min(1),
3589
- description: z32.string().min(1),
3590
- sessionIds: z32.array(z32.string()).optional(),
3591
- fileIds: z32.array(z32.string()).optional()
3911
+ import { z as z33 } from "zod";
3912
+ var createProjectSchema = z33.object({
3913
+ name: z33.string().min(1),
3914
+ description: z33.string().min(1),
3915
+ sessionIds: z33.array(z33.string()).optional(),
3916
+ fileIds: z33.array(z33.string()).optional()
3592
3917
  });
3593
3918
 
3594
3919
  // ../../b4m-core/packages/services/dist/src/projectService/search.js
3595
- import { z as z33 } from "zod";
3596
- var searchProjectsSchema = z33.object({
3597
- search: z33.string().optional(),
3598
- filters: z33.object({
3599
- favorite: z33.coerce.boolean().optional(),
3600
- scope: z33.record(z33.any()).optional()
3920
+ import { z as z34 } from "zod";
3921
+ var searchProjectsSchema = z34.object({
3922
+ search: z34.string().optional(),
3923
+ filters: z34.object({
3924
+ favorite: z34.coerce.boolean().optional(),
3925
+ scope: z34.record(z34.any()).optional()
3601
3926
  }).optional(),
3602
- pagination: z33.object({
3603
- page: z33.coerce.number().optional(),
3604
- limit: z33.coerce.number().optional()
3927
+ pagination: z34.object({
3928
+ page: z34.coerce.number().optional(),
3929
+ limit: z34.coerce.number().optional()
3605
3930
  }).optional(),
3606
- orderBy: z33.object({
3607
- by: z33.enum(["createdAt", "updatedAt"]).optional(),
3608
- direction: z33.enum(["asc", "desc"]).optional()
3931
+ orderBy: z34.object({
3932
+ by: z34.enum(["createdAt", "updatedAt"]).optional(),
3933
+ direction: z34.enum(["asc", "desc"]).optional()
3609
3934
  }).optional()
3610
3935
  });
3611
3936
 
3612
3937
  // ../../b4m-core/packages/services/dist/src/projectService/addSessions.js
3613
- import { z as z44 } from "zod";
3938
+ import { z as z45 } from "zod";
3614
3939
  import uniq2 from "lodash/uniq.js";
3615
3940
 
3616
3941
  // ../../b4m-core/packages/services/dist/src/sharingService/accept.js
3617
- import { z as z34 } from "zod";
3618
- var acceptInviteSchema = z34.object({
3619
- id: z34.string()
3942
+ import { z as z35 } from "zod";
3943
+ var acceptInviteSchema = z35.object({
3944
+ id: z35.string()
3620
3945
  });
3621
3946
 
3622
3947
  // ../../b4m-core/packages/services/dist/src/sharingService/cancel.js
3623
- import { z as z35 } from "zod";
3624
- var cancelInviteSchema = z35.object({
3625
- id: z35.string(),
3626
- type: z35.nativeEnum(InviteType),
3627
- email: z35.string().email().optional()
3948
+ import { z as z36 } from "zod";
3949
+ var cancelInviteSchema = z36.object({
3950
+ id: z36.string(),
3951
+ type: z36.nativeEnum(InviteType),
3952
+ email: z36.string().email().optional()
3628
3953
  });
3629
3954
 
3630
3955
  // ../../b4m-core/packages/services/dist/src/sharingService/cancelOwnDocument.js
3631
- import { z as z36 } from "zod";
3632
- var cancelOwnDocumentInvitesSchema = z36.object({
3633
- documentId: z36.string(),
3634
- type: z36.nativeEnum(InviteType)
3956
+ import { z as z37 } from "zod";
3957
+ var cancelOwnDocumentInvitesSchema = z37.object({
3958
+ documentId: z37.string(),
3959
+ type: z37.nativeEnum(InviteType)
3635
3960
  });
3636
3961
 
3637
3962
  // ../../b4m-core/packages/services/dist/src/sharingService/create.js
3638
- import { z as z37 } from "zod";
3963
+ import { z as z38 } from "zod";
3639
3964
  var defaultExpiration = () => new Date((/* @__PURE__ */ new Date()).getFullYear() + 100, (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate());
3640
3965
  var DEFAULT_AVAILABLE = 1;
3641
- var createInviteSchema = z37.object({
3642
- id: z37.string(),
3643
- type: z37.nativeEnum(InviteType),
3644
- permissions: z37.array(z37.nativeEnum(Permission)),
3645
- recipients: z37.string().array().optional(),
3646
- description: z37.string().optional(),
3647
- expiresAt: z37.date().optional().default(defaultExpiration()),
3648
- available: z37.number().optional().default(DEFAULT_AVAILABLE)
3966
+ var createInviteSchema = z38.object({
3967
+ id: z38.string(),
3968
+ type: z38.nativeEnum(InviteType),
3969
+ permissions: z38.array(z38.nativeEnum(Permission)),
3970
+ recipients: z38.string().array().optional(),
3971
+ description: z38.string().optional(),
3972
+ expiresAt: z38.date().optional().default(defaultExpiration()),
3973
+ available: z38.number().optional().default(DEFAULT_AVAILABLE)
3649
3974
  });
3650
3975
 
3651
3976
  // ../../b4m-core/packages/services/dist/src/sharingService/get.js
3652
- import { z as z38 } from "zod";
3653
- var getInviteSchema = z38.object({
3654
- id: z38.string(),
3655
- withUsername: z38.boolean().optional()
3977
+ import { z as z39 } from "zod";
3978
+ var getInviteSchema = z39.object({
3979
+ id: z39.string(),
3980
+ withUsername: z39.boolean().optional()
3656
3981
  });
3657
3982
 
3658
3983
  // ../../b4m-core/packages/services/dist/src/sharingService/listByDocumentIdAndType.js
3659
- import { z as z39 } from "zod";
3660
- var listInviteByDocumentIdAndTypeSchema = z39.object({
3661
- documentId: z39.string(),
3662
- type: z39.nativeEnum(InviteType)
3984
+ import { z as z40 } from "zod";
3985
+ var listInviteByDocumentIdAndTypeSchema = z40.object({
3986
+ documentId: z40.string(),
3987
+ type: z40.nativeEnum(InviteType)
3663
3988
  });
3664
3989
 
3665
3990
  // ../../b4m-core/packages/services/dist/src/sharingService/listOwnPending.js
3666
- import { z as z40 } from "zod";
3667
- var listOwnPendingInvitesSchema = z40.object({
3668
- limit: z40.number().min(1).max(100).default(20),
3669
- page: z40.number().min(1).default(1)
3991
+ import { z as z41 } from "zod";
3992
+ var listOwnPendingInvitesSchema = z41.object({
3993
+ limit: z41.number().min(1).max(100).default(20),
3994
+ page: z41.number().min(1).default(1)
3670
3995
  });
3671
3996
 
3672
3997
  // ../../b4m-core/packages/services/dist/src/sharingService/refuse.js
3673
- import { z as z41 } from "zod";
3674
- var refuseInviteSchema = z41.object({
3675
- id: z41.string()
3998
+ import { z as z42 } from "zod";
3999
+ var refuseInviteSchema = z42.object({
4000
+ id: z42.string()
3676
4001
  });
3677
4002
 
3678
4003
  // ../../b4m-core/packages/services/dist/src/sharingService/revoke.js
3679
- import { z as z42 } from "zod";
3680
- var revokeSharingSchema = z42.object({
3681
- id: z42.string(),
3682
- type: z42.enum(["files", "sessions", "projects"]),
3683
- userId: z42.string(),
3684
- projectId: z42.string().optional()
4004
+ import { z as z43 } from "zod";
4005
+ var revokeSharingSchema = z43.object({
4006
+ id: z43.string(),
4007
+ type: z43.enum(["files", "sessions", "projects"]),
4008
+ userId: z43.string(),
4009
+ projectId: z43.string().optional()
3685
4010
  });
3686
4011
 
3687
4012
  // ../../b4m-core/packages/services/dist/src/projectService/addFiles.js
3688
- import { z as z43 } from "zod";
4013
+ import { z as z44 } from "zod";
3689
4014
  import uniq from "lodash/uniq.js";
3690
- var addFilesProjectSchema = z43.object({
3691
- projectId: z43.string().nonempty(),
3692
- fileIds: z43.array(z43.string().nonempty())
4015
+ var addFilesProjectSchema = z44.object({
4016
+ projectId: z44.string().nonempty(),
4017
+ fileIds: z44.array(z44.string().nonempty())
3693
4018
  });
3694
4019
 
3695
4020
  // ../../b4m-core/packages/services/dist/src/projectService/addSessions.js
3696
- var addSessionsProjectSchema = z44.object({
3697
- projectId: z44.string().nonempty(),
3698
- sessionIds: z44.array(z44.string().nonempty())
4021
+ var addSessionsProjectSchema = z45.object({
4022
+ projectId: z45.string().nonempty(),
4023
+ sessionIds: z45.array(z45.string().nonempty())
3699
4024
  });
3700
4025
 
3701
4026
  // ../../b4m-core/packages/services/dist/src/projectService/get.js
3702
- import { z as z45 } from "zod";
3703
- var getProjectSchema = z45.object({
3704
- id: z45.string()
3705
- });
3706
-
3707
- // ../../b4m-core/packages/services/dist/src/projectService/update.js
3708
4027
  import { z as z46 } from "zod";
3709
- var updateProjectSchema = z46.object({
3710
- id: z46.string(),
3711
- name: z46.string().optional(),
3712
- description: z46.string().optional()
4028
+ var getProjectSchema = z46.object({
4029
+ id: z46.string()
3713
4030
  });
3714
4031
 
3715
- // ../../b4m-core/packages/services/dist/src/projectService/delete.js
4032
+ // ../../b4m-core/packages/services/dist/src/projectService/update.js
3716
4033
  import { z as z47 } from "zod";
3717
- var deleteProjectSchema = z47.object({
3718
- id: z47.string()
4034
+ var updateProjectSchema = z47.object({
4035
+ id: z47.string(),
4036
+ name: z47.string().optional(),
4037
+ description: z47.string().optional()
3719
4038
  });
3720
4039
 
3721
- // ../../b4m-core/packages/services/dist/src/projectService/removeFiles.js
4040
+ // ../../b4m-core/packages/services/dist/src/projectService/delete.js
3722
4041
  import { z as z48 } from "zod";
3723
- var removeProjectFilesSchema = z48.object({
3724
- projectId: z48.string(),
3725
- fileIds: z48.array(z48.string())
4042
+ var deleteProjectSchema = z48.object({
4043
+ id: z48.string()
3726
4044
  });
3727
4045
 
3728
- // ../../b4m-core/packages/services/dist/src/projectService/removeSessions.js
4046
+ // ../../b4m-core/packages/services/dist/src/projectService/removeFiles.js
3729
4047
  import { z as z49 } from "zod";
3730
- var removeProjectSessionsSchema = z49.object({
4048
+ var removeProjectFilesSchema = z49.object({
3731
4049
  projectId: z49.string(),
3732
- sessionIds: z49.array(z49.string())
4050
+ fileIds: z49.array(z49.string())
3733
4051
  });
3734
4052
 
3735
- // ../../b4m-core/packages/services/dist/src/projectService/listSessions.js
4053
+ // ../../b4m-core/packages/services/dist/src/projectService/removeSessions.js
3736
4054
  import { z as z50 } from "zod";
3737
- var listProjectSessionsSchema = z50.object({
3738
- projectId: z50.string()
4055
+ var removeProjectSessionsSchema = z50.object({
4056
+ projectId: z50.string(),
4057
+ sessionIds: z50.array(z50.string())
3739
4058
  });
3740
4059
 
3741
- // ../../b4m-core/packages/services/dist/src/projectService/listFiles.js
4060
+ // ../../b4m-core/packages/services/dist/src/projectService/listSessions.js
3742
4061
  import { z as z51 } from "zod";
3743
- var listProjectFilesSchema = z51.object({
4062
+ var listProjectSessionsSchema = z51.object({
3744
4063
  projectId: z51.string()
3745
4064
  });
3746
4065
 
3747
- // ../../b4m-core/packages/services/dist/src/projectService/listInvites.js
4066
+ // ../../b4m-core/packages/services/dist/src/projectService/listFiles.js
3748
4067
  import { z as z52 } from "zod";
3749
- var listProjectInvitesParamsSchema = z52.object({
3750
- id: z52.string(),
3751
- statuses: z52.string().optional().default(""),
3752
- limit: z52.coerce.number().optional().default(10),
3753
- page: z52.coerce.number().optional().default(1)
4068
+ var listProjectFilesSchema = z52.object({
4069
+ projectId: z52.string()
3754
4070
  });
3755
4071
 
3756
- // ../../b4m-core/packages/services/dist/src/projectService/addSystemPrompts.js
4072
+ // ../../b4m-core/packages/services/dist/src/projectService/listInvites.js
3757
4073
  import { z as z53 } from "zod";
3758
- var addSystemPromptsSchema = z53.object({
3759
- projectId: z53.string(),
3760
- fileIds: z53.array(z53.string())
4074
+ var listProjectInvitesParamsSchema = z53.object({
4075
+ id: z53.string(),
4076
+ statuses: z53.string().optional().default(""),
4077
+ limit: z53.coerce.number().optional().default(10),
4078
+ page: z53.coerce.number().optional().default(1)
3761
4079
  });
3762
4080
 
3763
- // ../../b4m-core/packages/services/dist/src/projectService/toggleSystemPrompt.js
4081
+ // ../../b4m-core/packages/services/dist/src/projectService/addSystemPrompts.js
3764
4082
  import { z as z54 } from "zod";
3765
- var toggleSystemPromptSchema = z54.object({
4083
+ var addSystemPromptsSchema = z54.object({
3766
4084
  projectId: z54.string(),
3767
- fileId: z54.string()
4085
+ fileIds: z54.array(z54.string())
3768
4086
  });
3769
4087
 
3770
- // ../../b4m-core/packages/services/dist/src/projectService/removeSystemPrompt.js
4088
+ // ../../b4m-core/packages/services/dist/src/projectService/toggleSystemPrompt.js
3771
4089
  import { z as z55 } from "zod";
3772
- var removeSystemPromptSchema = z55.object({
4090
+ var toggleSystemPromptSchema = z55.object({
3773
4091
  projectId: z55.string(),
3774
4092
  fileId: z55.string()
3775
4093
  });
3776
4094
 
3777
- // ../../b4m-core/packages/services/dist/src/projectService/addFavorite.js
3778
- import { z as z58 } from "zod";
3779
-
3780
- // ../../b4m-core/packages/services/dist/src/favoriteService/create.js
4095
+ // ../../b4m-core/packages/services/dist/src/projectService/removeSystemPrompt.js
3781
4096
  import { z as z56 } from "zod";
3782
- var createFavoriteParametersSchema = z56.object({
3783
- documentId: z56.string(),
3784
- documentType: z56.nativeEnum(FavoriteDocumentType)
4097
+ var removeSystemPromptSchema = z56.object({
4098
+ projectId: z56.string(),
4099
+ fileId: z56.string()
3785
4100
  });
3786
4101
 
3787
- // ../../b4m-core/packages/services/dist/src/favoriteService/delete.js
4102
+ // ../../b4m-core/packages/services/dist/src/projectService/addFavorite.js
4103
+ import { z as z59 } from "zod";
4104
+
4105
+ // ../../b4m-core/packages/services/dist/src/favoriteService/create.js
3788
4106
  import { z as z57 } from "zod";
3789
- var deleteFavoriteParametersSchema = z57.object({
4107
+ var createFavoriteParametersSchema = z57.object({
3790
4108
  documentId: z57.string(),
3791
4109
  documentType: z57.nativeEnum(FavoriteDocumentType)
3792
4110
  });
3793
4111
 
3794
- // ../../b4m-core/packages/services/dist/src/projectService/addFavorite.js
3795
- var addFavoriteParametersSchema = z58.object({
3796
- projectId: z58.string()
4112
+ // ../../b4m-core/packages/services/dist/src/favoriteService/delete.js
4113
+ import { z as z58 } from "zod";
4114
+ var deleteFavoriteParametersSchema = z58.object({
4115
+ documentId: z58.string(),
4116
+ documentType: z58.nativeEnum(FavoriteDocumentType)
3797
4117
  });
3798
4118
 
3799
- // ../../b4m-core/packages/services/dist/src/projectService/deleteFavorite.js
3800
- import { z as z59 } from "zod";
3801
- var deleteFavoriteParametersSchema2 = z59.object({
4119
+ // ../../b4m-core/packages/services/dist/src/projectService/addFavorite.js
4120
+ var addFavoriteParametersSchema = z59.object({
3802
4121
  projectId: z59.string()
3803
4122
  });
3804
4123
 
3805
- // ../../b4m-core/packages/services/dist/src/projectService/removeNonExistentFiles.js
4124
+ // ../../b4m-core/packages/services/dist/src/projectService/deleteFavorite.js
3806
4125
  import { z as z60 } from "zod";
3807
- var removeNonExistentFilesSchema = z60.object({
4126
+ var deleteFavoriteParametersSchema2 = z60.object({
3808
4127
  projectId: z60.string()
3809
4128
  });
3810
4129
 
3811
- // ../../b4m-core/packages/services/dist/src/projectService/leaveProject.js
4130
+ // ../../b4m-core/packages/services/dist/src/projectService/removeNonExistentFiles.js
3812
4131
  import { z as z61 } from "zod";
3813
- var leaveProjectParamsSchema = z61.object({
3814
- id: z61.string(),
3815
- userIdToRemove: z61.string().optional()
3816
- // Optional: if provided, this is a removal by owner
4132
+ var removeNonExistentFilesSchema = z61.object({
4133
+ projectId: z61.string()
3817
4134
  });
3818
4135
 
3819
- // ../../b4m-core/packages/services/dist/src/sessionService/update.js
3820
- import uniq3 from "lodash/uniq.js";
3821
- import isEqual from "lodash/isEqual.js";
4136
+ // ../../b4m-core/packages/services/dist/src/projectService/leaveProject.js
3822
4137
  import { z as z62 } from "zod";
3823
- var updateSessionParamtersSchema = z62.object({
4138
+ var leaveProjectParamsSchema = z62.object({
3824
4139
  id: z62.string(),
3825
- name: z62.string().optional(),
3826
- knowledgeIds: z62.array(z62.string()).optional(),
3827
- artifactIds: z62.array(z62.string()).optional(),
3828
- tags: z62.array(z62.object({ name: z62.string(), strength: z62.number() })).optional(),
3829
- lastUsedModel: z62.string().optional()
4140
+ userIdToRemove: z62.string().optional()
4141
+ // Optional: if provided, this is a removal by owner
3830
4142
  });
3831
4143
 
3832
- // ../../b4m-core/packages/services/dist/src/sessionService/clone.js
4144
+ // ../../b4m-core/packages/services/dist/src/sessionService/update.js
4145
+ import uniq3 from "lodash/uniq.js";
4146
+ import isEqual from "lodash/isEqual.js";
3833
4147
  import { z as z63 } from "zod";
3834
- var cloneSessionSchema = z63.object({
3835
- id: z63.string()
4148
+ var updateSessionParamtersSchema = z63.object({
4149
+ id: z63.string(),
4150
+ name: z63.string().optional(),
4151
+ knowledgeIds: z63.array(z63.string()).optional(),
4152
+ artifactIds: z63.array(z63.string()).optional(),
4153
+ tags: z63.array(z63.object({ name: z63.string(), strength: z63.number() })).optional(),
4154
+ lastUsedModel: z63.string().optional()
3836
4155
  });
3837
4156
 
3838
- // ../../b4m-core/packages/services/dist/src/sessionService/fork.js
4157
+ // ../../b4m-core/packages/services/dist/src/sessionService/clone.js
3839
4158
  import { z as z64 } from "zod";
3840
- var forkSessionSchema = z64.object({
3841
- sessionId: z64.string(),
3842
- messageId: z64.string()
4159
+ var cloneSessionSchema = z64.object({
4160
+ id: z64.string()
3843
4161
  });
3844
4162
 
3845
- // ../../b4m-core/packages/services/dist/src/sessionService/snip.js
4163
+ // ../../b4m-core/packages/services/dist/src/sessionService/fork.js
3846
4164
  import { z as z65 } from "zod";
3847
- var snipSessionSchema = z65.object({
4165
+ var forkSessionSchema = z65.object({
3848
4166
  sessionId: z65.string(),
3849
4167
  messageId: z65.string()
3850
4168
  });
3851
4169
 
3852
- // ../../b4m-core/packages/services/dist/src/sessionService/get.js
4170
+ // ../../b4m-core/packages/services/dist/src/sessionService/snip.js
3853
4171
  import { z as z66 } from "zod";
3854
- var getSessionSchema = z66.object({
3855
- id: z66.string()
4172
+ var snipSessionSchema = z66.object({
4173
+ sessionId: z66.string(),
4174
+ messageId: z66.string()
3856
4175
  });
3857
4176
 
3858
- // ../../b4m-core/packages/services/dist/src/sessionService/deleteMessage.js
4177
+ // ../../b4m-core/packages/services/dist/src/sessionService/get.js
3859
4178
  import { z as z67 } from "zod";
3860
- var deleteSessionMessageSchema = z67.object({
3861
- sessionId: z67.string(),
3862
- messageId: z67.string()
4179
+ var getSessionSchema = z67.object({
4180
+ id: z67.string()
3863
4181
  });
3864
4182
 
3865
- // ../../b4m-core/packages/services/dist/src/sessionService/addFavorite.js
4183
+ // ../../b4m-core/packages/services/dist/src/sessionService/deleteMessage.js
3866
4184
  import { z as z68 } from "zod";
3867
- var addFavoriteParametersSchema2 = z68.object({
3868
- sessionId: z68.string()
4185
+ var deleteSessionMessageSchema = z68.object({
4186
+ sessionId: z68.string(),
4187
+ messageId: z68.string()
3869
4188
  });
3870
4189
 
3871
- // ../../b4m-core/packages/services/dist/src/sessionService/deleteFavorite.js
4190
+ // ../../b4m-core/packages/services/dist/src/sessionService/addFavorite.js
3872
4191
  import { z as z69 } from "zod";
3873
- var deleteFavoriteParametersSchema3 = z69.object({
4192
+ var addFavoriteParametersSchema2 = z69.object({
3874
4193
  sessionId: z69.string()
3875
4194
  });
3876
4195
 
3877
- // ../../b4m-core/packages/services/dist/src/sessionService/autoName.js
4196
+ // ../../b4m-core/packages/services/dist/src/sessionService/deleteFavorite.js
3878
4197
  import { z as z70 } from "zod";
3879
- var autoNameParameterSchema = z70.object({
3880
- sessionId: z70.string(),
4198
+ var deleteFavoriteParametersSchema3 = z70.object({
4199
+ sessionId: z70.string()
4200
+ });
4201
+
4202
+ // ../../b4m-core/packages/services/dist/src/sessionService/autoName.js
4203
+ import { z as z71 } from "zod";
4204
+ var autoNameParameterSchema = z71.object({
4205
+ sessionId: z71.string(),
3881
4206
  /** The maximum number of words to include in the title */
3882
- maxWords: z70.number().optional()
4207
+ maxWords: z71.number().optional()
3883
4208
  });
3884
4209
 
3885
4210
  // ../../b4m-core/packages/services/dist/src/organizationService/search.js
3886
- import { z as z71 } from "zod";
3887
- var searchSchema2 = z71.object({
4211
+ import { z as z72 } from "zod";
4212
+ var searchSchema2 = z72.object({
3888
4213
  /**
3889
4214
  * Text search query (searches in name and description)
3890
4215
  */
3891
- query: z71.string().optional(),
4216
+ query: z72.string().optional(),
3892
4217
  /**
3893
4218
  * Filter by personal organizations
3894
4219
  */
3895
- filters: z71.object({
3896
- personal: z71.union([z71.enum(["true", "false"]).transform((val) => val === "true"), z71.boolean()]).optional(),
3897
- userId: z71.string().optional()
4220
+ filters: z72.object({
4221
+ personal: z72.union([z72.enum(["true", "false"]).transform((val) => val === "true"), z72.boolean()]).optional(),
4222
+ userId: z72.string().optional()
3898
4223
  }).default({}),
3899
- pagination: z71.object({
3900
- page: z71.coerce.number().int().positive().default(1),
3901
- limit: z71.coerce.number().int().positive().max(100).default(10)
4224
+ pagination: z72.object({
4225
+ page: z72.coerce.number().int().positive().default(1),
4226
+ limit: z72.coerce.number().int().positive().max(100).default(10)
3902
4227
  }).default({
3903
4228
  page: 1,
3904
4229
  limit: 10
3905
4230
  }),
3906
- orderBy: z71.object({
3907
- field: z71.enum(["name", "createdAt", "updatedAt"]).default("name"),
3908
- direction: z71.enum(["asc", "desc"]).default("asc")
4231
+ orderBy: z72.object({
4232
+ field: z72.enum(["name", "createdAt", "updatedAt"]).default("name"),
4233
+ direction: z72.enum(["asc", "desc"]).default("asc")
3909
4234
  }).default({
3910
4235
  field: "name",
3911
4236
  direction: "asc"
@@ -3913,355 +4238,355 @@ var searchSchema2 = z71.object({
3913
4238
  });
3914
4239
 
3915
4240
  // ../../b4m-core/packages/services/dist/src/organizationService/get.js
3916
- import { z as z72 } from "zod";
3917
- var getSchema = z72.object({
4241
+ import { z as z73 } from "zod";
4242
+ var getSchema = z73.object({
3918
4243
  /**
3919
4244
  * Organization ID
3920
4245
  */
3921
- id: z72.string().min(1)
4246
+ id: z73.string().min(1)
3922
4247
  });
3923
4248
 
3924
4249
  // ../../b4m-core/packages/services/dist/src/organizationService/addMember.js
3925
- import { z as z73 } from "zod";
3926
- var addMemberSchema = z73.object({
3927
- userId: z73.string().optional(),
3928
- email: z73.string().optional(),
3929
- organizationId: z73.string(),
3930
- force: z73.boolean().optional()
4250
+ import { z as z74 } from "zod";
4251
+ var addMemberSchema = z74.object({
4252
+ userId: z74.string().optional(),
4253
+ email: z74.string().optional(),
4254
+ organizationId: z74.string(),
4255
+ force: z74.boolean().optional()
3931
4256
  // If true, add the user to the organization even if it's at full capacity
3932
4257
  });
3933
4258
 
3934
4259
  // ../../b4m-core/packages/services/dist/src/organizationService/getUsers.js
3935
- import { z as z74 } from "zod";
3936
- var getUsersSchema = z74.object({
3937
- id: z74.string()
4260
+ import { z as z75 } from "zod";
4261
+ var getUsersSchema = z75.object({
4262
+ id: z75.string()
3938
4263
  });
3939
4264
 
3940
4265
  // ../../b4m-core/packages/services/dist/src/organizationService/create.js
3941
- import { z as z75 } from "zod";
3942
- var createSchema = z75.object({
3943
- name: z75.string(),
3944
- personal: z75.boolean().default(false),
3945
- seats: z75.number().default(1),
3946
- stripeCustomerId: z75.string().nullable(),
3947
- billingOwnerId: z75.string().optional(),
4266
+ import { z as z76 } from "zod";
4267
+ var createSchema = z76.object({
4268
+ name: z76.string(),
4269
+ personal: z76.boolean().default(false),
4270
+ seats: z76.number().default(1),
4271
+ stripeCustomerId: z76.string().nullable(),
4272
+ billingOwnerId: z76.string().optional(),
3948
4273
  // Optional billing owner (defaults to user if not provided)
3949
- managerId: z75.string().optional()
4274
+ managerId: z76.string().optional()
3950
4275
  // Optional team manager
3951
4276
  });
3952
4277
 
3953
4278
  // ../../b4m-core/packages/services/dist/src/organizationService/update.js
3954
- import { z as z76 } from "zod";
3955
- var updateSchema = z76.object({
3956
- id: z76.string(),
3957
- name: z76.string().optional(),
3958
- description: z76.string().optional(),
3959
- billingContact: z76.string().optional(),
3960
- currentCredits: z76.coerce.number().optional()
4279
+ import { z as z77 } from "zod";
4280
+ var updateSchema = z77.object({
4281
+ id: z77.string(),
4282
+ name: z77.string().optional(),
4283
+ description: z77.string().optional(),
4284
+ billingContact: z77.string().optional(),
4285
+ currentCredits: z77.coerce.number().optional()
3961
4286
  });
3962
4287
 
3963
4288
  // ../../b4m-core/packages/services/dist/src/organizationService/delete.js
3964
- import { z as z77 } from "zod";
3965
- var deleteSchema = z77.object({
4289
+ import { z as z78 } from "zod";
4290
+ var deleteSchema = z78.object({
3966
4291
  /**
3967
4292
  * Organization ID
3968
4293
  */
3969
- id: z77.string().min(1)
4294
+ id: z78.string().min(1)
3970
4295
  });
3971
4296
 
3972
4297
  // ../../b4m-core/packages/services/dist/src/organizationService/listPendingUsers.js
3973
- import { z as z78 } from "zod";
3974
- var listPendingUsersSchema = z78.object({
3975
- organizationId: z78.string()
4298
+ import { z as z79 } from "zod";
4299
+ var listPendingUsersSchema = z79.object({
4300
+ organizationId: z79.string()
3976
4301
  });
3977
4302
 
3978
4303
  // ../../b4m-core/packages/services/dist/src/organizationService/revokeAccess.js
3979
- import { z as z79 } from "zod";
3980
- var revokeAccessSchema = z79.object({
3981
- id: z79.string(),
3982
- userId: z79.string()
4304
+ import { z as z80 } from "zod";
4305
+ var revokeAccessSchema = z80.object({
4306
+ id: z80.string(),
4307
+ userId: z80.string()
3983
4308
  });
3984
4309
 
3985
4310
  // ../../b4m-core/packages/services/dist/src/organizationService/leave.js
3986
- import { z as z80 } from "zod";
3987
- var organizationLeaveSchema = z80.object({
3988
- id: z80.string()
4311
+ import { z as z81 } from "zod";
4312
+ var organizationLeaveSchema = z81.object({
4313
+ id: z81.string()
3989
4314
  });
3990
4315
 
3991
4316
  // ../../b4m-core/packages/services/dist/src/apiKeyService/create.js
3992
- import { z as z81 } from "zod";
3993
- var createApiKeySchema = z81.object({
3994
- apiKey: z81.string().min(6),
3995
- description: z81.string().optional().default(""),
3996
- isActive: z81.boolean().optional().default(true),
3997
- type: z81.nativeEnum(ApiKeyType),
3998
- expireDays: z81.number().min(1).max(365).default(90)
4317
+ import { z as z82 } from "zod";
4318
+ var createApiKeySchema = z82.object({
4319
+ apiKey: z82.string().min(6),
4320
+ description: z82.string().optional().default(""),
4321
+ isActive: z82.boolean().optional().default(true),
4322
+ type: z82.nativeEnum(ApiKeyType),
4323
+ expireDays: z82.number().min(1).max(365).default(90)
3999
4324
  // Default 90-day expiration
4000
4325
  });
4001
4326
 
4002
4327
  // ../../b4m-core/packages/services/dist/src/apiKeyService/set.js
4003
- import { z as z82 } from "zod";
4004
- var setApiKeySchema = z82.object({
4005
- id: z82.string(),
4006
- type: z82.nativeEnum(ApiKeyType)
4328
+ import { z as z83 } from "zod";
4329
+ var setApiKeySchema = z83.object({
4330
+ id: z83.string(),
4331
+ type: z83.nativeEnum(ApiKeyType)
4007
4332
  });
4008
4333
 
4009
4334
  // ../../b4m-core/packages/services/dist/src/apiKeyService/delete.js
4010
- import { z as z83 } from "zod";
4011
- var deleteApiKeySchema = z83.object({
4012
- id: z83.string()
4335
+ import { z as z84 } from "zod";
4336
+ var deleteApiKeySchema = z84.object({
4337
+ id: z84.string()
4013
4338
  });
4014
4339
 
4015
4340
  // ../../b4m-core/packages/services/dist/src/fabFileService/get.js
4016
- import { z as z84 } from "zod";
4017
- var getFabFileSchema = z84.object({
4018
- id: z84.string()
4341
+ import { z as z85 } from "zod";
4342
+ var getFabFileSchema = z85.object({
4343
+ id: z85.string()
4019
4344
  });
4020
4345
 
4021
4346
  // ../../b4m-core/packages/services/dist/src/fabFileService/list.js
4022
- import { z as z85 } from "zod";
4023
- var listFabFilesSchema = z85.object({
4024
- ids: z85.array(z85.string()).optional()
4347
+ import { z as z86 } from "zod";
4348
+ var listFabFilesSchema = z86.object({
4349
+ ids: z86.array(z86.string()).optional()
4025
4350
  });
4026
4351
 
4027
4352
  // ../../b4m-core/packages/services/dist/src/fabFileService/update.js
4028
4353
  import mime from "mime-types";
4029
- import { v4 as uuidv42 } from "uuid";
4030
- import { z as z86 } from "zod";
4031
- var updateFabFileSchema = z86.object({
4032
- id: z86.string(),
4033
- fileName: z86.string(),
4034
- mimeType: z86.string(),
4035
- fileContent: z86.string().optional(),
4036
- type: z86.nativeEnum(KnowledgeType),
4037
- system: z86.boolean().optional(),
4038
- systemPriority: z86.number().min(0).max(999).optional(),
4039
- sessionId: z86.string().optional(),
4040
- notes: z86.string().optional(),
4041
- primaryTag: z86.string().optional(),
4042
- tags: z86.array(z86.object({
4043
- name: z86.string(),
4044
- strength: z86.number()
4354
+ import { v4 as uuidv43 } from "uuid";
4355
+ import { z as z87 } from "zod";
4356
+ var updateFabFileSchema = z87.object({
4357
+ id: z87.string(),
4358
+ fileName: z87.string(),
4359
+ mimeType: z87.string(),
4360
+ fileContent: z87.string().optional(),
4361
+ type: z87.nativeEnum(KnowledgeType),
4362
+ system: z87.boolean().optional(),
4363
+ systemPriority: z87.number().min(0).max(999).optional(),
4364
+ sessionId: z87.string().optional(),
4365
+ notes: z87.string().optional(),
4366
+ primaryTag: z87.string().optional(),
4367
+ tags: z87.array(z87.object({
4368
+ name: z87.string(),
4369
+ strength: z87.number()
4045
4370
  })).optional(),
4046
- error: z86.string().nullable().optional()
4371
+ error: z87.string().nullable().optional()
4047
4372
  });
4048
4373
 
4049
4374
  // ../../b4m-core/packages/services/dist/src/fabFileService/delete.js
4050
- import { z as z87 } from "zod";
4051
- var deleteFabFileSchema = z87.object({
4052
- id: z87.string()
4375
+ import { z as z88 } from "zod";
4376
+ var deleteFabFileSchema = z88.object({
4377
+ id: z88.string()
4053
4378
  });
4054
4379
 
4055
4380
  // ../../b4m-core/packages/services/dist/src/fabFileService/chunk.js
4056
- import { z as z88 } from "zod";
4057
- var chunkFileSchema = z88.object({
4058
- fabFileId: z88.string(),
4059
- embeddingModel: z88.string()
4381
+ import { z as z89 } from "zod";
4382
+ var chunkFileSchema = z89.object({
4383
+ fabFileId: z89.string(),
4384
+ embeddingModel: z89.string()
4060
4385
  });
4061
4386
 
4062
4387
  // ../../b4m-core/packages/services/dist/src/fabFileService/vectorize.js
4063
- import { z as z89 } from "zod";
4064
- var vectorizeFabFileChunkSchema = z89.object({
4065
- fabFileId: z89.string(),
4066
- chunkId: z89.string()
4388
+ import { z as z90 } from "zod";
4389
+ var vectorizeFabFileChunkSchema = z90.object({
4390
+ fabFileId: z90.string(),
4391
+ chunkId: z90.string()
4067
4392
  });
4068
4393
 
4069
4394
  // ../../b4m-core/packages/services/dist/src/fabFileService/listBySession.js
4070
- import { z as z90 } from "zod";
4071
- var listFabFilesBySessionSchema = z90.object({
4072
- sessionId: z90.string()
4395
+ import { z as z91 } from "zod";
4396
+ var listFabFilesBySessionSchema = z91.object({
4397
+ sessionId: z91.string()
4073
4398
  });
4074
4399
 
4075
4400
  // ../../b4m-core/packages/services/dist/src/fabFileService/listByQuest.js
4076
- import { z as z91 } from "zod";
4077
- var listFabFilesByQuestSchema = z91.object({
4078
- questId: z91.string()
4401
+ import { z as z92 } from "zod";
4402
+ var listFabFilesByQuestSchema = z92.object({
4403
+ questId: z92.string()
4079
4404
  });
4080
4405
 
4081
4406
  // ../../b4m-core/packages/services/dist/src/fabFileService/createByUrl.js
4082
- import { z as z92 } from "zod";
4083
- var createFabFileByUrlSchema = z92.object({
4084
- 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,})).+/)
4407
+ import { z as z93 } from "zod";
4408
+ var createFabFileByUrlSchema = z93.object({
4409
+ 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,})).+/)
4085
4410
  });
4086
4411
 
4087
4412
  // ../../b4m-core/packages/services/dist/src/fabFileService/search.js
4088
- import { z as z93 } from "zod";
4089
- var searchFabFilesSchema = z93.object({
4090
- search: z93.string().optional(),
4091
- filters: z93.object({
4092
- tags: z93.array(z93.string()).optional(),
4093
- type: z93.enum(["text", "pdf", "url", "image", "excel", "word", "json", "csv", "markdown", "code"]).optional(),
4094
- shared: z93.coerce.boolean().optional(),
4413
+ import { z as z94 } from "zod";
4414
+ var searchFabFilesSchema = z94.object({
4415
+ search: z94.string().optional(),
4416
+ filters: z94.object({
4417
+ tags: z94.array(z94.string()).optional(),
4418
+ type: z94.enum(["text", "pdf", "url", "image", "excel", "word", "json", "csv", "markdown", "code"]).optional(),
4419
+ shared: z94.coerce.boolean().optional(),
4095
4420
  // Indicates if the user is searching for shared files
4096
- curated: z93.coerce.boolean().optional(),
4421
+ curated: z94.coerce.boolean().optional(),
4097
4422
  // Indicates if the user is searching for curated notebook files
4098
- projectId: z93.string().optional(),
4099
- ids: z93.array(z93.string()).optional()
4423
+ projectId: z94.string().optional(),
4424
+ ids: z94.array(z94.string()).optional()
4100
4425
  // Add support for filtering by IDs
4101
4426
  }).optional(),
4102
- pagination: z93.object({
4103
- page: z93.coerce.number(),
4104
- limit: z93.coerce.number()
4427
+ pagination: z94.object({
4428
+ page: z94.coerce.number(),
4429
+ limit: z94.coerce.number()
4105
4430
  }).optional(),
4106
- order: z93.object({
4107
- by: z93.enum(["createdAt", "fileName", "fileSize"]),
4108
- direction: z93.enum(["asc", "desc"])
4431
+ order: z94.object({
4432
+ by: z94.enum(["createdAt", "fileName", "fileSize"]),
4433
+ direction: z94.enum(["asc", "desc"])
4109
4434
  }).optional(),
4110
- options: z93.object({
4111
- includeShared: z93.coerce.boolean().optional()
4435
+ options: z94.object({
4436
+ includeShared: z94.coerce.boolean().optional()
4112
4437
  }).optional()
4113
4438
  });
4114
4439
 
4115
4440
  // ../../b4m-core/packages/services/dist/src/fabFileService/addFavorite.js
4116
- import { z as z94 } from "zod";
4117
- var addFavoriteParametersSchema3 = z94.object({
4118
- fileId: z94.string()
4441
+ import { z as z95 } from "zod";
4442
+ var addFavoriteParametersSchema3 = z95.object({
4443
+ fileId: z95.string()
4119
4444
  });
4120
4445
 
4121
4446
  // ../../b4m-core/packages/services/dist/src/fabFileService/deleteFavorite.js
4122
- import { z as z95 } from "zod";
4123
- var deleteFavoriteParametersSchema4 = z95.object({
4124
- fileId: z95.string()
4447
+ import { z as z96 } from "zod";
4448
+ var deleteFavoriteParametersSchema4 = z96.object({
4449
+ fileId: z96.string()
4125
4450
  });
4126
4451
 
4127
4452
  // ../../b4m-core/packages/services/dist/src/fabFileService/toggleTags.js
4128
- import { z as z96 } from "zod";
4129
- var fabFileToggleTagsSchema = z96.object({
4130
- ids: z96.array(z96.string()),
4131
- tags: z96.array(z96.string())
4453
+ import { z as z97 } from "zod";
4454
+ var fabFileToggleTagsSchema = z97.object({
4455
+ ids: z97.array(z97.string()),
4456
+ tags: z97.array(z97.string())
4132
4457
  });
4133
4458
 
4134
4459
  // ../../b4m-core/packages/services/dist/src/fabFileService/edit.js
4135
- import { z as z97 } from "zod";
4460
+ import { z as z98 } from "zod";
4136
4461
  import { diffLines } from "diff";
4137
- var editFabFileSchema = z97.object({
4138
- id: z97.string(),
4139
- instruction: z97.string(),
4140
- selection: z97.object({
4141
- start: z97.number(),
4142
- end: z97.number()
4462
+ var editFabFileSchema = z98.object({
4463
+ id: z98.string(),
4464
+ instruction: z98.string(),
4465
+ selection: z98.object({
4466
+ start: z98.number(),
4467
+ end: z98.number()
4143
4468
  }).optional(),
4144
- preserveFormatting: z97.boolean().optional().default(true),
4145
- applyImmediately: z97.boolean().optional().default(false)
4469
+ preserveFormatting: z98.boolean().optional().default(true),
4470
+ applyImmediately: z98.boolean().optional().default(false)
4146
4471
  });
4147
4472
 
4148
4473
  // ../../b4m-core/packages/services/dist/src/fabFileService/applyEdit.js
4149
4474
  import mime2 from "mime-types";
4150
- import { v4 as uuidv43 } from "uuid";
4151
- import { z as z98 } from "zod";
4152
- var applyEditSchema = z98.object({
4153
- id: z98.string(),
4154
- modifiedContent: z98.string(),
4155
- createBackup: z98.boolean().optional().default(true)
4475
+ import { v4 as uuidv44 } from "uuid";
4476
+ import { z as z99 } from "zod";
4477
+ var applyEditSchema = z99.object({
4478
+ id: z99.string(),
4479
+ modifiedContent: z99.string(),
4480
+ createBackup: z99.boolean().optional().default(true)
4156
4481
  });
4157
4482
 
4158
4483
  // ../../b4m-core/packages/services/dist/src/friendshipService/respondToFriendRequest.js
4159
- import { z as z99 } from "zod";
4160
- var respondToFriendRequestSchema = z99.object({
4161
- id: z99.string(),
4484
+ import { z as z100 } from "zod";
4485
+ var respondToFriendRequestSchema = z100.object({
4486
+ id: z100.string(),
4162
4487
  /** The user ID of the recipient of the friend request */
4163
- userId: z99.string(),
4164
- accept: z99.boolean()
4488
+ userId: z100.string(),
4489
+ accept: z100.boolean()
4165
4490
  });
4166
4491
 
4167
4492
  // ../../b4m-core/packages/services/dist/src/friendshipService/unfriend.js
4168
- import { z as z100 } from "zod";
4169
- var unfriendSchema = z100.object({
4170
- friendshipId: z100.string(),
4493
+ import { z as z101 } from "zod";
4494
+ var unfriendSchema = z101.object({
4495
+ friendshipId: z101.string(),
4171
4496
  /** The user ID of the user who wants to unfriend the other user */
4172
- userId: z100.string()
4497
+ userId: z101.string()
4173
4498
  });
4174
4499
 
4175
4500
  // ../../b4m-core/packages/services/dist/src/friendshipService/list.js
4176
- import { z as z101 } from "zod";
4177
- var listFriendsSchema = z101.object({
4178
- userId: z101.string()
4501
+ import { z as z102 } from "zod";
4502
+ var listFriendsSchema = z102.object({
4503
+ userId: z102.string()
4179
4504
  });
4180
- var listPendingFriendRequestsSchema = z101.object({
4181
- userId: z101.string()
4505
+ var listPendingFriendRequestsSchema = z102.object({
4506
+ userId: z102.string()
4182
4507
  });
4183
4508
 
4184
4509
  // ../../b4m-core/packages/services/dist/src/adminService/loginAs.js
4185
- import { z as z102 } from "zod";
4186
- var loginAsSchema = z102.object({
4187
- targetUserId: z102.string()
4510
+ import { z as z103 } from "zod";
4511
+ var loginAsSchema = z103.object({
4512
+ targetUserId: z103.string()
4188
4513
  });
4189
4514
 
4190
4515
  // ../../b4m-core/packages/services/dist/src/cacheService/get.js
4191
- import { z as z103 } from "zod";
4192
- var getParamsSchema = z103.object({
4193
- key: z103.string()
4516
+ import { z as z104 } from "zod";
4517
+ var getParamsSchema = z104.object({
4518
+ key: z104.string()
4194
4519
  });
4195
4520
 
4196
4521
  // ../../b4m-core/packages/services/dist/src/cacheService/set.js
4197
- import { z as z104 } from "zod";
4198
- var setParamsSchema = z104.object({
4199
- key: z104.string(),
4200
- value: z104.any(),
4522
+ import { z as z105 } from "zod";
4523
+ var setParamsSchema = z105.object({
4524
+ key: z105.string(),
4525
+ value: z105.any(),
4201
4526
  /**
4202
4527
  * Time to live in milliseconds
4203
4528
  */
4204
- ttl: z104.number(),
4205
- recache: z104.boolean().optional()
4529
+ ttl: z105.number(),
4530
+ recache: z105.boolean().optional()
4206
4531
  });
4207
4532
 
4208
4533
  // ../../b4m-core/packages/services/dist/src/cacheService/ttl.js
4209
- import { z as z105 } from "zod";
4210
- var ttlParamsSchema = z105.object({
4211
- key: z105.string()
4534
+ import { z as z106 } from "zod";
4535
+ var ttlParamsSchema = z106.object({
4536
+ key: z106.string()
4212
4537
  });
4213
4538
 
4214
4539
  // ../../b4m-core/packages/services/dist/src/cacheService/weeklyReports.js
4215
- import { z as z106 } from "zod";
4540
+ import { z as z107 } from "zod";
4216
4541
  import dayjs3 from "dayjs";
4217
- var weeklyReportSchema = z106.object({
4218
- startDate: z106.string(),
4219
- endDate: z106.string(),
4220
- report: z106.string(),
4221
- aiInsights: z106.string().nullable()
4542
+ var weeklyReportSchema = z107.object({
4543
+ startDate: z107.string(),
4544
+ endDate: z107.string(),
4545
+ report: z107.string(),
4546
+ aiInsights: z107.string().nullable()
4222
4547
  });
4223
4548
 
4224
4549
  // ../../b4m-core/packages/services/dist/src/embeddingCacheService/generateCacheKey.js
4225
4550
  import crypto2 from "crypto";
4226
4551
 
4227
4552
  // ../../b4m-core/packages/services/dist/src/researchAgentService/create.js
4228
- import { z as z107 } from "zod";
4229
- var researchAgentCreateSchema = z107.object({
4230
- name: z107.string().min(1),
4231
- description: z107.string().min(1)
4232
- });
4233
-
4234
- // ../../b4m-core/packages/services/dist/src/researchAgentService/update.js
4235
4553
  import { z as z108 } from "zod";
4236
- var researchAgentUpdateSchema = z108.object({
4237
- id: z108.string(),
4554
+ var researchAgentCreateSchema = z108.object({
4238
4555
  name: z108.string().min(1),
4239
4556
  description: z108.string().min(1)
4240
4557
  });
4241
4558
 
4242
- // ../../b4m-core/packages/services/dist/src/researchAgentService/remove.js
4559
+ // ../../b4m-core/packages/services/dist/src/researchAgentService/update.js
4243
4560
  import { z as z109 } from "zod";
4244
- var researchAgentRemoveSchema = z109.object({
4245
- id: z109.string()
4561
+ var researchAgentUpdateSchema = z109.object({
4562
+ id: z109.string(),
4563
+ name: z109.string().min(1),
4564
+ description: z109.string().min(1)
4246
4565
  });
4247
4566
 
4248
- // ../../b4m-core/packages/services/dist/src/researchAgentService/get.js
4567
+ // ../../b4m-core/packages/services/dist/src/researchAgentService/remove.js
4249
4568
  import { z as z110 } from "zod";
4250
- var researchAgentGetSchema = z110.object({
4569
+ var researchAgentRemoveSchema = z110.object({
4251
4570
  id: z110.string()
4252
4571
  });
4253
4572
 
4254
- // ../../b4m-core/packages/services/dist/src/researchAgentService/listFiles.js
4573
+ // ../../b4m-core/packages/services/dist/src/researchAgentService/get.js
4255
4574
  import { z as z111 } from "zod";
4256
- var researchAgentListFilesSchema = z111.object({
4575
+ var researchAgentGetSchema = z111.object({
4576
+ id: z111.string()
4577
+ });
4578
+
4579
+ // ../../b4m-core/packages/services/dist/src/researchAgentService/listFiles.js
4580
+ import { z as z112 } from "zod";
4581
+ var researchAgentListFilesSchema = z112.object({
4257
4582
  /**
4258
4583
  * The ID of the research agent
4259
4584
  */
4260
- id: z111.string()
4585
+ id: z112.string()
4261
4586
  });
4262
4587
 
4263
4588
  // ../../b4m-core/packages/services/dist/src/researchTaskService/process.js
4264
- import { z as z112 } from "zod";
4589
+ import { z as z113 } from "zod";
4265
4590
 
4266
4591
  // ../../b4m-core/packages/services/dist/src/lib/turndown.js
4267
4592
  import turndown from "turndown";
@@ -4652,316 +4977,316 @@ var deepResearchTool = {
4652
4977
  };
4653
4978
 
4654
4979
  // ../../b4m-core/packages/services/dist/src/researchTaskService/process.js
4655
- var ResearchTaskProcessSchema = z112.object({
4656
- id: z112.string()
4980
+ var ResearchTaskProcessSchema = z113.object({
4981
+ id: z113.string()
4657
4982
  });
4658
4983
 
4659
4984
  // ../../b4m-core/packages/services/dist/src/researchTaskService/create.js
4660
- import { z as z113 } from "zod";
4661
- var researchTaskCreateSchema = z113.object({
4662
- researchAgentId: z113.string(),
4663
- title: z113.string().max(100),
4664
- description: z113.string().max(500),
4665
- prompt: z113.string().max(500).optional(),
4666
- type: z113.nativeEnum(ResearchTaskType),
4667
- executionType: z113.nativeEnum(ResearchTaskExecutionType).default(ResearchTaskExecutionType.ON_DEMAND),
4668
- fileTagId: z113.string().optional(),
4669
- autoGeneratedTag: z113.object({
4670
- name: z113.string(),
4671
- icon: z113.string(),
4672
- color: z113.string()
4985
+ import { z as z114 } from "zod";
4986
+ var researchTaskCreateSchema = z114.object({
4987
+ researchAgentId: z114.string(),
4988
+ title: z114.string().max(100),
4989
+ description: z114.string().max(500),
4990
+ prompt: z114.string().max(500).optional(),
4991
+ type: z114.nativeEnum(ResearchTaskType),
4992
+ executionType: z114.nativeEnum(ResearchTaskExecutionType).default(ResearchTaskExecutionType.ON_DEMAND),
4993
+ fileTagId: z114.string().optional(),
4994
+ autoGeneratedTag: z114.object({
4995
+ name: z114.string(),
4996
+ icon: z114.string(),
4997
+ color: z114.string()
4673
4998
  }).optional()
4674
4999
  });
4675
5000
  var researchTaskScrapeCreateSchema = researchTaskCreateSchema.extend({
4676
- urls: z113.array(z113.string().url()).min(1),
4677
- canDiscoverLinks: z113.boolean()
5001
+ urls: z114.array(z114.string().url()).min(1),
5002
+ canDiscoverLinks: z114.boolean()
4678
5003
  });
4679
5004
  var researchTaskPeriodicCreateSchema = researchTaskCreateSchema.extend({
4680
- executionPeriodicStartAt: z113.coerce.date(),
4681
- executionPeriodicEndAt: z113.coerce.date(),
4682
- executionPeriodicFrequency: z113.nativeEnum(ResearchTaskPeriodicFrequencyType)
5005
+ executionPeriodicStartAt: z114.coerce.date(),
5006
+ executionPeriodicEndAt: z114.coerce.date(),
5007
+ executionPeriodicFrequency: z114.nativeEnum(ResearchTaskPeriodicFrequencyType)
4683
5008
  });
4684
5009
  var researchTaskScheduledCreateSchema = researchTaskCreateSchema.extend({
4685
- executionScheduledAt: z113.coerce.date()
5010
+ executionScheduledAt: z114.coerce.date()
4686
5011
  });
4687
5012
  var researchTaskDeepResearchCreateSchema = researchTaskCreateSchema.extend({
4688
- maxDepth: z113.number().min(1).max(10).optional()
5013
+ maxDepth: z114.number().min(1).max(10).optional()
4689
5014
  });
4690
5015
 
4691
5016
  // ../../b4m-core/packages/services/dist/src/researchTaskService/search.js
4692
- import { z as z114 } from "zod";
4693
- var searchResearchTasksSchema = z114.object({
4694
- search: z114.string().optional(),
5017
+ import { z as z115 } from "zod";
5018
+ var searchResearchTasksSchema = z115.object({
5019
+ search: z115.string().optional(),
4695
5020
  // ADD FILTERS SCHEMA HERE
4696
5021
  // filters: z
4697
5022
  // .object({
4698
5023
  // userId: z.string().optional(),
4699
5024
  // })
4700
5025
  // .optional(),
4701
- pagination: z114.object({
4702
- page: z114.coerce.number().optional(),
4703
- limit: z114.coerce.number().optional()
5026
+ pagination: z115.object({
5027
+ page: z115.coerce.number().optional(),
5028
+ limit: z115.coerce.number().optional()
4704
5029
  }).optional(),
4705
- orderBy: z114.object({
4706
- by: z114.enum(["createdAt", "updatedAt"]).optional(),
4707
- direction: z114.enum(["asc", "desc"]).optional()
5030
+ orderBy: z115.object({
5031
+ by: z115.enum(["createdAt", "updatedAt"]).optional(),
5032
+ direction: z115.enum(["asc", "desc"]).optional()
4708
5033
  }).optional()
4709
5034
  });
4710
5035
 
4711
5036
  // ../../b4m-core/packages/services/dist/src/researchTaskService/get.js
4712
- import { z as z115 } from "zod";
4713
- var getResearchTaskSchema = z115.object({
4714
- id: z115.string().min(1)
5037
+ import { z as z116 } from "zod";
5038
+ var getResearchTaskSchema = z116.object({
5039
+ id: z116.string().min(1)
4715
5040
  });
4716
5041
 
4717
5042
  // ../../b4m-core/packages/services/dist/src/researchTaskService/update.js
4718
- import { z as z116 } from "zod";
4719
- var updateResearchTaskSchema = z116.object({
4720
- id: z116.string(),
4721
- title: z116.string(),
4722
- description: z116.string(),
4723
- type: z116.nativeEnum(ResearchTaskType)
5043
+ import { z as z117 } from "zod";
5044
+ var updateResearchTaskSchema = z117.object({
5045
+ id: z117.string(),
5046
+ title: z117.string(),
5047
+ description: z117.string(),
5048
+ type: z117.nativeEnum(ResearchTaskType)
4724
5049
  });
4725
5050
  var researchTaskScrapeUpdateSchema = updateResearchTaskSchema.extend({
4726
- urls: z116.array(z116.string().url()).min(1),
4727
- canDiscoverLinks: z116.boolean()
5051
+ urls: z117.array(z117.string().url()).min(1),
5052
+ canDiscoverLinks: z117.boolean()
4728
5053
  });
4729
5054
 
4730
5055
  // ../../b4m-core/packages/services/dist/src/researchTaskService/listByAgentId.js
4731
- import { z as z117 } from "zod";
4732
- var listByAgentIdSchema = z117.object({
4733
- researchAgentId: z117.string()
5056
+ import { z as z118 } from "zod";
5057
+ var listByAgentIdSchema = z118.object({
5058
+ researchAgentId: z118.string()
4734
5059
  });
4735
5060
 
4736
5061
  // ../../b4m-core/packages/services/dist/src/researchTaskService/remove.js
4737
- import { z as z118 } from "zod";
4738
- var researchTaskRemoveSchema = z118.object({
4739
- id: z118.string().min(1)
5062
+ import { z as z119 } from "zod";
5063
+ var researchTaskRemoveSchema = z119.object({
5064
+ id: z119.string().min(1)
4740
5065
  });
4741
5066
 
4742
5067
  // ../../b4m-core/packages/services/dist/src/researchTaskService/retry.js
4743
- import { z as z119 } from "zod";
4744
- var researchTaskRetrySchema = z119.object({
4745
- id: z119.string(),
4746
- userId: z119.string()
5068
+ import { z as z120 } from "zod";
5069
+ var researchTaskRetrySchema = z120.object({
5070
+ id: z120.string(),
5071
+ userId: z120.string()
4747
5072
  });
4748
5073
 
4749
5074
  // ../../b4m-core/packages/services/dist/src/researchTaskService/processDiscoveredLinks.js
4750
5075
  import axios4 from "axios";
4751
- import { z as z120 } from "zod";
5076
+ import { z as z121 } from "zod";
4752
5077
  import plimit from "p-limit";
4753
5078
  import pLimit2 from "p-limit";
4754
- var researchTaskProcessDiscoveredLinksSchema = z120.object({
4755
- id: z120.string()
5079
+ var researchTaskProcessDiscoveredLinksSchema = z121.object({
5080
+ id: z121.string()
4756
5081
  });
4757
5082
 
4758
5083
  // ../../b4m-core/packages/services/dist/src/researchTaskService/downloadRelevantLinks.js
4759
- import { z as z121 } from "zod";
5084
+ import { z as z122 } from "zod";
4760
5085
  import plimit2 from "p-limit";
4761
5086
  import axios5 from "axios";
4762
5087
  import { fileTypeFromBuffer } from "file-type";
4763
- var researchTaskDownloadRelevantLinksSchema = z121.object({
4764
- id: z121.string()
5088
+ var researchTaskDownloadRelevantLinksSchema = z122.object({
5089
+ id: z122.string()
4765
5090
  });
4766
5091
 
4767
5092
  // ../../b4m-core/packages/services/dist/src/researchData/remove.js
4768
- import { z as z122 } from "zod";
4769
- var researchDataRemoveSchema = z122.object({
4770
- id: z122.string(),
4771
- researchAgentId: z122.string()
5093
+ import { z as z123 } from "zod";
5094
+ var researchDataRemoveSchema = z123.object({
5095
+ id: z123.string(),
5096
+ researchAgentId: z123.string()
4772
5097
  });
4773
5098
 
4774
5099
  // ../../b4m-core/packages/services/dist/src/taskSchedulerService/create.js
4775
- import { z as z123 } from "zod";
4776
- var researchTaskPayload = z123.object({
4777
- id: z123.string(),
4778
- userId: z123.string()
5100
+ import { z as z124 } from "zod";
5101
+ var researchTaskPayload = z124.object({
5102
+ id: z124.string(),
5103
+ userId: z124.string()
4779
5104
  });
4780
- var customTaskPayload = z123.object({
4781
- test: z123.string()
5105
+ var customTaskPayload = z124.object({
5106
+ test: z124.string()
4782
5107
  });
4783
- var taskSchedulerCreate = z123.discriminatedUnion("handler", [
4784
- z123.object({
4785
- handler: z123.literal(TaskScheduleHandler.RESEARCH_TASK_PROCESS),
5108
+ var taskSchedulerCreate = z124.discriminatedUnion("handler", [
5109
+ z124.object({
5110
+ handler: z124.literal(TaskScheduleHandler.RESEARCH_TASK_PROCESS),
4786
5111
  payload: researchTaskPayload,
4787
- processDate: z123.date()
5112
+ processDate: z124.date()
4788
5113
  }),
4789
- z123.object({
4790
- handler: z123.literal(TaskScheduleHandler.CUSTOM_TASK_PROCESS),
5114
+ z124.object({
5115
+ handler: z124.literal(TaskScheduleHandler.CUSTOM_TASK_PROCESS),
4791
5116
  payload: customTaskPayload,
4792
- processDate: z123.date()
5117
+ processDate: z124.date()
4793
5118
  })
4794
5119
  ]);
4795
5120
 
4796
5121
  // ../../b4m-core/packages/services/dist/src/tagService/createFileTag.js
4797
- import { z as z124 } from "zod";
4798
- var tagCreateFileTagSchema = z124.object({
4799
- name: z124.string(),
4800
- icon: z124.string().optional(),
4801
- color: z124.string().optional(),
4802
- description: z124.string().optional()
4803
- });
4804
-
4805
- // ../../b4m-core/packages/services/dist/src/tagService/create.js
4806
5122
  import { z as z125 } from "zod";
4807
- var tagCreateSchema = z125.object({
5123
+ var tagCreateFileTagSchema = z125.object({
4808
5124
  name: z125.string(),
4809
5125
  icon: z125.string().optional(),
4810
- description: z125.string().optional(),
4811
5126
  color: z125.string().optional(),
4812
- type: z125.nativeEnum(TagType)
5127
+ description: z125.string().optional()
4813
5128
  });
4814
5129
 
4815
- // ../../b4m-core/packages/services/dist/src/tagService/update.js
5130
+ // ../../b4m-core/packages/services/dist/src/tagService/create.js
4816
5131
  import { z as z126 } from "zod";
4817
- var tagUpdateSchema = z126.object({
4818
- id: z126.string(),
4819
- name: z126.string().optional(),
5132
+ var tagCreateSchema = z126.object({
5133
+ name: z126.string(),
4820
5134
  icon: z126.string().optional(),
4821
5135
  description: z126.string().optional(),
4822
- color: z126.string().optional()
5136
+ color: z126.string().optional(),
5137
+ type: z126.nativeEnum(TagType)
4823
5138
  });
4824
5139
 
4825
- // ../../b4m-core/packages/services/dist/src/tagService/remove.js
5140
+ // ../../b4m-core/packages/services/dist/src/tagService/update.js
4826
5141
  import { z as z127 } from "zod";
4827
- var tagRemoveSchema = z127.object({
4828
- id: z127.string()
5142
+ var tagUpdateSchema = z127.object({
5143
+ id: z127.string(),
5144
+ name: z127.string().optional(),
5145
+ icon: z127.string().optional(),
5146
+ description: z127.string().optional(),
5147
+ color: z127.string().optional()
4829
5148
  });
4830
5149
 
4831
- // ../../b4m-core/packages/services/dist/src/artifactService/create.js
5150
+ // ../../b4m-core/packages/services/dist/src/tagService/remove.js
4832
5151
  import { z as z128 } from "zod";
4833
- var createArtifactSchema = z128.object({
4834
- id: z128.string().optional(),
5152
+ var tagRemoveSchema = z128.object({
5153
+ id: z128.string()
5154
+ });
5155
+
5156
+ // ../../b4m-core/packages/services/dist/src/artifactService/create.js
5157
+ import { z as z129 } from "zod";
5158
+ var createArtifactSchema = z129.object({
5159
+ id: z129.string().optional(),
4835
5160
  // Allow custom ID for AI-generated artifacts
4836
- type: z128.enum(["mermaid", "recharts", "python", "react", "html", "svg", "code", "quest", "file", "questmaster"]),
4837
- title: z128.string().min(1).max(255),
4838
- description: z128.string().max(1e3).optional(),
4839
- content: z128.string().min(1),
4840
- projectId: z128.string().optional(),
4841
- organizationId: z128.string().optional(),
4842
- visibility: z128.enum(["private", "project", "organization", "public"]).default("private"),
4843
- tags: z128.array(z128.string().max(50)).max(20).default([]),
4844
- versionTag: z128.string().max(100).optional(),
4845
- sourceQuestId: z128.string().optional(),
4846
- sessionId: z128.string().optional(),
4847
- parentArtifactId: z128.string().optional(),
4848
- permissions: z128.object({
4849
- canRead: z128.array(z128.string()).default([]),
4850
- canWrite: z128.array(z128.string()).default([]),
4851
- canDelete: z128.array(z128.string()).default([]),
4852
- isPublic: z128.boolean().default(false),
4853
- inheritFromProject: z128.boolean().default(true)
5161
+ type: z129.enum(["mermaid", "recharts", "python", "react", "html", "svg", "code", "quest", "file", "questmaster"]),
5162
+ title: z129.string().min(1).max(255),
5163
+ description: z129.string().max(1e3).optional(),
5164
+ content: z129.string().min(1),
5165
+ projectId: z129.string().optional(),
5166
+ organizationId: z129.string().optional(),
5167
+ visibility: z129.enum(["private", "project", "organization", "public"]).default("private"),
5168
+ tags: z129.array(z129.string().max(50)).max(20).default([]),
5169
+ versionTag: z129.string().max(100).optional(),
5170
+ sourceQuestId: z129.string().optional(),
5171
+ sessionId: z129.string().optional(),
5172
+ parentArtifactId: z129.string().optional(),
5173
+ permissions: z129.object({
5174
+ canRead: z129.array(z129.string()).default([]),
5175
+ canWrite: z129.array(z129.string()).default([]),
5176
+ canDelete: z129.array(z129.string()).default([]),
5177
+ isPublic: z129.boolean().default(false),
5178
+ inheritFromProject: z129.boolean().default(true)
4854
5179
  }).optional(),
4855
- metadata: z128.record(z128.unknown()).default({})
5180
+ metadata: z129.record(z129.unknown()).default({})
4856
5181
  });
4857
5182
 
4858
5183
  // ../../b4m-core/packages/services/dist/src/artifactService/get.js
4859
- import { z as z129 } from "zod";
4860
- var getArtifactSchema = z129.object({
4861
- id: z129.string(),
4862
- includeContent: z129.boolean().default(false),
4863
- includeVersions: z129.boolean().default(false),
4864
- version: z129.number().optional()
5184
+ import { z as z130 } from "zod";
5185
+ var getArtifactSchema = z130.object({
5186
+ id: z130.string(),
5187
+ includeContent: z130.boolean().default(false),
5188
+ includeVersions: z130.boolean().default(false),
5189
+ version: z130.number().optional()
4865
5190
  });
4866
5191
 
4867
5192
  // ../../b4m-core/packages/services/dist/src/artifactService/list.js
4868
- import { z as z130 } from "zod";
4869
- var listArtifactsSchema = z130.object({
4870
- type: z130.string().optional(),
4871
- status: z130.enum(["draft", "review", "published", "archived"]).optional(),
4872
- visibility: z130.enum(["private", "project", "organization", "public"]).optional(),
4873
- projectId: z130.string().optional(),
4874
- sessionId: z130.string().optional(),
4875
- tags: z130.array(z130.string()).optional(),
4876
- search: z130.string().optional(),
4877
- limit: z130.number().min(1).max(100).default(20),
4878
- offset: z130.number().min(0).default(0),
4879
- sortBy: z130.enum(["createdAt", "updatedAt", "title", "type"]).default("updatedAt"),
4880
- sortOrder: z130.enum(["asc", "desc"]).default("desc"),
4881
- includeDeleted: z130.boolean().default(false)
5193
+ import { z as z131 } from "zod";
5194
+ var listArtifactsSchema = z131.object({
5195
+ type: z131.string().optional(),
5196
+ status: z131.enum(["draft", "review", "published", "archived"]).optional(),
5197
+ visibility: z131.enum(["private", "project", "organization", "public"]).optional(),
5198
+ projectId: z131.string().optional(),
5199
+ sessionId: z131.string().optional(),
5200
+ tags: z131.array(z131.string()).optional(),
5201
+ search: z131.string().optional(),
5202
+ limit: z131.number().min(1).max(100).default(20),
5203
+ offset: z131.number().min(0).default(0),
5204
+ sortBy: z131.enum(["createdAt", "updatedAt", "title", "type"]).default("updatedAt"),
5205
+ sortOrder: z131.enum(["asc", "desc"]).default("desc"),
5206
+ includeDeleted: z131.boolean().default(false)
4882
5207
  });
4883
5208
 
4884
5209
  // ../../b4m-core/packages/services/dist/src/artifactService/update.js
4885
- import { z as z131 } from "zod";
4886
- var updateArtifactSchema = z131.object({
4887
- id: z131.string(),
4888
- title: z131.string().min(1).max(255).optional(),
4889
- description: z131.string().max(1e3).optional(),
4890
- content: z131.string().optional(),
4891
- visibility: z131.enum(["private", "project", "organization", "public"]).optional(),
4892
- status: z131.enum(["draft", "review", "published", "archived"]).optional(),
4893
- tags: z131.array(z131.string().max(50)).max(20).optional(),
4894
- versionTag: z131.string().max(100).optional(),
4895
- permissions: z131.object({
4896
- canRead: z131.array(z131.string()).optional(),
4897
- canWrite: z131.array(z131.string()).optional(),
4898
- canDelete: z131.array(z131.string()).optional(),
4899
- isPublic: z131.boolean().optional(),
4900
- inheritFromProject: z131.boolean().optional()
5210
+ import { z as z132 } from "zod";
5211
+ var updateArtifactSchema = z132.object({
5212
+ id: z132.string(),
5213
+ title: z132.string().min(1).max(255).optional(),
5214
+ description: z132.string().max(1e3).optional(),
5215
+ content: z132.string().optional(),
5216
+ visibility: z132.enum(["private", "project", "organization", "public"]).optional(),
5217
+ status: z132.enum(["draft", "review", "published", "archived"]).optional(),
5218
+ tags: z132.array(z132.string().max(50)).max(20).optional(),
5219
+ versionTag: z132.string().max(100).optional(),
5220
+ permissions: z132.object({
5221
+ canRead: z132.array(z132.string()).optional(),
5222
+ canWrite: z132.array(z132.string()).optional(),
5223
+ canDelete: z132.array(z132.string()).optional(),
5224
+ isPublic: z132.boolean().optional(),
5225
+ inheritFromProject: z132.boolean().optional()
4901
5226
  }).optional(),
4902
- metadata: z131.record(z131.unknown()).optional(),
4903
- changes: z131.array(z131.string()).optional(),
4904
- changeDescription: z131.string().max(1e3).optional(),
4905
- createNewVersion: z131.boolean().optional(),
4906
- versionMessage: z131.string().max(500).optional()
5227
+ metadata: z132.record(z132.unknown()).optional(),
5228
+ changes: z132.array(z132.string()).optional(),
5229
+ changeDescription: z132.string().max(1e3).optional(),
5230
+ createNewVersion: z132.boolean().optional(),
5231
+ versionMessage: z132.string().max(500).optional()
4907
5232
  });
4908
5233
 
4909
5234
  // ../../b4m-core/packages/services/dist/src/artifactService/delete.js
4910
- import { z as z132 } from "zod";
4911
- var deleteArtifactSchema = z132.object({
4912
- id: z132.string(),
4913
- hardDelete: z132.boolean().default(false)
5235
+ import { z as z133 } from "zod";
5236
+ var deleteArtifactSchema = z133.object({
5237
+ id: z133.string(),
5238
+ hardDelete: z133.boolean().default(false)
4914
5239
  // For future implementation
4915
5240
  });
4916
5241
 
4917
5242
  // ../../b4m-core/packages/services/dist/src/questMasterService/create.js
4918
- import { z as z133 } from "zod";
4919
- var questSchema = z133.object({
4920
- id: z133.string(),
4921
- title: z133.string().min(1).max(255),
4922
- description: z133.string().max(1e3),
4923
- status: z133.enum(["not_started", "in_progress", "completed", "blocked"]).default("not_started"),
4924
- order: z133.number().min(0),
4925
- dependencies: z133.array(z133.string()).default([]),
4926
- estimatedTime: z133.string().optional()
4927
- });
4928
- var questResourceSchema = z133.object({
4929
- title: z133.string().min(1).max(255),
4930
- url: z133.string().url(),
4931
- type: z133.enum(["documentation", "tutorial", "reference", "example"])
4932
- });
4933
- var createQuestMasterSchema = z133.object({
4934
- title: z133.string().min(1).max(255),
4935
- description: z133.string().max(1e3).optional(),
4936
- goal: z133.string().min(1).max(1e3),
4937
- complexity: z133.enum(["beginner", "intermediate", "advanced", "expert"]),
4938
- estimatedTotalTime: z133.string().optional(),
4939
- prerequisites: z133.array(z133.string().max(200)).default([]),
4940
- quests: z133.array(questSchema).min(1),
4941
- resources: z133.array(questResourceSchema).default([]),
4942
- projectId: z133.string().optional(),
4943
- organizationId: z133.string().optional(),
4944
- visibility: z133.enum(["private", "project", "organization", "public"]).default("private"),
4945
- tags: z133.array(z133.string().max(50)).max(20).default([]),
4946
- permissions: z133.object({
4947
- canRead: z133.array(z133.string()).default([]),
4948
- canWrite: z133.array(z133.string()).default([]),
4949
- canDelete: z133.array(z133.string()).default([]),
4950
- isPublic: z133.boolean().default(false),
4951
- inheritFromProject: z133.boolean().default(true)
5243
+ import { z as z134 } from "zod";
5244
+ var questSchema = z134.object({
5245
+ id: z134.string(),
5246
+ title: z134.string().min(1).max(255),
5247
+ description: z134.string().max(1e3),
5248
+ status: z134.enum(["not_started", "in_progress", "completed", "blocked"]).default("not_started"),
5249
+ order: z134.number().min(0),
5250
+ dependencies: z134.array(z134.string()).default([]),
5251
+ estimatedTime: z134.string().optional()
5252
+ });
5253
+ var questResourceSchema = z134.object({
5254
+ title: z134.string().min(1).max(255),
5255
+ url: z134.string().url(),
5256
+ type: z134.enum(["documentation", "tutorial", "reference", "example"])
5257
+ });
5258
+ var createQuestMasterSchema = z134.object({
5259
+ title: z134.string().min(1).max(255),
5260
+ description: z134.string().max(1e3).optional(),
5261
+ goal: z134.string().min(1).max(1e3),
5262
+ complexity: z134.enum(["beginner", "intermediate", "advanced", "expert"]),
5263
+ estimatedTotalTime: z134.string().optional(),
5264
+ prerequisites: z134.array(z134.string().max(200)).default([]),
5265
+ quests: z134.array(questSchema).min(1),
5266
+ resources: z134.array(questResourceSchema).default([]),
5267
+ projectId: z134.string().optional(),
5268
+ organizationId: z134.string().optional(),
5269
+ visibility: z134.enum(["private", "project", "organization", "public"]).default("private"),
5270
+ tags: z134.array(z134.string().max(50)).max(20).default([]),
5271
+ permissions: z134.object({
5272
+ canRead: z134.array(z134.string()).default([]),
5273
+ canWrite: z134.array(z134.string()).default([]),
5274
+ canDelete: z134.array(z134.string()).default([]),
5275
+ isPublic: z134.boolean().default(false),
5276
+ inheritFromProject: z134.boolean().default(true)
4952
5277
  }).optional(),
4953
- sourceQuestId: z133.string().optional(),
4954
- sessionId: z133.string().optional(),
4955
- metadata: z133.record(z133.unknown()).default({})
5278
+ sourceQuestId: z134.string().optional(),
5279
+ sessionId: z134.string().optional(),
5280
+ metadata: z134.record(z134.unknown()).default({})
4956
5281
  });
4957
5282
 
4958
5283
  // ../../b4m-core/packages/services/dist/src/questMasterService/updateQuestStatus.js
4959
- import { z as z134 } from "zod";
4960
- var updateQuestStatusSchema = z134.object({
4961
- artifactId: z134.string(),
4962
- questId: z134.string(),
4963
- status: z134.enum(["not_started", "in_progress", "completed", "blocked"]),
4964
- completionNote: z134.string().max(500).optional()
5284
+ import { z as z135 } from "zod";
5285
+ var updateQuestStatusSchema = z135.object({
5286
+ artifactId: z135.string(),
5287
+ questId: z135.string(),
5288
+ status: z135.enum(["not_started", "in_progress", "completed", "blocked"]),
5289
+ completionNote: z135.string().max(500).optional()
4965
5290
  });
4966
5291
 
4967
5292
  // ../../b4m-core/packages/services/dist/src/dataLakeService/opensearchClient.js
@@ -4975,69 +5300,69 @@ import { toFile } from "openai/uploads";
4975
5300
  import { Readable } from "stream";
4976
5301
  import { TranscribeClient, StartTranscriptionJobCommand, GetTranscriptionJobCommand, LanguageCode, MediaFormat } from "@aws-sdk/client-transcribe";
4977
5302
  import { S3Client, PutObjectCommand, GetObjectCommand, DeleteObjectCommand } from "@aws-sdk/client-s3";
4978
- import { v4 as uuidv44 } from "uuid";
5303
+ import { v4 as uuidv45 } from "uuid";
4979
5304
 
4980
5305
  // ../../b4m-core/packages/services/dist/src/emailIngestionService/processIngestedEmail.js
4981
5306
  import { randomUUID as randomUUID5 } from "crypto";
4982
5307
 
4983
5308
  // ../../b4m-core/packages/services/dist/src/emailIngestionService/types.js
4984
- import { z as z135 } from "zod";
4985
- var processIngestedEmailOptionsSchema = z135.object({
4986
- platformDomain: z135.string().optional(),
4987
- isNewsletter: z135.boolean().optional()
5309
+ import { z as z136 } from "zod";
5310
+ var processIngestedEmailOptionsSchema = z136.object({
5311
+ platformDomain: z136.string().optional(),
5312
+ isNewsletter: z136.boolean().optional()
4988
5313
  }).optional();
4989
- var emailAttachmentSchema = z135.object({
4990
- filename: z135.string().optional(),
4991
- contentType: z135.string().optional(),
4992
- contentDisposition: z135.string().optional(),
4993
- size: z135.number().min(0),
4994
- content: z135.instanceof(Buffer),
4995
- related: z135.boolean().optional()
4996
- });
4997
- var parsedEmailObjectSchema = z135.object({
4998
- messageId: z135.string().optional(),
4999
- inReplyTo: z135.string().optional(),
5000
- references: z135.union([z135.string(), z135.array(z135.string())]).optional(),
5001
- from: z135.any().optional(),
5314
+ var emailAttachmentSchema = z136.object({
5315
+ filename: z136.string().optional(),
5316
+ contentType: z136.string().optional(),
5317
+ contentDisposition: z136.string().optional(),
5318
+ size: z136.number().min(0),
5319
+ content: z136.instanceof(Buffer),
5320
+ related: z136.boolean().optional()
5321
+ });
5322
+ var parsedEmailObjectSchema = z136.object({
5323
+ messageId: z136.string().optional(),
5324
+ inReplyTo: z136.string().optional(),
5325
+ references: z136.union([z136.string(), z136.array(z136.string())]).optional(),
5326
+ from: z136.any().optional(),
5002
5327
  // Complex email address object
5003
- to: z135.any().optional(),
5004
- cc: z135.any().optional(),
5005
- bcc: z135.any().optional(),
5006
- subject: z135.string().optional(),
5007
- date: z135.date().optional(),
5008
- text: z135.string().optional(),
5009
- html: z135.string().optional(),
5010
- attachments: z135.array(emailAttachmentSchema).optional()
5011
- });
5012
- var processIngestedEmailSchema = z135.object({
5328
+ to: z136.any().optional(),
5329
+ cc: z136.any().optional(),
5330
+ bcc: z136.any().optional(),
5331
+ subject: z136.string().optional(),
5332
+ date: z136.date().optional(),
5333
+ text: z136.string().optional(),
5334
+ html: z136.string().optional(),
5335
+ attachments: z136.array(emailAttachmentSchema).optional()
5336
+ });
5337
+ var processIngestedEmailSchema = z136.object({
5013
5338
  parsedEmail: parsedEmailObjectSchema,
5014
- rawEmailS3Key: z135.string().min(1, "rawEmailS3Key cannot be empty"),
5339
+ rawEmailS3Key: z136.string().min(1, "rawEmailS3Key cannot be empty"),
5015
5340
  options: processIngestedEmailOptionsSchema
5016
5341
  });
5017
5342
 
5018
5343
  // ../../b4m-core/packages/services/dist/src/emailAnalysisService/types.js
5019
- import { z as z136 } from "zod";
5020
- var llmAnalysisResponseSchema = z136.object({
5021
- summary: z136.string().min(1, "Summary cannot be empty"),
5022
- entities: z136.object({
5023
- companies: z136.array(z136.string()).default([]),
5024
- people: z136.array(z136.string()).default([]),
5025
- products: z136.array(z136.string()).default([]),
5026
- technologies: z136.array(z136.string()).default([])
5344
+ import { z as z137 } from "zod";
5345
+ var llmAnalysisResponseSchema = z137.object({
5346
+ summary: z137.string().min(1, "Summary cannot be empty"),
5347
+ entities: z137.object({
5348
+ companies: z137.array(z137.string()).default([]),
5349
+ people: z137.array(z137.string()).default([]),
5350
+ products: z137.array(z137.string()).default([]),
5351
+ technologies: z137.array(z137.string()).default([])
5027
5352
  }),
5028
- sentiment: z136.enum(["positive", "neutral", "negative", "urgent"]),
5029
- actionItems: z136.array(z136.object({
5030
- description: z136.string(),
5031
- deadline: z136.string().optional()
5353
+ sentiment: z137.enum(["positive", "neutral", "negative", "urgent"]),
5354
+ actionItems: z137.array(z137.object({
5355
+ description: z137.string(),
5356
+ deadline: z137.string().optional()
5032
5357
  // ISO date string from LLM
5033
5358
  })).default([]),
5034
- privacyRecommendation: z136.enum(["public", "team", "private"]),
5035
- embargoDetected: z136.boolean().default(false),
5036
- suggestedTags: z136.array(z136.string()).default([])
5359
+ privacyRecommendation: z137.enum(["public", "team", "private"]),
5360
+ embargoDetected: z137.boolean().default(false),
5361
+ suggestedTags: z137.array(z137.string()).default([])
5037
5362
  });
5038
5363
 
5039
5364
  // ../../b4m-core/packages/services/dist/src/llm/ChatCompletion.js
5040
- import { z as z138 } from "zod";
5365
+ import { z as z139 } from "zod";
5041
5366
 
5042
5367
  // ../../b4m-core/packages/services/dist/src/llm/ChatCompletionInvoke.js
5043
5368
  import { fromZodError } from "zod-validation-error";
@@ -5136,7 +5461,7 @@ var weatherTool = {
5136
5461
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/imageGeneration/index.js
5137
5462
  import axios6 from "axios";
5138
5463
  import { fileTypeFromBuffer as fileTypeFromBuffer2 } from "file-type";
5139
- import { v4 as uuidv45 } from "uuid";
5464
+ import { v4 as uuidv46 } from "uuid";
5140
5465
  async function downloadImage(url) {
5141
5466
  if (url.startsWith("data:image/")) {
5142
5467
  const base64Data = url.split(",")[1];
@@ -5150,9 +5475,9 @@ async function processAndStoreImages(images, context) {
5150
5475
  return Promise.all(images.map(async (image) => {
5151
5476
  const buffer = await downloadImage(image);
5152
5477
  const fileType = await fileTypeFromBuffer2(buffer);
5153
- const filename = `${uuidv45()}.${fileType?.ext}`;
5154
- const path15 = await context.imageGenerateStorage.upload(buffer, filename, {});
5155
- return path15;
5478
+ const filename = `${uuidv46()}.${fileType?.ext}`;
5479
+ const path16 = await context.imageGenerateStorage.upload(buffer, filename, {});
5480
+ return path16;
5156
5481
  }));
5157
5482
  }
5158
5483
  async function updateQuestAndReturnMarkdown(storedImageUrls, context) {
@@ -6125,17 +6450,17 @@ var rechartsTool = {
6125
6450
  };
6126
6451
 
6127
6452
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/editFile/index.js
6128
- import { z as z137 } from "zod";
6453
+ import { z as z138 } from "zod";
6129
6454
  import { diffLines as diffLines2 } from "diff";
6130
- var editFileSchema = z137.object({
6131
- fileId: z137.string().describe("The ID of the file to edit"),
6132
- instruction: z137.string().describe("Natural language instruction describing the changes to make"),
6133
- selection: z137.object({
6134
- start: z137.number().describe("Starting character position of the selection"),
6135
- end: z137.number().describe("Ending character position of the selection")
6455
+ var editFileSchema = z138.object({
6456
+ fileId: z138.string().describe("The ID of the file to edit"),
6457
+ instruction: z138.string().describe("Natural language instruction describing the changes to make"),
6458
+ selection: z138.object({
6459
+ start: z138.number().describe("Starting character position of the selection"),
6460
+ end: z138.number().describe("Ending character position of the selection")
6136
6461
  }).optional().describe("Optional selection range to edit within the file"),
6137
- preserveFormatting: z137.boolean().optional().default(true).describe("Whether to preserve the original formatting style"),
6138
- returnDiff: z137.boolean().optional().default(true).describe("Whether to return a diff of the changes")
6462
+ preserveFormatting: z138.boolean().optional().default(true).describe("Whether to preserve the original formatting style"),
6463
+ returnDiff: z138.boolean().optional().default(true).describe("Whether to return a diff of the changes")
6139
6464
  });
6140
6465
  function generateSimpleDiff(original, modified) {
6141
6466
  const differences = diffLines2(original, modified);
@@ -6319,7 +6644,7 @@ Return only the edited content without any markdown code blocks or explanations.
6319
6644
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/imageEdit/index.js
6320
6645
  import axios7 from "axios";
6321
6646
  import { fileTypeFromBuffer as fileTypeFromBuffer3 } from "file-type";
6322
- import { v4 as uuidv46 } from "uuid";
6647
+ import { v4 as uuidv47 } from "uuid";
6323
6648
  async function downloadImage2(url) {
6324
6649
  if (url.startsWith("data:image/")) {
6325
6650
  const base64Data = url.split(",")[1];
@@ -6363,9 +6688,9 @@ async function getImageFromFileId(fileId, context) {
6363
6688
  async function processAndStoreImage(imageUrl, context) {
6364
6689
  const buffer = await downloadImage2(imageUrl);
6365
6690
  const fileType = await fileTypeFromBuffer3(buffer);
6366
- const filename = `${uuidv46()}.${fileType?.ext}`;
6367
- const path15 = await context.imageGenerateStorage.upload(buffer, filename, {});
6368
- return path15;
6691
+ const filename = `${uuidv47()}.${fileType?.ext}`;
6692
+ const path16 = await context.imageGenerateStorage.upload(buffer, filename, {});
6693
+ return path16;
6369
6694
  }
6370
6695
  async function updateQuestAndReturnMarkdown2(storedImagePath, context) {
6371
6696
  await context.onFinish?.("edit_image", storedImagePath);
@@ -7894,8 +8219,8 @@ var getHeliocentricCoords = (planet, T) => {
7894
8219
  const sinNode = Math.sin(longNode);
7895
8220
  const x = r * (cosNode * cosOmega - sinNode * sinOmega * cosI);
7896
8221
  const y = r * (sinNode * cosOmega + cosNode * sinOmega * cosI);
7897
- const z144 = r * sinOmega * sinI;
7898
- return { x, y, z: z144, r };
8222
+ const z145 = r * sinOmega * sinI;
8223
+ return { x, y, z: z145, r };
7899
8224
  };
7900
8225
  var getGeocentricEcliptic = (planet, earth) => {
7901
8226
  const dx = planet.x - earth.x;
@@ -8202,15 +8527,15 @@ var planetVisibilityTool = {
8202
8527
  };
8203
8528
 
8204
8529
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/fileRead/index.js
8205
- import { promises as fs7 } from "fs";
8530
+ import { promises as fs8 } from "fs";
8206
8531
  import { existsSync as existsSync4, statSync as statSync4 } from "fs";
8207
- import path6 from "path";
8532
+ import path7 from "path";
8208
8533
  var MAX_FILE_SIZE2 = 10 * 1024 * 1024;
8209
8534
  async function readFileContent(params) {
8210
8535
  const { path: filePath, encoding = "utf-8", maxLines } = params;
8211
- const normalizedPath = path6.normalize(filePath);
8212
- const resolvedPath = path6.resolve(process.cwd(), normalizedPath);
8213
- const cwd = path6.resolve(process.cwd());
8536
+ const normalizedPath = path7.normalize(filePath);
8537
+ const resolvedPath = path7.resolve(process.cwd(), normalizedPath);
8538
+ const cwd = path7.resolve(process.cwd());
8214
8539
  if (!resolvedPath.startsWith(cwd)) {
8215
8540
  throw new Error(`Access denied: Cannot read files outside of current working directory`);
8216
8541
  }
@@ -8228,7 +8553,7 @@ async function readFileContent(params) {
8228
8553
  if (isBinary && encoding === "utf-8") {
8229
8554
  throw new Error(`File appears to be binary. Use encoding 'base64' to read binary files, or specify a different encoding.`);
8230
8555
  }
8231
- const content = await fs7.readFile(resolvedPath, encoding);
8556
+ const content = await fs8.readFile(resolvedPath, encoding);
8232
8557
  if (maxLines && typeof content === "string") {
8233
8558
  const lines = content.split("\n");
8234
8559
  if (lines.length > maxLines) {
@@ -8243,7 +8568,7 @@ ${content}`;
8243
8568
  }
8244
8569
  async function checkIfBinary(filePath) {
8245
8570
  const buffer = Buffer.alloc(8192);
8246
- const fd = await fs7.open(filePath, "r");
8571
+ const fd = await fs8.open(filePath, "r");
8247
8572
  try {
8248
8573
  const { bytesRead } = await fd.read(buffer, 0, 8192, 0);
8249
8574
  const chunk = buffer.slice(0, bytesRead);
@@ -8260,7 +8585,7 @@ var fileReadTool = {
8260
8585
  context.logger.info("\u{1F4C4} FileRead: Reading file", { path: params.path });
8261
8586
  try {
8262
8587
  const content = await readFileContent(params);
8263
- const stats = statSync4(path6.resolve(process.cwd(), path6.normalize(params.path)));
8588
+ const stats = statSync4(path7.resolve(process.cwd(), path7.normalize(params.path)));
8264
8589
  context.logger.info("\u2705 FileRead: Success", {
8265
8590
  path: params.path,
8266
8591
  size: stats.size,
@@ -8300,25 +8625,25 @@ var fileReadTool = {
8300
8625
  };
8301
8626
 
8302
8627
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/createFile/index.js
8303
- import { promises as fs8 } from "fs";
8628
+ import { promises as fs9 } from "fs";
8304
8629
  import { existsSync as existsSync5 } from "fs";
8305
- import path7 from "path";
8630
+ import path8 from "path";
8306
8631
  async function createFile(params) {
8307
8632
  const { path: filePath, content, createDirectories = true } = params;
8308
- const normalizedPath = path7.normalize(filePath);
8309
- const resolvedPath = path7.resolve(process.cwd(), normalizedPath);
8310
- const cwd = path7.resolve(process.cwd());
8633
+ const normalizedPath = path8.normalize(filePath);
8634
+ const resolvedPath = path8.resolve(process.cwd(), normalizedPath);
8635
+ const cwd = path8.resolve(process.cwd());
8311
8636
  if (!resolvedPath.startsWith(cwd)) {
8312
8637
  throw new Error(`Access denied: Cannot create files outside of current working directory`);
8313
8638
  }
8314
8639
  const fileExists = existsSync5(resolvedPath);
8315
8640
  const action = fileExists ? "overwritten" : "created";
8316
8641
  if (createDirectories) {
8317
- const dir = path7.dirname(resolvedPath);
8318
- await fs8.mkdir(dir, { recursive: true });
8642
+ const dir = path8.dirname(resolvedPath);
8643
+ await fs9.mkdir(dir, { recursive: true });
8319
8644
  }
8320
- await fs8.writeFile(resolvedPath, content, "utf-8");
8321
- const stats = await fs8.stat(resolvedPath);
8645
+ await fs9.writeFile(resolvedPath, content, "utf-8");
8646
+ const stats = await fs9.stat(resolvedPath);
8322
8647
  const lines = content.split("\n").length;
8323
8648
  return `File ${action} successfully: ${filePath}
8324
8649
  Size: ${stats.size} bytes
@@ -8329,7 +8654,7 @@ var createFileTool = {
8329
8654
  implementation: (context) => ({
8330
8655
  toolFn: async (value) => {
8331
8656
  const params = value;
8332
- const fileExists = existsSync5(path7.resolve(process.cwd(), path7.normalize(params.path)));
8657
+ const fileExists = existsSync5(path8.resolve(process.cwd(), path8.normalize(params.path)));
8333
8658
  context.logger.info(`\u{1F4DD} CreateFile: ${fileExists ? "Overwriting" : "Creating"} file`, {
8334
8659
  path: params.path,
8335
8660
  size: params.content.length
@@ -8371,7 +8696,7 @@ var createFileTool = {
8371
8696
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/globFiles/index.js
8372
8697
  import { readdir } from "fs/promises";
8373
8698
  import { statSync as statSync5 } from "fs";
8374
- import path8 from "path";
8699
+ import path9 from "path";
8375
8700
  function matchGlob(filePath, pattern) {
8376
8701
  let regexPattern = pattern.replace(/\./g, "\\.").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (_, options) => `(${options.split(",").join("|")})`).replace(/\[([^\]]+)\]/g, "[$1]");
8377
8702
  regexPattern = regexPattern.replace(/\{\{GLOBSTAR\}\}\//g, "(.*/)?").replace(/\/\{\{GLOBSTAR\}\}/g, "(/.*)?").replace(/\{\{GLOBSTAR\}\}/g, ".*");
@@ -8389,8 +8714,8 @@ async function walkDir(dir, pattern, includeHidden, maxResults, basePath = "") {
8389
8714
  if (!includeHidden && entry.name.startsWith(".")) {
8390
8715
  continue;
8391
8716
  }
8392
- const relativePath = basePath ? path8.join(basePath, entry.name) : entry.name;
8393
- const fullPath = path8.join(dir, entry.name);
8717
+ const relativePath = basePath ? path9.join(basePath, entry.name) : entry.name;
8718
+ const fullPath = path9.join(dir, entry.name);
8394
8719
  if (matchGlob(relativePath, pattern)) {
8395
8720
  matches.push(relativePath);
8396
8721
  }
@@ -8406,7 +8731,7 @@ async function walkDir(dir, pattern, includeHidden, maxResults, basePath = "") {
8406
8731
  async function listFiles(params) {
8407
8732
  const { pattern, cwd: relativeCwd, includeHidden = false, maxResults = 1e3 } = params;
8408
8733
  const baseCwd = process.cwd();
8409
- const targetCwd = relativeCwd ? path8.resolve(baseCwd, path8.normalize(relativeCwd)) : baseCwd;
8734
+ const targetCwd = relativeCwd ? path9.resolve(baseCwd, path9.normalize(relativeCwd)) : baseCwd;
8410
8735
  if (!targetCwd.startsWith(baseCwd)) {
8411
8736
  throw new Error(`Access denied: Cannot list files outside of current working directory`);
8412
8737
  }
@@ -8417,7 +8742,7 @@ async function listFiles(params) {
8417
8742
  const filesInfo = [];
8418
8743
  for (const match of matches) {
8419
8744
  try {
8420
- const fullPath = path8.join(targetCwd, match);
8745
+ const fullPath = path9.join(targetCwd, match);
8421
8746
  const stats = statSync5(fullPath);
8422
8747
  filesInfo.push({
8423
8748
  path: match,
@@ -8500,7 +8825,7 @@ var globFilesTool = {
8500
8825
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/grepSearch/index.js
8501
8826
  import { readdir as readdir2 } from "fs/promises";
8502
8827
  import { readFileSync as readFileSync3, statSync as statSync6 } from "fs";
8503
- import path9 from "path";
8828
+ import path10 from "path";
8504
8829
  var MAX_FILE_SIZE3 = 10 * 1024 * 1024;
8505
8830
  function matchGlob2(filePath, pattern) {
8506
8831
  const regexPattern = pattern.replace(/\./g, "\\.").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/\{\{GLOBSTAR\}\}/g, ".*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (_, options) => `(${options.split(",").join("|")})`).replace(/\[([^\]]+)\]/g, "[$1]");
@@ -8518,8 +8843,8 @@ async function walkDir2(dir, pattern, maxResults, basePath = "") {
8518
8843
  if (entry.name.startsWith(".")) {
8519
8844
  continue;
8520
8845
  }
8521
- const relativePath = basePath ? path9.join(basePath, entry.name) : entry.name;
8522
- const fullPath = path9.join(dir, entry.name);
8846
+ const relativePath = basePath ? path10.join(basePath, entry.name) : entry.name;
8847
+ const fullPath = path10.join(dir, entry.name);
8523
8848
  if (matchGlob2(relativePath, pattern)) {
8524
8849
  matches.push(relativePath);
8525
8850
  }
@@ -8535,7 +8860,7 @@ async function walkDir2(dir, pattern, maxResults, basePath = "") {
8535
8860
  async function searchFiles2(params) {
8536
8861
  const { pattern, filePattern = "**/*", cwd: relativeCwd, caseSensitive = false, maxResults = 100, contextLines = 0 } = params;
8537
8862
  const baseCwd = process.cwd();
8538
- const targetCwd = relativeCwd ? path9.resolve(baseCwd, path9.normalize(relativeCwd)) : baseCwd;
8863
+ const targetCwd = relativeCwd ? path10.resolve(baseCwd, path10.normalize(relativeCwd)) : baseCwd;
8539
8864
  if (!targetCwd.startsWith(baseCwd)) {
8540
8865
  throw new Error(`Access denied: Cannot search files outside of current working directory`);
8541
8866
  }
@@ -8549,7 +8874,7 @@ async function searchFiles2(params) {
8549
8874
  const filesToSearch = await walkDir2(targetCwd, filePattern, 1e4);
8550
8875
  const filteredFiles = [];
8551
8876
  for (const match of filesToSearch) {
8552
- const fullPath = path9.join(targetCwd, match);
8877
+ const fullPath = path10.join(targetCwd, match);
8553
8878
  try {
8554
8879
  const stats = statSync6(fullPath);
8555
8880
  if (stats.isDirectory() || stats.size > MAX_FILE_SIZE3) {
@@ -8573,7 +8898,7 @@ async function searchFiles2(params) {
8573
8898
  break;
8574
8899
  }
8575
8900
  filesSearched++;
8576
- const fullPath = path9.join(targetCwd, file);
8901
+ const fullPath = path10.join(targetCwd, file);
8577
8902
  try {
8578
8903
  const content = readFileSync3(fullPath, "utf-8");
8579
8904
  const lines = content.split("\n");
@@ -8708,14 +9033,14 @@ var grepSearchTool = {
8708
9033
  };
8709
9034
 
8710
9035
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/deleteFile/index.js
8711
- import { promises as fs9 } from "fs";
9036
+ import { promises as fs10 } from "fs";
8712
9037
  import { existsSync as existsSync6, statSync as statSync7 } from "fs";
8713
- import path10 from "path";
9038
+ import path11 from "path";
8714
9039
  async function deleteFile(params) {
8715
9040
  const { path: filePath, recursive = false } = params;
8716
- const normalizedPath = path10.normalize(filePath);
8717
- const resolvedPath = path10.resolve(process.cwd(), normalizedPath);
8718
- const cwd = path10.resolve(process.cwd());
9041
+ const normalizedPath = path11.normalize(filePath);
9042
+ const resolvedPath = path11.resolve(process.cwd(), normalizedPath);
9043
+ const cwd = path11.resolve(process.cwd());
8719
9044
  if (!resolvedPath.startsWith(cwd)) {
8720
9045
  throw new Error(`Access denied: Cannot delete files outside of current working directory`);
8721
9046
  }
@@ -8729,10 +9054,10 @@ async function deleteFile(params) {
8729
9054
  throw new Error(`Path is a directory: ${filePath}. Use recursive=true to delete directories and their contents.`);
8730
9055
  }
8731
9056
  if (isDirectory) {
8732
- await fs9.rm(resolvedPath, { recursive: true, force: true });
9057
+ await fs10.rm(resolvedPath, { recursive: true, force: true });
8733
9058
  return `Directory deleted successfully: ${filePath}`;
8734
9059
  } else {
8735
- await fs9.unlink(resolvedPath);
9060
+ await fs10.unlink(resolvedPath);
8736
9061
  return `File deleted successfully: ${filePath}
8737
9062
  Size: ${size} bytes`;
8738
9063
  }
@@ -8742,7 +9067,7 @@ var deleteFileTool = {
8742
9067
  implementation: (context) => ({
8743
9068
  toolFn: async (value) => {
8744
9069
  const params = value;
8745
- const resolvedPath = path10.resolve(process.cwd(), path10.normalize(params.path));
9070
+ const resolvedPath = path11.resolve(process.cwd(), path11.normalize(params.path));
8746
9071
  const isDirectory = existsSync6(resolvedPath) && statSync7(resolvedPath).isDirectory();
8747
9072
  context.logger.info(`\u{1F5D1}\uFE0F DeleteFile: Deleting ${isDirectory ? "directory" : "file"}`, {
8748
9073
  path: params.path,
@@ -8780,7 +9105,7 @@ var deleteFileTool = {
8780
9105
 
8781
9106
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/bashExecute/index.js
8782
9107
  import { spawn } from "child_process";
8783
- import path11 from "path";
9108
+ import path12 from "path";
8784
9109
  var DEFAULT_TIMEOUT_MS = 6e4;
8785
9110
  var MAX_OUTPUT_SIZE = 100 * 1024;
8786
9111
  var DANGEROUS_PATTERNS = [
@@ -8964,7 +9289,7 @@ async function executeBashCommand(params) {
8964
9289
  };
8965
9290
  }
8966
9291
  const baseCwd = process.cwd();
8967
- const targetCwd = relativeCwd ? path11.resolve(baseCwd, relativeCwd) : baseCwd;
9292
+ const targetCwd = relativeCwd ? path12.resolve(baseCwd, relativeCwd) : baseCwd;
8968
9293
  const effectiveTimeout = Math.min(timeout, 5 * 60 * 1e3);
8969
9294
  return new Promise((resolve3) => {
8970
9295
  let stdout = "";
@@ -9298,73 +9623,52 @@ var DISABLE_SERVER_THROTTLING = process.env.DISABLE_SERVER_THROTTLING === "true"
9298
9623
  var questSaveMutex = new Mutex();
9299
9624
 
9300
9625
  // ../../b4m-core/packages/services/dist/src/llm/ChatCompletion.js
9301
- var QuestStartBodySchema = z138.object({
9302
- userId: z138.string(),
9303
- sessionId: z138.string(),
9304
- questId: z138.string(),
9305
- message: z138.string(),
9306
- messageFileIds: z138.array(z138.string()),
9307
- historyCount: z138.number(),
9308
- fabFileIds: z138.array(z138.string()),
9626
+ var QuestStartBodySchema = z139.object({
9627
+ userId: z139.string(),
9628
+ sessionId: z139.string(),
9629
+ questId: z139.string(),
9630
+ message: z139.string(),
9631
+ messageFileIds: z139.array(z139.string()),
9632
+ historyCount: z139.number(),
9633
+ fabFileIds: z139.array(z139.string()),
9309
9634
  params: ChatCompletionCreateInputSchema,
9310
9635
  dashboardParams: DashboardParamsSchema.optional(),
9311
- enableQuestMaster: z138.boolean().optional(),
9312
- enableMementos: z138.boolean().optional(),
9313
- enableArtifacts: z138.boolean().optional(),
9314
- enableAgents: z138.boolean().optional(),
9636
+ enableQuestMaster: z139.boolean().optional(),
9637
+ enableMementos: z139.boolean().optional(),
9638
+ enableArtifacts: z139.boolean().optional(),
9639
+ enableAgents: z139.boolean().optional(),
9315
9640
  promptMeta: PromptMetaZodSchema,
9316
- tools: z138.array(z138.union([b4mLLMTools, z138.string()])).optional(),
9317
- mcpServers: z138.array(z138.string()).optional(),
9318
- projectId: z138.string().optional(),
9319
- organizationId: z138.string().nullable().optional(),
9641
+ tools: z139.array(z139.union([b4mLLMTools, z139.string()])).optional(),
9642
+ mcpServers: z139.array(z139.string()).optional(),
9643
+ projectId: z139.string().optional(),
9644
+ organizationId: z139.string().nullable().optional(),
9320
9645
  questMaster: QuestMasterParamsSchema.optional(),
9321
- toolPromptId: z138.string().optional(),
9646
+ toolPromptId: z139.string().optional(),
9322
9647
  researchMode: ResearchModeParamsSchema.optional(),
9323
- fallbackModel: z138.string().optional(),
9324
- embeddingModel: z138.string().optional(),
9325
- queryComplexity: z138.string(),
9648
+ fallbackModel: z139.string().optional(),
9649
+ embeddingModel: z139.string().optional(),
9650
+ queryComplexity: z139.string(),
9326
9651
  imageConfig: GenerateImageToolCallSchema.optional(),
9327
- deepResearchConfig: z138.object({
9328
- maxDepth: z138.number().optional(),
9329
- duration: z138.number().optional(),
9652
+ deepResearchConfig: z139.object({
9653
+ maxDepth: z139.number().optional(),
9654
+ duration: z139.number().optional(),
9330
9655
  // Note: searchers are passed via ToolContext and not through this API schema
9331
- searchers: z138.array(z138.any()).optional()
9656
+ searchers: z139.array(z139.any()).optional()
9332
9657
  }).optional(),
9333
- extraContextMessages: z138.array(z138.object({
9334
- role: z138.enum(["user", "assistant", "system", "function", "tool"]),
9335
- content: z138.union([z138.string(), z138.array(z138.any())]),
9336
- fabFileIds: z138.array(z138.string()).optional()
9658
+ extraContextMessages: z139.array(z139.object({
9659
+ role: z139.enum(["user", "assistant", "system", "function", "tool"]),
9660
+ content: z139.union([z139.string(), z139.array(z139.any())]),
9661
+ fabFileIds: z139.array(z139.string()).optional()
9337
9662
  })).optional()
9338
9663
  });
9339
9664
 
9340
9665
  // ../../b4m-core/packages/services/dist/src/llm/ImageGeneration.js
9341
9666
  import axios8 from "axios";
9342
9667
  import { fileTypeFromBuffer as fileTypeFromBuffer4 } from "file-type";
9343
- import { v4 as uuidv47 } from "uuid";
9344
- import { z as z139 } from "zod";
9345
- import { fromZodError as fromZodError2 } from "zod-validation-error";
9346
- var ImageGenerationBodySchema = OpenAIImageGenerationInput.extend({
9347
- sessionId: z139.string(),
9348
- questId: z139.string(),
9349
- userId: z139.string(),
9350
- prompt: z139.string(),
9351
- safety_tolerance: z139.number().min(BFL_SAFETY_TOLERANCE.MIN).max(BFL_SAFETY_TOLERANCE.MAX).optional().default(BFL_SAFETY_TOLERANCE.DEFAULT),
9352
- prompt_upsampling: z139.boolean().optional().default(false),
9353
- seed: z139.number().nullable().optional(),
9354
- output_format: z139.enum(["jpeg", "png"]).nullable().optional().default("png"),
9355
- width: z139.number().optional(),
9356
- height: z139.number().optional(),
9357
- aspect_ratio: z139.string().optional(),
9358
- fabFileIds: z139.array(z139.string()).optional()
9359
- });
9360
-
9361
- // ../../b4m-core/packages/services/dist/src/llm/ImageEdit.js
9362
- import axios9 from "axios";
9363
- import { fileTypeFromBuffer as fileTypeFromBuffer5 } from "file-type";
9364
9668
  import { v4 as uuidv48 } from "uuid";
9365
9669
  import { z as z140 } from "zod";
9366
- import { fromZodError as fromZodError3 } from "zod-validation-error";
9367
- var ImageEditBodySchema = OpenAIImageGenerationInput.extend({
9670
+ import { fromZodError as fromZodError2 } from "zod-validation-error";
9671
+ var ImageGenerationBodySchema = OpenAIImageGenerationInput.extend({
9368
9672
  sessionId: z140.string(),
9369
9673
  questId: z140.string(),
9370
9674
  userId: z140.string(),
@@ -9372,35 +9676,56 @@ var ImageEditBodySchema = OpenAIImageGenerationInput.extend({
9372
9676
  safety_tolerance: z140.number().min(BFL_SAFETY_TOLERANCE.MIN).max(BFL_SAFETY_TOLERANCE.MAX).optional().default(BFL_SAFETY_TOLERANCE.DEFAULT),
9373
9677
  prompt_upsampling: z140.boolean().optional().default(false),
9374
9678
  seed: z140.number().nullable().optional(),
9375
- output_format: z140.enum(["jpeg", "png"]).optional().default("png"),
9679
+ output_format: z140.enum(["jpeg", "png"]).nullable().optional().default("png"),
9376
9680
  width: z140.number().optional(),
9377
9681
  height: z140.number().optional(),
9378
9682
  aspect_ratio: z140.string().optional(),
9379
- size: z140.string().optional(),
9380
- fabFileIds: z140.array(z140.string()).optional(),
9381
- image: z140.string()
9683
+ fabFileIds: z140.array(z140.string()).optional()
9382
9684
  });
9383
9685
 
9384
- // ../../b4m-core/packages/services/dist/src/llm/refineText.js
9686
+ // ../../b4m-core/packages/services/dist/src/llm/ImageEdit.js
9687
+ import axios9 from "axios";
9688
+ import { fileTypeFromBuffer as fileTypeFromBuffer5 } from "file-type";
9689
+ import { v4 as uuidv49 } from "uuid";
9385
9690
  import { z as z141 } from "zod";
9386
- var refineTextLLMSchema = z141.object({
9387
- text: z141.string(),
9388
- context: z141.string().optional()
9691
+ import { fromZodError as fromZodError3 } from "zod-validation-error";
9692
+ var ImageEditBodySchema = OpenAIImageGenerationInput.extend({
9693
+ sessionId: z141.string(),
9694
+ questId: z141.string(),
9695
+ userId: z141.string(),
9696
+ prompt: z141.string(),
9697
+ safety_tolerance: z141.number().min(BFL_SAFETY_TOLERANCE.MIN).max(BFL_SAFETY_TOLERANCE.MAX).optional().default(BFL_SAFETY_TOLERANCE.DEFAULT),
9698
+ prompt_upsampling: z141.boolean().optional().default(false),
9699
+ seed: z141.number().nullable().optional(),
9700
+ output_format: z141.enum(["jpeg", "png"]).optional().default("png"),
9701
+ width: z141.number().optional(),
9702
+ height: z141.number().optional(),
9703
+ aspect_ratio: z141.string().optional(),
9704
+ size: z141.string().optional(),
9705
+ fabFileIds: z141.array(z141.string()).optional(),
9706
+ image: z141.string()
9707
+ });
9708
+
9709
+ // ../../b4m-core/packages/services/dist/src/llm/refineText.js
9710
+ import { z as z142 } from "zod";
9711
+ var refineTextLLMSchema = z142.object({
9712
+ text: z142.string(),
9713
+ context: z142.string().optional()
9389
9714
  // tone: z.enum(['formal', 'informal', 'neutral']).optional(),
9390
9715
  // style: z.enum(['technical', 'creative', 'academic', 'business', 'narrative']).optional(),
9391
9716
  });
9392
9717
 
9393
9718
  // ../../b4m-core/packages/services/dist/src/llm/MementoEvaluationService.js
9394
- import { z as z142 } from "zod";
9395
- var SingleMementoEvalSchema = z142.object({
9396
- importance: z142.number().min(1).max(10),
9719
+ import { z as z143 } from "zod";
9720
+ var SingleMementoEvalSchema = z143.object({
9721
+ importance: z143.number().min(1).max(10),
9397
9722
  // 1-10 scale for personal info importance
9398
- summary: z142.string(),
9399
- tags: z142.array(z142.string()).optional()
9723
+ summary: z143.string(),
9724
+ tags: z143.array(z143.string()).optional()
9400
9725
  });
9401
- var MementoEvalResponseSchema = z142.object({
9402
- isPersonal: z142.boolean(),
9403
- mementos: z142.array(SingleMementoEvalSchema).optional()
9726
+ var MementoEvalResponseSchema = z143.object({
9727
+ isPersonal: z143.boolean(),
9728
+ mementos: z143.array(SingleMementoEvalSchema).optional()
9404
9729
  // Array of distinct personal information
9405
9730
  });
9406
9731
 
@@ -9457,7 +9782,7 @@ async function generateFileDeletePreview(args) {
9457
9782
  if (!existsSync7(args.path)) {
9458
9783
  return `[File does not exist: ${args.path}]`;
9459
9784
  }
9460
- const stats = await import("fs/promises").then((fs12) => fs12.stat(args.path));
9785
+ const stats = await import("fs/promises").then((fs13) => fs13.stat(args.path));
9461
9786
  return `[File will be deleted]
9462
9787
 
9463
9788
  Path: ${args.path}
@@ -9469,9 +9794,9 @@ Last modified: ${stats.mtime.toLocaleString()}`;
9469
9794
  }
9470
9795
 
9471
9796
  // src/utils/Logger.ts
9472
- import fs10 from "fs/promises";
9473
- import path12 from "path";
9474
- import os from "os";
9797
+ import fs11 from "fs/promises";
9798
+ import path13 from "path";
9799
+ import os2 from "os";
9475
9800
  var Logger2 = class _Logger {
9476
9801
  constructor() {
9477
9802
  this.logFilePath = null;
@@ -9493,9 +9818,9 @@ var Logger2 = class _Logger {
9493
9818
  */
9494
9819
  async initialize(sessionId) {
9495
9820
  this.sessionId = sessionId;
9496
- const debugDir = path12.join(os.homedir(), ".bike4mind", "debug");
9497
- await fs10.mkdir(debugDir, { recursive: true });
9498
- this.logFilePath = path12.join(debugDir, `${sessionId}.txt`);
9821
+ const debugDir = path13.join(os2.homedir(), ".bike4mind", "debug");
9822
+ await fs11.mkdir(debugDir, { recursive: true });
9823
+ this.logFilePath = path13.join(debugDir, `${sessionId}.txt`);
9499
9824
  await this.writeToFile("INFO", "=== CLI SESSION START ===");
9500
9825
  }
9501
9826
  /**
@@ -9559,7 +9884,7 @@ var Logger2 = class _Logger {
9559
9884
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").substring(0, 19);
9560
9885
  const logEntry = `[${timestamp}] [${level}] ${message}
9561
9886
  `;
9562
- await fs10.appendFile(this.logFilePath, logEntry, "utf-8");
9887
+ await fs11.appendFile(this.logFilePath, logEntry, "utf-8");
9563
9888
  } catch (error) {
9564
9889
  console.error("File logging failed:", error);
9565
9890
  }
@@ -9705,15 +10030,15 @@ var Logger2 = class _Logger {
9705
10030
  async cleanupOldLogs() {
9706
10031
  if (!this.fileLoggingEnabled) return;
9707
10032
  try {
9708
- const debugDir = path12.join(os.homedir(), ".bike4mind", "debug");
9709
- const files = await fs10.readdir(debugDir);
10033
+ const debugDir = path13.join(os2.homedir(), ".bike4mind", "debug");
10034
+ const files = await fs11.readdir(debugDir);
9710
10035
  const now = Date.now();
9711
10036
  const thirtyDaysAgo = now - 30 * 24 * 60 * 60 * 1e3;
9712
10037
  for (const file of files) {
9713
- const filePath = path12.join(debugDir, file);
9714
- const stats = await fs10.stat(filePath);
10038
+ const filePath = path13.join(debugDir, file);
10039
+ const stats = await fs11.stat(filePath);
9715
10040
  if (stats.mtime.getTime() < thirtyDaysAgo) {
9716
- await fs10.unlink(filePath);
10041
+ await fs11.unlink(filePath);
9717
10042
  }
9718
10043
  }
9719
10044
  } catch (error) {
@@ -9807,21 +10132,21 @@ var NoOpStorage = class extends BaseStorage {
9807
10132
  async upload(input, destination, options) {
9808
10133
  return `/tmp/${destination}`;
9809
10134
  }
9810
- async download(path15) {
10135
+ async download(path16) {
9811
10136
  throw new Error("Download not supported in CLI");
9812
10137
  }
9813
- async delete(path15) {
10138
+ async delete(path16) {
9814
10139
  }
9815
- async getSignedUrl(path15) {
9816
- return `/tmp/${path15}`;
10140
+ async getSignedUrl(path16) {
10141
+ return `/tmp/${path16}`;
9817
10142
  }
9818
- getPublicUrl(path15) {
9819
- return `/tmp/${path15}`;
10143
+ getPublicUrl(path16) {
10144
+ return `/tmp/${path16}`;
9820
10145
  }
9821
- async getPreview(path15) {
9822
- return `/tmp/${path15}`;
10146
+ async getPreview(path16) {
10147
+ return `/tmp/${path16}`;
9823
10148
  }
9824
- async getMetadata(path15) {
10149
+ async getMetadata(path16) {
9825
10150
  return { size: 0, contentType: "application/octet-stream" };
9826
10151
  }
9827
10152
  };
@@ -10031,8 +10356,8 @@ function generateCliTools(userId, llm, model, permissionManager, showPermissionP
10031
10356
  }
10032
10357
 
10033
10358
  // src/config/toolSafety.ts
10034
- import { z as z143 } from "zod";
10035
- var ToolCategorySchema = z143.enum([
10359
+ import { z as z144 } from "zod";
10360
+ var ToolCategorySchema = z144.enum([
10036
10361
  "auto_approve",
10037
10362
  // Safe tools that run automatically without permission
10038
10363
  "prompt_always",
@@ -10040,9 +10365,9 @@ var ToolCategorySchema = z143.enum([
10040
10365
  "prompt_default"
10041
10366
  // Tools that prompt by default but can be trusted
10042
10367
  ]);
10043
- var ToolSafetyConfigSchema = z143.object({
10044
- categories: z143.record(z143.string(), ToolCategorySchema),
10045
- trustedTools: z143.array(z143.string())
10368
+ var ToolSafetyConfigSchema = z144.object({
10369
+ categories: z144.record(z144.string(), ToolCategorySchema),
10370
+ trustedTools: z144.array(z144.string())
10046
10371
  });
10047
10372
  var DEFAULT_TOOL_CATEGORIES = {
10048
10373
  // ===== AUTO APPROVE (Safe tools) =====
@@ -10222,8 +10547,8 @@ function getEnvironmentName(configApiConfig) {
10222
10547
  }
10223
10548
 
10224
10549
  // src/utils/contextLoader.ts
10225
- import * as fs11 from "fs";
10226
- import * as path13 from "path";
10550
+ import * as fs12 from "fs";
10551
+ import * as path14 from "path";
10227
10552
  import { homedir as homedir4 } from "os";
10228
10553
  var CONTEXT_FILE_SIZE_LIMIT = 100 * 1024;
10229
10554
  var PROJECT_CONTEXT_FILES = [
@@ -10244,9 +10569,9 @@ function formatFileSize2(bytes) {
10244
10569
  return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
10245
10570
  }
10246
10571
  function tryReadContextFile(dir, filename, source) {
10247
- const filePath = path13.join(dir, filename);
10572
+ const filePath = path14.join(dir, filename);
10248
10573
  try {
10249
- const stats = fs11.lstatSync(filePath);
10574
+ const stats = fs12.lstatSync(filePath);
10250
10575
  if (stats.isDirectory()) {
10251
10576
  return null;
10252
10577
  }
@@ -10260,7 +10585,7 @@ function tryReadContextFile(dir, filename, source) {
10260
10585
  error: `${source === "global" ? "Global" : "Project"} ${filename} exceeds 100KB limit (${formatFileSize2(stats.size)})`
10261
10586
  };
10262
10587
  }
10263
- const content = fs11.readFileSync(filePath, "utf-8");
10588
+ const content = fs12.readFileSync(filePath, "utf-8");
10264
10589
  return {
10265
10590
  filename,
10266
10591
  content,
@@ -10312,7 +10637,7 @@ ${project.content}`;
10312
10637
  }
10313
10638
  async function loadContextFiles(projectDir) {
10314
10639
  const errors = [];
10315
- const globalDir = path13.join(homedir4(), ".bike4mind");
10640
+ const globalDir = path14.join(homedir4(), ".bike4mind");
10316
10641
  const projectDirectory = projectDir || process.cwd();
10317
10642
  const [globalResult, projectResult] = await Promise.all([
10318
10643
  Promise.resolve(findContextFile(globalDir, GLOBAL_CONTEXT_FILES, "global")),
@@ -10333,10 +10658,22 @@ async function loadContextFiles(projectDir) {
10333
10658
  };
10334
10659
  }
10335
10660
 
10661
+ // src/utils/argumentSubstitution.ts
10662
+ function substituteArguments(template, args) {
10663
+ let result = template;
10664
+ for (let i = args.length; i >= 1; i--) {
10665
+ const pattern = new RegExp(`\\$${i}`, "g");
10666
+ result = result.replace(pattern, args[i - 1] || "");
10667
+ }
10668
+ const allArgsString = args.join(" ");
10669
+ result = result.replace(/\$ARGUMENTS/g, allArgsString);
10670
+ return result;
10671
+ }
10672
+
10336
10673
  // ../../b4m-core/packages/mcp/dist/src/client.js
10337
10674
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
10338
10675
  import { Client as Client2 } from "@modelcontextprotocol/sdk/client/index.js";
10339
- import path14 from "path";
10676
+ import path15 from "path";
10340
10677
  import { existsSync as existsSync8, readdirSync as readdirSync3 } from "fs";
10341
10678
  var MCPClient = class {
10342
10679
  // Note: This class handles MCP server communication with repository filtering
@@ -10377,16 +10714,16 @@ var MCPClient = class {
10377
10714
  const root = process.env.INIT_CWD || process.cwd();
10378
10715
  const candidatePaths = [
10379
10716
  // When running from SST Lambda with node_modules structure (copyFiles)
10380
- path14.join(root, `node_modules/@bike4mind/mcp/dist/src/${this.serverName}/index.js`),
10717
+ path15.join(root, `node_modules/@bike4mind/mcp/dist/src/${this.serverName}/index.js`),
10381
10718
  // When running from SST Lambda deployed environment (/var/task)
10382
- path14.join(root, `b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10719
+ path15.join(root, `b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10383
10720
  // When running from SST Lambda (.sst/artifacts/mcpHandler-dev), navigate to monorepo root (3 levels up)
10384
- path14.join(root, `../../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10721
+ path15.join(root, `../../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10385
10722
  // When running from packages/client (Next.js app), navigate to monorepo root (2 levels up)
10386
- path14.join(root, `../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10723
+ path15.join(root, `../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10387
10724
  // Original paths (backward compatibility)
10388
- path14.join(root, `/b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10389
- path14.join(root, "core", "mcp", "servers", this.serverName, "dist", "index.js")
10725
+ path15.join(root, `/b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10726
+ path15.join(root, "core", "mcp", "servers", this.serverName, "dist", "index.js")
10390
10727
  ];
10391
10728
  const serverScriptPath = candidatePaths.find((p) => existsSync8(p));
10392
10729
  if (!serverScriptPath) {
@@ -11190,7 +11527,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
11190
11527
  // package.json
11191
11528
  var package_default = {
11192
11529
  name: "@bike4mind/cli",
11193
- version: "0.2.10-feat-explore-subagent-implementation.17263+b92e2f586",
11530
+ version: "0.2.10-feat-cli-message-unique-ids.17271+dbdd57e69",
11194
11531
  type: "module",
11195
11532
  description: "Interactive CLI tool for Bike4Mind with ReAct agents",
11196
11533
  license: "UNLICENSED",
@@ -11260,6 +11597,7 @@ var package_default = {
11260
11597
  "eventsource-parser": "^3.0.6",
11261
11598
  "file-type": "^18.7.0",
11262
11599
  "fuse.js": "^7.1.0",
11600
+ "gray-matter": "^4.0.3",
11263
11601
  ink: "^6.5.1",
11264
11602
  "ink-select-input": "^6.2.0",
11265
11603
  "ink-spinner": "^5.0.0",
@@ -11293,10 +11631,10 @@ var package_default = {
11293
11631
  },
11294
11632
  devDependencies: {
11295
11633
  "@bike4mind/agents": "0.1.0",
11296
- "@bike4mind/common": "2.39.1-feat-explore-subagent-implementation.17263+b92e2f586",
11297
- "@bike4mind/mcp": "1.20.4-feat-explore-subagent-implementation.17263+b92e2f586",
11298
- "@bike4mind/services": "2.34.2-feat-explore-subagent-implementation.17263+b92e2f586",
11299
- "@bike4mind/utils": "2.1.4-feat-explore-subagent-implementation.17263+b92e2f586",
11634
+ "@bike4mind/common": "2.39.1-feat-cli-message-unique-ids.17271+dbdd57e69",
11635
+ "@bike4mind/mcp": "1.20.4-feat-cli-message-unique-ids.17271+dbdd57e69",
11636
+ "@bike4mind/services": "2.34.2-feat-cli-message-unique-ids.17271+dbdd57e69",
11637
+ "@bike4mind/utils": "2.1.4-feat-cli-message-unique-ids.17271+dbdd57e69",
11300
11638
  "@types/better-sqlite3": "^7.6.13",
11301
11639
  "@types/diff": "^5.0.9",
11302
11640
  "@types/jsonwebtoken": "^9.0.4",
@@ -11309,7 +11647,7 @@ var package_default = {
11309
11647
  typescript: "^5.9.3",
11310
11648
  vitest: "^3.2.4"
11311
11649
  },
11312
- gitHead: "b92e2f586a6e216a1e40919bea0c36aa3c0db84f"
11650
+ gitHead: "dbdd57e69e453a6c69e32529dfd7defede8ae278"
11313
11651
  };
11314
11652
 
11315
11653
  // src/config/constants.ts
@@ -11543,8 +11881,8 @@ Provide a structured plan that the main agent can execute.`,
11543
11881
  };
11544
11882
  var REVIEW_CONFIG = {
11545
11883
  type: "review",
11546
- model: "claude-3-5-sonnet-20241022",
11547
- // Use Sonnet for better reasoning
11884
+ model: "claude-sonnet-4-5-20250929",
11885
+ // Use latest Sonnet for better reasoning
11548
11886
  systemPrompt: `You are a code review specialist. Your job is to analyze code quality and identify issues.
11549
11887
 
11550
11888
  Focus on:
@@ -11661,6 +11999,7 @@ function CliApp() {
11661
11999
  sessionStore: new SessionStore(),
11662
12000
  configStore: new ConfigStore(),
11663
12001
  commandHistoryStore: new CommandHistoryStore(),
12002
+ customCommandStore: new CustomCommandStore(),
11664
12003
  imageStore: null,
11665
12004
  // Lazy-loaded on first use
11666
12005
  imageRenderer,
@@ -11740,6 +12079,15 @@ function CliApp() {
11740
12079
  const config = await state.configStore.load();
11741
12080
  const history = await state.commandHistoryStore.load();
11742
12081
  setCommandHistory(history);
12082
+ try {
12083
+ await state.customCommandStore.loadCommands();
12084
+ const customCommandCount = state.customCommandStore.getCommandCount();
12085
+ if (customCommandCount > 0) {
12086
+ console.log(`\u{1F4DD} Loaded ${customCommandCount} custom command${customCommandCount !== 1 ? "s" : ""}`);
12087
+ }
12088
+ } catch (error) {
12089
+ console.warn("Failed to load custom commands:", error instanceof Error ? error.message : String(error));
12090
+ }
11743
12091
  const authTokens = await state.configStore.getAuthTokens();
11744
12092
  let isAuthenticated = false;
11745
12093
  if (!authTokens) {
@@ -11762,7 +12110,7 @@ function CliApp() {
11762
12110
  if (!isAuthenticated) {
11763
12111
  console.log("\u2139\uFE0F AI features disabled. Available commands: /login, /help, /config\n");
11764
12112
  const minimalSession = {
11765
- id: uuidv49(),
12113
+ id: uuidv410(),
11766
12114
  name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
11767
12115
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
11768
12116
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -11806,7 +12154,7 @@ function CliApp() {
11806
12154
  }
11807
12155
  llm.currentModel = modelInfo.id;
11808
12156
  const newSession = {
11809
- id: uuidv49(),
12157
+ id: uuidv410(),
11810
12158
  name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
11811
12159
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
11812
12160
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -12009,8 +12357,169 @@ Remember: Use context from previous messages to understand follow-up questions.$
12009
12357
  useEffect3(() => {
12010
12358
  init();
12011
12359
  }, [init]);
12360
+ const handleCustomCommandMessage = async (fullTemplate, displayMessage) => {
12361
+ if (!state.agent || !state.session) {
12362
+ console.error("\u274C Agent or session not initialized");
12363
+ return;
12364
+ }
12365
+ const authTokens = await state.configStore.getAuthTokens();
12366
+ if (!authTokens || new Date(authTokens.expiresAt) <= /* @__PURE__ */ new Date()) {
12367
+ console.log("\n\u274C Authentication required to use AI features.");
12368
+ console.log("\u{1F4A1} Run /login to authenticate with your B4M account.\n");
12369
+ return;
12370
+ }
12371
+ useCliStore.getState().setIsThinking(true);
12372
+ const currentSteps = [];
12373
+ const stepHandler = (step) => {
12374
+ currentSteps.push(step);
12375
+ const currentSession = useCliStore.getState().session;
12376
+ if (currentSession) {
12377
+ const messages = [...currentSession.messages];
12378
+ const lastMessage = messages[messages.length - 1];
12379
+ if (lastMessage && lastMessage.role === "assistant") {
12380
+ messages[messages.length - 1] = {
12381
+ ...lastMessage,
12382
+ metadata: {
12383
+ ...lastMessage.metadata,
12384
+ steps: [...currentSteps]
12385
+ }
12386
+ };
12387
+ setStoreSession({
12388
+ ...currentSession,
12389
+ messages
12390
+ });
12391
+ }
12392
+ }
12393
+ };
12394
+ state.agent.on("action", stepHandler);
12395
+ try {
12396
+ let messageContent = fullTemplate;
12397
+ const userMessageContent = displayMessage;
12398
+ if (state.messageBuilder && state.messageBuilder.hasImages(fullTemplate)) {
12399
+ const { message: multimodalMessage } = await state.messageBuilder.buildMessage(fullTemplate);
12400
+ messageContent = multimodalMessage.content;
12401
+ }
12402
+ const userMessage = {
12403
+ id: uuidv410(),
12404
+ role: "user",
12405
+ content: userMessageContent,
12406
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
12407
+ };
12408
+ const pendingAssistantMessage = {
12409
+ id: uuidv410(),
12410
+ role: "assistant",
12411
+ content: "...",
12412
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
12413
+ metadata: {
12414
+ steps: []
12415
+ }
12416
+ };
12417
+ const sessionWithMessages = {
12418
+ ...state.session,
12419
+ messages: [...state.session.messages, userMessage, pendingAssistantMessage],
12420
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
12421
+ };
12422
+ setState((prev) => ({ ...prev, session: sessionWithMessages }));
12423
+ setStoreSession(sessionWithMessages);
12424
+ const recentMessages = state.session.messages.slice(-20);
12425
+ const previousMessages = recentMessages.filter((msg) => msg.role === "user" || msg.role === "assistant").map((msg) => ({
12426
+ role: msg.role,
12427
+ content: msg.content
12428
+ }));
12429
+ const result = await state.agent.run(messageContent, {
12430
+ previousMessages: previousMessages.length > 0 ? previousMessages : void 0
12431
+ });
12432
+ const permissionDenied = result.finalAnswer.startsWith("Permission denied for tool");
12433
+ if (permissionDenied) {
12434
+ console.log("\n\u26A0\uFE0F Action denied by user\n");
12435
+ }
12436
+ const successfulToolCalls = result.steps.filter((s) => s.type === "observation").length;
12437
+ const currentSession = useCliStore.getState().session;
12438
+ if (!currentSession) return;
12439
+ const updatedMessages = [...currentSession.messages];
12440
+ const lastMessage = updatedMessages[updatedMessages.length - 1];
12441
+ updatedMessages[updatedMessages.length - 1] = {
12442
+ id: lastMessage.id,
12443
+ // Preserve the original message ID
12444
+ role: "assistant",
12445
+ content: result.finalAnswer,
12446
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
12447
+ metadata: {
12448
+ steps: result.steps,
12449
+ tokenUsage: {
12450
+ prompt: 0,
12451
+ completion: 0,
12452
+ total: result.completionInfo.totalTokens
12453
+ },
12454
+ model: state.session.model,
12455
+ permissionDenied
12456
+ }
12457
+ };
12458
+ const finalSession = {
12459
+ ...currentSession,
12460
+ messages: updatedMessages,
12461
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
12462
+ metadata: {
12463
+ ...currentSession.metadata,
12464
+ totalTokens: currentSession.metadata.totalTokens + result.completionInfo.totalTokens,
12465
+ toolCallCount: currentSession.metadata.toolCallCount + successfulToolCalls
12466
+ }
12467
+ };
12468
+ setState((prev) => ({ ...prev, session: finalSession }));
12469
+ setStoreSession(finalSession);
12470
+ await state.sessionStore.save(finalSession);
12471
+ usageCache = null;
12472
+ useCliStore.getState().setIsThinking(false);
12473
+ } catch (error) {
12474
+ useCliStore.getState().setIsThinking(false);
12475
+ if (error?.message?.includes("Permission denied")) {
12476
+ console.log("\n\u26A0\uFE0F Action blocked by permission settings");
12477
+ const currentSession2 = useCliStore.getState().session;
12478
+ if (!currentSession2) return;
12479
+ const sessionWithDenied = { ...currentSession2 };
12480
+ const messages2 = [...sessionWithDenied.messages];
12481
+ const lastMessage2 = messages2[messages2.length - 1];
12482
+ if (lastMessage2 && lastMessage2.role === "assistant") {
12483
+ messages2[messages2.length - 1] = {
12484
+ ...lastMessage2,
12485
+ content: error.message,
12486
+ metadata: {
12487
+ ...lastMessage2.metadata,
12488
+ permissionDenied: true
12489
+ }
12490
+ };
12491
+ }
12492
+ sessionWithDenied.messages = messages2;
12493
+ setState((prev) => ({ ...prev, session: sessionWithDenied }));
12494
+ setStoreSession(sessionWithDenied);
12495
+ await state.sessionStore.save(sessionWithDenied);
12496
+ return;
12497
+ }
12498
+ console.error("Error executing command:", error);
12499
+ console.error(error.stack);
12500
+ const currentSession = useCliStore.getState().session;
12501
+ if (!currentSession) return;
12502
+ const sessionWithError = { ...currentSession };
12503
+ const messages = [...sessionWithError.messages];
12504
+ const lastMessage = messages[messages.length - 1];
12505
+ if (lastMessage && lastMessage.role === "assistant") {
12506
+ messages[messages.length - 1] = {
12507
+ ...lastMessage,
12508
+ content: `\u274C Error: ${error.message || "Unknown error occurred"}`
12509
+ };
12510
+ }
12511
+ sessionWithError.messages = messages;
12512
+ setState((prev) => ({ ...prev, session: sessionWithError }));
12513
+ setStoreSession(sessionWithError);
12514
+ } finally {
12515
+ state.agent.off("action", stepHandler);
12516
+ }
12517
+ };
12012
12518
  const handleMessage = async (message) => {
12013
- if (!state.agent || !state.session) return;
12519
+ if (!state.agent || !state.session) {
12520
+ console.error("\u274C Agent or session not initialized");
12521
+ return;
12522
+ }
12014
12523
  await state.commandHistoryStore.add(message);
12015
12524
  const updatedHistory = await state.commandHistoryStore.list();
12016
12525
  setCommandHistory(updatedHistory);
@@ -12020,6 +12529,7 @@ Remember: Use context from previous messages to understand follow-up questions.$
12020
12529
  console.log("\u{1F4A1} Run /login to authenticate with your B4M account.\n");
12021
12530
  return;
12022
12531
  }
12532
+ useCliStore.getState().setIsThinking(true);
12023
12533
  const currentSteps = [];
12024
12534
  const stepHandler = (step) => {
12025
12535
  currentSteps.push(step);
@@ -12045,11 +12555,13 @@ Remember: Use context from previous messages to understand follow-up questions.$
12045
12555
  userMessageContent = message;
12046
12556
  }
12047
12557
  const userMessage = {
12558
+ id: uuidv410(),
12048
12559
  role: "user",
12049
12560
  content: userMessageContent,
12050
12561
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
12051
12562
  };
12052
12563
  const pendingAssistantMessage = {
12564
+ id: uuidv410(),
12053
12565
  role: "assistant",
12054
12566
  content: "...",
12055
12567
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -12079,6 +12591,8 @@ Remember: Use context from previous messages to understand follow-up questions.$
12079
12591
  }
12080
12592
  const successfulToolCalls = result.steps.filter((s) => s.type === "observation").length;
12081
12593
  const finalAssistantMessage = {
12594
+ id: pendingAssistantMessage.id,
12595
+ // Preserve the original message ID
12082
12596
  role: "assistant",
12083
12597
  content: result.finalAnswer,
12084
12598
  timestamp: pendingAssistantMessage.timestamp,
@@ -12140,11 +12654,13 @@ Remember: Use context from previous messages to understand follow-up questions.$
12140
12654
  isError = true;
12141
12655
  }
12142
12656
  const userMessage = {
12657
+ id: uuidv410(),
12143
12658
  role: "user",
12144
12659
  content: `$ ${command}`,
12145
12660
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
12146
12661
  };
12147
12662
  const assistantMessage = {
12663
+ id: uuidv410(),
12148
12664
  role: "assistant",
12149
12665
  content: isError ? `\u274C Error:
12150
12666
  ${output}` : output.trim() || "(no output)",
@@ -12215,8 +12731,48 @@ ${output}` : output.trim() || "(no output)",
12215
12731
  };
12216
12732
  };
12217
12733
  const handleCommand = async (command, args) => {
12734
+ const customCommand = state.customCommandStore.getCommand(command);
12735
+ if (customCommand) {
12736
+ try {
12737
+ const sourceIcon = customCommand.source === "global" ? "\u{1F3E0}" : "\u{1F4C1}";
12738
+ console.log(`${sourceIcon} Executing custom command: /${command}`);
12739
+ let substitutedBody = substituteArguments(customCommand.body, args);
12740
+ const processed = await processFileReferences(substitutedBody);
12741
+ substitutedBody = processed.content;
12742
+ if (processed.errors.length > 0) {
12743
+ processed.errors.forEach((error) => console.warn(`Warning: ${error}`));
12744
+ }
12745
+ if (process.env.B4M_VERBOSE === "1") {
12746
+ console.log("\u{1F4DD} Expanded command:\n", substitutedBody);
12747
+ }
12748
+ const displayMessage = `/${command}${args.length > 0 ? " " + args.join(" ") : ""}`;
12749
+ if (customCommand.model && state.agent) {
12750
+ console.log(`\u{1F504} Using model override: ${customCommand.model}`);
12751
+ const originalModel = state.session?.model;
12752
+ if (state.session) {
12753
+ state.session.model = customCommand.model;
12754
+ }
12755
+ await handleCustomCommandMessage(substitutedBody, displayMessage);
12756
+ if (state.session && originalModel) {
12757
+ state.session.model = originalModel;
12758
+ }
12759
+ } else {
12760
+ console.log("\u{1F916} Sending to agent...\n");
12761
+ await handleCustomCommandMessage(substitutedBody, displayMessage);
12762
+ }
12763
+ return;
12764
+ } catch (error) {
12765
+ console.error(
12766
+ `\u274C Failed to execute custom command /${command}:`,
12767
+ error instanceof Error ? error.message : String(error)
12768
+ );
12769
+ return;
12770
+ }
12771
+ }
12218
12772
  switch (command) {
12219
- case "help":
12773
+ case "help": {
12774
+ const customCommands = state.customCommandStore.getAllCommands();
12775
+ const hasCustomCommands = customCommands.length > 0;
12220
12776
  console.log(`
12221
12777
  Available commands:
12222
12778
  /help - Show this help message
@@ -12243,8 +12799,19 @@ Tool Permissions:
12243
12799
 
12244
12800
  Project Configuration:
12245
12801
  /project-config - Show merged project configuration
12802
+
12803
+ Custom Commands:
12804
+ /commands - List all custom commands
12805
+ /commands:new <name> - Create a new custom command
12806
+ /commands:reload - Reload custom commands from disk${hasCustomCommands ? "\n\n\u{1F4DD} Custom Commands Available:" : ""}${hasCustomCommands ? customCommands.map((cmd) => {
12807
+ const source = cmd.source === "global" ? "\u{1F3E0}" : "\u{1F4C1}";
12808
+ const argHint = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
12809
+ return `
12810
+ ${source} /${cmd.name}${argHint} - ${cmd.description}`;
12811
+ }).join("") : ""}
12246
12812
  `);
12247
12813
  break;
12814
+ }
12248
12815
  case "exit":
12249
12816
  case "quit":
12250
12817
  logger.debug("[EXIT /exit command - cleaning up and exiting...");
@@ -12504,7 +13071,7 @@ Project Configuration:
12504
13071
  console.clear();
12505
13072
  const model = state.session?.model || state.config?.defaultModel || "claude-sonnet";
12506
13073
  const newSession = {
12507
- id: uuidv49(),
13074
+ id: uuidv410(),
12508
13075
  name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
12509
13076
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
12510
13077
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -12732,6 +13299,71 @@ No usage data available for the last ${USAGE_DAYS} days.`);
12732
13299
  console.log("");
12733
13300
  break;
12734
13301
  }
13302
+ case "commands": {
13303
+ const customCommands = state.customCommandStore.getAllCommands();
13304
+ const globalCommands = state.customCommandStore.getCommandsBySource("global");
13305
+ const projectCommands = state.customCommandStore.getCommandsBySource("project");
13306
+ console.log("\n\u{1F4DD} Custom Commands:\n");
13307
+ if (customCommands.length === 0) {
13308
+ console.log("No custom commands found.");
13309
+ console.log("\nTo create a custom command:");
13310
+ console.log(" /commands:new <name> - Create a new command");
13311
+ console.log("\nCustom commands can be stored in:");
13312
+ console.log(" \u{1F3E0} Global: ~/.bike4mind/commands/ (available in all projects)");
13313
+ console.log(" \u{1F4C1} Project: .bike4mind/commands/ (team-shared, committed to git)");
13314
+ } else {
13315
+ if (globalCommands.length > 0) {
13316
+ console.log("\u{1F3E0} Global Commands (~/.bike4mind/commands/):");
13317
+ globalCommands.forEach((cmd) => {
13318
+ const argHint = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
13319
+ console.log(` /${cmd.name}${argHint} - ${cmd.description}`);
13320
+ });
13321
+ console.log("");
13322
+ }
13323
+ if (projectCommands.length > 0) {
13324
+ console.log("\u{1F4C1} Project Commands (.bike4mind/commands/):");
13325
+ projectCommands.forEach((cmd) => {
13326
+ const argHint = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
13327
+ console.log(` /${cmd.name}${argHint} - ${cmd.description}`);
13328
+ });
13329
+ console.log("");
13330
+ }
13331
+ console.log(`Total: ${customCommands.length} custom command${customCommands.length !== 1 ? "s" : ""}`);
13332
+ }
13333
+ console.log("");
13334
+ break;
13335
+ }
13336
+ case "commands:new": {
13337
+ const commandName = args[0];
13338
+ if (!commandName) {
13339
+ console.log("\u274C Please provide a command name");
13340
+ console.log("Usage: /commands:new <name>");
13341
+ break;
13342
+ }
13343
+ console.log("\nWhere should this command be stored?");
13344
+ console.log(" 1. \u{1F3E0} Global (~/.bike4mind/commands/) - available in all projects");
13345
+ console.log(" 2. \u{1F4C1} Project (.bike4mind/commands/) - team-shared");
13346
+ console.log("\nDefaulting to global. Creating command file...");
13347
+ try {
13348
+ const filePath = await state.customCommandStore.createCommandFile(commandName, true);
13349
+ console.log(`\u2705 Created command file: ${filePath}`);
13350
+ console.log("\nEdit this file to customize your command.");
13351
+ console.log("Then run: /commands:reload to load it");
13352
+ } catch (error) {
13353
+ console.error("\u274C Failed to create command file:", error instanceof Error ? error.message : String(error));
13354
+ }
13355
+ break;
13356
+ }
13357
+ case "commands:reload": {
13358
+ try {
13359
+ await state.customCommandStore.reloadCommands();
13360
+ const count = state.customCommandStore.getCommandCount();
13361
+ console.log(`\u2705 Reloaded ${count} custom command${count !== 1 ? "s" : ""}`);
13362
+ } catch (error) {
13363
+ console.error("\u274C Failed to reload commands:", error instanceof Error ? error.message : String(error));
13364
+ }
13365
+ break;
13366
+ }
12735
13367
  default:
12736
13368
  console.log(`Unknown command: /${command}`);
12737
13369
  console.log("Type /help for available commands");
@@ -12849,6 +13481,7 @@ No usage data available for the last ${USAGE_DAYS} days.`);
12849
13481
  if (!isInitialized) {
12850
13482
  return /* @__PURE__ */ React17.createElement(Box16, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React17.createElement(Text16, null, "\u{1F680} Initializing..."));
12851
13483
  }
13484
+ const allCommands = mergeCommands(state.customCommandStore.getAllCommands());
12852
13485
  return /* @__PURE__ */ React17.createElement(
12853
13486
  App,
12854
13487
  {
@@ -12857,6 +13490,7 @@ No usage data available for the last ${USAGE_DAYS} days.`);
12857
13490
  onBashCommand: handleBashCommand,
12858
13491
  onImageDetected: handleImageDetected,
12859
13492
  commandHistory,
13493
+ commands: allCommands,
12860
13494
  config: state.config,
12861
13495
  availableModels: state.availableModels,
12862
13496
  onSaveConfig: handleSaveConfig,