adhdev 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.
package/dist/index.js CHANGED
@@ -4990,6 +4990,15 @@ var init_extension_provider_instance = __esm({
4990
4990
  pendingEvents: this.flushEvents()
4991
4991
  };
4992
4992
  }
4993
+ getSessionModalState(sessionId) {
4994
+ if (sessionId && sessionId !== this.instanceId) return null;
4995
+ return {
4996
+ id: this.instanceId,
4997
+ status: this.currentStatus,
4998
+ title: this.chatTitle || this.agentName || this.provider.name,
4999
+ activeModal: this.activeModal
5000
+ };
5001
+ }
4993
5002
  onEvent(event, data) {
4994
5003
  if (event === "stream_update") {
4995
5004
  if (data?.streams) this.agentStreams = data.streams;
@@ -5617,6 +5626,23 @@ var init_ide_provider_instance = __esm({
5617
5626
  pendingEvents: this.flushEvents()
5618
5627
  };
5619
5628
  }
5629
+ getSessionModalState(sessionId) {
5630
+ if (sessionId && sessionId !== this.instanceId) {
5631
+ for (const ext of this.extensions.values()) {
5632
+ const projected = ext.getSessionModalState?.(sessionId);
5633
+ if (projected?.id === sessionId) return projected;
5634
+ }
5635
+ return null;
5636
+ }
5637
+ const autoApproveActive = (this.currentStatus === "waiting_approval" || this.cachedChat?.status === "waiting_approval") && this.canAutoApprove();
5638
+ const visibleStatus = autoApproveActive ? "generating" : this.currentStatus;
5639
+ return {
5640
+ id: this.instanceId,
5641
+ status: autoApproveActive && this.cachedChat?.status === "waiting_approval" ? "generating" : this.cachedChat?.status || visibleStatus,
5642
+ title: this.cachedChat?.title || this.type,
5643
+ activeModal: autoApproveActive ? null : this.cachedChat?.activeModal || null
5644
+ };
5645
+ }
5620
5646
  onEvent(event, data) {
5621
5647
  if (event === "cdp_connected") {
5622
5648
  } else if (event === "cdp_disconnected") {
@@ -10924,7 +10950,7 @@ function ensureNodePtySpawnHelperPermissions(logFn) {
10924
10950
  } catch {
10925
10951
  }
10926
10952
  }
10927
- var os8, path22, net, import_crypto3, os22, path32, __require, DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS, SessionHostClient;
10953
+ var os8, path22, net, import_crypto3, os22, path32, __require, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS, SessionHostClient;
10928
10954
  var init_dist = __esm({
10929
10955
  "../../oss/packages/session-host-core/dist/index.mjs"() {
10930
10956
  "use strict";
@@ -10940,6 +10966,7 @@ var init_dist = __esm({
10940
10966
  if (typeof require !== "undefined") return require.apply(this, arguments);
10941
10967
  throw Error('Dynamic require of "' + x + '" is not supported');
10942
10968
  });
10969
+ DEFAULT_SESSION_RING_BUFFER_MAX_BYTES = 4 * 1024 * 1024;
10943
10970
  DEFAULT_SESSION_HOST_COLS = 80;
10944
10971
  DEFAULT_SESSION_HOST_ROWS = 32;
10945
10972
  SessionHostClient = class {
@@ -11575,6 +11602,10 @@ function normalizeCliParsedMessages(parsedMessages, options) {
11575
11602
  kind: message.kind,
11576
11603
  id: message.id,
11577
11604
  index: message.index,
11605
+ providerUnitKey: message.providerUnitKey,
11606
+ bubbleId: message.bubbleId,
11607
+ bubbleState: message.bubbleState,
11608
+ _turnKey: message._turnKey,
11578
11609
  meta: message.meta,
11579
11610
  senderName: message.senderName
11580
11611
  })));
@@ -11708,6 +11739,8 @@ function resolveCliSpawnPlan(options) {
11708
11739
  shellCmd = binaryPath;
11709
11740
  shellArgs = allArgs;
11710
11741
  }
11742
+ const env3 = buildCliSpawnEnv(process.env, spawnConfig.env);
11743
+ env3.TERMINAL_CWD = workingDir;
11711
11744
  return {
11712
11745
  binaryPath,
11713
11746
  allArgs,
@@ -11719,7 +11752,7 @@ function resolveCliSpawnPlan(options) {
11719
11752
  cols: DEFAULT_SESSION_HOST_COLS,
11720
11753
  rows: DEFAULT_SESSION_HOST_ROWS,
11721
11754
  cwd: workingDir,
11722
- env: buildCliSpawnEnv(process.env, spawnConfig.env)
11755
+ env: env3
11723
11756
  }
11724
11757
  };
11725
11758
  }
@@ -12015,7 +12048,7 @@ var init_provider_cli_adapter = __esm({
12015
12048
  }
12016
12049
  getFreshParsedStatusCache() {
12017
12050
  const cached2 = this.parsedStatusCache;
12018
- if (cached2 && cached2.committedMessagesRef === this.committedMessages && cached2.responseBuffer === this.responseBuffer && cached2.currentTurnScope === this.currentTurnScope && cached2.recentOutputBuffer === this.recentOutputBuffer && cached2.accumulatedBuffer === this.accumulatedBuffer && cached2.accumulatedRawBuffer === this.accumulatedRawBuffer && cached2.screenText === this.lastScreenText && cached2.currentStatus === this.currentStatus && cached2.activeModal === this.activeModal && cached2.cliName === this.cliName && cached2.lastOutputAt === this.lastOutputAt) {
12051
+ if (cached2 && cached2.committedMessagesRef === this.committedMessages && cached2.responseBuffer === this.responseBuffer && cached2.currentTurnScope === this.currentTurnScope && cached2.recentOutputBuffer === this.recentOutputBuffer && cached2.accumulatedBuffer === this.accumulatedBuffer && cached2.screenText === this.lastScreenText && cached2.currentStatus === this.currentStatus && cached2.activeModal === this.activeModal && cached2.cliName === this.cliName) {
12019
12052
  return cached2.result;
12020
12053
  }
12021
12054
  return null;
@@ -13187,6 +13220,10 @@ var init_provider_cli_adapter = __esm({
13187
13220
  kind: typeof message.kind === "string" ? message.kind : void 0,
13188
13221
  id: typeof message.id === "string" ? message.id : void 0,
13189
13222
  index: typeof message.index === "number" ? message.index : void 0,
13223
+ providerUnitKey: typeof message.providerUnitKey === "string" ? message.providerUnitKey : void 0,
13224
+ bubbleId: typeof message.bubbleId === "string" ? message.bubbleId : void 0,
13225
+ bubbleState: typeof message.bubbleState === "string" ? message.bubbleState : void 0,
13226
+ _turnKey: typeof message._turnKey === "string" ? message._turnKey : void 0,
13190
13227
  meta: message.meta && typeof message.meta === "object" ? { ...message.meta } : void 0,
13191
13228
  senderName: typeof message.senderName === "string" ? message.senderName : void 0
13192
13229
  }));
@@ -13216,6 +13253,10 @@ var init_provider_cli_adapter = __esm({
13216
13253
  kind: message.kind,
13217
13254
  id: message.id || `msg_${index}`,
13218
13255
  index: typeof message.index === "number" ? message.index : index,
13256
+ providerUnitKey: message.providerUnitKey,
13257
+ bubbleId: message.bubbleId,
13258
+ bubbleState: message.bubbleState,
13259
+ _turnKey: message._turnKey,
13219
13260
  meta: message.meta,
13220
13261
  senderName: message.senderName
13221
13262
  };
@@ -13252,6 +13293,10 @@ var init_provider_cli_adapter = __esm({
13252
13293
  senderName: message.senderName,
13253
13294
  id: message.id || `msg_${index}`,
13254
13295
  index: typeof message.index === "number" ? message.index : index,
13296
+ providerUnitKey: message.providerUnitKey,
13297
+ bubbleId: message.bubbleId,
13298
+ bubbleState: message.bubbleState,
13299
+ _turnKey: message._turnKey,
13255
13300
  receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
13256
13301
  });
13257
13302
  });
@@ -13263,7 +13308,7 @@ var init_provider_cli_adapter = __esm({
13263
13308
  getScriptParsedStatus() {
13264
13309
  const screenText = this.readTerminalScreenText();
13265
13310
  const cached2 = this.parsedStatusCache;
13266
- if (cached2 && cached2.committedMessagesRef === this.committedMessages && cached2.responseBuffer === this.responseBuffer && cached2.currentTurnScope === this.currentTurnScope && cached2.recentOutputBuffer === this.recentOutputBuffer && cached2.accumulatedBuffer === this.accumulatedBuffer && cached2.accumulatedRawBuffer === this.accumulatedRawBuffer && cached2.screenText === screenText && cached2.currentStatus === this.currentStatus && cached2.activeModal === this.activeModal && cached2.cliName === this.cliName && cached2.lastOutputAt === this.lastOutputAt) {
13311
+ if (cached2 && cached2.committedMessagesRef === this.committedMessages && cached2.responseBuffer === this.responseBuffer && cached2.currentTurnScope === this.currentTurnScope && cached2.recentOutputBuffer === this.recentOutputBuffer && cached2.accumulatedBuffer === this.accumulatedBuffer && cached2.screenText === screenText && cached2.currentStatus === this.currentStatus && cached2.activeModal === this.activeModal && cached2.cliName === this.cliName) {
13267
13312
  return cached2.result;
13268
13313
  }
13269
13314
  const parsed = this.parseCurrentTranscript(
@@ -13382,12 +13427,10 @@ var init_provider_cli_adapter = __esm({
13382
13427
  currentTurnScope: this.currentTurnScope,
13383
13428
  recentOutputBuffer: this.recentOutputBuffer,
13384
13429
  accumulatedBuffer: this.accumulatedBuffer,
13385
- accumulatedRawBuffer: this.accumulatedRawBuffer,
13386
13430
  screenText,
13387
13431
  currentStatus: this.currentStatus,
13388
13432
  activeModal: this.activeModal,
13389
13433
  cliName: this.cliName,
13390
- lastOutputAt: this.lastOutputAt,
13391
13434
  result
13392
13435
  };
13393
13436
  return result;
@@ -14476,6 +14519,18 @@ var init_cli_provider_instance = __esm({
14476
14519
  runtimeRecoveryState: runtime?.recoveryState ?? null
14477
14520
  };
14478
14521
  }
14522
+ getSessionModalState() {
14523
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
14524
+ const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
14525
+ const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
14526
+ const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
14527
+ return {
14528
+ id: this.instanceId,
14529
+ status: visibleStatus,
14530
+ title: dirName,
14531
+ activeModal: autoApproveActive ? null : adapterStatus.activeModal
14532
+ };
14533
+ }
14479
14534
  updateSettings(newSettings) {
14480
14535
  this.settings = { ...newSettings };
14481
14536
  this.adapter.updateRuntimeSettings?.(this.settings);
@@ -31513,6 +31568,18 @@ var init_acp_provider_instance = __esm({
31513
31568
  this.detectStatusTransition();
31514
31569
  }
31515
31570
  }
31571
+ getSessionModalState() {
31572
+ const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
31573
+ return {
31574
+ id: this.instanceId,
31575
+ status: this.currentStatus,
31576
+ title: `${this.provider.name} \xB7 ${dirName}`,
31577
+ activeModal: this.currentStatus === "waiting_approval" ? {
31578
+ message: this.activeToolCalls.find((t) => t.status === "running")?.name || "Permission requested",
31579
+ buttons: ["Approve", "Reject"]
31580
+ } : null
31581
+ };
31582
+ }
31516
31583
  getState() {
31517
31584
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
31518
31585
  const recentMessages = normalizeChatMessages(this.messages.map((m) => {
@@ -40310,6 +40377,29 @@ var init_provider_instance_manager = __esm({
40310
40377
  }
40311
40378
  return sessions;
40312
40379
  }
40380
+ getSessionModalState(sessionId, options = {}) {
40381
+ if (!sessionId) return null;
40382
+ const candidates = [sessionId];
40383
+ if (options.instanceKey && options.instanceKey !== sessionId) {
40384
+ candidates.push(options.instanceKey);
40385
+ }
40386
+ for (const id of candidates) {
40387
+ const instance = this.instances.get(id);
40388
+ if (!instance?.getSessionModalState) continue;
40389
+ try {
40390
+ const projected = instance.getSessionModalState(sessionId);
40391
+ if (!projected?.id) continue;
40392
+ if (projected.id !== sessionId) {
40393
+ LOG.warn("InstanceMgr", `[InstanceManager] Ignoring mismatched session modal projection from ${id}: requested=${sessionId} projected=${projected.id}`);
40394
+ continue;
40395
+ }
40396
+ return projected;
40397
+ } catch (e) {
40398
+ LOG.warn("InstanceMgr", `[InstanceManager] Failed to project session modal metadata from ${id}: ${e.message}`);
40399
+ }
40400
+ }
40401
+ return null;
40402
+ }
40313
40403
  /**
40314
40404
  * Per-category status collect
40315
40405
  */
@@ -56600,7 +56690,7 @@ var init_adhdev_daemon = __esm({
56600
56690
  init_version();
56601
56691
  init_src();
56602
56692
  init_runtime_defaults();
56603
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.40" });
56693
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.42" });
56604
56694
  AdhdevDaemon = class _AdhdevDaemon {
56605
56695
  localHttpServer = null;
56606
56696
  localWss = null;
@@ -56916,37 +57006,20 @@ var init_adhdev_daemon = __esm({
56916
57006
  async (subscription) => this.buildSessionHostDiagnosticsUpdateForSubscription(subscription)
56917
57007
  );
56918
57008
  }
56919
- findProviderStateBySessionId(sessionId) {
57009
+ findSessionModalStateBySessionId(sessionId) {
56920
57010
  if (!this.components || !sessionId) return null;
56921
- const directInstance = this.components.instanceManager.getInstance(sessionId);
56922
- if (directInstance) {
56923
- try {
56924
- return directInstance.getState();
56925
- } catch (error48) {
56926
- LOG.warn("P2P", `Failed to collect subscribed session state for ${sessionId}: ${error48?.message || String(error48)}`);
56927
- return null;
56928
- }
56929
- }
56930
- for (const instance of this.components.instanceManager.getByCategory("ide")) {
56931
- try {
56932
- const state = instance.getState();
56933
- if (state.instanceId === sessionId) return state;
56934
- if (state.category !== "ide") continue;
56935
- const child = state.extensions.find((entry) => entry.instanceId === sessionId);
56936
- if (child) return child;
56937
- } catch (error48) {
56938
- LOG.warn("P2P", `Failed to collect IDE child state for ${sessionId}: ${error48?.message || String(error48)}`);
56939
- }
56940
- }
56941
- return null;
57011
+ const target = this.components.sessionRegistry.get(sessionId);
57012
+ return this.components.instanceManager.getSessionModalState(sessionId, {
57013
+ instanceKey: target?.instanceKey
57014
+ });
56942
57015
  }
56943
57016
  buildSessionModalUpdateForSubscription(subscription) {
56944
- const state = this.findProviderStateBySessionId(subscription.params.targetSessionId);
57017
+ const state = this.findSessionModalStateBySessionId(subscription.params.targetSessionId);
56945
57018
  if (!state) return null;
56946
57019
  const now = Date.now();
56947
- const activeModal = state.activeChat?.activeModal;
56948
- const status = String(state.activeChat?.status || state.status || "idle");
56949
- const title = typeof state.activeChat?.title === "string" ? state.activeChat.title : void 0;
57020
+ const activeModal = state.activeModal;
57021
+ const status = String(state.status || "idle");
57022
+ const title = typeof state.title === "string" ? state.title : void 0;
56950
57023
  const interactionId = this.getSessionInteractionId(subscription.params.targetSessionId);
56951
57024
  const prepared = prepareSessionModalUpdate({
56952
57025
  key: subscription.key,