agent-worker 0.18.0 → 0.19.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/README.md +49 -38
- package/dist/cli/index.mjs +208 -4320
- package/dist/client-DAKkzdOn.mjs +171 -0
- package/dist/daemon-CwaHgxs6.mjs +1071 -0
- package/dist/index.d.mts +249 -849
- package/dist/index.mjs +27 -1102
- package/dist/output-B0mwPqjv.mjs +20 -0
- package/dist/rolldown-runtime-wcPFST8Q.mjs +13 -0
- package/dist/target-9yiBRXxa.mjs +105 -0
- package/package.json +25 -37
- package/dist/backends-D7DT0uox.mjs +0 -1484
- package/dist/backends-DUvcm-ce.mjs +0 -3
- package/dist/context-CoRTddGx.mjs +0 -4
- package/dist/create-tool-gcUuI1FD.mjs +0 -32
- package/dist/display-pretty-Kyd40DEF.mjs +0 -190
- package/dist/memory-provider-Z9D8NdwS.mjs +0 -75
- package/dist/runner-BmT0Y8MD.mjs +0 -690
- package/dist/workflow-LOZUlaDo.mjs +0 -744
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { C as CLAUDE_MODEL_MAP, D as SDK_MODEL_ALIASES, E as OPENCODE_MODEL_MAP, O as getModelForBackend, S as BACKEND_DEFAULT_MODELS, T as CURSOR_MODEL_MAP, _ as extractCodexResult, a as createMockBackend, b as execWithIdleTimeout, c as extractOpenCodeResult, d as CodexBackend, f as ClaudeCodeBackend, g as extractClaudeResult, h as createStreamParser, i as MockAIBackend, k as normalizeBackendType, l as opencodeAdapter, m as codexAdapter, n as createBackend, o as SdkBackend, p as claudeAdapter, r as listBackends, s as OpenCodeBackend, t as checkBackends, u as CursorBackend, v as formatEvent, w as CODEX_MODEL_MAP, x as DEFAULT_IDLE_TIMEOUT, y as IdleTimeoutError } from "./backends-D7DT0uox.mjs";
|
|
2
|
-
|
|
3
|
-
export { listBackends };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { $ as formatInbox, A as resolveContextDir, B as MENTION_PATTERN, D as FileContextProvider, F as DefaultChannelStore, G as createResourceRef, H as RESOURCE_PREFIX, I as FileStorage, J as shouldUseResource, K as extractMentions, L as MemoryStorage, M as DefaultResourceStore, N as DefaultDocumentStore, O as createFileContextProvider, P as DefaultInboxStore, Q as createLogTool, R as ContextProviderImpl, U as RESOURCE_SCHEME, V as MESSAGE_LENGTH_THRESHOLD, W as calculatePriority, X as formatProposal, Y as createContextMCPServer, Z as formatProposalList, et as formatToolParams, j as DefaultStatusStore, k as getDefaultContextDir, nt as EventLog, q as generateResourceId, tt as getAgentId, z as CONTEXT_DEFAULTS } from "./cli/index.mjs";
|
|
2
|
-
import { n as createMemoryContextProvider, t as MemoryContextProvider } from "./memory-provider-Z9D8NdwS.mjs";
|
|
3
|
-
|
|
4
|
-
export { createFileContextProvider };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { jsonSchema, tool } from "ai";
|
|
2
|
-
|
|
3
|
-
//#region src/agent/tools/create-tool.ts
|
|
4
|
-
/**
|
|
5
|
-
* Type-safe wrapper for AI SDK tool() with JSON Schema.
|
|
6
|
-
*
|
|
7
|
-
* The AI SDK's tool() function has complex generic types that don't align
|
|
8
|
-
* with jsonSchema() return types. This utility absorbs the necessary casts
|
|
9
|
-
* in one place instead of scattering `as unknown` across every tool file.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Create an AI SDK tool with a plain JSON Schema object.
|
|
13
|
-
*
|
|
14
|
-
* Usage:
|
|
15
|
-
* ```ts
|
|
16
|
-
* const myTool = createTool({
|
|
17
|
-
* description: "Do something",
|
|
18
|
-
* schema: { type: "object", properties: { name: { type: "string" } }, required: ["name"] },
|
|
19
|
-
* execute: async (args) => { ... },
|
|
20
|
-
* });
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
function createTool(config) {
|
|
24
|
-
return tool({
|
|
25
|
-
description: config.description,
|
|
26
|
-
inputSchema: jsonSchema(config.schema),
|
|
27
|
-
execute: config.execute
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
export { createTool as t };
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import * as p from "@clack/prompts";
|
|
2
|
-
import pc from "picocolors";
|
|
3
|
-
|
|
4
|
-
//#region src/workflow/display-pretty.ts
|
|
5
|
-
/**
|
|
6
|
-
* Pretty display mode using @clack/prompts
|
|
7
|
-
*
|
|
8
|
-
* Clean, step-based CLI output:
|
|
9
|
-
* - Each message/event is a step
|
|
10
|
-
* - Uses clack's native symbols
|
|
11
|
-
* - Minimal decoration, maximum clarity
|
|
12
|
-
*/
|
|
13
|
-
const BANNER_LINES = [
|
|
14
|
-
" █████╗ ██████╗ ███████╗███╗ ██╗████████╗ ██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗",
|
|
15
|
-
"██╔══██╗██╔════╝ ██╔════╝████╗ ██║╚══██╔══╝ ██║ ██║██╔═══██╗██╔══██╗██║ ██╔╝██╔════╝██╔══██╗",
|
|
16
|
-
"███████║██║ ███╗█████╗ ██╔██╗ ██║ ██║ ██║ █╗ ██║██║ ██║██████╔╝█████╔╝ █████╗ ██████╔╝",
|
|
17
|
-
"██╔══██║██║ ██║██╔══╝ ██║╚██╗██║ ██║ ██║███╗██║██║ ██║██╔══██╗██╔═██╗ ██╔══╝ ██╔══██╗",
|
|
18
|
-
"██║ ██║╚██████╔╝███████╗██║ ╚████║ ██║ ╚███╔███╔╝╚██████╔╝██║ ██║██║ ██╗███████╗██║ ██║",
|
|
19
|
-
"╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝"
|
|
20
|
-
];
|
|
21
|
-
/**
|
|
22
|
-
* Apply gradient colors to banner lines
|
|
23
|
-
* Creates a smooth cyan gradient effect (bright → dark) using ANSI 256 colors
|
|
24
|
-
* Inspired by vercel-labs/skills gradient approach
|
|
25
|
-
*/
|
|
26
|
-
function applyBannerGradient(lines) {
|
|
27
|
-
const CYAN_GRADIENT = [
|
|
28
|
-
"\x1B[38;5;51m",
|
|
29
|
-
"\x1B[38;5;45m",
|
|
30
|
-
"\x1B[38;5;39m",
|
|
31
|
-
"\x1B[38;5;33m",
|
|
32
|
-
"\x1B[38;5;27m",
|
|
33
|
-
"\x1B[38;5;21m"
|
|
34
|
-
];
|
|
35
|
-
const RESET = "\x1B[0m";
|
|
36
|
-
return lines.map((line, i) => `${CYAN_GRADIENT[i]}${line}${RESET}`).join("\n");
|
|
37
|
-
}
|
|
38
|
-
const AGENT_COLORS = [
|
|
39
|
-
pc.cyan,
|
|
40
|
-
pc.yellow,
|
|
41
|
-
pc.magenta,
|
|
42
|
-
pc.green,
|
|
43
|
-
pc.blue
|
|
44
|
-
];
|
|
45
|
-
function getAgentColor(name, agentNames) {
|
|
46
|
-
if (name === "system" || name === "user") return pc.dim;
|
|
47
|
-
const idx = agentNames.indexOf(name);
|
|
48
|
-
if (idx < 0) return AGENT_COLORS[name.split("").reduce((acc, c) => acc + c.charCodeAt(0), 0) % AGENT_COLORS.length];
|
|
49
|
-
return AGENT_COLORS[idx % AGENT_COLORS.length];
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Extract HH:MM:SS from ISO timestamp for display
|
|
53
|
-
*/
|
|
54
|
-
function formatTime(timestamp) {
|
|
55
|
-
const d = new Date(timestamp);
|
|
56
|
-
const h = String(d.getHours()).padStart(2, "0");
|
|
57
|
-
const m = String(d.getMinutes()).padStart(2, "0");
|
|
58
|
-
const s = String(d.getSeconds()).padStart(2, "0");
|
|
59
|
-
return pc.dim(`${h}:${m}:${s}`);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Process a channel entry for pretty display
|
|
63
|
-
*/
|
|
64
|
-
function processEntry(entry, state, agentNames) {
|
|
65
|
-
const { kind, from, content, toolCall, timestamp } = entry;
|
|
66
|
-
const time = formatTime(timestamp);
|
|
67
|
-
if (kind === "debug") return;
|
|
68
|
-
if (kind === "tool_call" && toolCall) {
|
|
69
|
-
const caller = from.includes(":") ? from.split(":").pop() : from;
|
|
70
|
-
if (caller) {
|
|
71
|
-
const color = getAgentColor(caller, agentNames);
|
|
72
|
-
const tool = pc.bold(pc.cyan(toolCall.name));
|
|
73
|
-
const args = toolCall.args ? pc.dim(`(${toolCall.args})`) : pc.dim("()");
|
|
74
|
-
p.log.message(`${time} ${color(caller)} called ${tool}${args}`, { symbol: pc.cyan("▶") });
|
|
75
|
-
} else p.log.message(`${time} called ${pc.cyan(pc.bold(toolCall.name))}${pc.dim(`(${toolCall.args || ""})`)}`, { symbol: pc.cyan("▶") });
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (kind === "output") {
|
|
79
|
-
const color = getAgentColor(from, agentNames);
|
|
80
|
-
const agent = from.includes(":") ? from.split(":").pop() : from;
|
|
81
|
-
if (content.startsWith("STARTING ")) p.log.message(`${time} ${color(agent)} ${content}`, { symbol: pc.cyan("▶") });
|
|
82
|
-
else if (content.startsWith("Assistant: ")) {
|
|
83
|
-
const text = content.slice(11);
|
|
84
|
-
p.log.message(`${time} ${color(agent)} ${text}`, { symbol: pc.cyan("◆") });
|
|
85
|
-
} else p.log.message(`${time} ${color(agent)} ${pc.dim(content)}`, { symbol: pc.dim("│") });
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (kind === "system") {
|
|
89
|
-
if (content.includes("Running workflow:")) {
|
|
90
|
-
state.phase = "running";
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (content.includes("Agents:")) return;
|
|
94
|
-
if (content.includes("Starting agents")) {
|
|
95
|
-
if (state.spinner) {
|
|
96
|
-
const agentList = agentNames.join(", ");
|
|
97
|
-
state.spinner.stop(`${time} Initialized: ${pc.dim(agentList)}`);
|
|
98
|
-
}
|
|
99
|
-
state.spinner = p.spinner();
|
|
100
|
-
state.spinner.start("Starting agents");
|
|
101
|
-
} else if (content.includes("Workflow complete")) {
|
|
102
|
-
if (state.spinner) {
|
|
103
|
-
state.spinner.stop();
|
|
104
|
-
state.spinner = null;
|
|
105
|
-
}
|
|
106
|
-
const match = content.match(/\(([0-9.]+)s\)/);
|
|
107
|
-
if (match) p.log.success(`${time} Completed in ${pc.bold(match[1])}s`);
|
|
108
|
-
else p.log.success(`${time} Workflow complete`);
|
|
109
|
-
state.phase = "complete";
|
|
110
|
-
} else if (content.startsWith("[ERROR]")) {
|
|
111
|
-
if (state.spinner) {
|
|
112
|
-
state.spinner.stop();
|
|
113
|
-
state.spinner = null;
|
|
114
|
-
}
|
|
115
|
-
p.log.error(`${time} ${content.replace("[ERROR] ", "")}`);
|
|
116
|
-
state.phase = "error";
|
|
117
|
-
} else if (content.startsWith("[WARN]")) p.log.warn(`${time} ${content.replace("[WARN] ", "")}`);
|
|
118
|
-
else if (content.match(/Inbox: \d+ message/)) p.log.step(`${time} ${pc.dim(content)}`);
|
|
119
|
-
else if (content.match(/Running \(attempt/)) p.log.step(`${time} ${pc.dim(content)}`);
|
|
120
|
-
else if (content.startsWith("DONE")) {
|
|
121
|
-
const details = content.replace("DONE ", "");
|
|
122
|
-
p.log.info(`${time} ${pc.green("✓")} ${pc.dim(details)}`);
|
|
123
|
-
}
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const color = getAgentColor(from, agentNames);
|
|
127
|
-
if (state.spinner && state.phase === "running" && !state.hasShownAgentsStarted) {
|
|
128
|
-
state.spinner.stop();
|
|
129
|
-
state.spinner = null;
|
|
130
|
-
p.log.info(`${time} Agents ready and processing`);
|
|
131
|
-
state.hasShownAgentsStarted = true;
|
|
132
|
-
}
|
|
133
|
-
p.note(content.trim(), `${time} ${color(from)}`);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Start pretty display watcher
|
|
137
|
-
*/
|
|
138
|
-
function startPrettyDisplay(config) {
|
|
139
|
-
const { contextProvider, agentNames, workflowName, tag, workflowPath, pollInterval = 500, initialCursor = 0 } = config;
|
|
140
|
-
const state = {
|
|
141
|
-
spinner: null,
|
|
142
|
-
phase: "init",
|
|
143
|
-
hasShownAgentsStarted: false
|
|
144
|
-
};
|
|
145
|
-
console.log("\n" + applyBannerGradient(BANNER_LINES));
|
|
146
|
-
console.log("");
|
|
147
|
-
const introText = ` ${workflowName}${tag === "main" ? "" : `:${tag}`}${workflowPath ? ` ${pc.dim(`(${workflowPath})`)}` : ""} `;
|
|
148
|
-
p.intro(pc.bgCyan(pc.black(introText)));
|
|
149
|
-
state.spinner = p.spinner();
|
|
150
|
-
const agentCount = agentNames.length;
|
|
151
|
-
const agentWord = agentCount === 1 ? "agent" : "agents";
|
|
152
|
-
state.spinner.start(`Initializing ${agentCount} ${agentWord}`);
|
|
153
|
-
let cursor = initialCursor;
|
|
154
|
-
let running = true;
|
|
155
|
-
const poll = async () => {
|
|
156
|
-
while (running) {
|
|
157
|
-
try {
|
|
158
|
-
const tail = await contextProvider.tailChannel(cursor);
|
|
159
|
-
for (const entry of tail.entries) processEntry(entry, state, agentNames);
|
|
160
|
-
cursor = tail.cursor;
|
|
161
|
-
} catch (error) {
|
|
162
|
-
console.error("Display polling error:", error instanceof Error ? error.message : error);
|
|
163
|
-
}
|
|
164
|
-
await sleep(pollInterval);
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
poll();
|
|
168
|
-
return { stop: () => {
|
|
169
|
-
running = false;
|
|
170
|
-
if (state.spinner) state.spinner.stop("Stopped");
|
|
171
|
-
} };
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Show workflow completion summary
|
|
175
|
-
*/
|
|
176
|
-
function showWorkflowSummary(options) {
|
|
177
|
-
const { document, feedback } = options;
|
|
178
|
-
if (document && document.trim()) p.note(document, "Document");
|
|
179
|
-
if (feedback && feedback.length > 0) {
|
|
180
|
-
const feedbackLines = feedback.map((f) => `[${f.type}] ${f.target}: ${f.description}`);
|
|
181
|
-
p.note(feedbackLines.join("\n"), `Feedback (${feedback.length})`);
|
|
182
|
-
}
|
|
183
|
-
p.outro("Done");
|
|
184
|
-
}
|
|
185
|
-
function sleep(ms) {
|
|
186
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
//#endregion
|
|
190
|
-
export { showWorkflowSummary, startPrettyDisplay };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { F as DefaultChannelStore, L as MemoryStorage, M as DefaultResourceStore, N as DefaultDocumentStore, P as DefaultInboxStore, R as ContextProviderImpl, j as DefaultStatusStore } from "./cli/index.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/workflow/context/memory-provider.ts
|
|
4
|
-
/**
|
|
5
|
-
* In-memory ContextProvider for testing.
|
|
6
|
-
* All domain logic is in the composed stores;
|
|
7
|
-
* this class adds test helpers for inspection and cleanup.
|
|
8
|
-
*/
|
|
9
|
-
var MemoryContextProvider = class extends ContextProviderImpl {
|
|
10
|
-
memoryStorage;
|
|
11
|
-
constructor(validAgents) {
|
|
12
|
-
const storage = new MemoryStorage();
|
|
13
|
-
const channel = new DefaultChannelStore(storage, validAgents);
|
|
14
|
-
const inbox = new DefaultInboxStore(channel, storage);
|
|
15
|
-
const documents = new DefaultDocumentStore(storage);
|
|
16
|
-
const resources = new DefaultResourceStore(storage);
|
|
17
|
-
const status = new DefaultStatusStore(storage);
|
|
18
|
-
super(channel, inbox, documents, resources, status, validAgents);
|
|
19
|
-
this.memoryStorage = storage;
|
|
20
|
-
}
|
|
21
|
-
/** Get underlying MemoryStorage (for testing) */
|
|
22
|
-
getStorage() {
|
|
23
|
-
return this.memoryStorage;
|
|
24
|
-
}
|
|
25
|
-
/** Get all channel messages (for testing, unfiltered) */
|
|
26
|
-
async getMessages() {
|
|
27
|
-
return this.readChannel();
|
|
28
|
-
}
|
|
29
|
-
/** Clear all data (for testing) */
|
|
30
|
-
clear() {
|
|
31
|
-
this.memoryStorage.clear();
|
|
32
|
-
}
|
|
33
|
-
/** Get all resources (for testing) */
|
|
34
|
-
async getResources() {
|
|
35
|
-
const keys = await this.memoryStorage.list("resources/");
|
|
36
|
-
const map = /* @__PURE__ */ new Map();
|
|
37
|
-
for (const key of keys) {
|
|
38
|
-
const content = await this.memoryStorage.read(`resources/${key}`);
|
|
39
|
-
if (content !== null) {
|
|
40
|
-
const id = key.replace(/\.[^.]+$/, "");
|
|
41
|
-
map.set(id, content);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return map;
|
|
45
|
-
}
|
|
46
|
-
/** Get inbox state for an agent (for testing) */
|
|
47
|
-
async getInboxState(agent) {
|
|
48
|
-
const raw = await this.memoryStorage.read("_state/inbox.json");
|
|
49
|
-
if (!raw) return void 0;
|
|
50
|
-
try {
|
|
51
|
-
return JSON.parse(raw).readCursors?.[agent];
|
|
52
|
-
} catch {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/** Get all documents (for testing) */
|
|
57
|
-
async getDocuments() {
|
|
58
|
-
const files = await this.memoryStorage.list("documents/");
|
|
59
|
-
const map = /* @__PURE__ */ new Map();
|
|
60
|
-
for (const file of files) {
|
|
61
|
-
const content = await this.memoryStorage.read(`documents/${file}`);
|
|
62
|
-
if (content !== null) map.set(file, content);
|
|
63
|
-
}
|
|
64
|
-
return map;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Create a memory context provider
|
|
69
|
-
*/
|
|
70
|
-
function createMemoryContextProvider(validAgents) {
|
|
71
|
-
return new MemoryContextProvider(validAgents);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
//#endregion
|
|
75
|
-
export { createMemoryContextProvider as n, MemoryContextProvider as t };
|