@adhdev/daemon-standalone 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
@@ -9164,6 +9164,7 @@ var require_dist = __commonJS({
9164
9164
  __export2(index_exports, {
9165
9165
  DEFAULT_SESSION_HOST_COLS: () => DEFAULT_SESSION_HOST_COLS,
9166
9166
  DEFAULT_SESSION_HOST_ROWS: () => DEFAULT_SESSION_HOST_ROWS,
9167
+ DEFAULT_SESSION_RING_BUFFER_MAX_BYTES: () => DEFAULT_SESSION_RING_BUFFER_MAX_BYTES2,
9167
9168
  SessionHostClient: () => SessionHostClient2,
9168
9169
  SessionHostRegistry: () => SessionHostRegistry,
9169
9170
  SessionRingBuffer: () => SessionRingBuffer,
@@ -9188,13 +9189,14 @@ var require_dist = __commonJS({
9188
9189
  writeEnvelope: () => writeEnvelope
9189
9190
  });
9190
9191
  module2.exports = __toCommonJS2(index_exports);
9192
+ var DEFAULT_SESSION_RING_BUFFER_MAX_BYTES2 = 4 * 1024 * 1024;
9191
9193
  var SessionRingBuffer = class {
9192
9194
  maxBytes;
9193
9195
  chunks = [];
9194
9196
  nextSeq = 1;
9195
9197
  totalBytes = 0;
9196
9198
  constructor(options = {}) {
9197
- this.maxBytes = options.maxBytes ?? 512 * 1024;
9199
+ this.maxBytes = options.maxBytes ?? DEFAULT_SESSION_RING_BUFFER_MAX_BYTES2;
9198
9200
  }
9199
9201
  append(data) {
9200
9202
  const normalized = typeof data === "string" ? data : String(data ?? "");
@@ -29713,6 +29715,10 @@ var require_dist2 = __commonJS({
29713
29715
  kind: message.kind,
29714
29716
  id: message.id,
29715
29717
  index: message.index,
29718
+ providerUnitKey: message.providerUnitKey,
29719
+ bubbleId: message.bubbleId,
29720
+ bubbleState: message.bubbleState,
29721
+ _turnKey: message._turnKey,
29716
29722
  meta: message.meta,
29717
29723
  senderName: message.senderName
29718
29724
  })));
@@ -29842,6 +29848,8 @@ var require_dist2 = __commonJS({
29842
29848
  shellCmd = binaryPath;
29843
29849
  shellArgs = allArgs;
29844
29850
  }
29851
+ const env = buildCliSpawnEnv(process.env, spawnConfig.env);
29852
+ env.TERMINAL_CWD = workingDir;
29845
29853
  return {
29846
29854
  binaryPath,
29847
29855
  allArgs,
@@ -29853,7 +29861,7 @@ var require_dist2 = __commonJS({
29853
29861
  cols: import_session_host_core22.DEFAULT_SESSION_HOST_COLS,
29854
29862
  rows: import_session_host_core22.DEFAULT_SESSION_HOST_ROWS,
29855
29863
  cwd: workingDir,
29856
- env: buildCliSpawnEnv(process.env, spawnConfig.env)
29864
+ env
29857
29865
  }
29858
29866
  };
29859
29867
  }
@@ -30150,7 +30158,7 @@ var require_dist2 = __commonJS({
30150
30158
  }
30151
30159
  getFreshParsedStatusCache() {
30152
30160
  const cached2 = this.parsedStatusCache;
30153
- 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) {
30161
+ 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) {
30154
30162
  return cached2.result;
30155
30163
  }
30156
30164
  return null;
@@ -31322,6 +31330,10 @@ var require_dist2 = __commonJS({
31322
31330
  kind: typeof message.kind === "string" ? message.kind : void 0,
31323
31331
  id: typeof message.id === "string" ? message.id : void 0,
31324
31332
  index: typeof message.index === "number" ? message.index : void 0,
31333
+ providerUnitKey: typeof message.providerUnitKey === "string" ? message.providerUnitKey : void 0,
31334
+ bubbleId: typeof message.bubbleId === "string" ? message.bubbleId : void 0,
31335
+ bubbleState: typeof message.bubbleState === "string" ? message.bubbleState : void 0,
31336
+ _turnKey: typeof message._turnKey === "string" ? message._turnKey : void 0,
31325
31337
  meta: message.meta && typeof message.meta === "object" ? { ...message.meta } : void 0,
31326
31338
  senderName: typeof message.senderName === "string" ? message.senderName : void 0
31327
31339
  }));
@@ -31351,6 +31363,10 @@ var require_dist2 = __commonJS({
31351
31363
  kind: message.kind,
31352
31364
  id: message.id || `msg_${index}`,
31353
31365
  index: typeof message.index === "number" ? message.index : index,
31366
+ providerUnitKey: message.providerUnitKey,
31367
+ bubbleId: message.bubbleId,
31368
+ bubbleState: message.bubbleState,
31369
+ _turnKey: message._turnKey,
31354
31370
  meta: message.meta,
31355
31371
  senderName: message.senderName
31356
31372
  };
@@ -31387,6 +31403,10 @@ var require_dist2 = __commonJS({
31387
31403
  senderName: message.senderName,
31388
31404
  id: message.id || `msg_${index}`,
31389
31405
  index: typeof message.index === "number" ? message.index : index,
31406
+ providerUnitKey: message.providerUnitKey,
31407
+ bubbleId: message.bubbleId,
31408
+ bubbleState: message.bubbleState,
31409
+ _turnKey: message._turnKey,
31390
31410
  receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
31391
31411
  });
31392
31412
  });
@@ -31398,7 +31418,7 @@ var require_dist2 = __commonJS({
31398
31418
  getScriptParsedStatus() {
31399
31419
  const screenText = this.readTerminalScreenText();
31400
31420
  const cached2 = this.parsedStatusCache;
31401
- 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) {
31421
+ 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) {
31402
31422
  return cached2.result;
31403
31423
  }
31404
31424
  const parsed = this.parseCurrentTranscript(
@@ -31517,12 +31537,10 @@ var require_dist2 = __commonJS({
31517
31537
  currentTurnScope: this.currentTurnScope,
31518
31538
  recentOutputBuffer: this.recentOutputBuffer,
31519
31539
  accumulatedBuffer: this.accumulatedBuffer,
31520
- accumulatedRawBuffer: this.accumulatedRawBuffer,
31521
31540
  screenText,
31522
31541
  currentStatus: this.currentStatus,
31523
31542
  activeModal: this.activeModal,
31524
31543
  cliName: this.cliName,
31525
- lastOutputAt: this.lastOutputAt,
31526
31544
  result
31527
31545
  };
31528
31546
  return result;
@@ -36342,6 +36360,15 @@ ${cleanBody}`;
36342
36360
  pendingEvents: this.flushEvents()
36343
36361
  };
36344
36362
  }
36363
+ getSessionModalState(sessionId) {
36364
+ if (sessionId && sessionId !== this.instanceId) return null;
36365
+ return {
36366
+ id: this.instanceId,
36367
+ status: this.currentStatus,
36368
+ title: this.chatTitle || this.agentName || this.provider.name,
36369
+ activeModal: this.activeModal
36370
+ };
36371
+ }
36345
36372
  onEvent(event, data) {
36346
36373
  if (event === "stream_update") {
36347
36374
  if (data?.streams) this.agentStreams = data.streams;
@@ -36802,6 +36829,23 @@ ${effect.notification.body || ""}`.trim();
36802
36829
  pendingEvents: this.flushEvents()
36803
36830
  };
36804
36831
  }
36832
+ getSessionModalState(sessionId) {
36833
+ if (sessionId && sessionId !== this.instanceId) {
36834
+ for (const ext of this.extensions.values()) {
36835
+ const projected = ext.getSessionModalState?.(sessionId);
36836
+ if (projected?.id === sessionId) return projected;
36837
+ }
36838
+ return null;
36839
+ }
36840
+ const autoApproveActive = (this.currentStatus === "waiting_approval" || this.cachedChat?.status === "waiting_approval") && this.canAutoApprove();
36841
+ const visibleStatus = autoApproveActive ? "generating" : this.currentStatus;
36842
+ return {
36843
+ id: this.instanceId,
36844
+ status: autoApproveActive && this.cachedChat?.status === "waiting_approval" ? "generating" : this.cachedChat?.status || visibleStatus,
36845
+ title: this.cachedChat?.title || this.type,
36846
+ activeModal: autoApproveActive ? null : this.cachedChat?.activeModal || null
36847
+ };
36848
+ }
36805
36849
  onEvent(event, data) {
36806
36850
  if (event === "cdp_connected") {
36807
36851
  } else if (event === "cdp_disconnected") {
@@ -41412,6 +41456,18 @@ ${effect.notification.body || ""}`.trim();
41412
41456
  runtimeRecoveryState: runtime?.recoveryState ?? null
41413
41457
  };
41414
41458
  }
41459
+ getSessionModalState() {
41460
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
41461
+ const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
41462
+ const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
41463
+ const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
41464
+ return {
41465
+ id: this.instanceId,
41466
+ status: visibleStatus,
41467
+ title: dirName,
41468
+ activeModal: autoApproveActive ? null : adapterStatus.activeModal
41469
+ };
41470
+ }
41415
41471
  updateSettings(newSettings) {
41416
41472
  this.settings = { ...newSettings };
41417
41473
  this.adapter.updateRuntimeSettings?.(this.settings);
@@ -42137,6 +42193,18 @@ ${effect.notification.body || ""}`.trim();
42137
42193
  this.detectStatusTransition();
42138
42194
  }
42139
42195
  }
42196
+ getSessionModalState() {
42197
+ const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
42198
+ return {
42199
+ id: this.instanceId,
42200
+ status: this.currentStatus,
42201
+ title: `${this.provider.name} \xB7 ${dirName}`,
42202
+ activeModal: this.currentStatus === "waiting_approval" ? {
42203
+ message: this.activeToolCalls.find((t) => t.status === "running")?.name || "Permission requested",
42204
+ buttons: ["Approve", "Reject"]
42205
+ } : null
42206
+ };
42207
+ }
42140
42208
  getState() {
42141
42209
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
42142
42210
  const recentMessages = normalizeChatMessages(this.messages.map((m) => {
@@ -48971,6 +49039,29 @@ Run 'adhdev doctor' for detailed diagnostics.`
48971
49039
  }
48972
49040
  return sessions;
48973
49041
  }
49042
+ getSessionModalState(sessionId, options = {}) {
49043
+ if (!sessionId) return null;
49044
+ const candidates = [sessionId];
49045
+ if (options.instanceKey && options.instanceKey !== sessionId) {
49046
+ candidates.push(options.instanceKey);
49047
+ }
49048
+ for (const id of candidates) {
49049
+ const instance = this.instances.get(id);
49050
+ if (!instance?.getSessionModalState) continue;
49051
+ try {
49052
+ const projected = instance.getSessionModalState(sessionId);
49053
+ if (!projected?.id) continue;
49054
+ if (projected.id !== sessionId) {
49055
+ LOG2.warn("InstanceMgr", `[InstanceManager] Ignoring mismatched session modal projection from ${id}: requested=${sessionId} projected=${projected.id}`);
49056
+ continue;
49057
+ }
49058
+ return projected;
49059
+ } catch (e) {
49060
+ LOG2.warn("InstanceMgr", `[InstanceManager] Failed to project session modal metadata from ${id}: ${e.message}`);
49061
+ }
49062
+ }
49063
+ return null;
49064
+ }
48974
49065
  /**
48975
49066
  * Per-category status collect
48976
49067
  */
@@ -55610,6 +55701,7 @@ var os3 = __toESM(require("os"), 1);
55610
55701
  var path22 = __toESM(require("path"), 1);
55611
55702
  var net = __toESM(require("net"), 1);
55612
55703
  var import_crypto = require("crypto");
55704
+ var DEFAULT_SESSION_RING_BUFFER_MAX_BYTES = 4 * 1024 * 1024;
55613
55705
  function getDefaultSessionHostEndpoint(appName = "adhdev") {
55614
55706
  if (process.platform === "win32") {
55615
55707
  return {
@@ -57219,25 +57311,20 @@ var StandaloneServer = class {
57219
57311
  }
57220
57312
  }
57221
57313
  }
57222
- findProviderStateBySessionId(sessionId) {
57314
+ findSessionModalStateBySessionId(sessionId) {
57223
57315
  if (!this.components || !sessionId) return null;
57224
- const states = this.components.instanceManager.collectAllStates();
57225
- for (const state of states) {
57226
- if (state.instanceId === sessionId) return state;
57227
- if (state.category === "ide") {
57228
- const child = state.extensions.find((entry) => entry.instanceId === sessionId);
57229
- if (child) return child;
57230
- }
57231
- }
57232
- return null;
57316
+ const target = this.components.sessionRegistry.get(sessionId);
57317
+ return this.components.instanceManager.getSessionModalState(sessionId, {
57318
+ instanceKey: target?.instanceKey
57319
+ });
57233
57320
  }
57234
57321
  buildSessionModalUpdate(state, key) {
57235
- const providerState = this.findProviderStateBySessionId(state.request.params.targetSessionId);
57236
- if (!providerState) return null;
57322
+ const modalState = this.findSessionModalStateBySessionId(state.request.params.targetSessionId);
57323
+ if (!modalState) return null;
57237
57324
  const now = Date.now();
57238
- const activeModal = providerState.activeChat?.activeModal;
57239
- const status = String(providerState.activeChat?.status || providerState.status || "idle");
57240
- const title = typeof providerState.activeChat?.title === "string" ? providerState.activeChat.title : void 0;
57325
+ const activeModal = modalState.activeModal;
57326
+ const status = String(modalState.status || "idle");
57327
+ const title = typeof modalState.title === "string" ? modalState.title : void 0;
57241
57328
  const prepared = (0, import_daemon_core2.prepareSessionModalUpdate)({
57242
57329
  key,
57243
57330
  sessionId: state.request.params.targetSessionId,