typescript

270 files

_archivesource

Ack Gate

/** * H3.1 — Observation acknowledgment gate (P1 feedback closure). * After tool results are re-injected, the NEXT ass…

TS55 lines2,076 bytes
loom-sprint-scaffoldsource

Ack Gate

/** * H3.1 — Ack Gate: wrap every tool result with obs_hash; enforce that the * NEXT assistant turn begins with `<ack …

TS94 lines2,810 bytes
loom-sprint-scaffoldtest

Ack Gate.Test

/** * Tests for ack-gate (H3.1). * * Proves: * - wrapResult produces deterministic hex hash from tool result * - ch…

TS162 lines5,577 bytes
_archivesource

Adapters

import { drizzle } from "drizzle-orm/d1"; import { memoryRecords, traceEvents } from "../db/schema"; import { withRetry …

TS118 lines4,160 bytes
codemode-gatewaysource

Ai

import type { Env } from "../types"; /** * AI namespace tools — powered by Workers AI binding. * * Uses `env.AI.run(…

TS125 lines4,276 bytes
pi-cyberneticsource

Analyze Batches

import { Agent } from "@earendil-works/pi-agent-core"; import { getModel } from "@earendil-works/pi-ai"; import { Type }…

TS139 lines5,068 bytes
_archivesource

Anthropic Client

import { withRetry } from "../lib/retry"; import { LoomError } from "../types/errors"; import type { AssistantBlock, Mod…

TS92 lines3,295 bytes
loom-sprint-scaffoldsource

Approve Skills

#!/usr/bin/env bun /** * Approval CLI for skill proposals. * * This is OPERATOR TOOLING — a bun script, NOT workerd c…

TS233 lines7,435 bytes
loom-buildertest

Artifact Contract.Test

/** * Artifact Contract Tests for run.ts dispatch paths. * * Proves that run.ts enforces the Dispatch Artifact Contra…

TS200 lines7,726 bytes
loom-builder-soltest

Artifact Contract.Test

/** * Artifact Contract Tests for run.ts dispatch paths. * * Proves that run.ts enforces the Dispatch Artifact Contra…

TS200 lines7,726 bytes
codemode-gatewaysource

Artifacts

import type { Env } from "../types"; /** * Artifacts namespace tools — R2 bucket for binary artifacts. * * Provides …

TS36 lines992 bytes
codemode-gatewaysource

Browser

import type { Env } from "../types"; /** * Browser namespace tools — powered by Browser Rendering quick actions. * *…

TS195 lines6,781 bytes
_archivesource

Budget Governor

import type { StageBudget } from "../types/contracts"; import type { Clock } from "./ports"; /** * H3.6 — Budget gover…

TS57 lines1,685 bytes
loom-sprint-scaffoldsource

Budget Governor

/** * H3.6 — Budget Governor: hard caps B_tokens / B_calls / B_wallclock_ms from * the envelope. Breach → graceful sus…

TS142 lines3,640 bytes
loom-sprint-scaffoldtest

Budget Governor.Test

/** * Tests for budget-governor (H3.6). * * Proves: * - all 3 hard cap types (calls, tokens, wallclock) are enforced…

TS190 lines6,388 bytes
codemode-gatewaysource

Cf

/** * Cloudflare REST API client types and the typed error surfaced to sandbox * code when the API returns `success:fa…

TS58 lines1,628 bytes
loom-sprint-scaffoldtest

Chaos Scenarios

/** * Shared chaos scenario runners used by both chaos.test.ts and * no-silent-failure.test.ts. Lives outside *.test.t…

TS76 lines2,999 bytes
loom-sprint-scaffoldtest

Chaos.Test

/** * Chaos Tests — fault injection, one scenario per test. * * Five scenarios: * 1. dropped-tool-result — ack gat…

TS253 lines10,016 bytes
loom-sprint-scaffoldsource

Checkpoint

/** * H1.1 + H1.4 — The alarm-tick sequence: assemble current GoalState, * evaluate active stage done-criteria predica…

TS299 lines9,633 bytes
loom-sprint-scaffoldtest

Checkpoint.Test

/** * Tests for CheckpointEngine (H1.1 + H1.4). * * Proves: * - scripted fake stage results drive fail_streak to EXA…

TS386 lines13,178 bytes
codemode-gatewaysource

Client

import type { CfEnvelope, CfError, Env } from "../types"; import { CloudflareApiError } from "../types"; /** * Host-si…

TS176 lines5,471 bytes
loom-sprint-scaffoldtest

Codegen

/** * Golden goal: codegen — multi-stage code-generation goal. * * All stages pass done-criteria; the goal completes …

TS82 lines2,789 bytes
loom-sprint-scaffoldsource

Compactor

/** * H4.5 — Compactor: summarize raw working context into semantic MemoryRecords. * * compactStage(goal_id, stage_id…

TS208 lines6,662 bytes
loom-sprint-scaffoldtest

Compactor.Test

/** * Compactor tests (H4.5). * * Proves: * - Compactor output records all validate against memory-record.schema.j…

TS178 lines6,156 bytes
_archivesource

Conf Monitor

/** * H3.5 — Confidence EWMA monitor (P5). * Each assistant turn must carry <conf>0.NN</conf>. EWMA(alpha=0.4) below …

TS40 lines1,274 bytes
loom-sprint-scaffoldsource

Conf Monitor

/** * H3.5 — Confidence Monitor: every assistant turn must include conf ∈ [0,1] * (schema-enforced; extract from a tra…

TS108 lines3,011 bytes
loom-sprint-scaffoldtest

Conf Monitor.Test

/** * Tests for conf-monitor (H3.5). * * Proves: * - extractConf finds trailing JSON line `{"conf": 0.8}` in assista…

TS159 lines5,452 bytes
pi-cyberneticsource

Confidence Calibrator

/** P5 — Brier-score confidence calibration over (stated confidence, outcome) pairs. */ import type { Escalation } from…

TS59 lines1,723 bytes
pi-cyberneticsource

Config

/** Harness configuration — one section per loop. */ import type { ToolExecutionMode } from "@earendil-works/pi-agent-c…

TS129 lines4,146 bytes
pi-cyberneticsource

Consolidation

/** * Offline consolidation: Hippocampus -> Neocortex. * * This engine is intentionally not called from transformCont…

TS78 lines2,583 bytes