@adhdev/daemon-core 0.9.77-rc.34 → 0.9.77-rc.35

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/index.mjs CHANGED
@@ -1478,12 +1478,14 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
1478
1478
  return "";
1479
1479
  }
1480
1480
  function injectMeshSystemMessage(components, args) {
1481
+ let completedTaskForLedger = null;
1481
1482
  if (args.event === "agent:generating_completed") {
1482
1483
  const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
1483
1484
  const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
1484
1485
  const providerType = readNonEmptyString(args.metadataEvent.providerType);
1485
1486
  if (sessionId) {
1486
- updateSessionTaskStatus(args.meshId, sessionId, "completed");
1487
+ const completedTask = updateSessionTaskStatus(args.meshId, sessionId, "completed");
1488
+ completedTaskForLedger = completedTask ? { id: completedTask.id } : null;
1487
1489
  if (nodeId && providerType) {
1488
1490
  setTimeout(() => {
1489
1491
  tryAssignQueueTask(components, args.meshId, nodeId, sessionId, providerType);
@@ -1496,6 +1498,7 @@ function injectMeshSystemMessage(components, args) {
1496
1498
  const providerType = readNonEmptyString(args.metadataEvent.providerType);
1497
1499
  const completedTask = sessionId ? updateSessionTaskStatus(args.meshId, sessionId, "completed") : null;
1498
1500
  if (completedTask) {
1501
+ completedTaskForLedger = { id: completedTask.id };
1499
1502
  try {
1500
1503
  appendLedgerEntry(args.meshId, {
1501
1504
  kind: "task_completed",
@@ -1507,7 +1510,8 @@ function injectMeshSystemMessage(components, args) {
1507
1510
  nodeLabel: args.nodeLabel,
1508
1511
  taskId: completedTask.id,
1509
1512
  completedViaReady: true,
1510
- providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0
1513
+ providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0,
1514
+ finalSummary: readNonEmptyString(args.metadataEvent.finalSummary) || void 0
1511
1515
  }
1512
1516
  });
1513
1517
  } catch (e) {
@@ -1550,7 +1554,9 @@ function injectMeshSystemMessage(components, args) {
1550
1554
  payload: {
1551
1555
  event: args.event,
1552
1556
  nodeLabel: args.nodeLabel,
1553
- providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0
1557
+ taskId: completedTaskForLedger?.id || void 0,
1558
+ providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0,
1559
+ finalSummary: readNonEmptyString(args.metadataEvent.finalSummary) || void 0
1554
1560
  }
1555
1561
  });
1556
1562
  } catch (e) {
@@ -1665,7 +1671,8 @@ function handleMeshForwardEvent(components, payload) {
1665
1671
  metadataEvent: {
1666
1672
  targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId) || readNonEmptyString(payload.instanceId),
1667
1673
  providerType: readNonEmptyString(payload.providerType),
1668
- providerSessionId: readNonEmptyString(payload.providerSessionId)
1674
+ providerSessionId: readNonEmptyString(payload.providerSessionId),
1675
+ finalSummary: readNonEmptyString(payload.finalSummary) || readNonEmptyString(payload.summary)
1669
1676
  }
1670
1677
  });
1671
1678
  }
@@ -3890,6 +3897,11 @@ ${lastSnapshot}`;
3890
3897
  };
3891
3898
  }
3892
3899
  // ─── Script Execution ──────────────────────────
3900
+ invokeCliScript(script, input) {
3901
+ const hasStateFactory = typeof this.cliScripts?.createState === "function";
3902
+ const expectsStateArgument = hasStateFactory || this.scriptState !== null || script.length >= 2;
3903
+ return expectsStateArgument ? script(this.scriptState, input) : script(input);
3904
+ }
3893
3905
  runParseSession() {
3894
3906
  if (typeof this.cliScripts?.parseSession !== "function") {
3895
3907
  this.parseErrorMessage = `${this.cliType} parseSession unavailable`;
@@ -3910,7 +3922,10 @@ ${lastSnapshot}`;
3910
3922
  scope: this.currentTurnScope,
3911
3923
  runtimeSettings: this.runtimeSettings
3912
3924
  });
3913
- const session = this.cliScripts.parseSession(this.scriptState, { ...input, tail, tailScreen: buildCliScreenSnapshot(tail) });
3925
+ const session = this.invokeCliScript(
3926
+ this.cliScripts.parseSession,
3927
+ { ...input, tail, tailScreen: buildCliScreenSnapshot(tail) }
3928
+ );
3914
3929
  this.parseErrorMessage = null;
3915
3930
  return session && typeof session === "object" ? session : null;
3916
3931
  } catch (e) {
@@ -3924,7 +3939,7 @@ ${lastSnapshot}`;
3924
3939
  if (!this.cliScripts?.detectStatus) return null;
3925
3940
  try {
3926
3941
  const screenText = this.terminalScreen.getText();
3927
- const status = this.cliScripts.detectStatus(this.scriptState, {
3942
+ const status = this.invokeCliScript(this.cliScripts.detectStatus, {
3928
3943
  tail: text.slice(-500),
3929
3944
  screenText,
3930
3945
  rawBuffer: this.accumulatedRawBuffer,
@@ -3943,7 +3958,7 @@ ${lastSnapshot}`;
3943
3958
  try {
3944
3959
  const screenText = this.terminalScreen.getText();
3945
3960
  const buffer = screenText || this.accumulatedBuffer;
3946
- return this.cliScripts.parseApproval(this.scriptState, {
3961
+ return this.invokeCliScript(this.cliScripts.parseApproval, {
3947
3962
  buffer,
3948
3963
  screenText,
3949
3964
  rawBuffer: this.accumulatedRawBuffer,
@@ -23926,7 +23941,13 @@ var DaemonCommandRouter = class {
23926
23941
  appendLedgerEntry2(meshId, {
23927
23942
  kind: "node_removed",
23928
23943
  nodeId,
23929
- payload: { worktree: !!node?.isLocalWorktree, sessionCleanupMode }
23944
+ payload: {
23945
+ worktree: !!node?.isLocalWorktree,
23946
+ sessionCleanupMode,
23947
+ workspace: typeof node?.workspace === "string" ? node.workspace : void 0,
23948
+ daemonId: typeof node?.daemonId === "string" ? node.daemonId : void 0,
23949
+ worktreeBranch: typeof node?.worktreeBranch === "string" ? node.worktreeBranch : void 0
23950
+ }
23930
23951
  });
23931
23952
  } catch {
23932
23953
  }