@dsmm/dsmm 0.1.6 → 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 +13 -8
- package/docs/compatibility.md +12 -6
- package/docs/profiles.md +8 -4
- package/docs/releasing.md +42 -18
- package/docs/settings-status.md +4 -4
- package/lib/client/SessionProfiles.d.ts +2 -1
- package/lib/client/SessionProfiles.js +78 -17
- package/lib/client/controller.d.ts +9 -3
- package/lib/client/controller.js +69 -6
- package/lib/client/index.js +6 -4
- package/lib/client/locales.d.ts +23 -0
- package/lib/client/locales.js +12 -4
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +8 -3
- package/lib/client.js +226 -65
- 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.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.",
|
|
@@ -2226,13 +2307,16 @@ var en = {
|
|
|
2226
2307
|
headerProfileLabel: "Current-session profile (header)",
|
|
2227
2308
|
headerCaptured: "captured global default",
|
|
2228
2309
|
headerSavedUnavailable: "saved profile unavailable",
|
|
2310
|
+
headerCurrentProfile: "Current profile: {profile}",
|
|
2311
|
+
headerRefresh: "Refresh profiles and current-session state",
|
|
2312
|
+
headerUseModelAction: "Use profile model: {profile}",
|
|
2229
2313
|
headerLoading: "Loading profile…",
|
|
2230
2314
|
headerApplying: "Applying profile…",
|
|
2231
2315
|
headerApplied: "Profile applied.",
|
|
2232
2316
|
headerBusy: "Session is busy.",
|
|
2233
2317
|
headerUnavailable: "Profile unavailable.",
|
|
2234
2318
|
headerDraft: "Save or discard the draft in Settings.",
|
|
2235
|
-
headerConflict: "
|
|
2319
|
+
headerConflict: "The session profile or admission changed elsewhere. Refresh current-session state before retrying.",
|
|
2236
2320
|
headerRefused: "Profile change unconfirmed. Check Settings.",
|
|
2237
2321
|
headerKeepModelGroup: "Switch profile — keep current model",
|
|
2238
2322
|
headerUseModelGroup: "Switch and use profile model",
|
|
@@ -2241,6 +2325,16 @@ var en = {
|
|
|
2241
2325
|
headerModelUnconfirmed: "Profile applied; model change unconfirmed. Check Models/Settings.",
|
|
2242
2326
|
headerAppliedWithModel: "Profile and native model applied.",
|
|
2243
2327
|
headerModelChoiceChanged: "Profile applied; newer native model choice kept.",
|
|
2328
|
+
headerActivationRefused: "Profile activation was refused. Check its configuration and native model catalog.",
|
|
2329
|
+
headerSelectionRefused: "The profile change could not be confirmed.",
|
|
2330
|
+
headerIssueCode: "Reason: {code}.",
|
|
2331
|
+
headerIssueField: "Configuration field: {field}.",
|
|
2332
|
+
headerRetryHint: "Refresh profiles and current-session state, resolve the indicated issue in Settings or native Models, then retry when the session is idle.",
|
|
2333
|
+
headerMaintenanceRefused: "Native maintenance owns this session. The previous profile is kept.",
|
|
2334
|
+
headerBusyRefused: "The session is busy. The previous profile is kept.",
|
|
2335
|
+
headerCancelledRefused: "The profile request was cancelled. Refresh current-session state before retrying; do not assume a change completed.",
|
|
2336
|
+
headerUnavailableRefused: "The native session or profile service is unavailable. Reconnect and refresh before retrying.",
|
|
2337
|
+
headerWaitRetryHint: "Wait for the native work or maintenance to finish, then Refresh and retry. No profile change is queued automatically.",
|
|
2244
2338
|
noSession: "No native session is selected. Session Apply is disabled; global defaults and drafts remain editable.",
|
|
2245
2339
|
sessionUnavailable: "The current session could not be confirmed. Refresh its state before retrying; the prior policy is kept.",
|
|
2246
2340
|
sessionBusy: "Switching is unavailable: {reason}. The Host must reserve a truly idle ordinary session before applying.",
|
|
@@ -2321,6 +2415,16 @@ var en = {
|
|
|
2321
2415
|
invalidNumber: "Correct this bounded integer before saving or changing roles. The invalid value has not replaced the saved draft policy."
|
|
2322
2416
|
};
|
|
2323
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: "使用配置档模型",
|
|
2324
2428
|
title: "Deepwork 配置档",
|
|
2325
2429
|
description: "保存独立的运行时配置,并选择新会话使用的配置档。",
|
|
2326
2430
|
newSessions: "全局应用和重置仅影响之后没有独立选择的新会话。下方当前会话操作相互独立。冷恢复保留明确保存的会话选择,否则继承全局默认值。",
|
|
@@ -2374,13 +2478,16 @@ var zh = {
|
|
|
2374
2478
|
headerProfileLabel: "当前会话配置档(会话栏)",
|
|
2375
2479
|
headerCaptured: "已捕获的全局默认值",
|
|
2376
2480
|
headerSavedUnavailable: "保存的配置档不可用",
|
|
2481
|
+
headerCurrentProfile: "当前配置档:{profile}",
|
|
2482
|
+
headerRefresh: "刷新配置档和当前会话状态",
|
|
2483
|
+
headerUseModelAction: "使用配置档模型:{profile}",
|
|
2377
2484
|
headerLoading: "加载配置档…",
|
|
2378
2485
|
headerApplying: "应用配置档…",
|
|
2379
2486
|
headerApplied: "配置档已应用。",
|
|
2380
2487
|
headerBusy: "会话忙碌。",
|
|
2381
2488
|
headerUnavailable: "配置档不可用。",
|
|
2382
2489
|
headerDraft: "请在设置中保存或丢弃草稿。",
|
|
2383
|
-
headerConflict: "
|
|
2490
|
+
headerConflict: "会话配置档或准入代次已在其他位置改变,请刷新当前会话状态后重试。",
|
|
2384
2491
|
headerRefused: "未确认配置档更改,请检查设置。",
|
|
2385
2492
|
headerKeepModelGroup: "切换配置档 — 保留当前模型",
|
|
2386
2493
|
headerUseModelGroup: "切换并使用配置档模型",
|
|
@@ -2389,6 +2496,16 @@ var zh = {
|
|
|
2389
2496
|
headerModelUnconfirmed: "配置档已应用,模型更改未确认。请检查模型或设置页。",
|
|
2390
2497
|
headerAppliedWithModel: "配置档和原生模型已应用。",
|
|
2391
2498
|
headerModelChoiceChanged: "配置档已应用,已保留更新的原生模型选择。",
|
|
2499
|
+
headerActivationRefused: "配置档启用被拒绝,请检查其配置和原生模型目录。",
|
|
2500
|
+
headerSelectionRefused: "无法确认配置档更改。",
|
|
2501
|
+
headerIssueCode: "原因:{code}。",
|
|
2502
|
+
headerIssueField: "配置字段:{field}。",
|
|
2503
|
+
headerRetryHint: "请刷新配置档和当前会话状态,在设置或原生模型页解决所示问题,然后在会话空闲时重试。",
|
|
2504
|
+
headerMaintenanceRefused: "原生维护正在占用此会话,原配置档已保留。",
|
|
2505
|
+
headerBusyRefused: "会话正在运行,原配置档已保留。",
|
|
2506
|
+
headerCancelledRefused: "配置档请求已取消,请刷新当前会话状态后重试,不要假定更改已完成。",
|
|
2507
|
+
headerUnavailableRefused: "原生会话或配置档服务不可用,请重新连接并刷新后重试。",
|
|
2508
|
+
headerWaitRetryHint: "请等待原生运行或维护结束,然后刷新并重试。不会自动排队应用配置档。",
|
|
2392
2509
|
noSession: "未选择原生会话。会话应用已禁用;仍可编辑全局默认值和草稿。",
|
|
2393
2510
|
sessionUnavailable: "无法确认当前会话。重试前请刷新状态;原策略已保留。",
|
|
2394
2511
|
sessionBusy: "暂不可切换:{reason}。Host 必须先保留真正空闲的普通会话。",
|
|
@@ -2704,6 +2821,14 @@ function sessionProfileLabels(session, t) {
|
|
|
2704
2821
|
|
|
2705
2822
|
// src/client/SessionProfiles.tsx
|
|
2706
2823
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2824
|
+
var MENU_ISSUE_CODES = /* @__PURE__ */ new Set(["validation", "conflict", "not-found", "lock-timeout", "unsafe-path", "io", "activation", "corrupt-selection", "limit", "busy", "maintenance", "disposed", "not-owned", "unavailable", "cancelled", "model-unconfigured", "model-choice-changed", "model-service-unavailable", "model-observation-unavailable", "model-selection-failed"]);
|
|
2825
|
+
var MENU_ROLE_FIELD = /^(?:settings\.roleRouting\.)?dsmm-(?:orchestrator|planner|plan-critic|builder|reviewer|oracle|oracle-2nd|creative|code-search|doc-search|clarifier|media-reader)(?:\.(?:primary|fallbackRoutes)(?:\[[0-7]\])?(?:\.(?:provider|model|reasoningEffort))?|\.strategy|\.rateLimit(?:\.(?:maxRetries|initialDelayMs|maxDelayMs|maxTotalDelayMs|switchAfterRateLimits|maxSwitches))?)?$/u;
|
|
2826
|
+
var MENU_COMMON_FIELD = /^(?:version|id|label|content|sessionId|expectedRevision|expectedSelectionRevision|expectedAdmissionEpoch|settings(?:\.(?:defaultActive|roleRouting|workflow|guards|runtimeRecovery|runtimePolicy))?)$/u;
|
|
2827
|
+
function menuIssue(issue) {
|
|
2828
|
+
const code = MENU_ISSUE_CODES.has(issue.code) ? issue.code : issue.kind === "transport" ? "transport" : "unavailable";
|
|
2829
|
+
const field = issue.field;
|
|
2830
|
+
return { code, ...typeof field === "string" && field.length <= 128 && (MENU_ROLE_FIELD.test(field) || MENU_COMMON_FIELD.test(field)) ? { field } : {} };
|
|
2831
|
+
}
|
|
2707
2832
|
function SessionScope({ state, actions, t, compact = false }) {
|
|
2708
2833
|
const prefix = (0, import_react2.useId)();
|
|
2709
2834
|
const session = state.session;
|
|
@@ -2711,7 +2836,7 @@ function SessionScope({ state, actions, t, compact = false }) {
|
|
|
2711
2836
|
const selected = state.snapshot?.profiles.find((profile) => profile.id === state.sessionChoice);
|
|
2712
2837
|
const disabled = state.busy !== null || state.pendingEditor !== null || state.sessionBusy !== null || state.dirty;
|
|
2713
2838
|
const allowed = session !== null && session.switchAllowed && /^[a-f0-9]{64}$|^absent$/u.test(session.selection.selectionRevision);
|
|
2714
|
-
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");
|
|
2715
2840
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsmm-session-scope", "aria-busy": state.sessionBusy !== null, "data-dsmm-session-scope": true, children: [
|
|
2716
2841
|
!compact && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { children: t("sessionScope") }),
|
|
2717
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: [
|
|
@@ -2747,7 +2872,12 @@ function SessionScope({ state, actions, t, compact = false }) {
|
|
|
2747
2872
|
function SessionProfiles(props) {
|
|
2748
2873
|
const prefix = (0, import_react2.useId)();
|
|
2749
2874
|
const state = props.useProfiles((snapshot2) => snapshot2);
|
|
2750
|
-
|
|
2875
|
+
const id2 = state.currentSessionId;
|
|
2876
|
+
const [openFor, setOpenFor] = (0, import_react2.useState)(void 0);
|
|
2877
|
+
(0, import_react2.useEffect)(() => {
|
|
2878
|
+
setOpenFor(void 0);
|
|
2879
|
+
}, [id2]);
|
|
2880
|
+
if (props.sessionId !== void 0 && props.sessionId !== id2) return null;
|
|
2751
2881
|
const { t } = props;
|
|
2752
2882
|
const session = state.session;
|
|
2753
2883
|
const admission = session?.admittedSelection ?? (session?.scope === "global-default" ? void 0 : session?.selection);
|
|
@@ -2756,51 +2886,78 @@ function SessionProfiles(props) {
|
|
|
2756
2886
|
const profiles = state.snapshot?.profiles ?? [];
|
|
2757
2887
|
const currentSaved = profiles.find((profile) => profile.id === current);
|
|
2758
2888
|
const committing = state.sessionBusy !== null;
|
|
2759
|
-
const disabled = committing || state.busy !== null || state.pendingEditor !== null || state.dirty || state.invalidFields.length > 0 || session === null || !session.switchAllowed || state.snapshot === null;
|
|
2889
|
+
const disabled = id2 === null || committing || state.busy !== null || state.pendingEditor !== null || state.dirty || state.invalidFields.length > 0 || session === null || !session.switchAllowed || state.snapshot === null;
|
|
2760
2890
|
let feedback = "";
|
|
2761
|
-
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" : "
|
|
2762
|
-
else if (committing) feedback = t(state.sessionBusy === "
|
|
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");
|
|
2892
|
+
else if (committing || state.busy !== null) feedback = t(state.sessionBusy === "apply" || state.sessionBusy === "reset" ? "headerApplying" : "headerLoading");
|
|
2763
2893
|
else if (state.dirty || state.invalidFields.length > 0 || state.pendingEditor !== null) feedback = t("headerDraft");
|
|
2894
|
+
else if (id2 === null) feedback = t("headerNoSession");
|
|
2764
2895
|
else if (session === null || state.snapshot === null) feedback = t("headerUnavailable");
|
|
2765
2896
|
else if (!session.switchAllowed) feedback = t("headerBusy");
|
|
2766
|
-
else if (state.sessionNotice !== null) feedback = t(state.sessionNotice === "applied-with-model" ? "headerAppliedWithModel" : "headerApplied");
|
|
2767
|
-
const
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
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");
|
|
2898
|
+
const profileName = unknownCaptured ? t("headerCaptured") : currentSaved?.label === void 0 ? admission?.selectedId ?? t("sessionBaseline") : `${currentSaved.label} (${currentSaved.id})`;
|
|
2899
|
+
const currentLabel = t("headerCurrentProfile", { profile: session === null ? t("headerUnavailable") : profileName });
|
|
2900
|
+
const entries = [{ type: "label", id: "@current", text: currentLabel }];
|
|
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") }) });
|
|
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
|
+
});
|
|
2909
|
+
const diagnostic = state.sessionIssue === null ? null : menuIssue(state.sessionIssue);
|
|
2910
|
+
const diagnosticText = diagnostic === null ? "" : t("headerIssueCode", { code: diagnostic.code }) + (diagnostic.field === void 0 ? "" : ` ${t("headerIssueField", { field: diagnostic.field })}`);
|
|
2911
|
+
const retryHint = t(diagnostic?.code === "maintenance" || diagnostic?.code === "busy" ? "headerWaitRetryHint" : "headerRetryHint");
|
|
2912
|
+
if (diagnostic !== null) entries.push({ type: "label", id: "@diagnostic", text: diagnosticText }, { type: "label", id: "@retry", text: retryHint });
|
|
2913
|
+
if (admission?.selectedId != null && currentSaved === void 0) entries.push({ id: admission.selectedId, label: `${admission.selectedId} — ${t("headerSavedUnavailable")}`, disabled: true });
|
|
2914
|
+
if (unknownCaptured) entries.push({ id: "__dsmm_captured_default__", label: t("headerCaptured"), disabled: true });
|
|
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 });
|
|
2918
|
+
const open = openFor === id2;
|
|
2919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsmm-header-profiles", "data-dsmm-header-profile": true, "aria-busy": committing, children: [
|
|
2920
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2921
|
+
import_dsh_client_ui_primitives2.Menu,
|
|
2922
|
+
{
|
|
2923
|
+
open,
|
|
2924
|
+
autoFocus: true,
|
|
2925
|
+
portal: true,
|
|
2926
|
+
align: "start",
|
|
2927
|
+
className: "dsmm-profile-anchor",
|
|
2928
|
+
listClassName: "dsmm-profile-menu",
|
|
2929
|
+
items: entries,
|
|
2930
|
+
selectedId: current,
|
|
2931
|
+
footer: [{ id: "@refresh", label: t("headerCompactRefresh"), disabled: committing || state.busy !== null }],
|
|
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) }),
|
|
2933
|
+
onClose: () => setOpenFor(void 0),
|
|
2934
|
+
onSelect: (value) => {
|
|
2935
|
+
if (props.readProfileView().currentSessionId !== id2) return;
|
|
2936
|
+
if (value === "@refresh") {
|
|
2937
|
+
if (committing || state.busy !== null) return;
|
|
2938
|
+
void (async () => {
|
|
2939
|
+
await props.refresh();
|
|
2940
|
+
if (id2 !== null && props.readProfileView().currentSessionId === id2) await props.refreshSession();
|
|
2941
|
+
})();
|
|
2942
|
+
} else {
|
|
2943
|
+
const row = entries.find((entry) => entry.id === value && !("type" in entry));
|
|
2944
|
+
if (row === void 0 || !("disabled" in row) || row.disabled) return;
|
|
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
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
setOpenFor(void 0);
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
),
|
|
2957
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsmm-profile-announcement", id: `${prefix}-feedback`, role: state.sessionIssue === null ? "status" : "alert", "aria-live": "polite", "aria-atomic": "true", children: [
|
|
2958
|
+
feedback || currentLabel,
|
|
2959
|
+
diagnostic === null ? "" : ` ${diagnosticText} ${retryHint}`
|
|
2960
|
+
] })
|
|
2804
2961
|
] });
|
|
2805
2962
|
}
|
|
2806
2963
|
|
|
@@ -2967,9 +3124,14 @@ var PROFILE_STYLES = `
|
|
|
2967
3124
|
.dsmm-profiles summary{cursor:pointer;color:var(--dsw-alias-label-primary);min-height:32px;line-height:32px}
|
|
2968
3125
|
.dsmm-profiles summary:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
|
2969
3126
|
.dsmm-profiles .dsmm-advanced[open]>div{margin-top:8px}
|
|
2970
|
-
.dsmm-
|
|
2971
|
-
.dsmm-profiles.dsmm-
|
|
2972
|
-
.dsmm-
|
|
3127
|
+
.dsmm-header-profiles{display:inline-flex;align-items:center;min-width:0;font-family:var(--dsw-font-family);color:var(--dsw-alias-label-primary)}
|
|
3128
|
+
.dsmm-header-profiles .dsmm-profile-trigger{width:28px;height:28px;min-height:28px;padding:6px;justify-content:center}
|
|
3129
|
+
.dsmm-profile-trigger:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
|
3130
|
+
.dsmm-profile-menu{font-family:var(--dsw-font-family);font-size:14px;line-height:22px;max-width:calc(100vw - 24px);color:var(--dsw-alias-label-primary)}
|
|
3131
|
+
.dsmm-profile-menu [role=presentation]{font:inherit;white-space:normal;overflow-wrap:anywhere;color:var(--dsw-alias-label-secondary)}
|
|
3132
|
+
.dsmm-profile-menu [role=menuitem]{font:inherit}
|
|
3133
|
+
.dsmm-profile-menu [role=menuitem]>span{white-space:normal;overflow-wrap:anywhere}
|
|
3134
|
+
.dsmm-profile-announcement{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
|
|
2973
3135
|
.dsmm-profiles p{margin:0;overflow-wrap:anywhere}
|
|
2974
3136
|
.dsmm-profiles .dsmm-hint{color:var(--dsw-alias-label-secondary)}
|
|
2975
3137
|
.dsmm-profiles .dsmm-field{min-width:0;display:flex;flex-direction:column;gap:6px}
|
|
@@ -3015,6 +3177,12 @@ async function apply(ctx) {
|
|
|
3015
3177
|
locale: NS,
|
|
3016
3178
|
inject: () => ({ hooks: { profiles: controller.store }, ...controller.actions })
|
|
3017
3179
|
}, ProfilesSection));
|
|
3180
|
+
profileCtx.slots.inject("conversation.header.leading", () => profileCtx.slots.register({
|
|
3181
|
+
name: "conversation.header.leading",
|
|
3182
|
+
priority: Number.MAX_SAFE_INTEGER,
|
|
3183
|
+
locale: NS,
|
|
3184
|
+
inject: () => ({ hooks: { profiles: controller.store }, readProfileView: controller.store.getSnapshot, ...controller.actions })
|
|
3185
|
+
}, SessionProfiles));
|
|
3018
3186
|
void profileCtx.inject(["remote.session"], (catalogCtx) => {
|
|
3019
3187
|
controller.attachCatalog(catalogCtx.remote.session);
|
|
3020
3188
|
controller.attachModelSelector(catalogCtx.remote.session);
|
|
@@ -3057,13 +3225,6 @@ async function apply(ctx) {
|
|
|
3057
3225
|
modelCtx.effect(() => source.subscribe(updateInteraction), "dsmm: native model interaction binding");
|
|
3058
3226
|
modelCtx.effect(() => () => controller.attachModelInteractionSource(null, null), "dsmm: native model interaction withdrawal");
|
|
3059
3227
|
});
|
|
3060
|
-
sessionCtx.slots.inject("conversation.session.header.utilities", () => sessionCtx.slots.register({
|
|
3061
|
-
name: "conversation.session.header.utilities",
|
|
3062
|
-
id: "dsmm-session-profiles",
|
|
3063
|
-
order: 30,
|
|
3064
|
-
locale: NS,
|
|
3065
|
-
inject: () => ({ hooks: { profiles: controller.store }, ...controller.actions })
|
|
3066
|
-
}, SessionProfiles));
|
|
3067
3228
|
});
|
|
3068
3229
|
void controller.refresh();
|
|
3069
3230
|
});
|
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) }),
|