@fungi.computer/oyster 0.53.1 → 0.54.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/agents.d.ts CHANGED
@@ -194,6 +194,25 @@ export type OysterAgents = Readonly<{
194
194
  approveAppToolPolicy(agentId: string, principal: TenantPrincipal, level: AppToolPolicy["level"], expectedRevision: string | null, actor: AgentPolicyActor): Promise<AppToolPolicy | PendingAgentPolicy | Readonly<{
195
195
  error: "not_found" | "revision_conflict" | "not_granted";
196
196
  }>>;
197
+ /**
198
+ * The installations the owner attached to this Agent as hosted
199
+ * extensions, or `null` for no such Agent. An Agent's App-tool approval
200
+ * alone never asks an extension.
201
+ */
202
+ extensionAttachments(agentId: string): Promise<readonly Readonly<{
203
+ installationId: string;
204
+ }>[] | null>;
205
+ /** Attach an enabled installation whose Release is an Agent extension. */
206
+ attachExtension(agentId: string, installationId: string, principal: TenantPrincipal): Promise<Readonly<{
207
+ installationId: string;
208
+ attachedBy: string;
209
+ }> | Readonly<{
210
+ error: "not_found" | "not_granted" | "not_extension";
211
+ }>>;
212
+ /** Detach a hosted extension; detaching only removes authority. */
213
+ detachExtension(agentId: string, installationId: string, principal: TenantPrincipal): Promise<"detached" | "absent" | Readonly<{
214
+ error: "not_found" | "not_granted";
215
+ }>>;
197
216
  /**
198
217
  * Whether a model and an image provider are connected, so an App can say so
199
218
  * before it takes a prompt. Reads configuration; never reaches a provider.
package/dist/agents.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { bodyAtMost } from "./body-limit.js";
2
2
  import { destinationsSchema, subjectSchema, } from "@fungi.computer/veil/connections";
3
3
  import { agent, agents as agentCollection, owner, routes, } from "./authorization.js";
4
+ import { installationIdSchema } from "./apps/installation.js";
4
5
  import * as Schema from "effect/Schema";
5
6
  import { agentNameSchema } from "@fungi.computer/agar/agents";
6
7
  import { z } from "zod";
@@ -469,6 +470,39 @@ export function agentApprovalRoutes(agents) {
469
470
  ? 403
470
471
  : 409, choice.error)
471
472
  : Response.json(choice);
473
+ })
474
+ .get("/api/agent-extensions/:agentId", owner("direct"), async (context) => {
475
+ const agentId = context.req.param("agentId");
476
+ if (!agentIdPattern.test(agentId))
477
+ return refusal(404, "No such agent");
478
+ const attachments = await agents.extensionAttachments(agentId);
479
+ return attachments === null
480
+ ? refusal(404, "No such agent")
481
+ : Response.json({ attachments });
482
+ })
483
+ .put("/api/agent-extensions/:agentId/:installationId", owner("direct"), async (context, { principal }) => {
484
+ const agentId = context.req.param("agentId");
485
+ const installationId = installationIdSchema.safeParse(context.req.param("installationId"));
486
+ if (!agentIdPattern.test(agentId) || !installationId.success)
487
+ return refusal(404, "No such agent or installation");
488
+ const result = await agents.attachExtension(agentId, installationId.data, principal);
489
+ if (!("error" in result))
490
+ return Response.json(result);
491
+ return refusal(result.error === "not_found"
492
+ ? 404
493
+ : result.error === "not_granted"
494
+ ? 403
495
+ : 409, result.error);
496
+ })
497
+ .delete("/api/agent-extensions/:agentId/:installationId", owner("direct"), async (context, { principal }) => {
498
+ const agentId = context.req.param("agentId");
499
+ const installationId = installationIdSchema.safeParse(context.req.param("installationId"));
500
+ if (!agentIdPattern.test(agentId) || !installationId.success)
501
+ return refusal(404, "No such agent or installation");
502
+ const result = await agents.detachExtension(agentId, installationId.data, principal);
503
+ if (result === "detached" || result === "absent")
504
+ return Response.json({ result });
505
+ return refusal(result.error === "not_found" ? 404 : 403, result.error);
472
506
  })
473
507
  .get("/api/agent-policies/:agentId", owner("direct"), async (context) => {
474
508
  const agentId = context.req.param("agentId");