@fungi.computer/oyster 0.24.0 → 0.25.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.
@@ -268,6 +268,12 @@ export declare abstract class StandaloneAgentBase<Env extends StandaloneAgentEnv
268
268
  /** A byok choice must name a stored key of the chosen provider. */
269
269
  private admitKey;
270
270
  private choice;
271
+ private instructionsOwner;
272
+ private ownerInstructions;
273
+ /** The owner's standing instructions for this Agent; the host admits the owner first. */
274
+ readInstructions(): string;
275
+ /** Replace them. The next turn follows the new text; a run already going does not change. */
276
+ writeInstructions(instructions: string): string;
271
277
  /** Secret-free default of this Agent; stored separately from Session history. */
272
278
  readModelChoice(): Promise<AgentModelChoice>;
273
279
  setModelChoice(input: AgentModelChoice): Promise<AgentModelChoice | Readonly<{
@@ -16,6 +16,7 @@ import { createDiscordReplies, } from "../channels/discord-replies.js";
16
16
  import { isDiscordBinding, createDiscordBindings, createDiscordInputSchema, updateDiscordInputSchema, } from "../channels/discord-binding.js";
17
17
  import { DISCORD_SETTLEMENT_WAIT_MS, discordDenial, discordFailureText, patchOriginal, postChannelMessage, postFollowUp, quoted, STILL_WORKING_TEXT, splitDiscordMessage, registerAskCommand, } from "../channels/discord-interactions.js";
18
18
  import { discordOutcome, sealDiscordToken, } from "./discord-channels.js";
19
+ import { createAgentInstructions, withOwnerInstructions, } from "../agent-instructions.js";
19
20
  import { channelSessionDoor } from "./channel-session-door.js";
20
21
  import { createAuthenticatedVisitorChannel } from "../channels/visitor-channel.js";
21
22
  import { verifyVisitor } from "./visitor-proof.js";
@@ -1038,6 +1039,18 @@ export class StandaloneAgentBase extends ShiitakeDO {
1038
1039
  });
1039
1040
  });
1040
1041
  }
1042
+ instructionsOwner;
1043
+ ownerInstructions() {
1044
+ return (this.instructionsOwner ??= createAgentInstructions(this.ctx.storage.sql));
1045
+ }
1046
+ /** The owner's standing instructions for this Agent; the host admits the owner first. */
1047
+ readInstructions() {
1048
+ return this.ownerInstructions().read().instructions;
1049
+ }
1050
+ /** Replace them. The next turn follows the new text; a run already going does not change. */
1051
+ writeInstructions(instructions) {
1052
+ return this.ownerInstructions().write(instructions).instructions;
1053
+ }
1041
1054
  /** Secret-free default of this Agent; stored separately from Session history. */
1042
1055
  async readModelChoice() {
1043
1056
  return this.choice().read();
@@ -1236,10 +1249,10 @@ export class StandaloneAgentBase extends ShiitakeDO {
1236
1249
  instructions: this.channelInstructions({
1237
1250
  load: async () => {
1238
1251
  const { appApprovalInstructions } = await import("../mcp.js");
1239
- return {
1252
+ return withOwnerInstructions({
1240
1253
  revision: "oyster-7",
1241
1254
  text: instructions + "\n" + appApprovalInstructions,
1242
- };
1255
+ }, this.ownerInstructions().read());
1243
1256
  },
1244
1257
  }),
1245
1258
  tools: {
@@ -2420,6 +2433,26 @@ export function standaloneAgents(env, scope) {
2420
2433
  const parsed = Schema.decodeUnknownOption(Schema.fromJsonString(agentModelChoiceSchema), { onExcessProperty: "error" })(json);
2421
2434
  return parsed._tag === "None" ? null : parsed.value;
2422
2435
  },
2436
+ readInstructions: async (agentId, principal) => {
2437
+ if (!oysterPrincipalIsOwner(principal))
2438
+ return { error: "not_granted" };
2439
+ if (!(await directory().has(agentId)))
2440
+ return { error: "not_found" };
2441
+ return {
2442
+ agentId,
2443
+ instructions: await env.AGENTS.getByName(agentId).readInstructions(),
2444
+ };
2445
+ },
2446
+ setInstructions: async (agentId, instructions, principal) => {
2447
+ if (!oysterPrincipalIsOwner(principal))
2448
+ return { error: "not_granted" };
2449
+ if (!(await directory().has(agentId)))
2450
+ return { error: "not_found" };
2451
+ return {
2452
+ agentId,
2453
+ instructions: await env.AGENTS.getByName(agentId).writeInstructions(instructions),
2454
+ };
2455
+ },
2423
2456
  setModelChoice: async (agentId, choice, principal) => {
2424
2457
  if (!oysterPrincipalIsOwner(principal))
2425
2458
  return { error: "not_granted" };
@@ -6,7 +6,7 @@ import * as z from "zod";
6
6
  import { computerProcessSchema, computerToolResultSchema, readOutputSchema } from "@fungi.computer/computer-contract";
7
7
  import { ComputerDO as NativeComputerDO, type AttachedBackend, type ComputerEnv, type ComputerFilesRpc } from "@fungi.computer/computer";
8
8
  import { patchInputSchema, patchOutputSchema } from "@fungi.computer/knapsack/files-patch";
9
- import { listOutputSchema, writeOutputSchema, mkdirOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsOutputSchema, computerOperationResultSchema, type ComputerExecutionHostHooks, type ComputerValue } from "@fungi.computer/computer-contract";
9
+ import { listOutputSchema, writeOutputSchema, mkdirOutputSchema, moveOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsOutputSchema, computerOperationResultSchema, type ComputerExecutionHostHooks, type ComputerValue } from "@fungi.computer/computer-contract";
10
10
  import { type WorkflowGitCredential, type WorkflowGitPassGrant } from "@fungi.computer/braid/runtime";
11
11
  import { type ComputerAction, type ComputerBackendView, type ComputerGrant, type LocalBackendAttachInput, type LocalBackendDetachInput } from "@fungi.computer/computer/fleet";
12
12
  import type { InvocationFrame } from "../invocation.js";
@@ -39,8 +39,8 @@ export type StandaloneComputerResult = z.output<typeof listOutputSchema> | Reado
39
39
  encoding: "base64";
40
40
  truncated: boolean;
41
41
  }> | Readonly<{
42
- error: "conflict" | "no_runtime" | "not_found";
43
- }> | z.output<typeof writeOutputSchema> | z.output<typeof mkdirOutputSchema> | z.output<typeof computerPortsOutputSchema> | z.output<typeof computerPortOutputSchema> | z.output<typeof computerPortRemovalOutputSchema> | z.output<typeof processListOutputSchema> | z.output<typeof processKillOutputSchema> | z.output<typeof processLogsOutputSchema> | z.output<typeof computerProcessSchema> | ComputerPorts["ports"][number] | z.output<typeof computerOperationResultSchema> | z.output<typeof readOutputSchema> | z.output<typeof computerToolResultSchema>;
42
+ error: "conflict" | "no_runtime" | "not_found" | "invalid";
43
+ }> | z.output<typeof writeOutputSchema> | z.output<typeof moveOutputSchema> | z.output<typeof mkdirOutputSchema> | z.output<typeof computerPortsOutputSchema> | z.output<typeof computerPortOutputSchema> | z.output<typeof computerPortRemovalOutputSchema> | z.output<typeof processListOutputSchema> | z.output<typeof processKillOutputSchema> | z.output<typeof processLogsOutputSchema> | z.output<typeof computerProcessSchema> | ComputerPorts["ports"][number] | z.output<typeof computerOperationResultSchema> | z.output<typeof readOutputSchema> | z.output<typeof computerToolResultSchema>;
44
44
  /**
45
45
  * A port-preview listing, or the typed refusal the owner route presents with
46
46
  * {@link appMethodRefusalStatus}. A refusal never escapes as a 500.
@@ -12,7 +12,7 @@ import * as z from "zod";
12
12
  import { ComputerPortConflictError, computerByteReadReplySchema, computerProcessSchema, installationProcessScope, processStartInputSchema, processStartToolInputSchema, computerCapabilities, computerToolResultSchema, readOutputSchema, } from "@fungi.computer/computer-contract";
13
13
  import { ComputerDO as NativeComputerDO, ComputerOperationConflictError, ComputerBackendUnavailableError, } from "@fungi.computer/computer";
14
14
  import { patchInputSchema, patchOutputSchema, } from "@fungi.computer/knapsack/files-patch";
15
- import { ComputerFileConflict, computerExecutionRequestSchema, computerValueSchema, computerPortInputSchema, listInputSchema, listOutputSchema, readBytesInputSchema, writeInputSchema, replaceInputSchema, writeOutputSchema, mkdirOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsInputSchema, processLogsOutputSchema, computerOperationResultSchema, mintComputerRequestId, processIdInputSchema, } from "@fungi.computer/computer-contract";
15
+ import { ComputerFileConflict, ComputerFileMoveError, computerExecutionRequestSchema, computerValueSchema, computerPortInputSchema, listInputSchema, listOutputSchema, readBytesInputSchema, writeInputSchema, replaceInputSchema, writeOutputSchema, mkdirOutputSchema, moveInputSchema, moveOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsInputSchema, processLogsOutputSchema, computerOperationResultSchema, mintComputerRequestId, processIdInputSchema, } from "@fungi.computer/computer-contract";
16
16
  import { workflowGitExecutionEnvironment, workflowGitPassGrantSchema, } from "@fungi.computer/braid/runtime";
17
17
  import { checkComputerGrant, computerActionSchema, computerGrantSchema, ComputerBackingError, createFleetBacking, FleetGrantRefused, FleetLifecycle, } from "@fungi.computer/computer/fleet";
18
18
  import { AppInstanceError, selectionOf } from "../index.js";
@@ -84,6 +84,7 @@ const computerTools = {
84
84
  read: { action: "files.read", output: readOutputSchema },
85
85
  list: { action: "files.list", output: listOutputSchema },
86
86
  write: { action: "files.write", output: writeOutputSchema },
87
+ move: { action: "files.move", output: moveOutputSchema },
87
88
  mkdir: { action: "mkdir", output: mkdirOutputSchema },
88
89
  bash: { action: "bash", output: computerToolResultSchema },
89
90
  exec: { action: "exec", output: computerToolResultSchema },
@@ -95,6 +96,7 @@ const computerTool = z.enum([
95
96
  "read",
96
97
  "list",
97
98
  "write",
99
+ "move",
98
100
  "mkdir",
99
101
  "bash",
100
102
  "exec",
@@ -534,6 +536,21 @@ export class ComputerDO extends NativeComputerDO {
534
536
  }
535
537
  case "files.write":
536
538
  return writeOutputSchema.parse(await this.callAfterAcceptance("write", input, accept));
539
+ case "files.move":
540
+ try {
541
+ return moveOutputSchema.parse(await this.callAfterAcceptance("move", input, accept));
542
+ }
543
+ catch (error) {
544
+ if (error instanceof ComputerFileMoveError)
545
+ return {
546
+ error: error.reason === "exists"
547
+ ? "conflict"
548
+ : error.reason === "missing"
549
+ ? "not_found"
550
+ : "invalid",
551
+ };
552
+ throw error;
553
+ }
537
554
  case "mkdir":
538
555
  return mkdirOutputSchema.parse(await this.callAfterAcceptance("mkdir", input, accept));
539
556
  default:
@@ -778,6 +795,18 @@ export const computerFrameMethods = {
778
795
  .parse(value),
779
796
  requiredOperations: () => ["write"],
780
797
  },
798
+ move: {
799
+ decodeArgs: (args) => z.tuple([moveInputSchema]).parse(args),
800
+ decodeResult: (value) => z
801
+ .union([
802
+ moveOutputSchema,
803
+ z.strictObject({
804
+ error: z.enum(["conflict", "not_found", "invalid"]),
805
+ }),
806
+ ])
807
+ .parse(value),
808
+ requiredOperations: () => ["move"],
809
+ },
781
810
  ports: {
782
811
  decodeArgs: (args) => z.tuple([empty]).parse(args),
783
812
  decodeResult: (value) => computerPortsOutputSchema.parse(value),
@@ -907,6 +936,10 @@ export async function computerInvocation(env, scope, frame, method, args) {
907
936
  };
908
937
  break;
909
938
  }
939
+ case "move":
940
+ action = "files.move";
941
+ [input] = z.tuple([moveInputSchema]).parse(args);
942
+ break;
910
943
  case "ports":
911
944
  action = "listPorts";
912
945
  [input] = z.tuple([empty]).parse(args);
@@ -103,7 +103,7 @@ export declare function createStandaloneWorkflowHost(owner: WatchdogSqliteOwner,
103
103
  authorityVersion: number;
104
104
  declaredOperationsDigest: import("@fungi.computer/puffball").Sha256Digest;
105
105
  approvedGrants: readonly Readonly<{
106
- capability: "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
106
+ capability: "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
107
107
  capabilityApproved: true;
108
108
  operations: readonly string[];
109
109
  resources: "tenant-scope" | readonly Readonly<{
@@ -220,7 +220,7 @@ export declare function createStandaloneWorkflowHost(owner: WatchdogSqliteOwner,
220
220
  authorityVersion: number;
221
221
  declaredOperationsDigest: import("@fungi.computer/puffball").Sha256Digest;
222
222
  approvedGrants: readonly Readonly<{
223
- capability: "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
223
+ capability: "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
224
224
  capabilityApproved: true;
225
225
  operations: readonly string[];
226
226
  resources: "tenant-scope" | readonly Readonly<{
@@ -287,7 +287,7 @@ export declare function createStandaloneWorkflowHost(owner: WatchdogSqliteOwner,
287
287
  authorityVersion: number;
288
288
  declaredOperationsDigest: import("@fungi.computer/puffball").Sha256Digest;
289
289
  approvedGrants: readonly Readonly<{
290
- capability: "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
290
+ capability: "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
291
291
  capabilityApproved: true;
292
292
  operations: readonly string[];
293
293
  resources: "tenant-scope" | readonly Readonly<{
@@ -387,7 +387,7 @@ export declare function createStandaloneWorkflowHost(owner: WatchdogSqliteOwner,
387
387
  authorityVersion: number;
388
388
  declaredOperationsDigest: import("@fungi.computer/puffball").Sha256Digest;
389
389
  approvedGrants: readonly Readonly<{
390
- capability: "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
390
+ capability: "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
391
391
  capabilityApproved: true;
392
392
  operations: readonly string[];
393
393
  resources: "tenant-scope" | readonly Readonly<{
@@ -468,7 +468,7 @@ export declare function createStandaloneWorkflowHost(owner: WatchdogSqliteOwner,
468
468
  authorityVersion: number;
469
469
  declaredOperationsDigest: import("@fungi.computer/puffball").Sha256Digest;
470
470
  approvedGrants: readonly Readonly<{
471
- capability: "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
471
+ capability: "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
472
472
  capabilityApproved: true;
473
473
  operations: readonly string[];
474
474
  resources: "tenant-scope" | readonly Readonly<{
@@ -344,7 +344,7 @@ export declare function createStandaloneWorkflowTriggerHost(options: {
344
344
  readonly operations: readonly string[];
345
345
  }[];
346
346
  readonly nodeId: string;
347
- readonly capabilities: readonly ("approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage")[];
347
+ readonly capabilities: readonly ("approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage")[];
348
348
  readonly graphId?: string;
349
349
  }[];
350
350
  readonly nodeGitAccess: readonly {
@@ -269,6 +269,24 @@ type OysterAgents = Readonly<{
269
269
  };
270
270
  keyId?: string;
271
271
  } | null>;
272
+ readInstructions: Promise<
273
+ | Readonly<{
274
+ agentId: string;
275
+ instructions: string;
276
+ }>
277
+ | Readonly<{
278
+ error: "not_found" | "not_granted";
279
+ }>
280
+ >;
281
+ setInstructions: Promise<
282
+ | Readonly<{
283
+ agentId: string;
284
+ instructions: string;
285
+ }>
286
+ | Readonly<{
287
+ error: "not_found" | "not_granted";
288
+ }>
289
+ >;
272
290
  decodeModelChoice: {
273
291
  keySource: "workers-ai" | "ai-gateway" | "byok";
274
292
  model: {