@dsmm/dsmm 0.1.0 → 0.1.4
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 +26 -12
- package/agent-presets/dsmm-builder/agent.cordis.yml +25 -23
- package/agent-presets/dsmm-builder/preset.yml +1 -1
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-clarifier/preset.yml +1 -1
- package/agent-presets/dsmm-code-search/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-code-search/preset.yml +1 -1
- package/agent-presets/dsmm-creative/agent.cordis.yml +3 -1
- package/agent-presets/dsmm-creative/preset.yml +1 -1
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-doc-search/preset.yml +1 -1
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-media-reader/preset.yml +1 -1
- package/agent-presets/dsmm-oracle/agent.cordis.yml +3 -1
- package/agent-presets/dsmm-oracle/preset.yml +1 -1
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +3 -1
- package/agent-presets/dsmm-oracle-2nd/preset.yml +1 -1
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +26 -24
- package/agent-presets/dsmm-orchestrator/preset.yml +2 -2
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-plan-critic/preset.yml +1 -1
- package/agent-presets/dsmm-planner/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-planner/preset.yml +1 -1
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-reviewer/preset.yml +1 -1
- package/docs/agent-presets.md +17 -5
- package/docs/compatibility.md +68 -12
- package/docs/migration-from-ocmm.md +10 -4
- package/docs/model-routing.md +50 -1
- package/docs/profiles.md +83 -0
- package/docs/releasing.md +59 -18
- package/docs/roadmap.md +1 -1
- package/docs/runtime-recovery.md +10 -2
- package/docs/settings-status.md +16 -4
- package/lib/client/ProfilesSection.d.ts +11 -0
- package/lib/client/ProfilesSection.js +62 -0
- package/lib/client/controller.d.ts +77 -0
- package/lib/client/controller.js +198 -0
- package/lib/client/index.d.ts +11 -0
- package/lib/client/index.js +34 -0
- package/lib/client/locales.d.ts +56 -0
- package/lib/client/locales.js +48 -0
- package/lib/client/styles.d.ts +3 -0
- package/lib/client/styles.js +25 -0
- package/lib/client.js +1930 -0
- package/lib/commands.d.ts +3 -3
- package/lib/commands.js +4 -4
- package/lib/dsh-events.d.ts +8 -0
- package/lib/dsh-types.d.ts +8 -0
- package/lib/guards.d.ts +2 -2
- package/lib/guards.js +3 -2
- package/lib/index.d.ts +16 -6
- package/lib/index.js +77 -21
- package/lib/mode.d.ts +2 -2
- package/lib/mode.js +1 -1
- package/lib/model-routing.d.ts +2 -2
- package/lib/model-routing.js +44 -4
- package/lib/preset-materializer.js +2 -2
- package/lib/preset-registry.js +4 -2
- package/lib/profile-remote.d.ts +31 -0
- package/lib/profile-remote.js +106 -0
- package/lib/profile-rpc.d.ts +27 -0
- package/lib/profile-rpc.js +90 -0
- package/lib/profile-runtime.d.ts +44 -0
- package/lib/profile-runtime.js +159 -0
- package/lib/profile-store.d.ts +42 -0
- package/lib/profile-store.js +478 -0
- package/lib/profile-types.d.ts +40 -0
- package/lib/profile-types.js +2 -0
- package/lib/profiles.d.ts +26 -0
- package/lib/profiles.js +237 -0
- package/lib/prompts.d.ts +2 -2
- package/lib/prompts.js +4 -4
- package/lib/recovery-policy.js +1 -1
- package/lib/role-providers.d.ts +13 -0
- package/lib/role-providers.js +94 -0
- package/lib/role-routing.d.ts +15 -0
- package/lib/role-routing.js +147 -0
- package/lib/role-subagents.d.ts +2 -2
- package/lib/role-subagents.js +6 -4
- package/lib/roles.d.ts +9 -4
- package/lib/roles.js +54 -36
- package/lib/runtime-recovery.d.ts +2 -2
- package/lib/runtime-recovery.js +36 -17
- package/lib/session-metadata.d.ts +13 -0
- package/lib/session-metadata.js +34 -0
- package/lib/session-persistence.d.ts +35 -0
- package/lib/session-persistence.js +304 -0
- package/lib/session-scope.d.ts +6 -1
- package/lib/session-scope.js +23 -0
- package/lib/settings.d.ts +20 -2
- package/lib/settings.js +127 -39
- package/lib/state.d.ts +1 -0
- package/lib/state.js +4 -0
- package/lib/status.d.ts +11 -2
- package/lib/status.js +52 -13
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +67 -15
- package/patches/agent-presets-root.example.cordis.patch.yml +6 -10
- package/prompts/deepseek-v4-pro.md +1 -1
- package/prompts/deepwork.md +3 -3
- package/scripts/repair-session-log.mjs +476 -0
- package/scripts/session-repair-native-verifier.mjs +367 -0
package/lib/commands.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DshContext } from "./dsh-types.js";
|
|
2
2
|
import { DSMM_STATUS_COMMAND } from "./settings.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { DsmmSettingsGetter } from "./settings.js";
|
|
4
4
|
import type { DeepworkModeController } from "./state.js";
|
|
5
5
|
export { DSMM_STATUS_COMMAND };
|
|
6
6
|
export interface DeepworkCommandInput {
|
|
@@ -8,6 +8,6 @@ export interface DeepworkCommandInput {
|
|
|
8
8
|
message: string;
|
|
9
9
|
}
|
|
10
10
|
export declare function parseDeepworkCommandInput(rawInput: string): DeepworkCommandInput;
|
|
11
|
-
export declare function registerDeepworkCommand(readyCtx: DshContext, controller: DeepworkModeController, getSettings:
|
|
12
|
-
export declare function registerDsmmStatusCommand(readyCtx: DshContext, controller: DeepworkModeController, getSettings:
|
|
11
|
+
export declare function registerDeepworkCommand(readyCtx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): void;
|
|
12
|
+
export declare function registerDsmmStatusCommand(readyCtx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): void;
|
|
13
13
|
//# sourceMappingURL=commands.d.ts.map
|
package/lib/commands.js
CHANGED
|
@@ -8,7 +8,7 @@ export function parseDeepworkCommandInput(rawInput) {
|
|
|
8
8
|
}
|
|
9
9
|
async function handleDeepworkCommand(controller, getSettings, invocation) {
|
|
10
10
|
const parsed = parseDeepworkCommandInput(invocation.rawInput);
|
|
11
|
-
await controller.select(invocation.agent, parsed.action === "on", getSettings().defaultActive);
|
|
11
|
+
await controller.select(invocation.agent, parsed.action === "on", getSettings(invocation.agent).defaultActive);
|
|
12
12
|
if (parsed.action === "on" && parsed.message !== "") {
|
|
13
13
|
await invocation.agent.steer?.(createUserMessage({
|
|
14
14
|
content: [{ type: "text", text: parsed.message }],
|
|
@@ -23,7 +23,7 @@ function handleDsmmStatusCommand(controller, getSettings, invocation) {
|
|
|
23
23
|
const input = invocation.rawInput.trim();
|
|
24
24
|
if (input !== "" && input !== "json")
|
|
25
25
|
return { kind: "error", text: "Usage: /dsmm-status [json]" };
|
|
26
|
-
const settings = getSettings();
|
|
26
|
+
const settings = getSettings(invocation.agent);
|
|
27
27
|
const snapshot = createDsmmStatusSnapshot({
|
|
28
28
|
agent: invocation.agent,
|
|
29
29
|
settings,
|
|
@@ -38,7 +38,7 @@ export function registerDeepworkCommand(readyCtx, controller, getSettings) {
|
|
|
38
38
|
const commands = readyCtx.get?.("commands") ?? readyCtx.commands;
|
|
39
39
|
commands?.register({
|
|
40
40
|
name: getSettings().modeName,
|
|
41
|
-
description: "Enter or leave
|
|
41
|
+
description: "Enter or leave Deepwork mode",
|
|
42
42
|
input: { hint: "[off|message]" },
|
|
43
43
|
handler: (invocation) => handleDeepworkCommand(controller, getSettings, invocation)
|
|
44
44
|
});
|
|
@@ -47,7 +47,7 @@ export function registerDsmmStatusCommand(readyCtx, controller, getSettings) {
|
|
|
47
47
|
const commands = readyCtx.get?.("commands") ?? readyCtx.commands;
|
|
48
48
|
commands?.register({
|
|
49
49
|
name: DSMM_STATUS_COMMAND,
|
|
50
|
-
description: "Show
|
|
50
|
+
description: "Show Deepwork status",
|
|
51
51
|
input: { hint: "[json]" },
|
|
52
52
|
handler: (invocation) => handleDsmmStatusCommand(controller, getSettings, invocation)
|
|
53
53
|
});
|
package/lib/dsh-events.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import type { DsmmRoleId } from "./roles.js";
|
|
2
|
+
export interface DsmmRolePolicyEventData {
|
|
3
|
+
version: 1;
|
|
4
|
+
role: DsmmRoleId;
|
|
5
|
+
policy: string | null;
|
|
6
|
+
}
|
|
1
7
|
declare module "@deepseek-ai/dsh-session/types" {
|
|
2
8
|
interface SessionEventMap {
|
|
3
9
|
"deepwork/mode": {
|
|
4
10
|
active: boolean;
|
|
5
11
|
};
|
|
12
|
+
"dsmm/role-policy": DsmmRolePolicyEventData;
|
|
6
13
|
}
|
|
7
14
|
}
|
|
8
15
|
export interface DeepworkSessionEventMap {
|
|
9
16
|
"deepwork/mode": {
|
|
10
17
|
active: boolean;
|
|
11
18
|
};
|
|
19
|
+
"dsmm/role-policy": DsmmRolePolicyEventData;
|
|
12
20
|
}
|
|
13
21
|
//# sourceMappingURL=dsh-events.d.ts.map
|
package/lib/dsh-types.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface DshSessionHeader {
|
|
|
18
18
|
origin?: string;
|
|
19
19
|
}
|
|
20
20
|
export interface DshSession {
|
|
21
|
+
inheritedEventCount?: number;
|
|
21
22
|
events?: readonly DshSessionEvent[];
|
|
22
23
|
snapshotEvents?(): readonly DshSessionEvent[];
|
|
23
24
|
header?: DshSessionHeader;
|
|
@@ -25,12 +26,16 @@ export interface DshSession {
|
|
|
25
26
|
append(type: "deepwork/mode", payload: {
|
|
26
27
|
active: boolean;
|
|
27
28
|
}): unknown | Promise<unknown>;
|
|
29
|
+
append(type: "dsmm/role-policy", payload: import("./dsh-events.js").DsmmRolePolicyEventData): unknown | Promise<unknown>;
|
|
28
30
|
}
|
|
29
31
|
export interface DshAgent {
|
|
32
|
+
id?: string;
|
|
33
|
+
ctx?: DshContext;
|
|
30
34
|
session: DshSession;
|
|
31
35
|
options?: {
|
|
32
36
|
provider?: string;
|
|
33
37
|
model?: string;
|
|
38
|
+
reasoningEffort?: string;
|
|
34
39
|
};
|
|
35
40
|
steer?(message: unknown): unknown | Promise<unknown>;
|
|
36
41
|
inject?(message: unknown): unknown | Promise<unknown>;
|
|
@@ -74,6 +79,7 @@ export interface DshResolvedModelInfo {
|
|
|
74
79
|
}
|
|
75
80
|
export interface DshLlmRuntime {
|
|
76
81
|
resolveModelInfo(provider: string, model: string, signal?: AbortSignal): Promise<DshResolvedModelInfo>;
|
|
82
|
+
resolveCallConfig?(config: DshLlmCallConfig, signal?: AbortSignal): Promise<DshLlmCallConfig>;
|
|
77
83
|
}
|
|
78
84
|
export interface AgentRequestFrame {
|
|
79
85
|
agent: DshAgent;
|
|
@@ -277,6 +283,7 @@ export interface PreStepDecision {
|
|
|
277
283
|
[key: string]: unknown;
|
|
278
284
|
}
|
|
279
285
|
export interface DshContext {
|
|
286
|
+
subagents?: import("./role-providers.js").DsmmSubagentRegistry;
|
|
280
287
|
settings?: DshSettingsRegistry;
|
|
281
288
|
systemPrompt?: DshSystemPromptRegistry;
|
|
282
289
|
skills?: DshSkillRegistry;
|
|
@@ -284,6 +291,7 @@ export interface DshContext {
|
|
|
284
291
|
tools?: DshToolRuntime;
|
|
285
292
|
llm?: DshLlmRuntime;
|
|
286
293
|
get?<T = unknown>(name: string): T | undefined;
|
|
294
|
+
provide?(name: string, service: unknown): unknown;
|
|
287
295
|
plugin?(plugin: unknown, config?: unknown): PromiseLike<unknown>;
|
|
288
296
|
inject?(dependencies: string[], installer: (readyCtx: DshContext) => unknown): unknown;
|
|
289
297
|
effect?(callback: () => void | (() => void)): unknown;
|
package/lib/guards.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { DshContext, DshPostToolDecision, DshPreToolDecision, DshToolExecution, DshToolExecutionResult } from "./dsh-types.js";
|
|
2
|
-
import type { DsmmSettings } from "./settings.js";
|
|
2
|
+
import type { DsmmSettings, DsmmSettingsGetter } from "./settings.js";
|
|
3
3
|
import type { DeepworkModeController } from "./state.js";
|
|
4
4
|
export declare const DSMM_GUARD_PREFIX = "[dsmm safety]";
|
|
5
5
|
export declare function truncateTextMiddle(text: string, maxBytes: number, toolName: string): string;
|
|
6
6
|
export declare function isSafetyScopeActive(exec: DshToolExecution, settings: DsmmSettings, controller: DeepworkModeController): boolean;
|
|
7
7
|
export declare function decidePreToolExecution(exec: DshToolExecution, settings: DsmmSettings, controller: DeepworkModeController): DshPreToolDecision | undefined;
|
|
8
8
|
export declare function decidePostToolExecution(exec: DshToolExecution, result: Readonly<DshToolExecutionResult>, decision: DshPostToolDecision, settings: DsmmSettings, controller: DeepworkModeController): DshPostToolDecision;
|
|
9
|
-
export declare function registerSafetyGuards(ctx: DshContext, controller: DeepworkModeController, getSettings:
|
|
9
|
+
export declare function registerSafetyGuards(ctx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): void;
|
|
10
10
|
//# sourceMappingURL=guards.d.ts.map
|
package/lib/guards.js
CHANGED
|
@@ -236,7 +236,7 @@ export function decidePostToolExecution(exec, result, decision, settings, contro
|
|
|
236
236
|
}
|
|
237
237
|
export function registerSafetyGuards(ctx, controller, getSettings) {
|
|
238
238
|
ctx.on?.("tools/pre-execute", async (exec, next) => {
|
|
239
|
-
const decision = decidePreToolExecution(exec, getSettings(), controller);
|
|
239
|
+
const decision = decidePreToolExecution(exec, getSettings(exec.agent), controller);
|
|
240
240
|
if (decision === undefined)
|
|
241
241
|
return next();
|
|
242
242
|
if (decision.kind === "deny")
|
|
@@ -245,8 +245,9 @@ export function registerSafetyGuards(ctx, controller, getSettings) {
|
|
|
245
245
|
return downstream.kind === "allow" ? decision : downstream;
|
|
246
246
|
}, { prepend: true });
|
|
247
247
|
ctx.on?.("tools/post-execute", async (exec, result, next) => {
|
|
248
|
+
const settings = getSettings(exec.agent);
|
|
248
249
|
const decision = await next();
|
|
249
|
-
return decidePostToolExecution(exec, result, decision,
|
|
250
|
+
return decidePostToolExecution(exec, result, decision, settings, controller);
|
|
250
251
|
}, { prepend: true });
|
|
251
252
|
}
|
|
252
253
|
//# sourceMappingURL=guards.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DshContext } from "./dsh-types.js";
|
|
2
2
|
import type { DsmmPluginConfig } from "./settings.js";
|
|
3
3
|
export declare const name = "dsmm";
|
|
4
|
-
export declare const inject: readonly [];
|
|
4
|
+
export declare const inject: readonly ["profileContext"];
|
|
5
5
|
export type Config = DsmmPluginConfig;
|
|
6
6
|
export declare const Config: import("@deepseek-ai/schemastery").default<DsmmPluginConfig>;
|
|
7
7
|
export type { DeepworkSessionEventMap } from "./dsh-events.js";
|
|
@@ -18,14 +18,24 @@ export type { DeepseekReasoningEffort } from "./model-routing.js";
|
|
|
18
18
|
export { classifyRecoveryFailure, foldAttemptedRecoveryRoutes, foldDurableRecoveryWork, selectFallbackRoute } from "./recovery-policy.js";
|
|
19
19
|
export type { DurableRecoveryWork, RecoveryFailureDecision } from "./recovery-policy.js";
|
|
20
20
|
export { registerRuntimeRecovery } from "./runtime-recovery.js";
|
|
21
|
-
export { resolveSelectedAgentPreset } from "./session-scope.js";
|
|
21
|
+
export { childOwnedSessionEvents, resolveEffectiveDsmmRole, resolveSelectedAgentPreset } from "./session-scope.js";
|
|
22
|
+
export { roleFromProviderName, roleProviderName, registerRoleProviders } from "./role-providers.js";
|
|
23
|
+
export { effectiveRoleFallbackRoutes } from "./role-routing.js";
|
|
22
24
|
export { DSMM_STATUS_COMMAND, registerDsmmStatusCommand } from "./commands.js";
|
|
23
25
|
export { DSMM_STATUS_VERSION, createDsmmStatusSnapshot, formatDsmmStatus } from "./status.js";
|
|
24
26
|
export type { DsmmStatusSnapshot } from "./status.js";
|
|
25
27
|
export type { AgentRequestErrorFrame, AgentRequestFrame, AgentTurnStoppingFrame, DshEpochHeader, DshGoalChangeEventData, DshGoalSnapshot, DshLlmCallConfig, DshLlmFailure, DshModelReasoningInfo, DshReasoningEffortInfo, DshRequestErrorAction, DshRequestHeaderEventData, DshResolvedModelInfo, DshStepBoundaryEventData, DshTodoItem, DshTodoWriteEventData } from "./dsh-types.js";
|
|
26
|
-
export { DSMM_SKILL_NAMES, DEFAULT_DSMM_SETTINGS, MVP_SKILL_NAMES, isRoleEnabled, resolveConfig, registerSettings } from "./settings.js";
|
|
27
|
-
export type { DeepseekCalibration, DeepseekDefaultReasoningEffort, DsmmFinalReviewPolicy, DsmmGitWritePolicy, DsmmGuardScope, DsmmGuardSettings, DsmmPluginConfig, DsmmRecoveryRoute, DsmmRuntimeRecoverySettings, DsmmSettings, DsmmSkillName, DsmmWorkflowSettings, MvpSkillName } from "./settings.js";
|
|
28
|
+
export { DSMM_SKILL_NAMES, DEFAULT_DSMM_SETTINGS, MVP_SKILL_NAMES, isRoleEnabled, resolveConfig, resolveRoleRouting, registerSettings } from "./settings.js";
|
|
29
|
+
export type { DeepseekCalibration, DeepseekDefaultReasoningEffort, DsmmFinalReviewPolicy, DsmmGitWritePolicy, DsmmGuardScope, DsmmGuardSettings, DsmmPluginConfig, DsmmModelRoute, DsmmRoleRoutingConfig, DsmmRoleRouting, DsmmRecoveryRoute, DsmmRuntimeRecoverySettings, DsmmSettings, DsmmSettingsGetter, DsmmSkillName, DsmmWorkflowSettings, MvpSkillName } from "./settings.js";
|
|
30
|
+
export { createProfileRuntime, DsmmProfileRuntime } from "./profile-runtime.js";
|
|
31
|
+
export type { DsmmProfileRuntimeStore, DsmmProfileRuntimeOptions } from "./profile-runtime.js";
|
|
28
32
|
export { DEEPWORK_MODE_EVENT, DeepworkModeController, hasOpenTurn, isDeepworkActive } from "./state.js";
|
|
29
|
-
export declare function apply(ctx: DshContext, config?: Config): void
|
|
30
|
-
|
|
33
|
+
export declare function apply(ctx: DshContext, config?: Config): void | Promise<void>;
|
|
34
|
+
declare const _default: {
|
|
35
|
+
name: string;
|
|
36
|
+
inject: readonly ["profileContext"];
|
|
37
|
+
Config: import("@deepseek-ai/schemastery").default<DsmmPluginConfig>;
|
|
38
|
+
apply: typeof apply;
|
|
39
|
+
};
|
|
40
|
+
export default _default;
|
|
31
41
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -6,10 +6,15 @@ import { registerRuntimeRecovery } from "./runtime-recovery.js";
|
|
|
6
6
|
import { reconcileRolePresets, resolveManagedPresetRoot } from "./preset-materializer.js";
|
|
7
7
|
import { registerHeadlessRoleTools } from "./role-subagents.js";
|
|
8
8
|
import { registerRolePresets } from "./preset-registry.js";
|
|
9
|
+
import { registerRoleProviders } from "./role-providers.js";
|
|
10
|
+
import { createProfileRuntime } from "./profile-runtime.js";
|
|
11
|
+
import { registerProfilesRpc } from "./profile-rpc.js";
|
|
9
12
|
import { DSMM_CONFIG_SCHEMA, registerSettings } from "./settings.js";
|
|
10
13
|
import { DeepworkModeController } from "./state.js";
|
|
14
|
+
import DsmmSessionPersistence from "./session-persistence.js";
|
|
15
|
+
import { isAbsolute } from "node:path";
|
|
11
16
|
export const name = "dsmm";
|
|
12
|
-
export const inject = [];
|
|
17
|
+
export const inject = ["profileContext"];
|
|
13
18
|
export const Config = DSMM_CONFIG_SCHEMA;
|
|
14
19
|
export { DSMM_ROLE_IDS, DSMM_ROLES, isDsmmRoleId, renderAgentCordis, renderPresetMetadata } from "./roles.js";
|
|
15
20
|
export { DSMM_MANAGED_PRESET_MARKER, materializeRolePresets, reconcileRolePresets, resolveManagedPresetRoot } from "./preset-materializer.js";
|
|
@@ -19,36 +24,87 @@ export { classifyModelFamily } from "./model-family.js";
|
|
|
19
24
|
export { desiredDeepseekEffort, isDeepseekV4ProRoute, registerModelRouting, selectAdvertisedEffort } from "./model-routing.js";
|
|
20
25
|
export { classifyRecoveryFailure, foldAttemptedRecoveryRoutes, foldDurableRecoveryWork, selectFallbackRoute } from "./recovery-policy.js";
|
|
21
26
|
export { registerRuntimeRecovery } from "./runtime-recovery.js";
|
|
22
|
-
export { resolveSelectedAgentPreset } from "./session-scope.js";
|
|
27
|
+
export { childOwnedSessionEvents, resolveEffectiveDsmmRole, resolveSelectedAgentPreset } from "./session-scope.js";
|
|
28
|
+
export { roleFromProviderName, roleProviderName, registerRoleProviders } from "./role-providers.js";
|
|
29
|
+
export { effectiveRoleFallbackRoutes } from "./role-routing.js";
|
|
23
30
|
export { DSMM_STATUS_COMMAND, registerDsmmStatusCommand } from "./commands.js";
|
|
24
31
|
export { DSMM_STATUS_VERSION, createDsmmStatusSnapshot, formatDsmmStatus } from "./status.js";
|
|
25
|
-
export { DSMM_SKILL_NAMES, DEFAULT_DSMM_SETTINGS, MVP_SKILL_NAMES, isRoleEnabled, resolveConfig, registerSettings } from "./settings.js";
|
|
32
|
+
export { DSMM_SKILL_NAMES, DEFAULT_DSMM_SETTINGS, MVP_SKILL_NAMES, isRoleEnabled, resolveConfig, resolveRoleRouting, registerSettings } from "./settings.js";
|
|
33
|
+
export { createProfileRuntime, DsmmProfileRuntime } from "./profile-runtime.js";
|
|
26
34
|
export { DEEPWORK_MODE_EVENT, DeepworkModeController, hasOpenTurn, isDeepworkActive } from "./state.js";
|
|
27
35
|
export function apply(ctx, config = {}) {
|
|
36
|
+
const storage = config.sessionPersistence;
|
|
37
|
+
if (storage !== undefined) {
|
|
38
|
+
if (storage === null || typeof storage !== "object" || typeof storage.root !== "string" || !isAbsolute(storage.root)
|
|
39
|
+
|| Object.keys(storage).some((key) => !["root", "compression"].includes(key))
|
|
40
|
+
|| storage.compression !== undefined && !["zstd", "none"].includes(storage.compression)) {
|
|
41
|
+
throw new Error("Deepwork sessionPersistence must preserve an explicit absolute native root and compression");
|
|
42
|
+
}
|
|
43
|
+
if (ctx.get === undefined || ctx.plugin === undefined)
|
|
44
|
+
throw new Error("Deepwork sessionPersistence requires native startup composition");
|
|
45
|
+
if (ctx.get("sessionPersistence") !== undefined)
|
|
46
|
+
throw new Error("Disable the exact existing JSONL entry at startup before enabling Deepwork sessionPersistence; live replacement is refused");
|
|
47
|
+
const fiber = ctx.plugin(DsmmSessionPersistence, storage);
|
|
48
|
+
if (fiber === undefined)
|
|
49
|
+
throw new Error("Deepwork sessionPersistence startup registration failed");
|
|
50
|
+
return fiber.await().then(() => applyRuntime(ctx, config));
|
|
51
|
+
}
|
|
52
|
+
return applyRuntime(ctx, config);
|
|
53
|
+
}
|
|
54
|
+
function applyRuntime(ctx, config) {
|
|
28
55
|
const controller = new DeepworkModeController(ctx);
|
|
56
|
+
let runtime;
|
|
57
|
+
let profileInitialization;
|
|
58
|
+
const getBoundSettings = (agent) => runtime?.getSettings(agent) ?? getSettings();
|
|
29
59
|
const getSettings = registerSettings(ctx, config, {
|
|
30
60
|
install(readyCtx, getReadySettings) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
61
|
+
const install = (installCtx, settingsGetter) => {
|
|
62
|
+
registerDeepworkPrompt(installCtx, controller, settingsGetter, config);
|
|
63
|
+
const installCommands = (commandCtx) => {
|
|
64
|
+
registerDeepworkCommand(commandCtx, controller, settingsGetter);
|
|
65
|
+
registerDsmmStatusCommand(commandCtx, controller, settingsGetter);
|
|
66
|
+
};
|
|
67
|
+
if (installCtx.get !== undefined && installCtx.inject !== undefined)
|
|
68
|
+
installCtx.inject(["commands"], installCommands);
|
|
69
|
+
else
|
|
70
|
+
installCommands(installCtx);
|
|
71
|
+
registerRoleProviders(installCtx, settingsGetter, getReadySettings);
|
|
72
|
+
// Standing compositions are deployment-only and never replaced on a
|
|
73
|
+
// runtime profile selection. All routes are read from Agent bindings.
|
|
74
|
+
registerRolePresets(installCtx, getReadySettings);
|
|
75
|
+
const settings = getReadySettings();
|
|
76
|
+
const root = resolveManagedPresetRoot(settings);
|
|
77
|
+
if (root !== undefined)
|
|
78
|
+
reconcileRolePresets({ root, settings });
|
|
35
79
|
};
|
|
36
|
-
if (readyCtx.get
|
|
37
|
-
readyCtx
|
|
38
|
-
else
|
|
39
|
-
installCommands(readyCtx);
|
|
40
|
-
registerRolePresets(readyCtx, getReadySettings);
|
|
41
|
-
const settings = getReadySettings();
|
|
42
|
-
const root = resolveManagedPresetRoot(settings);
|
|
43
|
-
if (root === undefined)
|
|
80
|
+
if (readyCtx.get === undefined) {
|
|
81
|
+
install(readyCtx, getReadySettings);
|
|
44
82
|
return;
|
|
45
|
-
|
|
83
|
+
}
|
|
84
|
+
const installProfiles = async (profileCtx) => {
|
|
85
|
+
runtime = await createProfileRuntime(profileCtx, getReadySettings());
|
|
86
|
+
profileCtx.provide?.("dsmmProfileRuntime", runtime);
|
|
87
|
+
const manager = runtime;
|
|
88
|
+
profileCtx.inject?.(["typert"], (rpcCtx) => {
|
|
89
|
+
registerProfilesRpc(rpcCtx, manager);
|
|
90
|
+
});
|
|
91
|
+
install(profileCtx, runtime.getSettings);
|
|
92
|
+
};
|
|
93
|
+
if (readyCtx.inject !== undefined) {
|
|
94
|
+
const initialization = readyCtx.inject(["profileContext"], installProfiles);
|
|
95
|
+
profileInitialization = Promise.resolve(initialization).then(() => undefined);
|
|
96
|
+
}
|
|
97
|
+
else
|
|
98
|
+
throw new Error("dsmm native profiles require asynchronous profileContext injection");
|
|
46
99
|
}
|
|
47
100
|
});
|
|
48
|
-
registerRuntimeRecovery(ctx, controller,
|
|
49
|
-
registerModelRouting(ctx, controller,
|
|
50
|
-
registerHeadlessRoleTools(ctx, controller,
|
|
51
|
-
registerSafetyGuards(ctx, controller,
|
|
101
|
+
registerRuntimeRecovery(ctx, controller, getBoundSettings);
|
|
102
|
+
registerModelRouting(ctx, controller, getBoundSettings);
|
|
103
|
+
registerHeadlessRoleTools(ctx, controller, getBoundSettings);
|
|
104
|
+
registerSafetyGuards(ctx, controller, getBoundSettings);
|
|
105
|
+
return profileInitialization;
|
|
52
106
|
}
|
|
53
|
-
|
|
107
|
+
// Cordis Loader introspects this object's Config/inject; a bare function loses
|
|
108
|
+
// the exported schema and may pass null where required DSMM defaults belong.
|
|
109
|
+
export default { name, inject, Config, apply };
|
|
54
110
|
//# sourceMappingURL=index.js.map
|
package/lib/mode.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DshContext } from "./dsh-types.js";
|
|
2
2
|
import type { Config } from "./index.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { DsmmSettingsGetter } from "./settings.js";
|
|
4
4
|
import type { DeepworkModeController } from "./state.js";
|
|
5
|
-
export declare function registerDeepworkPrompt(readyCtx: DshContext, controller: DeepworkModeController, getSettings:
|
|
5
|
+
export declare function registerDeepworkPrompt(readyCtx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter, config?: Config): void;
|
|
6
6
|
//# sourceMappingURL=mode.d.ts.map
|
package/lib/mode.js
CHANGED
|
@@ -14,7 +14,7 @@ export function registerDeepworkPrompt(readyCtx, controller, getSettings, config
|
|
|
14
14
|
order: getSettings().promptOrder,
|
|
15
15
|
interpolate: false,
|
|
16
16
|
text(context) {
|
|
17
|
-
const settings = getSettings();
|
|
17
|
+
const settings = getSettings(context.agent);
|
|
18
18
|
const preset = resolveSelectedAgentPreset(context.agent?.session);
|
|
19
19
|
const active = controller.active(context.agent, settings.defaultActive);
|
|
20
20
|
if (!active && !isDsmmRoleId(preset))
|
package/lib/model-routing.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DshContext, DshLlmCallConfig, DshModelReasoningInfo } from "./dsh-types.js";
|
|
2
|
-
import type { DeepseekDefaultReasoningEffort, DsmmSettings } from "./settings.js";
|
|
2
|
+
import type { DeepseekDefaultReasoningEffort, DsmmSettings, DsmmSettingsGetter } from "./settings.js";
|
|
3
3
|
import type { DeepworkModeController } from "./state.js";
|
|
4
4
|
export type DeepseekReasoningEffort = DeepseekDefaultReasoningEffort | "max";
|
|
5
5
|
export type DeepseekModelRoute = "v4-pro" | "flash";
|
|
@@ -7,5 +7,5 @@ export declare function isDeepseekV4ProRoute(config: Pick<DshLlmCallConfig, "pro
|
|
|
7
7
|
export declare function isDeepseekFlashRoute(config: Pick<DshLlmCallConfig, "provider" | "model">): boolean;
|
|
8
8
|
export declare function desiredDeepseekEffort(settings: DsmmSettings, preset?: string, route?: DeepseekModelRoute): DeepseekReasoningEffort;
|
|
9
9
|
export declare function selectAdvertisedEffort(desired: DeepseekReasoningEffort, reasoning: DshModelReasoningInfo | undefined): string | undefined;
|
|
10
|
-
export declare function registerModelRouting(ctx: DshContext, controller: DeepworkModeController, getSettings:
|
|
10
|
+
export declare function registerModelRouting(ctx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): void;
|
|
11
11
|
//# sourceMappingURL=model-routing.d.ts.map
|
package/lib/model-routing.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isDsmmRoleId } from "./roles.js";
|
|
2
|
-
import {
|
|
2
|
+
import { applyModelRoute, effectiveRoleFallbackRoutes, establishRolePolicy, persistedRoleRoute, sameModelRoute, takeAdmittedRecoveryRoute } from "./role-routing.js";
|
|
3
|
+
import { resolveEffectiveDsmmRole, resolveSelectedAgentPreset } from "./session-scope.js";
|
|
3
4
|
export function isDeepseekV4ProRoute(config) {
|
|
4
5
|
return config.provider.toLowerCase() === "deepseek-official" && config.model.toLowerCase() === "deepseek-v4-pro";
|
|
5
6
|
}
|
|
@@ -27,6 +28,11 @@ export function selectAdvertisedEffort(desired, reasoning) {
|
|
|
27
28
|
}
|
|
28
29
|
return advertised.has(desired) ? desired : fallback;
|
|
29
30
|
}
|
|
31
|
+
function hasLiveRuntimeOwner(ctx, agent) {
|
|
32
|
+
const agents = ctx.get?.("agents");
|
|
33
|
+
return agent.id !== undefined && agents !== undefined
|
|
34
|
+
&& agents.list().some((parent) => parent !== agent && agents.isOwnedBy(agent.id, parent));
|
|
35
|
+
}
|
|
30
36
|
export function registerModelRouting(ctx, controller, getSettings) {
|
|
31
37
|
const installedContexts = new WeakSet();
|
|
32
38
|
const install = (readyCtx) => {
|
|
@@ -36,8 +42,42 @@ export function registerModelRouting(ctx, controller, getSettings) {
|
|
|
36
42
|
let dispose;
|
|
37
43
|
try {
|
|
38
44
|
dispose = readyCtx.on("agent/request", async (frame, next) => {
|
|
39
|
-
|
|
40
|
-
const settings = getSettings();
|
|
45
|
+
let downstream = await next();
|
|
46
|
+
const settings = getSettings(frame.agent);
|
|
47
|
+
const admitted = takeAdmittedRecoveryRoute(frame);
|
|
48
|
+
const active = controller.active(frame.agent, settings.defaultActive);
|
|
49
|
+
const role = resolveEffectiveDsmmRole(frame.agent, settings, active);
|
|
50
|
+
const policy = role === undefined ? undefined : settings.roleRouting[role];
|
|
51
|
+
const primary = policy?.primary;
|
|
52
|
+
const identity = await establishRolePolicy(frame, settings, role, readyCtx);
|
|
53
|
+
if (admitted !== undefined) {
|
|
54
|
+
downstream = applyModelRoute(downstream, admitted);
|
|
55
|
+
if (admitted.reasoningEffort !== undefined || primary !== undefined
|
|
56
|
+
|| (role !== undefined && settings.roleRouting[role]?.fallbackRoutes !== undefined))
|
|
57
|
+
return downstream;
|
|
58
|
+
}
|
|
59
|
+
const fallbacks = effectiveRoleFallbackRoutes(settings, role);
|
|
60
|
+
if (primary !== undefined && role !== undefined && frame.agent.session.header?.origin === "subagent"
|
|
61
|
+
&& (frame.agent.session.inheritedEventCount ?? 0) === 0
|
|
62
|
+
&& hasLiveRuntimeOwner(readyCtx, frame.agent)) {
|
|
63
|
+
// A trusted one-shot alias already preflighted its merged native
|
|
64
|
+
// options. Its first accepted route, not the profile default, starts
|
|
65
|
+
// this live child's durable host/recovery ownership. Cold unowned or
|
|
66
|
+
// parent-seeded fork children resolve the current primary below.
|
|
67
|
+
const accepted = persistedRoleRoute(frame, undefined, fallbacks, identity);
|
|
68
|
+
return accepted === undefined ? downstream : applyModelRoute(downstream, accepted);
|
|
69
|
+
}
|
|
70
|
+
if (primary !== undefined)
|
|
71
|
+
return applyModelRoute(downstream, persistedRoleRoute(frame, primary, fallbacks, identity) ?? primary);
|
|
72
|
+
if (settings.runtimeRecovery.enabled && policy?.fallbackRoutes !== undefined) {
|
|
73
|
+
const accepted = persistedRoleRoute(frame, undefined, fallbacks, identity);
|
|
74
|
+
if (accepted !== undefined)
|
|
75
|
+
return applyModelRoute(downstream, accepted);
|
|
76
|
+
}
|
|
77
|
+
// Named fallback efforts are native policy IDs, never legacy calibration inputs.
|
|
78
|
+
if (fallbacks.some((fallback) => fallback.reasoningEffort !== undefined
|
|
79
|
+
&& sameModelRoute(fallback, downstream) && fallback.reasoningEffort === downstream.reasoningEffort))
|
|
80
|
+
return downstream;
|
|
41
81
|
const route = isDeepseekV4ProRoute(downstream) ? "v4-pro" : isDeepseekFlashRoute(downstream) ? "flash" : undefined;
|
|
42
82
|
if (route === undefined)
|
|
43
83
|
return downstream;
|
|
@@ -45,7 +85,7 @@ export function registerModelRouting(ctx, controller, getSettings) {
|
|
|
45
85
|
if (calibration === "off")
|
|
46
86
|
return downstream;
|
|
47
87
|
const preset = resolveSelectedAgentPreset(frame.agent?.session);
|
|
48
|
-
const inScope =
|
|
88
|
+
const inScope = active || isDsmmRoleId(preset);
|
|
49
89
|
if (!inScope)
|
|
50
90
|
return downstream;
|
|
51
91
|
if (calibration === "auto" && downstream.reasoningEffort !== undefined)
|
|
@@ -146,7 +146,7 @@ function updateOwnedRoleDirectory(canonicalRoot, knownDirectory, settings, files
|
|
|
146
146
|
throw new Error(`dsmm preset directory is not owned and cannot be updated: ${knownDirectory.directory}`);
|
|
147
147
|
}
|
|
148
148
|
const files = [
|
|
149
|
-
["agent.cordis.yml", renderAgentCordis(knownDirectory.role, enabledSkillNames(settings), enabledRoles(settings))],
|
|
149
|
+
["agent.cordis.yml", renderAgentCordis(knownDirectory.role, enabledSkillNames(settings), enabledRoles(settings), settings.roleRouting)],
|
|
150
150
|
["preset.yml", renderPresetMetadata(knownDirectory.role)],
|
|
151
151
|
[DSMM_MANAGED_PRESET_MARKER, renderManagedPresetMarker(knownDirectory.role.id)]
|
|
152
152
|
];
|
|
@@ -183,7 +183,7 @@ function publishNewRoleDirectory(canonicalRoot, root, role, settings, filesystem
|
|
|
183
183
|
}
|
|
184
184
|
assertDirectoryNotLinked(temporaryDirectory, temporaryStatus, `temporary preset directory for ${role}`);
|
|
185
185
|
assertCanonicalChild(canonicalRoot, filesystem.realpathSync(temporaryDirectory), `temporary preset directory for ${role}`);
|
|
186
|
-
filesystem.writeFileSync(join(temporaryDirectory, "agent.cordis.yml"), renderAgentCordis(findRole(role), enabledSkillNames(settings), enabledRoles(settings)), "utf8");
|
|
186
|
+
filesystem.writeFileSync(join(temporaryDirectory, "agent.cordis.yml"), renderAgentCordis(findRole(role), enabledSkillNames(settings), enabledRoles(settings), settings.roleRouting), "utf8");
|
|
187
187
|
filesystem.writeFileSync(join(temporaryDirectory, "preset.yml"), renderPresetMetadata(findRole(role)), "utf8");
|
|
188
188
|
filesystem.writeFileSync(join(temporaryDirectory, DSMM_MANAGED_PRESET_MARKER), renderManagedPresetMarker(role), "utf8");
|
|
189
189
|
if (lstatIfExists(finalDirectory, filesystem) !== undefined) {
|
package/lib/preset-registry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getTraceable } from "@deepseek-ai/cordis";
|
|
2
|
-
import { DSMM_ROLES, DSMM_ROLE_IDS, rolePluginRows } from "./roles.js";
|
|
2
|
+
import { DSMM_ROLES, DSMM_ROLE_IDS, isRootRole, rolePluginRows } from "./roles.js";
|
|
3
3
|
import { enabledSkillNames } from "./skills.js";
|
|
4
4
|
/** Declare roles to DSH 0.2's native registry; directories are not discovery inputs. */
|
|
5
5
|
export function registerRolePresets(ctx, getSettings) {
|
|
@@ -10,7 +10,7 @@ export function registerRolePresets(ctx, getSettings) {
|
|
|
10
10
|
throw new Error("dsmm requires the native DSH agentPresets registry");
|
|
11
11
|
const settings = getSettings();
|
|
12
12
|
const enabled = DSMM_ROLE_IDS.filter((id) => settings.roles[id]);
|
|
13
|
-
const active = DSMM_ROLES.filter((role) => enabled.includes(role.id));
|
|
13
|
+
const active = DSMM_ROLES.filter((role) => isRootRole(role) && enabled.includes(role.id));
|
|
14
14
|
const disposers = [];
|
|
15
15
|
try {
|
|
16
16
|
for (const role of active) {
|
|
@@ -19,6 +19,8 @@ export function registerRolePresets(ctx, getSettings) {
|
|
|
19
19
|
name: role.name,
|
|
20
20
|
description: role.description,
|
|
21
21
|
order: role.order,
|
|
22
|
+
// Profiles do not replace standing native compositions. Child routes
|
|
23
|
+
// are admitted by the role provider from the parent's fixed snapshot.
|
|
22
24
|
plugins: rolePluginRows(role, enabledSkillNames(settings), enabled)
|
|
23
25
|
}));
|
|
24
26
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RemoteResult, TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
2
|
+
import type { TypertContribution } from "@deepseek-ai/dsh-typert-registry";
|
|
3
|
+
import type { ProfileErrorInfo, ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSnapshot } from "./profile-types.js";
|
|
4
|
+
export interface DsmmProfilesRemote {
|
|
5
|
+
describe(): Promise<RemoteResult<ProfileSnapshot>>;
|
|
6
|
+
read(id: string): Promise<RemoteResult<ProfileReadResult>>;
|
|
7
|
+
save(request: ProfileSaveRequest): Promise<RemoteResult<ProfileReadResult>>;
|
|
8
|
+
select(request: ProfileSelectRequest): Promise<RemoteResult<ProfileSnapshot>>;
|
|
9
|
+
}
|
|
10
|
+
declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
11
|
+
interface TypertRemoteMap {
|
|
12
|
+
"dsmmProfiles/describe": DsmmProfilesRemote["describe"];
|
|
13
|
+
"dsmmProfiles/read": DsmmProfilesRemote["read"];
|
|
14
|
+
"dsmmProfiles/save": DsmmProfilesRemote["save"];
|
|
15
|
+
"dsmmProfiles/select": DsmmProfilesRemote["select"];
|
|
16
|
+
}
|
|
17
|
+
interface TypertRemoteNamespaceMap {
|
|
18
|
+
dsmmProfiles: DsmmProfilesRemote;
|
|
19
|
+
}
|
|
20
|
+
interface RemoteErrorDetailsMap {
|
|
21
|
+
"dsmm-profiles/refused": ProfileErrorInfo;
|
|
22
|
+
"dsmm-profiles/peer-required": {};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Shared wire grammar for native codec validation and local form feedback. */
|
|
26
|
+
export declare function isProfileId(value: unknown): value is string;
|
|
27
|
+
/** Explicit strict Host contract; no SRC fallback or browser-supplied authority. */
|
|
28
|
+
export declare const TYPERT_REMOTE: TypertRemoteContribution;
|
|
29
|
+
export declare const TYPERT_HOST: TypertContribution;
|
|
30
|
+
export default TYPERT_REMOTE;
|
|
31
|
+
//# sourceMappingURL=profile-remote.d.ts.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const errorCodes = new Set(["validation", "conflict", "not-found", "lock-timeout", "unsafe-path", "io", "activation", "corrupt-selection", "limit"]);
|
|
2
|
+
const idPattern = /^[a-z0-9][a-z0-9_-]{0,63}$/u;
|
|
3
|
+
const revisionPattern = /^[a-f0-9]{64}$/u;
|
|
4
|
+
/** Shared wire grammar for native codec validation and local form feedback. */
|
|
5
|
+
export function isProfileId(value) {
|
|
6
|
+
return typeof value === "string" && idPattern.test(value)
|
|
7
|
+
&& !/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])$/iu.test(value);
|
|
8
|
+
}
|
|
9
|
+
function fail(field) { throw new TypeError(`Invalid Deepwork profile wire field: ${field}`); }
|
|
10
|
+
function text(value, field, maximum = 1024) {
|
|
11
|
+
if (typeof value !== "string" || value.length > maximum)
|
|
12
|
+
fail(field);
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
function id(value) {
|
|
16
|
+
const result = text(value, "id", 64);
|
|
17
|
+
if (!isProfileId(result))
|
|
18
|
+
fail("id");
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
function revision(value) {
|
|
22
|
+
const result = text(value, "revision", 64);
|
|
23
|
+
if (!revisionPattern.test(result))
|
|
24
|
+
fail("revision");
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
function selectionRevision(value) { return value === "absent" ? value : revision(value); }
|
|
28
|
+
function object(value, required, optional = []) {
|
|
29
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
30
|
+
fail("object");
|
|
31
|
+
const result = value;
|
|
32
|
+
if (Object.keys(result).some((key) => !required.includes(key) && !optional.includes(key))
|
|
33
|
+
|| required.some((key) => !Object.hasOwn(result, key)))
|
|
34
|
+
fail("object keys");
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
function optional(value, key, parse) {
|
|
38
|
+
return Object.hasOwn(value, key) ? { [key]: parse(value[key]) } : {};
|
|
39
|
+
}
|
|
40
|
+
function errorInfo(value) {
|
|
41
|
+
const item = object(value, ["code", "message"], ["field"]);
|
|
42
|
+
const code = text(item.code, "code");
|
|
43
|
+
if (!errorCodes.has(code))
|
|
44
|
+
fail("code");
|
|
45
|
+
return { code: code, message: text(item.message, "message", 4096), ...optional(item, "field", (input) => text(input, "field", 256)) };
|
|
46
|
+
}
|
|
47
|
+
function readResult(value) {
|
|
48
|
+
const item = object(value, ["id", "revision", "content"], ["label"]);
|
|
49
|
+
return { id: id(item.id), revision: revision(item.revision), content: content(item.content), ...optional(item, "label", (input) => text(input, "label", 120)) };
|
|
50
|
+
}
|
|
51
|
+
function content(value) {
|
|
52
|
+
const result = text(value, "content", 128 * 1024);
|
|
53
|
+
if (new TextEncoder().encode(result).byteLength > 128 * 1024)
|
|
54
|
+
fail("content");
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
function snapshot(value) {
|
|
58
|
+
const item = object(value, ["profiles", "selectedId", "appliedRevision", "selectionRevision"], ["selectionError"]);
|
|
59
|
+
if (!Array.isArray(item.profiles) || item.profiles.length > 128)
|
|
60
|
+
fail("profiles");
|
|
61
|
+
return {
|
|
62
|
+
profiles: item.profiles.map((input) => {
|
|
63
|
+
const row = object(input, ["id", "revision"], ["label", "error"]);
|
|
64
|
+
return { id: text(row.id, "id", 64), revision: row.revision === null ? null : revision(row.revision), ...optional(row, "label", (input) => text(input, "label", 120)), ...optional(row, "error", errorInfo) };
|
|
65
|
+
}),
|
|
66
|
+
selectedId: item.selectedId === null ? null : id(item.selectedId),
|
|
67
|
+
appliedRevision: item.appliedRevision === null ? null : revision(item.appliedRevision),
|
|
68
|
+
selectionRevision: item.selectionRevision === "unavailable" && Object.hasOwn(item, "selectionError") ? "unavailable" : selectionRevision(item.selectionRevision),
|
|
69
|
+
...optional(item, "selectionError", errorInfo),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function saveRequest(value) {
|
|
73
|
+
const item = object(value, ["id", "content", "expectedRevision"]);
|
|
74
|
+
return { id: id(item.id), content: content(item.content), expectedRevision: item.expectedRevision === null ? null : revision(item.expectedRevision) };
|
|
75
|
+
}
|
|
76
|
+
function selectRequest(value) {
|
|
77
|
+
const item = object(value, ["id", "expectedSelectionRevision"], ["expectedRevision"]);
|
|
78
|
+
const result = { id: item.id === null ? null : id(item.id), expectedSelectionRevision: selectionRevision(item.expectedSelectionRevision), ...optional(item, "expectedRevision", revision) };
|
|
79
|
+
if (result.id !== null && result.expectedRevision === undefined)
|
|
80
|
+
fail("expectedRevision");
|
|
81
|
+
if (result.id === null && result.expectedRevision !== undefined)
|
|
82
|
+
fail("expectedRevision");
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
function codec(symbol, parse) {
|
|
86
|
+
return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse }) };
|
|
87
|
+
}
|
|
88
|
+
function descriptor(method, result, parameter) {
|
|
89
|
+
return { id: `@dsmm/dsmm#dsmmProfiles/${method}`, service: "dsmmProfiles", namespace: "dsmmProfiles", method, invocation: { kind: "direct" }, parameters: parameter === undefined ? [] : [{ name: parameter.name, wire: parameter.name, source: "json", codec: parameter.codec }], result };
|
|
90
|
+
}
|
|
91
|
+
/** Explicit strict Host contract; no SRC fallback or browser-supplied authority. */
|
|
92
|
+
export const TYPERT_REMOTE = {
|
|
93
|
+
package: "@dsmm/dsmm",
|
|
94
|
+
descriptors: [
|
|
95
|
+
descriptor("describe", codec("ProfileSnapshot", snapshot)),
|
|
96
|
+
descriptor("read", codec("ProfileReadResult", readResult), { name: "id", codec: codec("ProfileId", id) }),
|
|
97
|
+
descriptor("save", codec("ProfileReadResult", readResult), { name: "request", codec: codec("ProfileSaveRequest", saveRequest) }),
|
|
98
|
+
descriptor("select", codec("ProfileSnapshot", snapshot), { name: "request", codec: codec("ProfileSelectRequest", selectRequest) }),
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
export const TYPERT_HOST = {
|
|
102
|
+
package: "@dsmm/dsmm", face: "host", schemas: [],
|
|
103
|
+
model: { services: [], events: [], objects: [] }, invocations: TYPERT_REMOTE.descriptors,
|
|
104
|
+
};
|
|
105
|
+
export default TYPERT_REMOTE;
|
|
106
|
+
//# sourceMappingURL=profile-remote.js.map
|