@almadar/runtime 6.26.0 → 6.28.0
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/dist/{OrbitalServerRuntime-h0NCwFuc.d.ts → OrbitalServerRuntime-DCkk0alk.d.ts} +50 -2
- package/dist/OrbitalServerRuntime.d.ts +2 -2
- package/dist/OrbitalServerRuntime.js +31 -2
- package/dist/OrbitalServerRuntime.js.map +1 -1
- package/dist/ServerBridge.d.ts +1 -1
- package/dist/{chunk-YNRDYK3N.js → chunk-FWBY567U.js} +101 -5
- package/dist/chunk-FWBY567U.js.map +1 -0
- package/dist/createAgentSubstrateHandlers-4JMLGDZQ.js +71 -0
- package/dist/createAgentSubstrateHandlers-4JMLGDZQ.js.map +1 -0
- package/dist/createOsHandlers.d.ts +1 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.js +2 -2
- package/dist/{types-BA7GoDni.d.ts → types-CguyGOms.d.ts} +24 -1
- package/package.json +2 -2
- package/dist/chunk-YNRDYK3N.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
import { I as IEventBus, g as RuntimeEvent, f as EventListener, U as Unsubscribe, T as TraitDefinition, R as RuntimeConfig, i as TransitionObserver, C as ConfigContext, h as TraitState, j as TransitionResult, E as EvaluationContextExtensions, a as EffectHandlers } from './types-
|
|
3
|
-
import { EventPayload, EntityRow, DeclaredTraitConfig, TraitConfig, Entity, OrbitalSchema, Orbital, Trait, PatternConfig, ResolvedPatternProps, SExpr, BusEventSource, OrbitalDefinition, TraitTick } from '@almadar/core';
|
|
2
|
+
import { I as IEventBus, g as RuntimeEvent, f as EventListener, U as Unsubscribe, T as TraitDefinition, R as RuntimeConfig, i as TransitionObserver, C as ConfigContext, h as TraitState, j as TransitionResult, E as EvaluationContextExtensions, a as EffectHandlers } from './types-CguyGOms.js';
|
|
3
|
+
import { EventPayload, EntityRow, ServiceCallResult, DeclaredTraitConfig, TraitConfig, Entity, OrbitalSchema, Orbital, Trait, PatternConfig, ResolvedPatternProps, SExpr, BusEventSource, OrbitalDefinition, TraitTick } from '@almadar/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* EventBus - Platform-Agnostic Pub/Sub Implementation
|
|
@@ -308,6 +308,40 @@ declare class StateMachineManager {
|
|
|
308
308
|
resetAll(): void;
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Agent Substrate Handlers — Server-Side Only
|
|
313
|
+
*
|
|
314
|
+
* Provides implementations for the effect-position substrate operators:
|
|
315
|
+
* compose/compose-all, compose/compose-children, behavior/instantiate,
|
|
316
|
+
* behavior/call, validate/validate, lolo/emit-body.
|
|
317
|
+
*
|
|
318
|
+
* Used by OrbitalServerRuntime (interpreted path). Wired alongside
|
|
319
|
+
* createOsHandlers — same lazy-import + merge-under-user-handlers pattern.
|
|
320
|
+
*
|
|
321
|
+
* The actual service invocations are injected via the `services` field of
|
|
322
|
+
* AgentSubstrateHandlerContext. @almadar-io/rabit supplies these at runtime;
|
|
323
|
+
* tests can inject mocks. When a service is absent, the handler logs a
|
|
324
|
+
* warning and returns a safe default.
|
|
325
|
+
*
|
|
326
|
+
* NOT exported from the main index.ts because it references Node-only types.
|
|
327
|
+
* Import directly: import { createAgentSubstrateHandlers } from '@almadar/runtime/createAgentSubstrateHandlers';
|
|
328
|
+
*
|
|
329
|
+
* @packageDocumentation
|
|
330
|
+
*/
|
|
331
|
+
|
|
332
|
+
interface SubstrateServices {
|
|
333
|
+
composeAll?: (config: {
|
|
334
|
+
appName: string;
|
|
335
|
+
orbitals: unknown[];
|
|
336
|
+
layoutStrategy?: string;
|
|
337
|
+
}) => Promise<ServiceCallResult>;
|
|
338
|
+
composeChildren?: (parentName: string, children: unknown[]) => Promise<ServiceCallResult>;
|
|
339
|
+
instantiate?: (parentName: string, behavior: string, params?: unknown) => Promise<ServiceCallResult>;
|
|
340
|
+
call?: (behavior: string, method: string, params?: unknown) => Promise<ServiceCallResult>;
|
|
341
|
+
validate?: (orbitalName: string) => Promise<ServiceCallResult>;
|
|
342
|
+
emitBody?: (orbitalName: string, loloSource: string) => Promise<ServiceCallResult>;
|
|
343
|
+
}
|
|
344
|
+
|
|
311
345
|
/**
|
|
312
346
|
* Pure config-default extraction — kept OUT of `OrbitalServerRuntime.ts` so the
|
|
313
347
|
* package index can re-export it without dragging that module's node-only
|
|
@@ -993,6 +1027,12 @@ interface OrbitalServerRuntimeConfig {
|
|
|
993
1027
|
* The evaluator dispatches agent/* operators to ctx.agent.
|
|
994
1028
|
*/
|
|
995
1029
|
contextExtensions?: EvaluationContextExtensions;
|
|
1030
|
+
/**
|
|
1031
|
+
* Substrate service implementations for effect-position operators
|
|
1032
|
+
* (compose/compose-all, behavior/instantiate, validate/validate, etc.).
|
|
1033
|
+
* @almadar-io/rabit injects these at runtime; tests can inject mocks.
|
|
1034
|
+
*/
|
|
1035
|
+
substrateServices?: SubstrateServices;
|
|
996
1036
|
}
|
|
997
1037
|
|
|
998
1038
|
declare class OrbitalServerRuntime {
|
|
@@ -1009,6 +1049,8 @@ declare class OrbitalServerRuntime {
|
|
|
1009
1049
|
private eventNamespaceMap;
|
|
1010
1050
|
private osHandlers;
|
|
1011
1051
|
private osHandlersPromise;
|
|
1052
|
+
private substrateHandlers;
|
|
1053
|
+
private substrateHandlersPromise;
|
|
1012
1054
|
private resolvedSchema;
|
|
1013
1055
|
constructor(config?: OrbitalServerRuntimeConfig);
|
|
1014
1056
|
/**
|
|
@@ -1020,6 +1062,12 @@ declare class OrbitalServerRuntime {
|
|
|
1020
1062
|
* no-op in the browser (the import never runs behind the isNodeEnv guard).
|
|
1021
1063
|
*/
|
|
1022
1064
|
private ensureOsHandlers;
|
|
1065
|
+
/**
|
|
1066
|
+
* Lazily wire the agent substrate effect handlers (compose/behavior/
|
|
1067
|
+
* validate/lolo), merging them UNDER any user-provided handlers.
|
|
1068
|
+
* Same deferred-import pattern as ensureOsHandlers.
|
|
1069
|
+
*/
|
|
1070
|
+
private ensureAgentSubstrateHandlers;
|
|
1023
1071
|
/**
|
|
1024
1072
|
* Lazily construct a default loader when the caller didn't provide one
|
|
1025
1073
|
* but `register()` needs to preprocess. Looks for `@almadar/std` in the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
export { F as ClientEffectTuple, G as ClientNavigateTuple, H as ClientNotifyTuple, J as ClientRenderUITuple, K as EffectResult, e as InMemoryPersistence, M as LoaderConfig, O as OrbitalEventRequest, f as OrbitalEventResponse, N as OrbitalServerRuntime, g as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, Q as RuntimeTraitTick, p as collectDeclaredConfigDefaults, T as createOrbitalServerRuntime } from './OrbitalServerRuntime-
|
|
3
|
-
import './types-
|
|
2
|
+
export { F as ClientEffectTuple, G as ClientNavigateTuple, H as ClientNotifyTuple, J as ClientRenderUITuple, K as EffectResult, e as InMemoryPersistence, M as LoaderConfig, O as OrbitalEventRequest, f as OrbitalEventResponse, N as OrbitalServerRuntime, g as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, Q as RuntimeTraitTick, p as collectDeclaredConfigDefaults, T as createOrbitalServerRuntime } from './OrbitalServerRuntime-DCkk0alk.js';
|
|
3
|
+
import './types-CguyGOms.js';
|
|
4
4
|
import '@almadar/core';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, createContextFromBindings, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-
|
|
2
|
-
export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-
|
|
1
|
+
import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, createContextFromBindings, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-FWBY567U.js';
|
|
2
|
+
export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-FWBY567U.js';
|
|
3
3
|
import { isValidCronExpression } from './chunk-U4PL237A.js';
|
|
4
4
|
import './chunk-PZ5AY32C.js';
|
|
5
5
|
import { createLogger } from '@almadar/logger';
|
|
@@ -69,6 +69,8 @@ var OrbitalServerRuntime = class {
|
|
|
69
69
|
eventNamespaceMap = {};
|
|
70
70
|
osHandlers = null;
|
|
71
71
|
osHandlersPromise = null;
|
|
72
|
+
substrateHandlers = null;
|
|
73
|
+
substrateHandlersPromise = null;
|
|
72
74
|
resolvedSchema = null;
|
|
73
75
|
constructor(config = {}) {
|
|
74
76
|
this.config = {
|
|
@@ -127,6 +129,28 @@ var OrbitalServerRuntime = class {
|
|
|
127
129
|
}
|
|
128
130
|
return this.osHandlersPromise;
|
|
129
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Lazily wire the agent substrate effect handlers (compose/behavior/
|
|
134
|
+
* validate/lolo), merging them UNDER any user-provided handlers.
|
|
135
|
+
* Same deferred-import pattern as ensureOsHandlers.
|
|
136
|
+
*/
|
|
137
|
+
async ensureAgentSubstrateHandlers() {
|
|
138
|
+
if (!isNodeEnv()) return;
|
|
139
|
+
if (!this.substrateHandlersPromise) {
|
|
140
|
+
this.substrateHandlersPromise = (async () => {
|
|
141
|
+
const { createAgentSubstrateHandlers } = await import('./createAgentSubstrateHandlers-4JMLGDZQ.js');
|
|
142
|
+
this.substrateHandlers = createAgentSubstrateHandlers({
|
|
143
|
+
emitEvent: (type, payload) => this.eventBus.emit(type, payload),
|
|
144
|
+
services: this.config.substrateServices ?? {}
|
|
145
|
+
});
|
|
146
|
+
this.config.effectHandlers = {
|
|
147
|
+
...this.substrateHandlers.handlers,
|
|
148
|
+
...this.config.effectHandlers
|
|
149
|
+
};
|
|
150
|
+
})();
|
|
151
|
+
}
|
|
152
|
+
return this.substrateHandlersPromise;
|
|
153
|
+
}
|
|
130
154
|
/**
|
|
131
155
|
* Lazily construct a default loader when the caller didn't provide one
|
|
132
156
|
* but `register()` needs to preprocess. Looks for `@almadar/std` in the
|
|
@@ -749,6 +773,10 @@ var OrbitalServerRuntime = class {
|
|
|
749
773
|
this.osHandlers.cleanup();
|
|
750
774
|
this.osHandlers = null;
|
|
751
775
|
}
|
|
776
|
+
if (this.substrateHandlers) {
|
|
777
|
+
this.substrateHandlers.cleanup();
|
|
778
|
+
this.substrateHandlers = null;
|
|
779
|
+
}
|
|
752
780
|
}
|
|
753
781
|
/**
|
|
754
782
|
* Reset the mock persistence store to a clean-slate re-seed without
|
|
@@ -787,6 +815,7 @@ var OrbitalServerRuntime = class {
|
|
|
787
815
|
*/
|
|
788
816
|
async processOrbitalEvent(orbitalName, request, onPush) {
|
|
789
817
|
await this.ensureOsHandlers();
|
|
818
|
+
await this.ensureAgentSubstrateHandlers();
|
|
790
819
|
const registered = this.orbitals.get(orbitalName);
|
|
791
820
|
if (!registered) {
|
|
792
821
|
return {
|