@arcforge/types 2.0.106 → 2.0.108
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/cognet/cognet.ts +11 -3
- package/src/config.ts +20 -6
- package/src/handle.ts +47 -1
- package/src/instance.ts +21 -0
- package/src/session/events/stdio/stimuli.ts +29 -16
package/package.json
CHANGED
package/src/cognet/cognet.ts
CHANGED
|
@@ -24,12 +24,20 @@ import type { AxonEntryEvent } from "../session/events/entries"
|
|
|
24
24
|
* - "invocation" — invoked once per admitted stimulus arrival, handed the
|
|
25
25
|
* full diff accumulated since the last invocation (may be more than one
|
|
26
26
|
* stimulus if several arrived while the previous wake was running).
|
|
27
|
-
* - "continuous" — invoked
|
|
28
|
-
* arrived; an empty diff is the ordinary steady state, not an
|
|
27
|
+
* - "continuous" — invoked by a clock the BODY owns, regardless of whether
|
|
28
|
+
* anything arrived; an empty diff is the ordinary steady state, not an
|
|
29
|
+
* edge case.
|
|
30
|
+
*
|
|
31
|
+
* Continuous carries no rate. It declares the SHAPE of the cognet — "tick
|
|
32
|
+
* me, don't hand me a chat prompt" — which is what `stream()` and `tick()`
|
|
33
|
+
* reject against, and nothing more. A `tickMs` lived here once and was
|
|
34
|
+
* wrong in the same way a `salience` field on a stimulus is wrong: it had
|
|
35
|
+
* the brain asserting how fast its world turns, which it cannot know and
|
|
36
|
+
* must never assume. The rate lives with whatever drives `axon.tick()`.
|
|
29
37
|
*/
|
|
30
38
|
export type CognetSchedule =
|
|
31
39
|
| { kind: "invocation" }
|
|
32
|
-
| { kind: "continuous"
|
|
40
|
+
| { kind: "continuous" }
|
|
33
41
|
|
|
34
42
|
/**
|
|
35
43
|
* Cognet identity — what cognet.config.ts declares via defineCognet().
|
package/src/config.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { EngineConfig } from "./engine"
|
|
|
2
2
|
import { CapsulePartialConfig } from "./capsule-config"
|
|
3
3
|
import { DeployConfig } from "./deploy"
|
|
4
4
|
import { ModuleEntry } from "./module"
|
|
5
|
+
import { CognetConfig } from "./cognet/cognet"
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Authoring configuration for an Axon agent.
|
|
@@ -44,16 +45,29 @@ export type AxonConfig<EventMap extends Record<string, unknown> = Record<string,
|
|
|
44
45
|
/**
|
|
45
46
|
* Cognet selection — which brain this agent runs.
|
|
46
47
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
48
|
+
* Two forms, exactly like a module:
|
|
49
|
+
*
|
|
50
|
+
* - `"@axon/zero"` — a scoped registry specifier, optionally
|
|
51
|
+
* version-pinned (`"@axon/zero@^0.2.0"`). Installed as a package.json
|
|
52
|
+
* dependency at `axon prepare` and compiled into the agent, so versions
|
|
53
|
+
* resolve and lock through Bun like any other dependency.
|
|
54
|
+
* - `Vehicle` — a direct source import of a `cognet.config.ts`, compiled
|
|
55
|
+
* from its own directory with no install step. The path comes from the
|
|
56
|
+
* import statement, resolved statically at prepare.
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* import Vehicle from "../../cognets/braitenberg-vehicle/cognet.config"
|
|
60
|
+
* export default defineAgent({ cognet: Vehicle })
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* Omitted entirely, the agent tracks the registry's latest `@axon/zero`
|
|
64
|
+
* for this kernel ABI — choosing nothing is not the same as choosing the
|
|
65
|
+
* default.
|
|
52
66
|
*
|
|
53
67
|
* Exactly one per agent — an agent has one brain. The runtime never sees
|
|
54
68
|
* this field; it reads the bundled blueprint.cognet.
|
|
55
69
|
*/
|
|
56
|
-
cognet?: string
|
|
70
|
+
cognet?: string | CognetConfig
|
|
57
71
|
|
|
58
72
|
|
|
59
73
|
|
package/src/handle.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AxonEntry, AxonKernelEvent, AxonSessionEvent } from "./session"
|
|
1
|
+
import type { AxonEntry, AxonKernelEvent, AxonSessionEvent, AxonStimulusEvent, AxonStimulusType } from "./session"
|
|
2
2
|
import type { AxonScript } from "./scripts"
|
|
3
3
|
import type { AxonPrompt } from "./prompts"
|
|
4
4
|
import type { AxonPartialBlueprint } from "./blueprint"
|
|
@@ -142,6 +142,52 @@ export type AxonHandle = {
|
|
|
142
142
|
/** Streaming agent invocation — yields entries as they happen. */
|
|
143
143
|
stream(input: AxonRequestInput | string): AxonRun
|
|
144
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Deliver a stimulus — the agent's sense door, and the only way the
|
|
147
|
+
* environment reaches cognition.
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* axon.stim("cognet:stimulus:field", {
|
|
151
|
+
* source: { channel: "light:left" },
|
|
152
|
+
* reading: { value: 0.42, unit: "lux" },
|
|
153
|
+
* })
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* The stimulus lands on the delivery buffer and is handed to the cognet
|
|
157
|
+
* at its next wake, then dropped — a stimulus is a transient sensation,
|
|
158
|
+
* not a record. A cognet gets ONE chance to attend to it; anything it
|
|
159
|
+
* wants to keep, it keeps in its own resident state. Nothing here judges
|
|
160
|
+
* what is worth delivering (see stimuli.ts — zero cognition upstream of
|
|
161
|
+
* the brain), so a producer emits what its sensor produced and lets the
|
|
162
|
+
* mind decide what matters.
|
|
163
|
+
*
|
|
164
|
+
* Mirrors `kernel.output(type, data)` on the far side of the boundary:
|
|
165
|
+
* sense in, act out, same shape.
|
|
166
|
+
*/
|
|
167
|
+
stim<K extends AxonStimulusType>(type: K, data: AxonStimulusEvent[K]): Promise<AxonEntry>
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Advance a continuous cognet by one wake, handing it whatever stimuli
|
|
171
|
+
* have arrived since the last one. The clock is yours: a body knows how
|
|
172
|
+
* fast its world turns, a brain does not.
|
|
173
|
+
*
|
|
174
|
+
* ```ts
|
|
175
|
+
* // server/plugins/body.ts
|
|
176
|
+
* setInterval(async () => {
|
|
177
|
+
* world.step(dt)
|
|
178
|
+
* await axon.stim("cognet:stimulus:field", { ... })
|
|
179
|
+
* await axon.tick()
|
|
180
|
+
* }, 33)
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* Resolves `true` when a wake ran to completion, `false` when one was
|
|
184
|
+
* already in flight and this tick was skipped — a clock running near
|
|
185
|
+
* capacity skips, it does not queue and it does not throw. Throws only if
|
|
186
|
+
* the cognet is invocation-mode, which wakes on stimuli via `request()`
|
|
187
|
+
* or `stream()` instead.
|
|
188
|
+
*/
|
|
189
|
+
tick(): Promise<boolean>
|
|
190
|
+
|
|
145
191
|
scripts: {
|
|
146
192
|
request(name: string, args?: Record<string, unknown>): Promise<unknown>
|
|
147
193
|
list(): AxonScript[]
|
package/src/instance.ts
CHANGED
|
@@ -51,4 +51,25 @@ export type AxonInstance = {
|
|
|
51
51
|
* is answering rather than inferring it from timing.
|
|
52
52
|
*/
|
|
53
53
|
job?: string
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The local control channel this process is listening on, when it runs
|
|
57
|
+
* a surface something can drive (the TUI does; a headless `axon run`
|
|
58
|
+
* does not). Absent means "this instance cannot be controlled", which
|
|
59
|
+
* is a real answer rather than a missing one.
|
|
60
|
+
*
|
|
61
|
+
* Both fields are written once at boot and true for the whole life of
|
|
62
|
+
* the process: the port is bound before this record is written and
|
|
63
|
+
* closes with the pid, so the registry's existing liveness check proves
|
|
64
|
+
* the socket too. That is why discovery needs nothing beyond this field
|
|
65
|
+
* — no announce protocol, no lockfile, no second watcher.
|
|
66
|
+
*
|
|
67
|
+
* The token exists because a listening port is reachable by any local
|
|
68
|
+
* process no matter how the store is chmod'd. The 0700 store guards
|
|
69
|
+
* this secret; this secret guards the socket.
|
|
70
|
+
*/
|
|
71
|
+
control?: {
|
|
72
|
+
port: number
|
|
73
|
+
token: string
|
|
74
|
+
}
|
|
54
75
|
}
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
* Stimuli — the sense protocol. Every environment event that can trigger
|
|
3
3
|
* cognition enters through this vocabulary and no other path.
|
|
4
4
|
*
|
|
5
|
+
* ZERO COGNITION HAPPENS BEFORE THE COGNET. This is the invariant the whole
|
|
6
|
+
* namespace exists to protect. A stimulus is raw sense data, and nothing
|
|
7
|
+
* upstream of the brain may judge, rank, filter, or interpret it — those are
|
|
8
|
+
* brain functions, and a runtime that performs them has moved part of the
|
|
9
|
+
* mind outside the mind. Selective attention, salience, novelty detection,
|
|
10
|
+
* sensor fusion: all real, all cognition, all implemented INSIDE a cognet by
|
|
11
|
+
* whoever wants them. The kernel's job is delivery, not perception.
|
|
12
|
+
*
|
|
5
13
|
* DESIGN RULES (what keeps this file from growing forever):
|
|
6
14
|
*
|
|
7
15
|
* 1. Top-level types are INFORMATION KINDS, not sensors. Symbolic language,
|
|
@@ -9,13 +17,16 @@
|
|
|
9
17
|
* kind (ROS sensor_msgs discipline: the core set outlives every vendor).
|
|
10
18
|
* A new top-level type here is a once-per-epoch event, like a syscall.
|
|
11
19
|
*
|
|
12
|
-
* 2. Heavy payloads NEVER
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
20
|
+
* 2. Heavy payloads NEVER cross this protocol. A stimulus is a small fact: a
|
|
21
|
+
* `ref` into content-addressed storage / a device buffer, plus an optional
|
|
22
|
+
* inline digest the cognet may fold without fetching bytes. MB/s sense
|
|
23
|
+
* streams live below this protocol as devices, and what a cognet does with
|
|
24
|
+
* a `ref` — fetch it, ignore it, sample one in ten — is a cognet decision.
|
|
25
|
+
*
|
|
26
|
+
* NO CULLING HAPPENS HERE. A producer delivers what its sensor produced;
|
|
27
|
+
* it does not decide what was worth delivering. If a dense stream needs
|
|
28
|
+
* thinning, the thing doing the thinning is cognition and belongs inside a
|
|
29
|
+
* cognet, not upstream of one.
|
|
19
30
|
*
|
|
20
31
|
* 3. Stimuli are EXTEROCEPTION — the world reaching the agent. Internal
|
|
21
32
|
* news (timers, process exits) also wakes a cognet but is interoception:
|
|
@@ -65,35 +76,37 @@ export type AxonStimulusEvent = {
|
|
|
65
76
|
content: string
|
|
66
77
|
}
|
|
67
78
|
|
|
68
|
-
/**
|
|
79
|
+
/** An audio segment. Bytes stay behind `ref`; `transcript` is an optional inline digest. */
|
|
69
80
|
"cognet:stimulus:audio": {
|
|
70
81
|
source: StimulusSource
|
|
71
82
|
ref: StimulusRef
|
|
72
|
-
/**
|
|
83
|
+
/** inline digest, when the producer already had one — never a summary it computed */
|
|
73
84
|
transcript?: string
|
|
74
85
|
durationMs?: number
|
|
75
86
|
}
|
|
76
87
|
|
|
77
|
-
/** A
|
|
88
|
+
/** A frame or clip. Bytes stay behind `ref`; `caption` is an optional inline digest. */
|
|
78
89
|
"cognet:stimulus:visual": {
|
|
79
90
|
source: StimulusSource
|
|
80
91
|
ref: StimulusRef
|
|
81
|
-
/**
|
|
92
|
+
/** inline digest, when the producer already had one — never a summary it computed */
|
|
82
93
|
caption?: string
|
|
83
94
|
kind: "image" | "video"
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
/**
|
|
87
|
-
* A
|
|
88
|
-
*
|
|
89
|
-
*
|
|
98
|
+
* A reading from a measured field — touch, heat, pose, battery, light,
|
|
99
|
+
* price. The reading is inline (small by nature); `ref` optionally points
|
|
100
|
+
* at a surrounding raw window.
|
|
101
|
+
*
|
|
102
|
+
* Deliberately carries no judgment about why the reading was sent. A
|
|
103
|
+
* producer emits what it measured; deciding which readings matter is the
|
|
104
|
+
* cognet's, and only the cognet's.
|
|
90
105
|
*/
|
|
91
106
|
"cognet:stimulus:field": {
|
|
92
107
|
source: StimulusSource
|
|
93
108
|
/** the measurement, unit-tagged, e.g. { value: 87, unit: "%" } */
|
|
94
109
|
reading: { value: number | string | boolean; unit?: string }
|
|
95
|
-
/** why this reading surfaced — the attention module's verdict */
|
|
96
|
-
salience?: string
|
|
97
110
|
ref?: StimulusRef
|
|
98
111
|
}
|
|
99
112
|
}
|