@adhdev/daemon-core 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.
Files changed (57) hide show
  1. package/dist/agent-stream/types.d.ts +3 -4
  2. package/dist/commands/router.d.ts +1 -0
  3. package/dist/commands/stream-commands.d.ts +1 -0
  4. package/dist/config/recent-activity.d.ts +2 -1
  5. package/dist/config/saved-sessions.d.ts +2 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +560 -182
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +560 -182
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/providers/acp-provider-instance.d.ts +8 -2
  12. package/dist/providers/cli-provider-instance.d.ts +1 -0
  13. package/dist/providers/contracts.d.ts +3 -2
  14. package/dist/providers/extension-provider-instance.d.ts +1 -2
  15. package/dist/providers/provider-instance.d.ts +3 -4
  16. package/dist/providers/provider-patch-state.d.ts +23 -0
  17. package/dist/providers/summary-metadata.d.ts +22 -0
  18. package/dist/shared-types.d.ts +15 -9
  19. package/dist/status/snapshot.d.ts +16 -1
  20. package/node_modules/@adhdev/session-host-core/package.json +1 -1
  21. package/package.json +1 -1
  22. package/src/agent-stream/forward.ts +1 -2
  23. package/src/agent-stream/manager.ts +2 -1
  24. package/src/agent-stream/provider-adapter.ts +7 -3
  25. package/src/agent-stream/types.d.ts +3 -4
  26. package/src/agent-stream/types.ts +3 -4
  27. package/src/commands/cli-manager.ts +10 -5
  28. package/src/commands/router.ts +155 -22
  29. package/src/commands/stream-commands.ts +19 -2
  30. package/src/config/recent-activity.d.ts +2 -1
  31. package/src/config/recent-activity.ts +12 -1
  32. package/src/config/saved-sessions.d.ts +2 -1
  33. package/src/config/saved-sessions.ts +12 -2
  34. package/src/daemon/dev-auto-implement.ts +1 -1
  35. package/src/daemon/dev-cli-debug.ts +0 -1
  36. package/src/daemon/dev-server.ts +1 -1
  37. package/src/daemon/scaffold-template.ts +8 -1
  38. package/src/index.d.ts +1 -1
  39. package/src/index.ts +2 -0
  40. package/src/providers/acp-provider-instance.d.ts +8 -2
  41. package/src/providers/acp-provider-instance.ts +80 -23
  42. package/src/providers/cli-provider-instance.ts +17 -22
  43. package/src/providers/contracts.d.ts +3 -2
  44. package/src/providers/contracts.ts +6 -4
  45. package/src/providers/control-effects.ts +3 -4
  46. package/src/providers/extension-provider-instance.d.ts +1 -2
  47. package/src/providers/extension-provider-instance.ts +26 -14
  48. package/src/providers/ide-provider-instance.ts +28 -15
  49. package/src/providers/provider-instance.d.ts +3 -4
  50. package/src/providers/provider-instance.ts +6 -7
  51. package/src/providers/provider-patch-state.ts +91 -0
  52. package/src/providers/summary-metadata.ts +118 -0
  53. package/src/shared-types.d.ts +15 -9
  54. package/src/shared-types.ts +17 -9
  55. package/src/status/builders.ts +18 -13
  56. package/src/status/reporter.ts +2 -4
  57. package/src/status/snapshot.ts +60 -2
package/dist/index.mjs CHANGED
@@ -3175,6 +3175,70 @@ function setDefaultWorkspaceId(config, id) {
3175
3175
 
3176
3176
  // src/config/recent-activity.ts
3177
3177
  import * as path2 from "path";
3178
+
3179
+ // src/providers/summary-metadata.ts
3180
+ function normalizeSummaryItem(item) {
3181
+ if (!item || typeof item !== "object") return null;
3182
+ const id = String(item.id || "").trim();
3183
+ const value = String(item.value || "").trim();
3184
+ if (!id || !value) return null;
3185
+ const normalized = {
3186
+ id,
3187
+ value
3188
+ };
3189
+ if (typeof item.label === "string" && item.label.trim()) normalized.label = item.label.trim();
3190
+ if (typeof item.shortValue === "string" && item.shortValue.trim()) normalized.shortValue = item.shortValue.trim();
3191
+ if (typeof item.icon === "string" && item.icon.trim()) normalized.icon = item.icon.trim();
3192
+ if (typeof item.order === "number" && Number.isFinite(item.order)) normalized.order = item.order;
3193
+ return normalized;
3194
+ }
3195
+ function normalizeProviderSummaryMetadata(summary) {
3196
+ if (!summary || !Array.isArray(summary.items)) return void 0;
3197
+ const items = summary.items.map((item) => normalizeSummaryItem(item)).filter((item) => !!item).sort((left, right) => {
3198
+ const orderDiff = (left.order ?? Number.MAX_SAFE_INTEGER) - (right.order ?? Number.MAX_SAFE_INTEGER);
3199
+ if (orderDiff !== 0) return orderDiff;
3200
+ return left.id.localeCompare(right.id);
3201
+ });
3202
+ return items.length > 0 ? { items } : void 0;
3203
+ }
3204
+ function buildProviderSummaryMetadata(items) {
3205
+ return normalizeProviderSummaryMetadata({ items: items.filter(Boolean) });
3206
+ }
3207
+ function buildLegacyModelModeSummaryMetadata(params) {
3208
+ return buildProviderSummaryMetadata([
3209
+ params.model ? {
3210
+ id: "model",
3211
+ label: "Model",
3212
+ value: String(params.modelLabel || params.model).trim(),
3213
+ shortValue: String(params.model).trim(),
3214
+ order: 10
3215
+ } : null,
3216
+ params.mode ? {
3217
+ id: "mode",
3218
+ label: "Mode",
3219
+ value: String(params.modeLabel || params.mode).trim(),
3220
+ shortValue: String(params.mode).trim(),
3221
+ order: 20
3222
+ } : null
3223
+ ]);
3224
+ }
3225
+ function resolveProviderStateSummaryMetadata(params) {
3226
+ const explicit = normalizeProviderSummaryMetadata(params.summaryMetadata);
3227
+ if (explicit) return explicit;
3228
+ const model = typeof params.controlValues?.model === "string" ? params.controlValues.model : void 0;
3229
+ const mode = typeof params.controlValues?.mode === "string" ? params.controlValues.mode : void 0;
3230
+ return buildLegacyModelModeSummaryMetadata({
3231
+ model,
3232
+ mode,
3233
+ modelLabel: params.modelLabel,
3234
+ modeLabel: params.modeLabel
3235
+ });
3236
+ }
3237
+ function normalizePersistedSummaryMetadata(params) {
3238
+ return normalizeProviderSummaryMetadata(params.summaryMetadata);
3239
+ }
3240
+
3241
+ // src/config/recent-activity.ts
3178
3242
  var MAX_ACTIVITY = 30;
3179
3243
  function normalizeWorkspace(workspace) {
3180
3244
  if (!workspace) return "";
@@ -3198,6 +3262,9 @@ function appendRecentActivity(state, entry) {
3198
3262
  const nextEntry = {
3199
3263
  ...entry,
3200
3264
  workspace: entry.workspace ? normalizeWorkspace(entry.workspace) : void 0,
3265
+ summaryMetadata: normalizePersistedSummaryMetadata({
3266
+ summaryMetadata: entry.summaryMetadata
3267
+ }),
3201
3268
  id: buildRecentActivityKeyForEntry(entry),
3202
3269
  lastUsedAt: entry.lastUsedAt || Date.now()
3203
3270
  };
@@ -3208,7 +3275,12 @@ function appendRecentActivity(state, entry) {
3208
3275
  };
3209
3276
  }
3210
3277
  function getRecentActivity(state, limit = 20) {
3211
- return [...state.recentActivity || []].sort((a, b) => b.lastUsedAt - a.lastUsedAt).slice(0, limit);
3278
+ return [...state.recentActivity || []].map((entry) => ({
3279
+ ...entry,
3280
+ summaryMetadata: normalizePersistedSummaryMetadata({
3281
+ summaryMetadata: entry.summaryMetadata
3282
+ })
3283
+ })).sort((a, b) => b.lastUsedAt - a.lastUsedAt).slice(0, limit);
3212
3284
  }
3213
3285
  function getSessionSeenAt(state, sessionId) {
3214
3286
  return state.sessionReads?.[sessionId] || 0;
@@ -3260,7 +3332,9 @@ function upsertSavedProviderSession(state, entry) {
3260
3332
  providerName: entry.providerName,
3261
3333
  providerSessionId,
3262
3334
  workspace: entry.workspace ? normalizeWorkspace2(entry.workspace) : void 0,
3263
- currentModel: entry.currentModel,
3335
+ summaryMetadata: normalizePersistedSummaryMetadata({
3336
+ summaryMetadata: entry.summaryMetadata
3337
+ }),
3264
3338
  title: entry.title,
3265
3339
  createdAt: existing?.createdAt || entry.createdAt || Date.now(),
3266
3340
  lastUsedAt: entry.lastUsedAt || Date.now()
@@ -3276,7 +3350,12 @@ function getSavedProviderSessions(state, filters) {
3276
3350
  if (filters?.providerType && entry.providerType !== filters.providerType) return false;
3277
3351
  if (filters?.kind && entry.kind !== filters.kind) return false;
3278
3352
  return true;
3279
- }).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
3353
+ }).map((entry) => ({
3354
+ ...entry,
3355
+ summaryMetadata: normalizePersistedSummaryMetadata({
3356
+ summaryMetadata: entry.summaryMetadata
3357
+ })
3358
+ })).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
3280
3359
  }
3281
3360
 
3282
3361
  // src/config/state-store.ts
@@ -5033,8 +5112,6 @@ function extractProviderControlValues(controls, data) {
5033
5112
  if (rawValue === void 0 || rawValue === null) continue;
5034
5113
  values[ctrl.id] = normalizeControlValue(rawValue);
5035
5114
  }
5036
- if (data.model !== void 0 && values.model === void 0) values.model = normalizeControlValue(data.model);
5037
- if (data.mode !== void 0 && values.mode === void 0) values.mode = normalizeControlValue(data.mode);
5038
5115
  return Object.keys(values).length > 0 ? values : void 0;
5039
5116
  }
5040
5117
  function normalizeProviderEffects(data) {
@@ -5136,7 +5213,7 @@ function normalizeControlOption(option) {
5136
5213
  }
5137
5214
  if (!option || typeof option !== "object") return null;
5138
5215
  const record = option;
5139
- const value = typeof record.value === "string" ? record.value : typeof record.id === "string" ? record.id : null;
5216
+ const value = typeof record.value === "string" ? record.value : typeof record.id === "string" ? record.id : typeof record.name === "string" ? record.name : null;
5140
5217
  if (!value) return null;
5141
5218
  const label = typeof record.label === "string" ? record.label : typeof record.name === "string" ? record.name : value;
5142
5219
  const normalized = { value, label };
@@ -5671,6 +5748,61 @@ function listSavedHistorySessions(agentType, options = {}) {
5671
5748
  }
5672
5749
  }
5673
5750
 
5751
+ // src/providers/provider-patch-state.ts
5752
+ function isControlValue(value) {
5753
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
5754
+ }
5755
+ function asControlValueMap(value) {
5756
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
5757
+ const result = {};
5758
+ for (const [entryKey, entryValue] of Object.entries(value)) {
5759
+ if (isControlValue(entryValue)) result[entryKey] = entryValue;
5760
+ }
5761
+ return Object.keys(result).length > 0 ? result : void 0;
5762
+ }
5763
+ function getLegacyModelModeValues(data) {
5764
+ if (!data || typeof data !== "object") return void 0;
5765
+ const legacy = {};
5766
+ if (typeof data.model === "string" && data.model.trim()) legacy.model = data.model.trim();
5767
+ if (typeof data.mode === "string" && data.mode.trim()) legacy.mode = data.mode.trim();
5768
+ return Object.keys(legacy).length > 0 ? legacy : void 0;
5769
+ }
5770
+ function mergeProviderPatchState(params) {
5771
+ const {
5772
+ providerControls,
5773
+ data,
5774
+ currentControlValues,
5775
+ currentSummaryMetadata,
5776
+ mergeWithCurrent = true
5777
+ } = params;
5778
+ const sources = [
5779
+ mergeWithCurrent ? asControlValueMap(currentControlValues) : void 0,
5780
+ asControlValueMap(data?.controlValues),
5781
+ asControlValueMap(extractProviderControlValues(providerControls, data)),
5782
+ getLegacyModelModeValues(data)
5783
+ ];
5784
+ const controlValues = Object.assign({}, ...sources.filter(Boolean));
5785
+ return {
5786
+ controlValues,
5787
+ summaryMetadata: data?.summaryMetadata !== void 0 ? data.summaryMetadata : currentSummaryMetadata
5788
+ };
5789
+ }
5790
+ function normalizeProviderStateControlValues(controlValues) {
5791
+ return controlValues && Object.keys(controlValues).length > 0 ? controlValues : void 0;
5792
+ }
5793
+ function resolveProviderStateSurface(params) {
5794
+ const controlValues = normalizeProviderStateControlValues(params.controlValues);
5795
+ return {
5796
+ controlValues,
5797
+ summaryMetadata: resolveProviderStateSummaryMetadata({
5798
+ summaryMetadata: params.summaryMetadata,
5799
+ controlValues,
5800
+ modelLabel: params.modelLabel,
5801
+ modeLabel: params.modeLabel
5802
+ })
5803
+ };
5804
+ }
5805
+
5674
5806
  // src/providers/extension-provider-instance.ts
5675
5807
  var ExtensionProviderInstance = class {
5676
5808
  type;
@@ -5685,9 +5817,8 @@ var ExtensionProviderInstance = class {
5685
5817
  messages = [];
5686
5818
  prevMessageHashes = /* @__PURE__ */ new Map();
5687
5819
  activeModal = null;
5688
- currentModel = "";
5689
- currentMode = "";
5690
5820
  controlValues = {};
5821
+ summaryMetadata = void 0;
5691
5822
  appliedEffectKeys = /* @__PURE__ */ new Set();
5692
5823
  runtimeMessages = [];
5693
5824
  lastAgentStatus = "idle";
@@ -5722,6 +5853,10 @@ var ExtensionProviderInstance = class {
5722
5853
  if (!this.context?.cdp?.isConnected) return;
5723
5854
  }
5724
5855
  getState() {
5856
+ const surface = resolveProviderStateSurface({
5857
+ summaryMetadata: this.summaryMetadata,
5858
+ controlValues: this.controlValues
5859
+ });
5725
5860
  return {
5726
5861
  type: this.type,
5727
5862
  name: this.provider.name,
@@ -5735,10 +5870,9 @@ var ExtensionProviderInstance = class {
5735
5870
  activeModal: this.activeModal,
5736
5871
  inputContent: ""
5737
5872
  } : null,
5738
- currentModel: this.currentModel || void 0,
5739
- currentPlan: this.currentMode || void 0,
5740
- controlValues: this.controlValues,
5873
+ controlValues: surface.controlValues,
5741
5874
  providerControls: this.provider.controls,
5875
+ summaryMetadata: surface.summaryMetadata,
5742
5876
  agentStreams: this.agentStreams,
5743
5877
  instanceId: this.instanceId,
5744
5878
  lastUpdated: Date.now(),
@@ -5751,10 +5885,14 @@ var ExtensionProviderInstance = class {
5751
5885
  if (data?.streams) this.agentStreams = data.streams;
5752
5886
  if (data?.messages) this.messages = this.assignReceivedAt(data.messages);
5753
5887
  if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
5754
- if (data?.model) this.currentModel = data.model;
5755
- if (data?.mode) this.currentMode = data.mode;
5756
- const controlValues = extractProviderControlValues(this.provider.controls, data) || data?.controlValues;
5757
- if (controlValues) this.controlValues = controlValues;
5888
+ const patchedState = mergeProviderPatchState({
5889
+ providerControls: this.provider.controls,
5890
+ data,
5891
+ currentControlValues: this.controlValues,
5892
+ currentSummaryMetadata: this.summaryMetadata
5893
+ });
5894
+ this.controlValues = patchedState.controlValues;
5895
+ this.summaryMetadata = patchedState.summaryMetadata;
5758
5896
  if (typeof data?.sessionId === "string" && data.sessionId.trim()) this.chatId = data.sessionId;
5759
5897
  if (typeof data?.title === "string" && data.title.trim()) this.chatTitle = data.title;
5760
5898
  if (typeof data?.agentName === "string" && data.agentName.trim()) this.agentName = data.agentName;
@@ -5855,8 +5993,14 @@ var ExtensionProviderInstance = class {
5855
5993
  }
5856
5994
  applyProviderResponse(data, options) {
5857
5995
  if (!data || typeof data !== "object") return;
5858
- const controlValues = extractProviderControlValues(this.provider.controls, data);
5859
- if (controlValues) this.controlValues = { ...this.controlValues, ...controlValues };
5996
+ const patchedState = mergeProviderPatchState({
5997
+ providerControls: this.provider.controls,
5998
+ data,
5999
+ currentControlValues: this.controlValues,
6000
+ currentSummaryMetadata: this.summaryMetadata
6001
+ });
6002
+ this.controlValues = patchedState.controlValues;
6003
+ this.summaryMetadata = patchedState.summaryMetadata;
5860
6004
  const effects = normalizeProviderEffects(data);
5861
6005
  for (const effect of effects) {
5862
6006
  const effectWhen = effect.when || "immediate";
@@ -6006,8 +6150,6 @@ ${effect.notification.body || ""}`.trim();
6006
6150
  this.messages = [];
6007
6151
  this.prevMessageHashes.clear();
6008
6152
  this.activeModal = null;
6009
- this.currentModel = "";
6010
- this.currentMode = "";
6011
6153
  this.controlValues = {};
6012
6154
  this.currentStatus = "idle";
6013
6155
  this.chatId = null;
@@ -6143,6 +6285,10 @@ var IdeProviderInstance = class {
6143
6285
  for (const ext of this.extensions.values()) {
6144
6286
  extensionStates.push(ext.getState());
6145
6287
  }
6288
+ const surface = resolveProviderStateSurface({
6289
+ summaryMetadata: this.cachedChat?.summaryMetadata,
6290
+ controlValues: this.cachedChat?.controlValues
6291
+ });
6146
6292
  return {
6147
6293
  type: this.type,
6148
6294
  name: this.provider.name,
@@ -6159,11 +6305,9 @@ var IdeProviderInstance = class {
6159
6305
  workspace: this.workspace || null,
6160
6306
  extensions: extensionStates,
6161
6307
  cdpConnected: cdp?.isConnected || false,
6162
- currentModel: this.cachedChat?.model || void 0,
6163
- currentPlan: this.cachedChat?.mode || void 0,
6164
- currentAutoApprove: this.cachedChat?.autoApprove || void 0,
6165
- controlValues: this.cachedChat?.controlValues || void 0,
6308
+ controlValues: surface.controlValues,
6166
6309
  providerControls: this.provider.controls,
6310
+ summaryMetadata: surface.summaryMetadata,
6167
6311
  instanceId: this.instanceId,
6168
6312
  lastUpdated: Date.now(),
6169
6313
  settings: this.settings,
@@ -6335,8 +6479,13 @@ var IdeProviderInstance = class {
6335
6479
  chat.messages = messages.filter((m) => !hiddenKinds.has(m.kind || ""));
6336
6480
  }
6337
6481
  }
6338
- const controlValues = extractProviderControlValues(this.provider.controls, chat);
6339
- if (controlValues) chat.controlValues = controlValues;
6482
+ const patchedState = mergeProviderPatchState({
6483
+ providerControls: this.provider.controls,
6484
+ data: chat,
6485
+ mergeWithCurrent: false
6486
+ });
6487
+ chat.controlValues = Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0;
6488
+ chat.summaryMetadata = patchedState.summaryMetadata;
6340
6489
  this.cachedChat = { ...chat, activeModal };
6341
6490
  this.detectAgentTransitions(chat, now);
6342
6491
  const persistedMessages = chat.messages || messages;
@@ -6423,14 +6572,18 @@ var IdeProviderInstance = class {
6423
6572
  }
6424
6573
  applyProviderResponse(data, options) {
6425
6574
  if (!data || typeof data !== "object") return;
6426
- const controlValues = extractProviderControlValues(this.provider.controls, data);
6427
- if (controlValues) {
6428
- this.cachedChat = {
6429
- ...this.cachedChat || {},
6430
- ...data,
6431
- controlValues: { ...this.cachedChat?.controlValues || {}, ...controlValues }
6432
- };
6433
- }
6575
+ const patchedState = mergeProviderPatchState({
6576
+ providerControls: this.provider.controls,
6577
+ data,
6578
+ currentControlValues: this.cachedChat?.controlValues,
6579
+ currentSummaryMetadata: this.cachedChat?.summaryMetadata
6580
+ });
6581
+ this.cachedChat = {
6582
+ ...this.cachedChat || {},
6583
+ ...data,
6584
+ controlValues: Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0,
6585
+ summaryMetadata: patchedState.summaryMetadata
6586
+ };
6434
6587
  const effects = normalizeProviderEffects(data);
6435
6588
  for (const effect of effects) {
6436
6589
  const effectWhen = effect.when || "immediate";
@@ -7213,6 +7366,8 @@ var ACP_SESSION_CAPABILITIES = [
7213
7366
  function buildIdeWorkspaceSession(state, cdpManagers, options) {
7214
7367
  const profile = options.profile || "full";
7215
7368
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
7369
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
7370
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
7216
7371
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
7217
7372
  const includeSessionControls = shouldIncludeSessionControls(profile);
7218
7373
  const title = activeChat?.title || state.name;
@@ -7229,13 +7384,11 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
7229
7384
  title,
7230
7385
  ...includeSessionMetadata && { workspace: state.workspace || null },
7231
7386
  activeChat,
7387
+ ...summaryMetadata && { summaryMetadata },
7232
7388
  ...includeSessionMetadata && { capabilities: IDE_SESSION_CAPABILITIES },
7233
7389
  cdpConnected: state.cdpConnected ?? isCdpConnected(cdpManagers, state.type),
7234
- currentModel: state.currentModel,
7235
- currentPlan: state.currentPlan,
7236
- currentAutoApprove: state.currentAutoApprove,
7237
7390
  ...includeSessionControls && {
7238
- controlValues: state.controlValues,
7391
+ ...controlValues && { controlValues },
7239
7392
  providerControls: state.providerControls
7240
7393
  },
7241
7394
  errorMessage: state.errorMessage,
@@ -7246,6 +7399,8 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
7246
7399
  function buildExtensionAgentSession(parent, ext, options) {
7247
7400
  const profile = options.profile || "full";
7248
7401
  const activeChat = normalizeActiveChatData(ext.activeChat, getActiveChatOptions(profile));
7402
+ const summaryMetadata = normalizeProviderSummaryMetadata(ext.summaryMetadata);
7403
+ const controlValues = normalizeProviderStateControlValues(ext.controlValues);
7249
7404
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
7250
7405
  const includeSessionControls = shouldIncludeSessionControls(profile);
7251
7406
  return {
@@ -7261,11 +7416,10 @@ function buildExtensionAgentSession(parent, ext, options) {
7261
7416
  title: activeChat?.title || ext.name,
7262
7417
  ...includeSessionMetadata && { workspace: parent.workspace || null },
7263
7418
  activeChat,
7419
+ ...summaryMetadata && { summaryMetadata },
7264
7420
  ...includeSessionMetadata && { capabilities: EXTENSION_SESSION_CAPABILITIES },
7265
- currentModel: ext.currentModel,
7266
- currentPlan: ext.currentPlan,
7267
7421
  ...includeSessionControls && {
7268
- controlValues: ext.controlValues,
7422
+ ...controlValues && { controlValues },
7269
7423
  providerControls: ext.providerControls
7270
7424
  },
7271
7425
  errorMessage: ext.errorMessage,
@@ -7276,6 +7430,8 @@ function buildExtensionAgentSession(parent, ext, options) {
7276
7430
  function buildCliSession(state, options) {
7277
7431
  const profile = options.profile || "full";
7278
7432
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
7433
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
7434
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
7279
7435
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
7280
7436
  const includeRuntimeMetadata = shouldIncludeRuntimeMetadata(profile);
7281
7437
  const includeSessionControls = shouldIncludeSessionControls(profile);
@@ -7302,11 +7458,12 @@ function buildCliSession(state, options) {
7302
7458
  mode: state.mode,
7303
7459
  resume: state.resume,
7304
7460
  activeChat,
7461
+ ...summaryMetadata && { summaryMetadata },
7305
7462
  ...includeSessionMetadata && {
7306
7463
  capabilities: state.mode === "terminal" ? PTY_SESSION_CAPABILITIES : CLI_CHAT_SESSION_CAPABILITIES
7307
7464
  },
7308
7465
  ...includeSessionControls && {
7309
- controlValues: state.controlValues,
7466
+ ...controlValues && { controlValues },
7310
7467
  providerControls: state.providerControls
7311
7468
  },
7312
7469
  errorMessage: state.errorMessage,
@@ -7317,6 +7474,8 @@ function buildCliSession(state, options) {
7317
7474
  function buildAcpSession(state, options) {
7318
7475
  const profile = options.profile || "full";
7319
7476
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
7477
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
7478
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
7320
7479
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
7321
7480
  const includeSessionControls = shouldIncludeSessionControls(profile);
7322
7481
  return {
@@ -7332,13 +7491,10 @@ function buildAcpSession(state, options) {
7332
7491
  title: activeChat?.title || state.name,
7333
7492
  ...includeSessionMetadata && { workspace: state.workspace || null },
7334
7493
  activeChat,
7494
+ ...summaryMetadata && { summaryMetadata },
7335
7495
  ...includeSessionMetadata && { capabilities: ACP_SESSION_CAPABILITIES },
7336
- currentModel: state.currentModel,
7337
- currentPlan: state.currentPlan,
7338
7496
  ...includeSessionControls && {
7339
- acpConfigOptions: state.acpConfigOptions,
7340
- acpModes: state.acpModes,
7341
- controlValues: state.controlValues,
7497
+ ...controlValues && { controlValues },
7342
7498
  providerControls: state.providerControls
7343
7499
  },
7344
7500
  errorMessage: state.errorMessage,
@@ -9398,8 +9554,17 @@ async function handleSetProviderSourceConfig(h, args) {
9398
9554
  );
9399
9555
  return { success: true, reloaded: true, ...sourceConfig };
9400
9556
  }
9401
- function normalizeProviderScriptArgs(args) {
9557
+ function normalizeProviderScriptArgs(args, scriptName) {
9402
9558
  const normalizedArgs = { ...args || {} };
9559
+ const normalizedScriptName = String(scriptName || "").toLowerCase();
9560
+ if (Object.prototype.hasOwnProperty.call(normalizedArgs, "value")) {
9561
+ if (normalizedArgs.model === void 0 && (normalizedScriptName === "setmodel" || normalizedScriptName === "setmodelgui" || normalizedScriptName === "webviewsetmodel")) {
9562
+ normalizedArgs.model = normalizedArgs.value;
9563
+ }
9564
+ if (normalizedArgs.mode === void 0 && (normalizedScriptName === "setmode" || normalizedScriptName === "webviewsetmode")) {
9565
+ normalizedArgs.mode = normalizedArgs.value;
9566
+ }
9567
+ }
9403
9568
  for (const key of ["mode", "model", "message", "action", "button", "text", "sessionId", "value"]) {
9404
9569
  if (key in normalizedArgs && !(key.toUpperCase() in normalizedArgs)) {
9405
9570
  normalizedArgs[key.toUpperCase()] = normalizedArgs[key];
@@ -9445,7 +9610,7 @@ async function executeProviderScript(h, args, scriptName) {
9445
9610
  if (!provider.scripts?.[actualScriptName]) {
9446
9611
  return { success: false, error: `Script '${actualScriptName}' not available for ${resolvedProviderType}` };
9447
9612
  }
9448
- const normalizedArgs = normalizeProviderScriptArgs(args);
9613
+ const normalizedArgs = normalizeProviderScriptArgs(args, actualScriptName);
9449
9614
  if (provider.category === "cli") {
9450
9615
  const adapter = h.getCliAdapter(args?.targetSessionId || resolvedProviderType);
9451
9616
  if (!adapter?.invokeScript) {
@@ -10306,6 +10471,7 @@ var CliProviderInstance = class {
10306
10471
  generatingDebouncePending = null;
10307
10472
  lastApprovalEventAt = 0;
10308
10473
  controlValues = {};
10474
+ summaryMetadata = void 0;
10309
10475
  appliedEffectKeys = /* @__PURE__ */ new Set();
10310
10476
  historyWriter;
10311
10477
  runtimeMessages = [];
@@ -10448,13 +10614,7 @@ var CliProviderInstance = class {
10448
10614
  if (historyMessageCount !== null) {
10449
10615
  parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
10450
10616
  }
10451
- const controlValues = extractProviderControlValues(this.provider.controls, parsedStatus);
10452
- if (controlValues) {
10453
- this.controlValues = { ...this.controlValues, ...controlValues };
10454
- }
10455
10617
  const mergedMessages = this.mergeConversationMessages(parsedMessages);
10456
- 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;
10457
- 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;
10458
10618
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
10459
10619
  if (parsedMessages.length > 0) {
10460
10620
  const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
@@ -10476,6 +10636,10 @@ var CliProviderInstance = class {
10476
10636
  }
10477
10637
  }
10478
10638
  this.applyProviderResponse(parsedStatus, { phase: "immediate" });
10639
+ const surface = resolveProviderStateSurface({
10640
+ summaryMetadata: this.summaryMetadata,
10641
+ controlValues: this.controlValues
10642
+ });
10479
10643
  return {
10480
10644
  type: this.type,
10481
10645
  name: this.provider.name,
@@ -10491,8 +10655,6 @@ var CliProviderInstance = class {
10491
10655
  inputContent: ""
10492
10656
  },
10493
10657
  workspace: this.workingDir,
10494
- currentModel,
10495
- currentPlan,
10496
10658
  instanceId: this.instanceId,
10497
10659
  providerSessionId: this.providerSessionId,
10498
10660
  lastUpdated: Date.now(),
@@ -10507,8 +10669,9 @@ var CliProviderInstance = class {
10507
10669
  attachedClients: runtime.attachedClients || []
10508
10670
  } : void 0,
10509
10671
  resume: this.provider.resume,
10510
- controlValues: this.controlValues,
10511
- providerControls: this.provider.controls
10672
+ controlValues: surface.controlValues,
10673
+ providerControls: this.provider.controls,
10674
+ summaryMetadata: surface.summaryMetadata
10512
10675
  };
10513
10676
  }
10514
10677
  setPresentationMode(mode) {
@@ -10712,10 +10875,14 @@ var CliProviderInstance = class {
10712
10875
  this.suppressIdleHistoryReplay = false;
10713
10876
  this.adapter.clearHistory();
10714
10877
  }
10715
- const controlValues = extractProviderControlValues(this.provider.controls, data);
10716
- if (controlValues) {
10717
- this.controlValues = { ...this.controlValues, ...controlValues };
10718
- }
10878
+ const patchedState = mergeProviderPatchState({
10879
+ providerControls: this.provider.controls,
10880
+ data,
10881
+ currentControlValues: this.controlValues,
10882
+ currentSummaryMetadata: this.summaryMetadata
10883
+ });
10884
+ this.controlValues = patchedState.controlValues;
10885
+ this.summaryMetadata = patchedState.summaryMetadata;
10719
10886
  const effects = normalizeProviderEffects(data);
10720
10887
  for (const effect of effects) {
10721
10888
  const effectWhen = effect.when || "immediate";
@@ -11086,8 +11253,7 @@ var AcpProviderInstance = class {
11086
11253
  lastStatus = "starting";
11087
11254
  generatingStartedAt = 0;
11088
11255
  agentCapabilities = {};
11089
- currentModel;
11090
- currentMode;
11256
+ currentSelections = {};
11091
11257
  activeToolCalls = [];
11092
11258
  stopReason = null;
11093
11259
  partialContent = "";
@@ -11167,8 +11333,6 @@ var AcpProviderInstance = class {
11167
11333
  inputContent: ""
11168
11334
  },
11169
11335
  workspace: this.workingDir,
11170
- currentModel: this.currentModel,
11171
- currentPlan: this.currentMode,
11172
11336
  instanceId: this.instanceId,
11173
11337
  lastUpdated: Date.now(),
11174
11338
  settings: this.settings,
@@ -11179,11 +11343,9 @@ var AcpProviderInstance = class {
11179
11343
  // Error details for dashboard display
11180
11344
  errorMessage: this.errorMessage || void 0,
11181
11345
  errorReason: this.errorReason || void 0,
11182
- controlValues: {
11183
- ...this.currentModel ? { model: this.currentModel } : {},
11184
- ...this.currentMode ? { mode: this.currentMode } : {}
11185
- },
11186
- providerControls: this.provider.controls
11346
+ controlValues: this.getSelectionControlValues(),
11347
+ providerControls: this.provider.controls,
11348
+ summaryMetadata: this.buildSelectionSummaryMetadata()
11187
11349
  };
11188
11350
  }
11189
11351
  onEvent(event, data) {
@@ -11217,6 +11379,54 @@ var AcpProviderInstance = class {
11217
11379
  getInstanceId() {
11218
11380
  return this.instanceId;
11219
11381
  }
11382
+ resolveConfigOptionLabel(category, value) {
11383
+ if (!value) return void 0;
11384
+ const option = this.configOptions.find((entry) => entry.category === category);
11385
+ return option?.options.find((candidate) => candidate.value === value)?.name || value;
11386
+ }
11387
+ resolveModeLabel(modeId) {
11388
+ if (!modeId) return void 0;
11389
+ return this.availableModes.find((mode) => mode.id === modeId)?.name || modeId;
11390
+ }
11391
+ getCurrentSelection(category) {
11392
+ return this.currentSelections[category];
11393
+ }
11394
+ setCurrentSelection(category, value) {
11395
+ const normalized = typeof value === "string" ? value.trim() : "";
11396
+ if (normalized) {
11397
+ this.currentSelections[category] = normalized;
11398
+ return;
11399
+ }
11400
+ delete this.currentSelections[category];
11401
+ }
11402
+ getSelectionControlValues() {
11403
+ const model = this.getCurrentSelection("model");
11404
+ const mode = this.getCurrentSelection("mode");
11405
+ return {
11406
+ ...model ? { model } : {},
11407
+ ...mode ? { mode } : {}
11408
+ };
11409
+ }
11410
+ resolveSelectionLabel(category, value) {
11411
+ if (!value) return void 0;
11412
+ const configLabel = this.resolveConfigOptionLabel(category, value);
11413
+ if (configLabel && configLabel !== value) return configLabel;
11414
+ if (category === "mode") {
11415
+ const modeLabel = this.resolveModeLabel(value);
11416
+ if (modeLabel) return modeLabel;
11417
+ }
11418
+ return configLabel || value;
11419
+ }
11420
+ buildSelectionSummaryMetadata() {
11421
+ const model = this.getCurrentSelection("model");
11422
+ const mode = this.getCurrentSelection("mode");
11423
+ return buildLegacyModelModeSummaryMetadata({
11424
+ model,
11425
+ mode,
11426
+ modelLabel: this.resolveSelectionLabel("model", model),
11427
+ modeLabel: this.resolveSelectionLabel("mode", mode)
11428
+ });
11429
+ }
11220
11430
  // ─── ACP Config Options & Modes ─────────────────────
11221
11431
  parseConfigOptions(raw) {
11222
11432
  if (!Array.isArray(raw)) return;
@@ -11248,12 +11458,14 @@ var AcpProviderInstance = class {
11248
11458
  }
11249
11459
  }
11250
11460
  this.configOptions.push({ category, configId, currentValue, options: flatOptions });
11251
- if (category === "model" && currentValue) this.currentModel = currentValue;
11461
+ if (category === "model" || category === "mode") {
11462
+ this.setCurrentSelection(category, currentValue);
11463
+ }
11252
11464
  }
11253
11465
  }
11254
11466
  parseModes(raw) {
11255
11467
  if (!raw) return;
11256
- if (raw.currentModeId) this.currentMode = raw.currentModeId;
11468
+ this.setCurrentSelection("mode", raw.currentModeId);
11257
11469
  if (Array.isArray(raw.availableModes)) {
11258
11470
  this.availableModes = raw.availableModes.map((m) => ({
11259
11471
  id: m.id,
@@ -11272,8 +11484,7 @@ var AcpProviderInstance = class {
11272
11484
  if (this.useStaticConfig) {
11273
11485
  opt.currentValue = value;
11274
11486
  this.selectedConfig[opt.configId] = value;
11275
- if (category === "model") this.currentModel = value;
11276
- if (category === "mode") this.currentMode = value;
11487
+ if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
11277
11488
  this.log.info(`[${this.type}] Static config ${category} set to: ${value} \u2014 restarting agent`);
11278
11489
  await this.restartWithNewConfig();
11279
11490
  return;
@@ -11291,7 +11502,7 @@ var AcpProviderInstance = class {
11291
11502
  value
11292
11503
  });
11293
11504
  opt.currentValue = value;
11294
- if (category === "model") this.currentModel = value;
11505
+ if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
11295
11506
  if (result?.configOptions) this.parseConfigOptions(result.configOptions);
11296
11507
  this.log.info(`[${this.type}] Config ${category} set to: ${value} | response: ${JSON.stringify(result)?.slice(0, 300)}`);
11297
11508
  } catch (e) {
@@ -11307,7 +11518,7 @@ var AcpProviderInstance = class {
11307
11518
  opt.currentValue = modeId;
11308
11519
  this.selectedConfig[opt.configId] = modeId;
11309
11520
  }
11310
- this.currentMode = modeId;
11521
+ this.setCurrentSelection("mode", modeId);
11311
11522
  this.log.info(`[${this.type}] Static mode set to: ${modeId} \u2014 restarting agent`);
11312
11523
  await this.restartWithNewConfig();
11313
11524
  return;
@@ -11322,7 +11533,7 @@ var AcpProviderInstance = class {
11322
11533
  sessionId: this.sessionId,
11323
11534
  modeId
11324
11535
  });
11325
- this.currentMode = modeId;
11536
+ this.setCurrentSelection("mode", modeId);
11326
11537
  this.log.info(`[${this.type}] Mode set to: ${modeId}`);
11327
11538
  } catch (e) {
11328
11539
  const message = e?.message || "Unknown ACP mode error";
@@ -11580,8 +11791,8 @@ var AcpProviderInstance = class {
11580
11791
  if (result?.modes) this.log.debug(`[${this.type}] modes: ${JSON.stringify(result.modes).slice(0, 300)}`);
11581
11792
  this.parseConfigOptions(result?.configOptions);
11582
11793
  this.parseModes(result?.modes);
11583
- if (!this.currentModel && result?.models?.currentModelId) {
11584
- this.currentModel = result.models.currentModelId;
11794
+ if (!this.getCurrentSelection("model") && result?.models?.currentModelId) {
11795
+ this.setCurrentSelection("model", result.models.currentModelId);
11585
11796
  }
11586
11797
  if (this.configOptions.length === 0 && this.provider.staticConfigOptions?.length) {
11587
11798
  this.useStaticConfig = true;
@@ -11595,13 +11806,16 @@ var AcpProviderInstance = class {
11595
11806
  });
11596
11807
  if (defaultVal) {
11597
11808
  this.selectedConfig[sc.configId] = defaultVal;
11598
- if (sc.category === "model") this.currentModel = defaultVal;
11599
- if (sc.category === "mode") this.currentMode = defaultVal;
11809
+ if (sc.category === "model" || sc.category === "mode") {
11810
+ this.setCurrentSelection(sc.category, defaultVal);
11811
+ }
11600
11812
  }
11601
11813
  }
11602
11814
  this.log.info(`[${this.type}] Using static configOptions (${this.configOptions.length} options)`);
11603
11815
  }
11604
- this.log.info(`[${this.type}] Session created: ${this.sessionId}${this.currentModel ? ` (model: ${this.currentModel})` : ""}${this.currentMode ? ` (mode: ${this.currentMode})` : ""}`);
11816
+ const currentModel = this.getCurrentSelection("model");
11817
+ const currentMode = this.getCurrentSelection("mode");
11818
+ this.log.info(`[${this.type}] Session created: ${this.sessionId}${currentModel ? ` (model: ${currentModel})` : ""}${currentMode ? ` (mode: ${currentMode})` : ""}`);
11605
11819
  if (this.configOptions.length > 0) {
11606
11820
  this.log.info(`[${this.type}] Config options: ${this.configOptions.map((c) => `${c.category}(${c.options.length})`).join(", ")}`);
11607
11821
  }
@@ -11776,7 +11990,7 @@ var AcpProviderInstance = class {
11776
11990
  break;
11777
11991
  }
11778
11992
  case "current_mode_update": {
11779
- this.currentMode = update.currentModeId;
11993
+ this.setCurrentSelection("mode", update.currentModeId);
11780
11994
  break;
11781
11995
  }
11782
11996
  case "config_option_update": {
@@ -11849,7 +12063,7 @@ var AcpProviderInstance = class {
11849
12063
  this.detectStatusTransition();
11850
12064
  }
11851
12065
  if (params.model) {
11852
- this.currentModel = params.model;
12066
+ this.setCurrentSelection("model", params.model);
11853
12067
  }
11854
12068
  }
11855
12069
  /** Map SDK ToolCallStatus to internal status */
@@ -12138,7 +12352,11 @@ var DaemonCliManager = class {
12138
12352
  }
12139
12353
  persistRecentActivity(entry) {
12140
12354
  try {
12141
- let nextState = appendRecentActivity(loadState(), entry);
12355
+ const summaryMetadata = normalizeProviderSummaryMetadata(entry.summaryMetadata);
12356
+ let nextState = appendRecentActivity(loadState(), {
12357
+ ...entry,
12358
+ summaryMetadata
12359
+ });
12142
12360
  if (entry.providerSessionId && (entry.kind === "cli" || entry.kind === "acp")) {
12143
12361
  nextState = upsertSavedProviderSession(nextState, {
12144
12362
  kind: entry.kind,
@@ -12146,7 +12364,7 @@ var DaemonCliManager = class {
12146
12364
  providerName: entry.providerName,
12147
12365
  providerSessionId: entry.providerSessionId,
12148
12366
  workspace: entry.workspace,
12149
- currentModel: entry.currentModel,
12367
+ summaryMetadata,
12150
12368
  title: entry.title
12151
12369
  });
12152
12370
  }
@@ -12336,7 +12554,7 @@ ${installInfo}`
12336
12554
  providerType: normalizedType,
12337
12555
  providerName: provider.displayName || provider.name || normalizedType,
12338
12556
  workspace: resolvedDir,
12339
- currentModel: initialModel,
12557
+ summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
12340
12558
  sessionId,
12341
12559
  title: provider.displayName || provider.name || normalizedType
12342
12560
  });
@@ -12438,7 +12656,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
12438
12656
  providerName: provider?.displayName || provider?.name || normalizedType,
12439
12657
  providerSessionId: sessionBinding.providerSessionId,
12440
12658
  workspace: resolvedDir,
12441
- currentModel: initialModel,
12659
+ summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
12442
12660
  sessionId: key,
12443
12661
  title: provider?.displayName || provider?.name || normalizedType
12444
12662
  });
@@ -14603,12 +14821,90 @@ cleanOldFiles();
14603
14821
  // src/commands/router.ts
14604
14822
  init_logger();
14605
14823
 
14824
+ // src/session-host/runtime-surface.ts
14825
+ var LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
14826
+ function isSessionHostLiveRuntime(record) {
14827
+ const lifecycle = String(record?.lifecycle || "").trim();
14828
+ return LIVE_LIFECYCLES.has(lifecycle);
14829
+ }
14830
+ function getSessionHostRecoveryLabel(meta) {
14831
+ const recoveryState = typeof meta?.runtimeRecoveryState === "string" ? String(meta.runtimeRecoveryState).trim() : "";
14832
+ if (!recoveryState) return null;
14833
+ if (recoveryState === "auto_resumed") return "restored after restart";
14834
+ if (recoveryState === "resume_failed") return "restore failed";
14835
+ if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
14836
+ if (recoveryState === "orphan_snapshot") return "snapshot recovered";
14837
+ return recoveryState.replace(/_/g, " ");
14838
+ }
14839
+ function isSessionHostRecoverySnapshot(record) {
14840
+ if (!record) return false;
14841
+ if (isSessionHostLiveRuntime(record)) return false;
14842
+ const lifecycle = String(record.lifecycle || "").trim();
14843
+ if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
14844
+ return false;
14845
+ }
14846
+ const meta = record.meta || void 0;
14847
+ if (meta?.restoredFromStorage === true) return true;
14848
+ return getSessionHostRecoveryLabel(meta) !== null;
14849
+ }
14850
+ function getSessionHostSurfaceKind(record) {
14851
+ if (isSessionHostLiveRuntime(record)) return "live_runtime";
14852
+ if (isSessionHostRecoverySnapshot(record)) return "recovery_snapshot";
14853
+ return "inactive_record";
14854
+ }
14855
+ function partitionSessionHostRecords(records) {
14856
+ const liveRuntimes = [];
14857
+ const recoverySnapshots = [];
14858
+ const inactiveRecords = [];
14859
+ for (const record of records) {
14860
+ const kind = getSessionHostSurfaceKind(record);
14861
+ if (kind === "live_runtime") {
14862
+ liveRuntimes.push(record);
14863
+ } else if (kind === "recovery_snapshot") {
14864
+ recoverySnapshots.push(record);
14865
+ } else {
14866
+ inactiveRecords.push(record);
14867
+ }
14868
+ }
14869
+ return {
14870
+ liveRuntimes,
14871
+ recoverySnapshots,
14872
+ inactiveRecords
14873
+ };
14874
+ }
14875
+ function partitionSessionHostDiagnosticsSessions(records) {
14876
+ return partitionSessionHostRecords(records || []);
14877
+ }
14878
+
14606
14879
  // src/status/snapshot.ts
14607
14880
  init_config();
14608
14881
  import * as os16 from "os";
14609
14882
  init_terminal_screen();
14610
14883
  init_logger();
14611
14884
  var READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
14885
+ var recentReadDebugSignatureBySession = /* @__PURE__ */ new Map();
14886
+ function buildRecentReadDebugSignature(snapshot) {
14887
+ return [
14888
+ snapshot.providerType,
14889
+ snapshot.status,
14890
+ snapshot.inboxBucket,
14891
+ snapshot.unread ? "1" : "0",
14892
+ String(snapshot.lastSeenAt),
14893
+ snapshot.completionMarker,
14894
+ snapshot.seenCompletionMarker,
14895
+ String(snapshot.lastUpdated),
14896
+ String(snapshot.lastUsedAt),
14897
+ snapshot.lastRole,
14898
+ String(snapshot.messageUpdatedAt)
14899
+ ].join("|");
14900
+ }
14901
+ function shouldEmitRecentReadDebugLog(cache, snapshot) {
14902
+ const nextSignature = buildRecentReadDebugSignature(snapshot);
14903
+ const previousSignature = cache.get(snapshot.sessionId);
14904
+ if (previousSignature === nextSignature) return false;
14905
+ cache.set(snapshot.sessionId, nextSignature);
14906
+ return true;
14907
+ }
14612
14908
  function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
14613
14909
  return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
14614
14910
  id: ide.id,
@@ -14760,7 +15056,7 @@ function buildRecentLaunches(recentActivity) {
14760
15056
  providerSessionId: item.providerSessionId,
14761
15057
  title: item.title || item.providerName,
14762
15058
  workspace: item.workspace,
14763
- currentModel: item.currentModel,
15059
+ summaryMetadata: item.summaryMetadata,
14764
15060
  lastLaunchedAt: item.lastUsedAt
14765
15061
  })).sort((a, b) => b.lastLaunchedAt - a.lastLaunchedAt).slice(0, 12);
14766
15062
  }
@@ -14801,9 +15097,24 @@ function buildStatusSnapshot(options) {
14801
15097
  session.unread = unread;
14802
15098
  session.inboxBucket = inboxBucket;
14803
15099
  if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
15100
+ const recentReadSnapshot = {
15101
+ sessionId: session.id,
15102
+ providerType: session.providerType,
15103
+ status: String(session.status || ""),
15104
+ inboxBucket,
15105
+ unread,
15106
+ lastSeenAt,
15107
+ completionMarker: completionMarker || "-",
15108
+ seenCompletionMarker: seenCompletionMarker || "-",
15109
+ lastUpdated: Number(session.lastUpdated || 0),
15110
+ lastUsedAt,
15111
+ lastRole: getLastMessageRole(sourceSession),
15112
+ messageUpdatedAt: getSessionMessageUpdatedAt(sourceSession)
15113
+ };
15114
+ if (!shouldEmitRecentReadDebugLog(recentReadDebugSignatureBySession, recentReadSnapshot)) continue;
14804
15115
  LOG.info(
14805
15116
  "RecentRead",
14806
- `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)}`
15117
+ `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}`
14807
15118
  );
14808
15119
  }
14809
15120
  const lastDisplayMessage = getLastDisplayMessage(sourceSession);
@@ -15078,11 +15389,104 @@ function toHostedCliRuntimeDescriptor(record) {
15078
15389
  providerSessionId: typeof record.meta?.providerSessionId === "string" ? String(record.meta.providerSessionId) : void 0
15079
15390
  };
15080
15391
  }
15392
+ function getWriteConflictOwnerClientId(error) {
15393
+ const message = typeof error === "string" ? error : error instanceof Error ? error.message : "";
15394
+ const match = /^Write owned by\s+(.+)$/.exec(message.trim());
15395
+ return match?.[1]?.trim() || void 0;
15396
+ }
15397
+ function summarizeSessionHostRecord(result) {
15398
+ if (!result || typeof result !== "object") return {};
15399
+ const record = result;
15400
+ return {
15401
+ runtimeKey: typeof record.runtimeKey === "string" ? record.runtimeKey : void 0,
15402
+ lifecycle: typeof record.lifecycle === "string" ? record.lifecycle : void 0,
15403
+ surfaceKind: getSessionHostSurfaceKind(record),
15404
+ attachedClientCount: Array.isArray(record.attachedClients) ? record.attachedClients.length : void 0,
15405
+ hasWriteOwner: !!record.writeOwner,
15406
+ writeOwnerClientId: typeof record.writeOwner?.clientId === "string" ? record.writeOwner.clientId : void 0
15407
+ };
15408
+ }
15409
+ function summarizeSessionHostRecords(result) {
15410
+ const records = Array.isArray(result) ? result : [];
15411
+ const groups = partitionSessionHostRecords(records);
15412
+ return {
15413
+ sessionCount: records.length,
15414
+ liveRuntimeCount: groups.liveRuntimes.length,
15415
+ recoverySnapshotCount: groups.recoverySnapshots.length,
15416
+ inactiveRecordCount: groups.inactiveRecords.length
15417
+ };
15418
+ }
15419
+ function summarizeSessionHostDiagnostics(result) {
15420
+ const diagnostics = result && typeof result === "object" ? result : {};
15421
+ const sessions = Array.isArray(diagnostics.sessions) ? diagnostics.sessions : [];
15422
+ return {
15423
+ runtimeCount: typeof diagnostics.runtimeCount === "number" ? diagnostics.runtimeCount : void 0,
15424
+ ...summarizeSessionHostRecords(sessions)
15425
+ };
15426
+ }
15427
+ function summarizeSessionHostPruneResult(result) {
15428
+ const value = result && typeof result === "object" ? result : {};
15429
+ return {
15430
+ duplicateGroupCount: typeof value.duplicateGroupCount === "number" ? value.duplicateGroupCount : void 0,
15431
+ prunedCount: Array.isArray(value.prunedSessionIds) ? value.prunedSessionIds.length : void 0,
15432
+ keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
15433
+ };
15434
+ }
15081
15435
  var DaemonCommandRouter = class {
15082
15436
  deps;
15083
15437
  constructor(deps) {
15084
15438
  this.deps = deps;
15085
15439
  }
15440
+ async traceSessionHostAction(action, args, run, summarizeResult) {
15441
+ const interactionId = typeof args?._interactionId === "string" ? args._interactionId : void 0;
15442
+ const sessionId = typeof args?.sessionId === "string" ? args.sessionId : void 0;
15443
+ const requestedPayload = { action };
15444
+ if (sessionId) requestedPayload.sessionId = sessionId;
15445
+ if (typeof args?.clientId === "string") requestedPayload.clientId = args.clientId;
15446
+ if (typeof args?.signal === "string") requestedPayload.signal = args.signal;
15447
+ if (typeof args?.providerType === "string") requestedPayload.providerType = args.providerType;
15448
+ if (typeof args?.workspace === "string") requestedPayload.workspace = args.workspace;
15449
+ if (typeof args?.dryRun === "boolean") requestedPayload.dryRun = args.dryRun;
15450
+ recordDebugTrace({
15451
+ interactionId,
15452
+ category: "session_host",
15453
+ stage: "action_requested",
15454
+ level: "info",
15455
+ sessionId,
15456
+ payload: requestedPayload
15457
+ });
15458
+ try {
15459
+ const result = await run();
15460
+ recordDebugTrace({
15461
+ interactionId,
15462
+ category: "session_host",
15463
+ stage: "action_result",
15464
+ level: "info",
15465
+ sessionId,
15466
+ payload: {
15467
+ ...requestedPayload,
15468
+ success: true,
15469
+ ...summarizeResult ? summarizeResult(result) : {}
15470
+ }
15471
+ });
15472
+ return result;
15473
+ } catch (error) {
15474
+ recordDebugTrace({
15475
+ interactionId,
15476
+ category: "session_host",
15477
+ stage: "action_failed",
15478
+ level: "error",
15479
+ sessionId,
15480
+ payload: {
15481
+ ...requestedPayload,
15482
+ error: error?.message || String(error),
15483
+ failureKind: getWriteConflictOwnerClientId(error) ? "write_conflict" : "request_failed",
15484
+ conflictOwnerClientId: getWriteConflictOwnerClientId(error)
15485
+ }
15486
+ });
15487
+ throw error;
15488
+ }
15489
+ }
15086
15490
  /**
15087
15491
  * Unified command routing.
15088
15492
  * Returns result for all commands:
@@ -15192,44 +15596,60 @@ var DaemonCommandRouter = class {
15192
15596
  }
15193
15597
  case "session_host_get_diagnostics": {
15194
15598
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15195
- const diagnostics = await this.deps.sessionHostControl.getDiagnostics({
15599
+ const diagnostics = await this.traceSessionHostAction("session_host_get_diagnostics", args, () => this.deps.sessionHostControl.getDiagnostics({
15196
15600
  includeSessions: args?.includeSessions !== false,
15197
15601
  limit: Number(args?.limit) || void 0
15198
- });
15602
+ }), (result) => ({
15603
+ includeSessions: args?.includeSessions !== false,
15604
+ limit: Number(args?.limit) || void 0,
15605
+ ...summarizeSessionHostDiagnostics(result)
15606
+ }));
15199
15607
  return { success: true, diagnostics };
15200
15608
  }
15201
15609
  case "session_host_list_sessions": {
15202
15610
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15203
- const sessions = await this.deps.sessionHostControl.listSessions();
15611
+ const sessions = await this.traceSessionHostAction("session_host_list_sessions", args, () => this.deps.sessionHostControl.listSessions(), (records) => summarizeSessionHostRecords(records));
15204
15612
  return { success: true, sessions };
15205
15613
  }
15206
15614
  case "session_host_stop_session": {
15207
15615
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15208
15616
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
15209
15617
  if (!sessionId) return { success: false, error: "sessionId required" };
15210
- const record = await this.deps.sessionHostControl.stopSession(sessionId);
15618
+ const record = await this.traceSessionHostAction("session_host_stop_session", args, () => this.deps.sessionHostControl.stopSession(sessionId), (result) => summarizeSessionHostRecord(result));
15211
15619
  return { success: true, record };
15212
15620
  }
15213
15621
  case "session_host_resume_session": {
15214
15622
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15215
15623
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
15216
15624
  if (!sessionId) return { success: false, error: "sessionId required" };
15217
- const record = await this.deps.sessionHostControl.resumeSession(sessionId);
15218
- const hosted = toHostedCliRuntimeDescriptor(record);
15219
- if (hosted) {
15220
- await this.deps.cliManager.restoreHostedSessions([hosted]);
15221
- }
15625
+ const record = await this.traceSessionHostAction("session_host_resume_session", args, async () => {
15626
+ const nextRecord = await this.deps.sessionHostControl.resumeSession(sessionId);
15627
+ const hosted = toHostedCliRuntimeDescriptor(nextRecord);
15628
+ if (hosted) {
15629
+ await this.deps.cliManager.restoreHostedSessions([hosted]);
15630
+ }
15631
+ return nextRecord;
15632
+ }, (result) => ({
15633
+ ...summarizeSessionHostRecord(result),
15634
+ restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
15635
+ }));
15222
15636
  return { success: true, record };
15223
15637
  }
15224
15638
  case "session_host_restart_session": {
15225
15639
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15226
15640
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
15227
15641
  if (!sessionId) return { success: false, error: "sessionId required" };
15228
- const record = await this.deps.sessionHostControl.restartSession(sessionId);
15229
- const hosted = toHostedCliRuntimeDescriptor(record);
15230
- if (hosted) {
15231
- await this.deps.cliManager.restoreHostedSessions([hosted]);
15232
- }
15642
+ const record = await this.traceSessionHostAction("session_host_restart_session", args, async () => {
15643
+ const nextRecord = await this.deps.sessionHostControl.restartSession(sessionId);
15644
+ const hosted = toHostedCliRuntimeDescriptor(nextRecord);
15645
+ if (hosted) {
15646
+ await this.deps.cliManager.restoreHostedSessions([hosted]);
15647
+ }
15648
+ return nextRecord;
15649
+ }, (result) => ({
15650
+ ...summarizeSessionHostRecord(result),
15651
+ restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
15652
+ }));
15233
15653
  return { success: true, record };
15234
15654
  }
15235
15655
  case "session_host_send_signal": {
@@ -15238,7 +15658,7 @@ var DaemonCommandRouter = class {
15238
15658
  const signal = typeof args?.signal === "string" ? args.signal : "";
15239
15659
  if (!sessionId) return { success: false, error: "sessionId required" };
15240
15660
  if (!signal) return { success: false, error: "signal required" };
15241
- const record = await this.deps.sessionHostControl.sendSignal(sessionId, signal);
15661
+ const record = await this.traceSessionHostAction("session_host_send_signal", args, () => this.deps.sessionHostControl.sendSignal(sessionId, signal), (result) => summarizeSessionHostRecord(result));
15242
15662
  return { success: true, record };
15243
15663
  }
15244
15664
  case "session_host_force_detach_client": {
@@ -15247,16 +15667,16 @@ var DaemonCommandRouter = class {
15247
15667
  const clientId = typeof args?.clientId === "string" ? args.clientId : "";
15248
15668
  if (!sessionId) return { success: false, error: "sessionId required" };
15249
15669
  if (!clientId) return { success: false, error: "clientId required" };
15250
- const record = await this.deps.sessionHostControl.forceDetachClient(sessionId, clientId);
15670
+ const record = await this.traceSessionHostAction("session_host_force_detach_client", args, () => this.deps.sessionHostControl.forceDetachClient(sessionId, clientId), (result) => summarizeSessionHostRecord(result));
15251
15671
  return { success: true, record };
15252
15672
  }
15253
15673
  case "session_host_prune_duplicate_sessions": {
15254
15674
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15255
- const result = await this.deps.sessionHostControl.pruneDuplicateSessions({
15675
+ const result = await this.traceSessionHostAction("session_host_prune_duplicate_sessions", args, () => this.deps.sessionHostControl.pruneDuplicateSessions({
15256
15676
  providerType: typeof args?.providerType === "string" ? args.providerType : void 0,
15257
15677
  workspace: typeof args?.workspace === "string" ? args.workspace : void 0,
15258
15678
  dryRun: args?.dryRun === true
15259
- });
15679
+ }), (value) => summarizeSessionHostPruneResult(value));
15260
15680
  return { success: true, result };
15261
15681
  }
15262
15682
  case "session_host_acquire_write": {
@@ -15266,12 +15686,15 @@ var DaemonCommandRouter = class {
15266
15686
  const ownerType = args?.ownerType === "agent" ? "agent" : "user";
15267
15687
  if (!sessionId) return { success: false, error: "sessionId required" };
15268
15688
  if (!clientId) return { success: false, error: "clientId required" };
15269
- const record = await this.deps.sessionHostControl.acquireWrite({
15689
+ const record = await this.traceSessionHostAction("session_host_acquire_write", args, () => this.deps.sessionHostControl.acquireWrite({
15270
15690
  sessionId,
15271
15691
  clientId,
15272
15692
  ownerType,
15273
15693
  force: args?.force !== false
15274
- });
15694
+ }), (result) => ({
15695
+ ...summarizeSessionHostRecord(result),
15696
+ ownerType
15697
+ }));
15275
15698
  return { success: true, record };
15276
15699
  }
15277
15700
  case "session_host_release_write": {
@@ -15280,7 +15703,10 @@ var DaemonCommandRouter = class {
15280
15703
  const clientId = typeof args?.clientId === "string" ? args.clientId : "";
15281
15704
  if (!sessionId) return { success: false, error: "sessionId required" };
15282
15705
  if (!clientId) return { success: false, error: "clientId required" };
15283
- const record = await this.deps.sessionHostControl.releaseWrite({ sessionId, clientId });
15706
+ const record = await this.traceSessionHostAction("session_host_release_write", args, () => this.deps.sessionHostControl.releaseWrite({
15707
+ sessionId,
15708
+ clientId
15709
+ }), (result) => summarizeSessionHostRecord(result));
15284
15710
  return { success: true, record };
15285
15711
  }
15286
15712
  case "list_saved_sessions": {
@@ -15313,7 +15739,7 @@ var DaemonCommandRouter = class {
15313
15739
  kind: saved?.kind || recent?.kind || kind,
15314
15740
  title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
15315
15741
  workspace: saved?.workspace || recent?.workspace || session.workspace,
15316
- currentModel: saved?.currentModel || recent?.currentModel,
15742
+ summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
15317
15743
  preview: session.preview,
15318
15744
  messageCount: session.messageCount,
15319
15745
  firstMessageAt: session.firstMessageAt,
@@ -15752,7 +16178,7 @@ var DaemonStatusReporter = class {
15752
16178
  const ideSummary = ideStates.map((s) => {
15753
16179
  const msgs = s.activeChat?.messages?.length || 0;
15754
16180
  const exts = s.extensions.length;
15755
- return `${s.type}(${s.status},${msgs}msg,${exts}ext${s.currentModel ? ",model=" + s.currentModel : ""})`;
16181
+ return `${s.type}(${s.status},${msgs}msg,${exts}ext)`;
15756
16182
  }).join(", ");
15757
16183
  const cliSummary = cliStates.map((s) => `${s.type}(${s.status})`).join(", ");
15758
16184
  const acpSummary = acpStates.map((s) => `${s.type}(${s.status})`).join(", ");
@@ -15814,9 +16240,7 @@ var DaemonStatusReporter = class {
15814
16240
  workspace: session.workspace ?? null,
15815
16241
  title: session.title,
15816
16242
  cdpConnected: session.cdpConnected,
15817
- currentModel: session.currentModel,
15818
- currentPlan: session.currentPlan,
15819
- currentAutoApprove: session.currentAutoApprove
16243
+ summaryMetadata: session.summaryMetadata
15820
16244
  })),
15821
16245
  p2p: payload.p2p,
15822
16246
  timestamp: now
@@ -15982,15 +16406,18 @@ var ProviderStreamAdapter = class {
15982
16406
  status: data.status || "idle",
15983
16407
  messages: data.messages || [],
15984
16408
  inputContent: data.inputContent || "",
15985
- model: data.model,
15986
- mode: data.mode,
15987
16409
  activeModal: data.activeModal
15988
16410
  };
15989
16411
  if (typeof data.title === "string" && data.title.trim()) {
15990
16412
  state.title = data.title.trim();
15991
16413
  }
15992
16414
  const controlValues = extractProviderControlValues(this.provider.controls, data);
15993
- if (controlValues) state.controlValues = controlValues;
16415
+ const surface = resolveProviderStateSurface({
16416
+ controlValues,
16417
+ summaryMetadata: data.summaryMetadata
16418
+ });
16419
+ if (surface.controlValues) state.controlValues = surface.controlValues;
16420
+ if (surface.summaryMetadata) state.summaryMetadata = surface.summaryMetadata;
15994
16421
  const effects = normalizeProviderEffects(data);
15995
16422
  if (effects.length > 0) state.effects = effects;
15996
16423
  if (state.messages.length > 0) {
@@ -16264,7 +16691,8 @@ var DaemonAgentStreamManager = class {
16264
16691
  const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.cdpSessionId, expr, timeout);
16265
16692
  const state = await agent.adapter.readChat(evaluate);
16266
16693
  const stateError = this.getStateError(state);
16267
- LOG.debug("AgentStream", `[AgentStream] readChat(${type}) result: status=${state.status} msgs=${state.messages?.length || 0} model=${state.model || ""}${state.status === "error" ? " error=" + JSON.stringify(stateError) : ""}`);
16694
+ const selectedModelValue = typeof state.controlValues?.model === "string" ? state.controlValues.model : "";
16695
+ LOG.debug("AgentStream", `[AgentStream] readChat(${type}) result: status=${state.status} msgs=${state.messages?.length || 0} model=${selectedModelValue}${state.status === "error" ? " error=" + JSON.stringify(stateError) : ""}`);
16268
16696
  if (state.status === "error" && this.isRecoverableSessionError(stateError)) {
16269
16697
  throw new Error(stateError);
16270
16698
  }
@@ -16612,9 +17040,8 @@ function forwardAgentStreamsToIdeInstance(instanceManager, ideType, streams) {
16612
17040
  messages: stream.messages || [],
16613
17041
  status: stream.status || "idle",
16614
17042
  activeModal: stream.activeModal || null,
16615
- model: stream.model || void 0,
16616
- mode: stream.mode || void 0,
16617
17043
  controlValues: stream.controlValues || void 0,
17044
+ summaryMetadata: stream.summaryMetadata || void 0,
16618
17045
  effects: stream.effects || void 0,
16619
17046
  sessionId: stream.sessionId || stream.instanceId || void 0,
16620
17047
  title: stream.title || stream.agentName || void 0,
@@ -17150,7 +17577,11 @@ module.exports.setMode = (params) => {
17150
17577
  * 5. Approval dialog detection (buttons, modal)
17151
17578
  * 6. Input field selector
17152
17579
  *
17153
- * \u2192 { id, status, title, messages[], inputContent, activeModal }
17580
+ * Preferred live-state surface:
17581
+ * - controlValues: explicit current control selections (model/mode/etc.)
17582
+ * - summaryMetadata: compact always-visible metadata for dashboard/recent views
17583
+ * Legacy top-level model/mode output is no longer the preferred shape.
17584
+ * \u2192 { id, status, title, messages[], inputContent, activeModal, controlValues?, summaryMetadata? }
17154
17585
  */
17155
17586
  (() => {
17156
17587
  try {
@@ -17178,6 +17609,9 @@ module.exports.setMode = (params) => {
17178
17609
  messages,
17179
17610
  inputContent,
17180
17611
  activeModal,
17612
+ // TODO: Return explicit selections when available, e.g.
17613
+ // controlValues: { model: selectedModel, mode: selectedMode },
17614
+ // summaryMetadata: { items: [{ id: 'model', value: selectedModelLabel || selectedModel, shortValue: selectedModel, order: 10 }] },
17181
17615
  });
17182
17616
  } catch(e) {
17183
17617
  return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
@@ -18918,7 +19352,6 @@ async function handleCliStatus(ctx, _req, res) {
18918
19352
  lastMessage: s.activeChat?.messages?.slice(-1)[0] || null,
18919
19353
  activeModal: s.activeChat?.activeModal || null,
18920
19354
  pendingEvents: s.pendingEvents || [],
18921
- currentModel: s.currentModel,
18922
19355
  settings: s.settings
18923
19356
  }));
18924
19357
  ctx.json(res, 200, { instances: result, count: result.length });
@@ -20075,7 +20508,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
20075
20508
  lines.push("## Required Return Format");
20076
20509
  lines.push("| Function | Return JSON |");
20077
20510
  lines.push("|---|---|");
20078
- 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 |");
20511
+ 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 |");
20079
20512
  lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
20080
20513
  lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
20081
20514
  lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
@@ -21710,7 +22143,7 @@ var DevServer = class _DevServer {
21710
22143
  lines.push("## Required Return Format");
21711
22144
  lines.push("| Function | Return JSON |");
21712
22145
  lines.push("|---|---|");
21713
- 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 |");
22146
+ 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 |");
21714
22147
  lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
21715
22148
  lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
21716
22149
  lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
@@ -22621,61 +23054,6 @@ async function listHostedCliRuntimes(endpoint) {
22621
23054
  }
22622
23055
  }
22623
23056
 
22624
- // src/session-host/runtime-surface.ts
22625
- var LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
22626
- function isSessionHostLiveRuntime(record) {
22627
- const lifecycle = String(record?.lifecycle || "").trim();
22628
- return LIVE_LIFECYCLES.has(lifecycle);
22629
- }
22630
- function getSessionHostRecoveryLabel(meta) {
22631
- const recoveryState = typeof meta?.runtimeRecoveryState === "string" ? String(meta.runtimeRecoveryState).trim() : "";
22632
- if (!recoveryState) return null;
22633
- if (recoveryState === "auto_resumed") return "restored after restart";
22634
- if (recoveryState === "resume_failed") return "restore failed";
22635
- if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
22636
- if (recoveryState === "orphan_snapshot") return "snapshot recovered";
22637
- return recoveryState.replace(/_/g, " ");
22638
- }
22639
- function isSessionHostRecoverySnapshot(record) {
22640
- if (!record) return false;
22641
- if (isSessionHostLiveRuntime(record)) return false;
22642
- const lifecycle = String(record.lifecycle || "").trim();
22643
- if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
22644
- return false;
22645
- }
22646
- const meta = record.meta || void 0;
22647
- if (meta?.restoredFromStorage === true) return true;
22648
- return getSessionHostRecoveryLabel(meta) !== null;
22649
- }
22650
- function getSessionHostSurfaceKind(record) {
22651
- if (isSessionHostLiveRuntime(record)) return "live_runtime";
22652
- if (isSessionHostRecoverySnapshot(record)) return "recovery_snapshot";
22653
- return "inactive_record";
22654
- }
22655
- function partitionSessionHostRecords(records) {
22656
- const liveRuntimes = [];
22657
- const recoverySnapshots = [];
22658
- const inactiveRecords = [];
22659
- for (const record of records) {
22660
- const kind = getSessionHostSurfaceKind(record);
22661
- if (kind === "live_runtime") {
22662
- liveRuntimes.push(record);
22663
- } else if (kind === "recovery_snapshot") {
22664
- recoverySnapshots.push(record);
22665
- } else {
22666
- inactiveRecords.push(record);
22667
- }
22668
- }
22669
- return {
22670
- liveRuntimes,
22671
- recoverySnapshots,
22672
- inactiveRecords
22673
- };
22674
- }
22675
- function partitionSessionHostDiagnosticsSessions(records) {
22676
- return partitionSessionHostRecords(records || []);
22677
- }
22678
-
22679
23057
  // src/session-host/startup-restore-policy.js
22680
23058
  function shouldAutoRestoreHostedSessionsOnStartup(env = process.env) {
22681
23059
  const raw = typeof env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP === "string" ? env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP.trim().toLowerCase() : "";