@arcforge/types 2.0.119 → 2.0.121

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.119",
3
+ "version": "2.0.121",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./src/index.ts",
package/src/engine.ts CHANGED
@@ -57,6 +57,19 @@ export type AxonEngineDef = {
57
57
  * resolves server-side, per call; a client showing it should say so.
58
58
  */
59
59
  model?: string
60
+ /**
61
+ * Auto-selection weighting, when the constructor was given it. Only
62
+ * meaningful alongside model: "auto".
63
+ *
64
+ * On the DEF rather than only inside the driver's closure because with
65
+ * "auto" these are what decides the real model, so a client asking
66
+ * "what am I running on" (cloud.engine.resolve) must be able to read
67
+ * them — resolving without them answers for the default, not for this
68
+ * agent.
69
+ */
70
+ optimize?: EngineAutoWeights
71
+ /** Hard ceilings applied before scoring. Only meaningful alongside model: "auto". */
72
+ limit?: EngineAutoLimits
60
73
  create(res: EngineResources): AxonEngineDriver
61
74
  }
62
75
 
package/src/error.ts CHANGED
@@ -76,6 +76,19 @@ export interface AxonError extends Error {
76
76
  description: string
77
77
  source: AxonErrorSource
78
78
  severity: AxonErrorSeverity
79
+ /**
80
+ * The USER caused this and can fix it from the message alone — a wrong
81
+ * directory, a missing argument, a name that does not exist.
82
+ *
83
+ * Renderers show these without frames or a cause chain: our call stack is
84
+ * not part of the answer, and printing it tells the user to debug software
85
+ * they did not write. Absent means unexpected (the safe default), which
86
+ * still gets the full diagnostic.
87
+ *
88
+ * A different axis from `severity`: PROJECT_NOT_FOUND is both `fatal` (the
89
+ * command cannot continue) and expected.
90
+ */
91
+ expected?: boolean
79
92
  context: AxonErrorContext | undefined
80
93
  frames: AxonStackFrame[]
81
94
  /** native Error.cause — walk this to render the full chain */
@@ -54,16 +54,41 @@ export type AxonEventContext = {
54
54
  * `K` narrows to one event type.
55
55
  */
56
56
  export type AxonEvent<M, K extends keyof M = keyof M, C extends object = AxonEventContext> = {
57
- /** UUIDv7 — globally unique and time-sortable. Idempotent ingest. */
58
- id: string
59
57
  type: K
60
58
  time: {
61
59
  /** Wall clock ms since epoch. */
62
60
  ms: number
63
- /** Monotonic per-session counter — authoritative ordering, immune to clock skew. */
61
+ /**
62
+ * Monotonic per-session counter — authoritative ordering, immune to
63
+ * clock skew, and the event's IDENTITY.
64
+ *
65
+ * There used to be a UUIDv7 `id` alongside this. It was removed:
66
+ * measured on a real 1M-event session it cost 8.8MB (14% of the
67
+ * file) to express something `seq` already expressed better —
68
+ * verified unique and monotonic across 300k consecutive events, and
69
+ * never read back by the runtime. A session log is a sequence, and
70
+ * a sequence numbers its members.
71
+ *
72
+ * Unique within one session. A consumer needing global uniqueness
73
+ * (cloud ingest) pairs it with the session id from the header.
74
+ */
64
75
  seq: number
65
76
  }
66
- context: C
77
+ /**
78
+ * Correlation ids for this event.
79
+ *
80
+ * Optional ONLY for the session envelope, whose context is
81
+ * `AxonEventContext` — there, most events have no correlation at all,
82
+ * and an empty object on every line is exactly the kind of constant
83
+ * this format exists to stop writing. What is true of the WHOLE FILE
84
+ * (agent, session) lives in the header line instead; only
85
+ * `runId`/`spanId`, which genuinely vary per event, are carried here.
86
+ *
87
+ * A stream that supplies its own context type — bench, test — keeps it
88
+ * required, because for those it identifies WHICH run or case the event
89
+ * belongs to and an event without it would be unattributable.
90
+ */
91
+ context: AxonEventContext extends C ? C | undefined : C
67
92
  /** Typed payload — the registry map is the single source of payload truth. */
68
93
  data: M[K]
69
94
  }
@@ -40,6 +40,15 @@ import type { CapsuleScope } from "../../capsule-scope"
40
40
  * behavior is lost, which is exactly what the JSON shape describes.
41
41
  */
42
42
 
43
+ /**
44
+ * Who asked for a capsule command to run — see the capsule:cmd span below.
45
+ *
46
+ * Declared here rather than in @axon/capsule for the same reason the event
47
+ * map is: every type that can reach a session log lives in this package's
48
+ * registry, and @axon/capsule re-exports from here rather than owning it.
49
+ */
50
+ export type CapsuleCommandOrigin = "cognet" | "host"
51
+
43
52
  export type CapsuleEventMap =
44
53
  // ── Lifecycle ────────────────────────────────────────────────────────────
45
54
  & AxonSpan<"capsule:boot", {}, {}, { error: AxonErrorJSON }>
@@ -69,9 +78,16 @@ export type CapsuleEventMap =
69
78
  { restartCount: number; error: AxonErrorJSON }
70
79
  >
71
80
  // ── Command execution (one run() = one command id) ──────────────────────
81
+ // `origin` is provenance, never privilege: a "host" command (a
82
+ // developer typing into Fleet's capsule input) travels the identical
83
+ // path under the identical policy gate as the cognet's own code. It
84
+ // is recorded because this log is a record of what the AGENT did,
85
+ // and an unmarked human command would make that record lie.
86
+ // Absent means "cognet" — every command predating this field, and
87
+ // every command the runtime itself issues.
72
88
  & AxonCancellableSpan<
73
89
  "capsule:cmd",
74
- { id: string },
90
+ { id: string; origin?: CapsuleCommandOrigin },
75
91
  { id: string; result: unknown; scope: CapsuleScope },
76
92
  { id: string; error: AxonErrorJSON },
77
93
  { id: string; durationMs: number }
@@ -6,7 +6,7 @@ export type {
6
6
  } from "./envelope"
7
7
  export type { AxonKernelEventMap } from "./events/kernel"
8
8
  export type { CognetEventMap } from "./events/cognet"
9
- export type { CapsuleEventMap, CapsuleEventName, AnyCapsuleEvent } from "./events/capsule"
9
+ export type { CapsuleEventMap, CapsuleEventName, AnyCapsuleEvent, CapsuleCommandOrigin } from "./events/capsule"
10
10
  export type { BuildEventMap, BuildEventName, AnyBuildEvent, BuildStage } from "./events/build"
11
11
  export { isBuildEvent } from "./events/build"
12
12
  export type { Activity, ActivityHandle, ActivityPayloads, ActivityPhase, ActivityType, AxonAmbient } from "./events/activity"
@@ -20,7 +20,8 @@ import { isSpanEnd, isSpanStart, spanStem } from "./events/span"
20
20
  export type ReadableEvent = {
21
21
  type: string
22
22
  time: { seq: number; ms: number }
23
- context: { runId?: string }
23
+ /** Optional: most events carry no correlation at all — see AxonEvent. */
24
+ context?: { runId?: string }
24
25
  data: Record<string, unknown>
25
26
  }
26
27
 
@@ -67,7 +68,7 @@ function bracketKey(event: ReadableEvent): string {
67
68
  const value = d[field]
68
69
  if (typeof value === "string" || typeof value === "number") parts.push(`${field}:${value}`)
69
70
  }
70
- const spanId = (event.context as { spanId?: string }).spanId
71
+ const spanId = (event.context as { spanId?: string } | undefined)?.spanId
71
72
  if (spanId) parts.push(`span:${spanId}`)
72
73
  return parts.join("|")
73
74
  }