@arcforge/types 2.0.115 → 2.0.116

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcforge/types",
3
- "version": "2.0.115",
3
+ "version": "2.0.116",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./src/index.ts",
package/src/define.ts CHANGED
@@ -119,13 +119,16 @@ export function defineBench<Schema extends Record<string, unknown> = Record<stri
119
119
  * top-level `.vue`/`.md` file in the folder is an invokable prompt;
120
120
  * `components/` holds the fragments they compose and is never invokable.
121
121
  *
122
- * Identity only — a prompt has no build step, no dependencies, and no
123
- * runtime surface of its own. It is text an agent is handed.
122
+ * A prompt has no build step, no dependencies, and no runtime surface of its
123
+ * own. It is text an agent is handed.
124
+ *
125
+ * The config is EMPTY today, deliberately: identity (name, version,
126
+ * description) lives in package.json, which is what publish reads. The call
127
+ * exists because the file's presence is how a prompt package is identified,
128
+ * and configuration is expected to land here.
124
129
  *
125
130
  * ```ts
126
- * export default definePrompt({
127
- * description: "Scouts a codebase and files proposals",
128
- * })
131
+ * export default definePrompt({})
129
132
  * ```
130
133
  */
131
134
  export function definePrompt(config: PromptConfig): PromptDefinition {
package/src/engine.ts CHANGED
@@ -181,26 +181,40 @@ export type AxonEngine = {
181
181
  * Protocol lives here rather than on AxonEngineRequest because a driver is a
182
182
  * dumb token pipe that never parses anything; only the manager runs the AIR
183
183
  * parser. It is per-call rather than per-runtime so one cognet can hold a
184
- * cortex loop on "sfc" and a one-shot classification on "raw" against the
184
+ * cortex loop on "classic" and a one-shot classification on "raw" against the
185
185
  * same kernel.
186
186
  *
187
187
  * Omitted means the manager's default. The caller that rendered the context
188
- * owns this: a cognet rendering an SFC contract and a kernel parsing classic
189
- * tags would silently discard every block the model emitted.
188
+ * owns this: a cognet rendering one grammar while the kernel parses another
189
+ * would silently discard every block the model emitted.
190
190
  */
191
191
  export type AxonEngineCall = AxonEngineRequest & {
192
192
  /** The output grammar to parse the reply with. Must match what the caller rendered. */
193
193
  protocol?: AirProtocolName
194
+ /**
195
+ * The shape this response must produce, already compiled.
196
+ *
197
+ * Structural rather than a named type because @arcforge/types must not
198
+ * depend on @arcforge/air (which depends on it) — the compiled contract
199
+ * is `CompiledOutput` there, and this is the same shape spelled at the
200
+ * seam. The engine enforces it and retries a response that misses it; no
201
+ * cognet ever sees the check.
202
+ */
203
+ output?: {
204
+ declaration: string
205
+ check(script: string): readonly { message: string; line?: number }[]
206
+ }
207
+ /** Attempts after a response fails `output`. Ignored without one. Default 2. */
208
+ retries?: number
194
209
  }
195
210
 
196
211
  /**
197
212
  * The named AIR output grammars. Declared here, not imported from
198
- * @arcforge/cognet: the kernel ABI is ring 0 and must not depend on the
199
- * cognet runtime it loads. The two are kept in step by AirProtocolName in
200
- * air/types.ts being assignable to this — one is the library's, this is the
201
- * contract's.
213
+ * @arcforge/air: the kernel ABI is ring 0 and must not depend on a library
214
+ * above it. The two are kept in step by AirProtocolName in air/types.ts
215
+ * being assignable to this — one is the library's, this is the contract's.
202
216
  */
203
- export type AirProtocolName = "classic" | "sfc" | "raw"
217
+ export type AirProtocolName = "classic" | "raw"
204
218
 
205
219
  export type AxonEngineMessage = {
206
220
  role: "user" | "assistant" | "system"
package/src/handle.ts CHANGED
@@ -23,6 +23,35 @@ import type { AxonAmbient } from "./session/events/activity"
23
23
  export type AxonRequestInput = {
24
24
  /** One stimulus, or an ordered batch committed before a single wake. */
25
25
  prompt: string | string[]
26
+ /**
27
+ * The shape this response must have, as a TypeScript type.
28
+ *
29
+ * output: "{ files: number, issues: { file: string }[] }"
30
+ * output: "type Issue = { file: string }\ntype Output = { issues: Issue[] }"
31
+ *
32
+ * Either a type expression, or declarations whose target is named
33
+ * `Output` — the second form is how a recursive or shared shape is
34
+ * expressed. TypeScript rather than a schema library because the agent's
35
+ * whole model-facing surface is already TypeScript declarations: the
36
+ * model sees its target in the same language as its tools, and there is
37
+ * nothing new for anyone to learn or install.
38
+ *
39
+ * Checked before the model is called (an invalid type throws at the call
40
+ * site, costing no inference), rendered into the model's context, and
41
+ * enforced against the script it writes. A mismatch returns to the model
42
+ * as a real TypeScript diagnostic — which it repairs far more reliably
43
+ * than schema-validator prose.
44
+ */
45
+ output?: string
46
+ /**
47
+ * Further attempts allowed after a response fails its `output` check.
48
+ * Defaults to 2, so a request makes at most 3 model calls. On
49
+ * exhaustion the invocation throws with the accumulated diagnostics —
50
+ * it never returns a response that does not satisfy the contract.
51
+ *
52
+ * Ignored when `output` is absent: there is nothing to fail.
53
+ */
54
+ retries?: number
26
55
  }
27
56
 
28
57
  /** Result of a completed agent invocation. */
package/src/kernel/abi.ts CHANGED
@@ -142,6 +142,17 @@ export type AxonRunResult = {
142
142
  * It guards the user's base identity and reports the capsule's executable
143
143
  * scope; the program alone decides how either enters model context.
144
144
  */
145
+ /**
146
+ * What a cognet may ask of an engine.
147
+ *
148
+ * AxonEngineCall minus the fields the KERNEL owns. `signal` is the wake's
149
+ * cancellation, applied by the kernel unconditionally — a program never
150
+ * passes one and so can never omit one. `output`/`retries` are the caller's
151
+ * structured-output contract, attached from the invocation; a cognet has no
152
+ * business knowing a shape was demanded.
153
+ */
154
+ export type CognetEngineCall = Omit<AxonEngineCall, "signal" | "output" | "retries">
155
+
145
156
  export type KernelAbi = {
146
157
  /**
147
158
  * Emit a fact to the world — text, audio, visual, or a declared field
@@ -164,11 +175,11 @@ export type KernelAbi = {
164
175
  *
165
176
  * `protocol` selects the grammar the reply is parsed with, and belongs
166
177
  * to the caller because the caller is what rendered the context — a
167
- * cognet showing the model an SFC contract while the kernel parsed
178
+ * cognet showing the model one contract while the kernel parsed
168
179
  * classic tags would discard every block silently. Omitted keeps the
169
180
  * default, so a cognet that never mentions it is unaffected.
170
181
  */
171
- stream(req: AxonEngineCall): AsyncGenerator<AxonEngineEvent>
182
+ stream(req: CognetEngineCall): AsyncGenerator<AxonEngineEvent>
172
183
 
173
184
  /**
174
185
  * Execute code in the capsule — ring 3, policy-mediated. The only
@@ -190,14 +201,8 @@ export type KernelAbi = {
190
201
  * common "await several tool calls to respond" case needs no manual
191
202
  * fan-out.
192
203
  */
193
- run(code: string, opts?: {
194
- /** Wake cancellation. The capsule must stop this block when aborted. */
195
- signal?: AbortSignal
196
- }): Promise<AxonRunResult>
197
- run(code: string[], opts?: {
198
- /** Wake cancellation. The capsule must stop every in-flight block when aborted. */
199
- signal?: AbortSignal
200
- }): Promise<AxonRunResult[]>
204
+ run(code: string): Promise<AxonRunResult>
205
+ run(code: string[]): Promise<AxonRunResult[]>
201
206
 
202
207
  /**
203
208
  * The complete TypeScript scope implemented by the current capsule
@@ -206,6 +211,7 @@ export type KernelAbi = {
206
211
  */
207
212
  scope(): AxonScope
208
213
 
214
+
209
215
  /**
210
216
  * The agent's base context, rendered — boot.md / boot.vue. Kernel-
211
217
  * mediated because it's the USER's identity contract, not program
@@ -362,6 +368,19 @@ export type CognetWake = {
362
368
  * receive.
363
369
  */
364
370
  stimuli: readonly AxonStimulusEntry[]
365
- /** Kernel interrupt — programs must honor it between units of work. */
371
+ /**
372
+ * Kernel interrupt, for the cognet's OWN work.
373
+ *
374
+ * Everything the kernel mediates — run(), stream() — is cancelled by the
375
+ * kernel itself, unconditionally: a wake's cancellation is not something
376
+ * a program opts into, and threading a signal by hand meant one missing
377
+ * argument made an operation unkillable. Those verbs take no signal at
378
+ * all now.
379
+ *
380
+ * This is what remains: the loop's own units of work between those
381
+ * calls — folding state, evaluating a stop condition, anything running
382
+ * in cognet code. A JS function cannot be preempted, so honouring this
383
+ * is cooperative and always will be. Check it between units and return.
384
+ */
366
385
  signal: AbortSignal
367
386
  }
@@ -1,2 +1,3 @@
1
1
  export { KERNEL_ABI_VERSION } from "./abi"
2
- export type { KernelAbi, CognetWake, AxonRunResult, KernelStore, KernelClock } from "./abi"
2
+ export type { KernelAbi, CognetWake, CognetEngineCall, AxonRunResult, KernelStore, KernelClock } from "./abi"
3
+
package/src/prompts.ts CHANGED
@@ -38,16 +38,20 @@ export type AxonPrompt = {
38
38
  }
39
39
 
40
40
  /**
41
- * `prompt.config.ts` — a prompt package's identity.
41
+ * `prompt.config.ts` — a prompt package's marker.
42
42
  *
43
- * Deliberately thin. A prompt has no dependencies, no build output and no
44
- * runtime surface: the folder's top-level .vue/.md files ARE the artifact,
45
- * and this only carries what the registry needs to list it.
43
+ * Deliberately EMPTY. A prompt has no dependencies, no build output and no
44
+ * runtime surface: the folder's top-level .vue/.md files ARE the artifact.
45
+ *
46
+ * Identity (name, version, description) lives in package.json, which is what
47
+ * publish actually reads — see `bundle/source.ts`. This type carried a
48
+ * `description` that no code ever read, so a package could set it and watch
49
+ * the registry list something else.
50
+ *
51
+ * The config FILE stays: its presence is how `detectKind()` identifies a
52
+ * prompt package, and real per-prompt configuration is expected here.
46
53
  */
47
- export type PromptConfig = {
48
- /** One line, shown in the registry listing and `axon prompt list`. */
49
- description?: string
50
- }
54
+ export type PromptConfig = Record<string, never>
51
55
 
52
56
  /** Return shape produced by `definePrompt()`. */
53
57
  export type PromptDefinition = {
@@ -1,69 +1,102 @@
1
1
  import type { AxonEngineResponse } from "../../engine"
2
+ import type { AxonError } from "../../error"
2
3
 
3
4
  /**
4
- * The engine wire contract — what every AxonEngine.stream() yields, and what
5
- * kernel.stream() hands the cognet raw. Honestly named: this is engine:*,
6
- * not agent:* cosplaying as the cognet's own committed vocabulary — the
7
- * cognet reads these and DECIDES whether/how to act (output() a block,
8
- * run() a code block); it never receives something pre-labeled as its own
9
- * output. kernel:engine:* (the tick/phase telemetry, unrelated file) is the
10
- * durable accounting span around a call; this is the call's actual content.
5
+ * The engine wire contract — what AxonEngine.stream() yields and what
6
+ * kernel.stream() hands a cognet.
11
7
  *
12
- * Reasoning/"thinking" tokens are dropped at the adapter boundary (engine.ts
13
- * in core) and never reach this wire at all — thinking was never a data
14
- * kind, it was one specific inference pipeline's internal stage. If a
15
- * distributed multi-model cognet has something analogous, that's an
16
- * inference-side concern with no single causal stream to represent here.
8
+ * EVERY EVENT HERE IS A FINISHED MECHANISM, NOT A DECISION. The kernel owns
9
+ * the output half of the model service: parsing AIR, running the script,
10
+ * rendering the template against its bindings, enforcing a declared output
11
+ * shape, retrying a malformed response. A cognet receives what the model
12
+ * PRODUCED, never machinery it has to finish itself.
17
13
  *
18
- * Deltas are wire-only — forwarded live to clients, never persisted.
19
- * Blocks are complete — the cognet decides what becomes a durable fact.
14
+ * What the kernel never decides is whether any of it reaches the world.
15
+ * These are engine:* — the call's content — and emitting is still the
16
+ * cognet's own act through output(). A brain may call an engine to classify
17
+ * a stimulus or judge its own stop condition, and neither is the agent
18
+ * speaking; the kernel cannot tell those apart from a reply, because which
19
+ * is which is a cognitive fact. So it hands back what happened and the
20
+ * cognet routes it.
21
+ *
22
+ * The vocabulary is deliberately small, and named for DATA rather than for
23
+ * the tag that produced it. Every model response reduces to the same two
24
+ * things: a structure it produced, and optionally the computation it ran to
25
+ * get there. `<text>` is a template with lang="md" and no script; a JSON
26
+ * response is lang="json". So there is one spoken event and one action event,
27
+ * whatever protocol was in force.
28
+ *
29
+ * Reasoning/"thinking" tokens are dropped at the adapter boundary and never
30
+ * reach this wire — thinking was never a data kind, it was one inference
31
+ * pipeline's internal stage.
20
32
  */
33
+ export type AxonEngineEvent =
34
+ /** The call began. The bracket's open half — a consumer showing "thinking" starts here rather than inferring from the first token. */
35
+ | { type: "engine:start" }
21
36
 
22
- /** Streaming chunks — transient, never enter a log. */
23
- export type AxonEngineDelta =
24
- | { type: "engine:text:delta"; content: string }
25
37
  /**
26
- * A chunk of UNRENDERED template source (sfc protocol). Interpolations
27
- * have not been substituted, so this is never user-facing text — a
28
- * cognet feeds it through the template renderer and emits what comes
29
- * out, never this directly.
38
+ * The agent spoke — already interpolated, exactly as a user reads it.
39
+ * Never unrendered template source and never a raw brace.
40
+ *
41
+ * `lang` is the structure the model produced ("md" prose, "json" for a
42
+ * declared output shape), so a consumer can tell a message from a value
43
+ * without knowing which protocol was rendered.
44
+ *
45
+ * `chunk` carries the AxonChunk correlation group while streaming; a
46
+ * complete one-shot block has none. NOTE these are chunks of RENDERED
47
+ * output, so they no longer correspond 1:1 to model tokens — one delta
48
+ * can emit nothing (buffered mid-interpolation) or a great deal (a large
49
+ * interpolated value).
30
50
  */
31
- | { type: "engine:template:delta"; content: string }
51
+ | {
52
+ type: "engine:text"
53
+ content: string
54
+ lang: "md" | "json"
55
+ chunk?: { of: string; final?: boolean }
56
+ }
32
57
 
33
- /** Complete parsed blocks. */
34
- export type AxonEngineBlock =
35
- | { type: "engine:text"; content: string }
36
- /** id is minted at parse time by the AIR parser. The kernel's run() mints its own action id independently, so this parse-time id is currently unconsumed downstream. */
37
- | { type: "engine:typescript"; id: string; content: string }
38
58
  /**
39
- * The sfc protocol's code block — same execution semantics as
40
- * engine:typescript, but named for the role it plays: it runs BEFORE the
41
- * template so the template can render against its bindings. A cognet
42
- * starts it the moment this arrives and does not await it, or the
43
- * template cannot stream.
59
+ * The model ran code. Reported for the record — the kernel already
60
+ * executed it and committed the result, so a cognet reads this to know
61
+ * what happened, never to act on it.
44
62
  */
45
63
  | { type: "engine:script"; id: string; content: string }
64
+
46
65
  /**
47
- * The template opened. Carries the lang because it selects the
48
- * interpolation serializer, and the renderer must exist before the first
49
- * delta lands.
66
+ * The call could not produce a usable response — a malformed reply the
67
+ * model failed to correct within its retries, or a declared output shape
68
+ * it never satisfied. Terminal for this call: no `engine:done` follows.
50
69
  */
51
- | { type: "engine:template:open"; lang: "md" | "json" }
52
- /** The template closed — its full unrendered source, for the record. */
53
- | { type: "engine:template"; content: string }
54
- /** A format violation in the model's output. */
55
- | { type: "engine:output:error"; code: string; message: string; excerpt?: string }
70
+ | { type: "engine:failure"; error: AxonError }
56
71
 
57
- export type AxonEngineEvent =
58
- | AxonEngineDelta
59
- | AxonEngineBlock
60
72
  /**
61
- * The model emitted <done/> this tick — its own explicit stop signal.
62
- * Causal, not inferred: a loop def reads this directly rather than
63
- * guessing from what blocks did or didn't appear (a text-only tick is
64
- * NOT implicitly terminal — a model can speak across several ticks and
65
- * only stop when it actually says so).
73
+ * The call ended. Exactly once per successful call, carrying the
74
+ * authoritative response and billing meta.
75
+ *
76
+ * The booleans are SIGNALS, not decisions — reductions over what this
77
+ * call produced, from which a loop derives its own stop condition. The
78
+ * kernel never acts on them and deliberately does not decide whether a
79
+ * turn is over: that is the one thing a loop is for.
80
+ *
81
+ * `yielded` is the model's own <done/>, and it is here under protest.
82
+ * Whether a turn is over is a SEMANTIC question — "I see the issue" and
83
+ * "the fix is deployed" are structurally identical, same block and no
84
+ * script — so no reduction over what a response DID can separate a
85
+ * progress report from a final answer. Deriving it structurally ends a
86
+ * long run the first time the model narrates between actions.
87
+ *
88
+ * So the model is asked, which works consistently enough. It stays a
89
+ * SIGNAL: the kernel never acts on it, and a loop weighs it against the
90
+ * structural facts beside it. Replacing it needs something that can judge
91
+ * the situation rather than the response.
66
92
  */
67
- | { type: "engine:stop" }
68
- /** Terminal — carries the authoritative full response and billing meta. Always emitted once per call, independent of <done/>. */
69
- | { type: "engine:done"; response: AxonEngineResponse }
93
+ | {
94
+ type: "engine:done"
95
+ response: AxonEngineResponse
96
+ /** The agent produced user-facing output this call. */
97
+ spoke: boolean
98
+ /** The model emitted a script this call — code it has not yet seen the result of. */
99
+ acted: boolean
100
+ /** The model emitted <done/> — its own claim that it is handing control back. */
101
+ yielded: boolean
102
+ }
@@ -12,7 +12,7 @@ export { isBuildEvent } from "./events/build"
12
12
  export type { Activity, ActivityHandle, ActivityPayloads, ActivityPhase, ActivityType, AxonAmbient } from "./events/activity"
13
13
  export { CAPSULE_TRANSIENT_EVENTS } from "./events/capsule"
14
14
  export type { AxonRuntimeEvent } from "./events/runtime"
15
- export type { AxonEngineBlock, AxonEngineDelta, AxonEngineEvent } from "./events/engine"
15
+ export type { AxonEngineEvent } from "./events/engine"
16
16
  export type { AxonEntryEvent } from "./events/entries"
17
17
  export { ENTRY_EVENT_PREFIXES } from "./events/entries"
18
18
  export { isKernelEvent, isEntryEvent, classifyEvent, type AxonEventView } from "./classify"