@adhdev/daemon-core 0.9.40 → 0.9.42

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.
Files changed (27) hide show
  1. package/dist/index.js +94 -5
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +94 -5
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/providers/acp-provider-instance.d.ts +2 -1
  6. package/dist/providers/cli-provider-instance.d.ts +2 -1
  7. package/dist/providers/extension-provider-instance.d.ts +2 -1
  8. package/dist/providers/ide-provider-instance.d.ts +2 -1
  9. package/dist/providers/provider-instance-manager.d.ts +4 -1
  10. package/dist/providers/provider-instance.d.ts +11 -0
  11. package/node_modules/@adhdev/session-host-core/dist/index.d.mts +2 -1
  12. package/node_modules/@adhdev/session-host-core/dist/index.d.ts +2 -1
  13. package/node_modules/@adhdev/session-host-core/dist/index.js +4 -1
  14. package/node_modules/@adhdev/session-host-core/dist/index.js.map +1 -1
  15. package/node_modules/@adhdev/session-host-core/dist/index.mjs +3 -1
  16. package/node_modules/@adhdev/session-host-core/dist/index.mjs.map +1 -1
  17. package/node_modules/@adhdev/session-host-core/package.json +1 -1
  18. package/package.json +1 -1
  19. package/src/cli-adapters/provider-cli-adapter.ts +12 -8
  20. package/src/cli-adapters/provider-cli-parse.ts +4 -0
  21. package/src/cli-adapters/provider-cli-runtime.ts +7 -1
  22. package/src/providers/acp-provider-instance.ts +14 -1
  23. package/src/providers/cli-provider-instance.ts +14 -1
  24. package/src/providers/extension-provider-instance.ts +11 -1
  25. package/src/providers/ide-provider-instance.ts +25 -1
  26. package/src/providers/provider-instance-manager.ts +27 -1
  27. package/src/providers/provider-instance.ts +13 -0
package/dist/index.mjs CHANGED
@@ -1841,6 +1841,10 @@ function normalizeCliParsedMessages(parsedMessages, options) {
1841
1841
  kind: message.kind,
1842
1842
  id: message.id,
1843
1843
  index: message.index,
1844
+ providerUnitKey: message.providerUnitKey,
1845
+ bubbleId: message.bubbleId,
1846
+ bubbleState: message.bubbleState,
1847
+ _turnKey: message._turnKey,
1844
1848
  meta: message.meta,
1845
1849
  senderName: message.senderName
1846
1850
  })));
@@ -1977,6 +1981,8 @@ function resolveCliSpawnPlan(options) {
1977
1981
  shellCmd = binaryPath;
1978
1982
  shellArgs = allArgs;
1979
1983
  }
1984
+ const env = buildCliSpawnEnv(process.env, spawnConfig.env);
1985
+ env.TERMINAL_CWD = workingDir;
1980
1986
  return {
1981
1987
  binaryPath,
1982
1988
  allArgs,
@@ -1988,7 +1994,7 @@ function resolveCliSpawnPlan(options) {
1988
1994
  cols: DEFAULT_SESSION_HOST_COLS,
1989
1995
  rows: DEFAULT_SESSION_HOST_ROWS,
1990
1996
  cwd: workingDir,
1991
- env: buildCliSpawnEnv(process.env, spawnConfig.env)
1997
+ env
1992
1998
  }
1993
1999
  };
1994
2000
  }
@@ -2280,7 +2286,7 @@ var init_provider_cli_adapter = __esm({
2280
2286
  }
2281
2287
  getFreshParsedStatusCache() {
2282
2288
  const cached = this.parsedStatusCache;
2283
- if (cached && cached.committedMessagesRef === this.committedMessages && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.accumulatedRawBuffer === this.accumulatedRawBuffer && cached.screenText === this.lastScreenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName && cached.lastOutputAt === this.lastOutputAt) {
2289
+ if (cached && cached.committedMessagesRef === this.committedMessages && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.screenText === this.lastScreenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName) {
2284
2290
  return cached.result;
2285
2291
  }
2286
2292
  return null;
@@ -3452,6 +3458,10 @@ var init_provider_cli_adapter = __esm({
3452
3458
  kind: typeof message.kind === "string" ? message.kind : void 0,
3453
3459
  id: typeof message.id === "string" ? message.id : void 0,
3454
3460
  index: typeof message.index === "number" ? message.index : void 0,
3461
+ providerUnitKey: typeof message.providerUnitKey === "string" ? message.providerUnitKey : void 0,
3462
+ bubbleId: typeof message.bubbleId === "string" ? message.bubbleId : void 0,
3463
+ bubbleState: typeof message.bubbleState === "string" ? message.bubbleState : void 0,
3464
+ _turnKey: typeof message._turnKey === "string" ? message._turnKey : void 0,
3455
3465
  meta: message.meta && typeof message.meta === "object" ? { ...message.meta } : void 0,
3456
3466
  senderName: typeof message.senderName === "string" ? message.senderName : void 0
3457
3467
  }));
@@ -3481,6 +3491,10 @@ var init_provider_cli_adapter = __esm({
3481
3491
  kind: message.kind,
3482
3492
  id: message.id || `msg_${index}`,
3483
3493
  index: typeof message.index === "number" ? message.index : index,
3494
+ providerUnitKey: message.providerUnitKey,
3495
+ bubbleId: message.bubbleId,
3496
+ bubbleState: message.bubbleState,
3497
+ _turnKey: message._turnKey,
3484
3498
  meta: message.meta,
3485
3499
  senderName: message.senderName
3486
3500
  };
@@ -3517,6 +3531,10 @@ var init_provider_cli_adapter = __esm({
3517
3531
  senderName: message.senderName,
3518
3532
  id: message.id || `msg_${index}`,
3519
3533
  index: typeof message.index === "number" ? message.index : index,
3534
+ providerUnitKey: message.providerUnitKey,
3535
+ bubbleId: message.bubbleId,
3536
+ bubbleState: message.bubbleState,
3537
+ _turnKey: message._turnKey,
3520
3538
  receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
3521
3539
  });
3522
3540
  });
@@ -3528,7 +3546,7 @@ var init_provider_cli_adapter = __esm({
3528
3546
  getScriptParsedStatus() {
3529
3547
  const screenText = this.readTerminalScreenText();
3530
3548
  const cached = this.parsedStatusCache;
3531
- if (cached && cached.committedMessagesRef === this.committedMessages && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.accumulatedRawBuffer === this.accumulatedRawBuffer && cached.screenText === screenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName && cached.lastOutputAt === this.lastOutputAt) {
3549
+ if (cached && cached.committedMessagesRef === this.committedMessages && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.screenText === screenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName) {
3532
3550
  return cached.result;
3533
3551
  }
3534
3552
  const parsed = this.parseCurrentTranscript(
@@ -3647,12 +3665,10 @@ var init_provider_cli_adapter = __esm({
3647
3665
  currentTurnScope: this.currentTurnScope,
3648
3666
  recentOutputBuffer: this.recentOutputBuffer,
3649
3667
  accumulatedBuffer: this.accumulatedBuffer,
3650
- accumulatedRawBuffer: this.accumulatedRawBuffer,
3651
3668
  screenText,
3652
3669
  currentStatus: this.currentStatus,
3653
3670
  activeModal: this.activeModal,
3654
3671
  cliName: this.cliName,
3655
- lastOutputAt: this.lastOutputAt,
3656
3672
  result
3657
3673
  };
3658
3674
  return result;
@@ -8368,6 +8384,15 @@ var ExtensionProviderInstance = class {
8368
8384
  pendingEvents: this.flushEvents()
8369
8385
  };
8370
8386
  }
8387
+ getSessionModalState(sessionId) {
8388
+ if (sessionId && sessionId !== this.instanceId) return null;
8389
+ return {
8390
+ id: this.instanceId,
8391
+ status: this.currentStatus,
8392
+ title: this.chatTitle || this.agentName || this.provider.name,
8393
+ activeModal: this.activeModal
8394
+ };
8395
+ }
8371
8396
  onEvent(event, data) {
8372
8397
  if (event === "stream_update") {
8373
8398
  if (data?.streams) this.agentStreams = data.streams;
@@ -8834,6 +8859,23 @@ var IdeProviderInstance = class {
8834
8859
  pendingEvents: this.flushEvents()
8835
8860
  };
8836
8861
  }
8862
+ getSessionModalState(sessionId) {
8863
+ if (sessionId && sessionId !== this.instanceId) {
8864
+ for (const ext of this.extensions.values()) {
8865
+ const projected = ext.getSessionModalState?.(sessionId);
8866
+ if (projected?.id === sessionId) return projected;
8867
+ }
8868
+ return null;
8869
+ }
8870
+ const autoApproveActive = (this.currentStatus === "waiting_approval" || this.cachedChat?.status === "waiting_approval") && this.canAutoApprove();
8871
+ const visibleStatus = autoApproveActive ? "generating" : this.currentStatus;
8872
+ return {
8873
+ id: this.instanceId,
8874
+ status: autoApproveActive && this.cachedChat?.status === "waiting_approval" ? "generating" : this.cachedChat?.status || visibleStatus,
8875
+ title: this.cachedChat?.title || this.type,
8876
+ activeModal: autoApproveActive ? null : this.cachedChat?.activeModal || null
8877
+ };
8878
+ }
8837
8879
  onEvent(event, data) {
8838
8880
  if (event === "cdp_connected") {
8839
8881
  } else if (event === "cdp_disconnected") {
@@ -13498,6 +13540,18 @@ var CliProviderInstance = class {
13498
13540
  runtimeRecoveryState: runtime?.recoveryState ?? null
13499
13541
  };
13500
13542
  }
13543
+ getSessionModalState() {
13544
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
13545
+ const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
13546
+ const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
13547
+ const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
13548
+ return {
13549
+ id: this.instanceId,
13550
+ status: visibleStatus,
13551
+ title: dirName,
13552
+ activeModal: autoApproveActive ? null : adapterStatus.activeModal
13553
+ };
13554
+ }
13501
13555
  updateSettings(newSettings) {
13502
13556
  this.settings = { ...newSettings };
13503
13557
  this.adapter.updateRuntimeSettings?.(this.settings);
@@ -14230,6 +14284,18 @@ var AcpProviderInstance = class {
14230
14284
  this.detectStatusTransition();
14231
14285
  }
14232
14286
  }
14287
+ getSessionModalState() {
14288
+ const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
14289
+ return {
14290
+ id: this.instanceId,
14291
+ status: this.currentStatus,
14292
+ title: `${this.provider.name} \xB7 ${dirName}`,
14293
+ activeModal: this.currentStatus === "waiting_approval" ? {
14294
+ message: this.activeToolCalls.find((t) => t.status === "running")?.name || "Permission requested",
14295
+ buttons: ["Approve", "Reject"]
14296
+ } : null
14297
+ };
14298
+ }
14233
14299
  getState() {
14234
14300
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
14235
14301
  const recentMessages = normalizeChatMessages(this.messages.map((m) => {
@@ -21112,6 +21178,29 @@ var ProviderInstanceManager = class {
21112
21178
  }
21113
21179
  return sessions;
21114
21180
  }
21181
+ getSessionModalState(sessionId, options = {}) {
21182
+ if (!sessionId) return null;
21183
+ const candidates = [sessionId];
21184
+ if (options.instanceKey && options.instanceKey !== sessionId) {
21185
+ candidates.push(options.instanceKey);
21186
+ }
21187
+ for (const id of candidates) {
21188
+ const instance = this.instances.get(id);
21189
+ if (!instance?.getSessionModalState) continue;
21190
+ try {
21191
+ const projected = instance.getSessionModalState(sessionId);
21192
+ if (!projected?.id) continue;
21193
+ if (projected.id !== sessionId) {
21194
+ LOG.warn("InstanceMgr", `[InstanceManager] Ignoring mismatched session modal projection from ${id}: requested=${sessionId} projected=${projected.id}`);
21195
+ continue;
21196
+ }
21197
+ return projected;
21198
+ } catch (e) {
21199
+ LOG.warn("InstanceMgr", `[InstanceManager] Failed to project session modal metadata from ${id}: ${e.message}`);
21200
+ }
21201
+ }
21202
+ return null;
21203
+ }
21115
21204
  /**
21116
21205
  * Per-category status collect
21117
21206
  */