@openvulcan/dsh-vulcancode 0.0.0-stage → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +126 -2
  3. package/assets/openvulcan-icon.svg +33 -0
  4. package/cordis.patch.yml +19 -0
  5. package/node_modules/@openvulcan/dsh-decision-guard/LICENSE +21 -0
  6. package/node_modules/@openvulcan/dsh-decision-guard/README.md +14 -0
  7. package/node_modules/@openvulcan/dsh-decision-guard/assets/decision-guard-icon.png +0 -0
  8. package/node_modules/@openvulcan/dsh-decision-guard/lib/calls.d.ts +40 -0
  9. package/node_modules/@openvulcan/dsh-decision-guard/lib/calls.js +150 -0
  10. package/node_modules/@openvulcan/dsh-decision-guard/lib/client.js +2250 -0
  11. package/node_modules/@openvulcan/dsh-decision-guard/lib/decide.d.ts +90 -0
  12. package/node_modules/@openvulcan/dsh-decision-guard/lib/decide.js +108 -0
  13. package/node_modules/@openvulcan/dsh-decision-guard/lib/index.d.ts +129 -0
  14. package/node_modules/@openvulcan/dsh-decision-guard/lib/index.js +572 -0
  15. package/node_modules/@openvulcan/dsh-decision-guard/lib/intent.d.ts +22 -0
  16. package/node_modules/@openvulcan/dsh-decision-guard/lib/intent.js +77 -0
  17. package/node_modules/@openvulcan/dsh-decision-guard/lib/panel.d.ts +158 -0
  18. package/node_modules/@openvulcan/dsh-decision-guard/lib/panel.js +340 -0
  19. package/node_modules/@openvulcan/dsh-decision-guard/lib/records.d.ts +133 -0
  20. package/node_modules/@openvulcan/dsh-decision-guard/lib/records.js +186 -0
  21. package/node_modules/@openvulcan/dsh-decision-guard/lib/review.d.ts +55 -0
  22. package/node_modules/@openvulcan/dsh-decision-guard/lib/review.js +202 -0
  23. package/node_modules/@openvulcan/dsh-decision-guard/lib/session-state.d.ts +62 -0
  24. package/node_modules/@openvulcan/dsh-decision-guard/lib/session-state.js +155 -0
  25. package/node_modules/@openvulcan/dsh-decision-guard/lib/version.d.ts +2 -0
  26. package/node_modules/@openvulcan/dsh-decision-guard/lib/version.js +4 -0
  27. package/node_modules/@openvulcan/dsh-decision-guard/package.json +68 -0
  28. package/node_modules/@openvulcan/dsh-vulcan-account/LICENSE +21 -0
  29. package/node_modules/@openvulcan/dsh-vulcan-account/assets/account-icon.png +0 -0
  30. package/node_modules/@openvulcan/dsh-vulcan-account/lib/client.js +573 -0
  31. package/node_modules/@openvulcan/dsh-vulcan-account/lib/index.d.ts +92 -0
  32. package/node_modules/@openvulcan/dsh-vulcan-account/lib/index.js +194 -0
  33. package/node_modules/@openvulcan/dsh-vulcan-account/package.json +57 -0
  34. package/node_modules/@openvulcan/dsh-vulcan-answers/LICENSE +21 -0
  35. package/node_modules/@openvulcan/dsh-vulcan-answers/assets/answers-icon.png +0 -0
  36. package/node_modules/@openvulcan/dsh-vulcan-answers/assets/prompts/answer-mode-interactive.md +79 -0
  37. package/node_modules/@openvulcan/dsh-vulcan-answers/assets/prompts/answer-mode-standard.md +1 -0
  38. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/answer-model.d.ts +258 -0
  39. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/answer-model.js +698 -0
  40. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/client.js +671 -0
  41. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/fences.d.ts +29 -0
  42. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/fences.js +70 -0
  43. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/index.d.ts +19 -0
  44. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/index.js +52 -0
  45. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/limits.d.ts +9 -0
  46. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/limits.js +9 -0
  47. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/prompt.d.ts +22 -0
  48. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/prompt.js +39 -0
  49. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/reply-format.d.ts +20 -0
  50. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/reply-format.js +17 -0
  51. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/session-state.d.ts +66 -0
  52. package/node_modules/@openvulcan/dsh-vulcan-answers/lib/session-state.js +118 -0
  53. package/node_modules/@openvulcan/dsh-vulcan-answers/package.json +59 -0
  54. package/node_modules/@openvulcan/dsh-vulcan-luaskills/LICENSE +21 -0
  55. package/node_modules/@openvulcan/dsh-vulcan-luaskills/assets/luaskills-icon.svg +1 -0
  56. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/client.js +949 -0
  57. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/constants.d.ts +46 -0
  58. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/constants.js +51 -0
  59. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/engine.d.ts +55 -0
  60. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/engine.js +149 -0
  61. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/hub.d.ts +49 -0
  62. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/hub.js +116 -0
  63. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/index.d.ts +26 -0
  64. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/index.js +276 -0
  65. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/protocol.d.ts +65 -0
  66. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/protocol.js +2 -0
  67. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/runtime.d.ts +111 -0
  68. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/runtime.js +281 -0
  69. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/sdk-install.d.ts +26 -0
  70. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/sdk-install.js +87 -0
  71. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/settings.d.ts +79 -0
  72. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/settings.js +165 -0
  73. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/skills.d.ts +34 -0
  74. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/skills.js +61 -0
  75. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/tools.d.ts +59 -0
  76. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/tools.js +107 -0
  77. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/worker.d.ts +10 -0
  78. package/node_modules/@openvulcan/dsh-vulcan-luaskills/lib/worker.js +140 -0
  79. package/node_modules/@openvulcan/dsh-vulcan-luaskills/package.json +57 -0
  80. package/node_modules/@openvulcan/dsh-vulcan-memory/LICENSE +21 -0
  81. package/node_modules/@openvulcan/dsh-vulcan-memory/assets/markdown-memory-guide.md +21 -0
  82. package/node_modules/@openvulcan/dsh-vulcan-memory/assets/memory-curator/SKILL.md +31 -0
  83. package/node_modules/@openvulcan/dsh-vulcan-memory/assets/memory-icon.png +0 -0
  84. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/client.js +1090 -0
  85. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/index.d.ts +30 -0
  86. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/index.js +240 -0
  87. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/inject.d.ts +30 -0
  88. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/inject.js +46 -0
  89. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/constants.d.ts +23 -0
  90. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/constants.js +25 -0
  91. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/document.d.ts +108 -0
  92. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/document.js +373 -0
  93. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/errors.d.ts +14 -0
  94. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/errors.js +31 -0
  95. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/index.d.ts +196 -0
  96. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/index.js +204 -0
  97. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/operations.d.ts +92 -0
  98. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/operations.js +472 -0
  99. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/package.d.ts +126 -0
  100. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/package.js +553 -0
  101. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/registry.d.ts +56 -0
  102. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/registry.js +182 -0
  103. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/scope.d.ts +13 -0
  104. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/scope.js +24 -0
  105. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/search.d.ts +65 -0
  106. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/search.js +227 -0
  107. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/snapshot.d.ts +34 -0
  108. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/snapshot.js +171 -0
  109. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/store.d.ts +72 -0
  110. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/store.js +250 -0
  111. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/timestamp.d.ts +6 -0
  112. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/timestamp.js +12 -0
  113. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/tokens.d.ts +8 -0
  114. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/markdown/tokens.js +38 -0
  115. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/page.d.ts +132 -0
  116. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/page.js +235 -0
  117. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/project.d.ts +14 -0
  118. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/project.js +27 -0
  119. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/settings.d.ts +29 -0
  120. package/node_modules/@openvulcan/dsh-vulcan-memory/lib/settings.js +62 -0
  121. package/node_modules/@openvulcan/dsh-vulcan-memory/package.json +63 -0
  122. package/node_modules/@openvulcan/dsh-vulcan-reasoning/LICENSE +21 -0
  123. package/node_modules/@openvulcan/dsh-vulcan-reasoning/lib/client.js +509 -0
  124. package/node_modules/@openvulcan/dsh-vulcan-reasoning/lib/index.d.ts +6 -0
  125. package/node_modules/@openvulcan/dsh-vulcan-reasoning/lib/index.js +8 -0
  126. package/node_modules/@openvulcan/dsh-vulcan-reasoning/package.json +42 -0
  127. package/node_modules/@openvulcan/dsh-vulcan-style/LICENSE +21 -0
  128. package/node_modules/@openvulcan/dsh-vulcan-style/assets/style-icon.png +0 -0
  129. package/node_modules/@openvulcan/dsh-vulcan-style/lib/client.js +1121 -0
  130. package/node_modules/@openvulcan/dsh-vulcan-style/lib/index.d.ts +34 -0
  131. package/node_modules/@openvulcan/dsh-vulcan-style/lib/index.js +42 -0
  132. package/node_modules/@openvulcan/dsh-vulcan-style/package.json +51 -0
  133. package/node_modules/@openvulcan/openvulcan-account/LICENSE +21 -0
  134. package/node_modules/@openvulcan/openvulcan-account/lib/account.d.ts +140 -0
  135. package/node_modules/@openvulcan/openvulcan-account/lib/account.js +347 -0
  136. package/node_modules/@openvulcan/openvulcan-account/lib/index.d.ts +1 -0
  137. package/node_modules/@openvulcan/openvulcan-account/lib/index.js +1 -0
  138. package/node_modules/@openvulcan/openvulcan-account/package.json +29 -0
  139. package/node_modules/@openvulcan/vulcan-decision/LICENSE +21 -0
  140. package/node_modules/@openvulcan/vulcan-decision/README.md +23 -0
  141. package/node_modules/@openvulcan/vulcan-decision/bin/vulcan-decision.js +4 -0
  142. package/node_modules/@openvulcan/vulcan-decision/lib/cli.d.ts +5 -0
  143. package/node_modules/@openvulcan/vulcan-decision/lib/cli.js +267 -0
  144. package/node_modules/@openvulcan/vulcan-decision/lib/cloud/edge.d.ts +211 -0
  145. package/node_modules/@openvulcan/vulcan-decision/lib/cloud/edge.js +594 -0
  146. package/node_modules/@openvulcan/vulcan-decision/lib/download.d.ts +36 -0
  147. package/node_modules/@openvulcan/vulcan-decision/lib/download.js +99 -0
  148. package/node_modules/@openvulcan/vulcan-decision/lib/engine.d.ts +37 -0
  149. package/node_modules/@openvulcan/vulcan-decision/lib/engine.js +39 -0
  150. package/node_modules/@openvulcan/vulcan-decision/lib/hardware.d.ts +105 -0
  151. package/node_modules/@openvulcan/vulcan-decision/lib/hardware.js +207 -0
  152. package/node_modules/@openvulcan/vulcan-decision/lib/home.d.ts +26 -0
  153. package/node_modules/@openvulcan/vulcan-decision/lib/home.js +54 -0
  154. package/node_modules/@openvulcan/vulcan-decision/lib/index.d.ts +17 -0
  155. package/node_modules/@openvulcan/vulcan-decision/lib/index.js +17 -0
  156. package/node_modules/@openvulcan/vulcan-decision/lib/local/engine.d.ts +54 -0
  157. package/node_modules/@openvulcan/vulcan-decision/lib/local/engine.js +157 -0
  158. package/node_modules/@openvulcan/vulcan-decision/lib/local/models.d.ts +126 -0
  159. package/node_modules/@openvulcan/vulcan-decision/lib/local/models.js +261 -0
  160. package/node_modules/@openvulcan/vulcan-decision/lib/local/packs.d.ts +102 -0
  161. package/node_modules/@openvulcan/vulcan-decision/lib/local/packs.js +195 -0
  162. package/node_modules/@openvulcan/vulcan-decision/lib/local/worker.d.ts +61 -0
  163. package/node_modules/@openvulcan/vulcan-decision/lib/local/worker.js +123 -0
  164. package/node_modules/@openvulcan/vulcan-decision/lib/protocol.d.ts +74 -0
  165. package/node_modules/@openvulcan/vulcan-decision/lib/protocol.js +31 -0
  166. package/node_modules/@openvulcan/vulcan-decision/lib/render.d.ts +15 -0
  167. package/node_modules/@openvulcan/vulcan-decision/lib/render.js +33 -0
  168. package/node_modules/@openvulcan/vulcan-decision/lib/version.d.ts +2 -0
  169. package/node_modules/@openvulcan/vulcan-decision/lib/version.js +4 -0
  170. package/node_modules/@openvulcan/vulcan-decision/package.json +40 -0
  171. package/node_modules/@openvulcan/vulcan-decision/python/vulcan_decision_worker.py +363 -0
  172. package/node_modules/@openvulcan/vulcan-decision/runtime-packs/onnx-cpu.json +627 -0
  173. package/node_modules/@openvulcan/vulcan-decision/runtime-packs/onnx-cuda.json +423 -0
  174. package/node_modules/@openvulcan/vulcan-decision/runtime-packs/torch-cpu.json +1047 -0
  175. package/node_modules/@openvulcan/vulcan-decision/runtime-packs/torch-cu128.json +647 -0
  176. package/package.json +55 -4
@@ -0,0 +1,90 @@
1
+ /**
2
+ * How the decision model's verdict, the optional LLM review and the session's attendance combine
3
+ * into what dsh does with a call. Nothing that fails or cannot be judged ever runs without either
4
+ * the LLM review or the user allowing it.
5
+ */
6
+ import type { Verdict } from '@openvulcan/vulcan-decision';
7
+ /** The decision model's answer, or why there is none. */
8
+ export type FirstStage = {
9
+ readonly kind: 'verdict';
10
+ readonly verdict: Verdict;
11
+ } | {
12
+ readonly kind: 'error';
13
+ readonly message: string;
14
+ };
15
+ /**
16
+ * The LLM review's answer.
17
+ *
18
+ * - `review`: the reviewer cannot confirm authorization and leaves it to the user (attended only).
19
+ * - `deny`: unsafe, unauthorized or matching a deny rule.
20
+ * - `forbid`: matching a rule the user absolutely forbids; refused without asking anyone.
21
+ */
22
+ export type SecondStage = {
23
+ readonly kind: 'skipped';
24
+ } | {
25
+ readonly kind: 'allow';
26
+ } | {
27
+ readonly kind: 'review';
28
+ readonly reason?: string;
29
+ } | {
30
+ readonly kind: 'deny';
31
+ readonly reason?: string;
32
+ } | {
33
+ readonly kind: 'forbid';
34
+ readonly reason?: string;
35
+ } | {
36
+ readonly kind: 'error';
37
+ readonly message: string;
38
+ };
39
+ /** What the decision model made of a call it did not allow; `unjudged` means it could not judge. */
40
+ export type Stage = 'review' | 'block' | 'unjudged';
41
+ /** Localized text for the approval prompt; dsh picks the entry for the UI locale. */
42
+ export interface DisplayText {
43
+ readonly [locale: string]: string;
44
+ readonly en: string;
45
+ readonly zh: string;
46
+ }
47
+ /** What the approval prompt shows besides its headline; the client reads it to set focus and badges. */
48
+ export interface PromptDetail {
49
+ readonly stage: Stage;
50
+ /** The LLM review's answer, when one was made. */
51
+ readonly review?: 'review' | 'deny' | 'error';
52
+ /** Reviewer's reason or failure message. */
53
+ readonly reviewReason?: string;
54
+ /** The button focused when the prompt opens. */
55
+ readonly focus: 'allow' | 'reject';
56
+ }
57
+ export type Outcome = {
58
+ readonly kind: 'run';
59
+ } | {
60
+ readonly kind: 'ask';
61
+ readonly reason: string;
62
+ readonly display: DisplayText;
63
+ readonly detail: PromptDetail;
64
+ } | {
65
+ readonly kind: 'deny';
66
+ readonly reason: string;
67
+ };
68
+ /** The settings and session facts {@link decide} needs. */
69
+ export interface Situation {
70
+ /** Whether a human can be asked in this session. */
71
+ readonly attended: boolean;
72
+ /** Whether the LLM review is turned on. */
73
+ readonly llm: boolean;
74
+ /** Whether a `block` verdict also goes to the LLM review, which may then allow it. */
75
+ readonly llmOverridesBlock: boolean;
76
+ }
77
+ /** Name of the tool through which the agent explains its next call; see `intent.ts`. */
78
+ export declare const INTENT_TOOL = "explain_tool_call";
79
+ /** The stage of a call the decision model did not allow, or undefined when it runs. */
80
+ export declare function stageOf(first: FirstStage): Stage | undefined;
81
+ /** Whether the LLM review looks at a call of this stage. */
82
+ export declare function wantsReview(stage: Stage, situation: Situation): boolean;
83
+ /**
84
+ * - `allow` runs.
85
+ * - With the LLM review on, it decides first: allow runs, forbid is refused outright, and anything
86
+ * else asks the user when someone is there and is refused otherwise.
87
+ * - A `block` the LLM may not override, and every stage with the LLM review off, asks the user
88
+ * when someone is there and is refused otherwise.
89
+ */
90
+ export declare function decide(tool: string, first: FirstStage, second: SecondStage, situation: Situation): Outcome;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * How the decision model's verdict, the optional LLM review and the session's attendance combine
3
+ * into what dsh does with a call. Nothing that fails or cannot be judged ever runs without either
4
+ * the LLM review or the user allowing it.
5
+ */
6
+ /** Name of the tool through which the agent explains its next call; see `intent.ts`. */
7
+ export const INTENT_TOOL = 'explain_tool_call';
8
+ /** The stage of a call the decision model did not allow, or undefined when it runs. */
9
+ export function stageOf(first) {
10
+ if (first.kind === 'error')
11
+ return 'unjudged';
12
+ if (first.verdict.decision === 'allow')
13
+ return undefined;
14
+ return first.verdict.decision;
15
+ }
16
+ /** Whether the LLM review looks at a call of this stage. */
17
+ export function wantsReview(stage, situation) {
18
+ return situation.llm && (stage !== 'block' || situation.llmOverridesBlock);
19
+ }
20
+ /**
21
+ * - `allow` runs.
22
+ * - With the LLM review on, it decides first: allow runs, forbid is refused outright, and anything
23
+ * else asks the user when someone is there and is refused otherwise.
24
+ * - A `block` the LLM may not override, and every stage with the LLM review off, asks the user
25
+ * when someone is there and is refused otherwise.
26
+ */
27
+ export function decide(tool, first, second, situation) {
28
+ const stage = stageOf(first);
29
+ if (stage === undefined)
30
+ return { kind: 'run' };
31
+ const subject = subjectOf(tool, first, stage);
32
+ if (second.kind === 'allow')
33
+ return { kind: 'run' };
34
+ if (second.kind === 'forbid') {
35
+ return { kind: 'deny', reason: `${subject}, and its review found that it breaks a rule the user absolutely forbids${detail(second.reason)}. ${retryHint(tool)}` };
36
+ }
37
+ if (!situation.attended) {
38
+ switch (second.kind) {
39
+ case 'deny':
40
+ return { kind: 'deny', reason: `${subject}, and its review denied it${detail(second.reason)}. ${retryHint(tool)}` };
41
+ case 'review':
42
+ // The unattended reviewer is told it has only two answers; a third is still not an allow.
43
+ return { kind: 'deny', reason: `${subject}, and its review did not allow it${detail(second.reason)}. ${retryHint(tool)}` };
44
+ case 'error':
45
+ return { kind: 'deny', reason: `${subject}, and its review failed: ${second.message}. No one is available to confirm the call in this unattended session, so it was not executed.` };
46
+ case 'skipped':
47
+ return { kind: 'deny', reason: `${subject}. No one is available to confirm the call in this unattended session, so it was not executed.` };
48
+ }
49
+ }
50
+ const display = displayOf(first, stage, second);
51
+ switch (second.kind) {
52
+ case 'review':
53
+ return ask(`${subject}; its review leaves the decision to the user${detail(second.reason)}`, display, {
54
+ stage, review: 'review', focus: 'allow', ...reasonOf(second.reason),
55
+ });
56
+ case 'deny':
57
+ return ask(`${subject}; its review denied it${detail(second.reason)}`, display, {
58
+ stage, review: 'deny', focus: 'reject', ...reasonOf(second.reason),
59
+ });
60
+ case 'error':
61
+ return ask(`${subject}; its review failed: ${second.message}`, display, {
62
+ stage, review: 'error', reviewReason: second.message, focus: stage === 'review' ? 'allow' : 'reject',
63
+ });
64
+ case 'skipped':
65
+ return ask(`${subject}; the user decides`, display, { stage, focus: stage === 'review' ? 'allow' : 'reject' });
66
+ }
67
+ }
68
+ function subjectOf(tool, first, stage) {
69
+ if (first.kind === 'error')
70
+ return `Vulcan Decision could not judge tool "${tool}" (${first.message})`;
71
+ if (stage === 'review')
72
+ return `Vulcan Decision flagged tool "${tool}" as needing confirmation`;
73
+ return first.verdict.reason_code === 'input_token_limit'
74
+ ? `Vulcan Decision blocked tool "${tool}" because the call is too long to judge`
75
+ : `Vulcan Decision blocked tool "${tool}" as unsafe`;
76
+ }
77
+ function displayOf(first, stage, second) {
78
+ const model = first.kind === 'error'
79
+ ? { en: `Vulcan Decision could not judge this call (${first.message})`, zh: `Vulcan Decision 无法判定此调用(${first.message})` }
80
+ : stage === 'review'
81
+ ? { en: 'Vulcan Decision asks you to confirm this call', zh: 'Vulcan Decision 需要你确认此调用' }
82
+ : first.verdict.reason_code === 'input_token_limit'
83
+ ? { en: 'Vulcan Decision blocked this call because it is too long to judge', zh: '此调用过长,Vulcan Decision 无法判定,已拦截' }
84
+ : { en: 'Vulcan Decision blocked this call as unsafe', zh: 'Vulcan Decision 认为此调用不安全,已拦截' };
85
+ switch (second.kind) {
86
+ case 'review':
87
+ return { en: `${model.en}; the LLM review leaves it to you.`, zh: `${model.zh};LLM 复核交由你决定。` };
88
+ case 'deny':
89
+ return { en: `${model.en}; the LLM review denied it.`, zh: `${model.zh};LLM 复核未放行。` };
90
+ case 'error':
91
+ return { en: `${model.en}; the LLM review failed.`, zh: `${model.zh};LLM 复核失败。` };
92
+ default:
93
+ return { en: `${model.en}.`, zh: `${model.zh}。` };
94
+ }
95
+ }
96
+ function ask(reason, display, detail) {
97
+ return { kind: 'ask', reason, display, detail };
98
+ }
99
+ function detail(reason) {
100
+ return reason === undefined ? '' : `: ${reason}`;
101
+ }
102
+ function reasonOf(reason) {
103
+ return reason === undefined ? {} : { reviewReason: reason };
104
+ }
105
+ /** Every LLM denial tells the agent how to explain itself and ask again. */
106
+ function retryHint(tool) {
107
+ return `The call was not executed. If it is needed and the reviewer misread it, call ${INTENT_TOOL} with tool "${tool}" and the purpose of the call, then make the call again.`;
108
+ }
@@ -0,0 +1,129 @@
1
+ import type { Context, Volatile } from '@deepseek-ai/cordis';
2
+ import Schema from '@deepseek-ai/schemastery';
3
+ import { type DecisionOptions, type DownloadSource, type PackId } from '@openvulcan/vulcan-decision';
4
+ export { PROJECTION_KEY, REVIEW_PROMPT_COMMAND, REVIEW_PROMPT_RECORD, UNATTENDED_COMMAND, UNATTENDED_RECORD, type GuardSessionView, } from './session-state.js';
5
+ export declare const name = "vulcan-decision-guard";
6
+ export declare const inject: string[];
7
+ /**
8
+ * How users turn the guard on.
9
+ *
10
+ * - `auto-preset`: register dsh's single `auto` permission preset; sessions that select it are
11
+ * judged and run with the preset's Full access sandbox.
12
+ * - `standalone`: judge every session on top of whatever preset it selected.
13
+ */
14
+ export type Mode = 'auto-preset' | 'standalone';
15
+ /**
16
+ * Where verdicts come from: OpenVulcan's cloud endpoints (the default, needing only a sign-in), or
17
+ * a model on this machine run by an installed runtime pack.
18
+ */
19
+ export type Backend = 'cloud' | 'local';
20
+ /**
21
+ * Which LLM reviews calls the decision model did not allow.
22
+ *
23
+ * - `session`: the session's current model.
24
+ * - `custom`: `reviewProvider` and `reviewModel`.
25
+ * - `off`: no LLM review; the user is asked, or the call is refused when nobody can be asked.
26
+ */
27
+ export type Review = 'session' | 'custom' | 'off';
28
+ /**
29
+ * Every field is volatile: dsh's settings forms expose only volatile fields, and a change applies
30
+ * without restarting the plugin. Read each value when an operation starts.
31
+ */
32
+ export interface Config {
33
+ mode: Volatile<Mode>;
34
+ backend: Volatile<Backend>;
35
+ /** Cloud model id; empty uses the first model OpenVulcan lists for the account. */
36
+ cloudModel: Volatile<string>;
37
+ /** Endpoint id the user locked; absent uses the measured best one. */
38
+ cloudEndpoint: Volatile<string | undefined>;
39
+ /** Installed runtime pack for the local backend. */
40
+ localPack: Volatile<PackId | undefined>;
41
+ /** Installed model id for the local backend. */
42
+ localModel: Volatile<string | undefined>;
43
+ /** Download host for runtime packs: the official hosts, or mirrors in China. */
44
+ downloadSource: Volatile<DownloadSource>;
45
+ review: Volatile<Review>;
46
+ reviewProvider: Volatile<string | undefined>;
47
+ reviewModel: Volatile<string | undefined>;
48
+ allowRules: Volatile<string>;
49
+ denyRules: Volatile<string>;
50
+ forbidRules: Volatile<string>;
51
+ llmOverridesBlock: Volatile<boolean>;
52
+ /** System default additional review prompt while the user is present; a session may replace it. */
53
+ reviewPrompt: Volatile<string>;
54
+ /** Deny policy offered when a session turns unattended mode on; the session keeps what the user confirmed. */
55
+ unattendedPolicy: Volatile<string>;
56
+ /** Whether calls are kept in the local decision log. */
57
+ recordDecisions: Volatile<boolean>;
58
+ /** Seconds an approval prompt waits before the call is refused; 0 waits for the user. */
59
+ askTimeout: Volatile<number>;
60
+ crossProjectWrites: Volatile<DecisionOptions['cross_project_writes']>;
61
+ databaseReset: Volatile<DecisionOptions['database_reset']>;
62
+ projectReset: Volatile<DecisionOptions['project_reset']>;
63
+ }
64
+ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
65
+ mode: Schema<"auto-preset" | "standalone", "auto-preset" | "standalone", "volatile-defined">;
66
+ backend: Schema<"local" | "cloud", "local" | "cloud", "volatile-defined">;
67
+ cloudModel: Schema<string, string, "volatile-defined">;
68
+ cloudEndpoint: Schema<string, string, "volatile">;
69
+ localPack: Schema<"onnx-cpu" | "onnx-cuda" | "torch-cpu" | "torch-cu128", "onnx-cpu" | "onnx-cuda" | "torch-cpu" | "torch-cu128", "volatile">;
70
+ localModel: Schema<string, string, "volatile">;
71
+ downloadSource: Schema<"cn" | "official", "cn" | "official", "volatile-defined">;
72
+ review: Schema<"off" | "session" | "custom", "off" | "session" | "custom", "volatile-defined">;
73
+ reviewProvider: Schema<string, string, "volatile">;
74
+ reviewModel: Schema<string, string, "volatile">;
75
+ allowRules: Schema<string, string, "volatile-defined">;
76
+ denyRules: Schema<string, string, "volatile-defined">;
77
+ forbidRules: Schema<string, string, "volatile-defined">;
78
+ llmOverridesBlock: Schema<boolean, boolean, "volatile-defined">;
79
+ reviewPrompt: Schema<string, string, "volatile-defined">;
80
+ unattendedPolicy: Schema<string, string, "volatile-defined">;
81
+ recordDecisions: Schema<boolean, boolean, "volatile-defined">;
82
+ askTimeout: Schema<number, number, "volatile-defined">;
83
+ crossProjectWrites: Schema<"allow" | "review", "allow" | "review", "volatile-defined">;
84
+ databaseReset: Schema<"allow" | "confirm", "allow" | "confirm", "volatile-defined">;
85
+ projectReset: Schema<"allow" | "confirm", "allow" | "confirm", "volatile-defined">;
86
+ }>>, Schemastery.ObjectT<NoInfer<{
87
+ mode: Schema<"auto-preset" | "standalone", "auto-preset" | "standalone", "volatile-defined">;
88
+ backend: Schema<"local" | "cloud", "local" | "cloud", "volatile-defined">;
89
+ cloudModel: Schema<string, string, "volatile-defined">;
90
+ cloudEndpoint: Schema<string, string, "volatile">;
91
+ localPack: Schema<"onnx-cpu" | "onnx-cuda" | "torch-cpu" | "torch-cu128", "onnx-cpu" | "onnx-cuda" | "torch-cpu" | "torch-cu128", "volatile">;
92
+ localModel: Schema<string, string, "volatile">;
93
+ downloadSource: Schema<"cn" | "official", "cn" | "official", "volatile-defined">;
94
+ review: Schema<"off" | "session" | "custom", "off" | "session" | "custom", "volatile-defined">;
95
+ reviewProvider: Schema<string, string, "volatile">;
96
+ reviewModel: Schema<string, string, "volatile">;
97
+ allowRules: Schema<string, string, "volatile-defined">;
98
+ denyRules: Schema<string, string, "volatile-defined">;
99
+ forbidRules: Schema<string, string, "volatile-defined">;
100
+ llmOverridesBlock: Schema<boolean, boolean, "volatile-defined">;
101
+ reviewPrompt: Schema<string, string, "volatile-defined">;
102
+ unattendedPolicy: Schema<string, string, "volatile-defined">;
103
+ recordDecisions: Schema<boolean, boolean, "volatile-defined">;
104
+ askTimeout: Schema<number, number, "volatile-defined">;
105
+ crossProjectWrites: Schema<"allow" | "review", "allow" | "review", "volatile-defined">;
106
+ databaseReset: Schema<"allow" | "confirm", "allow" | "confirm", "volatile-defined">;
107
+ projectReset: Schema<"allow" | "confirm", "allow" | "confirm", "volatile-defined">;
108
+ }>>, "plain">;
109
+ /**
110
+ * Key of the approval prompt's `displayReason` entry that carries {@link PromptPayload} as JSON.
111
+ * dsh resolves the prompt text by locale and never reads this key; this plugin's composer card
112
+ * does. Also restated in `client/index.tsx`.
113
+ */
114
+ export declare const PROMPT_KEY = "x-vulcan-decision";
115
+ /** What this plugin's approval card reads from {@link PROMPT_KEY}. */
116
+ export interface PromptPayload {
117
+ readonly v: 1;
118
+ readonly stage: 'review' | 'block' | 'unjudged';
119
+ readonly review?: 'review' | 'deny' | 'error';
120
+ readonly reviewReason?: string;
121
+ readonly focus: 'allow' | 'reject';
122
+ readonly intent?: string;
123
+ /** The call's command or arguments, shortened. */
124
+ readonly preview: string;
125
+ /** Countdown length; absent when the prompt waits for the user. */
126
+ readonly timeoutMs?: number;
127
+ }
128
+ /** Install the Vulcan Decision gate and, in `auto-preset` mode, the Auto preset. */
129
+ export declare function apply(ctx: Context, config: Config): Promise<void>;