@almadar/core 10.83.0 → 10.84.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.js +96 -0
- package/dist/index.js.map +1 -1
- package/dist/state-machine/index.js +96 -0
- package/dist/state-machine/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -65593,6 +65593,61 @@ function nestedPayload(path, leaf) {
|
|
|
65593
65593
|
function isPayloadObject(v) {
|
|
65594
65594
|
return typeof v === "object" && v !== null && !Array.isArray(v) && !(v instanceof Date);
|
|
65595
65595
|
}
|
|
65596
|
+
var SYNTHESIZED_GUARD_OPERATORS = /* @__PURE__ */ new Set([
|
|
65597
|
+
"not-nil",
|
|
65598
|
+
"not_nil",
|
|
65599
|
+
"nil",
|
|
65600
|
+
"eq",
|
|
65601
|
+
"==",
|
|
65602
|
+
"=",
|
|
65603
|
+
"not-eq",
|
|
65604
|
+
"!=",
|
|
65605
|
+
"neq",
|
|
65606
|
+
"gt",
|
|
65607
|
+
">",
|
|
65608
|
+
"gte",
|
|
65609
|
+
">=",
|
|
65610
|
+
"lt",
|
|
65611
|
+
"<",
|
|
65612
|
+
"lte",
|
|
65613
|
+
"<=",
|
|
65614
|
+
"and",
|
|
65615
|
+
"or",
|
|
65616
|
+
"not",
|
|
65617
|
+
"object/has",
|
|
65618
|
+
"object/get",
|
|
65619
|
+
"array/includes",
|
|
65620
|
+
"str/startsWith",
|
|
65621
|
+
"agent/is-pinned",
|
|
65622
|
+
"agent/memory-strength"
|
|
65623
|
+
]);
|
|
65624
|
+
var ACKNOWLEDGED_UNSYNTHESIZED_GUARD_OPERATORS = /* @__PURE__ */ new Set(["if", "let", "array/some", "grid/in-bounds"]);
|
|
65625
|
+
function isRecognizedGuardOperator(op) {
|
|
65626
|
+
return SYNTHESIZED_GUARD_OPERATORS.has(op) || ACKNOWLEDGED_UNSYNTHESIZED_GUARD_OPERATORS.has(op) || op.startsWith("agent/");
|
|
65627
|
+
}
|
|
65628
|
+
var unhandledGuardOperators = [];
|
|
65629
|
+
function recordUnhandledOperator(op) {
|
|
65630
|
+
if (unhandledGuardOperators.includes(op)) return;
|
|
65631
|
+
unhandledGuardOperators.push(op);
|
|
65632
|
+
console.warn(
|
|
65633
|
+
`[@almadar/core buildGuardPayloads] unrecognized guard operator "${op}" \u2014 synthesizing {pass:{}, fail:{}}; this guard arm cannot be walked pass/fail by verify. Add synthesis (or a tracked-gap entry) in guard-payloads.ts.`
|
|
65634
|
+
);
|
|
65635
|
+
}
|
|
65636
|
+
function splitPayloadArg(a, b) {
|
|
65637
|
+
const pathA = extractPayloadFieldPath(a);
|
|
65638
|
+
if (pathA) return { path: pathA, collection: b };
|
|
65639
|
+
const pathB = extractPayloadFieldPath(b);
|
|
65640
|
+
if (pathB) return { path: pathB, collection: a };
|
|
65641
|
+
return null;
|
|
65642
|
+
}
|
|
65643
|
+
function isPlainRecord(v) {
|
|
65644
|
+
return typeof v === "object" && v !== null && !Array.isArray(v) && !(v instanceof Date);
|
|
65645
|
+
}
|
|
65646
|
+
function absentKey(keys) {
|
|
65647
|
+
let candidate = `${keys.reduce((longest, k) => k.length > longest.length ? k : longest, "")}_`;
|
|
65648
|
+
while (keys.includes(candidate)) candidate += "_";
|
|
65649
|
+
return candidate;
|
|
65650
|
+
}
|
|
65596
65651
|
function mergePayloads(a, b) {
|
|
65597
65652
|
const out = { ...a };
|
|
65598
65653
|
for (const [k, v] of Object.entries(b)) {
|
|
@@ -65715,6 +65770,44 @@ function buildGuardPayloads(guard) {
|
|
|
65715
65770
|
const inner = buildGuardPayloads(guard[1]);
|
|
65716
65771
|
return { pass: inner.fail, fail: inner.pass };
|
|
65717
65772
|
}
|
|
65773
|
+
if (op === "object/has") {
|
|
65774
|
+
const split = splitPayloadArg(guard[1], guard[2]);
|
|
65775
|
+
if (split && isPlainRecord(split.collection)) {
|
|
65776
|
+
const keys = Object.keys(split.collection);
|
|
65777
|
+
if (keys.length > 0) {
|
|
65778
|
+
return { pass: nestedPayload(split.path, keys[0]), fail: nestedPayload(split.path, absentKey(keys)) };
|
|
65779
|
+
}
|
|
65780
|
+
}
|
|
65781
|
+
}
|
|
65782
|
+
if (op === "object/get") {
|
|
65783
|
+
const split = splitPayloadArg(guard[1], guard[2]);
|
|
65784
|
+
if (split && isPlainRecord(split.collection)) {
|
|
65785
|
+
const map = split.collection;
|
|
65786
|
+
const keys = Object.keys(map);
|
|
65787
|
+
const passKey = keys.find((k) => Boolean(map[k]));
|
|
65788
|
+
if (passKey !== void 0) {
|
|
65789
|
+
return { pass: nestedPayload(split.path, passKey), fail: nestedPayload(split.path, absentKey(keys)) };
|
|
65790
|
+
}
|
|
65791
|
+
}
|
|
65792
|
+
}
|
|
65793
|
+
if (op === "array/includes") {
|
|
65794
|
+
const split = splitPayloadArg(guard[1], guard[2]);
|
|
65795
|
+
if (split && Array.isArray(split.collection) && split.collection.length > 0) {
|
|
65796
|
+
const passVal = split.collection[0];
|
|
65797
|
+
const failVal = typeof passVal === "string" ? `${passVal}-not-in-list` : "not-in-list";
|
|
65798
|
+
return { pass: nestedPayload(split.path, passVal), fail: nestedPayload(split.path, failVal) };
|
|
65799
|
+
}
|
|
65800
|
+
}
|
|
65801
|
+
if (op === "str/startsWith") {
|
|
65802
|
+
const path = extractPayloadFieldPath(guard[1]);
|
|
65803
|
+
const prefix = typeof guard[2] === "string" ? guard[2] : "";
|
|
65804
|
+
if (path) {
|
|
65805
|
+
return {
|
|
65806
|
+
pass: nestedPayload(path, `${prefix}mock-suffix`),
|
|
65807
|
+
fail: nestedPayload(path, prefix.length > 0 ? `not-${prefix}` : "mock-test-value")
|
|
65808
|
+
};
|
|
65809
|
+
}
|
|
65810
|
+
}
|
|
65718
65811
|
if (op === "agent/is-pinned") {
|
|
65719
65812
|
const field = extractPayloadFieldRef(guard[1]);
|
|
65720
65813
|
if (field) return { pass: { [field]: "mem_test_unpinned" }, fail: { [field]: "mem_test_pinned" } };
|
|
@@ -65726,6 +65819,9 @@ function buildGuardPayloads(guard) {
|
|
|
65726
65819
|
if (op.startsWith("agent/")) {
|
|
65727
65820
|
return { pass: {}, fail: {} };
|
|
65728
65821
|
}
|
|
65822
|
+
if (!isRecognizedGuardOperator(op)) {
|
|
65823
|
+
recordUnhandledOperator(op);
|
|
65824
|
+
}
|
|
65729
65825
|
return { pass: {}, fail: {} };
|
|
65730
65826
|
}
|
|
65731
65827
|
|