@fungi.computer/oyster 0.44.0 → 0.46.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/dist/agents.d.ts +6 -0
- package/dist/agents.js +122 -0
- package/dist/platform-skills.generated.d.ts +1 -1
- package/dist/platform-skills.generated.js +1 -1
- package/dist/standalone/agent-connections.d.ts +21 -1
- package/dist/standalone/agent-connections.js +85 -1
- package/dist/standalone/agents.d.ts +30 -3
- package/dist/standalone/agents.js +118 -28
- package/dist/standalone/model-key-usage.d.ts +28 -0
- package/dist/standalone/model-key-usage.js +70 -0
- package/dist/standalone/vault.d.ts +84 -0
- package/dist/standalone/vault.js +64 -0
- package/docs/api/agents.md +167 -3
- package/docs/api/workers-git.md +7 -7
- package/package.json +6 -6
package/dist/agents.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import type { TenantPrincipal } from "./tenant.js";
|
|
|
3
3
|
import type { ModelKeyRecord, ModelKeyRefusal, ModelKeySealInput } from "./standalone/model-key-vault.js";
|
|
4
4
|
export type { ModelKeyRecord, ModelKeyRefusal, ModelKeySealInput, } from "./standalone/model-key-vault.js";
|
|
5
5
|
export type { StandaloneModelKeyProvider } from "./standalone/model-key-providers.js";
|
|
6
|
+
import type { VaultCommand, VaultResult } from "./standalone/vault.js";
|
|
7
|
+
export type { VaultCommand, VaultCredential, VaultRefusal, VaultResult, VaultView, } from "./standalone/vault.js";
|
|
8
|
+
export type { ModelKeyUsage } from "./standalone/model-key-usage.js";
|
|
9
|
+
export type { CredentialRefusal } from "./standalone/agent-connections.js";
|
|
6
10
|
import { type Routes } from "./authorization.js";
|
|
7
11
|
import type { AppToolPolicy } from "./apps/tools.js";
|
|
8
12
|
import * as Schema from "effect/Schema";
|
|
@@ -204,6 +208,8 @@ export type OysterAgents = Readonly<{
|
|
|
204
208
|
}>>;
|
|
205
209
|
/** Remove one key; Agents that chose it then fail with `key_removed`. */
|
|
206
210
|
removeModelKey(keyId: string): Promise<"deleted" | "absent">;
|
|
211
|
+
/** The Vault page's one owner door: every stored credential, write-only. */
|
|
212
|
+
vault(command: VaultCommand): Promise<VaultResult>;
|
|
207
213
|
/** Every connection with the Agents that may use it. */
|
|
208
214
|
connections(): Promise<readonly OysterConnection[]>;
|
|
209
215
|
/** Connect one remote MCP server; no Agent has it until the owner grants it. */
|
package/dist/agents.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { destinationsSchema, subjectSchema, } from "@fungi.computer/veil/connections";
|
|
1
2
|
import { agent, agents as agentCollection, owner, routes, } from "./authorization.js";
|
|
2
3
|
import * as Schema from "effect/Schema";
|
|
3
4
|
import { agentNameSchema } from "@fungi.computer/agar/agents";
|
|
@@ -525,6 +526,127 @@ export function modelKeyRoutes(agents, computerSetup) {
|
|
|
525
526
|
return (await agents.removeModelKey(keyId)) === "deleted"
|
|
526
527
|
? new Response(null, { status: 204 })
|
|
527
528
|
: refusal(404, "No such key");
|
|
529
|
+
})
|
|
530
|
+
.include(vaultRoutes(agents));
|
|
531
|
+
}
|
|
532
|
+
/** Printable ASCII, as Veil seals it; never echoed back. */
|
|
533
|
+
const vaultValue = Schema.String.check(Schema.isPattern(/^[\x21-\x7e]{1,16384}$/u));
|
|
534
|
+
const vaultLabel = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(128));
|
|
535
|
+
const expectedVersion = Schema.Number.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(1));
|
|
536
|
+
const addSecretSchema = Schema.Struct({
|
|
537
|
+
name: Schema.String.check(Schema.isPattern(/^[a-z][a-z0-9_]{0,31}$/u)),
|
|
538
|
+
label: Schema.optional(vaultLabel),
|
|
539
|
+
destinations: destinationsSchema,
|
|
540
|
+
placement: Schema.Union([
|
|
541
|
+
Schema.Literal("bearer"),
|
|
542
|
+
Schema.Literal("basic"),
|
|
543
|
+
Schema.Struct({
|
|
544
|
+
header: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9-]{1,64}$/u)),
|
|
545
|
+
}),
|
|
546
|
+
Schema.Struct({
|
|
547
|
+
query: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_.-]{1,64}$/u)),
|
|
548
|
+
}),
|
|
549
|
+
]),
|
|
550
|
+
secret: vaultValue,
|
|
551
|
+
});
|
|
552
|
+
const updateCredentialSchema = Schema.Struct({
|
|
553
|
+
expectedVersion,
|
|
554
|
+
label: Schema.optional(vaultLabel),
|
|
555
|
+
destinations: Schema.optional(destinationsSchema),
|
|
556
|
+
secret: Schema.optional(vaultValue),
|
|
557
|
+
});
|
|
558
|
+
const revokeCredentialSchema = Schema.Struct({ expectedVersion });
|
|
559
|
+
/** Apps hold no Vault power: the subject kinds the page offers. */
|
|
560
|
+
const vaultSubjectKinds = new Set(["agent", "computer", "team-key"]);
|
|
561
|
+
const vaultRefusalStatus = {
|
|
562
|
+
not_found: 404,
|
|
563
|
+
conflict: 409,
|
|
564
|
+
denied: 403,
|
|
565
|
+
invalid_input: 400,
|
|
566
|
+
duplicate_name: 409,
|
|
567
|
+
limit: 409,
|
|
568
|
+
invalid_endpoint: 400,
|
|
569
|
+
unsupported_subject: 400,
|
|
570
|
+
};
|
|
571
|
+
/**
|
|
572
|
+
* The Vault page's owner routes. A value is posted straight here and nothing
|
|
573
|
+
* ever reads one back; listings and usage carry no value.
|
|
574
|
+
*/
|
|
575
|
+
function vaultRoutes(agents) {
|
|
576
|
+
const answer = async (command, status = 200) => {
|
|
577
|
+
const result = await agents.vault(command);
|
|
578
|
+
return "error" in result
|
|
579
|
+
? refusal(vaultRefusalStatus[result.error], result.error)
|
|
580
|
+
: Response.json(result, {
|
|
581
|
+
status,
|
|
582
|
+
headers: { "cache-control": "private, no-store" },
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
const body = async (request, schema) => {
|
|
586
|
+
if (Number(request.headers.get("content-length") ?? "0") > 64 * 1024)
|
|
587
|
+
return null;
|
|
588
|
+
const decoded = Schema.decodeUnknownOption(Schema.fromJsonString(schema), {
|
|
589
|
+
onExcessProperty: "error",
|
|
590
|
+
})(await request.text());
|
|
591
|
+
return decoded._tag === "None" ? null : decoded.value;
|
|
592
|
+
};
|
|
593
|
+
const subjectOf = (kind, id) => {
|
|
594
|
+
if (!vaultSubjectKinds.has(kind))
|
|
595
|
+
return null;
|
|
596
|
+
const subject = Schema.decodeUnknownOption(subjectSchema)({ kind, id });
|
|
597
|
+
return subject._tag === "None" ? null : subject.value;
|
|
598
|
+
};
|
|
599
|
+
return routes()
|
|
600
|
+
.get("/api/vault", owner("direct"), () => answer({ op: "read" }))
|
|
601
|
+
.post("/api/vault/secrets", owner("direct"), async (context) => {
|
|
602
|
+
const input = await body(context.req.raw, addSecretSchema);
|
|
603
|
+
return input === null
|
|
604
|
+
? refusal(400, "Name the secret, bind it to hosts and paste its value")
|
|
605
|
+
: answer({ op: "addSecret", ...input }, 201);
|
|
606
|
+
})
|
|
607
|
+
.put("/api/vault/credentials/:connectionId", owner("direct"), async (context) => {
|
|
608
|
+
const connectionId = context.req.param("connectionId");
|
|
609
|
+
const input = await body(context.req.raw, updateCredentialSchema);
|
|
610
|
+
if (!connectionIdPattern.test(connectionId))
|
|
611
|
+
return refusal(404, "No such credential");
|
|
612
|
+
return input === null
|
|
613
|
+
? refusal(400, "invalid_input")
|
|
614
|
+
: answer({ op: "updateCredential", connectionId, ...input });
|
|
615
|
+
})
|
|
616
|
+
.delete("/api/vault/credentials/:connectionId", owner("direct"), async (context) => {
|
|
617
|
+
const connectionId = context.req.param("connectionId");
|
|
618
|
+
const input = await body(context.req.raw, revokeCredentialSchema);
|
|
619
|
+
if (!connectionIdPattern.test(connectionId))
|
|
620
|
+
return refusal(404, "No such credential");
|
|
621
|
+
return input === null
|
|
622
|
+
? refusal(400, "invalid_input")
|
|
623
|
+
: answer({ op: "revokeCredential", connectionId, ...input });
|
|
624
|
+
})
|
|
625
|
+
.put("/api/vault/credentials/:connectionId/subjects/:kind/:subjectId", owner("direct"), (context) => {
|
|
626
|
+
const connectionId = context.req.param("connectionId");
|
|
627
|
+
const subject = subjectOf(context.req.param("kind"), context.req.param("subjectId"));
|
|
628
|
+
return !connectionIdPattern.test(connectionId) || subject === null
|
|
629
|
+
? refusal(400, "invalid_input")
|
|
630
|
+
: answer({ op: "grantSecret", connectionId, subject });
|
|
631
|
+
})
|
|
632
|
+
.delete("/api/vault/credentials/:connectionId/subjects/:kind/:subjectId", owner("direct"), (context) => {
|
|
633
|
+
const connectionId = context.req.param("connectionId");
|
|
634
|
+
const subject = subjectOf(context.req.param("kind"), context.req.param("subjectId"));
|
|
635
|
+
return !connectionIdPattern.test(connectionId) || subject === null
|
|
636
|
+
? refusal(400, "invalid_input")
|
|
637
|
+
: answer({ op: "ungrantSecret", connectionId, subject });
|
|
638
|
+
})
|
|
639
|
+
.get("/api/vault/credentials/:connectionId/usage", owner("direct"), (context) => {
|
|
640
|
+
const connectionId = context.req.param("connectionId");
|
|
641
|
+
return connectionIdPattern.test(connectionId)
|
|
642
|
+
? answer({ op: "usage", connectionId })
|
|
643
|
+
: refusal(404, "No such credential");
|
|
644
|
+
})
|
|
645
|
+
.get("/api/vault/model-keys/:keyId/usage", owner("direct"), (context) => {
|
|
646
|
+
const keyId = context.req.param("keyId");
|
|
647
|
+
return keyIdPattern.test(keyId)
|
|
648
|
+
? answer({ op: "modelKeyUsage", keyId })
|
|
649
|
+
: refusal(404, "No such key");
|
|
528
650
|
});
|
|
529
651
|
}
|
|
530
652
|
const connectionIdPattern = /^[A-Za-z0-9_.:-]{1,128}$/u;
|
|
@@ -10,5 +10,5 @@ export declare const platformSkillFiles: readonly [{
|
|
|
10
10
|
readonly content: "---\nname: fungible-computing\ndescription:\n Change how you work on this Agent's Computer. Edit your standing instructions\n and voice, add a skill of your own, or replace a built-in skill. Use when\n asked to remember a rule for every conversation, change your tone, or teach\n yourself a repeatable task.\n---\n\n# Fungible computing\n\nYour standing instructions and your skills are files on a Computer. You and your\nowner can both change them.\n\n## Instructions and voice\n\n- `AGENTS.md` on Home holds standing instructions. `SYSTEM.md` on Home holds\n your voice. Both are read at the start of each run, so an edit applies from\n the next run.\n- Together the two files may hold 32,000 bytes. A file over the limit is not\n loaded.\n- Follow them unless they conflict with the instructions the host gave you\n first. They never grant a tool, an approval or access.\n- They are at `computer://home/AGENTS.md` and `computer://home/SYSTEM.md`.\n- Only a person changes Home, with `/home <name>`. Ask them when no Home is\n available.\n\n## Skills\n\n- A skill is a folder holding a `SKILL.md`. Put your own at\n `.agents/skills/<name>/SKILL.md` on a Computer.\n `.fungi/skills/<name>/SKILL.md` works too and is searched first.\n- `SKILL.md` starts with YAML frontmatter that has a `description`. The `name`\n should match the folder and use lowercase letters, digits and single hyphens,\n at most 64 characters. The prompt shows at most 512 characters of the\n description.\n- Load a skill inside `execute` with\n `return await skill.load({ name: \"skill-name\" });`. Add `file`, relative to\n the returned `baseDirectory`, for a supporting file in the folder.\n- A person can list every skill, and the file each came from, with `/skills`.\n\n## Replace a built-in skill\n\nBuilt-in skills ship with Fungi and are not files on a Computer. To replace one,\nmake a skill with the same name on a Computer, for example\n`.agents/skills/debug-fungi/SKILL.md`. The first skill found with a name wins,\nand a Computer's skills are searched before the built-in ones. Yours is listed,\nand `skill.load` returns yours. Discovery records that yours won.\n";
|
|
11
11
|
}, {
|
|
12
12
|
readonly path: "setup-fungi/SKILL.md";
|
|
13
|
-
readonly content: "---\nname: setup-fungi\ndescription:\n Set yourself up for a new person in your first conversation, or when asked to\n set up Fungi or a project. Interview briefly, then do the setup yourself with\n their approval.\n---\n\n# Set up Fungi for your person\n\n## Goal\n\nWithin a few minutes, be set up for what they actually want: your instructions\nwritten, their project read, and, only if they want it, one App or one schedule.\nFinish with one useful result, not a tour.\n\n## Rules\n\n- Plain words. Say Agent, Computer, App, skill, schedule, Team or Home only at\n the moment you use that thing, with a one-sentence explanation.\n- One new concept per message. Name what you did, never list features.\n- Ask at most 3 questions in total. Use `question.ask` with options, the\n recommended one first. Free text is always allowed. Batch questions.\n- Propose, then act. Before writing files, cloning, scheduling or opening an\n App, show the `plan` checklist and ask \"Do it?\" with `question.ask` (options\n \"Do it\", \"Change something\", \"Skip\"). Reading needs no approval.\n- Document only what you observe. Every command, path and fact comes from a file\n you read or a command you ran.\n- Suggest only these Apps: Grove, Prints, Inkcap, Bazaar.\n- Skip any step whose tool this host does not give you, and carry on.\n- When they want to get on with a task, do the task and set up afterwards.\n- Keep prices and credit amounts out of your messages. Only the `setup.finish`\n line in step 5 mentions continuing.\n\n## Steps\n\n1. Understand. Open with one line that acknowledges what they just said. Then\n learn, from that message and at most 2 follow-up questions: what they want\n Fungi for; whether there is a project (repo, folder, site, docs); anything\n that repeats (daily, weekly). Done when you can state their goal in a\n sentence.\n2. Plan. Write a `plan` checklist of at most 4 items, each one concrete thing\n you will do. Ask \"Do it?\". Done when they answer.\n3. Do, item by item, ticking the plan.\n - Instructions. Edit Home `AGENTS.md` in place: add a short \"About <their\n name>\" section with their goal, the preferences they stated and how they\n want updates. Every line answers \"would I get this wrong without it?\". Then\n introduce instructions in one sentence: \"I saved this in my instructions,\n so I'll remember it in every conversation. You can read or edit them from\n my menu → Instructions.\"\n - Project, if any. Get it onto your Computer.\n - A public repo: `git clone` into `/workspace/<repo>`.\n - A private GitHub repo, when the `gitTeam` tool is present: first offer\n \"Connect GitHub\" as a link to the GitHub connector in Team settings. Once\n the repo is granted, run `gitTeam.clone` into `/workspace/<repo>`.\n - Files: ask them to drop the files in Inkcap.\n\n Then crawl it: list the top level; read the README, manifests and\n lockfiles; the build, test, lint and CI config; existing rule files\n (`AGENTS.md`, `CLAUDE.md`, `.cursor/rules`, `.cursorrules`,\n `.github/copilot-instructions.md`); then a few representative source files.\n Write or improve the project's own `AGENTS.md` with exact commands\n (including one test), entry points, boundaries and gotchas. Show the 3 most\n useful lines you learned. Introduce your Computer in one sentence: \"I have\n my own Computer, a private machine where I keep files and run things.\"\n\n - Repeating work, if any. Propose one schedule with a time and time zone.\n Create it from a new conversation named for the job.\n - An App, only when a stated need matches one. Offer its App link.\n4. First result. Do one small real task toward their goal, now. Done when they\n can see its output.\n5. Finish.\n - Say in two lines what you set up and where to change it.\n - Delete the \"First conversation\" section from Home `AGENTS.md`.\n - When the `setup.finish` tool is available, say one more line: \"That's you\n set up. To keep going with me, start Pro, or link your wallet if you're a\n holder.\" Then call `setup.finish()` once.\n - When the `setup.finish` tool is absent, stop after the two-line summary:\n that host has no money step, so say nothing about Pro or wallets and call\n nothing.\n\n##
|
|
13
|
+
readonly content: "---\nname: setup-fungi\ndescription:\n Set yourself up for a new person in your first conversation, or when asked to\n set up Fungi or a project. Interview briefly, then do the setup yourself with\n their approval.\n---\n\n# Set up Fungi for your person\n\n## Goal\n\nWithin a few minutes, be set up for what they actually want: your instructions\nwritten, their project read, and, only if they want it, one App or one schedule.\nFinish with one useful result, not a tour.\n\n## Rules\n\n- Plain words. Say Agent, Computer, App, skill, schedule, Team or Home only at\n the moment you use that thing, with a one-sentence explanation.\n- One new concept per message. Name what you did, never list features.\n- Ask at most 3 questions in total. Use `question.ask` with options, the\n recommended one first. Free text is always allowed. Batch questions.\n- Propose, then act. Before writing files, cloning, scheduling or opening an\n App, show the `plan` checklist and ask \"Do it?\" with `question.ask` (options\n \"Do it\", \"Change something\", \"Skip\"). Reading needs no approval.\n- Document only what you observe. Every command, path and fact comes from a file\n you read or a command you ran.\n- Suggest only these Apps: Grove, Prints, Inkcap, Bazaar.\n- Skip any step whose tool this host does not give you, and carry on.\n- When they want to get on with a task, do the task and set up afterwards.\n- Keep prices and credit amounts out of your messages. Only the `setup.finish`\n line in step 5 mentions continuing.\n\n## Steps\n\n1. Understand. Open with one line that acknowledges what they just said. Then\n learn, from that message and at most 2 follow-up questions: what they want\n Fungi for; whether there is a project (repo, folder, site, docs); anything\n that repeats (daily, weekly). Done when you can state their goal in a\n sentence.\n2. Plan. Write a `plan` checklist of at most 4 items, each one concrete thing\n you will do. Ask \"Do it?\". Done when they answer.\n3. Do, item by item, ticking the plan.\n - Instructions. Edit Home `AGENTS.md` in place: add a short \"About <their\n name>\" section with their goal, the preferences they stated and how they\n want updates. Every line answers \"would I get this wrong without it?\". Then\n introduce instructions in one sentence: \"I saved this in my instructions,\n so I'll remember it in every conversation. You can read or edit them from\n my menu → Instructions.\"\n - Project, if any. Get it onto your Computer.\n - A public repo: `git clone` into `/workspace/<repo>`.\n - A private GitHub repo, when the `gitTeam` tool is present: first offer\n \"Connect GitHub\" as a link to the GitHub connector in Team settings. Once\n the repo is granted, run `gitTeam.clone` into `/workspace/<repo>`.\n - Files: ask them to drop the files in Inkcap.\n\n Then crawl it: list the top level; read the README, manifests and\n lockfiles; the build, test, lint and CI config; existing rule files\n (`AGENTS.md`, `CLAUDE.md`, `.cursor/rules`, `.cursorrules`,\n `.github/copilot-instructions.md`); then a few representative source files.\n Write or improve the project's own `AGENTS.md` with exact commands\n (including one test), entry points, boundaries and gotchas. Show the 3 most\n useful lines you learned. Introduce your Computer in one sentence: \"I have\n my own Computer, a private machine where I keep files and run things.\"\n\n - Repeating work, if any. Propose one schedule with a time and time zone.\n Create it from a new conversation named for the job.\n - An App, only when a stated need matches one. Offer its App link.\n4. First result. Do one small real task toward their goal, now. Done when they\n can see its output.\n5. Finish.\n - Say in two lines what you set up and where to change it.\n - Delete the \"First conversation\" section from Home `AGENTS.md`.\n - When the `setup.finish` tool is available, say one more line: \"That's you\n set up. To keep going with me, start Pro, or link your wallet if you're a\n holder.\" Then call `setup.finish()` once.\n - When the `setup.finish` tool is absent, stop after the two-line summary:\n that host has no money step, so say nothing about Pro or wallets and call\n nothing.\n\n## Credit\n\n- When the `setup.finish` description says less than $0.15 of credit remains,\n finish the step in hand, then do step 5 without starting a crawl.\n- Reach step 5 only after the first useful result. A hand-off before that leaves\n the person with nothing.\n";
|
|
14
14
|
}];
|
|
@@ -15,6 +15,6 @@ export const platformSkillFiles = [
|
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
path: "setup-fungi/SKILL.md",
|
|
18
|
-
content: '---\nname: setup-fungi\ndescription:\n Set yourself up for a new person in your first conversation, or when asked to\n set up Fungi or a project. Interview briefly, then do the setup yourself with\n their approval.\n---\n\n# Set up Fungi for your person\n\n## Goal\n\nWithin a few minutes, be set up for what they actually want: your instructions\nwritten, their project read, and, only if they want it, one App or one schedule.\nFinish with one useful result, not a tour.\n\n## Rules\n\n- Plain words. Say Agent, Computer, App, skill, schedule, Team or Home only at\n the moment you use that thing, with a one-sentence explanation.\n- One new concept per message. Name what you did, never list features.\n- Ask at most 3 questions in total. Use `question.ask` with options, the\n recommended one first. Free text is always allowed. Batch questions.\n- Propose, then act. Before writing files, cloning, scheduling or opening an\n App, show the `plan` checklist and ask "Do it?" with `question.ask` (options\n "Do it", "Change something", "Skip"). Reading needs no approval.\n- Document only what you observe. Every command, path and fact comes from a file\n you read or a command you ran.\n- Suggest only these Apps: Grove, Prints, Inkcap, Bazaar.\n- Skip any step whose tool this host does not give you, and carry on.\n- When they want to get on with a task, do the task and set up afterwards.\n- Keep prices and credit amounts out of your messages. Only the `setup.finish`\n line in step 5 mentions continuing.\n\n## Steps\n\n1. Understand. Open with one line that acknowledges what they just said. Then\n learn, from that message and at most 2 follow-up questions: what they want\n Fungi for; whether there is a project (repo, folder, site, docs); anything\n that repeats (daily, weekly). Done when you can state their goal in a\n sentence.\n2. Plan. Write a `plan` checklist of at most 4 items, each one concrete thing\n you will do. Ask "Do it?". Done when they answer.\n3. Do, item by item, ticking the plan.\n - Instructions. Edit Home `AGENTS.md` in place: add a short "About <their\n name>" section with their goal, the preferences they stated and how they\n want updates. Every line answers "would I get this wrong without it?". Then\n introduce instructions in one sentence: "I saved this in my instructions,\n so I\'ll remember it in every conversation. You can read or edit them from\n my menu → Instructions."\n - Project, if any. Get it onto your Computer.\n - A public repo: `git clone` into `/workspace/<repo>`.\n - A private GitHub repo, when the `gitTeam` tool is present: first offer\n "Connect GitHub" as a link to the GitHub connector in Team settings. Once\n the repo is granted, run `gitTeam.clone` into `/workspace/<repo>`.\n - Files: ask them to drop the files in Inkcap.\n\n Then crawl it: list the top level; read the README, manifests and\n lockfiles; the build, test, lint and CI config; existing rule files\n (`AGENTS.md`, `CLAUDE.md`, `.cursor/rules`, `.cursorrules`,\n `.github/copilot-instructions.md`); then a few representative source files.\n Write or improve the project\'s own `AGENTS.md` with exact commands\n (including one test), entry points, boundaries and gotchas. Show the 3 most\n useful lines you learned. Introduce your Computer in one sentence: "I have\n my own Computer, a private machine where I keep files and run things."\n\n - Repeating work, if any. Propose one schedule with a time and time zone.\n Create it from a new conversation named for the job.\n - An App, only when a stated need matches one. Offer its App link.\n4. First result. Do one small real task toward their goal, now. Done when they\n can see its output.\n5. Finish.\n - Say in two lines what you set up and where to change it.\n - Delete the "First conversation" section from Home `AGENTS.md`.\n - When the `setup.finish` tool is available, say one more line: "That\'s you\n set up. To keep going with me, start Pro, or link your wallet if you\'re a\n holder." Then call `setup.finish()` once.\n - When the `setup.finish` tool is absent, stop after the two-line summary:\n that host has no money step, so say nothing about Pro or wallets and call\n nothing.\n\n##
|
|
18
|
+
content: '---\nname: setup-fungi\ndescription:\n Set yourself up for a new person in your first conversation, or when asked to\n set up Fungi or a project. Interview briefly, then do the setup yourself with\n their approval.\n---\n\n# Set up Fungi for your person\n\n## Goal\n\nWithin a few minutes, be set up for what they actually want: your instructions\nwritten, their project read, and, only if they want it, one App or one schedule.\nFinish with one useful result, not a tour.\n\n## Rules\n\n- Plain words. Say Agent, Computer, App, skill, schedule, Team or Home only at\n the moment you use that thing, with a one-sentence explanation.\n- One new concept per message. Name what you did, never list features.\n- Ask at most 3 questions in total. Use `question.ask` with options, the\n recommended one first. Free text is always allowed. Batch questions.\n- Propose, then act. Before writing files, cloning, scheduling or opening an\n App, show the `plan` checklist and ask "Do it?" with `question.ask` (options\n "Do it", "Change something", "Skip"). Reading needs no approval.\n- Document only what you observe. Every command, path and fact comes from a file\n you read or a command you ran.\n- Suggest only these Apps: Grove, Prints, Inkcap, Bazaar.\n- Skip any step whose tool this host does not give you, and carry on.\n- When they want to get on with a task, do the task and set up afterwards.\n- Keep prices and credit amounts out of your messages. Only the `setup.finish`\n line in step 5 mentions continuing.\n\n## Steps\n\n1. Understand. Open with one line that acknowledges what they just said. Then\n learn, from that message and at most 2 follow-up questions: what they want\n Fungi for; whether there is a project (repo, folder, site, docs); anything\n that repeats (daily, weekly). Done when you can state their goal in a\n sentence.\n2. Plan. Write a `plan` checklist of at most 4 items, each one concrete thing\n you will do. Ask "Do it?". Done when they answer.\n3. Do, item by item, ticking the plan.\n - Instructions. Edit Home `AGENTS.md` in place: add a short "About <their\n name>" section with their goal, the preferences they stated and how they\n want updates. Every line answers "would I get this wrong without it?". Then\n introduce instructions in one sentence: "I saved this in my instructions,\n so I\'ll remember it in every conversation. You can read or edit them from\n my menu → Instructions."\n - Project, if any. Get it onto your Computer.\n - A public repo: `git clone` into `/workspace/<repo>`.\n - A private GitHub repo, when the `gitTeam` tool is present: first offer\n "Connect GitHub" as a link to the GitHub connector in Team settings. Once\n the repo is granted, run `gitTeam.clone` into `/workspace/<repo>`.\n - Files: ask them to drop the files in Inkcap.\n\n Then crawl it: list the top level; read the README, manifests and\n lockfiles; the build, test, lint and CI config; existing rule files\n (`AGENTS.md`, `CLAUDE.md`, `.cursor/rules`, `.cursorrules`,\n `.github/copilot-instructions.md`); then a few representative source files.\n Write or improve the project\'s own `AGENTS.md` with exact commands\n (including one test), entry points, boundaries and gotchas. Show the 3 most\n useful lines you learned. Introduce your Computer in one sentence: "I have\n my own Computer, a private machine where I keep files and run things."\n\n - Repeating work, if any. Propose one schedule with a time and time zone.\n Create it from a new conversation named for the job.\n - An App, only when a stated need matches one. Offer its App link.\n4. First result. Do one small real task toward their goal, now. Done when they\n can see its output.\n5. Finish.\n - Say in two lines what you set up and where to change it.\n - Delete the "First conversation" section from Home `AGENTS.md`.\n - When the `setup.finish` tool is available, say one more line: "That\'s you\n set up. To keep going with me, start Pro, or link your wallet if you\'re a\n holder." Then call `setup.finish()` once.\n - When the `setup.finish` tool is absent, stop after the two-line summary:\n that host has no money step, so say nothing about Pro or wallets and call\n nothing.\n\n## Credit\n\n- When the `setup.finish` description says less than $0.15 of credit remains,\n finish the step in hand, then do step 5 without starting a crawl.\n- Reach step 5 only after the first useful result. A hand-off before that leaves\n the person with nothing.\n',
|
|
19
19
|
},
|
|
20
20
|
];
|
|
@@ -5,6 +5,10 @@ import { type ConnectionAccess, type ConnectionAdded, type ConnectionInput, type
|
|
|
5
5
|
type SecretGrantRefusal = ConnectionRefusal | Readonly<{
|
|
6
6
|
error: "unsupported_subject";
|
|
7
7
|
}>;
|
|
8
|
+
/** Why the Vault could not change a stored credential; never its value. */
|
|
9
|
+
export type CredentialRefusal = Readonly<{
|
|
10
|
+
error: "not_found" | "conflict" | "denied" | "invalid_input";
|
|
11
|
+
}>;
|
|
8
12
|
/**
|
|
9
13
|
* This instance's Agent MCP connections over Veil's connections core. The
|
|
10
14
|
* owner holds every credential; an Agent receives a secret-free projection and
|
|
@@ -39,11 +43,27 @@ export declare function createAgentMcpConnections(options: {
|
|
|
39
43
|
connectionId: string;
|
|
40
44
|
}> | ConnectionRefusal>;
|
|
41
45
|
secrets: () => Promise<readonly ConnectionView[]>;
|
|
46
|
+
credentials: () => Promise<readonly ConnectionView[]>;
|
|
47
|
+
updateCredential: (input: Readonly<{
|
|
48
|
+
connectionId: string;
|
|
49
|
+
expectedVersion: number;
|
|
50
|
+
label?: string | undefined;
|
|
51
|
+
destinations?: HttpDestinations | undefined;
|
|
52
|
+
secret?: string | undefined;
|
|
53
|
+
}>) => Promise<Readonly<{
|
|
54
|
+
version: number;
|
|
55
|
+
}> | CredentialRefusal>;
|
|
56
|
+
clearCredential: (input: Readonly<{
|
|
57
|
+
connectionId: string;
|
|
58
|
+
expectedVersion: number;
|
|
59
|
+
}>) => Promise<Readonly<{
|
|
60
|
+
version: number;
|
|
61
|
+
}> | CredentialRefusal>;
|
|
42
62
|
grantSecret: (connectionId: string, subject: ConnectionSubject) => Promise<Readonly<{
|
|
43
63
|
ok: true;
|
|
44
64
|
}> | SecretGrantRefusal>;
|
|
45
65
|
ungrantSecret: (connectionId: string, subject: ConnectionSubject) => Promise<void>;
|
|
46
|
-
/** Every recorded use and refusal of one
|
|
66
|
+
/** Every recorded use and refusal of one credential, without its value. */
|
|
47
67
|
secretUsage: (connectionId: string) => Promise<{
|
|
48
68
|
readonly firstAt: number;
|
|
49
69
|
readonly lastAt: number;
|
|
@@ -9,6 +9,24 @@ const ids = defineIdFamily({
|
|
|
9
9
|
});
|
|
10
10
|
/** The Oyster owner is the only actor that manages connections. */
|
|
11
11
|
const owner = "owner";
|
|
12
|
+
const credentialRefusal = (cause) => {
|
|
13
|
+
if (cause instanceof ConnectionsError)
|
|
14
|
+
switch (cause.code) {
|
|
15
|
+
case "conflict":
|
|
16
|
+
return { error: "conflict" };
|
|
17
|
+
case "denied":
|
|
18
|
+
return { error: "denied" };
|
|
19
|
+
case "revoked":
|
|
20
|
+
case "pending":
|
|
21
|
+
return { error: "not_found" };
|
|
22
|
+
case "invalid_input":
|
|
23
|
+
case "unsupported":
|
|
24
|
+
return { error: "invalid_input" };
|
|
25
|
+
default:
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
throw cause;
|
|
29
|
+
};
|
|
12
30
|
/**
|
|
13
31
|
* This instance's Agent MCP connections over Veil's connections core. The
|
|
14
32
|
* owner holds every credential; an Agent receives a secret-free projection and
|
|
@@ -269,13 +287,79 @@ export function createAgentMcpConnections(options) {
|
|
|
269
287
|
if (subject.kind === "agent")
|
|
270
288
|
await options.notify(subject.id);
|
|
271
289
|
}
|
|
290
|
+
/** Every live credential this instance holds, of every kind; never a value. */
|
|
291
|
+
async function credentials() {
|
|
292
|
+
return (await run(connections.list(owner))).filter((row) => row.state !== "revoked");
|
|
293
|
+
}
|
|
294
|
+
const live = async (connectionId) => (await credentials()).find((row) => row.connectionId === connectionId);
|
|
295
|
+
/**
|
|
296
|
+
* The Vault's one write path for a stored credential, write-only: rotate its
|
|
297
|
+
* value, rename it, rescope an HTTP secret, or give a Connection without one
|
|
298
|
+
* a bearer value. Grants stay; a widened secret needs its value re-entered.
|
|
299
|
+
*/
|
|
300
|
+
async function updateCredential(input) {
|
|
301
|
+
const view = await live(input.connectionId);
|
|
302
|
+
if (view === undefined)
|
|
303
|
+
return { error: "not_found" };
|
|
304
|
+
// A signed-in Connection's tokens come from its sign-in, never a paste.
|
|
305
|
+
if (input.secret !== undefined && view.credential.kind === "oauth")
|
|
306
|
+
return { error: "invalid_input" };
|
|
307
|
+
try {
|
|
308
|
+
const done = await run(connections.update(owner, {
|
|
309
|
+
requestId: ids.connection.generate(),
|
|
310
|
+
connectionId: input.connectionId,
|
|
311
|
+
expectedVersion: input.expectedVersion,
|
|
312
|
+
label: input.label,
|
|
313
|
+
destinations: input.destinations,
|
|
314
|
+
// A rotation keeps the placement; a first value rides as a bearer.
|
|
315
|
+
credential: input.secret === undefined
|
|
316
|
+
? undefined
|
|
317
|
+
: view.credential.kind === "static"
|
|
318
|
+
? view.credential
|
|
319
|
+
: { kind: "static", placement: "bearer" },
|
|
320
|
+
secret: input.secret,
|
|
321
|
+
}));
|
|
322
|
+
await notifyHolders(view);
|
|
323
|
+
return { version: done.version };
|
|
324
|
+
}
|
|
325
|
+
catch (cause) {
|
|
326
|
+
return credentialRefusal(cause);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/** Take a Connection's pasted value out of custody; an HTTP secret is revoked whole instead. */
|
|
330
|
+
async function clearCredential(input) {
|
|
331
|
+
const view = await live(input.connectionId);
|
|
332
|
+
if (view === undefined)
|
|
333
|
+
return { error: "not_found" };
|
|
334
|
+
if (view.surface.kind === "http" || view.credential.kind !== "static")
|
|
335
|
+
return { error: "invalid_input" };
|
|
336
|
+
try {
|
|
337
|
+
const done = await run(connections.update(owner, {
|
|
338
|
+
requestId: ids.connection.generate(),
|
|
339
|
+
connectionId: input.connectionId,
|
|
340
|
+
expectedVersion: input.expectedVersion,
|
|
341
|
+
credential: { kind: "none" },
|
|
342
|
+
}));
|
|
343
|
+
await notifyHolders(view);
|
|
344
|
+
return { version: done.version };
|
|
345
|
+
}
|
|
346
|
+
catch (cause) {
|
|
347
|
+
return credentialRefusal(cause);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const notifyHolders = (view) => Promise.all(view.grants
|
|
351
|
+
.filter((grant) => grant.subject.kind === "agent")
|
|
352
|
+
.map((grant) => options.notify(grant.subject.id)));
|
|
272
353
|
return {
|
|
273
354
|
list,
|
|
274
355
|
addSecret,
|
|
275
356
|
secrets,
|
|
357
|
+
credentials,
|
|
358
|
+
updateCredential,
|
|
359
|
+
clearCredential,
|
|
276
360
|
grantSecret,
|
|
277
361
|
ungrantSecret,
|
|
278
|
-
/** Every recorded use and refusal of one
|
|
362
|
+
/** Every recorded use and refusal of one credential, without its value. */
|
|
279
363
|
secretUsage: (connectionId) => run(connections.audit(owner, connectionId)),
|
|
280
364
|
/** Complete one request with a secret on the owner side; the caller names its subject. */
|
|
281
365
|
fetchSecret: (subject, ref, data) => answerEgressRequest(connections.egress, subject, ref, data),
|
|
@@ -28,6 +28,7 @@ import { DurableObject } from "cloudflare:workers";
|
|
|
28
28
|
import { type StandaloneComputerEnv } from "./computer.js";
|
|
29
29
|
import { ShiitakeDO } from "@fungi.computer/shiitake/cloudflare";
|
|
30
30
|
import { type ModelKeyRecord, type ModelKeyRefusal, type ModelKeySealInput } from "./model-key-vault.js";
|
|
31
|
+
import type { VaultCommand, VaultResult } from "./vault.js";
|
|
31
32
|
import type { CloudflareShiitakeOptions } from "@fungi.computer/shiitake/cloudflare";
|
|
32
33
|
import { type AgentModelChoice, type AgentModelRefusal } from "./agent-model-choice.js";
|
|
33
34
|
import * as Schema from "effect/Schema";
|
|
@@ -67,6 +68,8 @@ export type StandaloneAgentsEnv = Readonly<{
|
|
|
67
68
|
OYSTER_WEBSITE_PROOF_KEY?: string;
|
|
68
69
|
/** Configured standalone-owner identity subject; never a stored member ID. */
|
|
69
70
|
OYSTER_OWNER_NAME?: string;
|
|
71
|
+
/** The host's own configured Computer; the starter's Home when it is there. */
|
|
72
|
+
OYSTER_COMPUTER_ID?: string;
|
|
70
73
|
/** Gateway custody remains in Veil; only the host receives these bindings. */
|
|
71
74
|
AI_GATEWAY_AUTH_TOKEN?: string;
|
|
72
75
|
AI_GATEWAY_ACCOUNT_ID?: string;
|
|
@@ -291,6 +294,24 @@ export declare abstract class StandaloneAgentBase<Env extends StandaloneAgentEnv
|
|
|
291
294
|
}>>;
|
|
292
295
|
/** Secret-free default of this Agent; stored separately from Session history. */
|
|
293
296
|
readModelChoice(): Promise<AgentModelChoice>;
|
|
297
|
+
/**
|
|
298
|
+
* Keep the starter's setup prompt on this Agent while it has no Home to hold
|
|
299
|
+
* an AGENTS.md. Written once; Agents that never needed it have no such key.
|
|
300
|
+
* `actor` is the owner whose grant later writes it into a Home.
|
|
301
|
+
*/
|
|
302
|
+
seedFirstConversation(content: string, actor: string): Promise<void>;
|
|
303
|
+
/** The instructions every run of this Agent starts from. */
|
|
304
|
+
protected agentInstructions(): Promise<{
|
|
305
|
+
revision: string;
|
|
306
|
+
text: string;
|
|
307
|
+
}>;
|
|
308
|
+
/**
|
|
309
|
+
* The kept setup prompt, until a Home exists. Then it moves into that Home's
|
|
310
|
+
* AGENTS.md when the Home has none (the starter seed's rule), so an
|
|
311
|
+
* interview that gains a Home midway keeps its instructions, and the kept
|
|
312
|
+
* copy is dropped. A Home that already has an AGENTS.md is left as it is.
|
|
313
|
+
*/
|
|
314
|
+
private firstConversation;
|
|
294
315
|
setModelChoice(input: AgentModelChoice): Promise<AgentModelChoice | Readonly<{
|
|
295
316
|
error: AgentModelRefusal;
|
|
296
317
|
}>>;
|
|
@@ -377,9 +398,15 @@ export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
|
|
|
377
398
|
method: string;
|
|
378
399
|
headers: readonly (readonly [string, string])[];
|
|
379
400
|
body: string | null;
|
|
380
|
-
}
|
|
401
|
+
}>,
|
|
402
|
+
/** The Agent the use is audited to; never its prompt or reply. */
|
|
403
|
+
agentId?: string | null): Promise<Response | Readonly<{
|
|
381
404
|
error: ModelKeyRefusal;
|
|
382
405
|
}>>;
|
|
406
|
+
private modelKeyUsageOwner;
|
|
407
|
+
private modelKeyUsage;
|
|
408
|
+
/** The Vault page's one owner door: every stored credential, write-only. */
|
|
409
|
+
vault(command: VaultCommand): Promise<VaultResult>;
|
|
383
410
|
private redactionSet;
|
|
384
411
|
/**
|
|
385
412
|
* Host-only: fingerprints of every credential this directory stores (model
|
|
@@ -409,10 +436,10 @@ export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
|
|
|
409
436
|
}>[];
|
|
410
437
|
}>[]>;
|
|
411
438
|
addConnection(input: ConnectionInput): Promise<Readonly<{
|
|
439
|
+
error: "not_found" | "duplicate_name" | "limit" | "invalid_endpoint";
|
|
440
|
+
}> | Readonly<{
|
|
412
441
|
connectionId: string;
|
|
413
442
|
authorizeUrl: string | null;
|
|
414
|
-
}> | Readonly<{
|
|
415
|
-
error: "not_found" | "duplicate_name" | "limit" | "invalid_endpoint";
|
|
416
443
|
}>>;
|
|
417
444
|
grantConnection(connectionId: string, agentId: string, access: ConnectionAccess): Promise<Readonly<{
|
|
418
445
|
error: "not_found" | "duplicate_name" | "limit" | "invalid_endpoint";
|