@dsmm/dsmm 0.3.14 → 0.3.16
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 +83 -36
- package/docs/agent-presets.md +1 -1
- package/docs/compatibility.md +3 -3
- package/docs/deferred-native-approval-risk.md +1 -1
- package/docs/design.md +1 -1
- package/docs/lsp.md +1 -1
- package/docs/model-routing.md +13 -6
- package/docs/native-permissions.md +1 -1
- package/docs/profiles.md +3 -1
- package/docs/roadmap.md +2 -2
- package/docs/runtime-recovery.md +4 -4
- package/docs/safety-guards.md +1 -1
- package/docs/settings-status.md +4 -2
- package/docs/tui.md +53 -0
- package/dsh-plugin.json +41 -0
- package/lib/client/DeploymentFields.js +3 -1
- package/lib/client/DeploymentPage.js +4 -1
- package/lib/client/EditableChoice.js +5 -2
- package/lib/client/ProfileModelsDialog.d.ts +2 -1
- package/lib/client/ProfileModelsDialog.js +9 -5
- package/lib/client/ProfilesSection.js +1 -1
- package/lib/client/RoleToolView-locales.d.ts +1 -1
- package/lib/client/RoleToolView-locales.js +2 -2
- package/lib/client/SessionProfiles.js +8 -7
- package/lib/client/children-locales.d.ts +1 -1
- package/lib/client/controller.d.ts +13 -1
- package/lib/client/controller.js +114 -20
- package/lib/client/deployment-locales.d.ts +2 -0
- package/lib/client/deployment-locales.js +6 -3
- package/lib/client/deployment-modules.js +1 -1
- package/lib/client/index.js +22 -4
- package/lib/client/locales.d.ts +1 -0
- package/lib/client/locales.js +6 -4
- package/lib/client/session-labels.d.ts +1 -0
- package/lib/client/session-labels.js +3 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +23 -13
- package/lib/client.js +226 -86
- package/lib/commands.d.ts +7 -3
- package/lib/commands.js +20 -11
- package/lib/host-llm.js +6 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -6
- package/lib/model-routing.js +43 -19
- package/lib/profile-diagnostics.js +1 -0
- package/lib/profile-runtime.js +1 -1
- package/lib/request-routing.d.ts +27 -0
- package/lib/request-routing.js +69 -0
- package/lib/role-llm-runtime.js +15 -2
- package/lib/role-routing.d.ts +4 -3
- package/lib/role-routing.js +17 -10
- package/lib/runtime-recovery.js +56 -16
- package/lib/settings.d.ts +3 -0
- package/lib/settings.js +9 -0
- package/lib/state.d.ts +2 -2
- package/lib/state.js +13 -4
- package/lib/status.d.ts +5 -0
- package/lib/status.js +18 -7
- package/lib/tui-actions.d.ts +21 -0
- package/lib/tui-actions.js +301 -0
- package/lib/tui-adapter.d.ts +25 -0
- package/lib/tui-adapter.js +422 -0
- package/lib/tui-types.d.ts +98 -0
- package/lib/tui-types.js +2 -0
- package/package.json +3 -1
package/lib/commands.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DshContext } from "./dsh-types.js";
|
|
1
|
+
import type { DshCommandInvocation, DshCommandResult, DshCommandsRegistry, DshContext } from "./dsh-types.js";
|
|
2
2
|
import { DSMM_STATUS_COMMAND } from "./settings.js";
|
|
3
3
|
import type { DsmmSettingsGetter } from "./settings.js";
|
|
4
4
|
import type { DeepworkModeController } from "./state.js";
|
|
@@ -7,7 +7,11 @@ export interface DeepworkCommandInput {
|
|
|
7
7
|
action: "on" | "off";
|
|
8
8
|
message: string;
|
|
9
9
|
}
|
|
10
|
+
export type DsmmCommandDefinition = Parameters<DshCommandsRegistry["register"]>[0];
|
|
10
11
|
export declare function parseDeepworkCommandInput(rawInput: string): DeepworkCommandInput;
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function handleDsmmStatusCommand(controller: DeepworkModeController, getSettings: DsmmSettingsGetter, invocation: DshCommandInvocation): DshCommandResult;
|
|
13
|
+
export declare function createDeepworkCommandDefinition(controller: DeepworkModeController, getSettings: DsmmSettingsGetter, handler?: DsmmCommandDefinition["handler"]): DsmmCommandDefinition;
|
|
14
|
+
export declare function createDsmmStatusCommandDefinition(controller: DeepworkModeController, getSettings: DsmmSettingsGetter): DsmmCommandDefinition;
|
|
15
|
+
export declare function registerDeepworkCommand(readyCtx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): () => void;
|
|
16
|
+
export declare function registerDsmmStatusCommand(readyCtx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): () => void;
|
|
13
17
|
//# sourceMappingURL=commands.d.ts.map
|
package/lib/commands.js
CHANGED
|
@@ -23,7 +23,7 @@ async function handleDeepworkCommand(controller, getSettings, invocation) {
|
|
|
23
23
|
? { kind: "success", text: "Entering deepwork mode." }
|
|
24
24
|
: { kind: "success", text: "Leaving deepwork mode." };
|
|
25
25
|
}
|
|
26
|
-
function handleDsmmStatusCommand(controller, getSettings, invocation) {
|
|
26
|
+
export function handleDsmmStatusCommand(controller, getSettings, invocation) {
|
|
27
27
|
const input = invocation.rawInput.trim();
|
|
28
28
|
if (input !== "" && input !== "json")
|
|
29
29
|
return { kind: "error", text: "Usage: /dsmm-status [json]" };
|
|
@@ -40,22 +40,31 @@ function handleDsmmStatusCommand(controller, getSettings, invocation) {
|
|
|
40
40
|
text: input === "json" ? JSON.stringify(snapshot, null, 2) : formatDsmmStatus(snapshot)
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
export function
|
|
44
|
-
|
|
45
|
-
commands?.register({
|
|
43
|
+
export function createDeepworkCommandDefinition(controller, getSettings, handler = invocation => handleDeepworkCommand(controller, getSettings, invocation)) {
|
|
44
|
+
return {
|
|
46
45
|
name: getSettings().modeName,
|
|
47
46
|
description: "Enter or leave Deepwork mode",
|
|
48
47
|
input: { hint: "[off|message]" },
|
|
49
|
-
handler
|
|
50
|
-
}
|
|
48
|
+
handler
|
|
49
|
+
};
|
|
51
50
|
}
|
|
52
|
-
export function
|
|
53
|
-
|
|
54
|
-
commands?.register({
|
|
51
|
+
export function createDsmmStatusCommandDefinition(controller, getSettings) {
|
|
52
|
+
return {
|
|
55
53
|
name: DSMM_STATUS_COMMAND,
|
|
56
54
|
description: "Show Deepwork status",
|
|
57
55
|
input: { hint: "[json]" },
|
|
58
|
-
handler:
|
|
59
|
-
}
|
|
56
|
+
handler: invocation => handleDsmmStatusCommand(controller, getSettings, invocation)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function commandDisposer(value) {
|
|
60
|
+
return typeof value === "function" ? value : () => { };
|
|
61
|
+
}
|
|
62
|
+
export function registerDeepworkCommand(readyCtx, controller, getSettings) {
|
|
63
|
+
const commands = readyCtx.get?.("commands") ?? readyCtx.commands;
|
|
64
|
+
return commands === undefined ? () => { } : commandDisposer(commands.register(createDeepworkCommandDefinition(controller, getSettings)));
|
|
65
|
+
}
|
|
66
|
+
export function registerDsmmStatusCommand(readyCtx, controller, getSettings) {
|
|
67
|
+
const commands = readyCtx.get?.("commands") ?? readyCtx.commands;
|
|
68
|
+
return commands === undefined ? () => { } : commandDisposer(commands.register(createDsmmStatusCommandDefinition(controller, getSettings)));
|
|
60
69
|
}
|
|
61
70
|
//# sourceMappingURL=commands.js.map
|
package/lib/host-llm.js
CHANGED
|
@@ -283,7 +283,12 @@ export class DsmmAwareLlmRuntime extends LlmRuntime {
|
|
|
283
283
|
runtime.assertCaptured(captured);
|
|
284
284
|
const providerSignal = AbortSignal.any([captured.frame.signal, captured.admission.signal,
|
|
285
285
|
...captured.generation === undefined ? [] : [captured.generation.signal], captured.revocation.signal, runtime.lifetime.signal]);
|
|
286
|
-
|
|
286
|
+
for await (const chunk of dispatchPrepared(request, providerSignal)) {
|
|
287
|
+
runtime.assertCaptured(captured);
|
|
288
|
+
yield chunk;
|
|
289
|
+
runtime.assertCaptured(captured);
|
|
290
|
+
}
|
|
291
|
+
runtime.assertCaptured(captured);
|
|
287
292
|
}
|
|
288
293
|
finally {
|
|
289
294
|
runtime.finishCaptured(captured);
|
package/lib/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export { DSMM_STATUS_VERSION, createDsmmStatusSnapshot, formatDsmmStatus } from
|
|
|
23
23
|
export type { DsmmStatusSnapshot } from "./status.js";
|
|
24
24
|
export type * from "./dsh-types.js";
|
|
25
25
|
export { DSMM_SKILL_NAMES, DSMM_SETTINGS_SCHEMA, DEFAULT_DSMM_SETTINGS, MVP_SKILL_NAMES, deploymentEditorSchema, isRoleEnabled, resolveConfig, resolveDeployment, resolveRoleRouting, registerSettings, validateNativeConfig } from "./settings.js";
|
|
26
|
-
export type { DsmmFinalReviewPolicy, DsmmGitWritePolicy, DsmmGitWriteScope, DsmmGuardScope, DsmmGuardSettings, DsmmPluginConfig, DsmmNativeConfig, DsmmModelRoute, DsmmRoleRoutingConfig, DsmmRoleRouting, DsmmRecoveryRoute, DsmmRuntimeRecoverySettings, DsmmSettings, DsmmSettingsGetter, DsmmSkillName, DsmmWorkflowSettings, MvpSkillName, DsmmSubagentSettings, DsmmDeploymentSnapshot } from "./settings.js";
|
|
26
|
+
export type { DsmmFinalReviewPolicy, DsmmGitWritePolicy, DsmmGitWriteScope, DsmmGuardScope, DsmmGuardSettings, DsmmPluginConfig, DsmmNativeConfig, DsmmModelRoute, DsmmRootModelPolicy, DsmmRoleRoutingConfig, DsmmRoleRouting, DsmmRecoveryRoute, DsmmRuntimeRecoverySettings, DsmmSettings, DsmmSettingsGetter, DsmmSkillName, DsmmWorkflowSettings, MvpSkillName, DsmmSubagentSettings, DsmmDeploymentSnapshot } from "./settings.js";
|
|
27
27
|
export { createProfileRuntime, DsmmProfileRuntime } from "./profile-runtime.js";
|
|
28
28
|
export type { DsmmProfileRuntimeStore, DsmmProfileRuntimeOptions } from "./profile-runtime.js";
|
|
29
29
|
export { resolveDshHome } from "./dsh-home.js";
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, symbols } from "@deepseek-ai/cordis";
|
|
2
|
-
import {
|
|
2
|
+
import { registerDsmmTuiAdapter } from "./tui-adapter.js";
|
|
3
3
|
import { registerSafetyGuards } from "./guards.js";
|
|
4
4
|
import { registerDeepworkPrompt } from "./mode.js";
|
|
5
5
|
import { registerAgentSkills } from "./preset-skills.js";
|
|
@@ -155,11 +155,7 @@ export async function apply(input, config = {}, startupOptions = {}) {
|
|
|
155
155
|
}
|
|
156
156
|
installed.add(agent);
|
|
157
157
|
});
|
|
158
|
-
ctx
|
|
159
|
-
registerDsmmStatusCommand(scope, controller, getSettings);
|
|
160
|
-
if (startup.settings.modules.deepwork.enabled)
|
|
161
|
-
registerDeepworkCommand(scope, controller, getSettings);
|
|
162
|
-
});
|
|
158
|
+
registerDsmmTuiAdapter(ctx, { controller, getSettings, profiles, deployment });
|
|
163
159
|
ctx.inject(["typert"], scope => { registerConfigRpc(scope, deployment, startup.settings, () => profiles, startup.sources, mountedPermission); new DsmmProfilesHost(scope, profiles); registerRoleControlRpc(scope, nativeAdmission); });
|
|
164
160
|
const permissions = createCorePermissionAuthority(ctx, { getSettings, rolePolicy: policy, signal: lifetime.signal });
|
|
165
161
|
const installPermissions = () => ctx.inject(["tools", ...(ctx.fiber.entry === undefined ? [] : ["settings"])], scope => {
|
package/lib/model-routing.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DsmmAwareLlmRuntime } from "./host-llm.js";
|
|
2
|
-
import { applyModelRoute, clearRoleRouteLock, effectiveRoleFallbackRoutes, establishRolePolicy, latestNativeModelSelection, nativeModelSelectionWasAccepted, orderedModelRoutes, persistedRoleRoute, pinRoleRoute, roleRouteLock, selectInitialModelRoute, sameExactModelRoute, sameModelRoute, takeAdmittedRecoveryRoute } from "./role-routing.js";
|
|
3
|
-
import { resolveAdmittedDsmmRole } from "./role-policy.js";
|
|
2
|
+
import { applyModelRoute, clearRoleRouteLock, effectiveRoleFallbackRoutes, establishRolePolicy, latestNativeModelSelection, nativeModelSelectionWasAccepted, orderedModelRoutes, persistedRoleRoute, pinRoleRoute, roleRouteLock, selectInitialModelRoute, selectInitialModelRouteChoice, sameExactModelRoute, sameModelRoute, takeAdmittedRecoveryRoute } from "./role-routing.js";
|
|
4
3
|
import { childOwnedSessionEvents, sessionEvents } from "./session-scope.js";
|
|
5
4
|
import { isCurrentRecoveryStep } from "./recovery-policy.js";
|
|
6
5
|
import { capturedRoleInvocation } from "./role-invocation.js";
|
|
7
|
-
import { modelRouteFromCall } from "./role-llm.js";
|
|
6
|
+
import { modelRouteFromCall, projectModelRouteParameters } from "./role-llm.js";
|
|
8
7
|
import { configuredModelParameterPolicy, resolvedModelParameterPolicy } from "./model-parameter-policy.js";
|
|
9
8
|
import { registerRuntimeRecovery } from "./runtime-recovery.js";
|
|
9
|
+
import { captureRequestRouting, captureRequestRoute } from "./request-routing.js";
|
|
10
10
|
const preparations = new WeakMap();
|
|
11
11
|
export async function prepareDsmmRequest(frame, proposal, assertCurrent) {
|
|
12
12
|
const prepare = preparations.get(frame.agent);
|
|
@@ -21,45 +21,58 @@ export function registerModelRouting(ctx, controller, getSettings, agent) {
|
|
|
21
21
|
return;
|
|
22
22
|
installedContexts.add(readyCtx);
|
|
23
23
|
const lockedAgents = new Set();
|
|
24
|
+
let active = true;
|
|
24
25
|
const assembledSelections = new WeakMap();
|
|
25
26
|
let dispose, disposeAgent, disposeAssembly;
|
|
26
27
|
try {
|
|
27
28
|
const owned = agent !== undefined && readyCtx.get?.("llm") instanceof DsmmAwareLlmRuntime;
|
|
28
29
|
let recovery;
|
|
29
|
-
registerRuntimeRecovery(readyCtx, controller, getSettings,
|
|
30
|
+
registerRuntimeRecovery(readyCtx, controller, getSettings, prepare => { recovery = prepare; });
|
|
30
31
|
disposeAssembly = readyCtx.on("system-prompt/assemble", async (_assembly, context, next) => {
|
|
31
32
|
if (context.agent !== undefined && context.signal !== undefined)
|
|
32
33
|
assembledSelections.set(context.agent, { signal: context.signal, intent: latestNativeModelSelection(context.agent) });
|
|
33
34
|
return next();
|
|
34
35
|
}, { prepend: true });
|
|
35
36
|
const prepare = async (frame, proposal, assertCurrent = () => frame.signal.throwIfAborted()) => {
|
|
37
|
+
if (frame.signal.aborted)
|
|
38
|
+
return proposal;
|
|
39
|
+
const decision = captureRequestRouting(frame, readyCtx, controller, getSettings, () => {
|
|
40
|
+
if (!active)
|
|
41
|
+
throw new Error("DSMM routing owner retired");
|
|
42
|
+
assertCurrent();
|
|
43
|
+
});
|
|
36
44
|
const downstream = recovery === undefined ? proposal : await recovery(frame, proposal);
|
|
37
45
|
if (frame.signal.aborted)
|
|
38
46
|
return downstream;
|
|
39
|
-
assertCurrent();
|
|
40
|
-
const settings
|
|
47
|
+
decision.assertCurrent();
|
|
48
|
+
const { settings, admission, role, configuredRoot } = decision;
|
|
41
49
|
const parameterPolicy = admission === undefined ? configuredModelParameterPolicy(settings) : resolvedModelParameterPolicy(admission);
|
|
42
|
-
if (!settings.modules.deepwork.enabled)
|
|
50
|
+
if (!settings.modules.deepwork.enabled) {
|
|
51
|
+
captureRequestRoute(frame, decision);
|
|
43
52
|
return downstream;
|
|
53
|
+
}
|
|
44
54
|
const ordinaryRoot = frame.agent.session.header?.origin !== "subagent";
|
|
45
55
|
const admitted = takeAdmittedRecoveryRoute(frame);
|
|
46
|
-
const role = resolveAdmittedDsmmRole(frame.agent, settings, controller.active(frame.agent, settings.defaultActive));
|
|
47
56
|
const policy = role === undefined ? undefined : settings.roleRouting[role];
|
|
48
57
|
const invocation = capturedRoleInvocation(frame.agent);
|
|
49
58
|
const primary = invocation?.initialRoute ?? policy?.primary;
|
|
50
59
|
const identity = await establishRolePolicy(frame, settings, role, readyCtx, admission?.epoch);
|
|
51
|
-
assertCurrent();
|
|
60
|
+
decision.assertCurrent();
|
|
52
61
|
frame.signal.throwIfAborted();
|
|
53
62
|
const fallbacks = effectiveRoleFallbackRoutes(settings, role);
|
|
54
63
|
const currentStep = isCurrentRecoveryStep(ordinaryRoot ? sessionEvents(frame.agent.session) : childOwnedSessionEvents(frame.agent.session), frame.turn, frame.step);
|
|
55
|
-
if (
|
|
64
|
+
if (configuredRoot && !currentStep)
|
|
65
|
+
throw new Error("Configured root has no current request step");
|
|
66
|
+
if (role === undefined || identity === undefined || !currentStep) {
|
|
67
|
+
captureRequestRoute(frame, decision);
|
|
56
68
|
return downstream;
|
|
69
|
+
}
|
|
57
70
|
let lock = roleRouteLock(frame.agent, identity);
|
|
58
71
|
const exactPolicy = invocation === undefined ? primary !== undefined || policy?.fallbackRoutes !== undefined || fallbacks.length > 0
|
|
59
72
|
: invocation.routeSource !== "inherited" || invocation.exactEffort || fallbacks.length > 0;
|
|
60
73
|
const captured = assembledSelections.get(frame.agent);
|
|
61
74
|
const manual = captured?.signal === frame.signal ? captured.intent : undefined;
|
|
62
|
-
if (ordinaryRoot) {
|
|
75
|
+
if (ordinaryRoot && !configuredRoot) {
|
|
63
76
|
const selected = modelRouteFromCall(downstream);
|
|
64
77
|
if (lock === undefined || !sameExactModelRoute(lock.route, selected) || lock.manualSelectionSeq !== manual?.seq) {
|
|
65
78
|
const generation = (lock?.generation ?? -1) + 1;
|
|
@@ -68,11 +81,12 @@ export function registerModelRouting(ctx, controller, getSettings, agent) {
|
|
|
68
81
|
lock.generation = generation;
|
|
69
82
|
lockedAgents.add(frame.agent);
|
|
70
83
|
}
|
|
84
|
+
captureRequestRoute(frame, decision, "native");
|
|
71
85
|
return downstream;
|
|
72
86
|
}
|
|
73
87
|
const llm = frame.agent.ctx?.get?.("llm") ?? readyCtx.get?.("llm") ?? readyCtx.llm;
|
|
74
88
|
const assembledManual = manual !== undefined && sameModelRoute(downstream, manual.route) && downstream.reasoningEffort === manual.route.reasoningEffort;
|
|
75
|
-
if (manual !== undefined && lock?.manualSelectionSeq !== manual.seq
|
|
89
|
+
if (!configuredRoot && manual !== undefined && lock?.manualSelectionSeq !== manual.seq
|
|
76
90
|
&& (assembledManual || nativeModelSelectionWasAccepted(frame.agent, manual))) {
|
|
77
91
|
const selected = assembledManual ? modelRouteFromCall(downstream) : manual.route;
|
|
78
92
|
const generation = (lock?.generation ?? -1) + 1;
|
|
@@ -82,11 +96,15 @@ export function registerModelRouting(ctx, controller, getSettings, agent) {
|
|
|
82
96
|
lockedAgents.add(frame.agent);
|
|
83
97
|
}
|
|
84
98
|
// A consumed explicit selection must not undo an admitted fallback.
|
|
85
|
-
if (lock?.manualSelectionSeq !== undefined)
|
|
99
|
+
if (!configuredRoot && lock?.manualSelectionSeq !== undefined) {
|
|
100
|
+
captureRequestRoute(frame, decision, "native");
|
|
86
101
|
return applyModelRoute(downstream, lock.route);
|
|
87
|
-
|
|
102
|
+
}
|
|
103
|
+
if (admitted !== undefined) {
|
|
104
|
+
captureRequestRoute(frame, decision, lock?.effortSource);
|
|
88
105
|
return applyModelRoute(downstream, admitted);
|
|
89
|
-
|
|
106
|
+
}
|
|
107
|
+
const accepted = persistedRoleRoute(frame, primary, fallbacks, identity, configuredRoot);
|
|
90
108
|
if (lock !== undefined && accepted !== undefined && !sameExactModelRoute(accepted, lock.route)) {
|
|
91
109
|
lock.route = { ...accepted };
|
|
92
110
|
lock.candidateIndex = lock.candidates.findIndex(candidate => sameExactModelRoute(candidate, accepted));
|
|
@@ -96,16 +114,21 @@ export function registerModelRouting(ctx, controller, getSettings, agent) {
|
|
|
96
114
|
lock.rateLimits = 0;
|
|
97
115
|
}
|
|
98
116
|
if (lock === undefined) {
|
|
99
|
-
const inherited = modelRouteFromCall(downstream);
|
|
117
|
+
const inherited = primary === undefined ? modelRouteFromCall(downstream) : undefined;
|
|
100
118
|
const candidates = invocation?.candidates ?? orderedModelRoutes([primary ?? inherited, ...fallbacks]);
|
|
101
|
-
const
|
|
102
|
-
|
|
119
|
+
const resolver = parameterPolicy.mode === "passthrough" ? readyCtx.get?.("dsmmLlmRoutes") : undefined;
|
|
120
|
+
const choice = configuredRoot ? await selectInitialModelRouteChoice(llm ?? {}, candidates, frame.signal, resolver, parameterPolicy.mode === "native-defaults" ? route => modelRouteFromCall(projectModelRouteParameters(route, primary === undefined && sameExactModelRoute(route, inherited) ? "native" : "dsmm-config", false)) : undefined, decision.assertCurrent) : undefined;
|
|
121
|
+
const selected = choice?.route ?? accepted ?? invocation?.initialRoute ?? (exactPolicy ? await selectInitialModelRoute(llm ?? {}, candidates, frame.signal, resolver, decision.assertCurrent) : inherited);
|
|
122
|
+
decision.assertCurrent();
|
|
103
123
|
frame.signal.throwIfAborted();
|
|
104
|
-
lock = pinRoleRoute(frame.agent, identity, selected, candidates, { preserveCandidates: parameterPolicy.mode === "native-defaults", initialCandidate: accepted ?? invocation?.selectedCandidate });
|
|
124
|
+
lock = pinRoleRoute(frame.agent, identity, selected, candidates, { preserveCandidates: parameterPolicy.mode === "native-defaults", initialCandidate: choice?.requestedRoute ?? accepted ?? invocation?.selectedCandidate });
|
|
125
|
+
if (configuredRoot)
|
|
126
|
+
lock.effortSource = primary === undefined && lock.candidateIndex === 0 ? "native" : "dsmm-config";
|
|
105
127
|
if (accepted !== undefined)
|
|
106
128
|
lock.startupSettled = true;
|
|
107
129
|
lockedAgents.add(frame.agent);
|
|
108
130
|
}
|
|
131
|
+
captureRequestRoute(frame, decision, configuredRoot ? lock.effortSource : undefined);
|
|
109
132
|
return applyModelRoute(downstream, lock.route);
|
|
110
133
|
};
|
|
111
134
|
if (owned) {
|
|
@@ -126,6 +149,7 @@ export function registerModelRouting(ctx, controller, getSettings, agent) {
|
|
|
126
149
|
throw error;
|
|
127
150
|
}
|
|
128
151
|
readyCtx.effect?.(() => () => {
|
|
152
|
+
active = false;
|
|
129
153
|
for (const agent of lockedAgents)
|
|
130
154
|
clearRoleRouteLock(agent);
|
|
131
155
|
lockedAgents.clear();
|
|
@@ -33,6 +33,7 @@ const roleRouting = { primary: route, fallbackRoutes: [route], strategy: null, r
|
|
|
33
33
|
const configFields = {
|
|
34
34
|
permissionControl: schemaFieldShape(permissionControlSchema),
|
|
35
35
|
modelParameters: { passthrough: null },
|
|
36
|
+
rootModelPolicy: null,
|
|
36
37
|
locale: null, modeName: null, section: null, defaultActive: null, promptOrder: null,
|
|
37
38
|
deepseekV4ProCalibration: null, deepseekV4ProDefaultReasoningEffort: null, deepseekFlashCalibration: null, deepseekFlashDefaultReasoningEffort: null,
|
|
38
39
|
deepseekV4ProMaxReasoningPresets: null, deepseekFlashMaxReasoningPresets: null,
|
package/lib/profile-runtime.js
CHANGED
|
@@ -240,7 +240,7 @@ export class DsmmProfileRuntime {
|
|
|
240
240
|
check(maintenanceSignal);
|
|
241
241
|
if (hasOpenTurn(sessionEvents(agent.session)))
|
|
242
242
|
throw new DsmmProfileError("busy", "A session turn is still open.");
|
|
243
|
-
await this.mode.selectIdle(agent, request.active, admitted.settings.defaultActive);
|
|
243
|
+
await this.mode.selectIdle(agent, request.active, admitted.settings.defaultActive, () => check(maintenanceSignal));
|
|
244
244
|
const role = resolveAdmittedDsmmRole(agent, admitted.settings, this.mode.active(agent, admitted.settings.defaultActive));
|
|
245
245
|
const profileModel = role === undefined ? undefined : admitted.settings.roleRouting[role]?.primary;
|
|
246
246
|
const deepwork = this.mode.describe(agent, admitted.settings.defaultActive);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AgentRequestFrame, DshAgent, DshContext } from "./dsh-types.js";
|
|
2
|
+
import type { DsmmSettingsGetter } from "./settings.js";
|
|
3
|
+
import type { DeepworkModeController } from "./state.js";
|
|
4
|
+
import type { DsmmEffortSource } from "./host-llm.js";
|
|
5
|
+
import { resolveAdmittedDsmmRole } from "./role-policy.js";
|
|
6
|
+
/** Shared by selection, recovery and the native prepared-call owner. */
|
|
7
|
+
export interface DsmmRequestRoutingDecision {
|
|
8
|
+
readonly frame: AgentRequestFrame;
|
|
9
|
+
readonly settings: ReturnType<DsmmSettingsGetter>;
|
|
10
|
+
readonly admission: ReturnType<NonNullable<DsmmSettingsGetter["admission"]>> | undefined;
|
|
11
|
+
readonly role: ReturnType<typeof resolveAdmittedDsmmRole>;
|
|
12
|
+
readonly policy: string | undefined;
|
|
13
|
+
readonly configuredRoot: boolean;
|
|
14
|
+
assertPolicyCurrent(): void;
|
|
15
|
+
assertCurrent(): void;
|
|
16
|
+
}
|
|
17
|
+
declare const results: WeakMap<AgentRequestFrame, {
|
|
18
|
+
decision: DsmmRequestRoutingDecision;
|
|
19
|
+
effortSource?: DsmmEffortSource;
|
|
20
|
+
assertCurrent(): void;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function currentRequestRouting(agent: DshAgent): DsmmRequestRoutingDecision | undefined;
|
|
23
|
+
export declare function preparedRequestRouting(frame: AgentRequestFrame): ReturnType<typeof results.get>;
|
|
24
|
+
export declare function captureRequestRouting(frame: AgentRequestFrame, ctx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter, assertOwner: () => void): DsmmRequestRoutingDecision;
|
|
25
|
+
export declare function captureRequestRoute(frame: AgentRequestFrame, decision: DsmmRequestRoutingDecision, effortSource?: DsmmEffortSource): void;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=request-routing.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { resolveAdmittedDsmmRole } from "./role-policy.js";
|
|
2
|
+
import { liveRolePolicyIdentity, roleRouteLock } from "./role-routing.js";
|
|
3
|
+
import { childOwnedSessionEvents, sessionEvents } from "./session-scope.js";
|
|
4
|
+
import { isCurrentRecoveryStep } from "./recovery-policy.js";
|
|
5
|
+
const decisions = new WeakMap();
|
|
6
|
+
const routeAssertions = new WeakMap();
|
|
7
|
+
const results = new WeakMap();
|
|
8
|
+
export function currentRequestRouting(agent) { return decisions.get(agent); }
|
|
9
|
+
export function preparedRequestRouting(frame) { return results.get(frame); }
|
|
10
|
+
export function captureRequestRouting(frame, ctx, controller, getSettings, assertOwner) {
|
|
11
|
+
const settings = getSettings(frame.agent), admission = getSettings.admission?.(frame.agent);
|
|
12
|
+
const role = settings.modules.deepwork.enabled
|
|
13
|
+
? resolveAdmittedDsmmRole(frame.agent, settings, controller.active(frame.agent, settings.defaultActive)) : undefined;
|
|
14
|
+
const policy = liveRolePolicyIdentity(frame.agent, settings, role, admission?.epoch);
|
|
15
|
+
const modeRevision = controller.describe(frame.agent, settings.defaultActive).revision;
|
|
16
|
+
const initialLock = policy === undefined ? undefined : roleRouteLock(frame.agent, policy);
|
|
17
|
+
const initialGeneration = initialLock?.generation;
|
|
18
|
+
const captured = Object.freeze({ ...frame });
|
|
19
|
+
const events = () => captured.agent.session.header?.origin === "subagent" ? childOwnedSessionEvents(captured.agent.session) : sessionEvents(captured.agent.session);
|
|
20
|
+
const currentStep = isCurrentRecoveryStep(events(), captured.turn, captured.step);
|
|
21
|
+
const decision = Object.freeze({ frame: captured, settings, admission, role, policy,
|
|
22
|
+
configuredRoot: captured.agent.session.header?.origin !== "subagent" && admission !== undefined
|
|
23
|
+
&& admission.settings === settings && settings.rootModelPolicy === "configured" && settings.modules.deepwork.enabled && role !== undefined,
|
|
24
|
+
assertPolicyCurrent() {
|
|
25
|
+
assertOwner();
|
|
26
|
+
captured.signal.throwIfAborted();
|
|
27
|
+
if (frame.agent !== captured.agent || frame.signal !== captured.signal || frame.turn !== captured.turn || frame.step !== captured.step) {
|
|
28
|
+
throw new Error("DSMM request frame changed");
|
|
29
|
+
}
|
|
30
|
+
const agents = ctx.get?.("agents");
|
|
31
|
+
const current = getSettings(captured.agent), currentAdmission = getSettings.admission?.(captured.agent);
|
|
32
|
+
const currentRole = current.modules.deepwork.enabled
|
|
33
|
+
? resolveAdmittedDsmmRole(captured.agent, current, controller.active(captured.agent, current.defaultActive)) : undefined;
|
|
34
|
+
if (agents !== undefined && (captured.agent.id === undefined || agents.get(captured.agent.id) !== captured.agent)
|
|
35
|
+
|| current !== settings || currentAdmission !== admission || currentRole !== role
|
|
36
|
+
|| controller.describe(captured.agent, current.defaultActive).revision !== modeRevision
|
|
37
|
+
|| liveRolePolicyIdentity(captured.agent, current, currentRole, currentAdmission?.epoch) !== policy
|
|
38
|
+
|| currentStep && !isCurrentRecoveryStep(events(), captured.turn, captured.step)) {
|
|
39
|
+
throw new Error("DSMM request routing admission is no longer current");
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
assertCurrent() {
|
|
43
|
+
decision.assertPolicyCurrent();
|
|
44
|
+
if (decisions.get(captured.agent) !== decision)
|
|
45
|
+
throw new Error("DSMM request routing was superseded");
|
|
46
|
+
const assertRoute = routeAssertions.get(decision);
|
|
47
|
+
if (assertRoute !== undefined)
|
|
48
|
+
assertRoute();
|
|
49
|
+
else if (decision.configuredRoot && initialLock !== undefined
|
|
50
|
+
&& (roleRouteLock(captured.agent, policy) !== initialLock || initialLock.generation !== initialGeneration)) {
|
|
51
|
+
throw new Error("DSMM request route generation changed");
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
decisions.set(frame.agent, decision);
|
|
56
|
+
return decision;
|
|
57
|
+
}
|
|
58
|
+
export function captureRequestRoute(frame, decision, effortSource) {
|
|
59
|
+
decision.assertCurrent();
|
|
60
|
+
const lock = decision.policy === undefined ? undefined : roleRouteLock(frame.agent, decision.policy);
|
|
61
|
+
const generation = lock?.generation;
|
|
62
|
+
routeAssertions.set(decision, () => {
|
|
63
|
+
const current = decision.policy === undefined ? undefined : roleRouteLock(frame.agent, decision.policy);
|
|
64
|
+
if (current !== lock || current?.generation !== generation)
|
|
65
|
+
throw new Error("DSMM request route generation changed");
|
|
66
|
+
});
|
|
67
|
+
results.set(frame, Object.freeze({ decision, effortSource, assertCurrent: decision.assertCurrent }));
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=request-routing.js.map
|
package/lib/role-llm-runtime.js
CHANGED
|
@@ -3,6 +3,8 @@ import { captureDsmmEffortSource, requiresDsmmCallAdmission, snapshotDsmmCall }
|
|
|
3
3
|
import { resolvedModelParameterPolicy } from "./model-parameter-policy.js";
|
|
4
4
|
import { modelRouteFromCall, projectModelRouteParameters } from "./role-llm.js";
|
|
5
5
|
import { prepareDsmmRequest } from "./model-routing.js";
|
|
6
|
+
import { preparedRequestRouting } from "./request-routing.js";
|
|
7
|
+
import { roleRouteLock } from "./role-routing.js";
|
|
6
8
|
/** Connect the cold Host LLM owner to the existing exact Agent/role admission authority. */
|
|
7
9
|
export function createDsmmRoleLlmOwner(ctx, providers) {
|
|
8
10
|
const nativeFallback = async (frame, proposal) => {
|
|
@@ -21,7 +23,7 @@ export function createDsmmRoleLlmOwner(ctx, providers) {
|
|
|
21
23
|
if (core === undefined) {
|
|
22
24
|
return nativeFallback(frame, proposal);
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
let admission = await core.admit(frame);
|
|
25
27
|
if (admission === undefined) {
|
|
26
28
|
return nativeFallback(frame, proposal);
|
|
27
29
|
}
|
|
@@ -35,9 +37,18 @@ export function createDsmmRoleLlmOwner(ctx, providers) {
|
|
|
35
37
|
const routed = await prepareDsmmRequest(frame, proposal, admission.assertCurrent);
|
|
36
38
|
admission.assertCurrent();
|
|
37
39
|
frame.signal.throwIfAborted();
|
|
38
|
-
const
|
|
40
|
+
const routing = preparedRequestRouting(frame);
|
|
41
|
+
if (routing === undefined)
|
|
42
|
+
throw new Error("DSMM request lost its routing capture");
|
|
43
|
+
const originalAdmission = admission;
|
|
44
|
+
admission = Object.freeze({ ...originalAdmission, assertCurrent() { originalAdmission.assertCurrent(); routing.assertCurrent(); } });
|
|
45
|
+
const effortSource = routing.effortSource ?? captureDsmmEffortSource(frame.agent);
|
|
39
46
|
const config = snapshotDsmmCall(projectModelRouteParameters(modelRouteFromCall(routed), effortSource, policy.mode !== "native-defaults"));
|
|
40
47
|
admission.assertCurrent();
|
|
48
|
+
if (routing.decision.configuredRoot && routing.decision.policy !== undefined) {
|
|
49
|
+
const lock = roleRouteLock(agent, routing.decision.policy);
|
|
50
|
+
lock.route = modelRouteFromCall(config);
|
|
51
|
+
}
|
|
41
52
|
if (policy.mode !== "passthrough") {
|
|
42
53
|
await ctx.get("llm").resolveCallConfig(config, frame.signal);
|
|
43
54
|
admission.assertCurrent();
|
|
@@ -51,6 +62,8 @@ export function createDsmmRoleLlmOwner(ctx, providers) {
|
|
|
51
62
|
return { kind: "stock", admission, config, effortSource };
|
|
52
63
|
}
|
|
53
64
|
catch (error) {
|
|
65
|
+
admission.assertCurrent();
|
|
66
|
+
frame.signal.throwIfAborted();
|
|
54
67
|
if (!(error instanceof LlmError) || error.code !== "UNSUPPORTED_OPTION"
|
|
55
68
|
&& (error.code !== "UNSUPPORTED_REASONING_EFFORT" || effortSource === "native"))
|
|
56
69
|
throw error;
|
package/lib/role-routing.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface RoleRouteLock {
|
|
|
17
17
|
switches: number;
|
|
18
18
|
totalDelayMs: number;
|
|
19
19
|
manualSelectionSeq?: number;
|
|
20
|
+
effortSource?: "native" | "dsmm-config";
|
|
20
21
|
}
|
|
21
22
|
export interface NativeModelSelectionIntent {
|
|
22
23
|
seq: number;
|
|
@@ -31,8 +32,8 @@ export declare function nativeModelSelectionWasAccepted(agent: DshAgent, intent:
|
|
|
31
32
|
export declare function isUnavailableRouteFailure(error: unknown, nativeRequestFailure?: boolean): boolean;
|
|
32
33
|
export declare function orderedModelRoutes(candidates: readonly DsmmModelRoute[]): DsmmModelRoute[];
|
|
33
34
|
/** Exact metadata preparation, never a completion or advisory catalog health check. */
|
|
34
|
-
export declare function selectInitialModelRoute(llm: DshLlmRuntime, candidates: readonly DsmmModelRoute[], signal?: AbortSignal, resolver?: DsmmLlmRouteResolver): Promise<DsmmModelRoute>;
|
|
35
|
-
export declare function selectInitialModelRouteChoice(llm: DshLlmRuntime, candidates: readonly DsmmModelRoute[], signal?: AbortSignal, resolver?: DsmmLlmRouteResolver): Promise<{
|
|
35
|
+
export declare function selectInitialModelRoute(llm: DshLlmRuntime, candidates: readonly DsmmModelRoute[], signal?: AbortSignal, resolver?: DsmmLlmRouteResolver, assertCurrent?: () => void): Promise<DsmmModelRoute>;
|
|
36
|
+
export declare function selectInitialModelRouteChoice(llm: DshLlmRuntime, candidates: readonly DsmmModelRoute[], signal?: AbortSignal, resolver?: DsmmLlmRouteResolver, project?: (route: DsmmModelRoute) => DsmmModelRoute, assertCurrent?: () => void): Promise<{
|
|
36
37
|
route: DsmmModelRoute;
|
|
37
38
|
requestedRoute: DsmmModelRoute;
|
|
38
39
|
}>;
|
|
@@ -52,5 +53,5 @@ export declare function effectiveRoleFallbackRoutes(settings: DsmmSettings, role
|
|
|
52
53
|
export declare function applyModelRoute(config: DshLlmCallConfig, route: DsmmModelRoute): DshLlmCallConfig;
|
|
53
54
|
export declare function sameModelRoute(left: Pick<DsmmModelRoute, "provider" | "model">, right: Pick<DsmmModelRoute, "provider" | "model">): boolean;
|
|
54
55
|
/** Accepted post-policy route changes are durable host/recovery ownership, not a new primary request. */
|
|
55
|
-
export declare function persistedRoleRoute(frame: Pick<AgentRequestFrame, "agent">, primary: DsmmModelRoute | undefined, fallbacks?: readonly DsmmModelRoute[], identity?: string): DsmmModelRoute | undefined;
|
|
56
|
+
export declare function persistedRoleRoute(frame: Pick<AgentRequestFrame, "agent">, primary: DsmmModelRoute | undefined, fallbacks?: readonly DsmmModelRoute[], identity?: string, configuredRoot?: boolean): DsmmModelRoute | undefined;
|
|
56
57
|
//# sourceMappingURL=role-routing.d.ts.map
|
package/lib/role-routing.js
CHANGED
|
@@ -51,26 +51,30 @@ export function orderedModelRoutes(candidates) {
|
|
|
51
51
|
return routes;
|
|
52
52
|
}
|
|
53
53
|
/** Exact metadata preparation, never a completion or advisory catalog health check. */
|
|
54
|
-
export async function selectInitialModelRoute(llm, candidates, signal, resolver) {
|
|
55
|
-
return (await selectInitialModelRouteChoice(llm, candidates, signal, resolver)).route;
|
|
54
|
+
export async function selectInitialModelRoute(llm, candidates, signal, resolver, assertCurrent) {
|
|
55
|
+
return (await selectInitialModelRouteChoice(llm, candidates, signal, resolver, undefined, assertCurrent)).route;
|
|
56
56
|
}
|
|
57
|
-
export async function selectInitialModelRouteChoice(llm, candidates, signal, resolver) {
|
|
57
|
+
export async function selectInitialModelRouteChoice(llm, candidates, signal, resolver, project, assertCurrent) {
|
|
58
58
|
if (resolver === undefined && llm.resolveCallConfig === undefined)
|
|
59
59
|
throw new Error("dsmm route admission requires the Host model service");
|
|
60
60
|
let unavailable;
|
|
61
61
|
for (const route of orderedModelRoutes(candidates)) {
|
|
62
|
+
assertCurrent?.();
|
|
62
63
|
signal?.throwIfAborted();
|
|
63
64
|
try {
|
|
64
65
|
if (resolver === undefined && llm.listProviders !== undefined && !llm.listProviders().some(provider => provider.id === route.provider))
|
|
65
66
|
throw new DsmmMissingProviderError();
|
|
66
|
-
const
|
|
67
|
-
const
|
|
67
|
+
const projected = project?.(route) ?? route;
|
|
68
|
+
const call = modelRouteToCall(projected);
|
|
69
|
+
const prepared = resolver === undefined ? await llm.resolveCallConfig(call, signal) : await resolver.resolveRoute(projected, signal);
|
|
70
|
+
assertCurrent?.();
|
|
68
71
|
if (resolver === undefined && call.customParameters !== undefined)
|
|
69
72
|
throw new LlmError("Raw route parameters require their declared Host provider owner", "UNSUPPORTED_ROUTE_PARAMETERS");
|
|
70
73
|
signal?.throwIfAborted();
|
|
71
74
|
return { route: canonicalRoute(prepared), requestedRoute: canonicalRoute(route) };
|
|
72
75
|
}
|
|
73
76
|
catch (error) {
|
|
77
|
+
assertCurrent?.();
|
|
74
78
|
signal?.throwIfAborted();
|
|
75
79
|
if (!isUnavailableRouteFailure(error))
|
|
76
80
|
throw error;
|
|
@@ -96,7 +100,7 @@ export function roleRouteRuntimeState(agent, settings, role, epoch) {
|
|
|
96
100
|
const resolved = resolveRoleRuntimePolicy(settings, role);
|
|
97
101
|
const identity = liveRolePolicyIdentity(agent, settings, role, epoch);
|
|
98
102
|
const lock = identity === undefined ? undefined : roleRouteLock(agent, identity);
|
|
99
|
-
return { ...(role === undefined ? {} : { role }), strategy: agent.session.header?.origin === "subagent" ? resolved.strategy : "startup-lock", rateLimit: { ...resolved.rateLimit },
|
|
103
|
+
return { ...(role === undefined ? {} : { role }), strategy: agent.session.header?.origin === "subagent" || epoch !== undefined && settings.rootModelPolicy === "configured" && settings.modules.deepwork.enabled && role !== undefined ? resolved.strategy : "startup-lock", rateLimit: { ...resolved.rateLimit },
|
|
100
104
|
...(lock === undefined ? {} : { route: { ...lock.route } }), retries: lock?.retries ?? 0,
|
|
101
105
|
rateLimitFailures: lock?.rateLimits ?? 0, switches: lock?.switches ?? 0, totalDelayMs: lock?.totalDelayMs ?? 0 };
|
|
102
106
|
}
|
|
@@ -107,7 +111,7 @@ export function liveRolePolicyIdentity(agent, settings, role, epoch) {
|
|
|
107
111
|
}
|
|
108
112
|
const policy = settings.roleRouting[role];
|
|
109
113
|
const resolved = resolveRoleRuntimePolicy(settings, role);
|
|
110
|
-
const fields = { role, epoch, primary: policy?.primary, levels: policy?.levels,
|
|
114
|
+
const fields = { role, epoch, rootModelPolicy: settings.rootModelPolicy, deepworkEnabled: settings.modules.deepwork.enabled, primary: policy?.primary, levels: policy?.levels,
|
|
111
115
|
fallbackSource: resolved.fallbackSource, fallbackRoutes: resolved.fallbackRoutes,
|
|
112
116
|
strategy: resolved.strategy, rateLimit: resolved.rateLimit, modelParameters: settings.modelParameters,
|
|
113
117
|
recovery: { enabled: settings.runtimeRecovery.enabled, retryOnStatusCodes: settings.runtimeRecovery.retryOnStatusCodes,
|
|
@@ -190,7 +194,7 @@ export function sameModelRoute(left, right) {
|
|
|
190
194
|
return left.provider === right.provider && left.model === right.model;
|
|
191
195
|
}
|
|
192
196
|
/** Accepted post-policy route changes are durable host/recovery ownership, not a new primary request. */
|
|
193
|
-
export function persistedRoleRoute(frame, primary, fallbacks = [], identity) {
|
|
197
|
+
export function persistedRoleRoute(frame, primary, fallbacks = [], identity, configuredRoot = false) {
|
|
194
198
|
const currentIdentity = agentPolicies.get(frame.agent)?.identity;
|
|
195
199
|
const events = policyEvents(frame);
|
|
196
200
|
let matchingPolicy = false;
|
|
@@ -216,8 +220,11 @@ export function persistedRoleRoute(frame, primary, fallbacks = [], identity) {
|
|
|
216
220
|
continue;
|
|
217
221
|
selected = modelRouteFromHeader(header);
|
|
218
222
|
}
|
|
219
|
-
|
|
220
|
-
|
|
223
|
+
if (configuredRoot) {
|
|
224
|
+
const lock = identity === undefined ? undefined : roleRouteLock(frame.agent, identity);
|
|
225
|
+
return selected !== undefined && lock !== undefined && lock.candidateIndex >= 0 && sameExactModelRoute(selected, lock.route) ? lock.route : undefined;
|
|
226
|
+
}
|
|
227
|
+
// Native/child routes retain durable Host ownership after a matching policy.
|
|
221
228
|
return selected === undefined ? undefined : [primary, ...fallbacks].find((route) => route !== undefined && sameExactModelRoute(route, selected)) ?? selected;
|
|
222
229
|
}
|
|
223
230
|
function isRecord(value) {
|