@fungi.computer/oyster 0.37.2 → 0.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/agents.js +9 -2
- package/dist/app-builds.d.ts +1 -1
- package/dist/app-region.d.ts +94 -0
- package/dist/app-region.js +316 -0
- package/dist/authorization.d.ts +58 -9
- package/dist/authorization.js +56 -11
- package/dist/backend-request.d.ts +4 -0
- package/dist/backend-request.js +3 -10
- package/dist/boot-host-script.js +1 -1
- package/dist/build/candidate-builder.d.ts +1 -1
- package/dist/build/candidate-cli.mjs +284 -17
- package/dist/build/effect.d.ts +3 -3
- package/dist/build/submission-contract.d.ts +1 -1
- package/dist/build/workspace-build.d.ts +2 -2
- package/dist/channels/discord-replies.d.ts +8 -1
- package/dist/channels/discord-replies.js +80 -29
- package/dist/cloudflare.d.ts +1 -0
- package/dist/cloudflare.js +12 -2
- package/dist/credential-migration-001.d.ts +14 -0
- package/dist/credential-migration-001.js +13 -0
- package/dist/credential-migration-002.d.ts +38 -0
- package/dist/credential-migration-002.js +74 -0
- package/dist/embed-metafiles.js +2 -2
- package/dist/embed-scripts.js +1 -1
- package/dist/host.d.ts +2 -0
- package/dist/host.js +23 -13
- package/dist/index.d.ts +15 -1
- package/dist/index.js +19 -0
- package/dist/invocation.d.ts +165 -0
- package/dist/invocation.js +67 -0
- package/dist/keys.d.ts +4 -3
- package/dist/keys.js +5 -4
- package/dist/mcp-owner.d.ts +4 -3
- package/dist/mcp-owner.js +3 -2
- package/dist/page/mount.js +5 -1
- package/dist/page/region.d.ts +6 -0
- package/dist/page/region.js +12 -0
- package/dist/page-config.d.ts +2 -0
- package/dist/page-config.js +2 -0
- package/dist/page-script.js +2 -2
- package/dist/source/seed-receipt.d.ts +1 -1
- package/dist/source/template-seed.d.ts +1 -1
- package/dist/standalone/agent-connections.d.ts +49 -1
- package/dist/standalone/agent-connections.js +101 -12
- package/dist/standalone/agent-self.js +2 -1
- package/dist/standalone/agents.d.ts +7 -3
- package/dist/standalone/agents.js +42 -19
- package/dist/standalone/computer-fleet.d.ts +12 -6
- package/dist/standalone/computer-fleet.js +70 -29
- package/dist/standalone/computer.js +39 -14
- package/dist/standalone/instance.d.ts +3 -1
- package/dist/standalone/instance.js +8 -0
- package/dist/standalone/model-key-vault.d.ts +33 -4
- package/dist/standalone/model-key-vault.js +74 -17
- package/dist/standalone/preview.js +11 -10
- package/dist/standalone/try-cli.d.ts +12 -2
- package/dist/standalone/try-cli.js +170 -32
- package/dist/standalone/try-worker.d.ts +2 -0
- package/dist/standalone/try-worker.js +15 -0
- package/dist/standalone/worker.js +3 -3
- package/dist/standalone/workflow-host.d.ts +1 -1
- package/dist/standalone/workflows.d.ts +3 -3
- package/dist/standalone/workflows.js +7 -0
- package/dist/testing/capabilities.d.ts +2 -0
- package/dist/testing/capabilities.js +2 -0
- package/dist/webhook-custody.d.ts +14 -3
- package/dist/webhook-custody.js +165 -43
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.js +15 -3
- package/dist/workers-git.d.ts +24 -8
- package/dist/workers-git.js +105 -15
- package/dist/workers.d.ts +16 -0
- package/dist/workers.js +95 -5
- package/docs/api/apps.md +31 -31
- package/docs/api/authorization.md +119 -17
- package/docs/api/build-contract.md +8 -8
- package/docs/api/build.md +163 -174
- package/docs/api/cloudflare.md +171 -0
- package/docs/api/host.md +1 -0
- package/docs/api/index.md +23 -0
- package/docs/api/invocation.md +623 -23
- package/docs/api/keys.md +6 -6
- package/docs/api/pack.md +3 -3
- package/docs/api/page/mount.md +22 -20
- package/docs/api/workers-git.md +273 -157
- package/docs/api/workers.md +257 -175
- package/package.json +19 -18
package/dist/authorization.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Who may reach what is decided here once, from one {@link Authority}: the
|
|
8
8
|
* owner reaches everything; a named key reaches exactly its Ear Tag grants
|
|
9
|
-
* (Apps, Agents,
|
|
9
|
+
* (Apps, Agents, Computers); an Agent reaches its App tool policy. An
|
|
10
10
|
* anonymous request reaches only the public routes: sign-in, robots.txt and
|
|
11
11
|
* digest-pinned assets. The App gate
|
|
12
12
|
* (`apps/gate.ts`) still owns App-declaration rules; it asks this module for a
|
|
@@ -43,19 +43,63 @@ export function keyAppAccess(key, installationId) {
|
|
|
43
43
|
export function keyAgentAccess(key, agentId) {
|
|
44
44
|
return oysterKeyVocabulary.grantsAllow(key.grants, "agents.use", agentId);
|
|
45
45
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Whether a live key's `computer.use` grant reaches this Computer: every
|
|
48
|
+
* Computer (`all`), or one its selected ids name. Off by default. A host with
|
|
49
|
+
* no Computer id (`null`) is reached only by an `all` grant.
|
|
50
|
+
*/
|
|
51
|
+
export function keyComputer(key, computerId) {
|
|
52
|
+
return oysterKeyVocabulary.grantsAllow(key.grants, "computer.use", computerId ?? undefined);
|
|
53
|
+
}
|
|
54
|
+
/** Decide {@link KeyFrameComputer} for one live key; a dead key is refused. */
|
|
55
|
+
export function keyFrameComputer(key, computerId) {
|
|
56
|
+
if (key === null)
|
|
57
|
+
return { kind: "refused" };
|
|
58
|
+
if (!key.grants.some((grant) => grant.capability === "computer.use"))
|
|
59
|
+
return { kind: "owner-computer" };
|
|
60
|
+
return keyComputer(key, computerId)
|
|
61
|
+
? { kind: "granted", owner: key.owner }
|
|
62
|
+
: { kind: "refused" };
|
|
63
|
+
}
|
|
64
|
+
/** Decide {@link KeyComputerChoice} from a key's live grants; a dead key names nothing. */
|
|
65
|
+
export function keyComputerChoice(key, requested) {
|
|
66
|
+
const grants = (key?.grants ?? []).filter((grant) => grant.capability === "computer.use");
|
|
67
|
+
const everyComputer = grants.some((grant) => grant.targets.kind === "all");
|
|
68
|
+
const granted = [
|
|
69
|
+
...new Set(grants.flatMap((grant) => grant.targets.kind === "selected" ? grant.targets.ids : [])),
|
|
70
|
+
];
|
|
71
|
+
if (requested !== null) {
|
|
72
|
+
if (everyComputer || key === null)
|
|
73
|
+
return { kind: "refused", status: 403, error: "Owner only" };
|
|
74
|
+
return granted.includes(requested)
|
|
75
|
+
? { kind: "granted", computerId: requested, owner: key.owner }
|
|
76
|
+
: {
|
|
77
|
+
kind: "refused",
|
|
78
|
+
status: 403,
|
|
79
|
+
error: "This key can't use that Computer",
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const [only, ...others] = granted;
|
|
83
|
+
if (key === null || everyComputer || only === undefined)
|
|
84
|
+
return { kind: "owner-selection" };
|
|
85
|
+
if (others.length === 0)
|
|
86
|
+
return { kind: "granted", computerId: only, owner: key.owner };
|
|
87
|
+
return {
|
|
88
|
+
kind: "refused",
|
|
89
|
+
status: 400,
|
|
90
|
+
error: "This key reaches several Computers; name one with ?computerId=",
|
|
91
|
+
};
|
|
49
92
|
}
|
|
50
93
|
/** True only for a member admitted with the owner role. */
|
|
51
94
|
export function oysterPrincipalIsOwner(principal) {
|
|
52
95
|
return "role" in principal && principal.role === "owner";
|
|
53
96
|
}
|
|
54
|
-
/** A host's own ports: its key store's liveness
|
|
97
|
+
/** A host's own ports: its key store's liveness, its Agents' tool policy and its Computer. */
|
|
55
98
|
export function hostAuthorityPorts(host) {
|
|
56
99
|
return {
|
|
57
100
|
liveKey: async (keyId) => (await host.keys?.live(keyId)) ?? null,
|
|
58
101
|
appToolPolicy: async (actor) => (await host.appToolPolicy?.(actor)) ?? null,
|
|
102
|
+
computerId: host.computerId ?? null,
|
|
59
103
|
};
|
|
60
104
|
}
|
|
61
105
|
/** Resolve one principal's authority through the live key port. */
|
|
@@ -89,17 +133,18 @@ export function reachesAgent(authority, agentId) {
|
|
|
89
133
|
}
|
|
90
134
|
}
|
|
91
135
|
/**
|
|
92
|
-
* Whether this authority reaches
|
|
93
|
-
*
|
|
94
|
-
* Agents reach a Computer only through their own
|
|
136
|
+
* Whether this authority reaches one Computer, its workspace files and the
|
|
137
|
+
* media written there. Members do; a key only with `computer.use` naming that
|
|
138
|
+
* Computer or all of them; Agents reach a Computer only through their own
|
|
139
|
+
* attachment owner.
|
|
95
140
|
*/
|
|
96
|
-
export function reachesComputer(authority) {
|
|
141
|
+
export function reachesComputer(authority, computerId) {
|
|
97
142
|
switch (authority.kind) {
|
|
98
143
|
case "owner":
|
|
99
144
|
case "member":
|
|
100
145
|
return true;
|
|
101
146
|
case "key":
|
|
102
|
-
return authority.key !== null &&
|
|
147
|
+
return authority.key !== null && keyComputer(authority.key, computerId);
|
|
103
148
|
case "agent":
|
|
104
149
|
return false;
|
|
105
150
|
}
|
|
@@ -322,7 +367,7 @@ export function computer() {
|
|
|
322
367
|
const authority = await signedInAuthority(facts);
|
|
323
368
|
if (authority instanceof Response)
|
|
324
369
|
return authority;
|
|
325
|
-
if (!reachesComputer(authority))
|
|
370
|
+
if (!reachesComputer(authority, facts.ports.computerId ?? null))
|
|
326
371
|
return refused(403, "Computer access requires an owner or key");
|
|
327
372
|
return { principal: authority.principal };
|
|
328
373
|
});
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** Second boundary before an admitted request enters customer backend code.
|
|
2
|
+
* Hub normally builds this shape itself; callers of the App runtime must not
|
|
3
|
+
* be able to pass their own headers through the facet.
|
|
4
|
+
*/
|
|
1
5
|
export declare function appFacetRequest(request: Request): Request;
|
|
2
6
|
/** Only content metadata crosses back from a guest; origin policy is host-owned. */
|
|
3
7
|
export declare function appFacetResponse(response: Response): Response;
|
package/dist/backend-request.js
CHANGED
|
@@ -2,18 +2,11 @@
|
|
|
2
2
|
* Hub normally builds this shape itself; callers of the App runtime must not
|
|
3
3
|
* be able to pass their own headers through the facet.
|
|
4
4
|
*/
|
|
5
|
-
import { appBackendActorHeader, appBackendComputerHeader, } from "@fungi.computer/agar/backend";
|
|
6
5
|
export function appFacetRequest(request) {
|
|
7
6
|
const headers = new Headers();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
appBackendComputerHeader,
|
|
12
|
-
]) {
|
|
13
|
-
const value = request.headers.get(name);
|
|
14
|
-
if (value !== null)
|
|
15
|
-
headers.set(name, value);
|
|
16
|
-
}
|
|
7
|
+
const contentType = request.headers.get("Content-Type");
|
|
8
|
+
if (contentType !== null)
|
|
9
|
+
headers.set("Content-Type", contentType);
|
|
17
10
|
const init = {
|
|
18
11
|
method: request.method,
|
|
19
12
|
headers,
|