@almadar/evaluator 2.26.0 → 2.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/{index-CA1FEv6g.d.ts → index-BjtK8dP9.d.ts} +12 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -38
- package/dist/index.js.map +1 -1
- package/dist/operators/index.d.ts +1 -1
- package/dist/operators/index.js +10 -6
- package/dist/operators/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -230,14 +230,22 @@ declare function evalMatches(args: SExpr[], evaluate: Evaluator$4, ctx: Evaluati
|
|
|
230
230
|
type Evaluator$3 = (expr: SExpr, ctx: EvaluationContext) => unknown;
|
|
231
231
|
/**
|
|
232
232
|
* Evaluate logical AND: ["and", a, b, ...]
|
|
233
|
-
*
|
|
233
|
+
* Operand semantics (matches JS `&&` and the compiled TS path — Phase 5,
|
|
234
|
+
* R-OR-AND-RETURN-BOOLEAN): returns the first falsy argument's VALUE, or the
|
|
235
|
+
* last argument's value if all are truthy. Short-circuits — does not evaluate
|
|
236
|
+
* past the first falsy. (When every operand is boolean — the case for all
|
|
237
|
+
* shipping behaviors — this is observationally identical to returning a
|
|
238
|
+
* boolean.)
|
|
234
239
|
*/
|
|
235
|
-
declare function evalAnd(args: SExpr[], evaluate: Evaluator$3, ctx: EvaluationContext):
|
|
240
|
+
declare function evalAnd(args: SExpr[], evaluate: Evaluator$3, ctx: EvaluationContext): unknown;
|
|
236
241
|
/**
|
|
237
242
|
* Evaluate logical OR: ["or", a, b, ...]
|
|
238
|
-
*
|
|
243
|
+
* Operand semantics (matches JS `||` and the compiled TS path — Phase 5,
|
|
244
|
+
* R-OR-AND-RETURN-BOOLEAN): returns the first truthy argument's VALUE, or the
|
|
245
|
+
* last argument's value if all are falsy. Short-circuits — does not evaluate
|
|
246
|
+
* past the first truthy.
|
|
239
247
|
*/
|
|
240
|
-
declare function evalOr(args: SExpr[], evaluate: Evaluator$3, ctx: EvaluationContext):
|
|
248
|
+
declare function evalOr(args: SExpr[], evaluate: Evaluator$3, ctx: EvaluationContext): unknown;
|
|
241
249
|
/**
|
|
242
250
|
* Evaluate logical NOT: ["not", a]
|
|
243
251
|
*/
|
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-
|
|
4
|
-
export { U as UserContext, 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 evalList, K as evalMap, L as evalMatches, M as evalMax, N as evalMin, O as evalModulo, P as evalMultiply, Q as evalNavigate, R as evalNot, S as evalNotEqual, T as evalNotify, V as evalNth, W as evalOr, X as evalPersist, Y as evalRef, Z as evalRenderUI, _ as evalRound, $ as evalSet, a0 as evalSetDynamic, a1 as evalSpawn, a2 as evalSubtract, a3 as evalSum, a4 as evalSwap, a5 as evalWatch, a6 as evalWhen, a7 as resolveBinding } from './index-
|
|
3
|
+
import { E as EvaluationContext } from './index-BjtK8dP9.js';
|
|
4
|
+
export { U as UserContext, 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 evalList, K as evalMap, L as evalMatches, M as evalMax, N as evalMin, O as evalModulo, P as evalMultiply, Q as evalNavigate, R as evalNot, S as evalNotEqual, T as evalNotify, V as evalNth, W as evalOr, X as evalPersist, Y as evalRef, Z as evalRenderUI, _ as evalRound, $ as evalSet, a0 as evalSetDynamic, a1 as evalSpawn, a2 as evalSubtract, a3 as evalSum, a4 as evalSwap, a5 as evalWatch, a6 as evalWhen, a7 as resolveBinding } from './index-BjtK8dP9.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* S-Expression Evaluator
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isSExpr, isBinding, getOperator, getArgs, OrbitalZodSchema, safeParseOrbitalSchema } from '@almadar/core';
|
|
1
|
+
import { isSExpr, isBinding, getOperator, getArgs, isFieldValue, isEventPayloadValue, isSessionHistoryEntry, isPlanSnapshot, OrbitalZodSchema, safeParseOrbitalSchema } from '@almadar/core';
|
|
2
2
|
export { CORE_BINDINGS, ExpressionSchema, SExprSchema, collectBindings, getArgs, getOperator, isBinding, isSExpr, isSExprAtom, isSExprCall, isValidBinding, parseBinding, sexpr, walkSExpr } from '@almadar/core';
|
|
3
3
|
|
|
4
4
|
// types/expression.ts
|
|
@@ -237,20 +237,24 @@ function toComparable(value) {
|
|
|
237
237
|
|
|
238
238
|
// operators/logic.ts
|
|
239
239
|
function evalAnd(args, evaluate2, ctx) {
|
|
240
|
+
let last = true;
|
|
240
241
|
for (const arg of args) {
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
last = evaluate2(arg, ctx);
|
|
243
|
+
if (!toBoolean(last)) {
|
|
244
|
+
return last;
|
|
243
245
|
}
|
|
244
246
|
}
|
|
245
|
-
return
|
|
247
|
+
return last;
|
|
246
248
|
}
|
|
247
249
|
function evalOr(args, evaluate2, ctx) {
|
|
250
|
+
let last = false;
|
|
248
251
|
for (const arg of args) {
|
|
249
|
-
|
|
250
|
-
|
|
252
|
+
last = evaluate2(arg, ctx);
|
|
253
|
+
if (toBoolean(last)) {
|
|
254
|
+
return last;
|
|
251
255
|
}
|
|
252
256
|
}
|
|
253
|
-
return
|
|
257
|
+
return last;
|
|
254
258
|
}
|
|
255
259
|
function evalNot(args, evaluate2, ctx) {
|
|
256
260
|
return !toBoolean(evaluate2(args[0], ctx));
|
|
@@ -2563,37 +2567,6 @@ function evalLlmCompact(args, evaluate2, ctx) {
|
|
|
2563
2567
|
const strategy = args.length > 0 ? evaluate2(args[0], ctx) : void 0;
|
|
2564
2568
|
return ctx.llm.compact(strategy);
|
|
2565
2569
|
}
|
|
2566
|
-
function isFieldValue(value) {
|
|
2567
|
-
if (value === null) return true;
|
|
2568
|
-
const kind = typeof value;
|
|
2569
|
-
if (kind === "string" || kind === "number" || kind === "boolean") return true;
|
|
2570
|
-
if (value instanceof Date) return true;
|
|
2571
|
-
if (Array.isArray(value)) return value.every((item) => isFieldValue(item));
|
|
2572
|
-
if (kind === "object" && value !== null && typeof value === "object") {
|
|
2573
|
-
return Object.values(value).every((item) => item === void 0 || isFieldValue(item));
|
|
2574
|
-
}
|
|
2575
|
-
return false;
|
|
2576
|
-
}
|
|
2577
|
-
function isEventPayloadValue(value) {
|
|
2578
|
-
if (value === null || value === void 0) return true;
|
|
2579
|
-
const kind = typeof value;
|
|
2580
|
-
if (kind === "string" || kind === "number" || kind === "boolean") return true;
|
|
2581
|
-
if (value instanceof Date) return true;
|
|
2582
|
-
if (Array.isArray(value)) return value.every((item) => isEventPayloadValue(item));
|
|
2583
|
-
if (kind === "object" && value !== null && typeof value === "object") {
|
|
2584
|
-
return Object.values(value).every((item) => isEventPayloadValue(item));
|
|
2585
|
-
}
|
|
2586
|
-
return false;
|
|
2587
|
-
}
|
|
2588
|
-
function isSessionHistoryEntry(value) {
|
|
2589
|
-
if (typeof value !== "object" || value === null) return false;
|
|
2590
|
-
return "role" in value && typeof value.role === "string" && "content" in value && typeof value.content === "string" && "timestamp" in value && typeof value.timestamp === "number";
|
|
2591
|
-
}
|
|
2592
|
-
function isPlanSnapshot(value) {
|
|
2593
|
-
if (typeof value !== "object" || value === null) return false;
|
|
2594
|
-
const statuses = ["proposed", "confirmed", "built", "failed"];
|
|
2595
|
-
return "schemaVersion" in value && value.schemaVersion === 1 && "status" in value && statuses.some((s) => s === value.status) && "builtAt" in value && typeof value.builtAt === "string" && "orbitals" in value && Array.isArray(value.orbitals) && "renames" in value && Array.isArray(value.renames) && "deletedOrbitals" in value && Array.isArray(value.deletedOrbitals);
|
|
2596
|
-
}
|
|
2597
2570
|
function isOrbital(value) {
|
|
2598
2571
|
return OrbitalZodSchema.safeParse(value).success;
|
|
2599
2572
|
}
|