adhdev 0.8.58 → 0.8.60

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/cli/index.js CHANGED
@@ -939,6 +939,73 @@ var init_workspaces = __esm({
939
939
  }
940
940
  });
941
941
 
942
+ // ../../oss/packages/daemon-core/src/providers/summary-metadata.ts
943
+ function normalizeSummaryItem(item) {
944
+ if (!item || typeof item !== "object") return null;
945
+ const id = String(item.id || "").trim();
946
+ const value = String(item.value || "").trim();
947
+ if (!id || !value) return null;
948
+ const normalized = {
949
+ id,
950
+ value
951
+ };
952
+ if (typeof item.label === "string" && item.label.trim()) normalized.label = item.label.trim();
953
+ if (typeof item.shortValue === "string" && item.shortValue.trim()) normalized.shortValue = item.shortValue.trim();
954
+ if (typeof item.icon === "string" && item.icon.trim()) normalized.icon = item.icon.trim();
955
+ if (typeof item.order === "number" && Number.isFinite(item.order)) normalized.order = item.order;
956
+ return normalized;
957
+ }
958
+ function normalizeProviderSummaryMetadata(summary) {
959
+ if (!summary || !Array.isArray(summary.items)) return void 0;
960
+ const items = summary.items.map((item) => normalizeSummaryItem(item)).filter((item) => !!item).sort((left2, right2) => {
961
+ const orderDiff = (left2.order ?? Number.MAX_SAFE_INTEGER) - (right2.order ?? Number.MAX_SAFE_INTEGER);
962
+ if (orderDiff !== 0) return orderDiff;
963
+ return left2.id.localeCompare(right2.id);
964
+ });
965
+ return items.length > 0 ? { items } : void 0;
966
+ }
967
+ function buildProviderSummaryMetadata(items) {
968
+ return normalizeProviderSummaryMetadata({ items: items.filter(Boolean) });
969
+ }
970
+ function buildLegacyModelModeSummaryMetadata(params) {
971
+ return buildProviderSummaryMetadata([
972
+ params.model ? {
973
+ id: "model",
974
+ label: "Model",
975
+ value: String(params.modelLabel || params.model).trim(),
976
+ shortValue: String(params.model).trim(),
977
+ order: 10
978
+ } : null,
979
+ params.mode ? {
980
+ id: "mode",
981
+ label: "Mode",
982
+ value: String(params.modeLabel || params.mode).trim(),
983
+ shortValue: String(params.mode).trim(),
984
+ order: 20
985
+ } : null
986
+ ]);
987
+ }
988
+ function resolveProviderStateSummaryMetadata(params) {
989
+ const explicit = normalizeProviderSummaryMetadata(params.summaryMetadata);
990
+ if (explicit) return explicit;
991
+ const model = typeof params.controlValues?.model === "string" ? params.controlValues.model : void 0;
992
+ const mode = typeof params.controlValues?.mode === "string" ? params.controlValues.mode : void 0;
993
+ return buildLegacyModelModeSummaryMetadata({
994
+ model,
995
+ mode,
996
+ modelLabel: params.modelLabel,
997
+ modeLabel: params.modeLabel
998
+ });
999
+ }
1000
+ function normalizePersistedSummaryMetadata(params) {
1001
+ return normalizeProviderSummaryMetadata(params.summaryMetadata);
1002
+ }
1003
+ var init_summary_metadata = __esm({
1004
+ "../../oss/packages/daemon-core/src/providers/summary-metadata.ts"() {
1005
+ "use strict";
1006
+ }
1007
+ });
1008
+
942
1009
  // ../../oss/packages/daemon-core/src/config/recent-activity.ts
943
1010
  function normalizeWorkspace(workspace) {
944
1011
  if (!workspace) return "";
@@ -962,6 +1029,9 @@ function appendRecentActivity(state, entry) {
962
1029
  const nextEntry = {
963
1030
  ...entry,
964
1031
  workspace: entry.workspace ? normalizeWorkspace(entry.workspace) : void 0,
1032
+ summaryMetadata: normalizePersistedSummaryMetadata({
1033
+ summaryMetadata: entry.summaryMetadata
1034
+ }),
965
1035
  id: buildRecentActivityKeyForEntry(entry),
966
1036
  lastUsedAt: entry.lastUsedAt || Date.now()
967
1037
  };
@@ -972,7 +1042,12 @@ function appendRecentActivity(state, entry) {
972
1042
  };
973
1043
  }
974
1044
  function getRecentActivity(state, limit = 20) {
975
- return [...state.recentActivity || []].sort((a, b) => b.lastUsedAt - a.lastUsedAt).slice(0, limit);
1045
+ return [...state.recentActivity || []].map((entry) => ({
1046
+ ...entry,
1047
+ summaryMetadata: normalizePersistedSummaryMetadata({
1048
+ summaryMetadata: entry.summaryMetadata
1049
+ })
1050
+ })).sort((a, b) => b.lastUsedAt - a.lastUsedAt).slice(0, limit);
976
1051
  }
977
1052
  function getSessionSeenAt(state, sessionId) {
978
1053
  return state.sessionReads?.[sessionId] || 0;
@@ -1003,6 +1078,7 @@ var init_recent_activity = __esm({
1003
1078
  "use strict";
1004
1079
  path2 = __toESM(require("path"));
1005
1080
  init_workspaces();
1081
+ init_summary_metadata();
1006
1082
  MAX_ACTIVITY = 30;
1007
1083
  }
1008
1084
  });
@@ -1031,7 +1107,9 @@ function upsertSavedProviderSession(state, entry) {
1031
1107
  providerName: entry.providerName,
1032
1108
  providerSessionId,
1033
1109
  workspace: entry.workspace ? normalizeWorkspace2(entry.workspace) : void 0,
1034
- currentModel: entry.currentModel,
1110
+ summaryMetadata: normalizePersistedSummaryMetadata({
1111
+ summaryMetadata: entry.summaryMetadata
1112
+ }),
1035
1113
  title: entry.title,
1036
1114
  createdAt: existing?.createdAt || entry.createdAt || Date.now(),
1037
1115
  lastUsedAt: entry.lastUsedAt || Date.now()
@@ -1047,7 +1125,12 @@ function getSavedProviderSessions(state, filters) {
1047
1125
  if (filters?.providerType && entry.providerType !== filters.providerType) return false;
1048
1126
  if (filters?.kind && entry.kind !== filters.kind) return false;
1049
1127
  return true;
1050
- }).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
1128
+ }).map((entry) => ({
1129
+ ...entry,
1130
+ summaryMetadata: normalizePersistedSummaryMetadata({
1131
+ summaryMetadata: entry.summaryMetadata
1132
+ })
1133
+ })).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
1051
1134
  }
1052
1135
  var path3, MAX_SAVED_SESSIONS;
1053
1136
  var init_saved_sessions = __esm({
@@ -1055,6 +1138,7 @@ var init_saved_sessions = __esm({
1055
1138
  "use strict";
1056
1139
  path3 = __toESM(require("path"));
1057
1140
  init_workspaces();
1141
+ init_summary_metadata();
1058
1142
  MAX_SAVED_SESSIONS = 500;
1059
1143
  }
1060
1144
  });
@@ -3067,8 +3151,6 @@ function extractProviderControlValues(controls, data) {
3067
3151
  if (rawValue === void 0 || rawValue === null) continue;
3068
3152
  values[ctrl.id] = normalizeControlValue(rawValue);
3069
3153
  }
3070
- if (data.model !== void 0 && values.model === void 0) values.model = normalizeControlValue(data.model);
3071
- if (data.mode !== void 0 && values.mode === void 0) values.mode = normalizeControlValue(data.mode);
3072
3154
  return Object.keys(values).length > 0 ? values : void 0;
3073
3155
  }
3074
3156
  function normalizeProviderEffects(data) {
@@ -3170,7 +3252,7 @@ function normalizeControlOption(option) {
3170
3252
  }
3171
3253
  if (!option || typeof option !== "object") return null;
3172
3254
  const record2 = option;
3173
- const value = typeof record2.value === "string" ? record2.value : typeof record2.id === "string" ? record2.id : null;
3255
+ const value = typeof record2.value === "string" ? record2.value : typeof record2.id === "string" ? record2.id : typeof record2.name === "string" ? record2.name : null;
3174
3256
  if (!value) return null;
3175
3257
  const label = typeof record2.label === "string" ? record2.label : typeof record2.name === "string" ? record2.name : value;
3176
3258
  const normalized = { value, label };
@@ -3716,6 +3798,68 @@ var init_chat_history = __esm({
3716
3798
  }
3717
3799
  });
3718
3800
 
3801
+ // ../../oss/packages/daemon-core/src/providers/provider-patch-state.ts
3802
+ function isControlValue(value) {
3803
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
3804
+ }
3805
+ function asControlValueMap(value) {
3806
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
3807
+ const result = {};
3808
+ for (const [entryKey, entryValue] of Object.entries(value)) {
3809
+ if (isControlValue(entryValue)) result[entryKey] = entryValue;
3810
+ }
3811
+ return Object.keys(result).length > 0 ? result : void 0;
3812
+ }
3813
+ function getLegacyModelModeValues(data) {
3814
+ if (!data || typeof data !== "object") return void 0;
3815
+ const legacy = {};
3816
+ if (typeof data.model === "string" && data.model.trim()) legacy.model = data.model.trim();
3817
+ if (typeof data.mode === "string" && data.mode.trim()) legacy.mode = data.mode.trim();
3818
+ return Object.keys(legacy).length > 0 ? legacy : void 0;
3819
+ }
3820
+ function mergeProviderPatchState(params) {
3821
+ const {
3822
+ providerControls,
3823
+ data,
3824
+ currentControlValues,
3825
+ currentSummaryMetadata,
3826
+ mergeWithCurrent = true
3827
+ } = params;
3828
+ const sources = [
3829
+ mergeWithCurrent ? asControlValueMap(currentControlValues) : void 0,
3830
+ asControlValueMap(data?.controlValues),
3831
+ asControlValueMap(extractProviderControlValues(providerControls, data)),
3832
+ getLegacyModelModeValues(data)
3833
+ ];
3834
+ const controlValues = Object.assign({}, ...sources.filter(Boolean));
3835
+ return {
3836
+ controlValues,
3837
+ summaryMetadata: data?.summaryMetadata !== void 0 ? data.summaryMetadata : currentSummaryMetadata
3838
+ };
3839
+ }
3840
+ function normalizeProviderStateControlValues(controlValues) {
3841
+ return controlValues && Object.keys(controlValues).length > 0 ? controlValues : void 0;
3842
+ }
3843
+ function resolveProviderStateSurface(params) {
3844
+ const controlValues = normalizeProviderStateControlValues(params.controlValues);
3845
+ return {
3846
+ controlValues,
3847
+ summaryMetadata: resolveProviderStateSummaryMetadata({
3848
+ summaryMetadata: params.summaryMetadata,
3849
+ controlValues,
3850
+ modelLabel: params.modelLabel,
3851
+ modeLabel: params.modeLabel
3852
+ })
3853
+ };
3854
+ }
3855
+ var init_provider_patch_state = __esm({
3856
+ "../../oss/packages/daemon-core/src/providers/provider-patch-state.ts"() {
3857
+ "use strict";
3858
+ init_control_effects();
3859
+ init_summary_metadata();
3860
+ }
3861
+ });
3862
+
3719
3863
  // ../../oss/packages/daemon-core/src/providers/extension-provider-instance.ts
3720
3864
  var ExtensionProviderInstance;
3721
3865
  var init_extension_provider_instance = __esm({
@@ -3724,6 +3868,7 @@ var init_extension_provider_instance = __esm({
3724
3868
  init_status_monitor();
3725
3869
  init_control_effects();
3726
3870
  init_chat_history();
3871
+ init_provider_patch_state();
3727
3872
  ExtensionProviderInstance = class {
3728
3873
  type;
3729
3874
  category = "extension";
@@ -3737,9 +3882,8 @@ var init_extension_provider_instance = __esm({
3737
3882
  messages = [];
3738
3883
  prevMessageHashes = /* @__PURE__ */ new Map();
3739
3884
  activeModal = null;
3740
- currentModel = "";
3741
- currentMode = "";
3742
3885
  controlValues = {};
3886
+ summaryMetadata = void 0;
3743
3887
  appliedEffectKeys = /* @__PURE__ */ new Set();
3744
3888
  runtimeMessages = [];
3745
3889
  lastAgentStatus = "idle";
@@ -3774,6 +3918,10 @@ var init_extension_provider_instance = __esm({
3774
3918
  if (!this.context?.cdp?.isConnected) return;
3775
3919
  }
3776
3920
  getState() {
3921
+ const surface = resolveProviderStateSurface({
3922
+ summaryMetadata: this.summaryMetadata,
3923
+ controlValues: this.controlValues
3924
+ });
3777
3925
  return {
3778
3926
  type: this.type,
3779
3927
  name: this.provider.name,
@@ -3787,10 +3935,9 @@ var init_extension_provider_instance = __esm({
3787
3935
  activeModal: this.activeModal,
3788
3936
  inputContent: ""
3789
3937
  } : null,
3790
- currentModel: this.currentModel || void 0,
3791
- currentPlan: this.currentMode || void 0,
3792
- controlValues: this.controlValues,
3938
+ controlValues: surface.controlValues,
3793
3939
  providerControls: this.provider.controls,
3940
+ summaryMetadata: surface.summaryMetadata,
3794
3941
  agentStreams: this.agentStreams,
3795
3942
  instanceId: this.instanceId,
3796
3943
  lastUpdated: Date.now(),
@@ -3803,10 +3950,14 @@ var init_extension_provider_instance = __esm({
3803
3950
  if (data?.streams) this.agentStreams = data.streams;
3804
3951
  if (data?.messages) this.messages = this.assignReceivedAt(data.messages);
3805
3952
  if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
3806
- if (data?.model) this.currentModel = data.model;
3807
- if (data?.mode) this.currentMode = data.mode;
3808
- const controlValues = extractProviderControlValues(this.provider.controls, data) || data?.controlValues;
3809
- if (controlValues) this.controlValues = controlValues;
3953
+ const patchedState = mergeProviderPatchState({
3954
+ providerControls: this.provider.controls,
3955
+ data,
3956
+ currentControlValues: this.controlValues,
3957
+ currentSummaryMetadata: this.summaryMetadata
3958
+ });
3959
+ this.controlValues = patchedState.controlValues;
3960
+ this.summaryMetadata = patchedState.summaryMetadata;
3810
3961
  if (typeof data?.sessionId === "string" && data.sessionId.trim()) this.chatId = data.sessionId;
3811
3962
  if (typeof data?.title === "string" && data.title.trim()) this.chatTitle = data.title;
3812
3963
  if (typeof data?.agentName === "string" && data.agentName.trim()) this.agentName = data.agentName;
@@ -3907,8 +4058,14 @@ var init_extension_provider_instance = __esm({
3907
4058
  }
3908
4059
  applyProviderResponse(data, options) {
3909
4060
  if (!data || typeof data !== "object") return;
3910
- const controlValues = extractProviderControlValues(this.provider.controls, data);
3911
- if (controlValues) this.controlValues = { ...this.controlValues, ...controlValues };
4061
+ const patchedState = mergeProviderPatchState({
4062
+ providerControls: this.provider.controls,
4063
+ data,
4064
+ currentControlValues: this.controlValues,
4065
+ currentSummaryMetadata: this.summaryMetadata
4066
+ });
4067
+ this.controlValues = patchedState.controlValues;
4068
+ this.summaryMetadata = patchedState.summaryMetadata;
3912
4069
  const effects = normalizeProviderEffects(data);
3913
4070
  for (const effect of effects) {
3914
4071
  const effectWhen = effect.when || "immediate";
@@ -4058,8 +4215,6 @@ ${effect.notification.body || ""}`.trim();
4058
4215
  this.messages = [];
4059
4216
  this.prevMessageHashes.clear();
4060
4217
  this.activeModal = null;
4061
- this.currentModel = "";
4062
- this.currentMode = "";
4063
4218
  this.controlValues = {};
4064
4219
  this.currentStatus = "idle";
4065
4220
  this.chatId = null;
@@ -4139,6 +4294,7 @@ var init_ide_provider_instance = __esm({
4139
4294
  init_logger();
4140
4295
  init_control_effects();
4141
4296
  init_approval_utils();
4297
+ init_provider_patch_state();
4142
4298
  IdeProviderInstance = class {
4143
4299
  type;
4144
4300
  category = "ide";
@@ -4211,6 +4367,10 @@ var init_ide_provider_instance = __esm({
4211
4367
  for (const ext of this.extensions.values()) {
4212
4368
  extensionStates.push(ext.getState());
4213
4369
  }
4370
+ const surface = resolveProviderStateSurface({
4371
+ summaryMetadata: this.cachedChat?.summaryMetadata,
4372
+ controlValues: this.cachedChat?.controlValues
4373
+ });
4214
4374
  return {
4215
4375
  type: this.type,
4216
4376
  name: this.provider.name,
@@ -4227,11 +4387,9 @@ var init_ide_provider_instance = __esm({
4227
4387
  workspace: this.workspace || null,
4228
4388
  extensions: extensionStates,
4229
4389
  cdpConnected: cdp?.isConnected || false,
4230
- currentModel: this.cachedChat?.model || void 0,
4231
- currentPlan: this.cachedChat?.mode || void 0,
4232
- currentAutoApprove: this.cachedChat?.autoApprove || void 0,
4233
- controlValues: this.cachedChat?.controlValues || void 0,
4390
+ controlValues: surface.controlValues,
4234
4391
  providerControls: this.provider.controls,
4392
+ summaryMetadata: surface.summaryMetadata,
4235
4393
  instanceId: this.instanceId,
4236
4394
  lastUpdated: Date.now(),
4237
4395
  settings: this.settings,
@@ -4403,8 +4561,13 @@ var init_ide_provider_instance = __esm({
4403
4561
  chat.messages = messages.filter((m) => !hiddenKinds.has(m.kind || ""));
4404
4562
  }
4405
4563
  }
4406
- const controlValues = extractProviderControlValues(this.provider.controls, chat);
4407
- if (controlValues) chat.controlValues = controlValues;
4564
+ const patchedState = mergeProviderPatchState({
4565
+ providerControls: this.provider.controls,
4566
+ data: chat,
4567
+ mergeWithCurrent: false
4568
+ });
4569
+ chat.controlValues = Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0;
4570
+ chat.summaryMetadata = patchedState.summaryMetadata;
4408
4571
  this.cachedChat = { ...chat, activeModal };
4409
4572
  this.detectAgentTransitions(chat, now);
4410
4573
  const persistedMessages = chat.messages || messages;
@@ -4491,14 +4654,18 @@ var init_ide_provider_instance = __esm({
4491
4654
  }
4492
4655
  applyProviderResponse(data, options) {
4493
4656
  if (!data || typeof data !== "object") return;
4494
- const controlValues = extractProviderControlValues(this.provider.controls, data);
4495
- if (controlValues) {
4496
- this.cachedChat = {
4497
- ...this.cachedChat || {},
4498
- ...data,
4499
- controlValues: { ...this.cachedChat?.controlValues || {}, ...controlValues }
4500
- };
4501
- }
4657
+ const patchedState = mergeProviderPatchState({
4658
+ providerControls: this.provider.controls,
4659
+ data,
4660
+ currentControlValues: this.cachedChat?.controlValues,
4661
+ currentSummaryMetadata: this.cachedChat?.summaryMetadata
4662
+ });
4663
+ this.cachedChat = {
4664
+ ...this.cachedChat || {},
4665
+ ...data,
4666
+ controlValues: Object.keys(patchedState.controlValues).length > 0 ? patchedState.controlValues : void 0,
4667
+ summaryMetadata: patchedState.summaryMetadata
4668
+ };
4502
4669
  const effects = normalizeProviderEffects(data);
4503
4670
  for (const effect of effects) {
4504
4671
  const effectWhen = effect.when || "immediate";
@@ -5271,6 +5438,8 @@ function isCdpConnected(cdpManagers, key) {
5271
5438
  function buildIdeWorkspaceSession(state, cdpManagers, options) {
5272
5439
  const profile = options.profile || "full";
5273
5440
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
5441
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
5442
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
5274
5443
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
5275
5444
  const includeSessionControls = shouldIncludeSessionControls(profile);
5276
5445
  const title = activeChat?.title || state.name;
@@ -5287,13 +5456,11 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
5287
5456
  title,
5288
5457
  ...includeSessionMetadata && { workspace: state.workspace || null },
5289
5458
  activeChat,
5459
+ ...summaryMetadata && { summaryMetadata },
5290
5460
  ...includeSessionMetadata && { capabilities: IDE_SESSION_CAPABILITIES },
5291
5461
  cdpConnected: state.cdpConnected ?? isCdpConnected(cdpManagers, state.type),
5292
- currentModel: state.currentModel,
5293
- currentPlan: state.currentPlan,
5294
- currentAutoApprove: state.currentAutoApprove,
5295
5462
  ...includeSessionControls && {
5296
- controlValues: state.controlValues,
5463
+ ...controlValues && { controlValues },
5297
5464
  providerControls: state.providerControls
5298
5465
  },
5299
5466
  errorMessage: state.errorMessage,
@@ -5304,6 +5471,8 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
5304
5471
  function buildExtensionAgentSession(parent, ext, options) {
5305
5472
  const profile = options.profile || "full";
5306
5473
  const activeChat = normalizeActiveChatData(ext.activeChat, getActiveChatOptions(profile));
5474
+ const summaryMetadata = normalizeProviderSummaryMetadata(ext.summaryMetadata);
5475
+ const controlValues = normalizeProviderStateControlValues(ext.controlValues);
5307
5476
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
5308
5477
  const includeSessionControls = shouldIncludeSessionControls(profile);
5309
5478
  return {
@@ -5319,11 +5488,10 @@ function buildExtensionAgentSession(parent, ext, options) {
5319
5488
  title: activeChat?.title || ext.name,
5320
5489
  ...includeSessionMetadata && { workspace: parent.workspace || null },
5321
5490
  activeChat,
5491
+ ...summaryMetadata && { summaryMetadata },
5322
5492
  ...includeSessionMetadata && { capabilities: EXTENSION_SESSION_CAPABILITIES },
5323
- currentModel: ext.currentModel,
5324
- currentPlan: ext.currentPlan,
5325
5493
  ...includeSessionControls && {
5326
- controlValues: ext.controlValues,
5494
+ ...controlValues && { controlValues },
5327
5495
  providerControls: ext.providerControls
5328
5496
  },
5329
5497
  errorMessage: ext.errorMessage,
@@ -5334,6 +5502,8 @@ function buildExtensionAgentSession(parent, ext, options) {
5334
5502
  function buildCliSession(state, options) {
5335
5503
  const profile = options.profile || "full";
5336
5504
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
5505
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
5506
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
5337
5507
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
5338
5508
  const includeRuntimeMetadata = shouldIncludeRuntimeMetadata(profile);
5339
5509
  const includeSessionControls = shouldIncludeSessionControls(profile);
@@ -5360,11 +5530,12 @@ function buildCliSession(state, options) {
5360
5530
  mode: state.mode,
5361
5531
  resume: state.resume,
5362
5532
  activeChat,
5533
+ ...summaryMetadata && { summaryMetadata },
5363
5534
  ...includeSessionMetadata && {
5364
5535
  capabilities: state.mode === "terminal" ? PTY_SESSION_CAPABILITIES : CLI_CHAT_SESSION_CAPABILITIES
5365
5536
  },
5366
5537
  ...includeSessionControls && {
5367
- controlValues: state.controlValues,
5538
+ ...controlValues && { controlValues },
5368
5539
  providerControls: state.providerControls
5369
5540
  },
5370
5541
  errorMessage: state.errorMessage,
@@ -5375,6 +5546,8 @@ function buildCliSession(state, options) {
5375
5546
  function buildAcpSession(state, options) {
5376
5547
  const profile = options.profile || "full";
5377
5548
  const activeChat = normalizeActiveChatData(state.activeChat, getActiveChatOptions(profile));
5549
+ const summaryMetadata = normalizeProviderSummaryMetadata(state.summaryMetadata);
5550
+ const controlValues = normalizeProviderStateControlValues(state.controlValues);
5378
5551
  const includeSessionMetadata = shouldIncludeSessionMetadata(profile);
5379
5552
  const includeSessionControls = shouldIncludeSessionControls(profile);
5380
5553
  return {
@@ -5390,13 +5563,10 @@ function buildAcpSession(state, options) {
5390
5563
  title: activeChat?.title || state.name,
5391
5564
  ...includeSessionMetadata && { workspace: state.workspace || null },
5392
5565
  activeChat,
5566
+ ...summaryMetadata && { summaryMetadata },
5393
5567
  ...includeSessionMetadata && { capabilities: ACP_SESSION_CAPABILITIES },
5394
- currentModel: state.currentModel,
5395
- currentPlan: state.currentPlan,
5396
5568
  ...includeSessionControls && {
5397
- acpConfigOptions: state.acpConfigOptions,
5398
- acpModes: state.acpModes,
5399
- controlValues: state.controlValues,
5569
+ ...controlValues && { controlValues },
5400
5570
  providerControls: state.providerControls
5401
5571
  },
5402
5572
  errorMessage: state.errorMessage,
@@ -5436,6 +5606,8 @@ var init_builders = __esm({
5436
5606
  "../../oss/packages/daemon-core/src/status/builders.ts"() {
5437
5607
  "use strict";
5438
5608
  init_normalize();
5609
+ init_provider_patch_state();
5610
+ init_summary_metadata();
5439
5611
  IDE_SESSION_CAPABILITIES = [
5440
5612
  "read_chat",
5441
5613
  "send_message",
@@ -7551,8 +7723,17 @@ async function handleSetProviderSourceConfig(h, args) {
7551
7723
  );
7552
7724
  return { success: true, reloaded: true, ...sourceConfig };
7553
7725
  }
7554
- function normalizeProviderScriptArgs(args) {
7726
+ function normalizeProviderScriptArgs(args, scriptName) {
7555
7727
  const normalizedArgs = { ...args || {} };
7728
+ const normalizedScriptName = String(scriptName || "").toLowerCase();
7729
+ if (Object.prototype.hasOwnProperty.call(normalizedArgs, "value")) {
7730
+ if (normalizedArgs.model === void 0 && (normalizedScriptName === "setmodel" || normalizedScriptName === "setmodelgui" || normalizedScriptName === "webviewsetmodel")) {
7731
+ normalizedArgs.model = normalizedArgs.value;
7732
+ }
7733
+ if (normalizedArgs.mode === void 0 && (normalizedScriptName === "setmode" || normalizedScriptName === "webviewsetmode")) {
7734
+ normalizedArgs.mode = normalizedArgs.value;
7735
+ }
7736
+ }
7556
7737
  for (const key of ["mode", "model", "message", "action", "button", "text", "sessionId", "value"]) {
7557
7738
  if (key in normalizedArgs && !(key.toUpperCase() in normalizedArgs)) {
7558
7739
  normalizedArgs[key.toUpperCase()] = normalizedArgs[key];
@@ -7598,7 +7779,7 @@ async function executeProviderScript(h, args, scriptName) {
7598
7779
  if (!provider.scripts?.[actualScriptName]) {
7599
7780
  return { success: false, error: `Script '${actualScriptName}' not available for ${resolvedProviderType}` };
7600
7781
  }
7601
- const normalizedArgs = normalizeProviderScriptArgs(args);
7782
+ const normalizedArgs = normalizeProviderScriptArgs(args, actualScriptName);
7602
7783
  if (provider.category === "cli") {
7603
7784
  const adapter = h.getCliAdapter(args?.targetSessionId || resolvedProviderType);
7604
7785
  if (!adapter?.invokeScript) {
@@ -10505,6 +10686,7 @@ var init_provider_cli_adapter = __esm({
10505
10686
  static MAX_TRACE_ENTRIES = 250;
10506
10687
  providerResolutionMeta;
10507
10688
  static IDLE_FINISH_CONFIRM_MS = 2e3;
10689
+ static HERMES_IDLE_FINISH_CONFIRM_MS = 5e3;
10508
10690
  static STATUS_ACTIVITY_HOLD_MS = 2e3;
10509
10691
  static FINISH_RETRY_DELAY_MS = 300;
10510
10692
  static MAX_FINISH_RETRIES = 2;
@@ -10512,6 +10694,12 @@ var init_provider_cli_adapter = __esm({
10512
10694
  this.messages = [...this.committedMessages];
10513
10695
  this.structuredMessages = [...this.committedMessages];
10514
10696
  }
10697
+ getIdleFinishConfirmMs() {
10698
+ return this.cliType === "hermes-cli" ? _ProviderCliAdapter.HERMES_IDLE_FINISH_CONFIRM_MS : _ProviderCliAdapter.IDLE_FINISH_CONFIRM_MS;
10699
+ }
10700
+ getStatusActivityHoldMs() {
10701
+ return this.cliType === "hermes-cli" ? _ProviderCliAdapter.HERMES_IDLE_FINISH_CONFIRM_MS : _ProviderCliAdapter.STATUS_ACTIVITY_HOLD_MS;
10702
+ }
10515
10703
  setStatus(status, trigger) {
10516
10704
  const prev = this.currentStatus;
10517
10705
  if (prev === status) return;
@@ -10534,6 +10722,7 @@ var init_provider_cli_adapter = __esm({
10534
10722
  }
10535
10723
  armIdleFinishCandidate(assistantLength) {
10536
10724
  const now = Date.now();
10725
+ const idleFinishConfirmMs = this.getIdleFinishConfirmMs();
10537
10726
  this.idleFinishCandidate = {
10538
10727
  armedAt: now,
10539
10728
  lastOutputAt: this.lastOutputAt,
@@ -10542,7 +10731,7 @@ var init_provider_cli_adapter = __esm({
10542
10731
  assistantLength
10543
10732
  };
10544
10733
  this.recordTrace("idle_candidate_armed", {
10545
- confirmMs: _ProviderCliAdapter.IDLE_FINISH_CONFIRM_MS,
10734
+ confirmMs: idleFinishConfirmMs,
10546
10735
  candidate: this.idleFinishCandidate,
10547
10736
  ...buildCliTraceParseSnapshot({
10548
10737
  accumulatedBuffer: this.accumulatedBuffer,
@@ -10557,7 +10746,7 @@ var init_provider_cli_adapter = __esm({
10557
10746
  this.settleTimer = null;
10558
10747
  this.settledBuffer = this.recentOutputBuffer;
10559
10748
  this.evaluateSettled();
10560
- }, _ProviderCliAdapter.IDLE_FINISH_CONFIRM_MS);
10749
+ }, idleFinishConfirmMs);
10561
10750
  }
10562
10751
  recordTrace(type, payload = {}) {
10563
10752
  const entry = {
@@ -10936,7 +11125,8 @@ var init_provider_cli_adapter = __esm({
10936
11125
  hasRecentInteractiveActivity(now) {
10937
11126
  const quietForMs = this.lastNonEmptyOutputAt ? now - this.lastNonEmptyOutputAt : Number.MAX_SAFE_INTEGER;
10938
11127
  const screenStableMs = this.lastScreenChangeAt ? now - this.lastScreenChangeAt : Number.MAX_SAFE_INTEGER;
10939
- return quietForMs < _ProviderCliAdapter.STATUS_ACTIVITY_HOLD_MS || screenStableMs < _ProviderCliAdapter.STATUS_ACTIVITY_HOLD_MS;
11128
+ const holdMs = this.getStatusActivityHoldMs();
11129
+ return quietForMs < holdMs || screenStableMs < holdMs;
10940
11130
  }
10941
11131
  getStartupConfirmationModal(screenText) {
10942
11132
  const text = sanitizeTerminalText(String(screenText || ""));
@@ -11088,6 +11278,7 @@ var init_provider_cli_adapter = __esm({
11088
11278
  clearPendingScriptStatus();
11089
11279
  }
11090
11280
  const recentInteractiveActivity = this.hasRecentInteractiveActivity(now);
11281
+ const statusActivityHoldMs = this.getStatusActivityHoldMs();
11091
11282
  const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity;
11092
11283
  if (shouldHoldGenerating) {
11093
11284
  this.clearIdleFinishCandidate("hold_generating_recent_activity");
@@ -11103,7 +11294,7 @@ var init_provider_cli_adapter = __esm({
11103
11294
  recentInteractiveActivity,
11104
11295
  lastNonEmptyOutputAt: this.lastNonEmptyOutputAt,
11105
11296
  lastScreenChangeAt: this.lastScreenChangeAt,
11106
- holdMs: _ProviderCliAdapter.STATUS_ACTIVITY_HOLD_MS,
11297
+ holdMs: statusActivityHoldMs,
11107
11298
  ...buildCliTraceParseSnapshot({
11108
11299
  accumulatedBuffer: this.accumulatedBuffer,
11109
11300
  accumulatedRawBuffer: this.accumulatedRawBuffer,
@@ -11192,11 +11383,12 @@ var init_provider_cli_adapter = __esm({
11192
11383
  const screenStableMs = this.lastScreenChangeAt ? now - this.lastScreenChangeAt : 0;
11193
11384
  const hasAssistantTurn = !!lastParsedAssistant;
11194
11385
  const assistantLength = lastParsedAssistant?.content?.length || 0;
11195
- const idleQuietThresholdMs = Math.max(2e3, this.timeouts.outputSettle);
11196
- const idleStableThresholdMs = 2e3;
11386
+ const idleFinishConfirmMs = this.getIdleFinishConfirmMs();
11387
+ const idleQuietThresholdMs = Math.max(idleFinishConfirmMs, this.timeouts.outputSettle);
11388
+ const idleStableThresholdMs = idleFinishConfirmMs;
11197
11389
  const idleReady = visibleIdlePrompt && !modal && hasAssistantTurn && quietForMs >= idleQuietThresholdMs && screenStableMs >= idleStableThresholdMs;
11198
11390
  const candidate = this.idleFinishCandidate;
11199
- const candidateQuiet = !!candidate && candidate.responseEpoch === this.responseEpoch && candidate.lastOutputAt === this.lastOutputAt && candidate.lastScreenChangeAt === this.lastScreenChangeAt && assistantLength >= candidate.assistantLength && now - candidate.armedAt >= _ProviderCliAdapter.IDLE_FINISH_CONFIRM_MS;
11391
+ const candidateQuiet = !!candidate && candidate.responseEpoch === this.responseEpoch && candidate.lastOutputAt === this.lastOutputAt && candidate.lastScreenChangeAt === this.lastScreenChangeAt && assistantLength >= candidate.assistantLength && now - candidate.armedAt >= idleFinishConfirmMs;
11200
11392
  const canFinishImmediately = idleReady && candidateQuiet;
11201
11393
  this.recordTrace("idle_decision", {
11202
11394
  visibleIdlePrompt,
@@ -11208,7 +11400,7 @@ var init_provider_cli_adapter = __esm({
11208
11400
  idleQuietThresholdMs,
11209
11401
  idleStableThresholdMs,
11210
11402
  idleReady,
11211
- idleFinishConfirmMs: _ProviderCliAdapter.IDLE_FINISH_CONFIRM_MS,
11403
+ idleFinishConfirmMs,
11212
11404
  idleFinishCandidate: candidate,
11213
11405
  candidateQuiet,
11214
11406
  canFinishImmediately,
@@ -12154,6 +12346,7 @@ var init_cli_provider_instance = __esm({
12154
12346
  init_control_effects();
12155
12347
  init_approval_utils();
12156
12348
  init_cli_script_results();
12349
+ init_provider_patch_state();
12157
12350
  CachedDatabaseSync = null;
12158
12351
  CliProviderInstance = class {
12159
12352
  constructor(provider, workingDir, cliArgs = [], instanceId, transportFactory, options) {
@@ -12183,6 +12376,7 @@ var init_cli_provider_instance = __esm({
12183
12376
  generatingDebouncePending = null;
12184
12377
  lastApprovalEventAt = 0;
12185
12378
  controlValues = {};
12379
+ summaryMetadata = void 0;
12186
12380
  appliedEffectKeys = /* @__PURE__ */ new Set();
12187
12381
  historyWriter;
12188
12382
  runtimeMessages = [];
@@ -12325,13 +12519,7 @@ var init_cli_provider_instance = __esm({
12325
12519
  if (historyMessageCount !== null) {
12326
12520
  parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
12327
12521
  }
12328
- const controlValues = extractProviderControlValues(this.provider.controls, parsedStatus);
12329
- if (controlValues) {
12330
- this.controlValues = { ...this.controlValues, ...controlValues };
12331
- }
12332
12522
  const mergedMessages = this.mergeConversationMessages(parsedMessages);
12333
- 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;
12334
- 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;
12335
12523
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
12336
12524
  if (parsedMessages.length > 0) {
12337
12525
  const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
@@ -12353,6 +12541,10 @@ var init_cli_provider_instance = __esm({
12353
12541
  }
12354
12542
  }
12355
12543
  this.applyProviderResponse(parsedStatus, { phase: "immediate" });
12544
+ const surface = resolveProviderStateSurface({
12545
+ summaryMetadata: this.summaryMetadata,
12546
+ controlValues: this.controlValues
12547
+ });
12356
12548
  return {
12357
12549
  type: this.type,
12358
12550
  name: this.provider.name,
@@ -12368,8 +12560,6 @@ var init_cli_provider_instance = __esm({
12368
12560
  inputContent: ""
12369
12561
  },
12370
12562
  workspace: this.workingDir,
12371
- currentModel,
12372
- currentPlan,
12373
12563
  instanceId: this.instanceId,
12374
12564
  providerSessionId: this.providerSessionId,
12375
12565
  lastUpdated: Date.now(),
@@ -12384,8 +12574,9 @@ var init_cli_provider_instance = __esm({
12384
12574
  attachedClients: runtime.attachedClients || []
12385
12575
  } : void 0,
12386
12576
  resume: this.provider.resume,
12387
- controlValues: this.controlValues,
12388
- providerControls: this.provider.controls
12577
+ controlValues: surface.controlValues,
12578
+ providerControls: this.provider.controls,
12579
+ summaryMetadata: surface.summaryMetadata
12389
12580
  };
12390
12581
  }
12391
12582
  setPresentationMode(mode) {
@@ -12589,10 +12780,14 @@ var init_cli_provider_instance = __esm({
12589
12780
  this.suppressIdleHistoryReplay = false;
12590
12781
  this.adapter.clearHistory();
12591
12782
  }
12592
- const controlValues = extractProviderControlValues(this.provider.controls, data);
12593
- if (controlValues) {
12594
- this.controlValues = { ...this.controlValues, ...controlValues };
12595
- }
12783
+ const patchedState = mergeProviderPatchState({
12784
+ providerControls: this.provider.controls,
12785
+ data,
12786
+ currentControlValues: this.controlValues,
12787
+ currentSummaryMetadata: this.summaryMetadata
12788
+ });
12789
+ this.controlValues = patchedState.controlValues;
12790
+ this.summaryMetadata = patchedState.summaryMetadata;
12596
12791
  const effects = normalizeProviderEffects(data);
12597
12792
  for (const effect of effects) {
12598
12793
  const effectWhen = effect.when || "immediate";
@@ -29239,6 +29434,7 @@ var init_acp_provider_instance = __esm({
29239
29434
  init_acp();
29240
29435
  init_contracts();
29241
29436
  init_status_monitor();
29437
+ init_summary_metadata();
29242
29438
  init_logger();
29243
29439
  AcpProviderInstance = class {
29244
29440
  constructor(provider, workingDir, cliArgs = []) {
@@ -29267,8 +29463,7 @@ var init_acp_provider_instance = __esm({
29267
29463
  lastStatus = "starting";
29268
29464
  generatingStartedAt = 0;
29269
29465
  agentCapabilities = {};
29270
- currentModel;
29271
- currentMode;
29466
+ currentSelections = {};
29272
29467
  activeToolCalls = [];
29273
29468
  stopReason = null;
29274
29469
  partialContent = "";
@@ -29348,8 +29543,6 @@ var init_acp_provider_instance = __esm({
29348
29543
  inputContent: ""
29349
29544
  },
29350
29545
  workspace: this.workingDir,
29351
- currentModel: this.currentModel,
29352
- currentPlan: this.currentMode,
29353
29546
  instanceId: this.instanceId,
29354
29547
  lastUpdated: Date.now(),
29355
29548
  settings: this.settings,
@@ -29360,11 +29553,9 @@ var init_acp_provider_instance = __esm({
29360
29553
  // Error details for dashboard display
29361
29554
  errorMessage: this.errorMessage || void 0,
29362
29555
  errorReason: this.errorReason || void 0,
29363
- controlValues: {
29364
- ...this.currentModel ? { model: this.currentModel } : {},
29365
- ...this.currentMode ? { mode: this.currentMode } : {}
29366
- },
29367
- providerControls: this.provider.controls
29556
+ controlValues: this.getSelectionControlValues(),
29557
+ providerControls: this.provider.controls,
29558
+ summaryMetadata: this.buildSelectionSummaryMetadata()
29368
29559
  };
29369
29560
  }
29370
29561
  onEvent(event, data) {
@@ -29398,6 +29589,54 @@ var init_acp_provider_instance = __esm({
29398
29589
  getInstanceId() {
29399
29590
  return this.instanceId;
29400
29591
  }
29592
+ resolveConfigOptionLabel(category, value) {
29593
+ if (!value) return void 0;
29594
+ const option = this.configOptions.find((entry) => entry.category === category);
29595
+ return option?.options.find((candidate) => candidate.value === value)?.name || value;
29596
+ }
29597
+ resolveModeLabel(modeId) {
29598
+ if (!modeId) return void 0;
29599
+ return this.availableModes.find((mode) => mode.id === modeId)?.name || modeId;
29600
+ }
29601
+ getCurrentSelection(category) {
29602
+ return this.currentSelections[category];
29603
+ }
29604
+ setCurrentSelection(category, value) {
29605
+ const normalized = typeof value === "string" ? value.trim() : "";
29606
+ if (normalized) {
29607
+ this.currentSelections[category] = normalized;
29608
+ return;
29609
+ }
29610
+ delete this.currentSelections[category];
29611
+ }
29612
+ getSelectionControlValues() {
29613
+ const model = this.getCurrentSelection("model");
29614
+ const mode = this.getCurrentSelection("mode");
29615
+ return {
29616
+ ...model ? { model } : {},
29617
+ ...mode ? { mode } : {}
29618
+ };
29619
+ }
29620
+ resolveSelectionLabel(category, value) {
29621
+ if (!value) return void 0;
29622
+ const configLabel = this.resolveConfigOptionLabel(category, value);
29623
+ if (configLabel && configLabel !== value) return configLabel;
29624
+ if (category === "mode") {
29625
+ const modeLabel = this.resolveModeLabel(value);
29626
+ if (modeLabel) return modeLabel;
29627
+ }
29628
+ return configLabel || value;
29629
+ }
29630
+ buildSelectionSummaryMetadata() {
29631
+ const model = this.getCurrentSelection("model");
29632
+ const mode = this.getCurrentSelection("mode");
29633
+ return buildLegacyModelModeSummaryMetadata({
29634
+ model,
29635
+ mode,
29636
+ modelLabel: this.resolveSelectionLabel("model", model),
29637
+ modeLabel: this.resolveSelectionLabel("mode", mode)
29638
+ });
29639
+ }
29401
29640
  // ─── ACP Config Options & Modes ─────────────────────
29402
29641
  parseConfigOptions(raw) {
29403
29642
  if (!Array.isArray(raw)) return;
@@ -29429,12 +29668,14 @@ var init_acp_provider_instance = __esm({
29429
29668
  }
29430
29669
  }
29431
29670
  this.configOptions.push({ category, configId, currentValue, options: flatOptions });
29432
- if (category === "model" && currentValue) this.currentModel = currentValue;
29671
+ if (category === "model" || category === "mode") {
29672
+ this.setCurrentSelection(category, currentValue);
29673
+ }
29433
29674
  }
29434
29675
  }
29435
29676
  parseModes(raw) {
29436
29677
  if (!raw) return;
29437
- if (raw.currentModeId) this.currentMode = raw.currentModeId;
29678
+ this.setCurrentSelection("mode", raw.currentModeId);
29438
29679
  if (Array.isArray(raw.availableModes)) {
29439
29680
  this.availableModes = raw.availableModes.map((m) => ({
29440
29681
  id: m.id,
@@ -29453,8 +29694,7 @@ var init_acp_provider_instance = __esm({
29453
29694
  if (this.useStaticConfig) {
29454
29695
  opt.currentValue = value;
29455
29696
  this.selectedConfig[opt.configId] = value;
29456
- if (category === "model") this.currentModel = value;
29457
- if (category === "mode") this.currentMode = value;
29697
+ if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
29458
29698
  this.log.info(`[${this.type}] Static config ${category} set to: ${value} \u2014 restarting agent`);
29459
29699
  await this.restartWithNewConfig();
29460
29700
  return;
@@ -29472,7 +29712,7 @@ var init_acp_provider_instance = __esm({
29472
29712
  value
29473
29713
  });
29474
29714
  opt.currentValue = value;
29475
- if (category === "model") this.currentModel = value;
29715
+ if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
29476
29716
  if (result?.configOptions) this.parseConfigOptions(result.configOptions);
29477
29717
  this.log.info(`[${this.type}] Config ${category} set to: ${value} | response: ${JSON.stringify(result)?.slice(0, 300)}`);
29478
29718
  } catch (e) {
@@ -29488,7 +29728,7 @@ var init_acp_provider_instance = __esm({
29488
29728
  opt.currentValue = modeId;
29489
29729
  this.selectedConfig[opt.configId] = modeId;
29490
29730
  }
29491
- this.currentMode = modeId;
29731
+ this.setCurrentSelection("mode", modeId);
29492
29732
  this.log.info(`[${this.type}] Static mode set to: ${modeId} \u2014 restarting agent`);
29493
29733
  await this.restartWithNewConfig();
29494
29734
  return;
@@ -29503,7 +29743,7 @@ var init_acp_provider_instance = __esm({
29503
29743
  sessionId: this.sessionId,
29504
29744
  modeId
29505
29745
  });
29506
- this.currentMode = modeId;
29746
+ this.setCurrentSelection("mode", modeId);
29507
29747
  this.log.info(`[${this.type}] Mode set to: ${modeId}`);
29508
29748
  } catch (e) {
29509
29749
  const message = e?.message || "Unknown ACP mode error";
@@ -29761,8 +30001,8 @@ var init_acp_provider_instance = __esm({
29761
30001
  if (result?.modes) this.log.debug(`[${this.type}] modes: ${JSON.stringify(result.modes).slice(0, 300)}`);
29762
30002
  this.parseConfigOptions(result?.configOptions);
29763
30003
  this.parseModes(result?.modes);
29764
- if (!this.currentModel && result?.models?.currentModelId) {
29765
- this.currentModel = result.models.currentModelId;
30004
+ if (!this.getCurrentSelection("model") && result?.models?.currentModelId) {
30005
+ this.setCurrentSelection("model", result.models.currentModelId);
29766
30006
  }
29767
30007
  if (this.configOptions.length === 0 && this.provider.staticConfigOptions?.length) {
29768
30008
  this.useStaticConfig = true;
@@ -29776,13 +30016,16 @@ var init_acp_provider_instance = __esm({
29776
30016
  });
29777
30017
  if (defaultVal) {
29778
30018
  this.selectedConfig[sc.configId] = defaultVal;
29779
- if (sc.category === "model") this.currentModel = defaultVal;
29780
- if (sc.category === "mode") this.currentMode = defaultVal;
30019
+ if (sc.category === "model" || sc.category === "mode") {
30020
+ this.setCurrentSelection(sc.category, defaultVal);
30021
+ }
29781
30022
  }
29782
30023
  }
29783
30024
  this.log.info(`[${this.type}] Using static configOptions (${this.configOptions.length} options)`);
29784
30025
  }
29785
- this.log.info(`[${this.type}] Session created: ${this.sessionId}${this.currentModel ? ` (model: ${this.currentModel})` : ""}${this.currentMode ? ` (mode: ${this.currentMode})` : ""}`);
30026
+ const currentModel = this.getCurrentSelection("model");
30027
+ const currentMode = this.getCurrentSelection("mode");
30028
+ this.log.info(`[${this.type}] Session created: ${this.sessionId}${currentModel ? ` (model: ${currentModel})` : ""}${currentMode ? ` (mode: ${currentMode})` : ""}`);
29786
30029
  if (this.configOptions.length > 0) {
29787
30030
  this.log.info(`[${this.type}] Config options: ${this.configOptions.map((c) => `${c.category}(${c.options.length})`).join(", ")}`);
29788
30031
  }
@@ -29957,7 +30200,7 @@ var init_acp_provider_instance = __esm({
29957
30200
  break;
29958
30201
  }
29959
30202
  case "current_mode_update": {
29960
- this.currentMode = update.currentModeId;
30203
+ this.setCurrentSelection("mode", update.currentModeId);
29961
30204
  break;
29962
30205
  }
29963
30206
  case "config_option_update": {
@@ -30030,7 +30273,7 @@ var init_acp_provider_instance = __esm({
30030
30273
  this.detectStatusTransition();
30031
30274
  }
30032
30275
  if (params.model) {
30033
- this.currentModel = params.model;
30276
+ this.setCurrentSelection("model", params.model);
30034
30277
  }
30035
30278
  }
30036
30279
  /** Map SDK ToolCallStatus to internal status */
@@ -30312,6 +30555,7 @@ var init_cli_manager = __esm({
30312
30555
  init_workspaces();
30313
30556
  init_recent_activity();
30314
30557
  init_saved_sessions();
30558
+ init_summary_metadata();
30315
30559
  init_cli_provider_instance();
30316
30560
  init_acp_provider_instance();
30317
30561
  init_contracts();
@@ -30343,7 +30587,11 @@ var init_cli_manager = __esm({
30343
30587
  }
30344
30588
  persistRecentActivity(entry) {
30345
30589
  try {
30346
- let nextState = appendRecentActivity(loadState(), entry);
30590
+ const summaryMetadata = normalizeProviderSummaryMetadata(entry.summaryMetadata);
30591
+ let nextState = appendRecentActivity(loadState(), {
30592
+ ...entry,
30593
+ summaryMetadata
30594
+ });
30347
30595
  if (entry.providerSessionId && (entry.kind === "cli" || entry.kind === "acp")) {
30348
30596
  nextState = upsertSavedProviderSession(nextState, {
30349
30597
  kind: entry.kind,
@@ -30351,7 +30599,7 @@ var init_cli_manager = __esm({
30351
30599
  providerName: entry.providerName,
30352
30600
  providerSessionId: entry.providerSessionId,
30353
30601
  workspace: entry.workspace,
30354
- currentModel: entry.currentModel,
30602
+ summaryMetadata,
30355
30603
  title: entry.title
30356
30604
  });
30357
30605
  }
@@ -30541,7 +30789,7 @@ ${installInfo}`
30541
30789
  providerType: normalizedType,
30542
30790
  providerName: provider.displayName || provider.name || normalizedType,
30543
30791
  workspace: resolvedDir,
30544
- currentModel: initialModel,
30792
+ summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
30545
30793
  sessionId,
30546
30794
  title: provider.displayName || provider.name || normalizedType
30547
30795
  });
@@ -30643,7 +30891,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
30643
30891
  providerName: provider?.displayName || provider?.name || normalizedType,
30644
30892
  providerSessionId: sessionBinding.providerSessionId,
30645
30893
  workspace: resolvedDir,
30646
- currentModel: initialModel,
30894
+ summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
30647
30895
  sessionId: key,
30648
30896
  title: provider?.displayName || provider?.name || normalizedType
30649
30897
  });
@@ -34576,7 +34824,90 @@ var init_command_log = __esm({
34576
34824
  }
34577
34825
  });
34578
34826
 
34827
+ // ../../oss/packages/daemon-core/src/session-host/runtime-surface.ts
34828
+ function isSessionHostLiveRuntime2(record2) {
34829
+ const lifecycle = String(record2?.lifecycle || "").trim();
34830
+ return LIVE_LIFECYCLES2.has(lifecycle);
34831
+ }
34832
+ function getSessionHostRecoveryLabel2(meta3) {
34833
+ const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
34834
+ if (!recoveryState) return null;
34835
+ if (recoveryState === "auto_resumed") return "restored after restart";
34836
+ if (recoveryState === "resume_failed") return "restore failed";
34837
+ if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
34838
+ if (recoveryState === "orphan_snapshot") return "snapshot recovered";
34839
+ return recoveryState.replace(/_/g, " ");
34840
+ }
34841
+ function isSessionHostRecoverySnapshot2(record2) {
34842
+ if (!record2) return false;
34843
+ if (isSessionHostLiveRuntime2(record2)) return false;
34844
+ const lifecycle = String(record2.lifecycle || "").trim();
34845
+ if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
34846
+ return false;
34847
+ }
34848
+ const meta3 = record2.meta || void 0;
34849
+ if (meta3?.restoredFromStorage === true) return true;
34850
+ return getSessionHostRecoveryLabel2(meta3) !== null;
34851
+ }
34852
+ function getSessionHostSurfaceKind2(record2) {
34853
+ if (isSessionHostLiveRuntime2(record2)) return "live_runtime";
34854
+ if (isSessionHostRecoverySnapshot2(record2)) return "recovery_snapshot";
34855
+ return "inactive_record";
34856
+ }
34857
+ function partitionSessionHostRecords(records) {
34858
+ const liveRuntimes = [];
34859
+ const recoverySnapshots = [];
34860
+ const inactiveRecords = [];
34861
+ for (const record2 of records) {
34862
+ const kind = getSessionHostSurfaceKind2(record2);
34863
+ if (kind === "live_runtime") {
34864
+ liveRuntimes.push(record2);
34865
+ } else if (kind === "recovery_snapshot") {
34866
+ recoverySnapshots.push(record2);
34867
+ } else {
34868
+ inactiveRecords.push(record2);
34869
+ }
34870
+ }
34871
+ return {
34872
+ liveRuntimes,
34873
+ recoverySnapshots,
34874
+ inactiveRecords
34875
+ };
34876
+ }
34877
+ function partitionSessionHostDiagnosticsSessions(records) {
34878
+ return partitionSessionHostRecords(records || []);
34879
+ }
34880
+ var LIVE_LIFECYCLES2;
34881
+ var init_runtime_surface = __esm({
34882
+ "../../oss/packages/daemon-core/src/session-host/runtime-surface.ts"() {
34883
+ "use strict";
34884
+ LIVE_LIFECYCLES2 = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
34885
+ }
34886
+ });
34887
+
34579
34888
  // ../../oss/packages/daemon-core/src/status/snapshot.ts
34889
+ function buildRecentReadDebugSignature(snapshot) {
34890
+ return [
34891
+ snapshot.providerType,
34892
+ snapshot.status,
34893
+ snapshot.inboxBucket,
34894
+ snapshot.unread ? "1" : "0",
34895
+ String(snapshot.lastSeenAt),
34896
+ snapshot.completionMarker,
34897
+ snapshot.seenCompletionMarker,
34898
+ String(snapshot.lastUpdated),
34899
+ String(snapshot.lastUsedAt),
34900
+ snapshot.lastRole,
34901
+ String(snapshot.messageUpdatedAt)
34902
+ ].join("|");
34903
+ }
34904
+ function shouldEmitRecentReadDebugLog(cache, snapshot) {
34905
+ const nextSignature = buildRecentReadDebugSignature(snapshot);
34906
+ const previousSignature = cache.get(snapshot.sessionId);
34907
+ if (previousSignature === nextSignature) return false;
34908
+ cache.set(snapshot.sessionId, nextSignature);
34909
+ return true;
34910
+ }
34580
34911
  function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
34581
34912
  return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
34582
34913
  id: ide.id,
@@ -34728,7 +35059,7 @@ function buildRecentLaunches(recentActivity) {
34728
35059
  providerSessionId: item.providerSessionId,
34729
35060
  title: item.title || item.providerName,
34730
35061
  workspace: item.workspace,
34731
- currentModel: item.currentModel,
35062
+ summaryMetadata: item.summaryMetadata,
34732
35063
  lastLaunchedAt: item.lastUsedAt
34733
35064
  })).sort((a, b) => b.lastLaunchedAt - a.lastLaunchedAt).slice(0, 12);
34734
35065
  }
@@ -34769,9 +35100,24 @@ function buildStatusSnapshot(options) {
34769
35100
  session.unread = unread;
34770
35101
  session.inboxBucket = inboxBucket;
34771
35102
  if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
35103
+ const recentReadSnapshot = {
35104
+ sessionId: session.id,
35105
+ providerType: session.providerType,
35106
+ status: String(session.status || ""),
35107
+ inboxBucket,
35108
+ unread,
35109
+ lastSeenAt,
35110
+ completionMarker: completionMarker || "-",
35111
+ seenCompletionMarker: seenCompletionMarker || "-",
35112
+ lastUpdated: Number(session.lastUpdated || 0),
35113
+ lastUsedAt,
35114
+ lastRole: getLastMessageRole(sourceSession),
35115
+ messageUpdatedAt: getSessionMessageUpdatedAt(sourceSession)
35116
+ };
35117
+ if (!shouldEmitRecentReadDebugLog(recentReadDebugSignatureBySession, recentReadSnapshot)) continue;
34772
35118
  LOG.info(
34773
35119
  "RecentRead",
34774
- `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)}`
35120
+ `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}`
34775
35121
  );
34776
35122
  }
34777
35123
  const lastDisplayMessage = getLastDisplayMessage(sourceSession);
@@ -34804,7 +35150,7 @@ function buildStatusSnapshot(options) {
34804
35150
  }
34805
35151
  };
34806
35152
  }
34807
- var os19, READ_DEBUG_ENABLED;
35153
+ var os19, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession;
34808
35154
  var init_snapshot = __esm({
34809
35155
  "../../oss/packages/daemon-core/src/status/snapshot.ts"() {
34810
35156
  "use strict";
@@ -34818,6 +35164,7 @@ var init_snapshot = __esm({
34818
35164
  init_logger();
34819
35165
  init_builders();
34820
35166
  READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
35167
+ recentReadDebugSignatureBySession = /* @__PURE__ */ new Map();
34821
35168
  }
34822
35169
  });
34823
35170
 
@@ -35059,6 +35406,49 @@ function toHostedCliRuntimeDescriptor(record2) {
35059
35406
  providerSessionId: typeof record2.meta?.providerSessionId === "string" ? String(record2.meta.providerSessionId) : void 0
35060
35407
  };
35061
35408
  }
35409
+ function getWriteConflictOwnerClientId(error48) {
35410
+ const message = typeof error48 === "string" ? error48 : error48 instanceof Error ? error48.message : "";
35411
+ const match = /^Write owned by\s+(.+)$/.exec(message.trim());
35412
+ return match?.[1]?.trim() || void 0;
35413
+ }
35414
+ function summarizeSessionHostRecord(result) {
35415
+ if (!result || typeof result !== "object") return {};
35416
+ const record2 = result;
35417
+ return {
35418
+ runtimeKey: typeof record2.runtimeKey === "string" ? record2.runtimeKey : void 0,
35419
+ lifecycle: typeof record2.lifecycle === "string" ? record2.lifecycle : void 0,
35420
+ surfaceKind: getSessionHostSurfaceKind2(record2),
35421
+ attachedClientCount: Array.isArray(record2.attachedClients) ? record2.attachedClients.length : void 0,
35422
+ hasWriteOwner: !!record2.writeOwner,
35423
+ writeOwnerClientId: typeof record2.writeOwner?.clientId === "string" ? record2.writeOwner.clientId : void 0
35424
+ };
35425
+ }
35426
+ function summarizeSessionHostRecords(result) {
35427
+ const records = Array.isArray(result) ? result : [];
35428
+ const groups = partitionSessionHostRecords(records);
35429
+ return {
35430
+ sessionCount: records.length,
35431
+ liveRuntimeCount: groups.liveRuntimes.length,
35432
+ recoverySnapshotCount: groups.recoverySnapshots.length,
35433
+ inactiveRecordCount: groups.inactiveRecords.length
35434
+ };
35435
+ }
35436
+ function summarizeSessionHostDiagnostics(result) {
35437
+ const diagnostics = result && typeof result === "object" ? result : {};
35438
+ const sessions = Array.isArray(diagnostics.sessions) ? diagnostics.sessions : [];
35439
+ return {
35440
+ runtimeCount: typeof diagnostics.runtimeCount === "number" ? diagnostics.runtimeCount : void 0,
35441
+ ...summarizeSessionHostRecords(sessions)
35442
+ };
35443
+ }
35444
+ function summarizeSessionHostPruneResult(result) {
35445
+ const value = result && typeof result === "object" ? result : {};
35446
+ return {
35447
+ duplicateGroupCount: typeof value.duplicateGroupCount === "number" ? value.duplicateGroupCount : void 0,
35448
+ prunedCount: Array.isArray(value.prunedSessionIds) ? value.prunedSessionIds.length : void 0,
35449
+ keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
35450
+ };
35451
+ }
35062
35452
  var fs9, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
35063
35453
  var init_router = __esm({
35064
35454
  "../../oss/packages/daemon-core/src/commands/router.ts"() {
@@ -35078,6 +35468,7 @@ var init_router = __esm({
35078
35468
  init_command_log();
35079
35469
  init_logger();
35080
35470
  init_debug_trace();
35471
+ init_runtime_surface();
35081
35472
  init_builders();
35082
35473
  init_snapshot();
35083
35474
  init_snapshot();
@@ -35096,6 +35487,56 @@ var init_router = __esm({
35096
35487
  constructor(deps) {
35097
35488
  this.deps = deps;
35098
35489
  }
35490
+ async traceSessionHostAction(action, args, run, summarizeResult) {
35491
+ const interactionId = typeof args?._interactionId === "string" ? args._interactionId : void 0;
35492
+ const sessionId = typeof args?.sessionId === "string" ? args.sessionId : void 0;
35493
+ const requestedPayload = { action };
35494
+ if (sessionId) requestedPayload.sessionId = sessionId;
35495
+ if (typeof args?.clientId === "string") requestedPayload.clientId = args.clientId;
35496
+ if (typeof args?.signal === "string") requestedPayload.signal = args.signal;
35497
+ if (typeof args?.providerType === "string") requestedPayload.providerType = args.providerType;
35498
+ if (typeof args?.workspace === "string") requestedPayload.workspace = args.workspace;
35499
+ if (typeof args?.dryRun === "boolean") requestedPayload.dryRun = args.dryRun;
35500
+ recordDebugTrace({
35501
+ interactionId,
35502
+ category: "session_host",
35503
+ stage: "action_requested",
35504
+ level: "info",
35505
+ sessionId,
35506
+ payload: requestedPayload
35507
+ });
35508
+ try {
35509
+ const result = await run();
35510
+ recordDebugTrace({
35511
+ interactionId,
35512
+ category: "session_host",
35513
+ stage: "action_result",
35514
+ level: "info",
35515
+ sessionId,
35516
+ payload: {
35517
+ ...requestedPayload,
35518
+ success: true,
35519
+ ...summarizeResult ? summarizeResult(result) : {}
35520
+ }
35521
+ });
35522
+ return result;
35523
+ } catch (error48) {
35524
+ recordDebugTrace({
35525
+ interactionId,
35526
+ category: "session_host",
35527
+ stage: "action_failed",
35528
+ level: "error",
35529
+ sessionId,
35530
+ payload: {
35531
+ ...requestedPayload,
35532
+ error: error48?.message || String(error48),
35533
+ failureKind: getWriteConflictOwnerClientId(error48) ? "write_conflict" : "request_failed",
35534
+ conflictOwnerClientId: getWriteConflictOwnerClientId(error48)
35535
+ }
35536
+ });
35537
+ throw error48;
35538
+ }
35539
+ }
35099
35540
  /**
35100
35541
  * Unified command routing.
35101
35542
  * Returns result for all commands:
@@ -35205,44 +35646,60 @@ var init_router = __esm({
35205
35646
  }
35206
35647
  case "session_host_get_diagnostics": {
35207
35648
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
35208
- const diagnostics = await this.deps.sessionHostControl.getDiagnostics({
35649
+ const diagnostics = await this.traceSessionHostAction("session_host_get_diagnostics", args, () => this.deps.sessionHostControl.getDiagnostics({
35209
35650
  includeSessions: args?.includeSessions !== false,
35210
35651
  limit: Number(args?.limit) || void 0
35211
- });
35652
+ }), (result) => ({
35653
+ includeSessions: args?.includeSessions !== false,
35654
+ limit: Number(args?.limit) || void 0,
35655
+ ...summarizeSessionHostDiagnostics(result)
35656
+ }));
35212
35657
  return { success: true, diagnostics };
35213
35658
  }
35214
35659
  case "session_host_list_sessions": {
35215
35660
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
35216
- const sessions = await this.deps.sessionHostControl.listSessions();
35661
+ const sessions = await this.traceSessionHostAction("session_host_list_sessions", args, () => this.deps.sessionHostControl.listSessions(), (records) => summarizeSessionHostRecords(records));
35217
35662
  return { success: true, sessions };
35218
35663
  }
35219
35664
  case "session_host_stop_session": {
35220
35665
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
35221
35666
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
35222
35667
  if (!sessionId) return { success: false, error: "sessionId required" };
35223
- const record2 = await this.deps.sessionHostControl.stopSession(sessionId);
35668
+ const record2 = await this.traceSessionHostAction("session_host_stop_session", args, () => this.deps.sessionHostControl.stopSession(sessionId), (result) => summarizeSessionHostRecord(result));
35224
35669
  return { success: true, record: record2 };
35225
35670
  }
35226
35671
  case "session_host_resume_session": {
35227
35672
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
35228
35673
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
35229
35674
  if (!sessionId) return { success: false, error: "sessionId required" };
35230
- const record2 = await this.deps.sessionHostControl.resumeSession(sessionId);
35231
- const hosted = toHostedCliRuntimeDescriptor(record2);
35232
- if (hosted) {
35233
- await this.deps.cliManager.restoreHostedSessions([hosted]);
35234
- }
35675
+ const record2 = await this.traceSessionHostAction("session_host_resume_session", args, async () => {
35676
+ const nextRecord = await this.deps.sessionHostControl.resumeSession(sessionId);
35677
+ const hosted = toHostedCliRuntimeDescriptor(nextRecord);
35678
+ if (hosted) {
35679
+ await this.deps.cliManager.restoreHostedSessions([hosted]);
35680
+ }
35681
+ return nextRecord;
35682
+ }, (result) => ({
35683
+ ...summarizeSessionHostRecord(result),
35684
+ restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
35685
+ }));
35235
35686
  return { success: true, record: record2 };
35236
35687
  }
35237
35688
  case "session_host_restart_session": {
35238
35689
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
35239
35690
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
35240
35691
  if (!sessionId) return { success: false, error: "sessionId required" };
35241
- const record2 = await this.deps.sessionHostControl.restartSession(sessionId);
35242
- const hosted = toHostedCliRuntimeDescriptor(record2);
35243
- if (hosted) {
35244
- await this.deps.cliManager.restoreHostedSessions([hosted]);
35245
- }
35692
+ const record2 = await this.traceSessionHostAction("session_host_restart_session", args, async () => {
35693
+ const nextRecord = await this.deps.sessionHostControl.restartSession(sessionId);
35694
+ const hosted = toHostedCliRuntimeDescriptor(nextRecord);
35695
+ if (hosted) {
35696
+ await this.deps.cliManager.restoreHostedSessions([hosted]);
35697
+ }
35698
+ return nextRecord;
35699
+ }, (result) => ({
35700
+ ...summarizeSessionHostRecord(result),
35701
+ restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
35702
+ }));
35246
35703
  return { success: true, record: record2 };
35247
35704
  }
35248
35705
  case "session_host_send_signal": {
@@ -35251,7 +35708,7 @@ var init_router = __esm({
35251
35708
  const signal = typeof args?.signal === "string" ? args.signal : "";
35252
35709
  if (!sessionId) return { success: false, error: "sessionId required" };
35253
35710
  if (!signal) return { success: false, error: "signal required" };
35254
- const record2 = await this.deps.sessionHostControl.sendSignal(sessionId, signal);
35711
+ const record2 = await this.traceSessionHostAction("session_host_send_signal", args, () => this.deps.sessionHostControl.sendSignal(sessionId, signal), (result) => summarizeSessionHostRecord(result));
35255
35712
  return { success: true, record: record2 };
35256
35713
  }
35257
35714
  case "session_host_force_detach_client": {
@@ -35260,16 +35717,16 @@ var init_router = __esm({
35260
35717
  const clientId = typeof args?.clientId === "string" ? args.clientId : "";
35261
35718
  if (!sessionId) return { success: false, error: "sessionId required" };
35262
35719
  if (!clientId) return { success: false, error: "clientId required" };
35263
- const record2 = await this.deps.sessionHostControl.forceDetachClient(sessionId, clientId);
35720
+ const record2 = await this.traceSessionHostAction("session_host_force_detach_client", args, () => this.deps.sessionHostControl.forceDetachClient(sessionId, clientId), (result) => summarizeSessionHostRecord(result));
35264
35721
  return { success: true, record: record2 };
35265
35722
  }
35266
35723
  case "session_host_prune_duplicate_sessions": {
35267
35724
  if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
35268
- const result = await this.deps.sessionHostControl.pruneDuplicateSessions({
35725
+ const result = await this.traceSessionHostAction("session_host_prune_duplicate_sessions", args, () => this.deps.sessionHostControl.pruneDuplicateSessions({
35269
35726
  providerType: typeof args?.providerType === "string" ? args.providerType : void 0,
35270
35727
  workspace: typeof args?.workspace === "string" ? args.workspace : void 0,
35271
35728
  dryRun: args?.dryRun === true
35272
- });
35729
+ }), (value) => summarizeSessionHostPruneResult(value));
35273
35730
  return { success: true, result };
35274
35731
  }
35275
35732
  case "session_host_acquire_write": {
@@ -35279,12 +35736,15 @@ var init_router = __esm({
35279
35736
  const ownerType = args?.ownerType === "agent" ? "agent" : "user";
35280
35737
  if (!sessionId) return { success: false, error: "sessionId required" };
35281
35738
  if (!clientId) return { success: false, error: "clientId required" };
35282
- const record2 = await this.deps.sessionHostControl.acquireWrite({
35739
+ const record2 = await this.traceSessionHostAction("session_host_acquire_write", args, () => this.deps.sessionHostControl.acquireWrite({
35283
35740
  sessionId,
35284
35741
  clientId,
35285
35742
  ownerType,
35286
35743
  force: args?.force !== false
35287
- });
35744
+ }), (result) => ({
35745
+ ...summarizeSessionHostRecord(result),
35746
+ ownerType
35747
+ }));
35288
35748
  return { success: true, record: record2 };
35289
35749
  }
35290
35750
  case "session_host_release_write": {
@@ -35293,7 +35753,10 @@ var init_router = __esm({
35293
35753
  const clientId = typeof args?.clientId === "string" ? args.clientId : "";
35294
35754
  if (!sessionId) return { success: false, error: "sessionId required" };
35295
35755
  if (!clientId) return { success: false, error: "clientId required" };
35296
- const record2 = await this.deps.sessionHostControl.releaseWrite({ sessionId, clientId });
35756
+ const record2 = await this.traceSessionHostAction("session_host_release_write", args, () => this.deps.sessionHostControl.releaseWrite({
35757
+ sessionId,
35758
+ clientId
35759
+ }), (result) => summarizeSessionHostRecord(result));
35297
35760
  return { success: true, record: record2 };
35298
35761
  }
35299
35762
  case "list_saved_sessions": {
@@ -35326,7 +35789,7 @@ var init_router = __esm({
35326
35789
  kind: saved?.kind || recent?.kind || kind,
35327
35790
  title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
35328
35791
  workspace: saved?.workspace || recent?.workspace || session.workspace,
35329
- currentModel: saved?.currentModel || recent?.currentModel,
35792
+ summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
35330
35793
  preview: session.preview,
35331
35794
  messageCount: session.messageCount,
35332
35795
  firstMessageAt: session.firstMessageAt,
@@ -35773,7 +36236,7 @@ var init_reporter = __esm({
35773
36236
  const ideSummary = ideStates.map((s) => {
35774
36237
  const msgs = s.activeChat?.messages?.length || 0;
35775
36238
  const exts = s.extensions.length;
35776
- return `${s.type}(${s.status},${msgs}msg,${exts}ext${s.currentModel ? ",model=" + s.currentModel : ""})`;
36239
+ return `${s.type}(${s.status},${msgs}msg,${exts}ext)`;
35777
36240
  }).join(", ");
35778
36241
  const cliSummary = cliStates.map((s) => `${s.type}(${s.status})`).join(", ");
35779
36242
  const acpSummary = acpStates.map((s) => `${s.type}(${s.status})`).join(", ");
@@ -35835,9 +36298,7 @@ var init_reporter = __esm({
35835
36298
  workspace: session.workspace ?? null,
35836
36299
  title: session.title,
35837
36300
  cdpConnected: session.cdpConnected,
35838
- currentModel: session.currentModel,
35839
- currentPlan: session.currentPlan,
35840
- currentAutoApprove: session.currentAutoApprove
36301
+ summaryMetadata: session.summaryMetadata
35841
36302
  })),
35842
36303
  p2p: payload.p2p,
35843
36304
  timestamp: now
@@ -35902,6 +36363,7 @@ var init_provider_adapter = __esm({
35902
36363
  "../../oss/packages/daemon-core/src/agent-stream/provider-adapter.ts"() {
35903
36364
  "use strict";
35904
36365
  init_control_effects();
36366
+ init_provider_patch_state();
35905
36367
  ProviderStreamAdapter = class {
35906
36368
  agentType;
35907
36369
  agentName;
@@ -36013,15 +36475,18 @@ var init_provider_adapter = __esm({
36013
36475
  status: data.status || "idle",
36014
36476
  messages: data.messages || [],
36015
36477
  inputContent: data.inputContent || "",
36016
- model: data.model,
36017
- mode: data.mode,
36018
36478
  activeModal: data.activeModal
36019
36479
  };
36020
36480
  if (typeof data.title === "string" && data.title.trim()) {
36021
36481
  state.title = data.title.trim();
36022
36482
  }
36023
36483
  const controlValues = extractProviderControlValues(this.provider.controls, data);
36024
- if (controlValues) state.controlValues = controlValues;
36484
+ const surface = resolveProviderStateSurface({
36485
+ controlValues,
36486
+ summaryMetadata: data.summaryMetadata
36487
+ });
36488
+ if (surface.controlValues) state.controlValues = surface.controlValues;
36489
+ if (surface.summaryMetadata) state.summaryMetadata = surface.summaryMetadata;
36025
36490
  const effects = normalizeProviderEffects(data);
36026
36491
  if (effects.length > 0) state.effects = effects;
36027
36492
  if (state.messages.length > 0) {
@@ -36302,7 +36767,8 @@ var init_manager2 = __esm({
36302
36767
  const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.cdpSessionId, expr, timeout);
36303
36768
  const state = await agent.adapter.readChat(evaluate);
36304
36769
  const stateError = this.getStateError(state);
36305
- 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) : ""}`);
36770
+ const selectedModelValue = typeof state.controlValues?.model === "string" ? state.controlValues.model : "";
36771
+ LOG.debug("AgentStream", `[AgentStream] readChat(${type}) result: status=${state.status} msgs=${state.messages?.length || 0} model=${selectedModelValue}${state.status === "error" ? " error=" + JSON.stringify(stateError) : ""}`);
36306
36772
  if (state.status === "error" && this.isRecoverableSessionError(stateError)) {
36307
36773
  throw new Error(stateError);
36308
36774
  }
@@ -36679,9 +37145,8 @@ function forwardAgentStreamsToIdeInstance(instanceManager, ideType, streams) {
36679
37145
  messages: stream.messages || [],
36680
37146
  status: stream.status || "idle",
36681
37147
  activeModal: stream.activeModal || null,
36682
- model: stream.model || void 0,
36683
- mode: stream.mode || void 0,
36684
37148
  controlValues: stream.controlValues || void 0,
37149
+ summaryMetadata: stream.summaryMetadata || void 0,
36685
37150
  effects: stream.effects || void 0,
36686
37151
  sessionId: stream.sessionId || stream.instanceId || void 0,
36687
37152
  title: stream.title || stream.agentName || void 0,
@@ -37228,7 +37693,11 @@ module.exports.setMode = (params) => {
37228
37693
  * 5. Approval dialog detection (buttons, modal)
37229
37694
  * 6. Input field selector
37230
37695
  *
37231
- * \u2192 { id, status, title, messages[], inputContent, activeModal }
37696
+ * Preferred live-state surface:
37697
+ * - controlValues: explicit current control selections (model/mode/etc.)
37698
+ * - summaryMetadata: compact always-visible metadata for dashboard/recent views
37699
+ * Legacy top-level model/mode output is no longer the preferred shape.
37700
+ * \u2192 { id, status, title, messages[], inputContent, activeModal, controlValues?, summaryMetadata? }
37232
37701
  */
37233
37702
  (() => {
37234
37703
  try {
@@ -37256,6 +37725,9 @@ module.exports.setMode = (params) => {
37256
37725
  messages,
37257
37726
  inputContent,
37258
37727
  activeModal,
37728
+ // TODO: Return explicit selections when available, e.g.
37729
+ // controlValues: { model: selectedModel, mode: selectedMode },
37730
+ // summaryMetadata: { items: [{ id: 'model', value: selectedModelLabel || selectedModel, shortValue: selectedModel, order: 10 }] },
37259
37731
  });
37260
37732
  } catch(e) {
37261
37733
  return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
@@ -39002,7 +39474,6 @@ async function handleCliStatus(ctx, _req, res) {
39002
39474
  lastMessage: s.activeChat?.messages?.slice(-1)[0] || null,
39003
39475
  activeModal: s.activeChat?.activeModal || null,
39004
39476
  pendingEvents: s.pendingEvents || [],
39005
- currentModel: s.currentModel,
39006
39477
  settings: s.settings
39007
39478
  }));
39008
39479
  ctx.json(res, 200, { instances: result, count: result.length });
@@ -40164,7 +40635,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
40164
40635
  lines.push("## Required Return Format");
40165
40636
  lines.push("| Function | Return JSON |");
40166
40637
  lines.push("|---|---|");
40167
- 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 |");
40638
+ 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 |");
40168
40639
  lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
40169
40640
  lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
40170
40641
  lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
@@ -41827,7 +42298,7 @@ var init_dev_server = __esm({
41827
42298
  lines.push("## Required Return Format");
41828
42299
  lines.push("| Function | Return JSON |");
41829
42300
  lines.push("|---|---|");
41830
- 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 |");
42301
+ 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 |");
41831
42302
  lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
41832
42303
  lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
41833
42304
  lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
@@ -42749,67 +43220,6 @@ var init_runtime_support = __esm({
42749
43220
  }
42750
43221
  });
42751
43222
 
42752
- // ../../oss/packages/daemon-core/src/session-host/runtime-surface.ts
42753
- function isSessionHostLiveRuntime2(record2) {
42754
- const lifecycle = String(record2?.lifecycle || "").trim();
42755
- return LIVE_LIFECYCLES2.has(lifecycle);
42756
- }
42757
- function getSessionHostRecoveryLabel2(meta3) {
42758
- const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
42759
- if (!recoveryState) return null;
42760
- if (recoveryState === "auto_resumed") return "restored after restart";
42761
- if (recoveryState === "resume_failed") return "restore failed";
42762
- if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
42763
- if (recoveryState === "orphan_snapshot") return "snapshot recovered";
42764
- return recoveryState.replace(/_/g, " ");
42765
- }
42766
- function isSessionHostRecoverySnapshot2(record2) {
42767
- if (!record2) return false;
42768
- if (isSessionHostLiveRuntime2(record2)) return false;
42769
- const lifecycle = String(record2.lifecycle || "").trim();
42770
- if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
42771
- return false;
42772
- }
42773
- const meta3 = record2.meta || void 0;
42774
- if (meta3?.restoredFromStorage === true) return true;
42775
- return getSessionHostRecoveryLabel2(meta3) !== null;
42776
- }
42777
- function getSessionHostSurfaceKind2(record2) {
42778
- if (isSessionHostLiveRuntime2(record2)) return "live_runtime";
42779
- if (isSessionHostRecoverySnapshot2(record2)) return "recovery_snapshot";
42780
- return "inactive_record";
42781
- }
42782
- function partitionSessionHostRecords(records) {
42783
- const liveRuntimes = [];
42784
- const recoverySnapshots = [];
42785
- const inactiveRecords = [];
42786
- for (const record2 of records) {
42787
- const kind = getSessionHostSurfaceKind2(record2);
42788
- if (kind === "live_runtime") {
42789
- liveRuntimes.push(record2);
42790
- } else if (kind === "recovery_snapshot") {
42791
- recoverySnapshots.push(record2);
42792
- } else {
42793
- inactiveRecords.push(record2);
42794
- }
42795
- }
42796
- return {
42797
- liveRuntimes,
42798
- recoverySnapshots,
42799
- inactiveRecords
42800
- };
42801
- }
42802
- function partitionSessionHostDiagnosticsSessions(records) {
42803
- return partitionSessionHostRecords(records || []);
42804
- }
42805
- var LIVE_LIFECYCLES2;
42806
- var init_runtime_surface = __esm({
42807
- "../../oss/packages/daemon-core/src/session-host/runtime-surface.ts"() {
42808
- "use strict";
42809
- LIVE_LIFECYCLES2 = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
42810
- }
42811
- });
42812
-
42813
43223
  // ../../oss/packages/daemon-core/src/session-host/startup-restore-policy.js
42814
43224
  function shouldAutoRestoreHostedSessionsOnStartup(env3 = process.env) {
42815
43225
  const raw = typeof env3.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP === "string" ? env3.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP.trim().toLowerCase() : "";
@@ -83547,7 +83957,7 @@ var init_adhdev_daemon = __esm({
83547
83957
  import_ws3 = require("ws");
83548
83958
  init_source();
83549
83959
  init_version();
83550
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.58" });
83960
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.60" });
83551
83961
  ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
83552
83962
  "generating",
83553
83963
  "waiting_approval",
@@ -85034,6 +85444,41 @@ ${source_default.cyan("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2
85034
85444
  }
85035
85445
  });
85036
85446
 
85447
+ // src/cli/runtime-target-trace.ts
85448
+ var runtime_target_trace_exports = {};
85449
+ __export(runtime_target_trace_exports, {
85450
+ buildRuntimeTargetResolutionTrace: () => buildRuntimeTargetResolutionTrace
85451
+ });
85452
+ async function buildRuntimeTargetResolutionTrace(records, target, options) {
85453
+ const attachable = options?.attachable === true;
85454
+ try {
85455
+ const record2 = attachable ? resolveAttachableRuntimeRecord(records, target) : resolveRuntimeRecord(records, target);
85456
+ return {
85457
+ target,
85458
+ attachable,
85459
+ sessionId: record2.sessionId,
85460
+ runtimeKey: record2.runtimeKey,
85461
+ displayName: record2.displayName,
85462
+ lifecycle: record2.lifecycle,
85463
+ surfaceKind: getSessionHostSurfaceKind(record2),
85464
+ attachedClientCount: Array.isArray(record2.attachedClients) ? record2.attachedClients.length : 0,
85465
+ writeOwnerClientId: record2.writeOwner?.clientId
85466
+ };
85467
+ } catch (error48) {
85468
+ return {
85469
+ target,
85470
+ attachable,
85471
+ error: error48?.message || String(error48)
85472
+ };
85473
+ }
85474
+ }
85475
+ var init_runtime_target_trace = __esm({
85476
+ "src/cli/runtime-target-trace.ts"() {
85477
+ "use strict";
85478
+ init_dist();
85479
+ }
85480
+ });
85481
+
85037
85482
  // ../../oss/packages/web-core/src/constants/supported.ts
85038
85483
  var supported_exports = {};
85039
85484
  __export(supported_exports, {
@@ -86045,12 +86490,24 @@ function formatSavedHistoryTimestamp(timestamp) {
86045
86490
  function getSavedHistoryStatusLabel(session) {
86046
86491
  return session.canResume ? "resume-ready" : "needs --dir";
86047
86492
  }
86493
+ function getSavedHistorySummaryValues(summaryMetadata) {
86494
+ if (!summaryMetadata || !Array.isArray(summaryMetadata.items)) return [];
86495
+ return summaryMetadata.items.map((item) => String(item?.value || item?.shortValue || "").trim()).filter(Boolean);
86496
+ }
86497
+ function getSavedHistorySummaryValue(session, id, options = {}) {
86498
+ const targetId = String(id || "").trim();
86499
+ if (!targetId || !session.summaryMetadata || !Array.isArray(session.summaryMetadata.items)) return "";
86500
+ const item = session.summaryMetadata.items.find((entry) => String(entry?.id || "").trim() === targetId);
86501
+ if (!item) return "";
86502
+ return String(options.preferShortValue ? item.shortValue || item.value || "" : item.value || item.shortValue || "").trim();
86503
+ }
86048
86504
  function buildSavedHistorySessionLines(session) {
86049
86505
  const title = session.title || session.providerSessionId;
86050
86506
  const locationParts = [session.providerSessionId];
86051
86507
  if (session.workspace) locationParts.push(session.workspace);
86052
86508
  const summaryParts = [`${session.messageCount || 0} msgs`];
86053
- if (session.currentModel) summaryParts.push(session.currentModel);
86509
+ const summaryValues = getSavedHistorySummaryValues(session.summaryMetadata);
86510
+ if (summaryValues.length > 0) summaryParts.push(...summaryValues);
86054
86511
  const updated = formatSavedHistoryTimestamp(session.lastMessageAt);
86055
86512
  if (updated !== "-") summaryParts.push(`updated ${updated}`);
86056
86513
  summaryParts.push(getSavedHistoryStatusLabel(session));
@@ -86080,7 +86537,7 @@ function filterSavedHistorySessions(sessions, options = {}) {
86080
86537
  if (!workspace.includes(workspaceQuery)) return false;
86081
86538
  }
86082
86539
  if (modelQuery) {
86083
- const model = String(session.currentModel || "").toLowerCase();
86540
+ const model = getSavedHistorySummaryValues(session.summaryMetadata).map((value) => value.toLowerCase()).join("\n");
86084
86541
  if (!model.includes(modelQuery)) return false;
86085
86542
  }
86086
86543
  return true;
@@ -86141,8 +86598,9 @@ function buildHistoryResumeLaunchPayload(cliType, session, overrideDir) {
86141
86598
  dir,
86142
86599
  resumeSessionId: session.providerSessionId
86143
86600
  };
86144
- if (typeof session.currentModel === "string" && session.currentModel.trim()) {
86145
- payload.initialModel = session.currentModel.trim();
86601
+ const initialModel = getSavedHistorySummaryValue(session, "model", { preferShortValue: true });
86602
+ if (initialModel) {
86603
+ payload.initialModel = initialModel;
86146
86604
  }
86147
86605
  return payload;
86148
86606
  }
@@ -86859,6 +87317,74 @@ function buildRuntimeOpenLaunchSpec(options) {
86859
87317
  return spec;
86860
87318
  }
86861
87319
 
87320
+ // src/cli/debug-trace-cli.ts
87321
+ function normalizeOptionalFilter(value) {
87322
+ if (typeof value !== "string") return void 0;
87323
+ const trimmed = value.trim();
87324
+ return trimmed ? trimmed : void 0;
87325
+ }
87326
+ function buildDebugTraceCommandArgs(options) {
87327
+ const category = normalizeOptionalFilter(options.category);
87328
+ const interactionId = normalizeOptionalFilter(options.interactionId);
87329
+ return {
87330
+ count: Math.max(1, Math.floor(options.count || 0) || 40),
87331
+ ...category && category !== "all" ? { category } : {},
87332
+ ...interactionId ? { interactionId } : {}
87333
+ };
87334
+ }
87335
+ function buildDebugTraceFollowPollArgs(options, cursor) {
87336
+ const base = buildDebugTraceCommandArgs(options);
87337
+ if (!cursor || cursor.lastTs <= 0) {
87338
+ return base;
87339
+ }
87340
+ return {
87341
+ ...base,
87342
+ since: Math.max(0, cursor.lastTs - 1)
87343
+ };
87344
+ }
87345
+ function collectFreshDebugTraceEntries(entries, cursor) {
87346
+ const previousTs = cursor?.lastTs ?? 0;
87347
+ const seenIdsAtLastTs = new Set(cursor?.seenIdsAtLastTs ?? []);
87348
+ const fresh = entries.filter((entry) => {
87349
+ const ts2 = Number(entry.ts || 0);
87350
+ if (ts2 > previousTs) return true;
87351
+ if (ts2 < previousTs) return false;
87352
+ return !seenIdsAtLastTs.has(entry.id);
87353
+ });
87354
+ if (entries.length === 0) {
87355
+ return {
87356
+ entries: fresh,
87357
+ cursor: cursor ?? { lastTs: 0, seenIdsAtLastTs: [] }
87358
+ };
87359
+ }
87360
+ const nextLastTs = entries.reduce((max, entry) => Math.max(max, Number(entry.ts || 0)), previousTs);
87361
+ const nextSeenIdsAtLastTs = Array.from(new Set(
87362
+ entries.filter((entry) => Number(entry.ts || 0) === nextLastTs).map((entry) => entry.id)
87363
+ ));
87364
+ return {
87365
+ entries: fresh,
87366
+ cursor: {
87367
+ lastTs: nextLastTs,
87368
+ seenIdsAtLastTs: nextSeenIdsAtLastTs
87369
+ }
87370
+ };
87371
+ }
87372
+ function formatPayload(payload) {
87373
+ if (!payload || Object.keys(payload).length === 0) return "";
87374
+ try {
87375
+ const raw = JSON.stringify(payload);
87376
+ return raw.length > 220 ? `${raw.slice(0, 220)}\u2026` : raw;
87377
+ } catch {
87378
+ return "[unserializable payload]";
87379
+ }
87380
+ }
87381
+ function formatDebugTraceEntryLine(entry) {
87382
+ const timestamp = new Date(entry.ts).toLocaleTimeString();
87383
+ const interactionLabel = entry.interactionId ? ` ix=${entry.interactionId}` : "";
87384
+ const payload = formatPayload(entry.payload);
87385
+ return `${timestamp} ${entry.level.toUpperCase()} ${entry.category}.${entry.stage}${interactionLabel}${payload ? ` ${payload}` : ""}`;
87386
+ }
87387
+
86862
87388
  // src/cli/daemon-commands.ts
86863
87389
  function hideCommand(command) {
86864
87390
  if (typeof command.hideHelp === "function") {
@@ -86914,6 +87440,12 @@ async function resolveRuntimeSessionId(target, options) {
86914
87440
  if (!envelope?.success || !Array.isArray(envelope?.result)) {
86915
87441
  throw new Error(envelope?.error || "Failed to list runtimes");
86916
87442
  }
87443
+ if (process.env.ADHDEV_SESSION_HOST_TRACE === "1") {
87444
+ const { buildRuntimeTargetResolutionTrace: buildRuntimeTargetResolutionTrace2 } = await Promise.resolve().then(() => (init_runtime_target_trace(), runtime_target_trace_exports));
87445
+ const trace = await buildRuntimeTargetResolutionTrace2(envelope.result, target, { attachable: options?.attachable === true });
87446
+ process.stderr.write(`[session-host-trace] runtime_target_resolution ${JSON.stringify(trace)}
87447
+ `);
87448
+ }
86917
87449
  if (options?.attachable === true) {
86918
87450
  const { resolveAttachableRuntimeRecord: resolveAttachableRuntimeRecord2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
86919
87451
  return resolveAttachableRuntimeRecord2(envelope.result, target).sessionId;
@@ -87054,6 +87586,112 @@ async function printRuntimeGroups(records, options) {
87054
87586
  console.log();
87055
87587
  }
87056
87588
  }
87589
+ async function handleTraceCommand(options) {
87590
+ const port = parseInt(String(options.port ?? "19222"), 10) || 19222;
87591
+ const count = Math.max(1, Math.min(500, parseInt(String(options.count ?? "40"), 10) || 40));
87592
+ const intervalMs = Math.max(250, Math.min(3e4, parseInt(String(options.interval ?? "1500"), 10) || 1500));
87593
+ const baseArgs = {
87594
+ count,
87595
+ category: options.category,
87596
+ interactionId: options.interaction
87597
+ };
87598
+ const fetchTrace = async (args) => {
87599
+ const traceResult = await sendDaemonCommandSafe("get_debug_trace", args, port);
87600
+ const payload = traceResult?.result || traceResult;
87601
+ if (!payload?.success) {
87602
+ throw new Error(payload?.error || "debug trace query failed");
87603
+ }
87604
+ return Array.isArray(payload?.trace) ? payload.trace : [];
87605
+ };
87606
+ if (!options.follow) {
87607
+ const args = buildDebugTraceCommandArgs(baseArgs);
87608
+ const trace = await fetchTrace(args);
87609
+ if (options.json) {
87610
+ console.log(JSON.stringify({
87611
+ port,
87612
+ count: trace.length,
87613
+ query: args,
87614
+ trace
87615
+ }, null, 2));
87616
+ return;
87617
+ }
87618
+ console.log(source_default.bold("\n Structured Daemon Trace\n"));
87619
+ console.log(source_default.gray(` Port: ${port}`));
87620
+ console.log(source_default.gray(` Category: ${args.category || "all"}`));
87621
+ console.log(source_default.gray(` Interaction: ${args.interactionId || "-"}`));
87622
+ console.log(source_default.gray(` Entries: ${trace.length}`));
87623
+ console.log();
87624
+ if (trace.length === 0) {
87625
+ console.log(source_default.gray(" No trace entries found. Start the daemon with `adhdev daemon --dev` or `adhdev daemon --trace`."));
87626
+ console.log();
87627
+ return;
87628
+ }
87629
+ for (const entry of trace) {
87630
+ console.log(source_default.gray(` ${formatDebugTraceEntryLine(entry)}`));
87631
+ }
87632
+ console.log();
87633
+ return;
87634
+ }
87635
+ let stopped = false;
87636
+ const stopFollowing = () => {
87637
+ stopped = true;
87638
+ };
87639
+ process.once("SIGINT", stopFollowing);
87640
+ process.once("SIGTERM", stopFollowing);
87641
+ try {
87642
+ let cursor = void 0;
87643
+ const initialTrace = await fetchTrace(buildDebugTraceFollowPollArgs(baseArgs));
87644
+ const initialBatch = collectFreshDebugTraceEntries(initialTrace, cursor);
87645
+ cursor = initialBatch.cursor;
87646
+ if (options.json) {
87647
+ for (const entry of initialBatch.entries) {
87648
+ console.log(JSON.stringify(entry));
87649
+ }
87650
+ } else {
87651
+ console.log(source_default.bold("\n Structured Daemon Trace\n"));
87652
+ console.log(source_default.gray(` Port: ${port}`));
87653
+ console.log(source_default.gray(` Category: ${buildDebugTraceCommandArgs(baseArgs).category || "all"}`));
87654
+ console.log(source_default.gray(` Interaction: ${buildDebugTraceCommandArgs(baseArgs).interactionId || "-"}`));
87655
+ console.log(source_default.gray(` Initial: ${initialBatch.entries.length}`));
87656
+ console.log(source_default.gray(` Follow: every ${intervalMs}ms (Ctrl+C to stop)`));
87657
+ console.log();
87658
+ if (initialBatch.entries.length === 0) {
87659
+ console.log(source_default.gray(" No trace entries yet. Waiting for new entries..."));
87660
+ console.log();
87661
+ } else {
87662
+ for (const entry of initialBatch.entries) {
87663
+ console.log(source_default.gray(` ${formatDebugTraceEntryLine(entry)}`));
87664
+ }
87665
+ console.log();
87666
+ }
87667
+ }
87668
+ while (!stopped) {
87669
+ await new Promise((resolve17) => setTimeout(resolve17, intervalMs));
87670
+ if (stopped) break;
87671
+ const nextTrace = await fetchTrace(buildDebugTraceFollowPollArgs(baseArgs, cursor));
87672
+ const nextBatch = collectFreshDebugTraceEntries(nextTrace, cursor);
87673
+ cursor = nextBatch.cursor;
87674
+ if (nextBatch.entries.length === 0) continue;
87675
+ if (options.json) {
87676
+ for (const entry of nextBatch.entries) {
87677
+ console.log(JSON.stringify(entry));
87678
+ }
87679
+ continue;
87680
+ }
87681
+ for (const entry of nextBatch.entries) {
87682
+ console.log(source_default.gray(` ${formatDebugTraceEntryLine(entry)}`));
87683
+ }
87684
+ }
87685
+ } finally {
87686
+ process.off("SIGINT", stopFollowing);
87687
+ process.off("SIGTERM", stopFollowing);
87688
+ }
87689
+ if (!options.json) {
87690
+ console.log();
87691
+ console.log(source_default.gray(" Trace follow stopped."));
87692
+ console.log();
87693
+ }
87694
+ }
87057
87695
  function registerDaemonCommands(program2, pkgVersion3) {
87058
87696
  program2.command("daemon").description("\u{1F680} Start ADHDev Daemon \u2014 unified hub for IDE monitoring, agent management, and remote control").option("-p, --port <port>", "Local WS server port", "19222").option("--server <url>", "Override server URL for testing").option("--dev", "Enable Dev Mode \u2014 HTTP API on :19280 for script debugging + structured trace collection").option("--log-level <level>", "Console log level (debug|info|warn|error)").option("--trace", "Enable structured debug trace collection").option("--trace-content", "Include richer content snapshots in debug traces").option("--trace-buffer-size <count>", "Structured trace ring buffer size").action(async (options) => {
87059
87697
  const { AdhdevDaemon: AdhdevDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
@@ -87069,6 +87707,16 @@ function registerDaemonCommands(program2, pkgVersion3) {
87069
87707
  traceBufferSize: options.traceBufferSize ? parseInt(options.traceBufferSize, 10) || void 0 : void 0
87070
87708
  });
87071
87709
  });
87710
+ program2.command("trace").description("Inspect structured daemon trace from the running local daemon (for example: --category session_host)").option("-p, --port <port>", "Local daemon IPC port", "19222").option("--category <category>", "Filter by trace category (for example: session_host)").option("--interaction <id>", "Filter by interaction id").option("--count <count>", "Maximum number of trace entries to fetch", "40").option("--follow", "Keep polling and print new trace entries as they arrive").option("--interval <ms>", "Polling interval for --follow mode", "1500").option("--json", "Print raw trace JSON output").action(async (options) => {
87711
+ try {
87712
+ await handleTraceCommand(options);
87713
+ } catch (error48) {
87714
+ console.error(source_default.red(`
87715
+ \u2717 ${error48?.message || String(error48)}
87716
+ `));
87717
+ process.exit(1);
87718
+ }
87719
+ });
87072
87720
  program2.command("standalone").description("\u{1F5A5}\uFE0F Start ADHDev Standalone Server (Local Dashboard & Embedded Daemon)").option("-p, --port <port>", "Local HTTP/WS server port", "3847").option("--host <host>", "Bind to specific host (use 0.0.0.0 for LAN access)").option("--no-open", "Prevent opening browser automatically").option("--token <token>", "Require token authentication").option("--dev", "Enable Dev Mode").action(async (options) => {
87073
87721
  const { spawn: spawn6, execSync: execSync8 } = await import("child_process");
87074
87722
  const { DEFAULT_STANDALONE_SESSION_HOST_APP_NAME: DEFAULT_STANDALONE_SESSION_HOST_APP_NAME2, resolveSessionHostAppName: resolveSessionHostAppName2 } = await Promise.resolve().then(() => (init_src(), src_exports));
@@ -89784,6 +90432,7 @@ void (async () => {
89784
90432
  console.log(source_default.gray(" adhdev update \u2014 Upgrade to latest version"));
89785
90433
  console.log();
89786
90434
  console.log(source_default.gray(" Advanced tools:"));
90435
+ console.log(source_default.gray(" adhdev trace --category session_host \u2014 Inspect structured daemon trace"));
89787
90436
  console.log(source_default.gray(" adhdev service \u2014 Manage OS background auto-start service"));
89788
90437
  console.log(source_default.gray(" adhdev provider ... \u2014 Provider development commands"));
89789
90438
  console.log(source_default.gray(" adhdev cdp ... \u2014 CDP debugging tools"));