@arcforge/types 2.0.219 → 2.0.244
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 +6 -2
- package/src/agent-handle.ts +2 -1
- package/src/blueprint.ts +19 -3
- package/src/body/body.ts +669 -0
- package/src/cognet/blueprint.ts +32 -4
- package/src/cognet/cognet.ts +126 -11
- package/src/cognet/index.ts +2 -2
- package/src/config.ts +21 -3
- package/src/connections.ts +70 -0
- package/src/define.ts +34 -0
- package/src/engine.ts +33 -3
- package/src/error.ts +11 -0
- package/src/handle.ts +67 -0
- package/src/index.ts +8 -0
- package/src/inference.ts +193 -12
- package/src/kernel/abi.ts +132 -10
- package/src/kernel/index.ts +1 -1
- package/src/machine.ts +17 -0
- package/src/provider-usage.ts +63 -0
- package/src/services.ts +79 -0
- package/src/session/channel.ts +15 -0
- package/src/session/envelope.ts +10 -1
- package/src/session/events/activity.ts +13 -1
- package/src/session/events/build.ts +26 -1
- package/src/session/events/cognet.ts +211 -15
- package/src/session/events/kernel.ts +20 -0
- package/src/session/events/runtime.ts +29 -1
- package/src/session/events/stdio/output.ts +6 -0
- package/src/session/events/stdio/shared.ts +35 -0
- package/src/session/events/stdio/stimuli.ts +17 -0
- package/src/session/index.ts +4 -1
- package/src/session/session.ts +2 -2
- package/src/session/text.ts +36 -0
- package/src/supervisor.ts +45 -4
- package/src/tui-contract.ts +1 -1
- package/src/tui.ts +14 -0
- package/src/usage.ts +83 -0
- package/src/world/world.ts +224 -0
|
@@ -42,7 +42,9 @@ export type BuildStage =
|
|
|
42
42
|
| "modules"
|
|
43
43
|
| "cognet"
|
|
44
44
|
| "tree"
|
|
45
|
+
| "blueprint"
|
|
45
46
|
| "scan"
|
|
47
|
+
| "supervise"
|
|
46
48
|
| "typegen"
|
|
47
49
|
|
|
48
50
|
export type BuildEventMap =
|
|
@@ -90,13 +92,27 @@ export type BuildEventMap =
|
|
|
90
92
|
{ specifier: string | null },
|
|
91
93
|
{ name: string; version: string; abi: string; compiled: boolean }
|
|
92
94
|
>
|
|
95
|
+
/** Bundle the cognet source, or validate and reuse its content-addressed artifact. */
|
|
96
|
+
& AxonSpan<
|
|
97
|
+
"build:compile",
|
|
98
|
+
{ specifier: string | null },
|
|
99
|
+
{}
|
|
100
|
+
>
|
|
93
101
|
/** `bun install` in the project. Usually the slowest span in the phase. */
|
|
94
102
|
& AxonSpan<
|
|
95
103
|
"build:tree",
|
|
96
|
-
{
|
|
104
|
+
{
|
|
105
|
+
reason: "framework" | "modules" | "reconcile"
|
|
106
|
+
/** Every independent condition that made reconciliation necessary. */
|
|
107
|
+
reasons?: string[]
|
|
108
|
+
},
|
|
97
109
|
{ durationMs: number }
|
|
98
110
|
>
|
|
99
111
|
& AxonSpan<"build:typegen", {}, { files: string[] }>
|
|
112
|
+
/** Scan a prepared project into the blueprint typegen and runtime consume. */
|
|
113
|
+
& AxonSpan<"build:blueprint", {}, { warnings: number }>
|
|
114
|
+
/** Supervisor-side services plus spawning the isolated agent to readiness. */
|
|
115
|
+
& AxonSpan<"build:supervise", { agent: string }, { pid: number }>
|
|
100
116
|
|
|
101
117
|
// ── Stage 3: load ───────────────────────────────────────────────────────
|
|
102
118
|
// Scan the prepared project into a blueprint. The last thing before
|
|
@@ -119,6 +135,15 @@ export type BuildEventMap =
|
|
|
119
135
|
>
|
|
120
136
|
|
|
121
137
|
& {
|
|
138
|
+
/**
|
|
139
|
+
* A live update inside a build span.
|
|
140
|
+
*
|
|
141
|
+
* Progress is durable for diagnosis but stays at debug visibility: a
|
|
142
|
+
* retry updates the active boot label instead of becoming another
|
|
143
|
+
* conversation row. Warnings below describe degraded final state;
|
|
144
|
+
* progress describes work that is still underway.
|
|
145
|
+
*/
|
|
146
|
+
"build:progress": { stage: BuildStage; message: string }
|
|
122
147
|
/**
|
|
123
148
|
* A recoverable defect found during the build — a tool shadowed by
|
|
124
149
|
* one of the same name, a component that will not resolve.
|
|
@@ -2,6 +2,44 @@ import type { AxonError } from "../../error"
|
|
|
2
2
|
import type { AxonLogEvents } from "./log"
|
|
3
3
|
import type { AxonCancellableSpan, AxonSpan } from "./span"
|
|
4
4
|
|
|
5
|
+
/** Instrument meaning is declared by the producer; a viewer never infers it from a component name or number count. */
|
|
6
|
+
export type InstrumentRole = "velocity" | "acceleration" | "angular-velocity" | "altitude" | "joint-position" | "joint-effort" | "power" | "temperature"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* What a tick opened with. A mind with systems has its ticks run by its
|
|
10
|
+
* schedule, which says what each one answered — enough to run it again
|
|
11
|
+
* exactly as it ran. A tick of a `loop()` mind carries only its number.
|
|
12
|
+
*/
|
|
13
|
+
export type CognetTickStart = {
|
|
14
|
+
tick: number
|
|
15
|
+
/** The moment the tick stands for — every system's `now` in it. */
|
|
16
|
+
now?: number
|
|
17
|
+
/**
|
|
18
|
+
* How many wakes the tick answers. More than one when wakes arrived
|
|
19
|
+
* while the tick before it ran: they merge into the one tick waiting.
|
|
20
|
+
*/
|
|
21
|
+
wakes?: number
|
|
22
|
+
/**
|
|
23
|
+
* The stimuli it admitted — every one that arrived since the tick before
|
|
24
|
+
* it — by their place in the mind's own stream: from its `from`th
|
|
25
|
+
* stimulus (counting from 0), `count` of them. Not by seq: a confined
|
|
26
|
+
* agent's events are stamped again by the supervisor that records them,
|
|
27
|
+
* so the seqs a mind saw are not the log's. Absent: none arrived.
|
|
28
|
+
*/
|
|
29
|
+
admitted?: { from: number; count: number }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** How a tick ended. */
|
|
33
|
+
export type CognetTickComplete = {
|
|
34
|
+
tick: number
|
|
35
|
+
/**
|
|
36
|
+
* The time the tick spent waiting on a system rather than running one,
|
|
37
|
+
* by system, ms: a worker its next system needed, or a lagged run landing
|
|
38
|
+
* late. What set the tick's length when it ran over.
|
|
39
|
+
*/
|
|
40
|
+
held?: Array<{ system: string; ms: number }>
|
|
41
|
+
}
|
|
42
|
+
|
|
5
43
|
/**
|
|
6
44
|
* Cognet telemetry — the cognition artifact's own observability record.
|
|
7
45
|
*
|
|
@@ -46,8 +84,8 @@ export type CognetEventMap =
|
|
|
46
84
|
// end when siblings of the same stem appear in one run.
|
|
47
85
|
& AxonCancellableSpan<
|
|
48
86
|
"cognet:tick",
|
|
49
|
-
|
|
50
|
-
|
|
87
|
+
CognetTickStart,
|
|
88
|
+
CognetTickComplete,
|
|
51
89
|
{ tick: number; error: AxonError },
|
|
52
90
|
{ tick: number }
|
|
53
91
|
>
|
|
@@ -58,14 +96,53 @@ export type CognetEventMap =
|
|
|
58
96
|
{ tick: number; phase: string; error: AxonError },
|
|
59
97
|
{ tick: number; phase: string }
|
|
60
98
|
>
|
|
61
|
-
& AxonCancellableSpan<
|
|
62
|
-
"cognet:system",
|
|
63
|
-
{ tick: number; phase: string | null; system: string },
|
|
64
|
-
{ tick: number; phase: string | null; system: string },
|
|
65
|
-
{ tick: number; phase: string | null; system: string; error: AxonError },
|
|
66
|
-
{ tick: number; phase: string | null; system: string }
|
|
67
|
-
>
|
|
68
99
|
& {
|
|
100
|
+
// ── One system run, whole ────────────────────────────────────────────────
|
|
101
|
+
//
|
|
102
|
+
// ONE record per run, emitted when it ends — not a start/reads/complete
|
|
103
|
+
// triad. Systems run tens of times a tick, and the triad was three events
|
|
104
|
+
// per run: 77% of every event a continuous mind logged, measured on Terry
|
|
105
|
+
// at 20Hz, and most of what its log, its link and its debugger carried.
|
|
106
|
+
// A run's start is a field (`at`), so a reader still draws it as a span.
|
|
107
|
+
//
|
|
108
|
+
// `durationMs` is the run's OWN time. For an async system that is the
|
|
109
|
+
// time it computed beside the tick, not the moment its writes landed —
|
|
110
|
+
// which is what the triad used to report, and why async systems looked
|
|
111
|
+
// free.
|
|
112
|
+
"cognet:system:run": {
|
|
113
|
+
tick: number
|
|
114
|
+
phase: string | null
|
|
115
|
+
system: string
|
|
116
|
+
/** When the run began, epoch ms. */
|
|
117
|
+
at: number
|
|
118
|
+
durationMs: number
|
|
119
|
+
outcome: "complete" | "failed" | "interrupted"
|
|
120
|
+
error?: AxonError
|
|
121
|
+
/** It ran beside the tick; its writes landed at `tick`. */
|
|
122
|
+
async?: true
|
|
123
|
+
/** The worker thread it ran on, from 0. Absent: the main thread. */
|
|
124
|
+
thread?: number
|
|
125
|
+
/** It started this many ticks before `tick`, the one its writes landed in (see `lag` on the system). */
|
|
126
|
+
lag?: number
|
|
127
|
+
/**
|
|
128
|
+
* What the run actually read — every value, by the rev it was at. The
|
|
129
|
+
* declared `reads` say what a system may look at; this says what it
|
|
130
|
+
* did look at, which makes every write in the run a child of exactly
|
|
131
|
+
* these values — "why is this 0.62?" answered as a chain of real
|
|
132
|
+
* values, not a guess from declarations. Absent when the runtime could
|
|
133
|
+
* not observe it (an async run).
|
|
134
|
+
*/
|
|
135
|
+
reads?: Array<{ entity: string; component: string; rev: number }>
|
|
136
|
+
/** Query calls in run order: final matches by revision, without duplicating values. */
|
|
137
|
+
queries?: Array<{ ordinal: number; required: string[]; optional: string[]; where?: unknown; filtered: boolean; candidates: number; count: number; matched: Array<{ entity: string; values: Array<{ entity: string; component: string; rev: number }> }> }>
|
|
138
|
+
/**
|
|
139
|
+
* The stimuli this run consumed, by their own seq in this log — where
|
|
140
|
+
* a chain of causes leaves the mind. Absent for a run that declares no
|
|
141
|
+
* input.
|
|
142
|
+
*/
|
|
143
|
+
inputs?: Array<{ seq: number; channel: string }>
|
|
144
|
+
}
|
|
145
|
+
|
|
69
146
|
// ── Knowledge mutations ──────────────────────────────────────────────────
|
|
70
147
|
//
|
|
71
148
|
// Emitted by the KERNEL when a cognet writes or removes long-term
|
|
@@ -79,6 +156,34 @@ export type CognetEventMap =
|
|
|
79
156
|
// Traced because "the agent modified its own long-term memory" is exactly
|
|
80
157
|
// the fact you want when behaviour drifts weeks later. Name only, never
|
|
81
158
|
// content — the log records that memory changed, not a second copy of it.
|
|
159
|
+
/**
|
|
160
|
+
* A worker thread answered its first job: which OS thread it is. Lets a
|
|
161
|
+
* reader of per-thread CPU (axon:usage `threads`) name worker N instead
|
|
162
|
+
* of guessing from thread names. `tid` is null where the OS has no
|
|
163
|
+
* per-thread ids to give.
|
|
164
|
+
*/
|
|
165
|
+
"cognet:thread:start": { index: number; pid: number; tid: number | null }
|
|
166
|
+
/**
|
|
167
|
+
* A lagged run was still going when the tick it lands in came, and the
|
|
168
|
+
* tick waited `waitedMs` for it — its work is longer than its lag. The
|
|
169
|
+
* mind's result is unchanged (it lands where it always would); only the
|
|
170
|
+
* tick was late.
|
|
171
|
+
*/
|
|
172
|
+
"cognet:system:overrun": { tick: number; system: string; lag: number; waitedMs: number }
|
|
173
|
+
/**
|
|
174
|
+
* What the mind is working on, beside its ticks: the async systems with a
|
|
175
|
+
* run in flight, by name. Emitted when that set changes — a run starting,
|
|
176
|
+
* or the last one landing — so a client can show a mind as busy without
|
|
177
|
+
* asking it anything. Empty: nothing is in flight.
|
|
178
|
+
*/
|
|
179
|
+
"cognet:activity": { working: string[] }
|
|
180
|
+
/**
|
|
181
|
+
* Stimuli the mind is done with, by the seq it received each at: every
|
|
182
|
+
* system that reads stimuli has taken them, and every run that took them —
|
|
183
|
+
* and whatever that run started — has ended. Whatever the mind was going
|
|
184
|
+
* to do about them, it has done. What ends a request to a continuous mind.
|
|
185
|
+
*/
|
|
186
|
+
"cognet:settled": { seqs: number[] }
|
|
82
187
|
"cognet:knowledge:write": { name: string }
|
|
83
188
|
"cognet:knowledge:remove": { name: string }
|
|
84
189
|
|
|
@@ -109,12 +214,16 @@ export type CognetEventMap =
|
|
|
109
214
|
shape: "scalar" | "vector" | "categorical" | "record"
|
|
110
215
|
/** Physical unit for scalar/vector readings — "hp", "px/tick", "bool". */
|
|
111
216
|
unit?: string
|
|
217
|
+
/** Optional physical meaning for cockpit instruments. Requires the matching shape, unit and frame/limits. */
|
|
218
|
+
instrument?: InstrumentRole
|
|
112
219
|
/** Expected bounds, so a reader can scale without waiting for outliers. */
|
|
113
220
|
range?: [number, number]
|
|
114
221
|
/** Component names, in value order. Vectors only. */
|
|
115
222
|
labels?: string[]
|
|
116
223
|
/** The permitted values. Categoricals only. */
|
|
117
224
|
options?: string[]
|
|
225
|
+
/** How a viewer draws it in its frame — see `Archetype`. Absent: shown as a value, not drawn. */
|
|
226
|
+
archetype?: Archetype
|
|
118
227
|
/**
|
|
119
228
|
* The declared frame this value is expressed in, by name.
|
|
120
229
|
*
|
|
@@ -166,17 +275,104 @@ export type CognetEventMap =
|
|
|
166
275
|
// anything.
|
|
167
276
|
"cognet:frame:declare": {
|
|
168
277
|
frame: string
|
|
169
|
-
kind:
|
|
278
|
+
kind: FrameKind
|
|
170
279
|
/** Physical unit of the axes, for metric frames. */
|
|
171
280
|
unit?: string
|
|
172
281
|
/** Size along each axis, so a reader can scale without waiting for outliers. */
|
|
173
282
|
extent?: number[]
|
|
283
|
+
/**
|
|
284
|
+
* The frame this one is expressed relative to, with how to convert:
|
|
285
|
+
* where the parent's origin sits in these axes, and how many parent
|
|
286
|
+
* units one of these is. A camera frame related to the body frame is
|
|
287
|
+
* what lets a reader draw a belief positioned in one INSIDE the other
|
|
288
|
+
* — the same belief as a box on an image and a dot on a map — without
|
|
289
|
+
* knowing what either frame means.
|
|
290
|
+
*/
|
|
291
|
+
relativeTo?: string
|
|
292
|
+
origin?: number[]
|
|
293
|
+
scale?: number
|
|
294
|
+
/** Which way is up along these axes (`[0, 1, 0]` when y rises), so a 3D viewer stands the frame upright. Absent: z for a 3D frame, −y for a 2D one (drawn y down, as a picture). */
|
|
295
|
+
up?: number[]
|
|
296
|
+
/** The sense whose pixels this frame is (`"/vision"`), so a viewer of that camera knows its frame. */
|
|
297
|
+
sensor?: string
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// ── Schedule ─────────────────────────────────────────────────────────────
|
|
301
|
+
//
|
|
302
|
+
// The shape of the mind: every system, when it runs, and which beliefs it
|
|
303
|
+
// reads and writes. An ECS has no call graph — systems never call each
|
|
304
|
+
// other — so this data lineage IS the program's structure, and without it
|
|
305
|
+
// a reader can see beliefs change but never what connects them.
|
|
306
|
+
//
|
|
307
|
+
// Declared once, on the schedule's first run. The schedule enforces it:
|
|
308
|
+
// a system that touches a component it did not declare fails its run.
|
|
309
|
+
"cognet:schedule:declare": {
|
|
310
|
+
/** The process the schedule runs in — whose main thread is the thread with this id. Absent from older runtimes. */
|
|
311
|
+
pid?: number
|
|
312
|
+
/** Continuous clock rate. Null for reactive minds; absent from older runtimes. */
|
|
313
|
+
hz?: number | null
|
|
314
|
+
/** Every system, in the order the schedule runs them — derived from reads and writes. */
|
|
315
|
+
systems: Array<{
|
|
316
|
+
/** The system's path under the cognet, without `.system.ts`. */
|
|
317
|
+
name: string
|
|
318
|
+
/**
|
|
319
|
+
* What runs it, when it names it (\`on\`): components, or \`clock\` —
|
|
320
|
+
* every tick. Null: what it reads runs it. Absent from runtimes
|
|
321
|
+
* that paced systems by a declared rate.
|
|
322
|
+
*/
|
|
323
|
+
on?: string[] | null
|
|
324
|
+
/** Runs on the first tick only. */
|
|
325
|
+
once: boolean
|
|
326
|
+
/** Runs beside the tick: its writes land at the start of a later one. */
|
|
327
|
+
async: boolean
|
|
328
|
+
/** Runs on a worker thread when the cognet has threads. */
|
|
329
|
+
worker: boolean
|
|
330
|
+
/** Ticks from when a run starts to when its writes land; 0, the tick it ran in. Absent from older runtimes. */
|
|
331
|
+
lag?: number
|
|
332
|
+
/** This tick's values — every writer runs first. */
|
|
333
|
+
reads: string[]
|
|
334
|
+
/** Every value written since it last ran — every writer runs first. Absent from older runtimes. */
|
|
335
|
+
streams?: string[]
|
|
336
|
+
/** Last tick's values — no ordering edge. */
|
|
337
|
+
recalls: string[]
|
|
338
|
+
writes: string[]
|
|
339
|
+
/** The services it calls, by the names the cognet gave them. Absent from older runtimes. */
|
|
340
|
+
uses?: string[]
|
|
341
|
+
}>
|
|
342
|
+
/** Every component a system names, and the folder it is declared in. */
|
|
343
|
+
components: Array<{ name: string; scope: string }>
|
|
344
|
+
/** Every query a system names, and the components it is made of. */
|
|
345
|
+
queries: Array<{ name: string; scope: string; members: string[] }>
|
|
174
346
|
}
|
|
175
347
|
|
|
176
|
-
|
|
177
|
-
|
|
348
|
+
// `system` is who made the write — null outside any system bracket (boot
|
|
349
|
+
// spawning, a loop body writing directly). Optional on the wire for the
|
|
350
|
+
// same reason `value` is: bundles predating it still emit these events.
|
|
351
|
+
"cognet:entity:add": { tick: number; phase: string | null; system?: string | null; entity: string }
|
|
352
|
+
"cognet:entity:remove": { tick: number; phase: string | null; system?: string | null; entity: string }
|
|
178
353
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
354
|
+
//
|
|
355
|
+
// `rev` names this change, world-monotonic, so a read can point at exactly
|
|
356
|
+
// the value it saw. Optional on the wire for the same reason as the rest.
|
|
357
|
+
"cognet:component:add": { tick: number; phase: string | null; system?: string | null; entity: string; component: string; rev?: number; value?: unknown }
|
|
358
|
+
"cognet:component:update": { tick: number; phase: string | null; system?: string | null; entity: string; component: string; rev?: number; value?: unknown }
|
|
359
|
+
"cognet:component:remove": { tick: number; phase: string | null; system?: string | null; entity: string; component: string }
|
|
182
360
|
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* What kind of space a frame is. Not only metric: a dependency graph, a file
|
|
364
|
+
* tree and a conversation are spaces too, with positions and neighbours.
|
|
365
|
+
*/
|
|
366
|
+
export type FrameKind = "metric2d" | "metric3d" | "graph" | "tree" | "sequence"
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* How a component's value is drawn in its frame — the contract between a
|
|
370
|
+
* mind and every viewer of it, so a viewer draws a belief without knowing
|
|
371
|
+
* what it means. Each value shape is documented where a mind declares it
|
|
372
|
+
* (`@arcforge/cognet`'s component schema).
|
|
373
|
+
*
|
|
374
|
+
* span { from: { seq, at }, to: { seq, at } } — a stretch of the session's text (`TextSpan`),
|
|
375
|
+
* in a `sequence` frame. Text perception's position: an atom, a
|
|
376
|
+
* mention, a segment. The entity's other components colour it.
|
|
377
|
+
*/
|
|
378
|
+
export type Archetype = "point" | "box" | "arrow" | "path" | "cloud" | "grid" | "raster" | "view" | "series" | "transform" | "span"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AxonEngineFault, AxonEngineMessage, AxonEngineMeta } from "../../engine"
|
|
2
|
+
import type { AxonError } from "../../error"
|
|
2
3
|
import type { AxonLogEvents } from "./log"
|
|
3
4
|
import type { AxonCancellableSpan, AxonSpan } from "./span"
|
|
4
5
|
|
|
@@ -73,6 +74,25 @@ export type AxonKernelEventMap =
|
|
|
73
74
|
{ role: string; durationMs: number },
|
|
74
75
|
{ role: string; fault: AxonEngineFault }
|
|
75
76
|
>
|
|
77
|
+
/**
|
|
78
|
+
* A service call — what a cognet asked of a use, and which provider
|
|
79
|
+
* answered. The agent's record, never the cognet's: the cognet sees the
|
|
80
|
+
* interface, and this is where the provider that answered is kept.
|
|
81
|
+
*
|
|
82
|
+
* A stream is one span, open to its end, with how many `events` it gave;
|
|
83
|
+
* left early by its reader, it is interrupted. A session is bracketed at
|
|
84
|
+
* open and close, never per push — a voice detector at 30Hz would drown
|
|
85
|
+
* the log, and the session's lifetime is the interval that means
|
|
86
|
+
* something. The payload never appears: the log records what happened,
|
|
87
|
+
* not what moved.
|
|
88
|
+
*/
|
|
89
|
+
& AxonCancellableSpan<
|
|
90
|
+
"kernel:service",
|
|
91
|
+
{ use: string; method: string; kind: "call" | "stream" | "session"; provider: string },
|
|
92
|
+
{ use: string; method: string; events?: number },
|
|
93
|
+
{ use: string; method: string; error: AxonError },
|
|
94
|
+
{ use: string; method: string; events?: number }
|
|
95
|
+
>
|
|
76
96
|
& {
|
|
77
97
|
/**
|
|
78
98
|
* The rendered AIR document handed to the engine for this call — what the
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { AxonError } from "../../error"
|
|
2
|
+
import type { AgentUsage } from "../../usage"
|
|
3
|
+
import type { Manifest } from "../../body/body"
|
|
2
4
|
import type { AxonLogEvents } from "./log"
|
|
3
5
|
import type { AxonCancellableSpan, AxonSpan } from "./span"
|
|
4
6
|
|
|
@@ -98,7 +100,7 @@ export type AxonRuntimeEvent =
|
|
|
98
100
|
& AxonSpan<
|
|
99
101
|
"axon:inference:provider",
|
|
100
102
|
{ provider: string; spanId: string },
|
|
101
|
-
{ provider: string; spanId: string; capabilities: number; cached: boolean },
|
|
103
|
+
{ provider: string; spanId: string; capabilities: number; cached: boolean; failure?: { message: string } },
|
|
102
104
|
{ provider: string; spanId: string; error: AxonError }
|
|
103
105
|
>
|
|
104
106
|
|
|
@@ -343,6 +345,32 @@ export type AxonRuntimeEvent =
|
|
|
343
345
|
"process:attach": { capsuleId: string; cwd: string }
|
|
344
346
|
"process:detach": { capsuleId: string; reason: "shutdown" | "crash" | "reload" }
|
|
345
347
|
|
|
348
|
+
// ── Body ─────────────────────────────────────────────────────────────────
|
|
349
|
+
/**
|
|
350
|
+
* The body the agent now wears, as it described itself — and again each
|
|
351
|
+
* time it describes itself anew. Durable, because every reading after it
|
|
352
|
+
* means something only in its terms: a replay, a score, a debugger read
|
|
353
|
+
* the body from here.
|
|
354
|
+
*/
|
|
355
|
+
"axon:body:worn": { manifest: Manifest }
|
|
356
|
+
/** The body is gone: released, lost, or its world stopped. */
|
|
357
|
+
"axon:body:left": { why: string }
|
|
358
|
+
/**
|
|
359
|
+
* Whether the worn body is the mind's to move: embodied, or held (an
|
|
360
|
+
* emergency stop, a safe mode) or overridden (someone else drives it),
|
|
361
|
+
* and why. Its senses go on either way.
|
|
362
|
+
*/
|
|
363
|
+
"axon:body:presence": { state: "embodied" | "held" | "overridden"; why?: string }
|
|
364
|
+
|
|
365
|
+
// ── Cost ─────────────────────────────────────────────────────────────────
|
|
366
|
+
/**
|
|
367
|
+
* What this agent is costing the machine, part by part — sampled by its
|
|
368
|
+
* supervisor every few seconds while it runs. In the session log so a
|
|
369
|
+
* reader scrubbing back in time sees what it cost THEN, beside what it
|
|
370
|
+
* was doing.
|
|
371
|
+
*/
|
|
372
|
+
"axon:usage": AgentUsage
|
|
373
|
+
|
|
346
374
|
// ── Server ───────────────────────────────────────────────────────────────
|
|
347
375
|
"axon:server:request": { method: string; path: string; status: number; durationMs: number }
|
|
348
376
|
|
|
@@ -119,6 +119,12 @@ export type AxonOutputEvent = {
|
|
|
119
119
|
ref?: StimulusRef
|
|
120
120
|
/** chunking standard (shared.ts) — absent = self-contained complete emission */
|
|
121
121
|
chunk?: AxonChunk
|
|
122
|
+
/**
|
|
123
|
+
* The `sensed` stamp of the newest reading this was decided on, when it is a command to a body. The body
|
|
124
|
+
* answers when the command took effect, on the same clock — so acting's latency is measured for every
|
|
125
|
+
* command (body contract: Command.basis).
|
|
126
|
+
*/
|
|
127
|
+
basis?: number
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
130
|
|
|
@@ -94,6 +94,41 @@ export const SENSORY_EVENTS = new Set<string>([
|
|
|
94
94
|
"cognet:output:visual",
|
|
95
95
|
])
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* The high-rate half of cognet telemetry: what a continuous mind emits per
|
|
99
|
+
* system per tick — run records, tick and phase brackets, world writes.
|
|
100
|
+
*
|
|
101
|
+
* A fourth retention tier, beside the log and the sensory ring: kept in a
|
|
102
|
+
* bounded BINARY ring (TelemetryRing in @arcforge/session), held in the
|
|
103
|
+
* kernel window and announced live exactly like any kernel event, and never
|
|
104
|
+
* appended to the log. A 20Hz mind writes over a thousand of these a second;
|
|
105
|
+
* as JSON lines they were most of the log's size and most of every reader's
|
|
106
|
+
* parse time.
|
|
107
|
+
*
|
|
108
|
+
* What stays in the log is what the mind DECLARED — its schema, its frames,
|
|
109
|
+
* its schedule — and what happened to it: load, errors, outputs, usage. A
|
|
110
|
+
* reader that opens a session long after its ring has rolled still knows
|
|
111
|
+
* what the mind was, and sees how it behaved for as far back as the ring
|
|
112
|
+
* reaches.
|
|
113
|
+
*/
|
|
114
|
+
export const TELEMETRY_EVENTS = new Set<string>([
|
|
115
|
+
"cognet:system:run",
|
|
116
|
+
"cognet:system:overrun",
|
|
117
|
+
"cognet:tick:start",
|
|
118
|
+
"cognet:tick:complete",
|
|
119
|
+
"cognet:tick:failed",
|
|
120
|
+
"cognet:tick:interrupted",
|
|
121
|
+
"cognet:phase:start",
|
|
122
|
+
"cognet:phase:complete",
|
|
123
|
+
"cognet:phase:failed",
|
|
124
|
+
"cognet:phase:interrupted",
|
|
125
|
+
"cognet:component:add",
|
|
126
|
+
"cognet:component:update",
|
|
127
|
+
"cognet:component:remove",
|
|
128
|
+
"cognet:entity:add",
|
|
129
|
+
"cognet:entity:remove",
|
|
130
|
+
])
|
|
131
|
+
|
|
97
132
|
/**
|
|
98
133
|
* Content-addressed reference to a heavy payload (audio segment, frame,
|
|
99
134
|
* clip) held OUTSIDE the log — device buffer, blob store, agent home.
|
|
@@ -76,6 +76,8 @@ export type AxonStimulusEvent = {
|
|
|
76
76
|
/** inline digest, when the producer already had one — never a summary it computed */
|
|
77
77
|
transcript?: string
|
|
78
78
|
durationMs?: number
|
|
79
|
+
/** When it began to be heard, ms on the body's own clock — as a vector reading's `sensed`. */
|
|
80
|
+
sensed?: number
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
/** A frame or clip. Bytes stay behind `ref`; `caption` is an optional inline digest. */
|
|
@@ -85,6 +87,8 @@ export type AxonStimulusEvent = {
|
|
|
85
87
|
/** inline digest, when the producer already had one — never a summary it computed */
|
|
86
88
|
caption?: string
|
|
87
89
|
kind: "image" | "video"
|
|
90
|
+
/** When it was seen, ms on the body's own clock — as a vector reading's `sensed`. */
|
|
91
|
+
sensed?: number
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
/**
|
|
@@ -160,6 +164,19 @@ export type AxonStimulusEvent = {
|
|
|
160
164
|
* is what keeps this kind set closed.
|
|
161
165
|
*/
|
|
162
166
|
profile?: string
|
|
167
|
+
/**
|
|
168
|
+
* When the instrument took the sample, ms on the BODY's own clock —
|
|
169
|
+
* what ROS calls a header stamp. The envelope's time is when the
|
|
170
|
+
* reading reached the mind, which a lagging body, a batching bridge
|
|
171
|
+
* or a large reading's upload can put tens of ms after the fact.
|
|
172
|
+
* Anything relating readings to each other in time — an IMU's
|
|
173
|
+
* samples, a depth look and the motion it was taken during — needs
|
|
174
|
+
* this, and must compare it only with readings from the same body.
|
|
175
|
+
*
|
|
176
|
+
* Optional because most instruments have no clock worth more than
|
|
177
|
+
* arrival: a reading without it was sensed when it arrived.
|
|
178
|
+
*/
|
|
179
|
+
sensed?: number
|
|
163
180
|
/**
|
|
164
181
|
* For readings too large to inline — a point cloud is 50,000 × 3
|
|
165
182
|
* numbers. Same size rule audio and visual already use, so a reading
|
package/src/session/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type {
|
|
|
6
6
|
AxonIngestedEvent,
|
|
7
7
|
} from "./envelope"
|
|
8
8
|
export type { AxonKernelEventMap } from "./events/kernel"
|
|
9
|
-
export type { CognetEventMap } from "./events/cognet"
|
|
9
|
+
export type { Archetype, CognetEventMap, CognetTickComplete, CognetTickStart, FrameKind, InstrumentRole } from "./events/cognet"
|
|
10
10
|
export type { CapsuleEventMap, CapsuleEventName, AnyCapsuleEvent, CapsuleCommandOrigin } from "./events/capsule"
|
|
11
11
|
export type { BuildEventMap, BuildEventName, AnyBuildEvent, BuildStage } from "./events/build"
|
|
12
12
|
export { isBuildEvent } from "./events/build"
|
|
@@ -19,6 +19,7 @@ export { ENTRY_EVENT_PREFIXES } from "./events/entries"
|
|
|
19
19
|
export { isKernelEvent, isEntryEvent, classifyEvent, type AxonEventView } from "./classify"
|
|
20
20
|
export type { AxonStimulusEntry, AxonStimulusInput, AxonStimulusEvent, AxonStimulusType } from "./events/stdio/stimuli"
|
|
21
21
|
export { STIMULUS_TRANSIENT_EVENTS } from "./events/stdio/stimuli"
|
|
22
|
+
export { SENSORY_EVENTS, TELEMETRY_EVENTS } from "./events/stdio/shared"
|
|
22
23
|
export type { AxonOutputEvent, AxonOutputType } from "./events/stdio/output"
|
|
23
24
|
export type { AxonChannel, AxonChunk, AxonTextFormat, StimulusRef } from "./events/stdio/shared"
|
|
24
25
|
export type { AxonLogEvents } from "./events/log"
|
|
@@ -37,6 +38,8 @@ export type {
|
|
|
37
38
|
AxonTestStatus,
|
|
38
39
|
} from "./events/test"
|
|
39
40
|
export { foldChunks } from "./session"
|
|
41
|
+
export { addressedTo } from "./channel"
|
|
42
|
+
export { entryText, type TextPoint, type TextSpan } from "./text"
|
|
40
43
|
|
|
41
44
|
export type {
|
|
42
45
|
AxonSessionSnapshot,
|
package/src/session/session.ts
CHANGED
|
@@ -64,7 +64,7 @@ export type AxonSpanName = {
|
|
|
64
64
|
// ── Enveloped unions (what actually sits in the JSONL) ──────────────────────
|
|
65
65
|
|
|
66
66
|
/** One line in the session's kernel log — internal telemetry, never rendered to the user. */
|
|
67
|
-
export type AxonKernelEvent = AxonEventUnion<AxonKernelEventMap>
|
|
67
|
+
export type AxonKernelEvent = AxonEventUnion<AxonKernelEventMap & CognetEventMap & CapsuleEventMap>
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* One line in the session's own log — runtime/continuity facts, and the build
|
|
@@ -137,7 +137,7 @@ export function foldChunks(entries: readonly AxonEntry[]): AxonEntry[] {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/** A single enveloped kernel-log event of a specific type, e.g. AxonKernelEventOf<"kernel:tick:start">. */
|
|
140
|
-
export type AxonKernelEventOf<K extends keyof AxonKernelEventMap> = AxonEvent<AxonKernelEventMap, K>
|
|
140
|
+
export type AxonKernelEventOf<K extends keyof (AxonKernelEventMap & CognetEventMap & CapsuleEventMap)> = AxonEvent<AxonKernelEventMap & CognetEventMap & CapsuleEventMap, K>
|
|
141
141
|
/** A single enveloped session-log event of a specific type, e.g. AxonSessionEventOf<"axon:boot:complete">. */
|
|
142
142
|
export type AxonSessionEventOf<K extends keyof AxonRuntimeEvent> = AxonEvent<AxonRuntimeEvent, K>
|
|
143
143
|
export type AxonEntryOf<K extends keyof AxonEntryEvent> = AxonEvent<AxonEntryEvent, K>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A place in the session's text: an entry, named by the seq the mind received
|
|
3
|
+
* it at, and an offset into `entryText(entry)` in UTF-16 code units. A
|
|
4
|
+
* streamed reply is ONE entry: its chunks folded together (`foldChunks`),
|
|
5
|
+
* named by the seq of its first chunk. A place never addresses a chunk.
|
|
6
|
+
*/
|
|
7
|
+
export type TextPoint = { seq: number; at: number }
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A stretch of the session's text — where a piece of text perception sits,
|
|
11
|
+
* as a pose is where a thing sits in space. `to` is exclusive.
|
|
12
|
+
*
|
|
13
|
+
* Its ends may lie in different entries: a sentence starts and ends in one,
|
|
14
|
+
* a topic runs across many. Equal ends are a boundary — a place, not a stretch.
|
|
15
|
+
*/
|
|
16
|
+
export type TextSpan = { from: TextPoint; to: TextPoint }
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The text of an entry, as a span indexes it — or null for an entry that has
|
|
20
|
+
* none (a picture, a sound).
|
|
21
|
+
*
|
|
22
|
+
* The ONE definition: the mind computes spans against it and every viewer
|
|
23
|
+
* draws them against it. Two that disagreed by a character would shift every
|
|
24
|
+
* overlay by it — plausibly, and with nothing to say so.
|
|
25
|
+
*/
|
|
26
|
+
export function entryText(entry: { type: string; data: unknown }): string | null {
|
|
27
|
+
switch (entry.type) {
|
|
28
|
+
case "cognet:stimulus:text":
|
|
29
|
+
case "cognet:output:text":
|
|
30
|
+
case "cognet:action:typescript":
|
|
31
|
+
case "cognet:action:result":
|
|
32
|
+
return (entry.data as { content: string }).content
|
|
33
|
+
default:
|
|
34
|
+
return null
|
|
35
|
+
}
|
|
36
|
+
}
|