@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.js CHANGED
@@ -1843,6 +1843,10 @@ function normalizeCliParsedMessages(parsedMessages, options) {
1843
1843
  kind: message.kind,
1844
1844
  id: message.id,
1845
1845
  index: message.index,
1846
+ providerUnitKey: message.providerUnitKey,
1847
+ bubbleId: message.bubbleId,
1848
+ bubbleState: message.bubbleState,
1849
+ _turnKey: message._turnKey,
1846
1850
  meta: message.meta,
1847
1851
  senderName: message.senderName
1848
1852
  })));
@@ -1976,6 +1980,8 @@ function resolveCliSpawnPlan(options) {
1976
1980
  shellCmd = binaryPath;
1977
1981
  shellArgs = allArgs;
1978
1982
  }
1983
+ const env = buildCliSpawnEnv(process.env, spawnConfig.env);
1984
+ env.TERMINAL_CWD = workingDir;
1979
1985
  return {
1980
1986
  binaryPath,
1981
1987
  allArgs,
@@ -1987,7 +1993,7 @@ function resolveCliSpawnPlan(options) {
1987
1993
  cols: import_session_host_core2.DEFAULT_SESSION_HOST_COLS,
1988
1994
  rows: import_session_host_core2.DEFAULT_SESSION_HOST_ROWS,
1989
1995
  cwd: workingDir,
1990
- env: buildCliSpawnEnv(process.env, spawnConfig.env)
1996
+ env
1991
1997
  }
1992
1998
  };
1993
1999
  }
@@ -2283,7 +2289,7 @@ var init_provider_cli_adapter = __esm({
2283
2289
  }
2284
2290
  getFreshParsedStatusCache() {
2285
2291
  const cached = this.parsedStatusCache;
2286
- 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) {
2292
+ 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) {
2287
2293
  return cached.result;
2288
2294
  }
2289
2295
  return null;
@@ -3455,6 +3461,10 @@ var init_provider_cli_adapter = __esm({
3455
3461
  kind: typeof message.kind === "string" ? message.kind : void 0,
3456
3462
  id: typeof message.id === "string" ? message.id : void 0,
3457
3463
  index: typeof message.index === "number" ? message.index : void 0,
3464
+ providerUnitKey: typeof message.providerUnitKey === "string" ? message.providerUnitKey : void 0,
3465
+ bubbleId: typeof message.bubbleId === "string" ? message.bubbleId : void 0,
3466
+ bubbleState: typeof message.bubbleState === "string" ? message.bubbleState : void 0,
3467
+ _turnKey: typeof message._turnKey === "string" ? message._turnKey : void 0,
3458
3468
  meta: message.meta && typeof message.meta === "object" ? { ...message.meta } : void 0,
3459
3469
  senderName: typeof message.senderName === "string" ? message.senderName : void 0
3460
3470
  }));
@@ -3484,6 +3494,10 @@ var init_provider_cli_adapter = __esm({
3484
3494
  kind: message.kind,
3485
3495
  id: message.id || `msg_${index}`,
3486
3496
  index: typeof message.index === "number" ? message.index : index,
3497
+ providerUnitKey: message.providerUnitKey,
3498
+ bubbleId: message.bubbleId,
3499
+ bubbleState: message.bubbleState,
3500
+ _turnKey: message._turnKey,
3487
3501
  meta: message.meta,
3488
3502
  senderName: message.senderName
3489
3503
  };
@@ -3520,6 +3534,10 @@ var init_provider_cli_adapter = __esm({
3520
3534
  senderName: message.senderName,
3521
3535
  id: message.id || `msg_${index}`,
3522
3536
  index: typeof message.index === "number" ? message.index : index,
3537
+ providerUnitKey: message.providerUnitKey,
3538
+ bubbleId: message.bubbleId,
3539
+ bubbleState: message.bubbleState,
3540
+ _turnKey: message._turnKey,
3523
3541
  receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
3524
3542
  });
3525
3543
  });
@@ -3531,7 +3549,7 @@ var init_provider_cli_adapter = __esm({
3531
3549
  getScriptParsedStatus() {
3532
3550
  const screenText = this.readTerminalScreenText();
3533
3551
  const cached = this.parsedStatusCache;
3534
- 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) {
3552
+ 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) {
3535
3553
  return cached.result;
3536
3554
  }
3537
3555
  const parsed = this.parseCurrentTranscript(
@@ -3650,12 +3668,10 @@ var init_provider_cli_adapter = __esm({
3650
3668
  currentTurnScope: this.currentTurnScope,
3651
3669
  recentOutputBuffer: this.recentOutputBuffer,
3652
3670
  accumulatedBuffer: this.accumulatedBuffer,
3653
- accumulatedRawBuffer: this.accumulatedRawBuffer,
3654
3671
  screenText,
3655
3672
  currentStatus: this.currentStatus,
3656
3673
  activeModal: this.activeModal,
3657
3674
  cliName: this.cliName,
3658
- lastOutputAt: this.lastOutputAt,
3659
3675
  result
3660
3676
  };
3661
3677
  return result;
@@ -8521,6 +8537,15 @@ var ExtensionProviderInstance = class {
8521
8537
  pendingEvents: this.flushEvents()
8522
8538
  };
8523
8539
  }
8540
+ getSessionModalState(sessionId) {
8541
+ if (sessionId && sessionId !== this.instanceId) return null;
8542
+ return {
8543
+ id: this.instanceId,
8544
+ status: this.currentStatus,
8545
+ title: this.chatTitle || this.agentName || this.provider.name,
8546
+ activeModal: this.activeModal
8547
+ };
8548
+ }
8524
8549
  onEvent(event, data) {
8525
8550
  if (event === "stream_update") {
8526
8551
  if (data?.streams) this.agentStreams = data.streams;
@@ -8987,6 +9012,23 @@ var IdeProviderInstance = class {
8987
9012
  pendingEvents: this.flushEvents()
8988
9013
  };
8989
9014
  }
9015
+ getSessionModalState(sessionId) {
9016
+ if (sessionId && sessionId !== this.instanceId) {
9017
+ for (const ext of this.extensions.values()) {
9018
+ const projected = ext.getSessionModalState?.(sessionId);
9019
+ if (projected?.id === sessionId) return projected;
9020
+ }
9021
+ return null;
9022
+ }
9023
+ const autoApproveActive = (this.currentStatus === "waiting_approval" || this.cachedChat?.status === "waiting_approval") && this.canAutoApprove();
9024
+ const visibleStatus = autoApproveActive ? "generating" : this.currentStatus;
9025
+ return {
9026
+ id: this.instanceId,
9027
+ status: autoApproveActive && this.cachedChat?.status === "waiting_approval" ? "generating" : this.cachedChat?.status || visibleStatus,
9028
+ title: this.cachedChat?.title || this.type,
9029
+ activeModal: autoApproveActive ? null : this.cachedChat?.activeModal || null
9030
+ };
9031
+ }
8990
9032
  onEvent(event, data) {
8991
9033
  if (event === "cdp_connected") {
8992
9034
  } else if (event === "cdp_disconnected") {
@@ -13651,6 +13693,18 @@ var CliProviderInstance = class {
13651
13693
  runtimeRecoveryState: runtime?.recoveryState ?? null
13652
13694
  };
13653
13695
  }
13696
+ getSessionModalState() {
13697
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
13698
+ const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
13699
+ const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
13700
+ const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
13701
+ return {
13702
+ id: this.instanceId,
13703
+ status: visibleStatus,
13704
+ title: dirName,
13705
+ activeModal: autoApproveActive ? null : adapterStatus.activeModal
13706
+ };
13707
+ }
13654
13708
  updateSettings(newSettings) {
13655
13709
  this.settings = { ...newSettings };
13656
13710
  this.adapter.updateRuntimeSettings?.(this.settings);
@@ -14378,6 +14432,18 @@ var AcpProviderInstance = class {
14378
14432
  this.detectStatusTransition();
14379
14433
  }
14380
14434
  }
14435
+ getSessionModalState() {
14436
+ const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
14437
+ return {
14438
+ id: this.instanceId,
14439
+ status: this.currentStatus,
14440
+ title: `${this.provider.name} \xB7 ${dirName}`,
14441
+ activeModal: this.currentStatus === "waiting_approval" ? {
14442
+ message: this.activeToolCalls.find((t) => t.status === "running")?.name || "Permission requested",
14443
+ buttons: ["Approve", "Reject"]
14444
+ } : null
14445
+ };
14446
+ }
14381
14447
  getState() {
14382
14448
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
14383
14449
  const recentMessages = normalizeChatMessages(this.messages.map((m) => {
@@ -21260,6 +21326,29 @@ var ProviderInstanceManager = class {
21260
21326
  }
21261
21327
  return sessions;
21262
21328
  }
21329
+ getSessionModalState(sessionId, options = {}) {
21330
+ if (!sessionId) return null;
21331
+ const candidates = [sessionId];
21332
+ if (options.instanceKey && options.instanceKey !== sessionId) {
21333
+ candidates.push(options.instanceKey);
21334
+ }
21335
+ for (const id of candidates) {
21336
+ const instance = this.instances.get(id);
21337
+ if (!instance?.getSessionModalState) continue;
21338
+ try {
21339
+ const projected = instance.getSessionModalState(sessionId);
21340
+ if (!projected?.id) continue;
21341
+ if (projected.id !== sessionId) {
21342
+ LOG.warn("InstanceMgr", `[InstanceManager] Ignoring mismatched session modal projection from ${id}: requested=${sessionId} projected=${projected.id}`);
21343
+ continue;
21344
+ }
21345
+ return projected;
21346
+ } catch (e) {
21347
+ LOG.warn("InstanceMgr", `[InstanceManager] Failed to project session modal metadata from ${id}: ${e.message}`);
21348
+ }
21349
+ }
21350
+ return null;
21351
+ }
21263
21352
  /**
21264
21353
  * Per-category status collect
21265
21354
  */