@bike4mind/cli 0.2.10-feat-custom-slash-commands.17246 → 0.2.10-feat-explore-subagent-implementation.17245

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 +1425 -1632
  2. package/package.json +6 -7
package/dist/index.js CHANGED
@@ -210,8 +210,7 @@ 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
- 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));
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));
215
214
  }));
216
215
  }
217
216
 
@@ -312,7 +311,7 @@ function searchFiles(query) {
312
311
  searchPool = files;
313
312
  }
314
313
  }
315
- const fuse = new Fuse(searchPool, {
314
+ const fuse2 = new Fuse(searchPool, {
316
315
  keys: [{ name: "path", weight: 1 }],
317
316
  threshold: 0.4,
318
317
  // Allow some fuzzy matching
@@ -321,7 +320,7 @@ function searchFiles(query) {
321
320
  // Use extended search for better path matching
322
321
  useExtendedSearch: false
323
322
  });
324
- const results = fuse.search(query);
323
+ const results = fuse2.search(query);
325
324
  return results.slice(0, 20).map((result) => result.item);
326
325
  }
327
326
  function isPathWithinCwd(filePath) {
@@ -496,61 +495,11 @@ var COMMANDS = [
496
495
  name: "rewind",
497
496
  description: "Rewind conversation to a previous point",
498
497
  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"
516
498
  }
517
499
  ];
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
- }
551
500
 
552
501
  // src/utils/fuzzySearch.ts
553
- var fuseOptions = {
502
+ var fuse = new Fuse2(COMMANDS, {
554
503
  keys: [
555
504
  { name: "name", weight: 0.7 },
556
505
  // Prioritize command name
@@ -561,12 +510,11 @@ var fuseOptions = {
561
510
  // 0 = perfect match, 1 = match anything
562
511
  includeScore: true,
563
512
  minMatchCharLength: 1
564
- };
565
- function searchCommands(query, commands = COMMANDS) {
513
+ });
514
+ function searchCommands(query) {
566
515
  if (!query || query.trim() === "") {
567
- return commands;
516
+ return COMMANDS;
568
517
  }
569
- const fuse = new Fuse2(commands, fuseOptions);
570
518
  const results = fuse.search(query);
571
519
  return results.map((result) => result.item);
572
520
  }
@@ -789,7 +737,6 @@ function InputPrompt({
789
737
  onImageDetected,
790
738
  disabled = false,
791
739
  history = [],
792
- commands = [],
793
740
  prefillInput,
794
741
  onPrefillConsumed,
795
742
  onBashModeChange
@@ -815,8 +762,8 @@ function InputPrompt({
815
762
  const commandQuery = shouldShowCommandAutocomplete ? value.slice(1) : "";
816
763
  const filteredCommands = useMemo(() => {
817
764
  if (!shouldShowCommandAutocomplete) return [];
818
- return searchCommands(commandQuery, commands);
819
- }, [shouldShowCommandAutocomplete, commandQuery, commands]);
765
+ return searchCommands(commandQuery);
766
+ }, [shouldShowCommandAutocomplete, commandQuery]);
820
767
  const filteredFiles = useMemo(() => {
821
768
  if (!fileAutocomplete?.active) return [];
822
769
  return searchFiles(fileAutocomplete.query);
@@ -1467,7 +1414,6 @@ function App({
1467
1414
  onPermissionResponse,
1468
1415
  onImageDetected,
1469
1416
  commandHistory = [],
1470
- commands = [],
1471
1417
  config,
1472
1418
  availableModels = [],
1473
1419
  onSaveConfig,
@@ -1540,7 +1486,6 @@ ${errorBlock}`;
1540
1486
  onImageDetected,
1541
1487
  disabled: isThinking,
1542
1488
  history: commandHistory,
1543
- commands,
1544
1489
  prefillInput,
1545
1490
  onPrefillConsumed,
1546
1491
  onBashModeChange: setIsBashMode
@@ -2763,261 +2708,6 @@ var CommandHistoryStore = class {
2763
2708
  }
2764
2709
  };
2765
2710
 
2766
- // src/storage/CustomCommandStore.ts
2767
- import fs6 from "fs/promises";
2768
- import path6 from "path";
2769
- import os from "os";
2770
-
2771
- // src/utils/commandParser.ts
2772
- import matter from "gray-matter";
2773
- import { z as z2 } from "zod";
2774
- var FrontmatterSchema = z2.object({
2775
- description: z2.string().optional(),
2776
- "argument-hint": z2.string().optional(),
2777
- model: z2.string().optional(),
2778
- // Future fields (ignored for now):
2779
- "allowed-tools": z2.any().optional(),
2780
- context: z2.any().optional(),
2781
- agent: z2.any().optional(),
2782
- "disable-model-invocation": z2.any().optional(),
2783
- hooks: z2.any().optional()
2784
- });
2785
- function extractDescriptionFromBody(body) {
2786
- const lines = body.trim().split("\n");
2787
- for (const line of lines) {
2788
- const trimmed = line.trim();
2789
- if (trimmed && !trimmed.startsWith("#")) {
2790
- return trimmed.length > 100 ? trimmed.substring(0, 97) + "..." : trimmed;
2791
- }
2792
- }
2793
- return "Custom command";
2794
- }
2795
- function parseCommandFile(fileContent, filePath, commandName, source) {
2796
- try {
2797
- const { data: frontmatter, content: body } = matter(fileContent);
2798
- const validationResult = FrontmatterSchema.safeParse(frontmatter);
2799
- if (!validationResult.success) {
2800
- console.warn(
2801
- `Warning: Invalid frontmatter in ${filePath}:`,
2802
- validationResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join(", ")
2803
- );
2804
- }
2805
- const validFrontmatter = validationResult.success ? validationResult.data : {};
2806
- const description = validFrontmatter.description || extractDescriptionFromBody(body) || "Custom command";
2807
- return {
2808
- name: commandName,
2809
- description,
2810
- argumentHint: validFrontmatter["argument-hint"],
2811
- model: validFrontmatter.model,
2812
- body: body.trim(),
2813
- source,
2814
- filePath
2815
- };
2816
- } catch (error) {
2817
- throw new Error(
2818
- `Failed to parse command file ${filePath}: ${error instanceof Error ? error.message : String(error)}`
2819
- );
2820
- }
2821
- }
2822
- function isValidCommandName(name) {
2823
- if (!name || name.trim().length === 0) {
2824
- return false;
2825
- }
2826
- const validPattern = /^[a-z0-9-_:]+$/i;
2827
- return validPattern.test(name);
2828
- }
2829
- function extractCommandName(filename) {
2830
- if (!filename.endsWith(".md")) {
2831
- return null;
2832
- }
2833
- const name = filename.slice(0, -3);
2834
- if (!isValidCommandName(name)) {
2835
- return null;
2836
- }
2837
- return name;
2838
- }
2839
-
2840
- // src/storage/CustomCommandStore.ts
2841
- var CustomCommandStore = class {
2842
- constructor(projectRoot) {
2843
- this.commands = /* @__PURE__ */ new Map();
2844
- this.globalCommandsDir = path6.join(os.homedir(), ".bike4mind", "commands");
2845
- this.projectCommandsDir = path6.join(projectRoot || process.cwd(), ".bike4mind", "commands");
2846
- }
2847
- /**
2848
- * Loads all custom commands from both global and project directories
2849
- * Project commands override global commands with the same name
2850
- */
2851
- async loadCommands() {
2852
- this.commands.clear();
2853
- await this.loadCommandsFromDirectory(this.globalCommandsDir, "global");
2854
- await this.loadCommandsFromDirectory(this.projectCommandsDir, "project");
2855
- }
2856
- /**
2857
- * Recursively scans a directory for .md files and loads them as commands
2858
- *
2859
- * @param directory - Directory to scan
2860
- * @param source - Source identifier ('global' or 'project')
2861
- */
2862
- async loadCommandsFromDirectory(directory, source) {
2863
- try {
2864
- const stats = await fs6.stat(directory);
2865
- if (!stats.isDirectory()) {
2866
- return;
2867
- }
2868
- const commandFiles = await this.findCommandFiles(directory);
2869
- for (const filePath of commandFiles) {
2870
- try {
2871
- await this.loadCommandFile(filePath, source);
2872
- } catch (error) {
2873
- console.warn(
2874
- `Failed to load command from ${filePath}:`,
2875
- error instanceof Error ? error.message : String(error)
2876
- );
2877
- }
2878
- }
2879
- } catch (error) {
2880
- if (error.code !== "ENOENT") {
2881
- console.warn(
2882
- `Error accessing ${source} commands directory ${directory}:`,
2883
- error instanceof Error ? error.message : String(error)
2884
- );
2885
- }
2886
- }
2887
- }
2888
- /**
2889
- * Recursively finds all .md files in a directory
2890
- *
2891
- * @param directory - Directory to search
2892
- * @returns Array of full file paths to .md files
2893
- */
2894
- async findCommandFiles(directory) {
2895
- const files = [];
2896
- try {
2897
- const entries = await fs6.readdir(directory, { withFileTypes: true });
2898
- for (const entry of entries) {
2899
- const fullPath = path6.join(directory, entry.name);
2900
- if (entry.isDirectory()) {
2901
- const subFiles = await this.findCommandFiles(fullPath);
2902
- files.push(...subFiles);
2903
- } else if (entry.isFile() && entry.name.endsWith(".md")) {
2904
- files.push(fullPath);
2905
- }
2906
- }
2907
- } catch (error) {
2908
- console.warn(`Error reading directory ${directory}:`, error instanceof Error ? error.message : String(error));
2909
- }
2910
- return files;
2911
- }
2912
- /**
2913
- * Loads a single command file
2914
- *
2915
- * @param filePath - Full path to the command file
2916
- * @param source - Source identifier ('global' or 'project')
2917
- */
2918
- async loadCommandFile(filePath, source) {
2919
- const filename = path6.basename(filePath);
2920
- const commandName = extractCommandName(filename);
2921
- if (!commandName) {
2922
- console.warn(`Invalid command filename: ${filename} (must end with .md and have valid name)`);
2923
- return;
2924
- }
2925
- const fileContent = await fs6.readFile(filePath, "utf-8");
2926
- const command = parseCommandFile(fileContent, filePath, commandName, source);
2927
- const existing = this.commands.get(commandName);
2928
- if (existing && existing.source === "project" && source === "global") {
2929
- return;
2930
- }
2931
- this.commands.set(commandName, command);
2932
- }
2933
- /**
2934
- * Gets a command by name
2935
- *
2936
- * @param name - Command name
2937
- * @returns CustomCommand if found, undefined otherwise
2938
- */
2939
- getCommand(name) {
2940
- return this.commands.get(name);
2941
- }
2942
- /**
2943
- * Gets all loaded commands
2944
- *
2945
- * @returns Array of all custom commands
2946
- */
2947
- getAllCommands() {
2948
- return Array.from(this.commands.values());
2949
- }
2950
- /**
2951
- * Gets commands filtered by source
2952
- *
2953
- * @param source - Filter by 'global' or 'project'
2954
- * @returns Array of commands from the specified source
2955
- */
2956
- getCommandsBySource(source) {
2957
- return this.getAllCommands().filter((cmd) => cmd.source === source);
2958
- }
2959
- /**
2960
- * Checks if a command name exists
2961
- *
2962
- * @param name - Command name to check
2963
- * @returns true if command exists
2964
- */
2965
- hasCommand(name) {
2966
- return this.commands.has(name);
2967
- }
2968
- /**
2969
- * Gets the number of loaded commands
2970
- *
2971
- * @returns Number of custom commands
2972
- */
2973
- getCommandCount() {
2974
- return this.commands.size;
2975
- }
2976
- /**
2977
- * Reloads all commands from directories
2978
- * Useful for the /commands:reload command
2979
- */
2980
- async reloadCommands() {
2981
- await this.loadCommands();
2982
- }
2983
- /**
2984
- * Creates a new command file from a template
2985
- *
2986
- * @param name - Command name
2987
- * @param isGlobal - If true, creates in global directory, otherwise project directory
2988
- * @returns Path to the created file
2989
- */
2990
- async createCommandFile(name, isGlobal = false) {
2991
- const targetDir = isGlobal ? this.globalCommandsDir : this.projectCommandsDir;
2992
- const filePath = path6.join(targetDir, `${name}.md`);
2993
- try {
2994
- await fs6.access(filePath);
2995
- throw new Error(`Command file already exists: ${filePath}`);
2996
- } catch (error) {
2997
- if (error.code !== "ENOENT") {
2998
- throw error;
2999
- }
3000
- }
3001
- await fs6.mkdir(targetDir, { recursive: true });
3002
- const template = `---
3003
- description: ${name} command
3004
- argument-hint: [args]
3005
- ---
3006
-
3007
- # ${name}
3008
-
3009
- Replace this with your command template.
3010
-
3011
- You can use:
3012
- - $ARGUMENTS for all arguments
3013
- - $1, $2, etc. for positional arguments
3014
- - @filename for file references
3015
- `;
3016
- await fs6.writeFile(filePath, template, "utf-8");
3017
- return filePath;
3018
- }
3019
- };
3020
-
3021
2711
  // ../../b4m-core/packages/agents/src/ReActAgent.ts
3022
2712
  import { EventEmitter } from "events";
3023
2713
  var ReActAgent = class extends EventEmitter {
@@ -3331,38 +3021,38 @@ Remember: You are an autonomous AGENT. Act independently and solve problems proa
3331
3021
  // ../../b4m-core/packages/services/dist/src/referService/generateCodes.js
3332
3022
  import { randomBytes } from "crypto";
3333
3023
  import range from "lodash/range.js";
3334
- import { z as z3 } from "zod";
3335
- var generateReferralCodesSchema = z3.object({
3336
- count: z3.number().optional(),
3337
- unlimitedUse: z3.boolean().optional(),
3338
- expiresAt: z3.date().optional()
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()
3339
3029
  });
3340
3030
 
3341
3031
  // ../../b4m-core/packages/services/dist/src/referService/delete.js
3342
- import { z as z4 } from "zod";
3343
- var deleteInviteCodesSchema = z4.object({
3344
- ids: z4.array(z4.string())
3032
+ import { z as z3 } from "zod";
3033
+ var deleteInviteCodesSchema = z3.object({
3034
+ ids: z3.array(z3.string())
3345
3035
  });
3346
3036
 
3347
3037
  // ../../b4m-core/packages/services/dist/src/userService/login.js
3348
- import { z as z5 } from "zod";
3038
+ import { z as z4 } from "zod";
3349
3039
  import bcrypt from "bcryptjs";
3350
- var loginUserSchema = z5.object({
3351
- usernameOrEmail: z5.string(),
3352
- password: z5.string(),
3353
- metadata: z5.object({
3354
- loginTime: z5.date(),
3355
- userAgent: z5.string(),
3356
- browser: z5.string(),
3357
- operatingSystem: z5.string(),
3358
- deviceType: z5.string(),
3359
- screenResolution: z5.string(),
3360
- viewportSize: z5.string(),
3361
- colorDepth: z5.number(),
3362
- pixelDepth: z5.number(),
3363
- devicePixelRatio: z5.number(),
3364
- ip: z5.string().optional().default(""),
3365
- location: z5.string().optional()
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()
3366
3056
  }).optional()
3367
3057
  });
3368
3058
 
@@ -3372,78 +3062,78 @@ import escapeRegExp from "lodash/escapeRegExp.js";
3372
3062
 
3373
3063
  // ../../b4m-core/packages/services/dist/src/userService/forgotPassword.js
3374
3064
  import { randomUUID } from "crypto";
3375
- import { z as z6 } from "zod";
3376
- var forgotPasswordUserSchema = z6.object({
3377
- email: z6.string().email()
3065
+ import { z as z5 } from "zod";
3066
+ var forgotPasswordUserSchema = z5.object({
3067
+ email: z5.string().email()
3378
3068
  });
3379
3069
 
3380
3070
  // ../../b4m-core/packages/services/dist/src/userService/update.js
3381
3071
  import bcrypt3 from "bcryptjs";
3382
- import { z as z7 } from "zod";
3383
- var updateUserSchema = z7.object({
3384
- name: z7.string().optional(),
3385
- username: z7.string().optional(),
3072
+ import { z as z6 } from "zod";
3073
+ var updateUserSchema = z6.object({
3074
+ name: z6.string().optional(),
3075
+ username: z6.string().optional(),
3386
3076
  // email field removed - users must use the secure email change verification flow
3387
3077
  // See requestEmailChange and verifyEmailChange in userService
3388
- password: z7.string().nullable().optional(),
3389
- team: z7.string().nullable().optional(),
3390
- role: z7.string().nullable().optional(),
3391
- phone: z7.string().nullable().optional(),
3392
- preferredLanguage: z7.string().nullable().optional(),
3393
- preferredContact: z7.string().nullable().optional(),
3394
- preferredVoice: z7.string().nullable().optional(),
3395
- tshirtSize: z7.string().nullable().optional(),
3396
- geoLocation: z7.string().nullable().optional(),
3397
- lastNotebookId: z7.string().nullable().optional(),
3398
- tags: z7.array(z7.string()).nullable().optional(),
3399
- lastCreditsPurchasedAt: z7.date().nullable().optional(),
3400
- systemFiles: z7.array(z7.object({
3401
- fileId: z7.string(),
3402
- enabled: z7.boolean()
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
3093
  })).nullable().optional(),
3404
- securityQuestions: z7.array(z7.object({ question: z7.string(), answer: z7.string() })).nullable().optional(),
3405
- photoUrl: z7.string().nullable().optional(),
3406
- showCreditsUsed: z7.boolean().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()
3407
3097
  });
3408
3098
 
3409
3099
  // ../../b4m-core/packages/services/dist/src/userService/adminUpdate.js
3410
- import { z as z9 } from "zod";
3100
+ import { z as z8 } from "zod";
3411
3101
 
3412
3102
  // ../../b4m-core/packages/services/dist/src/friendshipService/sendFriendRequest.js
3413
- import { z as z8 } from "zod";
3414
- var sendFriendRequestSchema = z8.object({
3415
- requesterId: z8.string(),
3416
- recipientId: z8.string(),
3417
- message: z8.string().optional()
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()
3418
3108
  });
3419
3109
 
3420
3110
  // ../../b4m-core/packages/services/dist/src/userService/adminUpdate.js
3421
3111
  var adminUpdateUserSchema = updateUserSchema.extend({
3422
- id: z9.string(),
3112
+ id: z8.string(),
3423
3113
  // Admins can directly update email addresses without verification
3424
- email: z9.string().email().optional(),
3425
- role: z9.string().optional().nullable(),
3426
- isAdmin: z9.boolean().optional(),
3427
- organizationId: z9.string().optional().nullable(),
3428
- storageLimit: z9.number().optional(),
3429
- currentCredits: z9.number().optional(),
3430
- isBanned: z9.boolean().optional(),
3431
- isModerated: z9.boolean().optional(),
3432
- subscribedUntil: z9.string().optional().nullable(),
3433
- systemFiles: z9.array(z9.object({ fileId: z9.string(), enabled: z9.boolean() })).optional(),
3434
- level: z9.enum(["DemoUser", "PaidUser", "VIPUser", "ManagerUser", "AdminUser"]).optional(),
3435
- lastNotebookId: z9.string().optional().nullable(),
3436
- userNotes: z9.array(z9.object({ timestamp: z9.string(), note: z9.string(), userName: z9.string() })).optional(),
3437
- numReferralsAvailable: z9.number().optional()
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()
3438
3128
  });
3439
3129
 
3440
3130
  // ../../b4m-core/packages/services/dist/src/userService/register.js
3441
- import { z as z11 } from "zod";
3131
+ import { z as z10 } from "zod";
3442
3132
  import bcrypt4 from "bcryptjs";
3443
3133
 
3444
3134
  // ../../b4m-core/packages/services/dist/src/creditService/addCredits.js
3445
- import { z as z10 } from "zod";
3446
- var AddCreditsSchema = z10.discriminatedUnion("type", [
3135
+ import { z as z9 } from "zod";
3136
+ var AddCreditsSchema = z9.discriminatedUnion("type", [
3447
3137
  PurchaseTransaction.omit({ createdAt: true, updatedAt: true }),
3448
3138
  SubscriptionCreditTransaction.omit({ createdAt: true, updatedAt: true }),
3449
3139
  GenericCreditAddTransaction.omit({ createdAt: true, updatedAt: true }),
@@ -3451,57 +3141,57 @@ var AddCreditsSchema = z10.discriminatedUnion("type", [
3451
3141
  ]);
3452
3142
 
3453
3143
  // ../../b4m-core/packages/services/dist/src/userService/register.js
3454
- var registerUserSchema = z11.object({
3455
- username: z11.string(),
3456
- email: z11.string(),
3457
- name: z11.string(),
3458
- inviteCode: z11.string(),
3459
- password: z11.string(),
3460
- metadata: z11.object({
3461
- loginTime: z11.date(),
3462
- userAgent: z11.string(),
3463
- browser: z11.string(),
3464
- operatingSystem: z11.string(),
3465
- deviceType: z11.string(),
3466
- screenResolution: z11.string(),
3467
- viewportSize: z11.string(),
3468
- colorDepth: z11.number(),
3469
- pixelDepth: z11.number(),
3470
- devicePixelRatio: z11.number(),
3471
- ip: z11.string().optional().default(""),
3472
- location: z11.string().optional()
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()
3473
3163
  }).optional()
3474
3164
  });
3475
3165
 
3476
3166
  // ../../b4m-core/packages/services/dist/src/userService/adminDelete.js
3477
- import { z as z12 } from "zod";
3478
- var adminDeleteUserSchema = z12.object({
3479
- id: z12.string()
3167
+ import { z as z11 } from "zod";
3168
+ var adminDeleteUserSchema = z11.object({
3169
+ id: z11.string()
3480
3170
  });
3481
3171
 
3482
3172
  // ../../b4m-core/packages/services/dist/src/userService/searchUserCollection.js
3483
- import { z as z13 } from "zod";
3484
- var searchUserCollectionSchema = z13.object({
3485
- userId: z13.string(),
3486
- page: z13.coerce.number().optional().default(1),
3487
- limit: z13.coerce.number().optional().default(10),
3488
- search: z13.string().optional().default(""),
3489
- type: z13.nativeEnum(CollectionType).optional()
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()
3490
3180
  });
3491
3181
 
3492
3182
  // ../../b4m-core/packages/services/dist/src/userService/recalculateUserStorage.js
3493
- import { z as z14 } from "zod";
3494
- var recalculateUserStorageSchema = z14.object({
3183
+ import { z as z13 } from "zod";
3184
+ var recalculateUserStorageSchema = z13.object({
3495
3185
  /**
3496
3186
  * The user to recalculate the storage for
3497
3187
  */
3498
- userId: z14.string()
3188
+ userId: z13.string()
3499
3189
  });
3500
3190
 
3501
3191
  // ../../b4m-core/packages/services/dist/src/userService/listRecentActivities.js
3502
- import { z as z15 } from "zod";
3503
- var listRecentActivitiesSchema = z15.object({
3504
- coverage: z15.enum(["all", "important"]).default("important")
3192
+ import { z as z14 } from "zod";
3193
+ var listRecentActivitiesSchema = z14.object({
3194
+ coverage: z14.enum(["all", "important"]).default("important")
3505
3195
  });
3506
3196
  var IMPORTANT_COUNTER_NAMES = [
3507
3197
  SessionEvents.CREATE_SESSION,
@@ -3515,82 +3205,82 @@ var IMPORTANT_COUNTER_NAMES = [
3515
3205
 
3516
3206
  // ../../b4m-core/packages/services/dist/src/userService/sendEmailVerification.js
3517
3207
  import { randomUUID as randomUUID2 } from "crypto";
3518
- import { z as z16 } from "zod";
3519
- var sendEmailVerificationSchema = z16.object({
3520
- userId: z16.string()
3208
+ import { z as z15 } from "zod";
3209
+ var sendEmailVerificationSchema = z15.object({
3210
+ userId: z15.string()
3521
3211
  });
3522
3212
 
3523
3213
  // ../../b4m-core/packages/services/dist/src/userService/verifyEmailToken.js
3524
- import { z as z17 } from "zod";
3214
+ import { z as z16 } from "zod";
3525
3215
 
3526
3216
  // ../../b4m-core/packages/services/dist/src/utils/crypto.js
3527
3217
  import crypto from "crypto";
3528
3218
 
3529
3219
  // ../../b4m-core/packages/services/dist/src/userService/verifyEmailToken.js
3530
- var verifyEmailTokenSchema = z17.object({
3531
- token: z17.string()
3220
+ var verifyEmailTokenSchema = z16.object({
3221
+ token: z16.string()
3532
3222
  });
3533
3223
 
3534
3224
  // ../../b4m-core/packages/services/dist/src/userService/resendEmailVerification.js
3535
3225
  import { randomUUID as randomUUID3 } from "crypto";
3536
- import { z as z18 } from "zod";
3537
- var resendEmailVerificationSchema = z18.object({
3538
- userId: z18.string()
3226
+ import { z as z17 } from "zod";
3227
+ var resendEmailVerificationSchema = z17.object({
3228
+ userId: z17.string()
3539
3229
  });
3540
3230
 
3541
3231
  // ../../b4m-core/packages/services/dist/src/userService/requestEmailChange.js
3542
3232
  import { randomUUID as randomUUID4 } from "crypto";
3543
- import { z as z19 } from "zod";
3544
- var requestEmailChangeSchema = z19.object({
3545
- userId: z19.string(),
3546
- newEmail: z19.string().email(),
3547
- password: z19.string()
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()
3548
3238
  });
3549
3239
 
3550
3240
  // ../../b4m-core/packages/services/dist/src/userService/verifyEmailChange.js
3551
- import { z as z20 } from "zod";
3552
- var verifyEmailChangeSchema = z20.object({
3553
- token: z20.string()
3241
+ import { z as z19 } from "zod";
3242
+ var verifyEmailChangeSchema = z19.object({
3243
+ token: z19.string()
3554
3244
  });
3555
3245
 
3556
3246
  // ../../b4m-core/packages/services/dist/src/userService/cancelEmailChange.js
3557
- import { z as z21 } from "zod";
3558
- var cancelEmailChangeSchema = z21.object({
3559
- userId: z21.string()
3247
+ import { z as z20 } from "zod";
3248
+ var cancelEmailChangeSchema = z20.object({
3249
+ userId: z20.string()
3560
3250
  });
3561
3251
 
3562
3252
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/create.js
3563
3253
  import { randomBytes as randomBytes2 } from "crypto";
3564
3254
  import bcrypt5 from "bcryptjs";
3565
- import { z as z22 } from "zod";
3566
- var createUserApiKeySchema = z22.object({
3567
- name: z22.string().min(1).max(100),
3568
- scopes: z22.array(z22.nativeEnum(ApiKeyScope)).min(1),
3569
- expiresAt: z22.date().optional(),
3570
- rateLimit: z22.object({
3571
- requestsPerMinute: z22.number().min(1).max(1e3).default(60),
3572
- requestsPerDay: z22.number().min(1).max(1e4).default(1e3)
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)
3573
3263
  }).optional(),
3574
- metadata: z22.object({
3575
- clientIP: z22.string().optional(),
3576
- userAgent: z22.string().optional(),
3577
- createdFrom: z22.enum(["dashboard", "cli", "api"])
3264
+ metadata: z21.object({
3265
+ clientIP: z21.string().optional(),
3266
+ userAgent: z21.string().optional(),
3267
+ createdFrom: z21.enum(["dashboard", "cli", "api"])
3578
3268
  })
3579
3269
  });
3580
3270
 
3581
3271
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/revoke.js
3582
- import { z as z23 } from "zod";
3583
- var revokeUserApiKeySchema = z23.object({
3584
- keyId: z23.string(),
3585
- reason: z23.string().optional()
3272
+ import { z as z22 } from "zod";
3273
+ var revokeUserApiKeySchema = z22.object({
3274
+ keyId: z22.string(),
3275
+ reason: z22.string().optional()
3586
3276
  });
3587
3277
 
3588
3278
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/rotate.js
3589
3279
  import { randomBytes as randomBytes3 } from "crypto";
3590
3280
  import bcrypt6 from "bcryptjs";
3591
- import { z as z24 } from "zod";
3592
- var rotateUserApiKeySchema = z24.object({
3593
- keyId: z24.string()
3281
+ import { z as z23 } from "zod";
3282
+ var rotateUserApiKeySchema = z23.object({
3283
+ keyId: z23.string()
3594
3284
  });
3595
3285
 
3596
3286
  // ../../b4m-core/packages/services/dist/src/userApiKeyService/validate.js
@@ -3737,29 +3427,29 @@ var EVENT_GROUPS = [
3737
3427
  ];
3738
3428
 
3739
3429
  // ../../b4m-core/packages/services/dist/src/countersService/generateReport.js
3740
- import { z as z26 } from "zod";
3430
+ import { z as z25 } from "zod";
3741
3431
 
3742
3432
  // ../../b4m-core/packages/services/dist/src/countersService/getAllCounterFrom24Hours.js
3743
- import { z as z25 } from "zod";
3433
+ import { z as z24 } from "zod";
3744
3434
  import dayjs2 from "dayjs";
3745
- var getCounterTotalsForLast24HoursSchema = z25.object({
3746
- date: z25.string(),
3747
- endDate: z25.string().optional()
3435
+ var getCounterTotalsForLast24HoursSchema = z24.object({
3436
+ date: z24.string(),
3437
+ endDate: z24.string().optional()
3748
3438
  });
3749
3439
 
3750
3440
  // ../../b4m-core/packages/services/dist/src/countersService/generateReport.js
3751
- var generateDailyReportSchema = z26.object({
3752
- date: z26.string(),
3753
- startDate: z26.string().optional(),
3754
- endDate: z26.string().optional()
3441
+ var generateDailyReportSchema = z25.object({
3442
+ date: z25.string(),
3443
+ startDate: z25.string().optional(),
3444
+ endDate: z25.string().optional()
3755
3445
  });
3756
3446
 
3757
3447
  // ../../b4m-core/packages/services/dist/src/countersService/incrementUserCounter.js
3758
- import { z as z27 } from "zod";
3759
- var incrementUserCounterSchema = z27.object({
3760
- action: z27.string(),
3761
- increment: z27.coerce.number().default(1).optional(),
3762
- metadata: z27.record(z27.unknown()).optional()
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()
3763
3453
  });
3764
3454
 
3765
3455
  // ../../b4m-core/packages/services/dist/src/countersService/sendSlackReport.js
@@ -3775,47 +3465,47 @@ import { GoogleGenerativeAI } from "@google/generative-ai";
3775
3465
  import OpenAI2 from "openai";
3776
3466
 
3777
3467
  // ../../b4m-core/packages/services/dist/src/importHistoryService/index.js
3778
- import fs7, { unlinkSync } from "fs";
3468
+ import fs6, { unlinkSync } from "fs";
3779
3469
  import yauzl from "yauzl";
3780
3470
  import axios3 from "axios";
3781
3471
 
3782
3472
  // ../../b4m-core/packages/services/dist/src/importHistoryService/importOpenaiHistory.js
3783
- import { z as z28 } from "zod";
3473
+ import { z as z27 } from "zod";
3784
3474
  import last from "lodash/last.js";
3785
- var epochDate = () => z28.preprocess((val) => new Date(Number(val) * 1e3), z28.date());
3786
- var openaiConversationSchema = z28.object({
3787
- id: z28.string(),
3788
- title: z28.string(),
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(),
3789
3479
  create_time: epochDate(),
3790
3480
  update_time: epochDate().nullable(),
3791
- mapping: z28.record(
3792
- z28.string(),
3793
- z28.object({
3794
- id: z28.string(),
3795
- parent: z28.string().nullable(),
3796
- children: z28.array(z28.string()),
3797
- message: z28.object({
3798
- id: z28.string(),
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(),
3799
3489
  create_time: epochDate(),
3800
3490
  update_time: epochDate().nullable(),
3801
- author: z28.object({
3802
- role: z28.string(),
3803
- name: z28.string().nullable(),
3804
- metadata: z28.any()
3491
+ author: z27.object({
3492
+ role: z27.string(),
3493
+ name: z27.string().nullable(),
3494
+ metadata: z27.any()
3805
3495
  // Accept any metadata structure
3806
3496
  }).passthrough(),
3807
3497
  // Allow extra fields in author
3808
- content: z28.object({
3809
- content_type: z28.string(),
3810
- parts: z28.array(z28.any()).optional()
3498
+ content: z27.object({
3499
+ content_type: z27.string(),
3500
+ parts: z27.array(z27.any()).optional()
3811
3501
  // Accept any type in parts array (strings, objects, etc.)
3812
3502
  }).passthrough(),
3813
3503
  // Allow extra fields in content
3814
- status: z28.string(),
3815
- end_turn: z28.boolean().nullable(),
3816
- metadata: z28.any(),
3504
+ status: z27.string(),
3505
+ end_turn: z27.boolean().nullable(),
3506
+ metadata: z27.any(),
3817
3507
  // Accept any metadata structure since it varies widely
3818
- recipient: z28.string()
3508
+ recipient: z27.string()
3819
3509
  }).passthrough().nullable()
3820
3510
  }).passthrough()
3821
3511
  // Allow extra fields in mapping node
@@ -3823,38 +3513,38 @@ var openaiConversationSchema = z28.object({
3823
3513
  }).passthrough();
3824
3514
 
3825
3515
  // ../../b4m-core/packages/services/dist/src/importHistoryService/importClaudeHistory.js
3826
- import { z as z29 } from "zod";
3827
- var claudeChatMessageSchema = z29.object({
3828
- uuid: z29.string().uuid(),
3829
- text: z29.string(),
3830
- content: z29.array(
3831
- z29.object({
3832
- type: z29.string(),
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(),
3833
3523
  // Accept any type: "text", "image", "tool_result", etc.
3834
- text: z29.string().optional()
3524
+ text: z28.string().optional()
3835
3525
  // Make text optional since tool_result may not have it
3836
3526
  }).passthrough()
3837
3527
  // Allow all other fields
3838
3528
  ),
3839
- sender: z29.enum(["human", "assistant"]),
3840
- created_at: z29.coerce.date(),
3841
- updated_at: z29.coerce.date(),
3842
- attachments: z29.array(z29.any()),
3529
+ sender: z28.enum(["human", "assistant"]),
3530
+ created_at: z28.coerce.date(),
3531
+ updated_at: z28.coerce.date(),
3532
+ attachments: z28.array(z28.any()),
3843
3533
  // Accept any attachment structure
3844
- files: z29.array(z29.any())
3534
+ files: z28.array(z28.any())
3845
3535
  // Accept any file structure
3846
3536
  }).passthrough();
3847
- var claudeConversationSchema = z29.object({
3848
- uuid: z29.string().uuid(),
3849
- name: z29.string(),
3850
- summary: z29.string().optional(),
3537
+ var claudeConversationSchema = z28.object({
3538
+ uuid: z28.string().uuid(),
3539
+ name: z28.string(),
3540
+ summary: z28.string().optional(),
3851
3541
  // Summary field is optional
3852
- created_at: z29.coerce.date(),
3853
- updated_at: z29.coerce.date(),
3854
- account: z29.object({
3855
- uuid: z29.string().uuid()
3542
+ created_at: z28.coerce.date(),
3543
+ updated_at: z28.coerce.date(),
3544
+ account: z28.object({
3545
+ uuid: z28.string().uuid()
3856
3546
  }),
3857
- chat_messages: z29.array(claudeChatMessageSchema)
3547
+ chat_messages: z28.array(claudeChatMessageSchema)
3858
3548
  }).passthrough();
3859
3549
 
3860
3550
  // ../../b4m-core/packages/services/dist/src/importHistoryService/index.js
@@ -3865,357 +3555,357 @@ var ImportSource;
3865
3555
  })(ImportSource || (ImportSource = {}));
3866
3556
 
3867
3557
  // ../../b4m-core/packages/services/dist/src/sessionService/create.js
3868
- import { z as z30 } from "zod";
3869
- var createSessionParametersSchema = z30.object({
3870
- name: z30.string(),
3871
- knowledgeIds: z30.array(z30.string()).optional(),
3872
- artifactIds: z30.array(z30.string()).optional(),
3873
- agentIds: z30.array(z30.string()).optional(),
3874
- tags: z30.array(z30.object({ name: z30.string(), strength: z30.number() })).optional(),
3875
- summary: z30.string().optional(),
3876
- summaryAt: z30.date().optional(),
3877
- clonedSourceId: z30.string().optional().nullable(),
3878
- forkedSourceId: z30.string().optional().nullable(),
3879
- projectId: z30.string().optional(),
3880
- lastUsedModel: z30.string().optional().nullable()
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()
3881
3571
  });
3882
3572
 
3883
3573
  // ../../b4m-core/packages/services/dist/src/sessionService/delete.js
3884
- import { z as z31 } from "zod";
3885
- var deleteSessionSchema = z31.object({
3886
- id: z31.string()
3574
+ import { z as z30 } from "zod";
3575
+ var deleteSessionSchema = z30.object({
3576
+ id: z30.string()
3887
3577
  });
3888
3578
 
3889
3579
  // ../../b4m-core/packages/services/dist/src/sessionService/sumarize.js
3890
- import { z as z32 } from "zod";
3891
- var sumarizeSessionSchema = z32.object({
3892
- id: z32.string()
3580
+ import { z as z31 } from "zod";
3581
+ var sumarizeSessionSchema = z31.object({
3582
+ id: z31.string()
3893
3583
  });
3894
3584
 
3895
3585
  // ../../b4m-core/packages/services/dist/src/projectService/create.js
3896
- import { z as z33 } from "zod";
3897
- var createProjectSchema = z33.object({
3898
- name: z33.string().min(1),
3899
- description: z33.string().min(1),
3900
- sessionIds: z33.array(z33.string()).optional(),
3901
- fileIds: z33.array(z33.string()).optional()
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()
3902
3592
  });
3903
3593
 
3904
3594
  // ../../b4m-core/packages/services/dist/src/projectService/search.js
3905
- import { z as z34 } from "zod";
3906
- var searchProjectsSchema = z34.object({
3907
- search: z34.string().optional(),
3908
- filters: z34.object({
3909
- favorite: z34.coerce.boolean().optional(),
3910
- scope: z34.record(z34.any()).optional()
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()
3911
3601
  }).optional(),
3912
- pagination: z34.object({
3913
- page: z34.coerce.number().optional(),
3914
- limit: z34.coerce.number().optional()
3602
+ pagination: z33.object({
3603
+ page: z33.coerce.number().optional(),
3604
+ limit: z33.coerce.number().optional()
3915
3605
  }).optional(),
3916
- orderBy: z34.object({
3917
- by: z34.enum(["createdAt", "updatedAt"]).optional(),
3918
- direction: z34.enum(["asc", "desc"]).optional()
3606
+ orderBy: z33.object({
3607
+ by: z33.enum(["createdAt", "updatedAt"]).optional(),
3608
+ direction: z33.enum(["asc", "desc"]).optional()
3919
3609
  }).optional()
3920
3610
  });
3921
3611
 
3922
3612
  // ../../b4m-core/packages/services/dist/src/projectService/addSessions.js
3923
- import { z as z45 } from "zod";
3613
+ import { z as z44 } from "zod";
3924
3614
  import uniq2 from "lodash/uniq.js";
3925
3615
 
3926
3616
  // ../../b4m-core/packages/services/dist/src/sharingService/accept.js
3927
- import { z as z35 } from "zod";
3928
- var acceptInviteSchema = z35.object({
3929
- id: z35.string()
3617
+ import { z as z34 } from "zod";
3618
+ var acceptInviteSchema = z34.object({
3619
+ id: z34.string()
3930
3620
  });
3931
3621
 
3932
3622
  // ../../b4m-core/packages/services/dist/src/sharingService/cancel.js
3933
- import { z as z36 } from "zod";
3934
- var cancelInviteSchema = z36.object({
3935
- id: z36.string(),
3936
- type: z36.nativeEnum(InviteType),
3937
- email: z36.string().email().optional()
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()
3938
3628
  });
3939
3629
 
3940
3630
  // ../../b4m-core/packages/services/dist/src/sharingService/cancelOwnDocument.js
3941
- import { z as z37 } from "zod";
3942
- var cancelOwnDocumentInvitesSchema = z37.object({
3943
- documentId: z37.string(),
3944
- type: z37.nativeEnum(InviteType)
3631
+ import { z as z36 } from "zod";
3632
+ var cancelOwnDocumentInvitesSchema = z36.object({
3633
+ documentId: z36.string(),
3634
+ type: z36.nativeEnum(InviteType)
3945
3635
  });
3946
3636
 
3947
3637
  // ../../b4m-core/packages/services/dist/src/sharingService/create.js
3948
- import { z as z38 } from "zod";
3638
+ import { z as z37 } from "zod";
3949
3639
  var defaultExpiration = () => new Date((/* @__PURE__ */ new Date()).getFullYear() + 100, (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate());
3950
3640
  var DEFAULT_AVAILABLE = 1;
3951
- var createInviteSchema = z38.object({
3952
- id: z38.string(),
3953
- type: z38.nativeEnum(InviteType),
3954
- permissions: z38.array(z38.nativeEnum(Permission)),
3955
- recipients: z38.string().array().optional(),
3956
- description: z38.string().optional(),
3957
- expiresAt: z38.date().optional().default(defaultExpiration()),
3958
- available: z38.number().optional().default(DEFAULT_AVAILABLE)
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)
3959
3649
  });
3960
3650
 
3961
3651
  // ../../b4m-core/packages/services/dist/src/sharingService/get.js
3962
- import { z as z39 } from "zod";
3963
- var getInviteSchema = z39.object({
3964
- id: z39.string(),
3965
- withUsername: z39.boolean().optional()
3652
+ import { z as z38 } from "zod";
3653
+ var getInviteSchema = z38.object({
3654
+ id: z38.string(),
3655
+ withUsername: z38.boolean().optional()
3966
3656
  });
3967
3657
 
3968
3658
  // ../../b4m-core/packages/services/dist/src/sharingService/listByDocumentIdAndType.js
3969
- import { z as z40 } from "zod";
3970
- var listInviteByDocumentIdAndTypeSchema = z40.object({
3971
- documentId: z40.string(),
3972
- type: z40.nativeEnum(InviteType)
3659
+ import { z as z39 } from "zod";
3660
+ var listInviteByDocumentIdAndTypeSchema = z39.object({
3661
+ documentId: z39.string(),
3662
+ type: z39.nativeEnum(InviteType)
3973
3663
  });
3974
3664
 
3975
3665
  // ../../b4m-core/packages/services/dist/src/sharingService/listOwnPending.js
3976
- import { z as z41 } from "zod";
3977
- var listOwnPendingInvitesSchema = z41.object({
3978
- limit: z41.number().min(1).max(100).default(20),
3979
- page: z41.number().min(1).default(1)
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)
3980
3670
  });
3981
3671
 
3982
3672
  // ../../b4m-core/packages/services/dist/src/sharingService/refuse.js
3983
- import { z as z42 } from "zod";
3984
- var refuseInviteSchema = z42.object({
3985
- id: z42.string()
3673
+ import { z as z41 } from "zod";
3674
+ var refuseInviteSchema = z41.object({
3675
+ id: z41.string()
3986
3676
  });
3987
3677
 
3988
3678
  // ../../b4m-core/packages/services/dist/src/sharingService/revoke.js
3989
- import { z as z43 } from "zod";
3990
- var revokeSharingSchema = z43.object({
3991
- id: z43.string(),
3992
- type: z43.enum(["files", "sessions", "projects"]),
3993
- userId: z43.string(),
3994
- projectId: z43.string().optional()
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()
3995
3685
  });
3996
3686
 
3997
3687
  // ../../b4m-core/packages/services/dist/src/projectService/addFiles.js
3998
- import { z as z44 } from "zod";
3688
+ import { z as z43 } from "zod";
3999
3689
  import uniq from "lodash/uniq.js";
4000
- var addFilesProjectSchema = z44.object({
4001
- projectId: z44.string().nonempty(),
4002
- fileIds: z44.array(z44.string().nonempty())
3690
+ var addFilesProjectSchema = z43.object({
3691
+ projectId: z43.string().nonempty(),
3692
+ fileIds: z43.array(z43.string().nonempty())
4003
3693
  });
4004
3694
 
4005
3695
  // ../../b4m-core/packages/services/dist/src/projectService/addSessions.js
4006
- var addSessionsProjectSchema = z45.object({
4007
- projectId: z45.string().nonempty(),
4008
- sessionIds: z45.array(z45.string().nonempty())
3696
+ var addSessionsProjectSchema = z44.object({
3697
+ projectId: z44.string().nonempty(),
3698
+ sessionIds: z44.array(z44.string().nonempty())
4009
3699
  });
4010
3700
 
4011
3701
  // ../../b4m-core/packages/services/dist/src/projectService/get.js
4012
- import { z as z46 } from "zod";
4013
- var getProjectSchema = z46.object({
4014
- id: z46.string()
3702
+ import { z as z45 } from "zod";
3703
+ var getProjectSchema = z45.object({
3704
+ id: z45.string()
4015
3705
  });
4016
3706
 
4017
3707
  // ../../b4m-core/packages/services/dist/src/projectService/update.js
4018
- import { z as z47 } from "zod";
4019
- var updateProjectSchema = z47.object({
4020
- id: z47.string(),
4021
- name: z47.string().optional(),
4022
- description: z47.string().optional()
3708
+ 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()
4023
3713
  });
4024
3714
 
4025
3715
  // ../../b4m-core/packages/services/dist/src/projectService/delete.js
4026
- import { z as z48 } from "zod";
4027
- var deleteProjectSchema = z48.object({
4028
- id: z48.string()
3716
+ import { z as z47 } from "zod";
3717
+ var deleteProjectSchema = z47.object({
3718
+ id: z47.string()
4029
3719
  });
4030
3720
 
4031
3721
  // ../../b4m-core/packages/services/dist/src/projectService/removeFiles.js
3722
+ import { z as z48 } from "zod";
3723
+ var removeProjectFilesSchema = z48.object({
3724
+ projectId: z48.string(),
3725
+ fileIds: z48.array(z48.string())
3726
+ });
3727
+
3728
+ // ../../b4m-core/packages/services/dist/src/projectService/removeSessions.js
4032
3729
  import { z as z49 } from "zod";
4033
- var removeProjectFilesSchema = z49.object({
3730
+ var removeProjectSessionsSchema = z49.object({
4034
3731
  projectId: z49.string(),
4035
- fileIds: z49.array(z49.string())
3732
+ sessionIds: z49.array(z49.string())
4036
3733
  });
4037
3734
 
4038
- // ../../b4m-core/packages/services/dist/src/projectService/removeSessions.js
3735
+ // ../../b4m-core/packages/services/dist/src/projectService/listSessions.js
4039
3736
  import { z as z50 } from "zod";
4040
- var removeProjectSessionsSchema = z50.object({
4041
- projectId: z50.string(),
4042
- sessionIds: z50.array(z50.string())
3737
+ var listProjectSessionsSchema = z50.object({
3738
+ projectId: z50.string()
4043
3739
  });
4044
3740
 
4045
- // ../../b4m-core/packages/services/dist/src/projectService/listSessions.js
3741
+ // ../../b4m-core/packages/services/dist/src/projectService/listFiles.js
4046
3742
  import { z as z51 } from "zod";
4047
- var listProjectSessionsSchema = z51.object({
3743
+ var listProjectFilesSchema = z51.object({
4048
3744
  projectId: z51.string()
4049
3745
  });
4050
3746
 
4051
- // ../../b4m-core/packages/services/dist/src/projectService/listFiles.js
3747
+ // ../../b4m-core/packages/services/dist/src/projectService/listInvites.js
4052
3748
  import { z as z52 } from "zod";
4053
- var listProjectFilesSchema = z52.object({
4054
- projectId: z52.string()
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)
4055
3754
  });
4056
3755
 
4057
- // ../../b4m-core/packages/services/dist/src/projectService/listInvites.js
3756
+ // ../../b4m-core/packages/services/dist/src/projectService/addSystemPrompts.js
4058
3757
  import { z as z53 } from "zod";
4059
- var listProjectInvitesParamsSchema = z53.object({
4060
- id: z53.string(),
4061
- statuses: z53.string().optional().default(""),
4062
- limit: z53.coerce.number().optional().default(10),
4063
- page: z53.coerce.number().optional().default(1)
3758
+ var addSystemPromptsSchema = z53.object({
3759
+ projectId: z53.string(),
3760
+ fileIds: z53.array(z53.string())
4064
3761
  });
4065
3762
 
4066
- // ../../b4m-core/packages/services/dist/src/projectService/addSystemPrompts.js
3763
+ // ../../b4m-core/packages/services/dist/src/projectService/toggleSystemPrompt.js
4067
3764
  import { z as z54 } from "zod";
4068
- var addSystemPromptsSchema = z54.object({
3765
+ var toggleSystemPromptSchema = z54.object({
4069
3766
  projectId: z54.string(),
4070
- fileIds: z54.array(z54.string())
3767
+ fileId: z54.string()
4071
3768
  });
4072
3769
 
4073
- // ../../b4m-core/packages/services/dist/src/projectService/toggleSystemPrompt.js
3770
+ // ../../b4m-core/packages/services/dist/src/projectService/removeSystemPrompt.js
4074
3771
  import { z as z55 } from "zod";
4075
- var toggleSystemPromptSchema = z55.object({
3772
+ var removeSystemPromptSchema = z55.object({
4076
3773
  projectId: z55.string(),
4077
3774
  fileId: z55.string()
4078
3775
  });
4079
3776
 
4080
- // ../../b4m-core/packages/services/dist/src/projectService/removeSystemPrompt.js
4081
- import { z as z56 } from "zod";
4082
- var removeSystemPromptSchema = z56.object({
4083
- projectId: z56.string(),
4084
- fileId: z56.string()
4085
- });
4086
-
4087
3777
  // ../../b4m-core/packages/services/dist/src/projectService/addFavorite.js
4088
- import { z as z59 } from "zod";
3778
+ import { z as z58 } from "zod";
4089
3779
 
4090
3780
  // ../../b4m-core/packages/services/dist/src/favoriteService/create.js
4091
- import { z as z57 } from "zod";
4092
- var createFavoriteParametersSchema = z57.object({
4093
- documentId: z57.string(),
4094
- documentType: z57.nativeEnum(FavoriteDocumentType)
3781
+ import { z as z56 } from "zod";
3782
+ var createFavoriteParametersSchema = z56.object({
3783
+ documentId: z56.string(),
3784
+ documentType: z56.nativeEnum(FavoriteDocumentType)
4095
3785
  });
4096
3786
 
4097
3787
  // ../../b4m-core/packages/services/dist/src/favoriteService/delete.js
4098
- import { z as z58 } from "zod";
4099
- var deleteFavoriteParametersSchema = z58.object({
4100
- documentId: z58.string(),
4101
- documentType: z58.nativeEnum(FavoriteDocumentType)
3788
+ import { z as z57 } from "zod";
3789
+ var deleteFavoriteParametersSchema = z57.object({
3790
+ documentId: z57.string(),
3791
+ documentType: z57.nativeEnum(FavoriteDocumentType)
4102
3792
  });
4103
3793
 
4104
3794
  // ../../b4m-core/packages/services/dist/src/projectService/addFavorite.js
4105
- var addFavoriteParametersSchema = z59.object({
4106
- projectId: z59.string()
3795
+ var addFavoriteParametersSchema = z58.object({
3796
+ projectId: z58.string()
4107
3797
  });
4108
3798
 
4109
3799
  // ../../b4m-core/packages/services/dist/src/projectService/deleteFavorite.js
4110
- import { z as z60 } from "zod";
4111
- var deleteFavoriteParametersSchema2 = z60.object({
4112
- projectId: z60.string()
3800
+ import { z as z59 } from "zod";
3801
+ var deleteFavoriteParametersSchema2 = z59.object({
3802
+ projectId: z59.string()
4113
3803
  });
4114
3804
 
4115
3805
  // ../../b4m-core/packages/services/dist/src/projectService/removeNonExistentFiles.js
4116
- import { z as z61 } from "zod";
4117
- var removeNonExistentFilesSchema = z61.object({
4118
- projectId: z61.string()
3806
+ import { z as z60 } from "zod";
3807
+ var removeNonExistentFilesSchema = z60.object({
3808
+ projectId: z60.string()
4119
3809
  });
4120
3810
 
4121
3811
  // ../../b4m-core/packages/services/dist/src/projectService/leaveProject.js
4122
- import { z as z62 } from "zod";
4123
- var leaveProjectParamsSchema = z62.object({
4124
- id: z62.string(),
4125
- userIdToRemove: z62.string().optional()
3812
+ import { z as z61 } from "zod";
3813
+ var leaveProjectParamsSchema = z61.object({
3814
+ id: z61.string(),
3815
+ userIdToRemove: z61.string().optional()
4126
3816
  // Optional: if provided, this is a removal by owner
4127
3817
  });
4128
3818
 
4129
3819
  // ../../b4m-core/packages/services/dist/src/sessionService/update.js
4130
3820
  import uniq3 from "lodash/uniq.js";
4131
3821
  import isEqual from "lodash/isEqual.js";
4132
- import { z as z63 } from "zod";
4133
- var updateSessionParamtersSchema = z63.object({
4134
- id: z63.string(),
4135
- name: z63.string().optional(),
4136
- knowledgeIds: z63.array(z63.string()).optional(),
4137
- artifactIds: z63.array(z63.string()).optional(),
4138
- tags: z63.array(z63.object({ name: z63.string(), strength: z63.number() })).optional(),
4139
- lastUsedModel: z63.string().optional()
3822
+ import { z as z62 } from "zod";
3823
+ var updateSessionParamtersSchema = z62.object({
3824
+ 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
3830
  });
4141
3831
 
4142
3832
  // ../../b4m-core/packages/services/dist/src/sessionService/clone.js
4143
- import { z as z64 } from "zod";
4144
- var cloneSessionSchema = z64.object({
4145
- id: z64.string()
3833
+ import { z as z63 } from "zod";
3834
+ var cloneSessionSchema = z63.object({
3835
+ id: z63.string()
4146
3836
  });
4147
3837
 
4148
3838
  // ../../b4m-core/packages/services/dist/src/sessionService/fork.js
3839
+ import { z as z64 } from "zod";
3840
+ var forkSessionSchema = z64.object({
3841
+ sessionId: z64.string(),
3842
+ messageId: z64.string()
3843
+ });
3844
+
3845
+ // ../../b4m-core/packages/services/dist/src/sessionService/snip.js
4149
3846
  import { z as z65 } from "zod";
4150
- var forkSessionSchema = z65.object({
3847
+ var snipSessionSchema = z65.object({
4151
3848
  sessionId: z65.string(),
4152
3849
  messageId: z65.string()
4153
3850
  });
4154
3851
 
4155
- // ../../b4m-core/packages/services/dist/src/sessionService/snip.js
3852
+ // ../../b4m-core/packages/services/dist/src/sessionService/get.js
4156
3853
  import { z as z66 } from "zod";
4157
- var snipSessionSchema = z66.object({
4158
- sessionId: z66.string(),
4159
- messageId: z66.string()
3854
+ var getSessionSchema = z66.object({
3855
+ id: z66.string()
4160
3856
  });
4161
3857
 
4162
- // ../../b4m-core/packages/services/dist/src/sessionService/get.js
3858
+ // ../../b4m-core/packages/services/dist/src/sessionService/deleteMessage.js
4163
3859
  import { z as z67 } from "zod";
4164
- var getSessionSchema = z67.object({
4165
- id: z67.string()
3860
+ var deleteSessionMessageSchema = z67.object({
3861
+ sessionId: z67.string(),
3862
+ messageId: z67.string()
4166
3863
  });
4167
3864
 
4168
- // ../../b4m-core/packages/services/dist/src/sessionService/deleteMessage.js
3865
+ // ../../b4m-core/packages/services/dist/src/sessionService/addFavorite.js
4169
3866
  import { z as z68 } from "zod";
4170
- var deleteSessionMessageSchema = z68.object({
4171
- sessionId: z68.string(),
4172
- messageId: z68.string()
3867
+ var addFavoriteParametersSchema2 = z68.object({
3868
+ sessionId: z68.string()
4173
3869
  });
4174
3870
 
4175
- // ../../b4m-core/packages/services/dist/src/sessionService/addFavorite.js
3871
+ // ../../b4m-core/packages/services/dist/src/sessionService/deleteFavorite.js
4176
3872
  import { z as z69 } from "zod";
4177
- var addFavoriteParametersSchema2 = z69.object({
3873
+ var deleteFavoriteParametersSchema3 = z69.object({
4178
3874
  sessionId: z69.string()
4179
3875
  });
4180
3876
 
4181
- // ../../b4m-core/packages/services/dist/src/sessionService/deleteFavorite.js
4182
- import { z as z70 } from "zod";
4183
- var deleteFavoriteParametersSchema3 = z70.object({
4184
- sessionId: z70.string()
4185
- });
4186
-
4187
3877
  // ../../b4m-core/packages/services/dist/src/sessionService/autoName.js
4188
- import { z as z71 } from "zod";
4189
- var autoNameParameterSchema = z71.object({
4190
- sessionId: z71.string(),
3878
+ import { z as z70 } from "zod";
3879
+ var autoNameParameterSchema = z70.object({
3880
+ sessionId: z70.string(),
4191
3881
  /** The maximum number of words to include in the title */
4192
- maxWords: z71.number().optional()
3882
+ maxWords: z70.number().optional()
4193
3883
  });
4194
3884
 
4195
3885
  // ../../b4m-core/packages/services/dist/src/organizationService/search.js
4196
- import { z as z72 } from "zod";
4197
- var searchSchema2 = z72.object({
3886
+ import { z as z71 } from "zod";
3887
+ var searchSchema2 = z71.object({
4198
3888
  /**
4199
3889
  * Text search query (searches in name and description)
4200
3890
  */
4201
- query: z72.string().optional(),
3891
+ query: z71.string().optional(),
4202
3892
  /**
4203
3893
  * Filter by personal organizations
4204
3894
  */
4205
- filters: z72.object({
4206
- personal: z72.union([z72.enum(["true", "false"]).transform((val) => val === "true"), z72.boolean()]).optional(),
4207
- userId: z72.string().optional()
3895
+ filters: z71.object({
3896
+ personal: z71.union([z71.enum(["true", "false"]).transform((val) => val === "true"), z71.boolean()]).optional(),
3897
+ userId: z71.string().optional()
4208
3898
  }).default({}),
4209
- pagination: z72.object({
4210
- page: z72.coerce.number().int().positive().default(1),
4211
- limit: z72.coerce.number().int().positive().max(100).default(10)
3899
+ pagination: z71.object({
3900
+ page: z71.coerce.number().int().positive().default(1),
3901
+ limit: z71.coerce.number().int().positive().max(100).default(10)
4212
3902
  }).default({
4213
3903
  page: 1,
4214
3904
  limit: 10
4215
3905
  }),
4216
- orderBy: z72.object({
4217
- field: z72.enum(["name", "createdAt", "updatedAt"]).default("name"),
4218
- direction: z72.enum(["asc", "desc"]).default("asc")
3906
+ orderBy: z71.object({
3907
+ field: z71.enum(["name", "createdAt", "updatedAt"]).default("name"),
3908
+ direction: z71.enum(["asc", "desc"]).default("asc")
4219
3909
  }).default({
4220
3910
  field: "name",
4221
3911
  direction: "asc"
@@ -4223,355 +3913,355 @@ var searchSchema2 = z72.object({
4223
3913
  });
4224
3914
 
4225
3915
  // ../../b4m-core/packages/services/dist/src/organizationService/get.js
4226
- import { z as z73 } from "zod";
4227
- var getSchema = z73.object({
3916
+ import { z as z72 } from "zod";
3917
+ var getSchema = z72.object({
4228
3918
  /**
4229
3919
  * Organization ID
4230
3920
  */
4231
- id: z73.string().min(1)
3921
+ id: z72.string().min(1)
4232
3922
  });
4233
3923
 
4234
3924
  // ../../b4m-core/packages/services/dist/src/organizationService/addMember.js
4235
- import { z as z74 } from "zod";
4236
- var addMemberSchema = z74.object({
4237
- userId: z74.string().optional(),
4238
- email: z74.string().optional(),
4239
- organizationId: z74.string(),
4240
- force: z74.boolean().optional()
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()
4241
3931
  // If true, add the user to the organization even if it's at full capacity
4242
3932
  });
4243
3933
 
4244
3934
  // ../../b4m-core/packages/services/dist/src/organizationService/getUsers.js
4245
- import { z as z75 } from "zod";
4246
- var getUsersSchema = z75.object({
4247
- id: z75.string()
3935
+ import { z as z74 } from "zod";
3936
+ var getUsersSchema = z74.object({
3937
+ id: z74.string()
4248
3938
  });
4249
3939
 
4250
3940
  // ../../b4m-core/packages/services/dist/src/organizationService/create.js
4251
- import { z as z76 } from "zod";
4252
- var createSchema = z76.object({
4253
- name: z76.string(),
4254
- personal: z76.boolean().default(false),
4255
- seats: z76.number().default(1),
4256
- stripeCustomerId: z76.string().nullable(),
4257
- billingOwnerId: z76.string().optional(),
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(),
4258
3948
  // Optional billing owner (defaults to user if not provided)
4259
- managerId: z76.string().optional()
3949
+ managerId: z75.string().optional()
4260
3950
  // Optional team manager
4261
3951
  });
4262
3952
 
4263
3953
  // ../../b4m-core/packages/services/dist/src/organizationService/update.js
4264
- import { z as z77 } from "zod";
4265
- var updateSchema = z77.object({
4266
- id: z77.string(),
4267
- name: z77.string().optional(),
4268
- description: z77.string().optional(),
4269
- billingContact: z77.string().optional(),
4270
- currentCredits: z77.coerce.number().optional()
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()
4271
3961
  });
4272
3962
 
4273
3963
  // ../../b4m-core/packages/services/dist/src/organizationService/delete.js
4274
- import { z as z78 } from "zod";
4275
- var deleteSchema = z78.object({
3964
+ import { z as z77 } from "zod";
3965
+ var deleteSchema = z77.object({
4276
3966
  /**
4277
3967
  * Organization ID
4278
3968
  */
4279
- id: z78.string().min(1)
3969
+ id: z77.string().min(1)
4280
3970
  });
4281
3971
 
4282
3972
  // ../../b4m-core/packages/services/dist/src/organizationService/listPendingUsers.js
4283
- import { z as z79 } from "zod";
4284
- var listPendingUsersSchema = z79.object({
4285
- organizationId: z79.string()
3973
+ import { z as z78 } from "zod";
3974
+ var listPendingUsersSchema = z78.object({
3975
+ organizationId: z78.string()
4286
3976
  });
4287
3977
 
4288
3978
  // ../../b4m-core/packages/services/dist/src/organizationService/revokeAccess.js
4289
- import { z as z80 } from "zod";
4290
- var revokeAccessSchema = z80.object({
4291
- id: z80.string(),
4292
- userId: z80.string()
3979
+ import { z as z79 } from "zod";
3980
+ var revokeAccessSchema = z79.object({
3981
+ id: z79.string(),
3982
+ userId: z79.string()
4293
3983
  });
4294
3984
 
4295
3985
  // ../../b4m-core/packages/services/dist/src/organizationService/leave.js
4296
- import { z as z81 } from "zod";
4297
- var organizationLeaveSchema = z81.object({
4298
- id: z81.string()
3986
+ import { z as z80 } from "zod";
3987
+ var organizationLeaveSchema = z80.object({
3988
+ id: z80.string()
4299
3989
  });
4300
3990
 
4301
3991
  // ../../b4m-core/packages/services/dist/src/apiKeyService/create.js
4302
- import { z as z82 } from "zod";
4303
- var createApiKeySchema = z82.object({
4304
- apiKey: z82.string().min(6),
4305
- description: z82.string().optional().default(""),
4306
- isActive: z82.boolean().optional().default(true),
4307
- type: z82.nativeEnum(ApiKeyType),
4308
- expireDays: z82.number().min(1).max(365).default(90)
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)
4309
3999
  // Default 90-day expiration
4310
4000
  });
4311
4001
 
4312
4002
  // ../../b4m-core/packages/services/dist/src/apiKeyService/set.js
4313
- import { z as z83 } from "zod";
4314
- var setApiKeySchema = z83.object({
4315
- id: z83.string(),
4316
- type: z83.nativeEnum(ApiKeyType)
4003
+ import { z as z82 } from "zod";
4004
+ var setApiKeySchema = z82.object({
4005
+ id: z82.string(),
4006
+ type: z82.nativeEnum(ApiKeyType)
4317
4007
  });
4318
4008
 
4319
4009
  // ../../b4m-core/packages/services/dist/src/apiKeyService/delete.js
4320
- import { z as z84 } from "zod";
4321
- var deleteApiKeySchema = z84.object({
4322
- id: z84.string()
4010
+ import { z as z83 } from "zod";
4011
+ var deleteApiKeySchema = z83.object({
4012
+ id: z83.string()
4323
4013
  });
4324
4014
 
4325
4015
  // ../../b4m-core/packages/services/dist/src/fabFileService/get.js
4326
- import { z as z85 } from "zod";
4327
- var getFabFileSchema = z85.object({
4328
- id: z85.string()
4016
+ import { z as z84 } from "zod";
4017
+ var getFabFileSchema = z84.object({
4018
+ id: z84.string()
4329
4019
  });
4330
4020
 
4331
4021
  // ../../b4m-core/packages/services/dist/src/fabFileService/list.js
4332
- import { z as z86 } from "zod";
4333
- var listFabFilesSchema = z86.object({
4334
- ids: z86.array(z86.string()).optional()
4022
+ import { z as z85 } from "zod";
4023
+ var listFabFilesSchema = z85.object({
4024
+ ids: z85.array(z85.string()).optional()
4335
4025
  });
4336
4026
 
4337
4027
  // ../../b4m-core/packages/services/dist/src/fabFileService/update.js
4338
4028
  import mime from "mime-types";
4339
4029
  import { v4 as uuidv42 } from "uuid";
4340
- import { z as z87 } from "zod";
4341
- var updateFabFileSchema = z87.object({
4342
- id: z87.string(),
4343
- fileName: z87.string(),
4344
- mimeType: z87.string(),
4345
- fileContent: z87.string().optional(),
4346
- type: z87.nativeEnum(KnowledgeType),
4347
- system: z87.boolean().optional(),
4348
- systemPriority: z87.number().min(0).max(999).optional(),
4349
- sessionId: z87.string().optional(),
4350
- notes: z87.string().optional(),
4351
- primaryTag: z87.string().optional(),
4352
- tags: z87.array(z87.object({
4353
- name: z87.string(),
4354
- strength: z87.number()
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()
4355
4045
  })).optional(),
4356
- error: z87.string().nullable().optional()
4046
+ error: z86.string().nullable().optional()
4357
4047
  });
4358
4048
 
4359
4049
  // ../../b4m-core/packages/services/dist/src/fabFileService/delete.js
4360
- import { z as z88 } from "zod";
4361
- var deleteFabFileSchema = z88.object({
4362
- id: z88.string()
4050
+ import { z as z87 } from "zod";
4051
+ var deleteFabFileSchema = z87.object({
4052
+ id: z87.string()
4363
4053
  });
4364
4054
 
4365
4055
  // ../../b4m-core/packages/services/dist/src/fabFileService/chunk.js
4366
- import { z as z89 } from "zod";
4367
- var chunkFileSchema = z89.object({
4368
- fabFileId: z89.string(),
4369
- embeddingModel: z89.string()
4056
+ import { z as z88 } from "zod";
4057
+ var chunkFileSchema = z88.object({
4058
+ fabFileId: z88.string(),
4059
+ embeddingModel: z88.string()
4370
4060
  });
4371
4061
 
4372
4062
  // ../../b4m-core/packages/services/dist/src/fabFileService/vectorize.js
4373
- import { z as z90 } from "zod";
4374
- var vectorizeFabFileChunkSchema = z90.object({
4375
- fabFileId: z90.string(),
4376
- chunkId: z90.string()
4063
+ import { z as z89 } from "zod";
4064
+ var vectorizeFabFileChunkSchema = z89.object({
4065
+ fabFileId: z89.string(),
4066
+ chunkId: z89.string()
4377
4067
  });
4378
4068
 
4379
4069
  // ../../b4m-core/packages/services/dist/src/fabFileService/listBySession.js
4380
- import { z as z91 } from "zod";
4381
- var listFabFilesBySessionSchema = z91.object({
4382
- sessionId: z91.string()
4070
+ import { z as z90 } from "zod";
4071
+ var listFabFilesBySessionSchema = z90.object({
4072
+ sessionId: z90.string()
4383
4073
  });
4384
4074
 
4385
4075
  // ../../b4m-core/packages/services/dist/src/fabFileService/listByQuest.js
4386
- import { z as z92 } from "zod";
4387
- var listFabFilesByQuestSchema = z92.object({
4388
- questId: z92.string()
4076
+ import { z as z91 } from "zod";
4077
+ var listFabFilesByQuestSchema = z91.object({
4078
+ questId: z91.string()
4389
4079
  });
4390
4080
 
4391
4081
  // ../../b4m-core/packages/services/dist/src/fabFileService/createByUrl.js
4392
- import { z as z93 } from "zod";
4393
- var createFabFileByUrlSchema = z93.object({
4394
- 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,})).+/)
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,})).+/)
4395
4085
  });
4396
4086
 
4397
4087
  // ../../b4m-core/packages/services/dist/src/fabFileService/search.js
4398
- import { z as z94 } from "zod";
4399
- var searchFabFilesSchema = z94.object({
4400
- search: z94.string().optional(),
4401
- filters: z94.object({
4402
- tags: z94.array(z94.string()).optional(),
4403
- type: z94.enum(["text", "pdf", "url", "image", "excel", "word", "json", "csv", "markdown", "code"]).optional(),
4404
- shared: z94.coerce.boolean().optional(),
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(),
4405
4095
  // Indicates if the user is searching for shared files
4406
- curated: z94.coerce.boolean().optional(),
4096
+ curated: z93.coerce.boolean().optional(),
4407
4097
  // Indicates if the user is searching for curated notebook files
4408
- projectId: z94.string().optional(),
4409
- ids: z94.array(z94.string()).optional()
4098
+ projectId: z93.string().optional(),
4099
+ ids: z93.array(z93.string()).optional()
4410
4100
  // Add support for filtering by IDs
4411
4101
  }).optional(),
4412
- pagination: z94.object({
4413
- page: z94.coerce.number(),
4414
- limit: z94.coerce.number()
4102
+ pagination: z93.object({
4103
+ page: z93.coerce.number(),
4104
+ limit: z93.coerce.number()
4415
4105
  }).optional(),
4416
- order: z94.object({
4417
- by: z94.enum(["createdAt", "fileName", "fileSize"]),
4418
- direction: z94.enum(["asc", "desc"])
4106
+ order: z93.object({
4107
+ by: z93.enum(["createdAt", "fileName", "fileSize"]),
4108
+ direction: z93.enum(["asc", "desc"])
4419
4109
  }).optional(),
4420
- options: z94.object({
4421
- includeShared: z94.coerce.boolean().optional()
4110
+ options: z93.object({
4111
+ includeShared: z93.coerce.boolean().optional()
4422
4112
  }).optional()
4423
4113
  });
4424
4114
 
4425
4115
  // ../../b4m-core/packages/services/dist/src/fabFileService/addFavorite.js
4426
- import { z as z95 } from "zod";
4427
- var addFavoriteParametersSchema3 = z95.object({
4428
- fileId: z95.string()
4116
+ import { z as z94 } from "zod";
4117
+ var addFavoriteParametersSchema3 = z94.object({
4118
+ fileId: z94.string()
4429
4119
  });
4430
4120
 
4431
4121
  // ../../b4m-core/packages/services/dist/src/fabFileService/deleteFavorite.js
4432
- import { z as z96 } from "zod";
4433
- var deleteFavoriteParametersSchema4 = z96.object({
4434
- fileId: z96.string()
4122
+ import { z as z95 } from "zod";
4123
+ var deleteFavoriteParametersSchema4 = z95.object({
4124
+ fileId: z95.string()
4435
4125
  });
4436
4126
 
4437
4127
  // ../../b4m-core/packages/services/dist/src/fabFileService/toggleTags.js
4438
- import { z as z97 } from "zod";
4439
- var fabFileToggleTagsSchema = z97.object({
4440
- ids: z97.array(z97.string()),
4441
- tags: z97.array(z97.string())
4128
+ import { z as z96 } from "zod";
4129
+ var fabFileToggleTagsSchema = z96.object({
4130
+ ids: z96.array(z96.string()),
4131
+ tags: z96.array(z96.string())
4442
4132
  });
4443
4133
 
4444
4134
  // ../../b4m-core/packages/services/dist/src/fabFileService/edit.js
4445
- import { z as z98 } from "zod";
4135
+ import { z as z97 } from "zod";
4446
4136
  import { diffLines } from "diff";
4447
- var editFabFileSchema = z98.object({
4448
- id: z98.string(),
4449
- instruction: z98.string(),
4450
- selection: z98.object({
4451
- start: z98.number(),
4452
- end: z98.number()
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()
4453
4143
  }).optional(),
4454
- preserveFormatting: z98.boolean().optional().default(true),
4455
- applyImmediately: z98.boolean().optional().default(false)
4144
+ preserveFormatting: z97.boolean().optional().default(true),
4145
+ applyImmediately: z97.boolean().optional().default(false)
4456
4146
  });
4457
4147
 
4458
4148
  // ../../b4m-core/packages/services/dist/src/fabFileService/applyEdit.js
4459
4149
  import mime2 from "mime-types";
4460
4150
  import { v4 as uuidv43 } from "uuid";
4461
- import { z as z99 } from "zod";
4462
- var applyEditSchema = z99.object({
4463
- id: z99.string(),
4464
- modifiedContent: z99.string(),
4465
- createBackup: z99.boolean().optional().default(true)
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)
4466
4156
  });
4467
4157
 
4468
4158
  // ../../b4m-core/packages/services/dist/src/friendshipService/respondToFriendRequest.js
4469
- import { z as z100 } from "zod";
4470
- var respondToFriendRequestSchema = z100.object({
4471
- id: z100.string(),
4159
+ import { z as z99 } from "zod";
4160
+ var respondToFriendRequestSchema = z99.object({
4161
+ id: z99.string(),
4472
4162
  /** The user ID of the recipient of the friend request */
4473
- userId: z100.string(),
4474
- accept: z100.boolean()
4163
+ userId: z99.string(),
4164
+ accept: z99.boolean()
4475
4165
  });
4476
4166
 
4477
4167
  // ../../b4m-core/packages/services/dist/src/friendshipService/unfriend.js
4478
- import { z as z101 } from "zod";
4479
- var unfriendSchema = z101.object({
4480
- friendshipId: z101.string(),
4168
+ import { z as z100 } from "zod";
4169
+ var unfriendSchema = z100.object({
4170
+ friendshipId: z100.string(),
4481
4171
  /** The user ID of the user who wants to unfriend the other user */
4482
- userId: z101.string()
4172
+ userId: z100.string()
4483
4173
  });
4484
4174
 
4485
4175
  // ../../b4m-core/packages/services/dist/src/friendshipService/list.js
4486
- import { z as z102 } from "zod";
4487
- var listFriendsSchema = z102.object({
4488
- userId: z102.string()
4176
+ import { z as z101 } from "zod";
4177
+ var listFriendsSchema = z101.object({
4178
+ userId: z101.string()
4489
4179
  });
4490
- var listPendingFriendRequestsSchema = z102.object({
4491
- userId: z102.string()
4180
+ var listPendingFriendRequestsSchema = z101.object({
4181
+ userId: z101.string()
4492
4182
  });
4493
4183
 
4494
4184
  // ../../b4m-core/packages/services/dist/src/adminService/loginAs.js
4495
- import { z as z103 } from "zod";
4496
- var loginAsSchema = z103.object({
4497
- targetUserId: z103.string()
4185
+ import { z as z102 } from "zod";
4186
+ var loginAsSchema = z102.object({
4187
+ targetUserId: z102.string()
4498
4188
  });
4499
4189
 
4500
4190
  // ../../b4m-core/packages/services/dist/src/cacheService/get.js
4501
- import { z as z104 } from "zod";
4502
- var getParamsSchema = z104.object({
4503
- key: z104.string()
4191
+ import { z as z103 } from "zod";
4192
+ var getParamsSchema = z103.object({
4193
+ key: z103.string()
4504
4194
  });
4505
4195
 
4506
4196
  // ../../b4m-core/packages/services/dist/src/cacheService/set.js
4507
- import { z as z105 } from "zod";
4508
- var setParamsSchema = z105.object({
4509
- key: z105.string(),
4510
- value: z105.any(),
4197
+ import { z as z104 } from "zod";
4198
+ var setParamsSchema = z104.object({
4199
+ key: z104.string(),
4200
+ value: z104.any(),
4511
4201
  /**
4512
4202
  * Time to live in milliseconds
4513
4203
  */
4514
- ttl: z105.number(),
4515
- recache: z105.boolean().optional()
4204
+ ttl: z104.number(),
4205
+ recache: z104.boolean().optional()
4516
4206
  });
4517
4207
 
4518
4208
  // ../../b4m-core/packages/services/dist/src/cacheService/ttl.js
4519
- import { z as z106 } from "zod";
4520
- var ttlParamsSchema = z106.object({
4521
- key: z106.string()
4209
+ import { z as z105 } from "zod";
4210
+ var ttlParamsSchema = z105.object({
4211
+ key: z105.string()
4522
4212
  });
4523
4213
 
4524
4214
  // ../../b4m-core/packages/services/dist/src/cacheService/weeklyReports.js
4525
- import { z as z107 } from "zod";
4215
+ import { z as z106 } from "zod";
4526
4216
  import dayjs3 from "dayjs";
4527
- var weeklyReportSchema = z107.object({
4528
- startDate: z107.string(),
4529
- endDate: z107.string(),
4530
- report: z107.string(),
4531
- aiInsights: z107.string().nullable()
4217
+ var weeklyReportSchema = z106.object({
4218
+ startDate: z106.string(),
4219
+ endDate: z106.string(),
4220
+ report: z106.string(),
4221
+ aiInsights: z106.string().nullable()
4532
4222
  });
4533
4223
 
4534
4224
  // ../../b4m-core/packages/services/dist/src/embeddingCacheService/generateCacheKey.js
4535
4225
  import crypto2 from "crypto";
4536
4226
 
4537
4227
  // ../../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
4538
4235
  import { z as z108 } from "zod";
4539
- var researchAgentCreateSchema = z108.object({
4236
+ var researchAgentUpdateSchema = z108.object({
4237
+ id: z108.string(),
4540
4238
  name: z108.string().min(1),
4541
4239
  description: z108.string().min(1)
4542
4240
  });
4543
4241
 
4544
- // ../../b4m-core/packages/services/dist/src/researchAgentService/update.js
4242
+ // ../../b4m-core/packages/services/dist/src/researchAgentService/remove.js
4545
4243
  import { z as z109 } from "zod";
4546
- var researchAgentUpdateSchema = z109.object({
4547
- id: z109.string(),
4548
- name: z109.string().min(1),
4549
- description: z109.string().min(1)
4244
+ var researchAgentRemoveSchema = z109.object({
4245
+ id: z109.string()
4550
4246
  });
4551
4247
 
4552
- // ../../b4m-core/packages/services/dist/src/researchAgentService/remove.js
4248
+ // ../../b4m-core/packages/services/dist/src/researchAgentService/get.js
4553
4249
  import { z as z110 } from "zod";
4554
- var researchAgentRemoveSchema = z110.object({
4250
+ var researchAgentGetSchema = z110.object({
4555
4251
  id: z110.string()
4556
4252
  });
4557
4253
 
4558
- // ../../b4m-core/packages/services/dist/src/researchAgentService/get.js
4559
- import { z as z111 } from "zod";
4560
- var researchAgentGetSchema = z111.object({
4561
- id: z111.string()
4562
- });
4563
-
4564
4254
  // ../../b4m-core/packages/services/dist/src/researchAgentService/listFiles.js
4565
- import { z as z112 } from "zod";
4566
- var researchAgentListFilesSchema = z112.object({
4255
+ import { z as z111 } from "zod";
4256
+ var researchAgentListFilesSchema = z111.object({
4567
4257
  /**
4568
4258
  * The ID of the research agent
4569
4259
  */
4570
- id: z112.string()
4260
+ id: z111.string()
4571
4261
  });
4572
4262
 
4573
4263
  // ../../b4m-core/packages/services/dist/src/researchTaskService/process.js
4574
- import { z as z113 } from "zod";
4264
+ import { z as z112 } from "zod";
4575
4265
 
4576
4266
  // ../../b4m-core/packages/services/dist/src/lib/turndown.js
4577
4267
  import turndown from "turndown";
@@ -4962,316 +4652,316 @@ var deepResearchTool = {
4962
4652
  };
4963
4653
 
4964
4654
  // ../../b4m-core/packages/services/dist/src/researchTaskService/process.js
4965
- var ResearchTaskProcessSchema = z113.object({
4966
- id: z113.string()
4655
+ var ResearchTaskProcessSchema = z112.object({
4656
+ id: z112.string()
4967
4657
  });
4968
4658
 
4969
4659
  // ../../b4m-core/packages/services/dist/src/researchTaskService/create.js
4970
- import { z as z114 } from "zod";
4971
- var researchTaskCreateSchema = z114.object({
4972
- researchAgentId: z114.string(),
4973
- title: z114.string().max(100),
4974
- description: z114.string().max(500),
4975
- prompt: z114.string().max(500).optional(),
4976
- type: z114.nativeEnum(ResearchTaskType),
4977
- executionType: z114.nativeEnum(ResearchTaskExecutionType).default(ResearchTaskExecutionType.ON_DEMAND),
4978
- fileTagId: z114.string().optional(),
4979
- autoGeneratedTag: z114.object({
4980
- name: z114.string(),
4981
- icon: z114.string(),
4982
- color: z114.string()
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()
4983
4673
  }).optional()
4984
4674
  });
4985
4675
  var researchTaskScrapeCreateSchema = researchTaskCreateSchema.extend({
4986
- urls: z114.array(z114.string().url()).min(1),
4987
- canDiscoverLinks: z114.boolean()
4676
+ urls: z113.array(z113.string().url()).min(1),
4677
+ canDiscoverLinks: z113.boolean()
4988
4678
  });
4989
4679
  var researchTaskPeriodicCreateSchema = researchTaskCreateSchema.extend({
4990
- executionPeriodicStartAt: z114.coerce.date(),
4991
- executionPeriodicEndAt: z114.coerce.date(),
4992
- executionPeriodicFrequency: z114.nativeEnum(ResearchTaskPeriodicFrequencyType)
4680
+ executionPeriodicStartAt: z113.coerce.date(),
4681
+ executionPeriodicEndAt: z113.coerce.date(),
4682
+ executionPeriodicFrequency: z113.nativeEnum(ResearchTaskPeriodicFrequencyType)
4993
4683
  });
4994
4684
  var researchTaskScheduledCreateSchema = researchTaskCreateSchema.extend({
4995
- executionScheduledAt: z114.coerce.date()
4685
+ executionScheduledAt: z113.coerce.date()
4996
4686
  });
4997
4687
  var researchTaskDeepResearchCreateSchema = researchTaskCreateSchema.extend({
4998
- maxDepth: z114.number().min(1).max(10).optional()
4688
+ maxDepth: z113.number().min(1).max(10).optional()
4999
4689
  });
5000
4690
 
5001
4691
  // ../../b4m-core/packages/services/dist/src/researchTaskService/search.js
5002
- import { z as z115 } from "zod";
5003
- var searchResearchTasksSchema = z115.object({
5004
- search: z115.string().optional(),
4692
+ import { z as z114 } from "zod";
4693
+ var searchResearchTasksSchema = z114.object({
4694
+ search: z114.string().optional(),
5005
4695
  // ADD FILTERS SCHEMA HERE
5006
4696
  // filters: z
5007
4697
  // .object({
5008
4698
  // userId: z.string().optional(),
5009
4699
  // })
5010
4700
  // .optional(),
5011
- pagination: z115.object({
5012
- page: z115.coerce.number().optional(),
5013
- limit: z115.coerce.number().optional()
4701
+ pagination: z114.object({
4702
+ page: z114.coerce.number().optional(),
4703
+ limit: z114.coerce.number().optional()
5014
4704
  }).optional(),
5015
- orderBy: z115.object({
5016
- by: z115.enum(["createdAt", "updatedAt"]).optional(),
5017
- direction: z115.enum(["asc", "desc"]).optional()
4705
+ orderBy: z114.object({
4706
+ by: z114.enum(["createdAt", "updatedAt"]).optional(),
4707
+ direction: z114.enum(["asc", "desc"]).optional()
5018
4708
  }).optional()
5019
4709
  });
5020
4710
 
5021
4711
  // ../../b4m-core/packages/services/dist/src/researchTaskService/get.js
5022
- import { z as z116 } from "zod";
5023
- var getResearchTaskSchema = z116.object({
5024
- id: z116.string().min(1)
4712
+ import { z as z115 } from "zod";
4713
+ var getResearchTaskSchema = z115.object({
4714
+ id: z115.string().min(1)
5025
4715
  });
5026
4716
 
5027
4717
  // ../../b4m-core/packages/services/dist/src/researchTaskService/update.js
5028
- import { z as z117 } from "zod";
5029
- var updateResearchTaskSchema = z117.object({
5030
- id: z117.string(),
5031
- title: z117.string(),
5032
- description: z117.string(),
5033
- type: z117.nativeEnum(ResearchTaskType)
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)
5034
4724
  });
5035
4725
  var researchTaskScrapeUpdateSchema = updateResearchTaskSchema.extend({
5036
- urls: z117.array(z117.string().url()).min(1),
5037
- canDiscoverLinks: z117.boolean()
4726
+ urls: z116.array(z116.string().url()).min(1),
4727
+ canDiscoverLinks: z116.boolean()
5038
4728
  });
5039
4729
 
5040
4730
  // ../../b4m-core/packages/services/dist/src/researchTaskService/listByAgentId.js
5041
- import { z as z118 } from "zod";
5042
- var listByAgentIdSchema = z118.object({
5043
- researchAgentId: z118.string()
4731
+ import { z as z117 } from "zod";
4732
+ var listByAgentIdSchema = z117.object({
4733
+ researchAgentId: z117.string()
5044
4734
  });
5045
4735
 
5046
4736
  // ../../b4m-core/packages/services/dist/src/researchTaskService/remove.js
5047
- import { z as z119 } from "zod";
5048
- var researchTaskRemoveSchema = z119.object({
5049
- id: z119.string().min(1)
4737
+ import { z as z118 } from "zod";
4738
+ var researchTaskRemoveSchema = z118.object({
4739
+ id: z118.string().min(1)
5050
4740
  });
5051
4741
 
5052
4742
  // ../../b4m-core/packages/services/dist/src/researchTaskService/retry.js
5053
- import { z as z120 } from "zod";
5054
- var researchTaskRetrySchema = z120.object({
5055
- id: z120.string(),
5056
- userId: z120.string()
4743
+ import { z as z119 } from "zod";
4744
+ var researchTaskRetrySchema = z119.object({
4745
+ id: z119.string(),
4746
+ userId: z119.string()
5057
4747
  });
5058
4748
 
5059
4749
  // ../../b4m-core/packages/services/dist/src/researchTaskService/processDiscoveredLinks.js
5060
4750
  import axios4 from "axios";
5061
- import { z as z121 } from "zod";
4751
+ import { z as z120 } from "zod";
5062
4752
  import plimit from "p-limit";
5063
4753
  import pLimit2 from "p-limit";
5064
- var researchTaskProcessDiscoveredLinksSchema = z121.object({
5065
- id: z121.string()
4754
+ var researchTaskProcessDiscoveredLinksSchema = z120.object({
4755
+ id: z120.string()
5066
4756
  });
5067
4757
 
5068
4758
  // ../../b4m-core/packages/services/dist/src/researchTaskService/downloadRelevantLinks.js
5069
- import { z as z122 } from "zod";
4759
+ import { z as z121 } from "zod";
5070
4760
  import plimit2 from "p-limit";
5071
4761
  import axios5 from "axios";
5072
4762
  import { fileTypeFromBuffer } from "file-type";
5073
- var researchTaskDownloadRelevantLinksSchema = z122.object({
5074
- id: z122.string()
4763
+ var researchTaskDownloadRelevantLinksSchema = z121.object({
4764
+ id: z121.string()
5075
4765
  });
5076
4766
 
5077
4767
  // ../../b4m-core/packages/services/dist/src/researchData/remove.js
5078
- import { z as z123 } from "zod";
5079
- var researchDataRemoveSchema = z123.object({
5080
- id: z123.string(),
5081
- researchAgentId: z123.string()
4768
+ import { z as z122 } from "zod";
4769
+ var researchDataRemoveSchema = z122.object({
4770
+ id: z122.string(),
4771
+ researchAgentId: z122.string()
5082
4772
  });
5083
4773
 
5084
4774
  // ../../b4m-core/packages/services/dist/src/taskSchedulerService/create.js
5085
- import { z as z124 } from "zod";
5086
- var researchTaskPayload = z124.object({
5087
- id: z124.string(),
5088
- userId: z124.string()
4775
+ import { z as z123 } from "zod";
4776
+ var researchTaskPayload = z123.object({
4777
+ id: z123.string(),
4778
+ userId: z123.string()
5089
4779
  });
5090
- var customTaskPayload = z124.object({
5091
- test: z124.string()
4780
+ var customTaskPayload = z123.object({
4781
+ test: z123.string()
5092
4782
  });
5093
- var taskSchedulerCreate = z124.discriminatedUnion("handler", [
5094
- z124.object({
5095
- handler: z124.literal(TaskScheduleHandler.RESEARCH_TASK_PROCESS),
4783
+ var taskSchedulerCreate = z123.discriminatedUnion("handler", [
4784
+ z123.object({
4785
+ handler: z123.literal(TaskScheduleHandler.RESEARCH_TASK_PROCESS),
5096
4786
  payload: researchTaskPayload,
5097
- processDate: z124.date()
4787
+ processDate: z123.date()
5098
4788
  }),
5099
- z124.object({
5100
- handler: z124.literal(TaskScheduleHandler.CUSTOM_TASK_PROCESS),
4789
+ z123.object({
4790
+ handler: z123.literal(TaskScheduleHandler.CUSTOM_TASK_PROCESS),
5101
4791
  payload: customTaskPayload,
5102
- processDate: z124.date()
4792
+ processDate: z123.date()
5103
4793
  })
5104
4794
  ]);
5105
4795
 
5106
4796
  // ../../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
5107
4806
  import { z as z125 } from "zod";
5108
- var tagCreateFileTagSchema = z125.object({
4807
+ var tagCreateSchema = z125.object({
5109
4808
  name: z125.string(),
5110
4809
  icon: z125.string().optional(),
4810
+ description: z125.string().optional(),
5111
4811
  color: z125.string().optional(),
5112
- description: z125.string().optional()
4812
+ type: z125.nativeEnum(TagType)
5113
4813
  });
5114
4814
 
5115
- // ../../b4m-core/packages/services/dist/src/tagService/create.js
4815
+ // ../../b4m-core/packages/services/dist/src/tagService/update.js
5116
4816
  import { z as z126 } from "zod";
5117
- var tagCreateSchema = z126.object({
5118
- name: z126.string(),
4817
+ var tagUpdateSchema = z126.object({
4818
+ id: z126.string(),
4819
+ name: z126.string().optional(),
5119
4820
  icon: z126.string().optional(),
5120
4821
  description: z126.string().optional(),
5121
- color: z126.string().optional(),
5122
- type: z126.nativeEnum(TagType)
5123
- });
5124
-
5125
- // ../../b4m-core/packages/services/dist/src/tagService/update.js
5126
- import { z as z127 } from "zod";
5127
- var tagUpdateSchema = z127.object({
5128
- id: z127.string(),
5129
- name: z127.string().optional(),
5130
- icon: z127.string().optional(),
5131
- description: z127.string().optional(),
5132
- color: z127.string().optional()
4822
+ color: z126.string().optional()
5133
4823
  });
5134
4824
 
5135
4825
  // ../../b4m-core/packages/services/dist/src/tagService/remove.js
5136
- import { z as z128 } from "zod";
5137
- var tagRemoveSchema = z128.object({
5138
- id: z128.string()
4826
+ import { z as z127 } from "zod";
4827
+ var tagRemoveSchema = z127.object({
4828
+ id: z127.string()
5139
4829
  });
5140
4830
 
5141
4831
  // ../../b4m-core/packages/services/dist/src/artifactService/create.js
5142
- import { z as z129 } from "zod";
5143
- var createArtifactSchema = z129.object({
5144
- id: z129.string().optional(),
4832
+ import { z as z128 } from "zod";
4833
+ var createArtifactSchema = z128.object({
4834
+ id: z128.string().optional(),
5145
4835
  // Allow custom ID for AI-generated artifacts
5146
- type: z129.enum(["mermaid", "recharts", "python", "react", "html", "svg", "code", "quest", "file", "questmaster"]),
5147
- title: z129.string().min(1).max(255),
5148
- description: z129.string().max(1e3).optional(),
5149
- content: z129.string().min(1),
5150
- projectId: z129.string().optional(),
5151
- organizationId: z129.string().optional(),
5152
- visibility: z129.enum(["private", "project", "organization", "public"]).default("private"),
5153
- tags: z129.array(z129.string().max(50)).max(20).default([]),
5154
- versionTag: z129.string().max(100).optional(),
5155
- sourceQuestId: z129.string().optional(),
5156
- sessionId: z129.string().optional(),
5157
- parentArtifactId: z129.string().optional(),
5158
- permissions: z129.object({
5159
- canRead: z129.array(z129.string()).default([]),
5160
- canWrite: z129.array(z129.string()).default([]),
5161
- canDelete: z129.array(z129.string()).default([]),
5162
- isPublic: z129.boolean().default(false),
5163
- inheritFromProject: z129.boolean().default(true)
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)
5164
4854
  }).optional(),
5165
- metadata: z129.record(z129.unknown()).default({})
4855
+ metadata: z128.record(z128.unknown()).default({})
5166
4856
  });
5167
4857
 
5168
4858
  // ../../b4m-core/packages/services/dist/src/artifactService/get.js
5169
- import { z as z130 } from "zod";
5170
- var getArtifactSchema = z130.object({
5171
- id: z130.string(),
5172
- includeContent: z130.boolean().default(false),
5173
- includeVersions: z130.boolean().default(false),
5174
- version: z130.number().optional()
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()
5175
4865
  });
5176
4866
 
5177
4867
  // ../../b4m-core/packages/services/dist/src/artifactService/list.js
5178
- import { z as z131 } from "zod";
5179
- var listArtifactsSchema = z131.object({
5180
- type: z131.string().optional(),
5181
- status: z131.enum(["draft", "review", "published", "archived"]).optional(),
5182
- visibility: z131.enum(["private", "project", "organization", "public"]).optional(),
5183
- projectId: z131.string().optional(),
5184
- sessionId: z131.string().optional(),
5185
- tags: z131.array(z131.string()).optional(),
5186
- search: z131.string().optional(),
5187
- limit: z131.number().min(1).max(100).default(20),
5188
- offset: z131.number().min(0).default(0),
5189
- sortBy: z131.enum(["createdAt", "updatedAt", "title", "type"]).default("updatedAt"),
5190
- sortOrder: z131.enum(["asc", "desc"]).default("desc"),
5191
- includeDeleted: z131.boolean().default(false)
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)
5192
4882
  });
5193
4883
 
5194
4884
  // ../../b4m-core/packages/services/dist/src/artifactService/update.js
5195
- import { z as z132 } from "zod";
5196
- var updateArtifactSchema = z132.object({
5197
- id: z132.string(),
5198
- title: z132.string().min(1).max(255).optional(),
5199
- description: z132.string().max(1e3).optional(),
5200
- content: z132.string().optional(),
5201
- visibility: z132.enum(["private", "project", "organization", "public"]).optional(),
5202
- status: z132.enum(["draft", "review", "published", "archived"]).optional(),
5203
- tags: z132.array(z132.string().max(50)).max(20).optional(),
5204
- versionTag: z132.string().max(100).optional(),
5205
- permissions: z132.object({
5206
- canRead: z132.array(z132.string()).optional(),
5207
- canWrite: z132.array(z132.string()).optional(),
5208
- canDelete: z132.array(z132.string()).optional(),
5209
- isPublic: z132.boolean().optional(),
5210
- inheritFromProject: z132.boolean().optional()
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()
5211
4901
  }).optional(),
5212
- metadata: z132.record(z132.unknown()).optional(),
5213
- changes: z132.array(z132.string()).optional(),
5214
- changeDescription: z132.string().max(1e3).optional(),
5215
- createNewVersion: z132.boolean().optional(),
5216
- versionMessage: z132.string().max(500).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()
5217
4907
  });
5218
4908
 
5219
4909
  // ../../b4m-core/packages/services/dist/src/artifactService/delete.js
5220
- import { z as z133 } from "zod";
5221
- var deleteArtifactSchema = z133.object({
5222
- id: z133.string(),
5223
- hardDelete: z133.boolean().default(false)
4910
+ import { z as z132 } from "zod";
4911
+ var deleteArtifactSchema = z132.object({
4912
+ id: z132.string(),
4913
+ hardDelete: z132.boolean().default(false)
5224
4914
  // For future implementation
5225
4915
  });
5226
4916
 
5227
4917
  // ../../b4m-core/packages/services/dist/src/questMasterService/create.js
5228
- import { z as z134 } from "zod";
5229
- var questSchema = z134.object({
5230
- id: z134.string(),
5231
- title: z134.string().min(1).max(255),
5232
- description: z134.string().max(1e3),
5233
- status: z134.enum(["not_started", "in_progress", "completed", "blocked"]).default("not_started"),
5234
- order: z134.number().min(0),
5235
- dependencies: z134.array(z134.string()).default([]),
5236
- estimatedTime: z134.string().optional()
5237
- });
5238
- var questResourceSchema = z134.object({
5239
- title: z134.string().min(1).max(255),
5240
- url: z134.string().url(),
5241
- type: z134.enum(["documentation", "tutorial", "reference", "example"])
5242
- });
5243
- var createQuestMasterSchema = z134.object({
5244
- title: z134.string().min(1).max(255),
5245
- description: z134.string().max(1e3).optional(),
5246
- goal: z134.string().min(1).max(1e3),
5247
- complexity: z134.enum(["beginner", "intermediate", "advanced", "expert"]),
5248
- estimatedTotalTime: z134.string().optional(),
5249
- prerequisites: z134.array(z134.string().max(200)).default([]),
5250
- quests: z134.array(questSchema).min(1),
5251
- resources: z134.array(questResourceSchema).default([]),
5252
- projectId: z134.string().optional(),
5253
- organizationId: z134.string().optional(),
5254
- visibility: z134.enum(["private", "project", "organization", "public"]).default("private"),
5255
- tags: z134.array(z134.string().max(50)).max(20).default([]),
5256
- permissions: z134.object({
5257
- canRead: z134.array(z134.string()).default([]),
5258
- canWrite: z134.array(z134.string()).default([]),
5259
- canDelete: z134.array(z134.string()).default([]),
5260
- isPublic: z134.boolean().default(false),
5261
- inheritFromProject: z134.boolean().default(true)
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)
5262
4952
  }).optional(),
5263
- sourceQuestId: z134.string().optional(),
5264
- sessionId: z134.string().optional(),
5265
- metadata: z134.record(z134.unknown()).default({})
4953
+ sourceQuestId: z133.string().optional(),
4954
+ sessionId: z133.string().optional(),
4955
+ metadata: z133.record(z133.unknown()).default({})
5266
4956
  });
5267
4957
 
5268
4958
  // ../../b4m-core/packages/services/dist/src/questMasterService/updateQuestStatus.js
5269
- import { z as z135 } from "zod";
5270
- var updateQuestStatusSchema = z135.object({
5271
- artifactId: z135.string(),
5272
- questId: z135.string(),
5273
- status: z135.enum(["not_started", "in_progress", "completed", "blocked"]),
5274
- completionNote: z135.string().max(500).optional()
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()
5275
4965
  });
5276
4966
 
5277
4967
  // ../../b4m-core/packages/services/dist/src/dataLakeService/opensearchClient.js
@@ -5291,63 +4981,63 @@ import { v4 as uuidv44 } from "uuid";
5291
4981
  import { randomUUID as randomUUID5 } from "crypto";
5292
4982
 
5293
4983
  // ../../b4m-core/packages/services/dist/src/emailIngestionService/types.js
5294
- import { z as z136 } from "zod";
5295
- var processIngestedEmailOptionsSchema = z136.object({
5296
- platformDomain: z136.string().optional(),
5297
- isNewsletter: z136.boolean().optional()
4984
+ import { z as z135 } from "zod";
4985
+ var processIngestedEmailOptionsSchema = z135.object({
4986
+ platformDomain: z135.string().optional(),
4987
+ isNewsletter: z135.boolean().optional()
5298
4988
  }).optional();
5299
- var emailAttachmentSchema = z136.object({
5300
- filename: z136.string().optional(),
5301
- contentType: z136.string().optional(),
5302
- contentDisposition: z136.string().optional(),
5303
- size: z136.number().min(0),
5304
- content: z136.instanceof(Buffer),
5305
- related: z136.boolean().optional()
5306
- });
5307
- var parsedEmailObjectSchema = z136.object({
5308
- messageId: z136.string().optional(),
5309
- inReplyTo: z136.string().optional(),
5310
- references: z136.union([z136.string(), z136.array(z136.string())]).optional(),
5311
- from: z136.any().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(),
5312
5002
  // Complex email address object
5313
- to: z136.any().optional(),
5314
- cc: z136.any().optional(),
5315
- bcc: z136.any().optional(),
5316
- subject: z136.string().optional(),
5317
- date: z136.date().optional(),
5318
- text: z136.string().optional(),
5319
- html: z136.string().optional(),
5320
- attachments: z136.array(emailAttachmentSchema).optional()
5321
- });
5322
- var processIngestedEmailSchema = z136.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({
5323
5013
  parsedEmail: parsedEmailObjectSchema,
5324
- rawEmailS3Key: z136.string().min(1, "rawEmailS3Key cannot be empty"),
5014
+ rawEmailS3Key: z135.string().min(1, "rawEmailS3Key cannot be empty"),
5325
5015
  options: processIngestedEmailOptionsSchema
5326
5016
  });
5327
5017
 
5328
5018
  // ../../b4m-core/packages/services/dist/src/emailAnalysisService/types.js
5329
- import { z as z137 } from "zod";
5330
- var llmAnalysisResponseSchema = z137.object({
5331
- summary: z137.string().min(1, "Summary cannot be empty"),
5332
- entities: z137.object({
5333
- companies: z137.array(z137.string()).default([]),
5334
- people: z137.array(z137.string()).default([]),
5335
- products: z137.array(z137.string()).default([]),
5336
- technologies: z137.array(z137.string()).default([])
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([])
5337
5027
  }),
5338
- sentiment: z137.enum(["positive", "neutral", "negative", "urgent"]),
5339
- actionItems: z137.array(z137.object({
5340
- description: z137.string(),
5341
- deadline: z137.string().optional()
5028
+ sentiment: z136.enum(["positive", "neutral", "negative", "urgent"]),
5029
+ actionItems: z136.array(z136.object({
5030
+ description: z136.string(),
5031
+ deadline: z136.string().optional()
5342
5032
  // ISO date string from LLM
5343
5033
  })).default([]),
5344
- privacyRecommendation: z137.enum(["public", "team", "private"]),
5345
- embargoDetected: z137.boolean().default(false),
5346
- suggestedTags: z137.array(z137.string()).default([])
5034
+ privacyRecommendation: z136.enum(["public", "team", "private"]),
5035
+ embargoDetected: z136.boolean().default(false),
5036
+ suggestedTags: z136.array(z136.string()).default([])
5347
5037
  });
5348
5038
 
5349
5039
  // ../../b4m-core/packages/services/dist/src/llm/ChatCompletion.js
5350
- import { z as z139 } from "zod";
5040
+ import { z as z138 } from "zod";
5351
5041
 
5352
5042
  // ../../b4m-core/packages/services/dist/src/llm/ChatCompletionInvoke.js
5353
5043
  import { fromZodError } from "zod-validation-error";
@@ -5461,8 +5151,8 @@ async function processAndStoreImages(images, context) {
5461
5151
  const buffer = await downloadImage(image);
5462
5152
  const fileType = await fileTypeFromBuffer2(buffer);
5463
5153
  const filename = `${uuidv45()}.${fileType?.ext}`;
5464
- const path16 = await context.imageGenerateStorage.upload(buffer, filename, {});
5465
- return path16;
5154
+ const path15 = await context.imageGenerateStorage.upload(buffer, filename, {});
5155
+ return path15;
5466
5156
  }));
5467
5157
  }
5468
5158
  async function updateQuestAndReturnMarkdown(storedImageUrls, context) {
@@ -6435,17 +6125,17 @@ var rechartsTool = {
6435
6125
  };
6436
6126
 
6437
6127
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/editFile/index.js
6438
- import { z as z138 } from "zod";
6128
+ import { z as z137 } from "zod";
6439
6129
  import { diffLines as diffLines2 } from "diff";
6440
- var editFileSchema = z138.object({
6441
- fileId: z138.string().describe("The ID of the file to edit"),
6442
- instruction: z138.string().describe("Natural language instruction describing the changes to make"),
6443
- selection: z138.object({
6444
- start: z138.number().describe("Starting character position of the selection"),
6445
- end: z138.number().describe("Ending character position of the selection")
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")
6446
6136
  }).optional().describe("Optional selection range to edit within the file"),
6447
- preserveFormatting: z138.boolean().optional().default(true).describe("Whether to preserve the original formatting style"),
6448
- returnDiff: z138.boolean().optional().default(true).describe("Whether to return a diff of the changes")
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")
6449
6139
  });
6450
6140
  function generateSimpleDiff(original, modified) {
6451
6141
  const differences = diffLines2(original, modified);
@@ -6674,8 +6364,8 @@ async function processAndStoreImage(imageUrl, context) {
6674
6364
  const buffer = await downloadImage2(imageUrl);
6675
6365
  const fileType = await fileTypeFromBuffer3(buffer);
6676
6366
  const filename = `${uuidv46()}.${fileType?.ext}`;
6677
- const path16 = await context.imageGenerateStorage.upload(buffer, filename, {});
6678
- return path16;
6367
+ const path15 = await context.imageGenerateStorage.upload(buffer, filename, {});
6368
+ return path15;
6679
6369
  }
6680
6370
  async function updateQuestAndReturnMarkdown2(storedImagePath, context) {
6681
6371
  await context.onFinish?.("edit_image", storedImagePath);
@@ -8204,8 +7894,8 @@ var getHeliocentricCoords = (planet, T) => {
8204
7894
  const sinNode = Math.sin(longNode);
8205
7895
  const x = r * (cosNode * cosOmega - sinNode * sinOmega * cosI);
8206
7896
  const y = r * (sinNode * cosOmega + cosNode * sinOmega * cosI);
8207
- const z145 = r * sinOmega * sinI;
8208
- return { x, y, z: z145, r };
7897
+ const z144 = r * sinOmega * sinI;
7898
+ return { x, y, z: z144, r };
8209
7899
  };
8210
7900
  var getGeocentricEcliptic = (planet, earth) => {
8211
7901
  const dx = planet.x - earth.x;
@@ -8512,15 +8202,15 @@ var planetVisibilityTool = {
8512
8202
  };
8513
8203
 
8514
8204
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/fileRead/index.js
8515
- import { promises as fs8 } from "fs";
8205
+ import { promises as fs7 } from "fs";
8516
8206
  import { existsSync as existsSync4, statSync as statSync4 } from "fs";
8517
- import path7 from "path";
8207
+ import path6 from "path";
8518
8208
  var MAX_FILE_SIZE2 = 10 * 1024 * 1024;
8519
8209
  async function readFileContent(params) {
8520
8210
  const { path: filePath, encoding = "utf-8", maxLines } = params;
8521
- const normalizedPath = path7.normalize(filePath);
8522
- const resolvedPath = path7.resolve(process.cwd(), normalizedPath);
8523
- const cwd = path7.resolve(process.cwd());
8211
+ const normalizedPath = path6.normalize(filePath);
8212
+ const resolvedPath = path6.resolve(process.cwd(), normalizedPath);
8213
+ const cwd = path6.resolve(process.cwd());
8524
8214
  if (!resolvedPath.startsWith(cwd)) {
8525
8215
  throw new Error(`Access denied: Cannot read files outside of current working directory`);
8526
8216
  }
@@ -8538,7 +8228,7 @@ async function readFileContent(params) {
8538
8228
  if (isBinary && encoding === "utf-8") {
8539
8229
  throw new Error(`File appears to be binary. Use encoding 'base64' to read binary files, or specify a different encoding.`);
8540
8230
  }
8541
- const content = await fs8.readFile(resolvedPath, encoding);
8231
+ const content = await fs7.readFile(resolvedPath, encoding);
8542
8232
  if (maxLines && typeof content === "string") {
8543
8233
  const lines = content.split("\n");
8544
8234
  if (lines.length > maxLines) {
@@ -8553,7 +8243,7 @@ ${content}`;
8553
8243
  }
8554
8244
  async function checkIfBinary(filePath) {
8555
8245
  const buffer = Buffer.alloc(8192);
8556
- const fd = await fs8.open(filePath, "r");
8246
+ const fd = await fs7.open(filePath, "r");
8557
8247
  try {
8558
8248
  const { bytesRead } = await fd.read(buffer, 0, 8192, 0);
8559
8249
  const chunk = buffer.slice(0, bytesRead);
@@ -8570,7 +8260,7 @@ var fileReadTool = {
8570
8260
  context.logger.info("\u{1F4C4} FileRead: Reading file", { path: params.path });
8571
8261
  try {
8572
8262
  const content = await readFileContent(params);
8573
- const stats = statSync4(path7.resolve(process.cwd(), path7.normalize(params.path)));
8263
+ const stats = statSync4(path6.resolve(process.cwd(), path6.normalize(params.path)));
8574
8264
  context.logger.info("\u2705 FileRead: Success", {
8575
8265
  path: params.path,
8576
8266
  size: stats.size,
@@ -8609,25 +8299,25 @@ var fileReadTool = {
8609
8299
  };
8610
8300
 
8611
8301
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/createFile/index.js
8612
- import { promises as fs9 } from "fs";
8302
+ import { promises as fs8 } from "fs";
8613
8303
  import { existsSync as existsSync5 } from "fs";
8614
- import path8 from "path";
8304
+ import path7 from "path";
8615
8305
  async function createFile(params) {
8616
8306
  const { path: filePath, content, createDirectories = true } = params;
8617
- const normalizedPath = path8.normalize(filePath);
8618
- const resolvedPath = path8.resolve(process.cwd(), normalizedPath);
8619
- const cwd = path8.resolve(process.cwd());
8307
+ const normalizedPath = path7.normalize(filePath);
8308
+ const resolvedPath = path7.resolve(process.cwd(), normalizedPath);
8309
+ const cwd = path7.resolve(process.cwd());
8620
8310
  if (!resolvedPath.startsWith(cwd)) {
8621
8311
  throw new Error(`Access denied: Cannot create files outside of current working directory`);
8622
8312
  }
8623
8313
  const fileExists = existsSync5(resolvedPath);
8624
8314
  const action = fileExists ? "overwritten" : "created";
8625
8315
  if (createDirectories) {
8626
- const dir = path8.dirname(resolvedPath);
8627
- await fs9.mkdir(dir, { recursive: true });
8316
+ const dir = path7.dirname(resolvedPath);
8317
+ await fs8.mkdir(dir, { recursive: true });
8628
8318
  }
8629
- await fs9.writeFile(resolvedPath, content, "utf-8");
8630
- const stats = await fs9.stat(resolvedPath);
8319
+ await fs8.writeFile(resolvedPath, content, "utf-8");
8320
+ const stats = await fs8.stat(resolvedPath);
8631
8321
  const lines = content.split("\n").length;
8632
8322
  return `File ${action} successfully: ${filePath}
8633
8323
  Size: ${stats.size} bytes
@@ -8638,7 +8328,7 @@ var createFileTool = {
8638
8328
  implementation: (context) => ({
8639
8329
  toolFn: async (value) => {
8640
8330
  const params = value;
8641
- const fileExists = existsSync5(path8.resolve(process.cwd(), path8.normalize(params.path)));
8331
+ const fileExists = existsSync5(path7.resolve(process.cwd(), path7.normalize(params.path)));
8642
8332
  context.logger.info(`\u{1F4DD} CreateFile: ${fileExists ? "Overwriting" : "Creating"} file`, {
8643
8333
  path: params.path,
8644
8334
  size: params.content.length
@@ -8680,7 +8370,7 @@ var createFileTool = {
8680
8370
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/globFiles/index.js
8681
8371
  import { readdir } from "fs/promises";
8682
8372
  import { statSync as statSync5 } from "fs";
8683
- import path9 from "path";
8373
+ import path8 from "path";
8684
8374
  function matchGlob(filePath, pattern) {
8685
8375
  let regexPattern = pattern.replace(/\./g, "\\.").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (_, options) => `(${options.split(",").join("|")})`).replace(/\[([^\]]+)\]/g, "[$1]");
8686
8376
  regexPattern = regexPattern.replace(/\{\{GLOBSTAR\}\}\//g, "(.*/)?").replace(/\/\{\{GLOBSTAR\}\}/g, "(/.*)?").replace(/\{\{GLOBSTAR\}\}/g, ".*");
@@ -8698,8 +8388,8 @@ async function walkDir(dir, pattern, includeHidden, maxResults, basePath = "") {
8698
8388
  if (!includeHidden && entry.name.startsWith(".")) {
8699
8389
  continue;
8700
8390
  }
8701
- const relativePath = basePath ? path9.join(basePath, entry.name) : entry.name;
8702
- const fullPath = path9.join(dir, entry.name);
8391
+ const relativePath = basePath ? path8.join(basePath, entry.name) : entry.name;
8392
+ const fullPath = path8.join(dir, entry.name);
8703
8393
  if (matchGlob(relativePath, pattern)) {
8704
8394
  matches.push(relativePath);
8705
8395
  }
@@ -8715,7 +8405,7 @@ async function walkDir(dir, pattern, includeHidden, maxResults, basePath = "") {
8715
8405
  async function listFiles(params) {
8716
8406
  const { pattern, cwd: relativeCwd, includeHidden = false, maxResults = 1e3 } = params;
8717
8407
  const baseCwd = process.cwd();
8718
- const targetCwd = relativeCwd ? path9.resolve(baseCwd, path9.normalize(relativeCwd)) : baseCwd;
8408
+ const targetCwd = relativeCwd ? path8.resolve(baseCwd, path8.normalize(relativeCwd)) : baseCwd;
8719
8409
  if (!targetCwd.startsWith(baseCwd)) {
8720
8410
  throw new Error(`Access denied: Cannot list files outside of current working directory`);
8721
8411
  }
@@ -8726,7 +8416,7 @@ async function listFiles(params) {
8726
8416
  const filesInfo = [];
8727
8417
  for (const match of matches) {
8728
8418
  try {
8729
- const fullPath = path9.join(targetCwd, match);
8419
+ const fullPath = path8.join(targetCwd, match);
8730
8420
  const stats = statSync5(fullPath);
8731
8421
  filesInfo.push({
8732
8422
  path: match,
@@ -8809,7 +8499,7 @@ var globFilesTool = {
8809
8499
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/grepSearch/index.js
8810
8500
  import { readdir as readdir2 } from "fs/promises";
8811
8501
  import { readFileSync as readFileSync3, statSync as statSync6 } from "fs";
8812
- import path10 from "path";
8502
+ import path9 from "path";
8813
8503
  var MAX_FILE_SIZE3 = 10 * 1024 * 1024;
8814
8504
  function matchGlob2(filePath, pattern) {
8815
8505
  const regexPattern = pattern.replace(/\./g, "\\.").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/\{\{GLOBSTAR\}\}/g, ".*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (_, options) => `(${options.split(",").join("|")})`).replace(/\[([^\]]+)\]/g, "[$1]");
@@ -8827,8 +8517,8 @@ async function walkDir2(dir, pattern, maxResults, basePath = "") {
8827
8517
  if (entry.name.startsWith(".")) {
8828
8518
  continue;
8829
8519
  }
8830
- const relativePath = basePath ? path10.join(basePath, entry.name) : entry.name;
8831
- const fullPath = path10.join(dir, entry.name);
8520
+ const relativePath = basePath ? path9.join(basePath, entry.name) : entry.name;
8521
+ const fullPath = path9.join(dir, entry.name);
8832
8522
  if (matchGlob2(relativePath, pattern)) {
8833
8523
  matches.push(relativePath);
8834
8524
  }
@@ -8844,7 +8534,7 @@ async function walkDir2(dir, pattern, maxResults, basePath = "") {
8844
8534
  async function searchFiles2(params) {
8845
8535
  const { pattern, filePattern = "**/*", cwd: relativeCwd, caseSensitive = false, maxResults = 100, contextLines = 0 } = params;
8846
8536
  const baseCwd = process.cwd();
8847
- const targetCwd = relativeCwd ? path10.resolve(baseCwd, path10.normalize(relativeCwd)) : baseCwd;
8537
+ const targetCwd = relativeCwd ? path9.resolve(baseCwd, path9.normalize(relativeCwd)) : baseCwd;
8848
8538
  if (!targetCwd.startsWith(baseCwd)) {
8849
8539
  throw new Error(`Access denied: Cannot search files outside of current working directory`);
8850
8540
  }
@@ -8858,7 +8548,7 @@ async function searchFiles2(params) {
8858
8548
  const filesToSearch = await walkDir2(targetCwd, filePattern, 1e4);
8859
8549
  const filteredFiles = [];
8860
8550
  for (const match of filesToSearch) {
8861
- const fullPath = path10.join(targetCwd, match);
8551
+ const fullPath = path9.join(targetCwd, match);
8862
8552
  try {
8863
8553
  const stats = statSync6(fullPath);
8864
8554
  if (stats.isDirectory() || stats.size > MAX_FILE_SIZE3) {
@@ -8882,7 +8572,7 @@ async function searchFiles2(params) {
8882
8572
  break;
8883
8573
  }
8884
8574
  filesSearched++;
8885
- const fullPath = path10.join(targetCwd, file);
8575
+ const fullPath = path9.join(targetCwd, file);
8886
8576
  try {
8887
8577
  const content = readFileSync3(fullPath, "utf-8");
8888
8578
  const lines = content.split("\n");
@@ -9017,14 +8707,14 @@ var grepSearchTool = {
9017
8707
  };
9018
8708
 
9019
8709
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/deleteFile/index.js
9020
- import { promises as fs10 } from "fs";
8710
+ import { promises as fs9 } from "fs";
9021
8711
  import { existsSync as existsSync6, statSync as statSync7 } from "fs";
9022
- import path11 from "path";
8712
+ import path10 from "path";
9023
8713
  async function deleteFile(params) {
9024
8714
  const { path: filePath, recursive = false } = params;
9025
- const normalizedPath = path11.normalize(filePath);
9026
- const resolvedPath = path11.resolve(process.cwd(), normalizedPath);
9027
- const cwd = path11.resolve(process.cwd());
8715
+ const normalizedPath = path10.normalize(filePath);
8716
+ const resolvedPath = path10.resolve(process.cwd(), normalizedPath);
8717
+ const cwd = path10.resolve(process.cwd());
9028
8718
  if (!resolvedPath.startsWith(cwd)) {
9029
8719
  throw new Error(`Access denied: Cannot delete files outside of current working directory`);
9030
8720
  }
@@ -9038,10 +8728,10 @@ async function deleteFile(params) {
9038
8728
  throw new Error(`Path is a directory: ${filePath}. Use recursive=true to delete directories and their contents.`);
9039
8729
  }
9040
8730
  if (isDirectory) {
9041
- await fs10.rm(resolvedPath, { recursive: true, force: true });
8731
+ await fs9.rm(resolvedPath, { recursive: true, force: true });
9042
8732
  return `Directory deleted successfully: ${filePath}`;
9043
8733
  } else {
9044
- await fs10.unlink(resolvedPath);
8734
+ await fs9.unlink(resolvedPath);
9045
8735
  return `File deleted successfully: ${filePath}
9046
8736
  Size: ${size} bytes`;
9047
8737
  }
@@ -9051,7 +8741,7 @@ var deleteFileTool = {
9051
8741
  implementation: (context) => ({
9052
8742
  toolFn: async (value) => {
9053
8743
  const params = value;
9054
- const resolvedPath = path11.resolve(process.cwd(), path11.normalize(params.path));
8744
+ const resolvedPath = path10.resolve(process.cwd(), path10.normalize(params.path));
9055
8745
  const isDirectory = existsSync6(resolvedPath) && statSync7(resolvedPath).isDirectory();
9056
8746
  context.logger.info(`\u{1F5D1}\uFE0F DeleteFile: Deleting ${isDirectory ? "directory" : "file"}`, {
9057
8747
  path: params.path,
@@ -9089,7 +8779,7 @@ var deleteFileTool = {
9089
8779
 
9090
8780
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/bashExecute/index.js
9091
8781
  import { spawn } from "child_process";
9092
- import path12 from "path";
8782
+ import path11 from "path";
9093
8783
  var DEFAULT_TIMEOUT_MS = 6e4;
9094
8784
  var MAX_OUTPUT_SIZE = 100 * 1024;
9095
8785
  var DANGEROUS_PATTERNS = [
@@ -9273,7 +8963,7 @@ async function executeBashCommand(params) {
9273
8963
  };
9274
8964
  }
9275
8965
  const baseCwd = process.cwd();
9276
- const targetCwd = relativeCwd ? path12.resolve(baseCwd, relativeCwd) : baseCwd;
8966
+ const targetCwd = relativeCwd ? path11.resolve(baseCwd, relativeCwd) : baseCwd;
9277
8967
  const effectiveTimeout = Math.min(timeout, 5 * 60 * 1e3);
9278
8968
  return new Promise((resolve3) => {
9279
8969
  let stdout = "";
@@ -9607,42 +9297,42 @@ var DISABLE_SERVER_THROTTLING = process.env.DISABLE_SERVER_THROTTLING === "true"
9607
9297
  var questSaveMutex = new Mutex();
9608
9298
 
9609
9299
  // ../../b4m-core/packages/services/dist/src/llm/ChatCompletion.js
9610
- var QuestStartBodySchema = z139.object({
9611
- userId: z139.string(),
9612
- sessionId: z139.string(),
9613
- questId: z139.string(),
9614
- message: z139.string(),
9615
- messageFileIds: z139.array(z139.string()),
9616
- historyCount: z139.number(),
9617
- fabFileIds: z139.array(z139.string()),
9300
+ var QuestStartBodySchema = z138.object({
9301
+ userId: z138.string(),
9302
+ sessionId: z138.string(),
9303
+ questId: z138.string(),
9304
+ message: z138.string(),
9305
+ messageFileIds: z138.array(z138.string()),
9306
+ historyCount: z138.number(),
9307
+ fabFileIds: z138.array(z138.string()),
9618
9308
  params: ChatCompletionCreateInputSchema,
9619
9309
  dashboardParams: DashboardParamsSchema.optional(),
9620
- enableQuestMaster: z139.boolean().optional(),
9621
- enableMementos: z139.boolean().optional(),
9622
- enableArtifacts: z139.boolean().optional(),
9623
- enableAgents: z139.boolean().optional(),
9310
+ enableQuestMaster: z138.boolean().optional(),
9311
+ enableMementos: z138.boolean().optional(),
9312
+ enableArtifacts: z138.boolean().optional(),
9313
+ enableAgents: z138.boolean().optional(),
9624
9314
  promptMeta: PromptMetaZodSchema,
9625
- tools: z139.array(z139.union([b4mLLMTools, z139.string()])).optional(),
9626
- mcpServers: z139.array(z139.string()).optional(),
9627
- projectId: z139.string().optional(),
9628
- organizationId: z139.string().nullable().optional(),
9315
+ tools: z138.array(z138.union([b4mLLMTools, z138.string()])).optional(),
9316
+ mcpServers: z138.array(z138.string()).optional(),
9317
+ projectId: z138.string().optional(),
9318
+ organizationId: z138.string().nullable().optional(),
9629
9319
  questMaster: QuestMasterParamsSchema.optional(),
9630
- toolPromptId: z139.string().optional(),
9320
+ toolPromptId: z138.string().optional(),
9631
9321
  researchMode: ResearchModeParamsSchema.optional(),
9632
- fallbackModel: z139.string().optional(),
9633
- embeddingModel: z139.string().optional(),
9634
- queryComplexity: z139.string(),
9322
+ fallbackModel: z138.string().optional(),
9323
+ embeddingModel: z138.string().optional(),
9324
+ queryComplexity: z138.string(),
9635
9325
  imageConfig: GenerateImageToolCallSchema.optional(),
9636
- deepResearchConfig: z139.object({
9637
- maxDepth: z139.number().optional(),
9638
- duration: z139.number().optional(),
9326
+ deepResearchConfig: z138.object({
9327
+ maxDepth: z138.number().optional(),
9328
+ duration: z138.number().optional(),
9639
9329
  // Note: searchers are passed via ToolContext and not through this API schema
9640
- searchers: z139.array(z139.any()).optional()
9330
+ searchers: z138.array(z138.any()).optional()
9641
9331
  }).optional(),
9642
- extraContextMessages: z139.array(z139.object({
9643
- role: z139.enum(["user", "assistant", "system", "function", "tool"]),
9644
- content: z139.union([z139.string(), z139.array(z139.any())]),
9645
- fabFileIds: z139.array(z139.string()).optional()
9332
+ extraContextMessages: z138.array(z138.object({
9333
+ role: z138.enum(["user", "assistant", "system", "function", "tool"]),
9334
+ content: z138.union([z138.string(), z138.array(z138.any())]),
9335
+ fabFileIds: z138.array(z138.string()).optional()
9646
9336
  })).optional()
9647
9337
  });
9648
9338
 
@@ -9650,9 +9340,30 @@ var QuestStartBodySchema = z139.object({
9650
9340
  import axios8 from "axios";
9651
9341
  import { fileTypeFromBuffer as fileTypeFromBuffer4 } from "file-type";
9652
9342
  import { v4 as uuidv47 } from "uuid";
9653
- import { z as z140 } from "zod";
9343
+ import { z as z139 } from "zod";
9654
9344
  import { fromZodError as fromZodError2 } from "zod-validation-error";
9655
9345
  var ImageGenerationBodySchema = OpenAIImageGenerationInput.extend({
9346
+ sessionId: z139.string(),
9347
+ questId: z139.string(),
9348
+ userId: z139.string(),
9349
+ prompt: z139.string(),
9350
+ safety_tolerance: z139.number().min(BFL_SAFETY_TOLERANCE.MIN).max(BFL_SAFETY_TOLERANCE.MAX).optional().default(BFL_SAFETY_TOLERANCE.DEFAULT),
9351
+ prompt_upsampling: z139.boolean().optional().default(false),
9352
+ seed: z139.number().nullable().optional(),
9353
+ output_format: z139.enum(["jpeg", "png"]).nullable().optional().default("png"),
9354
+ width: z139.number().optional(),
9355
+ height: z139.number().optional(),
9356
+ aspect_ratio: z139.string().optional(),
9357
+ fabFileIds: z139.array(z139.string()).optional()
9358
+ });
9359
+
9360
+ // ../../b4m-core/packages/services/dist/src/llm/ImageEdit.js
9361
+ import axios9 from "axios";
9362
+ import { fileTypeFromBuffer as fileTypeFromBuffer5 } from "file-type";
9363
+ import { v4 as uuidv48 } from "uuid";
9364
+ import { z as z140 } from "zod";
9365
+ import { fromZodError as fromZodError3 } from "zod-validation-error";
9366
+ var ImageEditBodySchema = OpenAIImageGenerationInput.extend({
9656
9367
  sessionId: z140.string(),
9657
9368
  questId: z140.string(),
9658
9369
  userId: z140.string(),
@@ -9660,56 +9371,35 @@ var ImageGenerationBodySchema = OpenAIImageGenerationInput.extend({
9660
9371
  safety_tolerance: z140.number().min(BFL_SAFETY_TOLERANCE.MIN).max(BFL_SAFETY_TOLERANCE.MAX).optional().default(BFL_SAFETY_TOLERANCE.DEFAULT),
9661
9372
  prompt_upsampling: z140.boolean().optional().default(false),
9662
9373
  seed: z140.number().nullable().optional(),
9663
- output_format: z140.enum(["jpeg", "png"]).nullable().optional().default("png"),
9374
+ output_format: z140.enum(["jpeg", "png"]).optional().default("png"),
9664
9375
  width: z140.number().optional(),
9665
9376
  height: z140.number().optional(),
9666
9377
  aspect_ratio: z140.string().optional(),
9667
- fabFileIds: z140.array(z140.string()).optional()
9668
- });
9669
-
9670
- // ../../b4m-core/packages/services/dist/src/llm/ImageEdit.js
9671
- import axios9 from "axios";
9672
- import { fileTypeFromBuffer as fileTypeFromBuffer5 } from "file-type";
9673
- import { v4 as uuidv48 } from "uuid";
9674
- import { z as z141 } from "zod";
9675
- import { fromZodError as fromZodError3 } from "zod-validation-error";
9676
- var ImageEditBodySchema = OpenAIImageGenerationInput.extend({
9677
- sessionId: z141.string(),
9678
- questId: z141.string(),
9679
- userId: z141.string(),
9680
- prompt: z141.string(),
9681
- safety_tolerance: z141.number().min(BFL_SAFETY_TOLERANCE.MIN).max(BFL_SAFETY_TOLERANCE.MAX).optional().default(BFL_SAFETY_TOLERANCE.DEFAULT),
9682
- prompt_upsampling: z141.boolean().optional().default(false),
9683
- seed: z141.number().nullable().optional(),
9684
- output_format: z141.enum(["jpeg", "png"]).optional().default("png"),
9685
- width: z141.number().optional(),
9686
- height: z141.number().optional(),
9687
- aspect_ratio: z141.string().optional(),
9688
- size: z141.string().optional(),
9689
- fabFileIds: z141.array(z141.string()).optional(),
9690
- image: z141.string()
9378
+ size: z140.string().optional(),
9379
+ fabFileIds: z140.array(z140.string()).optional(),
9380
+ image: z140.string()
9691
9381
  });
9692
9382
 
9693
9383
  // ../../b4m-core/packages/services/dist/src/llm/refineText.js
9694
- import { z as z142 } from "zod";
9695
- var refineTextLLMSchema = z142.object({
9696
- text: z142.string(),
9697
- context: z142.string().optional()
9384
+ import { z as z141 } from "zod";
9385
+ var refineTextLLMSchema = z141.object({
9386
+ text: z141.string(),
9387
+ context: z141.string().optional()
9698
9388
  // tone: z.enum(['formal', 'informal', 'neutral']).optional(),
9699
9389
  // style: z.enum(['technical', 'creative', 'academic', 'business', 'narrative']).optional(),
9700
9390
  });
9701
9391
 
9702
9392
  // ../../b4m-core/packages/services/dist/src/llm/MementoEvaluationService.js
9703
- import { z as z143 } from "zod";
9704
- var SingleMementoEvalSchema = z143.object({
9705
- importance: z143.number().min(1).max(10),
9393
+ import { z as z142 } from "zod";
9394
+ var SingleMementoEvalSchema = z142.object({
9395
+ importance: z142.number().min(1).max(10),
9706
9396
  // 1-10 scale for personal info importance
9707
- summary: z143.string(),
9708
- tags: z143.array(z143.string()).optional()
9397
+ summary: z142.string(),
9398
+ tags: z142.array(z142.string()).optional()
9709
9399
  });
9710
- var MementoEvalResponseSchema = z143.object({
9711
- isPersonal: z143.boolean(),
9712
- mementos: z143.array(SingleMementoEvalSchema).optional()
9400
+ var MementoEvalResponseSchema = z142.object({
9401
+ isPersonal: z142.boolean(),
9402
+ mementos: z142.array(SingleMementoEvalSchema).optional()
9713
9403
  // Array of distinct personal information
9714
9404
  });
9715
9405
 
@@ -9766,7 +9456,7 @@ async function generateFileDeletePreview(args) {
9766
9456
  if (!existsSync7(args.path)) {
9767
9457
  return `[File does not exist: ${args.path}]`;
9768
9458
  }
9769
- const stats = await import("fs/promises").then((fs13) => fs13.stat(args.path));
9459
+ const stats = await import("fs/promises").then((fs12) => fs12.stat(args.path));
9770
9460
  return `[File will be deleted]
9771
9461
 
9772
9462
  Path: ${args.path}
@@ -9778,9 +9468,9 @@ Last modified: ${stats.mtime.toLocaleString()}`;
9778
9468
  }
9779
9469
 
9780
9470
  // src/utils/Logger.ts
9781
- import fs11 from "fs/promises";
9782
- import path13 from "path";
9783
- import os2 from "os";
9471
+ import fs10 from "fs/promises";
9472
+ import path12 from "path";
9473
+ import os from "os";
9784
9474
  var Logger2 = class _Logger {
9785
9475
  constructor() {
9786
9476
  this.logFilePath = null;
@@ -9802,9 +9492,9 @@ var Logger2 = class _Logger {
9802
9492
  */
9803
9493
  async initialize(sessionId) {
9804
9494
  this.sessionId = sessionId;
9805
- const debugDir = path13.join(os2.homedir(), ".bike4mind", "debug");
9806
- await fs11.mkdir(debugDir, { recursive: true });
9807
- this.logFilePath = path13.join(debugDir, `${sessionId}.txt`);
9495
+ const debugDir = path12.join(os.homedir(), ".bike4mind", "debug");
9496
+ await fs10.mkdir(debugDir, { recursive: true });
9497
+ this.logFilePath = path12.join(debugDir, `${sessionId}.txt`);
9808
9498
  await this.writeToFile("INFO", "=== CLI SESSION START ===");
9809
9499
  }
9810
9500
  /**
@@ -9868,7 +9558,7 @@ var Logger2 = class _Logger {
9868
9558
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").substring(0, 19);
9869
9559
  const logEntry = `[${timestamp}] [${level}] ${message}
9870
9560
  `;
9871
- await fs11.appendFile(this.logFilePath, logEntry, "utf-8");
9561
+ await fs10.appendFile(this.logFilePath, logEntry, "utf-8");
9872
9562
  } catch (error) {
9873
9563
  console.error("File logging failed:", error);
9874
9564
  }
@@ -10014,15 +9704,15 @@ var Logger2 = class _Logger {
10014
9704
  async cleanupOldLogs() {
10015
9705
  if (!this.fileLoggingEnabled) return;
10016
9706
  try {
10017
- const debugDir = path13.join(os2.homedir(), ".bike4mind", "debug");
10018
- const files = await fs11.readdir(debugDir);
9707
+ const debugDir = path12.join(os.homedir(), ".bike4mind", "debug");
9708
+ const files = await fs10.readdir(debugDir);
10019
9709
  const now = Date.now();
10020
9710
  const thirtyDaysAgo = now - 30 * 24 * 60 * 60 * 1e3;
10021
9711
  for (const file of files) {
10022
- const filePath = path13.join(debugDir, file);
10023
- const stats = await fs11.stat(filePath);
9712
+ const filePath = path12.join(debugDir, file);
9713
+ const stats = await fs10.stat(filePath);
10024
9714
  if (stats.mtime.getTime() < thirtyDaysAgo) {
10025
- await fs11.unlink(filePath);
9715
+ await fs10.unlink(filePath);
10026
9716
  }
10027
9717
  }
10028
9718
  } catch (error) {
@@ -10116,21 +9806,21 @@ var NoOpStorage = class extends BaseStorage {
10116
9806
  async upload(input, destination, options) {
10117
9807
  return `/tmp/${destination}`;
10118
9808
  }
10119
- async download(path16) {
9809
+ async download(path15) {
10120
9810
  throw new Error("Download not supported in CLI");
10121
9811
  }
10122
- async delete(path16) {
9812
+ async delete(path15) {
10123
9813
  }
10124
- async getSignedUrl(path16) {
10125
- return `/tmp/${path16}`;
9814
+ async getSignedUrl(path15) {
9815
+ return `/tmp/${path15}`;
10126
9816
  }
10127
- getPublicUrl(path16) {
10128
- return `/tmp/${path16}`;
9817
+ getPublicUrl(path15) {
9818
+ return `/tmp/${path15}`;
10129
9819
  }
10130
- async getPreview(path16) {
10131
- return `/tmp/${path16}`;
9820
+ async getPreview(path15) {
9821
+ return `/tmp/${path15}`;
10132
9822
  }
10133
- async getMetadata(path16) {
9823
+ async getMetadata(path15) {
10134
9824
  return { size: 0, contentType: "application/octet-stream" };
10135
9825
  }
10136
9826
  };
@@ -10224,7 +9914,31 @@ function wrapToolWithPermission(tool, permissionManager, showPermissionPrompt, a
10224
9914
  }
10225
9915
  };
10226
9916
  }
10227
- function generateCliTools(userId, llm, model, permissionManager, showPermissionPrompt, agentContext, configStore, apiClient) {
9917
+ var TOOL_NAME_MAPPING = {
9918
+ // Claude Code -> B4M
9919
+ read: "file_read",
9920
+ write: "create_file",
9921
+ edit: "edit_file",
9922
+ delete: "delete_file",
9923
+ glob: "glob_files",
9924
+ grep: "grep_search",
9925
+ bash: "bash_execute",
9926
+ // B4M -> Claude Code (reverse mapping)
9927
+ file_read: "read",
9928
+ create_file: "write",
9929
+ edit_file: "edit",
9930
+ delete_file: "delete",
9931
+ glob_files: "glob",
9932
+ grep_search: "grep",
9933
+ bash_execute: "bash"
9934
+ };
9935
+ function normalizeToolName(toolName) {
9936
+ if (toolName.includes("_")) {
9937
+ return toolName;
9938
+ }
9939
+ return TOOL_NAME_MAPPING[toolName] || toolName;
9940
+ }
9941
+ function generateCliTools(userId, llm, model, permissionManager, showPermissionPrompt, agentContext, configStore, apiClient, toolFilter) {
10228
9942
  const logger2 = new CliLogger();
10229
9943
  const storage = new NoOpStorage();
10230
9944
  const user = {
@@ -10294,15 +10008,30 @@ function generateCliTools(userId, llm, model, permissionManager, showPermissionP
10294
10008
  toolConfig,
10295
10009
  model
10296
10010
  );
10297
- const tools2 = Object.entries(toolsMap).filter(([key]) => toolConfig[key] !== void 0).map(
10011
+ let tools2 = Object.entries(toolsMap).filter(([key]) => toolConfig[key] !== void 0).map(
10298
10012
  ([_, tool]) => wrapToolWithPermission(tool, permissionManager, showPermissionPrompt, agentContext, configStore, apiClient)
10299
10013
  );
10014
+ if (toolFilter) {
10015
+ const { allowedTools, deniedTools } = toolFilter;
10016
+ const normalizedAllowed = allowedTools?.map(normalizeToolName);
10017
+ const normalizedDenied = deniedTools?.map(normalizeToolName);
10018
+ tools2 = tools2.filter((tool) => {
10019
+ const toolName = tool.toolSchema.name;
10020
+ if (normalizedDenied && normalizedDenied.includes(toolName)) {
10021
+ return false;
10022
+ }
10023
+ if (normalizedAllowed && normalizedAllowed.length > 0) {
10024
+ return normalizedAllowed.includes(toolName);
10025
+ }
10026
+ return true;
10027
+ });
10028
+ }
10300
10029
  return { tools: tools2, agentContext };
10301
10030
  }
10302
10031
 
10303
10032
  // src/config/toolSafety.ts
10304
- import { z as z144 } from "zod";
10305
- var ToolCategorySchema = z144.enum([
10033
+ import { z as z143 } from "zod";
10034
+ var ToolCategorySchema = z143.enum([
10306
10035
  "auto_approve",
10307
10036
  // Safe tools that run automatically without permission
10308
10037
  "prompt_always",
@@ -10310,9 +10039,9 @@ var ToolCategorySchema = z144.enum([
10310
10039
  "prompt_default"
10311
10040
  // Tools that prompt by default but can be trusted
10312
10041
  ]);
10313
- var ToolSafetyConfigSchema = z144.object({
10314
- categories: z144.record(z144.string(), ToolCategorySchema),
10315
- trustedTools: z144.array(z144.string())
10042
+ var ToolSafetyConfigSchema = z143.object({
10043
+ categories: z143.record(z143.string(), ToolCategorySchema),
10044
+ trustedTools: z143.array(z143.string())
10316
10045
  });
10317
10046
  var DEFAULT_TOOL_CATEGORIES = {
10318
10047
  // ===== AUTO APPROVE (Safe tools) =====
@@ -10492,8 +10221,8 @@ function getEnvironmentName(configApiConfig) {
10492
10221
  }
10493
10222
 
10494
10223
  // src/utils/contextLoader.ts
10495
- import * as fs12 from "fs";
10496
- import * as path14 from "path";
10224
+ import * as fs11 from "fs";
10225
+ import * as path13 from "path";
10497
10226
  import { homedir as homedir4 } from "os";
10498
10227
  var CONTEXT_FILE_SIZE_LIMIT = 100 * 1024;
10499
10228
  var PROJECT_CONTEXT_FILES = [
@@ -10514,9 +10243,9 @@ function formatFileSize2(bytes) {
10514
10243
  return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
10515
10244
  }
10516
10245
  function tryReadContextFile(dir, filename, source) {
10517
- const filePath = path14.join(dir, filename);
10246
+ const filePath = path13.join(dir, filename);
10518
10247
  try {
10519
- const stats = fs12.lstatSync(filePath);
10248
+ const stats = fs11.lstatSync(filePath);
10520
10249
  if (stats.isDirectory()) {
10521
10250
  return null;
10522
10251
  }
@@ -10530,7 +10259,7 @@ function tryReadContextFile(dir, filename, source) {
10530
10259
  error: `${source === "global" ? "Global" : "Project"} ${filename} exceeds 100KB limit (${formatFileSize2(stats.size)})`
10531
10260
  };
10532
10261
  }
10533
- const content = fs12.readFileSync(filePath, "utf-8");
10262
+ const content = fs11.readFileSync(filePath, "utf-8");
10534
10263
  return {
10535
10264
  filename,
10536
10265
  content,
@@ -10582,7 +10311,7 @@ ${project.content}`;
10582
10311
  }
10583
10312
  async function loadContextFiles(projectDir) {
10584
10313
  const errors = [];
10585
- const globalDir = path14.join(homedir4(), ".bike4mind");
10314
+ const globalDir = path13.join(homedir4(), ".bike4mind");
10586
10315
  const projectDirectory = projectDir || process.cwd();
10587
10316
  const [globalResult, projectResult] = await Promise.all([
10588
10317
  Promise.resolve(findContextFile(globalDir, GLOBAL_CONTEXT_FILES, "global")),
@@ -10603,22 +10332,10 @@ async function loadContextFiles(projectDir) {
10603
10332
  };
10604
10333
  }
10605
10334
 
10606
- // src/utils/argumentSubstitution.ts
10607
- function substituteArguments(template, args) {
10608
- let result = template;
10609
- for (let i = args.length; i >= 1; i--) {
10610
- const pattern = new RegExp(`\\$${i}`, "g");
10611
- result = result.replace(pattern, args[i - 1] || "");
10612
- }
10613
- const allArgsString = args.join(" ");
10614
- result = result.replace(/\$ARGUMENTS/g, allArgsString);
10615
- return result;
10616
- }
10617
-
10618
10335
  // ../../b4m-core/packages/mcp/dist/src/client.js
10619
10336
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
10620
10337
  import { Client as Client2 } from "@modelcontextprotocol/sdk/client/index.js";
10621
- import path15 from "path";
10338
+ import path14 from "path";
10622
10339
  import { existsSync as existsSync8, readdirSync as readdirSync3 } from "fs";
10623
10340
  var MCPClient = class {
10624
10341
  // Note: This class handles MCP server communication with repository filtering
@@ -10659,16 +10376,16 @@ var MCPClient = class {
10659
10376
  const root = process.env.INIT_CWD || process.cwd();
10660
10377
  const candidatePaths = [
10661
10378
  // When running from SST Lambda with node_modules structure (copyFiles)
10662
- path15.join(root, `node_modules/@bike4mind/mcp/dist/src/${this.serverName}/index.js`),
10379
+ path14.join(root, `node_modules/@bike4mind/mcp/dist/src/${this.serverName}/index.js`),
10663
10380
  // When running from SST Lambda deployed environment (/var/task)
10664
- path15.join(root, `b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10381
+ path14.join(root, `b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10665
10382
  // When running from SST Lambda (.sst/artifacts/mcpHandler-dev), navigate to monorepo root (3 levels up)
10666
- path15.join(root, `../../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10383
+ path14.join(root, `../../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10667
10384
  // When running from packages/client (Next.js app), navigate to monorepo root (2 levels up)
10668
- path15.join(root, `../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10385
+ path14.join(root, `../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10669
10386
  // Original paths (backward compatibility)
10670
- path15.join(root, `/b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10671
- path15.join(root, "core", "mcp", "servers", this.serverName, "dist", "index.js")
10387
+ path14.join(root, `/b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
10388
+ path14.join(root, "core", "mcp", "servers", this.serverName, "dist", "index.js")
10672
10389
  ];
10673
10390
  const serverScriptPath = candidatePaths.find((p) => existsSync8(p));
10674
10391
  if (!serverScriptPath) {
@@ -11472,7 +11189,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
11472
11189
  // package.json
11473
11190
  var package_default = {
11474
11191
  name: "@bike4mind/cli",
11475
- version: "0.2.10-feat-custom-slash-commands.17246+98e77a500",
11192
+ version: "0.2.10-feat-explore-subagent-implementation.17245+d73e88b84",
11476
11193
  type: "module",
11477
11194
  description: "Interactive CLI tool for Bike4Mind with ReAct agents",
11478
11195
  license: "UNLICENSED",
@@ -11542,7 +11259,6 @@ var package_default = {
11542
11259
  "eventsource-parser": "^3.0.6",
11543
11260
  "file-type": "^18.7.0",
11544
11261
  "fuse.js": "^7.1.0",
11545
- "gray-matter": "^4.0.3",
11546
11262
  ink: "^6.5.1",
11547
11263
  "ink-select-input": "^6.2.0",
11548
11264
  "ink-spinner": "^5.0.0",
@@ -11576,10 +11292,10 @@ var package_default = {
11576
11292
  },
11577
11293
  devDependencies: {
11578
11294
  "@bike4mind/agents": "0.1.0",
11579
- "@bike4mind/common": "2.39.1-feat-custom-slash-commands.17246+98e77a500",
11580
- "@bike4mind/mcp": "1.20.4-feat-custom-slash-commands.17246+98e77a500",
11581
- "@bike4mind/services": "2.34.2-feat-custom-slash-commands.17246+98e77a500",
11582
- "@bike4mind/utils": "2.1.4-feat-custom-slash-commands.17246+98e77a500",
11295
+ "@bike4mind/common": "2.39.1-feat-explore-subagent-implementation.17245+d73e88b84",
11296
+ "@bike4mind/mcp": "1.20.4-feat-explore-subagent-implementation.17245+d73e88b84",
11297
+ "@bike4mind/services": "2.34.2-feat-explore-subagent-implementation.17245+d73e88b84",
11298
+ "@bike4mind/utils": "2.1.4-feat-explore-subagent-implementation.17245+d73e88b84",
11583
11299
  "@types/better-sqlite3": "^7.6.13",
11584
11300
  "@types/diff": "^5.0.9",
11585
11301
  "@types/jsonwebtoken": "^9.0.4",
@@ -11592,7 +11308,7 @@ var package_default = {
11592
11308
  typescript: "^5.9.3",
11593
11309
  vitest: "^3.2.4"
11594
11310
  },
11595
- gitHead: "98e77a500de577e81822e8683a7b6713fb783225"
11311
+ gitHead: "d73e88b84cc88ea33861cf5270ee1e23eb953ed1"
11596
11312
  };
11597
11313
 
11598
11314
  // src/config/constants.ts
@@ -11600,6 +11316,331 @@ var USAGE_DAYS = 30;
11600
11316
  var MODEL_NAME_COLUMN_WIDTH = 18;
11601
11317
  var USAGE_CACHE_TTL = 5 * 60 * 1e3;
11602
11318
 
11319
+ // src/agents/SubagentOrchestrator.ts
11320
+ var SubagentOrchestrator = class {
11321
+ constructor(deps) {
11322
+ this.deps = deps;
11323
+ }
11324
+ /**
11325
+ * Delegate a task to a specialized subagent
11326
+ *
11327
+ * @param options - Configuration for subagent execution
11328
+ * @returns Subagent result with summary
11329
+ */
11330
+ async delegateToSubagent(options) {
11331
+ const { task, type, thoroughness, parentSessionId, config: configOverride } = options;
11332
+ const baseConfig = this.deps.subagentConfigs.get(type);
11333
+ if (!baseConfig) {
11334
+ throw new Error(`No configuration found for subagent type: ${type}`);
11335
+ }
11336
+ const config = {
11337
+ ...baseConfig,
11338
+ ...configOverride,
11339
+ type
11340
+ };
11341
+ const model = config.model || "claude-3-5-haiku-20241022";
11342
+ const maxIterations = this.getMaxIterations(config, thoroughness);
11343
+ const toolFilter = {
11344
+ allowedTools: config.allowedTools,
11345
+ deniedTools: config.deniedTools
11346
+ };
11347
+ const agentContext = {
11348
+ currentAgent: null,
11349
+ observationQueue: []
11350
+ };
11351
+ const { tools: tools2, agentContext: updatedContext } = generateCliTools(
11352
+ this.deps.userId,
11353
+ this.deps.llm,
11354
+ model,
11355
+ this.deps.permissionManager,
11356
+ this.deps.showPermissionPrompt,
11357
+ agentContext,
11358
+ this.deps.configStore,
11359
+ this.deps.apiClient,
11360
+ toolFilter
11361
+ );
11362
+ this.deps.logger.debug(`Spawning ${type} subagent with ${tools2.length} tools, thoroughness: ${thoroughness}`);
11363
+ const subagent = new ReActAgent({
11364
+ userId: this.deps.userId,
11365
+ logger: this.deps.logger,
11366
+ llm: this.deps.llm,
11367
+ model,
11368
+ tools: tools2,
11369
+ maxIterations,
11370
+ systemPrompt: config.systemPrompt || this.getDefaultSystemPrompt(type)
11371
+ });
11372
+ updatedContext.currentAgent = subagent;
11373
+ const startTime = Date.now();
11374
+ const result = await subagent.run(task, {
11375
+ maxIterations
11376
+ });
11377
+ const duration = Date.now() - startTime;
11378
+ this.deps.logger.debug(
11379
+ `Subagent completed in ${duration}ms, ${result.completionInfo.iterations} iterations, ${result.completionInfo.totalTokens} tokens`
11380
+ );
11381
+ const summary = this.summarizeResult(result, type);
11382
+ const subagentResult = {
11383
+ ...result,
11384
+ subagentType: type,
11385
+ thoroughness,
11386
+ summary,
11387
+ parentSessionId
11388
+ };
11389
+ return subagentResult;
11390
+ }
11391
+ /**
11392
+ * Get max iterations based on thoroughness and config
11393
+ */
11394
+ getMaxIterations(config, thoroughness) {
11395
+ const defaults = {
11396
+ quick: 2,
11397
+ medium: 5,
11398
+ very_thorough: 10
11399
+ };
11400
+ const configIterations = config.maxIterations || defaults;
11401
+ return configIterations[thoroughness];
11402
+ }
11403
+ /**
11404
+ * Get default system prompt for subagent type
11405
+ */
11406
+ getDefaultSystemPrompt(type) {
11407
+ switch (type) {
11408
+ case "explore":
11409
+ return `You are a code exploration specialist. Your job is to search and analyze codebases efficiently.
11410
+
11411
+ Focus on:
11412
+ - Finding relevant files and functions
11413
+ - Understanding code structure and patterns
11414
+ - Providing clear, concise summaries
11415
+
11416
+ You have read-only access. Use file_read, grep_search, and glob_files to explore.
11417
+
11418
+ When you find what you're looking for, provide a clear summary including:
11419
+ 1. What you found (files, functions, patterns)
11420
+ 2. Key insights or observations
11421
+ 3. Relevant code locations
11422
+
11423
+ Be thorough but concise. Your summary will be used by the main agent.`;
11424
+ case "plan":
11425
+ return `You are a task planning specialist. Your job is to break down complex tasks into clear, actionable steps.
11426
+
11427
+ Focus on:
11428
+ - Identifying dependencies and blockers
11429
+ - Creating logical sequence of steps
11430
+ - Estimating scope and priorities
11431
+
11432
+ Provide a structured plan that the main agent can execute.`;
11433
+ case "review":
11434
+ return `You are a code review specialist. Your job is to analyze code quality and identify issues.
11435
+
11436
+ Focus on:
11437
+ - Code quality and best practices
11438
+ - Potential bugs and edge cases
11439
+ - Performance and security considerations
11440
+
11441
+ Provide actionable feedback with specific file and line references.`;
11442
+ default:
11443
+ return "You are a helpful AI assistant.";
11444
+ }
11445
+ }
11446
+ /**
11447
+ * Summarize subagent result for parent agent
11448
+ */
11449
+ summarizeResult(result, type) {
11450
+ const { finalAnswer, steps, completionInfo } = result;
11451
+ const toolCalls = steps.filter((s) => s.type === "action");
11452
+ const filesRead = toolCalls.filter((s) => s.metadata?.toolName === "file_read").length;
11453
+ const searches = toolCalls.filter((s) => s.metadata?.toolName === "grep_search").length;
11454
+ const globs = toolCalls.filter((s) => s.metadata?.toolName === "glob_files").length;
11455
+ let summary = `**${type.charAt(0).toUpperCase() + type.slice(1)} Subagent Results**
11456
+
11457
+ `;
11458
+ summary += `*Execution: ${completionInfo.iterations} iterations, ${completionInfo.toolCalls} tool calls*
11459
+
11460
+ `;
11461
+ if (type === "explore") {
11462
+ summary += `*Exploration: ${filesRead} files read, ${searches} searches, ${globs} glob patterns*
11463
+
11464
+ `;
11465
+ }
11466
+ const maxLength = 1e3;
11467
+ if (finalAnswer.length > maxLength) {
11468
+ summary += finalAnswer.slice(0, maxLength) + "\n\n...(truncated)";
11469
+ } else {
11470
+ summary += finalAnswer;
11471
+ }
11472
+ return summary;
11473
+ }
11474
+ };
11475
+
11476
+ // src/agents/configs.ts
11477
+ var EXPLORE_CONFIG = {
11478
+ type: "explore",
11479
+ model: "claude-3-5-haiku-20241022",
11480
+ systemPrompt: `You are a code exploration specialist. Your job is to search and analyze codebases efficiently.
11481
+
11482
+ Focus on:
11483
+ - Finding relevant files and functions
11484
+ - Understanding code structure and patterns
11485
+ - Providing clear, concise summaries
11486
+
11487
+ You have read-only access. Use file_read, grep_search, and glob_files to explore.
11488
+
11489
+ When you find what you're looking for, provide a clear summary including:
11490
+ 1. What you found (files, functions, patterns)
11491
+ 2. Key insights or observations
11492
+ 3. Relevant code locations
11493
+
11494
+ Be thorough but concise. Your summary will be used by the main agent.`,
11495
+ allowedTools: [
11496
+ "file_read",
11497
+ "grep_search",
11498
+ "glob_files",
11499
+ "bash_execute",
11500
+ // Only for read-only commands like ls, cat, find
11501
+ "current_datetime",
11502
+ "math_evaluate"
11503
+ ],
11504
+ deniedTools: [
11505
+ "create_file",
11506
+ "edit_file",
11507
+ "delete_file",
11508
+ "web_search",
11509
+ "weather_info",
11510
+ "blog_publish",
11511
+ "blog_edit",
11512
+ "blog_draft"
11513
+ ],
11514
+ maxIterations: {
11515
+ quick: 2,
11516
+ medium: 5,
11517
+ very_thorough: 10
11518
+ },
11519
+ defaultThoroughness: "medium"
11520
+ };
11521
+ var PLAN_CONFIG = {
11522
+ type: "plan",
11523
+ model: "claude-3-5-haiku-20241022",
11524
+ systemPrompt: `You are a task planning specialist. Your job is to break down complex tasks into clear, actionable steps.
11525
+
11526
+ Focus on:
11527
+ - Identifying dependencies and blockers
11528
+ - Creating logical sequence of steps
11529
+ - Estimating scope and priorities
11530
+
11531
+ You can explore the codebase to understand the current architecture before planning.
11532
+
11533
+ Provide a structured plan that the main agent can execute.`,
11534
+ allowedTools: ["file_read", "grep_search", "glob_files", "bash_execute", "current_datetime", "math_evaluate"],
11535
+ deniedTools: ["create_file", "edit_file", "delete_file", "web_search", "weather_info"],
11536
+ maxIterations: {
11537
+ quick: 3,
11538
+ medium: 7,
11539
+ very_thorough: 12
11540
+ },
11541
+ defaultThoroughness: "medium"
11542
+ };
11543
+ var REVIEW_CONFIG = {
11544
+ type: "review",
11545
+ model: "claude-3-5-sonnet-20241022",
11546
+ // Use Sonnet for better reasoning
11547
+ systemPrompt: `You are a code review specialist. Your job is to analyze code quality and identify issues.
11548
+
11549
+ Focus on:
11550
+ - Code quality and best practices
11551
+ - Potential bugs and edge cases
11552
+ - Performance and security considerations
11553
+
11554
+ You have read-only access to analyze code.
11555
+
11556
+ Provide actionable feedback with specific file and line references.`,
11557
+ allowedTools: ["file_read", "grep_search", "glob_files", "bash_execute", "current_datetime"],
11558
+ deniedTools: ["create_file", "edit_file", "delete_file", "web_search", "weather_info"],
11559
+ maxIterations: {
11560
+ quick: 3,
11561
+ medium: 8,
11562
+ very_thorough: 15
11563
+ },
11564
+ defaultThoroughness: "medium"
11565
+ };
11566
+ function getDefaultSubagentConfigs() {
11567
+ return /* @__PURE__ */ new Map([
11568
+ ["explore", EXPLORE_CONFIG],
11569
+ ["plan", PLAN_CONFIG],
11570
+ ["review", REVIEW_CONFIG]
11571
+ ]);
11572
+ }
11573
+
11574
+ // src/agents/delegateTool.ts
11575
+ function createSubagentDelegateTool(orchestrator, parentSessionId) {
11576
+ return {
11577
+ toolFn: async (args) => {
11578
+ const params = args;
11579
+ if (!params.task) {
11580
+ throw new Error("subagent_delegate: task parameter is required");
11581
+ }
11582
+ if (!params.type) {
11583
+ throw new Error("subagent_delegate: type parameter is required");
11584
+ }
11585
+ const thoroughness = params.thoroughness || "medium";
11586
+ const type = params.type;
11587
+ const result = await orchestrator.delegateToSubagent({
11588
+ task: params.task,
11589
+ type,
11590
+ thoroughness,
11591
+ parentSessionId
11592
+ });
11593
+ return result.summary;
11594
+ },
11595
+ toolSchema: {
11596
+ name: "subagent_delegate",
11597
+ description: `Delegate a task to a specialized subagent for focused work.
11598
+
11599
+ **When to use this tool:**
11600
+ - **Explore**: When you need to search through the codebase, find files, or understand code structure (read-only)
11601
+ - **Plan**: When you need to break down a complex task into actionable steps
11602
+ - **Review**: When you need to analyze code quality and identify potential issues
11603
+
11604
+ **Benefits:**
11605
+ - Keeps main conversation focused and clean
11606
+ - Uses specialized prompts optimized for each task type
11607
+ - Faster execution with appropriate models (Haiku for explore/plan, Sonnet for review)
11608
+
11609
+ **Example uses:**
11610
+ - "Find all files that use the authentication system" \u2192 explore
11611
+ - "Search for components that handle user input" \u2192 explore
11612
+ - "Break down implementing a new feature into steps" \u2192 plan
11613
+ - "Review this module for potential bugs" \u2192 review`,
11614
+ parameters: {
11615
+ type: "object",
11616
+ properties: {
11617
+ task: {
11618
+ type: "string",
11619
+ description: "Clear description of what you want the subagent to do. Be specific about what you're looking for or what needs to be accomplished."
11620
+ },
11621
+ type: {
11622
+ type: "string",
11623
+ enum: ["explore", "plan", "review"],
11624
+ description: `Type of subagent to use:
11625
+ - explore: Read-only codebase exploration and search (fast, uses Haiku)
11626
+ - plan: Task breakdown and planning (uses Haiku)
11627
+ - review: Code quality analysis and review (uses Sonnet for better reasoning)`
11628
+ },
11629
+ thoroughness: {
11630
+ type: "string",
11631
+ enum: ["quick", "medium", "very_thorough"],
11632
+ description: `How thoroughly to execute:
11633
+ - quick: Fast lookup, 1-2 iterations
11634
+ - medium: Balanced exploration, 3-5 iterations (default)
11635
+ - very_thorough: Comprehensive analysis, 8-10 iterations`
11636
+ }
11637
+ },
11638
+ required: ["task", "type"]
11639
+ }
11640
+ }
11641
+ };
11642
+ }
11643
+
11603
11644
  // src/index.tsx
11604
11645
  process.removeAllListeners("warning");
11605
11646
  process.on("warning", (warning) => {
@@ -11619,7 +11660,6 @@ function CliApp() {
11619
11660
  sessionStore: new SessionStore(),
11620
11661
  configStore: new ConfigStore(),
11621
11662
  commandHistoryStore: new CommandHistoryStore(),
11622
- customCommandStore: new CustomCommandStore(),
11623
11663
  imageStore: null,
11624
11664
  // Lazy-loaded on first use
11625
11665
  imageRenderer,
@@ -11699,15 +11739,6 @@ function CliApp() {
11699
11739
  const config = await state.configStore.load();
11700
11740
  const history = await state.commandHistoryStore.load();
11701
11741
  setCommandHistory(history);
11702
- try {
11703
- await state.customCommandStore.loadCommands();
11704
- const customCommandCount = state.customCommandStore.getCommandCount();
11705
- if (customCommandCount > 0) {
11706
- console.log(`\u{1F4DD} Loaded ${customCommandCount} custom command${customCommandCount !== 1 ? "s" : ""}`);
11707
- }
11708
- } catch (error) {
11709
- console.warn("Failed to load custom commands:", error instanceof Error ? error.message : String(error));
11710
- }
11711
11742
  const authTokens = await state.configStore.getAuthTokens();
11712
11743
  let isAuthenticated = false;
11713
11744
  if (!authTokens) {
@@ -11847,7 +11878,34 @@ function CliApp() {
11847
11878
  console.log(` \u{1F4E1} ${serverName}: ${count} tool(s)`);
11848
11879
  });
11849
11880
  }
11850
- const allTools = [...b4mTools, ...mcpTools];
11881
+ const subagentConfigs = getDefaultSubagentConfigs();
11882
+ if (config.subagents) {
11883
+ if (config.subagents.explore) {
11884
+ const currentConfig = subagentConfigs.get("explore");
11885
+ subagentConfigs.set("explore", { ...currentConfig, ...config.subagents.explore });
11886
+ }
11887
+ if (config.subagents.plan) {
11888
+ const currentConfig = subagentConfigs.get("plan");
11889
+ subagentConfigs.set("plan", { ...currentConfig, ...config.subagents.plan });
11890
+ }
11891
+ if (config.subagents.review) {
11892
+ const currentConfig = subagentConfigs.get("review");
11893
+ subagentConfigs.set("review", { ...currentConfig, ...config.subagents.review });
11894
+ }
11895
+ }
11896
+ const orchestrator = new SubagentOrchestrator({
11897
+ userId: config.userId,
11898
+ llm,
11899
+ logger: silentLogger,
11900
+ permissionManager,
11901
+ showPermissionPrompt: promptFn,
11902
+ configStore: state.configStore,
11903
+ apiClient,
11904
+ subagentConfigs
11905
+ });
11906
+ const subagentDelegateTool = createSubagentDelegateTool(orchestrator, newSession.id);
11907
+ const allTools = [...b4mTools, ...mcpTools, subagentDelegateTool];
11908
+ console.log(`\u{1F916} Subagent delegation enabled (explore, plan, review)`);
11851
11909
  const projectDir = state.configStore.getProjectConfigDir();
11852
11910
  const contextResult = await loadContextFiles(projectDir);
11853
11911
  if (contextResult.globalContext) {
@@ -11884,6 +11942,15 @@ FOR CODING TASKS:
11884
11942
  - When searching for code: Use grep_search or glob_files to find relevant files
11885
11943
  - Permission system will ask for approval before any file writes
11886
11944
 
11945
+ SUBAGENT DELEGATION:
11946
+ - You have access to specialized subagents via the subagent_delegate tool
11947
+ - Use subagents for focused exploration, planning, or review tasks:
11948
+ * explore: Fast read-only codebase search (e.g., "find all auth files", "locate API endpoints")
11949
+ * plan: Break down complex tasks into actionable steps
11950
+ * review: Analyze code quality and identify issues
11951
+ - Subagents keep the main conversation clean and run faster with optimized models
11952
+ - Delegate when you need to search extensively or analyze code structure
11953
+
11887
11954
  FOR GENERAL TASKS:
11888
11955
  - Use available tools to get information (weather, web search, calculations, etc.)
11889
11956
  - When user asks follow-up questions, use conversation context to understand what they're referring to
@@ -11894,6 +11961,7 @@ EXAMPLES:
11894
11961
  - "how about Japan?" \u2192 use weather tool for Japan (applying same question from context)
11895
11962
  - "enhance README" \u2192 file_read \u2192 generate \u2192 create_file
11896
11963
  - "what packages installed?" \u2192 glob_files "**/package.json" \u2192 file_read
11964
+ - "find all components using React hooks" \u2192 subagent_delegate(task="find all components using React hooks", type="explore")
11897
11965
 
11898
11966
  Remember: Use context from previous messages to understand follow-up questions.${contextSection}`;
11899
11967
  const maxIterations = config.preferences.maxIterations === null ? 999999 : config.preferences.maxIterations;
@@ -11940,164 +12008,8 @@ Remember: Use context from previous messages to understand follow-up questions.$
11940
12008
  useEffect3(() => {
11941
12009
  init();
11942
12010
  }, [init]);
11943
- const handleCustomCommandMessage = async (fullTemplate, displayMessage) => {
11944
- if (!state.agent || !state.session) {
11945
- console.error("\u274C Agent or session not initialized");
11946
- return;
11947
- }
11948
- const authTokens = await state.configStore.getAuthTokens();
11949
- if (!authTokens || new Date(authTokens.expiresAt) <= /* @__PURE__ */ new Date()) {
11950
- console.log("\n\u274C Authentication required to use AI features.");
11951
- console.log("\u{1F4A1} Run /login to authenticate with your B4M account.\n");
11952
- return;
11953
- }
11954
- useCliStore.getState().setIsThinking(true);
11955
- const currentSteps = [];
11956
- const stepHandler = (step) => {
11957
- currentSteps.push(step);
11958
- const currentSession = useCliStore.getState().session;
11959
- if (currentSession) {
11960
- const messages = [...currentSession.messages];
11961
- const lastMessage = messages[messages.length - 1];
11962
- if (lastMessage && lastMessage.role === "assistant") {
11963
- messages[messages.length - 1] = {
11964
- ...lastMessage,
11965
- metadata: {
11966
- ...lastMessage.metadata,
11967
- steps: [...currentSteps]
11968
- }
11969
- };
11970
- setStoreSession({
11971
- ...currentSession,
11972
- messages
11973
- });
11974
- }
11975
- }
11976
- };
11977
- state.agent.on("action", stepHandler);
11978
- try {
11979
- let messageContent = fullTemplate;
11980
- const userMessageContent = displayMessage;
11981
- if (state.messageBuilder && state.messageBuilder.hasImages(fullTemplate)) {
11982
- const { message: multimodalMessage } = await state.messageBuilder.buildMessage(fullTemplate);
11983
- messageContent = multimodalMessage.content;
11984
- }
11985
- const userMessage = {
11986
- role: "user",
11987
- content: userMessageContent,
11988
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
11989
- };
11990
- const pendingAssistantMessage = {
11991
- role: "assistant",
11992
- content: "...",
11993
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
11994
- metadata: {
11995
- steps: []
11996
- }
11997
- };
11998
- const sessionWithMessages = {
11999
- ...state.session,
12000
- messages: [...state.session.messages, userMessage, pendingAssistantMessage],
12001
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
12002
- };
12003
- setState((prev) => ({ ...prev, session: sessionWithMessages }));
12004
- setStoreSession(sessionWithMessages);
12005
- const recentMessages = state.session.messages.slice(-20);
12006
- const previousMessages = recentMessages.filter((msg) => msg.role === "user" || msg.role === "assistant").map((msg) => ({
12007
- role: msg.role,
12008
- content: msg.content
12009
- }));
12010
- const result = await state.agent.run(messageContent, {
12011
- previousMessages: previousMessages.length > 0 ? previousMessages : void 0
12012
- });
12013
- const permissionDenied = result.finalAnswer.startsWith("Permission denied for tool");
12014
- if (permissionDenied) {
12015
- console.log("\n\u26A0\uFE0F Action denied by user\n");
12016
- }
12017
- const successfulToolCalls = result.steps.filter((s) => s.type === "observation").length;
12018
- const currentSession = useCliStore.getState().session;
12019
- if (!currentSession) return;
12020
- const updatedMessages = [...currentSession.messages];
12021
- updatedMessages[updatedMessages.length - 1] = {
12022
- role: "assistant",
12023
- content: result.finalAnswer,
12024
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
12025
- metadata: {
12026
- steps: result.steps,
12027
- tokenUsage: {
12028
- prompt: 0,
12029
- completion: 0,
12030
- total: result.completionInfo.totalTokens
12031
- },
12032
- model: state.session.model,
12033
- permissionDenied
12034
- }
12035
- };
12036
- const finalSession = {
12037
- ...currentSession,
12038
- messages: updatedMessages,
12039
- updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
12040
- metadata: {
12041
- ...currentSession.metadata,
12042
- totalTokens: currentSession.metadata.totalTokens + result.completionInfo.totalTokens,
12043
- toolCallCount: currentSession.metadata.toolCallCount + successfulToolCalls
12044
- }
12045
- };
12046
- setState((prev) => ({ ...prev, session: finalSession }));
12047
- setStoreSession(finalSession);
12048
- await state.sessionStore.save(finalSession);
12049
- usageCache = null;
12050
- useCliStore.getState().setIsThinking(false);
12051
- } catch (error) {
12052
- useCliStore.getState().setIsThinking(false);
12053
- if (error?.message?.includes("Permission denied")) {
12054
- console.log("\n\u26A0\uFE0F Action blocked by permission settings");
12055
- const currentSession2 = useCliStore.getState().session;
12056
- if (!currentSession2) return;
12057
- const sessionWithDenied = { ...currentSession2 };
12058
- const messages2 = [...sessionWithDenied.messages];
12059
- const lastMessage2 = messages2[messages2.length - 1];
12060
- if (lastMessage2 && lastMessage2.role === "assistant") {
12061
- messages2[messages2.length - 1] = {
12062
- ...lastMessage2,
12063
- content: error.message,
12064
- metadata: {
12065
- ...lastMessage2.metadata,
12066
- permissionDenied: true
12067
- }
12068
- };
12069
- }
12070
- sessionWithDenied.messages = messages2;
12071
- setState((prev) => ({ ...prev, session: sessionWithDenied }));
12072
- setStoreSession(sessionWithDenied);
12073
- await state.sessionStore.save(sessionWithDenied);
12074
- return;
12075
- }
12076
- console.error("Error executing command:", error);
12077
- console.error(error.stack);
12078
- const currentSession = useCliStore.getState().session;
12079
- if (!currentSession) return;
12080
- const sessionWithError = { ...currentSession };
12081
- const messages = [...sessionWithError.messages];
12082
- const lastMessage = messages[messages.length - 1];
12083
- if (lastMessage && lastMessage.role === "assistant") {
12084
- messages[messages.length - 1] = {
12085
- ...lastMessage,
12086
- content: `\u274C Error: ${error.message || "Unknown error occurred"}`
12087
- };
12088
- }
12089
- sessionWithError.messages = messages;
12090
- setState((prev) => ({ ...prev, session: sessionWithError }));
12091
- setStoreSession(sessionWithError);
12092
- } finally {
12093
- state.agent.off("action", stepHandler);
12094
- }
12095
- };
12096
12011
  const handleMessage = async (message) => {
12097
- if (!state.agent || !state.session) {
12098
- console.error("\u274C Agent or session not initialized");
12099
- return;
12100
- }
12012
+ if (!state.agent || !state.session) return;
12101
12013
  await state.commandHistoryStore.add(message);
12102
12014
  const updatedHistory = await state.commandHistoryStore.list();
12103
12015
  setCommandHistory(updatedHistory);
@@ -12107,7 +12019,6 @@ Remember: Use context from previous messages to understand follow-up questions.$
12107
12019
  console.log("\u{1F4A1} Run /login to authenticate with your B4M account.\n");
12108
12020
  return;
12109
12021
  }
12110
- useCliStore.getState().setIsThinking(true);
12111
12022
  const currentSteps = [];
12112
12023
  const stepHandler = (step) => {
12113
12024
  currentSteps.push(step);
@@ -12303,48 +12214,8 @@ ${output}` : output.trim() || "(no output)",
12303
12214
  };
12304
12215
  };
12305
12216
  const handleCommand = async (command, args) => {
12306
- const customCommand = state.customCommandStore.getCommand(command);
12307
- if (customCommand) {
12308
- try {
12309
- const sourceIcon = customCommand.source === "global" ? "\u{1F3E0}" : "\u{1F4C1}";
12310
- console.log(`${sourceIcon} Executing custom command: /${command}`);
12311
- let substitutedBody = substituteArguments(customCommand.body, args);
12312
- const processed = await processFileReferences(substitutedBody);
12313
- substitutedBody = processed.content;
12314
- if (processed.errors.length > 0) {
12315
- processed.errors.forEach((error) => console.warn(`Warning: ${error}`));
12316
- }
12317
- if (process.env.B4M_VERBOSE === "1") {
12318
- console.log("\u{1F4DD} Expanded command:\n", substitutedBody);
12319
- }
12320
- const displayMessage = `/${command}${args.length > 0 ? " " + args.join(" ") : ""}`;
12321
- if (customCommand.model && state.agent) {
12322
- console.log(`\u{1F504} Using model override: ${customCommand.model}`);
12323
- const originalModel = state.session?.model;
12324
- if (state.session) {
12325
- state.session.model = customCommand.model;
12326
- }
12327
- await handleCustomCommandMessage(substitutedBody, displayMessage);
12328
- if (state.session && originalModel) {
12329
- state.session.model = originalModel;
12330
- }
12331
- } else {
12332
- console.log("\u{1F916} Sending to agent...\n");
12333
- await handleCustomCommandMessage(substitutedBody, displayMessage);
12334
- }
12335
- return;
12336
- } catch (error) {
12337
- console.error(
12338
- `\u274C Failed to execute custom command /${command}:`,
12339
- error instanceof Error ? error.message : String(error)
12340
- );
12341
- return;
12342
- }
12343
- }
12344
12217
  switch (command) {
12345
- case "help": {
12346
- const customCommands = state.customCommandStore.getAllCommands();
12347
- const hasCustomCommands = customCommands.length > 0;
12218
+ case "help":
12348
12219
  console.log(`
12349
12220
  Available commands:
12350
12221
  /help - Show this help message
@@ -12371,19 +12242,8 @@ Tool Permissions:
12371
12242
 
12372
12243
  Project Configuration:
12373
12244
  /project-config - Show merged project configuration
12374
-
12375
- Custom Commands:
12376
- /commands - List all custom commands
12377
- /commands:new <name> - Create a new custom command
12378
- /commands:reload - Reload custom commands from disk${hasCustomCommands ? "\n\n\u{1F4DD} Custom Commands Available:" : ""}${hasCustomCommands ? customCommands.map((cmd) => {
12379
- const source = cmd.source === "global" ? "\u{1F3E0}" : "\u{1F4C1}";
12380
- const argHint = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
12381
- return `
12382
- ${source} /${cmd.name}${argHint} - ${cmd.description}`;
12383
- }).join("") : ""}
12384
12245
  `);
12385
12246
  break;
12386
- }
12387
12247
  case "exit":
12388
12248
  case "quit":
12389
12249
  logger.debug("[EXIT /exit command - cleaning up and exiting...");
@@ -12871,71 +12731,6 @@ No usage data available for the last ${USAGE_DAYS} days.`);
12871
12731
  console.log("");
12872
12732
  break;
12873
12733
  }
12874
- case "commands": {
12875
- const customCommands = state.customCommandStore.getAllCommands();
12876
- const globalCommands = state.customCommandStore.getCommandsBySource("global");
12877
- const projectCommands = state.customCommandStore.getCommandsBySource("project");
12878
- console.log("\n\u{1F4DD} Custom Commands:\n");
12879
- if (customCommands.length === 0) {
12880
- console.log("No custom commands found.");
12881
- console.log("\nTo create a custom command:");
12882
- console.log(" /commands:new <name> - Create a new command");
12883
- console.log("\nCustom commands can be stored in:");
12884
- console.log(" \u{1F3E0} Global: ~/.bike4mind/commands/ (available in all projects)");
12885
- console.log(" \u{1F4C1} Project: .bike4mind/commands/ (team-shared, committed to git)");
12886
- } else {
12887
- if (globalCommands.length > 0) {
12888
- console.log("\u{1F3E0} Global Commands (~/.bike4mind/commands/):");
12889
- globalCommands.forEach((cmd) => {
12890
- const argHint = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
12891
- console.log(` /${cmd.name}${argHint} - ${cmd.description}`);
12892
- });
12893
- console.log("");
12894
- }
12895
- if (projectCommands.length > 0) {
12896
- console.log("\u{1F4C1} Project Commands (.bike4mind/commands/):");
12897
- projectCommands.forEach((cmd) => {
12898
- const argHint = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
12899
- console.log(` /${cmd.name}${argHint} - ${cmd.description}`);
12900
- });
12901
- console.log("");
12902
- }
12903
- console.log(`Total: ${customCommands.length} custom command${customCommands.length !== 1 ? "s" : ""}`);
12904
- }
12905
- console.log("");
12906
- break;
12907
- }
12908
- case "commands:new": {
12909
- const commandName = args[0];
12910
- if (!commandName) {
12911
- console.log("\u274C Please provide a command name");
12912
- console.log("Usage: /commands:new <name>");
12913
- break;
12914
- }
12915
- console.log("\nWhere should this command be stored?");
12916
- console.log(" 1. \u{1F3E0} Global (~/.bike4mind/commands/) - available in all projects");
12917
- console.log(" 2. \u{1F4C1} Project (.bike4mind/commands/) - team-shared");
12918
- console.log("\nDefaulting to global. Creating command file...");
12919
- try {
12920
- const filePath = await state.customCommandStore.createCommandFile(commandName, true);
12921
- console.log(`\u2705 Created command file: ${filePath}`);
12922
- console.log("\nEdit this file to customize your command.");
12923
- console.log("Then run: /commands:reload to load it");
12924
- } catch (error) {
12925
- console.error("\u274C Failed to create command file:", error instanceof Error ? error.message : String(error));
12926
- }
12927
- break;
12928
- }
12929
- case "commands:reload": {
12930
- try {
12931
- await state.customCommandStore.reloadCommands();
12932
- const count = state.customCommandStore.getCommandCount();
12933
- console.log(`\u2705 Reloaded ${count} custom command${count !== 1 ? "s" : ""}`);
12934
- } catch (error) {
12935
- console.error("\u274C Failed to reload commands:", error instanceof Error ? error.message : String(error));
12936
- }
12937
- break;
12938
- }
12939
12734
  default:
12940
12735
  console.log(`Unknown command: /${command}`);
12941
12736
  console.log("Type /help for available commands");
@@ -13032,7 +12827,6 @@ No usage data available for the last ${USAGE_DAYS} days.`);
13032
12827
  if (!isInitialized) {
13033
12828
  return /* @__PURE__ */ React17.createElement(Box16, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React17.createElement(Text16, null, "\u{1F680} Initializing..."));
13034
12829
  }
13035
- const allCommands = mergeCommands(state.customCommandStore.getAllCommands());
13036
12830
  return /* @__PURE__ */ React17.createElement(
13037
12831
  App,
13038
12832
  {
@@ -13041,7 +12835,6 @@ No usage data available for the last ${USAGE_DAYS} days.`);
13041
12835
  onBashCommand: handleBashCommand,
13042
12836
  onImageDetected: handleImageDetected,
13043
12837
  commandHistory,
13044
- commands: allCommands,
13045
12838
  config: state.config,
13046
12839
  availableModels: state.availableModels,
13047
12840
  onSaveConfig: handleSaveConfig,