@botbotgo/agent-harness 0.0.175 → 0.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.175";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.175";
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
4
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
|
-
import { cp, mkdir, readFile,
|
|
6
|
+
import { cp, mkdir, readFile, stat, symlink } from "node:fs/promises";
|
|
7
7
|
const isolatedResourceRootCache = new Map();
|
|
8
|
+
const isolatedResourceRootBuilds = new Map();
|
|
8
9
|
function isolationCacheRoot() {
|
|
9
10
|
return path.join(os.tmpdir(), "agent-harness-resource-isolation");
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
+
function isolationDirPrefix(packageRoot) {
|
|
12
13
|
const digest = createHash("sha256").update(packageRoot).digest("hex").slice(0, 16);
|
|
13
14
|
return path.join(isolationCacheRoot(), `${path.basename(packageRoot)}-${digest}`);
|
|
14
15
|
}
|
|
16
|
+
function createIsolatedSnapshotDir(packageRoot) {
|
|
17
|
+
return `${isolationDirPrefix(packageRoot)}-${Date.now().toString(36)}-${randomUUID()}`;
|
|
18
|
+
}
|
|
15
19
|
function declaredDependencyNames(manifest) {
|
|
16
20
|
return Array.from(new Set([
|
|
17
21
|
...Object.keys(manifest.dependencies ?? {}),
|
|
@@ -52,8 +56,7 @@ async function linkDeclaredDependencies(isolatedRoot, packageRoot, manifest) {
|
|
|
52
56
|
async function buildIsolatedResourceRoot(packageRoot) {
|
|
53
57
|
const packageJsonPath = path.join(packageRoot, "package.json");
|
|
54
58
|
const manifest = JSON.parse(await readFile(packageJsonPath, "utf8"));
|
|
55
|
-
const isolatedRoot =
|
|
56
|
-
await rm(isolatedRoot, { recursive: true, force: true });
|
|
59
|
+
const isolatedRoot = createIsolatedSnapshotDir(packageRoot);
|
|
57
60
|
await mkdir(path.dirname(isolatedRoot), { recursive: true });
|
|
58
61
|
await cp(packageRoot, isolatedRoot, {
|
|
59
62
|
recursive: true,
|
|
@@ -65,8 +68,27 @@ async function buildIsolatedResourceRoot(packageRoot) {
|
|
|
65
68
|
return isolatedRoot;
|
|
66
69
|
}
|
|
67
70
|
async function rebuildIsolatedResourcePackageRoot(packageRoot) {
|
|
68
|
-
const
|
|
71
|
+
const existingBuild = isolatedResourceRootBuilds.get(packageRoot);
|
|
72
|
+
if (existingBuild) {
|
|
73
|
+
return existingBuild;
|
|
74
|
+
}
|
|
75
|
+
let loading;
|
|
76
|
+
loading = buildIsolatedResourceRoot(packageRoot)
|
|
77
|
+
.then((isolatedRoot) => {
|
|
78
|
+
isolatedResourceRootCache.set(packageRoot, Promise.resolve(isolatedRoot));
|
|
79
|
+
return isolatedRoot;
|
|
80
|
+
})
|
|
81
|
+
.catch((error) => {
|
|
82
|
+
if (isolatedResourceRootCache.get(packageRoot) === loading) {
|
|
83
|
+
isolatedResourceRootCache.delete(packageRoot);
|
|
84
|
+
}
|
|
85
|
+
throw error;
|
|
86
|
+
})
|
|
87
|
+
.finally(() => {
|
|
88
|
+
isolatedResourceRootBuilds.delete(packageRoot);
|
|
89
|
+
});
|
|
69
90
|
isolatedResourceRootCache.set(packageRoot, loading);
|
|
91
|
+
isolatedResourceRootBuilds.set(packageRoot, loading);
|
|
70
92
|
return loading;
|
|
71
93
|
}
|
|
72
94
|
export async function ensureIsolatedResourcePackageRoot(packageRoot) {
|