deepagentsdk 0.12.0 → 0.13.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 (37) hide show
  1. package/dist/adapters/elements/index.cjs +244 -294
  2. package/dist/adapters/elements/index.cjs.map +1 -1
  3. package/dist/adapters/elements/index.d.cts +84 -174
  4. package/dist/adapters/elements/index.d.mts +84 -174
  5. package/dist/adapters/elements/index.mjs +238 -290
  6. package/dist/adapters/elements/index.mjs.map +1 -1
  7. package/dist/{types-4g9UvXal.d.mts → agent-BDM-PIu8.d.mts} +374 -25
  8. package/dist/{types-IulnvhFg.d.cts → agent-DToEVxs-.d.cts} +374 -25
  9. package/dist/{chunk-CbDLau6x.cjs → chunk-C5azi7Hr.cjs} +33 -0
  10. package/dist/cli/index.cjs +12 -12
  11. package/dist/cli/index.cjs.map +1 -1
  12. package/dist/cli/index.mjs +2 -2
  13. package/dist/cli/index.mjs.map +1 -1
  14. package/dist/{agent-Cuks-Idh.cjs → file-saver-BYPKakT4.cjs} +799 -205
  15. package/dist/file-saver-BYPKakT4.cjs.map +1 -0
  16. package/dist/{agent-CrH-He58.mjs → file-saver-Hj5so3dV.mjs} +793 -199
  17. package/dist/file-saver-Hj5so3dV.mjs.map +1 -0
  18. package/dist/index.cjs +83 -73
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +5 -353
  21. package/dist/index.d.mts +5 -353
  22. package/dist/index.mjs +13 -3
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/{load-B6CA5js_.mjs → load-BBYEnMwz.mjs} +1 -1
  25. package/dist/{load-B6CA5js_.mjs.map → load-BBYEnMwz.mjs.map} +1 -1
  26. package/dist/{load-94gjHorc.mjs → load-BDxe6Cet.mjs} +1 -1
  27. package/dist/{load-79a2H4m0.cjs → load-BrRAKlO6.cjs} +2 -2
  28. package/dist/{load-79a2H4m0.cjs.map → load-BrRAKlO6.cjs.map} +1 -1
  29. package/dist/load-DqllBbDc.cjs +4 -0
  30. package/package.json +1 -1
  31. package/dist/agent-CrH-He58.mjs.map +0 -1
  32. package/dist/agent-Cuks-Idh.cjs.map +0 -1
  33. package/dist/file-saver-BJCqMIb5.mjs +0 -655
  34. package/dist/file-saver-BJCqMIb5.mjs.map +0 -1
  35. package/dist/file-saver-C6O2LAvg.cjs +0 -679
  36. package/dist/file-saver-C6O2LAvg.cjs.map +0 -1
  37. package/dist/load-C2qVmZMp.cjs +0 -3
@@ -1,5 +1,5 @@
1
- import * as ai3 from "ai";
2
- import { LanguageModel, LanguageModel as LanguageModel$2, LanguageModelMiddleware, ModelMessage, ModelMessage as ModelMessage$1, StopCondition, ToolLoopAgentSettings, ToolSet } from "ai";
1
+ import * as ai2 from "ai";
2
+ import { LanguageModel, LanguageModel as LanguageModel$2, LanguageModelMiddleware, ModelMessage, ModelMessage as ModelMessage$1, StopCondition, ToolLoopAgent, ToolLoopAgentSettings, ToolSet } from "ai";
3
3
  import { z } from "zod";
4
4
 
5
5
  //#region src/checkpointer/types.d.ts
@@ -256,7 +256,7 @@ declare function createWebSearchTool(state: DeepAgentState, options: {
256
256
  onEvent?: EventCallback;
257
257
  toolResultEvictionLimit?: number;
258
258
  tavilyApiKey: string;
259
- }): ai3.Tool<{
259
+ }): ai2.Tool<{
260
260
  query: string;
261
261
  max_results: number;
262
262
  topic: "general" | "news" | "finance";
@@ -270,7 +270,7 @@ declare function createHttpRequestTool(state: DeepAgentState, options: {
270
270
  onEvent?: EventCallback;
271
271
  toolResultEvictionLimit?: number;
272
272
  defaultTimeout: number;
273
- }): ai3.Tool<{
273
+ }): ai2.Tool<{
274
274
  timeout: number;
275
275
  url: string;
276
276
  method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
@@ -286,7 +286,7 @@ declare function createFetchUrlTool(state: DeepAgentState, options: {
286
286
  onEvent?: EventCallback;
287
287
  toolResultEvictionLimit?: number;
288
288
  defaultTimeout: number;
289
- }): ai3.Tool<{
289
+ }): ai2.Tool<{
290
290
  timeout: number;
291
291
  url: string;
292
292
  extract_article: boolean;
@@ -323,13 +323,13 @@ declare const fetch_url: typeof createFetchUrlTool;
323
323
  /**
324
324
  * Create the ls tool.
325
325
  */
326
- declare function createLsTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, onEvent?: EventCallback): ai3.Tool<{
326
+ declare function createLsTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, onEvent?: EventCallback): ai2.Tool<{
327
327
  path: string;
328
328
  }, string>;
329
329
  /**
330
330
  * Create the read_file tool.
331
331
  */
332
- declare function createReadFileTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, evictionLimit?: number, onEvent?: EventCallback): ai3.Tool<{
332
+ declare function createReadFileTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, evictionLimit?: number, onEvent?: EventCallback): ai2.Tool<{
333
333
  file_path: string;
334
334
  offset: number;
335
335
  limit: number;
@@ -337,14 +337,14 @@ declare function createReadFileTool(state: DeepAgentState, backend: BackendProto
337
337
  /**
338
338
  * Create the write_file tool.
339
339
  */
340
- declare function createWriteFileTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, onEvent?: EventCallback): ai3.Tool<{
341
- content: string;
340
+ declare function createWriteFileTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, onEvent?: EventCallback): ai2.Tool<{
342
341
  file_path: string;
342
+ content: string;
343
343
  }, string>;
344
344
  /**
345
345
  * Create the edit_file tool.
346
346
  */
347
- declare function createEditFileTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, onEvent?: EventCallback): ai3.Tool<{
347
+ declare function createEditFileTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, onEvent?: EventCallback): ai2.Tool<{
348
348
  file_path: string;
349
349
  old_string: string;
350
350
  new_string: string;
@@ -353,14 +353,14 @@ declare function createEditFileTool(state: DeepAgentState, backend: BackendProto
353
353
  /**
354
354
  * Create the glob tool.
355
355
  */
356
- declare function createGlobTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, onEvent?: EventCallback): ai3.Tool<{
356
+ declare function createGlobTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, onEvent?: EventCallback): ai2.Tool<{
357
357
  path: string;
358
358
  pattern: string;
359
359
  }, string>;
360
360
  /**
361
361
  * Create the grep tool.
362
362
  */
363
- declare function createGrepTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, evictionLimit?: number, onEvent?: EventCallback): ai3.Tool<{
363
+ declare function createGrepTool(state: DeepAgentState, backend: BackendProtocol | BackendFactory, evictionLimit?: number, onEvent?: EventCallback): ai2.Tool<{
364
364
  path: string;
365
365
  pattern: string;
366
366
  glob?: string | null | undefined;
@@ -383,29 +383,29 @@ interface CreateFilesystemToolsOptions {
383
383
  * @param onEvent - Optional callback for emitting events (deprecated, use options)
384
384
  */
385
385
  declare function createFilesystemTools(state: DeepAgentState, backendOrOptions?: BackendProtocol | BackendFactory | CreateFilesystemToolsOptions, onEvent?: EventCallback): {
386
- ls: ai3.Tool<{
386
+ ls: ai2.Tool<{
387
387
  path: string;
388
388
  }, string>;
389
- read_file: ai3.Tool<{
389
+ read_file: ai2.Tool<{
390
390
  file_path: string;
391
391
  offset: number;
392
392
  limit: number;
393
393
  }, string>;
394
- write_file: ai3.Tool<{
395
- content: string;
394
+ write_file: ai2.Tool<{
396
395
  file_path: string;
396
+ content: string;
397
397
  }, string>;
398
- edit_file: ai3.Tool<{
398
+ edit_file: ai2.Tool<{
399
399
  file_path: string;
400
400
  old_string: string;
401
401
  new_string: string;
402
402
  replace_all: boolean;
403
403
  }, string>;
404
- glob: ai3.Tool<{
404
+ glob: ai2.Tool<{
405
405
  path: string;
406
406
  pattern: string;
407
407
  }, string>;
408
- grep: ai3.Tool<{
408
+ grep: ai2.Tool<{
409
409
  path: string;
410
410
  pattern: string;
411
411
  glob?: string | null | undefined;
@@ -428,7 +428,7 @@ declare const grep: typeof createGrepTool;
428
428
  * @param state - The shared agent state
429
429
  * @param onEvent - Optional callback for emitting events
430
430
  */
431
- declare function createTodosTool(state: DeepAgentState, onEvent?: EventCallback): ai3.Tool<{
431
+ declare function createTodosTool(state: DeepAgentState, onEvent?: EventCallback): ai2.Tool<{
432
432
  todos: {
433
433
  status: "pending" | "in_progress" | "completed" | "cancelled";
434
434
  id: string;
@@ -489,7 +489,7 @@ interface CreateExecuteToolOptions {
489
489
  * });
490
490
  * ```
491
491
  */
492
- declare function createExecuteTool(options: CreateExecuteToolOptions): ai3.Tool<{
492
+ declare function createExecuteTool(options: CreateExecuteToolOptions): ai2.Tool<{
493
493
  command: string;
494
494
  }, string>;
495
495
  /**
@@ -507,7 +507,7 @@ declare function createExecuteTool(options: CreateExecuteToolOptions): ai3.Tool<
507
507
  * };
508
508
  * ```
509
509
  */
510
- declare function createExecuteToolFromBackend(backend: SandboxBackendProtocol): ai3.Tool<{
510
+ declare function createExecuteToolFromBackend(backend: SandboxBackendProtocol): ai2.Tool<{
511
511
  command: string;
512
512
  }, string>;
513
513
  /**
@@ -641,7 +641,7 @@ interface PrepareStepArgs {
641
641
  stepNumber: number;
642
642
  steps: unknown[];
643
643
  model: LanguageModel$2;
644
- messages: ai3.ModelMessage[];
644
+ messages: ai2.ModelMessage[];
645
645
  experimental_context?: unknown;
646
646
  }
647
647
  /**
@@ -1147,5 +1147,354 @@ declare function getStructuredOutput<T>(result: any): T | undefined;
1147
1147
  */
1148
1148
  declare function getEventOutput<T>(event: any): T | undefined;
1149
1149
  //#endregion
1150
- export { createReadFileTool as $, TodosChangedEvent as A, InterruptData as At, InterruptOnConfig as B, HttpRequestStartEvent as C, GrepMatch as Ct, SubagentFinishEvent as D, BaseCheckpointSaver as Dt, StreamWithEventsOptions as E, isSandboxBackend as Et, AgentMemoryOptions as F, execute as G, CreateExecuteToolOptions as H, CreateDeepAgentParams as I, createEditFileTool as J, createTodosTool as K, SummarizationConfig as L, ToolResultEvent as M, ResumeOptions as Mt, WebSearchFinishEvent as N, SubagentStartEvent as O, Checkpoint as Ot, WebSearchStartEvent as P, createLsTool as Q, TodoItem as R, HttpRequestFinishEvent as S, FileInfo as St, StepStartEvent as T, WriteResult as Tt, createExecuteTool as U, SubAgent as V, createExecuteToolFromBackend as W, createGlobTool as X, createFilesystemTools as Y, createGrepTool as Z, FetchUrlFinishEvent as _, BackendProtocol as _t, getStructuredOutput as a, read_file as at, FileWriteStartEvent as b, ExecuteResponse as bt, ApprovalResponseEvent as c, createFetchUrlTool as ct, DeepAgentEvent as d, createWebTools as dt, createWriteFileTool as et, DoneEvent as f, fetch_url as ft, ExecuteStartEvent as g, BackendFactory as gt, ExecuteFinishEvent as h, web_search as ht, getEventOutput as i, ls as it, ToolCallEvent as j, ResumeDecision as jt, TextEvent as k, CheckpointSaverOptions as kt, CheckpointLoadedEvent as l, createHttpRequestTool as lt, EventCallback as m, http_request as mt, StructuredAgentResult as n, glob as nt, hasStructuredOutput as o, write_file as ot, ErrorEvent as p, htmlToMarkdown as pt, write_todos as q, eventHasStructuredOutput as r, grep as rt, ApprovalRequestedEvent as s, CreateWebToolsOptions as st, ModelMessage$1 as t, edit_file as tt, CheckpointSavedEvent as u, createWebSearchTool as ut, FetchUrlStartEvent as v, DeepAgentState as vt, StepFinishEvent as w, SandboxBackendProtocol as wt, FileWrittenEvent as x, FileData as xt, FileEditedEvent as y, EditResult as yt, DynamicApprovalConfig as z };
1151
- //# sourceMappingURL=types-4g9UvXal.d.mts.map
1150
+ //#region src/agent.d.ts
1151
+ /**
1152
+ * Deep Agent wrapper class that provides generate() and stream() methods.
1153
+ * Uses ToolLoopAgent from AI SDK v6 for the agent loop.
1154
+ */
1155
+ declare class DeepAgent {
1156
+ private model;
1157
+ private systemPrompt;
1158
+ private userTools;
1159
+ private maxSteps;
1160
+ private backend;
1161
+ private subagentOptions;
1162
+ private toolResultEvictionLimit?;
1163
+ private enablePromptCaching;
1164
+ private summarizationConfig?;
1165
+ private hasSandboxBackend;
1166
+ private interruptOn?;
1167
+ private checkpointer?;
1168
+ private skillsMetadata;
1169
+ private outputConfig?;
1170
+ private loopControl?;
1171
+ private generationOptions?;
1172
+ private advancedOptions?;
1173
+ constructor(params: CreateDeepAgentParams);
1174
+ /**
1175
+ * Create core tools (todos and filesystem).
1176
+ * @private
1177
+ */
1178
+ private createCoreTools;
1179
+ /**
1180
+ * Create web tools if TAVILY_API_KEY is available.
1181
+ * Uses dynamic import to avoid bundling Node.js dependencies in client builds.
1182
+ * @private
1183
+ */
1184
+ private createWebToolSet;
1185
+ /**
1186
+ * Create execute tool if backend is a sandbox.
1187
+ * @private
1188
+ */
1189
+ private createExecuteToolSet;
1190
+ /**
1191
+ * Create subagent tool if configured.
1192
+ * @private
1193
+ */
1194
+ private createSubagentToolSet;
1195
+ /**
1196
+ * Create all tools for the agent, combining core, web, execute, and subagent tools.
1197
+ * @private
1198
+ */
1199
+ private createTools;
1200
+ /**
1201
+ * Build stop conditions with maxSteps safety limit.
1202
+ * Combines user-provided stop conditions with the maxSteps limit.
1203
+ */
1204
+ private buildStopConditions;
1205
+ /**
1206
+ * Build agent settings by combining passthrough options with defaults.
1207
+ */
1208
+ private buildAgentSettings;
1209
+ /**
1210
+ * Create a ToolLoopAgent for a given state.
1211
+ * @param state - The shared agent state
1212
+ * @param maxSteps - Optional max steps override
1213
+ * @param onEvent - Optional callback for emitting events
1214
+ */
1215
+ private createAgent;
1216
+ /**
1217
+ * Load skills from directory asynchronously.
1218
+ * Supports both legacy skillsDir and new agentId modes.
1219
+ */
1220
+ private loadSkills;
1221
+ /**
1222
+ * Generate a response (non-streaming).
1223
+ */
1224
+ generate(options: {
1225
+ prompt: string;
1226
+ maxSteps?: number;
1227
+ }): Promise<ai2.GenerateTextResult<{}, never> & {
1228
+ state: DeepAgentState;
1229
+ }>;
1230
+ /**
1231
+ * Stream a response.
1232
+ */
1233
+ stream(options: {
1234
+ prompt: string;
1235
+ maxSteps?: number;
1236
+ }): Promise<ai2.StreamTextResult<{}, never> & {
1237
+ state: DeepAgentState;
1238
+ }>;
1239
+ /**
1240
+ * Generate with an existing state (for continuing conversations).
1241
+ */
1242
+ generateWithState(options: {
1243
+ prompt: string;
1244
+ state: DeepAgentState;
1245
+ maxSteps?: number;
1246
+ }): Promise<ai2.GenerateTextResult<{}, never> & {
1247
+ state: DeepAgentState;
1248
+ }>;
1249
+ /**
1250
+ * Get the underlying ToolLoopAgent for advanced usage.
1251
+ * This allows using AI SDK's createAgentUIStream and other utilities.
1252
+ */
1253
+ getAgent(state?: DeepAgentState): ToolLoopAgent<never, {}, never>;
1254
+ /**
1255
+ * Stream a response with real-time events.
1256
+ * This is an async generator that yields DeepAgentEvent objects.
1257
+ *
1258
+ * Supports conversation history via the `messages` option for multi-turn conversations.
1259
+ *
1260
+ * @example
1261
+ * ```typescript
1262
+ * // Single turn
1263
+ * for await (const event of agent.streamWithEvents({ prompt: "..." })) {
1264
+ * switch (event.type) {
1265
+ * case 'text':
1266
+ * process.stdout.write(event.text);
1267
+ * break;
1268
+ * case 'done':
1269
+ * // event.messages contains the updated conversation history
1270
+ * console.log('Messages:', event.messages);
1271
+ * break;
1272
+ * }
1273
+ * }
1274
+ *
1275
+ * // Multi-turn conversation
1276
+ * let messages = [];
1277
+ * for await (const event of agent.streamWithEvents({ prompt: "Hello", messages })) {
1278
+ * if (event.type === 'done') {
1279
+ * messages = event.messages; // Save for next turn
1280
+ * }
1281
+ * }
1282
+ * for await (const event of agent.streamWithEvents({ prompt: "Follow up", messages })) {
1283
+ * // Agent now has context from previous turn
1284
+ * }
1285
+ * ```
1286
+ */
1287
+ /**
1288
+ * Compose user's onStepFinish callback with DeepAgent's internal checkpointing logic.
1289
+ * User callback executes first, errors are caught to prevent breaking checkpointing.
1290
+ */
1291
+ private composeOnStepFinish;
1292
+ /**
1293
+ * Compose user's onFinish callback with DeepAgent's internal cleanup logic.
1294
+ */
1295
+ private composeOnFinish;
1296
+ /**
1297
+ * Compose user's prepareStep callback with DeepAgent's internal step preparation.
1298
+ * Returns a function typed as `any` to avoid AI SDK's strict toolName inference.
1299
+ */
1300
+ private composePrepareStep;
1301
+ /**
1302
+ * Build streamText options with callbacks for step tracking and checkpointing.
1303
+ *
1304
+ * @private
1305
+ */
1306
+ private buildStreamTextOptions;
1307
+ /**
1308
+ * Build message array from options, handling validation and priority logic.
1309
+ * Priority: explicit messages > prompt > checkpoint history.
1310
+ *
1311
+ * @private
1312
+ */
1313
+ private buildMessageArray;
1314
+ /**
1315
+ * Load checkpoint context if threadId is provided.
1316
+ * Handles checkpoint restoration and resume from interrupt.
1317
+ *
1318
+ * @private
1319
+ */
1320
+ private loadCheckpointContext;
1321
+ streamWithEvents(options: StreamWithEventsOptions): AsyncGenerator<DeepAgentEvent, void, unknown>;
1322
+ /**
1323
+ * Stream with a simple callback interface.
1324
+ * This is a convenience wrapper around streamWithEvents.
1325
+ */
1326
+ streamWithCallback(options: StreamWithEventsOptions, onEvent: EventCallback): Promise<{
1327
+ state: DeepAgentState;
1328
+ text?: string;
1329
+ messages?: ModelMessage$1[];
1330
+ }>;
1331
+ }
1332
+ /**
1333
+ * Create a Deep Agent with planning, filesystem, and subagent capabilities.
1334
+ *
1335
+ * @param params - Configuration object for the Deep Agent
1336
+ * @param params.model - **Required.** AI SDK LanguageModel instance (e.g., `anthropic('claude-sonnet-4-20250514')`, `openai('gpt-4o')`)
1337
+ * @param params.systemPrompt - Optional custom system prompt for the agent
1338
+ * @param params.tools - Optional custom tools to add to the agent (AI SDK ToolSet)
1339
+ * @param params.subagents - Optional array of specialized subagent configurations for task delegation
1340
+ * @param params.backend - Optional backend for filesystem operations (default: StateBackend for in-memory storage)
1341
+ * @param params.maxSteps - Optional maximum number of steps for the agent loop (default: 100)
1342
+ * @param params.includeGeneralPurposeAgent - Optional flag to include general-purpose subagent (default: true)
1343
+ * @param params.toolResultEvictionLimit - Optional token limit before evicting large tool results to filesystem (default: disabled)
1344
+ * @param params.enablePromptCaching - Optional flag to enable prompt caching for improved performance (Anthropic only, default: false)
1345
+ * @param params.summarization - Optional summarization configuration for automatic conversation summarization
1346
+ * @returns A configured DeepAgent instance
1347
+ *
1348
+ * @see {@link CreateDeepAgentParams} for detailed parameter types
1349
+ *
1350
+ * @example Basic usage
1351
+ * ```typescript
1352
+ * import { createDeepAgent } from 'deepagentsdk';
1353
+ * import { anthropic } from '@ai-sdk/anthropic';
1354
+ *
1355
+ * const agent = createDeepAgent({
1356
+ * model: anthropic('claude-sonnet-4-20250514'),
1357
+ * systemPrompt: 'You are a research assistant...',
1358
+ * });
1359
+ *
1360
+ * const result = await agent.generate({
1361
+ * prompt: 'Research the topic and write a report',
1362
+ * });
1363
+ * ```
1364
+ *
1365
+ * @example With custom tools
1366
+ * ```typescript
1367
+ * import { tool } from 'ai';
1368
+ * import { z } from 'zod';
1369
+ *
1370
+ * const customTool = tool({
1371
+ * description: 'Get current time',
1372
+ * inputSchema: z.object({}),
1373
+ * execute: async () => new Date().toISOString(),
1374
+ * });
1375
+ *
1376
+ * const agent = createDeepAgent({
1377
+ * model: anthropic('claude-sonnet-4-20250514'),
1378
+ * tools: { get_time: customTool },
1379
+ * });
1380
+ * ```
1381
+ *
1382
+ * @example With subagents
1383
+ * ```typescript
1384
+ * const agent = createDeepAgent({
1385
+ * model: anthropic('claude-sonnet-4-20250514'),
1386
+ * subagents: [{
1387
+ * name: 'research-agent',
1388
+ * description: 'Specialized for research tasks',
1389
+ * systemPrompt: 'You are a research specialist...',
1390
+ * }],
1391
+ * });
1392
+ * ```
1393
+ *
1394
+ * @example With StateBackend (default, explicit)
1395
+ * ```typescript
1396
+ * import { StateBackend } from 'deepagentsdk';
1397
+ *
1398
+ * const state = { todos: [], files: {} };
1399
+ * const agent = createDeepAgent({
1400
+ * model: anthropic('claude-sonnet-4-20250514'),
1401
+ * backend: new StateBackend(state), // Ephemeral in-memory storage
1402
+ * });
1403
+ * ```
1404
+ *
1405
+ * @example With FilesystemBackend
1406
+ * ```typescript
1407
+ * import { FilesystemBackend } from 'deepagentsdk';
1408
+ *
1409
+ * const agent = createDeepAgent({
1410
+ * model: anthropic('claude-sonnet-4-20250514'),
1411
+ * backend: new FilesystemBackend({ rootDir: './workspace' }), // Persist to disk
1412
+ * });
1413
+ * ```
1414
+ *
1415
+ * @example With PersistentBackend
1416
+ * ```typescript
1417
+ * import { PersistentBackend, InMemoryStore } from 'deepagentsdk';
1418
+ *
1419
+ * const store = new InMemoryStore();
1420
+ * const agent = createDeepAgent({
1421
+ * model: anthropic('claude-sonnet-4-20250514'),
1422
+ * backend: new PersistentBackend({ store, namespace: 'project-1' }), // Cross-session persistence
1423
+ * });
1424
+ * ```
1425
+ *
1426
+ * @example With CompositeBackend
1427
+ * ```typescript
1428
+ * import { CompositeBackend, FilesystemBackend, StateBackend } from 'deepagentsdk';
1429
+ *
1430
+ * const state = { todos: [], files: {} };
1431
+ * const agent = createDeepAgent({
1432
+ * model: anthropic('claude-sonnet-4-20250514'),
1433
+ * backend: new CompositeBackend(
1434
+ * new StateBackend(state),
1435
+ * { '/persistent/': new FilesystemBackend({ rootDir: './persistent' }) }
1436
+ * ), // Route files by path prefix
1437
+ * });
1438
+ * ```
1439
+ *
1440
+ * @example With middleware for logging and caching
1441
+ * ```typescript
1442
+ * import { createDeepAgent } from 'deepagentsdk';
1443
+ * import { anthropic } from '@ai-sdk/anthropic';
1444
+ *
1445
+ * const loggingMiddleware = {
1446
+ * wrapGenerate: async ({ doGenerate, params }) => {
1447
+ * console.log('Model called with:', params.prompt);
1448
+ * const result = await doGenerate();
1449
+ * console.log('Model returned:', result.text);
1450
+ * return result;
1451
+ * },
1452
+ * };
1453
+ *
1454
+ * const agent = createDeepAgent({
1455
+ * model: anthropic('claude-sonnet-4-20250514'),
1456
+ * middleware: [loggingMiddleware],
1457
+ * });
1458
+ * ```
1459
+ *
1460
+ * @example With middleware factory for context access
1461
+ * ```typescript
1462
+ * import { FilesystemBackend } from 'deepagentsdk';
1463
+ *
1464
+ * function createContextMiddleware(backend: BackendProtocol) {
1465
+ * return {
1466
+ * wrapGenerate: async ({ doGenerate }) => {
1467
+ * const state = await backend.read('state');
1468
+ * const result = await doGenerate();
1469
+ * await backend.write('state', { ...state, lastCall: result });
1470
+ * return result;
1471
+ * },
1472
+ * };
1473
+ * }
1474
+ *
1475
+ * const backend = new FilesystemBackend({ rootDir: './workspace' });
1476
+ * const agent = createDeepAgent({
1477
+ * model: anthropic('claude-sonnet-4-20250514'),
1478
+ * backend,
1479
+ * middleware: createContextMiddleware(backend),
1480
+ * });
1481
+ * ```
1482
+ *
1483
+ * @example With performance optimizations
1484
+ * ```typescript
1485
+ * const agent = createDeepAgent({
1486
+ * model: anthropic('claude-sonnet-4-20250514'),
1487
+ * enablePromptCaching: true,
1488
+ * toolResultEvictionLimit: 20000,
1489
+ * summarization: {
1490
+ * enabled: true,
1491
+ * tokenThreshold: 170000,
1492
+ * keepMessages: 6,
1493
+ * },
1494
+ * });
1495
+ * ```
1496
+ */
1497
+ declare function createDeepAgent(params: CreateDeepAgentParams): DeepAgent;
1498
+ //#endregion
1499
+ export { createLsTool as $, TextEvent as A, CheckpointSaverOptions as At, DynamicApprovalConfig as B, FileWrittenEvent as C, FileInfo as Ct, StepStartEvent as D, isSandboxBackend as Dt, StepFinishEvent as E, WriteResult as Et, WebSearchStartEvent as F, createExecuteToolFromBackend as G, SubAgent as H, AgentMemoryOptions as I, write_todos as J, execute as K, CreateDeepAgentParams as L, ToolCallEvent as M, ResumeDecision as Mt, ToolResultEvent as N, ResumeOptions as Nt, SubagentFinishEvent as O, BaseCheckpointSaver as Ot, WebSearchFinishEvent as P, createGrepTool as Q, SummarizationConfig as R, FileWriteStartEvent as S, FileData as St, HttpRequestStartEvent as T, SandboxBackendProtocol as Tt, CreateExecuteToolOptions as U, InterruptOnConfig as V, createExecuteTool as W, createFilesystemTools as X, createEditFileTool as Y, createGlobTool as Z, ExecuteFinishEvent as _, BackendFactory as _t, eventHasStructuredOutput as a, ls as at, FetchUrlStartEvent as b, EditResult as bt, hasStructuredOutput as c, CreateWebToolsOptions as ct, CheckpointLoadedEvent as d, createWebSearchTool as dt, createReadFileTool as et, CheckpointSavedEvent as f, createWebTools as ft, EventCallback as g, web_search as gt, ErrorEvent as h, http_request as ht, StructuredAgentResult as i, grep as it, TodosChangedEvent as j, InterruptData as jt, SubagentStartEvent as k, Checkpoint as kt, ApprovalRequestedEvent as l, createFetchUrlTool as lt, DoneEvent as m, htmlToMarkdown as mt, createDeepAgent as n, edit_file as nt, getEventOutput as o, read_file as ot, DeepAgentEvent as p, fetch_url as pt, createTodosTool as q, ModelMessage$1 as r, glob as rt, getStructuredOutput as s, write_file as st, DeepAgent as t, createWriteFileTool as tt, ApprovalResponseEvent as u, createHttpRequestTool as ut, ExecuteStartEvent as v, BackendProtocol as vt, HttpRequestFinishEvent as w, GrepMatch as wt, FileEditedEvent as x, ExecuteResponse as xt, FetchUrlFinishEvent as y, DeepAgentState as yt, TodoItem as z };
1500
+ //# sourceMappingURL=agent-BDM-PIu8.d.mts.map