@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.
@@ -163,6 +163,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
163
163
  private finishResponse;
164
164
  private maybeCommitVisibleIdleTranscript;
165
165
  private commitCurrentTranscript;
166
+ private invokeCliScript;
166
167
  private runParseSession;
167
168
  private runDetectStatus;
168
169
  private runParseApproval;
package/dist/index.js CHANGED
@@ -1484,12 +1484,14 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
1484
1484
  return "";
1485
1485
  }
1486
1486
  function injectMeshSystemMessage(components, args) {
1487
+ let completedTaskForLedger = null;
1487
1488
  if (args.event === "agent:generating_completed") {
1488
1489
  const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
1489
1490
  const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
1490
1491
  const providerType = readNonEmptyString(args.metadataEvent.providerType);
1491
1492
  if (sessionId) {
1492
- updateSessionTaskStatus(args.meshId, sessionId, "completed");
1493
+ const completedTask = updateSessionTaskStatus(args.meshId, sessionId, "completed");
1494
+ completedTaskForLedger = completedTask ? { id: completedTask.id } : null;
1493
1495
  if (nodeId && providerType) {
1494
1496
  setTimeout(() => {
1495
1497
  tryAssignQueueTask(components, args.meshId, nodeId, sessionId, providerType);
@@ -1502,6 +1504,7 @@ function injectMeshSystemMessage(components, args) {
1502
1504
  const providerType = readNonEmptyString(args.metadataEvent.providerType);
1503
1505
  const completedTask = sessionId ? updateSessionTaskStatus(args.meshId, sessionId, "completed") : null;
1504
1506
  if (completedTask) {
1507
+ completedTaskForLedger = { id: completedTask.id };
1505
1508
  try {
1506
1509
  appendLedgerEntry(args.meshId, {
1507
1510
  kind: "task_completed",
@@ -1513,7 +1516,8 @@ function injectMeshSystemMessage(components, args) {
1513
1516
  nodeLabel: args.nodeLabel,
1514
1517
  taskId: completedTask.id,
1515
1518
  completedViaReady: true,
1516
- providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0
1519
+ providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0,
1520
+ finalSummary: readNonEmptyString(args.metadataEvent.finalSummary) || void 0
1517
1521
  }
1518
1522
  });
1519
1523
  } catch (e) {
@@ -1556,7 +1560,9 @@ function injectMeshSystemMessage(components, args) {
1556
1560
  payload: {
1557
1561
  event: args.event,
1558
1562
  nodeLabel: args.nodeLabel,
1559
- providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0
1563
+ taskId: completedTaskForLedger?.id || void 0,
1564
+ providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0,
1565
+ finalSummary: readNonEmptyString(args.metadataEvent.finalSummary) || void 0
1560
1566
  }
1561
1567
  });
1562
1568
  } catch (e) {
@@ -1671,7 +1677,8 @@ function handleMeshForwardEvent(components, payload) {
1671
1677
  metadataEvent: {
1672
1678
  targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId) || readNonEmptyString(payload.instanceId),
1673
1679
  providerType: readNonEmptyString(payload.providerType),
1674
- providerSessionId: readNonEmptyString(payload.providerSessionId)
1680
+ providerSessionId: readNonEmptyString(payload.providerSessionId),
1681
+ finalSummary: readNonEmptyString(payload.finalSummary) || readNonEmptyString(payload.summary)
1675
1682
  }
1676
1683
  });
1677
1684
  }
@@ -3894,6 +3901,11 @@ ${lastSnapshot}`;
3894
3901
  };
3895
3902
  }
3896
3903
  // ─── Script Execution ──────────────────────────
3904
+ invokeCliScript(script, input) {
3905
+ const hasStateFactory = typeof this.cliScripts?.createState === "function";
3906
+ const expectsStateArgument = hasStateFactory || this.scriptState !== null || script.length >= 2;
3907
+ return expectsStateArgument ? script(this.scriptState, input) : script(input);
3908
+ }
3897
3909
  runParseSession() {
3898
3910
  if (typeof this.cliScripts?.parseSession !== "function") {
3899
3911
  this.parseErrorMessage = `${this.cliType} parseSession unavailable`;
@@ -3914,7 +3926,10 @@ ${lastSnapshot}`;
3914
3926
  scope: this.currentTurnScope,
3915
3927
  runtimeSettings: this.runtimeSettings
3916
3928
  });
3917
- const session = this.cliScripts.parseSession(this.scriptState, { ...input, tail, tailScreen: buildCliScreenSnapshot(tail) });
3929
+ const session = this.invokeCliScript(
3930
+ this.cliScripts.parseSession,
3931
+ { ...input, tail, tailScreen: buildCliScreenSnapshot(tail) }
3932
+ );
3918
3933
  this.parseErrorMessage = null;
3919
3934
  return session && typeof session === "object" ? session : null;
3920
3935
  } catch (e) {
@@ -3928,7 +3943,7 @@ ${lastSnapshot}`;
3928
3943
  if (!this.cliScripts?.detectStatus) return null;
3929
3944
  try {
3930
3945
  const screenText = this.terminalScreen.getText();
3931
- const status = this.cliScripts.detectStatus(this.scriptState, {
3946
+ const status = this.invokeCliScript(this.cliScripts.detectStatus, {
3932
3947
  tail: text.slice(-500),
3933
3948
  screenText,
3934
3949
  rawBuffer: this.accumulatedRawBuffer,
@@ -3947,7 +3962,7 @@ ${lastSnapshot}`;
3947
3962
  try {
3948
3963
  const screenText = this.terminalScreen.getText();
3949
3964
  const buffer = screenText || this.accumulatedBuffer;
3950
- return this.cliScripts.parseApproval(this.scriptState, {
3965
+ return this.invokeCliScript(this.cliScripts.parseApproval, {
3951
3966
  buffer,
3952
3967
  screenText,
3953
3968
  rawBuffer: this.accumulatedRawBuffer,
@@ -24145,7 +24160,13 @@ var DaemonCommandRouter = class {
24145
24160
  appendLedgerEntry2(meshId, {
24146
24161
  kind: "node_removed",
24147
24162
  nodeId,
24148
- payload: { worktree: !!node?.isLocalWorktree, sessionCleanupMode }
24163
+ payload: {
24164
+ worktree: !!node?.isLocalWorktree,
24165
+ sessionCleanupMode,
24166
+ workspace: typeof node?.workspace === "string" ? node.workspace : void 0,
24167
+ daemonId: typeof node?.daemonId === "string" ? node.daemonId : void 0,
24168
+ worktreeBranch: typeof node?.worktreeBranch === "string" ? node.worktreeBranch : void 0
24169
+ }
24149
24170
  });
24150
24171
  } catch {
24151
24172
  }