@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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
3
|
+
import type { ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSnapshot } from "./profile-types.js";
|
|
4
|
+
export interface ProfilesBackend {
|
|
5
|
+
describe(): Promise<ProfileSnapshot>;
|
|
6
|
+
read(id: string): Promise<ProfileReadResult>;
|
|
7
|
+
save(request: ProfileSaveRequest): Promise<ProfileReadResult>;
|
|
8
|
+
select(request: ProfileSelectRequest): Promise<ProfileSnapshot>;
|
|
9
|
+
}
|
|
10
|
+
/** Business service addressed only by native Typert Gateway invocations. */
|
|
11
|
+
export declare class DsmmProfilesHost extends TypertRemoteService {
|
|
12
|
+
readonly backend: ProfilesBackend;
|
|
13
|
+
constructor(ctx: Context, backend: ProfilesBackend);
|
|
14
|
+
private invoke;
|
|
15
|
+
describe(): Promise<ProfileSnapshot>;
|
|
16
|
+
read(id: string): Promise<ProfileReadResult>;
|
|
17
|
+
save(request: ProfileSaveRequest): Promise<ProfileReadResult>;
|
|
18
|
+
select(request: ProfileSelectRequest): Promise<ProfileSnapshot>;
|
|
19
|
+
}
|
|
20
|
+
declare module "@deepseek-ai/cordis" {
|
|
21
|
+
interface Context {
|
|
22
|
+
dsmmProfiles: DsmmProfilesHost;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** The caller supplies the owned injection fiber; withdrawal stays native. */
|
|
26
|
+
export declare function registerProfilesRpc(ctx: Context, backend: ProfilesBackend): DsmmProfilesHost;
|
|
27
|
+
//# sourceMappingURL=profile-rpc.d.ts.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
36
|
+
import { TYPERT_HOST } from "./profile-remote.js";
|
|
37
|
+
import { profileErrorInfo } from "./profiles.js";
|
|
38
|
+
/** Business service addressed only by native Typert Gateway invocations. */
|
|
39
|
+
let DsmmProfilesHost = (() => {
|
|
40
|
+
let _classSuper = TypertRemoteService;
|
|
41
|
+
let _instanceExtraInitializers = [];
|
|
42
|
+
let _describe_decorators;
|
|
43
|
+
let _read_decorators;
|
|
44
|
+
let _save_decorators;
|
|
45
|
+
let _select_decorators;
|
|
46
|
+
return class DsmmProfilesHost extends _classSuper {
|
|
47
|
+
static {
|
|
48
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
49
|
+
_describe_decorators = [Remote];
|
|
50
|
+
_read_decorators = [Remote];
|
|
51
|
+
_save_decorators = [Remote];
|
|
52
|
+
_select_decorators = [Remote];
|
|
53
|
+
__esDecorate(this, null, _describe_decorators, { kind: "method", name: "describe", static: false, private: false, access: { has: obj => "describe" in obj, get: obj => obj.describe }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
54
|
+
__esDecorate(this, null, _read_decorators, { kind: "method", name: "read", static: false, private: false, access: { has: obj => "read" in obj, get: obj => obj.read }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
55
|
+
__esDecorate(this, null, _save_decorators, { kind: "method", name: "save", static: false, private: false, access: { has: obj => "save" in obj, get: obj => obj.save }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
56
|
+
__esDecorate(this, null, _select_decorators, { kind: "method", name: "select", static: false, private: false, access: { has: obj => "select" in obj, get: obj => obj.select }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
57
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
58
|
+
}
|
|
59
|
+
backend = __runInitializers(this, _instanceExtraInitializers);
|
|
60
|
+
constructor(ctx, backend) {
|
|
61
|
+
super(ctx, "dsmmProfiles");
|
|
62
|
+
this.backend = backend;
|
|
63
|
+
}
|
|
64
|
+
async invoke(operation) {
|
|
65
|
+
const invocation = this.ctx.invocation;
|
|
66
|
+
if (invocation === undefined || invocation.peer === undefined) {
|
|
67
|
+
throw new RemoteError("dsmm-profiles/peer-required", "Use Deepwork Profiles through the native Host connection.", {});
|
|
68
|
+
}
|
|
69
|
+
invocation.signal.throwIfAborted();
|
|
70
|
+
try {
|
|
71
|
+
return await operation();
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw new RemoteError("dsmm-profiles/refused", "The Host refused the profile operation.", profileErrorInfo(error));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
describe() { return this.invoke(() => this.backend.describe()); }
|
|
78
|
+
read(id) { return this.invoke(() => this.backend.read(id)); }
|
|
79
|
+
save(request) { return this.invoke(() => this.backend.save(request)); }
|
|
80
|
+
select(request) { return this.invoke(() => this.backend.select(request)); }
|
|
81
|
+
};
|
|
82
|
+
})();
|
|
83
|
+
export { DsmmProfilesHost };
|
|
84
|
+
/** The caller supplies the owned injection fiber; withdrawal stays native. */
|
|
85
|
+
export function registerProfilesRpc(ctx, backend) {
|
|
86
|
+
const service = new DsmmProfilesHost(ctx, backend);
|
|
87
|
+
ctx.typert.register(TYPERT_HOST);
|
|
88
|
+
return service;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=profile-rpc.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DshAgent, DshContext } from "./dsh-types.js";
|
|
2
|
+
import type { LoadedProfileSelection } from "./profile-store.js";
|
|
3
|
+
import type { ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSelectionState, ProfileSnapshot } from "./profile-types.js";
|
|
4
|
+
import type { DsmmProfileDocument } from "./profiles.js";
|
|
5
|
+
import type { DsmmSettings, DsmmSettingsGetter } from "./settings.js";
|
|
6
|
+
export interface DsmmProfileRuntimeStore {
|
|
7
|
+
loadSelection(): Promise<LoadedProfileSelection>;
|
|
8
|
+
describe(): Promise<ProfileSnapshot>;
|
|
9
|
+
read(id: string): Promise<ProfileReadResult>;
|
|
10
|
+
save(request: ProfileSaveRequest): Promise<ProfileReadResult>;
|
|
11
|
+
select<T>(request: ProfileSelectRequest, validateCandidate: (document: DsmmProfileDocument | null) => T | Promise<T>): Promise<{
|
|
12
|
+
selection: ProfileSelectionState;
|
|
13
|
+
prepared: T;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
export interface DsmmProfileRuntimeOptions {
|
|
17
|
+
/** Trusted test/integration seam, never a wire-supplied path or callback. */
|
|
18
|
+
validateCandidate?: (settings: DsmmSettings) => void | Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/** Selection admits new roots only; live children inherit exact runtime ownership. */
|
|
21
|
+
export declare class DsmmProfileRuntime {
|
|
22
|
+
private readonly ctx;
|
|
23
|
+
private readonly store;
|
|
24
|
+
private readonly options;
|
|
25
|
+
readonly getSettings: DsmmSettingsGetter;
|
|
26
|
+
private current;
|
|
27
|
+
private readonly baseline;
|
|
28
|
+
private readonly bound;
|
|
29
|
+
private selectionQueue;
|
|
30
|
+
constructor(ctx: DshContext, baseline: DsmmSettings, store: DsmmProfileRuntimeStore, options?: DsmmProfileRuntimeOptions);
|
|
31
|
+
initialize(): Promise<void>;
|
|
32
|
+
admission(agent: DshAgent): ProfileSelectionState;
|
|
33
|
+
describe(): Promise<ProfileSnapshot>;
|
|
34
|
+
read(id: string): Promise<ProfileReadResult>;
|
|
35
|
+
save(request: ProfileSaveRequest): Promise<ProfileReadResult>;
|
|
36
|
+
select(request: ProfileSelectRequest): Promise<ProfileSnapshot>;
|
|
37
|
+
private prepare;
|
|
38
|
+
private agents;
|
|
39
|
+
private bind;
|
|
40
|
+
private validate;
|
|
41
|
+
}
|
|
42
|
+
/** No guessed home fallback: native deployment context owns this directory. */
|
|
43
|
+
export declare function createProfileRuntime(ctx: DshContext, baseline: DsmmSettings): Promise<DsmmProfileRuntime>;
|
|
44
|
+
//# sourceMappingURL=profile-runtime.d.ts.map
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { ProfileStore } from "./profile-store.js";
|
|
3
|
+
import { DsmmProfileError, resolveProfileSettings } from "./profiles.js";
|
|
4
|
+
import { DSMM_ROLES, isRootRole } from "./roles.js";
|
|
5
|
+
function immutableSettings(settings) {
|
|
6
|
+
const copy = structuredClone(settings);
|
|
7
|
+
const freeze = (value) => {
|
|
8
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value))
|
|
9
|
+
return;
|
|
10
|
+
for (const entry of Object.values(value))
|
|
11
|
+
freeze(entry);
|
|
12
|
+
Object.freeze(value);
|
|
13
|
+
};
|
|
14
|
+
freeze(copy);
|
|
15
|
+
return copy;
|
|
16
|
+
}
|
|
17
|
+
/** Selection admits new roots only; live children inherit exact runtime ownership. */
|
|
18
|
+
export class DsmmProfileRuntime {
|
|
19
|
+
ctx;
|
|
20
|
+
store;
|
|
21
|
+
options;
|
|
22
|
+
getSettings = (agent) => agent === undefined ? this.current.settings : this.bind(agent).settings;
|
|
23
|
+
current;
|
|
24
|
+
baseline;
|
|
25
|
+
bound = new WeakMap();
|
|
26
|
+
selectionQueue = Promise.resolve();
|
|
27
|
+
constructor(ctx, baseline, store, options = {}) {
|
|
28
|
+
this.ctx = ctx;
|
|
29
|
+
this.store = store;
|
|
30
|
+
this.options = options;
|
|
31
|
+
this.baseline = immutableSettings(baseline);
|
|
32
|
+
this.current = { selectedId: null, appliedRevision: null, selectionRevision: "absent", settings: this.baseline };
|
|
33
|
+
}
|
|
34
|
+
async initialize() {
|
|
35
|
+
const selection = await this.store.loadSelection();
|
|
36
|
+
// Cold resumes are new runtime Agents: the pinned current selection is the
|
|
37
|
+
// startup authority, not an assertion that a previous process still lives.
|
|
38
|
+
this.current = this.prepare(selection.document, selection);
|
|
39
|
+
this.ctx.on?.("agent/created", ({ agent }) => { this.bind(agent); }, { global: true, prepend: true });
|
|
40
|
+
// Installation into an already-running host treats those Agents as admitted
|
|
41
|
+
// now, while all later profile switches continue to preserve their snapshot.
|
|
42
|
+
for (const agent of this.agents()?.list() ?? [])
|
|
43
|
+
this.bind(agent);
|
|
44
|
+
}
|
|
45
|
+
admission(agent) {
|
|
46
|
+
const { selectedId, appliedRevision, selectionRevision } = this.bind(agent);
|
|
47
|
+
return { selectedId, appliedRevision, selectionRevision };
|
|
48
|
+
}
|
|
49
|
+
async describe() {
|
|
50
|
+
const persisted = await this.store.describe();
|
|
51
|
+
const current = this.current;
|
|
52
|
+
const changedOutsideHost = persisted.selectedId !== current.selectedId
|
|
53
|
+
|| persisted.appliedRevision !== current.appliedRevision
|
|
54
|
+
|| persisted.selectionRevision !== current.selectionRevision;
|
|
55
|
+
return {
|
|
56
|
+
...persisted,
|
|
57
|
+
selectedId: current.selectedId,
|
|
58
|
+
appliedRevision: current.appliedRevision,
|
|
59
|
+
// Keep the disk revision for CAS, but never label its unvalidated policy
|
|
60
|
+
// as admitted in this Host. Existing Agent snapshots remain untouched.
|
|
61
|
+
...(persisted.selectionError === undefined && changedOutsideHost ? {
|
|
62
|
+
selectionError: {
|
|
63
|
+
code: "conflict",
|
|
64
|
+
message: "The persisted selection changed outside this Host. New Agents still use this Host's admitted current policy; reapply the desired profile or restart."
|
|
65
|
+
}
|
|
66
|
+
} : {})
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
read(id) { return this.store.read(id); }
|
|
70
|
+
save(request) { return this.store.save(request); }
|
|
71
|
+
select(request) {
|
|
72
|
+
const operation = this.selectionQueue.then(async () => {
|
|
73
|
+
const result = await this.store.select(request, async (document) => {
|
|
74
|
+
const prepared = immutableSettings(resolveProfileSettings(this.baseline, document?.settings ?? {}));
|
|
75
|
+
await this.validate(prepared);
|
|
76
|
+
return prepared;
|
|
77
|
+
});
|
|
78
|
+
// There is no await between successful durable commit and publication of
|
|
79
|
+
// the complete settings value. Draft saves never reach this assignment.
|
|
80
|
+
this.current = { ...result.selection, settings: result.prepared };
|
|
81
|
+
return this.describe();
|
|
82
|
+
});
|
|
83
|
+
this.selectionQueue = operation.catch(() => undefined);
|
|
84
|
+
return operation;
|
|
85
|
+
}
|
|
86
|
+
prepare(document, selection) {
|
|
87
|
+
return { selectedId: selection.selectedId, appliedRevision: selection.appliedRevision, selectionRevision: selection.selectionRevision,
|
|
88
|
+
settings: immutableSettings(resolveProfileSettings(this.baseline, document?.settings ?? {})) };
|
|
89
|
+
}
|
|
90
|
+
agents() { return this.ctx.get?.("agents"); }
|
|
91
|
+
bind(agent) {
|
|
92
|
+
const existing = this.bound.get(agent);
|
|
93
|
+
if (existing !== undefined)
|
|
94
|
+
return existing;
|
|
95
|
+
const agents = this.agents();
|
|
96
|
+
// The native factory enters the exact child/owner pair before announcing
|
|
97
|
+
// creation. Durable lineage and inherited persona never establish ownership.
|
|
98
|
+
const parent = agent.id === undefined ? undefined
|
|
99
|
+
: agents?.list().find((candidate) => candidate !== agent && agents.isOwnedBy(agent.id, candidate));
|
|
100
|
+
const admitted = parent === undefined ? this.current : this.bind(parent);
|
|
101
|
+
this.bound.set(agent, admitted);
|
|
102
|
+
return admitted;
|
|
103
|
+
}
|
|
104
|
+
async validate(settings) {
|
|
105
|
+
if (this.options.validateCandidate !== undefined) {
|
|
106
|
+
await this.options.validateCandidate(settings);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const registry = this.ctx.get?.("agentPresets");
|
|
110
|
+
if (registry !== undefined) {
|
|
111
|
+
for (const role of DSMM_ROLES.filter((role) => isRootRole(role) && settings.roles[role.id])) {
|
|
112
|
+
try {
|
|
113
|
+
const preset = await registry.resolve(role.id);
|
|
114
|
+
if (preset.broken !== undefined)
|
|
115
|
+
throw new Error("unusable root preset");
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
throw new DsmmProfileError("activation", "An enabled DW root preset is unavailable. Resolve the native preset loading error before applying a profile.", role.id);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const routes = [];
|
|
123
|
+
for (const [role, policy] of Object.entries(settings.roleRouting)) {
|
|
124
|
+
if (!settings.roles[role])
|
|
125
|
+
continue;
|
|
126
|
+
if (policy.primary !== undefined)
|
|
127
|
+
routes.push({ route: policy.primary, field: `settings.roleRouting.${role}.primary` });
|
|
128
|
+
for (const [index, route] of (policy.fallbackRoutes ?? []).entries())
|
|
129
|
+
routes.push({ route, field: `settings.roleRouting.${role}.fallbackRoutes.${index}` });
|
|
130
|
+
}
|
|
131
|
+
for (const [index, route] of settings.runtimeRecovery.fallbackRoutes.entries())
|
|
132
|
+
routes.push({ route, field: `settings.runtimeRecovery.fallbackRoutes.${index}` });
|
|
133
|
+
if (routes.length === 0)
|
|
134
|
+
return;
|
|
135
|
+
const llm = (this.agents()?.list() ?? []).map((agent) => agent.ctx?.get?.("llm")).find((service) => service?.resolveCallConfig !== undefined)
|
|
136
|
+
?? this.ctx.get?.("llm") ?? (this.ctx.get === undefined ? this.ctx.llm : undefined);
|
|
137
|
+
if (llm?.resolveCallConfig === undefined) {
|
|
138
|
+
throw new DsmmProfileError("activation", "Open a chat so its native model service can validate configured routes before applying this profile.");
|
|
139
|
+
}
|
|
140
|
+
for (const { route, field } of routes) {
|
|
141
|
+
try {
|
|
142
|
+
await llm.resolveCallConfig({ ...route });
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
throw new DsmmProfileError("activation", "The configured provider, model or exact reasoning effort is unavailable in the native model catalog.", field);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/** No guessed home fallback: native deployment context owns this directory. */
|
|
151
|
+
export async function createProfileRuntime(ctx, baseline) {
|
|
152
|
+
const profile = ctx.get?.("profileContext");
|
|
153
|
+
if (typeof profile?.dir !== "string" || profile.dir.trim() === "")
|
|
154
|
+
throw new DsmmProfileError("activation", "Deepwork profiles require the native deployment profile directory.");
|
|
155
|
+
const runtime = new DsmmProfileRuntime(ctx, baseline, new ProfileStore(join(profile.dir, "dsmm-profiles")));
|
|
156
|
+
await runtime.initialize();
|
|
157
|
+
return runtime;
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=profile-runtime.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSelectionState, ProfileSnapshot } from "./profile-types.js";
|
|
2
|
+
import type { DsmmProfileDocument } from "./profiles.js";
|
|
3
|
+
export type SaveProfileRequest = ProfileSaveRequest;
|
|
4
|
+
export type SelectProfileRequest = ProfileSelectRequest;
|
|
5
|
+
export interface LoadedProfileSelection extends ProfileSelectionState {
|
|
6
|
+
document: DsmmProfileDocument | null;
|
|
7
|
+
content: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface ProfileStoreOptions {
|
|
10
|
+
lockTimeoutMs?: number;
|
|
11
|
+
lockPollMs?: number;
|
|
12
|
+
/** Narrow test seam for a failed atomic replacement; never delete the old target. */
|
|
13
|
+
rename?: (source: string, destination: string) => void;
|
|
14
|
+
}
|
|
15
|
+
/** This directory is supplied by the Host, never by a remote method parameter. */
|
|
16
|
+
export declare class ProfileStore {
|
|
17
|
+
readonly profileDir: string;
|
|
18
|
+
private readonly timeoutMs;
|
|
19
|
+
private readonly pollMs;
|
|
20
|
+
private readonly rename;
|
|
21
|
+
private rootIdentity?;
|
|
22
|
+
constructor(profileDir: string, options?: ProfileStoreOptions);
|
|
23
|
+
describe(): Promise<ProfileSnapshot>;
|
|
24
|
+
read(id: string): Promise<ProfileReadResult>;
|
|
25
|
+
save(request: ProfileSaveRequest): Promise<ProfileReadResult>;
|
|
26
|
+
loadSelection(): Promise<LoadedProfileSelection>;
|
|
27
|
+
select<T = undefined>(request: ProfileSelectRequest, validateCandidate?: (document: DsmmProfileDocument | null) => T | Promise<T>): Promise<{
|
|
28
|
+
selection: LoadedProfileSelection;
|
|
29
|
+
prepared: T;
|
|
30
|
+
}>;
|
|
31
|
+
private readResult;
|
|
32
|
+
private inventory;
|
|
33
|
+
private draftName;
|
|
34
|
+
private draft;
|
|
35
|
+
private selection;
|
|
36
|
+
private assertSelectionRevision;
|
|
37
|
+
private publishRevision;
|
|
38
|
+
private atomicReplace;
|
|
39
|
+
private validateRoot;
|
|
40
|
+
private locked;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=profile-store.d.ts.map
|