anyclaude-sdk 0.4.3 → 0.4.4
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/fs/dexie.d.ts +5 -0
- package/dist/fs/dexie.js +20 -8
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.js +15 -0
- package/package.json +1 -1
package/dist/fs/dexie.d.ts
CHANGED
|
@@ -22,11 +22,16 @@ export interface DexieFileSystemOptions {
|
|
|
22
22
|
cwd?: string;
|
|
23
23
|
/** Wipe all nodes on first open (fresh filesystem). */
|
|
24
24
|
resetOnInit?: boolean;
|
|
25
|
+
/** Use an existing Dexie instance instead of opening one by name — lets the
|
|
26
|
+
* filesystem share a database your app already owns. It must declare a
|
|
27
|
+
* `nodes` table keyed by `path` (or be a fresh Dexie this FS can version). */
|
|
28
|
+
db?: unknown;
|
|
25
29
|
}
|
|
26
30
|
export declare class DexieFileSystem implements FileSystem {
|
|
27
31
|
readonly cwd: string;
|
|
28
32
|
private readonly dbName;
|
|
29
33
|
private readonly resetOnInit;
|
|
34
|
+
private readonly injectedDb;
|
|
30
35
|
private db;
|
|
31
36
|
private opening;
|
|
32
37
|
constructor(dbName?: string, options?: DexieFileSystemOptions);
|
package/dist/fs/dexie.js
CHANGED
|
@@ -20,6 +20,7 @@ export class DexieFileSystem {
|
|
|
20
20
|
this.dbName = dbName;
|
|
21
21
|
this.cwd = options.cwd ?? '/';
|
|
22
22
|
this.resetOnInit = options.resetOnInit ?? false;
|
|
23
|
+
this.injectedDb = options.db ?? null;
|
|
23
24
|
}
|
|
24
25
|
// ---- lifecycle ----
|
|
25
26
|
async open() {
|
|
@@ -28,14 +29,25 @@ export class DexieFileSystem {
|
|
|
28
29
|
if (this.opening)
|
|
29
30
|
return this.opening;
|
|
30
31
|
this.opening = (async () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
let db;
|
|
33
|
+
if (this.injectedDb) {
|
|
34
|
+
// Use the caller's Dexie instance. Declare our schema if it isn't open
|
|
35
|
+
// yet; an already-open db is assumed to carry a compatible `nodes` table.
|
|
36
|
+
db = this.injectedDb;
|
|
37
|
+
if (!db.isOpen?.()) {
|
|
38
|
+
db.version(1).stores({ nodes: 'path, parent' });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// @ts-ignore optional peer dependency, resolved at runtime
|
|
43
|
+
const mod = await import('dexie');
|
|
44
|
+
const Dexie = mod.default ?? mod;
|
|
45
|
+
db = new Dexie(this.dbName);
|
|
46
|
+
db.version(1).stores({
|
|
47
|
+
// primary key `path`, secondary index `parent`
|
|
48
|
+
nodes: 'path, parent',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
39
51
|
this.db = db;
|
|
40
52
|
if (this.resetOnInit)
|
|
41
53
|
await db.nodes.clear();
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ export { defineTool, type DefineToolSpec } from './define.js';
|
|
|
23
23
|
export { askUserQuestion } from './ask_user.js';
|
|
24
24
|
/** Every built-in Claude Code tool, ready to pass to `query()`. */
|
|
25
25
|
export declare const ALL_CLAUDE_CODE_TOOLS: Tool[];
|
|
26
|
+
/** Built-in tools that operate on the workspace (filesystem + shell). Pass as
|
|
27
|
+
* `query({ clientTools: WORKSPACE_TOOL_NAMES })` to execute them on the HOST
|
|
28
|
+
* (e.g. a browser WebContainer or IndexedDB FS) instead of server-side. Pair
|
|
29
|
+
* with anyclaude-react's `createWorkspaceClientTools(workspace)`. */
|
|
30
|
+
export declare const WORKSPACE_TOOL_NAMES: readonly ["bash", "write_file", "read_file", "edit_file", "multi_edit", "delete_file", "list_files", "glob", "grep"];
|
|
26
31
|
/** Extract the OpenAI-shape definitions to send to the LLM. */
|
|
27
32
|
export declare function toolDefs(tools: Tool[]): ToolDef[];
|
|
28
33
|
/** Build a name→tool lookup for dispatching tool calls. */
|
package/dist/tools/index.js
CHANGED
|
@@ -36,6 +36,21 @@ export const ALL_CLAUDE_CODE_TOOLS = [
|
|
|
36
36
|
toolSearch,
|
|
37
37
|
config,
|
|
38
38
|
];
|
|
39
|
+
/** Built-in tools that operate on the workspace (filesystem + shell). Pass as
|
|
40
|
+
* `query({ clientTools: WORKSPACE_TOOL_NAMES })` to execute them on the HOST
|
|
41
|
+
* (e.g. a browser WebContainer or IndexedDB FS) instead of server-side. Pair
|
|
42
|
+
* with anyclaude-react's `createWorkspaceClientTools(workspace)`. */
|
|
43
|
+
export const WORKSPACE_TOOL_NAMES = [
|
|
44
|
+
'bash',
|
|
45
|
+
'write_file',
|
|
46
|
+
'read_file',
|
|
47
|
+
'edit_file',
|
|
48
|
+
'multi_edit',
|
|
49
|
+
'delete_file',
|
|
50
|
+
'list_files',
|
|
51
|
+
'glob',
|
|
52
|
+
'grep',
|
|
53
|
+
];
|
|
39
54
|
/** Extract the OpenAI-shape definitions to send to the LLM. */
|
|
40
55
|
export function toolDefs(tools) {
|
|
41
56
|
return tools.map((t) => t.def);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anyclaude-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Standalone, browser-compatible SDK providing Claude Code agent capabilities (tools, tool loop, multi-turn, MCP, sub-agents, sessions) against any OpenAI/Anthropic-compatible LLM endpoint. Runs in the browser (WebContainer), Node, and Bun — no backend required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|