agent-worker 0.8.0 → 0.10.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.
@@ -345,8 +345,12 @@ async function execWithIdleTimeout(options) {
345
345
  subprocess.stdout?.on("data", (chunk) => {
346
346
  const text = chunk.toString();
347
347
  stdout += text;
348
- if (onStdout) onStdout(text);
349
348
  resetTimer();
349
+ if (onStdout) try {
350
+ onStdout(text);
351
+ } catch (err) {
352
+ console.error("onStdout callback error:", err);
353
+ }
350
354
  });
351
355
  subprocess.stderr?.on("data", (chunk) => {
352
356
  stderr += chunk.toString();
@@ -393,8 +397,12 @@ function execWithIdleTimeoutAbortable(options) {
393
397
  subprocess.stdout?.on("data", (chunk) => {
394
398
  const text = chunk.toString();
395
399
  stdout += text;
396
- if (onStdout) onStdout(text);
397
400
  resetTimer();
401
+ if (onStdout) try {
402
+ onStdout(text);
403
+ } catch (err) {
404
+ console.error("onStdout callback error:", err);
405
+ }
398
406
  });
399
407
  subprocess.stderr?.on("data", (chunk) => {
400
408
  stderr += chunk.toString();
@@ -481,6 +489,9 @@ function formatEvent(event, backendName) {
481
489
  if (details.length > 0) parts.push(`(${details.join(", ")})`);
482
490
  return parts.join(" ");
483
491
  }
492
+ case "user_message": return `User: ${event.text.length > 80 ? event.text.slice(0, 80) + "..." : event.text}`;
493
+ case "assistant_message": return `Assistant: ${event.text.length > 80 ? event.text.slice(0, 80) + "..." : event.text}`;
494
+ case "skip": return null;
484
495
  case "unknown": {
485
496
  const preview = JSON.stringify(event.raw).slice(0, 100);
486
497
  return `[DEBUG] ${backendName} unknown event type="${event.type}": ${preview}...`;
@@ -502,6 +513,14 @@ const claudeAdapter = (raw) => {
502
513
  model: event.model,
503
514
  sessionId: event.session_id
504
515
  };
516
+ if (event.type === "user") {
517
+ const textContent = event.message.content.find((c) => c.type === "text");
518
+ if (textContent && "text" in textContent) return {
519
+ kind: "user_message",
520
+ text: textContent.text
521
+ };
522
+ return { kind: "skip" };
523
+ }
505
524
  if (event.type === "assistant") {
506
525
  const toolCalls = event.message.content.filter((c) => c.type === "tool_use");
507
526
  if (toolCalls.length > 0) {
@@ -512,7 +531,7 @@ const claudeAdapter = (raw) => {
512
531
  args: formatToolInput(tc.input)
513
532
  };
514
533
  }
515
- return null;
534
+ return { kind: "skip" };
516
535
  }
517
536
  if (event.type === "result") return {
518
537
  kind: "completed",
@@ -560,6 +579,14 @@ const cursorAdapter = (raw) => {
560
579
  model: event.model,
561
580
  sessionId: event.session_id
562
581
  };
582
+ if (event.type === "user") return {
583
+ kind: "user_message",
584
+ text: event.message.content.map((c) => c.text).join("\n")
585
+ };
586
+ if (event.type === "assistant") return {
587
+ kind: "assistant_message",
588
+ text: event.message.content.map((c) => c.text).join("\n")
589
+ };
563
590
  if (event.type === "tool_call") {
564
591
  if (event.subtype === "started" && event.tool_call) {
565
592
  if (event.tool_call.shellToolCall) return {
@@ -573,7 +600,7 @@ const cursorAdapter = (raw) => {
573
600
  callId: event.call_id
574
601
  };
575
602
  }
576
- return null;
603
+ return { kind: "skip" };
577
604
  }
578
605
  if (event.type === "result") return {
579
606
  kind: "completed",
@@ -602,7 +629,7 @@ const codexAdapter = (raw) => {
602
629
  name: event.item.name,
603
630
  args: event.item.arguments
604
631
  };
605
- return null;
632
+ return { kind: "skip" };
606
633
  }
607
634
  if (event.type === "turn.completed") return {
608
635
  kind: "completed",
@@ -632,13 +659,14 @@ function extractCodexResult(stdout) {
632
659
  * Create a line-buffered stream parser.
633
660
  *
634
661
  * Accumulates stdout chunks, parses each line through the given adapter,
635
- * and emits formatted progress messages via debugLog.
662
+ * and emits formatted progress messages via appropriate callback.
636
663
  *
637
- * @param debugLog - Callback for progress messages
664
+ * @param debugLog - Callback for debug messages (kind="debug", only in --debug mode)
638
665
  * @param backendName - Display name (e.g., "Cursor", "Claude", "Codex")
639
666
  * @param adapter - Format-specific adapter to convert raw JSON → StreamEvent
667
+ * @param messageLog - Optional callback for agent output messages (tool calls, assistant messages) (kind="stream", visible in normal mode). If not provided, uses debugLog.
640
668
  */
641
- function createStreamParser(debugLog, backendName, adapter) {
669
+ function createStreamParser(debugLog, backendName, adapter, messageLog) {
642
670
  let lineBuf = "";
643
671
  return (chunk) => {
644
672
  lineBuf += chunk;
@@ -656,7 +684,7 @@ function createStreamParser(debugLog, backendName, adapter) {
656
684
  };
657
685
  if (event) {
658
686
  const progress = formatEvent(event, backendName);
659
- if (progress) debugLog(progress);
687
+ if (progress) ((event.kind === "tool_call" || event.kind === "tool_call_started" || event.kind === "user_message" || event.kind === "assistant_message") && messageLog ? messageLog : debugLog)(progress);
660
688
  }
661
689
  } catch {}
662
690
  }
@@ -720,7 +748,7 @@ var ClaudeCodeBackend = class {
720
748
  args,
721
749
  cwd,
722
750
  timeout,
723
- onStdout: outputFormat === "stream-json" && debugLog ? createStreamParser(debugLog, "Claude", claudeAdapter) : void 0
751
+ onStdout: outputFormat === "stream-json" && debugLog ? createStreamParser(debugLog, "Claude", claudeAdapter, this.options.messageLog) : void 0
724
752
  });
725
753
  this.currentAbort = abort;
726
754
  const { stdout } = await promise;
@@ -844,7 +872,7 @@ var CodexBackend = class {
844
872
  args,
845
873
  cwd,
846
874
  timeout,
847
- onStdout: debugLog ? createStreamParser(debugLog, "Codex", codexAdapter) : void 0
875
+ onStdout: debugLog ? createStreamParser(debugLog, "Codex", codexAdapter, this.options.messageLog) : void 0
848
876
  });
849
877
  return extractCodexResult(stdout);
850
878
  } catch (error) {
@@ -925,6 +953,7 @@ var CursorBackend = class {
925
953
  const { command, args } = await this.buildCommand(message);
926
954
  const cwd = this.options.workspace || this.options.cwd;
927
955
  const debugLog = this.options.debugLog;
956
+ const messageLog = this.options.messageLog;
928
957
  const timeout = this.options.timeout ?? DEFAULT_IDLE_TIMEOUT;
929
958
  try {
930
959
  const { stdout } = await execWithIdleTimeout({
@@ -932,7 +961,7 @@ var CursorBackend = class {
932
961
  args,
933
962
  cwd,
934
963
  timeout,
935
- onStdout: debugLog ? createStreamParser(debugLog, "Cursor", cursorAdapter) : void 0
964
+ onStdout: debugLog ? createStreamParser(debugLog, "Cursor", cursorAdapter, messageLog) : void 0
936
965
  });
937
966
  return extractClaudeResult(stdout);
938
967
  } catch (error) {
@@ -1,3 +1,3 @@
1
- import { C as SDK_MODEL_ALIASES, S as CURSOR_MODEL_MAP, _ as execWithIdleTimeout, a as createMockBackend, b as CLAUDE_MODEL_MAP, c as CodexBackend, d as codexAdapter, f as createStreamParser, g as IdleTimeoutError, h as formatEvent, i as MockAIBackend, l as ClaudeCodeBackend, m as extractCodexResult, n as createBackend, o as SdkBackend, p as extractClaudeResult, r as listBackends, s as CursorBackend, t as checkBackends, u as claudeAdapter, v as DEFAULT_IDLE_TIMEOUT, w as getModelForBackend, x as CODEX_MODEL_MAP, y as BACKEND_DEFAULT_MODELS } from "./backends-rQZxF7Fl.mjs";
1
+ import { C as SDK_MODEL_ALIASES, S as CURSOR_MODEL_MAP, _ as execWithIdleTimeout, a as createMockBackend, b as CLAUDE_MODEL_MAP, c as CodexBackend, d as codexAdapter, f as createStreamParser, g as IdleTimeoutError, h as formatEvent, i as MockAIBackend, l as ClaudeCodeBackend, m as extractCodexResult, n as createBackend, o as SdkBackend, p as extractClaudeResult, r as listBackends, s as CursorBackend, t as checkBackends, u as claudeAdapter, v as DEFAULT_IDLE_TIMEOUT, w as getModelForBackend, x as CODEX_MODEL_MAP, y as BACKEND_DEFAULT_MODELS } from "./backends-BOAkfYyL.mjs";
2
2
 
3
3
  export { listBackends };
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { A as getDefaultModel, E as FRONTIER_MODELS, n as createBackend } from "../backends-rQZxF7Fl.mjs";
3
- import { a as createSkillsTool, c as createFeedbackTool, l as AgentSession, o as SkillsProvider, s as FEEDBACK_PROMPT, t as SkillImporter } from "../skills-ks27oet6.mjs";
2
+ import { A as getDefaultModel, E as FRONTIER_MODELS, n as createBackend } from "../backends-BOAkfYyL.mjs";
3
+ import { a as createSkillsTool, c as createFeedbackTool, l as AgentSession, o as SkillsProvider, s as FEEDBACK_PROMPT, t as SkillImporter } from "../skills-xNmQZf8e.mjs";
4
4
  import { jsonSchema, tool } from "ai";
5
5
  import { existsSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from "node:fs";
6
6
  import { dirname, isAbsolute, join, relative } from "node:path";
@@ -673,7 +673,7 @@ var ContextProviderImpl = class {
673
673
  if (options?.agent) {
674
674
  const agent = options.agent;
675
675
  entries = entries.filter((e) => {
676
- if (e.kind === "log" || e.kind === "debug") return false;
676
+ if (e.kind === "log" || e.kind === "debug" || e.kind === "stream") return false;
677
677
  if (e.to) return e.to === agent || e.from === agent;
678
678
  return true;
679
679
  });
@@ -719,7 +719,7 @@ var ContextProviderImpl = class {
719
719
  let seenIdx = -1;
720
720
  if (lastSeenId) seenIdx = entries.findIndex((e) => e.id === lastSeenId);
721
721
  return entries.filter((e) => {
722
- if (e.kind === "log" || e.kind === "debug") return false;
722
+ if (e.kind === "log" || e.kind === "debug" || e.kind === "stream") return false;
723
723
  if (e.from === agent) return false;
724
724
  return e.mentions.includes(agent) || e.to === agent;
725
725
  }).map((entry) => {
@@ -2157,7 +2157,7 @@ Examples:
2157
2157
 
2158
2158
  Note: Workflow name is inferred from YAML 'name' field or filename
2159
2159
  `).action(async (file, options) => {
2160
- const { parseWorkflowFile, runWorkflowWithControllers } = await import("../workflow-B_y98Ood.mjs");
2160
+ const { parseWorkflowFile, runWorkflowWithControllers } = await import("../workflow-BGpkJlFb.mjs");
2161
2161
  const tag = options.tag || DEFAULT_TAG;
2162
2162
  const parsedWorkflow = await parseWorkflowFile(file, { tag });
2163
2163
  const workflowName = parsedWorkflow.name;
@@ -2168,7 +2168,7 @@ Note: Workflow name is inferred from YAML 'name' field or filename
2168
2168
  isCleaningUp = true;
2169
2169
  console.log("\nInterrupted, cleaning up...");
2170
2170
  if (controllers) {
2171
- const { shutdownControllers } = await import("../workflow-B_y98Ood.mjs");
2171
+ const { shutdownControllers } = await import("../workflow-BGpkJlFb.mjs");
2172
2172
  const { createSilentLogger } = await import("../logger-C3ekEOzi.mjs");
2173
2173
  await shutdownControllers(controllers, createSilentLogger());
2174
2174
  }
@@ -2206,7 +2206,7 @@ Note: Workflow name is inferred from YAML 'name' field or filename
2206
2206
  feedback: result.feedback
2207
2207
  }, null, 2));
2208
2208
  else if (!options.debug) {
2209
- const { showWorkflowSummary } = await import("../display-pretty-BL9H2ocr.mjs");
2209
+ const { showWorkflowSummary } = await import("../display-pretty-CWoRE9FY.mjs");
2210
2210
  showWorkflowSummary({
2211
2211
  duration: result.duration,
2212
2212
  document: finalDoc,
@@ -2238,7 +2238,7 @@ Examples:
2238
2238
 
2239
2239
  Note: Workflow name is inferred from YAML 'name' field or filename
2240
2240
  `).action(async (file, options) => {
2241
- const { parseWorkflowFile, runWorkflowWithControllers } = await import("../workflow-B_y98Ood.mjs");
2241
+ const { parseWorkflowFile, runWorkflowWithControllers } = await import("../workflow-BGpkJlFb.mjs");
2242
2242
  const tag = options.tag || DEFAULT_TAG;
2243
2243
  const parsedWorkflow = await parseWorkflowFile(file, { tag });
2244
2244
  const workflowName = parsedWorkflow.name;
@@ -2433,7 +2433,7 @@ function registerInfoCommands(program) {
2433
2433
  console.log(`\nDefault: ${defaultModel} (when no model specified)`);
2434
2434
  });
2435
2435
  program.command("backends").description("Check available backends (SDK, CLI tools)").action(async () => {
2436
- const { listBackends } = await import("../backends-CoOMoMcP.mjs");
2436
+ const { listBackends } = await import("../backends-e6gCxRZ9.mjs");
2437
2437
  const backends = await listBackends();
2438
2438
  console.log("Backend Status:\n");
2439
2439
  for (const backend of backends) {
@@ -2581,7 +2581,7 @@ Note: Requires agent to be created with --feedback flag
2581
2581
 
2582
2582
  //#endregion
2583
2583
  //#region package.json
2584
- var version = "0.8.0";
2584
+ var version = "0.10.0";
2585
2585
 
2586
2586
  //#endregion
2587
2587
  //#region src/cli/index.ts
@@ -49,10 +49,21 @@ function getAgentColor(name, agentNames) {
49
49
  return AGENT_COLORS[idx % AGENT_COLORS.length];
50
50
  }
51
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
+ /**
52
62
  * Process a channel entry for pretty display
53
63
  */
54
64
  function processEntry(entry, state, agentNames) {
55
- const { kind, from, content, toolCall } = entry;
65
+ const { kind, from, content, toolCall, timestamp } = entry;
66
+ const time = formatTime(timestamp);
56
67
  if (kind === "debug") return;
57
68
  if (kind === "tool_call" && toolCall) {
58
69
  const caller = from.includes(":") ? from.split(":").pop() : from;
@@ -60,8 +71,18 @@ function processEntry(entry, state, agentNames) {
60
71
  const color = getAgentColor(caller, agentNames);
61
72
  const tool = pc.bold(pc.cyan(toolCall.name));
62
73
  const args = toolCall.args ? pc.dim(`(${toolCall.args})`) : pc.dim("()");
63
- p.log.message(`${color(caller)} called ${tool}${args}`, { symbol: pc.cyan("▶") });
64
- } else p.log.message(`called ${pc.cyan(pc.bold(toolCall.name))}${pc.dim(`(${toolCall.args || ""})`)}`, { symbol: pc.cyan("▶") });
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 === "stream") {
79
+ const color = getAgentColor(from, agentNames);
80
+ const agent = from.includes(":") ? from.split(":").pop() : from;
81
+ if (content.startsWith("STARTING ") || content.startsWith("CALL ")) 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("│") });
65
86
  return;
66
87
  }
67
88
  if (kind === "log") {
@@ -73,7 +94,7 @@ function processEntry(entry, state, agentNames) {
73
94
  if (content.includes("Starting agents")) {
74
95
  if (state.spinner) {
75
96
  const agentList = agentNames.join(", ");
76
- state.spinner.stop(`Initialized: ${pc.dim(agentList)}`);
97
+ state.spinner.stop(`${time} Initialized: ${pc.dim(agentList)}`);
77
98
  }
78
99
  state.spinner = p.spinner();
79
100
  state.spinner.start("Starting agents");
@@ -83,22 +104,22 @@ function processEntry(entry, state, agentNames) {
83
104
  state.spinner = null;
84
105
  }
85
106
  const match = content.match(/\(([0-9.]+)s\)/);
86
- if (match) p.log.success(`Completed in ${pc.bold(match[1])}s`);
87
- else p.log.success("Workflow complete");
107
+ if (match) p.log.success(`${time} Completed in ${pc.bold(match[1])}s`);
108
+ else p.log.success(`${time} Workflow complete`);
88
109
  state.phase = "complete";
89
110
  } else if (content.startsWith("[ERROR]")) {
90
111
  if (state.spinner) {
91
112
  state.spinner.stop();
92
113
  state.spinner = null;
93
114
  }
94
- p.log.error(content.replace("[ERROR] ", ""));
115
+ p.log.error(`${time} ${content.replace("[ERROR] ", "")}`);
95
116
  state.phase = "error";
96
- } else if (content.startsWith("[WARN]")) p.log.warn(content.replace("[WARN] ", ""));
97
- else if (content.match(/Inbox: \d+ message/)) p.log.step(pc.dim(content));
98
- else if (content.match(/Running \(attempt/)) p.log.step(pc.dim(content));
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)}`);
99
120
  else if (content.startsWith("DONE")) {
100
121
  const details = content.replace("DONE ", "");
101
- p.log.info(pc.green("✓") + " " + pc.dim(details));
122
+ p.log.info(`${time} ${pc.green("✓")} ${pc.dim(details)}`);
102
123
  }
103
124
  return;
104
125
  }
@@ -106,10 +127,10 @@ function processEntry(entry, state, agentNames) {
106
127
  if (state.spinner && state.phase === "running" && !state.hasShownAgentsStarted) {
107
128
  state.spinner.stop();
108
129
  state.spinner = null;
109
- p.log.info("Agents ready and processing");
130
+ p.log.info(`${time} Agents ready and processing`);
110
131
  state.hasShownAgentsStarted = true;
111
132
  }
112
- p.note(content.trim(), color(from));
133
+ p.note(content.trim(), `${time} ${color(from)}`);
113
134
  }
114
135
  /**
115
136
  * Start pretty display watcher
package/dist/index.d.mts CHANGED
@@ -473,8 +473,10 @@ interface ClaudeCodeOptions {
473
473
  timeout?: number;
474
474
  /** MCP config file path (for workflow context) */
475
475
  mcpConfigPath?: string;
476
- /** Debug log function (for workflow diagnostics) */
476
+ /** Debug log function (for tool calls and debug info) */
477
477
  debugLog?: (message: string) => void;
478
+ /** Message log function (for agent messages - user/assistant) */
479
+ messageLog?: (message: string) => void;
478
480
  }
479
481
  declare class ClaudeCodeBackend implements Backend {
480
482
  readonly type: "claude";
@@ -520,8 +522,10 @@ interface CodexOptions {
520
522
  resume?: string;
521
523
  /** Idle timeout in milliseconds — kills process if no output for this duration */
522
524
  timeout?: number;
523
- /** Debug log function (for workflow diagnostics) */
525
+ /** Debug log function (for tool calls and debug info) */
524
526
  debugLog?: (message: string) => void;
527
+ /** Message log function (for agent messages - user/assistant) */
528
+ messageLog?: (message: string) => void;
525
529
  }
526
530
  declare class CodexBackend implements Backend {
527
531
  readonly type: "codex";
@@ -556,8 +560,10 @@ interface CursorOptions {
556
560
  workspace?: string;
557
561
  /** Idle timeout in milliseconds — kills process if no output for this duration */
558
562
  timeout?: number;
559
- /** Debug log function (for workflow diagnostics) */
563
+ /** Debug log function (for tool calls and debug info) */
560
564
  debugLog?: (message: string) => void;
565
+ /** Message log function (for agent messages - user/assistant) */
566
+ messageLog?: (message: string) => void;
561
567
  }
562
568
  declare class CursorBackend implements Backend {
563
569
  readonly type: "cursor";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { D as SUPPORTED_PROVIDERS, E as FRONTIER_MODELS, O as createModel, a as createMockBackend, c as CodexBackend, i as MockAIBackend, k as createModelAsync, l as ClaudeCodeBackend, n as createBackend, o as SdkBackend, r as listBackends, s as CursorBackend, t as checkBackends } from "./backends-rQZxF7Fl.mjs";
2
- import { a as createSkillsTool, c as createFeedbackTool, i as parseImportSpec, l as AgentSession, n as buildGitUrl, o as SkillsProvider, r as getSpecDisplayName, s as FEEDBACK_PROMPT, t as SkillImporter } from "./skills-ks27oet6.mjs";
1
+ import { D as SUPPORTED_PROVIDERS, E as FRONTIER_MODELS, O as createModel, a as createMockBackend, c as CodexBackend, i as MockAIBackend, k as createModelAsync, l as ClaudeCodeBackend, n as createBackend, o as SdkBackend, r as listBackends, s as CursorBackend, t as checkBackends } from "./backends-BOAkfYyL.mjs";
2
+ import { a as createSkillsTool, c as createFeedbackTool, i as parseImportSpec, l as AgentSession, n as buildGitUrl, o as SkillsProvider, r as getSpecDisplayName, s as FEEDBACK_PROMPT, t as SkillImporter } from "./skills-xNmQZf8e.mjs";
3
3
  import { jsonSchema, tool } from "ai";
4
4
  import { createBashTool } from "bash-tool";
5
5
 
@@ -1,4 +1,4 @@
1
- import { k as createModelAsync } from "./backends-rQZxF7Fl.mjs";
1
+ import { k as createModelAsync } from "./backends-BOAkfYyL.mjs";
2
2
  import { ToolLoopAgent, jsonSchema, stepCountIs, tool } from "ai";
3
3
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
4
4
  import { join, normalize } from "node:path";
@@ -1,4 +1,4 @@
1
- import { T as parseModel, a as createMockBackend, k as createModelAsync, n as createBackend } from "./backends-rQZxF7Fl.mjs";
1
+ import { T as parseModel, a as createMockBackend, k as createModelAsync, n as createBackend } from "./backends-BOAkfYyL.mjs";
2
2
  import { c as CONTEXT_DEFAULTS, i as resolveContextDir, n as createFileContextProvider, t as FileContextProvider } from "./cli/index.mjs";
3
3
  import { a as createMemoryContextProvider, t as createContextMCPServer } from "./mcp-server-BQCQxv2v.mjs";
4
4
  import { createChannelLogger, createSilentLogger } from "./logger-C3ekEOzi.mjs";
@@ -1025,10 +1025,11 @@ async function runAgent(backend, ctx, log, infoLog) {
1025
1025
  }
1026
1026
  const prompt = buildAgentPrompt(ctx);
1027
1027
  info(`Prompt (${prompt.length} chars) → ${backend.type} backend`);
1028
- await backend.send(prompt, { system: ctx.agent.resolvedSystemPrompt });
1028
+ const response = await backend.send(prompt, { system: ctx.agent.resolvedSystemPrompt });
1029
1029
  return {
1030
1030
  success: true,
1031
- duration: Date.now() - startTime
1031
+ duration: Date.now() - startTime,
1032
+ content: response.content
1032
1033
  };
1033
1034
  } catch (error) {
1034
1035
  return {
@@ -1067,6 +1068,7 @@ function getBackendByType(backendType, options) {
1067
1068
  const backendOptions = {};
1068
1069
  if (options?.timeout) backendOptions.timeout = options.timeout;
1069
1070
  if (options?.debugLog) backendOptions.debugLog = options.debugLog;
1071
+ if (options?.messageLog) backendOptions.messageLog = options.messageLog;
1070
1072
  return createBackend({
1071
1073
  type: backendType,
1072
1074
  model: options?.model,
@@ -1575,14 +1577,21 @@ async function runWorkflowWithControllers(config) {
1575
1577
  const backendDebugLog = (msg) => {
1576
1578
  agentLogger.debug(msg);
1577
1579
  };
1580
+ const backendMessageLog = (msg) => {
1581
+ runtime.contextProvider.appendChannel(agentName, msg, { kind: "stream" }).catch(() => {});
1582
+ };
1578
1583
  let backend;
1579
1584
  if (createBackend) backend = createBackend(agentName, agentDef);
1580
1585
  else if (agentDef.backend) backend = getBackendByType(agentDef.backend, {
1581
1586
  model: agentDef.model,
1582
1587
  debugLog: backendDebugLog,
1588
+ messageLog: backendMessageLog,
1583
1589
  timeout: agentDef.timeout
1584
1590
  });
1585
- else if (agentDef.model) backend = getBackendForModel(agentDef.model, { debugLog: backendDebugLog });
1591
+ else if (agentDef.model) backend = getBackendForModel(agentDef.model, {
1592
+ debugLog: backendDebugLog,
1593
+ messageLog: backendMessageLog
1594
+ });
1586
1595
  else throw new Error(`Agent "${agentName}" requires either a backend or model field`);
1587
1596
  logger.debug(`Using backend: ${backend.type} for ${agentName}`);
1588
1597
  const workspaceDir = join(runtime.contextDir, "workspaces", agentName);
@@ -1611,7 +1620,7 @@ async function runWorkflowWithControllers(config) {
1611
1620
  logger.debug("Kickoff sent");
1612
1621
  let channelWatcher;
1613
1622
  if (config.prettyDisplay) {
1614
- const { startPrettyDisplay } = await import("./display-pretty-BL9H2ocr.mjs");
1623
+ const { startPrettyDisplay } = await import("./display-pretty-CWoRE9FY.mjs");
1615
1624
  channelWatcher = startPrettyDisplay({
1616
1625
  contextProvider: runtime.contextProvider,
1617
1626
  agentNames: runtime.agentNames,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-worker",
3
- "version": "0.8.0",
3
+ "version": "0.10.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",