@arcforge/platform 2.0.187 → 2.0.188
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 +12 -12
- package/src/bin/test-preload.ts +5 -1
- package/src/build/bench/runner.ts +6 -2
- package/src/build/bench/schema/schema.ts +6 -2
- package/src/build/blueprint/scan/declare-worker.ts +18 -0
- package/src/build/blueprint/scan/tools.ts +1 -1
- package/src/services/cloud.ts +26 -0
- package/src/services/registry.ts +53 -7
- package/src/services/resources/reservations.ts +6 -2
- package/src/services/store/store.ts +28 -0
- package/src/services/test/child.ts +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcforge/platform",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.188",
|
|
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,24 +44,24 @@
|
|
|
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.188",
|
|
48
|
+
"@arcforge/engines": "2.0.188",
|
|
49
|
+
"@arcforge/err": "2.0.188",
|
|
50
|
+
"@arcforge/types": "2.0.188",
|
|
51
|
+
"@arcforge/cloud": "2.0.188",
|
|
52
|
+
"@arcforge/capsule": "2.0.188",
|
|
53
|
+
"@arcforge/core": "2.0.188",
|
|
54
|
+
"@arcforge/vstr": "2.0.188",
|
|
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.188"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@arcforge/air": "2.0.
|
|
64
|
-
"@arcforge/cognet": "2.0.
|
|
63
|
+
"@arcforge/air": "2.0.187",
|
|
64
|
+
"@arcforge/cognet": "2.0.187",
|
|
65
65
|
"@arclabs/repo": "1.0.0",
|
|
66
66
|
"@types/bun": "latest",
|
|
67
67
|
"@types/semver": "^7.7.1"
|
package/src/bin/test-preload.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks"
|
|
2
|
+
import { existsSync } from "node:fs"
|
|
2
3
|
import { resolve } from "node:path"
|
|
3
4
|
import { pathToFileURL } from "node:url"
|
|
4
5
|
import {
|
|
@@ -282,7 +283,10 @@ Object.assign(globalThis, instrumented)
|
|
|
282
283
|
// globalThis alone does not replace them. Transform only the explicitly
|
|
283
284
|
// selected test file in memory — user source is never rewritten on disk.
|
|
284
285
|
const target = resolve(process.cwd(), file)
|
|
285
|
-
const
|
|
286
|
+
const packagedApi = resolve(import.meta.dir, "test-api.js")
|
|
287
|
+
const apiUrl = pathToFileURL(existsSync(packagedApi)
|
|
288
|
+
? packagedApi
|
|
289
|
+
: resolve(import.meta.dir, "test-api.ts")).href
|
|
286
290
|
const injected = `import { describe, test, it, xdescribe, xtest, xit, beforeAll, beforeEach, afterEach, afterAll } from ${JSON.stringify(apiUrl)};\n`
|
|
287
291
|
const targetFilter = new RegExp(`^${target.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`)
|
|
288
292
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { join } from "node:path"
|
|
1
|
+
import { join, resolve } from "node:path"
|
|
2
|
+
import { existsSync } from "node:fs"
|
|
2
3
|
import type {
|
|
3
4
|
AxonTestEvent,
|
|
4
5
|
BenchAxis,
|
|
@@ -130,7 +131,10 @@ export function Runner(opts: RunnerOpts) {
|
|
|
130
131
|
const requiredIds = new Set(config.measurements.filter(item => item.required).map(item => item.id))
|
|
131
132
|
const measured = new Set<string>()
|
|
132
133
|
const measurementStates: BenchMeasurementState[] = []
|
|
133
|
-
const
|
|
134
|
+
const packagedPreload = resolve(import.meta.dir, "bench-preload.js")
|
|
135
|
+
const preload = existsSync(packagedPreload)
|
|
136
|
+
? packagedPreload
|
|
137
|
+
: resolve(import.meta.dir, "preload.ts")
|
|
134
138
|
|
|
135
139
|
try {
|
|
136
140
|
for (let cellIndex = 0; cellIndex < coordinates.length && !budgetExhausted; cellIndex++) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto"
|
|
2
|
+
import { existsSync } from "node:fs"
|
|
2
3
|
import { mkdir } from "node:fs/promises"
|
|
3
|
-
import { join } from "node:path"
|
|
4
|
+
import { join, resolve } from "node:path"
|
|
4
5
|
import { err } from "@arcforge/err"
|
|
5
6
|
import type { BenchMeasurementDefinition } from "@arcforge/types"
|
|
6
7
|
import { Frame } from "../../frame"
|
|
@@ -36,7 +37,10 @@ export function BenchSchema(opts: { root: string }) {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
async function extract(): Promise<BenchMeasurementDefinition[]> {
|
|
39
|
-
const
|
|
40
|
+
const packaged = resolve(import.meta.dir, "bench-schema-worker.js")
|
|
41
|
+
const worker = existsSync(packaged)
|
|
42
|
+
? packaged
|
|
43
|
+
: resolve(import.meta.dir, "worker.ts")
|
|
40
44
|
const proc = Bun.spawn(["bun", "run", worker, configPath], { stdout: "pipe", stderr: "pipe" })
|
|
41
45
|
const [stdout, stderr, code] = await Promise.all([
|
|
42
46
|
new Response(proc.stdout).text(),
|
|
@@ -43,11 +43,29 @@ function declare(raw: string): string {
|
|
|
43
43
|
* spawned it.
|
|
44
44
|
*/
|
|
45
45
|
if (process.argv[2] === "--serve") {
|
|
46
|
+
// Piped stdin normally closes with the parent, but Bun can keep the pipe
|
|
47
|
+
// alive while its process is exiting. Independently watch the spawning
|
|
48
|
+
// pid so a compiler worker cannot be reparented and survive the CLI.
|
|
49
|
+
const parentPid = Number(process.argv[3])
|
|
50
|
+
const initialPpid = process.ppid
|
|
51
|
+
const parentWatch = Number.isInteger(parentPid) && parentPid > 0
|
|
52
|
+
? setInterval(() => {
|
|
53
|
+
// Reparenting is observable immediately, even while the old
|
|
54
|
+
// parent is briefly still a zombie for kill(pid, 0). Checking
|
|
55
|
+
// both closes that race and keeps the worker below the test's
|
|
56
|
+
// bounded reap window.
|
|
57
|
+
if (process.ppid !== initialPpid || process.ppid === 1) process.exit(0)
|
|
58
|
+
try { process.kill(parentPid, 0) }
|
|
59
|
+
catch { process.exit(0) }
|
|
60
|
+
}, 50)
|
|
61
|
+
: undefined
|
|
62
|
+
|
|
46
63
|
for await (const line of console) {
|
|
47
64
|
const request = line.trim()
|
|
48
65
|
if (!request) continue
|
|
49
66
|
console.log(declare(request))
|
|
50
67
|
}
|
|
68
|
+
if (parentWatch) clearInterval(parentWatch)
|
|
51
69
|
process.exit(0)
|
|
52
70
|
}
|
|
53
71
|
|
|
@@ -121,7 +121,7 @@ function DeclareServer() {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
function spawn(): void {
|
|
124
|
-
proc = Bun.spawn(["bun", "run", DECLARE_WORKER_PATH, "--serve"], {
|
|
124
|
+
proc = Bun.spawn(["bun", "run", DECLARE_WORKER_PATH, "--serve", String(process.pid)], {
|
|
125
125
|
stdin: "pipe",
|
|
126
126
|
stdout: "pipe",
|
|
127
127
|
stderr: "pipe",
|
package/src/services/cloud.ts
CHANGED
|
@@ -319,6 +319,32 @@ export function Cloud(opts: CloudOpts) {
|
|
|
319
319
|
...(input.signal !== undefined ? { signal: input.signal } : {}),
|
|
320
320
|
})
|
|
321
321
|
persist(session)
|
|
322
|
+
|
|
323
|
+
/*
|
|
324
|
+
* Claim the install that produced this signup.
|
|
325
|
+
*
|
|
326
|
+
* The install script wrote an anonymous machine id long before any
|
|
327
|
+
* of this code existed on the machine, and reports install
|
|
328
|
+
* successes and failures against it. Nothing else connects that id
|
|
329
|
+
* to an account, so without this the backend holds two counters it
|
|
330
|
+
* cannot relate — and "how many installs become accounts" is the
|
|
331
|
+
* question install telemetry mainly exists to answer.
|
|
332
|
+
*
|
|
333
|
+
* Here rather than in AxonCloud because it needs BOTH halves: the
|
|
334
|
+
* id comes off disk (Store owns ~/.axon) and the claim goes over
|
|
335
|
+
* the wire (client owns the session). This wrapper is the only
|
|
336
|
+
* layer holding both, which is exactly what it is for.
|
|
337
|
+
*
|
|
338
|
+
* Awaited, but structurally incapable of failing a login: `attribute`
|
|
339
|
+
* swallows its own errors and the backend's write does too. It is
|
|
340
|
+
* awaited rather than fired-and-forgotten so a CLI process that
|
|
341
|
+
* exits immediately after login does not kill the request in
|
|
342
|
+
* flight — the same mistake that lost every failure event in the
|
|
343
|
+
* install script's first telemetry pass.
|
|
344
|
+
*/
|
|
345
|
+
const installId = store.installId()
|
|
346
|
+
if (installId) await client.user.installs.attribute(installId)
|
|
347
|
+
|
|
322
348
|
return session.user
|
|
323
349
|
},
|
|
324
350
|
|
package/src/services/registry.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { existsSync } from "node:fs"
|
|
|
4
4
|
import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises"
|
|
5
5
|
import { basename, join, resolve } from "node:path"
|
|
6
6
|
import type { AxonCloudClient } from "@arcforge/cloud"
|
|
7
|
-
import { err } from "@arcforge/err"
|
|
7
|
+
import { err, type AxonError } from "@arcforge/err"
|
|
8
8
|
import { parseSpecifier } from "../build/project/specifier"
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -89,20 +89,66 @@ export function PromptCache(opts: { cloud: AxonCloudClient; root: string }) {
|
|
|
89
89
|
|
|
90
90
|
export type PromptCacheT = ReturnType<typeof PromptCache>
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* `reportPrepareFailure` is opt-in, never the default — see runPrepare().
|
|
94
|
+
* Only a caller that asked for FILES (the `axon clone` / `axon fork` commands)
|
|
95
|
+
* wants a half-installed tree back instead of a throw.
|
|
96
|
+
*/
|
|
97
|
+
export type CloneOptions = { dir?: string; reportPrepareFailure?: boolean }
|
|
98
|
+
|
|
92
99
|
export function Registry(opts: { cloud: AxonCloudClient; prepare(root: string): Promise<void> }) {
|
|
93
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Install what was downloaded. Throws by DEFAULT; reports only on request.
|
|
102
|
+
*
|
|
103
|
+
* `clone` and `fork` each do two things — fetch an artifact, then install
|
|
104
|
+
* its dependencies — and who is asking decides whether the second failing
|
|
105
|
+
* should destroy the first.
|
|
106
|
+
*
|
|
107
|
+
* `axon clone` asks for FILES ("copy a published artifact into a
|
|
108
|
+
* directory"). Its prepare step can fail for reasons belonging to the
|
|
109
|
+
* artifact's AUTHOR rather than to the person cloning: an agent pinning a
|
|
110
|
+
* cognet built for another kernel ABI aborted the clone outright
|
|
111
|
+
* (COGNET_ABI_MISMATCH, seen in production). The tarball had already been
|
|
112
|
+
* extracted, so the user got a tree on disk, no node_modules, and a fatal
|
|
113
|
+
* error naming a version pin they never chose. The prepare-time ABI gate
|
|
114
|
+
* catches a bad pairing at the moment it is CHOSEN — true of `axon
|
|
115
|
+
* prepare` on your own agent, false of cloning someone else's.
|
|
116
|
+
*
|
|
117
|
+
* Every OTHER caller — zeno's first-run scaffold, an extension install, a
|
|
118
|
+
* bench fixture — asked for a working project and never sees the
|
|
119
|
+
* directory. For them a returned error is a silent failure by another
|
|
120
|
+
* name: zeno would be installed broken, and the extension loader would
|
|
121
|
+
* record a version for something that cannot load. So the throw is the
|
|
122
|
+
* default and tolerance is opt-in, which also means no existing caller
|
|
123
|
+
* changes behaviour.
|
|
124
|
+
*
|
|
125
|
+
* Nothing unsafe is admitted either way: core/src/cognet refuses a bad ABI
|
|
126
|
+
* pairing at agent boot, so a cloned-but-unprepared project cannot quietly
|
|
127
|
+
* run against the wrong kernel.
|
|
128
|
+
*/
|
|
129
|
+
async function runPrepare(target: string, report: boolean): Promise<AxonError | null> {
|
|
130
|
+
try {
|
|
131
|
+
await opts.prepare(target)
|
|
132
|
+
return null
|
|
133
|
+
} catch (cause) {
|
|
134
|
+
if (!report) throw cause
|
|
135
|
+
return err(cause)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function clone(ref: string, cwd: string, options: CloneOptions = {}) {
|
|
94
140
|
if (!ref) throw err("CLONE_REF_REQUIRED")
|
|
95
141
|
|
|
96
142
|
const { name, version: requestedVersion } = parseSpecifier(ref)
|
|
97
143
|
const resolved = await opts.cloud.registry.resolve(name, requestedVersion)
|
|
98
144
|
const target = resolve(cwd, options.dir ?? directoryName(resolved.name))
|
|
99
145
|
await extract(await download(resolved.downloadUrl), target)
|
|
100
|
-
await
|
|
146
|
+
const prepareError = await runPrepare(target, options.reportPrepareFailure === true)
|
|
101
147
|
|
|
102
|
-
return { ...resolved, root: target }
|
|
148
|
+
return { ...resolved, root: target, prepareError }
|
|
103
149
|
}
|
|
104
150
|
|
|
105
|
-
async function fork(ref: string, cwd: string, options: { as?: string
|
|
151
|
+
async function fork(ref: string, cwd: string, options: CloneOptions & { as?: string } = {}) {
|
|
106
152
|
if (!options.as) throw err("FORK_NAME_REQUIRED")
|
|
107
153
|
|
|
108
154
|
if (!ref) throw err("FORK_REF_REQUIRED")
|
|
@@ -125,9 +171,9 @@ export function Registry(opts: { cloud: AxonCloudClient; prepare(root: string):
|
|
|
125
171
|
forkedFrom: { name: cloneResult.name, version: cloneResult.version },
|
|
126
172
|
}
|
|
127
173
|
await writeFile(packagePath, JSON.stringify(raw, null, 2) + "\n")
|
|
128
|
-
await
|
|
174
|
+
const prepareError = await runPrepare(target, options.reportPrepareFailure === true)
|
|
129
175
|
|
|
130
|
-
return { ...cloneResult, name: options.as, version: "0.1.0" }
|
|
176
|
+
return { ...cloneResult, name: options.as, version: "0.1.0", prepareError }
|
|
131
177
|
}
|
|
132
178
|
|
|
133
179
|
return { clone, fork }
|
|
@@ -76,6 +76,10 @@ export type ReservationsOpts = {
|
|
|
76
76
|
|
|
77
77
|
export function Reservations(opts: ReservationsOpts = {}) {
|
|
78
78
|
const writeRoot = opts.root ?? ROOTS[1]!
|
|
79
|
+
// An injected root is an isolation boundary, not merely an alternate
|
|
80
|
+
// write destination. Tests and embedded callers supply one specifically
|
|
81
|
+
// so they do not observe or reap the machine's real reservations.
|
|
82
|
+
const readRoots = opts.root ? [writeRoot] : ROOTS
|
|
79
83
|
|
|
80
84
|
function ensure(): string {
|
|
81
85
|
mkdirSync(writeRoot, { recursive: true })
|
|
@@ -94,7 +98,7 @@ export function Reservations(opts: ReservationsOpts = {}) {
|
|
|
94
98
|
function live(): Reservation[] {
|
|
95
99
|
const found: Reservation[] = []
|
|
96
100
|
|
|
97
|
-
for (const root of new Set([...
|
|
101
|
+
for (const root of new Set([...readRoots, writeRoot])) {
|
|
98
102
|
if (!existsSync(root)) continue
|
|
99
103
|
|
|
100
104
|
for (const name of readdirSync(root)) {
|
|
@@ -145,7 +149,7 @@ export function Reservations(opts: ReservationsOpts = {}) {
|
|
|
145
149
|
|
|
146
150
|
/** Release everything this process holds — shutdown, and the one place a clean exit matters. */
|
|
147
151
|
releaseAll(): void {
|
|
148
|
-
for (const root of new Set([...
|
|
152
|
+
for (const root of new Set([...readRoots, writeRoot])) {
|
|
149
153
|
if (!existsSync(root)) continue
|
|
150
154
|
for (const name of readdirSync(root)) {
|
|
151
155
|
const path = join(root, name)
|
|
@@ -70,6 +70,7 @@ function storeDir(id: string): string {
|
|
|
70
70
|
* profiles/<email>/store/ — everything the APP writes (see STORE_DIR)
|
|
71
71
|
* cache/running/<sessionId>.json — liveness record for a local agent process
|
|
72
72
|
* cache/active-profile.json — who is logged in
|
|
73
|
+
* install-id — anonymous machine id, written by the install script
|
|
73
74
|
* cache/<name>.json — registry caches
|
|
74
75
|
*
|
|
75
76
|
* A profile root is now authored-vs-generated, not a flat bag: everything at
|
|
@@ -453,6 +454,33 @@ export function Store(opts: StoreOpts = {}) {
|
|
|
453
454
|
return {
|
|
454
455
|
root,
|
|
455
456
|
|
|
457
|
+
/**
|
|
458
|
+
* The anonymous machine id the INSTALL SCRIPT wrote, if there is one.
|
|
459
|
+
*
|
|
460
|
+
* Not written here — `curl … | bash` creates it long before any of this
|
|
461
|
+
* code exists on the machine, and re-running the installer must reuse
|
|
462
|
+
* the same id. This is a read-only view of a file another program owns,
|
|
463
|
+
* which is why it has no setter.
|
|
464
|
+
*
|
|
465
|
+
* It exists so a signup can be joined to the install that produced it.
|
|
466
|
+
* Without the join the backend has two counters — installs and users —
|
|
467
|
+
* that cannot be related, so "what fraction of installs become
|
|
468
|
+
* accounts" is unanswerable, which is the main thing install telemetry
|
|
469
|
+
* is for.
|
|
470
|
+
*
|
|
471
|
+
* Validated rather than trusted: the file is plain text in a directory
|
|
472
|
+
* a person is encouraged to navigate by hand, so it can be edited or
|
|
473
|
+
* truncated. The backend applies the same rule and would reject a bad
|
|
474
|
+
* value anyway; failing here keeps a pointless request off the wire.
|
|
475
|
+
* Returns null for absent, unreadable or malformed — all of which mean
|
|
476
|
+
* the same thing to every caller: nothing to attribute.
|
|
477
|
+
*/
|
|
478
|
+
installId(): string | null {
|
|
479
|
+
const raw = disk.text("install-id").get()?.trim()
|
|
480
|
+
if (!raw) return null
|
|
481
|
+
return /^[a-z0-9]{8,64}$/i.test(raw) ? raw : null
|
|
482
|
+
},
|
|
483
|
+
|
|
456
484
|
update: {
|
|
457
485
|
state: disk.json<UpdateRecord>("update.json"),
|
|
458
486
|
statePath: join(root, "update.json"),
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { err } from "@arcforge/err"
|
|
2
|
+
import { existsSync } from "node:fs"
|
|
3
|
+
import { resolve } from "node:path"
|
|
2
4
|
import type { AxonTestEventFrame } from "@arcforge/types"
|
|
3
5
|
import { isFrame, isTestChannel } from "./frames"
|
|
4
6
|
|
|
@@ -15,7 +17,10 @@ const DISCONNECT_GRACE_MS = 100
|
|
|
15
17
|
* --preload` — and is never imported by this one. Packaged builds ship it as a
|
|
16
18
|
* sibling .js (see the TUI's vterm.config.ts); a source checkout runs the .ts.
|
|
17
19
|
*/
|
|
18
|
-
const
|
|
20
|
+
const packagedPreload = resolve(import.meta.dir, "test-preload.js")
|
|
21
|
+
const PRELOAD = existsSync(packagedPreload)
|
|
22
|
+
? packagedPreload
|
|
23
|
+
: resolve(import.meta.dir, "../../bin/test-preload.ts")
|
|
19
24
|
|
|
20
25
|
export type ChildOutcome = {
|
|
21
26
|
exitCode: number
|