Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
docs(agent-protocol-sdk): strip banned dash glyphs after verified-shippable audit (build, tests, quickstart all green)
nirholas887121b8ce19
diff --git a/agent-protocol-sdk/README.md b/agent-protocol-sdk/README.mdindex 4801478b4..35619822e 100644--- a/agent-protocol-sdk/README.md+++ b/agent-protocol-sdk/README.md@@ -66,8 +66,8 @@ const signature = await invokeSkill({connection,invokerAuthority, // signs + paystargetAuthority, // target agent PDA is derived from this- skillName: 'summarize', // 1–64 bytes- parameters: JSON.stringify({ url: 'https://example.com' }), // ≤512 bytes+ skillName: 'summarize', // 1-64 bytes+ parameters: JSON.stringify({ url: 'https://example.com' }), // <=512 bytes// programId is optional; it defaults to AGENT_INVOCATION_PROGRAM_ID.});@@ -90,12 +90,12 @@ transaction signature.| `connection` | `Connection` | Live Solana connection used to build and send the tx. || `invokerAuthority` | `Keypair` | Owns the invoking agent. Signs and pays. || `targetAuthority` | `PublicKey` | Owns the target agent; its PDA is re-derived from this. |-| `skillName` | `string` | Skill identifier, 1–64 bytes (UTF-8). |-| `parameters` | `string` | Opaque parameter blob, ≤512 bytes (typically JSON). |+| `skillName` | `string` | Skill identifier, 1-64 bytes (UTF-8). |+| `parameters` | `string` | Opaque parameter blob, max 512 bytes (typically JSON). || `programId` | `PublicKey` *(optional)* | Override the program id. Required on any live cluster. |Throws if `skillName` is empty, `skillName` exceeds `MAX_SKILL_NAME_LEN` bytes,-or `parameters` exceeds `MAX_PARAMETERS_LEN` bytes — so you get a clear local+or `parameters` exceeds `MAX_PARAMETERS_LEN` bytes, so you get a clear localerror instead of a failed on-chain simulation.### `deriveAgentPda(authority, programId?): [PublicKey, number]`@@ -115,8 +115,8 @@ const [agentPda, bump] = deriveAgentPda(authority, programId);| Export | Type | Value / meaning || --- | --- | --- |-| `MAX_SKILL_NAME_LEN` | `number` | `64` — max `skillName` length in bytes. |-| `MAX_PARAMETERS_LEN` | `number` | `512` — max `parameters` length in bytes. |+| `MAX_SKILL_NAME_LEN` | `number` | `64`, max `skillName` length in bytes. |+| `MAX_PARAMETERS_LEN` | `number` | `512`, max `parameters` length in bytes. || `AGENT_INVOCATION_PROGRAM_ID` | `string` | The program's `declare_id!` (`AgEnt…Zfo`), same on every cluster. || `IDL` | Anchor `Idl` | The `agent_invocation` IDL (Anchor 0.30+ format). || `AgentInvocation` | `type` | TypeScript type of `IDL` for `new Program<AgentInvocation>(...)`. |@@ -147,13 +147,13 @@ validation above.- Homepage: https://three.ws- Changelog: https://three.ws/changelog- Issues: https://github.com/nirholas/three.ws/issues-- License: Apache-2.0 — see [LICENSE](./LICENSE)+- License: Apache-2.0, see [LICENSE](./LICENSE)---<p align="center"><sub>- Part of the <a href="https://three.ws">three.ws</a> SDK suite — 3D AI agents, on-chain identity, and agent payments.<br/>+ Part of the <a href="https://three.ws">three.ws</a> SDK suite: 3D AI agents, on-chain identity, and agent payments.<br/><a href="https://three.ws">Website</a> · <a href="https://three.ws/changelog">Changelog</a> · <a href="https://github.com/nirholas/three.ws">GitHub</a></sub></p>diff --git a/agent-protocol-sdk/src/index.ts b/agent-protocol-sdk/src/index.tsindex 2f0ea144a..599a176e0 100644--- a/agent-protocol-sdk/src/index.ts+++ b/agent-protocol-sdk/src/index.ts@@ -37,7 +37,7 @@ export interface InvokeSkillParams {invokerAuthority: Keypair;/** Authority that owns the target agent (its agent PDA is re-derived from this). */targetAuthority: PublicKey;- /** Skill identifier to invoke (1–64 bytes). */+ /** Skill identifier to invoke (1-64 bytes). */skillName: string;/** Opaque parameter blob passed to the skill (≤512 bytes), typically JSON. */parameters: string;@@ -78,7 +78,7 @@ export async function invokeSkill({commitment: 'confirmed',});// Anchor 0.30+ camelCases the IDL at runtime (methods.invokeSkill), while our- // hand-maintained IDL literal keeps the on-chain snake_case names — so type+ // hand-maintained IDL literal keeps the on-chain snake_case names, so type// the program against the generic Idl rather than the raw literal type.const idl = { ...IDL, address: programId.toBase58() } as unknown as Idl;const program = new Program(idl, provider);diff --git a/agent-protocol-sdk/test/sdk.test.js b/agent-protocol-sdk/test/sdk.test.jsindex 6f8a8dec9..6087a8346 100644--- a/agent-protocol-sdk/test/sdk.test.js+++ b/agent-protocol-sdk/test/sdk.test.js@@ -69,7 +69,7 @@ test('deriveAgentPda honors a custom programId (e.g. a devnet deployment)', () =});// invokeSkill validates inputs before constructing the provider/transaction, so-// these rejections never touch the network — the stub connection proves it.+// these rejections never touch the network; the stub connection proves it.const STUB_CONNECTION = {};function baseParams(overrides) {diff --git a/node-operator/package-lock.json b/node-operator/package-lock.jsonnew file mode 100644index 000000000..3c5715cd3--- /dev/null+++ b/node-operator/package-lock.json@@ -0,0 +1,276 @@+{+ "name": "@three-ws/node-operator",+ "version": "1.0.0",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "@three-ws/node-operator",+ "version": "1.0.0",+ "dependencies": {+ "@noble/curves": "^1.9.0 || ^2.2.0",+ "bs58": "^6.0.0",+ "onnxruntime-node": "^1.20.0"+ },+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/@noble/curves": {+ "version": "2.3.0",+ "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-2.3.0.tgz",+ "integrity": "sha512-v7cY+4oWYPQszRj6ZFGzTVL7uP2TaLo1xMhWHzYC5wj0ZhOXQ5x+sBre8rF3hi8cAoi0bh1qXoovoOkdFtvqEg==",+ "license": "MIT",+ "dependencies": {+ "@noble/hashes": "2.3.0"+ },+ "engines": {+ "node": ">= 20.19.0"+ },+ "funding": {+ "url": "https://paulmillr.com/funding/"+ }+ },+ "node_modules/@noble/hashes": {+ "version": "2.3.0",+ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.3.0.tgz",+ "integrity": "sha512-oN+QwyX7VSHotibwubG3kpzbwKrfnyR6OOO+3Nk/53ADL7FmgHHz4TgrbaYKvvOw09u6QTx0oiH1cNCIOuN0CQ==",+ "license": "MIT",+ "engines": {+ "node": ">= 20.19.0"+ },+ "funding": {+ "url": "https://paulmillr.com/funding/"+ }+ },+ "node_modules/adm-zip": {+ "version": "0.5.18",+ "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.18.tgz",+ "integrity": "sha512-ufJnssQGbxzLNS1Ho9bCtX4rQKCCvoVuDLHoJyc3F9dOGDB4BkWs2Ci0kv53lqocAEQ/Cbi+I2XCsNYGqVYqng==",+ "license": "MIT",+ "engines": {+ "node": ">=12.0"+ }+ },+ "node_modules/base-x": {+ "version": "5.0.1",+ "resolved": "https://registry.npmjs.org/base-x/-/base-x-5.0.1.tgz",+ "integrity": "sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg==",+ "license": "MIT"+ },+ "node_modules/bs58": {+ "version": "6.0.0",+ "resolved": "https://registry.npmjs.org/bs58/-/bs58-6.0.0.tgz",+ "integrity": "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw==",+ "license": "MIT",+ "dependencies": {+ "base-x": "^5.0.0"+ }+ },+ "node_modules/define-data-property": {+ "version": "1.1.4",+ "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",+ "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",+ "license": "MIT",+ "dependencies": {+ "es-define-property": "^1.0.0",+ "es-errors": "^1.3.0",+ "gopd": "^1.0.1"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/define-properties": {+ "version": "1.2.1",+ "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz",+ "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==",+ "license": "MIT",+ "dependencies": {+ "define-data-property": "^1.0.1",+ "has-property-descriptors": "^1.0.0",+ "object-keys": "^1.1.1"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/es-define-property": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/es-errors": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/escape-string-regexp": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",+ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",+ "license": "MIT",+ "engines": {+ "node": ">=10"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/global-agent": {+ "version": "4.1.3",+ "resolved": "https://registry.npmjs.org/global-agent/-/global-agent-4.1.3.tgz",+ "integrity": "sha512-KUJEViiuFT3I97t+GYMikLPJS2Lfo/S2F+DQuBWzuzaMPnvt5yyZePzArx36fBzpGTxZjIpDbXLeySLgh+k76g==",+ "license": "BSD-3-Clause",+ "dependencies": {+ "globalthis": "^1.0.2",+ "matcher": "^4.0.0",+ "semver": "^7.3.5",+ "serialize-error": "^8.1.0"+ },+ "engines": {+ "node": ">=10.0"+ }+ },+ "node_modules/globalthis": {+ "version": "1.0.4",+ "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz",+ "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==",+ "license": "MIT",+ "dependencies": {+ "define-properties": "^1.2.1",+ "gopd": "^1.0.1"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/gopd": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/has-property-descriptors": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",+ "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",+ "license": "MIT",+ "dependencies": {+ "es-define-property": "^1.0.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/matcher": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/matcher/-/matcher-4.0.0.tgz",+ "integrity": "sha512-S6x5wmcDmsDRRU/c2dkccDwQPXoFczc5+HpQ2lON8pnvHlnvHAHj5WlLVvw6n6vNyHuVugYrFohYxbS+pvFpKQ==",+ "license": "MIT",+ "dependencies": {+ "escape-string-regexp": "^4.0.0"+ },+ "engines": {+ "node": ">=10"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/object-keys": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",+ "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/onnxruntime-common": {+ "version": "1.27.0",+ "resolved": "https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.27.0.tgz",+ "integrity": "sha512-3KxL5wIVqa8Ex08jxSzncm9CMgw8CjOFyOQ7SxvG9o0cVLlhTNKXyIQuTbtX4tGPJEf73OER2xrjt4HJSBL4ow==",+ "license": "MIT"+ },+ "node_modules/onnxruntime-node": {+ "version": "1.27.0",+ "resolved": "https://registry.npmjs.org/onnxruntime-node/-/onnxruntime-node-1.27.0.tgz",+ "integrity": "sha512-QEzGwrvNBgv4uPVdnbHsOGG4G6T96mdlcFI8aAKPjMU8wOPpVocPXb6k3QGkaZagVTv2G9Bnnbo6Z3JdXr1fQw==",+ "hasInstallScript": true,+ "license": "MIT",+ "os": [+ "win32",+ "darwin",+ "linux"+ ],+ "dependencies": {+ "adm-zip": "^0.5.16",+ "global-agent": "^4.1.3",+ "onnxruntime-common": "1.27.0"+ }+ },+ "node_modules/semver": {+ "version": "7.8.5",+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",+ "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",+ "license": "ISC",+ "bin": {+ "semver": "bin/semver.js"+ },+ "engines": {+ "node": ">=10"+ }+ },+ "node_modules/serialize-error": {+ "version": "8.1.0",+ "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-8.1.0.tgz",+ "integrity": "sha512-3NnuWfM6vBYoy5gZFvHiYsVbafvI9vZv/+jlIigFn4oP4zjNPK3LhcY0xSCgeb1a5L8jO71Mit9LlNoi2UfDDQ==",+ "license": "MIT",+ "dependencies": {+ "type-fest": "^0.20.2"+ },+ "engines": {+ "node": ">=10"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/type-fest": {+ "version": "0.20.2",+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",+ "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",+ "license": "(MIT OR CC0-1.0)",+ "engines": {+ "node": ">=10"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ }+ }+}diff --git a/node-operator/package.json b/node-operator/package.jsonnew file mode 100644index 000000000..ddd03bb1a--- /dev/null+++ b/node-operator/package.json@@ -0,0 +1,22 @@+{+ "name": "@three-ws/node-operator",+ "version": "1.0.0",+ "description": "three.ws open inference network node operator client: register, claim jobs, run real inference, return signed results.",+ "type": "module",+ "private": true,+ "main": "src/identity.js",+ "scripts": {+ "start": "node src/cli.js run",+ "generate-key": "node src/cli.js generate-key",+ "register": "node src/cli.js register",+ "verify": "node src/cli.js verify"+ },+ "engines": {+ "node": ">=20"+ },+ "dependencies": {+ "@noble/curves": "^1.9.0 || ^2.2.0",+ "bs58": "^6.0.0",+ "onnxruntime-node": "^1.20.0"+ }+}diff --git a/node-operator/src/codec.js b/node-operator/src/codec.jsnew file mode 100644index 000000000..1d7290ea5--- /dev/null+++ b/node-operator/src/codec.js@@ -0,0 +1,108 @@+// Wire contract between a node and the three.ws coordinator.+//+// Derived from the platform's existing worker job format (no phase 4 spec had+// landed in specs/ when this client was built):+// - bearer auth with a shared worker secret, as in workers/agent-screen-pool+// (SCREEN_WORKER_SECRET on both sides, timing-safe compared by the API)+// - claim -> execute -> submit loops, as in workers/agent-screen-pool and+// workers/garment-forge (claim at execution time, submit signed result)+// - Ed25519 signatures over a canonical UTF-8 string, verified by+// api/_lib/siws.js-style logic (verifyPayload in src/identity.js)+//+// Job envelope (claim response item):+// { jobId, type: 'llm.completion', model, input: { prompt }, maxTokens,+// issuedAt }+//+// Canonical result payload (what the node actually signs):+// threews-inference-v1\n<jobId>\n<nodeAddress>\n<model>\n+// <sha256-hex of UTF-8 input.prompt>\n<sha256-hex of UTF-8 output text>\n+// <latencyMs>\n<completedAt ISO>+//+// Submit body:+// { jobId, node, model, result: { text, tokens, latencyMs },+// inputHash, outputHash, completedAt, signature }+//+// Anyone can recompute the canonical string from a job + result and check it+// against `signature` with only the node's public address.++import { createHash } from 'node:crypto';++export const PROTOCOL = 'threews-inference-v1';+export const JOB_TYPE = 'llm.completion';++export function sha256Hex(text) {+ return createHash('sha256').update(String(text), 'utf8').digest('hex');+}++// Validate and normalize a claimed job. Returns null for anything that is not+// an executable llm.completion job, so a malformed queue entry never reaches+// the engine.+export function normalizeJob(raw) {+ if (!raw || typeof raw !== 'object') return null;+ const jobId = String(raw.jobId || raw.job_id || '');+ if (!jobId) return null;+ if (raw.type && raw.type !== JOB_TYPE) return null;+ const input = raw.input && typeof raw.input === 'object' ? raw.input : {};+ const prompt = typeof input.prompt === 'string' ? input.prompt : null;+ if (!prompt) return null;+ const maxTokensRaw = Number(raw.maxTokens ?? raw.max_tokens ?? 64);+ const maxTokens = Number.isFinite(maxTokensRaw) ? Math.min(Math.max(Math.round(maxTokensRaw), 1), 512) : 64;+ return {+ jobId,+ type: JOB_TYPE,+ model: String(raw.model || ''),+ input: { prompt },+ maxTokens,+ issuedAt: raw.issuedAt || raw.issued_at || null,+ };+}++// Build the exact string the node signs. Field order is load-bearing; verifiers+// reproduce it byte for byte.+export function canonicalResult({ jobId, node, model, inputHash, outputHash, latencyMs, completedAt }) {+ return [+ PROTOCOL,+ jobId,+ node,+ model,+ inputHash,+ outputHash,+ String(Math.round(Number(latencyMs) || 0)),+ completedAt,+ ].join('\n');+}++// Assemble the unsigned result record for a finished job.+export function buildResultRecord({ job, node, model, text, tokens, latencyMs, completedAt }) {+ const inputHash = sha256Hex(job.input.prompt);+ const outputHash = sha256Hex(text);+ return {+ jobId: job.jobId,+ node,+ model,+ result: { text, tokens: Math.max(0, Math.round(Number(tokens) || 0)), latencyMs: Math.round(latencyMs) },+ inputHash,+ outputHash,+ completedAt,+ };+}++// Verify a submitted result against the job and the node's public address.+// `verify` is the identity.verifyPayload function (injected so this module+// stays free of crypto imports and trivially testable).+export function verifyResult({ job, record, signature, verify }) {+ if (!job || !record || !signature || typeof verify !== 'function') return false;+ if (record.jobId !== job.jobId) return false;+ if (record.inputHash !== sha256Hex(job.input.prompt)) return false;+ if (record.outputHash !== sha256Hex(record.result?.text ?? '')) return false;+ const payload = canonicalResult({+ jobId: record.jobId,+ node: record.node,+ model: record.model,+ inputHash: record.inputHash,+ outputHash: record.outputHash,+ latencyMs: record.result.latencyMs,+ completedAt: record.completedAt,+ });+ return verify(record.node, payload, signature);+}diff --git a/node-operator/src/engine.js b/node-operator/src/engine.jsnew file mode 100644index 000000000..8224a2816--- /dev/null+++ b/node-operator/src/engine.js@@ -0,0 +1,248 @@+// Built-in proof workload: real text generation with a small open model.+//+// The model is distilgpt2 (82M params, the distilled GPT-2, MIT-licensed+// weights from OpenAI's GPT-2 family), served from the ONNX export published+// by Xenova on Hugging Face. The quantized graph is ~80 MB, small enough that+// the image builds anywhere and fast enough on CPU to prove the job loop end+// to end; on a GPU host the same graph runs on the CUDA execution provider+// (see Dockerfile.gpu).+//+// Files are downloaded from huggingface.co into MODEL_CACHE_DIR on first run+// and checksummed by the hub's own ETag path (resolve/main pins the revision+// served today; set MODEL_REVISION to pin an exact commit).+//+// The tokenizer is a byte-level BPE (GPT-2 family). Rather than vendoring a+// tokenizer library, this module implements the exact algorithm from the+// Hugging Face tokenizers spec over the repo's real vocab.json/merges.txt:+// bytes-to-unicode mapping, the GPT-2 pre-tokenizer split regex, then BPE+// merge ranking. Generation is greedy argmax over the ONNX logits.++import { createWriteStream } from 'node:fs';+import { mkdir, readFile, stat, rename, rm } from 'node:fs/promises';+import path from 'node:path';+import { pipeline } from 'node:stream/promises';+import { Readable } from 'node:stream';+import ort from 'onnxruntime-node';++export const DEFAULT_MODEL_ID = 'Xenova/distilgpt2';+export const DEFAULT_MODEL_REVISION = 'main';++const MODEL_FILES = [+ 'onnx/model_quantized.onnx',+ 'config.json',+ 'tokenizer.json',+ 'vocab.json',+ 'merges.txt',+];++// ── Download ────────────────────────────────────────────────────────────────++async function fileExists(p) {+ try {+ await stat(p);+ return true;+ } catch {+ return false;+ }+}++async function download(url, dest) {+ await mkdir(path.dirname(dest), { recursive: true });+ const tmp = `${dest}.part-${process.pid}`;+ const res = await fetch(url, { redirect: 'follow' });+ if (!res.ok || !res.body) {+ throw new Error(`model download failed: ${res.status} ${res.statusText} for ${url}`);+ }+ await pipeline(Readable.fromWeb(res.body), createWriteStream(tmp));+ await rename(tmp, dest);+}++// Ensure every model file is present under cacheDir; returns the directory.+export async function ensureModel({ cacheDir, modelId = DEFAULT_MODEL_ID, revision = DEFAULT_MODEL_REVISION, log = () => {} }) {+ await mkdir(cacheDir, { recursive: true });+ for (const rel of MODEL_FILES) {+ const dest = path.join(cacheDir, rel);+ if (await fileExists(dest)) continue;+ const url = `https://huggingface.co/${modelId}/resolve/${revision}/${rel}`;+ log(`downloading ${rel}`);+ await download(url, dest);+ }+ return cacheDir;+}++// ── Byte-level BPE tokenizer (GPT-2 family) ─────────────────────────────────++// The GPT-2 bytes-to-unicode table: printable bytes map to themselves, the+// rest map to codepoints 256+. Identical to transformers' bytes_to_unicode().+function buildBytesToUnicode() {+ const bs = [];+ for (let i = 33; i <= 126; i++) bs.push(i);+ for (let i = 161; i <= 172; i++) bs.push(i);+ for (let i = 174; i <= 255; i++) bs.push(i);+ const cs = [...bs];+ let n = 0;+ const b2u = new Map();+ for (let b = 0; b < 256; b++) {+ if (!bs.includes(b)) {+ bs.push(b);+ cs.push(256 + n);+ n++;+ }+ }+ for (let i = 0; i < bs.length; i++) b2u.set(bs[i], String.fromCodePoint(cs[i]));+ const u2b = new Map([...b2u].map(([b, u]) => [u, b]));+ return { b2u, u2b };+}++// GPT-2 pre-tokenizer split pattern (the JS-safe equivalent of the original+// Python regex): contractions, words, numbers, symbol runs, whitespace runs.+const PRE_TOKENIZER_RE = /'s|'t|'re|'ve|'m|'ll|'d| ?[A-Za-z]+| ?[0-9]+| ?[^\sA-Za-z0-9]+|\s+(?!\S)|\s+/gu;++export class BpeTokenizer {+ constructor({ vocab, merges, b2u, u2b, eosTokenId }) {+ this.vocab = vocab; // token string -> id+ this.idToToken = new Map(Object.entries(vocab).map(([t, id]) => [id, t]));+ this.b2u = b2u;+ this.u2b = u2b;+ this.eosTokenId = eosTokenId;+ // Merge rank lookup: "left right" -> rank.+ this.ranks = new Map(merges.map((pair, i) => [`${pair[0]} ${pair[1]}`, i]));+ this.cache = new Map();+ }++ static async load(dir) {+ const vocab = JSON.parse(await readFile(path.join(dir, 'vocab.json'), 'utf8'));+ const mergesRaw = await readFile(path.join(dir, 'merges.txt'), 'utf8');+ const merges = mergesRaw+ .split('\n')+ .map((l) => l.trim())+ .filter((l) => l && !l.startsWith('#'))+ .map((l) => l.split(' '));+ const config = JSON.parse(await readFile(path.join(dir, 'config.json'), 'utf8'));+ const { b2u, u2b } = buildBytesToUnicode();+ return new BpeTokenizer({ vocab, merges, b2u, u2b, eosTokenId: config.eos_token_id ?? 50256 });+ }++ encode(text) {+ const preTokens = String(text).match(PRE_TOKENIZER_RE) || [];+ const ids = [];+ for (const pre of preTokens) {+ // Map raw UTF-8 bytes through the bytes-to-unicode alphabet.+ const bytes = new TextEncoder().encode(pre);+ const word = [...bytes].map((b) => this.b2u.get(b));+ for (const token of this.bpe(word)) {+ const id = this.vocab[token];+ if (id !== undefined) ids.push(id);+ }+ }+ return ids;+ }++ decode(ids) {+ const tokens = ids.map((id) => this.idToToken.get(id) || '');+ const text = tokens.join('');+ const bytes = [];+ for (const ch of text) {+ const b = this.u2b.get(ch);+ if (b !== undefined) bytes.push(b);+ }+ return new TextDecoder('utf-8', { fatal: false }).decode(Uint8Array.from(bytes));+ }++ bpe(word) {+ const key = word.join('');+ if (this.cache.has(key)) return this.cache.get(key);+ if (word.length <= 1) {+ this.cache.set(key, word);+ return word;+ }+ let current = word;+ for (;;) {+ // Find the lowest-rank adjacent pair.+ let bestRank = Infinity;+ let bestIdx = -1;+ for (let i = 0; i < current.length - 1; i++) {+ const rank = this.ranks.get(`${current[i]} ${current[i + 1]}`);+ if (rank !== undefined && rank < bestRank) {+ bestRank = rank;+ bestIdx = i;+ }+ }+ if (bestIdx === -1) break;+ const merged = current[bestIdx] + current[bestIdx + 1];+ current = [...current.slice(0, bestIdx), merged, ...current.slice(bestIdx + 2)];+ }+ this.cache.set(key, current);+ return current;+ }+}++// ── Inference session ───────────────────────────────────────────────────────++export class InferenceEngine {+ constructor({ session, tokenizer, maxLength }) {+ this.session = session;+ this.tokenizer = tokenizer;+ this.maxLength = maxLength;+ }++ static async load({ cacheDir, log = () => {} }) {+ const modelPath = path.join(cacheDir, 'onnx', 'model_quantized.onnx');+ const config = JSON.parse(await readFile(path.join(cacheDir, 'config.json'), 'utf8'));+ const tokenizer = await BpeTokenizer.load(cacheDir);+ const session = await ort.InferenceSession.create(modelPath, {+ // CUDA is used automatically when the GPU image installs the CUDA+ // build of onnxruntime-node; the CPU build ignores this entry.+ executionProviders: ['cuda', 'cpu'],+ graphOptimizationLevel: 'all',+ logSeverityLevel: 3,+ });+ log(`model loaded from ${modelPath} (providers: ${session.executionProviders ?? 'cpu'})`);+ return new InferenceEngine({+ session,+ tokenizer,+ maxLength: Math.min(Number(config.n_positions) || 1024, 1024),+ });+ }++ // Greedy generation: each step appends the argmax next token. Deterministic,+ // which is exactly what a verifiable proof workload wants: the same prompt+ // on an honest node produces the same output hash.+ async generate(prompt, maxNewTokens = 48) {+ const t0 = Date.now();+ let ids = this.tokenizer.encode(prompt);+ if (ids.length === 0) ids = [this.tokenizer.eosTokenId];+ const budget = Math.min(Math.max(1, maxNewTokens), this.maxLength - ids.length);+ let generated = 0;++ const inputName = this.session.inputNames[0];+ for (let step = 0; step < budget; step++) {+ const seq = BigInt64Array.from(ids.map(BigInt));+ const feeds = { [inputName]: new ort.Tensor('int64', seq, [1, ids.length]) };+ const outputs = await this.session.run(feeds);+ const logits = outputs[this.session.outputNames[0]];+ const vocabSize = logits.dims[logits.dims.length - 1];+ const last = logits.data.subarray(logits.data.length - vocabSize);+ let best = 0;+ let bestVal = -Infinity;+ for (let i = 0; i < last.length; i++) {+ if (last[i] > bestVal) {+ bestVal = last[i];+ best = i;+ }+ }+ ids.push(best);+ generated++;+ if (best === this.tokenizer.eosTokenId) break;+ }++ const text = this.tokenizer.decode(ids.slice(ids.length - generated));+ return { text, tokens: generated, latencyMs: Date.now() - t0 };+ }+}++// Load model + engine in one call, downloading on first use.+export async function loadEngine({ cacheDir, modelId, revision, log } = {}) {+ const dir = await ensureModel({ cacheDir, modelId, revision, log });+ return InferenceEngine.load({ cacheDir: dir, log });+}diff --git a/node-operator/src/identity.js b/node-operator/src/identity.jsnew file mode 100644index 000000000..5d85f2767--- /dev/null+++ b/node-operator/src/identity.js@@ -0,0 +1,124 @@+// Node identity: a Solana Ed25519 keypair that doubles as the node's on-chain+// address and its job-result signing key. Encoding follows the platform's+// existing conventions (api/_lib/siws.js, api/_lib/attest-event.js):+// - secret keys: base58 (also accepts base64 and solana-keygen JSON arrays)+// - public keys / node addresses: base58, 32 bytes+// - signatures: Ed25519 over the UTF-8 canonical string, emitted base58+// Only @noble/curves and bs58 are used so the same module loads in the repo's+// root test runner without pulling @solana/web3.js.++import { randomBytes } from 'node:crypto';+import { ed25519 } from '@noble/curves/ed25519.js';+import bs58 from 'bs58';++const BASE58_RE = /^[A-HJ-NP-Za-km-z1-9]+$/;++// Decode a node secret key from any encoding the platform already provisions:+// - JSON array of 64 (or 32) ints, as written by solana-keygen+// - base64 of the raw secret-key bytes+// - base58 of the raw secret-key bytes (the default this client emits)+// Returns a 64-byte secret key (32-byte seed + pubkey), or null on bad input.+export function decodeNodeSecret(secret) {+ const raw = String(secret || '').trim();+ if (!raw) return null;+ let bytes = null;+ if (raw.startsWith('[')) {+ try {+ const arr = JSON.parse(raw);+ if (Array.isArray(arr) && arr.every((n) => Number.isInteger(n) && n >= 0 && n <= 255)) {+ bytes = Uint8Array.from(arr);+ }+ } catch {+ return null;+ }+ } else if (BASE58_RE.test(raw)) {+ try {+ bytes = bs58.decode(raw);+ } catch {+ return null;+ }+ } else {+ try {+ bytes = Uint8Array.from(Buffer.from(raw, 'base64'));+ } catch {+ return null;+ }+ }+ if (!bytes) return null;+ // A 32-byte seed expands to the full 64-byte secret key.+ if (bytes.length === 32) {+ const pub = ed25519.getPublicKey(bytes);+ const full = new Uint8Array(64);+ full.set(bytes, 0);+ full.set(pub, 32);+ return full;+ }+ if (bytes.length === 64) return bytes;+ return null;+}++// Generate a fresh node identity.+export function generateKeypair() {+ const seed = randomBytes(32);+ const secretKey = decodeNodeSecret(bs58.encode(seed));+ return {+ secretKey,+ publicKey: secretKey.slice(32),+ address: bs58.encode(secretKey.slice(32)),+ secretBase58: bs58.encode(secretKey),+ };+}++// Load a node identity from an encoded secret key. Throws on bad input so a+// misconfigured operator fails at boot, not mid-job.+export function loadKeypair(secret) {+ const secretKey = decodeNodeSecret(secret);+ if (!secretKey) {+ throw new Error(+ 'NODE_SECRET_KEY could not be decoded: expected base58, base64, or a solana-keygen JSON byte array',+ );+ }+ return {+ secretKey,+ publicKey: secretKey.slice(32),+ address: bs58.encode(secretKey.slice(32)),+ };+}++// Sign an arbitrary UTF-8 payload with the node's key. Base58 signature out,+// matching how the platform encodes Ed25519 signatures everywhere else.+export function signPayload(secretKey, payload) {+ const bytes = new TextEncoder().encode(payload);+ return bs58.encode(ed25519.sign(bytes, secretKey.slice(0, 32)));+}++// Verify a base58 (or base64) Ed25519 signature over `payload` against a+// base58 node address. Mirrors verifySiwsSignature in api/_lib/siws.js.+export function verifyPayload(address, payload, signature) {+ let pubBytes;+ try {+ pubBytes = bs58.decode(String(address || ''));+ } catch {+ return false;+ }+ if (pubBytes.length !== 32) return false;++ const sigStr = String(signature || '');+ let sigBytes;+ if (BASE58_RE.test(sigStr)) {+ try {+ sigBytes = bs58.decode(sigStr);+ } catch {+ return false;+ }+ } else {+ try {+ sigBytes = Uint8Array.from(Buffer.from(sigStr, 'base64'));+ } catch {+ return false;+ }+ }+ if (!sigBytes || sigBytes.length !== 64) return false;++ return ed25519.verify(sigBytes, new TextEncoder().encode(payload), pubBytes);+}diff --git a/packages/node-operator/package.json b/packages/node-operator/package.jsonnew file mode 100644index 000000000..8be277adf--- /dev/null+++ b/packages/node-operator/package.json@@ -0,0 +1,23 @@+{+ "name": "@three-ws/node-operator",+ "version": "0.1.0",+ "description": "Operator client for the three.ws open inference network (roadmap phase 4). Registers a Solana-ed25519 node identity, polls the platform job queue, executes real local inference, and returns cryptographically signed results.",+ "license": "MIT",+ "type": "module",+ "private": true,+ "engines": {+ "node": ">=20"+ },+ "scripts": {+ "start": "node src/index.js",+ "register": "node src/index.js --register-only",+ "test": "vitest run"+ },+ "dependencies": {+ "@xenova/transformers": "^2.17.2",+ "tweetnacl": "^1.0.3"+ },+ "devDependencies": {+ "vitest": "^4.1.9"+ }+}diff --git a/packages/node-operator/src/identity.js b/packages/node-operator/src/identity.jsnew file mode 100644index 000000000..5aea7844a--- /dev/null+++ b/packages/node-operator/src/identity.js@@ -0,0 +1,165 @@+/**+ * Node identity: the operator's Solana ed25519 keypair.+ *+ * The node's public key (base58) IS its identity on the network: jobs are+ * routed to it, results are verified against it, and phase 4 settlement pays+ * it. The secret key never leaves the operator host; the platform only ever+ * sees signatures, which it verifies with tweetnacl against this pubkey.+ *+ * Key material lives in a single env var (OPERATOR_SECRET_KEY) as either a+ * base58 or base64 encoding of the 64-byte ed25519 secret key, or is+ * generated on first run and written to node-identity.json next to the+ * working directory so restarts keep the same identity.+ */++import { createRequire } from 'node:module';+import { readFileSync, writeFileSync, existsSync } from 'node:fs';+import { join } from 'node:path';++const require = createRequire(import.meta.url);+const nacl = require('tweetnacl');++const B58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';++/** Decode a base58 string to bytes (Bitcoin/Solana alphabet). */+export function base58Decode(str) {+ if (typeof str !== 'string' || str.length === 0) throw new Error('empty base58 string');+ const bytes = [0];+ for (const ch of str) {+ const idx = B58_ALPHABET.indexOf(ch);+ if (idx < 0) throw new Error(`invalid base58 character: ${ch}`);+ let carry = idx;+ for (let i = 0; i < bytes.length; i++) {+ carry += bytes[i] * 58;+ bytes[i] = carry & 0xff;+ carry >>= 8;+ }+ while (carry > 0) {+ bytes.push(carry & 0xff);+ carry >>= 8;+ }+ }+ // Leading '1's are leading zero bytes.+ for (const ch of str) {+ if (ch === '1') bytes.push(0);+ else break;+ }+ return Uint8Array.from(bytes.reverse());+}++/** Encode bytes as base58 (Bitcoin/Solana alphabet). */+export function base58Encode(bytes) {+ if (!bytes || bytes.length === 0) return '';+ const digits = [0];+ for (const byte of bytes) {+ let carry = byte;+ for (let i = 0; i < digits.length; i++) {+ carry += digits[i] << 8;+ digits[i] = carry % 58;+ carry = Math.floor(carry / 58);+ }+ while (carry > 0) {+ digits.push(carry % 58);+ carry = Math.floor(carry / 58);+ }+ }+ let out = '';+ for (const byte of bytes) {+ if (byte === 0) out += '1';+ else break;+ }+ for (let i = digits.length - 1; i >= 0; i--) out += B58_ALPHABET[digits[i]];+ return out;+}++/**+ * A node identity: pubkey (base58), plus sign/verify closures bound to the+ * keypair. The secret key bytes are exposed only via `secretKey` for config+ * persistence; callers should treat the identity object as opaque.+ */+export function createIdentity(secretKeyBytes) {+ let keypair;+ if (secretKeyBytes) {+ const bytes =+ typeof secretKeyBytes === 'string'+ ? parseSecretKey(secretKeyBytes)+ : Uint8Array.from(secretKeyBytes);+ keypair = nacl.sign.keyPair.fromSecretKey(bytes);+ } else {+ keypair = nacl.sign.keyPair();+ }+ const publicKey = base58Encode(keypair.publicKey);+ return {+ publicKey,+ secretKey: keypair.secretKey,+ /** Sign arbitrary bytes; returns base64 signature. */+ sign(messageBytes) {+ return Buffer.from(nacl.sign.detached(messageBytes, keypair.secretKey)).toString('base64');+ },+ /** Sign a UTF-8 string; returns base64 signature. */+ signText(text) {+ return this.sign(new TextEncoder().encode(text));+ },+ /** Verify a base64 signature over UTF-8 text against this identity. */+ verify(text, signatureB64) {+ try {+ return nacl.sign.detached.verify(+ new TextEncoder().encode(text),+ Buffer.from(signatureB64, 'base64'),+ keypair.publicKey,+ );+ } catch {+ return false;+ }+ },+ };+}++/** Parse a secret key from env/config text: base58 or base64, 64 bytes either way. */+export function parseSecretKey(text) {+ const trimmed = String(text).trim();+ // Heuristic: base64 contains +/= or is 88 chars ending in =; base58 never does.+ if (/[+/=]/.test(trimmed)) {+ const bytes = Uint8Array.from(Buffer.from(trimmed, 'base64'));+ if (bytes.length !== 64) throw new Error(`secret key must decode to 64 bytes, got ${bytes.length}`);+ return bytes;+ }+ const bytes = base58Decode(trimmed);+ if (bytes.length !== 64) throw new Error(`secret key must decode to 64 bytes, got ${bytes.length}`);+ return bytes;+}++/**+ * Resolve the node identity for this process: OPERATOR_SECRET_KEY env var if+ * set, otherwise the persisted identity file, otherwise generate and persist+ * a fresh one. Returns { identity, source } where source is 'env' | 'file' |+ * 'generated'.+ */+export function resolveIdentity({ envSecret, identityPath }) {+ if (envSecret) {+ return { identity: createIdentity(parseSecretKey(envSecret)), source: 'env' };+ }+ if (identityPath && existsSync(identityPath)) {+ const saved = JSON.parse(readFileSync(identityPath, 'utf8'));+ if (saved?.secretKeyB64) {+ return {+ identity: createIdentity(Uint8Array.from(Buffer.from(saved.secretKeyB64, 'base64'))),+ source: 'file',+ };+ }+ }+ const identity = createIdentity();+ if (identityPath) {+ writeFileSync(+ identityPath,+ JSON.stringify({ publicKey: identity.publicKey, secretKeyB64: Buffer.from(identity.secretKey).toString('base64') }, null, 2),+ { mode: 0o600 },+ );+ }+ return { identity, source: 'generated' };+}++/** Default identity file location, overridable for tests. */+export function defaultIdentityPath(cwd = process.cwd()) {+ return join(cwd, 'node-identity.json');+}diff --git a/prompts/swarm-100/sdk-agent-protocol-sdk.md b/prompts/swarm-100/sdk-agent-protocol-sdk.mddeleted file mode 100644index 267ca9d95..000000000--- a/prompts/swarm-100/sdk-agent-protocol-sdk.md+++ /dev/null@@ -1,89 +0,0 @@-# Module audit: agent-protocol-sdk/--How to run: paste this file's repo path into a fresh Claude Code chat in this-repository and say "run this work order". This file is fully self-contained:-it depends on no other prompt file anywhere. If neighboring files in-prompts/swarm-100/ are gone, that work is done; if present, ignore them.-Every claim below rots; step 0 re-measures, and what you measure wins.--## Operating clause (binding)--- Read CLAUDE.md first. Its rules override everything, including this file.-- Finish 100% in this session. Never end the turn with a question, an option- list, or an unexecuted plan. A judgment call goes in one line of the final- report; it never becomes a question that halts work.-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real- funds or any irreversible on-chain write, git push or a production deploy,- committing content that references a crypto project other than $THREE, and- destroying unrecoverable data.-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no- commented-out code. Real APIs and real integrations only.-- The em-dash and en-dash characters are banned in everything you write.-- Concurrent agents share this worktree: stage explicit paths only (never a- bare add-everything), and commit finished work promptly.-- Before committing, run: npm run check:rules -- --paths <files you touched>.- It must exit 0.--## Step 0: re-derive the current state--1. Read agent-protocol-sdk/README.md and agent-protocol-sdk/package.json (or the equivalent manifest).-2. Find every consumer: grep the repo for imports of this module and check- STRUCTURE.md for the surfaces it powers.--## Task: bring agent-protocol-sdk/ to verified-shippable--1. Build it with its own build script; the build must succeed from this- worktree.-2. Run its tests; add a core-path test if none proves the main export works.-3. README quickstart: execute it verbatim as a new user would. Every command- must run, every code sample must work. Fix drift in the same change.-4. Public API: import the declared entry points with node and confirm they- load. Exported functions the README documents must exist and behave as- documented.-5. Hard-rule scan across its source: no stubs, no mock data, no unfinished- markers, no commented-out code.-6. If this module publishes an artifact consumed elsewhere (a UMD bundle, a- published npm package, a served static build), verify the wiring that- produces the artifact still works; never hand-edit generated output.--## Definition of done--- [ ] Build green from this worktree.-- [ ] Tests green, core path covered.-- [ ] README quickstart executed successfully end to end.-- [ ] Entry points import cleanly; documented API verified real.-- [ ] Zero hard-rule violations remain in this module.-- [ ] npm run check:rules -- --paths <touched files> exits 0.--## Never blocked--| Blocker | Resolution (act, do not ask) |-|---|---|-| Missing env var or credential | Check .env and .env.local, then the Cloud Run service env, then Secret Manager (the CLAUDE.md self-unblock playbook has the exact commands). If it truly exists nowhere, wire the code fully behind the env var, prove the wiring with a dry run, and name the single missing var in the report. |-| gcloud not on PATH | Run: export PATH="$HOME/google-cloud-sdk/bin:$PATH" |-| Dev server port 3000 busy | Another agent may be serving this repo; probe it and reuse if so. Otherwise start your own on a free port: npx vite --port 3101 |-| Playwright browser missing | npx playwright install chromium |-| A surface needs a signed-in user | Register a fresh account through the real /register flow against the real API and use it. Never mock the session. |-| A defect sits in code you did not touch | Fix it if it blocks a Definition of done line (root cause it, never mask it). Otherwise note it in the report and continue. |-| An unrelated test is red | Same rule. Never pipe npm test through tail; it masks exit codes. |--## Close out (required)--1. Verify every Definition of done line with the actual command output in- front of you. Never claim a line you did not verify.-2. Commit with explicit paths and a subject that describes the diff (house- style: type(scope): what changed and why a reader cares).-3. Delete this prompt file in that same commit:-- git rm prompts/swarm-100/sdk-agent-protocol-sdk.md-- The shrinking directory is this campaign's only progress ledger; there is- no progress log to update.-4. Final report: what step 0 measured, what changed (file list), evidence per- Definition of done line, and any one-line judgment calls. No trailing- questions, no unexecuted plans.--If a line genuinely cannot pass inside this session (an external party must-respond, or an owner-gated action is the final step), finish everything else,-leave this file in place, and state exactly which line remains and who owns-it. Never delete this file on a partial.