@arcforge/types 2.0.59

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.
Files changed (59) hide show
  1. package/package.json +29 -0
  2. package/src/bench/aggregate.ts +67 -0
  3. package/src/bench/artifact.ts +39 -0
  4. package/src/bench/bench.ts +62 -0
  5. package/src/bench/contribution.ts +40 -0
  6. package/src/bench/dimension.ts +15 -0
  7. package/src/bench/execution.ts +76 -0
  8. package/src/bench/factor.ts +69 -0
  9. package/src/bench/index.ts +108 -0
  10. package/src/bench/manifest.ts +49 -0
  11. package/src/bench/measurement.ts +41 -0
  12. package/src/bench/observation.ts +42 -0
  13. package/src/bench/protocol.ts +21 -0
  14. package/src/bench/result.ts +32 -0
  15. package/src/bench/value.ts +7 -0
  16. package/src/bench/workspace.ts +76 -0
  17. package/src/blueprint.ts +125 -0
  18. package/src/capsule-config.ts +111 -0
  19. package/src/cognet/blueprint.ts +38 -0
  20. package/src/cognet/cognet.ts +69 -0
  21. package/src/cognet/hooks.ts +43 -0
  22. package/src/cognet/index.ts +3 -0
  23. package/src/config.ts +72 -0
  24. package/src/define.ts +184 -0
  25. package/src/deploy.ts +54 -0
  26. package/src/engine.ts +254 -0
  27. package/src/error.ts +88 -0
  28. package/src/handle.ts +137 -0
  29. package/src/hooks.ts +31 -0
  30. package/src/http.ts +49 -0
  31. package/src/index.ts +23 -0
  32. package/src/kernel/abi.ts +244 -0
  33. package/src/kernel/index.ts +2 -0
  34. package/src/middleware.ts +7 -0
  35. package/src/module.ts +193 -0
  36. package/src/plugin.ts +9 -0
  37. package/src/policy.ts +89 -0
  38. package/src/prompts.ts +25 -0
  39. package/src/route.ts +15 -0
  40. package/src/scope.ts +29 -0
  41. package/src/scripts.ts +21 -0
  42. package/src/session/envelope.ts +61 -0
  43. package/src/session/events/activity.ts +77 -0
  44. package/src/session/events/bench.ts +49 -0
  45. package/src/session/events/capsule.ts +114 -0
  46. package/src/session/events/cognet.ts +51 -0
  47. package/src/session/events/engine.ts +46 -0
  48. package/src/session/events/entries.ts +66 -0
  49. package/src/session/events/kernel.ts +44 -0
  50. package/src/session/events/log.ts +27 -0
  51. package/src/session/events/runtime.ts +76 -0
  52. package/src/session/events/stdio/output.ts +94 -0
  53. package/src/session/events/stdio/shared.ts +50 -0
  54. package/src/session/events/stdio/stimuli.ts +110 -0
  55. package/src/session/events/test.ts +52 -0
  56. package/src/session/index.ts +40 -0
  57. package/src/session/session.ts +107 -0
  58. package/src/tools.ts +54 -0
  59. package/tsconfig.base.json +14 -0
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Stimuli — the sense protocol. Every environment event that can trigger
3
+ * cognition enters through this vocabulary and no other path.
4
+ *
5
+ * DESIGN RULES (what keeps this file from growing forever):
6
+ *
7
+ * 1. Top-level types are INFORMATION KINDS, not sensors. Symbolic language,
8
+ * sound, light, measured fields — new hardware maps into an existing
9
+ * kind (ROS sensor_msgs discipline: the core set outlives every vendor).
10
+ * A new top-level type here is a once-per-epoch event, like a syscall.
11
+ *
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.
19
+ *
20
+ * 3. Stimuli are EXTEROCEPTION — the world reaching the agent. Internal
21
+ * news (timers, process exits) also wakes a cognet but is interoception:
22
+ * machine-body vocabulary, defined with the machine, not here. The wake
23
+ * mask spans both; this namespace stays senses-only.
24
+ *
25
+ * 4. Stimulushood is a DELIVERY ROLE, not a type property. These are log
26
+ * entries like any other; the scheduler wakes a cognet when an entry is
27
+ * (a) in its wake mask and (b) foreign to its own execution (provenance
28
+ * check via context.runId — a brain never wakes to its own echo).
29
+ */
30
+
31
+ import type { AxonEventUnion } from "../../envelope"
32
+ import type { StimulusRef } from "./shared"
33
+
34
+ // ── Shared shapes ─────────────────────────────────────────────────────────────
35
+
36
+ /**
37
+ * Where a stimulus came from. `channel` identifies the concrete source
38
+ * ("user", "email:inbox", "mic0", "cam:front", "telemetry:battery") —
39
+ * open vocabulary, agent-defined. The TYPE says what kind of information
40
+ * it is; the source says where it entered.
41
+ */
42
+ export type StimulusSource = {
43
+ channel: string
44
+ /** stable id when the source is a session participant (user id, device id) */
45
+ id?: string
46
+ }
47
+
48
+ // ── The sense set ─────────────────────────────────────────────────────────────
49
+
50
+ /**
51
+ * The stimulus registry — log entries, wake-capable by default.
52
+ *
53
+ * Four kinds, chosen to generalize:
54
+ * text — symbolic language (native modality of an LLM)
55
+ * audio — sound over time (speech, ambient) — digest is the transcript
56
+ * visual — light: frames and clips — digest is the caption/percept
57
+ * field — measured quantities over time: touch, heat, pose, battery,
58
+ * GPS, market prices, autopilot telemetry. One type, open
59
+ * channel vocabulary — this is what stops sense-set sprawl.
60
+ */
61
+ export type AxonStimulusEvent = {
62
+ /** Symbolic language input. Inline — text IS its own digest. */
63
+ "cognet:stimulus:text": {
64
+ source: StimulusSource
65
+ content: string
66
+ }
67
+
68
+ /** A salient audio segment, cut from a stream by an attention module. */
69
+ "cognet:stimulus:audio": {
70
+ source: StimulusSource
71
+ ref: StimulusRef
72
+ /** symbolic digest — what cognition folds without fetching audio */
73
+ transcript?: string
74
+ durationMs?: number
75
+ }
76
+
77
+ /** A salient frame or clip, cut from a stream by an attention module. */
78
+ "cognet:stimulus:visual": {
79
+ source: StimulusSource
80
+ ref: StimulusRef
81
+ /** symbolic digest — caption / detected percepts */
82
+ caption?: string
83
+ kind: "image" | "video"
84
+ }
85
+
86
+ /**
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.
90
+ */
91
+ "cognet:stimulus:field": {
92
+ source: StimulusSource
93
+ /** the measurement, unit-tagged, e.g. { value: 87, unit: "%" } */
94
+ reading: { value: number | string | boolean; unit?: string }
95
+ /** why this reading surfaced — the attention module's verdict */
96
+ salience?: string
97
+ ref?: StimulusRef
98
+ }
99
+ }
100
+
101
+ export type AxonStimulusType = keyof AxonStimulusEvent
102
+
103
+ /**
104
+ * One enveloped stimulus — the shape CognetWake.stimuli actually delivers.
105
+ * Narrower than AxonEntry on purpose: a cognet's input contract is
106
+ * stimulus:* only, the mirror of output() being its only unmediated write —
107
+ * it never has to switch over every entry family that exists, only
108
+ * the ones it can actually receive.
109
+ */
110
+ export type AxonStimulusEntry = AxonEventUnion<AxonStimulusEvent>
@@ -0,0 +1,52 @@
1
+ import type { AxonError } from "../../error"
2
+ import type { AxonEventUnion } from "../envelope"
3
+
4
+ export type AxonTestEventContext = {
5
+ testRunId: string
6
+ file?: string
7
+ suiteId?: string
8
+ testId?: string
9
+ hookId?: string
10
+ /** Execution count for retries/repeats of one declared test, zero-based. */
11
+ attempt?: number
12
+ }
13
+
14
+ export type AxonTestHookKind = "beforeAll" | "beforeEach" | "afterEach" | "afterAll"
15
+ export type AxonTestStatus = "passed" | "failed" | "cancelled"
16
+
17
+ export type AxonTestEventMap = {
18
+ "test:run:start": { files: string[] }
19
+ "test:run:complete": { status: AxonTestStatus; durationMs: number; passed: number; failed: number; skipped: number; todo: number }
20
+
21
+ "test:file:start": {}
22
+ "test:file:complete": { exitCode: number | null; durationMs: number }
23
+
24
+ "test:suite:declare": { name: string; parentSuiteId?: string; mode: "run" | "only" | "skip" | "todo" }
25
+ "test:suite:start": { name: string }
26
+ "test:suite:complete": { name: string; durationMs: number }
27
+
28
+ "test:case:declare": { name: string; suite: string[]; mode: "run" | "only" | "skip" | "todo" | "failing" }
29
+ "test:case:start": { name: string; suite: string[] }
30
+ "test:case:pass": { durationMs: number }
31
+ "test:case:fail": { durationMs: number; error: AxonError }
32
+ "test:case:skip": { reason?: string }
33
+ "test:case:todo": {}
34
+
35
+ "test:hook:start": { kind: AxonTestHookKind }
36
+ "test:hook:complete": { kind: AxonTestHookKind; durationMs: number }
37
+ "test:hook:fail": { kind: AxonTestHookKind; durationMs: number; error: AxonError }
38
+
39
+ "test:console": { level: "log" | "info" | "warn" | "error" | "debug"; values: string[] }
40
+ "test:process:fault": { kind: "uncaught" | "unhandled" | "exit" | "protocol"; error: AxonError }
41
+ }
42
+
43
+ export type AxonTestEvent = AxonEventUnion<AxonTestEventMap, AxonTestEventContext>
44
+
45
+ /** Unstamped child-process frame. The parent owns id/time/sequence. */
46
+ export type AxonTestEventFrame = {
47
+ [K in keyof AxonTestEventMap]: {
48
+ type: K
49
+ context: Omit<AxonTestEventContext, "testRunId">
50
+ data: AxonTestEventMap[K]
51
+ }
52
+ }[keyof AxonTestEventMap]
@@ -0,0 +1,40 @@
1
+ export type {
2
+ AxonEvent,
3
+ AxonEventContext,
4
+ AxonEventUnion,
5
+ AxonIngestedEvent,
6
+ } from "./envelope"
7
+ export type { AxonKernelEventMap } from "./events/kernel"
8
+ export type { CognetEventMap } from "./events/cognet"
9
+ export type { CapsuleEventMap, CapsuleEventName, AnyCapsuleEvent } from "./events/capsule"
10
+ export type { Activity, ActivityHandle, ActivityPayloads, ActivityPhase, ActivityType, AxonAmbient } from "./events/activity"
11
+ export { CAPSULE_TRANSIENT_EVENTS } from "./events/capsule"
12
+ export type { AxonRuntimeEvent } from "./events/runtime"
13
+ export type { AxonEngineBlock, AxonEngineDelta, AxonEngineEvent } from "./events/engine"
14
+ export type { AxonEntryEvent } from "./events/entries"
15
+ export { ENTRY_EVENT_PREFIXES } from "./events/entries"
16
+ export type { AxonStimulusEntry, AxonStimulusEvent, AxonStimulusType, StimulusSource } from "./events/stdio/stimuli"
17
+ export type { AxonOutputEvent, AxonOutputType } from "./events/stdio/output"
18
+ export type { AxonChunk, StimulusRef } from "./events/stdio/shared"
19
+ export type { AxonLogEvents } from "./events/log"
20
+ export { LOG_EVENT_SUFFIXES, isLogEventType } from "./events/log"
21
+ export type { BenchEvent, BenchEventContext, BenchEventMap } from "./events/bench"
22
+ export type {
23
+ AxonTestEvent,
24
+ AxonTestEventContext,
25
+ AxonTestEventFrame,
26
+ AxonTestEventMap,
27
+ AxonTestHookKind,
28
+ AxonTestStatus,
29
+ } from "./events/test"
30
+ export { foldChunks } from "./session"
31
+ export type {
32
+ AxonEntry,
33
+ AxonEntryOf,
34
+ AxonEventMap,
35
+ AxonKernelEvent,
36
+ AxonKernelEventOf,
37
+ AxonSession,
38
+ AxonSessionEvent,
39
+ AxonSessionEventOf,
40
+ } from "./session"
@@ -0,0 +1,107 @@
1
+ import type { AxonEvent, AxonEventUnion } from "./envelope"
2
+ import type { AxonKernelEventMap } from "./events/kernel"
3
+ import type { AxonRuntimeEvent } from "./events/runtime"
4
+ import type { CognetEventMap } from "./events/cognet"
5
+ import type { CapsuleEventMap } from "./events/capsule"
6
+ import type { AxonEntryEvent } from "./events/entries"
7
+
8
+ /**
9
+ * A session is the agent's lifetime record — the persistent working context
10
+ * runtimes attach to. It survives restarts; it is why an agent can be
11
+ * restarted and still know what it was working on.
12
+ *
13
+ * Two responsibilities:
14
+ * - Continuity: the one entry log, capsule attachment, summaries.
15
+ * - Observability: the kernel/runtime telemetry firehose.
16
+ *
17
+ * The entry log holds the interactions (what cognition and clients see);
18
+ * the session's own logs hold everything about how the machine ran, split
19
+ * by audience — kernel is internal tick/phase/system telemetry (devtools,
20
+ * flame graphs, never rendered to the user); session is the small,
21
+ * human-relevant runtime/continuity record (boot, shutdown, errors) shown
22
+ * alongside the entry log. First-class split in the data, not a filter a
23
+ * consumer has to remember to apply.
24
+ */
25
+ export type AxonSession = {
26
+ id: string
27
+ entries: AxonEntry[]
28
+ events: {
29
+ kernel: AxonKernelEvent[]
30
+ session: AxonSessionEvent[]
31
+ }
32
+ }
33
+
34
+ // ── Registry maps ────────────────────────────────────────────────────────────
35
+
36
+ /** Everything that can appear in a session's logs (and on the runtime bus). Telemetry (kernel/cognet/capsule) is durable like everything else; only the capsule byte streams (CAPSULE_TRANSIENT_EVENTS) stay bus-only. */
37
+ export type AxonEventMap = AxonKernelEventMap & AxonRuntimeEvent & CognetEventMap & CapsuleEventMap
38
+
39
+ // ── Enveloped unions (what actually sits in the JSONL) ──────────────────────
40
+
41
+ /** One line in the session's kernel log — internal telemetry, never rendered to the user. */
42
+ export type AxonKernelEvent = AxonEventUnion<AxonKernelEventMap>
43
+
44
+ /** One line in the session's own log — runtime/continuity facts. */
45
+ export type AxonSessionEvent = AxonEventUnion<AxonRuntimeEvent>
46
+
47
+ /** One line in the session's entry log. */
48
+ export type AxonEntry = AxonEventUnion<AxonEntryEvent>
49
+
50
+ /**
51
+ * THE folding rule for the chunking standard (AxonChunk, stdio/shared.ts) —
52
+ * the one implementation every observer applies: group entries by
53
+ * `data.chunk.of`, in order; a group folds into ONE entry (the first
54
+ * chunk's envelope) whose payload is the assembly of its chunks; `final`
55
+ * closes the group. A folded entry keeps its `chunk` field so a reader can
56
+ * see an unclosed group for what it is: a truncated emission
57
+ * (`chunk.final !== true` after folding = interrupted mid-emission).
58
+ *
59
+ * Entries without `chunk` pass through untouched — self-contained complete
60
+ * emissions, the degenerate 1-chunk case. Never mutates its input; folded
61
+ * entries are fresh objects.
62
+ *
63
+ * Assembly is per information kind: text concatenates `content`;
64
+ * ref-carrying kinds (audio/visual) concatenate their symbolic digest
65
+ * (transcript/caption) and let later structural fields (ref, kind,
66
+ * reading) win — the group's final state is its authoritative shape.
67
+ */
68
+ export function foldChunks(entries: readonly AxonEntry[]): AxonEntry[] {
69
+ const out: AxonEntry[] = []
70
+ const open = new Map<string, AxonEntry>()
71
+
72
+ for (const entry of entries) {
73
+ const data = entry.data as { chunk?: { of: string; final?: boolean }; content?: string; transcript?: string; caption?: string }
74
+ if (!data.chunk) {
75
+ out.push(entry)
76
+ continue
77
+ }
78
+
79
+ const existing = open.get(data.chunk.of)
80
+ if (!existing) {
81
+ const folded = { ...entry, data: { ...data } } as AxonEntry
82
+ out.push(folded)
83
+ if (!data.chunk.final) open.set(data.chunk.of, folded)
84
+ continue
85
+ }
86
+
87
+ const target = existing.data as typeof data
88
+ // concatenating fields accumulate; everything else the newest chunk wins
89
+ const content = typeof target.content === "string" && typeof data.content === "string" ? target.content + data.content : undefined
90
+ const transcript = typeof target.transcript === "string" && typeof data.transcript === "string" ? target.transcript + data.transcript : undefined
91
+ const caption = typeof target.caption === "string" && typeof data.caption === "string" ? target.caption + data.caption : undefined
92
+ Object.assign(target, data)
93
+ if (content !== undefined) target.content = content
94
+ if (transcript !== undefined) target.transcript = transcript
95
+ if (caption !== undefined) target.caption = caption
96
+
97
+ if (data.chunk.final) open.delete(data.chunk.of)
98
+ }
99
+
100
+ return out
101
+ }
102
+
103
+ /** A single enveloped kernel-log event of a specific type, e.g. AxonKernelEventOf<"kernel:tick:start">. */
104
+ export type AxonKernelEventOf<K extends keyof AxonKernelEventMap> = AxonEvent<AxonKernelEventMap, K>
105
+ /** A single enveloped session-log event of a specific type, e.g. AxonSessionEventOf<"axon:boot:complete">. */
106
+ export type AxonSessionEventOf<K extends keyof AxonRuntimeEvent> = AxonEvent<AxonRuntimeEvent, K>
107
+ export type AxonEntryOf<K extends keyof AxonEntryEvent> = AxonEvent<AxonEntryEvent, K>
package/src/tools.ts ADDED
@@ -0,0 +1,54 @@
1
+ import type { AxonScopeMember } from "./scope"
2
+
3
+ /** Function exported by a tool namespace and discovered for agent use. */
4
+ export type ToolFnEntry = AxonScopeMember
5
+
6
+ /** Tool namespace discovered from an agent, module, or installed package. */
7
+ export type AxonTool = {
8
+ /** Package name or local `src/tools/` namespace name. */
9
+ name: string
10
+ /** Human-readable namespace summary, usually extracted from package metadata or JSDoc. */
11
+ description?: string
12
+ /** Callable functions available under this namespace. */
13
+ fns: ToolFnEntry[]
14
+ /**
15
+ * "src" — from agent's src/tools/<name>.ts
16
+ * "module" — from modules/<module-name>/src/tools/
17
+ * "workspace" — from the shared workspace tools/ directory
18
+ *
19
+ * There is no "package" origin: an npm dependency is importable by the
20
+ * agent's own source, but the capsule is a separate process and a
21
+ * dependency grants nothing there. Re-export from src/tools/ to make
22
+ * one callable.
23
+ */
24
+ origin: "src" | "module" | "workspace"
25
+ /**
26
+ * When true, each fn is a top-level named export — not grouped under the tool name as a namespace.
27
+ * Helios renders flat tools as `declare const hello: ...` instead of `declare namespace another { hello }`.
28
+ * Set for src/tools/ files where the filename is just a grouping mechanism, not a user-facing namespace.
29
+ */
30
+ flat?: boolean
31
+ /** Absolute path to the module root — present when origin is "module" or a workspace module. */
32
+ modulePath?: string
33
+ /**
34
+ * Absolute entry file for this tool. Capsule imports this module in place
35
+ * so its relative imports and normal package resolution remain intact.
36
+ */
37
+ entryPath?: string
38
+ /**
39
+ * Inline source is a compatibility escape hatch for programmatically
40
+ * constructed blueprints. Project scanning uses entryPath instead: a tool
41
+ * file is a module, not a self-contained source string.
42
+ */
43
+ source?: string
44
+ /**
45
+ * Interface/type-alias declarations this tool's functions reference
46
+ * (e.g. a return type defined in a sibling file), deduped by name, in
47
+ * the order first encountered. Emitted once per tool by both
48
+ * consumers -- renderScope() (the live model context) and the IDE's
49
+ * tool-globals.d.ts — rather than duplicated inline into every
50
+ * fn.declaration that uses them. Empty/absent when a tool's functions
51
+ * only use built-in/primitive types.
52
+ */
53
+ ambientTypes?: string[]
54
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "moduleDetection": "force",
7
+ "strict": true,
8
+ "noUncheckedIndexedAccess": true,
9
+ "lib": ["ESNext"],
10
+ "skipLibCheck": true,
11
+ "allowImportingTsExtensions": true,
12
+ "noEmit": true
13
+ }
14
+ }