@fungi.computer/oyster 0.26.0 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/agents.d.ts CHANGED
@@ -14,6 +14,17 @@ export type { StarterOutcome };
14
14
  import type { AgentModelChoice, AgentModelRefusal } from "./standalone/agent-model-choice.js";
15
15
  export type { AgentModelChoice, AgentModelRefusal, } from "./standalone/agent-model-choice.js";
16
16
  import type { MemberInboxItem, MemberInboxSession } from "@fungi.computer/puffball/inbox";
17
+ /** An Agent's AGENTS.md on its Home Computer, with the byte limit the host enforces. */
18
+ export type OysterAgentInstructions = Readonly<{
19
+ /** The Home Computer holding the file; null when the Agent has none. */
20
+ home: Readonly<{
21
+ name: string;
22
+ }> | null;
23
+ /** The file's text; null when there is no Home or the file does not exist yet. */
24
+ content: string | null;
25
+ bytes: number;
26
+ limit: number;
27
+ }>;
17
28
  /** One agent as Apps see it, in Agar's `appAgentSchema` shape. */
18
29
  export type OysterAgent = Readonly<{
19
30
  agentId: string;
@@ -140,19 +151,24 @@ export type OysterAgents = Readonly<{
140
151
  }>>;
141
152
  /** Owner-only, secret-free Agent default; an unknown Agent cannot be configured. */
142
153
  readModelChoice(agentId: string): Promise<AgentModelChoice | null>;
143
- /** Owner-only read of the standing instructions this Agent follows on every turn. */
154
+ /** Owner-only read of the AGENTS.md on this Agent's Home Computer. */
144
155
  readInstructions(agentId: string, principal: TenantPrincipal): Promise<Readonly<{
145
156
  agentId: string;
146
- instructions: string;
147
- }> | Readonly<{
157
+ } & OysterAgentInstructions> | Readonly<{
148
158
  error: "not_found" | "not_granted";
149
159
  }>>;
150
- /** Owner-only replacement of them; empty clears. Appended after the host's fixed instructions. */
151
- setInstructions(agentId: string, instructions: string, principal: TenantPrincipal): Promise<Readonly<{
160
+ /**
161
+ * Owner-only replacement of it. `expectedContent` is what the owner last read;
162
+ * null creates the file only while absent. A file the Agent changed since is a
163
+ * `conflict`, never overwritten.
164
+ */
165
+ setInstructions(agentId: string, edit: Readonly<{
166
+ expectedContent: string | null;
167
+ content: string;
168
+ }>, principal: TenantPrincipal): Promise<Readonly<{
152
169
  agentId: string;
153
- instructions: string;
154
- }> | Readonly<{
155
- error: "not_found" | "not_granted";
170
+ } & OysterAgentInstructions> | Readonly<{
171
+ error: "not_found" | "not_granted" | "conflict" | "too_large" | "no_home";
156
172
  }>>;
157
173
  /** Parse the owner's JSON through the deployable Agent's model preference schema. */
158
174
  decodeModelChoice(json: string): AgentModelChoice | null;
package/dist/agents.js CHANGED
@@ -6,7 +6,7 @@ import { agentAvatarSchema } from "./agent-avatars.js";
6
6
  import { computerTargetParam } from "./computer-target.js";
7
7
  import { modelKeyProviderChoices } from "./standalone/model-key-providers.js";
8
8
  import { supportedAgentModels } from "./standalone/agent-model-choice.js";
9
- import { agentAvatar, agentInstructions, appAgentInstructionsMaxLength, agentList, agentManage, agentRename, agentSessionRead, agentSessionWrite, agentToolPolicy, } from "@fungi.computer/agar/agents";
9
+ import { agentAvatar, agentInstructions, agentList, agentManage, agentRename, agentSessionRead, agentSessionWrite, agentToolPolicy, } from "@fungi.computer/agar/agents";
10
10
  /** At most this many connections per Agent. */
11
11
  export const maxAgentConnections = 16;
12
12
  /** Owner input for one MCP connection: a guest identifier, an `https:` endpoint and an optional bearer. */
@@ -44,7 +44,8 @@ const renameSchema = Schema.Struct({
44
44
  });
45
45
  const avatarInputSchema = z.object({ avatar: agentAvatarSchema });
46
46
  const instructionsInputSchema = z.object({
47
- instructions: z.string().max(appAgentInstructionsMaxLength),
47
+ expectedContent: z.string().nullable(),
48
+ content: z.string(),
48
49
  });
49
50
  const visitSchema = Schema.Struct({
50
51
  agentId: Schema.String,
@@ -267,10 +268,16 @@ function createAgentRoutes(agents) {
267
268
  return refusal(404, "No such agent");
268
269
  const body = instructionsInputSchema.safeParse(await context.req.json());
269
270
  if (!body.success)
270
- return refusal(400, "Instructions are too long");
271
- const result = await agents.setInstructions(agentId, body.data.instructions, principal);
271
+ return refusal(400, "Invalid instructions edit");
272
+ const result = await agents.setInstructions(agentId, body.data, principal);
272
273
  if ("error" in result)
273
- return refusal(result.error === "not_found" ? 404 : 403, result.error);
274
+ return refusal(result.error === "not_found"
275
+ ? 404
276
+ : result.error === "not_granted"
277
+ ? 403
278
+ : result.error === "too_large"
279
+ ? 413
280
+ : 409, result.error);
274
281
  return Response.json(result);
275
282
  })
276
283
  .get("/agent-policies/:agentId", agent(), async (_context, { agentId }) => {
@@ -19,7 +19,7 @@ export const permissionCatalog = {
19
19
  "agent.manage": entry("agents", "Create and manage Agents", "create Agents and manage their sessions.", "createAgents", "install", "agent"),
20
20
  "agent.rename": entry("agents", "Rename Agents", "rename Agents you created.", "createAgents", "install"),
21
21
  "agent.avatar": entry("agents", "Change Agent avatars", "change the avatars of Agents you created.", "createAgents", "install"),
22
- "agent.instructions": entry("agents", "Change Agent instructions", "change the standing instructions of your Agents.", "createAgents", "install"),
22
+ "agent.instructions": entry("agents", "Change Agent instructions", "change the AGENTS.md instructions on your Agents' Home Computers.", "createAgents", "install"),
23
23
  "agent.toolPolicy": entry("agents", "Allow Agents to use Apps", "approve Agents to use your installed Apps.", "createAgents", "install"),
24
24
  "agent.read": entry("agents", "Read Agent conversations", "read Agent conversations.", "readConversations", "install", "agent"),
25
25
  "agent.send": entry("agents", "Send messages to Agents", "send messages to Agents.", "sendPrompts", "install", "agent"),