@arcforge/platform 2.0.174 → 2.0.176
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 +10 -10
- package/src/build/project/tree.ts +46 -6
- package/src/link/agent-main.ts +1 -0
- package/src/platform.ts +1 -1
- package/src/services/cloud.ts +3 -0
- package/src/services/mic/capture.ts +41 -16
- package/src/services/running/running.ts +20 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcforge/platform",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.176",
|
|
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.176",
|
|
48
|
+
"@arcforge/engines": "2.0.176",
|
|
49
|
+
"@arcforge/err": "2.0.176",
|
|
50
|
+
"@arcforge/types": "2.0.176",
|
|
51
|
+
"@arcforge/cloud": "2.0.176",
|
|
52
|
+
"@arcforge/capsule": "2.0.176",
|
|
53
|
+
"@arcforge/core": "2.0.176",
|
|
54
|
+
"@arcforge/vstr": "2.0.176",
|
|
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.176"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@arcforge/air": "2.0.167",
|
|
@@ -561,11 +561,52 @@ async function linkFramework(root: string): Promise<void> {
|
|
|
561
561
|
* claim the specifier, so a moved or renamed package fails to link instead of
|
|
562
562
|
* linking the wrong directory.
|
|
563
563
|
*/
|
|
564
|
+
/**
|
|
565
|
+
* Every package.json under `root`, to `depth` levels, skipping node_modules.
|
|
566
|
+
*
|
|
567
|
+
* Walked in-process rather than shelled out to `find`. Two reasons, and the
|
|
568
|
+
* second is the one that matters:
|
|
569
|
+
*
|
|
570
|
+
* - `find` does not exist on Windows, so the spawn produced no output there.
|
|
571
|
+
* - `spawnSync` reports a missing binary as EMPTY STDOUT, which is exactly what
|
|
572
|
+
* a successful search with no matches looks like. Both call sites then looped
|
|
573
|
+
* over nothing and returned null — so "this machine has no `find`" was
|
|
574
|
+
* indistinguishable from "this workspace has no framework packages", and a
|
|
575
|
+
* developer on a Mac or Windows box silently linked against the published
|
|
576
|
+
* copy while believing they were testing their own checkout.
|
|
577
|
+
*
|
|
578
|
+
* A directory walk cannot fail that way: an unreadable directory is skipped
|
|
579
|
+
* explicitly, and there is no binary to be absent.
|
|
580
|
+
*/
|
|
581
|
+
function manifestsUnder(root: string, depth: number): string[] {
|
|
582
|
+
const out: string[] = []
|
|
583
|
+
|
|
584
|
+
const walk = (dir: string, remaining: number): void => {
|
|
585
|
+
if (remaining < 0) return
|
|
586
|
+
let entries
|
|
587
|
+
try {
|
|
588
|
+
entries = readdirSync(dir, { withFileTypes: true })
|
|
589
|
+
} catch {
|
|
590
|
+
// Unreadable directory — a permission fault or a broken symlink.
|
|
591
|
+
// Skipped rather than fatal: it is one branch of a search, and the
|
|
592
|
+
// caller's question is "is this package here", not "is every
|
|
593
|
+
// directory readable".
|
|
594
|
+
return
|
|
595
|
+
}
|
|
596
|
+
for (const entry of entries) {
|
|
597
|
+
if (entry.name === "node_modules") continue
|
|
598
|
+
const path = join(dir, entry.name)
|
|
599
|
+
if (entry.isDirectory()) walk(path, remaining - 1)
|
|
600
|
+
else if (entry.name === "package.json") out.push(path)
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
walk(root, depth)
|
|
605
|
+
return out
|
|
606
|
+
}
|
|
607
|
+
|
|
564
608
|
function frameworkDir(workspace: string, name: string): string | null {
|
|
565
|
-
const found =
|
|
566
|
-
"find", join(workspace, "libs"), "-maxdepth", "5", "-name", "package.json",
|
|
567
|
-
"-not", "-path", "*/node_modules/*",
|
|
568
|
-
]).stdout.toString().trim().split("\n")
|
|
609
|
+
const found = manifestsUnder(join(workspace, "libs"), 5)
|
|
569
610
|
|
|
570
611
|
for (const candidate of found) {
|
|
571
612
|
if (!candidate) continue
|
|
@@ -586,8 +627,7 @@ function findWorkspacePackage(from: string, name: string): string | null {
|
|
|
586
627
|
try {
|
|
587
628
|
const pkg = JSON.parse(readFileSync(manifest, "utf8")) as { workspaces?: string[] }
|
|
588
629
|
if (pkg.workspaces) {
|
|
589
|
-
const found =
|
|
590
|
-
"-not", "-path", "*/node_modules/*"]).stdout.toString().trim().split("\n")
|
|
630
|
+
const found = manifestsUnder(dir, 4)
|
|
591
631
|
for (const candidate of found) {
|
|
592
632
|
if (!candidate) continue
|
|
593
633
|
try {
|
package/src/link/agent-main.ts
CHANGED
|
@@ -84,6 +84,7 @@ export async function main(): Promise<void> {
|
|
|
84
84
|
|
|
85
85
|
const handlers = agentHandlers({
|
|
86
86
|
stimulus: entry => serve().then(s => s.stimulus(entry)),
|
|
87
|
+
ingest: entry => serve().then(s => s.ingest(entry)),
|
|
87
88
|
update: bp => serve().then(s => s.update(bp)),
|
|
88
89
|
/**
|
|
89
90
|
* Interrupt is sync and fire-and-forget — but it must not be LOST.
|
package/src/platform.ts
CHANGED
|
@@ -92,7 +92,7 @@ export function Platform(opts: PlatformOpts) {
|
|
|
92
92
|
return result
|
|
93
93
|
},
|
|
94
94
|
})
|
|
95
|
-
const cloud = Cloud({ store: store, distribution: distribution })
|
|
95
|
+
const cloud = Cloud({ store: store, distribution: distribution, release: opts.version })
|
|
96
96
|
|
|
97
97
|
const ollama = Ollama() // local models via the Ollama daemon
|
|
98
98
|
const mic = Mic() // mic capture + visualizer service
|
package/src/services/cloud.ts
CHANGED
|
@@ -17,6 +17,8 @@ type CloudOpts = {
|
|
|
17
17
|
* credentials — that is this leaf's own policy.
|
|
18
18
|
*/
|
|
19
19
|
distribution: Distribution
|
|
20
|
+
/** Shipped host version stamped onto every crash report. */
|
|
21
|
+
release: string
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export type Distribution = "production" | "development"
|
|
@@ -138,6 +140,7 @@ export function Cloud(opts: CloudOpts) {
|
|
|
138
140
|
...(profile?.record.auth.apiKey ? { key: profile.record.auth.apiKey } : {}),
|
|
139
141
|
...(session ? { session } : {}),
|
|
140
142
|
environmentCredentials: policy.environmentCredentials,
|
|
143
|
+
release: opts.release,
|
|
141
144
|
onUnauthorized: () => { void onSessionExpired() },
|
|
142
145
|
})
|
|
143
146
|
}
|
|
@@ -24,42 +24,67 @@ export type CaptureOpts = {
|
|
|
24
24
|
windowSamples: number
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Capture backends worth trying, in priority order, for one platform.
|
|
29
|
+
*
|
|
30
|
+
* Split from the $PATH probe and given the platform as a PARAMETER so all
|
|
31
|
+
* three orders are assertable from one machine. The darwin and win32 lists
|
|
32
|
+
* cannot execute on Linux CI otherwise, which is how a wrong argv ships: the
|
|
33
|
+
* failure is a silent "voice unavailable", indistinguishable from a machine
|
|
34
|
+
* that genuinely has no capture tool installed.
|
|
35
|
+
*/
|
|
36
|
+
export function backendsFor(platform: NodeJS.Platform = process.platform): CaptureBackend[] {
|
|
37
|
+
// Windows has no reliable always-present CLI capture tool, so sox/ffmpeg
|
|
38
|
+
// only. macOS likewise — arecord is ALSA, which is Linux's.
|
|
39
|
+
if (platform === "darwin" || platform === "win32") return ["sox", "ffmpeg"]
|
|
40
|
+
return ["arecord", "sox", "ffmpeg"] // linux and other unix
|
|
41
|
+
}
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
/** First backend actually present on $PATH, or null when none is. */
|
|
44
|
+
function detectBackend(): CaptureBackend | null {
|
|
45
|
+
for (const cmd of backendsFor()) {
|
|
35
46
|
if (Bun.which(cmd)) return cmd
|
|
36
47
|
}
|
|
37
48
|
return null
|
|
38
49
|
}
|
|
39
50
|
|
|
40
|
-
/**
|
|
41
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Spawn args per backend — all produce raw signed 16-bit LE PCM, mono, at
|
|
53
|
+
* `sampleRate`, on stdout. Every branch ends in that same format, which is the
|
|
54
|
+
* invariant the reader downstream depends on.
|
|
55
|
+
*
|
|
56
|
+
* The platform is a PARAMETER, not a `process.platform` read, so the six
|
|
57
|
+
* OS-specific argv shapes can be asserted on any machine. Each names a
|
|
58
|
+
* different audio subsystem — avfoundation on macOS, dshow on Windows, ALSA on
|
|
59
|
+
* Linux — and getting one wrong yields a backend that spawns and then produces
|
|
60
|
+
* nothing, which reads to the user as a microphone that does not work.
|
|
61
|
+
*/
|
|
62
|
+
export function buildArgs(
|
|
63
|
+
backend: CaptureBackend,
|
|
64
|
+
sampleRate: number,
|
|
65
|
+
platform: NodeJS.Platform = process.platform,
|
|
66
|
+
): string[] {
|
|
42
67
|
const rate = String(sampleRate)
|
|
43
68
|
|
|
44
69
|
if (backend === "arecord") {
|
|
70
|
+
// ALSA only — never selected on darwin or win32 (see backendsFor).
|
|
45
71
|
return ["-t", "raw", "-f", "S16_LE", "-r", rate, "-c", "1", "-"]
|
|
46
72
|
}
|
|
47
73
|
|
|
48
74
|
if (backend === "sox") {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (process.platform === "win32") {
|
|
75
|
+
// `-d` is sox's default input device, which both macOS and Windows
|
|
76
|
+
// resolve themselves. Linux needs the ALSA device named explicitly.
|
|
77
|
+
if (platform === "darwin" || platform === "win32") {
|
|
53
78
|
return ["-d", "-r", rate, "-c", "1", "-e", "signed-integer", "-b", "16", "-t", "raw", "-"]
|
|
54
79
|
}
|
|
55
80
|
return ["-t", "alsa", "default", "-r", rate, "-c", "1", "-e", "signed-integer", "-b", "16", "-t", "raw", "-"]
|
|
56
81
|
}
|
|
57
82
|
|
|
58
|
-
// ffmpeg
|
|
59
|
-
if (
|
|
83
|
+
// ffmpeg — one flag per platform's capture subsystem.
|
|
84
|
+
if (platform === "darwin") {
|
|
60
85
|
return ["-f", "avfoundation", "-i", ":0", "-ac", "1", "-ar", rate, "-f", "s16le", "-"]
|
|
61
86
|
}
|
|
62
|
-
if (
|
|
87
|
+
if (platform === "win32") {
|
|
63
88
|
return ["-f", "dshow", "-i", "audio=default", "-ac", "1", "-ar", rate, "-f", "s16le", "-"]
|
|
64
89
|
}
|
|
65
90
|
return ["-f", "alsa", "-i", "default", "-ac", "1", "-ar", rate, "-f", "s16le", "-"]
|
|
@@ -53,6 +53,20 @@ function read(path: string): AxonInstance | null {
|
|
|
53
53
|
type RunningOpts = {
|
|
54
54
|
/** Where THIS process registers itself. Readers still see every root. */
|
|
55
55
|
root?: string
|
|
56
|
+
/**
|
|
57
|
+
* Read ONLY `root`, rather than every well-known store.
|
|
58
|
+
*
|
|
59
|
+
* The default is deliberately wide: an observer must see an agent booted by
|
|
60
|
+
* the installed binary and one booted from a source checkout alike, or it
|
|
61
|
+
* reports an idle machine while work is running. That is right in
|
|
62
|
+
* production and wrong under test, where sweeping the real `~/.axon` means
|
|
63
|
+
* a developer with an agent open fails an assertion about an empty store —
|
|
64
|
+
* and, worse, a test can DELETE a real record (`remove` sweeps every root).
|
|
65
|
+
*
|
|
66
|
+
* The daemon's Registry already carries this exact flag; naming it the same
|
|
67
|
+
* way here keeps one idea with one spelling.
|
|
68
|
+
*/
|
|
69
|
+
isolated?: boolean
|
|
56
70
|
/** Coalesce a burst of fs events (several agents booting at once) into one callback. */
|
|
57
71
|
debounceMs?: number
|
|
58
72
|
/** How often to re-check without an fs event — catches a crashed pid, which touches no file. */
|
|
@@ -79,6 +93,8 @@ type RunningOpts = {
|
|
|
79
93
|
*/
|
|
80
94
|
export function Running(opts: RunningOpts = {}) {
|
|
81
95
|
const writeRoot = opts.root ?? ROOTS[0]!
|
|
96
|
+
/** Every directory this instance reads and prunes. See `isolated`. */
|
|
97
|
+
const roots = opts.isolated === true ? [writeRoot] : [...new Set([...ROOTS, writeRoot])]
|
|
82
98
|
const debounceMs = opts.debounceMs ?? 100
|
|
83
99
|
const pollMs = opts.pollMs ?? 5000
|
|
84
100
|
|
|
@@ -96,7 +112,7 @@ export function Running(opts: RunningOpts = {}) {
|
|
|
96
112
|
// stale record in one root must never shadow the live one in another.
|
|
97
113
|
const live = new Map<string, AxonInstance>()
|
|
98
114
|
|
|
99
|
-
for (const root of
|
|
115
|
+
for (const root of roots) {
|
|
100
116
|
if (!existsSync(root)) continue
|
|
101
117
|
|
|
102
118
|
for (const name of readdirSync(root)) {
|
|
@@ -124,7 +140,7 @@ export function Running(opts: RunningOpts = {}) {
|
|
|
124
140
|
|
|
125
141
|
return {
|
|
126
142
|
/** Every root read by list()/watch(). Exposed for diagnostics, not for callers to walk. */
|
|
127
|
-
roots:
|
|
143
|
+
roots: roots,
|
|
128
144
|
|
|
129
145
|
/** Register this process. Called once, immediately after the runtime is up. */
|
|
130
146
|
start(instance: AxonInstance): void {
|
|
@@ -141,7 +157,7 @@ export function Running(opts: RunningOpts = {}) {
|
|
|
141
157
|
|
|
142
158
|
/** Deregister. Called first thing on shutdown — a reader must never see "alive" for a session mid-teardown. */
|
|
143
159
|
stop(sessionId: string): void {
|
|
144
|
-
for (const root of
|
|
160
|
+
for (const root of roots) rmSync(fileOf(root, sessionId), { force: true })
|
|
145
161
|
},
|
|
146
162
|
|
|
147
163
|
/** Every currently-live instance, pid-checked fresh. Dead records are GC'd as a side effect. */
|
|
@@ -165,7 +181,7 @@ export function Running(opts: RunningOpts = {}) {
|
|
|
165
181
|
*/
|
|
166
182
|
watch(listener: (instances: AxonInstance[]) => void): () => void {
|
|
167
183
|
if (!watchers.length) {
|
|
168
|
-
for (const root of
|
|
184
|
+
for (const root of roots) {
|
|
169
185
|
mkdirSync(root, { recursive: true }) // fs.watch throws on a missing directory
|
|
170
186
|
watchers.push(watch(root, () => notify()))
|
|
171
187
|
}
|