kernel

Everything a cognet can do outside its own world. See Kernel for why there is only one door.

VerbDoes
outputtells the body something
runruns code in the agent's sandbox
bodywhat the body says it is
presencewhether the body is the mind's to move
scopewhat the sandbox can run right now
basethe user's identity text
emitthe mind's own telemetry
faultreports a model breaking the mind's grammar
store, knowledge, memorywhat outlives a session
// ambient — never imported
kernel.output(type: OutputType, data: OutputData): Promise<void>
kernel.run(code: string): Promise<RunResult>
kernel.run(code: string[]): Promise<RunResult[]>
kernel.body(): Manifest | null
kernel.presence(): Presence | null
kernel.scope(): Scope
kernel.base(): Promise<string>
kernel.emit(type: CognetEvent, data: unknown): void
kernel.fault(fault: { code: string; message: string; excerpt?: string }): Promise<void>

output, emit and fault need no answer, so any system may use them: in a sync system they are made when its run lands, in order, with its writes; in an async one, as they are made. body, presence and scope are as they stood when the run began. Everything else needs an answer, so only an async system may ask — it runs beside the tick, and its writes land on a later one. A worker system has no kernel.

output

Acts on the body — one act, on one of the controls it declared. Every kind, field and control type is on Output.

kernel.output("cognet:output:vector", { channel: "/wheels", values: [0.4, 0.4], basis: sensed })

run

Runs code in the agent's sandbox, checked against its policy. Never throws — success and failure both come back as a result.

const result = await kernel.run(`await search("arxiv", "depth estimation")`)
if (!result.ok) console.warn(result.error?.kind)   // "timeout" | "policy" | "interrupt" | "exception"

const [a, b] = await kernel.run([blockA, blockB])   // concurrent, results in order
FieldIs
okit ran, and policy refused nothing
valuewhat the code evaluated to
stdouteverything it printed, one entry per call
error{ kind, message } when it failed
denialscalls policy refused — a block with any is not ok

The kernel records the code and its result itself. The cognet writes nothing.

body

What the body said it is: its senses, its controls, how its parts sit. null until a body is worn. Find senses by what they are, never by channel.

const eye = kernel.body()?.senses.find(sense => sense.kind === "visual")

presence

Whether the body is the mind's to move right now. null until the body says.

StateMeans
embodiedcommands are applied
heldan emergency stop, a safe mode, asleep — commands are not applied
overriddensomeone else is driving — commands are not applied

Senses keep arriving in every state. held and overridden carry a why.

scope

Every module and function the sandbox can run right now — and, under unavailable, what failed to load. A mind that shows its model unavailable can say "I can't search arXiv right now" instead of guessing.

base

The user's identity text for this agent, rendered. "" when there is none, never null.

emit

The mind's own telemetry: recorded, shown in the debugger, never shown to the user. Types are cognet:* only — a mind can't forge the kernel's events. Rarely needed: every system run and every write is already recorded.

kernel.emit("cognet:log:info", { value: "map rebuilt from 412 looks" })

fault

For a mind that renders a model's output: reports that the model broke the mind's grammar. The kernel puts it in the model's next context, so the model sees its mistake and corrects. Never shown to the user.

await kernel.fault({ code: "UNDECLARED_BINDING", message: "interpolated {total}, which the script never declared" })

Errors

ErrorWhen
COGNET_ACCESSED_BEFORE_LOADa verb called at the top level of a file, before the mind loaded
COGNET_WORKER_KERNELa verb called from a worker system