@zerone-agent/open-agent-sdk 0.5.2 → 0.5.4

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.
@@ -1,161 +0,0 @@
1
- /**
2
- * AgentTool - Spawn subagents for parallel/delegated work
3
- *
4
- * Supports built-in agents (Explore, Plan) and custom agent definitions.
5
- * Agents run as nested query loops with their own context and tool sets.
6
- * Subagent events are propagated to the parent stream via context.emitEvent.
7
- */
8
- import { QueryEngine } from '../engine.js';
9
- import { getAllBaseTools, filterTools } from './index.js';
10
- import { createProvider } from '../providers/index.js';
11
- // Store for registered agent definitions
12
- let registeredAgents = {};
13
- /**
14
- * Register agent definitions for the AgentTool to use.
15
- */
16
- export function registerAgents(agents) {
17
- registeredAgents = { ...registeredAgents, ...agents };
18
- }
19
- /**
20
- * Clear registered agents.
21
- */
22
- export function clearAgents() {
23
- registeredAgents = {};
24
- }
25
- /**
26
- * Built-in agent definitions.
27
- */
28
- const BUILTIN_AGENTS = {
29
- Explore: {
30
- description: 'Fast agent for exploring codebases. Use for finding files, searching code, and answering questions about the codebase.',
31
- prompt: 'You are a codebase exploration agent. Search through files and code to answer questions. Be thorough but efficient. Use Glob to find files, Grep to search content, and Read to examine files.',
32
- tools: ['Read', 'Glob', 'Grep', 'Bash'],
33
- },
34
- Plan: {
35
- description: 'Software architect agent for designing implementation plans. Returns step-by-step plans and identifies critical files.',
36
- prompt: 'You are a software architect. Design implementation plans for the given task. Identify critical files, consider trade-offs, and provide step-by-step plans. Use search tools to understand the codebase before planning.',
37
- tools: ['Read', 'Glob', 'Grep', 'Bash'],
38
- },
39
- };
40
- export const AgentTool = {
41
- name: 'Agent',
42
- description: 'Launch a subagent to handle complex, multi-step tasks autonomously. Subagents have their own context and can run specialized tool sets.',
43
- inputSchema: {
44
- type: 'object',
45
- properties: {
46
- prompt: {
47
- type: 'string',
48
- description: 'The task for the agent to perform',
49
- },
50
- description: {
51
- type: 'string',
52
- description: 'A short (3-5 word) description of the task',
53
- },
54
- subagent_type: {
55
- type: 'string',
56
- description: 'The type of agent to use (e.g., "Explore", "Plan", or a custom agent name)',
57
- },
58
- model: {
59
- type: 'string',
60
- description: 'Optional model override for this agent',
61
- },
62
- name: {
63
- type: 'string',
64
- description: 'Name for the spawned agent',
65
- },
66
- run_in_background: {
67
- type: 'boolean',
68
- description: 'Whether to run in background',
69
- },
70
- },
71
- required: ['prompt', 'description'],
72
- },
73
- isReadOnly: () => false,
74
- isConcurrencySafe: () => false,
75
- isEnabled: () => true,
76
- async prompt() {
77
- return 'Launch a subagent to handle complex tasks autonomously.';
78
- },
79
- async call(input, context) {
80
- const agentType = input.subagent_type || 'general-purpose';
81
- const agentDef = registeredAgents[agentType] || BUILTIN_AGENTS[agentType];
82
- let tools = getAllBaseTools();
83
- if (agentDef?.tools) {
84
- tools = filterTools(tools, agentDef.tools);
85
- }
86
- tools = tools.filter(t => t.name !== 'Agent');
87
- tools = tools.filter(t => t.name !== 'Memory');
88
- const systemPrompt = agentDef?.prompt ||
89
- 'You are a helpful assistant. Complete the given task using the available tools.';
90
- const subModel = input.model || context.model || process.env.OPENAGENT_MODEL || 'claude-sonnet-4-6';
91
- const provider = context.provider ?? createProvider((context.apiType || process.env.OPENAGENT_API_TYPE) || 'anthropic-messages', {
92
- apiKey: process.env.OPENAGENT_API_KEY,
93
- baseURL: process.env.OPENAGENT_BASE_URL,
94
- });
95
- const subSessionId = crypto.randomUUID();
96
- const engine = new QueryEngine({
97
- cwd: context.cwd,
98
- model: subModel,
99
- provider,
100
- tools,
101
- systemPrompt,
102
- agentId: agentType,
103
- maxTurns: agentDef?.maxTurns || 10,
104
- maxTokens: context.maxTokens ?? 65536,
105
- canUseTool: async () => ({ behavior: 'allow' }),
106
- includePartialMessages: true,
107
- sessionId: subSessionId,
108
- allowedSkills: agentDef?.skills,
109
- settingSources: context.settingSources,
110
- abortSignal: context.abortSignal,
111
- });
112
- const emitEvent = context.emitEvent;
113
- let resultText = '';
114
- let toolCalls = [];
115
- try {
116
- for await (const event of engine.submitMessage(input.prompt)) {
117
- if (context.abortSignal?.aborted)
118
- break;
119
- if (event.type === 'assistant') {
120
- for (const block of event.message.content) {
121
- if ('text' in block && block.text) {
122
- resultText = block.text;
123
- }
124
- if ('name' in block) {
125
- toolCalls.push(block.name);
126
- }
127
- }
128
- }
129
- if (emitEvent) {
130
- const propagatedTypes = ['assistant', 'partial_message', 'tool_result', 'system'];
131
- if (propagatedTypes.includes(event.type)) {
132
- emitEvent({
133
- type: 'subagent',
134
- parent_tool_use_id: '',
135
- session_id: subSessionId,
136
- event: event,
137
- });
138
- }
139
- }
140
- }
141
- }
142
- catch (err) {
143
- return {
144
- type: 'tool_result',
145
- tool_use_id: '',
146
- content: `Subagent error: ${err.message}`,
147
- is_error: true,
148
- };
149
- }
150
- const output = resultText || '(Subagent completed with no text output)';
151
- const toolSummary = toolCalls.length > 0
152
- ? `\n[Tools used: ${toolCalls.join(', ')}]`
153
- : '';
154
- return {
155
- type: 'tool_result',
156
- tool_use_id: '',
157
- content: output + toolSummary,
158
- };
159
- },
160
- };
161
- //# sourceMappingURL=agent-tool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-tool.js","sourceRoot":"","sources":["../../src/tools/agent-tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,cAAc,EAAgB,MAAM,uBAAuB,CAAA;AAEpE,yCAAyC;AACzC,IAAI,gBAAgB,GAAoC,EAAE,CAAA;AAE1D;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAAuC;IACpE,gBAAgB,GAAG,EAAE,GAAG,gBAAgB,EAAE,GAAG,MAAM,EAAE,CAAA;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,gBAAgB,GAAG,EAAE,CAAA;A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CAAC,IAAI,CAAC,EAAE,CAAC;wBACzC,SAAS,CAAC;4BACR,IAAI,EAAE,UAAU;4BAChB,kBAAkB,EAAE,EAAE;4BACtB,UAAU,EAAE,YAAY;4BACxB,KAAK,EAAE,KAAY;yBACpB,CAAC,CAAA;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO;gBACL,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,EAAE;gBACf,OAAO,EAAE,mBAAmB,GAAG,CAAC,OAAO,EAAE;gBACzC,QAAQ,EAAE,IAAI;aACf,CAAA;QACH,CAAC;QAED,MAAM,MAAM,GAAG,UAAU,IAAI,0CAA0C,CAAA;QACvE,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC;YACtC,CAAC,CAAC,kBAAkB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YAC3C,CAAC,CAAC,EAAE,CAAA;QAEN,OAAO;YACL,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,EAAE;YACf,OAAO,EAAE,MAAM,GAAG,WAAW;SAC9B,CAAA;IACH,CAAC;CACF,CAAA"}
@@ -1,48 +0,0 @@
1
- /**
2
- * Task Management Tools
3
- *
4
- * TaskCreate, TaskList, TaskUpdate, TaskGet, TaskStop, TaskOutput
5
- *
6
- * Provides in-memory task tracking for agent coordination.
7
- * Tasks persist across turns within a session.
8
- */
9
- import type { ToolDefinition } from '../types.js';
10
- /**
11
- * Task status.
12
- */
13
- export type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'cancelled';
14
- /**
15
- * Task entry.
16
- */
17
- export interface Task {
18
- id: string;
19
- subject: string;
20
- description?: string;
21
- status: TaskStatus;
22
- owner?: string;
23
- createdAt: string;
24
- updatedAt: string;
25
- output?: string;
26
- blockedBy?: string[];
27
- blocks?: string[];
28
- metadata?: Record<string, unknown>;
29
- }
30
- /**
31
- * Get all tasks.
32
- */
33
- export declare function getAllTasks(): Task[];
34
- /**
35
- * Get a task by ID.
36
- */
37
- export declare function getTask(id: string): Task | undefined;
38
- /**
39
- * Clear all tasks (for session reset).
40
- */
41
- export declare function clearTasks(): void;
42
- export declare const TaskCreateTool: ToolDefinition;
43
- export declare const TaskListTool: ToolDefinition;
44
- export declare const TaskUpdateTool: ToolDefinition;
45
- export declare const TaskGetTool: ToolDefinition;
46
- export declare const TaskStopTool: ToolDefinition;
47
- export declare const TaskOutputTool: ToolDefinition;
48
- //# sourceMappingURL=task-tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"task-tools.d.ts","sourceRoot":"","sources":["../../src/tools/task-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,aAAa,CAAA;AAE7D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAA;AAEzF;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,UAAU,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AASD;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,EAAE,CAEpC;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAEpD;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAGjC;AAMD,eAAO,MAAM,cAAc,EAAE,cAoC5B,CAAA;AAMD,eAAO,MAAM,YAAY,EAAE,cAsC1B,CAAA;AAMD,eAAO,MAAM,cAAc,EAAE,cAoC5B,CAAA;AAMD,eAAO,MAAM,WAAW,EAAE,cA0BzB,CAAA;AAMD,eAAO,MAAM,YAAY,EAAE,cA+B1B,CAAA;AAMD,eAAO,MAAM,cAAc,EAAE,cA0B5B,CAAA"}
@@ -1,242 +0,0 @@
1
- /**
2
- * Task Management Tools
3
- *
4
- * TaskCreate, TaskList, TaskUpdate, TaskGet, TaskStop, TaskOutput
5
- *
6
- * Provides in-memory task tracking for agent coordination.
7
- * Tasks persist across turns within a session.
8
- */
9
- /**
10
- * Global task store (shared across tools in a session).
11
- */
12
- const taskStore = new Map();
13
- let taskCounter = 0;
14
- /**
15
- * Get all tasks.
16
- */
17
- export function getAllTasks() {
18
- return Array.from(taskStore.values());
19
- }
20
- /**
21
- * Get a task by ID.
22
- */
23
- export function getTask(id) {
24
- return taskStore.get(id);
25
- }
26
- /**
27
- * Clear all tasks (for session reset).
28
- */
29
- export function clearTasks() {
30
- taskStore.clear();
31
- taskCounter = 0;
32
- }
33
- // ============================================================================
34
- // TaskCreateTool
35
- // ============================================================================
36
- export const TaskCreateTool = {
37
- name: 'TaskCreate',
38
- description: 'Create a new task for tracking work progress. Tasks help organize multi-step operations.',
39
- inputSchema: {
40
- type: 'object',
41
- properties: {
42
- subject: { type: 'string', description: 'Short task title' },
43
- description: { type: 'string', description: 'Detailed task description' },
44
- owner: { type: 'string', description: 'Task owner/assignee' },
45
- status: { type: 'string', enum: ['pending', 'in_progress'], description: 'Initial status' },
46
- },
47
- required: ['subject'],
48
- },
49
- isReadOnly: () => false,
50
- isConcurrencySafe: () => true,
51
- isEnabled: () => true,
52
- async prompt() { return 'Create a task for tracking progress.'; },
53
- async call(input) {
54
- const id = `task_${++taskCounter}`;
55
- const task = {
56
- id,
57
- subject: input.subject,
58
- description: input.description,
59
- status: input.status || 'pending',
60
- owner: input.owner,
61
- createdAt: new Date().toISOString(),
62
- updatedAt: new Date().toISOString(),
63
- };
64
- taskStore.set(id, task);
65
- return {
66
- type: 'tool_result',
67
- tool_use_id: '',
68
- content: `Task created: ${id} - "${task.subject}" (${task.status})`,
69
- };
70
- },
71
- };
72
- // ============================================================================
73
- // TaskListTool
74
- // ============================================================================
75
- export const TaskListTool = {
76
- name: 'TaskList',
77
- description: 'List all tasks with their status, ownership, and dependencies.',
78
- inputSchema: {
79
- type: 'object',
80
- properties: {
81
- status: { type: 'string', description: 'Filter by status' },
82
- owner: { type: 'string', description: 'Filter by owner' },
83
- },
84
- },
85
- isReadOnly: () => true,
86
- isConcurrencySafe: () => true,
87
- isEnabled: () => true,
88
- async prompt() { return 'List tasks.'; },
89
- async call(input) {
90
- let tasks = getAllTasks();
91
- if (input.status) {
92
- tasks = tasks.filter(t => t.status === input.status);
93
- }
94
- if (input.owner) {
95
- tasks = tasks.filter(t => t.owner === input.owner);
96
- }
97
- if (tasks.length === 0) {
98
- return { type: 'tool_result', tool_use_id: '', content: 'No tasks found.' };
99
- }
100
- const lines = tasks.map(t => `[${t.id}] ${t.status.toUpperCase()} - ${t.subject}${t.owner ? ` (owner: ${t.owner})` : ''}`);
101
- return {
102
- type: 'tool_result',
103
- tool_use_id: '',
104
- content: lines.join('\n'),
105
- };
106
- },
107
- };
108
- // ============================================================================
109
- // TaskUpdateTool
110
- // ============================================================================
111
- export const TaskUpdateTool = {
112
- name: 'TaskUpdate',
113
- description: 'Update a task\'s status, description, or other properties.',
114
- inputSchema: {
115
- type: 'object',
116
- properties: {
117
- id: { type: 'string', description: 'Task ID' },
118
- status: { type: 'string', enum: ['pending', 'in_progress', 'completed', 'failed', 'cancelled'] },
119
- description: { type: 'string', description: 'Updated description' },
120
- owner: { type: 'string', description: 'New owner' },
121
- output: { type: 'string', description: 'Task output/result' },
122
- },
123
- required: ['id'],
124
- },
125
- isReadOnly: () => false,
126
- isConcurrencySafe: () => true,
127
- isEnabled: () => true,
128
- async prompt() { return 'Update a task.'; },
129
- async call(input) {
130
- const task = taskStore.get(input.id);
131
- if (!task) {
132
- return { type: 'tool_result', tool_use_id: '', content: `Task not found: ${input.id}`, is_error: true };
133
- }
134
- if (input.status)
135
- task.status = input.status;
136
- if (input.description)
137
- task.description = input.description;
138
- if (input.owner)
139
- task.owner = input.owner;
140
- if (input.output)
141
- task.output = input.output;
142
- task.updatedAt = new Date().toISOString();
143
- return {
144
- type: 'tool_result',
145
- tool_use_id: '',
146
- content: `Task updated: ${task.id} - ${task.status} - "${task.subject}"`,
147
- };
148
- },
149
- };
150
- // ============================================================================
151
- // TaskGetTool
152
- // ============================================================================
153
- export const TaskGetTool = {
154
- name: 'TaskGet',
155
- description: 'Get full details of a specific task.',
156
- inputSchema: {
157
- type: 'object',
158
- properties: {
159
- id: { type: 'string', description: 'Task ID' },
160
- },
161
- required: ['id'],
162
- },
163
- isReadOnly: () => true,
164
- isConcurrencySafe: () => true,
165
- isEnabled: () => true,
166
- async prompt() { return 'Get task details.'; },
167
- async call(input) {
168
- const task = taskStore.get(input.id);
169
- if (!task) {
170
- return { type: 'tool_result', tool_use_id: '', content: `Task not found: ${input.id}`, is_error: true };
171
- }
172
- return {
173
- type: 'tool_result',
174
- tool_use_id: '',
175
- content: JSON.stringify(task, null, 2),
176
- };
177
- },
178
- };
179
- // ============================================================================
180
- // TaskStopTool
181
- // ============================================================================
182
- export const TaskStopTool = {
183
- name: 'TaskStop',
184
- description: 'Stop/cancel a running task.',
185
- inputSchema: {
186
- type: 'object',
187
- properties: {
188
- id: { type: 'string', description: 'Task ID to stop' },
189
- reason: { type: 'string', description: 'Reason for stopping' },
190
- },
191
- required: ['id'],
192
- },
193
- isReadOnly: () => false,
194
- isConcurrencySafe: () => true,
195
- isEnabled: () => true,
196
- async prompt() { return 'Stop a task.'; },
197
- async call(input) {
198
- const task = taskStore.get(input.id);
199
- if (!task) {
200
- return { type: 'tool_result', tool_use_id: '', content: `Task not found: ${input.id}`, is_error: true };
201
- }
202
- task.status = 'cancelled';
203
- task.updatedAt = new Date().toISOString();
204
- if (input.reason)
205
- task.output = `Stopped: ${input.reason}`;
206
- return {
207
- type: 'tool_result',
208
- tool_use_id: '',
209
- content: `Task stopped: ${task.id}`,
210
- };
211
- },
212
- };
213
- // ============================================================================
214
- // TaskOutputTool
215
- // ============================================================================
216
- export const TaskOutputTool = {
217
- name: 'TaskOutput',
218
- description: 'Get the output/result of a task.',
219
- inputSchema: {
220
- type: 'object',
221
- properties: {
222
- id: { type: 'string', description: 'Task ID' },
223
- },
224
- required: ['id'],
225
- },
226
- isReadOnly: () => true,
227
- isConcurrencySafe: () => true,
228
- isEnabled: () => true,
229
- async prompt() { return 'Get task output.'; },
230
- async call(input) {
231
- const task = taskStore.get(input.id);
232
- if (!task) {
233
- return { type: 'tool_result', tool_use_id: '', content: `Task not found: ${input.id}`, is_error: true };
234
- }
235
- return {
236
- type: 'tool_result',
237
- tool_use_id: '',
238
- content: task.output || '(no output yet)',
239
- };
240
- },
241
- };
242
- //# sourceMappingURL=task-tools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"task-tools.js","sourceRoot":"","sources":["../../src/tools/task-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA0BH;;GAEG;AACH,MAAM,SAAS,GAAG,IAAI,GAAG,EAAgB,CAAA;AAEzC,IAAI,WAAW,GAAG,CAAC,CAAA;AAEnB;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAA;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,EAAU;IAChC,OAAO,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,SAAS,CAAC,KAAK,EAAE,CAAA;IACjB,WAAW,GAAG,CAAC,CA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