@brud/kernel 0.0.1 → 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.
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/serviceModules/events.d.ts +0 -0
- package/dist/serviceModules/events.js +0 -0
- package/dist/serviceModules/exposedApiRegistry.d.ts +0 -0
- package/dist/serviceModules/exposedApiRegistry.js +0 -0
- package/dist/serviceModules/identityRegistry.d.ts +0 -0
- package/dist/serviceModules/identityRegistry.js +0 -0
- package/dist/serviceModules/interception.d.ts +0 -0
- package/dist/serviceModules/interception.js +0 -0
- package/dist/serviceModules/parser.d.ts +0 -0
- package/dist/serviceModules/parser.js +0 -0
- package/dist/serviceModules/router.d.ts +0 -0
- package/dist/serviceModules/router.js +0 -0
- package/dist/serviceModules/wasmCage.d.ts +0 -0
- package/dist/serviceModules/wasmCage.js +0 -0
- package/dist/services/Events/contracts/IEventsService.d.ts +0 -0
- package/dist/services/Events/contracts/IEventsService.js +0 -0
- package/dist/services/Events/contracts/errors.d.ts +0 -0
- package/dist/services/Events/contracts/errors.js +0 -0
- package/dist/services/Events/contracts/index.d.ts +0 -0
- package/dist/services/Events/contracts/index.js +0 -0
- package/dist/services/Events/contracts/tokens.d.ts +0 -0
- package/dist/services/Events/contracts/tokens.js +0 -0
- package/dist/services/Events/descriptor/EventsDescriptor.d.ts +0 -0
- package/dist/services/Events/descriptor/EventsDescriptor.js +0 -0
- package/dist/services/Events/descriptor/tokens.d.ts +0 -0
- package/dist/services/Events/descriptor/tokens.js +0 -0
- package/dist/services/Events/index.d.ts +0 -0
- package/dist/services/Events/index.js +0 -0
- package/dist/services/Events/orchestrator/EventsService.d.ts +0 -0
- package/dist/services/Events/orchestrator/EventsService.js +0 -0
- package/dist/services/Events/orchestrator/index.d.ts +0 -0
- package/dist/services/Events/orchestrator/index.js +0 -0
- package/dist/services/Events/orchestrator/limits.d.ts +0 -0
- package/dist/services/Events/orchestrator/limits.js +0 -0
- package/dist/services/Events/serviceModule.d.ts +0 -0
- package/dist/services/Events/serviceModule.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.d.ts +13 -1
- package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/errors.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/contracts/errors.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/index.d.ts +1 -1
- package/dist/services/ExposedApiRegistry/contracts/index.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/policy.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/contracts/policy.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/registrant.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/contracts/registrant.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/types.d.ts +21 -0
- package/dist/services/ExposedApiRegistry/contracts/types.js +0 -0
- package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.d.ts +2 -2
- package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.js +2 -2
- package/dist/services/ExposedApiRegistry/descriptor/tokens.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/descriptor/tokens.js +0 -0
- package/dist/services/ExposedApiRegistry/index.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/index.js +0 -0
- package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.d.ts +9 -2
- package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.js +50 -5
- package/dist/services/ExposedApiRegistry/orchestrator/index.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/orchestrator/index.js +0 -0
- package/dist/services/ExposedApiRegistry/serviceModule.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/serviceModule.js +0 -0
- package/dist/services/ExposedApiRegistry/storage/protection.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/storage/protection.js +0 -0
- package/dist/services/ExposedApiRegistry/storage/scopeRecord.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/storage/scopeRecord.js +0 -0
- package/dist/services/IdentityRegistry/contracts/errors.d.ts +0 -0
- package/dist/services/IdentityRegistry/contracts/errors.js +0 -0
- package/dist/services/IdentityRegistry/contracts/index.d.ts +0 -0
- package/dist/services/IdentityRegistry/contracts/index.js +0 -0
- package/dist/services/IdentityRegistry/contracts/types.d.ts +0 -0
- package/dist/services/IdentityRegistry/contracts/types.js +0 -0
- package/dist/services/IdentityRegistry/descriptor/descriptor.d.ts +0 -0
- package/dist/services/IdentityRegistry/descriptor/descriptor.js +0 -0
- package/dist/services/IdentityRegistry/descriptor/tokens.d.ts +0 -0
- package/dist/services/IdentityRegistry/descriptor/tokens.js +0 -0
- package/dist/services/IdentityRegistry/index.d.ts +0 -0
- package/dist/services/IdentityRegistry/index.js +0 -0
- package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.d.ts +0 -0
- package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.js +0 -0
- package/dist/services/IdentityRegistry/serviceModule.d.ts +0 -0
- package/dist/services/IdentityRegistry/serviceModule.js +0 -0
- package/dist/services/IdentityRegistry/storage/registryDocument.d.ts +0 -0
- package/dist/services/IdentityRegistry/storage/registryDocument.js +0 -0
- package/dist/services/Interception/contracts/IInterceptionService.d.ts +91 -1
- package/dist/services/Interception/contracts/IInterceptionService.js +12 -1
- package/dist/services/Interception/contracts/errors.d.ts +0 -0
- package/dist/services/Interception/contracts/errors.js +0 -0
- package/dist/services/Interception/contracts/index.d.ts +0 -0
- package/dist/services/Interception/contracts/index.js +0 -0
- package/dist/services/Interception/contracts/tokens.d.ts +0 -0
- package/dist/services/Interception/contracts/tokens.js +0 -0
- package/dist/services/Interception/descriptor/InterceptionDescriptor.d.ts +1 -1
- package/dist/services/Interception/descriptor/InterceptionDescriptor.js +2 -1
- package/dist/services/Interception/descriptor/tokens.d.ts +0 -0
- package/dist/services/Interception/descriptor/tokens.js +0 -0
- package/dist/services/Interception/index.d.ts +0 -0
- package/dist/services/Interception/index.js +0 -0
- package/dist/services/Interception/orchestrator/InterceptionService.d.ts +9 -1
- package/dist/services/Interception/orchestrator/InterceptionService.js +167 -4
- package/dist/services/Interception/orchestrator/index.d.ts +0 -0
- package/dist/services/Interception/orchestrator/index.js +0 -0
- package/dist/services/Interception/serviceModule.d.ts +0 -0
- package/dist/services/Interception/serviceModule.js +0 -0
- package/dist/services/Parser/contracts/IParserService.d.ts +0 -0
- package/dist/services/Parser/contracts/IParserService.js +0 -0
- package/dist/services/Parser/contracts/errors.d.ts +0 -0
- package/dist/services/Parser/contracts/errors.js +0 -0
- package/dist/services/Parser/contracts/index.d.ts +0 -0
- package/dist/services/Parser/contracts/index.js +0 -0
- package/dist/services/Parser/contracts/types.d.ts +0 -0
- package/dist/services/Parser/contracts/types.js +0 -0
- package/dist/services/Parser/descriptor/ParserDescriptor.d.ts +0 -0
- package/dist/services/Parser/descriptor/ParserDescriptor.js +0 -0
- package/dist/services/Parser/descriptor/tokens.d.ts +0 -0
- package/dist/services/Parser/descriptor/tokens.js +0 -0
- package/dist/services/Parser/index.d.ts +0 -0
- package/dist/services/Parser/index.js +0 -0
- package/dist/services/Parser/orchestrator/ParserService.d.ts +0 -0
- package/dist/services/Parser/orchestrator/ParserService.js +0 -0
- package/dist/services/Parser/orchestrator/index.d.ts +0 -0
- package/dist/services/Parser/orchestrator/index.js +0 -0
- package/dist/services/Parser/parser/indexSynthesis.d.ts +0 -0
- package/dist/services/Parser/parser/indexSynthesis.js +0 -0
- package/dist/services/Parser/parser/parameters.d.ts +0 -0
- package/dist/services/Parser/parser/parameters.js +0 -0
- package/dist/services/Parser/parser/scanner.d.ts +0 -0
- package/dist/services/Parser/parser/scanner.js +0 -0
- package/dist/services/Parser/parser/syntax.d.ts +0 -0
- package/dist/services/Parser/parser/syntax.js +0 -0
- package/dist/services/Parser/serviceModule.d.ts +0 -0
- package/dist/services/Parser/serviceModule.js +0 -0
- package/dist/services/Router/bootOptions.d.ts +0 -0
- package/dist/services/Router/bootOptions.js +0 -0
- package/dist/services/Router/contracts/IRouterService.d.ts +1 -1
- package/dist/services/Router/contracts/IRouterService.js +0 -0
- package/dist/services/Router/contracts/caller.d.ts +0 -0
- package/dist/services/Router/contracts/caller.js +0 -0
- package/dist/services/Router/contracts/errors.d.ts +12 -1
- package/dist/services/Router/contracts/errors.js +15 -0
- package/dist/services/Router/contracts/index.d.ts +2 -2
- package/dist/services/Router/contracts/index.js +1 -1
- package/dist/services/Router/contracts/kind.d.ts +0 -0
- package/dist/services/Router/contracts/kind.js +0 -0
- package/dist/services/Router/contracts/registrant.d.ts +0 -0
- package/dist/services/Router/contracts/registrant.js +0 -0
- package/dist/services/Router/contracts/types.d.ts +28 -8
- package/dist/services/Router/contracts/types.js +0 -0
- package/dist/services/Router/descriptor/RouterDescriptor.d.ts +0 -0
- package/dist/services/Router/descriptor/RouterDescriptor.js +1 -1
- package/dist/services/Router/descriptor/tokens.d.ts +0 -0
- package/dist/services/Router/descriptor/tokens.js +0 -0
- package/dist/services/Router/index.d.ts +0 -0
- package/dist/services/Router/index.js +0 -0
- package/dist/services/Router/orchestrator/RouterService.d.ts +22 -3
- package/dist/services/Router/orchestrator/RouterService.js +131 -6
- package/dist/services/Router/orchestrator/index.d.ts +0 -0
- package/dist/services/Router/orchestrator/index.js +0 -0
- package/dist/services/Router/serviceModule.d.ts +0 -0
- package/dist/services/Router/serviceModule.js +0 -0
- package/dist/services/WasmCage/index.d.ts +0 -0
- package/dist/services/WasmCage/index.js +0 -0
- package/dist/services/WasmCage/scripts/prepin.d.ts +0 -0
- package/dist/services/WasmCage/scripts/prepin.js +0 -0
- package/dist/services/WasmCage/serviceModule.d.ts +0 -0
- package/dist/services/WasmCage/serviceModule.js +0 -0
- package/dist/services/WasmCage/src/caged.d.ts +19 -2
- package/dist/services/WasmCage/src/caged.js +85 -6
- package/dist/services/WasmCage/src/descriptor.d.ts +0 -0
- package/dist/services/WasmCage/src/descriptor.js +0 -0
- package/dist/services/WasmCage/src/native.d.ts +0 -0
- package/dist/services/WasmCage/src/native.js +0 -0
- package/dist/services/WasmCage/src/nativeDigests.d.ts +0 -0
- package/dist/services/WasmCage/src/nativeDigests.js +5 -5
- package/dist/services/WasmCage/src/package.d.ts +0 -0
- package/dist/services/WasmCage/src/package.js +0 -0
- package/dist/services/shared/canonicalJson.d.ts +0 -0
- package/dist/services/shared/canonicalJson.js +0 -0
- package/dist/services/shared/documentStore.d.ts +0 -0
- package/dist/services/shared/documentStore.js +0 -0
- package/dist/src/bootstrap/bootKernelInternal.d.ts +4 -3
- package/dist/src/bootstrap/bootKernelInternal.js +284 -71
- package/dist/src/bootstrap/bootTypes.d.ts +25 -1
- package/dist/src/bootstrap/bootTypes.js +0 -0
- package/dist/src/bootstrap/config/index.d.ts +0 -0
- package/dist/src/bootstrap/config/index.js +0 -0
- package/dist/src/bootstrap/config/integrity.d.ts +11 -0
- package/dist/src/bootstrap/config/integrity.js +13 -0
- package/dist/src/bootstrap/config/parse.d.ts +0 -0
- package/dist/src/bootstrap/config/parse.js +0 -0
- package/dist/src/bootstrap/config/pathWriteGuard.d.ts +0 -0
- package/dist/src/bootstrap/config/pathWriteGuard.js +0 -0
- package/dist/src/bootstrap/config/types.d.ts +1 -1
- package/dist/src/bootstrap/config/types.js +0 -0
- package/dist/src/bootstrap/hardcore.d.ts +0 -0
- package/dist/src/bootstrap/hardcore.js +0 -0
- package/dist/src/bootstrap/hardcoreServices.d.ts +0 -0
- package/dist/src/bootstrap/hardcoreServices.js +14 -14
- package/dist/src/bootstrap/index.d.ts +6 -1
- package/dist/src/bootstrap/index.js +2 -0
- package/dist/src/bootstrap/loaded.d.ts +30 -0
- package/dist/src/bootstrap/loaded.js +45 -0
- package/dist/src/bootstrap/packageRequirements.d.ts +0 -0
- package/dist/src/bootstrap/packageRequirements.js +0 -0
- package/dist/src/bootstrap/reload.d.ts +44 -0
- package/dist/src/bootstrap/reload.js +45 -0
- package/dist/src/bootstrap/seal.d.ts +32 -0
- package/dist/src/bootstrap/seal.js +101 -0
- package/dist/src/contracts/accessBroker.d.ts +0 -0
- package/dist/src/contracts/accessBroker.js +0 -0
- package/dist/src/contracts/brudOperation.d.ts +0 -0
- package/dist/src/contracts/brudOperation.js +0 -0
- package/dist/src/contracts/callChain.d.ts +0 -0
- package/dist/src/contracts/callChain.js +0 -0
- package/dist/src/contracts/capability.d.ts +0 -0
- package/dist/src/contracts/capability.js +0 -0
- package/dist/src/contracts/capabilitySet.d.ts +23 -0
- package/dist/src/contracts/capabilitySet.js +72 -0
- package/dist/src/contracts/container.d.ts +0 -0
- package/dist/src/contracts/container.js +0 -0
- package/dist/src/contracts/context.d.ts +0 -0
- package/dist/src/contracts/context.js +0 -0
- package/dist/src/contracts/contextContract.d.ts +11 -8
- package/dist/src/contracts/contextContract.js +21 -32
- package/dist/src/contracts/dispatchView.d.ts +3 -3
- package/dist/src/contracts/dispatchView.js +0 -0
- package/dist/src/contracts/handler.d.ts +0 -7
- package/dist/src/contracts/handler.js +0 -0
- package/dist/src/contracts/index.d.ts +2 -1
- package/dist/src/contracts/index.js +1 -0
- package/dist/src/contracts/kernel.d.ts +0 -0
- package/dist/src/contracts/kernel.js +0 -0
- package/dist/src/contracts/lifecycle.d.ts +0 -0
- package/dist/src/contracts/lifecycle.js +0 -0
- package/dist/src/contracts/manifest.d.ts +35 -0
- package/dist/src/contracts/manifest.js +62 -23
- package/dist/src/contracts/pipeline.d.ts +0 -0
- package/dist/src/contracts/pipeline.js +0 -0
- package/dist/src/contracts/policy.d.ts +0 -0
- package/dist/src/contracts/policy.js +0 -0
- package/dist/src/contracts/registry.d.ts +0 -0
- package/dist/src/contracts/registry.js +0 -0
- package/dist/src/contracts/serviceDescriptor.d.ts +0 -0
- package/dist/src/contracts/serviceDescriptor.js +0 -0
- package/dist/src/contracts/serviceToken.d.ts +0 -0
- package/dist/src/contracts/serviceToken.js +0 -0
- package/dist/src/engine/BrudKernel.d.ts +2 -0
- package/dist/src/engine/BrudKernel.js +35 -6
- package/dist/src/engine/ExecutionPipeline.d.ts +0 -0
- package/dist/src/engine/ExecutionPipeline.js +0 -0
- package/dist/src/engine/KernelAccessBroker.d.ts +0 -0
- package/dist/src/engine/KernelAccessBroker.js +0 -0
- package/dist/src/engine/KernelRegistry.d.ts +0 -0
- package/dist/src/engine/KernelRegistry.js +0 -0
- package/dist/src/engine/OperationRegistry.d.ts +0 -0
- package/dist/src/engine/OperationRegistry.js +0 -0
- package/dist/src/engine/ServiceContainer.d.ts +0 -0
- package/dist/src/engine/ServiceContainer.js +0 -0
- package/dist/src/engine/callChain.d.ts +0 -0
- package/dist/src/engine/callChain.js +5 -10
- package/dist/src/engine/dag.d.ts +0 -0
- package/dist/src/engine/dag.js +0 -0
- package/dist/src/engine/errors.d.ts +0 -0
- package/dist/src/engine/errors.js +0 -0
- package/dist/src/engine/index.d.ts +0 -0
- package/dist/src/engine/index.js +0 -0
- package/dist/src/engine/state.d.ts +0 -0
- package/dist/src/engine/state.js +0 -0
- package/dist/src/validation/jsonSchema/compile.d.ts +0 -0
- package/dist/src/validation/jsonSchema/compile.js +0 -0
- package/dist/src/validation/jsonSchema/index.d.ts +0 -0
- package/dist/src/validation/jsonSchema/index.js +0 -0
- package/dist/src/validation/jsonSchema/jsonValue.d.ts +0 -0
- package/dist/src/validation/jsonSchema/jsonValue.js +0 -0
- package/dist/src/validation/jsonSchema/pattern.d.ts +0 -0
- package/dist/src/validation/jsonSchema/pattern.js +0 -0
- package/dist/src/validation/jsonSchema/types.d.ts +0 -0
- package/dist/src/validation/jsonSchema/types.js +0 -0
- package/package.json +1 -1
- package/services/WasmCage/native/brud-wasm-cage.darwin-arm64.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.darwin-x64.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.linux-arm64-gnu.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.linux-x64-gnu.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.win32-x64-msvc.node +0 -0
|
@@ -60,6 +60,15 @@ export interface InterceptionDeclaration {
|
|
|
60
60
|
readonly target: string;
|
|
61
61
|
/** Major version of the target; defaults to 1. */
|
|
62
62
|
readonly version?: number | string;
|
|
63
|
+
/**
|
|
64
|
+
* The stages this interceptor takes part in: `'input'` (it sees a call's
|
|
65
|
+
* arguments before the giver runs, and may modify or block them) and
|
|
66
|
+
* `'output'` (it may append content to the giver's result). Defaults to
|
|
67
|
+
* `['output']`: seeing or changing arguments must be asked for explicitly.
|
|
68
|
+
* A declared stage must be implemented. An output interceptor that is not is
|
|
69
|
+
* skipped; an input interceptor that is not blocks the call.
|
|
70
|
+
*/
|
|
71
|
+
readonly stages?: readonly ('input' | 'output')[];
|
|
63
72
|
}
|
|
64
73
|
/**
|
|
65
74
|
* One interception point a giver declares on one of its own exposures, naming
|
|
@@ -79,6 +88,12 @@ export interface InterceptionPointDeclaration {
|
|
|
79
88
|
readonly operations?: Readonly<Record<string, KindOperationDescription>>;
|
|
80
89
|
/** Service tokens of the admitted interceptors, in run order. */
|
|
81
90
|
readonly admit: readonly string[];
|
|
91
|
+
/**
|
|
92
|
+
* Lowers the kernel's output-stage limits for this point, in bytes of
|
|
93
|
+
* canonical JSON. The Interception primitive validates the values; a value
|
|
94
|
+
* can lower a kernel ceiling and never raise it.
|
|
95
|
+
*/
|
|
96
|
+
readonly outputLimits?: Readonly<Record<string, number>>;
|
|
82
97
|
}
|
|
83
98
|
/**
|
|
84
99
|
* One Brud Syntax kind a participant claims, served by one of its own
|
|
@@ -89,6 +104,12 @@ export interface KindOperationDescription {
|
|
|
89
104
|
readonly description?: string;
|
|
90
105
|
/** JSON Schema of the operation's input (plain JSON). */
|
|
91
106
|
readonly input?: Readonly<Record<string, unknown>>;
|
|
107
|
+
/**
|
|
108
|
+
* Who may call this operation: a Layer 1 policy object, in the same
|
|
109
|
+
* language as an exposure's `policy`. Falls back to the kind's `permission`.
|
|
110
|
+
* The Router validates and evaluates it; admission checks only its shape.
|
|
111
|
+
*/
|
|
112
|
+
readonly permission?: Readonly<Record<string, unknown>>;
|
|
92
113
|
}
|
|
93
114
|
export interface KindDeclaration {
|
|
94
115
|
/** The kind word written after `[CALL`, e.g. `tool`. */
|
|
@@ -97,6 +118,20 @@ export interface KindDeclaration {
|
|
|
97
118
|
readonly exposure: string;
|
|
98
119
|
/** Major version of the exposure; defaults to 1. */
|
|
99
120
|
readonly version?: number | string;
|
|
121
|
+
/** Public description of the kind. */
|
|
122
|
+
readonly description?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Every operation the kind serves, by name. Required: the kernel refuses an
|
|
125
|
+
* operation that is not listed, before the owner is reached.
|
|
126
|
+
*
|
|
127
|
+
* `'open'` declares that the owner defines the operation names itself (for
|
|
128
|
+
* example from a registry filled at runtime), so the kernel cannot list them.
|
|
129
|
+
* It must be written out, and the kind's `permission` is then required and is
|
|
130
|
+
* enforced on every call; the owner decides which names exist.
|
|
131
|
+
*/
|
|
132
|
+
readonly operations: Readonly<Record<string, KindOperationDescription>> | 'open';
|
|
133
|
+
/** Default permission for operations that declare none; required when `operations` is `'open'`. */
|
|
134
|
+
readonly permission?: Readonly<Record<string, unknown>>;
|
|
100
135
|
}
|
|
101
136
|
/** A participant's manifest. */
|
|
102
137
|
export interface ParticipantManifest {
|
|
@@ -19,14 +19,15 @@ export class ParticipantManifestError extends Error {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
const MANIFEST_KEYS = new Set(['requests', 'exposures', 'events', 'interceptions', 'interceptionPoints', 'kinds']);
|
|
22
|
-
const KIND_KEYS = new Set(['kind', 'exposure', 'version', 'description', 'operations']);
|
|
23
|
-
const KIND_OPERATION_KEYS = new Set(['description', 'input']);
|
|
22
|
+
const KIND_KEYS = new Set(['kind', 'exposure', 'version', 'description', 'operations', 'permission']);
|
|
23
|
+
const KIND_OPERATION_KEYS = new Set(['description', 'input', 'permission']);
|
|
24
|
+
const KIND_OPERATION_PATTERN = /^[A-Za-z][A-Za-z0-9_.-]*$/u;
|
|
24
25
|
const KIND_PATTERN = /^[a-z][a-z0-9_-]*$/u;
|
|
25
26
|
const REQUEST_KEYS = new Set(['capabilities']);
|
|
26
27
|
const EXPOSURE_KEYS = new Set(['name', 'version', 'scope', 'policy']);
|
|
27
28
|
const EVENT_KEYS = new Set(['name', 'version', 'scope', 'policy', 'payloadSchema']);
|
|
28
|
-
const INTERCEPTION_KEYS = new Set(['target', 'version']);
|
|
29
|
-
const INTERCEPTION_POINT_KEYS = new Set(['exposure', 'version', 'admit']);
|
|
29
|
+
const INTERCEPTION_KEYS = new Set(['target', 'version', 'stages']);
|
|
30
|
+
const INTERCEPTION_POINT_KEYS = new Set(['exposure', 'version', 'admit', 'outputLimits']);
|
|
30
31
|
function isPlainObject(value) {
|
|
31
32
|
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
32
33
|
return false;
|
|
@@ -206,12 +207,25 @@ function admitInterceptions(value, participant) {
|
|
|
206
207
|
throw new ParticipantManifestError(participant, `${path}.target must be a non-empty string`);
|
|
207
208
|
}
|
|
208
209
|
assertVersion(entry.version, path, participant);
|
|
209
|
-
|
|
210
|
+
const stages = entry.stages;
|
|
211
|
+
if (stages !== undefined
|
|
212
|
+
&& (!Array.isArray(stages)
|
|
213
|
+
|| stages.length === 0
|
|
214
|
+
|| new Set(stages).size !== stages.length
|
|
215
|
+
|| stages.some((stage) => stage !== 'input' && stage !== 'output'))) {
|
|
216
|
+
throw new ParticipantManifestError(participant, `${path}.stages must be a non-empty list of unique "input" or "output"`);
|
|
217
|
+
}
|
|
218
|
+
return Object.freeze({
|
|
219
|
+
...entry,
|
|
220
|
+
...(stages === undefined ? {} : { stages: Object.freeze([...stages]) }),
|
|
221
|
+
});
|
|
210
222
|
}));
|
|
211
223
|
}
|
|
212
224
|
/**
|
|
213
225
|
* Admits `manifest.kinds`. Each kind names one of the participant's own
|
|
214
|
-
* declared exposures
|
|
226
|
+
* declared exposures, lists every operation it serves, and gives each
|
|
227
|
+
* operation a permission (its own, or the kind's); a kind may be claimed once
|
|
228
|
+
* per manifest. The Router validates and evaluates the permissions.
|
|
215
229
|
*/
|
|
216
230
|
function admitKinds(value, exposures, participant) {
|
|
217
231
|
if (value === undefined) {
|
|
@@ -245,22 +259,38 @@ function admitKinds(value, exposures, participant) {
|
|
|
245
259
|
if (entry.description !== undefined && typeof entry.description !== 'string') {
|
|
246
260
|
throw new ParticipantManifestError(participant, `${path}.description must be a string`);
|
|
247
261
|
}
|
|
248
|
-
if (entry.
|
|
249
|
-
|
|
250
|
-
|
|
262
|
+
if (entry.permission !== undefined && !isPlainObject(entry.permission)) {
|
|
263
|
+
throw new ParticipantManifestError(participant, `${path}.permission must be a policy object`);
|
|
264
|
+
}
|
|
265
|
+
if (entry.operations === 'open') {
|
|
266
|
+
if (entry.permission === undefined) {
|
|
267
|
+
throw new ParticipantManifestError(participant, `${path}.permission is required when operations is "open"; write { "policyVersion": 2 } to allow every routing caller`);
|
|
251
268
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
269
|
+
return Object.freeze(JSON.parse(JSON.stringify(entry)));
|
|
270
|
+
}
|
|
271
|
+
if (!isPlainObject(entry.operations) || Object.keys(entry.operations).length === 0) {
|
|
272
|
+
throw new ParticipantManifestError(participant, `${path}.operations is required: declare every operation the kind serves, or write "open" if its owner defines the names at runtime`);
|
|
273
|
+
}
|
|
274
|
+
for (const [name, operation] of Object.entries(entry.operations)) {
|
|
275
|
+
const at = `${path}.operations.${name}`;
|
|
276
|
+
if (!KIND_OPERATION_PATTERN.test(name)) {
|
|
277
|
+
throw new ParticipantManifestError(participant, `${at}: operation names start with a letter and use letters, digits, "_", "-" and "."`);
|
|
278
|
+
}
|
|
279
|
+
if (!isPlainObject(operation)) {
|
|
280
|
+
throw new ParticipantManifestError(participant, `${at} must be an object`);
|
|
281
|
+
}
|
|
282
|
+
assertKnownKeys(operation, KIND_OPERATION_KEYS, at, participant);
|
|
283
|
+
if (operation.description !== undefined && typeof operation.description !== 'string') {
|
|
284
|
+
throw new ParticipantManifestError(participant, `${at}.description must be a string`);
|
|
285
|
+
}
|
|
286
|
+
if (operation.input !== undefined && !isPlainObject(operation.input)) {
|
|
287
|
+
throw new ParticipantManifestError(participant, `${at}.input must be a JSON Schema object`);
|
|
288
|
+
}
|
|
289
|
+
if (operation.permission !== undefined && !isPlainObject(operation.permission)) {
|
|
290
|
+
throw new ParticipantManifestError(participant, `${at}.permission must be a policy object`);
|
|
291
|
+
}
|
|
292
|
+
if (operation.permission === undefined && entry.permission === undefined) {
|
|
293
|
+
throw new ParticipantManifestError(participant, `${at}.permission is required, or declare a kind-level permission; write { "policyVersion": 2 } to allow every routing caller`);
|
|
264
294
|
}
|
|
265
295
|
}
|
|
266
296
|
// Deep copy so the admitted declaration is plain, frozen data.
|
|
@@ -288,8 +318,17 @@ function admitInterceptionPoints(value, participant) {
|
|
|
288
318
|
if (!Array.isArray(admit)
|
|
289
319
|
|| admit.some((token) => typeof token !== 'string' || token.length === 0)
|
|
290
320
|
|| new Set(admit).size !== admit.length) {
|
|
291
|
-
|
|
321
|
+
const object = Array.isArray(admit) ? admit.find((token) => isPlainObject(token) && typeof token.id === 'string') : undefined;
|
|
322
|
+
const hint = object === undefined ? '' : ` A token object was given; pass its id string ("${object.id}") instead`;
|
|
323
|
+
throw new ParticipantManifestError(participant, `${path}.admit must be an array of unique non-empty service token id strings.${hint}`);
|
|
324
|
+
}
|
|
325
|
+
if (entry.outputLimits !== undefined && !isPlainObject(entry.outputLimits)) {
|
|
326
|
+
throw new ParticipantManifestError(participant, `${path}.outputLimits must be an object`);
|
|
292
327
|
}
|
|
293
|
-
return Object.freeze({
|
|
328
|
+
return Object.freeze({
|
|
329
|
+
...entry,
|
|
330
|
+
admit: Object.freeze([...admit]),
|
|
331
|
+
...(entry.outputLimits === undefined ? {} : { outputLimits: Object.freeze({ ...entry.outputLimits }) }),
|
|
332
|
+
});
|
|
294
333
|
}));
|
|
295
334
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -116,3 +116,5 @@ export declare class BrudKernel implements IBrudKernel {
|
|
|
116
116
|
private createExecutionContext;
|
|
117
117
|
generatePromptManifest(): PromptManifest;
|
|
118
118
|
}
|
|
119
|
+
/** The token of the service whose lifecycle code threw `error`, when the kernel recorded it. */
|
|
120
|
+
export declare function failingServiceOf(error: unknown): string | undefined;
|
|
@@ -154,12 +154,18 @@ export class BrudKernel {
|
|
|
154
154
|
options: this.bootOptions,
|
|
155
155
|
...(options.logger === undefined ? {} : { logger: options.logger }),
|
|
156
156
|
};
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
try {
|
|
158
|
+
const instance = descriptor.factory(context, this.accessBroker);
|
|
159
|
+
this.registry.setInstance(descriptor.token.id, instance);
|
|
160
|
+
if (typeof instance.initialize === 'function') {
|
|
161
|
+
await instance.initialize(this.accessBroker);
|
|
162
|
+
}
|
|
163
|
+
this.initializedServices.push({ tokenId: descriptor.token.id, instance });
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
tagFailingService(error, descriptor.token.id);
|
|
167
|
+
throw error;
|
|
161
168
|
}
|
|
162
|
-
this.initializedServices.push({ tokenId: descriptor.token.id, instance });
|
|
163
169
|
});
|
|
164
170
|
};
|
|
165
171
|
for (const descriptor of hardcoreOrder) {
|
|
@@ -217,7 +223,13 @@ export class BrudKernel {
|
|
|
217
223
|
try {
|
|
218
224
|
for (const { tokenId, instance } of this.initializedServices) {
|
|
219
225
|
if (typeof instance.onRunning === 'function') {
|
|
220
|
-
|
|
226
|
+
try {
|
|
227
|
+
await this.runFor(tokenId, () => instance.onRunning?.(this.accessBroker));
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
tagFailingService(error, tokenId);
|
|
231
|
+
throw error;
|
|
232
|
+
}
|
|
221
233
|
}
|
|
222
234
|
}
|
|
223
235
|
}
|
|
@@ -364,3 +376,20 @@ export class BrudKernel {
|
|
|
364
376
|
return { operations };
|
|
365
377
|
}
|
|
366
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Records, on an error thrown by a service's own lifecycle code, which service
|
|
381
|
+
* threw it. The mark is not enumerable and never replaces an earlier one, so
|
|
382
|
+
* the error keeps its type and message. A caller that must decide what to do
|
|
383
|
+
* about a failed boot reads it with `failingServiceOf`.
|
|
384
|
+
*/
|
|
385
|
+
function tagFailingService(error, tokenId) {
|
|
386
|
+
if (error !== null && typeof error === 'object' && !(FAILING_SERVICE in error)) {
|
|
387
|
+
Object.defineProperty(error, FAILING_SERVICE, { value: tokenId, enumerable: false });
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const FAILING_SERVICE = Symbol.for('brud.kernel.failingService');
|
|
391
|
+
/** The token of the service whose lifecycle code threw `error`, when the kernel recorded it. */
|
|
392
|
+
export function failingServiceOf(error) {
|
|
393
|
+
const value = error !== null && typeof error === 'object' ? error[FAILING_SERVICE] : undefined;
|
|
394
|
+
return typeof value === 'string' ? value : undefined;
|
|
395
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NO_CAPABILITIES, createCapabilitySet } from '../contracts/capabilitySet.js';
|
|
1
2
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
3
|
import { DEFAULT_KERNEL_CALL_LIMITS, } from '../contracts/callChain.js';
|
|
3
4
|
/**
|
|
@@ -9,20 +10,19 @@ import { DEFAULT_KERNEL_CALL_LIMITS, } from '../contracts/callChain.js';
|
|
|
9
10
|
const frames = new AsyncLocalStorage();
|
|
10
11
|
/** Largest number of records the observation stream retains. */
|
|
11
12
|
const OBSERVATION_CAPACITY = 1_000;
|
|
12
|
-
const EMPTY_CAPABILITIES = Object.freeze(new Set());
|
|
13
13
|
/** The kernel itself as a caller. */
|
|
14
14
|
export const KERNEL_CALLER = Object.freeze({
|
|
15
15
|
callerClass: 'kernel',
|
|
16
16
|
identity: null,
|
|
17
17
|
official: true,
|
|
18
|
-
capabilities:
|
|
18
|
+
capabilities: NO_CAPABILITIES,
|
|
19
19
|
});
|
|
20
20
|
/** A participant the kernel has not assigned an identity to. */
|
|
21
21
|
export const UNIDENTIFIED_PARTICIPANT = Object.freeze({
|
|
22
22
|
callerClass: 'participant',
|
|
23
23
|
identity: null,
|
|
24
24
|
official: false,
|
|
25
|
-
capabilities:
|
|
25
|
+
capabilities: NO_CAPABILITIES,
|
|
26
26
|
});
|
|
27
27
|
/**
|
|
28
28
|
* One kernel's call chain.
|
|
@@ -88,17 +88,12 @@ export class KernelCallChain {
|
|
|
88
88
|
* @param operation - Work performed inside the chain.
|
|
89
89
|
*/
|
|
90
90
|
runHost(session, operation) {
|
|
91
|
-
const capabilities =
|
|
92
|
-
for (const capability of session.capabilities ?? []) {
|
|
93
|
-
if (typeof capability === 'string' && capability.length > 0) {
|
|
94
|
-
capabilities.add(capability);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
91
|
+
const capabilities = createCapabilitySet([...(session.capabilities ?? [])].filter((capability) => typeof capability === 'string' && capability.length > 0));
|
|
97
92
|
const caller = Object.freeze({
|
|
98
93
|
callerClass: 'host',
|
|
99
94
|
identity: null,
|
|
100
95
|
official: false,
|
|
101
|
-
capabilities
|
|
96
|
+
capabilities,
|
|
102
97
|
});
|
|
103
98
|
return this.runRoot('host', caller, operation);
|
|
104
99
|
}
|
package/dist/src/engine/dag.d.ts
CHANGED
|
File without changes
|
package/dist/src/engine/dag.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/src/engine/index.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/src/engine/state.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|