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
@@ -0,0 +1,1581 @@
1
+ import { $ as createReadFileTool, A as TodosChangedEvent, At as InterruptData, B as InterruptOnConfig, C as HttpRequestStartEvent, Ct as GrepMatch, D as SubagentFinishEvent, Dt as BaseCheckpointSaver, E as StreamWithEventsOptions, Et as isSandboxBackend, F as AgentMemoryOptions, G as execute, H as CreateExecuteToolOptions, I as CreateDeepAgentParams, J as createEditFileTool, K as createTodosTool, L as SummarizationConfig, M as ToolResultEvent, Mt as ResumeOptions, N as WebSearchFinishEvent, O as SubagentStartEvent, Ot as Checkpoint, P as WebSearchStartEvent, Q as createLsTool, R as TodoItem, S as HttpRequestFinishEvent, St as FileInfo, T as StepStartEvent, Tt as WriteResult, U as createExecuteTool, V as SubAgent, W as createExecuteToolFromBackend, X as createGlobTool, Y as createFilesystemTools, Z as createGrepTool, _ as FetchUrlFinishEvent, _t as BackendProtocol, a as getStructuredOutput, at as read_file, b as FileWriteStartEvent, bt as ExecuteResponse, c as ApprovalResponseEvent, ct as createFetchUrlTool, d as DeepAgentEvent, dt as createWebTools, et as createWriteFileTool, f as DoneEvent, ft as fetch_url, g as ExecuteStartEvent, gt as BackendFactory, h as ExecuteFinishEvent, ht as web_search, i as getEventOutput, it as ls, j as ToolCallEvent, jt as ResumeDecision, k as TextEvent, kt as CheckpointSaverOptions, l as CheckpointLoadedEvent, lt as createHttpRequestTool, m as EventCallback, mt as http_request, n as StructuredAgentResult, nt as glob, o as hasStructuredOutput, ot as write_file, p as ErrorEvent, pt as htmlToMarkdown, q as write_todos, r as eventHasStructuredOutput, rt as grep, s as ApprovalRequestedEvent, st as CreateWebToolsOptions, t as ModelMessage$1, tt as edit_file, u as CheckpointSavedEvent, ut as createWebSearchTool, v as FetchUrlStartEvent, vt as DeepAgentState, w as StepFinishEvent, wt as SandboxBackendProtocol, x as FileWrittenEvent, xt as FileData, y as FileEditedEvent, yt as EditResult, z as DynamicApprovalConfig } from "./types-IulnvhFg.cjs";
2
+ import * as ai0 from "ai";
3
+ import { LanguageModel, LanguageModelMiddleware, LanguageModelMiddleware as LanguageModelMiddleware$1, ModelMessage, ToolLoopAgent, ToolLoopAgent as ToolLoopAgent$1, ToolSet, hasToolCall, stepCountIs, wrapLanguageModel } from "ai";
4
+
5
+ //#region src/agent.d.ts
6
+
7
+ /**
8
+ * Deep Agent wrapper class that provides generate() and stream() methods.
9
+ * Uses ToolLoopAgent from AI SDK v6 for the agent loop.
10
+ */
11
+ declare class DeepAgent {
12
+ private model;
13
+ private systemPrompt;
14
+ private userTools;
15
+ private maxSteps;
16
+ private backend;
17
+ private subagentOptions;
18
+ private toolResultEvictionLimit?;
19
+ private enablePromptCaching;
20
+ private summarizationConfig?;
21
+ private hasSandboxBackend;
22
+ private interruptOn?;
23
+ private checkpointer?;
24
+ private skillsMetadata;
25
+ private outputConfig?;
26
+ private loopControl?;
27
+ private generationOptions?;
28
+ private advancedOptions?;
29
+ constructor(params: CreateDeepAgentParams);
30
+ /**
31
+ * Create core tools (todos and filesystem).
32
+ * @private
33
+ */
34
+ private createCoreTools;
35
+ /**
36
+ * Create web tools if TAVILY_API_KEY is available.
37
+ * @private
38
+ */
39
+ private createWebToolSet;
40
+ /**
41
+ * Create execute tool if backend is a sandbox.
42
+ * @private
43
+ */
44
+ private createExecuteToolSet;
45
+ /**
46
+ * Create subagent tool if configured.
47
+ * @private
48
+ */
49
+ private createSubagentToolSet;
50
+ /**
51
+ * Create all tools for the agent, combining core, web, execute, and subagent tools.
52
+ * @private
53
+ */
54
+ private createTools;
55
+ /**
56
+ * Build stop conditions with maxSteps safety limit.
57
+ * Combines user-provided stop conditions with the maxSteps limit.
58
+ */
59
+ private buildStopConditions;
60
+ /**
61
+ * Build agent settings by combining passthrough options with defaults.
62
+ */
63
+ private buildAgentSettings;
64
+ /**
65
+ * Create a ToolLoopAgent for a given state.
66
+ * @param state - The shared agent state
67
+ * @param maxSteps - Optional max steps override
68
+ * @param onEvent - Optional callback for emitting events
69
+ */
70
+ private createAgent;
71
+ /**
72
+ * Load skills from directory asynchronously.
73
+ * Supports both legacy skillsDir and new agentId modes.
74
+ */
75
+ private loadSkills;
76
+ /**
77
+ * Generate a response (non-streaming).
78
+ */
79
+ generate(options: {
80
+ prompt: string;
81
+ maxSteps?: number;
82
+ }): Promise<ai0.GenerateTextResult<{}, never> & {
83
+ state: DeepAgentState;
84
+ }>;
85
+ /**
86
+ * Stream a response.
87
+ */
88
+ stream(options: {
89
+ prompt: string;
90
+ maxSteps?: number;
91
+ }): Promise<ai0.StreamTextResult<{}, never> & {
92
+ state: DeepAgentState;
93
+ }>;
94
+ /**
95
+ * Generate with an existing state (for continuing conversations).
96
+ */
97
+ generateWithState(options: {
98
+ prompt: string;
99
+ state: DeepAgentState;
100
+ maxSteps?: number;
101
+ }): Promise<ai0.GenerateTextResult<{}, never> & {
102
+ state: DeepAgentState;
103
+ }>;
104
+ /**
105
+ * Get the underlying ToolLoopAgent for advanced usage.
106
+ * This allows using AI SDK's createAgentUIStream and other utilities.
107
+ */
108
+ getAgent(state?: DeepAgentState): ToolLoopAgent$1<never, {}, never>;
109
+ /**
110
+ * Stream a response with real-time events.
111
+ * This is an async generator that yields DeepAgentEvent objects.
112
+ *
113
+ * Supports conversation history via the `messages` option for multi-turn conversations.
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * // Single turn
118
+ * for await (const event of agent.streamWithEvents({ prompt: "..." })) {
119
+ * switch (event.type) {
120
+ * case 'text':
121
+ * process.stdout.write(event.text);
122
+ * break;
123
+ * case 'done':
124
+ * // event.messages contains the updated conversation history
125
+ * console.log('Messages:', event.messages);
126
+ * break;
127
+ * }
128
+ * }
129
+ *
130
+ * // Multi-turn conversation
131
+ * let messages = [];
132
+ * for await (const event of agent.streamWithEvents({ prompt: "Hello", messages })) {
133
+ * if (event.type === 'done') {
134
+ * messages = event.messages; // Save for next turn
135
+ * }
136
+ * }
137
+ * for await (const event of agent.streamWithEvents({ prompt: "Follow up", messages })) {
138
+ * // Agent now has context from previous turn
139
+ * }
140
+ * ```
141
+ */
142
+ /**
143
+ * Compose user's onStepFinish callback with DeepAgent's internal checkpointing logic.
144
+ * User callback executes first, errors are caught to prevent breaking checkpointing.
145
+ */
146
+ private composeOnStepFinish;
147
+ /**
148
+ * Compose user's onFinish callback with DeepAgent's internal cleanup logic.
149
+ */
150
+ private composeOnFinish;
151
+ /**
152
+ * Compose user's prepareStep callback with DeepAgent's internal step preparation.
153
+ * Returns a function typed as `any` to avoid AI SDK's strict toolName inference.
154
+ */
155
+ private composePrepareStep;
156
+ /**
157
+ * Build streamText options with callbacks for step tracking and checkpointing.
158
+ *
159
+ * @private
160
+ */
161
+ private buildStreamTextOptions;
162
+ /**
163
+ * Build message array from options, handling validation and priority logic.
164
+ * Priority: explicit messages > prompt > checkpoint history.
165
+ *
166
+ * @private
167
+ */
168
+ private buildMessageArray;
169
+ /**
170
+ * Load checkpoint context if threadId is provided.
171
+ * Handles checkpoint restoration and resume from interrupt.
172
+ *
173
+ * @private
174
+ */
175
+ private loadCheckpointContext;
176
+ streamWithEvents(options: StreamWithEventsOptions): AsyncGenerator<DeepAgentEvent, void, unknown>;
177
+ /**
178
+ * Stream with a simple callback interface.
179
+ * This is a convenience wrapper around streamWithEvents.
180
+ */
181
+ streamWithCallback(options: StreamWithEventsOptions, onEvent: EventCallback): Promise<{
182
+ state: DeepAgentState;
183
+ text?: string;
184
+ messages?: ModelMessage$1[];
185
+ }>;
186
+ }
187
+ /**
188
+ * Create a Deep Agent with planning, filesystem, and subagent capabilities.
189
+ *
190
+ * @param params - Configuration object for the Deep Agent
191
+ * @param params.model - **Required.** AI SDK LanguageModel instance (e.g., `anthropic('claude-sonnet-4-20250514')`, `openai('gpt-4o')`)
192
+ * @param params.systemPrompt - Optional custom system prompt for the agent
193
+ * @param params.tools - Optional custom tools to add to the agent (AI SDK ToolSet)
194
+ * @param params.subagents - Optional array of specialized subagent configurations for task delegation
195
+ * @param params.backend - Optional backend for filesystem operations (default: StateBackend for in-memory storage)
196
+ * @param params.maxSteps - Optional maximum number of steps for the agent loop (default: 100)
197
+ * @param params.includeGeneralPurposeAgent - Optional flag to include general-purpose subagent (default: true)
198
+ * @param params.toolResultEvictionLimit - Optional token limit before evicting large tool results to filesystem (default: disabled)
199
+ * @param params.enablePromptCaching - Optional flag to enable prompt caching for improved performance (Anthropic only, default: false)
200
+ * @param params.summarization - Optional summarization configuration for automatic conversation summarization
201
+ * @returns A configured DeepAgent instance
202
+ *
203
+ * @see {@link CreateDeepAgentParams} for detailed parameter types
204
+ *
205
+ * @example Basic usage
206
+ * ```typescript
207
+ * import { createDeepAgent } from 'deepagentsdk';
208
+ * import { anthropic } from '@ai-sdk/anthropic';
209
+ *
210
+ * const agent = createDeepAgent({
211
+ * model: anthropic('claude-sonnet-4-20250514'),
212
+ * systemPrompt: 'You are a research assistant...',
213
+ * });
214
+ *
215
+ * const result = await agent.generate({
216
+ * prompt: 'Research the topic and write a report',
217
+ * });
218
+ * ```
219
+ *
220
+ * @example With custom tools
221
+ * ```typescript
222
+ * import { tool } from 'ai';
223
+ * import { z } from 'zod';
224
+ *
225
+ * const customTool = tool({
226
+ * description: 'Get current time',
227
+ * inputSchema: z.object({}),
228
+ * execute: async () => new Date().toISOString(),
229
+ * });
230
+ *
231
+ * const agent = createDeepAgent({
232
+ * model: anthropic('claude-sonnet-4-20250514'),
233
+ * tools: { get_time: customTool },
234
+ * });
235
+ * ```
236
+ *
237
+ * @example With subagents
238
+ * ```typescript
239
+ * const agent = createDeepAgent({
240
+ * model: anthropic('claude-sonnet-4-20250514'),
241
+ * subagents: [{
242
+ * name: 'research-agent',
243
+ * description: 'Specialized for research tasks',
244
+ * systemPrompt: 'You are a research specialist...',
245
+ * }],
246
+ * });
247
+ * ```
248
+ *
249
+ * @example With StateBackend (default, explicit)
250
+ * ```typescript
251
+ * import { StateBackend } from 'deepagentsdk';
252
+ *
253
+ * const state = { todos: [], files: {} };
254
+ * const agent = createDeepAgent({
255
+ * model: anthropic('claude-sonnet-4-20250514'),
256
+ * backend: new StateBackend(state), // Ephemeral in-memory storage
257
+ * });
258
+ * ```
259
+ *
260
+ * @example With FilesystemBackend
261
+ * ```typescript
262
+ * import { FilesystemBackend } from 'deepagentsdk';
263
+ *
264
+ * const agent = createDeepAgent({
265
+ * model: anthropic('claude-sonnet-4-20250514'),
266
+ * backend: new FilesystemBackend({ rootDir: './workspace' }), // Persist to disk
267
+ * });
268
+ * ```
269
+ *
270
+ * @example With PersistentBackend
271
+ * ```typescript
272
+ * import { PersistentBackend, InMemoryStore } from 'deepagentsdk';
273
+ *
274
+ * const store = new InMemoryStore();
275
+ * const agent = createDeepAgent({
276
+ * model: anthropic('claude-sonnet-4-20250514'),
277
+ * backend: new PersistentBackend({ store, namespace: 'project-1' }), // Cross-session persistence
278
+ * });
279
+ * ```
280
+ *
281
+ * @example With CompositeBackend
282
+ * ```typescript
283
+ * import { CompositeBackend, FilesystemBackend, StateBackend } from 'deepagentsdk';
284
+ *
285
+ * const state = { todos: [], files: {} };
286
+ * const agent = createDeepAgent({
287
+ * model: anthropic('claude-sonnet-4-20250514'),
288
+ * backend: new CompositeBackend(
289
+ * new StateBackend(state),
290
+ * { '/persistent/': new FilesystemBackend({ rootDir: './persistent' }) }
291
+ * ), // Route files by path prefix
292
+ * });
293
+ * ```
294
+ *
295
+ * @example With middleware for logging and caching
296
+ * ```typescript
297
+ * import { createDeepAgent } from 'deepagentsdk';
298
+ * import { anthropic } from '@ai-sdk/anthropic';
299
+ *
300
+ * const loggingMiddleware = {
301
+ * wrapGenerate: async ({ doGenerate, params }) => {
302
+ * console.log('Model called with:', params.prompt);
303
+ * const result = await doGenerate();
304
+ * console.log('Model returned:', result.text);
305
+ * return result;
306
+ * },
307
+ * };
308
+ *
309
+ * const agent = createDeepAgent({
310
+ * model: anthropic('claude-sonnet-4-20250514'),
311
+ * middleware: [loggingMiddleware],
312
+ * });
313
+ * ```
314
+ *
315
+ * @example With middleware factory for context access
316
+ * ```typescript
317
+ * import { FilesystemBackend } from 'deepagentsdk';
318
+ *
319
+ * function createContextMiddleware(backend: BackendProtocol) {
320
+ * return {
321
+ * wrapGenerate: async ({ doGenerate }) => {
322
+ * const state = await backend.read('state');
323
+ * const result = await doGenerate();
324
+ * await backend.write('state', { ...state, lastCall: result });
325
+ * return result;
326
+ * },
327
+ * };
328
+ * }
329
+ *
330
+ * const backend = new FilesystemBackend({ rootDir: './workspace' });
331
+ * const agent = createDeepAgent({
332
+ * model: anthropic('claude-sonnet-4-20250514'),
333
+ * backend,
334
+ * middleware: createContextMiddleware(backend),
335
+ * });
336
+ * ```
337
+ *
338
+ * @example With performance optimizations
339
+ * ```typescript
340
+ * const agent = createDeepAgent({
341
+ * model: anthropic('claude-sonnet-4-20250514'),
342
+ * enablePromptCaching: true,
343
+ * toolResultEvictionLimit: 20000,
344
+ * summarization: {
345
+ * enabled: true,
346
+ * tokenThreshold: 170000,
347
+ * keepMessages: 6,
348
+ * },
349
+ * });
350
+ * ```
351
+ */
352
+ declare function createDeepAgent(params: CreateDeepAgentParams): DeepAgent;
353
+ //#endregion
354
+ //#region src/backends/state.d.ts
355
+ /**
356
+ * Backend that stores files in shared state (ephemeral).
357
+ *
358
+ * Files persist within a single agent invocation but not across invocations.
359
+ * This is the default backend for Deep Agent when no backend is specified.
360
+ *
361
+ * Files are stored in memory as part of the `DeepAgentState`, making this backend
362
+ * fast but non-persistent. Use `FilesystemBackend` or `PersistentBackend` for
363
+ * cross-session persistence.
364
+ *
365
+ * @example Default usage (no backend specified)
366
+ * ```typescript
367
+ * const agent = createDeepAgent({
368
+ * model: anthropic('claude-sonnet-4-20250514'),
369
+ * // StateBackend is used by default
370
+ * });
371
+ * ```
372
+ *
373
+ * @example Explicit usage
374
+ * ```typescript
375
+ * const state: DeepAgentState = { todos: [], files: {} };
376
+ * const backend = new StateBackend(state);
377
+ * const agent = createDeepAgent({
378
+ * model: anthropic('claude-sonnet-4-20250514'),
379
+ * backend,
380
+ * });
381
+ * ```
382
+ */
383
+ declare class StateBackend implements BackendProtocol {
384
+ private state;
385
+ /**
386
+ * Create a new StateBackend instance.
387
+ *
388
+ * @param state - The DeepAgentState object that will store the files.
389
+ * Files are stored in `state.files` as a Record<string, FileData>.
390
+ */
391
+ constructor(state: DeepAgentState);
392
+ /**
393
+ * Get files from current state.
394
+ */
395
+ private getFiles;
396
+ /**
397
+ * List files and directories in the specified directory (non-recursive).
398
+ */
399
+ lsInfo(path: string): FileInfo[];
400
+ /**
401
+ * Read file content with line numbers.
402
+ */
403
+ read(filePath: string, offset?: number, limit?: number): string;
404
+ /**
405
+ * Read file content as raw FileData.
406
+ */
407
+ readRaw(filePath: string): FileData;
408
+ /**
409
+ * Create a new file with content.
410
+ */
411
+ write(filePath: string, content: string): WriteResult;
412
+ /**
413
+ * Edit a file by replacing string occurrences.
414
+ */
415
+ edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): EditResult;
416
+ /**
417
+ * Structured search results or error string for invalid input.
418
+ */
419
+ grepRaw(pattern: string, path?: string, glob?: string | null): GrepMatch[] | string;
420
+ /**
421
+ * Structured glob matching returning FileInfo objects.
422
+ */
423
+ globInfo(pattern: string, path?: string): FileInfo[];
424
+ }
425
+ //#endregion
426
+ //#region src/backends/filesystem.d.ts
427
+ /**
428
+ * Backend that reads and writes files directly from the filesystem.
429
+ *
430
+ * Files are persisted to disk, making them available across agent invocations.
431
+ * This backend provides real file I/O operations with security checks to prevent
432
+ * directory traversal attacks.
433
+ *
434
+ * @example Basic usage
435
+ * ```typescript
436
+ * const backend = new FilesystemBackend({ rootDir: './workspace' });
437
+ * const agent = createDeepAgent({
438
+ * model: anthropic('claude-sonnet-4-20250514'),
439
+ * backend,
440
+ * });
441
+ * ```
442
+ *
443
+ * @example With custom options
444
+ * ```typescript
445
+ * const backend = new FilesystemBackend({
446
+ * rootDir: './my-project',
447
+ * virtualMode: false,
448
+ * maxFileSizeMb: 50, // Allow larger files
449
+ * });
450
+ * ```
451
+ */
452
+ declare class FilesystemBackend implements BackendProtocol {
453
+ private cwd;
454
+ private virtualMode;
455
+ private maxFileSizeBytes;
456
+ /**
457
+ * Create a new FilesystemBackend instance.
458
+ *
459
+ * @param options - Configuration options
460
+ * @param options.rootDir - Optional root directory for file operations (default: current working directory).
461
+ * All file paths are resolved relative to this directory.
462
+ * @param options.virtualMode - Optional flag for virtual mode (default: false).
463
+ * When true, files are stored in memory but paths are validated against filesystem.
464
+ * @param options.maxFileSizeMb - Optional maximum file size in MB (default: 10).
465
+ * Files larger than this will be rejected.
466
+ */
467
+ constructor(options?: {
468
+ rootDir?: string;
469
+ virtualMode?: boolean;
470
+ maxFileSizeMb?: number;
471
+ });
472
+ /**
473
+ * Resolve a file path with security checks.
474
+ */
475
+ private resolvePath;
476
+ /**
477
+ * List files and directories in the specified directory (non-recursive).
478
+ */
479
+ lsInfo(dirPath: string): Promise<FileInfo[]>;
480
+ /**
481
+ * Read file content with line numbers.
482
+ */
483
+ read(filePath: string, offset?: number, limit?: number): Promise<string>;
484
+ /**
485
+ * Read file content as raw FileData.
486
+ */
487
+ readRaw(filePath: string): Promise<FileData>;
488
+ /**
489
+ * Create a new file with content.
490
+ */
491
+ write(filePath: string, content: string): Promise<WriteResult>;
492
+ /**
493
+ * Edit a file by replacing string occurrences.
494
+ */
495
+ edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): Promise<EditResult>;
496
+ /**
497
+ * Structured search results or error string for invalid input.
498
+ */
499
+ grepRaw(pattern: string, dirPath?: string, glob?: string | null): Promise<GrepMatch[] | string>;
500
+ /**
501
+ * Try to use ripgrep for fast searching.
502
+ */
503
+ private ripgrepSearch;
504
+ /**
505
+ * Fallback regex search implementation.
506
+ */
507
+ private regexSearch;
508
+ /**
509
+ * Structured glob matching returning FileInfo objects.
510
+ */
511
+ globInfo(pattern: string, searchPath?: string): Promise<FileInfo[]>;
512
+ }
513
+ //#endregion
514
+ //#region src/backends/composite.d.ts
515
+ /**
516
+ * Backend that routes file operations to different backends based on path prefix.
517
+ *
518
+ * This enables hybrid storage strategies by routing files to different backends
519
+ * based on their path prefix. Useful for separating persistent and ephemeral storage,
520
+ * or using different storage backends for different types of files.
521
+ *
522
+ * @example Hybrid storage strategy
523
+ * ```typescript
524
+ * import { CompositeBackend, FilesystemBackend, StateBackend } from 'deepagentsdk';
525
+ *
526
+ * const state = { todos: [], files: {} };
527
+ * const backend = new CompositeBackend(
528
+ * new StateBackend(state), // Default: ephemeral storage
529
+ * {
530
+ * '/persistent/': new FilesystemBackend({ rootDir: './persistent' }), // Persistent files
531
+ * '/cache/': new StateBackend(state), // Cached files (ephemeral)
532
+ * }
533
+ * );
534
+ *
535
+ * const agent = createDeepAgent({
536
+ * model: anthropic('claude-sonnet-4-20250514'),
537
+ * backend,
538
+ * });
539
+ * ```
540
+ *
541
+ * @example Multiple persistent backends
542
+ * ```typescript
543
+ * const backend = new CompositeBackend(
544
+ * new FilesystemBackend({ rootDir: './default' }),
545
+ * {
546
+ * '/user-data/': new FilesystemBackend({ rootDir: './user-data' }),
547
+ * '/system/': new FilesystemBackend({ rootDir: './system' }),
548
+ * }
549
+ * );
550
+ * ```
551
+ */
552
+ declare class CompositeBackend implements BackendProtocol {
553
+ private defaultBackend;
554
+ private routes;
555
+ private sortedRoutes;
556
+ /**
557
+ * Create a new CompositeBackend instance.
558
+ *
559
+ * @param defaultBackend - Backend to use for paths that don't match any route prefix
560
+ * @param routes - Record mapping path prefixes to backends.
561
+ * Routes are matched by longest prefix first.
562
+ * Example: `{ '/persistent/': filesystemBackend, '/cache/': stateBackend }`
563
+ */
564
+ constructor(defaultBackend: BackendProtocol, routes: Record<string, BackendProtocol>);
565
+ /**
566
+ * Determine which backend handles this key and strip prefix.
567
+ */
568
+ private getBackendAndKey;
569
+ /**
570
+ * List files and directories in the specified directory (non-recursive).
571
+ */
572
+ lsInfo(path: string): Promise<FileInfo[]>;
573
+ /**
574
+ * Read file content, routing to appropriate backend.
575
+ */
576
+ read(filePath: string, offset?: number, limit?: number): Promise<string>;
577
+ /**
578
+ * Read file content as raw FileData.
579
+ */
580
+ readRaw(filePath: string): Promise<FileData>;
581
+ /**
582
+ * Structured search results or error string for invalid input.
583
+ */
584
+ grepRaw(pattern: string, path?: string, glob?: string | null): Promise<GrepMatch[] | string>;
585
+ /**
586
+ * Structured glob matching returning FileInfo objects.
587
+ */
588
+ globInfo(pattern: string, path?: string): Promise<FileInfo[]>;
589
+ /**
590
+ * Create a new file, routing to appropriate backend.
591
+ */
592
+ write(filePath: string, content: string): Promise<WriteResult>;
593
+ /**
594
+ * Edit a file, routing to appropriate backend.
595
+ */
596
+ edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): Promise<EditResult>;
597
+ }
598
+ //#endregion
599
+ //#region src/backends/persistent.d.ts
600
+ /**
601
+ * Generic key-value store interface for persistent storage.
602
+ *
603
+ * Implement this interface to use any storage backend (Redis, SQLite, cloud storage, etc.)
604
+ * with PersistentBackend. The interface uses hierarchical namespaces for organization.
605
+ *
606
+ * @example Redis implementation
607
+ * ```typescript
608
+ * class RedisStore implements KeyValueStore {
609
+ * constructor(private redis: RedisClient) {}
610
+ *
611
+ * async get(namespace: string[], key: string) {
612
+ * const redisKey = [...namespace, key].join(':');
613
+ * const data = await this.redis.get(redisKey);
614
+ * return data ? JSON.parse(data) : undefined;
615
+ * }
616
+ *
617
+ * async put(namespace: string[], key: string, value: Record<string, unknown>) {
618
+ * const redisKey = [...namespace, key].join(':');
619
+ * await this.redis.set(redisKey, JSON.stringify(value));
620
+ * }
621
+ *
622
+ * async delete(namespace: string[], key: string) {
623
+ * const redisKey = [...namespace, key].join(':');
624
+ * await this.redis.del(redisKey);
625
+ * }
626
+ *
627
+ * async list(namespace: string[]) {
628
+ * const prefix = [...namespace].join(':') + ':';
629
+ * const keys = await this.redis.keys(prefix + '*');
630
+ * const results = [];
631
+ * for (const key of keys) {
632
+ * const data = await this.redis.get(key);
633
+ * if (data) {
634
+ * const relativeKey = key.substring(prefix.length);
635
+ * results.push({ key: relativeKey, value: JSON.parse(data) });
636
+ * }
637
+ * }
638
+ * return results;
639
+ * }
640
+ * }
641
+ * ```
642
+ */
643
+ interface KeyValueStore {
644
+ /**
645
+ * Get a value by key from the store.
646
+ * @param namespace - Hierarchical namespace array (e.g., ["project1", "filesystem"])
647
+ * @param key - The key to retrieve (file path in the case of PersistentBackend)
648
+ * @returns The stored value as a record, or undefined if not found
649
+ */
650
+ get(namespace: string[], key: string): Promise<Record<string, unknown> | undefined>;
651
+ /**
652
+ * Store a value by key in the store.
653
+ * @param namespace - Hierarchical namespace array
654
+ * @param key - The key to store (file path in the case of PersistentBackend)
655
+ * @param value - The value to store (must be serializable to JSON)
656
+ */
657
+ put(namespace: string[], key: string, value: Record<string, unknown>): Promise<void>;
658
+ /**
659
+ * Delete a value by key from the store.
660
+ * @param namespace - Hierarchical namespace array
661
+ * @param key - The key to delete (file path in the case of PersistentBackend)
662
+ */
663
+ delete(namespace: string[], key: string): Promise<void>;
664
+ /**
665
+ * List all keys and values in a namespace.
666
+ * @param namespace - Hierarchical namespace array
667
+ * @returns Array of items with key and value pairs directly in this namespace
668
+ * (not including sub-namespaces)
669
+ */
670
+ list(namespace: string[]): Promise<Array<{
671
+ key: string;
672
+ value: Record<string, unknown>;
673
+ }>>;
674
+ }
675
+ /**
676
+ * Simple in-memory implementation of KeyValueStore.
677
+ *
678
+ * Useful for testing or single-session persistence. Data is stored in a Map
679
+ * and does not persist across application restarts.
680
+ *
681
+ * @example Basic usage
682
+ * ```typescript
683
+ * const store = new InMemoryStore();
684
+ * const backend = new PersistentBackend({ store });
685
+ * ```
686
+ *
687
+ * @example For testing
688
+ * ```typescript
689
+ * const store = new InMemoryStore();
690
+ * // ... run tests ...
691
+ * store.clear(); // Clean up after tests
692
+ * ```
693
+ */
694
+ declare class InMemoryStore implements KeyValueStore {
695
+ private data;
696
+ private makeKey;
697
+ private parseKey;
698
+ get(namespace: string[], key: string): Promise<Record<string, unknown> | undefined>;
699
+ put(namespace: string[], key: string, value: Record<string, unknown>): Promise<void>;
700
+ delete(namespace: string[], key: string): Promise<void>;
701
+ list(namespace: string[]): Promise<Array<{
702
+ key: string;
703
+ value: Record<string, unknown>;
704
+ }>>;
705
+ /**
706
+ * Clear all data (useful for testing).
707
+ */
708
+ clear(): void;
709
+ /**
710
+ * Get the number of stored items.
711
+ */
712
+ size(): number;
713
+ }
714
+ /**
715
+ * Options for creating a PersistentBackend.
716
+ */
717
+ interface PersistentBackendOptions {
718
+ /**
719
+ * **Required.** The key-value store implementation to use.
720
+ *
721
+ * You can use the built-in `InMemoryStore` for testing, or implement `KeyValueStore`
722
+ * for custom storage (Redis, SQLite, etc.).
723
+ *
724
+ * @see {@link KeyValueStore} for the interface definition
725
+ * @see {@link InMemoryStore} for a simple in-memory implementation
726
+ */
727
+ store: KeyValueStore;
728
+ /**
729
+ * Optional namespace prefix for isolation (e.g., project ID, user ID).
730
+ *
731
+ * This allows multiple agents or projects to share the same store without conflicts.
732
+ * Files are stored under `[namespace]/filesystem/` in the key-value store.
733
+ *
734
+ * Default: "default"
735
+ */
736
+ namespace?: string;
737
+ }
738
+ /**
739
+ * Backend that stores files in a persistent key-value store.
740
+ *
741
+ * This provides cross-conversation file persistence that survives between agent sessions.
742
+ * Files are stored in the provided key-value store, allowing you to use any storage backend
743
+ * (Redis, SQLite, cloud storage, etc.) by implementing the `KeyValueStore` interface.
744
+ *
745
+ * @example Using InMemoryStore (for testing or single-session persistence)
746
+ * ```typescript
747
+ * import { createDeepAgent } from 'deepagentsdk';
748
+ * import { PersistentBackend, InMemoryStore } from 'deepagentsdk';
749
+ * import { anthropic } from '@ai-sdk/anthropic';
750
+ *
751
+ * const store = new InMemoryStore();
752
+ * const backend = new PersistentBackend({ store });
753
+ * const agent = createDeepAgent({
754
+ * model: anthropic('claude-sonnet-4-20250514'),
755
+ * backend,
756
+ * });
757
+ * ```
758
+ *
759
+ * @example With custom namespace for project isolation
760
+ * ```typescript
761
+ * import { createDeepAgent } from 'deepagentsdk';
762
+ * import { PersistentBackend, InMemoryStore } from 'deepagentsdk';
763
+ * import { anthropic } from '@ai-sdk/anthropic';
764
+ *
765
+ * const store = new InMemoryStore();
766
+ * const backend = new PersistentBackend({
767
+ * store,
768
+ * namespace: 'project-123', // Isolate files for this project
769
+ * });
770
+ * const agent = createDeepAgent({
771
+ * model: anthropic('claude-sonnet-4-20250514'),
772
+ * backend,
773
+ * });
774
+ * ```
775
+ *
776
+ * @example Custom KeyValueStore implementation (Redis)
777
+ * ```typescript
778
+ * import { createDeepAgent } from 'deepagentsdk';
779
+ * import { PersistentBackend, type KeyValueStore } from 'deepagentsdk';
780
+ * import { anthropic } from '@ai-sdk/anthropic';
781
+ * import { createClient } from 'redis';
782
+ *
783
+ * class RedisStore implements KeyValueStore {
784
+ * constructor(private redis: ReturnType<typeof createClient>) {}
785
+ *
786
+ * async get(namespace: string[], key: string) {
787
+ * const redisKey = [...namespace, key].join(':');
788
+ * const data = await this.redis.get(redisKey);
789
+ * return data ? JSON.parse(data) : undefined;
790
+ * }
791
+ *
792
+ * async put(namespace: string[], key: string, value: Record<string, unknown>) {
793
+ * const redisKey = [...namespace, key].join(':');
794
+ * await this.redis.set(redisKey, JSON.stringify(value));
795
+ * }
796
+ *
797
+ * async delete(namespace: string[], key: string) {
798
+ * const redisKey = [...namespace, key].join(':');
799
+ * await this.redis.del(redisKey);
800
+ * }
801
+ *
802
+ * async list(namespace: string[]) {
803
+ * const prefix = [...namespace].join(':') + ':';
804
+ * const keys = await this.redis.keys(prefix + '*');
805
+ * const results = [];
806
+ * for (const key of keys) {
807
+ * const data = await this.redis.get(key);
808
+ * if (data) {
809
+ * const relativeKey = key.substring(prefix.length);
810
+ * results.push({ key: relativeKey, value: JSON.parse(data) });
811
+ * }
812
+ * }
813
+ * return results;
814
+ * }
815
+ * }
816
+ *
817
+ * const redis = createClient();
818
+ * await redis.connect();
819
+ *
820
+ * const backend = new PersistentBackend({
821
+ * store: new RedisStore(redis),
822
+ * namespace: 'production'
823
+ * });
824
+ *
825
+ * const agent = createDeepAgent({
826
+ * model: anthropic('claude-sonnet-4-20250514'),
827
+ * backend,
828
+ * });
829
+ * ```
830
+ */
831
+ declare class PersistentBackend implements BackendProtocol {
832
+ private store;
833
+ private namespacePrefix;
834
+ /**
835
+ * Create a new PersistentBackend instance.
836
+ *
837
+ * @param options - Configuration options
838
+ * @param options.store - The key-value store implementation to use
839
+ * @param options.namespace - Optional namespace prefix for file isolation
840
+ */
841
+ constructor(options: PersistentBackendOptions);
842
+ /**
843
+ * Get the namespace for store operations.
844
+ */
845
+ protected getNamespace(): string[];
846
+ /**
847
+ * Convert a store value to FileData format.
848
+ */
849
+ private convertToFileData;
850
+ /**
851
+ * Convert FileData to a value suitable for store.put().
852
+ */
853
+ private convertFromFileData;
854
+ /**
855
+ * List files and directories in the specified directory (non-recursive).
856
+ */
857
+ lsInfo(path: string): Promise<FileInfo[]>;
858
+ /**
859
+ * Read file content with line numbers.
860
+ */
861
+ read(filePath: string, offset?: number, limit?: number): Promise<string>;
862
+ /**
863
+ * Read file content as raw FileData.
864
+ */
865
+ readRaw(filePath: string): Promise<FileData>;
866
+ /**
867
+ * Create a new file with content.
868
+ */
869
+ write(filePath: string, content: string): Promise<WriteResult>;
870
+ /**
871
+ * Edit a file by replacing string occurrences.
872
+ */
873
+ edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): Promise<EditResult>;
874
+ /**
875
+ * Structured search results or error string for invalid input.
876
+ */
877
+ grepRaw(pattern: string, path?: string, glob?: string | null): Promise<GrepMatch[] | string>;
878
+ /**
879
+ * Structured glob matching returning FileInfo objects.
880
+ */
881
+ globInfo(pattern: string, path?: string): Promise<FileInfo[]>;
882
+ /**
883
+ * Delete a file.
884
+ */
885
+ deleteFile(filePath: string): Promise<{
886
+ error?: string;
887
+ }>;
888
+ }
889
+ //#endregion
890
+ //#region src/backends/sandbox.d.ts
891
+ /**
892
+ * Abstract base class for sandbox backends.
893
+ *
894
+ * Implements all file operations using shell commands via execute().
895
+ * Subclasses only need to implement execute() and id.
896
+ *
897
+ * @example Creating a custom sandbox backend
898
+ * ```typescript
899
+ * class MyCloudSandbox extends BaseSandbox {
900
+ * readonly id = 'my-cloud-123';
901
+ *
902
+ * async execute(command: string): Promise<ExecuteResponse> {
903
+ * // Call your cloud provider's API
904
+ * const result = await myCloudApi.runCommand(command);
905
+ * return {
906
+ * output: result.stdout + result.stderr,
907
+ * exitCode: result.exitCode,
908
+ * truncated: false,
909
+ * };
910
+ * }
911
+ * }
912
+ * ```
913
+ */
914
+ declare abstract class BaseSandbox implements SandboxBackendProtocol {
915
+ /**
916
+ * Execute a shell command in the sandbox.
917
+ * Must be implemented by subclasses.
918
+ */
919
+ abstract execute(command: string): Promise<ExecuteResponse>;
920
+ /**
921
+ * Unique identifier for this sandbox instance.
922
+ * Must be implemented by subclasses.
923
+ */
924
+ abstract readonly id: string;
925
+ /**
926
+ * List files and directories in a path.
927
+ */
928
+ lsInfo(path: string): Promise<FileInfo[]>;
929
+ /**
930
+ * Read file content with line numbers.
931
+ */
932
+ read(filePath: string, offset?: number, limit?: number): Promise<string>;
933
+ /**
934
+ * Read raw file data.
935
+ */
936
+ readRaw(filePath: string): Promise<FileData>;
937
+ /**
938
+ * Write content to a new file.
939
+ */
940
+ write(filePath: string, content: string): Promise<WriteResult>;
941
+ /**
942
+ * Edit a file by replacing string occurrences.
943
+ */
944
+ edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): Promise<EditResult>;
945
+ /**
946
+ * Search for pattern in files.
947
+ */
948
+ grepRaw(pattern: string, path?: string, glob?: string | null): Promise<GrepMatch[] | string>;
949
+ /**
950
+ * Find files matching glob pattern.
951
+ */
952
+ globInfo(pattern: string, path?: string): Promise<FileInfo[]>;
953
+ }
954
+ //#endregion
955
+ //#region src/backends/local-sandbox.d.ts
956
+ /**
957
+ * Options for LocalSandbox.
958
+ */
959
+ interface LocalSandboxOptions {
960
+ /**
961
+ * Working directory for command execution.
962
+ * All file paths in sandbox operations are relative to this directory.
963
+ * @default process.cwd()
964
+ */
965
+ cwd?: string;
966
+ /**
967
+ * Timeout in milliseconds for command execution.
968
+ * Commands that exceed this timeout will be terminated.
969
+ * @default 30000 (30 seconds)
970
+ */
971
+ timeout?: number;
972
+ /**
973
+ * Additional environment variables to set for command execution.
974
+ * These are merged with the current process environment.
975
+ */
976
+ env?: Record<string, string>;
977
+ /**
978
+ * Maximum output size in bytes before truncation.
979
+ * @default 1048576 (1MB)
980
+ */
981
+ maxOutputSize?: number;
982
+ }
983
+ /**
984
+ * Local sandbox that executes commands using Node.js child_process.
985
+ *
986
+ * All commands are executed in a bash shell with the specified working directory.
987
+ * Inherits all file operations (read, write, edit, ls, grep, glob) from BaseSandbox.
988
+ *
989
+ * @example Basic usage
990
+ * ```typescript
991
+ * import { LocalSandbox } from 'deepagentsdk';
992
+ *
993
+ * const sandbox = new LocalSandbox({ cwd: './workspace' });
994
+ *
995
+ * // Execute commands
996
+ * const result = await sandbox.execute('ls -la');
997
+ * console.log(result.output);
998
+ *
999
+ * // File operations
1000
+ * await sandbox.write('./src/index.ts', 'console.log("hello")');
1001
+ * const content = await sandbox.read('./src/index.ts');
1002
+ * ```
1003
+ *
1004
+ * @example With timeout and environment
1005
+ * ```typescript
1006
+ * const sandbox = new LocalSandbox({
1007
+ * cwd: './workspace',
1008
+ * timeout: 60000, // 60 seconds
1009
+ * env: {
1010
+ * NODE_ENV: 'development',
1011
+ * DEBUG: '*',
1012
+ * },
1013
+ * });
1014
+ * ```
1015
+ *
1016
+ * @example Error handling
1017
+ * ```typescript
1018
+ * const result = await sandbox.execute('npm test');
1019
+ * if (result.exitCode !== 0) {
1020
+ * console.error('Tests failed:', result.output);
1021
+ * }
1022
+ * ```
1023
+ */
1024
+ declare class LocalSandbox extends BaseSandbox {
1025
+ private readonly cwd;
1026
+ private readonly timeout;
1027
+ private readonly env;
1028
+ private readonly maxOutputSize;
1029
+ private readonly _id;
1030
+ /**
1031
+ * Create a new LocalSandbox instance.
1032
+ *
1033
+ * @param options - Configuration options for the sandbox
1034
+ */
1035
+ constructor(options?: LocalSandboxOptions);
1036
+ /**
1037
+ * Unique identifier for this sandbox instance.
1038
+ * Format: `local-{timestamp}-{random}`
1039
+ */
1040
+ get id(): string;
1041
+ /**
1042
+ * Execute a shell command in the local filesystem.
1043
+ *
1044
+ * Commands are executed using bash with the configured working directory
1045
+ * and environment variables. Output is captured from both stdout and stderr.
1046
+ *
1047
+ * @param command - Shell command to execute
1048
+ * @returns ExecuteResponse with output, exit code, and truncation status
1049
+ *
1050
+ * @example
1051
+ * ```typescript
1052
+ * const result = await sandbox.execute('echo "Hello" && ls -la');
1053
+ * console.log(result.output);
1054
+ * console.log('Exit code:', result.exitCode);
1055
+ * ```
1056
+ */
1057
+ execute(command: string): Promise<ExecuteResponse>;
1058
+ }
1059
+ //#endregion
1060
+ //#region src/tools/subagent.d.ts
1061
+ /**
1062
+ * Options for creating the subagent tool.
1063
+ */
1064
+ interface CreateSubagentToolOptions {
1065
+ /** Default model for subagents (AI SDK LanguageModel instance) */
1066
+ defaultModel: LanguageModel;
1067
+ /** Default tools available to all subagents */
1068
+ defaultTools?: ToolSet;
1069
+ /** List of custom subagent specifications */
1070
+ subagents?: SubAgent[];
1071
+ /** Whether to include the general-purpose agent */
1072
+ includeGeneralPurposeAgent?: boolean;
1073
+ /** Backend for filesystem operations */
1074
+ backend?: BackendProtocol | BackendFactory;
1075
+ /** Custom description for the task tool */
1076
+ taskDescription?: string | null;
1077
+ /** Optional callback for emitting events */
1078
+ onEvent?: EventCallback;
1079
+ /** Interrupt config to pass to subagents */
1080
+ interruptOn?: InterruptOnConfig;
1081
+ /** Parent agent options to pass through to subagents */
1082
+ parentGenerationOptions?: CreateDeepAgentParams["generationOptions"];
1083
+ parentAdvancedOptions?: CreateDeepAgentParams["advancedOptions"];
1084
+ }
1085
+ /**
1086
+ * Create the task tool for spawning subagents using ToolLoopAgent.
1087
+ */
1088
+ declare function createSubagentTool(state: DeepAgentState, options: CreateSubagentToolOptions): ai0.Tool<{
1089
+ description: string;
1090
+ subagent_type: string;
1091
+ }, string>;
1092
+ //#endregion
1093
+ //#region src/prompts.d.ts
1094
+ /**
1095
+ * System prompts for Deep Agent.
1096
+ */
1097
+ declare const BASE_PROMPT = "In order to complete the objective that the user asks of you, you have access to a number of standard tools.";
1098
+ declare const TODO_SYSTEM_PROMPT = "## `write_todos` (task planning)\n\nYou have access to a `write_todos` tool to help you manage and plan tasks. Use this tool whenever you are working on a complex task.\n\n### When to Use This Tool\n\nUse proactively for:\n1. Complex multi-step tasks (3+ distinct steps)\n2. Non-trivial tasks requiring careful planning\n3. After receiving new instructions - capture requirements as todos\n4. After completing tasks - mark complete and add follow-ups\n5. When starting new tasks - mark as in_progress (ideally only one at a time)\n\n### When NOT to Use\n\nSkip for:\n1. Single, straightforward tasks\n2. Trivial tasks with no organizational benefit\n3. Tasks completable in < 3 trivial steps\n4. Purely conversational/informational requests\n\n### Task States and Management\n\n1. **Task States:**\n - pending: Not yet started\n - in_progress: Currently working on\n - completed: Finished successfully\n - cancelled: No longer needed\n\n2. **Task Management:**\n - Update status in real-time\n - Mark complete IMMEDIATELY after finishing\n - Only ONE task in_progress at a time\n - Complete current tasks before starting new ones";
1099
+ declare const FILESYSTEM_SYSTEM_PROMPT = "## Virtual Filesystem\n\nYou have access to a virtual filesystem. All file paths must start with a /.\n\n- ls: list files in a directory (requires absolute path)\n- read_file: read a file from the filesystem\n- write_file: write to a file in the filesystem\n- edit_file: edit a file in the filesystem\n- glob: find files matching a pattern (e.g., \"**/*.py\")\n- grep: search for text within files";
1100
+ declare const TASK_SYSTEM_PROMPT = "## `task` (subagent spawner)\n\nYou have access to a `task` tool to launch short-lived subagents that handle isolated tasks. These agents are ephemeral \u2014 they live only for the duration of the task and return a single result.\n\nWhen to use the task tool:\n- When a task is complex and multi-step, and can be fully delegated in isolation\n- When a task is independent of other tasks and can run in parallel\n- When a task requires focused reasoning or heavy token/context usage that would bloat the orchestrator thread\n- When sandboxing improves reliability (e.g. code execution, structured searches, data formatting)\n- When you only care about the output of the subagent, and not the intermediate steps\n\nSubagent lifecycle:\n1. **Spawn** \u2192 Provide clear role, instructions, and expected output\n2. **Run** \u2192 The subagent completes the task autonomously\n3. **Return** \u2192 The subagent provides a single structured result\n4. **Reconcile** \u2192 Incorporate or synthesize the result into the main thread\n\nWhen NOT to use the task tool:\n- If you need to see the intermediate reasoning or steps after the subagent has completed (the task tool hides them)\n- If the task is trivial (a few tool calls or simple lookup)\n- If delegating does not reduce token usage, complexity, or context switching\n- If splitting would add latency without benefit\n\n## Important Task Tool Usage Notes\n- Whenever possible, parallelize the work that you do. Whenever you have independent steps to complete - kick off tasks (subagents) in parallel to accomplish them faster.\n- Remember to use the `task` tool to silo independent tasks within a multi-part objective.\n- You should use the `task` tool whenever you have a complex task that will take multiple steps, and is independent from other tasks that the agent needs to complete.";
1101
+ /**
1102
+ * Get the task tool description with available subagent types.
1103
+ */
1104
+ declare function getTaskToolDescription(subagentDescriptions: string[]): string;
1105
+ declare const DEFAULT_GENERAL_PURPOSE_DESCRIPTION = "General-purpose agent for researching complex questions, searching for files and content, and executing multi-step tasks. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries use this agent to perform the search for you. This agent has access to all tools as the main agent.";
1106
+ declare const DEFAULT_SUBAGENT_PROMPT = "In order to complete the objective that the user asks of you, you have access to a number of standard tools.";
1107
+ declare const EXECUTE_SYSTEM_PROMPT = "## `execute` (shell command execution)\n\nYou have access to an `execute` tool to run shell commands in the sandbox environment.\n\n### When to Use This Tool\n\nUse for:\n- Running build commands (npm install, npm run build, bun install)\n- Running tests (npm test, bun test, pytest)\n- Executing scripts (node script.js, python script.py)\n- Installing dependencies\n- Checking system state (ls, cat, pwd, which)\n- Any shell command that helps accomplish the task\n\n### Important Notes\n\n1. **Exit Codes**: Always check the exit code to determine success\n - 0 = success\n - non-zero = failure\n - null = possibly timed out\n\n2. **Command Chaining**:\n - Use `&&` to chain commands that depend on each other\n - Use `;` to run commands sequentially regardless of success\n\n3. **Timeouts**: Long-running commands may timeout\n\n4. **Working Directory**: Commands run in the sandbox's working directory";
1108
+ //#endregion
1109
+ //#region src/utils/patch-tool-calls.d.ts
1110
+ /**
1111
+ * Patch dangling tool calls in a message array.
1112
+ *
1113
+ * Scans for assistant messages with tool_calls that don't have corresponding
1114
+ * tool result messages, and adds synthetic "cancelled" responses.
1115
+ *
1116
+ * @param messages - Array of messages to patch
1117
+ * @returns New array with patched messages (original array is not modified)
1118
+ *
1119
+ * @example
1120
+ * ```typescript
1121
+ * const messages = [
1122
+ * { role: "user", content: "Hello" },
1123
+ * { role: "assistant", content: [{ type: "tool-call", toolCallId: "1", toolName: "search" }] },
1124
+ * // Missing tool result for tool call "1"
1125
+ * { role: "user", content: "Never mind" },
1126
+ * ];
1127
+ *
1128
+ * const patched = patchToolCalls(messages);
1129
+ * // patched now includes a synthetic tool result for the dangling call
1130
+ * ```
1131
+ */
1132
+ declare function patchToolCalls(messages: ModelMessage[]): ModelMessage[];
1133
+ /**
1134
+ * Check if messages have any dangling tool calls.
1135
+ *
1136
+ * @param messages - Array of messages to check
1137
+ * @returns True if there are dangling tool calls
1138
+ */
1139
+ declare function hasDanglingToolCalls(messages: ModelMessage[]): boolean;
1140
+ //#endregion
1141
+ //#region src/utils/eviction.d.ts
1142
+ /**
1143
+ * Default token limit before evicting a tool result.
1144
+ * Approximately 20,000 tokens (~80KB of text).
1145
+ */
1146
+ declare const DEFAULT_EVICTION_TOKEN_LIMIT = 20000;
1147
+ /**
1148
+ * Estimate the number of tokens in a string.
1149
+ * Uses a simple character-based approximation.
1150
+ */
1151
+ declare function estimateTokens(text: string): number;
1152
+ /**
1153
+ * Check if a tool result should be evicted based on size.
1154
+ */
1155
+ declare function shouldEvict(result: string, tokenLimit?: number): boolean;
1156
+ /**
1157
+ * Options for evicting a tool result.
1158
+ */
1159
+ interface EvictOptions {
1160
+ /** The tool result content */
1161
+ result: string;
1162
+ /** The tool call ID (used for filename) */
1163
+ toolCallId: string;
1164
+ /** The tool name */
1165
+ toolName: string;
1166
+ /** Backend to write the evicted content to */
1167
+ backend: BackendProtocol;
1168
+ /** Token limit before eviction (default: 20000) */
1169
+ tokenLimit?: number;
1170
+ }
1171
+ /**
1172
+ * Result of an eviction operation.
1173
+ */
1174
+ interface EvictResult {
1175
+ /** Whether the result was evicted */
1176
+ evicted: boolean;
1177
+ /** The content to return (either original or truncated message) */
1178
+ content: string;
1179
+ /** Path where content was evicted to (if evicted) */
1180
+ evictedPath?: string;
1181
+ }
1182
+ /**
1183
+ * Evict a large tool result to the filesystem.
1184
+ *
1185
+ * If the result exceeds the token limit, writes it to a file and
1186
+ * returns a truncated message with the file path.
1187
+ *
1188
+ * @param options - Eviction options
1189
+ * @returns Eviction result with content and metadata
1190
+ *
1191
+ * @example
1192
+ * ```typescript
1193
+ * const result = await evictToolResult({
1194
+ * result: veryLongString,
1195
+ * toolCallId: "call_123",
1196
+ * toolName: "grep",
1197
+ * backend: filesystemBackend,
1198
+ * });
1199
+ *
1200
+ * if (result.evicted) {
1201
+ * console.log(`Content saved to ${result.evictedPath}`);
1202
+ * }
1203
+ * ```
1204
+ */
1205
+ declare function evictToolResult(options: EvictOptions): Promise<EvictResult>;
1206
+ /**
1207
+ * Create a tool result wrapper that automatically evicts large results.
1208
+ *
1209
+ * @param backend - Backend or factory for filesystem operations
1210
+ * @param state - Current agent state (for factory backends)
1211
+ * @param tokenLimit - Token limit before eviction
1212
+ * @returns Function that wraps tool results with eviction
1213
+ */
1214
+ declare function createToolResultWrapper(backend: BackendProtocol | BackendFactory, state: DeepAgentState, tokenLimit?: number): (result: string, toolCallId: string, toolName: string) => Promise<string>;
1215
+ //#endregion
1216
+ //#region src/utils/summarization.d.ts
1217
+ /**
1218
+ * Default token threshold before triggering summarization.
1219
+ * 170k tokens is a safe threshold for most models.
1220
+ */
1221
+ declare const DEFAULT_SUMMARIZATION_THRESHOLD = 170000;
1222
+ /**
1223
+ * Default number of recent messages to keep intact.
1224
+ */
1225
+ declare const DEFAULT_KEEP_MESSAGES = 6;
1226
+ /**
1227
+ * Options for summarization.
1228
+ */
1229
+ interface SummarizationOptions {
1230
+ /** Model to use for summarization (AI SDK LanguageModel instance) */
1231
+ model: LanguageModel;
1232
+ /** Token threshold to trigger summarization (default: 170000) */
1233
+ tokenThreshold?: number;
1234
+ /** Number of recent messages to keep intact (default: 6) */
1235
+ keepMessages?: number;
1236
+ /** Generation options to pass through */
1237
+ generationOptions?: any;
1238
+ /** Advanced options to pass through */
1239
+ advancedOptions?: any;
1240
+ }
1241
+ /**
1242
+ * Result of summarization check.
1243
+ */
1244
+ interface SummarizationResult {
1245
+ /** Whether summarization was needed */
1246
+ summarized: boolean;
1247
+ /** The processed messages (either original or with summary) */
1248
+ messages: ModelMessage$1[];
1249
+ /** Token count before processing */
1250
+ tokensBefore?: number;
1251
+ /** Token count after processing */
1252
+ tokensAfter?: number;
1253
+ }
1254
+ /**
1255
+ * Estimate total tokens in a messages array.
1256
+ */
1257
+ declare function estimateMessagesTokens(messages: ModelMessage$1[]): number;
1258
+ /**
1259
+ * Summarize older messages when approaching token limits.
1260
+ *
1261
+ * This function checks if the total tokens in the messages exceed the threshold.
1262
+ * If so, it summarizes older messages while keeping recent ones intact.
1263
+ *
1264
+ * @param messages - Array of conversation messages
1265
+ * @param options - Summarization options
1266
+ * @returns Processed messages with optional summary
1267
+ *
1268
+ * @example
1269
+ * ```typescript
1270
+ * import { anthropic } from '@ai-sdk/anthropic';
1271
+ *
1272
+ * const result = await summarizeIfNeeded(messages, {
1273
+ * model: anthropic('claude-haiku-4-5-20251001'),
1274
+ * tokenThreshold: 170000,
1275
+ * keepMessages: 6,
1276
+ * });
1277
+ *
1278
+ * if (result.summarized) {
1279
+ * console.log(`Reduced from ${result.tokensBefore} to ${result.tokensAfter} tokens`);
1280
+ * }
1281
+ * ```
1282
+ */
1283
+ declare function summarizeIfNeeded(messages: ModelMessage$1[], options: SummarizationOptions): Promise<SummarizationResult>;
1284
+ /**
1285
+ * Check if messages need summarization without performing it.
1286
+ */
1287
+ declare function needsSummarization(messages: ModelMessage$1[], tokenThreshold?: number): boolean;
1288
+ //#endregion
1289
+ //#region src/checkpointer/memory-saver.d.ts
1290
+ /**
1291
+ * In-memory checkpoint saver.
1292
+ *
1293
+ * Stores checkpoints in a Map. Data is lost when the process exits.
1294
+ * Useful for testing or single-session applications.
1295
+ *
1296
+ * @example
1297
+ * ```typescript
1298
+ * const saver = new MemorySaver();
1299
+ * const agent = createDeepAgent({
1300
+ * model: anthropic('claude-sonnet-4-20250514'),
1301
+ * checkpointer: saver,
1302
+ * });
1303
+ * ```
1304
+ */
1305
+ declare class MemorySaver implements BaseCheckpointSaver {
1306
+ private checkpoints;
1307
+ private namespace;
1308
+ constructor(options?: CheckpointSaverOptions);
1309
+ private getKey;
1310
+ save(checkpoint: Checkpoint): Promise<void>;
1311
+ load(threadId: string): Promise<Checkpoint | undefined>;
1312
+ list(): Promise<string[]>;
1313
+ delete(threadId: string): Promise<void>;
1314
+ exists(threadId: string): Promise<boolean>;
1315
+ /**
1316
+ * Clear all checkpoints (useful for testing).
1317
+ */
1318
+ clear(): void;
1319
+ /**
1320
+ * Get the number of stored checkpoints.
1321
+ */
1322
+ size(): number;
1323
+ }
1324
+ //#endregion
1325
+ //#region src/checkpointer/file-saver.d.ts
1326
+ /**
1327
+ * Options for FileSaver.
1328
+ */
1329
+ interface FileSaverOptions {
1330
+ /** Directory to store checkpoint files */
1331
+ dir: string;
1332
+ }
1333
+ /**
1334
+ * File-based checkpoint saver.
1335
+ *
1336
+ * Stores checkpoints as JSON files in a directory. Each thread gets
1337
+ * its own file named `{threadId}.json`.
1338
+ *
1339
+ * @example
1340
+ * ```typescript
1341
+ * const saver = new FileSaver({ dir: './.checkpoints' });
1342
+ * const agent = createDeepAgent({
1343
+ * model: anthropic('claude-sonnet-4-20250514'),
1344
+ * checkpointer: saver,
1345
+ * });
1346
+ * ```
1347
+ */
1348
+ declare class FileSaver implements BaseCheckpointSaver {
1349
+ private dir;
1350
+ constructor(options: FileSaverOptions);
1351
+ private getFilePath;
1352
+ save(checkpoint: Checkpoint): Promise<void>;
1353
+ load(threadId: string): Promise<Checkpoint | undefined>;
1354
+ list(): Promise<string[]>;
1355
+ delete(threadId: string): Promise<void>;
1356
+ exists(threadId: string): Promise<boolean>;
1357
+ }
1358
+ //#endregion
1359
+ //#region src/checkpointer/kv-saver.d.ts
1360
+ /**
1361
+ * Options for KeyValueStoreSaver.
1362
+ */
1363
+ interface KeyValueStoreSaverOptions extends CheckpointSaverOptions {
1364
+ /** The KeyValueStore implementation to use */
1365
+ store: KeyValueStore;
1366
+ }
1367
+ /**
1368
+ * Checkpoint saver using KeyValueStore interface.
1369
+ *
1370
+ * This adapter allows using any KeyValueStore implementation (Redis,
1371
+ * database, cloud storage, etc.) for checkpoint storage.
1372
+ *
1373
+ * @example
1374
+ * ```typescript
1375
+ * import { InMemoryStore } from 'deepagentsdk';
1376
+ *
1377
+ * const store = new InMemoryStore();
1378
+ * const saver = new KeyValueStoreSaver({ store });
1379
+ * const agent = createDeepAgent({
1380
+ * model: anthropic('claude-sonnet-4-20250514'),
1381
+ * checkpointer: saver,
1382
+ * });
1383
+ * ```
1384
+ *
1385
+ * @example With Redis
1386
+ * ```typescript
1387
+ * const redisStore = new RedisStore(redisClient); // Your implementation
1388
+ * const saver = new KeyValueStoreSaver({ store: redisStore });
1389
+ * ```
1390
+ */
1391
+ declare class KeyValueStoreSaver implements BaseCheckpointSaver {
1392
+ private store;
1393
+ private namespace;
1394
+ constructor(options: KeyValueStoreSaverOptions);
1395
+ save(checkpoint: Checkpoint): Promise<void>;
1396
+ load(threadId: string): Promise<Checkpoint | undefined>;
1397
+ list(): Promise<string[]>;
1398
+ delete(threadId: string): Promise<void>;
1399
+ exists(threadId: string): Promise<boolean>;
1400
+ }
1401
+ //#endregion
1402
+ //#region src/skills/types.d.ts
1403
+ /**
1404
+ * Metadata extracted from SKILL.md frontmatter.
1405
+ */
1406
+ interface SkillMetadata {
1407
+ /**
1408
+ * Unique skill name (kebab-case, e.g., 'web-research')
1409
+ */
1410
+ name: string;
1411
+ /**
1412
+ * Short description of what the skill does
1413
+ */
1414
+ description: string;
1415
+ /**
1416
+ * Absolute path to the SKILL.md file
1417
+ */
1418
+ path: string;
1419
+ /**
1420
+ * Source of the skill ('user' or 'project')
1421
+ * Project skills override user skills with same name
1422
+ */
1423
+ source: 'user' | 'project';
1424
+ }
1425
+ /**
1426
+ * Options for skill loading
1427
+ */
1428
+ interface SkillLoadOptions {
1429
+ /**
1430
+ * User-level skills directory (e.g., ~/.deepagents/skills/)
1431
+ */
1432
+ userSkillsDir?: string;
1433
+ /**
1434
+ * Project-level skills directory (e.g., ./.deepagents/skills/)
1435
+ */
1436
+ projectSkillsDir?: string;
1437
+ /**
1438
+ * Optional agent ID for loading agent-specific skills.
1439
+ * When provided, looks for skills in ~/.deepagents/{agentId}/skills/
1440
+ * and .deepagents/skills/ (project-level, shared across agents).
1441
+ */
1442
+ agentId?: string;
1443
+ /**
1444
+ * Optional working directory for detecting project root.
1445
+ * Only used when agentId is provided.
1446
+ */
1447
+ workingDirectory?: string;
1448
+ }
1449
+ //#endregion
1450
+ //#region src/skills/load.d.ts
1451
+ /**
1452
+ * Parse YAML frontmatter from a SKILL.md file.
1453
+ *
1454
+ * Expected format:
1455
+ * ---
1456
+ * name: skill-name
1457
+ * description: What this skill does
1458
+ * ---
1459
+ *
1460
+ * # Skill Content
1461
+ * ...
1462
+ */
1463
+ declare function parseSkillMetadata(skillMdPath: string, source: 'user' | 'project'): Promise<SkillMetadata | null>;
1464
+ /**
1465
+ * List all skills from user and project directories.
1466
+ * Project skills override user skills with the same name.
1467
+ *
1468
+ * Supports two modes:
1469
+ * 1. Legacy mode: Use userSkillsDir and projectSkillsDir directly (deprecated)
1470
+ * 2. Agent mode: Use agentId to load from ~/.deepagents/{agentId}/skills/ and .deepagents/skills/
1471
+ */
1472
+ declare function listSkills(options: SkillLoadOptions): Promise<SkillMetadata[]>;
1473
+ //#endregion
1474
+ //#region src/middleware/agent-memory.d.ts
1475
+ /**
1476
+ * Configuration options for agent memory middleware.
1477
+ */
1478
+ interface AgentMemoryOptions$1 {
1479
+ /**
1480
+ * Unique identifier for the agent (e.g., "code-architect", "research-agent").
1481
+ * Used to locate agent-specific memory at ~/.deepagents/{agentId}/agent.md
1482
+ */
1483
+ agentId: string;
1484
+ /**
1485
+ * Optional working directory for project-level memory detection.
1486
+ * Defaults to process.cwd().
1487
+ */
1488
+ workingDirectory?: string;
1489
+ /**
1490
+ * Optional custom path for user-level .deepagents directory.
1491
+ * Defaults to os.homedir() + '/.deepagents'.
1492
+ *
1493
+ * Useful for testing or custom deployment environments.
1494
+ *
1495
+ * @example
1496
+ * ```typescript
1497
+ * userDeepagentsDir: '/custom/path/.deepagents'
1498
+ * // Will look for memory at: /custom/path/.deepagents/{agentId}/agent.md
1499
+ * ```
1500
+ */
1501
+ userDeepagentsDir?: string;
1502
+ /**
1503
+ * Optional callback to request user approval for creating project-level .deepagents/ directory.
1504
+ * If not provided, project memory will be silently skipped if directory doesn't exist.
1505
+ *
1506
+ * @param projectPath - Absolute path to the detected git root
1507
+ * @returns Promise<boolean> - true if user approves, false otherwise
1508
+ */
1509
+ requestProjectApproval?: (projectPath: string) => Promise<boolean>;
1510
+ }
1511
+ /**
1512
+ * Create agent memory middleware for AI SDK v6.
1513
+ *
1514
+ * This middleware loads agent memory from:
1515
+ * 1. User-level: ~/.deepagents/{agentId}/agent.md (personality, preferences)
1516
+ * 2. Project-level: [git-root]/.deepagents/agent.md (project-specific context)
1517
+ * 3. Additional files: Any other .md files in the user-level directory
1518
+ *
1519
+ * The memory is injected into the system prompt before each model call, teaching
1520
+ * the agent when and how to read/update its own memory using filesystem tools.
1521
+ *
1522
+ * @param options - Configuration for agent memory
1523
+ * @param options.agentId - Unique identifier for the agent (e.g., "code-architect")
1524
+ * @param options.workingDirectory - Optional working directory for project detection (defaults to process.cwd())
1525
+ * @param options.userDeepagentsDir - Optional custom path for user-level .deepagents directory (defaults to ~/.deepagents)
1526
+ * @param options.requestProjectApproval - Optional callback to request approval before creating project .deepagents/ directory
1527
+ * @returns AI SDK v6 middleware
1528
+ *
1529
+ * @example Basic usage
1530
+ * ```typescript
1531
+ * import { createDeepAgent } from 'deepagentsdk';
1532
+ * import { createAgentMemoryMiddleware } from 'deepagentsdk/middleware';
1533
+ * import { anthropic } from '@ai-sdk/anthropic';
1534
+ *
1535
+ * const memoryMiddleware = createAgentMemoryMiddleware({
1536
+ * agentId: 'code-architect',
1537
+ * });
1538
+ *
1539
+ * const agent = createDeepAgent({
1540
+ * model: anthropic('claude-sonnet-4-5'),
1541
+ * middleware: memoryMiddleware,
1542
+ * });
1543
+ * ```
1544
+ *
1545
+ * @example With project approval callback
1546
+ * ```typescript
1547
+ * const memoryMiddleware = createAgentMemoryMiddleware({
1548
+ * agentId: 'code-architect',
1549
+ * requestProjectApproval: async (projectPath) => {
1550
+ * console.log(`Create .deepagents/ in ${projectPath}? (y/n)`);
1551
+ * // ... get user input
1552
+ * return userSaidYes;
1553
+ * }
1554
+ * });
1555
+ * ```
1556
+ *
1557
+ * @example With custom user directory path
1558
+ * ```typescript
1559
+ * const memoryMiddleware = createAgentMemoryMiddleware({
1560
+ * agentId: 'code-architect',
1561
+ * userDeepagentsDir: '/custom/path/.deepagents',
1562
+ * // Memory will be loaded from:
1563
+ * // - /custom/path/.deepagents/code-architect/agent.md
1564
+ * // - [git-root]/.deepagents/agent.md (project-level)
1565
+ * });
1566
+ * ```
1567
+ */
1568
+ declare function createAgentMemoryMiddleware(options: AgentMemoryOptions$1): LanguageModelMiddleware$1;
1569
+ //#endregion
1570
+ //#region src/utils/project-detection.d.ts
1571
+ /**
1572
+ * Find the git root by walking up the directory tree.
1573
+ * Returns null if no .git directory is found.
1574
+ *
1575
+ * @param startPath - Starting directory (defaults to process.cwd())
1576
+ * @returns Absolute path to git root, or null if not in a git repository
1577
+ */
1578
+ declare function findGitRoot(startPath?: string): Promise<string | null>;
1579
+ //#endregion
1580
+ export { type AgentMemoryOptions, type ApprovalRequestedEvent, type ApprovalResponseEvent, BASE_PROMPT, type BackendFactory, type BackendProtocol, BaseCheckpointSaver, BaseSandbox, Checkpoint, type CheckpointLoadedEvent, type CheckpointSavedEvent, CheckpointSaverOptions, CompositeBackend, type CreateDeepAgentParams, type CreateExecuteToolOptions, type CreateSubagentToolOptions, type CreateWebToolsOptions, DEFAULT_EVICTION_TOKEN_LIMIT, DEFAULT_GENERAL_PURPOSE_DESCRIPTION, DEFAULT_KEEP_MESSAGES, DEFAULT_SUBAGENT_PROMPT, DEFAULT_SUMMARIZATION_THRESHOLD, DeepAgent, type DeepAgentEvent, type DeepAgentState, type DoneEvent, type DynamicApprovalConfig, EXECUTE_SYSTEM_PROMPT, type EditResult, type ErrorEvent, type EventCallback, type EvictOptions, type EvictResult, type ExecuteFinishEvent, type ExecuteResponse, type ExecuteStartEvent, FILESYSTEM_SYSTEM_PROMPT, type FetchUrlFinishEvent, type FetchUrlStartEvent, type FileData, type FileEditedEvent, type FileInfo, FileSaver, FileSaverOptions, type FileWriteStartEvent, type FileWrittenEvent, FilesystemBackend, type GrepMatch, type HttpRequestFinishEvent, type HttpRequestStartEvent, InMemoryStore, InterruptData, type InterruptOnConfig, type KeyValueStore, KeyValueStoreSaver, KeyValueStoreSaverOptions, type LanguageModelMiddleware, LocalSandbox, type LocalSandboxOptions, MemorySaver, PersistentBackend, type PersistentBackendOptions, ResumeDecision, ResumeOptions, type SandboxBackendProtocol, type SkillLoadOptions, type SkillMetadata, StateBackend, type StepFinishEvent, type StepStartEvent, type StructuredAgentResult, type SubAgent, type SubagentFinishEvent, type SubagentStartEvent, type SummarizationConfig, type SummarizationOptions, type SummarizationResult, TASK_SYSTEM_PROMPT, TODO_SYSTEM_PROMPT, type TextEvent, type TodoItem, type TodosChangedEvent, type ToolCallEvent, ToolLoopAgent, type ToolResultEvent, type WebSearchFinishEvent, type WebSearchStartEvent, type WriteResult, createAgentMemoryMiddleware, createDeepAgent, createEditFileTool, createExecuteTool, createExecuteToolFromBackend, createFetchUrlTool, createFilesystemTools, createGlobTool, createGrepTool, createHttpRequestTool, createLsTool, createReadFileTool, createSubagentTool, createTodosTool, createToolResultWrapper, createWebSearchTool, createWebTools, createWriteFileTool, edit_file, estimateMessagesTokens, estimateTokens, eventHasStructuredOutput, evictToolResult, execute, fetch_url, findGitRoot, getEventOutput, getStructuredOutput, getTaskToolDescription, glob, grep, hasDanglingToolCalls, hasStructuredOutput, hasToolCall, htmlToMarkdown, http_request, isSandboxBackend, listSkills, ls, needsSummarization, parseSkillMetadata, patchToolCalls, read_file, shouldEvict, stepCountIs, summarizeIfNeeded, web_search, wrapLanguageModel, write_file, write_todos };
1581
+ //# sourceMappingURL=index.d.cts.map