@almadar/runtime 6.29.0 → 6.31.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.
@@ -1,6 +1,6 @@
1
1
  import { Router } from 'express';
2
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-D-9feVsj.js';
3
- import { EventPayload, EntityRow, Orbital, ServiceCallResult, TraitConfig, DeclaredTraitConfig, Entity, OrbitalSchema, Trait, PatternConfig, ResolvedPatternProps, SExpr, BusEventSource, OrbitalDefinition, TraitTick } from '@almadar/core';
3
+ import { EventPayload, EntityRow, Orbital, ServiceCallResult, TraitConfig, DeclaredTraitConfig, Entity, CallSiteConfig, OrbitalSchema, Trait, PatternConfig, ResolvedPatternProps, SExpr, BusEventSource, OrbitalDefinition, TraitTick } from '@almadar/core';
4
4
 
5
5
  /**
6
6
  * EventBus - Platform-Agnostic Pub/Sub Implementation
@@ -358,6 +358,17 @@ interface SubstrateServices {
358
358
  declare function collectDeclaredConfigDefaults(trait: {
359
359
  config?: DeclaredTraitConfig;
360
360
  } | undefined): TraitConfig | undefined;
361
+ /**
362
+ * Convert a call-site config map into plain runtime values.
363
+ *
364
+ * A `CallSiteConfig` may contain either plain wiring values
365
+ * (`TraitConfigValue`) or annotated `ConfigFieldDeclaration` objects
366
+ * (`{ type, default, label, ... }`). The runtime binding context expects
367
+ * only values, so this helper extracts `.default` from declarations and
368
+ * passes plain values through unchanged. Entries that are not recognized as
369
+ * declarations by `isCallSiteConfigDeclaration` are returned as-is.
370
+ */
371
+ declare function normalizeCallSiteConfigToValues(config: CallSiteConfig | undefined): TraitConfig | undefined;
361
372
  /**
362
373
  * Walk an entity's `fields` array and return a flat `{ fieldName: default, … }`
363
374
  * map. Seeds the `@entity` binding context with declared field defaults before
@@ -1300,4 +1311,4 @@ declare class OrbitalServerRuntime {
1300
1311
  */
1301
1312
  declare function createOrbitalServerRuntime(config?: OrbitalServerRuntimeConfig): OrbitalServerRuntime;
1302
1313
 
1303
- export { normalizeEventKey as A, parseNamespacedEvent as B, preprocessSchema as C, processEvent as D, type EntitySharingMap as E, type ClientEffectTuple as F, type ClientNavigateTuple as G, type ClientNotifyTuple as H, type ImportChainLike as I, type ClientRenderUITuple as J, type EffectResult as K, type LoadResult as L, type LoaderConfig as M, OrbitalServerRuntime as N, type OrbitalEventRequest as O, type PersistenceAdapter as P, type RuntimeTraitTick as Q, type RegisteredOrbital as R, type SchemaLoader as S, createOrbitalServerRuntime as T, type UnifiedLoaderOptions as U, type LoadedSchema as a, type LoadedOrbital as b, EventBus as c, type EventNamespaceMap as d, InMemoryPersistence as e, type OrbitalEventResponse as f, type OrbitalServerRuntimeConfig as g, type PreprocessOptions as h, type PreprocessResult as i, type PreprocessedSchema as j, type ProcessEventOptions as k, type RuntimeOrbital as l, type RuntimeOrbitalSchema as m, type RuntimeTrait as n, StateMachineManager as o, collectDeclaredConfigDefaults as p, collectDeclaredEntityDefaults as q, createInitialTraitState as r, findInitialState as s, findTransition as t, getIsolatedCollectionName as u, getNamespacedEvent as v, isBrowser as w, isElectron as x, isNamespacedEvent as y, isNode as z };
1314
+ export { normalizeCallSiteConfigToValues as A, normalizeEventKey as B, parseNamespacedEvent as C, preprocessSchema as D, type EntitySharingMap as E, processEvent as F, type ClientEffectTuple as G, type ClientNavigateTuple as H, type ImportChainLike as I, type ClientNotifyTuple as J, type ClientRenderUITuple as K, type LoadResult as L, type EffectResult as M, type LoaderConfig as N, type OrbitalEventRequest as O, type PersistenceAdapter as P, OrbitalServerRuntime as Q, type RegisteredOrbital as R, type SchemaLoader as S, type RuntimeTraitTick as T, type UnifiedLoaderOptions as U, createOrbitalServerRuntime as V, type LoadedSchema as a, type LoadedOrbital as b, EventBus as c, type EventNamespaceMap as d, InMemoryPersistence as e, type OrbitalEventResponse as f, type OrbitalServerRuntimeConfig as g, type PreprocessOptions as h, type PreprocessResult as i, type PreprocessedSchema as j, type ProcessEventOptions as k, type RuntimeOrbital as l, type RuntimeOrbitalSchema as m, type RuntimeTrait as n, StateMachineManager as o, collectDeclaredConfigDefaults as p, collectDeclaredEntityDefaults as q, createInitialTraitState as r, findInitialState as s, findTransition as t, getIsolatedCollectionName as u, getNamespacedEvent as v, isBrowser as w, isElectron as x, isNamespacedEvent as y, isNode as z };
@@ -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-BkaBvI6-.js';
2
+ export { G as ClientEffectTuple, H as ClientNavigateTuple, J as ClientNotifyTuple, K as ClientRenderUITuple, M as EffectResult, e as InMemoryPersistence, N as LoaderConfig, O as OrbitalEventRequest, f as OrbitalEventResponse, Q as OrbitalServerRuntime, g as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, T as RuntimeTraitTick, p as collectDeclaredConfigDefaults, V as createOrbitalServerRuntime } from './OrbitalServerRuntime-DpAwIrmv.js';
3
3
  import './types-D-9feVsj.js';
4
4
  import '@almadar/core';
@@ -1,7 +1,7 @@
1
- import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, createContextFromBindings, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-6YDQGA6X.js';
2
- export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-6YDQGA6X.js';
3
- import { isValidCronExpression } from './chunk-U4PL237A.js';
4
- import './chunk-PZ5AY32C.js';
1
+ import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, createContextFromBindings, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-YFH577FH.js';
2
+ export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-YFH577FH.js';
3
+ import { isValidCronExpression } from './chunk-OU3ITB5S.js';
4
+ import './chunk-MLKGABMK.js';
5
5
  import { createLogger } from '@almadar/logger';
6
6
  import * as nodeModule from 'module';
7
7
  import { evaluateGuard, evaluate } from '@almadar/evaluator';
@@ -138,7 +138,7 @@ var OrbitalServerRuntime = class {
138
138
  if (!isNodeEnv()) return;
139
139
  if (!this.substrateHandlersPromise) {
140
140
  this.substrateHandlersPromise = (async () => {
141
- const { createAgentSubstrateHandlers } = await import('./createAgentSubstrateHandlers-WZCHKGU6.js');
141
+ const { createAgentSubstrateHandlers } = await import('./createAgentSubstrateHandlers-G6KSTJPA.js');
142
142
  this.substrateHandlers = createAgentSubstrateHandlers({
143
143
  emitEvent: (type, payload) => this.eventBus.emit(type, payload),
144
144
  services: this.config.substrateServices ?? {}
@@ -1921,5 +1921,3 @@ function buildMatcher(src, listenerOrbital) {
1921
1921
  }
1922
1922
 
1923
1923
  export { OrbitalServerRuntime, createOrbitalServerRuntime };
1924
- //# sourceMappingURL=OrbitalServerRuntime.js.map
1925
- //# sourceMappingURL=OrbitalServerRuntime.js.map
@@ -1,4 +1,4 @@
1
- import './chunk-PZ5AY32C.js';
1
+ import './chunk-MLKGABMK.js';
2
2
  import { createLogger } from '@almadar/logger';
3
3
 
4
4
  var log = createLogger("almadar:runtime:server-bridge");
@@ -240,5 +240,3 @@ function createServerBridge(config) {
240
240
  }
241
241
 
242
242
  export { ServerBridge, createServerBridge };
243
- //# sourceMappingURL=ServerBridge.js.map
244
- //# sourceMappingURL=ServerBridge.js.map
@@ -5,5 +5,3 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  export { __export };
8
- //# sourceMappingURL=chunk-PZ5AY32C.js.map
9
- //# sourceMappingURL=chunk-PZ5AY32C.js.map
@@ -47,5 +47,3 @@ function cronMinuteKey(date) {
47
47
  }
48
48
 
49
49
  export { cronMatches, cronMinuteKey, isValidCronExpression, parseCron, parseCronField };
50
- //# sourceMappingURL=chunk-U4PL237A.js.map
51
- //# sourceMappingURL=chunk-U4PL237A.js.map
@@ -1,4 +1,4 @@
1
- import { parseCron, cronMinuteKey, cronMatches } from './chunk-U4PL237A.js';
1
+ import { parseCron, cronMinuteKey, cronMatches } from './chunk-OU3ITB5S.js';
2
2
  import { createLogger, setNamespaceLevel } from '@almadar/logger';
3
3
  import { resolveBinding, evaluate, createMinimalContext, evaluateGuard, SExpressionEvaluator } from '@almadar/evaluator';
4
4
  export { createMinimalContext } from '@almadar/evaluator';
@@ -1008,6 +1008,7 @@ var HANDLER_MANIFEST = {
1008
1008
  };
1009
1009
  var effectLog = createLogger("almadar:runtime:effects");
1010
1010
  setNamespaceLevel("almadar:runtime:effects", "WARN");
1011
+ var persistLog = createLogger("almadar:runtime:persist");
1011
1012
  function parseEffect(effect) {
1012
1013
  if (!Array.isArray(effect) || effect.length === 0) {
1013
1014
  return null;
@@ -1312,6 +1313,35 @@ var EffectExecutor = class _EffectExecutor {
1312
1313
  failure: emit.failure
1313
1314
  };
1314
1315
  }
1316
+ /**
1317
+ * Run a substrate (async) effect and dispatch the author's `emit.success`
1318
+ * / `emit.failure` bus event when configured. Mirrors the compiled-path
1319
+ * generic substrate dispatch (server.rs): uniform `{ result }` payload on
1320
+ * success, `{ error }` on failure.
1321
+ *
1322
+ * When no `emit` config is present (fire-and-forget call) the op still runs
1323
+ * but no event is dispatched and errors propagate (legacy behavior).
1324
+ */
1325
+ async runSubstrate(invoke, emitCfg) {
1326
+ if (!emitCfg) {
1327
+ await invoke();
1328
+ return;
1329
+ }
1330
+ try {
1331
+ const result = await invoke();
1332
+ this.emitSuccess(emitCfg, "success", { result: result ?? null });
1333
+ } catch (err) {
1334
+ this.emitFailure(emitCfg, err);
1335
+ }
1336
+ }
1337
+ /**
1338
+ * Separate a trailing `{ emit: {...} }` options object from positional
1339
+ * substrate-op args. Returns `[positionalArgs, emitConfig]`.
1340
+ */
1341
+ splitSubstrateEmit(args) {
1342
+ const emitCfg = args.length > 0 ? this.extractEmitConfig(args[args.length - 1]) : void 0;
1343
+ return emitCfg ? [args.slice(0, -1), emitCfg] : [args, void 0];
1344
+ }
1315
1345
  // ==========================================================================
1316
1346
  // Effect Dispatch
1317
1347
  // ==========================================================================
@@ -1375,14 +1405,14 @@ var EffectExecutor = class _EffectExecutor {
1375
1405
  const action = args[0];
1376
1406
  const last = args[args.length - 1];
1377
1407
  const emitCfg = last && typeof last === "object" && !Array.isArray(last) && "emit" in last ? this.extractEmitConfig(last) : void 0;
1378
- effectLog.debug("persist:dispatch", {
1408
+ persistLog.debug("persist:dispatch", {
1379
1409
  action,
1380
1410
  argCount: args.length,
1381
1411
  argTypes: args.map((a) => Array.isArray(a) ? "array" : a === null ? "null" : typeof a).join(","),
1382
1412
  traitName: this.context.traitName,
1383
1413
  transition: this.context.transition
1384
1414
  });
1385
- effectLog.debug("persist:emit-config", {
1415
+ persistLog.debug("persist:emit-config", {
1386
1416
  action,
1387
1417
  hasEmitCfg: emitCfg !== void 0,
1388
1418
  success: emitCfg?.success,
@@ -1392,30 +1422,30 @@ var EffectExecutor = class _EffectExecutor {
1392
1422
  if (action === "batch") {
1393
1423
  const operations = args[1];
1394
1424
  await this.handlers.persist("batch", "", { operations });
1395
- effectLog.debug("persist:success", {
1425
+ persistLog.debug("persist:success", {
1396
1426
  action,
1397
1427
  entityType: "batch",
1398
1428
  opCount: operations.length,
1399
1429
  willEmit: emitCfg?.success
1400
1430
  });
1401
1431
  this.emitSuccess(emitCfg, "success", operations);
1402
- effectLog.debug("persist:emit-fired", { action, eventName: emitCfg?.success });
1432
+ persistLog.debug("persist:emit-fired", { action, eventName: emitCfg?.success });
1403
1433
  } else {
1404
1434
  const entityType = args[1];
1405
1435
  const data = args[2];
1406
1436
  await this.handlers.persist(action, entityType, data);
1407
1437
  const dataId = typeof data === "string" ? data : data && typeof data === "object" ? data.id : void 0;
1408
- effectLog.debug("persist:success", {
1438
+ persistLog.debug("persist:success", {
1409
1439
  action,
1410
1440
  entityType,
1411
1441
  dataId,
1412
1442
  willEmit: emitCfg?.success
1413
1443
  });
1414
1444
  this.emitSuccess(emitCfg, "success", data);
1415
- effectLog.debug("persist:emit-fired", { action, eventName: emitCfg?.success });
1445
+ persistLog.debug("persist:emit-fired", { action, eventName: emitCfg?.success });
1416
1446
  }
1417
1447
  } catch (err) {
1418
- effectLog.error("persist:error", {
1448
+ persistLog.error("persist:error", {
1419
1449
  action,
1420
1450
  entityType: action === "batch" ? "batch" : args[1],
1421
1451
  error: err instanceof Error ? err.message : String(err)
@@ -1823,80 +1853,106 @@ var EffectExecutor = class _EffectExecutor {
1823
1853
  break;
1824
1854
  }
1825
1855
  // === Agent substrate operators (server-side, effect-position) ===
1856
+ //
1857
+ // Each honours a trailing `{ emit: { success, failure } }` options
1858
+ // object (mirrors fetch/persist/call-service): on success the
1859
+ // author's `emit.success` event fires with a uniform `{ result }`
1860
+ // payload so `?result` captures the return value; on failure the
1861
+ // `emit.failure` event fires with `{ error }`. Without an emit
1862
+ // config the call is fire-and-forget (legacy).
1826
1863
  case "compose/compose-all": {
1827
- if (this.handlers.substrateComposeAll) {
1828
- const config = args[0];
1829
- await this.handlers.substrateComposeAll(config);
1830
- } else {
1831
- this.logUnsupported("compose/compose-all");
1832
- }
1864
+ const [positional, emitCfg] = this.splitSubstrateEmit(args);
1865
+ const config = positional[0];
1866
+ await this.runSubstrate(async () => {
1867
+ if (!this.handlers.substrateComposeAll) {
1868
+ this.logUnsupported("compose/compose-all");
1869
+ return null;
1870
+ }
1871
+ return this.handlers.substrateComposeAll(config);
1872
+ }, emitCfg);
1833
1873
  break;
1834
1874
  }
1835
1875
  case "compose/compose-children": {
1836
- if (this.handlers.substrateComposeChildren) {
1837
- const parentName = args[0];
1838
- const children = args[1];
1839
- await this.handlers.substrateComposeChildren(parentName, children);
1840
- } else {
1841
- this.logUnsupported("compose/compose-children");
1842
- }
1876
+ const [positional, emitCfg] = this.splitSubstrateEmit(args);
1877
+ const parentName = positional[0];
1878
+ const children = positional[1];
1879
+ await this.runSubstrate(async () => {
1880
+ if (!this.handlers.substrateComposeChildren) {
1881
+ this.logUnsupported("compose/compose-children");
1882
+ return null;
1883
+ }
1884
+ return this.handlers.substrateComposeChildren(parentName, children);
1885
+ }, emitCfg);
1843
1886
  break;
1844
1887
  }
1845
1888
  case "behavior/instantiate": {
1846
- if (this.handlers.substrateInstantiate) {
1847
- const parentName = args[0];
1848
- const behavior = args[1];
1849
- const params = args.length > 2 ? args[2] : void 0;
1850
- await this.handlers.substrateInstantiate(parentName, behavior, params);
1851
- } else {
1852
- this.logUnsupported("behavior/instantiate");
1853
- }
1889
+ const [positional, emitCfg] = this.splitSubstrateEmit(args);
1890
+ const parentName = positional[0];
1891
+ const behavior = positional[1];
1892
+ const params = positional.length > 2 ? positional[2] : void 0;
1893
+ await this.runSubstrate(async () => {
1894
+ if (!this.handlers.substrateInstantiate) {
1895
+ this.logUnsupported("behavior/instantiate");
1896
+ return null;
1897
+ }
1898
+ return this.handlers.substrateInstantiate(parentName, behavior, params);
1899
+ }, emitCfg);
1854
1900
  break;
1855
1901
  }
1856
1902
  case "behavior/call": {
1857
- if (this.handlers.substrateCall) {
1858
- const behavior = args[0];
1859
- const method = args[1];
1860
- const params = args.length > 2 ? args[2] : void 0;
1861
- await this.handlers.substrateCall(behavior, method, params);
1862
- } else {
1863
- this.logUnsupported("behavior/call");
1864
- }
1903
+ const [positional, emitCfg] = this.splitSubstrateEmit(args);
1904
+ const behavior = positional[0];
1905
+ const method = positional[1];
1906
+ const params = positional.length > 2 ? positional[2] : void 0;
1907
+ await this.runSubstrate(async () => {
1908
+ if (!this.handlers.substrateCall) {
1909
+ this.logUnsupported("behavior/call");
1910
+ return null;
1911
+ }
1912
+ return this.handlers.substrateCall(behavior, method, params);
1913
+ }, emitCfg);
1865
1914
  break;
1866
1915
  }
1867
1916
  case "validate/validate": {
1868
- if (this.handlers.substrateValidate) {
1869
- const orbitalName = args[0];
1870
- await this.handlers.substrateValidate(orbitalName);
1871
- } else {
1872
- this.logUnsupported("validate/validate");
1873
- }
1917
+ const [positional, emitCfg] = this.splitSubstrateEmit(args);
1918
+ const orbitalName = positional[0];
1919
+ await this.runSubstrate(async () => {
1920
+ if (!this.handlers.substrateValidate) {
1921
+ this.logUnsupported("validate/validate");
1922
+ return null;
1923
+ }
1924
+ return this.handlers.substrateValidate(orbitalName);
1925
+ }, emitCfg);
1874
1926
  break;
1875
1927
  }
1876
1928
  case "lolo/emit-body": {
1877
- if (this.handlers.substrateEmitBody) {
1878
- const orbitalName = args[0];
1879
- const loloSource = args[1];
1880
- await this.handlers.substrateEmitBody(orbitalName, loloSource);
1881
- } else {
1882
- this.logUnsupported("lolo/emit-body");
1883
- }
1929
+ const [positional, emitCfg] = this.splitSubstrateEmit(args);
1930
+ const orbitalName = positional[0];
1931
+ const loloSource = positional[1];
1932
+ await this.runSubstrate(async () => {
1933
+ if (!this.handlers.substrateEmitBody) {
1934
+ this.logUnsupported("lolo/emit-body");
1935
+ return null;
1936
+ }
1937
+ return this.handlers.substrateEmitBody(orbitalName, loloSource);
1938
+ }, emitCfg);
1884
1939
  break;
1885
1940
  }
1886
1941
  default: {
1887
1942
  if (operator.includes("/")) {
1888
- const ctx = createContextFromBindings(
1889
- this.bindings,
1890
- this.strictBindings,
1891
- this.contextExtensions
1892
- );
1893
- const result = this.getEvaluator().evaluate(
1894
- [operator, ...args],
1895
- ctx
1896
- );
1897
- if (result instanceof Promise) {
1898
- await result;
1899
- }
1943
+ const [positional, emitCfg] = this.splitSubstrateEmit(args);
1944
+ await this.runSubstrate(async () => {
1945
+ const ctx = createContextFromBindings(
1946
+ this.bindings,
1947
+ this.strictBindings,
1948
+ this.contextExtensions
1949
+ );
1950
+ const result = this.getEvaluator().evaluate(
1951
+ [operator, ...positional],
1952
+ ctx
1953
+ );
1954
+ return result instanceof Promise ? await result : result;
1955
+ }, emitCfg);
1900
1956
  } else if (this.debug) {
1901
1957
  effectLog.warn("unknown-operator", { operator });
1902
1958
  }
@@ -2846,7 +2902,7 @@ async function getExternalLoaderModule() {
2846
2902
  return null;
2847
2903
  }
2848
2904
  try {
2849
- externalLoaderModule = await import('./external-loader-C2LO5XG3.js');
2905
+ externalLoaderModule = await import('./external-loader-OPXVTNC4.js');
2850
2906
  return externalLoaderModule;
2851
2907
  } catch {
2852
2908
  return null;
@@ -3287,7 +3343,7 @@ var ReferenceResolver = class {
3287
3343
  if (this.loader || this.loaderInitialized) return;
3288
3344
  this.loaderInitialized = true;
3289
3345
  try {
3290
- const { ExternalOrbitalLoader } = await import('./external-loader-C2LO5XG3.js');
3346
+ const { ExternalOrbitalLoader } = await import('./external-loader-OPXVTNC4.js');
3291
3347
  this.loader = new ExternalOrbitalLoader(this.options);
3292
3348
  } catch {
3293
3349
  }
@@ -3997,5 +4053,3 @@ var InMemoryPersistence = class {
3997
4053
  };
3998
4054
 
3999
4055
  export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, TickScheduler, buildEmitsFromTraits, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, containsBindings, createContextFromBindings, createInitialTraitState, createMockPersistence, createTestExecutor, createTickScheduler, createUnifiedLoader, extractBindings, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isBrowser, isElectron, isNamespacedEvent, isNode, isValidDurationString, normalizeCallSiteConfigToValues, normalizeEventKey, parseDurationString, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes };
4000
- //# sourceMappingURL=chunk-6YDQGA6X.js.map
4001
- //# sourceMappingURL=chunk-6YDQGA6X.js.map
@@ -1,4 +1,4 @@
1
- import './chunk-PZ5AY32C.js';
1
+ import './chunk-MLKGABMK.js';
2
2
  import { createLogger } from '@almadar/logger';
3
3
 
4
4
  var log = createLogger("almadar:runtime:substrate-handlers");
@@ -9,54 +9,42 @@ function createAgentSubstrateHandlers(ctx) {
9
9
  log.warn("compose-all service not registered");
10
10
  return null;
11
11
  }
12
- const result = await ctx.services.composeAll(config);
13
- ctx.emitEvent("COMPOSED_ALL", { appName: config.appName, orbitalCount: config.orbitals.length });
14
- return result;
12
+ return ctx.services.composeAll(config);
15
13
  },
16
14
  substrateComposeChildren: async (parentName, children) => {
17
15
  if (!ctx.services.composeChildren) {
18
16
  log.warn("compose-children service not registered");
19
17
  return null;
20
18
  }
21
- const result = await ctx.services.composeChildren(parentName, children);
22
- ctx.emitEvent("COMPOSED_CHILDREN", { parentName, childCount: children.length });
23
- return result;
19
+ return ctx.services.composeChildren(parentName, children);
24
20
  },
25
21
  substrateInstantiate: async (parentName, behavior, params) => {
26
22
  if (!ctx.services.instantiate) {
27
23
  log.warn("instantiate service not registered");
28
24
  return null;
29
25
  }
30
- const result = await ctx.services.instantiate(parentName, behavior, params);
31
- ctx.emitEvent("BEHAVIOR_INSTANTIATED", { parentName, behavior });
32
- return result;
26
+ return ctx.services.instantiate(parentName, behavior, params);
33
27
  },
34
28
  substrateCall: async (behavior, method) => {
35
29
  if (!ctx.services.call) {
36
30
  log.warn("call service not registered");
37
31
  return null;
38
32
  }
39
- const result = await ctx.services.call(behavior, method);
40
- ctx.emitEvent("BEHAVIOR_CALLED", { behavior, method });
41
- return result;
33
+ return ctx.services.call(behavior, method);
42
34
  },
43
35
  substrateValidate: async (orbitalName) => {
44
36
  if (!ctx.services.validate) {
45
37
  log.warn("validate service not registered");
46
38
  return null;
47
39
  }
48
- const result = await ctx.services.validate(orbitalName);
49
- ctx.emitEvent("VALIDATED", { orbitalName });
50
- return result;
40
+ return ctx.services.validate(orbitalName);
51
41
  },
52
42
  substrateEmitBody: async (orbitalName) => {
53
43
  if (!ctx.services.emitBody) {
54
44
  log.warn("emit-body service not registered");
55
45
  return null;
56
46
  }
57
- const result = await ctx.services.emitBody(orbitalName, "");
58
- ctx.emitEvent("LOLO_EMITTED", { orbitalName });
59
- return result;
47
+ return ctx.services.emitBody(orbitalName, "");
60
48
  }
61
49
  };
62
50
  return {
@@ -67,5 +55,3 @@ function createAgentSubstrateHandlers(ctx) {
67
55
  }
68
56
 
69
57
  export { createAgentSubstrateHandlers };
70
- //# sourceMappingURL=createAgentSubstrateHandlers-WZCHKGU6.js.map
71
- //# sourceMappingURL=createAgentSubstrateHandlers-WZCHKGU6.js.map
@@ -1,5 +1,5 @@
1
- import { parseCron, cronMinuteKey, cronMatches } from './chunk-U4PL237A.js';
2
- import './chunk-PZ5AY32C.js';
1
+ import { parseCron, cronMinuteKey, cronMatches } from './chunk-OU3ITB5S.js';
2
+ import './chunk-MLKGABMK.js';
3
3
  import * as fs from 'fs';
4
4
  import * as net from 'net';
5
5
  import { execFileSync } from 'child_process';
@@ -254,5 +254,3 @@ function createOsHandlers(ctx) {
254
254
  }
255
255
 
256
256
  export { createOsHandlers };
257
- //# sourceMappingURL=createOsHandlers.js.map
258
- //# sourceMappingURL=createOsHandlers.js.map
@@ -1,4 +1,4 @@
1
- import './chunk-PZ5AY32C.js';
1
+ import './chunk-MLKGABMK.js';
2
2
  import * as fs from 'fs';
3
3
  import * as path from 'path';
4
4
  import { OrbitalSchemaSchema } from '@almadar/core';
@@ -439,5 +439,3 @@ function autoDetectBehaviorsLibPaths(stdLibPath) {
439
439
  }
440
440
 
441
441
  export { ExternalOrbitalLoader, ImportChain, LoaderCache, createLoader, parseImportPath };
442
- //# sourceMappingURL=external-loader-C2LO5XG3.js.map
443
- //# sourceMappingURL=external-loader-C2LO5XG3.js.map
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { B as BindingContext, E as EvaluationContextExtensions, P as PatternProps, a as EffectHandlers, b as EffectContext, c as ExecutionEnvironment, d as EffectResult, T as TraitDefinition } from './types-D-9feVsj.js';
2
2
  export { e as Effect, f as EventListener, H as HANDLER_MANIFEST, I as IEventBus, R as RuntimeConfig, g as RuntimeEvent, h as TraitState, i as TransitionObserver, j as TransitionResult, U as Unsubscribe } from './types-D-9feVsj.js';
3
- import { U as UnifiedLoaderOptions, S as SchemaLoader, I as ImportChainLike, L as LoadResult, a as LoadedSchema, b as LoadedOrbital, P as PersistenceAdapter } from './OrbitalServerRuntime-BkaBvI6-.js';
4
- export { E as EntitySharingMap, c as EventBus, d as EventNamespaceMap, e as InMemoryPersistence, O as OrbitalEventRequest, f as OrbitalEventResponse, g as OrbitalServerRuntimeConfig, h as PreprocessOptions, i as PreprocessResult, j as PreprocessedSchema, k as ProcessEventOptions, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, o as StateMachineManager, p as collectDeclaredConfigDefaults, q as collectDeclaredEntityDefaults, r as createInitialTraitState, s as findInitialState, t as findTransition, u as getIsolatedCollectionName, v as getNamespacedEvent, w as isBrowser, x as isElectron, y as isNamespacedEvent, z as isNode, A as normalizeEventKey, B as parseNamespacedEvent, C as preprocessSchema, D as processEvent } from './OrbitalServerRuntime-BkaBvI6-.js';
3
+ import { U as UnifiedLoaderOptions, S as SchemaLoader, I as ImportChainLike, L as LoadResult, a as LoadedSchema, b as LoadedOrbital, P as PersistenceAdapter } from './OrbitalServerRuntime-DpAwIrmv.js';
4
+ export { E as EntitySharingMap, c as EventBus, d as EventNamespaceMap, e as InMemoryPersistence, O as OrbitalEventRequest, f as OrbitalEventResponse, g as OrbitalServerRuntimeConfig, h as PreprocessOptions, i as PreprocessResult, j as PreprocessedSchema, k as ProcessEventOptions, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, o as StateMachineManager, p as collectDeclaredConfigDefaults, q as collectDeclaredEntityDefaults, r as createInitialTraitState, s as findInitialState, t as findTransition, u as getIsolatedCollectionName, v as getNamespacedEvent, w as isBrowser, x as isElectron, y as isNamespacedEvent, z as isNode, A as normalizeCallSiteConfigToValues, B as normalizeEventKey, C as parseNamespacedEvent, D as preprocessSchema, F as processEvent } from './OrbitalServerRuntime-DpAwIrmv.js';
5
5
  import { EvaluationContext, SExpressionEvaluator } from '@almadar/evaluator';
6
6
  export { EvaluationContext, createMinimalContext } from '@almadar/evaluator';
7
7
  import { EventPayload, EntityField, EntityRow, ServiceParams, PayloadField, OrbitalDefinition, OrbitalSchema } from '@almadar/core';
@@ -404,6 +404,21 @@ declare class EffectExecutor {
404
404
  * with a single `if (emit)` guard.
405
405
  */
406
406
  private osEmit;
407
+ /**
408
+ * Run a substrate (async) effect and dispatch the author's `emit.success`
409
+ * / `emit.failure` bus event when configured. Mirrors the compiled-path
410
+ * generic substrate dispatch (server.rs): uniform `{ result }` payload on
411
+ * success, `{ error }` on failure.
412
+ *
413
+ * When no `emit` config is present (fire-and-forget call) the op still runs
414
+ * but no event is dispatched and errors propagate (legacy behavior).
415
+ */
416
+ private runSubstrate;
417
+ /**
418
+ * Separate a trailing `{ emit: {...} }` options object from positional
419
+ * substrate-op args. Returns `[positionalArgs, emitConfig]`.
420
+ */
421
+ private splitSubstrateEmit;
407
422
  private dispatch;
408
423
  private logUnsupported;
409
424
  }
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { EffectExecutor, createContextFromBindings } from './chunk-6YDQGA6X.js';
2
- export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, TickScheduler, buildEmitsFromTraits, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, containsBindings, createContextFromBindings, createInitialTraitState, createMinimalContext, createMockPersistence, createTestExecutor, createTickScheduler, createUnifiedLoader, extractBindings, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isBrowser, isElectron, isNamespacedEvent, isNode, isValidDurationString, normalizeEventKey, parseDurationString, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes } from './chunk-6YDQGA6X.js';
3
- export { cronMatches, cronMinuteKey, isValidCronExpression, parseCron, parseCronField } from './chunk-U4PL237A.js';
4
- import { __export } from './chunk-PZ5AY32C.js';
1
+ import { EffectExecutor, createContextFromBindings } from './chunk-YFH577FH.js';
2
+ export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, TickScheduler, buildEmitsFromTraits, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, containsBindings, createContextFromBindings, createInitialTraitState, createMinimalContext, createMockPersistence, createTestExecutor, createTickScheduler, createUnifiedLoader, extractBindings, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isBrowser, isElectron, isNamespacedEvent, isNode, isValidDurationString, normalizeCallSiteConfigToValues, normalizeEventKey, parseDurationString, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes } from './chunk-YFH577FH.js';
3
+ export { cronMatches, cronMinuteKey, isValidCronExpression, parseCron, parseCronField } from './chunk-OU3ITB5S.js';
4
+ import { __export } from './chunk-MLKGABMK.js';
5
5
  import { createLogger } from '@almadar/logger';
6
6
  import { evaluate } from '@almadar/evaluator';
7
7
  import { isInlineTrait } from '@almadar/core';
@@ -763,5 +763,3 @@ function pipeBehaviors(seed, ...steps) {
763
763
  }
764
764
 
765
765
  export { applyEventWiring, composeBehaviors, composition_exports as composition, createClientEffectHandlers, createServerEffectHandlers, detectLayoutStrategy, pipeBehaviors };
766
- //# sourceMappingURL=index.js.map
767
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/runtime",
3
- "version": "6.29.0",
3
+ "version": "6.31.0",
4
4
  "description": "Interpreted runtime for Almadar orbital applications (OrbitalServerRuntime)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -42,11 +42,11 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@almadar/core": "^10.21.0",
46
- "@almadar/evaluator": ">=2.9.2",
47
- "@almadar/logger": "^1.0.0",
48
- "@almadar/server": "^2.14.2",
49
- "@almadar/std": ">=7.2.4",
45
+ "@almadar/core": "^10.27.0",
46
+ "@almadar/evaluator": "^2.29.0",
47
+ "@almadar/logger": "^1.9.0",
48
+ "@almadar/server": "^2.20.0",
49
+ "@almadar/std": "^16.137.0",
50
50
  "@faker-js/faker": "^9.3.0"
51
51
  },
52
52
  "peerDependencies": {
@@ -58,7 +58,7 @@
58
58
  }
59
59
  },
60
60
  "devDependencies": {
61
- "@almadar/eslint-plugin": ">=2.7.0",
61
+ "@almadar/eslint-plugin": "^2.14.0",
62
62
  "@types/express": "^5.0.0",
63
63
  "@types/node": "^20.0.0",
64
64
  "@typescript-eslint/parser": "8.56.0",