@modelrelay/sdk 1.25.0 → 1.27.0
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/chunk-BL7GWXRZ.js +1196 -0
- package/dist/index.cjs +75 -681
- package/dist/index.d.cts +3 -1315
- package/dist/index.d.ts +3 -1315
- package/dist/index.js +627 -2276
- package/dist/node.cjs +878 -0
- package/dist/node.d.cts +149 -0
- package/dist/node.d.ts +149 -0
- package/dist/node.js +611 -0
- package/dist/tools-Db-F5rIL.d.cts +1169 -0
- package/dist/tools-Db-F5rIL.d.ts +1169 -0
- package/package.json +8 -3
package/dist/node.d.cts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { k as Tool, u as ToolRegistry } from './tools-Db-F5rIL.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Local filesystem tool pack for client-side tool execution.
|
|
5
|
+
*
|
|
6
|
+
* Implements tools.v0 contract:
|
|
7
|
+
* - fs.read_file - Read workspace-relative files
|
|
8
|
+
* - fs.list_files - List files recursively
|
|
9
|
+
* - fs.search - Regex search (ripgrep or JS fallback)
|
|
10
|
+
*
|
|
11
|
+
* Safety features:
|
|
12
|
+
* - Root sandbox with symlink resolution
|
|
13
|
+
* - Path traversal prevention
|
|
14
|
+
* - Size limits with hard caps
|
|
15
|
+
* - Ignore patterns for common large directories
|
|
16
|
+
* - UTF-8 validation
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** Reserved tool names from tools.v0 specification. */
|
|
22
|
+
declare const ToolNames: {
|
|
23
|
+
readonly FS_READ_FILE: "fs.read_file";
|
|
24
|
+
readonly FS_LIST_FILES: "fs.list_files";
|
|
25
|
+
readonly FS_SEARCH: "fs.search";
|
|
26
|
+
};
|
|
27
|
+
/** Default size limits and caps from wire contract. */
|
|
28
|
+
declare const FSDefaults: {
|
|
29
|
+
readonly MAX_READ_BYTES: 64000;
|
|
30
|
+
readonly HARD_MAX_READ_BYTES: 1000000;
|
|
31
|
+
readonly MAX_LIST_ENTRIES: 2000;
|
|
32
|
+
readonly HARD_MAX_LIST_ENTRIES: 20000;
|
|
33
|
+
readonly MAX_SEARCH_MATCHES: 100;
|
|
34
|
+
readonly HARD_MAX_SEARCH_MATCHES: 2000;
|
|
35
|
+
readonly SEARCH_TIMEOUT_MS: 5000;
|
|
36
|
+
readonly MAX_SEARCH_BYTES_PER_FILE: 1000000;
|
|
37
|
+
};
|
|
38
|
+
/** Default directories to skip during list/search operations. */
|
|
39
|
+
declare const DEFAULT_IGNORE_DIRS: Set<string>;
|
|
40
|
+
/** Configuration options for LocalFSToolPack. */
|
|
41
|
+
interface LocalFSToolPackOptions {
|
|
42
|
+
/** Root directory for sandboxing (required). All paths are relative to this. */
|
|
43
|
+
root: string;
|
|
44
|
+
/** Directory names to skip during list/search. Defaults to DEFAULT_IGNORE_DIRS. */
|
|
45
|
+
ignoreDirs?: Set<string>;
|
|
46
|
+
/** Default max_bytes for fs.read_file. Defaults to 64KB. */
|
|
47
|
+
maxReadBytes?: number;
|
|
48
|
+
/** Hard cap for fs.read_file max_bytes. Defaults to 1MB. */
|
|
49
|
+
hardMaxReadBytes?: number;
|
|
50
|
+
/** Default max_entries for fs.list_files. Defaults to 2000. */
|
|
51
|
+
maxListEntries?: number;
|
|
52
|
+
/** Hard cap for fs.list_files max_entries. Defaults to 20000. */
|
|
53
|
+
hardMaxListEntries?: number;
|
|
54
|
+
/** Default max_matches for fs.search. Defaults to 100. */
|
|
55
|
+
maxSearchMatches?: number;
|
|
56
|
+
/** Hard cap for fs.search max_matches. Defaults to 2000. */
|
|
57
|
+
hardMaxSearchMatches?: number;
|
|
58
|
+
/** Timeout for fs.search in milliseconds. Defaults to 5000. */
|
|
59
|
+
searchTimeoutMs?: number;
|
|
60
|
+
/** Max bytes to read per file during JS fallback search. Defaults to 1MB. */
|
|
61
|
+
maxSearchBytesPerFile?: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Tool pack providing safe filesystem access for LLM workflows.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const pack = new LocalFSToolPack({ root: process.cwd() });
|
|
69
|
+
* const registry = pack.toRegistry();
|
|
70
|
+
*
|
|
71
|
+
* // Use tools in a workflow
|
|
72
|
+
* const response = await client.responses.create({
|
|
73
|
+
* model: "anthropic/claude-sonnet-4-20250514",
|
|
74
|
+
* input: [{ type: "message", role: "user", content: [{ type: "text", text: "List all TypeScript files" }] }],
|
|
75
|
+
* tools: pack.getToolDefinitions(),
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // Execute tool calls
|
|
79
|
+
* const results = await registry.executeAll(response.output.filter(o => o.type === "tool_use"));
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare class LocalFSToolPack {
|
|
83
|
+
private readonly rootAbs;
|
|
84
|
+
private readonly cfg;
|
|
85
|
+
private rgPath;
|
|
86
|
+
private rgChecked;
|
|
87
|
+
constructor(options: LocalFSToolPackOptions);
|
|
88
|
+
/**
|
|
89
|
+
* Returns the tool definitions for LLM requests.
|
|
90
|
+
* Use these when constructing the tools array for /responses requests.
|
|
91
|
+
*/
|
|
92
|
+
getToolDefinitions(): Tool[];
|
|
93
|
+
/**
|
|
94
|
+
* Registers handlers into an existing ToolRegistry.
|
|
95
|
+
* @param registry - The registry to register into
|
|
96
|
+
* @returns The registry for chaining
|
|
97
|
+
*/
|
|
98
|
+
registerInto(registry: ToolRegistry): ToolRegistry;
|
|
99
|
+
/**
|
|
100
|
+
* Creates a new ToolRegistry with fs.* tools pre-registered.
|
|
101
|
+
*/
|
|
102
|
+
toRegistry(): ToolRegistry;
|
|
103
|
+
private readFile;
|
|
104
|
+
private listFiles;
|
|
105
|
+
private search;
|
|
106
|
+
/**
|
|
107
|
+
* Resolves a workspace-relative path and validates it stays within the sandbox.
|
|
108
|
+
* @throws {ToolArgumentError} if path is invalid
|
|
109
|
+
* @throws {PathEscapeError} if resolved path escapes root
|
|
110
|
+
*/
|
|
111
|
+
private resolveAndValidatePath;
|
|
112
|
+
private detectRipgrep;
|
|
113
|
+
private searchWithRipgrep;
|
|
114
|
+
private normalizeRipgrepLine;
|
|
115
|
+
private searchWithJS;
|
|
116
|
+
private parseArgs;
|
|
117
|
+
private toolArgumentError;
|
|
118
|
+
private requireString;
|
|
119
|
+
private optionalString;
|
|
120
|
+
private optionalPositiveInt;
|
|
121
|
+
private isValidUtf8;
|
|
122
|
+
/**
|
|
123
|
+
* Recursively walks a directory, calling visitor for each entry.
|
|
124
|
+
* Visitor returns true to continue, false to skip (for dirs) or stop.
|
|
125
|
+
*/
|
|
126
|
+
private walkDir;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Creates a LocalFSToolPack with the given options.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* const pack = createLocalFSToolPack({ root: process.cwd() });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare function createLocalFSToolPack(options: LocalFSToolPackOptions): LocalFSToolPack;
|
|
137
|
+
/**
|
|
138
|
+
* Creates a ToolRegistry with fs.* tools pre-registered.
|
|
139
|
+
* Shorthand for createLocalFSToolPack(options).toRegistry().
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const registry = createLocalFSTools({ root: process.cwd() });
|
|
144
|
+
* const result = await registry.execute(toolCall);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function createLocalFSTools(options: LocalFSToolPackOptions): ToolRegistry;
|
|
148
|
+
|
|
149
|
+
export { DEFAULT_IGNORE_DIRS, FSDefaults, ToolNames as FSToolNames, LocalFSToolPack, type LocalFSToolPackOptions, createLocalFSToolPack, createLocalFSTools };
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { k as Tool, u as ToolRegistry } from './tools-Db-F5rIL.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Local filesystem tool pack for client-side tool execution.
|
|
5
|
+
*
|
|
6
|
+
* Implements tools.v0 contract:
|
|
7
|
+
* - fs.read_file - Read workspace-relative files
|
|
8
|
+
* - fs.list_files - List files recursively
|
|
9
|
+
* - fs.search - Regex search (ripgrep or JS fallback)
|
|
10
|
+
*
|
|
11
|
+
* Safety features:
|
|
12
|
+
* - Root sandbox with symlink resolution
|
|
13
|
+
* - Path traversal prevention
|
|
14
|
+
* - Size limits with hard caps
|
|
15
|
+
* - Ignore patterns for common large directories
|
|
16
|
+
* - UTF-8 validation
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** Reserved tool names from tools.v0 specification. */
|
|
22
|
+
declare const ToolNames: {
|
|
23
|
+
readonly FS_READ_FILE: "fs.read_file";
|
|
24
|
+
readonly FS_LIST_FILES: "fs.list_files";
|
|
25
|
+
readonly FS_SEARCH: "fs.search";
|
|
26
|
+
};
|
|
27
|
+
/** Default size limits and caps from wire contract. */
|
|
28
|
+
declare const FSDefaults: {
|
|
29
|
+
readonly MAX_READ_BYTES: 64000;
|
|
30
|
+
readonly HARD_MAX_READ_BYTES: 1000000;
|
|
31
|
+
readonly MAX_LIST_ENTRIES: 2000;
|
|
32
|
+
readonly HARD_MAX_LIST_ENTRIES: 20000;
|
|
33
|
+
readonly MAX_SEARCH_MATCHES: 100;
|
|
34
|
+
readonly HARD_MAX_SEARCH_MATCHES: 2000;
|
|
35
|
+
readonly SEARCH_TIMEOUT_MS: 5000;
|
|
36
|
+
readonly MAX_SEARCH_BYTES_PER_FILE: 1000000;
|
|
37
|
+
};
|
|
38
|
+
/** Default directories to skip during list/search operations. */
|
|
39
|
+
declare const DEFAULT_IGNORE_DIRS: Set<string>;
|
|
40
|
+
/** Configuration options for LocalFSToolPack. */
|
|
41
|
+
interface LocalFSToolPackOptions {
|
|
42
|
+
/** Root directory for sandboxing (required). All paths are relative to this. */
|
|
43
|
+
root: string;
|
|
44
|
+
/** Directory names to skip during list/search. Defaults to DEFAULT_IGNORE_DIRS. */
|
|
45
|
+
ignoreDirs?: Set<string>;
|
|
46
|
+
/** Default max_bytes for fs.read_file. Defaults to 64KB. */
|
|
47
|
+
maxReadBytes?: number;
|
|
48
|
+
/** Hard cap for fs.read_file max_bytes. Defaults to 1MB. */
|
|
49
|
+
hardMaxReadBytes?: number;
|
|
50
|
+
/** Default max_entries for fs.list_files. Defaults to 2000. */
|
|
51
|
+
maxListEntries?: number;
|
|
52
|
+
/** Hard cap for fs.list_files max_entries. Defaults to 20000. */
|
|
53
|
+
hardMaxListEntries?: number;
|
|
54
|
+
/** Default max_matches for fs.search. Defaults to 100. */
|
|
55
|
+
maxSearchMatches?: number;
|
|
56
|
+
/** Hard cap for fs.search max_matches. Defaults to 2000. */
|
|
57
|
+
hardMaxSearchMatches?: number;
|
|
58
|
+
/** Timeout for fs.search in milliseconds. Defaults to 5000. */
|
|
59
|
+
searchTimeoutMs?: number;
|
|
60
|
+
/** Max bytes to read per file during JS fallback search. Defaults to 1MB. */
|
|
61
|
+
maxSearchBytesPerFile?: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Tool pack providing safe filesystem access for LLM workflows.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const pack = new LocalFSToolPack({ root: process.cwd() });
|
|
69
|
+
* const registry = pack.toRegistry();
|
|
70
|
+
*
|
|
71
|
+
* // Use tools in a workflow
|
|
72
|
+
* const response = await client.responses.create({
|
|
73
|
+
* model: "anthropic/claude-sonnet-4-20250514",
|
|
74
|
+
* input: [{ type: "message", role: "user", content: [{ type: "text", text: "List all TypeScript files" }] }],
|
|
75
|
+
* tools: pack.getToolDefinitions(),
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // Execute tool calls
|
|
79
|
+
* const results = await registry.executeAll(response.output.filter(o => o.type === "tool_use"));
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare class LocalFSToolPack {
|
|
83
|
+
private readonly rootAbs;
|
|
84
|
+
private readonly cfg;
|
|
85
|
+
private rgPath;
|
|
86
|
+
private rgChecked;
|
|
87
|
+
constructor(options: LocalFSToolPackOptions);
|
|
88
|
+
/**
|
|
89
|
+
* Returns the tool definitions for LLM requests.
|
|
90
|
+
* Use these when constructing the tools array for /responses requests.
|
|
91
|
+
*/
|
|
92
|
+
getToolDefinitions(): Tool[];
|
|
93
|
+
/**
|
|
94
|
+
* Registers handlers into an existing ToolRegistry.
|
|
95
|
+
* @param registry - The registry to register into
|
|
96
|
+
* @returns The registry for chaining
|
|
97
|
+
*/
|
|
98
|
+
registerInto(registry: ToolRegistry): ToolRegistry;
|
|
99
|
+
/**
|
|
100
|
+
* Creates a new ToolRegistry with fs.* tools pre-registered.
|
|
101
|
+
*/
|
|
102
|
+
toRegistry(): ToolRegistry;
|
|
103
|
+
private readFile;
|
|
104
|
+
private listFiles;
|
|
105
|
+
private search;
|
|
106
|
+
/**
|
|
107
|
+
* Resolves a workspace-relative path and validates it stays within the sandbox.
|
|
108
|
+
* @throws {ToolArgumentError} if path is invalid
|
|
109
|
+
* @throws {PathEscapeError} if resolved path escapes root
|
|
110
|
+
*/
|
|
111
|
+
private resolveAndValidatePath;
|
|
112
|
+
private detectRipgrep;
|
|
113
|
+
private searchWithRipgrep;
|
|
114
|
+
private normalizeRipgrepLine;
|
|
115
|
+
private searchWithJS;
|
|
116
|
+
private parseArgs;
|
|
117
|
+
private toolArgumentError;
|
|
118
|
+
private requireString;
|
|
119
|
+
private optionalString;
|
|
120
|
+
private optionalPositiveInt;
|
|
121
|
+
private isValidUtf8;
|
|
122
|
+
/**
|
|
123
|
+
* Recursively walks a directory, calling visitor for each entry.
|
|
124
|
+
* Visitor returns true to continue, false to skip (for dirs) or stop.
|
|
125
|
+
*/
|
|
126
|
+
private walkDir;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Creates a LocalFSToolPack with the given options.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* const pack = createLocalFSToolPack({ root: process.cwd() });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare function createLocalFSToolPack(options: LocalFSToolPackOptions): LocalFSToolPack;
|
|
137
|
+
/**
|
|
138
|
+
* Creates a ToolRegistry with fs.* tools pre-registered.
|
|
139
|
+
* Shorthand for createLocalFSToolPack(options).toRegistry().
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const registry = createLocalFSTools({ root: process.cwd() });
|
|
144
|
+
* const result = await registry.execute(toolCall);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function createLocalFSTools(options: LocalFSToolPackOptions): ToolRegistry;
|
|
148
|
+
|
|
149
|
+
export { DEFAULT_IGNORE_DIRS, FSDefaults, ToolNames as FSToolNames, LocalFSToolPack, type LocalFSToolPackOptions, createLocalFSToolPack, createLocalFSTools };
|