@arcforge/platform 2.0.166
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/README.md +31 -0
- package/package.json +69 -0
- package/src/bin/supervisor.ts +102 -0
- package/src/bin/test-api.ts +30 -0
- package/src/bin/test-preload.ts +308 -0
- package/src/bin/update-helper.ts +32 -0
- package/src/build/bench/CLAUDE.md +106 -0
- package/src/build/bench/SPEC.md +209 -0
- package/src/build/bench/agents.ts +105 -0
- package/src/build/bench/axes.ts +84 -0
- package/src/build/bench/bench.ts +96 -0
- package/src/build/bench/discover.ts +147 -0
- package/src/build/bench/index.ts +7 -0
- package/src/build/bench/log.ts +47 -0
- package/src/build/bench/matrix.ts +23 -0
- package/src/build/bench/preload.ts +440 -0
- package/src/build/bench/prepare.ts +61 -0
- package/src/build/bench/projection.ts +112 -0
- package/src/build/bench/resolve.ts +54 -0
- package/src/build/bench/runner.ts +309 -0
- package/src/build/bench/schema/extract.ts +148 -0
- package/src/build/bench/schema/index.ts +2 -0
- package/src/build/bench/schema/schema.ts +95 -0
- package/src/build/bench/schema/worker.ts +30 -0
- package/src/build/bench/typegen.ts +119 -0
- package/src/build/bench/workspace/files.ts +139 -0
- package/src/build/bench/workspace/handle.ts +133 -0
- package/src/build/bench/workspace/index.ts +11 -0
- package/src/build/bench/workspace/workspace.ts +14 -0
- package/src/build/blueprint/blueprint.ts +398 -0
- package/src/build/blueprint/cognet/abi.ts +207 -0
- package/src/build/blueprint/cognet/bundle-worker.ts +93 -0
- package/src/build/blueprint/cognet/bundle.ts +664 -0
- package/src/build/blueprint/cognet/cognet.ts +249 -0
- package/src/build/blueprint/cognet/index.ts +10 -0
- package/src/build/blueprint/cognet/manifest.ts +38 -0
- package/src/build/blueprint/cognet/resolve.ts +113 -0
- package/src/build/blueprint/collisions.ts +51 -0
- package/src/build/blueprint/index.ts +29 -0
- package/src/build/blueprint/modules/entries.ts +117 -0
- package/src/build/blueprint/modules/index.ts +300 -0
- package/src/build/blueprint/modules/meta.ts +174 -0
- package/src/build/blueprint/scan/boot.ts +34 -0
- package/src/build/blueprint/scan/cognetImports.ts +56 -0
- package/src/build/blueprint/scan/components.ts +45 -0
- package/src/build/blueprint/scan/config.ts +234 -0
- package/src/build/blueprint/scan/configImports.ts +232 -0
- package/src/build/blueprint/scan/declare-worker.ts +61 -0
- package/src/build/blueprint/scan/declare.ts +393 -0
- package/src/build/blueprint/scan/h3-globals.ts +137 -0
- package/src/build/blueprint/scan/knowledge.ts +101 -0
- package/src/build/blueprint/scan/middleware.ts +110 -0
- package/src/build/blueprint/scan/moduleImports.ts +79 -0
- package/src/build/blueprint/scan/plugins.ts +93 -0
- package/src/build/blueprint/scan/promptPackages.ts +45 -0
- package/src/build/blueprint/scan/prompts.ts +164 -0
- package/src/build/blueprint/scan/published.ts +131 -0
- package/src/build/blueprint/scan/resolve.ts +398 -0
- package/src/build/blueprint/scan/routes.ts +109 -0
- package/src/build/blueprint/scan/scripts.ts +119 -0
- package/src/build/blueprint/scan/tool-bundle-worker.ts +69 -0
- package/src/build/blueprint/scan/tools.ts +610 -0
- package/src/build/blueprint/types.ts +28 -0
- package/src/build/extensions/config.ts +261 -0
- package/src/build/extensions/edit.ts +684 -0
- package/src/build/extensions/extensions.ts +731 -0
- package/src/build/extensions/index.ts +10 -0
- package/src/build/extensions/load.ts +350 -0
- package/src/build/extensions/registrations.ts +189 -0
- package/src/build/extensions/store.ts +200 -0
- package/src/build/frame/frame.ts +145 -0
- package/src/build/frame/index.ts +5 -0
- package/src/build/frame/migrate.ts +246 -0
- package/src/build/project/bundle/agent.ts +382 -0
- package/src/build/project/bundle/artifacts.ts +88 -0
- package/src/build/project/bundle/assets.ts +385 -0
- package/src/build/project/bundle/bundle.ts +160 -0
- package/src/build/project/bundle/imports.ts +102 -0
- package/src/build/project/bundle/index.ts +16 -0
- package/src/build/project/bundle/module.ts +130 -0
- package/src/build/project/bundle/source.ts +136 -0
- package/src/build/project/bundle/stage.ts +97 -0
- package/src/build/project/bundle/types.ts +111 -0
- package/src/build/project/cognet.ts +156 -0
- package/src/build/project/create/agent.ts +52 -0
- package/src/build/project/create/bench.ts +81 -0
- package/src/build/project/create/cognet.ts +102 -0
- package/src/build/project/create/extension.ts +63 -0
- package/src/build/project/create/module.ts +43 -0
- package/src/build/project/create/profile.ts +102 -0
- package/src/build/project/create/prompt.ts +68 -0
- package/src/build/project/create/templates.ts +88 -0
- package/src/build/project/deploy.ts +96 -0
- package/src/build/project/index.ts +40 -0
- package/src/build/project/installer.ts +616 -0
- package/src/build/project/kinds.ts +374 -0
- package/src/build/project/links.ts +33 -0
- package/src/build/project/manifest/bunfig.ts +139 -0
- package/src/build/project/manifest/config.ts +246 -0
- package/src/build/project/manifest/env.ts +184 -0
- package/src/build/project/manifest/index.ts +9 -0
- package/src/build/project/manifest/manifest.ts +49 -0
- package/src/build/project/manifest/model.ts +124 -0
- package/src/build/project/manifest/package.ts +386 -0
- package/src/build/project/manifest/text.ts +19 -0
- package/src/build/project/models/fetch.ts +123 -0
- package/src/build/project/models/index.ts +8 -0
- package/src/build/project/models/models.ts +111 -0
- package/src/build/project/models/specifier.ts +106 -0
- package/src/build/project/models/store.ts +202 -0
- package/src/build/project/modules/hash.ts +31 -0
- package/src/build/project/modules/index.ts +5 -0
- package/src/build/project/modules/lock.ts +78 -0
- package/src/build/project/modules/modules.ts +155 -0
- package/src/build/project/prepare.ts +709 -0
- package/src/build/project/project.ts +253 -0
- package/src/build/project/projects.ts +164 -0
- package/src/build/project/propagation.ts +120 -0
- package/src/build/project/publish/verify.ts +312 -0
- package/src/build/project/publish.ts +155 -0
- package/src/build/project/reconcile.ts +93 -0
- package/src/build/project/specifier.ts +42 -0
- package/src/build/project/tree.ts +615 -0
- package/src/build/project/treecache.ts +356 -0
- package/src/build/project/typegen/axon-dts.ts +362 -0
- package/src/build/project/typegen/cognet-dts.ts +91 -0
- package/src/build/project/typegen/components.ts +45 -0
- package/src/build/project/typegen/env.ts +59 -0
- package/src/build/project/typegen/generators.ts +108 -0
- package/src/build/project/typegen/hooks.ts +71 -0
- package/src/build/project/typegen/index.ts +137 -0
- package/src/build/project/typegen/prompt-dts.ts +40 -0
- package/src/build/project/typegen/prompts.ts +36 -0
- package/src/build/project/typegen/registry-dts.ts +109 -0
- package/src/build/project/typegen/scripts.ts +37 -0
- package/src/build/project/typegen/tools.ts +31 -0
- package/src/build/project/typegen/tsconfig.ts +243 -0
- package/src/build/project/typegen/tui-dts.ts +120 -0
- package/src/build/project/typegen/write.ts +40 -0
- package/src/build/project/verify.ts +268 -0
- package/src/build/project/watcher.ts +266 -0
- package/src/build/runtime/agent.ts +550 -0
- package/src/build/runtime/escalations.ts +159 -0
- package/src/build/runtime/index.ts +15 -0
- package/src/build/runtime/instances.ts +604 -0
- package/src/build/runtime/profile.ts +91 -0
- package/src/build/runtime/progress.ts +143 -0
- package/src/build/runtime/requests.ts +167 -0
- package/src/build/runtime/resolve.ts +159 -0
- package/src/build/runtime/runtime.ts +233 -0
- package/src/build/runtime/sessions/index.ts +5 -0
- package/src/build/runtime/sessions/record.ts +145 -0
- package/src/build/runtime/sessions/sessions.ts +240 -0
- package/src/build/runtime/zeno.ts +120 -0
- package/src/index.ts +11 -0
- package/src/link/agent-main.ts +395 -0
- package/src/link/index.ts +70 -0
- package/src/link/services.ts +120 -0
- package/src/platform.ts +293 -0
- package/src/procs/index.ts +15 -0
- package/src/procs/tree.ts +177 -0
- package/src/services/cloud.ts +419 -0
- package/src/services/control/client.ts +126 -0
- package/src/services/control/dispatch.ts +156 -0
- package/src/services/control/index.ts +17 -0
- package/src/services/control/protocol.ts +179 -0
- package/src/services/control/server.ts +241 -0
- package/src/services/deployments.ts +81 -0
- package/src/services/files.ts +329 -0
- package/src/services/index.ts +5 -0
- package/src/services/mic/capture.ts +248 -0
- package/src/services/mic/config.ts +109 -0
- package/src/services/mic/fft.ts +93 -0
- package/src/services/mic/index.ts +139 -0
- package/src/services/mic/visualizer.ts +46 -0
- package/src/services/ollama/catalog.ts +122 -0
- package/src/services/ollama/http.ts +124 -0
- package/src/services/ollama/index.ts +13 -0
- package/src/services/ollama/models.ts +153 -0
- package/src/services/ollama/ollama.ts +89 -0
- package/src/services/ollama/registry.ts +112 -0
- package/src/services/ollama/types.ts +72 -0
- package/src/services/prompts.ts +76 -0
- package/src/services/registry.ts +220 -0
- package/src/services/resources/hardware.ts +125 -0
- package/src/services/resources/index.ts +6 -0
- package/src/services/resources/reservations.ts +162 -0
- package/src/services/resources/resources.ts +156 -0
- package/src/services/running/index.ts +1 -0
- package/src/services/running/running.ts +200 -0
- package/src/services/store/disk.ts +97 -0
- package/src/services/store/index.ts +15 -0
- package/src/services/store/store.ts +729 -0
- package/src/services/store/types.ts +303 -0
- package/src/services/test/child.ts +150 -0
- package/src/services/test/events.ts +102 -0
- package/src/services/test/files.ts +26 -0
- package/src/services/test/frames.ts +39 -0
- package/src/services/test/index.ts +7 -0
- package/src/services/test/runner.ts +122 -0
- package/src/services/test/types.ts +26 -0
- package/src/services/update/contract.ts +77 -0
- package/src/services/update/index.ts +12 -0
- package/src/services/update/installer.ts +139 -0
- package/src/services/update/updates.ts +137 -0
- package/src/utils/fs.ts +148 -0
- package/src/utils/tsast.ts +102 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AxonError } from "@arcforge/err"
|
|
2
|
+
/**
|
|
3
|
+
* Blueprint-internal types. The entry shapes themselves (AxonPrompt,
|
|
4
|
+
* AxonScript, AxonTool, AxonRoute, AxonModule) are canonical in @arcforge/types —
|
|
5
|
+
* there is no separate "manifest" layer anymore.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** A non-fatal discovery problem. Scanners warn; only Config throws. */
|
|
9
|
+
export type ScanWarning = {
|
|
10
|
+
domain: string
|
|
11
|
+
/** Flattened message — every consumer can print this. */
|
|
12
|
+
error: string
|
|
13
|
+
/**
|
|
14
|
+
* The structured failure, when the scanner had one.
|
|
15
|
+
*
|
|
16
|
+
* Kept BESIDE the string rather than replacing it: a warning is not always
|
|
17
|
+
* an AxonError (a shadowed tool name is a sentence, not a throw), and a
|
|
18
|
+
* renderer must not have to branch on which kind it got just to show a
|
|
19
|
+
* line. The string is the contract; this is the upgrade.
|
|
20
|
+
*/
|
|
21
|
+
cause?: AxonError
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** What every scanner returns: entries plus whatever it couldn't read. */
|
|
25
|
+
export type Scanned<T> = {
|
|
26
|
+
entries: T[]
|
|
27
|
+
warnings: ScanWarning[]
|
|
28
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { isAbsolute, join, resolve } from "node:path"
|
|
2
|
+
import { homedir } from "node:os"
|
|
3
|
+
import { err } from "@arcforge/err"
|
|
4
|
+
import { withProviderGlobals } from "../blueprint"
|
|
5
|
+
import { ExtensionStore, parseRef, type ExtensionStoreT } from "./store"
|
|
6
|
+
import type { ExtensionEntry, ProfileConfig, ProviderEntry } from "@arcforge/types"
|
|
7
|
+
import { fsx } from "../../utils/fs"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Loads and evaluates `profile.config.ts` — the user's declaration of WHICH
|
|
11
|
+
* extensions load.
|
|
12
|
+
*
|
|
13
|
+
* The same capture mechanism `blueprint/scan/config.ts` uses for
|
|
14
|
+
* `axon.config.ts`: install `defineProfile` as a global, import the file,
|
|
15
|
+
* catch what it passed. Serialized through a lock so the synchronous capture
|
|
16
|
+
* is unambiguous, and cache-busted so a reload picks up edits.
|
|
17
|
+
*
|
|
18
|
+
* Deliberately separate from the extension LOADING that follows it. This file
|
|
19
|
+
* only answers "what is enabled" — reading it must not run any of it, which is
|
|
20
|
+
* the property that lets `axon ext install` edit the list without executing a
|
|
21
|
+
* single extension.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
type ProfileEvaluation = {
|
|
25
|
+
capture(config: ProfileConfig): void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* One shared evaluation slot, on globalThis so every copy of this module
|
|
30
|
+
* agrees. See scan/config.ts for why the lock exists rather than a stack: Bun
|
|
31
|
+
* schedules concurrent import()s and then runs their synchronous evaluations
|
|
32
|
+
* back-to-back, so a stack cross-captures.
|
|
33
|
+
*/
|
|
34
|
+
const PROFILE_EVALUATION = Symbol.for("axon.profile.evaluation")
|
|
35
|
+
const state = (() => {
|
|
36
|
+
const shared = globalThis as typeof globalThis & {
|
|
37
|
+
[PROFILE_EVALUATION]?: { current: ProfileEvaluation | null; lock: Promise<void> }
|
|
38
|
+
}
|
|
39
|
+
return shared[PROFILE_EVALUATION] ??= { current: null, lock: Promise.resolve() }
|
|
40
|
+
})()
|
|
41
|
+
|
|
42
|
+
function installProfileGlobals(): void {
|
|
43
|
+
const g = globalThis as Record<string, unknown>
|
|
44
|
+
g.defineProfile = (config: ProfileConfig) => {
|
|
45
|
+
const evaluation = state.current
|
|
46
|
+
if (!evaluation) throw err("PROFILE_CONFIG_INVALID", { detail: "defineProfile() called outside config evaluation" })
|
|
47
|
+
evaluation.capture(config)
|
|
48
|
+
return { _kind: "profile" as const, config }
|
|
49
|
+
}
|
|
50
|
+
// An extension's own config file may be imported while resolving a local
|
|
51
|
+
// entry (it is what marks the directory), so its marker has to resolve
|
|
52
|
+
// here too. Pure identity — an extension declares nothing today.
|
|
53
|
+
g.defineExtension ??= (config: unknown = {}) => ({ _kind: "extension" as const, config })
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
installProfileGlobals()
|
|
57
|
+
|
|
58
|
+
/** One extension the profile asked for, normalized. */
|
|
59
|
+
export type ResolvedEntry = {
|
|
60
|
+
/** As written in profile.config.ts — what an error message should quote. */
|
|
61
|
+
source: string
|
|
62
|
+
/** "local" resolves as a path from the profile root; "registry" installs by name. */
|
|
63
|
+
kind: "local" | "registry"
|
|
64
|
+
/** Absolute directory this extension does (or will) live in. */
|
|
65
|
+
root: string
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type ProfileConfigResult = {
|
|
69
|
+
/** Enabled entries, in declaration order. Empty when the config is absent. */
|
|
70
|
+
entries: ResolvedEntry[]
|
|
71
|
+
/**
|
|
72
|
+
* The inference sources this profile declares, in declaration order.
|
|
73
|
+
*
|
|
74
|
+
* Projected here rather than read separately because this is already the
|
|
75
|
+
* one place a profile's config is evaluated — a second reader would be a
|
|
76
|
+
* second chance for the two to disagree about what the user wrote.
|
|
77
|
+
*
|
|
78
|
+
* Empty when the config is absent or declares none, which is the honest
|
|
79
|
+
* state: an agent then runs on whatever it configures for itself.
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* The inference sources this profile declares, in declaration order.
|
|
83
|
+
*
|
|
84
|
+
* UNDEFINED and EMPTY are different answers and must stay that way:
|
|
85
|
+
* absent means the profile predates the field (or was never configured)
|
|
86
|
+
* and gets the default pool; `[]` means the user deliberately declared
|
|
87
|
+
* none and gets exactly that. Collapsing the two here is what made every
|
|
88
|
+
* existing profile fail to boot — they all had no field, and `?? []`
|
|
89
|
+
* reported that as "I have nothing".
|
|
90
|
+
*/
|
|
91
|
+
providers: ProviderEntry[] | undefined
|
|
92
|
+
/**
|
|
93
|
+
* Why the config could not be read, if it could not be.
|
|
94
|
+
*
|
|
95
|
+
* Returned rather than thrown: a broken extension LIST must not stop the
|
|
96
|
+
* profile's own main.ts and plugins/ from loading. The caller reports it
|
|
97
|
+
* and carries on with no extensions.
|
|
98
|
+
*/
|
|
99
|
+
error: unknown | null
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A local entry is one that looks like a path. Everything else is a registry
|
|
104
|
+
* name — the same "./" | "../" | absolute test the module system uses, so a
|
|
105
|
+
* user's intuition transfers between the two.
|
|
106
|
+
*/
|
|
107
|
+
function isLocalPath(source: string): boolean {
|
|
108
|
+
return source.startsWith(".") || isAbsolute(source) || source.startsWith("~")
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A local entry's absolute directory. `~` expands; everything else resolves from the profile root. */
|
|
112
|
+
function localRoot(profileRoot: string, source: string): string {
|
|
113
|
+
if (source.startsWith("~")) return join(homedir(), source.slice(1))
|
|
114
|
+
return isAbsolute(source) ? source : resolve(profileRoot, source)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Where a registry extension lives: the MACHINE store, not this profile.
|
|
119
|
+
*
|
|
120
|
+
* `~/.axon/cache/extensions/<scope>/<name>/<version>/`. Profiles reference a
|
|
121
|
+
* shared copy rather than each holding their own — see ExtensionStore for why
|
|
122
|
+
* that is safe (nothing in a fetched extension is profile-relative) and what
|
|
123
|
+
* it buys (one install and one prepare, however many profiles use it).
|
|
124
|
+
*
|
|
125
|
+
* An UNPINNED entry has no version to address, so it resolves to the newest
|
|
126
|
+
* present. Every entry an install writes is pinned; this is the legacy shape,
|
|
127
|
+
* kept working so a config written before pinning still loads.
|
|
128
|
+
*/
|
|
129
|
+
function registryRoot(store: ExtensionStoreT, source: string): string {
|
|
130
|
+
const { name, version } = parseRef(source)
|
|
131
|
+
if (version) return store.pathFor(name, version)
|
|
132
|
+
|
|
133
|
+
// versions() is newest-first and semver-ordered — the store owns that
|
|
134
|
+
// rule, and re-deriving "which is newest" here is how this drifted into a
|
|
135
|
+
// second, lexical answer that disagreed with the store's own.
|
|
136
|
+
const newest = store.versions(name)[0]
|
|
137
|
+
// Nothing stored yet — the path an install will materialize into is
|
|
138
|
+
// unknowable until the version resolves, so this names the directory the
|
|
139
|
+
// name occupies. materialize() replaces it with the real one.
|
|
140
|
+
return newest ? store.pathFor(name, newest) : join(store.root, ...name.split("/"))
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* One source string → where it lives and how it gets there.
|
|
145
|
+
*
|
|
146
|
+
* Exported because installing takes a source the config does not yet contain,
|
|
147
|
+
* so it cannot come from reading the config — but it must resolve to the same
|
|
148
|
+
* place the loader will look for it afterwards.
|
|
149
|
+
*/
|
|
150
|
+
export function resolveEntry(source: string, profileRoot: string, store: ExtensionStoreT = ExtensionStore()): ResolvedEntry {
|
|
151
|
+
return isLocalPath(source)
|
|
152
|
+
? { source, kind: "local", root: localRoot(profileRoot, source) }
|
|
153
|
+
: { source, kind: "registry", root: registryRoot(store, source) }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function normalize(entry: ExtensionEntry, profileRoot: string, store: ExtensionStoreT): ResolvedEntry | null {
|
|
157
|
+
const raw = typeof entry === "string" ? { source: entry } : entry
|
|
158
|
+
if (typeof raw?.source !== "string" || raw.source.length === 0) {
|
|
159
|
+
throw err("EXTENSION_ENTRY_INVALID", {
|
|
160
|
+
detail: `expected a string or { source }, received ${JSON.stringify(entry)}`,
|
|
161
|
+
context: { entry },
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
// `enabled: false` keeps the line but does not load it — the point of the
|
|
165
|
+
// object form, and what lets a CLI toggle one without losing the entry.
|
|
166
|
+
if (typeof entry === "object" && entry.enabled === false) return null
|
|
167
|
+
|
|
168
|
+
return resolveEntry(raw.source, profileRoot, store)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Read a profile's extension list.
|
|
173
|
+
*
|
|
174
|
+
* A missing config is not an error — a profile that has never been configured
|
|
175
|
+
* simply loads no extensions.
|
|
176
|
+
*/
|
|
177
|
+
export async function ProfileConfigFile(profileRoot: string, store: ExtensionStoreT = ExtensionStore()): Promise<ProfileConfigResult> {
|
|
178
|
+
const configPath = join(profileRoot, "profile.config.ts")
|
|
179
|
+
if (!fsx.exists(configPath)) return { entries: [], providers: undefined, error: null }
|
|
180
|
+
|
|
181
|
+
let captured: ProfileConfig | null = null
|
|
182
|
+
const evaluation: ProfileEvaluation = { capture: config => { captured = config } }
|
|
183
|
+
|
|
184
|
+
let release!: () => void
|
|
185
|
+
const previous = state.lock
|
|
186
|
+
state.lock = new Promise<void>(resolve => { release = resolve })
|
|
187
|
+
await previous
|
|
188
|
+
|
|
189
|
+
try {
|
|
190
|
+
state.current = evaluation
|
|
191
|
+
try {
|
|
192
|
+
// Cache-bust per call so a reload re-evaluates rather than being
|
|
193
|
+
// served Bun's cached module — randomUUID, not Date.now(), which
|
|
194
|
+
// collides within a millisecond.
|
|
195
|
+
// Provider factories bound for the read: `providers: [Axon()]`
|
|
196
|
+
// in a profile means the PROVIDER factory, and under `axon exec`
|
|
197
|
+
// the bare global is the script's agent-booter. See
|
|
198
|
+
// withProviderGlobals in scan/config.ts.
|
|
199
|
+
// A BARE PATH, like scan/config.ts and for the same reason: this
|
|
200
|
+
// relies on globals installed around the import surviving into the
|
|
201
|
+
// module's evaluation, and a file:// URL loses that context. An
|
|
202
|
+
// extension config imports nothing from node_modules, so the
|
|
203
|
+
// resolution problem that forced pathToFileURL in the module loader
|
|
204
|
+
// does not arise here.
|
|
205
|
+
await withProviderGlobals(() => import(`${configPath}?t=${crypto.randomUUID()}`))
|
|
206
|
+
} catch (cause) {
|
|
207
|
+
return {
|
|
208
|
+
entries: [],
|
|
209
|
+
providers: undefined,
|
|
210
|
+
error: err("PROFILE_CONFIG_FAILED", {
|
|
211
|
+
detail: `${configPath} — ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
212
|
+
context: { configPath },
|
|
213
|
+
cause,
|
|
214
|
+
}),
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (!captured) {
|
|
219
|
+
return {
|
|
220
|
+
entries: [],
|
|
221
|
+
providers: undefined,
|
|
222
|
+
error: err("PROFILE_CONFIG_INVALID", { detail: configPath, context: { configPath } }),
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const config: ProfileConfig = captured
|
|
227
|
+
const entries: ResolvedEntry[] = []
|
|
228
|
+
// Validated as an ARRAY before iterating. `for...of` over a string
|
|
229
|
+
// walks its characters, so `extensions: "@cody/theme"` — a plausible
|
|
230
|
+
// typo, and the shape a single-entry config wants to be — silently
|
|
231
|
+
// became one registry entry per letter, each fetched and each reported
|
|
232
|
+
// missing. Eleven confusing errors for one obvious mistake.
|
|
233
|
+
const declared = config.extensions
|
|
234
|
+
if (declared !== undefined && !Array.isArray(declared)) {
|
|
235
|
+
return {
|
|
236
|
+
entries: [],
|
|
237
|
+
providers: config.providers,
|
|
238
|
+
error: err("EXTENSION_ENTRY_INVALID", {
|
|
239
|
+
detail: `extensions must be an array, received ${typeof declared}`,
|
|
240
|
+
context: { extensions: declared },
|
|
241
|
+
}),
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
for (const entry of declared ?? []) {
|
|
246
|
+
try {
|
|
247
|
+
const resolved = normalize(entry, profileRoot, store)
|
|
248
|
+
if (resolved) entries.push(resolved)
|
|
249
|
+
} catch (cause) {
|
|
250
|
+
// One malformed entry does not invalidate the others — the
|
|
251
|
+
// list is a set of independent requests, not a transaction.
|
|
252
|
+
return { entries, providers: config.providers, error: cause }
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return { entries, providers: config.providers, error: null }
|
|
257
|
+
} finally {
|
|
258
|
+
state.current = null
|
|
259
|
+
release()
|
|
260
|
+
}
|
|
261
|
+
}
|