@fungi.computer/oyster 0.42.1 → 0.44.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/app-storage.d.ts +13 -1
- package/dist/app-storage.js +35 -2
- package/dist/host.d.ts +1 -1
- package/dist/host.js +9 -1
- package/dist/page/mount.d.ts +1 -0
- package/dist/page/storage.js +7 -1
- package/dist/page-script.js +1 -1
- package/dist/root-data.d.ts +10 -0
- package/dist/standalone/agent-connections.d.ts +1 -1
- package/dist/standalone/agents.d.ts +40 -2
- package/dist/standalone/agents.js +48 -4
- package/dist/standalone/computer-egress.d.ts +31 -0
- package/dist/standalone/computer-egress.js +21 -3
- package/dist/standalone/computer.d.ts +9 -1
- package/dist/standalone/computer.js +14 -4
- package/dist/standalone/worker.d.ts +2 -1
- package/dist/standalone/worker.js +12 -2
- package/dist/workers.d.ts +3 -1
- package/dist/workers.js +5 -0
- package/docs/api/host.md +1 -1
- package/docs/api/page/mount.md +5 -5
- package/docs/api/workers.md +50 -17
- package/package.json +12 -12
package/dist/root-data.d.ts
CHANGED
|
@@ -62,6 +62,11 @@ export declare function createOysterRootData(options: OysterRootDataOptions): {
|
|
|
62
62
|
reset: (input: import("@fungi.computer/agar").AppStorageReset) => import("effect/Effect").Effect<{
|
|
63
63
|
revision: number;
|
|
64
64
|
}, import("@fungi.computer/agar").AppStorageError, never>;
|
|
65
|
+
claim: (input: import("@fungi.computer/agar/storage-wire").AppStorageClaim) => import("effect/Effect").Effect<{
|
|
66
|
+
readonly value: import("effect/Schema").Json;
|
|
67
|
+
readonly revision: number;
|
|
68
|
+
readonly claimed: boolean;
|
|
69
|
+
}, import("@fungi.computer/agar").AppStorageError, never>;
|
|
65
70
|
};
|
|
66
71
|
open(authorize: () => import("effect/Effect").Effect<import("./app-storage.js").AppStorageAdmission, Error>): {
|
|
67
72
|
read: (key: string) => import("effect/Effect").Effect<{
|
|
@@ -83,6 +88,11 @@ export declare function createOysterRootData(options: OysterRootDataOptions): {
|
|
|
83
88
|
reset: (input: import("@fungi.computer/agar").AppStorageReset) => import("effect/Effect").Effect<{
|
|
84
89
|
revision: number;
|
|
85
90
|
}, import("@fungi.computer/agar").AppStorageError, never>;
|
|
91
|
+
claim: (input: import("@fungi.computer/agar/storage-wire").AppStorageClaim) => import("effect/Effect").Effect<{
|
|
92
|
+
readonly value: import("effect/Schema").Json;
|
|
93
|
+
readonly revision: number;
|
|
94
|
+
readonly claimed: boolean;
|
|
95
|
+
}, import("@fungi.computer/agar").AppStorageError, never>;
|
|
86
96
|
events: (key: string) => import("effect/Stream").Stream<{
|
|
87
97
|
readonly appId: string;
|
|
88
98
|
readonly key: string;
|
|
@@ -59,7 +59,7 @@ export declare function createAgentMcpConnections(options: {
|
|
|
59
59
|
readonly pathTemplate: "/" | "/:segment" | "/:segment/\u2026";
|
|
60
60
|
readonly pathLength: "short" | "medium" | "long";
|
|
61
61
|
readonly method: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "OTHER";
|
|
62
|
-
readonly outcome: "placed" | "refused_destination" | "refused_grant" | "upstream_status";
|
|
62
|
+
readonly outcome: "placed" | "refused_destination" | "refused_grant" | "echo_redacted" | "upstream_status";
|
|
63
63
|
readonly status: number | null;
|
|
64
64
|
}[]>;
|
|
65
65
|
/** Complete one request with a secret on the owner side; the caller names its subject. */
|
|
@@ -20,7 +20,10 @@ export type AiBinding = {
|
|
|
20
20
|
import { type ComputerAttachmentInput } from "../agent-computers.js";
|
|
21
21
|
import { type AgentComputerSnapshot, type AgentComputerConnection } from "../agent-computer-source.js";
|
|
22
22
|
import { type StandaloneAgentComputerReply } from "./agent-computers.js";
|
|
23
|
-
import { type ComputerGrant } from "@fungi.computer/computer/fleet";
|
|
23
|
+
import { type ComputerAction, type ComputerGrant } from "@fungi.computer/computer/fleet";
|
|
24
|
+
import { type VaultReferenceAdmission, type VaultSecretGrant } from "@fungi.computer/computer";
|
|
25
|
+
import type { VaultRequestData } from "@fungi.computer/computer/egress";
|
|
26
|
+
import type { ConnectionSubject, ConnectionUsage, HttpDestinations, Placement } from "@fungi.computer/veil/connections";
|
|
24
27
|
import { DurableObject } from "cloudflare:workers";
|
|
25
28
|
import { type StandaloneComputerEnv } from "./computer.js";
|
|
26
29
|
import { ShiitakeDO } from "@fungi.computer/shiitake/cloudflare";
|
|
@@ -336,6 +339,17 @@ export declare abstract class StandaloneAgentBase<Env extends StandaloneAgentEnv
|
|
|
336
339
|
inboxRows(): Promise<AgentInboxRows>;
|
|
337
340
|
}
|
|
338
341
|
/** Names this Oyster's agents and remembers which Sessions the member opened. */
|
|
342
|
+
/**
|
|
343
|
+
* An admitted Agent Computer call as it crosses the directory's RPC boundary:
|
|
344
|
+
* plain data, which the Agent turns into its fleet grant with the Vault
|
|
345
|
+
* context of the directory that admitted it.
|
|
346
|
+
*/
|
|
347
|
+
export type AdmittedAgentComputer = Readonly<{
|
|
348
|
+
computerId: string;
|
|
349
|
+
actions: readonly ComputerAction[];
|
|
350
|
+
expiresAt: number;
|
|
351
|
+
provenance: ComputerGrant["provenance"];
|
|
352
|
+
}>;
|
|
339
353
|
export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
|
|
340
354
|
private archiveProjectionOwner;
|
|
341
355
|
private archiveProjection;
|
|
@@ -407,6 +421,30 @@ export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
|
|
|
407
421
|
}>>;
|
|
408
422
|
ungrantConnection(connectionId: string, agentId: string): Promise<boolean>;
|
|
409
423
|
removeConnection(connectionId: string): Promise<boolean>;
|
|
424
|
+
/** Host-only: save one Vault secret bound to exact destinations. */
|
|
425
|
+
addSecret(input: Readonly<{
|
|
426
|
+
name: string;
|
|
427
|
+
destinations: HttpDestinations;
|
|
428
|
+
placement: Placement;
|
|
429
|
+
secret: string;
|
|
430
|
+
}>): Promise<Readonly<{
|
|
431
|
+
connectionId: string;
|
|
432
|
+
}> | Readonly<{
|
|
433
|
+
error: string;
|
|
434
|
+
}>>;
|
|
435
|
+
grantSecret(connectionId: string, subject: ConnectionSubject): Promise<Readonly<{
|
|
436
|
+
ok: true;
|
|
437
|
+
}> | Readonly<{
|
|
438
|
+
error: string;
|
|
439
|
+
}>>;
|
|
440
|
+
ungrantSecret(connectionId: string, subject: ConnectionSubject): Promise<void>;
|
|
441
|
+
secretUsage(connectionId: string): Promise<readonly ConnectionUsage[]>;
|
|
442
|
+
/** A Computer opening one Agent command: which secrets it holds now; never a value. */
|
|
443
|
+
computerVaultGrants(agentId: string): Promise<readonly VaultSecretGrant[]>;
|
|
444
|
+
/** The Computer gateway's Vault lane: one resolved reference's request, sent here. */
|
|
445
|
+
sendComputerVault(admission: VaultReferenceAdmission, data: VaultRequestData): Promise<Response | Readonly<{
|
|
446
|
+
error: string;
|
|
447
|
+
}>>;
|
|
410
448
|
connectionTools(connectionId: string): Promise<readonly string[] | Readonly<{
|
|
411
449
|
error: "not_found" | "duplicate_name" | "limit" | "invalid_endpoint";
|
|
412
450
|
}>>;
|
|
@@ -494,7 +532,7 @@ export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
|
|
|
494
532
|
/** The owner HTTP read uses the same projection as direct discovery. */
|
|
495
533
|
readAgentComputers(agentId: string, principal: TenantPrincipal, tenantId?: TenantId): Promise<StandaloneAgentComputerReply>;
|
|
496
534
|
/** Every captured native call rechecks the exact live attachment and credential owner. */
|
|
497
|
-
admitAgentComputer(captured: Pick<AgentComputerConnection, "scopeId" | "agentId" | "attachment">, tenantId: TenantId): Promise<
|
|
535
|
+
admitAgentComputer(captured: Pick<AgentComputerConnection, "scopeId" | "agentId" | "attachment">, tenantId: TenantId): Promise<AdmittedAgentComputer>;
|
|
498
536
|
private websiteChannelsOwner;
|
|
499
537
|
private websites;
|
|
500
538
|
/** Owner read of every website bound to one of this tenant's Agents. */
|
|
@@ -41,6 +41,7 @@ import { createAgentComputers, } from "../agent-computers.js";
|
|
|
41
41
|
import { createAgentComputerSource, readAgentComputerConnections, } from "../agent-computer-source.js";
|
|
42
42
|
import { standaloneAgentComputerPorts, standaloneBrowserSave, } from "./agent-computers.js";
|
|
43
43
|
import { FleetGrantRefused, } from "@fungi.computer/computer/fleet";
|
|
44
|
+
import { vaultExecutionContext, } from "@fungi.computer/computer";
|
|
44
45
|
import { homeExtension, homeGrant, } from "@fungi.computer/shiitake-extensions/home/host";
|
|
45
46
|
import { homeContract, homeInstructionsLimit, } from "@fungi.computer/shiitake-extensions/home";
|
|
46
47
|
import { resolveHome } from "@fungi.computer/shiitake-extensions/home/host";
|
|
@@ -743,11 +744,22 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
743
744
|
const pin = await this.policyDirectory();
|
|
744
745
|
if (pin?.directoryName !== captured.scopeId)
|
|
745
746
|
throw new FleetGrantRefused();
|
|
746
|
-
|
|
747
|
+
const grant = await this.env.AGENT_DIRECTORY.getByName(pin.directoryName).admitAgentComputer({
|
|
747
748
|
scopeId: captured.scopeId,
|
|
748
749
|
agentId: captured.agentId,
|
|
749
750
|
attachment: captured.attachment,
|
|
750
751
|
}, pin.tenantId);
|
|
752
|
+
return {
|
|
753
|
+
computerId: grant.computerId,
|
|
754
|
+
actions: new Set(grant.actions),
|
|
755
|
+
expiresAt: grant.expiresAt,
|
|
756
|
+
provenance: grant.provenance,
|
|
757
|
+
// Whose Vault secrets this Agent's commands may name: its directory's.
|
|
758
|
+
egress: vaultExecutionContext({
|
|
759
|
+
owner: pin.directoryName,
|
|
760
|
+
subject: { kind: "agent", id: captured.agentId },
|
|
761
|
+
}),
|
|
762
|
+
};
|
|
751
763
|
},
|
|
752
764
|
};
|
|
753
765
|
}
|
|
@@ -1555,7 +1567,6 @@ const visitRow = Schema.Struct({
|
|
|
1555
1567
|
visited_at: Schema.Number,
|
|
1556
1568
|
});
|
|
1557
1569
|
const counterRow = Schema.Struct({ value: Schema.Number });
|
|
1558
|
-
/** Names this Oyster's agents and remembers which Sessions the member opened. */
|
|
1559
1570
|
export class AgentDirectory extends DurableObject {
|
|
1560
1571
|
archiveProjectionOwner;
|
|
1561
1572
|
archiveProjection() {
|
|
@@ -1723,6 +1734,39 @@ export class AgentDirectory extends DurableObject {
|
|
|
1723
1734
|
async removeConnection(connectionId) {
|
|
1724
1735
|
return (await this.mcpConnections()).remove(connectionId);
|
|
1725
1736
|
}
|
|
1737
|
+
/** Host-only: save one Vault secret bound to exact destinations. */
|
|
1738
|
+
async addSecret(input) {
|
|
1739
|
+
return (await this.mcpConnections()).addSecret(input);
|
|
1740
|
+
}
|
|
1741
|
+
async grantSecret(connectionId, subject) {
|
|
1742
|
+
return (await this.mcpConnections()).grantSecret(connectionId, subject);
|
|
1743
|
+
}
|
|
1744
|
+
async ungrantSecret(connectionId, subject) {
|
|
1745
|
+
await (await this.mcpConnections()).ungrantSecret(connectionId, subject);
|
|
1746
|
+
}
|
|
1747
|
+
async secretUsage(connectionId) {
|
|
1748
|
+
return (await this.mcpConnections()).secretUsage(connectionId);
|
|
1749
|
+
}
|
|
1750
|
+
/** A Computer opening one Agent command: which secrets it holds now; never a value. */
|
|
1751
|
+
async computerVaultGrants(agentId) {
|
|
1752
|
+
const granted = await (await this.mcpConnections()).projection(agentId);
|
|
1753
|
+
return granted.connections.flatMap((connection) => connection.surface.kind === "http"
|
|
1754
|
+
? [
|
|
1755
|
+
{
|
|
1756
|
+
name: connection.name,
|
|
1757
|
+
connectionId: connection.connectionId,
|
|
1758
|
+
grantVersion: connection.grantVersion,
|
|
1759
|
+
},
|
|
1760
|
+
]
|
|
1761
|
+
: []);
|
|
1762
|
+
}
|
|
1763
|
+
/** The Computer gateway's Vault lane: one resolved reference's request, sent here. */
|
|
1764
|
+
async sendComputerVault(admission, data) {
|
|
1765
|
+
return (await this.mcpConnections()).fetchSecret(admission.subject, {
|
|
1766
|
+
connectionId: admission.connectionId,
|
|
1767
|
+
grantVersion: admission.grantVersion,
|
|
1768
|
+
}, data);
|
|
1769
|
+
}
|
|
1726
1770
|
async connectionTools(connectionId) {
|
|
1727
1771
|
return (await this.mcpConnections()).tools(connectionId);
|
|
1728
1772
|
}
|
|
@@ -2051,7 +2095,7 @@ export class AgentDirectory extends DurableObject {
|
|
|
2051
2095
|
throw new FleetGrantRefused();
|
|
2052
2096
|
return {
|
|
2053
2097
|
computerId: held.computerId,
|
|
2054
|
-
actions:
|
|
2098
|
+
actions: [
|
|
2055
2099
|
"files.read",
|
|
2056
2100
|
"files.readBytes",
|
|
2057
2101
|
"files.list",
|
|
@@ -2065,7 +2109,7 @@ export class AgentDirectory extends DurableObject {
|
|
|
2065
2109
|
"processStart",
|
|
2066
2110
|
"processList",
|
|
2067
2111
|
"processKill",
|
|
2068
|
-
]
|
|
2112
|
+
],
|
|
2069
2113
|
expiresAt: Date.now() + 60_000,
|
|
2070
2114
|
provenance: { actor: oysterPrincipalId(owner), via: captured.agentId },
|
|
2071
2115
|
};
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone Oyster's Computer egress: the same host policy Hub's
|
|
3
|
+
* ComputerEgress decides with. It serves four lanes:
|
|
4
|
+
*
|
|
5
|
+
* - the Vault lane: a request presenting one of this Computer's live `fvr1.`
|
|
6
|
+
* references, which the Agent directory that owns the secret completes
|
|
7
|
+
* (its grant, exact binding, value placement, echo check and audit);
|
|
8
|
+
* - Oyster's own origin Git, carrying only the guest's own credential;
|
|
9
|
+
* - the anonymous public download lane (package registries and release hosts
|
|
10
|
+
* the policy classifies), so a build can install its dependencies, behind
|
|
11
|
+
* the same `COMPUTER_PUBLIC_EGRESS=disabled` kill switch as Hub;
|
|
12
|
+
* - the internal build hosts: a live App build job's read-only clone on
|
|
13
|
+
* `git.team.internal` (an installation repository through the Git door,
|
|
14
|
+
* presented with a host-held job pass the guest never sees, or the App's
|
|
15
|
+
* template through the registry's read-only template exchange), and its
|
|
16
|
+
* `/jobs/:id/*` reports and object uploads on `build.team.internal`, each
|
|
17
|
+
* object streamed into the Release store without passing the registry.
|
|
18
|
+
*
|
|
19
|
+
* Team Git is refused, because this host serves no such lane.
|
|
20
|
+
*/
|
|
21
|
+
import { type VaultRequestData } from "@fungi.computer/computer/egress";
|
|
22
|
+
import type { VaultReferenceAdmission } from "@fungi.computer/computer";
|
|
1
23
|
import { type BuildGitEvent } from "../build-egress.js";
|
|
2
24
|
import type { ContentObjectOwner } from "../build/content-objects.js";
|
|
3
25
|
import type { CandidateObject, CandidateObjectMediaType, TeamAppCandidateManifest } from "../build-contract.js";
|
|
@@ -6,6 +28,13 @@ import { type GitDoorTarget } from "../git.js";
|
|
|
6
28
|
export type OysterComputerEgressProps = Readonly<{
|
|
7
29
|
computerObjectId: string;
|
|
8
30
|
}>;
|
|
31
|
+
/** The Vault lane: this Computer resolves a reference, its owner sends. */
|
|
32
|
+
export type OysterComputerVaultPort = Readonly<{
|
|
33
|
+
admit(reference: string): Promise<VaultReferenceAdmission | null>;
|
|
34
|
+
send(admission: VaultReferenceAdmission, data: VaultRequestData): Promise<Response | Readonly<{
|
|
35
|
+
error: string;
|
|
36
|
+
}>>;
|
|
37
|
+
}>;
|
|
9
38
|
/** The registry's build admission, for the one Computer this egress serves. */
|
|
10
39
|
export type OysterComputerBuildPort = Readonly<{
|
|
11
40
|
gitPassFor(target: GitDoorTarget): Promise<string | null>;
|
|
@@ -37,5 +66,7 @@ export declare function serveOysterComputerEgress(request: Request, options: Rea
|
|
|
37
66
|
/** Live setting from the Computer identified by the host's loopback props. */
|
|
38
67
|
internetAccess(): Promise<boolean>;
|
|
39
68
|
build: OysterComputerBuildPort;
|
|
69
|
+
/** Absent: this host offers no Vault lane, and every reference is refused. */
|
|
70
|
+
vault?: OysterComputerVaultPort;
|
|
40
71
|
forward(request: Request): Promise<Response>;
|
|
41
72
|
}>): Promise<Response>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Standalone Oyster's Computer egress: the same host policy Hub's
|
|
3
|
-
* ComputerEgress decides with. It serves
|
|
3
|
+
* ComputerEgress decides with. It serves four lanes:
|
|
4
4
|
*
|
|
5
|
+
* - the Vault lane: a request presenting one of this Computer's live `fvr1.`
|
|
6
|
+
* references, which the Agent directory that owns the secret completes
|
|
7
|
+
* (its grant, exact binding, value placement, echo check and audit);
|
|
5
8
|
* - Oyster's own origin Git, carrying only the guest's own credential;
|
|
6
9
|
* - the anonymous public download lane (package registries and release hosts
|
|
7
10
|
* the policy classifies), so a build can install its dependencies, behind
|
|
@@ -15,7 +18,8 @@
|
|
|
15
18
|
*
|
|
16
19
|
* Team Git is refused, because this host serves no such lane.
|
|
17
20
|
*/
|
|
18
|
-
import { anonymousRequest, anonymousResponse, computerEgressDenied, decideComputerEgress, decidePublicLane, originGitRequest, publicEgressEnabled, recordComputerEgress, } from "@fungi.computer/computer/egress";
|
|
21
|
+
import { anonymousRequest, anonymousResponse, computerEgressDenied, decideComputerEgress, decidePublicLane, originGitRequest, publicEgressEnabled, recordComputerEgress, vaultRefusalStatus, vaultRequestData, } from "@fungi.computer/computer/egress";
|
|
22
|
+
import { connectionBodyLimit } from "@fungi.computer/veil/connections";
|
|
19
23
|
import { createBuildEgress } from "../build-egress.js";
|
|
20
24
|
import { oysterBuildGitHost, oysterBuildReportHost } from "../app-builds.js";
|
|
21
25
|
import { gitDoorRoute, smartHttpExchange } from "../git.js";
|
|
@@ -48,7 +52,21 @@ export async function serveOysterComputerEgress(request, options) {
|
|
|
48
52
|
if (decision.kind === "denied")
|
|
49
53
|
return deny(url.hostname, decision.reason);
|
|
50
54
|
let response;
|
|
51
|
-
if (decision.kind === "
|
|
55
|
+
if (decision.kind === "vault") {
|
|
56
|
+
if (options.vault === undefined)
|
|
57
|
+
return deny(url.hostname, "lane-not-offered:vault");
|
|
58
|
+
const admission = await options.vault.admit(decision.reference);
|
|
59
|
+
if (admission === null)
|
|
60
|
+
return deny(url.hostname, "vault-reference");
|
|
61
|
+
const prepared = await vaultRequestData(request, url, decision.reference, connectionBodyLimit);
|
|
62
|
+
if (prepared.kind === "refused")
|
|
63
|
+
return deny(url.hostname, `vault-${prepared.reason}`, prepared.reason === "too_large" ? 413 : 403);
|
|
64
|
+
const sent = await options.vault.send(admission, prepared.data);
|
|
65
|
+
if (!(sent instanceof Response))
|
|
66
|
+
return deny(url.hostname, `vault-${sent.error}`, vaultRefusalStatus(sent.error));
|
|
67
|
+
response = sent;
|
|
68
|
+
}
|
|
69
|
+
else if (decision.kind === "origin-git")
|
|
52
70
|
response = await options.forward(originGitRequest(request, url));
|
|
53
71
|
else if (decision.kind === "public") {
|
|
54
72
|
let enabled;
|
|
@@ -6,7 +6,7 @@ import { type PreviewSelector } from "./preview.js";
|
|
|
6
6
|
import { type StandaloneTenancyEnv } from "./tenancy.js";
|
|
7
7
|
import * as z from "zod";
|
|
8
8
|
import { computerProcessSchema, computerToolResultSchema, readOutputSchema } from "@fungi.computer/computer-contract";
|
|
9
|
-
import { ComputerDO as NativeComputerDO, type AttachedBackend, type ComputerEnv, type ComputerFilesRpc } from "@fungi.computer/computer";
|
|
9
|
+
import { ComputerDO as NativeComputerDO, type AttachedBackend, type ComputerEnv, type ComputerFilesRpc, type VaultSecretGrant } from "@fungi.computer/computer";
|
|
10
10
|
import { patchInputSchema, patchOutputSchema } from "@fungi.computer/knapsack/files-patch";
|
|
11
11
|
import { listOutputSchema, writeOutputSchema, mkdirOutputSchema, moveOutputSchema, removeOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsOutputSchema, processWaitOutputSchema, computerOperationResultSchema, type ComputerExecutionHostHooks, type ComputerValue } from "@fungi.computer/computer-contract";
|
|
12
12
|
import { type WorkflowGitCredential, type WorkflowGitPassGrant } from "@fungi.computer/braid/runtime";
|
|
@@ -61,6 +61,14 @@ export type StandaloneComputerOwnerEnv = StandaloneComputerEnv & StandaloneTenan
|
|
|
61
61
|
WORKFLOW_RUNS: Readonly<{
|
|
62
62
|
getByName(libraryId: string): StandaloneWorkflowGitIssuer;
|
|
63
63
|
}>;
|
|
64
|
+
/** Each Agent directory owns its Agents' Vault secrets. */
|
|
65
|
+
AGENT_DIRECTORY: Readonly<{
|
|
66
|
+
getByName(directoryName: string): StandaloneVaultGrantOwner;
|
|
67
|
+
}>;
|
|
68
|
+
}>;
|
|
69
|
+
/** Which secrets one Agent holds now, for its command's references. */
|
|
70
|
+
export type StandaloneVaultGrantOwner = Readonly<{
|
|
71
|
+
computerVaultGrants(agentId: string): Promise<readonly VaultSecretGrant[]>;
|
|
64
72
|
}>;
|
|
65
73
|
/** The library run owner's per-invocation Workflow Git credential ports. */
|
|
66
74
|
export type StandaloneWorkflowGitIssuer = Readonly<{
|
|
@@ -11,7 +11,7 @@ import { standaloneTenancy } from "./tenancy.js";
|
|
|
11
11
|
import { Base64 } from "effect/encoding";
|
|
12
12
|
import * as z from "zod";
|
|
13
13
|
import { ComputerPortConflictError, computerByteReadReplySchema, computerProcessSchema, installationProcessScope, processStartInputSchema, processStartToolInputSchema, computerCapabilities, computerToolResultSchema, readOutputSchema, } from "@fungi.computer/computer-contract";
|
|
14
|
-
import { ComputerDO as NativeComputerDO, ComputerOperationConflictError, ComputerBackendUnavailableError, } from "@fungi.computer/computer";
|
|
14
|
+
import { ComputerDO as NativeComputerDO, ComputerOperationConflictError, ComputerBackendUnavailableError, isVaultExecutionContext, withVaultExecution, } from "@fungi.computer/computer";
|
|
15
15
|
import { patchInputSchema, patchOutputSchema, } from "@fungi.computer/knapsack/files-patch";
|
|
16
16
|
import { ComputerFileConflict, ComputerFileMoveError, ComputerFileRemoveError, computerExecutionRequestSchema, computerValueSchema, computerPortInputSchema, listInputSchema, listOutputSchema, readBytesInputSchema, writeInputSchema, replaceInputSchema, writeOutputSchema, mkdirOutputSchema, moveInputSchema, moveOutputSchema, removeOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsInputSchema, processWaitInputSchema, processLogsOutputSchema, processWaitOutputSchema, computerOperationResultSchema, mintComputerRequestId, processIdInputSchema, } from "@fungi.computer/computer-contract";
|
|
17
17
|
import { workflowGitExecutionEnvironment, workflowGitPassGrantSchema, } from "@fungi.computer/braid/runtime";
|
|
@@ -460,6 +460,10 @@ export class ComputerDO extends NativeComputerDO {
|
|
|
460
460
|
* Computer hands it only to that command's Git environment.
|
|
461
461
|
*/
|
|
462
462
|
executionHooks() {
|
|
463
|
+
// An Agent command's references come from the directory its grant names.
|
|
464
|
+
const vault = this.vaultExecutionHooks({
|
|
465
|
+
grants: ({ owner, subject }) => this.previewBindings.AGENT_DIRECTORY.getByName(owner).computerVaultGrants(subject.id),
|
|
466
|
+
});
|
|
463
467
|
const issuer = (context) => {
|
|
464
468
|
const grant = workflowGitExecutionContextSchema.parse(context).workflowGit;
|
|
465
469
|
return {
|
|
@@ -467,7 +471,7 @@ export class ComputerDO extends NativeComputerDO {
|
|
|
467
471
|
runs: this.previewBindings.WORKFLOW_RUNS.getByName(grant.teamId),
|
|
468
472
|
};
|
|
469
473
|
};
|
|
470
|
-
return {
|
|
474
|
+
return withVaultExecution(vault, {
|
|
471
475
|
async open(invocation, context) {
|
|
472
476
|
const { grant, runs } = issuer(context);
|
|
473
477
|
return {
|
|
@@ -482,7 +486,7 @@ export class ComputerDO extends NativeComputerDO {
|
|
|
482
486
|
const { grant, runs } = issuer(context);
|
|
483
487
|
await runs.closeWorkflowGit(invocation.id, grant);
|
|
484
488
|
},
|
|
485
|
-
};
|
|
489
|
+
});
|
|
486
490
|
}
|
|
487
491
|
attachedBackends() {
|
|
488
492
|
if (this.#backends !== undefined)
|
|
@@ -524,7 +528,13 @@ export class ComputerDO extends NativeComputerDO {
|
|
|
524
528
|
requestId: mintComputerRequestId(),
|
|
525
529
|
requestScope: `tool:${authority.provenance.actor}`,
|
|
526
530
|
}), accept);
|
|
527
|
-
|
|
531
|
+
// The host-issued grant names whose Vault references an Agent command holds.
|
|
532
|
+
const vault = (tool === "bash" || tool === "exec") &&
|
|
533
|
+
authority.egress !== undefined &&
|
|
534
|
+
isVaultExecutionContext(authority.egress)
|
|
535
|
+
? authority.egress
|
|
536
|
+
: undefined;
|
|
537
|
+
return output.parse(await this.callAfterAcceptance(tool, input, accept, vault));
|
|
528
538
|
}
|
|
529
539
|
/** JSON operations keep the Computer's maintained parsers and execution engine. */
|
|
530
540
|
async value(authority, action, input, executionContext) {
|
|
@@ -60,7 +60,8 @@ declare const OysterInstallationExecutor_base: new (ctx: ExecutionContext, env:
|
|
|
60
60
|
/** Private loopback execution uses this root's ordinary host composition. */
|
|
61
61
|
export declare class OysterInstallationExecutor extends OysterInstallationExecutor_base {
|
|
62
62
|
}
|
|
63
|
-
/** The Computer's egress gateway: its own HTTPS Git back into this Worker
|
|
63
|
+
/** The Computer's egress gateway: its own HTTPS Git back into this Worker,
|
|
64
|
+
* and the Vault lane through the Agent directory that owns each secret. */
|
|
64
65
|
export declare class OysterComputerEgress extends WorkerEntrypoint<StandaloneEnv, OysterComputerEgressProps> {
|
|
65
66
|
fetch(request: Request): Promise<Response>;
|
|
66
67
|
}
|
|
@@ -155,16 +155,26 @@ const oyster = createOysterGitWorker(oysterRoot);
|
|
|
155
155
|
/** Private loopback execution uses this root's ordinary host composition. */
|
|
156
156
|
export class OysterInstallationExecutor extends installationWorkerEntrypoint((env, scope) => oysterRoot.hostFor(env, scope)) {
|
|
157
157
|
}
|
|
158
|
-
/** The Computer's egress gateway: its own HTTPS Git back into this Worker
|
|
158
|
+
/** The Computer's egress gateway: its own HTTPS Git back into this Worker,
|
|
159
|
+
* and the Vault lane through the Agent directory that owns each secret. */
|
|
159
160
|
export class OysterComputerEgress extends WorkerEntrypoint {
|
|
160
161
|
fetch(request) {
|
|
161
162
|
const computerObjectId = this.ctx.props.computerObjectId;
|
|
162
163
|
const registry = computerRegistry(this.env);
|
|
164
|
+
const computer = () => this.env.COMPUTER.get(this.env.COMPUTER.idFromString(computerObjectId));
|
|
165
|
+
// The Agent directory that owns each secret, not the Git owner's narrow view.
|
|
166
|
+
const directories = this.env.AGENT_DIRECTORY;
|
|
163
167
|
return serveOysterComputerEgress(request, {
|
|
164
168
|
origin: this.env.OYSTER_ORIGIN,
|
|
165
169
|
computerId: computerObjectId,
|
|
166
170
|
publicEgress: this.env.COMPUTER_PUBLIC_EGRESS,
|
|
167
|
-
internetAccess: () =>
|
|
171
|
+
internetAccess: () => computer().internetAccess(),
|
|
172
|
+
vault: {
|
|
173
|
+
admit: (reference) => computer().admitVaultReference(reference),
|
|
174
|
+
send: (admission, data) => directories
|
|
175
|
+
.getByName(admission.owner)
|
|
176
|
+
.sendComputerVault(admission, data),
|
|
177
|
+
},
|
|
168
178
|
build: {
|
|
169
179
|
gitPassFor: (target) => registry.buildGitPassFor(computerObjectId, target),
|
|
170
180
|
exchangeTemplate: (repository, request) => registry.exchangeBuildTemplate(computerObjectId, repository, request),
|
package/dist/workers.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { r2ArtifactStore, type FrameBindingReply, type FrameBindingMethod, type
|
|
|
26
26
|
import type { AppTestCopy, AppTestCopyAuthority } from "./app-test-copies.js";
|
|
27
27
|
import { type BackgroundFrameState, type InvocationFacts, type InvocationFrame } from "./invocation.js";
|
|
28
28
|
import { type InstallationCommit, type InstanceResult, type OysterAuth, type OysterHost, type OysterJson } from "./host.js";
|
|
29
|
-
import { type AppStorageResult, type AppStorageWrite, type AppStorageReset, type ResolvedAppStorage } from "@fungi.computer/agar/storage";
|
|
29
|
+
import { type AppStorageResult, type AppStorageWrite, type AppStorageReset, type AppStorageClaim, type AppStorageClaimed, type ResolvedAppStorage } from "@fungi.computer/agar/storage";
|
|
30
30
|
import { type OysterRootDirectory } from "./root-data.js";
|
|
31
31
|
import type { AppApi } from "@fungi.computer/puffball";
|
|
32
32
|
import type { AppDeclaration } from "@fungi.computer/puffball/app";
|
|
@@ -209,6 +209,8 @@ export declare class OysterRegistry<Env extends OysterWorkerEnv = OysterWorkerEn
|
|
|
209
209
|
storageReset(installationId: string, ownerId: string, input: AppStorageReset): Promise<AppStorageResult<{
|
|
210
210
|
revision: number;
|
|
211
211
|
}>>;
|
|
212
|
+
/** Claim one declared absent layer for the authenticated root owner, or read the layer already there. */
|
|
213
|
+
storageClaim(installationId: string, ownerId: string, input: AppStorageClaim): Promise<AppStorageResult<AppStorageClaimed>>;
|
|
212
214
|
/** Storage for a live owner method frame; no guest-selected installation or member. */
|
|
213
215
|
storageBackend(raw: InvocationFacts, method: string, args: readonly unknown[], tenantId: TenantId): Promise<OysterBindingResult>;
|
|
214
216
|
/** Open the existing App-storage invalidation stream under fresh owner admission. */
|
package/dist/workers.js
CHANGED
|
@@ -247,6 +247,10 @@ export class OysterRegistry extends DurableObject {
|
|
|
247
247
|
storageReset(installationId, ownerId, input) {
|
|
248
248
|
return this.storageResult(this.storageView(installationId, () => Promise.resolve(ownerId)).reset(input));
|
|
249
249
|
}
|
|
250
|
+
/** Claim one declared absent layer for the authenticated root owner, or read the layer already there. */
|
|
251
|
+
storageClaim(installationId, ownerId, input) {
|
|
252
|
+
return this.storageResult(this.storageView(installationId, () => Promise.resolve(ownerId)).claim(input));
|
|
253
|
+
}
|
|
250
254
|
/** Storage for a live owner method frame; no guest-selected installation or member. */
|
|
251
255
|
storageBackend(raw, method, args, tenantId) {
|
|
252
256
|
const facts = Schema.decodeUnknownSync(invocationFactsSchema, {
|
|
@@ -1419,6 +1423,7 @@ export function oysterWorkerHost(env, auth, options = {}) {
|
|
|
1419
1423
|
read: (key) => registry().storageRead(installationId, ownerId, key),
|
|
1420
1424
|
write: (input) => registry().storageWrite(installationId, ownerId, input),
|
|
1421
1425
|
reset: (input) => registry().storageReset(installationId, ownerId, input),
|
|
1426
|
+
claim: (input) => registry().storageClaim(installationId, ownerId, input),
|
|
1422
1427
|
events: (key) => registry().storageEvents(installationId, ownerId, key),
|
|
1423
1428
|
}),
|
|
1424
1429
|
},
|
package/docs/api/host.md
CHANGED
|
@@ -528,7 +528,7 @@ type OysterHost = Readonly<{
|
|
|
528
528
|
}>;
|
|
529
529
|
installing?: readonly InstallingApp[];
|
|
530
530
|
}>>;
|
|
531
|
-
storage: Pick<AppStorageWire, "read" | "write" | "reset"> & Readonly<{
|
|
531
|
+
storage: Pick<AppStorageWire, "read" | "write" | "reset" | "claim"> & Readonly<{
|
|
532
532
|
events: Promise<Response>;
|
|
533
533
|
}>;
|
|
534
534
|
}>;
|
package/docs/api/page/mount.md
CHANGED
|
@@ -239,11 +239,11 @@ would, without a frame between the shell and its host.
|
|
|
239
239
|
|
|
240
240
|
`object`
|
|
241
241
|
|
|
242
|
-
| Name | Type
|
|
243
|
-
| --------- |
|
|
244
|
-
| `storage` | \| `Readonly`\<\{ `read`: `Promise`\<\{ `value`: `Json`; `source`: `"member"` \| `"team"` \| `"none"`; `team`: \| \{ `value`: `Json`; `revision`: `number`; \} \| `null`; `member`: \| \{ `value`: `Json`; `revision`: `number`; \} \| `null`; `canWriteTeam`: `boolean`; \}\>; `write`: `Promise`\<\{ `revision`: `number`; \}\>; `reset`: `Promise`\<\{ `revision`: `number`; \}\>; `watch`: `Promise`\<`AppStorageWatch`\>; \}\> \| `null` | - |
|
|
245
|
-
| `methods` | `object`
|
|
246
|
-
| `call()` | (`method`, `input`) => `Promise`\<`WhistleJsonValue`\>
|
|
242
|
+
| Name | Type | Description |
|
|
243
|
+
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
|
|
244
|
+
| `storage` | \| `Readonly`\<\{ `read`: `Promise`\<\{ `value`: `Json`; `source`: `"member"` \| `"team"` \| `"none"`; `team`: \| \{ `value`: `Json`; `revision`: `number`; \} \| `null`; `member`: \| \{ `value`: `Json`; `revision`: `number`; \} \| `null`; `canWriteTeam`: `boolean`; \}\>; `write`: `Promise`\<\{ `revision`: `number`; \}\>; `reset`: `Promise`\<\{ `revision`: `number`; \}\>; `claim`: `Promise`\<\{ `value`: `Json`; `revision`: `number`; `claimed`: `boolean`; \}\>; `watch`: `Promise`\<`AppStorageWatch`\>; \}\> \| `null` | - |
|
|
245
|
+
| `methods` | `object` | - |
|
|
246
|
+
| `call()` | (`method`, `input`) => `Promise`\<`WhistleJsonValue`\> | Call the named method with JSON-encoded `input`; resolves with its JSON result. |
|
|
247
247
|
|
|
248
248
|
---
|
|
249
249
|
|