@wagemule/daemon 0.1.5 → 0.1.6

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
@@ -3888,7 +3888,7 @@ var import_ws = __toESM(require("ws"));
3888
3888
  // package.json
3889
3889
  var package_default = {
3890
3890
  name: "@wagemule/daemon",
3891
- version: "0.1.4",
3891
+ version: "0.1.6",
3892
3892
  private: false,
3893
3893
  description: "Wage Mule local daemon for connecting local agent runtimes to Workspace Server.",
3894
3894
  main: "./dist/main.cjs",
@@ -3910,6 +3910,7 @@ var package_default = {
3910
3910
  dev: "tsx watch src/main.ts",
3911
3911
  build: "node scripts/build.mjs",
3912
3912
  start: "node dist/main.cjs",
3913
+ prepack: "npm run build",
3913
3914
  "pack:check": "node scripts/pack-check.mjs",
3914
3915
  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",
3915
3916
  "test:real": "node --import tsx src/testing/integration-real.test.ts",
@@ -3966,7 +3967,9 @@ var ServerConnection = class {
3966
3967
  this.log(`send skipped socket=closed msg=${summarizeDaemonMessage(msg)}`);
3967
3968
  return;
3968
3969
  }
3969
- this.log(`send ${summarizeDaemonMessage(msg)}`);
3970
+ if (shouldLogDaemonMessage(msg)) {
3971
+ this.log(`send ${summarizeDaemonMessage(msg)}`);
3972
+ }
3970
3973
  this.ws?.send(JSON.stringify(msg));
3971
3974
  }
3972
3975
  onMessage(handler) {
@@ -4055,6 +4058,9 @@ function summarizeDaemonMessage(msg) {
4055
4058
  if ("agentId" in msg) return `${base} agent=${msg.agentId}`;
4056
4059
  return base;
4057
4060
  }
4061
+ function shouldLogDaemonMessage(msg) {
4062
+ return !(msg.type === "agent:activity" && msg.detail === "assistant_delta");
4063
+ }
4058
4064
  function summarizeServerMessage(msg) {
4059
4065
  const base = `type=${msg.type}`;
4060
4066
  if ("agentId" in msg) return `${base} agent=${msg.agentId}`;
@@ -5084,8 +5090,12 @@ var AgentProcessManager = class {
5084
5090
  });
5085
5091
  if (!delegation.enabled) return;
5086
5092
  const intervalMs = Math.max(6e4, delegation.interval_seconds * 1e3);
5087
- const lookbackMinutes = Math.min(60, Math.max(10, Math.ceil(delegation.interval_seconds * 2 / 60)));
5093
+ const lookbackMinutes = feishuDelegationLookbackMinutes(delegation.interval_seconds);
5088
5094
  const timer = setInterval(() => {
5095
+ if (this.shouldSkipScheduledFeishuWake(delegation.delegate_agent_id)) {
5096
+ this.log(`feishu delegation tick skipped agent=${delegation.delegate_agent_id} delegation=${delegation.id} reason=agent_busy`);
5097
+ return;
5098
+ }
5089
5099
  const wakeMessage = {
5090
5100
  target: "feishu:delegation",
5091
5101
  message_id: `feishu-${delegation.id}-${Date.now()}`,
@@ -5122,6 +5132,11 @@ var AgentProcessManager = class {
5122
5132
  }, intervalMs);
5123
5133
  this.feishuDelegationTimers.set(delegation.id, timer);
5124
5134
  }
5135
+ shouldSkipScheduledFeishuWake(agentId) {
5136
+ if (this.starting.has(agentId)) return true;
5137
+ const running = this.running.get(agentId);
5138
+ return running !== void 0 && running.state !== "idle";
5139
+ }
5125
5140
  stopFeishuDelegationSchedule(delegationId) {
5126
5141
  const timer = this.feishuDelegationTimers.get(delegationId);
5127
5142
  if (timer) clearInterval(timer);
@@ -5447,8 +5462,22 @@ var AgentProcessManager = class {
5447
5462
  [Runtime Profile Migration] Your runtime configuration has been updated. Before handling the above, re-ground yourself in the new context, then run: \`${workspace.wrapperPath} profile migration-ack --key ${migrationKey}\`` : basePrompt;
5448
5463
  const tracker = new ActivityTracker();
5449
5464
  const requestPermission = (request) => this.requestRuntimePermission(agentId, launchId, request);
5465
+ let deltaLogText = "";
5466
+ let deltaLogCount = 0;
5467
+ const flushDeltaLog = () => {
5468
+ if (!deltaLogCount) return;
5469
+ this.log(`runtime stream agent=${agentId} type=assistant_delta chunks=${deltaLogCount} text=${compact(deltaLogText)}`);
5470
+ deltaLogText = "";
5471
+ deltaLogCount = 0;
5472
+ };
5450
5473
  const onEvent = (event) => {
5451
- this.log(`runtime event agent=${agentId} type=${event.type}${event.content ? ` text=${compact(event.content)}` : ""}`);
5474
+ if (event.type === "assistant_delta") {
5475
+ if (event.content) deltaLogText += event.content;
5476
+ deltaLogCount += 1;
5477
+ } else {
5478
+ flushDeltaLog();
5479
+ this.log(`runtime event agent=${agentId} type=${event.type}${event.content ? ` text=${compact(event.content)}` : ""}`);
5480
+ }
5452
5481
  const running = this.running.get(agentId);
5453
5482
  if (running) {
5454
5483
  running.lastRuntimeEventAt = Date.now();
@@ -5557,6 +5586,7 @@ var AgentProcessManager = class {
5557
5586
  requestPermission
5558
5587
  });
5559
5588
  }
5589
+ flushDeltaLog();
5560
5590
  if (result.runtimeSessionId) {
5561
5591
  this.log(`runtime session agent=${agentId} session=${result.runtimeSessionId}`);
5562
5592
  const running = this.running.get(agentId);
@@ -6294,6 +6324,9 @@ function dedupeDeliveredMessages(messages) {
6294
6324
  }
6295
6325
  return deduped;
6296
6326
  }
6327
+ function feishuDelegationLookbackMinutes(intervalSeconds) {
6328
+ return Math.min(60, Math.max(2, Math.ceil((intervalSeconds + 60) / 60)));
6329
+ }
6297
6330
  function selectRuntimeModel(detection, requestedModel) {
6298
6331
  if (detection.models.length === 0) {
6299
6332
  if (requestedModel === "default") return void 0;