@dsmm/dsmm 0.1.4 → 0.1.5
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 -12
- package/docs/compatibility.md +8 -6
- package/docs/migration-from-ocmm.md +8 -0
- package/docs/model-routing.md +19 -5
- package/docs/profiles.md +21 -9
- package/docs/releasing.md +23 -15
- package/docs/runtime-recovery.md +39 -14
- package/docs/settings-status.md +7 -7
- package/lib/client/ProfilesSection.js +7 -3
- package/lib/client/SessionProfiles.d.ts +19 -0
- package/lib/client/SessionProfiles.js +24 -0
- package/lib/client/StructuredEditor.d.ts +11 -0
- package/lib/client/StructuredEditor.js +74 -0
- package/lib/client/controller.d.ts +38 -0
- package/lib/client/controller.js +153 -11
- package/lib/client/index.d.ts +2 -0
- package/lib/client/index.js +20 -0
- package/lib/client/locales.d.ts +89 -0
- package/lib/client/locales.js +45 -2
- package/lib/client/session-labels.d.ts +8 -0
- package/lib/client/session-labels.js +13 -0
- package/lib/client/structured.d.ts +18 -0
- package/lib/client/structured.js +98 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +12 -1
- package/lib/client.js +969 -74
- package/lib/commands.js +1 -0
- package/lib/dsh-types.d.ts +16 -0
- package/lib/index.js +27 -1
- package/lib/model-routing.js +93 -23
- package/lib/profile-remote.d.ts +7 -1
- package/lib/profile-remote.js +115 -2
- package/lib/profile-rpc.d.ts +9 -1
- package/lib/profile-rpc.js +99 -2
- package/lib/profile-runtime.d.ts +24 -5
- package/lib/profile-runtime.js +182 -31
- package/lib/profile-store.d.ts +19 -1
- package/lib/profile-store.js +120 -10
- package/lib/profile-types.d.ts +41 -1
- package/lib/profiles.d.ts +1 -1
- package/lib/profiles.js +34 -2
- package/lib/role-providers.js +12 -2
- package/lib/role-routing.d.ts +37 -3
- package/lib/role-routing.js +107 -35
- package/lib/routing-policy.d.ts +32 -0
- package/lib/routing-policy.js +92 -0
- package/lib/runtime-recovery.js +213 -52
- package/lib/settings.d.ts +27 -1
- package/lib/settings.js +29 -7
- package/lib/status.d.ts +9 -1
- package/lib/status.js +29 -8
- package/package.json +5 -1
package/lib/client.js
CHANGED
|
@@ -25,18 +25,70 @@ __export(index_exports, {
|
|
|
25
25
|
NS: () => NS,
|
|
26
26
|
ProfilesController: () => ProfilesController,
|
|
27
27
|
ProfilesSection: () => ProfilesSection,
|
|
28
|
+
SessionProfiles: () => SessionProfiles,
|
|
28
29
|
TYPERT_REMOTE: () => TYPERT_REMOTE,
|
|
29
30
|
apply: () => apply,
|
|
31
|
+
editStructuredPath: () => editStructuredPath,
|
|
30
32
|
en: () => en,
|
|
31
33
|
inject: () => inject,
|
|
34
|
+
moveFallback: () => moveFallback,
|
|
35
|
+
structuredDocument: () => structuredDocument,
|
|
32
36
|
zh: () => zh
|
|
33
37
|
});
|
|
34
38
|
module.exports = __toCommonJS(index_exports);
|
|
35
39
|
|
|
40
|
+
// src/routing-policy.ts
|
|
41
|
+
var DEFAULT_DSMM_RATE_LIMIT_POLICY = Object.freeze({
|
|
42
|
+
maxRetries: 3,
|
|
43
|
+
initialDelayMs: 500,
|
|
44
|
+
maxDelayMs: 1e4,
|
|
45
|
+
maxTotalDelayMs: 3e4,
|
|
46
|
+
switchAfterRateLimits: 3,
|
|
47
|
+
maxSwitches: 2
|
|
48
|
+
});
|
|
49
|
+
var DEFAULT_DSMM_RUNTIME_POLICY = Object.freeze({
|
|
50
|
+
strategy: "startup-lock",
|
|
51
|
+
rateLimit: DEFAULT_DSMM_RATE_LIMIT_POLICY
|
|
52
|
+
});
|
|
53
|
+
var DSMM_RATE_LIMIT_BOUNDS = Object.freeze({
|
|
54
|
+
maxRetries: Object.freeze([0, 10]),
|
|
55
|
+
initialDelayMs: Object.freeze([0, 3e4]),
|
|
56
|
+
maxDelayMs: Object.freeze([0, 3e4]),
|
|
57
|
+
maxTotalDelayMs: Object.freeze([0, 12e4]),
|
|
58
|
+
switchAfterRateLimits: Object.freeze([1, 10]),
|
|
59
|
+
maxSwitches: Object.freeze([0, 10])
|
|
60
|
+
});
|
|
61
|
+
function normalizeRoutingStrategy(value) {
|
|
62
|
+
if (value !== "startup-lock" && value !== "rate-limit-fallback") {
|
|
63
|
+
throw new TypeError("dsmm strategy must be startup-lock or rate-limit-fallback");
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
function normalizeRateLimitOverrides(value) {
|
|
68
|
+
if (!isRecord(value)) throw new TypeError("dsmm rateLimit must be an object");
|
|
69
|
+
const result = {};
|
|
70
|
+
for (const [field, raw] of Object.entries(value)) {
|
|
71
|
+
if (!Object.hasOwn(DSMM_RATE_LIMIT_BOUNDS, field)) throw new TypeError("dsmm rateLimit contains an unknown field");
|
|
72
|
+
const [minimum, maximum] = DSMM_RATE_LIMIT_BOUNDS[field];
|
|
73
|
+
if (typeof raw !== "number" || !Number.isSafeInteger(raw) || raw < minimum || raw > maximum) {
|
|
74
|
+
throw new TypeError(`dsmm rateLimit ${field} must be an integer from ${minimum} to ${maximum}`);
|
|
75
|
+
}
|
|
76
|
+
result[field] = raw;
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
function normalizeRateLimitPolicy(value = void 0, defaults = DEFAULT_DSMM_RATE_LIMIT_POLICY) {
|
|
81
|
+
return { ...defaults, ...value === void 0 ? {} : normalizeRateLimitOverrides(value) };
|
|
82
|
+
}
|
|
83
|
+
function isRecord(value) {
|
|
84
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
85
|
+
}
|
|
86
|
+
|
|
36
87
|
// src/profile-remote.ts
|
|
37
|
-
var errorCodes = /* @__PURE__ */ new Set(["validation", "conflict", "not-found", "lock-timeout", "unsafe-path", "io", "activation", "corrupt-selection", "limit"]);
|
|
88
|
+
var errorCodes = /* @__PURE__ */ new Set(["validation", "conflict", "not-found", "lock-timeout", "unsafe-path", "io", "activation", "corrupt-selection", "limit", "busy", "maintenance", "disposed", "not-owned", "unavailable", "cancelled"]);
|
|
38
89
|
var idPattern = /^[a-z0-9][a-z0-9_-]{0,63}$/u;
|
|
39
90
|
var revisionPattern = /^[a-f0-9]{64}$/u;
|
|
91
|
+
var rolePattern = /^dsmm-(?:orchestrator|planner|plan-critic|builder|reviewer|oracle|oracle-2nd|creative|code-search|doc-search|clarifier|media-reader)$/u;
|
|
40
92
|
function isProfileId(value) {
|
|
41
93
|
return typeof value === "string" && idPattern.test(value) && !/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])$/iu.test(value);
|
|
42
94
|
}
|
|
@@ -60,14 +112,38 @@ function revision(value) {
|
|
|
60
112
|
function selectionRevision(value) {
|
|
61
113
|
return value === "absent" ? value : revision(value);
|
|
62
114
|
}
|
|
115
|
+
function isNativeSessionId(value) {
|
|
116
|
+
return typeof value === "string" && value.length > 0 && value.length <= 256 && !/[\u0000-\u001f\u007f]/u.test(value) && new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(new TextEncoder().encode(value)) === value;
|
|
117
|
+
}
|
|
118
|
+
function sessionId(value) {
|
|
119
|
+
if (!isNativeSessionId(value)) fail("sessionId");
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
function boolean(value, field) {
|
|
123
|
+
if (typeof value !== "boolean") fail(field);
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
function integer(value, field, maximum = Number.MAX_SAFE_INTEGER) {
|
|
127
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0 || value > maximum) fail(field);
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
function routeText(value, field, maximum) {
|
|
131
|
+
const result = text(value, field, maximum);
|
|
132
|
+
if (result.trim() === "" || /[\u0000-\u001f\u007f]/u.test(result) || new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(new TextEncoder().encode(result)) !== result) fail(field);
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
function role(value) {
|
|
136
|
+
if (typeof value !== "string" || !rolePattern.test(value)) fail("role");
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
63
139
|
function object(value, required, optional2 = []) {
|
|
64
140
|
if (value === null || typeof value !== "object" || Array.isArray(value)) fail("object");
|
|
65
141
|
const result = value;
|
|
66
142
|
if (Object.keys(result).some((key) => !required.includes(key) && !optional2.includes(key)) || required.some((key) => !Object.hasOwn(result, key))) fail("object keys");
|
|
67
143
|
return result;
|
|
68
144
|
}
|
|
69
|
-
function optional(value, key,
|
|
70
|
-
return Object.hasOwn(value, key) ? { [key]:
|
|
145
|
+
function optional(value, key, parse3) {
|
|
146
|
+
return Object.hasOwn(value, key) ? { [key]: parse3(value[key]) } : {};
|
|
71
147
|
}
|
|
72
148
|
function errorInfo(value) {
|
|
73
149
|
const item = object(value, ["code", "message"], ["field"]);
|
|
@@ -85,7 +161,7 @@ function content(value) {
|
|
|
85
161
|
return result;
|
|
86
162
|
}
|
|
87
163
|
function snapshot(value) {
|
|
88
|
-
const item = object(value, ["profiles", "selectedId", "appliedRevision", "selectionRevision"], ["selectionError"]);
|
|
164
|
+
const item = object(value, ["profiles", "selectedId", "appliedRevision", "selectionRevision"], ["selectionError", "roles", "editorDefaults"]);
|
|
89
165
|
if (!Array.isArray(item.profiles) || item.profiles.length > 128) fail("profiles");
|
|
90
166
|
return {
|
|
91
167
|
profiles: item.profiles.map((input) => {
|
|
@@ -95,7 +171,68 @@ function snapshot(value) {
|
|
|
95
171
|
selectedId: item.selectedId === null ? null : id(item.selectedId),
|
|
96
172
|
appliedRevision: item.appliedRevision === null ? null : revision(item.appliedRevision),
|
|
97
173
|
selectionRevision: item.selectionRevision === "unavailable" && Object.hasOwn(item, "selectionError") ? "unavailable" : selectionRevision(item.selectionRevision),
|
|
98
|
-
...optional(item, "selectionError", errorInfo)
|
|
174
|
+
...optional(item, "selectionError", errorInfo),
|
|
175
|
+
...optional(item, "roles", (input) => {
|
|
176
|
+
if (!Array.isArray(input) || input.length > 12) fail("roles");
|
|
177
|
+
const result = input.map((value2) => {
|
|
178
|
+
const row = object(value2, ["id", "label", "enabled"], ["runtimePolicy"]);
|
|
179
|
+
return { id: role(row.id), label: text(row.label, "label", 120), enabled: boolean(row.enabled, "enabled"), ...optional(row, "runtimePolicy", (input2) => {
|
|
180
|
+
const policy = object(input2, [], ["strategy", "rateLimit"]);
|
|
181
|
+
return { ...optional(policy, "strategy", normalizeRoutingStrategy), ...optional(policy, "rateLimit", normalizeRateLimitOverrides) };
|
|
182
|
+
}) };
|
|
183
|
+
});
|
|
184
|
+
if (new Set(result.map((row) => row.id)).size !== result.length) fail("roles");
|
|
185
|
+
return result;
|
|
186
|
+
}),
|
|
187
|
+
...optional(item, "editorDefaults", runtimePolicy)
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function rateLimit(value) {
|
|
191
|
+
const item = object(value, Object.keys(DSMM_RATE_LIMIT_BOUNDS));
|
|
192
|
+
return normalizeRateLimitPolicy(item);
|
|
193
|
+
}
|
|
194
|
+
function runtimePolicy(value) {
|
|
195
|
+
const item = object(value, ["strategy", "rateLimit"]);
|
|
196
|
+
return { strategy: normalizeRoutingStrategy(item.strategy), rateLimit: rateLimit(item.rateLimit) };
|
|
197
|
+
}
|
|
198
|
+
function rolePolicy(value) {
|
|
199
|
+
const item = object(value, ["strategy", "rateLimit", "retries", "rateLimitFailures", "switches", "totalDelayMs"], ["role", "route"]);
|
|
200
|
+
return {
|
|
201
|
+
...runtimePolicy({ strategy: item.strategy, rateLimit: item.rateLimit }),
|
|
202
|
+
retries: integer(item.retries, "retries", 10),
|
|
203
|
+
rateLimitFailures: integer(item.rateLimitFailures, "rateLimitFailures"),
|
|
204
|
+
switches: integer(item.switches, "switches", 10),
|
|
205
|
+
totalDelayMs: integer(item.totalDelayMs, "totalDelayMs", 12e4),
|
|
206
|
+
...optional(item, "role", role),
|
|
207
|
+
...optional(item, "route", (input) => {
|
|
208
|
+
const route2 = object(input, ["provider", "model"], ["reasoningEffort"]);
|
|
209
|
+
const provider = routeText(route2.provider, "provider", 128);
|
|
210
|
+
const model = routeText(route2.model, "model", 512);
|
|
211
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9_.:-]*$/u.test(provider) || model.includes("://")) fail("route");
|
|
212
|
+
return { provider, model, ...optional(route2, "reasoningEffort", (value2) => routeText(value2, "reasoningEffort", 64)) };
|
|
213
|
+
})
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function selectionState(value) {
|
|
217
|
+
const item = object(value, ["selectedId", "appliedRevision", "selectionRevision"]);
|
|
218
|
+
return { selectedId: item.selectedId === null ? null : id(item.selectedId), appliedRevision: item.appliedRevision === null ? null : revision(item.appliedRevision), selectionRevision: selectionRevision(item.selectionRevision) };
|
|
219
|
+
}
|
|
220
|
+
function sessionSnapshot(value) {
|
|
221
|
+
const item = object(value, ["sessionId", "globalDefault", "selection", "scope", "admissionEpoch", "switchAllowed"], ["admittedSelection", "switchUnavailableReason", "rolePolicy"]);
|
|
222
|
+
if (typeof item.scope !== "string" || !["global-default", "session-override", "deployment-baseline"].includes(item.scope)) fail("scope");
|
|
223
|
+
return {
|
|
224
|
+
sessionId: sessionId(item.sessionId),
|
|
225
|
+
globalDefault: selectionState(item.globalDefault),
|
|
226
|
+
selection: selectionState(item.selection),
|
|
227
|
+
scope: item.scope,
|
|
228
|
+
admissionEpoch: revision(item.admissionEpoch),
|
|
229
|
+
switchAllowed: boolean(item.switchAllowed, "switchAllowed"),
|
|
230
|
+
...optional(item, "admittedSelection", selectionState),
|
|
231
|
+
...optional(item, "switchUnavailableReason", (input) => {
|
|
232
|
+
if (typeof input !== "string" || !["busy", "maintenance", "disposed", "not-owned", "unavailable"].includes(input)) fail("switchUnavailableReason");
|
|
233
|
+
return input;
|
|
234
|
+
}),
|
|
235
|
+
...optional(item, "rolePolicy", rolePolicy)
|
|
99
236
|
};
|
|
100
237
|
}
|
|
101
238
|
function saveRequest(value) {
|
|
@@ -109,8 +246,13 @@ function selectRequest(value) {
|
|
|
109
246
|
if (result.id === null && result.expectedRevision !== void 0) fail("expectedRevision");
|
|
110
247
|
return result;
|
|
111
248
|
}
|
|
112
|
-
function
|
|
113
|
-
|
|
249
|
+
function sessionSelectRequest(value) {
|
|
250
|
+
const item = object(value, ["sessionId", "id", "expectedSelectionRevision", "expectedAdmissionEpoch"], ["expectedRevision"]);
|
|
251
|
+
const { sessionId: inputSessionId, expectedAdmissionEpoch, ...profileRequest } = item;
|
|
252
|
+
return { ...selectRequest(profileRequest), sessionId: sessionId(inputSessionId), expectedAdmissionEpoch: revision(expectedAdmissionEpoch) };
|
|
253
|
+
}
|
|
254
|
+
function codec(symbol, parse3) {
|
|
255
|
+
return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse: parse3 }) };
|
|
114
256
|
}
|
|
115
257
|
function descriptor(method, result, parameter) {
|
|
116
258
|
return { id: `@dsmm/dsmm#dsmmProfiles/${method}`, service: "dsmmProfiles", namespace: "dsmmProfiles", method, invocation: { kind: "direct" }, parameters: parameter === void 0 ? [] : [{ name: parameter.name, wire: parameter.name, source: "json", codec: parameter.codec }], result };
|
|
@@ -121,7 +263,18 @@ var TYPERT_REMOTE = {
|
|
|
121
263
|
descriptor("describe", codec("ProfileSnapshot", snapshot)),
|
|
122
264
|
descriptor("read", codec("ProfileReadResult", readResult), { name: "id", codec: codec("ProfileId", id) }),
|
|
123
265
|
descriptor("save", codec("ProfileReadResult", readResult), { name: "request", codec: codec("ProfileSaveRequest", saveRequest) }),
|
|
124
|
-
descriptor("select", codec("ProfileSnapshot", snapshot), { name: "request", codec: codec("ProfileSelectRequest", selectRequest) })
|
|
266
|
+
descriptor("select", codec("ProfileSnapshot", snapshot), { name: "request", codec: codec("ProfileSelectRequest", selectRequest) }),
|
|
267
|
+
{
|
|
268
|
+
...descriptor("describeSession", codec("SessionProfileSnapshot", sessionSnapshot)),
|
|
269
|
+
parameters: [{ name: "sessionId", wire: "sessionId", source: "json", codec: codec("NativeSessionId", sessionId) }]
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
...descriptor("selectSession", codec("SessionProfileSnapshot", sessionSnapshot)),
|
|
273
|
+
parameters: [
|
|
274
|
+
{ name: "sessionId", wire: "sessionId", source: "json", codec: codec("NativeSessionId", sessionId) },
|
|
275
|
+
{ name: "request", wire: "request", source: "json", codec: codec("SessionProfileSelectRequest", sessionSelectRequest) }
|
|
276
|
+
]
|
|
277
|
+
}
|
|
125
278
|
]
|
|
126
279
|
};
|
|
127
280
|
var TYPERT_HOST = {
|
|
@@ -827,6 +980,49 @@ var ParseOptions;
|
|
|
827
980
|
allowTrailingComma: false
|
|
828
981
|
};
|
|
829
982
|
})(ParseOptions || (ParseOptions = {}));
|
|
983
|
+
function parse(text2, errors = [], options = ParseOptions.DEFAULT) {
|
|
984
|
+
let currentProperty = null;
|
|
985
|
+
let currentParent = [];
|
|
986
|
+
const previousParents = [];
|
|
987
|
+
function onValue(value) {
|
|
988
|
+
if (Array.isArray(currentParent)) {
|
|
989
|
+
currentParent.push(value);
|
|
990
|
+
} else if (currentProperty !== null) {
|
|
991
|
+
currentParent[currentProperty] = value;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
const visitor = {
|
|
995
|
+
onObjectBegin: () => {
|
|
996
|
+
const object2 = {};
|
|
997
|
+
onValue(object2);
|
|
998
|
+
previousParents.push(currentParent);
|
|
999
|
+
currentParent = object2;
|
|
1000
|
+
currentProperty = null;
|
|
1001
|
+
},
|
|
1002
|
+
onObjectProperty: (name) => {
|
|
1003
|
+
currentProperty = name;
|
|
1004
|
+
},
|
|
1005
|
+
onObjectEnd: () => {
|
|
1006
|
+
currentParent = previousParents.pop();
|
|
1007
|
+
},
|
|
1008
|
+
onArrayBegin: () => {
|
|
1009
|
+
const array = [];
|
|
1010
|
+
onValue(array);
|
|
1011
|
+
previousParents.push(currentParent);
|
|
1012
|
+
currentParent = array;
|
|
1013
|
+
currentProperty = null;
|
|
1014
|
+
},
|
|
1015
|
+
onArrayEnd: () => {
|
|
1016
|
+
currentParent = previousParents.pop();
|
|
1017
|
+
},
|
|
1018
|
+
onLiteralValue: onValue,
|
|
1019
|
+
onError: (error, offset, length) => {
|
|
1020
|
+
errors.push({ error, offset, length });
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
visit(text2, visitor, options);
|
|
1024
|
+
return currentParent[0];
|
|
1025
|
+
}
|
|
830
1026
|
function parseTree(text2, errors = [], options = ParseOptions.DEFAULT) {
|
|
831
1027
|
let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: void 0 };
|
|
832
1028
|
function ensurePropertyComplete(endOffset) {
|
|
@@ -1417,6 +1613,9 @@ var SyntaxKind;
|
|
|
1417
1613
|
SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
|
|
1418
1614
|
SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
|
|
1419
1615
|
})(SyntaxKind || (SyntaxKind = {}));
|
|
1616
|
+
var parse2 = parse;
|
|
1617
|
+
var parseTree2 = parseTree;
|
|
1618
|
+
var findNodeAtLocation2 = findNodeAtLocation;
|
|
1420
1619
|
var ParseErrorCode;
|
|
1421
1620
|
(function(ParseErrorCode2) {
|
|
1422
1621
|
ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
|
|
@@ -1460,6 +1659,75 @@ function applyEdits(text2, edits) {
|
|
|
1460
1659
|
return text2;
|
|
1461
1660
|
}
|
|
1462
1661
|
|
|
1662
|
+
// src/client/structured.ts
|
|
1663
|
+
function record(value) {
|
|
1664
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1665
|
+
}
|
|
1666
|
+
function route(value) {
|
|
1667
|
+
return record(value) && typeof value.provider === "string" && typeof value.model === "string" && (value.reasoningEffort === void 0 || typeof value.reasoningEffort === "string") && Object.keys(value).every((key) => ["provider", "model", "reasoningEffort"].includes(key));
|
|
1668
|
+
}
|
|
1669
|
+
function validTree(node, depth = 0) {
|
|
1670
|
+
if (depth > 32) return false;
|
|
1671
|
+
if (node.type === "object") {
|
|
1672
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1673
|
+
for (const property of node.children ?? []) {
|
|
1674
|
+
const key = property.children?.[0]?.value;
|
|
1675
|
+
if (typeof key !== "string" || seen.has(key) || ["__proto__", "prototype", "constructor"].includes(key)) return false;
|
|
1676
|
+
seen.add(key);
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
return (node.children ?? []).every((child) => validTree(child, depth + 1));
|
|
1680
|
+
}
|
|
1681
|
+
function structuredDocument(content2) {
|
|
1682
|
+
const errors = [];
|
|
1683
|
+
const tree = parseTree2(content2, errors, { allowTrailingComma: true });
|
|
1684
|
+
if (errors.length !== 0 || tree === void 0 || !validTree(tree)) return null;
|
|
1685
|
+
const document2 = parse2(content2, errors, { allowTrailingComma: true });
|
|
1686
|
+
if (errors.length !== 0 || !record(document2) || document2.version !== 1 || typeof document2.id !== "string" || !record(document2.settings) || document2.label !== void 0 && typeof document2.label !== "string") return null;
|
|
1687
|
+
const settings = document2.settings;
|
|
1688
|
+
if (settings.defaultActive !== void 0 && typeof settings.defaultActive !== "boolean") return null;
|
|
1689
|
+
if (settings.roleRouting !== void 0 && !record(settings.roleRouting)) return null;
|
|
1690
|
+
if (settings.runtimePolicy !== void 0 && !record(settings.runtimePolicy)) return null;
|
|
1691
|
+
const runtimePolicy2 = settings.runtimePolicy ?? {};
|
|
1692
|
+
const policies = settings.roleRouting ?? {};
|
|
1693
|
+
try {
|
|
1694
|
+
if (Object.keys(runtimePolicy2).some((key) => key !== "strategy" && key !== "rateLimit")) return null;
|
|
1695
|
+
if (runtimePolicy2.strategy !== void 0) normalizeRoutingStrategy(runtimePolicy2.strategy);
|
|
1696
|
+
if (runtimePolicy2.rateLimit !== void 0) normalizeRateLimitOverrides(runtimePolicy2.rateLimit);
|
|
1697
|
+
for (const raw of Object.values(policies)) {
|
|
1698
|
+
if (!record(raw) || Object.keys(raw).some((key) => !["primary", "fallbackRoutes", "strategy", "rateLimit"].includes(key))) return null;
|
|
1699
|
+
if (raw.primary !== void 0 && !route(raw.primary)) return null;
|
|
1700
|
+
if (raw.fallbackRoutes !== void 0 && (!Array.isArray(raw.fallbackRoutes) || raw.fallbackRoutes.length > 32 || !raw.fallbackRoutes.every(route))) return null;
|
|
1701
|
+
if (raw.strategy !== void 0) normalizeRoutingStrategy(raw.strategy);
|
|
1702
|
+
if (raw.rateLimit !== void 0) normalizeRateLimitOverrides(raw.rateLimit);
|
|
1703
|
+
}
|
|
1704
|
+
} catch {
|
|
1705
|
+
return null;
|
|
1706
|
+
}
|
|
1707
|
+
return { label: document2.label, settings, roleRouting: policies, runtimePolicy: runtimePolicy2 };
|
|
1708
|
+
}
|
|
1709
|
+
function editStructuredPath(content2, path, value) {
|
|
1710
|
+
if (structuredDocument(content2) === null) return null;
|
|
1711
|
+
try {
|
|
1712
|
+
return applyEdits(content2, modify(content2, path, value, { formattingOptions: { insertSpaces: true, tabSize: 2 } }));
|
|
1713
|
+
} catch {
|
|
1714
|
+
return null;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
function moveFallback(content2, role2, from, to) {
|
|
1718
|
+
const document2 = structuredDocument(content2);
|
|
1719
|
+
const chain = document2?.roleRouting[role2]?.fallbackRoutes;
|
|
1720
|
+
if (chain === void 0 || from < 0 || from >= chain.length || to < 0 || to >= chain.length) return null;
|
|
1721
|
+
const low = Math.min(from, to), high = Math.max(from, to);
|
|
1722
|
+
const tree = parseTree2(content2);
|
|
1723
|
+
if (tree === void 0) return null;
|
|
1724
|
+
const nodes = chain.map((_, index) => findNodeAtLocation2(tree, ["settings", "roleRouting", role2, "fallbackRoutes", index]));
|
|
1725
|
+
if (nodes.some((node) => node === void 0)) return null;
|
|
1726
|
+
const order = nodes.map((node) => content2.slice(node.offset, node.offset + node.length));
|
|
1727
|
+
order.splice(to, 0, order.splice(from, 1)[0]);
|
|
1728
|
+
return applyEdits(content2, nodes.slice(low, high + 1).map((node, offset) => ({ offset: node.offset, length: node.length, content: order[low + offset] })));
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1463
1731
|
// src/client/controller.ts
|
|
1464
1732
|
var NEW_EDITOR = "";
|
|
1465
1733
|
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';
|
|
@@ -1470,11 +1738,33 @@ var ProfilesController = class {
|
|
|
1470
1738
|
constructor(remote) {
|
|
1471
1739
|
this.remote = remote;
|
|
1472
1740
|
}
|
|
1473
|
-
current = {
|
|
1741
|
+
current = {
|
|
1742
|
+
snapshot: null,
|
|
1743
|
+
editor: null,
|
|
1744
|
+
dirty: false,
|
|
1745
|
+
busy: null,
|
|
1746
|
+
issue: null,
|
|
1747
|
+
notice: null,
|
|
1748
|
+
pendingEditor: null,
|
|
1749
|
+
catalog: null,
|
|
1750
|
+
catalogBusy: false,
|
|
1751
|
+
catalogUnavailable: true,
|
|
1752
|
+
currentSessionId: null,
|
|
1753
|
+
session: null,
|
|
1754
|
+
sessionChoice: null,
|
|
1755
|
+
sessionBusy: null,
|
|
1756
|
+
sessionIssue: null,
|
|
1757
|
+
sessionNotice: null,
|
|
1758
|
+
invalidFields: [],
|
|
1759
|
+
editorEpoch: 0
|
|
1760
|
+
};
|
|
1474
1761
|
accepted = null;
|
|
1475
1762
|
listeners = /* @__PURE__ */ new Set();
|
|
1476
1763
|
generation = 0;
|
|
1477
1764
|
disposed = false;
|
|
1765
|
+
sessionGeneration = 0;
|
|
1766
|
+
catalogGeneration = 0;
|
|
1767
|
+
catalogRemote = null;
|
|
1478
1768
|
store = {
|
|
1479
1769
|
getSnapshot: () => this.current,
|
|
1480
1770
|
subscribe: (listener) => {
|
|
@@ -1495,13 +1785,99 @@ var ProfilesController = class {
|
|
|
1495
1785
|
apply: () => this.apply(),
|
|
1496
1786
|
reset: () => this.reset(),
|
|
1497
1787
|
discardAndOpen: () => this.discardAndOpen(),
|
|
1498
|
-
cancelDiscard: () => this.publish({ pendingEditor: null })
|
|
1788
|
+
cancelDiscard: () => this.publish({ pendingEditor: null }),
|
|
1789
|
+
editPath: (path, value) => this.editPath(path, value),
|
|
1790
|
+
moveFallback: (role2, from, to) => this.editFallbackOrder(role2, from, to),
|
|
1791
|
+
editRoute: (path, provider, model) => this.editRoute(path, provider, model),
|
|
1792
|
+
refreshCatalog: () => this.refreshCatalog(),
|
|
1793
|
+
refreshSession: () => this.refreshSession(),
|
|
1794
|
+
chooseSessionProfile: (id2) => {
|
|
1795
|
+
if (!this.disposed && this.current.sessionBusy === null && this.current.busy === null && !this.current.dirty) this.publish({ sessionChoice: id2, sessionNotice: null });
|
|
1796
|
+
},
|
|
1797
|
+
applySession: () => this.selectSession(false),
|
|
1798
|
+
resetSession: () => this.selectSession(true),
|
|
1799
|
+
setFieldInvalid: (field, invalid) => {
|
|
1800
|
+
if (this.disposed) return;
|
|
1801
|
+
const invalidFields = this.current.invalidFields.filter((candidate) => candidate !== field);
|
|
1802
|
+
if (invalid) invalidFields.push(field);
|
|
1803
|
+
if (invalidFields.join("\n") !== this.current.invalidFields.join("\n")) this.publish({ invalidFields, ...invalid ? { dirty: true } : {} });
|
|
1804
|
+
}
|
|
1499
1805
|
};
|
|
1500
1806
|
dispose() {
|
|
1501
1807
|
this.disposed = true;
|
|
1502
1808
|
this.generation += 1;
|
|
1809
|
+
this.sessionGeneration += 1;
|
|
1810
|
+
this.catalogGeneration += 1;
|
|
1811
|
+
this.catalogRemote = null;
|
|
1503
1812
|
this.listeners.clear();
|
|
1504
1813
|
}
|
|
1814
|
+
attachCatalog(remote) {
|
|
1815
|
+
if (this.disposed) return;
|
|
1816
|
+
this.catalogGeneration += 1;
|
|
1817
|
+
this.catalogRemote = remote;
|
|
1818
|
+
this.publish({ catalogBusy: false, catalogUnavailable: remote === null });
|
|
1819
|
+
if (remote !== null) void this.refreshCatalog();
|
|
1820
|
+
}
|
|
1821
|
+
setSession(id2) {
|
|
1822
|
+
if (this.disposed || id2 === this.current.currentSessionId) return;
|
|
1823
|
+
this.sessionGeneration += 1;
|
|
1824
|
+
this.publish({ currentSessionId: id2, session: null, sessionChoice: null, sessionBusy: null, sessionIssue: null, sessionNotice: null });
|
|
1825
|
+
if (id2 !== null) void this.refreshSession();
|
|
1826
|
+
}
|
|
1827
|
+
async refreshCatalog() {
|
|
1828
|
+
if (this.disposed || this.current.catalogBusy || this.catalogRemote === null) return;
|
|
1829
|
+
const remote = this.catalogRemote, generation = ++this.catalogGeneration;
|
|
1830
|
+
this.publish({ catalogBusy: true });
|
|
1831
|
+
try {
|
|
1832
|
+
const catalog = await this.unwrap(remote.modelCatalog());
|
|
1833
|
+
if (!this.disposed && generation === this.catalogGeneration) this.publish({ catalog, catalogUnavailable: false });
|
|
1834
|
+
} catch {
|
|
1835
|
+
if (!this.disposed && generation === this.catalogGeneration) this.publish({ catalogUnavailable: true });
|
|
1836
|
+
} finally {
|
|
1837
|
+
if (!this.disposed && generation === this.catalogGeneration) this.publish({ catalogBusy: false });
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
async refreshSession() {
|
|
1841
|
+
const id2 = this.current.currentSessionId;
|
|
1842
|
+
if (this.disposed || id2 === null || this.current.sessionBusy !== null) return;
|
|
1843
|
+
const generation = ++this.sessionGeneration;
|
|
1844
|
+
const live = () => !this.disposed && generation === this.sessionGeneration && id2 === this.current.currentSessionId;
|
|
1845
|
+
this.publish({ sessionBusy: "read", sessionIssue: null, sessionNotice: null });
|
|
1846
|
+
try {
|
|
1847
|
+
const session = await this.unwrap(this.remote.describeSession(id2));
|
|
1848
|
+
if (session.sessionId !== id2) throw { kind: "assembly", code: "unavailable" };
|
|
1849
|
+
if (live()) this.publish({ session, sessionChoice: session.selection.selectedId });
|
|
1850
|
+
} catch (error) {
|
|
1851
|
+
if (live()) this.publish({ sessionIssue: this.issue(error) });
|
|
1852
|
+
} finally {
|
|
1853
|
+
if (live()) this.publish({ sessionBusy: null });
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
async selectSession(reset) {
|
|
1857
|
+
const { currentSessionId: id2, session, sessionChoice, snapshot: snapshot2 } = this.current;
|
|
1858
|
+
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;
|
|
1859
|
+
const selectedId = reset ? null : sessionChoice;
|
|
1860
|
+
const revision2 = snapshot2?.profiles.find((profile) => profile.id === selectedId)?.revision;
|
|
1861
|
+
if (selectedId !== null && revision2 == null) return;
|
|
1862
|
+
const generation = ++this.sessionGeneration;
|
|
1863
|
+
const live = () => !this.disposed && generation === this.sessionGeneration && id2 === this.current.currentSessionId;
|
|
1864
|
+
this.publish({ sessionBusy: reset ? "reset" : "apply", sessionIssue: null, sessionNotice: null });
|
|
1865
|
+
try {
|
|
1866
|
+
const accepted = await this.unwrap(this.remote.selectSession(id2, {
|
|
1867
|
+
sessionId: id2,
|
|
1868
|
+
id: selectedId,
|
|
1869
|
+
...selectedId === null ? {} : { expectedRevision: revision2 },
|
|
1870
|
+
expectedSelectionRevision: session.selection.selectionRevision,
|
|
1871
|
+
expectedAdmissionEpoch: session.admissionEpoch
|
|
1872
|
+
}));
|
|
1873
|
+
if (accepted.sessionId !== id2) throw { kind: "assembly", code: "unavailable" };
|
|
1874
|
+
if (live()) this.publish({ session: accepted, sessionChoice: accepted.selection.selectedId, sessionNotice: reset ? "reset" : "applied" });
|
|
1875
|
+
} catch (error) {
|
|
1876
|
+
if (live()) this.publish({ sessionIssue: this.issue(error) });
|
|
1877
|
+
} finally {
|
|
1878
|
+
if (live()) this.publish({ sessionBusy: null });
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1505
1881
|
publish(patch) {
|
|
1506
1882
|
if (this.disposed) return;
|
|
1507
1883
|
this.current = { ...this.current, ...patch };
|
|
@@ -1509,7 +1885,7 @@ var ProfilesController = class {
|
|
|
1509
1885
|
}
|
|
1510
1886
|
accept(document2) {
|
|
1511
1887
|
this.accepted = { ...document2 };
|
|
1512
|
-
this.publish({ editor: { ...document2 }, dirty: false, pendingEditor: null });
|
|
1888
|
+
this.publish({ editor: { ...document2 }, dirty: false, pendingEditor: null, invalidFields: [], editorEpoch: this.current.editorEpoch + 1 });
|
|
1513
1889
|
}
|
|
1514
1890
|
async unwrap(request, field) {
|
|
1515
1891
|
const result = await request;
|
|
@@ -1527,7 +1903,7 @@ var ProfilesController = class {
|
|
|
1527
1903
|
return { kind: "assembly", code: "unavailable" };
|
|
1528
1904
|
}
|
|
1529
1905
|
async perform(busy, operation) {
|
|
1530
|
-
if (this.disposed || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
1906
|
+
if (this.disposed || this.current.busy !== null || this.current.sessionBusy === "apply" || this.current.sessionBusy === "reset" || this.current.pendingEditor !== null) return;
|
|
1531
1907
|
const generation = ++this.generation;
|
|
1532
1908
|
const live = () => !this.disposed && generation === this.generation;
|
|
1533
1909
|
this.publish({ busy, issue: null, notice: null });
|
|
@@ -1566,7 +1942,7 @@ var ProfilesController = class {
|
|
|
1566
1942
|
async loadEditor(id2) {
|
|
1567
1943
|
if (id2 === NEW_EDITOR) {
|
|
1568
1944
|
this.accepted = null;
|
|
1569
|
-
this.publish({ editor: { id: "new-profile", content: NEW_PROFILE_CONTENT, revision: null }, dirty: true, issue: null, notice: null, pendingEditor: null });
|
|
1945
|
+
this.publish({ editor: { id: "new-profile", content: NEW_PROFILE_CONTENT, revision: null }, dirty: true, issue: null, notice: null, pendingEditor: null, invalidFields: [], editorEpoch: this.current.editorEpoch + 1 });
|
|
1570
1946
|
return;
|
|
1571
1947
|
}
|
|
1572
1948
|
await this.perform("read", async (live) => {
|
|
@@ -1589,10 +1965,10 @@ var ProfilesController = class {
|
|
|
1589
1965
|
editId(id2) {
|
|
1590
1966
|
const editor = this.current.editor;
|
|
1591
1967
|
if (editor === null || editor.revision !== null || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1968
|
+
const content2 = editStructuredPath(editor.content, ["id"], id2);
|
|
1969
|
+
if (content2 === null) {
|
|
1970
|
+
this.publish({ issue: { kind: "domain", code: "validation", field: "content" }, notice: null });
|
|
1971
|
+
return;
|
|
1596
1972
|
}
|
|
1597
1973
|
this.publish({ editor: { ...editor, id: id2, content: content2 }, dirty: true, issue: null, notice: null });
|
|
1598
1974
|
}
|
|
@@ -1601,9 +1977,38 @@ var ProfilesController = class {
|
|
|
1601
1977
|
if (editor === null || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
1602
1978
|
this.publish({ editor: { ...editor, content: content2 }, dirty: this.accepted === null || this.accepted.content !== content2 || this.accepted.id !== editor.id, issue: null, notice: null });
|
|
1603
1979
|
}
|
|
1980
|
+
editPath(path, value) {
|
|
1981
|
+
const editor = this.current.editor;
|
|
1982
|
+
if (editor === null || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
1983
|
+
const content2 = editStructuredPath(editor.content, path, value);
|
|
1984
|
+
if (content2 === null) {
|
|
1985
|
+
this.publish({ issue: { kind: "domain", code: "validation", field: "content" }, notice: null });
|
|
1986
|
+
return;
|
|
1987
|
+
}
|
|
1988
|
+
this.editContent(content2);
|
|
1989
|
+
}
|
|
1990
|
+
editRoute(path, provider, model) {
|
|
1991
|
+
const editor = this.current.editor;
|
|
1992
|
+
if (editor === null || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
1993
|
+
let content2 = editor.content;
|
|
1994
|
+
for (const [key, value] of [["provider", provider], ["model", model], ["reasoningEffort", void 0]]) {
|
|
1995
|
+
content2 = editStructuredPath(content2, [...path, key], value);
|
|
1996
|
+
if (content2 === null) {
|
|
1997
|
+
this.publish({ issue: { kind: "domain", code: "validation", field: "content" }, notice: null });
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
this.editContent(content2);
|
|
2002
|
+
}
|
|
2003
|
+
editFallbackOrder(role2, from, to) {
|
|
2004
|
+
const editor = this.current.editor;
|
|
2005
|
+
if (editor === null || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
2006
|
+
const content2 = moveFallback(editor.content, role2, from, to);
|
|
2007
|
+
if (content2 !== null) this.editContent(content2);
|
|
2008
|
+
}
|
|
1604
2009
|
async save() {
|
|
1605
2010
|
const editor = this.current.editor;
|
|
1606
|
-
if (editor === null || !this.current.dirty || this.current.snapshot === null || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
2011
|
+
if (editor === null || !this.current.dirty || this.current.snapshot === null || this.current.busy !== null || this.current.pendingEditor !== null || this.current.invalidFields.length > 0) return;
|
|
1607
2012
|
if (!isProfileId(editor.id)) {
|
|
1608
2013
|
this.publish({ issue: { kind: "domain", code: "validation", field: "id" }, notice: null });
|
|
1609
2014
|
return;
|
|
@@ -1649,7 +2054,7 @@ var NS = "settings.dsmm-profiles";
|
|
|
1649
2054
|
var en = {
|
|
1650
2055
|
title: "Deepwork Profiles",
|
|
1651
2056
|
description: "Save independent runtime configurations and choose which one new sessions use.",
|
|
1652
|
-
newSessions: "
|
|
2057
|
+
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.",
|
|
1653
2058
|
editorSelect: "Profile to edit",
|
|
1654
2059
|
choose: "Choose a profile",
|
|
1655
2060
|
newDraft: "New unsaved profile",
|
|
@@ -1691,12 +2096,93 @@ var en = {
|
|
|
1691
2096
|
transport: "The native connection could not confirm this operation. Your draft is kept. Refresh the Host state before retrying; do not assume a save or apply completed.",
|
|
1692
2097
|
invalidProfile: "Unavailable profile: {id}",
|
|
1693
2098
|
details: "Host diagnostic",
|
|
1694
|
-
retry: "Resolve the diagnostic, refresh profiles, then retry."
|
|
2099
|
+
retry: "Resolve the diagnostic, refresh profiles, then retry.",
|
|
2100
|
+
globalScope: "Global default for future sessions",
|
|
2101
|
+
sessionScope: "Current native session",
|
|
2102
|
+
sessionSelect: "Current-session profile",
|
|
2103
|
+
globalActionHint: "Apply saved profile below changes the global default for future unscoped sessions only. It does not apply to the current session.",
|
|
2104
|
+
noSession: "No native session is selected. Session Apply is disabled; global defaults and drafts remain editable.",
|
|
2105
|
+
sessionUnavailable: "The current session could not be confirmed. Refresh its state before retrying; the prior policy is kept.",
|
|
2106
|
+
sessionBusy: "Switching is unavailable: {reason}. The Host must reserve a truly idle ordinary session before applying.",
|
|
2107
|
+
sessionState: "Session {id}: {profile}; scope {scope}; admission epoch {epoch}.",
|
|
2108
|
+
sessionBaseline: "deployment baseline",
|
|
2109
|
+
sessionGlobalCaptured: "captured global default (no explicit session override)",
|
|
2110
|
+
sessionAdmittedProfile: "{id} (revision {revision})",
|
|
2111
|
+
sessionFutureDefault: "Global default for future unscoped sessions: {profile}. This does not change this session's admission.",
|
|
2112
|
+
sessionConflict: "The session selection or admission epoch changed elsewhere. The prior display and draft are kept. Refresh current-session state before applying again.",
|
|
2113
|
+
sessionApply: "Apply profile to current session",
|
|
2114
|
+
sessionApplying: "Applying current-session profile…",
|
|
2115
|
+
sessionReset: "Pin baseline for current session",
|
|
2116
|
+
sessionResetting: "Pinning current-session baseline…",
|
|
2117
|
+
sessionRefresh: "Refresh current-session state",
|
|
2118
|
+
sessionApplied: "Applied the saved revision to this session only. Global default and existing children were not changed.",
|
|
2119
|
+
sessionResetDone: "Pinned the deployment baseline for this session only. Global default was not changed.",
|
|
2120
|
+
sessionDirty: "Save or explicitly discard the editor draft before applying a current-session choice.",
|
|
2121
|
+
roleState: "Admitted route {route}; strategy {strategy}; retries {retries}; rate-limit failures {failures}; switches {switches}; total delay {delay} ms.",
|
|
2122
|
+
catalogTitle: "Native model catalog",
|
|
2123
|
+
catalogHint: "Catalog listings are advisory, not network or account health checks. Unlisted/manual routes stay editable; refresh never changes the draft or native model default.",
|
|
2124
|
+
catalogUnavailable: "The native catalog is unavailable. Manual provider/model/effort fields and advanced JSONC remain available.",
|
|
2125
|
+
catalogRefresh: "Refresh model catalog",
|
|
2126
|
+
catalogRefreshing: "Refreshing model catalog…",
|
|
2127
|
+
catalogFailure: "Provider catalog unavailable: {name} ({id}).",
|
|
2128
|
+
profileLabel: "Profile display label",
|
|
2129
|
+
defaultActive: "Default Deepwork mode",
|
|
2130
|
+
activeHint: "This default does not erase an explicit saved session mode.",
|
|
2131
|
+
enabled: "Enabled",
|
|
2132
|
+
disabled: "Disabled",
|
|
2133
|
+
inherit: "Inherit deployment baseline",
|
|
2134
|
+
profileDefaults: "Profile runtime defaults",
|
|
2135
|
+
roleSelect: "Agent role to edit",
|
|
2136
|
+
rolesUnavailable: "Native role inventory unavailable — use advanced JSONC",
|
|
2137
|
+
roleEnabled: "Enabled in the native deployment",
|
|
2138
|
+
roleDisabled: "Disabled in the native deployment",
|
|
2139
|
+
strategy: "{name} strategy",
|
|
2140
|
+
inheritStrategy: "Inherit ({value})",
|
|
2141
|
+
startupLock: "startup-lock — keep the admitted route",
|
|
2142
|
+
rateFallback: "rate-limit-fallback — ordered rollover at threshold",
|
|
2143
|
+
strategyHint: "Both strategies use finite, positively no-output-safe RATE_LIMIT retries. Generic, auth and quota failures do not authorize a model switch. Blank numeric fields inherit; zero is an explicit value.",
|
|
2144
|
+
retryField: "{name} {field}",
|
|
2145
|
+
inheritNumber: "Inherit {value}",
|
|
2146
|
+
retryBounds: "Integer {min}–{max}; inherited value {value}.",
|
|
2147
|
+
unknownDefault: "unavailable",
|
|
2148
|
+
retryCount: "retry count",
|
|
2149
|
+
initialDelay: "initial delay (ms)",
|
|
2150
|
+
maxDelay: "maximum delay (ms)",
|
|
2151
|
+
totalWait: "total wait budget (ms)",
|
|
2152
|
+
switchThreshold: "rate-limit failures before switch",
|
|
2153
|
+
maxSwitches: "maximum switches",
|
|
2154
|
+
primaryMode: "{name} primary route",
|
|
2155
|
+
inheritRoute: "Inherit native/deployment route",
|
|
2156
|
+
configuredRoute: "Configure primary route",
|
|
2157
|
+
primaryName: "{name} primary",
|
|
2158
|
+
fallbackMode: "{name} fallback chain",
|
|
2159
|
+
inheritChain: "Inherit deployment fallback chain",
|
|
2160
|
+
configuredChain: "Explicit ordered fallback chain",
|
|
2161
|
+
emptyChain: "Explicitly empty chain: no configured fallback routes.",
|
|
2162
|
+
fallbackName: "{name} fallback {index}",
|
|
2163
|
+
addFallback: "Add fallback for {name}",
|
|
2164
|
+
removeFallback: "Remove {name}",
|
|
2165
|
+
moveUp: "Move up {name}",
|
|
2166
|
+
moveDown: "Move down {name}",
|
|
2167
|
+
routeProvider: "{name} provider",
|
|
2168
|
+
routeModel: "{name} model",
|
|
2169
|
+
routeEffort: "{name} exact effort",
|
|
2170
|
+
manualProvider: "{name} manual provider",
|
|
2171
|
+
manualModel: "{name} manual model",
|
|
2172
|
+
manualEffort: "{name} manual exact effort",
|
|
2173
|
+
manual: "Enter manual identifier",
|
|
2174
|
+
manualValue: "Manual / unlisted: {value}",
|
|
2175
|
+
unset: "not set",
|
|
2176
|
+
effortDefault: "Native default (omit exact effort)",
|
|
2177
|
+
effortChangeHint: "Changing a provider/model explicitly clears that route's exact effort. Catalog refresh preserves all configured values; choose an exact effort again if required.",
|
|
2178
|
+
advanced: "Advanced JSONC",
|
|
2179
|
+
rawInvalid: "Structured editing is unavailable for this invalid raw draft. Correct Advanced JSONC; no fields, comments or bytes have been normalized.",
|
|
2180
|
+
invalidNumber: "Correct this bounded integer before saving or changing roles. The invalid value has not replaced the saved draft policy."
|
|
1695
2181
|
};
|
|
1696
2182
|
var zh = {
|
|
1697
2183
|
title: "Deepwork 配置档",
|
|
1698
2184
|
description: "保存独立的运行时配置,并选择新会话使用的配置档。",
|
|
1699
|
-
newSessions: "
|
|
2185
|
+
newSessions: "全局应用和重置仅影响之后没有独立选择的新会话。下方当前会话操作相互独立。冷恢复保留明确保存的会话选择,否则继承全局默认值。",
|
|
1700
2186
|
editorSelect: "要编辑的配置档",
|
|
1701
2187
|
choose: "选择配置档",
|
|
1702
2188
|
newDraft: "新的未保存配置档",
|
|
@@ -1738,13 +2224,376 @@ var zh = {
|
|
|
1738
2224
|
transport: "原生连接无法确认此操作。草稿已保留。重试之前请刷新 Host 状态;不要假定保存或应用已完成。",
|
|
1739
2225
|
invalidProfile: "不可用配置档:{id}",
|
|
1740
2226
|
details: "Host 诊断",
|
|
1741
|
-
retry: "请解决诊断问题,刷新配置档后重试。"
|
|
2227
|
+
retry: "请解决诊断问题,刷新配置档后重试。",
|
|
2228
|
+
globalScope: "未来会话的全局默认值",
|
|
2229
|
+
sessionScope: "当前原生会话",
|
|
2230
|
+
sessionSelect: "当前会话配置档",
|
|
2231
|
+
globalActionHint: "下方应用已保存配置档仅改变未来没有独立选择的会话的全局默认值,不会应用到当前会话。",
|
|
2232
|
+
noSession: "未选择原生会话。会话应用已禁用;仍可编辑全局默认值和草稿。",
|
|
2233
|
+
sessionUnavailable: "无法确认当前会话。重试前请刷新状态;原策略已保留。",
|
|
2234
|
+
sessionBusy: "暂不可切换:{reason}。Host 必须先保留真正空闲的普通会话。",
|
|
2235
|
+
sessionState: "会话 {id}:{profile};范围 {scope};准入代次 {epoch}。",
|
|
2236
|
+
sessionBaseline: "部署基线",
|
|
2237
|
+
sessionGlobalCaptured: "已捕获的全局默认值(没有明确会话覆盖)",
|
|
2238
|
+
sessionAdmittedProfile: "{id}(修订 {revision})",
|
|
2239
|
+
sessionFutureDefault: "未来没有独立选择的会话的全局默认值:{profile}。这不会改变当前会话的准入。",
|
|
2240
|
+
sessionConflict: "会话选择或准入代次已在其他位置改变。原显示和草稿已保留。再次应用前请刷新当前会话状态。",
|
|
2241
|
+
sessionApply: "应用配置档到当前会话",
|
|
2242
|
+
sessionApplying: "正在应用当前会话配置档…",
|
|
2243
|
+
sessionReset: "为当前会话固定基线",
|
|
2244
|
+
sessionResetting: "正在固定当前会话基线…",
|
|
2245
|
+
sessionRefresh: "刷新当前会话状态",
|
|
2246
|
+
sessionApplied: "已仅对此会话应用保存的修订。全局默认值和已有子会话未改变。",
|
|
2247
|
+
sessionResetDone: "已仅对此会话固定部署基线。全局默认值未改变。",
|
|
2248
|
+
sessionDirty: "应用当前会话选择之前,请保存或明确丢弃编辑器草稿。",
|
|
2249
|
+
roleState: "准入路由 {route};策略 {strategy};重试 {retries};限流失败 {failures};切换 {switches};累计延迟 {delay} 毫秒。",
|
|
2250
|
+
catalogTitle: "原生模型目录",
|
|
2251
|
+
catalogHint: "目录仅供参考,不是网络或账户健康检查。未列出或手动路由仍可编辑;刷新不会改变草稿或原生模型默认值。",
|
|
2252
|
+
catalogUnavailable: "原生模型目录不可用。仍可使用手动提供商、模型、强度字段和高级 JSONC。",
|
|
2253
|
+
catalogRefresh: "刷新模型目录",
|
|
2254
|
+
catalogRefreshing: "正在刷新模型目录…",
|
|
2255
|
+
catalogFailure: "提供商目录不可用:{name}({id})。",
|
|
2256
|
+
profileLabel: "配置档显示名称",
|
|
2257
|
+
defaultActive: "默认 Deepwork 模式",
|
|
2258
|
+
activeHint: "此默认值不会抹除已明确保存的会话模式。",
|
|
2259
|
+
enabled: "启用",
|
|
2260
|
+
disabled: "禁用",
|
|
2261
|
+
inherit: "继承部署基线",
|
|
2262
|
+
profileDefaults: "配置档运行时默认值",
|
|
2263
|
+
roleSelect: "要编辑的 Agent 角色",
|
|
2264
|
+
rolesUnavailable: "原生角色列表不可用,请使用高级 JSONC",
|
|
2265
|
+
roleEnabled: "原生部署中已启用",
|
|
2266
|
+
roleDisabled: "原生部署中已禁用",
|
|
2267
|
+
strategy: "{name} 策略",
|
|
2268
|
+
inheritStrategy: "继承({value})",
|
|
2269
|
+
startupLock: "startup-lock — 保留准入路由",
|
|
2270
|
+
rateFallback: "rate-limit-fallback — 达到阈值后按顺序切换",
|
|
2271
|
+
strategyHint: "两种策略均使用有限且已证明无输出的 RATE_LIMIT 重试。普通、认证或配额失败不允许切换模型。数字留空表示继承,零是明确值。",
|
|
2272
|
+
retryField: "{name} {field}",
|
|
2273
|
+
inheritNumber: "继承 {value}",
|
|
2274
|
+
retryBounds: "整数 {min}–{max};继承值 {value}。",
|
|
2275
|
+
unknownDefault: "不可用",
|
|
2276
|
+
retryCount: "重试次数",
|
|
2277
|
+
initialDelay: "初始延迟(毫秒)",
|
|
2278
|
+
maxDelay: "最大单次延迟(毫秒)",
|
|
2279
|
+
totalWait: "累计等待上限(毫秒)",
|
|
2280
|
+
switchThreshold: "切换前的限流失败次数",
|
|
2281
|
+
maxSwitches: "最大切换次数",
|
|
2282
|
+
primaryMode: "{name} 主路由",
|
|
2283
|
+
inheritRoute: "继承原生或部署路由",
|
|
2284
|
+
configuredRoute: "配置主路由",
|
|
2285
|
+
primaryName: "{name} 主路由",
|
|
2286
|
+
fallbackMode: "{name} 备用链",
|
|
2287
|
+
inheritChain: "继承部署备用链",
|
|
2288
|
+
configuredChain: "明确的有序备用链",
|
|
2289
|
+
emptyChain: "明确为空的备用链:没有已配置备用路由。",
|
|
2290
|
+
fallbackName: "{name} 备用 {index}",
|
|
2291
|
+
addFallback: "为 {name} 添加备用路由",
|
|
2292
|
+
removeFallback: "移除 {name}",
|
|
2293
|
+
moveUp: "上移 {name}",
|
|
2294
|
+
moveDown: "下移 {name}",
|
|
2295
|
+
routeProvider: "{name} 提供商",
|
|
2296
|
+
routeModel: "{name} 模型",
|
|
2297
|
+
routeEffort: "{name} 精确强度",
|
|
2298
|
+
manualProvider: "{name} 手动提供商",
|
|
2299
|
+
manualModel: "{name} 手动模型",
|
|
2300
|
+
manualEffort: "{name} 手动精确强度",
|
|
2301
|
+
manual: "输入手动标识",
|
|
2302
|
+
manualValue: "手动或未列出:{value}",
|
|
2303
|
+
unset: "未设置",
|
|
2304
|
+
effortDefault: "原生默认值(省略精确强度)",
|
|
2305
|
+
effortChangeHint: "明确更改提供商或模型会清除该路由的精确强度。刷新目录会保留所有配置值;需要时请重新选择精确强度。",
|
|
2306
|
+
advanced: "高级 JSONC",
|
|
2307
|
+
rawInvalid: "原始草稿无效,暂不可结构化编辑。请修正高级 JSONC;字段、注释和字节均未自动规范化。",
|
|
2308
|
+
invalidNumber: "保存或切换角色之前,请修正此有界整数。无效值尚未替换草稿中的策略。"
|
|
2309
|
+
};
|
|
2310
|
+
var RETRY_FIELD_LABEL_KEYS = {
|
|
2311
|
+
maxRetries: "retryCount",
|
|
2312
|
+
initialDelayMs: "initialDelay",
|
|
2313
|
+
maxDelayMs: "maxDelay",
|
|
2314
|
+
maxTotalDelayMs: "totalWait",
|
|
2315
|
+
switchAfterRateLimits: "switchThreshold",
|
|
2316
|
+
maxSwitches: "maxSwitches"
|
|
1742
2317
|
};
|
|
1743
2318
|
|
|
1744
2319
|
// src/client/ProfilesSection.tsx
|
|
2320
|
+
var import_react3 = require("react");
|
|
2321
|
+
var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
2322
|
+
|
|
2323
|
+
// src/client/StructuredEditor.tsx
|
|
1745
2324
|
var import_react = require("react");
|
|
1746
2325
|
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
1747
2326
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
2327
|
+
var MANUAL = "__dsmm_manual__";
|
|
2328
|
+
function RetryNumber({ id: id2, name, field, value, inherited, path, disabled, actions, t }) {
|
|
2329
|
+
const [draft, setDraft] = (0, import_react.useState)(value === void 0 ? "" : String(value));
|
|
2330
|
+
const [invalid, setInvalid] = (0, import_react.useState)(false);
|
|
2331
|
+
const [min, max] = DSMM_RATE_LIMIT_BOUNDS[field];
|
|
2332
|
+
const key = path.join(".");
|
|
2333
|
+
(0, import_react.useEffect)(() => {
|
|
2334
|
+
setDraft(value === void 0 ? "" : String(value));
|
|
2335
|
+
setInvalid(false);
|
|
2336
|
+
}, [value]);
|
|
2337
|
+
(0, import_react.useEffect)(() => {
|
|
2338
|
+
actions.setFieldInvalid(key, invalid);
|
|
2339
|
+
return () => actions.setFieldInvalid(key, false);
|
|
2340
|
+
}, [actions.setFieldInvalid, key, invalid]);
|
|
2341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
2342
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: id2, children: t("retryField", { name, field: t(RETRY_FIELD_LABEL_KEYS[field]) }) }),
|
|
2343
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2344
|
+
import_dsh_client_ui_primitives.Input,
|
|
2345
|
+
{
|
|
2346
|
+
id: id2,
|
|
2347
|
+
"data-dsmm-policy-field": field,
|
|
2348
|
+
className: "dsmm-input",
|
|
2349
|
+
type: "number",
|
|
2350
|
+
inputMode: "numeric",
|
|
2351
|
+
min,
|
|
2352
|
+
max,
|
|
2353
|
+
step: 1,
|
|
2354
|
+
disabled,
|
|
2355
|
+
value: draft,
|
|
2356
|
+
placeholder: inherited === void 0 ? t("unknownDefault") : t("inheritNumber", { value: inherited }),
|
|
2357
|
+
"aria-invalid": invalid || void 0,
|
|
2358
|
+
"aria-describedby": `${id2}-hint${invalid ? ` ${id2}-invalid` : ""}`,
|
|
2359
|
+
onChange: (event) => {
|
|
2360
|
+
const input = event.currentTarget;
|
|
2361
|
+
setDraft(input.value);
|
|
2362
|
+
const valid = input.validity.valid && (input.value === "" || Number.isSafeInteger(input.valueAsNumber));
|
|
2363
|
+
setInvalid(!valid);
|
|
2364
|
+
actions.setFieldInvalid(key, !valid);
|
|
2365
|
+
if (valid) actions.editPath(path, input.value === "" ? void 0 : input.valueAsNumber);
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
),
|
|
2369
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsmm-hint", id: `${id2}-hint`, children: t("retryBounds", { min, max, value: inherited ?? t("unknownDefault") }) }),
|
|
2370
|
+
invalid && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { id: `${id2}-invalid`, children: t("invalidNumber") })
|
|
2371
|
+
] });
|
|
2372
|
+
}
|
|
2373
|
+
function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t }) {
|
|
2374
|
+
const prefix = (0, import_react.useId)();
|
|
2375
|
+
const providers = catalog?.groups ?? [];
|
|
2376
|
+
const group = providers.find((candidate) => candidate.id === value.provider);
|
|
2377
|
+
const model = group?.models.find((candidate) => candidate.id === value.model);
|
|
2378
|
+
const efforts = model?.reasoning?.efforts ?? [];
|
|
2379
|
+
const providerListed = group !== void 0;
|
|
2380
|
+
const modelListed = model !== void 0;
|
|
2381
|
+
const updateModel = (provider, modelId) => {
|
|
2382
|
+
editRoute(path, provider, modelId);
|
|
2383
|
+
};
|
|
2384
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-route-fields", children: [
|
|
2385
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
2386
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-provider`, children: t("routeProvider", { name }) }),
|
|
2387
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { id: `${prefix}-provider`, disabled, value: providerListed ? value.provider : MANUAL, onChange: (event) => updateModel(event.currentTarget.value === MANUAL ? "" : event.currentTarget.value, ""), children: [
|
|
2388
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: MANUAL, children: providerListed ? t("manual") : t("manualValue", { value: value.provider || t("unset") }) }),
|
|
2389
|
+
providers.map((provider) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", { value: provider.id, children: [
|
|
2390
|
+
provider.name,
|
|
2391
|
+
" (",
|
|
2392
|
+
provider.id,
|
|
2393
|
+
")"
|
|
2394
|
+
] }, provider.id))
|
|
2395
|
+
] }),
|
|
2396
|
+
!providerListed && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { "aria-label": t("manualProvider", { name }), className: "dsmm-input", value: value.provider, disabled, onChange: (event) => updateModel(event.currentTarget.value, value.model) })
|
|
2397
|
+
] }),
|
|
2398
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
2399
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-model`, children: t("routeModel", { name }) }),
|
|
2400
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { id: `${prefix}-model`, disabled, value: modelListed ? value.model : MANUAL, onChange: (event) => updateModel(value.provider, event.currentTarget.value === MANUAL ? "" : event.currentTarget.value), children: [
|
|
2401
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: MANUAL, children: modelListed ? t("manual") : t("manualValue", { value: value.model || t("unset") }) }),
|
|
2402
|
+
group?.models.map((candidate) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", { value: candidate.id, children: [
|
|
2403
|
+
candidate.name,
|
|
2404
|
+
" (",
|
|
2405
|
+
candidate.id,
|
|
2406
|
+
")"
|
|
2407
|
+
] }, candidate.id))
|
|
2408
|
+
] }),
|
|
2409
|
+
!modelListed && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { "aria-label": t("manualModel", { name }), className: "dsmm-input", value: value.model, disabled, onChange: (event) => updateModel(value.provider, event.currentTarget.value) })
|
|
2410
|
+
] }),
|
|
2411
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
2412
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-effort`, children: t("routeEffort", { name }) }),
|
|
2413
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { id: `${prefix}-effort`, disabled, value: value.reasoningEffort ?? "", onChange: (event) => edit([...path, "reasoningEffort"], event.currentTarget.value || void 0), children: [
|
|
2414
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: t("effortDefault") }),
|
|
2415
|
+
value.reasoningEffort !== void 0 && !efforts.some((effort) => effort.id === value.reasoningEffort) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: value.reasoningEffort, children: t("manualValue", { value: value.reasoningEffort }) }),
|
|
2416
|
+
efforts.map((effort) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", { value: effort.id, children: [
|
|
2417
|
+
effort.name,
|
|
2418
|
+
" (",
|
|
2419
|
+
effort.id,
|
|
2420
|
+
")"
|
|
2421
|
+
] }, effort.id))
|
|
2422
|
+
] }),
|
|
2423
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { "aria-label": t("manualEffort", { name }), className: "dsmm-input", value: value.reasoningEffort ?? "", disabled, placeholder: t("effortDefault"), onChange: (event) => edit([...path, "reasoningEffort"], event.currentTarget.value || void 0) })
|
|
2424
|
+
] })
|
|
2425
|
+
] });
|
|
2426
|
+
}
|
|
2427
|
+
function PolicyFields({ value, inherited, path, name, disabled, actions, t }) {
|
|
2428
|
+
const prefix = (0, import_react.useId)();
|
|
2429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-policy-fields", children: [
|
|
2430
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
2431
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-strategy`, children: t("strategy", { name }) }),
|
|
2432
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { id: `${prefix}-strategy`, disabled, value: value.strategy ?? "", onChange: (event) => actions.editPath([...path, "strategy"], event.currentTarget.value || void 0), children: [
|
|
2433
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: t("inheritStrategy", { value: inherited?.strategy ?? t("unknownDefault") }) }),
|
|
2434
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "startup-lock", children: t("startupLock") }),
|
|
2435
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "rate-limit-fallback", children: t("rateFallback") })
|
|
2436
|
+
] })
|
|
2437
|
+
] }),
|
|
2438
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsmm-hint", children: t("strategyHint") }),
|
|
2439
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsmm-route-fields", children: Object.keys(DSMM_RATE_LIMIT_BOUNDS).map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RetryNumber, { id: `${prefix}-${field}`, t, name, field, value: value.rateLimit?.[field], inherited: inherited?.rateLimit[field], path: [...path, "rateLimit", field], disabled, actions }, field)) })
|
|
2440
|
+
] });
|
|
2441
|
+
}
|
|
2442
|
+
function StructuredEditor({ state, actions, disabled, t }) {
|
|
2443
|
+
const prefix = (0, import_react.useId)();
|
|
2444
|
+
const [selectedRole, setSelectedRole] = (0, import_react.useState)("dsmm-orchestrator");
|
|
2445
|
+
const document2 = state.editor === null ? null : structuredDocument(state.editor.content);
|
|
2446
|
+
if (document2 === null) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsmm-hint", "data-dsmm-structured-invalid": true, children: t("rawInvalid") });
|
|
2447
|
+
const roles = state.snapshot?.roles ?? [];
|
|
2448
|
+
const role2 = roles.find((candidate) => candidate.id === selectedRole) ?? roles[0];
|
|
2449
|
+
const policy = role2 === void 0 ? void 0 : document2.roleRouting[role2.id] ?? {};
|
|
2450
|
+
const baseline = state.snapshot?.editorDefaults;
|
|
2451
|
+
let inherited;
|
|
2452
|
+
try {
|
|
2453
|
+
if (baseline !== void 0) {
|
|
2454
|
+
const profileDefaults = { strategy: document2.runtimePolicy.strategy ?? baseline.strategy, rateLimit: normalizeRateLimitPolicy(document2.runtimePolicy.rateLimit, baseline.rateLimit) };
|
|
2455
|
+
inherited = { strategy: role2?.runtimePolicy?.strategy ?? profileDefaults.strategy, rateLimit: normalizeRateLimitPolicy(role2?.runtimePolicy?.rateLimit, profileDefaults.rateLimit) };
|
|
2456
|
+
}
|
|
2457
|
+
} catch {
|
|
2458
|
+
}
|
|
2459
|
+
const rolePath = ["settings", "roleRouting", role2?.id ?? ""];
|
|
2460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-structured", "data-dsmm-structured": true, children: [
|
|
2461
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
2462
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-label`, children: t("profileLabel") }),
|
|
2463
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { id: `${prefix}-label`, className: "dsmm-input", value: document2.label ?? "", disabled, onChange: (event) => actions.editPath(["label"], event.currentTarget.value || void 0) })
|
|
2464
|
+
] }),
|
|
2465
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
2466
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-active`, children: t("defaultActive") }),
|
|
2467
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { id: `${prefix}-active`, disabled, value: document2.settings.defaultActive === void 0 ? "" : String(document2.settings.defaultActive), onChange: (event) => actions.editPath(["settings", "defaultActive"], event.currentTarget.value === "" ? void 0 : event.currentTarget.value === "true"), children: [
|
|
2468
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: t("inherit") }),
|
|
2469
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "true", children: t("enabled") }),
|
|
2470
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "false", children: t("disabled") })
|
|
2471
|
+
] }),
|
|
2472
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsmm-hint", children: t("activeHint") })
|
|
2473
|
+
] }),
|
|
2474
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("fieldset", { children: [
|
|
2475
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("legend", { children: t("profileDefaults") }),
|
|
2476
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PolicyFields, { t, value: document2.runtimePolicy, inherited: baseline, path: ["settings", "runtimePolicy"], name: t("profileDefaults"), disabled, actions })
|
|
2477
|
+
] }),
|
|
2478
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
2479
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-role`, children: t("roleSelect") }),
|
|
2480
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { id: `${prefix}-role`, disabled: disabled || roles.length === 0 || state.invalidFields.length > 0, value: role2?.id ?? "", onChange: (event) => setSelectedRole(event.currentTarget.value), children: [
|
|
2481
|
+
roles.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: t("rolesUnavailable") }),
|
|
2482
|
+
roles.map((candidate) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", { value: candidate.id, children: [
|
|
2483
|
+
candidate.label,
|
|
2484
|
+
candidate.enabled ? "" : ` — ${t("roleDisabled")}`
|
|
2485
|
+
] }, candidate.id))
|
|
2486
|
+
] })
|
|
2487
|
+
] }),
|
|
2488
|
+
role2 !== void 0 && policy !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("fieldset", { "data-dsmm-role": role2.id, children: [
|
|
2489
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("legend", { children: role2.label }),
|
|
2490
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsmm-hint", children: t(role2.enabled ? "roleEnabled" : "roleDisabled") }),
|
|
2491
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PolicyFields, { t, value: policy, inherited, path: rolePath, name: role2.label, disabled, actions }),
|
|
2492
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
2493
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-primary-mode`, children: t("primaryMode", { name: role2.label }) }),
|
|
2494
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { id: `${prefix}-primary-mode`, disabled, value: policy.primary === void 0 ? "inherit" : "explicit", onChange: (event) => actions.editPath([...rolePath, "primary"], event.currentTarget.value === "inherit" ? void 0 : { provider: "", model: "" }), children: [
|
|
2495
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "inherit", children: t("inheritRoute") }),
|
|
2496
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "explicit", children: t("configuredRoute") })
|
|
2497
|
+
] })
|
|
2498
|
+
] }),
|
|
2499
|
+
policy.primary !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouteFields, { t, value: policy.primary, path: [...rolePath, "primary"], name: t("primaryName", { name: role2.label }), catalog: state.catalog, disabled, edit: actions.editPath, editRoute: actions.editRoute }),
|
|
2500
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsmm-hint", children: t("effortChangeHint") }),
|
|
2501
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
2502
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-fallback-mode`, children: t("fallbackMode", { name: role2.label }) }),
|
|
2503
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { id: `${prefix}-fallback-mode`, disabled, value: policy.fallbackRoutes === void 0 ? "inherit" : "explicit", onChange: (event) => actions.editPath([...rolePath, "fallbackRoutes"], event.currentTarget.value === "inherit" ? void 0 : []), children: [
|
|
2504
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "inherit", children: t("inheritChain") }),
|
|
2505
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "explicit", children: t("configuredChain") })
|
|
2506
|
+
] })
|
|
2507
|
+
] }),
|
|
2508
|
+
policy.fallbackRoutes?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsmm-hint", children: t("emptyChain") }),
|
|
2509
|
+
policy.fallbackRoutes?.map((candidate, index) => {
|
|
2510
|
+
const name = t("fallbackName", { name: role2.label, index: index + 1 });
|
|
2511
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("fieldset", { children: [
|
|
2512
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("legend", { children: name }),
|
|
2513
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouteFields, { t, value: candidate, path: [...rolePath, "fallbackRoutes", index], name, catalog: state.catalog, disabled, edit: actions.editPath, editRoute: actions.editRoute }),
|
|
2514
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-actions", children: [
|
|
2515
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", variant: "outline", disabled: disabled || index === 0, onClick: () => actions.moveFallback(role2.id, index, index - 1), children: t("moveUp", { name }) }),
|
|
2516
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", variant: "outline", disabled: disabled || index === policy.fallbackRoutes.length - 1, onClick: () => actions.moveFallback(role2.id, index, index + 1), children: t("moveDown", { name }) }),
|
|
2517
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", variant: "outline", disabled, onClick: () => actions.editPath([...rolePath, "fallbackRoutes", index], void 0), children: t("removeFallback", { name }) })
|
|
2518
|
+
] })
|
|
2519
|
+
] }, index);
|
|
2520
|
+
}),
|
|
2521
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", variant: "outline", disabled: disabled || (policy.fallbackRoutes?.length ?? 0) >= 32, onClick: () => {
|
|
2522
|
+
if (policy.fallbackRoutes === void 0) actions.editPath([...rolePath, "fallbackRoutes"], [{ provider: "", model: "" }]);
|
|
2523
|
+
else actions.editPath([...rolePath, "fallbackRoutes", policy.fallbackRoutes.length], { provider: "", model: "" });
|
|
2524
|
+
}, children: t("addFallback", { name: role2.label }) })
|
|
2525
|
+
] })
|
|
2526
|
+
] });
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2529
|
+
// src/client/SessionProfiles.tsx
|
|
2530
|
+
var import_react2 = require("react");
|
|
2531
|
+
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
2532
|
+
|
|
2533
|
+
// src/client/session-labels.ts
|
|
2534
|
+
function sessionProfileLabels(session, t) {
|
|
2535
|
+
const admitted = session.admittedSelection;
|
|
2536
|
+
const profile = admitted === void 0 && session.scope === "global-default" ? t("sessionGlobalCaptured") : (admitted ?? session.selection).selectedId === null ? t("sessionBaseline") : t("sessionAdmittedProfile", { id: (admitted ?? session.selection).selectedId, revision: (admitted ?? session.selection).appliedRevision?.slice(0, 12) ?? "—" });
|
|
2537
|
+
const future = session.globalDefault;
|
|
2538
|
+
return {
|
|
2539
|
+
admitted: t("sessionState", { id: session.sessionId, profile, scope: session.scope, epoch: session.admissionEpoch }),
|
|
2540
|
+
futureDefault: t("sessionFutureDefault", { profile: future.selectedId === null ? t("sessionBaseline") : t("sessionAdmittedProfile", { id: future.selectedId, revision: future.appliedRevision?.slice(0, 12) ?? "—" }) })
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
// src/client/SessionProfiles.tsx
|
|
2545
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2546
|
+
function SessionScope({ state, actions, t, compact = false }) {
|
|
2547
|
+
const prefix = (0, import_react2.useId)();
|
|
2548
|
+
const session = state.session;
|
|
2549
|
+
const labels = session === null ? null : sessionProfileLabels(session, t);
|
|
2550
|
+
const selected = state.snapshot?.profiles.find((profile) => profile.id === state.sessionChoice);
|
|
2551
|
+
const disabled = state.busy !== null || state.pendingEditor !== null || state.sessionBusy !== null || state.dirty;
|
|
2552
|
+
const allowed = session !== null && session.switchAllowed && /^[a-f0-9]{64}$|^absent$/u.test(session.selection.selectionRevision);
|
|
2553
|
+
const status = state.sessionNotice === null ? "" : t(state.sessionNotice === "applied" ? "sessionApplied" : "sessionResetDone");
|
|
2554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsmm-session-scope", "aria-busy": state.sessionBusy !== null, "data-dsmm-session-scope": true, children: [
|
|
2555
|
+
!compact && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { children: t("sessionScope") }),
|
|
2556
|
+
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: [
|
|
2557
|
+
labels !== null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { "data-dsmm-session-state": true, children: labels.admitted }),
|
|
2558
|
+
labels !== null && !compact && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsmm-hint", "data-dsmm-session-future-default": true, children: labels.futureDefault }),
|
|
2559
|
+
session !== null && !session.switchAllowed && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsmm-hint", children: t("sessionBusy", { reason: session.switchUnavailableReason ?? "unavailable" }) }),
|
|
2560
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsmm-field", children: [
|
|
2561
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }),
|
|
2562
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: disabled || !allowed, onChange: (event) => actions.chooseSessionProfile(event.currentTarget.value || null), children: [
|
|
2563
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: t("sessionBaseline") }),
|
|
2564
|
+
state.sessionChoice !== null && selected === void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: state.sessionChoice, children: state.sessionChoice }),
|
|
2565
|
+
state.snapshot?.profiles.map((profile) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: profile.id, disabled: profile.revision === null || profile.error !== void 0, children: profile.label === void 0 ? profile.id : `${profile.label} (${profile.id})` }, profile.id))
|
|
2566
|
+
] })
|
|
2567
|
+
] }),
|
|
2568
|
+
state.dirty && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsmm-hint", children: t("sessionDirty") }),
|
|
2569
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsmm-actions", children: [
|
|
2570
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled: disabled || !allowed || state.sessionChoice !== null && selected?.revision == null, onClick: () => {
|
|
2571
|
+
void actions.applySession();
|
|
2572
|
+
}, children: t(state.sessionBusy === "apply" ? "sessionApplying" : "sessionApply") }),
|
|
2573
|
+
!compact && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled: disabled || !allowed, onClick: () => {
|
|
2574
|
+
void actions.resetSession();
|
|
2575
|
+
}, children: t(state.sessionBusy === "reset" ? "sessionResetting" : "sessionReset") }),
|
|
2576
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled: state.sessionBusy !== null || state.busy !== null || state.pendingEditor !== null, onClick: () => {
|
|
2577
|
+
void actions.refreshSession();
|
|
2578
|
+
}, children: t("sessionRefresh") })
|
|
2579
|
+
] }),
|
|
2580
|
+
!compact && session?.rolePolicy !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { "data-dsmm-session-policy": true, children: t("roleState", { route: session.rolePolicy.route === void 0 ? t("inheritRoute") : `${session.rolePolicy.route.provider}/${session.rolePolicy.route.model}${session.rolePolicy.route.reasoningEffort === void 0 ? "" : ` (${session.rolePolicy.route.reasoningEffort})`}`, strategy: session.rolePolicy.strategy, retries: session.rolePolicy.retries, failures: session.rolePolicy.rateLimitFailures, switches: session.rolePolicy.switches, delay: session.rolePolicy.totalDelayMs }) })
|
|
2581
|
+
] }),
|
|
2582
|
+
state.sessionIssue !== null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { role: "alert", children: state.sessionIssue.code === "conflict" ? t("sessionConflict") : ["busy", "maintenance", "disposed", "not-owned"].includes(state.sessionIssue.code) ? t("sessionBusy", { reason: state.sessionIssue.code }) : t(state.sessionIssue.code === "validation" ? "validation" : "sessionUnavailable") }),
|
|
2583
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.sessionBusy === "read" ? t("reading") : status })
|
|
2584
|
+
] });
|
|
2585
|
+
}
|
|
2586
|
+
function SessionProfiles(props) {
|
|
2587
|
+
const state = props.useProfiles((snapshot2) => snapshot2);
|
|
2588
|
+
if (props.sessionId !== state.currentSessionId) return null;
|
|
2589
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsmm-profiles dsmm-header-profiles", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("details", { children: [
|
|
2590
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("summary", { children: props.t("title") }),
|
|
2591
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SessionScope, { state, actions: props, t: props.t, compact: true })
|
|
2592
|
+
] }) });
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
// src/client/ProfilesSection.tsx
|
|
2596
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1748
2597
|
function issueKey(issue) {
|
|
1749
2598
|
if (issue.source === "selection") return issue.code === "conflict" ? "selectionConflict" : "appliedInvalid";
|
|
1750
2599
|
if (issue.kind === "assembly") return "unavailable";
|
|
@@ -1754,20 +2603,21 @@ function issueKey(issue) {
|
|
|
1754
2603
|
function ProfilesSection(props) {
|
|
1755
2604
|
const { t } = props;
|
|
1756
2605
|
const state = props.useProfiles((snapshot3) => snapshot3);
|
|
1757
|
-
const prefix = (0,
|
|
1758
|
-
const selectRef = (0,
|
|
1759
|
-
const inputRef = (0,
|
|
1760
|
-
const editorRef = (0,
|
|
1761
|
-
const cancelRef = (0,
|
|
1762
|
-
const hadConfirmation = (0,
|
|
1763
|
-
const disabled = state.busy !== null || state.pendingEditor !== null;
|
|
2606
|
+
const prefix = (0, import_react3.useId)();
|
|
2607
|
+
const selectRef = (0, import_react3.useRef)(null);
|
|
2608
|
+
const inputRef = (0, import_react3.useRef)(null);
|
|
2609
|
+
const editorRef = (0, import_react3.useRef)(null);
|
|
2610
|
+
const cancelRef = (0, import_react3.useRef)(null);
|
|
2611
|
+
const hadConfirmation = (0, import_react3.useRef)(false);
|
|
2612
|
+
const disabled = state.busy !== null || state.pendingEditor !== null || state.sessionBusy === "apply" || state.sessionBusy === "reset";
|
|
1764
2613
|
const snapshot2 = state.snapshot;
|
|
1765
2614
|
const editor = state.editor;
|
|
1766
2615
|
const reconcilable = canReconcileSelection(snapshot2);
|
|
1767
2616
|
const selectionConflict = reconcilable && snapshot2?.selectionError?.code === "conflict";
|
|
1768
2617
|
const invalid = state.issue?.kind === "domain" && state.issue.code === "validation";
|
|
1769
2618
|
const idInvalid = invalid && state.issue?.field === "id";
|
|
1770
|
-
(
|
|
2619
|
+
const rawInvalid = editor !== null && structuredDocument(editor.content) === null;
|
|
2620
|
+
(0, import_react3.useEffect)(() => {
|
|
1771
2621
|
if (state.pendingEditor !== null) {
|
|
1772
2622
|
cancelRef.current?.focus();
|
|
1773
2623
|
hadConfirmation.current = true;
|
|
@@ -1776,7 +2626,7 @@ function ProfilesSection(props) {
|
|
|
1776
2626
|
hadConfirmation.current = false;
|
|
1777
2627
|
}
|
|
1778
2628
|
}, [state.pendingEditor]);
|
|
1779
|
-
(0,
|
|
2629
|
+
(0, import_react3.useEffect)(() => {
|
|
1780
2630
|
if (state.issue?.kind === "domain" && state.issue.code === "validation") {
|
|
1781
2631
|
if (state.issue.field === "id") inputRef.current?.focus();
|
|
1782
2632
|
else editorRef.current?.focus();
|
|
@@ -1787,91 +2637,107 @@ function ProfilesSection(props) {
|
|
|
1787
2637
|
if (snapshot2?.selectionError !== void 0 && !selectionConflict) selection = t("appliedInvalid");
|
|
1788
2638
|
else if (snapshot2?.selectedId !== null && snapshot2?.selectedId !== void 0) selection = t("appliedProfile", { id: snapshot2.selectedId, revision: snapshot2.appliedRevision?.slice(0, 12) ?? "—" });
|
|
1789
2639
|
const notice = state.notice === null ? "" : t(state.notice.key === "reset" ? "resetDone" : state.notice.key, { id: state.notice.id });
|
|
1790
|
-
return /* @__PURE__ */ (0,
|
|
1791
|
-
/* @__PURE__ */ (0,
|
|
1792
|
-
/* @__PURE__ */ (0,
|
|
1793
|
-
/* @__PURE__ */ (0,
|
|
1794
|
-
/* @__PURE__ */ (0,
|
|
1795
|
-
/* @__PURE__ */ (0,
|
|
1796
|
-
|
|
2640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "dsmm-profiles", "aria-labelledby": `${prefix}-title`, "aria-busy": state.busy !== null, children: [
|
|
2641
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { id: `${prefix}-title`, children: t("title") }),
|
|
2642
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: t("description") }),
|
|
2643
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { id: `${prefix}-global`, children: t("globalScope") }),
|
|
2644
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "dsmm-hint", children: t("newSessions") }),
|
|
2645
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { "data-dsmm-selection": true, children: selection }),
|
|
2646
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-actions", children: [
|
|
2647
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled: disabled || snapshot2 === null, onClick: () => {
|
|
1797
2648
|
void props.create();
|
|
1798
2649
|
}, children: t("new") }),
|
|
1799
|
-
/* @__PURE__ */ (0,
|
|
2650
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled, onClick: () => {
|
|
1800
2651
|
void props.refresh();
|
|
1801
2652
|
}, children: t(state.busy === "refresh" ? "refreshing" : "refresh") }),
|
|
1802
|
-
/* @__PURE__ */ (0,
|
|
2653
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled: disabled || !reconcilable || snapshot2?.selectedId === null && !selectionConflict, onClick: () => {
|
|
1803
2654
|
void props.reset();
|
|
1804
2655
|
}, children: t(state.busy === "reset" ? "resetting" : "reset") })
|
|
1805
2656
|
] }),
|
|
1806
|
-
snapshot2 !== null && /* @__PURE__ */ (0,
|
|
1807
|
-
/* @__PURE__ */ (0,
|
|
1808
|
-
/* @__PURE__ */ (0,
|
|
2657
|
+
snapshot2 !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-field", children: [
|
|
2658
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { htmlFor: `${prefix}-select`, children: t("editorSelect") }),
|
|
2659
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("select", { ref: selectRef, id: `${prefix}-select`, disabled, value: editor?.revision == null ? "" : editor.id, onChange: (event) => {
|
|
1809
2660
|
if (event.currentTarget.value) void props.open(event.currentTarget.value);
|
|
1810
2661
|
}, children: [
|
|
1811
|
-
/* @__PURE__ */ (0,
|
|
1812
|
-
snapshot2.profiles.map((profile, index) => /* @__PURE__ */ (0,
|
|
2662
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "", children: t(editor?.revision === null ? "newDraft" : "choose") }),
|
|
2663
|
+
snapshot2.profiles.map((profile, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("option", { value: profile.id, children: [
|
|
1813
2664
|
profile.label === void 0 ? profile.id : `${profile.label} (${profile.id})`,
|
|
1814
2665
|
profile.error === void 0 ? "" : ` — ${t("invalidProfile", { id: profile.id })}`
|
|
1815
2666
|
] }, `${index}:${profile.id}`))
|
|
1816
2667
|
] }),
|
|
1817
|
-
snapshot2.profiles.length === 0 && /* @__PURE__ */ (0,
|
|
2668
|
+
snapshot2.profiles.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "dsmm-hint", children: t("empty") })
|
|
1818
2669
|
] }),
|
|
1819
|
-
state.pendingEditor !== null && /* @__PURE__ */ (0,
|
|
2670
|
+
state.pendingEditor !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-confirm", role: "group", "aria-labelledby": `${prefix}-confirm`, onKeyDown: (event) => {
|
|
1820
2671
|
if (event.key === "Escape") {
|
|
1821
2672
|
event.preventDefault();
|
|
1822
2673
|
props.cancelDiscard();
|
|
1823
2674
|
}
|
|
1824
2675
|
}, children: [
|
|
1825
|
-
/* @__PURE__ */ (0,
|
|
1826
|
-
/* @__PURE__ */ (0,
|
|
1827
|
-
/* @__PURE__ */ (0,
|
|
2676
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: `${prefix}-confirm`, children: t("discardPrompt") }),
|
|
2677
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-actions", children: [
|
|
2678
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", onClick: () => {
|
|
1828
2679
|
void props.discardAndOpen();
|
|
1829
2680
|
}, children: t("discard") }),
|
|
1830
|
-
/* @__PURE__ */ (0,
|
|
2681
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { ref: cancelRef, type: "button", variant: "primary", onClick: props.cancelDiscard, children: t("cancel") })
|
|
1831
2682
|
] })
|
|
1832
2683
|
] }),
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
2684
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SessionScope, { state, actions: props, t }),
|
|
2685
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-catalog", children: [
|
|
2686
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { children: t("catalogTitle") }),
|
|
2687
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "dsmm-hint", children: t("catalogHint") }),
|
|
2688
|
+
state.catalogUnavailable && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "dsmm-hint", children: t("catalogUnavailable") }),
|
|
2689
|
+
state.catalog?.failures.map((failure) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "dsmm-hint", children: t("catalogFailure", { name: failure.name, id: failure.id }) }, failure.id)),
|
|
2690
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled: state.catalogBusy, onClick: () => {
|
|
2691
|
+
void props.refreshCatalog();
|
|
2692
|
+
}, children: t(state.catalogBusy ? "catalogRefreshing" : "catalogRefresh") })
|
|
2693
|
+
] }),
|
|
2694
|
+
editor !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-editor", children: [
|
|
2695
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-field", children: [
|
|
2696
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { htmlFor: `${prefix}-id`, children: t("profileId") }),
|
|
2697
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Input, { ref: inputRef, id: `${prefix}-id`, className: "dsmm-input", value: editor.id, disabled: disabled || editor.revision !== null, "aria-invalid": idInvalid || void 0, "aria-describedby": `${prefix}-id-hint${idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editId(event.currentTarget.value) }),
|
|
2698
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: `${prefix}-id-hint`, className: "dsmm-hint", children: t("idHint") })
|
|
1838
2699
|
] }),
|
|
1839
|
-
/* @__PURE__ */ (0,
|
|
1840
|
-
|
|
1841
|
-
/* @__PURE__ */ (0,
|
|
1842
|
-
/* @__PURE__ */ (0,
|
|
1843
|
-
|
|
2700
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StructuredEditor, { state, actions: props, disabled, t }, state.editorEpoch),
|
|
2701
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("details", { className: "dsmm-advanced", open: true, children: [
|
|
2702
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("summary", { children: t("advanced") }),
|
|
2703
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-field", children: [
|
|
2704
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { htmlFor: `${prefix}-content`, children: t("configuration") }),
|
|
2705
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("textarea", { ref: editorRef, id: `${prefix}-content`, rows: 12, spellCheck: false, value: editor.content, disabled, "aria-invalid": rawInvalid || invalid && !idInvalid || void 0, "aria-describedby": `${prefix}-content-hint ${prefix}-structural-hint${invalid && !idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editContent(event.currentTarget.value) }),
|
|
2706
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: `${prefix}-content-hint`, className: "dsmm-hint", children: t("configurationHint") }),
|
|
2707
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: `${prefix}-structural-hint`, className: "dsmm-hint", children: t("structuralHint") })
|
|
2708
|
+
] })
|
|
1844
2709
|
] }),
|
|
1845
|
-
/* @__PURE__ */ (0,
|
|
1846
|
-
/* @__PURE__ */ (0,
|
|
1847
|
-
|
|
2710
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { "data-dsmm-editor-state": true, children: t(state.dirty ? "dirty" : applied ? "savedApplied" : "savedNotApplied") }),
|
|
2711
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: `${prefix}-global-action`, className: "dsmm-hint", children: t("globalActionHint") }),
|
|
2712
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-actions", children: [
|
|
2713
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "primary", disabled: disabled || !state.dirty || snapshot2 === null || state.invalidFields.length > 0, onClick: () => {
|
|
1848
2714
|
void props.save();
|
|
1849
2715
|
}, children: t(state.busy === "save" ? "saving" : "save") }),
|
|
1850
|
-
/* @__PURE__ */ (0,
|
|
2716
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", "aria-describedby": `${prefix}-global-action`, disabled: disabled || state.dirty || editor.revision === null || !reconcilable || applied && !selectionConflict, onClick: () => {
|
|
1851
2717
|
void props.apply();
|
|
1852
2718
|
}, children: t(state.busy === "apply" ? "applying" : "apply") }),
|
|
1853
|
-
editor.revision !== null && /* @__PURE__ */ (0,
|
|
2719
|
+
editor.revision !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled, onClick: () => {
|
|
1854
2720
|
void props.reload();
|
|
1855
2721
|
}, children: t("reload") })
|
|
1856
2722
|
] })
|
|
1857
2723
|
] }),
|
|
1858
|
-
state.issue !== null && /* @__PURE__ */ (0,
|
|
1859
|
-
/* @__PURE__ */ (0,
|
|
1860
|
-
state.issue.kind === "domain" && state.issue.message !== void 0 && /* @__PURE__ */ (0,
|
|
2724
|
+
state.issue !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-issue", id: `${prefix}-issue`, role: "alert", children: [
|
|
2725
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: t(issueKey(state.issue)) }),
|
|
2726
|
+
state.issue.kind === "domain" && state.issue.message !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
|
|
1861
2727
|
t("details"),
|
|
1862
2728
|
": ",
|
|
1863
2729
|
state.issue.message
|
|
1864
2730
|
] })
|
|
1865
2731
|
] }),
|
|
1866
|
-
snapshot2?.selectionError !== void 0 && /* @__PURE__ */ (0,
|
|
1867
|
-
/* @__PURE__ */ (0,
|
|
2732
|
+
snapshot2?.selectionError !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-issue", children: [
|
|
2733
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
|
|
1868
2734
|
t("details"),
|
|
1869
2735
|
": ",
|
|
1870
2736
|
snapshot2.selectionError.message
|
|
1871
2737
|
] }),
|
|
1872
|
-
/* @__PURE__ */ (0,
|
|
2738
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: t(selectionConflict ? "selectionConflict" : "retry") })
|
|
1873
2739
|
] }),
|
|
1874
|
-
/* @__PURE__ */ (0,
|
|
2740
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.busy === "refresh" && snapshot2 === null ? t("loading") : state.busy === "read" ? t("reading") : notice })
|
|
1875
2741
|
] });
|
|
1876
2742
|
}
|
|
1877
2743
|
|
|
@@ -1879,11 +2745,22 @@ function ProfilesSection(props) {
|
|
|
1879
2745
|
var PROFILE_STYLES = `
|
|
1880
2746
|
.dsmm-profiles{width:100%;max-width:760px;min-width:0;display:flex;flex-direction:column;gap:12px;font-family:var(--dsw-font-family);font-size:14px;line-height:22px;color:var(--dsw-alias-label-primary)}
|
|
1881
2747
|
.dsmm-profiles h2{margin:0;font-size:18px;font-weight:600}
|
|
2748
|
+
.dsmm-profiles h3,.dsmm-profiles legend{margin:0;font-size:14px;font-weight:500;line-height:22px}
|
|
2749
|
+
.dsmm-profiles :is(label,legend,summary){min-width:0;max-width:100%;overflow-wrap:anywhere}
|
|
2750
|
+
.dsmm-profiles :is(.dsmm-structured,.dsmm-session-scope,.dsmm-catalog,.dsmm-policy-fields){min-width:0;display:flex;flex-direction:column;gap:12px}
|
|
2751
|
+
.dsmm-profiles fieldset{min-width:0;margin:0;padding:12px;border:1px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);display:flex;flex-direction:column;gap:12px}
|
|
2752
|
+
.dsmm-profiles .dsmm-route-fields{display:flex;flex-wrap:wrap;gap:12px;min-width:0}
|
|
2753
|
+
.dsmm-profiles .dsmm-route-fields>.dsmm-field{flex:1 1 240px;max-width:100%}
|
|
2754
|
+
.dsmm-profiles .dsmm-route-fields select{width:100%}
|
|
2755
|
+
.dsmm-profiles summary{cursor:pointer;color:var(--dsw-alias-label-primary);min-height:32px;line-height:32px}
|
|
2756
|
+
.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}
|
|
2757
|
+
.dsmm-profiles .dsmm-advanced[open]>div{margin-top:8px}
|
|
2758
|
+
.dsmm-header-profiles{width:auto;max-width:760px}
|
|
1882
2759
|
.dsmm-profiles p{margin:0;overflow-wrap:anywhere}
|
|
1883
2760
|
.dsmm-profiles .dsmm-hint{color:var(--dsw-alias-label-secondary)}
|
|
1884
2761
|
.dsmm-profiles .dsmm-field{min-width:0;display:flex;flex-direction:column;gap:6px}
|
|
1885
2762
|
.dsmm-profiles .dsmm-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
|
|
1886
|
-
.dsmm-profiles
|
|
2763
|
+
.dsmm-profiles button{max-width:100%;white-space:normal;overflow-wrap:anywhere;min-height:36px;height:auto}
|
|
1887
2764
|
.dsmm-profiles .dsmm-input{width:100%;min-width:0;box-sizing:border-box;border-color:var(--dsw-alias-label-secondary)}
|
|
1888
2765
|
.dsmm-profiles .dsmm-input input{width:100%;min-width:0;font:inherit;color:inherit}
|
|
1889
2766
|
.dsmm-profiles select,.dsmm-profiles textarea{box-sizing:border-box;min-width:0;max-width:100%;font:inherit;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-label-secondary);border-radius:var(--dsw-radius-md)}
|
|
@@ -1924,6 +2801,24 @@ async function apply(ctx) {
|
|
|
1924
2801
|
locale: NS,
|
|
1925
2802
|
inject: () => ({ hooks: { profiles: controller.store }, ...controller.actions })
|
|
1926
2803
|
}, ProfilesSection));
|
|
2804
|
+
void profileCtx.inject(["remote.session"], (catalogCtx) => {
|
|
2805
|
+
controller.attachCatalog(catalogCtx.remote.session);
|
|
2806
|
+
catalogCtx.effect(() => () => controller.attachCatalog(null), "dsmm: native catalog lifetime");
|
|
2807
|
+
});
|
|
2808
|
+
void profileCtx.inject(["uiSession"], (sessionCtx) => {
|
|
2809
|
+
const source = sessionCtx.uiSession.adapter.current;
|
|
2810
|
+
const update = () => controller.setSession(source.getSnapshot().key ?? null);
|
|
2811
|
+
update();
|
|
2812
|
+
sessionCtx.effect(() => source.subscribe(update), "dsmm: current native session");
|
|
2813
|
+
sessionCtx.effect(() => () => controller.setSession(null), "dsmm: native session withdrawal");
|
|
2814
|
+
sessionCtx.slots.inject("conversation.session.header.utilities", () => sessionCtx.slots.register({
|
|
2815
|
+
name: "conversation.session.header.utilities",
|
|
2816
|
+
id: "dsmm-session-profiles",
|
|
2817
|
+
order: 30,
|
|
2818
|
+
locale: NS,
|
|
2819
|
+
inject: () => ({ hooks: { profiles: controller.store }, ...controller.actions })
|
|
2820
|
+
}, SessionProfiles));
|
|
2821
|
+
});
|
|
1927
2822
|
void controller.refresh();
|
|
1928
2823
|
});
|
|
1929
2824
|
}
|