@arcforge/types 2.0.113 → 2.0.115
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 +1 -1
- package/src/capsule-scope.ts +38 -0
- package/src/config.ts +0 -16
- package/src/engine.ts +30 -2
- package/src/index.ts +1 -0
- package/src/kernel/abi.ts +42 -3
- package/src/session/events/capsule.ts +2 -1
- package/src/session/events/engine.ts +24 -1
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bindings a capsule run left behind — what a rendered template may
|
|
3
|
+
* interpolate.
|
|
4
|
+
*
|
|
5
|
+
* Bun's REPL transform hoists every top-level declaration onto the sandbox's
|
|
6
|
+
* real globalThis, which is what makes "declarations persist into later
|
|
7
|
+
* blocks" true. Scope extraction reads that same state: it is a diff of
|
|
8
|
+
* globalThis across one submission, never a second capture mechanism.
|
|
9
|
+
*
|
|
10
|
+
* Values cross a process boundary, so only JSON-representable ones can come
|
|
11
|
+
* with. Everything else is reported by NAME with a reason instead of being
|
|
12
|
+
* silently dropped — a template interpolating a function would otherwise
|
|
13
|
+
* render `undefined` with nothing to explain it, and the model would have no
|
|
14
|
+
* way to know what it did wrong.
|
|
15
|
+
*/
|
|
16
|
+
export type CapsuleScope = {
|
|
17
|
+
/** Bindings whose values crossed intact. */
|
|
18
|
+
values: Record<string, unknown>
|
|
19
|
+
/** Bindings that exist in the sandbox but could not cross, by name. */
|
|
20
|
+
unavailable: CapsuleScopeUnavailable[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type CapsuleScopeUnavailable = {
|
|
24
|
+
name: string
|
|
25
|
+
/**
|
|
26
|
+
* function — a callable; meaningless outside the sandbox that owns it.
|
|
27
|
+
* circular — self-referencing structure; not representable as JSON.
|
|
28
|
+
* unserializable — threw during serialization (getters, BigInt, ...).
|
|
29
|
+
* oversized — the run's scope budget was exhausted before this binding.
|
|
30
|
+
* A script may build anything in the sandbox, but the scope crosses a
|
|
31
|
+
* process boundary every run; a runaway accumulation is reported by
|
|
32
|
+
* name rather than put on the wire.
|
|
33
|
+
*/
|
|
34
|
+
reason: "function" | "circular" | "unserializable" | "oversized"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** An empty scope — the honest value for a run that declared nothing. */
|
|
38
|
+
export const EMPTY_CAPSULE_SCOPE: CapsuleScope = { values: {}, unavailable: [] }
|
package/src/config.ts
CHANGED
|
@@ -105,22 +105,6 @@ export type AxonConfig<EventMap extends Record<string, unknown> = Record<string,
|
|
|
105
105
|
*/
|
|
106
106
|
modules?: ModuleEntry[]
|
|
107
107
|
|
|
108
|
-
/**
|
|
109
|
-
* Prompt packages to load into this agent.
|
|
110
|
-
*
|
|
111
|
-
* Each entry is a registry name — `"@cody/eslint-scout"` — auto-installed
|
|
112
|
-
* at `axon prepare` / `axon dev` like a module. Every top-level .vue/.md
|
|
113
|
-
* in the package becomes an invokable prompt, namespaced by the package
|
|
114
|
-
* so an installed one can never shadow the agent's own:
|
|
115
|
-
*
|
|
116
|
-
* src/prompts/scout.vue → `axon run scout`
|
|
117
|
-
* @cody/eslint-scout:scout → `axon run @cody/eslint-scout:scout`
|
|
118
|
-
*
|
|
119
|
-
* A prompt is the smallest shareable unit of work — an instruction, not a
|
|
120
|
-
* capability. Modules bring tools; prompts bring tasks.
|
|
121
|
-
*/
|
|
122
|
-
prompts?: string[]
|
|
123
|
-
|
|
124
108
|
/**
|
|
125
109
|
* Opt this agent into the repository workspace layer.
|
|
126
110
|
* When true, Axon discovers the nearest .agents/ directory (walking up from cwd)
|
package/src/engine.ts
CHANGED
|
@@ -169,11 +169,39 @@ export type AxonEngineRawEvent =
|
|
|
169
169
|
*/
|
|
170
170
|
export type AxonEngine = {
|
|
171
171
|
/** Stream block events in real time, terminated by a single agent:done. */
|
|
172
|
-
stream: (req:
|
|
172
|
+
stream: (req: AxonEngineCall) => AsyncGenerator<AxonEngineEvent>
|
|
173
173
|
/** Single-shot completion. Same response shape as the stream's done event. */
|
|
174
|
-
request: (req:
|
|
174
|
+
request: (req: AxonEngineCall) => Promise<AxonEngineResponse>
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
/**
|
|
178
|
+
* One call through the engine MANAGER — the driver request plus the grammar
|
|
179
|
+
* to parse the reply with.
|
|
180
|
+
*
|
|
181
|
+
* Protocol lives here rather than on AxonEngineRequest because a driver is a
|
|
182
|
+
* dumb token pipe that never parses anything; only the manager runs the AIR
|
|
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
|
|
185
|
+
* same kernel.
|
|
186
|
+
*
|
|
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.
|
|
190
|
+
*/
|
|
191
|
+
export type AxonEngineCall = AxonEngineRequest & {
|
|
192
|
+
/** The output grammar to parse the reply with. Must match what the caller rendered. */
|
|
193
|
+
protocol?: AirProtocolName
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 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.
|
|
202
|
+
*/
|
|
203
|
+
export type AirProtocolName = "classic" | "sfc" | "raw"
|
|
204
|
+
|
|
177
205
|
export type AxonEngineMessage = {
|
|
178
206
|
role: "user" | "assistant" | "system"
|
|
179
207
|
content: string
|
package/src/index.ts
CHANGED
package/src/kernel/abi.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AxonEngineCall } from "../engine"
|
|
2
2
|
import type { AxonEngineEvent } from "../session/events/engine"
|
|
3
3
|
import type { AxonEntry } from "../session/session"
|
|
4
4
|
import type { AxonOutputEvent } from "../session/events/stdio/output"
|
|
5
5
|
import type { AxonStimulusEntry } from "../session/events/stdio/stimuli"
|
|
6
6
|
import type { CognetEventMap } from "../session/events/cognet"
|
|
7
7
|
import type { AxonScope } from "../scope"
|
|
8
|
+
import type { CapsuleScope } from "../capsule-scope"
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* The current kernel ABI contract version. Program definitions declare the
|
|
@@ -14,7 +15,7 @@ import type { AxonScope } from "../scope"
|
|
|
14
15
|
*
|
|
15
16
|
* THE VERSIONED SURFACE IS MORE THAN THE FUNCTION SHAPES. A cognet is a
|
|
16
17
|
* prebuilt bundle: it compiled against a snapshot of every payload type
|
|
17
|
-
* this file references — AxonOutputEvent (output),
|
|
18
|
+
* this file references — AxonOutputEvent (output), AxonEngineCall /
|
|
18
19
|
* AxonEngineEvent (stream), CognetEventMap (emit), AxonEntry
|
|
19
20
|
* (the wake wire). A breaking change to ANY of those is a breaking change to the
|
|
20
21
|
* ABI and requires a version bump, even though no signature here moved —
|
|
@@ -104,6 +105,13 @@ export type AxonRunResult = {
|
|
|
104
105
|
value?: unknown
|
|
105
106
|
/** console.* output from this block, in order, one entry per call. */
|
|
106
107
|
stdout: string[]
|
|
108
|
+
/**
|
|
109
|
+
* The top-level bindings this block declared — what a template rendered
|
|
110
|
+
* from the same turn interpolates against. Empty on failure, and empty
|
|
111
|
+
* for a block that declared nothing; never absent, so a caller never has
|
|
112
|
+
* to distinguish "no scope" from "scope unavailable".
|
|
113
|
+
*/
|
|
114
|
+
scope: CapsuleScope
|
|
107
115
|
error?: { kind: "timeout" | "interrupt" | "exception"; message: string }
|
|
108
116
|
}
|
|
109
117
|
|
|
@@ -153,8 +161,14 @@ export type KernelAbi = {
|
|
|
153
161
|
* decides what to do with each: output() a text block, run() a
|
|
154
162
|
* typescript block. The kernel never pre-labels these as the cognet's
|
|
155
163
|
* own committed output; that decision belongs to the cognet alone.
|
|
164
|
+
*
|
|
165
|
+
* `protocol` selects the grammar the reply is parsed with, and belongs
|
|
166
|
+
* to the caller because the caller is what rendered the context — a
|
|
167
|
+
* cognet showing the model an SFC contract while the kernel parsed
|
|
168
|
+
* classic tags would discard every block silently. Omitted keeps the
|
|
169
|
+
* default, so a cognet that never mentions it is unaffected.
|
|
156
170
|
*/
|
|
157
|
-
stream(req:
|
|
171
|
+
stream(req: AxonEngineCall): AsyncGenerator<AxonEngineEvent>
|
|
158
172
|
|
|
159
173
|
/**
|
|
160
174
|
* Execute code in the capsule — ring 3, policy-mediated. The only
|
|
@@ -209,6 +223,31 @@ export type KernelAbi = {
|
|
|
209
223
|
*/
|
|
210
224
|
emit<K extends keyof CognetEventMap>(type: K, data: CognetEventMap[K]): void
|
|
211
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Report a format violation in the model's output — the model broke the
|
|
228
|
+
* grammar this cognet gave it.
|
|
229
|
+
*
|
|
230
|
+
* Separate from emit() because the OUTCOME is not telemetry: the kernel
|
|
231
|
+
* commits it as axon:system:message, so AIR renders it into the next
|
|
232
|
+
* tick's <system> block and the model reads its own violation and
|
|
233
|
+
* corrects. That is a system fact, and a cognet may not forge one
|
|
234
|
+
* directly (see emit's typing) — so it describes the fault and the kernel
|
|
235
|
+
* writes it.
|
|
236
|
+
*
|
|
237
|
+
* Why a cognet needs this at all: the runtime detects violations it can
|
|
238
|
+
* see in the token stream (an unclosed block), but a cognet that renders
|
|
239
|
+
* the model's output detects its own class of them — an interpolation
|
|
240
|
+
* naming a binding the script never declared. Without this verb the only
|
|
241
|
+
* way to make such a fault visible was to speak it as the agent's own
|
|
242
|
+
* message, which puts a diagnostic in the agent's voice and shows the
|
|
243
|
+
* user machinery they cannot act on.
|
|
244
|
+
*
|
|
245
|
+
* Deliberately NOT user-facing: hosts hide these (see the TUI's
|
|
246
|
+
* isEntryVisible) so a violation is a retry the model performs, not an
|
|
247
|
+
* error the user watches it make.
|
|
248
|
+
*/
|
|
249
|
+
fault(input: { code: string; message: string; excerpt?: string }): Promise<void>
|
|
250
|
+
|
|
212
251
|
/**
|
|
213
252
|
* Private cognitive state + read-only episodic access — see KernelStore.
|
|
214
253
|
* Persistence is a mediated resource like inference (stream) and
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
import type { Activity } from "./activity"
|
|
23
23
|
import type { AxonErrorJSON } from "../../error"
|
|
24
24
|
import type { AxonCancellableSpan, AxonSpan } from "./span"
|
|
25
|
+
import type { CapsuleScope } from "../../capsule-scope"
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Capsule failures carry AxonErrorJSON, not AxonError.
|
|
@@ -71,7 +72,7 @@ export type CapsuleEventMap =
|
|
|
71
72
|
& AxonCancellableSpan<
|
|
72
73
|
"capsule:cmd",
|
|
73
74
|
{ id: string },
|
|
74
|
-
{ id: string; result: unknown },
|
|
75
|
+
{ id: string; result: unknown; scope: CapsuleScope },
|
|
75
76
|
{ id: string; error: AxonErrorJSON },
|
|
76
77
|
{ id: string; durationMs: number }
|
|
77
78
|
>
|
|
@@ -21,13 +21,36 @@ import type { AxonEngineResponse } from "../../engine"
|
|
|
21
21
|
|
|
22
22
|
/** Streaming chunks — transient, never enter a log. */
|
|
23
23
|
export type AxonEngineDelta =
|
|
24
|
-
{ type: "engine:text:delta"; content: string }
|
|
24
|
+
| { type: "engine:text:delta"; content: string }
|
|
25
|
+
/**
|
|
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.
|
|
30
|
+
*/
|
|
31
|
+
| { type: "engine:template:delta"; content: string }
|
|
25
32
|
|
|
26
33
|
/** Complete parsed blocks. */
|
|
27
34
|
export type AxonEngineBlock =
|
|
28
35
|
| { type: "engine:text"; content: string }
|
|
29
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. */
|
|
30
37
|
| { type: "engine:typescript"; id: string; content: string }
|
|
38
|
+
/**
|
|
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.
|
|
44
|
+
*/
|
|
45
|
+
| { type: "engine:script"; id: string; content: string }
|
|
46
|
+
/**
|
|
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.
|
|
50
|
+
*/
|
|
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 }
|
|
31
54
|
/** A format violation in the model's output. */
|
|
32
55
|
| { type: "engine:output:error"; code: string; message: string; excerpt?: string }
|
|
33
56
|
|