@fungi.computer/oyster 0.9.0 → 0.10.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/README.md +13 -0
- package/dist/agents.d.ts +16 -1
- package/dist/agents.js +60 -3
- package/dist/computer-control-port.d.ts +20 -1
- package/dist/mcp.d.ts +128 -0
- package/dist/mcp.js +63 -1
- package/dist/standalone/agent-computers.d.ts +12 -1
- package/dist/standalone/agent-computers.js +35 -0
- package/dist/standalone/agent-connections.d.ts +47 -0
- package/dist/standalone/agent-connections.js +170 -0
- package/dist/standalone/agent-model-choice.d.ts +7 -3
- package/dist/standalone/agent-model-choice.js +33 -4
- package/dist/standalone/agents.d.ts +70 -9
- package/dist/standalone/agents.js +187 -110
- package/dist/standalone/browser.d.ts +4 -3
- package/dist/standalone/browser.js +4 -3
- package/dist/standalone/computer-control.js +55 -1
- package/dist/standalone/computer-fleet.d.ts +21 -0
- package/dist/standalone/computer-fleet.js +30 -6
- package/dist/standalone/computer.d.ts +20 -1
- package/dist/standalone/computer.js +63 -1
- package/dist/standalone/model-key-vault.d.ts +50 -0
- package/dist/standalone/model-key-vault.js +147 -0
- package/dist/standalone/registry.d.ts +23 -0
- package/dist/standalone/registry.js +30 -0
- package/dist/standalone/web.d.ts +10 -0
- package/dist/standalone/web.js +34 -0
- package/dist/standalone/worker-routes.d.ts +3 -1
- package/dist/standalone/worker-routes.js +1 -0
- package/dist/standalone/worker.js +9 -1
- package/dist/web/index.d.ts +3 -0
- package/dist/web/index.js +3 -0
- package/dist/web/search-contract.d.ts +19 -0
- package/dist/web/search-contract.js +14 -0
- package/dist/web/search.d.ts +25 -0
- package/dist/web/search.js +123 -0
- package/dist/web/source.d.ts +46 -0
- package/dist/web/source.js +335 -0
- package/dist/workers-git.js +2 -1
- package/docs/api/agents.md +81 -3
- package/docs/api/apps.md +129 -111
- package/docs/api/build-contract.md +27 -21
- package/docs/api/build.md +55 -54
- package/docs/api/git.md +3 -3
- package/docs/api/host.md +69 -60
- package/docs/api/mcp.md +81 -44
- package/docs/api/workers-git.md +6 -6
- package/docs/api/workers.md +53 -47
- package/package.json +27 -22
package/README.md
CHANGED
|
@@ -265,6 +265,19 @@ export OYSTER_OWNER_KEY=$(openssl rand -hex 24)
|
|
|
265
265
|
printf '%s' "$OYSTER_OWNER_KEY" | npx wrangler secret put OYSTER_OWNER_KEY
|
|
266
266
|
```
|
|
267
267
|
|
|
268
|
+
### Set the credential key (to bring your own model keys)
|
|
269
|
+
|
|
270
|
+
Model API keys you add in Settings are sealed on your Oyster under a 32-byte
|
|
271
|
+
credential key held as a host secret. Generate it at install; it is never in the
|
|
272
|
+
repository, storage or logs. Without it, adding a model key is refused.
|
|
273
|
+
|
|
274
|
+
```sh
|
|
275
|
+
openssl rand -base64 32 | tr '+/' '-_' | tr -d '=\n' |
|
|
276
|
+
npx wrangler secret put OYSTER_CREDENTIAL_KEY
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Keep a copy: losing it makes the sealed keys unreadable, and you re-add them.
|
|
280
|
+
|
|
268
281
|
### Install the starter Apps
|
|
269
282
|
|
|
270
283
|
```sh
|
package/dist/agents.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { TenantPrincipal } from "./tenant.js";
|
|
2
|
+
import type { ModelKeyRecord, ModelKeyRefusal, ModelKeySealInput } from "./standalone/model-key-vault.js";
|
|
3
|
+
export type { ModelKeyRefusal, ModelKeySealInput, } from "./standalone/model-key-vault.js";
|
|
2
4
|
import { type Routes } from "./authorization.js";
|
|
3
5
|
import type { AppToolPolicy } from "./apps/tools.js";
|
|
4
6
|
import * as Schema from "effect/Schema";
|
|
@@ -50,7 +52,7 @@ export type AgentMcpServer = Readonly<{
|
|
|
50
52
|
export type AgentMcpServerInput = typeof agentMcpServerInputSchema.Type;
|
|
51
53
|
/** Why connecting an MCP server was refused. */
|
|
52
54
|
export type AgentMcpServerRefusal = Readonly<{
|
|
53
|
-
error: "not_found" | "duplicate_name" | "limit";
|
|
55
|
+
error: "not_found" | "duplicate_name" | "limit" | "invalid_endpoint";
|
|
54
56
|
}>;
|
|
55
57
|
/** At most this many MCP servers per Agent. */
|
|
56
58
|
export declare const maxAgentMcpServers = 16;
|
|
@@ -123,6 +125,14 @@ export type OysterAgents = Readonly<{
|
|
|
123
125
|
approveAppToolPolicy(agentId: string, principal: TenantPrincipal, level: AppToolPolicy["level"], expectedRevision: string | null, actor: AgentPolicyActor): Promise<AppToolPolicy | PendingAgentPolicy | Readonly<{
|
|
124
126
|
error: "not_found" | "revision_conflict" | "not_granted";
|
|
125
127
|
}>>;
|
|
128
|
+
/** The instance's sealed model keys, never their secrets. */
|
|
129
|
+
modelKeys(): Promise<readonly ModelKeyRecord[]>;
|
|
130
|
+
/** Validate with the provider, then seal one key; or an explicit refusal. */
|
|
131
|
+
sealModelKey(input: ModelKeySealInput): Promise<ModelKeyRecord | Readonly<{
|
|
132
|
+
error: ModelKeyRefusal;
|
|
133
|
+
}>>;
|
|
134
|
+
/** Remove one key; Agents that chose it then fail with `key_removed`. */
|
|
135
|
+
removeModelKey(keyId: string): Promise<"deleted" | "absent">;
|
|
126
136
|
/** An Agent's connected MCP servers, or `null` when there is no such Agent. */
|
|
127
137
|
mcpServers(agentId: string): Promise<readonly AgentMcpServer[] | null>;
|
|
128
138
|
/** Connect one remote MCP server; the Agent's next run sees its tools. */
|
|
@@ -142,6 +152,11 @@ export type OysterAgents = Readonly<{
|
|
|
142
152
|
export declare function agentCapabilities(agents: OysterAgents): readonly OysterCapability[];
|
|
143
153
|
/** Host-owned direct approval under the admitted owner; never an App capability. */
|
|
144
154
|
export declare function agentApprovalRoutes(agents: OysterAgents): Routes<OysterEnv>;
|
|
155
|
+
/**
|
|
156
|
+
* Host-owned model-key custody for the owner directly. A key goes in once and
|
|
157
|
+
* never comes back out; listings carry provider, label and times only.
|
|
158
|
+
*/
|
|
159
|
+
export declare function modelKeyRoutes(agents: OysterAgents): Routes<OysterEnv>;
|
|
145
160
|
/**
|
|
146
161
|
* Host-owned Agent MCP server custody for the owner directly; never an App
|
|
147
162
|
* capability. Bearer tokens go in and never come back out.
|
package/dist/agents.js
CHANGED
|
@@ -329,7 +329,16 @@ async function approvePolicy(agents, principal, actor, agentId, body) {
|
|
|
329
329
|
}
|
|
330
330
|
/** Host-owned direct approval under the admitted owner; never an App capability. */
|
|
331
331
|
export function agentApprovalRoutes(agents) {
|
|
332
|
-
return routes()
|
|
332
|
+
return (routes()
|
|
333
|
+
// One owner read for the settings panel: every Agent with its model choice.
|
|
334
|
+
.get("/api/agent-models", owner("direct"), async () => {
|
|
335
|
+
const rows = await Promise.all((await agents.list()).map(async (item) => ({
|
|
336
|
+
agentId: item.agentId,
|
|
337
|
+
name: item.name,
|
|
338
|
+
choice: await agents.readModelChoice(item.agentId),
|
|
339
|
+
})));
|
|
340
|
+
return Response.json({ agents: rows });
|
|
341
|
+
})
|
|
333
342
|
.get("/api/agent-models/:agentId", owner("direct"), async (context) => {
|
|
334
343
|
const agentId = context.req.param("agentId");
|
|
335
344
|
if (!agentIdPattern.test(agentId))
|
|
@@ -365,10 +374,58 @@ export function agentApprovalRoutes(agents) {
|
|
|
365
374
|
expectedRevision: await agents.policyRevision(agentId),
|
|
366
375
|
});
|
|
367
376
|
})
|
|
368
|
-
.put("/api/agent-policies/:agentId", owner("direct"), async (context, { principal }) => approvePolicy(agents, principal, "owner-direct", context.req.param("agentId"), await context.req.text()));
|
|
377
|
+
.put("/api/agent-policies/:agentId", owner("direct"), async (context, { principal }) => approvePolicy(agents, principal, "owner-direct", context.req.param("agentId"), await context.req.text())));
|
|
378
|
+
}
|
|
379
|
+
const keyIdPattern = /^cred_[A-Za-z0-9_-]{1,64}$/u;
|
|
380
|
+
const sealRequestSchema = Schema.Struct({
|
|
381
|
+
provider: Schema.Literals(["anthropic", "openai", "openrouter"]),
|
|
382
|
+
label: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(64)),
|
|
383
|
+
apiKey: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(16_384)),
|
|
384
|
+
});
|
|
385
|
+
const modelKeyRefusalStatus = {
|
|
386
|
+
invalid_key: 400,
|
|
387
|
+
key_rejected: 422,
|
|
388
|
+
provider_unavailable: 502,
|
|
389
|
+
custody_unavailable: 503,
|
|
390
|
+
key_removed: 404,
|
|
391
|
+
target_denied: 400,
|
|
392
|
+
limit: 409,
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* Host-owned model-key custody for the owner directly. A key goes in once and
|
|
396
|
+
* never comes back out; listings carry provider, label and times only.
|
|
397
|
+
*/
|
|
398
|
+
export function modelKeyRoutes(agents) {
|
|
399
|
+
return routes()
|
|
400
|
+
.get("/api/model-keys", owner("direct"), async () => Response.json({ keys: await agents.modelKeys() }))
|
|
401
|
+
.post("/api/model-keys", owner("direct"), async (context) => {
|
|
402
|
+
const length = Number(context.req.header("content-length") ?? "0");
|
|
403
|
+
if (length > 32 * 1024)
|
|
404
|
+
return refusal(413, "Request too large");
|
|
405
|
+
const input = Schema.decodeUnknownOption(Schema.fromJsonString(sealRequestSchema), { onExcessProperty: "error" })(await context.req.text());
|
|
406
|
+
if (input._tag === "None")
|
|
407
|
+
return refusal(400, "Choose a provider, name the key and paste it");
|
|
408
|
+
const sealed = await agents.sealModelKey(input.value);
|
|
409
|
+
return "error" in sealed
|
|
410
|
+
? refusal(modelKeyRefusalStatus[sealed.error], sealed.error)
|
|
411
|
+
: Response.json(sealed, { status: 201 });
|
|
412
|
+
})
|
|
413
|
+
.delete("/api/model-keys/:keyId", owner("direct"), async (context) => {
|
|
414
|
+
const keyId = context.req.param("keyId");
|
|
415
|
+
if (!keyIdPattern.test(keyId))
|
|
416
|
+
return refusal(404, "No such key");
|
|
417
|
+
return (await agents.removeModelKey(keyId)) === "deleted"
|
|
418
|
+
? new Response(null, { status: 204 })
|
|
419
|
+
: refusal(404, "No such key");
|
|
420
|
+
});
|
|
369
421
|
}
|
|
370
422
|
const serverIdPattern = /^[a-z0-9_-]{1,64}$/u;
|
|
371
|
-
const mcpRefusalStatus = {
|
|
423
|
+
const mcpRefusalStatus = {
|
|
424
|
+
not_found: 404,
|
|
425
|
+
duplicate_name: 409,
|
|
426
|
+
limit: 409,
|
|
427
|
+
invalid_endpoint: 400,
|
|
428
|
+
};
|
|
372
429
|
/**
|
|
373
430
|
* Host-owned Agent MCP server custody for the owner directly; never an App
|
|
374
431
|
* capability. Bearer tokens go in and never come back out.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import type { computerCreateRequestSchema, computerPageSchema } from "@fungi.computer/computer/fleet/inventory-wire";
|
|
3
|
-
import type { computerStateSchema } from "@fungi.computer/computer/fleet/wire";
|
|
3
|
+
import type { computerBackendViewSchema, computerStateSchema, LocalBackendAttachInput } from "@fungi.computer/computer/fleet/wire";
|
|
4
4
|
import type { teamComputerDirectorySchema } from "@fungi.computer/nacre/workbench";
|
|
5
5
|
import type { InvocationContext } from "@fungi.computer/mycelium";
|
|
6
6
|
/** Host policy stays outside this family: Hub admits funded slots, standalone
|
|
@@ -23,4 +23,23 @@ export type ComputerControlPort = Readonly<{
|
|
|
23
23
|
} | {
|
|
24
24
|
kind: "uncertain" | "denied" | "conflict" | "invalid";
|
|
25
25
|
}>;
|
|
26
|
+
/** List one Computer's attached execution backends with live status. */
|
|
27
|
+
backends(computerId: string, context: InvocationContext): Promise<z.output<typeof computerBackendViewSchema>[]>;
|
|
28
|
+
/** Attach the caller's machine, or replay the same request. */
|
|
29
|
+
attachLocal(input: LocalBackendAttachInput, context: InvocationContext): Promise<{
|
|
30
|
+
kind: "attached";
|
|
31
|
+
backendId: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: "uncertain" | "denied" | "conflict" | "invalid";
|
|
34
|
+
}>;
|
|
35
|
+
/** Detach a machine the caller attached; one already gone settles. */
|
|
36
|
+
detachLocal(input: Readonly<{
|
|
37
|
+
computerId: string;
|
|
38
|
+
backendId: string;
|
|
39
|
+
}>, context: InvocationContext): Promise<{
|
|
40
|
+
kind: "detached";
|
|
41
|
+
detached: boolean;
|
|
42
|
+
} | {
|
|
43
|
+
kind: "denied" | "uncertain" | "invalid";
|
|
44
|
+
}>;
|
|
26
45
|
}>;
|
package/dist/mcp.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type AppToolPolicy } from "./apps/tools.js";
|
|
|
3
3
|
import type { DeclaredOperations, Installation } from "./apps/installation.js";
|
|
4
4
|
import { type CapabilitySource, type Grants, type ModuleRegistration } from "@fungi.computer/mycelium";
|
|
5
5
|
import { computerPageSchema } from "@fungi.computer/computer/fleet/inventory-wire";
|
|
6
|
+
import { localBackendDetachSchema } from "@fungi.computer/computer/fleet/wire";
|
|
6
7
|
import type { InvocationContext } from "@fungi.computer/mycelium";
|
|
7
8
|
import type { ComputerControlPort } from "./computer-control-port.js";
|
|
8
9
|
export type { ComputerControlPort } from "./computer-control-port.js";
|
|
@@ -25,6 +26,57 @@ declare const fleetCreate: z.ZodObject<{
|
|
|
25
26
|
name: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
26
27
|
requestId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
27
28
|
}, z.core.$strict>;
|
|
29
|
+
declare const fleetBackends: z.ZodObject<{
|
|
30
|
+
backends: z.ZodArray<z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
kind: z.ZodEnum<{
|
|
33
|
+
"platform-container": "platform-container";
|
|
34
|
+
"on-box-vm": "on-box-vm";
|
|
35
|
+
local: "local";
|
|
36
|
+
}>;
|
|
37
|
+
status: z.ZodEnum<{
|
|
38
|
+
ready: "ready";
|
|
39
|
+
online: "online";
|
|
40
|
+
offline: "offline";
|
|
41
|
+
queued: "queued";
|
|
42
|
+
}>;
|
|
43
|
+
queuePosition: z.ZodNullable<z.ZodNumber>;
|
|
44
|
+
hostId: z.ZodNullable<z.ZodString>;
|
|
45
|
+
hostLabel: z.ZodNullable<z.ZodString>;
|
|
46
|
+
folderLabel: z.ZodNullable<z.ZodString>;
|
|
47
|
+
detachable: z.ZodBoolean;
|
|
48
|
+
}, z.core.$strict>>;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
declare const fleetAttachInput: z.ZodObject<{
|
|
51
|
+
computerId: z.ZodString;
|
|
52
|
+
publicKey: z.ZodBase64;
|
|
53
|
+
hostLabel: z.ZodLazy<z.ZodString>;
|
|
54
|
+
folderLabel: z.ZodLazy<z.ZodString>;
|
|
55
|
+
requestId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
declare const fleetAttachment: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
58
|
+
kind: z.ZodLiteral<"attached">;
|
|
59
|
+
requestId: z.ZodString;
|
|
60
|
+
backendId: z.ZodString;
|
|
61
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
62
|
+
kind: z.ZodEnum<{
|
|
63
|
+
invalid: "invalid";
|
|
64
|
+
denied: "denied";
|
|
65
|
+
uncertain: "uncertain";
|
|
66
|
+
conflict: "conflict";
|
|
67
|
+
}>;
|
|
68
|
+
requestId: z.ZodString;
|
|
69
|
+
}, z.core.$strict>], "kind">;
|
|
70
|
+
declare const fleetDetachment: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
71
|
+
kind: z.ZodLiteral<"detached">;
|
|
72
|
+
detached: z.ZodBoolean;
|
|
73
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
74
|
+
kind: z.ZodEnum<{
|
|
75
|
+
invalid: "invalid";
|
|
76
|
+
denied: "denied";
|
|
77
|
+
uncertain: "uncertain";
|
|
78
|
+
}>;
|
|
79
|
+
}, z.core.$strict>], "kind">;
|
|
28
80
|
declare const fleetCreation: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
29
81
|
kind: z.ZodLiteral<"created">;
|
|
30
82
|
requestId: z.ZodString;
|
|
@@ -148,6 +200,82 @@ export declare function computerControlSpecs(port: ComputerControlPort): {
|
|
|
148
200
|
/** Mint one identity or preserve the requestId for an uncertain retry. */
|
|
149
201
|
execute: (input: z.output<typeof fleetCreate>, context: InvocationContext) => Promise<z.output<typeof fleetCreation>>;
|
|
150
202
|
};
|
|
203
|
+
backends: {
|
|
204
|
+
replay: "safe";
|
|
205
|
+
description: string;
|
|
206
|
+
input: z.ZodObject<{
|
|
207
|
+
computerId: z.ZodString;
|
|
208
|
+
}, z.core.$strict>;
|
|
209
|
+
output: z.ZodObject<{
|
|
210
|
+
backends: z.ZodArray<z.ZodObject<{
|
|
211
|
+
id: z.ZodString;
|
|
212
|
+
kind: z.ZodEnum<{
|
|
213
|
+
"platform-container": "platform-container";
|
|
214
|
+
"on-box-vm": "on-box-vm";
|
|
215
|
+
local: "local";
|
|
216
|
+
}>;
|
|
217
|
+
status: z.ZodEnum<{
|
|
218
|
+
ready: "ready";
|
|
219
|
+
online: "online";
|
|
220
|
+
offline: "offline";
|
|
221
|
+
queued: "queued";
|
|
222
|
+
}>;
|
|
223
|
+
queuePosition: z.ZodNullable<z.ZodNumber>;
|
|
224
|
+
hostId: z.ZodNullable<z.ZodString>;
|
|
225
|
+
hostLabel: z.ZodNullable<z.ZodString>;
|
|
226
|
+
folderLabel: z.ZodNullable<z.ZodString>;
|
|
227
|
+
detachable: z.ZodBoolean;
|
|
228
|
+
}, z.core.$strict>>;
|
|
229
|
+
}, z.core.$strict>;
|
|
230
|
+
/** Return the attached list without waking any backend. */
|
|
231
|
+
execute: (input: z.output<typeof fleetComputerId>, context: InvocationContext) => Promise<z.output<typeof fleetBackends>>;
|
|
232
|
+
};
|
|
233
|
+
attachLocal: {
|
|
234
|
+
replay: "unsafe";
|
|
235
|
+
description: string;
|
|
236
|
+
input: z.ZodObject<{
|
|
237
|
+
computerId: z.ZodString;
|
|
238
|
+
publicKey: z.ZodBase64;
|
|
239
|
+
hostLabel: z.ZodLazy<z.ZodString>;
|
|
240
|
+
folderLabel: z.ZodLazy<z.ZodString>;
|
|
241
|
+
requestId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
242
|
+
}, z.core.$strict>;
|
|
243
|
+
output: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
244
|
+
kind: z.ZodLiteral<"attached">;
|
|
245
|
+
requestId: z.ZodString;
|
|
246
|
+
backendId: z.ZodString;
|
|
247
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
248
|
+
kind: z.ZodEnum<{
|
|
249
|
+
invalid: "invalid";
|
|
250
|
+
denied: "denied";
|
|
251
|
+
uncertain: "uncertain";
|
|
252
|
+
conflict: "conflict";
|
|
253
|
+
}>;
|
|
254
|
+
requestId: z.ZodString;
|
|
255
|
+
}, z.core.$strict>], "kind">;
|
|
256
|
+
/** Mint one identity or preserve the requestId for an uncertain retry. */
|
|
257
|
+
execute: (input: z.output<typeof fleetAttachInput>, context: InvocationContext) => Promise<z.output<typeof fleetAttachment>>;
|
|
258
|
+
};
|
|
259
|
+
detachLocal: {
|
|
260
|
+
replay: "unsafe";
|
|
261
|
+
description: string;
|
|
262
|
+
input: z.ZodLazy<z.ZodObject<{
|
|
263
|
+
computerId: z.ZodString;
|
|
264
|
+
backendId: z.ZodString;
|
|
265
|
+
}, z.core.$strict>>;
|
|
266
|
+
output: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
267
|
+
kind: z.ZodLiteral<"detached">;
|
|
268
|
+
detached: z.ZodBoolean;
|
|
269
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
270
|
+
kind: z.ZodEnum<{
|
|
271
|
+
invalid: "invalid";
|
|
272
|
+
denied: "denied";
|
|
273
|
+
uncertain: "uncertain";
|
|
274
|
+
}>;
|
|
275
|
+
}, z.core.$strict>], "kind">;
|
|
276
|
+
/** Close the attachment and its live connection; a gone one settles. */
|
|
277
|
+
execute: (input: z.output<typeof localBackendDetachSchema>, context: InvocationContext) => Promise<z.output<typeof fleetDetachment>>;
|
|
278
|
+
};
|
|
151
279
|
};
|
|
152
280
|
/** An installation ID as a guest binding name: `spawn-git` becomes `SPAWN_GIT`. */
|
|
153
281
|
export declare function appBindingName(installationId: string): string;
|
package/dist/mcp.js
CHANGED
|
@@ -15,6 +15,7 @@ import { Knapsack } from "@fungi.computer/knapsack";
|
|
|
15
15
|
import * as Schema from "effect/Schema";
|
|
16
16
|
import { defineIdFamily } from "@fungi.computer/cairn/id";
|
|
17
17
|
import { computerCreateRequestSchema, computerPageSchema, } from "@fungi.computer/computer/fleet/inventory-wire";
|
|
18
|
+
import { computerBackendViewSchema, localBackendAttachSchema, localBackendDetachSchema, } from "@fungi.computer/computer/fleet/wire";
|
|
18
19
|
import { computerStateSchema } from "@fungi.computer/computer/fleet/wire";
|
|
19
20
|
import { teamComputerDirectorySchema } from "@fungi.computer/nacre/workbench";
|
|
20
21
|
import { appToolAccess, authorityOf, hostAuthorityPorts, } from "./authorization.js";
|
|
@@ -48,6 +49,31 @@ const fleetComputer = z.strictObject({
|
|
|
48
49
|
computerId: z.string(),
|
|
49
50
|
name: z.string(),
|
|
50
51
|
});
|
|
52
|
+
const fleetBackends = z.strictObject({
|
|
53
|
+
backends: z.array(computerBackendViewSchema),
|
|
54
|
+
});
|
|
55
|
+
const fleetAttachInput = z.strictObject({
|
|
56
|
+
computerId: localBackendAttachSchema.shape.computerId,
|
|
57
|
+
publicKey: localBackendAttachSchema.shape.publicKey,
|
|
58
|
+
hostLabel: localBackendAttachSchema.shape.hostLabel,
|
|
59
|
+
folderLabel: localBackendAttachSchema.shape.folderLabel,
|
|
60
|
+
requestId: localBackendAttachSchema.shape.requestId.nullable().default(null),
|
|
61
|
+
});
|
|
62
|
+
const fleetAttachment = z.discriminatedUnion("kind", [
|
|
63
|
+
z.strictObject({
|
|
64
|
+
kind: z.literal("attached"),
|
|
65
|
+
requestId: z.string(),
|
|
66
|
+
backendId: z.string(),
|
|
67
|
+
}),
|
|
68
|
+
z.strictObject({
|
|
69
|
+
kind: z.enum(["uncertain", "denied", "conflict", "invalid"]),
|
|
70
|
+
requestId: z.string(),
|
|
71
|
+
}),
|
|
72
|
+
]);
|
|
73
|
+
const fleetDetachment = z.discriminatedUnion("kind", [
|
|
74
|
+
z.strictObject({ kind: z.literal("detached"), detached: z.boolean() }),
|
|
75
|
+
z.strictObject({ kind: z.enum(["denied", "uncertain", "invalid"]) }),
|
|
76
|
+
]);
|
|
51
77
|
const fleetCreation = z.discriminatedUnion("kind", [
|
|
52
78
|
z.strictObject({
|
|
53
79
|
kind: z.literal("created"),
|
|
@@ -100,6 +126,36 @@ export function computerControlSpecs(port) {
|
|
|
100
126
|
return { ...result, requestId };
|
|
101
127
|
},
|
|
102
128
|
},
|
|
129
|
+
backends: {
|
|
130
|
+
replay: "safe",
|
|
131
|
+
description: "List one Computer's attached execution backends (platform container, on-box VM, members' machines) with live status.",
|
|
132
|
+
input: fleetComputerId,
|
|
133
|
+
output: fleetBackends,
|
|
134
|
+
/** Return the attached list without waking any backend. */
|
|
135
|
+
execute: async (input, context) => ({
|
|
136
|
+
backends: await port.backends(input.computerId, context),
|
|
137
|
+
}),
|
|
138
|
+
},
|
|
139
|
+
attachLocal: {
|
|
140
|
+
replay: "unsafe",
|
|
141
|
+
description: "Attach this authenticated member's machine to a Computer as an execution backend. Send only the device public key and labels; the folder path and private key stay on the machine. Retry an uncertain outcome with its returned requestId.",
|
|
142
|
+
input: fleetAttachInput,
|
|
143
|
+
output: fleetAttachment,
|
|
144
|
+
/** Mint one identity or preserve the requestId for an uncertain retry. */
|
|
145
|
+
execute: async (input, context) => {
|
|
146
|
+
const requestId = input.requestId ?? fleetIds.request.generate();
|
|
147
|
+
const result = await port.attachLocal({ ...input, requestId }, context);
|
|
148
|
+
return { ...result, requestId };
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
detachLocal: {
|
|
152
|
+
replay: "unsafe",
|
|
153
|
+
description: "Detach a machine this member attached from a Computer. Its live connection closes and the Computer keeps its files. Safe to retry.",
|
|
154
|
+
input: localBackendDetachSchema,
|
|
155
|
+
output: fleetDetachment,
|
|
156
|
+
/** Close the attachment and its live connection; a gone one settles. */
|
|
157
|
+
execute: (input, context) => port.detachLocal(input, context),
|
|
158
|
+
},
|
|
103
159
|
};
|
|
104
160
|
}
|
|
105
161
|
/** Mints the requestId a tool family tool sends on the caller's behalf to its
|
|
@@ -388,7 +444,10 @@ export async function oysterAppSnapshot(host, surfaces, principal, installations
|
|
|
388
444
|
fences[id] = await sha256(new TextEncoder().encode(JSON.stringify({
|
|
389
445
|
installation,
|
|
390
446
|
generation,
|
|
391
|
-
principal
|
|
447
|
+
// The canonical caller facts, never the raw principal: a resolver may
|
|
448
|
+
// carry extra registry fields (membershipVersion) that the submit-time
|
|
449
|
+
// principal lacks, which would fence a legitimate approval.
|
|
450
|
+
caller,
|
|
392
451
|
access: captured,
|
|
393
452
|
api,
|
|
394
453
|
family: familyFacts,
|
|
@@ -552,6 +611,9 @@ export function oysterMcpCatalogLoad(host) {
|
|
|
552
611
|
...fleetSpecs.create,
|
|
553
612
|
confirm: true,
|
|
554
613
|
}),
|
|
614
|
+
backends: Mycelium.operation(fleetSpecs.backends),
|
|
615
|
+
attachLocal: Mycelium.operation(fleetSpecs.attachLocal),
|
|
616
|
+
detachLocal: Mycelium.operation(fleetSpecs.detachLocal),
|
|
555
617
|
},
|
|
556
618
|
}),
|
|
557
619
|
],
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { TenantPrincipal } from "../tenant.js";
|
|
2
2
|
import { type ComputerGrant } from "@fungi.computer/computer/fleet";
|
|
3
3
|
import { type AgentComputerProjection, type ComputerAttachmentInput } from "../agent-computers.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { SaveBrowserFile } from "../browser/index.js";
|
|
5
|
+
import type { AgentComputerConnection, AgentComputerPorts, AgentComputerSnapshot } from "../agent-computer-source.js";
|
|
5
6
|
import { type OysterEnv } from "../host.js";
|
|
6
7
|
import { type Routes } from "../authorization.js";
|
|
7
8
|
import type { StandaloneAgentComputerRpc } from "./computer.js";
|
|
@@ -10,6 +11,16 @@ export type StandaloneAgentComputerAccess = Readonly<{
|
|
|
10
11
|
admit: (connection: AgentComputerConnection) => Promise<ComputerGrant>;
|
|
11
12
|
computer: (computerId: string) => Rpc.Provider<StandaloneAgentComputerRpc>;
|
|
12
13
|
}>;
|
|
14
|
+
/**
|
|
15
|
+
* `cloudBrowser.screenshot`/`pdf` bytes go straight to one attached Computer's
|
|
16
|
+
* file system, never through the model. The destination must be a Computer in
|
|
17
|
+
* the Agent's current attachments, and the directory re-admits it for
|
|
18
|
+
* `files.writeBytes` on every save, so a detached or revoked Computer refuses.
|
|
19
|
+
*/
|
|
20
|
+
export declare function standaloneBrowserSave(access: Readonly<{
|
|
21
|
+
admit: StandaloneAgentComputerAccess["admit"];
|
|
22
|
+
write: (computerId: string, grant: ComputerGrant, path: string, bytes: Uint8Array) => Promise<void>;
|
|
23
|
+
}>, read: () => AgentComputerSnapshot | null): SaveBrowserFile;
|
|
13
24
|
/** Native operations use the captured Computer, never the mutable workspace selection. */
|
|
14
25
|
export declare function standaloneAgentComputerPorts(access: StandaloneAgentComputerAccess, connection: AgentComputerConnection): AgentComputerPorts;
|
|
15
26
|
/** Persisted command outcome, with no fabricated attachment result on refusal. */
|
|
@@ -4,6 +4,41 @@ import { computerCapabilities, computerValueSchema, } from "@fungi.computer/comp
|
|
|
4
4
|
import { attachComputerInputSchema, detachComputerInputSchema, readAgentComputersInputSchema, } from "../agent-computers.js";
|
|
5
5
|
import {} from "../host.js";
|
|
6
6
|
import { owner, routes as routeTable } from "../authorization.js";
|
|
7
|
+
/** A save named a Computer this Agent is not attached to, or the directory refused it. */
|
|
8
|
+
class BrowserSaveDenied extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "BrowserSaveDenied";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `cloudBrowser.screenshot`/`pdf` bytes go straight to one attached Computer's
|
|
16
|
+
* file system, never through the model. The destination must be a Computer in
|
|
17
|
+
* the Agent's current attachments, and the directory re-admits it for
|
|
18
|
+
* `files.writeBytes` on every save, so a detached or revoked Computer refuses.
|
|
19
|
+
*/
|
|
20
|
+
export function standaloneBrowserSave(access, read) {
|
|
21
|
+
return async ({ computerId, path, bytes }) => {
|
|
22
|
+
const snapshot = read();
|
|
23
|
+
const attachment = snapshot?.projection.attachments.find((candidate) => candidate.computerId === computerId);
|
|
24
|
+
if (snapshot === null || attachment === undefined)
|
|
25
|
+
throw new BrowserSaveDenied(`${computerId} is not a Computer this Agent is attached to`);
|
|
26
|
+
const grant = await access.admit({
|
|
27
|
+
scopeId: snapshot.scopeId,
|
|
28
|
+
agentId: snapshot.agentId,
|
|
29
|
+
attachment,
|
|
30
|
+
admission: () => attachment.admission,
|
|
31
|
+
});
|
|
32
|
+
if (checkComputerGrant(grant, {
|
|
33
|
+
computerId,
|
|
34
|
+
action: "files.writeBytes",
|
|
35
|
+
now: Date.now(),
|
|
36
|
+
}).kind !== "admitted")
|
|
37
|
+
throw new FleetGrantRefused();
|
|
38
|
+
await access.write(computerId, grant, path, bytes);
|
|
39
|
+
return { computerId, path, bytes: bytes.byteLength };
|
|
40
|
+
};
|
|
41
|
+
}
|
|
7
42
|
/** Native operations use the captured Computer, never the mutable workspace selection. */
|
|
8
43
|
export function standaloneAgentComputerPorts(access, connection) {
|
|
9
44
|
const { computerId } = connection.attachment;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { McpServersConnectionOptions } from "@fungi.computer/knapsack";
|
|
2
|
+
import { createSealedCustody, type ConnectionProjection, type EgressRef, type SqlStore } from "@fungi.computer/veil/connections";
|
|
3
|
+
import { type AgentMcpServer, type AgentMcpServerInput, type AgentMcpServerRefusal } from "../agents.js";
|
|
4
|
+
/** One Agent MCP request as plain data, so it can cross the Durable Object RPC boundary. */
|
|
5
|
+
export type McpRequestData = Readonly<{
|
|
6
|
+
url: string;
|
|
7
|
+
method: string;
|
|
8
|
+
headers: readonly (readonly [string, string])[];
|
|
9
|
+
body: ArrayBuffer | null;
|
|
10
|
+
}>;
|
|
11
|
+
/** A refusal crosses RPC as data: a stable code, never a message. */
|
|
12
|
+
type McpFetchRefusal = Readonly<{
|
|
13
|
+
error: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function mcpRequestData(request: Request): Promise<McpRequestData>;
|
|
16
|
+
/**
|
|
17
|
+
* This instance's Agent MCP connections over Veil's connections core. The
|
|
18
|
+
* owner holds every credential; an Agent receives a secret-free projection and
|
|
19
|
+
* a fetch that only the owner side can complete.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createAgentMcpConnections(options: {
|
|
22
|
+
store: SqlStore;
|
|
23
|
+
vault: Parameters<typeof createSealedCustody>[0]["vault"];
|
|
24
|
+
/** The checked public transport; credentials ride only on this one hop. */
|
|
25
|
+
send: (request: Request) => Promise<Response>;
|
|
26
|
+
hasAgent: (agentId: string) => boolean;
|
|
27
|
+
/** Told after a change so the Agent drops captured tools. */
|
|
28
|
+
notify: (agentId: string) => Promise<void>;
|
|
29
|
+
ownerId: string;
|
|
30
|
+
}): {
|
|
31
|
+
servers: (agentId: string) => Promise<readonly AgentMcpServer[] | null>;
|
|
32
|
+
add: (agentId: string, input: AgentMcpServerInput) => Promise<AgentMcpServer | AgentMcpServerRefusal>;
|
|
33
|
+
remove: (agentId: string, serverId: string) => Promise<boolean>;
|
|
34
|
+
projection: (agentId: string) => Promise<ConnectionProjection>;
|
|
35
|
+
fetch: (agentId: string, ref: EgressRef, data: McpRequestData) => Promise<Response | McpFetchRefusal>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The Agent half: Knapsack connects to each granted server through a fetch that
|
|
39
|
+
* is completed by the owner. No header, token or locator is ever held here.
|
|
40
|
+
*/
|
|
41
|
+
export declare function agentMcpSourceOptions(input: {
|
|
42
|
+
read: () => Promise<ConnectionProjection>;
|
|
43
|
+
subscribe: McpServersConnectionOptions["subscribe"];
|
|
44
|
+
onUnavailable: McpServersConnectionOptions["onUnavailable"];
|
|
45
|
+
fetch: (ref: EgressRef, request: Request) => Promise<Response>;
|
|
46
|
+
}): McpServersConnectionOptions;
|
|
47
|
+
export {};
|