@dsmm/dsmm 0.1.7 → 0.1.8
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/README.md +12 -9
- package/docs/compatibility.md +10 -6
- package/docs/profiles.md +6 -4
- package/docs/releasing.md +26 -20
- package/docs/settings-status.md +4 -4
- package/lib/client/SessionProfiles.js +23 -16
- package/lib/client/controller.d.ts +9 -3
- package/lib/client/controller.js +69 -6
- package/lib/client/locales.d.ts +10 -0
- package/lib/client/locales.js +4 -0
- package/lib/client.js +124 -25
- package/lib/index.js +1 -1
- package/lib/profile-remote.d.ts +3 -1
- package/lib/profile-remote.js +16 -1
- package/lib/profile-rpc.d.ts +3 -1
- package/lib/profile-rpc.js +13 -0
- package/lib/profile-runtime.d.ts +6 -2
- package/lib/profile-runtime.js +64 -6
- package/lib/profile-types.d.ts +15 -0
- package/lib/state.d.ts +5 -1
- package/lib/state.js +33 -8
- package/package.json +1 -1
package/lib/client/controller.js
CHANGED
|
@@ -7,6 +7,13 @@ function modelSelectionWatermark(window) {
|
|
|
7
7
|
watermark = Math.max(watermark, Number(entry.event.seq));
|
|
8
8
|
return watermark;
|
|
9
9
|
}
|
|
10
|
+
function modeIntentWatermark(window) {
|
|
11
|
+
let watermark = -1;
|
|
12
|
+
for (const entry of window.entries)
|
|
13
|
+
if (entry.type === "event" && (entry.event.type === "deepwork/mode" || entry.event.type === "agent-preset/selected"))
|
|
14
|
+
watermark = Math.max(watermark, Number(entry.event.seq));
|
|
15
|
+
return watermark;
|
|
16
|
+
}
|
|
10
17
|
const NEW_EDITOR = "";
|
|
11
18
|
export const NEW_PROFILE_CONTENT = '{\n "version": 1,\n "id": "new-profile",\n "label": "New profile",\n "settings": {\n // Runtime overlay only. Omitted fields inherit the deployment baseline.\n "defaultActive": true\n }\n}\n';
|
|
12
19
|
/** A valid external CAS conflict is reconcilable; corruption is never reset implicitly. */
|
|
@@ -36,6 +43,8 @@ export class ProfilesController {
|
|
|
36
43
|
modelEventsSessionId = null;
|
|
37
44
|
modelEventsGeneration = 0;
|
|
38
45
|
modelEventsWatermark = -1;
|
|
46
|
+
modeEventsWatermark = -1;
|
|
47
|
+
modeRefreshPending = false;
|
|
39
48
|
stopModelEvents = null;
|
|
40
49
|
modelInteraction = null;
|
|
41
50
|
modelInteractionSessionId = null;
|
|
@@ -59,6 +68,7 @@ export class ProfilesController {
|
|
|
59
68
|
chooseSessionProfile: (id) => { if (!this.disposed && this.current.sessionBusy === null && this.current.busy === null && !this.current.dirty)
|
|
60
69
|
this.publish({ sessionChoice: id, sessionNotice: null }); },
|
|
61
70
|
applySession: (options) => this.selectSession(false, options), resetSession: () => this.selectSession(true),
|
|
71
|
+
setDeepwork: (active) => this.setDeepwork(active), useSessionProfileModel: () => this.selectSession(false, { useProfileModel: true }, true),
|
|
62
72
|
setFieldInvalid: (field, invalid) => {
|
|
63
73
|
if (this.disposed)
|
|
64
74
|
return;
|
|
@@ -96,6 +106,7 @@ export class ProfilesController {
|
|
|
96
106
|
this.modelEventsSessionId = sessionId;
|
|
97
107
|
this.modelEvents = source;
|
|
98
108
|
this.modelEventsWatermark = source === null ? -1 : modelSelectionWatermark(source.getSnapshot());
|
|
109
|
+
this.modeEventsWatermark = source === null ? -1 : modeIntentWatermark(source.getSnapshot());
|
|
99
110
|
this.stopModelEvents = source?.subscribe(() => {
|
|
100
111
|
const window = source.getSnapshot(), change = window.change;
|
|
101
112
|
if (change.kind === "settle-assistant")
|
|
@@ -108,6 +119,17 @@ export class ProfilesController {
|
|
|
108
119
|
this.modelEventsWatermark = watermark;
|
|
109
120
|
this.modelEventsGeneration += 1;
|
|
110
121
|
}
|
|
122
|
+
let modeWatermark = change.kind === "replace" ? -1 : this.modeEventsWatermark;
|
|
123
|
+
for (const entry of change.entries)
|
|
124
|
+
if (entry.type === "event" && (entry.event.type === "deepwork/mode" || entry.event.type === "agent-preset/selected"))
|
|
125
|
+
modeWatermark = Math.max(modeWatermark, Number(entry.event.seq));
|
|
126
|
+
if (modeWatermark !== this.modeEventsWatermark) {
|
|
127
|
+
this.modeEventsWatermark = modeWatermark;
|
|
128
|
+
if (sessionId === this.current.currentSessionId) {
|
|
129
|
+
this.modeRefreshPending = true;
|
|
130
|
+
this.refreshObservedMode();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
111
133
|
}) ?? null;
|
|
112
134
|
}
|
|
113
135
|
attachModelInteractionSource(sessionId, source) {
|
|
@@ -133,6 +155,7 @@ export class ProfilesController {
|
|
|
133
155
|
if (this.disposed || id === this.current.currentSessionId)
|
|
134
156
|
return;
|
|
135
157
|
this.sessionGeneration += 1;
|
|
158
|
+
this.modeRefreshPending = false;
|
|
136
159
|
if (id !== this.modelSelectionSessionId)
|
|
137
160
|
this.attachModelSelectionSource(null, null);
|
|
138
161
|
if (id !== this.modelEventsSessionId)
|
|
@@ -162,13 +185,18 @@ export class ProfilesController {
|
|
|
162
185
|
this.publish({ catalogBusy: false });
|
|
163
186
|
}
|
|
164
187
|
}
|
|
165
|
-
|
|
188
|
+
refreshObservedMode() {
|
|
189
|
+
if (!this.disposed && this.modeRefreshPending && this.current.sessionBusy === null)
|
|
190
|
+
void this.refreshSession(true);
|
|
191
|
+
}
|
|
192
|
+
async refreshSession(preserveFeedback = false) {
|
|
166
193
|
const id = this.current.currentSessionId;
|
|
167
194
|
if (this.disposed || id === null || this.current.sessionBusy !== null)
|
|
168
195
|
return;
|
|
196
|
+
this.modeRefreshPending = false;
|
|
169
197
|
const generation = ++this.sessionGeneration;
|
|
170
198
|
const live = () => !this.disposed && generation === this.sessionGeneration && id === this.current.currentSessionId;
|
|
171
|
-
this.publish({ sessionBusy: "read", sessionIssue: null, sessionNotice: null });
|
|
199
|
+
this.publish({ sessionBusy: "read", ...(preserveFeedback ? {} : { sessionIssue: null, sessionNotice: null }) });
|
|
172
200
|
try {
|
|
173
201
|
const session = await this.unwrap(this.remote.describeSession(id));
|
|
174
202
|
if (session.sessionId !== id)
|
|
@@ -181,18 +209,47 @@ export class ProfilesController {
|
|
|
181
209
|
this.publish({ sessionIssue: this.issue(error) });
|
|
182
210
|
}
|
|
183
211
|
finally {
|
|
212
|
+
if (live()) {
|
|
213
|
+
this.publish({ sessionBusy: null });
|
|
214
|
+
this.refreshObservedMode();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
async setDeepwork(active) {
|
|
219
|
+
const { currentSessionId: id, session } = this.current;
|
|
220
|
+
if (this.disposed || id === null || session?.deepwork === undefined || session.deepwork.locked || !session.switchAllowed
|
|
221
|
+
|| this.current.sessionBusy !== null || this.current.busy !== null || this.remote.selectMode === undefined)
|
|
222
|
+
return;
|
|
223
|
+
const generation = ++this.sessionGeneration;
|
|
224
|
+
const live = () => !this.disposed && generation === this.sessionGeneration && id === this.current.currentSessionId;
|
|
225
|
+
this.publish({ sessionBusy: "mode", sessionIssue: null, sessionNotice: null });
|
|
226
|
+
try {
|
|
227
|
+
const accepted = await this.unwrap(this.remote.selectMode(id, { sessionId: id, active,
|
|
228
|
+
expectedModeRevision: session.deepwork.revision, expectedAdmissionEpoch: session.admissionEpoch }));
|
|
229
|
+
if (accepted.sessionId !== id || accepted.deepwork?.active !== active || !accepted.deepwork.explicit)
|
|
230
|
+
throw { kind: "assembly", code: "unavailable" };
|
|
231
|
+
if (live())
|
|
232
|
+
this.publish({ session: accepted, sessionNotice: active ? "mode-on" : "mode-off" });
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
184
235
|
if (live())
|
|
236
|
+
this.publish({ sessionIssue: this.issue(error) });
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
if (live()) {
|
|
185
240
|
this.publish({ sessionBusy: null });
|
|
241
|
+
this.refreshObservedMode();
|
|
242
|
+
}
|
|
186
243
|
}
|
|
187
244
|
}
|
|
188
|
-
async selectSession(reset, options) {
|
|
245
|
+
async selectSession(reset, options, modelOnly = false) {
|
|
189
246
|
const { currentSessionId: id, session, sessionChoice, snapshot } = this.current;
|
|
190
247
|
if (this.disposed || id === null || session === null || !session.switchAllowed || this.current.sessionBusy !== null
|
|
191
248
|
|| this.current.busy !== null || this.current.dirty || this.current.pendingEditor !== null)
|
|
192
249
|
return;
|
|
193
250
|
const selectedId = reset ? null : sessionChoice;
|
|
194
251
|
const revision = snapshot?.profiles.find((profile) => profile.id === selectedId)?.revision;
|
|
195
|
-
if (selectedId !== null && revision == null)
|
|
252
|
+
if (!modelOnly && selectedId !== null && revision == null)
|
|
196
253
|
return;
|
|
197
254
|
const generation = ++this.sessionGeneration;
|
|
198
255
|
const useProfileModel = !reset && options?.useProfileModel === true;
|
|
@@ -201,18 +258,21 @@ export class ProfilesController {
|
|
|
201
258
|
const modelSnapshot = modelSource?.getSnapshot();
|
|
202
259
|
const eventSource = this.modelEvents, eventGeneration = this.modelEventsGeneration;
|
|
203
260
|
const eventWatermark = eventSource === null ? -1 : modelSelectionWatermark(eventSource.getSnapshot());
|
|
261
|
+
const modeWatermark = eventSource === null ? -1 : modeIntentWatermark(eventSource.getSnapshot());
|
|
204
262
|
const interaction = this.modelInteraction, interactionGeneration = this.modelInteractionGeneration;
|
|
205
263
|
const pendingNativeChoice = interaction?.getSnapshot().status === "selecting";
|
|
206
264
|
const live = () => !this.disposed && generation === this.sessionGeneration && id === this.current.currentSessionId;
|
|
207
265
|
const selectorLive = () => live() && selector !== null && selector === this.modelSelector && selectorGeneration === this.modelSelectorGeneration;
|
|
208
266
|
this.publish({ sessionBusy: reset ? "reset" : "apply", sessionIssue: null, sessionNotice: null });
|
|
209
267
|
try {
|
|
210
|
-
const accepted = await this.unwrap(this.remote.selectSession(id, {
|
|
268
|
+
const accepted = await this.unwrap(modelOnly ? this.remote.describeSession(id) : this.remote.selectSession(id, {
|
|
211
269
|
sessionId: id, id: selectedId, ...(selectedId === null ? {} : { expectedRevision: revision }),
|
|
212
270
|
expectedSelectionRevision: session.selection.selectionRevision, expectedAdmissionEpoch: session.admissionEpoch,
|
|
213
271
|
}));
|
|
214
272
|
if (accepted.sessionId !== id)
|
|
215
273
|
throw { kind: "assembly", code: "unavailable" };
|
|
274
|
+
if (modelOnly && (accepted.admissionEpoch !== session.admissionEpoch || accepted.deepwork?.revision !== session.deepwork?.revision || !accepted.switchAllowed))
|
|
275
|
+
throw { kind: "domain", code: "conflict" };
|
|
216
276
|
if (!live())
|
|
217
277
|
return;
|
|
218
278
|
this.publish({ session: accepted, sessionChoice: accepted.selection.selectedId, sessionNotice: useProfileModel ? null : reset ? "reset" : "applied" });
|
|
@@ -242,6 +302,7 @@ export class ProfilesController {
|
|
|
242
302
|
return;
|
|
243
303
|
}
|
|
244
304
|
if (eventGeneration !== this.modelEventsGeneration || eventWatermark !== modelSelectionWatermark(eventSource.getSnapshot())
|
|
305
|
+
|| (modelOnly && modeWatermark !== modeIntentWatermark(eventSource.getSnapshot()))
|
|
245
306
|
|| interactionGeneration !== this.modelInteractionGeneration || pendingNativeChoice || interaction.getSnapshot().status === "selecting") {
|
|
246
307
|
this.publish({ sessionIssue: { kind: "assembly", code: "model-choice-changed", source: "profile-model" } });
|
|
247
308
|
return;
|
|
@@ -266,8 +327,10 @@ export class ProfilesController {
|
|
|
266
327
|
this.publish({ sessionIssue: this.issue(error) });
|
|
267
328
|
}
|
|
268
329
|
finally {
|
|
269
|
-
if (live())
|
|
330
|
+
if (live()) {
|
|
270
331
|
this.publish({ sessionBusy: null });
|
|
332
|
+
this.refreshObservedMode();
|
|
333
|
+
}
|
|
271
334
|
}
|
|
272
335
|
}
|
|
273
336
|
publish(patch) {
|
package/lib/client/locales.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
export declare const NS = "settings.dsmm-profiles";
|
|
2
2
|
export declare const en: {
|
|
3
|
+
headerCompactProfiles: string;
|
|
4
|
+
headerCompactRefresh: string;
|
|
5
|
+
headerNoSession: string;
|
|
6
|
+
headerModeEnable: string;
|
|
7
|
+
headerModeDisable: string;
|
|
8
|
+
headerModePreset: string;
|
|
9
|
+
headerModeUnavailable: string;
|
|
10
|
+
headerModeOn: string;
|
|
11
|
+
headerModeOff: string;
|
|
12
|
+
headerUseCurrentModel: string;
|
|
3
13
|
title: string;
|
|
4
14
|
description: string;
|
|
5
15
|
newSessions: string;
|
package/lib/client/locales.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const NS = "settings.dsmm-profiles";
|
|
2
2
|
export const en = {
|
|
3
|
+
headerCompactProfiles: "Profiles · keep model", headerCompactRefresh: "Refresh", headerNoSession: "Select a session to make changes.",
|
|
4
|
+
headerModeEnable: "Enable Deepwork", headerModeDisable: "Disable Deepwork", headerModePreset: "Deepwork · DW preset", headerModeUnavailable: "Deepwork unavailable", headerModeOn: "Deepwork enabled.", headerModeOff: "Deepwork disabled.", headerUseCurrentModel: "Use profile model",
|
|
3
5
|
title: "Deepwork Profiles", description: "Save independent runtime configurations and choose which one new sessions use.",
|
|
4
6
|
newSessions: "Global apply and reset affect future unscoped sessions only. Current-session actions below are separate. A cold resume retains an explicit saved session choice; otherwise it inherits the global default.",
|
|
5
7
|
editorSelect: "Profile to edit", choose: "Choose a profile", newDraft: "New unsaved profile", new: "New profile",
|
|
@@ -56,6 +58,8 @@ export const en = {
|
|
|
56
58
|
advanced: "Advanced JSONC", rawInvalid: "Structured editing is unavailable for this invalid raw draft. Correct Advanced JSONC; no fields, comments or bytes have been normalized.", invalidNumber: "Correct this bounded integer before saving or changing roles. The invalid value has not replaced the saved draft policy.",
|
|
57
59
|
};
|
|
58
60
|
export const zh = {
|
|
61
|
+
headerCompactProfiles: "配置档 · 保留模型", headerCompactRefresh: "刷新", headerNoSession: "选择会话后可更改。",
|
|
62
|
+
headerModeEnable: "启用 Deepwork", headerModeDisable: "关闭 Deepwork", headerModePreset: "Deepwork · DW 预设", headerModeUnavailable: "Deepwork 不可用", headerModeOn: "Deepwork 已启用。", headerModeOff: "Deepwork 已关闭。", headerUseCurrentModel: "使用配置档模型",
|
|
59
63
|
title: "Deepwork 配置档", description: "保存独立的运行时配置,并选择新会话使用的配置档。",
|
|
60
64
|
newSessions: "全局应用和重置仅影响之后没有独立选择的新会话。下方当前会话操作相互独立。冷恢复保留明确保存的会话选择,否则继承全局默认值。",
|
|
61
65
|
editorSelect: "要编辑的配置档", choose: "选择配置档", newDraft: "新的未保存配置档", new: "新建配置档",
|
package/lib/client.js
CHANGED
|
@@ -219,7 +219,7 @@ function selectionState(value) {
|
|
|
219
219
|
return { selectedId: item.selectedId === null ? null : id(item.selectedId), appliedRevision: item.appliedRevision === null ? null : revision(item.appliedRevision), selectionRevision: selectionRevision(item.selectionRevision) };
|
|
220
220
|
}
|
|
221
221
|
function sessionSnapshot(value) {
|
|
222
|
-
const item = object(value, ["sessionId", "globalDefault", "selection", "scope", "admissionEpoch", "switchAllowed"], ["admittedSelection", "switchUnavailableReason", "rolePolicy", "profileModel"]);
|
|
222
|
+
const item = object(value, ["sessionId", "globalDefault", "selection", "scope", "admissionEpoch", "switchAllowed"], ["admittedSelection", "switchUnavailableReason", "rolePolicy", "profileModel", "deepwork"]);
|
|
223
223
|
if (typeof item.scope !== "string" || !["global-default", "session-override", "deployment-baseline"].includes(item.scope)) fail("scope");
|
|
224
224
|
return {
|
|
225
225
|
sessionId: sessionId(item.sessionId),
|
|
@@ -234,7 +234,11 @@ function sessionSnapshot(value) {
|
|
|
234
234
|
return input;
|
|
235
235
|
}),
|
|
236
236
|
...optional(item, "rolePolicy", rolePolicy),
|
|
237
|
-
...optional(item, "profileModel", modelRoute)
|
|
237
|
+
...optional(item, "profileModel", modelRoute),
|
|
238
|
+
...optional(item, "deepwork", (input) => {
|
|
239
|
+
const mode = object(input, ["active", "explicit", "locked", "revision"]);
|
|
240
|
+
return { active: boolean(mode.active, "active"), explicit: boolean(mode.explicit, "explicit"), locked: boolean(mode.locked, "locked"), revision: revision(mode.revision) };
|
|
241
|
+
})
|
|
238
242
|
};
|
|
239
243
|
}
|
|
240
244
|
function saveRequest(value) {
|
|
@@ -253,6 +257,10 @@ function sessionSelectRequest(value) {
|
|
|
253
257
|
const { sessionId: inputSessionId, expectedAdmissionEpoch, ...profileRequest } = item;
|
|
254
258
|
return { ...selectRequest(profileRequest), sessionId: sessionId(inputSessionId), expectedAdmissionEpoch: revision(expectedAdmissionEpoch) };
|
|
255
259
|
}
|
|
260
|
+
function modeSelectRequest(value) {
|
|
261
|
+
const item = object(value, ["sessionId", "active", "expectedModeRevision", "expectedAdmissionEpoch"]);
|
|
262
|
+
return { sessionId: sessionId(item.sessionId), active: boolean(item.active, "active"), expectedModeRevision: revision(item.expectedModeRevision), expectedAdmissionEpoch: revision(item.expectedAdmissionEpoch) };
|
|
263
|
+
}
|
|
256
264
|
function codec(symbol, parse3) {
|
|
257
265
|
return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse: parse3 }) };
|
|
258
266
|
}
|
|
@@ -262,6 +270,13 @@ function descriptor(method, result, parameter) {
|
|
|
262
270
|
var TYPERT_REMOTE = {
|
|
263
271
|
package: "@dsmm/dsmm",
|
|
264
272
|
descriptors: [
|
|
273
|
+
{
|
|
274
|
+
...descriptor("selectMode", codec("SessionProfileSnapshot", sessionSnapshot)),
|
|
275
|
+
parameters: [
|
|
276
|
+
{ name: "sessionId", wire: "sessionId", source: "json", codec: codec("NativeSessionId", sessionId) },
|
|
277
|
+
{ name: "request", wire: "request", source: "json", codec: codec("SessionModeSelectRequest", modeSelectRequest) }
|
|
278
|
+
]
|
|
279
|
+
},
|
|
265
280
|
descriptor("describe", codec("ProfileSnapshot", snapshot)),
|
|
266
281
|
descriptor("read", codec("ProfileReadResult", readResult), { name: "id", codec: codec("ProfileId", id) }),
|
|
267
282
|
descriptor("save", codec("ProfileReadResult", readResult), { name: "request", codec: codec("ProfileSaveRequest", saveRequest) }),
|
|
@@ -1736,6 +1751,11 @@ function modelSelectionWatermark(window) {
|
|
|
1736
1751
|
for (const entry of window.entries) if (entry.type === "event" && entry.event.type === "model/selection") watermark = Math.max(watermark, Number(entry.event.seq));
|
|
1737
1752
|
return watermark;
|
|
1738
1753
|
}
|
|
1754
|
+
function modeIntentWatermark(window) {
|
|
1755
|
+
let watermark = -1;
|
|
1756
|
+
for (const entry of window.entries) if (entry.type === "event" && (entry.event.type === "deepwork/mode" || entry.event.type === "agent-preset/selected")) watermark = Math.max(watermark, Number(entry.event.seq));
|
|
1757
|
+
return watermark;
|
|
1758
|
+
}
|
|
1739
1759
|
var NEW_EDITOR = "";
|
|
1740
1760
|
var NEW_PROFILE_CONTENT = '{\n "version": 1,\n "id": "new-profile",\n "label": "New profile",\n "settings": {\n // Runtime overlay only. Omitted fields inherit the deployment baseline.\n "defaultActive": true\n }\n}\n';
|
|
1741
1761
|
function canReconcileSelection(snapshot2) {
|
|
@@ -1782,6 +1802,8 @@ var ProfilesController = class {
|
|
|
1782
1802
|
modelEventsSessionId = null;
|
|
1783
1803
|
modelEventsGeneration = 0;
|
|
1784
1804
|
modelEventsWatermark = -1;
|
|
1805
|
+
modeEventsWatermark = -1;
|
|
1806
|
+
modeRefreshPending = false;
|
|
1785
1807
|
stopModelEvents = null;
|
|
1786
1808
|
modelInteraction = null;
|
|
1787
1809
|
modelInteractionSessionId = null;
|
|
@@ -1818,6 +1840,8 @@ var ProfilesController = class {
|
|
|
1818
1840
|
},
|
|
1819
1841
|
applySession: (options) => this.selectSession(false, options),
|
|
1820
1842
|
resetSession: () => this.selectSession(true),
|
|
1843
|
+
setDeepwork: (active) => this.setDeepwork(active),
|
|
1844
|
+
useSessionProfileModel: () => this.selectSession(false, { useProfileModel: true }, true),
|
|
1821
1845
|
setFieldInvalid: (field, invalid) => {
|
|
1822
1846
|
if (this.disposed) return;
|
|
1823
1847
|
const invalidFields = this.current.invalidFields.filter((candidate) => candidate !== field);
|
|
@@ -1867,6 +1891,7 @@ var ProfilesController = class {
|
|
|
1867
1891
|
this.modelEventsSessionId = sessionId2;
|
|
1868
1892
|
this.modelEvents = source;
|
|
1869
1893
|
this.modelEventsWatermark = source === null ? -1 : modelSelectionWatermark(source.getSnapshot());
|
|
1894
|
+
this.modeEventsWatermark = source === null ? -1 : modeIntentWatermark(source.getSnapshot());
|
|
1870
1895
|
this.stopModelEvents = source?.subscribe(() => {
|
|
1871
1896
|
const window = source.getSnapshot(), change = window.change;
|
|
1872
1897
|
if (change.kind === "settle-assistant") return;
|
|
@@ -1876,6 +1901,15 @@ var ProfilesController = class {
|
|
|
1876
1901
|
this.modelEventsWatermark = watermark;
|
|
1877
1902
|
this.modelEventsGeneration += 1;
|
|
1878
1903
|
}
|
|
1904
|
+
let modeWatermark = change.kind === "replace" ? -1 : this.modeEventsWatermark;
|
|
1905
|
+
for (const entry of change.entries) if (entry.type === "event" && (entry.event.type === "deepwork/mode" || entry.event.type === "agent-preset/selected")) modeWatermark = Math.max(modeWatermark, Number(entry.event.seq));
|
|
1906
|
+
if (modeWatermark !== this.modeEventsWatermark) {
|
|
1907
|
+
this.modeEventsWatermark = modeWatermark;
|
|
1908
|
+
if (sessionId2 === this.current.currentSessionId) {
|
|
1909
|
+
this.modeRefreshPending = true;
|
|
1910
|
+
this.refreshObservedMode();
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1879
1913
|
}) ?? null;
|
|
1880
1914
|
}
|
|
1881
1915
|
attachModelInteractionSource(sessionId2, source) {
|
|
@@ -1898,6 +1932,7 @@ var ProfilesController = class {
|
|
|
1898
1932
|
setSession(id2) {
|
|
1899
1933
|
if (this.disposed || id2 === this.current.currentSessionId) return;
|
|
1900
1934
|
this.sessionGeneration += 1;
|
|
1935
|
+
this.modeRefreshPending = false;
|
|
1901
1936
|
if (id2 !== this.modelSelectionSessionId) this.attachModelSelectionSource(null, null);
|
|
1902
1937
|
if (id2 !== this.modelEventsSessionId) this.attachModelEventSource(null, null);
|
|
1903
1938
|
if (id2 !== this.modelInteractionSessionId) this.attachModelInteractionSource(null, null);
|
|
@@ -1917,12 +1952,16 @@ var ProfilesController = class {
|
|
|
1917
1952
|
if (!this.disposed && generation === this.catalogGeneration) this.publish({ catalogBusy: false });
|
|
1918
1953
|
}
|
|
1919
1954
|
}
|
|
1920
|
-
|
|
1955
|
+
refreshObservedMode() {
|
|
1956
|
+
if (!this.disposed && this.modeRefreshPending && this.current.sessionBusy === null) void this.refreshSession(true);
|
|
1957
|
+
}
|
|
1958
|
+
async refreshSession(preserveFeedback = false) {
|
|
1921
1959
|
const id2 = this.current.currentSessionId;
|
|
1922
1960
|
if (this.disposed || id2 === null || this.current.sessionBusy !== null) return;
|
|
1961
|
+
this.modeRefreshPending = false;
|
|
1923
1962
|
const generation = ++this.sessionGeneration;
|
|
1924
1963
|
const live = () => !this.disposed && generation === this.sessionGeneration && id2 === this.current.currentSessionId;
|
|
1925
|
-
this.publish({ sessionBusy: "read", sessionIssue: null, sessionNotice: null });
|
|
1964
|
+
this.publish({ sessionBusy: "read", ...preserveFeedback ? {} : { sessionIssue: null, sessionNotice: null } });
|
|
1926
1965
|
try {
|
|
1927
1966
|
const session = await this.unwrap(this.remote.describeSession(id2));
|
|
1928
1967
|
if (session.sessionId !== id2) throw { kind: "assembly", code: "unavailable" };
|
|
@@ -1930,15 +1969,42 @@ var ProfilesController = class {
|
|
|
1930
1969
|
} catch (error) {
|
|
1931
1970
|
if (live()) this.publish({ sessionIssue: this.issue(error) });
|
|
1932
1971
|
} finally {
|
|
1933
|
-
if (live())
|
|
1972
|
+
if (live()) {
|
|
1973
|
+
this.publish({ sessionBusy: null });
|
|
1974
|
+
this.refreshObservedMode();
|
|
1975
|
+
}
|
|
1934
1976
|
}
|
|
1935
1977
|
}
|
|
1936
|
-
async
|
|
1978
|
+
async setDeepwork(active) {
|
|
1979
|
+
const { currentSessionId: id2, session } = this.current;
|
|
1980
|
+
if (this.disposed || id2 === null || session?.deepwork === void 0 || session.deepwork.locked || !session.switchAllowed || this.current.sessionBusy !== null || this.current.busy !== null || this.remote.selectMode === void 0) return;
|
|
1981
|
+
const generation = ++this.sessionGeneration;
|
|
1982
|
+
const live = () => !this.disposed && generation === this.sessionGeneration && id2 === this.current.currentSessionId;
|
|
1983
|
+
this.publish({ sessionBusy: "mode", sessionIssue: null, sessionNotice: null });
|
|
1984
|
+
try {
|
|
1985
|
+
const accepted = await this.unwrap(this.remote.selectMode(id2, {
|
|
1986
|
+
sessionId: id2,
|
|
1987
|
+
active,
|
|
1988
|
+
expectedModeRevision: session.deepwork.revision,
|
|
1989
|
+
expectedAdmissionEpoch: session.admissionEpoch
|
|
1990
|
+
}));
|
|
1991
|
+
if (accepted.sessionId !== id2 || accepted.deepwork?.active !== active || !accepted.deepwork.explicit) throw { kind: "assembly", code: "unavailable" };
|
|
1992
|
+
if (live()) this.publish({ session: accepted, sessionNotice: active ? "mode-on" : "mode-off" });
|
|
1993
|
+
} catch (error) {
|
|
1994
|
+
if (live()) this.publish({ sessionIssue: this.issue(error) });
|
|
1995
|
+
} finally {
|
|
1996
|
+
if (live()) {
|
|
1997
|
+
this.publish({ sessionBusy: null });
|
|
1998
|
+
this.refreshObservedMode();
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
async selectSession(reset, options, modelOnly = false) {
|
|
1937
2003
|
const { currentSessionId: id2, session, sessionChoice, snapshot: snapshot2 } = this.current;
|
|
1938
2004
|
if (this.disposed || id2 === null || session === null || !session.switchAllowed || this.current.sessionBusy !== null || this.current.busy !== null || this.current.dirty || this.current.pendingEditor !== null) return;
|
|
1939
2005
|
const selectedId = reset ? null : sessionChoice;
|
|
1940
2006
|
const revision2 = snapshot2?.profiles.find((profile) => profile.id === selectedId)?.revision;
|
|
1941
|
-
if (selectedId !== null && revision2 == null) return;
|
|
2007
|
+
if (!modelOnly && selectedId !== null && revision2 == null) return;
|
|
1942
2008
|
const generation = ++this.sessionGeneration;
|
|
1943
2009
|
const useProfileModel = !reset && options?.useProfileModel === true;
|
|
1944
2010
|
const selector = this.modelSelector, selectorGeneration = this.modelSelectorGeneration;
|
|
@@ -1946,13 +2012,14 @@ var ProfilesController = class {
|
|
|
1946
2012
|
const modelSnapshot = modelSource?.getSnapshot();
|
|
1947
2013
|
const eventSource = this.modelEvents, eventGeneration = this.modelEventsGeneration;
|
|
1948
2014
|
const eventWatermark = eventSource === null ? -1 : modelSelectionWatermark(eventSource.getSnapshot());
|
|
2015
|
+
const modeWatermark = eventSource === null ? -1 : modeIntentWatermark(eventSource.getSnapshot());
|
|
1949
2016
|
const interaction = this.modelInteraction, interactionGeneration = this.modelInteractionGeneration;
|
|
1950
2017
|
const pendingNativeChoice = interaction?.getSnapshot().status === "selecting";
|
|
1951
2018
|
const live = () => !this.disposed && generation === this.sessionGeneration && id2 === this.current.currentSessionId;
|
|
1952
2019
|
const selectorLive = () => live() && selector !== null && selector === this.modelSelector && selectorGeneration === this.modelSelectorGeneration;
|
|
1953
2020
|
this.publish({ sessionBusy: reset ? "reset" : "apply", sessionIssue: null, sessionNotice: null });
|
|
1954
2021
|
try {
|
|
1955
|
-
const accepted = await this.unwrap(this.remote.selectSession(id2, {
|
|
2022
|
+
const accepted = await this.unwrap(modelOnly ? this.remote.describeSession(id2) : this.remote.selectSession(id2, {
|
|
1956
2023
|
sessionId: id2,
|
|
1957
2024
|
id: selectedId,
|
|
1958
2025
|
...selectedId === null ? {} : { expectedRevision: revision2 },
|
|
@@ -1960,6 +2027,7 @@ var ProfilesController = class {
|
|
|
1960
2027
|
expectedAdmissionEpoch: session.admissionEpoch
|
|
1961
2028
|
}));
|
|
1962
2029
|
if (accepted.sessionId !== id2) throw { kind: "assembly", code: "unavailable" };
|
|
2030
|
+
if (modelOnly && (accepted.admissionEpoch !== session.admissionEpoch || accepted.deepwork?.revision !== session.deepwork?.revision || !accepted.switchAllowed)) throw { kind: "domain", code: "conflict" };
|
|
1963
2031
|
if (!live()) return;
|
|
1964
2032
|
this.publish({ session: accepted, sessionChoice: accepted.selection.selectedId, sessionNotice: useProfileModel ? null : reset ? "reset" : "applied" });
|
|
1965
2033
|
if (!useProfileModel || !live()) return;
|
|
@@ -1983,7 +2051,7 @@ var ProfilesController = class {
|
|
|
1983
2051
|
this.publish({ sessionIssue: { kind: "assembly", code: "model-observation-unavailable", source: "profile-model" } });
|
|
1984
2052
|
return;
|
|
1985
2053
|
}
|
|
1986
|
-
if (eventGeneration !== this.modelEventsGeneration || eventWatermark !== modelSelectionWatermark(eventSource.getSnapshot()) || interactionGeneration !== this.modelInteractionGeneration || pendingNativeChoice || interaction.getSnapshot().status === "selecting") {
|
|
2054
|
+
if (eventGeneration !== this.modelEventsGeneration || eventWatermark !== modelSelectionWatermark(eventSource.getSnapshot()) || modelOnly && modeWatermark !== modeIntentWatermark(eventSource.getSnapshot()) || interactionGeneration !== this.modelInteractionGeneration || pendingNativeChoice || interaction.getSnapshot().status === "selecting") {
|
|
1987
2055
|
this.publish({ sessionIssue: { kind: "assembly", code: "model-choice-changed", source: "profile-model" } });
|
|
1988
2056
|
return;
|
|
1989
2057
|
}
|
|
@@ -1996,7 +2064,10 @@ var ProfilesController = class {
|
|
|
1996
2064
|
} catch (error) {
|
|
1997
2065
|
if (live()) this.publish({ sessionIssue: this.issue(error) });
|
|
1998
2066
|
} finally {
|
|
1999
|
-
if (live())
|
|
2067
|
+
if (live()) {
|
|
2068
|
+
this.publish({ sessionBusy: null });
|
|
2069
|
+
this.refreshObservedMode();
|
|
2070
|
+
}
|
|
2000
2071
|
}
|
|
2001
2072
|
}
|
|
2002
2073
|
publish(patch) {
|
|
@@ -2173,6 +2244,16 @@ var ProfilesController = class {
|
|
|
2173
2244
|
// src/client/locales.ts
|
|
2174
2245
|
var NS = "settings.dsmm-profiles";
|
|
2175
2246
|
var en = {
|
|
2247
|
+
headerCompactProfiles: "Profiles · keep model",
|
|
2248
|
+
headerCompactRefresh: "Refresh",
|
|
2249
|
+
headerNoSession: "Select a session to make changes.",
|
|
2250
|
+
headerModeEnable: "Enable Deepwork",
|
|
2251
|
+
headerModeDisable: "Disable Deepwork",
|
|
2252
|
+
headerModePreset: "Deepwork · DW preset",
|
|
2253
|
+
headerModeUnavailable: "Deepwork unavailable",
|
|
2254
|
+
headerModeOn: "Deepwork enabled.",
|
|
2255
|
+
headerModeOff: "Deepwork disabled.",
|
|
2256
|
+
headerUseCurrentModel: "Use profile model",
|
|
2176
2257
|
title: "Deepwork Profiles",
|
|
2177
2258
|
description: "Save independent runtime configurations and choose which one new sessions use.",
|
|
2178
2259
|
newSessions: "Global apply and reset affect future unscoped sessions only. Current-session actions below are separate. A cold resume retains an explicit saved session choice; otherwise it inherits the global default.",
|
|
@@ -2334,6 +2415,16 @@ var en = {
|
|
|
2334
2415
|
invalidNumber: "Correct this bounded integer before saving or changing roles. The invalid value has not replaced the saved draft policy."
|
|
2335
2416
|
};
|
|
2336
2417
|
var zh = {
|
|
2418
|
+
headerCompactProfiles: "配置档 · 保留模型",
|
|
2419
|
+
headerCompactRefresh: "刷新",
|
|
2420
|
+
headerNoSession: "选择会话后可更改。",
|
|
2421
|
+
headerModeEnable: "启用 Deepwork",
|
|
2422
|
+
headerModeDisable: "关闭 Deepwork",
|
|
2423
|
+
headerModePreset: "Deepwork · DW 预设",
|
|
2424
|
+
headerModeUnavailable: "Deepwork 不可用",
|
|
2425
|
+
headerModeOn: "Deepwork 已启用。",
|
|
2426
|
+
headerModeOff: "Deepwork 已关闭。",
|
|
2427
|
+
headerUseCurrentModel: "使用配置档模型",
|
|
2337
2428
|
title: "Deepwork 配置档",
|
|
2338
2429
|
description: "保存独立的运行时配置,并选择新会话使用的配置档。",
|
|
2339
2430
|
newSessions: "全局应用和重置仅影响之后没有独立选择的新会话。下方当前会话操作相互独立。冷恢复保留明确保存的会话选择,否则继承全局默认值。",
|
|
@@ -2745,7 +2836,7 @@ function SessionScope({ state, actions, t, compact = false }) {
|
|
|
2745
2836
|
const selected = state.snapshot?.profiles.find((profile) => profile.id === state.sessionChoice);
|
|
2746
2837
|
const disabled = state.busy !== null || state.pendingEditor !== null || state.sessionBusy !== null || state.dirty;
|
|
2747
2838
|
const allowed = session !== null && session.switchAllowed && /^[a-f0-9]{64}$|^absent$/u.test(session.selection.selectionRevision);
|
|
2748
|
-
const status = state.sessionNotice === null ? "" : t(state.sessionNotice === "applied-with-model" ? "sessionAppliedWithModel" : state.sessionNotice === "applied" ? "sessionApplied" : "sessionResetDone");
|
|
2839
|
+
const status = state.sessionNotice === null ? "" : t(state.sessionNotice === "mode-on" ? "headerModeOn" : state.sessionNotice === "mode-off" ? "headerModeOff" : state.sessionNotice === "applied-with-model" ? "sessionAppliedWithModel" : state.sessionNotice === "applied" ? "sessionApplied" : "sessionResetDone");
|
|
2749
2840
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsmm-session-scope", "aria-busy": state.sessionBusy !== null, "data-dsmm-session-scope": true, children: [
|
|
2750
2841
|
!compact && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { children: t("sessionScope") }),
|
|
2751
2842
|
state.currentSessionId === null ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsmm-hint", children: t("noSession") }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
@@ -2800,26 +2891,30 @@ function SessionProfiles(props) {
|
|
|
2800
2891
|
if (state.sessionIssue !== null) feedback = t(state.sessionIssue.source === "profile-model" ? state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed" : state.sessionIssue.code === "conflict" ? "headerConflict" : state.sessionIssue.code === "activation" ? "headerActivationRefused" : state.sessionIssue.code === "maintenance" ? "headerMaintenanceRefused" : state.sessionIssue.code === "busy" ? "headerBusyRefused" : state.sessionIssue.code === "cancelled" ? "headerCancelledRefused" : state.sessionIssue.code === "unavailable" || state.sessionIssue.kind === "assembly" ? "headerUnavailableRefused" : "headerSelectionRefused");
|
|
2801
2892
|
else if (committing || state.busy !== null) feedback = t(state.sessionBusy === "apply" || state.sessionBusy === "reset" ? "headerApplying" : "headerLoading");
|
|
2802
2893
|
else if (state.dirty || state.invalidFields.length > 0 || state.pendingEditor !== null) feedback = t("headerDraft");
|
|
2803
|
-
else if (id2 === null) feedback = t("
|
|
2894
|
+
else if (id2 === null) feedback = t("headerNoSession");
|
|
2804
2895
|
else if (session === null || state.snapshot === null) feedback = t("headerUnavailable");
|
|
2805
2896
|
else if (!session.switchAllowed) feedback = t("headerBusy");
|
|
2806
|
-
else if (state.sessionNotice !== null) feedback = t(state.sessionNotice === "applied-with-model" ? "headerAppliedWithModel" : "headerApplied");
|
|
2807
|
-
const capturedSuffix = session?.scope === "global-default" && !unknownCaptured ? ` — ${t("headerCaptured")}` : "";
|
|
2897
|
+
else if (state.sessionNotice !== null) feedback = t(state.sessionNotice === "mode-on" ? "headerModeOn" : state.sessionNotice === "mode-off" ? "headerModeOff" : state.sessionNotice === "applied-with-model" ? "headerAppliedWithModel" : "headerApplied");
|
|
2808
2898
|
const profileName = unknownCaptured ? t("headerCaptured") : currentSaved?.label === void 0 ? admission?.selectedId ?? t("sessionBaseline") : `${currentSaved.label} (${currentSaved.id})`;
|
|
2809
|
-
const currentLabel = t("headerCurrentProfile", { profile: session === null ? t("headerUnavailable") : profileName
|
|
2899
|
+
const currentLabel = t("headerCurrentProfile", { profile: session === null ? t("headerUnavailable") : profileName });
|
|
2810
2900
|
const entries = [{ type: "label", id: "@current", text: currentLabel }];
|
|
2811
2901
|
if (id2 === null && state.snapshot !== null) entries.push({ type: "label", id: "@future", text: t("sessionFutureDefault", { profile: state.snapshot.profiles.find((profile) => profile.id === state.snapshot.selectedId)?.label ?? state.snapshot.selectedId ?? t("sessionBaseline") }) });
|
|
2812
|
-
if (feedback !== "") entries.push({ type: "label", id: "@status", text: feedback });
|
|
2902
|
+
if (feedback !== "" && (state.sessionNotice === null || state.sessionIssue !== null)) entries.push({ type: "label", id: "@status", text: feedback });
|
|
2903
|
+
const mode = session?.deepwork;
|
|
2904
|
+
entries.push({
|
|
2905
|
+
id: "@mode",
|
|
2906
|
+
label: t(mode === void 0 ? "headerModeUnavailable" : mode.locked ? "headerModePreset" : mode.active ? "headerModeDisable" : "headerModeEnable"),
|
|
2907
|
+
disabled: id2 === null || committing || state.busy !== null || session === null || !session.switchAllowed || mode === void 0 || mode.locked
|
|
2908
|
+
});
|
|
2813
2909
|
const diagnostic = state.sessionIssue === null ? null : menuIssue(state.sessionIssue);
|
|
2814
2910
|
const diagnosticText = diagnostic === null ? "" : t("headerIssueCode", { code: diagnostic.code }) + (diagnostic.field === void 0 ? "" : ` ${t("headerIssueField", { field: diagnostic.field })}`);
|
|
2815
2911
|
const retryHint = t(diagnostic?.code === "maintenance" || diagnostic?.code === "busy" ? "headerWaitRetryHint" : "headerRetryHint");
|
|
2816
2912
|
if (diagnostic !== null) entries.push({ type: "label", id: "@diagnostic", text: diagnosticText }, { type: "label", id: "@retry", text: retryHint });
|
|
2817
|
-
if (admission?.selectedId != null && currentSaved === void 0) entries.push({ id: admission.selectedId, label: `${admission.selectedId} — ${t("headerSavedUnavailable")}
|
|
2913
|
+
if (admission?.selectedId != null && currentSaved === void 0) entries.push({ id: admission.selectedId, label: `${admission.selectedId} — ${t("headerSavedUnavailable")}`, disabled: true });
|
|
2818
2914
|
if (unknownCaptured) entries.push({ id: "__dsmm_captured_default__", label: t("headerCaptured"), disabled: true });
|
|
2819
|
-
entries.push({ type: "separator", id: "@keep-separator" }, { type: "label", id: "@keep-heading", text: t("
|
|
2820
|
-
for (const profile of profiles) entries.push({ id: profile.id, label: (profile.label ?? profile.id) + (profile.
|
|
2821
|
-
entries.push({ type: "separator", id: "@model-separator" }, {
|
|
2822
|
-
for (const profile of profiles) entries.push({ id: `@model:${profile.id}`, label: t("headerUseModelAction", { profile: profile.label ?? profile.id }) + (profile.error === void 0 && profile.revision !== null ? "" : ` — ${t("headerSavedUnavailable")}`), disabled: disabled || profile.revision === null || profile.error !== void 0 });
|
|
2915
|
+
entries.push({ type: "separator", id: "@keep-separator" }, { type: "label", id: "@keep-heading", text: t("headerCompactProfiles") }, { id: "", label: t("sessionBaseline"), disabled });
|
|
2916
|
+
for (const profile of profiles) entries.push({ id: profile.id, label: (profile.label ?? profile.id) + (profile.error === void 0 && profile.revision !== null ? "" : ` — ${t("headerSavedUnavailable")}`), disabled: disabled || profile.revision === null || profile.error !== void 0 });
|
|
2917
|
+
entries.push({ type: "separator", id: "@model-separator" }, { id: "@use-model", label: t("headerUseCurrentModel"), disabled: disabled || session?.profileModel === void 0 });
|
|
2823
2918
|
const open = openFor === id2;
|
|
2824
2919
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsmm-header-profiles", "data-dsmm-header-profile": true, "aria-busy": committing, children: [
|
|
2825
2920
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -2833,7 +2928,7 @@ function SessionProfiles(props) {
|
|
|
2833
2928
|
listClassName: "dsmm-profile-menu",
|
|
2834
2929
|
items: entries,
|
|
2835
2930
|
selectedId: current,
|
|
2836
|
-
footer: [{ id: "@refresh", label: t("
|
|
2931
|
+
footer: [{ id: "@refresh", label: t("headerCompactRefresh"), disabled: committing || state.busy !== null }],
|
|
2837
2932
|
anchor: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", size: "sm", variant: "toolbar", className: "dsmm-profile-trigger", icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconBranchOutlineRegular, {}), "aria-label": t("headerProfileLabel"), "aria-haspopup": "menu", "aria-expanded": open, "aria-describedby": `${prefix}-feedback`, onClick: () => setOpenFor(open ? void 0 : id2) }),
|
|
2838
2933
|
onClose: () => setOpenFor(void 0),
|
|
2839
2934
|
onSelect: (value) => {
|
|
@@ -2847,9 +2942,13 @@ function SessionProfiles(props) {
|
|
|
2847
2942
|
} else {
|
|
2848
2943
|
const row = entries.find((entry) => entry.id === value && !("type" in entry));
|
|
2849
2944
|
if (row === void 0 || !("disabled" in row) || row.disabled) return;
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2945
|
+
if (value === "@mode") {
|
|
2946
|
+
if (mode !== void 0) void props.setDeepwork(!mode.active);
|
|
2947
|
+
} else if (value === "@use-model") void props.useSessionProfileModel();
|
|
2948
|
+
else {
|
|
2949
|
+
props.chooseSessionProfile(value || null);
|
|
2950
|
+
void props.applySession();
|
|
2951
|
+
}
|
|
2853
2952
|
}
|
|
2854
2953
|
setOpenFor(void 0);
|
|
2855
2954
|
}
|
package/lib/index.js
CHANGED
|
@@ -108,7 +108,7 @@ function applyRuntime(ctx, config) {
|
|
|
108
108
|
}
|
|
109
109
|
requiresNativeProfiles = true;
|
|
110
110
|
const installProfiles = async (profileCtx) => {
|
|
111
|
-
runtime = await createProfileRuntime(profileCtx, getReadySettings());
|
|
111
|
+
runtime = await createProfileRuntime(profileCtx, getReadySettings(), { modeController: controller });
|
|
112
112
|
profileCtx.provide?.("dsmmProfileRuntime", runtime);
|
|
113
113
|
const manager = runtime;
|
|
114
114
|
profileCtx.inject?.(["typert"], (rpcCtx) => {
|
package/lib/profile-remote.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RemoteResult, TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
2
2
|
import type { TypertContribution } from "@deepseek-ai/dsh-typert-registry";
|
|
3
|
-
import type { ProfileErrorInfo, ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSnapshot, SessionProfileSelectRequest, SessionProfileSnapshot } from "./profile-types.js";
|
|
3
|
+
import type { ProfileErrorInfo, ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSnapshot, SessionModeSelectRequest, SessionProfileSelectRequest, SessionProfileSnapshot } from "./profile-types.js";
|
|
4
4
|
export interface DsmmProfilesRemote {
|
|
5
5
|
describe(): Promise<RemoteResult<ProfileSnapshot>>;
|
|
6
6
|
read(id: string): Promise<RemoteResult<ProfileReadResult>>;
|
|
@@ -8,6 +8,7 @@ export interface DsmmProfilesRemote {
|
|
|
8
8
|
select(request: ProfileSelectRequest): Promise<RemoteResult<ProfileSnapshot>>;
|
|
9
9
|
describeSession(sessionId: string): Promise<RemoteResult<SessionProfileSnapshot>>;
|
|
10
10
|
selectSession(sessionId: string, request: SessionProfileSelectRequest): Promise<RemoteResult<SessionProfileSnapshot>>;
|
|
11
|
+
selectMode?(sessionId: string, request: SessionModeSelectRequest): Promise<RemoteResult<SessionProfileSnapshot>>;
|
|
11
12
|
}
|
|
12
13
|
declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
13
14
|
interface TypertRemoteMap {
|
|
@@ -17,6 +18,7 @@ declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
|
17
18
|
"dsmmProfiles/select": DsmmProfilesRemote["select"];
|
|
18
19
|
"dsmmProfiles/describeSession": DsmmProfilesRemote["describeSession"];
|
|
19
20
|
"dsmmProfiles/selectSession": DsmmProfilesRemote["selectSession"];
|
|
21
|
+
"dsmmProfiles/selectMode": NonNullable<DsmmProfilesRemote["selectMode"]>;
|
|
20
22
|
}
|
|
21
23
|
interface TypertRemoteNamespaceMap {
|
|
22
24
|
dsmmProfiles: DsmmProfilesRemote;
|
package/lib/profile-remote.js
CHANGED
|
@@ -152,7 +152,7 @@ function selectionState(value) {
|
|
|
152
152
|
return { selectedId: item.selectedId === null ? null : id(item.selectedId), appliedRevision: item.appliedRevision === null ? null : revision(item.appliedRevision), selectionRevision: selectionRevision(item.selectionRevision) };
|
|
153
153
|
}
|
|
154
154
|
function sessionSnapshot(value) {
|
|
155
|
-
const item = object(value, ["sessionId", "globalDefault", "selection", "scope", "admissionEpoch", "switchAllowed"], ["admittedSelection", "switchUnavailableReason", "rolePolicy", "profileModel"]);
|
|
155
|
+
const item = object(value, ["sessionId", "globalDefault", "selection", "scope", "admissionEpoch", "switchAllowed"], ["admittedSelection", "switchUnavailableReason", "rolePolicy", "profileModel", "deepwork"]);
|
|
156
156
|
if (typeof item.scope !== "string" || !["global-default", "session-override", "deployment-baseline"].includes(item.scope))
|
|
157
157
|
fail("scope");
|
|
158
158
|
return {
|
|
@@ -166,6 +166,10 @@ function sessionSnapshot(value) {
|
|
|
166
166
|
}),
|
|
167
167
|
...optional(item, "rolePolicy", rolePolicy),
|
|
168
168
|
...optional(item, "profileModel", modelRoute),
|
|
169
|
+
...optional(item, "deepwork", (input) => {
|
|
170
|
+
const mode = object(input, ["active", "explicit", "locked", "revision"]);
|
|
171
|
+
return { active: boolean(mode.active, "active"), explicit: boolean(mode.explicit, "explicit"), locked: boolean(mode.locked, "locked"), revision: revision(mode.revision) };
|
|
172
|
+
}),
|
|
169
173
|
};
|
|
170
174
|
}
|
|
171
175
|
function saveRequest(value) {
|
|
@@ -186,6 +190,10 @@ function sessionSelectRequest(value) {
|
|
|
186
190
|
const { sessionId: inputSessionId, expectedAdmissionEpoch, ...profileRequest } = item;
|
|
187
191
|
return { ...selectRequest(profileRequest), sessionId: sessionId(inputSessionId), expectedAdmissionEpoch: revision(expectedAdmissionEpoch) };
|
|
188
192
|
}
|
|
193
|
+
function modeSelectRequest(value) {
|
|
194
|
+
const item = object(value, ["sessionId", "active", "expectedModeRevision", "expectedAdmissionEpoch"]);
|
|
195
|
+
return { sessionId: sessionId(item.sessionId), active: boolean(item.active, "active"), expectedModeRevision: revision(item.expectedModeRevision), expectedAdmissionEpoch: revision(item.expectedAdmissionEpoch) };
|
|
196
|
+
}
|
|
189
197
|
function codec(symbol, parse) {
|
|
190
198
|
return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse }) };
|
|
191
199
|
}
|
|
@@ -196,6 +204,13 @@ function descriptor(method, result, parameter) {
|
|
|
196
204
|
export const TYPERT_REMOTE = {
|
|
197
205
|
package: "@dsmm/dsmm",
|
|
198
206
|
descriptors: [
|
|
207
|
+
{
|
|
208
|
+
...descriptor("selectMode", codec("SessionProfileSnapshot", sessionSnapshot)),
|
|
209
|
+
parameters: [
|
|
210
|
+
{ name: "sessionId", wire: "sessionId", source: "json", codec: codec("NativeSessionId", sessionId) },
|
|
211
|
+
{ name: "request", wire: "request", source: "json", codec: codec("SessionModeSelectRequest", modeSelectRequest) },
|
|
212
|
+
],
|
|
213
|
+
},
|
|
199
214
|
descriptor("describe", codec("ProfileSnapshot", snapshot)),
|
|
200
215
|
descriptor("read", codec("ProfileReadResult", readResult), { name: "id", codec: codec("ProfileId", id) }),
|
|
201
216
|
descriptor("save", codec("ProfileReadResult", readResult), { name: "request", codec: codec("ProfileSaveRequest", saveRequest) }),
|