@brud/kernel 0.0.0-stage → 0.0.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 (286) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +63 -2
  3. package/dist/index.d.ts +15 -0
  4. package/dist/index.js +13 -0
  5. package/dist/serviceModules/events.d.ts +1 -0
  6. package/dist/serviceModules/events.js +1 -0
  7. package/dist/serviceModules/exposedApiRegistry.d.ts +1 -0
  8. package/dist/serviceModules/exposedApiRegistry.js +1 -0
  9. package/dist/serviceModules/identityRegistry.d.ts +1 -0
  10. package/dist/serviceModules/identityRegistry.js +1 -0
  11. package/dist/serviceModules/interception.d.ts +1 -0
  12. package/dist/serviceModules/interception.js +1 -0
  13. package/dist/serviceModules/parser.d.ts +1 -0
  14. package/dist/serviceModules/parser.js +1 -0
  15. package/dist/serviceModules/router.d.ts +1 -0
  16. package/dist/serviceModules/router.js +1 -0
  17. package/dist/serviceModules/wasmCage.d.ts +1 -0
  18. package/dist/serviceModules/wasmCage.js +1 -0
  19. package/dist/services/Events/contracts/IEventsService.d.ts +64 -0
  20. package/dist/services/Events/contracts/IEventsService.js +1 -0
  21. package/dist/services/Events/contracts/errors.d.ts +31 -0
  22. package/dist/services/Events/contracts/errors.js +40 -0
  23. package/dist/services/Events/contracts/index.d.ts +3 -0
  24. package/dist/services/Events/contracts/index.js +3 -0
  25. package/dist/services/Events/contracts/tokens.d.ts +2 -0
  26. package/dist/services/Events/contracts/tokens.js +2 -0
  27. package/dist/services/Events/descriptor/EventsDescriptor.d.ts +9 -0
  28. package/dist/services/Events/descriptor/EventsDescriptor.js +56 -0
  29. package/dist/services/Events/descriptor/tokens.d.ts +1 -0
  30. package/dist/services/Events/descriptor/tokens.js +1 -0
  31. package/dist/services/Events/index.d.ts +4 -0
  32. package/dist/services/Events/index.js +4 -0
  33. package/dist/services/Events/orchestrator/EventsService.d.ts +51 -0
  34. package/dist/services/Events/orchestrator/EventsService.js +339 -0
  35. package/dist/services/Events/orchestrator/index.d.ts +2 -0
  36. package/dist/services/Events/orchestrator/index.js +2 -0
  37. package/dist/services/Events/orchestrator/limits.d.ts +22 -0
  38. package/dist/services/Events/orchestrator/limits.js +33 -0
  39. package/dist/services/Events/serviceModule.d.ts +2 -0
  40. package/dist/services/Events/serviceModule.js +5 -0
  41. package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.d.ts +56 -0
  42. package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.js +1 -0
  43. package/dist/services/ExposedApiRegistry/contracts/errors.d.ts +132 -0
  44. package/dist/services/ExposedApiRegistry/contracts/errors.js +195 -0
  45. package/dist/services/ExposedApiRegistry/contracts/index.d.ts +9 -0
  46. package/dist/services/ExposedApiRegistry/contracts/index.js +4 -0
  47. package/dist/services/ExposedApiRegistry/contracts/policy.d.ts +90 -0
  48. package/dist/services/ExposedApiRegistry/contracts/policy.js +169 -0
  49. package/dist/services/ExposedApiRegistry/contracts/registrant.d.ts +37 -0
  50. package/dist/services/ExposedApiRegistry/contracts/registrant.js +36 -0
  51. package/dist/services/ExposedApiRegistry/contracts/types.d.ts +133 -0
  52. package/dist/services/ExposedApiRegistry/contracts/types.js +73 -0
  53. package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.d.ts +44 -0
  54. package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.js +58 -0
  55. package/dist/services/ExposedApiRegistry/descriptor/tokens.d.ts +8 -0
  56. package/dist/services/ExposedApiRegistry/descriptor/tokens.js +8 -0
  57. package/dist/services/ExposedApiRegistry/index.d.ts +6 -0
  58. package/dist/services/ExposedApiRegistry/index.js +5 -0
  59. package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.d.ts +68 -0
  60. package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.js +452 -0
  61. package/dist/services/ExposedApiRegistry/orchestrator/index.d.ts +2 -0
  62. package/dist/services/ExposedApiRegistry/orchestrator/index.js +1 -0
  63. package/dist/services/ExposedApiRegistry/serviceModule.d.ts +10 -0
  64. package/dist/services/ExposedApiRegistry/serviceModule.js +20 -0
  65. package/dist/services/ExposedApiRegistry/storage/protection.d.ts +21 -0
  66. package/dist/services/ExposedApiRegistry/storage/protection.js +35 -0
  67. package/dist/services/ExposedApiRegistry/storage/scopeRecord.d.ts +45 -0
  68. package/dist/services/ExposedApiRegistry/storage/scopeRecord.js +178 -0
  69. package/dist/services/IdentityRegistry/contracts/errors.d.ts +88 -0
  70. package/dist/services/IdentityRegistry/contracts/errors.js +128 -0
  71. package/dist/services/IdentityRegistry/contracts/index.d.ts +5 -0
  72. package/dist/services/IdentityRegistry/contracts/index.js +3 -0
  73. package/dist/services/IdentityRegistry/contracts/types.d.ts +77 -0
  74. package/dist/services/IdentityRegistry/contracts/types.js +18 -0
  75. package/dist/services/IdentityRegistry/descriptor/descriptor.d.ts +36 -0
  76. package/dist/services/IdentityRegistry/descriptor/descriptor.js +44 -0
  77. package/dist/services/IdentityRegistry/descriptor/tokens.d.ts +8 -0
  78. package/dist/services/IdentityRegistry/descriptor/tokens.js +8 -0
  79. package/dist/services/IdentityRegistry/index.d.ts +11 -0
  80. package/dist/services/IdentityRegistry/index.js +6 -0
  81. package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.d.ts +47 -0
  82. package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.js +240 -0
  83. package/dist/services/IdentityRegistry/serviceModule.d.ts +10 -0
  84. package/dist/services/IdentityRegistry/serviceModule.js +24 -0
  85. package/dist/services/IdentityRegistry/storage/registryDocument.d.ts +55 -0
  86. package/dist/services/IdentityRegistry/storage/registryDocument.js +235 -0
  87. package/dist/services/Interception/contracts/IInterceptionService.d.ts +155 -0
  88. package/dist/services/Interception/contracts/IInterceptionService.js +12 -0
  89. package/dist/services/Interception/contracts/errors.d.ts +26 -0
  90. package/dist/services/Interception/contracts/errors.js +35 -0
  91. package/dist/services/Interception/contracts/index.d.ts +3 -0
  92. package/dist/services/Interception/contracts/index.js +3 -0
  93. package/dist/services/Interception/contracts/tokens.d.ts +2 -0
  94. package/dist/services/Interception/contracts/tokens.js +2 -0
  95. package/dist/services/Interception/descriptor/InterceptionDescriptor.d.ts +9 -0
  96. package/dist/services/Interception/descriptor/InterceptionDescriptor.js +50 -0
  97. package/dist/services/Interception/descriptor/tokens.d.ts +1 -0
  98. package/dist/services/Interception/descriptor/tokens.js +1 -0
  99. package/dist/services/Interception/index.d.ts +4 -0
  100. package/dist/services/Interception/index.js +4 -0
  101. package/dist/services/Interception/orchestrator/InterceptionService.d.ts +40 -0
  102. package/dist/services/Interception/orchestrator/InterceptionService.js +343 -0
  103. package/dist/services/Interception/orchestrator/index.d.ts +1 -0
  104. package/dist/services/Interception/orchestrator/index.js +1 -0
  105. package/dist/services/Interception/serviceModule.d.ts +2 -0
  106. package/dist/services/Interception/serviceModule.js +5 -0
  107. package/dist/services/Parser/contracts/IParserService.d.ts +21 -0
  108. package/dist/services/Parser/contracts/IParserService.js +1 -0
  109. package/dist/services/Parser/contracts/errors.d.ts +25 -0
  110. package/dist/services/Parser/contracts/errors.js +33 -0
  111. package/dist/services/Parser/contracts/index.d.ts +4 -0
  112. package/dist/services/Parser/contracts/index.js +1 -0
  113. package/dist/services/Parser/contracts/types.d.ts +42 -0
  114. package/dist/services/Parser/contracts/types.js +1 -0
  115. package/dist/services/Parser/descriptor/ParserDescriptor.d.ts +23 -0
  116. package/dist/services/Parser/descriptor/ParserDescriptor.js +50 -0
  117. package/dist/services/Parser/descriptor/tokens.d.ts +8 -0
  118. package/dist/services/Parser/descriptor/tokens.js +8 -0
  119. package/dist/services/Parser/index.d.ts +8 -0
  120. package/dist/services/Parser/index.js +8 -0
  121. package/dist/services/Parser/orchestrator/ParserService.d.ts +20 -0
  122. package/dist/services/Parser/orchestrator/ParserService.js +105 -0
  123. package/dist/services/Parser/orchestrator/index.d.ts +1 -0
  124. package/dist/services/Parser/orchestrator/index.js +1 -0
  125. package/dist/services/Parser/parser/indexSynthesis.d.ts +11 -0
  126. package/dist/services/Parser/parser/indexSynthesis.js +13 -0
  127. package/dist/services/Parser/parser/parameters.d.ts +14 -0
  128. package/dist/services/Parser/parser/parameters.js +89 -0
  129. package/dist/services/Parser/parser/scanner.d.ts +48 -0
  130. package/dist/services/Parser/parser/scanner.js +156 -0
  131. package/dist/services/Parser/parser/syntax.d.ts +30 -0
  132. package/dist/services/Parser/parser/syntax.js +34 -0
  133. package/dist/services/Parser/serviceModule.d.ts +2 -0
  134. package/dist/services/Parser/serviceModule.js +5 -0
  135. package/dist/services/Router/bootOptions.d.ts +2 -0
  136. package/dist/services/Router/bootOptions.js +2 -0
  137. package/dist/services/Router/contracts/IRouterService.d.ts +43 -0
  138. package/dist/services/Router/contracts/IRouterService.js +1 -0
  139. package/dist/services/Router/contracts/caller.d.ts +6 -0
  140. package/dist/services/Router/contracts/caller.js +6 -0
  141. package/dist/services/Router/contracts/errors.d.ts +67 -0
  142. package/dist/services/Router/contracts/errors.js +90 -0
  143. package/dist/services/Router/contracts/index.d.ts +8 -0
  144. package/dist/services/Router/contracts/index.js +4 -0
  145. package/dist/services/Router/contracts/kind.d.ts +7 -0
  146. package/dist/services/Router/contracts/kind.js +10 -0
  147. package/dist/services/Router/contracts/registrant.d.ts +23 -0
  148. package/dist/services/Router/contracts/registrant.js +13 -0
  149. package/dist/services/Router/contracts/types.d.ts +110 -0
  150. package/dist/services/Router/contracts/types.js +1 -0
  151. package/dist/services/Router/descriptor/RouterDescriptor.d.ts +32 -0
  152. package/dist/services/Router/descriptor/RouterDescriptor.js +92 -0
  153. package/dist/services/Router/descriptor/tokens.d.ts +9 -0
  154. package/dist/services/Router/descriptor/tokens.js +9 -0
  155. package/dist/services/Router/index.d.ts +4 -0
  156. package/dist/services/Router/index.js +4 -0
  157. package/dist/services/Router/orchestrator/RouterService.d.ts +93 -0
  158. package/dist/services/Router/orchestrator/RouterService.js +457 -0
  159. package/dist/services/Router/orchestrator/index.d.ts +2 -0
  160. package/dist/services/Router/orchestrator/index.js +1 -0
  161. package/dist/services/Router/serviceModule.d.ts +4 -0
  162. package/dist/services/Router/serviceModule.js +22 -0
  163. package/dist/services/WasmCage/index.d.ts +7 -0
  164. package/dist/services/WasmCage/index.js +4 -0
  165. package/dist/services/WasmCage/scripts/prepin.d.ts +1 -0
  166. package/dist/services/WasmCage/scripts/prepin.js +38 -0
  167. package/dist/services/WasmCage/serviceModule.d.ts +12 -0
  168. package/dist/services/WasmCage/serviceModule.js +18 -0
  169. package/dist/services/WasmCage/src/caged.d.ts +121 -0
  170. package/dist/services/WasmCage/src/caged.js +460 -0
  171. package/dist/services/WasmCage/src/descriptor.d.ts +47 -0
  172. package/dist/services/WasmCage/src/descriptor.js +56 -0
  173. package/dist/services/WasmCage/src/native.d.ts +29 -0
  174. package/dist/services/WasmCage/src/native.js +66 -0
  175. package/dist/services/WasmCage/src/nativeDigests.d.ts +9 -0
  176. package/dist/services/WasmCage/src/nativeDigests.js +15 -0
  177. package/dist/services/WasmCage/src/package.d.ts +36 -0
  178. package/dist/services/WasmCage/src/package.js +122 -0
  179. package/dist/services/shared/canonicalJson.d.ts +29 -0
  180. package/dist/services/shared/canonicalJson.js +93 -0
  181. package/dist/services/shared/documentStore.d.ts +16 -0
  182. package/dist/services/shared/documentStore.js +98 -0
  183. package/dist/src/bootstrap/bootKernelInternal.d.ts +19 -0
  184. package/dist/src/bootstrap/bootKernelInternal.js +633 -0
  185. package/dist/src/bootstrap/bootTypes.d.ts +113 -0
  186. package/dist/src/bootstrap/bootTypes.js +1 -0
  187. package/dist/src/bootstrap/config/index.d.ts +3 -0
  188. package/dist/src/bootstrap/config/index.js +2 -0
  189. package/dist/src/bootstrap/config/integrity.d.ts +45 -0
  190. package/dist/src/bootstrap/config/integrity.js +92 -0
  191. package/dist/src/bootstrap/config/parse.d.ts +15 -0
  192. package/dist/src/bootstrap/config/parse.js +81 -0
  193. package/dist/src/bootstrap/config/pathWriteGuard.d.ts +20 -0
  194. package/dist/src/bootstrap/config/pathWriteGuard.js +349 -0
  195. package/dist/src/bootstrap/config/types.d.ts +41 -0
  196. package/dist/src/bootstrap/config/types.js +15 -0
  197. package/dist/src/bootstrap/hardcore.d.ts +212 -0
  198. package/dist/src/bootstrap/hardcore.js +312 -0
  199. package/dist/src/bootstrap/hardcoreServices.d.ts +10 -0
  200. package/dist/src/bootstrap/hardcoreServices.js +258 -0
  201. package/dist/src/bootstrap/index.d.ts +13 -0
  202. package/dist/src/bootstrap/index.js +7 -0
  203. package/dist/src/bootstrap/loaded.d.ts +30 -0
  204. package/dist/src/bootstrap/loaded.js +45 -0
  205. package/dist/src/bootstrap/packageRequirements.d.ts +26 -0
  206. package/dist/src/bootstrap/packageRequirements.js +52 -0
  207. package/dist/src/bootstrap/reload.d.ts +44 -0
  208. package/dist/src/bootstrap/reload.js +45 -0
  209. package/dist/src/bootstrap/seal.d.ts +32 -0
  210. package/dist/src/bootstrap/seal.js +101 -0
  211. package/dist/src/contracts/accessBroker.d.ts +53 -0
  212. package/dist/src/contracts/accessBroker.js +1 -0
  213. package/dist/src/contracts/brudOperation.d.ts +20 -0
  214. package/dist/src/contracts/brudOperation.js +20 -0
  215. package/dist/src/contracts/callChain.d.ts +161 -0
  216. package/dist/src/contracts/callChain.js +19 -0
  217. package/dist/src/contracts/capability.d.ts +26 -0
  218. package/dist/src/contracts/capability.js +26 -0
  219. package/dist/src/contracts/capabilitySet.d.ts +23 -0
  220. package/dist/src/contracts/capabilitySet.js +72 -0
  221. package/dist/src/contracts/container.d.ts +17 -0
  222. package/dist/src/contracts/container.js +8 -0
  223. package/dist/src/contracts/context.d.ts +19 -0
  224. package/dist/src/contracts/context.js +1 -0
  225. package/dist/src/contracts/contextContract.d.ts +132 -0
  226. package/dist/src/contracts/contextContract.js +274 -0
  227. package/dist/src/contracts/dispatchView.d.ts +21 -0
  228. package/dist/src/contracts/dispatchView.js +1 -0
  229. package/dist/src/contracts/handler.d.ts +21 -0
  230. package/dist/src/contracts/handler.js +1 -0
  231. package/dist/src/contracts/index.d.ts +26 -0
  232. package/dist/src/contracts/index.js +9 -0
  233. package/dist/src/contracts/kernel.d.ts +60 -0
  234. package/dist/src/contracts/kernel.js +1 -0
  235. package/dist/src/contracts/lifecycle.d.ts +59 -0
  236. package/dist/src/contracts/lifecycle.js +1 -0
  237. package/dist/src/contracts/manifest.d.ts +180 -0
  238. package/dist/src/contracts/manifest.js +334 -0
  239. package/dist/src/contracts/pipeline.d.ts +8 -0
  240. package/dist/src/contracts/pipeline.js +1 -0
  241. package/dist/src/contracts/policy.d.ts +75 -0
  242. package/dist/src/contracts/policy.js +77 -0
  243. package/dist/src/contracts/registry.d.ts +7 -0
  244. package/dist/src/contracts/registry.js +1 -0
  245. package/dist/src/contracts/serviceDescriptor.d.ts +67 -0
  246. package/dist/src/contracts/serviceDescriptor.js +1 -0
  247. package/dist/src/contracts/serviceToken.d.ts +36 -0
  248. package/dist/src/contracts/serviceToken.js +16 -0
  249. package/dist/src/engine/BrudKernel.d.ts +120 -0
  250. package/dist/src/engine/BrudKernel.js +395 -0
  251. package/dist/src/engine/ExecutionPipeline.d.ts +13 -0
  252. package/dist/src/engine/ExecutionPipeline.js +62 -0
  253. package/dist/src/engine/KernelAccessBroker.d.ts +47 -0
  254. package/dist/src/engine/KernelAccessBroker.js +107 -0
  255. package/dist/src/engine/KernelRegistry.d.ts +14 -0
  256. package/dist/src/engine/KernelRegistry.js +33 -0
  257. package/dist/src/engine/OperationRegistry.d.ts +9 -0
  258. package/dist/src/engine/OperationRegistry.js +18 -0
  259. package/dist/src/engine/ServiceContainer.d.ts +13 -0
  260. package/dist/src/engine/ServiceContainer.js +53 -0
  261. package/dist/src/engine/callChain.d.ts +68 -0
  262. package/dist/src/engine/callChain.js +175 -0
  263. package/dist/src/engine/dag.d.ts +2 -0
  264. package/dist/src/engine/dag.js +34 -0
  265. package/dist/src/engine/errors.d.ts +26 -0
  266. package/dist/src/engine/errors.js +52 -0
  267. package/dist/src/engine/index.d.ts +11 -0
  268. package/dist/src/engine/index.js +8 -0
  269. package/dist/src/engine/state.d.ts +1 -0
  270. package/dist/src/engine/state.js +1 -0
  271. package/dist/src/validation/jsonSchema/compile.d.ts +8 -0
  272. package/dist/src/validation/jsonSchema/compile.js +386 -0
  273. package/dist/src/validation/jsonSchema/index.d.ts +3 -0
  274. package/dist/src/validation/jsonSchema/index.js +2 -0
  275. package/dist/src/validation/jsonSchema/jsonValue.d.ts +29 -0
  276. package/dist/src/validation/jsonSchema/jsonValue.js +190 -0
  277. package/dist/src/validation/jsonSchema/pattern.d.ts +28 -0
  278. package/dist/src/validation/jsonSchema/pattern.js +155 -0
  279. package/dist/src/validation/jsonSchema/types.d.ts +71 -0
  280. package/dist/src/validation/jsonSchema/types.js +15 -0
  281. package/package.json +59 -4
  282. package/services/WasmCage/native/brud-wasm-cage.darwin-arm64.node +0 -0
  283. package/services/WasmCage/native/brud-wasm-cage.darwin-x64.node +0 -0
  284. package/services/WasmCage/native/brud-wasm-cage.linux-arm64-gnu.node +0 -0
  285. package/services/WasmCage/native/brud-wasm-cage.linux-x64-gnu.node +0 -0
  286. package/services/WasmCage/native/brud-wasm-cage.win32-x64-msvc.node +0 -0
@@ -0,0 +1,343 @@
1
+ import { createCapabilitySet } from '../../../src/contracts/capabilitySet.js';
2
+ import { compileJsonSchema } from '../../../src/validation/jsonSchema/index.js';
3
+ import { freezeJsonCopy, inspectJsonValue } from '../../../src/validation/jsonSchema/jsonValue.js';
4
+ import { InterceptionDeclarationError } from '../contracts/errors.js';
5
+ import { INTERCEPTION_OUTPUT_CEILINGS, } from '../contracts/IInterceptionService.js';
6
+ /** Source name the interception hardcore records observations under. */
7
+ const OBSERVATION_SOURCE = 'brud.core.interception';
8
+ /** Arguments must be a plain JSON array within the kernel validator's limits. */
9
+ const ARGS_SCHEMA = (() => {
10
+ const compiled = compileJsonSchema({ type: 'array' });
11
+ if (!compiled.ok) {
12
+ throw new Error('interception argument schema failed to compile');
13
+ }
14
+ return compiled.schema;
15
+ })();
16
+ function majorOf(version) {
17
+ if (version === undefined) {
18
+ return 1;
19
+ }
20
+ return typeof version === 'number' ? version : Number.parseInt(version.split('.')[0] ?? '', 10);
21
+ }
22
+ function pointKey(name, version) {
23
+ return `${name}@${String(majorOf(version))}`;
24
+ }
25
+ function isInterceptor(value) {
26
+ return typeof value?.intercept === 'function';
27
+ }
28
+ function isResultInterceptor(value) {
29
+ return typeof value?.interceptResult === 'function';
30
+ }
31
+ /** Largest value shape the output stage will carry: plain JSON of ordinary size. */
32
+ const OUTPUT_JSON_LIMITS = Object.freeze({ maxDepth: 64, maxNodes: 100_000 });
33
+ function jsonBytes(value) {
34
+ return Buffer.byteLength(JSON.stringify(value), 'utf8');
35
+ }
36
+ /**
37
+ * Reads a point's `outputLimits`: any of the three limits may be lowered,
38
+ * none may be raised above its kernel ceiling, and one addition may not be
39
+ * allowed to exceed all additions together.
40
+ */
41
+ function parseOutputLimits(owner, key, declared) {
42
+ const limits = { ...INTERCEPTION_OUTPUT_CEILINGS };
43
+ for (const [name, value] of Object.entries(declared ?? {})) {
44
+ if (!(name in INTERCEPTION_OUTPUT_CEILINGS)) {
45
+ throw new InterceptionDeclarationError(owner, `outputLimits of "${key}" has an unknown limit "${name}"`);
46
+ }
47
+ const ceiling = INTERCEPTION_OUTPUT_CEILINGS[name];
48
+ if (typeof value !== 'number' || !Number.isInteger(value) || value < 1 || value > ceiling) {
49
+ throw new InterceptionDeclarationError(owner, `outputLimits.${name} of "${key}" must be a whole number from 1 to ${String(ceiling)}`);
50
+ }
51
+ limits[name] = value;
52
+ }
53
+ if (limits.maxAdditionBytes > limits.maxTotalBytes) {
54
+ throw new InterceptionDeclarationError(owner, `outputLimits of "${key}" allow one addition to exceed all additions together`);
55
+ }
56
+ return Object.freeze(limits);
57
+ }
58
+ function isValidArgs(value) {
59
+ return Array.isArray(value) && ARGS_SCHEMA.validate(value).valid;
60
+ }
61
+ export class InterceptionService {
62
+ authority;
63
+ #points = new Map();
64
+ bindAuthority(value) {
65
+ this.authority = value;
66
+ }
67
+ /**
68
+ * Builds the interception-point table from the composition's manifests.
69
+ *
70
+ * A point must sit on an exposure its giver declares; every admitted token
71
+ * must be a participant that declares an interception of that point; every
72
+ * declared interception must be admitted by a point. Anything else refuses
73
+ * the boot.
74
+ */
75
+ registerComposition(participants) {
76
+ const byToken = new Map(participants.map((participant) => [participant.token, participant]));
77
+ const requests = new Map();
78
+ for (const participant of participants) {
79
+ for (const interception of participant.manifest.interceptions) {
80
+ const key = pointKey(interception.target, interception.version);
81
+ const tokens = requests.get(key) ?? new Set();
82
+ tokens.add(participant.token);
83
+ requests.set(key, tokens);
84
+ }
85
+ }
86
+ for (const participant of participants) {
87
+ if (participant.manifest.interceptionPoints.length === 0) {
88
+ continue;
89
+ }
90
+ const owner = participant.identity;
91
+ if (owner === undefined) {
92
+ throw new InterceptionDeclarationError(participant.token, 'declares interception points but has no kernel identity');
93
+ }
94
+ for (const point of participant.manifest.interceptionPoints) {
95
+ const key = pointKey(point.exposure, point.version);
96
+ const gives = participant.manifest.exposures.some((exposure) => pointKey(exposure.name, exposure.version) === key);
97
+ if (!gives) {
98
+ throw new InterceptionDeclarationError(participant.token, `opens an interception point on "${key}", which it does not expose`);
99
+ }
100
+ if (this.#points.has(key)) {
101
+ throw new InterceptionDeclarationError(participant.token, `interception point "${key}" is declared twice`);
102
+ }
103
+ const interceptors = point.admit.map((token) => {
104
+ const interceptor = byToken.get(token);
105
+ if (interceptor === undefined) {
106
+ throw new InterceptionDeclarationError(participant.token, `admits "${token}", which is not in the composition`);
107
+ }
108
+ if (token === participant.token) {
109
+ throw new InterceptionDeclarationError(participant.token, `cannot admit itself on "${key}"`);
110
+ }
111
+ if (requests.get(key)?.has(token) !== true) {
112
+ throw new InterceptionDeclarationError(participant.token, `admits "${token}", which declares no interception of "${key}"`);
113
+ }
114
+ if (interceptor.identity === undefined) {
115
+ throw new InterceptionDeclarationError(token, 'is admitted as an interceptor but has no kernel identity');
116
+ }
117
+ const declared = interceptor.manifest.interceptions.find((entry) => pointKey(entry.target, entry.version) === key);
118
+ return Object.freeze({ token, identity: interceptor.identity, stages: Object.freeze([...(declared?.stages ?? ['output'])]) });
119
+ });
120
+ this.#points.set(key, Object.freeze({
121
+ key,
122
+ owner,
123
+ interceptors: Object.freeze(interceptors),
124
+ limits: parseOutputLimits(participant.token, key, point.outputLimits),
125
+ }));
126
+ }
127
+ }
128
+ for (const [key, tokens] of requests) {
129
+ for (const token of tokens) {
130
+ if (this.#points.get(key)?.interceptors.some((interceptor) => interceptor.token === token) !== true) {
131
+ throw new InterceptionDeclarationError(token, `declares an interception of "${key}" that no giver admits`);
132
+ }
133
+ }
134
+ }
135
+ }
136
+ evaluate(target, method, args, options) {
137
+ const context = this.authority?.current();
138
+ const caller = context === undefined ? undefined : { ...context.caller, origin: context.origin };
139
+ return this.evaluateAs(caller, target, method, args, options);
140
+ }
141
+ list() {
142
+ return Array.from(this.#points.keys());
143
+ }
144
+ /**
145
+ * Evaluates the point for `resolver`, which must be the point's owner. The
146
+ * interceptors run in the giver's admitted order, each as itself: the first
147
+ * `block` wins; `modify` chains; a throw or an invalid verdict blocks
148
+ * (fail closed).
149
+ */
150
+ evaluateAs(resolver, target, method, args, options) {
151
+ const key = target.includes('@') ? target : `${target}@1`;
152
+ const point = this.#points.get(key);
153
+ const authority = this.authority;
154
+ if (authority === undefined) {
155
+ return this.#refuse(key, 'interception is not bound');
156
+ }
157
+ if (point === undefined) {
158
+ return this.#refuse(key, 'unknown interception point');
159
+ }
160
+ if (resolver?.identity === null || resolver?.identity === undefined || resolver.identity !== point.owner) {
161
+ return this.#refuse(key, 'only the interception point owner may evaluate it');
162
+ }
163
+ if (typeof method !== 'string' || method.length === 0 || !isValidArgs(args)) {
164
+ return this.#refuse(key, 'method must be a non-empty string and args a plain JSON array');
165
+ }
166
+ const caller = options?.caller ?? resolver;
167
+ let call = Object.freeze({
168
+ target: key,
169
+ method,
170
+ args: freezeJsonCopy(args),
171
+ caller: Object.freeze({
172
+ identity: caller.identity,
173
+ callerClass: caller.callerClass,
174
+ official: caller.official,
175
+ // The giver names the caller it is intercepting for; whatever it passes, the interceptor sees the one read-only shape.
176
+ capabilities: createCapabilitySet(caller.capabilities ?? []),
177
+ origin: caller.origin,
178
+ }),
179
+ });
180
+ const modifiedBy = [];
181
+ for (const interceptor of point.interceptors) {
182
+ if (!interceptor.stages.includes('input')) {
183
+ continue;
184
+ }
185
+ let verdict;
186
+ try {
187
+ const instance = authority.instanceOf(interceptor.identity);
188
+ if (!isInterceptor(instance)) {
189
+ throw new Error('the interceptor does not implement intercept');
190
+ }
191
+ const current = call;
192
+ verdict = authority.runAs(interceptor.identity, () => instance.intercept(current));
193
+ }
194
+ catch (error) {
195
+ return this.#fail(key, interceptor.token, error instanceof Error ? error.message : 'interceptor threw');
196
+ }
197
+ if (verdict?.verdict === 'allow') {
198
+ continue;
199
+ }
200
+ if (verdict?.verdict === 'block' && typeof verdict.reason === 'string') {
201
+ authority.observe(OBSERVATION_SOURCE, 'interception.blocked', { target: key, method, interceptor: interceptor.token, reason: verdict.reason });
202
+ return Object.freeze({ allowed: false, reason: verdict.reason, interceptor: interceptor.token });
203
+ }
204
+ if (verdict?.verdict === 'modify' && isValidArgs(verdict.args)) {
205
+ call = Object.freeze({ ...call, args: freezeJsonCopy(verdict.args) });
206
+ modifiedBy.push(interceptor.token);
207
+ authority.observe(OBSERVATION_SOURCE, 'interception.modified', { target: key, method, interceptor: interceptor.token });
208
+ continue;
209
+ }
210
+ return this.#fail(key, interceptor.token, 'invalid verdict');
211
+ }
212
+ return Object.freeze({ allowed: true, args: call.args, modifiedBy: Object.freeze(modifiedBy) });
213
+ }
214
+ evaluateResult(target, method, args, result, options) {
215
+ const context = this.authority?.current();
216
+ const caller = context === undefined ? undefined : { ...context.caller, origin: context.origin };
217
+ return this.evaluateResultAs(caller, target, method, args, result, options);
218
+ }
219
+ /**
220
+ * Runs the output stage for `resolver`, which must be the point's owner. The
221
+ * interceptors that declared the stage run in the giver's admitted order,
222
+ * each as itself and each seeing only the original result; each may append
223
+ * one piece of content and nothing else. Any failure withholds the result.
224
+ */
225
+ evaluateResultAs(resolver, target, method, args, result, options) {
226
+ const key = target.includes('@') ? target : `${target}@1`;
227
+ const point = this.#points.get(key);
228
+ const authority = this.authority;
229
+ if (authority === undefined) {
230
+ return this.#refuseResult(key, 'interception is not bound');
231
+ }
232
+ if (point === undefined) {
233
+ return this.#refuseResult(key, 'unknown interception point');
234
+ }
235
+ if (resolver?.identity === null || resolver?.identity === undefined || resolver.identity !== point.owner) {
236
+ return this.#refuseResult(key, 'only the interception point owner may evaluate it');
237
+ }
238
+ const taking = point.interceptors.filter((interceptor) => interceptor.stages.includes('output'));
239
+ if (taking.length === 0) {
240
+ return Object.freeze({ applied: false });
241
+ }
242
+ if (typeof method !== 'string' || method.length === 0 || !isValidArgs(args)) {
243
+ return this.#refuseResult(key, 'method must be a non-empty string and args a plain JSON array');
244
+ }
245
+ // A result the output stage cannot carry is the giver's own data, never an
246
+ // interceptor's doing. The stage is skipped and the giver ships its result.
247
+ if (inspectJsonValue(result, OUTPUT_JSON_LIMITS) !== null) {
248
+ return this.#skipStage(key, 'the result must be plain JSON to take part in the output stage');
249
+ }
250
+ const resultBytes = result === undefined ? 0 : jsonBytes(result);
251
+ if (resultBytes > point.limits.maxResultBytes) {
252
+ return this.#skipStage(key, `the result is ${String(resultBytes)} bytes; the limit is ${String(point.limits.maxResultBytes)}`);
253
+ }
254
+ const caller = options?.caller ?? resolver;
255
+ const frozenResult = freezeJsonCopy(result);
256
+ const call = Object.freeze({
257
+ target: key,
258
+ method,
259
+ args: freezeJsonCopy(args),
260
+ caller: Object.freeze({
261
+ identity: caller.identity,
262
+ callerClass: caller.callerClass,
263
+ official: caller.official,
264
+ capabilities: createCapabilitySet(caller.capabilities ?? []),
265
+ origin: caller.origin,
266
+ }),
267
+ result: frozenResult,
268
+ });
269
+ const additions = [];
270
+ const ran = [];
271
+ const skipped = [];
272
+ let total = 0;
273
+ // The output stage can only append, so an interceptor that misbehaves is
274
+ // skipped and the result is delivered without its contribution. It must
275
+ // never be able to withhold the giver's result by failing.
276
+ for (const interceptor of taking) {
277
+ const skip = (reason) => {
278
+ skipped.push(Object.freeze({ interceptor: interceptor.token, reason }));
279
+ authority.observe(OBSERVATION_SOURCE, 'interception.result.skipped', { target: key, method, interceptor: interceptor.token, reason });
280
+ };
281
+ let verdict;
282
+ try {
283
+ const instance = authority.instanceOf(interceptor.identity);
284
+ if (!isResultInterceptor(instance)) {
285
+ throw new Error('the interceptor does not implement interceptResult (an interceptor that means to see arguments must declare the input stage)');
286
+ }
287
+ verdict = authority.runAs(interceptor.identity, () => instance.interceptResult(call));
288
+ }
289
+ catch (error) {
290
+ skip(error instanceof Error ? error.message : 'interceptor threw');
291
+ continue;
292
+ }
293
+ if (verdict?.verdict === 'none') {
294
+ ran.push(interceptor.token);
295
+ authority.observe(OBSERVATION_SOURCE, 'interception.result.unchanged', { target: key, method, interceptor: interceptor.token });
296
+ continue;
297
+ }
298
+ if (verdict?.verdict !== 'append' || inspectJsonValue(verdict.content, OUTPUT_JSON_LIMITS) !== null || verdict.content === undefined) {
299
+ skip('invalid output verdict: the output stage can only append');
300
+ continue;
301
+ }
302
+ const bytes = jsonBytes(verdict.content);
303
+ if (bytes > point.limits.maxAdditionBytes) {
304
+ skip(`the addition is ${String(bytes)} bytes; the limit is ${String(point.limits.maxAdditionBytes)}`);
305
+ continue;
306
+ }
307
+ if (total + bytes > point.limits.maxTotalBytes) {
308
+ skip(`the additions together would exceed ${String(point.limits.maxTotalBytes)} bytes`);
309
+ continue;
310
+ }
311
+ total += bytes;
312
+ ran.push(interceptor.token);
313
+ additions.push(Object.freeze({ interceptor: interceptor.token, content: freezeJsonCopy(verdict.content) }));
314
+ authority.observe(OBSERVATION_SOURCE, 'interception.result.appended', { target: key, method, interceptor: interceptor.token, bytes });
315
+ }
316
+ return Object.freeze({
317
+ applied: true,
318
+ allowed: true,
319
+ envelope: Object.freeze({
320
+ result: frozenResult,
321
+ additions: Object.freeze(additions),
322
+ interceptedBy: Object.freeze(ran),
323
+ skipped: Object.freeze(skipped),
324
+ }),
325
+ });
326
+ }
327
+ #refuseResult(key, reason) {
328
+ this.authority?.observe(OBSERVATION_SOURCE, 'interception.result.refused', { target: key, reason });
329
+ return Object.freeze({ applied: true, allowed: false, reason });
330
+ }
331
+ #skipStage(key, reason) {
332
+ this.authority?.observe(OBSERVATION_SOURCE, 'interception.result.stage-skipped', { target: key, reason });
333
+ return Object.freeze({ applied: false });
334
+ }
335
+ #refuse(key, reason) {
336
+ this.authority?.observe(OBSERVATION_SOURCE, 'interception.refused', { target: key, reason });
337
+ return Object.freeze({ allowed: false, reason });
338
+ }
339
+ #fail(key, interceptor, reason) {
340
+ this.authority?.observe(OBSERVATION_SOURCE, 'interception.failed', { target: key, interceptor, reason });
341
+ return Object.freeze({ allowed: false, reason: `interceptor-failed: ${reason}`, interceptor });
342
+ }
343
+ }
@@ -0,0 +1 @@
1
+ export * from './InterceptionService.js';
@@ -0,0 +1 @@
1
+ export * from './InterceptionService.js';
@@ -0,0 +1,2 @@
1
+ import type { KernelServiceModuleContext } from '../../src/bootstrap/bootTypes.js';
2
+ export declare function createService(context: KernelServiceModuleContext): import("../../index.js").ServiceDescriptor<import("./index.js").IInterceptionService, import("./index.js").InterceptionService>;
@@ -0,0 +1,5 @@
1
+ import { createInterceptionDescriptor } from './descriptor/InterceptionDescriptor.js';
2
+ export function createService(context) {
3
+ void context;
4
+ return createInterceptionDescriptor();
5
+ }
@@ -0,0 +1,21 @@
1
+ import type { BrudParseOptions, BrudParseResult } from './types.js';
2
+ /**
3
+ * Level-1 Brud Protocol v2 Parser.
4
+ *
5
+ * Converts a raw `[BRUD]` document into an ordered list of internal
6
+ * operations. The service is deliberately schema-agnostic and routing-agnostic:
7
+ * it neither looks up a tool or action nor knows which service will consume
8
+ * the result.
9
+ */
10
+ export interface IBrudParserService {
11
+ /**
12
+ * Scans a raw document into operations without dispatching anything.
13
+ *
14
+ * The parser is fail-closed: a malformed document returns `ok: false` and no
15
+ * partial operation list. Brace regions are captured literally.
16
+ *
17
+ * @param rawInput - Raw model output, including any surrounding prose.
18
+ * @param options - Operation bound.
19
+ */
20
+ parse(rawInput: string, options?: BrudParseOptions): BrudParseResult;
21
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ /** Stable, machine-readable codes for Parser failures. */
2
+ export type ParserErrorCode = 'PARSER_DISPOSED' | 'PARSE_ERROR' | 'OPERATION_LIMIT_EXCEEDED';
3
+ /** Raised when the parser is used after disposal. */
4
+ export declare class ParserDisposedError extends Error {
5
+ readonly code: "PARSER_DISPOSED";
6
+ constructor();
7
+ }
8
+ /** Base class for parser-domain failures other than structural parse errors. */
9
+ export declare abstract class ParserError extends Error {
10
+ abstract readonly code: ParserErrorCode;
11
+ protected constructor(message: string, options?: ErrorOptions);
12
+ }
13
+ /** Raised when a document exceeds the configured operation bound. */
14
+ export declare class OperationLimitExceededError extends ParserError {
15
+ readonly code: "OPERATION_LIMIT_EXCEEDED";
16
+ /** Number of operations the document contained. */
17
+ readonly observed: number;
18
+ /** Configured maximum. */
19
+ readonly limit: number;
20
+ /**
21
+ * @param observed - Operations found in the document.
22
+ * @param limit - Configured maximum.
23
+ */
24
+ constructor(observed: number, limit: number);
25
+ }
@@ -0,0 +1,33 @@
1
+ /** Raised when the parser is used after disposal. */
2
+ export class ParserDisposedError extends Error {
3
+ code = 'PARSER_DISPOSED';
4
+ constructor() {
5
+ super('Brud parser has been disposed');
6
+ this.name = 'ParserDisposedError';
7
+ }
8
+ }
9
+ /** Base class for parser-domain failures other than structural parse errors. */
10
+ export class ParserError extends Error {
11
+ constructor(message, options) {
12
+ super(message, options);
13
+ this.name = 'ParserError';
14
+ }
15
+ }
16
+ /** Raised when a document exceeds the configured operation bound. */
17
+ export class OperationLimitExceededError extends ParserError {
18
+ code = 'OPERATION_LIMIT_EXCEEDED';
19
+ /** Number of operations the document contained. */
20
+ observed;
21
+ /** Configured maximum. */
22
+ limit;
23
+ /**
24
+ * @param observed - Operations found in the document.
25
+ * @param limit - Configured maximum.
26
+ */
27
+ constructor(observed, limit) {
28
+ super(`document contains ${String(observed)} operations; the limit is ${String(limit)}`);
29
+ this.name = 'OperationLimitExceededError';
30
+ this.observed = observed;
31
+ this.limit = limit;
32
+ }
33
+ }
@@ -0,0 +1,4 @@
1
+ export type { IBrudParserService } from './IParserService.js';
2
+ export type { BrudOperation, BrudParseFailure, BrudParseOptions, BrudParseResult, } from './types.js';
3
+ export type { ParserErrorCode } from './errors.js';
4
+ export { OperationLimitExceededError, ParserDisposedError, ParserError, } from './errors.js';
@@ -0,0 +1 @@
1
+ export { OperationLimitExceededError, ParserDisposedError, ParserError, } from './errors.js';
@@ -0,0 +1,42 @@
1
+ import type { BrudOperationKind } from '../../../src/contracts/brudOperation.js';
2
+ /**
3
+ * One parsed `[BRUD]` operation.
4
+ *
5
+ * This service knows only the wire syntax: an operation carries its
6
+ * synthesized document index, the shared kind token, the name written on the
7
+ * header, and the parameter map. It never resolves a target or a service.
8
+ */
9
+ export interface BrudOperation {
10
+ /** 1-based document index synthesized from operation order. */
11
+ readonly index: string;
12
+ /** Shared operation kind, e.g. `tool` or `action`. */
13
+ readonly kind: BrudOperationKind;
14
+ /** Operation name written after the kind, e.g. `read_file`. */
15
+ readonly name: string;
16
+ /** Parsed payload. Protected regions are literal strings. */
17
+ readonly parameters: Readonly<Record<string, unknown>>;
18
+ }
19
+ /** Structured, fail-closed parse failure. */
20
+ export interface BrudParseFailure {
21
+ /** Stable machine-readable code. */
22
+ readonly code: string;
23
+ /** Human-readable summary. */
24
+ readonly friendly: string;
25
+ /** Diagnostic detail, including the document line when known. */
26
+ readonly details: string;
27
+ /** Absolute 1-based document line, when the failure is positional. */
28
+ readonly line?: number;
29
+ }
30
+ /** Bounds accepted by {@link IBrudParserService.parse}. */
31
+ export interface BrudParseOptions {
32
+ /** Upper bound on parsed operations. Default 1_000. */
33
+ readonly maxOperations?: number;
34
+ }
35
+ /** Result of a pure scan/parse. */
36
+ export type BrudParseResult = {
37
+ readonly ok: true;
38
+ readonly operations: readonly BrudOperation[];
39
+ } | {
40
+ readonly ok: false;
41
+ readonly error: BrudParseFailure;
42
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { ServiceTier } from '../../../src/contracts/lifecycle.js';
2
+ import type { ServiceDescriptor } from '../../../src/contracts/serviceDescriptor.js';
3
+ import type { IBrudParserService } from '../contracts/IParserService.js';
4
+ import { ParserService } from '../orchestrator/index.js';
5
+ /** The Parser's v1 entry exposure. */
6
+ export declare const PARSER_EXPOSURE = "syntax.parse";
7
+ /** Tier assigned to the Parser descriptor. */
8
+ export declare const PARSER_SERVICE_TIER: ServiceTier;
9
+ /** Contract version declared for the Parser interface. */
10
+ export declare const PARSER_CONTRACT_VERSION = "1.0.0";
11
+ /** Methods declared for the Parser interface. */
12
+ export declare const PARSER_CONTRACT_METHODS: readonly ["parse"];
13
+ /**
14
+ * Builds the `brud.core.parser` service descriptor.
15
+ *
16
+ * It declares no dependencies: it is a pure syntax engine. It sits before the
17
+ * routing service and every routing consumer in the standard boot order.
18
+ *
19
+ * @returns A core-tier descriptor for `brud.core.parser`.
20
+ */
21
+ export declare function createParserDescriptor(): ServiceDescriptor<IBrudParserService, ParserService>;
22
+ /** Standard parser descriptor with no overrides. */
23
+ export declare const ParserDescriptor: ServiceDescriptor<IBrudParserService, ParserService>;
@@ -0,0 +1,50 @@
1
+ import { ParserService } from '../orchestrator/index.js';
2
+ import { ParserToken } from './tokens.js';
3
+ import { withExposureBindings } from '../../ExposedApiRegistry/contracts/registrant.js';
4
+ /** The Parser's v1 entry exposure. */
5
+ export const PARSER_EXPOSURE = 'syntax.parse';
6
+ /** Tier assigned to the Parser descriptor. */
7
+ export const PARSER_SERVICE_TIER = 'core';
8
+ /** Contract version declared for the Parser interface. */
9
+ export const PARSER_CONTRACT_VERSION = '1.0.0';
10
+ /** Methods declared for the Parser interface. */
11
+ export const PARSER_CONTRACT_METHODS = ['parse'];
12
+ /**
13
+ * Builds the `brud.core.parser` service descriptor.
14
+ *
15
+ * It declares no dependencies: it is a pure syntax engine. It sits before the
16
+ * routing service and every routing consumer in the standard boot order.
17
+ *
18
+ * @returns A core-tier descriptor for `brud.core.parser`.
19
+ */
20
+ export function createParserDescriptor() {
21
+ return {
22
+ token: ParserToken,
23
+ tier: PARSER_SERVICE_TIER,
24
+ dependencies: [],
25
+ contract: {
26
+ version: PARSER_CONTRACT_VERSION,
27
+ methods: PARSER_CONTRACT_METHODS,
28
+ },
29
+ // Token access is kernel-internal (the Router). Every other caller uses the
30
+ // `syntax.parse@1` exposure; parsing is pure, so it carries no policy.
31
+ accessPolicy: {
32
+ allowedCallers: ['kernel', 'brud.core.router'],
33
+ },
34
+ manifest: {
35
+ exposures: [{ name: PARSER_EXPOSURE, version: 1, scope: 'any' }],
36
+ },
37
+ factory: () => {
38
+ const service = new ParserService();
39
+ return withExposureBindings(service, {
40
+ [`${PARSER_EXPOSURE}@1`]: {
41
+ projection: () => Object.freeze({
42
+ parse: (rawInput, options) => service.parse(rawInput, options),
43
+ }),
44
+ },
45
+ });
46
+ },
47
+ };
48
+ }
49
+ /** Standard parser descriptor with no overrides. */
50
+ export const ParserDescriptor = createParserDescriptor();
@@ -0,0 +1,8 @@
1
+ import type { IBrudParserService } from '../contracts/IParserService.js';
2
+ /**
3
+ * Kernel service token for `brud.core.parser`.
4
+ *
5
+ * Resolution grants pure syntax parsing only. The parser holds no registry,
6
+ * broker, or routing authority.
7
+ */
8
+ export declare const ParserToken: import("../../../src/contracts/serviceToken.js").ServiceToken<IBrudParserService>;
@@ -0,0 +1,8 @@
1
+ import { createServiceToken } from '../../../src/contracts/serviceToken.js';
2
+ /**
3
+ * Kernel service token for `brud.core.parser`.
4
+ *
5
+ * Resolution grants pure syntax parsing only. The parser holds no registry,
6
+ * broker, or routing authority.
7
+ */
8
+ export const ParserToken = createServiceToken('brud.core.parser', 'Brud Protocol v2 syntax parser producing kind-tagged operations');
@@ -0,0 +1,8 @@
1
+ export * from './contracts/index.js';
2
+ export * from './descriptor/ParserDescriptor.js';
3
+ export * from './descriptor/tokens.js';
4
+ export * from './orchestrator/index.js';
5
+ export { extractWrapper, scanBrudDocument, type ProtectedParameterResolver, type ScannedCall, } from './parser/scanner.js';
6
+ export { parseParameters } from './parser/parameters.js';
7
+ export { synthesizeIndex } from './parser/indexSynthesis.js';
8
+ export { BRUD_PARSE_ERROR, BrudParseError } from './parser/syntax.js';
@@ -0,0 +1,8 @@
1
+ export * from './contracts/index.js';
2
+ export * from './descriptor/ParserDescriptor.js';
3
+ export * from './descriptor/tokens.js';
4
+ export * from './orchestrator/index.js';
5
+ export { extractWrapper, scanBrudDocument, } from './parser/scanner.js';
6
+ export { parseParameters } from './parser/parameters.js';
7
+ export { synthesizeIndex } from './parser/indexSynthesis.js';
8
+ export { BRUD_PARSE_ERROR, BrudParseError } from './parser/syntax.js';
@@ -0,0 +1,20 @@
1
+ import type { IServiceLifecycle } from '../../../src/contracts/lifecycle.js';
2
+ import type { IBrudParserService } from '../contracts/IParserService.js';
3
+ import type { BrudParseOptions, BrudParseResult } from '../contracts/types.js';
4
+ /**
5
+ * Level-1 Brud Protocol v2 Parser.
6
+ *
7
+ * Owns the `[BRUD]` scanner and nothing else. It has no registry, no broker
8
+ * dependency, and no knowledge of the kind vocabulary beyond validating the
9
+ * kind token written on the header. Routing belongs to `brud.core.router`.
10
+ */
11
+ export declare class ParserService implements IBrudParserService, IServiceLifecycle {
12
+ private disposed;
13
+ /** Lifecycle no-op: bootstrap is synchronous. */
14
+ initialize(): Promise<void>;
15
+ /** Refuses every later parse. */
16
+ dispose(): Promise<void>;
17
+ /** Whether {@link dispose} has run. */
18
+ get isDisposed(): boolean;
19
+ parse(rawInput: string, options?: BrudParseOptions): BrudParseResult;
20
+ }