illuma-agents 1.0.45 → 1.0.49

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 (34) hide show
  1. package/dist/cjs/deepagents/DeepAgentBackend.cjs +170 -0
  2. package/dist/cjs/deepagents/DeepAgentBackend.cjs.map +1 -0
  3. package/dist/cjs/deepagents/DeepAgentRuntime.cjs +135 -0
  4. package/dist/cjs/deepagents/DeepAgentRuntime.cjs.map +1 -0
  5. package/dist/cjs/deepagents/types.cjs +29 -0
  6. package/dist/cjs/deepagents/types.cjs.map +1 -0
  7. package/dist/cjs/main.cjs +17 -6
  8. package/dist/cjs/main.cjs.map +1 -1
  9. package/dist/esm/deepagents/DeepAgentBackend.mjs +168 -0
  10. package/dist/esm/deepagents/DeepAgentBackend.mjs.map +1 -0
  11. package/dist/esm/deepagents/DeepAgentRuntime.mjs +132 -0
  12. package/dist/esm/deepagents/DeepAgentRuntime.mjs.map +1 -0
  13. package/dist/esm/deepagents/types.mjs +26 -0
  14. package/dist/esm/deepagents/types.mjs.map +1 -0
  15. package/dist/esm/main.mjs +4 -1
  16. package/dist/esm/main.mjs.map +1 -1
  17. package/dist/types/deepagents/DeepAgentBackend.d.ts +82 -0
  18. package/dist/types/deepagents/DeepAgentRuntime.d.ts +46 -0
  19. package/dist/types/deepagents/index.d.ts +16 -0
  20. package/dist/types/deepagents/types.d.ts +105 -0
  21. package/dist/types/index.d.ts +1 -1
  22. package/package.json +2 -1
  23. package/src/deepagents/DeepAgentBackend.ts +214 -0
  24. package/src/deepagents/DeepAgentRuntime.ts +187 -0
  25. package/src/deepagents/index.ts +25 -0
  26. package/src/deepagents/types.ts +118 -0
  27. package/src/index.ts +3 -1
  28. package/src/specs/deepagents.test.ts +286 -0
  29. package/dist/cjs/tools/DesktopTools.cjs +0 -363
  30. package/dist/cjs/tools/DesktopTools.cjs.map +0 -1
  31. package/dist/esm/tools/DesktopTools.mjs +0 -357
  32. package/dist/esm/tools/DesktopTools.mjs.map +0 -1
  33. package/dist/types/tools/DesktopTools.d.ts +0 -134
  34. package/src/tools/DesktopTools.ts +0 -574
@@ -0,0 +1,170 @@
1
+ 'use strict';
2
+
3
+ var deepagents = require('deepagents');
4
+
5
+ /**
6
+ * Deep Agent Backend
7
+ *
8
+ * A backend implementation that extends deepagents' FilesystemBackend
9
+ * with SSE streaming for real-time updates and integration with
10
+ * external code execution services.
11
+ */
12
+ /**
13
+ * Deep Agent Backend
14
+ *
15
+ * Extends FilesystemBackend with:
16
+ * - SSE streaming for real-time updates
17
+ * - Integration with external code executor services
18
+ * - Event emission for todos and subagents
19
+ */
20
+ class DeepAgentBackend extends deepagents.FilesystemBackend {
21
+ id;
22
+ timeout;
23
+ maxOutputBytes;
24
+ conversationId;
25
+ sseResponse;
26
+ codeExecutorUrl;
27
+ onTodoUpdate;
28
+ onSubagentUpdate;
29
+ constructor(options = {}) {
30
+ super({
31
+ rootDir: options.rootDir ?? process.cwd(),
32
+ virtualMode: options.virtualMode ?? true,
33
+ maxFileSizeMb: 10,
34
+ });
35
+ this.id = `deep-agent-backend-${Date.now().toString(36)}`;
36
+ this.timeout = options.timeout ?? 120_000;
37
+ this.maxOutputBytes = options.maxOutputBytes ?? 100_000;
38
+ this.conversationId = options.conversationId;
39
+ this.sseResponse = options.sseResponse;
40
+ this.codeExecutorUrl = options.codeExecutorUrl;
41
+ this.onTodoUpdate = options.onTodoUpdate;
42
+ this.onSubagentUpdate = options.onSubagentUpdate;
43
+ }
44
+ /**
45
+ * Execute a command
46
+ *
47
+ * If codeExecutorUrl is configured, uses the external sandboxed executor.
48
+ * Otherwise, logs a warning (shell execution may not be available).
49
+ */
50
+ async execute(command) {
51
+ if (!command || typeof command !== 'string') {
52
+ return {
53
+ output: 'Error: Command must be a non-empty string.',
54
+ exitCode: 1,
55
+ truncated: false,
56
+ };
57
+ }
58
+ // If we have a code executor URL, use that for sandboxed execution
59
+ if (this.codeExecutorUrl) {
60
+ return this.executeViaCodeExecutor(command);
61
+ }
62
+ // Log warning - direct shell execution may not be available
63
+ console.warn('[DeepAgentBackend] Shell execution requested but no code executor configured');
64
+ return {
65
+ output: 'Shell execution is not available in this environment. Consider using the code executor tool instead.',
66
+ exitCode: 1,
67
+ truncated: false,
68
+ };
69
+ }
70
+ /**
71
+ * Execute command via external code executor service
72
+ */
73
+ async executeViaCodeExecutor(command) {
74
+ try {
75
+ const response = await fetch(`${this.codeExecutorUrl}/execute`, {
76
+ method: 'POST',
77
+ headers: { 'Content-Type': 'application/json' },
78
+ body: JSON.stringify({
79
+ code: command,
80
+ language: 'shell',
81
+ timeout: this.timeout,
82
+ }),
83
+ signal: AbortSignal.timeout(this.timeout + 5000),
84
+ });
85
+ if (!response.ok) {
86
+ return {
87
+ output: `Execution error: ${response.statusText}`,
88
+ exitCode: 1,
89
+ truncated: false,
90
+ };
91
+ }
92
+ const result = await response.json();
93
+ let output = result.output ?? result.error ?? '';
94
+ let truncated = false;
95
+ if (output.length > this.maxOutputBytes) {
96
+ output = output.slice(0, this.maxOutputBytes) + '\n... (output truncated)';
97
+ truncated = true;
98
+ }
99
+ return {
100
+ output,
101
+ exitCode: result.exitCode ?? (result.error ? 1 : 0),
102
+ truncated,
103
+ };
104
+ }
105
+ catch (error) {
106
+ return {
107
+ output: `Execution failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
108
+ exitCode: 1,
109
+ truncated: false,
110
+ };
111
+ }
112
+ }
113
+ /**
114
+ * Send an SSE event to the client
115
+ */
116
+ sendEvent(event, data) {
117
+ if (this.sseResponse && !this.sseResponse.headersSent) {
118
+ try {
119
+ this.sseResponse.write(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
120
+ }
121
+ catch (e) {
122
+ console.warn('[DeepAgentBackend] Failed to send SSE event:', e);
123
+ }
124
+ }
125
+ }
126
+ /**
127
+ * Emit todo update event
128
+ */
129
+ emitTodoUpdate(todos) {
130
+ // Call callback if provided
131
+ if (this.onTodoUpdate) {
132
+ this.onTodoUpdate(todos);
133
+ }
134
+ // Send SSE event
135
+ this.sendEvent('deep_research', {
136
+ type: 'todo_update',
137
+ conversationId: this.conversationId,
138
+ todos,
139
+ progress: this.calculateProgress(todos),
140
+ isRunning: todos.some(t => t.status === 'in_progress'),
141
+ });
142
+ }
143
+ /**
144
+ * Emit subagent update event
145
+ */
146
+ emitSubagentUpdate(subagents) {
147
+ // Call callback if provided
148
+ if (this.onSubagentUpdate) {
149
+ this.onSubagentUpdate(subagents);
150
+ }
151
+ // Send SSE event
152
+ this.sendEvent('deep_research', {
153
+ type: 'subagent_update',
154
+ conversationId: this.conversationId,
155
+ subagents,
156
+ });
157
+ }
158
+ /**
159
+ * Calculate progress from todos
160
+ */
161
+ calculateProgress(todos) {
162
+ if (todos.length === 0)
163
+ return 0;
164
+ const completed = todos.filter(t => t.status === 'completed').length;
165
+ return Math.round((completed / todos.length) * 100);
166
+ }
167
+ }
168
+
169
+ exports.DeepAgentBackend = DeepAgentBackend;
170
+ //# sourceMappingURL=DeepAgentBackend.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepAgentBackend.cjs","sources":["../../../src/deepagents/DeepAgentBackend.ts"],"sourcesContent":["/**\r\n * Deep Agent Backend\r\n * \r\n * A backend implementation that extends deepagents' FilesystemBackend\r\n * with SSE streaming for real-time updates and integration with\r\n * external code execution services.\r\n */\r\n\r\nimport { FilesystemBackend } from 'deepagents';\r\nimport type { ExecuteResponse, SandboxBackendProtocol } from 'deepagents';\r\nimport type { DeepAgentTodo, DeepAgentSubagent } from './types';\r\n\r\n/** SSE Response interface for streaming */\r\nexport interface SSEResponse {\r\n write: (data: string) => void;\r\n headersSent?: boolean;\r\n}\r\n\r\n/** Options for Deep Agent Backend */\r\nexport interface DeepAgentBackendOptions {\r\n /** Root directory for file operations (default: process.cwd()) */\r\n rootDir?: string;\r\n /** Whether to use virtual paths (default: true) */\r\n virtualMode?: boolean;\r\n /** Timeout for command execution in ms (default: 120000) */\r\n timeout?: number;\r\n /** Max output size in bytes (default: 100000) */\r\n maxOutputBytes?: number;\r\n /** SSE response for streaming updates */\r\n sseResponse?: SSEResponse;\r\n /** Conversation ID for event tracking */\r\n conversationId?: string;\r\n /** Code executor API URL (optional - for sandboxed execution) */\r\n codeExecutorUrl?: string;\r\n /** Callback for todo changes */\r\n onTodoUpdate?: (todos: DeepAgentTodo[]) => void;\r\n /** Callback for subagent changes */\r\n onSubagentUpdate?: (subagents: DeepAgentSubagent[]) => void;\r\n}\r\n\r\n/**\r\n * Deep Agent Backend\r\n * \r\n * Extends FilesystemBackend with:\r\n * - SSE streaming for real-time updates\r\n * - Integration with external code executor services\r\n * - Event emission for todos and subagents\r\n */\r\nexport class DeepAgentBackend extends FilesystemBackend implements SandboxBackendProtocol {\r\n readonly id: string;\r\n private readonly timeout: number;\r\n private readonly maxOutputBytes: number;\r\n private readonly conversationId?: string;\r\n private readonly sseResponse?: SSEResponse;\r\n private readonly codeExecutorUrl?: string;\r\n private readonly onTodoUpdate?: (todos: DeepAgentTodo[]) => void;\r\n private readonly onSubagentUpdate?: (subagents: DeepAgentSubagent[]) => void;\r\n\r\n constructor(options: DeepAgentBackendOptions = {}) {\r\n super({\r\n rootDir: options.rootDir ?? process.cwd(),\r\n virtualMode: options.virtualMode ?? true,\r\n maxFileSizeMb: 10,\r\n });\r\n\r\n this.id = `deep-agent-backend-${Date.now().toString(36)}`;\r\n this.timeout = options.timeout ?? 120_000;\r\n this.maxOutputBytes = options.maxOutputBytes ?? 100_000;\r\n this.conversationId = options.conversationId;\r\n this.sseResponse = options.sseResponse;\r\n this.codeExecutorUrl = options.codeExecutorUrl;\r\n this.onTodoUpdate = options.onTodoUpdate;\r\n this.onSubagentUpdate = options.onSubagentUpdate;\r\n }\r\n\r\n /**\r\n * Execute a command\r\n * \r\n * If codeExecutorUrl is configured, uses the external sandboxed executor.\r\n * Otherwise, logs a warning (shell execution may not be available).\r\n */\r\n async execute(command: string): Promise<ExecuteResponse> {\r\n if (!command || typeof command !== 'string') {\r\n return {\r\n output: 'Error: Command must be a non-empty string.',\r\n exitCode: 1,\r\n truncated: false,\r\n };\r\n }\r\n\r\n // If we have a code executor URL, use that for sandboxed execution\r\n if (this.codeExecutorUrl) {\r\n return this.executeViaCodeExecutor(command);\r\n }\r\n\r\n // Log warning - direct shell execution may not be available\r\n console.warn('[DeepAgentBackend] Shell execution requested but no code executor configured');\r\n return {\r\n output: 'Shell execution is not available in this environment. Consider using the code executor tool instead.',\r\n exitCode: 1,\r\n truncated: false,\r\n };\r\n }\r\n\r\n /**\r\n * Execute command via external code executor service\r\n */\r\n private async executeViaCodeExecutor(command: string): Promise<ExecuteResponse> {\r\n try {\r\n const response = await fetch(`${this.codeExecutorUrl}/execute`, {\r\n method: 'POST',\r\n headers: { 'Content-Type': 'application/json' },\r\n body: JSON.stringify({\r\n code: command,\r\n language: 'shell',\r\n timeout: this.timeout,\r\n }),\r\n signal: AbortSignal.timeout(this.timeout + 5000),\r\n });\r\n\r\n if (!response.ok) {\r\n return {\r\n output: `Execution error: ${response.statusText}`,\r\n exitCode: 1,\r\n truncated: false,\r\n };\r\n }\r\n\r\n const result = await response.json() as {\r\n output?: string;\r\n exitCode?: number;\r\n error?: string;\r\n };\r\n\r\n let output = result.output ?? result.error ?? '';\r\n let truncated = false;\r\n\r\n if (output.length > this.maxOutputBytes) {\r\n output = output.slice(0, this.maxOutputBytes) + '\\n... (output truncated)';\r\n truncated = true;\r\n }\r\n\r\n return {\r\n output,\r\n exitCode: result.exitCode ?? (result.error ? 1 : 0),\r\n truncated,\r\n };\r\n } catch (error) {\r\n return {\r\n output: `Execution failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\r\n exitCode: 1,\r\n truncated: false,\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Send an SSE event to the client\r\n */\r\n sendEvent(event: string, data: unknown): void {\r\n if (this.sseResponse && !this.sseResponse.headersSent) {\r\n try {\r\n this.sseResponse.write(`event: ${event}\\ndata: ${JSON.stringify(data)}\\n\\n`);\r\n } catch (e) {\r\n console.warn('[DeepAgentBackend] Failed to send SSE event:', e);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Emit todo update event\r\n */\r\n emitTodoUpdate(todos: DeepAgentTodo[]): void {\r\n // Call callback if provided\r\n if (this.onTodoUpdate) {\r\n this.onTodoUpdate(todos);\r\n }\r\n\r\n // Send SSE event\r\n this.sendEvent('deep_research', {\r\n type: 'todo_update',\r\n conversationId: this.conversationId,\r\n todos,\r\n progress: this.calculateProgress(todos),\r\n isRunning: todos.some(t => t.status === 'in_progress'),\r\n });\r\n }\r\n\r\n /**\r\n * Emit subagent update event\r\n */\r\n emitSubagentUpdate(subagents: DeepAgentSubagent[]): void {\r\n // Call callback if provided\r\n if (this.onSubagentUpdate) {\r\n this.onSubagentUpdate(subagents);\r\n }\r\n\r\n // Send SSE event\r\n this.sendEvent('deep_research', {\r\n type: 'subagent_update',\r\n conversationId: this.conversationId,\r\n subagents,\r\n });\r\n }\r\n\r\n /**\r\n * Calculate progress from todos\r\n */\r\n private calculateProgress(todos: DeepAgentTodo[]): number {\r\n if (todos.length === 0) return 0;\r\n const completed = todos.filter(t => t.status === 'completed').length;\r\n return Math.round((completed / todos.length) * 100);\r\n }\r\n}\r\n"],"names":["FilesystemBackend"],"mappings":";;;;AAAA;;;;;;AAMG;AAkCH;;;;;;;AAOG;AACG,MAAO,gBAAiB,SAAQA,4BAAiB,CAAA;AAC5C,IAAA,EAAE;AACM,IAAA,OAAO;AACP,IAAA,cAAc;AACd,IAAA,cAAc;AACd,IAAA,WAAW;AACX,IAAA,eAAe;AACf,IAAA,YAAY;AACZ,IAAA,gBAAgB;AAEjC,IAAA,WAAA,CAAY,UAAmC,EAAE,EAAA;AAC/C,QAAA,KAAK,CAAC;YACJ,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE;AACzC,YAAA,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI;AACxC,YAAA,aAAa,EAAE,EAAE;AAClB,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C;AAAE,YAAA,OAAO,CAAC;AAChC,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,MAAM;AACpE,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;;AAEtD;;;;"}
@@ -0,0 +1,135 @@
1
+ 'use strict';
2
+
3
+ var deepagents = require('deepagents');
4
+ var DeepAgentBackend = require('./DeepAgentBackend.cjs');
5
+
6
+ /**
7
+ * Deep Agent Runtime
8
+ *
9
+ * Factory for creating and managing deep agent instances with
10
+ * illuma-agents integration.
11
+ *
12
+ * Uses explicit any types to avoid version conflicts between
13
+ * langchain dependencies in deepagents vs illuma-agents.
14
+ */
15
+ /** Default system prompt for deep research mode */
16
+ const DEFAULT_DEEP_RESEARCH_PROMPT = `You are a deep research agent capable of breaking down complex tasks into manageable steps.
17
+
18
+ ## Todo Management
19
+
20
+ You have a todo tool to track your progress. Use it to:
21
+ 1. Create a plan at the START with all tasks as "pending"
22
+ 2. Mark ONE task as "in_progress" before working on it
23
+ 3. Mark it "completed" IMMEDIATELY after finishing
24
+ 4. Update the FULL list each time (include all todos)
25
+
26
+ ## Best Practices
27
+
28
+ - Break complex tasks into 3-7 discrete steps
29
+ - Work through tasks sequentially
30
+ - Keep the user informed of progress
31
+ - If a task is blocked, mark it and move to the next
32
+ - Summarize findings after completing all tasks
33
+ `;
34
+ /**
35
+ * Create a deep agent runtime with the provided options
36
+ *
37
+ * @param options - Configuration for the deep agent
38
+ * @returns The configured deep agent instance
39
+ */
40
+ async function createDeepAgentRuntime(options) {
41
+ const { model, threadId, conversationId, workspacePath, systemPrompt, checkpointer, sseResponse, onTodoUpdate, onSubagentUpdate, requireApproval = false, codeExecutorUrl, } = options;
42
+ if (!threadId) {
43
+ throw new Error('Thread ID is required for deep agent checkpointing');
44
+ }
45
+ // Create the backend with SSE streaming
46
+ const backend = new DeepAgentBackend.DeepAgentBackend({
47
+ rootDir: workspacePath,
48
+ virtualMode: !workspacePath, // Use virtual mode if no workspace path
49
+ conversationId,
50
+ sseResponse,
51
+ codeExecutorUrl,
52
+ onTodoUpdate,
53
+ onSubagentUpdate,
54
+ });
55
+ // Build the full system prompt
56
+ const fullSystemPrompt = systemPrompt
57
+ ? `${systemPrompt}\n\n${DEFAULT_DEEP_RESEARCH_PROMPT}`
58
+ : DEFAULT_DEEP_RESEARCH_PROMPT;
59
+ // Create the deep agent with explicit any casts to avoid version conflicts
60
+ // between langchain types in deepagents vs illuma-agents
61
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
+ const agent = deepagents.createDeepAgent({
63
+ model: model,
64
+ checkpointer: checkpointer,
65
+ backend,
66
+ systemPrompt: fullSystemPrompt,
67
+ // Require approval for shell commands if configured
68
+ interruptOn: requireApproval ? { execute: true } : undefined,
69
+ });
70
+ return {
71
+ agent,
72
+ backend,
73
+ threadId,
74
+ conversationId,
75
+ };
76
+ }
77
+ /**
78
+ * Run a deep agent with the given input
79
+ *
80
+ * @param runtime - The deep agent runtime
81
+ * @param input - User input message
82
+ * @param config - Optional run configuration
83
+ */
84
+ async function runDeepAgent(runtime, input, config) {
85
+ const { agent, threadId, backend } = runtime;
86
+ // Stream the agent response
87
+ const stream = await agent.stream({ messages: [{ role: 'human', content: input }] }, {
88
+ configurable: { thread_id: threadId },
89
+ signal: config?.signal,
90
+ });
91
+ let fullResponse = '';
92
+ const todos = [];
93
+ const subagents = [];
94
+ for await (const event of stream) {
95
+ // Handle different event types
96
+ if ('messages' in event && Array.isArray(event.messages)) {
97
+ // Extract the latest AI message content
98
+ const lastMessage = event.messages[event.messages.length - 1];
99
+ if (lastMessage?.role === 'ai' && typeof lastMessage.content === 'string') {
100
+ const newContent = lastMessage.content.slice(fullResponse.length);
101
+ if (newContent && config?.onToken) {
102
+ config.onToken(newContent);
103
+ }
104
+ fullResponse = lastMessage.content;
105
+ }
106
+ }
107
+ // Handle todo updates
108
+ if ('todos' in event && Array.isArray(event.todos)) {
109
+ todos.length = 0;
110
+ todos.push(...event.todos);
111
+ if (config?.onTodoUpdate) {
112
+ config.onTodoUpdate(todos);
113
+ }
114
+ backend.emitTodoUpdate(todos);
115
+ }
116
+ // Handle subagent updates
117
+ if ('subagents' in event && Array.isArray(event.subagents)) {
118
+ subagents.length = 0;
119
+ subagents.push(...event.subagents);
120
+ if (config?.onSubagentUpdate) {
121
+ config.onSubagentUpdate(subagents);
122
+ }
123
+ backend.emitSubagentUpdate(subagents);
124
+ }
125
+ }
126
+ return {
127
+ response: fullResponse,
128
+ todos,
129
+ subagents,
130
+ };
131
+ }
132
+
133
+ exports.createDeepAgentRuntime = createDeepAgentRuntime;
134
+ exports.runDeepAgent = runDeepAgent;
135
+ //# sourceMappingURL=DeepAgentRuntime.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepAgentRuntime.cjs","sources":["../../../src/deepagents/DeepAgentRuntime.ts"],"sourcesContent":["/**\r\n * Deep Agent Runtime\r\n * \r\n * Factory for creating and managing deep agent instances with\r\n * illuma-agents integration.\r\n * \r\n * Uses explicit any types to avoid version conflicts between\r\n * langchain dependencies in deepagents vs illuma-agents.\r\n */\r\n\r\nimport { createDeepAgent } from 'deepagents';\r\nimport { DeepAgentBackend } from './DeepAgentBackend';\r\nimport type { DeepAgentRuntimeOptions, DeepAgentTodo, DeepAgentSubagent } from './types';\r\n\r\n/** Default system prompt for deep research mode */\r\nconst DEFAULT_DEEP_RESEARCH_PROMPT = `You are a deep research agent capable of breaking down complex tasks into manageable steps.\r\n\r\n## Todo Management\r\n\r\nYou have a todo tool to track your progress. Use it to:\r\n1. Create a plan at the START with all tasks as \"pending\"\r\n2. Mark ONE task as \"in_progress\" before working on it\r\n3. Mark it \"completed\" IMMEDIATELY after finishing\r\n4. Update the FULL list each time (include all todos)\r\n\r\n## Best Practices\r\n\r\n- Break complex tasks into 3-7 discrete steps\r\n- Work through tasks sequentially\r\n- Keep the user informed of progress\r\n- If a task is blocked, mark it and move to the next\r\n- Summarize findings after completing all tasks\r\n`;\r\n\r\n/** Return type for createDeepAgentRuntime */\r\nexport interface DeepAgentRuntimeResult {\r\n /** The deep agent instance */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n agent: any;\r\n /** The backend for execution */\r\n backend: DeepAgentBackend;\r\n /** Thread ID for checkpointing */\r\n threadId: string;\r\n /** Conversation ID for tracking */\r\n conversationId: string;\r\n}\r\n\r\n/**\r\n * Create a deep agent runtime with the provided options\r\n * \r\n * @param options - Configuration for the deep agent\r\n * @returns The configured deep agent instance\r\n */\r\nexport async function createDeepAgentRuntime(\r\n options: DeepAgentRuntimeOptions\r\n): Promise<DeepAgentRuntimeResult> {\r\n const {\r\n model,\r\n threadId,\r\n conversationId,\r\n workspacePath,\r\n systemPrompt,\r\n checkpointer,\r\n sseResponse,\r\n onTodoUpdate,\r\n onSubagentUpdate,\r\n requireApproval = false,\r\n codeExecutorUrl,\r\n } = options;\r\n\r\n if (!threadId) {\r\n throw new Error('Thread ID is required for deep agent checkpointing');\r\n }\r\n\r\n // Create the backend with SSE streaming\r\n const backend = new DeepAgentBackend({\r\n rootDir: workspacePath,\r\n virtualMode: !workspacePath, // Use virtual mode if no workspace path\r\n conversationId,\r\n sseResponse,\r\n codeExecutorUrl,\r\n onTodoUpdate,\r\n onSubagentUpdate,\r\n });\r\n\r\n // Build the full system prompt\r\n const fullSystemPrompt = systemPrompt \r\n ? `${systemPrompt}\\n\\n${DEFAULT_DEEP_RESEARCH_PROMPT}`\r\n : DEFAULT_DEEP_RESEARCH_PROMPT;\r\n\r\n // Create the deep agent with explicit any casts to avoid version conflicts\r\n // between langchain types in deepagents vs illuma-agents\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const agent = createDeepAgent({\r\n model: model as any,\r\n checkpointer: checkpointer as any,\r\n backend,\r\n systemPrompt: fullSystemPrompt,\r\n // Require approval for shell commands if configured\r\n interruptOn: requireApproval ? { execute: true } : undefined,\r\n } as any);\r\n\r\n return {\r\n agent,\r\n backend,\r\n threadId,\r\n conversationId,\r\n };\r\n}\r\n\r\n/**\r\n * Run a deep agent with the given input\r\n * \r\n * @param runtime - The deep agent runtime\r\n * @param input - User input message\r\n * @param config - Optional run configuration\r\n */\r\nexport async function runDeepAgent(\r\n runtime: DeepAgentRuntimeResult,\r\n input: string,\r\n config?: {\r\n signal?: AbortSignal;\r\n onToken?: (token: string) => void;\r\n onTodoUpdate?: (todos: DeepAgentTodo[]) => void;\r\n onSubagentUpdate?: (subagents: DeepAgentSubagent[]) => void;\r\n }\r\n): Promise<{\r\n response: string;\r\n todos: DeepAgentTodo[];\r\n subagents: DeepAgentSubagent[];\r\n}> {\r\n const { agent, threadId, backend } = runtime;\r\n\r\n // Stream the agent response\r\n const stream = await agent.stream(\r\n { messages: [{ role: 'human', content: input }] },\r\n { \r\n configurable: { thread_id: threadId },\r\n signal: config?.signal,\r\n }\r\n );\r\n\r\n let fullResponse = '';\r\n const todos: DeepAgentTodo[] = [];\r\n const subagents: DeepAgentSubagent[] = [];\r\n\r\n for await (const event of stream) {\r\n // Handle different event types\r\n if ('messages' in event && Array.isArray(event.messages)) {\r\n // Extract the latest AI message content\r\n const lastMessage = event.messages[event.messages.length - 1];\r\n if (lastMessage?.role === 'ai' && typeof lastMessage.content === 'string') {\r\n const newContent = lastMessage.content.slice(fullResponse.length);\r\n if (newContent && config?.onToken) {\r\n config.onToken(newContent);\r\n }\r\n fullResponse = lastMessage.content;\r\n }\r\n }\r\n\r\n // Handle todo updates\r\n if ('todos' in event && Array.isArray(event.todos)) {\r\n todos.length = 0;\r\n todos.push(...(event.todos as DeepAgentTodo[]));\r\n if (config?.onTodoUpdate) {\r\n config.onTodoUpdate(todos);\r\n }\r\n backend.emitTodoUpdate(todos);\r\n }\r\n\r\n // Handle subagent updates\r\n if ('subagents' in event && Array.isArray(event.subagents)) {\r\n subagents.length = 0;\r\n subagents.push(...(event.subagents as DeepAgentSubagent[]));\r\n if (config?.onSubagentUpdate) {\r\n config.onSubagentUpdate(subagents);\r\n }\r\n backend.emitSubagentUpdate(subagents);\r\n }\r\n }\r\n\r\n return {\r\n response: fullResponse,\r\n todos,\r\n subagents,\r\n };\r\n}"],"names":["DeepAgentBackend","createDeepAgent"],"mappings":";;;;;AAAA;;;;;;;;AAQG;AAMH;AACA,MAAM,4BAA4B,GAAG,CAAA;;;;;;;;;;;;;;;;;CAiBpC;AAeD;;;;;AAKG;AACI,eAAe,sBAAsB,CAC1C,OAAgC,EAAA;IAEhC,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,cAAc,EACd,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,eAAe,GAAG,KAAK,EACvB,eAAe,GAChB,GAAG,OAAO;IAEX,IAAI,CAAC,QAAQ,EAAE;AACb,QAAA,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC;;;AAIvE,IAAA,MAAM,OAAO,GAAG,IAAIA,iCAAgB,CAAC;AACnC,QAAA,OAAO,EAAE,aAAa;AACtB,QAAA,WAAW,EAAE,CAAC,aAAa;QAC3B,cAAc;QACd,WAAW;QACX,eAAe;QACf,YAAY;QACZ,gBAAgB;AACjB,KAAA,CAAC;;IAGF,MAAM,gBAAgB,GAAG;AACvB,UAAE,CAAA,EAAG,YAAY,CAAA,IAAA,EAAO,4BAA4B,CAAE;UACpD,4BAA4B;;;;IAKhC,MAAM,KAAK,GAAGC,0BAAe,CAAC;AAC5B,QAAA,KAAK,EAAE,KAAY;AACnB,QAAA,YAAY,EAAE,YAAmB;QACjC,OAAO;AACP,QAAA,YAAY,EAAE,gBAAgB;;AAE9B,QAAA,WAAW,EAAE,eAAe,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS;AACtD,KAAA,CAAC;IAET,OAAO;QACL,KAAK;QACL,OAAO;QACP,QAAQ;QACR,cAAc;KACf;AACH;AAEA;;;;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B,KAAK,CAAC,IAAI,CAAC,GAAI,KAAK,CAAC,KAAyB,CAAC;AAC/C,YAAA,IAAI,MAAM,EAAE,YAAY,EAAE;AACxB,gBAAA,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC;;AAE5B,YAAA,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC;;;AAI/B,QAAA,IAAI,WAAW,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;AAC1D,YAAA,SAAS,CAAC,MAAM,GAAG,CAAC;YACpB,SAAS,CAAC,IAAI,CAAC,GAAI,KAAK,CAAC,SAAiC,CAAC;AAC3D,YAAA,IAAI,MAAM,EAAE,gBAAgB,EAAE;AAC5B,gBAAA,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC;;AAEpC,YAAA,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC;;;IAIzC,OAAO;AACL,QAAA,QAAQ,EAAE,YAAY;QACtB,KAAK;QACL,SAAS;KACV;AACH;;;;;"}
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Deep Agents Types
5
+ *
6
+ * Type definitions for deep agent integration
7
+ *
8
+ * Uses generic/unknown types to avoid version conflicts between
9
+ * langchain dependencies in deepagents vs illuma-agents.
10
+ */
11
+ /** Calculate progress from todos */
12
+ function calculateTodoProgress(todos) {
13
+ if (todos.length === 0)
14
+ return 0;
15
+ const completed = todos.filter(t => t.status === 'completed').length;
16
+ return Math.round((completed / todos.length) * 100);
17
+ }
18
+ /** Default state for deep agent */
19
+ const defaultDeepAgentState = {
20
+ enabled: false,
21
+ todos: [],
22
+ subagents: [],
23
+ progress: 0,
24
+ isRunning: false,
25
+ };
26
+
27
+ exports.calculateTodoProgress = calculateTodoProgress;
28
+ exports.defaultDeepAgentState = defaultDeepAgentState;
29
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sources":["../../../src/deepagents/types.ts"],"sourcesContent":["/**\r\n * Deep Agents Types\r\n * \r\n * Type definitions for deep agent integration\r\n * \r\n * Uses generic/unknown types to avoid version conflicts between\r\n * langchain dependencies in deepagents vs illuma-agents.\r\n */\r\n\r\n/** Status of a todo item */\r\nexport type TodoStatus = 'pending' | 'in_progress' | 'completed' | 'cancelled';\r\n\r\n/** A todo item tracked by the deep agent */\r\nexport interface DeepAgentTodo {\r\n /** Unique identifier */\r\n id: string;\r\n /** Task description */\r\n content: string;\r\n /** Current status */\r\n status: TodoStatus;\r\n /** Order index */\r\n order?: number;\r\n /** When created */\r\n createdAt?: string;\r\n /** When last updated */\r\n updatedAt?: string;\r\n}\r\n\r\n/** A subagent spawned by the deep agent */\r\nexport interface DeepAgentSubagent {\r\n /** Unique identifier */\r\n id: string;\r\n /** Subagent name/purpose */\r\n name: string;\r\n /** Description of what it's doing */\r\n description?: string;\r\n /** Current status */\r\n status: 'pending' | 'running' | 'completed' | 'failed';\r\n /** When started */\r\n startedAt?: string;\r\n /** When completed */\r\n completedAt?: string;\r\n}\r\n\r\n/** State of a deep agent session */\r\nexport interface DeepAgentState {\r\n /** Whether deep research mode is active */\r\n enabled: boolean;\r\n /** Current todos */\r\n todos: DeepAgentTodo[];\r\n /** Active subagents */\r\n subagents: DeepAgentSubagent[];\r\n /** Overall progress (0-100) */\r\n progress: number;\r\n /** Whether currently executing */\r\n isRunning: boolean;\r\n /** Workspace path for file operations */\r\n workspacePath?: string;\r\n}\r\n\r\n/** Options for creating a deep agent runtime */\r\nexport interface DeepAgentRuntimeOptions {\r\n /** The LLM model to use (BaseChatModel or model name string) */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n model: any;\r\n /** Thread ID for checkpointing */\r\n threadId: string;\r\n /** Conversation ID for event tracking */\r\n conversationId: string;\r\n /** Workspace path for file operations (optional) */\r\n workspacePath?: string;\r\n /** Custom system prompt to prepend */\r\n systemPrompt?: string;\r\n /** Checkpointer for state persistence (BaseCheckpointSaver) */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n checkpointer?: any;\r\n /** SSE response object for streaming updates */\r\n sseResponse?: {\r\n write: (data: string) => void;\r\n headersSent?: boolean;\r\n };\r\n /** Callback for todo updates */\r\n onTodoUpdate?: (todos: DeepAgentTodo[]) => void;\r\n /** Callback for subagent updates */\r\n onSubagentUpdate?: (subagents: DeepAgentSubagent[]) => void;\r\n /** Whether to require human approval for shell commands */\r\n requireApproval?: boolean;\r\n /** Code executor URL for sandboxed execution */\r\n codeExecutorUrl?: string;\r\n}\r\n\r\n/** Events emitted by the deep agent */\r\nexport interface DeepAgentEvent {\r\n type: 'todo_update' | 'subagent_update' | 'file_change' | 'execution';\r\n conversationId: string;\r\n data: {\r\n todos?: DeepAgentTodo[];\r\n subagents?: DeepAgentSubagent[];\r\n files?: Array<{ path: string; action: 'read' | 'write' | 'delete' }>;\r\n execution?: { command: string; output: string; exitCode: number | null };\r\n };\r\n}\r\n\r\n/** Calculate progress from todos */\r\nexport function calculateTodoProgress(todos: DeepAgentTodo[]): number {\r\n if (todos.length === 0) return 0;\r\n const completed = todos.filter(t => t.status === 'completed').length;\r\n return Math.round((completed / todos.length) * 100);\r\n}\r\n\r\n/** Default state for deep agent */\r\nexport const defaultDeepAgentState: DeepAgentState = {\r\n enabled: false,\r\n todos: [],\r\n subagents: [],\r\n progress: 0,\r\n isRunning: false,\r\n};\r\n"],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAgGH;AACM,SAAU,qBAAqB,CAAC,KAAsB,EAAA;AAC1D,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,CAAC;AAChC,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,MAAM;AACpE,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;AACrD;AAEA;AACa,MAAA,qBAAqB,GAAmB;AACnD,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,KAAK,EAAE,EAAE;AACT,IAAA,SAAS,EAAE,EAAE;AACb,IAAA,QAAQ,EAAE,CAAC;AACX,IAAA,SAAS,EAAE,KAAK;;;;;;"}
package/dist/cjs/main.cjs CHANGED
@@ -13,10 +13,13 @@ var content = require('./messages/content.cjs');
13
13
  var tools = require('./messages/tools.cjs');
14
14
  var Graph = require('./graphs/Graph.cjs');
15
15
  var MultiAgentGraph = require('./graphs/MultiAgentGraph.cjs');
16
+ var deepagents = require('deepagents');
17
+ var types = require('./deepagents/types.cjs');
18
+ var DeepAgentRuntime = require('./deepagents/DeepAgentRuntime.cjs');
19
+ var DeepAgentBackend = require('./deepagents/DeepAgentBackend.cjs');
16
20
  var Calculator = require('./tools/Calculator.cjs');
17
21
  var CodeExecutor = require('./tools/CodeExecutor.cjs');
18
22
  var BrowserTools = require('./tools/BrowserTools.cjs');
19
- var DesktopTools = require('./tools/DesktopTools.cjs');
20
23
  var ProgrammaticToolCalling = require('./tools/ProgrammaticToolCalling.cjs');
21
24
  var ToolSearch = require('./tools/ToolSearch.cjs');
22
25
  var handlers = require('./tools/handlers.cjs');
@@ -79,6 +82,19 @@ exports.hasToolSearchInCurrentTurn = tools.hasToolSearchInCurrentTurn;
79
82
  exports.Graph = Graph.Graph;
80
83
  exports.StandardGraph = Graph.StandardGraph;
81
84
  exports.MultiAgentGraph = MultiAgentGraph.MultiAgentGraph;
85
+ Object.defineProperty(exports, "FilesystemBackend", {
86
+ enumerable: true,
87
+ get: function () { return deepagents.FilesystemBackend; }
88
+ });
89
+ Object.defineProperty(exports, "createDeepAgent", {
90
+ enumerable: true,
91
+ get: function () { return deepagents.createDeepAgent; }
92
+ });
93
+ exports.calculateTodoProgress = types.calculateTodoProgress;
94
+ exports.defaultDeepAgentState = types.defaultDeepAgentState;
95
+ exports.createDeepAgentRuntime = DeepAgentRuntime.createDeepAgentRuntime;
96
+ exports.runDeepAgent = DeepAgentRuntime.runDeepAgent;
97
+ exports.DeepAgentBackend = DeepAgentBackend.DeepAgentBackend;
82
98
  exports.Calculator = Calculator.Calculator;
83
99
  exports.createCodeExecutionTool = CodeExecutor.createCodeExecutionTool;
84
100
  exports.getCodeBaseURL = CodeExecutor.getCodeBaseURL;
@@ -86,11 +102,6 @@ exports.imageExtRegex = CodeExecutor.imageExtRegex;
86
102
  exports.EBrowserTools = BrowserTools.EBrowserTools;
87
103
  exports.createBrowserTools = BrowserTools.createBrowserTools;
88
104
  exports.hasBrowserCapability = BrowserTools.hasBrowserCapability;
89
- exports.EDesktopTools = DesktopTools.EDesktopTools;
90
- exports.createDesktopTools = DesktopTools.createDesktopTools;
91
- exports.getDesktopToolNames = DesktopTools.getDesktopToolNames;
92
- exports.hasDesktopCapability = DesktopTools.hasDesktopCapability;
93
- exports.isDesktopTool = DesktopTools.isDesktopTool;
94
105
  exports.createProgrammaticToolCallingTool = ProgrammaticToolCalling.createProgrammaticToolCallingTool;
95
106
  exports.executeTools = ProgrammaticToolCalling.executeTools;
96
107
  exports.extractUsedToolNames = ProgrammaticToolCalling.extractUsedToolNames;
@@ -1 +1 @@
1
- {"version":3,"file":"main.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"main.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,168 @@
1
+ import { FilesystemBackend } from 'deepagents';
2
+
3
+ /**
4
+ * Deep Agent Backend
5
+ *
6
+ * A backend implementation that extends deepagents' FilesystemBackend
7
+ * with SSE streaming for real-time updates and integration with
8
+ * external code execution services.
9
+ */
10
+ /**
11
+ * Deep Agent Backend
12
+ *
13
+ * Extends FilesystemBackend with:
14
+ * - SSE streaming for real-time updates
15
+ * - Integration with external code executor services
16
+ * - Event emission for todos and subagents
17
+ */
18
+ class DeepAgentBackend extends FilesystemBackend {
19
+ id;
20
+ timeout;
21
+ maxOutputBytes;
22
+ conversationId;
23
+ sseResponse;
24
+ codeExecutorUrl;
25
+ onTodoUpdate;
26
+ onSubagentUpdate;
27
+ constructor(options = {}) {
28
+ super({
29
+ rootDir: options.rootDir ?? process.cwd(),
30
+ virtualMode: options.virtualMode ?? true,
31
+ maxFileSizeMb: 10,
32
+ });
33
+ this.id = `deep-agent-backend-${Date.now().toString(36)}`;
34
+ this.timeout = options.timeout ?? 120_000;
35
+ this.maxOutputBytes = options.maxOutputBytes ?? 100_000;
36
+ this.conversationId = options.conversationId;
37
+ this.sseResponse = options.sseResponse;
38
+ this.codeExecutorUrl = options.codeExecutorUrl;
39
+ this.onTodoUpdate = options.onTodoUpdate;
40
+ this.onSubagentUpdate = options.onSubagentUpdate;
41
+ }
42
+ /**
43
+ * Execute a command
44
+ *
45
+ * If codeExecutorUrl is configured, uses the external sandboxed executor.
46
+ * Otherwise, logs a warning (shell execution may not be available).
47
+ */
48
+ async execute(command) {
49
+ if (!command || typeof command !== 'string') {
50
+ return {
51
+ output: 'Error: Command must be a non-empty string.',
52
+ exitCode: 1,
53
+ truncated: false,
54
+ };
55
+ }
56
+ // If we have a code executor URL, use that for sandboxed execution
57
+ if (this.codeExecutorUrl) {
58
+ return this.executeViaCodeExecutor(command);
59
+ }
60
+ // Log warning - direct shell execution may not be available
61
+ console.warn('[DeepAgentBackend] Shell execution requested but no code executor configured');
62
+ return {
63
+ output: 'Shell execution is not available in this environment. Consider using the code executor tool instead.',
64
+ exitCode: 1,
65
+ truncated: false,
66
+ };
67
+ }
68
+ /**
69
+ * Execute command via external code executor service
70
+ */
71
+ async executeViaCodeExecutor(command) {
72
+ try {
73
+ const response = await fetch(`${this.codeExecutorUrl}/execute`, {
74
+ method: 'POST',
75
+ headers: { 'Content-Type': 'application/json' },
76
+ body: JSON.stringify({
77
+ code: command,
78
+ language: 'shell',
79
+ timeout: this.timeout,
80
+ }),
81
+ signal: AbortSignal.timeout(this.timeout + 5000),
82
+ });
83
+ if (!response.ok) {
84
+ return {
85
+ output: `Execution error: ${response.statusText}`,
86
+ exitCode: 1,
87
+ truncated: false,
88
+ };
89
+ }
90
+ const result = await response.json();
91
+ let output = result.output ?? result.error ?? '';
92
+ let truncated = false;
93
+ if (output.length > this.maxOutputBytes) {
94
+ output = output.slice(0, this.maxOutputBytes) + '\n... (output truncated)';
95
+ truncated = true;
96
+ }
97
+ return {
98
+ output,
99
+ exitCode: result.exitCode ?? (result.error ? 1 : 0),
100
+ truncated,
101
+ };
102
+ }
103
+ catch (error) {
104
+ return {
105
+ output: `Execution failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
106
+ exitCode: 1,
107
+ truncated: false,
108
+ };
109
+ }
110
+ }
111
+ /**
112
+ * Send an SSE event to the client
113
+ */
114
+ sendEvent(event, data) {
115
+ if (this.sseResponse && !this.sseResponse.headersSent) {
116
+ try {
117
+ this.sseResponse.write(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
118
+ }
119
+ catch (e) {
120
+ console.warn('[DeepAgentBackend] Failed to send SSE event:', e);
121
+ }
122
+ }
123
+ }
124
+ /**
125
+ * Emit todo update event
126
+ */
127
+ emitTodoUpdate(todos) {
128
+ // Call callback if provided
129
+ if (this.onTodoUpdate) {
130
+ this.onTodoUpdate(todos);
131
+ }
132
+ // Send SSE event
133
+ this.sendEvent('deep_research', {
134
+ type: 'todo_update',
135
+ conversationId: this.conversationId,
136
+ todos,
137
+ progress: this.calculateProgress(todos),
138
+ isRunning: todos.some(t => t.status === 'in_progress'),
139
+ });
140
+ }
141
+ /**
142
+ * Emit subagent update event
143
+ */
144
+ emitSubagentUpdate(subagents) {
145
+ // Call callback if provided
146
+ if (this.onSubagentUpdate) {
147
+ this.onSubagentUpdate(subagents);
148
+ }
149
+ // Send SSE event
150
+ this.sendEvent('deep_research', {
151
+ type: 'subagent_update',
152
+ conversationId: this.conversationId,
153
+ subagents,
154
+ });
155
+ }
156
+ /**
157
+ * Calculate progress from todos
158
+ */
159
+ calculateProgress(todos) {
160
+ if (todos.length === 0)
161
+ return 0;
162
+ const completed = todos.filter(t => t.status === 'completed').length;
163
+ return Math.round((completed / todos.length) * 100);
164
+ }
165
+ }
166
+
167
+ export { DeepAgentBackend };
168
+ //# sourceMappingURL=DeepAgentBackend.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepAgentBackend.mjs","sources":["../../../src/deepagents/DeepAgentBackend.ts"],"sourcesContent":["/**\r\n * Deep Agent Backend\r\n * \r\n * A backend implementation that extends deepagents' FilesystemBackend\r\n * with SSE streaming for real-time updates and integration with\r\n * external code execution services.\r\n */\r\n\r\nimport { FilesystemBackend } from 'deepagents';\r\nimport type { ExecuteResponse, SandboxBackendProtocol } from 'deepagents';\r\nimport type { DeepAgentTodo, DeepAgentSubagent } from './types';\r\n\r\n/** SSE Response interface for streaming */\r\nexport interface SSEResponse {\r\n write: (data: string) => void;\r\n headersSent?: boolean;\r\n}\r\n\r\n/** Options for Deep Agent Backend */\r\nexport interface DeepAgentBackendOptions {\r\n /** Root directory for file operations (default: process.cwd()) */\r\n rootDir?: string;\r\n /** Whether to use virtual paths (default: true) */\r\n virtualMode?: boolean;\r\n /** Timeout for command execution in ms (default: 120000) */\r\n timeout?: number;\r\n /** Max output size in bytes (default: 100000) */\r\n maxOutputBytes?: number;\r\n /** SSE response for streaming updates */\r\n sseResponse?: SSEResponse;\r\n /** Conversation ID for event tracking */\r\n conversationId?: string;\r\n /** Code executor API URL (optional - for sandboxed execution) */\r\n codeExecutorUrl?: string;\r\n /** Callback for todo changes */\r\n onTodoUpdate?: (todos: DeepAgentTodo[]) => void;\r\n /** Callback for subagent changes */\r\n onSubagentUpdate?: (subagents: DeepAgentSubagent[]) => void;\r\n}\r\n\r\n/**\r\n * Deep Agent Backend\r\n * \r\n * Extends FilesystemBackend with:\r\n * - SSE streaming for real-time updates\r\n * - Integration with external code executor services\r\n * - Event emission for todos and subagents\r\n */\r\nexport class DeepAgentBackend extends FilesystemBackend implements SandboxBackendProtocol {\r\n readonly id: string;\r\n private readonly timeout: number;\r\n private readonly maxOutputBytes: number;\r\n private readonly conversationId?: string;\r\n private readonly sseResponse?: SSEResponse;\r\n private readonly codeExecutorUrl?: string;\r\n private readonly onTodoUpdate?: (todos: DeepAgentTodo[]) => void;\r\n private readonly onSubagentUpdate?: (subagents: DeepAgentSubagent[]) => void;\r\n\r\n constructor(options: DeepAgentBackendOptions = {}) {\r\n super({\r\n rootDir: options.rootDir ?? process.cwd(),\r\n virtualMode: options.virtualMode ?? true,\r\n maxFileSizeMb: 10,\r\n });\r\n\r\n this.id = `deep-agent-backend-${Date.now().toString(36)}`;\r\n this.timeout = options.timeout ?? 120_000;\r\n this.maxOutputBytes = options.maxOutputBytes ?? 100_000;\r\n this.conversationId = options.conversationId;\r\n this.sseResponse = options.sseResponse;\r\n this.codeExecutorUrl = options.codeExecutorUrl;\r\n this.onTodoUpdate = options.onTodoUpdate;\r\n this.onSubagentUpdate = options.onSubagentUpdate;\r\n }\r\n\r\n /**\r\n * Execute a command\r\n * \r\n * If codeExecutorUrl is configured, uses the external sandboxed executor.\r\n * Otherwise, logs a warning (shell execution may not be available).\r\n */\r\n async execute(command: string): Promise<ExecuteResponse> {\r\n if (!command || typeof command !== 'string') {\r\n return {\r\n output: 'Error: Command must be a non-empty string.',\r\n exitCode: 1,\r\n truncated: false,\r\n };\r\n }\r\n\r\n // If we have a code executor URL, use that for sandboxed execution\r\n if (this.codeExecutorUrl) {\r\n return this.executeViaCodeExecutor(command);\r\n }\r\n\r\n // Log warning - direct shell execution may not be available\r\n console.warn('[DeepAgentBackend] Shell execution requested but no code executor configured');\r\n return {\r\n output: 'Shell execution is not available in this environment. Consider using the code executor tool instead.',\r\n exitCode: 1,\r\n truncated: false,\r\n };\r\n }\r\n\r\n /**\r\n * Execute command via external code executor service\r\n */\r\n private async executeViaCodeExecutor(command: string): Promise<ExecuteResponse> {\r\n try {\r\n const response = await fetch(`${this.codeExecutorUrl}/execute`, {\r\n method: 'POST',\r\n headers: { 'Content-Type': 'application/json' },\r\n body: JSON.stringify({\r\n code: command,\r\n language: 'shell',\r\n timeout: this.timeout,\r\n }),\r\n signal: AbortSignal.timeout(this.timeout + 5000),\r\n });\r\n\r\n if (!response.ok) {\r\n return {\r\n output: `Execution error: ${response.statusText}`,\r\n exitCode: 1,\r\n truncated: false,\r\n };\r\n }\r\n\r\n const result = await response.json() as {\r\n output?: string;\r\n exitCode?: number;\r\n error?: string;\r\n };\r\n\r\n let output = result.output ?? result.error ?? '';\r\n let truncated = false;\r\n\r\n if (output.length > this.maxOutputBytes) {\r\n output = output.slice(0, this.maxOutputBytes) + '\\n... (output truncated)';\r\n truncated = true;\r\n }\r\n\r\n return {\r\n output,\r\n exitCode: result.exitCode ?? (result.error ? 1 : 0),\r\n truncated,\r\n };\r\n } catch (error) {\r\n return {\r\n output: `Execution failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\r\n exitCode: 1,\r\n truncated: false,\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Send an SSE event to the client\r\n */\r\n sendEvent(event: string, data: unknown): void {\r\n if (this.sseResponse && !this.sseResponse.headersSent) {\r\n try {\r\n this.sseResponse.write(`event: ${event}\\ndata: ${JSON.stringify(data)}\\n\\n`);\r\n } catch (e) {\r\n console.warn('[DeepAgentBackend] Failed to send SSE event:', e);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Emit todo update event\r\n */\r\n emitTodoUpdate(todos: DeepAgentTodo[]): void {\r\n // Call callback if provided\r\n if (this.onTodoUpdate) {\r\n this.onTodoUpdate(todos);\r\n }\r\n\r\n // Send SSE event\r\n this.sendEvent('deep_research', {\r\n type: 'todo_update',\r\n conversationId: this.conversationId,\r\n todos,\r\n progress: this.calculateProgress(todos),\r\n isRunning: todos.some(t => t.status === 'in_progress'),\r\n });\r\n }\r\n\r\n /**\r\n * Emit subagent update event\r\n */\r\n emitSubagentUpdate(subagents: DeepAgentSubagent[]): void {\r\n // Call callback if provided\r\n if (this.onSubagentUpdate) {\r\n this.onSubagentUpdate(subagents);\r\n }\r\n\r\n // Send SSE event\r\n this.sendEvent('deep_research', {\r\n type: 'subagent_update',\r\n conversationId: this.conversationId,\r\n subagents,\r\n });\r\n }\r\n\r\n /**\r\n * Calculate progress from todos\r\n */\r\n private calculateProgress(todos: DeepAgentTodo[]): number {\r\n if (todos.length === 0) return 0;\r\n const completed = todos.filter(t => t.status === 'completed').length;\r\n return Math.round((completed / todos.length) * 100);\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAAA;;;;;;AAMG;AAkCH;;;;;;;AAOG;AACG,MAAO,gBAAiB,SAAQ,iBAAiB,CAAA;AAC5C,IAAA,EAAE;AACM,IAAA,OAAO;AACP,IAAA,cAAc;AACd,IAAA,cAAc;AACd,IAAA,WAAW;AACX,IAAA,eAAe;AACf,IAAA,YAAY;AACZ,IAAA,gBAAgB;AAEjC,IAAA,WAAA,CAAY,UAAmC,EAAE,EAAA;AAC/C,QAAA,KAAK,CAAC;YACJ,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE;AACzC,YAAA,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI;AACxC,YAAA,aAAa,EAAE,EAAE;AAClB,SAAA,CAAC;AAEF,Q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