typescript
270 files
Ack Gate
/** * H3.1 — Observation acknowledgment gate (P1 feedback closure). * After tool results are re-injected, the NEXT ass…
Ack Gate
/** * H3.1 — Ack Gate: wrap every tool result with obs_hash; enforce that the * NEXT assistant turn begins with `<ack …
Ack Gate.Test
/** * Tests for ack-gate (H3.1). * * Proves: * - wrapResult produces deterministic hex hash from tool result * - ch…
Adapters
import { drizzle } from "drizzle-orm/d1"; import { memoryRecords, traceEvents } from "../db/schema"; import { withRetry …
Ai
import type { Env } from "../types"; /** * AI namespace tools — powered by Workers AI binding. * * Uses `env.AI.run(…
Analyze Batches
import { Agent } from "@earendil-works/pi-agent-core"; import { getModel } from "@earendil-works/pi-ai"; import { Type }…
Anthropic Client
import { withRetry } from "../lib/retry"; import { LoomError } from "../types/errors"; import type { AssistantBlock, Mod…
Approve Skills
#!/usr/bin/env bun /** * Approval CLI for skill proposals. * * This is OPERATOR TOOLING — a bun script, NOT workerd c…
Artifact Contract.Test
/** * Artifact Contract Tests for run.ts dispatch paths. * * Proves that run.ts enforces the Dispatch Artifact Contra…
Artifact Contract.Test
/** * Artifact Contract Tests for run.ts dispatch paths. * * Proves that run.ts enforces the Dispatch Artifact Contra…
Artifacts
import type { Env } from "../types"; /** * Artifacts namespace tools — R2 bucket for binary artifacts. * * Provides …
Browser
import type { Env } from "../types"; /** * Browser namespace tools — powered by Browser Rendering quick actions. * *…
Budget Governor
import type { StageBudget } from "../types/contracts"; import type { Clock } from "./ports"; /** * H3.6 — Budget gover…
Budget Governor
/** * H3.6 — Budget Governor: hard caps B_tokens / B_calls / B_wallclock_ms from * the envelope. Breach → graceful sus…
Budget Governor.Test
/** * Tests for budget-governor (H3.6). * * Proves: * - all 3 hard cap types (calls, tokens, wallclock) are enforced…
Cf
/** * Cloudflare REST API client types and the typed error surfaced to sandbox * code when the API returns `success:fa…
Chaos Scenarios
/** * Shared chaos scenario runners used by both chaos.test.ts and * no-silent-failure.test.ts. Lives outside *.test.t…
Chaos.Test
/** * Chaos Tests — fault injection, one scenario per test. * * Five scenarios: * 1. dropped-tool-result — ack gat…
Checkpoint
/** * H1.1 + H1.4 — The alarm-tick sequence: assemble current GoalState, * evaluate active stage done-criteria predica…
Checkpoint.Test
/** * Tests for CheckpointEngine (H1.1 + H1.4). * * Proves: * - scripted fake stage results drive fail_streak to EXA…
Client
import type { CfEnvelope, CfError, Env } from "../types"; import { CloudflareApiError } from "../types"; /** * Host-si…
Codegen
/** * Golden goal: codegen — multi-stage code-generation goal. * * All stages pass done-criteria; the goal completes …
Compactor
/** * H4.5 — Compactor: summarize raw working context into semantic MemoryRecords. * * compactStage(goal_id, stage_id…
Compactor.Test
/** * Compactor tests (H4.5). * * Proves: * - Compactor output records all validate against memory-record.schema.j…
Conf Monitor
/** * H3.5 — Confidence EWMA monitor (P5). * Each assistant turn must carry <conf>0.NN</conf>. EWMA(alpha=0.4) below …
Conf Monitor
/** * H3.5 — Confidence Monitor: every assistant turn must include conf ∈ [0,1] * (schema-enforced; extract from a tra…
Conf Monitor.Test
/** * Tests for conf-monitor (H3.5). * * Proves: * - extractConf finds trailing JSON line `{"conf": 0.8}` in assista…
Confidence Calibrator
/** P5 — Brier-score confidence calibration over (stated confidence, outcome) pairs. */ import type { Escalation } from…
Config
/** Harness configuration — one section per loop. */ import type { ToolExecutionMode } from "@earendil-works/pi-agent-c…
Consolidation
/** * Offline consolidation: Hippocampus -> Neocortex. * * This engine is intentionally not called from transformCont…