- MCP
- show on this site's /mcp
- CLI
- abso show 198 --json
- JSON
- /christopher/abso-core/versions/198?format=json
Auto-settle (#19): Clef, Cloudflare's decision model on Workers AI, as a settler. Clef takes Jev's System One request, so clef.ts sends jev.ts's own questions through the local Worker's new /system-one route, with the same code checks before and after. score.ts and settle-one.ts take --via clef (--model clef or clef-flash). Six local holds: 6 of 6 right, 0.4 to 0.6 s each.
of shared·autosettle··Not checked
Version 197 · Files at version 198
5 files, 102 lines added, 18 removed.
--- /dev/null
+++ b/scripts/autosettle/clef.ts
@@ -0,0 +1,45 @@
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";
8+
14+
15+/** Code's rules first, then Clef, then code's check on its pick, as for the Workers AI text model. */
42+ const v = verdictOf({ ...out, model: out.model ?? opts.model ?? "clef" }, performance.now() - started);
44+ return no ? { ...v, pick: "agent", reason: no, by: "turned down", modelPick: v.pick } : { ...v, by: "model" };
--- a/scripts/autosettle/jev.ts
+++ b/scripts/autosettle/jev.ts
@@ -124,32 +124,43 @@
126126
127−/** Ask Jev once, with the choice in two option orders (Jev's docs warn order can sway a Choice) and the side questions. */
128−export async function ask(h: Hold, opts: { model?: string; key?: string } = {}): Promise<Verdict> {
129− const forward = PICKS;
130− const backward = [...PICKS].reverse();
131− const body = {
132− model: opts.model ?? "jev-latest",
128+ * One System One request (TypeSafe's API, which Cloudflare's Clef also takes): the choice in two option orders
135− settle: choice(forward),
136− settle_reversed: choice(backward),
137138 ...Object.fromEntries(Object.entries(SIGNS).map(([id, q]) => [id, { type: "noul", instructions: q }])),
142+
145+ answers: Record<string, { type: string; probabilities?: Record<string, number>; noul?: number; choice?: string }>;
148+
150+export async function ask(h: Hold, opts: { model?: string; key?: string } = {}): Promise<Verdict> {
143154 headers: { authorization: `Bearer ${opts.key ?? apiKey()}`, "content-type": "application/json" },
144− body: JSON.stringify(body),
147158 if (!res.ok) throw new Error(`Jev answered ${res.status}: ${(await res.text()).slice(0, 500)}`);
148− const out = (await res.json()) as {
149− model: string;
150− answers: Record<string, { type: string; probabilities?: Record<string, number>; noul?: number; choice?: string }>;
151− usage: { input_tokens: number };
152− };
161+
154165 const probabilities = Object.fromEntries(PICKS.map((k) => [k, out.answers[id]!.probabilities![k] ?? 0])) as Record<
@@ -168,7 +179,7 @@
168179 signs: Object.fromEntries(Object.keys(SIGNS).map((id) => [id, out.answers[id]?.noul ?? Number.NaN])),
171− inputTokens: out.usage.input_tokens,
174185
--- a/scripts/autosettle/score.ts
+++ b/scripts/autosettle/score.ts
@@ -1,6 +1,6 @@
3−// node scripts/autosettle/score.ts <cases.json> [--via workers-ai|jev] [--model <id>] [--out <report.json>]
3+// node scripts/autosettle/score.ts <cases.json> [--via workers-ai|clef|jev] [--model <id>] [--out <report.json>]
@@ -9,6 +9,7 @@
1010
1415
@@ -70,7 +71,12 @@
73− const verdict: Verdict = via === "jev" ? await ask(holdOf(c), model) : await askWorkersAi(holdOf(c), model);
--- a/scripts/autosettle/settle-one.ts
+++ b/scripts/autosettle/settle-one.ts
@@ -1,12 +1,13 @@
4−// node scripts/autosettle/settle-one.ts <file> [--via workers-ai|jev] [--model <id>] [--message "<your held push's message>"] [--issue "..."] [--name <path in the project>] [--json]
4+// node scripts/autosettle/settle-one.ts <file> [--via workers-ai|clef|jev] [--model <id>] [--message "<your held push's message>"] [--issue "..."] [--name <path in the project>] [--json]
66// --via workers-ai (the default) needs workers-ai/ running under wrangler dev; --via jev needs JEV_API_KEY.
77
1213
@@ -60,6 +61,15 @@
65+ const c = await askClef(h, { model: (flag(args, "--model") as "clef" | "clef-flash" | undefined) ?? "clef" });
69+ `Block ${i + 1} of ${holds.length} in ${h.file}: ${c.pick}, confidence ${c.confidence.toFixed(2)} (${c.by}${c.modelPick ? `, Clef said ${c.modelPick}` : ""})\n probabilities: ${PICKS.map((k) => `${k} ${(c.probabilities[k] * 100).toFixed(0)}%`).join(", ")}\n ${c.model}, ${c.ms.toFixed(0)} ms`,
--- a/scripts/autosettle/workers-ai/index.ts
+++ b/scripts/autosettle/workers-ai/index.ts
@@ -74,6 +74,18 @@
77+ // POST /system-one: a System One request (state and typed questions) for a Clef decision model, passed through.