@fungi.computer/oyster 0.8.1 → 0.8.2
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 +0 -8
- package/dist/agents.js +21 -15
- package/dist/host.d.ts +4 -1
- package/dist/host.js +9 -0
- package/docs/api/host.md +1 -1
- package/package.json +11 -11
package/dist/agents.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agents for Apps on a standalone Oyster: one adapter shape and the routes
|
|
3
|
-
* the App page calls. Apps reach agents through Agar's `agent.list`,
|
|
4
|
-
* `agent.manage`, `agent.read` and `agent.send` contracts, so an App written
|
|
5
|
-
* for the Hub (Grove) runs unchanged. Each agent's own transport is
|
|
6
|
-
* Shiitake's HTTP routes (`/sessions…`, `/acp`) and Knapsack's Session browser
|
|
7
|
-
* transport (`/browser/…`), served by the adapter behind the same App grants.
|
|
8
|
-
*/
|
|
9
1
|
import type { TenantPrincipal } from "./tenant.js";
|
|
10
2
|
import { type Routes } from "./authorization.js";
|
|
11
3
|
import type { AppToolPolicy } from "./apps/tools.js";
|
package/dist/agents.js
CHANGED
|
@@ -64,6 +64,7 @@ export function agentCapabilities(agents) {
|
|
|
64
64
|
{
|
|
65
65
|
...shared,
|
|
66
66
|
id: "agent.manage",
|
|
67
|
+
ownerDirect: ownerAgentRoutes(agents, "direct"),
|
|
67
68
|
permission: "agent.manage",
|
|
68
69
|
version: agentManage.version,
|
|
69
70
|
methods: {
|
|
@@ -133,8 +134,28 @@ export function agentCapabilities(agents) {
|
|
|
133
134
|
},
|
|
134
135
|
];
|
|
135
136
|
}
|
|
137
|
+
/** The owner capability: create, archive and restore, never Session transport. */
|
|
138
|
+
function ownerAgentRoutes(agents, via) {
|
|
139
|
+
return routes()
|
|
140
|
+
.post("/agents", owner(via), async (context, { principal }) => {
|
|
141
|
+
const body = Schema.decodeUnknownOption(createSchema)(await context.req.json());
|
|
142
|
+
if (body._tag === "None")
|
|
143
|
+
return refusal(400, "Name the agent");
|
|
144
|
+
const avatar = body.value.avatar === undefined
|
|
145
|
+
? undefined
|
|
146
|
+
: agentAvatarSchema.safeParse(body.value.avatar);
|
|
147
|
+
if (avatar?.success === false)
|
|
148
|
+
return refusal(400, "Choose a valid avatar");
|
|
149
|
+
// The owner's own authenticated request creates this Agent; its App tools
|
|
150
|
+
// are approved the same way direct owner approval is, with no second path.
|
|
151
|
+
return Response.json(await agents.create(body.value.name, body.value.requestId, principal, "owner-direct", avatar?.data));
|
|
152
|
+
})
|
|
153
|
+
.post("/agents/:agentId/archive", owner(via), (context, { principal }) => changeArchive(agents, context.req.param("agentId"), true, principal))
|
|
154
|
+
.post("/agents/:agentId/unarchive", owner(via), (context, { principal }) => changeArchive(agents, context.req.param("agentId"), false, principal));
|
|
155
|
+
}
|
|
136
156
|
function createAgentRoutes(agents) {
|
|
137
157
|
return (routes()
|
|
158
|
+
.include(ownerAgentRoutes(agents, "direct-or-app"))
|
|
138
159
|
.get("/agents", agentCollection(), async (context, { reaches }) => {
|
|
139
160
|
const selected = context.req.query("archived");
|
|
140
161
|
if (selected !== undefined &&
|
|
@@ -147,19 +168,6 @@ function createAgentRoutes(agents) {
|
|
|
147
168
|
if (await reaches(item.agentId))
|
|
148
169
|
reached.push(item);
|
|
149
170
|
return Response.json(reached);
|
|
150
|
-
})
|
|
151
|
-
.post("/agents", owner("direct-or-app"), async (context, { principal }) => {
|
|
152
|
-
const body = Schema.decodeUnknownOption(createSchema)(await context.req.json());
|
|
153
|
-
if (body._tag === "None")
|
|
154
|
-
return refusal(400, "Name the agent");
|
|
155
|
-
const avatar = body.value.avatar === undefined
|
|
156
|
-
? undefined
|
|
157
|
-
: agentAvatarSchema.safeParse(body.value.avatar);
|
|
158
|
-
if (avatar?.success === false)
|
|
159
|
-
return refusal(400, "Choose a valid avatar");
|
|
160
|
-
// The owner's own authenticated request creates this Agent; its App tools
|
|
161
|
-
// are approved the same way direct owner approval is, with no second path.
|
|
162
|
-
return Response.json(await agents.create(body.value.name, body.value.requestId, principal, "owner-direct", avatar?.data));
|
|
163
171
|
})
|
|
164
172
|
.put("/agent-names/:agentId", owner("direct-or-app"), async (context, { principal }) => {
|
|
165
173
|
const agentId = context.req.param("agentId");
|
|
@@ -198,8 +206,6 @@ function createAgentRoutes(agents) {
|
|
|
198
206
|
: Response.json(status);
|
|
199
207
|
})
|
|
200
208
|
.put("/agent-policies/:agentId", owner("direct-or-app"), async (context, { principal }) => approvePolicy(agents, principal, "owner-direct", context.req.param("agentId"), await context.req.text()))
|
|
201
|
-
.post("/agents/:agentId/archive", owner("direct-or-app"), (context, { principal }) => changeArchive(agents, context.req.param("agentId"), true, principal))
|
|
202
|
-
.post("/agents/:agentId/unarchive", owner("direct-or-app"), (context, { principal }) => changeArchive(agents, context.req.param("agentId"), false, principal))
|
|
203
209
|
.all("/agents/:agentId/*", agent(), async (context, { agentId }) => {
|
|
204
210
|
if (!agentIdPattern.test(agentId))
|
|
205
211
|
return refusal(404, "No such agent");
|
package/dist/host.d.ts
CHANGED
|
@@ -149,13 +149,16 @@ export type CapabilityAdmission = Readonly<{
|
|
|
149
149
|
export type CapabilityEnv = {
|
|
150
150
|
Bindings: CapabilityAdmission;
|
|
151
151
|
};
|
|
152
|
-
/**
|
|
152
|
+
/** An App capability adapter, with an optional narrow owner-direct table. */
|
|
153
153
|
export type OysterCapability = Readonly<CapabilityDescriptor & {
|
|
154
154
|
/** The permission declared by an App Release to use this contract. */
|
|
155
155
|
permission: AppCapabilityId;
|
|
156
156
|
/** Declared routes relative to the descriptor's base path; each names
|
|
157
157
|
* its own requirement beyond the App holding this capability. */
|
|
158
158
|
routes: Routes<CapabilityEnv>;
|
|
159
|
+
/** An explicit owner-only capability table, available without an App
|
|
160
|
+
* installation. It must not include the App's broader transport routes. */
|
|
161
|
+
ownerDirect?: Routes<OysterEnv>;
|
|
159
162
|
}>;
|
|
160
163
|
/** The host table's Hono env; every route receives its principal from its declared requirement. */
|
|
161
164
|
export type OysterEnv = {
|
package/dist/host.js
CHANGED
|
@@ -466,6 +466,15 @@ export function oysterRouteTable(host) {
|
|
|
466
466
|
candidates.some((route) => route.kind === "transport");
|
|
467
467
|
const installationId = context.req.header("X-Oyster-Installation") ??
|
|
468
468
|
(browserTransport ? url.searchParams.get("oysterInstallation") : null);
|
|
469
|
+
// A direct owner capability is a separate, narrow table. Never lend an
|
|
470
|
+
// owner's role to the ordinary App table or skip an App's installation gate.
|
|
471
|
+
if (installationId === null) {
|
|
472
|
+
const direct = candidates.find(({ capability }) => capability.ownerDirect);
|
|
473
|
+
if (direct?.capability.ownerDirect !== undefined) {
|
|
474
|
+
url.pathname = "/" + url.pathname.slice(direct.capability.base.length);
|
|
475
|
+
return serveHost(direct.capability.ownerDirect, () => Promise.resolve({ kind: "admitted", principal }), ports).fetch(new Request(url, context.req.raw));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
469
478
|
const installation = installationId === null
|
|
470
479
|
? null
|
|
471
480
|
: await host.installations.get(installationId);
|
package/docs/api/host.md
CHANGED
|
@@ -343,7 +343,7 @@ Bindings: CapabilityAdmission;
|
|
|
343
343
|
type OysterCapability = Readonly<CapabilityDescriptor & object>;
|
|
344
344
|
```
|
|
345
345
|
|
|
346
|
-
|
|
346
|
+
An App capability adapter, with an optional narrow owner-direct table.
|
|
347
347
|
|
|
348
348
|
---
|
|
349
349
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/oyster",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Run your own Apps on Cloudflare Workers or celld: installable App Releases, each with its own Durable Object, SQLite database and declared bindings",
|
|
6
6
|
"type": "module",
|
|
@@ -310,33 +310,33 @@
|
|
|
310
310
|
"@earendil-works/pi-ai": "1.3.0",
|
|
311
311
|
"@fungi.computer/agar": "0.6.1",
|
|
312
312
|
"@fungi.computer/bird-dog": "0.3.1",
|
|
313
|
-
"@fungi.computer/braid": "0.4.
|
|
313
|
+
"@fungi.computer/braid": "0.4.1",
|
|
314
314
|
"@fungi.computer/burrow": "0.2.0",
|
|
315
315
|
"@fungi.computer/cairn": "0.1.0",
|
|
316
316
|
"@fungi.computer/capnweb": "0.12.0",
|
|
317
317
|
"@fungi.computer/caps": "0.6.0",
|
|
318
318
|
"@fungi.computer/carrier": "0.2.0",
|
|
319
|
-
"@fungi.computer/computer": "0.4.
|
|
320
|
-
"@fungi.computer/computer-contract": "0.0.
|
|
319
|
+
"@fungi.computer/computer": "0.4.2",
|
|
320
|
+
"@fungi.computer/computer-contract": "0.0.8",
|
|
321
321
|
"@fungi.computer/darkroom": "0.4.1",
|
|
322
322
|
"@fungi.computer/ear-tag": "0.1.0",
|
|
323
323
|
"@fungi.computer/forage": "0.2.2",
|
|
324
324
|
"@fungi.computer/gills": "0.2.0",
|
|
325
|
-
"@fungi.computer/knapsack": "0.4.
|
|
326
|
-
"@fungi.computer/mycelium": "0.3.
|
|
325
|
+
"@fungi.computer/knapsack": "0.4.3",
|
|
326
|
+
"@fungi.computer/mycelium": "0.3.2",
|
|
327
327
|
"@fungi.computer/nacre": "0.1.2",
|
|
328
328
|
"@fungi.computer/puffball": "0.4.0",
|
|
329
329
|
"@fungi.computer/seam": "0.2.0",
|
|
330
|
-
"@fungi.computer/shiitake": "0.
|
|
331
|
-
"@fungi.computer/shiitake-extensions": "0.6.
|
|
332
|
-
"@fungi.computer/sigils": "0.
|
|
330
|
+
"@fungi.computer/shiitake": "0.9.0",
|
|
331
|
+
"@fungi.computer/shiitake-extensions": "0.6.1",
|
|
332
|
+
"@fungi.computer/sigils": "0.3.0",
|
|
333
333
|
"@fungi.computer/sprite": "0.2.0",
|
|
334
334
|
"@fungi.computer/sprite-zdog": "0.3.0",
|
|
335
335
|
"@fungi.computer/veil": "0.3.0",
|
|
336
336
|
"@fungi.computer/watchdog": "0.1.0",
|
|
337
337
|
"@fungi.computer/whistle": "0.3.0",
|
|
338
|
-
"@fungi.computer/workflows-wire": "0.4.
|
|
339
|
-
"@fungi.computer/zookeeper": "0.0.
|
|
338
|
+
"@fungi.computer/workflows-wire": "0.4.1",
|
|
339
|
+
"@fungi.computer/zookeeper": "0.0.8",
|
|
340
340
|
"@modelcontextprotocol/server": "2.0.0",
|
|
341
341
|
"@pnpm/lockfile.fs": "1100.2.13",
|
|
342
342
|
"@pnpm/lockfile.pruner": "1100.0.27",
|