@fungi.computer/oyster 0.10.0 → 0.12.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.
Files changed (107) hide show
  1. package/README.md +103 -12
  2. package/dist/agents.d.ts +66 -22
  3. package/dist/agents.js +128 -38
  4. package/dist/app-builds.d.ts +2 -0
  5. package/dist/app-builds.js +17 -6
  6. package/dist/authorization.d.ts +25 -3
  7. package/dist/authorization.js +47 -14
  8. package/dist/browser/capability-source.d.ts +23 -5
  9. package/dist/browser/capability-source.js +19 -22
  10. package/dist/browser/index.d.ts +2 -1
  11. package/dist/browser/index.js +1 -0
  12. package/dist/browser/live-view.d.ts +38 -0
  13. package/dist/browser/live-view.js +179 -0
  14. package/dist/build/artifact-writer.d.ts +11 -2
  15. package/dist/build/artifact-writer.js +42 -24
  16. package/dist/build/candidate-cli.mjs +26 -18
  17. package/dist/build/content-objects.d.ts +29 -14
  18. package/dist/build/content-objects.js +57 -19
  19. package/dist/build/local-build.js +3 -0
  20. package/dist/build/submission-contract.d.ts +1 -1
  21. package/dist/build/submission-contract.js +5 -5
  22. package/dist/build-egress.d.ts +8 -7
  23. package/dist/build-egress.js +4 -3
  24. package/dist/build.d.ts +1 -1
  25. package/dist/channels/binding.d.ts +2 -0
  26. package/dist/channels/run-decision.d.ts +33 -0
  27. package/dist/channels/run-decision.js +25 -0
  28. package/dist/channels/visitor-channel.d.ts +84 -14
  29. package/dist/channels/visitor-channel.js +55 -32
  30. package/dist/channels/visitor-edge.d.ts +18 -2
  31. package/dist/channels/visitor-edge.js +67 -5
  32. package/dist/channels/visitors.d.ts +4 -0
  33. package/dist/channels/visitors.js +22 -1
  34. package/dist/channels/web-binding.d.ts +117 -0
  35. package/dist/channels/web-binding.js +227 -0
  36. package/dist/embed-metafiles.d.ts +8 -0
  37. package/dist/embed-metafiles.js +2 -0
  38. package/dist/embed-scripts.d.ts +8 -0
  39. package/dist/embed-scripts.js +3 -0
  40. package/dist/host.d.ts +3 -1
  41. package/dist/host.js +6 -1
  42. package/dist/install-release-cli.d.ts +2 -1
  43. package/dist/install-release-cli.js +18 -10
  44. package/dist/installation-client.d.ts +1 -0
  45. package/dist/installation-operations.d.ts +2 -0
  46. package/dist/installation-operations.js +1 -0
  47. package/dist/pack.d.ts +5 -2
  48. package/dist/pack.js +3 -1
  49. package/dist/page/embed-challenge.d.ts +19 -0
  50. package/dist/page/embed-challenge.js +45 -0
  51. package/dist/page/embed-error.d.ts +2 -0
  52. package/dist/page/embed-error.js +16 -0
  53. package/dist/page/embed-loader-protocol.d.ts +12 -0
  54. package/dist/page/embed-loader-protocol.js +29 -0
  55. package/dist/standalone/agent-connections.d.ts +22 -19
  56. package/dist/standalone/agent-connections.js +150 -106
  57. package/dist/standalone/agents.d.ts +174 -16
  58. package/dist/standalone/agents.js +331 -21
  59. package/dist/standalone/browser.d.ts +14 -2
  60. package/dist/standalone/browser.js +52 -4
  61. package/dist/standalone/channel-session-door.d.ts +4 -0
  62. package/dist/standalone/channel-session-door.js +72 -0
  63. package/dist/standalone/computer-egress.d.ts +5 -3
  64. package/dist/standalone/computer-egress.js +1 -1
  65. package/dist/standalone/hello-app.d.ts +9 -0
  66. package/dist/standalone/hello-app.js +78 -0
  67. package/dist/standalone/install-apps-cli.d.ts +2 -1
  68. package/dist/standalone/install-apps-cli.js +36 -14
  69. package/dist/standalone/instance.js +2 -2
  70. package/dist/standalone/local-desktop.d.ts +11 -0
  71. package/dist/standalone/local-desktop.js +75 -0
  72. package/dist/standalone/owner-routes.d.ts +4 -3
  73. package/dist/standalone/owner-routes.js +7 -1
  74. package/dist/standalone/registry.d.ts +2 -0
  75. package/dist/standalone/sign-in-link.d.ts +9 -0
  76. package/dist/standalone/sign-in-link.js +49 -0
  77. package/dist/standalone/try-cli.d.ts +52 -0
  78. package/dist/standalone/try-cli.js +404 -0
  79. package/dist/standalone/visitor-edge.d.ts +36 -0
  80. package/dist/standalone/visitor-edge.js +67 -0
  81. package/dist/standalone/visitor-proof.d.ts +23 -0
  82. package/dist/standalone/visitor-proof.js +67 -0
  83. package/dist/standalone/website-channels.d.ts +134 -0
  84. package/dist/standalone/website-channels.js +262 -0
  85. package/dist/standalone/worker-routes.d.ts +4 -1
  86. package/dist/standalone/worker-routes.js +3 -0
  87. package/dist/standalone/worker.d.ts +2 -1
  88. package/dist/standalone/worker.js +5 -1
  89. package/dist/testing/capabilities.d.ts +3 -0
  90. package/dist/testing/capabilities.js +1 -0
  91. package/dist/testing/installation.d.ts +4 -2
  92. package/dist/testing/installation.js +7 -2
  93. package/dist/webhook-abuse.d.ts +7 -1
  94. package/dist/webhook-abuse.js +8 -2
  95. package/dist/workers-git.js +2 -2
  96. package/dist/workers.d.ts +7 -2
  97. package/dist/workers.js +1 -1
  98. package/docs/api/agents.md +103 -36
  99. package/docs/api/authorization.md +56 -11
  100. package/docs/api/browser.md +115 -8
  101. package/docs/api/build-contract.md +52 -10
  102. package/docs/api/build.md +16 -2
  103. package/docs/api/host.md +1 -0
  104. package/docs/api/pack.md +179 -3
  105. package/docs/api/workers-git.md +6 -6
  106. package/docs/site/agent-quickstart.mdx +8 -0
  107. package/package.json +34 -8
@@ -1,7 +1,7 @@
1
1
  import { defineIdFamily } from "@fungi.computer/cairn";
2
- import { ConnectionsError, createConnections, createSealedCustody, } from "@fungi.computer/veil/connections";
2
+ import { ConnectionsError, createConnections, createSealedCustody, answerMcpRequest, mcpAgentSource, } from "@fungi.computer/veil/connections";
3
3
  import * as Effect from "effect/Effect";
4
- import { maxAgentMcpServers, } from "../agents.js";
4
+ import { maxAgentConnections, } from "../agents.js";
5
5
  const ids = defineIdFamily({
6
6
  family: "oyster-connection",
7
7
  version: 1,
@@ -9,14 +9,6 @@ const ids = defineIdFamily({
9
9
  });
10
10
  /** The Oyster owner is the only actor that manages connections. */
11
11
  const owner = "owner";
12
- export async function mcpRequestData(request) {
13
- return {
14
- url: request.url,
15
- method: request.method,
16
- headers: [...request.headers],
17
- body: request.body === null ? null : await request.arrayBuffer(),
18
- };
19
- }
20
12
  /**
21
13
  * This instance's Agent MCP connections over Veil's connections core. The
22
14
  * owner holds every credential; an Agent receives a secret-free projection and
@@ -31,87 +23,153 @@ export function createAgentMcpConnections(options) {
31
23
  send: options.send,
32
24
  }),
33
25
  authorize: (actor) => actor === owner,
26
+ oauth: { callbackUrl: options.callbackUrl, fetch: options.send },
34
27
  clock: () => Date.now(),
35
28
  ids: () => ids.connection.generate(),
36
29
  });
37
30
  const run = (effect) => Effect.runPromise(effect);
38
31
  const projection = (agentId) => run(connections.projection(agentId));
39
- async function servers(agentId) {
40
- if (!options.hasAgent(agentId))
41
- return null;
42
- const [granted, listed] = await Promise.all([
43
- projection(agentId),
44
- run(connections.list(owner)),
45
- ]);
46
- return granted.connections.flatMap((connection) => connection.surface.kind === "mcp"
47
- ? [
32
+ const holdersOf = async (connectionId) => (await run(connections.list(owner))).flatMap((row) => row.connectionId === connectionId
33
+ ? row.grants.map((grant) => grant.agentId)
34
+ : []);
35
+ const toolsFor = (access) => access === "all"
36
+ ? "all"
37
+ : access === "read"
38
+ ? { effect: "read" }
39
+ : [...access];
40
+ /** Every live connection with the Agents that may use it. */
41
+ async function list() {
42
+ return (await run(connections.list(owner))).flatMap((row) => row.state === "revoked"
43
+ ? []
44
+ : [
48
45
  {
49
- serverId: connection.connectionId,
50
- name: connection.name,
51
- url: connection.surface.url,
52
- hasBearer: listed.find((row) => row.connectionId === connection.connectionId)?.credentialKind === "static",
46
+ connectionId: row.connectionId,
47
+ name: row.name,
48
+ label: row.label,
49
+ kind: row.surface.kind,
50
+ url: row.surface.url,
51
+ auth: row.credentialKind === "static"
52
+ ? "token"
53
+ : row.credentialKind === "oauth"
54
+ ? "oauth"
55
+ : "none",
56
+ state: row.state === "active" ? "connected" : row.state,
57
+ grants: row.grants.map((grant) => ({
58
+ agentId: grant.agentId,
59
+ access: grant.tools === "all"
60
+ ? "all"
61
+ : Array.isArray(grant.tools)
62
+ ? grant.tools
63
+ : "read",
64
+ })),
53
65
  },
54
- ]
55
- : []);
66
+ ]);
56
67
  }
57
- async function add(agentId, input) {
58
- const current = await servers(agentId);
59
- if (current === null)
60
- return { error: "not_found" };
68
+ /** Connect one MCP server. No Agent has it until the owner grants it. */
69
+ async function add(input) {
70
+ // Abandoned sign-ins age out before names are compared.
71
+ await run(connections.sweep());
61
72
  const url = new URL(input.url).href;
62
- if (current.some((server) => server.name === input.name || server.url === url))
63
- return { error: "duplicate_name" };
64
- if (current.length >= maxAgentMcpServers)
65
- return { error: "limit" };
66
73
  try {
67
- const draft = {
68
- requestId: ids.connection.generate(),
69
- name: input.name,
70
- surface: { kind: "mcp", url },
71
- };
72
- const { connectionId } = await run(input.bearer === null
73
- ? connections.begin(owner, { ...draft, credential: { kind: "none" } })
74
- : connections.begin(owner, {
75
- ...draft,
76
- credential: { kind: "static", placement: "bearer" },
77
- secret: input.bearer,
78
- }));
79
- await run(connections.grant(owner, { connectionId, agentId, tools: "all" }));
80
- await options.notify(agentId);
74
+ const requestId = ids.connection.generate();
75
+ const surface = { kind: "mcp", url };
76
+ const oauth = input.oauth;
77
+ const begun = await run(oauth !== undefined
78
+ ? connections.begin(owner, {
79
+ requestId,
80
+ name: input.name,
81
+ surface,
82
+ credential: {
83
+ kind: "oauth",
84
+ scope: oauth.scope,
85
+ clientId: oauth.clientId,
86
+ },
87
+ secret: oauth.clientSecret,
88
+ })
89
+ : input.bearer === null
90
+ ? connections.begin(owner, {
91
+ requestId,
92
+ name: input.name,
93
+ surface,
94
+ credential: { kind: "none" },
95
+ })
96
+ : connections.begin(owner, {
97
+ requestId,
98
+ name: input.name,
99
+ surface,
100
+ credential: { kind: "static", placement: "bearer" },
101
+ secret: input.bearer,
102
+ }));
81
103
  return {
82
- serverId: connectionId,
83
- name: input.name,
84
- url,
85
- hasBearer: input.bearer !== null,
104
+ connectionId: begun.connectionId,
105
+ authorizeUrl: begun.authorizeUrl,
86
106
  };
87
107
  }
88
108
  catch (cause) {
89
- if (cause instanceof ConnectionsError &&
90
- (cause.code === "invalid_input" || cause.code === "denied"))
109
+ if (cause instanceof ConnectionsError) {
110
+ if (cause.code === "conflict")
111
+ return { error: "duplicate_name" };
112
+ if (cause.code === "invalid_input" || cause.code === "denied")
113
+ return { error: "invalid_endpoint" };
114
+ }
115
+ throw cause;
116
+ }
117
+ }
118
+ /** Give an Agent access, or change how much it has; its next call sees the change. */
119
+ async function grant(connectionId, agentId, access) {
120
+ if (!options.hasAgent(agentId))
121
+ return { error: "not_found" };
122
+ const all = await list();
123
+ const connection = all.find((row) => row.connectionId === connectionId);
124
+ if (connection === undefined)
125
+ return { error: "not_found" };
126
+ const held = connection.grants.some((entry) => entry.agentId === agentId);
127
+ if (!held &&
128
+ all.filter((row) => row.grants.some((entry) => entry.agentId === agentId))
129
+ .length >= maxAgentConnections)
130
+ return { error: "limit" };
131
+ try {
132
+ await run(connections.grant(owner, {
133
+ connectionId,
134
+ agentId,
135
+ tools: toolsFor(access),
136
+ }));
137
+ }
138
+ catch (cause) {
139
+ if (cause instanceof ConnectionsError && cause.code === "invalid_input")
91
140
  return { error: "invalid_endpoint" };
92
141
  throw cause;
93
142
  }
143
+ await options.notify(agentId);
144
+ return { ok: true };
94
145
  }
95
- async function remove(agentId, serverId) {
96
- const current = await servers(agentId);
97
- if (current?.some((server) => server.serverId === serverId) !== true)
146
+ async function ungrant(connectionId, agentId) {
147
+ if (!(await holdersOf(connectionId)).includes(agentId))
98
148
  return false;
99
- const holders = (await run(connections.list(owner))).flatMap((row) => row.connectionId === serverId ? row.grants.map((g) => g.agentId) : []);
100
- await run(connections.revoke(owner, { connectionId: serverId }));
101
- await Promise.all(holders.map((holder) => options.notify(holder)));
149
+ await run(connections.ungrant(owner, { connectionId, agentId }));
150
+ await options.notify(agentId);
102
151
  return true;
103
152
  }
104
- /** Complete one Agent request on the owner side: the only place a credential opens. */
105
- async function fetchFor(agentId, ref, data) {
153
+ /** The tool names an MCP connection offers. */
154
+ async function tools(connectionId) {
106
155
  try {
107
- const init = {
108
- method: data.method,
109
- headers: data.headers.map(([name, value]) => [name, value]),
110
- redirect: "error",
111
- };
112
- if (data.body !== null)
113
- init.body = data.body;
114
- return await connections.egress(agentId, ref)(new Request(data.url, init));
156
+ return await run(connections.tools(owner, connectionId));
157
+ }
158
+ catch (cause) {
159
+ if (cause instanceof ConnectionsError)
160
+ return { error: "not_found" };
161
+ throw cause;
162
+ }
163
+ }
164
+ /** The browser's return from the authorization server; the Agent drops stale tools. */
165
+ async function complete(query) {
166
+ try {
167
+ const { connectionId } = await run(connections.complete(owner, query));
168
+ const holders = (await run(connections.list(owner))).flatMap((row) => row.connectionId === connectionId
169
+ ? row.grants.map((grant) => grant.agentId)
170
+ : []);
171
+ await Promise.all(holders.map((holder) => options.notify(holder)));
172
+ return { ok: true };
115
173
  }
116
174
  catch (cause) {
117
175
  if (cause instanceof ConnectionsError)
@@ -119,52 +177,38 @@ export function createAgentMcpConnections(options) {
119
177
  throw cause;
120
178
  }
121
179
  }
122
- return { servers, add, remove, projection, fetch: fetchFor };
180
+ async function remove(connectionId) {
181
+ const holders = await holdersOf(connectionId);
182
+ const known = (await list()).some((row) => row.connectionId === connectionId);
183
+ if (!known)
184
+ return false;
185
+ await run(connections.revoke(owner, { connectionId }));
186
+ await Promise.all(holders.map((holder) => options.notify(holder)));
187
+ return true;
188
+ }
189
+ /** Complete one Agent request on the owner side: the only place a credential opens. */
190
+ const fetchFor = (agentId, ref, data) => answerMcpRequest(connections.egress, agentId, ref, data);
191
+ return {
192
+ list,
193
+ add,
194
+ grant,
195
+ ungrant,
196
+ remove,
197
+ tools,
198
+ complete,
199
+ projection,
200
+ fetch: fetchFor,
201
+ };
123
202
  }
124
203
  /**
125
204
  * The Agent half: Knapsack connects to each granted server through a fetch that
126
205
  * is completed by the owner. No header, token or locator is ever held here.
127
206
  */
128
207
  export function agentMcpSourceOptions(input) {
129
- const refs = new Map();
130
208
  return {
131
209
  id: "agent-mcp",
132
- read: async () => {
133
- const granted = await input.read();
134
- refs.clear();
135
- const list = granted.connections.flatMap((connection) => {
136
- if (connection.surface.kind !== "mcp")
137
- return [];
138
- refs.set(new URL(connection.surface.url).href, {
139
- connectionId: connection.connectionId,
140
- grantVersion: connection.grantVersion,
141
- });
142
- return [
143
- {
144
- id: `mcp.${connection.connectionId}`,
145
- name: connection.name,
146
- url: new URL(connection.surface.url),
147
- },
148
- ];
149
- });
150
- return {
151
- // Secret-free: ids, versions and endpoints.
152
- version: JSON.stringify(granted.connections.map((c) => [
153
- c.connectionId,
154
- c.grantVersion,
155
- c.authorityVersion,
156
- ])),
157
- servers: list,
158
- };
159
- },
210
+ ...mcpAgentSource({ read: input.read, fetch: input.fetch }),
160
211
  subscribe: input.subscribe,
161
212
  onUnavailable: input.onUnavailable,
162
- fetch: (url, init) => {
163
- const request = new Request(url, init);
164
- const ref = refs.get(request.url);
165
- return ref === undefined
166
- ? Promise.reject(new Error("MCP server is not connected"))
167
- : input.fetch(ref, request);
168
- },
169
213
  };
170
214
  }
@@ -1,5 +1,11 @@
1
1
  import { type StandaloneTenancyEnv } from "./tenancy.js";
2
2
  import type { PostEnvelope } from "@fungi.computer/carrier/post";
3
+ import { type ChannelConversation, type ChannelConversations } from "../channels/conversations.js";
4
+ import { type WebsiteTranscript } from "@fungi.computer/nacre/website-channels";
5
+ import { type CreateWebsiteInput, type UpdateWebsiteInput, type WebsiteBinding } from "../channels/web-binding.js";
6
+ import { type WebsiteRefusal, type WebsiteSite } from "./website-channels.js";
7
+ import { type ProvenVisitor } from "./visitor-proof.js";
8
+ import type { VisitorReadOptions } from "../channels/conversations.js";
3
9
  import { type StandaloneMachineLinkBindings, type StandaloneMachineJoinResult } from "./machine-link.js";
4
10
  import { type MachineAgentSettlementPrincipal, type MachineAgentHome, type MachineEnrollment, type MachineLinkCaller, type MachineLinkIdentity } from "../machine-link/index.js";
5
11
  /** Workers AI binding surface used by the standalone provider adapter. */
@@ -25,15 +31,14 @@ import type { Avatar } from "@fungi.computer/sprite/avatar";
25
31
  import type { InvocationFrame } from "../invocation.js";
26
32
  import type { OysterJson } from "../host.js";
27
33
  import { type FleetMessage } from "@fungi.computer/shiitake/fleet";
28
- import { type AppToolPolicy } from "../apps/index.js";
34
+ import { type AppToolPolicy, type Installation } from "../apps/index.js";
29
35
  import { type OysterHost } from "../host.js";
30
36
  import { type TenantScope, type TenantId, type TenantPrincipal } from "../tenant.js";
31
37
  import type { ReadonlyTenancy } from "../tenancy/index.js";
32
38
  import type { HostActor } from "@fungi.computer/puffball/app";
33
39
  import type { OysterWorkerEnv } from "../workers.js";
34
- import type { AgentMcpServerInput } from "../agents.js";
35
- import type { EgressRef } from "@fungi.computer/veil/connections";
36
- import type { McpRequestData } from "./agent-connections.js";
40
+ import type { ConnectionAccess, ConnectionInput } from "../agents.js";
41
+ import type { EgressRef, McpRequestData } from "@fungi.computer/veil/connections";
37
42
  import type { AgentPolicyActor, OysterAgents, OysterSessionRow } from "../agents.js";
38
43
  /** The model door an agent runs on; Shiitake's own contract. */
39
44
  export type StandaloneModelSource = CloudflareShiitakeOptions["model"];
@@ -46,6 +51,12 @@ export type AgentEntry = Readonly<{
46
51
  }>;
47
52
  /** Bindings the agent host reads. */
48
53
  export type StandaloneAgentsEnv = Readonly<{
54
+ /**
55
+ * Host secret (at least 32 bytes) that signs a website visitor's identity
56
+ * between the public edge and its website Agent. Without it no website
57
+ * Agent admits a visitor. Never sent to a browser.
58
+ */
59
+ OYSTER_WEBSITE_PROOF_KEY?: string;
49
60
  /** Configured standalone-owner identity subject; never a stored member ID. */
50
61
  OYSTER_OWNER_NAME?: string;
51
62
  /** Gateway custody remains in Veil; only the host receives these bindings. */
@@ -90,6 +101,98 @@ export declare abstract class StandaloneAgentBase<Env extends StandaloneAgentEnv
90
101
  setArchived(archived: boolean): Promise<import("./agent-archive-owner.js").AgentArchiveTransitionResult>;
91
102
  /** The deployable root's host for this Agent's pinned tenant. */
92
103
  protected abstract hostFor(scope: TenantScope): Promise<OysterHost>;
104
+ private channelOwner;
105
+ private channelDoor;
106
+ private readonly acquireChannelStream;
107
+ /** The website bindings that name this Agent, as the directory last said. */
108
+ private readonly websiteBindings;
109
+ /** The owner's current record of one binding; hosts and tests supply it. */
110
+ protected readChannelBinding(bindingId: string): Promise<WebsiteBinding | null>;
111
+ /**
112
+ * Read one binding afresh from its owner: suspension, persona and edits are
113
+ * never stale. A binding that names another Agent is not this Agent's.
114
+ */
115
+ protected loadChannelBinding(bindingId: string): Promise<WebsiteBinding | null>;
116
+ /** A web host shares its edge's private assertion key with its Agent. */
117
+ protected channelProofKey(): string | null;
118
+ /**
119
+ * The one per-Session decision, with the binding read afresh: an owner
120
+ * Session is private, a visitor's runs only while its binding is active.
121
+ * Tools and permissions stay the Agent's own either way.
122
+ */
123
+ private channelRun;
124
+ /** The same decision from what this Agent already read; unknown denies. */
125
+ private cachedChannelRun;
126
+ /** Shiitake calls instructions.load at the start of the actual model turn.
127
+ * Capture that command before any asynchronous guidance can change the
128
+ * handoff version; participant projection otherwise hides its reply. A
129
+ * visitor's Session adds the fixed channel rules and the owner's persona to
130
+ * the Agent's own instructions, never replacing them. */
131
+ protected channelInstructions(source: CloudflareShiitakeOptions["instructions"]): CloudflareShiitakeOptions["instructions"];
132
+ /** Owner read of one website's conversations; the host admits the owner first. */
133
+ websiteConversations(bindingId: string): Promise<readonly ChannelConversation[]>;
134
+ /** Owner read of one conversation of a website, from its Session. */
135
+ websiteTranscript(bindingId: string, sessionId: string): Promise<WebsiteTranscript | null>;
136
+ private channelBinding;
137
+ private channelSessionDoor;
138
+ /**
139
+ * Compose Oyster's channel owner on this Agent's real store and Shiitake.
140
+ * A host must supply its own binding lookup after authenticating its edge;
141
+ * this does not install an inbound route or mint provider credentials.
142
+ */
143
+ protected channelConversations(): ChannelConversations;
144
+ /**
145
+ * Internal DO RPC only: the HTTP edge authenticates once in the central
146
+ * visitor owner, then selects this Agent. No bearer or client-provided
147
+ * visitor id enters this method. Its caller retains the SSE recheck callback.
148
+ */
149
+ private visitorConversation;
150
+ private verifiedVisitor;
151
+ sendChannelVisitor(bindingId: string, visitor: ProvenVisitor, requestId: string, text: string): Promise<import("../channels/conversations.js").IntakeResult>;
152
+ withdrawChannelVisitor(bindingId: string, visitor: ProvenVisitor, requestId: string): Promise<import("../channels/conversations.js").ChannelWithdrawResult | Readonly<{
153
+ kind: "unauthorized";
154
+ }> | Readonly<{
155
+ kind: "denied";
156
+ reason: "event_conflict" | "new_party_limit" | "banned";
157
+ }>>;
158
+ latestPendingChannelVisitor(bindingId: string, visitor: ProvenVisitor): Promise<Readonly<{
159
+ requestId: string;
160
+ commandId: string;
161
+ text: string;
162
+ delivery: "steer" | "followUp";
163
+ images?: readonly Readonly<{
164
+ type: "image";
165
+ data: string;
166
+ mimeType: string;
167
+ }>[] | undefined;
168
+ }> | Readonly<{
169
+ kind: "unauthorized";
170
+ }> | null>;
171
+ openChannelVisitor(bindingId: string, visitor: ProvenVisitor, options: VisitorReadOptions): Promise<Readonly<{
172
+ kind: "session";
173
+ snapshot: string;
174
+ }> | Readonly<{
175
+ kind: "unauthorized";
176
+ }> | Readonly<{
177
+ kind: "denied";
178
+ reason: "new_party_limit" | "banned";
179
+ }>>;
180
+ /**
181
+ * A stream is reauthorized at every beat by the central visitor owner, not
182
+ * by a callback held across this Durable Object's RPC boundary: the site must
183
+ * still be active and the visitor still live.
184
+ */
185
+ watchChannelVisitor(bindingId: string, visitor: ProvenVisitor): Promise<Readonly<{
186
+ kind: "stream";
187
+ body: ReadableStream<Uint8Array>;
188
+ }> | Readonly<{
189
+ kind: "empty" | "unauthorized";
190
+ }> | Readonly<{
191
+ kind: "denied";
192
+ reason: "suspended" | "stream_limit";
193
+ }>>;
194
+ /** Whether the central visitor owner still serves this visitor. */
195
+ protected channelVisitorLive(bindingId: string, visitorId: string): Promise<boolean>;
93
196
  private uiOwner;
94
197
  private machineClient;
95
198
  private computerSnapshot;
@@ -155,6 +258,10 @@ export declare abstract class StandaloneAgentBase<Env extends StandaloneAgentEnv
155
258
  private readonly mcpInvalidations;
156
259
  /** Host-only: the directory told us this Agent's connections changed. */
157
260
  invalidateMcpConnections(): void;
261
+ /**
262
+ * A full override must retain channelSource and channelInstructions:
263
+ * dropping them removes a suspended website's run refusal and turn capture.
264
+ */
158
265
  protected shiitakeOptions(): Promise<CloudflareShiitakeOptions>;
159
266
  /** Send an installation-admitted message through fleet Session operations. */
160
267
  sendFromApp(installationId: string, sessionId: string, message: FleetMessage): Promise<{
@@ -195,22 +302,45 @@ export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
195
302
  private mcpOwner;
196
303
  /** Loaded on the first MCP request: the SDK and OpenAPI decoders stay out of startup. */
197
304
  private mcpConnections;
198
- /** Host-only: an Agent's granted MCP servers, never their credentials. */
199
- mcpServers(agentId: string): Promise<readonly Readonly<{
200
- serverId: string;
305
+ /** Host-only: every connection with the Agents that may use it, never a credential. */
306
+ connections(): Promise<readonly Readonly<{
307
+ connectionId: string;
201
308
  name: string;
309
+ label: string;
310
+ kind: "mcp" | "openapi";
202
311
  url: string;
203
- hasBearer: boolean;
204
- }>[] | null>;
205
- addMcpServer(agentId: string, input: AgentMcpServerInput): Promise<Readonly<{
206
- serverId: string;
207
- name: string;
208
- url: string;
209
- hasBearer: boolean;
312
+ auth: "none" | "token" | "oauth";
313
+ state: "connected" | "pending" | "reconnect_required";
314
+ grants: readonly Readonly<{
315
+ agentId: string;
316
+ access: ConnectionAccess;
317
+ }>[];
318
+ }>[]>;
319
+ addConnection(input: ConnectionInput): Promise<Readonly<{
320
+ connectionId: string;
321
+ authorizeUrl: string | null;
210
322
  }> | Readonly<{
211
323
  error: "not_found" | "duplicate_name" | "limit" | "invalid_endpoint";
212
324
  }>>;
213
- removeMcpServer(agentId: string, serverId: string): Promise<boolean>;
325
+ grantConnection(connectionId: string, agentId: string, access: ConnectionAccess): Promise<Readonly<{
326
+ error: "not_found" | "duplicate_name" | "limit" | "invalid_endpoint";
327
+ }> | Readonly<{
328
+ ok: true;
329
+ }>>;
330
+ ungrantConnection(connectionId: string, agentId: string): Promise<boolean>;
331
+ removeConnection(connectionId: string): Promise<boolean>;
332
+ connectionTools(connectionId: string): Promise<readonly string[] | Readonly<{
333
+ error: "not_found" | "duplicate_name" | "limit" | "invalid_endpoint";
334
+ }>>;
335
+ completeMcpConnection(query: {
336
+ state: string;
337
+ code: string;
338
+ iss: string | undefined;
339
+ }): Promise<Readonly<{
340
+ ok: true;
341
+ }> | Readonly<{
342
+ error: string;
343
+ }>>;
214
344
  /** Secret-free grants for one Agent: ids, versions and endpoints. */
215
345
  mcpProjection(agentId: string): Promise<Readonly<{
216
346
  revision: number;
@@ -219,6 +349,7 @@ export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
219
349
  name: string;
220
350
  surface: import("@fungi.computer/veil/connections").SurfaceView;
221
351
  tools: import("@fungi.computer/veil/connections").Tools;
352
+ version: number;
222
353
  authorityVersion: number;
223
354
  grantVersion: number;
224
355
  }>[];
@@ -286,6 +417,29 @@ export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
286
417
  readAgentComputers(agentId: string, principal: TenantPrincipal, tenantId?: TenantId): Promise<StandaloneAgentComputerReply>;
287
418
  /** Every captured native call rechecks the exact live attachment and credential owner. */
288
419
  admitAgentComputer(captured: Pick<AgentComputerConnection, "scopeId" | "agentId" | "attachment">, tenantId: TenantId): Promise<Omit<ComputerGrant, "egress">>;
420
+ private websiteChannelsOwner;
421
+ private websites;
422
+ /** Owner read of every website bound to one of this tenant's Agents. */
423
+ websiteList(principal: TenantPrincipal): readonly WebsiteBinding[] | WebsiteRefusal;
424
+ /** Owner-only: put a chosen Agent behind a new site key. */
425
+ websiteCreate(principal: TenantPrincipal, input: CreateWebsiteInput, requestId: string): WebsiteBinding | WebsiteRefusal;
426
+ /** Owner-only edit, fenced by the version the owner last read. */
427
+ websiteUpdate(principal: TenantPrincipal, bindingId: string, input: UpdateWebsiteInput): WebsiteBinding | WebsiteRefusal;
428
+ /** Host-only: the binding a website Agent serves, read fresh on every use. */
429
+ websiteBinding(bindingId: string): WebsiteBinding | null;
430
+ /** Host-only public lookup: a site key resolves to its site, or to nothing. */
431
+ websiteSite(siteKey: string): WebsiteSite | null;
432
+ websiteMint(bindingId: string, siteKey: string, addressHash: string): Promise<import("../channels/visitors.js").VisitorGrant>;
433
+ websiteRefresh(bindingId: string, refreshSecret: string): Promise<import("../channels/visitors.js").VisitorGrant>;
434
+ websiteRotate(bindingId: string, siteKey: string, accessToken: string, addressHash: string): Promise<import("../channels/visitors.js").VisitorGrant | Readonly<{
435
+ kind: "unauthorized";
436
+ }>>;
437
+ websiteVisitorLive(bindingId: string, visitorId: string): boolean;
438
+ websiteAuthenticate(bindingId: string, accessToken: string): Promise<Readonly<{
439
+ visitorId: string;
440
+ expiresAt: number;
441
+ addressHash: string;
442
+ }> | null>;
289
443
  list(options?: Readonly<{
290
444
  archived?: boolean;
291
445
  }>): readonly AgentEntry[];
@@ -388,6 +542,10 @@ export declare const agentFrameMethods: {
388
542
  readonly visited: true;
389
543
  };
390
544
  requiredOperations: () => string[];
545
+ requestedResource: (raw: readonly unknown[]) => {
546
+ kind: string;
547
+ id: string;
548
+ };
391
549
  };
392
550
  };
393
551
  AGENTS: {
@@ -562,5 +720,5 @@ export declare const agentFrameMethods: {
562
720
  };
563
721
  };
564
722
  /** Provider effects are admitted by the originating Instance's live frame. */
565
- export declare function dispatchAgentBinding(env: StandaloneAgentsEnv, scope: TenantScope, frame: InvocationFrame, props: FrameBindingProps, method: string, args: readonly unknown[]): Promise<OysterJson>;
723
+ export declare function dispatchAgentBinding(env: StandaloneAgentsEnv, scope: TenantScope, frame: InvocationFrame, props: FrameBindingProps, method: string, args: readonly unknown[], admitted: Installation): Promise<OysterJson>;
566
724
  export {};