agent-worker 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{backends-CziIqKRg.mjs → backends-C6WBIn9H.mjs} +66 -16
- package/dist/{backends-BWzhErjT.mjs → backends-Cv0oM9Ru.mjs} +1 -1
- package/dist/cli/index.mjs +1415 -104
- package/dist/context-CzqQeThq.mjs +4 -0
- package/dist/index.d.mts +67 -60
- package/dist/index.mjs +446 -3
- package/dist/{memory-provider-BtLYtdQH.mjs → memory-provider-0nuDxzYQ.mjs} +1 -1
- package/dist/runner-DV86expc.mjs +663 -0
- package/dist/{workflow-CIE3WPNx.mjs → workflow-DogkVjOs.mjs} +35 -6
- package/package.json +2 -1
- package/dist/context-BqEyt2SF.mjs +0 -4
- package/dist/logger-Bfdo83xL.mjs +0 -63
- package/dist/runner-CnxROIev.mjs +0 -1496
- package/dist/worker-DBJ8136Q.mjs +0 -448
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import "./backends-
|
|
2
|
-
import {
|
|
3
|
-
import "./memory-provider-
|
|
4
|
-
import {
|
|
5
|
-
import { a as runSdkAgent, c as buildAgentPrompt, createWorkflowProvider, d as createContext, f as interpolate, i as createAgentController, initWorkflow, l as formatInbox, n as getBackendForModel, o as runMockAgent, r as checkWorkflowIdle, runWorkflowWithControllers, s as generateWorkflowMCPConfig, shutdownControllers, t as getBackendByType, u as CONTROLLER_DEFAULTS } from "./runner-CnxROIev.mjs";
|
|
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";
|
|
6
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
6
|
import { basename, dirname, join, resolve } from "node:path";
|
|
8
7
|
import { parse } from "yaml";
|
|
@@ -85,6 +84,10 @@ function resolveContext(config, workflowDir, workflowName, workflow, tag) {
|
|
|
85
84
|
}
|
|
86
85
|
/**
|
|
87
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.
|
|
88
91
|
*/
|
|
89
92
|
async function resolveAgent(agent, workflowDir) {
|
|
90
93
|
let resolvedSystemPrompt = agent.system_prompt;
|
|
@@ -92,9 +95,15 @@ async function resolveAgent(agent, workflowDir) {
|
|
|
92
95
|
const promptPath = resolvedSystemPrompt.startsWith("/") ? resolvedSystemPrompt : join(workflowDir, resolvedSystemPrompt);
|
|
93
96
|
if (existsSync(promptPath)) resolvedSystemPrompt = readFileSync(promptPath, "utf-8");
|
|
94
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
|
+
}
|
|
95
103
|
return {
|
|
96
104
|
...agent,
|
|
97
|
-
resolvedSystemPrompt
|
|
105
|
+
resolvedSystemPrompt,
|
|
106
|
+
schedule
|
|
98
107
|
};
|
|
99
108
|
}
|
|
100
109
|
/**
|
|
@@ -242,6 +251,26 @@ function validateAgent(name, agent, errors) {
|
|
|
242
251
|
path: `${path}.tools`,
|
|
243
252
|
message: "Optional field \"tools\" must be an array"
|
|
244
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
|
+
}
|
|
245
274
|
if (a.provider !== void 0) {
|
|
246
275
|
if (typeof a.provider === "string") {} else if (typeof a.provider === "object" && a.provider !== null && !Array.isArray(a.provider)) {
|
|
247
276
|
const p = a.provider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"@ai-sdk/openai": "^3.0.0",
|
|
59
59
|
"@ai-sdk/xai": "^1.0.0",
|
|
60
60
|
"@types/bun": "latest",
|
|
61
|
+
"@types/node": ">=22",
|
|
61
62
|
"@typescript/native-preview": "^7.0.0-dev.20260203.1",
|
|
62
63
|
"oxfmt": "^0.28.0",
|
|
63
64
|
"oxlint": "^1.43.0",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { C as formatToolParams, S as formatInbox, T as EventLog, _ as shouldUseResource, a as FileStorage, b as formatProposalList, c as CONTEXT_DEFAULTS, d as RESOURCE_PREFIX, f as RESOURCE_SCHEME, g as generateResourceId, h as extractMentions, i as resolveContextDir, l as MENTION_PATTERN, m as createResourceRef, n as createFileContextProvider, o as MemoryStorage, p as calculatePriority, r as getDefaultContextDir, s as ContextProviderImpl, t as FileContextProvider, u as MESSAGE_LENGTH_THRESHOLD, v as createContextMCPServer, w as getAgentId, x as createLogTool, y as formatProposal } from "./cli/index.mjs";
|
|
2
|
-
import { n as createMemoryContextProvider, t as MemoryContextProvider } from "./memory-provider-BtLYtdQH.mjs";
|
|
3
|
-
|
|
4
|
-
export { createFileContextProvider };
|
package/dist/logger-Bfdo83xL.mjs
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
//#region src/workflow/logger.ts
|
|
2
|
-
/**
|
|
3
|
-
* Create a silent logger (no output)
|
|
4
|
-
*/
|
|
5
|
-
function createSilentLogger() {
|
|
6
|
-
const noop = () => {};
|
|
7
|
-
return {
|
|
8
|
-
debug: noop,
|
|
9
|
-
info: noop,
|
|
10
|
-
warn: noop,
|
|
11
|
-
error: noop,
|
|
12
|
-
isDebug: () => false,
|
|
13
|
-
child: () => createSilentLogger()
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Create a logger that writes to the channel.
|
|
18
|
-
*
|
|
19
|
-
* - info/warn/error → channel entry with kind="system" (always shown to user)
|
|
20
|
-
* - debug → channel entry with kind="debug" (only shown with --debug)
|
|
21
|
-
*
|
|
22
|
-
* The display layer handles formatting and filtering.
|
|
23
|
-
*/
|
|
24
|
-
function createChannelLogger(config) {
|
|
25
|
-
const { provider, from = "system" } = config;
|
|
26
|
-
const formatContent = (level, message, args) => {
|
|
27
|
-
const argsStr = args.length > 0 ? " " + args.map(formatArg).join(" ") : "";
|
|
28
|
-
if (level === "warn") return `[WARN] ${message}${argsStr}`;
|
|
29
|
-
if (level === "error") return `[ERROR] ${message}${argsStr}`;
|
|
30
|
-
return `${message}${argsStr}`;
|
|
31
|
-
};
|
|
32
|
-
const write = (level, message, args) => {
|
|
33
|
-
const content = formatContent(level, message, args);
|
|
34
|
-
const kind = level === "debug" ? "debug" : "system";
|
|
35
|
-
provider.appendChannel(from, content, { kind }).catch(() => {});
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
debug: (message, ...args) => write("debug", message, args),
|
|
39
|
-
info: (message, ...args) => write("info", message, args),
|
|
40
|
-
warn: (message, ...args) => write("warn", message, args),
|
|
41
|
-
error: (message, ...args) => write("error", message, args),
|
|
42
|
-
isDebug: () => true,
|
|
43
|
-
child: (childPrefix) => {
|
|
44
|
-
return createChannelLogger({
|
|
45
|
-
provider,
|
|
46
|
-
from: from ? `${from}:${childPrefix}` : childPrefix
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/** Format an argument for logging */
|
|
52
|
-
function formatArg(arg) {
|
|
53
|
-
if (arg === null || arg === void 0) return String(arg);
|
|
54
|
-
if (typeof arg === "object") try {
|
|
55
|
-
return JSON.stringify(arg);
|
|
56
|
-
} catch {
|
|
57
|
-
return String(arg);
|
|
58
|
-
}
|
|
59
|
-
return String(arg);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
export { createChannelLogger, createSilentLogger };
|