@dsmm/dsmm 0.3.2 → 0.3.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.
Files changed (190) hide show
  1. package/README.md +2 -2
  2. package/agent-presets/dsmm-builder/agent.cordis.yml +1 -1
  3. package/agent-presets/dsmm-clarifier/agent.cordis.yml +1 -1
  4. package/agent-presets/dsmm-code-search/agent.cordis.yml +1 -1
  5. package/agent-presets/dsmm-coding/agent.cordis.yml +3 -2
  6. package/agent-presets/dsmm-complex/agent.cordis.yml +2 -1
  7. package/agent-presets/dsmm-creative/agent.cordis.yml +1 -1
  8. package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +1 -1
  9. package/agent-presets/dsmm-deep/agent.cordis.yml +2 -1
  10. package/agent-presets/dsmm-doc-search/agent.cordis.yml +1 -1
  11. package/agent-presets/dsmm-documenting/agent.cordis.yml +1 -1
  12. package/agent-presets/dsmm-frontend/agent.cordis.yml +4 -2
  13. package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +1 -1
  14. package/agent-presets/dsmm-media-reader/agent.cordis.yml +1 -1
  15. package/agent-presets/dsmm-normal-task/agent.cordis.yml +3 -2
  16. package/agent-presets/dsmm-oracle/agent.cordis.yml +1 -1
  17. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +1 -1
  18. package/agent-presets/dsmm-orchestrator/agent.cordis.yml +11 -1
  19. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +1 -1
  20. package/agent-presets/dsmm-planner/agent.cordis.yml +1 -1
  21. package/agent-presets/dsmm-quick/agent.cordis.yml +2 -1
  22. package/agent-presets/dsmm-research/agent.cordis.yml +1 -1
  23. package/agent-presets/dsmm-reviewer/agent.cordis.yml +1 -1
  24. package/cordis.patch.yml +0 -9
  25. package/docs/agent-presets.md +5 -5
  26. package/docs/compatibility.md +2 -6
  27. package/docs/migration-from-ocmm.md +1 -1
  28. package/docs/native-permissions.md +11 -3
  29. package/docs/roadmap.md +31 -11
  30. package/docs/runtime-recovery.md +30 -2
  31. package/docs/settings-status.md +7 -5
  32. package/docs/skill-sync.md +13 -14
  33. package/lib/client/ChildrenPanel.d.ts +1 -4
  34. package/lib/client/ChildrenPanel.js +3 -3
  35. package/lib/client/DeploymentFields.js +12 -1
  36. package/lib/client/DeploymentPage.d.ts +1 -3
  37. package/lib/client/DeploymentPage.js +30 -18
  38. package/lib/client/NativeCommandEntries.js +47 -37
  39. package/lib/client/PermissionRuleEntries.d.ts +17 -0
  40. package/lib/client/PermissionRuleEntries.js +70 -0
  41. package/lib/client/PermissionsPanel.d.ts +1 -3
  42. package/lib/client/PermissionsPanel.js +5 -4
  43. package/lib/client/children-locales.d.ts +4 -4
  44. package/lib/client/controller.js +4 -1
  45. package/lib/client/deployment-locales.d.ts +2 -2
  46. package/lib/client/deployment-locales.js +8 -9
  47. package/lib/client/deployment-modules.d.ts +5 -3
  48. package/lib/client/deployment-modules.js +4 -4
  49. package/lib/client/deployment-workspace.d.ts +4 -0
  50. package/lib/client/deployment-workspace.js +37 -11
  51. package/lib/client/index.js +2 -7
  52. package/lib/client/locales.js +131 -119
  53. package/lib/client/permission-controller.d.ts +13 -0
  54. package/lib/client/permission-controller.js +50 -23
  55. package/lib/client/permission-locales.d.ts +28 -30
  56. package/lib/client/permission-locales.js +38 -38
  57. package/lib/client/styles.d.ts +1 -1
  58. package/lib/client/styles.js +8 -8
  59. package/lib/client.js +2272 -3773
  60. package/lib/core-permission-authority.js +28 -16
  61. package/lib/index.d.ts +0 -2
  62. package/lib/index.js +11 -31
  63. package/lib/native-admission.d.ts +3 -3
  64. package/lib/native-admission.js +67 -66
  65. package/lib/permission-controller.js +1 -1
  66. package/lib/permission-fs-search.js +1 -2
  67. package/lib/permission-fs.js +1 -2
  68. package/lib/permission-native-command.js +6 -4
  69. package/lib/permission-settings.d.ts +21 -7
  70. package/lib/permission-settings.js +21 -9
  71. package/lib/permission-web.js +1 -2
  72. package/lib/preset-materializer.js +3 -3
  73. package/lib/preset-registry.d.ts +20 -2
  74. package/lib/preset-registry.js +46 -17
  75. package/lib/profile-diagnostics.js +1 -1
  76. package/lib/profile-remote.js +1 -3
  77. package/lib/role-identity.d.ts +1 -1
  78. package/lib/role-identity.js +16 -4
  79. package/lib/role-policy.d.ts +3 -0
  80. package/lib/role-policy.js +30 -6
  81. package/lib/role-subagents.js +6 -4
  82. package/lib/roles.d.ts +2 -0
  83. package/lib/roles.js +2 -0
  84. package/lib/runtime-integration.js +4 -4
  85. package/lib/settings.d.ts +1 -3
  86. package/lib/settings.js +8 -10
  87. package/lib/state.d.ts +4 -1
  88. package/lib/state.js +37 -6
  89. package/package.json +1 -5
  90. package/prompts/deepwork.md +13 -1
  91. package/prompts/source/agents/orchestrator.md +10 -0
  92. package/prompts/source/category/coding.md +2 -1
  93. package/prompts/source/category/complex.md +1 -0
  94. package/prompts/source/category/deep.md +1 -0
  95. package/prompts/source/category/frontend.md +3 -1
  96. package/prompts/source/category/normal-task.md +2 -1
  97. package/prompts/source/category/quick.md +1 -0
  98. package/prompts/source/deepwork/claude-opus-5.md +2 -0
  99. package/prompts/source/deepwork/default.md +12 -0
  100. package/prompts/source/deepwork/gemini.md +6 -1
  101. package/prompts/source/deepwork/glm.md +5 -1
  102. package/prompts/source/deepwork/gpt.md +22 -2
  103. package/prompts/source/deepwork/kimi-k27.md +2 -0
  104. package/prompts/source/deepwork/planner.md +3 -1
  105. package/prompts/source/deepwork/swe-2.md +2 -0
  106. package/prompts/source/manifest.json +3 -68
  107. package/prompts/source/shared/dsh-host-contract.md +1 -1
  108. package/skills/ast-grep/SKILL.md +1 -1
  109. package/skills/brainstorming/SKILL.md +1 -1
  110. package/skills/coding-agent-sessions/SKILL.md +1 -1
  111. package/skills/debugging/SKILL.md +1 -1
  112. package/skills/dispatching-parallel-agents/SKILL.md +1 -1
  113. package/skills/frontend/SKILL.md +1 -1
  114. package/skills/git-master/SKILL.md +1 -1
  115. package/skills/init-deep/SKILL.md +1 -1
  116. package/skills/receiving-code-review/SKILL.md +1 -1
  117. package/skills/remove-ai-slops/SKILL.md +1 -1
  118. package/skills/requesting-code-review/SKILL.md +1 -1
  119. package/skills/subagent-driven-development/SKILL.md +1 -1
  120. package/skills/using-git-worktrees/SKILL.md +1 -1
  121. package/skills/writing-plans/SKILL.md +1 -1
  122. package/lib/client/ChildPermissions.d.ts +0 -43
  123. package/lib/client/ChildPermissions.js +0 -100
  124. package/lib/client/HistoryContinuation.d.ts +0 -7
  125. package/lib/client/HistoryContinuation.js +0 -22
  126. package/lib/client/PermissionPanelEntry.d.ts +0 -8
  127. package/lib/client/PermissionPanelEntry.js +0 -11
  128. package/lib/client/TemporaryPermissions.d.ts +0 -21
  129. package/lib/client/TemporaryPermissions.js +0 -94
  130. package/lib/client/history-controller.d.ts +0 -29
  131. package/lib/client/history-controller.js +0 -111
  132. package/lib/client/history-entry.d.ts +0 -11
  133. package/lib/client/history-entry.js +0 -106
  134. package/lib/client/history-locales.d.ts +0 -95
  135. package/lib/client/history-locales.js +0 -41
  136. package/lib/client/temporary-permission-client.d.ts +0 -20
  137. package/lib/client/temporary-permission-client.js +0 -52
  138. package/lib/client/temporary-permission-entry.d.ts +0 -6
  139. package/lib/client/temporary-permission-entry.js +0 -56
  140. package/lib/history-candidates.d.ts +0 -30
  141. package/lib/history-candidates.js +0 -176
  142. package/lib/history-codec.d.ts +0 -11
  143. package/lib/history-codec.js +0 -102
  144. package/lib/history-contract.d.ts +0 -44
  145. package/lib/history-contract.js +0 -2
  146. package/lib/history-controller.d.ts +0 -42
  147. package/lib/history-controller.js +0 -329
  148. package/lib/history-policy.d.ts +0 -4
  149. package/lib/history-policy.js +0 -8
  150. package/lib/history-remote.d.ts +0 -28
  151. package/lib/history-remote.js +0 -17
  152. package/lib/history-rpc.d.ts +0 -24
  153. package/lib/history-rpc.js +0 -136
  154. package/lib/history-support.d.ts +0 -15
  155. package/lib/history-support.js +0 -21
  156. package/lib/history-types.d.ts +0 -67
  157. package/lib/history-types.js +0 -2
  158. package/lib/permission-child-control.d.ts +0 -36
  159. package/lib/permission-child-control.js +0 -164
  160. package/lib/permission-exec-argv.d.ts +0 -32
  161. package/lib/permission-exec-argv.js +0 -171
  162. package/lib/permission-temporary-files.d.ts +0 -19
  163. package/lib/permission-temporary-files.js +0 -248
  164. package/lib/permission-temporary-grants.d.ts +0 -106
  165. package/lib/permission-temporary-grants.js +0 -198
  166. package/lib/permission-temporary-install.d.ts +0 -25
  167. package/lib/permission-temporary-install.js +0 -86
  168. package/lib/permission-temporary-remote.d.ts +0 -19
  169. package/lib/permission-temporary-remote.js +0 -75
  170. package/lib/permission-temporary-rpc.d.ts +0 -37
  171. package/lib/permission-temporary-rpc.js +0 -154
  172. package/lib/permission-temporary-types.d.ts +0 -47
  173. package/lib/permission-temporary-types.js +0 -2
  174. package/lib/permission-temporary-web.d.ts +0 -11
  175. package/lib/permission-temporary-web.js +0 -154
  176. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +0 -13291
  177. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +0 -9133
  178. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +0 -156
  179. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +0 -3546
  180. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +0 -431
  181. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +0 -119
  182. package/patches/dsh-approval-settlement/README.md +0 -41
  183. package/patches/dsh-approval-settlement/metadata.json +0 -10
  184. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +0 -383
  185. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +0 -55
  186. package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +0 -16673
  187. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +0 -29
  188. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +0 -196
  189. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +0 -35
  190. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +0 -40
@@ -1,102 +0,0 @@
1
- import { isNativeSessionId, isProfileId } from "./profile-remote.js";
2
- const codes = ["validation", "not-owned", "not-found", "unsupported-host", "unsupported-backend", "unavailable", "busy", "stale", "cancelled", "authorization-required", "child-owner-required", "format-unavailable", "initialization-failed"];
3
- function invalid() { throw new TypeError("Invalid history continuation request or response"); }
4
- function object(input, required, optional = []) {
5
- if (!input || typeof input !== "object" || Array.isArray(input)
6
- || ![Object.prototype, null].includes(Object.getPrototypeOf(input)) || Object.getOwnPropertySymbols(input).length
7
- || Object.values(Object.getOwnPropertyDescriptors(input)).some(row => !Object.hasOwn(row, "value") || !row.enumerable))
8
- invalid();
9
- const row = input;
10
- if (required.some(key => !Object.hasOwn(row, key)) || Object.keys(row).some(key => !required.includes(key) && !optional.includes(key)))
11
- invalid();
12
- return row;
13
- }
14
- function text(input, maximum = 4096) { if (typeof input !== "string" || input.length > maximum)
15
- invalid(); return input; }
16
- function bool(input) { if (typeof input !== "boolean")
17
- invalid(); return input; }
18
- function list(input, parse) { if (!Array.isArray(input))
19
- invalid(); return input.map(value => parse(value)); }
20
- function code(input) { if (!codes.includes(input))
21
- invalid(); return input; }
22
- export function historySessionId(input) { if (!isNativeSessionId(input))
23
- invalid(); return input; }
24
- function intentId(input) { const id = text(input, 36); if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u.test(id))
25
- invalid(); return id; }
26
- function profileId(input) { if (input === null)
27
- return null; if (!isProfileId(input))
28
- invalid(); return input; }
29
- function presetId(input) { return historySessionId(input); }
30
- function choice(input) { const row = object(input, ["id", "label"]); return { id: text(row.id, 256), label: text(row.label, 120) }; }
31
- export function historyJson(input, depth = 0, active = new Set()) {
32
- if (depth > 32)
33
- invalid();
34
- if (input === null || typeof input === "boolean" || typeof input === "string")
35
- return input;
36
- if (typeof input === "number") {
37
- if (!Number.isFinite(input))
38
- invalid();
39
- return input;
40
- }
41
- if (!input || typeof input !== "object")
42
- invalid();
43
- if (active.has(input))
44
- invalid();
45
- active.add(input);
46
- try {
47
- if (Array.isArray(input)) {
48
- if (Object.getOwnPropertySymbols(input).length || Object.entries(Object.getOwnPropertyDescriptors(input)).some(([key, property]) => key !== "length" && (!/^(0|[1-9][0-9]*)$/u.test(key) || !Object.hasOwn(property, "value") || !property.enumerable)))
49
- invalid();
50
- return input.map(value => historyJson(value, depth + 1, active));
51
- }
52
- const row = object(input, Object.keys(input));
53
- return Object.fromEntries(Object.entries(row).map(([key, value]) => [key, historyJson(value, depth + 1, active)]));
54
- }
55
- finally {
56
- active.delete(input);
57
- }
58
- }
59
- export function parseHistoryFailure(input) {
60
- const row = object(input, ["code", "storageEffects"]);
61
- if (row.storageEffects !== "none" && row.storageEffects !== "may-have-committed")
62
- invalid();
63
- return { code: code(row.code), storageEffects: row.storageEffects };
64
- }
65
- export function parseHistoryStatus(input) {
66
- const row = object(input, ["sessionId", "readable", "execution", "compatibleHost"], ["reason"]);
67
- if (row.readable !== "readable" && row.readable !== "unavailable")
68
- invalid();
69
- if (!["authorization-required", "activating", "active", "unavailable"].includes(String(row.execution)))
70
- invalid();
71
- return { sessionId: historySessionId(row.sessionId), readable: row.readable, execution: row.execution, compatibleHost: bool(row.compatibleHost), ...(row.reason === undefined ? {} : { reason: code(row.reason) }) };
72
- }
73
- export function parseHistoryChoices(input) {
74
- const row = object(input, ["presets", "profiles"]);
75
- return { presets: list(row.presets, value => { const result = choice(value); presetId(result.id); return result; }), profiles: list(row.profiles, value => { const result = choice(value); profileId(result.id); return result; }) };
76
- }
77
- export function parseHistoryPreviewRequest(input) {
78
- const row = object(input, ["sessionId", "preset", "profileId"]);
79
- return { sessionId: historySessionId(row.sessionId), preset: presetId(row.preset), profileId: profileId(row.profileId) };
80
- }
81
- export function parseHistoryConfirmRequest(input) {
82
- const row = object(input, ["sessionId", "intentId", "processPending", "acceptMigration"]);
83
- return { sessionId: historySessionId(row.sessionId), intentId: intentId(row.intentId), processPending: bool(row.processPending), acceptMigration: bool(row.acceptMigration) };
84
- }
85
- function candidate(input) {
86
- const row = object(input, ["preset", "profile", "model", "roles", "restrictions", "differences"]);
87
- const model = object(row.model, ["provider", "model"], ["reasoningEffort"]);
88
- return { preset: choice(row.preset), profile: row.profile === null ? null : choice(row.profile),
89
- model: { provider: text(model.provider, 256), model: text(model.model, 256), ...(model.reasoningEffort === undefined ? {} : { reasoningEffort: text(model.reasoningEffort, 128) }) },
90
- roles: list(row.roles, choice), restrictions: list(row.restrictions, value => text(value)), differences: list(row.differences, value => text(value)) };
91
- }
92
- export function parseHistoryPreview(input) {
93
- const row = object(input, ["sessionId", "intentId", "cwd", "candidate", "migrationRequired", "pending"]), pending = object(row.pending, ["nextTurn", "nextStep"]);
94
- return { sessionId: historySessionId(row.sessionId), intentId: intentId(row.intentId), cwd: text(row.cwd), candidate: candidate(row.candidate), migrationRequired: bool(row.migrationRequired), pending: { nextTurn: list(pending.nextTurn, historyJson), nextStep: list(pending.nextStep, historyJson) } };
95
- }
96
- export function parseHistoryResult(input) {
97
- const row = object(input, ["sessionId", "execution"]);
98
- if (row.execution !== "active")
99
- invalid();
100
- return { sessionId: historySessionId(row.sessionId), execution: "active" };
101
- }
102
- //# sourceMappingURL=history-codec.js.map
@@ -1,44 +0,0 @@
1
- import type { Agent, ModelSelection } from "@deepseek-ai/dsh-agent";
2
- import type { SessionInspection } from "@deepseek-ai/dsh-session-persistence";
3
- import type { DsmmProfileAdmission } from "./settings.js";
4
- import type { HistoryCandidateView, HistoryChoices, HistoryPreviewRequest } from "./history-types.js";
5
- /** A current profile/preset/policy preparation, never reconstructed from old epochs or approvals. */
6
- export interface HistoryCandidate {
7
- readonly admission: DsmmProfileAdmission;
8
- readonly view: HistoryCandidateView;
9
- readonly model: ModelSelection;
10
- readonly signal: AbortSignal;
11
- /** Re-read current configuration and availability without touching the historical log. */
12
- revalidate(signal: AbortSignal): Promise<void>;
13
- /** Synchronous revision/owner/policy fence, including across native created notifications. */
14
- assertCurrent(): undefined;
15
- /** Install current native restrictions in the unpublished Agent; registrations belong to that Agent. */
16
- install(agent: Agent, signal: AbortSignal): Promise<void>;
17
- /** Release preparation resources, not successfully installed Agent policy. */
18
- dispose(): void | Promise<void>;
19
- }
20
- export interface HistoryCandidates {
21
- readonly signal: AbortSignal;
22
- checkCompatibility?(): Promise<void>;
23
- choices(signal: AbortSignal): Promise<HistoryChoices>;
24
- prepare(request: HistoryPreviewRequest, inspection: SessionInspection, signal: AbortSignal): Promise<HistoryCandidate>;
25
- }
26
- /** Existing NativeAdmission surface; the bridge adds no second admission owner. */
27
- export interface HistoryNativeAdmission {
28
- readonly lifetime: AbortController;
29
- readonly isReady: boolean;
30
- get(agent: Agent): DsmmProfileAdmission | undefined;
31
- assert(agent: Agent): DsmmProfileAdmission;
32
- }
33
- /** Host-created identity. None of these fields is accepted from the wire. */
34
- export interface HistoryOperator {
35
- readonly peer: object;
36
- readonly connection: object;
37
- readonly peerSignal: AbortSignal;
38
- readonly signal: AbortSignal;
39
- assertCurrent(): void;
40
- /** Does not retain a completed preview RPC's cancellation signal. */
41
- assertOwner(): void;
42
- assertVisible(sessionId: string): void;
43
- }
44
- //# sourceMappingURL=history-contract.d.ts.map
@@ -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