@mettlelabs/mettle 0.0.0-beta.2-linux-arm64 → 0.0.0-beta.2
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/bin/mettle.js +53 -0
- package/bin/postinstall.js +28 -0
- package/package.json +19 -13
- package/THIRD_PARTY_NOTICES.md +0 -11974
- package/bin/mettle +0 -4
- package/harness/audit-investigation.mjs +0 -203
- package/harness/chunk-1sygmp11.mjs +0 -18142
- package/harness/chunk-1ykxpmaz.mjs +0 -7887
- package/harness/chunk-2pm2sayw.mjs +0 -248
- package/harness/chunk-3m7jn5ac.mjs +0 -16242
- package/harness/chunk-3wt8a8fq.mjs +0 -1716
- package/harness/chunk-3wvjs93w.mjs +0 -538
- package/harness/chunk-49ytr8d5.mjs +0 -33761
- package/harness/chunk-4bepyxmq.mjs +0 -113
- package/harness/chunk-4vx34w5h.mjs +0 -2357
- package/harness/chunk-50sbrf09.mjs +0 -18972
- package/harness/chunk-56csr8sw.mjs +0 -322
- package/harness/chunk-5wgmv4np.mjs +0 -585
- package/harness/chunk-65eyq32y.mjs +0 -225
- package/harness/chunk-6fnh6qhk.mjs +0 -195
- package/harness/chunk-6kgqw9ny.mjs +0 -32303
- package/harness/chunk-7b242j0n.mjs +0 -14
- package/harness/chunk-9dg1btk1.mjs +0 -2818
- package/harness/chunk-ageqxj9v.mjs +0 -63008
- package/harness/chunk-b0qbt5jd.mjs +0 -14
- package/harness/chunk-b5g1r3fz.mjs +0 -4785
- package/harness/chunk-b71gpkxg.mjs +0 -1514
- package/harness/chunk-bdv1rx4a.mjs +0 -20364
- package/harness/chunk-c1631s2x.mjs +0 -12241
- package/harness/chunk-c7dx5mdd.mjs +0 -10807
- package/harness/chunk-d5xgxsnp.mjs +0 -74
- package/harness/chunk-erg1fbh0.mjs +0 -0
- package/harness/chunk-fh78v9vn.mjs +0 -19366
- package/harness/chunk-fjx29qvp.mjs +0 -50
- package/harness/chunk-gryka6kg.mjs +0 -39
- package/harness/chunk-h1td5kq9.mjs +0 -422
- package/harness/chunk-jb0r19et.mjs +0 -180
- package/harness/chunk-jp69h6sj.mjs +0 -95
- package/harness/chunk-mfn574ss.mjs +0 -179
- package/harness/chunk-nz5sv9as.mjs +0 -1642
- package/harness/chunk-p9d3cgvq.mjs +0 -452
- package/harness/chunk-pq6wvwxr.mjs +0 -12
- package/harness/chunk-qcm9arf8.mjs +0 -7736
- package/harness/chunk-qr8zfqjd.mjs +0 -24
- package/harness/chunk-rd80vvc5.mjs +0 -22047
- package/harness/chunk-rz2tz6jp.mjs +0 -26
- package/harness/chunk-sbkgc3kn.mjs +0 -8
- package/harness/chunk-v66qvpnb.mjs +0 -169
- package/harness/chunk-vjaxzab3.mjs +0 -136
- package/harness/chunk-vr1n5nza.mjs +0 -1045
- package/harness/chunk-vsf2zajv.mjs +0 -3867
- package/harness/chunk-w0qwc5z2.mjs +0 -41
- package/harness/chunk-wq253fj4.mjs +0 -19041
- package/harness/chunk-wyv7ceq4.mjs +0 -0
- package/harness/chunk-xnqknk2r.mjs +0 -198
- package/harness/chunk-z6n9thea.mjs +0 -45146
- package/harness/chunk-zty0d3bw.mjs +0 -0
- package/harness/chunk-zvkxtj82.mjs +0 -42
- package/harness/issue-api-token.mjs +0 -35
- package/harness/launcher.mjs +0 -459
- package/harness/sandbox.mjs +0 -133
- package/harness/server.mjs +0 -87314
package/harness/sandbox.mjs
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HarnessError,
|
|
3
|
-
publicError,
|
|
4
|
-
FIXTURE_TARGET,
|
|
5
|
-
fixtureConfig
|
|
6
|
-
} from "./chunk-rd80vvc5.mjs";
|
|
7
|
-
import {
|
|
8
|
-
ToolExecutor,
|
|
9
|
-
SandboxProbeJournal,
|
|
10
|
-
SandboxJournal,
|
|
11
|
-
reapSandboxes
|
|
12
|
-
} from "./chunk-h1td5kq9.mjs";
|
|
13
|
-
import {
|
|
14
|
-
sandboxRuntime,
|
|
15
|
-
PROBE_TOOL
|
|
16
|
-
} from "./chunk-c7dx5mdd.mjs";
|
|
17
|
-
import"./chunk-zvkxtj82.mjs";
|
|
18
|
-
import {
|
|
19
|
-
ToolRegistry,
|
|
20
|
-
DockerEngine,
|
|
21
|
-
sandboxConfig,
|
|
22
|
-
checkSandbox,
|
|
23
|
-
SandboxWorker
|
|
24
|
-
} from "./chunk-9dg1btk1.mjs";
|
|
25
|
-
import {
|
|
26
|
-
databaseConfig
|
|
27
|
-
} from "./chunk-w0qwc5z2.mjs";
|
|
28
|
-
import {
|
|
29
|
-
uuid
|
|
30
|
-
} from "./chunk-1sygmp11.mjs";
|
|
31
|
-
|
|
32
|
-
// apps/harness/src/sandbox/probe.ts
|
|
33
|
-
import { randomUUID } from "node:crypto";
|
|
34
|
-
async function sandboxProbe(args) {
|
|
35
|
-
const [command, argument] = args;
|
|
36
|
-
if (!["check", "run", "cleanup", "reap"].includes(command ?? "") || args.length !== (command === "cleanup" ? 2 : 1) || command === "cleanup" && !uuid().safeParse(argument).success)
|
|
37
|
-
throw new HarnessError("sandbox_command", "Use sandbox check, run, reap, or cleanup <runId>.");
|
|
38
|
-
const config = sandboxConfig();
|
|
39
|
-
const engine = new DockerEngine(config.socket);
|
|
40
|
-
if (command === "check") {
|
|
41
|
-
const workerId = await checkSandbox(config, engine);
|
|
42
|
-
console.log(JSON.stringify({
|
|
43
|
-
configured: true,
|
|
44
|
-
runtime: sandboxRuntime(config),
|
|
45
|
-
workerId,
|
|
46
|
-
image: config.image,
|
|
47
|
-
executed: false,
|
|
48
|
-
productionApproved: false
|
|
49
|
-
}));
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const journal = new SandboxProbeJournal(databaseConfig());
|
|
53
|
-
const controller = new AbortController;
|
|
54
|
-
let lease;
|
|
55
|
-
let heartbeat;
|
|
56
|
-
let heartbeatTask;
|
|
57
|
-
const stop = () => controller.abort();
|
|
58
|
-
process.on("SIGINT", stop);
|
|
59
|
-
process.on("SIGTERM", stop);
|
|
60
|
-
try {
|
|
61
|
-
if (command === "reap") {
|
|
62
|
-
const report = await reapSandboxes(config, engine, journal, controller.signal);
|
|
63
|
-
console.log(JSON.stringify(report));
|
|
64
|
-
if (report.interrupted || report.outcomes.some((outcome) => outcome.status === "blocked"))
|
|
65
|
-
process.exitCode = 1;
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (command === "run")
|
|
69
|
-
await checkSandbox(config, engine);
|
|
70
|
-
const runId = argument ?? randomUUID();
|
|
71
|
-
if (command === "run")
|
|
72
|
-
await journal.createRun(runId, FIXTURE_TARGET, fixtureConfig());
|
|
73
|
-
lease = await journal.acquire(runId);
|
|
74
|
-
const owned = lease;
|
|
75
|
-
heartbeat = setInterval(() => {
|
|
76
|
-
if (heartbeatTask)
|
|
77
|
-
return;
|
|
78
|
-
heartbeatTask = journal.heartbeat(owned).then(async () => {
|
|
79
|
-
if ((await journal.read(runId)).stopRequested)
|
|
80
|
-
controller.abort();
|
|
81
|
-
}).catch(() => controller.abort()).finally(() => {
|
|
82
|
-
heartbeatTask = undefined;
|
|
83
|
-
});
|
|
84
|
-
}, 1000);
|
|
85
|
-
const worker = new SandboxWorker(config, engine, new SandboxJournal(journal, lease));
|
|
86
|
-
if (command === "cleanup") {
|
|
87
|
-
const removed = await worker.reap();
|
|
88
|
-
console.log(JSON.stringify({
|
|
89
|
-
runId,
|
|
90
|
-
removed,
|
|
91
|
-
actionReplayed: false,
|
|
92
|
-
actionReconciled: false
|
|
93
|
-
}));
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
console.log(JSON.stringify({
|
|
97
|
-
runId,
|
|
98
|
-
diagnostic: "offline-sandbox-probe",
|
|
99
|
-
providerCalls: 0
|
|
100
|
-
}));
|
|
101
|
-
const callId = "sandbox-probe-1";
|
|
102
|
-
await journal.beginModel(lease, "sandbox-diagnostic", {
|
|
103
|
-
diagnostic: "offline-sandbox-probe"
|
|
104
|
-
});
|
|
105
|
-
await journal.completeModel(lease, "sandbox-diagnostic", {
|
|
106
|
-
tool_calls: [{ id: callId, name: PROBE_TOOL, args: {} }]
|
|
107
|
-
});
|
|
108
|
-
const executor = new ToolExecutor(journal, lease, controller.signal, new ToolRegistry([worker.tool()]));
|
|
109
|
-
const result = JSON.parse(await executor.execute(callId, PROBE_TOOL, {}));
|
|
110
|
-
await journal.finish(lease, "completed");
|
|
111
|
-
console.log(JSON.stringify({ runId, ...result, productionApproved: false }));
|
|
112
|
-
} finally {
|
|
113
|
-
controller.abort();
|
|
114
|
-
if (heartbeat)
|
|
115
|
-
clearInterval(heartbeat);
|
|
116
|
-
await heartbeatTask;
|
|
117
|
-
if (lease)
|
|
118
|
-
await journal.release(lease).catch(() => {
|
|
119
|
-
return;
|
|
120
|
-
});
|
|
121
|
-
await journal.close();
|
|
122
|
-
process.off("SIGINT", stop);
|
|
123
|
-
process.off("SIGTERM", stop);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// apps/harness/scripts/sandbox.ts
|
|
128
|
-
try {
|
|
129
|
-
await sandboxProbe(process.argv.slice(2));
|
|
130
|
-
} catch (error) {
|
|
131
|
-
console.error(publicError(error));
|
|
132
|
-
process.exitCode = 1;
|
|
133
|
-
}
|