agent-worker 0.14.0 → 0.16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-worker",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "SDK and CLI for creating and testing agent workers with Vercel AI SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -32,14 +32,21 @@
32
32
  "prepublishOnly": "bun run build"
33
33
  },
34
34
  "dependencies": {
35
+ "@ai-sdk/anthropic": "^3.0.0",
36
+ "@ai-sdk/deepseek": "^1.0.0",
37
+ "@ai-sdk/google": "^1.0.0",
38
+ "@ai-sdk/groq": "^1.0.0",
39
+ "@ai-sdk/mistral": "^1.0.0",
40
+ "@ai-sdk/openai": "^3.0.0",
41
+ "@ai-sdk/xai": "^1.0.0",
35
42
  "@clack/prompts": "^1.0.0",
43
+ "@hono/node-server": "^1.19.9",
36
44
  "@modelcontextprotocol/sdk": "^1.26.0",
37
45
  "ai": "^6.0.69",
38
46
  "bash-tool": "^1.3.12",
39
47
  "chalk": "^5.6.2",
40
48
  "commander": "^14.0.3",
41
49
  "execa": "^9.6.1",
42
- "@hono/node-server": "^1.19.9",
43
50
  "hono": "^4.11.9",
44
51
  "just-bash": "^2.8.0",
45
52
  "nanoid": "^5.1.6",
@@ -47,16 +54,9 @@
47
54
  "string-width": "^8.1.1",
48
55
  "wrap-ansi": "^9.0.2",
49
56
  "yaml": "^2.7.0",
50
- "zod": "^3.24.1"
57
+ "zod": "^4.3.6"
51
58
  },
52
59
  "devDependencies": {
53
- "@ai-sdk/anthropic": "^3.0.0",
54
- "@ai-sdk/deepseek": "^1.0.0",
55
- "@ai-sdk/google": "^1.0.0",
56
- "@ai-sdk/groq": "^1.0.0",
57
- "@ai-sdk/mistral": "^1.0.0",
58
- "@ai-sdk/openai": "^3.0.0",
59
- "@ai-sdk/xai": "^1.0.0",
60
60
  "@types/bun": "latest",
61
61
  "@types/node": ">=22",
62
62
  "@typescript/native-preview": "^7.0.0-dev.20260203.1",
@@ -64,39 +64,6 @@
64
64
  "oxlint": "^1.43.0",
65
65
  "tsdown": "^0.20.1"
66
66
  },
67
- "peerDependencies": {
68
- "@ai-sdk/anthropic": "^3.0.0",
69
- "@ai-sdk/deepseek": "^1.0.0",
70
- "@ai-sdk/google": "^1.0.0",
71
- "@ai-sdk/groq": "^1.0.0",
72
- "@ai-sdk/mistral": "^1.0.0",
73
- "@ai-sdk/openai": "^3.0.0",
74
- "@ai-sdk/xai": "^1.0.0",
75
- "typescript": "^5"
76
- },
77
- "peerDependenciesMeta": {
78
- "@ai-sdk/anthropic": {
79
- "optional": true
80
- },
81
- "@ai-sdk/openai": {
82
- "optional": true
83
- },
84
- "@ai-sdk/deepseek": {
85
- "optional": true
86
- },
87
- "@ai-sdk/google": {
88
- "optional": true
89
- },
90
- "@ai-sdk/groq": {
91
- "optional": true
92
- },
93
- "@ai-sdk/mistral": {
94
- "optional": true
95
- },
96
- "@ai-sdk/xai": {
97
- "optional": true
98
- }
99
- },
100
67
  "repository": {
101
68
  "type": "git",
102
69
  "url": "https://github.com/lidessen/moniro.git",
@@ -1,4 +0,0 @@
1
- import { A as extractMentions, B as EventLog, C as CONTEXT_DEFAULTS, D as RESOURCE_SCHEME, E as RESOURCE_PREFIX, F as formatProposalList, I as createLogTool, L as formatInbox, M as shouldUseResource, N as createContextMCPServer, O as calculatePriority, P as formatProposal, R as formatToolParams, S as ContextProviderImpl, T as MESSAGE_LENGTH_THRESHOLD, _ as createFileContextProvider, b as FileStorage, g as FileContextProvider, j as generateResourceId, k as createResourceRef, v as getDefaultContextDir, w as MENTION_PATTERN, x as MemoryStorage, y as resolveContextDir, z as getAgentId } from "./cli/index.mjs";
2
- import { n as createMemoryContextProvider, t as MemoryContextProvider } from "./memory-provider-0nuDxzYQ.mjs";
3
-
4
- export { createFileContextProvider };
@@ -1,301 +0,0 @@
1
- import "./backends-C6WBIn9H.mjs";
2
- import { C as CONTEXT_DEFAULTS, a as getBackendByType, c as createAgentController, d as generateWorkflowMCPConfig, f as buildAgentPrompt, i as createSilentLogger, l as runSdkAgent, m as CONTROLLER_DEFAULTS, n as createWiredController, o as getBackendForModel, p as formatInbox, r as createChannelLogger, s as checkWorkflowIdle, t as createMinimalRuntime, u as runMockAgent, y as resolveContextDir } from "./cli/index.mjs";
3
- import "./memory-provider-0nuDxzYQ.mjs";
4
- import { createWorkflowProvider, initWorkflow, n as interpolate, runWorkflowWithControllers, shutdownControllers, t as createContext } from "./runner-DV86expc.mjs";
5
- import { existsSync, readFileSync } from "node:fs";
6
- import { basename, dirname, join, resolve } from "node:path";
7
- import { parse } from "yaml";
8
-
9
- //#region src/workflow/parser.ts
10
- /**
11
- * Workflow file parser
12
- */
13
- /**
14
- * Parse a workflow file
15
- */
16
- async function parseWorkflowFile(filePath, options) {
17
- const absolutePath = resolve(filePath);
18
- const workflow = options?.workflow ?? options?.instance ?? "global";
19
- const tag = options?.tag ?? "main";
20
- if (!existsSync(absolutePath)) throw new Error(`Workflow file not found: ${absolutePath}`);
21
- const content = readFileSync(absolutePath, "utf-8");
22
- const workflowDir = dirname(absolutePath);
23
- let raw;
24
- try {
25
- raw = parse(content);
26
- } catch (error) {
27
- throw new Error(`Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
28
- }
29
- const validation = validateWorkflow(raw);
30
- if (!validation.valid) {
31
- const messages = validation.errors.map((e) => ` - ${e.path}: ${e.message}`).join("\n");
32
- throw new Error(`Invalid workflow file:\n${messages}`);
33
- }
34
- const name = raw.name || basename(absolutePath, ".yml").replace(".yaml", "");
35
- const agents = {};
36
- for (const [agentName, agentDef] of Object.entries(raw.agents)) agents[agentName] = await resolveAgent(agentDef, workflowDir);
37
- return {
38
- name,
39
- filePath: absolutePath,
40
- agents,
41
- context: resolveContext(raw.context, workflowDir, name, workflow, tag),
42
- setup: raw.setup || [],
43
- kickoff: raw.kickoff
44
- };
45
- }
46
- /**
47
- * Resolve context configuration
48
- *
49
- * - undefined (not set): default file provider enabled
50
- * - null: default file provider enabled (YAML `context:` syntax)
51
- * - false: explicitly disabled
52
- * - { provider: 'file', config?: { dir | bind } }: file provider (ephemeral or persistent)
53
- * - { provider: 'memory' }: memory provider (for testing)
54
- */
55
- function resolveContext(config, workflowDir, workflowName, workflow, tag) {
56
- const resolve = (template) => resolveContextDir(template, {
57
- workflowName,
58
- workflow,
59
- tag,
60
- instance: workflow,
61
- baseDir: workflowDir
62
- });
63
- if (config === false) return;
64
- if (config === void 0 || config === null) return {
65
- provider: "file",
66
- dir: resolve(CONTEXT_DEFAULTS.dir)
67
- };
68
- if (config.provider === "memory") return {
69
- provider: "memory",
70
- documentOwner: config.documentOwner
71
- };
72
- const bindPath = config.config?.bind;
73
- if (bindPath) return {
74
- provider: "file",
75
- dir: resolve(bindPath),
76
- persistent: true,
77
- documentOwner: config.documentOwner
78
- };
79
- return {
80
- provider: "file",
81
- dir: resolve(config.config?.dir || CONTEXT_DEFAULTS.dir),
82
- documentOwner: config.documentOwner
83
- };
84
- }
85
- /**
86
- * Resolve agent definition (load system prompt from file if needed)
87
- *
88
- * Also transforms `wakeup` and `wakeup_prompt` fields into a `ScheduleConfig`
89
- * object, which is the format expected by the daemon and controller layers
90
- * for setting up periodic wakeup timers.
91
- */
92
- async function resolveAgent(agent, workflowDir) {
93
- let resolvedSystemPrompt = agent.system_prompt;
94
- if (resolvedSystemPrompt?.endsWith(".txt") || resolvedSystemPrompt?.endsWith(".md")) {
95
- const promptPath = resolvedSystemPrompt.startsWith("/") ? resolvedSystemPrompt : join(workflowDir, resolvedSystemPrompt);
96
- if (existsSync(promptPath)) resolvedSystemPrompt = readFileSync(promptPath, "utf-8");
97
- }
98
- let schedule;
99
- if (agent.wakeup !== void 0) {
100
- schedule = { wakeup: agent.wakeup };
101
- if (agent.wakeup_prompt) schedule.prompt = agent.wakeup_prompt;
102
- }
103
- return {
104
- ...agent,
105
- resolvedSystemPrompt,
106
- schedule
107
- };
108
- }
109
- /**
110
- * Validate workflow structure
111
- */
112
- function validateWorkflow(workflow) {
113
- const errors = [];
114
- if (!workflow || typeof workflow !== "object") {
115
- errors.push({
116
- path: "",
117
- message: "Workflow must be an object"
118
- });
119
- return {
120
- valid: false,
121
- errors
122
- };
123
- }
124
- const w = workflow;
125
- if (!w.agents || typeof w.agents !== "object") errors.push({
126
- path: "agents",
127
- message: "Required field \"agents\" must be an object"
128
- });
129
- else {
130
- const agents = w.agents;
131
- for (const [name, agent] of Object.entries(agents)) validateAgent(name, agent, errors);
132
- }
133
- if (w.context !== void 0 && w.context !== null && w.context !== false) validateContext(w.context, errors);
134
- if (w.setup !== void 0) if (!Array.isArray(w.setup)) errors.push({
135
- path: "setup",
136
- message: "Setup must be an array"
137
- });
138
- else for (let i = 0; i < w.setup.length; i++) validateSetupTask(`setup[${i}]`, w.setup[i], errors);
139
- if (w.kickoff !== void 0 && typeof w.kickoff !== "string") errors.push({
140
- path: "kickoff",
141
- message: "Kickoff must be a string"
142
- });
143
- return {
144
- valid: errors.length === 0,
145
- errors
146
- };
147
- }
148
- function validateContext(context, errors) {
149
- if (typeof context !== "object" || context === null) {
150
- errors.push({
151
- path: "context",
152
- message: "Context must be an object or false"
153
- });
154
- return;
155
- }
156
- const c = context;
157
- if (!c.provider || typeof c.provider !== "string") {
158
- errors.push({
159
- path: "context.provider",
160
- message: "Context requires \"provider\" field (file or memory)"
161
- });
162
- return;
163
- }
164
- if (c.provider !== "file" && c.provider !== "memory") {
165
- errors.push({
166
- path: "context.provider",
167
- message: "Context provider must be \"file\" or \"memory\""
168
- });
169
- return;
170
- }
171
- if (c.documentOwner !== void 0 && typeof c.documentOwner !== "string") errors.push({
172
- path: "context.documentOwner",
173
- message: "Context documentOwner must be a string"
174
- });
175
- if (c.provider === "file" && c.config !== void 0) {
176
- if (typeof c.config !== "object" || c.config === null) {
177
- errors.push({
178
- path: "context.config",
179
- message: "Context config must be an object"
180
- });
181
- return;
182
- }
183
- const cfg = c.config;
184
- if (cfg.dir !== void 0 && cfg.bind !== void 0) {
185
- errors.push({
186
- path: "context.config",
187
- message: "\"dir\" and \"bind\" are mutually exclusive — use one or the other"
188
- });
189
- return;
190
- }
191
- if (cfg.dir !== void 0 && typeof cfg.dir !== "string") errors.push({
192
- path: "context.config.dir",
193
- message: "Context config dir must be a string"
194
- });
195
- if (cfg.bind !== void 0 && typeof cfg.bind !== "string") errors.push({
196
- path: "context.config.bind",
197
- message: "Context config bind must be a string path"
198
- });
199
- }
200
- }
201
- function validateSetupTask(path, task, errors) {
202
- if (!task || typeof task !== "object") {
203
- errors.push({
204
- path,
205
- message: "Setup task must be an object"
206
- });
207
- return;
208
- }
209
- const t = task;
210
- if (!t.shell || typeof t.shell !== "string") errors.push({
211
- path: `${path}.shell`,
212
- message: "Setup task requires \"shell\" field as string"
213
- });
214
- if (t.as !== void 0 && typeof t.as !== "string") errors.push({
215
- path: `${path}.as`,
216
- message: "Setup task \"as\" field must be a string"
217
- });
218
- }
219
- /** Backends that don't require an explicit model field */
220
- const CLI_BACKENDS = [
221
- "claude",
222
- "cursor",
223
- "codex",
224
- "opencode",
225
- "mock"
226
- ];
227
- function validateAgent(name, agent, errors) {
228
- const path = `agents.${name}`;
229
- if (!agent || typeof agent !== "object") {
230
- errors.push({
231
- path,
232
- message: "Agent must be an object"
233
- });
234
- return;
235
- }
236
- const a = agent;
237
- const backend = typeof a.backend === "string" ? a.backend : "default";
238
- if (a.model !== void 0 && typeof a.model !== "string") errors.push({
239
- path: `${path}.model`,
240
- message: "Field \"model\" must be a string"
241
- });
242
- else if (!a.model && !CLI_BACKENDS.includes(backend)) errors.push({
243
- path: `${path}.model`,
244
- message: "Required field \"model\" must be a string (required for default backend)"
245
- });
246
- if (a.system_prompt !== void 0 && typeof a.system_prompt !== "string") errors.push({
247
- path: `${path}.system_prompt`,
248
- message: "Optional field \"system_prompt\" must be a string"
249
- });
250
- if (a.tools !== void 0 && !Array.isArray(a.tools)) errors.push({
251
- path: `${path}.tools`,
252
- message: "Optional field \"tools\" must be an array"
253
- });
254
- if (a.wakeup !== void 0) {
255
- if (typeof a.wakeup !== "string" && typeof a.wakeup !== "number") errors.push({
256
- path: `${path}.wakeup`,
257
- message: "Field \"wakeup\" must be a string (duration or cron) or number (ms)"
258
- });
259
- else if (typeof a.wakeup === "number" && a.wakeup <= 0) errors.push({
260
- path: `${path}.wakeup`,
261
- message: "Field \"wakeup\" must be a positive number when specified as ms"
262
- });
263
- }
264
- if (a.wakeup_prompt !== void 0) {
265
- if (typeof a.wakeup_prompt !== "string") errors.push({
266
- path: `${path}.wakeup_prompt`,
267
- message: "Field \"wakeup_prompt\" must be a string"
268
- });
269
- if (a.wakeup === void 0) errors.push({
270
- path: `${path}.wakeup_prompt`,
271
- message: "Field \"wakeup_prompt\" can only be used when \"wakeup\" is also specified"
272
- });
273
- }
274
- if (a.provider !== void 0) {
275
- if (typeof a.provider === "string") {} else if (typeof a.provider === "object" && a.provider !== null && !Array.isArray(a.provider)) {
276
- const p = a.provider;
277
- if (!p.name || typeof p.name !== "string") errors.push({
278
- path: `${path}.provider.name`,
279
- message: "Field \"provider.name\" is required and must be a string"
280
- });
281
- if (p.base_url !== void 0 && typeof p.base_url !== "string") errors.push({
282
- path: `${path}.provider.base_url`,
283
- message: "Field \"provider.base_url\" must be a string"
284
- });
285
- if (p.api_key !== void 0 && typeof p.api_key !== "string") errors.push({
286
- path: `${path}.provider.api_key`,
287
- message: "Field \"provider.api_key\" must be a string"
288
- });
289
- } else errors.push({
290
- path: `${path}.provider`,
291
- message: "Field \"provider\" must be a string or object with { name, base_url?, api_key? }"
292
- });
293
- if (CLI_BACKENDS.includes(backend) && backend !== "mock") errors.push({
294
- path: `${path}.provider`,
295
- message: `Field "provider" is ignored for CLI backend "${backend}" (only works with default backend)`
296
- });
297
- }
298
- }
299
-
300
- //#endregion
301
- export { parseWorkflowFile, runWorkflowWithControllers, shutdownControllers };