@abaigram/abai-stub 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":";;;;;;;;AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,kEAAkE;AAClE,sEAAsE;AACtE,4EAA4E;AAC5E,yEAAyE;AACzE,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,uEAAuE;AACvE,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAqB,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACN,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,iBAAiB,EAEjB,UAAU,EACV,aAAa,EACb,UAAU,GACV,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAA4C,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAEN,OAAO,EAEP,UAAU,EAEV,YAAY,EACZ,OAAO,EACP,cAAc,GAId,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5G,OAAO,EAEN,aAAa,GAIb,MAAM,eAAe,CAAC;AAEvB,4EAA4E;AAC5E,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC9B,QAAQ,CAAS;IAC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QACJ,MAAM,GAAG,CAAC,MAAM,MAAM,kCAAC,SAAS,EAAC,CAAkB,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,cAAc,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IAClE,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC;IACrC,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC;QACzB,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;IAAA,CACtB,CAAC;AAAA,CACF;AAED,8GAA8G;AAC9G,MAAM,UAAU,cAAc,CAAC,OAAwB,EAAE,MAAM,GAAmB,EAAE,EAAY;IAC/F,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAAA,CACrC","sourcesContent":["// createAbaigram: the program-facing API of the stub (abaigrammar sections 4\n// and 5). The program declares its manifest in code, obtains cell, knob and\n// event handles once, and then writes cells, emits events, serves\n// capabilities and calls touchpoints. With no harness attached, every\n// operation here costs what section 11.1 says: cell writes store, emits and\n// safepoints load one flag, decisions and turns load the flag and count.\n//\n// Touchpoints are awaited promises (see the instantiation's deviations in\n// registry.ts). The attached paths arrive with the harness binding; this\n// file carries the detached behaviour and the seams the binding fills.\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fitValue } from \"./cells/fit.ts\";\nimport { type ContentSlots, createContent, findRoot } from \"./content.ts\";\nimport { Endpoint } from \"./endpoint.ts\";\nimport {\n\tattachWaitMsFrom,\n\tENV_HARNESS,\n\tENV_HARNESS_BIN,\n\tENV_LAUNCH_SOCKET,\n\ttype HarnessSelection,\n\trunDirFrom,\n\tselectHarness,\n\tselectMode,\n} from \"./env.ts\";\nimport { DirectBinding, type HarnessBinding, type TouchpointKind } from \"./harness-binding.ts\";\nimport {\n\ttype CellDecl,\n\tcutUtf8,\n\ttype DecisionDecl,\n\tdurationMs,\n\ttype EventDecl,\n\tencodedBytes,\n\tfieldOf,\n\tLIBRARY_EVENTS,\n\ttype Manifest,\n\ttype Mode,\n\ttype TurnDecl,\n} from \"./manifest/manifest.ts\";\nimport { attachNullHarness, type NullHarness } from \"./null-harness.ts\";\nimport { FLAG_ATTACHED, FLAG_PAUSED, FLAG_QUEUE, FLAG_WORK, LIBRARY_EVENT_BASE, Region } from \"./region.ts\";\nimport {\n\ttype AbaigramOptions,\n\tbuildManifest,\n\ttype CapabilityHandler,\n\ttype KnobHandler,\n\ttype StopHandler,\n} from \"./registry.ts\";\n\n/** Thrown by `decide` when the applied default is `abort` (section 5.4). */\nexport class AbaigramAbort extends Error {\n\treadonly decision: string;\n\tconstructor(decision: string, cause: string) {\n\t\tsuper(`decision ${decision} applied its default, abort (${cause})`);\n\t\tthis.name = \"AbaigramAbort\";\n\t\tthis.decision = decision;\n\t}\n}\n\nexport interface CellHandle<T = unknown> {\n\treadonly name: string;\n\tget(): T;\n\t/** One store to the value and one to the version. Enum values must be declared; nothing else is checked. */\n\tset(value: T): void;\n}\n\nexport interface KnobHandle<T = unknown> extends CellHandle<T> {\n\t/** Back to the declared default; a sized knob's reset reaches the harness as `abai.knob.reset`. */\n\treset(): void;\n\t/** Sized knobs only: the handler that receives a delivered value at a safepoint. */\n\tonChange(handler: KnobHandler): void;\n}\n\nexport interface EventHandle {\n\treadonly name: string;\n\t/** One load of the attached flag when no harness is attached. */\n\temit(payload?: Record<string, unknown>): void;\n}\n\nexport interface CounterSnapshot {\n\t[name: string]: number;\n}\n\n/** What a harness binding supplies once attached; undefined while detached. */\nexport interface AttachedHarness {\n\t/** Ask the harness; resolves to the answer, or rejects with the cause of a default. */\n\tdecide(decision: DecisionDecl, context: Record<string, unknown>, deadlineMs: number): Promise<unknown>;\n\t/** Give the harness a turn; resolves when it is done or the timeout passes. */\n\tturn(turn: TurnDecl, deadlineMs: number): Promise<void>;\n\t/** An event was published; `seq` is its sequence number. */\n\temitted(seq: number): void;\n\t/** The program detaches it. */\n\tdetach(reason: string): void;\n}\n\ninterface CellEntry {\n\tdecl: CellDecl;\n\t/** Position in `manifest.cells`: the index into `versions`. */\n\tordinal: number;\n\t/** Index into `values` (scalar) or `sized`. */\n\tslot: number;\n\tscalar: boolean;\n\tenumIndex?: Map<string, number>;\n\t/** Built once per cell: the typed store and load (section 11.2 rows). */\n\tset: (value: unknown) => void;\n\tget: () => unknown;\n}\n\ninterface EventEntry {\n\tdecl: EventDecl;\n\tordinal: number;\n\tfields: Array<{ key: string; type: string; max: number | undefined }>;\n}\n\n/** Attaches an in-process harness to the binding the stub hands it. */\nexport type HarnessFactory = (binding: HarnessBinding) => void | Promise<void>;\n\nexport interface AbaigramExtras {\n\t/** The program's root, where abaigram.yaml and the content live. Default: found from the cwd on first use, else the cwd. */\n\troot?: string;\n\tenv?: NodeJS.ProcessEnv;\n\t/** Injectable clock. */\n\tnow?: () => number;\n\t/** The in-process harness for turns mode; overrides the dynamic import of the harness package. */\n\tharness?: HarnessFactory;\n\t/** Where the audit log goes; default: the manifest's path. */\n\tauditPath?: string;\n\t/** For the exercise form: where its report goes at exit. Default: stderr. */\n\treport?: (text: string) => void;\n}\n\nexport class Abaigram {\n\treadonly manifest: Manifest;\n\treadonly mode: Mode;\n\treadonly modeFallback: boolean;\n\treadonly harnessSelection: HarnessSelection;\n\t/** A problem with the environment's harness selection, reported by doctor, never thrown. */\n\treadonly harnessSelectionError: string | undefined;\n\treadonly content: ContentSlots;\n\t/**\n\t * The sidecar endpoint, listening from startup when the selected mode is\n\t * sidecar and a real harness is wanted (section 6.3). A check run under\n\t * `ABAI_HARNESS` keeps its null harness in-process and opens no socket.\n\t */\n\treadonly endpoint: Endpoint | undefined;\n\t/** A launcher handed this program its connection (section 6.3): the full lifecycle is available to it. */\n\treadonly launched: boolean = false;\n\treadonly startedAt: string = new Date().toISOString();\n\t/** The root given at construction, if any; otherwise the root is found lazily. */\n\treadonly explicitRoot: string | undefined;\n\t/** @internal The region; tests and the binding reach it, programs do not. */\n\treadonly region: Region;\n\treadonly now: () => number;\n\n\tprivate readonly cellEntries = new Map<string, CellEntry>();\n\tprivate readonly eventEntries = new Map<string, EventEntry>();\n\tprivate readonly libraryEvents = new Map<string, number>();\n\tprivate readonly cellHandles = new Map<string, CellHandle>();\n\tprivate readonly eventHandles = new Map<string, EventHandle>();\n\tprivate readonly knobHandlers = new Map<string, KnobHandler>();\n\tprivate readonly capabilityHandlers = new Map<string, CapabilityHandler>();\n\tprivate readonly decisionIndex = new Map<string, number>();\n\tprivate readonly turnIndex = new Map<string, number>();\n\tprivate readonly queue: Array<() => void> = [];\n\tprivate harness: AttachedHarness | undefined;\n\tprivate binding: DirectBinding | undefined;\n\tprivate nullHarness: NullHarness | undefined;\n\tprivate lastAttachError: string | undefined;\n\tprivate readonly harnessFactory: HarnessFactory | undefined;\n\tprivate readonly auditPathOverride: string | undefined;\n\tprivate readonly report: (text: string) => void;\n\tprivate readonly env: NodeJS.ProcessEnv;\n\treadonly stopHandler: StopHandler | undefined;\n\t/** Who waits for a cooperative pause to lift, and the ref'd timer that keeps a paused program alive. */\n\tprivate resumeWaiters: Array<() => void> = [];\n\tprivate pauseKeepAlive: NodeJS.Timeout | undefined;\n\t/** Under launch: the launcher connected at least once, so nothing waits for it a second time. */\n\tprivate launcherSeen = false;\n\n\tconstructor(options: AbaigramOptions, extras: AbaigramExtras = {}) {\n\t\tthis.manifest = buildManifest(options);\n\t\tthis.now = extras.now ?? Date.now;\n\t\tconst env = extras.env ?? process.env;\n\t\tthis.env = env;\n\t\tconst selection = selectMode(this.manifest.modes, env);\n\t\tthis.mode = selection.mode;\n\t\tthis.modeFallback = selection.fallback;\n\t\tconst harness = selectHarness(env);\n\t\tthis.harnessSelection = harness.selection;\n\t\tthis.harnessSelectionError = harness.error;\n\t\tthis.stopHandler = options.lifecycle?.stop?.handler;\n\t\tthis.explicitRoot = extras.root;\n\t\tthis.harnessFactory = extras.harness;\n\t\tthis.auditPathOverride = extras.auditPath;\n\t\tthis.report =\n\t\t\textras.report ??\n\t\t\t((text) => {\n\t\t\t\tprocess.stderr.write(`${text}\\n`);\n\t\t\t});\n\n\t\tlet scalars = 0;\n\t\tlet sized = 0;\n\t\tconst pending: Array<[CellDecl, number, number, boolean]> = [];\n\t\tthis.manifest.cells.forEach((decl, ordinal) => {\n\t\t\tconst scalar = decl.type !== \"string\" && decl.type !== \"object\" && decl.type !== \"list\";\n\t\t\tpending.push([decl, ordinal, scalar ? scalars++ : sized++, scalar]);\n\t\t});\n\t\tthis.manifest.decisions.forEach((decl, i) => {\n\t\t\tthis.decisionIndex.set(decl.name, i);\n\t\t});\n\t\tthis.manifest.turns.forEach((decl, i) => {\n\t\t\tthis.turnIndex.set(decl.name, i);\n\t\t});\n\t\tthis.region = new Region({\n\t\t\tscalars,\n\t\t\tsized,\n\t\t\tcounters: this.manifest.decisions.length + this.manifest.turns.length + 1,\n\t\t});\n\t\tif (this.modeFallback) this.region.counters[this.region.counters.length - 1] += 1;\n\t\tfor (const [decl, ordinal, slot, scalar] of pending)\n\t\t\tthis.cellEntries.set(decl.name, this.makeEntry(decl, ordinal, slot, scalar));\n\n\t\tthis.manifest.events.forEach((decl, ordinal) => {\n\t\t\tconst fields = Object.entries(decl.payload).map(([key, field]) => {\n\t\t\t\tconst f = fieldOf(field);\n\t\t\t\treturn { key, type: f.type, max: f.max };\n\t\t\t});\n\t\t\tthis.eventEntries.set(decl.name, { decl, ordinal, fields });\n\t\t});\n\t\tLIBRARY_EVENTS.forEach((name, i) => {\n\t\t\tthis.libraryEvents.set(name, LIBRARY_EVENT_BASE - i);\n\t\t});\n\n\t\tfor (const [name, cell] of Object.entries(options.cells ?? {})) {\n\t\t\tif (cell.access === \"readwrite\") {\n\t\t\t\tthis.cellEntries.get(name)?.set(cell.default);\n\t\t\t\tif (cell.onChange) this.knobHandlers.set(name, cell.onChange);\n\t\t\t}\n\t\t}\n\t\tfor (const [name, capability] of Object.entries(options.capabilities ?? {})) {\n\t\t\tif (capability.handler) this.capabilityHandlers.set(name, capability.handler);\n\t\t}\n\t\t// the root is found on first use, so a program that never attaches never touches the filesystem\n\t\tthis.content = createContent(this.manifest, () => extras.root ?? findRoot(this.manifest.name) ?? process.cwd());\n\t\t// startup is one of the five places (section 4.3): a null harness attaches here\n\t\tif (this.harnessSelection === \"null\" || this.harnessSelection === \"exercise\")\n\t\t\tthis.attachNull(this.harnessSelection);\n\t\t// sidecar: the receiving end waits from startup (section 6.3); its failure to listen is a reason\n\t\t// the next attach reports, never a throw into the program\n\t\tconst launchSocket = env[ENV_LAUNCH_SOCKET]?.trim();\n\t\tif (this.mode === \"sidecar\" && this.harnessSelection === \"real\") {\n\t\t\t// launched: the parent chose the socket and is waiting on it. Read once and removed, so a program\n\t\t\t// that spawns a copy of itself never hands it this very socket\n\t\t\tthis.launched = launchSocket !== undefined && launchSocket !== \"\";\n\t\t\tif (this.launched && env === process.env) delete process.env[ENV_LAUNCH_SOCKET];\n\t\t\tthis.endpoint = new Endpoint(this, {\n\t\t\t\trunDir: this.launched ? dirname(launchSocket as string) : runDirFrom(env),\n\t\t\t\t...(this.launched ? { socketPath: launchSocket as string } : {}),\n\t\t\t});\n\t\t\tthis.endpoint.ready.catch((error: unknown) => {\n\t\t\t\tthis.lastAttachError = `the endpoint could not listen: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\t});\n\t\t} else if (launchSocket !== undefined && launchSocket !== \"\") {\n\t\t\t// a launcher is waiting, but this program cannot take the connection up: it runs as itself, observed\n\t\t\t// from outside only (section 5.7), and says why when asked\n\t\t\tif (env === process.env) delete process.env[ENV_LAUNCH_SOCKET];\n\t\t\tthis.lastAttachError =\n\t\t\t\tthis.harnessSelection === \"real\"\n\t\t\t\t\t? `launched, but ${this.manifest.name} declares no sidecar mode (declared: ${this.manifest.modes.join(\", \")})`\n\t\t\t\t\t: `launched under ${ENV_HARNESS}=${this.harnessSelection}`;\n\t\t}\n\t}\n\n\tget name(): string {\n\t\treturn this.manifest.name;\n\t}\n\n\tget attached(): boolean {\n\t\treturn this.region.flags[FLAG_ATTACHED] !== 0;\n\t}\n\n\t/** Why the last attach did not happen, if it did not. */\n\tget attachError(): string | undefined {\n\t\treturn this.lastAttachError;\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Cells and knobs (section 5.2)\n\t// -----------------------------------------------------------------------\n\n\t/** The typed store and load of one cell, built once so the hot path is the store alone. */\n\tprivate makeEntry(decl: CellDecl, ordinal: number, slot: number, scalar: boolean): CellEntry {\n\t\tconst { values, versions, sized } = this.region;\n\t\tconst entry: CellEntry = { decl, ordinal, slot, scalar, set: () => {}, get: () => undefined };\n\t\tif (!scalar) {\n\t\t\tentry.set = (value) => {\n\t\t\t\tsized[slot] = fitValue(value, decl);\n\t\t\t\tversions[ordinal] += 1;\n\t\t\t};\n\t\t\tentry.get = () => sized[slot];\n\t\t\treturn entry;\n\t\t}\n\t\tswitch (decl.type) {\n\t\t\tcase \"bool\":\n\t\t\t\tentry.set = (value) => {\n\t\t\t\t\tvalues[slot] = value ? 1 : 0;\n\t\t\t\t\tversions[ordinal] += 1;\n\t\t\t\t};\n\t\t\t\tentry.get = () => values[slot] !== 0;\n\t\t\t\tbreak;\n\t\t\tcase \"enum\": {\n\t\t\t\tconst index = new Map((decl.enum ?? []).map((value, i) => [value, i]));\n\t\t\t\tconst names = decl.enum ?? [];\n\t\t\t\tentry.enumIndex = index;\n\t\t\t\tentry.set = (value) => {\n\t\t\t\t\tconst i = index.get(value as string);\n\t\t\t\t\tif (i === undefined) throw new Error(`${decl.name}: ${String(value)} is not a declared value`);\n\t\t\t\t\tvalues[slot] = i;\n\t\t\t\t\tversions[ordinal] += 1;\n\t\t\t\t};\n\t\t\t\tentry.get = () => names[values[slot]];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tentry.set = (value) => {\n\t\t\t\t\tvalues[slot] = value as number;\n\t\t\t\t\tversions[ordinal] += 1;\n\t\t\t\t};\n\t\t\t\tentry.get = () => values[slot];\n\t\t}\n\t\treturn entry;\n\t}\n\n\tprivate entry(name: string): CellEntry {\n\t\tconst entry = this.cellEntries.get(name);\n\t\tif (!entry) throw new Error(`${this.name} declares no cell ${name}`);\n\t\treturn entry;\n\t}\n\n\t/** A handle, created once per cell and cached. */\n\tcell<T = unknown>(name: string): CellHandle<T> {\n\t\tconst cached = this.cellHandles.get(name);\n\t\tif (cached) return cached as CellHandle<T>;\n\t\tconst entry = this.entry(name);\n\t\tconst handle: CellHandle = { name, get: entry.get, set: entry.set };\n\t\tthis.cellHandles.set(name, handle);\n\t\treturn handle as CellHandle<T>;\n\t}\n\n\t/** A knob handle; the cell must be `readwrite`. */\n\tknob<T = unknown>(name: string): KnobHandle<T> {\n\t\tconst entry = this.entry(name);\n\t\tif (entry.decl.access !== \"readwrite\") throw new Error(`${name} is a read cell, not a knob`);\n\t\tconst handle = this.cell<T>(name) as KnobHandle<T>;\n\t\tif (handle.reset === undefined) {\n\t\t\thandle.reset = () => {\n\t\t\t\tentry.set(entry.decl.default);\n\t\t\t\tif (!entry.scalar) this.emitLibrary(\"abai.knob.reset\", { cell: name, value: entry.get() });\n\t\t\t};\n\t\t\thandle.onChange = (handler) => {\n\t\t\t\tif (entry.scalar) throw new Error(`${name} is a scalar knob; the program reads it, nothing is delivered`);\n\t\t\t\tthis.knobHandlers.set(name, handler);\n\t\t\t};\n\t\t}\n\t\treturn handle;\n\t}\n\n\t/** @internal The handler a sized knob delivers to, for the binding. */\n\tknobHandler(name: string): KnobHandler | undefined {\n\t\treturn this.knobHandlers.get(name);\n\t}\n\n\t/** @internal Every cell's current value, keyed by name, for the binding. */\n\treadCells(): Record<string, unknown> {\n\t\tconst cells: Record<string, unknown> = {};\n\t\tfor (const [name, entry] of this.cellEntries) cells[name] = entry.get();\n\t\treturn cells;\n\t}\n\n\t/** @internal A cell's version counter. */\n\tversion(name: string): number {\n\t\treturn this.region.versions[this.entry(name).ordinal];\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Lifecycle (section 5.5): what the program itself can do\n\t// -----------------------------------------------------------------------\n\n\t/** A cooperative pause is in effect. */\n\tget paused(): boolean {\n\t\treturn this.region.flags[FLAG_PAUSED] !== 0;\n\t}\n\n\t/**\n\t * @internal A cooperative pause: the flag is set, and the program is held\n\t * at its next touchpoint (this instantiation's deviation: a safepoint\n\t * cannot block the loop the resume arrives on). A ref'd timer keeps a\n\t * paused program alive, since nothing else of its own may be pending.\n\t */\n\trequestPause(): void {\n\t\tif (this.paused) return;\n\t\tthis.region.flags[FLAG_PAUSED] = 1;\n\t\tthis.region.flags[FLAG_WORK] = 1;\n\t\tthis.pauseKeepAlive = setInterval(() => {}, 2 ** 31 - 1);\n\t}\n\n\t/** @internal Lift the pause: whoever is held at a touchpoint goes on, their clocks starting now. */\n\tresumeFromPause(): void {\n\t\tif (!this.paused) return;\n\t\tthis.region.flags[FLAG_PAUSED] = 0;\n\t\tthis.region.flags[FLAG_WORK] = this.queue.length > 0 ? 1 : 0;\n\t\tif (this.pauseKeepAlive !== undefined) clearInterval(this.pauseKeepAlive);\n\t\tthis.pauseKeepAlive = undefined;\n\t\tfor (const waiter of this.resumeWaiters.splice(0)) waiter();\n\t}\n\n\t/** Hold here while a cooperative pause is in effect; the agent is told what the pause holds (4.3). */\n\tprivate awaitResume(touchpoint: string): Promise<void> {\n\t\tif (!this.paused) return Promise.resolve();\n\t\tthis.emitLibrary(\"abai.pause.blocked\", { touchpoint });\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tthis.resumeWaiters.push(resolve);\n\t\t});\n\t}\n\n\t/** @internal What the stub knows of its own process, for `lifecycle status`. */\n\tlifecycleStatus(): {\n\t\tpid: number;\n\t\tname: string;\n\t\tmode: string;\n\t\tcwd: string;\n\t\tstartedAt: string;\n\t\tconnections: number;\n\t\tpaused: boolean;\n\t\tlaunched: boolean;\n\t} {\n\t\treturn {\n\t\t\tpid: process.pid,\n\t\t\tname: this.manifest.name,\n\t\t\tmode: this.mode,\n\t\t\tcwd: process.cwd(),\n\t\t\tstartedAt: this.startedAt,\n\t\t\tconnections: this.endpoint?.connectionCount ?? (this.attached ? 1 : 0),\n\t\t\tpaused: this.paused,\n\t\t\tlaunched: this.launched,\n\t\t};\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Events (section 5.1)\n\t// -----------------------------------------------------------------------\n\n\t/** A handle for a declared event, created once and cached; the name is checked here, never on the hot path. */\n\tevent(name: string): EventHandle {\n\t\tconst cached = this.eventHandles.get(name);\n\t\tif (cached) return cached;\n\t\tconst entry = this.eventEntries.get(name);\n\t\tif (!entry) throw new Error(`${this.name} declares no event ${name}`);\n\t\tconst flags = this.region.flags;\n\t\tconst handle: EventHandle = {\n\t\t\tname,\n\t\t\temit: (payload = {}) => {\n\t\t\t\tif (flags[FLAG_ATTACHED] === 0) return;\n\t\t\t\tthis.publish(entry, payload);\n\t\t\t},\n\t\t};\n\t\tthis.eventHandles.set(name, handle);\n\t\treturn handle;\n\t}\n\n\t/** Copy the declared fields, cut sized ones to their max, publish, and tell the harness. */\n\tprivate publish(entry: EventEntry, payload: Record<string, unknown>): void {\n\t\tlet truncated = false;\n\t\tconst copy: Record<string, unknown> = {};\n\t\tfor (const field of entry.fields) {\n\t\t\tconst value = payload[field.key];\n\t\t\tif (value === undefined) continue;\n\t\t\tswitch (field.type) {\n\t\t\t\tcase \"string\": {\n\t\t\t\t\tconst text = String(value);\n\t\t\t\t\tconst cut = cutUtf8(text, field.max ?? 256);\n\t\t\t\t\tif (cut !== text) truncated = true;\n\t\t\t\t\tcopy[field.key] = cut;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"object\":\n\t\t\t\tcase \"list\": {\n\t\t\t\t\tconst bytes = encodedBytes(value);\n\t\t\t\t\tif (bytes > (field.max ?? 1024)) {\n\t\t\t\t\t\ttruncated = true;\n\t\t\t\t\t\tcopy[field.key] = { truncated: true, bytes };\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcopy[field.key] = JSON.parse(JSON.stringify(value));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tcopy[field.key] = value;\n\t\t\t}\n\t\t}\n\t\tconst seq = this.region.emit(entry.ordinal, copy, truncated, this.now());\n\t\tthis.harness?.emitted(seq);\n\t}\n\n\t/** @internal A library event under the reserved prefix. */\n\temitLibrary(name: string, payload: Record<string, unknown>): void {\n\t\tif (this.region.flags[FLAG_ATTACHED] === 0) return;\n\t\tconst ordinal = this.libraryEvents.get(name);\n\t\tif (ordinal === undefined) throw new Error(`${name} is not a library event`);\n\t\tconst seq = this.region.emit(ordinal, payload, false, this.now());\n\t\tthis.harness?.emitted(seq);\n\t}\n\n\t/** @internal The declared event for a ring slot's ordinal, or the library event's name. */\n\teventName(ordinal: number): string {\n\t\tif (ordinal < 0) return LIBRARY_EVENTS[LIBRARY_EVENT_BASE - ordinal] ?? `abai.unknown.${ordinal}`;\n\t\treturn this.manifest.events[ordinal]?.name ?? `unknown.${ordinal}`;\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Capabilities and safepoints (section 5.3)\n\t// -----------------------------------------------------------------------\n\n\t/** Register the handler of a declared capability (or replace one given at declaration). */\n\tcapability(name: string, handler: CapabilityHandler): void {\n\t\tif (!this.manifest.capabilities.some((c) => c.name === name)) {\n\t\t\tthrow new Error(`${this.name} declares no capability ${name}`);\n\t\t}\n\t\tthis.capabilityHandlers.set(name, handler);\n\t}\n\n\t/** @internal */\n\tcapabilityHandler(name: string): CapabilityHandler | undefined {\n\t\treturn this.capabilityHandlers.get(name);\n\t}\n\n\t/** @internal Queue work for the next safepoint; the binding uses it for safepoint dispatch. */\n\tenqueue(work: () => void): void {\n\t\tthis.queue.push(work);\n\t\tthis.region.flags[FLAG_QUEUE] = this.queue.length;\n\t\tthis.region.flags[FLAG_WORK] = 1;\n\t}\n\n\t/** One load of a flag when nothing is queued and no pause is in effect. */\n\tsafepoint(): void {\n\t\tif (this.region.flags[FLAG_WORK] === 0) return;\n\t\tthis.drain();\n\t}\n\n\t/** @internal Remove queued work that will not run (a timed-out dispatch). */\n\tdequeue(work: () => void): void {\n\t\tconst index = this.queue.indexOf(work);\n\t\tif (index === -1) return;\n\t\tthis.queue.splice(index, 1);\n\t\tconst flags = this.region.flags;\n\t\tflags[FLAG_QUEUE] = this.queue.length;\n\t\tif (this.queue.length === 0 && flags[FLAG_PAUSED] === 0) flags[FLAG_WORK] = 0;\n\t}\n\n\t/** @internal Run everything queued, now, on this thread: a touchpoint holds the program at a safepoint. */\n\tdrain(): void {\n\t\tconst flags = this.region.flags;\n\t\twhile (this.queue.length > 0) {\n\t\t\tconst work = this.queue.shift() as () => void;\n\t\t\tflags[FLAG_QUEUE] = this.queue.length;\n\t\t\ttry {\n\t\t\t\twork();\n\t\t\t} catch {\n\t\t\t\t// a handler's failure is reported through its reply, never through the program's safepoint\n\t\t\t}\n\t\t}\n\t\tflags[FLAG_WORK] = flags[FLAG_PAUSED] !== 0 ? 1 : 0;\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Decisions and turns (sections 5.4, 4.3)\n\t// -----------------------------------------------------------------------\n\n\tprivate applyDefault(decl: DecisionDecl, cause: string): unknown {\n\t\tif (decl.default === \"abort\") throw new AbaigramAbort(decl.name, cause);\n\t\treturn decl.default;\n\t}\n\n\t/** Ask which way to go. With no harness attached the default applies at once and is counted. */\n\tasync decide<T = unknown>(name: string, context: Record<string, unknown> = {}): Promise<T> {\n\t\tconst index = this.decisionIndex.get(name);\n\t\tif (index === undefined) throw new Error(`${this.name} declares no decision ${name}`);\n\t\tconst decl = this.manifest.decisions[index];\n\t\tconst harness = this.harness;\n\t\tif (this.region.flags[FLAG_ATTACHED] === 0 || harness === undefined) {\n\t\t\tthis.region.counters[index] += 1;\n\t\t\treturn this.applyDefault(decl, \"no_harness\") as T;\n\t\t}\n\t\t// a cooperative pause holds the decision here; its own clock starts when the pause lifts (4.3)\n\t\tif (this.paused) await this.awaitResume(name);\n\t\tif (this.region.flags[FLAG_ATTACHED] === 0 || this.harness === undefined) {\n\t\t\tthis.region.counters[index] += 1;\n\t\t\treturn this.applyDefault(decl, \"no_harness\") as T;\n\t\t}\n\t\tthis.drain();\n\t\ttry {\n\t\t\treturn (await this.harness.decide(decl, context, this.now() + durationMs(decl.timeout))) as T;\n\t\t} catch (error) {\n\t\t\treturn this.applyDefault(decl, error instanceof Error ? error.message : String(error)) as T;\n\t\t}\n\t}\n\n\t/** Give the agent a turn. With no harness attached it returns at once and is counted. */\n\tasync turn(name: string): Promise<void> {\n\t\tconst index = this.turnIndex.get(name);\n\t\tif (index === undefined) throw new Error(`${this.name} declares no turn ${name}`);\n\t\tconst decl = this.manifest.turns[index];\n\t\tconst harness = this.harness;\n\t\tif (this.region.flags[FLAG_ATTACHED] === 0 || harness === undefined) {\n\t\t\tthis.region.counters[this.manifest.decisions.length + index] += 1;\n\t\t\treturn;\n\t\t}\n\t\tif (this.paused) await this.awaitResume(name);\n\t\tif (this.region.flags[FLAG_ATTACHED] === 0 || this.harness === undefined) {\n\t\t\tthis.region.counters[this.manifest.decisions.length + index] += 1;\n\t\t\treturn;\n\t\t}\n\t\tthis.drain();\n\t\ttry {\n\t\t\tawait this.harness.turn(decl, this.now() + durationMs(decl.timeout));\n\t\t} catch {\n\t\t\t// a turn that fails is a turn that ended\n\t\t}\n\t\tthis.drain();\n\t}\n\n\t/** The counters, by kind and name: defaulted decisions, skipped turns, and the mode fallback. */\n\tcounters(): CounterSnapshot {\n\t\tconst snapshot: CounterSnapshot = {};\n\t\tthis.manifest.decisions.forEach((decl, i) => {\n\t\t\tsnapshot[`decision:${decl.name}`] = this.region.counters[i];\n\t\t});\n\t\tthis.manifest.turns.forEach((decl, i) => {\n\t\t\tsnapshot[`turn:${decl.name}`] = this.region.counters[this.manifest.decisions.length + i];\n\t\t});\n\t\tsnapshot[\"abai.mode_fallback\"] = this.region.counters[this.region.counters.length - 1];\n\t\treturn snapshot;\n\t}\n\n\t/** @internal Read and reset the counters, for the harness that attaches. */\n\ttakeCounters(): CounterSnapshot {\n\t\tconst snapshot = this.counters();\n\t\tthis.region.counters.fill(0);\n\t\treturn snapshot;\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Attaching (section 4.3)\n\t// -----------------------------------------------------------------------\n\n\t/** @internal The binding attaches a harness. */\n\tsetHarness(harness: AttachedHarness): void {\n\t\tthis.harness = harness;\n\t\tthis.region.flags[FLAG_ATTACHED] = 1;\n\t\tthis.lastAttachError = undefined;\n\t}\n\n\t/** @internal The binding detaches it; a decision in flight takes its default with `reason`. */\n\tclearHarness(reason: string): void {\n\t\tconst harness = this.harness;\n\t\tthis.harness = undefined;\n\t\tthis.binding = undefined;\n\t\tthis.nullHarness = undefined;\n\t\tthis.region.flags[FLAG_ATTACHED] = 0;\n\t\tthis.lastAttachError = reason;\n\t\t// a pause is the attached harness's: when the harness goes the program runs as itself again (6.3)\n\t\tthis.resumeFromPause();\n\t\tharness?.detach(reason);\n\t}\n\n\t/** The direct binding, while an in-process harness is attached. */\n\tget directBinding(): HarnessBinding | undefined {\n\t\treturn this.binding;\n\t}\n\n\t/** The null harness, while one is attached. */\n\tget attachedNullHarness(): NullHarness | undefined {\n\t\treturn this.nullHarness;\n\t}\n\n\tprivate createBinding(connection?: string): DirectBinding {\n\t\tconst binding = new DirectBinding(this, {\n\t\t\t...(this.auditPathOverride === undefined ? {} : { auditPath: this.auditPathOverride }),\n\t\t\t...(connection === undefined ? {} : { connection }),\n\t\t});\n\t\tthis.binding = binding;\n\t\tthis.setHarness(binding);\n\t\tbinding.flushCounters();\n\t\treturn binding;\n\t}\n\n\t/**\n\t * @internal A front end of the library's own (the sidecar endpoint)\n\t * attaches the program through a binding it then drives; the connection's\n\t * id labels its acts in the audit. Refused while something else is\n\t * attached: a second harness would take the program over silently.\n\t */\n\tbind(connection: string): DirectBinding {\n\t\tif (this.attached) {\n\t\t\tthrow new Error(`${this.name} already has a harness attached; this connection cannot take it over`);\n\t\t}\n\t\tif (this.launched) this.launcherSeen = true;\n\t\treturn this.createBinding(connection);\n\t}\n\n\tprivate attachNull(form: \"null\" | \"exercise\"): void {\n\t\tconst binding = this.createBinding();\n\t\tthis.nullHarness = attachNullHarness(binding, form);\n\t\tif (form === \"exercise\") {\n\t\t\tconst harness = this.nullHarness;\n\t\t\tprocess.once(\"exit\", () => {\n\t\t\t\tif (this.nullHarness === harness) this.report(JSON.stringify(harness.report()));\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Connect or spawn a harness (one of the five places). Resolves true when\n\t * attached. The real harness arrives through the `harness` extra, or the\n\t * harness package's dynamic import once it exists; until then the reason\n\t * is recorded.\n\t */\n\tasync attach(): Promise<boolean> {\n\t\tif (this.attached) return true;\n\t\tswitch (this.harnessSelection) {\n\t\t\tcase \"off\":\n\t\t\t\tthis.lastAttachError = `${ENV_HARNESS}=off`;\n\t\t\t\treturn false;\n\t\t\tcase \"null\":\n\t\t\tcase \"exercise\":\n\t\t\t\tthis.attachNull(this.harnessSelection);\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\tif (this.harnessSelectionError !== undefined) {\n\t\t\t\t\tthis.lastAttachError = this.harnessSelectionError;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (this.endpoint) {\n\t\t\t\t\t// launched: the parent is already connecting; the program never spawns anything itself\n\t\t\t\t\treturn this.launched ? this.awaitLauncher(this.endpoint) : this.attachSidecar(this.endpoint);\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst factory =\n\t\t\t\t\t\tthis.harnessFactory ??\n\t\t\t\t\t\t(await installedHarness(\n\t\t\t\t\t\t\tthis.env[ENV_HARNESS_MODULE] || this.manifest.harness?.path || \"@abaigram/abai-embedded-harness\",\n\t\t\t\t\t\t));\n\t\t\t\t\tif (factory === undefined) {\n\t\t\t\t\t\tthis.lastAttachError =\n\t\t\t\t\t\t\t\"no harness is installed (the @abaigram/abai-embedded-harness package is not resolvable)\";\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tconst binding = this.createBinding();\n\t\t\t\t\tawait factory(binding);\n\t\t\t\t\treturn this.attached;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tthis.binding?.detach(reason);\n\t\t\t\t\tthis.lastAttachError = reason;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t}\n\t}\n\n\t/** Under launch: the launcher connects to the socket it chose; the program waits for it once, bounded. */\n\tprivate async awaitLauncher(endpoint: Endpoint): Promise<boolean> {\n\t\ttry {\n\t\t\tawait endpoint.ready;\n\t\t} catch (error) {\n\t\t\tthis.lastAttachError = `the endpoint could not listen: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\treturn false;\n\t\t}\n\t\tif (this.attached) return true;\n\t\tif (this.launcherSeen) {\n\t\t\t// it was here and went: a later attach place returns at once, as 4.3 says of every touchpoint after a detach\n\t\t\tthis.lastAttachError = this.lastAttachError ?? \"the launcher disconnected\";\n\t\t\treturn false;\n\t\t}\n\t\tconst waitMs = attachWaitMsFrom(this.env);\n\t\tif (await endpoint.waitForConnection(waitMs)) {\n\t\t\tthis.launcherSeen = true;\n\t\t\treturn true;\n\t\t}\n\t\tthis.lastAttachError = `launched, but the launcher did not connect within ${waitMs} ms`;\n\t\treturn false;\n\t}\n\n\t/**\n\t * Sidecar attach (section 6.3): a harness already connected to the\n\t * endpoint means attached; otherwise the harness binary is spawned with\n\t * the terminal inherited and given `ABAI_ATTACH_WAIT_MS` to connect. A\n\t * child that exits first fails the attach at once with its code, so an\n\t * unconfigured machine costs well under a second (section 4.3); a child\n\t * that never connects is ended at the wait and the attach fails with the\n\t * reason. The child is unref'd: a program whose work is done exits, and\n\t * the closing socket tells the harness.\n\t */\n\tprivate async attachSidecar(endpoint: Endpoint): Promise<boolean> {\n\t\ttry {\n\t\t\tawait endpoint.ready;\n\t\t} catch {\n\t\t\t// spawnHarness reports it\n\t\t}\n\t\t// a harness that connected while the endpoint came up, or at any time before: attached already\n\t\tif (this.attached) return true;\n\t\tconst spawned = await this.spawnHarness(endpoint, \"attach\");\n\t\treturn spawned !== undefined;\n\t}\n\n\t/**\n\t * Spawn the harness binary with a verb against this program's endpoint\n\t * and wait for it to connect. Resolves to the child once attached, or to\n\t * undefined with the reason in `attachError`: the endpoint could not\n\t * listen, the child exited first (its code), it never connected within\n\t * the wait (it is ended), or it could not be started at all.\n\t */\n\tprivate async spawnHarness(endpoint: Endpoint, verb: \"attach\" | \"mcp\"): Promise<ChildProcess | undefined> {\n\t\ttry {\n\t\t\tawait endpoint.ready;\n\t\t} catch (error) {\n\t\t\tthis.lastAttachError = `the endpoint could not listen: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\treturn undefined;\n\t\t}\n\t\tconst waitMs = attachWaitMsFrom(this.env);\n\t\tconst binary = harnessBinary(this.env, this.content.root);\n\t\tconst args = [...binary.args, verb, \"--target\", endpoint.socketPath, \"--run-dir\", endpoint.runDir];\n\t\tlet child: ChildProcess;\n\t\ttry {\n\t\t\tchild = spawn(binary.command, args, { stdio: \"inherit\", env: { ...process.env, ...this.env } });\n\t\t} catch (error) {\n\t\t\tthis.lastAttachError = `the harness binary could not be started: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\treturn undefined;\n\t\t}\n\t\tchild.unref();\n\t\t// a ChildProcess with no error listener throws into the program; one stays for the child's whole life\n\t\tchild.on(\"error\", () => {});\n\t\tconst outcome = await new Promise<string>((resolve) => {\n\t\t\tlet settled = false;\n\t\t\tconst settle = (result: string): void => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\tchild.off(\"exit\", onExit);\n\t\t\t\tchild.off(\"error\", onError);\n\t\t\t\tresolve(result);\n\t\t\t};\n\t\t\tconst onExit = (code: number | null, signal: NodeJS.Signals | null): void =>\n\t\t\t\tsettle(`exited:${code === null ? `signal ${signal ?? \"unknown\"}` : String(code)}`);\n\t\t\tconst onError = (error: NodeJS.ErrnoException): void => settle(`error:${error.code ?? error.message}`);\n\t\t\tchild.once(\"exit\", onExit);\n\t\t\tchild.once(\"error\", onError);\n\t\t\tvoid endpoint.waitForConnection(waitMs).then((connected) => settle(connected ? \"connected\" : \"timeout\"));\n\t\t});\n\t\tif (outcome === \"connected\") return child;\n\t\tif (outcome === \"timeout\") {\n\t\t\t// the one process this program started, by its own handle: nothing else is touched\n\t\t\tchild.kill();\n\t\t\tthis.lastAttachError = `the harness binary did not connect within ${waitMs} ms (${binary.command})`;\n\t\t\treturn undefined;\n\t\t}\n\t\tif (outcome.startsWith(\"exited:\")) {\n\t\t\tthis.lastAttachError = `the harness binary exited with ${outcome.slice(\"exited:\".length)} before connecting`;\n\t\t\treturn undefined;\n\t\t}\n\t\tthis.lastAttachError = `the harness binary could not be started: ${outcome.slice(\"error:\".length)} (${binary.command})`;\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * @internal `<prog> abai mcp` under sidecar: the binary's MCP server is\n\t * spawned against this program's endpoint with the terminal inherited, so\n\t * the MCP client on this process's stdin and stdout talks to it, and the\n\t * program waits at its entry, a safepoint it holds open, until the client\n\t * goes. Resolves to the child's exit code; -1 when nothing could be\n\t * spawned (the reason is in `attachError`).\n\t */\n\tasync serveMcpSidecar(endpoint: Endpoint): Promise<number> {\n\t\tif (this.attached) {\n\t\t\tthis.lastAttachError = `${this.name} already has a harness attached`;\n\t\t\treturn -1;\n\t\t}\n\t\tconst child = await this.spawnHarness(endpoint, \"mcp\");\n\t\tif (child === undefined) return -1;\n\t\t// the program's whole purpose now is to wait for its server: the child holds the event loop open,\n\t\t// where the spawn left it unref'd for the attach case, whose touchpoint holds the loop itself\n\t\tchild.ref();\n\t\t// the MCP client spawned this program and ends it with a signal; the server behind it must go too\n\t\tconst forward = (signal: NodeJS.Signals): void => {\n\t\t\tif (child.exitCode === null && child.signalCode === null) child.kill(signal);\n\t\t};\n\t\tconst forwarded: NodeJS.Signals[] = [\"SIGTERM\", \"SIGINT\", \"SIGHUP\"];\n\t\tfor (const signal of forwarded) process.on(signal, forward);\n\t\tconst binding = this.binding;\n\t\tbinding?.enterSafepoint();\n\t\ttry {\n\t\t\tif (child.exitCode !== null) return child.exitCode;\n\t\t\treturn await new Promise<number>((resolve) => {\n\t\t\t\tchild.once(\"exit\", (code) => resolve(code ?? 1));\n\t\t\t});\n\t\t} finally {\n\t\t\tfor (const signal of forwarded) process.off(signal, forward);\n\t\t\tbinding?.leaveSafepoint();\n\t\t}\n\t}\n\n\tprivate async touchpoint(kind: TouchpointKind): Promise<void> {\n\t\tif (!(await this.attach())) return;\n\t\tif (this.paused) await this.awaitResume(kind);\n\t\tconst binding = this.binding;\n\t\tif (!binding) return;\n\t\tthis.drain();\n\t\tawait binding.touchpoint(kind);\n\t\tthis.drain();\n\t}\n\n\t/** Run the install touchpoint; returns when the harness finishes, or at once when none can be attached. */\n\tinstall(): Promise<void> {\n\t\treturn this.touchpoint(\"install\");\n\t}\n\n\t/** Open a session; returns when the harness ends it, or at once when none can be attached. */\n\tsession(): Promise<void> {\n\t\treturn this.touchpoint(\"session\");\n\t}\n}\n\n/** Overrides where the in-process harness is imported from (a path or a package name). */\nexport const ENV_HARNESS_MODULE = \"ABAI_HARNESS_MODULE\";\n\n/**\n * The harness binary to spawn under sidecar: `ABAI_HARNESS_BIN` (a script\n * path runs under this very node), else the program's own\n * `node_modules/.bin/abai-embedded-harness`, else the name on PATH.\n */\nexport function harnessBinary(env: NodeJS.ProcessEnv, root: string): { command: string; args: string[] } {\n\tconst explicit = env[ENV_HARNESS_BIN]?.trim();\n\tif (explicit) {\n\t\treturn /\\.(?:[mc]?js|ts)$/.test(explicit)\n\t\t\t? { command: process.execPath, args: [explicit] }\n\t\t\t: { command: explicit, args: [] };\n\t}\n\tconst local = join(root, \"node_modules\", \".bin\", \"abai-embedded-harness\");\n\tif (existsSync(local)) return { command: local, args: [] };\n\treturn { command: \"abai-embedded-harness\", args: [] };\n}\n\n/** What the stub uses of the installed harness package. */\nexport interface HarnessModule {\n\tattachEmbedded?: (binding: HarnessBinding) => Promise<unknown>;\n\t/** `<prog> abai mcp` in-process: serve this binding to the MCP client on the process's stdio; resolves to the exit code. */\n\tserveMcpEmbedded?: (binding: HarnessBinding) => Promise<number>;\n\trunConfig?: (\n\t\targs: string[],\n\t\tio: { out(text: string): void; err(text: string): void; env: NodeJS.ProcessEnv },\n\t) => Promise<number>;\n\tdoctorOnline?: (\n\t\tmanifest: Manifest,\n\t\tenv: NodeJS.ProcessEnv,\n\t) => Promise<Array<{ name: string; status: \"ok\" | \"fail\" | \"skip\"; detail: string }>>;\n}\n\n/** The harness package, found by dynamic import when a program installed it; undefined when it does not resolve. */\nexport async function importHarnessModule(\n\tenv: NodeJS.ProcessEnv,\n\tmanifest: Manifest,\n): Promise<HarnessModule | undefined> {\n\tconst specifier = env[ENV_HARNESS_MODULE] || manifest.harness?.path || \"@abaigram/abai-embedded-harness\";\n\ttry {\n\t\treturn (await import(specifier)) as HarnessModule;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The harness package's in-process entry. */\nasync function installedHarness(specifier: string): Promise<HarnessFactory | undefined> {\n\tlet module: HarnessModule;\n\ttry {\n\t\tmodule = (await import(specifier)) as HarnessModule;\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (typeof module.attachEmbedded !== \"function\") return undefined;\n\tconst attach = module.attachEmbedded;\n\treturn async (binding) => {\n\t\tawait attach(binding);\n\t};\n}\n\n/** The program's one call: declarations in, the abaigram out. Throws when a declaration does not validate. */\nexport function createAbaigram(options: AbaigramOptions, extras: AbaigramExtras = {}): Abaigram {\n\treturn new Abaigram(options, extras);\n}\n"]}
1
+ {"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":";;;;;;;;AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,kEAAkE;AAClE,sEAAsE;AACtE,4EAA4E;AAC5E,yEAAyE;AACzE,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,uEAAuE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,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AAAA,CACD;AAED,8CAA8C;AAC9C,KAAK,UAAU,gBAAgB,CAAC,SAAiB,EAAuC;IACvF,IAAI,MAAqB,CAAC;IAC1B,IAAI,CAAC;QACJ,MAAM,GAAG,CAAC,MAAM,MAAM,kCAAC,SAAS,EAAC,CAAkB,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,cAAc,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IAClE,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC;IACrC,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC;QACzB,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;IAAA,CACtB,CAAC;AAAA,CACF;AAED,8GAA8G;AAC9G,MAAM,UAAU,cAAc,CAAC,OAAwB,EAAE,MAAM,GAAmB,EAAE,EAAY;IAC/F,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAAA,CACrC","sourcesContent":["// createAbaigram: the program-facing API of the stub (abaigrammar sections 4\n// and 5). The program declares its manifest in code, obtains cell, knob and\n// event handles once, and then writes cells, emits events, serves\n// capabilities and calls touchpoints. With no harness attached, every\n// operation here costs what section 11.1 says: cell writes store, emits and\n// safepoints load one flag, decisions and turns load the flag and count.\n//\n// Touchpoints are awaited promises (see the instantiation's deviations in\n// registry.ts). The attached paths arrive with the harness binding; this\n// file carries the detached behaviour and the seams the binding fills.\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fitValue } from \"./cells/fit.ts\";\nimport { type ContentSlots, createContent, findRoot } from \"./content.ts\";\nimport { Endpoint } from \"./endpoint.ts\";\nimport {\n\tattachWaitMsFrom,\n\tENV_HARNESS,\n\tENV_HARNESS_BIN,\n\tENV_LAUNCH_SOCKET,\n\ttype HarnessSelection,\n\trunDirFrom,\n\tselectHarness,\n\tselectMode,\n} from \"./env.ts\";\nimport { DirectBinding, type HarnessBinding, type TouchpointKind } from \"./harness-binding.ts\";\nimport {\n\ttype CellDecl,\n\tcutUtf8,\n\ttype DecisionDecl,\n\tdurationMs,\n\ttype EventDecl,\n\tencodedBytes,\n\tfieldOf,\n\tLIBRARY_EVENTS,\n\ttype Manifest,\n\ttype Mode,\n\ttype TurnDecl,\n} from \"./manifest/manifest.ts\";\nimport { attachNullHarness, type NullHarness } from \"./null-harness.ts\";\nimport { FLAG_ATTACHED, FLAG_PAUSED, FLAG_QUEUE, FLAG_WORK, LIBRARY_EVENT_BASE, Region } from \"./region.ts\";\nimport {\n\ttype AbaigramOptions,\n\tbuildManifest,\n\ttype CapabilityHandler,\n\ttype KnobHandler,\n\ttype StopHandler,\n} from \"./registry.ts\";\n\n/** Thrown by `decide` when the applied default is `abort` (section 5.4). */\nexport class AbaigramAbort extends Error {\n\treadonly decision: string;\n\tconstructor(decision: string, cause: string) {\n\t\tsuper(`decision ${decision} applied its default, abort (${cause})`);\n\t\tthis.name = \"AbaigramAbort\";\n\t\tthis.decision = decision;\n\t}\n}\n\nexport interface CellHandle<T = unknown> {\n\treadonly name: string;\n\tget(): T;\n\t/** One store to the value and one to the version. Enum values must be declared; nothing else is checked. */\n\tset(value: T): void;\n}\n\nexport interface KnobHandle<T = unknown> extends CellHandle<T> {\n\t/** Back to the declared default; a sized knob's reset reaches the harness as `abai.knob.reset`. */\n\treset(): void;\n\t/** Sized knobs only: the handler that receives a delivered value at a safepoint. */\n\tonChange(handler: KnobHandler): void;\n}\n\nexport interface EventHandle {\n\treadonly name: string;\n\t/** One load of the attached flag when no harness is attached. */\n\temit(payload?: Record<string, unknown>): void;\n}\n\nexport interface CounterSnapshot {\n\t[name: string]: number;\n}\n\n/** What a harness binding supplies once attached; undefined while detached. */\nexport interface AttachedHarness {\n\t/** Ask the harness; resolves to the answer, or rejects with the cause of a default. */\n\tdecide(decision: DecisionDecl, context: Record<string, unknown>, deadlineMs: number): Promise<unknown>;\n\t/** Give the harness a turn; resolves when it is done or the timeout passes. */\n\tturn(turn: TurnDecl, deadlineMs: number): Promise<void>;\n\t/** An event was published; `seq` is its sequence number. */\n\temitted(seq: number): void;\n\t/** The program detaches it. */\n\tdetach(reason: string): void;\n}\n\ninterface CellEntry {\n\tdecl: CellDecl;\n\t/** Position in `manifest.cells`: the index into `versions`. */\n\tordinal: number;\n\t/** Index into `values` (scalar) or `sized`. */\n\tslot: number;\n\tscalar: boolean;\n\tenumIndex?: Map<string, number>;\n\t/** Built once per cell: the typed store and load (section 11.2 rows). */\n\tset: (value: unknown) => void;\n\tget: () => unknown;\n}\n\ninterface EventEntry {\n\tdecl: EventDecl;\n\tordinal: number;\n\tfields: Array<{ key: string; type: string; max: number | undefined }>;\n}\n\n/** Attaches an in-process harness to the binding the stub hands it. */\nexport type HarnessFactory = (binding: HarnessBinding) => void | Promise<void>;\n\nexport interface AbaigramExtras {\n\t/** The program's root, where abaigram.yaml and the content live. Default: found from the cwd on first use, else the cwd. */\n\troot?: string;\n\tenv?: NodeJS.ProcessEnv;\n\t/** Injectable clock. */\n\tnow?: () => number;\n\t/** The in-process harness for turns mode; overrides the dynamic import of the harness package. */\n\tharness?: HarnessFactory;\n\t/** Where the audit log goes; default: the manifest's path. */\n\tauditPath?: string;\n\t/** For the exercise form: where its report goes at exit. Default: stderr. */\n\treport?: (text: string) => void;\n}\n\nexport class Abaigram {\n\treadonly manifest: Manifest;\n\treadonly mode: Mode;\n\treadonly modeFallback: boolean;\n\treadonly harnessSelection: HarnessSelection;\n\t/** A problem with the environment's harness selection, reported by doctor, never thrown. */\n\treadonly harnessSelectionError: string | undefined;\n\treadonly content: ContentSlots;\n\t/**\n\t * The sidecar endpoint, listening from startup when the selected mode is\n\t * sidecar and a real harness is wanted (section 6.3). A check run under\n\t * `ABAI_HARNESS` keeps its null harness in-process and opens no socket.\n\t */\n\treadonly endpoint: Endpoint | undefined;\n\t/** A launcher handed this program its connection (section 6.3): the full lifecycle is available to it. */\n\treadonly launched: boolean = false;\n\treadonly startedAt: string = new Date().toISOString();\n\t/** The root given at construction, if any; otherwise the root is found lazily. */\n\treadonly explicitRoot: string | undefined;\n\t/** @internal The region; tests and the binding reach it, programs do not. */\n\treadonly region: Region;\n\treadonly now: () => number;\n\n\tprivate readonly cellEntries = new Map<string, CellEntry>();\n\tprivate readonly eventEntries = new Map<string, EventEntry>();\n\tprivate readonly libraryEvents = new Map<string, number>();\n\tprivate readonly cellHandles = new Map<string, CellHandle>();\n\tprivate readonly eventHandles = new Map<string, EventHandle>();\n\tprivate readonly knobHandlers = new Map<string, KnobHandler>();\n\tprivate readonly capabilityHandlers = new Map<string, CapabilityHandler>();\n\tprivate readonly decisionIndex = new Map<string, number>();\n\tprivate readonly turnIndex = new Map<string, number>();\n\tprivate readonly queue: Array<() => void> = [];\n\tprivate harness: AttachedHarness | undefined;\n\tprivate binding: DirectBinding | undefined;\n\tprivate nullHarness: NullHarness | undefined;\n\tprivate lastAttachError: string | undefined;\n\tprivate readonly harnessFactory: HarnessFactory | undefined;\n\tprivate readonly auditPathOverride: string | undefined;\n\tprivate readonly report: (text: string) => void;\n\tprivate readonly env: NodeJS.ProcessEnv;\n\treadonly stopHandler: StopHandler | undefined;\n\t/** Who waits for a cooperative pause to lift, and the ref'd timer that keeps a paused program alive. */\n\tprivate resumeWaiters: Array<() => void> = [];\n\tprivate pauseKeepAlive: NodeJS.Timeout | undefined;\n\t/** Under launch: the launcher connected at least once, so nothing waits for it a second time. */\n\tprivate launcherSeen = false;\n\n\tconstructor(options: AbaigramOptions, extras: AbaigramExtras = {}) {\n\t\tthis.manifest = buildManifest(options);\n\t\tthis.now = extras.now ?? Date.now;\n\t\tconst env = extras.env ?? process.env;\n\t\tthis.env = env;\n\t\tconst selection = selectMode(this.manifest.modes, env);\n\t\tthis.mode = selection.mode;\n\t\tthis.modeFallback = selection.fallback;\n\t\tconst harness = selectHarness(env);\n\t\tthis.harnessSelection = harness.selection;\n\t\tthis.harnessSelectionError = harness.error;\n\t\tthis.stopHandler = options.lifecycle?.stop?.handler;\n\t\tthis.explicitRoot = extras.root;\n\t\tthis.harnessFactory = extras.harness;\n\t\tthis.auditPathOverride = extras.auditPath;\n\t\tthis.report =\n\t\t\textras.report ??\n\t\t\t((text) => {\n\t\t\t\tprocess.stderr.write(`${text}\\n`);\n\t\t\t});\n\n\t\tlet scalars = 0;\n\t\tlet sized = 0;\n\t\tconst pending: Array<[CellDecl, number, number, boolean]> = [];\n\t\tthis.manifest.cells.forEach((decl, ordinal) => {\n\t\t\tconst scalar = decl.type !== \"string\" && decl.type !== \"object\" && decl.type !== \"list\";\n\t\t\tpending.push([decl, ordinal, scalar ? scalars++ : sized++, scalar]);\n\t\t});\n\t\tthis.manifest.decisions.forEach((decl, i) => {\n\t\t\tthis.decisionIndex.set(decl.name, i);\n\t\t});\n\t\tthis.manifest.turns.forEach((decl, i) => {\n\t\t\tthis.turnIndex.set(decl.name, i);\n\t\t});\n\t\tthis.region = new Region({\n\t\t\tscalars,\n\t\t\tsized,\n\t\t\tcounters: this.manifest.decisions.length + this.manifest.turns.length + 1,\n\t\t});\n\t\tif (this.modeFallback) this.region.counters[this.region.counters.length - 1] += 1;\n\t\tfor (const [decl, ordinal, slot, scalar] of pending)\n\t\t\tthis.cellEntries.set(decl.name, this.makeEntry(decl, ordinal, slot, scalar));\n\n\t\tthis.manifest.events.forEach((decl, ordinal) => {\n\t\t\tconst fields = Object.entries(decl.payload).map(([key, field]) => {\n\t\t\t\tconst f = fieldOf(field);\n\t\t\t\treturn { key, type: f.type, max: f.max };\n\t\t\t});\n\t\t\tthis.eventEntries.set(decl.name, { decl, ordinal, fields });\n\t\t});\n\t\tLIBRARY_EVENTS.forEach((name, i) => {\n\t\t\tthis.libraryEvents.set(name, LIBRARY_EVENT_BASE - i);\n\t\t});\n\n\t\tfor (const [name, cell] of Object.entries(options.cells ?? {})) {\n\t\t\tif (cell.access === \"readwrite\") {\n\t\t\t\tthis.cellEntries.get(name)?.set(cell.default);\n\t\t\t\tif (cell.onChange) this.knobHandlers.set(name, cell.onChange);\n\t\t\t}\n\t\t}\n\t\tfor (const [name, capability] of Object.entries(options.capabilities ?? {})) {\n\t\t\tif (capability.handler) this.capabilityHandlers.set(name, capability.handler);\n\t\t}\n\t\t// the root is found on first use, so a program that never attaches never touches the filesystem\n\t\tthis.content = createContent(this.manifest, () => extras.root ?? findRoot(this.manifest.name) ?? process.cwd());\n\t\t// startup is one of the five places (section 4.3): a null harness attaches here\n\t\tif (this.harnessSelection === \"null\" || this.harnessSelection === \"exercise\")\n\t\t\tthis.attachNull(this.harnessSelection);\n\t\t// sidecar: the receiving end waits from startup (section 6.3); its failure to listen is a reason\n\t\t// the next attach reports, never a throw into the program\n\t\tconst launchSocket = env[ENV_LAUNCH_SOCKET]?.trim();\n\t\tif (this.mode === \"sidecar\" && this.harnessSelection === \"real\") {\n\t\t\t// launched: the parent chose the socket and is waiting on it. Read once and removed, so a program\n\t\t\t// that spawns a copy of itself never hands it this very socket\n\t\t\tthis.launched = launchSocket !== undefined && launchSocket !== \"\";\n\t\t\tif (this.launched && env === process.env) delete process.env[ENV_LAUNCH_SOCKET];\n\t\t\tthis.endpoint = new Endpoint(this, {\n\t\t\t\trunDir: this.launched ? dirname(launchSocket as string) : runDirFrom(env),\n\t\t\t\t...(this.launched ? { socketPath: launchSocket as string } : {}),\n\t\t\t});\n\t\t\tthis.endpoint.ready.catch((error: unknown) => {\n\t\t\t\tthis.lastAttachError = `the endpoint could not listen: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\t});\n\t\t} else if (launchSocket !== undefined && launchSocket !== \"\") {\n\t\t\t// a launcher is waiting, but this program cannot take the connection up: it runs as itself, observed\n\t\t\t// from outside only (section 5.7), and says why when asked\n\t\t\tif (env === process.env) delete process.env[ENV_LAUNCH_SOCKET];\n\t\t\tthis.lastAttachError =\n\t\t\t\tthis.harnessSelection === \"real\"\n\t\t\t\t\t? `launched, but ${this.manifest.name} declares no sidecar mode (declared: ${this.manifest.modes.join(\", \")})`\n\t\t\t\t\t: `launched under ${ENV_HARNESS}=${this.harnessSelection}`;\n\t\t}\n\t}\n\n\tget name(): string {\n\t\treturn this.manifest.name;\n\t}\n\n\tget attached(): boolean {\n\t\treturn this.region.flags[FLAG_ATTACHED] !== 0;\n\t}\n\n\t/** Why the last attach did not happen, if it did not. */\n\tget attachError(): string | undefined {\n\t\treturn this.lastAttachError;\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Cells and knobs (section 5.2)\n\t// -----------------------------------------------------------------------\n\n\t/** The typed store and load of one cell, built once so the hot path is the store alone. */\n\tprivate makeEntry(decl: CellDecl, ordinal: number, slot: number, scalar: boolean): CellEntry {\n\t\tconst { values, versions, sized } = this.region;\n\t\tconst entry: CellEntry = { decl, ordinal, slot, scalar, set: () => {}, get: () => undefined };\n\t\tif (!scalar) {\n\t\t\tentry.set = (value) => {\n\t\t\t\tsized[slot] = fitValue(value, decl);\n\t\t\t\tversions[ordinal] += 1;\n\t\t\t};\n\t\t\tentry.get = () => sized[slot];\n\t\t\treturn entry;\n\t\t}\n\t\tswitch (decl.type) {\n\t\t\tcase \"bool\":\n\t\t\t\tentry.set = (value) => {\n\t\t\t\t\tvalues[slot] = value ? 1 : 0;\n\t\t\t\t\tversions[ordinal] += 1;\n\t\t\t\t};\n\t\t\t\tentry.get = () => values[slot] !== 0;\n\t\t\t\tbreak;\n\t\t\tcase \"enum\": {\n\t\t\t\tconst index = new Map((decl.enum ?? []).map((value, i) => [value, i]));\n\t\t\t\tconst names = decl.enum ?? [];\n\t\t\t\tentry.enumIndex = index;\n\t\t\t\tentry.set = (value) => {\n\t\t\t\t\tconst i = index.get(value as string);\n\t\t\t\t\tif (i === undefined) throw new Error(`${decl.name}: ${String(value)} is not a declared value`);\n\t\t\t\t\tvalues[slot] = i;\n\t\t\t\t\tversions[ordinal] += 1;\n\t\t\t\t};\n\t\t\t\tentry.get = () => names[values[slot]];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tentry.set = (value) => {\n\t\t\t\t\tvalues[slot] = value as number;\n\t\t\t\t\tversions[ordinal] += 1;\n\t\t\t\t};\n\t\t\t\tentry.get = () => values[slot];\n\t\t}\n\t\treturn entry;\n\t}\n\n\tprivate entry(name: string): CellEntry {\n\t\tconst entry = this.cellEntries.get(name);\n\t\tif (!entry) throw new Error(`${this.name} declares no cell ${name}`);\n\t\treturn entry;\n\t}\n\n\t/** A handle, created once per cell and cached. */\n\tcell<T = unknown>(name: string): CellHandle<T> {\n\t\tconst cached = this.cellHandles.get(name);\n\t\tif (cached) return cached as CellHandle<T>;\n\t\tconst entry = this.entry(name);\n\t\tconst handle: CellHandle = { name, get: entry.get, set: entry.set };\n\t\tthis.cellHandles.set(name, handle);\n\t\treturn handle as CellHandle<T>;\n\t}\n\n\t/** A knob handle; the cell must be `readwrite`. */\n\tknob<T = unknown>(name: string): KnobHandle<T> {\n\t\tconst entry = this.entry(name);\n\t\tif (entry.decl.access !== \"readwrite\") throw new Error(`${name} is a read cell, not a knob`);\n\t\tconst handle = this.cell<T>(name) as KnobHandle<T>;\n\t\tif (handle.reset === undefined) {\n\t\t\thandle.reset = () => {\n\t\t\t\tentry.set(entry.decl.default);\n\t\t\t\tif (!entry.scalar) this.emitLibrary(\"abai.knob.reset\", { cell: name, value: entry.get() });\n\t\t\t};\n\t\t\thandle.onChange = (handler) => {\n\t\t\t\tif (entry.scalar) throw new Error(`${name} is a scalar knob; the program reads it, nothing is delivered`);\n\t\t\t\tthis.knobHandlers.set(name, handler);\n\t\t\t};\n\t\t}\n\t\treturn handle;\n\t}\n\n\t/** @internal The handler a sized knob delivers to, for the binding. */\n\tknobHandler(name: string): KnobHandler | undefined {\n\t\treturn this.knobHandlers.get(name);\n\t}\n\n\t/** @internal Every cell's current value, keyed by name, for the binding. */\n\treadCells(): Record<string, unknown> {\n\t\tconst cells: Record<string, unknown> = {};\n\t\tfor (const [name, entry] of this.cellEntries) cells[name] = entry.get();\n\t\treturn cells;\n\t}\n\n\t/** @internal A cell's version counter. */\n\tversion(name: string): number {\n\t\treturn this.region.versions[this.entry(name).ordinal];\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Lifecycle (section 5.5): what the program itself can do\n\t// -----------------------------------------------------------------------\n\n\t/** A cooperative pause is in effect. */\n\tget paused(): boolean {\n\t\treturn this.region.flags[FLAG_PAUSED] !== 0;\n\t}\n\n\t/**\n\t * @internal A cooperative pause: the flag is set, and the program is held\n\t * at its next touchpoint (this instantiation's deviation: a safepoint\n\t * cannot block the loop the resume arrives on). A ref'd timer keeps a\n\t * paused program alive, since nothing else of its own may be pending.\n\t */\n\trequestPause(): void {\n\t\tif (this.paused) return;\n\t\tthis.region.flags[FLAG_PAUSED] = 1;\n\t\tthis.region.flags[FLAG_WORK] = 1;\n\t\tthis.pauseKeepAlive = setInterval(() => {}, 2 ** 31 - 1);\n\t}\n\n\t/** @internal Lift the pause: whoever is held at a touchpoint goes on, their clocks starting now. */\n\tresumeFromPause(): void {\n\t\tif (!this.paused) return;\n\t\tthis.region.flags[FLAG_PAUSED] = 0;\n\t\tthis.region.flags[FLAG_WORK] = this.queue.length > 0 ? 1 : 0;\n\t\tif (this.pauseKeepAlive !== undefined) clearInterval(this.pauseKeepAlive);\n\t\tthis.pauseKeepAlive = undefined;\n\t\tfor (const waiter of this.resumeWaiters.splice(0)) waiter();\n\t}\n\n\t/** Hold here while a cooperative pause is in effect; the agent is told what the pause holds (4.3). */\n\tprivate awaitResume(touchpoint: string): Promise<void> {\n\t\tif (!this.paused) return Promise.resolve();\n\t\tthis.emitLibrary(\"abai.pause.blocked\", { touchpoint });\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tthis.resumeWaiters.push(resolve);\n\t\t});\n\t}\n\n\t/** @internal What the stub knows of its own process, for `lifecycle status`. */\n\tlifecycleStatus(): {\n\t\tpid: number;\n\t\tname: string;\n\t\tmode: string;\n\t\tcwd: string;\n\t\tstartedAt: string;\n\t\tconnections: number;\n\t\tpaused: boolean;\n\t\tlaunched: boolean;\n\t} {\n\t\treturn {\n\t\t\tpid: process.pid,\n\t\t\tname: this.manifest.name,\n\t\t\tmode: this.mode,\n\t\t\tcwd: process.cwd(),\n\t\t\tstartedAt: this.startedAt,\n\t\t\tconnections: this.endpoint?.connectionCount ?? (this.attached ? 1 : 0),\n\t\t\tpaused: this.paused,\n\t\t\tlaunched: this.launched,\n\t\t};\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Events (section 5.1)\n\t// -----------------------------------------------------------------------\n\n\t/** A handle for a declared event, created once and cached; the name is checked here, never on the hot path. */\n\tevent(name: string): EventHandle {\n\t\tconst cached = this.eventHandles.get(name);\n\t\tif (cached) return cached;\n\t\tconst entry = this.eventEntries.get(name);\n\t\tif (!entry) throw new Error(`${this.name} declares no event ${name}`);\n\t\tconst flags = this.region.flags;\n\t\tconst handle: EventHandle = {\n\t\t\tname,\n\t\t\temit: (payload = {}) => {\n\t\t\t\tif (flags[FLAG_ATTACHED] === 0) return;\n\t\t\t\tthis.publish(entry, payload);\n\t\t\t},\n\t\t};\n\t\tthis.eventHandles.set(name, handle);\n\t\treturn handle;\n\t}\n\n\t/** Copy the declared fields, cut sized ones to their max, publish, and tell the harness. */\n\tprivate publish(entry: EventEntry, payload: Record<string, unknown>): void {\n\t\tlet truncated = false;\n\t\tconst copy: Record<string, unknown> = {};\n\t\tfor (const field of entry.fields) {\n\t\t\tconst value = payload[field.key];\n\t\t\tif (value === undefined) continue;\n\t\t\tswitch (field.type) {\n\t\t\t\tcase \"string\": {\n\t\t\t\t\tconst text = String(value);\n\t\t\t\t\tconst cut = cutUtf8(text, field.max ?? 256);\n\t\t\t\t\tif (cut !== text) truncated = true;\n\t\t\t\t\tcopy[field.key] = cut;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"object\":\n\t\t\t\tcase \"list\": {\n\t\t\t\t\tconst bytes = encodedBytes(value);\n\t\t\t\t\tif (bytes > (field.max ?? 1024)) {\n\t\t\t\t\t\ttruncated = true;\n\t\t\t\t\t\tcopy[field.key] = { truncated: true, bytes };\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcopy[field.key] = JSON.parse(JSON.stringify(value));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tcopy[field.key] = value;\n\t\t\t}\n\t\t}\n\t\tconst seq = this.region.emit(entry.ordinal, copy, truncated, this.now());\n\t\tthis.harness?.emitted(seq);\n\t}\n\n\t/** @internal A library event under the reserved prefix. */\n\temitLibrary(name: string, payload: Record<string, unknown>): void {\n\t\tif (this.region.flags[FLAG_ATTACHED] === 0) return;\n\t\tconst ordinal = this.libraryEvents.get(name);\n\t\tif (ordinal === undefined) throw new Error(`${name} is not a library event`);\n\t\tconst seq = this.region.emit(ordinal, payload, false, this.now());\n\t\tthis.harness?.emitted(seq);\n\t}\n\n\t/** @internal The declared event for a ring slot's ordinal, or the library event's name. */\n\teventName(ordinal: number): string {\n\t\tif (ordinal < 0) return LIBRARY_EVENTS[LIBRARY_EVENT_BASE - ordinal] ?? `abai.unknown.${ordinal}`;\n\t\treturn this.manifest.events[ordinal]?.name ?? `unknown.${ordinal}`;\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Capabilities and safepoints (section 5.3)\n\t// -----------------------------------------------------------------------\n\n\t/** Register the handler of a declared capability (or replace one given at declaration). */\n\tcapability(name: string, handler: CapabilityHandler): void {\n\t\tif (!this.manifest.capabilities.some((c) => c.name === name)) {\n\t\t\tthrow new Error(`${this.name} declares no capability ${name}`);\n\t\t}\n\t\tthis.capabilityHandlers.set(name, handler);\n\t}\n\n\t/** @internal */\n\tcapabilityHandler(name: string): CapabilityHandler | undefined {\n\t\treturn this.capabilityHandlers.get(name);\n\t}\n\n\t/** @internal Queue work for the next safepoint; the binding uses it for safepoint dispatch. */\n\tenqueue(work: () => void): void {\n\t\tthis.queue.push(work);\n\t\tthis.region.flags[FLAG_QUEUE] = this.queue.length;\n\t\tthis.region.flags[FLAG_WORK] = 1;\n\t}\n\n\t/** One load of a flag when nothing is queued and no pause is in effect. */\n\tsafepoint(): void {\n\t\tif (this.region.flags[FLAG_WORK] === 0) return;\n\t\tthis.drain();\n\t}\n\n\t/** @internal Remove queued work that will not run (a timed-out dispatch). */\n\tdequeue(work: () => void): void {\n\t\tconst index = this.queue.indexOf(work);\n\t\tif (index === -1) return;\n\t\tthis.queue.splice(index, 1);\n\t\tconst flags = this.region.flags;\n\t\tflags[FLAG_QUEUE] = this.queue.length;\n\t\tif (this.queue.length === 0 && flags[FLAG_PAUSED] === 0) flags[FLAG_WORK] = 0;\n\t}\n\n\t/** @internal Run everything queued, now, on this thread: a touchpoint holds the program at a safepoint. */\n\tdrain(): void {\n\t\tconst flags = this.region.flags;\n\t\twhile (this.queue.length > 0) {\n\t\t\tconst work = this.queue.shift() as () => void;\n\t\t\tflags[FLAG_QUEUE] = this.queue.length;\n\t\t\ttry {\n\t\t\t\twork();\n\t\t\t} catch {\n\t\t\t\t// a handler's failure is reported through its reply, never through the program's safepoint\n\t\t\t}\n\t\t}\n\t\tflags[FLAG_WORK] = flags[FLAG_PAUSED] !== 0 ? 1 : 0;\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Decisions and turns (sections 5.4, 4.3)\n\t// -----------------------------------------------------------------------\n\n\tprivate applyDefault(decl: DecisionDecl, cause: string): unknown {\n\t\tif (decl.default === \"abort\") throw new AbaigramAbort(decl.name, cause);\n\t\treturn decl.default;\n\t}\n\n\t/** Ask which way to go. With no harness attached the default applies at once and is counted. */\n\tasync decide<T = unknown>(name: string, context: Record<string, unknown> = {}): Promise<T> {\n\t\tconst index = this.decisionIndex.get(name);\n\t\tif (index === undefined) throw new Error(`${this.name} declares no decision ${name}`);\n\t\tconst decl = this.manifest.decisions[index];\n\t\tconst harness = this.harness;\n\t\tif (this.region.flags[FLAG_ATTACHED] === 0 || harness === undefined) {\n\t\t\tthis.region.counters[index] += 1;\n\t\t\treturn this.applyDefault(decl, \"no_harness\") as T;\n\t\t}\n\t\t// a cooperative pause holds the decision here; its own clock starts when the pause lifts (4.3)\n\t\tif (this.paused) await this.awaitResume(name);\n\t\tif (this.region.flags[FLAG_ATTACHED] === 0 || this.harness === undefined) {\n\t\t\tthis.region.counters[index] += 1;\n\t\t\treturn this.applyDefault(decl, \"no_harness\") as T;\n\t\t}\n\t\tthis.drain();\n\t\ttry {\n\t\t\treturn (await this.harness.decide(decl, context, this.now() + durationMs(decl.timeout))) as T;\n\t\t} catch (error) {\n\t\t\treturn this.applyDefault(decl, error instanceof Error ? error.message : String(error)) as T;\n\t\t}\n\t}\n\n\t/** Give the agent a turn. With no harness attached it returns at once and is counted. */\n\tasync turn(name: string): Promise<void> {\n\t\tconst index = this.turnIndex.get(name);\n\t\tif (index === undefined) throw new Error(`${this.name} declares no turn ${name}`);\n\t\tconst decl = this.manifest.turns[index];\n\t\tconst harness = this.harness;\n\t\tif (this.region.flags[FLAG_ATTACHED] === 0 || harness === undefined) {\n\t\t\tthis.region.counters[this.manifest.decisions.length + index] += 1;\n\t\t\treturn;\n\t\t}\n\t\tif (this.paused) await this.awaitResume(name);\n\t\tif (this.region.flags[FLAG_ATTACHED] === 0 || this.harness === undefined) {\n\t\t\tthis.region.counters[this.manifest.decisions.length + index] += 1;\n\t\t\treturn;\n\t\t}\n\t\tthis.drain();\n\t\ttry {\n\t\t\tawait this.harness.turn(decl, this.now() + durationMs(decl.timeout));\n\t\t} catch {\n\t\t\t// a turn that fails is a turn that ended\n\t\t}\n\t\tthis.drain();\n\t}\n\n\t/** The counters, by kind and name: defaulted decisions, skipped turns, and the mode fallback. */\n\tcounters(): CounterSnapshot {\n\t\tconst snapshot: CounterSnapshot = {};\n\t\tthis.manifest.decisions.forEach((decl, i) => {\n\t\t\tsnapshot[`decision:${decl.name}`] = this.region.counters[i];\n\t\t});\n\t\tthis.manifest.turns.forEach((decl, i) => {\n\t\t\tsnapshot[`turn:${decl.name}`] = this.region.counters[this.manifest.decisions.length + i];\n\t\t});\n\t\tsnapshot[\"abai.mode_fallback\"] = this.region.counters[this.region.counters.length - 1];\n\t\treturn snapshot;\n\t}\n\n\t/** @internal Read and reset the counters, for the harness that attaches. */\n\ttakeCounters(): CounterSnapshot {\n\t\tconst snapshot = this.counters();\n\t\tthis.region.counters.fill(0);\n\t\treturn snapshot;\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Attaching (section 4.3)\n\t// -----------------------------------------------------------------------\n\n\t/** @internal The binding attaches a harness. */\n\tsetHarness(harness: AttachedHarness): void {\n\t\tthis.harness = harness;\n\t\tthis.region.flags[FLAG_ATTACHED] = 1;\n\t\tthis.lastAttachError = undefined;\n\t}\n\n\t/** @internal The binding detaches it; a decision in flight takes its default with `reason`. */\n\tclearHarness(reason: string): void {\n\t\tconst harness = this.harness;\n\t\tthis.harness = undefined;\n\t\tthis.binding = undefined;\n\t\tthis.nullHarness = undefined;\n\t\tthis.region.flags[FLAG_ATTACHED] = 0;\n\t\tthis.lastAttachError = reason;\n\t\t// a pause is the attached harness's: when the harness goes the program runs as itself again (6.3)\n\t\tthis.resumeFromPause();\n\t\tharness?.detach(reason);\n\t}\n\n\t/** The direct binding, while an in-process harness is attached. */\n\tget directBinding(): HarnessBinding | undefined {\n\t\treturn this.binding;\n\t}\n\n\t/** The null harness, while one is attached. */\n\tget attachedNullHarness(): NullHarness | undefined {\n\t\treturn this.nullHarness;\n\t}\n\n\tprivate createBinding(connection?: string): DirectBinding {\n\t\tconst binding = new DirectBinding(this, {\n\t\t\t...(this.auditPathOverride === undefined ? {} : { auditPath: this.auditPathOverride }),\n\t\t\t...(connection === undefined ? {} : { connection }),\n\t\t});\n\t\tthis.binding = binding;\n\t\tthis.setHarness(binding);\n\t\tbinding.flushCounters();\n\t\treturn binding;\n\t}\n\n\t/**\n\t * @internal A front end of the library's own (the sidecar endpoint)\n\t * attaches the program through a binding it then drives; the connection's\n\t * id labels its acts in the audit. Refused while something else is\n\t * attached: a second harness would take the program over silently.\n\t */\n\tbind(connection: string): DirectBinding {\n\t\tif (this.attached) {\n\t\t\tthrow new Error(`${this.name} already has a harness attached; this connection cannot take it over`);\n\t\t}\n\t\tif (this.launched) this.launcherSeen = true;\n\t\treturn this.createBinding(connection);\n\t}\n\n\tprivate attachNull(form: \"null\" | \"exercise\"): void {\n\t\tconst binding = this.createBinding();\n\t\tthis.nullHarness = attachNullHarness(binding, form);\n\t\tif (form === \"exercise\") {\n\t\t\tconst harness = this.nullHarness;\n\t\t\tprocess.once(\"exit\", () => {\n\t\t\t\tif (this.nullHarness === harness) this.report(JSON.stringify(harness.report()));\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Connect or spawn a harness (one of the five places). Resolves true when\n\t * attached. The real harness arrives through the `harness` extra, or the\n\t * harness package's dynamic import once it exists; until then the reason\n\t * is recorded.\n\t */\n\tasync attach(): Promise<boolean> {\n\t\tif (this.attached) return true;\n\t\tswitch (this.harnessSelection) {\n\t\t\tcase \"off\":\n\t\t\t\tthis.lastAttachError = `${ENV_HARNESS}=off`;\n\t\t\t\treturn false;\n\t\t\tcase \"null\":\n\t\t\tcase \"exercise\":\n\t\t\t\tthis.attachNull(this.harnessSelection);\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\tif (this.harnessSelectionError !== undefined) {\n\t\t\t\t\tthis.lastAttachError = this.harnessSelectionError;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (this.endpoint) {\n\t\t\t\t\t// launched: the parent is already connecting; the program never spawns anything itself\n\t\t\t\t\treturn this.launched ? this.awaitLauncher(this.endpoint) : this.attachSidecar(this.endpoint);\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst factory =\n\t\t\t\t\t\tthis.harnessFactory ??\n\t\t\t\t\t\t(await installedHarness(\n\t\t\t\t\t\t\tthis.env[ENV_HARNESS_MODULE] || this.manifest.harness?.path || \"@abaigram/abai-embedded-harness\",\n\t\t\t\t\t\t));\n\t\t\t\t\tif (factory === undefined) {\n\t\t\t\t\t\tthis.lastAttachError =\n\t\t\t\t\t\t\t\"no harness is installed (the @abaigram/abai-embedded-harness package is not resolvable)\";\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tconst binding = this.createBinding();\n\t\t\t\t\tawait factory(binding);\n\t\t\t\t\treturn this.attached;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tthis.binding?.detach(reason);\n\t\t\t\t\tthis.lastAttachError = reason;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t}\n\t}\n\n\t/** Under launch: the launcher connects to the socket it chose; the program waits for it once, bounded. */\n\tprivate async awaitLauncher(endpoint: Endpoint): Promise<boolean> {\n\t\ttry {\n\t\t\tawait endpoint.ready;\n\t\t} catch (error) {\n\t\t\tthis.lastAttachError = `the endpoint could not listen: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\treturn false;\n\t\t}\n\t\tif (this.attached) return true;\n\t\tif (this.launcherSeen) {\n\t\t\t// it was here and went: a later attach place returns at once, as 4.3 says of every touchpoint after a detach\n\t\t\tthis.lastAttachError = this.lastAttachError ?? \"the launcher disconnected\";\n\t\t\treturn false;\n\t\t}\n\t\tconst waitMs = attachWaitMsFrom(this.env);\n\t\tif (await endpoint.waitForConnection(waitMs)) {\n\t\t\tthis.launcherSeen = true;\n\t\t\treturn true;\n\t\t}\n\t\tthis.lastAttachError = `launched, but the launcher did not connect within ${waitMs} ms`;\n\t\treturn false;\n\t}\n\n\t/**\n\t * Sidecar attach (section 6.3): a harness already connected to the\n\t * endpoint means attached; otherwise the harness binary is spawned with\n\t * the terminal inherited and given `ABAI_ATTACH_WAIT_MS` to connect. A\n\t * child that exits first fails the attach at once with its code, so an\n\t * unconfigured machine costs well under a second (section 4.3); a child\n\t * that never connects is ended at the wait and the attach fails with the\n\t * reason. The child is unref'd: a program whose work is done exits, and\n\t * the closing socket tells the harness.\n\t */\n\tprivate async attachSidecar(endpoint: Endpoint): Promise<boolean> {\n\t\ttry {\n\t\t\tawait endpoint.ready;\n\t\t} catch {\n\t\t\t// spawnHarness reports it\n\t\t}\n\t\t// a harness that connected while the endpoint came up, or at any time before: attached already\n\t\tif (this.attached) return true;\n\t\tconst spawned = await this.spawnHarness(endpoint, \"attach\");\n\t\treturn spawned !== undefined;\n\t}\n\n\t/**\n\t * Spawn the harness binary with a verb against this program's endpoint\n\t * and wait for it to connect. Resolves to the child once attached, or to\n\t * undefined with the reason in `attachError`: the endpoint could not\n\t * listen, the child exited first (its code), it never connected within\n\t * the wait (it is ended), or it could not be started at all.\n\t */\n\tprivate async spawnHarness(endpoint: Endpoint, verb: \"attach\" | \"mcp\"): Promise<ChildProcess | undefined> {\n\t\ttry {\n\t\t\tawait endpoint.ready;\n\t\t} catch (error) {\n\t\t\tthis.lastAttachError = `the endpoint could not listen: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\treturn undefined;\n\t\t}\n\t\tconst waitMs = attachWaitMsFrom(this.env);\n\t\tconst binary = harnessBinary(this.env, this.content.root);\n\t\tconst args = [...binary.args, verb, \"--target\", endpoint.socketPath, \"--run-dir\", endpoint.runDir];\n\t\tlet child: ChildProcess;\n\t\ttry {\n\t\t\tchild = spawn(binary.command, args, { stdio: \"inherit\", env: { ...process.env, ...this.env } });\n\t\t} catch (error) {\n\t\t\tthis.lastAttachError = `the harness binary could not be started: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\treturn undefined;\n\t\t}\n\t\tchild.unref();\n\t\t// a ChildProcess with no error listener throws into the program; one stays for the child's whole life\n\t\tchild.on(\"error\", () => {});\n\t\tconst outcome = await new Promise<string>((resolve) => {\n\t\t\tlet settled = false;\n\t\t\tconst settle = (result: string): void => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\tchild.off(\"exit\", onExit);\n\t\t\t\tchild.off(\"error\", onError);\n\t\t\t\tresolve(result);\n\t\t\t};\n\t\t\tconst onExit = (code: number | null, signal: NodeJS.Signals | null): void =>\n\t\t\t\tsettle(`exited:${code === null ? `signal ${signal ?? \"unknown\"}` : String(code)}`);\n\t\t\tconst onError = (error: NodeJS.ErrnoException): void => settle(`error:${error.code ?? error.message}`);\n\t\t\tchild.once(\"exit\", onExit);\n\t\t\tchild.once(\"error\", onError);\n\t\t\tvoid endpoint.waitForConnection(waitMs).then((connected) => settle(connected ? \"connected\" : \"timeout\"));\n\t\t});\n\t\tif (outcome === \"connected\") return child;\n\t\tif (outcome === \"timeout\") {\n\t\t\t// the one process this program started, by its own handle: nothing else is touched\n\t\t\tchild.kill();\n\t\t\tthis.lastAttachError = `the harness binary did not connect within ${waitMs} ms (${binary.command})`;\n\t\t\treturn undefined;\n\t\t}\n\t\tif (outcome.startsWith(\"exited:\")) {\n\t\t\tthis.lastAttachError = `the harness binary exited with ${outcome.slice(\"exited:\".length)} before connecting`;\n\t\t\treturn undefined;\n\t\t}\n\t\tthis.lastAttachError = `the harness binary could not be started: ${outcome.slice(\"error:\".length)} (${binary.command})`;\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * @internal `<prog> abai mcp` under sidecar: the binary's MCP server is\n\t * spawned against this program's endpoint with the terminal inherited, so\n\t * the MCP client on this process's stdin and stdout talks to it, and the\n\t * program waits at its entry, a safepoint it holds open, until the client\n\t * goes. Resolves to the child's exit code; -1 when nothing could be\n\t * spawned (the reason is in `attachError`).\n\t */\n\tasync serveMcpSidecar(endpoint: Endpoint): Promise<number> {\n\t\tif (this.attached) {\n\t\t\tthis.lastAttachError = `${this.name} already has a harness attached`;\n\t\t\treturn -1;\n\t\t}\n\t\tconst child = await this.spawnHarness(endpoint, \"mcp\");\n\t\tif (child === undefined) return -1;\n\t\t// the program's whole purpose now is to wait for its server: the child holds the event loop open,\n\t\t// where the spawn left it unref'd for the attach case, whose touchpoint holds the loop itself\n\t\tchild.ref();\n\t\t// the MCP client spawned this program and ends it with a signal; the server behind it must go too\n\t\tconst forward = (signal: NodeJS.Signals): void => {\n\t\t\tif (child.exitCode === null && child.signalCode === null) child.kill(signal);\n\t\t};\n\t\tconst forwarded: NodeJS.Signals[] = [\"SIGTERM\", \"SIGINT\", \"SIGHUP\"];\n\t\tfor (const signal of forwarded) process.on(signal, forward);\n\t\tconst binding = this.binding;\n\t\tbinding?.enterSafepoint();\n\t\ttry {\n\t\t\tif (child.exitCode !== null) return child.exitCode;\n\t\t\treturn await new Promise<number>((resolve) => {\n\t\t\t\tchild.once(\"exit\", (code) => resolve(code ?? 1));\n\t\t\t});\n\t\t} finally {\n\t\t\tfor (const signal of forwarded) process.off(signal, forward);\n\t\t\tbinding?.leaveSafepoint();\n\t\t}\n\t}\n\n\tprivate async touchpoint(kind: TouchpointKind): Promise<void> {\n\t\tif (!(await this.attach())) return;\n\t\tif (this.paused) await this.awaitResume(kind);\n\t\tconst binding = this.binding;\n\t\tif (!binding) return;\n\t\tthis.drain();\n\t\tawait binding.touchpoint(kind);\n\t\tthis.drain();\n\t}\n\n\t/** Run the install touchpoint; returns when the harness finishes, or at once when none can be attached. */\n\tinstall(): Promise<void> {\n\t\treturn this.touchpoint(\"install\");\n\t}\n\n\t/** Open a session; returns when the harness ends it, or at once when none can be attached. */\n\tsession(): Promise<void> {\n\t\treturn this.touchpoint(\"session\");\n\t}\n}\n\n/** Overrides where the in-process harness is imported from (a path or a package name). */\nexport const ENV_HARNESS_MODULE = \"ABAI_HARNESS_MODULE\";\n\n/**\n * The harness binary to spawn under sidecar: `ABAI_HARNESS_BIN` (a script\n * path runs under this very node), else the nearest\n * `node_modules/.bin/abai-embedded-harness` from the program's root\n * upward, else the name on PATH.\n */\nexport function harnessBinary(env: NodeJS.ProcessEnv, root: string): { command: string; args: string[] } {\n\tconst explicit = env[ENV_HARNESS_BIN]?.trim();\n\tif (explicit) {\n\t\treturn /\\.(?:[mc]?js|ts)$/.test(explicit)\n\t\t\t? { command: process.execPath, args: [explicit] }\n\t\t\t: { command: explicit, args: [] };\n\t}\n\tconst installed = installedHarnessBinary(root);\n\tif (installed !== undefined) return { command: installed, args: [] };\n\treturn { command: \"abai-embedded-harness\", args: [] };\n}\n\n/**\n * The installed harness's bin link: under the program's root, else under the\n * nearest ancestor that has one, the way Node resolves a package. npm hoists\n * a workspace's packages and their bin links to the workspace root, so a\n * program that is one package of a workspace has no `.bin` of its own. When\n * no manifest was found the root is the working directory, and the walk is\n * the one Node would make for a module imported from there.\n */\nfunction installedHarnessBinary(root: string): string | undefined {\n\tlet dir = resolve(root);\n\tlet candidate = join(dir, \"node_modules\", \".bin\", \"abai-embedded-harness\");\n\twhile (!existsSync(candidate)) {\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return undefined;\n\t\tdir = parent;\n\t\tcandidate = join(dir, \"node_modules\", \".bin\", \"abai-embedded-harness\");\n\t}\n\treturn candidate;\n}\n\n/** What the stub uses of the installed harness package. */\nexport interface HarnessModule {\n\tattachEmbedded?: (binding: HarnessBinding) => Promise<unknown>;\n\t/** `<prog> abai mcp` in-process: serve this binding to the MCP client on the process's stdio; resolves to the exit code. */\n\tserveMcpEmbedded?: (binding: HarnessBinding) => Promise<number>;\n\trunConfig?: (\n\t\targs: string[],\n\t\tio: { out(text: string): void; err(text: string): void; env: NodeJS.ProcessEnv },\n\t\t/** The program the entry runs for, so `config net` finds its network directory. */\n\t\tcontext?: { program?: string },\n\t) => Promise<number>;\n\tdoctorOnline?: (\n\t\tmanifest: Manifest,\n\t\tenv: NodeJS.ProcessEnv,\n\t) => Promise<Array<{ name: string; status: \"ok\" | \"fail\" | \"skip\"; detail: string }>>;\n}\n\n/** The harness package, found by dynamic import when a program installed it; undefined when it does not resolve. */\nexport async function importHarnessModule(\n\tenv: NodeJS.ProcessEnv,\n\tmanifest: Manifest,\n): Promise<HarnessModule | undefined> {\n\tconst specifier = env[ENV_HARNESS_MODULE] || manifest.harness?.path || \"@abaigram/abai-embedded-harness\";\n\ttry {\n\t\treturn (await import(specifier)) as HarnessModule;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The harness package's in-process entry. */\nasync function installedHarness(specifier: string): Promise<HarnessFactory | undefined> {\n\tlet module: HarnessModule;\n\ttry {\n\t\tmodule = (await import(specifier)) as HarnessModule;\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (typeof module.attachEmbedded !== \"function\") return undefined;\n\tconst attach = module.attachEmbedded;\n\treturn async (binding) => {\n\t\tawait attach(binding);\n\t};\n}\n\n/** The program's one call: declarations in, the abaigram out. Throws when a declaration does not validate. */\nexport function createAbaigram(options: AbaigramOptions, extras: AbaigramExtras = {}): Abaigram {\n\treturn new Abaigram(options, extras);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"region.d.ts","sourceRoot":"","sources":["../src/region.ts"],"names":[],"mappings":"AAQA,oCAAoC;AACpC,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,UAAU,IAAI,CAAC;AAC5B,uGAAuG;AACvG,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,UAAU,IAAI,CAAC;AAE5B,uFAAuF;AACvF,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,MAAM,WAAW,SAAS;IACzB,sDAAsD;IACtD,GAAG,EAAE,MAAM,CAAC;IACZ,mHAAmH;IACnH,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7C,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,4BAA4B;IAC5B,EAAE,EAAE,MAAM,CAAC;CACX;AAED,kGAAkG;AAClG,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,MAAM,WAAW,YAAY;IAC5B,4FAA4F;IAC5F,OAAO,EAAE,MAAM,CAAC;IAChB,2FAA2F;IAC3F,KAAK,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IAC1B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,6FAA6F;IAC7F,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,qBAAa,MAAM;IAClB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAc;IACnC,0CAA0C;IAC1C,OAAO,CAAC,IAAI,CAAK;IAEjB,YAAY,MAAM,EAAE,YAAY,EAAE,QAAQ,SAAgB,EAUzD;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,mEAAmE;IACnE,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CASxG;IAED;;;OAGG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAapC;CACD","sourcesContent":["// The region (abaigrammar section 5, common rules): the memory the two halves\n// share. This is the in-process layout: scalar cells, versions, counters and\n// flags live in typed arrays so a write is one store and a read is one load\n// (sections 11.1 and 11.2); sized cells and event payloads live in\n// preallocated slot objects, whose copies allocate (a declared deviation).\n// A shared-buffer layout for thread mode can implement the same shape over a\n// SharedArrayBuffer later; nothing here reaches outside the process.\n\n/** Flag slots in `Region.flags`. */\nexport const FLAG_ATTACHED = 0;\nexport const FLAG_PARKED = 1;\nexport const FLAG_PAUSED = 2;\nexport const FLAG_QUEUE = 3;\n/** Nonzero when a safepoint has anything to do: work queued or a pause in effect. One load decides. */\nexport const FLAG_WORK = 4;\nexport const FLAG_COUNT = 8;\n\n/** Event slots the ring holds; the oldest unread slot is overwritten when it wraps. */\nexport const RING_CAPACITY = 256;\n\nexport interface EventSlot {\n\t/** Sequence number, from 1; 0 means never written. */\n\tseq: number;\n\t/** The event's ordinal in the manifest's `events` list (library events are negative, see `LIBRARY_EVENT_BASE`). */\n\tevent: number;\n\t/** The copied payload. */\n\tpayload: Record<string, unknown> | undefined;\n\t/** A sized field was cut to its `max`. */\n\ttruncated: boolean;\n\t/** `Date.now()` at emit. */\n\tts: number;\n}\n\n/** Ordinal of library event `i` (the index into `LIBRARY_EVENTS`) is `LIBRARY_EVENT_BASE - i`. */\nexport const LIBRARY_EVENT_BASE = -1;\n\nexport interface RegionLayout {\n\t/** How many cells are scalar (bool, int, float, enum); they occupy `values[0..scalars)`. */\n\tscalars: number;\n\t/** How many cells are sized (string, object, list); they occupy `sized[0..sizedCount)`. */\n\tsized: number;\n\t/** Counters: one per decision, one per turn, then one for the mode fallback. */\n\tcounters: number;\n}\n\nexport interface ReadEvents {\n\tslots: EventSlot[];\n\t/** Events overwritten before they were read, between `after` and the first slot returned. */\n\tdropped: number;\n\t/** The sequence number to pass next time. */\n\tnext: number;\n}\n\n/**\n * The in-process region. Cells are addressed by ordinal: a scalar cell by\n * its index into `values`, a sized cell by its index into `sized`; both share\n * `versions`, indexed by the cell's position in the manifest.\n */\nexport class Region {\n\treadonly values: Float64Array;\n\treadonly versions: Int32Array;\n\treadonly counters: Int32Array;\n\treadonly flags: Int32Array;\n\t/** Sized cell values; a slot is replaced, never mutated in place. */\n\treadonly sized: unknown[];\n\tprivate readonly ring: EventSlot[];\n\t/** The next sequence number to assign. */\n\tprivate head = 1;\n\n\tconstructor(layout: RegionLayout, capacity = RING_CAPACITY) {\n\t\tthis.values = new Float64Array(Math.max(1, layout.scalars));\n\t\tthis.versions = new Int32Array(Math.max(1, layout.scalars + layout.sized));\n\t\tthis.counters = new Int32Array(Math.max(1, layout.counters));\n\t\tthis.flags = new Int32Array(FLAG_COUNT);\n\t\tthis.sized = new Array<unknown>(layout.sized).fill(undefined);\n\t\tthis.ring = [];\n\t\tfor (let i = 0; i < capacity; i++) {\n\t\t\tthis.ring.push({ seq: 0, event: 0, payload: undefined, truncated: false, ts: 0 });\n\t\t}\n\t}\n\n\tget attached(): boolean {\n\t\treturn this.flags[FLAG_ATTACHED] !== 0;\n\t}\n\n\tget capacity(): number {\n\t\treturn this.ring.length;\n\t}\n\n\t/** The last sequence number assigned (0 before the first emit). */\n\tget lastSeq(): number {\n\t\treturn this.head - 1;\n\t}\n\n\t/**\n\t * Claim the next slot and publish an event into it: one sequence\n\t * assignment, four stores. The payload is the caller's copy; the region\n\t * does not copy again. Returns the sequence number.\n\t */\n\temit(event: number, payload: Record<string, unknown> | undefined, truncated: boolean, ts: number): number {\n\t\tconst seq = this.head++;\n\t\tconst slot = this.ring[(seq - 1) % this.ring.length];\n\t\tslot.seq = seq;\n\t\tslot.event = event;\n\t\tslot.payload = payload;\n\t\tslot.truncated = truncated;\n\t\tslot.ts = ts;\n\t\treturn seq;\n\t}\n\n\t/**\n\t * Every event with a sequence number above `after` that is still in the\n\t * ring, in order, with the count of those already overwritten.\n\t */\n\treadEvents(after: number): ReadEvents {\n\t\tconst last = this.head - 1;\n\t\tif (last <= after) return { slots: [], dropped: 0, next: after };\n\t\tconst oldest = Math.max(1, last - this.ring.length + 1);\n\t\tconst from = Math.max(after + 1, oldest);\n\t\tconst dropped = from - (after + 1);\n\t\tconst slots: EventSlot[] = [];\n\t\tfor (let seq = from; seq <= last; seq++) {\n\t\t\tconst slot = this.ring[(seq - 1) % this.ring.length];\n\t\t\tif (slot.seq !== seq) continue; // lapped while reading; the next read reports it as dropped\n\t\t\tslots.push(slot);\n\t\t}\n\t\treturn { slots, dropped, next: last };\n\t}\n}\n"]}
1
+ {"version":3,"file":"region.d.ts","sourceRoot":"","sources":["../src/region.ts"],"names":[],"mappings":"AASA,oCAAoC;AACpC,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,UAAU,IAAI,CAAC;AAC5B,uGAAuG;AACvG,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,UAAU,IAAI,CAAC;AAE5B,uFAAuF;AACvF,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,MAAM,WAAW,SAAS;IACzB,sDAAsD;IACtD,GAAG,EAAE,MAAM,CAAC;IACZ,mHAAmH;IACnH,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7C,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,4BAA4B;IAC5B,EAAE,EAAE,MAAM,CAAC;CACX;AAED,kGAAkG;AAClG,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,MAAM,WAAW,YAAY;IAC5B,4FAA4F;IAC5F,OAAO,EAAE,MAAM,CAAC;IAChB,2FAA2F;IAC3F,KAAK,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IAC1B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,6FAA6F;IAC7F,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,qBAAa,MAAM;IAClB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAc;IACnC,0CAA0C;IAC1C,OAAO,CAAC,IAAI,CAAK;IAEjB,YAAY,MAAM,EAAE,YAAY,EAAE,QAAQ,SAAgB,EAUzD;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,mEAAmE;IACnE,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CASxG;IAED;;;OAGG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAapC;CACD","sourcesContent":["// The region (abaigrammar section 5, common rules): the memory the two halves\n// share. This is the in-process layout: scalar cells, versions, counters and\n// flags live in typed arrays so a write is one store and a read is one load\n// (sections 11.1 and 11.2); sized cells and event payloads live in\n// preallocated slot objects, whose copies allocate (a declared deviation).\n// Thread mode uses this same layout: the harness lives on the program's event\n// loop, so nothing here reaches outside the process. A SharedArrayBuffer layout\n// of the same shape would serve a harness in a worker, if one is ever wanted.\n\n/** Flag slots in `Region.flags`. */\nexport const FLAG_ATTACHED = 0;\nexport const FLAG_PARKED = 1;\nexport const FLAG_PAUSED = 2;\nexport const FLAG_QUEUE = 3;\n/** Nonzero when a safepoint has anything to do: work queued or a pause in effect. One load decides. */\nexport const FLAG_WORK = 4;\nexport const FLAG_COUNT = 8;\n\n/** Event slots the ring holds; the oldest unread slot is overwritten when it wraps. */\nexport const RING_CAPACITY = 256;\n\nexport interface EventSlot {\n\t/** Sequence number, from 1; 0 means never written. */\n\tseq: number;\n\t/** The event's ordinal in the manifest's `events` list (library events are negative, see `LIBRARY_EVENT_BASE`). */\n\tevent: number;\n\t/** The copied payload. */\n\tpayload: Record<string, unknown> | undefined;\n\t/** A sized field was cut to its `max`. */\n\ttruncated: boolean;\n\t/** `Date.now()` at emit. */\n\tts: number;\n}\n\n/** Ordinal of library event `i` (the index into `LIBRARY_EVENTS`) is `LIBRARY_EVENT_BASE - i`. */\nexport const LIBRARY_EVENT_BASE = -1;\n\nexport interface RegionLayout {\n\t/** How many cells are scalar (bool, int, float, enum); they occupy `values[0..scalars)`. */\n\tscalars: number;\n\t/** How many cells are sized (string, object, list); they occupy `sized[0..sizedCount)`. */\n\tsized: number;\n\t/** Counters: one per decision, one per turn, then one for the mode fallback. */\n\tcounters: number;\n}\n\nexport interface ReadEvents {\n\tslots: EventSlot[];\n\t/** Events overwritten before they were read, between `after` and the first slot returned. */\n\tdropped: number;\n\t/** The sequence number to pass next time. */\n\tnext: number;\n}\n\n/**\n * The in-process region. Cells are addressed by ordinal: a scalar cell by\n * its index into `values`, a sized cell by its index into `sized`; both share\n * `versions`, indexed by the cell's position in the manifest.\n */\nexport class Region {\n\treadonly values: Float64Array;\n\treadonly versions: Int32Array;\n\treadonly counters: Int32Array;\n\treadonly flags: Int32Array;\n\t/** Sized cell values; a slot is replaced, never mutated in place. */\n\treadonly sized: unknown[];\n\tprivate readonly ring: EventSlot[];\n\t/** The next sequence number to assign. */\n\tprivate head = 1;\n\n\tconstructor(layout: RegionLayout, capacity = RING_CAPACITY) {\n\t\tthis.values = new Float64Array(Math.max(1, layout.scalars));\n\t\tthis.versions = new Int32Array(Math.max(1, layout.scalars + layout.sized));\n\t\tthis.counters = new Int32Array(Math.max(1, layout.counters));\n\t\tthis.flags = new Int32Array(FLAG_COUNT);\n\t\tthis.sized = new Array<unknown>(layout.sized).fill(undefined);\n\t\tthis.ring = [];\n\t\tfor (let i = 0; i < capacity; i++) {\n\t\t\tthis.ring.push({ seq: 0, event: 0, payload: undefined, truncated: false, ts: 0 });\n\t\t}\n\t}\n\n\tget attached(): boolean {\n\t\treturn this.flags[FLAG_ATTACHED] !== 0;\n\t}\n\n\tget capacity(): number {\n\t\treturn this.ring.length;\n\t}\n\n\t/** The last sequence number assigned (0 before the first emit). */\n\tget lastSeq(): number {\n\t\treturn this.head - 1;\n\t}\n\n\t/**\n\t * Claim the next slot and publish an event into it: one sequence\n\t * assignment, four stores. The payload is the caller's copy; the region\n\t * does not copy again. Returns the sequence number.\n\t */\n\temit(event: number, payload: Record<string, unknown> | undefined, truncated: boolean, ts: number): number {\n\t\tconst seq = this.head++;\n\t\tconst slot = this.ring[(seq - 1) % this.ring.length];\n\t\tslot.seq = seq;\n\t\tslot.event = event;\n\t\tslot.payload = payload;\n\t\tslot.truncated = truncated;\n\t\tslot.ts = ts;\n\t\treturn seq;\n\t}\n\n\t/**\n\t * Every event with a sequence number above `after` that is still in the\n\t * ring, in order, with the count of those already overwritten.\n\t */\n\treadEvents(after: number): ReadEvents {\n\t\tconst last = this.head - 1;\n\t\tif (last <= after) return { slots: [], dropped: 0, next: after };\n\t\tconst oldest = Math.max(1, last - this.ring.length + 1);\n\t\tconst from = Math.max(after + 1, oldest);\n\t\tconst dropped = from - (after + 1);\n\t\tconst slots: EventSlot[] = [];\n\t\tfor (let seq = from; seq <= last; seq++) {\n\t\t\tconst slot = this.ring[(seq - 1) % this.ring.length];\n\t\t\tif (slot.seq !== seq) continue; // lapped while reading; the next read reports it as dropped\n\t\t\tslots.push(slot);\n\t\t}\n\t\treturn { slots, dropped, next: last };\n\t}\n}\n"]}
package/dist/region.js CHANGED
@@ -3,8 +3,9 @@
3
3
  // flags live in typed arrays so a write is one store and a read is one load
4
4
  // (sections 11.1 and 11.2); sized cells and event payloads live in
5
5
  // preallocated slot objects, whose copies allocate (a declared deviation).
6
- // A shared-buffer layout for thread mode can implement the same shape over a
7
- // SharedArrayBuffer later; nothing here reaches outside the process.
6
+ // Thread mode uses this same layout: the harness lives on the program's event
7
+ // loop, so nothing here reaches outside the process. A SharedArrayBuffer layout
8
+ // of the same shape would serve a harness in a worker, if one is ever wanted.
8
9
  /** Flag slots in `Region.flags`. */
9
10
  export const FLAG_ATTACHED = 0;
10
11
  export const FLAG_PARKED = 1;
@@ -1 +1 @@
1
- {"version":3,"file":"region.js","sourceRoot":"","sources":["../src/region.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,4EAA4E;AAC5E,mEAAmE;AACnE,2EAA2E;AAC3E,6EAA6E;AAC7E,qEAAqE;AAErE,oCAAoC;AACpC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAC5B,uGAAuG;AACvG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAC3B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAE5B,uFAAuF;AACvF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAejC,kGAAkG;AAClG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,CAAC;AAmBrC;;;;GAIG;AACH,MAAM,OAAO,MAAM;IACT,MAAM,CAAe;IACrB,QAAQ,CAAa;IACrB,QAAQ,CAAa;IACrB,KAAK,CAAa;IAC3B,qEAAqE;IAC5D,KAAK,CAAY;IACT,IAAI,CAAc;IACnC,0CAA0C;IAClC,IAAI,GAAG,CAAC,CAAC;IAEjB,YAAY,MAAoB,EAAE,QAAQ,GAAG,aAAa,EAAE;QAC3D,IAAI,CAAC,MAAM,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE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AK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAAA,CACtC;CACD","sourcesContent":["// The region (abaigrammar section 5, common rules): the memory the two halves\n// share. This is the in-process layout: scalar cells, versions, counters and\n// flags live in typed arrays so a write is one store and a read is one load\n// (sections 11.1 and 11.2); sized cells and event payloads live in\n// preallocated slot objects, whose copies allocate (a declared deviation).\n// A shared-buffer layout for thread mode can implement the same shape over a\n// SharedArrayBuffer later; nothing here reaches outside the process.\n\n/** Flag slots in `Region.flags`. */\nexport const FLAG_ATTACHED = 0;\nexport const FLAG_PARKED = 1;\nexport const FLAG_PAUSED = 2;\nexport const FLAG_QUEUE = 3;\n/** Nonzero when a safepoint has anything to do: work queued or a pause in effect. One load decides. */\nexport const FLAG_WORK = 4;\nexport const FLAG_COUNT = 8;\n\n/** Event slots the ring holds; the oldest unread slot is overwritten when it wraps. */\nexport const RING_CAPACITY = 256;\n\nexport interface EventSlot {\n\t/** Sequence number, from 1; 0 means never written. */\n\tseq: number;\n\t/** The event's ordinal in the manifest's `events` list (library events are negative, see `LIBRARY_EVENT_BASE`). */\n\tevent: number;\n\t/** The copied payload. */\n\tpayload: Record<string, unknown> | undefined;\n\t/** A sized field was cut to its `max`. */\n\ttruncated: boolean;\n\t/** `Date.now()` at emit. */\n\tts: number;\n}\n\n/** Ordinal of library event `i` (the index into `LIBRARY_EVENTS`) is `LIBRARY_EVENT_BASE - i`. */\nexport const LIBRARY_EVENT_BASE = -1;\n\nexport interface RegionLayout {\n\t/** How many cells are scalar (bool, int, float, enum); they occupy `values[0..scalars)`. */\n\tscalars: number;\n\t/** How many cells are sized (string, object, list); they occupy `sized[0..sizedCount)`. */\n\tsized: number;\n\t/** Counters: one per decision, one per turn, then one for the mode fallback. */\n\tcounters: number;\n}\n\nexport interface ReadEvents {\n\tslots: EventSlot[];\n\t/** Events overwritten before they were read, between `after` and the first slot returned. */\n\tdropped: number;\n\t/** The sequence number to pass next time. */\n\tnext: number;\n}\n\n/**\n * The in-process region. Cells are addressed by ordinal: a scalar cell by\n * its index into `values`, a sized cell by its index into `sized`; both share\n * `versions`, indexed by the cell's position in the manifest.\n */\nexport class Region {\n\treadonly values: Float64Array;\n\treadonly versions: Int32Array;\n\treadonly counters: Int32Array;\n\treadonly flags: Int32Array;\n\t/** Sized cell values; a slot is replaced, never mutated in place. */\n\treadonly sized: unknown[];\n\tprivate readonly ring: EventSlot[];\n\t/** The next sequence number to assign. */\n\tprivate head = 1;\n\n\tconstructor(layout: RegionLayout, capacity = RING_CAPACITY) {\n\t\tthis.values = new Float64Array(Math.max(1, layout.scalars));\n\t\tthis.versions = new Int32Array(Math.max(1, layout.scalars + layout.sized));\n\t\tthis.counters = new Int32Array(Math.max(1, layout.counters));\n\t\tthis.flags = new Int32Array(FLAG_COUNT);\n\t\tthis.sized = new Array<unknown>(layout.sized).fill(undefined);\n\t\tthis.ring = [];\n\t\tfor (let i = 0; i < capacity; i++) {\n\t\t\tthis.ring.push({ seq: 0, event: 0, payload: undefined, truncated: false, ts: 0 });\n\t\t}\n\t}\n\n\tget attached(): boolean {\n\t\treturn this.flags[FLAG_ATTACHED] !== 0;\n\t}\n\n\tget capacity(): number {\n\t\treturn this.ring.length;\n\t}\n\n\t/** The last sequence number assigned (0 before the first emit). */\n\tget lastSeq(): number {\n\t\treturn this.head - 1;\n\t}\n\n\t/**\n\t * Claim the next slot and publish an event into it: one sequence\n\t * assignment, four stores. The payload is the caller's copy; the region\n\t * does not copy again. Returns the sequence number.\n\t */\n\temit(event: number, payload: Record<string, unknown> | undefined, truncated: boolean, ts: number): number {\n\t\tconst seq = this.head++;\n\t\tconst slot = this.ring[(seq - 1) % this.ring.length];\n\t\tslot.seq = seq;\n\t\tslot.event = event;\n\t\tslot.payload = payload;\n\t\tslot.truncated = truncated;\n\t\tslot.ts = ts;\n\t\treturn seq;\n\t}\n\n\t/**\n\t * Every event with a sequence number above `after` that is still in the\n\t * ring, in order, with the count of those already overwritten.\n\t */\n\treadEvents(after: number): ReadEvents {\n\t\tconst last = this.head - 1;\n\t\tif (last <= after) return { slots: [], dropped: 0, next: after };\n\t\tconst oldest = Math.max(1, last - this.ring.length + 1);\n\t\tconst from = Math.max(after + 1, oldest);\n\t\tconst dropped = from - (after + 1);\n\t\tconst slots: EventSlot[] = [];\n\t\tfor (let seq = from; seq <= last; seq++) {\n\t\t\tconst slot = this.ring[(seq - 1) % this.ring.length];\n\t\t\tif (slot.seq !== seq) continue; // lapped while reading; the next read reports it as dropped\n\t\t\tslots.push(slot);\n\t\t}\n\t\treturn { slots, dropped, next: last };\n\t}\n}\n"]}
1
+ {"version":3,"file":"region.js","sourceRoot":"","sources":["../src/region.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,4EAA4E;AAC5E,mEAAmE;AACnE,2EAA2E;AAC3E,8EAA8E;AAC9E,gFAAgF;AAChF,8EAA8E;AAE9E,oCAAoC;AACpC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAC5B,uGAAuG;AACvG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAC3B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAE5B,uFAAuF;AACvF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAejC,kGAAkG;AAClG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,CAAC;AAmBrC;;;;GAIG;AACH,MAAM,OAAO,MAAM;IACT,MAAM,CAAe;IACrB,QAAQ,CAAa;IACrB,QAAQ,CAAa;IACrB,KAAK,CAAa;IAC3B,qEAAqE;IAC5D,KAAK,CAAY;IAC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,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrD,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG;gBAAE,SAAS,CAAC,4DAA4D;YAC5F,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAAA,CACtC;CACD","sourcesContent":["// The region (abaigrammar section 5, common rules): the memory the two halves\n// share. This is the in-process layout: scalar cells, versions, counters and\n// flags live in typed arrays so a write is one store and a read is one load\n// (sections 11.1 and 11.2); sized cells and event payloads live in\n// preallocated slot objects, whose copies allocate (a declared deviation).\n// Thread mode uses this same layout: the harness lives on the program's event\n// loop, so nothing here reaches outside the process. A SharedArrayBuffer layout\n// of the same shape would serve a harness in a worker, if one is ever wanted.\n\n/** Flag slots in `Region.flags`. */\nexport const FLAG_ATTACHED = 0;\nexport const FLAG_PARKED = 1;\nexport const FLAG_PAUSED = 2;\nexport const FLAG_QUEUE = 3;\n/** Nonzero when a safepoint has anything to do: work queued or a pause in effect. One load decides. */\nexport const FLAG_WORK = 4;\nexport const FLAG_COUNT = 8;\n\n/** Event slots the ring holds; the oldest unread slot is overwritten when it wraps. */\nexport const RING_CAPACITY = 256;\n\nexport interface EventSlot {\n\t/** Sequence number, from 1; 0 means never written. */\n\tseq: number;\n\t/** The event's ordinal in the manifest's `events` list (library events are negative, see `LIBRARY_EVENT_BASE`). */\n\tevent: number;\n\t/** The copied payload. */\n\tpayload: Record<string, unknown> | undefined;\n\t/** A sized field was cut to its `max`. */\n\ttruncated: boolean;\n\t/** `Date.now()` at emit. */\n\tts: number;\n}\n\n/** Ordinal of library event `i` (the index into `LIBRARY_EVENTS`) is `LIBRARY_EVENT_BASE - i`. */\nexport const LIBRARY_EVENT_BASE = -1;\n\nexport interface RegionLayout {\n\t/** How many cells are scalar (bool, int, float, enum); they occupy `values[0..scalars)`. */\n\tscalars: number;\n\t/** How many cells are sized (string, object, list); they occupy `sized[0..sizedCount)`. */\n\tsized: number;\n\t/** Counters: one per decision, one per turn, then one for the mode fallback. */\n\tcounters: number;\n}\n\nexport interface ReadEvents {\n\tslots: EventSlot[];\n\t/** Events overwritten before they were read, between `after` and the first slot returned. */\n\tdropped: number;\n\t/** The sequence number to pass next time. */\n\tnext: number;\n}\n\n/**\n * The in-process region. Cells are addressed by ordinal: a scalar cell by\n * its index into `values`, a sized cell by its index into `sized`; both share\n * `versions`, indexed by the cell's position in the manifest.\n */\nexport class Region {\n\treadonly values: Float64Array;\n\treadonly versions: Int32Array;\n\treadonly counters: Int32Array;\n\treadonly flags: Int32Array;\n\t/** Sized cell values; a slot is replaced, never mutated in place. */\n\treadonly sized: unknown[];\n\tprivate readonly ring: EventSlot[];\n\t/** The next sequence number to assign. */\n\tprivate head = 1;\n\n\tconstructor(layout: RegionLayout, capacity = RING_CAPACITY) {\n\t\tthis.values = new Float64Array(Math.max(1, layout.scalars));\n\t\tthis.versions = new Int32Array(Math.max(1, layout.scalars + layout.sized));\n\t\tthis.counters = new Int32Array(Math.max(1, layout.counters));\n\t\tthis.flags = new Int32Array(FLAG_COUNT);\n\t\tthis.sized = new Array<unknown>(layout.sized).fill(undefined);\n\t\tthis.ring = [];\n\t\tfor (let i = 0; i < capacity; i++) {\n\t\t\tthis.ring.push({ seq: 0, event: 0, payload: undefined, truncated: false, ts: 0 });\n\t\t}\n\t}\n\n\tget attached(): boolean {\n\t\treturn this.flags[FLAG_ATTACHED] !== 0;\n\t}\n\n\tget capacity(): number {\n\t\treturn this.ring.length;\n\t}\n\n\t/** The last sequence number assigned (0 before the first emit). */\n\tget lastSeq(): number {\n\t\treturn this.head - 1;\n\t}\n\n\t/**\n\t * Claim the next slot and publish an event into it: one sequence\n\t * assignment, four stores. The payload is the caller's copy; the region\n\t * does not copy again. Returns the sequence number.\n\t */\n\temit(event: number, payload: Record<string, unknown> | undefined, truncated: boolean, ts: number): number {\n\t\tconst seq = this.head++;\n\t\tconst slot = this.ring[(seq - 1) % this.ring.length];\n\t\tslot.seq = seq;\n\t\tslot.event = event;\n\t\tslot.payload = payload;\n\t\tslot.truncated = truncated;\n\t\tslot.ts = ts;\n\t\treturn seq;\n\t}\n\n\t/**\n\t * Every event with a sequence number above `after` that is still in the\n\t * ring, in order, with the count of those already overwritten.\n\t */\n\treadEvents(after: number): ReadEvents {\n\t\tconst last = this.head - 1;\n\t\tif (last <= after) return { slots: [], dropped: 0, next: after };\n\t\tconst oldest = Math.max(1, last - this.ring.length + 1);\n\t\tconst from = Math.max(after + 1, oldest);\n\t\tconst dropped = from - (after + 1);\n\t\tconst slots: EventSlot[] = [];\n\t\tfor (let seq = from; seq <= last; seq++) {\n\t\t\tconst slot = this.ring[(seq - 1) % this.ring.length];\n\t\t\tif (slot.seq !== seq) continue; // lapped while reading; the next read reports it as dropped\n\t\t\tslots.push(slot);\n\t\t}\n\t\treturn { slots, dropped, next: last };\n\t}\n}\n"]}
@@ -39,6 +39,8 @@ export interface AbaigramOptions {
39
39
  };
40
40
  attention?: Manifest["attention"];
41
41
  policy?: Manifest["policy"];
42
+ /** The agent may be a member of an agent network; `doc` says how its members relate to this program's names. */
43
+ network?: Manifest["network"];
42
44
  /** The program's own deviations; the instantiation's are appended. */
43
45
  deviations?: string[];
44
46
  cells?: Record<string, CellOptions>;
@@ -49,6 +51,7 @@ export interface AbaigramOptions {
49
51
  }
50
52
  /** Where this TypeScript instantiation departs from the grammar, in every manifest it renders. */
51
53
  export declare const INSTANTIATION_DEVIATIONS: readonly string[];
54
+ export declare const THREAD_DEVIATION = "In thread mode the harness has no thread of its own: Node runs one event loop, so the harness runs on the program's loop between the program's callbacks, live, and a long synchronous step on either side delays the other. Isolation is what one loop allows: a harness listener that throws while the program emits, decides or gives a turn is caught at the binding, a failed agent run ends that run alone, and a model unreachable at first contact detaches the harness, so the program goes on as itself; an exception or rejection the harness lets escape to the process is a process fault, as for any library on the same loop (section 6.2).";
52
55
  export declare const SIDECAR_DEVIATION = "In sidecar mode the region is not shared memory: cells are read by request and events cross the socket, so observation costs the program one serialization per connected harness (section 11.3). Under ABAI_HARNESS=null or exercise the null harness stays in the program's process and no endpoint opens, so a check run's measured overhead leaves that serialization out.";
53
56
  export declare const DEFAULT_CAPABILITY_TIMEOUT = "30s";
54
57
  export declare const DEFAULT_KNOB_TIMEOUT = "30s";
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAMA,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,IAAI,EACT,KAAK,MAAM,EACX,KAAK,QAAQ,EAEb,MAAM,wBAAwB,CAAC;AAEhC,uFAAuF;AACvF,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAChG,kGAAkG;AAClG,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AACnD,6EAA6E;AAC7E,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAErD,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAC9E,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AACnD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC,GAAG;IAClG,QAAQ,CAAC,EAAE,cAAc,CA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AM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACpC;AAED,kGAAkG;AAClG,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAKrD,CAAC;AACF,eAAO,MAAM,iBAAiB,kXACkV,CAAC;AAEjX,eAAO,MAAM,0BAA0B,QAAQ,CAAC;AAChD,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAM1C,qGAAqG;AACrG,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CA6EhE","sourcesContent":["// Declarations in code become the manifest (abaigrammar section 7). The\n// program hands `createAbaigram` keyed records; this module turns them into\n// the manifest's lists in insertion order, fills the grammar's defaults so\n// the rendered abaigram.yaml is explicit and byte-stable, appends the\n// deviations this TypeScript instantiation declares, and validates. An\n// invalid declaration throws at startup: declared, not discovered.\nimport {\n\tABAIGRAMMAR_VERSION,\n\ttype CapabilityDecl,\n\ttype CellDecl,\n\ttype DecisionDecl,\n\ttype EventDecl,\n\ttype Manifest,\n\ttype Mode,\n\ttype Policy,\n\ttype TurnDecl,\n\tvalidateManifest,\n} from \"./manifest/manifest.ts\";\n\n/** A capability's handler: parameters in, a result out; a throw is an error result. */\nexport type CapabilityHandler = (params: Record<string, unknown>) => unknown | Promise<unknown>;\n/** A sized knob's handler: the delivered value, at a safepoint, on the thread that reached it. */\nexport type KnobHandler = (value: unknown) => void;\n/** The stop handler, run at a safepoint on a graceful stop (section 5.5). */\nexport type StopHandler = () => void | Promise<void>;\n\nexport type CellOptions = Omit<CellDecl, \"name\"> & { onChange?: KnobHandler };\nexport type EventOptions = Omit<EventDecl, \"name\">;\nexport type CapabilityOptions = Omit<CapabilityDecl, \"name\" | \"dispatch\" | \"policy\" | \"timeout\"> & {\n\tdispatch?: CapabilityDecl[\"dispatch\"];\n\tpolicy?: Policy;\n\ttimeout?: string;\n\thandler?: CapabilityHandler;\n};\nexport type DecisionOptions = Omit<DecisionDecl, \"name\" | \"policy\"> & { policy?: Policy };\nexport type TurnOptions = Omit<TurnDecl, \"name\">;\n\nexport interface AbaigramOptions {\n\tname: string;\n\t/** Default `<name> abai`. */\n\tentry?: string;\n\tmodes: Mode[];\n\t/** Paths relative to the program's root; `identity` defaults to `abai/identity.md`. */\n\tcontent?: Partial<Manifest[\"content\"]>;\n\t/** Default `~/.abai/audit/<name>.jsonl`. */\n\taudit?: Manifest[\"audit\"];\n\tharness?: Manifest[\"harness\"];\n\tmodel?: Manifest[\"model\"];\n\tcheck?: Manifest[\"check\"];\n\tlifecycle?: Omit<NonNullable<Manifest[\"lifecycle\"]>, \"stop\"> & {\n\t\tstop?: { graceful: string; handler: StopHandler };\n\t};\n\tattention?: Manifest[\"attention\"];\n\tpolicy?: Manifest[\"policy\"];\n\t/** The program's own deviations; the instantiation's are appended. */\n\tdeviations?: string[];\n\tcells?: Record<string, CellOptions>;\n\tevents?: Record<string, EventOptions>;\n\tcapabilities?: Record<string, CapabilityOptions>;\n\tdecisions?: Record<string, DecisionOptions>;\n\tturns?: Record<string, TurnOptions>;\n}\n\n/** Where this TypeScript instantiation departs from the grammar, in every manifest it renders. */\nexport const INSTANTIATION_DEVIATIONS: readonly string[] = [\n\t\"Touchpoints are awaited promises: Node cannot block its only thread while the agent loop runs on it, so the program's logic pauses at the await while its own timers and I/O callbacks keep running (section 4.3).\",\n\t\"Sized cell writes and event payload copies allocate: JavaScript has no copy into a preallocated byte slot; scalar rows meet section 11.2, sized rows are measured and reported.\",\n\t\"A cooperative pause holds the program at its next touchpoint, not inside safepoint(): a safepoint cannot block, since the resume arrives on the same event loop that would be blocked. The flag is still one load at a safepoint, and os pause (the launcher's signal) holds the program anywhere (section 5.5).\",\n\t\"Under launch the child is attached as soon as its endpoint is accepted, a moment after its first statement rather than before it: Node cannot listen in a constructor. A program that wants the agent present from its first line awaits attach() (section 6.3).\",\n];\nexport const SIDECAR_DEVIATION =\n\t\"In sidecar mode the region is not shared memory: cells are read by request and events cross the socket, so observation costs the program one serialization per connected harness (section 11.3). Under ABAI_HARNESS=null or exercise the null harness stays in the program's process and no endpoint opens, so a check run's measured overhead leaves that serialization out.\";\n\nexport const DEFAULT_CAPABILITY_TIMEOUT = \"30s\";\nexport const DEFAULT_KNOB_TIMEOUT = \"30s\";\n\nfunction isSized(type: CellDecl[\"type\"]): boolean {\n\treturn type === \"string\" || type === \"object\" || type === \"list\";\n}\n\n/** Build the explicit, validated manifest from the program's declarations. Throws on a violation. */\nexport function buildManifest(options: AbaigramOptions): Manifest {\n\tconst cells: CellDecl[] = [];\n\tfor (const [name, cell] of Object.entries(options.cells ?? {})) {\n\t\tconst { onChange: _onChange, ...decl } = cell;\n\t\tconst full: CellDecl = { name, ...decl };\n\t\tif (full.access === \"readwrite\") {\n\t\t\tfull.policy ??= \"auto\";\n\t\t\tif (isSized(full.type)) full.timeout ??= DEFAULT_KNOB_TIMEOUT;\n\t\t}\n\t\tcells.push(full);\n\t}\n\tconst events: EventDecl[] = [];\n\tfor (const [name, event] of Object.entries(options.events ?? {})) {\n\t\tconst full: EventDecl = { name, ...event };\n\t\tfull.wakes ??= \"never\";\n\t\tevents.push(full);\n\t}\n\tconst capabilities: CapabilityDecl[] = [];\n\tfor (const [name, capability] of Object.entries(options.capabilities ?? {})) {\n\t\tconst { handler: _handler, ...decl } = capability;\n\t\tcapabilities.push({\n\t\t\tname,\n\t\t\t...decl,\n\t\t\tdispatch: decl.dispatch ?? \"safepoint\",\n\t\t\ttimeout: decl.timeout ?? DEFAULT_CAPABILITY_TIMEOUT,\n\t\t\tpolicy: decl.policy ?? (decl.effect === \"mutate\" ? \"confirm\" : \"auto\"),\n\t\t});\n\t}\n\tconst decisions: DecisionDecl[] = [];\n\tfor (const [name, decision] of Object.entries(options.decisions ?? {})) {\n\t\tdecisions.push({ name, ...decision, policy: decision.policy ?? \"auto\" });\n\t}\n\tconst turns: TurnDecl[] = [];\n\tfor (const [name, turn] of Object.entries(options.turns ?? {})) {\n\t\tif (options.decisions?.[name] !== undefined) {\n\t\t\tthrow new Error(`the declarations of ${options.name} do not validate: ${name} is both a decision and a turn`);\n\t\t}\n\t\tturns.push({ name, ...turn });\n\t}\n\tconst deviations = [...(options.deviations ?? []), ...INSTANTIATION_DEVIATIONS];\n\tif (options.modes.includes(\"sidecar\")) deviations.push(SIDECAR_DEVIATION);\n\n\tconst manifest: Manifest = {\n\t\tabaigrammar: ABAIGRAMMAR_VERSION,\n\t\tname: options.name,\n\t\tentry: options.entry ?? `${options.name} abai`,\n\t\tmodes: [...options.modes],\n\t\t...(options.harness === undefined ? {} : { harness: options.harness }),\n\t\t...(options.model === undefined ? {} : { model: options.model }),\n\t\t...(options.check === undefined ? {} : { check: options.check }),\n\t\tcontent: { identity: \"abai/identity.md\", ...(options.content ?? {}) },\n\t\taudit: options.audit ?? { path: `~/.abai/audit/${options.name}.jsonl` },\n\t\t...(options.lifecycle === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\tlifecycle: {\n\t\t\t\t\t\tpause: options.lifecycle.pause,\n\t\t\t\t\t\t...(options.lifecycle.stop === undefined\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: { stop: { graceful: options.lifecycle.stop.graceful, handler: \"stop\" } }),\n\t\t\t\t\t\t...(options.lifecycle.policy === undefined ? {} : { policy: options.lifecycle.policy }),\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t...(options.attention === undefined ? {} : { attention: options.attention }),\n\t\t...(options.policy === undefined ? {} : { policy: options.policy }),\n\t\tdeviations,\n\t\tcells,\n\t\tevents,\n\t\tcapabilities,\n\t\tdecisions,\n\t\tturns,\n\t};\n\tconst violations = validateManifest(manifest);\n\tif (violations.length > 0) {\n\t\tthrow new Error(`the declarations of ${options.name} do not validate: ${violations.join(\"; \")}`);\n\t}\n\treturn manifest;\n}\n"]}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAMA,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,IAAI,EACT,KAAK,MAAM,EACX,KAAK,QAAQ,EAEb,MAAM,wBAAwB,CAAC;AAEhC,uFAAuF;AACvF,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAChG,kGAAkG;AAClG,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AACnD,6EAA6E;AAC7E,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAErD,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAC9E,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AACnD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC,GAAG;IAClG,QAAQ,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,Y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,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACpC;AAED,kGAAkG;AAClG,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAKrD,CAAC;AACF,eAAO,MAAM,gBAAgB,+nBACgmB,CAAC;AAC9nB,eAAO,MAAM,iBAAiB,kXACkV,CAAC;AAEjX,eAAO,MAAM,0BAA0B,QAAQ,CAAC;AAChD,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAM1C,qGAAqG;AACrG,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CA+EhE","sourcesContent":["// Declarations in code become the manifest (abaigrammar section 7). The\n// program hands `createAbaigram` keyed records; this module turns them into\n// the manifest's lists in insertion order, fills the grammar's defaults so\n// the rendered abaigram.yaml is explicit and byte-stable, appends the\n// deviations this TypeScript instantiation declares, and validates. An\n// invalid declaration throws at startup: declared, not discovered.\nimport {\n\tABAIGRAMMAR_VERSION,\n\ttype CapabilityDecl,\n\ttype CellDecl,\n\ttype DecisionDecl,\n\ttype EventDecl,\n\ttype Manifest,\n\ttype Mode,\n\ttype Policy,\n\ttype TurnDecl,\n\tvalidateManifest,\n} from \"./manifest/manifest.ts\";\n\n/** A capability's handler: parameters in, a result out; a throw is an error result. */\nexport type CapabilityHandler = (params: Record<string, unknown>) => unknown | Promise<unknown>;\n/** A sized knob's handler: the delivered value, at a safepoint, on the thread that reached it. */\nexport type KnobHandler = (value: unknown) => void;\n/** The stop handler, run at a safepoint on a graceful stop (section 5.5). */\nexport type StopHandler = () => void | Promise<void>;\n\nexport type CellOptions = Omit<CellDecl, \"name\"> & { onChange?: KnobHandler };\nexport type EventOptions = Omit<EventDecl, \"name\">;\nexport type CapabilityOptions = Omit<CapabilityDecl, \"name\" | \"dispatch\" | \"policy\" | \"timeout\"> & {\n\tdispatch?: CapabilityDecl[\"dispatch\"];\n\tpolicy?: Policy;\n\ttimeout?: string;\n\thandler?: CapabilityHandler;\n};\nexport type DecisionOptions = Omit<DecisionDecl, \"name\" | \"policy\"> & { policy?: Policy };\nexport type TurnOptions = Omit<TurnDecl, \"name\">;\n\nexport interface AbaigramOptions {\n\tname: string;\n\t/** Default `<name> abai`. */\n\tentry?: string;\n\tmodes: Mode[];\n\t/** Paths relative to the program's root; `identity` defaults to `abai/identity.md`. */\n\tcontent?: Partial<Manifest[\"content\"]>;\n\t/** Default `~/.abai/audit/<name>.jsonl`. */\n\taudit?: Manifest[\"audit\"];\n\tharness?: Manifest[\"harness\"];\n\tmodel?: Manifest[\"model\"];\n\tcheck?: Manifest[\"check\"];\n\tlifecycle?: Omit<NonNullable<Manifest[\"lifecycle\"]>, \"stop\"> & {\n\t\tstop?: { graceful: string; handler: StopHandler };\n\t};\n\tattention?: Manifest[\"attention\"];\n\tpolicy?: Manifest[\"policy\"];\n\t/** The agent may be a member of an agent network; `doc` says how its members relate to this program's names. */\n\tnetwork?: Manifest[\"network\"];\n\t/** The program's own deviations; the instantiation's are appended. */\n\tdeviations?: string[];\n\tcells?: Record<string, CellOptions>;\n\tevents?: Record<string, EventOptions>;\n\tcapabilities?: Record<string, CapabilityOptions>;\n\tdecisions?: Record<string, DecisionOptions>;\n\tturns?: Record<string, TurnOptions>;\n}\n\n/** Where this TypeScript instantiation departs from the grammar, in every manifest it renders. */\nexport const INSTANTIATION_DEVIATIONS: readonly string[] = [\n\t\"Touchpoints are awaited promises: Node cannot block its only thread while the agent loop runs on it, so the program's logic pauses at the await while its own timers and I/O callbacks keep running (section 4.3).\",\n\t\"Sized cell writes and event payload copies allocate: JavaScript has no copy into a preallocated byte slot; scalar rows meet section 11.2, sized rows are measured and reported.\",\n\t\"A cooperative pause holds the program at its next touchpoint, not inside safepoint(): a safepoint cannot block, since the resume arrives on the same event loop that would be blocked. The flag is still one load at a safepoint, and os pause (the launcher's signal) holds the program anywhere (section 5.5).\",\n\t\"Under launch the child is attached as soon as its endpoint is accepted, a moment after its first statement rather than before it: Node cannot listen in a constructor. A program that wants the agent present from its first line awaits attach() (section 6.3).\",\n];\nexport const THREAD_DEVIATION =\n\t\"In thread mode the harness has no thread of its own: Node runs one event loop, so the harness runs on the program's loop between the program's callbacks, live, and a long synchronous step on either side delays the other. Isolation is what one loop allows: a harness listener that throws while the program emits, decides or gives a turn is caught at the binding, a failed agent run ends that run alone, and a model unreachable at first contact detaches the harness, so the program goes on as itself; an exception or rejection the harness lets escape to the process is a process fault, as for any library on the same loop (section 6.2).\";\nexport const SIDECAR_DEVIATION =\n\t\"In sidecar mode the region is not shared memory: cells are read by request and events cross the socket, so observation costs the program one serialization per connected harness (section 11.3). Under ABAI_HARNESS=null or exercise the null harness stays in the program's process and no endpoint opens, so a check run's measured overhead leaves that serialization out.\";\n\nexport const DEFAULT_CAPABILITY_TIMEOUT = \"30s\";\nexport const DEFAULT_KNOB_TIMEOUT = \"30s\";\n\nfunction isSized(type: CellDecl[\"type\"]): boolean {\n\treturn type === \"string\" || type === \"object\" || type === \"list\";\n}\n\n/** Build the explicit, validated manifest from the program's declarations. Throws on a violation. */\nexport function buildManifest(options: AbaigramOptions): Manifest {\n\tconst cells: CellDecl[] = [];\n\tfor (const [name, cell] of Object.entries(options.cells ?? {})) {\n\t\tconst { onChange: _onChange, ...decl } = cell;\n\t\tconst full: CellDecl = { name, ...decl };\n\t\tif (full.access === \"readwrite\") {\n\t\t\tfull.policy ??= \"auto\";\n\t\t\tif (isSized(full.type)) full.timeout ??= DEFAULT_KNOB_TIMEOUT;\n\t\t}\n\t\tcells.push(full);\n\t}\n\tconst events: EventDecl[] = [];\n\tfor (const [name, event] of Object.entries(options.events ?? {})) {\n\t\tconst full: EventDecl = { name, ...event };\n\t\tfull.wakes ??= \"never\";\n\t\tevents.push(full);\n\t}\n\tconst capabilities: CapabilityDecl[] = [];\n\tfor (const [name, capability] of Object.entries(options.capabilities ?? {})) {\n\t\tconst { handler: _handler, ...decl } = capability;\n\t\tcapabilities.push({\n\t\t\tname,\n\t\t\t...decl,\n\t\t\tdispatch: decl.dispatch ?? \"safepoint\",\n\t\t\ttimeout: decl.timeout ?? DEFAULT_CAPABILITY_TIMEOUT,\n\t\t\tpolicy: decl.policy ?? (decl.effect === \"mutate\" ? \"confirm\" : \"auto\"),\n\t\t});\n\t}\n\tconst decisions: DecisionDecl[] = [];\n\tfor (const [name, decision] of Object.entries(options.decisions ?? {})) {\n\t\tdecisions.push({ name, ...decision, policy: decision.policy ?? \"auto\" });\n\t}\n\tconst turns: TurnDecl[] = [];\n\tfor (const [name, turn] of Object.entries(options.turns ?? {})) {\n\t\tif (options.decisions?.[name] !== undefined) {\n\t\t\tthrow new Error(`the declarations of ${options.name} do not validate: ${name} is both a decision and a turn`);\n\t\t}\n\t\tturns.push({ name, ...turn });\n\t}\n\tconst deviations = [...(options.deviations ?? []), ...INSTANTIATION_DEVIATIONS];\n\tif (options.modes.includes(\"thread\")) deviations.push(THREAD_DEVIATION);\n\tif (options.modes.includes(\"sidecar\")) deviations.push(SIDECAR_DEVIATION);\n\n\tconst manifest: Manifest = {\n\t\tabaigrammar: ABAIGRAMMAR_VERSION,\n\t\tname: options.name,\n\t\tentry: options.entry ?? `${options.name} abai`,\n\t\tmodes: [...options.modes],\n\t\t...(options.harness === undefined ? {} : { harness: options.harness }),\n\t\t...(options.model === undefined ? {} : { model: options.model }),\n\t\t...(options.check === undefined ? {} : { check: options.check }),\n\t\tcontent: { identity: \"abai/identity.md\", ...(options.content ?? {}) },\n\t\taudit: options.audit ?? { path: `~/.abai/audit/${options.name}.jsonl` },\n\t\t...(options.lifecycle === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\tlifecycle: {\n\t\t\t\t\t\tpause: options.lifecycle.pause,\n\t\t\t\t\t\t...(options.lifecycle.stop === undefined\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: { stop: { graceful: options.lifecycle.stop.graceful, handler: \"stop\" } }),\n\t\t\t\t\t\t...(options.lifecycle.policy === undefined ? {} : { policy: options.lifecycle.policy }),\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t...(options.attention === undefined ? {} : { attention: options.attention }),\n\t\t...(options.policy === undefined ? {} : { policy: options.policy }),\n\t\t...(options.network === undefined ? {} : { network: options.network }),\n\t\tdeviations,\n\t\tcells,\n\t\tevents,\n\t\tcapabilities,\n\t\tdecisions,\n\t\tturns,\n\t};\n\tconst violations = validateManifest(manifest);\n\tif (violations.length > 0) {\n\t\tthrow new Error(`the declarations of ${options.name} do not validate: ${violations.join(\"; \")}`);\n\t}\n\treturn manifest;\n}\n"]}
package/dist/registry.js CHANGED
@@ -12,6 +12,7 @@ export const INSTANTIATION_DEVIATIONS = [
12
12
  "A cooperative pause holds the program at its next touchpoint, not inside safepoint(): a safepoint cannot block, since the resume arrives on the same event loop that would be blocked. The flag is still one load at a safepoint, and os pause (the launcher's signal) holds the program anywhere (section 5.5).",
13
13
  "Under launch the child is attached as soon as its endpoint is accepted, a moment after its first statement rather than before it: Node cannot listen in a constructor. A program that wants the agent present from its first line awaits attach() (section 6.3).",
14
14
  ];
15
+ export const THREAD_DEVIATION = "In thread mode the harness has no thread of its own: Node runs one event loop, so the harness runs on the program's loop between the program's callbacks, live, and a long synchronous step on either side delays the other. Isolation is what one loop allows: a harness listener that throws while the program emits, decides or gives a turn is caught at the binding, a failed agent run ends that run alone, and a model unreachable at first contact detaches the harness, so the program goes on as itself; an exception or rejection the harness lets escape to the process is a process fault, as for any library on the same loop (section 6.2).";
15
16
  export const SIDECAR_DEVIATION = "In sidecar mode the region is not shared memory: cells are read by request and events cross the socket, so observation costs the program one serialization per connected harness (section 11.3). Under ABAI_HARNESS=null or exercise the null harness stays in the program's process and no endpoint opens, so a check run's measured overhead leaves that serialization out.";
16
17
  export const DEFAULT_CAPABILITY_TIMEOUT = "30s";
17
18
  export const DEFAULT_KNOB_TIMEOUT = "30s";
@@ -60,6 +61,8 @@ export function buildManifest(options) {
60
61
  turns.push({ name, ...turn });
61
62
  }
62
63
  const deviations = [...(options.deviations ?? []), ...INSTANTIATION_DEVIATIONS];
64
+ if (options.modes.includes("thread"))
65
+ deviations.push(THREAD_DEVIATION);
63
66
  if (options.modes.includes("sidecar"))
64
67
  deviations.push(SIDECAR_DEVIATION);
65
68
  const manifest = {
@@ -85,6 +88,7 @@ export function buildManifest(options) {
85
88
  }),
86
89
  ...(options.attention === undefined ? {} : { attention: options.attention }),
87
90
  ...(options.policy === undefined ? {} : { policy: options.policy }),
91
+ ...(options.network === undefined ? {} : { network: options.network }),
88
92
  deviations,
89
93
  cells,
90
94
  events,