@dsmm/dsmm 0.3.2 → 0.3.3

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 (110) hide show
  1. package/README.md +2 -2
  2. package/cordis.patch.yml +0 -9
  3. package/docs/agent-presets.md +5 -5
  4. package/docs/compatibility.md +2 -6
  5. package/docs/migration-from-ocmm.md +1 -1
  6. package/docs/roadmap.md +5 -12
  7. package/docs/settings-status.md +1 -1
  8. package/lib/client/ChildrenPanel.d.ts +1 -4
  9. package/lib/client/ChildrenPanel.js +3 -3
  10. package/lib/client/DeploymentPage.d.ts +1 -3
  11. package/lib/client/DeploymentPage.js +2 -2
  12. package/lib/client/PermissionsPanel.d.ts +1 -3
  13. package/lib/client/PermissionsPanel.js +2 -3
  14. package/lib/client/children-locales.d.ts +4 -4
  15. package/lib/client/controller.js +4 -1
  16. package/lib/client/deployment-locales.js +0 -1
  17. package/lib/client/deployment-modules.js +1 -1
  18. package/lib/client/index.js +2 -7
  19. package/lib/client/locales.js +131 -119
  20. package/lib/client/permission-locales.d.ts +0 -26
  21. package/lib/client/permission-locales.js +0 -20
  22. package/lib/client.js +1837 -3634
  23. package/lib/index.d.ts +0 -2
  24. package/lib/index.js +9 -22
  25. package/lib/native-admission.d.ts +0 -3
  26. package/lib/native-admission.js +12 -45
  27. package/lib/permission-fs-search.js +1 -2
  28. package/lib/permission-fs.js +1 -2
  29. package/lib/permission-web.js +1 -2
  30. package/lib/preset-materializer.js +3 -3
  31. package/lib/preset-registry.d.ts +20 -2
  32. package/lib/preset-registry.js +46 -17
  33. package/lib/profile-diagnostics.js +1 -1
  34. package/lib/profile-remote.js +1 -3
  35. package/lib/role-policy.js +2 -2
  36. package/lib/role-subagents.js +2 -1
  37. package/lib/roles.d.ts +2 -0
  38. package/lib/roles.js +2 -0
  39. package/lib/settings.d.ts +1 -3
  40. package/lib/settings.js +4 -9
  41. package/package.json +1 -5
  42. package/lib/client/ChildPermissions.d.ts +0 -43
  43. package/lib/client/ChildPermissions.js +0 -100
  44. package/lib/client/HistoryContinuation.d.ts +0 -7
  45. package/lib/client/HistoryContinuation.js +0 -22
  46. package/lib/client/PermissionPanelEntry.d.ts +0 -8
  47. package/lib/client/PermissionPanelEntry.js +0 -11
  48. package/lib/client/TemporaryPermissions.d.ts +0 -21
  49. package/lib/client/TemporaryPermissions.js +0 -94
  50. package/lib/client/history-controller.d.ts +0 -29
  51. package/lib/client/history-controller.js +0 -111
  52. package/lib/client/history-entry.d.ts +0 -11
  53. package/lib/client/history-entry.js +0 -106
  54. package/lib/client/history-locales.d.ts +0 -95
  55. package/lib/client/history-locales.js +0 -41
  56. package/lib/client/temporary-permission-client.d.ts +0 -20
  57. package/lib/client/temporary-permission-client.js +0 -52
  58. package/lib/client/temporary-permission-entry.d.ts +0 -6
  59. package/lib/client/temporary-permission-entry.js +0 -56
  60. package/lib/history-candidates.d.ts +0 -30
  61. package/lib/history-candidates.js +0 -176
  62. package/lib/history-codec.d.ts +0 -11
  63. package/lib/history-codec.js +0 -102
  64. package/lib/history-contract.d.ts +0 -44
  65. package/lib/history-contract.js +0 -2
  66. package/lib/history-controller.d.ts +0 -42
  67. package/lib/history-controller.js +0 -329
  68. package/lib/history-policy.d.ts +0 -4
  69. package/lib/history-policy.js +0 -8
  70. package/lib/history-remote.d.ts +0 -28
  71. package/lib/history-remote.js +0 -17
  72. package/lib/history-rpc.d.ts +0 -24
  73. package/lib/history-rpc.js +0 -136
  74. package/lib/history-support.d.ts +0 -15
  75. package/lib/history-support.js +0 -21
  76. package/lib/history-types.d.ts +0 -67
  77. package/lib/history-types.js +0 -2
  78. package/lib/permission-child-control.d.ts +0 -36
  79. package/lib/permission-child-control.js +0 -164
  80. package/lib/permission-exec-argv.d.ts +0 -32
  81. package/lib/permission-exec-argv.js +0 -171
  82. package/lib/permission-temporary-files.d.ts +0 -19
  83. package/lib/permission-temporary-files.js +0 -248
  84. package/lib/permission-temporary-grants.d.ts +0 -106
  85. package/lib/permission-temporary-grants.js +0 -198
  86. package/lib/permission-temporary-install.d.ts +0 -25
  87. package/lib/permission-temporary-install.js +0 -86
  88. package/lib/permission-temporary-remote.d.ts +0 -19
  89. package/lib/permission-temporary-remote.js +0 -75
  90. package/lib/permission-temporary-rpc.d.ts +0 -37
  91. package/lib/permission-temporary-rpc.js +0 -154
  92. package/lib/permission-temporary-types.d.ts +0 -47
  93. package/lib/permission-temporary-types.js +0 -2
  94. package/lib/permission-temporary-web.d.ts +0 -11
  95. package/lib/permission-temporary-web.js +0 -154
  96. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +0 -13291
  97. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +0 -9133
  98. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +0 -156
  99. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +0 -3546
  100. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +0 -431
  101. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +0 -119
  102. package/patches/dsh-approval-settlement/README.md +0 -41
  103. package/patches/dsh-approval-settlement/metadata.json +0 -10
  104. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +0 -383
  105. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +0 -55
  106. package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +0 -16673
  107. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +0 -29
  108. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +0 -196
  109. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +0 -35
  110. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +0 -40
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=history-contract.js.map
@@ -1,42 +0,0 @@
1
- import { Service } from "@deepseek-ai/cordis";
2
- import type { Context } from "@deepseek-ai/cordis";
3
- import type { Agent } from "@deepseek-ai/dsh-agent";
4
- import type { DsmmProfileAdmission } from "./settings.js";
5
- import type { HistoryCandidates, HistoryNativeAdmission, HistoryOperator } from "./history-contract.js";
6
- import type { HistoryChoices, HistoryConfirmRequest, HistoryContinuationResult, HistoryFailure, HistoryFailureCode, HistoryPreview, HistoryPreviewRequest, HistoryStatus } from "./history-types.js";
7
- export declare class HistoryRefusal extends Error {
8
- readonly code: HistoryFailureCode;
9
- readonly storageEffects: HistoryFailure["storageEffects"];
10
- constructor(code: HistoryFailureCode, storageEffects?: HistoryFailure["storageEffects"]);
11
- }
12
- /** Host-only one-operation intents around the native history and activation APIs. */
13
- export declare class HistoryContinuations extends Service {
14
- private readonly candidates;
15
- private readonly admission;
16
- readonly lifetime: AbortController;
17
- private readonly intents;
18
- private readonly prepared;
19
- private guardedLoop;
20
- private readonly cleanups;
21
- constructor(ctx: Context, candidates: HistoryCandidates, admission: HistoryNativeAdmission);
22
- private compatibility;
23
- private visible;
24
- private ready;
25
- private compatible;
26
- describe(input: string, operator: HistoryOperator): Promise<HistoryStatus>;
27
- choices(operator: HistoryOperator): Promise<HistoryChoices>;
28
- preview(input: HistoryPreviewRequest, operator: HistoryOperator): Promise<HistoryPreview>;
29
- private check;
30
- /** Called only by NativeAdmission.created for the exact unpublished continuation candidate. */
31
- admissionForCreated(agent: Agent): DsmmProfileAdmission | undefined;
32
- private authorize;
33
- confirm(input: HistoryConfirmRequest, operator: HistoryOperator): Promise<HistoryContinuationResult>;
34
- private release;
35
- }
36
- declare module "@deepseek-ai/cordis" {
37
- interface Context {
38
- dsmmHistoryContinuation: HistoryContinuations;
39
- }
40
- }
41
- export declare function historyFailure(error: unknown): HistoryFailure;
42
- //# sourceMappingURL=history-controller.d.ts.map
@@ -1,329 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { isDeepStrictEqual } from "node:util";
3
- import { Service, symbols } from "@deepseek-ai/cordis";
4
- import { SessionId } from "@deepseek-ai/dsh-session";
5
- import { scopeLifetime } from "./lifetime.js";
6
- import { historyJson, historySessionId, parseHistoryChoices, parseHistoryConfirmRequest, parseHistoryPreview, parseHistoryPreviewRequest } from "./history-codec.js";
7
- export class HistoryRefusal extends Error {
8
- code;
9
- storageEffects;
10
- constructor(code, storageEffects = "none") {
11
- super(`History continuation refused: ${code}`);
12
- this.code = code;
13
- this.storageEffects = storageEffects;
14
- }
15
- }
16
- function original(value) { return Reflect.get(value, symbols.original) ?? value; }
17
- /** Host-only one-operation intents around the native history and activation APIs. */
18
- export class HistoryContinuations extends Service {
19
- candidates;
20
- admission;
21
- lifetime = new AbortController();
22
- intents = new Map();
23
- prepared = new WeakMap();
24
- guardedLoop;
25
- cleanups = new Set();
26
- constructor(ctx, candidates, admission) {
27
- super(ctx, "dsmmHistoryContinuation");
28
- this.candidates = candidates;
29
- this.admission = admission;
30
- ctx.effect(() => async () => { await Promise.all(this.cleanups); }, "dsmm: release history preparations");
31
- const loop = ctx.get("agentLoop");
32
- if (typeof loop?.requireActivationAdmission === "function" && typeof loop.registerActivationGuard === "function") {
33
- loop.requireActivationAdmission();
34
- ctx.effect(() => {
35
- const remove = loop.registerActivationGuard(request => this.authorize(request));
36
- this.guardedLoop = original(loop);
37
- return () => { this.guardedLoop = undefined; remove(); };
38
- }, "dsmm: history activation admission");
39
- }
40
- const controller = ctx.get("sessionController");
41
- if (typeof controller?.registerHistoryOpenGuard === "function") {
42
- const owner = original(controller);
43
- ctx.effect(() => controller.registerHistoryOpenGuard({
44
- signal: AbortSignal.any([this.lifetime.signal, admission.lifetime.signal, candidates.signal]),
45
- assertCurrent: () => {
46
- this.ready();
47
- if (original(this.ctx.sessionController) !== owner)
48
- throw new HistoryRefusal("unsupported-host");
49
- },
50
- }), "dsmm: history opening readiness");
51
- }
52
- scopeLifetime(ctx, "dsmm: revoke history intents", () => {
53
- this.lifetime.abort();
54
- for (const intent of this.intents.values()) {
55
- try {
56
- this.release(intent);
57
- }
58
- catch (error) {
59
- ctx.logger.error(error);
60
- }
61
- }
62
- });
63
- }
64
- compatibility() {
65
- const loop = this.ctx.get("agentLoop"), controller = this.ctx.get("sessionController");
66
- if (typeof loop?.registerActivationGuard !== "function" || this.guardedLoop === undefined || original(loop) !== original(this.guardedLoop) || typeof loop.activationState !== "function"
67
- || typeof controller?.activateSession !== "function" || controller.activateOnFollow !== false)
68
- return "unsupported-host";
69
- if (this.ctx.get("sessionPersistence")?.writeAdmission?.lockedInspection !== 1)
70
- return "unsupported-backend";
71
- if (!this.admission.isReady || this.admission.lifetime.signal.aborted || this.candidates.signal.aborted || this.lifetime.signal.aborted)
72
- return "unavailable";
73
- return undefined;
74
- }
75
- visible(id, operator) {
76
- operator.assertCurrent();
77
- operator.assertVisible(id);
78
- }
79
- ready() { const reason = this.compatibility(); if (reason)
80
- throw new HistoryRefusal(reason); }
81
- async compatible() {
82
- const reason = this.compatibility();
83
- if (reason)
84
- return reason;
85
- try {
86
- await this.candidates.checkCompatibility?.();
87
- return this.compatibility();
88
- }
89
- catch (error) {
90
- return historyFailure(error).code;
91
- }
92
- }
93
- async describe(input, operator) {
94
- const sessionId = historySessionId(input);
95
- this.visible(sessionId, operator);
96
- const reason = await this.compatible();
97
- let child = false;
98
- try {
99
- const observation = await this.ctx.sessionQuery.observeSession(SessionId(sessionId), { signal: operator.signal, projectionMode: "none" });
100
- try {
101
- child = observation.header.origin === "subagent";
102
- }
103
- finally {
104
- observation[Symbol.dispose]();
105
- }
106
- }
107
- catch {
108
- this.visible(sessionId, operator);
109
- return { sessionId, readable: "unavailable", execution: "unavailable", compatibleHost: reason !== "unsupported-host", reason: reason ?? "format-unavailable" };
110
- }
111
- this.visible(sessionId, operator);
112
- if (reason || child)
113
- return { sessionId, readable: "readable", execution: "unavailable", compatibleHost: reason !== "unsupported-host", reason: reason ?? "child-owner-required" };
114
- const state = this.ctx.agentLoop.activationState(SessionId(sessionId));
115
- const live = this.ctx.agents.get(SessionId(sessionId));
116
- return { sessionId, readable: "readable", compatibleHost: true,
117
- execution: state?.phase === "initializing" || [...this.intents.values()].some(intent => intent.request.sessionId === sessionId && intent.operation !== undefined) ? "activating"
118
- : live && this.admission.get(live) ? "active" : live ? "unavailable" : "authorization-required", ...(live && !this.admission.get(live) ? { reason: "unavailable" } : {}) };
119
- }
120
- async choices(operator) {
121
- operator.assertCurrent();
122
- this.ready();
123
- await this.candidates.checkCompatibility?.();
124
- operator.assertCurrent();
125
- this.ready();
126
- const result = await this.candidates.choices(operator.signal);
127
- operator.assertCurrent();
128
- this.ready();
129
- return parseHistoryChoices(result);
130
- }
131
- async preview(input, operator) {
132
- const request = parseHistoryPreviewRequest(input), sessionId = SessionId(request.sessionId);
133
- this.visible(sessionId, operator);
134
- this.ready();
135
- await this.candidates.checkCompatibility?.();
136
- this.visible(sessionId, operator);
137
- this.ready();
138
- if (this.ctx.agents.get(sessionId) || this.ctx.agentLoop.activationState(sessionId))
139
- throw new HistoryRefusal("busy");
140
- const persistence = this.ctx.sessionPersistence, controller = this.ctx.sessionController;
141
- const stat = await persistence.stat(sessionId, { signal: operator.signal });
142
- this.visible(sessionId, operator);
143
- this.ready();
144
- if (!stat)
145
- throw new HistoryRefusal("not-found");
146
- const observation = await this.ctx.sessionQuery.observeSession(sessionId, { signal: operator.signal, projectionMode: "all" });
147
- let inspection, pending;
148
- try {
149
- if (observation.source !== "prepared")
150
- throw new HistoryRefusal("busy");
151
- if (observation.header.origin === "subagent")
152
- throw new HistoryRefusal("child-owner-required");
153
- if (!observation.header.cwd)
154
- throw new HistoryRefusal("unavailable");
155
- const inbox = observation.projections?.values.inbox;
156
- if (!inbox)
157
- throw new HistoryRefusal("unsupported-host");
158
- inspection = structuredClone({ meta: observation.header, inheritedEventCount: observation.inheritedEventCount, events: [...observation.events] });
159
- pending = { nextTurn: inbox["next-turn"].map(value => historyJson(value)), nextStep: inbox["next-step"].map(value => historyJson(value)) };
160
- }
161
- finally {
162
- observation[Symbol.dispose]();
163
- }
164
- this.visible(sessionId, operator);
165
- this.ready();
166
- const candidate = await this.candidates.prepare(Object.freeze(request), structuredClone(inspection), operator.signal);
167
- let intent;
168
- try {
169
- this.visible(sessionId, operator);
170
- this.ready();
171
- candidate.assertCurrent();
172
- if (candidate.view.preset.id !== request.preset || (candidate.view.profile?.id ?? null) !== request.profileId
173
- || !isDeepStrictEqual(candidate.view.model, candidate.model))
174
- throw new HistoryRefusal("stale");
175
- for (const previous of this.intents.values())
176
- if (previous.operator.peer === operator.peer && previous.request.sessionId === sessionId) {
177
- if (previous.operation)
178
- throw new HistoryRefusal("busy");
179
- this.release(previous);
180
- }
181
- const abort = new AbortController();
182
- const signal = AbortSignal.any([abort.signal, operator.peerSignal, this.lifetime.signal, this.admission.lifetime.signal, this.candidates.signal, candidate.signal]);
183
- const expired = () => { if (intent && !intent.operation)
184
- this.release(intent); };
185
- intent = { id: randomUUID(), request, operator, inspection, persistence, persistenceIdentity: persistence.identity, controller, candidate, view: structuredClone(candidate.view), model: structuredClone(candidate.model), migrationRequired: stat.formatStatus === "migration-required", signal, abort,
186
- detach: () => signal.removeEventListener("abort", expired), effects: "none" };
187
- this.intents.set(intent.id, intent);
188
- signal.addEventListener("abort", expired, { once: true });
189
- this.check(intent);
190
- return parseHistoryPreview({ sessionId, intentId: intent.id, cwd: inspection.meta.cwd, candidate: intent.view, migrationRequired: intent.migrationRequired, pending });
191
- }
192
- catch (error) {
193
- if (intent)
194
- this.release(intent);
195
- else
196
- await candidate.dispose();
197
- throw error;
198
- }
199
- }
200
- check(intent) {
201
- if (intent.signal.aborted)
202
- throw new HistoryRefusal("cancelled", intent.effects);
203
- intent.operator.assertOwner();
204
- this.ready();
205
- if (this.intents.get(intent.id) !== intent || original(this.ctx.sessionPersistence) !== original(intent.persistence) || this.ctx.sessionPersistence.identity !== intent.persistenceIdentity
206
- || original(this.ctx.sessionController) !== original(intent.controller))
207
- throw new HistoryRefusal("stale", intent.effects);
208
- intent.operator.assertVisible(intent.request.sessionId);
209
- if (!isDeepStrictEqual(intent.candidate.view, intent.view) || !isDeepStrictEqual(intent.candidate.model, intent.model))
210
- throw new HistoryRefusal("stale", intent.effects);
211
- intent.candidate.assertCurrent();
212
- }
213
- /** Called only by NativeAdmission.created for the exact unpublished continuation candidate. */
214
- admissionForCreated(agent) {
215
- const intent = this.prepared.get(agent);
216
- if (!intent)
217
- return undefined;
218
- this.check(intent);
219
- if (intent.agent !== agent || agent.id !== intent.request.sessionId || agent.session.header.origin === "subagent")
220
- throw new HistoryRefusal("not-owned", intent.effects);
221
- return intent.candidate.admission;
222
- }
223
- authorize(request) {
224
- const intent = [...this.intents.values()].find(row => row.options === request.options);
225
- if (!intent || request.parentAgent || !request.processPending || request.sessionId !== intent.request.sessionId || request.setup !== intent.options?.setup
226
- || original(request.persistence) !== original(intent.persistence) || request.persistence.identity !== intent.persistenceIdentity || original(request.owner.fiber) !== intent.nativeOwner)
227
- throw new HistoryRefusal("authorization-required");
228
- const check = () => { request.signal.throwIfAborted(); this.check(intent); };
229
- check();
230
- return {
231
- assertCurrent: check,
232
- validateLoaded: loaded => {
233
- check();
234
- if (!isDeepStrictEqual({ meta: loaded.meta, inheritedEventCount: loaded.inheritedEventCount, events: loaded.events }, intent.inspection)
235
- || loaded.migrationRequired !== intent.migrationRequired)
236
- throw new HistoryRefusal("stale");
237
- intent.effects = "may-have-committed";
238
- },
239
- validatePublish: agent => {
240
- check();
241
- if (this.prepared.get(agent) !== intent || intent.agent !== agent)
242
- throw new HistoryRefusal("not-owned", intent.effects);
243
- if (this.ctx.agents.get(agent.id) === agent && this.admission.assert(agent) !== intent.candidate.admission)
244
- throw new HistoryRefusal("stale", intent.effects);
245
- },
246
- dispose() { },
247
- };
248
- }
249
- confirm(input, operator) {
250
- const request = parseHistoryConfirmRequest(input), intent = this.intents.get(request.intentId);
251
- this.visible(request.sessionId, operator);
252
- this.ready();
253
- if (!intent || intent.request.sessionId !== request.sessionId || intent.operator.peer !== operator.peer || intent.operator.connection !== operator.connection)
254
- throw new HistoryRefusal("authorization-required");
255
- try {
256
- this.check(intent);
257
- }
258
- catch (error) {
259
- if (!intent.operation)
260
- this.release(intent);
261
- throw error;
262
- }
263
- if (!request.processPending || intent.migrationRequired && !request.acceptMigration)
264
- throw new HistoryRefusal("authorization-required");
265
- if (intent.operation)
266
- return intent.operation;
267
- const signal = AbortSignal.any([operator.signal, intent.signal]);
268
- const operation = (async () => {
269
- let committed = false;
270
- try {
271
- await intent.candidate.revalidate(signal);
272
- operator.assertCurrent();
273
- this.check(intent);
274
- const activation = {
275
- sessionId: SessionId(request.sessionId), agentPreset: intent.request.preset, modelSelection: intent.model,
276
- agentOptions: { provider: intent.model.provider, model: intent.model.model }, signal, processPending: true,
277
- authorize: (options, owner) => { operator.assertCurrent(); this.check(intent); intent.options = options; intent.nativeOwner = original(owner.fiber); },
278
- setup: async (_ctx, agent) => {
279
- operator.assertCurrent();
280
- this.check(intent);
281
- intent.agent = agent;
282
- this.prepared.set(agent, intent);
283
- await intent.candidate.install(agent, signal);
284
- operator.assertCurrent();
285
- this.check(intent);
286
- },
287
- };
288
- await intent.controller.activateSession(activation);
289
- committed = true;
290
- return { sessionId: request.sessionId, execution: "active" };
291
- }
292
- catch (error) {
293
- throw new HistoryRefusal(historyFailure(error).code, intent.effects);
294
- }
295
- finally {
296
- this.release(intent, !committed);
297
- }
298
- })();
299
- intent.operation = operation;
300
- return operation;
301
- }
302
- release(intent, abort = true) {
303
- if (this.intents.get(intent.id) !== intent)
304
- return;
305
- this.intents.delete(intent.id);
306
- intent.detach();
307
- if (abort)
308
- intent.abort.abort();
309
- if (intent.agent)
310
- this.prepared.delete(intent.agent);
311
- const result = intent.candidate.dispose();
312
- if (result) {
313
- const cleanup = Promise.resolve(result);
314
- this.cleanups.add(cleanup);
315
- void cleanup.then(() => this.cleanups.delete(cleanup), error => { this.ctx.logger.error(error); this.cleanups.delete(cleanup); });
316
- }
317
- }
318
- }
319
- export function historyFailure(error) {
320
- if (error instanceof HistoryRefusal)
321
- return { code: error.code, storageEffects: error.storageEffects };
322
- if (error instanceof TypeError)
323
- return { code: "validation", storageEffects: "none" };
324
- const category = error && typeof error === "object" ? Reflect.get(error, "category") : undefined;
325
- const code = category === "initializing" ? "busy" : category === "stale" || category === "cancelled" || category === "unsupported-backend" || category === "authorization-required" ? category
326
- : error instanceof Error && error.name === "SessionAlreadyOwnedError" ? "busy" : error instanceof Error && error.name === "AbortError" ? "cancelled" : "initialization-failed";
327
- return { code, storageEffects: "none" };
328
- }
329
- //# sourceMappingURL=history-controller.js.map
@@ -1,4 +0,0 @@
1
- import type { DsmmGitWritePolicy, DsmmSettings } from "./settings.js";
2
- /** The DSMM Git guard for the candidate's effective mode, not a grant from other policy layers. */
3
- export declare function effectiveHistoryGitWriteGuard(settings: DsmmSettings, nativeFullAccess: boolean, deepworkActive: boolean): DsmmGitWritePolicy;
4
- //# sourceMappingURL=history-policy.d.ts.map
@@ -1,8 +0,0 @@
1
- /** The DSMM Git guard for the candidate's effective mode, not a grant from other policy layers. */
2
- export function effectiveHistoryGitWriteGuard(settings, nativeFullAccess, deepworkActive) {
3
- const inScope = settings.guards.scope === "always" || settings.guards.scope !== "off" && deepworkActive;
4
- if (!inScope || nativeFullAccess && settings.guards.gitWriteGuard !== "deny")
5
- return "off";
6
- return settings.guards.gitWriteGuard;
7
- }
8
- //# sourceMappingURL=history-policy.js.map
@@ -1,28 +0,0 @@
1
- import type { RemoteResult, TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
2
- import type { TypertContribution } from "@deepseek-ai/dsh-typert-registry";
3
- import type { HistoryChoices, HistoryConfirmRequest, HistoryContinuationResult, HistoryFailure, HistoryPreview, HistoryPreviewRequest, HistoryStatus } from "./history-types.js";
4
- import { parseHistoryFailure } from "./history-codec.js";
5
- export interface DsmmHistoryRemote {
6
- describe(sessionId: string): Promise<RemoteResult<HistoryStatus>>;
7
- choices(): Promise<RemoteResult<HistoryChoices>>;
8
- preview(sessionId: string, request: HistoryPreviewRequest): Promise<RemoteResult<HistoryPreview>>;
9
- confirm(sessionId: string, request: HistoryConfirmRequest): Promise<RemoteResult<HistoryContinuationResult>>;
10
- }
11
- declare module "@deepseek-ai/dsh-typert-protocol/types" {
12
- interface TypertRemoteMap {
13
- "dsmmHistory/describe": DsmmHistoryRemote["describe"];
14
- "dsmmHistory/choices": DsmmHistoryRemote["choices"];
15
- "dsmmHistory/preview": DsmmHistoryRemote["preview"];
16
- "dsmmHistory/confirm": DsmmHistoryRemote["confirm"];
17
- }
18
- interface TypertRemoteNamespaceMap {
19
- dsmmHistory: DsmmHistoryRemote;
20
- }
21
- interface RemoteErrorDetailsMap {
22
- "dsmm-history/refused": HistoryFailure;
23
- }
24
- }
25
- export declare const HISTORY_REMOTE: TypertRemoteContribution;
26
- export declare const HISTORY_HOST: TypertContribution;
27
- export { parseHistoryFailure };
28
- //# sourceMappingURL=history-remote.d.ts.map
@@ -1,17 +0,0 @@
1
- import { historyJson, historySessionId, parseHistoryChoices, parseHistoryConfirmRequest, parseHistoryFailure, parseHistoryPreview, parseHistoryPreviewRequest, parseHistoryResult, parseHistoryStatus } from "./history-codec.js";
2
- function codec(name, parse) {
3
- return { mode: "strict", typeSymbol: `@dsmm/dsmm#${name}`, create: () => ({ parse: value => parse(historyJson(value)) }) };
4
- }
5
- function descriptor(method, result, request, session = true) {
6
- return { id: `@dsmm/dsmm-history#dsmmHistory/${method}`, service: "dsmmHistory", namespace: "dsmmHistory", method, invocation: { kind: "direct" },
7
- parameters: [...session ? [{ name: "sessionId", wire: "sessionId", source: "json", codec: codec("HistorySessionId", historySessionId) }] : [], ...request ? [{ name: "request", wire: "request", source: "json", codec: request }] : []], result };
8
- }
9
- export const HISTORY_REMOTE = { package: "@dsmm/dsmm-history", descriptors: [
10
- descriptor("describe", codec("HistoryStatus", parseHistoryStatus)),
11
- descriptor("choices", codec("HistoryChoices", parseHistoryChoices), undefined, false),
12
- descriptor("preview", codec("HistoryPreview", parseHistoryPreview), codec("HistoryPreviewRequest", parseHistoryPreviewRequest)),
13
- descriptor("confirm", codec("HistoryContinuationResult", parseHistoryResult), codec("HistoryConfirmRequest", parseHistoryConfirmRequest)),
14
- ] };
15
- export const HISTORY_HOST = { package: HISTORY_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: HISTORY_REMOTE.descriptors };
16
- export { parseHistoryFailure };
17
- //# sourceMappingURL=history-remote.js.map
@@ -1,24 +0,0 @@
1
- import type { Context } from "@deepseek-ai/cordis";
2
- import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
3
- import { HistoryContinuations } from "./history-controller.js";
4
- import type { HistoryCandidates, HistoryNativeAdmission } from "./history-contract.js";
5
- import type { HistoryChoices, HistoryConfirmRequest, HistoryContinuationResult, HistoryPreview, HistoryPreviewRequest, HistoryStatus } from "./history-types.js";
6
- /** Native authenticated local-operator RPC; browser payloads carry no admission authority. */
7
- export declare class DsmmHistoryHost extends TypertRemoteService {
8
- private readonly history;
9
- private readonly lifetime;
10
- constructor(ctx: Context, history: HistoryContinuations);
11
- private operator;
12
- private invoke;
13
- describe(sessionId: string): Promise<HistoryStatus>;
14
- choices(): Promise<HistoryChoices>;
15
- preview(sessionId: string, input: HistoryPreviewRequest): Promise<HistoryPreview>;
16
- confirm(sessionId: string, input: HistoryConfirmRequest): Promise<HistoryContinuationResult>;
17
- }
18
- declare module "@deepseek-ai/cordis" {
19
- interface Context {
20
- dsmmHistory: DsmmHistoryHost;
21
- }
22
- }
23
- export declare function registerHistoryContinuationRpc(ctx: Context, candidates: HistoryCandidates, admission: HistoryNativeAdmission): DsmmHistoryHost;
24
- //# sourceMappingURL=history-rpc.d.ts.map
@@ -1,136 +0,0 @@
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 { getTraceable, symbols } from "@deepseek-ai/cordis";
36
- import { RemoteAccessService } from "@deepseek-ai/dsh-api-remote-access";
37
- import { SessionId } from "@deepseek-ai/dsh-session";
38
- import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
39
- import { assertLocalSettingsOperator } from "./profile-rpc.js";
40
- import { scopeLifetime } from "./lifetime.js";
41
- import { HistoryContinuations, HistoryRefusal, historyFailure } from "./history-controller.js";
42
- import { HISTORY_HOST } from "./history-remote.js";
43
- import { historySessionId, parseHistoryConfirmRequest, parseHistoryFailure, parseHistoryPreviewRequest } from "./history-codec.js";
44
- /** Native authenticated local-operator RPC; browser payloads carry no admission authority. */
45
- let DsmmHistoryHost = (() => {
46
- let _classSuper = TypertRemoteService;
47
- let _instanceExtraInitializers = [];
48
- let _describe_decorators;
49
- let _choices_decorators;
50
- let _preview_decorators;
51
- let _confirm_decorators;
52
- return class DsmmHistoryHost extends _classSuper {
53
- static {
54
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
55
- _describe_decorators = [Remote];
56
- _choices_decorators = [Remote];
57
- _preview_decorators = [Remote];
58
- _confirm_decorators = [Remote];
59
- __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);
60
- __esDecorate(this, null, _choices_decorators, { kind: "method", name: "choices", static: false, private: false, access: { has: obj => "choices" in obj, get: obj => obj.choices }, metadata: _metadata }, null, _instanceExtraInitializers);
61
- __esDecorate(this, null, _preview_decorators, { kind: "method", name: "preview", static: false, private: false, access: { has: obj => "preview" in obj, get: obj => obj.preview }, metadata: _metadata }, null, _instanceExtraInitializers);
62
- __esDecorate(this, null, _confirm_decorators, { kind: "method", name: "confirm", static: false, private: false, access: { has: obj => "confirm" in obj, get: obj => obj.confirm }, metadata: _metadata }, null, _instanceExtraInitializers);
63
- if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
64
- }
65
- history = __runInitializers(this, _instanceExtraInitializers);
66
- lifetime = new AbortController();
67
- constructor(ctx, history) {
68
- super(ctx, "dsmmHistory");
69
- this.history = history;
70
- scopeLifetime(ctx, "dsmm: close history RPC", () => this.lifetime.abort());
71
- }
72
- operator() {
73
- try {
74
- assertLocalSettingsOperator(this.ctx);
75
- }
76
- catch {
77
- throw new HistoryRefusal("not-owned");
78
- }
79
- const ctx = this.ctx, invocation = ctx.invocation;
80
- const connection = ctx.get("connection");
81
- const owner = Reflect.get(connection, symbols.original) ?? connection;
82
- const peer = invocation.peer;
83
- const signal = AbortSignal.any([invocation.signal, peer.signal, this.lifetime.signal]);
84
- const assertOwner = () => {
85
- this.lifetime.signal.throwIfAborted();
86
- peer.signal.throwIfAborted();
87
- const current = ctx.get("connection");
88
- if (!current || (Reflect.get(current, symbols.original) ?? current) !== owner || current.browserPeer !== peer
89
- || ctx.get("webServer")?.host !== "127.0.0.1" || ctx.get("settings")?.writable !== true)
90
- throw new HistoryRefusal("not-owned");
91
- };
92
- return { peer, connection: owner, peerSignal: peer.signal, signal, assertOwner,
93
- assertCurrent: () => { signal.throwIfAborted(); assertOwner(); },
94
- assertVisible: id => {
95
- assertOwner();
96
- const access = ctx.get("remoteAccess");
97
- if (!(access instanceof RemoteAccessService) || !access.allows({ kind: "session", id: SessionId(id) }))
98
- throw new HistoryRefusal("not-owned");
99
- } };
100
- }
101
- async invoke(operation) {
102
- try {
103
- return await operation(getTraceable(this.ctx, this.history), this.operator());
104
- }
105
- catch (error) {
106
- throw new RemoteError("dsmm-history/refused", "The Host refused history continuation.", parseHistoryFailure(historyFailure(error)));
107
- }
108
- }
109
- describe(sessionId) { return this.invoke((history, operator) => history.describe(historySessionId(sessionId), operator)); }
110
- choices() { return this.invoke((history, operator) => history.choices(operator)); }
111
- preview(sessionId, input) {
112
- return this.invoke((history, operator) => {
113
- const request = parseHistoryPreviewRequest(input);
114
- if (historySessionId(sessionId) !== request.sessionId)
115
- throw new HistoryRefusal("validation");
116
- return history.preview(request, operator);
117
- });
118
- }
119
- confirm(sessionId, input) {
120
- return this.invoke((history, operator) => {
121
- const request = parseHistoryConfirmRequest(input);
122
- if (historySessionId(sessionId) !== request.sessionId)
123
- throw new HistoryRefusal("validation");
124
- return history.confirm(request, operator);
125
- });
126
- }
127
- };
128
- })();
129
- export { DsmmHistoryHost };
130
- export function registerHistoryContinuationRpc(ctx, candidates, admission) {
131
- const history = new HistoryContinuations(ctx, candidates, admission);
132
- const host = new DsmmHistoryHost(ctx, history);
133
- ctx.typert.register(HISTORY_HOST);
134
- return host;
135
- }
136
- //# sourceMappingURL=history-rpc.js.map
@@ -1,15 +0,0 @@
1
- import type { Context } from "@deepseek-ai/cordis";
2
- /** Supply these native plugin configs before their constructors or configured restores run. */
3
- export declare const DSMM_HISTORY_HOST_CONFIG: Readonly<{
4
- agentLoop: Readonly<{
5
- activationAdmissionRequired: true;
6
- }>;
7
- sessionController: Readonly<{
8
- activateOnFollow: false;
9
- }>;
10
- }>;
11
- /** Mount independently from the Core so failed configuration cannot reopen the Client gate. */
12
- export declare function apply(ctx: Context): void;
13
- /** A present patched loop becomes fail-closed before asynchronous DSMM configuration loading. */
14
- export declare function requireHistoryAdmission(ctx: Context): void;
15
- //# sourceMappingURL=history-support.d.ts.map
@@ -1,21 +0,0 @@
1
- /** Supply these native plugin configs before their constructors or configured restores run. */
2
- export const DSMM_HISTORY_HOST_CONFIG = Object.freeze({
3
- agentLoop: Object.freeze({ activationAdmissionRequired: true }),
4
- sessionController: Object.freeze({ activateOnFollow: false }),
5
- });
6
- /** Mount independently from the Core so failed configuration cannot reopen the Client gate. */
7
- export function apply(ctx) {
8
- requireHistoryAdmission(ctx);
9
- ctx.events.on("webserver/index-inject", (rows) => {
10
- rows.push({ kind: "global", name: "__DSMM_HISTORY_REQUIRED__", value: true });
11
- });
12
- }
13
- /** A present patched loop becomes fail-closed before asynchronous DSMM configuration loading. */
14
- export function requireHistoryAdmission(ctx) {
15
- ctx.inject(["agentLoop"], scope => {
16
- const loop = scope.agentLoop;
17
- if (typeof loop.requireActivationAdmission === "function")
18
- loop.requireActivationAdmission();
19
- });
20
- }
21
- //# sourceMappingURL=history-support.js.map