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 190 to 191

Compare

+45 −0 in 1 place
new file, 45 lines
1+// Ask the local auto-settle Worker (workers-ai/, run with wrangler dev) how a hold should be settled (#19).
2+
3+import type { Hold, Pick } from "./jev.ts";
4+
5+export const WORKER = process.env.AUTOSETTLE_WORKER ?? "http://127.0.0.1:8845";
6+
7+export interface ModelVerdict {
8+ readonly pick: Pick;
9+ readonly confidence: number;
10+ readonly reason: string;
11+ readonly model: string;
12+ /** Round trip from here, through wrangler dev, to Workers AI and back. */
13+ readonly ms: number;
14+ /** The model's own time, as the Worker measured it. */
15+ readonly modelMs: number;
16+ readonly inputTokens: number;
17+}
19+export async function askWorkersAi(h: Hold, opts: { model?: string; url?: string } = {}): Promise<ModelVerdict> {
20+ const started = performance.now();
21+ const res = await fetch(opts.url ?? WORKER, {
22+ method: "POST",
23+ headers: { "content-type": "application/json" },
24+ body: JSON.stringify({ hold: h, ...(opts.model ? { model: opts.model } : {}) }),
25+ });
26+ const out = (await res.json()) as {
27+ pick?: Pick;
28+ confidence?: number;
29+ reason?: string;
30+ model: string;
31+ ms: number;
32+ error?: string;
33+ usage?: { prompt_tokens?: number } | null;
34+ };
35+ if (!res.ok || out.error || !out.pick) throw new Error(`Workers AI: ${out.error ?? res.status}`);
36+ return {
37+ pick: out.pick,
38+ confidence: Math.min(1, Math.max(0, out.confidence ?? 0)),
39+ reason: out.reason ?? "",
40+ model: out.model,
41+ ms: performance.now() - started,
42+ modelMs: out.ms,
43+ inputTokens: out.usage?.prompt_tokens ?? 0,
44+ };
45+}
MCP
compare on this site's /mcp
CLI
abso diff 190 191 scripts/autosettle/workers-ai.ts --json
JSON
/christopher/abso-core/compare/190..191?file=scripts%2Fautosettle%2Fworkers-ai.ts&format=json