adhdev 0.8.58 → 0.8.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +832 -194
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +589 -190
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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 || []].
|
|
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
|
-
|
|
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
|
-
}).
|
|
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
|
-
|
|
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
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
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
|
|
3911
|
-
|
|
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
|
-
|
|
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
|
|
4407
|
-
|
|
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
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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) {
|
|
@@ -12154,6 +12335,7 @@ var init_cli_provider_instance = __esm({
|
|
|
12154
12335
|
init_control_effects();
|
|
12155
12336
|
init_approval_utils();
|
|
12156
12337
|
init_cli_script_results();
|
|
12338
|
+
init_provider_patch_state();
|
|
12157
12339
|
CachedDatabaseSync = null;
|
|
12158
12340
|
CliProviderInstance = class {
|
|
12159
12341
|
constructor(provider, workingDir, cliArgs = [], instanceId, transportFactory, options) {
|
|
@@ -12183,6 +12365,7 @@ var init_cli_provider_instance = __esm({
|
|
|
12183
12365
|
generatingDebouncePending = null;
|
|
12184
12366
|
lastApprovalEventAt = 0;
|
|
12185
12367
|
controlValues = {};
|
|
12368
|
+
summaryMetadata = void 0;
|
|
12186
12369
|
appliedEffectKeys = /* @__PURE__ */ new Set();
|
|
12187
12370
|
historyWriter;
|
|
12188
12371
|
runtimeMessages = [];
|
|
@@ -12325,13 +12508,7 @@ var init_cli_provider_instance = __esm({
|
|
|
12325
12508
|
if (historyMessageCount !== null) {
|
|
12326
12509
|
parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
|
|
12327
12510
|
}
|
|
12328
|
-
const controlValues = extractProviderControlValues(this.provider.controls, parsedStatus);
|
|
12329
|
-
if (controlValues) {
|
|
12330
|
-
this.controlValues = { ...this.controlValues, ...controlValues };
|
|
12331
|
-
}
|
|
12332
12511
|
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
12512
|
const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
|
|
12336
12513
|
if (parsedMessages.length > 0) {
|
|
12337
12514
|
const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
|
|
@@ -12353,6 +12530,10 @@ var init_cli_provider_instance = __esm({
|
|
|
12353
12530
|
}
|
|
12354
12531
|
}
|
|
12355
12532
|
this.applyProviderResponse(parsedStatus, { phase: "immediate" });
|
|
12533
|
+
const surface = resolveProviderStateSurface({
|
|
12534
|
+
summaryMetadata: this.summaryMetadata,
|
|
12535
|
+
controlValues: this.controlValues
|
|
12536
|
+
});
|
|
12356
12537
|
return {
|
|
12357
12538
|
type: this.type,
|
|
12358
12539
|
name: this.provider.name,
|
|
@@ -12368,8 +12549,6 @@ var init_cli_provider_instance = __esm({
|
|
|
12368
12549
|
inputContent: ""
|
|
12369
12550
|
},
|
|
12370
12551
|
workspace: this.workingDir,
|
|
12371
|
-
currentModel,
|
|
12372
|
-
currentPlan,
|
|
12373
12552
|
instanceId: this.instanceId,
|
|
12374
12553
|
providerSessionId: this.providerSessionId,
|
|
12375
12554
|
lastUpdated: Date.now(),
|
|
@@ -12384,8 +12563,9 @@ var init_cli_provider_instance = __esm({
|
|
|
12384
12563
|
attachedClients: runtime.attachedClients || []
|
|
12385
12564
|
} : void 0,
|
|
12386
12565
|
resume: this.provider.resume,
|
|
12387
|
-
controlValues:
|
|
12388
|
-
providerControls: this.provider.controls
|
|
12566
|
+
controlValues: surface.controlValues,
|
|
12567
|
+
providerControls: this.provider.controls,
|
|
12568
|
+
summaryMetadata: surface.summaryMetadata
|
|
12389
12569
|
};
|
|
12390
12570
|
}
|
|
12391
12571
|
setPresentationMode(mode) {
|
|
@@ -12589,10 +12769,14 @@ var init_cli_provider_instance = __esm({
|
|
|
12589
12769
|
this.suppressIdleHistoryReplay = false;
|
|
12590
12770
|
this.adapter.clearHistory();
|
|
12591
12771
|
}
|
|
12592
|
-
const
|
|
12593
|
-
|
|
12594
|
-
|
|
12595
|
-
|
|
12772
|
+
const patchedState = mergeProviderPatchState({
|
|
12773
|
+
providerControls: this.provider.controls,
|
|
12774
|
+
data,
|
|
12775
|
+
currentControlValues: this.controlValues,
|
|
12776
|
+
currentSummaryMetadata: this.summaryMetadata
|
|
12777
|
+
});
|
|
12778
|
+
this.controlValues = patchedState.controlValues;
|
|
12779
|
+
this.summaryMetadata = patchedState.summaryMetadata;
|
|
12596
12780
|
const effects = normalizeProviderEffects(data);
|
|
12597
12781
|
for (const effect of effects) {
|
|
12598
12782
|
const effectWhen = effect.when || "immediate";
|
|
@@ -29239,6 +29423,7 @@ var init_acp_provider_instance = __esm({
|
|
|
29239
29423
|
init_acp();
|
|
29240
29424
|
init_contracts();
|
|
29241
29425
|
init_status_monitor();
|
|
29426
|
+
init_summary_metadata();
|
|
29242
29427
|
init_logger();
|
|
29243
29428
|
AcpProviderInstance = class {
|
|
29244
29429
|
constructor(provider, workingDir, cliArgs = []) {
|
|
@@ -29267,8 +29452,7 @@ var init_acp_provider_instance = __esm({
|
|
|
29267
29452
|
lastStatus = "starting";
|
|
29268
29453
|
generatingStartedAt = 0;
|
|
29269
29454
|
agentCapabilities = {};
|
|
29270
|
-
|
|
29271
|
-
currentMode;
|
|
29455
|
+
currentSelections = {};
|
|
29272
29456
|
activeToolCalls = [];
|
|
29273
29457
|
stopReason = null;
|
|
29274
29458
|
partialContent = "";
|
|
@@ -29348,8 +29532,6 @@ var init_acp_provider_instance = __esm({
|
|
|
29348
29532
|
inputContent: ""
|
|
29349
29533
|
},
|
|
29350
29534
|
workspace: this.workingDir,
|
|
29351
|
-
currentModel: this.currentModel,
|
|
29352
|
-
currentPlan: this.currentMode,
|
|
29353
29535
|
instanceId: this.instanceId,
|
|
29354
29536
|
lastUpdated: Date.now(),
|
|
29355
29537
|
settings: this.settings,
|
|
@@ -29360,11 +29542,9 @@ var init_acp_provider_instance = __esm({
|
|
|
29360
29542
|
// Error details for dashboard display
|
|
29361
29543
|
errorMessage: this.errorMessage || void 0,
|
|
29362
29544
|
errorReason: this.errorReason || void 0,
|
|
29363
|
-
controlValues:
|
|
29364
|
-
|
|
29365
|
-
|
|
29366
|
-
},
|
|
29367
|
-
providerControls: this.provider.controls
|
|
29545
|
+
controlValues: this.getSelectionControlValues(),
|
|
29546
|
+
providerControls: this.provider.controls,
|
|
29547
|
+
summaryMetadata: this.buildSelectionSummaryMetadata()
|
|
29368
29548
|
};
|
|
29369
29549
|
}
|
|
29370
29550
|
onEvent(event, data) {
|
|
@@ -29398,6 +29578,54 @@ var init_acp_provider_instance = __esm({
|
|
|
29398
29578
|
getInstanceId() {
|
|
29399
29579
|
return this.instanceId;
|
|
29400
29580
|
}
|
|
29581
|
+
resolveConfigOptionLabel(category, value) {
|
|
29582
|
+
if (!value) return void 0;
|
|
29583
|
+
const option = this.configOptions.find((entry) => entry.category === category);
|
|
29584
|
+
return option?.options.find((candidate) => candidate.value === value)?.name || value;
|
|
29585
|
+
}
|
|
29586
|
+
resolveModeLabel(modeId) {
|
|
29587
|
+
if (!modeId) return void 0;
|
|
29588
|
+
return this.availableModes.find((mode) => mode.id === modeId)?.name || modeId;
|
|
29589
|
+
}
|
|
29590
|
+
getCurrentSelection(category) {
|
|
29591
|
+
return this.currentSelections[category];
|
|
29592
|
+
}
|
|
29593
|
+
setCurrentSelection(category, value) {
|
|
29594
|
+
const normalized = typeof value === "string" ? value.trim() : "";
|
|
29595
|
+
if (normalized) {
|
|
29596
|
+
this.currentSelections[category] = normalized;
|
|
29597
|
+
return;
|
|
29598
|
+
}
|
|
29599
|
+
delete this.currentSelections[category];
|
|
29600
|
+
}
|
|
29601
|
+
getSelectionControlValues() {
|
|
29602
|
+
const model = this.getCurrentSelection("model");
|
|
29603
|
+
const mode = this.getCurrentSelection("mode");
|
|
29604
|
+
return {
|
|
29605
|
+
...model ? { model } : {},
|
|
29606
|
+
...mode ? { mode } : {}
|
|
29607
|
+
};
|
|
29608
|
+
}
|
|
29609
|
+
resolveSelectionLabel(category, value) {
|
|
29610
|
+
if (!value) return void 0;
|
|
29611
|
+
const configLabel = this.resolveConfigOptionLabel(category, value);
|
|
29612
|
+
if (configLabel && configLabel !== value) return configLabel;
|
|
29613
|
+
if (category === "mode") {
|
|
29614
|
+
const modeLabel = this.resolveModeLabel(value);
|
|
29615
|
+
if (modeLabel) return modeLabel;
|
|
29616
|
+
}
|
|
29617
|
+
return configLabel || value;
|
|
29618
|
+
}
|
|
29619
|
+
buildSelectionSummaryMetadata() {
|
|
29620
|
+
const model = this.getCurrentSelection("model");
|
|
29621
|
+
const mode = this.getCurrentSelection("mode");
|
|
29622
|
+
return buildLegacyModelModeSummaryMetadata({
|
|
29623
|
+
model,
|
|
29624
|
+
mode,
|
|
29625
|
+
modelLabel: this.resolveSelectionLabel("model", model),
|
|
29626
|
+
modeLabel: this.resolveSelectionLabel("mode", mode)
|
|
29627
|
+
});
|
|
29628
|
+
}
|
|
29401
29629
|
// ─── ACP Config Options & Modes ─────────────────────
|
|
29402
29630
|
parseConfigOptions(raw) {
|
|
29403
29631
|
if (!Array.isArray(raw)) return;
|
|
@@ -29429,12 +29657,14 @@ var init_acp_provider_instance = __esm({
|
|
|
29429
29657
|
}
|
|
29430
29658
|
}
|
|
29431
29659
|
this.configOptions.push({ category, configId, currentValue, options: flatOptions });
|
|
29432
|
-
if (category === "model"
|
|
29660
|
+
if (category === "model" || category === "mode") {
|
|
29661
|
+
this.setCurrentSelection(category, currentValue);
|
|
29662
|
+
}
|
|
29433
29663
|
}
|
|
29434
29664
|
}
|
|
29435
29665
|
parseModes(raw) {
|
|
29436
29666
|
if (!raw) return;
|
|
29437
|
-
|
|
29667
|
+
this.setCurrentSelection("mode", raw.currentModeId);
|
|
29438
29668
|
if (Array.isArray(raw.availableModes)) {
|
|
29439
29669
|
this.availableModes = raw.availableModes.map((m) => ({
|
|
29440
29670
|
id: m.id,
|
|
@@ -29453,8 +29683,7 @@ var init_acp_provider_instance = __esm({
|
|
|
29453
29683
|
if (this.useStaticConfig) {
|
|
29454
29684
|
opt.currentValue = value;
|
|
29455
29685
|
this.selectedConfig[opt.configId] = value;
|
|
29456
|
-
if (category === "model") this.
|
|
29457
|
-
if (category === "mode") this.currentMode = value;
|
|
29686
|
+
if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
|
|
29458
29687
|
this.log.info(`[${this.type}] Static config ${category} set to: ${value} \u2014 restarting agent`);
|
|
29459
29688
|
await this.restartWithNewConfig();
|
|
29460
29689
|
return;
|
|
@@ -29472,7 +29701,7 @@ var init_acp_provider_instance = __esm({
|
|
|
29472
29701
|
value
|
|
29473
29702
|
});
|
|
29474
29703
|
opt.currentValue = value;
|
|
29475
|
-
if (category === "model") this.
|
|
29704
|
+
if (category === "model" || category === "mode") this.setCurrentSelection(category, value);
|
|
29476
29705
|
if (result?.configOptions) this.parseConfigOptions(result.configOptions);
|
|
29477
29706
|
this.log.info(`[${this.type}] Config ${category} set to: ${value} | response: ${JSON.stringify(result)?.slice(0, 300)}`);
|
|
29478
29707
|
} catch (e) {
|
|
@@ -29488,7 +29717,7 @@ var init_acp_provider_instance = __esm({
|
|
|
29488
29717
|
opt.currentValue = modeId;
|
|
29489
29718
|
this.selectedConfig[opt.configId] = modeId;
|
|
29490
29719
|
}
|
|
29491
|
-
this.
|
|
29720
|
+
this.setCurrentSelection("mode", modeId);
|
|
29492
29721
|
this.log.info(`[${this.type}] Static mode set to: ${modeId} \u2014 restarting agent`);
|
|
29493
29722
|
await this.restartWithNewConfig();
|
|
29494
29723
|
return;
|
|
@@ -29503,7 +29732,7 @@ var init_acp_provider_instance = __esm({
|
|
|
29503
29732
|
sessionId: this.sessionId,
|
|
29504
29733
|
modeId
|
|
29505
29734
|
});
|
|
29506
|
-
this.
|
|
29735
|
+
this.setCurrentSelection("mode", modeId);
|
|
29507
29736
|
this.log.info(`[${this.type}] Mode set to: ${modeId}`);
|
|
29508
29737
|
} catch (e) {
|
|
29509
29738
|
const message = e?.message || "Unknown ACP mode error";
|
|
@@ -29761,8 +29990,8 @@ var init_acp_provider_instance = __esm({
|
|
|
29761
29990
|
if (result?.modes) this.log.debug(`[${this.type}] modes: ${JSON.stringify(result.modes).slice(0, 300)}`);
|
|
29762
29991
|
this.parseConfigOptions(result?.configOptions);
|
|
29763
29992
|
this.parseModes(result?.modes);
|
|
29764
|
-
if (!this.
|
|
29765
|
-
this.
|
|
29993
|
+
if (!this.getCurrentSelection("model") && result?.models?.currentModelId) {
|
|
29994
|
+
this.setCurrentSelection("model", result.models.currentModelId);
|
|
29766
29995
|
}
|
|
29767
29996
|
if (this.configOptions.length === 0 && this.provider.staticConfigOptions?.length) {
|
|
29768
29997
|
this.useStaticConfig = true;
|
|
@@ -29776,13 +30005,16 @@ var init_acp_provider_instance = __esm({
|
|
|
29776
30005
|
});
|
|
29777
30006
|
if (defaultVal) {
|
|
29778
30007
|
this.selectedConfig[sc.configId] = defaultVal;
|
|
29779
|
-
if (sc.category === "model"
|
|
29780
|
-
|
|
30008
|
+
if (sc.category === "model" || sc.category === "mode") {
|
|
30009
|
+
this.setCurrentSelection(sc.category, defaultVal);
|
|
30010
|
+
}
|
|
29781
30011
|
}
|
|
29782
30012
|
}
|
|
29783
30013
|
this.log.info(`[${this.type}] Using static configOptions (${this.configOptions.length} options)`);
|
|
29784
30014
|
}
|
|
29785
|
-
|
|
30015
|
+
const currentModel = this.getCurrentSelection("model");
|
|
30016
|
+
const currentMode = this.getCurrentSelection("mode");
|
|
30017
|
+
this.log.info(`[${this.type}] Session created: ${this.sessionId}${currentModel ? ` (model: ${currentModel})` : ""}${currentMode ? ` (mode: ${currentMode})` : ""}`);
|
|
29786
30018
|
if (this.configOptions.length > 0) {
|
|
29787
30019
|
this.log.info(`[${this.type}] Config options: ${this.configOptions.map((c) => `${c.category}(${c.options.length})`).join(", ")}`);
|
|
29788
30020
|
}
|
|
@@ -29957,7 +30189,7 @@ var init_acp_provider_instance = __esm({
|
|
|
29957
30189
|
break;
|
|
29958
30190
|
}
|
|
29959
30191
|
case "current_mode_update": {
|
|
29960
|
-
this.
|
|
30192
|
+
this.setCurrentSelection("mode", update.currentModeId);
|
|
29961
30193
|
break;
|
|
29962
30194
|
}
|
|
29963
30195
|
case "config_option_update": {
|
|
@@ -30030,7 +30262,7 @@ var init_acp_provider_instance = __esm({
|
|
|
30030
30262
|
this.detectStatusTransition();
|
|
30031
30263
|
}
|
|
30032
30264
|
if (params.model) {
|
|
30033
|
-
this.
|
|
30265
|
+
this.setCurrentSelection("model", params.model);
|
|
30034
30266
|
}
|
|
30035
30267
|
}
|
|
30036
30268
|
/** Map SDK ToolCallStatus to internal status */
|
|
@@ -30312,6 +30544,7 @@ var init_cli_manager = __esm({
|
|
|
30312
30544
|
init_workspaces();
|
|
30313
30545
|
init_recent_activity();
|
|
30314
30546
|
init_saved_sessions();
|
|
30547
|
+
init_summary_metadata();
|
|
30315
30548
|
init_cli_provider_instance();
|
|
30316
30549
|
init_acp_provider_instance();
|
|
30317
30550
|
init_contracts();
|
|
@@ -30343,7 +30576,11 @@ var init_cli_manager = __esm({
|
|
|
30343
30576
|
}
|
|
30344
30577
|
persistRecentActivity(entry) {
|
|
30345
30578
|
try {
|
|
30346
|
-
|
|
30579
|
+
const summaryMetadata = normalizeProviderSummaryMetadata(entry.summaryMetadata);
|
|
30580
|
+
let nextState = appendRecentActivity(loadState(), {
|
|
30581
|
+
...entry,
|
|
30582
|
+
summaryMetadata
|
|
30583
|
+
});
|
|
30347
30584
|
if (entry.providerSessionId && (entry.kind === "cli" || entry.kind === "acp")) {
|
|
30348
30585
|
nextState = upsertSavedProviderSession(nextState, {
|
|
30349
30586
|
kind: entry.kind,
|
|
@@ -30351,7 +30588,7 @@ var init_cli_manager = __esm({
|
|
|
30351
30588
|
providerName: entry.providerName,
|
|
30352
30589
|
providerSessionId: entry.providerSessionId,
|
|
30353
30590
|
workspace: entry.workspace,
|
|
30354
|
-
|
|
30591
|
+
summaryMetadata,
|
|
30355
30592
|
title: entry.title
|
|
30356
30593
|
});
|
|
30357
30594
|
}
|
|
@@ -30541,7 +30778,7 @@ ${installInfo}`
|
|
|
30541
30778
|
providerType: normalizedType,
|
|
30542
30779
|
providerName: provider.displayName || provider.name || normalizedType,
|
|
30543
30780
|
workspace: resolvedDir,
|
|
30544
|
-
|
|
30781
|
+
summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
|
|
30545
30782
|
sessionId,
|
|
30546
30783
|
title: provider.displayName || provider.name || normalizedType
|
|
30547
30784
|
});
|
|
@@ -30643,7 +30880,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
30643
30880
|
providerName: provider?.displayName || provider?.name || normalizedType,
|
|
30644
30881
|
providerSessionId: sessionBinding.providerSessionId,
|
|
30645
30882
|
workspace: resolvedDir,
|
|
30646
|
-
|
|
30883
|
+
summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
|
|
30647
30884
|
sessionId: key,
|
|
30648
30885
|
title: provider?.displayName || provider?.name || normalizedType
|
|
30649
30886
|
});
|
|
@@ -34576,7 +34813,90 @@ var init_command_log = __esm({
|
|
|
34576
34813
|
}
|
|
34577
34814
|
});
|
|
34578
34815
|
|
|
34816
|
+
// ../../oss/packages/daemon-core/src/session-host/runtime-surface.ts
|
|
34817
|
+
function isSessionHostLiveRuntime2(record2) {
|
|
34818
|
+
const lifecycle = String(record2?.lifecycle || "").trim();
|
|
34819
|
+
return LIVE_LIFECYCLES2.has(lifecycle);
|
|
34820
|
+
}
|
|
34821
|
+
function getSessionHostRecoveryLabel2(meta3) {
|
|
34822
|
+
const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
|
|
34823
|
+
if (!recoveryState) return null;
|
|
34824
|
+
if (recoveryState === "auto_resumed") return "restored after restart";
|
|
34825
|
+
if (recoveryState === "resume_failed") return "restore failed";
|
|
34826
|
+
if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
|
|
34827
|
+
if (recoveryState === "orphan_snapshot") return "snapshot recovered";
|
|
34828
|
+
return recoveryState.replace(/_/g, " ");
|
|
34829
|
+
}
|
|
34830
|
+
function isSessionHostRecoverySnapshot2(record2) {
|
|
34831
|
+
if (!record2) return false;
|
|
34832
|
+
if (isSessionHostLiveRuntime2(record2)) return false;
|
|
34833
|
+
const lifecycle = String(record2.lifecycle || "").trim();
|
|
34834
|
+
if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
|
|
34835
|
+
return false;
|
|
34836
|
+
}
|
|
34837
|
+
const meta3 = record2.meta || void 0;
|
|
34838
|
+
if (meta3?.restoredFromStorage === true) return true;
|
|
34839
|
+
return getSessionHostRecoveryLabel2(meta3) !== null;
|
|
34840
|
+
}
|
|
34841
|
+
function getSessionHostSurfaceKind2(record2) {
|
|
34842
|
+
if (isSessionHostLiveRuntime2(record2)) return "live_runtime";
|
|
34843
|
+
if (isSessionHostRecoverySnapshot2(record2)) return "recovery_snapshot";
|
|
34844
|
+
return "inactive_record";
|
|
34845
|
+
}
|
|
34846
|
+
function partitionSessionHostRecords(records) {
|
|
34847
|
+
const liveRuntimes = [];
|
|
34848
|
+
const recoverySnapshots = [];
|
|
34849
|
+
const inactiveRecords = [];
|
|
34850
|
+
for (const record2 of records) {
|
|
34851
|
+
const kind = getSessionHostSurfaceKind2(record2);
|
|
34852
|
+
if (kind === "live_runtime") {
|
|
34853
|
+
liveRuntimes.push(record2);
|
|
34854
|
+
} else if (kind === "recovery_snapshot") {
|
|
34855
|
+
recoverySnapshots.push(record2);
|
|
34856
|
+
} else {
|
|
34857
|
+
inactiveRecords.push(record2);
|
|
34858
|
+
}
|
|
34859
|
+
}
|
|
34860
|
+
return {
|
|
34861
|
+
liveRuntimes,
|
|
34862
|
+
recoverySnapshots,
|
|
34863
|
+
inactiveRecords
|
|
34864
|
+
};
|
|
34865
|
+
}
|
|
34866
|
+
function partitionSessionHostDiagnosticsSessions(records) {
|
|
34867
|
+
return partitionSessionHostRecords(records || []);
|
|
34868
|
+
}
|
|
34869
|
+
var LIVE_LIFECYCLES2;
|
|
34870
|
+
var init_runtime_surface = __esm({
|
|
34871
|
+
"../../oss/packages/daemon-core/src/session-host/runtime-surface.ts"() {
|
|
34872
|
+
"use strict";
|
|
34873
|
+
LIVE_LIFECYCLES2 = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
|
|
34874
|
+
}
|
|
34875
|
+
});
|
|
34876
|
+
|
|
34579
34877
|
// ../../oss/packages/daemon-core/src/status/snapshot.ts
|
|
34878
|
+
function buildRecentReadDebugSignature(snapshot) {
|
|
34879
|
+
return [
|
|
34880
|
+
snapshot.providerType,
|
|
34881
|
+
snapshot.status,
|
|
34882
|
+
snapshot.inboxBucket,
|
|
34883
|
+
snapshot.unread ? "1" : "0",
|
|
34884
|
+
String(snapshot.lastSeenAt),
|
|
34885
|
+
snapshot.completionMarker,
|
|
34886
|
+
snapshot.seenCompletionMarker,
|
|
34887
|
+
String(snapshot.lastUpdated),
|
|
34888
|
+
String(snapshot.lastUsedAt),
|
|
34889
|
+
snapshot.lastRole,
|
|
34890
|
+
String(snapshot.messageUpdatedAt)
|
|
34891
|
+
].join("|");
|
|
34892
|
+
}
|
|
34893
|
+
function shouldEmitRecentReadDebugLog(cache, snapshot) {
|
|
34894
|
+
const nextSignature = buildRecentReadDebugSignature(snapshot);
|
|
34895
|
+
const previousSignature = cache.get(snapshot.sessionId);
|
|
34896
|
+
if (previousSignature === nextSignature) return false;
|
|
34897
|
+
cache.set(snapshot.sessionId, nextSignature);
|
|
34898
|
+
return true;
|
|
34899
|
+
}
|
|
34580
34900
|
function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
|
|
34581
34901
|
return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
|
|
34582
34902
|
id: ide.id,
|
|
@@ -34728,7 +35048,7 @@ function buildRecentLaunches(recentActivity) {
|
|
|
34728
35048
|
providerSessionId: item.providerSessionId,
|
|
34729
35049
|
title: item.title || item.providerName,
|
|
34730
35050
|
workspace: item.workspace,
|
|
34731
|
-
|
|
35051
|
+
summaryMetadata: item.summaryMetadata,
|
|
34732
35052
|
lastLaunchedAt: item.lastUsedAt
|
|
34733
35053
|
})).sort((a, b) => b.lastLaunchedAt - a.lastLaunchedAt).slice(0, 12);
|
|
34734
35054
|
}
|
|
@@ -34769,9 +35089,24 @@ function buildStatusSnapshot(options) {
|
|
|
34769
35089
|
session.unread = unread;
|
|
34770
35090
|
session.inboxBucket = inboxBucket;
|
|
34771
35091
|
if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
|
|
35092
|
+
const recentReadSnapshot = {
|
|
35093
|
+
sessionId: session.id,
|
|
35094
|
+
providerType: session.providerType,
|
|
35095
|
+
status: String(session.status || ""),
|
|
35096
|
+
inboxBucket,
|
|
35097
|
+
unread,
|
|
35098
|
+
lastSeenAt,
|
|
35099
|
+
completionMarker: completionMarker || "-",
|
|
35100
|
+
seenCompletionMarker: seenCompletionMarker || "-",
|
|
35101
|
+
lastUpdated: Number(session.lastUpdated || 0),
|
|
35102
|
+
lastUsedAt,
|
|
35103
|
+
lastRole: getLastMessageRole(sourceSession),
|
|
35104
|
+
messageUpdatedAt: getSessionMessageUpdatedAt(sourceSession)
|
|
35105
|
+
};
|
|
35106
|
+
if (!shouldEmitRecentReadDebugLog(recentReadDebugSignatureBySession, recentReadSnapshot)) continue;
|
|
34772
35107
|
LOG.info(
|
|
34773
35108
|
"RecentRead",
|
|
34774
|
-
`snapshot session id=${
|
|
35109
|
+
`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
35110
|
);
|
|
34776
35111
|
}
|
|
34777
35112
|
const lastDisplayMessage = getLastDisplayMessage(sourceSession);
|
|
@@ -34804,7 +35139,7 @@ function buildStatusSnapshot(options) {
|
|
|
34804
35139
|
}
|
|
34805
35140
|
};
|
|
34806
35141
|
}
|
|
34807
|
-
var os19, READ_DEBUG_ENABLED;
|
|
35142
|
+
var os19, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession;
|
|
34808
35143
|
var init_snapshot = __esm({
|
|
34809
35144
|
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
34810
35145
|
"use strict";
|
|
@@ -34818,6 +35153,7 @@ var init_snapshot = __esm({
|
|
|
34818
35153
|
init_logger();
|
|
34819
35154
|
init_builders();
|
|
34820
35155
|
READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
|
|
35156
|
+
recentReadDebugSignatureBySession = /* @__PURE__ */ new Map();
|
|
34821
35157
|
}
|
|
34822
35158
|
});
|
|
34823
35159
|
|
|
@@ -35059,6 +35395,49 @@ function toHostedCliRuntimeDescriptor(record2) {
|
|
|
35059
35395
|
providerSessionId: typeof record2.meta?.providerSessionId === "string" ? String(record2.meta.providerSessionId) : void 0
|
|
35060
35396
|
};
|
|
35061
35397
|
}
|
|
35398
|
+
function getWriteConflictOwnerClientId(error48) {
|
|
35399
|
+
const message = typeof error48 === "string" ? error48 : error48 instanceof Error ? error48.message : "";
|
|
35400
|
+
const match = /^Write owned by\s+(.+)$/.exec(message.trim());
|
|
35401
|
+
return match?.[1]?.trim() || void 0;
|
|
35402
|
+
}
|
|
35403
|
+
function summarizeSessionHostRecord(result) {
|
|
35404
|
+
if (!result || typeof result !== "object") return {};
|
|
35405
|
+
const record2 = result;
|
|
35406
|
+
return {
|
|
35407
|
+
runtimeKey: typeof record2.runtimeKey === "string" ? record2.runtimeKey : void 0,
|
|
35408
|
+
lifecycle: typeof record2.lifecycle === "string" ? record2.lifecycle : void 0,
|
|
35409
|
+
surfaceKind: getSessionHostSurfaceKind2(record2),
|
|
35410
|
+
attachedClientCount: Array.isArray(record2.attachedClients) ? record2.attachedClients.length : void 0,
|
|
35411
|
+
hasWriteOwner: !!record2.writeOwner,
|
|
35412
|
+
writeOwnerClientId: typeof record2.writeOwner?.clientId === "string" ? record2.writeOwner.clientId : void 0
|
|
35413
|
+
};
|
|
35414
|
+
}
|
|
35415
|
+
function summarizeSessionHostRecords(result) {
|
|
35416
|
+
const records = Array.isArray(result) ? result : [];
|
|
35417
|
+
const groups = partitionSessionHostRecords(records);
|
|
35418
|
+
return {
|
|
35419
|
+
sessionCount: records.length,
|
|
35420
|
+
liveRuntimeCount: groups.liveRuntimes.length,
|
|
35421
|
+
recoverySnapshotCount: groups.recoverySnapshots.length,
|
|
35422
|
+
inactiveRecordCount: groups.inactiveRecords.length
|
|
35423
|
+
};
|
|
35424
|
+
}
|
|
35425
|
+
function summarizeSessionHostDiagnostics(result) {
|
|
35426
|
+
const diagnostics = result && typeof result === "object" ? result : {};
|
|
35427
|
+
const sessions = Array.isArray(diagnostics.sessions) ? diagnostics.sessions : [];
|
|
35428
|
+
return {
|
|
35429
|
+
runtimeCount: typeof diagnostics.runtimeCount === "number" ? diagnostics.runtimeCount : void 0,
|
|
35430
|
+
...summarizeSessionHostRecords(sessions)
|
|
35431
|
+
};
|
|
35432
|
+
}
|
|
35433
|
+
function summarizeSessionHostPruneResult(result) {
|
|
35434
|
+
const value = result && typeof result === "object" ? result : {};
|
|
35435
|
+
return {
|
|
35436
|
+
duplicateGroupCount: typeof value.duplicateGroupCount === "number" ? value.duplicateGroupCount : void 0,
|
|
35437
|
+
prunedCount: Array.isArray(value.prunedSessionIds) ? value.prunedSessionIds.length : void 0,
|
|
35438
|
+
keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
|
|
35439
|
+
};
|
|
35440
|
+
}
|
|
35062
35441
|
var fs9, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
|
|
35063
35442
|
var init_router = __esm({
|
|
35064
35443
|
"../../oss/packages/daemon-core/src/commands/router.ts"() {
|
|
@@ -35078,6 +35457,7 @@ var init_router = __esm({
|
|
|
35078
35457
|
init_command_log();
|
|
35079
35458
|
init_logger();
|
|
35080
35459
|
init_debug_trace();
|
|
35460
|
+
init_runtime_surface();
|
|
35081
35461
|
init_builders();
|
|
35082
35462
|
init_snapshot();
|
|
35083
35463
|
init_snapshot();
|
|
@@ -35096,6 +35476,56 @@ var init_router = __esm({
|
|
|
35096
35476
|
constructor(deps) {
|
|
35097
35477
|
this.deps = deps;
|
|
35098
35478
|
}
|
|
35479
|
+
async traceSessionHostAction(action, args, run, summarizeResult) {
|
|
35480
|
+
const interactionId = typeof args?._interactionId === "string" ? args._interactionId : void 0;
|
|
35481
|
+
const sessionId = typeof args?.sessionId === "string" ? args.sessionId : void 0;
|
|
35482
|
+
const requestedPayload = { action };
|
|
35483
|
+
if (sessionId) requestedPayload.sessionId = sessionId;
|
|
35484
|
+
if (typeof args?.clientId === "string") requestedPayload.clientId = args.clientId;
|
|
35485
|
+
if (typeof args?.signal === "string") requestedPayload.signal = args.signal;
|
|
35486
|
+
if (typeof args?.providerType === "string") requestedPayload.providerType = args.providerType;
|
|
35487
|
+
if (typeof args?.workspace === "string") requestedPayload.workspace = args.workspace;
|
|
35488
|
+
if (typeof args?.dryRun === "boolean") requestedPayload.dryRun = args.dryRun;
|
|
35489
|
+
recordDebugTrace({
|
|
35490
|
+
interactionId,
|
|
35491
|
+
category: "session_host",
|
|
35492
|
+
stage: "action_requested",
|
|
35493
|
+
level: "info",
|
|
35494
|
+
sessionId,
|
|
35495
|
+
payload: requestedPayload
|
|
35496
|
+
});
|
|
35497
|
+
try {
|
|
35498
|
+
const result = await run();
|
|
35499
|
+
recordDebugTrace({
|
|
35500
|
+
interactionId,
|
|
35501
|
+
category: "session_host",
|
|
35502
|
+
stage: "action_result",
|
|
35503
|
+
level: "info",
|
|
35504
|
+
sessionId,
|
|
35505
|
+
payload: {
|
|
35506
|
+
...requestedPayload,
|
|
35507
|
+
success: true,
|
|
35508
|
+
...summarizeResult ? summarizeResult(result) : {}
|
|
35509
|
+
}
|
|
35510
|
+
});
|
|
35511
|
+
return result;
|
|
35512
|
+
} catch (error48) {
|
|
35513
|
+
recordDebugTrace({
|
|
35514
|
+
interactionId,
|
|
35515
|
+
category: "session_host",
|
|
35516
|
+
stage: "action_failed",
|
|
35517
|
+
level: "error",
|
|
35518
|
+
sessionId,
|
|
35519
|
+
payload: {
|
|
35520
|
+
...requestedPayload,
|
|
35521
|
+
error: error48?.message || String(error48),
|
|
35522
|
+
failureKind: getWriteConflictOwnerClientId(error48) ? "write_conflict" : "request_failed",
|
|
35523
|
+
conflictOwnerClientId: getWriteConflictOwnerClientId(error48)
|
|
35524
|
+
}
|
|
35525
|
+
});
|
|
35526
|
+
throw error48;
|
|
35527
|
+
}
|
|
35528
|
+
}
|
|
35099
35529
|
/**
|
|
35100
35530
|
* Unified command routing.
|
|
35101
35531
|
* Returns result for all commands:
|
|
@@ -35205,44 +35635,60 @@ var init_router = __esm({
|
|
|
35205
35635
|
}
|
|
35206
35636
|
case "session_host_get_diagnostics": {
|
|
35207
35637
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
35208
|
-
const diagnostics = await this.deps.sessionHostControl.getDiagnostics({
|
|
35638
|
+
const diagnostics = await this.traceSessionHostAction("session_host_get_diagnostics", args, () => this.deps.sessionHostControl.getDiagnostics({
|
|
35209
35639
|
includeSessions: args?.includeSessions !== false,
|
|
35210
35640
|
limit: Number(args?.limit) || void 0
|
|
35211
|
-
})
|
|
35641
|
+
}), (result) => ({
|
|
35642
|
+
includeSessions: args?.includeSessions !== false,
|
|
35643
|
+
limit: Number(args?.limit) || void 0,
|
|
35644
|
+
...summarizeSessionHostDiagnostics(result)
|
|
35645
|
+
}));
|
|
35212
35646
|
return { success: true, diagnostics };
|
|
35213
35647
|
}
|
|
35214
35648
|
case "session_host_list_sessions": {
|
|
35215
35649
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
35216
|
-
const sessions = await this.deps.sessionHostControl.listSessions();
|
|
35650
|
+
const sessions = await this.traceSessionHostAction("session_host_list_sessions", args, () => this.deps.sessionHostControl.listSessions(), (records) => summarizeSessionHostRecords(records));
|
|
35217
35651
|
return { success: true, sessions };
|
|
35218
35652
|
}
|
|
35219
35653
|
case "session_host_stop_session": {
|
|
35220
35654
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
35221
35655
|
const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
|
|
35222
35656
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
35223
|
-
const record2 = await this.deps.sessionHostControl.stopSession(sessionId);
|
|
35657
|
+
const record2 = await this.traceSessionHostAction("session_host_stop_session", args, () => this.deps.sessionHostControl.stopSession(sessionId), (result) => summarizeSessionHostRecord(result));
|
|
35224
35658
|
return { success: true, record: record2 };
|
|
35225
35659
|
}
|
|
35226
35660
|
case "session_host_resume_session": {
|
|
35227
35661
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
35228
35662
|
const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
|
|
35229
35663
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
35230
|
-
const record2 = await this.
|
|
35231
|
-
|
|
35232
|
-
|
|
35233
|
-
|
|
35234
|
-
|
|
35664
|
+
const record2 = await this.traceSessionHostAction("session_host_resume_session", args, async () => {
|
|
35665
|
+
const nextRecord = await this.deps.sessionHostControl.resumeSession(sessionId);
|
|
35666
|
+
const hosted = toHostedCliRuntimeDescriptor(nextRecord);
|
|
35667
|
+
if (hosted) {
|
|
35668
|
+
await this.deps.cliManager.restoreHostedSessions([hosted]);
|
|
35669
|
+
}
|
|
35670
|
+
return nextRecord;
|
|
35671
|
+
}, (result) => ({
|
|
35672
|
+
...summarizeSessionHostRecord(result),
|
|
35673
|
+
restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
|
|
35674
|
+
}));
|
|
35235
35675
|
return { success: true, record: record2 };
|
|
35236
35676
|
}
|
|
35237
35677
|
case "session_host_restart_session": {
|
|
35238
35678
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
35239
35679
|
const sessionId = typeof args?.sessionId === "string" ? args.sessionId : "";
|
|
35240
35680
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
35241
|
-
const record2 = await this.
|
|
35242
|
-
|
|
35243
|
-
|
|
35244
|
-
|
|
35245
|
-
|
|
35681
|
+
const record2 = await this.traceSessionHostAction("session_host_restart_session", args, async () => {
|
|
35682
|
+
const nextRecord = await this.deps.sessionHostControl.restartSession(sessionId);
|
|
35683
|
+
const hosted = toHostedCliRuntimeDescriptor(nextRecord);
|
|
35684
|
+
if (hosted) {
|
|
35685
|
+
await this.deps.cliManager.restoreHostedSessions([hosted]);
|
|
35686
|
+
}
|
|
35687
|
+
return nextRecord;
|
|
35688
|
+
}, (result) => ({
|
|
35689
|
+
...summarizeSessionHostRecord(result),
|
|
35690
|
+
restoredHostedSession: !!toHostedCliRuntimeDescriptor(result)
|
|
35691
|
+
}));
|
|
35246
35692
|
return { success: true, record: record2 };
|
|
35247
35693
|
}
|
|
35248
35694
|
case "session_host_send_signal": {
|
|
@@ -35251,7 +35697,7 @@ var init_router = __esm({
|
|
|
35251
35697
|
const signal = typeof args?.signal === "string" ? args.signal : "";
|
|
35252
35698
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
35253
35699
|
if (!signal) return { success: false, error: "signal required" };
|
|
35254
|
-
const record2 = await this.deps.sessionHostControl.sendSignal(sessionId, signal);
|
|
35700
|
+
const record2 = await this.traceSessionHostAction("session_host_send_signal", args, () => this.deps.sessionHostControl.sendSignal(sessionId, signal), (result) => summarizeSessionHostRecord(result));
|
|
35255
35701
|
return { success: true, record: record2 };
|
|
35256
35702
|
}
|
|
35257
35703
|
case "session_host_force_detach_client": {
|
|
@@ -35260,16 +35706,16 @@ var init_router = __esm({
|
|
|
35260
35706
|
const clientId = typeof args?.clientId === "string" ? args.clientId : "";
|
|
35261
35707
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
35262
35708
|
if (!clientId) return { success: false, error: "clientId required" };
|
|
35263
|
-
const record2 = await this.deps.sessionHostControl.forceDetachClient(sessionId, clientId);
|
|
35709
|
+
const record2 = await this.traceSessionHostAction("session_host_force_detach_client", args, () => this.deps.sessionHostControl.forceDetachClient(sessionId, clientId), (result) => summarizeSessionHostRecord(result));
|
|
35264
35710
|
return { success: true, record: record2 };
|
|
35265
35711
|
}
|
|
35266
35712
|
case "session_host_prune_duplicate_sessions": {
|
|
35267
35713
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
35268
|
-
const result = await this.deps.sessionHostControl.pruneDuplicateSessions({
|
|
35714
|
+
const result = await this.traceSessionHostAction("session_host_prune_duplicate_sessions", args, () => this.deps.sessionHostControl.pruneDuplicateSessions({
|
|
35269
35715
|
providerType: typeof args?.providerType === "string" ? args.providerType : void 0,
|
|
35270
35716
|
workspace: typeof args?.workspace === "string" ? args.workspace : void 0,
|
|
35271
35717
|
dryRun: args?.dryRun === true
|
|
35272
|
-
});
|
|
35718
|
+
}), (value) => summarizeSessionHostPruneResult(value));
|
|
35273
35719
|
return { success: true, result };
|
|
35274
35720
|
}
|
|
35275
35721
|
case "session_host_acquire_write": {
|
|
@@ -35279,12 +35725,15 @@ var init_router = __esm({
|
|
|
35279
35725
|
const ownerType = args?.ownerType === "agent" ? "agent" : "user";
|
|
35280
35726
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
35281
35727
|
if (!clientId) return { success: false, error: "clientId required" };
|
|
35282
|
-
const record2 = await this.deps.sessionHostControl.acquireWrite({
|
|
35728
|
+
const record2 = await this.traceSessionHostAction("session_host_acquire_write", args, () => this.deps.sessionHostControl.acquireWrite({
|
|
35283
35729
|
sessionId,
|
|
35284
35730
|
clientId,
|
|
35285
35731
|
ownerType,
|
|
35286
35732
|
force: args?.force !== false
|
|
35287
|
-
})
|
|
35733
|
+
}), (result) => ({
|
|
35734
|
+
...summarizeSessionHostRecord(result),
|
|
35735
|
+
ownerType
|
|
35736
|
+
}));
|
|
35288
35737
|
return { success: true, record: record2 };
|
|
35289
35738
|
}
|
|
35290
35739
|
case "session_host_release_write": {
|
|
@@ -35293,7 +35742,10 @@ var init_router = __esm({
|
|
|
35293
35742
|
const clientId = typeof args?.clientId === "string" ? args.clientId : "";
|
|
35294
35743
|
if (!sessionId) return { success: false, error: "sessionId required" };
|
|
35295
35744
|
if (!clientId) return { success: false, error: "clientId required" };
|
|
35296
|
-
const record2 = await this.deps.sessionHostControl.releaseWrite({
|
|
35745
|
+
const record2 = await this.traceSessionHostAction("session_host_release_write", args, () => this.deps.sessionHostControl.releaseWrite({
|
|
35746
|
+
sessionId,
|
|
35747
|
+
clientId
|
|
35748
|
+
}), (result) => summarizeSessionHostRecord(result));
|
|
35297
35749
|
return { success: true, record: record2 };
|
|
35298
35750
|
}
|
|
35299
35751
|
case "list_saved_sessions": {
|
|
@@ -35326,7 +35778,7 @@ var init_router = __esm({
|
|
|
35326
35778
|
kind: saved?.kind || recent?.kind || kind,
|
|
35327
35779
|
title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
|
|
35328
35780
|
workspace: saved?.workspace || recent?.workspace || session.workspace,
|
|
35329
|
-
|
|
35781
|
+
summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
|
|
35330
35782
|
preview: session.preview,
|
|
35331
35783
|
messageCount: session.messageCount,
|
|
35332
35784
|
firstMessageAt: session.firstMessageAt,
|
|
@@ -35773,7 +36225,7 @@ var init_reporter = __esm({
|
|
|
35773
36225
|
const ideSummary = ideStates.map((s) => {
|
|
35774
36226
|
const msgs = s.activeChat?.messages?.length || 0;
|
|
35775
36227
|
const exts = s.extensions.length;
|
|
35776
|
-
return `${s.type}(${s.status},${msgs}msg,${exts}ext
|
|
36228
|
+
return `${s.type}(${s.status},${msgs}msg,${exts}ext)`;
|
|
35777
36229
|
}).join(", ");
|
|
35778
36230
|
const cliSummary = cliStates.map((s) => `${s.type}(${s.status})`).join(", ");
|
|
35779
36231
|
const acpSummary = acpStates.map((s) => `${s.type}(${s.status})`).join(", ");
|
|
@@ -35835,9 +36287,7 @@ var init_reporter = __esm({
|
|
|
35835
36287
|
workspace: session.workspace ?? null,
|
|
35836
36288
|
title: session.title,
|
|
35837
36289
|
cdpConnected: session.cdpConnected,
|
|
35838
|
-
|
|
35839
|
-
currentPlan: session.currentPlan,
|
|
35840
|
-
currentAutoApprove: session.currentAutoApprove
|
|
36290
|
+
summaryMetadata: session.summaryMetadata
|
|
35841
36291
|
})),
|
|
35842
36292
|
p2p: payload.p2p,
|
|
35843
36293
|
timestamp: now
|
|
@@ -35902,6 +36352,7 @@ var init_provider_adapter = __esm({
|
|
|
35902
36352
|
"../../oss/packages/daemon-core/src/agent-stream/provider-adapter.ts"() {
|
|
35903
36353
|
"use strict";
|
|
35904
36354
|
init_control_effects();
|
|
36355
|
+
init_provider_patch_state();
|
|
35905
36356
|
ProviderStreamAdapter = class {
|
|
35906
36357
|
agentType;
|
|
35907
36358
|
agentName;
|
|
@@ -36013,15 +36464,18 @@ var init_provider_adapter = __esm({
|
|
|
36013
36464
|
status: data.status || "idle",
|
|
36014
36465
|
messages: data.messages || [],
|
|
36015
36466
|
inputContent: data.inputContent || "",
|
|
36016
|
-
model: data.model,
|
|
36017
|
-
mode: data.mode,
|
|
36018
36467
|
activeModal: data.activeModal
|
|
36019
36468
|
};
|
|
36020
36469
|
if (typeof data.title === "string" && data.title.trim()) {
|
|
36021
36470
|
state.title = data.title.trim();
|
|
36022
36471
|
}
|
|
36023
36472
|
const controlValues = extractProviderControlValues(this.provider.controls, data);
|
|
36024
|
-
|
|
36473
|
+
const surface = resolveProviderStateSurface({
|
|
36474
|
+
controlValues,
|
|
36475
|
+
summaryMetadata: data.summaryMetadata
|
|
36476
|
+
});
|
|
36477
|
+
if (surface.controlValues) state.controlValues = surface.controlValues;
|
|
36478
|
+
if (surface.summaryMetadata) state.summaryMetadata = surface.summaryMetadata;
|
|
36025
36479
|
const effects = normalizeProviderEffects(data);
|
|
36026
36480
|
if (effects.length > 0) state.effects = effects;
|
|
36027
36481
|
if (state.messages.length > 0) {
|
|
@@ -36302,7 +36756,8 @@ var init_manager2 = __esm({
|
|
|
36302
36756
|
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.cdpSessionId, expr, timeout);
|
|
36303
36757
|
const state = await agent.adapter.readChat(evaluate);
|
|
36304
36758
|
const stateError = this.getStateError(state);
|
|
36305
|
-
|
|
36759
|
+
const selectedModelValue = typeof state.controlValues?.model === "string" ? state.controlValues.model : "";
|
|
36760
|
+
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
36761
|
if (state.status === "error" && this.isRecoverableSessionError(stateError)) {
|
|
36307
36762
|
throw new Error(stateError);
|
|
36308
36763
|
}
|
|
@@ -36679,9 +37134,8 @@ function forwardAgentStreamsToIdeInstance(instanceManager, ideType, streams) {
|
|
|
36679
37134
|
messages: stream.messages || [],
|
|
36680
37135
|
status: stream.status || "idle",
|
|
36681
37136
|
activeModal: stream.activeModal || null,
|
|
36682
|
-
model: stream.model || void 0,
|
|
36683
|
-
mode: stream.mode || void 0,
|
|
36684
37137
|
controlValues: stream.controlValues || void 0,
|
|
37138
|
+
summaryMetadata: stream.summaryMetadata || void 0,
|
|
36685
37139
|
effects: stream.effects || void 0,
|
|
36686
37140
|
sessionId: stream.sessionId || stream.instanceId || void 0,
|
|
36687
37141
|
title: stream.title || stream.agentName || void 0,
|
|
@@ -37228,7 +37682,11 @@ module.exports.setMode = (params) => {
|
|
|
37228
37682
|
* 5. Approval dialog detection (buttons, modal)
|
|
37229
37683
|
* 6. Input field selector
|
|
37230
37684
|
*
|
|
37231
|
-
*
|
|
37685
|
+
* Preferred live-state surface:
|
|
37686
|
+
* - controlValues: explicit current control selections (model/mode/etc.)
|
|
37687
|
+
* - summaryMetadata: compact always-visible metadata for dashboard/recent views
|
|
37688
|
+
* Legacy top-level model/mode output is no longer the preferred shape.
|
|
37689
|
+
* \u2192 { id, status, title, messages[], inputContent, activeModal, controlValues?, summaryMetadata? }
|
|
37232
37690
|
*/
|
|
37233
37691
|
(() => {
|
|
37234
37692
|
try {
|
|
@@ -37256,6 +37714,9 @@ module.exports.setMode = (params) => {
|
|
|
37256
37714
|
messages,
|
|
37257
37715
|
inputContent,
|
|
37258
37716
|
activeModal,
|
|
37717
|
+
// TODO: Return explicit selections when available, e.g.
|
|
37718
|
+
// controlValues: { model: selectedModel, mode: selectedMode },
|
|
37719
|
+
// summaryMetadata: { items: [{ id: 'model', value: selectedModelLabel || selectedModel, shortValue: selectedModel, order: 10 }] },
|
|
37259
37720
|
});
|
|
37260
37721
|
} catch(e) {
|
|
37261
37722
|
return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
|
|
@@ -39002,7 +39463,6 @@ async function handleCliStatus(ctx, _req, res) {
|
|
|
39002
39463
|
lastMessage: s.activeChat?.messages?.slice(-1)[0] || null,
|
|
39003
39464
|
activeModal: s.activeChat?.activeModal || null,
|
|
39004
39465
|
pendingEvents: s.pendingEvents || [],
|
|
39005
|
-
currentModel: s.currentModel,
|
|
39006
39466
|
settings: s.settings
|
|
39007
39467
|
}));
|
|
39008
39468
|
ctx.json(res, 200, { instances: result, count: result.length });
|
|
@@ -40164,7 +40624,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40164
40624
|
lines.push("## Required Return Format");
|
|
40165
40625
|
lines.push("| Function | Return JSON |");
|
|
40166
40626
|
lines.push("|---|---|");
|
|
40167
|
-
lines.push("| readChat | `{ id, status, title, messages: [{role, content, index, kind?, meta?}], inputContent, activeModal }` \u2014 optional `kind`: standard, thought, tool, terminal;
|
|
40627
|
+
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
40628
|
lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
|
|
40169
40629
|
lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
|
|
40170
40630
|
lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
|
|
@@ -41827,7 +42287,7 @@ var init_dev_server = __esm({
|
|
|
41827
42287
|
lines.push("## Required Return Format");
|
|
41828
42288
|
lines.push("| Function | Return JSON |");
|
|
41829
42289
|
lines.push("|---|---|");
|
|
41830
|
-
lines.push("| readChat | `{ id, status, title, messages: [{role, content, index, kind?, meta?}], inputContent, activeModal }` \u2014 optional `kind`: standard, thought, tool, terminal;
|
|
42290
|
+
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
42291
|
lines.push("| sendMessage | `{ sent: false, needsTypeAndSend: true, selector }` |");
|
|
41832
42292
|
lines.push("| resolveAction | `{ resolved: true/false, clicked? }` |");
|
|
41833
42293
|
lines.push("| listSessions | `{ sessions: [{ id, title, active, index }] }` |");
|
|
@@ -42749,67 +43209,6 @@ var init_runtime_support = __esm({
|
|
|
42749
43209
|
}
|
|
42750
43210
|
});
|
|
42751
43211
|
|
|
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
43212
|
// ../../oss/packages/daemon-core/src/session-host/startup-restore-policy.js
|
|
42814
43213
|
function shouldAutoRestoreHostedSessionsOnStartup(env3 = process.env) {
|
|
42815
43214
|
const raw = typeof env3.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP === "string" ? env3.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP.trim().toLowerCase() : "";
|
|
@@ -83547,7 +83946,7 @@ var init_adhdev_daemon = __esm({
|
|
|
83547
83946
|
import_ws3 = require("ws");
|
|
83548
83947
|
init_source();
|
|
83549
83948
|
init_version();
|
|
83550
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.
|
|
83949
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.59" });
|
|
83551
83950
|
ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
|
|
83552
83951
|
"generating",
|
|
83553
83952
|
"waiting_approval",
|
|
@@ -85034,6 +85433,41 @@ ${source_default.cyan("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2
|
|
|
85034
85433
|
}
|
|
85035
85434
|
});
|
|
85036
85435
|
|
|
85436
|
+
// src/cli/runtime-target-trace.ts
|
|
85437
|
+
var runtime_target_trace_exports = {};
|
|
85438
|
+
__export(runtime_target_trace_exports, {
|
|
85439
|
+
buildRuntimeTargetResolutionTrace: () => buildRuntimeTargetResolutionTrace
|
|
85440
|
+
});
|
|
85441
|
+
async function buildRuntimeTargetResolutionTrace(records, target, options) {
|
|
85442
|
+
const attachable = options?.attachable === true;
|
|
85443
|
+
try {
|
|
85444
|
+
const record2 = attachable ? resolveAttachableRuntimeRecord(records, target) : resolveRuntimeRecord(records, target);
|
|
85445
|
+
return {
|
|
85446
|
+
target,
|
|
85447
|
+
attachable,
|
|
85448
|
+
sessionId: record2.sessionId,
|
|
85449
|
+
runtimeKey: record2.runtimeKey,
|
|
85450
|
+
displayName: record2.displayName,
|
|
85451
|
+
lifecycle: record2.lifecycle,
|
|
85452
|
+
surfaceKind: getSessionHostSurfaceKind(record2),
|
|
85453
|
+
attachedClientCount: Array.isArray(record2.attachedClients) ? record2.attachedClients.length : 0,
|
|
85454
|
+
writeOwnerClientId: record2.writeOwner?.clientId
|
|
85455
|
+
};
|
|
85456
|
+
} catch (error48) {
|
|
85457
|
+
return {
|
|
85458
|
+
target,
|
|
85459
|
+
attachable,
|
|
85460
|
+
error: error48?.message || String(error48)
|
|
85461
|
+
};
|
|
85462
|
+
}
|
|
85463
|
+
}
|
|
85464
|
+
var init_runtime_target_trace = __esm({
|
|
85465
|
+
"src/cli/runtime-target-trace.ts"() {
|
|
85466
|
+
"use strict";
|
|
85467
|
+
init_dist();
|
|
85468
|
+
}
|
|
85469
|
+
});
|
|
85470
|
+
|
|
85037
85471
|
// ../../oss/packages/web-core/src/constants/supported.ts
|
|
85038
85472
|
var supported_exports = {};
|
|
85039
85473
|
__export(supported_exports, {
|
|
@@ -86045,12 +86479,24 @@ function formatSavedHistoryTimestamp(timestamp) {
|
|
|
86045
86479
|
function getSavedHistoryStatusLabel(session) {
|
|
86046
86480
|
return session.canResume ? "resume-ready" : "needs --dir";
|
|
86047
86481
|
}
|
|
86482
|
+
function getSavedHistorySummaryValues(summaryMetadata) {
|
|
86483
|
+
if (!summaryMetadata || !Array.isArray(summaryMetadata.items)) return [];
|
|
86484
|
+
return summaryMetadata.items.map((item) => String(item?.value || item?.shortValue || "").trim()).filter(Boolean);
|
|
86485
|
+
}
|
|
86486
|
+
function getSavedHistorySummaryValue(session, id, options = {}) {
|
|
86487
|
+
const targetId = String(id || "").trim();
|
|
86488
|
+
if (!targetId || !session.summaryMetadata || !Array.isArray(session.summaryMetadata.items)) return "";
|
|
86489
|
+
const item = session.summaryMetadata.items.find((entry) => String(entry?.id || "").trim() === targetId);
|
|
86490
|
+
if (!item) return "";
|
|
86491
|
+
return String(options.preferShortValue ? item.shortValue || item.value || "" : item.value || item.shortValue || "").trim();
|
|
86492
|
+
}
|
|
86048
86493
|
function buildSavedHistorySessionLines(session) {
|
|
86049
86494
|
const title = session.title || session.providerSessionId;
|
|
86050
86495
|
const locationParts = [session.providerSessionId];
|
|
86051
86496
|
if (session.workspace) locationParts.push(session.workspace);
|
|
86052
86497
|
const summaryParts = [`${session.messageCount || 0} msgs`];
|
|
86053
|
-
|
|
86498
|
+
const summaryValues = getSavedHistorySummaryValues(session.summaryMetadata);
|
|
86499
|
+
if (summaryValues.length > 0) summaryParts.push(...summaryValues);
|
|
86054
86500
|
const updated = formatSavedHistoryTimestamp(session.lastMessageAt);
|
|
86055
86501
|
if (updated !== "-") summaryParts.push(`updated ${updated}`);
|
|
86056
86502
|
summaryParts.push(getSavedHistoryStatusLabel(session));
|
|
@@ -86080,7 +86526,7 @@ function filterSavedHistorySessions(sessions, options = {}) {
|
|
|
86080
86526
|
if (!workspace.includes(workspaceQuery)) return false;
|
|
86081
86527
|
}
|
|
86082
86528
|
if (modelQuery) {
|
|
86083
|
-
const model =
|
|
86529
|
+
const model = getSavedHistorySummaryValues(session.summaryMetadata).map((value) => value.toLowerCase()).join("\n");
|
|
86084
86530
|
if (!model.includes(modelQuery)) return false;
|
|
86085
86531
|
}
|
|
86086
86532
|
return true;
|
|
@@ -86141,8 +86587,9 @@ function buildHistoryResumeLaunchPayload(cliType, session, overrideDir) {
|
|
|
86141
86587
|
dir,
|
|
86142
86588
|
resumeSessionId: session.providerSessionId
|
|
86143
86589
|
};
|
|
86144
|
-
|
|
86145
|
-
|
|
86590
|
+
const initialModel = getSavedHistorySummaryValue(session, "model", { preferShortValue: true });
|
|
86591
|
+
if (initialModel) {
|
|
86592
|
+
payload.initialModel = initialModel;
|
|
86146
86593
|
}
|
|
86147
86594
|
return payload;
|
|
86148
86595
|
}
|
|
@@ -86859,6 +87306,74 @@ function buildRuntimeOpenLaunchSpec(options) {
|
|
|
86859
87306
|
return spec;
|
|
86860
87307
|
}
|
|
86861
87308
|
|
|
87309
|
+
// src/cli/debug-trace-cli.ts
|
|
87310
|
+
function normalizeOptionalFilter(value) {
|
|
87311
|
+
if (typeof value !== "string") return void 0;
|
|
87312
|
+
const trimmed = value.trim();
|
|
87313
|
+
return trimmed ? trimmed : void 0;
|
|
87314
|
+
}
|
|
87315
|
+
function buildDebugTraceCommandArgs(options) {
|
|
87316
|
+
const category = normalizeOptionalFilter(options.category);
|
|
87317
|
+
const interactionId = normalizeOptionalFilter(options.interactionId);
|
|
87318
|
+
return {
|
|
87319
|
+
count: Math.max(1, Math.floor(options.count || 0) || 40),
|
|
87320
|
+
...category && category !== "all" ? { category } : {},
|
|
87321
|
+
...interactionId ? { interactionId } : {}
|
|
87322
|
+
};
|
|
87323
|
+
}
|
|
87324
|
+
function buildDebugTraceFollowPollArgs(options, cursor) {
|
|
87325
|
+
const base = buildDebugTraceCommandArgs(options);
|
|
87326
|
+
if (!cursor || cursor.lastTs <= 0) {
|
|
87327
|
+
return base;
|
|
87328
|
+
}
|
|
87329
|
+
return {
|
|
87330
|
+
...base,
|
|
87331
|
+
since: Math.max(0, cursor.lastTs - 1)
|
|
87332
|
+
};
|
|
87333
|
+
}
|
|
87334
|
+
function collectFreshDebugTraceEntries(entries, cursor) {
|
|
87335
|
+
const previousTs = cursor?.lastTs ?? 0;
|
|
87336
|
+
const seenIdsAtLastTs = new Set(cursor?.seenIdsAtLastTs ?? []);
|
|
87337
|
+
const fresh = entries.filter((entry) => {
|
|
87338
|
+
const ts2 = Number(entry.ts || 0);
|
|
87339
|
+
if (ts2 > previousTs) return true;
|
|
87340
|
+
if (ts2 < previousTs) return false;
|
|
87341
|
+
return !seenIdsAtLastTs.has(entry.id);
|
|
87342
|
+
});
|
|
87343
|
+
if (entries.length === 0) {
|
|
87344
|
+
return {
|
|
87345
|
+
entries: fresh,
|
|
87346
|
+
cursor: cursor ?? { lastTs: 0, seenIdsAtLastTs: [] }
|
|
87347
|
+
};
|
|
87348
|
+
}
|
|
87349
|
+
const nextLastTs = entries.reduce((max, entry) => Math.max(max, Number(entry.ts || 0)), previousTs);
|
|
87350
|
+
const nextSeenIdsAtLastTs = Array.from(new Set(
|
|
87351
|
+
entries.filter((entry) => Number(entry.ts || 0) === nextLastTs).map((entry) => entry.id)
|
|
87352
|
+
));
|
|
87353
|
+
return {
|
|
87354
|
+
entries: fresh,
|
|
87355
|
+
cursor: {
|
|
87356
|
+
lastTs: nextLastTs,
|
|
87357
|
+
seenIdsAtLastTs: nextSeenIdsAtLastTs
|
|
87358
|
+
}
|
|
87359
|
+
};
|
|
87360
|
+
}
|
|
87361
|
+
function formatPayload(payload) {
|
|
87362
|
+
if (!payload || Object.keys(payload).length === 0) return "";
|
|
87363
|
+
try {
|
|
87364
|
+
const raw = JSON.stringify(payload);
|
|
87365
|
+
return raw.length > 220 ? `${raw.slice(0, 220)}\u2026` : raw;
|
|
87366
|
+
} catch {
|
|
87367
|
+
return "[unserializable payload]";
|
|
87368
|
+
}
|
|
87369
|
+
}
|
|
87370
|
+
function formatDebugTraceEntryLine(entry) {
|
|
87371
|
+
const timestamp = new Date(entry.ts).toLocaleTimeString();
|
|
87372
|
+
const interactionLabel = entry.interactionId ? ` ix=${entry.interactionId}` : "";
|
|
87373
|
+
const payload = formatPayload(entry.payload);
|
|
87374
|
+
return `${timestamp} ${entry.level.toUpperCase()} ${entry.category}.${entry.stage}${interactionLabel}${payload ? ` ${payload}` : ""}`;
|
|
87375
|
+
}
|
|
87376
|
+
|
|
86862
87377
|
// src/cli/daemon-commands.ts
|
|
86863
87378
|
function hideCommand(command) {
|
|
86864
87379
|
if (typeof command.hideHelp === "function") {
|
|
@@ -86914,6 +87429,12 @@ async function resolveRuntimeSessionId(target, options) {
|
|
|
86914
87429
|
if (!envelope?.success || !Array.isArray(envelope?.result)) {
|
|
86915
87430
|
throw new Error(envelope?.error || "Failed to list runtimes");
|
|
86916
87431
|
}
|
|
87432
|
+
if (process.env.ADHDEV_SESSION_HOST_TRACE === "1") {
|
|
87433
|
+
const { buildRuntimeTargetResolutionTrace: buildRuntimeTargetResolutionTrace2 } = await Promise.resolve().then(() => (init_runtime_target_trace(), runtime_target_trace_exports));
|
|
87434
|
+
const trace = await buildRuntimeTargetResolutionTrace2(envelope.result, target, { attachable: options?.attachable === true });
|
|
87435
|
+
process.stderr.write(`[session-host-trace] runtime_target_resolution ${JSON.stringify(trace)}
|
|
87436
|
+
`);
|
|
87437
|
+
}
|
|
86917
87438
|
if (options?.attachable === true) {
|
|
86918
87439
|
const { resolveAttachableRuntimeRecord: resolveAttachableRuntimeRecord2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
86919
87440
|
return resolveAttachableRuntimeRecord2(envelope.result, target).sessionId;
|
|
@@ -87054,6 +87575,112 @@ async function printRuntimeGroups(records, options) {
|
|
|
87054
87575
|
console.log();
|
|
87055
87576
|
}
|
|
87056
87577
|
}
|
|
87578
|
+
async function handleTraceCommand(options) {
|
|
87579
|
+
const port = parseInt(String(options.port ?? "19222"), 10) || 19222;
|
|
87580
|
+
const count = Math.max(1, Math.min(500, parseInt(String(options.count ?? "40"), 10) || 40));
|
|
87581
|
+
const intervalMs = Math.max(250, Math.min(3e4, parseInt(String(options.interval ?? "1500"), 10) || 1500));
|
|
87582
|
+
const baseArgs = {
|
|
87583
|
+
count,
|
|
87584
|
+
category: options.category,
|
|
87585
|
+
interactionId: options.interaction
|
|
87586
|
+
};
|
|
87587
|
+
const fetchTrace = async (args) => {
|
|
87588
|
+
const traceResult = await sendDaemonCommandSafe("get_debug_trace", args, port);
|
|
87589
|
+
const payload = traceResult?.result || traceResult;
|
|
87590
|
+
if (!payload?.success) {
|
|
87591
|
+
throw new Error(payload?.error || "debug trace query failed");
|
|
87592
|
+
}
|
|
87593
|
+
return Array.isArray(payload?.trace) ? payload.trace : [];
|
|
87594
|
+
};
|
|
87595
|
+
if (!options.follow) {
|
|
87596
|
+
const args = buildDebugTraceCommandArgs(baseArgs);
|
|
87597
|
+
const trace = await fetchTrace(args);
|
|
87598
|
+
if (options.json) {
|
|
87599
|
+
console.log(JSON.stringify({
|
|
87600
|
+
port,
|
|
87601
|
+
count: trace.length,
|
|
87602
|
+
query: args,
|
|
87603
|
+
trace
|
|
87604
|
+
}, null, 2));
|
|
87605
|
+
return;
|
|
87606
|
+
}
|
|
87607
|
+
console.log(source_default.bold("\n Structured Daemon Trace\n"));
|
|
87608
|
+
console.log(source_default.gray(` Port: ${port}`));
|
|
87609
|
+
console.log(source_default.gray(` Category: ${args.category || "all"}`));
|
|
87610
|
+
console.log(source_default.gray(` Interaction: ${args.interactionId || "-"}`));
|
|
87611
|
+
console.log(source_default.gray(` Entries: ${trace.length}`));
|
|
87612
|
+
console.log();
|
|
87613
|
+
if (trace.length === 0) {
|
|
87614
|
+
console.log(source_default.gray(" No trace entries found. Start the daemon with `adhdev daemon --dev` or `adhdev daemon --trace`."));
|
|
87615
|
+
console.log();
|
|
87616
|
+
return;
|
|
87617
|
+
}
|
|
87618
|
+
for (const entry of trace) {
|
|
87619
|
+
console.log(source_default.gray(` ${formatDebugTraceEntryLine(entry)}`));
|
|
87620
|
+
}
|
|
87621
|
+
console.log();
|
|
87622
|
+
return;
|
|
87623
|
+
}
|
|
87624
|
+
let stopped = false;
|
|
87625
|
+
const stopFollowing = () => {
|
|
87626
|
+
stopped = true;
|
|
87627
|
+
};
|
|
87628
|
+
process.once("SIGINT", stopFollowing);
|
|
87629
|
+
process.once("SIGTERM", stopFollowing);
|
|
87630
|
+
try {
|
|
87631
|
+
let cursor = void 0;
|
|
87632
|
+
const initialTrace = await fetchTrace(buildDebugTraceFollowPollArgs(baseArgs));
|
|
87633
|
+
const initialBatch = collectFreshDebugTraceEntries(initialTrace, cursor);
|
|
87634
|
+
cursor = initialBatch.cursor;
|
|
87635
|
+
if (options.json) {
|
|
87636
|
+
for (const entry of initialBatch.entries) {
|
|
87637
|
+
console.log(JSON.stringify(entry));
|
|
87638
|
+
}
|
|
87639
|
+
} else {
|
|
87640
|
+
console.log(source_default.bold("\n Structured Daemon Trace\n"));
|
|
87641
|
+
console.log(source_default.gray(` Port: ${port}`));
|
|
87642
|
+
console.log(source_default.gray(` Category: ${buildDebugTraceCommandArgs(baseArgs).category || "all"}`));
|
|
87643
|
+
console.log(source_default.gray(` Interaction: ${buildDebugTraceCommandArgs(baseArgs).interactionId || "-"}`));
|
|
87644
|
+
console.log(source_default.gray(` Initial: ${initialBatch.entries.length}`));
|
|
87645
|
+
console.log(source_default.gray(` Follow: every ${intervalMs}ms (Ctrl+C to stop)`));
|
|
87646
|
+
console.log();
|
|
87647
|
+
if (initialBatch.entries.length === 0) {
|
|
87648
|
+
console.log(source_default.gray(" No trace entries yet. Waiting for new entries..."));
|
|
87649
|
+
console.log();
|
|
87650
|
+
} else {
|
|
87651
|
+
for (const entry of initialBatch.entries) {
|
|
87652
|
+
console.log(source_default.gray(` ${formatDebugTraceEntryLine(entry)}`));
|
|
87653
|
+
}
|
|
87654
|
+
console.log();
|
|
87655
|
+
}
|
|
87656
|
+
}
|
|
87657
|
+
while (!stopped) {
|
|
87658
|
+
await new Promise((resolve17) => setTimeout(resolve17, intervalMs));
|
|
87659
|
+
if (stopped) break;
|
|
87660
|
+
const nextTrace = await fetchTrace(buildDebugTraceFollowPollArgs(baseArgs, cursor));
|
|
87661
|
+
const nextBatch = collectFreshDebugTraceEntries(nextTrace, cursor);
|
|
87662
|
+
cursor = nextBatch.cursor;
|
|
87663
|
+
if (nextBatch.entries.length === 0) continue;
|
|
87664
|
+
if (options.json) {
|
|
87665
|
+
for (const entry of nextBatch.entries) {
|
|
87666
|
+
console.log(JSON.stringify(entry));
|
|
87667
|
+
}
|
|
87668
|
+
continue;
|
|
87669
|
+
}
|
|
87670
|
+
for (const entry of nextBatch.entries) {
|
|
87671
|
+
console.log(source_default.gray(` ${formatDebugTraceEntryLine(entry)}`));
|
|
87672
|
+
}
|
|
87673
|
+
}
|
|
87674
|
+
} finally {
|
|
87675
|
+
process.off("SIGINT", stopFollowing);
|
|
87676
|
+
process.off("SIGTERM", stopFollowing);
|
|
87677
|
+
}
|
|
87678
|
+
if (!options.json) {
|
|
87679
|
+
console.log();
|
|
87680
|
+
console.log(source_default.gray(" Trace follow stopped."));
|
|
87681
|
+
console.log();
|
|
87682
|
+
}
|
|
87683
|
+
}
|
|
87057
87684
|
function registerDaemonCommands(program2, pkgVersion3) {
|
|
87058
87685
|
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
87686
|
const { AdhdevDaemon: AdhdevDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
@@ -87069,6 +87696,16 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
87069
87696
|
traceBufferSize: options.traceBufferSize ? parseInt(options.traceBufferSize, 10) || void 0 : void 0
|
|
87070
87697
|
});
|
|
87071
87698
|
});
|
|
87699
|
+
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) => {
|
|
87700
|
+
try {
|
|
87701
|
+
await handleTraceCommand(options);
|
|
87702
|
+
} catch (error48) {
|
|
87703
|
+
console.error(source_default.red(`
|
|
87704
|
+
\u2717 ${error48?.message || String(error48)}
|
|
87705
|
+
`));
|
|
87706
|
+
process.exit(1);
|
|
87707
|
+
}
|
|
87708
|
+
});
|
|
87072
87709
|
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
87710
|
const { spawn: spawn6, execSync: execSync8 } = await import("child_process");
|
|
87074
87711
|
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 +90421,7 @@ void (async () => {
|
|
|
89784
90421
|
console.log(source_default.gray(" adhdev update \u2014 Upgrade to latest version"));
|
|
89785
90422
|
console.log();
|
|
89786
90423
|
console.log(source_default.gray(" Advanced tools:"));
|
|
90424
|
+
console.log(source_default.gray(" adhdev trace --category session_host \u2014 Inspect structured daemon trace"));
|
|
89787
90425
|
console.log(source_default.gray(" adhdev service \u2014 Manage OS background auto-start service"));
|
|
89788
90426
|
console.log(source_default.gray(" adhdev provider ... \u2014 Provider development commands"));
|
|
89789
90427
|
console.log(source_default.gray(" adhdev cdp ... \u2014 CDP debugging tools"));
|