@fungi.computer/oyster 0.9.0 → 0.11.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 (96) hide show
  1. package/README.md +46 -2
  2. package/dist/agents.d.ts +82 -23
  3. package/dist/agents.js +187 -40
  4. package/dist/authorization.d.ts +25 -3
  5. package/dist/authorization.js +47 -14
  6. package/dist/browser/capability-source.d.ts +23 -5
  7. package/dist/browser/capability-source.js +19 -22
  8. package/dist/browser/index.d.ts +2 -1
  9. package/dist/browser/index.js +1 -0
  10. package/dist/browser/live-view.d.ts +38 -0
  11. package/dist/browser/live-view.js +179 -0
  12. package/dist/channels/binding.d.ts +2 -0
  13. package/dist/channels/run-decision.d.ts +33 -0
  14. package/dist/channels/run-decision.js +25 -0
  15. package/dist/channels/visitor-channel.d.ts +84 -14
  16. package/dist/channels/visitor-channel.js +55 -32
  17. package/dist/channels/visitor-edge.d.ts +18 -2
  18. package/dist/channels/visitor-edge.js +67 -5
  19. package/dist/channels/visitors.d.ts +4 -0
  20. package/dist/channels/visitors.js +22 -1
  21. package/dist/channels/web-binding.d.ts +117 -0
  22. package/dist/channels/web-binding.js +227 -0
  23. package/dist/computer-control-port.d.ts +20 -1
  24. package/dist/embed-metafiles.d.ts +8 -0
  25. package/dist/embed-metafiles.js +2 -0
  26. package/dist/embed-scripts.d.ts +8 -0
  27. package/dist/embed-scripts.js +3 -0
  28. package/dist/host.d.ts +3 -1
  29. package/dist/host.js +6 -1
  30. package/dist/mcp.d.ts +128 -0
  31. package/dist/mcp.js +63 -1
  32. package/dist/page/embed-challenge.d.ts +19 -0
  33. package/dist/page/embed-challenge.js +45 -0
  34. package/dist/page/embed-error.d.ts +2 -0
  35. package/dist/page/embed-error.js +16 -0
  36. package/dist/page/embed-loader-protocol.d.ts +12 -0
  37. package/dist/page/embed-loader-protocol.js +29 -0
  38. package/dist/standalone/agent-computers.d.ts +12 -1
  39. package/dist/standalone/agent-computers.js +35 -0
  40. package/dist/standalone/agent-connections.d.ts +50 -0
  41. package/dist/standalone/agent-connections.js +214 -0
  42. package/dist/standalone/agent-model-choice.d.ts +7 -3
  43. package/dist/standalone/agent-model-choice.js +33 -4
  44. package/dist/standalone/agents.d.ts +224 -9
  45. package/dist/standalone/agents.js +485 -115
  46. package/dist/standalone/browser.d.ts +16 -3
  47. package/dist/standalone/browser.js +54 -5
  48. package/dist/standalone/channel-session-door.d.ts +4 -0
  49. package/dist/standalone/channel-session-door.js +72 -0
  50. package/dist/standalone/computer-control.js +55 -1
  51. package/dist/standalone/computer-fleet.d.ts +21 -0
  52. package/dist/standalone/computer-fleet.js +30 -6
  53. package/dist/standalone/computer.d.ts +20 -1
  54. package/dist/standalone/computer.js +63 -1
  55. package/dist/standalone/model-key-vault.d.ts +50 -0
  56. package/dist/standalone/model-key-vault.js +147 -0
  57. package/dist/standalone/owner-routes.d.ts +4 -3
  58. package/dist/standalone/owner-routes.js +7 -1
  59. package/dist/standalone/registry.d.ts +23 -0
  60. package/dist/standalone/registry.js +30 -0
  61. package/dist/standalone/visitor-edge.d.ts +36 -0
  62. package/dist/standalone/visitor-edge.js +67 -0
  63. package/dist/standalone/visitor-proof.d.ts +23 -0
  64. package/dist/standalone/visitor-proof.js +67 -0
  65. package/dist/standalone/web.d.ts +10 -0
  66. package/dist/standalone/web.js +34 -0
  67. package/dist/standalone/website-channels.d.ts +134 -0
  68. package/dist/standalone/website-channels.js +262 -0
  69. package/dist/standalone/worker-routes.d.ts +6 -1
  70. package/dist/standalone/worker-routes.js +4 -0
  71. package/dist/standalone/worker.d.ts +2 -1
  72. package/dist/standalone/worker.js +13 -1
  73. package/dist/testing/capabilities.d.ts +3 -0
  74. package/dist/testing/capabilities.js +1 -0
  75. package/dist/testing/installation.d.ts +4 -2
  76. package/dist/testing/installation.js +7 -2
  77. package/dist/web/index.d.ts +3 -0
  78. package/dist/web/index.js +3 -0
  79. package/dist/web/search-contract.d.ts +19 -0
  80. package/dist/web/search-contract.js +14 -0
  81. package/dist/web/search.d.ts +25 -0
  82. package/dist/web/search.js +123 -0
  83. package/dist/web/source.d.ts +46 -0
  84. package/dist/web/source.js +335 -0
  85. package/dist/workers-git.js +3 -2
  86. package/docs/api/agents.md +184 -39
  87. package/docs/api/apps.md +129 -111
  88. package/docs/api/browser.md +115 -8
  89. package/docs/api/build-contract.md +27 -21
  90. package/docs/api/build.md +55 -54
  91. package/docs/api/git.md +3 -3
  92. package/docs/api/host.md +69 -60
  93. package/docs/api/mcp.md +81 -44
  94. package/docs/api/workers-git.md +6 -6
  95. package/docs/api/workers.md +53 -47
  96. package/package.json +52 -22
@@ -0,0 +1,214 @@
1
+ import { defineIdFamily } from "@fungi.computer/cairn";
2
+ import { ConnectionsError, createConnections, createSealedCustody, answerMcpRequest, mcpAgentSource, } from "@fungi.computer/veil/connections";
3
+ import * as Effect from "effect/Effect";
4
+ import { maxAgentConnections, } from "../agents.js";
5
+ const ids = defineIdFamily({
6
+ family: "oyster-connection",
7
+ version: 1,
8
+ kinds: { connection: { prefix: "conn" } },
9
+ });
10
+ /** The Oyster owner is the only actor that manages connections. */
11
+ const owner = "owner";
12
+ /**
13
+ * This instance's Agent MCP connections over Veil's connections core. The
14
+ * owner holds every credential; an Agent receives a secret-free projection and
15
+ * a fetch that only the owner side can complete.
16
+ */
17
+ export function createAgentMcpConnections(options) {
18
+ const connections = createConnections({
19
+ ownerId: options.ownerId,
20
+ store: options.store,
21
+ custody: createSealedCustody({
22
+ vault: options.vault,
23
+ send: options.send,
24
+ }),
25
+ authorize: (actor) => actor === owner,
26
+ oauth: { callbackUrl: options.callbackUrl, fetch: options.send },
27
+ clock: () => Date.now(),
28
+ ids: () => ids.connection.generate(),
29
+ });
30
+ const run = (effect) => Effect.runPromise(effect);
31
+ const projection = (agentId) => run(connections.projection(agentId));
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
+ : [
45
+ {
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
+ })),
65
+ },
66
+ ]);
67
+ }
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());
72
+ const url = new URL(input.url).href;
73
+ try {
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
+ }));
103
+ return {
104
+ connectionId: begun.connectionId,
105
+ authorizeUrl: begun.authorizeUrl,
106
+ };
107
+ }
108
+ catch (cause) {
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")
140
+ return { error: "invalid_endpoint" };
141
+ throw cause;
142
+ }
143
+ await options.notify(agentId);
144
+ return { ok: true };
145
+ }
146
+ async function ungrant(connectionId, agentId) {
147
+ if (!(await holdersOf(connectionId)).includes(agentId))
148
+ return false;
149
+ await run(connections.ungrant(owner, { connectionId, agentId }));
150
+ await options.notify(agentId);
151
+ return true;
152
+ }
153
+ /** The tool names an MCP connection offers. */
154
+ async function tools(connectionId) {
155
+ try {
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 };
173
+ }
174
+ catch (cause) {
175
+ if (cause instanceof ConnectionsError)
176
+ return { error: cause.code };
177
+ throw cause;
178
+ }
179
+ }
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
+ };
202
+ }
203
+ /**
204
+ * The Agent half: Knapsack connects to each granted server through a fetch that
205
+ * is completed by the owner. No header, token or locator is ever held here.
206
+ */
207
+ export function agentMcpSourceOptions(input) {
208
+ return {
209
+ id: "agent-mcp",
210
+ ...mcpAgentSource({ read: input.read, fetch: input.fetch }),
211
+ subscribe: input.subscribe,
212
+ onUnavailable: input.onUnavailable,
213
+ };
214
+ }
@@ -1,6 +1,9 @@
1
1
  import type { Api, Model } from "@earendil-works/pi-ai";
2
2
  import * as Schema from "effect/Schema";
3
- /** A credential-source address, not credential material or a custodian locator. */
3
+ /**
4
+ * A credential-source address, not credential material. `byok` names one of the
5
+ * instance's sealed model keys by id; no other source carries a key id.
6
+ */
4
7
  export declare const agentModelChoiceSchema: Schema.Struct<{
5
8
  readonly keySource: Schema.Literals<readonly ["workers-ai", "ai-gateway", "byok"]>;
6
9
  readonly model: Schema.Struct<{
@@ -8,11 +11,12 @@ export declare const agentModelChoiceSchema: Schema.Struct<{
8
11
  readonly modelId: Schema.String;
9
12
  readonly reasoning: Schema.optional<Schema.Literals<readonly ["minimal", "low", "medium", "high", "xhigh", "max"]>>;
10
13
  }>;
14
+ readonly keyId: Schema.optional<Schema.NonEmptyString>;
11
15
  }>;
12
16
  /** The Agent's model preference and source reference, never credential material. */
13
17
  export type AgentModelChoice = typeof agentModelChoiceSchema.Type;
14
18
  /** Stable reason for rejecting a model or credential source before a run. */
15
- export type AgentModelRefusal = "invalid_model_choice" | "unsupported_key_source" | "key_source_mismatch" | "model_unavailable" | "key_not_connected";
19
+ export type AgentModelRefusal = "invalid_model_choice" | "unsupported_key_source" | "key_source_mismatch" | "model_unavailable" | "key_not_connected" | "key_removed";
16
20
  export declare class AgentModelRefused extends Error {
17
21
  readonly reason: AgentModelRefusal;
18
22
  constructor(reason: AgentModelRefusal);
@@ -23,7 +27,7 @@ export declare function selectAgentModel(choice: AgentModelChoice): Promise<Mode
23
27
  export declare function agentModelChoice(storage: Readonly<{
24
28
  get<T = unknown>(key: string): Promise<T | undefined>;
25
29
  put(key: string, value: AgentModelChoice): Promise<void>;
26
- }>, admit: (choice: AgentModelChoice) => void): {
30
+ }>, admit: (choice: AgentModelChoice) => void | Promise<void>): {
27
31
  read(): Promise<AgentModelChoice>;
28
32
  set(input: AgentModelChoice): Promise<AgentModelChoice>;
29
33
  };
@@ -1,10 +1,15 @@
1
1
  import { ModelPreferenceSchema } from "@fungi.computer/shiitake/model-preference";
2
2
  import { cloudflareWorkersAIProvider } from "@earendil-works/pi-ai/providers/cloudflare-workers-ai";
3
+ import { isModelKeyProvider } from "@fungi.computer/veil/model-keys";
3
4
  import * as Schema from "effect/Schema";
4
- /** A credential-source address, not credential material or a custodian locator. */
5
+ /**
6
+ * A credential-source address, not credential material. `byok` names one of the
7
+ * instance's sealed model keys by id; no other source carries a key id.
8
+ */
5
9
  export const agentModelChoiceSchema = Schema.Struct({
6
10
  keySource: Schema.Literals(["workers-ai", "ai-gateway", "byok"]),
7
11
  model: ModelPreferenceSchema,
12
+ keyId: Schema.optional(Schema.NonEmptyString),
8
13
  });
9
14
  export class AgentModelRefused extends Error {
10
15
  reason;
@@ -22,11 +27,32 @@ const defaultChoice = {
22
27
  modelId: "@cf/moonshotai/kimi-k2.6",
23
28
  },
24
29
  };
30
+ /** Pi's maintained catalog for a provider a key may be brought for. */
31
+ async function byokCatalog(provider) {
32
+ if (provider === "anthropic")
33
+ return (await import("@earendil-works/pi-ai/providers/anthropic"))
34
+ .anthropicProvider()
35
+ .getModels();
36
+ if (provider === "openai")
37
+ return (await import("@earendil-works/pi-ai/providers/openai"))
38
+ .openaiProvider()
39
+ .getModels();
40
+ return (await import("@earendil-works/pi-ai/providers/openrouter"))
41
+ .openrouterProvider()
42
+ .getModels();
43
+ }
25
44
  /** Read the maintained Pi catalog; never accept a model from a different egress. */
26
45
  export async function selectAgentModel(choice) {
27
- if (choice.keySource === "byok")
28
- throw new AgentModelRefused("unsupported_key_source");
29
46
  const { providerId, modelId, reasoning } = choice.model;
47
+ if (choice.keySource === "byok") {
48
+ // Only a catalogued provider's own models; an OpenAI-compatible base has none.
49
+ if (!isModelKeyProvider(providerId) || providerId === "openai-compatible")
50
+ throw new AgentModelRefused("unsupported_key_source");
51
+ const found = (await byokCatalog(providerId)).find((item) => item.id === modelId);
52
+ if (found === undefined || (reasoning !== undefined && !found.reasoning))
53
+ throw new AgentModelRefused("model_unavailable");
54
+ return found;
55
+ }
30
56
  if ((choice.keySource === "workers-ai" &&
31
57
  providerId !== "cloudflare-workers-ai") ||
32
58
  (choice.keySource === "ai-gateway" &&
@@ -63,8 +89,11 @@ export function agentModelChoice(storage, admit) {
63
89
  if (parsed._tag === "None")
64
90
  throw new AgentModelRefused("invalid_model_choice");
65
91
  const choice = parsed.value;
92
+ // A key id belongs to byok alone, and byok cannot run without one.
93
+ if ((choice.keySource === "byok") !== (choice.keyId !== undefined))
94
+ throw new AgentModelRefused("invalid_model_choice");
66
95
  await selectAgentModel(choice);
67
- admit(choice);
96
+ await admit(choice);
68
97
  await storage.put(key, choice);
69
98
  return choice;
70
99
  },
@@ -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. */
@@ -15,6 +21,7 @@ import { type ComputerGrant } from "@fungi.computer/computer/fleet";
15
21
  import { DurableObject } from "cloudflare:workers";
16
22
  import type { StandaloneComputerEnv } from "./computer.js";
17
23
  import { ShiitakeDO } from "@fungi.computer/shiitake/cloudflare";
24
+ import { type ModelKeyRecord, type ModelKeyRefusal, type ModelKeySealInput } from "./model-key-vault.js";
18
25
  import type { CloudflareShiitakeOptions } from "@fungi.computer/shiitake/cloudflare";
19
26
  import { type AgentModelChoice, type AgentModelRefusal } from "./agent-model-choice.js";
20
27
  import * as Schema from "effect/Schema";
@@ -30,7 +37,8 @@ import { type TenantScope, type TenantId, type TenantPrincipal } from "../tenant
30
37
  import type { ReadonlyTenancy } from "../tenancy/index.js";
31
38
  import type { HostActor } from "@fungi.computer/puffball/app";
32
39
  import type { OysterWorkerEnv } from "../workers.js";
33
- import { type AgentMcpServer, type AgentMcpServerInput, type AgentMcpServerRefusal } from "../agents.js";
40
+ import type { ConnectionAccess, ConnectionInput } from "../agents.js";
41
+ import type { EgressRef, McpRequestData } from "@fungi.computer/veil/connections";
34
42
  import type { AgentPolicyActor, OysterAgents, OysterSessionRow } from "../agents.js";
35
43
  /** The model door an agent runs on; Shiitake's own contract. */
36
44
  export type StandaloneModelSource = CloudflareShiitakeOptions["model"];
@@ -43,12 +51,20 @@ export type AgentEntry = Readonly<{
43
51
  }>;
44
52
  /** Bindings the agent host reads. */
45
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;
46
60
  /** Configured standalone-owner identity subject; never a stored member ID. */
47
61
  OYSTER_OWNER_NAME?: string;
48
62
  /** Gateway custody remains in Veil; only the host receives these bindings. */
49
63
  AI_GATEWAY_AUTH_TOKEN?: string;
50
64
  AI_GATEWAY_ACCOUNT_ID?: string;
51
65
  AI_GATEWAY_ID?: string;
66
+ /** Optional owner-funded Parallel key for `web.search`; Veil holds custody. */
67
+ PARALLEL_API_KEY?: string;
52
68
  /** Workers AI, the default model door. */
53
69
  AI?: AiBinding;
54
70
  /** The AI Gateway the binding routes through (default `default`). */
@@ -59,6 +75,8 @@ export type StandaloneAgentsEnv = Readonly<{
59
75
  KEYS?: StandaloneTenancyEnv["KEYS"];
60
76
  OYSTER_ORIGIN: string;
61
77
  OYSTER_OWNER_KEY?: string;
78
+ /** Instance credential key (32 bytes, base64url) that seals model API keys; generated at install, never in the repository. */
79
+ OYSTER_CREDENTIAL_KEY?: string;
62
80
  AGENTS: DurableObjectNamespace<StandaloneAgentBase>;
63
81
  /** Host-only directory custody. Guest entrypoints expose operations, not this binding; Codemode receives only Mycelium modules. */
64
82
  AGENT_DIRECTORY: DurableObjectNamespace<AgentDirectory>;
@@ -83,6 +101,98 @@ export declare abstract class StandaloneAgentBase<Env extends StandaloneAgentEnv
83
101
  setArchived(archived: boolean): Promise<import("./agent-archive-owner.js").AgentArchiveTransitionResult>;
84
102
  /** The deployable root's host for this Agent's pinned tenant. */
85
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>;
86
196
  private uiOwner;
87
197
  private machineClient;
88
198
  private computerSnapshot;
@@ -92,6 +202,7 @@ export declare abstract class StandaloneAgentBase<Env extends StandaloneAgentEnv
92
202
  private readonly computerInvalidations;
93
203
  /** Host invalidation drops captured discovery, not just its displayed names. */
94
204
  invalidateComputerConnections(): void;
205
+ private computerAccess;
95
206
  private computerConnections;
96
207
  /** Revalidate the owner's generation before reusing a Home or tool snapshot. */
97
208
  private preparedComputerSnapshot;
@@ -114,6 +225,13 @@ export declare abstract class StandaloneAgentBase<Env extends StandaloneAgentEnv
114
225
  settlement(principal: MachineAgentSettlementPrincipal, sessionId: string, commandId: string): Promise<string | undefined>;
115
226
  /** The root host for this Agent's pinned policy directory; unpinned Agents have no App tools. */
116
227
  private appHost;
228
+ /** The instance directory that owns this Agent's sealed model keys. */
229
+ private keyDirectory;
230
+ /** The instance directory that owns this Agent's MCP connections and their credentials. */
231
+ private mcpDirectory;
232
+ private agentName;
233
+ /** A byok choice must name a stored key of the chosen provider. */
234
+ private admitKey;
117
235
  private choice;
118
236
  /** Secret-free default of this Agent; stored separately from Session history. */
119
237
  readModelChoice(): Promise<AgentModelChoice>;
@@ -138,14 +256,12 @@ export declare abstract class StandaloneAgentBase<Env extends StandaloneAgentEnv
138
256
  controlSchedule(directory: typeof policyDirectorySchema.Type, input: AgentScheduleTarget, action: "pause" | "resume" | "delete"): Promise<AgentScheduleControlReceipt>;
139
257
  /** Listeners from live codemode acquisitions, told when the server list changes. */
140
258
  private readonly mcpInvalidations;
141
- private storedMcpServers;
142
- private writeMcpServers;
143
- /** Host-only: this Agent's MCP servers, without their bearer tokens. */
144
- mcpServers(): Promise<readonly AgentMcpServer[]>;
145
- /** Host-only: connect one remote MCP server, admitted by the owner route. */
146
- addMcpServer(input: AgentMcpServerInput): Promise<AgentMcpServer | AgentMcpServerRefusal>;
147
- /** Host-only: disconnect one MCP server. */
148
- removeMcpServer(serverId: string): Promise<boolean>;
259
+ /** Host-only: the directory told us this Agent's connections changed. */
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
+ */
149
265
  protected shiitakeOptions(): Promise<CloudflareShiitakeOptions>;
150
266
  /** Send an installation-admitted message through fleet Session operations. */
151
267
  sendFromApp(installationId: string, sessionId: string, message: FleetMessage): Promise<{
@@ -166,6 +282,82 @@ export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
166
282
  recordArchive(agentId: string, archived: boolean, revision: number): boolean;
167
283
  /** Directory's bounded-stale projection, never the Agent's flag authority. */
168
284
  archived(agentId: string): boolean;
285
+ private modelKeys;
286
+ /** Domain refusals cross the DO RPC boundary as data, not as Error prototypes. */
287
+ sealModelKey(input: ModelKeySealInput): Promise<ModelKeyRecord | Readonly<{
288
+ error: ModelKeyRefusal;
289
+ }>>;
290
+ listModelKeys(): Promise<readonly ModelKeyRecord[]>;
291
+ modelKey(keyId: string): Promise<ModelKeyRecord | null>;
292
+ removeModelKey(keyId: string): Promise<"deleted" | "absent">;
293
+ /** Host-only: the one place a stored key meets a provider request. */
294
+ sendModelKey(keyId: string, request: Readonly<{
295
+ url: string;
296
+ method: string;
297
+ headers: readonly (readonly [string, string])[];
298
+ body: string | null;
299
+ }>): Promise<Response | Readonly<{
300
+ error: ModelKeyRefusal;
301
+ }>>;
302
+ private mcpOwner;
303
+ /** Loaded on the first MCP request: the SDK and OpenAPI decoders stay out of startup. */
304
+ private mcpConnections;
305
+ /** Host-only: every connection with the Agents that may use it, never a credential. */
306
+ connections(): Promise<readonly Readonly<{
307
+ connectionId: string;
308
+ name: string;
309
+ label: string;
310
+ kind: "mcp" | "openapi";
311
+ url: string;
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;
322
+ }> | Readonly<{
323
+ error: "not_found" | "duplicate_name" | "limit" | "invalid_endpoint";
324
+ }>>;
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
+ }>>;
344
+ /** Secret-free grants for one Agent: ids, versions and endpoints. */
345
+ mcpProjection(agentId: string): Promise<Readonly<{
346
+ revision: number;
347
+ connections: readonly Readonly<{
348
+ connectionId: string;
349
+ name: string;
350
+ surface: import("@fungi.computer/veil/connections").SurfaceView;
351
+ tools: import("@fungi.computer/veil/connections").Tools;
352
+ version: number;
353
+ authorityVersion: number;
354
+ grantVersion: number;
355
+ }>[];
356
+ }>>;
357
+ /** Host-only: complete one Agent MCP request; the credential opens only here. */
358
+ mcpFetch(agentId: string, ref: EgressRef, request: McpRequestData): Promise<Response | Readonly<{
359
+ error: string;
360
+ }>>;
169
361
  private readonly computers;
170
362
  private readonly computerNames;
171
363
  private readonly directory;
@@ -225,6 +417,29 @@ export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
225
417
  readAgentComputers(agentId: string, principal: TenantPrincipal, tenantId?: TenantId): Promise<StandaloneAgentComputerReply>;
226
418
  /** Every captured native call rechecks the exact live attachment and credential owner. */
227
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>;
228
443
  list(options?: Readonly<{
229
444
  archived?: boolean;
230
445
  }>): readonly AgentEntry[];