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/cli/index.js CHANGED
@@ -5510,6 +5510,15 @@ var init_extension_provider_instance = __esm({
5510
5510
  pendingEvents: this.flushEvents()
5511
5511
  };
5512
5512
  }
5513
+ getSessionModalState(sessionId) {
5514
+ if (sessionId && sessionId !== this.instanceId) return null;
5515
+ return {
5516
+ id: this.instanceId,
5517
+ status: this.currentStatus,
5518
+ title: this.chatTitle || this.agentName || this.provider.name,
5519
+ activeModal: this.activeModal
5520
+ };
5521
+ }
5513
5522
  onEvent(event, data) {
5514
5523
  if (event === "stream_update") {
5515
5524
  if (data?.streams) this.agentStreams = data.streams;
@@ -6137,6 +6146,23 @@ var init_ide_provider_instance = __esm({
6137
6146
  pendingEvents: this.flushEvents()
6138
6147
  };
6139
6148
  }
6149
+ getSessionModalState(sessionId) {
6150
+ if (sessionId && sessionId !== this.instanceId) {
6151
+ for (const ext of this.extensions.values()) {
6152
+ const projected = ext.getSessionModalState?.(sessionId);
6153
+ if (projected?.id === sessionId) return projected;
6154
+ }
6155
+ return null;
6156
+ }
6157
+ const autoApproveActive = (this.currentStatus === "waiting_approval" || this.cachedChat?.status === "waiting_approval") && this.canAutoApprove();
6158
+ const visibleStatus = autoApproveActive ? "generating" : this.currentStatus;
6159
+ return {
6160
+ id: this.instanceId,
6161
+ status: autoApproveActive && this.cachedChat?.status === "waiting_approval" ? "generating" : this.cachedChat?.status || visibleStatus,
6162
+ title: this.cachedChat?.title || this.type,
6163
+ activeModal: autoApproveActive ? null : this.cachedChat?.activeModal || null
6164
+ };
6165
+ }
6140
6166
  onEvent(event, data) {
6141
6167
  if (event === "cdp_connected") {
6142
6168
  } else if (event === "cdp_disconnected") {
@@ -11372,6 +11398,7 @@ var dist_exports = {};
11372
11398
  __export(dist_exports, {
11373
11399
  DEFAULT_SESSION_HOST_COLS: () => DEFAULT_SESSION_HOST_COLS,
11374
11400
  DEFAULT_SESSION_HOST_ROWS: () => DEFAULT_SESSION_HOST_ROWS,
11401
+ DEFAULT_SESSION_RING_BUFFER_MAX_BYTES: () => DEFAULT_SESSION_RING_BUFFER_MAX_BYTES,
11375
11402
  SessionHostClient: () => SessionHostClient,
11376
11403
  SessionHostRegistry: () => SessionHostRegistry,
11377
11404
  SessionRingBuffer: () => SessionRingBuffer,
@@ -11602,7 +11629,7 @@ function ensureNodePtySpawnHelperPermissions(logFn) {
11602
11629
  } catch {
11603
11630
  }
11604
11631
  }
11605
- var import_crypto3, path9, os9, path22, net, import_crypto4, os22, path32, __require, SessionRingBuffer, DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS, LIVE_LIFECYCLES2, SessionHostRegistry, SessionHostClient;
11632
+ var import_crypto3, path9, os9, path22, net, import_crypto4, os22, path32, __require, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, SessionRingBuffer, DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS, LIVE_LIFECYCLES2, SessionHostRegistry, SessionHostClient;
11606
11633
  var init_dist = __esm({
11607
11634
  "../../oss/packages/session-host-core/dist/index.mjs"() {
11608
11635
  "use strict";
@@ -11620,13 +11647,14 @@ var init_dist = __esm({
11620
11647
  if (typeof require !== "undefined") return require.apply(this, arguments);
11621
11648
  throw Error('Dynamic require of "' + x + '" is not supported');
11622
11649
  });
11650
+ DEFAULT_SESSION_RING_BUFFER_MAX_BYTES = 4 * 1024 * 1024;
11623
11651
  SessionRingBuffer = class {
11624
11652
  maxBytes;
11625
11653
  chunks = [];
11626
11654
  nextSeq = 1;
11627
11655
  totalBytes = 0;
11628
11656
  constructor(options = {}) {
11629
- this.maxBytes = options.maxBytes ?? 512 * 1024;
11657
+ this.maxBytes = options.maxBytes ?? DEFAULT_SESSION_RING_BUFFER_MAX_BYTES;
11630
11658
  }
11631
11659
  append(data) {
11632
11660
  const normalized = typeof data === "string" ? data : String(data ?? "");
@@ -12531,6 +12559,10 @@ function normalizeCliParsedMessages(parsedMessages, options) {
12531
12559
  kind: message.kind,
12532
12560
  id: message.id,
12533
12561
  index: message.index,
12562
+ providerUnitKey: message.providerUnitKey,
12563
+ bubbleId: message.bubbleId,
12564
+ bubbleState: message.bubbleState,
12565
+ _turnKey: message._turnKey,
12534
12566
  meta: message.meta,
12535
12567
  senderName: message.senderName
12536
12568
  })));
@@ -12664,6 +12696,8 @@ function resolveCliSpawnPlan(options) {
12664
12696
  shellCmd = binaryPath;
12665
12697
  shellArgs = allArgs;
12666
12698
  }
12699
+ const env3 = buildCliSpawnEnv(process.env, spawnConfig.env);
12700
+ env3.TERMINAL_CWD = workingDir;
12667
12701
  return {
12668
12702
  binaryPath,
12669
12703
  allArgs,
@@ -12675,7 +12709,7 @@ function resolveCliSpawnPlan(options) {
12675
12709
  cols: DEFAULT_SESSION_HOST_COLS,
12676
12710
  rows: DEFAULT_SESSION_HOST_ROWS,
12677
12711
  cwd: workingDir,
12678
- env: buildCliSpawnEnv(process.env, spawnConfig.env)
12712
+ env: env3
12679
12713
  }
12680
12714
  };
12681
12715
  }
@@ -12971,7 +13005,7 @@ var init_provider_cli_adapter = __esm({
12971
13005
  }
12972
13006
  getFreshParsedStatusCache() {
12973
13007
  const cached2 = this.parsedStatusCache;
12974
- 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) {
13008
+ 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) {
12975
13009
  return cached2.result;
12976
13010
  }
12977
13011
  return null;
@@ -14143,6 +14177,10 @@ var init_provider_cli_adapter = __esm({
14143
14177
  kind: typeof message.kind === "string" ? message.kind : void 0,
14144
14178
  id: typeof message.id === "string" ? message.id : void 0,
14145
14179
  index: typeof message.index === "number" ? message.index : void 0,
14180
+ providerUnitKey: typeof message.providerUnitKey === "string" ? message.providerUnitKey : void 0,
14181
+ bubbleId: typeof message.bubbleId === "string" ? message.bubbleId : void 0,
14182
+ bubbleState: typeof message.bubbleState === "string" ? message.bubbleState : void 0,
14183
+ _turnKey: typeof message._turnKey === "string" ? message._turnKey : void 0,
14146
14184
  meta: message.meta && typeof message.meta === "object" ? { ...message.meta } : void 0,
14147
14185
  senderName: typeof message.senderName === "string" ? message.senderName : void 0
14148
14186
  }));
@@ -14172,6 +14210,10 @@ var init_provider_cli_adapter = __esm({
14172
14210
  kind: message.kind,
14173
14211
  id: message.id || `msg_${index}`,
14174
14212
  index: typeof message.index === "number" ? message.index : index,
14213
+ providerUnitKey: message.providerUnitKey,
14214
+ bubbleId: message.bubbleId,
14215
+ bubbleState: message.bubbleState,
14216
+ _turnKey: message._turnKey,
14175
14217
  meta: message.meta,
14176
14218
  senderName: message.senderName
14177
14219
  };
@@ -14208,6 +14250,10 @@ var init_provider_cli_adapter = __esm({
14208
14250
  senderName: message.senderName,
14209
14251
  id: message.id || `msg_${index}`,
14210
14252
  index: typeof message.index === "number" ? message.index : index,
14253
+ providerUnitKey: message.providerUnitKey,
14254
+ bubbleId: message.bubbleId,
14255
+ bubbleState: message.bubbleState,
14256
+ _turnKey: message._turnKey,
14211
14257
  receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
14212
14258
  });
14213
14259
  });
@@ -14219,7 +14265,7 @@ var init_provider_cli_adapter = __esm({
14219
14265
  getScriptParsedStatus() {
14220
14266
  const screenText = this.readTerminalScreenText();
14221
14267
  const cached2 = this.parsedStatusCache;
14222
- 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) {
14268
+ 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) {
14223
14269
  return cached2.result;
14224
14270
  }
14225
14271
  const parsed = this.parseCurrentTranscript(
@@ -14338,12 +14384,10 @@ var init_provider_cli_adapter = __esm({
14338
14384
  currentTurnScope: this.currentTurnScope,
14339
14385
  recentOutputBuffer: this.recentOutputBuffer,
14340
14386
  accumulatedBuffer: this.accumulatedBuffer,
14341
- accumulatedRawBuffer: this.accumulatedRawBuffer,
14342
14387
  screenText,
14343
14388
  currentStatus: this.currentStatus,
14344
14389
  activeModal: this.activeModal,
14345
14390
  cliName: this.cliName,
14346
- lastOutputAt: this.lastOutputAt,
14347
14391
  result
14348
14392
  };
14349
14393
  return result;
@@ -15432,6 +15476,18 @@ var init_cli_provider_instance = __esm({
15432
15476
  runtimeRecoveryState: runtime?.recoveryState ?? null
15433
15477
  };
15434
15478
  }
15479
+ getSessionModalState() {
15480
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
15481
+ const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
15482
+ const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
15483
+ const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
15484
+ return {
15485
+ id: this.instanceId,
15486
+ status: visibleStatus,
15487
+ title: dirName,
15488
+ activeModal: autoApproveActive ? null : adapterStatus.activeModal
15489
+ };
15490
+ }
15435
15491
  updateSettings(newSettings) {
15436
15492
  this.settings = { ...newSettings };
15437
15493
  this.adapter.updateRuntimeSettings?.(this.settings);
@@ -32469,6 +32525,18 @@ var init_acp_provider_instance = __esm({
32469
32525
  this.detectStatusTransition();
32470
32526
  }
32471
32527
  }
32528
+ getSessionModalState() {
32529
+ const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
32530
+ return {
32531
+ id: this.instanceId,
32532
+ status: this.currentStatus,
32533
+ title: `${this.provider.name} \xB7 ${dirName}`,
32534
+ activeModal: this.currentStatus === "waiting_approval" ? {
32535
+ message: this.activeToolCalls.find((t) => t.status === "running")?.name || "Permission requested",
32536
+ buttons: ["Approve", "Reject"]
32537
+ } : null
32538
+ };
32539
+ }
32472
32540
  getState() {
32473
32541
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
32474
32542
  const recentMessages = normalizeChatMessages(this.messages.map((m) => {
@@ -41266,6 +41334,29 @@ var init_provider_instance_manager = __esm({
41266
41334
  }
41267
41335
  return sessions;
41268
41336
  }
41337
+ getSessionModalState(sessionId, options = {}) {
41338
+ if (!sessionId) return null;
41339
+ const candidates = [sessionId];
41340
+ if (options.instanceKey && options.instanceKey !== sessionId) {
41341
+ candidates.push(options.instanceKey);
41342
+ }
41343
+ for (const id of candidates) {
41344
+ const instance = this.instances.get(id);
41345
+ if (!instance?.getSessionModalState) continue;
41346
+ try {
41347
+ const projected = instance.getSessionModalState(sessionId);
41348
+ if (!projected?.id) continue;
41349
+ if (projected.id !== sessionId) {
41350
+ LOG.warn("InstanceMgr", `[InstanceManager] Ignoring mismatched session modal projection from ${id}: requested=${sessionId} projected=${projected.id}`);
41351
+ continue;
41352
+ }
41353
+ return projected;
41354
+ } catch (e) {
41355
+ LOG.warn("InstanceMgr", `[InstanceManager] Failed to project session modal metadata from ${id}: ${e.message}`);
41356
+ }
41357
+ }
41358
+ return null;
41359
+ }
41269
41360
  /**
41270
41361
  * Per-category status collect
41271
41362
  */
@@ -88320,7 +88411,7 @@ var init_adhdev_daemon = __esm({
88320
88411
  init_version();
88321
88412
  init_src();
88322
88413
  init_runtime_defaults();
88323
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.40" });
88414
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.42" });
88324
88415
  AdhdevDaemon = class _AdhdevDaemon {
88325
88416
  localHttpServer = null;
88326
88417
  localWss = null;
@@ -88636,37 +88727,20 @@ var init_adhdev_daemon = __esm({
88636
88727
  async (subscription) => this.buildSessionHostDiagnosticsUpdateForSubscription(subscription)
88637
88728
  );
88638
88729
  }
88639
- findProviderStateBySessionId(sessionId) {
88730
+ findSessionModalStateBySessionId(sessionId) {
88640
88731
  if (!this.components || !sessionId) return null;
88641
- const directInstance = this.components.instanceManager.getInstance(sessionId);
88642
- if (directInstance) {
88643
- try {
88644
- return directInstance.getState();
88645
- } catch (error48) {
88646
- LOG.warn("P2P", `Failed to collect subscribed session state for ${sessionId}: ${error48?.message || String(error48)}`);
88647
- return null;
88648
- }
88649
- }
88650
- for (const instance of this.components.instanceManager.getByCategory("ide")) {
88651
- try {
88652
- const state = instance.getState();
88653
- if (state.instanceId === sessionId) return state;
88654
- if (state.category !== "ide") continue;
88655
- const child = state.extensions.find((entry) => entry.instanceId === sessionId);
88656
- if (child) return child;
88657
- } catch (error48) {
88658
- LOG.warn("P2P", `Failed to collect IDE child state for ${sessionId}: ${error48?.message || String(error48)}`);
88659
- }
88660
- }
88661
- return null;
88732
+ const target = this.components.sessionRegistry.get(sessionId);
88733
+ return this.components.instanceManager.getSessionModalState(sessionId, {
88734
+ instanceKey: target?.instanceKey
88735
+ });
88662
88736
  }
88663
88737
  buildSessionModalUpdateForSubscription(subscription) {
88664
- const state = this.findProviderStateBySessionId(subscription.params.targetSessionId);
88738
+ const state = this.findSessionModalStateBySessionId(subscription.params.targetSessionId);
88665
88739
  if (!state) return null;
88666
88740
  const now = Date.now();
88667
- const activeModal = state.activeChat?.activeModal;
88668
- const status = String(state.activeChat?.status || state.status || "idle");
88669
- const title = typeof state.activeChat?.title === "string" ? state.activeChat.title : void 0;
88741
+ const activeModal = state.activeModal;
88742
+ const status = String(state.status || "idle");
88743
+ const title = typeof state.title === "string" ? state.title : void 0;
88670
88744
  const interactionId = this.getSessionInteractionId(subscription.params.targetSessionId);
88671
88745
  const prepared = prepareSessionModalUpdate({
88672
88746
  key: subscription.key,