adhdev 0.8.58 → 0.8.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -419,6 +419,73 @@ var init_workspaces = __esm({
419
419
  }
420
420
  });
421
421
 
422
+ // ../../oss/packages/daemon-core/src/providers/summary-metadata.ts
423
+ function normalizeSummaryItem(item) {
424
+ if (!item || typeof item !== "object") return null;
425
+ const id = String(item.id || "").trim();
426
+ const value = String(item.value || "").trim();
427
+ if (!id || !value) return null;
428
+ const normalized = {
429
+ id,
430
+ value
431
+ };
432
+ if (typeof item.label === "string" && item.label.trim()) normalized.label = item.label.trim();
433
+ if (typeof item.shortValue === "string" && item.shortValue.trim()) normalized.shortValue = item.shortValue.trim();
434
+ if (typeof item.icon === "string" && item.icon.trim()) normalized.icon = item.icon.trim();
435
+ if (typeof item.order === "number" && Number.isFinite(item.order)) normalized.order = item.order;
436
+ return normalized;
437
+ }
438
+ function normalizeProviderSummaryMetadata(summary) {
439
+ if (!summary || !Array.isArray(summary.items)) return void 0;
440
+ const items = summary.items.map((item) => normalizeSummaryItem(item)).filter((item) => !!item).sort((left2, right2) => {
441
+ const orderDiff = (left2.order ?? Number.MAX_SAFE_INTEGER) - (right2.order ?? Number.MAX_SAFE_INTEGER);
442
+ if (orderDiff !== 0) return orderDiff;
443
+ return left2.id.localeCompare(right2.id);
444
+ });
445
+ return items.length > 0 ? { items } : void 0;
446
+ }
447
+ function buildProviderSummaryMetadata(items) {
448
+ return normalizeProviderSummaryMetadata({ items: items.filter(Boolean) });
449
+ }
450
+ function buildLegacyModelModeSummaryMetadata(params) {
451
+ return buildProviderSummaryMetadata([
452
+ params.model ? {
453
+ id: "model",
454
+ label: "Model",
455
+ value: String(params.modelLabel || params.model).trim(),
456
+ shortValue: String(params.model).trim(),
457
+ order: 10
458
+ } : null,
459
+ params.mode ? {
460
+ id: "mode",
461
+ label: "Mode",
462
+ value: String(params.modeLabel || params.mode).trim(),
463
+ shortValue: String(params.mode).trim(),
464
+ order: 20
465
+ } : null
466
+ ]);
467
+ }
468
+ function resolveProviderStateSummaryMetadata(params) {
469
+ const explicit = normalizeProviderSummaryMetadata(params.summaryMetadata);
470
+ if (explicit) return explicit;
471
+ const model = typeof params.controlValues?.model === "string" ? params.controlValues.model : void 0;
472
+ const mode = typeof params.controlValues?.mode === "string" ? params.controlValues.mode : void 0;
473
+ return buildLegacyModelModeSummaryMetadata({
474
+ model,
475
+ mode,
476
+ modelLabel: params.modelLabel,
477
+ modeLabel: params.modeLabel
478
+ });
479
+ }
480
+ function normalizePersistedSummaryMetadata(params) {
481
+ return normalizeProviderSummaryMetadata(params.summaryMetadata);
482
+ }
483
+ var init_summary_metadata = __esm({
484
+ "../../oss/packages/daemon-core/src/providers/summary-metadata.ts"() {
485
+ "use strict";
486
+ }
487
+ });
488
+
422
489
  // ../../oss/packages/daemon-core/src/config/recent-activity.ts
423
490
  function normalizeWorkspace(workspace) {
424
491
  if (!workspace) return "";
@@ -442,6 +509,9 @@ function appendRecentActivity(state, entry) {
442
509
  const nextEntry = {
443
510
  ...entry,
444
511
  workspace: entry.workspace ? normalizeWorkspace(entry.workspace) : void 0,
512
+ summaryMetadata: normalizePersistedSummaryMetadata({
513
+ summaryMetadata: entry.summaryMetadata
514
+ }),
445
515
  id: buildRecentActivityKeyForEntry(entry),
446
516
  lastUsedAt: entry.lastUsedAt || Date.now()
447
517
  };
@@ -452,7 +522,12 @@ function appendRecentActivity(state, entry) {
452
522
  };
453
523
  }
454
524
  function getRecentActivity(state, limit = 20) {
455
- return [...state.recentActivity || []].sort((a, b) => b.lastUsedAt - a.lastUsedAt).slice(0, limit);
525
+ return [...state.recentActivity || []].map((entry) => ({
526
+ ...entry,
527
+ summaryMetadata: normalizePersistedSummaryMetadata({
528
+ summaryMetadata: entry.summaryMetadata
529
+ })
530
+ })).sort((a, b) => b.lastUsedAt - a.lastUsedAt).slice(0, limit);
456
531
  }
457
532
  function getSessionSeenAt(state, sessionId) {
458
533
  return state.sessionReads?.[sessionId] || 0;
@@ -483,6 +558,7 @@ var init_recent_activity = __esm({
483
558
  "use strict";
484
559
  path2 = __toESM(require("path"));
485
560
  init_workspaces();
561
+ init_summary_metadata();
486
562
  MAX_ACTIVITY = 30;
487
563
  }
488
564
  });
@@ -511,7 +587,9 @@ function upsertSavedProviderSession(state, entry) {
511
587
  providerName: entry.providerName,
512
588
  providerSessionId,
513
589
  workspace: entry.workspace ? normalizeWorkspace2(entry.workspace) : void 0,
514
- currentModel: entry.currentModel,
590
+ summaryMetadata: normalizePersistedSummaryMetadata({
591
+ summaryMetadata: entry.summaryMetadata
592
+ }),
515
593
  title: entry.title,
516
594
  createdAt: existing?.createdAt || entry.createdAt || Date.now(),
517
595
  lastUsedAt: entry.lastUsedAt || Date.now()
@@ -527,7 +605,12 @@ function getSavedProviderSessions(state, filters) {
527
605
  if (filters?.providerType && entry.providerType !== filters.providerType) return false;
528
606
  if (filters?.kind && entry.kind !== filters.kind) return false;
529
607
  return true;
530
- }).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
608
+ }).map((entry) => ({
609
+ ...entry,
610
+ summaryMetadata: normalizePersistedSummaryMetadata({
611
+ summaryMetadata: entry.summaryMetadata
612
+ })
613
+ })).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
531
614
  }
532
615
  var path3, MAX_SAVED_SESSIONS;
533
616
  var init_saved_sessions = __esm({
@@ -535,6 +618,7 @@ var init_saved_sessions = __esm({
535
618
  "use strict";
536
619
  path3 = __toESM(require("path"));
537
620
  init_workspaces();
621
+ init_summary_metadata();
538
622
  MAX_SAVED_SESSIONS = 500;
539
623
  }
540
624
  });
@@ -2547,8 +2631,6 @@ function extractProviderControlValues(controls, data) {
2547
2631
  if (rawValue === void 0 || rawValue === null) continue;
2548
2632
  values[ctrl.id] = normalizeControlValue(rawValue);
2549
2633
  }
2550
- if (data.model !== void 0 && values.model === void 0) values.model = normalizeControlValue(data.model);
2551
- if (data.mode !== void 0 && values.mode === void 0) values.mode = normalizeControlValue(data.mode);
2552
2634
  return Object.keys(values).length > 0 ? values : void 0;
2553
2635
  }
2554
2636
  function normalizeProviderEffects(data) {
@@ -2650,7 +2732,7 @@ function normalizeControlOption(option) {
2650
2732
  }
2651
2733
  if (!option || typeof option !== "object") return null;
2652
2734
  const record2 = option;
2653
- const value = typeof record2.value === "string" ? record2.value : typeof record2.id === "string" ? record2.id : null;
2735
+ const value = typeof record2.value === "string" ? record2.value : typeof record2.id === "string" ? record2.id : typeof record2.name === "string" ? record2.name : null;
2654
2736
  if (!value) return null;
2655
2737
  const label = typeof record2.label === "string" ? record2.label : typeof record2.name === "string" ? record2.name : value;
2656
2738
  const normalized = { value, label };
@@ -3196,6 +3278,68 @@ var init_chat_history = __esm({
3196
3278
  }
3197
3279
  });
3198
3280
 
3281
+ // ../../oss/packages/daemon-core/src/providers/provider-patch-state.ts
3282
+ function isControlValue(value) {
3283
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
3284
+ }
3285
+ function asControlValueMap(value) {
3286
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
3287
+ const result = {};
3288
+ for (const [entryKey, entryValue] of Object.entries(value)) {
3289
+ if (isControlValue(entryValue)) result[entryKey] = entryValue;
3290
+ }
3291
+ return Object.keys(result).length > 0 ? result : void 0;
3292
+ }
3293
+ function getLegacyModelModeValues(data) {
3294
+ if (!data || typeof data !== "object") return void 0;
3295
+ const legacy = {};
3296
+ if (typeof data.model === "string" && data.model.trim()) legacy.model = data.model.trim();
3297
+ if (typeof data.mode === "string" && data.mode.trim()) legacy.mode = data.mode.trim();
3298
+ return Object.keys(legacy).length > 0 ? legacy : void 0;
3299
+ }
3300
+ function mergeProviderPatchState(params) {
3301
+ const {
3302
+ providerControls,
3303
+ data,
3304
+ currentControlValues,
3305
+ currentSummaryMetadata,
3306
+ mergeWithCurrent = true
3307
+ } = params;
3308
+ const sources = [
3309
+ mergeWithCurrent ? asControlValueMap(currentControlValues) : void 0,
3310
+ asControlValueMap(data?.controlValues),
3311
+ asControlValueMap(extractProviderControlValues(providerControls, data)),
3312
+ getLegacyModelModeValues(data)
3313
+ ];
3314
+ const controlValues = Object.assign({}, ...sources.filter(Boolean));
3315
+ return {
3316
+ controlValues,
3317
+ summaryMetadata: data?.summaryMetadata !== void 0 ? data.summaryMetadata : currentSummaryMetadata
3318
+ };
3319
+ }
3320
+ function normalizeProviderStateControlValues(controlValues) {
3321
+ return controlValues && Object.keys(controlValues).length > 0 ? controlValues : void 0;
3322
+ }
3323
+ function resolveProviderStateSurface(params) {
3324
+ const controlValues = normalizeProviderStateControlValues(params.controlValues);
3325
+ return {
3326
+ controlValues,
3327
+ summaryMetadata: resolveProviderStateSummaryMetadata({
3328
+ summaryMetadata: params.summaryMetadata,
3329
+ controlValues,
3330
+ modelLabel: params.modelLabel,
3331
+ modeLabel: params.modeLabel
3332
+ })
3333
+ };
3334
+ }
3335
+ var init_provider_patch_state = __esm({
3336
+ "../../oss/packages/daemon-core/src/providers/provider-patch-state.ts"() {
3337
+ "use strict";
3338
+ init_control_effects();
3339
+ init_summary_metadata();
3340
+ }
3341
+ });
3342
+
3199
3343
  // ../../oss/packages/daemon-core/src/providers/extension-provider-instance.ts
3200
3344
  var ExtensionProviderInstance;
3201
3345
  var init_extension_provider_instance = __esm({
@@ -3204,6 +3348,7 @@ var init_extension_provider_instance = __esm({
3204
3348
  init_status_monitor();
3205
3349
  init_control_effects();
3206
3350
  init_chat_history();
3351
+ init_provider_patch_state();
3207
3352
  ExtensionProviderInstance = class {
3208
3353
  type;
3209
3354
  category = "extension";
@@ -3217,9 +3362,8 @@ var init_extension_provider_instance = __esm({
3217
3362
  messages = [];
3218
3363
  prevMessageHashes = /* @__PURE__ */ new Map();
3219
3364
  activeModal = null;
3220
- currentModel = "";
3221
- currentMode = "";
3222
3365
  controlValues = {};
3366
+ summaryMetadata = void 0;
3223
3367
  appliedEffectKeys = /* @__PURE__ */ new Set();
3224
3368
  runtimeMessages = [];
3225
3369
  lastAgentStatus = "idle";
@@ -3254,6 +3398,10 @@ var init_extension_provider_instance = __esm({
3254
3398
  if (!this.context?.cdp?.isConnected) return;
3255
3399
  }
3256
3400
  getState() {
3401
+ const surface = resolveProviderStateSurface({
3402
+ summaryMetadata: this.summaryMetadata,
3403
+ controlValues: this.controlValues
3404
+ });
3257
3405
  return {
3258
3406
  type: this.type,
3259
3407
  name: this.provider.name,
@@ -3267,10 +3415,9 @@ var init_extension_provider_instance = __esm({
3267
3415
  activeModal: this.activeModal,
3268
3416
  inputContent: ""
3269
3417
  } : null,
3270
- currentModel: this.currentModel || void 0,
3271
- currentPlan: this.currentMode || void 0,
3272
- controlValues: this.controlValues,
3418
+ controlValues: surface.controlValues,
3273
3419
  providerControls: this.provider.controls,
3420
+ summaryMetadata: surface.summaryMetadata,
3274
3421
  agentStreams: this.agentStreams,
3275
3422
  instanceId: this.instanceId,
3276
3423
  lastUpdated: Date.now(),
@@ -3283,10 +3430,14 @@ var init_extension_provider_instance = __esm({
3283
3430
  if (data?.streams) this.agentStreams = data.streams;
3284
3431
  if (data?.messages) this.messages = this.assignReceivedAt(data.messages);
3285
3432
  if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
3286
- if (data?.model) this.currentModel = data.model;
3287
- if (data?.mode) this.currentMode = data.mode;
3288
- const controlValues = extractProviderControlValues(this.provider.controls, data) || data?.controlValues;
3289
- if (controlValues) this.controlValues = controlValues;
3433
+ const patchedState = mergeProviderPatchState({
3434
+ providerControls: this.provider.controls,
3435
+ data,
3436
+ currentControlValues: this.controlValues,
3437
+ currentSummaryMetadata: this.summaryMetadata
3438
+ });
3439
+ this.controlValues = patchedState.controlValues;
3440
+ this.summaryMetadata = patchedState.summaryMetadata;
3290
3441
  if (typeof data?.sessionId === "string" && data.sessionId.trim()) this.chatId = data.sessionId;
3291
3442
  if (typeof data?.title === "string" && data.title.trim()) this.chatTitle = data.title;
3292
3443
  if (typeof data?.agentName === "string" && data.agentName.trim()) this.agentName = data.agentName;
@@ -3387,8 +3538,14 @@ var init_extension_provider_instance = __esm({
3387
3538
  }
3388
3539
  applyProviderResponse(data, options) {
3389
3540
  if (!data || typeof data !== "object") return;
3390
- const controlValues = extractProviderControlValues(this.provider.controls, data);
3391
- if (controlValues) this.controlValues = { ...this.controlValues, ...controlValues };
3541
+ const patchedState = mergeProviderPatchState({
3542
+ providerControls: this.provider.controls,
3543
+ data,
3544
+ currentControlValues: this.controlValues,
3545
+ currentSummaryMetadata: this.summaryMetadata
3546
+ });
3547
+ this.controlValues = patchedState.controlValues;
3548
+ this.summaryMetadata = patchedState.summaryMetadata;
3392
3549
  const effects = normalizeProviderEffects(data);
3393
3550
  for (const effect of effects) {
3394
3551
  const effectWhen = effect.when || "immediate";
@@ -3538,8 +3695,6 @@ ${effect.notification.body || ""}`.trim();
3538
3695
  this.messages = [];
3539
3696
  this.prevMessageHashes.clear();
3540
3697
  this.activeModal = null;
3541
- this.currentModel = "";
3542
- this.currentMode = "";
3543
3698
  this.controlValues = {};
3544
3699
  this.currentStatus = "idle";
3545
3700
  this.chatId = null;
@@ -3619,6 +3774,7 @@ var init_ide_provider_instance = __esm({
3619
3774
  init_logger();
3620
3775
  init_control_effects();
3621
3776
  init_approval_utils();
3777
+ init_provider_patch_state();
3622
3778
  IdeProviderInstance = class {
3623
3779
  type;
3624
3780
  category = "ide";
@@ -3691,6 +3847,10 @@ var init_ide_provider_instance = __esm({
3691
3847
  for (const ext of this.extensions.values()) {
3692
3848
  extensionStates.push(ext.getState());
3693
3849
  }
3850
+ const surface = resolveProviderStateSurface({
3851
+ summaryMetadata: this.cachedChat?.summaryMetadata,
3852
+ controlValues: this.cachedChat?.controlValues
3853
+ });
3694
3854
  return {
3695
3855
  type: this.type,
3696
3856
  name: this.provider.name,
@@ -3707,11 +3867,9 @@ var init_ide_provider_instance = __esm({
3707
3867
  workspace: this.workspace || null,
3708
3868
  extensions: extensionStates,
3709
3869
  cdpConnected: cdp?.isConnected || false,
3710
- currentModel: this.cachedChat?.model || void 0,
3711
- currentPlan: this.cachedChat?.mode || void 0,
3712
- currentAutoApprove: this.cachedChat?.autoApprove || void 0,
3713
- controlValues: this.cachedChat?.controlValues || void 0,
3870
+ controlValues: surface.controlValues,
3714
3871
  providerControls: this.provider.controls,
3872
+ summaryMetadata: surface.summaryMetadata,
3715
3873
  instanceId: this.instanceId,
3716
3874
  lastUpdated: Date.now(),
3717
3875
  settings: this.settings,
@@ -3883,8 +4041,13 @@ var init_ide_provider_instance = __esm({
3883
4041
  chat.messages = messages.filter((m) => !hiddenKinds.has(m.kind || ""));
3884
4042
  }
3885
4043
  }
3886
- const controlValues = extractProviderControlValues(this.provider.controls, chat);
3887
- if (controlValues) chat.controlValues = controlValues;
4044
+ const patchedState = mergeProviderPatchState({
4045
+ providerControls: this.provider.controls,
4046
+ data: chat,
4047
+ mergeWithCurrent: false
4048
+ });
4049
+ chat.controlValues = Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0;
4050
+ chat.summaryMetadata = patchedState.summaryMetadata;
3888
4051
  this.cachedChat = { ...chat, activeModal };
3889
4052
  this.detectAgentTransitions(chat, now);
3890
4053
  const persistedMessages = chat.messages || messages;
@@ -3971,14 +4134,18 @@ var init_ide_provider_instance = __esm({
3971
4134
  }
3972
4135
  applyProviderResponse(data, options) {
3973
4136
  if (!data || typeof data !== "object") return;
3974
- const controlValues = extractProviderControlValues(this.provider.controls, data);
3975
- if (controlValues) {
3976
- this.cachedChat = {
3977
- ...this.cachedChat || {},
3978
- ...data,
3979
- controlValues: { ...this.cachedChat?.controlValues || {}, ...controlValues }
3980
- };
3981
- }
4137
+ const patchedState = mergeProviderPatchState({
4138
+ providerControls: this.provider.controls,
4139
+ data,
4140
+ currentControlValues: this.cachedChat?.controlValues,
4141
+ currentSummaryMetadata: this.cachedChat?.summaryMetadata
4142
+ });
4143
+ this.cachedChat = {
4144
+ ...this.cachedChat || {},
4145
+ ...data,
4146
+ controlValues: Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0,
4147
+ summaryMetadata: patchedState.summaryMetadata
4148
+ };
3982
4149
  const effects = normalizeProviderEffects(data);
3983
4150
  for (const effect of effects) {
3984
4151
  const effectWhen = effect.when || "immediate";
@@ -4751,6 +4918,8 @@ function isCdpConnected(cdpManagers, key) {
4751
4918
  function buildIdeWorkspaceSession(state, cdpManagers, options) {
4752
4919
  const profile = options.profile || "full";
4753
4920
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
4921
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
4922
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
4754
4923
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
4755
4924
  const includeSessionControls = shouldIncludeSessionControls(profile);
4756
4925
  const title = activeChat?.title || state.name;
@@ -4767,13 +4936,11 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
4767
4936
  title,
4768
4937
  ...includeSessionMetadata && { workspace: state.workspace || null },
4769
4938
  activeChat,
4939
+ ...summaryMetadata && { summaryMetadata },
4770
4940
  ...includeSessionMetadata && { capabilities: IDE_SESSION_CAPABILITIES },
4771
4941
  cdpConnected: state.cdpConnected ?? isCdpConnected(cdpManagers, state.type),
4772
- currentModel: state.currentModel,
4773
- currentPlan: state.currentPlan,
4774
- currentAutoApprove: state.currentAutoApprove,
4775
4942
  ...includeSessionControls && {
4776
- controlValues: state.controlValues,
4943
+ ...controlValues && { controlValues },
4777
4944
  providerControls: state.providerControls
4778
4945
  },
4779
4946
  errorMessage: state.errorMessage,
@@ -4784,6 +4951,8 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
4784
4951
  function buildExtensionAgentSession(parent, ext, options) {
4785
4952
  const profile = options.profile || "full";
4786
4953
  const activeChat = normalizeActiveChatData(ext.activeChat, getActiveChatOptions(profile));
4954
+ const summaryMetadata = normalizeProviderSummaryMetadata(ext.summaryMetadata);
4955
+ const controlValues = normalizeProviderStateControlValues(ext.controlValues);
4787
4956
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
4788
4957
  const includeSessionControls = shouldIncludeSessionControls(profile);
4789
4958
  return {
@@ -4799,11 +4968,10 @@ function buildExtensionAgentSession(parent, ext, options) {
4799
4968
  title: activeChat?.title || ext.name,
4800
4969
  ...includeSessionMetadata && { workspace: parent.workspace || null },
4801
4970
  activeChat,
4971
+ ...summaryMetadata && { summaryMetadata },
4802
4972
  ...includeSessionMetadata && { capabilities: EXTENSION_SESSION_CAPABILITIES },
4803
- currentModel: ext.currentModel,
4804
- currentPlan: ext.currentPlan,
4805
4973
  ...includeSessionControls && {
4806
- controlValues: ext.controlValues,
4974
+ ...controlValues && { controlValues },
4807
4975
  providerControls: ext.providerControls
4808
4976
  },
4809
4977
  errorMessage: ext.errorMessage,
@@ -4814,6 +4982,8 @@ function buildExtensionAgentSession(parent, ext, options) {
4814
4982
  function buildCliSession(state, options) {
4815
4983
  const profile = options.profile || "full";
4816
4984
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
4985
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
4986
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
4817
4987
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
4818
4988
  const includeRuntimeMetadata = shouldIncludeRuntimeMetadata(profile);
4819
4989
  const includeSessionControls = shouldIncludeSessionControls(profile);
@@ -4840,11 +5010,12 @@ function buildCliSession(state, options) {
4840
5010
  mode: state.mode,
4841
5011
  resume: state.resume,
4842
5012
  activeChat,
5013
+ ...summaryMetadata && { summaryMetadata },
4843
5014
  ...includeSessionMetadata && {
4844
5015
  capabilities: state.mode === "terminal" ? PTY_SESSION_CAPABILITIES : CLI_CHAT_SESSION_CAPABILITIES
4845
5016
  },
4846
5017
  ...includeSessionControls && {
4847
- controlValues: state.controlValues,
5018
+ ...controlValues && { controlValues },
4848
5019
  providerControls: state.providerControls
4849
5020
  },
4850
5021
  errorMessage: state.errorMessage,
@@ -4855,6 +5026,8 @@ function buildCliSession(state, options) {
4855
5026
  function buildAcpSession(state, options) {
4856
5027
  const profile = options.profile || "full";
4857
5028
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
5029
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
5030
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
4858
5031
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
4859
5032
  const includeSessionControls = shouldIncludeSessionControls(profile);
4860
5033
  return {
@@ -4870,13 +5043,10 @@ function buildAcpSession(state, options) {
4870
5043
  title: activeChat?.title || state.name,
4871
5044
  ...includeSessionMetadata && { workspace: state.workspace || null },
4872
5045
  activeChat,
5046
+ ...summaryMetadata && { summaryMetadata },
4873
5047
  ...includeSessionMetadata && { capabilities: ACP_SESSION_CAPABILITIES },
4874
- currentModel: state.currentModel,
4875
- currentPlan: state.currentPlan,
4876
5048
  ...includeSessionControls && {
4877
- acpConfigOptions: state.acpConfigOptions,
4878
- acpModes: state.acpModes,
4879
- controlValues: state.controlValues,
5049
+ ...controlValues && { controlValues },
4880
5050
  providerControls: state.providerControls
4881
5051
  },
4882
5052
  errorMessage: state.errorMessage,
@@ -4916,6 +5086,8 @@ var init_builders = __esm({
4916
5086
  "../../oss/packages/daemon-core/src/status/builders.ts"() {
4917
5087
  "use strict";
4918
5088
  init_normalize();
5089
+ init_provider_patch_state();
5090
+ init_summary_metadata();
4919
5091
  IDE_SESSION_CAPABILITIES = [
4920
5092
  "read_chat",
4921
5093
  "send_message",
@@ -7031,8 +7203,17 @@ async function handleSetProviderSourceConfig(h, args) {
7031
7203
  );
7032
7204
  return { success: true, reloaded: true, ...sourceConfig };
7033
7205
  }
7034
- function normalizeProviderScriptArgs(args) {
7206
+ function normalizeProviderScriptArgs(args, scriptName) {
7035
7207
  const normalizedArgs = { ...args || {} };
7208
+ const normalizedScriptName = String(scriptName || "").toLowerCase();
7209
+ if (Object.prototype.hasOwnProperty.call(normalizedArgs, "value")) {
7210
+ if (normalizedArgs.model === void 0 && (normalizedScriptName === "setmodel" || normalizedScriptName === "setmodelgui" || normalizedScriptName === "webviewsetmodel")) {
7211
+ normalizedArgs.model = normalizedArgs.value;
7212
+ }
7213
+ if (normalizedArgs.mode === void 0 && (normalizedScriptName === "setmode" || normalizedScriptName === "webviewsetmode")) {
7214
+ normalizedArgs.mode = normalizedArgs.value;
7215
+ }
7216
+ }
7036
7217
  for (const key of ["mode", "model", "message", "action", "button", "text", "sessionId", "value"]) {
7037
7218
  if (key in normalizedArgs && !(key.toUpperCase() in normalizedArgs)) {
7038
7219
  normalizedArgs[key.toUpperCase()] = normalizedArgs[key];
@@ -7078,7 +7259,7 @@ async function executeProviderScript(h, args, scriptName) {
7078
7259
  if (!provider.scripts?.[actualScriptName]) {
7079
7260
  return { success: false, error: `Script '${actualScriptName}' not available for ${resolvedProviderType}` };
7080
7261
  }
7081
- const normalizedArgs = normalizeProviderScriptArgs(args);
7262
+ const normalizedArgs = normalizeProviderScriptArgs(args, actualScriptName);
7082
7263
  if (provider.category === "cli") {
7083
7264
  const adapter = h.getCliAdapter(args?.targetSessionId || resolvedProviderType);
7084
7265
  if (!adapter?.invokeScript) {
@@ -11213,6 +11394,7 @@ var init_cli_provider_instance = __esm({
11213
11394
  init_control_effects();
11214
11395
  init_approval_utils();
11215
11396
  init_cli_script_results();
11397
+ init_provider_patch_state();
11216
11398
  CachedDatabaseSync = null;
11217
11399
  CliProviderInstance = class {
11218
11400
  constructor(provider, workingDir, cliArgs = [], instanceId, transportFactory, options) {
@@ -11242,6 +11424,7 @@ var init_cli_provider_instance = __esm({
11242
11424
  generatingDebouncePending = null;
11243
11425
  lastApprovalEventAt = 0;
11244
11426
  controlValues = {};
11427
+ summaryMetadata = void 0;
11245
11428
  appliedEffectKeys = /* @__PURE__ */ new Set();
11246
11429
  historyWriter;
11247
11430
  runtimeMessages = [];
@@ -11384,13 +11567,7 @@ var init_cli_provider_instance = __esm({
11384
11567
  if (historyMessageCount !== null) {
11385
11568
  parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
11386
11569
  }
11387
- const controlValues = extractProviderControlValues(this.provider.controls, parsedStatus);
11388
- if (controlValues) {
11389
- this.controlValues = { ...this.controlValues, ...controlValues };
11390
- }
11391
11570
  const mergedMessages = this.mergeConversationMessages(parsedMessages);
11392
- 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;
11393
- 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;
11394
11571
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
11395
11572
  if (parsedMessages.length > 0) {
11396
11573
  const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
@@ -11412,6 +11589,10 @@ var init_cli_provider_instance = __esm({
11412
11589
  }
11413
11590
  }
11414
11591
  this.applyProviderResponse(parsedStatus, { phase: "immediate" });
11592
+ const surface = resolveProviderStateSurface({
11593
+ summaryMetadata: this.summaryMetadata,
11594
+ controlValues: this.controlValues
11595
+ });
11415
11596
  return {
11416
11597
  type: this.type,
11417
11598
  name: this.provider.name,
@@ -11427,8 +11608,6 @@ var init_cli_provider_instance = __esm({
11427
11608
  inputContent: ""
11428
11609
  },
11429
11610
  workspace: this.workingDir,
11430
- currentModel,
11431
- currentPlan,
11432
11611
  instanceId: this.instanceId,
11433
11612
  providerSessionId: this.providerSessionId,
11434
11613
  lastUpdated: Date.now(),
@@ -11443,8 +11622,9 @@ var init_cli_provider_instance = __esm({
11443
11622
  attachedClients: runtime.attachedClients || []
11444
11623
  } : void 0,
11445
11624
  resume: this.provider.resume,
11446
- controlValues: this.controlValues,
11447
- providerControls: this.provider.controls
11625
+ controlValues: surface.controlValues,
11626
+ providerControls: this.provider.controls,
11627
+ summaryMetadata: surface.summaryMetadata
11448
11628
  };
11449
11629
  }
11450
11630
  setPresentationMode(mode) {
@@ -11648,10 +11828,14 @@ var init_cli_provider_instance = __esm({
11648
11828
  this.suppressIdleHistoryReplay = false;
11649
11829
  this.adapter.clearHistory();
11650
11830
  }
11651
- const controlValues = extractProviderControlValues(this.provider.controls, data);
11652
- if (controlValues) {
11653
- this.controlValues = { ...this.controlValues, ...controlValues };
11654
- }
11831
+ const patchedState = mergeProviderPatchState({
11832
+ providerControls: this.provider.controls,
11833
+ data,
11834
+ currentControlValues: this.controlValues,
11835
+ currentSummaryMetadata: this.summaryMetadata
11836
+ });
11837
+ this.controlValues = patchedState.controlValues;
11838
+ this.summaryMetadata = patchedState.summaryMetadata;
11655
11839
  const effects = normalizeProviderEffects(data);
11656
11840
  for (const effect of effects) {
11657
11841
  const effectWhen = effect.when || "immediate";
@@ -28298,6 +28482,7 @@ var init_acp_provider_instance = __esm({
28298
28482
  init_acp();
28299
28483
  init_contracts();
28300
28484
  init_status_monitor();
28485
+ init_summary_metadata();
28301
28486
  init_logger();
28302
28487
  AcpProviderInstance = class {
28303
28488
  constructor(provider, workingDir, cliArgs = []) {
@@ -28326,8 +28511,7 @@ var init_acp_provider_instance = __esm({
28326
28511
  lastStatus = "starting";
28327
28512
  generatingStartedAt = 0;
28328
28513
  agentCapabilities = {};
28329
- currentModel;
28330
- currentMode;
28514
+ currentSelections = {};
28331
28515
  activeToolCalls = [];
28332
28516
  stopReason = null;
28333
28517
  partialContent = "";
@@ -28407,8 +28591,6 @@ var init_acp_provider_instance = __esm({
28407
28591
  inputContent: ""
28408
28592
  },
28409
28593
  workspace: this.workingDir,
28410
- currentModel: this.currentModel,
28411
- currentPlan: this.currentMode,
28412
28594
  instanceId: this.instanceId,
28413
28595
  lastUpdated: Date.now(),
28414
28596
  settings: this.settings,
@@ -28419,11 +28601,9 @@ var init_acp_provider_instance = __esm({
28419
28601
  // Error details for dashboard display
28420
28602
  errorMessage: this.errorMessage || void 0,
28421
28603
  errorReason: this.errorReason || void 0,
28422
- controlValues: {
28423
- ...this.currentModel ? { model: this.currentModel } : {},
28424
- ...this.currentMode ? { mode: this.currentMode } : {}
28425
- },
28426
- providerControls: this.provider.controls
28604
+ controlValues: this.getSelectionControlValues(),
28605
+ providerControls: this.provider.controls,
28606
+ summaryMetadata: this.buildSelectionSummaryMetadata()
28427
28607
  };
28428
28608
  }
28429
28609
  onEvent(event, data) {
@@ -28457,6 +28637,54 @@ var init_acp_provider_instance = __esm({
28457
28637
  getInstanceId() {
28458
28638
  return this.instanceId;
28459
28639
  }
28640
+ resolveConfigOptionLabel(category, value) {
28641
+ if (!value) return void 0;
28642
+ const option = this.configOptions.find((entry) => entry.category === category);
28643
+ return option?.options.find((candidate) => candidate.value === value)?.name || value;
28644
+ }
28645
+ resolveModeLabel(modeId) {
28646
+ if (!modeId) return void 0;
28647
+ return this.availableModes.find((mode) => mode.id === modeId)?.name || modeId;
28648
+ }
28649
+ getCurrentSelection(category) {
28650
+ return this.currentSelections[category];
28651
+ }
28652
+ setCurrentSelection(category, value) {
28653
+ const normalized = typeof value === "string" ? value.trim() : "";
28654
+ if (normalized) {
28655
+ this.currentSelections[category] = normalized;
28656
+ return;
28657
+ }
28658
+ delete this.currentSelections[category];
28659
+ }
28660
+ getSelectionControlValues() {
28661
+ const model = this.getCurrentSelection("model");
28662
+ const mode = this.getCurrentSelection("mode");
28663
+ return {
28664
+ ...model ? { model } : {},
28665
+ ...mode ? { mode } : {}
28666
+ };
28667
+ }
28668
+ resolveSelectionLabel(category, value) {
28669
+ if (!value) return void 0;
28670
+ const configLabel = this.resolveConfigOptionLabel(category, value);
28671
+ if (configLabel && configLabel !== value) return configLabel;
28672
+ if (category === "mode") {
28673
+ const modeLabel = this.resolveModeLabel(value);
28674
+ if (modeLabel) return modeLabel;
28675
+ }
28676
+ return configLabel || value;
28677
+ }
28678
+ buildSelectionSummaryMetadata() {
28679
+ const model = this.getCurrentSelection("model");
28680
+ const mode = this.getCurrentSelection("mode");
28681
+ return buildLegacyModelModeSummaryMetadata({
28682
+ model,
28683
+ mode,
28684
+ modelLabel: this.resolveSelectionLabel("model", model),
28685
+ modeLabel: this.resolveSelectionLabel("mode", mode)
28686
+ });
28687
+ }
28460
28688
  // ─── ACP Config Options & Modes ─────────────────────
28461
28689
  parseConfigOptions(raw) {
28462
28690
  if (!Array.isArray(raw)) return;
@@ -28488,12 +28716,14 @@ var init_acp_provider_instance = __esm({
28488
28716
  }
28489
28717
  }
28490
28718
  this.configOptions.push({ category, configId, currentValue, options: flatOptions });
28491
- if (category === "model" && currentValue) this.currentModel = currentValue;
28719
+ if (category === "model" || category === "mode") {
28720
+ this.setCurrentSelection(category, currentValue);
28721
+ }
28492
28722
  }
28493
28723
  }
28494
28724
  parseModes(raw) {
28495
28725
  if (!raw) return;
28496
- if (raw.currentModeId) this.currentMode = raw.currentModeId;
28726
+ this.setCurrentSelection("mode", raw.currentModeId);
28497
28727
  if (Array.isArray(raw.availableModes)) {
28498
28728
  this.availableModes = raw.availableModes.map((m) => ({
28499
28729
  id: m.id,
@@ -28512,8 +28742,7 @@ var init_acp_provider_instance = __esm({
28512
28742
  if (this.useStaticConfig) {
28513
28743
  opt.currentValue = value;
28514
28744
  this.selectedConfig[opt.configId] = value;
28515
- if (category === "model") this.currentModel = value;
28516
- if (category === "mode") this.currentMode = value;
28745
+ if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
28517
28746
  this.log.info(`[${this.type}] Static config ${category} set to: ${value} \u2014 restarting agent`);
28518
28747
  await this.restartWithNewConfig();
28519
28748
  return;
@@ -28531,7 +28760,7 @@ var init_acp_provider_instance = __esm({
28531
28760
  value
28532
28761
  });
28533
28762
  opt.currentValue = value;
28534
- if (category === "model") this.currentModel = value;
28763
+ if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
28535
28764
  if (result?.configOptions) this.parseConfigOptions(result.configOptions);
28536
28765
  this.log.info(`[${this.type}] Config ${category} set to: ${value} | response: ${JSON.stringify(result)?.slice(0, 300)}`);
28537
28766
  } catch (e) {
@@ -28547,7 +28776,7 @@ var init_acp_provider_instance = __esm({
28547
28776
  opt.currentValue = modeId;
28548
28777
  this.selectedConfig[opt.configId] = modeId;
28549
28778
  }
28550
- this.currentMode = modeId;
28779
+ this.setCurrentSelection("mode", modeId);
28551
28780
  this.log.info(`[${this.type}] Static mode set to: ${modeId} \u2014 restarting agent`);
28552
28781
  await this.restartWithNewConfig();
28553
28782
  return;
@@ -28562,7 +28791,7 @@ var init_acp_provider_instance = __esm({
28562
28791
  sessionId: this.sessionId,
28563
28792
  modeId
28564
28793
  });
28565
- this.currentMode = modeId;
28794
+ this.setCurrentSelection("mode", modeId);
28566
28795
  this.log.info(`[${this.type}] Mode set to: ${modeId}`);
28567
28796
  } catch (e) {
28568
28797
  const message = e?.message || "Unknown ACP mode error";
@@ -28820,8 +29049,8 @@ var init_acp_provider_instance = __esm({
28820
29049
  if (result?.modes) this.log.debug(`[${this.type}] modes: ${JSON.stringify(result.modes).slice(0, 300)}`);
28821
29050
  this.parseConfigOptions(result?.configOptions);
28822
29051
  this.parseModes(result?.modes);
28823
- if (!this.currentModel && result?.models?.currentModelId) {
28824
- this.currentModel = result.models.currentModelId;
29052
+ if (!this.getCurrentSelection("model") && result?.models?.currentModelId) {
29053
+ this.setCurrentSelection("model", result.models.currentModelId);
28825
29054
  }
28826
29055
  if (this.configOptions.length === 0 && this.provider.staticConfigOptions?.length) {
28827
29056
  this.useStaticConfig = true;
@@ -28835,13 +29064,16 @@ var init_acp_provider_instance = __esm({
28835
29064
  });
28836
29065
  if (defaultVal) {
28837
29066
  this.selectedConfig[sc.configId] = defaultVal;
28838
- if (sc.category === "model") this.currentModel = defaultVal;
28839
- if (sc.category === "mode") this.currentMode = defaultVal;
29067
+ if (sc.category === "model" || sc.category === "mode") {
29068
+ this.setCurrentSelection(sc.category, defaultVal);
29069
+ }
28840
29070
  }
28841
29071
  }
28842
29072
  this.log.info(`[${this.type}] Using static configOptions (${this.configOptions.length} options)`);
28843
29073
  }
28844
- this.log.info(`[${this.type}] Session created: ${this.sessionId}${this.currentModel ? ` (model: ${this.currentModel})` : ""}${this.currentMode ? ` (mode: ${this.currentMode})` : ""}`);
29074
+ const currentModel = this.getCurrentSelection("model");
29075
+ const currentMode = this.getCurrentSelection("mode");
29076
+ this.log.info(`[${this.type}] Session created: ${this.sessionId}${currentModel ? ` (model: ${currentModel})` : ""}${currentMode ? ` (mode: ${currentMode})` : ""}`);
28845
29077
  if (this.configOptions.length > 0) {
28846
29078
  this.log.info(`[${this.type}] Config options: ${this.configOptions.map((c) => `${c.category}(${c.options.length})`).join(", ")}`);
28847
29079
  }
@@ -29016,7 +29248,7 @@ var init_acp_provider_instance = __esm({
29016
29248
  break;
29017
29249
  }
29018
29250
  case "current_mode_update": {
29019
- this.currentMode = update.currentModeId;
29251
+ this.setCurrentSelection("mode", update.currentModeId);
29020
29252
  break;
29021
29253
  }
29022
29254
  case "config_option_update": {
@@ -29089,7 +29321,7 @@ var init_acp_provider_instance = __esm({
29089
29321
  this.detectStatusTransition();
29090
29322
  }
29091
29323
  if (params.model) {
29092
- this.currentModel = params.model;
29324
+ this.setCurrentSelection("model", params.model);
29093
29325
  }
29094
29326
  }
29095
29327
  /** Map SDK ToolCallStatus to internal status */
@@ -29371,6 +29603,7 @@ var init_cli_manager = __esm({
29371
29603
  init_workspaces();
29372
29604
  init_recent_activity();
29373
29605
  init_saved_sessions();
29606
+ init_summary_metadata();
29374
29607
  init_cli_provider_instance();
29375
29608
  init_acp_provider_instance();
29376
29609
  init_contracts();
@@ -29402,7 +29635,11 @@ var init_cli_manager = __esm({
29402
29635
  }
29403
29636
  persistRecentActivity(entry) {
29404
29637
  try {
29405
- let nextState = appendRecentActivity(loadState(), entry);
29638
+ const summaryMetadata = normalizeProviderSummaryMetadata(entry.summaryMetadata);
29639
+ let nextState = appendRecentActivity(loadState(), {
29640
+ ...entry,
29641
+ summaryMetadata
29642
+ });
29406
29643
  if (entry.providerSessionId && (entry.kind === "cli" || entry.kind === "acp")) {
29407
29644
  nextState = upsertSavedProviderSession(nextState, {
29408
29645
  kind: entry.kind,
@@ -29410,7 +29647,7 @@ var init_cli_manager = __esm({
29410
29647
  providerName: entry.providerName,
29411
29648
  providerSessionId: entry.providerSessionId,
29412
29649
  workspace: entry.workspace,
29413
- currentModel: entry.currentModel,
29650
+ summaryMetadata,
29414
29651
  title: entry.title
29415
29652
  });
29416
29653
  }
@@ -29600,7 +29837,7 @@ ${installInfo}`
29600
29837
  providerType: normalizedType,
29601
29838
  providerName: provider.displayName || provider.name || normalizedType,
29602
29839
  workspace: resolvedDir,
29603
- currentModel: initialModel,
29840
+ summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
29604
29841
  sessionId,
29605
29842
  title: provider.displayName || provider.name || normalizedType
29606
29843
  });
@@ -29702,7 +29939,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
29702
29939
  providerName: provider?.displayName || provider?.name || normalizedType,
29703
29940
  providerSessionId: sessionBinding.providerSessionId,
29704
29941
  workspace: resolvedDir,
29705
- currentModel: initialModel,
29942
+ summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
29706
29943
  sessionId: key,
29707
29944
  title: provider?.displayName || provider?.name || normalizedType
29708
29945
  });
@@ -33635,7 +33872,90 @@ var init_command_log = __esm({
33635
33872
  }
33636
33873
  });
33637
33874
 
33875
+ // ../../oss/packages/daemon-core/src/session-host/runtime-surface.ts
33876
+ function isSessionHostLiveRuntime(record2) {
33877
+ const lifecycle = String(record2?.lifecycle || "").trim();
33878
+ return LIVE_LIFECYCLES.has(lifecycle);
33879
+ }
33880
+ function getSessionHostRecoveryLabel(meta3) {
33881
+ const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
33882
+ if (!recoveryState) return null;
33883
+ if (recoveryState === "auto_resumed") return "restored after restart";
33884
+ if (recoveryState === "resume_failed") return "restore failed";
33885
+ if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
33886
+ if (recoveryState === "orphan_snapshot") return "snapshot recovered";
33887
+ return recoveryState.replace(/_/g, " ");
33888
+ }
33889
+ function isSessionHostRecoverySnapshot(record2) {
33890
+ if (!record2) return false;
33891
+ if (isSessionHostLiveRuntime(record2)) return false;
33892
+ const lifecycle = String(record2.lifecycle || "").trim();
33893
+ if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
33894
+ return false;
33895
+ }
33896
+ const meta3 = record2.meta || void 0;
33897
+ if (meta3?.restoredFromStorage === true) return true;
33898
+ return getSessionHostRecoveryLabel(meta3) !== null;
33899
+ }
33900
+ function getSessionHostSurfaceKind(record2) {
33901
+ if (isSessionHostLiveRuntime(record2)) return "live_runtime";
33902
+ if (isSessionHostRecoverySnapshot(record2)) return "recovery_snapshot";
33903
+ return "inactive_record";
33904
+ }
33905
+ function partitionSessionHostRecords(records) {
33906
+ const liveRuntimes = [];
33907
+ const recoverySnapshots = [];
33908
+ const inactiveRecords = [];
33909
+ for (const record2 of records) {
33910
+ const kind = getSessionHostSurfaceKind(record2);
33911
+ if (kind === "live_runtime") {
33912
+ liveRuntimes.push(record2);
33913
+ } else if (kind === "recovery_snapshot") {
33914
+ recoverySnapshots.push(record2);
33915
+ } else {
33916
+ inactiveRecords.push(record2);
33917
+ }
33918
+ }
33919
+ return {
33920
+ liveRuntimes,
33921
+ recoverySnapshots,
33922
+ inactiveRecords
33923
+ };
33924
+ }
33925
+ function partitionSessionHostDiagnosticsSessions(records) {
33926
+ return partitionSessionHostRecords(records || []);
33927
+ }
33928
+ var LIVE_LIFECYCLES;
33929
+ var init_runtime_surface = __esm({
33930
+ "../../oss/packages/daemon-core/src/session-host/runtime-surface.ts"() {
33931
+ "use strict";
33932
+ LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
33933
+ }
33934
+ });
33935
+
33638
33936
  // ../../oss/packages/daemon-core/src/status/snapshot.ts
33937
+ function buildRecentReadDebugSignature(snapshot) {
33938
+ return [
33939
+ snapshot.providerType,
33940
+ snapshot.status,
33941
+ snapshot.inboxBucket,
33942
+ snapshot.unread ? "1" : "0",
33943
+ String(snapshot.lastSeenAt),
33944
+ snapshot.completionMarker,
33945
+ snapshot.seenCompletionMarker,
33946
+ String(snapshot.lastUpdated),
33947
+ String(snapshot.lastUsedAt),
33948
+ snapshot.lastRole,
33949
+ String(snapshot.messageUpdatedAt)
33950
+ ].join("|");
33951
+ }
33952
+ function shouldEmitRecentReadDebugLog(cache, snapshot) {
33953
+ const nextSignature = buildRecentReadDebugSignature(snapshot);
33954
+ const previousSignature = cache.get(snapshot.sessionId);
33955
+ if (previousSignature === nextSignature) return false;
33956
+ cache.set(snapshot.sessionId, nextSignature);
33957
+ return true;
33958
+ }
33639
33959
  function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
33640
33960
  return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
33641
33961
  id: ide.id,
@@ -33787,7 +34107,7 @@ function buildRecentLaunches(recentActivity) {
33787
34107
  providerSessionId: item.providerSessionId,
33788
34108
  title: item.title || item.providerName,
33789
34109
  workspace: item.workspace,
33790
- currentModel: item.currentModel,
34110
+ summaryMetadata: item.summaryMetadata,
33791
34111
  lastLaunchedAt: item.lastUsedAt
33792
34112
  })).sort((a, b) => b.lastLaunchedAt - a.lastLaunchedAt).slice(0, 12);
33793
34113
  }
@@ -33828,9 +34148,24 @@ function buildStatusSnapshot(options) {
33828
34148
  session.unread = unread;
33829
34149
  session.inboxBucket = inboxBucket;
33830
34150
  if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
34151
+ const recentReadSnapshot = {
34152
+ sessionId: session.id,
34153
+ providerType: session.providerType,
34154
+ status: String(session.status || ""),
34155
+ inboxBucket,
34156
+ unread,
34157
+ lastSeenAt,
34158
+ completionMarker: completionMarker || "-",
34159
+ seenCompletionMarker: seenCompletionMarker || "-",
34160
+ lastUpdated: Number(session.lastUpdated || 0),
34161
+ lastUsedAt,
34162
+ lastRole: getLastMessageRole(sourceSession),
34163
+ messageUpdatedAt: getSessionMessageUpdatedAt(sourceSession)
34164
+ };
34165
+ if (!shouldEmitRecentReadDebugLog(recentReadDebugSignatureBySession, recentReadSnapshot)) continue;
33831
34166
  LOG.info(
33832
34167
  "RecentRead",
33833
- `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)}`
34168
+ `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}`
33834
34169
  );
33835
34170
  }
33836
34171
  const lastDisplayMessage = getLastDisplayMessage(sourceSession);
@@ -33863,7 +34198,7 @@ function buildStatusSnapshot(options) {
33863
34198
  }
33864
34199
  };
33865
34200
  }
33866
- var os18, READ_DEBUG_ENABLED;
34201
+ var os18, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession;
33867
34202
  var init_snapshot = __esm({
33868
34203
  "../../oss/packages/daemon-core/src/status/snapshot.ts"() {
33869
34204
  "use strict";
@@ -33877,6 +34212,7 @@ var init_snapshot = __esm({
33877
34212
  init_logger();
33878
34213
  init_builders();
33879
34214
  READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
34215
+ recentReadDebugSignatureBySession = /* @__PURE__ */ new Map();
33880
34216
  }
33881
34217
  });
33882
34218
 
@@ -34118,6 +34454,49 @@ function toHostedCliRuntimeDescriptor(record2) {
34118
34454
  providerSessionId: typeof record2.meta?.providerSessionId === "string" ? String(record2.meta.providerSessionId) : void 0
34119
34455
  };
34120
34456
  }
34457
+ function getWriteConflictOwnerClientId(error48) {
34458
+ const message = typeof error48 === "string" ? error48 : error48 instanceof Error ? error48.message : "";
34459
+ const match = /^Write owned by\s+(.+)$/.exec(message.trim());
34460
+ return match?.[1]?.trim() || void 0;
34461
+ }
34462
+ function summarizeSessionHostRecord(result) {
34463
+ if (!result || typeof result !== "object") return {};
34464
+ const record2 = result;
34465
+ return {
34466
+ runtimeKey: typeof record2.runtimeKey === "string" ? record2.runtimeKey : void 0,
34467
+ lifecycle: typeof record2.lifecycle === "string" ? record2.lifecycle : void 0,
34468
+ surfaceKind: getSessionHostSurfaceKind(record2),
34469
+ attachedClientCount: Array.isArray(record2.attachedClients) ? record2.attachedClients.length : void 0,
34470
+ hasWriteOwner: !!record2.writeOwner,
34471
+ writeOwnerClientId: typeof record2.writeOwner?.clientId === "string" ? record2.writeOwner.clientId : void 0
34472
+ };
34473
+ }
34474
+ function summarizeSessionHostRecords(result) {
34475
+ const records = Array.isArray(result) ? result : [];
34476
+ const groups = partitionSessionHostRecords(records);
34477
+ return {
34478
+ sessionCount: records.length,
34479
+ liveRuntimeCount: groups.liveRuntimes.length,
34480
+ recoverySnapshotCount: groups.recoverySnapshots.length,
34481
+ inactiveRecordCount: groups.inactiveRecords.length
34482
+ };
34483
+ }
34484
+ function summarizeSessionHostDiagnostics(result) {
34485
+ const diagnostics = result && typeof result === "object" ? result : {};
34486
+ const sessions = Array.isArray(diagnostics.sessions) ? diagnostics.sessions : [];
34487
+ return {
34488
+ runtimeCount: typeof diagnostics.runtimeCount === "number" ? diagnostics.runtimeCount : void 0,
34489
+ ...summarizeSessionHostRecords(sessions)
34490
+ };
34491
+ }
34492
+ function summarizeSessionHostPruneResult(result) {
34493
+ const value = result && typeof result === "object" ? result : {};
34494
+ return {
34495
+ duplicateGroupCount: typeof value.duplicateGroupCount === "number" ? value.duplicateGroupCount : void 0,
34496
+ prunedCount: Array.isArray(value.prunedSessionIds) ? value.prunedSessionIds.length : void 0,
34497
+ keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
34498
+ };
34499
+ }
34121
34500
  var fs9, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
34122
34501
  var init_router = __esm({
34123
34502
  "../../oss/packages/daemon-core/src/commands/router.ts"() {
@@ -34137,6 +34516,7 @@ var init_router = __esm({
34137
34516
  init_command_log();
34138
34517
  init_logger();
34139
34518
  init_debug_trace();
34519
+ init_runtime_surface();
34140
34520
  init_builders();
34141
34521
  init_snapshot();
34142
34522
  init_snapshot();
@@ -34155,6 +34535,56 @@ var init_router = __esm({
34155
34535
  constructor(deps) {
34156
34536
  this.deps = deps;
34157
34537
  }
34538
+ async traceSessionHostAction(action, args, run, summarizeResult) {
34539
+ const interactionId = typeof args?._interactionId === "string" ? args._interactionId : void 0;
34540
+ const sessionId = typeof args?.sessionId === "string" ? args.sessionId : void 0;
34541
+ const requestedPayload = { action };
34542
+ if (sessionId) requestedPayload.sessionId = sessionId;
34543
+ if (typeof args?.clientId === "string") requestedPayload.clientId = args.clientId;
34544
+ if (typeof args?.signal === "string") requestedPayload.signal = args.signal;
34545
+ if (typeof args?.providerType === "string") requestedPayload.providerType = args.providerType;
34546
+ if (typeof args?.workspace === "string") requestedPayload.workspace = args.workspace;
34547
+ if (typeof args?.dryRun === "boolean") requestedPayload.dryRun = args.dryRun;
34548
+ recordDebugTrace({
34549
+ interactionId,
34550
+ category: "session_host",
34551
+ stage: "action_requested",
34552
+ level: "info",
34553
+ sessionId,
34554
+ payload: requestedPayload
34555
+ });
34556
+ try {
34557
+ const result = await run();
34558
+ recordDebugTrace({
34559
+ interactionId,
34560
+ category: "session_host",
34561
+ stage: "action_result",
34562
+ level: "info",
34563
+ sessionId,
34564
+ payload: {
34565
+ ...requestedPayload,
34566
+ success: true,
34567
+ ...summarizeResult ? summarizeResult(result) : {}
34568
+ }
34569
+ });
34570
+ return result;
34571
+ } catch (error48) {
34572
+ recordDebugTrace({
34573
+ interactionId,
34574
+ category: "session_host",
34575
+ stage: "action_failed",
34576
+ level: "error",
34577
+ sessionId,
34578
+ payload: {
34579
+ ...requestedPayload,
34580
+ error: error48?.message || String(error48),
34581
+ failureKind: getWriteConflictOwnerClientId(error48) ? "write_conflict" : "request_failed",
34582
+ conflictOwnerClientId: getWriteConflictOwnerClientId(error48)
34583
+ }
34584
+ });
34585
+ throw error48;
34586
+ }
34587
+ }
34158
34588
  /**
34159
34589
  * Unified command routing.
34160
34590
  * Returns result for all commands:
@@ -34264,44 +34694,60 @@ var init_router = __esm({
34264
34694
  }
34265
34695
  case "session_host_get_diagnostics": {
34266
34696
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
34267
- const diagnostics = await this.deps.sessionHostControl.getDiagnostics({
34697
+ const diagnostics = await this.traceSessionHostAction("session_host_get_diagnostics", args, () => this.deps.sessionHostControl.getDiagnostics({
34268
34698
  includeSessions: args?.includeSessions !== false,
34269
34699
  limit: Number(args?.limit) || void 0
34270
- });
34700
+ }), (result) => ({
34701
+ includeSessions: args?.includeSessions !== false,
34702
+ limit: Number(args?.limit) || void 0,
34703
+ ...summarizeSessionHostDiagnostics(result)
34704
+ }));
34271
34705
  return { success: true, diagnostics };
34272
34706
  }
34273
34707
  case "session_host_list_sessions": {
34274
34708
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
34275
- const sessions = await this.deps.sessionHostControl.listSessions();
34709
+ const sessions = await this.traceSessionHostAction("session_host_list_sessions", args, () => this.deps.sessionHostControl.listSessions(), (records) => summarizeSessionHostRecords(records));
34276
34710
  return { success: true, sessions };
34277
34711
  }
34278
34712
  case "session_host_stop_session": {
34279
34713
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
34280
34714
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
34281
34715
  if (!sessionId) return { success: false, error: "sessionId required" };
34282
- const record2 = await this.deps.sessionHostControl.stopSession(sessionId);
34716
+ const record2 = await this.traceSessionHostAction("session_host_stop_session", args, () => this.deps.sessionHostControl.stopSession(sessionId), (result) => summarizeSessionHostRecord(result));
34283
34717
  return { success: true, record: record2 };
34284
34718
  }
34285
34719
  case "session_host_resume_session": {
34286
34720
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
34287
34721
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
34288
34722
  if (!sessionId) return { success: false, error: "sessionId required" };
34289
- const record2 = await this.deps.sessionHostControl.resumeSession(sessionId);
34290
- const hosted = toHostedCliRuntimeDescriptor(record2);
34291
- if (hosted) {
34292
- await this.deps.cliManager.restoreHostedSessions([hosted]);
34293
- }
34723
+ const record2 = await this.traceSessionHostAction("session_host_resume_session", args, async () => {
34724
+ const nextRecord = await this.deps.sessionHostControl.resumeSession(sessionId);
34725
+ const hosted = toHostedCliRuntimeDescriptor(nextRecord);
34726
+ if (hosted) {
34727
+ await this.deps.cliManager.restoreHostedSessions([hosted]);
34728
+ }
34729
+ return nextRecord;
34730
+ }, (result) => ({
34731
+ ...summarizeSessionHostRecord(result),
34732
+ restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
34733
+ }));
34294
34734
  return { success: true, record: record2 };
34295
34735
  }
34296
34736
  case "session_host_restart_session": {
34297
34737
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
34298
34738
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
34299
34739
  if (!sessionId) return { success: false, error: "sessionId required" };
34300
- const record2 = await this.deps.sessionHostControl.restartSession(sessionId);
34301
- const hosted = toHostedCliRuntimeDescriptor(record2);
34302
- if (hosted) {
34303
- await this.deps.cliManager.restoreHostedSessions([hosted]);
34304
- }
34740
+ const record2 = await this.traceSessionHostAction("session_host_restart_session", args, async () => {
34741
+ const nextRecord = await this.deps.sessionHostControl.restartSession(sessionId);
34742
+ const hosted = toHostedCliRuntimeDescriptor(nextRecord);
34743
+ if (hosted) {
34744
+ await this.deps.cliManager.restoreHostedSessions([hosted]);
34745
+ }
34746
+ return nextRecord;
34747
+ }, (result) => ({
34748
+ ...summarizeSessionHostRecord(result),
34749
+ restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
34750
+ }));
34305
34751
  return { success: true, record: record2 };
34306
34752
  }
34307
34753
  case "session_host_send_signal": {
@@ -34310,7 +34756,7 @@ var init_router = __esm({
34310
34756
  const signal = typeof args?.signal === "string" ? args.signal : "";
34311
34757
  if (!sessionId) return { success: false, error: "sessionId required" };
34312
34758
  if (!signal) return { success: false, error: "signal required" };
34313
- const record2 = await this.deps.sessionHostControl.sendSignal(sessionId, signal);
34759
+ const record2 = await this.traceSessionHostAction("session_host_send_signal", args, () => this.deps.sessionHostControl.sendSignal(sessionId, signal), (result) => summarizeSessionHostRecord(result));
34314
34760
  return { success: true, record: record2 };
34315
34761
  }
34316
34762
  case "session_host_force_detach_client": {
@@ -34319,16 +34765,16 @@ var init_router = __esm({
34319
34765
  const clientId = typeof args?.clientId === "string" ? args.clientId : "";
34320
34766
  if (!sessionId) return { success: false, error: "sessionId required" };
34321
34767
  if (!clientId) return { success: false, error: "clientId required" };
34322
- const record2 = await this.deps.sessionHostControl.forceDetachClient(sessionId, clientId);
34768
+ const record2 = await this.traceSessionHostAction("session_host_force_detach_client", args, () => this.deps.sessionHostControl.forceDetachClient(sessionId, clientId), (result) => summarizeSessionHostRecord(result));
34323
34769
  return { success: true, record: record2 };
34324
34770
  }
34325
34771
  case "session_host_prune_duplicate_sessions": {
34326
34772
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
34327
- const result = await this.deps.sessionHostControl.pruneDuplicateSessions({
34773
+ const result = await this.traceSessionHostAction("session_host_prune_duplicate_sessions", args, () => this.deps.sessionHostControl.pruneDuplicateSessions({
34328
34774
  providerType: typeof args?.providerType === "string" ? args.providerType : void 0,
34329
34775
  workspace: typeof args?.workspace === "string" ? args.workspace : void 0,
34330
34776
  dryRun: args?.dryRun === true
34331
- });
34777
+ }), (value) => summarizeSessionHostPruneResult(value));
34332
34778
  return { success: true, result };
34333
34779
  }
34334
34780
  case "session_host_acquire_write": {
@@ -34338,12 +34784,15 @@ var init_router = __esm({
34338
34784
  const ownerType = args?.ownerType === "agent" ? "agent" : "user";
34339
34785
  if (!sessionId) return { success: false, error: "sessionId required" };
34340
34786
  if (!clientId) return { success: false, error: "clientId required" };
34341
- const record2 = await this.deps.sessionHostControl.acquireWrite({
34787
+ const record2 = await this.traceSessionHostAction("session_host_acquire_write", args, () => this.deps.sessionHostControl.acquireWrite({
34342
34788
  sessionId,
34343
34789
  clientId,
34344
34790
  ownerType,
34345
34791
  force: args?.force !== false
34346
- });
34792
+ }), (result) => ({
34793
+ ...summarizeSessionHostRecord(result),
34794
+ ownerType
34795
+ }));
34347
34796
  return { success: true, record: record2 };
34348
34797
  }
34349
34798
  case "session_host_release_write": {
@@ -34352,7 +34801,10 @@ var init_router = __esm({
34352
34801
  const clientId = typeof args?.clientId === "string" ? args.clientId : "";
34353
34802
  if (!sessionId) return { success: false, error: "sessionId required" };
34354
34803
  if (!clientId) return { success: false, error: "clientId required" };
34355
- const record2 = await this.deps.sessionHostControl.releaseWrite({ sessionId, clientId });
34804
+ const record2 = await this.traceSessionHostAction("session_host_release_write", args, () => this.deps.sessionHostControl.releaseWrite({
34805
+ sessionId,
34806
+ clientId
34807
+ }), (result) => summarizeSessionHostRecord(result));
34356
34808
  return { success: true, record: record2 };
34357
34809
  }
34358
34810
  case "list_saved_sessions": {
@@ -34385,7 +34837,7 @@ var init_router = __esm({
34385
34837
  kind: saved?.kind || recent?.kind || kind,
34386
34838
  title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
34387
34839
  workspace: saved?.workspace || recent?.workspace || session.workspace,
34388
- currentModel: saved?.currentModel || recent?.currentModel,
34840
+ summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
34389
34841
  preview: session.preview,
34390
34842
  messageCount: session.messageCount,
34391
34843
  firstMessageAt: session.firstMessageAt,
@@ -34832,7 +35284,7 @@ var init_reporter = __esm({
34832
35284
  const ideSummary = ideStates.map((s) => {
34833
35285
  const msgs = s.activeChat?.messages?.length || 0;
34834
35286
  const exts = s.extensions.length;
34835
- return `${s.type}(${s.status},${msgs}msg,${exts}ext${s.currentModel ? ",model=" + s.currentModel : ""})`;
35287
+ return `${s.type}(${s.status},${msgs}msg,${exts}ext)`;
34836
35288
  }).join(", ");
34837
35289
  const cliSummary = cliStates.map((s) => `${s.type}(${s.status})`).join(", ");
34838
35290
  const acpSummary = acpStates.map((s) => `${s.type}(${s.status})`).join(", ");
@@ -34894,9 +35346,7 @@ var init_reporter = __esm({
34894
35346
  workspace: session.workspace ?? null,
34895
35347
  title: session.title,
34896
35348
  cdpConnected: session.cdpConnected,
34897
- currentModel: session.currentModel,
34898
- currentPlan: session.currentPlan,
34899
- currentAutoApprove: session.currentAutoApprove
35349
+ summaryMetadata: session.summaryMetadata
34900
35350
  })),
34901
35351
  p2p: payload.p2p,
34902
35352
  timestamp: now
@@ -34961,6 +35411,7 @@ var init_provider_adapter = __esm({
34961
35411
  "../../oss/packages/daemon-core/src/agent-stream/provider-adapter.ts"() {
34962
35412
  "use strict";
34963
35413
  init_control_effects();
35414
+ init_provider_patch_state();
34964
35415
  ProviderStreamAdapter = class {
34965
35416
  agentType;
34966
35417
  agentName;
@@ -35072,15 +35523,18 @@ var init_provider_adapter = __esm({
35072
35523
  status: data.status || "idle",
35073
35524
  messages: data.messages || [],
35074
35525
  inputContent: data.inputContent || "",
35075
- model: data.model,
35076
- mode: data.mode,
35077
35526
  activeModal: data.activeModal
35078
35527
  };
35079
35528
  if (typeof data.title === "string" && data.title.trim()) {
35080
35529
  state.title = data.title.trim();
35081
35530
  }
35082
35531
  const controlValues = extractProviderControlValues(this.provider.controls, data);
35083
- if (controlValues) state.controlValues = controlValues;
35532
+ const surface = resolveProviderStateSurface({
35533
+ controlValues,
35534
+ summaryMetadata: data.summaryMetadata
35535
+ });
35536
+ if (surface.controlValues) state.controlValues = surface.controlValues;
35537
+ if (surface.summaryMetadata) state.summaryMetadata = surface.summaryMetadata;
35084
35538
  const effects = normalizeProviderEffects(data);
35085
35539
  if (effects.length > 0) state.effects = effects;
35086
35540
  if (state.messages.length > 0) {
@@ -35361,7 +35815,8 @@ var init_manager2 = __esm({
35361
35815
  const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.cdpSessionId, expr, timeout);
35362
35816
  const state = await agent.adapter.readChat(evaluate);
35363
35817
  const stateError = this.getStateError(state);
35364
- 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) : ""}`);
35818
+ const selectedModelValue = typeof state.controlValues?.model === "string" ? state.controlValues.model : "";
35819
+ LOG.debug("AgentStream", `[AgentStream] readChat(${type}) result: status=${state.status} msgs=${state.messages?.length || 0} model=${selectedModelValue}${state.status === "error" ? " error=" + JSON.stringify(stateError) : ""}`);
35365
35820
  if (state.status === "error" && this.isRecoverableSessionError(stateError)) {
35366
35821
  throw new Error(stateError);
35367
35822
  }
@@ -35738,9 +36193,8 @@ function forwardAgentStreamsToIdeInstance(instanceManager, ideType, streams) {
35738
36193
  messages: stream.messages || [],
35739
36194
  status: stream.status || "idle",
35740
36195
  activeModal: stream.activeModal || null,
35741
- model: stream.model || void 0,
35742
- mode: stream.mode || void 0,
35743
36196
  controlValues: stream.controlValues || void 0,
36197
+ summaryMetadata: stream.summaryMetadata || void 0,
35744
36198
  effects: stream.effects || void 0,
35745
36199
  sessionId: stream.sessionId || stream.instanceId || void 0,
35746
36200
  title: stream.title || stream.agentName || void 0,
@@ -36287,7 +36741,11 @@ module.exports.setMode = (params) => {
36287
36741
  * 5. Approval dialog detection (buttons, modal)
36288
36742
  * 6. Input field selector
36289
36743
  *
36290
- * \u2192 { id, status, title, messages[], inputContent, activeModal }
36744
+ * Preferred live-state surface:
36745
+ * - controlValues: explicit current control selections (model/mode/etc.)
36746
+ * - summaryMetadata: compact always-visible metadata for dashboard/recent views
36747
+ * Legacy top-level model/mode output is no longer the preferred shape.
36748
+ * \u2192 { id, status, title, messages[], inputContent, activeModal, controlValues?, summaryMetadata? }
36291
36749
  */
36292
36750
  (() => {
36293
36751
  try {
@@ -36315,6 +36773,9 @@ module.exports.setMode = (params) => {
36315
36773
  messages,
36316
36774
  inputContent,
36317
36775
  activeModal,
36776
+ // TODO: Return explicit selections when available, e.g.
36777
+ // controlValues: { model: selectedModel, mode: selectedMode },
36778
+ // summaryMetadata: { items: [{ id: 'model', value: selectedModelLabel || selectedModel, shortValue: selectedModel, order: 10 }] },
36318
36779
  });
36319
36780
  } catch(e) {
36320
36781
  return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
@@ -38061,7 +38522,6 @@ async function handleCliStatus(ctx, _req, res) {
38061
38522
  lastMessage: s.activeChat?.messages?.slice(-1)[0] || null,
38062
38523
  activeModal: s.activeChat?.activeModal || null,
38063
38524
  pendingEvents: s.pendingEvents || [],
38064
- currentModel: s.currentModel,
38065
38525
  settings: s.settings
38066
38526
  }));
38067
38527
  ctx.json(res, 200, { instances: result, count: result.length });
@@ -39223,7 +39683,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
39223
39683
  lines.push("## Required Return Format");
39224
39684
  lines.push("| Function | Return JSON |");
39225
39685
  lines.push("|---|---|");
39226
- 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 |");
39686
+ 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 |");
39227
39687
  lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
39228
39688
  lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
39229
39689
  lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
@@ -40886,7 +41346,7 @@ var init_dev_server = __esm({
40886
41346
  lines.push("## Required Return Format");
40887
41347
  lines.push("| Function | Return JSON |");
40888
41348
  lines.push("|---|---|");
40889
- 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 |");
41349
+ 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 |");
40890
41350
  lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
40891
41351
  lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
40892
41352
  lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
@@ -41808,67 +42268,6 @@ var init_runtime_support = __esm({
41808
42268
  }
41809
42269
  });
41810
42270
 
41811
- // ../../oss/packages/daemon-core/src/session-host/runtime-surface.ts
41812
- function isSessionHostLiveRuntime(record2) {
41813
- const lifecycle = String(record2?.lifecycle || "").trim();
41814
- return LIVE_LIFECYCLES.has(lifecycle);
41815
- }
41816
- function getSessionHostRecoveryLabel(meta3) {
41817
- const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
41818
- if (!recoveryState) return null;
41819
- if (recoveryState === "auto_resumed") return "restored after restart";
41820
- if (recoveryState === "resume_failed") return "restore failed";
41821
- if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
41822
- if (recoveryState === "orphan_snapshot") return "snapshot recovered";
41823
- return recoveryState.replace(/_/g, " ");
41824
- }
41825
- function isSessionHostRecoverySnapshot(record2) {
41826
- if (!record2) return false;
41827
- if (isSessionHostLiveRuntime(record2)) return false;
41828
- const lifecycle = String(record2.lifecycle || "").trim();
41829
- if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
41830
- return false;
41831
- }
41832
- const meta3 = record2.meta || void 0;
41833
- if (meta3?.restoredFromStorage === true) return true;
41834
- return getSessionHostRecoveryLabel(meta3) !== null;
41835
- }
41836
- function getSessionHostSurfaceKind(record2) {
41837
- if (isSessionHostLiveRuntime(record2)) return "live_runtime";
41838
- if (isSessionHostRecoverySnapshot(record2)) return "recovery_snapshot";
41839
- return "inactive_record";
41840
- }
41841
- function partitionSessionHostRecords(records) {
41842
- const liveRuntimes = [];
41843
- const recoverySnapshots = [];
41844
- const inactiveRecords = [];
41845
- for (const record2 of records) {
41846
- const kind = getSessionHostSurfaceKind(record2);
41847
- if (kind === "live_runtime") {
41848
- liveRuntimes.push(record2);
41849
- } else if (kind === "recovery_snapshot") {
41850
- recoverySnapshots.push(record2);
41851
- } else {
41852
- inactiveRecords.push(record2);
41853
- }
41854
- }
41855
- return {
41856
- liveRuntimes,
41857
- recoverySnapshots,
41858
- inactiveRecords
41859
- };
41860
- }
41861
- function partitionSessionHostDiagnosticsSessions(records) {
41862
- return partitionSessionHostRecords(records || []);
41863
- }
41864
- var LIVE_LIFECYCLES;
41865
- var init_runtime_surface = __esm({
41866
- "../../oss/packages/daemon-core/src/session-host/runtime-surface.ts"() {
41867
- "use strict";
41868
- LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
41869
- }
41870
- });
41871
-
41872
42271
  // ../../oss/packages/daemon-core/src/session-host/startup-restore-policy.js
41873
42272
  function shouldAutoRestoreHostedSessionsOnStartup(env3 = process.env) {
41874
42273
  const raw = typeof env3.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP === "string" ? env3.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP.trim().toLowerCase() : "";
@@ -51843,7 +52242,7 @@ var init_adhdev_daemon = __esm({
51843
52242
  import_ws3 = require("ws");
51844
52243
  init_source2();
51845
52244
  init_version();
51846
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.58" });
52245
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.59" });
51847
52246
  ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
51848
52247
  "generating",
51849
52248
  "waiting_approval",