@fungi.computer/oyster 0.25.0 → 0.27.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/agents.d.ts +24 -8
- package/dist/agents.js +12 -5
- package/dist/app-builds.d.ts +4 -2
- package/dist/app-builds.js +14 -0
- package/dist/apps/catalog.js +1 -1
- package/dist/boot-host-script.js +1 -1
- 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/hello-app-script.js +1 -1
- package/dist/mcp.d.ts +26 -0
- package/dist/mcp.js +12 -2
- package/dist/media.d.ts +5 -0
- package/dist/media.js +1 -0
- package/dist/page-script.js +2 -2
- package/dist/release.d.ts +5 -0
- package/dist/standalone/agent-computers.js +17 -1
- package/dist/standalone/agents.d.ts +16 -8
- package/dist/standalone/agents.js +88 -25
- package/dist/standalone/app-set.d.ts +11 -3
- package/dist/standalone/app-set.js +26 -8
- package/dist/standalone/computer-control.js +7 -1
- package/dist/standalone/computer-fleet.d.ts +6 -0
- package/dist/standalone/computer-fleet.js +9 -1
- 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 +30 -4
- package/dist/standalone/computer.js +60 -3
- package/dist/standalone/install-apps-cli.js +9 -3
- package/dist/standalone/media.d.ts +9 -4
- package/dist/standalone/media.js +76 -7
- package/dist/standalone/registry.d.ts +8 -1
- package/dist/standalone/registry.js +10 -1
- package/docs/api/agents.md +204 -214
- package/docs/api/apps.md +33 -33
- package/docs/api/cloudflare.md +4 -1
- package/docs/api/mcp.md +52 -46
- package/docs/api/media.md +4 -0
- package/docs/api/workers-git.md +7 -7
- package/examples/standalone/wrangler.jsonc +3 -0
- package/package.json +19 -23
- package/dist/agent-instructions.d.ts +0 -35
- package/dist/agent-instructions.js +0 -42
package/dist/release.d.ts
CHANGED
|
@@ -15,6 +15,11 @@ export type ArtifactHead = Readonly<{
|
|
|
15
15
|
/** The digest the store verified when it took the bytes, if it did. */
|
|
16
16
|
digest: Sha256Digest | null;
|
|
17
17
|
}>;
|
|
18
|
+
/** A store that can remove one object; only host-owned namespaces use it. */
|
|
19
|
+
export type ArtifactDeletes = Readonly<{
|
|
20
|
+
/** Remove the object at `artifactRef`; a missing object is not an error. */
|
|
21
|
+
delete: (artifactRef: ArtifactRef) => Promise<void>;
|
|
22
|
+
}>;
|
|
18
23
|
/** A store that can describe an object without reading its bytes. */
|
|
19
24
|
export type ArtifactHeads = Readonly<{
|
|
20
25
|
/** Describe the object at `artifactRef`, or `null` when absent. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createComputerFilesPort } from "@fungi.computer/computer";
|
|
2
2
|
import { checkComputerGrant, FleetGrantRefused, } from "@fungi.computer/computer/fleet";
|
|
3
|
-
import { computerCapabilities, computerValueSchema, } from "@fungi.computer/computer-contract";
|
|
3
|
+
import { ComputerCommandTooLongError, computerCapabilities, computerValueSchema, parseComputerExecInput, } from "@fungi.computer/computer-contract";
|
|
4
|
+
import { CapabilityFailed, } from "@fungi.computer/mycelium";
|
|
4
5
|
import { attachComputerInputSchema, detachComputerInputSchema, readAgentComputersInputSchema, } from "../agent-computers.js";
|
|
5
6
|
import {} from "../host.js";
|
|
6
7
|
import { owner, routes as routeTable } from "../authorization.js";
|
|
@@ -80,6 +81,21 @@ export function standaloneAgentComputerPorts(access, connection) {
|
|
|
80
81
|
},
|
|
81
82
|
call: async (capabilityId, input, context) => {
|
|
82
83
|
context.signal.throwIfAborted();
|
|
84
|
+
if (capabilityId === "bash" || capabilityId === "exec") {
|
|
85
|
+
try {
|
|
86
|
+
parseComputerExecInput(input);
|
|
87
|
+
}
|
|
88
|
+
catch (cause) {
|
|
89
|
+
// The refusal is the owner's own words to the person and the model.
|
|
90
|
+
if (cause instanceof ComputerCommandTooLongError)
|
|
91
|
+
throw new CapabilityFailed({
|
|
92
|
+
namespace: "computer",
|
|
93
|
+
operation: capabilityId,
|
|
94
|
+
cause: { kind: "OperationFailed", message: cause.message },
|
|
95
|
+
});
|
|
96
|
+
throw cause;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
83
99
|
// tool() retains the native advertised-operation/action mapping and decoders.
|
|
84
100
|
const grant = await access.admit(connection);
|
|
85
101
|
context.signal.throwIfAborted();
|
|
@@ -22,7 +22,7 @@ import { type AgentComputerSnapshot, type AgentComputerConnection } from "../age
|
|
|
22
22
|
import { type StandaloneAgentComputerReply } from "./agent-computers.js";
|
|
23
23
|
import { type ComputerGrant } from "@fungi.computer/computer/fleet";
|
|
24
24
|
import { DurableObject } from "cloudflare:workers";
|
|
25
|
-
import type
|
|
25
|
+
import { type StandaloneComputerEnv } from "./computer.js";
|
|
26
26
|
import { ShiitakeDO } from "@fungi.computer/shiitake/cloudflare";
|
|
27
27
|
import { type ModelKeyRecord, type ModelKeyRefusal, type ModelKeySealInput } from "./model-key-vault.js";
|
|
28
28
|
import type { CloudflareShiitakeOptions } from "@fungi.computer/shiitake/cloudflare";
|
|
@@ -43,7 +43,7 @@ import type { HostActor } from "@fungi.computer/puffball/app";
|
|
|
43
43
|
import type { OysterWorkerEnv } from "../workers.js";
|
|
44
44
|
import type { ConnectionAccess, ConnectionInput } from "../agents.js";
|
|
45
45
|
import type { EgressRef, McpRequestData } from "@fungi.computer/veil/connections";
|
|
46
|
-
import type { AgentPolicyActor, OysterAgents, OysterSessionRow } from "../agents.js";
|
|
46
|
+
import type { OysterAgentInstructions, AgentPolicyActor, OysterAgents, OysterSessionRow } from "../agents.js";
|
|
47
47
|
/** The model door an agent runs on; Shiitake's own contract. */
|
|
48
48
|
export type StandaloneModelSource = CloudflareShiitakeOptions["model"];
|
|
49
49
|
/** One directory entry: an agent's id, display name and own avatar. */
|
|
@@ -268,12 +268,20 @@ export declare abstract class StandaloneAgentBase<Env extends StandaloneAgentEnv
|
|
|
268
268
|
/** A byok choice must name a stored key of the chosen provider. */
|
|
269
269
|
private admitKey;
|
|
270
270
|
private choice;
|
|
271
|
-
|
|
272
|
-
private
|
|
273
|
-
/**
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
271
|
+
/** Which Home this Agent uses: its recorded choice, else its only attachment. */
|
|
272
|
+
private homeComputer;
|
|
273
|
+
/**
|
|
274
|
+
* The AGENTS.md on this Agent's Home Computer. The host admits the owner
|
|
275
|
+
* first; `actor` names who the Computer's grant records.
|
|
276
|
+
*/
|
|
277
|
+
readInstructions(actor: string): Promise<OysterAgentInstructions>;
|
|
278
|
+
/**
|
|
279
|
+
* Replace it only if it still holds what the owner read; null creates it only
|
|
280
|
+
* while absent. The next run follows the new text; a run already going does not.
|
|
281
|
+
*/
|
|
282
|
+
replaceInstructions(actor: string, expectedContent: string | null, content: string): Promise<OysterAgentInstructions | Readonly<{
|
|
283
|
+
error: "conflict" | "too_large" | "no_home";
|
|
284
|
+
}>>;
|
|
277
285
|
/** Secret-free default of this Agent; stored separately from Session history. */
|
|
278
286
|
readModelChoice(): Promise<AgentModelChoice>;
|
|
279
287
|
setModelChoice(input: AgentModelChoice): Promise<AgentModelChoice | Readonly<{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { agentCodeExecutionTimeoutMs } from "@fungi.computer/computer-contract";
|
|
1
2
|
import { isRetryableProviderRejection, normalizeModel, observeProviderStatus, streamModel, } from "@fungi.computer/mule/effect";
|
|
2
3
|
import { standaloneTenancy, } from "./tenancy.js";
|
|
3
|
-
import { AcceptedSchema } from "@fungi.computer/shiitake/client";
|
|
4
|
+
import { AcceptedSchema, bindSessionExtension, } from "@fungi.computer/shiitake/client";
|
|
4
5
|
import { createShiitakeClient } from "@fungi.computer/shiitake/client";
|
|
5
6
|
import { ShiitakeError } from "@fungi.computer/shiitake";
|
|
6
7
|
import { AgentArchiveRefused, AgentCreateRefused, } from "@fungi.computer/shiitake/agent-control";
|
|
@@ -16,7 +17,7 @@ import { createDiscordReplies, } from "../channels/discord-replies.js";
|
|
|
16
17
|
import { isDiscordBinding, createDiscordBindings, createDiscordInputSchema, updateDiscordInputSchema, } from "../channels/discord-binding.js";
|
|
17
18
|
import { DISCORD_SETTLEMENT_WAIT_MS, discordDenial, discordFailureText, patchOriginal, postChannelMessage, postFollowUp, quoted, STILL_WORKING_TEXT, splitDiscordMessage, registerAskCommand, } from "../channels/discord-interactions.js";
|
|
18
19
|
import { discordOutcome, sealDiscordToken, } from "./discord-channels.js";
|
|
19
|
-
import {
|
|
20
|
+
import { computerSkillsEmpty, createComputerSkillSource, } from "./computer-skill-source.js";
|
|
20
21
|
import { channelSessionDoor } from "./channel-session-door.js";
|
|
21
22
|
import { createAuthenticatedVisitorChannel } from "../channels/visitor-channel.js";
|
|
22
23
|
import { verifyVisitor } from "./visitor-proof.js";
|
|
@@ -37,8 +38,10 @@ import { createAgentComputerSource, readAgentComputerConnections, } from "../age
|
|
|
37
38
|
import { standaloneAgentComputerPorts, standaloneBrowserSave, } from "./agent-computers.js";
|
|
38
39
|
import { FleetGrantRefused, } from "@fungi.computer/computer/fleet";
|
|
39
40
|
import { homeExtension, homeGrant, } from "@fungi.computer/shiitake-extensions/home/host";
|
|
40
|
-
import { homeContract } from "@fungi.computer/shiitake-extensions/home";
|
|
41
|
+
import { homeContract, homeInstructionsLimit, } from "@fungi.computer/shiitake-extensions/home";
|
|
42
|
+
import { resolveHome } from "@fungi.computer/shiitake-extensions/home/host";
|
|
41
43
|
import { DurableObject } from "cloudflare:workers";
|
|
44
|
+
import { standaloneHomeInstructionsFile, } from "./computer.js";
|
|
42
45
|
import { ShiitakeDO } from "@fungi.computer/shiitake/cloudflare";
|
|
43
46
|
import { agentStoreKeeping } from "./agent-store.js";
|
|
44
47
|
import { CredentialError, } from "@fungi.computer/veil/credential-store";
|
|
@@ -71,8 +74,24 @@ import { agentCeiling, oysterPrincipalIsOwner } from "../authorization.js";
|
|
|
71
74
|
import { defaultTenant, tenantIdSchema, tenantScope, } from "../tenant.js";
|
|
72
75
|
import { createCodemodeSandbox } from "@fungi.computer/mycelium/workers";
|
|
73
76
|
import { forageDiscoveryInstructions } from "@fungi.computer/mycelium/effect";
|
|
77
|
+
const noHomeInstructions = {
|
|
78
|
+
home: null,
|
|
79
|
+
content: null,
|
|
80
|
+
bytes: 0,
|
|
81
|
+
limit: homeInstructionsLimit,
|
|
82
|
+
};
|
|
83
|
+
function homeInstructions(home, content) {
|
|
84
|
+
return {
|
|
85
|
+
home: { name: home },
|
|
86
|
+
content,
|
|
87
|
+
bytes: content === null ? 0 : new TextEncoder().encode(content).byteLength,
|
|
88
|
+
limit: homeInstructionsLimit,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** Shown when the AI Gateway spend limit blocks a model call; same sentence as media. */
|
|
92
|
+
const DAILY_LIMIT_COPY = "Today's spending limit for this Oyster is used up. It resets at 00:00 UTC.";
|
|
74
93
|
/** Own transport evidence and exact-message decisions for one model lease. */
|
|
75
|
-
function observedModels(model, defaults) {
|
|
94
|
+
function observedModels(model, defaults, gatewaySpendLimit = false) {
|
|
76
95
|
return {
|
|
77
96
|
acquire: ({ signal }) => {
|
|
78
97
|
const retryableMessages = new WeakSet();
|
|
@@ -80,7 +99,13 @@ function observedModels(model, defaults) {
|
|
|
80
99
|
const failure = (message, rejection) => {
|
|
81
100
|
// Pi can include raw response bodies in errorMessage. No provider
|
|
82
101
|
// prose enters a Session, retry journal, model context or diagnostics.
|
|
83
|
-
|
|
102
|
+
// The gateway publishes no body code for a spend-limit block, only 429,
|
|
103
|
+
// and Oyster configures no gateway rate-limit rule. A 429 through the
|
|
104
|
+
// gateway therefore means the daily spend limit; retrying cannot help.
|
|
105
|
+
const spendLimit = gatewaySpendLimit && rejection?.code === "rate-limit";
|
|
106
|
+
const safe = spendLimit
|
|
107
|
+
? DAILY_LIMIT_COPY
|
|
108
|
+
: `Model request failed (${rejection?.code ?? "provider_rejected"}). Retry the request.`;
|
|
84
109
|
const terminal = {
|
|
85
110
|
role: "assistant",
|
|
86
111
|
content: [],
|
|
@@ -93,7 +118,7 @@ function observedModels(model, defaults) {
|
|
|
93
118
|
timestamp: message.timestamp,
|
|
94
119
|
};
|
|
95
120
|
safeFailures.set(terminal, safe);
|
|
96
|
-
if (isRetryableProviderRejection(rejection))
|
|
121
|
+
if (!spendLimit && isRetryableProviderRejection(rejection))
|
|
97
122
|
retryableMessages.add(terminal);
|
|
98
123
|
return terminal;
|
|
99
124
|
};
|
|
@@ -254,7 +279,7 @@ function workersAiModels(ai, options) {
|
|
|
254
279
|
};
|
|
255
280
|
if (options.reasoning !== undefined)
|
|
256
281
|
streamOptions.reasoning = options.reasoning;
|
|
257
|
-
return observedModels(normalizeModel(model), streamOptions);
|
|
282
|
+
return observedModels(normalizeModel(model), streamOptions, true);
|
|
258
283
|
}
|
|
259
284
|
const policyDirectorySchema = Schema.Struct({
|
|
260
285
|
directoryName: Schema.NonEmptyString,
|
|
@@ -1039,17 +1064,40 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
1039
1064
|
});
|
|
1040
1065
|
});
|
|
1041
1066
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1067
|
+
/** Which Home this Agent uses: its recorded choice, else its only attachment. */
|
|
1068
|
+
async homeComputer() {
|
|
1069
|
+
const attachments = (await this.preparedComputerSnapshot())?.projection.attachments ?? [];
|
|
1070
|
+
// Home's choice is Agent state; any Session id projects it, run or not.
|
|
1071
|
+
const session = (await this.shiitake()).session("home-choice");
|
|
1072
|
+
const view = bindSessionExtension(session, homeContract).view(await session.read());
|
|
1073
|
+
const chosen = resolveHome(view.status === "running" ? view.value : null, attachments);
|
|
1074
|
+
return attachments.find(({ attachmentId }) => attachmentId === chosen?.attachmentId);
|
|
1045
1075
|
}
|
|
1046
|
-
/**
|
|
1047
|
-
|
|
1048
|
-
|
|
1076
|
+
/**
|
|
1077
|
+
* The AGENTS.md on this Agent's Home Computer. The host admits the owner
|
|
1078
|
+
* first; `actor` names who the Computer's grant records.
|
|
1079
|
+
*/
|
|
1080
|
+
async readInstructions(actor) {
|
|
1081
|
+
const home = await this.homeComputer();
|
|
1082
|
+
if (home === undefined)
|
|
1083
|
+
return noHomeInstructions;
|
|
1084
|
+
const content = await standaloneHomeInstructionsFile(this.env.COMPUTER.getByName(home.computerId), home.computerId, actor).read();
|
|
1085
|
+
return homeInstructions(home.name, content);
|
|
1049
1086
|
}
|
|
1050
|
-
/**
|
|
1051
|
-
|
|
1052
|
-
|
|
1087
|
+
/**
|
|
1088
|
+
* Replace it only if it still holds what the owner read; null creates it only
|
|
1089
|
+
* while absent. The next run follows the new text; a run already going does not.
|
|
1090
|
+
*/
|
|
1091
|
+
async replaceInstructions(actor, expectedContent, content) {
|
|
1092
|
+
if (new TextEncoder().encode(content).byteLength > homeInstructionsLimit)
|
|
1093
|
+
return { error: "too_large" };
|
|
1094
|
+
const home = await this.homeComputer();
|
|
1095
|
+
if (home === undefined)
|
|
1096
|
+
return { error: "no_home" };
|
|
1097
|
+
const result = await standaloneHomeInstructionsFile(this.env.COMPUTER.getByName(home.computerId), home.computerId, actor).replace(expectedContent, content);
|
|
1098
|
+
return result.kind === "conflict"
|
|
1099
|
+
? { error: "conflict" }
|
|
1100
|
+
: homeInstructions(home.name, content);
|
|
1053
1101
|
}
|
|
1054
1102
|
/** Secret-free default of this Agent; stored separately from Session history. */
|
|
1055
1103
|
async readModelChoice() {
|
|
@@ -1228,7 +1276,16 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
1228
1276
|
return () => this.computerInvalidations.delete(invalidate);
|
|
1229
1277
|
},
|
|
1230
1278
|
});
|
|
1231
|
-
|
|
1279
|
+
// Skills the owner put on the Agent's Computer, found by the rules Local uses on a disk.
|
|
1280
|
+
const extensions = oysterAgentExtensions(conversationAgents.source(this.controlDirectory()), {
|
|
1281
|
+
source: createComputerSkillSource({
|
|
1282
|
+
computers: async () => {
|
|
1283
|
+
await this.preparedComputerSnapshot();
|
|
1284
|
+
return readAgentComputerConnections(this.computerConnections()).map(({ name, files }) => ({ name, port: files.port }));
|
|
1285
|
+
},
|
|
1286
|
+
}),
|
|
1287
|
+
empty: computerSkillsEmpty,
|
|
1288
|
+
});
|
|
1232
1289
|
const keeping = agentStoreKeeping(this.ctx.storage, (request) => this.readColdSessions(request));
|
|
1233
1290
|
const principal = {
|
|
1234
1291
|
actor: { kind: "agent", agentId: this.ctx.id.name ?? "agent" },
|
|
@@ -1249,13 +1306,19 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
1249
1306
|
instructions: this.channelInstructions({
|
|
1250
1307
|
load: async () => {
|
|
1251
1308
|
const { appApprovalInstructions } = await import("../mcp.js");
|
|
1252
|
-
return
|
|
1309
|
+
return {
|
|
1253
1310
|
revision: "oyster-7",
|
|
1254
1311
|
text: instructions + "\n" + appApprovalInstructions,
|
|
1255
|
-
}
|
|
1312
|
+
};
|
|
1256
1313
|
},
|
|
1257
1314
|
}),
|
|
1258
1315
|
tools: {
|
|
1316
|
+
// A run outlasts one ten-minute Computer command; waiting for a
|
|
1317
|
+
// sandbox slot keeps its shorter bound.
|
|
1318
|
+
execution: {
|
|
1319
|
+
timeoutMs: agentCodeExecutionTimeoutMs,
|
|
1320
|
+
admissionWaitMs: 180_000,
|
|
1321
|
+
},
|
|
1259
1322
|
sources: [
|
|
1260
1323
|
{
|
|
1261
1324
|
id: "oyster-apps",
|
|
@@ -1683,6 +1746,8 @@ export class AgentDirectory extends DurableObject {
|
|
|
1683
1746
|
}
|
|
1684
1747
|
constructor(ctx, env) {
|
|
1685
1748
|
super(ctx, env);
|
|
1749
|
+
// 0.33.0 kept owner text here; instructions now live in Home's AGENTS.md.
|
|
1750
|
+
ctx.storage.sql.exec("DROP TABLE IF EXISTS agent_instructions");
|
|
1686
1751
|
this.directory = createAgentDirectory(ctx.storage.sql);
|
|
1687
1752
|
this.avatars = createAgentAvatarStore(ctx.storage.sql);
|
|
1688
1753
|
this.computers = createAgentComputers({
|
|
@@ -2440,18 +2505,16 @@ export function standaloneAgents(env, scope) {
|
|
|
2440
2505
|
return { error: "not_found" };
|
|
2441
2506
|
return {
|
|
2442
2507
|
agentId,
|
|
2443
|
-
|
|
2508
|
+
...(await env.AGENTS.getByName(agentId).readInstructions(JSON.stringify(principal))),
|
|
2444
2509
|
};
|
|
2445
2510
|
},
|
|
2446
|
-
setInstructions: async (agentId,
|
|
2511
|
+
setInstructions: async (agentId, edit, principal) => {
|
|
2447
2512
|
if (!oysterPrincipalIsOwner(principal))
|
|
2448
2513
|
return { error: "not_granted" };
|
|
2449
2514
|
if (!(await directory().has(agentId)))
|
|
2450
2515
|
return { error: "not_found" };
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
instructions: await env.AGENTS.getByName(agentId).writeInstructions(instructions),
|
|
2454
|
-
};
|
|
2516
|
+
const result = await env.AGENTS.getByName(agentId).replaceInstructions(JSON.stringify(principal), edit.expectedContent, edit.content);
|
|
2517
|
+
return "error" in result ? result : { agentId, ...result };
|
|
2455
2518
|
},
|
|
2456
2519
|
setModelChoice: async (agentId, choice, principal) => {
|
|
2457
2520
|
if (!oysterPrincipalIsOwner(principal))
|
|
@@ -19,6 +19,11 @@ export type StarterApp = Readonly<{
|
|
|
19
19
|
trial: "local" | "needs-runtime";
|
|
20
20
|
}>;
|
|
21
21
|
export declare const standaloneAppSet: readonly StarterApp[];
|
|
22
|
+
/**
|
|
23
|
+
* The starter Apps to install: all of them, or only the named installation ids,
|
|
24
|
+
* in the starter order. An unknown name is refused with the valid names.
|
|
25
|
+
*/
|
|
26
|
+
export declare function selectStarterApps(only?: readonly string[]): readonly StarterApp[];
|
|
22
27
|
/** The Apps `oyster try` installs after the desktop, in the order it reports them. */
|
|
23
28
|
export declare const trialStarterOrder: readonly ["grove", "prints", "inkcap", "trellis", "bonsai", "shed"];
|
|
24
29
|
/** The plain refusal for an Oyster without a Computer to build on. */
|
|
@@ -80,10 +85,11 @@ export type StarterAppSetResult = Readonly<{
|
|
|
80
85
|
}>;
|
|
81
86
|
/**
|
|
82
87
|
* Builds the installer runs at once by default. A build's compiler may take a
|
|
83
|
-
* 4
|
|
84
|
-
*
|
|
88
|
+
* 4 GiB heap and pnpm and esbuild another 2 GiB, so a Computer runs one build
|
|
89
|
+
* per 6 GiB, two at most: two on a 12 GiB container or 16 GiB VM, one on an
|
|
90
|
+
* 8 GiB or 4 GiB VM. A third runs only when asked for.
|
|
85
91
|
*/
|
|
86
|
-
export declare
|
|
92
|
+
export declare function defaultStarterBuildConcurrency(): number;
|
|
87
93
|
/**
|
|
88
94
|
* Install the standalone App set, each App built on the Oyster's own
|
|
89
95
|
* Computer. Each App's editable source is published as its template; the host
|
|
@@ -99,6 +105,8 @@ export declare function installStandaloneAppSet(options: Readonly<{
|
|
|
99
105
|
report: (message: string) => void;
|
|
100
106
|
/** Builds at once on the Computer, 1 to 3; one by default. */
|
|
101
107
|
concurrency?: number;
|
|
108
|
+
/** Install only these starter installation ids; every starter by default. */
|
|
109
|
+
only?: readonly string[];
|
|
102
110
|
/** Publishes one App's source; the real installer uses `publishSource`. */
|
|
103
111
|
publish?: (app: StarterApp, located: Readonly<{
|
|
104
112
|
repositoryPath: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defaultBuildConcurrency, machineMemoryMib, } from "../build/build-memory.js";
|
|
1
2
|
import { execFile } from "node:child_process";
|
|
2
3
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
4
|
import { join } from "node:path";
|
|
@@ -71,6 +72,19 @@ export const standaloneAppSet = [
|
|
|
71
72
|
trial: "local",
|
|
72
73
|
},
|
|
73
74
|
];
|
|
75
|
+
/**
|
|
76
|
+
* The starter Apps to install: all of them, or only the named installation ids,
|
|
77
|
+
* in the starter order. An unknown name is refused with the valid names.
|
|
78
|
+
*/
|
|
79
|
+
export function selectStarterApps(only) {
|
|
80
|
+
if (only === undefined)
|
|
81
|
+
return standaloneAppSet;
|
|
82
|
+
const known = standaloneAppSet.map((app) => app.installationId);
|
|
83
|
+
const unknown = only.filter((name) => !known.includes(name));
|
|
84
|
+
if (unknown.length > 0 || only.length === 0)
|
|
85
|
+
throw new Error(`Unknown starter App ${unknown.join(", ") || "(none named)"}. Choose from: ${known.join(", ")}.`);
|
|
86
|
+
return standaloneAppSet.filter((app) => only.includes(app.installationId));
|
|
87
|
+
}
|
|
74
88
|
/** The Apps `oyster try` installs after the desktop, in the order it reports them. */
|
|
75
89
|
export const trialStarterOrder = [
|
|
76
90
|
"grove",
|
|
@@ -146,11 +160,14 @@ const computerPhasesSchema = Schema.fromJsonString(Schema.Struct({
|
|
|
146
160
|
const appBuildWaitMs = 20 * 60_000;
|
|
147
161
|
/**
|
|
148
162
|
* Builds the installer runs at once by default. A build's compiler may take a
|
|
149
|
-
* 4
|
|
150
|
-
*
|
|
163
|
+
* 4 GiB heap and pnpm and esbuild another 2 GiB, so a Computer runs one build
|
|
164
|
+
* per 6 GiB, two at most: two on a 12 GiB container or 16 GiB VM, one on an
|
|
165
|
+
* 8 GiB or 4 GiB VM. A third runs only when asked for.
|
|
151
166
|
*/
|
|
152
|
-
export
|
|
153
|
-
|
|
167
|
+
export function defaultStarterBuildConcurrency() {
|
|
168
|
+
return defaultBuildConcurrency(machineMemoryMib());
|
|
169
|
+
}
|
|
170
|
+
/** The most builds at once, when the caller asks for more than the default. */
|
|
154
171
|
const maxStarterBuildConcurrency = 3;
|
|
155
172
|
const run = (command, args, cwd) => new Promise((resolveRun, reject) => {
|
|
156
173
|
execFile(command, args, { cwd, encoding: "utf8", maxBuffer: 1_048_576 }, (error, stdout) => {
|
|
@@ -169,7 +186,8 @@ const run = (command, args, cwd) => new Promise((resolveRun, reject) => {
|
|
|
169
186
|
* is compiled on this machine and no installed App is needed to build.
|
|
170
187
|
*/
|
|
171
188
|
export async function installStandaloneAppSet(options) {
|
|
172
|
-
const
|
|
189
|
+
const apps = selectStarterApps(options.only);
|
|
190
|
+
const concurrency = options.concurrency ?? defaultStarterBuildConcurrency();
|
|
173
191
|
if (!Number.isInteger(concurrency) ||
|
|
174
192
|
concurrency < 1 ||
|
|
175
193
|
concurrency > maxStarterBuildConcurrency)
|
|
@@ -327,7 +345,7 @@ export async function installStandaloneAppSet(options) {
|
|
|
327
345
|
};
|
|
328
346
|
const seedAll = async () => {
|
|
329
347
|
try {
|
|
330
|
-
for (const app of
|
|
348
|
+
for (const app of apps) {
|
|
331
349
|
try {
|
|
332
350
|
const seeded = await seedApp(app);
|
|
333
351
|
const waiter = waiting.shift();
|
|
@@ -437,11 +455,11 @@ export async function installStandaloneAppSet(options) {
|
|
|
437
455
|
if (outcome.status === "rejected")
|
|
438
456
|
throw outcome.reason;
|
|
439
457
|
return {
|
|
440
|
-
installed:
|
|
458
|
+
installed: apps.flatMap((app) => {
|
|
441
459
|
const result = installed.get(app.installationId);
|
|
442
460
|
return result === undefined ? [] : [result];
|
|
443
461
|
}),
|
|
444
|
-
failed:
|
|
462
|
+
failed: apps.flatMap((app) => {
|
|
445
463
|
const reason = failures.get(app.installationId);
|
|
446
464
|
return reason === undefined
|
|
447
465
|
? []
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { computerSizeSchema } from "@fungi.computer/computer/backing";
|
|
2
3
|
import { computerBackendViewSchema, computerStateSchema, } from "@fungi.computer/computer/fleet";
|
|
3
4
|
import { teamComputerDirectorySchema } from "@fungi.computer/nacre/workbench";
|
|
4
5
|
const inventoryComputer = z.strictObject({
|
|
5
6
|
computerId: z.string(),
|
|
6
7
|
name: z.string(),
|
|
8
|
+
size: computerSizeSchema,
|
|
7
9
|
createdAt: z.number(),
|
|
8
10
|
updatedAt: z.number(),
|
|
9
11
|
});
|
|
@@ -75,7 +77,11 @@ export function standaloneComputerControl(registry, memberId) {
|
|
|
75
77
|
const computer = inventoryComputer.parse(result);
|
|
76
78
|
return {
|
|
77
79
|
kind: "created",
|
|
78
|
-
computer: {
|
|
80
|
+
computer: {
|
|
81
|
+
computerId: computer.computerId,
|
|
82
|
+
name: computer.name,
|
|
83
|
+
size: computer.size,
|
|
84
|
+
},
|
|
79
85
|
};
|
|
80
86
|
},
|
|
81
87
|
backends: async (computerId) => backendList.parse(available(await fleet({ operation: "backends", computerId }))).backends,
|
|
@@ -6,6 +6,11 @@ export declare const standaloneFleetRequestSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
6
6
|
operation: z.ZodLiteral<"create">;
|
|
7
7
|
request: z.ZodObject<{
|
|
8
8
|
name: z.ZodOptional<z.ZodString>;
|
|
9
|
+
size: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
default: "default";
|
|
11
|
+
small: "small";
|
|
12
|
+
large: "large";
|
|
13
|
+
}>>;
|
|
9
14
|
requestId: z.ZodString;
|
|
10
15
|
}, z.core.$strict>;
|
|
11
16
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -23,6 +28,7 @@ export declare const standaloneFleetRequestSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
23
28
|
select: "select";
|
|
24
29
|
state: "state";
|
|
25
30
|
resolve: "resolve";
|
|
31
|
+
stop: "stop";
|
|
26
32
|
start: "start";
|
|
27
33
|
}>;
|
|
28
34
|
computerId: z.ZodString;
|
|
@@ -17,7 +17,7 @@ export const standaloneFleetRequestSchema = z.discriminatedUnion("operation", [
|
|
|
17
17
|
page: computerPageSchema,
|
|
18
18
|
}),
|
|
19
19
|
z.strictObject({
|
|
20
|
-
operation: z.enum(["read", "resolve", "state", "start", "select"]),
|
|
20
|
+
operation: z.enum(["read", "resolve", "state", "start", "stop", "select"]),
|
|
21
21
|
computerId: fleetComputerId,
|
|
22
22
|
}),
|
|
23
23
|
z.strictObject({
|
|
@@ -166,6 +166,14 @@ export function standaloneComputerFleetRoutes(registryFor) {
|
|
|
166
166
|
});
|
|
167
167
|
return fleetResponse(result);
|
|
168
168
|
});
|
|
169
|
+
routes.get("/api/computers/:computerId/state", owner, async (context, { principal }) => fleetResponse(await registryFor().computerFleet(principal.actor.memberId, {
|
|
170
|
+
operation: "state",
|
|
171
|
+
computerId: context.req.param("computerId"),
|
|
172
|
+
})));
|
|
173
|
+
routes.post("/api/computers/:computerId/stop", owner, async (context, { principal }) => fleetResponse(await registryFor().computerFleet(principal.actor.memberId, {
|
|
174
|
+
operation: "stop",
|
|
175
|
+
computerId: context.req.param("computerId"),
|
|
176
|
+
})));
|
|
169
177
|
// One owner switch per durable Computer setting, read and written alike.
|
|
170
178
|
for (const [path, read, write] of [
|
|
171
179
|
["internet-access", "read-internet-access", "set-internet-access"],
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FilesPort } from "@fungi.computer/knapsack";
|
|
2
|
+
import type { SkillSource } from "@fungi.computer/shiitake-extensions/skills/source";
|
|
3
|
+
/**
|
|
4
|
+
* Skills on an Agent's own Computer. Discovery follows the same rules Local
|
|
5
|
+
* applies on a disk (frontmatter, naming, bounds, first name wins): this
|
|
6
|
+
* module only walks and reads folders through the Computer's Files port, and
|
|
7
|
+
* the port, not this code, confines every path to the Computer's workspace.
|
|
8
|
+
*/
|
|
9
|
+
/** One attached Computer, as the Agent reaches it. */
|
|
10
|
+
export type SkillComputer = Readonly<{
|
|
11
|
+
name: string;
|
|
12
|
+
port: FilesPort;
|
|
13
|
+
}>;
|
|
14
|
+
/** What a person is told when no skill is installed on the Computer. */
|
|
15
|
+
export declare const computerSkillsEmpty = "No skills are installed; put one at .agents/skills/<name>/SKILL.md on the Computer.";
|
|
16
|
+
/** Discover and load the skills on the Agent's attached Computers. */
|
|
17
|
+
export declare function createComputerSkillSource(options: Readonly<{
|
|
18
|
+
/** The Computers the Agent may use now; read at each discovery. */
|
|
19
|
+
computers: () => Promise<readonly SkillComputer[]>;
|
|
20
|
+
}>): SkillSource;
|