Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 116 to 318

Compare

+45 −0 in 1 place
new file, 45 lines
1+// Ask Clef, Cloudflare's decision model on Workers AI, how a hold should be settled (#19). Clef takes Jev's
2+// System One request (state and typed questions) and answers with a probability per option, so the questions are
3+// jev.ts's own; it goes through the local Worker (workers-ai/, wrangler dev), which has the AI binding.
4+
5+import { type Hold, type SystemOneAnswer, systemOneBody, type Verdict, verdictOf } from "./jev.ts";
6+import { refused, ruled } from "./rules.ts";
7+import { WORKER } from "./workers-ai.ts";
8+
9+export interface ClefVerdict extends Verdict {
10+ readonly reason?: string;
11+ readonly by: "rule" | "model" | "turned down";
12+ readonly modelPick?: Verdict["pick"];
13+}
15+/** Code's rules first, then Clef, then code's check on its pick, as for the Workers AI text model. */
16+export async function askClef(
17+ h: Hold,
18+ opts: { model?: "clef" | "clef-flash"; url?: string } = {},
19+): Promise<ClefVerdict> {
20+ const rule = ruled(h);
21+ if (rule)
22+ return {
23+ pick: rule.pick,
24+ reason: rule.reason,
25+ confidence: 1,
26+ probabilities: { yours: 0, theirs: 0, both: 0, agent: 0, [rule.pick]: 1 },
27+ orders: [],
28+ signs: {},
29+ model: "rule",
30+ ms: 0,
31+ inputTokens: 0,
32+ by: "rule",
33+ };
34+ const started = performance.now();
35+ const res = await fetch(`${opts.url ?? WORKER}/system-one`, {
36+ method: "POST",
37+ headers: { "content-type": "application/json" },
38+ body: JSON.stringify(systemOneBody(h, opts.model ?? "clef")),
39+ });
40+ const out = (await res.json()) as SystemOneAnswer & { error?: string };
41+ if (!res.ok || out.error || !out.answers) throw new Error(`Clef: ${out.error ?? res.status}`);
42+ const v = verdictOf({ ...out, model: out.model ?? opts.model ?? "clef" }, performance.now() - started);
43+ const no = refused(h, v.pick);
44+ return no ? { ...v, pick: "agent", reason: no, by: "turned down", modelPick: v.pick } : { ...v, by: "model" };
45+}
MCP
compare on this site's /mcp
CLI
abso diff 116 318 scripts/autosettle/clef.ts --json
JSON
/christopher/abso-core/compare/116..318?file=scripts%2Fautosettle%2Fclef.ts&format=json