@almadar/evaluator 2.22.0 → 2.25.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 { TraitConfig, AgentContext, SExpr } from '@almadar/core';
|
|
1
|
+
import { TraitConfig, AgentContext, LlmContext, WorkspaceContext, SessionContext, MemoryContext, TraceContext, IntegrationContext, SExpr } from '@almadar/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Evaluation Context
|
|
@@ -72,6 +72,13 @@ interface EvaluationContext {
|
|
|
72
72
|
};
|
|
73
73
|
/** Agent context for agent/* operators (memory, LLM, tools, session) */
|
|
74
74
|
agent?: AgentContext;
|
|
75
|
+
/** Substrate contexts for llm/*, workspace/*, session/*, memory/*, trace/*, integration/* operators */
|
|
76
|
+
llm?: LlmContext;
|
|
77
|
+
workspace?: WorkspaceContext;
|
|
78
|
+
session?: SessionContext;
|
|
79
|
+
memory?: MemoryContext;
|
|
80
|
+
trace?: TraceContext;
|
|
81
|
+
integration?: IntegrationContext;
|
|
75
82
|
/** Mutate entity fields */
|
|
76
83
|
mutateEntity?: (changes: Record<string, unknown>) => void;
|
|
77
84
|
/** Emit an event */
|
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-CA1FEv6g.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-CA1FEv6g.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 } from '@almadar/core';
|
|
1
|
+
import { isSExpr, isBinding, getOperator, getArgs, 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
|
|
@@ -2530,118 +2530,265 @@ function evalOsDebounce(args, evaluate2, ctx) {
|
|
|
2530
2530
|
registerTrigger(ctx, "debounce", { ms, eventType });
|
|
2531
2531
|
}
|
|
2532
2532
|
|
|
2533
|
-
// std/
|
|
2534
|
-
function
|
|
2535
|
-
if (!ctx.
|
|
2536
|
-
const
|
|
2537
|
-
const
|
|
2538
|
-
return ctx.
|
|
2533
|
+
// std/llm.ts
|
|
2534
|
+
function evalLlmGenerate(args, evaluate2, ctx) {
|
|
2535
|
+
if (!ctx.llm) return null;
|
|
2536
|
+
const prompt = evaluate2(args[0], ctx);
|
|
2537
|
+
const options = args.length > 1 ? evaluate2(args[1], ctx) : void 0;
|
|
2538
|
+
return ctx.llm.generate(prompt, options);
|
|
2539
2539
|
}
|
|
2540
|
-
function
|
|
2541
|
-
if (!ctx.
|
|
2542
|
-
const
|
|
2543
|
-
|
|
2540
|
+
function evalLlmCallTools(args, evaluate2, ctx) {
|
|
2541
|
+
if (!ctx.llm) return null;
|
|
2542
|
+
const messages = evaluate2(args[0], ctx);
|
|
2543
|
+
const tools = evaluate2(args[1], ctx);
|
|
2544
|
+
return ctx.llm.callTools(messages, tools);
|
|
2544
2545
|
}
|
|
2545
|
-
function
|
|
2546
|
-
if (!ctx.
|
|
2547
|
-
const
|
|
2548
|
-
return ctx.
|
|
2546
|
+
function evalLlmEmbed(args, evaluate2, ctx) {
|
|
2547
|
+
if (!ctx.llm) return null;
|
|
2548
|
+
const texts = evaluate2(args[0], ctx);
|
|
2549
|
+
return ctx.llm.embed(texts);
|
|
2549
2550
|
}
|
|
2550
|
-
function
|
|
2551
|
-
if (!ctx.
|
|
2552
|
-
|
|
2553
|
-
return ctx.agent.isPinned(id);
|
|
2551
|
+
function evalLlmTokenCount(_args, _evaluate, ctx) {
|
|
2552
|
+
if (!ctx.llm) return 0;
|
|
2553
|
+
return ctx.llm.tokenCount();
|
|
2554
2554
|
}
|
|
2555
|
-
function
|
|
2556
|
-
if (!ctx.
|
|
2557
|
-
|
|
2555
|
+
function evalLlmSwitch(args, evaluate2, ctx) {
|
|
2556
|
+
if (!ctx.llm) return;
|
|
2557
|
+
const provider = evaluate2(args[0], ctx);
|
|
2558
|
+
const model = args.length > 1 ? evaluate2(args[1], ctx) : void 0;
|
|
2559
|
+
ctx.llm.switchProvider(provider, model);
|
|
2558
2560
|
}
|
|
2559
|
-
function
|
|
2560
|
-
if (!ctx.
|
|
2561
|
-
|
|
2561
|
+
function evalLlmCompact(args, evaluate2, ctx) {
|
|
2562
|
+
if (!ctx.llm) return null;
|
|
2563
|
+
const strategy = args.length > 0 ? evaluate2(args[0], ctx) : void 0;
|
|
2564
|
+
return ctx.llm.compact(strategy);
|
|
2562
2565
|
}
|
|
2563
|
-
function
|
|
2564
|
-
if (
|
|
2565
|
-
|
|
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;
|
|
2566
2576
|
}
|
|
2567
|
-
function
|
|
2568
|
-
if (
|
|
2569
|
-
|
|
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;
|
|
2570
2587
|
}
|
|
2571
|
-
function
|
|
2572
|
-
if (
|
|
2573
|
-
return
|
|
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";
|
|
2574
2591
|
}
|
|
2575
|
-
function
|
|
2576
|
-
if (
|
|
2577
|
-
|
|
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);
|
|
2578
2596
|
}
|
|
2579
|
-
function
|
|
2580
|
-
|
|
2581
|
-
const content = evaluate2(args[0], ctx);
|
|
2582
|
-
const category = evaluate2(args[1], ctx);
|
|
2583
|
-
const scope = args.length > 2 ? evaluate2(args[2], ctx) : void 0;
|
|
2584
|
-
return ctx.agent.memorize(content, category, scope);
|
|
2585
|
-
}
|
|
2586
|
-
function evalAgentForget(args, evaluate2, ctx) {
|
|
2587
|
-
if (!ctx.agent) return null;
|
|
2588
|
-
const id = evaluate2(args[0], ctx);
|
|
2589
|
-
return ctx.agent.forget(id);
|
|
2590
|
-
}
|
|
2591
|
-
function evalAgentPin(args, evaluate2, ctx) {
|
|
2592
|
-
if (!ctx.agent) return null;
|
|
2593
|
-
const id = evaluate2(args[0], ctx);
|
|
2594
|
-
return ctx.agent.pin(id);
|
|
2595
|
-
}
|
|
2596
|
-
function evalAgentReinforce(args, evaluate2, ctx) {
|
|
2597
|
-
if (!ctx.agent) return null;
|
|
2598
|
-
const id = evaluate2(args[0], ctx);
|
|
2599
|
-
return ctx.agent.reinforce(id);
|
|
2600
|
-
}
|
|
2601
|
-
function evalAgentDecay(_args, _evaluate, ctx) {
|
|
2602
|
-
if (!ctx.agent) return null;
|
|
2603
|
-
return ctx.agent.decay();
|
|
2604
|
-
}
|
|
2605
|
-
function evalAgentGenerate(args, evaluate2, ctx) {
|
|
2606
|
-
if (!ctx.agent) return null;
|
|
2607
|
-
const prompt = evaluate2(args[0], ctx);
|
|
2608
|
-
const options = args.length > 1 ? evaluate2(args[1], ctx) : void 0;
|
|
2609
|
-
return ctx.agent.generate(prompt, options);
|
|
2610
|
-
}
|
|
2611
|
-
function evalAgentSwitchProvider(args, evaluate2, ctx) {
|
|
2612
|
-
if (!ctx.agent) return null;
|
|
2613
|
-
const provider = evaluate2(args[0], ctx);
|
|
2614
|
-
const model = args.length > 1 ? evaluate2(args[1], ctx) : void 0;
|
|
2615
|
-
ctx.agent.switchProvider(provider, model);
|
|
2616
|
-
return null;
|
|
2597
|
+
function isOrbital(value) {
|
|
2598
|
+
return OrbitalZodSchema.safeParse(value).success;
|
|
2617
2599
|
}
|
|
2618
|
-
function
|
|
2619
|
-
|
|
2620
|
-
const toolName = evaluate2(args[0], ctx);
|
|
2621
|
-
const toolArgs = evaluate2(args[1], ctx);
|
|
2622
|
-
return ctx.agent.invoke(toolName, toolArgs);
|
|
2600
|
+
function isOrbitalSchemaValue(value) {
|
|
2601
|
+
return safeParseOrbitalSchema(value).success;
|
|
2623
2602
|
}
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2603
|
+
|
|
2604
|
+
// std/workspace.ts
|
|
2605
|
+
function evalWorkspaceReadOrbital(args, evaluate2, ctx) {
|
|
2606
|
+
if (!ctx.workspace) return null;
|
|
2607
|
+
const name = evaluate2(args[0], ctx);
|
|
2608
|
+
return ctx.workspace.readOrbital(name);
|
|
2628
2609
|
}
|
|
2629
|
-
function
|
|
2630
|
-
if (!ctx.
|
|
2631
|
-
const
|
|
2632
|
-
|
|
2610
|
+
function evalWorkspaceWriteOrbital(args, evaluate2, ctx) {
|
|
2611
|
+
if (!ctx.workspace) return null;
|
|
2612
|
+
const name = evaluate2(args[0], ctx);
|
|
2613
|
+
const content = evaluate2(args[1], ctx);
|
|
2614
|
+
if (!isOrbital(content)) {
|
|
2615
|
+
throw new Error(`workspace/write-orbital value for "${name}" is not a valid orbital definition`);
|
|
2616
|
+
}
|
|
2617
|
+
return ctx.workspace.writeOrbital(name, content);
|
|
2618
|
+
}
|
|
2619
|
+
function evalWorkspaceReadFile(args, evaluate2, ctx) {
|
|
2620
|
+
if (!ctx.workspace) return null;
|
|
2621
|
+
const path = evaluate2(args[0], ctx);
|
|
2622
|
+
return ctx.workspace.readFile(path);
|
|
2623
|
+
}
|
|
2624
|
+
function evalWorkspaceWriteFile(args, evaluate2, ctx) {
|
|
2625
|
+
if (!ctx.workspace) return null;
|
|
2626
|
+
const path = evaluate2(args[0], ctx);
|
|
2627
|
+
const content = evaluate2(args[1], ctx);
|
|
2628
|
+
return ctx.workspace.writeFile(path, content);
|
|
2629
|
+
}
|
|
2630
|
+
function evalWorkspaceExists(args, evaluate2, ctx) {
|
|
2631
|
+
if (!ctx.workspace) return false;
|
|
2632
|
+
const path = evaluate2(args[0], ctx);
|
|
2633
|
+
return ctx.workspace.exists(path);
|
|
2634
|
+
}
|
|
2635
|
+
function evalWorkspaceListOrbitals(_args, _evaluate, ctx) {
|
|
2636
|
+
if (!ctx.workspace) return [];
|
|
2637
|
+
return ctx.workspace.listOrbitals();
|
|
2638
|
+
}
|
|
2639
|
+
function evalWorkspaceReadSchema(_args, _evaluate, ctx) {
|
|
2640
|
+
if (!ctx.workspace) return null;
|
|
2641
|
+
return ctx.workspace.readSchema();
|
|
2642
|
+
}
|
|
2643
|
+
function evalWorkspaceWriteSchema(args, evaluate2, ctx) {
|
|
2644
|
+
if (!ctx.workspace) return null;
|
|
2645
|
+
const schema = evaluate2(args[0], ctx);
|
|
2646
|
+
if (!isOrbitalSchemaValue(schema)) {
|
|
2647
|
+
throw new Error("workspace/write-schema value is not a valid orbital schema");
|
|
2648
|
+
}
|
|
2649
|
+
return ctx.workspace.writeSchema(schema);
|
|
2650
|
+
}
|
|
2651
|
+
function evalWorkspaceReadPlan(_args, _evaluate, ctx) {
|
|
2652
|
+
if (!ctx.workspace) return null;
|
|
2653
|
+
return ctx.workspace.readPlan();
|
|
2654
|
+
}
|
|
2655
|
+
function evalWorkspaceWritePlan(args, evaluate2, ctx) {
|
|
2656
|
+
if (!ctx.workspace) return null;
|
|
2657
|
+
const plan = evaluate2(args[0], ctx);
|
|
2658
|
+
if (!isPlanSnapshot(plan)) {
|
|
2659
|
+
throw new Error("workspace/write-plan value is not a valid plan snapshot (schemaVersion 1 envelope)");
|
|
2660
|
+
}
|
|
2661
|
+
return ctx.workspace.writePlan(plan);
|
|
2662
|
+
}
|
|
2663
|
+
function evalWorkspaceArchiveOrbital(args, evaluate2, ctx) {
|
|
2664
|
+
if (!ctx.workspace) return null;
|
|
2665
|
+
const name = evaluate2(args[0], ctx);
|
|
2666
|
+
return ctx.workspace.archiveOrbital(name);
|
|
2633
2667
|
}
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
ctx.
|
|
2638
|
-
|
|
2668
|
+
|
|
2669
|
+
// std/session.ts
|
|
2670
|
+
function evalSessionReadSpec(args, evaluate2, ctx) {
|
|
2671
|
+
if (!ctx.session) return null;
|
|
2672
|
+
const orbitalName = evaluate2(args[0], ctx);
|
|
2673
|
+
return ctx.session.readSpec(orbitalName);
|
|
2674
|
+
}
|
|
2675
|
+
function evalSessionWriteSpec(args, evaluate2, ctx) {
|
|
2676
|
+
if (!ctx.session) return null;
|
|
2677
|
+
const orbitalName = evaluate2(args[0], ctx);
|
|
2678
|
+
const spec = evaluate2(args[1], ctx);
|
|
2679
|
+
if (!isOrbital(spec)) {
|
|
2680
|
+
throw new Error(`session/write-spec value for "${orbitalName}" is not a valid orbital definition`);
|
|
2681
|
+
}
|
|
2682
|
+
return ctx.session.writeSpec(orbitalName, spec);
|
|
2683
|
+
}
|
|
2684
|
+
function evalSessionReadMemory(args, evaluate2, ctx) {
|
|
2685
|
+
if (!ctx.session) return null;
|
|
2686
|
+
const orbitalName = evaluate2(args[0], ctx);
|
|
2687
|
+
return ctx.session.readMemory(orbitalName);
|
|
2688
|
+
}
|
|
2689
|
+
function evalSessionWriteMemory(args, evaluate2, ctx) {
|
|
2690
|
+
if (!ctx.session) return null;
|
|
2691
|
+
const orbitalName = evaluate2(args[0], ctx);
|
|
2692
|
+
const memory = evaluate2(args[1], ctx);
|
|
2693
|
+
return ctx.session.writeMemory(orbitalName, memory);
|
|
2694
|
+
}
|
|
2695
|
+
function evalSessionReadHistory(args, evaluate2, ctx) {
|
|
2696
|
+
if (!ctx.session) return null;
|
|
2697
|
+
const orbitalName = evaluate2(args[0], ctx);
|
|
2698
|
+
return ctx.session.readHistory(orbitalName);
|
|
2699
|
+
}
|
|
2700
|
+
function evalSessionAppendHistory(args, evaluate2, ctx) {
|
|
2701
|
+
if (!ctx.session) return null;
|
|
2702
|
+
const orbitalName = evaluate2(args[0], ctx);
|
|
2703
|
+
const entry = evaluate2(args[1], ctx);
|
|
2704
|
+
if (!isSessionHistoryEntry(entry)) {
|
|
2705
|
+
throw new Error(`session/append-history entry for "${orbitalName}" must have role/content/timestamp`);
|
|
2706
|
+
}
|
|
2707
|
+
return ctx.session.appendHistory(orbitalName, entry);
|
|
2708
|
+
}
|
|
2709
|
+
function evalSessionReadErrors(args, evaluate2, ctx) {
|
|
2710
|
+
if (!ctx.session) return null;
|
|
2711
|
+
const orbitalName = evaluate2(args[0], ctx);
|
|
2712
|
+
return ctx.session.readErrors(orbitalName);
|
|
2713
|
+
}
|
|
2714
|
+
function evalSessionWriteErrors(args, evaluate2, ctx) {
|
|
2715
|
+
if (!ctx.session) return null;
|
|
2716
|
+
const orbitalName = evaluate2(args[0], ctx);
|
|
2717
|
+
const errors = evaluate2(args[1], ctx);
|
|
2718
|
+
return ctx.session.writeErrors(orbitalName, errors);
|
|
2719
|
+
}
|
|
2720
|
+
function evalSessionReadAnalysis(args, evaluate2, ctx) {
|
|
2721
|
+
if (!ctx.session) return null;
|
|
2722
|
+
const orbitalName = evaluate2(args[0], ctx);
|
|
2723
|
+
return ctx.session.readAnalysis(orbitalName);
|
|
2639
2724
|
}
|
|
2640
|
-
|
|
2641
|
-
|
|
2725
|
+
|
|
2726
|
+
// std/memory.ts
|
|
2727
|
+
function evalMemoryRecall(args, evaluate2, ctx) {
|
|
2728
|
+
if (!ctx.memory) return [];
|
|
2642
2729
|
const query = evaluate2(args[0], ctx);
|
|
2643
|
-
const
|
|
2644
|
-
return ctx.
|
|
2730
|
+
const limit = args.length > 1 ? evaluate2(args[1], ctx) : void 0;
|
|
2731
|
+
return ctx.memory.recall(query, limit);
|
|
2732
|
+
}
|
|
2733
|
+
function evalMemoryStore(args, evaluate2, ctx) {
|
|
2734
|
+
if (!ctx.memory) return null;
|
|
2735
|
+
const content = evaluate2(args[0], ctx);
|
|
2736
|
+
const category = args.length > 1 ? evaluate2(args[1], ctx) : void 0;
|
|
2737
|
+
const strength = args.length > 2 ? evaluate2(args[2], ctx) : void 0;
|
|
2738
|
+
return ctx.memory.store(content, category, strength);
|
|
2739
|
+
}
|
|
2740
|
+
function evalMemoryList(args, evaluate2, ctx) {
|
|
2741
|
+
if (!ctx.memory) return [];
|
|
2742
|
+
const category = args.length > 0 ? evaluate2(args[0], ctx) : void 0;
|
|
2743
|
+
return ctx.memory.list(category);
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2746
|
+
// std/trace.ts
|
|
2747
|
+
function evalTraceEmit(args, evaluate2, ctx) {
|
|
2748
|
+
if (!ctx.trace) return;
|
|
2749
|
+
const event = evaluate2(args[0], ctx);
|
|
2750
|
+
const payload = args.length > 1 ? evaluate2(args[1], ctx) : void 0;
|
|
2751
|
+
if (!isEventPayloadValue(payload)) {
|
|
2752
|
+
throw new Error(`trace/emit payload for "${event}" is not an event-payload value (JSON-like)`);
|
|
2753
|
+
}
|
|
2754
|
+
ctx.trace.emit(event, payload);
|
|
2755
|
+
}
|
|
2756
|
+
function evalTraceLog(args, evaluate2, ctx) {
|
|
2757
|
+
if (!ctx.trace) return;
|
|
2758
|
+
const message = evaluate2(args[0], ctx);
|
|
2759
|
+
const level = args.length > 1 ? evaluate2(args[1], ctx) : void 0;
|
|
2760
|
+
const data = args.length > 2 ? evaluate2(args[2], ctx) : void 0;
|
|
2761
|
+
if (!isEventPayloadValue(data)) {
|
|
2762
|
+
throw new Error("trace/log data is not an event-payload value (JSON-like)");
|
|
2763
|
+
}
|
|
2764
|
+
ctx.trace.log(message, level, data);
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
// std/integration.ts
|
|
2768
|
+
function evalIntegrationHttp(args, evaluate2, ctx) {
|
|
2769
|
+
if (!ctx.integration) return null;
|
|
2770
|
+
const method = evaluate2(args[0], ctx);
|
|
2771
|
+
const url = evaluate2(args[1], ctx);
|
|
2772
|
+
const body = args.length > 2 ? evaluate2(args[2], ctx) : void 0;
|
|
2773
|
+
if (body !== void 0 && !isFieldValue(body)) {
|
|
2774
|
+
throw new Error(`integration/http body for ${method} ${url} is not a field value (JSON-like)`);
|
|
2775
|
+
}
|
|
2776
|
+
const headers = args.length > 3 ? evaluate2(args[3], ctx) : void 0;
|
|
2777
|
+
return ctx.integration.http(method, url, body, headers);
|
|
2778
|
+
}
|
|
2779
|
+
function evalIntegrationGithubGetRepo(args, evaluate2, ctx) {
|
|
2780
|
+
if (!ctx.integration) return null;
|
|
2781
|
+
const owner = evaluate2(args[0], ctx);
|
|
2782
|
+
const repo = evaluate2(args[1], ctx);
|
|
2783
|
+
return ctx.integration.githubGetRepo(owner, repo);
|
|
2784
|
+
}
|
|
2785
|
+
function evalIntegrationGithubCreateIssue(args, evaluate2, ctx) {
|
|
2786
|
+
if (!ctx.integration) return null;
|
|
2787
|
+
const owner = evaluate2(args[0], ctx);
|
|
2788
|
+
const repo = evaluate2(args[1], ctx);
|
|
2789
|
+
const title = evaluate2(args[2], ctx);
|
|
2790
|
+
const body = args.length > 3 ? evaluate2(args[3], ctx) : void 0;
|
|
2791
|
+
return ctx.integration.githubCreateIssue(owner, repo, title, body);
|
|
2645
2792
|
}
|
|
2646
2793
|
|
|
2647
2794
|
// std/vector.ts
|
|
@@ -4375,63 +4522,91 @@ var SExpressionEvaluator = class {
|
|
|
4375
4522
|
evalOsDebounce(args, evaluate2, ctx);
|
|
4376
4523
|
return void 0;
|
|
4377
4524
|
// ===============================
|
|
4378
|
-
// Standard Library:
|
|
4525
|
+
// Standard Library: llm/*
|
|
4526
|
+
// ===============================
|
|
4527
|
+
case "llm/generate":
|
|
4528
|
+
return evalLlmGenerate(args, evaluate2, ctx);
|
|
4529
|
+
case "llm/call-tools":
|
|
4530
|
+
return evalLlmCallTools(args, evaluate2, ctx);
|
|
4531
|
+
case "llm/embed":
|
|
4532
|
+
return evalLlmEmbed(args, evaluate2, ctx);
|
|
4533
|
+
case "llm/token-count":
|
|
4534
|
+
return evalLlmTokenCount(args, evaluate2, ctx);
|
|
4535
|
+
case "llm/switch":
|
|
4536
|
+
return evalLlmSwitch(args, evaluate2, ctx);
|
|
4537
|
+
case "llm/compact":
|
|
4538
|
+
return evalLlmCompact(args, evaluate2, ctx);
|
|
4539
|
+
// ===============================
|
|
4540
|
+
// Standard Library: workspace/*
|
|
4541
|
+
// ===============================
|
|
4542
|
+
case "workspace/read-orbital":
|
|
4543
|
+
return evalWorkspaceReadOrbital(args, evaluate2, ctx);
|
|
4544
|
+
case "workspace/write-orbital":
|
|
4545
|
+
return evalWorkspaceWriteOrbital(args, evaluate2, ctx);
|
|
4546
|
+
case "workspace/read-file":
|
|
4547
|
+
return evalWorkspaceReadFile(args, evaluate2, ctx);
|
|
4548
|
+
case "workspace/write-file":
|
|
4549
|
+
return evalWorkspaceWriteFile(args, evaluate2, ctx);
|
|
4550
|
+
case "workspace/exists":
|
|
4551
|
+
return evalWorkspaceExists(args, evaluate2, ctx);
|
|
4552
|
+
case "workspace/list-orbitals":
|
|
4553
|
+
return evalWorkspaceListOrbitals(args, evaluate2, ctx);
|
|
4554
|
+
case "workspace/read-schema":
|
|
4555
|
+
return evalWorkspaceReadSchema(args, evaluate2, ctx);
|
|
4556
|
+
case "workspace/write-schema":
|
|
4557
|
+
return evalWorkspaceWriteSchema(args, evaluate2, ctx);
|
|
4558
|
+
case "workspace/read-plan":
|
|
4559
|
+
return evalWorkspaceReadPlan(args, evaluate2, ctx);
|
|
4560
|
+
case "workspace/write-plan":
|
|
4561
|
+
return evalWorkspaceWritePlan(args, evaluate2, ctx);
|
|
4562
|
+
case "workspace/archive-orbital":
|
|
4563
|
+
return evalWorkspaceArchiveOrbital(args, evaluate2, ctx);
|
|
4564
|
+
// ===============================
|
|
4565
|
+
// Standard Library: session/*
|
|
4566
|
+
// ===============================
|
|
4567
|
+
case "session/read-spec":
|
|
4568
|
+
return evalSessionReadSpec(args, evaluate2, ctx);
|
|
4569
|
+
case "session/write-spec":
|
|
4570
|
+
return evalSessionWriteSpec(args, evaluate2, ctx);
|
|
4571
|
+
case "session/read-memory":
|
|
4572
|
+
return evalSessionReadMemory(args, evaluate2, ctx);
|
|
4573
|
+
case "session/write-memory":
|
|
4574
|
+
return evalSessionWriteMemory(args, evaluate2, ctx);
|
|
4575
|
+
case "session/read-history":
|
|
4576
|
+
return evalSessionReadHistory(args, evaluate2, ctx);
|
|
4577
|
+
case "session/append-history":
|
|
4578
|
+
return evalSessionAppendHistory(args, evaluate2, ctx);
|
|
4579
|
+
case "session/read-errors":
|
|
4580
|
+
return evalSessionReadErrors(args, evaluate2, ctx);
|
|
4581
|
+
case "session/write-errors":
|
|
4582
|
+
return evalSessionWriteErrors(args, evaluate2, ctx);
|
|
4583
|
+
case "session/read-analysis":
|
|
4584
|
+
return evalSessionReadAnalysis(args, evaluate2, ctx);
|
|
4585
|
+
// ===============================
|
|
4586
|
+
// Standard Library: memory/*
|
|
4587
|
+
// ===============================
|
|
4588
|
+
case "memory/recall":
|
|
4589
|
+
return evalMemoryRecall(args, evaluate2, ctx);
|
|
4590
|
+
case "memory/store":
|
|
4591
|
+
return evalMemoryStore(args, evaluate2, ctx);
|
|
4592
|
+
case "memory/list":
|
|
4593
|
+
return evalMemoryList(args, evaluate2, ctx);
|
|
4594
|
+
// ===============================
|
|
4595
|
+
// Standard Library: trace/*
|
|
4596
|
+
// ===============================
|
|
4597
|
+
case "trace/emit":
|
|
4598
|
+
return evalTraceEmit(args, evaluate2, ctx);
|
|
4599
|
+
case "trace/log":
|
|
4600
|
+
return evalTraceLog(args, evaluate2, ctx);
|
|
4601
|
+
// ===============================
|
|
4602
|
+
// Standard Library: integration/*
|
|
4379
4603
|
// ===============================
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
return evalAgentMemoryStrength(args, evaluate2, ctx);
|
|
4387
|
-
case "agent/is-pinned":
|
|
4388
|
-
return evalAgentIsPinned(args, evaluate2, ctx);
|
|
4389
|
-
// Pure (LLM)
|
|
4390
|
-
case "agent/provider":
|
|
4391
|
-
return evalAgentProvider(args, evaluate2, ctx);
|
|
4392
|
-
case "agent/model":
|
|
4393
|
-
return evalAgentModel(args, evaluate2, ctx);
|
|
4394
|
-
// Pure (tools)
|
|
4395
|
-
case "agent/tools":
|
|
4396
|
-
return evalAgentTools(args, evaluate2, ctx);
|
|
4397
|
-
// Pure (context)
|
|
4398
|
-
case "agent/token-count":
|
|
4399
|
-
return evalAgentTokenCount(args, evaluate2, ctx);
|
|
4400
|
-
case "agent/context-usage":
|
|
4401
|
-
return evalAgentContextUsage(args, evaluate2, ctx);
|
|
4402
|
-
// Pure (session)
|
|
4403
|
-
case "agent/session-id":
|
|
4404
|
-
return evalAgentSessionId(args, evaluate2, ctx);
|
|
4405
|
-
// Effects (memory)
|
|
4406
|
-
case "agent/memorize":
|
|
4407
|
-
return evalAgentMemorize(args, evaluate2, ctx);
|
|
4408
|
-
case "agent/forget":
|
|
4409
|
-
return evalAgentForget(args, evaluate2, ctx);
|
|
4410
|
-
case "agent/pin":
|
|
4411
|
-
return evalAgentPin(args, evaluate2, ctx);
|
|
4412
|
-
case "agent/reinforce":
|
|
4413
|
-
return evalAgentReinforce(args, evaluate2, ctx);
|
|
4414
|
-
case "agent/decay":
|
|
4415
|
-
return evalAgentDecay(args, evaluate2, ctx);
|
|
4416
|
-
// Effects (LLM)
|
|
4417
|
-
case "agent/generate":
|
|
4418
|
-
return evalAgentGenerate(args, evaluate2, ctx);
|
|
4419
|
-
case "agent/switch-provider":
|
|
4420
|
-
return evalAgentSwitchProvider(args, evaluate2, ctx);
|
|
4421
|
-
// Effects (tools)
|
|
4422
|
-
case "agent/invoke":
|
|
4423
|
-
return evalAgentInvoke(args, evaluate2, ctx);
|
|
4424
|
-
// Effects (context)
|
|
4425
|
-
case "agent/compact":
|
|
4426
|
-
return evalAgentCompact(args, evaluate2, ctx);
|
|
4427
|
-
// Effects (session)
|
|
4428
|
-
case "agent/fork":
|
|
4429
|
-
return evalAgentFork(args, evaluate2, ctx);
|
|
4430
|
-
case "agent/label":
|
|
4431
|
-
return evalAgentLabel(args, evaluate2, ctx);
|
|
4432
|
-
// Effects (search)
|
|
4433
|
-
case "agent/search-code":
|
|
4434
|
-
return evalAgentSearchCode(args, evaluate2, ctx);
|
|
4604
|
+
case "integration/http":
|
|
4605
|
+
return evalIntegrationHttp(args, evaluate2, ctx);
|
|
4606
|
+
case "integration/github-get-repo":
|
|
4607
|
+
return evalIntegrationGithubGetRepo(args, evaluate2, ctx);
|
|
4608
|
+
case "integration/github-create-issue":
|
|
4609
|
+
return evalIntegrationGithubCreateIssue(args, evaluate2, ctx);
|
|
4435
4610
|
default:
|
|
4436
4611
|
console.warn(`Unknown operator: ${op}`);
|
|
4437
4612
|
return void 0;
|