@bike4mind/cli 0.2.10-fix-b4m-cli-flicker.17243 → 0.2.10-fix-cli-duplicate-chat-history.17269
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2059 -1028
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -210,7 +210,8 @@ function CommandAutocomplete({ commands, selectedIndex }) {
|
|
|
210
210
|
return /* @__PURE__ */ React3.createElement(Box2, { flexDirection: "column", marginLeft: 2, marginTop: 1 }, /* @__PURE__ */ React3.createElement(Box2, { marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, commands.length === 1 ? "1 command" : `${commands.length} commands`, " \u2022 Use \u2191\u2193 to navigate, Enter to select")), commands.map((cmd, index) => {
|
|
211
211
|
const args = cmd.args ? ` ${cmd.args}` : "";
|
|
212
212
|
const isSelected = index === selectedIndex;
|
|
213
|
-
|
|
213
|
+
const sourceIcon = cmd.source === "global" ? "\u{1F3E0} " : cmd.source === "project" ? "\u{1F4C1} " : cmd.source === "built-in" ? "\u{1F527} " : "";
|
|
214
|
+
return /* @__PURE__ */ React3.createElement(Box2, { key: cmd.name, marginLeft: 1 }, /* @__PURE__ */ React3.createElement(Text3, { color: isSelected ? "cyan" : void 0, bold: isSelected }, isSelected ? "\u25B8 " : " ", sourceIcon, "/", cmd.name, args, " - ", cmd.description));
|
|
214
215
|
}));
|
|
215
216
|
}
|
|
216
217
|
|
|
@@ -311,7 +312,7 @@ function searchFiles(query) {
|
|
|
311
312
|
searchPool = files;
|
|
312
313
|
}
|
|
313
314
|
}
|
|
314
|
-
const
|
|
315
|
+
const fuse = new Fuse(searchPool, {
|
|
315
316
|
keys: [{ name: "path", weight: 1 }],
|
|
316
317
|
threshold: 0.4,
|
|
317
318
|
// Allow some fuzzy matching
|
|
@@ -320,7 +321,7 @@ function searchFiles(query) {
|
|
|
320
321
|
// Use extended search for better path matching
|
|
321
322
|
useExtendedSearch: false
|
|
322
323
|
});
|
|
323
|
-
const results =
|
|
324
|
+
const results = fuse.search(query);
|
|
324
325
|
return results.slice(0, 20).map((result) => result.item);
|
|
325
326
|
}
|
|
326
327
|
function isPathWithinCwd(filePath) {
|
|
@@ -495,11 +496,61 @@ var COMMANDS = [
|
|
|
495
496
|
name: "rewind",
|
|
496
497
|
description: "Rewind conversation to a previous point",
|
|
497
498
|
aliases: ["undo"]
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
name: "project-config",
|
|
502
|
+
description: "Show merged project configuration"
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
name: "commands",
|
|
506
|
+
description: "List all custom commands"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
name: "commands:new",
|
|
510
|
+
description: "Create a new custom command",
|
|
511
|
+
args: "<name>"
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
name: "commands:reload",
|
|
515
|
+
description: "Reload custom commands from disk"
|
|
498
516
|
}
|
|
499
517
|
];
|
|
518
|
+
function getAllCommandNames() {
|
|
519
|
+
const names = [];
|
|
520
|
+
for (const cmd of COMMANDS) {
|
|
521
|
+
names.push(cmd.name);
|
|
522
|
+
if (cmd.aliases) {
|
|
523
|
+
names.push(...cmd.aliases);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return names;
|
|
527
|
+
}
|
|
528
|
+
function isBuiltInCommand(name) {
|
|
529
|
+
return getAllCommandNames().includes(name);
|
|
530
|
+
}
|
|
531
|
+
function customCommandToDefinition(customCommand) {
|
|
532
|
+
return {
|
|
533
|
+
name: customCommand.name,
|
|
534
|
+
description: customCommand.description,
|
|
535
|
+
args: customCommand.argumentHint,
|
|
536
|
+
source: customCommand.source
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function mergeCommands(customCommands) {
|
|
540
|
+
const builtInCommands = COMMANDS.map((cmd) => ({ ...cmd, source: "built-in" }));
|
|
541
|
+
const customDefinitions = customCommands.filter((cmd) => !isBuiltInCommand(cmd.name)).map(customCommandToDefinition);
|
|
542
|
+
const conflicts = customCommands.filter((cmd) => isBuiltInCommand(cmd.name));
|
|
543
|
+
if (conflicts.length > 0) {
|
|
544
|
+
console.warn(
|
|
545
|
+
"Warning: The following custom commands have names that conflict with built-in commands and will be ignored:",
|
|
546
|
+
conflicts.map((cmd) => cmd.name).join(", ")
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
return [...builtInCommands, ...customDefinitions];
|
|
550
|
+
}
|
|
500
551
|
|
|
501
552
|
// src/utils/fuzzySearch.ts
|
|
502
|
-
var
|
|
553
|
+
var fuseOptions = {
|
|
503
554
|
keys: [
|
|
504
555
|
{ name: "name", weight: 0.7 },
|
|
505
556
|
// Prioritize command name
|
|
@@ -510,11 +561,12 @@ var fuse = new Fuse2(COMMANDS, {
|
|
|
510
561
|
// 0 = perfect match, 1 = match anything
|
|
511
562
|
includeScore: true,
|
|
512
563
|
minMatchCharLength: 1
|
|
513
|
-
}
|
|
514
|
-
function searchCommands(query) {
|
|
564
|
+
};
|
|
565
|
+
function searchCommands(query, commands = COMMANDS) {
|
|
515
566
|
if (!query || query.trim() === "") {
|
|
516
|
-
return
|
|
567
|
+
return commands;
|
|
517
568
|
}
|
|
569
|
+
const fuse = new Fuse2(commands, fuseOptions);
|
|
518
570
|
const results = fuse.search(query);
|
|
519
571
|
return results.map((result) => result.item);
|
|
520
572
|
}
|
|
@@ -737,6 +789,7 @@ function InputPrompt({
|
|
|
737
789
|
onImageDetected,
|
|
738
790
|
disabled = false,
|
|
739
791
|
history = [],
|
|
792
|
+
commands = [],
|
|
740
793
|
prefillInput,
|
|
741
794
|
onPrefillConsumed,
|
|
742
795
|
onBashModeChange
|
|
@@ -762,8 +815,8 @@ function InputPrompt({
|
|
|
762
815
|
const commandQuery = shouldShowCommandAutocomplete ? value.slice(1) : "";
|
|
763
816
|
const filteredCommands = useMemo(() => {
|
|
764
817
|
if (!shouldShowCommandAutocomplete) return [];
|
|
765
|
-
return searchCommands(commandQuery);
|
|
766
|
-
}, [shouldShowCommandAutocomplete, commandQuery]);
|
|
818
|
+
return searchCommands(commandQuery, commands);
|
|
819
|
+
}, [shouldShowCommandAutocomplete, commandQuery, commands]);
|
|
767
820
|
const filteredFiles = useMemo(() => {
|
|
768
821
|
if (!fileAutocomplete?.active) return [];
|
|
769
822
|
return searchFiles(fileAutocomplete.query);
|
|
@@ -1414,6 +1467,7 @@ function App({
|
|
|
1414
1467
|
onPermissionResponse,
|
|
1415
1468
|
onImageDetected,
|
|
1416
1469
|
commandHistory = [],
|
|
1470
|
+
commands = [],
|
|
1417
1471
|
config,
|
|
1418
1472
|
availableModels = [],
|
|
1419
1473
|
onSaveConfig,
|
|
@@ -1469,7 +1523,7 @@ ${errorBlock}`;
|
|
|
1469
1523
|
onSave: onSaveConfig,
|
|
1470
1524
|
onClose: () => setShowConfigEditor(false)
|
|
1471
1525
|
}
|
|
1472
|
-
)) : permissionPrompt
|
|
1526
|
+
)) : /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Static, { items: messages }, (message, index) => /* @__PURE__ */ React11.createElement(Box10, { key: `${message.timestamp}-${message.role}-${index}`, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(MessageItem, { message }))), /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column" }, pendingMessages.map((message, index) => /* @__PURE__ */ React11.createElement(Box10, { key: `pending-${message.timestamp}-${index}`, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(MessageItem, { message })))), permissionPrompt && /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(
|
|
1473
1527
|
PermissionPrompt,
|
|
1474
1528
|
{
|
|
1475
1529
|
toolName: permissionPrompt.toolName,
|
|
@@ -1478,7 +1532,7 @@ ${errorBlock}`;
|
|
|
1478
1532
|
canBeTrusted: permissionPrompt.canBeTrusted,
|
|
1479
1533
|
onResponse: onPermissionResponse
|
|
1480
1534
|
}
|
|
1481
|
-
))
|
|
1535
|
+
)), /* @__PURE__ */ React11.createElement(AgentThinking, null), exitRequested && /* @__PURE__ */ React11.createElement(Box10, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React11.createElement(Text10, { color: "yellow", bold: true }, "Press Ctrl+C again to exit")), /* @__PURE__ */ React11.createElement(Box10, { borderStyle: "single", borderColor: isBashMode ? "yellow" : "cyan", paddingX: 1 }, /* @__PURE__ */ React11.createElement(
|
|
1482
1536
|
InputPrompt,
|
|
1483
1537
|
{
|
|
1484
1538
|
onSubmit: handleSubmit,
|
|
@@ -1486,6 +1540,7 @@ ${errorBlock}`;
|
|
|
1486
1540
|
onImageDetected,
|
|
1487
1541
|
disabled: isThinking,
|
|
1488
1542
|
history: commandHistory,
|
|
1543
|
+
commands,
|
|
1489
1544
|
prefillInput,
|
|
1490
1545
|
onPrefillConsumed,
|
|
1491
1546
|
onBashModeChange: setIsBashMode
|
|
@@ -2708,6 +2763,261 @@ var CommandHistoryStore = class {
|
|
|
2708
2763
|
}
|
|
2709
2764
|
};
|
|
2710
2765
|
|
|
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
|
+
|
|
2711
3021
|
// ../../b4m-core/packages/agents/src/ReActAgent.ts
|
|
2712
3022
|
import { EventEmitter } from "events";
|
|
2713
3023
|
var ReActAgent = class extends EventEmitter {
|
|
@@ -3021,38 +3331,38 @@ Remember: You are an autonomous AGENT. Act independently and solve problems proa
|
|
|
3021
3331
|
// ../../b4m-core/packages/services/dist/src/referService/generateCodes.js
|
|
3022
3332
|
import { randomBytes } from "crypto";
|
|
3023
3333
|
import range from "lodash/range.js";
|
|
3024
|
-
import { z as
|
|
3025
|
-
var generateReferralCodesSchema =
|
|
3026
|
-
count:
|
|
3027
|
-
unlimitedUse:
|
|
3028
|
-
expiresAt:
|
|
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()
|
|
3029
3339
|
});
|
|
3030
3340
|
|
|
3031
3341
|
// ../../b4m-core/packages/services/dist/src/referService/delete.js
|
|
3032
|
-
import { z as
|
|
3033
|
-
var deleteInviteCodesSchema =
|
|
3034
|
-
ids:
|
|
3342
|
+
import { z as z4 } from "zod";
|
|
3343
|
+
var deleteInviteCodesSchema = z4.object({
|
|
3344
|
+
ids: z4.array(z4.string())
|
|
3035
3345
|
});
|
|
3036
3346
|
|
|
3037
3347
|
// ../../b4m-core/packages/services/dist/src/userService/login.js
|
|
3038
|
-
import { z as
|
|
3348
|
+
import { z as z5 } from "zod";
|
|
3039
3349
|
import bcrypt from "bcryptjs";
|
|
3040
|
-
var loginUserSchema =
|
|
3041
|
-
usernameOrEmail:
|
|
3042
|
-
password:
|
|
3043
|
-
metadata:
|
|
3044
|
-
loginTime:
|
|
3045
|
-
userAgent:
|
|
3046
|
-
browser:
|
|
3047
|
-
operatingSystem:
|
|
3048
|
-
deviceType:
|
|
3049
|
-
screenResolution:
|
|
3050
|
-
viewportSize:
|
|
3051
|
-
colorDepth:
|
|
3052
|
-
pixelDepth:
|
|
3053
|
-
devicePixelRatio:
|
|
3054
|
-
ip:
|
|
3055
|
-
location:
|
|
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()
|
|
3056
3366
|
}).optional()
|
|
3057
3367
|
});
|
|
3058
3368
|
|
|
@@ -3062,78 +3372,78 @@ import escapeRegExp from "lodash/escapeRegExp.js";
|
|
|
3062
3372
|
|
|
3063
3373
|
// ../../b4m-core/packages/services/dist/src/userService/forgotPassword.js
|
|
3064
3374
|
import { randomUUID } from "crypto";
|
|
3065
|
-
import { z as
|
|
3066
|
-
var forgotPasswordUserSchema =
|
|
3067
|
-
email:
|
|
3375
|
+
import { z as z6 } from "zod";
|
|
3376
|
+
var forgotPasswordUserSchema = z6.object({
|
|
3377
|
+
email: z6.string().email()
|
|
3068
3378
|
});
|
|
3069
3379
|
|
|
3070
3380
|
// ../../b4m-core/packages/services/dist/src/userService/update.js
|
|
3071
3381
|
import bcrypt3 from "bcryptjs";
|
|
3072
|
-
import { z as
|
|
3073
|
-
var updateUserSchema =
|
|
3074
|
-
name:
|
|
3075
|
-
username:
|
|
3382
|
+
import { z as z7 } from "zod";
|
|
3383
|
+
var updateUserSchema = z7.object({
|
|
3384
|
+
name: z7.string().optional(),
|
|
3385
|
+
username: z7.string().optional(),
|
|
3076
3386
|
// email field removed - users must use the secure email change verification flow
|
|
3077
3387
|
// See requestEmailChange and verifyEmailChange in userService
|
|
3078
|
-
password:
|
|
3079
|
-
team:
|
|
3080
|
-
role:
|
|
3081
|
-
phone:
|
|
3082
|
-
preferredLanguage:
|
|
3083
|
-
preferredContact:
|
|
3084
|
-
preferredVoice:
|
|
3085
|
-
tshirtSize:
|
|
3086
|
-
geoLocation:
|
|
3087
|
-
lastNotebookId:
|
|
3088
|
-
tags:
|
|
3089
|
-
lastCreditsPurchasedAt:
|
|
3090
|
-
systemFiles:
|
|
3091
|
-
fileId:
|
|
3092
|
-
enabled:
|
|
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()
|
|
3093
3403
|
})).nullable().optional(),
|
|
3094
|
-
securityQuestions:
|
|
3095
|
-
photoUrl:
|
|
3096
|
-
showCreditsUsed:
|
|
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()
|
|
3097
3407
|
});
|
|
3098
3408
|
|
|
3099
3409
|
// ../../b4m-core/packages/services/dist/src/userService/adminUpdate.js
|
|
3100
|
-
import { z as
|
|
3410
|
+
import { z as z9 } from "zod";
|
|
3101
3411
|
|
|
3102
3412
|
// ../../b4m-core/packages/services/dist/src/friendshipService/sendFriendRequest.js
|
|
3103
|
-
import { z as
|
|
3104
|
-
var sendFriendRequestSchema =
|
|
3105
|
-
requesterId:
|
|
3106
|
-
recipientId:
|
|
3107
|
-
message:
|
|
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()
|
|
3108
3418
|
});
|
|
3109
3419
|
|
|
3110
3420
|
// ../../b4m-core/packages/services/dist/src/userService/adminUpdate.js
|
|
3111
3421
|
var adminUpdateUserSchema = updateUserSchema.extend({
|
|
3112
|
-
id:
|
|
3422
|
+
id: z9.string(),
|
|
3113
3423
|
// Admins can directly update email addresses without verification
|
|
3114
|
-
email:
|
|
3115
|
-
role:
|
|
3116
|
-
isAdmin:
|
|
3117
|
-
organizationId:
|
|
3118
|
-
storageLimit:
|
|
3119
|
-
currentCredits:
|
|
3120
|
-
isBanned:
|
|
3121
|
-
isModerated:
|
|
3122
|
-
subscribedUntil:
|
|
3123
|
-
systemFiles:
|
|
3124
|
-
level:
|
|
3125
|
-
lastNotebookId:
|
|
3126
|
-
userNotes:
|
|
3127
|
-
numReferralsAvailable:
|
|
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()
|
|
3128
3438
|
});
|
|
3129
3439
|
|
|
3130
3440
|
// ../../b4m-core/packages/services/dist/src/userService/register.js
|
|
3131
|
-
import { z as
|
|
3441
|
+
import { z as z11 } from "zod";
|
|
3132
3442
|
import bcrypt4 from "bcryptjs";
|
|
3133
3443
|
|
|
3134
3444
|
// ../../b4m-core/packages/services/dist/src/creditService/addCredits.js
|
|
3135
|
-
import { z as
|
|
3136
|
-
var AddCreditsSchema =
|
|
3445
|
+
import { z as z10 } from "zod";
|
|
3446
|
+
var AddCreditsSchema = z10.discriminatedUnion("type", [
|
|
3137
3447
|
PurchaseTransaction.omit({ createdAt: true, updatedAt: true }),
|
|
3138
3448
|
SubscriptionCreditTransaction.omit({ createdAt: true, updatedAt: true }),
|
|
3139
3449
|
GenericCreditAddTransaction.omit({ createdAt: true, updatedAt: true }),
|
|
@@ -3141,57 +3451,57 @@ var AddCreditsSchema = z9.discriminatedUnion("type", [
|
|
|
3141
3451
|
]);
|
|
3142
3452
|
|
|
3143
3453
|
// ../../b4m-core/packages/services/dist/src/userService/register.js
|
|
3144
|
-
var registerUserSchema =
|
|
3145
|
-
username:
|
|
3146
|
-
email:
|
|
3147
|
-
name:
|
|
3148
|
-
inviteCode:
|
|
3149
|
-
password:
|
|
3150
|
-
metadata:
|
|
3151
|
-
loginTime:
|
|
3152
|
-
userAgent:
|
|
3153
|
-
browser:
|
|
3154
|
-
operatingSystem:
|
|
3155
|
-
deviceType:
|
|
3156
|
-
screenResolution:
|
|
3157
|
-
viewportSize:
|
|
3158
|
-
colorDepth:
|
|
3159
|
-
pixelDepth:
|
|
3160
|
-
devicePixelRatio:
|
|
3161
|
-
ip:
|
|
3162
|
-
location:
|
|
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()
|
|
3163
3473
|
}).optional()
|
|
3164
3474
|
});
|
|
3165
3475
|
|
|
3166
3476
|
// ../../b4m-core/packages/services/dist/src/userService/adminDelete.js
|
|
3167
|
-
import { z as
|
|
3168
|
-
var adminDeleteUserSchema =
|
|
3169
|
-
id:
|
|
3477
|
+
import { z as z12 } from "zod";
|
|
3478
|
+
var adminDeleteUserSchema = z12.object({
|
|
3479
|
+
id: z12.string()
|
|
3170
3480
|
});
|
|
3171
3481
|
|
|
3172
3482
|
// ../../b4m-core/packages/services/dist/src/userService/searchUserCollection.js
|
|
3173
|
-
import { z as
|
|
3174
|
-
var searchUserCollectionSchema =
|
|
3175
|
-
userId:
|
|
3176
|
-
page:
|
|
3177
|
-
limit:
|
|
3178
|
-
search:
|
|
3179
|
-
type:
|
|
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()
|
|
3180
3490
|
});
|
|
3181
3491
|
|
|
3182
3492
|
// ../../b4m-core/packages/services/dist/src/userService/recalculateUserStorage.js
|
|
3183
|
-
import { z as
|
|
3184
|
-
var recalculateUserStorageSchema =
|
|
3493
|
+
import { z as z14 } from "zod";
|
|
3494
|
+
var recalculateUserStorageSchema = z14.object({
|
|
3185
3495
|
/**
|
|
3186
3496
|
* The user to recalculate the storage for
|
|
3187
3497
|
*/
|
|
3188
|
-
userId:
|
|
3498
|
+
userId: z14.string()
|
|
3189
3499
|
});
|
|
3190
3500
|
|
|
3191
3501
|
// ../../b4m-core/packages/services/dist/src/userService/listRecentActivities.js
|
|
3192
|
-
import { z as
|
|
3193
|
-
var listRecentActivitiesSchema =
|
|
3194
|
-
coverage:
|
|
3502
|
+
import { z as z15 } from "zod";
|
|
3503
|
+
var listRecentActivitiesSchema = z15.object({
|
|
3504
|
+
coverage: z15.enum(["all", "important"]).default("important")
|
|
3195
3505
|
});
|
|
3196
3506
|
var IMPORTANT_COUNTER_NAMES = [
|
|
3197
3507
|
SessionEvents.CREATE_SESSION,
|
|
@@ -3205,82 +3515,82 @@ var IMPORTANT_COUNTER_NAMES = [
|
|
|
3205
3515
|
|
|
3206
3516
|
// ../../b4m-core/packages/services/dist/src/userService/sendEmailVerification.js
|
|
3207
3517
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
3208
|
-
import { z as
|
|
3209
|
-
var sendEmailVerificationSchema =
|
|
3210
|
-
userId:
|
|
3518
|
+
import { z as z16 } from "zod";
|
|
3519
|
+
var sendEmailVerificationSchema = z16.object({
|
|
3520
|
+
userId: z16.string()
|
|
3211
3521
|
});
|
|
3212
3522
|
|
|
3213
3523
|
// ../../b4m-core/packages/services/dist/src/userService/verifyEmailToken.js
|
|
3214
|
-
import { z as
|
|
3524
|
+
import { z as z17 } from "zod";
|
|
3215
3525
|
|
|
3216
3526
|
// ../../b4m-core/packages/services/dist/src/utils/crypto.js
|
|
3217
3527
|
import crypto from "crypto";
|
|
3218
3528
|
|
|
3219
3529
|
// ../../b4m-core/packages/services/dist/src/userService/verifyEmailToken.js
|
|
3220
|
-
var verifyEmailTokenSchema =
|
|
3221
|
-
token:
|
|
3530
|
+
var verifyEmailTokenSchema = z17.object({
|
|
3531
|
+
token: z17.string()
|
|
3222
3532
|
});
|
|
3223
3533
|
|
|
3224
3534
|
// ../../b4m-core/packages/services/dist/src/userService/resendEmailVerification.js
|
|
3225
3535
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
3226
|
-
import { z as
|
|
3227
|
-
var resendEmailVerificationSchema =
|
|
3228
|
-
userId:
|
|
3536
|
+
import { z as z18 } from "zod";
|
|
3537
|
+
var resendEmailVerificationSchema = z18.object({
|
|
3538
|
+
userId: z18.string()
|
|
3229
3539
|
});
|
|
3230
3540
|
|
|
3231
3541
|
// ../../b4m-core/packages/services/dist/src/userService/requestEmailChange.js
|
|
3232
3542
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
3233
|
-
import { z as
|
|
3234
|
-
var requestEmailChangeSchema =
|
|
3235
|
-
userId:
|
|
3236
|
-
newEmail:
|
|
3237
|
-
password:
|
|
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()
|
|
3238
3548
|
});
|
|
3239
3549
|
|
|
3240
3550
|
// ../../b4m-core/packages/services/dist/src/userService/verifyEmailChange.js
|
|
3241
|
-
import { z as
|
|
3242
|
-
var verifyEmailChangeSchema =
|
|
3243
|
-
token:
|
|
3551
|
+
import { z as z20 } from "zod";
|
|
3552
|
+
var verifyEmailChangeSchema = z20.object({
|
|
3553
|
+
token: z20.string()
|
|
3244
3554
|
});
|
|
3245
3555
|
|
|
3246
3556
|
// ../../b4m-core/packages/services/dist/src/userService/cancelEmailChange.js
|
|
3247
|
-
import { z as
|
|
3248
|
-
var cancelEmailChangeSchema =
|
|
3249
|
-
userId:
|
|
3557
|
+
import { z as z21 } from "zod";
|
|
3558
|
+
var cancelEmailChangeSchema = z21.object({
|
|
3559
|
+
userId: z21.string()
|
|
3250
3560
|
});
|
|
3251
3561
|
|
|
3252
3562
|
// ../../b4m-core/packages/services/dist/src/userApiKeyService/create.js
|
|
3253
3563
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
3254
3564
|
import bcrypt5 from "bcryptjs";
|
|
3255
|
-
import { z as
|
|
3256
|
-
var createUserApiKeySchema =
|
|
3257
|
-
name:
|
|
3258
|
-
scopes:
|
|
3259
|
-
expiresAt:
|
|
3260
|
-
rateLimit:
|
|
3261
|
-
requestsPerMinute:
|
|
3262
|
-
requestsPerDay:
|
|
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)
|
|
3263
3573
|
}).optional(),
|
|
3264
|
-
metadata:
|
|
3265
|
-
clientIP:
|
|
3266
|
-
userAgent:
|
|
3267
|
-
createdFrom:
|
|
3574
|
+
metadata: z22.object({
|
|
3575
|
+
clientIP: z22.string().optional(),
|
|
3576
|
+
userAgent: z22.string().optional(),
|
|
3577
|
+
createdFrom: z22.enum(["dashboard", "cli", "api"])
|
|
3268
3578
|
})
|
|
3269
3579
|
});
|
|
3270
3580
|
|
|
3271
3581
|
// ../../b4m-core/packages/services/dist/src/userApiKeyService/revoke.js
|
|
3272
|
-
import { z as
|
|
3273
|
-
var revokeUserApiKeySchema =
|
|
3274
|
-
keyId:
|
|
3275
|
-
reason:
|
|
3582
|
+
import { z as z23 } from "zod";
|
|
3583
|
+
var revokeUserApiKeySchema = z23.object({
|
|
3584
|
+
keyId: z23.string(),
|
|
3585
|
+
reason: z23.string().optional()
|
|
3276
3586
|
});
|
|
3277
3587
|
|
|
3278
3588
|
// ../../b4m-core/packages/services/dist/src/userApiKeyService/rotate.js
|
|
3279
3589
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
3280
3590
|
import bcrypt6 from "bcryptjs";
|
|
3281
|
-
import { z as
|
|
3282
|
-
var rotateUserApiKeySchema =
|
|
3283
|
-
keyId:
|
|
3591
|
+
import { z as z24 } from "zod";
|
|
3592
|
+
var rotateUserApiKeySchema = z24.object({
|
|
3593
|
+
keyId: z24.string()
|
|
3284
3594
|
});
|
|
3285
3595
|
|
|
3286
3596
|
// ../../b4m-core/packages/services/dist/src/userApiKeyService/validate.js
|
|
@@ -3427,29 +3737,29 @@ var EVENT_GROUPS = [
|
|
|
3427
3737
|
];
|
|
3428
3738
|
|
|
3429
3739
|
// ../../b4m-core/packages/services/dist/src/countersService/generateReport.js
|
|
3430
|
-
import { z as
|
|
3740
|
+
import { z as z26 } from "zod";
|
|
3431
3741
|
|
|
3432
3742
|
// ../../b4m-core/packages/services/dist/src/countersService/getAllCounterFrom24Hours.js
|
|
3433
|
-
import { z as
|
|
3743
|
+
import { z as z25 } from "zod";
|
|
3434
3744
|
import dayjs2 from "dayjs";
|
|
3435
|
-
var getCounterTotalsForLast24HoursSchema =
|
|
3436
|
-
date:
|
|
3437
|
-
endDate:
|
|
3745
|
+
var getCounterTotalsForLast24HoursSchema = z25.object({
|
|
3746
|
+
date: z25.string(),
|
|
3747
|
+
endDate: z25.string().optional()
|
|
3438
3748
|
});
|
|
3439
3749
|
|
|
3440
3750
|
// ../../b4m-core/packages/services/dist/src/countersService/generateReport.js
|
|
3441
|
-
var generateDailyReportSchema =
|
|
3442
|
-
date:
|
|
3443
|
-
startDate:
|
|
3444
|
-
endDate:
|
|
3751
|
+
var generateDailyReportSchema = z26.object({
|
|
3752
|
+
date: z26.string(),
|
|
3753
|
+
startDate: z26.string().optional(),
|
|
3754
|
+
endDate: z26.string().optional()
|
|
3445
3755
|
});
|
|
3446
3756
|
|
|
3447
3757
|
// ../../b4m-core/packages/services/dist/src/countersService/incrementUserCounter.js
|
|
3448
|
-
import { z as
|
|
3449
|
-
var incrementUserCounterSchema =
|
|
3450
|
-
action:
|
|
3451
|
-
increment:
|
|
3452
|
-
metadata:
|
|
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()
|
|
3453
3763
|
});
|
|
3454
3764
|
|
|
3455
3765
|
// ../../b4m-core/packages/services/dist/src/countersService/sendSlackReport.js
|
|
@@ -3465,47 +3775,47 @@ import { GoogleGenerativeAI } from "@google/generative-ai";
|
|
|
3465
3775
|
import OpenAI2 from "openai";
|
|
3466
3776
|
|
|
3467
3777
|
// ../../b4m-core/packages/services/dist/src/importHistoryService/index.js
|
|
3468
|
-
import
|
|
3778
|
+
import fs7, { unlinkSync } from "fs";
|
|
3469
3779
|
import yauzl from "yauzl";
|
|
3470
3780
|
import axios3 from "axios";
|
|
3471
3781
|
|
|
3472
3782
|
// ../../b4m-core/packages/services/dist/src/importHistoryService/importOpenaiHistory.js
|
|
3473
|
-
import { z as
|
|
3783
|
+
import { z as z28 } from "zod";
|
|
3474
3784
|
import last from "lodash/last.js";
|
|
3475
|
-
var epochDate = () =>
|
|
3476
|
-
var openaiConversationSchema =
|
|
3477
|
-
id:
|
|
3478
|
-
title:
|
|
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(),
|
|
3479
3789
|
create_time: epochDate(),
|
|
3480
3790
|
update_time: epochDate().nullable(),
|
|
3481
|
-
mapping:
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
id:
|
|
3485
|
-
parent:
|
|
3486
|
-
children:
|
|
3487
|
-
message:
|
|
3488
|
-
id:
|
|
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(),
|
|
3489
3799
|
create_time: epochDate(),
|
|
3490
3800
|
update_time: epochDate().nullable(),
|
|
3491
|
-
author:
|
|
3492
|
-
role:
|
|
3493
|
-
name:
|
|
3494
|
-
metadata:
|
|
3801
|
+
author: z28.object({
|
|
3802
|
+
role: z28.string(),
|
|
3803
|
+
name: z28.string().nullable(),
|
|
3804
|
+
metadata: z28.any()
|
|
3495
3805
|
// Accept any metadata structure
|
|
3496
3806
|
}).passthrough(),
|
|
3497
3807
|
// Allow extra fields in author
|
|
3498
|
-
content:
|
|
3499
|
-
content_type:
|
|
3500
|
-
parts:
|
|
3808
|
+
content: z28.object({
|
|
3809
|
+
content_type: z28.string(),
|
|
3810
|
+
parts: z28.array(z28.any()).optional()
|
|
3501
3811
|
// Accept any type in parts array (strings, objects, etc.)
|
|
3502
3812
|
}).passthrough(),
|
|
3503
3813
|
// Allow extra fields in content
|
|
3504
|
-
status:
|
|
3505
|
-
end_turn:
|
|
3506
|
-
metadata:
|
|
3814
|
+
status: z28.string(),
|
|
3815
|
+
end_turn: z28.boolean().nullable(),
|
|
3816
|
+
metadata: z28.any(),
|
|
3507
3817
|
// Accept any metadata structure since it varies widely
|
|
3508
|
-
recipient:
|
|
3818
|
+
recipient: z28.string()
|
|
3509
3819
|
}).passthrough().nullable()
|
|
3510
3820
|
}).passthrough()
|
|
3511
3821
|
// Allow extra fields in mapping node
|
|
@@ -3513,38 +3823,38 @@ var openaiConversationSchema = z27.object({
|
|
|
3513
3823
|
}).passthrough();
|
|
3514
3824
|
|
|
3515
3825
|
// ../../b4m-core/packages/services/dist/src/importHistoryService/importClaudeHistory.js
|
|
3516
|
-
import { z as
|
|
3517
|
-
var claudeChatMessageSchema =
|
|
3518
|
-
uuid:
|
|
3519
|
-
text:
|
|
3520
|
-
content:
|
|
3521
|
-
|
|
3522
|
-
type:
|
|
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(),
|
|
3523
3833
|
// Accept any type: "text", "image", "tool_result", etc.
|
|
3524
|
-
text:
|
|
3834
|
+
text: z29.string().optional()
|
|
3525
3835
|
// Make text optional since tool_result may not have it
|
|
3526
3836
|
}).passthrough()
|
|
3527
3837
|
// Allow all other fields
|
|
3528
3838
|
),
|
|
3529
|
-
sender:
|
|
3530
|
-
created_at:
|
|
3531
|
-
updated_at:
|
|
3532
|
-
attachments:
|
|
3839
|
+
sender: z29.enum(["human", "assistant"]),
|
|
3840
|
+
created_at: z29.coerce.date(),
|
|
3841
|
+
updated_at: z29.coerce.date(),
|
|
3842
|
+
attachments: z29.array(z29.any()),
|
|
3533
3843
|
// Accept any attachment structure
|
|
3534
|
-
files:
|
|
3844
|
+
files: z29.array(z29.any())
|
|
3535
3845
|
// Accept any file structure
|
|
3536
3846
|
}).passthrough();
|
|
3537
|
-
var claudeConversationSchema =
|
|
3538
|
-
uuid:
|
|
3539
|
-
name:
|
|
3540
|
-
summary:
|
|
3847
|
+
var claudeConversationSchema = z29.object({
|
|
3848
|
+
uuid: z29.string().uuid(),
|
|
3849
|
+
name: z29.string(),
|
|
3850
|
+
summary: z29.string().optional(),
|
|
3541
3851
|
// Summary field is optional
|
|
3542
|
-
created_at:
|
|
3543
|
-
updated_at:
|
|
3544
|
-
account:
|
|
3545
|
-
uuid:
|
|
3852
|
+
created_at: z29.coerce.date(),
|
|
3853
|
+
updated_at: z29.coerce.date(),
|
|
3854
|
+
account: z29.object({
|
|
3855
|
+
uuid: z29.string().uuid()
|
|
3546
3856
|
}),
|
|
3547
|
-
chat_messages:
|
|
3857
|
+
chat_messages: z29.array(claudeChatMessageSchema)
|
|
3548
3858
|
}).passthrough();
|
|
3549
3859
|
|
|
3550
3860
|
// ../../b4m-core/packages/services/dist/src/importHistoryService/index.js
|
|
@@ -3555,357 +3865,357 @@ var ImportSource;
|
|
|
3555
3865
|
})(ImportSource || (ImportSource = {}));
|
|
3556
3866
|
|
|
3557
3867
|
// ../../b4m-core/packages/services/dist/src/sessionService/create.js
|
|
3558
|
-
import { z as
|
|
3559
|
-
var createSessionParametersSchema =
|
|
3560
|
-
name:
|
|
3561
|
-
knowledgeIds:
|
|
3562
|
-
artifactIds:
|
|
3563
|
-
agentIds:
|
|
3564
|
-
tags:
|
|
3565
|
-
summary:
|
|
3566
|
-
summaryAt:
|
|
3567
|
-
clonedSourceId:
|
|
3568
|
-
forkedSourceId:
|
|
3569
|
-
projectId:
|
|
3570
|
-
lastUsedModel:
|
|
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()
|
|
3571
3881
|
});
|
|
3572
3882
|
|
|
3573
3883
|
// ../../b4m-core/packages/services/dist/src/sessionService/delete.js
|
|
3574
|
-
import { z as
|
|
3575
|
-
var deleteSessionSchema =
|
|
3576
|
-
id:
|
|
3884
|
+
import { z as z31 } from "zod";
|
|
3885
|
+
var deleteSessionSchema = z31.object({
|
|
3886
|
+
id: z31.string()
|
|
3577
3887
|
});
|
|
3578
3888
|
|
|
3579
3889
|
// ../../b4m-core/packages/services/dist/src/sessionService/sumarize.js
|
|
3580
|
-
import { z as
|
|
3581
|
-
var sumarizeSessionSchema =
|
|
3582
|
-
id:
|
|
3890
|
+
import { z as z32 } from "zod";
|
|
3891
|
+
var sumarizeSessionSchema = z32.object({
|
|
3892
|
+
id: z32.string()
|
|
3583
3893
|
});
|
|
3584
3894
|
|
|
3585
3895
|
// ../../b4m-core/packages/services/dist/src/projectService/create.js
|
|
3586
|
-
import { z as
|
|
3587
|
-
var createProjectSchema =
|
|
3588
|
-
name:
|
|
3589
|
-
description:
|
|
3590
|
-
sessionIds:
|
|
3591
|
-
fileIds:
|
|
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()
|
|
3592
3902
|
});
|
|
3593
3903
|
|
|
3594
3904
|
// ../../b4m-core/packages/services/dist/src/projectService/search.js
|
|
3595
|
-
import { z as
|
|
3596
|
-
var searchProjectsSchema =
|
|
3597
|
-
search:
|
|
3598
|
-
filters:
|
|
3599
|
-
favorite:
|
|
3600
|
-
scope:
|
|
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()
|
|
3601
3911
|
}).optional(),
|
|
3602
|
-
pagination:
|
|
3603
|
-
page:
|
|
3604
|
-
limit:
|
|
3912
|
+
pagination: z34.object({
|
|
3913
|
+
page: z34.coerce.number().optional(),
|
|
3914
|
+
limit: z34.coerce.number().optional()
|
|
3605
3915
|
}).optional(),
|
|
3606
|
-
orderBy:
|
|
3607
|
-
by:
|
|
3608
|
-
direction:
|
|
3916
|
+
orderBy: z34.object({
|
|
3917
|
+
by: z34.enum(["createdAt", "updatedAt"]).optional(),
|
|
3918
|
+
direction: z34.enum(["asc", "desc"]).optional()
|
|
3609
3919
|
}).optional()
|
|
3610
3920
|
});
|
|
3611
3921
|
|
|
3612
3922
|
// ../../b4m-core/packages/services/dist/src/projectService/addSessions.js
|
|
3613
|
-
import { z as
|
|
3923
|
+
import { z as z45 } from "zod";
|
|
3614
3924
|
import uniq2 from "lodash/uniq.js";
|
|
3615
3925
|
|
|
3616
3926
|
// ../../b4m-core/packages/services/dist/src/sharingService/accept.js
|
|
3617
|
-
import { z as
|
|
3618
|
-
var acceptInviteSchema =
|
|
3619
|
-
id:
|
|
3927
|
+
import { z as z35 } from "zod";
|
|
3928
|
+
var acceptInviteSchema = z35.object({
|
|
3929
|
+
id: z35.string()
|
|
3620
3930
|
});
|
|
3621
3931
|
|
|
3622
3932
|
// ../../b4m-core/packages/services/dist/src/sharingService/cancel.js
|
|
3623
|
-
import { z as
|
|
3624
|
-
var cancelInviteSchema =
|
|
3625
|
-
id:
|
|
3626
|
-
type:
|
|
3627
|
-
email:
|
|
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()
|
|
3628
3938
|
});
|
|
3629
3939
|
|
|
3630
3940
|
// ../../b4m-core/packages/services/dist/src/sharingService/cancelOwnDocument.js
|
|
3631
|
-
import { z as
|
|
3632
|
-
var cancelOwnDocumentInvitesSchema =
|
|
3633
|
-
documentId:
|
|
3634
|
-
type:
|
|
3941
|
+
import { z as z37 } from "zod";
|
|
3942
|
+
var cancelOwnDocumentInvitesSchema = z37.object({
|
|
3943
|
+
documentId: z37.string(),
|
|
3944
|
+
type: z37.nativeEnum(InviteType)
|
|
3635
3945
|
});
|
|
3636
3946
|
|
|
3637
3947
|
// ../../b4m-core/packages/services/dist/src/sharingService/create.js
|
|
3638
|
-
import { z as
|
|
3948
|
+
import { z as z38 } from "zod";
|
|
3639
3949
|
var defaultExpiration = () => new Date((/* @__PURE__ */ new Date()).getFullYear() + 100, (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate());
|
|
3640
3950
|
var DEFAULT_AVAILABLE = 1;
|
|
3641
|
-
var createInviteSchema =
|
|
3642
|
-
id:
|
|
3643
|
-
type:
|
|
3644
|
-
permissions:
|
|
3645
|
-
recipients:
|
|
3646
|
-
description:
|
|
3647
|
-
expiresAt:
|
|
3648
|
-
available:
|
|
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)
|
|
3649
3959
|
});
|
|
3650
3960
|
|
|
3651
3961
|
// ../../b4m-core/packages/services/dist/src/sharingService/get.js
|
|
3652
|
-
import { z as
|
|
3653
|
-
var getInviteSchema =
|
|
3654
|
-
id:
|
|
3655
|
-
withUsername:
|
|
3962
|
+
import { z as z39 } from "zod";
|
|
3963
|
+
var getInviteSchema = z39.object({
|
|
3964
|
+
id: z39.string(),
|
|
3965
|
+
withUsername: z39.boolean().optional()
|
|
3656
3966
|
});
|
|
3657
3967
|
|
|
3658
3968
|
// ../../b4m-core/packages/services/dist/src/sharingService/listByDocumentIdAndType.js
|
|
3659
|
-
import { z as
|
|
3660
|
-
var listInviteByDocumentIdAndTypeSchema =
|
|
3661
|
-
documentId:
|
|
3662
|
-
type:
|
|
3969
|
+
import { z as z40 } from "zod";
|
|
3970
|
+
var listInviteByDocumentIdAndTypeSchema = z40.object({
|
|
3971
|
+
documentId: z40.string(),
|
|
3972
|
+
type: z40.nativeEnum(InviteType)
|
|
3663
3973
|
});
|
|
3664
3974
|
|
|
3665
3975
|
// ../../b4m-core/packages/services/dist/src/sharingService/listOwnPending.js
|
|
3666
|
-
import { z as
|
|
3667
|
-
var listOwnPendingInvitesSchema =
|
|
3668
|
-
limit:
|
|
3669
|
-
page:
|
|
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)
|
|
3670
3980
|
});
|
|
3671
3981
|
|
|
3672
3982
|
// ../../b4m-core/packages/services/dist/src/sharingService/refuse.js
|
|
3673
|
-
import { z as
|
|
3674
|
-
var refuseInviteSchema =
|
|
3675
|
-
id:
|
|
3983
|
+
import { z as z42 } from "zod";
|
|
3984
|
+
var refuseInviteSchema = z42.object({
|
|
3985
|
+
id: z42.string()
|
|
3676
3986
|
});
|
|
3677
3987
|
|
|
3678
3988
|
// ../../b4m-core/packages/services/dist/src/sharingService/revoke.js
|
|
3679
|
-
import { z as
|
|
3680
|
-
var revokeSharingSchema =
|
|
3681
|
-
id:
|
|
3682
|
-
type:
|
|
3683
|
-
userId:
|
|
3684
|
-
projectId:
|
|
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()
|
|
3685
3995
|
});
|
|
3686
3996
|
|
|
3687
3997
|
// ../../b4m-core/packages/services/dist/src/projectService/addFiles.js
|
|
3688
|
-
import { z as
|
|
3998
|
+
import { z as z44 } from "zod";
|
|
3689
3999
|
import uniq from "lodash/uniq.js";
|
|
3690
|
-
var addFilesProjectSchema =
|
|
3691
|
-
projectId:
|
|
3692
|
-
fileIds:
|
|
4000
|
+
var addFilesProjectSchema = z44.object({
|
|
4001
|
+
projectId: z44.string().nonempty(),
|
|
4002
|
+
fileIds: z44.array(z44.string().nonempty())
|
|
3693
4003
|
});
|
|
3694
4004
|
|
|
3695
4005
|
// ../../b4m-core/packages/services/dist/src/projectService/addSessions.js
|
|
3696
|
-
var addSessionsProjectSchema =
|
|
3697
|
-
projectId:
|
|
3698
|
-
sessionIds:
|
|
4006
|
+
var addSessionsProjectSchema = z45.object({
|
|
4007
|
+
projectId: z45.string().nonempty(),
|
|
4008
|
+
sessionIds: z45.array(z45.string().nonempty())
|
|
3699
4009
|
});
|
|
3700
4010
|
|
|
3701
4011
|
// ../../b4m-core/packages/services/dist/src/projectService/get.js
|
|
3702
|
-
import { z as z45 } from "zod";
|
|
3703
|
-
var getProjectSchema = z45.object({
|
|
3704
|
-
id: z45.string()
|
|
3705
|
-
});
|
|
3706
|
-
|
|
3707
|
-
// ../../b4m-core/packages/services/dist/src/projectService/update.js
|
|
3708
4012
|
import { z as z46 } from "zod";
|
|
3709
|
-
var
|
|
3710
|
-
id: z46.string()
|
|
3711
|
-
name: z46.string().optional(),
|
|
3712
|
-
description: z46.string().optional()
|
|
4013
|
+
var getProjectSchema = z46.object({
|
|
4014
|
+
id: z46.string()
|
|
3713
4015
|
});
|
|
3714
4016
|
|
|
3715
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
4017
|
+
// ../../b4m-core/packages/services/dist/src/projectService/update.js
|
|
3716
4018
|
import { z as z47 } from "zod";
|
|
3717
|
-
var
|
|
3718
|
-
id: z47.string()
|
|
4019
|
+
var updateProjectSchema = z47.object({
|
|
4020
|
+
id: z47.string(),
|
|
4021
|
+
name: z47.string().optional(),
|
|
4022
|
+
description: z47.string().optional()
|
|
3719
4023
|
});
|
|
3720
4024
|
|
|
3721
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
4025
|
+
// ../../b4m-core/packages/services/dist/src/projectService/delete.js
|
|
3722
4026
|
import { z as z48 } from "zod";
|
|
3723
|
-
var
|
|
3724
|
-
|
|
3725
|
-
fileIds: z48.array(z48.string())
|
|
4027
|
+
var deleteProjectSchema = z48.object({
|
|
4028
|
+
id: z48.string()
|
|
3726
4029
|
});
|
|
3727
4030
|
|
|
3728
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
4031
|
+
// ../../b4m-core/packages/services/dist/src/projectService/removeFiles.js
|
|
3729
4032
|
import { z as z49 } from "zod";
|
|
3730
|
-
var
|
|
4033
|
+
var removeProjectFilesSchema = z49.object({
|
|
3731
4034
|
projectId: z49.string(),
|
|
3732
|
-
|
|
4035
|
+
fileIds: z49.array(z49.string())
|
|
3733
4036
|
});
|
|
3734
4037
|
|
|
3735
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
4038
|
+
// ../../b4m-core/packages/services/dist/src/projectService/removeSessions.js
|
|
3736
4039
|
import { z as z50 } from "zod";
|
|
3737
|
-
var
|
|
3738
|
-
projectId: z50.string()
|
|
4040
|
+
var removeProjectSessionsSchema = z50.object({
|
|
4041
|
+
projectId: z50.string(),
|
|
4042
|
+
sessionIds: z50.array(z50.string())
|
|
3739
4043
|
});
|
|
3740
4044
|
|
|
3741
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
4045
|
+
// ../../b4m-core/packages/services/dist/src/projectService/listSessions.js
|
|
3742
4046
|
import { z as z51 } from "zod";
|
|
3743
|
-
var
|
|
4047
|
+
var listProjectSessionsSchema = z51.object({
|
|
3744
4048
|
projectId: z51.string()
|
|
3745
4049
|
});
|
|
3746
4050
|
|
|
3747
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
4051
|
+
// ../../b4m-core/packages/services/dist/src/projectService/listFiles.js
|
|
3748
4052
|
import { z as z52 } from "zod";
|
|
3749
|
-
var
|
|
3750
|
-
|
|
3751
|
-
statuses: z52.string().optional().default(""),
|
|
3752
|
-
limit: z52.coerce.number().optional().default(10),
|
|
3753
|
-
page: z52.coerce.number().optional().default(1)
|
|
4053
|
+
var listProjectFilesSchema = z52.object({
|
|
4054
|
+
projectId: z52.string()
|
|
3754
4055
|
});
|
|
3755
4056
|
|
|
3756
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
4057
|
+
// ../../b4m-core/packages/services/dist/src/projectService/listInvites.js
|
|
3757
4058
|
import { z as z53 } from "zod";
|
|
3758
|
-
var
|
|
3759
|
-
|
|
3760
|
-
|
|
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)
|
|
3761
4064
|
});
|
|
3762
4065
|
|
|
3763
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
4066
|
+
// ../../b4m-core/packages/services/dist/src/projectService/addSystemPrompts.js
|
|
3764
4067
|
import { z as z54 } from "zod";
|
|
3765
|
-
var
|
|
4068
|
+
var addSystemPromptsSchema = z54.object({
|
|
3766
4069
|
projectId: z54.string(),
|
|
3767
|
-
|
|
4070
|
+
fileIds: z54.array(z54.string())
|
|
3768
4071
|
});
|
|
3769
4072
|
|
|
3770
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
4073
|
+
// ../../b4m-core/packages/services/dist/src/projectService/toggleSystemPrompt.js
|
|
3771
4074
|
import { z as z55 } from "zod";
|
|
3772
|
-
var
|
|
4075
|
+
var toggleSystemPromptSchema = z55.object({
|
|
3773
4076
|
projectId: z55.string(),
|
|
3774
4077
|
fileId: z55.string()
|
|
3775
4078
|
});
|
|
3776
4079
|
|
|
3777
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
3778
|
-
import { z as z58 } from "zod";
|
|
3779
|
-
|
|
3780
|
-
// ../../b4m-core/packages/services/dist/src/favoriteService/create.js
|
|
4080
|
+
// ../../b4m-core/packages/services/dist/src/projectService/removeSystemPrompt.js
|
|
3781
4081
|
import { z as z56 } from "zod";
|
|
3782
|
-
var
|
|
3783
|
-
|
|
3784
|
-
|
|
4082
|
+
var removeSystemPromptSchema = z56.object({
|
|
4083
|
+
projectId: z56.string(),
|
|
4084
|
+
fileId: z56.string()
|
|
3785
4085
|
});
|
|
3786
4086
|
|
|
3787
|
-
// ../../b4m-core/packages/services/dist/src/
|
|
4087
|
+
// ../../b4m-core/packages/services/dist/src/projectService/addFavorite.js
|
|
4088
|
+
import { z as z59 } from "zod";
|
|
4089
|
+
|
|
4090
|
+
// ../../b4m-core/packages/services/dist/src/favoriteService/create.js
|
|
3788
4091
|
import { z as z57 } from "zod";
|
|
3789
|
-
var
|
|
4092
|
+
var createFavoriteParametersSchema = z57.object({
|
|
3790
4093
|
documentId: z57.string(),
|
|
3791
4094
|
documentType: z57.nativeEnum(FavoriteDocumentType)
|
|
3792
4095
|
});
|
|
3793
4096
|
|
|
3794
|
-
// ../../b4m-core/packages/services/dist/src/
|
|
3795
|
-
|
|
3796
|
-
|
|
4097
|
+
// ../../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)
|
|
3797
4102
|
});
|
|
3798
4103
|
|
|
3799
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
3800
|
-
|
|
3801
|
-
var deleteFavoriteParametersSchema2 = z59.object({
|
|
4104
|
+
// ../../b4m-core/packages/services/dist/src/projectService/addFavorite.js
|
|
4105
|
+
var addFavoriteParametersSchema = z59.object({
|
|
3802
4106
|
projectId: z59.string()
|
|
3803
4107
|
});
|
|
3804
4108
|
|
|
3805
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
4109
|
+
// ../../b4m-core/packages/services/dist/src/projectService/deleteFavorite.js
|
|
3806
4110
|
import { z as z60 } from "zod";
|
|
3807
|
-
var
|
|
4111
|
+
var deleteFavoriteParametersSchema2 = z60.object({
|
|
3808
4112
|
projectId: z60.string()
|
|
3809
4113
|
});
|
|
3810
4114
|
|
|
3811
|
-
// ../../b4m-core/packages/services/dist/src/projectService/
|
|
4115
|
+
// ../../b4m-core/packages/services/dist/src/projectService/removeNonExistentFiles.js
|
|
3812
4116
|
import { z as z61 } from "zod";
|
|
3813
|
-
var
|
|
3814
|
-
|
|
3815
|
-
userIdToRemove: z61.string().optional()
|
|
3816
|
-
// Optional: if provided, this is a removal by owner
|
|
4117
|
+
var removeNonExistentFilesSchema = z61.object({
|
|
4118
|
+
projectId: z61.string()
|
|
3817
4119
|
});
|
|
3818
4120
|
|
|
3819
|
-
// ../../b4m-core/packages/services/dist/src/
|
|
3820
|
-
import uniq3 from "lodash/uniq.js";
|
|
3821
|
-
import isEqual from "lodash/isEqual.js";
|
|
4121
|
+
// ../../b4m-core/packages/services/dist/src/projectService/leaveProject.js
|
|
3822
4122
|
import { z as z62 } from "zod";
|
|
3823
|
-
var
|
|
4123
|
+
var leaveProjectParamsSchema = z62.object({
|
|
3824
4124
|
id: z62.string(),
|
|
3825
|
-
|
|
3826
|
-
|
|
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()
|
|
4125
|
+
userIdToRemove: z62.string().optional()
|
|
4126
|
+
// Optional: if provided, this is a removal by owner
|
|
3830
4127
|
});
|
|
3831
4128
|
|
|
3832
|
-
// ../../b4m-core/packages/services/dist/src/sessionService/
|
|
4129
|
+
// ../../b4m-core/packages/services/dist/src/sessionService/update.js
|
|
4130
|
+
import uniq3 from "lodash/uniq.js";
|
|
4131
|
+
import isEqual from "lodash/isEqual.js";
|
|
3833
4132
|
import { z as z63 } from "zod";
|
|
3834
|
-
var
|
|
3835
|
-
id: z63.string()
|
|
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()
|
|
3836
4140
|
});
|
|
3837
4141
|
|
|
3838
|
-
// ../../b4m-core/packages/services/dist/src/sessionService/
|
|
4142
|
+
// ../../b4m-core/packages/services/dist/src/sessionService/clone.js
|
|
3839
4143
|
import { z as z64 } from "zod";
|
|
3840
|
-
var
|
|
3841
|
-
|
|
3842
|
-
messageId: z64.string()
|
|
4144
|
+
var cloneSessionSchema = z64.object({
|
|
4145
|
+
id: z64.string()
|
|
3843
4146
|
});
|
|
3844
4147
|
|
|
3845
|
-
// ../../b4m-core/packages/services/dist/src/sessionService/
|
|
4148
|
+
// ../../b4m-core/packages/services/dist/src/sessionService/fork.js
|
|
3846
4149
|
import { z as z65 } from "zod";
|
|
3847
|
-
var
|
|
4150
|
+
var forkSessionSchema = z65.object({
|
|
3848
4151
|
sessionId: z65.string(),
|
|
3849
4152
|
messageId: z65.string()
|
|
3850
4153
|
});
|
|
3851
4154
|
|
|
3852
|
-
// ../../b4m-core/packages/services/dist/src/sessionService/
|
|
4155
|
+
// ../../b4m-core/packages/services/dist/src/sessionService/snip.js
|
|
3853
4156
|
import { z as z66 } from "zod";
|
|
3854
|
-
var
|
|
3855
|
-
|
|
4157
|
+
var snipSessionSchema = z66.object({
|
|
4158
|
+
sessionId: z66.string(),
|
|
4159
|
+
messageId: z66.string()
|
|
3856
4160
|
});
|
|
3857
4161
|
|
|
3858
|
-
// ../../b4m-core/packages/services/dist/src/sessionService/
|
|
4162
|
+
// ../../b4m-core/packages/services/dist/src/sessionService/get.js
|
|
3859
4163
|
import { z as z67 } from "zod";
|
|
3860
|
-
var
|
|
3861
|
-
|
|
3862
|
-
messageId: z67.string()
|
|
4164
|
+
var getSessionSchema = z67.object({
|
|
4165
|
+
id: z67.string()
|
|
3863
4166
|
});
|
|
3864
4167
|
|
|
3865
|
-
// ../../b4m-core/packages/services/dist/src/sessionService/
|
|
4168
|
+
// ../../b4m-core/packages/services/dist/src/sessionService/deleteMessage.js
|
|
3866
4169
|
import { z as z68 } from "zod";
|
|
3867
|
-
var
|
|
3868
|
-
sessionId: z68.string()
|
|
4170
|
+
var deleteSessionMessageSchema = z68.object({
|
|
4171
|
+
sessionId: z68.string(),
|
|
4172
|
+
messageId: z68.string()
|
|
3869
4173
|
});
|
|
3870
4174
|
|
|
3871
|
-
// ../../b4m-core/packages/services/dist/src/sessionService/
|
|
4175
|
+
// ../../b4m-core/packages/services/dist/src/sessionService/addFavorite.js
|
|
3872
4176
|
import { z as z69 } from "zod";
|
|
3873
|
-
var
|
|
4177
|
+
var addFavoriteParametersSchema2 = z69.object({
|
|
3874
4178
|
sessionId: z69.string()
|
|
3875
4179
|
});
|
|
3876
4180
|
|
|
3877
|
-
// ../../b4m-core/packages/services/dist/src/sessionService/
|
|
4181
|
+
// ../../b4m-core/packages/services/dist/src/sessionService/deleteFavorite.js
|
|
3878
4182
|
import { z as z70 } from "zod";
|
|
3879
|
-
var
|
|
3880
|
-
sessionId: z70.string()
|
|
4183
|
+
var deleteFavoriteParametersSchema3 = z70.object({
|
|
4184
|
+
sessionId: z70.string()
|
|
4185
|
+
});
|
|
4186
|
+
|
|
4187
|
+
// ../../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(),
|
|
3881
4191
|
/** The maximum number of words to include in the title */
|
|
3882
|
-
maxWords:
|
|
4192
|
+
maxWords: z71.number().optional()
|
|
3883
4193
|
});
|
|
3884
4194
|
|
|
3885
4195
|
// ../../b4m-core/packages/services/dist/src/organizationService/search.js
|
|
3886
|
-
import { z as
|
|
3887
|
-
var searchSchema2 =
|
|
4196
|
+
import { z as z72 } from "zod";
|
|
4197
|
+
var searchSchema2 = z72.object({
|
|
3888
4198
|
/**
|
|
3889
4199
|
* Text search query (searches in name and description)
|
|
3890
4200
|
*/
|
|
3891
|
-
query:
|
|
4201
|
+
query: z72.string().optional(),
|
|
3892
4202
|
/**
|
|
3893
4203
|
* Filter by personal organizations
|
|
3894
4204
|
*/
|
|
3895
|
-
filters:
|
|
3896
|
-
personal:
|
|
3897
|
-
userId:
|
|
4205
|
+
filters: z72.object({
|
|
4206
|
+
personal: z72.union([z72.enum(["true", "false"]).transform((val) => val === "true"), z72.boolean()]).optional(),
|
|
4207
|
+
userId: z72.string().optional()
|
|
3898
4208
|
}).default({}),
|
|
3899
|
-
pagination:
|
|
3900
|
-
page:
|
|
3901
|
-
limit:
|
|
4209
|
+
pagination: z72.object({
|
|
4210
|
+
page: z72.coerce.number().int().positive().default(1),
|
|
4211
|
+
limit: z72.coerce.number().int().positive().max(100).default(10)
|
|
3902
4212
|
}).default({
|
|
3903
4213
|
page: 1,
|
|
3904
4214
|
limit: 10
|
|
3905
4215
|
}),
|
|
3906
|
-
orderBy:
|
|
3907
|
-
field:
|
|
3908
|
-
direction:
|
|
4216
|
+
orderBy: z72.object({
|
|
4217
|
+
field: z72.enum(["name", "createdAt", "updatedAt"]).default("name"),
|
|
4218
|
+
direction: z72.enum(["asc", "desc"]).default("asc")
|
|
3909
4219
|
}).default({
|
|
3910
4220
|
field: "name",
|
|
3911
4221
|
direction: "asc"
|
|
@@ -3913,355 +4223,355 @@ var searchSchema2 = z71.object({
|
|
|
3913
4223
|
});
|
|
3914
4224
|
|
|
3915
4225
|
// ../../b4m-core/packages/services/dist/src/organizationService/get.js
|
|
3916
|
-
import { z as
|
|
3917
|
-
var getSchema =
|
|
4226
|
+
import { z as z73 } from "zod";
|
|
4227
|
+
var getSchema = z73.object({
|
|
3918
4228
|
/**
|
|
3919
4229
|
* Organization ID
|
|
3920
4230
|
*/
|
|
3921
|
-
id:
|
|
4231
|
+
id: z73.string().min(1)
|
|
3922
4232
|
});
|
|
3923
4233
|
|
|
3924
4234
|
// ../../b4m-core/packages/services/dist/src/organizationService/addMember.js
|
|
3925
|
-
import { z as
|
|
3926
|
-
var addMemberSchema =
|
|
3927
|
-
userId:
|
|
3928
|
-
email:
|
|
3929
|
-
organizationId:
|
|
3930
|
-
force:
|
|
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()
|
|
3931
4241
|
// If true, add the user to the organization even if it's at full capacity
|
|
3932
4242
|
});
|
|
3933
4243
|
|
|
3934
4244
|
// ../../b4m-core/packages/services/dist/src/organizationService/getUsers.js
|
|
3935
|
-
import { z as
|
|
3936
|
-
var getUsersSchema =
|
|
3937
|
-
id:
|
|
4245
|
+
import { z as z75 } from "zod";
|
|
4246
|
+
var getUsersSchema = z75.object({
|
|
4247
|
+
id: z75.string()
|
|
3938
4248
|
});
|
|
3939
4249
|
|
|
3940
4250
|
// ../../b4m-core/packages/services/dist/src/organizationService/create.js
|
|
3941
|
-
import { z as
|
|
3942
|
-
var createSchema =
|
|
3943
|
-
name:
|
|
3944
|
-
personal:
|
|
3945
|
-
seats:
|
|
3946
|
-
stripeCustomerId:
|
|
3947
|
-
billingOwnerId:
|
|
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(),
|
|
3948
4258
|
// Optional billing owner (defaults to user if not provided)
|
|
3949
|
-
managerId:
|
|
4259
|
+
managerId: z76.string().optional()
|
|
3950
4260
|
// Optional team manager
|
|
3951
4261
|
});
|
|
3952
4262
|
|
|
3953
4263
|
// ../../b4m-core/packages/services/dist/src/organizationService/update.js
|
|
3954
|
-
import { z as
|
|
3955
|
-
var updateSchema =
|
|
3956
|
-
id:
|
|
3957
|
-
name:
|
|
3958
|
-
description:
|
|
3959
|
-
billingContact:
|
|
3960
|
-
currentCredits:
|
|
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()
|
|
3961
4271
|
});
|
|
3962
4272
|
|
|
3963
4273
|
// ../../b4m-core/packages/services/dist/src/organizationService/delete.js
|
|
3964
|
-
import { z as
|
|
3965
|
-
var deleteSchema =
|
|
4274
|
+
import { z as z78 } from "zod";
|
|
4275
|
+
var deleteSchema = z78.object({
|
|
3966
4276
|
/**
|
|
3967
4277
|
* Organization ID
|
|
3968
4278
|
*/
|
|
3969
|
-
id:
|
|
4279
|
+
id: z78.string().min(1)
|
|
3970
4280
|
});
|
|
3971
4281
|
|
|
3972
4282
|
// ../../b4m-core/packages/services/dist/src/organizationService/listPendingUsers.js
|
|
3973
|
-
import { z as
|
|
3974
|
-
var listPendingUsersSchema =
|
|
3975
|
-
organizationId:
|
|
4283
|
+
import { z as z79 } from "zod";
|
|
4284
|
+
var listPendingUsersSchema = z79.object({
|
|
4285
|
+
organizationId: z79.string()
|
|
3976
4286
|
});
|
|
3977
4287
|
|
|
3978
4288
|
// ../../b4m-core/packages/services/dist/src/organizationService/revokeAccess.js
|
|
3979
|
-
import { z as
|
|
3980
|
-
var revokeAccessSchema =
|
|
3981
|
-
id:
|
|
3982
|
-
userId:
|
|
4289
|
+
import { z as z80 } from "zod";
|
|
4290
|
+
var revokeAccessSchema = z80.object({
|
|
4291
|
+
id: z80.string(),
|
|
4292
|
+
userId: z80.string()
|
|
3983
4293
|
});
|
|
3984
4294
|
|
|
3985
4295
|
// ../../b4m-core/packages/services/dist/src/organizationService/leave.js
|
|
3986
|
-
import { z as
|
|
3987
|
-
var organizationLeaveSchema =
|
|
3988
|
-
id:
|
|
4296
|
+
import { z as z81 } from "zod";
|
|
4297
|
+
var organizationLeaveSchema = z81.object({
|
|
4298
|
+
id: z81.string()
|
|
3989
4299
|
});
|
|
3990
4300
|
|
|
3991
4301
|
// ../../b4m-core/packages/services/dist/src/apiKeyService/create.js
|
|
3992
|
-
import { z as
|
|
3993
|
-
var createApiKeySchema =
|
|
3994
|
-
apiKey:
|
|
3995
|
-
description:
|
|
3996
|
-
isActive:
|
|
3997
|
-
type:
|
|
3998
|
-
expireDays:
|
|
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)
|
|
3999
4309
|
// Default 90-day expiration
|
|
4000
4310
|
});
|
|
4001
4311
|
|
|
4002
4312
|
// ../../b4m-core/packages/services/dist/src/apiKeyService/set.js
|
|
4003
|
-
import { z as
|
|
4004
|
-
var setApiKeySchema =
|
|
4005
|
-
id:
|
|
4006
|
-
type:
|
|
4313
|
+
import { z as z83 } from "zod";
|
|
4314
|
+
var setApiKeySchema = z83.object({
|
|
4315
|
+
id: z83.string(),
|
|
4316
|
+
type: z83.nativeEnum(ApiKeyType)
|
|
4007
4317
|
});
|
|
4008
4318
|
|
|
4009
4319
|
// ../../b4m-core/packages/services/dist/src/apiKeyService/delete.js
|
|
4010
|
-
import { z as
|
|
4011
|
-
var deleteApiKeySchema =
|
|
4012
|
-
id:
|
|
4320
|
+
import { z as z84 } from "zod";
|
|
4321
|
+
var deleteApiKeySchema = z84.object({
|
|
4322
|
+
id: z84.string()
|
|
4013
4323
|
});
|
|
4014
4324
|
|
|
4015
4325
|
// ../../b4m-core/packages/services/dist/src/fabFileService/get.js
|
|
4016
|
-
import { z as
|
|
4017
|
-
var getFabFileSchema =
|
|
4018
|
-
id:
|
|
4326
|
+
import { z as z85 } from "zod";
|
|
4327
|
+
var getFabFileSchema = z85.object({
|
|
4328
|
+
id: z85.string()
|
|
4019
4329
|
});
|
|
4020
4330
|
|
|
4021
4331
|
// ../../b4m-core/packages/services/dist/src/fabFileService/list.js
|
|
4022
|
-
import { z as
|
|
4023
|
-
var listFabFilesSchema =
|
|
4024
|
-
ids:
|
|
4332
|
+
import { z as z86 } from "zod";
|
|
4333
|
+
var listFabFilesSchema = z86.object({
|
|
4334
|
+
ids: z86.array(z86.string()).optional()
|
|
4025
4335
|
});
|
|
4026
4336
|
|
|
4027
4337
|
// ../../b4m-core/packages/services/dist/src/fabFileService/update.js
|
|
4028
4338
|
import mime from "mime-types";
|
|
4029
4339
|
import { v4 as uuidv42 } from "uuid";
|
|
4030
|
-
import { z as
|
|
4031
|
-
var updateFabFileSchema =
|
|
4032
|
-
id:
|
|
4033
|
-
fileName:
|
|
4034
|
-
mimeType:
|
|
4035
|
-
fileContent:
|
|
4036
|
-
type:
|
|
4037
|
-
system:
|
|
4038
|
-
systemPriority:
|
|
4039
|
-
sessionId:
|
|
4040
|
-
notes:
|
|
4041
|
-
primaryTag:
|
|
4042
|
-
tags:
|
|
4043
|
-
name:
|
|
4044
|
-
strength:
|
|
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()
|
|
4045
4355
|
})).optional(),
|
|
4046
|
-
error:
|
|
4356
|
+
error: z87.string().nullable().optional()
|
|
4047
4357
|
});
|
|
4048
4358
|
|
|
4049
4359
|
// ../../b4m-core/packages/services/dist/src/fabFileService/delete.js
|
|
4050
|
-
import { z as
|
|
4051
|
-
var deleteFabFileSchema =
|
|
4052
|
-
id:
|
|
4360
|
+
import { z as z88 } from "zod";
|
|
4361
|
+
var deleteFabFileSchema = z88.object({
|
|
4362
|
+
id: z88.string()
|
|
4053
4363
|
});
|
|
4054
4364
|
|
|
4055
4365
|
// ../../b4m-core/packages/services/dist/src/fabFileService/chunk.js
|
|
4056
|
-
import { z as
|
|
4057
|
-
var chunkFileSchema =
|
|
4058
|
-
fabFileId:
|
|
4059
|
-
embeddingModel:
|
|
4366
|
+
import { z as z89 } from "zod";
|
|
4367
|
+
var chunkFileSchema = z89.object({
|
|
4368
|
+
fabFileId: z89.string(),
|
|
4369
|
+
embeddingModel: z89.string()
|
|
4060
4370
|
});
|
|
4061
4371
|
|
|
4062
4372
|
// ../../b4m-core/packages/services/dist/src/fabFileService/vectorize.js
|
|
4063
|
-
import { z as
|
|
4064
|
-
var vectorizeFabFileChunkSchema =
|
|
4065
|
-
fabFileId:
|
|
4066
|
-
chunkId:
|
|
4373
|
+
import { z as z90 } from "zod";
|
|
4374
|
+
var vectorizeFabFileChunkSchema = z90.object({
|
|
4375
|
+
fabFileId: z90.string(),
|
|
4376
|
+
chunkId: z90.string()
|
|
4067
4377
|
});
|
|
4068
4378
|
|
|
4069
4379
|
// ../../b4m-core/packages/services/dist/src/fabFileService/listBySession.js
|
|
4070
|
-
import { z as
|
|
4071
|
-
var listFabFilesBySessionSchema =
|
|
4072
|
-
sessionId:
|
|
4380
|
+
import { z as z91 } from "zod";
|
|
4381
|
+
var listFabFilesBySessionSchema = z91.object({
|
|
4382
|
+
sessionId: z91.string()
|
|
4073
4383
|
});
|
|
4074
4384
|
|
|
4075
4385
|
// ../../b4m-core/packages/services/dist/src/fabFileService/listByQuest.js
|
|
4076
|
-
import { z as
|
|
4077
|
-
var listFabFilesByQuestSchema =
|
|
4078
|
-
questId:
|
|
4386
|
+
import { z as z92 } from "zod";
|
|
4387
|
+
var listFabFilesByQuestSchema = z92.object({
|
|
4388
|
+
questId: z92.string()
|
|
4079
4389
|
});
|
|
4080
4390
|
|
|
4081
4391
|
// ../../b4m-core/packages/services/dist/src/fabFileService/createByUrl.js
|
|
4082
|
-
import { z as
|
|
4083
|
-
var createFabFileByUrlSchema =
|
|
4084
|
-
url:
|
|
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,})).+/)
|
|
4085
4395
|
});
|
|
4086
4396
|
|
|
4087
4397
|
// ../../b4m-core/packages/services/dist/src/fabFileService/search.js
|
|
4088
|
-
import { z as
|
|
4089
|
-
var searchFabFilesSchema =
|
|
4090
|
-
search:
|
|
4091
|
-
filters:
|
|
4092
|
-
tags:
|
|
4093
|
-
type:
|
|
4094
|
-
shared:
|
|
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(),
|
|
4095
4405
|
// Indicates if the user is searching for shared files
|
|
4096
|
-
curated:
|
|
4406
|
+
curated: z94.coerce.boolean().optional(),
|
|
4097
4407
|
// Indicates if the user is searching for curated notebook files
|
|
4098
|
-
projectId:
|
|
4099
|
-
ids:
|
|
4408
|
+
projectId: z94.string().optional(),
|
|
4409
|
+
ids: z94.array(z94.string()).optional()
|
|
4100
4410
|
// Add support for filtering by IDs
|
|
4101
4411
|
}).optional(),
|
|
4102
|
-
pagination:
|
|
4103
|
-
page:
|
|
4104
|
-
limit:
|
|
4412
|
+
pagination: z94.object({
|
|
4413
|
+
page: z94.coerce.number(),
|
|
4414
|
+
limit: z94.coerce.number()
|
|
4105
4415
|
}).optional(),
|
|
4106
|
-
order:
|
|
4107
|
-
by:
|
|
4108
|
-
direction:
|
|
4416
|
+
order: z94.object({
|
|
4417
|
+
by: z94.enum(["createdAt", "fileName", "fileSize"]),
|
|
4418
|
+
direction: z94.enum(["asc", "desc"])
|
|
4109
4419
|
}).optional(),
|
|
4110
|
-
options:
|
|
4111
|
-
includeShared:
|
|
4420
|
+
options: z94.object({
|
|
4421
|
+
includeShared: z94.coerce.boolean().optional()
|
|
4112
4422
|
}).optional()
|
|
4113
4423
|
});
|
|
4114
4424
|
|
|
4115
4425
|
// ../../b4m-core/packages/services/dist/src/fabFileService/addFavorite.js
|
|
4116
|
-
import { z as
|
|
4117
|
-
var addFavoriteParametersSchema3 =
|
|
4118
|
-
fileId:
|
|
4426
|
+
import { z as z95 } from "zod";
|
|
4427
|
+
var addFavoriteParametersSchema3 = z95.object({
|
|
4428
|
+
fileId: z95.string()
|
|
4119
4429
|
});
|
|
4120
4430
|
|
|
4121
4431
|
// ../../b4m-core/packages/services/dist/src/fabFileService/deleteFavorite.js
|
|
4122
|
-
import { z as
|
|
4123
|
-
var deleteFavoriteParametersSchema4 =
|
|
4124
|
-
fileId:
|
|
4432
|
+
import { z as z96 } from "zod";
|
|
4433
|
+
var deleteFavoriteParametersSchema4 = z96.object({
|
|
4434
|
+
fileId: z96.string()
|
|
4125
4435
|
});
|
|
4126
4436
|
|
|
4127
4437
|
// ../../b4m-core/packages/services/dist/src/fabFileService/toggleTags.js
|
|
4128
|
-
import { z as
|
|
4129
|
-
var fabFileToggleTagsSchema =
|
|
4130
|
-
ids:
|
|
4131
|
-
tags:
|
|
4438
|
+
import { z as z97 } from "zod";
|
|
4439
|
+
var fabFileToggleTagsSchema = z97.object({
|
|
4440
|
+
ids: z97.array(z97.string()),
|
|
4441
|
+
tags: z97.array(z97.string())
|
|
4132
4442
|
});
|
|
4133
4443
|
|
|
4134
4444
|
// ../../b4m-core/packages/services/dist/src/fabFileService/edit.js
|
|
4135
|
-
import { z as
|
|
4445
|
+
import { z as z98 } from "zod";
|
|
4136
4446
|
import { diffLines } from "diff";
|
|
4137
|
-
var editFabFileSchema =
|
|
4138
|
-
id:
|
|
4139
|
-
instruction:
|
|
4140
|
-
selection:
|
|
4141
|
-
start:
|
|
4142
|
-
end:
|
|
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()
|
|
4143
4453
|
}).optional(),
|
|
4144
|
-
preserveFormatting:
|
|
4145
|
-
applyImmediately:
|
|
4454
|
+
preserveFormatting: z98.boolean().optional().default(true),
|
|
4455
|
+
applyImmediately: z98.boolean().optional().default(false)
|
|
4146
4456
|
});
|
|
4147
4457
|
|
|
4148
4458
|
// ../../b4m-core/packages/services/dist/src/fabFileService/applyEdit.js
|
|
4149
4459
|
import mime2 from "mime-types";
|
|
4150
4460
|
import { v4 as uuidv43 } from "uuid";
|
|
4151
|
-
import { z as
|
|
4152
|
-
var applyEditSchema =
|
|
4153
|
-
id:
|
|
4154
|
-
modifiedContent:
|
|
4155
|
-
createBackup:
|
|
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)
|
|
4156
4466
|
});
|
|
4157
4467
|
|
|
4158
4468
|
// ../../b4m-core/packages/services/dist/src/friendshipService/respondToFriendRequest.js
|
|
4159
|
-
import { z as
|
|
4160
|
-
var respondToFriendRequestSchema =
|
|
4161
|
-
id:
|
|
4469
|
+
import { z as z100 } from "zod";
|
|
4470
|
+
var respondToFriendRequestSchema = z100.object({
|
|
4471
|
+
id: z100.string(),
|
|
4162
4472
|
/** The user ID of the recipient of the friend request */
|
|
4163
|
-
userId:
|
|
4164
|
-
accept:
|
|
4473
|
+
userId: z100.string(),
|
|
4474
|
+
accept: z100.boolean()
|
|
4165
4475
|
});
|
|
4166
4476
|
|
|
4167
4477
|
// ../../b4m-core/packages/services/dist/src/friendshipService/unfriend.js
|
|
4168
|
-
import { z as
|
|
4169
|
-
var unfriendSchema =
|
|
4170
|
-
friendshipId:
|
|
4478
|
+
import { z as z101 } from "zod";
|
|
4479
|
+
var unfriendSchema = z101.object({
|
|
4480
|
+
friendshipId: z101.string(),
|
|
4171
4481
|
/** The user ID of the user who wants to unfriend the other user */
|
|
4172
|
-
userId:
|
|
4482
|
+
userId: z101.string()
|
|
4173
4483
|
});
|
|
4174
4484
|
|
|
4175
4485
|
// ../../b4m-core/packages/services/dist/src/friendshipService/list.js
|
|
4176
|
-
import { z as
|
|
4177
|
-
var listFriendsSchema =
|
|
4178
|
-
userId:
|
|
4486
|
+
import { z as z102 } from "zod";
|
|
4487
|
+
var listFriendsSchema = z102.object({
|
|
4488
|
+
userId: z102.string()
|
|
4179
4489
|
});
|
|
4180
|
-
var listPendingFriendRequestsSchema =
|
|
4181
|
-
userId:
|
|
4490
|
+
var listPendingFriendRequestsSchema = z102.object({
|
|
4491
|
+
userId: z102.string()
|
|
4182
4492
|
});
|
|
4183
4493
|
|
|
4184
4494
|
// ../../b4m-core/packages/services/dist/src/adminService/loginAs.js
|
|
4185
|
-
import { z as
|
|
4186
|
-
var loginAsSchema =
|
|
4187
|
-
targetUserId:
|
|
4495
|
+
import { z as z103 } from "zod";
|
|
4496
|
+
var loginAsSchema = z103.object({
|
|
4497
|
+
targetUserId: z103.string()
|
|
4188
4498
|
});
|
|
4189
4499
|
|
|
4190
4500
|
// ../../b4m-core/packages/services/dist/src/cacheService/get.js
|
|
4191
|
-
import { z as
|
|
4192
|
-
var getParamsSchema =
|
|
4193
|
-
key:
|
|
4501
|
+
import { z as z104 } from "zod";
|
|
4502
|
+
var getParamsSchema = z104.object({
|
|
4503
|
+
key: z104.string()
|
|
4194
4504
|
});
|
|
4195
4505
|
|
|
4196
4506
|
// ../../b4m-core/packages/services/dist/src/cacheService/set.js
|
|
4197
|
-
import { z as
|
|
4198
|
-
var setParamsSchema =
|
|
4199
|
-
key:
|
|
4200
|
-
value:
|
|
4507
|
+
import { z as z105 } from "zod";
|
|
4508
|
+
var setParamsSchema = z105.object({
|
|
4509
|
+
key: z105.string(),
|
|
4510
|
+
value: z105.any(),
|
|
4201
4511
|
/**
|
|
4202
4512
|
* Time to live in milliseconds
|
|
4203
4513
|
*/
|
|
4204
|
-
ttl:
|
|
4205
|
-
recache:
|
|
4514
|
+
ttl: z105.number(),
|
|
4515
|
+
recache: z105.boolean().optional()
|
|
4206
4516
|
});
|
|
4207
4517
|
|
|
4208
4518
|
// ../../b4m-core/packages/services/dist/src/cacheService/ttl.js
|
|
4209
|
-
import { z as
|
|
4210
|
-
var ttlParamsSchema =
|
|
4211
|
-
key:
|
|
4519
|
+
import { z as z106 } from "zod";
|
|
4520
|
+
var ttlParamsSchema = z106.object({
|
|
4521
|
+
key: z106.string()
|
|
4212
4522
|
});
|
|
4213
4523
|
|
|
4214
4524
|
// ../../b4m-core/packages/services/dist/src/cacheService/weeklyReports.js
|
|
4215
|
-
import { z as
|
|
4525
|
+
import { z as z107 } from "zod";
|
|
4216
4526
|
import dayjs3 from "dayjs";
|
|
4217
|
-
var weeklyReportSchema =
|
|
4218
|
-
startDate:
|
|
4219
|
-
endDate:
|
|
4220
|
-
report:
|
|
4221
|
-
aiInsights:
|
|
4527
|
+
var weeklyReportSchema = z107.object({
|
|
4528
|
+
startDate: z107.string(),
|
|
4529
|
+
endDate: z107.string(),
|
|
4530
|
+
report: z107.string(),
|
|
4531
|
+
aiInsights: z107.string().nullable()
|
|
4222
4532
|
});
|
|
4223
4533
|
|
|
4224
4534
|
// ../../b4m-core/packages/services/dist/src/embeddingCacheService/generateCacheKey.js
|
|
4225
4535
|
import crypto2 from "crypto";
|
|
4226
4536
|
|
|
4227
4537
|
// ../../b4m-core/packages/services/dist/src/researchAgentService/create.js
|
|
4228
|
-
import { z as z107 } from "zod";
|
|
4229
|
-
var researchAgentCreateSchema = z107.object({
|
|
4230
|
-
name: z107.string().min(1),
|
|
4231
|
-
description: z107.string().min(1)
|
|
4232
|
-
});
|
|
4233
|
-
|
|
4234
|
-
// ../../b4m-core/packages/services/dist/src/researchAgentService/update.js
|
|
4235
4538
|
import { z as z108 } from "zod";
|
|
4236
|
-
var
|
|
4237
|
-
id: z108.string(),
|
|
4539
|
+
var researchAgentCreateSchema = z108.object({
|
|
4238
4540
|
name: z108.string().min(1),
|
|
4239
4541
|
description: z108.string().min(1)
|
|
4240
4542
|
});
|
|
4241
4543
|
|
|
4242
|
-
// ../../b4m-core/packages/services/dist/src/researchAgentService/
|
|
4544
|
+
// ../../b4m-core/packages/services/dist/src/researchAgentService/update.js
|
|
4243
4545
|
import { z as z109 } from "zod";
|
|
4244
|
-
var
|
|
4245
|
-
id: z109.string()
|
|
4546
|
+
var researchAgentUpdateSchema = z109.object({
|
|
4547
|
+
id: z109.string(),
|
|
4548
|
+
name: z109.string().min(1),
|
|
4549
|
+
description: z109.string().min(1)
|
|
4246
4550
|
});
|
|
4247
4551
|
|
|
4248
|
-
// ../../b4m-core/packages/services/dist/src/researchAgentService/
|
|
4552
|
+
// ../../b4m-core/packages/services/dist/src/researchAgentService/remove.js
|
|
4249
4553
|
import { z as z110 } from "zod";
|
|
4250
|
-
var
|
|
4554
|
+
var researchAgentRemoveSchema = z110.object({
|
|
4251
4555
|
id: z110.string()
|
|
4252
4556
|
});
|
|
4253
4557
|
|
|
4254
|
-
// ../../b4m-core/packages/services/dist/src/researchAgentService/
|
|
4558
|
+
// ../../b4m-core/packages/services/dist/src/researchAgentService/get.js
|
|
4255
4559
|
import { z as z111 } from "zod";
|
|
4256
|
-
var
|
|
4560
|
+
var researchAgentGetSchema = z111.object({
|
|
4561
|
+
id: z111.string()
|
|
4562
|
+
});
|
|
4563
|
+
|
|
4564
|
+
// ../../b4m-core/packages/services/dist/src/researchAgentService/listFiles.js
|
|
4565
|
+
import { z as z112 } from "zod";
|
|
4566
|
+
var researchAgentListFilesSchema = z112.object({
|
|
4257
4567
|
/**
|
|
4258
4568
|
* The ID of the research agent
|
|
4259
4569
|
*/
|
|
4260
|
-
id:
|
|
4570
|
+
id: z112.string()
|
|
4261
4571
|
});
|
|
4262
4572
|
|
|
4263
4573
|
// ../../b4m-core/packages/services/dist/src/researchTaskService/process.js
|
|
4264
|
-
import { z as
|
|
4574
|
+
import { z as z113 } from "zod";
|
|
4265
4575
|
|
|
4266
4576
|
// ../../b4m-core/packages/services/dist/src/lib/turndown.js
|
|
4267
4577
|
import turndown from "turndown";
|
|
@@ -4652,316 +4962,316 @@ var deepResearchTool = {
|
|
|
4652
4962
|
};
|
|
4653
4963
|
|
|
4654
4964
|
// ../../b4m-core/packages/services/dist/src/researchTaskService/process.js
|
|
4655
|
-
var ResearchTaskProcessSchema =
|
|
4656
|
-
id:
|
|
4965
|
+
var ResearchTaskProcessSchema = z113.object({
|
|
4966
|
+
id: z113.string()
|
|
4657
4967
|
});
|
|
4658
4968
|
|
|
4659
4969
|
// ../../b4m-core/packages/services/dist/src/researchTaskService/create.js
|
|
4660
|
-
import { z as
|
|
4661
|
-
var researchTaskCreateSchema =
|
|
4662
|
-
researchAgentId:
|
|
4663
|
-
title:
|
|
4664
|
-
description:
|
|
4665
|
-
prompt:
|
|
4666
|
-
type:
|
|
4667
|
-
executionType:
|
|
4668
|
-
fileTagId:
|
|
4669
|
-
autoGeneratedTag:
|
|
4670
|
-
name:
|
|
4671
|
-
icon:
|
|
4672
|
-
color:
|
|
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()
|
|
4673
4983
|
}).optional()
|
|
4674
4984
|
});
|
|
4675
4985
|
var researchTaskScrapeCreateSchema = researchTaskCreateSchema.extend({
|
|
4676
|
-
urls:
|
|
4677
|
-
canDiscoverLinks:
|
|
4986
|
+
urls: z114.array(z114.string().url()).min(1),
|
|
4987
|
+
canDiscoverLinks: z114.boolean()
|
|
4678
4988
|
});
|
|
4679
4989
|
var researchTaskPeriodicCreateSchema = researchTaskCreateSchema.extend({
|
|
4680
|
-
executionPeriodicStartAt:
|
|
4681
|
-
executionPeriodicEndAt:
|
|
4682
|
-
executionPeriodicFrequency:
|
|
4990
|
+
executionPeriodicStartAt: z114.coerce.date(),
|
|
4991
|
+
executionPeriodicEndAt: z114.coerce.date(),
|
|
4992
|
+
executionPeriodicFrequency: z114.nativeEnum(ResearchTaskPeriodicFrequencyType)
|
|
4683
4993
|
});
|
|
4684
4994
|
var researchTaskScheduledCreateSchema = researchTaskCreateSchema.extend({
|
|
4685
|
-
executionScheduledAt:
|
|
4995
|
+
executionScheduledAt: z114.coerce.date()
|
|
4686
4996
|
});
|
|
4687
4997
|
var researchTaskDeepResearchCreateSchema = researchTaskCreateSchema.extend({
|
|
4688
|
-
maxDepth:
|
|
4998
|
+
maxDepth: z114.number().min(1).max(10).optional()
|
|
4689
4999
|
});
|
|
4690
5000
|
|
|
4691
5001
|
// ../../b4m-core/packages/services/dist/src/researchTaskService/search.js
|
|
4692
|
-
import { z as
|
|
4693
|
-
var searchResearchTasksSchema =
|
|
4694
|
-
search:
|
|
5002
|
+
import { z as z115 } from "zod";
|
|
5003
|
+
var searchResearchTasksSchema = z115.object({
|
|
5004
|
+
search: z115.string().optional(),
|
|
4695
5005
|
// ADD FILTERS SCHEMA HERE
|
|
4696
5006
|
// filters: z
|
|
4697
5007
|
// .object({
|
|
4698
5008
|
// userId: z.string().optional(),
|
|
4699
5009
|
// })
|
|
4700
5010
|
// .optional(),
|
|
4701
|
-
pagination:
|
|
4702
|
-
page:
|
|
4703
|
-
limit:
|
|
5011
|
+
pagination: z115.object({
|
|
5012
|
+
page: z115.coerce.number().optional(),
|
|
5013
|
+
limit: z115.coerce.number().optional()
|
|
4704
5014
|
}).optional(),
|
|
4705
|
-
orderBy:
|
|
4706
|
-
by:
|
|
4707
|
-
direction:
|
|
5015
|
+
orderBy: z115.object({
|
|
5016
|
+
by: z115.enum(["createdAt", "updatedAt"]).optional(),
|
|
5017
|
+
direction: z115.enum(["asc", "desc"]).optional()
|
|
4708
5018
|
}).optional()
|
|
4709
5019
|
});
|
|
4710
5020
|
|
|
4711
5021
|
// ../../b4m-core/packages/services/dist/src/researchTaskService/get.js
|
|
4712
|
-
import { z as
|
|
4713
|
-
var getResearchTaskSchema =
|
|
4714
|
-
id:
|
|
5022
|
+
import { z as z116 } from "zod";
|
|
5023
|
+
var getResearchTaskSchema = z116.object({
|
|
5024
|
+
id: z116.string().min(1)
|
|
4715
5025
|
});
|
|
4716
5026
|
|
|
4717
5027
|
// ../../b4m-core/packages/services/dist/src/researchTaskService/update.js
|
|
4718
|
-
import { z as
|
|
4719
|
-
var updateResearchTaskSchema =
|
|
4720
|
-
id:
|
|
4721
|
-
title:
|
|
4722
|
-
description:
|
|
4723
|
-
type:
|
|
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)
|
|
4724
5034
|
});
|
|
4725
5035
|
var researchTaskScrapeUpdateSchema = updateResearchTaskSchema.extend({
|
|
4726
|
-
urls:
|
|
4727
|
-
canDiscoverLinks:
|
|
5036
|
+
urls: z117.array(z117.string().url()).min(1),
|
|
5037
|
+
canDiscoverLinks: z117.boolean()
|
|
4728
5038
|
});
|
|
4729
5039
|
|
|
4730
5040
|
// ../../b4m-core/packages/services/dist/src/researchTaskService/listByAgentId.js
|
|
4731
|
-
import { z as
|
|
4732
|
-
var listByAgentIdSchema =
|
|
4733
|
-
researchAgentId:
|
|
5041
|
+
import { z as z118 } from "zod";
|
|
5042
|
+
var listByAgentIdSchema = z118.object({
|
|
5043
|
+
researchAgentId: z118.string()
|
|
4734
5044
|
});
|
|
4735
5045
|
|
|
4736
5046
|
// ../../b4m-core/packages/services/dist/src/researchTaskService/remove.js
|
|
4737
|
-
import { z as
|
|
4738
|
-
var researchTaskRemoveSchema =
|
|
4739
|
-
id:
|
|
5047
|
+
import { z as z119 } from "zod";
|
|
5048
|
+
var researchTaskRemoveSchema = z119.object({
|
|
5049
|
+
id: z119.string().min(1)
|
|
4740
5050
|
});
|
|
4741
5051
|
|
|
4742
5052
|
// ../../b4m-core/packages/services/dist/src/researchTaskService/retry.js
|
|
4743
|
-
import { z as
|
|
4744
|
-
var researchTaskRetrySchema =
|
|
4745
|
-
id:
|
|
4746
|
-
userId:
|
|
5053
|
+
import { z as z120 } from "zod";
|
|
5054
|
+
var researchTaskRetrySchema = z120.object({
|
|
5055
|
+
id: z120.string(),
|
|
5056
|
+
userId: z120.string()
|
|
4747
5057
|
});
|
|
4748
5058
|
|
|
4749
5059
|
// ../../b4m-core/packages/services/dist/src/researchTaskService/processDiscoveredLinks.js
|
|
4750
5060
|
import axios4 from "axios";
|
|
4751
|
-
import { z as
|
|
5061
|
+
import { z as z121 } from "zod";
|
|
4752
5062
|
import plimit from "p-limit";
|
|
4753
5063
|
import pLimit2 from "p-limit";
|
|
4754
|
-
var researchTaskProcessDiscoveredLinksSchema =
|
|
4755
|
-
id:
|
|
5064
|
+
var researchTaskProcessDiscoveredLinksSchema = z121.object({
|
|
5065
|
+
id: z121.string()
|
|
4756
5066
|
});
|
|
4757
5067
|
|
|
4758
5068
|
// ../../b4m-core/packages/services/dist/src/researchTaskService/downloadRelevantLinks.js
|
|
4759
|
-
import { z as
|
|
5069
|
+
import { z as z122 } from "zod";
|
|
4760
5070
|
import plimit2 from "p-limit";
|
|
4761
5071
|
import axios5 from "axios";
|
|
4762
5072
|
import { fileTypeFromBuffer } from "file-type";
|
|
4763
|
-
var researchTaskDownloadRelevantLinksSchema =
|
|
4764
|
-
id:
|
|
5073
|
+
var researchTaskDownloadRelevantLinksSchema = z122.object({
|
|
5074
|
+
id: z122.string()
|
|
4765
5075
|
});
|
|
4766
5076
|
|
|
4767
5077
|
// ../../b4m-core/packages/services/dist/src/researchData/remove.js
|
|
4768
|
-
import { z as
|
|
4769
|
-
var researchDataRemoveSchema =
|
|
4770
|
-
id:
|
|
4771
|
-
researchAgentId:
|
|
5078
|
+
import { z as z123 } from "zod";
|
|
5079
|
+
var researchDataRemoveSchema = z123.object({
|
|
5080
|
+
id: z123.string(),
|
|
5081
|
+
researchAgentId: z123.string()
|
|
4772
5082
|
});
|
|
4773
5083
|
|
|
4774
5084
|
// ../../b4m-core/packages/services/dist/src/taskSchedulerService/create.js
|
|
4775
|
-
import { z as
|
|
4776
|
-
var researchTaskPayload =
|
|
4777
|
-
id:
|
|
4778
|
-
userId:
|
|
5085
|
+
import { z as z124 } from "zod";
|
|
5086
|
+
var researchTaskPayload = z124.object({
|
|
5087
|
+
id: z124.string(),
|
|
5088
|
+
userId: z124.string()
|
|
4779
5089
|
});
|
|
4780
|
-
var customTaskPayload =
|
|
4781
|
-
test:
|
|
5090
|
+
var customTaskPayload = z124.object({
|
|
5091
|
+
test: z124.string()
|
|
4782
5092
|
});
|
|
4783
|
-
var taskSchedulerCreate =
|
|
4784
|
-
|
|
4785
|
-
handler:
|
|
5093
|
+
var taskSchedulerCreate = z124.discriminatedUnion("handler", [
|
|
5094
|
+
z124.object({
|
|
5095
|
+
handler: z124.literal(TaskScheduleHandler.RESEARCH_TASK_PROCESS),
|
|
4786
5096
|
payload: researchTaskPayload,
|
|
4787
|
-
processDate:
|
|
5097
|
+
processDate: z124.date()
|
|
4788
5098
|
}),
|
|
4789
|
-
|
|
4790
|
-
handler:
|
|
5099
|
+
z124.object({
|
|
5100
|
+
handler: z124.literal(TaskScheduleHandler.CUSTOM_TASK_PROCESS),
|
|
4791
5101
|
payload: customTaskPayload,
|
|
4792
|
-
processDate:
|
|
5102
|
+
processDate: z124.date()
|
|
4793
5103
|
})
|
|
4794
5104
|
]);
|
|
4795
5105
|
|
|
4796
5106
|
// ../../b4m-core/packages/services/dist/src/tagService/createFileTag.js
|
|
4797
|
-
import { z as z124 } from "zod";
|
|
4798
|
-
var tagCreateFileTagSchema = z124.object({
|
|
4799
|
-
name: z124.string(),
|
|
4800
|
-
icon: z124.string().optional(),
|
|
4801
|
-
color: z124.string().optional(),
|
|
4802
|
-
description: z124.string().optional()
|
|
4803
|
-
});
|
|
4804
|
-
|
|
4805
|
-
// ../../b4m-core/packages/services/dist/src/tagService/create.js
|
|
4806
5107
|
import { z as z125 } from "zod";
|
|
4807
|
-
var
|
|
5108
|
+
var tagCreateFileTagSchema = z125.object({
|
|
4808
5109
|
name: z125.string(),
|
|
4809
5110
|
icon: z125.string().optional(),
|
|
4810
|
-
description: z125.string().optional(),
|
|
4811
5111
|
color: z125.string().optional(),
|
|
4812
|
-
|
|
5112
|
+
description: z125.string().optional()
|
|
4813
5113
|
});
|
|
4814
5114
|
|
|
4815
|
-
// ../../b4m-core/packages/services/dist/src/tagService/
|
|
5115
|
+
// ../../b4m-core/packages/services/dist/src/tagService/create.js
|
|
4816
5116
|
import { z as z126 } from "zod";
|
|
4817
|
-
var
|
|
4818
|
-
|
|
4819
|
-
name: z126.string().optional(),
|
|
5117
|
+
var tagCreateSchema = z126.object({
|
|
5118
|
+
name: z126.string(),
|
|
4820
5119
|
icon: z126.string().optional(),
|
|
4821
5120
|
description: z126.string().optional(),
|
|
4822
|
-
color: z126.string().optional()
|
|
5121
|
+
color: z126.string().optional(),
|
|
5122
|
+
type: z126.nativeEnum(TagType)
|
|
4823
5123
|
});
|
|
4824
5124
|
|
|
4825
|
-
// ../../b4m-core/packages/services/dist/src/tagService/
|
|
5125
|
+
// ../../b4m-core/packages/services/dist/src/tagService/update.js
|
|
4826
5126
|
import { z as z127 } from "zod";
|
|
4827
|
-
var
|
|
4828
|
-
id: z127.string()
|
|
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()
|
|
4829
5133
|
});
|
|
4830
5134
|
|
|
4831
|
-
// ../../b4m-core/packages/services/dist/src/
|
|
5135
|
+
// ../../b4m-core/packages/services/dist/src/tagService/remove.js
|
|
4832
5136
|
import { z as z128 } from "zod";
|
|
4833
|
-
var
|
|
4834
|
-
id: z128.string()
|
|
5137
|
+
var tagRemoveSchema = z128.object({
|
|
5138
|
+
id: z128.string()
|
|
5139
|
+
});
|
|
5140
|
+
|
|
5141
|
+
// ../../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(),
|
|
4835
5145
|
// Allow custom ID for AI-generated artifacts
|
|
4836
|
-
type:
|
|
4837
|
-
title:
|
|
4838
|
-
description:
|
|
4839
|
-
content:
|
|
4840
|
-
projectId:
|
|
4841
|
-
organizationId:
|
|
4842
|
-
visibility:
|
|
4843
|
-
tags:
|
|
4844
|
-
versionTag:
|
|
4845
|
-
sourceQuestId:
|
|
4846
|
-
sessionId:
|
|
4847
|
-
parentArtifactId:
|
|
4848
|
-
permissions:
|
|
4849
|
-
canRead:
|
|
4850
|
-
canWrite:
|
|
4851
|
-
canDelete:
|
|
4852
|
-
isPublic:
|
|
4853
|
-
inheritFromProject:
|
|
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)
|
|
4854
5164
|
}).optional(),
|
|
4855
|
-
metadata:
|
|
5165
|
+
metadata: z129.record(z129.unknown()).default({})
|
|
4856
5166
|
});
|
|
4857
5167
|
|
|
4858
5168
|
// ../../b4m-core/packages/services/dist/src/artifactService/get.js
|
|
4859
|
-
import { z as
|
|
4860
|
-
var getArtifactSchema =
|
|
4861
|
-
id:
|
|
4862
|
-
includeContent:
|
|
4863
|
-
includeVersions:
|
|
4864
|
-
version:
|
|
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()
|
|
4865
5175
|
});
|
|
4866
5176
|
|
|
4867
5177
|
// ../../b4m-core/packages/services/dist/src/artifactService/list.js
|
|
4868
|
-
import { z as
|
|
4869
|
-
var listArtifactsSchema =
|
|
4870
|
-
type:
|
|
4871
|
-
status:
|
|
4872
|
-
visibility:
|
|
4873
|
-
projectId:
|
|
4874
|
-
sessionId:
|
|
4875
|
-
tags:
|
|
4876
|
-
search:
|
|
4877
|
-
limit:
|
|
4878
|
-
offset:
|
|
4879
|
-
sortBy:
|
|
4880
|
-
sortOrder:
|
|
4881
|
-
includeDeleted:
|
|
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)
|
|
4882
5192
|
});
|
|
4883
5193
|
|
|
4884
5194
|
// ../../b4m-core/packages/services/dist/src/artifactService/update.js
|
|
4885
|
-
import { z as
|
|
4886
|
-
var updateArtifactSchema =
|
|
4887
|
-
id:
|
|
4888
|
-
title:
|
|
4889
|
-
description:
|
|
4890
|
-
content:
|
|
4891
|
-
visibility:
|
|
4892
|
-
status:
|
|
4893
|
-
tags:
|
|
4894
|
-
versionTag:
|
|
4895
|
-
permissions:
|
|
4896
|
-
canRead:
|
|
4897
|
-
canWrite:
|
|
4898
|
-
canDelete:
|
|
4899
|
-
isPublic:
|
|
4900
|
-
inheritFromProject:
|
|
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()
|
|
4901
5211
|
}).optional(),
|
|
4902
|
-
metadata:
|
|
4903
|
-
changes:
|
|
4904
|
-
changeDescription:
|
|
4905
|
-
createNewVersion:
|
|
4906
|
-
versionMessage:
|
|
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()
|
|
4907
5217
|
});
|
|
4908
5218
|
|
|
4909
5219
|
// ../../b4m-core/packages/services/dist/src/artifactService/delete.js
|
|
4910
|
-
import { z as
|
|
4911
|
-
var deleteArtifactSchema =
|
|
4912
|
-
id:
|
|
4913
|
-
hardDelete:
|
|
5220
|
+
import { z as z133 } from "zod";
|
|
5221
|
+
var deleteArtifactSchema = z133.object({
|
|
5222
|
+
id: z133.string(),
|
|
5223
|
+
hardDelete: z133.boolean().default(false)
|
|
4914
5224
|
// For future implementation
|
|
4915
5225
|
});
|
|
4916
5226
|
|
|
4917
5227
|
// ../../b4m-core/packages/services/dist/src/questMasterService/create.js
|
|
4918
|
-
import { z as
|
|
4919
|
-
var questSchema =
|
|
4920
|
-
id:
|
|
4921
|
-
title:
|
|
4922
|
-
description:
|
|
4923
|
-
status:
|
|
4924
|
-
order:
|
|
4925
|
-
dependencies:
|
|
4926
|
-
estimatedTime:
|
|
4927
|
-
});
|
|
4928
|
-
var questResourceSchema =
|
|
4929
|
-
title:
|
|
4930
|
-
url:
|
|
4931
|
-
type:
|
|
4932
|
-
});
|
|
4933
|
-
var createQuestMasterSchema =
|
|
4934
|
-
title:
|
|
4935
|
-
description:
|
|
4936
|
-
goal:
|
|
4937
|
-
complexity:
|
|
4938
|
-
estimatedTotalTime:
|
|
4939
|
-
prerequisites:
|
|
4940
|
-
quests:
|
|
4941
|
-
resources:
|
|
4942
|
-
projectId:
|
|
4943
|
-
organizationId:
|
|
4944
|
-
visibility:
|
|
4945
|
-
tags:
|
|
4946
|
-
permissions:
|
|
4947
|
-
canRead:
|
|
4948
|
-
canWrite:
|
|
4949
|
-
canDelete:
|
|
4950
|
-
isPublic:
|
|
4951
|
-
inheritFromProject:
|
|
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)
|
|
4952
5262
|
}).optional(),
|
|
4953
|
-
sourceQuestId:
|
|
4954
|
-
sessionId:
|
|
4955
|
-
metadata:
|
|
5263
|
+
sourceQuestId: z134.string().optional(),
|
|
5264
|
+
sessionId: z134.string().optional(),
|
|
5265
|
+
metadata: z134.record(z134.unknown()).default({})
|
|
4956
5266
|
});
|
|
4957
5267
|
|
|
4958
5268
|
// ../../b4m-core/packages/services/dist/src/questMasterService/updateQuestStatus.js
|
|
4959
|
-
import { z as
|
|
4960
|
-
var updateQuestStatusSchema =
|
|
4961
|
-
artifactId:
|
|
4962
|
-
questId:
|
|
4963
|
-
status:
|
|
4964
|
-
completionNote:
|
|
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()
|
|
4965
5275
|
});
|
|
4966
5276
|
|
|
4967
5277
|
// ../../b4m-core/packages/services/dist/src/dataLakeService/opensearchClient.js
|
|
@@ -4981,63 +5291,63 @@ import { v4 as uuidv44 } from "uuid";
|
|
|
4981
5291
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
4982
5292
|
|
|
4983
5293
|
// ../../b4m-core/packages/services/dist/src/emailIngestionService/types.js
|
|
4984
|
-
import { z as
|
|
4985
|
-
var processIngestedEmailOptionsSchema =
|
|
4986
|
-
platformDomain:
|
|
4987
|
-
isNewsletter:
|
|
5294
|
+
import { z as z136 } from "zod";
|
|
5295
|
+
var processIngestedEmailOptionsSchema = z136.object({
|
|
5296
|
+
platformDomain: z136.string().optional(),
|
|
5297
|
+
isNewsletter: z136.boolean().optional()
|
|
4988
5298
|
}).optional();
|
|
4989
|
-
var emailAttachmentSchema =
|
|
4990
|
-
filename:
|
|
4991
|
-
contentType:
|
|
4992
|
-
contentDisposition:
|
|
4993
|
-
size:
|
|
4994
|
-
content:
|
|
4995
|
-
related:
|
|
4996
|
-
});
|
|
4997
|
-
var parsedEmailObjectSchema =
|
|
4998
|
-
messageId:
|
|
4999
|
-
inReplyTo:
|
|
5000
|
-
references:
|
|
5001
|
-
from:
|
|
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(),
|
|
5002
5312
|
// Complex email address object
|
|
5003
|
-
to:
|
|
5004
|
-
cc:
|
|
5005
|
-
bcc:
|
|
5006
|
-
subject:
|
|
5007
|
-
date:
|
|
5008
|
-
text:
|
|
5009
|
-
html:
|
|
5010
|
-
attachments:
|
|
5011
|
-
});
|
|
5012
|
-
var processIngestedEmailSchema =
|
|
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({
|
|
5013
5323
|
parsedEmail: parsedEmailObjectSchema,
|
|
5014
|
-
rawEmailS3Key:
|
|
5324
|
+
rawEmailS3Key: z136.string().min(1, "rawEmailS3Key cannot be empty"),
|
|
5015
5325
|
options: processIngestedEmailOptionsSchema
|
|
5016
5326
|
});
|
|
5017
5327
|
|
|
5018
5328
|
// ../../b4m-core/packages/services/dist/src/emailAnalysisService/types.js
|
|
5019
|
-
import { z as
|
|
5020
|
-
var llmAnalysisResponseSchema =
|
|
5021
|
-
summary:
|
|
5022
|
-
entities:
|
|
5023
|
-
companies:
|
|
5024
|
-
people:
|
|
5025
|
-
products:
|
|
5026
|
-
technologies:
|
|
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([])
|
|
5027
5337
|
}),
|
|
5028
|
-
sentiment:
|
|
5029
|
-
actionItems:
|
|
5030
|
-
description:
|
|
5031
|
-
deadline:
|
|
5338
|
+
sentiment: z137.enum(["positive", "neutral", "negative", "urgent"]),
|
|
5339
|
+
actionItems: z137.array(z137.object({
|
|
5340
|
+
description: z137.string(),
|
|
5341
|
+
deadline: z137.string().optional()
|
|
5032
5342
|
// ISO date string from LLM
|
|
5033
5343
|
})).default([]),
|
|
5034
|
-
privacyRecommendation:
|
|
5035
|
-
embargoDetected:
|
|
5036
|
-
suggestedTags:
|
|
5344
|
+
privacyRecommendation: z137.enum(["public", "team", "private"]),
|
|
5345
|
+
embargoDetected: z137.boolean().default(false),
|
|
5346
|
+
suggestedTags: z137.array(z137.string()).default([])
|
|
5037
5347
|
});
|
|
5038
5348
|
|
|
5039
5349
|
// ../../b4m-core/packages/services/dist/src/llm/ChatCompletion.js
|
|
5040
|
-
import { z as
|
|
5350
|
+
import { z as z139 } from "zod";
|
|
5041
5351
|
|
|
5042
5352
|
// ../../b4m-core/packages/services/dist/src/llm/ChatCompletionInvoke.js
|
|
5043
5353
|
import { fromZodError } from "zod-validation-error";
|
|
@@ -5151,8 +5461,8 @@ async function processAndStoreImages(images, context) {
|
|
|
5151
5461
|
const buffer = await downloadImage(image);
|
|
5152
5462
|
const fileType = await fileTypeFromBuffer2(buffer);
|
|
5153
5463
|
const filename = `${uuidv45()}.${fileType?.ext}`;
|
|
5154
|
-
const
|
|
5155
|
-
return
|
|
5464
|
+
const path16 = await context.imageGenerateStorage.upload(buffer, filename, {});
|
|
5465
|
+
return path16;
|
|
5156
5466
|
}));
|
|
5157
5467
|
}
|
|
5158
5468
|
async function updateQuestAndReturnMarkdown(storedImageUrls, context) {
|
|
@@ -6125,17 +6435,17 @@ var rechartsTool = {
|
|
|
6125
6435
|
};
|
|
6126
6436
|
|
|
6127
6437
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/editFile/index.js
|
|
6128
|
-
import { z as
|
|
6438
|
+
import { z as z138 } from "zod";
|
|
6129
6439
|
import { diffLines as diffLines2 } from "diff";
|
|
6130
|
-
var editFileSchema =
|
|
6131
|
-
fileId:
|
|
6132
|
-
instruction:
|
|
6133
|
-
selection:
|
|
6134
|
-
start:
|
|
6135
|
-
end:
|
|
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")
|
|
6136
6446
|
}).optional().describe("Optional selection range to edit within the file"),
|
|
6137
|
-
preserveFormatting:
|
|
6138
|
-
returnDiff:
|
|
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")
|
|
6139
6449
|
});
|
|
6140
6450
|
function generateSimpleDiff(original, modified) {
|
|
6141
6451
|
const differences = diffLines2(original, modified);
|
|
@@ -6364,8 +6674,8 @@ async function processAndStoreImage(imageUrl, context) {
|
|
|
6364
6674
|
const buffer = await downloadImage2(imageUrl);
|
|
6365
6675
|
const fileType = await fileTypeFromBuffer3(buffer);
|
|
6366
6676
|
const filename = `${uuidv46()}.${fileType?.ext}`;
|
|
6367
|
-
const
|
|
6368
|
-
return
|
|
6677
|
+
const path16 = await context.imageGenerateStorage.upload(buffer, filename, {});
|
|
6678
|
+
return path16;
|
|
6369
6679
|
}
|
|
6370
6680
|
async function updateQuestAndReturnMarkdown2(storedImagePath, context) {
|
|
6371
6681
|
await context.onFinish?.("edit_image", storedImagePath);
|
|
@@ -7894,8 +8204,8 @@ var getHeliocentricCoords = (planet, T) => {
|
|
|
7894
8204
|
const sinNode = Math.sin(longNode);
|
|
7895
8205
|
const x = r * (cosNode * cosOmega - sinNode * sinOmega * cosI);
|
|
7896
8206
|
const y = r * (sinNode * cosOmega + cosNode * sinOmega * cosI);
|
|
7897
|
-
const
|
|
7898
|
-
return { x, y, z:
|
|
8207
|
+
const z145 = r * sinOmega * sinI;
|
|
8208
|
+
return { x, y, z: z145, r };
|
|
7899
8209
|
};
|
|
7900
8210
|
var getGeocentricEcliptic = (planet, earth) => {
|
|
7901
8211
|
const dx = planet.x - earth.x;
|
|
@@ -8202,15 +8512,15 @@ var planetVisibilityTool = {
|
|
|
8202
8512
|
};
|
|
8203
8513
|
|
|
8204
8514
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/fileRead/index.js
|
|
8205
|
-
import { promises as
|
|
8515
|
+
import { promises as fs8 } from "fs";
|
|
8206
8516
|
import { existsSync as existsSync4, statSync as statSync4 } from "fs";
|
|
8207
|
-
import
|
|
8517
|
+
import path7 from "path";
|
|
8208
8518
|
var MAX_FILE_SIZE2 = 10 * 1024 * 1024;
|
|
8209
8519
|
async function readFileContent(params) {
|
|
8210
8520
|
const { path: filePath, encoding = "utf-8", maxLines } = params;
|
|
8211
|
-
const normalizedPath =
|
|
8212
|
-
const resolvedPath =
|
|
8213
|
-
const cwd =
|
|
8521
|
+
const normalizedPath = path7.normalize(filePath);
|
|
8522
|
+
const resolvedPath = path7.resolve(process.cwd(), normalizedPath);
|
|
8523
|
+
const cwd = path7.resolve(process.cwd());
|
|
8214
8524
|
if (!resolvedPath.startsWith(cwd)) {
|
|
8215
8525
|
throw new Error(`Access denied: Cannot read files outside of current working directory`);
|
|
8216
8526
|
}
|
|
@@ -8228,7 +8538,7 @@ async function readFileContent(params) {
|
|
|
8228
8538
|
if (isBinary && encoding === "utf-8") {
|
|
8229
8539
|
throw new Error(`File appears to be binary. Use encoding 'base64' to read binary files, or specify a different encoding.`);
|
|
8230
8540
|
}
|
|
8231
|
-
const content = await
|
|
8541
|
+
const content = await fs8.readFile(resolvedPath, encoding);
|
|
8232
8542
|
if (maxLines && typeof content === "string") {
|
|
8233
8543
|
const lines = content.split("\n");
|
|
8234
8544
|
if (lines.length > maxLines) {
|
|
@@ -8243,7 +8553,7 @@ ${content}`;
|
|
|
8243
8553
|
}
|
|
8244
8554
|
async function checkIfBinary(filePath) {
|
|
8245
8555
|
const buffer = Buffer.alloc(8192);
|
|
8246
|
-
const fd = await
|
|
8556
|
+
const fd = await fs8.open(filePath, "r");
|
|
8247
8557
|
try {
|
|
8248
8558
|
const { bytesRead } = await fd.read(buffer, 0, 8192, 0);
|
|
8249
8559
|
const chunk = buffer.slice(0, bytesRead);
|
|
@@ -8260,7 +8570,7 @@ var fileReadTool = {
|
|
|
8260
8570
|
context.logger.info("\u{1F4C4} FileRead: Reading file", { path: params.path });
|
|
8261
8571
|
try {
|
|
8262
8572
|
const content = await readFileContent(params);
|
|
8263
|
-
const stats = statSync4(
|
|
8573
|
+
const stats = statSync4(path7.resolve(process.cwd(), path7.normalize(params.path)));
|
|
8264
8574
|
context.logger.info("\u2705 FileRead: Success", {
|
|
8265
8575
|
path: params.path,
|
|
8266
8576
|
size: stats.size,
|
|
@@ -8269,7 +8579,8 @@ var fileReadTool = {
|
|
|
8269
8579
|
return content;
|
|
8270
8580
|
} catch (error) {
|
|
8271
8581
|
context.logger.error("\u274C FileRead: Failed", error);
|
|
8272
|
-
|
|
8582
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
8583
|
+
return `Error reading file: ${errorMessage}`;
|
|
8273
8584
|
}
|
|
8274
8585
|
},
|
|
8275
8586
|
toolSchema: {
|
|
@@ -8299,25 +8610,25 @@ var fileReadTool = {
|
|
|
8299
8610
|
};
|
|
8300
8611
|
|
|
8301
8612
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/createFile/index.js
|
|
8302
|
-
import { promises as
|
|
8613
|
+
import { promises as fs9 } from "fs";
|
|
8303
8614
|
import { existsSync as existsSync5 } from "fs";
|
|
8304
|
-
import
|
|
8615
|
+
import path8 from "path";
|
|
8305
8616
|
async function createFile(params) {
|
|
8306
8617
|
const { path: filePath, content, createDirectories = true } = params;
|
|
8307
|
-
const normalizedPath =
|
|
8308
|
-
const resolvedPath =
|
|
8309
|
-
const cwd =
|
|
8618
|
+
const normalizedPath = path8.normalize(filePath);
|
|
8619
|
+
const resolvedPath = path8.resolve(process.cwd(), normalizedPath);
|
|
8620
|
+
const cwd = path8.resolve(process.cwd());
|
|
8310
8621
|
if (!resolvedPath.startsWith(cwd)) {
|
|
8311
8622
|
throw new Error(`Access denied: Cannot create files outside of current working directory`);
|
|
8312
8623
|
}
|
|
8313
8624
|
const fileExists = existsSync5(resolvedPath);
|
|
8314
8625
|
const action = fileExists ? "overwritten" : "created";
|
|
8315
8626
|
if (createDirectories) {
|
|
8316
|
-
const dir =
|
|
8317
|
-
await
|
|
8627
|
+
const dir = path8.dirname(resolvedPath);
|
|
8628
|
+
await fs9.mkdir(dir, { recursive: true });
|
|
8318
8629
|
}
|
|
8319
|
-
await
|
|
8320
|
-
const stats = await
|
|
8630
|
+
await fs9.writeFile(resolvedPath, content, "utf-8");
|
|
8631
|
+
const stats = await fs9.stat(resolvedPath);
|
|
8321
8632
|
const lines = content.split("\n").length;
|
|
8322
8633
|
return `File ${action} successfully: ${filePath}
|
|
8323
8634
|
Size: ${stats.size} bytes
|
|
@@ -8328,7 +8639,7 @@ var createFileTool = {
|
|
|
8328
8639
|
implementation: (context) => ({
|
|
8329
8640
|
toolFn: async (value) => {
|
|
8330
8641
|
const params = value;
|
|
8331
|
-
const fileExists = existsSync5(
|
|
8642
|
+
const fileExists = existsSync5(path8.resolve(process.cwd(), path8.normalize(params.path)));
|
|
8332
8643
|
context.logger.info(`\u{1F4DD} CreateFile: ${fileExists ? "Overwriting" : "Creating"} file`, {
|
|
8333
8644
|
path: params.path,
|
|
8334
8645
|
size: params.content.length
|
|
@@ -8370,7 +8681,7 @@ var createFileTool = {
|
|
|
8370
8681
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/globFiles/index.js
|
|
8371
8682
|
import { readdir } from "fs/promises";
|
|
8372
8683
|
import { statSync as statSync5 } from "fs";
|
|
8373
|
-
import
|
|
8684
|
+
import path9 from "path";
|
|
8374
8685
|
function matchGlob(filePath, pattern) {
|
|
8375
8686
|
let regexPattern = pattern.replace(/\./g, "\\.").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (_, options) => `(${options.split(",").join("|")})`).replace(/\[([^\]]+)\]/g, "[$1]");
|
|
8376
8687
|
regexPattern = regexPattern.replace(/\{\{GLOBSTAR\}\}\//g, "(.*/)?").replace(/\/\{\{GLOBSTAR\}\}/g, "(/.*)?").replace(/\{\{GLOBSTAR\}\}/g, ".*");
|
|
@@ -8388,8 +8699,8 @@ async function walkDir(dir, pattern, includeHidden, maxResults, basePath = "") {
|
|
|
8388
8699
|
if (!includeHidden && entry.name.startsWith(".")) {
|
|
8389
8700
|
continue;
|
|
8390
8701
|
}
|
|
8391
|
-
const relativePath = basePath ?
|
|
8392
|
-
const fullPath =
|
|
8702
|
+
const relativePath = basePath ? path9.join(basePath, entry.name) : entry.name;
|
|
8703
|
+
const fullPath = path9.join(dir, entry.name);
|
|
8393
8704
|
if (matchGlob(relativePath, pattern)) {
|
|
8394
8705
|
matches.push(relativePath);
|
|
8395
8706
|
}
|
|
@@ -8405,7 +8716,7 @@ async function walkDir(dir, pattern, includeHidden, maxResults, basePath = "") {
|
|
|
8405
8716
|
async function listFiles(params) {
|
|
8406
8717
|
const { pattern, cwd: relativeCwd, includeHidden = false, maxResults = 1e3 } = params;
|
|
8407
8718
|
const baseCwd = process.cwd();
|
|
8408
|
-
const targetCwd = relativeCwd ?
|
|
8719
|
+
const targetCwd = relativeCwd ? path9.resolve(baseCwd, path9.normalize(relativeCwd)) : baseCwd;
|
|
8409
8720
|
if (!targetCwd.startsWith(baseCwd)) {
|
|
8410
8721
|
throw new Error(`Access denied: Cannot list files outside of current working directory`);
|
|
8411
8722
|
}
|
|
@@ -8416,7 +8727,7 @@ async function listFiles(params) {
|
|
|
8416
8727
|
const filesInfo = [];
|
|
8417
8728
|
for (const match of matches) {
|
|
8418
8729
|
try {
|
|
8419
|
-
const fullPath =
|
|
8730
|
+
const fullPath = path9.join(targetCwd, match);
|
|
8420
8731
|
const stats = statSync5(fullPath);
|
|
8421
8732
|
filesInfo.push({
|
|
8422
8733
|
path: match,
|
|
@@ -8499,7 +8810,7 @@ var globFilesTool = {
|
|
|
8499
8810
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/grepSearch/index.js
|
|
8500
8811
|
import { readdir as readdir2 } from "fs/promises";
|
|
8501
8812
|
import { readFileSync as readFileSync3, statSync as statSync6 } from "fs";
|
|
8502
|
-
import
|
|
8813
|
+
import path10 from "path";
|
|
8503
8814
|
var MAX_FILE_SIZE3 = 10 * 1024 * 1024;
|
|
8504
8815
|
function matchGlob2(filePath, pattern) {
|
|
8505
8816
|
const regexPattern = pattern.replace(/\./g, "\\.").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/\{\{GLOBSTAR\}\}/g, ".*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (_, options) => `(${options.split(",").join("|")})`).replace(/\[([^\]]+)\]/g, "[$1]");
|
|
@@ -8517,8 +8828,8 @@ async function walkDir2(dir, pattern, maxResults, basePath = "") {
|
|
|
8517
8828
|
if (entry.name.startsWith(".")) {
|
|
8518
8829
|
continue;
|
|
8519
8830
|
}
|
|
8520
|
-
const relativePath = basePath ?
|
|
8521
|
-
const fullPath =
|
|
8831
|
+
const relativePath = basePath ? path10.join(basePath, entry.name) : entry.name;
|
|
8832
|
+
const fullPath = path10.join(dir, entry.name);
|
|
8522
8833
|
if (matchGlob2(relativePath, pattern)) {
|
|
8523
8834
|
matches.push(relativePath);
|
|
8524
8835
|
}
|
|
@@ -8534,7 +8845,7 @@ async function walkDir2(dir, pattern, maxResults, basePath = "") {
|
|
|
8534
8845
|
async function searchFiles2(params) {
|
|
8535
8846
|
const { pattern, filePattern = "**/*", cwd: relativeCwd, caseSensitive = false, maxResults = 100, contextLines = 0 } = params;
|
|
8536
8847
|
const baseCwd = process.cwd();
|
|
8537
|
-
const targetCwd = relativeCwd ?
|
|
8848
|
+
const targetCwd = relativeCwd ? path10.resolve(baseCwd, path10.normalize(relativeCwd)) : baseCwd;
|
|
8538
8849
|
if (!targetCwd.startsWith(baseCwd)) {
|
|
8539
8850
|
throw new Error(`Access denied: Cannot search files outside of current working directory`);
|
|
8540
8851
|
}
|
|
@@ -8548,7 +8859,7 @@ async function searchFiles2(params) {
|
|
|
8548
8859
|
const filesToSearch = await walkDir2(targetCwd, filePattern, 1e4);
|
|
8549
8860
|
const filteredFiles = [];
|
|
8550
8861
|
for (const match of filesToSearch) {
|
|
8551
|
-
const fullPath =
|
|
8862
|
+
const fullPath = path10.join(targetCwd, match);
|
|
8552
8863
|
try {
|
|
8553
8864
|
const stats = statSync6(fullPath);
|
|
8554
8865
|
if (stats.isDirectory() || stats.size > MAX_FILE_SIZE3) {
|
|
@@ -8572,7 +8883,7 @@ async function searchFiles2(params) {
|
|
|
8572
8883
|
break;
|
|
8573
8884
|
}
|
|
8574
8885
|
filesSearched++;
|
|
8575
|
-
const fullPath =
|
|
8886
|
+
const fullPath = path10.join(targetCwd, file);
|
|
8576
8887
|
try {
|
|
8577
8888
|
const content = readFileSync3(fullPath, "utf-8");
|
|
8578
8889
|
const lines = content.split("\n");
|
|
@@ -8707,14 +9018,14 @@ var grepSearchTool = {
|
|
|
8707
9018
|
};
|
|
8708
9019
|
|
|
8709
9020
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/deleteFile/index.js
|
|
8710
|
-
import { promises as
|
|
9021
|
+
import { promises as fs10 } from "fs";
|
|
8711
9022
|
import { existsSync as existsSync6, statSync as statSync7 } from "fs";
|
|
8712
|
-
import
|
|
9023
|
+
import path11 from "path";
|
|
8713
9024
|
async function deleteFile(params) {
|
|
8714
9025
|
const { path: filePath, recursive = false } = params;
|
|
8715
|
-
const normalizedPath =
|
|
8716
|
-
const resolvedPath =
|
|
8717
|
-
const cwd =
|
|
9026
|
+
const normalizedPath = path11.normalize(filePath);
|
|
9027
|
+
const resolvedPath = path11.resolve(process.cwd(), normalizedPath);
|
|
9028
|
+
const cwd = path11.resolve(process.cwd());
|
|
8718
9029
|
if (!resolvedPath.startsWith(cwd)) {
|
|
8719
9030
|
throw new Error(`Access denied: Cannot delete files outside of current working directory`);
|
|
8720
9031
|
}
|
|
@@ -8728,10 +9039,10 @@ async function deleteFile(params) {
|
|
|
8728
9039
|
throw new Error(`Path is a directory: ${filePath}. Use recursive=true to delete directories and their contents.`);
|
|
8729
9040
|
}
|
|
8730
9041
|
if (isDirectory) {
|
|
8731
|
-
await
|
|
9042
|
+
await fs10.rm(resolvedPath, { recursive: true, force: true });
|
|
8732
9043
|
return `Directory deleted successfully: ${filePath}`;
|
|
8733
9044
|
} else {
|
|
8734
|
-
await
|
|
9045
|
+
await fs10.unlink(resolvedPath);
|
|
8735
9046
|
return `File deleted successfully: ${filePath}
|
|
8736
9047
|
Size: ${size} bytes`;
|
|
8737
9048
|
}
|
|
@@ -8741,7 +9052,7 @@ var deleteFileTool = {
|
|
|
8741
9052
|
implementation: (context) => ({
|
|
8742
9053
|
toolFn: async (value) => {
|
|
8743
9054
|
const params = value;
|
|
8744
|
-
const resolvedPath =
|
|
9055
|
+
const resolvedPath = path11.resolve(process.cwd(), path11.normalize(params.path));
|
|
8745
9056
|
const isDirectory = existsSync6(resolvedPath) && statSync7(resolvedPath).isDirectory();
|
|
8746
9057
|
context.logger.info(`\u{1F5D1}\uFE0F DeleteFile: Deleting ${isDirectory ? "directory" : "file"}`, {
|
|
8747
9058
|
path: params.path,
|
|
@@ -8779,7 +9090,7 @@ var deleteFileTool = {
|
|
|
8779
9090
|
|
|
8780
9091
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/bashExecute/index.js
|
|
8781
9092
|
import { spawn } from "child_process";
|
|
8782
|
-
import
|
|
9093
|
+
import path12 from "path";
|
|
8783
9094
|
var DEFAULT_TIMEOUT_MS = 6e4;
|
|
8784
9095
|
var MAX_OUTPUT_SIZE = 100 * 1024;
|
|
8785
9096
|
var DANGEROUS_PATTERNS = [
|
|
@@ -8963,7 +9274,7 @@ async function executeBashCommand(params) {
|
|
|
8963
9274
|
};
|
|
8964
9275
|
}
|
|
8965
9276
|
const baseCwd = process.cwd();
|
|
8966
|
-
const targetCwd = relativeCwd ?
|
|
9277
|
+
const targetCwd = relativeCwd ? path12.resolve(baseCwd, relativeCwd) : baseCwd;
|
|
8967
9278
|
const effectiveTimeout = Math.min(timeout, 5 * 60 * 1e3);
|
|
8968
9279
|
return new Promise((resolve3) => {
|
|
8969
9280
|
let stdout = "";
|
|
@@ -9297,42 +9608,42 @@ var DISABLE_SERVER_THROTTLING = process.env.DISABLE_SERVER_THROTTLING === "true"
|
|
|
9297
9608
|
var questSaveMutex = new Mutex();
|
|
9298
9609
|
|
|
9299
9610
|
// ../../b4m-core/packages/services/dist/src/llm/ChatCompletion.js
|
|
9300
|
-
var QuestStartBodySchema =
|
|
9301
|
-
userId:
|
|
9302
|
-
sessionId:
|
|
9303
|
-
questId:
|
|
9304
|
-
message:
|
|
9305
|
-
messageFileIds:
|
|
9306
|
-
historyCount:
|
|
9307
|
-
fabFileIds:
|
|
9611
|
+
var QuestStartBodySchema = z139.object({
|
|
9612
|
+
userId: z139.string(),
|
|
9613
|
+
sessionId: z139.string(),
|
|
9614
|
+
questId: z139.string(),
|
|
9615
|
+
message: z139.string(),
|
|
9616
|
+
messageFileIds: z139.array(z139.string()),
|
|
9617
|
+
historyCount: z139.number(),
|
|
9618
|
+
fabFileIds: z139.array(z139.string()),
|
|
9308
9619
|
params: ChatCompletionCreateInputSchema,
|
|
9309
9620
|
dashboardParams: DashboardParamsSchema.optional(),
|
|
9310
|
-
enableQuestMaster:
|
|
9311
|
-
enableMementos:
|
|
9312
|
-
enableArtifacts:
|
|
9313
|
-
enableAgents:
|
|
9621
|
+
enableQuestMaster: z139.boolean().optional(),
|
|
9622
|
+
enableMementos: z139.boolean().optional(),
|
|
9623
|
+
enableArtifacts: z139.boolean().optional(),
|
|
9624
|
+
enableAgents: z139.boolean().optional(),
|
|
9314
9625
|
promptMeta: PromptMetaZodSchema,
|
|
9315
|
-
tools:
|
|
9316
|
-
mcpServers:
|
|
9317
|
-
projectId:
|
|
9318
|
-
organizationId:
|
|
9626
|
+
tools: z139.array(z139.union([b4mLLMTools, z139.string()])).optional(),
|
|
9627
|
+
mcpServers: z139.array(z139.string()).optional(),
|
|
9628
|
+
projectId: z139.string().optional(),
|
|
9629
|
+
organizationId: z139.string().nullable().optional(),
|
|
9319
9630
|
questMaster: QuestMasterParamsSchema.optional(),
|
|
9320
|
-
toolPromptId:
|
|
9631
|
+
toolPromptId: z139.string().optional(),
|
|
9321
9632
|
researchMode: ResearchModeParamsSchema.optional(),
|
|
9322
|
-
fallbackModel:
|
|
9323
|
-
embeddingModel:
|
|
9324
|
-
queryComplexity:
|
|
9633
|
+
fallbackModel: z139.string().optional(),
|
|
9634
|
+
embeddingModel: z139.string().optional(),
|
|
9635
|
+
queryComplexity: z139.string(),
|
|
9325
9636
|
imageConfig: GenerateImageToolCallSchema.optional(),
|
|
9326
|
-
deepResearchConfig:
|
|
9327
|
-
maxDepth:
|
|
9328
|
-
duration:
|
|
9637
|
+
deepResearchConfig: z139.object({
|
|
9638
|
+
maxDepth: z139.number().optional(),
|
|
9639
|
+
duration: z139.number().optional(),
|
|
9329
9640
|
// Note: searchers are passed via ToolContext and not through this API schema
|
|
9330
|
-
searchers:
|
|
9641
|
+
searchers: z139.array(z139.any()).optional()
|
|
9331
9642
|
}).optional(),
|
|
9332
|
-
extraContextMessages:
|
|
9333
|
-
role:
|
|
9334
|
-
content:
|
|
9335
|
-
fabFileIds:
|
|
9643
|
+
extraContextMessages: z139.array(z139.object({
|
|
9644
|
+
role: z139.enum(["user", "assistant", "system", "function", "tool"]),
|
|
9645
|
+
content: z139.union([z139.string(), z139.array(z139.any())]),
|
|
9646
|
+
fabFileIds: z139.array(z139.string()).optional()
|
|
9336
9647
|
})).optional()
|
|
9337
9648
|
});
|
|
9338
9649
|
|
|
@@ -9340,30 +9651,9 @@ var QuestStartBodySchema = z138.object({
|
|
|
9340
9651
|
import axios8 from "axios";
|
|
9341
9652
|
import { fileTypeFromBuffer as fileTypeFromBuffer4 } from "file-type";
|
|
9342
9653
|
import { v4 as uuidv47 } from "uuid";
|
|
9343
|
-
import { z as
|
|
9654
|
+
import { z as z140 } from "zod";
|
|
9344
9655
|
import { fromZodError as fromZodError2 } from "zod-validation-error";
|
|
9345
9656
|
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({
|
|
9367
9657
|
sessionId: z140.string(),
|
|
9368
9658
|
questId: z140.string(),
|
|
9369
9659
|
userId: z140.string(),
|
|
@@ -9371,35 +9661,56 @@ var ImageEditBodySchema = OpenAIImageGenerationInput.extend({
|
|
|
9371
9661
|
safety_tolerance: z140.number().min(BFL_SAFETY_TOLERANCE.MIN).max(BFL_SAFETY_TOLERANCE.MAX).optional().default(BFL_SAFETY_TOLERANCE.DEFAULT),
|
|
9372
9662
|
prompt_upsampling: z140.boolean().optional().default(false),
|
|
9373
9663
|
seed: z140.number().nullable().optional(),
|
|
9374
|
-
output_format: z140.enum(["jpeg", "png"]).optional().default("png"),
|
|
9664
|
+
output_format: z140.enum(["jpeg", "png"]).nullable().optional().default("png"),
|
|
9375
9665
|
width: z140.number().optional(),
|
|
9376
9666
|
height: z140.number().optional(),
|
|
9377
9667
|
aspect_ratio: z140.string().optional(),
|
|
9378
|
-
|
|
9379
|
-
fabFileIds: z140.array(z140.string()).optional(),
|
|
9380
|
-
image: z140.string()
|
|
9668
|
+
fabFileIds: z140.array(z140.string()).optional()
|
|
9381
9669
|
});
|
|
9382
9670
|
|
|
9383
|
-
// ../../b4m-core/packages/services/dist/src/llm/
|
|
9671
|
+
// ../../b4m-core/packages/services/dist/src/llm/ImageEdit.js
|
|
9672
|
+
import axios9 from "axios";
|
|
9673
|
+
import { fileTypeFromBuffer as fileTypeFromBuffer5 } from "file-type";
|
|
9674
|
+
import { v4 as uuidv48 } from "uuid";
|
|
9384
9675
|
import { z as z141 } from "zod";
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9676
|
+
import { fromZodError as fromZodError3 } from "zod-validation-error";
|
|
9677
|
+
var ImageEditBodySchema = OpenAIImageGenerationInput.extend({
|
|
9678
|
+
sessionId: z141.string(),
|
|
9679
|
+
questId: z141.string(),
|
|
9680
|
+
userId: z141.string(),
|
|
9681
|
+
prompt: z141.string(),
|
|
9682
|
+
safety_tolerance: z141.number().min(BFL_SAFETY_TOLERANCE.MIN).max(BFL_SAFETY_TOLERANCE.MAX).optional().default(BFL_SAFETY_TOLERANCE.DEFAULT),
|
|
9683
|
+
prompt_upsampling: z141.boolean().optional().default(false),
|
|
9684
|
+
seed: z141.number().nullable().optional(),
|
|
9685
|
+
output_format: z141.enum(["jpeg", "png"]).optional().default("png"),
|
|
9686
|
+
width: z141.number().optional(),
|
|
9687
|
+
height: z141.number().optional(),
|
|
9688
|
+
aspect_ratio: z141.string().optional(),
|
|
9689
|
+
size: z141.string().optional(),
|
|
9690
|
+
fabFileIds: z141.array(z141.string()).optional(),
|
|
9691
|
+
image: z141.string()
|
|
9692
|
+
});
|
|
9693
|
+
|
|
9694
|
+
// ../../b4m-core/packages/services/dist/src/llm/refineText.js
|
|
9695
|
+
import { z as z142 } from "zod";
|
|
9696
|
+
var refineTextLLMSchema = z142.object({
|
|
9697
|
+
text: z142.string(),
|
|
9698
|
+
context: z142.string().optional()
|
|
9388
9699
|
// tone: z.enum(['formal', 'informal', 'neutral']).optional(),
|
|
9389
9700
|
// style: z.enum(['technical', 'creative', 'academic', 'business', 'narrative']).optional(),
|
|
9390
9701
|
});
|
|
9391
9702
|
|
|
9392
9703
|
// ../../b4m-core/packages/services/dist/src/llm/MementoEvaluationService.js
|
|
9393
|
-
import { z as
|
|
9394
|
-
var SingleMementoEvalSchema =
|
|
9395
|
-
importance:
|
|
9704
|
+
import { z as z143 } from "zod";
|
|
9705
|
+
var SingleMementoEvalSchema = z143.object({
|
|
9706
|
+
importance: z143.number().min(1).max(10),
|
|
9396
9707
|
// 1-10 scale for personal info importance
|
|
9397
|
-
summary:
|
|
9398
|
-
tags:
|
|
9708
|
+
summary: z143.string(),
|
|
9709
|
+
tags: z143.array(z143.string()).optional()
|
|
9399
9710
|
});
|
|
9400
|
-
var MementoEvalResponseSchema =
|
|
9401
|
-
isPersonal:
|
|
9402
|
-
mementos:
|
|
9711
|
+
var MementoEvalResponseSchema = z143.object({
|
|
9712
|
+
isPersonal: z143.boolean(),
|
|
9713
|
+
mementos: z143.array(SingleMementoEvalSchema).optional()
|
|
9403
9714
|
// Array of distinct personal information
|
|
9404
9715
|
});
|
|
9405
9716
|
|
|
@@ -9456,7 +9767,7 @@ async function generateFileDeletePreview(args) {
|
|
|
9456
9767
|
if (!existsSync7(args.path)) {
|
|
9457
9768
|
return `[File does not exist: ${args.path}]`;
|
|
9458
9769
|
}
|
|
9459
|
-
const stats = await import("fs/promises").then((
|
|
9770
|
+
const stats = await import("fs/promises").then((fs13) => fs13.stat(args.path));
|
|
9460
9771
|
return `[File will be deleted]
|
|
9461
9772
|
|
|
9462
9773
|
Path: ${args.path}
|
|
@@ -9468,9 +9779,9 @@ Last modified: ${stats.mtime.toLocaleString()}`;
|
|
|
9468
9779
|
}
|
|
9469
9780
|
|
|
9470
9781
|
// src/utils/Logger.ts
|
|
9471
|
-
import
|
|
9472
|
-
import
|
|
9473
|
-
import
|
|
9782
|
+
import fs11 from "fs/promises";
|
|
9783
|
+
import path13 from "path";
|
|
9784
|
+
import os2 from "os";
|
|
9474
9785
|
var Logger2 = class _Logger {
|
|
9475
9786
|
constructor() {
|
|
9476
9787
|
this.logFilePath = null;
|
|
@@ -9492,9 +9803,9 @@ var Logger2 = class _Logger {
|
|
|
9492
9803
|
*/
|
|
9493
9804
|
async initialize(sessionId) {
|
|
9494
9805
|
this.sessionId = sessionId;
|
|
9495
|
-
const debugDir =
|
|
9496
|
-
await
|
|
9497
|
-
this.logFilePath =
|
|
9806
|
+
const debugDir = path13.join(os2.homedir(), ".bike4mind", "debug");
|
|
9807
|
+
await fs11.mkdir(debugDir, { recursive: true });
|
|
9808
|
+
this.logFilePath = path13.join(debugDir, `${sessionId}.txt`);
|
|
9498
9809
|
await this.writeToFile("INFO", "=== CLI SESSION START ===");
|
|
9499
9810
|
}
|
|
9500
9811
|
/**
|
|
@@ -9558,7 +9869,7 @@ var Logger2 = class _Logger {
|
|
|
9558
9869
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").substring(0, 19);
|
|
9559
9870
|
const logEntry = `[${timestamp}] [${level}] ${message}
|
|
9560
9871
|
`;
|
|
9561
|
-
await
|
|
9872
|
+
await fs11.appendFile(this.logFilePath, logEntry, "utf-8");
|
|
9562
9873
|
} catch (error) {
|
|
9563
9874
|
console.error("File logging failed:", error);
|
|
9564
9875
|
}
|
|
@@ -9704,15 +10015,15 @@ var Logger2 = class _Logger {
|
|
|
9704
10015
|
async cleanupOldLogs() {
|
|
9705
10016
|
if (!this.fileLoggingEnabled) return;
|
|
9706
10017
|
try {
|
|
9707
|
-
const debugDir =
|
|
9708
|
-
const files = await
|
|
10018
|
+
const debugDir = path13.join(os2.homedir(), ".bike4mind", "debug");
|
|
10019
|
+
const files = await fs11.readdir(debugDir);
|
|
9709
10020
|
const now = Date.now();
|
|
9710
10021
|
const thirtyDaysAgo = now - 30 * 24 * 60 * 60 * 1e3;
|
|
9711
10022
|
for (const file of files) {
|
|
9712
|
-
const filePath =
|
|
9713
|
-
const stats = await
|
|
10023
|
+
const filePath = path13.join(debugDir, file);
|
|
10024
|
+
const stats = await fs11.stat(filePath);
|
|
9714
10025
|
if (stats.mtime.getTime() < thirtyDaysAgo) {
|
|
9715
|
-
await
|
|
10026
|
+
await fs11.unlink(filePath);
|
|
9716
10027
|
}
|
|
9717
10028
|
}
|
|
9718
10029
|
} catch (error) {
|
|
@@ -9806,21 +10117,21 @@ var NoOpStorage = class extends BaseStorage {
|
|
|
9806
10117
|
async upload(input, destination, options) {
|
|
9807
10118
|
return `/tmp/${destination}`;
|
|
9808
10119
|
}
|
|
9809
|
-
async download(
|
|
10120
|
+
async download(path16) {
|
|
9810
10121
|
throw new Error("Download not supported in CLI");
|
|
9811
10122
|
}
|
|
9812
|
-
async delete(
|
|
10123
|
+
async delete(path16) {
|
|
9813
10124
|
}
|
|
9814
|
-
async getSignedUrl(
|
|
9815
|
-
return `/tmp/${
|
|
10125
|
+
async getSignedUrl(path16) {
|
|
10126
|
+
return `/tmp/${path16}`;
|
|
9816
10127
|
}
|
|
9817
|
-
getPublicUrl(
|
|
9818
|
-
return `/tmp/${
|
|
10128
|
+
getPublicUrl(path16) {
|
|
10129
|
+
return `/tmp/${path16}`;
|
|
9819
10130
|
}
|
|
9820
|
-
async getPreview(
|
|
9821
|
-
return `/tmp/${
|
|
10131
|
+
async getPreview(path16) {
|
|
10132
|
+
return `/tmp/${path16}`;
|
|
9822
10133
|
}
|
|
9823
|
-
async getMetadata(
|
|
10134
|
+
async getMetadata(path16) {
|
|
9824
10135
|
return { size: 0, contentType: "application/octet-stream" };
|
|
9825
10136
|
}
|
|
9826
10137
|
};
|
|
@@ -9914,7 +10225,31 @@ function wrapToolWithPermission(tool, permissionManager, showPermissionPrompt, a
|
|
|
9914
10225
|
}
|
|
9915
10226
|
};
|
|
9916
10227
|
}
|
|
9917
|
-
|
|
10228
|
+
var TOOL_NAME_MAPPING = {
|
|
10229
|
+
// Claude Code -> B4M
|
|
10230
|
+
read: "file_read",
|
|
10231
|
+
write: "create_file",
|
|
10232
|
+
edit: "edit_file",
|
|
10233
|
+
delete: "delete_file",
|
|
10234
|
+
glob: "glob_files",
|
|
10235
|
+
grep: "grep_search",
|
|
10236
|
+
bash: "bash_execute",
|
|
10237
|
+
// B4M -> Claude Code (reverse mapping)
|
|
10238
|
+
file_read: "read",
|
|
10239
|
+
create_file: "write",
|
|
10240
|
+
edit_file: "edit",
|
|
10241
|
+
delete_file: "delete",
|
|
10242
|
+
glob_files: "glob",
|
|
10243
|
+
grep_search: "grep",
|
|
10244
|
+
bash_execute: "bash"
|
|
10245
|
+
};
|
|
10246
|
+
function normalizeToolName(toolName) {
|
|
10247
|
+
if (toolName.includes("_")) {
|
|
10248
|
+
return toolName;
|
|
10249
|
+
}
|
|
10250
|
+
return TOOL_NAME_MAPPING[toolName] || toolName;
|
|
10251
|
+
}
|
|
10252
|
+
function generateCliTools(userId, llm, model, permissionManager, showPermissionPrompt, agentContext, configStore, apiClient, toolFilter) {
|
|
9918
10253
|
const logger2 = new CliLogger();
|
|
9919
10254
|
const storage = new NoOpStorage();
|
|
9920
10255
|
const user = {
|
|
@@ -9984,15 +10319,30 @@ function generateCliTools(userId, llm, model, permissionManager, showPermissionP
|
|
|
9984
10319
|
toolConfig,
|
|
9985
10320
|
model
|
|
9986
10321
|
);
|
|
9987
|
-
|
|
10322
|
+
let tools2 = Object.entries(toolsMap).filter(([key]) => toolConfig[key] !== void 0).map(
|
|
9988
10323
|
([_, tool]) => wrapToolWithPermission(tool, permissionManager, showPermissionPrompt, agentContext, configStore, apiClient)
|
|
9989
10324
|
);
|
|
10325
|
+
if (toolFilter) {
|
|
10326
|
+
const { allowedTools, deniedTools } = toolFilter;
|
|
10327
|
+
const normalizedAllowed = allowedTools?.map(normalizeToolName);
|
|
10328
|
+
const normalizedDenied = deniedTools?.map(normalizeToolName);
|
|
10329
|
+
tools2 = tools2.filter((tool) => {
|
|
10330
|
+
const toolName = tool.toolSchema.name;
|
|
10331
|
+
if (normalizedDenied && normalizedDenied.includes(toolName)) {
|
|
10332
|
+
return false;
|
|
10333
|
+
}
|
|
10334
|
+
if (normalizedAllowed && normalizedAllowed.length > 0) {
|
|
10335
|
+
return normalizedAllowed.includes(toolName);
|
|
10336
|
+
}
|
|
10337
|
+
return true;
|
|
10338
|
+
});
|
|
10339
|
+
}
|
|
9990
10340
|
return { tools: tools2, agentContext };
|
|
9991
10341
|
}
|
|
9992
10342
|
|
|
9993
10343
|
// src/config/toolSafety.ts
|
|
9994
|
-
import { z as
|
|
9995
|
-
var ToolCategorySchema =
|
|
10344
|
+
import { z as z144 } from "zod";
|
|
10345
|
+
var ToolCategorySchema = z144.enum([
|
|
9996
10346
|
"auto_approve",
|
|
9997
10347
|
// Safe tools that run automatically without permission
|
|
9998
10348
|
"prompt_always",
|
|
@@ -10000,9 +10350,9 @@ var ToolCategorySchema = z143.enum([
|
|
|
10000
10350
|
"prompt_default"
|
|
10001
10351
|
// Tools that prompt by default but can be trusted
|
|
10002
10352
|
]);
|
|
10003
|
-
var ToolSafetyConfigSchema =
|
|
10004
|
-
categories:
|
|
10005
|
-
trustedTools:
|
|
10353
|
+
var ToolSafetyConfigSchema = z144.object({
|
|
10354
|
+
categories: z144.record(z144.string(), ToolCategorySchema),
|
|
10355
|
+
trustedTools: z144.array(z144.string())
|
|
10006
10356
|
});
|
|
10007
10357
|
var DEFAULT_TOOL_CATEGORIES = {
|
|
10008
10358
|
// ===== AUTO APPROVE (Safe tools) =====
|
|
@@ -10182,8 +10532,8 @@ function getEnvironmentName(configApiConfig) {
|
|
|
10182
10532
|
}
|
|
10183
10533
|
|
|
10184
10534
|
// src/utils/contextLoader.ts
|
|
10185
|
-
import * as
|
|
10186
|
-
import * as
|
|
10535
|
+
import * as fs12 from "fs";
|
|
10536
|
+
import * as path14 from "path";
|
|
10187
10537
|
import { homedir as homedir4 } from "os";
|
|
10188
10538
|
var CONTEXT_FILE_SIZE_LIMIT = 100 * 1024;
|
|
10189
10539
|
var PROJECT_CONTEXT_FILES = [
|
|
@@ -10204,9 +10554,9 @@ function formatFileSize2(bytes) {
|
|
|
10204
10554
|
return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
10205
10555
|
}
|
|
10206
10556
|
function tryReadContextFile(dir, filename, source) {
|
|
10207
|
-
const filePath =
|
|
10557
|
+
const filePath = path14.join(dir, filename);
|
|
10208
10558
|
try {
|
|
10209
|
-
const stats =
|
|
10559
|
+
const stats = fs12.lstatSync(filePath);
|
|
10210
10560
|
if (stats.isDirectory()) {
|
|
10211
10561
|
return null;
|
|
10212
10562
|
}
|
|
@@ -10220,7 +10570,7 @@ function tryReadContextFile(dir, filename, source) {
|
|
|
10220
10570
|
error: `${source === "global" ? "Global" : "Project"} ${filename} exceeds 100KB limit (${formatFileSize2(stats.size)})`
|
|
10221
10571
|
};
|
|
10222
10572
|
}
|
|
10223
|
-
const content =
|
|
10573
|
+
const content = fs12.readFileSync(filePath, "utf-8");
|
|
10224
10574
|
return {
|
|
10225
10575
|
filename,
|
|
10226
10576
|
content,
|
|
@@ -10272,7 +10622,7 @@ ${project.content}`;
|
|
|
10272
10622
|
}
|
|
10273
10623
|
async function loadContextFiles(projectDir) {
|
|
10274
10624
|
const errors = [];
|
|
10275
|
-
const globalDir =
|
|
10625
|
+
const globalDir = path14.join(homedir4(), ".bike4mind");
|
|
10276
10626
|
const projectDirectory = projectDir || process.cwd();
|
|
10277
10627
|
const [globalResult, projectResult] = await Promise.all([
|
|
10278
10628
|
Promise.resolve(findContextFile(globalDir, GLOBAL_CONTEXT_FILES, "global")),
|
|
@@ -10293,10 +10643,22 @@ async function loadContextFiles(projectDir) {
|
|
|
10293
10643
|
};
|
|
10294
10644
|
}
|
|
10295
10645
|
|
|
10646
|
+
// src/utils/argumentSubstitution.ts
|
|
10647
|
+
function substituteArguments(template, args) {
|
|
10648
|
+
let result = template;
|
|
10649
|
+
for (let i = args.length; i >= 1; i--) {
|
|
10650
|
+
const pattern = new RegExp(`\\$${i}`, "g");
|
|
10651
|
+
result = result.replace(pattern, args[i - 1] || "");
|
|
10652
|
+
}
|
|
10653
|
+
const allArgsString = args.join(" ");
|
|
10654
|
+
result = result.replace(/\$ARGUMENTS/g, allArgsString);
|
|
10655
|
+
return result;
|
|
10656
|
+
}
|
|
10657
|
+
|
|
10296
10658
|
// ../../b4m-core/packages/mcp/dist/src/client.js
|
|
10297
10659
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
10298
10660
|
import { Client as Client2 } from "@modelcontextprotocol/sdk/client/index.js";
|
|
10299
|
-
import
|
|
10661
|
+
import path15 from "path";
|
|
10300
10662
|
import { existsSync as existsSync8, readdirSync as readdirSync3 } from "fs";
|
|
10301
10663
|
var MCPClient = class {
|
|
10302
10664
|
// Note: This class handles MCP server communication with repository filtering
|
|
@@ -10337,16 +10699,16 @@ var MCPClient = class {
|
|
|
10337
10699
|
const root = process.env.INIT_CWD || process.cwd();
|
|
10338
10700
|
const candidatePaths = [
|
|
10339
10701
|
// When running from SST Lambda with node_modules structure (copyFiles)
|
|
10340
|
-
|
|
10702
|
+
path15.join(root, `node_modules/@bike4mind/mcp/dist/src/${this.serverName}/index.js`),
|
|
10341
10703
|
// When running from SST Lambda deployed environment (/var/task)
|
|
10342
|
-
|
|
10704
|
+
path15.join(root, `b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
10343
10705
|
// When running from SST Lambda (.sst/artifacts/mcpHandler-dev), navigate to monorepo root (3 levels up)
|
|
10344
|
-
|
|
10706
|
+
path15.join(root, `../../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
10345
10707
|
// When running from packages/client (Next.js app), navigate to monorepo root (2 levels up)
|
|
10346
|
-
|
|
10708
|
+
path15.join(root, `../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
10347
10709
|
// Original paths (backward compatibility)
|
|
10348
|
-
|
|
10349
|
-
|
|
10710
|
+
path15.join(root, `/b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
10711
|
+
path15.join(root, "core", "mcp", "servers", this.serverName, "dist", "index.js")
|
|
10350
10712
|
];
|
|
10351
10713
|
const serverScriptPath = candidatePaths.find((p) => existsSync8(p));
|
|
10352
10714
|
if (!serverScriptPath) {
|
|
@@ -11150,7 +11512,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
|
|
|
11150
11512
|
// package.json
|
|
11151
11513
|
var package_default = {
|
|
11152
11514
|
name: "@bike4mind/cli",
|
|
11153
|
-
version: "0.2.10-fix-
|
|
11515
|
+
version: "0.2.10-fix-cli-duplicate-chat-history.17269+1be89f2b4",
|
|
11154
11516
|
type: "module",
|
|
11155
11517
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
11156
11518
|
license: "UNLICENSED",
|
|
@@ -11220,6 +11582,7 @@ var package_default = {
|
|
|
11220
11582
|
"eventsource-parser": "^3.0.6",
|
|
11221
11583
|
"file-type": "^18.7.0",
|
|
11222
11584
|
"fuse.js": "^7.1.0",
|
|
11585
|
+
"gray-matter": "^4.0.3",
|
|
11223
11586
|
ink: "^6.5.1",
|
|
11224
11587
|
"ink-select-input": "^6.2.0",
|
|
11225
11588
|
"ink-spinner": "^5.0.0",
|
|
@@ -11253,10 +11616,10 @@ var package_default = {
|
|
|
11253
11616
|
},
|
|
11254
11617
|
devDependencies: {
|
|
11255
11618
|
"@bike4mind/agents": "0.1.0",
|
|
11256
|
-
"@bike4mind/common": "2.39.1-fix-
|
|
11257
|
-
"@bike4mind/mcp": "1.20.4-fix-
|
|
11258
|
-
"@bike4mind/services": "2.34.2-fix-
|
|
11259
|
-
"@bike4mind/utils": "2.1.4-fix-
|
|
11619
|
+
"@bike4mind/common": "2.39.1-fix-cli-duplicate-chat-history.17269+1be89f2b4",
|
|
11620
|
+
"@bike4mind/mcp": "1.20.4-fix-cli-duplicate-chat-history.17269+1be89f2b4",
|
|
11621
|
+
"@bike4mind/services": "2.34.2-fix-cli-duplicate-chat-history.17269+1be89f2b4",
|
|
11622
|
+
"@bike4mind/utils": "2.1.4-fix-cli-duplicate-chat-history.17269+1be89f2b4",
|
|
11260
11623
|
"@types/better-sqlite3": "^7.6.13",
|
|
11261
11624
|
"@types/diff": "^5.0.9",
|
|
11262
11625
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -11269,7 +11632,7 @@ var package_default = {
|
|
|
11269
11632
|
typescript: "^5.9.3",
|
|
11270
11633
|
vitest: "^3.2.4"
|
|
11271
11634
|
},
|
|
11272
|
-
gitHead: "
|
|
11635
|
+
gitHead: "1be89f2b4af11a0ce89c8d4822dda698ded0f703"
|
|
11273
11636
|
};
|
|
11274
11637
|
|
|
11275
11638
|
// src/config/constants.ts
|
|
@@ -11277,6 +11640,331 @@ var USAGE_DAYS = 30;
|
|
|
11277
11640
|
var MODEL_NAME_COLUMN_WIDTH = 18;
|
|
11278
11641
|
var USAGE_CACHE_TTL = 5 * 60 * 1e3;
|
|
11279
11642
|
|
|
11643
|
+
// src/agents/SubagentOrchestrator.ts
|
|
11644
|
+
var SubagentOrchestrator = class {
|
|
11645
|
+
constructor(deps) {
|
|
11646
|
+
this.deps = deps;
|
|
11647
|
+
}
|
|
11648
|
+
/**
|
|
11649
|
+
* Delegate a task to a specialized subagent
|
|
11650
|
+
*
|
|
11651
|
+
* @param options - Configuration for subagent execution
|
|
11652
|
+
* @returns Subagent result with summary
|
|
11653
|
+
*/
|
|
11654
|
+
async delegateToSubagent(options) {
|
|
11655
|
+
const { task, type, thoroughness, parentSessionId, config: configOverride } = options;
|
|
11656
|
+
const baseConfig = this.deps.subagentConfigs.get(type);
|
|
11657
|
+
if (!baseConfig) {
|
|
11658
|
+
throw new Error(`No configuration found for subagent type: ${type}`);
|
|
11659
|
+
}
|
|
11660
|
+
const config = {
|
|
11661
|
+
...baseConfig,
|
|
11662
|
+
...configOverride,
|
|
11663
|
+
type
|
|
11664
|
+
};
|
|
11665
|
+
const model = config.model || "claude-3-5-haiku-20241022";
|
|
11666
|
+
const maxIterations = this.getMaxIterations(config, thoroughness);
|
|
11667
|
+
const toolFilter = {
|
|
11668
|
+
allowedTools: config.allowedTools,
|
|
11669
|
+
deniedTools: config.deniedTools
|
|
11670
|
+
};
|
|
11671
|
+
const agentContext = {
|
|
11672
|
+
currentAgent: null,
|
|
11673
|
+
observationQueue: []
|
|
11674
|
+
};
|
|
11675
|
+
const { tools: tools2, agentContext: updatedContext } = generateCliTools(
|
|
11676
|
+
this.deps.userId,
|
|
11677
|
+
this.deps.llm,
|
|
11678
|
+
model,
|
|
11679
|
+
this.deps.permissionManager,
|
|
11680
|
+
this.deps.showPermissionPrompt,
|
|
11681
|
+
agentContext,
|
|
11682
|
+
this.deps.configStore,
|
|
11683
|
+
this.deps.apiClient,
|
|
11684
|
+
toolFilter
|
|
11685
|
+
);
|
|
11686
|
+
this.deps.logger.debug(`Spawning ${type} subagent with ${tools2.length} tools, thoroughness: ${thoroughness}`);
|
|
11687
|
+
const subagent = new ReActAgent({
|
|
11688
|
+
userId: this.deps.userId,
|
|
11689
|
+
logger: this.deps.logger,
|
|
11690
|
+
llm: this.deps.llm,
|
|
11691
|
+
model,
|
|
11692
|
+
tools: tools2,
|
|
11693
|
+
maxIterations,
|
|
11694
|
+
systemPrompt: config.systemPrompt || this.getDefaultSystemPrompt(type)
|
|
11695
|
+
});
|
|
11696
|
+
updatedContext.currentAgent = subagent;
|
|
11697
|
+
const startTime = Date.now();
|
|
11698
|
+
const result = await subagent.run(task, {
|
|
11699
|
+
maxIterations
|
|
11700
|
+
});
|
|
11701
|
+
const duration = Date.now() - startTime;
|
|
11702
|
+
this.deps.logger.debug(
|
|
11703
|
+
`Subagent completed in ${duration}ms, ${result.completionInfo.iterations} iterations, ${result.completionInfo.totalTokens} tokens`
|
|
11704
|
+
);
|
|
11705
|
+
const summary = this.summarizeResult(result, type);
|
|
11706
|
+
const subagentResult = {
|
|
11707
|
+
...result,
|
|
11708
|
+
subagentType: type,
|
|
11709
|
+
thoroughness,
|
|
11710
|
+
summary,
|
|
11711
|
+
parentSessionId
|
|
11712
|
+
};
|
|
11713
|
+
return subagentResult;
|
|
11714
|
+
}
|
|
11715
|
+
/**
|
|
11716
|
+
* Get max iterations based on thoroughness and config
|
|
11717
|
+
*/
|
|
11718
|
+
getMaxIterations(config, thoroughness) {
|
|
11719
|
+
const defaults = {
|
|
11720
|
+
quick: 2,
|
|
11721
|
+
medium: 5,
|
|
11722
|
+
very_thorough: 10
|
|
11723
|
+
};
|
|
11724
|
+
const configIterations = config.maxIterations || defaults;
|
|
11725
|
+
return configIterations[thoroughness];
|
|
11726
|
+
}
|
|
11727
|
+
/**
|
|
11728
|
+
* Get default system prompt for subagent type
|
|
11729
|
+
*/
|
|
11730
|
+
getDefaultSystemPrompt(type) {
|
|
11731
|
+
switch (type) {
|
|
11732
|
+
case "explore":
|
|
11733
|
+
return `You are a code exploration specialist. Your job is to search and analyze codebases efficiently.
|
|
11734
|
+
|
|
11735
|
+
Focus on:
|
|
11736
|
+
- Finding relevant files and functions
|
|
11737
|
+
- Understanding code structure and patterns
|
|
11738
|
+
- Providing clear, concise summaries
|
|
11739
|
+
|
|
11740
|
+
You have read-only access. Use file_read, grep_search, and glob_files to explore.
|
|
11741
|
+
|
|
11742
|
+
When you find what you're looking for, provide a clear summary including:
|
|
11743
|
+
1. What you found (files, functions, patterns)
|
|
11744
|
+
2. Key insights or observations
|
|
11745
|
+
3. Relevant code locations
|
|
11746
|
+
|
|
11747
|
+
Be thorough but concise. Your summary will be used by the main agent.`;
|
|
11748
|
+
case "plan":
|
|
11749
|
+
return `You are a task planning specialist. Your job is to break down complex tasks into clear, actionable steps.
|
|
11750
|
+
|
|
11751
|
+
Focus on:
|
|
11752
|
+
- Identifying dependencies and blockers
|
|
11753
|
+
- Creating logical sequence of steps
|
|
11754
|
+
- Estimating scope and priorities
|
|
11755
|
+
|
|
11756
|
+
Provide a structured plan that the main agent can execute.`;
|
|
11757
|
+
case "review":
|
|
11758
|
+
return `You are a code review specialist. Your job is to analyze code quality and identify issues.
|
|
11759
|
+
|
|
11760
|
+
Focus on:
|
|
11761
|
+
- Code quality and best practices
|
|
11762
|
+
- Potential bugs and edge cases
|
|
11763
|
+
- Performance and security considerations
|
|
11764
|
+
|
|
11765
|
+
Provide actionable feedback with specific file and line references.`;
|
|
11766
|
+
default:
|
|
11767
|
+
return "You are a helpful AI assistant.";
|
|
11768
|
+
}
|
|
11769
|
+
}
|
|
11770
|
+
/**
|
|
11771
|
+
* Summarize subagent result for parent agent
|
|
11772
|
+
*/
|
|
11773
|
+
summarizeResult(result, type) {
|
|
11774
|
+
const { finalAnswer, steps, completionInfo } = result;
|
|
11775
|
+
const toolCalls = steps.filter((s) => s.type === "action");
|
|
11776
|
+
const filesRead = toolCalls.filter((s) => s.metadata?.toolName === "file_read").length;
|
|
11777
|
+
const searches = toolCalls.filter((s) => s.metadata?.toolName === "grep_search").length;
|
|
11778
|
+
const globs = toolCalls.filter((s) => s.metadata?.toolName === "glob_files").length;
|
|
11779
|
+
let summary = `**${type.charAt(0).toUpperCase() + type.slice(1)} Subagent Results**
|
|
11780
|
+
|
|
11781
|
+
`;
|
|
11782
|
+
summary += `*Execution: ${completionInfo.iterations} iterations, ${completionInfo.toolCalls} tool calls*
|
|
11783
|
+
|
|
11784
|
+
`;
|
|
11785
|
+
if (type === "explore") {
|
|
11786
|
+
summary += `*Exploration: ${filesRead} files read, ${searches} searches, ${globs} glob patterns*
|
|
11787
|
+
|
|
11788
|
+
`;
|
|
11789
|
+
}
|
|
11790
|
+
const maxLength = 1e3;
|
|
11791
|
+
if (finalAnswer.length > maxLength) {
|
|
11792
|
+
summary += finalAnswer.slice(0, maxLength) + "\n\n...(truncated)";
|
|
11793
|
+
} else {
|
|
11794
|
+
summary += finalAnswer;
|
|
11795
|
+
}
|
|
11796
|
+
return summary;
|
|
11797
|
+
}
|
|
11798
|
+
};
|
|
11799
|
+
|
|
11800
|
+
// src/agents/configs.ts
|
|
11801
|
+
var EXPLORE_CONFIG = {
|
|
11802
|
+
type: "explore",
|
|
11803
|
+
model: "claude-3-5-haiku-20241022",
|
|
11804
|
+
systemPrompt: `You are a code exploration specialist. Your job is to search and analyze codebases efficiently.
|
|
11805
|
+
|
|
11806
|
+
Focus on:
|
|
11807
|
+
- Finding relevant files and functions
|
|
11808
|
+
- Understanding code structure and patterns
|
|
11809
|
+
- Providing clear, concise summaries
|
|
11810
|
+
|
|
11811
|
+
You have read-only access. Use file_read, grep_search, and glob_files to explore.
|
|
11812
|
+
|
|
11813
|
+
When you find what you're looking for, provide a clear summary including:
|
|
11814
|
+
1. What you found (files, functions, patterns)
|
|
11815
|
+
2. Key insights or observations
|
|
11816
|
+
3. Relevant code locations
|
|
11817
|
+
|
|
11818
|
+
Be thorough but concise. Your summary will be used by the main agent.`,
|
|
11819
|
+
allowedTools: [
|
|
11820
|
+
"file_read",
|
|
11821
|
+
"grep_search",
|
|
11822
|
+
"glob_files",
|
|
11823
|
+
"bash_execute",
|
|
11824
|
+
// Only for read-only commands like ls, cat, find
|
|
11825
|
+
"current_datetime",
|
|
11826
|
+
"math_evaluate"
|
|
11827
|
+
],
|
|
11828
|
+
deniedTools: [
|
|
11829
|
+
"create_file",
|
|
11830
|
+
"edit_file",
|
|
11831
|
+
"delete_file",
|
|
11832
|
+
"web_search",
|
|
11833
|
+
"weather_info",
|
|
11834
|
+
"blog_publish",
|
|
11835
|
+
"blog_edit",
|
|
11836
|
+
"blog_draft"
|
|
11837
|
+
],
|
|
11838
|
+
maxIterations: {
|
|
11839
|
+
quick: 2,
|
|
11840
|
+
medium: 5,
|
|
11841
|
+
very_thorough: 10
|
|
11842
|
+
},
|
|
11843
|
+
defaultThoroughness: "medium"
|
|
11844
|
+
};
|
|
11845
|
+
var PLAN_CONFIG = {
|
|
11846
|
+
type: "plan",
|
|
11847
|
+
model: "claude-3-5-haiku-20241022",
|
|
11848
|
+
systemPrompt: `You are a task planning specialist. Your job is to break down complex tasks into clear, actionable steps.
|
|
11849
|
+
|
|
11850
|
+
Focus on:
|
|
11851
|
+
- Identifying dependencies and blockers
|
|
11852
|
+
- Creating logical sequence of steps
|
|
11853
|
+
- Estimating scope and priorities
|
|
11854
|
+
|
|
11855
|
+
You can explore the codebase to understand the current architecture before planning.
|
|
11856
|
+
|
|
11857
|
+
Provide a structured plan that the main agent can execute.`,
|
|
11858
|
+
allowedTools: ["file_read", "grep_search", "glob_files", "bash_execute", "current_datetime", "math_evaluate"],
|
|
11859
|
+
deniedTools: ["create_file", "edit_file", "delete_file", "web_search", "weather_info"],
|
|
11860
|
+
maxIterations: {
|
|
11861
|
+
quick: 3,
|
|
11862
|
+
medium: 7,
|
|
11863
|
+
very_thorough: 12
|
|
11864
|
+
},
|
|
11865
|
+
defaultThoroughness: "medium"
|
|
11866
|
+
};
|
|
11867
|
+
var REVIEW_CONFIG = {
|
|
11868
|
+
type: "review",
|
|
11869
|
+
model: "claude-sonnet-4-5-20250929",
|
|
11870
|
+
// Use latest Sonnet for better reasoning
|
|
11871
|
+
systemPrompt: `You are a code review specialist. Your job is to analyze code quality and identify issues.
|
|
11872
|
+
|
|
11873
|
+
Focus on:
|
|
11874
|
+
- Code quality and best practices
|
|
11875
|
+
- Potential bugs and edge cases
|
|
11876
|
+
- Performance and security considerations
|
|
11877
|
+
|
|
11878
|
+
You have read-only access to analyze code.
|
|
11879
|
+
|
|
11880
|
+
Provide actionable feedback with specific file and line references.`,
|
|
11881
|
+
allowedTools: ["file_read", "grep_search", "glob_files", "bash_execute", "current_datetime"],
|
|
11882
|
+
deniedTools: ["create_file", "edit_file", "delete_file", "web_search", "weather_info"],
|
|
11883
|
+
maxIterations: {
|
|
11884
|
+
quick: 3,
|
|
11885
|
+
medium: 8,
|
|
11886
|
+
very_thorough: 15
|
|
11887
|
+
},
|
|
11888
|
+
defaultThoroughness: "medium"
|
|
11889
|
+
};
|
|
11890
|
+
function getDefaultSubagentConfigs() {
|
|
11891
|
+
return /* @__PURE__ */ new Map([
|
|
11892
|
+
["explore", EXPLORE_CONFIG],
|
|
11893
|
+
["plan", PLAN_CONFIG],
|
|
11894
|
+
["review", REVIEW_CONFIG]
|
|
11895
|
+
]);
|
|
11896
|
+
}
|
|
11897
|
+
|
|
11898
|
+
// src/agents/delegateTool.ts
|
|
11899
|
+
function createSubagentDelegateTool(orchestrator, parentSessionId) {
|
|
11900
|
+
return {
|
|
11901
|
+
toolFn: async (args) => {
|
|
11902
|
+
const params = args;
|
|
11903
|
+
if (!params.task) {
|
|
11904
|
+
throw new Error("subagent_delegate: task parameter is required");
|
|
11905
|
+
}
|
|
11906
|
+
if (!params.type) {
|
|
11907
|
+
throw new Error("subagent_delegate: type parameter is required");
|
|
11908
|
+
}
|
|
11909
|
+
const thoroughness = params.thoroughness || "medium";
|
|
11910
|
+
const type = params.type;
|
|
11911
|
+
const result = await orchestrator.delegateToSubagent({
|
|
11912
|
+
task: params.task,
|
|
11913
|
+
type,
|
|
11914
|
+
thoroughness,
|
|
11915
|
+
parentSessionId
|
|
11916
|
+
});
|
|
11917
|
+
return result.summary;
|
|
11918
|
+
},
|
|
11919
|
+
toolSchema: {
|
|
11920
|
+
name: "subagent_delegate",
|
|
11921
|
+
description: `Delegate a task to a specialized subagent for focused work.
|
|
11922
|
+
|
|
11923
|
+
**When to use this tool:**
|
|
11924
|
+
- **Explore**: When you need to search through the codebase, find files, or understand code structure (read-only)
|
|
11925
|
+
- **Plan**: When you need to break down a complex task into actionable steps
|
|
11926
|
+
- **Review**: When you need to analyze code quality and identify potential issues
|
|
11927
|
+
|
|
11928
|
+
**Benefits:**
|
|
11929
|
+
- Keeps main conversation focused and clean
|
|
11930
|
+
- Uses specialized prompts optimized for each task type
|
|
11931
|
+
- Faster execution with appropriate models (Haiku for explore/plan, Sonnet for review)
|
|
11932
|
+
|
|
11933
|
+
**Example uses:**
|
|
11934
|
+
- "Find all files that use the authentication system" \u2192 explore
|
|
11935
|
+
- "Search for components that handle user input" \u2192 explore
|
|
11936
|
+
- "Break down implementing a new feature into steps" \u2192 plan
|
|
11937
|
+
- "Review this module for potential bugs" \u2192 review`,
|
|
11938
|
+
parameters: {
|
|
11939
|
+
type: "object",
|
|
11940
|
+
properties: {
|
|
11941
|
+
task: {
|
|
11942
|
+
type: "string",
|
|
11943
|
+
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."
|
|
11944
|
+
},
|
|
11945
|
+
type: {
|
|
11946
|
+
type: "string",
|
|
11947
|
+
enum: ["explore", "plan", "review"],
|
|
11948
|
+
description: `Type of subagent to use:
|
|
11949
|
+
- explore: Read-only codebase exploration and search (fast, uses Haiku)
|
|
11950
|
+
- plan: Task breakdown and planning (uses Haiku)
|
|
11951
|
+
- review: Code quality analysis and review (uses Sonnet for better reasoning)`
|
|
11952
|
+
},
|
|
11953
|
+
thoroughness: {
|
|
11954
|
+
type: "string",
|
|
11955
|
+
enum: ["quick", "medium", "very_thorough"],
|
|
11956
|
+
description: `How thoroughly to execute:
|
|
11957
|
+
- quick: Fast lookup, 1-2 iterations
|
|
11958
|
+
- medium: Balanced exploration, 3-5 iterations (default)
|
|
11959
|
+
- very_thorough: Comprehensive analysis, 8-10 iterations`
|
|
11960
|
+
}
|
|
11961
|
+
},
|
|
11962
|
+
required: ["task", "type"]
|
|
11963
|
+
}
|
|
11964
|
+
}
|
|
11965
|
+
};
|
|
11966
|
+
}
|
|
11967
|
+
|
|
11280
11968
|
// src/index.tsx
|
|
11281
11969
|
process.removeAllListeners("warning");
|
|
11282
11970
|
process.on("warning", (warning) => {
|
|
@@ -11296,6 +11984,7 @@ function CliApp() {
|
|
|
11296
11984
|
sessionStore: new SessionStore(),
|
|
11297
11985
|
configStore: new ConfigStore(),
|
|
11298
11986
|
commandHistoryStore: new CommandHistoryStore(),
|
|
11987
|
+
customCommandStore: new CustomCommandStore(),
|
|
11299
11988
|
imageStore: null,
|
|
11300
11989
|
// Lazy-loaded on first use
|
|
11301
11990
|
imageRenderer,
|
|
@@ -11375,6 +12064,15 @@ function CliApp() {
|
|
|
11375
12064
|
const config = await state.configStore.load();
|
|
11376
12065
|
const history = await state.commandHistoryStore.load();
|
|
11377
12066
|
setCommandHistory(history);
|
|
12067
|
+
try {
|
|
12068
|
+
await state.customCommandStore.loadCommands();
|
|
12069
|
+
const customCommandCount = state.customCommandStore.getCommandCount();
|
|
12070
|
+
if (customCommandCount > 0) {
|
|
12071
|
+
console.log(`\u{1F4DD} Loaded ${customCommandCount} custom command${customCommandCount !== 1 ? "s" : ""}`);
|
|
12072
|
+
}
|
|
12073
|
+
} catch (error) {
|
|
12074
|
+
console.warn("Failed to load custom commands:", error instanceof Error ? error.message : String(error));
|
|
12075
|
+
}
|
|
11378
12076
|
const authTokens = await state.configStore.getAuthTokens();
|
|
11379
12077
|
let isAuthenticated = false;
|
|
11380
12078
|
if (!authTokens) {
|
|
@@ -11514,7 +12212,34 @@ function CliApp() {
|
|
|
11514
12212
|
console.log(` \u{1F4E1} ${serverName}: ${count} tool(s)`);
|
|
11515
12213
|
});
|
|
11516
12214
|
}
|
|
11517
|
-
const
|
|
12215
|
+
const subagentConfigs = getDefaultSubagentConfigs();
|
|
12216
|
+
if (config.subagents) {
|
|
12217
|
+
if (config.subagents.explore) {
|
|
12218
|
+
const currentConfig = subagentConfigs.get("explore");
|
|
12219
|
+
subagentConfigs.set("explore", { ...currentConfig, ...config.subagents.explore });
|
|
12220
|
+
}
|
|
12221
|
+
if (config.subagents.plan) {
|
|
12222
|
+
const currentConfig = subagentConfigs.get("plan");
|
|
12223
|
+
subagentConfigs.set("plan", { ...currentConfig, ...config.subagents.plan });
|
|
12224
|
+
}
|
|
12225
|
+
if (config.subagents.review) {
|
|
12226
|
+
const currentConfig = subagentConfigs.get("review");
|
|
12227
|
+
subagentConfigs.set("review", { ...currentConfig, ...config.subagents.review });
|
|
12228
|
+
}
|
|
12229
|
+
}
|
|
12230
|
+
const orchestrator = new SubagentOrchestrator({
|
|
12231
|
+
userId: config.userId,
|
|
12232
|
+
llm,
|
|
12233
|
+
logger: silentLogger,
|
|
12234
|
+
permissionManager,
|
|
12235
|
+
showPermissionPrompt: promptFn,
|
|
12236
|
+
configStore: state.configStore,
|
|
12237
|
+
apiClient,
|
|
12238
|
+
subagentConfigs
|
|
12239
|
+
});
|
|
12240
|
+
const subagentDelegateTool = createSubagentDelegateTool(orchestrator, newSession.id);
|
|
12241
|
+
const allTools = [...b4mTools, ...mcpTools, subagentDelegateTool];
|
|
12242
|
+
console.log(`\u{1F916} Subagent delegation enabled (explore, plan, review)`);
|
|
11518
12243
|
const projectDir = state.configStore.getProjectConfigDir();
|
|
11519
12244
|
const contextResult = await loadContextFiles(projectDir);
|
|
11520
12245
|
if (contextResult.globalContext) {
|
|
@@ -11551,6 +12276,15 @@ FOR CODING TASKS:
|
|
|
11551
12276
|
- When searching for code: Use grep_search or glob_files to find relevant files
|
|
11552
12277
|
- Permission system will ask for approval before any file writes
|
|
11553
12278
|
|
|
12279
|
+
SUBAGENT DELEGATION:
|
|
12280
|
+
- You have access to specialized subagents via the subagent_delegate tool
|
|
12281
|
+
- Use subagents for focused exploration, planning, or review tasks:
|
|
12282
|
+
* explore: Fast read-only codebase search (e.g., "find all auth files", "locate API endpoints")
|
|
12283
|
+
* plan: Break down complex tasks into actionable steps
|
|
12284
|
+
* review: Analyze code quality and identify issues
|
|
12285
|
+
- Subagents keep the main conversation clean and run faster with optimized models
|
|
12286
|
+
- Delegate when you need to search extensively or analyze code structure
|
|
12287
|
+
|
|
11554
12288
|
FOR GENERAL TASKS:
|
|
11555
12289
|
- Use available tools to get information (weather, web search, calculations, etc.)
|
|
11556
12290
|
- When user asks follow-up questions, use conversation context to understand what they're referring to
|
|
@@ -11561,6 +12295,7 @@ EXAMPLES:
|
|
|
11561
12295
|
- "how about Japan?" \u2192 use weather tool for Japan (applying same question from context)
|
|
11562
12296
|
- "enhance README" \u2192 file_read \u2192 generate \u2192 create_file
|
|
11563
12297
|
- "what packages installed?" \u2192 glob_files "**/package.json" \u2192 file_read
|
|
12298
|
+
- "find all components using React hooks" \u2192 subagent_delegate(task="find all components using React hooks", type="explore")
|
|
11564
12299
|
|
|
11565
12300
|
Remember: Use context from previous messages to understand follow-up questions.${contextSection}`;
|
|
11566
12301
|
const maxIterations = config.preferences.maxIterations === null ? 999999 : config.preferences.maxIterations;
|
|
@@ -11607,8 +12342,164 @@ Remember: Use context from previous messages to understand follow-up questions.$
|
|
|
11607
12342
|
useEffect3(() => {
|
|
11608
12343
|
init();
|
|
11609
12344
|
}, [init]);
|
|
12345
|
+
const handleCustomCommandMessage = async (fullTemplate, displayMessage) => {
|
|
12346
|
+
if (!state.agent || !state.session) {
|
|
12347
|
+
console.error("\u274C Agent or session not initialized");
|
|
12348
|
+
return;
|
|
12349
|
+
}
|
|
12350
|
+
const authTokens = await state.configStore.getAuthTokens();
|
|
12351
|
+
if (!authTokens || new Date(authTokens.expiresAt) <= /* @__PURE__ */ new Date()) {
|
|
12352
|
+
console.log("\n\u274C Authentication required to use AI features.");
|
|
12353
|
+
console.log("\u{1F4A1} Run /login to authenticate with your B4M account.\n");
|
|
12354
|
+
return;
|
|
12355
|
+
}
|
|
12356
|
+
useCliStore.getState().setIsThinking(true);
|
|
12357
|
+
const currentSteps = [];
|
|
12358
|
+
const stepHandler = (step) => {
|
|
12359
|
+
currentSteps.push(step);
|
|
12360
|
+
const currentSession = useCliStore.getState().session;
|
|
12361
|
+
if (currentSession) {
|
|
12362
|
+
const messages = [...currentSession.messages];
|
|
12363
|
+
const lastMessage = messages[messages.length - 1];
|
|
12364
|
+
if (lastMessage && lastMessage.role === "assistant") {
|
|
12365
|
+
messages[messages.length - 1] = {
|
|
12366
|
+
...lastMessage,
|
|
12367
|
+
metadata: {
|
|
12368
|
+
...lastMessage.metadata,
|
|
12369
|
+
steps: [...currentSteps]
|
|
12370
|
+
}
|
|
12371
|
+
};
|
|
12372
|
+
setStoreSession({
|
|
12373
|
+
...currentSession,
|
|
12374
|
+
messages
|
|
12375
|
+
});
|
|
12376
|
+
}
|
|
12377
|
+
}
|
|
12378
|
+
};
|
|
12379
|
+
state.agent.on("action", stepHandler);
|
|
12380
|
+
try {
|
|
12381
|
+
let messageContent = fullTemplate;
|
|
12382
|
+
const userMessageContent = displayMessage;
|
|
12383
|
+
if (state.messageBuilder && state.messageBuilder.hasImages(fullTemplate)) {
|
|
12384
|
+
const { message: multimodalMessage } = await state.messageBuilder.buildMessage(fullTemplate);
|
|
12385
|
+
messageContent = multimodalMessage.content;
|
|
12386
|
+
}
|
|
12387
|
+
const userMessage = {
|
|
12388
|
+
role: "user",
|
|
12389
|
+
content: userMessageContent,
|
|
12390
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
12391
|
+
};
|
|
12392
|
+
const pendingAssistantMessage = {
|
|
12393
|
+
role: "assistant",
|
|
12394
|
+
content: "...",
|
|
12395
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12396
|
+
metadata: {
|
|
12397
|
+
steps: []
|
|
12398
|
+
}
|
|
12399
|
+
};
|
|
12400
|
+
const sessionWithMessages = {
|
|
12401
|
+
...state.session,
|
|
12402
|
+
messages: [...state.session.messages, userMessage, pendingAssistantMessage],
|
|
12403
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
12404
|
+
};
|
|
12405
|
+
setState((prev) => ({ ...prev, session: sessionWithMessages }));
|
|
12406
|
+
setStoreSession(sessionWithMessages);
|
|
12407
|
+
const recentMessages = state.session.messages.slice(-20);
|
|
12408
|
+
const previousMessages = recentMessages.filter((msg) => msg.role === "user" || msg.role === "assistant").map((msg) => ({
|
|
12409
|
+
role: msg.role,
|
|
12410
|
+
content: msg.content
|
|
12411
|
+
}));
|
|
12412
|
+
const result = await state.agent.run(messageContent, {
|
|
12413
|
+
previousMessages: previousMessages.length > 0 ? previousMessages : void 0
|
|
12414
|
+
});
|
|
12415
|
+
const permissionDenied = result.finalAnswer.startsWith("Permission denied for tool");
|
|
12416
|
+
if (permissionDenied) {
|
|
12417
|
+
console.log("\n\u26A0\uFE0F Action denied by user\n");
|
|
12418
|
+
}
|
|
12419
|
+
const successfulToolCalls = result.steps.filter((s) => s.type === "observation").length;
|
|
12420
|
+
const currentSession = useCliStore.getState().session;
|
|
12421
|
+
if (!currentSession) return;
|
|
12422
|
+
const updatedMessages = [...currentSession.messages];
|
|
12423
|
+
updatedMessages[updatedMessages.length - 1] = {
|
|
12424
|
+
role: "assistant",
|
|
12425
|
+
content: result.finalAnswer,
|
|
12426
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12427
|
+
metadata: {
|
|
12428
|
+
steps: result.steps,
|
|
12429
|
+
tokenUsage: {
|
|
12430
|
+
prompt: 0,
|
|
12431
|
+
completion: 0,
|
|
12432
|
+
total: result.completionInfo.totalTokens
|
|
12433
|
+
},
|
|
12434
|
+
model: state.session.model,
|
|
12435
|
+
permissionDenied
|
|
12436
|
+
}
|
|
12437
|
+
};
|
|
12438
|
+
const finalSession = {
|
|
12439
|
+
...currentSession,
|
|
12440
|
+
messages: updatedMessages,
|
|
12441
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12442
|
+
metadata: {
|
|
12443
|
+
...currentSession.metadata,
|
|
12444
|
+
totalTokens: currentSession.metadata.totalTokens + result.completionInfo.totalTokens,
|
|
12445
|
+
toolCallCount: currentSession.metadata.toolCallCount + successfulToolCalls
|
|
12446
|
+
}
|
|
12447
|
+
};
|
|
12448
|
+
setState((prev) => ({ ...prev, session: finalSession }));
|
|
12449
|
+
setStoreSession(finalSession);
|
|
12450
|
+
await state.sessionStore.save(finalSession);
|
|
12451
|
+
usageCache = null;
|
|
12452
|
+
useCliStore.getState().setIsThinking(false);
|
|
12453
|
+
} catch (error) {
|
|
12454
|
+
useCliStore.getState().setIsThinking(false);
|
|
12455
|
+
if (error?.message?.includes("Permission denied")) {
|
|
12456
|
+
console.log("\n\u26A0\uFE0F Action blocked by permission settings");
|
|
12457
|
+
const currentSession2 = useCliStore.getState().session;
|
|
12458
|
+
if (!currentSession2) return;
|
|
12459
|
+
const sessionWithDenied = { ...currentSession2 };
|
|
12460
|
+
const messages2 = [...sessionWithDenied.messages];
|
|
12461
|
+
const lastMessage2 = messages2[messages2.length - 1];
|
|
12462
|
+
if (lastMessage2 && lastMessage2.role === "assistant") {
|
|
12463
|
+
messages2[messages2.length - 1] = {
|
|
12464
|
+
...lastMessage2,
|
|
12465
|
+
content: error.message,
|
|
12466
|
+
metadata: {
|
|
12467
|
+
...lastMessage2.metadata,
|
|
12468
|
+
permissionDenied: true
|
|
12469
|
+
}
|
|
12470
|
+
};
|
|
12471
|
+
}
|
|
12472
|
+
sessionWithDenied.messages = messages2;
|
|
12473
|
+
setState((prev) => ({ ...prev, session: sessionWithDenied }));
|
|
12474
|
+
setStoreSession(sessionWithDenied);
|
|
12475
|
+
await state.sessionStore.save(sessionWithDenied);
|
|
12476
|
+
return;
|
|
12477
|
+
}
|
|
12478
|
+
console.error("Error executing command:", error);
|
|
12479
|
+
console.error(error.stack);
|
|
12480
|
+
const currentSession = useCliStore.getState().session;
|
|
12481
|
+
if (!currentSession) return;
|
|
12482
|
+
const sessionWithError = { ...currentSession };
|
|
12483
|
+
const messages = [...sessionWithError.messages];
|
|
12484
|
+
const lastMessage = messages[messages.length - 1];
|
|
12485
|
+
if (lastMessage && lastMessage.role === "assistant") {
|
|
12486
|
+
messages[messages.length - 1] = {
|
|
12487
|
+
...lastMessage,
|
|
12488
|
+
content: `\u274C Error: ${error.message || "Unknown error occurred"}`
|
|
12489
|
+
};
|
|
12490
|
+
}
|
|
12491
|
+
sessionWithError.messages = messages;
|
|
12492
|
+
setState((prev) => ({ ...prev, session: sessionWithError }));
|
|
12493
|
+
setStoreSession(sessionWithError);
|
|
12494
|
+
} finally {
|
|
12495
|
+
state.agent.off("action", stepHandler);
|
|
12496
|
+
}
|
|
12497
|
+
};
|
|
11610
12498
|
const handleMessage = async (message) => {
|
|
11611
|
-
if (!state.agent || !state.session)
|
|
12499
|
+
if (!state.agent || !state.session) {
|
|
12500
|
+
console.error("\u274C Agent or session not initialized");
|
|
12501
|
+
return;
|
|
12502
|
+
}
|
|
11612
12503
|
await state.commandHistoryStore.add(message);
|
|
11613
12504
|
const updatedHistory = await state.commandHistoryStore.list();
|
|
11614
12505
|
setCommandHistory(updatedHistory);
|
|
@@ -11618,6 +12509,7 @@ Remember: Use context from previous messages to understand follow-up questions.$
|
|
|
11618
12509
|
console.log("\u{1F4A1} Run /login to authenticate with your B4M account.\n");
|
|
11619
12510
|
return;
|
|
11620
12511
|
}
|
|
12512
|
+
useCliStore.getState().setIsThinking(true);
|
|
11621
12513
|
const currentSteps = [];
|
|
11622
12514
|
const stepHandler = (step) => {
|
|
11623
12515
|
currentSteps.push(step);
|
|
@@ -11813,8 +12705,48 @@ ${output}` : output.trim() || "(no output)",
|
|
|
11813
12705
|
};
|
|
11814
12706
|
};
|
|
11815
12707
|
const handleCommand = async (command, args) => {
|
|
12708
|
+
const customCommand = state.customCommandStore.getCommand(command);
|
|
12709
|
+
if (customCommand) {
|
|
12710
|
+
try {
|
|
12711
|
+
const sourceIcon = customCommand.source === "global" ? "\u{1F3E0}" : "\u{1F4C1}";
|
|
12712
|
+
console.log(`${sourceIcon} Executing custom command: /${command}`);
|
|
12713
|
+
let substitutedBody = substituteArguments(customCommand.body, args);
|
|
12714
|
+
const processed = await processFileReferences(substitutedBody);
|
|
12715
|
+
substitutedBody = processed.content;
|
|
12716
|
+
if (processed.errors.length > 0) {
|
|
12717
|
+
processed.errors.forEach((error) => console.warn(`Warning: ${error}`));
|
|
12718
|
+
}
|
|
12719
|
+
if (process.env.B4M_VERBOSE === "1") {
|
|
12720
|
+
console.log("\u{1F4DD} Expanded command:\n", substitutedBody);
|
|
12721
|
+
}
|
|
12722
|
+
const displayMessage = `/${command}${args.length > 0 ? " " + args.join(" ") : ""}`;
|
|
12723
|
+
if (customCommand.model && state.agent) {
|
|
12724
|
+
console.log(`\u{1F504} Using model override: ${customCommand.model}`);
|
|
12725
|
+
const originalModel = state.session?.model;
|
|
12726
|
+
if (state.session) {
|
|
12727
|
+
state.session.model = customCommand.model;
|
|
12728
|
+
}
|
|
12729
|
+
await handleCustomCommandMessage(substitutedBody, displayMessage);
|
|
12730
|
+
if (state.session && originalModel) {
|
|
12731
|
+
state.session.model = originalModel;
|
|
12732
|
+
}
|
|
12733
|
+
} else {
|
|
12734
|
+
console.log("\u{1F916} Sending to agent...\n");
|
|
12735
|
+
await handleCustomCommandMessage(substitutedBody, displayMessage);
|
|
12736
|
+
}
|
|
12737
|
+
return;
|
|
12738
|
+
} catch (error) {
|
|
12739
|
+
console.error(
|
|
12740
|
+
`\u274C Failed to execute custom command /${command}:`,
|
|
12741
|
+
error instanceof Error ? error.message : String(error)
|
|
12742
|
+
);
|
|
12743
|
+
return;
|
|
12744
|
+
}
|
|
12745
|
+
}
|
|
11816
12746
|
switch (command) {
|
|
11817
|
-
case "help":
|
|
12747
|
+
case "help": {
|
|
12748
|
+
const customCommands = state.customCommandStore.getAllCommands();
|
|
12749
|
+
const hasCustomCommands = customCommands.length > 0;
|
|
11818
12750
|
console.log(`
|
|
11819
12751
|
Available commands:
|
|
11820
12752
|
/help - Show this help message
|
|
@@ -11841,8 +12773,19 @@ Tool Permissions:
|
|
|
11841
12773
|
|
|
11842
12774
|
Project Configuration:
|
|
11843
12775
|
/project-config - Show merged project configuration
|
|
12776
|
+
|
|
12777
|
+
Custom Commands:
|
|
12778
|
+
/commands - List all custom commands
|
|
12779
|
+
/commands:new <name> - Create a new custom command
|
|
12780
|
+
/commands:reload - Reload custom commands from disk${hasCustomCommands ? "\n\n\u{1F4DD} Custom Commands Available:" : ""}${hasCustomCommands ? customCommands.map((cmd) => {
|
|
12781
|
+
const source = cmd.source === "global" ? "\u{1F3E0}" : "\u{1F4C1}";
|
|
12782
|
+
const argHint = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
|
|
12783
|
+
return `
|
|
12784
|
+
${source} /${cmd.name}${argHint} - ${cmd.description}`;
|
|
12785
|
+
}).join("") : ""}
|
|
11844
12786
|
`);
|
|
11845
12787
|
break;
|
|
12788
|
+
}
|
|
11846
12789
|
case "exit":
|
|
11847
12790
|
case "quit":
|
|
11848
12791
|
logger.debug("[EXIT /exit command - cleaning up and exiting...");
|
|
@@ -12330,6 +13273,71 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
12330
13273
|
console.log("");
|
|
12331
13274
|
break;
|
|
12332
13275
|
}
|
|
13276
|
+
case "commands": {
|
|
13277
|
+
const customCommands = state.customCommandStore.getAllCommands();
|
|
13278
|
+
const globalCommands = state.customCommandStore.getCommandsBySource("global");
|
|
13279
|
+
const projectCommands = state.customCommandStore.getCommandsBySource("project");
|
|
13280
|
+
console.log("\n\u{1F4DD} Custom Commands:\n");
|
|
13281
|
+
if (customCommands.length === 0) {
|
|
13282
|
+
console.log("No custom commands found.");
|
|
13283
|
+
console.log("\nTo create a custom command:");
|
|
13284
|
+
console.log(" /commands:new <name> - Create a new command");
|
|
13285
|
+
console.log("\nCustom commands can be stored in:");
|
|
13286
|
+
console.log(" \u{1F3E0} Global: ~/.bike4mind/commands/ (available in all projects)");
|
|
13287
|
+
console.log(" \u{1F4C1} Project: .bike4mind/commands/ (team-shared, committed to git)");
|
|
13288
|
+
} else {
|
|
13289
|
+
if (globalCommands.length > 0) {
|
|
13290
|
+
console.log("\u{1F3E0} Global Commands (~/.bike4mind/commands/):");
|
|
13291
|
+
globalCommands.forEach((cmd) => {
|
|
13292
|
+
const argHint = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
|
|
13293
|
+
console.log(` /${cmd.name}${argHint} - ${cmd.description}`);
|
|
13294
|
+
});
|
|
13295
|
+
console.log("");
|
|
13296
|
+
}
|
|
13297
|
+
if (projectCommands.length > 0) {
|
|
13298
|
+
console.log("\u{1F4C1} Project Commands (.bike4mind/commands/):");
|
|
13299
|
+
projectCommands.forEach((cmd) => {
|
|
13300
|
+
const argHint = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
|
|
13301
|
+
console.log(` /${cmd.name}${argHint} - ${cmd.description}`);
|
|
13302
|
+
});
|
|
13303
|
+
console.log("");
|
|
13304
|
+
}
|
|
13305
|
+
console.log(`Total: ${customCommands.length} custom command${customCommands.length !== 1 ? "s" : ""}`);
|
|
13306
|
+
}
|
|
13307
|
+
console.log("");
|
|
13308
|
+
break;
|
|
13309
|
+
}
|
|
13310
|
+
case "commands:new": {
|
|
13311
|
+
const commandName = args[0];
|
|
13312
|
+
if (!commandName) {
|
|
13313
|
+
console.log("\u274C Please provide a command name");
|
|
13314
|
+
console.log("Usage: /commands:new <name>");
|
|
13315
|
+
break;
|
|
13316
|
+
}
|
|
13317
|
+
console.log("\nWhere should this command be stored?");
|
|
13318
|
+
console.log(" 1. \u{1F3E0} Global (~/.bike4mind/commands/) - available in all projects");
|
|
13319
|
+
console.log(" 2. \u{1F4C1} Project (.bike4mind/commands/) - team-shared");
|
|
13320
|
+
console.log("\nDefaulting to global. Creating command file...");
|
|
13321
|
+
try {
|
|
13322
|
+
const filePath = await state.customCommandStore.createCommandFile(commandName, true);
|
|
13323
|
+
console.log(`\u2705 Created command file: ${filePath}`);
|
|
13324
|
+
console.log("\nEdit this file to customize your command.");
|
|
13325
|
+
console.log("Then run: /commands:reload to load it");
|
|
13326
|
+
} catch (error) {
|
|
13327
|
+
console.error("\u274C Failed to create command file:", error instanceof Error ? error.message : String(error));
|
|
13328
|
+
}
|
|
13329
|
+
break;
|
|
13330
|
+
}
|
|
13331
|
+
case "commands:reload": {
|
|
13332
|
+
try {
|
|
13333
|
+
await state.customCommandStore.reloadCommands();
|
|
13334
|
+
const count = state.customCommandStore.getCommandCount();
|
|
13335
|
+
console.log(`\u2705 Reloaded ${count} custom command${count !== 1 ? "s" : ""}`);
|
|
13336
|
+
} catch (error) {
|
|
13337
|
+
console.error("\u274C Failed to reload commands:", error instanceof Error ? error.message : String(error));
|
|
13338
|
+
}
|
|
13339
|
+
break;
|
|
13340
|
+
}
|
|
12333
13341
|
default:
|
|
12334
13342
|
console.log(`Unknown command: /${command}`);
|
|
12335
13343
|
console.log("Type /help for available commands");
|
|
@@ -12337,7 +13345,28 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
12337
13345
|
};
|
|
12338
13346
|
const handleSaveConfig = async (updatedConfig) => {
|
|
12339
13347
|
await state.configStore.save(updatedConfig);
|
|
12340
|
-
|
|
13348
|
+
const modelChanged = state.config?.defaultModel !== updatedConfig.defaultModel;
|
|
13349
|
+
setState((prev) => {
|
|
13350
|
+
if (modelChanged && prev.session) {
|
|
13351
|
+
const updatedSession = {
|
|
13352
|
+
...prev.session,
|
|
13353
|
+
model: updatedConfig.defaultModel,
|
|
13354
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
13355
|
+
};
|
|
13356
|
+
setStoreSession(updatedSession);
|
|
13357
|
+
if (prev.agent) {
|
|
13358
|
+
prev.agent.context.model = updatedConfig.defaultModel;
|
|
13359
|
+
}
|
|
13360
|
+
return { ...prev, config: updatedConfig, session: updatedSession };
|
|
13361
|
+
}
|
|
13362
|
+
return { ...prev, config: updatedConfig };
|
|
13363
|
+
});
|
|
13364
|
+
if (modelChanged && state.agent) {
|
|
13365
|
+
const llm = state.agent.context.llm;
|
|
13366
|
+
if (llm) {
|
|
13367
|
+
llm.currentModel = updatedConfig.defaultModel;
|
|
13368
|
+
}
|
|
13369
|
+
}
|
|
12341
13370
|
};
|
|
12342
13371
|
if (initError) {
|
|
12343
13372
|
return /* @__PURE__ */ React17.createElement(Box16, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React17.createElement(Text16, { color: "red", bold: true }, "\u274C Initialization Error"), /* @__PURE__ */ React17.createElement(Text16, null, initError), /* @__PURE__ */ React17.createElement(Text16, { dimColor: true }, "\n", "Tip: Run /config to set up your API keys"));
|
|
@@ -12426,6 +13455,7 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
12426
13455
|
if (!isInitialized) {
|
|
12427
13456
|
return /* @__PURE__ */ React17.createElement(Box16, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React17.createElement(Text16, null, "\u{1F680} Initializing..."));
|
|
12428
13457
|
}
|
|
13458
|
+
const allCommands = mergeCommands(state.customCommandStore.getAllCommands());
|
|
12429
13459
|
return /* @__PURE__ */ React17.createElement(
|
|
12430
13460
|
App,
|
|
12431
13461
|
{
|
|
@@ -12434,6 +13464,7 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
12434
13464
|
onBashCommand: handleBashCommand,
|
|
12435
13465
|
onImageDetected: handleImageDetected,
|
|
12436
13466
|
commandHistory,
|
|
13467
|
+
commands: allCommands,
|
|
12437
13468
|
config: state.config,
|
|
12438
13469
|
availableModels: state.availableModels,
|
|
12439
13470
|
onSaveConfig: handleSaveConfig,
|