diff --git a/scripts/register.js b/scripts/register.js index d26ba6b..75f2ac2 100644 --- a/scripts/register.js +++ b/scripts/register.js @@ -19,7 +19,7 @@ */ import { buildRegistry, resetRegistry } from "../src/modules/registry.js"; -import { stubKv } from "./stub-kv.js"; +import { stubAi, stubKv } from "./stub-kv.js"; const TELEGRAM_API = "https://api.telegram.org"; @@ -72,7 +72,7 @@ async function main() { // Build the registry against the same code the Worker uses. Stub KV // satisfies the binding so createStore() does not throw. resetRegistry(); - const reg = await buildRegistry({ MODULES: modules, KV: stubKv }); + const reg = await buildRegistry({ MODULES: modules, KV: stubKv, AI: stubAi }); const commands = [...reg.publicCommands.values()].map(({ cmd }) => ({ command: cmd.name, diff --git a/scripts/stub-kv.js b/scripts/stub-kv.js index b86629d..ef12426 100644 --- a/scripts/stub-kv.js +++ b/scripts/stub-kv.js @@ -1,11 +1,12 @@ /** - * @file stub-kv — minimal no-op KVNamespace stub used by scripts/register.js. + * @file stub-kv — no-op binding stubs used by scripts/register.js. * * The register script imports buildRegistry() to derive the public command - * list at deploy time. buildRegistry calls createStore() → CFKVStore → needs - * a KV binding. This stub satisfies the shape without doing any real IO, - * since module init hooks in this codebase read-only (or tolerate missing - * state). If a future module writes inside init(), update the stub to + * list at deploy time. Module init hooks in this codebase dereference + * runtime bindings like `env.KV` (via createStore) and `env.AI` (semantle). + * These stubs satisfy the shape without doing any real IO. All init hooks + * are assumed read-only (or tolerant of missing state) at registration time. + * If a future module writes inside init(), update the matching stub to * swallow writes or gate the write on a `process.env.REGISTER_DRYRUN` flag. */ @@ -33,3 +34,13 @@ export const stubKv = { return { value: null, metadata: null }; }, }; + +/** + * Workers AI binding stub. Semantle's init() wires `createClient(env.AI)` + * which only type-checks `.run` — no inference ever fires during register. + */ +export const stubAi = { + async run() { + return { data: [] }; + }, +};