@arcforge/platform 2.0.171 → 2.0.173
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/platform",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.173",
|
|
4
4
|
"description": "The Axon developer platform — headless project discovery, blueprint scanning, typegen, agent lifecycle, registry, benches and tests. Shared by the CLI/TUI and the Fleet extension.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -44,20 +44,20 @@
|
|
|
44
44
|
"deploy": "echo \"This package is published ONLY by apps/tui/scripts/release.ts, which pins workspace:* deps to concrete versions first. Publishing it directly ships an unresolvable dependency.\" && exit 1"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@arcforge/session": "2.0.
|
|
48
|
-
"@arcforge/engines": "2.0.
|
|
49
|
-
"@arcforge/err": "2.0.
|
|
50
|
-
"@arcforge/types": "2.0.
|
|
51
|
-
"@arcforge/cloud": "2.0.
|
|
52
|
-
"@arcforge/capsule": "2.0.
|
|
53
|
-
"@arcforge/core": "2.0.
|
|
54
|
-
"@arcforge/vstr": "2.0.
|
|
47
|
+
"@arcforge/session": "2.0.173",
|
|
48
|
+
"@arcforge/engines": "2.0.173",
|
|
49
|
+
"@arcforge/err": "2.0.173",
|
|
50
|
+
"@arcforge/types": "2.0.173",
|
|
51
|
+
"@arcforge/cloud": "2.0.173",
|
|
52
|
+
"@arcforge/capsule": "2.0.173",
|
|
53
|
+
"@arcforge/core": "2.0.173",
|
|
54
|
+
"@arcforge/vstr": "2.0.173",
|
|
55
55
|
"fft.js": "^4.0.4",
|
|
56
56
|
"h3": "^1.15.11",
|
|
57
57
|
"semver": "^7.7.4",
|
|
58
58
|
"sharp": "^0.35.3",
|
|
59
59
|
"typescript": "5.9.2",
|
|
60
|
-
"@arcforge/link": "2.0.
|
|
60
|
+
"@arcforge/link": "2.0.173"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@arcforge/air": "2.0.167",
|
|
@@ -112,15 +112,24 @@ export function Blueprint(opts: BlueprintOpts) {
|
|
|
112
112
|
// Authored truth — a broken config is no agent. Throws.
|
|
113
113
|
const config = await Config(root)
|
|
114
114
|
|
|
115
|
-
// `engine:` is
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
// the
|
|
115
|
+
// `engine:` is READ BY NOTHING, and now REFUSED.
|
|
116
|
+
//
|
|
117
|
+
// It warned for a deprecation window on the reasoning that an
|
|
118
|
+
// agent carrying it already booted on the profile pool, so
|
|
119
|
+
// failing would break working agents over a field that was being
|
|
120
|
+
// ignored anyway. That reasoning had the cost backwards. An agent
|
|
121
|
+
// whose config names a mock engine and silently resolves against
|
|
122
|
+
// the profile pool does not degrade — it runs on a DIFFERENT,
|
|
123
|
+
// billed provider while claiming otherwise, and a warning nobody
|
|
124
|
+
// reads is not a signal. Nine test fixtures declared `engine:
|
|
125
|
+
// Mock()` and spent real credits on every run for exactly as long
|
|
126
|
+
// as this was a warning.
|
|
127
|
+
//
|
|
128
|
+
// Fatal is the honest severity: the config asks for inference
|
|
129
|
+
// this runtime will not provide, and refusing at load is the only
|
|
130
|
+
// point where the author still knows why.
|
|
121
131
|
if ("engine" in config.value && config.value.engine !== undefined) {
|
|
122
|
-
|
|
123
|
-
warnings.push({ domain: "config", error: cause.message, cause })
|
|
132
|
+
throw err("CONFIG_ENGINE_DEPRECATED", { context: { root } })
|
|
124
133
|
}
|
|
125
134
|
|
|
126
135
|
// Before the scan, never after: Cognet.read() below reads exactly
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises"
|
|
2
|
+
import { join } from "node:path"
|
|
3
|
+
import { fsx } from "../../../utils/fs"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Remove the dead `engine:` field from an agent's config, in place.
|
|
7
|
+
*
|
|
8
|
+
* ── Why a migration and not a message ───────────────────────────────────────
|
|
9
|
+
*
|
|
10
|
+
* `engine:` was retired in favour of `providers:` (a source) and `model:` (a
|
|
11
|
+
* preference). For a window it warned and loaded anyway, which turned out to
|
|
12
|
+
* mean agents ran on a DIFFERENT, billed provider than their config named — so
|
|
13
|
+
* it is now fatal at load. That is the right severity and the wrong migration
|
|
14
|
+
* story: every agent already on disk carrying the field stops booting, and the
|
|
15
|
+
* largest population of those is zeno, which most users never created by hand
|
|
16
|
+
* and have no reason to know how to repair.
|
|
17
|
+
*
|
|
18
|
+
* So the field is removed FOR them, mechanically, on the next prepare.
|
|
19
|
+
*
|
|
20
|
+
* ── Why this is safe to do without asking ───────────────────────────────────
|
|
21
|
+
*
|
|
22
|
+
* The field was already being IGNORED. An agent carrying `engine: Codex()` was
|
|
23
|
+
* never running on Codex — it resolved against the profile pool like any agent
|
|
24
|
+
* declaring nothing. Deleting the line therefore changes no behaviour at all;
|
|
25
|
+
* it only makes the file honest about what was already happening. That is what
|
|
26
|
+
* separates this from "updating the user's agent", which this deliberately is
|
|
27
|
+
* not: nothing else in the config is read, moved, or rewritten.
|
|
28
|
+
*
|
|
29
|
+
* ── The one thing that is preserved ─────────────────────────────────────────
|
|
30
|
+
*
|
|
31
|
+
* `engine: Codex({ model: "gpt-5.6-terra" })` named a model. Dropping the line
|
|
32
|
+
* outright would leave the agent with no `model:` at all, and an agent that
|
|
33
|
+
* declares no preference lets the resolver pick from the pool — a different
|
|
34
|
+
* model than the config named. So a model found inside the old call is carried
|
|
35
|
+
* across into `model: "<route>:<model>"`, which is the field that expresses
|
|
36
|
+
* exactly that preference now.
|
|
37
|
+
*
|
|
38
|
+
* That is a behaviour CHANGE in the strict sense — the pin starts being
|
|
39
|
+
* honoured where before it was ignored — and it is the intended one: it makes
|
|
40
|
+
* the agent do what its author wrote, which is what they will expect when they
|
|
41
|
+
* next read the file. An engine call with no model has no preference to carry
|
|
42
|
+
* and simply loses the line.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/** What one config's migration did, for the report. */
|
|
46
|
+
export type EngineMigration = {
|
|
47
|
+
/** False when the config never declared `engine:` — the common case. */
|
|
48
|
+
migrated: boolean
|
|
49
|
+
/** The `route:model` preference carried across, when the old call named one. */
|
|
50
|
+
model?: string
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The `engine: X(...)` declaration, as a span in the source.
|
|
55
|
+
*
|
|
56
|
+
* Located textually rather than by parsing: the file is the author's own
|
|
57
|
+
* TypeScript and everything around this one line has to survive byte-identical.
|
|
58
|
+
* The scan walks parentheses and braces so a nested option object
|
|
59
|
+
* (`engine: Codex({ model: "x", effort: "high" })`) is matched to its true end
|
|
60
|
+
* rather than to the first `)` it meets.
|
|
61
|
+
*/
|
|
62
|
+
type EngineSpan = {
|
|
63
|
+
/** Index of `engine` in the source. */
|
|
64
|
+
start: number
|
|
65
|
+
/** Index just past the declaration, including a trailing comma if present. */
|
|
66
|
+
end: number
|
|
67
|
+
/** The provider factory called — "Axon", "Codex", … */
|
|
68
|
+
factory: string
|
|
69
|
+
/** The `model:` string inside the call, when it named one. */
|
|
70
|
+
model?: string
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function locateEngine(source: string): EngineSpan | null {
|
|
74
|
+
// `engine` as a KEY: at a line start (after whitespace) and followed by a
|
|
75
|
+
// colon. Anchoring this way keeps the word from matching inside a comment
|
|
76
|
+
// or a string that merely mentions it.
|
|
77
|
+
const match = /^[ \t]*engine[ \t]*:[ \t]*/m.exec(source)
|
|
78
|
+
if (!match) return null
|
|
79
|
+
|
|
80
|
+
const start = match.index
|
|
81
|
+
let cursor = match.index + match[0].length
|
|
82
|
+
|
|
83
|
+
// The factory name — `Axon`, `Codex`, `Mock`, …
|
|
84
|
+
const name = /^([A-Za-z_$][\w$]*)/.exec(source.slice(cursor))
|
|
85
|
+
if (!name) return null
|
|
86
|
+
const factory = name[1]!
|
|
87
|
+
cursor += name[0].length
|
|
88
|
+
|
|
89
|
+
// Walk to the matching close paren, tracking nesting and strings so a
|
|
90
|
+
// brace or paren inside an option value cannot end the scan early.
|
|
91
|
+
while (cursor < source.length && source[cursor] !== "(") cursor++
|
|
92
|
+
if (source[cursor] !== "(") return null
|
|
93
|
+
|
|
94
|
+
let depth = 0
|
|
95
|
+
let quote: string | null = null
|
|
96
|
+
let end = -1
|
|
97
|
+
for (let i = cursor; i < source.length; i++) {
|
|
98
|
+
const char = source[i]!
|
|
99
|
+
if (quote) {
|
|
100
|
+
if (char === "\\") i++
|
|
101
|
+
else if (char === quote) quote = null
|
|
102
|
+
continue
|
|
103
|
+
}
|
|
104
|
+
if (char === '"' || char === "'" || char === "`") { quote = char; continue }
|
|
105
|
+
if (char === "(" || char === "{" || char === "[") depth++
|
|
106
|
+
else if (char === ")" || char === "}" || char === "]") {
|
|
107
|
+
depth--
|
|
108
|
+
if (depth === 0) { end = i + 1; break }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (end === -1) return null
|
|
112
|
+
|
|
113
|
+
const call = source.slice(cursor, end)
|
|
114
|
+
const model = /\bmodel[ \t]*:[ \t]*["']([^"']+)["']/.exec(call)?.[1]
|
|
115
|
+
|
|
116
|
+
// Take the trailing comma and the rest of the line with it, so removing a
|
|
117
|
+
// whole declaration does not leave a dangling `,` or a blank line where a
|
|
118
|
+
// field used to be.
|
|
119
|
+
let after = end
|
|
120
|
+
if (source[after] === ",") after++
|
|
121
|
+
while (after < source.length && (source[after] === " " || source[after] === "\t")) after++
|
|
122
|
+
if (source[after] === "\n") after++
|
|
123
|
+
|
|
124
|
+
return { start, end: after, factory, ...(model ? { model } : {}) }
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The route name a provider factory maps to in a `model:` string.
|
|
129
|
+
*
|
|
130
|
+
* `model:` is `"<route>:<id>"` and the route is the provider's own name
|
|
131
|
+
* lowercased — the same string `providers:` uses. Only the factories that
|
|
132
|
+
* could carry a model are listed: `Mock` has no catalogue to pin against, so
|
|
133
|
+
* a mock engine loses its line and nothing else.
|
|
134
|
+
*/
|
|
135
|
+
const ROUTES: Record<string, string> = {
|
|
136
|
+
Axon: "axon",
|
|
137
|
+
Codex: "codex",
|
|
138
|
+
OpenRouter: "openrouter",
|
|
139
|
+
Ollama: "ollama",
|
|
140
|
+
HuggingFace: "huggingface",
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Migrate one agent config, if it declares `engine:`.
|
|
145
|
+
*
|
|
146
|
+
* Idempotent and cheap: a config without the field is read once and left
|
|
147
|
+
* alone, which is every config written after the field was retired.
|
|
148
|
+
*/
|
|
149
|
+
export async function migrateEngineField(root: string): Promise<EngineMigration> {
|
|
150
|
+
const path = join(root, "axon.config.ts")
|
|
151
|
+
if (!fsx.exists(path)) return { migrated: false }
|
|
152
|
+
|
|
153
|
+
const source = await readFile(path, "utf-8").catch(() => "")
|
|
154
|
+
const span = locateEngine(source)
|
|
155
|
+
if (!span) return { migrated: false }
|
|
156
|
+
|
|
157
|
+
const route = ROUTES[span.factory]
|
|
158
|
+
const model = span.model && route ? `${route}:${span.model}` : undefined
|
|
159
|
+
|
|
160
|
+
// The preference takes the removed declaration's place, so the field lands
|
|
161
|
+
// where its author already had it rather than at the end of the object.
|
|
162
|
+
// Its indentation is the line's own — copied, never assumed.
|
|
163
|
+
const indent = /^[ \t]*/.exec(source.slice(span.start))?.[0] ?? " "
|
|
164
|
+
const replacement = model ? `${indent}model: "${model}",\n` : ""
|
|
165
|
+
|
|
166
|
+
// A config that already declares `model:` keeps it: the author wrote that
|
|
167
|
+
// one deliberately and it is the field the runtime actually reads, so it
|
|
168
|
+
// outranks anything recovered from the dead call.
|
|
169
|
+
const declaresModel = /^[ \t]*model[ \t]*:/m.test(
|
|
170
|
+
source.slice(0, span.start) + source.slice(span.end),
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
const next = source.slice(0, span.start)
|
|
174
|
+
+ (declaresModel ? "" : replacement)
|
|
175
|
+
+ source.slice(span.end)
|
|
176
|
+
|
|
177
|
+
await writeFile(path, next, "utf-8")
|
|
178
|
+
return { migrated: true, ...(model && !declaresModel ? { model } : {}) }
|
|
179
|
+
}
|
|
@@ -16,6 +16,7 @@ import type { LinkResult, SourceModulesT } from "./modules"
|
|
|
16
16
|
import type { TypegenResult, TypegenT } from "./typegen"
|
|
17
17
|
import { fsx } from "../../utils/fs"
|
|
18
18
|
import { migrateFrame } from "../frame"
|
|
19
|
+
import { migrateEngineField } from "./manifest/engine-migrate"
|
|
19
20
|
import { KINDS, type ProjectKind } from "./kinds"
|
|
20
21
|
|
|
21
22
|
export type PrepareResult = {
|
|
@@ -276,6 +277,26 @@ export function Prepare(opts: PrepareOpts) {
|
|
|
276
277
|
})
|
|
277
278
|
}
|
|
278
279
|
|
|
280
|
+
// Beside the frame migration and for the same reason: an agent already
|
|
281
|
+
// on disk carries a field the runtime now REFUSES, and the user did not
|
|
282
|
+
// put it there — zeno ships to everyone and most people never wrote its
|
|
283
|
+
// config. Removing it here means the repair happens on the next launch
|
|
284
|
+
// with nobody typing anything.
|
|
285
|
+
//
|
|
286
|
+
// Ahead of every read of the config below, which is the whole ordering
|
|
287
|
+
// requirement: `engine:` is fatal at load, so a migration running after
|
|
288
|
+
// the load would never get the chance.
|
|
289
|
+
if (kind === "agent") {
|
|
290
|
+
const engine = await migrateEngineField(root)
|
|
291
|
+
if (engine.migrated) {
|
|
292
|
+
report?.("build:config:migrated", {
|
|
293
|
+
root: root,
|
|
294
|
+
field: "engine",
|
|
295
|
+
...(engine.model ? { model: engine.model } : {}),
|
|
296
|
+
})
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
279
300
|
// A prompt package is text: it declares no dependencies, so there is
|
|
280
301
|
// nothing to install and its frame is self-contained. It still gets
|
|
281
302
|
// one — definePrompt() is a global, and prompt.config.ts calls it.
|
|
@@ -3,17 +3,13 @@ import type { AxonRequestInput, AxonResult } from "@arcforge/types"
|
|
|
3
3
|
import type { InstancesT } from "./instances"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* The
|
|
6
|
+
* The in-process door for agent-initiated spawning.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* agent's fan-out, descendants caps the whole tree beneath one root.
|
|
8
|
+
* The LIMITS on it (depth, fan-out, descendants) are enforced by the daemon —
|
|
9
|
+
* see its `checkSubagentLimits`. They lived here while this was the only route
|
|
10
|
+
* an agent could spawn through; it no longer is, and a rule implemented per
|
|
11
|
+
* route is a rule that eventually differs by route.
|
|
13
12
|
*/
|
|
14
|
-
const MAX_DEPTH = 4
|
|
15
|
-
const MAX_LIVE_CHILDREN = 4
|
|
16
|
-
const MAX_LIVE_DESCENDANTS = 12
|
|
17
13
|
|
|
18
14
|
type RequestsOpts = {
|
|
19
15
|
instances: InstancesT
|
|
@@ -51,29 +47,23 @@ export function Requests(opts: RequestsOpts) {
|
|
|
51
47
|
return { prompt: prompt }
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the parent. The LIMITS are the daemon's.
|
|
52
|
+
*
|
|
53
|
+
* Depth, fan-out and descendant caps used to be enforced here, and this
|
|
54
|
+
* was described as "the ONLY caller-initiated spawn path with limits
|
|
55
|
+
* attached". That stopped being true: an agent shelling out to
|
|
56
|
+
* `axon <ref> --parent <id>` spawns through the daemon and never touches
|
|
57
|
+
* this function, so the limits guarded one of two routes.
|
|
58
|
+
*
|
|
59
|
+
* They live in the daemon now — the one place every spawn passes through,
|
|
60
|
+
* and the only one that sees the whole ownership graph. Two
|
|
61
|
+
* implementations of one rule is how they come to disagree about what a
|
|
62
|
+
* limit means, which is worse than either answer.
|
|
63
|
+
*/
|
|
55
64
|
function checkLimits(parentSessionId: string) {
|
|
56
65
|
const parent = instances.get(parentSessionId)
|
|
57
66
|
if (!parent) throw err("PARENT_INSTANCE_NOT_RUNNING", { context: { sessionId: parentSessionId } })
|
|
58
|
-
|
|
59
|
-
if (parent.depth >= MAX_DEPTH) {
|
|
60
|
-
throw err("SUBAGENT_DEPTH_EXCEEDED", {
|
|
61
|
-
detail: `maximum depth is ${MAX_DEPTH}`,
|
|
62
|
-
context: { sessionId: parent.sessionId, depth: parent.depth, limit: MAX_DEPTH },
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
if (instances.children(parent.sessionId).length >= MAX_LIVE_CHILDREN) {
|
|
66
|
-
throw err("SUBAGENT_CHILD_LIMIT_EXCEEDED", {
|
|
67
|
-
detail: `maximum live children is ${MAX_LIVE_CHILDREN}`,
|
|
68
|
-
context: { sessionId: parent.sessionId, limit: MAX_LIVE_CHILDREN },
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
if (instances.descendants(parent.rootSessionId).length >= MAX_LIVE_DESCENDANTS) {
|
|
72
|
-
throw err("SUBAGENT_DESCENDANT_LIMIT_EXCEEDED", {
|
|
73
|
-
detail: `maximum live descendants is ${MAX_LIVE_DESCENDANTS}`,
|
|
74
|
-
context: { rootSessionId: parent.rootSessionId, limit: MAX_LIVE_DESCENDANTS },
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
67
|
return parent
|
|
78
68
|
}
|
|
79
69
|
|
package/src/link/agent-main.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { err } from "@arcforge/err"
|
|
|
24
24
|
import { readFileSync } from "node:fs"
|
|
25
25
|
import { Axon, AxonBus } from "@arcforge/core"
|
|
26
26
|
import { Routes, Middleware, Plugins } from "../build/blueprint"
|
|
27
|
-
import type { AxonMiddleware, AxonPartialBlueprint, AxonPlugin, AxonRoute } from "@arcforge/types"
|
|
27
|
+
import type { AxonCommitContext, AxonMiddleware, AxonPartialBlueprint, AxonPlugin, AxonRoute } from "@arcforge/types"
|
|
28
28
|
import {
|
|
29
29
|
AGENT_BLUEPRINT_ENV,
|
|
30
30
|
AgentRuntime,
|
|
@@ -170,8 +170,8 @@ export async function main(): Promise<void> {
|
|
|
170
170
|
* which is why the TUI's header came up blank: the facts it renders had
|
|
171
171
|
* already gone past.
|
|
172
172
|
*/
|
|
173
|
-
const pending: Array<{ type: string; data: unknown }> = []
|
|
174
|
-
let forward = (type: string, data: unknown) => { pending.push({ type, data }) }
|
|
173
|
+
const pending: Array<{ type: string; data: unknown; ctx?: AxonCommitContext }> = []
|
|
174
|
+
let forward = (type: string, data: unknown, ctx?: AxonCommitContext) => { pending.push({ type, data, ctx }) }
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
177
|
* The bus, built HERE and handed to Axon() — so this can subscribe
|
|
@@ -240,6 +240,24 @@ export async function main(): Promise<void> {
|
|
|
240
240
|
* shape is known: the supervisor receives (type, data) and cannot tell an
|
|
241
241
|
* envelope from a payload that happens to have a `data` field of its own.
|
|
242
242
|
*/
|
|
243
|
+
/**
|
|
244
|
+
* The correlation half of an envelope's context, for the wire.
|
|
245
|
+
*
|
|
246
|
+
* `agentId` and `sessionId` are the SUPERVISOR's to stamp — it owns the
|
|
247
|
+
* session and knows both — so sending them back would be the child
|
|
248
|
+
* asserting its own identity to the thing that assigned it. Only the ids
|
|
249
|
+
* the child actually mints travel: runId and spanId.
|
|
250
|
+
*
|
|
251
|
+
* Returns undefined when neither is present, so an event with no
|
|
252
|
+
* correlation commits with no context rather than an empty object.
|
|
253
|
+
*/
|
|
254
|
+
function contextOf(context: AxonCommitContext | undefined): AxonCommitContext | undefined {
|
|
255
|
+
if (!context) return undefined
|
|
256
|
+
const { runId, spanId } = context
|
|
257
|
+
if (!runId && !spanId) return undefined
|
|
258
|
+
return { ...(runId ? { runId } : {}), ...(spanId ? { spanId } : {}) }
|
|
259
|
+
}
|
|
260
|
+
|
|
243
261
|
function announce(type: string, payload: unknown): void {
|
|
244
262
|
/**
|
|
245
263
|
* Two shapes travel this bus, and the difference is not cosmetic.
|
|
@@ -261,9 +279,21 @@ export async function main(): Promise<void> {
|
|
|
261
279
|
* payload with its own `data` field is a shape nobody should have to
|
|
262
280
|
* reason about at this seam.
|
|
263
281
|
*/
|
|
264
|
-
const carrier = payload as {
|
|
282
|
+
const carrier = payload as {
|
|
283
|
+
time?: unknown
|
|
284
|
+
data?: unknown
|
|
285
|
+
type?: unknown
|
|
286
|
+
context?: AxonCommitContext
|
|
287
|
+
} | undefined
|
|
265
288
|
if (carrier && typeof carrier === "object" && "time" in carrier) {
|
|
266
|
-
|
|
289
|
+
// The context travels WITH the payload, as its own argument.
|
|
290
|
+
// Unwrapping the envelope and dropping `context` is what silently
|
|
291
|
+
// un-correlated every span once agents moved into subprocesses:
|
|
292
|
+
// the kernel mints one spanId per engine call, start/input/
|
|
293
|
+
// complete share it, and nothing else joins them. The supervisor
|
|
294
|
+
// re-envelopes on the far side, so this is the only place the ids
|
|
295
|
+
// can be handed over.
|
|
296
|
+
forward(type, carrier.data, contextOf(carrier.context))
|
|
267
297
|
return
|
|
268
298
|
}
|
|
269
299
|
// A raw event: strip the name it already travels under, keep the rest.
|
|
@@ -276,8 +306,8 @@ export async function main(): Promise<void> {
|
|
|
276
306
|
}
|
|
277
307
|
|
|
278
308
|
// Live from here — and everything boot produced goes first, in order.
|
|
279
|
-
forward = (type, data) => { supervisor.commit(type as never, data as never) }
|
|
280
|
-
for (const event of pending.splice(0)) forward(event.type, event.data)
|
|
309
|
+
forward = (type, data, ctx) => { supervisor.commit(type as never, data as never, ctx) }
|
|
310
|
+
for (const event of pending.splice(0)) forward(event.type, event.data, event.ctx)
|
|
281
311
|
|
|
282
312
|
/**
|
|
283
313
|
* The agent's last words.
|