@arcforge/types 2.0.107 → 2.0.109

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.107",
3
+ "version": "2.0.109",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./src/index.ts",
@@ -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 on a fixed clock regardless of whether anything
28
- * arrived; an empty diff is the ordinary steady state, not an edge case.
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"; tickMs: number }
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.
@@ -31,6 +32,27 @@ export type AxonConfig<EventMap extends Record<string, unknown> = Record<string,
31
32
  /** Short human-readable summary shown in registries, docs, and generated manifests. */
32
33
  // description?: string // deprected. use package.json instead
33
34
 
35
+ /**
36
+ * Paths on this agent's own HTTP surface worth surfacing to whoever boots
37
+ * it — printed in the `axon dev` banner alongside the agent's URL.
38
+ *
39
+ * ```ts
40
+ * links: { viewer: "/api/sim", docs: "/api/help" }
41
+ * ```
42
+ *
43
+ * Values are PATHS, never absolute URLs: the runtime binds a port at boot
44
+ * (walking forward if the requested one is taken), so an agent that wrote
45
+ * `http://localhost:3010/...` here would advertise the wrong address the
46
+ * first time two agents ran side by side.
47
+ *
48
+ * The runtime attaches no meaning to a name. It does not know what a
49
+ * viewer is, only that the author wants this path shown — which is why
50
+ * this is a flat label→path map rather than a typed `ui:` field with a
51
+ * title and an icon. A shape that describes what the thing IS would be
52
+ * the runtime learning about kinds of page; this shape only says where.
53
+ */
54
+ links?: Record<string, string>
55
+
34
56
  /** Sandbox permissions enforced at the capsule boundary. */
35
57
  policy?: CapsulePartialConfig["policy"]
36
58
 
@@ -44,16 +66,29 @@ export type AxonConfig<EventMap extends Record<string, unknown> = Record<string,
44
66
  /**
45
67
  * Cognet selection — which brain this agent runs.
46
68
  *
47
- * A scoped registry specifier, optionally version-pinned, exactly like a
48
- * module: `"@axon/zero"`, `"@axon/zero@^0.2.0"`, `"@you/my-loop"`. It is
49
- * installed as a package.json dependency at `axon prepare` and compiled
50
- * into the agent, so versions resolve and lock through Bun like any other
51
- * dependency. Defaults to `"@axon/zero"`.
69
+ * Two forms, exactly like a module:
70
+ *
71
+ * - `"@axon/zero"` — a scoped registry specifier, optionally
72
+ * version-pinned (`"@axon/zero@^0.2.0"`). Installed as a package.json
73
+ * dependency at `axon prepare` and compiled into the agent, so versions
74
+ * resolve and lock through Bun like any other dependency.
75
+ * - `Vehicle` — a direct source import of a `cognet.config.ts`, compiled
76
+ * from its own directory with no install step. The path comes from the
77
+ * import statement, resolved statically at prepare.
78
+ *
79
+ * ```ts
80
+ * import Vehicle from "../../cognets/braitenberg-vehicle/cognet.config"
81
+ * export default defineAgent({ cognet: Vehicle })
82
+ * ```
83
+ *
84
+ * Omitted entirely, the agent tracks the registry's latest `@axon/zero`
85
+ * for this kernel ABI — choosing nothing is not the same as choosing the
86
+ * default.
52
87
  *
53
88
  * Exactly one per agent — an agent has one brain. The runtime never sees
54
89
  * this field; it reads the bundled blueprint.cognet.
55
90
  */
56
- cognet?: string
91
+ cognet?: string | CognetConfig
57
92
 
58
93
 
59
94
 
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[]
@@ -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 enter the log. A stimulus is a small, durable,
13
- * replayable fact: a `ref` into content-addressed storage / a device
14
- * buffer, plus a symbolic `digest` cognition can fold without fetching
15
- * bytes (perception delivers percepts, not pixels). MB/s sense streams
16
- * live below this protocol as devices; ATTENTION MODULES convert dense
17
- * streams into sparse salient stimuli (event-camera model) — the log
18
- * only ever sees the sparse side.
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
- /** A salient audio segment, cut from a stream by an attention module. */
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
- /** symbolic digest — what cognition folds without fetching audio */
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 salient frame or clip, cut from a stream by an attention module. */
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
- /** symbolic digest — caption / detected percepts */
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 salient reading from a measured field — threshold crossed, state
88
- * changed, anomaly detected. The reading is inline (small by nature);
89
- * `ref` optionally points at the surrounding raw window.
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
  }