@neuroverseos/governance 0.3.4 → 0.4.1

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 (129) hide show
  1. package/README.md +280 -405
  2. package/dist/adapters/autoresearch.cjs +63 -9
  3. package/dist/adapters/autoresearch.d.cts +2 -1
  4. package/dist/adapters/autoresearch.d.ts +2 -1
  5. package/dist/adapters/autoresearch.js +3 -3
  6. package/dist/adapters/deep-agents.cjs +63 -9
  7. package/dist/adapters/deep-agents.d.cts +3 -2
  8. package/dist/adapters/deep-agents.d.ts +3 -2
  9. package/dist/adapters/deep-agents.js +3 -3
  10. package/dist/adapters/express.cjs +63 -9
  11. package/dist/adapters/express.d.cts +2 -1
  12. package/dist/adapters/express.d.ts +2 -1
  13. package/dist/adapters/express.js +3 -3
  14. package/dist/adapters/index.cjs +961 -9
  15. package/dist/adapters/index.d.cts +4 -2
  16. package/dist/adapters/index.d.ts +4 -2
  17. package/dist/adapters/index.js +54 -17
  18. package/dist/adapters/langchain.cjs +63 -9
  19. package/dist/adapters/langchain.d.cts +3 -2
  20. package/dist/adapters/langchain.d.ts +3 -2
  21. package/dist/adapters/langchain.js +3 -3
  22. package/dist/adapters/mentraos.cjs +2181 -0
  23. package/dist/adapters/mentraos.d.cts +319 -0
  24. package/dist/adapters/mentraos.d.ts +319 -0
  25. package/dist/adapters/mentraos.js +48 -0
  26. package/dist/adapters/openai.cjs +63 -9
  27. package/dist/adapters/openai.d.cts +3 -2
  28. package/dist/adapters/openai.d.ts +3 -2
  29. package/dist/adapters/openai.js +3 -3
  30. package/dist/adapters/openclaw.cjs +63 -9
  31. package/dist/adapters/openclaw.d.cts +3 -2
  32. package/dist/adapters/openclaw.d.ts +3 -2
  33. package/dist/adapters/openclaw.js +3 -3
  34. package/dist/{add-ROOZLU62.js → add-XSANI3FK.js} +1 -1
  35. package/dist/{behavioral-MJO34S6Q.js → behavioral-SLW7ALEK.js} +4 -4
  36. package/dist/{bootstrap-CQRZVOXK.js → bootstrap-2OW5ZLBL.js} +4 -4
  37. package/dist/bootstrap-contract-DcV6t-8M.d.cts +216 -0
  38. package/dist/bootstrap-contract-DcV6t-8M.d.ts +216 -0
  39. package/dist/browser.global.js +149 -5
  40. package/dist/{build-ZHPMX5AZ.js → build-EGBGZFIJ.js} +6 -6
  41. package/dist/{chunk-A7GKPPU7.js → chunk-2VAWP6FI.js} +1 -1
  42. package/dist/{chunk-3WQLXYTP.js → chunk-3AYKQHYI.js} +2 -2
  43. package/dist/{chunk-EMQDLDAF.js → chunk-3NZMMSOW.js} +80 -2
  44. package/dist/chunk-3S5AD4AB.js +421 -0
  45. package/dist/{chunk-VXHSMA3I.js → chunk-6CV4XG3J.js} +1 -1
  46. package/dist/{chunk-BNKJPUPQ.js → chunk-A7SHG75T.js} +2 -2
  47. package/dist/{chunk-U6U7EJZL.js → chunk-AV7XJJWK.js} +2 -2
  48. package/dist/{chunk-ZWI3NIXK.js → chunk-CYDMUJVZ.js} +54 -3
  49. package/dist/{chunk-F66BVUYB.js → chunk-DA5MHFRR.js} +3 -3
  50. package/dist/{chunk-YEKMVDWK.js → chunk-FHXXD2TI.js} +7 -7
  51. package/dist/{chunk-5TPFNWRU.js → chunk-FS2UUJJO.js} +3 -3
  52. package/dist/{chunk-4FLICVVA.js → chunk-FVOGUCB6.js} +2 -2
  53. package/dist/chunk-GTPV2XGO.js +893 -0
  54. package/dist/{chunk-CTZHONLA.js → chunk-I4RTIMLX.js} +2 -2
  55. package/dist/{chunk-B6OXJLJ5.js → chunk-J2IZBHXJ.js} +4 -4
  56. package/dist/{chunk-TG6SEF24.js → chunk-OQU65525.js} +1 -1
  57. package/dist/{chunk-QXBFT7NI.js → chunk-QMVQ6KPL.js} +2 -2
  58. package/dist/{chunk-G7DJ6VOD.js → chunk-RDA7ISWC.js} +2 -2
  59. package/dist/{chunk-O5ABKEA7.js → chunk-YJ34R5NB.js} +2 -2
  60. package/dist/{chunk-PVTQQS3Y.js → chunk-YPCVY4GS.js} +31 -0
  61. package/dist/{chunk-W7LLXRGY.js → chunk-ZAF6JH23.js} +65 -10
  62. package/dist/{chunk-IS4WUH6Y.js → chunk-ZEIT2QLM.js} +4 -4
  63. package/dist/cli/neuroverse.cjs +4436 -1035
  64. package/dist/cli/neuroverse.js +40 -24
  65. package/dist/cli/plan.cjs +176 -12
  66. package/dist/cli/plan.js +2 -2
  67. package/dist/cli/run.cjs +63 -9
  68. package/dist/cli/run.js +2 -2
  69. package/dist/configure-world-XU2COHOZ.js +705 -0
  70. package/dist/{decision-flow-M63D47LO.js → decision-flow-3K4D72G4.js} +2 -2
  71. package/dist/{demo-G43RLCPK.js → demo-6OQYWRR6.js} +4 -4
  72. package/dist/{derive-LMDUTXDD.js → derive-7Y7YWVLU.js} +5 -5
  73. package/dist/{doctor-6BC6X2VO.js → doctor-NHXI7OQW.js} +3 -1
  74. package/dist/engine/bootstrap-emitter.cjs +241 -0
  75. package/dist/engine/bootstrap-emitter.d.cts +27 -0
  76. package/dist/engine/bootstrap-emitter.d.ts +27 -0
  77. package/dist/{bootstrap-emitter-Q7UIJZ2O.js → engine/bootstrap-emitter.js} +2 -2
  78. package/dist/engine/bootstrap-parser.cjs +560 -0
  79. package/dist/engine/bootstrap-parser.d.cts +96 -0
  80. package/dist/engine/bootstrap-parser.d.ts +96 -0
  81. package/dist/{bootstrap-parser-EEF36XDU.js → engine/bootstrap-parser.js} +2 -2
  82. package/dist/engine/guard-engine.cjs +1116 -0
  83. package/dist/engine/guard-engine.d.cts +60 -0
  84. package/dist/engine/guard-engine.d.ts +60 -0
  85. package/dist/engine/guard-engine.js +12 -0
  86. package/dist/engine/simulate-engine.cjs +390 -0
  87. package/dist/engine/simulate-engine.d.cts +105 -0
  88. package/dist/engine/simulate-engine.d.ts +105 -0
  89. package/dist/engine/simulate-engine.js +9 -0
  90. package/dist/{equity-penalties-SG5IZQ7I.js → equity-penalties-NVBAB5WL.js} +4 -4
  91. package/dist/{explain-RHBU2GBR.js → explain-HDFN4ION.js} +1 -1
  92. package/dist/github-TIKTWOGU.js +27 -0
  93. package/dist/{guard-AEEJNWLD.js → guard-6KSCWT2W.js} +4 -4
  94. package/dist/{guard-contract-B7lplwm9.d.cts → guard-contract-C991HDZp.d.cts} +32 -309
  95. package/dist/{guard-contract-B7lplwm9.d.ts → guard-contract-hHjTTjtR.d.ts} +32 -309
  96. package/dist/{impact-3XVDSCBU.js → impact-WIAM66IH.js} +3 -3
  97. package/dist/{improve-TQP4ECSY.js → improve-2PWGGO5B.js} +3 -3
  98. package/dist/index.cjs +682 -14
  99. package/dist/index.d.cts +231 -423
  100. package/dist/index.d.ts +231 -423
  101. package/dist/index.js +81 -58
  102. package/dist/{init-FYPV4SST.js → init-TKIJDR7I.js} +5 -1
  103. package/dist/lens-MHMUDCMQ.js +1084 -0
  104. package/dist/{mcp-server-5Y3ZM7TV.js → mcp-server-TNIWZ7B5.js} +3 -3
  105. package/dist/{playground-VZBNPPBO.js → playground-3FLDGBET.js} +3 -3
  106. package/dist/{redteam-MZPZD3EF.js → redteam-HV6LMKEH.js} +3 -3
  107. package/dist/{session-JYOARW54.js → session-XZP2754M.js} +3 -3
  108. package/dist/{shared-C_zpdvBm.d.cts → shared-DGnn1jiS.d.cts} +1 -1
  109. package/dist/{shared-Cf7yxx4-.d.ts → shared-U405h52W.d.ts} +1 -1
  110. package/dist/{simulate-LJXYBC6M.js → simulate-VT437EEL.js} +17 -4
  111. package/dist/spatial/index.cjs +682 -0
  112. package/dist/spatial/index.d.cts +517 -0
  113. package/dist/spatial/index.d.ts +517 -0
  114. package/dist/spatial/index.js +633 -0
  115. package/dist/{test-BOOR4A5F.js → test-4WTX6RKQ.js} +3 -3
  116. package/dist/{trace-PKV4KX56.js → trace-2YDNAXMK.js} +2 -2
  117. package/dist/types.cjs +18 -0
  118. package/dist/types.d.cts +370 -0
  119. package/dist/types.d.ts +370 -0
  120. package/dist/types.js +0 -0
  121. package/dist/{validate-RALX7CZS.js → validate-M52DX22Y.js} +1 -1
  122. package/dist/{world-BIP4GZBZ.js → world-O4HTQPDP.js} +1 -1
  123. package/dist/{world-loader-Y6HMQH2D.js → world-loader-YTYFOP7D.js} +1 -1
  124. package/dist/worlds/mentraos-smartglasses.nv-world.md +423 -0
  125. package/dist/worlds/mentraos-spatial.nv-world.md +68 -0
  126. package/dist/worlds/user-rules.nv-world.md +328 -0
  127. package/package.json +46 -3
  128. package/dist/guard-engine-PNR6MHCM.js +0 -10
  129. package/dist/{configure-ai-5MP5DWTT.js → configure-ai-LL3VAPQW.js} +3 -3
@@ -32,6 +32,8 @@ Commands:
32
32
  derive AI-assisted synthesis of .nv-world.md from markdown
33
33
  bootstrap Compile .nv-world.md \u2192 world JSON files
34
34
  configure-ai Configure AI provider credentials
35
+ configure-world Interactive wizard: define your system in plain language
36
+ lens Manage behavioral lenses (list, preview, compile, compare, add)
35
37
 
36
38
  Usage:
37
39
  neuroverse add "Block dairy orders" --world <dir>
@@ -63,6 +65,12 @@ Usage:
63
65
  neuroverse decision-flow [--log <path>] [--json]
64
66
  neuroverse equity-penalties --world <dir> [--agents N] [--rounds N] [--json]
65
67
  neuroverse configure-ai --provider <name> --model <name> --api-key <key>
68
+ neuroverse configure-world [--output <dir>]
69
+ neuroverse lens list [--world <dir>] [--json]
70
+ neuroverse lens preview <id> [--world <dir>]
71
+ neuroverse lens compile <id,...> [--world <dir>] [--role <role>] [--json]
72
+ neuroverse lens compare --input "text" --lenses stoic,coach,calm
73
+ neuroverse lens add --world <dir> --name "Name" --tagline "..." [options]
66
74
 
67
75
  Examples:
68
76
  neuroverse build horror-notes.md
@@ -92,27 +100,27 @@ async function main() {
92
100
  const subArgs = args.slice(1);
93
101
  switch (command) {
94
102
  case "add": {
95
- const { main: addMain } = await import("../add-ROOZLU62.js");
103
+ const { main: addMain } = await import("../add-XSANI3FK.js");
96
104
  return addMain(subArgs);
97
105
  }
98
106
  case "build": {
99
- const { main: buildMain } = await import("../build-ZHPMX5AZ.js");
107
+ const { main: buildMain } = await import("../build-EGBGZFIJ.js");
100
108
  return buildMain(subArgs);
101
109
  }
102
110
  case "explain": {
103
- const { main: explainMain } = await import("../explain-RHBU2GBR.js");
111
+ const { main: explainMain } = await import("../explain-HDFN4ION.js");
104
112
  return explainMain(subArgs);
105
113
  }
106
114
  case "simulate": {
107
- const { main: simulateMain } = await import("../simulate-LJXYBC6M.js");
115
+ const { main: simulateMain } = await import("../simulate-VT437EEL.js");
108
116
  return simulateMain(subArgs);
109
117
  }
110
118
  case "improve": {
111
- const { main: improveMain } = await import("../improve-TQP4ECSY.js");
119
+ const { main: improveMain } = await import("../improve-2PWGGO5B.js");
112
120
  return improveMain(subArgs);
113
121
  }
114
122
  case "init": {
115
- const { main: initMain } = await import("../init-FYPV4SST.js");
123
+ const { main: initMain } = await import("../init-TKIJDR7I.js");
116
124
  return initMain(subArgs);
117
125
  }
118
126
  case "init-world": {
@@ -124,35 +132,35 @@ async function main() {
124
132
  return inferWorldMain(subArgs);
125
133
  }
126
134
  case "bootstrap": {
127
- const { main: bootstrapMain } = await import("../bootstrap-CQRZVOXK.js");
135
+ const { main: bootstrapMain } = await import("../bootstrap-2OW5ZLBL.js");
128
136
  return bootstrapMain(subArgs);
129
137
  }
130
138
  case "validate": {
131
- const { main: validateMain } = await import("../validate-RALX7CZS.js");
139
+ const { main: validateMain } = await import("../validate-M52DX22Y.js");
132
140
  return validateMain(subArgs);
133
141
  }
134
142
  case "guard": {
135
- const { main: guardMain } = await import("../guard-AEEJNWLD.js");
143
+ const { main: guardMain } = await import("../guard-6KSCWT2W.js");
136
144
  return guardMain(subArgs);
137
145
  }
138
146
  case "test": {
139
- const { main: testMain } = await import("../test-BOOR4A5F.js");
147
+ const { main: testMain } = await import("../test-4WTX6RKQ.js");
140
148
  return testMain(subArgs);
141
149
  }
142
150
  case "redteam": {
143
- const { main: redteamMain } = await import("../redteam-MZPZD3EF.js");
151
+ const { main: redteamMain } = await import("../redteam-HV6LMKEH.js");
144
152
  return redteamMain(subArgs);
145
153
  }
146
154
  case "demo": {
147
- const { main: demoMain } = await import("../demo-G43RLCPK.js");
155
+ const { main: demoMain } = await import("../demo-6OQYWRR6.js");
148
156
  return demoMain(subArgs);
149
157
  }
150
158
  case "doctor": {
151
- const { main: doctorMain } = await import("../doctor-6BC6X2VO.js");
159
+ const { main: doctorMain } = await import("../doctor-NHXI7OQW.js");
152
160
  return doctorMain(subArgs);
153
161
  }
154
162
  case "playground": {
155
- const { main: playgroundMain } = await import("../playground-VZBNPPBO.js");
163
+ const { main: playgroundMain } = await import("../playground-3FLDGBET.js");
156
164
  return playgroundMain(subArgs);
157
165
  }
158
166
  case "plan": {
@@ -164,45 +172,53 @@ async function main() {
164
172
  return runMain(subArgs);
165
173
  }
166
174
  case "mcp": {
167
- const { startMcpServer } = await import("../mcp-server-5Y3ZM7TV.js");
175
+ const { startMcpServer } = await import("../mcp-server-TNIWZ7B5.js");
168
176
  return startMcpServer(subArgs);
169
177
  }
170
178
  case "worlds": {
171
- const { main: worldMain } = await import("../world-BIP4GZBZ.js");
179
+ const { main: worldMain } = await import("../world-O4HTQPDP.js");
172
180
  return worldMain(["list", ...subArgs]);
173
181
  }
174
182
  case "trace": {
175
- const { main: traceMain } = await import("../trace-PKV4KX56.js");
183
+ const { main: traceMain } = await import("../trace-2YDNAXMK.js");
176
184
  return traceMain(subArgs);
177
185
  }
178
186
  case "impact": {
179
- const { main: impactMain } = await import("../impact-3XVDSCBU.js");
187
+ const { main: impactMain } = await import("../impact-WIAM66IH.js");
180
188
  return impactMain(subArgs);
181
189
  }
182
190
  case "behavioral": {
183
- const { main: behavioralMain } = await import("../behavioral-MJO34S6Q.js");
191
+ const { main: behavioralMain } = await import("../behavioral-SLW7ALEK.js");
184
192
  return behavioralMain(subArgs);
185
193
  }
186
194
  case "world": {
187
- const { main: worldMain } = await import("../world-BIP4GZBZ.js");
195
+ const { main: worldMain } = await import("../world-O4HTQPDP.js");
188
196
  return worldMain(subArgs);
189
197
  }
190
198
  case "derive": {
191
- const { main: deriveMain } = await import("../derive-LMDUTXDD.js");
199
+ const { main: deriveMain } = await import("../derive-7Y7YWVLU.js");
192
200
  return deriveMain(subArgs);
193
201
  }
194
202
  case "decision-flow": {
195
- const { main: decisionFlowMain } = await import("../decision-flow-M63D47LO.js");
203
+ const { main: decisionFlowMain } = await import("../decision-flow-3K4D72G4.js");
196
204
  return decisionFlowMain(subArgs);
197
205
  }
198
206
  case "equity-penalties": {
199
- const { main: equityPenaltiesMain } = await import("../equity-penalties-SG5IZQ7I.js");
207
+ const { main: equityPenaltiesMain } = await import("../equity-penalties-NVBAB5WL.js");
200
208
  return equityPenaltiesMain(subArgs);
201
209
  }
202
210
  case "configure-ai": {
203
- const { main: configureAiMain } = await import("../configure-ai-5MP5DWTT.js");
211
+ const { main: configureAiMain } = await import("../configure-ai-LL3VAPQW.js");
204
212
  return configureAiMain(subArgs);
205
213
  }
214
+ case "configure-world": {
215
+ const { main: configureWorldMain } = await import("../configure-world-XU2COHOZ.js");
216
+ return configureWorldMain(subArgs);
217
+ }
218
+ case "lens": {
219
+ const { main: lensMain } = await import("../lens-MHMUDCMQ.js");
220
+ return lensMain(subArgs);
221
+ }
206
222
  case "--help":
207
223
  case "-h":
208
224
  case "help":
package/dist/cli/plan.cjs CHANGED
@@ -675,6 +675,67 @@ function parseValueLiteral(raw) {
675
675
  if (!isNaN(num) && raw.trim() !== "") return num;
676
676
  return raw;
677
677
  }
678
+ function parseLenses(content, startLine, issues) {
679
+ const lenses = [];
680
+ const subSections = splitH2Sections(content, startLine);
681
+ for (const sub of subSections) {
682
+ const props = parseKeyValueBullets(sub.content);
683
+ const lineNum = sub.startLine;
684
+ const directives = [];
685
+ const lines = sub.content.split("\n");
686
+ let directiveIndex = 0;
687
+ for (let i = 0; i < lines.length; i++) {
688
+ const line = lines[i].trim();
689
+ if (line.startsWith(">")) {
690
+ const blockContent = line.slice(1).trim();
691
+ const colonIdx = blockContent.indexOf(":");
692
+ if (colonIdx > 0) {
693
+ const scope = blockContent.slice(0, colonIdx).trim();
694
+ let instruction = blockContent.slice(colonIdx + 1).trim();
695
+ for (let j = i + 1; j < lines.length; j++) {
696
+ const nextLine = lines[j].trim();
697
+ if (nextLine.startsWith(">")) {
698
+ const nextContent = nextLine.slice(1).trim();
699
+ const nextColon = nextContent.indexOf(":");
700
+ if (nextColon > 0 && !nextContent.slice(0, nextColon).includes(" ")) {
701
+ break;
702
+ }
703
+ instruction += " " + nextContent;
704
+ i = j;
705
+ } else {
706
+ break;
707
+ }
708
+ }
709
+ directives.push({
710
+ id: `${sub.name}_directive_${directiveIndex++}`,
711
+ scope,
712
+ instruction,
713
+ line: startLine + i
714
+ });
715
+ }
716
+ }
717
+ }
718
+ const tags = (props.tags ?? "").split(",").map((s) => s.trim()).filter(Boolean);
719
+ const defaultForRoles = (props.default_for_roles ?? props.roles ?? "").split(",").map((s) => s.trim()).filter(Boolean);
720
+ lenses.push({
721
+ id: sub.name,
722
+ name: props.name ?? sub.name,
723
+ tagline: props.tagline ?? "",
724
+ description: props.description ?? "",
725
+ tags,
726
+ formality: props.formality ?? "neutral",
727
+ verbosity: props.verbosity ?? "balanced",
728
+ emotion: props.emotion ?? "neutral",
729
+ confidence: props.confidence ?? "balanced",
730
+ defaultForRoles,
731
+ directives,
732
+ priority: props.priority ? parseInt(props.priority, 10) : 50,
733
+ stackable: props.stackable === "false" ? false : true,
734
+ line: lineNum
735
+ });
736
+ }
737
+ return lenses;
738
+ }
678
739
  function parseWorldMarkdown(markdown) {
679
740
  const issues = [];
680
741
  const { frontmatter: fmRaw, sections } = splitSections(markdown);
@@ -712,8 +773,22 @@ function parseWorldMarkdown(markdown) {
712
773
  }
713
774
  const outcomesSection = findSection("Outcomes");
714
775
  const outcomes = outcomesSection ? parseOutcomes(outcomesSection.content, outcomesSection.startLine, issues) : [];
776
+ const lensesSection = findSection("Lenses");
777
+ const lenses = lensesSection ? parseLenses(lensesSection.content, lensesSection.startLine, issues) : [];
778
+ let lensPolicy;
779
+ let lensLockPin;
780
+ if (lensesSection) {
781
+ const topContent = lensesSection.content.split(/^##\s/m)[0];
782
+ const topProps = parseKeyValueBullets(topContent);
783
+ if (topProps.policy === "locked" || topProps.policy === "role_default" || topProps.policy === "user_choice") {
784
+ lensPolicy = topProps.policy;
785
+ }
786
+ if (topProps.lock_pin) {
787
+ lensLockPin = topProps.lock_pin;
788
+ }
789
+ }
715
790
  const parsedSections = sections.map((s) => s.name);
716
- const knownSections = /* @__PURE__ */ new Set(["thesis", "invariants", "state", "assumptions", "rules", "gates", "outcomes"]);
791
+ const knownSections = /* @__PURE__ */ new Set(["thesis", "invariants", "state", "assumptions", "rules", "gates", "outcomes", "lenses"]);
717
792
  for (const section of sections) {
718
793
  if (!knownSections.has(section.name.toLowerCase())) {
719
794
  issues.push({
@@ -739,7 +814,10 @@ function parseWorldMarkdown(markdown) {
739
814
  assumptions,
740
815
  rules,
741
816
  gates,
742
- outcomes
817
+ outcomes,
818
+ lenses,
819
+ lensPolicy,
820
+ lensLockPin
743
821
  },
744
822
  issues
745
823
  };
@@ -911,6 +989,36 @@ function emitWorldDefinition(parsed) {
911
989
  structural_indicators: rules.filter((r) => r.severity === "structural").map((r) => r.id)
912
990
  }
913
991
  };
992
+ const validScopes = /* @__PURE__ */ new Set(["response_framing", "language_style", "content_filtering", "value_emphasis", "behavior_shaping"]);
993
+ const lensConfigs = parsed.lenses.map((pl) => {
994
+ const directives = pl.directives.map((d) => ({
995
+ id: d.id,
996
+ scope: validScopes.has(d.scope) ? d.scope : "behavior_shaping",
997
+ instruction: d.instruction
998
+ }));
999
+ return {
1000
+ id: pl.id,
1001
+ name: pl.name,
1002
+ tagline: pl.tagline,
1003
+ description: pl.description,
1004
+ tags: pl.tags,
1005
+ tone: {
1006
+ formality: pl.formality || "neutral",
1007
+ verbosity: pl.verbosity || "balanced",
1008
+ emotion: pl.emotion || "neutral",
1009
+ confidence: pl.confidence || "balanced"
1010
+ },
1011
+ directives,
1012
+ defaultForRoles: pl.defaultForRoles,
1013
+ priority: pl.priority,
1014
+ stackable: pl.stackable
1015
+ };
1016
+ });
1017
+ const lensesConfig = lensConfigs.length > 0 ? {
1018
+ lenses: lensConfigs,
1019
+ ...parsed.lensPolicy ? { policy: parsed.lensPolicy } : {},
1020
+ ...parsed.lensLockPin ? { lockPin: parsed.lensLockPin } : {}
1021
+ } : void 0;
914
1022
  const metadata = {
915
1023
  format_version: "1.0.0",
916
1024
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -925,6 +1033,7 @@ function emitWorldDefinition(parsed) {
925
1033
  rules,
926
1034
  gates,
927
1035
  outcomes,
1036
+ ...lensesConfig ? { lenses: lensesConfig } : {},
928
1037
  metadata
929
1038
  };
930
1039
  return { world: worldDefinition, issues };
@@ -1090,7 +1199,8 @@ var init_world_loader = __esm({
1090
1199
  var guard_engine_exports = {};
1091
1200
  __export(guard_engine_exports, {
1092
1201
  evaluateGuard: () => evaluateGuard,
1093
- eventToAllowlistKey: () => eventToAllowlistKey
1202
+ eventToAllowlistKey: () => eventToAllowlistKey,
1203
+ verdictToEvent: () => verdictToEvent
1094
1204
  });
1095
1205
  function levelRequiresConfirmation(level, actionType) {
1096
1206
  if (level === "strict") return true;
@@ -1165,6 +1275,33 @@ function evaluateGuard(event, world, options = {}) {
1165
1275
  let decidingId;
1166
1276
  const guardsMatched = [];
1167
1277
  const rulesMatched = [];
1278
+ if (options.emergencyOverride) {
1279
+ checkInvariantCoverage(world, invariantChecks);
1280
+ return buildVerdict(
1281
+ "ALLOW",
1282
+ void 0,
1283
+ "emergency-override",
1284
+ "Emergency override active \u2014 all governance rules suspended. Platform constraints still apply.",
1285
+ world,
1286
+ level,
1287
+ invariantChecks,
1288
+ guardsMatched,
1289
+ rulesMatched,
1290
+ includeTrace ? buildTrace(
1291
+ invariantChecks,
1292
+ safetyChecks,
1293
+ planCheckResult,
1294
+ roleChecks,
1295
+ guardChecks,
1296
+ kernelRuleChecks,
1297
+ levelChecks,
1298
+ "session-allowlist",
1299
+ "emergency-override",
1300
+ startTime
1301
+ ) : void 0,
1302
+ event.intent
1303
+ );
1304
+ }
1168
1305
  checkInvariantCoverage(world, invariantChecks);
1169
1306
  if (event.roleId && options.agentStates) {
1170
1307
  const agentState = options.agentStates.get(event.roleId);
@@ -1229,7 +1366,8 @@ function evaluateGuard(event, world, options = {}) {
1229
1366
  decidingLayer,
1230
1367
  decidingId,
1231
1368
  startTime
1232
- ) : void 0
1369
+ ) : void 0,
1370
+ event.intent
1233
1371
  );
1234
1372
  }
1235
1373
  }
@@ -1258,7 +1396,8 @@ function evaluateGuard(event, world, options = {}) {
1258
1396
  decidingLayer,
1259
1397
  decidingId,
1260
1398
  startTime
1261
- ) : void 0
1399
+ ) : void 0,
1400
+ event.intent
1262
1401
  );
1263
1402
  }
1264
1403
  if (options.plan) {
@@ -1293,7 +1432,8 @@ function evaluateGuard(event, world, options = {}) {
1293
1432
  decidingLayer,
1294
1433
  decidingId,
1295
1434
  startTime
1296
- ) : void 0
1435
+ ) : void 0,
1436
+ event.intent
1297
1437
  );
1298
1438
  }
1299
1439
  }
@@ -1322,7 +1462,8 @@ function evaluateGuard(event, world, options = {}) {
1322
1462
  decidingLayer,
1323
1463
  decidingId,
1324
1464
  startTime
1325
- ) : void 0
1465
+ ) : void 0,
1466
+ event.intent
1326
1467
  );
1327
1468
  }
1328
1469
  const guardVerdict = checkGuards(event, eventText, world, guardChecks, guardsMatched);
@@ -1360,7 +1501,8 @@ function evaluateGuard(event, world, options = {}) {
1360
1501
  decidingLayer,
1361
1502
  decidingId,
1362
1503
  startTime
1363
- ) : void 0
1504
+ ) : void 0,
1505
+ event.intent
1364
1506
  );
1365
1507
  verdict.intentRecord = intentRecord;
1366
1508
  if (guardVerdict.consequence) verdict.consequence = guardVerdict.consequence;
@@ -1393,7 +1535,8 @@ function evaluateGuard(event, world, options = {}) {
1393
1535
  decidingLayer,
1394
1536
  decidingId,
1395
1537
  startTime
1396
- ) : void 0
1538
+ ) : void 0,
1539
+ event.intent
1397
1540
  );
1398
1541
  }
1399
1542
  const levelVerdict = checkLevelConstraints(event, level, levelChecks);
@@ -1421,7 +1564,8 @@ function evaluateGuard(event, world, options = {}) {
1421
1564
  decidingLayer,
1422
1565
  decidingId,
1423
1566
  startTime
1424
- ) : void 0
1567
+ ) : void 0,
1568
+ event.intent
1425
1569
  );
1426
1570
  }
1427
1571
  const warning = guardVerdict?.warning;
@@ -1446,7 +1590,8 @@ function evaluateGuard(event, world, options = {}) {
1446
1590
  decidingLayer,
1447
1591
  decidingId,
1448
1592
  startTime
1449
- ) : void 0
1593
+ ) : void 0,
1594
+ event.intent
1450
1595
  );
1451
1596
  }
1452
1597
  function checkInvariantCoverage(world, checks) {
@@ -1823,7 +1968,7 @@ function buildTrace(invariantChecks, safetyChecks, planCheck, roleChecks, guardC
1823
1968
  }
1824
1969
  return trace;
1825
1970
  }
1826
- function buildVerdict(status, reason, ruleId, warning, world, level, invariantChecks, guardsMatched, rulesMatched, trace) {
1971
+ function buildVerdict(status, reason, ruleId, warning, world, level, invariantChecks, guardsMatched, rulesMatched, trace, eventIntent) {
1827
1972
  const evidence = {
1828
1973
  worldId: world.world.world_id,
1829
1974
  worldName: world.world.name,
@@ -1843,8 +1988,27 @@ function buildVerdict(status, reason, ruleId, warning, world, level, invariantCh
1843
1988
  if (ruleId) verdict.ruleId = ruleId;
1844
1989
  if (warning) verdict.warning = warning;
1845
1990
  if (trace) verdict.trace = trace;
1991
+ verdict.event = verdictToEvent(status, eventIntent);
1846
1992
  return verdict;
1847
1993
  }
1994
+ function verdictToEvent(status, intent) {
1995
+ const statusEventMap = {
1996
+ ALLOW: "action_allowed",
1997
+ BLOCK: "action_blocked",
1998
+ PAUSE: "action_paused",
1999
+ MODIFY: "action_modified",
2000
+ PENALIZE: "action_penalized",
2001
+ REWARD: "action_rewarded",
2002
+ NEUTRAL: "action_neutral"
2003
+ };
2004
+ return {
2005
+ type: intent || statusEventMap[status] || "unknown_action",
2006
+ actor: "agent",
2007
+ source: "guard",
2008
+ timestamp: Date.now(),
2009
+ guardStatus: status
2010
+ };
2011
+ }
1848
2012
  var PROMPT_INJECTION_PATTERNS, EXECUTION_CLAIM_PATTERNS, EXECUTION_INTENT_PATTERNS, SCOPE_ESCAPE_PATTERNS, NEUTRAL_MESSAGES, MAX_INPUT_LENGTH;
1849
2013
  var init_guard_engine = __esm({
1850
2014
  "src/engine/guard-engine.ts"() {
package/dist/cli/plan.js CHANGED
@@ -100,8 +100,8 @@ async function checkCommand(args) {
100
100
  }
101
101
  const worldPath = parseArg(args, "--world");
102
102
  if (worldPath) {
103
- const { loadWorld } = await import("../world-loader-Y6HMQH2D.js");
104
- const { evaluateGuard } = await import("../guard-engine-PNR6MHCM.js");
103
+ const { loadWorld } = await import("../world-loader-YTYFOP7D.js");
104
+ const { evaluateGuard } = await import("../engine/guard-engine.js");
105
105
  const world = await loadWorld(worldPath);
106
106
  const verdict2 = evaluateGuard(event, world, { plan });
107
107
  process.stdout.write(JSON.stringify(verdict2, null, 2) + "\n");
package/dist/cli/run.cjs CHANGED
@@ -497,6 +497,33 @@ function evaluateGuard(event, world, options = {}) {
497
497
  let decidingId;
498
498
  const guardsMatched = [];
499
499
  const rulesMatched = [];
500
+ if (options.emergencyOverride) {
501
+ checkInvariantCoverage(world, invariantChecks);
502
+ return buildVerdict(
503
+ "ALLOW",
504
+ void 0,
505
+ "emergency-override",
506
+ "Emergency override active \u2014 all governance rules suspended. Platform constraints still apply.",
507
+ world,
508
+ level,
509
+ invariantChecks,
510
+ guardsMatched,
511
+ rulesMatched,
512
+ includeTrace ? buildTrace(
513
+ invariantChecks,
514
+ safetyChecks,
515
+ planCheckResult,
516
+ roleChecks,
517
+ guardChecks,
518
+ kernelRuleChecks,
519
+ levelChecks,
520
+ "session-allowlist",
521
+ "emergency-override",
522
+ startTime
523
+ ) : void 0,
524
+ event.intent
525
+ );
526
+ }
500
527
  checkInvariantCoverage(world, invariantChecks);
501
528
  if (event.roleId && options.agentStates) {
502
529
  const agentState = options.agentStates.get(event.roleId);
@@ -561,7 +588,8 @@ function evaluateGuard(event, world, options = {}) {
561
588
  decidingLayer,
562
589
  decidingId,
563
590
  startTime
564
- ) : void 0
591
+ ) : void 0,
592
+ event.intent
565
593
  );
566
594
  }
567
595
  }
@@ -590,7 +618,8 @@ function evaluateGuard(event, world, options = {}) {
590
618
  decidingLayer,
591
619
  decidingId,
592
620
  startTime
593
- ) : void 0
621
+ ) : void 0,
622
+ event.intent
594
623
  );
595
624
  }
596
625
  if (options.plan) {
@@ -625,7 +654,8 @@ function evaluateGuard(event, world, options = {}) {
625
654
  decidingLayer,
626
655
  decidingId,
627
656
  startTime
628
- ) : void 0
657
+ ) : void 0,
658
+ event.intent
629
659
  );
630
660
  }
631
661
  }
@@ -654,7 +684,8 @@ function evaluateGuard(event, world, options = {}) {
654
684
  decidingLayer,
655
685
  decidingId,
656
686
  startTime
657
- ) : void 0
687
+ ) : void 0,
688
+ event.intent
658
689
  );
659
690
  }
660
691
  const guardVerdict = checkGuards(event, eventText, world, guardChecks, guardsMatched);
@@ -692,7 +723,8 @@ function evaluateGuard(event, world, options = {}) {
692
723
  decidingLayer,
693
724
  decidingId,
694
725
  startTime
695
- ) : void 0
726
+ ) : void 0,
727
+ event.intent
696
728
  );
697
729
  verdict.intentRecord = intentRecord;
698
730
  if (guardVerdict.consequence) verdict.consequence = guardVerdict.consequence;
@@ -725,7 +757,8 @@ function evaluateGuard(event, world, options = {}) {
725
757
  decidingLayer,
726
758
  decidingId,
727
759
  startTime
728
- ) : void 0
760
+ ) : void 0,
761
+ event.intent
729
762
  );
730
763
  }
731
764
  const levelVerdict = checkLevelConstraints(event, level, levelChecks);
@@ -753,7 +786,8 @@ function evaluateGuard(event, world, options = {}) {
753
786
  decidingLayer,
754
787
  decidingId,
755
788
  startTime
756
- ) : void 0
789
+ ) : void 0,
790
+ event.intent
757
791
  );
758
792
  }
759
793
  const warning = guardVerdict?.warning;
@@ -778,7 +812,8 @@ function evaluateGuard(event, world, options = {}) {
778
812
  decidingLayer,
779
813
  decidingId,
780
814
  startTime
781
- ) : void 0
815
+ ) : void 0,
816
+ event.intent
782
817
  );
783
818
  }
784
819
  function checkInvariantCoverage(world, checks) {
@@ -1155,7 +1190,7 @@ function buildTrace(invariantChecks, safetyChecks, planCheck, roleChecks, guardC
1155
1190
  }
1156
1191
  return trace;
1157
1192
  }
1158
- function buildVerdict(status, reason, ruleId, warning, world, level, invariantChecks, guardsMatched, rulesMatched, trace) {
1193
+ function buildVerdict(status, reason, ruleId, warning, world, level, invariantChecks, guardsMatched, rulesMatched, trace, eventIntent) {
1159
1194
  const evidence = {
1160
1195
  worldId: world.world.world_id,
1161
1196
  worldName: world.world.name,
@@ -1175,8 +1210,27 @@ function buildVerdict(status, reason, ruleId, warning, world, level, invariantCh
1175
1210
  if (ruleId) verdict.ruleId = ruleId;
1176
1211
  if (warning) verdict.warning = warning;
1177
1212
  if (trace) verdict.trace = trace;
1213
+ verdict.event = verdictToEvent(status, eventIntent);
1178
1214
  return verdict;
1179
1215
  }
1216
+ function verdictToEvent(status, intent) {
1217
+ const statusEventMap = {
1218
+ ALLOW: "action_allowed",
1219
+ BLOCK: "action_blocked",
1220
+ PAUSE: "action_paused",
1221
+ MODIFY: "action_modified",
1222
+ PENALIZE: "action_penalized",
1223
+ REWARD: "action_rewarded",
1224
+ NEUTRAL: "action_neutral"
1225
+ };
1226
+ return {
1227
+ type: intent || statusEventMap[status] || "unknown_action",
1228
+ actor: "agent",
1229
+ source: "guard",
1230
+ timestamp: Date.now(),
1231
+ guardStatus: status
1232
+ };
1233
+ }
1180
1234
  var PROMPT_INJECTION_PATTERNS, EXECUTION_CLAIM_PATTERNS, EXECUTION_INTENT_PATTERNS, SCOPE_ESCAPE_PATTERNS, NEUTRAL_MESSAGES, MAX_INPUT_LENGTH;
1181
1235
  var init_guard_engine = __esm({
1182
1236
  "src/engine/guard-engine.ts"() {
package/dist/cli/run.js CHANGED
@@ -92,7 +92,7 @@ async function main(args) {
92
92
  return;
93
93
  }
94
94
  const { resolveProvider, ModelAdapter } = await import("../model-adapter-VXEKB4LS.js");
95
- const { runInteractiveMode } = await import("../session-JYOARW54.js");
95
+ const { runInteractiveMode } = await import("../session-XZP2754M.js");
96
96
  const modelConfig = resolveProvider(providerName, {
97
97
  model: parseArg(args, "--model"),
98
98
  apiKey: parseArg(args, "--api-key")
@@ -126,7 +126,7 @@ async function main(args) {
126
126
  model
127
127
  );
128
128
  } else if (isPipeMode) {
129
- const { runPipeMode } = await import("../session-JYOARW54.js");
129
+ const { runPipeMode } = await import("../session-XZP2754M.js");
130
130
  await runPipeMode({
131
131
  worldPath,
132
132
  plan,