@wagemule/daemon 0.1.9 → 0.1.10

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/main.cjs CHANGED
@@ -1941,6 +1941,11 @@ var KimiAdapter = class {
1941
1941
  return;
1942
1942
  }
1943
1943
  if (active) {
1944
+ if (parsed.retry) active.lastRetry = parsed.retry;
1945
+ if (parsed.interrupted) {
1946
+ active.status = "runtime_error";
1947
+ active.errorMessage = kimiInterruptedMessage(active.lastRetry);
1948
+ }
1944
1949
  if (parsed.appendFinalMessage) active.append(parsed.appendFinalMessage);
1945
1950
  if (parsed.finalMessage) active.set(parsed.finalMessage);
1946
1951
  if (parsed.finished || parsed.events.some((event) => event.type === "turn_finished")) active.finish();
@@ -2000,15 +2005,51 @@ function parseKimiWireLine(line) {
2000
2005
  if (eventType === "TurnEnd") {
2001
2006
  return { finished: true, events: [{ type: "turn_finished", data: msg }] };
2002
2007
  }
2008
+ if (eventType === "ToolCallPart") {
2009
+ return { events: [] };
2010
+ }
2011
+ if (eventType === "ToolCall") {
2012
+ return {
2013
+ events: [{ type: "tool_start", content: text ?? stringValue5(payload.name), data: msg }]
2014
+ };
2015
+ }
2016
+ if (eventType === "ToolResult") {
2017
+ return {
2018
+ events: [{ type: "tool_result", content: text, data: msg }]
2019
+ };
2020
+ }
2021
+ if (eventType === "StepRetry") {
2022
+ return {
2023
+ retry: kimiRetryInfo(payload),
2024
+ events: [{ type: "runtime_event", content: text, data: msg }]
2025
+ };
2026
+ }
2027
+ if (eventType === "StepInterrupted") {
2028
+ return {
2029
+ interrupted: true,
2030
+ events: [{ type: "runtime_error", content: "Kimi step interrupted", data: msg }]
2031
+ };
2032
+ }
2003
2033
  return {
2004
2034
  events: [{ type: kimiEventName(eventType), content: text, data: msg }]
2005
2035
  };
2006
2036
  }
2007
2037
  function kimiEventName(eventType) {
2008
- if (/tool/i.test(eventType)) return "tool_progress";
2009
2038
  if (/begin|status|loading|retry|compaction|hook|notification/i.test(eventType)) return "runtime_event";
2010
2039
  return eventType;
2011
2040
  }
2041
+ function kimiRetryInfo(payload) {
2042
+ const statusCode = typeof payload.status_code === "number" ? payload.status_code : void 0;
2043
+ const errorType = typeof payload.error_type === "string" ? payload.error_type : void 0;
2044
+ return { errorType, statusCode };
2045
+ }
2046
+ function kimiInterruptedMessage(retry) {
2047
+ if (retry?.statusCode) {
2048
+ const type = retry.errorType ? `${retry.errorType} ` : "";
2049
+ return `Kimi step interrupted after ${type}${retry.statusCode}`;
2050
+ }
2051
+ return "Kimi step interrupted";
2052
+ }
2012
2053
  function stringValue5(value) {
2013
2054
  return typeof value === "string" ? value : void 0;
2014
2055
  }
@@ -3974,7 +4015,7 @@ var import_ws = __toESM(require("ws"));
3974
4015
  // package.json
3975
4016
  var package_default = {
3976
4017
  name: "@wagemule/daemon",
3977
- version: "0.1.9",
4018
+ version: "0.1.10",
3978
4019
  private: false,
3979
4020
  description: "Wage Mule local daemon for connecting local agent runtimes to Workspace Server.",
3980
4021
  main: "./dist/main.cjs",
@@ -3998,7 +4039,7 @@ var package_default = {
3998
4039
  start: "node dist/main.cjs",
3999
4040
  prepack: "npm run build",
4000
4041
  "pack:check": "node scripts/pack-check.mjs",
4001
- test: "node --import tsx src/workspace/agent-workspace.test.ts && node --import tsx src/workspace/feishu-token-writer.test.ts && node --import tsx src/agent-manager/workspace-browser.test.ts && node --import tsx src/agent-manager/agent-process-manager.memory.test.ts && node --import tsx src/agent-manager/agent-process-manager.delivery.test.ts && node --import tsx src/agent-manager/agent-process-manager.model-validation.test.ts && node --import tsx src/agent-manager/skill-scanner.test.ts && node --import tsx src/runtime/capabilities.test.ts && node --import tsx src/runtime/model-detector.test.ts && node --import tsx src/runtime/persistent-adapter.test.ts && node --import tsx src/runtime/json-rpc-stdio-client.test.ts && node --import tsx src/runtime/acp-adapter.test.ts && node --import tsx src/runtime/codex-adapter.test.ts && node --import tsx src/runtime/claude-adapter.test.ts && node --import tsx src/testing/smoke-harness.test.ts && node --import tsx src/lab/lab-store.test.ts && node --import tsx src/lab/lab-ui.test.ts && node --import tsx src/lab/interactive-lab.test.ts && node --import tsx src/main.test.ts && node --import tsx src/testing/integration.test.ts",
4042
+ test: "node --import tsx src/workspace/agent-workspace.test.ts && node --import tsx src/workspace/feishu-token-writer.test.ts && node --import tsx src/agent-manager/workspace-browser.test.ts && node --import tsx src/agent-manager/agent-process-manager.memory.test.ts && node --import tsx src/agent-manager/agent-process-manager.delivery.test.ts && node --import tsx src/agent-manager/agent-process-manager.model-validation.test.ts && node --import tsx src/agent-manager/skill-scanner.test.ts && node --import tsx src/runtime/capabilities.test.ts && node --import tsx src/runtime/model-detector.test.ts && node --import tsx src/runtime/persistent-adapter.test.ts && node --import tsx src/runtime/json-rpc-stdio-client.test.ts && node --import tsx src/runtime/acp-adapter.test.ts && node --import tsx src/runtime/codex-adapter.test.ts && node --import tsx src/runtime/claude-adapter.test.ts && node --import tsx src/runtime/kimi-adapter.test.ts && node --import tsx src/testing/smoke-harness.test.ts && node --import tsx src/lab/lab-store.test.ts && node --import tsx src/lab/lab-ui.test.ts && node --import tsx src/lab/interactive-lab.test.ts && node --import tsx src/main.test.ts && node --import tsx src/testing/integration.test.ts",
4002
4043
  "test:real": "node --import tsx src/testing/integration-real.test.ts",
4003
4044
  typecheck: "tsc --noEmit"
4004
4045
  },
@@ -4158,7 +4199,7 @@ function summarizeDaemonMessage(msg) {
4158
4199
  return base;
4159
4200
  }
4160
4201
  function shouldLogDaemonMessage(msg) {
4161
- return !(msg.type === "agent:activity" && msg.detail === "assistant_delta");
4202
+ return !(msg.type === "agent:activity" && (msg.detail === "assistant_delta" || msg.detail === "tool_progress"));
4162
4203
  }
4163
4204
  function summarizeServerMessage(msg) {
4164
4205
  const base = `type=${msg.type}`;
@@ -4953,6 +4994,7 @@ function shellQuote(value) {
4953
4994
  // src/agent-manager/activity-tracker.ts
4954
4995
  var ActivityTracker = class {
4955
4996
  clientSeq = 0;
4997
+ lastProgressAt = /* @__PURE__ */ new Map();
4956
4998
  toEntries(events) {
4957
4999
  return events.flatMap((event) => this.toEntry(event));
4958
5000
  }
@@ -4960,6 +5002,13 @@ var ActivityTracker = class {
4960
5002
  this.clientSeq += 1;
4961
5003
  return this.clientSeq;
4962
5004
  }
5005
+ shouldPublishProgress(key, intervalMs) {
5006
+ const now = Date.now();
5007
+ const last = this.lastProgressAt.get(key) ?? 0;
5008
+ if (now - last < intervalMs) return false;
5009
+ this.lastProgressAt.set(key, now);
5010
+ return true;
5011
+ }
4963
5012
  toEntry(event) {
4964
5013
  const timestamp = Date.now();
4965
5014
  if (event.type.includes("tool")) {
@@ -5228,11 +5277,13 @@ var AgentProcessManager = class {
5228
5277
  "Feishu delegation tick.",
5229
5278
  `Human ID: ${delegation.human_id}`,
5230
5279
  `Delegation ID: ${delegation.id}`,
5231
- `Read Feishu messages from the last ${lookbackMinutes} minutes only. Never send, reply, react, or mutate Feishu during this tick.`,
5232
- "For each new inbound Feishu message that needs a reply, draft a concise reply and create exactly one inbox item with:",
5280
+ `Read Feishu messages from the last ${lookbackMinutes} minutes only by using the injected .wm/lark-cli wrapper and the lark-im skill. Do not use runtime TaskList or background task tools for Feishu messages.`,
5281
+ "For each new inbound Feishu message that needs a reply, first create exactly one inbox item as the dedupe/process record:",
5233
5282
  "wm inbox feishu-draft create --delegation-id <delegation_id> --human-id <human_id> --feishu-message-id <message_id> --chat-id <chat_id> --sender-name <name> --sender-open-id <open_id> --original-text <summary> --draft-text <draft>",
5234
- "Deduplicate by Feishu message_id. If there are no new relevant messages, do nothing.",
5235
- "Do not call lark-cli im +messages-send or any other Feishu send command unless a later approved inbox task explicitly asks you to send."
5283
+ "If the reply is low-risk and routine, send exactly that draft once with lark-cli im +messages-reply or lark-cli im +messages-send, then run: wm inbox feishu-draft sent --id <Inbox ID> --message-id <sent message_id>",
5284
+ "If the reply is uncertain, sensitive, or high-risk, do not send it; leave the inbox item open for human approval.",
5285
+ "If sending fails, run: wm inbox feishu-draft failed --id <Inbox ID> --error <short error>.",
5286
+ "Deduplicate by Feishu message_id. If there are no new relevant messages, do nothing."
5236
5287
  ].join("\n")
5237
5288
  };
5238
5289
  void this.enqueueStart({
@@ -5628,7 +5679,9 @@ var AgentProcessManager = class {
5628
5679
  deltaLogCount += 1;
5629
5680
  } else {
5630
5681
  flushDeltaLog();
5631
- this.log(`runtime event agent=${agentId} type=${event.type}${event.content ? ` text=${compact(event.content)}` : ""}`);
5682
+ if (event.type !== "tool_progress") {
5683
+ this.log(`runtime event agent=${agentId} type=${event.type}${event.content ? ` text=${compact(event.content)}` : ""}`);
5684
+ }
5632
5685
  }
5633
5686
  const running = this.running.get(agentId);
5634
5687
  if (running) {
@@ -5661,6 +5714,7 @@ var AgentProcessManager = class {
5661
5714
  }
5662
5715
  }
5663
5716
  const entries = tracker.toEntries([event]);
5717
+ if (event.type === "tool_progress" && !tracker.shouldPublishProgress("tool_progress", 1e3)) return;
5664
5718
  this.sendActivity({
5665
5719
  agentId,
5666
5720
  activity: "working",