deepagentsdk 0.11.1 → 0.12.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.
Files changed (103) hide show
  1. package/dist/adapters/elements/index.cjs +324 -0
  2. package/dist/adapters/elements/index.cjs.map +1 -0
  3. package/dist/adapters/elements/index.d.cts +212 -0
  4. package/dist/adapters/elements/index.d.mts +212 -0
  5. package/dist/adapters/elements/index.mjs +320 -0
  6. package/dist/adapters/elements/index.mjs.map +1 -0
  7. package/dist/agent-CrH-He58.mjs +2974 -0
  8. package/dist/agent-CrH-He58.mjs.map +1 -0
  9. package/dist/agent-Cuks-Idh.cjs +3396 -0
  10. package/dist/agent-Cuks-Idh.cjs.map +1 -0
  11. package/dist/chunk-CbDLau6x.cjs +34 -0
  12. package/dist/cli/index.cjs +3162 -0
  13. package/dist/cli/index.cjs.map +1 -0
  14. package/dist/cli/index.d.cts +1 -0
  15. package/dist/cli/index.d.mts +1 -0
  16. package/dist/cli/index.mjs +3120 -0
  17. package/dist/cli/index.mjs.map +1 -0
  18. package/dist/file-saver-BJCqMIb5.mjs +655 -0
  19. package/dist/file-saver-BJCqMIb5.mjs.map +1 -0
  20. package/dist/file-saver-C6O2LAvg.cjs +679 -0
  21. package/dist/file-saver-C6O2LAvg.cjs.map +1 -0
  22. package/dist/index.cjs +1471 -0
  23. package/dist/index.cjs.map +1 -0
  24. package/dist/index.d.cts +1581 -0
  25. package/dist/index.d.mts +1581 -0
  26. package/dist/index.mjs +1371 -0
  27. package/dist/index.mjs.map +1 -0
  28. package/dist/load-79a2H4m0.cjs +163 -0
  29. package/dist/load-79a2H4m0.cjs.map +1 -0
  30. package/dist/load-94gjHorc.mjs +3 -0
  31. package/dist/load-B6CA5js_.mjs +142 -0
  32. package/dist/load-B6CA5js_.mjs.map +1 -0
  33. package/dist/load-C2qVmZMp.cjs +3 -0
  34. package/dist/types-4g9UvXal.d.mts +1151 -0
  35. package/dist/types-IulnvhFg.d.cts +1151 -0
  36. package/package.json +26 -12
  37. package/src/adapters/elements/index.ts +0 -27
  38. package/src/adapters/elements/messageAdapter.ts +0 -165
  39. package/src/adapters/elements/statusAdapter.ts +0 -39
  40. package/src/adapters/elements/types.ts +0 -97
  41. package/src/adapters/elements/useElementsAdapter.ts +0 -261
  42. package/src/agent.ts +0 -1258
  43. package/src/backends/composite.ts +0 -273
  44. package/src/backends/filesystem.ts +0 -692
  45. package/src/backends/index.ts +0 -22
  46. package/src/backends/local-sandbox.ts +0 -175
  47. package/src/backends/persistent.ts +0 -593
  48. package/src/backends/sandbox.ts +0 -510
  49. package/src/backends/state.ts +0 -244
  50. package/src/backends/utils.ts +0 -287
  51. package/src/checkpointer/file-saver.ts +0 -98
  52. package/src/checkpointer/index.ts +0 -5
  53. package/src/checkpointer/kv-saver.ts +0 -82
  54. package/src/checkpointer/memory-saver.ts +0 -82
  55. package/src/checkpointer/types.ts +0 -125
  56. package/src/cli/components/ApiKeyInput.tsx +0 -300
  57. package/src/cli/components/FilePreview.tsx +0 -237
  58. package/src/cli/components/Input.tsx +0 -277
  59. package/src/cli/components/Message.tsx +0 -93
  60. package/src/cli/components/ModelSelection.tsx +0 -338
  61. package/src/cli/components/SlashMenu.tsx +0 -101
  62. package/src/cli/components/StatusBar.tsx +0 -89
  63. package/src/cli/components/Subagent.tsx +0 -91
  64. package/src/cli/components/TodoList.tsx +0 -133
  65. package/src/cli/components/ToolApproval.tsx +0 -70
  66. package/src/cli/components/ToolCall.tsx +0 -144
  67. package/src/cli/components/ToolCallSummary.tsx +0 -175
  68. package/src/cli/components/Welcome.tsx +0 -75
  69. package/src/cli/components/index.ts +0 -24
  70. package/src/cli/hooks/index.ts +0 -12
  71. package/src/cli/hooks/useAgent.ts +0 -933
  72. package/src/cli/index.tsx +0 -1066
  73. package/src/cli/theme.ts +0 -205
  74. package/src/cli/utils/model-list.ts +0 -365
  75. package/src/constants/errors.ts +0 -29
  76. package/src/constants/limits.ts +0 -195
  77. package/src/index.ts +0 -176
  78. package/src/middleware/agent-memory.ts +0 -330
  79. package/src/prompts.ts +0 -196
  80. package/src/skills/index.ts +0 -2
  81. package/src/skills/load.ts +0 -191
  82. package/src/skills/types.ts +0 -53
  83. package/src/tools/execute.ts +0 -167
  84. package/src/tools/filesystem.ts +0 -418
  85. package/src/tools/index.ts +0 -39
  86. package/src/tools/subagent.ts +0 -443
  87. package/src/tools/todos.ts +0 -101
  88. package/src/tools/web.ts +0 -567
  89. package/src/types/backend.ts +0 -177
  90. package/src/types/core.ts +0 -220
  91. package/src/types/events.ts +0 -430
  92. package/src/types/index.ts +0 -94
  93. package/src/types/structured-output.ts +0 -43
  94. package/src/types/subagent.ts +0 -96
  95. package/src/types.ts +0 -22
  96. package/src/utils/approval.ts +0 -213
  97. package/src/utils/events.ts +0 -416
  98. package/src/utils/eviction.ts +0 -181
  99. package/src/utils/index.ts +0 -34
  100. package/src/utils/model-parser.ts +0 -38
  101. package/src/utils/patch-tool-calls.ts +0 -233
  102. package/src/utils/project-detection.ts +0 -32
  103. package/src/utils/summarization.ts +0 -254
@@ -1,273 +0,0 @@
1
- /**
2
- * CompositeBackend: Route operations to different backends based on path prefix.
3
- */
4
-
5
- import type {
6
- BackendProtocol,
7
- EditResult,
8
- FileData,
9
- FileInfo,
10
- GrepMatch,
11
- WriteResult,
12
- } from "../types";
13
-
14
- /**
15
- * Backend that routes file operations to different backends based on path prefix.
16
- *
17
- * This enables hybrid storage strategies by routing files to different backends
18
- * based on their path prefix. Useful for separating persistent and ephemeral storage,
19
- * or using different storage backends for different types of files.
20
- *
21
- * @example Hybrid storage strategy
22
- * ```typescript
23
- * import { CompositeBackend, FilesystemBackend, StateBackend } from 'deepagentsdk';
24
- *
25
- * const state = { todos: [], files: {} };
26
- * const backend = new CompositeBackend(
27
- * new StateBackend(state), // Default: ephemeral storage
28
- * {
29
- * '/persistent/': new FilesystemBackend({ rootDir: './persistent' }), // Persistent files
30
- * '/cache/': new StateBackend(state), // Cached files (ephemeral)
31
- * }
32
- * );
33
- *
34
- * const agent = createDeepAgent({
35
- * model: anthropic('claude-sonnet-4-20250514'),
36
- * backend,
37
- * });
38
- * ```
39
- *
40
- * @example Multiple persistent backends
41
- * ```typescript
42
- * const backend = new CompositeBackend(
43
- * new FilesystemBackend({ rootDir: './default' }),
44
- * {
45
- * '/user-data/': new FilesystemBackend({ rootDir: './user-data' }),
46
- * '/system/': new FilesystemBackend({ rootDir: './system' }),
47
- * }
48
- * );
49
- * ```
50
- */
51
- export class CompositeBackend implements BackendProtocol {
52
- private defaultBackend: BackendProtocol;
53
- private routes: Record<string, BackendProtocol>;
54
- private sortedRoutes: Array<[string, BackendProtocol]>;
55
-
56
- /**
57
- * Create a new CompositeBackend instance.
58
- *
59
- * @param defaultBackend - Backend to use for paths that don't match any route prefix
60
- * @param routes - Record mapping path prefixes to backends.
61
- * Routes are matched by longest prefix first.
62
- * Example: `{ '/persistent/': filesystemBackend, '/cache/': stateBackend }`
63
- */
64
- constructor(
65
- defaultBackend: BackendProtocol,
66
- routes: Record<string, BackendProtocol>
67
- ) {
68
- this.defaultBackend = defaultBackend;
69
- this.routes = routes;
70
-
71
- // Sort routes by length (longest first) for correct prefix matching
72
- this.sortedRoutes = Object.entries(routes).sort(
73
- (a, b) => b[0].length - a[0].length
74
- );
75
- }
76
-
77
- /**
78
- * Determine which backend handles this key and strip prefix.
79
- */
80
- private getBackendAndKey(key: string): [BackendProtocol, string] {
81
- for (const [prefix, backend] of this.sortedRoutes) {
82
- if (key.startsWith(prefix)) {
83
- const suffix = key.substring(prefix.length);
84
- const strippedKey = suffix ? "/" + suffix : "/";
85
- return [backend, strippedKey];
86
- }
87
- }
88
-
89
- return [this.defaultBackend, key];
90
- }
91
-
92
- /**
93
- * List files and directories in the specified directory (non-recursive).
94
- */
95
- async lsInfo(path: string): Promise<FileInfo[]> {
96
- // Check if path matches a specific route
97
- for (const [routePrefix, backend] of this.sortedRoutes) {
98
- if (path.startsWith(routePrefix.replace(/\/$/, ""))) {
99
- const suffix = path.substring(routePrefix.length);
100
- const searchPath = suffix ? "/" + suffix : "/";
101
- const infos = await backend.lsInfo(searchPath);
102
-
103
- // Add route prefix back to paths
104
- const prefixed: FileInfo[] = [];
105
- for (const fi of infos) {
106
- prefixed.push({
107
- ...fi,
108
- path: routePrefix.slice(0, -1) + fi.path,
109
- });
110
- }
111
- return prefixed;
112
- }
113
- }
114
-
115
- // At root, aggregate default and all routed backends
116
- if (path === "/") {
117
- const results: FileInfo[] = [];
118
- const defaultInfos = await this.defaultBackend.lsInfo(path);
119
- results.push(...defaultInfos);
120
-
121
- // Add the route itself as a directory
122
- for (const [routePrefix] of this.sortedRoutes) {
123
- results.push({
124
- path: routePrefix,
125
- is_dir: true,
126
- size: 0,
127
- modified_at: "",
128
- });
129
- }
130
-
131
- results.sort((a, b) => a.path.localeCompare(b.path));
132
- return results;
133
- }
134
-
135
- // Path doesn't match a route: query only default backend
136
- return await this.defaultBackend.lsInfo(path);
137
- }
138
-
139
- /**
140
- * Read file content, routing to appropriate backend.
141
- */
142
- async read(
143
- filePath: string,
144
- offset: number = 0,
145
- limit: number = 2000
146
- ): Promise<string> {
147
- const [backend, strippedKey] = this.getBackendAndKey(filePath);
148
- return await backend.read(strippedKey, offset, limit);
149
- }
150
-
151
- /**
152
- * Read file content as raw FileData.
153
- */
154
- async readRaw(filePath: string): Promise<FileData> {
155
- const [backend, strippedKey] = this.getBackendAndKey(filePath);
156
- return await backend.readRaw(strippedKey);
157
- }
158
-
159
- /**
160
- * Structured search results or error string for invalid input.
161
- */
162
- async grepRaw(
163
- pattern: string,
164
- path: string = "/",
165
- glob: string | null = null
166
- ): Promise<GrepMatch[] | string> {
167
- // If path targets a specific route, search only that backend
168
- for (const [routePrefix, backend] of this.sortedRoutes) {
169
- if (path.startsWith(routePrefix.replace(/\/$/, ""))) {
170
- const suffix = path.substring(routePrefix.length);
171
- const searchPath = suffix ? "/" + suffix : "/";
172
- const raw = await backend.grepRaw(pattern, searchPath, glob);
173
-
174
- if (typeof raw === "string") {
175
- return raw;
176
- }
177
-
178
- return raw.map((m) => ({
179
- ...m,
180
- path: routePrefix.slice(0, -1) + m.path,
181
- }));
182
- }
183
- }
184
-
185
- // Otherwise, search default and all routed backends and merge
186
- const allMatches: GrepMatch[] = [];
187
- const rawDefault = await this.defaultBackend.grepRaw(pattern, path, glob);
188
-
189
- if (typeof rawDefault === "string") {
190
- return rawDefault;
191
- }
192
-
193
- allMatches.push(...rawDefault);
194
-
195
- // Search all routes
196
- for (const [routePrefix, backend] of Object.entries(this.routes)) {
197
- const raw = await backend.grepRaw(pattern, "/", glob);
198
-
199
- if (typeof raw === "string") {
200
- return raw;
201
- }
202
-
203
- allMatches.push(
204
- ...raw.map((m) => ({
205
- ...m,
206
- path: routePrefix.slice(0, -1) + m.path,
207
- }))
208
- );
209
- }
210
-
211
- return allMatches;
212
- }
213
-
214
- /**
215
- * Structured glob matching returning FileInfo objects.
216
- */
217
- async globInfo(pattern: string, path: string = "/"): Promise<FileInfo[]> {
218
- const results: FileInfo[] = [];
219
-
220
- // Route based on path
221
- for (const [routePrefix, backend] of this.sortedRoutes) {
222
- if (path.startsWith(routePrefix.replace(/\/$/, ""))) {
223
- const suffix = path.substring(routePrefix.length);
224
- const searchPath = suffix ? "/" + suffix : "/";
225
- const infos = await backend.globInfo(pattern, searchPath);
226
-
227
- return infos.map((fi) => ({
228
- ...fi,
229
- path: routePrefix.slice(0, -1) + fi.path,
230
- }));
231
- }
232
- }
233
-
234
- // Path doesn't match any specific route - search all backends
235
- const defaultInfos = await this.defaultBackend.globInfo(pattern, path);
236
- results.push(...defaultInfos);
237
-
238
- for (const [routePrefix, backend] of Object.entries(this.routes)) {
239
- const infos = await backend.globInfo(pattern, "/");
240
- results.push(
241
- ...infos.map((fi) => ({
242
- ...fi,
243
- path: routePrefix.slice(0, -1) + fi.path,
244
- }))
245
- );
246
- }
247
-
248
- results.sort((a, b) => a.path.localeCompare(b.path));
249
- return results;
250
- }
251
-
252
- /**
253
- * Create a new file, routing to appropriate backend.
254
- */
255
- async write(filePath: string, content: string): Promise<WriteResult> {
256
- const [backend, strippedKey] = this.getBackendAndKey(filePath);
257
- return await backend.write(strippedKey, content);
258
- }
259
-
260
- /**
261
- * Edit a file, routing to appropriate backend.
262
- */
263
- async edit(
264
- filePath: string,
265
- oldString: string,
266
- newString: string,
267
- replaceAll: boolean = false
268
- ): Promise<EditResult> {
269
- const [backend, strippedKey] = this.getBackendAndKey(filePath);
270
- return await backend.edit(strippedKey, oldString, newString, replaceAll);
271
- }
272
- }
273
-