diff --git a/AGENTS.md b/AGENTS.md index 02a5b39..0404c28 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,7 +4,7 @@ Guidance for agents working in this repository. Prefer the checked-in code and t ## 1. Project -- Published on npm as one package, `serverless-objects` (0.3.x, pre-alpha). It contains the `sobjects` CLI, the native engine, and the `serverless-objects/hotcell` and `serverless-objects/autopilot` modules. There is no `@serverless-objects` npm scope; ship new modules as subpath exports of this package. +- Published on npm as one package, `serverless-objects` (0.13.x, pre-alpha). It contains the `sobjects` CLI, the native engine, and the `serverless-objects/hotcell` and `serverless-objects/autopilot` modules. There is no `@serverless-objects` npm scope; ship new modules as subpath exports of this package. - Two engines: celld (external, pinned 0.6.2) and the native engine (`sobjects dev --engine native`: in-process, trusted code, node:sqlite per object). Conformance: Cloudflare 17/17 (`test:cloudflare`, deploys to the logged-in account and deletes afterwards), Wrangler 4.150.0 16/16, celld 0.6.2 17/17, native 17/17 (hibernation runs everywhere but Wrangler); facets are not covered. - ACME HTTP-01 is verified only against a local Pebble server. Point-in-time restore is not available on celld 0.6. The native engine has bucket backups (`--backup-bucket`; `--backup-mode durable` holds each result until its writes are in the bucket and adds Cloudflare's point-in-time recovery API, back `--backup-retention-days`), several nodes per bucket (`--node-name`, `--peer-listen`), and optional worker threads (`--threads`; fault and CPU isolation, not a security boundary). A `[native]` table in `sobjects.toml` (instead of `[celld]`) makes `sobjects up` run it as `sobjects dev --engine native` in a child process; `[admin]` isn't supported with it yet. Roadmap targets are not guarantees. diff --git a/docs/autopilot.md b/docs/autopilot.md index 56c7df8..9890552 100644 --- a/docs/autopilot.md +++ b/docs/autopilot.md @@ -78,7 +78,7 @@ await env.RUNS.getByName(id).start({ model: "moonshotai/kimi-k2.6", egress: { sp - **Budgets:** a tripped tool, token or cost budget aborts the cell's turn, and the run waits in `needs_input`. The object sees tool calls as the cell reports them, so the call that tripped a budget may already have run. - **Resuming:** `resume(budgets, { message? })` applies the new budgets and starts a follow-up turn in the same cell session, which still has the conversation. It polls from the saved cursor and ignores the aborted turn's late events. It is refused until the cell has finished stopping the previous turn. - **Turn lost:** if the cell reports no active turn and stops producing events, the run fails as `cell_turn_lost`. -- **Options for `start()`:** `model` (OpenRouter id, default `moonshotai/kimi-k2.6`), `packageSpec` (`autopilot-ai@`, default `autopilot-ai@2.8.0`), `image` (default `ghcr.io/sinameraji/hotcell-base:latest`, which has Node 22 and git), and `egress` (a Hotcell egress policy, default a $1 spend cap and 1-hour TTL). CI warns when the default falls more than a minor release behind `autopilot-ai` on npm. +- **Options for `start()`:** `model` (OpenRouter id, default `moonshotai/kimi-k2.6`), `packageSpec` (`autopilot-ai@`, default `autopilot-ai@3.0.2`), `image` (default `ghcr.io/sinameraji/hotcell-base:latest`, which has Node 22 and git), and `egress` (a Hotcell egress policy, default a $1 spend cap and 1-hour TTL). CI fails when the default falls a major release behind `autopilot-ai` on npm, and warns when it falls more than a minor behind. - **Daemon:** set `HOTCELL_ENDPOINT` and `HOTCELL_API_KEY` in the Worker's vars and secrets. - **Other methods:** `cancel()` aborts the turn; `executorState()` returns the step, cell id, cursor and last error. - **Concurrency:** each step runs under a lease, and every executor write checks it, so an overlapping or stale invocation can't advance the run. `npm install` runs in the background in the cell, so no alarm handler waits on it. @@ -163,7 +163,7 @@ The object doesn't check `event_type` against Camouflage's schema. Run `camoufla Unit tests run the SQL against `node:sqlite`. They cover transitions, budgets, hashing, reconcile, leases, retry and backoff, job polling, runtime limits, cursors, and announcing events only after commit. The cell executor is tested against a fake bridge: setup steps, event mapping, resuming after a restart without re-prompting, budget aborts, errors and backoff, failed setup, lost turns, and schema migration. -A real Autopilot run (celld 0.6.2, Hotcell 0.1.19 container driver, `autopilot-ai` 1.25.1, `moonshotai/kimi-k2.6` through the Hotcell gateway) went from provision to completion in about 30 seconds. It wrote the requested file for $0.0084, and `camouflage-validate` accepted all 99 session events. In a second run, the node was stopped for about 45 seconds during a 40-second bash tool call. After `up`, the object resumed from its saved cursor (36 → 48) and the run completed ($0.0114). Its tool intent and result stayed paired, and all 48 session events were valid. A third run with `maxToolIterations: 1` paused at its second tool call. `resume({ maxToolIterations: 5 }, { message })` then finished the task in the same session ($0.0145), and all 33 session events were valid. Those runs used `autopilot-ai` 1.25.1. The default is now 2.8.0, whose bridge protocol (health, session, prompt de-duplication by turn id, event cursor) was checked against its SDK, but the end-to-end and restart runs have not been repeated on it. +A real Autopilot run (celld 0.6.2, Hotcell 0.1.19 container driver, `autopilot-ai` 1.25.1, `moonshotai/kimi-k2.6` through the Hotcell gateway) went from provision to completion in about 30 seconds. It wrote the requested file for $0.0084, and `camouflage-validate` accepted all 99 session events. In a second run, the node was stopped for about 45 seconds during a 40-second bash tool call. After `up`, the object resumed from its saved cursor (36 → 48) and the run completed ($0.0114). Its tool intent and result stayed paired, and all 48 session events were valid. A third run with `maxToolIterations: 1` paused at its second tool call. `resume({ maxToolIterations: 5 }, { message })` then finished the task in the same session ($0.0145), and all 33 session events were valid. Those runs used `autopilot-ai` 1.25.1. The default is now 3.0.2. Its bridge protocol was checked against that version's SDK: `/health`, `/status`, `/events` and `/rpc` are unchanged from 2.8.0, prompt de-duplication is still by turn id, the event cursor still advances the same way, and the `SessionEvent` union the recorder consumes is identical. The only addition is an optional `modelInfo` field on `new_session` and `set_model`, which the executor does not send. The end-to-end and restart runs have not been repeated on 3.0.2. Separately, [`examples/autopilot-runs`](https://github.com/directionally-local/serverless-objects/tree/main/examples/autopilot-runs) was run on celld 0.6.2 through `sobjects deploy`/`up` with a SeaweedFS bucket: - A wake fell due while the node was stopped, and fired after `up`. diff --git a/packages/cli/autopilot/cell-executor.js b/packages/cli/autopilot/cell-executor.js index 15e7f8c..78600ff 100644 --- a/packages/cli/autopilot/cell-executor.js +++ b/packages/cli/autopilot/cell-executor.js @@ -8,7 +8,7 @@ import { redactDeep } from "./redact.js"; import { TurnRecorder, bounded } from "./turn-recorder.js"; export const DEFAULT_MODEL = "moonshotai/kimi-k2.6"; -export const DEFAULT_PACKAGE = "autopilot-ai@2.8.0"; +export const DEFAULT_PACKAGE = "autopilot-ai@3.0.2"; export const DEFAULT_IMAGE = "ghcr.io/sinameraji/hotcell-base:latest"; const CELL_STATE_DIR = "/workspace/.aster"; diff --git a/packages/cli/test/autopilot-default-version.test.js b/packages/cli/test/autopilot-default-version.test.js index ff42077..b1e106f 100644 --- a/packages/cli/test/autopilot-default-version.test.js +++ b/packages/cli/test/autopilot-default-version.test.js @@ -1,28 +1,37 @@ import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import { test } from "node:test"; -import { defaultPackageVersion, isBehind, parseVersion } from "../../../scripts/check-autopilot-default.mjs"; +import { defaultPackageVersion, isBehind, isMajorBehind, parseVersion } from "../../../scripts/check-autopilot-default.mjs"; test("parseVersion reads major, minor and patch", () => { - assert.deepEqual(parseVersion("2.8.0"), { major: 2, minor: 8, patch: 0 }); + assert.deepEqual(parseVersion("3.0.2"), { major: 3, minor: 0, patch: 2 }); assert.deepEqual(parseVersion(" 1.25.1 "), { major: 1, minor: 25, patch: 1 }); assert.throws(() => parseVersion("latest"), /not a version/); }); test("isBehind allows one minor release of lag", () => { - assert.equal(isBehind("2.8.0", "2.8.0"), false); - assert.equal(isBehind("2.7.1", "2.8.0"), false); - assert.equal(isBehind("2.6.0", "2.8.0"), true); - assert.equal(isBehind("1.25.1", "2.8.0"), true); + assert.equal(isBehind("3.0.2", "3.0.2"), false); + assert.equal(isBehind("2.9.1", "3.0.0"), true); + assert.equal(isBehind("3.0.0", "3.1.0"), false); + assert.equal(isBehind("3.0.0", "3.2.0"), true); + assert.equal(isBehind("1.25.1", "3.0.0"), true); }); test("isBehind treats a default ahead of npm as current", () => { - assert.equal(isBehind("2.9.0", "2.8.0"), false); - assert.equal(isBehind("3.0.0", "2.8.0"), false); + assert.equal(isBehind("3.1.0", "3.0.2"), false); + assert.equal(isBehind("4.0.0", "3.0.2"), false); +}); + +test("isMajorBehind fails only when npm has a newer major", () => { + assert.equal(isMajorBehind("3.0.2", "3.0.2"), false); + assert.equal(isMajorBehind("3.0.0", "3.4.0"), false); + assert.equal(isMajorBehind("2.8.0", "3.0.2"), true); + assert.equal(isMajorBehind("3.0.2", "4.0.0"), true); + assert.equal(isMajorBehind("4.0.0", "3.0.2"), false); }); test("defaultPackageVersion reads the executor's default", async () => { - assert.equal(defaultPackageVersion('export const DEFAULT_PACKAGE = "autopilot-ai@2.8.0";'), "2.8.0"); + assert.equal(defaultPackageVersion('export const DEFAULT_PACKAGE = "autopilot-ai@3.0.2";'), "3.0.2"); assert.throws(() => defaultPackageVersion("export const DEFAULT_PACKAGE = 1;"), /DEFAULT_PACKAGE/); const source = await readFile(new URL("../autopilot/cell-executor.js", import.meta.url), "utf8"); assert.match(defaultPackageVersion(source), /^\d+\.\d+\.\d+$/); diff --git a/scripts/check-autopilot-default.mjs b/scripts/check-autopilot-default.mjs index 16bce48..59c0d41 100644 --- a/scripts/check-autopilot-default.mjs +++ b/scripts/check-autopilot-default.mjs @@ -1,6 +1,7 @@ -// Warns when the autopilot-ai version the cell executor installs by default -// falls more than a minor release behind the latest on npm. CI runs this on -// every push and pull request; it warns instead of failing, because a new +// Checks the autopilot-ai version the cell executor installs by default against +// the latest on npm. CI runs this on every push and pull request. A default a +// major release behind fails the build, because the bridge protocol may have +// changed; a default more than a minor behind only warns, because a new // Autopilot release should not break an unrelated change. import { readFile } from "node:fs/promises"; import { pathToFileURL } from "node:url"; @@ -14,6 +15,12 @@ export function parseVersion(version) { return { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]) }; } +// A newer major on npm means the bridge protocol may have changed, so the +// default must be re-checked rather than left to drift. +export function isMajorBehind(defaultVersion, latestVersion) { + return parseVersion(latestVersion).major > parseVersion(defaultVersion).major; +} + // "More than a minor behind" means a newer major, or two or more minors within // the same major. A default ahead of npm (an unreleased pin) is not behind. export function isBehind(defaultVersion, latestVersion) { @@ -40,6 +47,11 @@ async function main() { console.log(`::warning::could not read the latest autopilot-ai version (${error.message}); the default is ${pinned}`); return; } + if (isMajorBehind(pinned, latest)) { + console.log(`::error::AutopilotCellRun installs autopilot-ai@${pinned} by default, but ${latest} is on npm. Bump DEFAULT_PACKAGE in packages/cli/autopilot/cell-executor.js and re-check the bridge protocol against the new major.`); + process.exitCode = 1; + return; + } if (isBehind(pinned, latest)) { console.log(`::warning::AutopilotCellRun installs autopilot-ai@${pinned} by default, but ${latest} is on npm. Bump DEFAULT_PACKAGE in packages/cli/autopilot/cell-executor.js and re-check the bridge protocol.`); return;