@fungi.computer/oyster 0.56.2 → 0.57.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/agent-computer-source.js +4 -1
- package/dist/auth.d.ts +12 -4
- package/dist/auth.js +85 -24
- package/dist/boot-capability-route.js +5 -1
- package/dist/boot-gate.d.ts +5 -0
- package/dist/boot-gate.js +12 -2
- package/dist/boot-host-script.js +1 -1
- package/dist/boot-mount.d.ts +7 -1
- package/dist/boot-mount.js +11 -5
- package/dist/embed-metafiles.js +2 -2
- package/dist/embed-scripts.js +1 -1
- package/dist/hello-app-script.js +1 -1
- package/dist/host-page-assets.js +1 -1
- package/dist/host-page-lazy.d.ts +2 -0
- package/dist/host-page-lazy.js +8 -0
- package/dist/host-page.d.ts +19 -1
- package/dist/host-page.js +61 -11
- package/dist/host.d.ts +2 -0
- package/dist/host.js +3 -0
- package/dist/owner-sessions.d.ts +25 -0
- package/dist/owner-sessions.js +50 -0
- package/dist/page/boot-host.js +20 -2
- package/dist/page-script.js +1 -1
- package/dist/platform-skills.generated.d.ts +1 -1
- package/dist/platform-skills.generated.js +1 -1
- package/dist/standalone/agents.js +1 -0
- package/dist/standalone/builds.js +5 -0
- package/dist/standalone/candidate-preview.d.ts +25 -0
- package/dist/standalone/candidate-preview.js +265 -0
- package/dist/standalone/tenancy.d.ts +1 -1
- package/dist/standalone/tenancy.js +9 -1
- package/dist/standalone/worker.js +12 -2
- package/dist/starter-agent.js +5 -2
- package/dist/tenancy/owner-key.d.ts +4 -1
- package/dist/tenancy/owner-key.js +27 -2
- package/dist/upgrade/old-worker-http.js +2 -6
- package/dist/workers-git.js +10 -2
- package/dist/workers.d.ts +11 -0
- package/dist/workers.js +33 -1
- package/docs/api/README.md +5 -3
- package/docs/api/auth.md +96 -8
- package/docs/api/host.md +1 -0
- package/docs/api/tenancy/owner-key.md +1 -0
- package/docs/api/workers.md +81 -0
- package/package.json +17 -17
|
@@ -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, or install a missing Computer toolchain or agent\n CLI.\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## Computer tools\n\nOn a hosted Fungi Computer, if go, rust or an agent CLI is missing, run\n`fungi-tools install <tool>` through that Computer's exec operation. Select\n`go`, `rust` (for rustc and cargo), `claude`, `codex`, `opencode` or `pi`. Go\nand Rust persist in that Computer's home. Agent CLIs live in a cache that is\ncleared when the Computer sleeps; after a wake their first use reinstalls the\nsame pinned version and prints `installing <tool> (one-time after wake)`. A\nfailed install is an error to report, not a reason to fetch an unpinned\ninstaller. This command does not supply provider keys or sign the CLI in.\nMember-attached machines use their own installed tools.\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- Your Home prompt section names where they are; read and edit them there.\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 cards in total, counting the \"Do it?\" plan and the name offer. A\n card is one `question.ask`; keep each short and specific, and batch a few\n questions into one card. Use options, the recommended one first. Free text is\n always allowed, and an option that lets them type their own answer is fine. Do\n not ask for the person's own name; their account already has it.\n- Every decision is a `question.ask` card, including \"Do it?\". Never end a turn\n asking the person to reply with options in text.\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- A build, install or test that fails or times out never ends setup: say what\n failed in one line, carry on, and still make every offer in step 5. A command\n result of `unknown` means it may still be running, so check again before\n calling it failed.\n- When an action fails and says it is not retryable, such as a generation, try\n at most once more with clearly different input (another model, say), never the\n same action again. Then say so in one line, carry on, and finish setup.\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 1 follow-up card: what they want Fungi\n for; whether there is a project (repo, folder, site, docs); anything that\n repeats (daily, weekly). Done when you can state their goal in a 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. First list your Computer's top folder, never read `AGENTS.md`\n blind. When it is listed, edit it in place; when it is not there yet, your\n Computer is still finishing its first start: carry on with the other items,\n come back to it before step 4, and if it is still missing create it with\n the same headings. Fill its \"About my person\" section (rename it \"About\n <their name>\") with their goal, the preferences they stated and how they\n want updates. Follow its \"Keeping this file up to date\" section from then\n on. Every line answers \"would I get this wrong without it?\". Then introduce\n instructions in one sentence: \"I saved this in my instructions, so I'll\n remember it in every conversation. You can read or edit them from my menu →\n Instructions.\"\n - Files you create for them: write several in one `files.patch` of Add File\n blocks rather than one write each, so they approve once. Write files with\n `files.patch` or `files.write`, never shell heredocs inside `execute`,\n whose quoting breaks.\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.\n - Prints: describe `PRINTS.generateImage` or `PRINTS.generateVideo`, then\n call it; mark a keeper with `PRINTS.setFavorite` on its saved path and\n read them back with `PRINTS.listFavorites`. The library folder is chosen\n by the person in Prints, and no method lets you choose it, so do not\n search for one: if Prints says no library is selected, say so in one line\n and tell them to pick it in Prints.\n4. First result. Do one small real task toward their goal, now. Done when they\n can see its output.\n5. Finish. Do every item below, in order. Do not end your turn before the name\n offer and the dashboard offer have each been asked, failed, or skipped. Even\n if part of setup is blocked, such as an App that is not ready, say so in your\n two lines and still make both offers. An answered card is final: do not ask\n it again in text.\n - Say in two lines what you set up and where to change it.\n - Offer a name, once (required). Never settle it yourself by saying you keep\n your name: the card is how they keep it. Ask with `question.ask`: \"Keep\n <your name>\" first, where your name is the one in your instructions (\"Your\n name is …\"), copied verbatim and never guessed, then two names you suggest\n that fit their goal; free text is always allowed. Ask the name only as a\n `question.ask` card, never in plain text. Wait for their pick: call\n `question.ask` without `mode`, never `mode: \"continue\"`, and make no\n dashboard call until they have picked. Ask it at most once in the whole\n conversation, even if you run step 5 again. Once they have picked, whether\n a new name or Keep, the name is settled: never ask it again, not even after\n an empty or interrupted turn; carry on with the dashboard offer. Only when\n they pick a new name, call `await env.self.rename({name})`: the moment they\n pick a new name, your very next call is `await env.self.rename({name})`,\n before any other step. Then say in one line that you are now called that.\n Call it directly and do not look it up first, since a lookup of a tool you\n may not see reads as absent. If `env.self` is missing or the call is\n refused, say nothing about it.\n - Offer \"Add to your dashboard\" (required). Call\n `await env.TOURTOIS.widgets.available({})` and pick at most 2 matching\n widgets from what you did: Grove Inbox, Inkcap Recent Files, Prints Recent\n Outputs. If no widget clearly matches what you did, offer the most\n generally useful one: Inbox first, then Recent Files. Skip the offer only\n when `widgets.available` returns nothing but the launcher. Never say there\n is no dashboard offer before you have called\n `await env.TOURTOIS.widgets.available({})`. Do not use `question.ask` here.\n For each widget, write one plain line first, such as \"I'm adding Inbox to\n your dashboard; approve the card if you want it.\", then call\n `await env.TOURTOIS.layout.get({})` and\n `await env.TOURTOIS.layout.place({ ... })` with its `surfaceId`, `gillId`,\n a size the widget lists, `scope` \"member\" and `basedOn` the revision\n `layout.get` returned. The call makes the Hub show the person an approval\n card to Approve or Deny. The approval card is their choice: wait for it.\n Denied or expired means move on: do not retry or ask again. Pass `params`\n only for the keys the widget lists, with values you know, and pass every\n key the widget lists as required in `params`, for example\n `params: { computer: <id> }`. Never call `layout.place` without them: a\n call missing one is rejected after the person has approved it. When a\n required parameter is a Computer and the Team has exactly one, use the id\n from your instructions:\n `params: { computer: <the id from your instructions> }`. Skip a widget\n whose required Computer you cannot fill because the Team has none, or more\n than one. Skip a widget only when a required parameter has no value you can\n fill. Never ask a yes or no question before `layout.place`: if a widget\n needs something the person must do first, say so in one line and skip that\n widget. Never place one without that approval, and never add one for a\n person who denied. If `env.TOURTOIS` is missing or a call fails, skip 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";
|
|
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 and the completed name and widget offers.\n\nSetup is one flow: approved work → useful result → name card → widget approval →\nfinish. After the work or a name answer, continue with the next tool call in the\nsame turn. A progress summary is commentary, never the end of setup. End only\nafter step 5 is complete, or while a card is parked awaiting its answer; when\nthat answer arrives, resume at the next unfinished item.\n\n## Start and resume\n\nOn resume, continue at the first unfinished step. A name answer goes straight to\nstep 5's rename/Keep handling, before file discovery or goal calls. The\ndiscovery and arming below happen once, at the start of setup.\n\nFirst list Home's working folder with its `list` tool (`{path: \".\"}`), or your\nattached Computer's `files.list({path: \".\"})`. Read `AGENTS.md` only if that\nlisting contains it, using `path: \"AGENTS.md\"`. Use that same relative path for\nedits; the working folder is not the filesystem root. If the file is absent,\ncontinue the interview and check again in step 3.\n\nBefore approved work, arm the existing Session goal so an accidental end of turn\nresumes this checklist without a nudge. Describe `goal`, read\n`env.goal.get_goal({})`, and, only when no goal is current, call\n`env.goal.create_goal({objective: \"Finish setting up for you, including your first useful result, a name card and widget approvals.\"})`.\nKeep an existing goal; never replace or complete someone else's objective for\nsetup. Save this goal's objective in setup progress so resumed turns reuse it.\nIf goal tools are absent, continue the checklist directly.\n\nA parked question or approval is a real wait; the goal runtime waits with it.\nAfter the useful result, use a declarative transition such as \"Your image is\nready.\" and make the name-card tool call in step 5 in this same turn. Put the\nentire name question and its options inside that card. A goal continuation\nrepairs an interrupted checklist; it never turns a plain-text name question into\na valid offer. On continuation, use step 5's resume check and call the missing\ncard directly or continue after its answer. Complete the setup goal only after\nstep 5's offers and cleanup have finished; keep it active while any required\noffer is pending.\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 cards in total, counting the \"Do it?\" plan and the name offer. A\n card is one `question.ask`; keep each short and specific, and batch a few\n questions into one card. Use options, the recommended one first. Free text is\n always allowed, and an option that lets them type their own answer is fine. Do\n not ask for the person's own name; their account already has it.\n- Every decision is a `question.ask` card, including \"Do it?\". Never end a turn\n asking the person to reply with options in text.\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- A build, install or test that fails or times out never ends setup: say what\n failed in one line, carry on, and still make every offer in step 5. A command\n result of `unknown` means it may still be running, so check again before\n calling it failed.\n- Media budget: at most ONE sample attempt across images and videos for the\n entire setup, including resumed turns. Make it only when the catalog/quote\n shows it is cheap and the approved plan includes it; otherwise save a useful\n prompt or brief as the first result. A failed, denied or expired generation\n spends that attempt. Never retry, switch models, or try the other medium. Say\n the cause once in plain words, then continue to the name and widget steps.\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 1 follow-up card: what they want Fungi\n for; whether there is a project (repo, folder, site, docs); anything that\n repeats (daily, weekly). Done when you can state their goal in a 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. List the working folder again with `files.list({path: \".\"})`.\n When `AGENTS.md` is listed, read and edit `path: \"AGENTS.md\"` in place;\n when it is not there yet, your Computer is still finishing its first start:\n carry on with the other items, come back to it before step 4, and if it is\n still missing create it with the same headings. Fill its \"About my person\"\n section (rename it \"About <their name>\") with their goal, the preferences\n they stated and how they want updates. Follow its \"Keeping this file up to\n date\" section from then on. Every line answers \"would I get this wrong\n without it?\". Then introduce instructions in one sentence: \"I saved this in\n my instructions, so I'll remember it in every conversation. You can read or\n edit them from my menu → Instructions.\"\n - Files you create for them: write several in one `files.patch` of Add File\n blocks rather than one write each, so they approve once. Write files with\n `files.patch` or `files.write`, never shell heredocs inside `execute`,\n whose quoting breaks.\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.\n - Prints: apply the Media budget above before calling\n `PRINTS.generateImage` or `PRINTS.generateVideo`. Record the attempt in\n Home's setup progress before calling, so a resumed turn cannot repeat it.\n Mark a keeper with `PRINTS.setFavorite` on its saved path and read them\n back with `PRINTS.listFavorites`. The library folder is chosen by the\n person in Prints, and no method lets you choose it, so do not search for\n one: if Prints says no library is selected, say so in one line and tell\n them to pick it in Prints.\n4. First result. Do one small real task toward their goal, now. When they can\n see its output, immediately enter step 5 in this turn. If media is\n unavailable, a saved prompt or brief is the result; the media budget still\n applies.\n5. Finish. Do every item below, in order. Do not end your turn before the name\n offer and the dashboard offer have each been asked, failed, or skipped. Even\n if part of setup is blocked, such as an App that is not ready, say so in your\n two lines and still make both offers. An answered card is final: do not ask\n it again in text.\n - Say in two lines what you set up and where to change it, then continue\n immediately to the name card tool call.\n - Resume check. Read your current name from your instructions, the answers\n and rename results already in this conversation, and Home's setup progress.\n If a name was picked (including Keep), or a rename already succeeded, the\n name is settled: skip the name card and rename call and proceed directly to\n widgets. A current name different from the starting name saved in setup\n progress also proves the rename happened. If a name card is still pending,\n wait on that same card instead of issuing a replacement. Plain text and an\n offered marker alone do not prove a card is waiting: without an actual name\n card call in this conversation, make that call now. A nudge, failure or\n interrupted turn resumes this checklist; it never restarts setup.\n - Offer a name, once (required). Never settle it yourself by saying you keep\n your name: the card is how they keep it. Before the first name card, save\n its offered status and your starting name under \"First conversation\" in\n Home `AGENTS.md`. Ask with `question.ask`: \"Keep <your name>\" first, where\n your name is the one in your instructions (\"Your name is …\"), copied\n verbatim and never guessed, then two names you suggest that fit their goal;\n free text is always allowed. In `execute`, bind `currentName` to that\n verbatim current name and choose `firstSuggestion` and `secondSuggestion`,\n then run the actual card call below. Your chat transition is a statement;\n the name question belongs inside this call:\n\n ```js\n return await env.question.ask({\n questions: [\n {\n id: \"agent_name\",\n header: \"Name\",\n question: \"Choose a name for me\",\n options: [\n {\n label: `Keep ${currentName}`,\n description: \"Keep my current name.\",\n },\n { label: firstSuggestion, description: \"Use this name.\" },\n { label: secondSuggestion, description: \"Use this name.\" },\n ],\n },\n ],\n });\n ```\n\n Ask the name only as a `question.ask` card, never in plain text. Wait for\n their pick: call `question.ask` without `mode`, never `mode: \"continue\"`,\n and make no dashboard call until they have picked. Ask it at most once in\n the whole conversation, even if you run step 5 again. Once they have\n picked, whether a new name or Keep, the name is settled: never ask it\n again, not even after an empty or interrupted turn; carry on with the\n dashboard offer. Only when they pick a new name, call\n `await env.self.rename({name})`: the moment they pick a new name, your very\n next call is `await env.self.rename({name})`, before any other step. Then\n say in one line that you are now called that. Call it directly and do not\n look it up first, since a lookup of a tool you may not see reads as absent.\n If `env.self` is missing or the call is refused, say nothing about it.\n After applying their pick, save the settled name (including Keep) in setup\n progress, then immediately call `await env.TOURTOIS.widgets.available({})`\n in this turn.\n\n - Offer \"Add to your dashboard\" (required). Call\n `await env.TOURTOIS.widgets.available({})` and pick at most 2 matching\n widgets from what you did: Grove Inbox, Inkcap Recent Files, Prints Recent\n Outputs. If no widget clearly matches what you did, offer the most\n generally useful one: Inbox first, then Recent Files. Skip the offer only\n when `widgets.available` returns nothing but the launcher. Never say there\n is no dashboard offer before you have called\n `await env.TOURTOIS.widgets.available({})`. Do not use `question.ask` here.\n For each widget, write one plain line first, such as \"I'm adding Inbox to\n your dashboard; approve the card if you want it.\", then call\n `await env.TOURTOIS.layout.get({})` and\n `await env.TOURTOIS.layout.place({ ... })` with its `surfaceId`, `gillId`,\n a size the widget lists, `scope` \"member\" and `basedOn` the revision\n `layout.get` returned. The call makes the Hub show the person an approval\n card to Approve or Deny. The approval card is their choice: wait for it.\n Denied or expired means move on: do not retry or ask again. Pass `params`\n only for the keys the widget lists, with values you know, and pass every\n key the widget lists as required in `params`, for example\n `params: { computer: <id> }`. Never call `layout.place` without them: a\n call missing one is rejected after the person has approved it. When a\n required parameter is a Computer and the Team has exactly one, use the id\n from your instructions:\n `params: { computer: <the id from your instructions> }`. Skip a widget\n whose required Computer you cannot fill because the Team has none, or more\n than one. Skip a widget only when a required parameter has no value you can\n fill. Never ask a yes or no question before `layout.place`: if a widget\n needs something the person must do first, say so in one line and skip that\n widget. Never place one without that approval, and never add one for a\n person who denied. If `env.TOURTOIS` is missing or a call fails, skip 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 in your final `execute`. If you\n created the setup goal, that same invocation must first await\n `env.goal.update_goal({status: \"complete\", reason: \"Useful result delivered; name and widget offers settled; setup progress cleaned up.\"})`,\n then await `env.setup.finish({})`. Keep the two calls together so the\n hand-off cannot leave the setup goal unfinished. Leave any other current\n goal alone.\n - When the `setup.finish` tool is absent, finish after the offers and cleanup\n above are complete. If you created the setup goal, your final tool call is\n `await env.goal.update_goal({status: \"complete\", reason: \"Useful result delivered; name and widget offers settled; setup progress cleaned up.\"})`.\n Leave any other current goal alone. That host has no money step; say\n nothing about Pro or wallets. Its absence never skips the name card or\n widget approval.\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 cards in total, counting the "Do it?" plan and the name offer. A\n card is one `question.ask`; keep each short and specific, and batch a few\n questions into one card. Use options, the recommended one first. Free text is\n always allowed, and an option that lets them type their own answer is fine. Do\n not ask for the person\'s own name; their account already has it.\n- Every decision is a `question.ask` card, including "Do it?". Never end a turn\n asking the person to reply with options in text.\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- A build, install or test that fails or times out never ends setup: say what\n failed in one line, carry on, and still make every offer in step 5. A command\n result of `unknown` means it may still be running, so check again before\n calling it failed.\n- When an action fails and says it is not retryable, such as a generation, try\n at most once more with clearly different input (another model, say), never the\n same action again. Then say so in one line, carry on, and finish setup.\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 1 follow-up card: what they want Fungi\n for; whether there is a project (repo, folder, site, docs); anything that\n repeats (daily, weekly). Done when you can state their goal in a 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. First list your Computer\'s top folder, never read `AGENTS.md`\n blind. When it is listed, edit it in place; when it is not there yet, your\n Computer is still finishing its first start: carry on with the other items,\n come back to it before step 4, and if it is still missing create it with\n the same headings. Fill its "About my person" section (rename it "About\n <their name>") with their goal, the preferences they stated and how they\n want updates. Follow its "Keeping this file up to date" section from then\n on. Every line answers "would I get this wrong without it?". Then introduce\n instructions in one sentence: "I saved this in my instructions, so I\'ll\n remember it in every conversation. You can read or edit them from my menu →\n Instructions."\n - Files you create for them: write several in one `files.patch` of Add File\n blocks rather than one write each, so they approve once. Write files with\n `files.patch` or `files.write`, never shell heredocs inside `execute`,\n whose quoting breaks.\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.\n - Prints: describe `PRINTS.generateImage` or `PRINTS.generateVideo`, then\n call it; mark a keeper with `PRINTS.setFavorite` on its saved path and\n read them back with `PRINTS.listFavorites`. The library folder is chosen\n by the person in Prints, and no method lets you choose it, so do not\n search for one: if Prints says no library is selected, say so in one line\n and tell them to pick it in Prints.\n4. First result. Do one small real task toward their goal, now. Done when they\n can see its output.\n5. Finish. Do every item below, in order. Do not end your turn before the name\n offer and the dashboard offer have each been asked, failed, or skipped. Even\n if part of setup is blocked, such as an App that is not ready, say so in your\n two lines and still make both offers. An answered card is final: do not ask\n it again in text.\n - Say in two lines what you set up and where to change it.\n - Offer a name, once (required). Never settle it yourself by saying you keep\n your name: the card is how they keep it. Ask with `question.ask`: "Keep\n <your name>" first, where your name is the one in your instructions ("Your\n name is …"), copied verbatim and never guessed, then two names you suggest\n that fit their goal; free text is always allowed. Ask the name only as a\n `question.ask` card, never in plain text. Wait for their pick: call\n `question.ask` without `mode`, never `mode: "continue"`, and make no\n dashboard call until they have picked. Ask it at most once in the whole\n conversation, even if you run step 5 again. Once they have picked, whether\n a new name or Keep, the name is settled: never ask it again, not even after\n an empty or interrupted turn; carry on with the dashboard offer. Only when\n they pick a new name, call `await env.self.rename({name})`: the moment they\n pick a new name, your very next call is `await env.self.rename({name})`,\n before any other step. Then say in one line that you are now called that.\n Call it directly and do not look it up first, since a lookup of a tool you\n may not see reads as absent. If `env.self` is missing or the call is\n refused, say nothing about it.\n - Offer "Add to your dashboard" (required). Call\n `await env.TOURTOIS.widgets.available({})` and pick at most 2 matching\n widgets from what you did: Grove Inbox, Inkcap Recent Files, Prints Recent\n Outputs. If no widget clearly matches what you did, offer the most\n generally useful one: Inbox first, then Recent Files. Skip the offer only\n when `widgets.available` returns nothing but the launcher. Never say there\n is no dashboard offer before you have called\n `await env.TOURTOIS.widgets.available({})`. Do not use `question.ask` here.\n For each widget, write one plain line first, such as "I\'m adding Inbox to\n your dashboard; approve the card if you want it.", then call\n `await env.TOURTOIS.layout.get({})` and\n `await env.TOURTOIS.layout.place({ ... })` with its `surfaceId`, `gillId`,\n a size the widget lists, `scope` "member" and `basedOn` the revision\n `layout.get` returned. The call makes the Hub show the person an approval\n card to Approve or Deny. The approval card is their choice: wait for it.\n Denied or expired means move on: do not retry or ask again. Pass `params`\n only for the keys the widget lists, with values you know, and pass every\n key the widget lists as required in `params`, for example\n `params: { computer: <id> }`. Never call `layout.place` without them: a\n call missing one is rejected after the person has approved it. When a\n required parameter is a Computer and the Team has exactly one, use the id\n from your instructions:\n `params: { computer: <the id from your instructions> }`. Skip a widget\n whose required Computer you cannot fill because the Team has none, or more\n than one. Skip a widget only when a required parameter has no value you can\n fill. Never ask a yes or no question before `layout.place`: if a widget\n needs something the person must do first, say so in one line and skip that\n widget. Never place one without that approval, and never add one for a\n person who denied. If `env.TOURTOIS` is missing or a call fails, skip 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',
|
|
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 and the completed name and widget offers.\n\nSetup is one flow: approved work → useful result → name card → widget approval →\nfinish. After the work or a name answer, continue with the next tool call in the\nsame turn. A progress summary is commentary, never the end of setup. End only\nafter step 5 is complete, or while a card is parked awaiting its answer; when\nthat answer arrives, resume at the next unfinished item.\n\n## Start and resume\n\nOn resume, continue at the first unfinished step. A name answer goes straight to\nstep 5\'s rename/Keep handling, before file discovery or goal calls. The\ndiscovery and arming below happen once, at the start of setup.\n\nFirst list Home\'s working folder with its `list` tool (`{path: "."}`), or your\nattached Computer\'s `files.list({path: "."})`. Read `AGENTS.md` only if that\nlisting contains it, using `path: "AGENTS.md"`. Use that same relative path for\nedits; the working folder is not the filesystem root. If the file is absent,\ncontinue the interview and check again in step 3.\n\nBefore approved work, arm the existing Session goal so an accidental end of turn\nresumes this checklist without a nudge. Describe `goal`, read\n`env.goal.get_goal({})`, and, only when no goal is current, call\n`env.goal.create_goal({objective: "Finish setting up for you, including your first useful result, a name card and widget approvals."})`.\nKeep an existing goal; never replace or complete someone else\'s objective for\nsetup. Save this goal\'s objective in setup progress so resumed turns reuse it.\nIf goal tools are absent, continue the checklist directly.\n\nA parked question or approval is a real wait; the goal runtime waits with it.\nAfter the useful result, use a declarative transition such as "Your image is\nready." and make the name-card tool call in step 5 in this same turn. Put the\nentire name question and its options inside that card. A goal continuation\nrepairs an interrupted checklist; it never turns a plain-text name question into\na valid offer. On continuation, use step 5\'s resume check and call the missing\ncard directly or continue after its answer. Complete the setup goal only after\nstep 5\'s offers and cleanup have finished; keep it active while any required\noffer is pending.\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 cards in total, counting the "Do it?" plan and the name offer. A\n card is one `question.ask`; keep each short and specific, and batch a few\n questions into one card. Use options, the recommended one first. Free text is\n always allowed, and an option that lets them type their own answer is fine. Do\n not ask for the person\'s own name; their account already has it.\n- Every decision is a `question.ask` card, including "Do it?". Never end a turn\n asking the person to reply with options in text.\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- A build, install or test that fails or times out never ends setup: say what\n failed in one line, carry on, and still make every offer in step 5. A command\n result of `unknown` means it may still be running, so check again before\n calling it failed.\n- Media budget: at most ONE sample attempt across images and videos for the\n entire setup, including resumed turns. Make it only when the catalog/quote\n shows it is cheap and the approved plan includes it; otherwise save a useful\n prompt or brief as the first result. A failed, denied or expired generation\n spends that attempt. Never retry, switch models, or try the other medium. Say\n the cause once in plain words, then continue to the name and widget steps.\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 1 follow-up card: what they want Fungi\n for; whether there is a project (repo, folder, site, docs); anything that\n repeats (daily, weekly). Done when you can state their goal in a 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. List the working folder again with `files.list({path: "."})`.\n When `AGENTS.md` is listed, read and edit `path: "AGENTS.md"` in place;\n when it is not there yet, your Computer is still finishing its first start:\n carry on with the other items, come back to it before step 4, and if it is\n still missing create it with the same headings. Fill its "About my person"\n section (rename it "About <their name>") with their goal, the preferences\n they stated and how they want updates. Follow its "Keeping this file up to\n date" section from then on. Every line answers "would I get this wrong\n without it?". Then introduce instructions in one sentence: "I saved this in\n my instructions, so I\'ll remember it in every conversation. You can read or\n edit them from my menu → Instructions."\n - Files you create for them: write several in one `files.patch` of Add File\n blocks rather than one write each, so they approve once. Write files with\n `files.patch` or `files.write`, never shell heredocs inside `execute`,\n whose quoting breaks.\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.\n - Prints: apply the Media budget above before calling\n `PRINTS.generateImage` or `PRINTS.generateVideo`. Record the attempt in\n Home\'s setup progress before calling, so a resumed turn cannot repeat it.\n Mark a keeper with `PRINTS.setFavorite` on its saved path and read them\n back with `PRINTS.listFavorites`. The library folder is chosen by the\n person in Prints, and no method lets you choose it, so do not search for\n one: if Prints says no library is selected, say so in one line and tell\n them to pick it in Prints.\n4. First result. Do one small real task toward their goal, now. When they can\n see its output, immediately enter step 5 in this turn. If media is\n unavailable, a saved prompt or brief is the result; the media budget still\n applies.\n5. Finish. Do every item below, in order. Do not end your turn before the name\n offer and the dashboard offer have each been asked, failed, or skipped. Even\n if part of setup is blocked, such as an App that is not ready, say so in your\n two lines and still make both offers. An answered card is final: do not ask\n it again in text.\n - Say in two lines what you set up and where to change it, then continue\n immediately to the name card tool call.\n - Resume check. Read your current name from your instructions, the answers\n and rename results already in this conversation, and Home\'s setup progress.\n If a name was picked (including Keep), or a rename already succeeded, the\n name is settled: skip the name card and rename call and proceed directly to\n widgets. A current name different from the starting name saved in setup\n progress also proves the rename happened. If a name card is still pending,\n wait on that same card instead of issuing a replacement. Plain text and an\n offered marker alone do not prove a card is waiting: without an actual name\n card call in this conversation, make that call now. A nudge, failure or\n interrupted turn resumes this checklist; it never restarts setup.\n - Offer a name, once (required). Never settle it yourself by saying you keep\n your name: the card is how they keep it. Before the first name card, save\n its offered status and your starting name under "First conversation" in\n Home `AGENTS.md`. Ask with `question.ask`: "Keep <your name>" first, where\n your name is the one in your instructions ("Your name is …"), copied\n verbatim and never guessed, then two names you suggest that fit their goal;\n free text is always allowed. In `execute`, bind `currentName` to that\n verbatim current name and choose `firstSuggestion` and `secondSuggestion`,\n then run the actual card call below. Your chat transition is a statement;\n the name question belongs inside this call:\n\n ```js\n return await env.question.ask({\n questions: [\n {\n id: "agent_name",\n header: "Name",\n question: "Choose a name for me",\n options: [\n {\n label: `Keep ${currentName}`,\n description: "Keep my current name.",\n },\n { label: firstSuggestion, description: "Use this name." },\n { label: secondSuggestion, description: "Use this name." },\n ],\n },\n ],\n });\n ```\n\n Ask the name only as a `question.ask` card, never in plain text. Wait for\n their pick: call `question.ask` without `mode`, never `mode: "continue"`,\n and make no dashboard call until they have picked. Ask it at most once in\n the whole conversation, even if you run step 5 again. Once they have\n picked, whether a new name or Keep, the name is settled: never ask it\n again, not even after an empty or interrupted turn; carry on with the\n dashboard offer. Only when they pick a new name, call\n `await env.self.rename({name})`: the moment they pick a new name, your very\n next call is `await env.self.rename({name})`, before any other step. Then\n say in one line that you are now called that. Call it directly and do not\n look it up first, since a lookup of a tool you may not see reads as absent.\n If `env.self` is missing or the call is refused, say nothing about it.\n After applying their pick, save the settled name (including Keep) in setup\n progress, then immediately call `await env.TOURTOIS.widgets.available({})`\n in this turn.\n\n - Offer "Add to your dashboard" (required). Call\n `await env.TOURTOIS.widgets.available({})` and pick at most 2 matching\n widgets from what you did: Grove Inbox, Inkcap Recent Files, Prints Recent\n Outputs. If no widget clearly matches what you did, offer the most\n generally useful one: Inbox first, then Recent Files. Skip the offer only\n when `widgets.available` returns nothing but the launcher. Never say there\n is no dashboard offer before you have called\n `await env.TOURTOIS.widgets.available({})`. Do not use `question.ask` here.\n For each widget, write one plain line first, such as "I\'m adding Inbox to\n your dashboard; approve the card if you want it.", then call\n `await env.TOURTOIS.layout.get({})` and\n `await env.TOURTOIS.layout.place({ ... })` with its `surfaceId`, `gillId`,\n a size the widget lists, `scope` "member" and `basedOn` the revision\n `layout.get` returned. The call makes the Hub show the person an approval\n card to Approve or Deny. The approval card is their choice: wait for it.\n Denied or expired means move on: do not retry or ask again. Pass `params`\n only for the keys the widget lists, with values you know, and pass every\n key the widget lists as required in `params`, for example\n `params: { computer: <id> }`. Never call `layout.place` without them: a\n call missing one is rejected after the person has approved it. When a\n required parameter is a Computer and the Team has exactly one, use the id\n from your instructions:\n `params: { computer: <the id from your instructions> }`. Skip a widget\n whose required Computer you cannot fill because the Team has none, or more\n than one. Skip a widget only when a required parameter has no value you can\n fill. Never ask a yes or no question before `layout.place`: if a widget\n needs something the person must do first, say so in one line and skip that\n widget. Never place one without that approval, and never add one for a\n person who denied. If `env.TOURTOIS` is missing or a call fails, skip 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 in your final `execute`. If you\n created the setup goal, that same invocation must first await\n `env.goal.update_goal({status: "complete", reason: "Useful result delivered; name and widget offers settled; setup progress cleaned up."})`,\n then await `env.setup.finish({})`. Keep the two calls together so the\n hand-off cannot leave the setup goal unfinished. Leave any other current\n goal alone.\n - When the `setup.finish` tool is absent, finish after the offers and cleanup\n above are complete. If you created the setup goal, your final tool call is\n `await env.goal.update_goal({status: "complete", reason: "Useful result delivered; name and widget offers settled; setup progress cleaned up."})`.\n Leave any other current goal alone. That host has no money step; say\n nothing about Pro or wallets. Its absence never skips the name card or\n widget approval.\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
|
];
|
|
@@ -2729,6 +2729,7 @@ export class AgentDirectory extends DurableObject {
|
|
|
2729
2729
|
let configured = {
|
|
2730
2730
|
TENANTS: this.env.TENANTS,
|
|
2731
2731
|
KEYS: this.env.KEYS,
|
|
2732
|
+
REGISTRY: this.env.REGISTRY,
|
|
2732
2733
|
OYSTER_ORIGIN: this.env.OYSTER_ORIGIN,
|
|
2733
2734
|
OYSTER_OWNER_KEY: this.env.OYSTER_OWNER_KEY,
|
|
2734
2735
|
};
|
|
@@ -82,6 +82,11 @@ export function standaloneBuildRoutes(registryFor) {
|
|
|
82
82
|
? Response.json({ error: "Not found" }, { status: 404 })
|
|
83
83
|
: Response.json({
|
|
84
84
|
...build,
|
|
85
|
+
// This is only the owner entry. It mints no content grant here;
|
|
86
|
+
// the entry verifies UI availability after same-origin owner admission.
|
|
87
|
+
previewUrl: build.status === "succeeded" && build.release !== null
|
|
88
|
+
? new URL(`/builds/${encodeURIComponent(build.jobId)}/preview`, context.req.url).href
|
|
89
|
+
: null,
|
|
85
90
|
release: build.release === null
|
|
86
91
|
? null
|
|
87
92
|
: Schema.encodeUnknownSync(releaseSchema)(build.release),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type OwnerPrincipal } from "../authorization.js";
|
|
2
|
+
import type { OysterEnv } from "../host.js";
|
|
3
|
+
import type { OysterBuildView } from "../app-builds.js";
|
|
4
|
+
import { type ArtifactStore } from "../release.js";
|
|
5
|
+
import type { TenantScope } from "../tenant.js";
|
|
6
|
+
/** S7 supplies the live refs and the base captured for this build; Oyster owns no proposal ledger. */
|
|
7
|
+
export type CandidatePreviewProposal = Readonly<{
|
|
8
|
+
headRevision: string;
|
|
9
|
+
baseRevision: string;
|
|
10
|
+
buildBaseRevision: string;
|
|
11
|
+
}>;
|
|
12
|
+
/** Read-only candidate custody; no Instance, selection, storage or build-start port. */
|
|
13
|
+
export type CandidatePreviewOptions = Readonly<{
|
|
14
|
+
scope: Pick<TenantScope, "tenantId" | "origin">;
|
|
15
|
+
secret: string;
|
|
16
|
+
owner(): Promise<OwnerPrincipal | null>;
|
|
17
|
+
readBuild(jobId: string): Promise<OysterBuildView | null>;
|
|
18
|
+
artifacts: ArtifactStore;
|
|
19
|
+
/** Absent/null for manual builds. S7 can join proposal refs without changing readBuild. */
|
|
20
|
+
readProposal?(build: OysterBuildView): Promise<CandidatePreviewProposal | null>;
|
|
21
|
+
}>;
|
|
22
|
+
/** Owner arrival and the private, zero-grant UI of an unselected build. */
|
|
23
|
+
export declare function standaloneCandidatePreview(options: CandidatePreviewOptions): {
|
|
24
|
+
routes: import("../authorization.js").Routes<OysterEnv>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { SignJWT, errors, jwtVerify } from "jose";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { door, owner, publicRoute, routes, } from "../authorization.js";
|
|
4
|
+
import { readPreviewUi } from "../boot-gate.js";
|
|
5
|
+
import { bootAssetUrl, bootHostScript, bootParentDocument, candidateAssetUrls, parentSecurityHeaders, } from "../boot-mount.js";
|
|
6
|
+
import { readCachedVerified, ReleaseError, } from "../release.js";
|
|
7
|
+
import { renderHostPage, renderPreviewStyles } from "../host-page-lazy.js";
|
|
8
|
+
// Human candidates must never inherit installed Apps' escaping popups or forms.
|
|
9
|
+
const candidateSandbox = "allow-scripts";
|
|
10
|
+
const issuer = "oyster.candidate-preview";
|
|
11
|
+
const purpose = "oyster/candidate-preview/v1";
|
|
12
|
+
const lifetimeSeconds = 5 * 60;
|
|
13
|
+
const claimsSchema = z.object({
|
|
14
|
+
tenantId: z.string().min(1).max(40),
|
|
15
|
+
ownerId: z.string().min(1).max(256),
|
|
16
|
+
origin: z.url(),
|
|
17
|
+
jobId: z.string().min(1).max(256),
|
|
18
|
+
appId: z.string().min(1).max(256),
|
|
19
|
+
releaseId: z.string().min(1).max(256),
|
|
20
|
+
digest: z.string().regex(/^sha256:[a-f0-9]{64}$/u),
|
|
21
|
+
sourceRevision: z.string().regex(/^git:[a-f0-9]{40}$/u),
|
|
22
|
+
});
|
|
23
|
+
const privateHeaders = {
|
|
24
|
+
"cache-control": "private, no-store",
|
|
25
|
+
"referrer-policy": "no-referrer",
|
|
26
|
+
"x-content-type-options": "nosniff",
|
|
27
|
+
"cross-origin-opener-policy": "same-origin",
|
|
28
|
+
};
|
|
29
|
+
const unavailable = (status = 404, message = "Candidate preview unavailable") => new Response(message, { status, headers: privateHeaders });
|
|
30
|
+
function candidateHeaders(prefix) {
|
|
31
|
+
return {
|
|
32
|
+
...privateHeaders,
|
|
33
|
+
"content-security-policy": `default-src 'none'; sandbox ${candidateSandbox}; script-src 'unsafe-inline' ${prefix}; style-src 'unsafe-inline' ${prefix}; img-src data: blob: ${prefix}; font-src data: ${prefix}; connect-src ${prefix}; worker-src 'none'; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Owner arrival and the private, zero-grant UI of an unselected build. */
|
|
37
|
+
export function standaloneCandidatePreview(options) {
|
|
38
|
+
const table = routes();
|
|
39
|
+
const path = "/builds/:jobId/preview";
|
|
40
|
+
const signingKey = () => crypto.subtle
|
|
41
|
+
.importKey("raw", new TextEncoder().encode(options.secret), "HKDF", false, ["deriveKey"])
|
|
42
|
+
.then((key) => crypto.subtle.deriveKey({
|
|
43
|
+
name: "HKDF",
|
|
44
|
+
hash: "SHA-256",
|
|
45
|
+
salt: new Uint8Array(),
|
|
46
|
+
info: new TextEncoder().encode(purpose),
|
|
47
|
+
}, key, { name: "HMAC", hash: "SHA-256", length: 256 }, false, ["sign", "verify"]));
|
|
48
|
+
const audience = `${purpose}:${options.scope.origin}`;
|
|
49
|
+
const readCustody = async (jobId, ownerId) => {
|
|
50
|
+
if ((await options.owner())?.actor.memberId !== ownerId)
|
|
51
|
+
return null;
|
|
52
|
+
const build = await options.readBuild(jobId);
|
|
53
|
+
if (build?.status !== "succeeded" ||
|
|
54
|
+
build.appId !== build.release?.appId ||
|
|
55
|
+
build.releaseId !== build.release.releaseId ||
|
|
56
|
+
build.sourceRevision !== build.release.artifact.provenance.sourceRevision)
|
|
57
|
+
return null;
|
|
58
|
+
return { build, release: build.release };
|
|
59
|
+
};
|
|
60
|
+
const candidate = async (jobId, ownerId) => {
|
|
61
|
+
const custody = await readCustody(jobId, ownerId);
|
|
62
|
+
if (custody === null)
|
|
63
|
+
return null;
|
|
64
|
+
const preview = await readPreviewUi(options.artifacts, custody.release);
|
|
65
|
+
return preview.ui === null
|
|
66
|
+
? null
|
|
67
|
+
: { ...custody, ui: preview.ui, appName: preview.appName };
|
|
68
|
+
};
|
|
69
|
+
const stillCurrent = async (claims) => {
|
|
70
|
+
const current = await readCustody(claims.jobId, claims.ownerId);
|
|
71
|
+
return (current !== null &&
|
|
72
|
+
current.build.appId === claims.appId &&
|
|
73
|
+
current.build.releaseId === claims.releaseId &&
|
|
74
|
+
current.release.artifact.artifactDigest === claims.digest &&
|
|
75
|
+
current.build.sourceRevision === claims.sourceRevision);
|
|
76
|
+
};
|
|
77
|
+
const landing = async (action, appName) => {
|
|
78
|
+
const response = await renderHostPage({
|
|
79
|
+
state: "preview",
|
|
80
|
+
preview: { action, appName, preparing: appName === undefined },
|
|
81
|
+
inlineStyles: await renderPreviewStyles(),
|
|
82
|
+
});
|
|
83
|
+
const headers = new Headers(response.headers);
|
|
84
|
+
for (const [name, value] of Object.entries(privateHeaders))
|
|
85
|
+
headers.set(name, value);
|
|
86
|
+
headers.set("content-security-policy", "default-src 'none'; style-src 'unsafe-inline'; font-src data:; img-src data:; script-src 'unsafe-inline'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'");
|
|
87
|
+
return new Response(response.body, { status: response.status, headers });
|
|
88
|
+
};
|
|
89
|
+
table.get(path, publicRoute("styled arrival without candidate metadata"), (context) => landing(context.req.path));
|
|
90
|
+
table.post(path, owner("direct"), async (context, { principal }) => {
|
|
91
|
+
const requestOrigin = context.req.header("Origin");
|
|
92
|
+
if (new URL(context.req.url).origin !== options.scope.origin ||
|
|
93
|
+
(context.req.header("Sec-Fetch-Site") !== "same-origin" &&
|
|
94
|
+
requestOrigin !== options.scope.origin))
|
|
95
|
+
return unavailable(403, "Same-origin owner request required");
|
|
96
|
+
try {
|
|
97
|
+
let preparing = false;
|
|
98
|
+
if (context.req.raw.body !== null) {
|
|
99
|
+
const fields = await context.req.raw
|
|
100
|
+
.formData()
|
|
101
|
+
.catch((cause) => {
|
|
102
|
+
if (cause instanceof TypeError)
|
|
103
|
+
return null;
|
|
104
|
+
throw cause;
|
|
105
|
+
});
|
|
106
|
+
if (fields === null)
|
|
107
|
+
return unavailable(403, "Could not open this preview. Reload to try again.");
|
|
108
|
+
preparing = fields.get("intent") === "prepare";
|
|
109
|
+
}
|
|
110
|
+
const current = await candidate(context.req.param("jobId"), principal.actor.memberId);
|
|
111
|
+
if (current === null)
|
|
112
|
+
return unavailable();
|
|
113
|
+
const { build, release, ui, appName } = current;
|
|
114
|
+
const claims = claimsSchema.parse({
|
|
115
|
+
tenantId: options.scope.tenantId,
|
|
116
|
+
ownerId: principal.actor.memberId,
|
|
117
|
+
origin: options.scope.origin,
|
|
118
|
+
jobId: build.jobId,
|
|
119
|
+
appId: build.appId,
|
|
120
|
+
releaseId: build.releaseId,
|
|
121
|
+
digest: release.artifact.artifactDigest,
|
|
122
|
+
sourceRevision: build.sourceRevision,
|
|
123
|
+
});
|
|
124
|
+
if (preparing) {
|
|
125
|
+
if (!(await stillCurrent(claims)))
|
|
126
|
+
return unavailable();
|
|
127
|
+
return await landing(context.req.path, appName);
|
|
128
|
+
}
|
|
129
|
+
const proposal = await options.readProposal?.(build);
|
|
130
|
+
if (!(await stillCurrent(claims)))
|
|
131
|
+
return unavailable();
|
|
132
|
+
const now = Math.floor(Date.now() / 1000);
|
|
133
|
+
const grant = await new SignJWT(claims)
|
|
134
|
+
.setProtectedHeader({ alg: "HS256", typ: "JWT" })
|
|
135
|
+
.setIssuer(issuer)
|
|
136
|
+
.setAudience(audience)
|
|
137
|
+
.setSubject(claims.ownerId)
|
|
138
|
+
.setIssuedAt(now)
|
|
139
|
+
.setExpirationTime(now + lifetimeSeconds)
|
|
140
|
+
.sign(await signingKey());
|
|
141
|
+
const root = new URL(`/private-builds/${encodeURIComponent(grant)}/`, options.scope.origin);
|
|
142
|
+
const prefix = new URL("candidate/", root).href;
|
|
143
|
+
candidateAssetUrls(ui, prefix);
|
|
144
|
+
const identity = {
|
|
145
|
+
...ui.identity,
|
|
146
|
+
surfaceId: `preview:${build.releaseId}`,
|
|
147
|
+
};
|
|
148
|
+
const freshness = proposal === undefined || proposal === null
|
|
149
|
+
? "This build was not checked against the latest proposal."
|
|
150
|
+
: proposal.headRevision !== build.sourceRevision ||
|
|
151
|
+
proposal.baseRevision !== proposal.buildBaseRevision
|
|
152
|
+
? "The proposal changed after this build. Open a new preview before merging."
|
|
153
|
+
: "The proposal matched when this preview opened. Check it again in Bonsai before merging.";
|
|
154
|
+
const notice = {
|
|
155
|
+
appName,
|
|
156
|
+
revision: build.sourceRevision.slice(4, 11),
|
|
157
|
+
status: proposal === undefined || proposal === null
|
|
158
|
+
? "not checked"
|
|
159
|
+
: proposal.headRevision !== build.sourceRevision ||
|
|
160
|
+
proposal.baseRevision !== proposal.buildBaseRevision
|
|
161
|
+
? "changed"
|
|
162
|
+
: "checked",
|
|
163
|
+
explanation: freshness,
|
|
164
|
+
expiresAt: (now + lifetimeSeconds) * 1000,
|
|
165
|
+
entry: context.req.path,
|
|
166
|
+
};
|
|
167
|
+
return new Response(await bootParentDocument(identity, bootAssetUrl(prefix, ui.base, "/index.html"), {
|
|
168
|
+
bridge: new URL("bridge.js", root).href,
|
|
169
|
+
sandbox: candidateSandbox,
|
|
170
|
+
notice,
|
|
171
|
+
}), {
|
|
172
|
+
headers: {
|
|
173
|
+
...parentSecurityHeaders(prefix),
|
|
174
|
+
...privateHeaders,
|
|
175
|
+
"content-security-policy": `${parentSecurityHeaders(prefix)["content-security-policy"]}; font-src data:; frame-ancestors 'none'`,
|
|
176
|
+
"content-type": "text/html; charset=utf-8",
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
catch (cause) {
|
|
181
|
+
if (cause instanceof ReleaseError)
|
|
182
|
+
return unavailable();
|
|
183
|
+
throw cause;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
table.get("/private-builds/:grant/*", door("purpose-bound candidate grant, current owner and immutable build custody"), async (context) => {
|
|
187
|
+
const url = new URL(context.req.url);
|
|
188
|
+
if (url.origin !== options.scope.origin || url.search !== "")
|
|
189
|
+
return unavailable();
|
|
190
|
+
const grant = context.req.param("grant");
|
|
191
|
+
if (grant.length > 4096)
|
|
192
|
+
return unavailable();
|
|
193
|
+
let verified;
|
|
194
|
+
try {
|
|
195
|
+
verified = await jwtVerify(grant, await signingKey(), {
|
|
196
|
+
issuer,
|
|
197
|
+
audience,
|
|
198
|
+
algorithms: ["HS256"],
|
|
199
|
+
typ: "JWT",
|
|
200
|
+
maxTokenAge: lifetimeSeconds,
|
|
201
|
+
requiredClaims: ["exp", "iat", "sub"],
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
catch (cause) {
|
|
205
|
+
if (cause instanceof errors.JWTExpired)
|
|
206
|
+
return unavailable(404, "This preview expired. Reload to open it again.");
|
|
207
|
+
if (cause instanceof errors.JOSEError)
|
|
208
|
+
return unavailable();
|
|
209
|
+
throw cause;
|
|
210
|
+
}
|
|
211
|
+
const parsed = claimsSchema.safeParse(verified.payload);
|
|
212
|
+
if (!parsed.success || verified.payload.exp === undefined)
|
|
213
|
+
return unavailable();
|
|
214
|
+
const expiresAt = verified.payload.exp * 1000;
|
|
215
|
+
const claims = parsed.data;
|
|
216
|
+
if (claims.origin !== options.scope.origin ||
|
|
217
|
+
claims.tenantId !== options.scope.tenantId ||
|
|
218
|
+
verified.payload.sub !== claims.ownerId)
|
|
219
|
+
return unavailable();
|
|
220
|
+
try {
|
|
221
|
+
const current = await candidate(claims.jobId, claims.ownerId);
|
|
222
|
+
if (current?.build.appId !== claims.appId ||
|
|
223
|
+
current.build.releaseId !== claims.releaseId ||
|
|
224
|
+
current.release.artifact.artifactDigest !== claims.digest ||
|
|
225
|
+
current.build.sourceRevision !== claims.sourceRevision)
|
|
226
|
+
return unavailable();
|
|
227
|
+
const root = new URL(`/private-builds/${encodeURIComponent(grant)}/`, options.scope.origin);
|
|
228
|
+
const prefix = new URL("candidate/", root).href;
|
|
229
|
+
if (!(await stillCurrent(claims)) || Date.now() >= expiresAt)
|
|
230
|
+
return unavailable();
|
|
231
|
+
if (url.pathname === new URL("bridge.js", root).pathname)
|
|
232
|
+
return new Response(bootHostScript, {
|
|
233
|
+
headers: {
|
|
234
|
+
...privateHeaders,
|
|
235
|
+
"content-type": "text/javascript; charset=utf-8",
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
const urls = candidateAssetUrls(current.ui, prefix);
|
|
239
|
+
const index = urls.findIndex((asset) => new URL(asset).pathname === url.pathname);
|
|
240
|
+
const asset = current.ui.assets[index];
|
|
241
|
+
if (asset === undefined)
|
|
242
|
+
return unavailable();
|
|
243
|
+
const bytes = await readCachedVerified(options.artifacts, undefined, asset.artifactRef, asset.digest);
|
|
244
|
+
// Storage I/O must not let an expired grant deliver another response.
|
|
245
|
+
if (!(await stillCurrent(claims)) || Date.now() >= expiresAt)
|
|
246
|
+
return unavailable();
|
|
247
|
+
const headers = new Headers({
|
|
248
|
+
...candidateHeaders(prefix),
|
|
249
|
+
"content-type": asset.contentType,
|
|
250
|
+
});
|
|
251
|
+
if (context.req.header("Origin") === "null") {
|
|
252
|
+
headers.set("access-control-allow-origin", "null");
|
|
253
|
+
headers.set("vary", "Origin");
|
|
254
|
+
}
|
|
255
|
+
return new Response(bytes, { headers });
|
|
256
|
+
}
|
|
257
|
+
catch (cause) {
|
|
258
|
+
if (cause instanceof ReleaseError)
|
|
259
|
+
return unavailable();
|
|
260
|
+
throw cause;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
table.all("/private-builds/*", door("refuse unsupported private candidate requests"), () => unavailable());
|
|
264
|
+
return { routes: table };
|
|
265
|
+
}
|
|
@@ -26,7 +26,7 @@ export declare class StandaloneTenants extends TenancyRegistryDO {
|
|
|
26
26
|
seed(input: StandaloneSeed): Promise<Tenant | StandaloneSeedRefusal>;
|
|
27
27
|
}
|
|
28
28
|
/** The same trusted bindings are used by HTTP, MCP and cold root readers. */
|
|
29
|
-
export type StandaloneTenancyEnv = Pick<OysterGitWorkerEnv, "OYSTER_ORIGIN" | "OYSTER_OWNER_NAME" | "OYSTER_OWNER_KEY" | "KEYS"> & Readonly<{
|
|
29
|
+
export type StandaloneTenancyEnv = Pick<OysterGitWorkerEnv, "OYSTER_ORIGIN" | "OYSTER_OWNER_NAME" | "OYSTER_OWNER_KEY" | "KEYS" | "REGISTRY"> & Readonly<{
|
|
30
30
|
TENANTS: DurableObjectNamespace<StandaloneTenants>;
|
|
31
31
|
/** Opt-in Cloudflare Access sign-in: the team domain, with the AUD tag. */
|
|
32
32
|
OYSTER_ACCESS_TEAM_DOMAIN?: string;
|
|
@@ -5,6 +5,7 @@ import { ownerKey } from "../tenancy/owner-key.js";
|
|
|
5
5
|
import { loopbackAliasLocation } from "../tenancy/registry-record.js";
|
|
6
6
|
import { hosts } from "../tenancy/resolve.js";
|
|
7
7
|
import { ownerOrKeyAuth } from "../auth.js";
|
|
8
|
+
import { registryOwnerSessions } from "../workers.js";
|
|
8
9
|
import { HTTPException } from "hono/http-exception";
|
|
9
10
|
import { defaultTenant, tenantScope, } from "../tenant.js";
|
|
10
11
|
import * as Schema from "effect/Schema";
|
|
@@ -182,8 +183,10 @@ async function composeTenancy(env) {
|
|
|
182
183
|
const admitted = (admission) => {
|
|
183
184
|
const view = admittedRegistry(admission);
|
|
184
185
|
const owner = ownerOf(admission);
|
|
186
|
+
const sessions = registryOwnerSessions(() => env.REGISTRY.getByName(scope.durableName("registry")));
|
|
185
187
|
const ownerAuth = ownerKey({
|
|
186
188
|
registry: view,
|
|
189
|
+
sessions: () => sessions,
|
|
187
190
|
keys: {
|
|
188
191
|
get: () => Promise.resolve(owner === null
|
|
189
192
|
? null
|
|
@@ -242,7 +245,7 @@ async function composeTenancy(env) {
|
|
|
242
245
|
if (owner === null)
|
|
243
246
|
return { kind: "refused", status: 403 };
|
|
244
247
|
const keys = () => env.KEYS.getByName(scope.durableName("keys"));
|
|
245
|
-
const auth = ownerOrKeyAuth(env.OYSTER_OWNER_KEY, owner.actor.memberId, keys);
|
|
248
|
+
const auth = ownerOrKeyAuth(env.OYSTER_OWNER_KEY, owner.actor.memberId, sessions, keys);
|
|
246
249
|
const admission = await auth.authenticate(request);
|
|
247
250
|
// This entry admits only named keys; the owner key has its own entry.
|
|
248
251
|
return admission.kind === "admitted" &&
|
|
@@ -260,6 +263,9 @@ async function composeTenancy(env) {
|
|
|
260
263
|
login: async (request) => routes === undefined
|
|
261
264
|
? new Response("Sign-in is not available", { status: 404 })
|
|
262
265
|
: await routes.fetch(request),
|
|
266
|
+
logout: async (request) => routes === undefined
|
|
267
|
+
? new Response("Sign-out is not available", { status: 404 })
|
|
268
|
+
: await routes.fetch(request),
|
|
263
269
|
};
|
|
264
270
|
};
|
|
265
271
|
/**
|
|
@@ -337,6 +343,8 @@ async function composeTenancy(env) {
|
|
|
337
343
|
},
|
|
338
344
|
login: async (incoming) => (await (await forRequest(incoming))?.login(incoming)) ??
|
|
339
345
|
new Response("Not found", { status: 404 }),
|
|
346
|
+
logout: async (incoming) => (await (await forRequest(incoming))?.logout(incoming)) ??
|
|
347
|
+
new Response("Not found", { status: 404 }),
|
|
340
348
|
},
|
|
341
349
|
};
|
|
342
350
|
},
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
import { createOysterGitWorker, createOysterGitMcpOwner, oysterGitRoot, } from "../workers-git.js";
|
|
7
7
|
import { defaultTenant, tenantScope } from "../tenant.js";
|
|
8
8
|
import { oysterPrincipalIsOwner } from "../authorization.js";
|
|
9
|
+
import { r2ArtifactStore } from "../workers.js";
|
|
10
|
+
import { standaloneCandidatePreview } from "./candidate-preview.js";
|
|
9
11
|
import { standaloneComputerControl } from "./computer-control.js";
|
|
10
12
|
import { standalonePermissionResources } from "./permission-resources.js";
|
|
11
13
|
import { onBoxVmIngress, ownerLocalBackendDialPath, } from "@fungi.computer/computer";
|
|
@@ -20,7 +22,7 @@ import { StandaloneInstance as ComputerInstance } from "./instance.js";
|
|
|
20
22
|
// Every guest binding in every frame is this one entrypoint, routed by props.
|
|
21
23
|
export { OysterBinding } from "./instance.js";
|
|
22
24
|
import { StandaloneWorkflowRunsBase, } from "./workflows.js";
|
|
23
|
-
import { standaloneTenancyForRequest, StandaloneSeedConfigurationChanged, } from "./tenancy.js";
|
|
25
|
+
import { standaloneTenancyForRequest, standaloneTenancy, StandaloneSeedConfigurationChanged, } from "./tenancy.js";
|
|
24
26
|
export { StandaloneTenants } from "./tenancy.js";
|
|
25
27
|
import { standalonePreviewRequest, standalonePortEntryRoutes, } from "./preview.js";
|
|
26
28
|
import { standaloneMachineLinkRoutes, } from "./machine-link.js";
|
|
@@ -120,7 +122,15 @@ const standaloneRoot = (selectComputer) => {
|
|
|
120
122
|
};
|
|
121
123
|
},
|
|
122
124
|
// Operator source seeding and owner builds share the one owner guard.
|
|
123
|
-
ownerRoutes: (env, scope) => standaloneOwnerRoutes(env, scope, () => root.hostFor(env, scope))
|
|
125
|
+
ownerRoutes: (env, scope) => standaloneOwnerRoutes(env, scope, () => root.hostFor(env, scope))
|
|
126
|
+
.include(standaloneCandidatePreview({
|
|
127
|
+
scope,
|
|
128
|
+
secret: env.OYSTER_OWNER_KEY,
|
|
129
|
+
owner: async () => (await standaloneTenancy(env)).owner(),
|
|
130
|
+
readBuild: (jobId) => tenantRegistry(env, scope).readBuild(jobId),
|
|
131
|
+
artifacts: r2ArtifactStore(env.RELEASES),
|
|
132
|
+
}).routes)
|
|
133
|
+
.include(standalonePortEntryRoutes({
|
|
124
134
|
ownsComputer: (id) => tenantRegistry(env, scope).ownsComputer(id),
|
|
125
135
|
issue: (id, ownerId, port) => env.COMPUTER.getByName(id).issuePortConnect(ownerId, port),
|
|
126
136
|
})),
|
package/dist/starter-agent.js
CHANGED
|
@@ -17,13 +17,16 @@ const starterHomeInstructions = `# Shiitake's instructions
|
|
|
17
17
|
|
|
18
18
|
These are my standing instructions. They live on my Computer at
|
|
19
19
|
AGENTS.md and load at the start of every conversation. Read or patch
|
|
20
|
-
it with that plain path
|
|
20
|
+
it with that plain path after listing \`files.list({path: "."})\` and
|
|
21
|
+
confirming it is present. My person and I both edit this file.
|
|
21
22
|
|
|
22
23
|
## First conversation
|
|
23
24
|
My person is new to Fungi. In our first conversation, load the \`setup-fungi\`
|
|
24
25
|
skill with \`return await skill.load({name: "setup-fungi"});\` inside execute
|
|
25
26
|
and follow it. If they ask for something specific first, do that, then set up.
|
|
26
|
-
|
|
27
|
+
Continue approved work → useful result → name card → widget approval in one
|
|
28
|
+
flow, resuming after each answer; a work summary does not finish setup. Keep
|
|
29
|
+
setup progress here until the offers are settled, then delete this section.
|
|
27
30
|
|
|
28
31
|
## About my person
|
|
29
32
|
(Empty until setup. Fill in: their name, what they want from Fungi, their
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OwnerSessions } from "../owner-sessions.js";
|
|
1
2
|
import type { TenantId } from "../tenant.js";
|
|
2
3
|
import type { AuthAdapter, ReadonlyTenantRegistry, ReadonlyTenancy } from "./contracts.js";
|
|
3
4
|
/** Stored owner verification material for one selected tenant. */
|
|
@@ -16,7 +17,9 @@ export type OwnerKeyOptions = Readonly<{
|
|
|
16
17
|
/** Current verification material, or null when no owner key is configured. */
|
|
17
18
|
get(tenantId: TenantId): Promise<OwnerKeyRecord | null>;
|
|
18
19
|
}>;
|
|
19
|
-
/**
|
|
20
|
+
/** Host-owned owner browser sessions for one tenant; the cookie names one of these. */
|
|
21
|
+
sessions(tenantId: TenantId): OwnerSessions;
|
|
22
|
+
/** Optional relative POST /login and POST /logout routes, explicitly mounted by the host. */
|
|
20
23
|
login?: Readonly<{
|
|
21
24
|
/** Resolve the tenant through the kit, not from form/body data. */
|
|
22
25
|
resolveTenant: ReadonlyTenancy["resolve"];
|
|
@@ -19,7 +19,17 @@ export function ownerKey(options) {
|
|
|
19
19
|
const record = await options.keys.get(tenant.id);
|
|
20
20
|
if (record === null)
|
|
21
21
|
return context.json({ error: "unauthorized" }, 401);
|
|
22
|
-
|
|
22
|
+
// The session is stored only once the signed-in member is still the
|
|
23
|
+
// tenant's owner, so a refused sign-in leaves no session behind.
|
|
24
|
+
const sessions = options.sessions(tenant.id);
|
|
25
|
+
const opened = [];
|
|
26
|
+
const helper = ownerKeyAuth(record.key, record.memberId, {
|
|
27
|
+
...sessions,
|
|
28
|
+
open: (...session) => {
|
|
29
|
+
opened.push(session);
|
|
30
|
+
return Promise.resolve();
|
|
31
|
+
},
|
|
32
|
+
});
|
|
23
33
|
if (helper.login === undefined)
|
|
24
34
|
throw new Error("Oyster owner authentication has no login handler");
|
|
25
35
|
const response = await helper.login(context.req.raw);
|
|
@@ -27,9 +37,24 @@ export function ownerKey(options) {
|
|
|
27
37
|
return response;
|
|
28
38
|
if (!(await currentOwner(tenant, record.memberId)))
|
|
29
39
|
return context.json({ error: "forbidden" }, 403);
|
|
40
|
+
for (const session of opened)
|
|
41
|
+
await sessions.open(...session);
|
|
30
42
|
response.headers.set("Cache-Control", "no-store");
|
|
31
43
|
return response;
|
|
32
44
|
});
|
|
45
|
+
if (login !== undefined)
|
|
46
|
+
routes.post("/logout", async (context) => {
|
|
47
|
+
const tenant = await login.resolveTenant(context.req.raw);
|
|
48
|
+
if (tenant === null)
|
|
49
|
+
return context.json({ error: "not_found" }, 404);
|
|
50
|
+
const record = await options.keys.get(tenant.id);
|
|
51
|
+
if (record === null)
|
|
52
|
+
return context.json({ error: "unauthorized" }, 401);
|
|
53
|
+
const helper = ownerKeyAuth(record.key, record.memberId, options.sessions(tenant.id));
|
|
54
|
+
if (helper.logout === undefined)
|
|
55
|
+
throw new Error("Oyster owner authentication has no logout handler");
|
|
56
|
+
return await helper.logout(context.req.raw);
|
|
57
|
+
});
|
|
33
58
|
const adapter = {
|
|
34
59
|
id: "owner-key",
|
|
35
60
|
async authenticate(request, tenant) {
|
|
@@ -45,7 +70,7 @@ export function ownerKey(options) {
|
|
|
45
70
|
return recognizedCookie
|
|
46
71
|
? { kind: "refused", status: 401 }
|
|
47
72
|
: { kind: "pass" };
|
|
48
|
-
const result = await ownerKeyAuth(record.key, record.memberId).authenticate(request);
|
|
73
|
+
const result = await ownerKeyAuth(record.key, record.memberId, options.sessions(tenant.id)).authenticate(request);
|
|
49
74
|
if (result.kind === "refused")
|
|
50
75
|
return recognizedCookie
|
|
51
76
|
? { kind: "refused", status: 401 }
|