@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/runtime-recovery.js
CHANGED
|
@@ -7,6 +7,7 @@ import { childOwnedSessionEvents, resolveSelectedAgentPreset, sessionEvents } fr
|
|
|
7
7
|
import { resolveAdmittedDsmmRole as resolveEffectiveDsmmRole } from "./role-policy.js";
|
|
8
8
|
import { resolveRoleRuntimePolicy } from "./routing-policy.js";
|
|
9
9
|
import { configuredModelParameterPolicy, resolvedModelParameterPolicy } from "./model-parameter-policy.js";
|
|
10
|
+
import { currentRequestRouting } from "./request-routing.js";
|
|
10
11
|
const installedContexts = new WeakSet();
|
|
11
12
|
const RECOVERY_WARNING = "dsmm runtime recovery refused an unproven or exhausted retry";
|
|
12
13
|
const CONTINUATION_WARNING = "dsmm runtime recovery continuation steering failed for turn";
|
|
@@ -23,7 +24,7 @@ function isRecord(value) {
|
|
|
23
24
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
25
|
}
|
|
25
26
|
function isRateLimit(failure) {
|
|
26
|
-
if (["AUTH", "MISSING_CREDENTIAL", "INVALID_CREDENTIAL", "QUOTA", "ACCOUNT_QUOTA", "CONTEXT_WINDOW_EXCEEDED", "INVALID_ARGS", "CANCELLED", "ABORTED"].includes(failure.code) || failure.status === 402)
|
|
27
|
+
if (["AUTH", "PERMISSION", "PERMISSION_DENIED", "FORBIDDEN", "MISSING_CREDENTIAL", "INVALID_CREDENTIAL", "QUOTA", "ACCOUNT_QUOTA", "CONTEXT_WINDOW_EXCEEDED", "INVALID_ARGS", "CANCELLED", "ABORTED"].includes(failure.code) || failure.status === 401 || failure.status === 403 || failure.status === 402)
|
|
27
28
|
return false;
|
|
28
29
|
return failure.code === "RATE_LIMIT" || failure.status === 429;
|
|
29
30
|
}
|
|
@@ -106,6 +107,14 @@ export function registerRuntimeRecovery(ctx, controller, getSettings, bindReques
|
|
|
106
107
|
if (!active || !live(agent) || !getSettings(agent).modules.deepwork.enabled)
|
|
107
108
|
return;
|
|
108
109
|
if (frame.type === "start") {
|
|
110
|
+
const decision = currentRequestRouting(agent);
|
|
111
|
+
try {
|
|
112
|
+
decision?.assertCurrent();
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
attemptsByAgent.delete(agent);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
109
118
|
const settings = getSettings(agent);
|
|
110
119
|
const role = resolveEffectiveDsmmRole(agent, settings, controller.active(agent, settings.defaultActive));
|
|
111
120
|
const policy = liveRolePolicyIdentity(agent, settings, role, getSettings.admission?.(agent).epoch);
|
|
@@ -116,7 +125,7 @@ export function registerRuntimeRecovery(ctx, controller, getSettings, bindReques
|
|
|
116
125
|
return;
|
|
117
126
|
}
|
|
118
127
|
const previous = attemptsByAgent.get(agent);
|
|
119
|
-
const attempt = { id: frame.attemptId, turn: frame.turn, step: frame.step, revision: frame.revision, chunks: 0,
|
|
128
|
+
const attempt = { decision, id: frame.attemptId, turn: frame.turn, step: frame.step, revision: frame.revision, chunks: 0,
|
|
120
129
|
route: modelRouteFromHeader(header), header, policy, generation: lock?.generation, manualSelectionSeq: lock?.manualSelectionSeq,
|
|
121
130
|
valid: Number.isSafeInteger(frame.revision) && frame.revision >= 1 && (previous === undefined || frame.revision === previous.revision + 1), output: false, consumed: false };
|
|
122
131
|
attemptsByAgent.set(agent, attempt);
|
|
@@ -158,35 +167,52 @@ export function registerRuntimeRecovery(ctx, controller, getSettings, bindReques
|
|
|
158
167
|
if (!active || !live(frame.agent))
|
|
159
168
|
return downstream;
|
|
160
169
|
const pending = pendingByAgent.get(frame.agent);
|
|
161
|
-
if (pending === undefined
|
|
170
|
+
if (pending === undefined)
|
|
162
171
|
return downstream;
|
|
163
|
-
|
|
172
|
+
const decision = currentRequestRouting(frame.agent);
|
|
173
|
+
decision?.assertCurrent();
|
|
174
|
+
if (pending.turn !== frame.turn || pending.step !== frame.step
|
|
175
|
+
|| !isCurrentRecoveryStep(recoveryEvents(frame.agent), pending.turn, pending.step)) {
|
|
176
|
+
pendingByAgent.delete(frame.agent);
|
|
177
|
+
return downstream;
|
|
178
|
+
}
|
|
179
|
+
pending.attempt.decision?.assertPolicyCurrent();
|
|
180
|
+
if (pending.attempt.decision !== undefined && (decision?.policy !== pending.attempt.decision.policy
|
|
181
|
+
|| decision?.admission !== pending.attempt.decision.admission || frame.signal !== pending.attempt.decision.frame.signal)) {
|
|
182
|
+
pendingByAgent.delete(frame.agent);
|
|
183
|
+
throw new Error("DSMM retry routing capture changed");
|
|
184
|
+
}
|
|
185
|
+
if (!decision?.configuredRoot && latestNativeModelSelection(frame.agent)?.seq !== pending.manualSelectionSeq) {
|
|
164
186
|
pendingByAgent.delete(frame.agent);
|
|
165
187
|
throw new Error("dsmm retry was superseded by an explicit native model selection");
|
|
166
188
|
}
|
|
167
|
-
if (frame.signal.aborted
|
|
189
|
+
if (frame.signal.aborted) {
|
|
168
190
|
pendingByAgent.delete(frame.agent);
|
|
169
191
|
return downstream;
|
|
170
192
|
}
|
|
171
|
-
if (pending.turn !== frame.turn || pending.step !== frame.step)
|
|
172
|
-
return downstream;
|
|
173
193
|
if (pending.policy !== undefined) {
|
|
174
194
|
const settings = getSettings(frame.agent);
|
|
175
195
|
const role = resolveEffectiveDsmmRole(frame.agent, settings, controller.active(frame.agent, settings.defaultActive));
|
|
176
196
|
if (role !== pending.role || liveRolePolicyIdentity(frame.agent, settings, role, getSettings.admission?.(frame.agent).epoch) !== pending.policy) {
|
|
177
197
|
pendingByAgent.delete(frame.agent);
|
|
198
|
+
if (decision?.configuredRoot)
|
|
199
|
+
throw new Error("DSMM retry policy is no longer current");
|
|
178
200
|
return downstream;
|
|
179
201
|
}
|
|
180
202
|
}
|
|
181
203
|
const accepted = frame.agent.session.requestHeader?.();
|
|
182
204
|
const lock = pending.policy === undefined ? undefined : roleRouteLock(frame.agent, pending.policy);
|
|
205
|
+
const failure = pending.attempt.failure;
|
|
183
206
|
if (!active || lock === undefined || lock.generation !== pending.generation || attemptsByAgent.get(frame.agent) !== pending.attempt
|
|
184
|
-
|| accepted === undefined || !sameExactModelRoute(modelRouteFromHeader(accepted), pending.failedRoute)
|
|
207
|
+
|| accepted === undefined || !sameExactModelRoute(modelRouteFromHeader(accepted), pending.failedRoute)
|
|
208
|
+
|| decision?.configuredRoot && (failure === undefined || !positiveNoOutput({ ...frame, provider: pending.failedRoute.provider, failure }, pending.attempt, true))) {
|
|
185
209
|
pendingByAgent.delete(frame.agent);
|
|
210
|
+
if (decision?.configuredRoot)
|
|
211
|
+
throw new Error("DSMM retry evidence is no longer current");
|
|
186
212
|
return downstream;
|
|
187
213
|
}
|
|
188
214
|
pendingByAgent.delete(frame.agent);
|
|
189
|
-
if (frame.agent.session.header?.origin !== "subagent")
|
|
215
|
+
if (frame.agent.session.header?.origin !== "subagent" && !decision?.configuredRoot)
|
|
190
216
|
return downstream;
|
|
191
217
|
lock.route = { ...pending.route };
|
|
192
218
|
recordAdmittedRecoveryRoute(frame, pending.route);
|
|
@@ -202,6 +228,7 @@ export function registerRuntimeRecovery(ctx, controller, getSettings, bindReques
|
|
|
202
228
|
let settings;
|
|
203
229
|
let role;
|
|
204
230
|
try {
|
|
231
|
+
attemptsByAgent.get(frame.agent)?.decision?.assertCurrent();
|
|
205
232
|
settings = getSettings(frame.agent);
|
|
206
233
|
if (!settings.modules.deepwork.enabled)
|
|
207
234
|
return await next();
|
|
@@ -209,7 +236,7 @@ export function registerRuntimeRecovery(ctx, controller, getSettings, bindReques
|
|
|
209
236
|
}
|
|
210
237
|
catch {
|
|
211
238
|
const prior = attemptsByAgent.get(frame.agent);
|
|
212
|
-
return isRateLimit(frame.failure) && prior?.policy !== undefined ? undefined : await next();
|
|
239
|
+
return (isRateLimit(frame.failure) || isUnavailableRouteFailure(frame.failure, true)) && prior?.policy !== undefined ? undefined : await next();
|
|
213
240
|
}
|
|
214
241
|
const unavailable = isUnavailableRouteFailure(frame.failure, true);
|
|
215
242
|
if (role === undefined || (!isRateLimit(frame.failure) && !unavailable))
|
|
@@ -218,13 +245,23 @@ export function registerRuntimeRecovery(ctx, controller, getSettings, bindReques
|
|
|
218
245
|
const policy = liveRolePolicyIdentity(frame.agent, settings, role, getSettings.admission?.(frame.agent).epoch);
|
|
219
246
|
const lock = policy === undefined ? undefined : roleRouteLock(frame.agent, policy);
|
|
220
247
|
const attempt = attemptsByAgent.get(frame.agent);
|
|
248
|
+
const decision = attempt?.decision;
|
|
249
|
+
decision?.assertCurrent();
|
|
221
250
|
const header = frame.agent.session.requestHeader?.();
|
|
222
251
|
if (!active || frame.signal.aborted || lock === undefined || header === undefined
|
|
223
252
|
|| header.config.provider !== frame.provider || !sameExactModelRoute(modelRouteFromHeader(header), lock.route)
|
|
224
253
|
|| attempt === undefined || attempt.policy !== policy || attempt.generation !== lock.generation
|
|
225
|
-
|| latestNativeModelSelection(frame.agent)?.seq !== attempt.manualSelectionSeq
|
|
254
|
+
|| !decision?.configuredRoot && latestNativeModelSelection(frame.agent)?.seq !== attempt.manualSelectionSeq
|
|
226
255
|
|| !isCurrentRecoveryStep(recoveryEvents(frame.agent), frame.turn, frame.step) || !positiveNoOutput(frame, attempt))
|
|
227
256
|
return undefined;
|
|
257
|
+
const expectedGeneration = lock.generation;
|
|
258
|
+
const assertRouteCurrent = () => {
|
|
259
|
+
decision?.assertCurrent();
|
|
260
|
+
frame.signal.throwIfAborted();
|
|
261
|
+
if (!active || !live(frame.agent) || roleRouteLock(frame.agent, policy) !== lock || lock.generation !== expectedGeneration) {
|
|
262
|
+
throw new Error("DSMM recovery route generation changed");
|
|
263
|
+
}
|
|
264
|
+
};
|
|
228
265
|
attempt.consumed = true;
|
|
229
266
|
const resolved = resolveRoleRuntimePolicy(settings, role);
|
|
230
267
|
const bounds = resolved.rateLimit;
|
|
@@ -239,7 +276,7 @@ export function registerRuntimeRecovery(ctx, controller, getSettings, bindReques
|
|
|
239
276
|
else {
|
|
240
277
|
lock.startupSettled = true;
|
|
241
278
|
lock.rateLimits += 1;
|
|
242
|
-
switching = frame.agent.session.header?.origin === "subagent"
|
|
279
|
+
switching = (frame.agent.session.header?.origin === "subagent" || decision?.configuredRoot === true)
|
|
243
280
|
&& resolved.strategy === "rate-limit-fallback" && lock.rateLimits >= bounds.switchAfterRateLimits;
|
|
244
281
|
if (!switching && lock.retries >= bounds.maxRetries)
|
|
245
282
|
return undefined;
|
|
@@ -254,9 +291,10 @@ export function registerRuntimeRecovery(ctx, controller, getSettings, bindReques
|
|
|
254
291
|
const llm = frame.agent.ctx?.get?.("llm") ?? ctx.get?.("llm") ?? ctx.llm;
|
|
255
292
|
const admission = getSettings.admission?.(frame.agent);
|
|
256
293
|
const parameterPolicy = admission === undefined ? configuredModelParameterPolicy(settings) : resolvedModelParameterPolicy(admission);
|
|
257
|
-
const selected = await selectInitialModelRouteChoice(llm ?? {}, candidates, frame.signal, parameterPolicy.mode === "passthrough" ? ctx.get?.("dsmmLlmRoutes") : undefined);
|
|
294
|
+
const selected = await selectInitialModelRouteChoice(llm ?? {}, candidates, frame.signal, parameterPolicy.mode === "passthrough" ? ctx.get?.("dsmmLlmRoutes") : undefined, decision?.configuredRoot && parameterPolicy.mode === "native-defaults" ? route => modelRouteFromCall(projectModelRouteParameters(route, "dsmm-config", false)) : undefined, assertRouteCurrent);
|
|
295
|
+
assertRouteCurrent();
|
|
258
296
|
route = parameterPolicy.mode === "native-defaults"
|
|
259
|
-
? modelRouteFromCall(projectModelRouteParameters(selected.route, selected.requestedRoute.reasoningEffort === undefined ? "dsmm-config" : "native", false))
|
|
297
|
+
? modelRouteFromCall(projectModelRouteParameters(selected.route, decision?.configuredRoot || selected.requestedRoute.reasoningEffort === undefined ? "dsmm-config" : "native", false))
|
|
260
298
|
: selected.route;
|
|
261
299
|
candidateIndex = index + 1 + candidates.findIndex(candidate => sameExactModelRoute(candidate, selected.requestedRoute));
|
|
262
300
|
}
|
|
@@ -267,7 +305,6 @@ export function registerRuntimeRecovery(ctx, controller, getSettings, bindReques
|
|
|
267
305
|
if (delay > bounds.maxDelayMs || delay > bounds.maxTotalDelayMs - lock.totalDelayMs)
|
|
268
306
|
return undefined;
|
|
269
307
|
lock.totalDelayMs += delay;
|
|
270
|
-
const expectedGeneration = lock.generation;
|
|
271
308
|
if (delay > 0) {
|
|
272
309
|
const wait = new AbortController();
|
|
273
310
|
waits.add(wait);
|
|
@@ -286,16 +323,19 @@ export function registerRuntimeRecovery(ctx, controller, getSettings, bindReques
|
|
|
286
323
|
}
|
|
287
324
|
}
|
|
288
325
|
const currentSettings = getSettings(frame.agent);
|
|
326
|
+
decision?.assertCurrent();
|
|
289
327
|
const currentRole = resolveEffectiveDsmmRole(frame.agent, currentSettings, controller.active(frame.agent, currentSettings.defaultActive));
|
|
290
328
|
if (!active || !live(frame.agent) || frame.signal.aborted || currentRole !== role
|
|
291
329
|
|| liveRolePolicyIdentity(frame.agent, currentSettings, currentRole, getSettings.admission?.(frame.agent).epoch) !== policy
|
|
292
330
|
|| roleRouteLock(frame.agent, policy) !== lock || lock.generation !== expectedGeneration
|
|
293
331
|
|| attemptsByAgent.get(frame.agent) !== attempt || !isCurrentRecoveryStep(recoveryEvents(frame.agent), frame.turn, frame.step)
|
|
294
|
-
|| latestNativeModelSelection(frame.agent)?.seq !== attempt.manualSelectionSeq
|
|
332
|
+
|| !decision?.configuredRoot && latestNativeModelSelection(frame.agent)?.seq !== attempt.manualSelectionSeq
|
|
295
333
|
|| !positiveNoOutput(frame, attempt, true)
|
|
296
334
|
|| !sameExactModelRoute(modelRouteFromHeader(frame.agent.session.requestHeader?.()), attempt.route))
|
|
297
335
|
return undefined;
|
|
298
336
|
if (switching) {
|
|
337
|
+
if (decision?.configuredRoot)
|
|
338
|
+
lock.effortSource = "dsmm-config";
|
|
299
339
|
lock.candidateIndex = candidateIndex;
|
|
300
340
|
lock.generation += 1;
|
|
301
341
|
if (!unavailable)
|
package/lib/settings.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export interface DsmmInvocationOptions {
|
|
|
29
29
|
route?: DsmmLevelOverride;
|
|
30
30
|
}
|
|
31
31
|
export type DsmmToolTopology = "per-role" | "parameterized";
|
|
32
|
+
export type DsmmRootModelPolicy = "native" | "configured";
|
|
32
33
|
export interface DsmmWorkflowSettings {
|
|
33
34
|
policy: "risk-based" | "legacy";
|
|
34
35
|
strictGates: boolean;
|
|
@@ -99,6 +100,7 @@ export interface DsmmPluginConfig {
|
|
|
99
100
|
modelParameters?: {
|
|
100
101
|
passthrough?: boolean;
|
|
101
102
|
};
|
|
103
|
+
rootModelPolicy?: DsmmRootModelPolicy;
|
|
102
104
|
locale?: DsmmLocale;
|
|
103
105
|
/** Only global deployment input; native/legacy profile transport rejects it. */
|
|
104
106
|
modules?: {
|
|
@@ -127,6 +129,7 @@ export interface DsmmSettings {
|
|
|
127
129
|
modelParameters: {
|
|
128
130
|
passthrough: boolean;
|
|
129
131
|
};
|
|
132
|
+
rootModelPolicy: DsmmRootModelPolicy;
|
|
130
133
|
locale?: DsmmLocale;
|
|
131
134
|
modules: {
|
|
132
135
|
deepwork: {
|
package/lib/settings.js
CHANGED
|
@@ -14,6 +14,7 @@ export const DSMM_STATUS_COMMAND = "dsmm-status";
|
|
|
14
14
|
export const DEFAULT_DSMM_SETTINGS = {
|
|
15
15
|
permissionControl: DEFAULT_PERMISSION_CONTROL,
|
|
16
16
|
modelParameters: { passthrough: true },
|
|
17
|
+
rootModelPolicy: "native",
|
|
17
18
|
modules: { deepwork: { enabled: true } },
|
|
18
19
|
modeName: "deepwork",
|
|
19
20
|
defaultActive: false,
|
|
@@ -85,6 +86,7 @@ const MODEL_ROUTE_SCHEMA = Schema.transform(Schema.any(), (input) => normalizeMo
|
|
|
85
86
|
const LEVEL_OVERRIDE_SCHEMA = Schema.union([MODEL_ROUTE_SCHEMA, Schema.object({ reasoningEffort: Schema.string().required() })]);
|
|
86
87
|
const LEVELS_SCHEMA = Schema.object({ low: LEVEL_OVERRIDE_SCHEMA, high: LEVEL_OVERRIDE_SCHEMA, max: LEVEL_OVERRIDE_SCHEMA });
|
|
87
88
|
const LOCALE_SCHEMA = Schema.union(DSMM_LOCALES.map(locale => Schema.const(locale)));
|
|
89
|
+
const ROOT_MODEL_POLICY_SCHEMA = Schema.union([Schema.const("native"), Schema.const("configured")]);
|
|
88
90
|
const RATE_LIMIT_CONFIG_SCHEMA = Schema.object(Object.fromEntries(Object.keys(DEFAULT_DSMM_RUNTIME_POLICY.rateLimit).map((key) => [key, Schema.number()])));
|
|
89
91
|
const ROUTING_STRATEGY_CONFIG_SCHEMA = Schema.union([Schema.const("startup-lock"), Schema.const("rate-limit-fallback")]);
|
|
90
92
|
const RUNTIME_POLICY_CONFIG_SCHEMA = Schema.object({ strategy: ROUTING_STRATEGY_CONFIG_SCHEMA, rateLimit: RATE_LIMIT_CONFIG_SCHEMA });
|
|
@@ -106,6 +108,8 @@ const ROLE_ROUTING_VALIDATION_SCHEMA = Schema.transform(Schema.any(), (input) =>
|
|
|
106
108
|
rejectDeprecatedFields(input);
|
|
107
109
|
if (Object.hasOwn(input, "locale"))
|
|
108
110
|
validateLocale(input.locale);
|
|
111
|
+
if (Object.hasOwn(input, "rootModelPolicy"))
|
|
112
|
+
validateShape(input.rootModelPolicy, ROOT_MODEL_POLICY_SCHEMA, ["rootModelPolicy"]);
|
|
109
113
|
if (isRoutingRecord(input.guards) && Object.hasOwn(input.guards, "gitWriteScope"))
|
|
110
114
|
validateShape(input.guards.gitWriteScope, GIT_WRITE_SCOPE_SCHEMA, ["guards", "gitWriteScope"]);
|
|
111
115
|
if (isRoutingRecord(input.runtimeRecovery) && Array.isArray(input.runtimeRecovery.fallbackRoutes)) {
|
|
@@ -205,6 +209,7 @@ const LSP_SCHEMA = Schema.object({
|
|
|
205
209
|
const CONFIG_FIELDS_SCHEMA = Schema.object({
|
|
206
210
|
permissionControl: permissionControlSchema,
|
|
207
211
|
modelParameters: Schema.object({ passthrough: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.modelParameters.passthrough) }),
|
|
212
|
+
rootModelPolicy: ROOT_MODEL_POLICY_SCHEMA.default(DEFAULT_DSMM_SETTINGS.rootModelPolicy),
|
|
208
213
|
locale: LOCALE_SCHEMA,
|
|
209
214
|
modeName: Schema.string().default(DEFAULT_DSMM_SETTINGS.modeName),
|
|
210
215
|
section: Schema.string(),
|
|
@@ -301,6 +306,7 @@ export function validateNativeConfig(input) {
|
|
|
301
306
|
export const DSMM_SETTINGS_SCHEMA = Schema.intersect([ROLE_ROUTING_VALIDATION_SCHEMA, Schema.object({
|
|
302
307
|
permissionControl: permissionControlSchema,
|
|
303
308
|
modelParameters: Schema.object({ passthrough: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.modelParameters.passthrough) }),
|
|
309
|
+
rootModelPolicy: ROOT_MODEL_POLICY_SCHEMA.default(DEFAULT_DSMM_SETTINGS.rootModelPolicy),
|
|
304
310
|
locale: LOCALE_SCHEMA,
|
|
305
311
|
modules: Schema.object({ deepwork: Schema.object({ enabled: Schema.boolean().default(true) }) }),
|
|
306
312
|
modeName: Schema.string().default(DEFAULT_DSMM_SETTINGS.modeName),
|
|
@@ -321,6 +327,8 @@ export function resolveConfig(config = {}) {
|
|
|
321
327
|
rejectDeprecatedFields(config);
|
|
322
328
|
if (Object.hasOwn(config, "locale"))
|
|
323
329
|
validateLocale(config.locale);
|
|
330
|
+
if (Object.hasOwn(config, "rootModelPolicy"))
|
|
331
|
+
validateShape(config.rootModelPolicy, ROOT_MODEL_POLICY_SCHEMA, ["rootModelPolicy"]);
|
|
324
332
|
if (config.subagents !== undefined)
|
|
325
333
|
validateShape(config.subagents, SUBAGENTS_SCHEMA, ["subagents"]);
|
|
326
334
|
if (config.modelParameters !== undefined)
|
|
@@ -330,6 +338,7 @@ export function resolveConfig(config = {}) {
|
|
|
330
338
|
const settings = {
|
|
331
339
|
permissionControl: resolvePermissionControl(config.permissionControl),
|
|
332
340
|
modelParameters: { passthrough: config.modelParameters?.passthrough ?? DEFAULT_DSMM_SETTINGS.modelParameters.passthrough },
|
|
341
|
+
rootModelPolicy: config.rootModelPolicy ?? DEFAULT_DSMM_SETTINGS.rootModelPolicy,
|
|
333
342
|
...(config.locale === undefined ? {} : { locale: config.locale }),
|
|
334
343
|
modules: { deepwork: { enabled: config.modules?.deepwork?.enabled ?? DEFAULT_DSMM_SETTINGS.modules.deepwork.enabled } },
|
|
335
344
|
modeName: normalizeModeName(config.modeName),
|
package/lib/state.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ export declare class DeepworkModeController {
|
|
|
19
19
|
private childDefaultActive;
|
|
20
20
|
describe(agent: DshAgent, defaultActive: boolean): SessionDeepworkState;
|
|
21
21
|
private intent;
|
|
22
|
-
select(agent: DshAgent, active: boolean, defaultActive?: boolean): Promise<DeepworkSelectionOutcome>;
|
|
22
|
+
select(agent: DshAgent, active: boolean, defaultActive?: boolean, authority?: () => void, committed?: (revision: string) => void): Promise<DeepworkSelectionOutcome>;
|
|
23
23
|
/** Called inside the existing native maintenance / admission CAS boundary. */
|
|
24
|
-
selectIdle(agent: DshAgent, active: boolean,
|
|
24
|
+
selectIdle(agent: DshAgent, active: boolean, defaultActive: boolean, authority?: () => void, committed?: (revision: string) => void): Promise<void>;
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=state.d.ts.map
|
package/lib/state.js
CHANGED
|
@@ -101,7 +101,8 @@ export class DeepworkModeController {
|
|
|
101
101
|
}
|
|
102
102
|
return undefined;
|
|
103
103
|
}
|
|
104
|
-
async select(agent, active, defaultActive = false) {
|
|
104
|
+
async select(agent, active, defaultActive = false, authority, committed) {
|
|
105
|
+
authority?.();
|
|
105
106
|
if (active && !this.runtimeReady())
|
|
106
107
|
throw new Error("Deepwork runtime is not ready; enable it in native settings and restart the Host");
|
|
107
108
|
if (active && !this.moduleEnabled(agent))
|
|
@@ -115,7 +116,8 @@ export class DeepworkModeController {
|
|
|
115
116
|
signal?.throwIfAborted();
|
|
116
117
|
if (this.describe(agent, defaultActive).revision !== before.revision)
|
|
117
118
|
throw new Error("Deepwork mode changed; refresh before retrying");
|
|
118
|
-
|
|
119
|
+
authority?.();
|
|
120
|
+
await this.selectIdle(agent, active, defaultActive, authority, committed);
|
|
119
121
|
};
|
|
120
122
|
if (agent.runMaintenance === undefined)
|
|
121
123
|
throw new Error("Deepwork mode requires native idle maintenance");
|
|
@@ -123,7 +125,7 @@ export class DeepworkModeController {
|
|
|
123
125
|
return "committed";
|
|
124
126
|
}
|
|
125
127
|
/** Called inside the existing native maintenance / admission CAS boundary. */
|
|
126
|
-
async selectIdle(agent, active,
|
|
128
|
+
async selectIdle(agent, active, defaultActive, authority, committed) {
|
|
127
129
|
if (active && !this.runtimeReady())
|
|
128
130
|
throw new Error("Deepwork runtime is not ready; enable it in native settings and restart the Host");
|
|
129
131
|
if (active && !this.moduleEnabled(agent))
|
|
@@ -132,8 +134,15 @@ export class DeepworkModeController {
|
|
|
132
134
|
throw new Error("Deepwork mode requires an idle session");
|
|
133
135
|
if (this.intent(agent) === active)
|
|
134
136
|
return;
|
|
137
|
+
authority?.();
|
|
135
138
|
appendModeRecord(agent.session, active);
|
|
136
|
-
this.
|
|
139
|
+
const revision = this.describe(agent, defaultActive).revision;
|
|
140
|
+
try {
|
|
141
|
+
committed?.(revision);
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
this.changed(agent);
|
|
145
|
+
}
|
|
137
146
|
}
|
|
138
147
|
}
|
|
139
148
|
//# sourceMappingURL=state.js.map
|
package/lib/status.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ export interface DsmmStatusSnapshot {
|
|
|
16
16
|
source: string;
|
|
17
17
|
capture: string;
|
|
18
18
|
};
|
|
19
|
+
rootModelPolicy?: {
|
|
20
|
+
value: DsmmSettings["rootModelPolicy"];
|
|
21
|
+
source: string;
|
|
22
|
+
capture: string;
|
|
23
|
+
};
|
|
19
24
|
version: typeof DSMM_STATUS_VERSION;
|
|
20
25
|
modules?: DsmmModuleState[];
|
|
21
26
|
admission?: Pick<DsmmProfileAdmission, "profile" | "epoch" | "scope">;
|
package/lib/status.js
CHANGED
|
@@ -20,12 +20,14 @@ export function createDsmmStatusSnapshot(input) {
|
|
|
20
20
|
invalidDescriptor = true;
|
|
21
21
|
}
|
|
22
22
|
const inScope = modeActive || role !== undefined;
|
|
23
|
-
const
|
|
23
|
+
const nativeRoot = ordinaryRoot && !(input.admission?.settings === settings
|
|
24
|
+
&& settings.rootModelPolicy === "configured" && settings.modules.deepwork.enabled && role !== undefined && !invalidDescriptor);
|
|
25
|
+
const policy = nativeRoot || role === undefined ? undefined : settings.roleRouting[role];
|
|
24
26
|
const runtimePolicy = resolveRoleRuntimePolicy(settings, role);
|
|
25
27
|
const roleRuntimeState = input.roleRuntimeState ?? (input.admission === undefined || invalidDescriptor ? undefined
|
|
26
28
|
: roleRouteRuntimeState(agent, settings, role, input.admission.epoch));
|
|
27
|
-
const fallbacks =
|
|
28
|
-
const selectedRoute = resolveRoute(agent);
|
|
29
|
+
const fallbacks = nativeRoot || invalidDescriptor ? [] : runtimePolicy.fallbackRoutes;
|
|
30
|
+
const selectedRoute = resolveRoute(agent, !ordinaryRoot || nativeRoot);
|
|
29
31
|
const family = classifyModelFamily({
|
|
30
32
|
providerID: selectedRoute.provider,
|
|
31
33
|
modelID: selectedRoute.model
|
|
@@ -36,6 +38,11 @@ export function createDsmmStatusSnapshot(input) {
|
|
|
36
38
|
...(input.admission?.warnings === undefined ? {} : { warnings: structuredClone(input.admission.warnings) }),
|
|
37
39
|
...(input.subagentRuntime === undefined && input.admission?.subagentRuntime === undefined ? {} : { subagentRuntime: { ...(input.subagentRuntime ?? input.admission.subagentRuntime) } }),
|
|
38
40
|
...(settings.locale === undefined ? {} : { locale: { value: settings.locale, source: input.admission?.sources?.locale ?? "defaults", capture: input.admission?.sourceCaptures?.fields.locale ?? "admission" } }),
|
|
41
|
+
...(input.admission === undefined ? {} : { rootModelPolicy: {
|
|
42
|
+
value: input.admission.settings.rootModelPolicy,
|
|
43
|
+
source: input.admission.sources?.rootModelPolicy ?? "defaults",
|
|
44
|
+
capture: input.admission.sourceCaptures?.fields.rootModelPolicy ?? "admission"
|
|
45
|
+
} }),
|
|
39
46
|
...(input.modules === undefined ? {} : { modules: structuredClone(input.modules) }),
|
|
40
47
|
...(input.admission?.store === undefined ? {} : { profileStore: { ...input.admission.store } }),
|
|
41
48
|
...(input.admission?.deployment === undefined ? {} : { deployment: {
|
|
@@ -69,12 +76,12 @@ export function createDsmmStatusSnapshot(input) {
|
|
|
69
76
|
applies: inScope && !invalidDescriptor,
|
|
70
77
|
...(policy?.primary === undefined ? {} : { primary: { ...policy.primary } }),
|
|
71
78
|
fallbackRoutes: fallbacks.map((route) => ({ ...route })),
|
|
72
|
-
fallbackSource:
|
|
73
|
-
strategy:
|
|
79
|
+
fallbackSource: nativeRoot || invalidDescriptor ? "disabled" : runtimePolicy.fallbackSource,
|
|
80
|
+
strategy: nativeRoot ? "startup-lock" : runtimePolicy.strategy,
|
|
74
81
|
rateLimit: { ...runtimePolicy.rateLimit },
|
|
75
82
|
...(roleRuntimeState === undefined ? {} : { runtimeState: {
|
|
76
83
|
...roleRuntimeState,
|
|
77
|
-
...(
|
|
84
|
+
...(nativeRoot ? { strategy: "startup-lock" } : {}),
|
|
78
85
|
rateLimit: { ...roleRuntimeState.rateLimit },
|
|
79
86
|
...(roleRuntimeState.route === undefined ? {} : { route: { ...roleRuntimeState.route } })
|
|
80
87
|
} }),
|
|
@@ -118,6 +125,7 @@ export function formatDsmmStatus(snapshot) {
|
|
|
118
125
|
...(snapshot.deployment?.sourceCaptures?.startup === undefined ? [] : [`Startup-pinned sources: global=${snapshot.deployment.sourceCaptures.startup.globalRevision}; native=${snapshot.deployment.sourceCaptures.startup.nativeRevision}`]),
|
|
119
126
|
...(snapshot.profileStore === undefined ? [] : [`Named store: ${snapshot.profileStore.origin}; ${snapshot.profileStore.readOnly ? "read-only" : "writable"}${snapshot.profileStore.writeRestriction === undefined ? "" : `; ${snapshot.profileStore.writeRestriction}`}`]),
|
|
120
127
|
`Workflow policy: ${snapshot.effectiveSettings.workflow.policy}`,
|
|
128
|
+
...(snapshot.rootModelPolicy === undefined ? [] : [`Root model policy: ${snapshot.rootModelPolicy.value} (${snapshot.rootModelPolicy.source}, ${snapshot.rootModelPolicy.capture})`]),
|
|
121
129
|
`Route: ${provider}/${model} [${snapshot.route.family}]`,
|
|
122
130
|
`Role policy: ${displayRole(snapshot.rolePolicy.role)}; strategy=${snapshot.rolePolicy.strategy}; primary=${snapshot.rolePolicy.primary === undefined ? "inherit" : `${snapshot.rolePolicy.primary.provider}/${snapshot.rolePolicy.primary.model}`}; fallbacks=${snapshot.rolePolicy.fallbackSource}; retries=${snapshot.rolePolicy.rateLimit.maxRetries}; threshold=${snapshot.rolePolicy.rateLimit.switchAfterRateLimits}; switches=${snapshot.rolePolicy.rateLimit.maxSwitches}`,
|
|
123
131
|
...(snapshot.rolePolicy.runtimeState === undefined ? [] : [`Retry state: retries=${snapshot.rolePolicy.runtimeState.retries}; rate limits=${snapshot.rolePolicy.runtimeState.rateLimitFailures}; switches=${snapshot.rolePolicy.runtimeState.switches}; delay ms=${snapshot.rolePolicy.runtimeState.totalDelayMs}`]),
|
|
@@ -127,7 +135,7 @@ export function formatDsmmStatus(snapshot) {
|
|
|
127
135
|
"Effective settings: use /dsmm-status json for the normalized snapshot"
|
|
128
136
|
].join("\n");
|
|
129
137
|
}
|
|
130
|
-
function resolveRoute(agent) {
|
|
138
|
+
function resolveRoute(agent, includeBaseline) {
|
|
131
139
|
const requestHeader = agent.session.requestHeader?.();
|
|
132
140
|
if (requestHeader !== undefined) {
|
|
133
141
|
const config = requestHeader?.config;
|
|
@@ -137,6 +145,8 @@ function resolveRoute(agent) {
|
|
|
137
145
|
reasoningEffort: readString(config?.reasoningEffort)
|
|
138
146
|
};
|
|
139
147
|
}
|
|
148
|
+
if (!includeBaseline)
|
|
149
|
+
return {};
|
|
140
150
|
return {
|
|
141
151
|
provider: readString(agent.options?.provider),
|
|
142
152
|
model: readString(agent.options?.model),
|
|
@@ -151,6 +161,7 @@ export function readOnlySettings(settings) {
|
|
|
151
161
|
return {
|
|
152
162
|
permissionControl: structuredClone(settings.permissionControl),
|
|
153
163
|
modelParameters: { ...settings.modelParameters },
|
|
164
|
+
rootModelPolicy: settings.rootModelPolicy,
|
|
154
165
|
modules: { deepwork: { enabled: settings.modules.deepwork.enabled } },
|
|
155
166
|
...(settings.locale === undefined ? {} : { locale: settings.locale }),
|
|
156
167
|
modeName: settings.modeName,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DsmmCommandDefinition } from "./commands.js";
|
|
2
|
+
import type { DsmmSettingsGetter } from "./settings.js";
|
|
3
|
+
import type { DeepworkModeController } from "./state.js";
|
|
4
|
+
import type { DsmmProfileRuntime } from "./profile-runtime.js";
|
|
5
|
+
import type { DsmmDeploymentConfig } from "./deployment-config.js";
|
|
6
|
+
import type { BeginDsmmTuiAction } from "./tui-types.js";
|
|
7
|
+
export declare const DSMM_TUI_COMPONENT_ID = "com.hugefiver.dsmm";
|
|
8
|
+
export declare const DSMM_TUI_CONTRIBUTIONS: Readonly<{
|
|
9
|
+
manage: "com.hugefiver.dsmm.manage";
|
|
10
|
+
}>;
|
|
11
|
+
declare const DIALOG_TIMEOUT_MS = 30000;
|
|
12
|
+
export interface DsmmTuiActionDependencies {
|
|
13
|
+
controller: DeepworkModeController;
|
|
14
|
+
getSettings: DsmmSettingsGetter;
|
|
15
|
+
profiles: DsmmProfileRuntime;
|
|
16
|
+
deployment: DsmmDeploymentConfig;
|
|
17
|
+
begin: BeginDsmmTuiAction;
|
|
18
|
+
}
|
|
19
|
+
export declare function createDsmmManagementCommandDefinition(deps: DsmmTuiActionDependencies): DsmmCommandDefinition;
|
|
20
|
+
export { DIALOG_TIMEOUT_MS };
|
|
21
|
+
//# sourceMappingURL=tui-actions.d.ts.map
|