@fungi.computer/computer 0.6.0 → 0.6.1
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/dist/on-box-vm.js +22 -5
- package/dist/team-candidate-builder.mjs +26 -18
- package/package.json +3 -3
package/dist/on-box-vm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import * as Data from "effect/Data";
|
|
3
|
-
import {
|
|
3
|
+
import { SeamReplayPartitions, importSeamSigner, importSeamVerifiers, seamBodyDigest, seamHeader, signSeamRequest, unsignedPayload, verifySeamRequest, } from "@fungi.computer/seam";
|
|
4
4
|
function accessHeaders(env) {
|
|
5
5
|
const id = env.COMPUTER_VM_ACCESS_CLIENT_ID;
|
|
6
6
|
const secret = env.COMPUTER_VM_ACCESS_CLIENT_SECRET;
|
|
@@ -241,7 +241,24 @@ export class OnBoxVmContainerHost {
|
|
|
241
241
|
}
|
|
242
242
|
const ingressPath = /^\/__computer-vm\/([0-9a-f]{64})(\/.*)$/;
|
|
243
243
|
const egressUrlSchema = z.url({ protocol: /^https?$/ });
|
|
244
|
-
|
|
244
|
+
/** Slots one host's vmd can place (`maxSlots` in the celld VM instances). */
|
|
245
|
+
const vmSlotsPerHost = 16_000;
|
|
246
|
+
const ingressReplays = new Map();
|
|
247
|
+
/**
|
|
248
|
+
* Ingress replay history, one bounded partition per VM id. The id is part of
|
|
249
|
+
* the signed path, so one guest's request rate fills only its own VM's
|
|
250
|
+
* history and never refuses another VM on the same or another host. The
|
|
251
|
+
* partition ceiling is every VM the registered hosts can place.
|
|
252
|
+
*/
|
|
253
|
+
function ingressReplay(env, vmId) {
|
|
254
|
+
const raw = env.COMPUTER_VM_HOSTS ?? "{}";
|
|
255
|
+
let replays = ingressReplays.get(raw);
|
|
256
|
+
if (replays === undefined) {
|
|
257
|
+
replays = new SeamReplayPartitions(Math.max(1, Object.keys(hostRegistry(env)).length) * vmSlotsPerHost);
|
|
258
|
+
ingressReplays.set(raw, replays);
|
|
259
|
+
}
|
|
260
|
+
return replays.partition(vmId);
|
|
261
|
+
}
|
|
245
262
|
/**
|
|
246
263
|
* The host service's door into this Worker: a VM's intercepted request
|
|
247
264
|
* reaches its Computer exactly as the platform container's interception
|
|
@@ -258,9 +275,9 @@ export function onBoxVmIngress(request, env, computers) {
|
|
|
258
275
|
return verifiedVmIngress(request, env, computers, id, rest, url.search);
|
|
259
276
|
}
|
|
260
277
|
/** The verified host id of a signed ingress request, or undefined. */
|
|
261
|
-
async function ingressHost(request, env) {
|
|
278
|
+
async function ingressHost(request, env, vmId) {
|
|
262
279
|
try {
|
|
263
|
-
return await verifySeamRequest(await hostVerifiers(env), vmIngressAudience, request.method, request.url, request.headers.get(seamHeader), null, ingressReplay);
|
|
280
|
+
return await verifySeamRequest(await hostVerifiers(env), vmIngressAudience, request.method, request.url, request.headers.get(seamHeader), null, ingressReplay(env, vmId));
|
|
264
281
|
}
|
|
265
282
|
catch (cause) {
|
|
266
283
|
console.error("VM seam verification refused", cause);
|
|
@@ -296,7 +313,7 @@ function vmEgressTarget(target, headers, token, url) {
|
|
|
296
313
|
target.search = "";
|
|
297
314
|
}
|
|
298
315
|
async function verifiedVmIngress(request, env, computers, id, rest, search) {
|
|
299
|
-
const hostId = await ingressHost(request, env);
|
|
316
|
+
const hostId = await ingressHost(request, env, id);
|
|
300
317
|
if (hostId === undefined)
|
|
301
318
|
return new Response(null, { status: 404 });
|
|
302
319
|
const headers = new Headers(request.headers);
|
|
@@ -22548,15 +22548,15 @@ function encodeTeamAppCandidateManifest(manifest) {
|
|
|
22548
22548
|
function candidateManifestObjects(output) {
|
|
22549
22549
|
const objects = [];
|
|
22550
22550
|
const add2 = (object3, mediaType) => {
|
|
22551
|
-
const
|
|
22552
|
-
if (
|
|
22551
|
+
const named = objects.filter(({ digest }) => digest === object3.digest);
|
|
22552
|
+
if (named.some(({ byteLength }) => byteLength !== object3.byteLength))
|
|
22553
|
+
throw new Error("One object digest names two sizes");
|
|
22554
|
+
if (!named.some((seen) => seen.mediaType === mediaType))
|
|
22553
22555
|
objects.push({
|
|
22554
22556
|
digest: object3.digest,
|
|
22555
22557
|
byteLength: object3.byteLength,
|
|
22556
22558
|
mediaType
|
|
22557
22559
|
});
|
|
22558
|
-
else if (seen.byteLength !== object3.byteLength)
|
|
22559
|
-
throw new Error("One object digest names two sizes");
|
|
22560
22560
|
};
|
|
22561
22561
|
if (output.kind !== "backend") {
|
|
22562
22562
|
const { content } = output.ui;
|
|
@@ -24034,26 +24034,24 @@ function sha256(bytes) {
|
|
|
24034
24034
|
`sha256:${createHash2("sha256").update(bytes).digest("hex")}`
|
|
24035
24035
|
);
|
|
24036
24036
|
}
|
|
24037
|
-
function contentArtifactRef(digest) {
|
|
24038
|
-
return parseArtifactRef(`artifact:sha256-${digest.slice("sha256:".length)}`);
|
|
24039
|
-
}
|
|
24040
24037
|
var fallbackRootBytes = 1024 * 1024;
|
|
24041
24038
|
function stageBuildOutput(output) {
|
|
24042
24039
|
const objects = [];
|
|
24043
|
-
const stage = (bytes) => {
|
|
24040
|
+
const stage = (bytes, mediaType) => {
|
|
24044
24041
|
const digest = sha256(bytes);
|
|
24045
|
-
if (!objects.some(
|
|
24046
|
-
|
|
24047
|
-
|
|
24048
|
-
|
|
24049
|
-
digest
|
|
24050
|
-
});
|
|
24042
|
+
if (!objects.some(
|
|
24043
|
+
(object3) => object3.digest === digest && object3.mediaType === mediaType
|
|
24044
|
+
))
|
|
24045
|
+
objects.push({ bytes: bytes.slice(), digest, mediaType });
|
|
24051
24046
|
return { digest, byteLength: bytes.byteLength };
|
|
24052
24047
|
};
|
|
24053
24048
|
const declared = output.declaration === void 0 ? {} : { declaration: output.declaration };
|
|
24054
24049
|
const ui = (prepared) => prepared.content.kind === "html" ? {
|
|
24055
24050
|
mediaType: "text/html; charset=utf-8",
|
|
24056
|
-
content: {
|
|
24051
|
+
content: {
|
|
24052
|
+
kind: "html",
|
|
24053
|
+
...stage(prepared.content.bytes, "text/html; charset=utf-8")
|
|
24054
|
+
}
|
|
24057
24055
|
} : {
|
|
24058
24056
|
mediaType: "application/vnd.fungi.app-assets+json",
|
|
24059
24057
|
content: {
|
|
@@ -24061,14 +24059,24 @@ function stageBuildOutput(output) {
|
|
|
24061
24059
|
base: prepared.content.base,
|
|
24062
24060
|
assets: prepared.content.assets.map((asset) => ({
|
|
24063
24061
|
path: asset.path,
|
|
24064
|
-
...stage(asset.bytes)
|
|
24062
|
+
...stage(asset.bytes, "application/octet-stream")
|
|
24065
24063
|
}))
|
|
24066
24064
|
}
|
|
24067
24065
|
};
|
|
24068
|
-
const manifest = output.kind === "ui" ? { kind: "ui", ui: ui(output.ui), ...declared } : output.kind === "backend" ? {
|
|
24066
|
+
const manifest = output.kind === "ui" ? { kind: "ui", ui: ui(output.ui), ...declared } : output.kind === "backend" ? {
|
|
24067
|
+
kind: "backend",
|
|
24068
|
+
backend: stage(
|
|
24069
|
+
output.backend,
|
|
24070
|
+
"application/vnd.fungi.app-backend+json"
|
|
24071
|
+
),
|
|
24072
|
+
...declared
|
|
24073
|
+
} : {
|
|
24069
24074
|
kind: "app",
|
|
24070
24075
|
ui: ui(output.ui),
|
|
24071
|
-
backend: stage(
|
|
24076
|
+
backend: stage(
|
|
24077
|
+
output.backend,
|
|
24078
|
+
"application/vnd.fungi.app-backend+json"
|
|
24079
|
+
),
|
|
24072
24080
|
...declared
|
|
24073
24081
|
};
|
|
24074
24082
|
return { manifest, objects };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/computer",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Cloudflare Computer host for one durable Fungi Computer",
|
|
6
6
|
"type": "module",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@fungi.computer/cloudflare-computer": "0.2.1-fungi.2",
|
|
62
62
|
"@fungi.computer/cordyceps": "0.4.0",
|
|
63
63
|
"@fungi.computer/knapsack": "0.4.5",
|
|
64
|
-
"@fungi.computer/seam": "0.2.
|
|
64
|
+
"@fungi.computer/seam": "0.2.2",
|
|
65
65
|
"@fungi.computer/watchdog": "0.1.0",
|
|
66
66
|
"@fungi.computer/computer-contract": "0.0.10",
|
|
67
67
|
"effect": "4.0.2",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"test:nightly": "bash ../../tooling/proof-runner/run-proof.sh node test/egress-proof.mjs",
|
|
119
119
|
"test:app-method-execution": "node test/app-method-execution-proof.mjs",
|
|
120
120
|
"test:execution-lifecycle": "node test/execution-lifecycle-proof.mjs",
|
|
121
|
-
"test:unit": "node --test --test-concurrency=${BOTANICAL_TEST_WORKERS:-4} test/egress-policy.test.mjs test/preview.test.mjs test/fleet.test.mjs test/proof-worker.test.mjs test/proof-client.test.mjs test/native-readiness.test.mjs test/workspace-sync.test.mjs test/runtime-observer.test.mjs test/files-patch.test.mjs test/exec-output.test.mjs && node --test --test-concurrency=${BOTANICAL_TEST_WORKERS:-4} test/seam-signature.test.mjs test/local-backend-replay.test.mjs test/machine-link-reopen-replay.test.mjs test/computer-backends.test.mjs test/terminal-welcome.test.mjs test/on-box-vm.test.mjs && node test/terminal-protocol.test.mjs && node test/container-policy.test.mjs && node test/files-adapter-proof.mjs && node test/operation-record-proof.mjs && node test/process-inventory-proof.mjs",
|
|
121
|
+
"test:unit": "bash ../../tooling/proof-runner/hermetic-host.sh -- sh -c \"node --test --test-concurrency=${BOTANICAL_TEST_WORKERS:-4} test/egress-policy.test.mjs test/preview.test.mjs test/fleet.test.mjs test/proof-worker.test.mjs test/proof-client.test.mjs test/native-readiness.test.mjs test/workspace-sync.test.mjs test/runtime-observer.test.mjs test/files-patch.test.mjs test/exec-output.test.mjs && node --test --test-concurrency=${BOTANICAL_TEST_WORKERS:-4} test/seam-signature.test.mjs test/local-backend-replay.test.mjs test/machine-link-reopen-replay.test.mjs test/computer-backends.test.mjs test/terminal-welcome.test.mjs test/on-box-vm.test.mjs && node test/terminal-protocol.test.mjs && node test/container-policy.test.mjs && node test/files-adapter-proof.mjs && node test/operation-record-proof.mjs && node test/process-inventory-proof.mjs\"",
|
|
122
122
|
"test:fleet-native": "node test/fleet.native.mjs",
|
|
123
123
|
"assemble:image": "node scripts/assemble-image.mjs"
|
|
124
124
|
}
|