@almadar/evaluator 2.9.0 → 2.10.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,4 +1,4 @@
1
- import { AgentContext, SExpr } from '@almadar/core';
1
+ import { TraitConfig, AgentContext, SExpr } from '@almadar/core';
2
2
 
3
3
  /**
4
4
  * Evaluation Context
@@ -45,6 +45,13 @@ interface EvaluationContext {
45
45
  singletons: Map<string, Record<string, unknown>>;
46
46
  /** Local variables from 'let' bindings */
47
47
  locals?: Map<string, unknown>;
48
+ /**
49
+ * Call-site trait config for @config bindings. Populated by
50
+ * `OrbitalServerRuntime.executeEffects` from `RegisteredOrbital.configByTrait`.
51
+ * Molecules parameterize imported atoms through `config: { ... }` on the
52
+ * trait ref; the atom's render-ui reads `@config.icon`, `@config.title`, etc.
53
+ */
54
+ config?: TraitConfig;
48
55
  /**
49
56
  * When true, log warnings when bindings resolve to undefined. (RCG-01)
50
57
  * Helps detect typos and missing entity fields early.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { SExpr } from '@almadar/core';
2
2
  export { CORE_BINDINGS, CoreBinding, Expression, ExpressionSchema, ParsedBinding, SExpr, SExprAtom, SExprSchema, collectBindings, getArgs, getOperator, isBinding, isSExpr, isSExprAtom, isSExprCall, isValidBinding, parseBinding, sexpr, walkSExpr } from '@almadar/core';
3
- import { E as EvaluationContext } from './index-qVziiBjr.js';
4
- export { c as createChildContext, a as createEffectContext, b as createMinimalContext, e as evalAbs, d as evalAdd, f as evalAnd, g as evalAtomic, h as evalCallService, i as evalCeil, j as evalClamp, k as evalConcat, l as evalCount, m as evalDecrement, n as evalDeref, o as evalDespawn, p as evalDivide, q as evalDo, r as evalEmit, s as evalEmpty, t as evalEqual, u as evalFilter, v as evalFind, w as evalFirst, x as evalFloor, y as evalFn, z as evalGreaterThan, A as evalGreaterThanOrEqual, B as evalIf, C as evalIncludes, D as evalIncrement, F as evalLast, G as evalLessThan, H as evalLessThanOrEqual, I as evalLet, J as evalMap, K as evalMatches, L as evalMax, M as evalMin, N as evalModulo, O as evalMultiply, P as evalNavigate, Q as evalNot, R as evalNotEqual, S as evalNotify, T as evalNth, U as evalOr, V as evalPersist, W as evalRef, X as evalRenderUI, Y as evalRound, Z as evalSet, _ as evalSetDynamic, $ as evalSpawn, a0 as evalSubtract, a1 as evalSum, a2 as evalSwap, a3 as evalWatch, a4 as evalWhen, a5 as resolveBinding } from './index-qVziiBjr.js';
3
+ import { E as EvaluationContext } from './index-BXG58x-Q.js';
4
+ export { c as createChildContext, a as createEffectContext, b as createMinimalContext, e as evalAbs, d as evalAdd, f as evalAnd, g as evalAtomic, h as evalCallService, i as evalCeil, j as evalClamp, k as evalConcat, l as evalCount, m as evalDecrement, n as evalDeref, o as evalDespawn, p as evalDivide, q as evalDo, r as evalEmit, s as evalEmpty, t as evalEqual, u as evalFilter, v as evalFind, w as evalFirst, x as evalFloor, y as evalFn, z as evalGreaterThan, A as evalGreaterThanOrEqual, B as evalIf, C as evalIncludes, D as evalIncrement, F as evalLast, G as evalLessThan, H as evalLessThanOrEqual, I as evalLet, J as evalMap, K as evalMatches, L as evalMax, M as evalMin, N as evalModulo, O as evalMultiply, P as evalNavigate, Q as evalNot, R as evalNotEqual, S as evalNotify, T as evalNth, U as evalOr, V as evalPersist, W as evalRef, X as evalRenderUI, Y as evalRound, Z as evalSet, _ as evalSetDynamic, $ as evalSpawn, a0 as evalSubtract, a1 as evalSum, a2 as evalSwap, a3 as evalWatch, a4 as evalWhen, a5 as resolveBinding } from './index-BXG58x-Q.js';
5
5
 
6
6
  /**
7
7
  * S-Expression Evaluator
@@ -26,6 +26,7 @@ declare class SExpressionEvaluator {
26
26
  * @returns Result of evaluation
27
27
  */
28
28
  evaluate(expr: SExpr, ctx: EvaluationContext): unknown;
29
+ private isPlainObject;
29
30
  /**
30
31
  * Evaluate an S-expression as a guard (returns boolean).
31
32
  *
package/dist/index.js CHANGED
@@ -59,6 +59,9 @@ function resolveBinding(binding, ctx) {
59
59
  case "user":
60
60
  value = ctx.user;
61
61
  break;
62
+ case "config":
63
+ value = ctx.config;
64
+ break;
62
65
  default:
63
66
  value = ctx.singletons.get(root);
64
67
  break;
@@ -2570,12 +2573,22 @@ var SExpressionEvaluator = class {
2570
2573
  if (isBinding(expr)) {
2571
2574
  return resolveBinding(expr, ctx);
2572
2575
  }
2576
+ if (this.isPlainObject(expr)) {
2577
+ const out = {};
2578
+ for (const [k, v] of Object.entries(expr)) {
2579
+ out[k] = this.evaluate(v, ctx);
2580
+ }
2581
+ return out;
2582
+ }
2573
2583
  return expr;
2574
2584
  }
2575
2585
  const op = getOperator(expr);
2576
2586
  const args = getArgs(expr);
2577
2587
  return this.dispatchOperator(op, args, ctx);
2578
2588
  }
2589
+ isPlainObject(value) {
2590
+ return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && Object.getPrototypeOf(value) === Object.prototype;
2591
+ }
2579
2592
  /**
2580
2593
  * Evaluate an S-expression as a guard (returns boolean).
2581
2594
  *