@fungi.computer/oyster 0.8.0 → 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/build/candidate-cli.mjs +2 -0
- package/dist/host.d.ts +4 -1
- package/dist/host.js +9 -0
- package/dist/page-script.js +1 -1
- 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");
|
|
@@ -22397,6 +22397,8 @@ var symbols = {
|
|
|
22397
22397
|
sell: (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [(0, import_jsx_runtime4.jsx)("path", { fill: yellow, d: "M6.4 41.2V48.4C6.4 51.4 13.2 54 21.8 54S37.2 51.4 37.2 48.4V41.2C37.2 37.8 30.4 35 21.8 35S6.4 37.8 6.4 41.2Z" }), (0, import_jsx_runtime4.jsx)("ellipse", { fill: cream, cx: "21.9", cy: "40.8", rx: "13.2", ry: "3.6" }), (0, import_jsx_runtime4.jsxs)("g", { transform: "rotate(-3 22.5 30) translate(0.5 0)", children: [(0, import_jsx_runtime4.jsx)("path", { fill: yellow, d: "M7.5 26V34C7.5 37.3 14.2 40 22.5 40S37.5 37.3 37.5 34V26C37.5 22.7 30.8 20 22.5 20S7.5 22.7 7.5 26Z" }), (0, import_jsx_runtime4.jsx)("ellipse", { fill: cream, cx: "23.7", cy: "26.55", rx: "13.05", ry: "4.4" })] }), (0, import_jsx_runtime4.jsxs)("g", { transform: "translate(46.3 40.3) rotate(-25)", children: [(0, import_jsx_runtime4.jsx)("path", { fill: coral, d: "M-8.5-10Q-8.5-12-7-13L-1.5-16.3Q0-17.2 1.5-16.3L7-13Q8.5-12 8.5-10V9Q8.5 12 5.5 12H-5.5Q-8.5 12-8.5 9Z" }), (0, import_jsx_runtime4.jsx)("circle", { fill: cream, cx: "0", cy: "-10.7", r: "2.2" })] }), (0, import_jsx_runtime4.jsx)(TaperedRay, { fill: yellow, transform: "translate(38.2 18.6) scale(1.1 .86)" }), (0, import_jsx_runtime4.jsx)(TaperedRay, { fill: yellow, transform: "translate(42.8 21.2) rotate(45) scale(1.1 .85)" })] }),
|
|
22398
22398
|
// Schedules and recurring runs: a calendar page with a clock.
|
|
22399
22399
|
schedule: (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [(0, import_jsx_runtime4.jsx)("rect", { fill: cream, x: "6", y: "11", width: "47.6", height: "44", rx: "6" }), (0, import_jsx_runtime4.jsx)("path", { fill: coral, d: "M12 11H47.6Q53.6 11 53.6 17V21.5H6V17Q6 11 12 11Z" }), (0, import_jsx_runtime4.jsxs)("g", { fill: cream, children: [(0, import_jsx_runtime4.jsx)("circle", { cx: "16.1", cy: "16.15", r: "3.4" }), (0, import_jsx_runtime4.jsx)("circle", { cx: "43.4", cy: "16.15", r: "3.4" })] }), (0, import_jsx_runtime4.jsxs)("g", { fill: blue, children: [(0, import_jsx_runtime4.jsx)("rect", { x: "13.6", y: "6", width: "5", height: "11.2", rx: "2.5" }), (0, import_jsx_runtime4.jsx)("rect", { x: "40.9", y: "6", width: "5", height: "11.2", rx: "2.5" })] }), (0, import_jsx_runtime4.jsxs)("g", { fill: mint, children: [(0, import_jsx_runtime4.jsx)("rect", { x: "11.1", y: "25.1", width: "6.9", height: "6.6", rx: "1.8" }), (0, import_jsx_runtime4.jsx)("rect", { x: "20.7", y: "25.1", width: "6.9", height: "6.6", rx: "1.8" }), (0, import_jsx_runtime4.jsx)("rect", { x: "30.4", y: "25.1", width: "6.9", height: "6.6", rx: "1.8" }), (0, import_jsx_runtime4.jsx)("rect", { x: "20.7", y: "33.9", width: "6.9", height: "6.6", rx: "1.8" }), (0, import_jsx_runtime4.jsx)("rect", { x: "30.4", y: "33.9", width: "6.9", height: "6.6", rx: "1.8" }), (0, import_jsx_runtime4.jsx)("rect", { x: "11.1", y: "42.7", width: "6.9", height: "6.6", rx: "1.8" }), (0, import_jsx_runtime4.jsx)("rect", { x: "30.4", y: "42.7", width: "6.9", height: "6.6", rx: "1.8" })] }), (0, import_jsx_runtime4.jsxs)("g", { fill: grape, children: [(0, import_jsx_runtime4.jsx)("rect", { x: "40.4", y: "25.1", width: "6.9", height: "6.6", rx: "1.8" }), (0, import_jsx_runtime4.jsx)("rect", { x: "11.1", y: "33.9", width: "6.9", height: "6.6", rx: "1.8" }), (0, import_jsx_runtime4.jsx)("rect", { x: "20.7", y: "42.7", width: "6.9", height: "6.6", rx: "1.8" })] }), (0, import_jsx_runtime4.jsx)("circle", { fill: yellow, cx: "45.5", cy: "45.6", r: "12.2" }), (0, import_jsx_runtime4.jsx)("path", { fill: "none", stroke: ink, strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", d: "M45.1 39.3V46.2L51.3 49.8" }), (0, import_jsx_runtime4.jsx)("circle", { fill: ink, cx: "45.1", cy: "46.2", r: "2.5" })] }),
|
|
22400
|
+
// Loop: one prompt inside a returning circular arrow.
|
|
22401
|
+
loop: (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [(0, import_jsx_runtime4.jsx)("path", { style: { stroke: coral }, strokeWidth: "6", strokeLinecap: "round", d: "M47.5 14.5C43 11 37.5 9 32 9 19.5 9 9 19.5 9 32S19.5 55 32 55 55 44.5 55 32" }), (0, import_jsx_runtime4.jsx)("path", { style: { fill: coral }, d: "M53.5 21.5Q54.5 20 55 22L58 33Q58.5 35 56.5 34.5L48.5 32.5Q47 32 48 30.5Z" }), (0, import_jsx_runtime4.jsx)("g", { transform: "translate(18 21) scale(.28)", children: (0, import_jsx_runtime4.jsx)(SpeechBubble, { fill: blue }) }), (0, import_jsx_runtime4.jsxs)("g", { style: { fill: cream }, children: [(0, import_jsx_runtime4.jsx)("rect", { x: "25", y: "27.5", width: "14", height: "3", rx: "1.5" }), (0, import_jsx_runtime4.jsx)("rect", { x: "25", y: "33.5", width: "9", height: "3", rx: "1.5" })] })] }),
|
|
22400
22402
|
// Fungi: Shiitake, the brand mushroom, winking.
|
|
22401
22403
|
fungi: (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [(0, import_jsx_runtime4.jsx)("ellipse", { fill: cream, cx: "33.5", cy: "43.6", rx: "18.6", ry: "14.4", transform: "rotate(-6 33.5 43.6)" }), (0, import_jsx_runtime4.jsx)("path", { fill: coral, d: "M29.5 6.5C22 7.5 16 11 11 18.5 4 29 4.6 39.6 13.5 42.2 24 45 44 40.5 54 34.6 57.6 32.6 58.6 29.2 57.5 25 56.5 20 53 16 48.5 13 43.5 8 37 5.5 29.5 6.5Z" }), (0, import_jsx_runtime4.jsxs)("g", { fill: cream, children: [(0, import_jsx_runtime4.jsx)("ellipse", { cx: "29", cy: "15.7", rx: "8.7", ry: "6.3", transform: "rotate(-15.5 29 15.7)" }), (0, import_jsx_runtime4.jsx)("ellipse", { cx: "50.8", cy: "20.1", rx: "6.5", ry: "3.5", transform: "rotate(51.6 50.8 20.1)" }), (0, import_jsx_runtime4.jsx)("ellipse", { cx: "13", cy: "26.8", rx: "4.2", ry: "3.3", transform: "rotate(-54.5 13 26.8)" })] }), (0, import_jsx_runtime4.jsxs)("g", { fill: ink, transform: "translate(26.6 46.6) scale(1.1) translate(-33.7 -38.5)", children: [(0, import_jsx_runtime4.jsx)("rect", { x: "31.85", y: "35.9", width: "3.75", height: "5.25", rx: "1.85" }), (0, import_jsx_runtime4.jsx)("path", { d: "M 47.4 34.3 C 46 35 44.6 35.8 43.5 36.7 42.9 37.2 43.2 38.3 44 38.4 45.2 38.6 46.5 38.6 47.7 38.4 48.4 38.3 48.3 37.3 47.6 37.3 46.6 37.4 45.7 37.4 45 37.3 45.9 36.7 46.9 36.1 48 35.6 48.7 35.3 48.2 34 47.4 34.3 Z" }), (0, import_jsx_runtime4.jsx)("path", { d: "M 37.4 41.1 C 38.6 44.3 42.6 44.3 43.6 40.5 43.7 40 43.1 39.8 42.9 40.3 41.9 42.8 39.1 42.9 38.3 40.7 38.1 40.2 37.3 40.5 37.4 41.1 Z" })] })] })
|
|
22402
22404
|
};
|
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);
|