illuma-agents 1.0.49 → 1.0.50
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/cjs/agents/AgentContext.cjs +44 -14
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/common/enum.cjs +2 -0
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +19 -0
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +26 -17
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +1 -0
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/main.cjs +9 -17
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/stream.cjs +0 -14
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +37 -27
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +22 -18
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +100 -5
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/ToolSearch.cjs +38 -31
- package/dist/cjs/tools/ToolSearch.cjs.map +1 -1
- package/dist/cjs/tools/schema.cjs +31 -0
- package/dist/cjs/tools/schema.cjs.map +1 -0
- package/dist/cjs/tools/search/schema.cjs +25 -23
- package/dist/cjs/tools/search/schema.cjs.map +1 -1
- package/dist/cjs/tools/search/tool.cjs +9 -33
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/cjs/utils/schema.cjs +27 -0
- package/dist/cjs/utils/schema.cjs.map +1 -0
- package/dist/cjs/utils/title.cjs +28 -14
- package/dist/cjs/utils/title.cjs.map +1 -1
- package/dist/esm/agents/AgentContext.mjs +44 -14
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/common/enum.mjs +2 -0
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +19 -0
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +26 -17
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +1 -0
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/main.mjs +3 -4
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/stream.mjs +0 -14
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +37 -27
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +22 -18
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +101 -6
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/ToolSearch.mjs +38 -31
- package/dist/esm/tools/ToolSearch.mjs.map +1 -1
- package/dist/esm/tools/schema.mjs +28 -0
- package/dist/esm/tools/schema.mjs.map +1 -0
- package/dist/esm/tools/search/schema.mjs +25 -23
- package/dist/esm/tools/search/schema.mjs.map +1 -1
- package/dist/esm/tools/search/tool.mjs +10 -34
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/esm/utils/schema.mjs +24 -0
- package/dist/esm/utils/schema.mjs.map +1 -0
- package/dist/esm/utils/title.mjs +28 -14
- package/dist/esm/utils/title.mjs.map +1 -1
- package/dist/types/agents/AgentContext.d.ts +13 -2
- package/dist/types/common/enum.d.ts +2 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/tools/CodeExecutor.d.ts +1 -15
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +1 -13
- package/dist/types/tools/ToolNode.d.ts +12 -1
- package/dist/types/tools/ToolSearch.d.ts +1 -15
- package/dist/types/tools/schema.d.ts +12 -0
- package/dist/types/tools/search/schema.d.ts +25 -7
- package/dist/types/tools/search/tool.d.ts +1 -52
- package/dist/types/tools/search/types.d.ts +5 -23
- package/dist/types/types/graph.d.ts +6 -0
- package/dist/types/types/tools.d.ts +55 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/schema.d.ts +8 -0
- package/package.json +2 -4
- package/src/agents/AgentContext.ts +55 -19
- package/src/common/enum.ts +2 -0
- package/src/graphs/Graph.ts +27 -4
- package/src/graphs/MultiAgentGraph.ts +26 -17
- package/src/index.ts +2 -3
- package/src/scripts/test_code_api.ts +4 -4
- package/src/specs/agent-handoffs.test.ts +1 -2
- package/src/specs/azure.simple.test.ts +214 -175
- package/src/specs/thinking-prune.test.ts +6 -6
- package/src/specs/tool-error.test.ts +7 -2
- package/src/stream.ts +0 -17
- package/src/test/mockTools.ts +34 -14
- package/src/tools/CodeExecutor.ts +48 -31
- package/src/tools/ProgrammaticToolCalling.ts +25 -24
- package/src/tools/ToolNode.ts +137 -15
- package/src/tools/ToolSearch.ts +55 -44
- package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.ts +10 -9
- package/src/tools/__tests__/ToolSearch.integration.test.ts +10 -9
- package/src/tools/schema.ts +37 -0
- package/src/tools/search/schema.ts +30 -25
- package/src/tools/search/tool.ts +23 -16
- package/src/tools/search/types.ts +5 -29
- package/src/types/graph.ts +6 -0
- package/src/types/tools.ts +58 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/schema.ts +35 -0
- package/src/utils/title.ts +31 -19
- package/LICENSE +0 -21
- package/dist/cjs/deepagents/DeepAgentBackend.cjs +0 -170
- package/dist/cjs/deepagents/DeepAgentBackend.cjs.map +0 -1
- package/dist/cjs/deepagents/DeepAgentRuntime.cjs +0 -135
- package/dist/cjs/deepagents/DeepAgentRuntime.cjs.map +0 -1
- package/dist/cjs/deepagents/types.cjs +0 -29
- package/dist/cjs/deepagents/types.cjs.map +0 -1
- package/dist/esm/deepagents/DeepAgentBackend.mjs +0 -168
- package/dist/esm/deepagents/DeepAgentBackend.mjs.map +0 -1
- package/dist/esm/deepagents/DeepAgentRuntime.mjs +0 -132
- package/dist/esm/deepagents/DeepAgentRuntime.mjs.map +0 -1
- package/dist/esm/deepagents/types.mjs +0 -26
- package/dist/esm/deepagents/types.mjs.map +0 -1
- package/dist/types/deepagents/DeepAgentBackend.d.ts +0 -82
- package/dist/types/deepagents/DeepAgentRuntime.d.ts +0 -46
- package/dist/types/deepagents/index.d.ts +0 -16
- package/dist/types/deepagents/types.d.ts +0 -105
- package/src/deepagents/DeepAgentBackend.ts +0 -214
- package/src/deepagents/DeepAgentRuntime.ts +0 -187
- package/src/deepagents/index.ts +0 -25
- package/src/deepagents/types.ts +0 -118
- package/src/specs/deepagents.test.ts +0 -286
package/src/deepagents/types.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deep Agents Types
|
|
3
|
-
*
|
|
4
|
-
* Type definitions for deep agent integration
|
|
5
|
-
*
|
|
6
|
-
* Uses generic/unknown types to avoid version conflicts between
|
|
7
|
-
* langchain dependencies in deepagents vs illuma-agents.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/** Status of a todo item */
|
|
11
|
-
export type TodoStatus = 'pending' | 'in_progress' | 'completed' | 'cancelled';
|
|
12
|
-
|
|
13
|
-
/** A todo item tracked by the deep agent */
|
|
14
|
-
export interface DeepAgentTodo {
|
|
15
|
-
/** Unique identifier */
|
|
16
|
-
id: string;
|
|
17
|
-
/** Task description */
|
|
18
|
-
content: string;
|
|
19
|
-
/** Current status */
|
|
20
|
-
status: TodoStatus;
|
|
21
|
-
/** Order index */
|
|
22
|
-
order?: number;
|
|
23
|
-
/** When created */
|
|
24
|
-
createdAt?: string;
|
|
25
|
-
/** When last updated */
|
|
26
|
-
updatedAt?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** A subagent spawned by the deep agent */
|
|
30
|
-
export interface DeepAgentSubagent {
|
|
31
|
-
/** Unique identifier */
|
|
32
|
-
id: string;
|
|
33
|
-
/** Subagent name/purpose */
|
|
34
|
-
name: string;
|
|
35
|
-
/** Description of what it's doing */
|
|
36
|
-
description?: string;
|
|
37
|
-
/** Current status */
|
|
38
|
-
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
39
|
-
/** When started */
|
|
40
|
-
startedAt?: string;
|
|
41
|
-
/** When completed */
|
|
42
|
-
completedAt?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** State of a deep agent session */
|
|
46
|
-
export interface DeepAgentState {
|
|
47
|
-
/** Whether deep research mode is active */
|
|
48
|
-
enabled: boolean;
|
|
49
|
-
/** Current todos */
|
|
50
|
-
todos: DeepAgentTodo[];
|
|
51
|
-
/** Active subagents */
|
|
52
|
-
subagents: DeepAgentSubagent[];
|
|
53
|
-
/** Overall progress (0-100) */
|
|
54
|
-
progress: number;
|
|
55
|
-
/** Whether currently executing */
|
|
56
|
-
isRunning: boolean;
|
|
57
|
-
/** Workspace path for file operations */
|
|
58
|
-
workspacePath?: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Options for creating a deep agent runtime */
|
|
62
|
-
export interface DeepAgentRuntimeOptions {
|
|
63
|
-
/** The LLM model to use (BaseChatModel or model name string) */
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
-
model: any;
|
|
66
|
-
/** Thread ID for checkpointing */
|
|
67
|
-
threadId: string;
|
|
68
|
-
/** Conversation ID for event tracking */
|
|
69
|
-
conversationId: string;
|
|
70
|
-
/** Workspace path for file operations (optional) */
|
|
71
|
-
workspacePath?: string;
|
|
72
|
-
/** Custom system prompt to prepend */
|
|
73
|
-
systemPrompt?: string;
|
|
74
|
-
/** Checkpointer for state persistence (BaseCheckpointSaver) */
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
-
checkpointer?: any;
|
|
77
|
-
/** SSE response object for streaming updates */
|
|
78
|
-
sseResponse?: {
|
|
79
|
-
write: (data: string) => void;
|
|
80
|
-
headersSent?: boolean;
|
|
81
|
-
};
|
|
82
|
-
/** Callback for todo updates */
|
|
83
|
-
onTodoUpdate?: (todos: DeepAgentTodo[]) => void;
|
|
84
|
-
/** Callback for subagent updates */
|
|
85
|
-
onSubagentUpdate?: (subagents: DeepAgentSubagent[]) => void;
|
|
86
|
-
/** Whether to require human approval for shell commands */
|
|
87
|
-
requireApproval?: boolean;
|
|
88
|
-
/** Code executor URL for sandboxed execution */
|
|
89
|
-
codeExecutorUrl?: string;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** Events emitted by the deep agent */
|
|
93
|
-
export interface DeepAgentEvent {
|
|
94
|
-
type: 'todo_update' | 'subagent_update' | 'file_change' | 'execution';
|
|
95
|
-
conversationId: string;
|
|
96
|
-
data: {
|
|
97
|
-
todos?: DeepAgentTodo[];
|
|
98
|
-
subagents?: DeepAgentSubagent[];
|
|
99
|
-
files?: Array<{ path: string; action: 'read' | 'write' | 'delete' }>;
|
|
100
|
-
execution?: { command: string; output: string; exitCode: number | null };
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** Calculate progress from todos */
|
|
105
|
-
export function calculateTodoProgress(todos: DeepAgentTodo[]): number {
|
|
106
|
-
if (todos.length === 0) return 0;
|
|
107
|
-
const completed = todos.filter(t => t.status === 'completed').length;
|
|
108
|
-
return Math.round((completed / todos.length) * 100);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** Default state for deep agent */
|
|
112
|
-
export const defaultDeepAgentState: DeepAgentState = {
|
|
113
|
-
enabled: false,
|
|
114
|
-
todos: [],
|
|
115
|
-
subagents: [],
|
|
116
|
-
progress: 0,
|
|
117
|
-
isRunning: false,
|
|
118
|
-
};
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deep Agents Unit Tests
|
|
3
|
-
*
|
|
4
|
-
* Tests for the deep agents integration module
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
DeepAgentBackend,
|
|
9
|
-
calculateTodoProgress,
|
|
10
|
-
defaultDeepAgentState,
|
|
11
|
-
type DeepAgentTodo,
|
|
12
|
-
type DeepAgentSubagent,
|
|
13
|
-
type DeepAgentState,
|
|
14
|
-
type TodoStatus,
|
|
15
|
-
} from '../deepagents';
|
|
16
|
-
|
|
17
|
-
describe('Deep Agents Types', () => {
|
|
18
|
-
describe('calculateTodoProgress', () => {
|
|
19
|
-
it('should return 0 for empty todos', () => {
|
|
20
|
-
expect(calculateTodoProgress([])).toBe(0);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should return 0 when no todos are completed', () => {
|
|
24
|
-
const todos: DeepAgentTodo[] = [
|
|
25
|
-
{ id: '1', content: 'Task 1', status: 'pending' },
|
|
26
|
-
{ id: '2', content: 'Task 2', status: 'in_progress' },
|
|
27
|
-
];
|
|
28
|
-
expect(calculateTodoProgress(todos)).toBe(0);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should return 50 when half of todos are completed', () => {
|
|
32
|
-
const todos: DeepAgentTodo[] = [
|
|
33
|
-
{ id: '1', content: 'Task 1', status: 'completed' },
|
|
34
|
-
{ id: '2', content: 'Task 2', status: 'pending' },
|
|
35
|
-
];
|
|
36
|
-
expect(calculateTodoProgress(todos)).toBe(50);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should return 100 when all todos are completed', () => {
|
|
40
|
-
const todos: DeepAgentTodo[] = [
|
|
41
|
-
{ id: '1', content: 'Task 1', status: 'completed' },
|
|
42
|
-
{ id: '2', content: 'Task 2', status: 'completed' },
|
|
43
|
-
{ id: '3', content: 'Task 3', status: 'completed' },
|
|
44
|
-
];
|
|
45
|
-
expect(calculateTodoProgress(todos)).toBe(100);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should round progress correctly', () => {
|
|
49
|
-
const todos: DeepAgentTodo[] = [
|
|
50
|
-
{ id: '1', content: 'Task 1', status: 'completed' },
|
|
51
|
-
{ id: '2', content: 'Task 2', status: 'pending' },
|
|
52
|
-
{ id: '3', content: 'Task 3', status: 'pending' },
|
|
53
|
-
];
|
|
54
|
-
expect(calculateTodoProgress(todos)).toBe(33); // 33.33... rounds to 33
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('defaultDeepAgentState', () => {
|
|
59
|
-
it('should have correct default values', () => {
|
|
60
|
-
expect(defaultDeepAgentState).toEqual({
|
|
61
|
-
enabled: false,
|
|
62
|
-
todos: [],
|
|
63
|
-
subagents: [],
|
|
64
|
-
progress: 0,
|
|
65
|
-
isRunning: false,
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('should be immutable (defensive copy check)', () => {
|
|
70
|
-
const state = { ...defaultDeepAgentState };
|
|
71
|
-
state.enabled = true;
|
|
72
|
-
expect(defaultDeepAgentState.enabled).toBe(false);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe('TodoStatus type', () => {
|
|
77
|
-
it('should accept valid status values', () => {
|
|
78
|
-
const statuses: TodoStatus[] = ['pending', 'in_progress', 'completed', 'cancelled'];
|
|
79
|
-
expect(statuses).toHaveLength(4);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe('DeepAgentTodo interface', () => {
|
|
84
|
-
it('should accept minimal todo', () => {
|
|
85
|
-
const todo: DeepAgentTodo = {
|
|
86
|
-
id: '1',
|
|
87
|
-
content: 'Test task',
|
|
88
|
-
status: 'pending',
|
|
89
|
-
};
|
|
90
|
-
expect(todo.id).toBe('1');
|
|
91
|
-
expect(todo.content).toBe('Test task');
|
|
92
|
-
expect(todo.status).toBe('pending');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should accept todo with optional fields', () => {
|
|
96
|
-
const todo: DeepAgentTodo = {
|
|
97
|
-
id: '1',
|
|
98
|
-
content: 'Test task',
|
|
99
|
-
status: 'completed',
|
|
100
|
-
order: 0,
|
|
101
|
-
createdAt: '2026-01-25T00:00:00Z',
|
|
102
|
-
updatedAt: '2026-01-25T01:00:00Z',
|
|
103
|
-
};
|
|
104
|
-
expect(todo.order).toBe(0);
|
|
105
|
-
expect(todo.createdAt).toBeDefined();
|
|
106
|
-
expect(todo.updatedAt).toBeDefined();
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe('DeepAgentSubagent interface', () => {
|
|
111
|
-
it('should accept minimal subagent', () => {
|
|
112
|
-
const subagent: DeepAgentSubagent = {
|
|
113
|
-
id: '1',
|
|
114
|
-
name: 'Research Agent',
|
|
115
|
-
status: 'pending',
|
|
116
|
-
};
|
|
117
|
-
expect(subagent.id).toBe('1');
|
|
118
|
-
expect(subagent.name).toBe('Research Agent');
|
|
119
|
-
expect(subagent.status).toBe('pending');
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('should accept subagent with optional fields', () => {
|
|
123
|
-
const subagent: DeepAgentSubagent = {
|
|
124
|
-
id: '1',
|
|
125
|
-
name: 'Research Agent',
|
|
126
|
-
description: 'Researches topics',
|
|
127
|
-
status: 'completed',
|
|
128
|
-
startedAt: '2026-01-25T00:00:00Z',
|
|
129
|
-
completedAt: '2026-01-25T01:00:00Z',
|
|
130
|
-
};
|
|
131
|
-
expect(subagent.description).toBe('Researches topics');
|
|
132
|
-
expect(subagent.startedAt).toBeDefined();
|
|
133
|
-
expect(subagent.completedAt).toBeDefined();
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
describe('DeepAgentBackend', () => {
|
|
139
|
-
describe('constructor', () => {
|
|
140
|
-
it('should create backend with default options', () => {
|
|
141
|
-
const backend = new DeepAgentBackend();
|
|
142
|
-
expect(backend.id).toMatch(/^deep-agent-backend-/);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('should create backend with custom options', () => {
|
|
146
|
-
const backend = new DeepAgentBackend({
|
|
147
|
-
rootDir: '/tmp/test',
|
|
148
|
-
virtualMode: true,
|
|
149
|
-
timeout: 60000,
|
|
150
|
-
maxOutputBytes: 50000,
|
|
151
|
-
conversationId: 'test-convo',
|
|
152
|
-
});
|
|
153
|
-
expect(backend.id).toMatch(/^deep-agent-backend-/);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
describe('execute', () => {
|
|
158
|
-
it('should return error for empty command', async () => {
|
|
159
|
-
const backend = new DeepAgentBackend();
|
|
160
|
-
const result = await backend.execute('');
|
|
161
|
-
expect(result.exitCode).toBe(1);
|
|
162
|
-
expect(result.output).toContain('Error');
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('should return warning when no code executor configured', async () => {
|
|
166
|
-
const backend = new DeepAgentBackend();
|
|
167
|
-
const result = await backend.execute('echo test');
|
|
168
|
-
expect(result.exitCode).toBe(1);
|
|
169
|
-
expect(result.output).toContain('not available');
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
describe('sendEvent', () => {
|
|
174
|
-
it('should send event when SSE response is available', () => {
|
|
175
|
-
const writeData: string[] = [];
|
|
176
|
-
const mockSseResponse = {
|
|
177
|
-
write: (data: string) => writeData.push(data),
|
|
178
|
-
headersSent: false,
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
const backend = new DeepAgentBackend({
|
|
182
|
-
sseResponse: mockSseResponse,
|
|
183
|
-
conversationId: 'test-convo',
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
backend.sendEvent('test_event', { foo: 'bar' });
|
|
187
|
-
|
|
188
|
-
expect(writeData.length).toBe(1);
|
|
189
|
-
expect(writeData[0]).toContain('event: test_event');
|
|
190
|
-
expect(writeData[0]).toContain('"foo":"bar"');
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it('should not throw when SSE response is not available', () => {
|
|
194
|
-
const backend = new DeepAgentBackend();
|
|
195
|
-
expect(() => backend.sendEvent('test', {})).not.toThrow();
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
describe('emitTodoUpdate', () => {
|
|
200
|
-
it('should emit todo update event', () => {
|
|
201
|
-
const writeData: string[] = [];
|
|
202
|
-
const mockSseResponse = {
|
|
203
|
-
write: (data: string) => writeData.push(data),
|
|
204
|
-
headersSent: false,
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const todos: DeepAgentTodo[] = [
|
|
208
|
-
{ id: '1', content: 'Task 1', status: 'completed' },
|
|
209
|
-
{ id: '2', content: 'Task 2', status: 'pending' },
|
|
210
|
-
];
|
|
211
|
-
|
|
212
|
-
const backend = new DeepAgentBackend({
|
|
213
|
-
sseResponse: mockSseResponse,
|
|
214
|
-
conversationId: 'test-convo',
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
backend.emitTodoUpdate(todos);
|
|
218
|
-
|
|
219
|
-
expect(writeData.length).toBe(1);
|
|
220
|
-
expect(writeData[0]).toContain('event: deep_research');
|
|
221
|
-
expect(writeData[0]).toContain('todo_update');
|
|
222
|
-
expect(writeData[0]).toContain('test-convo');
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it('should call onTodoUpdate callback', () => {
|
|
226
|
-
const receivedTodos: DeepAgentTodo[][] = [];
|
|
227
|
-
const onTodoUpdate = (todos: DeepAgentTodo[]) => receivedTodos.push(todos);
|
|
228
|
-
|
|
229
|
-
const todos: DeepAgentTodo[] = [
|
|
230
|
-
{ id: '1', content: 'Task 1', status: 'pending' },
|
|
231
|
-
];
|
|
232
|
-
|
|
233
|
-
const backend = new DeepAgentBackend({
|
|
234
|
-
onTodoUpdate,
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
backend.emitTodoUpdate(todos);
|
|
238
|
-
|
|
239
|
-
expect(receivedTodos.length).toBe(1);
|
|
240
|
-
expect(receivedTodos[0]).toEqual(todos);
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
describe('emitSubagentUpdate', () => {
|
|
245
|
-
it('should emit subagent update event', () => {
|
|
246
|
-
const writeData: string[] = [];
|
|
247
|
-
const mockSseResponse = {
|
|
248
|
-
write: (data: string) => writeData.push(data),
|
|
249
|
-
headersSent: false,
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
const subagents: DeepAgentSubagent[] = [
|
|
253
|
-
{ id: '1', name: 'Agent 1', status: 'running' },
|
|
254
|
-
];
|
|
255
|
-
|
|
256
|
-
const backend = new DeepAgentBackend({
|
|
257
|
-
sseResponse: mockSseResponse,
|
|
258
|
-
conversationId: 'test-convo',
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
backend.emitSubagentUpdate(subagents);
|
|
262
|
-
|
|
263
|
-
expect(writeData.length).toBe(1);
|
|
264
|
-
expect(writeData[0]).toContain('event: deep_research');
|
|
265
|
-
expect(writeData[0]).toContain('subagent_update');
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('should call onSubagentUpdate callback', () => {
|
|
269
|
-
const receivedSubagents: DeepAgentSubagent[][] = [];
|
|
270
|
-
const onSubagentUpdate = (subagents: DeepAgentSubagent[]) => receivedSubagents.push(subagents);
|
|
271
|
-
|
|
272
|
-
const subagents: DeepAgentSubagent[] = [
|
|
273
|
-
{ id: '1', name: 'Agent 1', status: 'running' },
|
|
274
|
-
];
|
|
275
|
-
|
|
276
|
-
const backend = new DeepAgentBackend({
|
|
277
|
-
onSubagentUpdate,
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
backend.emitSubagentUpdate(subagents);
|
|
281
|
-
|
|
282
|
-
expect(receivedSubagents.length).toBe(1);
|
|
283
|
-
expect(receivedSubagents[0]).toEqual(subagents);
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
});
|