openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
27 lines (26 loc) • 724 B
JavaScript
import { t as pruneMapToMaxSize } from "./map-size-BBr20tbc.mjs";
import { Clone } from "typebox/value";
//#region src/agents/schema/cached-schema.ts
/** Retain factory-owned schema variants, never the tool's execution or authority. */
function createCachedToolSchema(e) {
const t = /* @__PURE__ */ new Map();
return (n) => {
const r = e.key(n);
const i = t.get(r);
if (i) return i;
const a = Clone(e.build(n));
const o = [a];
while (o.length > 0) {
const e = o.pop();
if (e && typeof e === "object" && !Object.isFrozen(e)) {
o.push(...Object.values(e));
Object.freeze(e);
}
}
t.set(r, a);
pruneMapToMaxSize(t, 64);
return a;
};
}
//#endregion
export { createCachedToolSchema as t };