@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.js CHANGED
@@ -3287,6 +3287,70 @@ function setDefaultWorkspaceId(config, id) {
3287
3287
 
3288
3288
  // src/config/recent-activity.ts
3289
3289
  var path2 = __toESM(require("path"));
3290
+
3291
+ // src/providers/summary-metadata.ts
3292
+ function normalizeSummaryItem(item) {
3293
+ if (!item || typeof item !== "object") return null;
3294
+ const id = String(item.id || "").trim();
3295
+ const value = String(item.value || "").trim();
3296
+ if (!id || !value) return null;
3297
+ const normalized = {
3298
+ id,
3299
+ value
3300
+ };
3301
+ if (typeof item.label === "string" && item.label.trim()) normalized.label = item.label.trim();
3302
+ if (typeof item.shortValue === "string" && item.shortValue.trim()) normalized.shortValue = item.shortValue.trim();
3303
+ if (typeof item.icon === "string" && item.icon.trim()) normalized.icon = item.icon.trim();
3304
+ if (typeof item.order === "number" && Number.isFinite(item.order)) normalized.order = item.order;
3305
+ return normalized;
3306
+ }
3307
+ function normalizeProviderSummaryMetadata(summary) {
3308
+ if (!summary || !Array.isArray(summary.items)) return void 0;
3309
+ const items = summary.items.map((item) => normalizeSummaryItem(item)).filter((item) => !!item).sort((left, right) => {
3310
+ const orderDiff = (left.order ?? Number.MAX_SAFE_INTEGER) - (right.order ?? Number.MAX_SAFE_INTEGER);
3311
+ if (orderDiff !== 0) return orderDiff;
3312
+ return left.id.localeCompare(right.id);
3313
+ });
3314
+ return items.length > 0 ? { items } : void 0;
3315
+ }
3316
+ function buildProviderSummaryMetadata(items) {
3317
+ return normalizeProviderSummaryMetadata({ items: items.filter(Boolean) });
3318
+ }
3319
+ function buildLegacyModelModeSummaryMetadata(params) {
3320
+ return buildProviderSummaryMetadata([
3321
+ params.model ? {
3322
+ id: "model",
3323
+ label: "Model",
3324
+ value: String(params.modelLabel || params.model).trim(),
3325
+ shortValue: String(params.model).trim(),
3326
+ order: 10
3327
+ } : null,
3328
+ params.mode ? {
3329
+ id: "mode",
3330
+ label: "Mode",
3331
+ value: String(params.modeLabel || params.mode).trim(),
3332
+ shortValue: String(params.mode).trim(),
3333
+ order: 20
3334
+ } : null
3335
+ ]);
3336
+ }
3337
+ function resolveProviderStateSummaryMetadata(params) {
3338
+ const explicit = normalizeProviderSummaryMetadata(params.summaryMetadata);
3339
+ if (explicit) return explicit;
3340
+ const model = typeof params.controlValues?.model === "string" ? params.controlValues.model : void 0;
3341
+ const mode = typeof params.controlValues?.mode === "string" ? params.controlValues.mode : void 0;
3342
+ return buildLegacyModelModeSummaryMetadata({
3343
+ model,
3344
+ mode,
3345
+ modelLabel: params.modelLabel,
3346
+ modeLabel: params.modeLabel
3347
+ });
3348
+ }
3349
+ function normalizePersistedSummaryMetadata(params) {
3350
+ return normalizeProviderSummaryMetadata(params.summaryMetadata);
3351
+ }
3352
+
3353
+ // src/config/recent-activity.ts
3290
3354
  var MAX_ACTIVITY = 30;
3291
3355
  function normalizeWorkspace(workspace) {
3292
3356
  if (!workspace) return "";
@@ -3310,6 +3374,9 @@ function appendRecentActivity(state, entry) {
3310
3374
  const nextEntry = {
3311
3375
  ...entry,
3312
3376
  workspace: entry.workspace ? normalizeWorkspace(entry.workspace) : void 0,
3377
+ summaryMetadata: normalizePersistedSummaryMetadata({
3378
+ summaryMetadata: entry.summaryMetadata
3379
+ }),
3313
3380
  id: buildRecentActivityKeyForEntry(entry),
3314
3381
  lastUsedAt: entry.lastUsedAt || Date.now()
3315
3382
  };
@@ -3320,7 +3387,12 @@ function appendRecentActivity(state, entry) {
3320
3387
  };
3321
3388
  }
3322
3389
  function getRecentActivity(state, limit = 20) {
3323
- return [...state.recentActivity || []].sort((a, b) => b.lastUsedAt - a.lastUsedAt).slice(0, limit);
3390
+ return [...state.recentActivity || []].map((entry) => ({
3391
+ ...entry,
3392
+ summaryMetadata: normalizePersistedSummaryMetadata({
3393
+ summaryMetadata: entry.summaryMetadata
3394
+ })
3395
+ })).sort((a, b) => b.lastUsedAt - a.lastUsedAt).slice(0, limit);
3324
3396
  }
3325
3397
  function getSessionSeenAt(state, sessionId) {
3326
3398
  return state.sessionReads?.[sessionId] || 0;
@@ -3372,7 +3444,9 @@ function upsertSavedProviderSession(state, entry) {
3372
3444
  providerName: entry.providerName,
3373
3445
  providerSessionId,
3374
3446
  workspace: entry.workspace ? normalizeWorkspace2(entry.workspace) : void 0,
3375
- currentModel: entry.currentModel,
3447
+ summaryMetadata: normalizePersistedSummaryMetadata({
3448
+ summaryMetadata: entry.summaryMetadata
3449
+ }),
3376
3450
  title: entry.title,
3377
3451
  createdAt: existing?.createdAt || entry.createdAt || Date.now(),
3378
3452
  lastUsedAt: entry.lastUsedAt || Date.now()
@@ -3388,7 +3462,12 @@ function getSavedProviderSessions(state, filters) {
3388
3462
  if (filters?.providerType && entry.providerType !== filters.providerType) return false;
3389
3463
  if (filters?.kind && entry.kind !== filters.kind) return false;
3390
3464
  return true;
3391
- }).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
3465
+ }).map((entry) => ({
3466
+ ...entry,
3467
+ summaryMetadata: normalizePersistedSummaryMetadata({
3468
+ summaryMetadata: entry.summaryMetadata
3469
+ })
3470
+ })).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
3392
3471
  }
3393
3472
 
3394
3473
  // src/config/state-store.ts
@@ -5145,8 +5224,6 @@ function extractProviderControlValues(controls, data) {
5145
5224
  if (rawValue === void 0 || rawValue === null) continue;
5146
5225
  values[ctrl.id] = normalizeControlValue(rawValue);
5147
5226
  }
5148
- if (data.model !== void 0 && values.model === void 0) values.model = normalizeControlValue(data.model);
5149
- if (data.mode !== void 0 && values.mode === void 0) values.mode = normalizeControlValue(data.mode);
5150
5227
  return Object.keys(values).length > 0 ? values : void 0;
5151
5228
  }
5152
5229
  function normalizeProviderEffects(data) {
@@ -5248,7 +5325,7 @@ function normalizeControlOption(option) {
5248
5325
  }
5249
5326
  if (!option || typeof option !== "object") return null;
5250
5327
  const record = option;
5251
- const value = typeof record.value === "string" ? record.value : typeof record.id === "string" ? record.id : null;
5328
+ const value = typeof record.value === "string" ? record.value : typeof record.id === "string" ? record.id : typeof record.name === "string" ? record.name : null;
5252
5329
  if (!value) return null;
5253
5330
  const label = typeof record.label === "string" ? record.label : typeof record.name === "string" ? record.name : value;
5254
5331
  const normalized = { value, label };
@@ -5783,6 +5860,61 @@ function listSavedHistorySessions(agentType, options = {}) {
5783
5860
  }
5784
5861
  }
5785
5862
 
5863
+ // src/providers/provider-patch-state.ts
5864
+ function isControlValue(value) {
5865
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
5866
+ }
5867
+ function asControlValueMap(value) {
5868
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
5869
+ const result = {};
5870
+ for (const [entryKey, entryValue] of Object.entries(value)) {
5871
+ if (isControlValue(entryValue)) result[entryKey] = entryValue;
5872
+ }
5873
+ return Object.keys(result).length > 0 ? result : void 0;
5874
+ }
5875
+ function getLegacyModelModeValues(data) {
5876
+ if (!data || typeof data !== "object") return void 0;
5877
+ const legacy = {};
5878
+ if (typeof data.model === "string" && data.model.trim()) legacy.model = data.model.trim();
5879
+ if (typeof data.mode === "string" && data.mode.trim()) legacy.mode = data.mode.trim();
5880
+ return Object.keys(legacy).length > 0 ? legacy : void 0;
5881
+ }
5882
+ function mergeProviderPatchState(params) {
5883
+ const {
5884
+ providerControls,
5885
+ data,
5886
+ currentControlValues,
5887
+ currentSummaryMetadata,
5888
+ mergeWithCurrent = true
5889
+ } = params;
5890
+ const sources = [
5891
+ mergeWithCurrent ? asControlValueMap(currentControlValues) : void 0,
5892
+ asControlValueMap(data?.controlValues),
5893
+ asControlValueMap(extractProviderControlValues(providerControls, data)),
5894
+ getLegacyModelModeValues(data)
5895
+ ];
5896
+ const controlValues = Object.assign({}, ...sources.filter(Boolean));
5897
+ return {
5898
+ controlValues,
5899
+ summaryMetadata: data?.summaryMetadata !== void 0 ? data.summaryMetadata : currentSummaryMetadata
5900
+ };
5901
+ }
5902
+ function normalizeProviderStateControlValues(controlValues) {
5903
+ return controlValues && Object.keys(controlValues).length > 0 ? controlValues : void 0;
5904
+ }
5905
+ function resolveProviderStateSurface(params) {
5906
+ const controlValues = normalizeProviderStateControlValues(params.controlValues);
5907
+ return {
5908
+ controlValues,
5909
+ summaryMetadata: resolveProviderStateSummaryMetadata({
5910
+ summaryMetadata: params.summaryMetadata,
5911
+ controlValues,
5912
+ modelLabel: params.modelLabel,
5913
+ modeLabel: params.modeLabel
5914
+ })
5915
+ };
5916
+ }
5917
+
5786
5918
  // src/providers/extension-provider-instance.ts
5787
5919
  var ExtensionProviderInstance = class {
5788
5920
  type;
@@ -5797,9 +5929,8 @@ var ExtensionProviderInstance = class {
5797
5929
  messages = [];
5798
5930
  prevMessageHashes = /* @__PURE__ */ new Map();
5799
5931
  activeModal = null;
5800
- currentModel = "";
5801
- currentMode = "";
5802
5932
  controlValues = {};
5933
+ summaryMetadata = void 0;
5803
5934
  appliedEffectKeys = /* @__PURE__ */ new Set();
5804
5935
  runtimeMessages = [];
5805
5936
  lastAgentStatus = "idle";
@@ -5834,6 +5965,10 @@ var ExtensionProviderInstance = class {
5834
5965
  if (!this.context?.cdp?.isConnected) return;
5835
5966
  }
5836
5967
  getState() {
5968
+ const surface = resolveProviderStateSurface({
5969
+ summaryMetadata: this.summaryMetadata,
5970
+ controlValues: this.controlValues
5971
+ });
5837
5972
  return {
5838
5973
  type: this.type,
5839
5974
  name: this.provider.name,
@@ -5847,10 +5982,9 @@ var ExtensionProviderInstance = class {
5847
5982
  activeModal: this.activeModal,
5848
5983
  inputContent: ""
5849
5984
  } : null,
5850
- currentModel: this.currentModel || void 0,
5851
- currentPlan: this.currentMode || void 0,
5852
- controlValues: this.controlValues,
5985
+ controlValues: surface.controlValues,
5853
5986
  providerControls: this.provider.controls,
5987
+ summaryMetadata: surface.summaryMetadata,
5854
5988
  agentStreams: this.agentStreams,
5855
5989
  instanceId: this.instanceId,
5856
5990
  lastUpdated: Date.now(),
@@ -5863,10 +5997,14 @@ var ExtensionProviderInstance = class {
5863
5997
  if (data?.streams) this.agentStreams = data.streams;
5864
5998
  if (data?.messages) this.messages = this.assignReceivedAt(data.messages);
5865
5999
  if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
5866
- if (data?.model) this.currentModel = data.model;
5867
- if (data?.mode) this.currentMode = data.mode;
5868
- const controlValues = extractProviderControlValues(this.provider.controls, data) || data?.controlValues;
5869
- if (controlValues) this.controlValues = controlValues;
6000
+ const patchedState = mergeProviderPatchState({
6001
+ providerControls: this.provider.controls,
6002
+ data,
6003
+ currentControlValues: this.controlValues,
6004
+ currentSummaryMetadata: this.summaryMetadata
6005
+ });
6006
+ this.controlValues = patchedState.controlValues;
6007
+ this.summaryMetadata = patchedState.summaryMetadata;
5870
6008
  if (typeof data?.sessionId === "string" && data.sessionId.trim()) this.chatId = data.sessionId;
5871
6009
  if (typeof data?.title === "string" && data.title.trim()) this.chatTitle = data.title;
5872
6010
  if (typeof data?.agentName === "string" && data.agentName.trim()) this.agentName = data.agentName;
@@ -5967,8 +6105,14 @@ var ExtensionProviderInstance = class {
5967
6105
  }
5968
6106
  applyProviderResponse(data, options) {
5969
6107
  if (!data || typeof data !== "object") return;
5970
- const controlValues = extractProviderControlValues(this.provider.controls, data);
5971
- if (controlValues) this.controlValues = { ...this.controlValues, ...controlValues };
6108
+ const patchedState = mergeProviderPatchState({
6109
+ providerControls: this.provider.controls,
6110
+ data,
6111
+ currentControlValues: this.controlValues,
6112
+ currentSummaryMetadata: this.summaryMetadata
6113
+ });
6114
+ this.controlValues = patchedState.controlValues;
6115
+ this.summaryMetadata = patchedState.summaryMetadata;
5972
6116
  const effects = normalizeProviderEffects(data);
5973
6117
  for (const effect of effects) {
5974
6118
  const effectWhen = effect.when || "immediate";
@@ -6118,8 +6262,6 @@ ${effect.notification.body || ""}`.trim();
6118
6262
  this.messages = [];
6119
6263
  this.prevMessageHashes.clear();
6120
6264
  this.activeModal = null;
6121
- this.currentModel = "";
6122
- this.currentMode = "";
6123
6265
  this.controlValues = {};
6124
6266
  this.currentStatus = "idle";
6125
6267
  this.chatId = null;
@@ -6255,6 +6397,10 @@ var IdeProviderInstance = class {
6255
6397
  for (const ext of this.extensions.values()) {
6256
6398
  extensionStates.push(ext.getState());
6257
6399
  }
6400
+ const surface = resolveProviderStateSurface({
6401
+ summaryMetadata: this.cachedChat?.summaryMetadata,
6402
+ controlValues: this.cachedChat?.controlValues
6403
+ });
6258
6404
  return {
6259
6405
  type: this.type,
6260
6406
  name: this.provider.name,
@@ -6271,11 +6417,9 @@ var IdeProviderInstance = class {
6271
6417
  workspace: this.workspace || null,
6272
6418
  extensions: extensionStates,
6273
6419
  cdpConnected: cdp?.isConnected || false,
6274
- currentModel: this.cachedChat?.model || void 0,
6275
- currentPlan: this.cachedChat?.mode || void 0,
6276
- currentAutoApprove: this.cachedChat?.autoApprove || void 0,
6277
- controlValues: this.cachedChat?.controlValues || void 0,
6420
+ controlValues: surface.controlValues,
6278
6421
  providerControls: this.provider.controls,
6422
+ summaryMetadata: surface.summaryMetadata,
6279
6423
  instanceId: this.instanceId,
6280
6424
  lastUpdated: Date.now(),
6281
6425
  settings: this.settings,
@@ -6447,8 +6591,13 @@ var IdeProviderInstance = class {
6447
6591
  chat.messages = messages.filter((m) => !hiddenKinds.has(m.kind || ""));
6448
6592
  }
6449
6593
  }
6450
- const controlValues = extractProviderControlValues(this.provider.controls, chat);
6451
- if (controlValues) chat.controlValues = controlValues;
6594
+ const patchedState = mergeProviderPatchState({
6595
+ providerControls: this.provider.controls,
6596
+ data: chat,
6597
+ mergeWithCurrent: false
6598
+ });
6599
+ chat.controlValues = Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0;
6600
+ chat.summaryMetadata = patchedState.summaryMetadata;
6452
6601
  this.cachedChat = { ...chat, activeModal };
6453
6602
  this.detectAgentTransitions(chat, now);
6454
6603
  const persistedMessages = chat.messages || messages;
@@ -6535,14 +6684,18 @@ var IdeProviderInstance = class {
6535
6684
  }
6536
6685
  applyProviderResponse(data, options) {
6537
6686
  if (!data || typeof data !== "object") return;
6538
- const controlValues = extractProviderControlValues(this.provider.controls, data);
6539
- if (controlValues) {
6540
- this.cachedChat = {
6541
- ...this.cachedChat || {},
6542
- ...data,
6543
- controlValues: { ...this.cachedChat?.controlValues || {}, ...controlValues }
6544
- };
6545
- }
6687
+ const patchedState = mergeProviderPatchState({
6688
+ providerControls: this.provider.controls,
6689
+ data,
6690
+ currentControlValues: this.cachedChat?.controlValues,
6691
+ currentSummaryMetadata: this.cachedChat?.summaryMetadata
6692
+ });
6693
+ this.cachedChat = {
6694
+ ...this.cachedChat || {},
6695
+ ...data,
6696
+ controlValues: Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0,
6697
+ summaryMetadata: patchedState.summaryMetadata
6698
+ };
6546
6699
  const effects = normalizeProviderEffects(data);
6547
6700
  for (const effect of effects) {
6548
6701
  const effectWhen = effect.when || "immediate";
@@ -7325,6 +7478,8 @@ var ACP_SESSION_CAPABILITIES = [
7325
7478
  function buildIdeWorkspaceSession(state, cdpManagers, options) {
7326
7479
  const profile = options.profile || "full";
7327
7480
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
7481
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
7482
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
7328
7483
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
7329
7484
  const includeSessionControls = shouldIncludeSessionControls(profile);
7330
7485
  const title = activeChat?.title || state.name;
@@ -7341,13 +7496,11 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
7341
7496
  title,
7342
7497
  ...includeSessionMetadata && { workspace: state.workspace || null },
7343
7498
  activeChat,
7499
+ ...summaryMetadata && { summaryMetadata },
7344
7500
  ...includeSessionMetadata && { capabilities: IDE_SESSION_CAPABILITIES },
7345
7501
  cdpConnected: state.cdpConnected ?? isCdpConnected(cdpManagers, state.type),
7346
- currentModel: state.currentModel,
7347
- currentPlan: state.currentPlan,
7348
- currentAutoApprove: state.currentAutoApprove,
7349
7502
  ...includeSessionControls && {
7350
- controlValues: state.controlValues,
7503
+ ...controlValues && { controlValues },
7351
7504
  providerControls: state.providerControls
7352
7505
  },
7353
7506
  errorMessage: state.errorMessage,
@@ -7358,6 +7511,8 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
7358
7511
  function buildExtensionAgentSession(parent, ext, options) {
7359
7512
  const profile = options.profile || "full";
7360
7513
  const activeChat = normalizeActiveChatData(ext.activeChat, getActiveChatOptions(profile));
7514
+ const summaryMetadata = normalizeProviderSummaryMetadata(ext.summaryMetadata);
7515
+ const controlValues = normalizeProviderStateControlValues(ext.controlValues);
7361
7516
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
7362
7517
  const includeSessionControls = shouldIncludeSessionControls(profile);
7363
7518
  return {
@@ -7373,11 +7528,10 @@ function buildExtensionAgentSession(parent, ext, options) {
7373
7528
  title: activeChat?.title || ext.name,
7374
7529
  ...includeSessionMetadata && { workspace: parent.workspace || null },
7375
7530
  activeChat,
7531
+ ...summaryMetadata && { summaryMetadata },
7376
7532
  ...includeSessionMetadata && { capabilities: EXTENSION_SESSION_CAPABILITIES },
7377
- currentModel: ext.currentModel,
7378
- currentPlan: ext.currentPlan,
7379
7533
  ...includeSessionControls && {
7380
- controlValues: ext.controlValues,
7534
+ ...controlValues && { controlValues },
7381
7535
  providerControls: ext.providerControls
7382
7536
  },
7383
7537
  errorMessage: ext.errorMessage,
@@ -7388,6 +7542,8 @@ function buildExtensionAgentSession(parent, ext, options) {
7388
7542
  function buildCliSession(state, options) {
7389
7543
  const profile = options.profile || "full";
7390
7544
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
7545
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
7546
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
7391
7547
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
7392
7548
  const includeRuntimeMetadata = shouldIncludeRuntimeMetadata(profile);
7393
7549
  const includeSessionControls = shouldIncludeSessionControls(profile);
@@ -7414,11 +7570,12 @@ function buildCliSession(state, options) {
7414
7570
  mode: state.mode,
7415
7571
  resume: state.resume,
7416
7572
  activeChat,
7573
+ ...summaryMetadata && { summaryMetadata },
7417
7574
  ...includeSessionMetadata && {
7418
7575
  capabilities: state.mode === "terminal" ? PTY_SESSION_CAPABILITIES : CLI_CHAT_SESSION_CAPABILITIES
7419
7576
  },
7420
7577
  ...includeSessionControls && {
7421
- controlValues: state.controlValues,
7578
+ ...controlValues && { controlValues },
7422
7579
  providerControls: state.providerControls
7423
7580
  },
7424
7581
  errorMessage: state.errorMessage,
@@ -7429,6 +7586,8 @@ function buildCliSession(state, options) {
7429
7586
  function buildAcpSession(state, options) {
7430
7587
  const profile = options.profile || "full";
7431
7588
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
7589
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
7590
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
7432
7591
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
7433
7592
  const includeSessionControls = shouldIncludeSessionControls(profile);
7434
7593
  return {
@@ -7444,13 +7603,10 @@ function buildAcpSession(state, options) {
7444
7603
  title: activeChat?.title || state.name,
7445
7604
  ...includeSessionMetadata && { workspace: state.workspace || null },
7446
7605
  activeChat,
7606
+ ...summaryMetadata && { summaryMetadata },
7447
7607
  ...includeSessionMetadata && { capabilities: ACP_SESSION_CAPABILITIES },
7448
- currentModel: state.currentModel,
7449
- currentPlan: state.currentPlan,
7450
7608
  ...includeSessionControls && {
7451
- acpConfigOptions: state.acpConfigOptions,
7452
- acpModes: state.acpModes,
7453
- controlValues: state.controlValues,
7609
+ ...controlValues && { controlValues },
7454
7610
  providerControls: state.providerControls
7455
7611
  },
7456
7612
  errorMessage: state.errorMessage,
@@ -9510,8 +9666,17 @@ async function handleSetProviderSourceConfig(h, args) {
9510
9666
  );
9511
9667
  return { success: true, reloaded: true, ...sourceConfig };
9512
9668
  }
9513
- function normalizeProviderScriptArgs(args) {
9669
+ function normalizeProviderScriptArgs(args, scriptName) {
9514
9670
  const normalizedArgs = { ...args || {} };
9671
+ const normalizedScriptName = String(scriptName || "").toLowerCase();
9672
+ if (Object.prototype.hasOwnProperty.call(normalizedArgs, "value")) {
9673
+ if (normalizedArgs.model === void 0 && (normalizedScriptName === "setmodel" || normalizedScriptName === "setmodelgui" || normalizedScriptName === "webviewsetmodel")) {
9674
+ normalizedArgs.model = normalizedArgs.value;
9675
+ }
9676
+ if (normalizedArgs.mode === void 0 && (normalizedScriptName === "setmode" || normalizedScriptName === "webviewsetmode")) {
9677
+ normalizedArgs.mode = normalizedArgs.value;
9678
+ }
9679
+ }
9515
9680
  for (const key of ["mode", "model", "message", "action", "button", "text", "sessionId", "value"]) {
9516
9681
  if (key in normalizedArgs && !(key.toUpperCase() in normalizedArgs)) {
9517
9682
  normalizedArgs[key.toUpperCase()] = normalizedArgs[key];
@@ -9557,7 +9722,7 @@ async function executeProviderScript(h, args, scriptName) {
9557
9722
  if (!provider.scripts?.[actualScriptName]) {
9558
9723
  return { success: false, error: `Script '${actualScriptName}' not available for ${resolvedProviderType}` };
9559
9724
  }
9560
- const normalizedArgs = normalizeProviderScriptArgs(args);
9725
+ const normalizedArgs = normalizeProviderScriptArgs(args, actualScriptName);
9561
9726
  if (provider.category === "cli") {
9562
9727
  const adapter = h.getCliAdapter(args?.targetSessionId || resolvedProviderType);
9563
9728
  if (!adapter?.invokeScript) {
@@ -10418,6 +10583,7 @@ var CliProviderInstance = class {
10418
10583
  generatingDebouncePending = null;
10419
10584
  lastApprovalEventAt = 0;
10420
10585
  controlValues = {};
10586
+ summaryMetadata = void 0;
10421
10587
  appliedEffectKeys = /* @__PURE__ */ new Set();
10422
10588
  historyWriter;
10423
10589
  runtimeMessages = [];
@@ -10560,13 +10726,7 @@ var CliProviderInstance = class {
10560
10726
  if (historyMessageCount !== null) {
10561
10727
  parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
10562
10728
  }
10563
- const controlValues = extractProviderControlValues(this.provider.controls, parsedStatus);
10564
- if (controlValues) {
10565
- this.controlValues = { ...this.controlValues, ...controlValues };
10566
- }
10567
10729
  const mergedMessages = this.mergeConversationMessages(parsedMessages);
10568
- 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;
10569
- 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;
10570
10730
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
10571
10731
  if (parsedMessages.length > 0) {
10572
10732
  const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
@@ -10588,6 +10748,10 @@ var CliProviderInstance = class {
10588
10748
  }
10589
10749
  }
10590
10750
  this.applyProviderResponse(parsedStatus, { phase: "immediate" });
10751
+ const surface = resolveProviderStateSurface({
10752
+ summaryMetadata: this.summaryMetadata,
10753
+ controlValues: this.controlValues
10754
+ });
10591
10755
  return {
10592
10756
  type: this.type,
10593
10757
  name: this.provider.name,
@@ -10603,8 +10767,6 @@ var CliProviderInstance = class {
10603
10767
  inputContent: ""
10604
10768
  },
10605
10769
  workspace: this.workingDir,
10606
- currentModel,
10607
- currentPlan,
10608
10770
  instanceId: this.instanceId,
10609
10771
  providerSessionId: this.providerSessionId,
10610
10772
  lastUpdated: Date.now(),
@@ -10619,8 +10781,9 @@ var CliProviderInstance = class {
10619
10781
  attachedClients: runtime.attachedClients || []
10620
10782
  } : void 0,
10621
10783
  resume: this.provider.resume,
10622
- controlValues: this.controlValues,
10623
- providerControls: this.provider.controls
10784
+ controlValues: surface.controlValues,
10785
+ providerControls: this.provider.controls,
10786
+ summaryMetadata: surface.summaryMetadata
10624
10787
  };
10625
10788
  }
10626
10789
  setPresentationMode(mode) {
@@ -10824,10 +10987,14 @@ var CliProviderInstance = class {
10824
10987
  this.suppressIdleHistoryReplay = false;
10825
10988
  this.adapter.clearHistory();
10826
10989
  }
10827
- const controlValues = extractProviderControlValues(this.provider.controls, data);
10828
- if (controlValues) {
10829
- this.controlValues = { ...this.controlValues, ...controlValues };
10830
- }
10990
+ const patchedState = mergeProviderPatchState({
10991
+ providerControls: this.provider.controls,
10992
+ data,
10993
+ currentControlValues: this.controlValues,
10994
+ currentSummaryMetadata: this.summaryMetadata
10995
+ });
10996
+ this.controlValues = patchedState.controlValues;
10997
+ this.summaryMetadata = patchedState.summaryMetadata;
10831
10998
  const effects = normalizeProviderEffects(data);
10832
10999
  for (const effect of effects) {
10833
11000
  const effectWhen = effect.when || "immediate";
@@ -11193,8 +11360,7 @@ var AcpProviderInstance = class {
11193
11360
  lastStatus = "starting";
11194
11361
  generatingStartedAt = 0;
11195
11362
  agentCapabilities = {};
11196
- currentModel;
11197
- currentMode;
11363
+ currentSelections = {};
11198
11364
  activeToolCalls = [];
11199
11365
  stopReason = null;
11200
11366
  partialContent = "";
@@ -11274,8 +11440,6 @@ var AcpProviderInstance = class {
11274
11440
  inputContent: ""
11275
11441
  },
11276
11442
  workspace: this.workingDir,
11277
- currentModel: this.currentModel,
11278
- currentPlan: this.currentMode,
11279
11443
  instanceId: this.instanceId,
11280
11444
  lastUpdated: Date.now(),
11281
11445
  settings: this.settings,
@@ -11286,11 +11450,9 @@ var AcpProviderInstance = class {
11286
11450
  // Error details for dashboard display
11287
11451
  errorMessage: this.errorMessage || void 0,
11288
11452
  errorReason: this.errorReason || void 0,
11289
- controlValues: {
11290
- ...this.currentModel ? { model: this.currentModel } : {},
11291
- ...this.currentMode ? { mode: this.currentMode } : {}
11292
- },
11293
- providerControls: this.provider.controls
11453
+ controlValues: this.getSelectionControlValues(),
11454
+ providerControls: this.provider.controls,
11455
+ summaryMetadata: this.buildSelectionSummaryMetadata()
11294
11456
  };
11295
11457
  }
11296
11458
  onEvent(event, data) {
@@ -11324,6 +11486,54 @@ var AcpProviderInstance = class {
11324
11486
  getInstanceId() {
11325
11487
  return this.instanceId;
11326
11488
  }
11489
+ resolveConfigOptionLabel(category, value) {
11490
+ if (!value) return void 0;
11491
+ const option = this.configOptions.find((entry) => entry.category === category);
11492
+ return option?.options.find((candidate) => candidate.value === value)?.name || value;
11493
+ }
11494
+ resolveModeLabel(modeId) {
11495
+ if (!modeId) return void 0;
11496
+ return this.availableModes.find((mode) => mode.id === modeId)?.name || modeId;
11497
+ }
11498
+ getCurrentSelection(category) {
11499
+ return this.currentSelections[category];
11500
+ }
11501
+ setCurrentSelection(category, value) {
11502
+ const normalized = typeof value === "string" ? value.trim() : "";
11503
+ if (normalized) {
11504
+ this.currentSelections[category] = normalized;
11505
+ return;
11506
+ }
11507
+ delete this.currentSelections[category];
11508
+ }
11509
+ getSelectionControlValues() {
11510
+ const model = this.getCurrentSelection("model");
11511
+ const mode = this.getCurrentSelection("mode");
11512
+ return {
11513
+ ...model ? { model } : {},
11514
+ ...mode ? { mode } : {}
11515
+ };
11516
+ }
11517
+ resolveSelectionLabel(category, value) {
11518
+ if (!value) return void 0;
11519
+ const configLabel = this.resolveConfigOptionLabel(category, value);
11520
+ if (configLabel && configLabel !== value) return configLabel;
11521
+ if (category === "mode") {
11522
+ const modeLabel = this.resolveModeLabel(value);
11523
+ if (modeLabel) return modeLabel;
11524
+ }
11525
+ return configLabel || value;
11526
+ }
11527
+ buildSelectionSummaryMetadata() {
11528
+ const model = this.getCurrentSelection("model");
11529
+ const mode = this.getCurrentSelection("mode");
11530
+ return buildLegacyModelModeSummaryMetadata({
11531
+ model,
11532
+ mode,
11533
+ modelLabel: this.resolveSelectionLabel("model", model),
11534
+ modeLabel: this.resolveSelectionLabel("mode", mode)
11535
+ });
11536
+ }
11327
11537
  // ─── ACP Config Options & Modes ─────────────────────
11328
11538
  parseConfigOptions(raw) {
11329
11539
  if (!Array.isArray(raw)) return;
@@ -11355,12 +11565,14 @@ var AcpProviderInstance = class {
11355
11565
  }
11356
11566
  }
11357
11567
  this.configOptions.push({ category, configId, currentValue, options: flatOptions });
11358
- if (category === "model" && currentValue) this.currentModel = currentValue;
11568
+ if (category === "model" || category === "mode") {
11569
+ this.setCurrentSelection(category, currentValue);
11570
+ }
11359
11571
  }
11360
11572
  }
11361
11573
  parseModes(raw) {
11362
11574
  if (!raw) return;
11363
- if (raw.currentModeId) this.currentMode = raw.currentModeId;
11575
+ this.setCurrentSelection("mode", raw.currentModeId);
11364
11576
  if (Array.isArray(raw.availableModes)) {
11365
11577
  this.availableModes = raw.availableModes.map((m) => ({
11366
11578
  id: m.id,
@@ -11379,8 +11591,7 @@ var AcpProviderInstance = class {
11379
11591
  if (this.useStaticConfig) {
11380
11592
  opt.currentValue = value;
11381
11593
  this.selectedConfig[opt.configId] = value;
11382
- if (category === "model") this.currentModel = value;
11383
- if (category === "mode") this.currentMode = value;
11594
+ if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
11384
11595
  this.log.info(`[${this.type}] Static config ${category} set to: ${value} \u2014 restarting agent`);
11385
11596
  await this.restartWithNewConfig();
11386
11597
  return;
@@ -11398,7 +11609,7 @@ var AcpProviderInstance = class {
11398
11609
  value
11399
11610
  });
11400
11611
  opt.currentValue = value;
11401
- if (category === "model") this.currentModel = value;
11612
+ if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
11402
11613
  if (result?.configOptions) this.parseConfigOptions(result.configOptions);
11403
11614
  this.log.info(`[${this.type}] Config ${category} set to: ${value} | response: ${JSON.stringify(result)?.slice(0, 300)}`);
11404
11615
  } catch (e) {
@@ -11414,7 +11625,7 @@ var AcpProviderInstance = class {
11414
11625
  opt.currentValue = modeId;
11415
11626
  this.selectedConfig[opt.configId] = modeId;
11416
11627
  }
11417
- this.currentMode = modeId;
11628
+ this.setCurrentSelection("mode", modeId);
11418
11629
  this.log.info(`[${this.type}] Static mode set to: ${modeId} \u2014 restarting agent`);
11419
11630
  await this.restartWithNewConfig();
11420
11631
  return;
@@ -11429,7 +11640,7 @@ var AcpProviderInstance = class {
11429
11640
  sessionId: this.sessionId,
11430
11641
  modeId
11431
11642
  });
11432
- this.currentMode = modeId;
11643
+ this.setCurrentSelection("mode", modeId);
11433
11644
  this.log.info(`[${this.type}] Mode set to: ${modeId}`);
11434
11645
  } catch (e) {
11435
11646
  const message = e?.message || "Unknown ACP mode error";
@@ -11687,8 +11898,8 @@ var AcpProviderInstance = class {
11687
11898
  if (result?.modes) this.log.debug(`[${this.type}] modes: ${JSON.stringify(result.modes).slice(0, 300)}`);
11688
11899
  this.parseConfigOptions(result?.configOptions);
11689
11900
  this.parseModes(result?.modes);
11690
- if (!this.currentModel && result?.models?.currentModelId) {
11691
- this.currentModel = result.models.currentModelId;
11901
+ if (!this.getCurrentSelection("model") && result?.models?.currentModelId) {
11902
+ this.setCurrentSelection("model", result.models.currentModelId);
11692
11903
  }
11693
11904
  if (this.configOptions.length === 0 && this.provider.staticConfigOptions?.length) {
11694
11905
  this.useStaticConfig = true;
@@ -11702,13 +11913,16 @@ var AcpProviderInstance = class {
11702
11913
  });
11703
11914
  if (defaultVal) {
11704
11915
  this.selectedConfig[sc.configId] = defaultVal;
11705
- if (sc.category === "model") this.currentModel = defaultVal;
11706
- if (sc.category === "mode") this.currentMode = defaultVal;
11916
+ if (sc.category === "model" || sc.category === "mode") {
11917
+ this.setCurrentSelection(sc.category, defaultVal);
11918
+ }
11707
11919
  }
11708
11920
  }
11709
11921
  this.log.info(`[${this.type}] Using static configOptions (${this.configOptions.length} options)`);
11710
11922
  }
11711
- this.log.info(`[${this.type}] Session created: ${this.sessionId}${this.currentModel ? ` (model: ${this.currentModel})` : ""}${this.currentMode ? ` (mode: ${this.currentMode})` : ""}`);
11923
+ const currentModel = this.getCurrentSelection("model");
11924
+ const currentMode = this.getCurrentSelection("mode");
11925
+ this.log.info(`[${this.type}] Session created: ${this.sessionId}${currentModel ? ` (model: ${currentModel})` : ""}${currentMode ? ` (mode: ${currentMode})` : ""}`);
11712
11926
  if (this.configOptions.length > 0) {
11713
11927
  this.log.info(`[${this.type}] Config options: ${this.configOptions.map((c) => `${c.category}(${c.options.length})`).join(", ")}`);
11714
11928
  }
@@ -11883,7 +12097,7 @@ var AcpProviderInstance = class {
11883
12097
  break;
11884
12098
  }
11885
12099
  case "current_mode_update": {
11886
- this.currentMode = update.currentModeId;
12100
+ this.setCurrentSelection("mode", update.currentModeId);
11887
12101
  break;
11888
12102
  }
11889
12103
  case "config_option_update": {
@@ -11956,7 +12170,7 @@ var AcpProviderInstance = class {
11956
12170
  this.detectStatusTransition();
11957
12171
  }
11958
12172
  if (params.model) {
11959
- this.currentModel = params.model;
12173
+ this.setCurrentSelection("model", params.model);
11960
12174
  }
11961
12175
  }
11962
12176
  /** Map SDK ToolCallStatus to internal status */
@@ -12245,7 +12459,11 @@ var DaemonCliManager = class {
12245
12459
  }
12246
12460
  persistRecentActivity(entry) {
12247
12461
  try {
12248
- let nextState = appendRecentActivity(loadState(), entry);
12462
+ const summaryMetadata = normalizeProviderSummaryMetadata(entry.summaryMetadata);
12463
+ let nextState = appendRecentActivity(loadState(), {
12464
+ ...entry,
12465
+ summaryMetadata
12466
+ });
12249
12467
  if (entry.providerSessionId && (entry.kind === "cli" || entry.kind === "acp")) {
12250
12468
  nextState = upsertSavedProviderSession(nextState, {
12251
12469
  kind: entry.kind,
@@ -12253,7 +12471,7 @@ var DaemonCliManager = class {
12253
12471
  providerName: entry.providerName,
12254
12472
  providerSessionId: entry.providerSessionId,
12255
12473
  workspace: entry.workspace,
12256
- currentModel: entry.currentModel,
12474
+ summaryMetadata,
12257
12475
  title: entry.title
12258
12476
  });
12259
12477
  }
@@ -12443,7 +12661,7 @@ ${installInfo}`
12443
12661
  providerType: normalizedType,
12444
12662
  providerName: provider.displayName || provider.name || normalizedType,
12445
12663
  workspace: resolvedDir,
12446
- currentModel: initialModel,
12664
+ summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
12447
12665
  sessionId,
12448
12666
  title: provider.displayName || provider.name || normalizedType
12449
12667
  });
@@ -12545,7 +12763,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
12545
12763
  providerName: provider?.displayName || provider?.name || normalizedType,
12546
12764
  providerSessionId: sessionBinding.providerSessionId,
12547
12765
  workspace: resolvedDir,
12548
- currentModel: initialModel,
12766
+ summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
12549
12767
  sessionId: key,
12550
12768
  title: provider?.displayName || provider?.name || normalizedType
12551
12769
  });
@@ -14710,12 +14928,90 @@ cleanOldFiles();
14710
14928
  // src/commands/router.ts
14711
14929
  init_logger();
14712
14930
 
14931
+ // src/session-host/runtime-surface.ts
14932
+ var LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
14933
+ function isSessionHostLiveRuntime(record) {
14934
+ const lifecycle = String(record?.lifecycle || "").trim();
14935
+ return LIVE_LIFECYCLES.has(lifecycle);
14936
+ }
14937
+ function getSessionHostRecoveryLabel(meta) {
14938
+ const recoveryState = typeof meta?.runtimeRecoveryState === "string" ? String(meta.runtimeRecoveryState).trim() : "";
14939
+ if (!recoveryState) return null;
14940
+ if (recoveryState === "auto_resumed") return "restored after restart";
14941
+ if (recoveryState === "resume_failed") return "restore failed";
14942
+ if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
14943
+ if (recoveryState === "orphan_snapshot") return "snapshot recovered";
14944
+ return recoveryState.replace(/_/g, " ");
14945
+ }
14946
+ function isSessionHostRecoverySnapshot(record) {
14947
+ if (!record) return false;
14948
+ if (isSessionHostLiveRuntime(record)) return false;
14949
+ const lifecycle = String(record.lifecycle || "").trim();
14950
+ if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
14951
+ return false;
14952
+ }
14953
+ const meta = record.meta || void 0;
14954
+ if (meta?.restoredFromStorage === true) return true;
14955
+ return getSessionHostRecoveryLabel(meta) !== null;
14956
+ }
14957
+ function getSessionHostSurfaceKind(record) {
14958
+ if (isSessionHostLiveRuntime(record)) return "live_runtime";
14959
+ if (isSessionHostRecoverySnapshot(record)) return "recovery_snapshot";
14960
+ return "inactive_record";
14961
+ }
14962
+ function partitionSessionHostRecords(records) {
14963
+ const liveRuntimes = [];
14964
+ const recoverySnapshots = [];
14965
+ const inactiveRecords = [];
14966
+ for (const record of records) {
14967
+ const kind = getSessionHostSurfaceKind(record);
14968
+ if (kind === "live_runtime") {
14969
+ liveRuntimes.push(record);
14970
+ } else if (kind === "recovery_snapshot") {
14971
+ recoverySnapshots.push(record);
14972
+ } else {
14973
+ inactiveRecords.push(record);
14974
+ }
14975
+ }
14976
+ return {
14977
+ liveRuntimes,
14978
+ recoverySnapshots,
14979
+ inactiveRecords
14980
+ };
14981
+ }
14982
+ function partitionSessionHostDiagnosticsSessions(records) {
14983
+ return partitionSessionHostRecords(records || []);
14984
+ }
14985
+
14713
14986
  // src/status/snapshot.ts
14714
14987
  var os16 = __toESM(require("os"));
14715
14988
  init_config();
14716
14989
  init_terminal_screen();
14717
14990
  init_logger();
14718
14991
  var READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
14992
+ var recentReadDebugSignatureBySession = /* @__PURE__ */ new Map();
14993
+ function buildRecentReadDebugSignature(snapshot) {
14994
+ return [
14995
+ snapshot.providerType,
14996
+ snapshot.status,
14997
+ snapshot.inboxBucket,
14998
+ snapshot.unread ? "1" : "0",
14999
+ String(snapshot.lastSeenAt),
15000
+ snapshot.completionMarker,
15001
+ snapshot.seenCompletionMarker,
15002
+ String(snapshot.lastUpdated),
15003
+ String(snapshot.lastUsedAt),
15004
+ snapshot.lastRole,
15005
+ String(snapshot.messageUpdatedAt)
15006
+ ].join("|");
15007
+ }
15008
+ function shouldEmitRecentReadDebugLog(cache, snapshot) {
15009
+ const nextSignature = buildRecentReadDebugSignature(snapshot);
15010
+ const previousSignature = cache.get(snapshot.sessionId);
15011
+ if (previousSignature === nextSignature) return false;
15012
+ cache.set(snapshot.sessionId, nextSignature);
15013
+ return true;
15014
+ }
14719
15015
  function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
14720
15016
  return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
14721
15017
  id: ide.id,
@@ -14867,7 +15163,7 @@ function buildRecentLaunches(recentActivity) {
14867
15163
  providerSessionId: item.providerSessionId,
14868
15164
  title: item.title || item.providerName,
14869
15165
  workspace: item.workspace,
14870
- currentModel: item.currentModel,
15166
+ summaryMetadata: item.summaryMetadata,
14871
15167
  lastLaunchedAt: item.lastUsedAt
14872
15168
  })).sort((a, b) => b.lastLaunchedAt - a.lastLaunchedAt).slice(0, 12);
14873
15169
  }
@@ -14908,9 +15204,24 @@ function buildStatusSnapshot(options) {
14908
15204
  session.unread = unread;
14909
15205
  session.inboxBucket = inboxBucket;
14910
15206
  if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
15207
+ const recentReadSnapshot = {
15208
+ sessionId: session.id,
15209
+ providerType: session.providerType,
15210
+ status: String(session.status || ""),
15211
+ inboxBucket,
15212
+ unread,
15213
+ lastSeenAt,
15214
+ completionMarker: completionMarker || "-",
15215
+ seenCompletionMarker: seenCompletionMarker || "-",
15216
+ lastUpdated: Number(session.lastUpdated || 0),
15217
+ lastUsedAt,
15218
+ lastRole: getLastMessageRole(sourceSession),
15219
+ messageUpdatedAt: getSessionMessageUpdatedAt(sourceSession)
15220
+ };
15221
+ if (!shouldEmitRecentReadDebugLog(recentReadDebugSignatureBySession, recentReadSnapshot)) continue;
14911
15222
  LOG.info(
14912
15223
  "RecentRead",
14913
- `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)}`
15224
+ `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}`
14914
15225
  );
14915
15226
  }
14916
15227
  const lastDisplayMessage = getLastDisplayMessage(sourceSession);
@@ -15185,11 +15496,104 @@ function toHostedCliRuntimeDescriptor(record) {
15185
15496
  providerSessionId: typeof record.meta?.providerSessionId === "string" ? String(record.meta.providerSessionId) : void 0
15186
15497
  };
15187
15498
  }
15499
+ function getWriteConflictOwnerClientId(error) {
15500
+ const message = typeof error === "string" ? error : error instanceof Error ? error.message : "";
15501
+ const match = /^Write owned by\s+(.+)$/.exec(message.trim());
15502
+ return match?.[1]?.trim() || void 0;
15503
+ }
15504
+ function summarizeSessionHostRecord(result) {
15505
+ if (!result || typeof result !== "object") return {};
15506
+ const record = result;
15507
+ return {
15508
+ runtimeKey: typeof record.runtimeKey === "string" ? record.runtimeKey : void 0,
15509
+ lifecycle: typeof record.lifecycle === "string" ? record.lifecycle : void 0,
15510
+ surfaceKind: getSessionHostSurfaceKind(record),
15511
+ attachedClientCount: Array.isArray(record.attachedClients) ? record.attachedClients.length : void 0,
15512
+ hasWriteOwner: !!record.writeOwner,
15513
+ writeOwnerClientId: typeof record.writeOwner?.clientId === "string" ? record.writeOwner.clientId : void 0
15514
+ };
15515
+ }
15516
+ function summarizeSessionHostRecords(result) {
15517
+ const records = Array.isArray(result) ? result : [];
15518
+ const groups = partitionSessionHostRecords(records);
15519
+ return {
15520
+ sessionCount: records.length,
15521
+ liveRuntimeCount: groups.liveRuntimes.length,
15522
+ recoverySnapshotCount: groups.recoverySnapshots.length,
15523
+ inactiveRecordCount: groups.inactiveRecords.length
15524
+ };
15525
+ }
15526
+ function summarizeSessionHostDiagnostics(result) {
15527
+ const diagnostics = result && typeof result === "object" ? result : {};
15528
+ const sessions = Array.isArray(diagnostics.sessions) ? diagnostics.sessions : [];
15529
+ return {
15530
+ runtimeCount: typeof diagnostics.runtimeCount === "number" ? diagnostics.runtimeCount : void 0,
15531
+ ...summarizeSessionHostRecords(sessions)
15532
+ };
15533
+ }
15534
+ function summarizeSessionHostPruneResult(result) {
15535
+ const value = result && typeof result === "object" ? result : {};
15536
+ return {
15537
+ duplicateGroupCount: typeof value.duplicateGroupCount === "number" ? value.duplicateGroupCount : void 0,
15538
+ prunedCount: Array.isArray(value.prunedSessionIds) ? value.prunedSessionIds.length : void 0,
15539
+ keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
15540
+ };
15541
+ }
15188
15542
  var DaemonCommandRouter = class {
15189
15543
  deps;
15190
15544
  constructor(deps) {
15191
15545
  this.deps = deps;
15192
15546
  }
15547
+ async traceSessionHostAction(action, args, run, summarizeResult) {
15548
+ const interactionId = typeof args?._interactionId === "string" ? args._interactionId : void 0;
15549
+ const sessionId = typeof args?.sessionId === "string" ? args.sessionId : void 0;
15550
+ const requestedPayload = { action };
15551
+ if (sessionId) requestedPayload.sessionId = sessionId;
15552
+ if (typeof args?.clientId === "string") requestedPayload.clientId = args.clientId;
15553
+ if (typeof args?.signal === "string") requestedPayload.signal = args.signal;
15554
+ if (typeof args?.providerType === "string") requestedPayload.providerType = args.providerType;
15555
+ if (typeof args?.workspace === "string") requestedPayload.workspace = args.workspace;
15556
+ if (typeof args?.dryRun === "boolean") requestedPayload.dryRun = args.dryRun;
15557
+ recordDebugTrace({
15558
+ interactionId,
15559
+ category: "session_host",
15560
+ stage: "action_requested",
15561
+ level: "info",
15562
+ sessionId,
15563
+ payload: requestedPayload
15564
+ });
15565
+ try {
15566
+ const result = await run();
15567
+ recordDebugTrace({
15568
+ interactionId,
15569
+ category: "session_host",
15570
+ stage: "action_result",
15571
+ level: "info",
15572
+ sessionId,
15573
+ payload: {
15574
+ ...requestedPayload,
15575
+ success: true,
15576
+ ...summarizeResult ? summarizeResult(result) : {}
15577
+ }
15578
+ });
15579
+ return result;
15580
+ } catch (error) {
15581
+ recordDebugTrace({
15582
+ interactionId,
15583
+ category: "session_host",
15584
+ stage: "action_failed",
15585
+ level: "error",
15586
+ sessionId,
15587
+ payload: {
15588
+ ...requestedPayload,
15589
+ error: error?.message || String(error),
15590
+ failureKind: getWriteConflictOwnerClientId(error) ? "write_conflict" : "request_failed",
15591
+ conflictOwnerClientId: getWriteConflictOwnerClientId(error)
15592
+ }
15593
+ });
15594
+ throw error;
15595
+ }
15596
+ }
15193
15597
  /**
15194
15598
  * Unified command routing.
15195
15599
  * Returns result for all commands:
@@ -15299,44 +15703,60 @@ var DaemonCommandRouter = class {
15299
15703
  }
15300
15704
  case "session_host_get_diagnostics": {
15301
15705
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15302
- const diagnostics = await this.deps.sessionHostControl.getDiagnostics({
15706
+ const diagnostics = await this.traceSessionHostAction("session_host_get_diagnostics", args, () => this.deps.sessionHostControl.getDiagnostics({
15303
15707
  includeSessions: args?.includeSessions !== false,
15304
15708
  limit: Number(args?.limit) || void 0
15305
- });
15709
+ }), (result) => ({
15710
+ includeSessions: args?.includeSessions !== false,
15711
+ limit: Number(args?.limit) || void 0,
15712
+ ...summarizeSessionHostDiagnostics(result)
15713
+ }));
15306
15714
  return { success: true, diagnostics };
15307
15715
  }
15308
15716
  case "session_host_list_sessions": {
15309
15717
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15310
- const sessions = await this.deps.sessionHostControl.listSessions();
15718
+ const sessions = await this.traceSessionHostAction("session_host_list_sessions", args, () => this.deps.sessionHostControl.listSessions(), (records) => summarizeSessionHostRecords(records));
15311
15719
  return { success: true, sessions };
15312
15720
  }
15313
15721
  case "session_host_stop_session": {
15314
15722
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15315
15723
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
15316
15724
  if (!sessionId) return { success: false, error: "sessionId required" };
15317
- const record = await this.deps.sessionHostControl.stopSession(sessionId);
15725
+ const record = await this.traceSessionHostAction("session_host_stop_session", args, () => this.deps.sessionHostControl.stopSession(sessionId), (result) => summarizeSessionHostRecord(result));
15318
15726
  return { success: true, record };
15319
15727
  }
15320
15728
  case "session_host_resume_session": {
15321
15729
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15322
15730
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
15323
15731
  if (!sessionId) return { success: false, error: "sessionId required" };
15324
- const record = await this.deps.sessionHostControl.resumeSession(sessionId);
15325
- const hosted = toHostedCliRuntimeDescriptor(record);
15326
- if (hosted) {
15327
- await this.deps.cliManager.restoreHostedSessions([hosted]);
15328
- }
15732
+ const record = await this.traceSessionHostAction("session_host_resume_session", args, async () => {
15733
+ const nextRecord = await this.deps.sessionHostControl.resumeSession(sessionId);
15734
+ const hosted = toHostedCliRuntimeDescriptor(nextRecord);
15735
+ if (hosted) {
15736
+ await this.deps.cliManager.restoreHostedSessions([hosted]);
15737
+ }
15738
+ return nextRecord;
15739
+ }, (result) => ({
15740
+ ...summarizeSessionHostRecord(result),
15741
+ restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
15742
+ }));
15329
15743
  return { success: true, record };
15330
15744
  }
15331
15745
  case "session_host_restart_session": {
15332
15746
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15333
15747
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
15334
15748
  if (!sessionId) return { success: false, error: "sessionId required" };
15335
- const record = await this.deps.sessionHostControl.restartSession(sessionId);
15336
- const hosted = toHostedCliRuntimeDescriptor(record);
15337
- if (hosted) {
15338
- await this.deps.cliManager.restoreHostedSessions([hosted]);
15339
- }
15749
+ const record = await this.traceSessionHostAction("session_host_restart_session", args, async () => {
15750
+ const nextRecord = await this.deps.sessionHostControl.restartSession(sessionId);
15751
+ const hosted = toHostedCliRuntimeDescriptor(nextRecord);
15752
+ if (hosted) {
15753
+ await this.deps.cliManager.restoreHostedSessions([hosted]);
15754
+ }
15755
+ return nextRecord;
15756
+ }, (result) => ({
15757
+ ...summarizeSessionHostRecord(result),
15758
+ restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
15759
+ }));
15340
15760
  return { success: true, record };
15341
15761
  }
15342
15762
  case "session_host_send_signal": {
@@ -15345,7 +15765,7 @@ var DaemonCommandRouter = class {
15345
15765
  const signal = typeof args?.signal === "string" ? args.signal : "";
15346
15766
  if (!sessionId) return { success: false, error: "sessionId required" };
15347
15767
  if (!signal) return { success: false, error: "signal required" };
15348
- const record = await this.deps.sessionHostControl.sendSignal(sessionId, signal);
15768
+ const record = await this.traceSessionHostAction("session_host_send_signal", args, () => this.deps.sessionHostControl.sendSignal(sessionId, signal), (result) => summarizeSessionHostRecord(result));
15349
15769
  return { success: true, record };
15350
15770
  }
15351
15771
  case "session_host_force_detach_client": {
@@ -15354,16 +15774,16 @@ var DaemonCommandRouter = class {
15354
15774
  const clientId = typeof args?.clientId === "string" ? args.clientId : "";
15355
15775
  if (!sessionId) return { success: false, error: "sessionId required" };
15356
15776
  if (!clientId) return { success: false, error: "clientId required" };
15357
- const record = await this.deps.sessionHostControl.forceDetachClient(sessionId, clientId);
15777
+ const record = await this.traceSessionHostAction("session_host_force_detach_client", args, () => this.deps.sessionHostControl.forceDetachClient(sessionId, clientId), (result) => summarizeSessionHostRecord(result));
15358
15778
  return { success: true, record };
15359
15779
  }
15360
15780
  case "session_host_prune_duplicate_sessions": {
15361
15781
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
15362
- const result = await this.deps.sessionHostControl.pruneDuplicateSessions({
15782
+ const result = await this.traceSessionHostAction("session_host_prune_duplicate_sessions", args, () => this.deps.sessionHostControl.pruneDuplicateSessions({
15363
15783
  providerType: typeof args?.providerType === "string" ? args.providerType : void 0,
15364
15784
  workspace: typeof args?.workspace === "string" ? args.workspace : void 0,
15365
15785
  dryRun: args?.dryRun === true
15366
- });
15786
+ }), (value) => summarizeSessionHostPruneResult(value));
15367
15787
  return { success: true, result };
15368
15788
  }
15369
15789
  case "session_host_acquire_write": {
@@ -15373,12 +15793,15 @@ var DaemonCommandRouter = class {
15373
15793
  const ownerType = args?.ownerType === "agent" ? "agent" : "user";
15374
15794
  if (!sessionId) return { success: false, error: "sessionId required" };
15375
15795
  if (!clientId) return { success: false, error: "clientId required" };
15376
- const record = await this.deps.sessionHostControl.acquireWrite({
15796
+ const record = await this.traceSessionHostAction("session_host_acquire_write", args, () => this.deps.sessionHostControl.acquireWrite({
15377
15797
  sessionId,
15378
15798
  clientId,
15379
15799
  ownerType,
15380
15800
  force: args?.force !== false
15381
- });
15801
+ }), (result) => ({
15802
+ ...summarizeSessionHostRecord(result),
15803
+ ownerType
15804
+ }));
15382
15805
  return { success: true, record };
15383
15806
  }
15384
15807
  case "session_host_release_write": {
@@ -15387,7 +15810,10 @@ var DaemonCommandRouter = class {
15387
15810
  const clientId = typeof args?.clientId === "string" ? args.clientId : "";
15388
15811
  if (!sessionId) return { success: false, error: "sessionId required" };
15389
15812
  if (!clientId) return { success: false, error: "clientId required" };
15390
- const record = await this.deps.sessionHostControl.releaseWrite({ sessionId, clientId });
15813
+ const record = await this.traceSessionHostAction("session_host_release_write", args, () => this.deps.sessionHostControl.releaseWrite({
15814
+ sessionId,
15815
+ clientId
15816
+ }), (result) => summarizeSessionHostRecord(result));
15391
15817
  return { success: true, record };
15392
15818
  }
15393
15819
  case "list_saved_sessions": {
@@ -15420,7 +15846,7 @@ var DaemonCommandRouter = class {
15420
15846
  kind: saved?.kind || recent?.kind || kind,
15421
15847
  title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
15422
15848
  workspace: saved?.workspace || recent?.workspace || session.workspace,
15423
- currentModel: saved?.currentModel || recent?.currentModel,
15849
+ summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
15424
15850
  preview: session.preview,
15425
15851
  messageCount: session.messageCount,
15426
15852
  firstMessageAt: session.firstMessageAt,
@@ -15859,7 +16285,7 @@ var DaemonStatusReporter = class {
15859
16285
  const ideSummary = ideStates.map((s) => {
15860
16286
  const msgs = s.activeChat?.messages?.length || 0;
15861
16287
  const exts = s.extensions.length;
15862
- return `${s.type}(${s.status},${msgs}msg,${exts}ext${s.currentModel ? ",model=" + s.currentModel : ""})`;
16288
+ return `${s.type}(${s.status},${msgs}msg,${exts}ext)`;
15863
16289
  }).join(", ");
15864
16290
  const cliSummary = cliStates.map((s) => `${s.type}(${s.status})`).join(", ");
15865
16291
  const acpSummary = acpStates.map((s) => `${s.type}(${s.status})`).join(", ");
@@ -15921,9 +16347,7 @@ var DaemonStatusReporter = class {
15921
16347
  workspace: session.workspace ?? null,
15922
16348
  title: session.title,
15923
16349
  cdpConnected: session.cdpConnected,
15924
- currentModel: session.currentModel,
15925
- currentPlan: session.currentPlan,
15926
- currentAutoApprove: session.currentAutoApprove
16350
+ summaryMetadata: session.summaryMetadata
15927
16351
  })),
15928
16352
  p2p: payload.p2p,
15929
16353
  timestamp: now
@@ -16089,15 +16513,18 @@ var ProviderStreamAdapter = class {
16089
16513
  status: data.status || "idle",
16090
16514
  messages: data.messages || [],
16091
16515
  inputContent: data.inputContent || "",
16092
- model: data.model,
16093
- mode: data.mode,
16094
16516
  activeModal: data.activeModal
16095
16517
  };
16096
16518
  if (typeof data.title === "string" && data.title.trim()) {
16097
16519
  state.title = data.title.trim();
16098
16520
  }
16099
16521
  const controlValues = extractProviderControlValues(this.provider.controls, data);
16100
- if (controlValues) state.controlValues = controlValues;
16522
+ const surface = resolveProviderStateSurface({
16523
+ controlValues,
16524
+ summaryMetadata: data.summaryMetadata
16525
+ });
16526
+ if (surface.controlValues) state.controlValues = surface.controlValues;
16527
+ if (surface.summaryMetadata) state.summaryMetadata = surface.summaryMetadata;
16101
16528
  const effects = normalizeProviderEffects(data);
16102
16529
  if (effects.length > 0) state.effects = effects;
16103
16530
  if (state.messages.length > 0) {
@@ -16371,7 +16798,8 @@ var DaemonAgentStreamManager = class {
16371
16798
  const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.cdpSessionId, expr, timeout);
16372
16799
  const state = await agent.adapter.readChat(evaluate);
16373
16800
  const stateError = this.getStateError(state);
16374
- 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) : ""}`);
16801
+ const selectedModelValue = typeof state.controlValues?.model === "string" ? state.controlValues.model : "";
16802
+ LOG.debug("AgentStream", `[AgentStream] readChat(${type}) result: status=${state.status} msgs=${state.messages?.length || 0} model=${selectedModelValue}${state.status === "error" ? " error=" + JSON.stringify(stateError) : ""}`);
16375
16803
  if (state.status === "error" && this.isRecoverableSessionError(stateError)) {
16376
16804
  throw new Error(stateError);
16377
16805
  }
@@ -16719,9 +17147,8 @@ function forwardAgentStreamsToIdeInstance(instanceManager, ideType, streams) {
16719
17147
  messages: stream.messages || [],
16720
17148
  status: stream.status || "idle",
16721
17149
  activeModal: stream.activeModal || null,
16722
- model: stream.model || void 0,
16723
- mode: stream.mode || void 0,
16724
17150
  controlValues: stream.controlValues || void 0,
17151
+ summaryMetadata: stream.summaryMetadata || void 0,
16725
17152
  effects: stream.effects || void 0,
16726
17153
  sessionId: stream.sessionId || stream.instanceId || void 0,
16727
17154
  title: stream.title || stream.agentName || void 0,
@@ -17257,7 +17684,11 @@ module.exports.setMode = (params) => {
17257
17684
  * 5. Approval dialog detection (buttons, modal)
17258
17685
  * 6. Input field selector
17259
17686
  *
17260
- * \u2192 { id, status, title, messages[], inputContent, activeModal }
17687
+ * Preferred live-state surface:
17688
+ * - controlValues: explicit current control selections (model/mode/etc.)
17689
+ * - summaryMetadata: compact always-visible metadata for dashboard/recent views
17690
+ * Legacy top-level model/mode output is no longer the preferred shape.
17691
+ * \u2192 { id, status, title, messages[], inputContent, activeModal, controlValues?, summaryMetadata? }
17261
17692
  */
17262
17693
  (() => {
17263
17694
  try {
@@ -17285,6 +17716,9 @@ module.exports.setMode = (params) => {
17285
17716
  messages,
17286
17717
  inputContent,
17287
17718
  activeModal,
17719
+ // TODO: Return explicit selections when available, e.g.
17720
+ // controlValues: { model: selectedModel, mode: selectedMode },
17721
+ // summaryMetadata: { items: [{ id: 'model', value: selectedModelLabel || selectedModel, shortValue: selectedModel, order: 10 }] },
17288
17722
  });
17289
17723
  } catch(e) {
17290
17724
  return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
@@ -19025,7 +19459,6 @@ async function handleCliStatus(ctx, _req, res) {
19025
19459
  lastMessage: s.activeChat?.messages?.slice(-1)[0] || null,
19026
19460
  activeModal: s.activeChat?.activeModal || null,
19027
19461
  pendingEvents: s.pendingEvents || [],
19028
- currentModel: s.currentModel,
19029
19462
  settings: s.settings
19030
19463
  }));
19031
19464
  ctx.json(res, 200, { instances: result, count: result.length });
@@ -20182,7 +20615,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
20182
20615
  lines.push("## Required Return Format");
20183
20616
  lines.push("| Function | Return JSON |");
20184
20617
  lines.push("|---|---|");
20185
- 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 |");
20618
+ 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 |");
20186
20619
  lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
20187
20620
  lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
20188
20621
  lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
@@ -21817,7 +22250,7 @@ var DevServer = class _DevServer {
21817
22250
  lines.push("## Required Return Format");
21818
22251
  lines.push("| Function | Return JSON |");
21819
22252
  lines.push("|---|---|");
21820
- 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 |");
22253
+ 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 |");
21821
22254
  lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
21822
22255
  lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
21823
22256
  lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
@@ -22723,61 +23156,6 @@ async function listHostedCliRuntimes(endpoint) {
22723
23156
  }
22724
23157
  }
22725
23158
 
22726
- // src/session-host/runtime-surface.ts
22727
- var LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
22728
- function isSessionHostLiveRuntime(record) {
22729
- const lifecycle = String(record?.lifecycle || "").trim();
22730
- return LIVE_LIFECYCLES.has(lifecycle);
22731
- }
22732
- function getSessionHostRecoveryLabel(meta) {
22733
- const recoveryState = typeof meta?.runtimeRecoveryState === "string" ? String(meta.runtimeRecoveryState).trim() : "";
22734
- if (!recoveryState) return null;
22735
- if (recoveryState === "auto_resumed") return "restored after restart";
22736
- if (recoveryState === "resume_failed") return "restore failed";
22737
- if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
22738
- if (recoveryState === "orphan_snapshot") return "snapshot recovered";
22739
- return recoveryState.replace(/_/g, " ");
22740
- }
22741
- function isSessionHostRecoverySnapshot(record) {
22742
- if (!record) return false;
22743
- if (isSessionHostLiveRuntime(record)) return false;
22744
- const lifecycle = String(record.lifecycle || "").trim();
22745
- if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
22746
- return false;
22747
- }
22748
- const meta = record.meta || void 0;
22749
- if (meta?.restoredFromStorage === true) return true;
22750
- return getSessionHostRecoveryLabel(meta) !== null;
22751
- }
22752
- function getSessionHostSurfaceKind(record) {
22753
- if (isSessionHostLiveRuntime(record)) return "live_runtime";
22754
- if (isSessionHostRecoverySnapshot(record)) return "recovery_snapshot";
22755
- return "inactive_record";
22756
- }
22757
- function partitionSessionHostRecords(records) {
22758
- const liveRuntimes = [];
22759
- const recoverySnapshots = [];
22760
- const inactiveRecords = [];
22761
- for (const record of records) {
22762
- const kind = getSessionHostSurfaceKind(record);
22763
- if (kind === "live_runtime") {
22764
- liveRuntimes.push(record);
22765
- } else if (kind === "recovery_snapshot") {
22766
- recoverySnapshots.push(record);
22767
- } else {
22768
- inactiveRecords.push(record);
22769
- }
22770
- }
22771
- return {
22772
- liveRuntimes,
22773
- recoverySnapshots,
22774
- inactiveRecords
22775
- };
22776
- }
22777
- function partitionSessionHostDiagnosticsSessions(records) {
22778
- return partitionSessionHostRecords(records || []);
22779
- }
22780
-
22781
23159
  // src/session-host/startup-restore-policy.js
22782
23160
  function shouldAutoRestoreHostedSessionsOnStartup(env = process.env) {
22783
23161
  const raw = typeof env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP === "string" ? env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP.trim().toLowerCase() : "";