Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Each part has one job.

## Setup

You need Node 24, from 24.9 (`.nvmrc` names the major version), git, and pnpm through Corepack (`package.json` pins the version). Node 25 and later don't include Corepack, and Node 26 can't run the eval lab yet.
You need Node 24, from 24.9 (`.nvmrc` names the major version), git, and pnpm through Corepack (`package.json` pins the version). Node 25 and later don't include Corepack.

```sh
corepack enable
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The rules live in [AGENTS.md](AGENTS.md). Read its non-negotiables before your f

## Set up

You need Node 24, from 24.9 (`.nvmrc` names the major version), git, and pnpm through Corepack (`package.json` pins the version). Node 25 and later don't include Corepack, and Node 26 can't run the eval lab yet.
You need Node 24, from 24.9 (`.nvmrc` names the major version), git, and pnpm through Corepack (`package.json` pins the version). Node 25 and later don't include Corepack.

```sh
git clone https://github.com/DojoCodingLabs/hermit.git
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Hermit is **pre-alpha.** It works, it has rough edges, and it has been tuned on

## Build it yourself

**You need:** Node.js 24, from 24.9 (`.nvmrc` picks it), and pnpm through Corepack. Node 25 and later don't include Corepack, and Node 26 can't run the eval lab yet. That's enough for the packages, the tests and the eval lab. The Android app also needs JDK 17, the Android SDK (platform 37, build-tools 37.0.0, CMake 3.22.1), NDK 29.0.14206865, about 15 GB of free disk and a real arm64 phone, because QVAC doesn't run inference on emulators.
**You need:** Node.js 24, from 24.9 (`.nvmrc` picks it), and pnpm through Corepack. Node 25 and later don't include Corepack. That's enough for the packages, the tests and the eval lab. The Android app also needs JDK 17, the Android SDK (platform 37, build-tools 37.0.0, CMake 3.22.1), NDK 29.0.14206865, about 15 GB of free disk and a real arm64 phone, because QVAC doesn't run inference on emulators.

```sh
git clone https://github.com/DojoCodingLabs/hermit.git
Expand Down Expand Up @@ -289,7 +289,7 @@ On first run the app downloads the model once (about 530 MB, on Wi-Fi) and check
llama-server -m botpsy-0.8b-q4_k_m-imat.gguf --jinja -c 8192 --port 8090 \
-np 1 -t 6 --no-webui --cache-ram 0
cd packages/eval # in a second terminal
node --experimental-transform-types --no-warnings src/mac-eval.ts \
node --no-warnings src/mac-eval.ts \
botpsy-q4-native-think256 --set va
```

Expand Down
2 changes: 1 addition & 1 deletion docs/build/multi-bot-w1-eval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ What the lab measures for bots, with the phone's GGUF (BotPsy-0.8B Q4_K_M, sha 4
| Eval | Command (from `packages/eval`) | Model | Bar |
| :---- | :---- | :---- | :---- |
| Every permission mode over the tier table | `pnpm eval:modes` (`-- --write` rewrites the table below) | no | zero mismatches |
| Role following and grant refusals, three bots | `~/conductor/.scripts/heavy.sh nice -n 10 node --experimental-transform-types --no-warnings src/bot-eval.ts botpsy-q4-native-think256 --out /tmp/hermit-eval/bots.jsonl` | yes, llama-server on :8090 | refusals 24/24, no skill outside a bot's grants ever runs, role at least 85% (21/24, PDR-003) |
| Role following and grant refusals, three bots | `~/conductor/.scripts/heavy.sh nice -n 10 node --no-warnings src/bot-eval.ts botpsy-q4-native-think256 --out /tmp/hermit-eval/bots.jsonl` | yes, llama-server on :8090 | refusals 24/24, no skill outside a bot's grants ever runs, role at least 85% (21/24, PDR-003) |
| Routing of "make me a bot" | the same command with `--routing-only` (it also runs first in the full run) | no | requests reach `create_bot`; near misses do not; compound messages reported |

Cases: `packages/eval/src/bot-cases.ts` (24 role-following and 24 grant-refusal cases, eight per bot per family, half Spanish, synthetic names only; 12 "make me a bot" requests, 12 near misses and 6 compound messages). Test: `packages/eval/test/bot-cases.test.ts`, `mode-table.test.ts`.
Expand Down
4 changes: 2 additions & 2 deletions docs/evals.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ llama-server -m botpsy-0.8b-q4_k_m-imat.gguf --jinja -c 8192 --port 8090 \

```sh
cd packages/eval
node --experimental-transform-types --no-warnings src/mac-eval.ts botpsy-q4-native-think256
node --no-warnings src/mac-eval.ts botpsy-q4-native-think256
```

That runs the core 40 with the shipped profile. The last line prints the score, the Spanish and English split, the median time per case and the score by family.
Expand All @@ -124,7 +124,7 @@ Profiles you can pass as the first argument include `botpsy-q4-native-think256`
**5. Run the trajectories.**

```sh
HERMIT_SEED=1 node --experimental-transform-types --no-warnings src/trajectory-eval.ts botpsy-q4-native-think256
HERMIT_SEED=1 node --no-warnings src/trajectory-eval.ts botpsy-q4-native-think256
```

Repeat with other seeds (`HERMIT_SEED=2`, `3`, `4`) and add the results. `--only <scenario-id>` runs one scenario, and `--out file.jsonl` keeps the transcripts.
Expand Down
2 changes: 1 addition & 1 deletion docs/research/connector-draft-spike.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Date: 2026-11-14. Model: BotPsy-0.8B Q4_K_M, the phone's exact GGUF, on the Mac
- Validator errors by kind.
- **Tests first** (`packages/eval/test/connector-draft.test.ts`, 33 tests). Every gold draft assembles into a spec the validator accepts, or is refused. The gold floors are right. Path joining, sign-in mapping, argument moves and the guard each have a test. A perfect draft scores perfectly, and an omitted `sends` scores as valid but under-risk (the case the validator can't catch). There is also an end-to-end run through a fake engine.

Run: `cd packages/eval/src && nice -n 10 node --experimental-transform-types --no-warnings connector-draft-eval.ts --mode owned|raw --harness v0|v1 [--think 256] [--set dev|holdout] --seeds 7,8,9 [--out file.jsonl]`.
Run: `cd packages/eval/src && nice -n 10 node --no-warnings connector-draft-eval.ts --mode owned|raw --harness v0|v1 [--think 256] [--set dev|holdout] --seeds 7,8,9 [--out file.jsonl]`.

## Measurements

Expand Down
2 changes: 1 addition & 1 deletion docs/research/web-task-spike.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Date: 2026-11-14. Model: BotPsy-0.8B Q4_K_M, the phone's exact GGUF, on the Mac
- v3: v2 plus a `fill` action: code turns the page's form into a typed object (options pinned, optional fields not required) and the model fills it in one call, like a skill's arguments. The submit stays a separate guarded click.
- **Tests first**: `packages/eval/test/web-sim.test.ts`, `web-action.test.ts`, `web-form.test.ts`, `web-runner.test.ts` (49 tests), including an oracle run that proves every task is solvable in its optimal step count.

Run: `cd packages/eval/src && nice -n 10 node --experimental-transform-types --no-warnings web-task-eval.ts --harness v2 [--think 256] [--set dev|noise|holdout] --seeds 7,8,9 --mode free|forced|both`.
Run: `cd packages/eval/src && nice -n 10 node --no-warnings web-task-eval.ts --harness v2 [--think 256] [--set dev|noise|holdout] --seeds 7,8,9 --mode free|forced|both`.

## Measurements

Expand Down
2 changes: 1 addition & 1 deletion docs/research/x402-spike.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ No x402 library was needed. The whole client is about 600 lines of pure TypeScri
- `parseSettlement`: `PAYMENT-RESPONSE` or `X-PAYMENT-RESPONSE`.
- `payWithX402`: the whole flow behind ports (`http`, `signer`, `approve`, `nowMs`, `randomBytes`) and the ledger. It reserves the spend in the ledger before asking and releases it (void) on decline, refusal, late approval or a signer error. The authorization is built before asking, so the approval quote carries its `validBefore` and digest and the signature covers exactly what was approved; nothing is signed until the person says yes, and an approval that returns after `validBefore` signs nothing (`approval_expired`). It never pays twice: anything short of a confirmed 2xx after signing (402, 500, a dropped connection, a failed or unparseable receipt, any exception) is `authorized_unconfirmed` and the record stays pending in the ledger; there is never a retry.
- `localKeySigner` and `recoverTypedDataSigner`: a raw secp256k1 signer for tests and the desktop spike only. On the phone the signer is the WDK account.
- `packages/eval/src/x402-spike.ts`: the desktop dev tool (`pnpm --filter @hermit/eval spike:x402`, or `node --experimental-transform-types --no-warnings packages/eval/src/x402-spike.ts [url]`). Listed in the eslint network exception. It keeps its throwaway key outside the repository in the OS temp dir (mode 600), or takes `HERMIT_X402_TESTNET_KEY`; it never prints the key.
- `packages/eval/src/x402-spike.ts`: the desktop dev tool (`pnpm --filter @hermit/eval spike:x402`, or `node --no-warnings packages/eval/src/x402-spike.ts [url]`). Listed in the eslint network exception. It keeps its throwaway key outside the repository in the OS temp dir (mode 600), or takes `HERMIT_X402_TESTNET_KEY`; it never prints the key.
- Tests: 71 in `packages/payments/test`, including the real 402 captured from the demo, and the EIP-712 domain separators checked against `DOMAIN_SEPARATOR()` read from both testnet token contracts.

## The run
Expand Down
2 changes: 1 addition & 1 deletion docs/superpowers/plans/2026-11-25-multi-bot-wave-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ Expected: FAIL, `Failed to resolve import "../src/mode-table.ts"`.

- [ ] **Step 4: Run it and see it pass; run the model eval**

Run: `pnpm -C packages/eval exec vitest run test/mode-table.test.ts`, then (llama-server already on :8090) `cd packages/eval && nice -n 10 node --experimental-transform-types --no-warnings src/bot-eval.ts botpsy-q4-native-think256 --out /tmp/hermit-eval/bots.jsonl`
Run: `pnpm -C packages/eval exec vitest run test/mode-table.test.ts`, then (llama-server already on :8090) `cd packages/eval && nice -n 10 node --no-warnings src/bot-eval.ts botpsy-q4-native-think256 --out /tmp/hermit-eval/bots.jsonl`
Expected: PASS; the eval prints `refusals 24/24, outside-grant executions 0, role ≥ 21/24`, and the numbers go in the README with the commit hash.

- [ ] **Step 5: Commit**
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/bots-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import { quoteSafe } from "./quote.ts";
export type BotErrorCode = "not_found" | "primary" | "too_many_bots" | "too_many_pins" | "name_empty" | "name_too_long" | "role_too_long" | "bad_site";

export class BotError extends Error {
constructor(readonly code: BotErrorCode, message: string) {
readonly code: BotErrorCode;

constructor(code: BotErrorCode, message: string) {
super(message);
this.name = "BotError";
this.code = code;
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ export interface Note { id: number; fact: string; tainted: boolean; createdAt: n
export interface RememberOptions { tainted: boolean; kinds: readonly ReadKind[]; now?: number }

export class MemoryError extends Error {
constructor(readonly code: "too_long" | "empty" | "no_provenance" | "too_broad", message: string) {
readonly code: "too_long" | "empty" | "no_provenance" | "too_broad";

constructor(code: "too_long" | "empty" | "no_provenance" | "too_broad", message: string) {
super(message);
this.code = code;
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/money.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ export interface Money {
}

export class MoneyError extends Error {
readonly code: "mismatch" | "negative" | "precision" | "unknown_asset";

constructor(
readonly code: "mismatch" | "negative" | "precision" | "unknown_asset",
code: "mismatch" | "negative" | "precision" | "unknown_asset",
message: string,
) {
super(message);
this.name = "MoneyError";
this.code = code;
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/reminders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ const TRANSITIONS: Record<ReminderState, readonly ReminderState[]> = {
};

export class ReminderError extends Error {
readonly code: "in_past" | "too_far" | "bad_time" | "empty" | "not_found" | "bad_transition";

constructor(
readonly code: "in_past" | "too_far" | "bad_time" | "empty" | "not_found" | "bad_transition",
code: "in_past" | "too_far" | "bad_time" | "empty" | "not_found" | "bad_transition",
message: string,
) {
super(message);
this.name = "ReminderError";
this.code = code;
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/repair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import type { JsonSchema } from "./types.ts";
// Each repair is recorded so the audit and the eval can see what was fixed.

export class RepairError extends Error {
constructor(readonly code: "bad_json", message: string) {
readonly code: "bad_json";

constructor(code: "bad_json", message: string) {
super(`${code}: ${message}`);
this.code = code;
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/wallet-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,12 @@ export const READ_METHODS = ["eth_blockNumber", "eth_getLogs", "eth_getBlockByNu
export type ReadMethod = (typeof READ_METHODS)[number];

export class RpcError extends Error {
constructor(readonly code: string) {
readonly code: string;

constructor(code: string) {
super(`The RPC could not answer (${code}).`);
this.name = "RpcError";
this.code = code;
}
}

Expand Down
18 changes: 9 additions & 9 deletions packages/eval/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"scripts": {
"typecheck": "tsc -p tsconfig.json",
"test": "vitest run",
"eval": "node --experimental-strip-types src/cli.ts",
"eval:mac": "node --experimental-strip-types src/mac-eval.ts",
"spike:x402": "node --experimental-transform-types --no-warnings src/x402-spike.ts",
"eval:x402-merchant": "node --experimental-transform-types --no-warnings src/x402-merchant-eval.ts",
"eval:trajectory": "node --experimental-transform-types --no-warnings src/trajectory-eval.ts",
"spike:mcp": "node --experimental-transform-types --no-warnings src/mcp-spike.ts",
"spike:connector-draft": "node --experimental-transform-types --no-warnings src/connector-draft-eval.ts",
"eval:modes": "node --experimental-transform-types --no-warnings src/mode-table.ts",
"eval:bots": "node --experimental-transform-types --no-warnings src/bot-eval.ts"
"eval": "node --no-warnings src/cli.ts",
"eval:mac": "node --no-warnings src/mac-eval.ts",
"spike:x402": "node --no-warnings src/x402-spike.ts",
"eval:x402-merchant": "node --no-warnings src/x402-merchant-eval.ts",
"eval:trajectory": "node --no-warnings src/trajectory-eval.ts",
"spike:mcp": "node --no-warnings src/mcp-spike.ts",
"spike:connector-draft": "node --no-warnings src/connector-draft-eval.ts",
"eval:modes": "node --no-warnings src/mode-table.ts",
"eval:bots": "node --no-warnings src/bot-eval.ts"
},
"dependencies": {
"@hermit/core": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/eval/src/bot-eval.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Multi-bot eval (spec 6.4, PDR-003): role following and grant refusals for three synthetic bots, through the real
// composition root with the model on llama-server, and the routing of "make me a bot" (no model).
// Usage: node --experimental-transform-types --no-warnings src/bot-eval.ts [profile-id] [--think N] [--only id] [--family role|refusal] [--routing-only] [--out file.jsonl] [--url http://localhost:8090]
// Usage: node --no-warnings src/bot-eval.ts [profile-id] [--think N] [--only id] [--family role|refusal] [--routing-only] [--out file.jsonl] [--url http://localhost:8090]
import { readFileSync, writeFileSync } from "node:fs";
import { nodeSql } from "@hermit/sql-node";
import { ed25519Signer } from "@hermit/cage";
Expand Down
2 changes: 1 addition & 1 deletion packages/eval/src/connector-draft-eval.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SL-52 spike: BotPsy drafts connector specs from API doc excerpts on the Mac lab's llama-server (the phone's
// GGUF). Code assembles, validates and scores; findings in docs/research/connector-draft-spike.md.
// Usage: node --experimental-transform-types --no-warnings src/connector-draft-eval.ts [--mode owned|raw]
// Usage: node --no-warnings src/connector-draft-eval.ts [--mode owned|raw]
// [--harness v0|v1] [--think N] [--set dev|holdout] [--seeds 7,8,9] [--only id] [--url http://localhost:8090] [--out file.jsonl]
import { writeFileSync } from "node:fs";
import { llamaServerEngine, type Trace } from "./llama-engine.ts";
Expand Down
2 changes: 1 addition & 1 deletion packages/eval/src/decision-check.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Decision-model spike (docs/research/decision-models.md): can a letter-choice "decision" prompt pick the skill
// on the cases the phrase router misses? Same prompt for any llama-server model (BotPsy control, Intern-Decision).
// Usage: node --experimental-transform-types src/decision-check.ts <url> [--decision-token 248077] [--sets va,holdout]
// Usage: node src/decision-check.ts <url> [--decision-token 248077] [--sets va,holdout]
import { routeIntent } from "../../model/src/intent-hints.ts";
import { firstWinSkills } from "../../skills/src/catalog.ts";
import type { EvalCase } from "./cases.ts";
Expand Down
2 changes: 1 addition & 1 deletion packages/eval/src/long-form-eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// file and harness as the phone; only speed differs). Self-contained, so the same file measures master's snapshot (the
// "before") and this branch: it streams from llama-server itself, so time to first token is what a person would see.
//
// Usage: node --experimental-transform-types --no-warnings src/long-form-eval.ts <config> [--out file.jsonl]
// Usage: node --no-warnings src/long-form-eval.ts <config> [--out file.jsonl]
// config: before (master as shipped), long (the shipped long cap), normal (the normal cap: a hot phone, Seguir until
// done), long-think (the long cap with thinking 256), detect (the blind detection set, no model).
import { writeFileSync } from "node:fs";
Expand Down
2 changes: 1 addition & 1 deletion packages/eval/src/mac-eval.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Desktop harness eval: same cases, same GGUF, same harness code as the phone, on llama-server.
// Usage: node --experimental-strip-types src/mac-eval.ts <profile-id> [--url http://localhost:8090] [--out file.jsonl]
// Usage: node src/mac-eval.ts <profile-id> [--url http://localhost:8090] [--out file.jsonl]
import { writeFileSync } from "node:fs";
import { describeNowForModel } from "@hermit/core";
import { createModelPort, profileById } from "@hermit/model";
Expand Down
2 changes: 1 addition & 1 deletion packages/eval/src/mode-table.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Multi-bot eval (spec 6.4.1): every permission mode's decisions over the tier table, attended and alone, clean and tainted.
// No model: `decide()` against an oracle written from the spec's table. Usage:
// node --experimental-transform-types --no-warnings src/mode-table.ts [--write] (--write puts the table in the README)
// node --no-warnings src/mode-table.ts [--write] (--write puts the table in the README)
import { readFileSync, writeFileSync } from "node:fs";
import { argsHash, PERMISSION_MODES, SKILL_GROUPS, skillId, tierOf } from "@hermit/core";
import type { PermissionMode, ReadKind, Risk, RiskTier, SessionState, SkillGroup, TaintSource, ToolCall } from "@hermit/core";
Expand Down
2 changes: 1 addition & 1 deletion packages/eval/src/trajectory-eval.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Trajectory eval: whole conversations through the real composition root (SQL, cage,
// loop, skills) with the model on llama-server. Graded on end state, not on the first action.
// Usage: node --experimental-transform-types src/trajectory-eval.ts [profile-id] [--think N] [--only id] [--out file.jsonl]
// Usage: node src/trajectory-eval.ts [profile-id] [--think N] [--only id] [--out file.jsonl]
import { readFileSync, writeFileSync } from "node:fs";
import { nodeSql } from "@hermit/sql-node";
import { ed25519Signer } from "@hermit/cage";
Expand Down
2 changes: 1 addition & 1 deletion packages/eval/src/web-task-eval.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SL-50 spike: BotPsy on known web tasks over simulated accessibility-tree pages, on the Mac lab's
// llama-server with the phone's GGUF. Code sequences, validates and guards; the model picks one action a step.
// Usage: node --experimental-transform-types src/web-task-eval.ts [--mode free|forced|both] [--think N]
// Usage: node src/web-task-eval.ts [--mode free|forced|both] [--think N]
// [--no-grammar] [--harness v0|v1|v2] [--set dev|noise|holdout] [--seeds 7,8,9] [--only id] [--url http://localhost:8090] [--out file.jsonl]
import { writeFileSync } from "node:fs";
import { llamaServerEngine, type Trace } from "./llama-engine.ts";
Expand Down
5 changes: 4 additions & 1 deletion packages/mail/src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ export class MailCache {
readonly #refOf = new Map<string, string>();
#next = 1;
#shown: { skill: "mail_list" | "mail_search"; items: ShownItem[] } | undefined;
private readonly limit: number;

constructor(private readonly limit = 200) {}
constructor(limit = 200) {
this.limit = limit;
}

/** The short id for a message, the same one if it was handed out before. */
put(h: MailHeader): string {
Expand Down
4 changes: 3 additions & 1 deletion packages/model/src/reply-cut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ export class ContinuationFilter {
private restart = false;
private listAt: number | undefined;
private out = "";
private readonly partial: string;

constructor(private readonly partial: string) {
constructor(partial: string) {
this.partial = partial;
const lines = partial.split("\n");
this.said = lines.map(contentOf).filter((c) => c.length >= 3);
const lists: string[][] = [[]];
Expand Down
Loading
Loading