@adhdev/daemon-standalone 0.8.58 → 0.8.59

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
@@ -31131,6 +31131,66 @@ ${data.message || ""}`.trim();
31131
31131
  return { config: { ...config2, defaultWorkspaceId: id } };
31132
31132
  }
31133
31133
  var path22 = __toESM2(require("path"));
31134
+ function normalizeSummaryItem(item) {
31135
+ if (!item || typeof item !== "object") return null;
31136
+ const id = String(item.id || "").trim();
31137
+ const value = String(item.value || "").trim();
31138
+ if (!id || !value) return null;
31139
+ const normalized = {
31140
+ id,
31141
+ value
31142
+ };
31143
+ if (typeof item.label === "string" && item.label.trim()) normalized.label = item.label.trim();
31144
+ if (typeof item.shortValue === "string" && item.shortValue.trim()) normalized.shortValue = item.shortValue.trim();
31145
+ if (typeof item.icon === "string" && item.icon.trim()) normalized.icon = item.icon.trim();
31146
+ if (typeof item.order === "number" && Number.isFinite(item.order)) normalized.order = item.order;
31147
+ return normalized;
31148
+ }
31149
+ function normalizeProviderSummaryMetadata(summary) {
31150
+ if (!summary || !Array.isArray(summary.items)) return void 0;
31151
+ const items = summary.items.map((item) => normalizeSummaryItem(item)).filter((item) => !!item).sort((left, right) => {
31152
+ const orderDiff = (left.order ?? Number.MAX_SAFE_INTEGER) - (right.order ?? Number.MAX_SAFE_INTEGER);
31153
+ if (orderDiff !== 0) return orderDiff;
31154
+ return left.id.localeCompare(right.id);
31155
+ });
31156
+ return items.length > 0 ? { items } : void 0;
31157
+ }
31158
+ function buildProviderSummaryMetadata(items) {
31159
+ return normalizeProviderSummaryMetadata({ items: items.filter(Boolean) });
31160
+ }
31161
+ function buildLegacyModelModeSummaryMetadata(params) {
31162
+ return buildProviderSummaryMetadata([
31163
+ params.model ? {
31164
+ id: "model",
31165
+ label: "Model",
31166
+ value: String(params.modelLabel || params.model).trim(),
31167
+ shortValue: String(params.model).trim(),
31168
+ order: 10
31169
+ } : null,
31170
+ params.mode ? {
31171
+ id: "mode",
31172
+ label: "Mode",
31173
+ value: String(params.modeLabel || params.mode).trim(),
31174
+ shortValue: String(params.mode).trim(),
31175
+ order: 20
31176
+ } : null
31177
+ ]);
31178
+ }
31179
+ function resolveProviderStateSummaryMetadata(params) {
31180
+ const explicit = normalizeProviderSummaryMetadata(params.summaryMetadata);
31181
+ if (explicit) return explicit;
31182
+ const model = typeof params.controlValues?.model === "string" ? params.controlValues.model : void 0;
31183
+ const mode = typeof params.controlValues?.mode === "string" ? params.controlValues.mode : void 0;
31184
+ return buildLegacyModelModeSummaryMetadata({
31185
+ model,
31186
+ mode,
31187
+ modelLabel: params.modelLabel,
31188
+ modeLabel: params.modeLabel
31189
+ });
31190
+ }
31191
+ function normalizePersistedSummaryMetadata(params) {
31192
+ return normalizeProviderSummaryMetadata(params.summaryMetadata);
31193
+ }
31134
31194
  var MAX_ACTIVITY = 30;
31135
31195
  function normalizeWorkspace(workspace) {
31136
31196
  if (!workspace) return "";
@@ -31154,6 +31214,9 @@ ${data.message || ""}`.trim();
31154
31214
  const nextEntry = {
31155
31215
  ...entry,
31156
31216
  workspace: entry.workspace ? normalizeWorkspace(entry.workspace) : void 0,
31217
+ summaryMetadata: normalizePersistedSummaryMetadata({
31218
+ summaryMetadata: entry.summaryMetadata
31219
+ }),
31157
31220
  id: buildRecentActivityKeyForEntry(entry),
31158
31221
  lastUsedAt: entry.lastUsedAt || Date.now()
31159
31222
  };
@@ -31164,7 +31227,12 @@ ${data.message || ""}`.trim();
31164
31227
  };
31165
31228
  }
31166
31229
  function getRecentActivity(state, limit = 20) {
31167
- return [...state.recentActivity || []].sort((a, b2) => b2.lastUsedAt - a.lastUsedAt).slice(0, limit);
31230
+ return [...state.recentActivity || []].map((entry) => ({
31231
+ ...entry,
31232
+ summaryMetadata: normalizePersistedSummaryMetadata({
31233
+ summaryMetadata: entry.summaryMetadata
31234
+ })
31235
+ })).sort((a, b2) => b2.lastUsedAt - a.lastUsedAt).slice(0, limit);
31168
31236
  }
31169
31237
  function getSessionSeenAt(state, sessionId) {
31170
31238
  return state.sessionReads?.[sessionId] || 0;
@@ -31214,7 +31282,9 @@ ${data.message || ""}`.trim();
31214
31282
  providerName: entry.providerName,
31215
31283
  providerSessionId,
31216
31284
  workspace: entry.workspace ? normalizeWorkspace2(entry.workspace) : void 0,
31217
- currentModel: entry.currentModel,
31285
+ summaryMetadata: normalizePersistedSummaryMetadata({
31286
+ summaryMetadata: entry.summaryMetadata
31287
+ }),
31218
31288
  title: entry.title,
31219
31289
  createdAt: existing?.createdAt || entry.createdAt || Date.now(),
31220
31290
  lastUsedAt: entry.lastUsedAt || Date.now()
@@ -31230,7 +31300,12 @@ ${data.message || ""}`.trim();
31230
31300
  if (filters?.providerType && entry.providerType !== filters.providerType) return false;
31231
31301
  if (filters?.kind && entry.kind !== filters.kind) return false;
31232
31302
  return true;
31233
- }).sort((a, b2) => b2.lastUsedAt - a.lastUsedAt);
31303
+ }).map((entry) => ({
31304
+ ...entry,
31305
+ summaryMetadata: normalizePersistedSummaryMetadata({
31306
+ summaryMetadata: entry.summaryMetadata
31307
+ })
31308
+ })).sort((a, b2) => b2.lastUsedAt - a.lastUsedAt);
31234
31309
  }
31235
31310
  var import_fs2 = require("fs");
31236
31311
  var import_path22 = require("path");
@@ -32969,8 +33044,6 @@ ${data.message || ""}`.trim();
32969
33044
  if (rawValue === void 0 || rawValue === null) continue;
32970
33045
  values[ctrl.id] = normalizeControlValue(rawValue);
32971
33046
  }
32972
- if (data.model !== void 0 && values.model === void 0) values.model = normalizeControlValue(data.model);
32973
- if (data.mode !== void 0 && values.mode === void 0) values.mode = normalizeControlValue(data.mode);
32974
33047
  return Object.keys(values).length > 0 ? values : void 0;
32975
33048
  }
32976
33049
  function normalizeProviderEffects(data) {
@@ -33072,7 +33145,7 @@ ${data.message || ""}`.trim();
33072
33145
  }
33073
33146
  if (!option || typeof option !== "object") return null;
33074
33147
  const record2 = option;
33075
- const value = typeof record2.value === "string" ? record2.value : typeof record2.id === "string" ? record2.id : null;
33148
+ const value = typeof record2.value === "string" ? record2.value : typeof record2.id === "string" ? record2.id : typeof record2.name === "string" ? record2.name : null;
33076
33149
  if (!value) return null;
33077
33150
  const label = typeof record2.label === "string" ? record2.label : typeof record2.name === "string" ? record2.name : value;
33078
33151
  const normalized = { value, label };
@@ -33604,6 +33677,59 @@ ${data.message || ""}`.trim();
33604
33677
  return { sessions: [], hasMore: false };
33605
33678
  }
33606
33679
  }
33680
+ function isControlValue(value) {
33681
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
33682
+ }
33683
+ function asControlValueMap(value) {
33684
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
33685
+ const result = {};
33686
+ for (const [entryKey, entryValue] of Object.entries(value)) {
33687
+ if (isControlValue(entryValue)) result[entryKey] = entryValue;
33688
+ }
33689
+ return Object.keys(result).length > 0 ? result : void 0;
33690
+ }
33691
+ function getLegacyModelModeValues(data) {
33692
+ if (!data || typeof data !== "object") return void 0;
33693
+ const legacy = {};
33694
+ if (typeof data.model === "string" && data.model.trim()) legacy.model = data.model.trim();
33695
+ if (typeof data.mode === "string" && data.mode.trim()) legacy.mode = data.mode.trim();
33696
+ return Object.keys(legacy).length > 0 ? legacy : void 0;
33697
+ }
33698
+ function mergeProviderPatchState(params) {
33699
+ const {
33700
+ providerControls,
33701
+ data,
33702
+ currentControlValues,
33703
+ currentSummaryMetadata,
33704
+ mergeWithCurrent = true
33705
+ } = params;
33706
+ const sources = [
33707
+ mergeWithCurrent ? asControlValueMap(currentControlValues) : void 0,
33708
+ asControlValueMap(data?.controlValues),
33709
+ asControlValueMap(extractProviderControlValues(providerControls, data)),
33710
+ getLegacyModelModeValues(data)
33711
+ ];
33712
+ const controlValues = Object.assign({}, ...sources.filter(Boolean));
33713
+ return {
33714
+ controlValues,
33715
+ summaryMetadata: data?.summaryMetadata !== void 0 ? data.summaryMetadata : currentSummaryMetadata
33716
+ };
33717
+ }
33718
+ function normalizeProviderStateControlValues(controlValues) {
33719
+ return controlValues && Object.keys(controlValues).length > 0 ? controlValues : void 0;
33720
+ }
33721
+ function resolveProviderStateSurface(params) {
33722
+ const controlValues = normalizeProviderStateControlValues(params.controlValues);
33723
+ return {
33724
+ controlValues,
33725
+ summaryMetadata: resolveProviderStateSummaryMetadata({
33726
+ summaryMetadata: params.summaryMetadata,
33727
+ controlValues,
33728
+ modelLabel: params.modelLabel,
33729
+ modeLabel: params.modeLabel
33730
+ })
33731
+ };
33732
+ }
33607
33733
  var ExtensionProviderInstance = class {
33608
33734
  type;
33609
33735
  category = "extension";
@@ -33617,9 +33743,8 @@ ${data.message || ""}`.trim();
33617
33743
  messages = [];
33618
33744
  prevMessageHashes = /* @__PURE__ */ new Map();
33619
33745
  activeModal = null;
33620
- currentModel = "";
33621
- currentMode = "";
33622
33746
  controlValues = {};
33747
+ summaryMetadata = void 0;
33623
33748
  appliedEffectKeys = /* @__PURE__ */ new Set();
33624
33749
  runtimeMessages = [];
33625
33750
  lastAgentStatus = "idle";
@@ -33654,6 +33779,10 @@ ${data.message || ""}`.trim();
33654
33779
  if (!this.context?.cdp?.isConnected) return;
33655
33780
  }
33656
33781
  getState() {
33782
+ const surface = resolveProviderStateSurface({
33783
+ summaryMetadata: this.summaryMetadata,
33784
+ controlValues: this.controlValues
33785
+ });
33657
33786
  return {
33658
33787
  type: this.type,
33659
33788
  name: this.provider.name,
@@ -33667,10 +33796,9 @@ ${data.message || ""}`.trim();
33667
33796
  activeModal: this.activeModal,
33668
33797
  inputContent: ""
33669
33798
  } : null,
33670
- currentModel: this.currentModel || void 0,
33671
- currentPlan: this.currentMode || void 0,
33672
- controlValues: this.controlValues,
33799
+ controlValues: surface.controlValues,
33673
33800
  providerControls: this.provider.controls,
33801
+ summaryMetadata: surface.summaryMetadata,
33674
33802
  agentStreams: this.agentStreams,
33675
33803
  instanceId: this.instanceId,
33676
33804
  lastUpdated: Date.now(),
@@ -33683,10 +33811,14 @@ ${data.message || ""}`.trim();
33683
33811
  if (data?.streams) this.agentStreams = data.streams;
33684
33812
  if (data?.messages) this.messages = this.assignReceivedAt(data.messages);
33685
33813
  if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
33686
- if (data?.model) this.currentModel = data.model;
33687
- if (data?.mode) this.currentMode = data.mode;
33688
- const controlValues = extractProviderControlValues(this.provider.controls, data) || data?.controlValues;
33689
- if (controlValues) this.controlValues = controlValues;
33814
+ const patchedState = mergeProviderPatchState({
33815
+ providerControls: this.provider.controls,
33816
+ data,
33817
+ currentControlValues: this.controlValues,
33818
+ currentSummaryMetadata: this.summaryMetadata
33819
+ });
33820
+ this.controlValues = patchedState.controlValues;
33821
+ this.summaryMetadata = patchedState.summaryMetadata;
33690
33822
  if (typeof data?.sessionId === "string" && data.sessionId.trim()) this.chatId = data.sessionId;
33691
33823
  if (typeof data?.title === "string" && data.title.trim()) this.chatTitle = data.title;
33692
33824
  if (typeof data?.agentName === "string" && data.agentName.trim()) this.agentName = data.agentName;
@@ -33787,8 +33919,14 @@ ${data.message || ""}`.trim();
33787
33919
  }
33788
33920
  applyProviderResponse(data, options) {
33789
33921
  if (!data || typeof data !== "object") return;
33790
- const controlValues = extractProviderControlValues(this.provider.controls, data);
33791
- if (controlValues) this.controlValues = { ...this.controlValues, ...controlValues };
33922
+ const patchedState = mergeProviderPatchState({
33923
+ providerControls: this.provider.controls,
33924
+ data,
33925
+ currentControlValues: this.controlValues,
33926
+ currentSummaryMetadata: this.summaryMetadata
33927
+ });
33928
+ this.controlValues = patchedState.controlValues;
33929
+ this.summaryMetadata = patchedState.summaryMetadata;
33792
33930
  const effects = normalizeProviderEffects(data);
33793
33931
  for (const effect of effects) {
33794
33932
  const effectWhen = effect.when || "immediate";
@@ -33938,8 +34076,6 @@ ${effect.notification.body || ""}`.trim();
33938
34076
  this.messages = [];
33939
34077
  this.prevMessageHashes.clear();
33940
34078
  this.activeModal = null;
33941
- this.currentModel = "";
33942
- this.currentMode = "";
33943
34079
  this.controlValues = {};
33944
34080
  this.currentStatus = "idle";
33945
34081
  this.chatId = null;
@@ -34069,6 +34205,10 @@ ${effect.notification.body || ""}`.trim();
34069
34205
  for (const ext of this.extensions.values()) {
34070
34206
  extensionStates.push(ext.getState());
34071
34207
  }
34208
+ const surface = resolveProviderStateSurface({
34209
+ summaryMetadata: this.cachedChat?.summaryMetadata,
34210
+ controlValues: this.cachedChat?.controlValues
34211
+ });
34072
34212
  return {
34073
34213
  type: this.type,
34074
34214
  name: this.provider.name,
@@ -34085,11 +34225,9 @@ ${effect.notification.body || ""}`.trim();
34085
34225
  workspace: this.workspace || null,
34086
34226
  extensions: extensionStates,
34087
34227
  cdpConnected: cdp?.isConnected || false,
34088
- currentModel: this.cachedChat?.model || void 0,
34089
- currentPlan: this.cachedChat?.mode || void 0,
34090
- currentAutoApprove: this.cachedChat?.autoApprove || void 0,
34091
- controlValues: this.cachedChat?.controlValues || void 0,
34228
+ controlValues: surface.controlValues,
34092
34229
  providerControls: this.provider.controls,
34230
+ summaryMetadata: surface.summaryMetadata,
34093
34231
  instanceId: this.instanceId,
34094
34232
  lastUpdated: Date.now(),
34095
34233
  settings: this.settings,
@@ -34261,8 +34399,13 @@ ${effect.notification.body || ""}`.trim();
34261
34399
  chat.messages = messages.filter((m) => !hiddenKinds.has(m.kind || ""));
34262
34400
  }
34263
34401
  }
34264
- const controlValues = extractProviderControlValues(this.provider.controls, chat);
34265
- if (controlValues) chat.controlValues = controlValues;
34402
+ const patchedState = mergeProviderPatchState({
34403
+ providerControls: this.provider.controls,
34404
+ data: chat,
34405
+ mergeWithCurrent: false
34406
+ });
34407
+ chat.controlValues = Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0;
34408
+ chat.summaryMetadata = patchedState.summaryMetadata;
34266
34409
  this.cachedChat = { ...chat, activeModal };
34267
34410
  this.detectAgentTransitions(chat, now);
34268
34411
  const persistedMessages = chat.messages || messages;
@@ -34349,14 +34492,18 @@ ${effect.notification.body || ""}`.trim();
34349
34492
  }
34350
34493
  applyProviderResponse(data, options) {
34351
34494
  if (!data || typeof data !== "object") return;
34352
- const controlValues = extractProviderControlValues(this.provider.controls, data);
34353
- if (controlValues) {
34354
- this.cachedChat = {
34355
- ...this.cachedChat || {},
34356
- ...data,
34357
- controlValues: { ...this.cachedChat?.controlValues || {}, ...controlValues }
34358
- };
34359
- }
34495
+ const patchedState = mergeProviderPatchState({
34496
+ providerControls: this.provider.controls,
34497
+ data,
34498
+ currentControlValues: this.cachedChat?.controlValues,
34499
+ currentSummaryMetadata: this.cachedChat?.summaryMetadata
34500
+ });
34501
+ this.cachedChat = {
34502
+ ...this.cachedChat || {},
34503
+ ...data,
34504
+ controlValues: Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0,
34505
+ summaryMetadata: patchedState.summaryMetadata
34506
+ };
34360
34507
  const effects = normalizeProviderEffects(data);
34361
34508
  for (const effect of effects) {
34362
34509
  const effectWhen = effect.when || "immediate";
@@ -35129,6 +35276,8 @@ ${effect.notification.body || ""}`.trim();
35129
35276
  function buildIdeWorkspaceSession(state, cdpManagers, options) {
35130
35277
  const profile = options.profile || "full";
35131
35278
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
35279
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
35280
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
35132
35281
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
35133
35282
  const includeSessionControls = shouldIncludeSessionControls(profile);
35134
35283
  const title = activeChat?.title || state.name;
@@ -35145,13 +35294,11 @@ ${effect.notification.body || ""}`.trim();
35145
35294
  title,
35146
35295
  ...includeSessionMetadata && { workspace: state.workspace || null },
35147
35296
  activeChat,
35297
+ ...summaryMetadata && { summaryMetadata },
35148
35298
  ...includeSessionMetadata && { capabilities: IDE_SESSION_CAPABILITIES },
35149
35299
  cdpConnected: state.cdpConnected ?? isCdpConnected(cdpManagers, state.type),
35150
- currentModel: state.currentModel,
35151
- currentPlan: state.currentPlan,
35152
- currentAutoApprove: state.currentAutoApprove,
35153
35300
  ...includeSessionControls && {
35154
- controlValues: state.controlValues,
35301
+ ...controlValues && { controlValues },
35155
35302
  providerControls: state.providerControls
35156
35303
  },
35157
35304
  errorMessage: state.errorMessage,
@@ -35162,6 +35309,8 @@ ${effect.notification.body || ""}`.trim();
35162
35309
  function buildExtensionAgentSession(parent, ext, options) {
35163
35310
  const profile = options.profile || "full";
35164
35311
  const activeChat = normalizeActiveChatData(ext.activeChat, getActiveChatOptions(profile));
35312
+ const summaryMetadata = normalizeProviderSummaryMetadata(ext.summaryMetadata);
35313
+ const controlValues = normalizeProviderStateControlValues(ext.controlValues);
35165
35314
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
35166
35315
  const includeSessionControls = shouldIncludeSessionControls(profile);
35167
35316
  return {
@@ -35177,11 +35326,10 @@ ${effect.notification.body || ""}`.trim();
35177
35326
  title: activeChat?.title || ext.name,
35178
35327
  ...includeSessionMetadata && { workspace: parent.workspace || null },
35179
35328
  activeChat,
35329
+ ...summaryMetadata && { summaryMetadata },
35180
35330
  ...includeSessionMetadata && { capabilities: EXTENSION_SESSION_CAPABILITIES },
35181
- currentModel: ext.currentModel,
35182
- currentPlan: ext.currentPlan,
35183
35331
  ...includeSessionControls && {
35184
- controlValues: ext.controlValues,
35332
+ ...controlValues && { controlValues },
35185
35333
  providerControls: ext.providerControls
35186
35334
  },
35187
35335
  errorMessage: ext.errorMessage,
@@ -35192,6 +35340,8 @@ ${effect.notification.body || ""}`.trim();
35192
35340
  function buildCliSession(state, options) {
35193
35341
  const profile = options.profile || "full";
35194
35342
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
35343
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
35344
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
35195
35345
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
35196
35346
  const includeRuntimeMetadata = shouldIncludeRuntimeMetadata(profile);
35197
35347
  const includeSessionControls = shouldIncludeSessionControls(profile);
@@ -35218,11 +35368,12 @@ ${effect.notification.body || ""}`.trim();
35218
35368
  mode: state.mode,
35219
35369
  resume: state.resume,
35220
35370
  activeChat,
35371
+ ...summaryMetadata && { summaryMetadata },
35221
35372
  ...includeSessionMetadata && {
35222
35373
  capabilities: state.mode === "terminal" ? PTY_SESSION_CAPABILITIES : CLI_CHAT_SESSION_CAPABILITIES
35223
35374
  },
35224
35375
  ...includeSessionControls && {
35225
- controlValues: state.controlValues,
35376
+ ...controlValues && { controlValues },
35226
35377
  providerControls: state.providerControls
35227
35378
  },
35228
35379
  errorMessage: state.errorMessage,
@@ -35233,6 +35384,8 @@ ${effect.notification.body || ""}`.trim();
35233
35384
  function buildAcpSession(state, options) {
35234
35385
  const profile = options.profile || "full";
35235
35386
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
35387
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
35388
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
35236
35389
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
35237
35390
  const includeSessionControls = shouldIncludeSessionControls(profile);
35238
35391
  return {
@@ -35248,13 +35401,10 @@ ${effect.notification.body || ""}`.trim();
35248
35401
  title: activeChat?.title || state.name,
35249
35402
  ...includeSessionMetadata && { workspace: state.workspace || null },
35250
35403
  activeChat,
35404
+ ...summaryMetadata && { summaryMetadata },
35251
35405
  ...includeSessionMetadata && { capabilities: ACP_SESSION_CAPABILITIES },
35252
- currentModel: state.currentModel,
35253
- currentPlan: state.currentPlan,
35254
35406
  ...includeSessionControls && {
35255
- acpConfigOptions: state.acpConfigOptions,
35256
- acpModes: state.acpModes,
35257
- controlValues: state.controlValues,
35407
+ ...controlValues && { controlValues },
35258
35408
  providerControls: state.providerControls
35259
35409
  },
35260
35410
  errorMessage: state.errorMessage,
@@ -37288,8 +37438,17 @@ ${effect.notification.body || ""}`.trim();
37288
37438
  );
37289
37439
  return { success: true, reloaded: true, ...sourceConfig };
37290
37440
  }
37291
- function normalizeProviderScriptArgs(args) {
37441
+ function normalizeProviderScriptArgs(args, scriptName) {
37292
37442
  const normalizedArgs = { ...args || {} };
37443
+ const normalizedScriptName = String(scriptName || "").toLowerCase();
37444
+ if (Object.prototype.hasOwnProperty.call(normalizedArgs, "value")) {
37445
+ if (normalizedArgs.model === void 0 && (normalizedScriptName === "setmodel" || normalizedScriptName === "setmodelgui" || normalizedScriptName === "webviewsetmodel")) {
37446
+ normalizedArgs.model = normalizedArgs.value;
37447
+ }
37448
+ if (normalizedArgs.mode === void 0 && (normalizedScriptName === "setmode" || normalizedScriptName === "webviewsetmode")) {
37449
+ normalizedArgs.mode = normalizedArgs.value;
37450
+ }
37451
+ }
37293
37452
  for (const key of ["mode", "model", "message", "action", "button", "text", "sessionId", "value"]) {
37294
37453
  if (key in normalizedArgs && !(key.toUpperCase() in normalizedArgs)) {
37295
37454
  normalizedArgs[key.toUpperCase()] = normalizedArgs[key];
@@ -37335,7 +37494,7 @@ ${effect.notification.body || ""}`.trim();
37335
37494
  if (!provider.scripts?.[actualScriptName]) {
37336
37495
  return { success: false, error: `Script '${actualScriptName}' not available for ${resolvedProviderType}` };
37337
37496
  }
37338
- const normalizedArgs = normalizeProviderScriptArgs(args);
37497
+ const normalizedArgs = normalizeProviderScriptArgs(args, actualScriptName);
37339
37498
  if (provider.category === "cli") {
37340
37499
  const adapter = h.getCliAdapter(args?.targetSessionId || resolvedProviderType);
37341
37500
  if (!adapter?.invokeScript) {
@@ -38188,6 +38347,7 @@ ${effect.notification.body || ""}`.trim();
38188
38347
  generatingDebouncePending = null;
38189
38348
  lastApprovalEventAt = 0;
38190
38349
  controlValues = {};
38350
+ summaryMetadata = void 0;
38191
38351
  appliedEffectKeys = /* @__PURE__ */ new Set();
38192
38352
  historyWriter;
38193
38353
  runtimeMessages = [];
@@ -38330,13 +38490,7 @@ ${effect.notification.body || ""}`.trim();
38330
38490
  if (historyMessageCount !== null) {
38331
38491
  parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
38332
38492
  }
38333
- const controlValues = extractProviderControlValues(this.provider.controls, parsedStatus);
38334
- if (controlValues) {
38335
- this.controlValues = { ...this.controlValues, ...controlValues };
38336
- }
38337
38493
  const mergedMessages = this.mergeConversationMessages(parsedMessages);
38338
- const currentModel = typeof parsedStatus?.model === "string" && parsedStatus.model.trim() ? parsedStatus.model.trim() : typeof this.controlValues.model === "string" && this.controlValues.model.trim() ? this.controlValues.model.trim() : void 0;
38339
- const currentPlan = typeof parsedStatus?.mode === "string" && parsedStatus.mode.trim() ? parsedStatus.mode.trim() : typeof this.controlValues.mode === "string" && this.controlValues.mode.trim() ? this.controlValues.mode.trim() : void 0;
38340
38494
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
38341
38495
  if (parsedMessages.length > 0) {
38342
38496
  const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
@@ -38358,6 +38512,10 @@ ${effect.notification.body || ""}`.trim();
38358
38512
  }
38359
38513
  }
38360
38514
  this.applyProviderResponse(parsedStatus, { phase: "immediate" });
38515
+ const surface = resolveProviderStateSurface({
38516
+ summaryMetadata: this.summaryMetadata,
38517
+ controlValues: this.controlValues
38518
+ });
38361
38519
  return {
38362
38520
  type: this.type,
38363
38521
  name: this.provider.name,
@@ -38373,8 +38531,6 @@ ${effect.notification.body || ""}`.trim();
38373
38531
  inputContent: ""
38374
38532
  },
38375
38533
  workspace: this.workingDir,
38376
- currentModel,
38377
- currentPlan,
38378
38534
  instanceId: this.instanceId,
38379
38535
  providerSessionId: this.providerSessionId,
38380
38536
  lastUpdated: Date.now(),
@@ -38389,8 +38545,9 @@ ${effect.notification.body || ""}`.trim();
38389
38545
  attachedClients: runtime.attachedClients || []
38390
38546
  } : void 0,
38391
38547
  resume: this.provider.resume,
38392
- controlValues: this.controlValues,
38393
- providerControls: this.provider.controls
38548
+ controlValues: surface.controlValues,
38549
+ providerControls: this.provider.controls,
38550
+ summaryMetadata: surface.summaryMetadata
38394
38551
  };
38395
38552
  }
38396
38553
  setPresentationMode(mode) {
@@ -38594,10 +38751,14 @@ ${effect.notification.body || ""}`.trim();
38594
38751
  this.suppressIdleHistoryReplay = false;
38595
38752
  this.adapter.clearHistory();
38596
38753
  }
38597
- const controlValues = extractProviderControlValues(this.provider.controls, data);
38598
- if (controlValues) {
38599
- this.controlValues = { ...this.controlValues, ...controlValues };
38600
- }
38754
+ const patchedState = mergeProviderPatchState({
38755
+ providerControls: this.provider.controls,
38756
+ data,
38757
+ currentControlValues: this.controlValues,
38758
+ currentSummaryMetadata: this.summaryMetadata
38759
+ });
38760
+ this.controlValues = patchedState.controlValues;
38761
+ this.summaryMetadata = patchedState.summaryMetadata;
38601
38762
  const effects = normalizeProviderEffects(data);
38602
38763
  for (const effect of effects) {
38603
38764
  const effectWhen = effect.when || "immediate";
@@ -38961,8 +39122,7 @@ ${effect.notification.body || ""}`.trim();
38961
39122
  lastStatus = "starting";
38962
39123
  generatingStartedAt = 0;
38963
39124
  agentCapabilities = {};
38964
- currentModel;
38965
- currentMode;
39125
+ currentSelections = {};
38966
39126
  activeToolCalls = [];
38967
39127
  stopReason = null;
38968
39128
  partialContent = "";
@@ -39042,8 +39202,6 @@ ${effect.notification.body || ""}`.trim();
39042
39202
  inputContent: ""
39043
39203
  },
39044
39204
  workspace: this.workingDir,
39045
- currentModel: this.currentModel,
39046
- currentPlan: this.currentMode,
39047
39205
  instanceId: this.instanceId,
39048
39206
  lastUpdated: Date.now(),
39049
39207
  settings: this.settings,
@@ -39054,11 +39212,9 @@ ${effect.notification.body || ""}`.trim();
39054
39212
  // Error details for dashboard display
39055
39213
  errorMessage: this.errorMessage || void 0,
39056
39214
  errorReason: this.errorReason || void 0,
39057
- controlValues: {
39058
- ...this.currentModel ? { model: this.currentModel } : {},
39059
- ...this.currentMode ? { mode: this.currentMode } : {}
39060
- },
39061
- providerControls: this.provider.controls
39215
+ controlValues: this.getSelectionControlValues(),
39216
+ providerControls: this.provider.controls,
39217
+ summaryMetadata: this.buildSelectionSummaryMetadata()
39062
39218
  };
39063
39219
  }
39064
39220
  onEvent(event, data) {
@@ -39092,6 +39248,54 @@ ${effect.notification.body || ""}`.trim();
39092
39248
  getInstanceId() {
39093
39249
  return this.instanceId;
39094
39250
  }
39251
+ resolveConfigOptionLabel(category, value) {
39252
+ if (!value) return void 0;
39253
+ const option = this.configOptions.find((entry) => entry.category === category);
39254
+ return option?.options.find((candidate) => candidate.value === value)?.name || value;
39255
+ }
39256
+ resolveModeLabel(modeId) {
39257
+ if (!modeId) return void 0;
39258
+ return this.availableModes.find((mode) => mode.id === modeId)?.name || modeId;
39259
+ }
39260
+ getCurrentSelection(category) {
39261
+ return this.currentSelections[category];
39262
+ }
39263
+ setCurrentSelection(category, value) {
39264
+ const normalized = typeof value === "string" ? value.trim() : "";
39265
+ if (normalized) {
39266
+ this.currentSelections[category] = normalized;
39267
+ return;
39268
+ }
39269
+ delete this.currentSelections[category];
39270
+ }
39271
+ getSelectionControlValues() {
39272
+ const model = this.getCurrentSelection("model");
39273
+ const mode = this.getCurrentSelection("mode");
39274
+ return {
39275
+ ...model ? { model } : {},
39276
+ ...mode ? { mode } : {}
39277
+ };
39278
+ }
39279
+ resolveSelectionLabel(category, value) {
39280
+ if (!value) return void 0;
39281
+ const configLabel = this.resolveConfigOptionLabel(category, value);
39282
+ if (configLabel && configLabel !== value) return configLabel;
39283
+ if (category === "mode") {
39284
+ const modeLabel = this.resolveModeLabel(value);
39285
+ if (modeLabel) return modeLabel;
39286
+ }
39287
+ return configLabel || value;
39288
+ }
39289
+ buildSelectionSummaryMetadata() {
39290
+ const model = this.getCurrentSelection("model");
39291
+ const mode = this.getCurrentSelection("mode");
39292
+ return buildLegacyModelModeSummaryMetadata({
39293
+ model,
39294
+ mode,
39295
+ modelLabel: this.resolveSelectionLabel("model", model),
39296
+ modeLabel: this.resolveSelectionLabel("mode", mode)
39297
+ });
39298
+ }
39095
39299
  // ─── ACP Config Options & Modes ─────────────────────
39096
39300
  parseConfigOptions(raw) {
39097
39301
  if (!Array.isArray(raw)) return;
@@ -39123,12 +39327,14 @@ ${effect.notification.body || ""}`.trim();
39123
39327
  }
39124
39328
  }
39125
39329
  this.configOptions.push({ category, configId, currentValue, options: flatOptions });
39126
- if (category === "model" && currentValue) this.currentModel = currentValue;
39330
+ if (category === "model" || category === "mode") {
39331
+ this.setCurrentSelection(category, currentValue);
39332
+ }
39127
39333
  }
39128
39334
  }
39129
39335
  parseModes(raw) {
39130
39336
  if (!raw) return;
39131
- if (raw.currentModeId) this.currentMode = raw.currentModeId;
39337
+ this.setCurrentSelection("mode", raw.currentModeId);
39132
39338
  if (Array.isArray(raw.availableModes)) {
39133
39339
  this.availableModes = raw.availableModes.map((m) => ({
39134
39340
  id: m.id,
@@ -39147,8 +39353,7 @@ ${effect.notification.body || ""}`.trim();
39147
39353
  if (this.useStaticConfig) {
39148
39354
  opt.currentValue = value;
39149
39355
  this.selectedConfig[opt.configId] = value;
39150
- if (category === "model") this.currentModel = value;
39151
- if (category === "mode") this.currentMode = value;
39356
+ if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
39152
39357
  this.log.info(`[${this.type}] Static config ${category} set to: ${value} \u2014 restarting agent`);
39153
39358
  await this.restartWithNewConfig();
39154
39359
  return;
@@ -39166,7 +39371,7 @@ ${effect.notification.body || ""}`.trim();
39166
39371
  value
39167
39372
  });
39168
39373
  opt.currentValue = value;
39169
- if (category === "model") this.currentModel = value;
39374
+ if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
39170
39375
  if (result?.configOptions) this.parseConfigOptions(result.configOptions);
39171
39376
  this.log.info(`[${this.type}] Config ${category} set to: ${value} | response: ${JSON.stringify(result)?.slice(0, 300)}`);
39172
39377
  } catch (e) {
@@ -39182,7 +39387,7 @@ ${effect.notification.body || ""}`.trim();
39182
39387
  opt.currentValue = modeId;
39183
39388
  this.selectedConfig[opt.configId] = modeId;
39184
39389
  }
39185
- this.currentMode = modeId;
39390
+ this.setCurrentSelection("mode", modeId);
39186
39391
  this.log.info(`[${this.type}] Static mode set to: ${modeId} \u2014 restarting agent`);
39187
39392
  await this.restartWithNewConfig();
39188
39393
  return;
@@ -39197,7 +39402,7 @@ ${effect.notification.body || ""}`.trim();
39197
39402
  sessionId: this.sessionId,
39198
39403
  modeId
39199
39404
  });
39200
- this.currentMode = modeId;
39405
+ this.setCurrentSelection("mode", modeId);
39201
39406
  this.log.info(`[${this.type}] Mode set to: ${modeId}`);
39202
39407
  } catch (e) {
39203
39408
  const message = e?.message || "Unknown ACP mode error";
@@ -39455,8 +39660,8 @@ ${effect.notification.body || ""}`.trim();
39455
39660
  if (result?.modes) this.log.debug(`[${this.type}] modes: ${JSON.stringify(result.modes).slice(0, 300)}`);
39456
39661
  this.parseConfigOptions(result?.configOptions);
39457
39662
  this.parseModes(result?.modes);
39458
- if (!this.currentModel && result?.models?.currentModelId) {
39459
- this.currentModel = result.models.currentModelId;
39663
+ if (!this.getCurrentSelection("model") && result?.models?.currentModelId) {
39664
+ this.setCurrentSelection("model", result.models.currentModelId);
39460
39665
  }
39461
39666
  if (this.configOptions.length === 0 && this.provider.staticConfigOptions?.length) {
39462
39667
  this.useStaticConfig = true;
@@ -39470,13 +39675,16 @@ ${effect.notification.body || ""}`.trim();
39470
39675
  });
39471
39676
  if (defaultVal) {
39472
39677
  this.selectedConfig[sc2.configId] = defaultVal;
39473
- if (sc2.category === "model") this.currentModel = defaultVal;
39474
- if (sc2.category === "mode") this.currentMode = defaultVal;
39678
+ if (sc2.category === "model" || sc2.category === "mode") {
39679
+ this.setCurrentSelection(sc2.category, defaultVal);
39680
+ }
39475
39681
  }
39476
39682
  }
39477
39683
  this.log.info(`[${this.type}] Using static configOptions (${this.configOptions.length} options)`);
39478
39684
  }
39479
- this.log.info(`[${this.type}] Session created: ${this.sessionId}${this.currentModel ? ` (model: ${this.currentModel})` : ""}${this.currentMode ? ` (mode: ${this.currentMode})` : ""}`);
39685
+ const currentModel = this.getCurrentSelection("model");
39686
+ const currentMode = this.getCurrentSelection("mode");
39687
+ this.log.info(`[${this.type}] Session created: ${this.sessionId}${currentModel ? ` (model: ${currentModel})` : ""}${currentMode ? ` (mode: ${currentMode})` : ""}`);
39480
39688
  if (this.configOptions.length > 0) {
39481
39689
  this.log.info(`[${this.type}] Config options: ${this.configOptions.map((c) => `${c.category}(${c.options.length})`).join(", ")}`);
39482
39690
  }
@@ -39651,7 +39859,7 @@ ${effect.notification.body || ""}`.trim();
39651
39859
  break;
39652
39860
  }
39653
39861
  case "current_mode_update": {
39654
- this.currentMode = update.currentModeId;
39862
+ this.setCurrentSelection("mode", update.currentModeId);
39655
39863
  break;
39656
39864
  }
39657
39865
  case "config_option_update": {
@@ -39724,7 +39932,7 @@ ${effect.notification.body || ""}`.trim();
39724
39932
  this.detectStatusTransition();
39725
39933
  }
39726
39934
  if (params.model) {
39727
- this.currentModel = params.model;
39935
+ this.setCurrentSelection("model", params.model);
39728
39936
  }
39729
39937
  }
39730
39938
  /** Map SDK ToolCallStatus to internal status */
@@ -40007,7 +40215,11 @@ ${effect.notification.body || ""}`.trim();
40007
40215
  }
40008
40216
  persistRecentActivity(entry) {
40009
40217
  try {
40010
- let nextState = appendRecentActivity(loadState(), entry);
40218
+ const summaryMetadata = normalizeProviderSummaryMetadata(entry.summaryMetadata);
40219
+ let nextState = appendRecentActivity(loadState(), {
40220
+ ...entry,
40221
+ summaryMetadata
40222
+ });
40011
40223
  if (entry.providerSessionId && (entry.kind === "cli" || entry.kind === "acp")) {
40012
40224
  nextState = upsertSavedProviderSession(nextState, {
40013
40225
  kind: entry.kind,
@@ -40015,7 +40227,7 @@ ${effect.notification.body || ""}`.trim();
40015
40227
  providerName: entry.providerName,
40016
40228
  providerSessionId: entry.providerSessionId,
40017
40229
  workspace: entry.workspace,
40018
- currentModel: entry.currentModel,
40230
+ summaryMetadata,
40019
40231
  title: entry.title
40020
40232
  });
40021
40233
  }
@@ -40205,7 +40417,7 @@ ${installInfo}`
40205
40417
  providerType: normalizedType,
40206
40418
  providerName: provider.displayName || provider.name || normalizedType,
40207
40419
  workspace: resolvedDir,
40208
- currentModel: initialModel,
40420
+ summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
40209
40421
  sessionId,
40210
40422
  title: provider.displayName || provider.name || normalizedType
40211
40423
  });
@@ -40307,7 +40519,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
40307
40519
  providerName: provider?.displayName || provider?.name || normalizedType,
40308
40520
  providerSessionId: sessionBinding.providerSessionId,
40309
40521
  workspace: resolvedDir,
40310
- currentModel: initialModel,
40522
+ summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
40311
40523
  sessionId: key,
40312
40524
  title: provider?.displayName || provider?.name || normalizedType
40313
40525
  });
@@ -42455,11 +42667,87 @@ Run 'adhdev doctor' for detailed diagnostics.`
42455
42667
  }
42456
42668
  cleanOldFiles();
42457
42669
  init_logger();
42670
+ var LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
42671
+ function isSessionHostLiveRuntime(record2) {
42672
+ const lifecycle = String(record2?.lifecycle || "").trim();
42673
+ return LIVE_LIFECYCLES.has(lifecycle);
42674
+ }
42675
+ function getSessionHostRecoveryLabel(meta3) {
42676
+ const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
42677
+ if (!recoveryState) return null;
42678
+ if (recoveryState === "auto_resumed") return "restored after restart";
42679
+ if (recoveryState === "resume_failed") return "restore failed";
42680
+ if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
42681
+ if (recoveryState === "orphan_snapshot") return "snapshot recovered";
42682
+ return recoveryState.replace(/_/g, " ");
42683
+ }
42684
+ function isSessionHostRecoverySnapshot(record2) {
42685
+ if (!record2) return false;
42686
+ if (isSessionHostLiveRuntime(record2)) return false;
42687
+ const lifecycle = String(record2.lifecycle || "").trim();
42688
+ if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
42689
+ return false;
42690
+ }
42691
+ const meta3 = record2.meta || void 0;
42692
+ if (meta3?.restoredFromStorage === true) return true;
42693
+ return getSessionHostRecoveryLabel(meta3) !== null;
42694
+ }
42695
+ function getSessionHostSurfaceKind(record2) {
42696
+ if (isSessionHostLiveRuntime(record2)) return "live_runtime";
42697
+ if (isSessionHostRecoverySnapshot(record2)) return "recovery_snapshot";
42698
+ return "inactive_record";
42699
+ }
42700
+ function partitionSessionHostRecords(records) {
42701
+ const liveRuntimes = [];
42702
+ const recoverySnapshots = [];
42703
+ const inactiveRecords = [];
42704
+ for (const record2 of records) {
42705
+ const kind = getSessionHostSurfaceKind(record2);
42706
+ if (kind === "live_runtime") {
42707
+ liveRuntimes.push(record2);
42708
+ } else if (kind === "recovery_snapshot") {
42709
+ recoverySnapshots.push(record2);
42710
+ } else {
42711
+ inactiveRecords.push(record2);
42712
+ }
42713
+ }
42714
+ return {
42715
+ liveRuntimes,
42716
+ recoverySnapshots,
42717
+ inactiveRecords
42718
+ };
42719
+ }
42720
+ function partitionSessionHostDiagnosticsSessions(records) {
42721
+ return partitionSessionHostRecords(records || []);
42722
+ }
42458
42723
  var os16 = __toESM2(require("os"));
42459
42724
  init_config();
42460
42725
  init_terminal_screen();
42461
42726
  init_logger();
42462
42727
  var READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
42728
+ var recentReadDebugSignatureBySession = /* @__PURE__ */ new Map();
42729
+ function buildRecentReadDebugSignature(snapshot) {
42730
+ return [
42731
+ snapshot.providerType,
42732
+ snapshot.status,
42733
+ snapshot.inboxBucket,
42734
+ snapshot.unread ? "1" : "0",
42735
+ String(snapshot.lastSeenAt),
42736
+ snapshot.completionMarker,
42737
+ snapshot.seenCompletionMarker,
42738
+ String(snapshot.lastUpdated),
42739
+ String(snapshot.lastUsedAt),
42740
+ snapshot.lastRole,
42741
+ String(snapshot.messageUpdatedAt)
42742
+ ].join("|");
42743
+ }
42744
+ function shouldEmitRecentReadDebugLog(cache, snapshot) {
42745
+ const nextSignature = buildRecentReadDebugSignature(snapshot);
42746
+ const previousSignature = cache.get(snapshot.sessionId);
42747
+ if (previousSignature === nextSignature) return false;
42748
+ cache.set(snapshot.sessionId, nextSignature);
42749
+ return true;
42750
+ }
42463
42751
  function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
42464
42752
  return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
42465
42753
  id: ide.id,
@@ -42611,7 +42899,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
42611
42899
  providerSessionId: item.providerSessionId,
42612
42900
  title: item.title || item.providerName,
42613
42901
  workspace: item.workspace,
42614
- currentModel: item.currentModel,
42902
+ summaryMetadata: item.summaryMetadata,
42615
42903
  lastLaunchedAt: item.lastUsedAt
42616
42904
  })).sort((a, b2) => b2.lastLaunchedAt - a.lastLaunchedAt).slice(0, 12);
42617
42905
  }
@@ -42652,9 +42940,24 @@ Run 'adhdev doctor' for detailed diagnostics.`
42652
42940
  session.unread = unread;
42653
42941
  session.inboxBucket = inboxBucket;
42654
42942
  if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
42943
+ const recentReadSnapshot = {
42944
+ sessionId: session.id,
42945
+ providerType: session.providerType,
42946
+ status: String(session.status || ""),
42947
+ inboxBucket,
42948
+ unread,
42949
+ lastSeenAt,
42950
+ completionMarker: completionMarker || "-",
42951
+ seenCompletionMarker: seenCompletionMarker || "-",
42952
+ lastUpdated: Number(session.lastUpdated || 0),
42953
+ lastUsedAt,
42954
+ lastRole: getLastMessageRole(sourceSession),
42955
+ messageUpdatedAt: getSessionMessageUpdatedAt(sourceSession)
42956
+ };
42957
+ if (!shouldEmitRecentReadDebugLog(recentReadDebugSignatureBySession, recentReadSnapshot)) continue;
42655
42958
  LOG2.info(
42656
42959
  "RecentRead",
42657
- `snapshot session id=${session.id} provider=${session.providerType} status=${String(session.status || "")} bucket=${inboxBucket} unread=${String(unread)} lastSeenAt=${lastSeenAt} completionMarker=${completionMarker || "-"} seenMarker=${seenCompletionMarker || "-"} lastUpdated=${String(session.lastUpdated || 0)} lastUsedAt=${lastUsedAt} lastRole=${getLastMessageRole(sourceSession)} msgUpdatedAt=${getSessionMessageUpdatedAt(sourceSession)}`
42960
+ `snapshot session id=${recentReadSnapshot.sessionId} provider=${recentReadSnapshot.providerType} status=${recentReadSnapshot.status} bucket=${recentReadSnapshot.inboxBucket} unread=${String(recentReadSnapshot.unread)} lastSeenAt=${recentReadSnapshot.lastSeenAt} completionMarker=${recentReadSnapshot.completionMarker} seenMarker=${recentReadSnapshot.seenCompletionMarker} lastUpdated=${String(recentReadSnapshot.lastUpdated)} lastUsedAt=${recentReadSnapshot.lastUsedAt} lastRole=${recentReadSnapshot.lastRole} msgUpdatedAt=${recentReadSnapshot.messageUpdatedAt}`
42658
42961
  );
42659
42962
  }
42660
42963
  const lastDisplayMessage = getLastDisplayMessage(sourceSession);
@@ -42925,11 +43228,104 @@ Run 'adhdev doctor' for detailed diagnostics.`
42925
43228
  providerSessionId: typeof record2.meta?.providerSessionId === "string" ? String(record2.meta.providerSessionId) : void 0
42926
43229
  };
42927
43230
  }
43231
+ function getWriteConflictOwnerClientId(error48) {
43232
+ const message = typeof error48 === "string" ? error48 : error48 instanceof Error ? error48.message : "";
43233
+ const match = /^Write owned by\s+(.+)$/.exec(message.trim());
43234
+ return match?.[1]?.trim() || void 0;
43235
+ }
43236
+ function summarizeSessionHostRecord(result) {
43237
+ if (!result || typeof result !== "object") return {};
43238
+ const record2 = result;
43239
+ return {
43240
+ runtimeKey: typeof record2.runtimeKey === "string" ? record2.runtimeKey : void 0,
43241
+ lifecycle: typeof record2.lifecycle === "string" ? record2.lifecycle : void 0,
43242
+ surfaceKind: getSessionHostSurfaceKind(record2),
43243
+ attachedClientCount: Array.isArray(record2.attachedClients) ? record2.attachedClients.length : void 0,
43244
+ hasWriteOwner: !!record2.writeOwner,
43245
+ writeOwnerClientId: typeof record2.writeOwner?.clientId === "string" ? record2.writeOwner.clientId : void 0
43246
+ };
43247
+ }
43248
+ function summarizeSessionHostRecords(result) {
43249
+ const records = Array.isArray(result) ? result : [];
43250
+ const groups = partitionSessionHostRecords(records);
43251
+ return {
43252
+ sessionCount: records.length,
43253
+ liveRuntimeCount: groups.liveRuntimes.length,
43254
+ recoverySnapshotCount: groups.recoverySnapshots.length,
43255
+ inactiveRecordCount: groups.inactiveRecords.length
43256
+ };
43257
+ }
43258
+ function summarizeSessionHostDiagnostics(result) {
43259
+ const diagnostics = result && typeof result === "object" ? result : {};
43260
+ const sessions = Array.isArray(diagnostics.sessions) ? diagnostics.sessions : [];
43261
+ return {
43262
+ runtimeCount: typeof diagnostics.runtimeCount === "number" ? diagnostics.runtimeCount : void 0,
43263
+ ...summarizeSessionHostRecords(sessions)
43264
+ };
43265
+ }
43266
+ function summarizeSessionHostPruneResult(result) {
43267
+ const value = result && typeof result === "object" ? result : {};
43268
+ return {
43269
+ duplicateGroupCount: typeof value.duplicateGroupCount === "number" ? value.duplicateGroupCount : void 0,
43270
+ prunedCount: Array.isArray(value.prunedSessionIds) ? value.prunedSessionIds.length : void 0,
43271
+ keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
43272
+ };
43273
+ }
42928
43274
  var DaemonCommandRouter = class {
42929
43275
  deps;
42930
43276
  constructor(deps) {
42931
43277
  this.deps = deps;
42932
43278
  }
43279
+ async traceSessionHostAction(action, args, run, summarizeResult) {
43280
+ const interactionId = typeof args?._interactionId === "string" ? args._interactionId : void 0;
43281
+ const sessionId = typeof args?.sessionId === "string" ? args.sessionId : void 0;
43282
+ const requestedPayload = { action };
43283
+ if (sessionId) requestedPayload.sessionId = sessionId;
43284
+ if (typeof args?.clientId === "string") requestedPayload.clientId = args.clientId;
43285
+ if (typeof args?.signal === "string") requestedPayload.signal = args.signal;
43286
+ if (typeof args?.providerType === "string") requestedPayload.providerType = args.providerType;
43287
+ if (typeof args?.workspace === "string") requestedPayload.workspace = args.workspace;
43288
+ if (typeof args?.dryRun === "boolean") requestedPayload.dryRun = args.dryRun;
43289
+ recordDebugTrace({
43290
+ interactionId,
43291
+ category: "session_host",
43292
+ stage: "action_requested",
43293
+ level: "info",
43294
+ sessionId,
43295
+ payload: requestedPayload
43296
+ });
43297
+ try {
43298
+ const result = await run();
43299
+ recordDebugTrace({
43300
+ interactionId,
43301
+ category: "session_host",
43302
+ stage: "action_result",
43303
+ level: "info",
43304
+ sessionId,
43305
+ payload: {
43306
+ ...requestedPayload,
43307
+ success: true,
43308
+ ...summarizeResult ? summarizeResult(result) : {}
43309
+ }
43310
+ });
43311
+ return result;
43312
+ } catch (error48) {
43313
+ recordDebugTrace({
43314
+ interactionId,
43315
+ category: "session_host",
43316
+ stage: "action_failed",
43317
+ level: "error",
43318
+ sessionId,
43319
+ payload: {
43320
+ ...requestedPayload,
43321
+ error: error48?.message || String(error48),
43322
+ failureKind: getWriteConflictOwnerClientId(error48) ? "write_conflict" : "request_failed",
43323
+ conflictOwnerClientId: getWriteConflictOwnerClientId(error48)
43324
+ }
43325
+ });
43326
+ throw error48;
43327
+ }
43328
+ }
42933
43329
  /**
42934
43330
  * Unified command routing.
42935
43331
  * Returns result for all commands:
@@ -43039,44 +43435,60 @@ Run 'adhdev doctor' for detailed diagnostics.`
43039
43435
  }
43040
43436
  case "session_host_get_diagnostics": {
43041
43437
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
43042
- const diagnostics = await this.deps.sessionHostControl.getDiagnostics({
43438
+ const diagnostics = await this.traceSessionHostAction("session_host_get_diagnostics", args, () => this.deps.sessionHostControl.getDiagnostics({
43043
43439
  includeSessions: args?.includeSessions !== false,
43044
43440
  limit: Number(args?.limit) || void 0
43045
- });
43441
+ }), (result) => ({
43442
+ includeSessions: args?.includeSessions !== false,
43443
+ limit: Number(args?.limit) || void 0,
43444
+ ...summarizeSessionHostDiagnostics(result)
43445
+ }));
43046
43446
  return { success: true, diagnostics };
43047
43447
  }
43048
43448
  case "session_host_list_sessions": {
43049
43449
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
43050
- const sessions = await this.deps.sessionHostControl.listSessions();
43450
+ const sessions = await this.traceSessionHostAction("session_host_list_sessions", args, () => this.deps.sessionHostControl.listSessions(), (records) => summarizeSessionHostRecords(records));
43051
43451
  return { success: true, sessions };
43052
43452
  }
43053
43453
  case "session_host_stop_session": {
43054
43454
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
43055
43455
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
43056
43456
  if (!sessionId) return { success: false, error: "sessionId required" };
43057
- const record2 = await this.deps.sessionHostControl.stopSession(sessionId);
43457
+ const record2 = await this.traceSessionHostAction("session_host_stop_session", args, () => this.deps.sessionHostControl.stopSession(sessionId), (result) => summarizeSessionHostRecord(result));
43058
43458
  return { success: true, record: record2 };
43059
43459
  }
43060
43460
  case "session_host_resume_session": {
43061
43461
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
43062
43462
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
43063
43463
  if (!sessionId) return { success: false, error: "sessionId required" };
43064
- const record2 = await this.deps.sessionHostControl.resumeSession(sessionId);
43065
- const hosted = toHostedCliRuntimeDescriptor(record2);
43066
- if (hosted) {
43067
- await this.deps.cliManager.restoreHostedSessions([hosted]);
43068
- }
43464
+ const record2 = await this.traceSessionHostAction("session_host_resume_session", args, async () => {
43465
+ const nextRecord = await this.deps.sessionHostControl.resumeSession(sessionId);
43466
+ const hosted = toHostedCliRuntimeDescriptor(nextRecord);
43467
+ if (hosted) {
43468
+ await this.deps.cliManager.restoreHostedSessions([hosted]);
43469
+ }
43470
+ return nextRecord;
43471
+ }, (result) => ({
43472
+ ...summarizeSessionHostRecord(result),
43473
+ restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
43474
+ }));
43069
43475
  return { success: true, record: record2 };
43070
43476
  }
43071
43477
  case "session_host_restart_session": {
43072
43478
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
43073
43479
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
43074
43480
  if (!sessionId) return { success: false, error: "sessionId required" };
43075
- const record2 = await this.deps.sessionHostControl.restartSession(sessionId);
43076
- const hosted = toHostedCliRuntimeDescriptor(record2);
43077
- if (hosted) {
43078
- await this.deps.cliManager.restoreHostedSessions([hosted]);
43079
- }
43481
+ const record2 = await this.traceSessionHostAction("session_host_restart_session", args, async () => {
43482
+ const nextRecord = await this.deps.sessionHostControl.restartSession(sessionId);
43483
+ const hosted = toHostedCliRuntimeDescriptor(nextRecord);
43484
+ if (hosted) {
43485
+ await this.deps.cliManager.restoreHostedSessions([hosted]);
43486
+ }
43487
+ return nextRecord;
43488
+ }, (result) => ({
43489
+ ...summarizeSessionHostRecord(result),
43490
+ restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
43491
+ }));
43080
43492
  return { success: true, record: record2 };
43081
43493
  }
43082
43494
  case "session_host_send_signal": {
@@ -43085,7 +43497,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
43085
43497
  const signal = typeof args?.signal === "string" ? args.signal : "";
43086
43498
  if (!sessionId) return { success: false, error: "sessionId required" };
43087
43499
  if (!signal) return { success: false, error: "signal required" };
43088
- const record2 = await this.deps.sessionHostControl.sendSignal(sessionId, signal);
43500
+ const record2 = await this.traceSessionHostAction("session_host_send_signal", args, () => this.deps.sessionHostControl.sendSignal(sessionId, signal), (result) => summarizeSessionHostRecord(result));
43089
43501
  return { success: true, record: record2 };
43090
43502
  }
43091
43503
  case "session_host_force_detach_client": {
@@ -43094,16 +43506,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
43094
43506
  const clientId = typeof args?.clientId === "string" ? args.clientId : "";
43095
43507
  if (!sessionId) return { success: false, error: "sessionId required" };
43096
43508
  if (!clientId) return { success: false, error: "clientId required" };
43097
- const record2 = await this.deps.sessionHostControl.forceDetachClient(sessionId, clientId);
43509
+ const record2 = await this.traceSessionHostAction("session_host_force_detach_client", args, () => this.deps.sessionHostControl.forceDetachClient(sessionId, clientId), (result) => summarizeSessionHostRecord(result));
43098
43510
  return { success: true, record: record2 };
43099
43511
  }
43100
43512
  case "session_host_prune_duplicate_sessions": {
43101
43513
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
43102
- const result = await this.deps.sessionHostControl.pruneDuplicateSessions({
43514
+ const result = await this.traceSessionHostAction("session_host_prune_duplicate_sessions", args, () => this.deps.sessionHostControl.pruneDuplicateSessions({
43103
43515
  providerType: typeof args?.providerType === "string" ? args.providerType : void 0,
43104
43516
  workspace: typeof args?.workspace === "string" ? args.workspace : void 0,
43105
43517
  dryRun: args?.dryRun === true
43106
- });
43518
+ }), (value) => summarizeSessionHostPruneResult(value));
43107
43519
  return { success: true, result };
43108
43520
  }
43109
43521
  case "session_host_acquire_write": {
@@ -43113,12 +43525,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
43113
43525
  const ownerType = args?.ownerType === "agent" ? "agent" : "user";
43114
43526
  if (!sessionId) return { success: false, error: "sessionId required" };
43115
43527
  if (!clientId) return { success: false, error: "clientId required" };
43116
- const record2 = await this.deps.sessionHostControl.acquireWrite({
43528
+ const record2 = await this.traceSessionHostAction("session_host_acquire_write", args, () => this.deps.sessionHostControl.acquireWrite({
43117
43529
  sessionId,
43118
43530
  clientId,
43119
43531
  ownerType,
43120
43532
  force: args?.force !== false
43121
- });
43533
+ }), (result) => ({
43534
+ ...summarizeSessionHostRecord(result),
43535
+ ownerType
43536
+ }));
43122
43537
  return { success: true, record: record2 };
43123
43538
  }
43124
43539
  case "session_host_release_write": {
@@ -43127,7 +43542,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
43127
43542
  const clientId = typeof args?.clientId === "string" ? args.clientId : "";
43128
43543
  if (!sessionId) return { success: false, error: "sessionId required" };
43129
43544
  if (!clientId) return { success: false, error: "clientId required" };
43130
- const record2 = await this.deps.sessionHostControl.releaseWrite({ sessionId, clientId });
43545
+ const record2 = await this.traceSessionHostAction("session_host_release_write", args, () => this.deps.sessionHostControl.releaseWrite({
43546
+ sessionId,
43547
+ clientId
43548
+ }), (result) => summarizeSessionHostRecord(result));
43131
43549
  return { success: true, record: record2 };
43132
43550
  }
43133
43551
  case "list_saved_sessions": {
@@ -43160,7 +43578,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
43160
43578
  kind: saved?.kind || recent?.kind || kind,
43161
43579
  title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
43162
43580
  workspace: saved?.workspace || recent?.workspace || session.workspace,
43163
- currentModel: saved?.currentModel || recent?.currentModel,
43581
+ summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
43164
43582
  preview: session.preview,
43165
43583
  messageCount: session.messageCount,
43166
43584
  firstMessageAt: session.firstMessageAt,
@@ -43597,7 +44015,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
43597
44015
  const ideSummary = ideStates.map((s15) => {
43598
44016
  const msgs = s15.activeChat?.messages?.length || 0;
43599
44017
  const exts = s15.extensions.length;
43600
- return `${s15.type}(${s15.status},${msgs}msg,${exts}ext${s15.currentModel ? ",model=" + s15.currentModel : ""})`;
44018
+ return `${s15.type}(${s15.status},${msgs}msg,${exts}ext)`;
43601
44019
  }).join(", ");
43602
44020
  const cliSummary = cliStates.map((s15) => `${s15.type}(${s15.status})`).join(", ");
43603
44021
  const acpSummary = acpStates.map((s15) => `${s15.type}(${s15.status})`).join(", ");
@@ -43659,9 +44077,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
43659
44077
  workspace: session.workspace ?? null,
43660
44078
  title: session.title,
43661
44079
  cdpConnected: session.cdpConnected,
43662
- currentModel: session.currentModel,
43663
- currentPlan: session.currentPlan,
43664
- currentAutoApprove: session.currentAutoApprove
44080
+ summaryMetadata: session.summaryMetadata
43665
44081
  })),
43666
44082
  p2p: payload.p2p,
43667
44083
  timestamp: now
@@ -43821,15 +44237,18 @@ Run 'adhdev doctor' for detailed diagnostics.`
43821
44237
  status: data.status || "idle",
43822
44238
  messages: data.messages || [],
43823
44239
  inputContent: data.inputContent || "",
43824
- model: data.model,
43825
- mode: data.mode,
43826
44240
  activeModal: data.activeModal
43827
44241
  };
43828
44242
  if (typeof data.title === "string" && data.title.trim()) {
43829
44243
  state.title = data.title.trim();
43830
44244
  }
43831
44245
  const controlValues = extractProviderControlValues(this.provider.controls, data);
43832
- if (controlValues) state.controlValues = controlValues;
44246
+ const surface = resolveProviderStateSurface({
44247
+ controlValues,
44248
+ summaryMetadata: data.summaryMetadata
44249
+ });
44250
+ if (surface.controlValues) state.controlValues = surface.controlValues;
44251
+ if (surface.summaryMetadata) state.summaryMetadata = surface.summaryMetadata;
43833
44252
  const effects = normalizeProviderEffects(data);
43834
44253
  if (effects.length > 0) state.effects = effects;
43835
44254
  if (state.messages.length > 0) {
@@ -44101,7 +44520,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
44101
44520
  const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.cdpSessionId, expr, timeout);
44102
44521
  const state = await agent.adapter.readChat(evaluate);
44103
44522
  const stateError = this.getStateError(state);
44104
- LOG2.debug("AgentStream", `[AgentStream] readChat(${type}) result: status=${state.status} msgs=${state.messages?.length || 0} model=${state.model || ""}${state.status === "error" ? " error=" + JSON.stringify(stateError) : ""}`);
44523
+ const selectedModelValue = typeof state.controlValues?.model === "string" ? state.controlValues.model : "";
44524
+ LOG2.debug("AgentStream", `[AgentStream] readChat(${type}) result: status=${state.status} msgs=${state.messages?.length || 0} model=${selectedModelValue}${state.status === "error" ? " error=" + JSON.stringify(stateError) : ""}`);
44105
44525
  if (state.status === "error" && this.isRecoverableSessionError(stateError)) {
44106
44526
  throw new Error(stateError);
44107
44527
  }
@@ -44445,9 +44865,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
44445
44865
  messages: stream.messages || [],
44446
44866
  status: stream.status || "idle",
44447
44867
  activeModal: stream.activeModal || null,
44448
- model: stream.model || void 0,
44449
- mode: stream.mode || void 0,
44450
44868
  controlValues: stream.controlValues || void 0,
44869
+ summaryMetadata: stream.summaryMetadata || void 0,
44451
44870
  effects: stream.effects || void 0,
44452
44871
  sessionId: stream.sessionId || stream.instanceId || void 0,
44453
44872
  title: stream.title || stream.agentName || void 0,
@@ -44975,7 +45394,11 @@ module.exports.setMode = (params) => {
44975
45394
  * 5. Approval dialog detection (buttons, modal)
44976
45395
  * 6. Input field selector
44977
45396
  *
44978
- * \u2192 { id, status, title, messages[], inputContent, activeModal }
45397
+ * Preferred live-state surface:
45398
+ * - controlValues: explicit current control selections (model/mode/etc.)
45399
+ * - summaryMetadata: compact always-visible metadata for dashboard/recent views
45400
+ * Legacy top-level model/mode output is no longer the preferred shape.
45401
+ * \u2192 { id, status, title, messages[], inputContent, activeModal, controlValues?, summaryMetadata? }
44979
45402
  */
44980
45403
  (() => {
44981
45404
  try {
@@ -45003,6 +45426,9 @@ module.exports.setMode = (params) => {
45003
45426
  messages,
45004
45427
  inputContent,
45005
45428
  activeModal,
45429
+ // TODO: Return explicit selections when available, e.g.
45430
+ // controlValues: { model: selectedModel, mode: selectedMode },
45431
+ // summaryMetadata: { items: [{ id: 'model', value: selectedModelLabel || selectedModel, shortValue: selectedModel, order: 10 }] },
45006
45432
  });
45007
45433
  } catch(e) {
45008
45434
  return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
@@ -46737,7 +47163,6 @@ async (params) => {
46737
47163
  lastMessage: s15.activeChat?.messages?.slice(-1)[0] || null,
46738
47164
  activeModal: s15.activeChat?.activeModal || null,
46739
47165
  pendingEvents: s15.pendingEvents || [],
46740
- currentModel: s15.currentModel,
46741
47166
  settings: s15.settings
46742
47167
  }));
46743
47168
  ctx.json(res, 200, { instances: result, count: result.length });
@@ -47892,7 +48317,7 @@ async (params) => {
47892
48317
  lines.push("## Required Return Format");
47893
48318
  lines.push("| Function | Return JSON |");
47894
48319
  lines.push("|---|---|");
47895
- lines.push("| readChat | `{ id, status, title, messages: [{role, content, index, kind?, meta?}], inputContent, activeModal }` \u2014 optional `kind`: standard, thought, tool, terminal; optional `meta`: e.g. `{ label, isRunning }` for dashboard |");
48320
+ lines.push("| readChat | `{ id, status, title, messages: [{role, content, index, kind?, meta?}], inputContent, activeModal, controlValues?, summaryMetadata? }` \u2014 optional `kind`: standard, thought, tool, terminal; prefer explicit `controlValues` for current selections and `summaryMetadata` for compact always-visible UI metadata |");
47896
48321
  lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
47897
48322
  lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
47898
48323
  lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
@@ -49525,7 +49950,7 @@ data: ${JSON.stringify(msg.data)}
49525
49950
  lines.push("## Required Return Format");
49526
49951
  lines.push("| Function | Return JSON |");
49527
49952
  lines.push("|---|---|");
49528
- lines.push("| readChat | `{ id, status, title, messages: [{role, content, index, kind?, meta?}], inputContent, activeModal }` \u2014 optional `kind`: standard, thought, tool, terminal; optional `meta`: e.g. `{ label, isRunning }` for dashboard |");
49953
+ lines.push("| readChat | `{ id, status, title, messages: [{role, content, index, kind?, meta?}], inputContent, activeModal, controlValues?, summaryMetadata? }` \u2014 optional `kind`: standard, thought, tool, terminal; prefer explicit `controlValues` for current selections and `summaryMetadata` for compact always-visible UI metadata |");
49529
49954
  lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
49530
49955
  lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
49531
49956
  lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
@@ -50422,59 +50847,6 @@ data: ${JSON.stringify(msg.data)}
50422
50847
  });
50423
50848
  }
50424
50849
  }
50425
- var LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
50426
- function isSessionHostLiveRuntime(record2) {
50427
- const lifecycle = String(record2?.lifecycle || "").trim();
50428
- return LIVE_LIFECYCLES.has(lifecycle);
50429
- }
50430
- function getSessionHostRecoveryLabel(meta3) {
50431
- const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
50432
- if (!recoveryState) return null;
50433
- if (recoveryState === "auto_resumed") return "restored after restart";
50434
- if (recoveryState === "resume_failed") return "restore failed";
50435
- if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
50436
- if (recoveryState === "orphan_snapshot") return "snapshot recovered";
50437
- return recoveryState.replace(/_/g, " ");
50438
- }
50439
- function isSessionHostRecoverySnapshot(record2) {
50440
- if (!record2) return false;
50441
- if (isSessionHostLiveRuntime(record2)) return false;
50442
- const lifecycle = String(record2.lifecycle || "").trim();
50443
- if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
50444
- return false;
50445
- }
50446
- const meta3 = record2.meta || void 0;
50447
- if (meta3?.restoredFromStorage === true) return true;
50448
- return getSessionHostRecoveryLabel(meta3) !== null;
50449
- }
50450
- function getSessionHostSurfaceKind(record2) {
50451
- if (isSessionHostLiveRuntime(record2)) return "live_runtime";
50452
- if (isSessionHostRecoverySnapshot(record2)) return "recovery_snapshot";
50453
- return "inactive_record";
50454
- }
50455
- function partitionSessionHostRecords(records) {
50456
- const liveRuntimes = [];
50457
- const recoverySnapshots = [];
50458
- const inactiveRecords = [];
50459
- for (const record2 of records) {
50460
- const kind = getSessionHostSurfaceKind(record2);
50461
- if (kind === "live_runtime") {
50462
- liveRuntimes.push(record2);
50463
- } else if (kind === "recovery_snapshot") {
50464
- recoverySnapshots.push(record2);
50465
- } else {
50466
- inactiveRecords.push(record2);
50467
- }
50468
- }
50469
- return {
50470
- liveRuntimes,
50471
- recoverySnapshots,
50472
- inactiveRecords
50473
- };
50474
- }
50475
- function partitionSessionHostDiagnosticsSessions(records) {
50476
- return partitionSessionHostRecords(records || []);
50477
- }
50478
50850
  function shouldAutoRestoreHostedSessionsOnStartup2(env = process.env) {
50479
50851
  const raw = typeof env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP === "string" ? env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP.trim().toLowerCase() : "";
50480
50852
  return raw === "1" || raw === "true" || raw === "yes";
@@ -52575,9 +52947,6 @@ var StandaloneServer = class {
52575
52947
  status: session.status,
52576
52948
  title: session.title,
52577
52949
  cdpConnected: session.cdpConnected,
52578
- currentModel: session.currentModel,
52579
- currentPlan: session.currentPlan,
52580
- currentAutoApprove: session.currentAutoApprove,
52581
52950
  lastSeenAt: session.lastSeenAt,
52582
52951
  unread: session.unread,
52583
52952
  inboxBucket: session.inboxBucket,
@@ -52605,8 +52974,10 @@ var StandaloneServer = class {
52605
52974
  return { success: false, error: "command type required" };
52606
52975
  }
52607
52976
  const result = await this.components.router.execute(type, args, "standalone");
52608
- if (type.startsWith("workspace_") || type.startsWith("session_host_")) this.scheduleBroadcastStatus();
52609
- if (type === "get_status_metadata" || type === "set_user_name" || type === "set_machine_nickname" || type.startsWith("workspace_") || type.startsWith("session_host_")) {
52977
+ if (type === "invoke_provider_script" || type.startsWith("workspace_") || type.startsWith("session_host_")) {
52978
+ this.scheduleBroadcastStatus();
52979
+ }
52980
+ if (type === "invoke_provider_script" || type === "get_status_metadata" || type === "set_user_name" || type === "set_machine_nickname" || type.startsWith("workspace_") || type.startsWith("session_host_")) {
52610
52981
  void this.flushWsDaemonMetadataSubscriptions();
52611
52982
  }
52612
52983
  if (type.startsWith("session_host_")) void this.flushWsSessionHostDiagnosticsSubscriptions();