@arcforge/types 2.0.59

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.
Files changed (59) hide show
  1. package/package.json +29 -0
  2. package/src/bench/aggregate.ts +67 -0
  3. package/src/bench/artifact.ts +39 -0
  4. package/src/bench/bench.ts +62 -0
  5. package/src/bench/contribution.ts +40 -0
  6. package/src/bench/dimension.ts +15 -0
  7. package/src/bench/execution.ts +76 -0
  8. package/src/bench/factor.ts +69 -0
  9. package/src/bench/index.ts +108 -0
  10. package/src/bench/manifest.ts +49 -0
  11. package/src/bench/measurement.ts +41 -0
  12. package/src/bench/observation.ts +42 -0
  13. package/src/bench/protocol.ts +21 -0
  14. package/src/bench/result.ts +32 -0
  15. package/src/bench/value.ts +7 -0
  16. package/src/bench/workspace.ts +76 -0
  17. package/src/blueprint.ts +125 -0
  18. package/src/capsule-config.ts +111 -0
  19. package/src/cognet/blueprint.ts +38 -0
  20. package/src/cognet/cognet.ts +69 -0
  21. package/src/cognet/hooks.ts +43 -0
  22. package/src/cognet/index.ts +3 -0
  23. package/src/config.ts +72 -0
  24. package/src/define.ts +184 -0
  25. package/src/deploy.ts +54 -0
  26. package/src/engine.ts +254 -0
  27. package/src/error.ts +88 -0
  28. package/src/handle.ts +137 -0
  29. package/src/hooks.ts +31 -0
  30. package/src/http.ts +49 -0
  31. package/src/index.ts +23 -0
  32. package/src/kernel/abi.ts +244 -0
  33. package/src/kernel/index.ts +2 -0
  34. package/src/middleware.ts +7 -0
  35. package/src/module.ts +193 -0
  36. package/src/plugin.ts +9 -0
  37. package/src/policy.ts +89 -0
  38. package/src/prompts.ts +25 -0
  39. package/src/route.ts +15 -0
  40. package/src/scope.ts +29 -0
  41. package/src/scripts.ts +21 -0
  42. package/src/session/envelope.ts +61 -0
  43. package/src/session/events/activity.ts +77 -0
  44. package/src/session/events/bench.ts +49 -0
  45. package/src/session/events/capsule.ts +114 -0
  46. package/src/session/events/cognet.ts +51 -0
  47. package/src/session/events/engine.ts +46 -0
  48. package/src/session/events/entries.ts +66 -0
  49. package/src/session/events/kernel.ts +44 -0
  50. package/src/session/events/log.ts +27 -0
  51. package/src/session/events/runtime.ts +76 -0
  52. package/src/session/events/stdio/output.ts +94 -0
  53. package/src/session/events/stdio/shared.ts +50 -0
  54. package/src/session/events/stdio/stimuli.ts +110 -0
  55. package/src/session/events/test.ts +52 -0
  56. package/src/session/index.ts +40 -0
  57. package/src/session/session.ts +107 -0
  58. package/src/tools.ts +54 -0
  59. package/tsconfig.base.json +14 -0
package/src/handle.ts ADDED
@@ -0,0 +1,137 @@
1
+ import type { AxonEntry } from "./session"
2
+ import type { AxonScript } from "./scripts"
3
+ import type { AxonPartialBlueprint } from "./blueprint"
4
+ import type { AxonHookName, AxonHooks } from "./hooks"
5
+ import type { AxonAmbient } from "./session/events/activity"
6
+
7
+ /**
8
+ * Cross-package contracts for the new runtime.
9
+ *
10
+ * Only seams that more than one package depends on live here:
11
+ * - AxonHandle — what agent code sees (globalThis.axon, plugins, scripts)
12
+ * - EngineConnection — what @axon/cloud hands @axon/core for inference
13
+ *
14
+ * Intra-core handles (session, capsule manager, server) are
15
+ * `ReturnType<typeof X>` inside @axon/core — they are not contracts.
16
+ */
17
+
18
+ // ── Engine connection (implemented by @axon/cloud, consumed by @axon/core) ───
19
+
20
+ /** Input to a single agent invocation. */
21
+ export type AxonRequestInput = {
22
+ /** One stimulus, or an ordered batch committed before a single wake. */
23
+ prompt: string | string[]
24
+ }
25
+
26
+ /** Result of a completed agent invocation. */
27
+ export type AxonResult = {
28
+ /** Final response text. */
29
+ text: string
30
+ /** Entries appended during this invocation, in order. */
31
+ entries: AxonEntry[]
32
+ }
33
+
34
+ /** One live invocation. Cancellation is scoped to this exact wake. */
35
+ export type AxonRun = {
36
+ stream: AsyncGenerator<AxonEntry, void, undefined>
37
+ /** Request cancellation. Returns immediately; teardown completes on the stream. */
38
+ interrupt(): void
39
+ }
40
+
41
+ /**
42
+ * What core hands cloud for Cognos to call back into mid-loop. All fields
43
+ * are lazy getters — the capsule boots after the connection is constructed,
44
+ * and the connection dials lazily anyway.
45
+ */
46
+ /**
47
+ * The capsule surface an engine delegate may drive — hand-written seam
48
+ * contract (the implementation type lives in @axon/capsule; this is what
49
+ * the wire actually needs: execute + cancel).
50
+ */
51
+ export type CapsuleDelegate = {
52
+ run(code: string, opts?: { timeoutMs?: number }): Promise<unknown>
53
+ interrupt(): void
54
+ }
55
+
56
+ export type EngineDelegate = {
57
+ /** Tool execution target. Absent/undefined = no capsule attached; capsule RPCs reject loudly. */
58
+ capsule?: () => CapsuleDelegate | undefined
59
+ /** Prompt template renderer — backs Cognos's prompt.render RPC. */
60
+ prompt?: (name: string, props?: Record<string, unknown>) => Promise<string>
61
+ }
62
+
63
+ /**
64
+ * A live connection to a Cognos engine. @axon/cloud owns how this is
65
+ * established (ws3, auth, engine resolution); @axon/core only ever
66
+ * dispatches through it. Deliberately Cognos-agnostic — this type is the
67
+ * open-source boundary and must never leak ws3/Cognos internals.
68
+ */
69
+ export type EngineConnection = {
70
+ request(input: AxonRequestInput): Promise<AxonResult>
71
+ stream(input: AxonRequestInput): AsyncGenerator<AxonEntry, void, undefined>
72
+ /** Hot reload — re-project the blueprint and push the refreshed surface to Cognos. */
73
+ update(blueprint: import("./blueprint").AxonBlueprint): Promise<void>
74
+ disconnect(): Promise<void>
75
+ }
76
+
77
+ // ── Lifecycle hooks surface ────────────────────────────────────────────────────
78
+
79
+ /**
80
+ * The hooks surface exposed on AxonHandle — register-only. Firing (`callHook`)
81
+ * is runtime-internal; agent code and plugins only ever register.
82
+ */
83
+ export type AxonHooksSurface = {
84
+ hook<N extends AxonHookName>(name: N, fn: AxonHooks[N]): () => void
85
+ removeHook<N extends AxonHookName>(name: N, fn: AxonHooks[N]): void
86
+ }
87
+
88
+ // ── AxonHandle ────────────────────────────────────────────────────────────────
89
+
90
+ /**
91
+ * The runtime handle agent code programs against — injected as the `axon`
92
+ * global inside scripts, handed to plugins and module setup. This is the
93
+ * user surface: anything on it is public API.
94
+ *
95
+ * No thread concept: one Axon() instance is always exactly one continuous
96
+ * stream. Multiple independent conversations are multiple Axon() instances,
97
+ * a host-level (TUI) concern this handle has no opinion on.
98
+ */
99
+ export type AxonHandle = {
100
+ /** Render a prompt by name. Static .md returns as-is; dynamic .vue renders with props. */
101
+ prompt(name: string, props?: Record<string, unknown>): Promise<string>
102
+
103
+ /** One-shot agent invocation. */
104
+ request(input: AxonRequestInput | string): Promise<AxonResult>
105
+
106
+ /** Streaming agent invocation — yields entries as they happen. */
107
+ stream(input: AxonRequestInput | string): AxonRun
108
+
109
+ scripts: {
110
+ request(name: string, args?: Record<string, unknown>): Promise<unknown>
111
+ list(): AxonScript[]
112
+ }
113
+
114
+ /** Installed tool namespaces, callable by name — each call is a mediated capsule request. */
115
+ tools: Record<string, Record<string, (...args: unknown[]) => Promise<unknown>>>
116
+
117
+ /** Hot-reload trigger — apply a partial blueprint to the live runtime. */
118
+ update(partial: AxonPartialBlueprint): Promise<void>
119
+
120
+ hooks: AxonHooksSurface
121
+
122
+ /**
123
+ * Minimal session identity — enough for a script to key its own state
124
+ * or logging off which session it's running in. Everything else about
125
+ * the session (log, kernelLog, raw commit) is core-internal.
126
+ */
127
+ session: { id: string }
128
+ }
129
+
130
+ /**
131
+ * The honest Axon surface inside a capsule tool. A tool cannot re-enter the
132
+ * Axon instance currently waiting for it, so request() is host-mediated and
133
+ * runs on an isolated child instance.
134
+ */
135
+ export type AxonCapsuleHandle = AxonAmbient & {
136
+ request(input: AxonRequestInput | string): Promise<AxonResult>
137
+ }
package/src/hooks.ts ADDED
@@ -0,0 +1,31 @@
1
+ import type { EventHandler as H3EventHandler } from "h3"
2
+
3
+ /**
4
+ * Runtime lifecycle hooks — Nitro/Nuxt-style call points the runtime itself
5
+ * awaits at fixed points during boot, request handling, and shutdown.
6
+ *
7
+ * Distinct from the event bus (`axon.on`/`axon.emit`): the bus is many-to-many
8
+ * fire-and-forget notification for module/domain events (`github:issue.opened`).
9
+ * These are one call point, in-order, awaited-to-completion — the runtime
10
+ * pauses here for every registered handler before continuing. Registered via
11
+ * `axon.hooks.hook(name, fn)` in `server/plugins/*.ts`; fired by the runtime,
12
+ * never by agent code.
13
+ *
14
+ * Add a call point here first — the type is the contract; Axon()/AxonServer()
15
+ * fire what's declared, nothing more.
16
+ */
17
+ export type AxonHooks = {
18
+ /** Runtime finished assembling — kernel, handle, and server are all live. */
19
+ "boot:after": () => void | Promise<void>
20
+
21
+ /** Fires once per incoming request, before the route handler runs. */
22
+ "request:before": H3EventHandler
23
+
24
+ /** Fires once per completed request, after the route handler resolved. */
25
+ "request:after": H3EventHandler
26
+
27
+ /** Runtime teardown has started — kernel/capsule/session are still alive. */
28
+ "shutdown:before": () => void | Promise<void>
29
+ }
30
+
31
+ export type AxonHookName = keyof AxonHooks
package/src/http.ts ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * HTTP error contract shared across the Axon stack.
3
+ *
4
+ * Lives in @arcforge/types (not @arclabs/cloud) because it is a wire contract:
5
+ * engines, cloud transport, and CLI publish/deploy flows all branch on
6
+ * `err.code` / `err.data`. @arclabs/cloud re-exports it so existing internal
7
+ * imports keep working; @arcforge/engines depends on it directly so it can be
8
+ * published to npm without pulling in internal cloud transport.
9
+ */
10
+
11
+ export type HttpErrorCode =
12
+ | "AUTH_REQUIRED" // no key available when one was required
13
+ | "AUTH_EXPIRED" // 401
14
+ | "FORBIDDEN" // 403
15
+ | "NOT_FOUND" // 404
16
+ | "CONFLICT" // 409
17
+ | "PAYLOAD_TOO_LARGE" // 413
18
+ | "RATE_LIMITED" // 429
19
+ | "SERVICE_UNAVAILABLE" // 503
20
+ | "SERVER_ERROR" // other 5xx / unclassified
21
+
22
+ export function classifyStatus(status: number): HttpErrorCode {
23
+ switch (status) {
24
+ case 401: return "AUTH_EXPIRED"
25
+ case 403: return "FORBIDDEN"
26
+ case 404: return "NOT_FOUND"
27
+ case 409: return "CONFLICT"
28
+ case 413: return "PAYLOAD_TOO_LARGE"
29
+ case 429: return "RATE_LIMITED"
30
+ case 503: return "SERVICE_UNAVAILABLE"
31
+ default: return "SERVER_ERROR"
32
+ }
33
+ }
34
+
35
+ export class HttpError extends Error {
36
+ code: HttpErrorCode
37
+ status: number
38
+ path: string
39
+ /** Structured error body from the backend (h3 createError `data`), when present. */
40
+ data?: Record<string, unknown>
41
+
42
+ constructor(status: number, path: string, message?: string, data?: Record<string, unknown>) {
43
+ super(message ?? `request to ${path} failed with status ${status}`)
44
+ this.code = classifyStatus(status)
45
+ this.status = status
46
+ this.path = path
47
+ if (data) this.data = data
48
+ }
49
+ }
package/src/index.ts ADDED
@@ -0,0 +1,23 @@
1
+ export * from "./blueprint"
2
+ export * from "./config"
3
+ export * from "./define"
4
+ export * from "./deploy"
5
+ export * from "./engine"
6
+ export * from "./error"
7
+ export * from "./http"
8
+ export * from "./handle"
9
+ export * from "./hooks"
10
+ export * from "./middleware"
11
+ export * from "./module"
12
+ export * from "./plugin"
13
+ export * from "./policy"
14
+ export * from "./capsule-config"
15
+ export * from "./prompts"
16
+ export * from "./route"
17
+ export * from "./scripts"
18
+ export * from "./scope"
19
+ export * from "./session"
20
+ export * from "./kernel"
21
+ export * from "./cognet"
22
+ export * from "./tools"
23
+ export * from "./bench"
@@ -0,0 +1,244 @@
1
+ import type { AxonEngineRequest } from "../engine"
2
+ import type { AxonEngineEvent } from "../session/events/engine"
3
+ import type { AxonEntry } from "../session/session"
4
+ import type { AxonOutputEvent } from "../session/events/stdio/output"
5
+ import type { AxonStimulusEntry } from "../session/events/stdio/stimuli"
6
+ import type { CognetEventMap } from "../session/events/cognet"
7
+ import type { AxonScope } from "../scope"
8
+
9
+ /**
10
+ * The current kernel ABI contract version. Program definitions declare the
11
+ * version they were built against; the kernel refuses loudly on mismatch.
12
+ * Bump on any breaking change to KernelAbi or CognetWake — reluctantly,
13
+ * like the syscall table it is.
14
+ *
15
+ * THE VERSIONED SURFACE IS MORE THAN THE FUNCTION SHAPES. A cognet is a
16
+ * prebuilt bundle: it compiled against a snapshot of every payload type
17
+ * this file references — AxonOutputEvent (output), AxonEngineRequest /
18
+ * AxonEngineEvent (stream), CognetEventMap (emit), AxonEntry
19
+ * (the wake wire). A breaking change to ANY of those is a breaking change to the
20
+ * ABI and requires a version bump, even though no signature here moved —
21
+ * otherwise a stale bundle loads cleanly under a matching version number
22
+ * and misreads events at runtime. Nothing enforces this mechanically yet;
23
+ * the rule is the enforcement. (Additive changes — new event types, new
24
+ * optional fields — are compatible, like new syscalls.)
25
+ */
26
+ export const KERNEL_ABI_VERSION = "9"
27
+
28
+ /**
29
+ * The cognet's own store schema — EMPTY here by design. A cognet declares
30
+ * its keys/values once via declaration merging (the same pattern Nuxt uses
31
+ * for runtime config, Vue for ComponentCustomProperties):
32
+ *
33
+ * // anywhere in the cognet's own sources
34
+ * declare global {
35
+ * interface CognetStoreSchema {
36
+ * checkpoint: { entries: unknown[]; seq: number }
37
+ * }
38
+ * }
39
+ *
40
+ * kernel.store.get/set are typed against keyof this interface, so a cognet
41
+ * with no declaration has no callable kv (keyof {} is never) — declaring
42
+ * the schema IS opting in. Each bundle compiles against its own
43
+ * augmentation; nothing leaks between cognets.
44
+ *
45
+ * Declared GLOBAL (not module-scoped) deliberately: a cognet augments it
46
+ * with a plain `declare global` block — module augmentation would force
47
+ * every author to name this package's specifier, which is exactly the
48
+ * kind of plumbing the ambient-globals authoring surface exists to hide.
49
+ */
50
+ declare global {
51
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
52
+ interface CognetStoreSchema {}
53
+ }
54
+
55
+ /**
56
+ * Private cognitive state + the episodic record, one door (kernel.store).
57
+ *
58
+ * Two rooms with two ownership regimes, deliberately asymmetric:
59
+ * - `session` — the session's entry log, READ-ONLY. This is how a cognet
60
+ * reaches its own history (cold-boot rehydration, context rebuilds)
61
+ * without the runtime passing anything in at boot. Entries only — never
62
+ * kernel telemetry, never error machinery. There is no write verb here
63
+ * and never will be: the cognet's only writes to the world are
64
+ * kernel.output()/kernel.run(); a patchable record is a footgun by
65
+ * construction.
66
+ * - the kv — the cognet's private consolidated state. One flat namespace
67
+ * per cognet (keyed by cognet name on disk); the kernel imposes NO
68
+ * lifetime taxonomy — a cognet that wants session-scoped keys prefixes
69
+ * with the sessionId it already has from every entry's envelope.
70
+ * Doctrine: this is a CACHE over the log. Atomic per key,
71
+ * last-write-wins (it's the one writable surface concurrent instances
72
+ * of the same agent share), unreadable/stale state is discarded and
73
+ * rebuilt from `session` — deleting data/state/ is always safe.
74
+ */
75
+ export type KernelStore = {
76
+ session: {
77
+ /**
78
+ * The session's entries so far, in seq order — the same envelopes
79
+ * stimuli arrive as. `after` is a seq cursor: boot reads all and
80
+ * remembers its high-water mark; steady-state never re-reads
81
+ * history it already folded. Synchronous — this is the kernel's
82
+ * live in-memory projection, not a disk read.
83
+ */
84
+ get(opts?: { after?: number }): readonly AxonEntry[]
85
+ }
86
+
87
+ /** Read one key. Null when absent (or unreadable — cache doctrine: rebuild, don't crash). */
88
+ get<K extends keyof CognetStoreSchema>(key: K): Promise<CognetStoreSchema[K] | null>
89
+
90
+ /** Write one key. Atomic (temp+rename); resolves when durable. */
91
+ set<K extends keyof CognetStoreSchema>(key: K, value: CognetStoreSchema[K]): Promise<void>
92
+ }
93
+
94
+ /**
95
+ * The outcome of one capsule run — success and failure are both ordinary
96
+ * values here, never a rejection. `stdout` is every console.* call this
97
+ * specific block made, in order, already joined into lines by the kernel —
98
+ * a program that wants it folded into a committed result just reads it,
99
+ * it never wires a console callback to build it itself.
100
+ */
101
+ export type AxonRunResult = {
102
+ ok: boolean
103
+ /** The block's completion value when ok. Undefined on failure. */
104
+ value?: unknown
105
+ /** console.* output from this block, in order, one entry per call. */
106
+ stdout: string[]
107
+ error?: { kind: "timeout" | "interrupt" | "exception"; message: string }
108
+ }
109
+
110
+ /**
111
+ * The kernel ABI — the syscall table. Everything a program may touch.
112
+ *
113
+ * Hand-written contract (cross-package seam): programs are versioned
114
+ * against this exactly like binaries against syscalls — the kernel evolves
115
+ * freely as long as this shape holds.
116
+ *
117
+ * Design rules:
118
+ * - There is no thread/session concept on this ABI at all. One cognet
119
+ * instance is always exactly one continuous stream — a program never
120
+ * addresses anything by id, the same way it never passes a session
121
+ * handle. Multiple independent conversations are multiple Axon()
122
+ * instances, a host-level (TUI) concern this ABI has no opinion on.
123
+ * A cognet's entire vocabulary for touching the world is exactly two
124
+ * verbs, output() and run(), both committed by the kernel on the
125
+ * cognet's behalf. It never reads or writes the log directly.
126
+ * - output() vs run() is the one distinction that matters here: output() is
127
+ * a self-contained emission — the cognet already has the full content,
128
+ * nothing external can fail it, so it's unmediated at the call site
129
+ * (writing to your own stdout can't itself harm anything). run() is a
130
+ * mediated REQUEST — the cognet doesn't know the outcome until the
131
+ * capsule responds, so it's policy-gated and never rejects, returning a
132
+ * stable result the cognet reads to decide what to do next.
133
+ * - The kernel has NO opinion on cognition: no grammar, no context assembly.
134
+ * It guards the user's base identity and reports the capsule's executable
135
+ * scope; the program alone decides how either enters model context.
136
+ */
137
+ export type KernelAbi = {
138
+ /**
139
+ * Emit a fact to the world — text, audio, visual, or a declared field
140
+ * reading. Unmediated: the kernel commits it durably to the session's
141
+ * one log and forwards it live, but never refuses it — there is
142
+ * nothing to refuse (see design rules above). Any redaction/filtering a
143
+ * host wants happens downstream of the commit, on the delivery/render
144
+ * path, never as a gate this call has to pass through.
145
+ */
146
+ output<K extends keyof AxonOutputEvent>(type: K, data: AxonOutputEvent[K]): Promise<void>
147
+
148
+ /**
149
+ * Inference — messages in, structured engine events out. The kernel
150
+ * mediates access to the provider (auth, metering, later quotas); the
151
+ * program owns everything about what the messages contain. Yields raw
152
+ * engine:* wire events (see session/events/engine.ts) — the cognet
153
+ * decides what to do with each: output() a text block, run() a
154
+ * typescript block. The kernel never pre-labels these as the cognet's
155
+ * own committed output; that decision belongs to the cognet alone.
156
+ */
157
+ stream(req: AxonEngineRequest): AsyncGenerator<AxonEngineEvent>
158
+
159
+ /**
160
+ * Execute code in the capsule — ring 3, policy-mediated. The only
161
+ * syscall a tool call ever needs. Never rejects: success and failure are
162
+ * both ordinary values on the returned result, not two different control
163
+ * flows a program has to catch and re-discriminate (timeout vs abort vs
164
+ * exception all collapse into one `error.kind`). Console output is
165
+ * captured server-side and returned inline — no callback, because the
166
+ * kernel already auto-wires the capsule's own event stream onto the bus
167
+ * (untranslated, same as capsule:attach/detach); a program that wants to
168
+ * fold stdout into its own committed result reads it off the result, it
169
+ * never wires the plumbing itself. The kernel durably commits
170
+ * cognet:action:typescript/cognet:action:result to the session's one log the
171
+ * moment the capsule's own cmd:complete/cmd:failed lands — the same
172
+ * pattern as capsule:attach/detach — never something cognet code writes.
173
+ *
174
+ * A single string runs one block; an array runs every block concurrently
175
+ * (Promise.all-shaped) and returns results in the same order — the
176
+ * common "await several tool calls to respond" case needs no manual
177
+ * fan-out.
178
+ */
179
+ run(code: string, opts?: {
180
+ /** Wake cancellation. The capsule must stop this block when aborted. */
181
+ signal?: AbortSignal
182
+ }): Promise<AxonRunResult>
183
+ run(code: string[], opts?: {
184
+ /** Wake cancellation. The capsule must stop every in-flight block when aborted. */
185
+ signal?: AbortSignal
186
+ }): Promise<AxonRunResult[]>
187
+
188
+ /**
189
+ * The complete TypeScript scope implemented by the current capsule
190
+ * incarnation. The kernel reports executable reality; the cognet decides
191
+ * where and how that capability surface enters model context.
192
+ */
193
+ scope(): AxonScope
194
+
195
+ /**
196
+ * The agent's base context, rendered — boot.md / boot.vue. Kernel-
197
+ * mediated because it's the USER's identity contract, not program
198
+ * strategy: a swapped brain decides where the base context sits in its
199
+ * rendering, never what it says. Empty string when the agent declares
200
+ * none — never undefined; the seam normalizes so callers never branch.
201
+ */
202
+ base(): Promise<string>
203
+
204
+ /**
205
+ * Cognet telemetry — fire-and-forget for the cognet, durable in the
206
+ * machine: committed to the session's log and forwarded to the runtime
207
+ * bus, flame-graph material. Typed against cognet:* ONLY: a cognet
208
+ * narrates its own world but can never forge kernel machinery events.
209
+ */
210
+ emit<K extends keyof CognetEventMap>(type: K, data: CognetEventMap[K]): void
211
+
212
+ /**
213
+ * Private cognitive state + read-only episodic access — see KernelStore.
214
+ * Persistence is a mediated resource like inference (stream) and
215
+ * execution (run): the cognet declares intent, the kernel owns
216
+ * mechanism (paths, atomicity, substrate — fs today, anything
217
+ * tomorrow, invisible either way).
218
+ */
219
+ store: KernelStore
220
+ }
221
+
222
+ /**
223
+ * What a wake delivers: a diff and a leash, nothing else. Wake-scoped
224
+ * things arrive HERE, never on the ABI.
225
+ *
226
+ * There is deliberately NO push/delta channel: a temporally-extended
227
+ * emission is expressed through output() itself using the chunking
228
+ * standard (AxonChunk in stdio/shared.ts — correlated entries, closed by
229
+ * final). Chunks are ordinary committed entries, so they reach every
230
+ * observer through the commit pipeline like any other fact; the wire
231
+ * carries entries only, and the cognet never addresses a caller.
232
+ */
233
+ export type CognetWake = {
234
+ /**
235
+ * Stimuli committed since the last wake, in seq order. Narrowly typed
236
+ * to stimulus:* only — the cognet's whole input contract, mirroring
237
+ * output() being its whole unmediated write contract. It never has to
238
+ * handle every entry family that exists, only what it can actually
239
+ * receive.
240
+ */
241
+ stimuli: readonly AxonStimulusEntry[]
242
+ /** Kernel interrupt — programs must honor it between units of work. */
243
+ signal: AbortSignal
244
+ }
@@ -0,0 +1,2 @@
1
+ export { KERNEL_ABI_VERSION } from "./abi"
2
+ export type { KernelAbi, CognetWake, AxonRunResult, KernelStore } from "./abi"
@@ -0,0 +1,7 @@
1
+ import type { EventHandler } from "h3"
2
+
3
+ /** Server middleware entry — pre-resolved and pre-ordered by the CLI. */
4
+ export type AxonMiddleware = {
5
+ name: string
6
+ handler: EventHandler
7
+ }