@fungi.computer/oyster 0.24.0 → 0.26.0
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/agent-instructions.d.ts +35 -0
- package/dist/agent-instructions.js +42 -0
- package/dist/agents.d.ts +14 -0
- package/dist/agents.js +43 -1
- package/dist/app-builds.d.ts +4 -2
- package/dist/app-builds.js +14 -0
- package/dist/apps/catalog.d.ts +11 -0
- package/dist/apps/catalog.js +1 -0
- package/dist/apps/gate.d.ts +2 -2
- package/dist/apps/installation.d.ts +7 -7
- package/dist/apps/permissions.d.ts +5 -5
- package/dist/boot-host-script.js +1 -1
- package/dist/browser/boot-once.d.ts +84 -0
- package/dist/browser/boot-once.js +48 -0
- package/dist/build/build-memory.d.ts +13 -0
- package/dist/build/build-memory.js +29 -0
- package/dist/build/candidate-cli.mjs +25 -2
- package/dist/build/local-build.js +4 -5
- package/dist/cloudflare.d.ts +2 -2
- package/dist/cloudflare.js +3 -0
- package/dist/computer-control-port.d.ts +2 -0
- package/dist/embed-metafiles.js +2 -2
- package/dist/embed-scripts.js +1 -1
- package/dist/installation-operations.d.ts +8 -8
- package/dist/mcp.d.ts +26 -0
- package/dist/mcp.js +12 -2
- package/dist/page-script.js +2 -2
- package/dist/release.d.ts +5 -0
- package/dist/standalone/agents.d.ts +6 -0
- package/dist/standalone/agents.js +46 -3
- package/dist/standalone/app-set.d.ts +4 -3
- package/dist/standalone/app-set.js +9 -5
- package/dist/standalone/computer-control.js +7 -1
- package/dist/standalone/computer-fleet.d.ts +5 -0
- package/dist/standalone/computer-skill-source.d.ts +20 -0
- package/dist/standalone/computer-skill-source.js +165 -0
- package/dist/standalone/computer.d.ts +7 -4
- package/dist/standalone/computer.js +62 -3
- package/dist/standalone/install-apps-cli.js +1 -1
- package/dist/standalone/media.d.ts +1 -1
- package/dist/standalone/registry.d.ts +3 -0
- package/dist/standalone/registry.js +1 -1
- package/dist/standalone/workflow-host.d.ts +5 -5
- package/dist/standalone/workflow-trigger-host.d.ts +1 -1
- package/docs/api/agents.md +18 -0
- package/docs/api/apps.md +148 -131
- package/docs/api/browser/boot-once.md +169 -0
- package/docs/api/build-contract.md +27 -21
- package/docs/api/build.md +70 -69
- package/docs/api/cloudflare.md +4 -1
- package/docs/api/git.md +3 -3
- package/docs/api/host.md +91 -85
- package/docs/api/mcp.md +68 -62
- package/docs/api/modules.md +1 -0
- package/docs/api/workers-git.md +7 -7
- package/docs/api/workers.md +24 -21
- package/package.json +25 -17
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { UiBootCheckOutcome } from "../boot-gate.js";
|
|
2
|
+
/** One Release and the version of the check that judges it. */
|
|
3
|
+
export type BootRunKey = Readonly<{
|
|
4
|
+
releaseId: string;
|
|
5
|
+
checkVersion: string;
|
|
6
|
+
}>;
|
|
7
|
+
/** Why a check could not judge the page. */
|
|
8
|
+
export type NotCheckedCode = Extract<UiBootCheckOutcome, {
|
|
9
|
+
kind: "not_checked";
|
|
10
|
+
}>["code"];
|
|
11
|
+
/** What an ask for the key's run slot learns. */
|
|
12
|
+
export type BootRunClaim = Readonly<{
|
|
13
|
+
kind: "acquired";
|
|
14
|
+
}>
|
|
15
|
+
/** Another asker is running the check right now. */
|
|
16
|
+
| Readonly<{
|
|
17
|
+
kind: "held";
|
|
18
|
+
}>
|
|
19
|
+
/** The last run was inconclusive a moment ago; it is reused, not retried. */
|
|
20
|
+
| Readonly<{
|
|
21
|
+
kind: "cooling";
|
|
22
|
+
code: NotCheckedCode;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* The run slot for one key, in a store every isolate shares (the Hub's
|
|
26
|
+
* catalog D1). `acquire` is one atomic step: it hands the slot to exactly one
|
|
27
|
+
* asker unless a live claim exists, and a claim past its lease is free, so a
|
|
28
|
+
* crashed holder never blocks the Release.
|
|
29
|
+
*/
|
|
30
|
+
export type BootRunClaims = Readonly<{
|
|
31
|
+
/** Take the key's slot, or learn who holds it or why it is cooling. */
|
|
32
|
+
acquire: (input: BootRunKey & Readonly<{
|
|
33
|
+
claimId: string;
|
|
34
|
+
now: number;
|
|
35
|
+
leaseMs: number;
|
|
36
|
+
}>) => Promise<BootRunClaim>;
|
|
37
|
+
/**
|
|
38
|
+
* End the holder's claim. With `cooling`, keep the slot closed for `coolMs`
|
|
39
|
+
* so waiters and new asks share the inconclusive reason; without it the slot
|
|
40
|
+
* is free at once. A claim another asker holds is left alone.
|
|
41
|
+
*/
|
|
42
|
+
finish: (input: BootRunKey & Readonly<{
|
|
43
|
+
claimId: string;
|
|
44
|
+
now: number;
|
|
45
|
+
cooling: Readonly<{
|
|
46
|
+
code: NotCheckedCode;
|
|
47
|
+
coolMs: number;
|
|
48
|
+
}> | null;
|
|
49
|
+
}>) => Promise<void>;
|
|
50
|
+
}>;
|
|
51
|
+
/** Everything one single-flight boot ask needs. */
|
|
52
|
+
export type SingleFlightBootInput = BootRunKey & Readonly<{
|
|
53
|
+
claims: BootRunClaims;
|
|
54
|
+
/** The recorded definitive outcome for the key, or null. */
|
|
55
|
+
recorded: () => Promise<UiBootCheckOutcome | null>;
|
|
56
|
+
/** One check; may open a browser session. */
|
|
57
|
+
run: () => Promise<UiBootCheckOutcome>;
|
|
58
|
+
/** Record a definitive outcome; the stored one wins. */
|
|
59
|
+
record: (outcome: Exclude<UiBootCheckOutcome, {
|
|
60
|
+
kind: "not_checked";
|
|
61
|
+
}>) => Promise<UiBootCheckOutcome>;
|
|
62
|
+
/** The clock, epoch ms. */
|
|
63
|
+
now: () => number;
|
|
64
|
+
/** Wait between polls of a held slot. */
|
|
65
|
+
sleep: (ms: number) => Promise<void>;
|
|
66
|
+
/** A host-minted identity for one attempt to take the slot. */
|
|
67
|
+
newClaimId: () => string;
|
|
68
|
+
/** Longer than one `run`, cleanup included. */
|
|
69
|
+
leaseMs: number;
|
|
70
|
+
pollMs: number;
|
|
71
|
+
/** How long an inconclusive reason is shared. */
|
|
72
|
+
coolMs: number;
|
|
73
|
+
/** The longest a waiter holds on before giving up as `boot_timeout`. */
|
|
74
|
+
maxWaitMs: number;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* At most one boot check per Release and check version is in flight across
|
|
78
|
+
* every caller sharing `claims`. A definitive outcome is recorded and read by
|
|
79
|
+
* everyone after. A waiter reuses whatever the holder produced: the recorded
|
|
80
|
+
* verdict, or its inconclusive reason for `coolMs`. An inconclusive outcome is
|
|
81
|
+
* never a verdict and never reported as a pass; once the cooldown ends the
|
|
82
|
+
* next ask checks again.
|
|
83
|
+
*/
|
|
84
|
+
export declare function singleFlightBoot(input: SingleFlightBootInput): Promise<UiBootCheckOutcome>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* At most one boot check per Release and check version is in flight across
|
|
3
|
+
* every caller sharing `claims`. A definitive outcome is recorded and read by
|
|
4
|
+
* everyone after. A waiter reuses whatever the holder produced: the recorded
|
|
5
|
+
* verdict, or its inconclusive reason for `coolMs`. An inconclusive outcome is
|
|
6
|
+
* never a verdict and never reported as a pass; once the cooldown ends the
|
|
7
|
+
* next ask checks again.
|
|
8
|
+
*/
|
|
9
|
+
export async function singleFlightBoot(input) {
|
|
10
|
+
const key = { releaseId: input.releaseId, checkVersion: input.checkVersion };
|
|
11
|
+
const startedAt = input.now();
|
|
12
|
+
for (;;) {
|
|
13
|
+
const stored = await input.recorded();
|
|
14
|
+
if (stored !== null)
|
|
15
|
+
return stored;
|
|
16
|
+
const claimId = input.newClaimId();
|
|
17
|
+
const claim = await input.claims.acquire({
|
|
18
|
+
...key,
|
|
19
|
+
claimId,
|
|
20
|
+
now: input.now(),
|
|
21
|
+
leaseMs: input.leaseMs,
|
|
22
|
+
});
|
|
23
|
+
if (claim.kind === "cooling")
|
|
24
|
+
return { kind: "not_checked", code: claim.code };
|
|
25
|
+
if (claim.kind === "acquired")
|
|
26
|
+
return await held(input, key, claimId);
|
|
27
|
+
if (input.now() - startedAt >= input.maxWaitMs)
|
|
28
|
+
return { kind: "not_checked", code: "boot_timeout" };
|
|
29
|
+
await input.sleep(input.pollMs);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function held(input, key, claimId) {
|
|
33
|
+
let cooling = null;
|
|
34
|
+
try {
|
|
35
|
+
// A verdict recorded between the read and the claim needs no run.
|
|
36
|
+
const stored = await input.recorded();
|
|
37
|
+
if (stored !== null)
|
|
38
|
+
return stored;
|
|
39
|
+
const outcome = await input.run();
|
|
40
|
+
if (outcome.kind !== "not_checked")
|
|
41
|
+
return await input.record(outcome);
|
|
42
|
+
cooling = { code: outcome.code, coolMs: input.coolMs };
|
|
43
|
+
return outcome;
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
await input.claims.finish({ ...key, claimId, now: input.now(), cooling });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The memory this process may use, in MiB: its cgroup limit when it has one,
|
|
3
|
+
* else the machine's. A Computer is a VM of 4, 8 or 16 GiB (or a 12 GiB
|
|
4
|
+
* container), so the build must read it rather than assume one.
|
|
5
|
+
*/
|
|
6
|
+
export declare function machineMemoryMib(): number;
|
|
7
|
+
/** The compiler heap ceiling: 4 GiB, or two thirds of a smaller machine. */
|
|
8
|
+
export declare function buildHeapMib(memoryMib: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* How many builds fit at once: one per 6 GiB, at most two by default (a third
|
|
11
|
+
* is allowed only when asked for), at least one.
|
|
12
|
+
*/
|
|
13
|
+
export declare function defaultBuildConcurrency(memoryMib: number): number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { totalmem } from "node:os";
|
|
2
|
+
const mebibyte = 1024 * 1024;
|
|
3
|
+
/** What one Bonsai-sized compile wants: a 4 GiB heap. */
|
|
4
|
+
const preferredHeapMib = 4096;
|
|
5
|
+
/** Heap plus pnpm and esbuild beside it: 4 GiB and 2 GiB. */
|
|
6
|
+
const memoryPerBuildMib = 6144;
|
|
7
|
+
/** Builds a machine runs at once unless the caller asks for more. */
|
|
8
|
+
const preferredBuildConcurrency = 2;
|
|
9
|
+
/**
|
|
10
|
+
* The memory this process may use, in MiB: its cgroup limit when it has one,
|
|
11
|
+
* else the machine's. A Computer is a VM of 4, 8 or 16 GiB (or a 12 GiB
|
|
12
|
+
* container), so the build must read it rather than assume one.
|
|
13
|
+
*/
|
|
14
|
+
export function machineMemoryMib() {
|
|
15
|
+
const constrained = process.constrainedMemory();
|
|
16
|
+
const bytes = constrained > 0 && constrained < totalmem() ? constrained : totalmem();
|
|
17
|
+
return Math.floor(bytes / mebibyte);
|
|
18
|
+
}
|
|
19
|
+
/** The compiler heap ceiling: 4 GiB, or two thirds of a smaller machine. */
|
|
20
|
+
export function buildHeapMib(memoryMib) {
|
|
21
|
+
return Math.min(preferredHeapMib, Math.floor((memoryMib * 2) / 3));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* How many builds fit at once: one per 6 GiB, at most two by default (a third
|
|
25
|
+
* is allowed only when asked for), at least one.
|
|
26
|
+
*/
|
|
27
|
+
export function defaultBuildConcurrency(memoryMib) {
|
|
28
|
+
return Math.max(1, Math.min(preferredBuildConcurrency, Math.floor(memoryMib / memoryPerBuildMib)));
|
|
29
|
+
}
|
|
@@ -19604,6 +19604,16 @@ var appBackendBindingKinds = {
|
|
|
19604
19604
|
requires: ["computer.writeFile"],
|
|
19605
19605
|
effect: "write"
|
|
19606
19606
|
},
|
|
19607
|
+
mkdir: {
|
|
19608
|
+
cap: "app.computer.write",
|
|
19609
|
+
requires: ["computer.writeFile"],
|
|
19610
|
+
effect: "write"
|
|
19611
|
+
},
|
|
19612
|
+
move: {
|
|
19613
|
+
cap: "app.computer.write",
|
|
19614
|
+
requires: ["computer.writeFile"],
|
|
19615
|
+
effect: "write"
|
|
19616
|
+
},
|
|
19607
19617
|
preview: {
|
|
19608
19618
|
cap: "app.computer.exec",
|
|
19609
19619
|
requires: ["computer.execute"],
|
|
@@ -19677,6 +19687,7 @@ var appCapabilityIds = [
|
|
|
19677
19687
|
"agent.manage",
|
|
19678
19688
|
"agent.rename",
|
|
19679
19689
|
"agent.avatar",
|
|
19690
|
+
"agent.instructions",
|
|
19680
19691
|
"agent.toolPolicy",
|
|
19681
19692
|
"agent.read",
|
|
19682
19693
|
"agent.send",
|
|
@@ -22488,6 +22499,19 @@ import { join as join6 } from "node:path";
|
|
|
22488
22499
|
// src/build.ts
|
|
22489
22500
|
init_snapshot_program_scripts();
|
|
22490
22501
|
|
|
22502
|
+
// src/build/build-memory.ts
|
|
22503
|
+
import { totalmem } from "node:os";
|
|
22504
|
+
var mebibyte = 1024 * 1024;
|
|
22505
|
+
var preferredHeapMib = 4096;
|
|
22506
|
+
function machineMemoryMib() {
|
|
22507
|
+
const constrained = process.constrainedMemory();
|
|
22508
|
+
const bytes = constrained > 0 && constrained < totalmem() ? constrained : totalmem();
|
|
22509
|
+
return Math.floor(bytes / mebibyte);
|
|
22510
|
+
}
|
|
22511
|
+
function buildHeapMib(memoryMib) {
|
|
22512
|
+
return Math.min(preferredHeapMib, Math.floor(memoryMib * 2 / 3));
|
|
22513
|
+
}
|
|
22514
|
+
|
|
22491
22515
|
// src/build/process-group.ts
|
|
22492
22516
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
22493
22517
|
var CleanupError = class extends Error {
|
|
@@ -35736,13 +35760,12 @@ function runHtmlCommand(args2, cwd, env, command = "pnpm", onOutput) {
|
|
|
35736
35760
|
function snapshotPrograms() {
|
|
35737
35761
|
return Promise.resolve().then(() => (init_snapshot_program_scripts(), snapshot_program_scripts_exports));
|
|
35738
35762
|
}
|
|
35739
|
-
var snapshotBuildHeapMegabytes = 4096;
|
|
35740
35763
|
function snapshotBuildEnvironment(sourceSnapshotPath) {
|
|
35741
35764
|
const env = {
|
|
35742
35765
|
PATH: process.env.PATH ?? "/usr/bin:/bin",
|
|
35743
35766
|
HOME: join5(sourceSnapshotPath, ".publisher-home"),
|
|
35744
35767
|
NODE_ENV: "production",
|
|
35745
|
-
NODE_OPTIONS: `--max-old-space-size=${String(
|
|
35768
|
+
NODE_OPTIONS: `--max-old-space-size=${String(buildHeapMib(machineMemoryMib()))}`,
|
|
35746
35769
|
NODE_EXTRA_CA_CERTS: process.env.NODE_EXTRA_CA_CERTS,
|
|
35747
35770
|
SSL_CERT_FILE: process.env.SSL_CERT_FILE,
|
|
35748
35771
|
npm_config_userconfig: "/dev/null",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildHeapMib, machineMemoryMib } from "./build-memory.js";
|
|
1
2
|
import { CleanupError, stopProcessGroup } from "./process-group.js";
|
|
2
3
|
import { addAbortListener } from "node:events";
|
|
3
4
|
import { Buffer } from "node:buffer";
|
|
@@ -621,19 +622,17 @@ function runHtmlCommand(args, cwd, env, command = "pnpm", onOutput) {
|
|
|
621
622
|
function snapshotPrograms() {
|
|
622
623
|
return import("#snapshot-program-scripts");
|
|
623
624
|
}
|
|
624
|
-
/** Compiler heap ceiling: fits a 12 GiB Computer with two builds at once. */
|
|
625
|
-
const snapshotBuildHeapMegabytes = 4096;
|
|
626
625
|
function snapshotBuildEnvironment(sourceSnapshotPath) {
|
|
627
626
|
// PATH locates pinned executables; the Computer's CA files authenticate
|
|
628
627
|
// its egress gateway. Credentials and package-manager settings stay out.
|
|
629
628
|
// V8 sizes its default heap from the machine, about 3 GB in a 12 GiB
|
|
630
|
-
//
|
|
631
|
-
//
|
|
629
|
+
// Computer, where compiling Bonsai runs out; the build owns its ceiling
|
|
630
|
+
// instead, 4 GiB or two thirds of a smaller Computer (see build-memory.ts).
|
|
632
631
|
const env = {
|
|
633
632
|
PATH: process.env.PATH ?? "/usr/bin:/bin",
|
|
634
633
|
HOME: join(sourceSnapshotPath, ".publisher-home"),
|
|
635
634
|
NODE_ENV: "production",
|
|
636
|
-
NODE_OPTIONS: `--max-old-space-size=${String(
|
|
635
|
+
NODE_OPTIONS: `--max-old-space-size=${String(buildHeapMib(machineMemoryMib()))}`,
|
|
637
636
|
NODE_EXTRA_CA_CERTS: process.env.NODE_EXTRA_CA_CERTS,
|
|
638
637
|
SSL_CERT_FILE: process.env.SSL_CERT_FILE,
|
|
639
638
|
npm_config_userconfig: "/dev/null",
|
package/dist/cloudflare.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type { BackgroundFrameState } from "./invocation.js";
|
|
|
4
4
|
import { WorkerEntrypoint } from "cloudflare:workers";
|
|
5
5
|
import { type GuestLimits } from "./guest-policy.js";
|
|
6
6
|
export type { GuestLimits } from "./guest-policy.js";
|
|
7
|
-
import type { ArtifactHeads, ArtifactStore, ArtifactStreams, VerifiedObjectCache } from "./release.js";
|
|
7
|
+
import type { ArtifactHeads, ArtifactDeletes, ArtifactStore, ArtifactStreams, VerifiedObjectCache } from "./release.js";
|
|
8
8
|
import { type AppBackendBindingName } from "@fungi.computer/puffball/app";
|
|
9
9
|
import { type InvocationFrame, type InvocationGate } from "./invocation.js";
|
|
10
10
|
import * as Schema from "effect/Schema";
|
|
@@ -22,7 +22,7 @@ import { AppInstanceError, type AppInstance, type InstancePorts } from "./index.
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function edgeVerifiedObjectCache(cache: Pick<Cache, "match" | "put">, origin: string): VerifiedObjectCache;
|
|
24
24
|
/** Store Release artifacts without loading the Worker ownership barrel. */
|
|
25
|
-
export declare function r2ArtifactStore(bucket: R2Bucket): ArtifactStore & ArtifactHeads & ArtifactStreams;
|
|
25
|
+
export declare function r2ArtifactStore(bucket: R2Bucket): ArtifactStore & ArtifactHeads & ArtifactStreams & ArtifactDeletes;
|
|
26
26
|
/** Encode supervisor refusals before native RPC can discard Error properties. */
|
|
27
27
|
export declare function captureFrameBindingReply<Value>(run: () => Promise<Value>): Promise<FrameBindingReply<Value>>;
|
|
28
28
|
/** Retained shard reply ceiling; replies settle before the frame aborts its facet. */
|
package/dist/cloudflare.js
CHANGED
|
@@ -109,6 +109,9 @@ export function r2ArtifactStore(bucket) {
|
|
|
109
109
|
async put(artifactRef, bytes) {
|
|
110
110
|
await bucket.put(artifactRef, bytes);
|
|
111
111
|
},
|
|
112
|
+
async delete(artifactRef) {
|
|
113
|
+
await bucket.delete(artifactRef);
|
|
114
|
+
},
|
|
112
115
|
};
|
|
113
116
|
}
|
|
114
117
|
/** Encode supervisor refusals before native RPC can discard Error properties. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
|
+
import type { ComputerSize } from "@fungi.computer/computer/backing";
|
|
2
3
|
import type { computerCreateRequestSchema, computerPageSchema } from "@fungi.computer/computer/fleet/inventory-wire";
|
|
3
4
|
import type { computerBackendViewSchema, computerStateSchema, LocalBackendAttachInput } from "@fungi.computer/computer/fleet/wire";
|
|
4
5
|
import type { teamComputerDirectorySchema } from "@fungi.computer/nacre/workbench";
|
|
@@ -19,6 +20,7 @@ export type ComputerControlPort = Readonly<{
|
|
|
19
20
|
computer: {
|
|
20
21
|
computerId: string;
|
|
21
22
|
name: string;
|
|
23
|
+
size: ComputerSize;
|
|
22
24
|
};
|
|
23
25
|
} | {
|
|
24
26
|
kind: "uncertain" | "denied" | "conflict" | "invalid";
|