@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.
- package/README.md +103 -12
- package/dist/agents.d.ts +66 -22
- package/dist/agents.js +128 -38
- package/dist/app-builds.d.ts +2 -0
- package/dist/app-builds.js +17 -6
- package/dist/authorization.d.ts +25 -3
- package/dist/authorization.js +47 -14
- package/dist/browser/capability-source.d.ts +23 -5
- package/dist/browser/capability-source.js +19 -22
- package/dist/browser/index.d.ts +2 -1
- package/dist/browser/index.js +1 -0
- package/dist/browser/live-view.d.ts +38 -0
- package/dist/browser/live-view.js +179 -0
- package/dist/build/artifact-writer.d.ts +11 -2
- package/dist/build/artifact-writer.js +42 -24
- package/dist/build/candidate-cli.mjs +26 -18
- package/dist/build/content-objects.d.ts +29 -14
- package/dist/build/content-objects.js +57 -19
- package/dist/build/local-build.js +3 -0
- package/dist/build/submission-contract.d.ts +1 -1
- package/dist/build/submission-contract.js +5 -5
- package/dist/build-egress.d.ts +8 -7
- package/dist/build-egress.js +4 -3
- package/dist/build.d.ts +1 -1
- package/dist/channels/binding.d.ts +2 -0
- package/dist/channels/run-decision.d.ts +33 -0
- package/dist/channels/run-decision.js +25 -0
- package/dist/channels/visitor-channel.d.ts +84 -14
- package/dist/channels/visitor-channel.js +55 -32
- package/dist/channels/visitor-edge.d.ts +18 -2
- package/dist/channels/visitor-edge.js +67 -5
- package/dist/channels/visitors.d.ts +4 -0
- package/dist/channels/visitors.js +22 -1
- package/dist/channels/web-binding.d.ts +117 -0
- package/dist/channels/web-binding.js +227 -0
- package/dist/embed-metafiles.d.ts +8 -0
- package/dist/embed-metafiles.js +2 -0
- package/dist/embed-scripts.d.ts +8 -0
- package/dist/embed-scripts.js +3 -0
- package/dist/host.d.ts +3 -1
- package/dist/host.js +6 -1
- package/dist/install-release-cli.d.ts +2 -1
- package/dist/install-release-cli.js +18 -10
- package/dist/installation-client.d.ts +1 -0
- package/dist/installation-operations.d.ts +2 -0
- package/dist/installation-operations.js +1 -0
- package/dist/pack.d.ts +5 -2
- package/dist/pack.js +3 -1
- package/dist/page/embed-challenge.d.ts +19 -0
- package/dist/page/embed-challenge.js +45 -0
- package/dist/page/embed-error.d.ts +2 -0
- package/dist/page/embed-error.js +16 -0
- package/dist/page/embed-loader-protocol.d.ts +12 -0
- package/dist/page/embed-loader-protocol.js +29 -0
- package/dist/standalone/agent-connections.d.ts +22 -19
- package/dist/standalone/agent-connections.js +150 -106
- package/dist/standalone/agents.d.ts +174 -16
- package/dist/standalone/agents.js +331 -21
- package/dist/standalone/browser.d.ts +14 -2
- package/dist/standalone/browser.js +52 -4
- package/dist/standalone/channel-session-door.d.ts +4 -0
- package/dist/standalone/channel-session-door.js +72 -0
- package/dist/standalone/computer-egress.d.ts +5 -3
- package/dist/standalone/computer-egress.js +1 -1
- package/dist/standalone/hello-app.d.ts +9 -0
- package/dist/standalone/hello-app.js +78 -0
- package/dist/standalone/install-apps-cli.d.ts +2 -1
- package/dist/standalone/install-apps-cli.js +36 -14
- package/dist/standalone/instance.js +2 -2
- package/dist/standalone/local-desktop.d.ts +11 -0
- package/dist/standalone/local-desktop.js +75 -0
- package/dist/standalone/owner-routes.d.ts +4 -3
- package/dist/standalone/owner-routes.js +7 -1
- package/dist/standalone/registry.d.ts +2 -0
- package/dist/standalone/sign-in-link.d.ts +9 -0
- package/dist/standalone/sign-in-link.js +49 -0
- package/dist/standalone/try-cli.d.ts +52 -0
- package/dist/standalone/try-cli.js +404 -0
- package/dist/standalone/visitor-edge.d.ts +36 -0
- package/dist/standalone/visitor-edge.js +67 -0
- package/dist/standalone/visitor-proof.d.ts +23 -0
- package/dist/standalone/visitor-proof.js +67 -0
- package/dist/standalone/website-channels.d.ts +134 -0
- package/dist/standalone/website-channels.js +262 -0
- package/dist/standalone/worker-routes.d.ts +4 -1
- package/dist/standalone/worker-routes.js +3 -0
- package/dist/standalone/worker.d.ts +2 -1
- package/dist/standalone/worker.js +5 -1
- package/dist/testing/capabilities.d.ts +3 -0
- package/dist/testing/capabilities.js +1 -0
- package/dist/testing/installation.d.ts +4 -2
- package/dist/testing/installation.js +7 -2
- package/dist/webhook-abuse.d.ts +7 -1
- package/dist/webhook-abuse.js +8 -2
- package/dist/workers-git.js +2 -2
- package/dist/workers.d.ts +7 -2
- package/dist/workers.js +1 -1
- package/docs/api/agents.md +103 -36
- package/docs/api/authorization.md +56 -11
- package/docs/api/browser.md +115 -8
- package/docs/api/build-contract.md +52 -10
- package/docs/api/build.md +16 -2
- package/docs/api/host.md +1 -0
- package/docs/api/pack.md +179 -3
- package/docs/api/workers-git.md +6 -6
- package/docs/site/agent-quickstart.mdx +8 -0
- package/package.json +34 -8
|
@@ -7,6 +7,15 @@ import { AgentArchiveRefused, AgentCreateRefused, } from "@fungi.computer/shiita
|
|
|
7
7
|
import { AgentDelegation, AgentDisclosureRefused, machineAgentCodecs, } from "@fungi.computer/shiitake/delegation";
|
|
8
8
|
import { FungiMessageMetaSchema } from "@fungi.computer/agar/agents";
|
|
9
9
|
import { agentMail } from "./agent-mail.js";
|
|
10
|
+
import { createChannelConversations, } from "../channels/conversations.js";
|
|
11
|
+
import { transcriptLine, } from "@fungi.computer/nacre/website-channels";
|
|
12
|
+
import { personChannelInstructions, } from "../channels/web-binding.js";
|
|
13
|
+
import { decideChannelRunSafely } from "../channels/run-decision.js";
|
|
14
|
+
import { createWebsiteChannelOwner, websiteOutcome, } from "./website-channels.js";
|
|
15
|
+
import { channelSessionDoor } from "./channel-session-door.js";
|
|
16
|
+
import { createAuthenticatedVisitorChannel } from "../channels/visitor-channel.js";
|
|
17
|
+
import { verifyVisitor } from "./visitor-proof.js";
|
|
18
|
+
import { createVisitorStreamSlots } from "../channels/visitor-stream-slots.js";
|
|
10
19
|
import { createStandaloneMachineEnrollment, standaloneMachineAgentHome, standaloneMachineLinkAuthority, } from "./machine-link.js";
|
|
11
20
|
import { createMachineLinkFences, MachineEnrollmentRefused, MachineLinkRefused, createMachineAgentClient, } from "../machine-link/index.js";
|
|
12
21
|
import { memberInboxItemSchema } from "@fungi.computer/puffball/inbox";
|
|
@@ -30,7 +39,7 @@ import { agentStoreKeeping } from "./agent-store.js";
|
|
|
30
39
|
import { createInstanceCredentialStore, createModelKeyVault, ModelKeyRefused, } from "./model-key-vault.js";
|
|
31
40
|
import { agentArchiveOwner } from "./agent-archive-owner.js";
|
|
32
41
|
import { agentArchiveProjection } from "../agent-archive-projection.js";
|
|
33
|
-
import { standaloneBrowserSource } from "./browser.js";
|
|
42
|
+
import { standaloneBrowserLiveView, standaloneBrowserSource, } from "./browser.js";
|
|
34
43
|
import { standaloneWebSource } from "./web.js";
|
|
35
44
|
import { configuredProviderEgress, providerFetch, } from "@fungi.computer/veil/gatekeeper";
|
|
36
45
|
import { createAssistantMessageEventStream } from "@earendil-works/pi-ai/utils/event-stream";
|
|
@@ -46,9 +55,9 @@ import { readAgentSchedulePage, controlAgentSchedule, } from "@fungi.computer/sh
|
|
|
46
55
|
import { agentScheduleTargetSchema } from "@fungi.computer/shiitake-extensions/schedules";
|
|
47
56
|
import { createAgentAvatarStore, } from "../agent-avatars.js";
|
|
48
57
|
import { agentIds, createAgentDirectory, createFleetSessions, commandSettlementSchema, DirectoryError, } from "@fungi.computer/shiitake/fleet";
|
|
49
|
-
import { appToolPolicySchema } from "../apps/index.js";
|
|
58
|
+
import { appToolPolicySchema, } from "../apps/index.js";
|
|
50
59
|
import { oysterPrincipalId } from "../host.js";
|
|
51
|
-
import { oysterPrincipalIsOwner } from "../authorization.js";
|
|
60
|
+
import { agentCeiling, oysterPrincipalIsOwner } from "../authorization.js";
|
|
52
61
|
import { defaultTenant, tenantIdSchema, tenantScope, } from "../tenant.js";
|
|
53
62
|
import { createCodemodeSandbox } from "@fungi.computer/mycelium/workers";
|
|
54
63
|
import { forageDiscoveryInstructions } from "@fungi.computer/mycelium/effect";
|
|
@@ -227,6 +236,187 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
227
236
|
setArchived(archived) {
|
|
228
237
|
return this.archiveControl().setArchived(archived);
|
|
229
238
|
}
|
|
239
|
+
channelOwner;
|
|
240
|
+
channelDoor;
|
|
241
|
+
acquireChannelStream = createVisitorStreamSlots();
|
|
242
|
+
/** The website bindings that name this Agent, as the directory last said. */
|
|
243
|
+
websiteBindings = new Map();
|
|
244
|
+
/** The owner's current record of one binding; hosts and tests supply it. */
|
|
245
|
+
readChannelBinding(bindingId) {
|
|
246
|
+
return agentDirectoryForScope(this.env, tenantScope(defaultTenant, this.env.OYSTER_ORIGIN)).websiteBinding(bindingId);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Read one binding afresh from its owner: suspension, persona and edits are
|
|
250
|
+
* never stale. A binding that names another Agent is not this Agent's.
|
|
251
|
+
*/
|
|
252
|
+
async loadChannelBinding(bindingId) {
|
|
253
|
+
const binding = await this.readChannelBinding(bindingId);
|
|
254
|
+
if (binding === null || binding.agentId !== this.ctx.id.name) {
|
|
255
|
+
this.websiteBindings.delete(bindingId);
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
this.websiteBindings.set(bindingId, binding);
|
|
259
|
+
return binding;
|
|
260
|
+
}
|
|
261
|
+
/** A web host shares its edge's private assertion key with its Agent. */
|
|
262
|
+
channelProofKey() {
|
|
263
|
+
return this.env.OYSTER_WEBSITE_PROOF_KEY ?? null;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The one per-Session decision, with the binding read afresh: an owner
|
|
267
|
+
* Session is private, a visitor's runs only while its binding is active.
|
|
268
|
+
* Tools and permissions stay the Agent's own either way.
|
|
269
|
+
*/
|
|
270
|
+
async channelRun(sessionId) {
|
|
271
|
+
const conversation = sessionId === undefined
|
|
272
|
+
? null
|
|
273
|
+
: this.channelConversations().sessionConversation(sessionId);
|
|
274
|
+
if (conversation !== null)
|
|
275
|
+
await this.loadChannelBinding(conversation.bindingId);
|
|
276
|
+
return this.cachedChannelRun(sessionId);
|
|
277
|
+
}
|
|
278
|
+
/** The same decision from what this Agent already read; unknown denies. */
|
|
279
|
+
cachedChannelRun(sessionId) {
|
|
280
|
+
return decideChannelRunSafely(() => {
|
|
281
|
+
const conversation = sessionId === undefined
|
|
282
|
+
? null
|
|
283
|
+
: this.channelConversations().sessionConversation(sessionId);
|
|
284
|
+
return {
|
|
285
|
+
conversationBindingId: conversation?.bindingId ?? null,
|
|
286
|
+
binding: conversation === null
|
|
287
|
+
? null
|
|
288
|
+
: (this.websiteBindings.get(conversation.bindingId) ?? null),
|
|
289
|
+
};
|
|
290
|
+
}, sessionId ?? "none", (cause) => {
|
|
291
|
+
console.error("channel run decision failed", cause);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/** Shiitake calls instructions.load at the start of the actual model turn.
|
|
295
|
+
* Capture that command before any asynchronous guidance can change the
|
|
296
|
+
* handoff version; participant projection otherwise hides its reply. A
|
|
297
|
+
* visitor's Session adds the fixed channel rules and the owner's persona to
|
|
298
|
+
* the Agent's own instructions, never replacing them. */
|
|
299
|
+
channelInstructions(source) {
|
|
300
|
+
return {
|
|
301
|
+
load: async (input) => {
|
|
302
|
+
const conversation = this.channelConversations().sessionConversation(input.sessionId);
|
|
303
|
+
if (conversation === null)
|
|
304
|
+
return source.load(input);
|
|
305
|
+
this.channelConversations().captureTurn(input.sessionId, input.commandId);
|
|
306
|
+
const decision = await this.channelRun(input.sessionId);
|
|
307
|
+
if (decision.kind !== "channel")
|
|
308
|
+
throw new Error("Website channel binding is unavailable");
|
|
309
|
+
const base = await source.load(input);
|
|
310
|
+
return {
|
|
311
|
+
revision: `${base.revision}+website-${String(decision.binding.authorityVersion)}`,
|
|
312
|
+
text: `${base.text}\n\n${personChannelInstructions(decision.binding.persona)}`,
|
|
313
|
+
};
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/** Owner read of one website's conversations; the host admits the owner first. */
|
|
318
|
+
async websiteConversations(bindingId) {
|
|
319
|
+
const binding = await this.loadChannelBinding(bindingId);
|
|
320
|
+
return binding === null ? [] : this.channelConversations().list(bindingId);
|
|
321
|
+
}
|
|
322
|
+
/** Owner read of one conversation of a website, from its Session. */
|
|
323
|
+
async websiteTranscript(bindingId, sessionId) {
|
|
324
|
+
const binding = await this.loadChannelBinding(bindingId);
|
|
325
|
+
const conversation = this.channelConversations().sessionConversation(sessionId);
|
|
326
|
+
if (binding === null || conversation?.bindingId !== bindingId)
|
|
327
|
+
return null;
|
|
328
|
+
const snapshot = await (await this.shiitake())
|
|
329
|
+
.session(sessionId)
|
|
330
|
+
.read({ limit: 200 });
|
|
331
|
+
return {
|
|
332
|
+
sessionId,
|
|
333
|
+
label: conversation.label,
|
|
334
|
+
lines: snapshot.messages.flatMap((message) => {
|
|
335
|
+
const line = transcriptLine(message);
|
|
336
|
+
return line === null ? [] : [line];
|
|
337
|
+
}),
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
channelBinding(bindingId) {
|
|
341
|
+
return this.websiteBindings.get(bindingId) ?? null;
|
|
342
|
+
}
|
|
343
|
+
channelSessionDoor() {
|
|
344
|
+
return (this.channelDoor ??= channelSessionDoor(() => this.shiitake(), () => {
|
|
345
|
+
// A visitor's Session runs on this Agent's own tools; nothing to deliver.
|
|
346
|
+
}, () => this.channelConversations()));
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Compose Oyster's channel owner on this Agent's real store and Shiitake.
|
|
350
|
+
* A host must supply its own binding lookup after authenticating its edge;
|
|
351
|
+
* this does not install an inbound route or mint provider credentials.
|
|
352
|
+
*/
|
|
353
|
+
channelConversations() {
|
|
354
|
+
if (this.channelOwner !== undefined)
|
|
355
|
+
return this.channelOwner;
|
|
356
|
+
const owner = createChannelConversations({
|
|
357
|
+
sql: this.ctx.storage.sql,
|
|
358
|
+
transactionSync: (body) => this.ctx.storage.transactionSync(body),
|
|
359
|
+
binding: (id) => this.channelBinding(id),
|
|
360
|
+
door: this.channelSessionDoor(),
|
|
361
|
+
now: () => Date.now(),
|
|
362
|
+
});
|
|
363
|
+
return (this.channelOwner = owner);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Internal DO RPC only: the HTTP edge authenticates once in the central
|
|
367
|
+
* visitor owner, then selects this Agent. No bearer or client-provided
|
|
368
|
+
* visitor id enters this method. Its caller retains the SSE recheck callback.
|
|
369
|
+
*/
|
|
370
|
+
visitorConversation() {
|
|
371
|
+
const conversations = this.channelConversations();
|
|
372
|
+
return createAuthenticatedVisitorChannel({
|
|
373
|
+
binding: (id) => this.channelBinding(id),
|
|
374
|
+
conversations: () => conversations,
|
|
375
|
+
sessionDoor: () => this.channelSessionDoor(),
|
|
376
|
+
intake: (event) => conversations.receive(event),
|
|
377
|
+
acquireStream: this.acquireChannelStream,
|
|
378
|
+
now: () => Date.now(),
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
async verifiedVisitor(bindingId, visitor) {
|
|
382
|
+
const binding = await this.loadChannelBinding(bindingId);
|
|
383
|
+
if (binding?.lifecycle !== "active")
|
|
384
|
+
throw new Error("Website channel binding is unavailable");
|
|
385
|
+
return verifyVisitor(bindingId, visitor, this.channelProofKey());
|
|
386
|
+
}
|
|
387
|
+
async sendChannelVisitor(bindingId, visitor, requestId, text) {
|
|
388
|
+
const verified = await this.verifiedVisitor(bindingId, visitor);
|
|
389
|
+
return this.visitorConversation().send(bindingId, verified, requestId, text);
|
|
390
|
+
}
|
|
391
|
+
async withdrawChannelVisitor(bindingId, visitor, requestId) {
|
|
392
|
+
const verified = await this.verifiedVisitor(bindingId, visitor);
|
|
393
|
+
return this.visitorConversation().withdraw(bindingId, verified, requestId);
|
|
394
|
+
}
|
|
395
|
+
async latestPendingChannelVisitor(bindingId, visitor) {
|
|
396
|
+
const verified = await this.verifiedVisitor(bindingId, visitor);
|
|
397
|
+
return this.visitorConversation().latestPending(bindingId, verified);
|
|
398
|
+
}
|
|
399
|
+
async openChannelVisitor(bindingId, visitor, options) {
|
|
400
|
+
const verified = await this.verifiedVisitor(bindingId, visitor);
|
|
401
|
+
return this.visitorConversation().open(bindingId, verified, options);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* A stream is reauthorized at every beat by the central visitor owner, not
|
|
405
|
+
* by a callback held across this Durable Object's RPC boundary: the site must
|
|
406
|
+
* still be active and the visitor still live.
|
|
407
|
+
*/
|
|
408
|
+
async watchChannelVisitor(bindingId, visitor) {
|
|
409
|
+
const verified = await this.verifiedVisitor(bindingId, visitor);
|
|
410
|
+
return this.visitorConversation().watch(bindingId, verified, async (visitorId) => {
|
|
411
|
+
const binding = await this.loadChannelBinding(bindingId);
|
|
412
|
+
return (binding?.lifecycle === "active" &&
|
|
413
|
+
(await this.channelVisitorLive(bindingId, visitorId)));
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
/** Whether the central visitor owner still serves this visitor. */
|
|
417
|
+
channelVisitorLive(bindingId, visitorId) {
|
|
418
|
+
return agentDirectoryForScope(this.env, tenantScope(defaultTenant, this.env.OYSTER_ORIGIN)).websiteVisitorLive(bindingId, visitorId);
|
|
419
|
+
}
|
|
230
420
|
/** Each installed Release's verified catalog surface, built once per Release for this Agent's lifetime. */
|
|
231
421
|
#appSurfaces;
|
|
232
422
|
uiOwner;
|
|
@@ -354,6 +544,11 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
354
544
|
}
|
|
355
545
|
hostFetch(request) {
|
|
356
546
|
const pathname = new URL(request.url).pathname;
|
|
547
|
+
if (pathname.startsWith("/cloud-browser/"))
|
|
548
|
+
return standaloneBrowserLiveView(this.env.BROWSER, () => ({
|
|
549
|
+
teamId: this.env.OYSTER_ORIGIN,
|
|
550
|
+
agentId: this.ctx.id.name ?? "agent",
|
|
551
|
+
}))(request);
|
|
357
552
|
if (pathname.startsWith("/browser/"))
|
|
358
553
|
return this.ui().then((connection) => connection.fetch(request));
|
|
359
554
|
// The Home command reads attachments inside a synchronous state transaction.
|
|
@@ -744,11 +939,16 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
744
939
|
for (const invalidate of this.mcpInvalidations)
|
|
745
940
|
invalidate();
|
|
746
941
|
}
|
|
942
|
+
/**
|
|
943
|
+
* A full override must retain channelSource and channelInstructions:
|
|
944
|
+
* dropping them removes a suspended website's run refusal and turn capture.
|
|
945
|
+
*/
|
|
747
946
|
async shiitakeOptions() {
|
|
748
|
-
const [{ oysterAgentExtensions }, { Knapsack }, { agentMcpSourceOptions, mcpRequestData },] = await Promise.all([
|
|
947
|
+
const [{ oysterAgentExtensions }, { Knapsack }, { agentMcpSourceOptions }, { mcpRequestData },] = await Promise.all([
|
|
749
948
|
import("@fungi.computer/shiitake-extensions/roster/conversation-agents"),
|
|
750
949
|
import("@fungi.computer/knapsack"),
|
|
751
950
|
import("./agent-connections.js"),
|
|
951
|
+
import("@fungi.computer/veil/connections"),
|
|
752
952
|
]);
|
|
753
953
|
const conversationAgents = await this.conversationAgents();
|
|
754
954
|
const computerSource = createAgentComputerSource({
|
|
@@ -763,11 +963,20 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
763
963
|
const principal = {
|
|
764
964
|
actor: { kind: "agent", agentId: this.ctx.id.name ?? "agent" },
|
|
765
965
|
};
|
|
966
|
+
const channelSource = (source) => ({
|
|
967
|
+
...source,
|
|
968
|
+
acquire: async (context) => (await this.channelRun(context.session?.sessionId)).kind !== "denied"
|
|
969
|
+
? source.acquire(context)
|
|
970
|
+
: {
|
|
971
|
+
snapshot: { version: "channel-denied", modules: [] },
|
|
972
|
+
release: () => Promise.resolve(),
|
|
973
|
+
},
|
|
974
|
+
});
|
|
766
975
|
return {
|
|
767
976
|
model: this.modelSource(),
|
|
768
977
|
meta: { schema: FungiMessageMetaSchema },
|
|
769
978
|
...this.mail().host,
|
|
770
|
-
instructions: {
|
|
979
|
+
instructions: this.channelInstructions({
|
|
771
980
|
load: async () => {
|
|
772
981
|
const { appApprovalInstructions } = await import("../mcp.js");
|
|
773
982
|
return {
|
|
@@ -775,7 +984,7 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
775
984
|
text: instructions + "\n" + appApprovalInstructions,
|
|
776
985
|
};
|
|
777
986
|
},
|
|
778
|
-
},
|
|
987
|
+
}),
|
|
779
988
|
tools: {
|
|
780
989
|
sources: [
|
|
781
990
|
{
|
|
@@ -804,7 +1013,11 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
804
1013
|
},
|
|
805
1014
|
},
|
|
806
1015
|
Knapsack.mcpServers(agentMcpSourceOptions({
|
|
807
|
-
|
|
1016
|
+
// Like attached Computers: an Agent not yet pinned to its
|
|
1017
|
+
// directory has no connections, rather than a failing source.
|
|
1018
|
+
read: async () => (await this.policyDirectory()) === null
|
|
1019
|
+
? { revision: 0, connections: [] }
|
|
1020
|
+
: (await this.mcpDirectory()).mcpProjection(this.agentName()),
|
|
808
1021
|
subscribe: (invalidate) => {
|
|
809
1022
|
this.mcpInvalidations.add(invalidate);
|
|
810
1023
|
return () => this.mcpInvalidations.delete(invalidate);
|
|
@@ -833,7 +1046,7 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
833
1046
|
admit: this.computerAccess().admit,
|
|
834
1047
|
write: (computerId, grant, path, bytes) => this.env.COMPUTER.getByName(computerId).fileWrite(grant, path, bytes),
|
|
835
1048
|
}, () => this.computerSnapshot)),
|
|
836
|
-
],
|
|
1049
|
+
].map(channelSource),
|
|
837
1050
|
sandbox: createCodemodeSandbox(this.env.LOADER, "oyster-workerd"),
|
|
838
1051
|
},
|
|
839
1052
|
extensions: {
|
|
@@ -844,7 +1057,9 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
844
1057
|
prepare: async () => {
|
|
845
1058
|
await this.preparedComputerSnapshot();
|
|
846
1059
|
},
|
|
847
|
-
read: () =>
|
|
1060
|
+
read: ({ sessionId }) => (this.cachedChannelRun(sessionId).kind !== "denied"
|
|
1061
|
+
? readAgentComputerConnections(this.computerConnections())
|
|
1062
|
+
: []).map(({ name, attachmentId, files }) => ({
|
|
848
1063
|
name,
|
|
849
1064
|
attachmentId,
|
|
850
1065
|
port: files.port,
|
|
@@ -1007,17 +1222,30 @@ export class AgentDirectory extends DurableObject {
|
|
|
1007
1222
|
send: (request) => fetch(request),
|
|
1008
1223
|
hasAgent: (agentId) => this.has(agentId),
|
|
1009
1224
|
notify: (agentId) => this.env.AGENTS.getByName(agentId).invalidateMcpConnections(),
|
|
1225
|
+
callbackUrl: mcpCallbackUrl(this.env.OYSTER_ORIGIN),
|
|
1010
1226
|
}));
|
|
1011
1227
|
}
|
|
1012
|
-
/** Host-only:
|
|
1013
|
-
async
|
|
1014
|
-
return (await this.mcpConnections()).
|
|
1228
|
+
/** Host-only: every connection with the Agents that may use it, never a credential. */
|
|
1229
|
+
async connections() {
|
|
1230
|
+
return (await this.mcpConnections()).list();
|
|
1231
|
+
}
|
|
1232
|
+
async addConnection(input) {
|
|
1233
|
+
return (await this.mcpConnections()).add(input);
|
|
1234
|
+
}
|
|
1235
|
+
async grantConnection(connectionId, agentId, access) {
|
|
1236
|
+
return (await this.mcpConnections()).grant(connectionId, agentId, access);
|
|
1237
|
+
}
|
|
1238
|
+
async ungrantConnection(connectionId, agentId) {
|
|
1239
|
+
return (await this.mcpConnections()).ungrant(connectionId, agentId);
|
|
1015
1240
|
}
|
|
1016
|
-
async
|
|
1017
|
-
return (await this.mcpConnections()).
|
|
1241
|
+
async removeConnection(connectionId) {
|
|
1242
|
+
return (await this.mcpConnections()).remove(connectionId);
|
|
1018
1243
|
}
|
|
1019
|
-
async
|
|
1020
|
-
return (await this.mcpConnections()).
|
|
1244
|
+
async connectionTools(connectionId) {
|
|
1245
|
+
return (await this.mcpConnections()).tools(connectionId);
|
|
1246
|
+
}
|
|
1247
|
+
async completeMcpConnection(query) {
|
|
1248
|
+
return (await this.mcpConnections()).complete(query);
|
|
1021
1249
|
}
|
|
1022
1250
|
/** Secret-free grants for one Agent: ids, versions and endpoints. */
|
|
1023
1251
|
async mcpProjection(agentId) {
|
|
@@ -1358,6 +1586,64 @@ export class AgentDirectory extends DurableObject {
|
|
|
1358
1586
|
provenance: { actor: oysterPrincipalId(owner), via: captured.agentId },
|
|
1359
1587
|
};
|
|
1360
1588
|
}
|
|
1589
|
+
websiteChannelsOwner;
|
|
1590
|
+
websites() {
|
|
1591
|
+
return (this.websiteChannelsOwner ??= createWebsiteChannelOwner({
|
|
1592
|
+
sql: this.ctx.storage.sql,
|
|
1593
|
+
transactionSync: (body) => this.ctx.storage.transactionSync(body),
|
|
1594
|
+
agentExists: (agentId) => this.has(agentId),
|
|
1595
|
+
agentIdentity: (agentId) => {
|
|
1596
|
+
const id = agentIds.agent.parse(agentId);
|
|
1597
|
+
if (!id.ok || this.archived(agentId))
|
|
1598
|
+
return null;
|
|
1599
|
+
const entry = this.directory.read(this.grant(), id.value);
|
|
1600
|
+
return entry === null
|
|
1601
|
+
? null
|
|
1602
|
+
: { name: entry.name, avatar: this.avatars.read(agentId) };
|
|
1603
|
+
},
|
|
1604
|
+
}));
|
|
1605
|
+
}
|
|
1606
|
+
/** Owner read of every website bound to one of this tenant's Agents. */
|
|
1607
|
+
websiteList(principal) {
|
|
1608
|
+
if (!oysterPrincipalIsOwner(principal))
|
|
1609
|
+
return { error: "not_granted" };
|
|
1610
|
+
return this.websites().bindings.list();
|
|
1611
|
+
}
|
|
1612
|
+
/** Owner-only: put a chosen Agent behind a new site key. */
|
|
1613
|
+
websiteCreate(principal, input, requestId) {
|
|
1614
|
+
if (!oysterPrincipalIsOwner(principal))
|
|
1615
|
+
return { error: "not_granted" };
|
|
1616
|
+
return websiteOutcome(() => this.websites().bindings.create(input, requestId));
|
|
1617
|
+
}
|
|
1618
|
+
/** Owner-only edit, fenced by the version the owner last read. */
|
|
1619
|
+
websiteUpdate(principal, bindingId, input) {
|
|
1620
|
+
if (!oysterPrincipalIsOwner(principal))
|
|
1621
|
+
return { error: "not_granted" };
|
|
1622
|
+
return websiteOutcome(() => this.websites().bindings.update(bindingId, input));
|
|
1623
|
+
}
|
|
1624
|
+
/** Host-only: the binding a website Agent serves, read fresh on every use. */
|
|
1625
|
+
websiteBinding(bindingId) {
|
|
1626
|
+
return this.websites().bindings.read(bindingId);
|
|
1627
|
+
}
|
|
1628
|
+
/** Host-only public lookup: a site key resolves to its site, or to nothing. */
|
|
1629
|
+
websiteSite(siteKey) {
|
|
1630
|
+
return this.websites().site(siteKey);
|
|
1631
|
+
}
|
|
1632
|
+
websiteMint(bindingId, siteKey, addressHash) {
|
|
1633
|
+
return this.websites().visitors.mint(this.websites().bindings.read(bindingId), siteKey, addressHash);
|
|
1634
|
+
}
|
|
1635
|
+
websiteRefresh(bindingId, refreshSecret) {
|
|
1636
|
+
return this.websites().visitors.refresh(this.websites().bindings.read(bindingId), refreshSecret);
|
|
1637
|
+
}
|
|
1638
|
+
websiteRotate(bindingId, siteKey, accessToken, addressHash) {
|
|
1639
|
+
return this.websites().visitors.rotate(this.websites().bindings.read(bindingId), siteKey, accessToken, addressHash);
|
|
1640
|
+
}
|
|
1641
|
+
websiteVisitorLive(bindingId, visitorId) {
|
|
1642
|
+
return this.websites().visitors.live(bindingId, visitorId);
|
|
1643
|
+
}
|
|
1644
|
+
websiteAuthenticate(bindingId, accessToken) {
|
|
1645
|
+
return this.websites().visitors.authenticate(bindingId, accessToken);
|
|
1646
|
+
}
|
|
1361
1647
|
list(options) {
|
|
1362
1648
|
const archived = this.archiveProjection().archivedIds();
|
|
1363
1649
|
return this.directory
|
|
@@ -1632,6 +1918,8 @@ export class AgentDirectory extends DurableObject {
|
|
|
1632
1918
|
this.ctx.storage.sql.exec("INSERT INTO counters(name, value) VALUES('revision', 1) ON CONFLICT(name) DO UPDATE SET value=value+1");
|
|
1633
1919
|
}
|
|
1634
1920
|
}
|
|
1921
|
+
/** Where an authorization server returns the owner after a sign-in. */
|
|
1922
|
+
const mcpCallbackUrl = (origin) => new URL("/api/connections/callback", origin).href;
|
|
1635
1923
|
/** The directory's Durable Object storage as the credential store's key-value port. */
|
|
1636
1924
|
const credentialStorage = (storage) => ({
|
|
1637
1925
|
get: (key) => storage.get(key),
|
|
@@ -1725,9 +2013,14 @@ export function standaloneAgents(env, scope) {
|
|
|
1725
2013
|
return { error: "not_found" };
|
|
1726
2014
|
return directory().approveAppToolPolicy(agentId, principal, level, expectedRevision, actor, scope?.tenantId ?? defaultTenant);
|
|
1727
2015
|
},
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
2016
|
+
connections: () => directory().connections(),
|
|
2017
|
+
addConnection: (input) => directory().addConnection(input),
|
|
2018
|
+
grantConnection: (connectionId, agentId, access) => directory().grantConnection(connectionId, agentId, access),
|
|
2019
|
+
ungrantConnection: (connectionId, agentId) => directory().ungrantConnection(connectionId, agentId),
|
|
2020
|
+
removeConnection: (connectionId) => directory().removeConnection(connectionId),
|
|
2021
|
+
connectionTools: (connectionId) => directory().connectionTools(connectionId),
|
|
2022
|
+
completeMcpConnection: (query) => directory().completeMcpConnection(query),
|
|
2023
|
+
mcpCallbackUrl: () => mcpCallbackUrl(env.OYSTER_ORIGIN),
|
|
1731
2024
|
fetch: async (agentId, request) => {
|
|
1732
2025
|
const home = await directory().agentHome(agentId);
|
|
1733
2026
|
if (home?.kind === "machine") {
|
|
@@ -1835,6 +2128,10 @@ export const agentFrameMethods = {
|
|
|
1835
2128
|
decodeArgs: (raw) => agentBindingArgs.INBOX.visit.parse(raw),
|
|
1836
2129
|
decodeResult: decodeInboxVisit,
|
|
1837
2130
|
requiredOperations: () => ["visit"],
|
|
2131
|
+
requestedResource: (raw) => ({
|
|
2132
|
+
kind: "agent",
|
|
2133
|
+
id: agentBindingArgs.INBOX.visit.parse(raw)[0].agentId,
|
|
2134
|
+
}),
|
|
1838
2135
|
},
|
|
1839
2136
|
},
|
|
1840
2137
|
AGENTS: {
|
|
@@ -1894,7 +2191,7 @@ export const agentFrameMethods = {
|
|
|
1894
2191
|
},
|
|
1895
2192
|
};
|
|
1896
2193
|
/** Provider effects are admitted by the originating Instance's live frame. */
|
|
1897
|
-
export async function dispatchAgentBinding(env, scope, frame, props, method, args) {
|
|
2194
|
+
export async function dispatchAgentBinding(env, scope, frame, props, method, args, admitted) {
|
|
1898
2195
|
frame.signal.throwIfAborted();
|
|
1899
2196
|
if (frame.facts.selection.owner.kind !== "installation")
|
|
1900
2197
|
throw new AppInstanceError("revoked");
|
|
@@ -1903,8 +2200,21 @@ export async function dispatchAgentBinding(env, scope, frame, props, method, arg
|
|
|
1903
2200
|
let result;
|
|
1904
2201
|
if (props.binding === "INBOX" && method === "page") {
|
|
1905
2202
|
agentBindingArgs.INBOX.page.parse(args);
|
|
2203
|
+
const read = admitted.authority.approvedGrants.find((grant) => grant.capability === "agent.read");
|
|
2204
|
+
if (read === undefined)
|
|
2205
|
+
throw new AppInstanceError("binding_not_granted");
|
|
2206
|
+
const ceiling = agentCeiling(read.resources);
|
|
1906
2207
|
const inbox = await standaloneAgents(env, scope).inbox();
|
|
1907
|
-
result =
|
|
2208
|
+
result =
|
|
2209
|
+
ceiling === "all"
|
|
2210
|
+
? { items: inbox.items, next: null, cursor: inbox.revision }
|
|
2211
|
+
: {
|
|
2212
|
+
items: inbox.items.filter((item) => "agentId" in item && ceiling.has(item.agentId)),
|
|
2213
|
+
next: null,
|
|
2214
|
+
// The global revision also moves for Agents outside the selection;
|
|
2215
|
+
// with no scoped change stream, a narrowed App sees neither it nor their rows.
|
|
2216
|
+
cursor: 0,
|
|
2217
|
+
};
|
|
1908
2218
|
}
|
|
1909
2219
|
else if (props.binding === "INBOX" && method === "visit") {
|
|
1910
2220
|
const [input] = agentBindingArgs.INBOX.visit.parse(args);
|
|
@@ -3,10 +3,22 @@ import { type BrowserBinding, type SaveBrowserFile } from "../browser/index.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* The agent's `cloudBrowser` tool on a standalone Oyster, or an empty source
|
|
5
5
|
* when the deployment declares no BROWSER binding. Driven sessions only: no
|
|
6
|
-
* Quick Reads
|
|
7
|
-
*
|
|
6
|
+
* Quick Reads. `handoff` pauses the lease and returns the owner's live view;
|
|
7
|
+
* `channel` stays null until the host supplies a conversations owner, which
|
|
8
|
+
* is the seam a channel Session's conversation handoff plugs into. Screenshots
|
|
9
|
+
* and PDFs save to an attached Computer through `saveFile`.
|
|
8
10
|
*/
|
|
9
11
|
export declare function standaloneBrowserSource(binding: BrowserBinding | undefined, identity: () => Readonly<{
|
|
10
12
|
teamId: string;
|
|
11
13
|
agentId: string;
|
|
12
14
|
}>, saveFile: SaveBrowserFile): CapabilitySource;
|
|
15
|
+
/**
|
|
16
|
+
* The Agent DO's side of the owner's live view. The browser singleton lives in
|
|
17
|
+
* this isolate, so the Worker's owner-admitted `/agents/:agentId/cloud-browser`
|
|
18
|
+
* route forwards here and this calls `Browser.member` on the Agent's own
|
|
19
|
+
* lease. Admission is the Worker's; this only serves already-admitted requests.
|
|
20
|
+
*/
|
|
21
|
+
export declare function standaloneBrowserLiveView(binding: BrowserBinding | undefined, identity: () => Readonly<{
|
|
22
|
+
teamId: string;
|
|
23
|
+
agentId: string;
|
|
24
|
+
}>): (request: Request) => Promise<Response>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { match } from "path-to-regexp";
|
|
2
|
+
import { bindingSessions, browserCapabilitySource, createBrowser, liveView, liveViewPaths, } from "../browser/index.js";
|
|
2
3
|
import { causeClass } from "../cause-class.js";
|
|
3
4
|
/**
|
|
4
5
|
* A standalone Oyster's `BrowserHost`: its own Workers BROWSER binding, no
|
|
@@ -41,11 +42,17 @@ function standaloneBrowser(binding) {
|
|
|
41
42
|
}
|
|
42
43
|
return browser;
|
|
43
44
|
}
|
|
45
|
+
/** The owner-admitted live-view base for one Agent's lease (see `agents.ts`'s cloud-browser route). */
|
|
46
|
+
function viewBase(agentId, leaseId) {
|
|
47
|
+
return `/agents/${encodeURIComponent(agentId)}/cloud-browser/${encodeURIComponent(leaseId)}`;
|
|
48
|
+
}
|
|
44
49
|
/**
|
|
45
50
|
* The agent's `cloudBrowser` tool on a standalone Oyster, or an empty source
|
|
46
51
|
* when the deployment declares no BROWSER binding. Driven sessions only: no
|
|
47
|
-
* Quick Reads
|
|
48
|
-
*
|
|
52
|
+
* Quick Reads. `handoff` pauses the lease and returns the owner's live view;
|
|
53
|
+
* `channel` stays null until the host supplies a conversations owner, which
|
|
54
|
+
* is the seam a channel Session's conversation handoff plugs into. Screenshots
|
|
55
|
+
* and PDFs save to an attached Computer through `saveFile`.
|
|
49
56
|
*/
|
|
50
57
|
export function standaloneBrowserSource(binding, identity, saveFile) {
|
|
51
58
|
if (binding === undefined)
|
|
@@ -68,6 +75,47 @@ export function standaloneBrowserSource(binding, identity, saveFile) {
|
|
|
68
75
|
},
|
|
69
76
|
quickReads: false,
|
|
70
77
|
saveFile,
|
|
71
|
-
|
|
78
|
+
handoff: {
|
|
79
|
+
channel: null,
|
|
80
|
+
viewPath: (owner, leaseId) => liveViewPaths(viewBase(owner.agentId, leaseId)).view,
|
|
81
|
+
},
|
|
72
82
|
});
|
|
73
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* The Agent DO's side of the owner's live view. The browser singleton lives in
|
|
86
|
+
* this isolate, so the Worker's owner-admitted `/agents/:agentId/cloud-browser`
|
|
87
|
+
* route forwards here and this calls `Browser.member` on the Agent's own
|
|
88
|
+
* lease. Admission is the Worker's; this only serves already-admitted requests.
|
|
89
|
+
*/
|
|
90
|
+
export function standaloneBrowserLiveView(binding, identity) {
|
|
91
|
+
const route = match("/cloud-browser/:leaseId/:part");
|
|
92
|
+
const handlers = (leaseId) => {
|
|
93
|
+
if (binding === undefined)
|
|
94
|
+
return null;
|
|
95
|
+
const { teamId, agentId } = identity();
|
|
96
|
+
const browser = standaloneBrowser(binding);
|
|
97
|
+
return liveView((action, signal) => browser.member(teamId, leaseId, action, signal), liveViewPaths(viewBase(agentId, leaseId)), (event, cause) => {
|
|
98
|
+
console.warn("Oyster browser", {
|
|
99
|
+
kind: event,
|
|
100
|
+
cause: causeClass(cause),
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const none = () => Response.json({ error: "no_browser" }, { status: 404 });
|
|
105
|
+
return (request) => {
|
|
106
|
+
const found = route(new URL(request.url).pathname);
|
|
107
|
+
if (found === false)
|
|
108
|
+
return Promise.resolve(none());
|
|
109
|
+
const { leaseId, part } = found.params;
|
|
110
|
+
const view = handlers(leaseId);
|
|
111
|
+
if (view === null)
|
|
112
|
+
return Promise.resolve(none());
|
|
113
|
+
if (part === "view" && request.method === "GET")
|
|
114
|
+
return Promise.resolve(view.page());
|
|
115
|
+
if (part === "frame" && request.method === "GET")
|
|
116
|
+
return view.frame(request.signal);
|
|
117
|
+
if (part === "input" && request.method === "POST")
|
|
118
|
+
return view.input(request, request.signal);
|
|
119
|
+
return Promise.resolve(none());
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ShiitakeOwnerAgent } from "@fungi.computer/shiitake/cloudflare";
|
|
2
|
+
import type { ChannelConversations, SessionDoor } from "../channels/conversations.js";
|
|
3
|
+
/** Translate a standalone Agent's Shiitake owner into Oyster's channel Session port. */
|
|
4
|
+
export declare function channelSessionDoor(open: () => Promise<ShiitakeOwnerAgent>, deliverGrants: (sessionId: string) => void, conversations: () => ChannelConversations): SessionDoor;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { authorMeta } from "@fungi.computer/agar/agents";
|
|
2
|
+
import { ShiitakeError } from "@fungi.computer/shiitake";
|
|
3
|
+
import { participantSnapshot, visitorPendingPrompt, visitorSnapshot, } from "@fungi.computer/shiitake/client";
|
|
4
|
+
import { visitorStream } from "@fungi.computer/shiitake/server-visitor-stream";
|
|
5
|
+
/** Translate a standalone Agent's Shiitake owner into Oyster's channel Session port. */
|
|
6
|
+
export function channelSessionDoor(open, deliverGrants, conversations) {
|
|
7
|
+
const policy = () => conversations();
|
|
8
|
+
return {
|
|
9
|
+
createSession: async (requestId) => (await open()).createSession(requestId),
|
|
10
|
+
deliverGrants,
|
|
11
|
+
withdraw: async (sessionId, requestId) => (await open()).session(sessionId).withdraw(requestId),
|
|
12
|
+
latestPending: async (sessionId, visitor) => {
|
|
13
|
+
const prompt = await (await open())
|
|
14
|
+
.withMeta(authorMeta(visitor))
|
|
15
|
+
.session(sessionId)
|
|
16
|
+
.latestPending();
|
|
17
|
+
return prompt === null ? null : visitorPendingPrompt(prompt, visitor.id);
|
|
18
|
+
},
|
|
19
|
+
participantDocument: async (sessionId, visitorId, options) => {
|
|
20
|
+
const snapshot = await (await open()).session(sessionId).read(options);
|
|
21
|
+
return JSON.stringify(visitorSnapshot(participantSnapshot(snapshot, policy()), visitorId));
|
|
22
|
+
},
|
|
23
|
+
participantStream: async (sessionId, visitorId, options) => {
|
|
24
|
+
let watch;
|
|
25
|
+
try {
|
|
26
|
+
watch = await (await open()).session(sessionId).watch();
|
|
27
|
+
}
|
|
28
|
+
catch (cause) {
|
|
29
|
+
options.release();
|
|
30
|
+
throw cause;
|
|
31
|
+
}
|
|
32
|
+
return visitorStream({
|
|
33
|
+
...options,
|
|
34
|
+
watch,
|
|
35
|
+
visitorId,
|
|
36
|
+
filter: (snapshot) => participantSnapshot(snapshot, policy()),
|
|
37
|
+
read: async () => (await open()).session(sessionId).read(),
|
|
38
|
+
onError: (event, cause) => {
|
|
39
|
+
console.warn(event, cause);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
prompt: async (sessionId, { requestId, text, meta }) => {
|
|
44
|
+
// The conversation row exists now, so its channel admission is known;
|
|
45
|
+
// deliver Agent tools before the first run can call one.
|
|
46
|
+
deliverGrants(sessionId);
|
|
47
|
+
const agent = await open();
|
|
48
|
+
return await agent.withMeta(meta).session(sessionId).command({
|
|
49
|
+
type: "prompt",
|
|
50
|
+
requestId,
|
|
51
|
+
text,
|
|
52
|
+
delivery: "followUp",
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
line: async (sessionId, input) => {
|
|
56
|
+
const agent = await open();
|
|
57
|
+
const meta = input.author === "operator" ? authorMeta(input.identity) : input.meta;
|
|
58
|
+
await agent.withMeta(meta).session(sessionId).command({
|
|
59
|
+
type: "operator",
|
|
60
|
+
requestId: input.requestId,
|
|
61
|
+
author: input.author,
|
|
62
|
+
text: input.text,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
errorKind: (error, requestId) => error instanceof ShiitakeError &&
|
|
66
|
+
error.boundary === "contract" &&
|
|
67
|
+
error.cause === "closed" &&
|
|
68
|
+
error.requestId === requestId
|
|
69
|
+
? "closed_request"
|
|
70
|
+
: null,
|
|
71
|
+
};
|
|
72
|
+
}
|