@dsmm/dsmm 0.2.0 → 0.2.2

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 (291) hide show
  1. package/README.md +38 -66
  2. package/agent-presets/dsmm-builder/agent.cordis.yml +10 -2015
  3. package/agent-presets/dsmm-clarifier/agent.cordis.yml +24 -343
  4. package/agent-presets/dsmm-code-search/agent.cordis.yml +19 -6
  5. package/agent-presets/dsmm-coding/agent.cordis.yml +19 -438
  6. package/agent-presets/dsmm-complex/agent.cordis.yml +23 -1009
  7. package/agent-presets/dsmm-creative/agent.cordis.yml +25 -442
  8. package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +29 -1013
  9. package/agent-presets/dsmm-deep/agent.cordis.yml +24 -1008
  10. package/agent-presets/dsmm-doc-search/agent.cordis.yml +19 -6
  11. package/agent-presets/dsmm-documenting/agent.cordis.yml +26 -439
  12. package/agent-presets/dsmm-frontend/agent.cordis.yml +21 -440
  13. package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +22 -441
  14. package/agent-presets/dsmm-media-reader/agent.cordis.yml +19 -6
  15. package/agent-presets/dsmm-normal-task/agent.cordis.yml +19 -438
  16. package/agent-presets/dsmm-oracle/agent.cordis.yml +25 -340
  17. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +25 -340
  18. package/agent-presets/dsmm-orchestrator/agent.cordis.yml +29 -2025
  19. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +24 -341
  20. package/agent-presets/dsmm-planner/agent.cordis.yml +14 -344
  21. package/agent-presets/dsmm-quick/agent.cordis.yml +19 -6
  22. package/agent-presets/dsmm-research/agent.cordis.yml +23 -8
  23. package/agent-presets/dsmm-reviewer/agent.cordis.yml +25 -340
  24. package/docs/agent-presets.md +36 -52
  25. package/docs/compatibility.md +50 -108
  26. package/docs/deferred-native-approval-risk.md +19 -0
  27. package/docs/design.md +2 -2
  28. package/docs/lsp.md +11 -21
  29. package/docs/migration-from-ocmm.md +2 -2
  30. package/docs/model-routing.md +84 -59
  31. package/docs/native-permissions.md +35 -0
  32. package/docs/profiles.md +40 -87
  33. package/docs/releasing.md +83 -2
  34. package/docs/roadmap.md +71 -17
  35. package/docs/settings-status.md +34 -169
  36. package/docs/skill-sync.md +52 -15
  37. package/lib/child-admission-contract.d.ts +37 -0
  38. package/lib/child-admission-contract.js +2 -0
  39. package/lib/child-admission.d.ts +42 -0
  40. package/lib/child-admission.js +162 -0
  41. package/lib/child-capture.d.ts +81 -0
  42. package/lib/child-capture.js +203 -0
  43. package/lib/child-evidence.d.ts +17 -0
  44. package/lib/child-evidence.js +43 -0
  45. package/lib/client/ChildrenPanel.d.ts +43 -0
  46. package/lib/client/ChildrenPanel.js +82 -0
  47. package/lib/client/DeploymentPage.js +15 -8
  48. package/lib/client/EditableChoice.d.ts +17 -0
  49. package/lib/client/EditableChoice.js +49 -0
  50. package/lib/client/PermissionsPanel.d.ts +14 -0
  51. package/lib/client/PermissionsPanel.js +46 -0
  52. package/lib/client/ProfilesSection.js +30 -15
  53. package/lib/client/RoleAvailability.d.ts +7 -0
  54. package/lib/client/RoleAvailability.js +19 -0
  55. package/lib/client/SessionProfiles.js +27 -9
  56. package/lib/client/StructuredEditor.js +15 -7
  57. package/lib/client/children-controller.d.ts +98 -0
  58. package/lib/client/children-controller.js +296 -0
  59. package/lib/client/children-locales.d.ts +367 -0
  60. package/lib/client/children-locales.js +69 -0
  61. package/lib/client/controller.d.ts +6 -1
  62. package/lib/client/controller.js +14 -8
  63. package/lib/client/deployment-data.d.ts +2 -1
  64. package/lib/client/deployment-data.js +34 -5
  65. package/lib/client/deployment-locales.d.ts +4 -0
  66. package/lib/client/deployment-locales.js +11 -2
  67. package/lib/client/diagnostics.d.ts +14 -0
  68. package/lib/client/diagnostics.js +53 -0
  69. package/lib/client/index.d.ts +4 -0
  70. package/lib/client/index.js +96 -2
  71. package/lib/client/locales.d.ts +54 -0
  72. package/lib/client/locales.js +34 -16
  73. package/lib/client/permission-client.d.ts +16 -0
  74. package/lib/client/permission-client.js +38 -0
  75. package/lib/client/permission-controller.d.ts +62 -0
  76. package/lib/client/permission-controller.js +149 -0
  77. package/lib/client/permission-locales.d.ts +114 -0
  78. package/lib/client/permission-locales.js +75 -0
  79. package/lib/client/session-labels.js +4 -4
  80. package/lib/client/structured.js +19 -5
  81. package/lib/client/styles.d.ts +1 -1
  82. package/lib/client/styles.js +20 -0
  83. package/lib/client.js +5780 -1679
  84. package/lib/core-permission-authority.d.ts +18 -0
  85. package/lib/core-permission-authority.js +255 -0
  86. package/lib/core-permissions.d.ts +8 -0
  87. package/lib/core-permissions.js +33 -0
  88. package/lib/delivery-authority.d.ts +68 -0
  89. package/lib/delivery-authority.js +260 -0
  90. package/lib/deployment-config.d.ts +23 -0
  91. package/lib/deployment-config.js +61 -40
  92. package/lib/deployment-permission-rules.d.ts +55 -0
  93. package/lib/deployment-permission-rules.js +306 -0
  94. package/lib/dsh-types.d.ts +10 -4
  95. package/lib/guards.d.ts +1 -1
  96. package/lib/guards.js +29 -8
  97. package/lib/host-llm-startup.d.ts +41 -0
  98. package/lib/host-llm-startup.js +65 -0
  99. package/lib/host-llm.d.ts +92 -0
  100. package/lib/host-llm.js +325 -0
  101. package/lib/index.d.ts +15 -4
  102. package/lib/index.js +300 -47
  103. package/lib/legacy-child-policy.d.ts +51 -0
  104. package/lib/legacy-child-policy.js +123 -0
  105. package/lib/legacy-read-composition.d.ts +20 -0
  106. package/lib/legacy-read-composition.js +144 -0
  107. package/lib/legacy-read-contracts.d.ts +157 -0
  108. package/lib/legacy-read-contracts.js +39 -0
  109. package/lib/legacy-read-host.d.ts +19 -0
  110. package/lib/legacy-read-host.js +67 -0
  111. package/lib/legacy-read-integration.d.ts +121 -0
  112. package/lib/legacy-read-integration.js +522 -0
  113. package/lib/legacy-read-proxy.d.ts +26 -0
  114. package/lib/legacy-read-proxy.js +237 -0
  115. package/lib/live-pi-ai-owner.d.ts +18 -0
  116. package/lib/live-pi-ai-owner.js +144 -0
  117. package/lib/llm-runtime.d.ts +11 -0
  118. package/lib/llm-runtime.js +21 -0
  119. package/lib/managed-settings.d.ts +5 -0
  120. package/lib/managed-settings.js +14 -0
  121. package/lib/model-parameter-policy.d.ts +11 -0
  122. package/lib/model-parameter-policy.js +27 -0
  123. package/lib/model-routing.js +28 -17
  124. package/lib/modules.d.ts +13 -5
  125. package/lib/modules.js +17 -1
  126. package/lib/native-child-evidence.d.ts +42 -0
  127. package/lib/native-child-evidence.js +133 -0
  128. package/lib/native-pi-ai-wire.d.ts +37 -0
  129. package/lib/native-pi-ai-wire.js +261 -0
  130. package/lib/native-scope.js +1 -1
  131. package/lib/permission-bash.d.ts +6 -0
  132. package/lib/permission-bash.js +7 -0
  133. package/lib/permission-control.d.ts +73 -0
  134. package/lib/permission-control.js +205 -0
  135. package/lib/permission-controller.d.ts +68 -0
  136. package/lib/permission-controller.js +317 -0
  137. package/lib/permission-errors.d.ts +7 -0
  138. package/lib/permission-errors.js +21 -0
  139. package/lib/permission-fs-search.d.ts +5 -0
  140. package/lib/permission-fs-search.js +7 -0
  141. package/lib/permission-fs.d.ts +5 -0
  142. package/lib/permission-fs.js +7 -0
  143. package/lib/permission-native-access.d.ts +11 -0
  144. package/lib/permission-native-access.js +6 -0
  145. package/lib/permission-native-command.d.ts +10 -0
  146. package/lib/permission-native-command.js +93 -0
  147. package/lib/permission-native-rules.d.ts +75 -0
  148. package/lib/permission-native-rules.js +278 -0
  149. package/lib/permission-pwsh.d.ts +6 -0
  150. package/lib/permission-pwsh.js +7 -0
  151. package/lib/permission-remote.d.ts +26 -0
  152. package/lib/permission-remote.js +53 -0
  153. package/lib/permission-rpc.d.ts +29 -0
  154. package/lib/permission-rpc.js +152 -0
  155. package/lib/permission-rules.d.ts +115 -0
  156. package/lib/permission-rules.js +256 -0
  157. package/lib/permission-settings.d.ts +45 -0
  158. package/lib/permission-settings.js +48 -0
  159. package/lib/permission-shell.d.ts +38 -0
  160. package/lib/permission-shell.js +150 -0
  161. package/lib/permission-web.d.ts +5 -0
  162. package/lib/permission-web.js +7 -0
  163. package/lib/preset-registry.js +36 -25
  164. package/lib/profile-diagnostics.d.ts +45 -0
  165. package/lib/profile-diagnostics.js +148 -0
  166. package/lib/profile-locale.d.ts +3 -0
  167. package/lib/profile-locale.js +2 -0
  168. package/lib/profile-remote.d.ts +8 -0
  169. package/lib/profile-remote.js +163 -39
  170. package/lib/profile-rpc.d.ts +4 -3
  171. package/lib/profile-rpc.js +14 -12
  172. package/lib/profile-runtime.d.ts +40 -1
  173. package/lib/profile-runtime.js +368 -93
  174. package/lib/profile-store.d.ts +11 -0
  175. package/lib/profile-store.js +143 -11
  176. package/lib/profile-types.d.ts +70 -1
  177. package/lib/profile-types.js +1 -0
  178. package/lib/profiles.d.ts +16 -2
  179. package/lib/profiles.js +156 -79
  180. package/lib/prompt-content.js +1 -1
  181. package/lib/prompts.d.ts +37 -2
  182. package/lib/prompts.js +111 -9
  183. package/lib/recovery-policy.js +20 -7
  184. package/lib/role-control-remote.d.ts +38 -0
  185. package/lib/role-control-remote.js +211 -0
  186. package/lib/role-control-rpc.d.ts +51 -0
  187. package/lib/role-control-rpc.js +377 -0
  188. package/lib/role-control-types.d.ts +92 -0
  189. package/lib/role-control-types.js +8 -0
  190. package/lib/role-invocation.d.ts +47 -0
  191. package/lib/role-invocation.js +135 -0
  192. package/lib/role-llm-runtime.d.ts +17 -0
  193. package/lib/role-llm-runtime.js +62 -0
  194. package/lib/role-llm.d.ts +31 -0
  195. package/lib/role-llm.js +66 -0
  196. package/lib/role-policy.d.ts +49 -8
  197. package/lib/role-policy.js +437 -60
  198. package/lib/role-providers.d.ts +1 -1
  199. package/lib/role-providers.js +30 -35
  200. package/lib/role-routing.d.ts +11 -2
  201. package/lib/role-routing.js +42 -25
  202. package/lib/role-runs.d.ts +135 -0
  203. package/lib/role-runs.js +304 -0
  204. package/lib/role-subagents.d.ts +58 -3
  205. package/lib/role-subagents.js +169 -56
  206. package/lib/roles.d.ts +5 -6
  207. package/lib/roles.js +10 -39
  208. package/lib/route-json.d.ts +19 -0
  209. package/lib/route-json.js +129 -0
  210. package/lib/routing-policy.d.ts +2 -0
  211. package/lib/routing-policy.js +12 -2
  212. package/lib/runtime-integration.d.ts +112 -0
  213. package/lib/runtime-integration.js +784 -0
  214. package/lib/runtime-recovery.js +18 -8
  215. package/lib/settings.d.ts +47 -13
  216. package/lib/settings.js +217 -82
  217. package/lib/skills.js +2 -2
  218. package/lib/status.d.ts +10 -1
  219. package/lib/status.js +11 -8
  220. package/lib/subagent-runtime.d.ts +45 -0
  221. package/lib/subagent-runtime.js +131 -0
  222. package/package.json +106 -56
  223. package/patches/subagent-runtime.yml +15 -0
  224. package/prompts/deepseek-flash.md +1 -1
  225. package/prompts/deepseek-v4-pro.md +2 -2
  226. package/prompts/deepwork.md +27 -18
  227. package/prompts/source/agents/clarifier.md +5 -3
  228. package/prompts/source/agents/orchestrator.md +18 -9
  229. package/prompts/source/agents/plan-critic.md +5 -1
  230. package/prompts/source/agents/planner.md +4 -2
  231. package/prompts/source/agents/reviewer.md +6 -0
  232. package/prompts/source/category/complex.md +4 -4
  233. package/prompts/source/category/creative.md +6 -4
  234. package/prompts/source/category/cross-cutting.md +10 -8
  235. package/prompts/source/category/deep.md +5 -3
  236. package/prompts/source/category/documenting.md +7 -1
  237. package/prompts/source/category/frontend.md +2 -2
  238. package/prompts/source/category/hard-reasoning.md +3 -3
  239. package/prompts/source/category/research.md +4 -2
  240. package/prompts/source/deepwork/claude-opus-5.md +2 -2
  241. package/prompts/source/deepwork/codex.md +1 -1
  242. package/prompts/source/deepwork/default.md +22 -15
  243. package/prompts/source/deepwork/gemini.md +23 -16
  244. package/prompts/source/deepwork/glm.md +21 -14
  245. package/prompts/source/deepwork/gpt.md +12 -6
  246. package/prompts/source/deepwork/planner.md +8 -5
  247. package/prompts/source/manifest.json +178 -63
  248. package/prompts/source/shared/dsh-host-contract.md +5 -3
  249. package/prompts/source/shared/locale.md +2 -2
  250. package/prompts/source/terminal/orchestrator.md +1 -1
  251. package/scripts/cold-profile-composition.mjs +329 -0
  252. package/scripts/cold-profile-sources.mjs +238 -0
  253. package/scripts/migrate-cold-profile.mjs +315 -0
  254. package/skills/ast-grep/SKILL.md +7 -4
  255. package/skills/brainstorming/SKILL.md +43 -22
  256. package/skills/coding-agent-sessions/SKILL.md +7 -4
  257. package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -46
  258. package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -130
  259. package/skills/debugging/SKILL.md +14 -9
  260. package/skills/debugging/references/methodology/00-setup.md +14 -62
  261. package/skills/debugging/references/methodology/02-investigate.md +4 -4
  262. package/skills/debugging/references/methodology/03-flaky-triage.md +3 -3
  263. package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +2 -14
  264. package/skills/debugging/references/methodology/06-fix.md +6 -6
  265. package/skills/debugging/references/methodology/08-qa.md +5 -5
  266. package/skills/debugging/references/methodology/09-cleanup.md +15 -153
  267. package/skills/debugging/references/methodology/partial-runtime-evidence.md +3 -16
  268. package/skills/debugging/references/runtimes/bundled-js-binary.md +1 -16
  269. package/skills/debugging/references/runtimes/native-binary.md +9 -54
  270. package/skills/debugging/references/runtimes/node.md +4 -15
  271. package/skills/debugging/references/runtimes/python.md +3 -15
  272. package/skills/debugging/references/runtimes/rust.md +2 -18
  273. package/skills/debugging/references/tools/dap.md +1 -1
  274. package/skills/debugging/references/tools/ghidra.md +4 -15
  275. package/skills/debugging/references/tools/playwright-cli.md +3 -15
  276. package/skills/debugging/references/tools/pwntools.md +4 -16
  277. package/skills/dispatching-parallel-agents/SKILL.md +18 -16
  278. package/skills/frontend/SKILL.md +7 -4
  279. package/skills/frontend/references/design/react-dev-tooling-skill.md +1 -1
  280. package/skills/git-master/SKILL.md +7 -4
  281. package/skills/init-deep/SKILL.md +7 -4
  282. package/skills/receiving-code-review/SKILL.md +17 -12
  283. package/skills/remove-ai-slops/SKILL.md +39 -38
  284. package/skills/requesting-code-review/SKILL.md +19 -17
  285. package/skills/requesting-code-review/code-reviewer.md +13 -1
  286. package/skills/subagent-driven-development/SKILL.md +29 -26
  287. package/skills/subagent-driven-development/implementer-prompt.md +29 -11
  288. package/skills/subagent-driven-development/spec-reviewer-prompt.md +6 -1
  289. package/skills/using-git-worktrees/SKILL.md +7 -4
  290. package/skills/writing-plans/SKILL.md +29 -24
  291. package/skills/writing-plans/plan-document-reviewer-prompt.md +10 -1
@@ -0,0 +1,152 @@
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 { SessionId } from "@deepseek-ai/dsh-session";
36
+ import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
37
+ import { PermissionRefusal, permissionOriginal } from "./permission-control.js";
38
+ import { PERMISSION_HOST, parsePermissionSessionId } from "./permission-remote.js";
39
+ import { parsePermissionRulesSave } from "./permission-rules.js";
40
+ /** Root controls are ordinary Core controls; no DW delivery fence/ticket is consulted. */
41
+ let DsmmPermissionsHost = (() => {
42
+ let _classSuper = TypertRemoteService;
43
+ let _instanceExtraInitializers = [];
44
+ let _describeRules_decorators;
45
+ let _saveRules_decorators;
46
+ return class DsmmPermissionsHost extends _classSuper {
47
+ static {
48
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
49
+ _describeRules_decorators = [Remote];
50
+ _saveRules_decorators = [Remote];
51
+ __esDecorate(this, null, _describeRules_decorators, { kind: "method", name: "describeRules", static: false, private: false, access: { has: obj => "describeRules" in obj, get: obj => obj.describeRules }, metadata: _metadata }, null, _instanceExtraInitializers);
52
+ __esDecorate(this, null, _saveRules_decorators, { kind: "method", name: "saveRules", static: false, private: false, access: { has: obj => "saveRules" in obj, get: obj => obj.saveRules }, metadata: _metadata }, null, _instanceExtraInitializers);
53
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
54
+ }
55
+ rules = __runInitializers(this, _instanceExtraInitializers);
56
+ lifetime = new AbortController();
57
+ constructor(ctx, rules) {
58
+ super(ctx, "dsmmPermissions");
59
+ this.rules = rules;
60
+ ctx.effect(() => () => this.lifetime.abort());
61
+ }
62
+ invoke(sessionId, operation) {
63
+ return Promise.resolve().then(() => {
64
+ const id = SessionId(parsePermissionSessionId(sessionId));
65
+ const invocation = this.ctx.invocation, connection = this.ctx.get("connection");
66
+ if (invocation?.peer === undefined || connection === undefined || invocation.peer !== connection.operator)
67
+ throw new PermissionRefusal("not-owned");
68
+ const peer = invocation.peer, owner = permissionOriginal(connection), agents = this.ctx.get("agents"), root = agents?.get(id);
69
+ if (root === undefined)
70
+ throw new PermissionRefusal("not-owned");
71
+ const signal = AbortSignal.any([invocation.signal, this.lifetime.signal]);
72
+ const check = () => {
73
+ const current = this.ctx.get("connection"), registry = this.ctx.get("agents");
74
+ if (signal.aborted)
75
+ throw new PermissionRefusal("cancelled");
76
+ if (current === undefined || permissionOriginal(current) !== owner || current.operator !== peer || registry?.get(id) !== root
77
+ || root.id !== sessionId || root.session.id !== sessionId || root.session.header.origin === "subagent" || !registry.roots().includes(root)
78
+ || registry.list().some(agent => agent !== root && registry.isOwnedBy(id, agent)))
79
+ throw new PermissionRefusal("not-owned");
80
+ };
81
+ check();
82
+ return operation(root, peer, signal, check);
83
+ }).catch(error => {
84
+ const code = error instanceof PermissionRefusal ? error.code : error instanceof TypeError ? "validation" : "unavailable";
85
+ throw new RemoteError("dsmm-permissions/refused", "The Host refused the permission operation.", { code });
86
+ });
87
+ }
88
+ rulesAuthority(root, peer, signal, check) {
89
+ const rules = this.rules;
90
+ const settings = this.ctx.get("settings"), webServer = this.ctx.get("webServer");
91
+ const assertCurrent = () => {
92
+ check();
93
+ const currentSettings = this.ctx.get("settings"), currentWeb = this.ctx.get("webServer");
94
+ if (settings === undefined || currentSettings === undefined || permissionOriginal(currentSettings) !== permissionOriginal(settings)
95
+ || currentSettings.writable !== true || webServer === undefined || currentWeb === undefined
96
+ || permissionOriginal(currentWeb) !== permissionOriginal(webServer) || currentWeb.host !== "127.0.0.1")
97
+ throw new PermissionRefusal("not-owned");
98
+ rules.backend.assertWritable(root);
99
+ };
100
+ assertCurrent();
101
+ return Object.freeze({ root, peer, signal, assertCurrent });
102
+ }
103
+ withCapabilities(root, result) {
104
+ const controller = this.ctx.get("dsmmPermissionController");
105
+ let capabilities;
106
+ if (controller !== undefined && permissionOriginal(controller.rules) === permissionOriginal(this.rules.runtime)) {
107
+ try {
108
+ const observed = controller.capabilities(root);
109
+ const current = this.ctx.get("dsmmPermissionController");
110
+ if (current !== undefined && permissionOriginal(current) === permissionOriginal(controller))
111
+ capabilities = observed;
112
+ }
113
+ catch { /* Unavailable live authority is unknown, not an empty successful observation. */ }
114
+ }
115
+ return { snapshot: result.snapshot, runtime: result.runtime, ...capabilities === undefined ? {} : { capabilities } };
116
+ }
117
+ describeRules(sessionId) {
118
+ return this.invoke(sessionId, async (root, peer, signal, check) => {
119
+ const authority = this.rulesAuthority(root, peer, signal, check), snapshot = await this.rules.backend.read(authority);
120
+ authority.assertCurrent();
121
+ const result = this.withCapabilities(root, { snapshot, runtime: this.rules.runtime.status() });
122
+ authority.assertCurrent();
123
+ return result;
124
+ });
125
+ }
126
+ saveRules(sessionId, request) {
127
+ return this.invoke(sessionId, async (root, peer, signal, check) => {
128
+ const parsed = parsePermissionRulesSave(request), authority = this.rulesAuthority(root, peer, signal, check);
129
+ const snapshot = await this.rules.backend.read(authority);
130
+ authority.assertCurrent();
131
+ if (snapshot.revision !== parsed.expectedRevision)
132
+ throw new PermissionRefusal("stale");
133
+ const result = await this.rules.backend.save(parsed, authority);
134
+ authority.assertCurrent();
135
+ const decorated = this.withCapabilities(root, result);
136
+ authority.assertCurrent();
137
+ return decorated;
138
+ });
139
+ }
140
+ };
141
+ })();
142
+ export { DsmmPermissionsHost };
143
+ export function registerPermissionControlRpc(ctx, rules) {
144
+ const host = new DsmmPermissionsHost(ctx, rules);
145
+ ctx.typert.register(PERMISSION_HOST);
146
+ return host;
147
+ }
148
+ /** Native-only mount does not construct a substitute Root ToolRuntime or scoped-memory authority. */
149
+ export function registerNativePermissionRulesRpc(ctx, backend, runtime) {
150
+ return registerPermissionControlRpc(ctx, { backend, runtime });
151
+ }
152
+ //# sourceMappingURL=permission-rpc.js.map
@@ -0,0 +1,115 @@
1
+ import type { Agent } from "@deepseek-ai/dsh-agent";
2
+ import type { NativePermissionCapabilityView } from "./permission-native-rules.js";
3
+ import type { PermissionControlSettings, PermissionRuleAction, PermissionWebPolicy } from "./permission-settings.js";
4
+ export type PermissionRuleMatch = {
5
+ readonly kind: "outside-read";
6
+ readonly path: string;
7
+ readonly scope: "exact" | "tree";
8
+ } | {
9
+ readonly kind: "shell";
10
+ readonly executable: string;
11
+ readonly command: string;
12
+ readonly workingDirectory: string;
13
+ } | {
14
+ readonly kind: "webSearch" | "webFetch";
15
+ };
16
+ export interface PermissionRuleDraft {
17
+ readonly id: string;
18
+ readonly action: Exclude<PermissionRuleAction, "inherit">;
19
+ readonly match: PermissionRuleMatch;
20
+ }
21
+ export type PermissionRuleSource = {
22
+ readonly kind: "operator";
23
+ readonly sessionId: string;
24
+ readonly savedAt: number;
25
+ } | {
26
+ readonly kind: "user-import";
27
+ readonly label: string;
28
+ };
29
+ export interface PermissionRule extends PermissionRuleDraft {
30
+ readonly source: PermissionRuleSource;
31
+ readonly revision: number;
32
+ readonly revoked: boolean;
33
+ }
34
+ export interface PermissionRuleSnapshot {
35
+ readonly revision: string;
36
+ readonly policy: PermissionControlSettings;
37
+ }
38
+ export interface PermissionRulesStatus {
39
+ readonly savedRevision: string;
40
+ readonly runtimeRevision: string;
41
+ readonly state: "synced" | "updating" | "unsynced";
42
+ readonly mounted: boolean;
43
+ readonly restartRequired: boolean;
44
+ }
45
+ export interface PermissionRulesSaveRequest {
46
+ readonly expectedRevision: string;
47
+ readonly changes?: {
48
+ readonly outsideReads?: PermissionRuleAction;
49
+ readonly webSearch?: PermissionWebPolicy;
50
+ readonly webFetch?: PermissionWebPolicy;
51
+ };
52
+ readonly upsert?: readonly PermissionRuleDraft[];
53
+ readonly revoke?: readonly string[];
54
+ }
55
+ export interface PermissionRulesSaveAuthority {
56
+ readonly root: Agent;
57
+ readonly peer: object;
58
+ readonly signal: AbortSignal;
59
+ /** Backend calls this after awaits and immediately before its durable CAS. Includes readonly. */
60
+ assertCurrent(): void;
61
+ }
62
+ /** One central backend only. Every permission-affecting save (including imports) uses sync. */
63
+ export interface PermissionRulesBackend {
64
+ assertWritable(root: Agent): void;
65
+ read(authority: PermissionRulesSaveAuthority): Promise<PermissionRuleSnapshot>;
66
+ save(request: PermissionRulesSaveRequest, authority: PermissionRulesSaveAuthority): Promise<PermissionRulesSaveResult>;
67
+ }
68
+ export interface PermissionRulesSaveResult {
69
+ readonly snapshot: PermissionRuleSnapshot;
70
+ readonly runtime: PermissionRulesStatus;
71
+ readonly capabilities?: NativePermissionCapabilityView;
72
+ }
73
+ export declare function permissionRuleRow(value: unknown, required: readonly string[], optional?: readonly string[]): Record<string, unknown>;
74
+ /** Persistent backend source identity, not a counter or a prescribed hash format. */
75
+ export declare function permissionRevision(value: unknown): string;
76
+ export declare function parsePermissionRules(value: unknown): readonly PermissionRule[];
77
+ export declare function parsePermissionRulesSave(value: unknown): PermissionRulesSaveRequest;
78
+ /** Backend derives provenance from its verified Host authority, never from a client rule. */
79
+ export declare function applyPermissionRulesSave(previous: PermissionRuleSnapshot, input: PermissionRulesSaveRequest, source: PermissionRuleSource): PermissionControlSettings;
80
+ export declare function operatorPermissionRulesSource(authority: PermissionRulesSaveAuthority): PermissionRuleSource;
81
+ /** Import paths explicitly re-stamp all records; imported operator claims are not ACKs. */
82
+ export declare function importPermissionRules(input: readonly PermissionRuleDraft[], label: string, revision: number): readonly PermissionRule[];
83
+ export interface PermissionRulesUpdate {
84
+ readonly expectedRevision: string;
85
+ }
86
+ /** In-process protocol owned by A's single CAS backend. No file watcher or persistence. */
87
+ export declare class PermissionRulesRuntimeSync {
88
+ private readonly revoke;
89
+ private snapshot;
90
+ private savedRevision;
91
+ private state;
92
+ private update?;
93
+ private lifetime;
94
+ private retired;
95
+ private readonly mounted;
96
+ private desiredEnabled;
97
+ constructor(initial: PermissionRuleSnapshot, revoke: () => void);
98
+ private validate;
99
+ status(): PermissionRulesStatus;
100
+ getPolicy(): PermissionRuleSnapshot;
101
+ get signal(): AbortSignal;
102
+ /** Source backends override this entry; consumers never reconcile storage themselves. */
103
+ refresh(): Promise<PermissionRuleSnapshot>;
104
+ invalidate(): void;
105
+ private assertLive;
106
+ begin(expectedRevision: string): PermissionRulesUpdate;
107
+ private check;
108
+ /** Called only after CAS succeeded. notify must acknowledge all runtime revocation consumers. */
109
+ commit(update: PermissionRulesUpdate, saved: PermissionRuleSnapshot, notify: (snapshot: PermissionRuleSnapshot) => Promise<void>): Promise<PermissionRulesStatus>;
110
+ /** CAS failure or failed notification: reread authoritative storage, never publish the rejected request. */
111
+ recover(update: PermissionRulesUpdate | undefined, authoritative: PermissionRuleSnapshot, notify: (snapshot: PermissionRuleSnapshot) => Promise<void>): Promise<PermissionRulesStatus>;
112
+ retire(): void;
113
+ }
114
+ export declare function intersectPermissionActions(actions: readonly PermissionRuleAction[]): PermissionRuleAction;
115
+ //# sourceMappingURL=permission-rules.d.ts.map
@@ -0,0 +1,256 @@
1
+ import { PermissionRefusal } from "./permission-errors.js";
2
+ import { resolvePermissionControl } from "./permission-settings.js";
3
+ function invalid() { throw new PermissionRefusal("validation"); }
4
+ export function permissionRuleRow(value, required, optional = []) {
5
+ if (value === null || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
6
+ invalid();
7
+ const fields = Object.getOwnPropertyDescriptors(value);
8
+ if (Reflect.ownKeys(value).some(key => typeof key !== "string" || !required.includes(key) && !optional.includes(key))
9
+ || required.some(key => !Object.hasOwn(fields, key)) || Object.values(fields).some(field => !Object.hasOwn(field, "value") || !field.enumerable))
10
+ invalid();
11
+ return value;
12
+ }
13
+ function text(value, max = 32768) {
14
+ if (typeof value !== "string" || value.length === 0 || value.length > max || value.includes("\0"))
15
+ invalid();
16
+ return value;
17
+ }
18
+ /** Persistent backend source identity, not a counter or a prescribed hash format. */
19
+ export function permissionRevision(value) { return text(value, 4096); }
20
+ function integer(value) { if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
21
+ invalid(); return value; }
22
+ function ruleAction(value, inherit = false) {
23
+ if (typeof value !== "string" || !(inherit ? ["inherit", "allow", "ask", "deny"] : ["allow", "ask", "deny"]).includes(value))
24
+ invalid();
25
+ return value;
26
+ }
27
+ function draft(value, persisted = false) {
28
+ const input = permissionRuleRow(value, ["id", "action", "match", ...persisted ? ["source", "revision", "revoked"] : []]);
29
+ const kind = permissionRuleRow(input.match, ["kind"], ["path", "scope", "executable", "command", "workingDirectory"]).kind;
30
+ let match;
31
+ if (kind === "outside-read") {
32
+ const row = permissionRuleRow(input.match, ["kind", "path", "scope"]);
33
+ if (row.scope !== "exact" && row.scope !== "tree")
34
+ invalid();
35
+ match = { kind, path: text(row.path), scope: row.scope };
36
+ }
37
+ else if (kind === "shell") {
38
+ const row = permissionRuleRow(input.match, ["kind", "executable", "command", "workingDirectory"]);
39
+ match = { kind, executable: text(row.executable), command: text(row.command), workingDirectory: text(row.workingDirectory) };
40
+ }
41
+ else if (kind === "webSearch" || kind === "webFetch") {
42
+ permissionRuleRow(input.match, ["kind"]);
43
+ match = { kind };
44
+ }
45
+ else
46
+ invalid();
47
+ return Object.freeze({ id: text(input.id, 256), action: ruleAction(input.action), match: Object.freeze(match) });
48
+ }
49
+ export function parsePermissionRules(value) {
50
+ if (!Array.isArray(value) || value.length > 1024)
51
+ invalid();
52
+ const ids = new Set();
53
+ return Object.freeze(value.map(item => {
54
+ const parsed = draft(item, true), row = item;
55
+ if (ids.has(parsed.id) || typeof row.revoked !== "boolean")
56
+ invalid();
57
+ ids.add(parsed.id);
58
+ const sourceRow = permissionRuleRow(row.source, ["kind"], ["sessionId", "savedAt", "label"]);
59
+ let source;
60
+ if (sourceRow.kind === "operator") {
61
+ permissionRuleRow(row.source, ["kind", "sessionId", "savedAt"]);
62
+ source = { kind: "operator", sessionId: text(sourceRow.sessionId, 256), savedAt: integer(sourceRow.savedAt) };
63
+ }
64
+ else if (sourceRow.kind === "user-import") {
65
+ permissionRuleRow(row.source, ["kind", "label"]);
66
+ source = { kind: "user-import", label: text(sourceRow.label, 512) };
67
+ }
68
+ else
69
+ invalid();
70
+ return Object.freeze({ ...parsed, source: Object.freeze(source), revision: integer(row.revision), revoked: row.revoked });
71
+ }));
72
+ }
73
+ export function parsePermissionRulesSave(value) {
74
+ const row = permissionRuleRow(value, ["expectedRevision"], ["changes", "upsert", "revoke"]);
75
+ let changes;
76
+ if (row.changes !== undefined) {
77
+ const input = permissionRuleRow(row.changes, [], ["outsideReads", "webSearch", "webFetch"]);
78
+ const web = (value) => { const row = permissionRuleRow(value, ["enabled", "rule"]); if (typeof row.enabled !== "boolean")
79
+ invalid(); return Object.freeze({ enabled: row.enabled, rule: ruleAction(row.rule, true) }); };
80
+ changes = Object.freeze({ ...input.outsideReads === undefined ? {} : { outsideReads: ruleAction(input.outsideReads, true) },
81
+ ...input.webSearch === undefined ? {} : { webSearch: web(input.webSearch) }, ...input.webFetch === undefined ? {} : { webFetch: web(input.webFetch) } });
82
+ }
83
+ if (row.upsert !== undefined && (!Array.isArray(row.upsert) || row.upsert.length > 1024)
84
+ || row.revoke !== undefined && (!Array.isArray(row.revoke) || row.revoke.length > 1024))
85
+ invalid();
86
+ const upsert = row.upsert?.map(item => draft(item)), revoke = row.revoke?.map(item => text(item, 256));
87
+ const ids = [...upsert?.map(item => item.id) ?? [], ...revoke ?? []];
88
+ if (ids.length !== new Set(ids).size || ids.length === 0 && (changes === undefined || Object.keys(changes).length === 0))
89
+ invalid();
90
+ return Object.freeze({ expectedRevision: permissionRevision(row.expectedRevision), ...changes === undefined ? {} : { changes },
91
+ ...upsert === undefined ? {} : { upsert: Object.freeze(upsert) }, ...revoke === undefined ? {} : { revoke: Object.freeze(revoke) } });
92
+ }
93
+ /** Backend derives provenance from its verified Host authority, never from a client rule. */
94
+ export function applyPermissionRulesSave(previous, input, source) {
95
+ const request = parsePermissionRulesSave(input);
96
+ if (permissionRevision(previous.revision) !== request.expectedRevision)
97
+ throw new PermissionRefusal("stale");
98
+ const policy = resolvePermissionControl(previous.policy), rules = new Map(policy.rules.map(rule => [rule.id, rule]));
99
+ for (const id of request.revoke ?? []) {
100
+ const existing = rules.get(id);
101
+ if (existing === undefined)
102
+ throw new PermissionRefusal("not-found");
103
+ rules.set(id, { ...existing, revision: integer(existing.revision + 1), revoked: true, source });
104
+ }
105
+ for (const rule of request.upsert ?? [])
106
+ rules.set(rule.id, { ...rule, revision: integer((rules.get(rule.id)?.revision ?? 0) + 1), revoked: false, source });
107
+ return resolvePermissionControl({ ...policy, ...request.changes, rules: [...rules.values()] });
108
+ }
109
+ export function operatorPermissionRulesSource(authority) {
110
+ authority.signal.throwIfAborted();
111
+ authority.assertCurrent();
112
+ return Object.freeze({ kind: "operator", sessionId: authority.root.id, savedAt: Date.now() });
113
+ }
114
+ /** Import paths explicitly re-stamp all records; imported operator claims are not ACKs. */
115
+ export function importPermissionRules(input, label, revision) {
116
+ return parsePermissionRules(input.map(item => ({ ...draft(item), source: { kind: "user-import", label: text(label, 512) }, revision: integer(revision), revoked: false })));
117
+ }
118
+ /** In-process protocol owned by A's single CAS backend. No file watcher or persistence. */
119
+ export class PermissionRulesRuntimeSync {
120
+ revoke;
121
+ snapshot;
122
+ savedRevision;
123
+ state = "synced";
124
+ update;
125
+ lifetime = new AbortController();
126
+ retired = false;
127
+ mounted;
128
+ desiredEnabled;
129
+ constructor(initial, revoke) {
130
+ this.revoke = revoke;
131
+ this.snapshot = this.validate(initial);
132
+ this.savedRevision = initial.revision;
133
+ this.mounted = initial.policy.enabled;
134
+ this.desiredEnabled = initial.policy.enabled;
135
+ }
136
+ validate(value) {
137
+ const revision = permissionRevision(value.revision), policy = resolvePermissionControl(value.policy);
138
+ return Object.freeze({ revision, policy });
139
+ }
140
+ status() {
141
+ return Object.freeze({ savedRevision: this.savedRevision, runtimeRevision: this.snapshot.revision,
142
+ state: this.state, mounted: this.mounted, restartRequired: this.desiredEnabled !== this.mounted });
143
+ }
144
+ getPolicy() {
145
+ if (this.retired || this.state !== "synced" || this.lifetime.signal.aborted)
146
+ throw new PermissionRefusal("unavailable");
147
+ return this.snapshot;
148
+ }
149
+ get signal() { return this.lifetime.signal; }
150
+ /** Source backends override this entry; consumers never reconcile storage themselves. */
151
+ async refresh() { return this.getPolicy(); }
152
+ invalidate() {
153
+ if (this.retired)
154
+ return;
155
+ this.state = "unsynced";
156
+ this.update = undefined;
157
+ this.lifetime.abort();
158
+ if (!this.retired)
159
+ this.revoke();
160
+ }
161
+ assertLive() { if (this.retired)
162
+ throw new PermissionRefusal("unavailable"); }
163
+ begin(expectedRevision) {
164
+ this.assertLive();
165
+ if (this.state === "updating" || permissionRevision(expectedRevision) !== this.savedRevision)
166
+ throw new PermissionRefusal("stale");
167
+ const update = Object.freeze({ expectedRevision, generation: {} });
168
+ this.update = update;
169
+ this.state = "updating";
170
+ this.lifetime.abort();
171
+ try {
172
+ this.revoke();
173
+ this.check(update);
174
+ }
175
+ catch (error) {
176
+ if (this.update === update) {
177
+ this.state = "unsynced";
178
+ this.update = undefined;
179
+ }
180
+ throw error;
181
+ }
182
+ return update;
183
+ }
184
+ check(update) { this.assertLive(); if (update !== this.update)
185
+ throw new PermissionRefusal("stale"); }
186
+ /** Called only after CAS succeeded. notify must acknowledge all runtime revocation consumers. */
187
+ async commit(update, saved, notify) {
188
+ this.check(update);
189
+ const snapshot = this.validate(saved);
190
+ this.savedRevision = snapshot.revision;
191
+ this.desiredEnabled = snapshot.policy.enabled;
192
+ try {
193
+ await notify(snapshot);
194
+ this.check(update);
195
+ this.snapshot = snapshot;
196
+ this.state = "synced";
197
+ this.update = undefined;
198
+ this.lifetime = new AbortController();
199
+ }
200
+ catch (error) {
201
+ if (this.update === update) {
202
+ this.state = "unsynced";
203
+ this.update = undefined;
204
+ }
205
+ throw error;
206
+ }
207
+ return this.status();
208
+ }
209
+ /** CAS failure or failed notification: reread authoritative storage, never publish the rejected request. */
210
+ async recover(update, authoritative, notify) {
211
+ this.assertLive();
212
+ if (update !== undefined)
213
+ this.check(update);
214
+ else if (this.state !== "unsynced")
215
+ throw new PermissionRefusal("stale");
216
+ const snapshot = this.validate(authoritative);
217
+ const recovery = Object.freeze({ expectedRevision: snapshot.revision, generation: {} });
218
+ this.update = recovery;
219
+ this.state = "updating";
220
+ try {
221
+ this.lifetime.abort();
222
+ this.check(recovery);
223
+ this.revoke();
224
+ this.check(recovery);
225
+ this.savedRevision = snapshot.revision;
226
+ this.desiredEnabled = snapshot.policy.enabled;
227
+ await notify(snapshot);
228
+ this.check(recovery);
229
+ this.snapshot = snapshot;
230
+ this.state = "synced";
231
+ this.update = undefined;
232
+ this.lifetime = new AbortController();
233
+ }
234
+ catch (error) {
235
+ if (this.update === recovery) {
236
+ this.state = "unsynced";
237
+ this.update = undefined;
238
+ }
239
+ throw error;
240
+ }
241
+ return this.status();
242
+ }
243
+ retire() {
244
+ if (this.retired)
245
+ return;
246
+ this.retired = true;
247
+ this.state = "unsynced";
248
+ this.update = undefined;
249
+ this.lifetime.abort();
250
+ this.revoke();
251
+ }
252
+ }
253
+ export function intersectPermissionActions(actions) {
254
+ return actions.includes("deny") ? "deny" : actions.includes("ask") ? "ask" : actions.includes("allow") ? "allow" : "inherit";
255
+ }
256
+ //# sourceMappingURL=permission-rules.js.map
@@ -0,0 +1,45 @@
1
+ import z from "@deepseek-ai/schemastery";
2
+ import type { PermissionRule } from "./permission-rules.js";
3
+ export type PermissionRuleAction = "inherit" | "allow" | "ask" | "deny";
4
+ export interface PermissionWebPolicy {
5
+ readonly enabled: boolean;
6
+ readonly rule: PermissionRuleAction;
7
+ }
8
+ export interface NativeCommandEntry {
9
+ readonly id: string;
10
+ readonly mode: "ask" | "allow";
11
+ readonly match: {
12
+ readonly tool: "bash" | "pwsh";
13
+ readonly executable: string;
14
+ readonly subcommand?: string;
15
+ readonly args: readonly string[];
16
+ readonly workingDirectory: string;
17
+ };
18
+ readonly sandboxMode: "workspace-write" | "danger-full-access";
19
+ }
20
+ export interface NativeCommandsSettings {
21
+ readonly enabled: boolean;
22
+ readonly entries: readonly NativeCommandEntry[];
23
+ }
24
+ /** Only enabled is deployment-only. Rules are independently synchronized at runtime. */
25
+ export interface PermissionControlSettings {
26
+ readonly enabled: boolean;
27
+ readonly outsideReads: PermissionRuleAction;
28
+ readonly webSearch: PermissionWebPolicy;
29
+ readonly webFetch: PermissionWebPolicy;
30
+ readonly rules: readonly PermissionRule[];
31
+ readonly nativeCommands: NativeCommandsSettings;
32
+ }
33
+ export interface PermissionControlSchemaInput {
34
+ readonly enabled?: boolean;
35
+ readonly outsideReads?: PermissionRuleAction;
36
+ readonly webSearch?: Partial<PermissionWebPolicy>;
37
+ readonly webFetch?: Partial<PermissionWebPolicy>;
38
+ readonly rules?: readonly PermissionRule[];
39
+ readonly nativeCommands?: Partial<NativeCommandsSettings>;
40
+ }
41
+ export declare function parseNativeCommands(input?: unknown): NativeCommandsSettings;
42
+ export declare const DEFAULT_PERMISSION_CONTROL: PermissionControlSettings;
43
+ export declare const permissionControlSchema: z<PermissionControlSettings>;
44
+ export declare function resolvePermissionControl(input?: PermissionControlSchemaInput): PermissionControlSettings;
45
+ //# sourceMappingURL=permission-settings.d.ts.map
@@ -0,0 +1,48 @@
1
+ import z from "@deepseek-ai/schemastery";
2
+ import { parsePermissionRules, permissionRuleRow } from "./permission-rules.js";
3
+ import { PermissionRefusal } from "./permission-errors.js";
4
+ export function parseNativeCommands(input = {}) {
5
+ const row = permissionRuleRow(input, [], ["enabled", "entries"]);
6
+ if (row.enabled !== undefined && typeof row.enabled !== "boolean" || row.entries !== undefined && (!Array.isArray(row.entries) || row.entries.length > 1024))
7
+ throw new PermissionRefusal("validation");
8
+ const text = (value) => { if (typeof value !== "string" || value.trim().length === 0 || value.length > 32768 || value.includes("\0"))
9
+ throw new PermissionRefusal("validation"); return value; };
10
+ const ids = new Set();
11
+ const entries = (row.entries ?? []).map(value => {
12
+ const entry = permissionRuleRow(value, ["id", "mode", "match", "sandboxMode"]), match = permissionRuleRow(entry.match, ["tool", "executable", "args", "workingDirectory"], ["subcommand"]);
13
+ const id = text(entry.id), cwd = text(match.workingDirectory);
14
+ if (ids.has(id) || !["ask", "allow"].includes(entry.mode) || !["bash", "pwsh"].includes(match.tool)
15
+ || !["workspace-write", "danger-full-access"].includes(entry.sandboxMode)
16
+ // Wire paths belong to the Host, not the browser's platform. The Host validates and canonicalizes them before use.
17
+ || !/^(?:\/|[a-z]:[\\/]|\\\\[^\\/]+[\\/][^\\/]+(?:[\\/]|$))/iu.test(cwd) || !Array.isArray(match.args))
18
+ throw new PermissionRefusal("validation");
19
+ ids.add(id);
20
+ return Object.freeze({ id, mode: entry.mode, sandboxMode: entry.sandboxMode, match: Object.freeze({
21
+ tool: match.tool, executable: text(match.executable), ...match.subcommand === undefined ? {} : { subcommand: text(match.subcommand) },
22
+ args: Object.freeze(match.args.map(text)), workingDirectory: cwd,
23
+ }) });
24
+ });
25
+ return Object.freeze({ enabled: row.enabled ?? false, entries: Object.freeze(entries) });
26
+ }
27
+ const nativeCommands = z.object({ enabled: z.boolean().default(false), entries: z.array(z.object({
28
+ id: z.string().required(), mode: z.union(["ask", "allow"]).required(), match: z.object({
29
+ tool: z.union(["bash", "pwsh"]).required(), executable: z.string().required(), subcommand: z.string(), args: z.array(z.string()).required(), workingDirectory: z.string().required(),
30
+ }).required(), sandboxMode: z.union(["workspace-write", "danger-full-access"]).required(),
31
+ })).default([]) });
32
+ const webDefault = Object.freeze({ enabled: true, rule: "inherit" });
33
+ export const DEFAULT_PERMISSION_CONTROL = Object.freeze({ enabled: true, outsideReads: "inherit", webSearch: webDefault, webFetch: webDefault, rules: Object.freeze([]), nativeCommands: parseNativeCommands() });
34
+ const action = () => z.union(["inherit", "allow", "ask", "deny"]).default("inherit");
35
+ const web = () => z.object({ enabled: z.boolean().default(true), rule: action() }).default({});
36
+ export const permissionControlSchema = z.transform(z.object({ enabled: z.boolean().default(true), outsideReads: action(), webSearch: web(), webFetch: web(),
37
+ nativeCommands, rules: z.array(z.any()).default([]) }), input => Object.freeze({ ...input, webSearch: Object.freeze(input.webSearch), webFetch: Object.freeze(input.webFetch), rules: parsePermissionRules(input.rules), nativeCommands: parseNativeCommands(input.nativeCommands) }), true);
38
+ export function resolvePermissionControl(input = {}) {
39
+ permissionRuleRow(input, [], ["enabled", "outsideReads", "webSearch", "webFetch", "rules", "nativeCommands"]);
40
+ if (Object.hasOwn(input, "nativeCommands"))
41
+ parseNativeCommands(input.nativeCommands);
42
+ for (const web of [input.webSearch, input.webFetch])
43
+ if (web !== undefined)
44
+ permissionRuleRow(web, [], ["enabled", "rule"]);
45
+ const parsed = permissionControlSchema(input);
46
+ return Object.freeze({ ...parsed, webSearch: Object.freeze(parsed.webSearch), webFetch: Object.freeze(parsed.webFetch), rules: parsePermissionRules(parsed.rules) });
47
+ }
48
+ //# sourceMappingURL=permission-settings.js.map
@@ -0,0 +1,38 @@
1
+ import type { ShellDialect } from "./shell-command.js";
2
+ import type { ToolExecution } from "@deepseek-ai/dsh-tools";
3
+ export type PermissionReadExecutable = "git" | "echo" | "printf" | "pwd" | "ls" | "cat" | "head" | "tail" | "wc" | "rg" | "grep" | "write-output" | "get-location" | "get-childitem" | "get-content";
4
+ /** Host-only native resolution proof for the actual execution realm and environment. */
5
+ export interface PermissionShellReadCapability {
6
+ readonly signal: AbortSignal;
7
+ /** Return a canonical implementation only after verifying actual executable/cmdlet identity and resolution in this cwd/Agent realm.
8
+ * The effective environment/configuration must exclude external preprocessors, pagers, hooks, fsmonitor, textconv and other dynamic handlers for these reads. */
9
+ resolveExecutable(token: string, workingDirectory: string, execution?: Readonly<ToolExecution>): PermissionReadExecutable | undefined;
10
+ /** Pure check of the same native executable/environment generation; not another SDK/third-party guard. */
11
+ assertCurrent(execution: Readonly<ToolExecution>): void;
12
+ }
13
+ /** Supplied by the trusted registration adapter, not inferred from a display name. */
14
+ export interface PermissionShellIdentity {
15
+ readonly executable: string;
16
+ readonly dialect: ShellDialect;
17
+ readonly commandField: string;
18
+ readonly cwdField?: string;
19
+ readonly readCapability?: PermissionShellReadCapability;
20
+ }
21
+ export type PermissionEffect = "read" | "local-write" | "external-write" | "destructive" | "unknown";
22
+ export interface PermissionOperation {
23
+ readonly effect: PermissionEffect;
24
+ readonly operations: readonly string[];
25
+ readonly rememberable: boolean;
26
+ readonly executable: string;
27
+ readonly command: string;
28
+ readonly workingDirectory: string;
29
+ }
30
+ /** Classification supports exact-operation authorization, not filesystem or network isolation. */
31
+ export declare function classifyPermissionShell(identity: PermissionShellIdentity, args: unknown, cwd: string, execution?: Readonly<ToolExecution>): PermissionOperation;
32
+ export interface PermissionShellReadPaths {
33
+ readonly workingDirectory: string;
34
+ readonly paths: readonly string[];
35
+ }
36
+ /** Typed DSMM extraction, not an SDK operand field. Undefined means exact native ask, not inside. */
37
+ export declare function parsePermissionShellReadPaths(identity: PermissionShellIdentity, args: unknown, cwd: string, execution?: Readonly<ToolExecution>): PermissionShellReadPaths | undefined;
38
+ //# sourceMappingURL=permission-shell.d.ts.map