@neuroverseos/governance 0.4.0 → 0.4.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 (108) hide show
  1. package/dist/adapters/autoresearch.d.cts +2 -1
  2. package/dist/adapters/autoresearch.d.ts +2 -1
  3. package/dist/adapters/autoresearch.js +2 -2
  4. package/dist/adapters/deep-agents.d.cts +3 -2
  5. package/dist/adapters/deep-agents.d.ts +3 -2
  6. package/dist/adapters/deep-agents.js +2 -2
  7. package/dist/adapters/express.d.cts +2 -1
  8. package/dist/adapters/express.d.ts +2 -1
  9. package/dist/adapters/express.js +2 -2
  10. package/dist/adapters/github.cjs +1697 -0
  11. package/dist/adapters/github.d.cts +225 -0
  12. package/dist/adapters/github.d.ts +225 -0
  13. package/dist/adapters/github.js +27 -0
  14. package/dist/adapters/index.cjs +66 -1
  15. package/dist/adapters/index.d.cts +4 -278
  16. package/dist/adapters/index.d.ts +4 -278
  17. package/dist/adapters/index.js +18 -18
  18. package/dist/adapters/langchain.d.cts +3 -2
  19. package/dist/adapters/langchain.d.ts +3 -2
  20. package/dist/adapters/langchain.js +2 -2
  21. package/dist/adapters/mentraos.cjs +2181 -0
  22. package/dist/adapters/mentraos.d.cts +319 -0
  23. package/dist/adapters/mentraos.d.ts +319 -0
  24. package/dist/{mentraos-YFS7FMJH.js → adapters/mentraos.js} +6 -6
  25. package/dist/adapters/openai.d.cts +3 -2
  26. package/dist/adapters/openai.d.ts +3 -2
  27. package/dist/adapters/openai.js +2 -2
  28. package/dist/adapters/openclaw.d.cts +3 -2
  29. package/dist/adapters/openclaw.d.ts +3 -2
  30. package/dist/adapters/openclaw.js +2 -2
  31. package/dist/{add-LYHDZ5RL.js → add-XSANI3FK.js} +1 -1
  32. package/dist/bootstrap-contract-DcV6t-8M.d.cts +216 -0
  33. package/dist/bootstrap-contract-DcV6t-8M.d.ts +216 -0
  34. package/dist/{build-THUEYMVT.js → build-EGBGZFIJ.js} +5 -5
  35. package/dist/{chunk-MFKHTE5R.js → chunk-3AYKQHYI.js} +1 -1
  36. package/dist/chunk-3S5AD4AB.js +421 -0
  37. package/dist/{chunk-V4FZHJQX.js → chunk-A7SHG75T.js} +1 -1
  38. package/dist/{chunk-JKGPSFGH.js → chunk-AV7XJJWK.js} +1 -1
  39. package/dist/{chunk-Y6WXAPKY.js → chunk-DA5MHFRR.js} +1 -1
  40. package/dist/{chunk-7D7PZLB7.js → chunk-FS2UUJJO.js} +3 -3
  41. package/dist/{chunk-TD5GKIHP.js → chunk-FVOGUCB6.js} +1 -1
  42. package/dist/{chunk-APU4OZIP.js → chunk-GTPV2XGO.js} +67 -2
  43. package/dist/{chunk-BXLTEUS4.js → chunk-I4RTIMLX.js} +2 -2
  44. package/dist/{chunk-5JUZ4HL7.js → chunk-J2IZBHXJ.js} +3 -3
  45. package/dist/{chunk-YNYCQECH.js → chunk-QMVQ6KPL.js} +1 -1
  46. package/dist/{chunk-25XHSTPT.js → chunk-RDA7ISWC.js} +1 -1
  47. package/dist/{chunk-DWHUZUEY.js → chunk-YJ34R5NB.js} +1 -1
  48. package/dist/{chunk-UTH7OXTM.js → chunk-ZEIT2QLM.js} +3 -3
  49. package/dist/cli/neuroverse.cjs +580 -28
  50. package/dist/cli/neuroverse.js +21 -21
  51. package/dist/cli/plan.js +2 -2
  52. package/dist/cli/run.js +2 -2
  53. package/dist/{demo-66MMJTEH.js → demo-6OQYWRR6.js} +3 -3
  54. package/dist/{derive-5LOMN7GO.js → derive-7Y7YWVLU.js} +4 -4
  55. package/dist/{doctor-WIO4FLA3.js → doctor-EC5OYTI3.js} +3 -2
  56. package/dist/engine/bootstrap-emitter.cjs +241 -0
  57. package/dist/engine/bootstrap-emitter.d.cts +27 -0
  58. package/dist/engine/bootstrap-emitter.d.ts +27 -0
  59. package/dist/{bootstrap-emitter-GIMOJFOC.js → engine/bootstrap-emitter.js} +2 -2
  60. package/dist/engine/bootstrap-parser.cjs +560 -0
  61. package/dist/engine/bootstrap-parser.d.cts +96 -0
  62. package/dist/engine/bootstrap-parser.d.ts +96 -0
  63. package/dist/{bootstrap-parser-LBLGVEMU.js → engine/bootstrap-parser.js} +2 -2
  64. package/dist/engine/guard-engine.cjs +1116 -0
  65. package/dist/engine/guard-engine.d.cts +60 -0
  66. package/dist/engine/guard-engine.d.ts +60 -0
  67. package/dist/{guard-engine-N7TUIUU7.js → engine/guard-engine.js} +3 -3
  68. package/dist/engine/simulate-engine.cjs +390 -0
  69. package/dist/engine/simulate-engine.d.cts +105 -0
  70. package/dist/engine/simulate-engine.d.ts +105 -0
  71. package/dist/engine/simulate-engine.js +9 -0
  72. package/dist/{equity-penalties-WWC7UDQD.js → equity-penalties-NVBAB5WL.js} +2 -2
  73. package/dist/{explain-MUSGDT67.js → explain-HDFN4ION.js} +1 -1
  74. package/dist/{guard-W3BMQPBJ.js → guard-6KSCWT2W.js} +2 -2
  75. package/dist/{guard-contract-CLBbTGK_.d.ts → guard-contract-ddiIPlOg.d.cts} +2 -369
  76. package/dist/{guard-contract-CLBbTGK_.d.cts → guard-contract-q6HJAq3Q.d.ts} +2 -369
  77. package/dist/{improve-PJDAWW4Q.js → improve-2PWGGO5B.js} +3 -3
  78. package/dist/index.cjs +452 -0
  79. package/dist/index.d.cts +12 -492
  80. package/dist/index.d.ts +12 -492
  81. package/dist/index.js +75 -54
  82. package/dist/{lens-IP6GIZ2Q.js → lens-MHMUDCMQ.js} +92 -25
  83. package/dist/{mcp-server-OG3PPVD2.js → mcp-server-TNIWZ7B5.js} +2 -2
  84. package/dist/{playground-4BK2XQ47.js → playground-3FLDGBET.js} +2 -2
  85. package/dist/{redteam-BRZALBPP.js → redteam-HV6LMKEH.js} +2 -2
  86. package/dist/{session-SGRUT2UH.js → session-XZP2754M.js} +2 -2
  87. package/dist/{shared-CwGpPheR.d.ts → shared-DAzdfWtU.d.ts} +1 -1
  88. package/dist/{shared-BGzmYP5g.d.cts → shared-PpalGKxc.d.cts} +1 -1
  89. package/dist/{simulate-FGXKIH7V.js → simulate-VT437EEL.js} +2 -2
  90. package/dist/spatial/index.cjs +682 -0
  91. package/dist/spatial/index.d.cts +517 -0
  92. package/dist/spatial/index.d.ts +517 -0
  93. package/dist/spatial/index.js +633 -0
  94. package/dist/{test-PT44BSYG.js → test-4WTX6RKQ.js} +2 -2
  95. package/dist/types.cjs +18 -0
  96. package/dist/types.d.cts +370 -0
  97. package/dist/types.d.ts +370 -0
  98. package/dist/types.js +0 -0
  99. package/dist/{validate-Q5O5TGLT.js → validate-M52DX22Y.js} +1 -1
  100. package/dist/{world-V52ZMH26.js → world-O4HTQPDP.js} +1 -1
  101. package/dist/{world-loader-C4D3VPP3.js → world-loader-YTYFOP7D.js} +1 -1
  102. package/dist/worlds/mentraos-spatial.nv-world.md +68 -0
  103. package/package.json +52 -3
  104. package/dist/{behavioral-SPWPGYXL.js → behavioral-SLW7ALEK.js} +3 -3
  105. package/dist/{bootstrap-IP5QMC3Q.js → bootstrap-2OW5ZLBL.js} +3 -3
  106. package/dist/{chunk-7QIAF377.js → chunk-CYDMUJVZ.js} +0 -0
  107. package/dist/{chunk-QZ666FCV.js → chunk-FHXXD2TI.js} +6 -6
  108. package/dist/{configure-ai-5MP5DWTT.js → configure-ai-LL3VAPQW.js} +3 -3
@@ -0,0 +1,225 @@
1
+ import { G as GuardVerdict, a as GuardEvent, b as GuardEngineOptions, P as PlanDefinition, c as PlanProgress } from '../guard-contract-ddiIPlOg.cjs';
2
+ import { WorldDefinition } from '../types.cjs';
3
+ import { G as GovernanceBlockedError } from '../shared-PpalGKxc.cjs';
4
+
5
+ /**
6
+ * NeuroVerse Adapter — GitHub
7
+ *
8
+ * Governance middleware for GitHub-driven workflows. Evaluates GitHub events
9
+ * (PRs, issues, comments, pushes, releases, workflow runs) against world rules
10
+ * before allowing actions to proceed.
11
+ *
12
+ * Two modes:
13
+ * 1. Webhook mode — receives GitHub webhook payloads, evaluates, returns verdict
14
+ * 2. Action mode — wraps Octokit/GitHub API calls with governance checks
15
+ *
16
+ * Usage (Webhook):
17
+ * import { createGitHubWebhookHandler } from 'neuroverse-governance/adapters/github';
18
+ *
19
+ * const handler = await createGitHubWebhookHandler('./world/');
20
+ * app.post('/webhook', async (req, res) => {
21
+ * const verdict = handler.evaluate(req.headers['x-github-event'], req.body);
22
+ * if (verdict.status === 'BLOCK') return res.status(403).json({ blocked: true });
23
+ * // proceed with webhook processing...
24
+ * });
25
+ *
26
+ * Usage (Action):
27
+ * import { createGitHubGovernor } from 'neuroverse-governance/adapters/github';
28
+ *
29
+ * const gov = await createGitHubGovernor('./world/');
30
+ *
31
+ * // Before merging a PR:
32
+ * const verdict = gov.evaluate({
33
+ * action: 'merge_pull_request',
34
+ * repository: 'myorg/myrepo',
35
+ * ref: 'refs/heads/main',
36
+ * actor: 'dependabot[bot]',
37
+ * metadata: { pr_number: 42, labels: ['auto-merge'] },
38
+ * });
39
+ *
40
+ * if (verdict.status === 'ALLOW') await octokit.pulls.merge(...);
41
+ */
42
+
43
+ /** GitHub webhook event names the adapter understands. */
44
+ type GitHubWebhookEvent = 'push' | 'pull_request' | 'pull_request_review' | 'issues' | 'issue_comment' | 'release' | 'workflow_run' | 'workflow_dispatch' | 'check_run' | 'check_suite' | 'deployment' | 'deployment_status' | 'create' | 'delete' | 'fork' | 'member' | 'repository' | 'status' | string;
45
+ /** A structured GitHub action to evaluate against governance. */
46
+ interface GitHubAction {
47
+ /** What the actor wants to do (e.g., 'merge_pull_request', 'push_to_main', 'create_release'). */
48
+ action: string;
49
+ /** Full repository name (e.g., 'myorg/myrepo'). */
50
+ repository: string;
51
+ /** Git ref involved (e.g., 'refs/heads/main', 'refs/tags/v1.0.0'). */
52
+ ref?: string;
53
+ /** GitHub username or bot performing the action. */
54
+ actor?: string;
55
+ /** Branch being targeted (extracted from ref or PR base). */
56
+ branch?: string;
57
+ /** Additional context for guard evaluation. */
58
+ metadata?: Record<string, unknown>;
59
+ }
60
+ /** Result of evaluating a GitHub action. */
61
+ interface GitHubGovernanceResult {
62
+ /** The guard verdict. */
63
+ verdict: GuardVerdict;
64
+ /** The GuardEvent that was evaluated (for audit/logging). */
65
+ event: GuardEvent;
66
+ /** The original action that triggered evaluation. */
67
+ action: GitHubAction;
68
+ }
69
+ /** Result of evaluating a webhook payload. */
70
+ interface WebhookGovernanceResult {
71
+ /** The guard verdict. */
72
+ verdict: GuardVerdict;
73
+ /** The GuardEvent that was evaluated. */
74
+ event: GuardEvent;
75
+ /** The webhook event type. */
76
+ webhookEvent: string;
77
+ /** The webhook action (e.g., 'opened', 'closed', 'merged'). */
78
+ webhookAction?: string;
79
+ }
80
+ interface GitHubGovernorOptions {
81
+ /** Include full evaluation trace in verdicts. Default: false. */
82
+ trace?: boolean;
83
+ /** Enforcement level override. */
84
+ level?: 'basic' | 'standard' | 'strict';
85
+ /** Called for every evaluation (logging/audit hook). */
86
+ onEvaluate?: (verdict: GuardVerdict, event: GuardEvent, action: GitHubAction) => void;
87
+ /** Custom mapping from GitHubAction to GuardEvent. */
88
+ mapAction?: (action: GitHubAction) => GuardEvent;
89
+ /** Active plan overlay for task-scoped governance. */
90
+ plan?: PlanDefinition;
91
+ /** Called when plan progress changes. */
92
+ onPlanProgress?: (progress: PlanProgress) => void;
93
+ /** Called when all plan steps are completed. */
94
+ onPlanComplete?: () => void;
95
+ /** Protected branches that require strict governance. Default: ['main', 'master', 'production']. */
96
+ protectedBranches?: string[];
97
+ /** Actors (bots, users) with restricted permissions. */
98
+ restrictedActors?: string[];
99
+ }
100
+ interface WebhookHandlerOptions extends GitHubGovernorOptions {
101
+ /** Webhook secret for signature verification (HMAC-SHA256). */
102
+ webhookSecret?: string;
103
+ /** Custom mapping from webhook payload to GitHubAction. */
104
+ mapWebhook?: (eventType: string, payload: Record<string, unknown>) => GitHubAction;
105
+ }
106
+ declare class GitHubGovernanceBlockedError extends GovernanceBlockedError {
107
+ readonly action: GitHubAction;
108
+ constructor(verdict: GuardVerdict, action: GitHubAction);
109
+ }
110
+ /**
111
+ * Evaluates GitHub actions against a NeuroVerse world.
112
+ * Use this when you're making GitHub API calls and want governance
113
+ * to approve/block them before execution.
114
+ */
115
+ declare class GitHubGovernor {
116
+ private world;
117
+ private options;
118
+ engineOptions: GuardEngineOptions;
119
+ activePlan?: PlanDefinition;
120
+ private protectedBranches;
121
+ private restrictedActors;
122
+ private mapFn;
123
+ constructor(world: WorldDefinition, options?: GitHubGovernorOptions);
124
+ /**
125
+ * Evaluate a GitHub action against governance rules.
126
+ * Returns a full result with verdict, event, and the original action.
127
+ */
128
+ evaluate(action: GitHubAction): GitHubGovernanceResult;
129
+ /**
130
+ * Evaluate and enforce — throws GitHubGovernanceBlockedError on BLOCK/PAUSE.
131
+ * Use this as a gate before executing GitHub API calls.
132
+ */
133
+ enforce(action: GitHubAction): GitHubGovernanceResult;
134
+ /**
135
+ * Check if pushing to a branch is allowed.
136
+ * Convenience method for the most common governance check.
137
+ */
138
+ canPush(repository: string, branch: string, actor?: string): GuardVerdict;
139
+ /**
140
+ * Check if merging a PR is allowed.
141
+ */
142
+ canMerge(repository: string, targetBranch: string, prNumber: number, actor?: string, labels?: string[]): GuardVerdict;
143
+ /**
144
+ * Check if creating a release is allowed.
145
+ */
146
+ canRelease(repository: string, tag: string, actor?: string, prerelease?: boolean): GuardVerdict;
147
+ /**
148
+ * Check if deploying to an environment is allowed.
149
+ */
150
+ canDeploy(repository: string, environment: string, ref?: string, actor?: string): GuardVerdict;
151
+ }
152
+ /**
153
+ * Evaluates incoming GitHub webhook payloads against a NeuroVerse world.
154
+ * Use this in your webhook endpoint to govern repository events.
155
+ */
156
+ declare class GitHubWebhookHandler {
157
+ private governor;
158
+ private mapWebhookFn;
159
+ private webhookSecret?;
160
+ constructor(world: WorldDefinition, options?: WebhookHandlerOptions);
161
+ /**
162
+ * Evaluate a webhook payload.
163
+ *
164
+ * @param eventType - The X-GitHub-Event header value
165
+ * @param payload - The parsed webhook body
166
+ */
167
+ evaluate(eventType: string, payload: Record<string, unknown>): WebhookGovernanceResult;
168
+ /**
169
+ * Evaluate and enforce — throws on BLOCK/PAUSE.
170
+ */
171
+ enforce(eventType: string, payload: Record<string, unknown>): WebhookGovernanceResult;
172
+ /** Access the underlying governor for direct action evaluation. */
173
+ getGovernor(): GitHubGovernor;
174
+ /** Get the configured webhook secret (for signature verification in your server). */
175
+ getWebhookSecret(): string | undefined;
176
+ }
177
+ /**
178
+ * Guard evaluation result formatted for GitHub Actions output.
179
+ * Set step outputs and write to $GITHUB_OUTPUT.
180
+ */
181
+ interface ActionsOutput {
182
+ /** 'allowed' or 'blocked' or 'paused' — for use in step conditions */
183
+ governance_status: string;
184
+ /** The full verdict status */
185
+ verdict_status: string;
186
+ /** Reason for block/pause (empty string if allowed) */
187
+ reason: string;
188
+ /** Matched rule ID (empty string if none) */
189
+ rule_id: string;
190
+ /** Formatted as GITHUB_OUTPUT lines */
191
+ outputLines: string;
192
+ }
193
+ /**
194
+ * Format a verdict for GitHub Actions step outputs.
195
+ * Write the .outputLines to $GITHUB_OUTPUT in your action.
196
+ *
197
+ * Usage in a GitHub Action:
198
+ * const result = governor.evaluate(action);
199
+ * const output = formatForActions(result.verdict);
200
+ * fs.appendFileSync(process.env.GITHUB_OUTPUT!, output.outputLines);
201
+ */
202
+ declare function formatForActions(verdict: GuardVerdict): ActionsOutput;
203
+ /**
204
+ * Create a PR comment body from a governance verdict.
205
+ * Useful for posting governance status as a PR comment.
206
+ */
207
+ declare function formatPRComment(verdict: GuardVerdict, action: GitHubAction): string;
208
+ /**
209
+ * Create a GitHub Governor from a world path.
210
+ */
211
+ declare function createGitHubGovernor(worldPath: string, options?: GitHubGovernorOptions): Promise<GitHubGovernor>;
212
+ /**
213
+ * Create a GitHub Governor from a pre-loaded world.
214
+ */
215
+ declare function createGitHubGovernorFromWorld(world: WorldDefinition, options?: GitHubGovernorOptions): GitHubGovernor;
216
+ /**
217
+ * Create a GitHub Webhook Handler from a world path.
218
+ */
219
+ declare function createGitHubWebhookHandler(worldPath: string, options?: WebhookHandlerOptions): Promise<GitHubWebhookHandler>;
220
+ /**
221
+ * Create a GitHub Webhook Handler from a pre-loaded world.
222
+ */
223
+ declare function createGitHubWebhookHandlerFromWorld(world: WorldDefinition, options?: WebhookHandlerOptions): GitHubWebhookHandler;
224
+
225
+ export { type ActionsOutput, type GitHubAction, GitHubGovernanceBlockedError, type GitHubGovernanceResult, GitHubGovernor, type GitHubGovernorOptions, type GitHubWebhookEvent, GitHubWebhookHandler, type WebhookGovernanceResult, type WebhookHandlerOptions, createGitHubGovernor, createGitHubGovernorFromWorld, createGitHubWebhookHandler, createGitHubWebhookHandlerFromWorld, formatForActions, formatPRComment };
@@ -0,0 +1,225 @@
1
+ import { G as GuardVerdict, a as GuardEvent, b as GuardEngineOptions, P as PlanDefinition, c as PlanProgress } from '../guard-contract-q6HJAq3Q.js';
2
+ import { WorldDefinition } from '../types.js';
3
+ import { G as GovernanceBlockedError } from '../shared-DAzdfWtU.js';
4
+
5
+ /**
6
+ * NeuroVerse Adapter — GitHub
7
+ *
8
+ * Governance middleware for GitHub-driven workflows. Evaluates GitHub events
9
+ * (PRs, issues, comments, pushes, releases, workflow runs) against world rules
10
+ * before allowing actions to proceed.
11
+ *
12
+ * Two modes:
13
+ * 1. Webhook mode — receives GitHub webhook payloads, evaluates, returns verdict
14
+ * 2. Action mode — wraps Octokit/GitHub API calls with governance checks
15
+ *
16
+ * Usage (Webhook):
17
+ * import { createGitHubWebhookHandler } from 'neuroverse-governance/adapters/github';
18
+ *
19
+ * const handler = await createGitHubWebhookHandler('./world/');
20
+ * app.post('/webhook', async (req, res) => {
21
+ * const verdict = handler.evaluate(req.headers['x-github-event'], req.body);
22
+ * if (verdict.status === 'BLOCK') return res.status(403).json({ blocked: true });
23
+ * // proceed with webhook processing...
24
+ * });
25
+ *
26
+ * Usage (Action):
27
+ * import { createGitHubGovernor } from 'neuroverse-governance/adapters/github';
28
+ *
29
+ * const gov = await createGitHubGovernor('./world/');
30
+ *
31
+ * // Before merging a PR:
32
+ * const verdict = gov.evaluate({
33
+ * action: 'merge_pull_request',
34
+ * repository: 'myorg/myrepo',
35
+ * ref: 'refs/heads/main',
36
+ * actor: 'dependabot[bot]',
37
+ * metadata: { pr_number: 42, labels: ['auto-merge'] },
38
+ * });
39
+ *
40
+ * if (verdict.status === 'ALLOW') await octokit.pulls.merge(...);
41
+ */
42
+
43
+ /** GitHub webhook event names the adapter understands. */
44
+ type GitHubWebhookEvent = 'push' | 'pull_request' | 'pull_request_review' | 'issues' | 'issue_comment' | 'release' | 'workflow_run' | 'workflow_dispatch' | 'check_run' | 'check_suite' | 'deployment' | 'deployment_status' | 'create' | 'delete' | 'fork' | 'member' | 'repository' | 'status' | string;
45
+ /** A structured GitHub action to evaluate against governance. */
46
+ interface GitHubAction {
47
+ /** What the actor wants to do (e.g., 'merge_pull_request', 'push_to_main', 'create_release'). */
48
+ action: string;
49
+ /** Full repository name (e.g., 'myorg/myrepo'). */
50
+ repository: string;
51
+ /** Git ref involved (e.g., 'refs/heads/main', 'refs/tags/v1.0.0'). */
52
+ ref?: string;
53
+ /** GitHub username or bot performing the action. */
54
+ actor?: string;
55
+ /** Branch being targeted (extracted from ref or PR base). */
56
+ branch?: string;
57
+ /** Additional context for guard evaluation. */
58
+ metadata?: Record<string, unknown>;
59
+ }
60
+ /** Result of evaluating a GitHub action. */
61
+ interface GitHubGovernanceResult {
62
+ /** The guard verdict. */
63
+ verdict: GuardVerdict;
64
+ /** The GuardEvent that was evaluated (for audit/logging). */
65
+ event: GuardEvent;
66
+ /** The original action that triggered evaluation. */
67
+ action: GitHubAction;
68
+ }
69
+ /** Result of evaluating a webhook payload. */
70
+ interface WebhookGovernanceResult {
71
+ /** The guard verdict. */
72
+ verdict: GuardVerdict;
73
+ /** The GuardEvent that was evaluated. */
74
+ event: GuardEvent;
75
+ /** The webhook event type. */
76
+ webhookEvent: string;
77
+ /** The webhook action (e.g., 'opened', 'closed', 'merged'). */
78
+ webhookAction?: string;
79
+ }
80
+ interface GitHubGovernorOptions {
81
+ /** Include full evaluation trace in verdicts. Default: false. */
82
+ trace?: boolean;
83
+ /** Enforcement level override. */
84
+ level?: 'basic' | 'standard' | 'strict';
85
+ /** Called for every evaluation (logging/audit hook). */
86
+ onEvaluate?: (verdict: GuardVerdict, event: GuardEvent, action: GitHubAction) => void;
87
+ /** Custom mapping from GitHubAction to GuardEvent. */
88
+ mapAction?: (action: GitHubAction) => GuardEvent;
89
+ /** Active plan overlay for task-scoped governance. */
90
+ plan?: PlanDefinition;
91
+ /** Called when plan progress changes. */
92
+ onPlanProgress?: (progress: PlanProgress) => void;
93
+ /** Called when all plan steps are completed. */
94
+ onPlanComplete?: () => void;
95
+ /** Protected branches that require strict governance. Default: ['main', 'master', 'production']. */
96
+ protectedBranches?: string[];
97
+ /** Actors (bots, users) with restricted permissions. */
98
+ restrictedActors?: string[];
99
+ }
100
+ interface WebhookHandlerOptions extends GitHubGovernorOptions {
101
+ /** Webhook secret for signature verification (HMAC-SHA256). */
102
+ webhookSecret?: string;
103
+ /** Custom mapping from webhook payload to GitHubAction. */
104
+ mapWebhook?: (eventType: string, payload: Record<string, unknown>) => GitHubAction;
105
+ }
106
+ declare class GitHubGovernanceBlockedError extends GovernanceBlockedError {
107
+ readonly action: GitHubAction;
108
+ constructor(verdict: GuardVerdict, action: GitHubAction);
109
+ }
110
+ /**
111
+ * Evaluates GitHub actions against a NeuroVerse world.
112
+ * Use this when you're making GitHub API calls and want governance
113
+ * to approve/block them before execution.
114
+ */
115
+ declare class GitHubGovernor {
116
+ private world;
117
+ private options;
118
+ engineOptions: GuardEngineOptions;
119
+ activePlan?: PlanDefinition;
120
+ private protectedBranches;
121
+ private restrictedActors;
122
+ private mapFn;
123
+ constructor(world: WorldDefinition, options?: GitHubGovernorOptions);
124
+ /**
125
+ * Evaluate a GitHub action against governance rules.
126
+ * Returns a full result with verdict, event, and the original action.
127
+ */
128
+ evaluate(action: GitHubAction): GitHubGovernanceResult;
129
+ /**
130
+ * Evaluate and enforce — throws GitHubGovernanceBlockedError on BLOCK/PAUSE.
131
+ * Use this as a gate before executing GitHub API calls.
132
+ */
133
+ enforce(action: GitHubAction): GitHubGovernanceResult;
134
+ /**
135
+ * Check if pushing to a branch is allowed.
136
+ * Convenience method for the most common governance check.
137
+ */
138
+ canPush(repository: string, branch: string, actor?: string): GuardVerdict;
139
+ /**
140
+ * Check if merging a PR is allowed.
141
+ */
142
+ canMerge(repository: string, targetBranch: string, prNumber: number, actor?: string, labels?: string[]): GuardVerdict;
143
+ /**
144
+ * Check if creating a release is allowed.
145
+ */
146
+ canRelease(repository: string, tag: string, actor?: string, prerelease?: boolean): GuardVerdict;
147
+ /**
148
+ * Check if deploying to an environment is allowed.
149
+ */
150
+ canDeploy(repository: string, environment: string, ref?: string, actor?: string): GuardVerdict;
151
+ }
152
+ /**
153
+ * Evaluates incoming GitHub webhook payloads against a NeuroVerse world.
154
+ * Use this in your webhook endpoint to govern repository events.
155
+ */
156
+ declare class GitHubWebhookHandler {
157
+ private governor;
158
+ private mapWebhookFn;
159
+ private webhookSecret?;
160
+ constructor(world: WorldDefinition, options?: WebhookHandlerOptions);
161
+ /**
162
+ * Evaluate a webhook payload.
163
+ *
164
+ * @param eventType - The X-GitHub-Event header value
165
+ * @param payload - The parsed webhook body
166
+ */
167
+ evaluate(eventType: string, payload: Record<string, unknown>): WebhookGovernanceResult;
168
+ /**
169
+ * Evaluate and enforce — throws on BLOCK/PAUSE.
170
+ */
171
+ enforce(eventType: string, payload: Record<string, unknown>): WebhookGovernanceResult;
172
+ /** Access the underlying governor for direct action evaluation. */
173
+ getGovernor(): GitHubGovernor;
174
+ /** Get the configured webhook secret (for signature verification in your server). */
175
+ getWebhookSecret(): string | undefined;
176
+ }
177
+ /**
178
+ * Guard evaluation result formatted for GitHub Actions output.
179
+ * Set step outputs and write to $GITHUB_OUTPUT.
180
+ */
181
+ interface ActionsOutput {
182
+ /** 'allowed' or 'blocked' or 'paused' — for use in step conditions */
183
+ governance_status: string;
184
+ /** The full verdict status */
185
+ verdict_status: string;
186
+ /** Reason for block/pause (empty string if allowed) */
187
+ reason: string;
188
+ /** Matched rule ID (empty string if none) */
189
+ rule_id: string;
190
+ /** Formatted as GITHUB_OUTPUT lines */
191
+ outputLines: string;
192
+ }
193
+ /**
194
+ * Format a verdict for GitHub Actions step outputs.
195
+ * Write the .outputLines to $GITHUB_OUTPUT in your action.
196
+ *
197
+ * Usage in a GitHub Action:
198
+ * const result = governor.evaluate(action);
199
+ * const output = formatForActions(result.verdict);
200
+ * fs.appendFileSync(process.env.GITHUB_OUTPUT!, output.outputLines);
201
+ */
202
+ declare function formatForActions(verdict: GuardVerdict): ActionsOutput;
203
+ /**
204
+ * Create a PR comment body from a governance verdict.
205
+ * Useful for posting governance status as a PR comment.
206
+ */
207
+ declare function formatPRComment(verdict: GuardVerdict, action: GitHubAction): string;
208
+ /**
209
+ * Create a GitHub Governor from a world path.
210
+ */
211
+ declare function createGitHubGovernor(worldPath: string, options?: GitHubGovernorOptions): Promise<GitHubGovernor>;
212
+ /**
213
+ * Create a GitHub Governor from a pre-loaded world.
214
+ */
215
+ declare function createGitHubGovernorFromWorld(world: WorldDefinition, options?: GitHubGovernorOptions): GitHubGovernor;
216
+ /**
217
+ * Create a GitHub Webhook Handler from a world path.
218
+ */
219
+ declare function createGitHubWebhookHandler(worldPath: string, options?: WebhookHandlerOptions): Promise<GitHubWebhookHandler>;
220
+ /**
221
+ * Create a GitHub Webhook Handler from a pre-loaded world.
222
+ */
223
+ declare function createGitHubWebhookHandlerFromWorld(world: WorldDefinition, options?: WebhookHandlerOptions): GitHubWebhookHandler;
224
+
225
+ export { type ActionsOutput, type GitHubAction, GitHubGovernanceBlockedError, type GitHubGovernanceResult, GitHubGovernor, type GitHubGovernorOptions, type GitHubWebhookEvent, GitHubWebhookHandler, type WebhookGovernanceResult, type WebhookHandlerOptions, createGitHubGovernor, createGitHubGovernorFromWorld, createGitHubWebhookHandler, createGitHubWebhookHandlerFromWorld, formatForActions, formatPRComment };
@@ -0,0 +1,27 @@
1
+ import {
2
+ GitHubGovernanceBlockedError,
3
+ GitHubGovernor,
4
+ GitHubWebhookHandler,
5
+ createGitHubGovernor,
6
+ createGitHubGovernorFromWorld,
7
+ createGitHubWebhookHandler,
8
+ createGitHubWebhookHandlerFromWorld,
9
+ formatForActions,
10
+ formatPRComment
11
+ } from "../chunk-3S5AD4AB.js";
12
+ import "../chunk-5U2MQO5P.js";
13
+ import "../chunk-ZAF6JH23.js";
14
+ import "../chunk-I4RTIMLX.js";
15
+ import "../chunk-QLPTHTVB.js";
16
+ import "../chunk-QWGCMQQD.js";
17
+ export {
18
+ GitHubGovernanceBlockedError,
19
+ GitHubGovernor,
20
+ GitHubWebhookHandler,
21
+ createGitHubGovernor,
22
+ createGitHubGovernorFromWorld,
23
+ createGitHubWebhookHandler,
24
+ createGitHubWebhookHandlerFromWorld,
25
+ formatForActions,
26
+ formatPRComment
27
+ };
@@ -2779,6 +2779,7 @@ var MentraGovernedExecutor = class {
2779
2779
  _userRules;
2780
2780
  _emergencyOverride = false;
2781
2781
  _emergencyActivatedAt = null;
2782
+ _spatialSession = null;
2782
2783
  constructor(world, options = {}, userRules = DEFAULT_USER_RULES) {
2783
2784
  this.world = world;
2784
2785
  this.options = options;
@@ -2835,13 +2836,36 @@ var MentraGovernedExecutor = class {
2835
2836
  get emergencyActivatedAt() {
2836
2837
  return this._emergencyActivatedAt;
2837
2838
  }
2839
+ // ── Spatial Governance (optional) ────────────────────────────────────────
2840
+ /**
2841
+ * Attach a spatial session to this executor.
2842
+ *
2843
+ * When attached, intents are evaluated against the spatial context
2844
+ * (zone rules + handshake rules) AFTER user rules but BEFORE
2845
+ * hardware and platform checks. This is Layer 1.5.
2846
+ *
2847
+ * Pass null to detach (e.g., when leaving a zone).
2848
+ */
2849
+ setSpatialSession(session) {
2850
+ this._spatialSession = session;
2851
+ }
2852
+ /** Whether a spatial session is currently active */
2853
+ get hasSpatialSession() {
2854
+ return this._spatialSession !== null;
2855
+ }
2856
+ /** Get the current spatial session description */
2857
+ get spatialDescription() {
2858
+ return this._spatialSession?.description ?? null;
2859
+ }
2838
2860
  /**
2839
2861
  * Evaluate an intent against user rules + platform world.
2840
2862
  *
2841
2863
  * Three-layer evaluation:
2842
- * 0. Emergency override — if active, skip governance (layers 1 + 3),
2864
+ * 0. Emergency override — if active, skip governance (layers 1 + 1.5 + 3),
2843
2865
  * but STILL enforce platform constraints (layer 2)
2844
2866
  * 1. User rules check — personal governance override, can BLOCK or PAUSE
2867
+ * 1.5. Spatial governance — zone + handshake rules (optional, temporary)
2868
+ * ↑ ONLY ACTIVE when a spatial session is attached
2845
2869
  * 2. Hardware capability check — validates glasses support
2846
2870
  * ↑ THIS IS A PLATFORM CONSTRAINT — never overridden
2847
2871
  * 3. Platform guard engine — full world rule evaluation
@@ -2872,6 +2896,47 @@ var MentraGovernedExecutor = class {
2872
2896
  return result2;
2873
2897
  }
2874
2898
  }
2899
+ if (!this._emergencyOverride && this._spatialSession) {
2900
+ const spatialResult = this._spatialSession.evaluate(intent);
2901
+ if (!spatialResult.allowed && !spatialResult.requiresConfirmation) {
2902
+ const verdict2 = {
2903
+ status: "BLOCK",
2904
+ ruleId: "spatial-zone-rule",
2905
+ reason: spatialResult.reason,
2906
+ evidence: makeEvidence("spatial-zone-rule")
2907
+ };
2908
+ const result2 = {
2909
+ allowed: false,
2910
+ requiresConfirmation: false,
2911
+ verdict: verdict2,
2912
+ intentDef,
2913
+ appContext,
2914
+ decidingLayer: "spatial"
2915
+ };
2916
+ this.options.onBlock?.(result2);
2917
+ this.options.onEvaluate?.(result2);
2918
+ return result2;
2919
+ }
2920
+ if (spatialResult.requiresConfirmation) {
2921
+ const verdict2 = {
2922
+ status: "PAUSE",
2923
+ ruleId: "spatial-zone-rule",
2924
+ reason: spatialResult.reason,
2925
+ evidence: makeEvidence("spatial-zone-rule")
2926
+ };
2927
+ const result2 = {
2928
+ allowed: false,
2929
+ requiresConfirmation: true,
2930
+ verdict: verdict2,
2931
+ intentDef,
2932
+ appContext,
2933
+ decidingLayer: "spatial"
2934
+ };
2935
+ this.options.onPause?.(result2);
2936
+ this.options.onEvaluate?.(result2);
2937
+ return result2;
2938
+ }
2939
+ }
2875
2940
  if (intentDef && glassesModel && !intentDef.supported_glasses.includes(glassesModel)) {
2876
2941
  const verdict2 = {
2877
2942
  status: "BLOCK",