@dsmm/dsmm 0.1.1 → 0.1.5

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.
Files changed (108) hide show
  1. package/README.md +26 -15
  2. package/agent-presets/dsmm-builder/agent.cordis.yml +14 -12
  3. package/agent-presets/dsmm-builder/preset.yml +1 -1
  4. package/agent-presets/dsmm-clarifier/agent.cordis.yml +4 -2
  5. package/agent-presets/dsmm-clarifier/preset.yml +1 -1
  6. package/agent-presets/dsmm-code-search/agent.cordis.yml +4 -2
  7. package/agent-presets/dsmm-code-search/preset.yml +1 -1
  8. package/agent-presets/dsmm-creative/agent.cordis.yml +3 -1
  9. package/agent-presets/dsmm-creative/preset.yml +1 -1
  10. package/agent-presets/dsmm-doc-search/agent.cordis.yml +4 -2
  11. package/agent-presets/dsmm-doc-search/preset.yml +1 -1
  12. package/agent-presets/dsmm-media-reader/agent.cordis.yml +4 -2
  13. package/agent-presets/dsmm-media-reader/preset.yml +1 -1
  14. package/agent-presets/dsmm-oracle/agent.cordis.yml +3 -1
  15. package/agent-presets/dsmm-oracle/preset.yml +1 -1
  16. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +3 -1
  17. package/agent-presets/dsmm-oracle-2nd/preset.yml +1 -1
  18. package/agent-presets/dsmm-orchestrator/agent.cordis.yml +15 -13
  19. package/agent-presets/dsmm-orchestrator/preset.yml +2 -2
  20. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +4 -2
  21. package/agent-presets/dsmm-plan-critic/preset.yml +1 -1
  22. package/agent-presets/dsmm-planner/agent.cordis.yml +4 -2
  23. package/agent-presets/dsmm-planner/preset.yml +1 -1
  24. package/agent-presets/dsmm-reviewer/agent.cordis.yml +4 -2
  25. package/agent-presets/dsmm-reviewer/preset.yml +1 -1
  26. package/docs/agent-presets.md +15 -5
  27. package/docs/compatibility.md +66 -11
  28. package/docs/migration-from-ocmm.md +8 -0
  29. package/docs/model-routing.md +25 -7
  30. package/docs/profiles.md +95 -0
  31. package/docs/releasing.md +66 -19
  32. package/docs/runtime-recovery.md +39 -14
  33. package/docs/settings-status.md +13 -5
  34. package/lib/client/ProfilesSection.d.ts +11 -0
  35. package/lib/client/ProfilesSection.js +66 -0
  36. package/lib/client/SessionProfiles.d.ts +19 -0
  37. package/lib/client/SessionProfiles.js +24 -0
  38. package/lib/client/StructuredEditor.d.ts +11 -0
  39. package/lib/client/StructuredEditor.js +74 -0
  40. package/lib/client/controller.d.ts +115 -0
  41. package/lib/client/controller.js +340 -0
  42. package/lib/client/index.d.ts +13 -0
  43. package/lib/client/index.js +54 -0
  44. package/lib/client/locales.d.ts +145 -0
  45. package/lib/client/locales.js +91 -0
  46. package/lib/client/session-labels.d.ts +8 -0
  47. package/lib/client/session-labels.js +13 -0
  48. package/lib/client/structured.d.ts +18 -0
  49. package/lib/client/structured.js +98 -0
  50. package/lib/client/styles.d.ts +3 -0
  51. package/lib/client/styles.js +36 -0
  52. package/lib/client.js +2825 -0
  53. package/lib/commands.d.ts +3 -3
  54. package/lib/commands.js +5 -4
  55. package/lib/dsh-types.d.ts +20 -0
  56. package/lib/guards.d.ts +2 -2
  57. package/lib/guards.js +3 -2
  58. package/lib/index.d.ts +12 -4
  59. package/lib/index.js +98 -20
  60. package/lib/mode.d.ts +2 -2
  61. package/lib/mode.js +1 -1
  62. package/lib/model-routing.d.ts +2 -2
  63. package/lib/model-routing.js +100 -15
  64. package/lib/preset-registry.js +5 -3
  65. package/lib/profile-remote.d.ts +37 -0
  66. package/lib/profile-remote.js +219 -0
  67. package/lib/profile-rpc.d.ts +35 -0
  68. package/lib/profile-rpc.js +187 -0
  69. package/lib/profile-runtime.d.ts +63 -0
  70. package/lib/profile-runtime.js +310 -0
  71. package/lib/profile-store.d.ts +60 -0
  72. package/lib/profile-store.js +588 -0
  73. package/lib/profile-types.d.ts +80 -0
  74. package/lib/profile-types.js +2 -0
  75. package/lib/profiles.d.ts +26 -0
  76. package/lib/profiles.js +269 -0
  77. package/lib/prompts.d.ts +2 -2
  78. package/lib/prompts.js +4 -4
  79. package/lib/role-providers.d.ts +2 -2
  80. package/lib/role-providers.js +49 -6
  81. package/lib/role-routing.d.ts +37 -3
  82. package/lib/role-routing.js +110 -35
  83. package/lib/role-subagents.d.ts +2 -2
  84. package/lib/role-subagents.js +6 -4
  85. package/lib/roles.d.ts +4 -0
  86. package/lib/roles.js +43 -27
  87. package/lib/routing-policy.d.ts +32 -0
  88. package/lib/routing-policy.js +92 -0
  89. package/lib/runtime-recovery.d.ts +2 -2
  90. package/lib/runtime-recovery.js +215 -54
  91. package/lib/session-metadata.d.ts +13 -0
  92. package/lib/session-metadata.js +34 -0
  93. package/lib/session-persistence.d.ts +35 -0
  94. package/lib/session-persistence.js +304 -0
  95. package/lib/settings.d.ts +34 -1
  96. package/lib/settings.js +33 -7
  97. package/lib/state.d.ts +1 -0
  98. package/lib/state.js +4 -0
  99. package/lib/status.d.ts +9 -1
  100. package/lib/status.js +34 -12
  101. package/locale/en.json +6 -0
  102. package/locale/zh.json +6 -0
  103. package/package.json +66 -15
  104. package/patches/agent-presets-root.example.cordis.patch.yml +6 -10
  105. package/prompts/deepseek-v4-pro.md +1 -1
  106. package/prompts/deepwork.md +3 -3
  107. package/scripts/repair-session-log.mjs +476 -0
  108. package/scripts/session-repair-native-verifier.mjs +367 -0
@@ -0,0 +1,310 @@
1
+ import { join } from "node:path";
2
+ import { createHash, randomUUID } from "node:crypto";
3
+ import { ProfileStore, validateSessionProfileId } from "./profile-store.js";
4
+ import { DsmmProfileError, resolveProfileSettings } from "./profiles.js";
5
+ import { DSMM_ROLES, isRootRole } from "./roles.js";
6
+ import { roleRouteRuntimeState, selectInitialModelRoute } from "./role-routing.js";
7
+ import { resolveEffectiveDsmmRole, sessionEvents } from "./session-scope.js";
8
+ import { isDeepworkActive } from "./state.js";
9
+ import { resolveRoleRuntimePolicy } from "./settings.js";
10
+ function immutableSettings(settings) {
11
+ const copy = structuredClone(settings);
12
+ const freeze = (value) => {
13
+ if (typeof value !== "object" || value === null || Object.isFrozen(value))
14
+ return;
15
+ for (const entry of Object.values(value))
16
+ freeze(entry);
17
+ Object.freeze(value);
18
+ };
19
+ freeze(copy);
20
+ return copy;
21
+ }
22
+ /** Global defaults admit new roots; scoped idle switches replace one root's epoch. */
23
+ export class DsmmProfileRuntime {
24
+ ctx;
25
+ store;
26
+ options;
27
+ getSettings = (agent) => agent === undefined ? this.current.settings : this.bind(agent).settings;
28
+ current;
29
+ baseline;
30
+ bound = new WeakMap();
31
+ admitting = new WeakSet();
32
+ disposedAgents = new WeakSet();
33
+ switching = new WeakSet();
34
+ disposed = false;
35
+ selectionQueue = Promise.resolve();
36
+ constructor(ctx, baseline, store, options = {}) {
37
+ this.ctx = ctx;
38
+ this.store = store;
39
+ this.options = options;
40
+ this.baseline = immutableSettings(baseline);
41
+ this.current = this.prepare(null, { selectedId: null, appliedRevision: null, selectionRevision: "absent" });
42
+ this.getSettings.admission = (agent) => this.admission(agent);
43
+ }
44
+ async initialize() {
45
+ const selection = await this.store.loadSelection();
46
+ this.current = this.prepare(selection.document, selection);
47
+ this.ctx.on?.("agent/created", async ({ agent, signal }) => {
48
+ // Factory initialization already owns native maintenance: never whenIdle
49
+ // or reserve maintenance from inside this serial creation listener.
50
+ await this.admit(agent, signal);
51
+ }, { global: true, prepend: true });
52
+ this.ctx.on?.("agent/disposed", ({ agent }) => { this.disposedAgents.add(agent); }, { global: true });
53
+ this.ctx.effect?.(() => () => { this.disposed = true; });
54
+ // Installation into an already-running host treats those Agents as admitted
55
+ // now, while all later profile switches continue to preserve their snapshot.
56
+ for (const agent of this.agents()?.list() ?? [])
57
+ await this.admit(agent);
58
+ }
59
+ admission(agent) { return agent === undefined ? this.current : this.bind(agent); }
60
+ async getSession(agent) {
61
+ this.assertRoot(agent);
62
+ const admitted = this.bind(agent);
63
+ const disk = await this.store.loadSessionSelection(agent.id);
64
+ this.assertRoot(agent);
65
+ if (this.bind(agent) !== admitted)
66
+ throw new DsmmProfileError("conflict", "The session admission changed while reading. Refresh before selecting again.");
67
+ if ((disk.admissionEpoch === null && admitted.scope !== "global-default") || (disk.admissionEpoch !== null && (disk.admissionEpoch !== admitted.epoch || disk.selectedId !== admitted.selectedId || disk.appliedRevision !== admitted.appliedRevision))) {
68
+ throw new DsmmProfileError("conflict", "The session choice changed outside this Host. Its admitted policy was retained; refresh or resume explicitly.");
69
+ }
70
+ const reason = this.switching.has(agent) ? "maintenance" : agent.status === "running" ? "busy" : agent.runMaintenance === undefined ? "unavailable" : undefined;
71
+ const role = resolveEffectiveDsmmRole(agent, admitted.settings, isDeepworkActive(sessionEvents(agent.session), admitted.settings.defaultActive));
72
+ return { sessionId: agent.id, globalDefault: selectionState(this.current), selection: selectionState(disk), admittedSelection: selectionState(admitted), scope: admitted.scope,
73
+ rolePolicy: roleRouteRuntimeState(agent, admitted.settings, role, admitted.epoch),
74
+ admissionEpoch: admitted.epoch, switchAllowed: reason === undefined, ...(reason === undefined ? {} : { switchUnavailableReason: reason }) };
75
+ }
76
+ /** The fourth argument is trusted native caller authority, never wire data. */
77
+ selectSession(request, agent, signal, assertAuthority) {
78
+ this.assertRoot(agent);
79
+ if (request.sessionId !== agent.id)
80
+ throw new DsmmProfileError("not-owned", "The native session does not match the captured Agent.");
81
+ const admitted = this.bind(agent);
82
+ const assertCurrent = (maintenanceSignal) => {
83
+ this.assertRoot(agent);
84
+ if (signal?.aborted || maintenanceSignal?.aborted)
85
+ throw new DsmmProfileError("cancelled", "Session profile selection was cancelled; the previous admission was retained.");
86
+ if (this.bind(agent) !== admitted || admitted.epoch !== request.expectedAdmissionEpoch)
87
+ throw new DsmmProfileError("conflict", "The session admission changed. Refresh before selecting again.");
88
+ assertAuthority?.();
89
+ };
90
+ assertCurrent();
91
+ if (agent.status === "running")
92
+ throw new DsmmProfileError("busy", "The session is running. Wait for its current activity before selecting a profile.");
93
+ if (agent.runMaintenance === undefined)
94
+ throw new DsmmProfileError("unavailable", "Native idle maintenance is unavailable; no session selection was committed.");
95
+ let operation;
96
+ try {
97
+ operation = agent.runMaintenance(async (maintenanceSignal) => {
98
+ this.switching.add(agent);
99
+ try {
100
+ assertCurrent(maintenanceSignal);
101
+ const epoch = newEpoch();
102
+ const result = await this.store.selectSession(request, epoch, async (document) => {
103
+ const prepared = immutableSettings(resolveProfileSettings(this.baseline, document?.settings ?? {}));
104
+ await this.validate(prepared, agent, maintenanceSignal);
105
+ assertCurrent(maintenanceSignal);
106
+ return prepared;
107
+ }, {
108
+ assertCurrent: () => assertCurrent(maintenanceSignal),
109
+ committed: (selection, settings) => {
110
+ this.bound.set(agent, this.profileAdmission(selection, settings, epoch, request.id === null ? "deployment-baseline" : "session-override"));
111
+ }
112
+ });
113
+ // A committed selection remains a successful transaction even if a
114
+ // queued wake or disposal wins immediately when maintenance releases.
115
+ return { sessionId: request.sessionId, globalDefault: selectionState(this.current), selection: selectionState(result.selection), admittedSelection: selectionState(result.selection),
116
+ scope: request.id === null ? "deployment-baseline" : "session-override", admissionEpoch: epoch, switchAllowed: true };
117
+ }
118
+ finally {
119
+ this.switching.delete(agent);
120
+ }
121
+ });
122
+ }
123
+ catch (error) {
124
+ if (error instanceof DsmmProfileError)
125
+ throw error;
126
+ throw new DsmmProfileError("maintenance", "Another activity owns the session's idle maintenance phase. No selection was queued or committed.");
127
+ }
128
+ return operation;
129
+ }
130
+ async describe() {
131
+ const persisted = await this.store.describe();
132
+ const current = this.current;
133
+ const changedOutsideHost = persisted.selectedId !== current.selectedId
134
+ || persisted.appliedRevision !== current.appliedRevision
135
+ || persisted.selectionRevision !== current.selectionRevision;
136
+ return {
137
+ ...persisted,
138
+ roles: DSMM_ROLES.map((role) => {
139
+ const configured = this.baseline.roleRouting[role.id];
140
+ const runtimePolicy = { ...(configured?.strategy === undefined ? {} : { strategy: configured.strategy }),
141
+ ...(configured?.rateLimit === undefined ? {} : { rateLimit: structuredClone(configured.rateLimit) }) };
142
+ return { id: role.id, label: role.name, enabled: this.baseline.roles[role.id],
143
+ ...(Object.keys(runtimePolicy).length === 0 ? {} : { runtimePolicy }) };
144
+ }),
145
+ editorDefaults: structuredClone(this.baseline.runtimePolicy),
146
+ selectedId: current.selectedId,
147
+ appliedRevision: current.appliedRevision,
148
+ // Keep the disk revision for CAS, but never label its unvalidated policy
149
+ // as admitted in this Host. Existing Agent snapshots remain untouched.
150
+ ...(persisted.selectionError === undefined && changedOutsideHost ? {
151
+ selectionError: {
152
+ code: "conflict",
153
+ message: "The persisted selection changed outside this Host. New Agents still use this Host's admitted current policy; reapply the desired profile or restart."
154
+ }
155
+ } : {})
156
+ };
157
+ }
158
+ read(id) { return this.store.read(id); }
159
+ save(request) { return this.store.save(request); }
160
+ select(request) {
161
+ const operation = this.selectionQueue.then(async () => {
162
+ const result = await this.store.select(request, async (document) => {
163
+ const prepared = immutableSettings(resolveProfileSettings(this.baseline, document?.settings ?? {}));
164
+ await this.validate(prepared);
165
+ return prepared;
166
+ });
167
+ // There is no await between successful durable commit and publication of
168
+ // the complete settings value. Draft saves never reach this assignment.
169
+ this.current = this.profileAdmission(result.selection, result.prepared, newEpoch(), "global-default");
170
+ return this.describe();
171
+ });
172
+ this.selectionQueue = operation.catch(() => undefined);
173
+ return operation;
174
+ }
175
+ prepare(document, selection, epoch = newEpoch(), scope = "global-default") {
176
+ return this.profileAdmission(selection, immutableSettings(resolveProfileSettings(this.baseline, document?.settings ?? {})), epoch, scope);
177
+ }
178
+ profileAdmission(selection, settings, epoch, scope) {
179
+ return Object.freeze({ ...selectionState(selection), settings, epoch, scope, profile: selection.selectedId === null || selection.appliedRevision === null ? null : Object.freeze({ id: selection.selectedId, revision: selection.appliedRevision }) });
180
+ }
181
+ agents() { return this.ctx.get?.("agents"); }
182
+ bind(agent) {
183
+ const existing = this.bound.get(agent);
184
+ if (existing !== undefined)
185
+ return existing;
186
+ if (this.admitting.has(agent))
187
+ throw new DsmmProfileError("activation", "The session's profile admission has not completed.");
188
+ if (agent.id !== undefined && this.agents()?.get !== undefined) {
189
+ // Native enter() precedes serial created admission. An early RPC or
190
+ // extension (including unpublished setup) cannot make a native root skip
191
+ // its persisted sidecar by eagerly creating a default binding.
192
+ throw new DsmmProfileError("activation", "The native session has not completed its awaited profile admission.");
193
+ }
194
+ // The native factory enters the exact child/owner pair before announcing
195
+ // creation. Durable lineage and inherited persona never establish ownership.
196
+ const parent = this.owner(agent);
197
+ const admitted = parent === undefined ? this.current : this.bind(parent);
198
+ this.bound.set(agent, admitted);
199
+ return admitted;
200
+ }
201
+ owner(agent) {
202
+ const agents = this.agents();
203
+ return agent.id === undefined ? undefined : agents?.list().find((candidate) => candidate !== agent && agents.isOwnedBy(agent.id, candidate));
204
+ }
205
+ assertRoot(agent) {
206
+ if (this.disposed || this.disposedAgents.has(agent))
207
+ throw new DsmmProfileError("disposed", "The session or profile service was disposed; no selection was committed.");
208
+ validateSessionProfileId(agent.id);
209
+ const agents = this.agents();
210
+ if (agents?.get === undefined)
211
+ throw new DsmmProfileError("unavailable", "Native live Agent lookup is unavailable; no session selection was committed.");
212
+ if (agents.get(agent.id) !== agent || this.owner(agent) !== undefined || agent.session.header?.origin === "subagent") {
213
+ throw new DsmmProfileError("not-owned", "Session profile selection requires the exact live ordinary root Agent.");
214
+ }
215
+ }
216
+ async admit(agent, signal) {
217
+ if (this.bound.has(agent))
218
+ return;
219
+ const parent = this.owner(agent);
220
+ if (parent !== undefined) {
221
+ this.bound.set(agent, this.bind(parent));
222
+ return;
223
+ }
224
+ if (agent.id === undefined) {
225
+ this.bind(agent);
226
+ return;
227
+ }
228
+ this.admitting.add(agent);
229
+ try {
230
+ signal?.throwIfAborted();
231
+ const selection = await this.store.loadSessionSelection(agent.id);
232
+ signal?.throwIfAborted();
233
+ if (this.disposed || this.disposedAgents.has(agent))
234
+ throw new DsmmProfileError("disposed", "The session was disposed during profile admission.");
235
+ const registry = this.agents();
236
+ if (registry?.get !== undefined && registry.get(agent.id) !== agent)
237
+ throw new DsmmProfileError("not-owned", "The live session changed during profile admission.");
238
+ this.bound.set(agent, selection.admissionEpoch === null ? this.current : this.prepare(selection.document, selection, selection.admissionEpoch, selection.selectedId === null ? "deployment-baseline" : "session-override"));
239
+ }
240
+ finally {
241
+ this.admitting.delete(agent);
242
+ }
243
+ }
244
+ async validate(settings, agent, signal) {
245
+ if (this.options.validateCandidate !== undefined) {
246
+ await this.options.validateCandidate(settings);
247
+ return;
248
+ }
249
+ const registry = this.ctx.get?.("agentPresets");
250
+ if (registry !== undefined) {
251
+ for (const role of DSMM_ROLES.filter((role) => isRootRole(role) && settings.roles[role.id])) {
252
+ try {
253
+ const preset = await registry.resolve(role.id);
254
+ if (preset.broken !== undefined)
255
+ throw new Error("unusable root preset");
256
+ }
257
+ catch {
258
+ throw new DsmmProfileError("activation", "An enabled DW root preset is unavailable. Resolve the native preset loading error before applying a profile.", role.id);
259
+ }
260
+ }
261
+ }
262
+ const nativeAgent = agent ?? (this.agents()?.list() ?? []).find((candidate) => candidate.ctx?.get?.("llm")?.resolveCallConfig !== undefined);
263
+ const inherited = nativeAgent?.options;
264
+ const inheritedRoute = inherited?.provider === undefined || inherited.model === undefined ? undefined
265
+ : { provider: inherited.provider, model: inherited.model, ...(inherited.reasoningEffort === undefined ? {} : { reasoningEffort: inherited.reasoningEffort }) };
266
+ const chains = [];
267
+ for (const role of DSMM_ROLES) {
268
+ if (!settings.roles[role.id])
269
+ continue;
270
+ const policy = resolveRoleRuntimePolicy(settings, role.id);
271
+ // No explicit primary inherits native routing. Dormant fallbacks alone
272
+ // cannot make a usable inherited route fail profile Apply. If that exact
273
+ // route is unavailable here, native request preflight remains authority.
274
+ if (policy.primary === undefined && inheritedRoute === undefined)
275
+ continue;
276
+ const routes = [policy.primary ?? inheritedRoute, ...policy.fallbackRoutes];
277
+ if (routes.length > 0)
278
+ chains.push({ routes, field: `settings.roleRouting.${role.id}.${policy.primary === undefined ? "fallbackRoutes" : "primary"}` });
279
+ }
280
+ if (chains.length === 0)
281
+ return;
282
+ const llm = nativeAgent?.ctx?.get?.("llm")
283
+ ?? this.ctx.get?.("llm") ?? (this.ctx.get === undefined ? this.ctx.llm : undefined);
284
+ if (llm?.resolveCallConfig === undefined) {
285
+ throw new DsmmProfileError("activation", "Open a chat so its native model service can validate configured routes before applying this profile.");
286
+ }
287
+ for (const { routes, field } of chains) {
288
+ try {
289
+ await selectInitialModelRoute(llm, routes, signal);
290
+ }
291
+ catch {
292
+ throw new DsmmProfileError("activation", "The configured provider, model or exact reasoning effort is unavailable in the native model catalog.", field);
293
+ }
294
+ }
295
+ }
296
+ }
297
+ function newEpoch() { return createHash("sha256").update(randomUUID()).digest("hex"); }
298
+ function selectionState(selection) {
299
+ return { selectedId: selection.selectedId, appliedRevision: selection.appliedRevision, selectionRevision: selection.selectionRevision };
300
+ }
301
+ /** No guessed home fallback: native deployment context owns this directory. */
302
+ export async function createProfileRuntime(ctx, baseline) {
303
+ const profile = ctx.get?.("profileContext");
304
+ if (typeof profile?.dir !== "string" || profile.dir.trim() === "")
305
+ throw new DsmmProfileError("activation", "Deepwork profiles require the native deployment profile directory.");
306
+ const runtime = new DsmmProfileRuntime(ctx, baseline, new ProfileStore(join(profile.dir, "dsmm-profiles")));
307
+ await runtime.initialize();
308
+ return runtime;
309
+ }
310
+ //# sourceMappingURL=profile-runtime.js.map
@@ -0,0 +1,60 @@
1
+ import type { ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSelectionState, ProfileSnapshot, SessionProfileSelectRequest } 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 LoadedSessionProfileSelection extends LoadedProfileSelection {
10
+ sessionId: string;
11
+ admissionEpoch: string | null;
12
+ }
13
+ export declare const MAX_SESSION_PROFILE_CHOICES = 1024;
14
+ export interface SessionProfileCommit<T> {
15
+ /** Trusted native liveness/cancellation fence; invoked immediately before rename. */
16
+ assertCurrent(): void;
17
+ /** Synchronous publication after durable commit. Must not throw or await. */
18
+ committed(selection: LoadedSessionProfileSelection, prepared: T): void;
19
+ }
20
+ export interface ProfileStoreOptions {
21
+ lockTimeoutMs?: number;
22
+ lockPollMs?: number;
23
+ /** Narrow test seam for a failed atomic replacement; never delete the old target. */
24
+ rename?: (source: string, destination: string) => void;
25
+ }
26
+ /** This directory is supplied by the Host, never by a remote method parameter. */
27
+ export declare class ProfileStore {
28
+ readonly profileDir: string;
29
+ private readonly timeoutMs;
30
+ private readonly pollMs;
31
+ private readonly rename;
32
+ private rootIdentity?;
33
+ constructor(profileDir: string, options?: ProfileStoreOptions);
34
+ describe(): Promise<ProfileSnapshot>;
35
+ read(id: string): Promise<ProfileReadResult>;
36
+ save(request: ProfileSaveRequest): Promise<ProfileReadResult>;
37
+ loadSelection(): Promise<LoadedProfileSelection>;
38
+ loadSessionSelection(sessionId: string): Promise<LoadedSessionProfileSelection>;
39
+ selectSession<T>(request: SessionProfileSelectRequest, epoch: string, validateCandidate: (document: DsmmProfileDocument | null) => T | Promise<T>, commit: SessionProfileCommit<T>): Promise<{
40
+ selection: LoadedSessionProfileSelection;
41
+ prepared: T;
42
+ }>;
43
+ select<T = undefined>(request: ProfileSelectRequest, validateCandidate?: (document: DsmmProfileDocument | null) => T | Promise<T>): Promise<{
44
+ selection: LoadedProfileSelection;
45
+ prepared: T;
46
+ }>;
47
+ private readResult;
48
+ private inventory;
49
+ private draftName;
50
+ private draft;
51
+ private selection;
52
+ private sessionSelection;
53
+ private assertSelectionRevision;
54
+ private publishRevision;
55
+ private atomicReplace;
56
+ private validateRoot;
57
+ private locked;
58
+ }
59
+ export declare function validateSessionProfileId(id: unknown): asserts id is string;
60
+ //# sourceMappingURL=profile-store.d.ts.map