@dsmm/dsmm 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -12
- package/docs/compatibility.md +8 -6
- package/docs/migration-from-ocmm.md +8 -0
- package/docs/model-routing.md +22 -6
- package/docs/profiles.md +23 -9
- package/docs/releasing.md +27 -15
- package/docs/runtime-recovery.md +41 -14
- package/docs/settings-status.md +10 -8
- package/lib/client/ProfilesSection.js +7 -3
- package/lib/client/SessionProfiles.d.ts +19 -0
- package/lib/client/SessionProfiles.js +55 -0
- package/lib/client/StructuredEditor.d.ts +11 -0
- package/lib/client/StructuredEditor.js +74 -0
- package/lib/client/controller.d.ts +68 -1
- package/lib/client/controller.js +282 -11
- package/lib/client/index.d.ts +3 -1
- package/lib/client/index.js +47 -0
- package/lib/client/locales.d.ts +109 -0
- package/lib/client/locales.js +56 -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 +14 -1
- package/lib/client.js +1215 -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 +109 -23
- package/lib/profile-remote.d.ts +7 -1
- package/lib/profile-remote.js +117 -2
- package/lib/profile-rpc.d.ts +9 -1
- package/lib/profile-rpc.js +99 -2
- package/lib/profile-runtime.d.ts +25 -5
- package/lib/profile-runtime.js +193 -31
- package/lib/profile-store.d.ts +19 -1
- package/lib/profile-store.js +120 -10
- package/lib/profile-types.d.ts +43 -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 +216 -52
- package/lib/settings.d.ts +27 -1
- package/lib/settings.js +29 -7
- package/lib/status.d.ts +10 -2
- package/lib/status.js +36 -10
- package/package.json +8 -1
package/lib/client/locales.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const NS = "settings.dsmm-profiles";
|
|
2
2
|
export const en = {
|
|
3
3
|
title: "Deepwork Profiles", description: "Save independent runtime configurations and choose which one new sessions use.",
|
|
4
|
-
newSessions: "
|
|
4
|
+
newSessions: "Global apply and reset affect future unscoped sessions only. Current-session actions below are separate. A cold resume retains an explicit saved session choice; otherwise it inherits the global default.",
|
|
5
5
|
editorSelect: "Profile to edit", choose: "Choose a profile", newDraft: "New unsaved profile", new: "New profile",
|
|
6
6
|
profileId: "Profile ID (name)", idHint: "Use 1–64 lowercase letters, digits, hyphens or underscores. The ID cannot be changed after saving. Add an optional display label in the JSONC document.",
|
|
7
7
|
configuration: "Runtime configuration (JSONC)", configurationHint: "Document: version 1, matching id, optional label, and settings. Supported runtime settings: defaultActive, roleRouting, workflow, guards, runtimeRecovery, and both DeepSeek families’ calibration, default-effort and max-preset policies.",
|
|
@@ -21,10 +21,41 @@ export const en = {
|
|
|
21
21
|
unavailable: "The native profile service is unavailable. Your draft is kept. Refresh after the Host reconnects or Deepwork is enabled.",
|
|
22
22
|
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.",
|
|
23
23
|
invalidProfile: "Unavailable profile: {id}", details: "Host diagnostic", retry: "Resolve the diagnostic, refresh profiles, then retry.",
|
|
24
|
+
globalScope: "Global default for future sessions", sessionScope: "Current native session", sessionSelect: "Current-session profile",
|
|
25
|
+
globalActionHint: "Apply saved profile below changes the global default for future unscoped sessions only. It does not apply to the current session.",
|
|
26
|
+
headerProfile: "Profile", headerProfileLabel: "Current-session profile (header)", headerCaptured: "captured global default", headerSavedUnavailable: "saved profile unavailable",
|
|
27
|
+
headerLoading: "Loading profile…", headerApplying: "Applying profile…", headerApplied: "Profile applied.", headerBusy: "Session is busy.", headerUnavailable: "Profile unavailable.", headerDraft: "Save or discard the draft in Settings.", headerConflict: "Profile changed elsewhere. Refresh in Settings.", headerRefused: "Profile change unconfirmed. Check Settings.",
|
|
28
|
+
headerKeepModelGroup: "Switch profile — keep current model", headerUseModelGroup: "Switch and use profile model", headerModelDefaultHint: "Normal switching preserves the current model. Explicit switch-and-use-model also saves the native model default, like the Models tab.",
|
|
29
|
+
headerNoProfileModel: "Profile applied; no main model configured. Current model kept.", headerModelUnconfirmed: "Profile applied; model change unconfirmed. Check Models/Settings.", headerAppliedWithModel: "Profile and native model applied.",
|
|
30
|
+
headerModelChoiceChanged: "Profile applied; newer native model choice kept.",
|
|
31
|
+
noSession: "No native session is selected. Session Apply is disabled; global defaults and drafts remain editable.",
|
|
32
|
+
sessionUnavailable: "The current session could not be confirmed. Refresh its state before retrying; the prior policy is kept.",
|
|
33
|
+
sessionBusy: "Switching is unavailable: {reason}. The Host must reserve a truly idle ordinary session before applying.",
|
|
34
|
+
sessionState: "Session {id}: {profile}; scope {scope}; admission epoch {epoch}.", sessionBaseline: "deployment baseline",
|
|
35
|
+
sessionGlobalCaptured: "captured global default (no explicit session override)",
|
|
36
|
+
sessionAdmittedProfile: "{id} (revision {revision})", sessionFutureDefault: "Global default for future unscoped sessions: {profile}. This does not change this session's admission.",
|
|
37
|
+
sessionConflict: "The session selection or admission epoch changed elsewhere. The prior display and draft are kept. Refresh current-session state before applying again.",
|
|
38
|
+
sessionApply: "Apply profile to current session", sessionApplying: "Applying current-session profile…", sessionReset: "Pin baseline for current session", sessionResetting: "Pinning current-session baseline…", sessionRefresh: "Refresh current-session state",
|
|
39
|
+
sessionApplied: "Applied the saved revision to this session only. Global default and existing children were not changed.", sessionResetDone: "Pinned the deployment baseline for this session only. Global default was not changed.",
|
|
40
|
+
sessionAppliedWithModel: "Applied this session profile and explicitly selected its native main model. Native model-default persistence follows the Models tab; the global profile default was not changed.",
|
|
41
|
+
sessionDirty: "Save or explicitly discard the editor draft before applying a current-session choice.",
|
|
42
|
+
roleState: "Admitted route {route}; strategy {strategy}; retries {retries}; rate-limit failures {failures}; switches {switches}; total delay {delay} ms.",
|
|
43
|
+
catalogTitle: "Native model catalog", 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.",
|
|
44
|
+
catalogUnavailable: "The native catalog is unavailable. Manual provider/model/effort fields and advanced JSONC remain available.", catalogRefresh: "Refresh model catalog", catalogRefreshing: "Refreshing model catalog…", catalogFailure: "Provider catalog unavailable: {name} ({id}).",
|
|
45
|
+
profileLabel: "Profile display label", defaultActive: "Default Deepwork mode", activeHint: "This default does not erase an explicit saved session mode.", enabled: "Enabled", disabled: "Disabled", inherit: "Inherit deployment baseline",
|
|
46
|
+
profileDefaults: "Profile runtime defaults", roleSelect: "Agent role to edit", rolesUnavailable: "Native role inventory unavailable — use advanced JSONC", roleEnabled: "Enabled in the native deployment", roleDisabled: "Disabled in the native deployment",
|
|
47
|
+
strategy: "{name} strategy", inheritStrategy: "Inherit ({value})", startupLock: "startup-lock — keep the admitted route", rateFallback: "rate-limit-fallback — ordered rollover at threshold",
|
|
48
|
+
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.",
|
|
49
|
+
retryField: "{name} {field}", inheritNumber: "Inherit {value}", retryBounds: "Integer {min}–{max}; inherited value {value}.", unknownDefault: "unavailable",
|
|
50
|
+
retryCount: "retry count", initialDelay: "initial delay (ms)", maxDelay: "maximum delay (ms)", totalWait: "total wait budget (ms)", switchThreshold: "rate-limit failures before switch", maxSwitches: "maximum switches",
|
|
51
|
+
primaryMode: "{name} primary route", inheritRoute: "Inherit native/deployment route", configuredRoute: "Configure primary route", primaryName: "{name} primary",
|
|
52
|
+
fallbackMode: "{name} fallback chain", inheritChain: "Inherit deployment fallback chain", configuredChain: "Explicit ordered fallback chain", emptyChain: "Explicitly empty chain: no configured fallback routes.", fallbackName: "{name} fallback {index}", addFallback: "Add fallback for {name}", removeFallback: "Remove {name}", moveUp: "Move up {name}", moveDown: "Move down {name}",
|
|
53
|
+
routeProvider: "{name} provider", routeModel: "{name} model", routeEffort: "{name} exact effort", manualProvider: "{name} manual provider", manualModel: "{name} manual model", manualEffort: "{name} manual exact effort", manual: "Enter manual identifier", manualValue: "Manual / unlisted: {value}", unset: "not set", effortDefault: "Native default (omit exact effort)", 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.",
|
|
54
|
+
advanced: "Advanced JSONC", rawInvalid: "Structured editing is unavailable for this invalid raw draft. Correct Advanced JSONC; no fields, comments or bytes have been normalized.", invalidNumber: "Correct this bounded integer before saving or changing roles. The invalid value has not replaced the saved draft policy.",
|
|
24
55
|
};
|
|
25
56
|
export const zh = {
|
|
26
57
|
title: "Deepwork 配置档", description: "保存独立的运行时配置,并选择新会话使用的配置档。",
|
|
27
|
-
newSessions: "
|
|
58
|
+
newSessions: "全局应用和重置仅影响之后没有独立选择的新会话。下方当前会话操作相互独立。冷恢复保留明确保存的会话选择,否则继承全局默认值。",
|
|
28
59
|
editorSelect: "要编辑的配置档", choose: "选择配置档", newDraft: "新的未保存配置档", new: "新建配置档",
|
|
29
60
|
profileId: "配置档 ID(名称)", idHint: "使用 1–64 个小写字母、数字、连字符或下划线。保存后不能修改 ID。可在 JSONC 文档中添加可选的显示名称 label。",
|
|
30
61
|
configuration: "运行时配置(JSONC)", configurationHint: "文档包含 version: 1、相同的 id、可选 label 和 settings。支持 defaultActive、roleRouting、workflow、guards、runtimeRecovery,以及两个 DeepSeek 系列的校准、默认推理强度和最高强度预设策略。",
|
|
@@ -44,5 +75,28 @@ export const zh = {
|
|
|
44
75
|
unavailable: "原生配置档服务不可用。草稿已保留。Host 重新连接或启用 Deepwork 后请刷新。",
|
|
45
76
|
transport: "原生连接无法确认此操作。草稿已保留。重试之前请刷新 Host 状态;不要假定保存或应用已完成。",
|
|
46
77
|
invalidProfile: "不可用配置档:{id}", details: "Host 诊断", retry: "请解决诊断问题,刷新配置档后重试。",
|
|
78
|
+
globalScope: "未来会话的全局默认值", sessionScope: "当前原生会话", sessionSelect: "当前会话配置档",
|
|
79
|
+
globalActionHint: "下方应用已保存配置档仅改变未来没有独立选择的会话的全局默认值,不会应用到当前会话。",
|
|
80
|
+
headerProfile: "配置档", headerProfileLabel: "当前会话配置档(会话栏)", headerCaptured: "已捕获的全局默认值", headerSavedUnavailable: "保存的配置档不可用",
|
|
81
|
+
headerLoading: "加载配置档…", headerApplying: "应用配置档…", headerApplied: "配置档已应用。", headerBusy: "会话忙碌。", headerUnavailable: "配置档不可用。", headerDraft: "请在设置中保存或丢弃草稿。", headerConflict: "配置档已在其他位置改变,请在设置中刷新。", headerRefused: "未确认配置档更改,请检查设置。",
|
|
82
|
+
headerKeepModelGroup: "切换配置档 — 保留当前模型", headerUseModelGroup: "切换并使用配置档模型", headerModelDefaultHint: "普通切换保留当前模型。明确切换并使用模型还会像模型页一样保存原生模型默认值。", headerNoProfileModel: "配置档已应用,未配置主模型。当前模型已保留。", headerModelUnconfirmed: "配置档已应用,模型更改未确认。请检查模型或设置页。", headerAppliedWithModel: "配置档和原生模型已应用。",
|
|
83
|
+
headerModelChoiceChanged: "配置档已应用,已保留更新的原生模型选择。",
|
|
84
|
+
noSession: "未选择原生会话。会话应用已禁用;仍可编辑全局默认值和草稿。", sessionUnavailable: "无法确认当前会话。重试前请刷新状态;原策略已保留。", sessionBusy: "暂不可切换:{reason}。Host 必须先保留真正空闲的普通会话。", sessionState: "会话 {id}:{profile};范围 {scope};准入代次 {epoch}。", sessionBaseline: "部署基线",
|
|
85
|
+
sessionGlobalCaptured: "已捕获的全局默认值(没有明确会话覆盖)",
|
|
86
|
+
sessionAdmittedProfile: "{id}(修订 {revision})", sessionFutureDefault: "未来没有独立选择的会话的全局默认值:{profile}。这不会改变当前会话的准入。",
|
|
87
|
+
sessionConflict: "会话选择或准入代次已在其他位置改变。原显示和草稿已保留。再次应用前请刷新当前会话状态。",
|
|
88
|
+
sessionApply: "应用配置档到当前会话", sessionApplying: "正在应用当前会话配置档…", sessionReset: "为当前会话固定基线", sessionResetting: "正在固定当前会话基线…", sessionRefresh: "刷新当前会话状态", sessionApplied: "已仅对此会话应用保存的修订。全局默认值和已有子会话未改变。", sessionResetDone: "已仅对此会话固定部署基线。全局默认值未改变。", sessionDirty: "应用当前会话选择之前,请保存或明确丢弃编辑器草稿。",
|
|
89
|
+
sessionAppliedWithModel: "已应用此会话配置档,并明确选择其原生主模型。模型默认值像模型页一样保存;全局配置档默认值未改变。",
|
|
90
|
+
roleState: "准入路由 {route};策略 {strategy};重试 {retries};限流失败 {failures};切换 {switches};累计延迟 {delay} 毫秒。",
|
|
91
|
+
catalogTitle: "原生模型目录", catalogHint: "目录仅供参考,不是网络或账户健康检查。未列出或手动路由仍可编辑;刷新不会改变草稿或原生模型默认值。", catalogUnavailable: "原生模型目录不可用。仍可使用手动提供商、模型、强度字段和高级 JSONC。", catalogRefresh: "刷新模型目录", catalogRefreshing: "正在刷新模型目录…", catalogFailure: "提供商目录不可用:{name}({id})。",
|
|
92
|
+
profileLabel: "配置档显示名称", defaultActive: "默认 Deepwork 模式", activeHint: "此默认值不会抹除已明确保存的会话模式。", enabled: "启用", disabled: "禁用", inherit: "继承部署基线", profileDefaults: "配置档运行时默认值", roleSelect: "要编辑的 Agent 角色", rolesUnavailable: "原生角色列表不可用,请使用高级 JSONC", roleEnabled: "原生部署中已启用", roleDisabled: "原生部署中已禁用",
|
|
93
|
+
strategy: "{name} 策略", inheritStrategy: "继承({value})", startupLock: "startup-lock — 保留准入路由", rateFallback: "rate-limit-fallback — 达到阈值后按顺序切换", strategyHint: "两种策略均使用有限且已证明无输出的 RATE_LIMIT 重试。普通、认证或配额失败不允许切换模型。数字留空表示继承,零是明确值。", retryField: "{name} {field}", inheritNumber: "继承 {value}", retryBounds: "整数 {min}–{max};继承值 {value}。", unknownDefault: "不可用",
|
|
94
|
+
retryCount: "重试次数", initialDelay: "初始延迟(毫秒)", maxDelay: "最大单次延迟(毫秒)", totalWait: "累计等待上限(毫秒)", switchThreshold: "切换前的限流失败次数", maxSwitches: "最大切换次数",
|
|
95
|
+
primaryMode: "{name} 主路由", inheritRoute: "继承原生或部署路由", configuredRoute: "配置主路由", primaryName: "{name} 主路由", fallbackMode: "{name} 备用链", inheritChain: "继承部署备用链", configuredChain: "明确的有序备用链", emptyChain: "明确为空的备用链:没有已配置备用路由。", fallbackName: "{name} 备用 {index}", addFallback: "为 {name} 添加备用路由", removeFallback: "移除 {name}", moveUp: "上移 {name}", moveDown: "下移 {name}",
|
|
96
|
+
routeProvider: "{name} 提供商", routeModel: "{name} 模型", routeEffort: "{name} 精确强度", manualProvider: "{name} 手动提供商", manualModel: "{name} 手动模型", manualEffort: "{name} 手动精确强度", manual: "输入手动标识", manualValue: "手动或未列出:{value}", unset: "未设置", effortDefault: "原生默认值(省略精确强度)", effortChangeHint: "明确更改提供商或模型会清除该路由的精确强度。刷新目录会保留所有配置值;需要时请重新选择精确强度。", advanced: "高级 JSONC", rawInvalid: "原始草稿无效,暂不可结构化编辑。请修正高级 JSONC;字段、注释和字节均未自动规范化。", invalidNumber: "保存或切换角色之前,请修正此有界整数。无效值尚未替换草稿中的策略。",
|
|
97
|
+
};
|
|
98
|
+
export const RETRY_FIELD_LABEL_KEYS = {
|
|
99
|
+
maxRetries: "retryCount", initialDelayMs: "initialDelay", maxDelayMs: "maxDelay",
|
|
100
|
+
maxTotalDelayMs: "totalWait", switchAfterRateLimits: "switchThreshold", maxSwitches: "maxSwitches",
|
|
47
101
|
};
|
|
48
102
|
//# sourceMappingURL=locales.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
|
|
2
|
+
import type { SessionProfileSnapshot } from "../profile-types.js";
|
|
3
|
+
/** Presentation only: admitted identity never substitutes for sidecar CAS. */
|
|
4
|
+
export declare function sessionProfileLabels(session: SessionProfileSnapshot, t: PropsLocale<"settings.dsmm-profiles">["t"]): {
|
|
5
|
+
admitted: string;
|
|
6
|
+
futureDefault: string;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=session-labels.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Presentation only: admitted identity never substitutes for sidecar CAS. */
|
|
2
|
+
export function sessionProfileLabels(session, t) {
|
|
3
|
+
const admitted = session.admittedSelection;
|
|
4
|
+
const profile = admitted === undefined && session.scope === "global-default" ? t("sessionGlobalCaptured")
|
|
5
|
+
: (admitted ?? session.selection).selectedId === null ? t("sessionBaseline")
|
|
6
|
+
: t("sessionAdmittedProfile", { id: (admitted ?? session.selection).selectedId, revision: (admitted ?? session.selection).appliedRevision?.slice(0, 12) ?? "—" });
|
|
7
|
+
const future = session.globalDefault;
|
|
8
|
+
return {
|
|
9
|
+
admitted: t("sessionState", { id: session.sessionId, profile, scope: session.scope, epoch: session.admissionEpoch }),
|
|
10
|
+
futureDefault: t("sessionFutureDefault", { profile: future.selectedId === null ? t("sessionBaseline") : t("sessionAdmittedProfile", { id: future.selectedId, revision: future.appliedRevision?.slice(0, 12) ?? "—" }) }),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=session-labels.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DsmmRoleRoutingConfig } from "../settings.js";
|
|
2
|
+
import type { DsmmRateLimitPolicy, DsmmRuntimePolicySettings } from "../routing-policy.js";
|
|
3
|
+
export type JsonPath = (string | number)[];
|
|
4
|
+
export interface StructuredDocument {
|
|
5
|
+
label?: string;
|
|
6
|
+
settings: Record<string, unknown>;
|
|
7
|
+
roleRouting: Record<string, DsmmRoleRoutingConfig>;
|
|
8
|
+
runtimePolicy: {
|
|
9
|
+
strategy?: DsmmRuntimePolicySettings["strategy"];
|
|
10
|
+
rateLimit?: Partial<DsmmRateLimitPolicy>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Read-only projection. Malformed raw drafts cannot be rewritten by the form. */
|
|
14
|
+
export declare function structuredDocument(content: string): StructuredDocument | null;
|
|
15
|
+
/** Only the named path changes; comments/unrelated raw JSONC remain untouched. */
|
|
16
|
+
export declare function editStructuredPath(content: string, path: JsonPath, value: unknown): string | null;
|
|
17
|
+
export declare function moveFallback(content: string, role: string, from: number, to: number): string | null;
|
|
18
|
+
//# sourceMappingURL=structured.d.ts.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { applyEdits, findNodeAtLocation, modify, parse, parseTree } from "jsonc-parser";
|
|
2
|
+
import { normalizeRateLimitOverrides, normalizeRoutingStrategy } from "../routing-policy.js";
|
|
3
|
+
function record(value) {
|
|
4
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
function route(value) {
|
|
7
|
+
return record(value) && typeof value.provider === "string" && typeof value.model === "string"
|
|
8
|
+
&& (value.reasoningEffort === undefined || typeof value.reasoningEffort === "string")
|
|
9
|
+
&& Object.keys(value).every((key) => ["provider", "model", "reasoningEffort"].includes(key));
|
|
10
|
+
}
|
|
11
|
+
function validTree(node, depth = 0) {
|
|
12
|
+
if (depth > 32)
|
|
13
|
+
return false;
|
|
14
|
+
if (node.type === "object") {
|
|
15
|
+
const seen = new Set();
|
|
16
|
+
for (const property of node.children ?? []) {
|
|
17
|
+
const key = property.children?.[0]?.value;
|
|
18
|
+
if (typeof key !== "string" || seen.has(key) || ["__proto__", "prototype", "constructor"].includes(key))
|
|
19
|
+
return false;
|
|
20
|
+
seen.add(key);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return (node.children ?? []).every((child) => validTree(child, depth + 1));
|
|
24
|
+
}
|
|
25
|
+
/** Read-only projection. Malformed raw drafts cannot be rewritten by the form. */
|
|
26
|
+
export function structuredDocument(content) {
|
|
27
|
+
const errors = [];
|
|
28
|
+
const tree = parseTree(content, errors, { allowTrailingComma: true });
|
|
29
|
+
if (errors.length !== 0 || tree === undefined || !validTree(tree))
|
|
30
|
+
return null;
|
|
31
|
+
const document = parse(content, errors, { allowTrailingComma: true });
|
|
32
|
+
if (errors.length !== 0 || !record(document) || document.version !== 1 || typeof document.id !== "string"
|
|
33
|
+
|| !record(document.settings) || (document.label !== undefined && typeof document.label !== "string"))
|
|
34
|
+
return null;
|
|
35
|
+
const settings = document.settings;
|
|
36
|
+
if (settings.defaultActive !== undefined && typeof settings.defaultActive !== "boolean")
|
|
37
|
+
return null;
|
|
38
|
+
if (settings.roleRouting !== undefined && !record(settings.roleRouting))
|
|
39
|
+
return null;
|
|
40
|
+
if (settings.runtimePolicy !== undefined && !record(settings.runtimePolicy))
|
|
41
|
+
return null;
|
|
42
|
+
const runtimePolicy = settings.runtimePolicy ?? {};
|
|
43
|
+
const policies = settings.roleRouting ?? {};
|
|
44
|
+
try {
|
|
45
|
+
if (Object.keys(runtimePolicy).some((key) => key !== "strategy" && key !== "rateLimit"))
|
|
46
|
+
return null;
|
|
47
|
+
if (runtimePolicy.strategy !== undefined)
|
|
48
|
+
normalizeRoutingStrategy(runtimePolicy.strategy);
|
|
49
|
+
if (runtimePolicy.rateLimit !== undefined)
|
|
50
|
+
normalizeRateLimitOverrides(runtimePolicy.rateLimit);
|
|
51
|
+
for (const raw of Object.values(policies)) {
|
|
52
|
+
if (!record(raw) || Object.keys(raw).some((key) => !["primary", "fallbackRoutes", "strategy", "rateLimit"].includes(key)))
|
|
53
|
+
return null;
|
|
54
|
+
if (raw.primary !== undefined && !route(raw.primary))
|
|
55
|
+
return null;
|
|
56
|
+
if (raw.fallbackRoutes !== undefined && (!Array.isArray(raw.fallbackRoutes) || raw.fallbackRoutes.length > 32 || !raw.fallbackRoutes.every(route)))
|
|
57
|
+
return null;
|
|
58
|
+
if (raw.strategy !== undefined)
|
|
59
|
+
normalizeRoutingStrategy(raw.strategy);
|
|
60
|
+
if (raw.rateLimit !== undefined)
|
|
61
|
+
normalizeRateLimitOverrides(raw.rateLimit);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return { label: document.label, settings, roleRouting: policies, runtimePolicy };
|
|
68
|
+
}
|
|
69
|
+
/** Only the named path changes; comments/unrelated raw JSONC remain untouched. */
|
|
70
|
+
export function editStructuredPath(content, path, value) {
|
|
71
|
+
if (structuredDocument(content) === null)
|
|
72
|
+
return null;
|
|
73
|
+
try {
|
|
74
|
+
return applyEdits(content, modify(content, path, value, { formattingOptions: { insertSpaces: true, tabSize: 2 } }));
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export function moveFallback(content, role, from, to) {
|
|
81
|
+
const document = structuredDocument(content);
|
|
82
|
+
const chain = document?.roleRouting[role]?.fallbackRoutes;
|
|
83
|
+
if (chain === undefined || from < 0 || from >= chain.length || to < 0 || to >= chain.length)
|
|
84
|
+
return null;
|
|
85
|
+
// Move the original object text, not parsed/serialized values, so even the
|
|
86
|
+
// edited rows retain their internal comments and manual identifier spelling.
|
|
87
|
+
const low = Math.min(from, to), high = Math.max(from, to);
|
|
88
|
+
const tree = parseTree(content);
|
|
89
|
+
if (tree === undefined)
|
|
90
|
+
return null;
|
|
91
|
+
const nodes = chain.map((_, index) => findNodeAtLocation(tree, ["settings", "roleRouting", role, "fallbackRoutes", index]));
|
|
92
|
+
if (nodes.some((node) => node === undefined))
|
|
93
|
+
return null;
|
|
94
|
+
const order = nodes.map((node) => content.slice(node.offset, node.offset + node.length));
|
|
95
|
+
order.splice(to, 0, order.splice(from, 1)[0]);
|
|
96
|
+
return applyEdits(content, nodes.slice(low, high + 1).map((node, offset) => ({ offset: node.offset, length: node.length, content: order[low + offset] })));
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=structured.js.map
|
package/lib/client/styles.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Geometry and theme aliases extracted in dsmm/DESIGN.md; scoped to this section. */
|
|
2
|
-
export declare const PROFILE_STYLES = "\n.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)}\n.dsmm-profiles h2{margin:0;font-size:18px;font-weight:600}\n.dsmm-profiles p{margin:0;overflow-wrap:anywhere}\n.dsmm-profiles .dsmm-hint{color:var(--dsw-alias-label-secondary)}\n.dsmm-profiles .dsmm-field{min-width:0;display:flex;flex-direction:column;gap:6px}\n.dsmm-profiles .dsmm-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}\n.dsmm-profiles
|
|
2
|
+
export declare const PROFILE_STYLES = "\n.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)}\n.dsmm-profiles h2{margin:0;font-size:18px;font-weight:600}\n.dsmm-profiles h3,.dsmm-profiles legend{margin:0;font-size:14px;font-weight:500;line-height:22px}\n.dsmm-profiles :is(label,legend,summary){min-width:0;max-width:100%;overflow-wrap:anywhere}\n.dsmm-profiles :is(.dsmm-structured,.dsmm-session-scope,.dsmm-catalog,.dsmm-policy-fields){min-width:0;display:flex;flex-direction:column;gap:12px}\n.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}\n.dsmm-profiles .dsmm-route-fields{display:flex;flex-wrap:wrap;gap:12px;min-width:0}\n.dsmm-profiles .dsmm-route-fields>.dsmm-field{flex:1 1 240px;max-width:100%}\n.dsmm-profiles .dsmm-route-fields select{width:100%}\n.dsmm-profiles summary{cursor:pointer;color:var(--dsw-alias-label-primary);min-height:32px;line-height:32px}\n.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}\n.dsmm-profiles .dsmm-advanced[open]>div{margin-top:8px}\n.dsmm-profiles.dsmm-header-profiles{width:auto;max-width:min(100%,max(0px,calc(100cqw - 24px)));flex-direction:row;flex-wrap:wrap;align-items:center;gap:8px}\n.dsmm-profiles.dsmm-header-profiles select{width:240px;max-width:100%;flex:1 1 0}\n.dsmm-header-profiles span{min-width:0;max-width:100%;overflow-wrap:anywhere;color:var(--dsw-alias-label-secondary)}\n.dsmm-profiles p{margin:0;overflow-wrap:anywhere}\n.dsmm-profiles .dsmm-hint{color:var(--dsw-alias-label-secondary)}\n.dsmm-profiles .dsmm-field{min-width:0;display:flex;flex-direction:column;gap:6px}\n.dsmm-profiles .dsmm-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}\n.dsmm-profiles button{max-width:100%;white-space:normal;overflow-wrap:anywhere;min-height:36px;height:auto}\n.dsmm-profiles .dsmm-input{width:100%;min-width:0;box-sizing:border-box;border-color:var(--dsw-alias-label-secondary)}\n.dsmm-profiles .dsmm-input input{width:100%;min-width:0;font:inherit;color:inherit}\n.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)}\n.dsmm-profiles select{width:240px;height:32px;padding:0 10px;text-overflow:ellipsis}\n.dsmm-profiles textarea{width:100%;padding:12px;font-family:var(--ds-font-family-code);resize:vertical;overflow:auto;white-space:pre;}\n.dsmm-profiles select:hover:not(:disabled),.dsmm-profiles textarea:hover:not(:disabled){border-color:var(--dsw-alias-label-primary)}\n.dsmm-profiles select:active:not(:disabled){background:var(--dsw-alias-interactive-bg-active)}\n.dsmm-profiles :is(select,textarea,button):focus-visible,.dsmm-profiles .dsmm-input:has(input:focus-visible){outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}\n.dsmm-profiles :is(select,textarea):disabled{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-module-platform);cursor:not-allowed}\n.dsmm-profiles .dsmm-editor,.dsmm-profiles .dsmm-confirm{min-width:0;display:flex;flex-direction:column;gap:12px;padding:16px;border:1px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform)}\n.dsmm-profiles .dsmm-issue{padding:12px;border-left:4px solid var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}\n.dsmm-profiles .dsmm-issue p+p{margin-top:8px}\n.dsmm-profiles .dsmm-status{min-height:22px}\n@media(prefers-reduced-motion:reduce){.dsmm-profiles *{transition:none!important;animation:none!important}}\n";
|
|
3
3
|
//# sourceMappingURL=styles.d.ts.map
|
package/lib/client/styles.js
CHANGED
|
@@ -2,11 +2,24 @@
|
|
|
2
2
|
export const PROFILE_STYLES = `
|
|
3
3
|
.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)}
|
|
4
4
|
.dsmm-profiles h2{margin:0;font-size:18px;font-weight:600}
|
|
5
|
+
.dsmm-profiles h3,.dsmm-profiles legend{margin:0;font-size:14px;font-weight:500;line-height:22px}
|
|
6
|
+
.dsmm-profiles :is(label,legend,summary){min-width:0;max-width:100%;overflow-wrap:anywhere}
|
|
7
|
+
.dsmm-profiles :is(.dsmm-structured,.dsmm-session-scope,.dsmm-catalog,.dsmm-policy-fields){min-width:0;display:flex;flex-direction:column;gap:12px}
|
|
8
|
+
.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}
|
|
9
|
+
.dsmm-profiles .dsmm-route-fields{display:flex;flex-wrap:wrap;gap:12px;min-width:0}
|
|
10
|
+
.dsmm-profiles .dsmm-route-fields>.dsmm-field{flex:1 1 240px;max-width:100%}
|
|
11
|
+
.dsmm-profiles .dsmm-route-fields select{width:100%}
|
|
12
|
+
.dsmm-profiles summary{cursor:pointer;color:var(--dsw-alias-label-primary);min-height:32px;line-height:32px}
|
|
13
|
+
.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}
|
|
14
|
+
.dsmm-profiles .dsmm-advanced[open]>div{margin-top:8px}
|
|
15
|
+
.dsmm-profiles.dsmm-header-profiles{width:auto;max-width:min(100%,max(0px,calc(100cqw - 24px)));flex-direction:row;flex-wrap:wrap;align-items:center;gap:8px}
|
|
16
|
+
.dsmm-profiles.dsmm-header-profiles select{width:240px;max-width:100%;flex:1 1 0}
|
|
17
|
+
.dsmm-header-profiles span{min-width:0;max-width:100%;overflow-wrap:anywhere;color:var(--dsw-alias-label-secondary)}
|
|
5
18
|
.dsmm-profiles p{margin:0;overflow-wrap:anywhere}
|
|
6
19
|
.dsmm-profiles .dsmm-hint{color:var(--dsw-alias-label-secondary)}
|
|
7
20
|
.dsmm-profiles .dsmm-field{min-width:0;display:flex;flex-direction:column;gap:6px}
|
|
8
21
|
.dsmm-profiles .dsmm-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
|
|
9
|
-
.dsmm-profiles
|
|
22
|
+
.dsmm-profiles button{max-width:100%;white-space:normal;overflow-wrap:anywhere;min-height:36px;height:auto}
|
|
10
23
|
.dsmm-profiles .dsmm-input{width:100%;min-width:0;box-sizing:border-box;border-color:var(--dsw-alias-label-secondary)}
|
|
11
24
|
.dsmm-profiles .dsmm-input input{width:100%;min-width:0;font:inherit;color:inherit}
|
|
12
25
|
.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)}
|