deepagentsdk 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/elements/index.cjs +478 -288
- package/dist/adapters/elements/index.cjs.map +1 -1
- package/dist/adapters/elements/index.d.cts +107 -172
- package/dist/adapters/elements/index.d.mts +107 -172
- package/dist/adapters/elements/index.mjs +471 -284
- package/dist/adapters/elements/index.mjs.map +1 -1
- package/dist/{types-4g9UvXal.d.mts → agent-D0bKkNI-.d.mts} +352 -3
- package/dist/{types-IulnvhFg.d.cts → agent-DwAj5emJ.d.cts} +352 -3
- package/dist/{chunk-CbDLau6x.cjs → chunk-C5azi7Hr.cjs} +33 -0
- package/dist/cli/index.cjs +12 -12
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.mjs +2 -2
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{agent-Cuks-Idh.cjs → file-saver-BYPKakT4.cjs} +799 -205
- package/dist/file-saver-BYPKakT4.cjs.map +1 -0
- package/dist/{agent-CrH-He58.mjs → file-saver-Hj5so3dV.mjs} +793 -199
- package/dist/file-saver-Hj5so3dV.mjs.map +1 -0
- package/dist/index.cjs +83 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -353
- package/dist/index.d.mts +5 -353
- package/dist/index.mjs +13 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{load-B6CA5js_.mjs → load-BBYEnMwz.mjs} +1 -1
- package/dist/{load-B6CA5js_.mjs.map → load-BBYEnMwz.mjs.map} +1 -1
- package/dist/{load-94gjHorc.mjs → load-BDxe6Cet.mjs} +1 -1
- package/dist/{load-79a2H4m0.cjs → load-BrRAKlO6.cjs} +2 -2
- package/dist/{load-79a2H4m0.cjs.map → load-BrRAKlO6.cjs.map} +1 -1
- package/dist/load-DqllBbDc.cjs +4 -0
- package/package.json +1 -1
- package/dist/agent-CrH-He58.mjs.map +0 -1
- package/dist/agent-Cuks-Idh.cjs.map +0 -1
- package/dist/file-saver-BJCqMIb5.mjs +0 -655
- package/dist/file-saver-BJCqMIb5.mjs.map +0 -1
- package/dist/file-saver-C6O2LAvg.cjs +0 -679
- package/dist/file-saver-C6O2LAvg.cjs.map +0 -1
- package/dist/load-C2qVmZMp.cjs +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/adapters/elements/messageAdapter.ts","../../../src/adapters/elements/statusAdapter.ts","../../../src/adapters/elements/useElementsAdapter.ts"],"sourcesContent":["/**\n * Message transformation adapter for AI SDK Elements\n *\n * Converts deepagentsdk events to Elements UIMessage format\n */\n\nimport type { AgentEventLog } from \"../../cli/hooks/useAgent\";\nimport type { UIMessage, UIMessagePart, UIStatus } from \"./types\";\n\n/**\n * Converts agent event log to UIMessage format expected by Elements\n *\n * @param events - Array of agent events from useAgent hook\n * @param streamingText - Current streaming text (if any)\n * @param uiStatus - Current UI status\n * @returns Array of UIMessage objects for Elements Message component\n *\n * Conversion logic:\n * 1. Group events by role (user/assistant)\n * 2. Convert each event type to appropriate UIMessagePart\n * 3. Handle streaming text as in-progress message\n * 4. Preserve event order and tool call/result pairing\n */\nexport function convertEventsToUIMessages(\n events: AgentEventLog[],\n streamingText: string,\n uiStatus: UIStatus\n): UIMessage[] {\n const messages: UIMessage[] = [];\n let currentAssistantParts: UIMessagePart[] = [];\n let messageIdCounter = 0;\n\n const generateMessageId = (): string => {\n return `msg-${Date.now()}-${++messageIdCounter}`;\n };\n\n for (const eventLog of events) {\n const event = eventLog.event;\n\n switch (event.type) {\n case \"user-message\":\n // Flush any pending assistant parts before user message\n if (currentAssistantParts.length > 0) {\n messages.push({\n id: generateMessageId(),\n role: \"assistant\",\n parts: currentAssistantParts,\n status: \"ready\",\n });\n currentAssistantParts = [];\n }\n\n // Add user message\n messages.push({\n id: eventLog.id,\n role: \"user\",\n parts: [{ type: \"text\", text: event.content }],\n status: \"ready\",\n });\n break;\n\n case \"text-segment\":\n // Add text segment as separate text part\n currentAssistantParts.push({\n type: \"text\",\n text: event.text,\n });\n break;\n\n case \"tool-call\":\n // Add tool call part\n currentAssistantParts.push({\n type: \"tool-call\",\n toolCallId: event.toolCallId,\n toolName: event.toolName,\n args: event.args,\n });\n break;\n\n case \"tool-result\":\n // Add tool result part\n currentAssistantParts.push({\n type: \"tool-result\",\n toolCallId: event.toolCallId,\n toolName: event.toolName,\n result: event.result,\n isError: event.isError,\n });\n break;\n\n // Ignore other event types for message rendering\n // (they're handled separately by Elements components like Task, etc.)\n default:\n break;\n }\n }\n\n // Add streaming text as in-progress assistant message\n if (streamingText || currentAssistantParts.length > 0) {\n if (streamingText) {\n currentAssistantParts.push({ type: \"text\", text: streamingText });\n }\n\n // Determine status for current message\n let messageStatus: UIStatus = \"ready\";\n if (uiStatus === \"streaming\") {\n messageStatus = \"streaming\";\n } else if (uiStatus === \"submitted\") {\n messageStatus = \"submitted\";\n } else if (uiStatus === \"error\") {\n messageStatus = \"error\";\n }\n\n messages.push({\n id: generateMessageId(),\n role: \"assistant\",\n parts: currentAssistantParts,\n status: messageStatus,\n });\n }\n\n return messages;\n}\n\n/**\n * Extracts tool parts from the most recent assistant message\n *\n * @param messages - UIMessage array\n * @returns Array of tool parts (tool-call and tool-result)\n */\nexport function extractToolParts(messages: UIMessage[]) {\n // Get last assistant message\n const lastAssistantMessage = [...messages]\n .reverse()\n .find((m) => m.role === \"assistant\");\n\n if (!lastAssistantMessage) {\n return [];\n }\n\n // Extract only tool-related parts\n return lastAssistantMessage.parts\n .filter(\n (part): part is Extract<UIMessagePart, { type: \"tool-call\" | \"tool-result\" }> =>\n part.type === \"tool-call\" || part.type === \"tool-result\"\n )\n .map((part) => {\n if (part.type === \"tool-call\") {\n return {\n type: \"tool-call\" as const,\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n args: part.args,\n };\n } else {\n return {\n type: \"tool-result\" as const,\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n result: part.result,\n isError: part.isError,\n };\n }\n });\n}\n","/**\n * Status mapping adapter for AI SDK Elements\n *\n * Maps deepagentsdk AgentStatus to Elements UIStatus\n */\n\nimport type { AgentStatus } from \"../../cli/hooks/useAgent\";\nimport type { UIStatus } from \"./types\";\n\n/**\n * Maps deepagentsdk AgentStatus to Elements UIStatus\n *\n * @param agentStatus - The agent status from useAgent hook\n * @returns The corresponding UI status for Elements components\n *\n * Mapping rules:\n * - idle/done → ready (agent is waiting for input)\n * - thinking/tool-call/subagent → submitted (agent is processing)\n * - streaming → streaming (agent is generating text)\n * - error → error (an error occurred)\n */\nexport function mapAgentStatusToUIStatus(\n agentStatus: AgentStatus\n): UIStatus {\n switch (agentStatus) {\n case \"thinking\":\n case \"tool-call\":\n case \"subagent\":\n return \"submitted\";\n case \"streaming\":\n return \"streaming\";\n case \"error\":\n return \"error\";\n case \"idle\":\n case \"done\":\n default:\n return \"ready\";\n }\n}\n","/**\n * React hook adapter for AI SDK Elements\n *\n * Provides Elements-compatible interface for deepagentsdk\n */\n\nimport { useState, useCallback, useRef, useMemo } from \"react\";\nimport { createDeepAgent } from \"../../agent\";\nimport type { LanguageModel, ToolSet } from \"ai\";\nimport type {\n BackendProtocol,\n DeepAgentState,\n DeepAgentEvent,\n} from \"../../types\";\nimport {\n convertEventsToUIMessages,\n extractToolParts,\n} from \"./messageAdapter\";\nimport { mapAgentStatusToUIStatus } from \"./statusAdapter\";\nimport type { UseElementsAdapterReturn, PromptInputMessage } from \"./types\";\nimport type { AgentStatus, AgentEventLog } from \"../../cli/hooks/useAgent\";\n\n/**\n * Options for useElementsAdapter hook\n */\nexport interface UseElementsAdapterOptions {\n /**\n * Language model instance from AI SDK provider\n */\n model: LanguageModel;\n\n /**\n * Backend for state management\n */\n backend: BackendProtocol;\n\n /**\n * Optional tools to provide to the agent\n */\n tools?: ToolSet;\n\n /**\n * Maximum number of tool loop iterations\n * @default 10\n */\n maxSteps?: number;\n\n /**\n * System prompt for the agent\n */\n systemPrompt?: string;\n}\n\nlet eventCounter = 0;\n\nfunction createEventId(): string {\n return `event-${++eventCounter}`;\n}\n\n/**\n * Hook that adapts deepagentsdk to work with AI SDK Elements UI components\n *\n * @param options - Configuration options\n * @returns Elements-compatible interface\n *\n * @example\n * ```tsx\n * import { useElementsAdapter } from 'deepagentsdk/elements';\n * import { Conversation, Message, PromptInput } from '@/components/ai-elements';\n *\n * function Chat() {\n * const { uiMessages, sendMessage } = useElementsAdapter({\n * model,\n * backend\n * });\n *\n * return (\n * <Conversation>\n * {uiMessages.map(msg => <Message key={msg.id} from={msg.role} />)}\n * <PromptInput onSubmit={sendMessage} />\n * </Conversation>\n * );\n * }\n * ```\n */\nexport function useElementsAdapter(\n options: UseElementsAdapterOptions\n): UseElementsAdapterReturn {\n const { model, backend, tools, maxSteps = 10, systemPrompt } = options;\n\n const [status, setStatus] = useState<AgentStatus>(\"idle\");\n const [streamingText, setStreamingText] = useState(\"\");\n const [events, setEvents] = useState<AgentEventLog[]>([]);\n const [state, setState] = useState<DeepAgentState>({\n todos: [],\n files: {},\n });\n\n const abortControllerRef = useRef<AbortController | null>(null);\n const accumulatedTextRef = useRef(\"\");\n\n // Create agent instance\n const agentRef = useRef(\n createDeepAgent({\n model,\n maxSteps,\n systemPrompt,\n backend,\n tools,\n })\n );\n\n const addEvent = useCallback(\n (event: DeepAgentEvent | { type: \"text-segment\"; text: string }) => {\n setEvents((prev) => [\n ...prev,\n {\n id: createEventId(),\n type: event.type,\n event,\n timestamp: new Date(),\n },\n ]);\n },\n []\n );\n\n // Flush accumulated text as a text-segment event\n const flushTextSegment = useCallback(() => {\n if (accumulatedTextRef.current.trim()) {\n addEvent({\n type: \"text-segment\",\n text: accumulatedTextRef.current,\n });\n accumulatedTextRef.current = \"\";\n setStreamingText(\"\");\n }\n }, [addEvent]);\n\n const sendMessage = async (message: PromptInputMessage): Promise<void> => {\n if (!message.text.trim()) {\n return; // Ignore empty messages\n }\n\n // Reset for new generation\n setStatus(\"thinking\");\n setStreamingText(\"\");\n accumulatedTextRef.current = \"\";\n\n // Add user message to events\n addEvent({ type: \"user-message\", content: message.text });\n\n // Create new abort controller\n abortControllerRef.current = new AbortController();\n\n try {\n for await (const event of agentRef.current.streamWithEvents({\n messages: [{ role: \"user\", content: message.text }],\n state,\n abortSignal: abortControllerRef.current.signal,\n })) {\n switch (event.type) {\n case \"text\":\n setStatus(\"streaming\");\n accumulatedTextRef.current += event.text;\n setStreamingText(accumulatedTextRef.current);\n break;\n\n case \"step-start\":\n if (event.stepNumber > 1) {\n addEvent(event);\n }\n break;\n\n case \"tool-call\":\n flushTextSegment();\n setStatus(\"tool-call\");\n addEvent(event);\n break;\n\n case \"tool-result\":\n addEvent(event);\n break;\n\n case \"todos-changed\":\n flushTextSegment();\n setStatus(\"tool-call\");\n setState((prev) => ({ ...prev, todos: event.todos }));\n addEvent(event);\n break;\n\n case \"done\":\n flushTextSegment();\n setStatus(\"done\");\n setState(event.state);\n addEvent(event);\n break;\n\n case \"error\":\n flushTextSegment();\n setStatus(\"error\");\n addEvent(event);\n break;\n\n default:\n addEvent(event);\n break;\n }\n }\n\n setStatus(\"idle\");\n } catch (err) {\n if ((err as Error).name === \"AbortError\") {\n flushTextSegment();\n setStatus(\"idle\");\n } else {\n flushTextSegment();\n setStatus(\"error\");\n }\n } finally {\n abortControllerRef.current = null;\n }\n };\n\n const abort = useCallback(() => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n setStatus(\"idle\");\n }\n }, []);\n\n const clear = useCallback(() => {\n setEvents([]);\n setStreamingText(\"\");\n setStatus(\"idle\");\n }, []);\n\n // Convert agent status to UI status\n const uiStatus = useMemo(\n () => mapAgentStatusToUIStatus(status),\n [status]\n );\n\n // Convert events to UI messages\n const uiMessages = useMemo(\n () => convertEventsToUIMessages(events, streamingText, uiStatus),\n [events, streamingText, uiStatus]\n );\n\n // Extract tool parts from current message\n const toolParts = useMemo(() => extractToolParts(uiMessages), [uiMessages]);\n\n return {\n uiMessages,\n uiStatus,\n toolParts,\n sendMessage,\n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AAK;AACH,uBAAkB;AAClB,eAAU,QAAQ;AAClB,cAAS,MAAM;AACf;IAEF;AACE,cAAS,MAAM;AACf;;AAIN,aAAU,OAAO;WACV,KAAK;AACZ,OAAK,IAAc,SAAS,cAAc;AACxC,sBAAkB;AAClB,cAAU,OAAO;UACZ;AACL,sBAAkB;AAClB,cAAU,QAAQ;;YAEZ;AACR,sBAAmB,UAAU;;;CAIjC,MAAM,QAAQ,kBAAkB;AAC9B,MAAI,mBAAmB,SAAS;AAC9B,sBAAmB,QAAQ,OAAO;AAClC,aAAU,OAAO;;IAElB,EAAE,CAAC;CAEN,MAAM,QAAQ,kBAAkB;AAC9B,YAAU,EAAE,CAAC;AACb,mBAAiB,GAAG;AACpB,YAAU,OAAO;IAChB,EAAE,CAAC;CAGN,MAAM,WAAW,cACT,yBAAyB,OAAO,EACtC,CAAC,OAAO,CACT;CAGD,MAAM,aAAa,cACX,0BAA0B,QAAQ,eAAe,SAAS,EAChE;EAAC;EAAQ;EAAe;EAAS,CAClC;AAKD,QAAO;EACL;EACA;EACA,WALgB,cAAc,iBAAiB,WAAW,EAAE,CAAC,WAAW,CAAC;EAMzE;EACA;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/adapters/elements/createElementsRouteHandler.ts","../../../src/adapters/elements/messageConverters.ts"],"sourcesContent":["/**\n * Server-side route handler adapter for AI SDK Elements\n *\n * Creates a Next.js/Express-compatible route handler that runs DeepAgent\n * and returns UI Message Stream compatible responses with full event visibility.\n *\n * This handler streams all DeepAgent event types (26+) including:\n * - Text and tool events (standard protocol)\n * - File system operations\n * - Command execution\n * - Web requests and searches\n * - Subagent lifecycle\n * - State changes (todos, checkpoints)\n *\n * @example\n * ```typescript\n * // app/api/chat/route.ts (Next.js App Router)\n * import { createDeepAgent } from 'deepagentsdk';\n * import { createElementsRouteHandler } from 'deepagentsdk/adapters/elements';\n * import { anthropic } from '@ai-sdk/anthropic';\n *\n * const agent = createDeepAgent({\n * model: anthropic('claude-sonnet-4-20250514'),\n * });\n *\n * export const POST = createElementsRouteHandler({ agent });\n * ```\n *\n * @see https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol\n */\n\nimport {\n createUIMessageStream,\n createUIMessageStreamResponse,\n convertToModelMessages,\n} from \"ai\";\nimport type { DeepAgent } from \"../../agent\";\nimport type { DeepAgentState, DeepAgentEvent } from \"../../types\";\n\n/**\n * Options for creating an Elements route handler\n */\nexport interface CreateElementsRouteHandlerOptions {\n /**\n * The DeepAgent instance to use for handling requests\n */\n agent: DeepAgent;\n\n /**\n * Optional callback before processing a request.\n * Use for authentication, logging, rate limiting, etc.\n *\n * @example\n * ```typescript\n * onRequest: async (req) => {\n * const token = req.headers.get('Authorization');\n * if (!validateToken(token)) {\n * throw new Error('Unauthorized');\n * }\n * }\n * ```\n */\n onRequest?: (req: Request) => Promise<void> | void;\n\n /**\n * Optional initial state to provide to the agent.\n * If not provided, uses empty state { todos: [], files: {} }\n */\n initialState?: DeepAgentState;\n\n /**\n * Optional thread ID for checkpointing.\n * If provided, enables conversation persistence.\n */\n threadId?: string;\n\n /**\n * Optional maximum number of steps for the agent loop.\n */\n maxSteps?: number;\n\n /**\n * Custom ID generator for message IDs.\n * Defaults to crypto.randomUUID if available.\n */\n generateId?: () => string;\n}\n\n/**\n * Creates a route handler that processes chat requests using DeepAgent\n * and streams all 26+ event types in UI Message Stream Protocol format.\n *\n * The returned handler:\n * - Accepts POST requests with { messages: UIMessage[] } body\n * - Runs DeepAgent with the conversation history\n * - Streams responses in UI Message Stream Protocol format\n * - Works with useChat hook from @ai-sdk/react\n * - Provides full visibility into agent behavior (file ops, web requests, subagents, etc.)\n *\n * @param options - Configuration options\n * @returns A request handler function compatible with Next.js/Express\n */\nexport function createElementsRouteHandler(\n options: CreateElementsRouteHandlerOptions\n): (req: Request) => Promise<Response> {\n const {\n agent,\n onRequest,\n initialState = {\n todos: [],\n files: {}\n },\n threadId,\n maxSteps,\n generateId\n } = options;\n\n return async (req: Request): Promise<Response> => {\n // 1. Handle onRequest hook (auth, logging, rate limiting)\n if (onRequest) {\n try {\n await onRequest(req);\n } catch (error) {\n return new Response(\n JSON.stringify({\n error: error instanceof Error ? error.message : 'Request rejected'\n }),\n {\n status: 401,\n headers: { 'Content-Type': 'application/json' }\n }\n );\n }\n }\n\n // 2. Parse request body\n let requestBody;\n try {\n requestBody = await req.json();\n } catch {\n return new Response(\n JSON.stringify({ error: 'Invalid JSON body' }),\n {\n status: 400,\n headers: { 'Content-Type': 'application/json' }\n }\n );\n }\n\n const { messages } = requestBody;\n if (!messages || !Array.isArray(messages)) {\n return new Response(\n JSON.stringify({ error: 'messages array is required' }),\n {\n status: 400,\n headers: { 'Content-Type': 'application/json' }\n }\n );\n }\n\n // 3. Convert UI messages to model messages\n const modelMessages = await convertToModelMessages(messages);\n\n // 4. Setup ID generator\n const genId = generateId || (() => crypto.randomUUID());\n\n // 5. Track current text ID for text-start/text-end\n let currentTextId: string | null = null;\n\n // 6. Create UI message stream response\n return createUIMessageStreamResponse({\n stream: createUIMessageStream({\n originalMessages: messages,\n generateId: genId,\n execute: async ({ writer }) => {\n try {\n // Stream all events from DeepAgent\n for await (const event of agent.streamWithEvents({\n messages: modelMessages,\n state: initialState,\n threadId,\n maxSteps\n })) {\n // Update currentTextId from the returned value\n const result = mapEventToProtocol(event, writer, genId, currentTextId);\n if (typeof result === 'string') {\n currentTextId = result;\n } else if (result === null) {\n currentTextId = null;\n }\n }\n\n // Ensure text is properly closed\n if (currentTextId) {\n writer.write({\n type: 'text-end',\n id: currentTextId\n });\n }\n } catch (error) {\n // Close text if error occurs mid-stream\n if (currentTextId) {\n writer.write({\n type: 'text-end',\n id: currentTextId\n });\n }\n throw error;\n }\n },\n onError: (error) => {\n return error instanceof Error ? error.message : 'Unknown error';\n }\n })\n });\n };\n}\n\n/**\n * Maps a DeepAgent event to a UI Message Stream Protocol event.\n *\n * This function handles all 26+ DeepAgent event types, mapping:\n * - Standard protocol events (text, tools, steps, errors)\n * - Custom data events (file operations, web requests, subagents, execution)\n *\n * @param event - The DeepAgent event to map\n * @param writer - The UI message stream writer\n * @param genId - ID generator function\n * @param currentTextId - The current text part ID (for tracking streaming text)\n * @returns The new currentTextId value (string | null)\n *\n * @example\n * ```typescript\n * // Handles text streaming with proper ID tracking\n * let textId: string | null = null;\n * textId = mapEventToProtocol({ type: 'text', text: 'Hello' }, writer, genId, textId);\n * // textId is now the ID of the active text part\n * ```\n */\nexport function mapEventToProtocol(\n event: DeepAgentEvent,\n writer: { write: (chunk: any) => void },\n genId: () => string,\n currentTextId: string | null\n): string | null {\n switch (event.type) {\n // ============================================================================\n // TEXT & FLOW EVENTS (Required for compatibility)\n // ============================================================================\n\n case 'step-start':\n writer.write({ type: 'start-step' });\n return currentTextId;\n\n case 'step-finish':\n writer.write({ type: 'finish-step' });\n return currentTextId;\n\n case 'text':\n // Start text if not already started\n if (!currentTextId) {\n const textId = genId();\n writer.write({\n type: 'text-start',\n id: textId\n });\n return textId;\n }\n writer.write({\n type: 'text-delta',\n id: currentTextId,\n delta: event.text\n });\n return currentTextId;\n\n // ============================================================================\n // TOOL EVENTS (Standard protocol events)\n // ============================================================================\n\n case 'tool-call':\n // End text before tool call\n if (currentTextId) {\n writer.write({\n type: 'text-end',\n id: currentTextId\n });\n currentTextId = null;\n }\n writer.write({\n type: 'tool-input-available',\n toolCallId: event.toolCallId,\n toolName: event.toolName,\n input: event.args\n });\n return null;\n\n case 'tool-result':\n if (event.isError) {\n writer.write({\n type: 'tool-output-error',\n toolCallId: event.toolCallId,\n errorText: String(event.result)\n });\n } else {\n writer.write({\n type: 'tool-output-available',\n toolCallId: event.toolCallId,\n output: event.result\n });\n }\n return currentTextId;\n\n // ============================================================================\n // TODO & PLANNING EVENTS\n // ============================================================================\n\n case 'todos-changed':\n writer.write({\n type: 'data',\n name: 'todos-changed',\n data: { todos: event.todos }\n });\n return currentTextId;\n\n // ============================================================================\n // FILE SYSTEM EVENTS (Custom data events)\n // ============================================================================\n\n case 'file-write-start':\n writer.write({\n type: 'data',\n name: 'file-write-start',\n data: {\n path: event.path,\n content: event.content\n }\n });\n return currentTextId;\n\n case 'file-written':\n writer.write({\n type: 'data',\n name: 'file-written',\n data: {\n path: event.path,\n content: event.content\n }\n });\n return currentTextId;\n\n case 'file-edited':\n writer.write({\n type: 'data',\n name: 'file-edited',\n data: {\n path: event.path,\n occurrences: event.occurrences\n }\n });\n return currentTextId;\n\n case 'file-read':\n writer.write({\n type: 'data',\n name: 'file-read',\n data: {\n path: event.path,\n lines: event.lines\n }\n });\n return currentTextId;\n\n case 'ls':\n writer.write({\n type: 'data',\n name: 'ls',\n data: {\n path: event.path,\n count: event.count\n }\n });\n return currentTextId;\n\n case 'glob':\n writer.write({\n type: 'data',\n name: 'glob',\n data: {\n pattern: event.pattern,\n count: event.count\n }\n });\n return currentTextId;\n\n case 'grep':\n writer.write({\n type: 'data',\n name: 'grep',\n data: {\n pattern: event.pattern,\n count: event.count\n }\n });\n return currentTextId;\n\n // ============================================================================\n // EXECUTION EVENTS (Custom data events)\n // ============================================================================\n\n case 'execute-start':\n writer.write({\n type: 'data',\n name: 'execute-start',\n data: {\n command: event.command,\n sandboxId: event.sandboxId\n }\n });\n return currentTextId;\n\n case 'execute-finish':\n writer.write({\n type: 'data',\n name: 'execute-finish',\n data: {\n command: event.command,\n exitCode: event.exitCode,\n truncated: event.truncated,\n sandboxId: event.sandboxId\n }\n });\n return currentTextId;\n\n // ============================================================================\n // WEB EVENTS (Custom data events)\n // ============================================================================\n\n case 'web-search-start':\n writer.write({\n type: 'data',\n name: 'web-search-start',\n data: {\n query: event.query\n }\n });\n return currentTextId;\n\n case 'web-search-finish':\n writer.write({\n type: 'data',\n name: 'web-search-finish',\n data: {\n query: event.query,\n resultCount: event.resultCount\n }\n });\n return currentTextId;\n\n case 'http-request-start':\n writer.write({\n type: 'data',\n name: 'http-request-start',\n data: {\n url: event.url,\n method: event.method\n }\n });\n return currentTextId;\n\n case 'http-request-finish':\n writer.write({\n type: 'data',\n name: 'http-request-finish',\n data: {\n url: event.url,\n statusCode: event.statusCode\n }\n });\n return currentTextId;\n\n case 'fetch-url-start':\n writer.write({\n type: 'data',\n name: 'fetch-url-start',\n data: {\n url: event.url\n }\n });\n return currentTextId;\n\n case 'fetch-url-finish':\n writer.write({\n type: 'data',\n name: 'fetch-url-finish',\n data: {\n url: event.url,\n success: event.success\n }\n });\n return currentTextId;\n\n // ============================================================================\n // SUBAGENT EVENTS (Custom data events)\n // ============================================================================\n\n case 'subagent-start':\n writer.write({\n type: 'data',\n name: 'subagent-start',\n data: {\n name: event.name,\n task: event.task\n }\n });\n return currentTextId;\n\n case 'subagent-finish':\n writer.write({\n type: 'data',\n name: 'subagent-finish',\n data: {\n name: event.name,\n result: event.result\n }\n });\n return currentTextId;\n\n case 'subagent-step':\n writer.write({\n type: 'data',\n name: 'subagent-step',\n data: {\n stepIndex: event.stepIndex,\n toolCalls: event.toolCalls\n }\n });\n return currentTextId;\n\n // ============================================================================\n // CHECKPOINT EVENTS (Custom data events)\n // ============================================================================\n\n case 'checkpoint-saved':\n writer.write({\n type: 'data',\n name: 'checkpoint-saved',\n data: {\n threadId: event.threadId,\n step: event.step\n }\n });\n return currentTextId;\n\n case 'checkpoint-loaded':\n writer.write({\n type: 'data',\n name: 'checkpoint-loaded',\n data: {\n threadId: event.threadId,\n step: event.step,\n messagesCount: event.messagesCount\n }\n });\n return currentTextId;\n\n // ============================================================================\n // CONTROL EVENTS\n // ============================================================================\n\n case 'error':\n // End text before error\n if (currentTextId) {\n writer.write({\n type: 'text-end',\n id: currentTextId\n });\n currentTextId = null;\n }\n writer.write({\n type: 'error',\n errorText: event.error.message\n });\n return null;\n\n case 'done':\n // End text before completion\n if (currentTextId) {\n writer.write({\n type: 'text-end',\n id: currentTextId\n });\n currentTextId = null;\n }\n // The finish event is auto-emitted by createUIMessageStream\n // We explicitly emit it here for clarity\n writer.write({\n type: 'finish',\n finishReason: 'stop',\n });\n return null;\n\n // Ignore unhandled events (text-segment, user-message, approval events)\n default:\n return currentTextId;\n }\n}\n\n/**\n * Type for the request handler returned by createElementsRouteHandler\n */\nexport type ElementsRouteHandler = (req: Request) => Promise<Response>;\n","/**\n * Message conversion utilities for AI SDK Elements adapter\n *\n * Provides utilities for converting between UI message formats and model message formats.\n * The primary conversion is handled by AI SDK's `convertToModelMessages`, but these\n * utilities provide additional helpers for DeepAgent-specific needs.\n */\n\nimport {\n convertToModelMessages,\n type UIMessage,\n} from \"ai\";\nimport type { ModelMessage } from \"../../types\";\n\n/**\n * Re-export AI SDK's convertToModelMessages for convenience.\n *\n * This function converts UIMessage[] (from useChat) to ModelMessage[]\n * (for agent consumption), handling:\n * - Role mapping (user/assistant)\n * - Tool call/result parts\n * - Text content extraction\n *\n * @example\n * ```typescript\n * import { convertUIMessagesToModelMessages } from 'deepagentsdk/adapters/elements';\n *\n * const modelMessages = await convertUIMessagesToModelMessages(uiMessages);\n * ```\n */\nexport async function convertUIMessagesToModelMessages(\n messages: UIMessage[]\n): Promise<ModelMessage[]> {\n return await convertToModelMessages(messages) as ModelMessage[];\n}\n\n/**\n * Extract the last user message text from a UIMessage array.\n * Useful for extracting the prompt from a conversation.\n *\n * @param messages - Array of UI messages\n * @returns The text content of the last user message, or undefined if none\n */\nexport function extractLastUserMessage(messages: UIMessage[]): string | undefined {\n // Find the last user message\n for (let i = messages.length - 1; i >= 0; i--) {\n const msg = messages[i];\n if (msg && msg.role === \"user\" && msg.parts) {\n // Extract text parts\n const textParts = msg.parts.filter(\n (p): p is { type: \"text\"; text: string } => p.type === \"text\"\n );\n if (textParts.length > 0) {\n return textParts.map(p => p.text).join(\"\");\n }\n }\n }\n return undefined;\n}\n\n/**\n * Check if the messages contain any tool parts.\n * This is a simplified helper that checks for any tool-related parts.\n *\n * @param messages - Array of UI messages\n * @returns True if there are any tool-related parts in the messages\n */\nexport function hasToolParts(messages: UIMessage[]): boolean {\n for (const msg of messages) {\n if (!msg.parts) continue;\n for (const part of msg.parts) {\n // Tool parts have type starting with \"tool-\" or \"dynamic-tool\"\n if (part.type.startsWith(\"tool-\") || part.type === \"dynamic-tool\") {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Count the number of messages by role.\n *\n * @param messages - Array of UI messages\n * @returns Object with counts by role\n */\nexport function countMessagesByRole(\n messages: UIMessage[]\n): { user: number; assistant: number; system: number } {\n let user = 0;\n let assistant = 0;\n let system = 0;\n\n for (const msg of messages) {\n if (msg.role === \"user\") {\n user++;\n } else if (msg.role === \"assistant\") {\n assistant++;\n } else if (msg.role === \"system\") {\n system++;\n }\n }\n\n return { user, assistant, system };\n}\n\n/**\n * Extract all text content from a message.\n *\n * @param message - A UI message\n * @returns Combined text from all text parts\n */\nexport function extractTextFromMessage(message: UIMessage): string {\n if (!message.parts) return \"\";\n\n return message.parts\n .filter((p): p is { type: \"text\"; text: string } => p.type === \"text\")\n .map(p => p.text)\n .join(\"\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,SAAgB,2BACd,SACqC;CACrC,MAAM,EACJ,OACA,WACA,eAAe;EACb,OAAO,EAAE;EACT,OAAO,EAAE;EACV,EACD,UACA,UACA,eACE;AAEJ,QAAO,OAAO,QAAoC;AAEhD,MAAI,UACF,KAAI;AACF,SAAM,UAAU,IAAI;WACb,OAAO;AACd,UAAO,IAAI,SACT,KAAK,UAAU,EACb,OAAO,iBAAiB,QAAQ,MAAM,UAAU,oBACjD,CAAC,EACF;IACE,QAAQ;IACR,SAAS,EAAE,gBAAgB,oBAAoB;IAChD,CACF;;EAKL,IAAI;AACJ,MAAI;AACF,iBAAc,MAAM,IAAI,MAAM;UACxB;AACN,UAAO,IAAI,SACT,KAAK,UAAU,EAAE,OAAO,qBAAqB,CAAC,EAC9C;IACE,QAAQ;IACR,SAAS,EAAE,gBAAgB,oBAAoB;IAChD,CACF;;EAGH,MAAM,EAAE,aAAa;AACrB,MAAI,CAAC,YAAY,CAAC,MAA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U,KAAI,MAAK,EAAE,KAAK,CAAC,KAAK,GAAG;;;;;;;;;;;AAclD,SAAgB,aAAa,UAAgC;AAC3D,MAAK,MAAM,OAAO,UAAU;AAC1B,MAAI,CAAC,IAAI,MAAO;AAChB,OAAK,MAAM,QAAQ,IAAI,MAErB,KAAI,KAAK,KAAK,WAAW,QAAQ,IAAI,KAAK,SAAS,eACjD,QAAO;;AAIb,QAAO;;;;;;;;AAST,SAAgB,oBACd,UACqD;CACrD,IAAI,OAAO;CACX,IAAI,YAAY;CAChB,IAAI,SAAS;AAEb,MAAK,MAAM,OAAO,SAChB,KAAI,IAAI,SAAS,OACf;UACS,IAAI,SAAS,YACtB;UACS,IAAI,SAAS,SACtB;AAIJ,QAAO;EAAE;EAAM;EAAW;EAAQ;;;;;;;;AASpC,SAAgB,uBAAuB,SAA4B;AACjE,KAAI,CAAC,QAAQ,MAAO,QAAO;AAE3B,QAAO,QAAQ,MACZ,QAAQ,MAA2C,EAAE,SAAS,OAAO,CACrE,KAAI,MAAK,EAAE,KAAK,CAChB,KAAK,GAAG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ai3 from "ai";
|
|
2
|
-
import { LanguageModel, LanguageModel as LanguageModel$2, LanguageModelMiddleware, ModelMessage, ModelMessage as ModelMessage$1, StopCondition, ToolLoopAgentSettings, ToolSet } 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
|
|
@@ -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
|
-
|
|
1151
|
-
|
|
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<ai3.GenerateTextResult<{}, never> & {
|
|
1228
|
+
state: DeepAgentState;
|
|
1229
|
+
}>;
|
|
1230
|
+
/**
|
|
1231
|
+
* Stream a response.
|
|
1232
|
+
*/
|
|
1233
|
+
stream(options: {
|
|
1234
|
+
prompt: string;
|
|
1235
|
+
maxSteps?: number;
|
|
1236
|
+
}): Promise<ai3.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<ai3.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-D0bKkNI-.d.mts.map
|