@arcforge/core 2.0.174 → 2.0.175
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/Axon.ts +14 -1
- package/src/tools/load.ts +11 -20
- package/src/tools/tools.ts +8 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcforge/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.175",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
"test:coverage": "bun test --coverage"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@arcforge/air": "2.0.
|
|
18
|
-
"@arcforge/capsule": "2.0.
|
|
19
|
-
"@arcforge/cloud": "2.0.
|
|
20
|
-
"@arcforge/cognet": "2.0.
|
|
21
|
-
"@arcforge/engines": "2.0.
|
|
22
|
-
"@arcforge/err": "2.0.
|
|
23
|
-
"@arcforge/kernel": "2.0.
|
|
24
|
-
"@arcforge/link": "2.0.
|
|
25
|
-
"@arcforge/session": "2.0.
|
|
26
|
-
"@arcforge/types": "2.0.
|
|
27
|
-
"@arcforge/vstr": "2.0.
|
|
17
|
+
"@arcforge/air": "2.0.175",
|
|
18
|
+
"@arcforge/capsule": "2.0.175",
|
|
19
|
+
"@arcforge/cloud": "2.0.175",
|
|
20
|
+
"@arcforge/cognet": "2.0.175",
|
|
21
|
+
"@arcforge/engines": "2.0.175",
|
|
22
|
+
"@arcforge/err": "2.0.175",
|
|
23
|
+
"@arcforge/kernel": "2.0.175",
|
|
24
|
+
"@arcforge/link": "2.0.175",
|
|
25
|
+
"@arcforge/session": "2.0.175",
|
|
26
|
+
"@arcforge/types": "2.0.175",
|
|
27
|
+
"@arcforge/vstr": "2.0.175",
|
|
28
28
|
"crossws": "^0.3.5",
|
|
29
29
|
"h3": "^1.13.0",
|
|
30
30
|
"hookable": "^5.5.3",
|
package/src/Axon.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { Inference } from "./runtime/inference"
|
|
|
16
16
|
import { Cognet } from "./cognet"
|
|
17
17
|
import { Modules } from "./modules"
|
|
18
18
|
import { Tools } from "./tools"
|
|
19
|
-
import { resolve } from "node:path"
|
|
19
|
+
import { dirname, join, resolve } from "node:path"
|
|
20
20
|
|
|
21
21
|
type AxonOpts = {
|
|
22
22
|
blueprint: AxonPartialBlueprint
|
|
@@ -202,6 +202,19 @@ export async function Axon(opts?: AxonOpts) {
|
|
|
202
202
|
// defined" for a module its config plainly installed.
|
|
203
203
|
const tools = Tools({
|
|
204
204
|
mediation: kernel.mediation,
|
|
205
|
+
// The agent's own frame, derived from paths.data — its sibling
|
|
206
|
+
// `cache` room is documented as regenerable and disposable,
|
|
207
|
+
// which is exactly what materialized tool source is. Never the
|
|
208
|
+
// OS temp directory: this process is spawned with an
|
|
209
|
+
// environment built from nothing and `TMPDIR` is not on the
|
|
210
|
+
// pass-through list, so host and agent resolved different
|
|
211
|
+
// directories and the import failed.
|
|
212
|
+
// Resolved against the agent root: `paths.data` defaults to the
|
|
213
|
+
// RELATIVE ".agent/data" for a programmatic blueprint, and a
|
|
214
|
+
// relative scratch path would resolve against whatever cwd the
|
|
215
|
+
// process happens to hold — which is exactly the ambient
|
|
216
|
+
// dependence this change exists to remove.
|
|
217
|
+
scratch: resolve(blueprint.paths.root, dirname(blueprint.paths.data), "cache", "tools"),
|
|
205
218
|
/**
|
|
206
219
|
* A name two tools both export, reported on the durable record.
|
|
207
220
|
*
|
package/src/tools/load.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { tmpdir } from "node:os"
|
|
3
|
-
import { join } from "node:path"
|
|
4
|
-
import { createHash } from "node:crypto"
|
|
1
|
+
import { materializeTool } from "@arcforge/capsule/materialize"
|
|
5
2
|
import { err } from "@arcforge/err"
|
|
6
3
|
import type { AxonTool } from "@arcforge/types"
|
|
7
4
|
import { mediate, type MediateOpts } from "./mediate"
|
|
@@ -24,21 +21,15 @@ export type LoadedTool = {
|
|
|
24
21
|
* ever mounted into the box, which is what kept the sandbox filesystem exactly
|
|
25
22
|
* what the fs policy declared. In-process that reason is gone; the tool's own
|
|
26
23
|
* file is part of the agent, so it can simply be imported. Materializing is
|
|
27
|
-
* kept only because bundled source has no path to import
|
|
28
|
-
*
|
|
24
|
+
* kept only because bundled source has no path to import.
|
|
25
|
+
*
|
|
26
|
+
* WHERE it materializes is `@arcforge/capsule/materialize` — shared with the
|
|
27
|
+
* capsule's own loader so the two cannot drift, and rooted in the agent's own
|
|
28
|
+
* frame rather than the OS temp directory. See that module for why: the agent
|
|
29
|
+
* process gets an environment built from nothing, `TMPDIR` is not on the
|
|
30
|
+
* pass-through list, and the resulting host/agent disagreement stopped agents
|
|
31
|
+
* booting on macOS entirely.
|
|
29
32
|
*/
|
|
30
|
-
async function materialize(source: string): Promise<string> {
|
|
31
|
-
// Content-hashed: repeated loads of identical source (a reload, two agents
|
|
32
|
-
// sharing a module) reuse one file rather than leaking a new one per call.
|
|
33
|
-
// A data: URI cannot be used — real tool sources exceed the OS module
|
|
34
|
-
// specifier length ceiling and throw NameTooLong.
|
|
35
|
-
const dir = join(tmpdir(), "axon-tools")
|
|
36
|
-
await mkdir(dir, { recursive: true })
|
|
37
|
-
const file = join(dir, `${createHash("sha256").update(source).digest("hex")}.ts`)
|
|
38
|
-
await writeFile(file, source)
|
|
39
|
-
return file
|
|
40
|
-
}
|
|
41
|
-
|
|
42
33
|
/**
|
|
43
34
|
* Load one tool and mediate everything it exports.
|
|
44
35
|
*
|
|
@@ -56,9 +47,9 @@ async function materialize(source: string): Promise<string> {
|
|
|
56
47
|
* A capsule missing scope the agent was promised is invalid state, not a
|
|
57
48
|
* warning — which is exactly what the host half already believed.
|
|
58
49
|
*/
|
|
59
|
-
export async function loadTool(tool: AxonTool, mediation: MediateOpts): Promise<LoadedTool> {
|
|
50
|
+
export async function loadTool(tool: AxonTool, mediation: MediateOpts, scratch: string): Promise<LoadedTool> {
|
|
60
51
|
const specifier = tool.source !== undefined
|
|
61
|
-
? await
|
|
52
|
+
? await materializeTool(scratch, tool.source)
|
|
62
53
|
: tool.entryPath
|
|
63
54
|
|
|
64
55
|
if (!specifier) {
|
package/src/tools/tools.ts
CHANGED
|
@@ -9,6 +9,12 @@ import type { MediateOpts } from "./mediate"
|
|
|
9
9
|
|
|
10
10
|
type ToolsOpts = {
|
|
11
11
|
mediation: MediateOpts
|
|
12
|
+
/**
|
|
13
|
+
* Where bundled tool source is materialized so it can be imported — the
|
|
14
|
+
* agent's own frame cache, never the OS temp directory. See
|
|
15
|
+
* `@arcforge/capsule/materialize` for why that distinction is load-bearing.
|
|
16
|
+
*/
|
|
17
|
+
scratch: string
|
|
12
18
|
/**
|
|
13
19
|
* Two tools exporting the same name into one scope.
|
|
14
20
|
*
|
|
@@ -67,7 +73,7 @@ export function Tools(opts: ToolsOpts) {
|
|
|
67
73
|
*/
|
|
68
74
|
async install(tools: AxonTool[]): Promise<void> {
|
|
69
75
|
for (const tool of tools.filter(isLoadable)) {
|
|
70
|
-
loaded.set(tool.name, await loadTool(tool, opts.mediation))
|
|
76
|
+
loaded.set(tool.name, await loadTool(tool, opts.mediation, opts.scratch))
|
|
71
77
|
origins.set(tool.name, tool.origin)
|
|
72
78
|
}
|
|
73
79
|
},
|
|
@@ -91,7 +97,7 @@ export function Tools(opts: ToolsOpts) {
|
|
|
91
97
|
const next = new Map<string, LoadedTool>()
|
|
92
98
|
const nextOrigins = new Map<string, AxonTool["origin"]>()
|
|
93
99
|
for (const tool of tools.filter(isLoadable)) {
|
|
94
|
-
next.set(tool.name, await loadTool(tool, opts.mediation))
|
|
100
|
+
next.set(tool.name, await loadTool(tool, opts.mediation, opts.scratch))
|
|
95
101
|
nextOrigins.set(tool.name, tool.origin)
|
|
96
102
|
}
|
|
97
103
|
loaded.clear()
|