@fungi.computer/oyster 0.31.2 → 0.33.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.
Files changed (63) hide show
  1. package/README.md +59 -0
  2. package/dist/agent-computer-source.d.ts +1 -0
  3. package/dist/agent-computer-source.js +1 -0
  4. package/dist/app-test-copies.d.ts +87 -0
  5. package/dist/app-test-copies.js +170 -0
  6. package/dist/app-test-copy-page.d.ts +4 -0
  7. package/dist/app-test-copy-page.js +89 -0
  8. package/dist/apps/installation.js +19 -14
  9. package/dist/browser/operations.d.ts +1 -1
  10. package/dist/cloudflare.d.ts +68 -3
  11. package/dist/cloudflare.js +214 -3
  12. package/dist/embed-metafiles.js +2 -2
  13. package/dist/embed-scripts.js +2 -2
  14. package/dist/host.d.ts +16 -0
  15. package/dist/host.js +309 -1
  16. package/dist/installation-operations.d.ts +247 -8
  17. package/dist/installation-operations.js +145 -7
  18. package/dist/installation-recovery-page.d.ts +24 -0
  19. package/dist/installation-recovery-page.js +168 -0
  20. package/dist/older-oyster-store.d.ts +1 -1
  21. package/dist/older-oyster-store.js +2 -4
  22. package/dist/page/mount.d.ts +2 -101
  23. package/dist/page/mount.js +1 -22
  24. package/dist/page-config.d.ts +102 -0
  25. package/dist/page-config.js +24 -0
  26. package/dist/page-script.js +1 -1
  27. package/dist/platform-skills.generated.d.ts +11 -0
  28. package/dist/platform-skills.generated.js +16 -0
  29. package/dist/recovery-style.d.ts +5 -0
  30. package/dist/recovery-style.js +32 -0
  31. package/dist/standalone/agents.d.ts +1 -1
  32. package/dist/standalone/agents.js +1 -0
  33. package/dist/standalone/computer-skill-source.d.ts +13 -2
  34. package/dist/standalone/computer-skill-source.js +80 -6
  35. package/dist/standalone/workflow-host.d.ts +4 -4
  36. package/dist/standalone/workflows.d.ts +9 -9
  37. package/dist/storage-frame.d.ts +3 -3
  38. package/dist/upgrade/old-worker-http.d.ts +2 -0
  39. package/dist/upgrade/old-worker-http.js +22 -0
  40. package/dist/upgrade/old-worker-readonly.d.ts +14 -0
  41. package/dist/upgrade/old-worker-readonly.js +22 -0
  42. package/dist/upgrade/old-worker-sql.d.ts +10 -0
  43. package/dist/upgrade/old-worker-sql.js +68 -0
  44. package/dist/upgrade/old-worker-stream.d.ts +12 -0
  45. package/dist/upgrade/old-worker-stream.js +54 -0
  46. package/dist/upgrade/private-stage.d.ts +23 -0
  47. package/dist/upgrade/private-stage.js +109 -0
  48. package/dist/upgrade/standalone-001.d.ts +16 -0
  49. package/dist/upgrade/standalone-001.js +31 -0
  50. package/dist/upgrade/standalone-01.d.ts +37 -0
  51. package/dist/upgrade/standalone-01.js +55 -0
  52. package/dist/upgrade/standalone-02.d.ts +37 -0
  53. package/dist/upgrade/standalone-02.js +55 -0
  54. package/dist/workers.d.ts +16 -2
  55. package/dist/workers.js +117 -7
  56. package/docs/api/README.md +8 -3
  57. package/docs/api/apps.md +33 -33
  58. package/docs/api/cloudflare.md +57 -0
  59. package/docs/api/host.md +223 -14
  60. package/docs/api/page/mount.md +10 -78
  61. package/docs/api/workers-git.md +246 -1
  62. package/docs/api/workers.md +352 -14
  63. package/package.json +23 -10
@@ -0,0 +1,11 @@
1
+ /** Built-in skill files, paths relative to skills/. */
2
+ export declare const platformSkillFiles: readonly [{
3
+ readonly path: "debug-fungi/REFERENCE.md";
4
+ readonly content: "# Debugging Fungi reference\n\n## Limits that explain a failure\n\n- A synchronous Computer command stops at ten minutes. An `execute` run may last\n one minute longer than that.\n- Work that must outlive ten minutes starts as a process. A process has no\n run-time bound of its own and lives within the Computer's awake window.\n- Stdout and stderr are each kept to 64 KiB. A longer stream is cut and marked.\n\n## A refused call\n\nA refused call returns a value with `refused: true` and a `reason`. It is a\ntyped value, not an error.\n\n## A result that says `pending_approval`\n\nFor an App's generation call, `pending_approval` does not confirm that anything\nwas generated. Wait for the result to be delivered in the ordinary way. Do not\nretry the approval to fetch the output.\n\n## No Home\n\nHome is your default Computer. When none is selected, or the selected Computer\nis detached, only a person can choose one, with `/home <name>`. There is no\nfallback Computer.\n";
5
+ }, {
6
+ readonly path: "debug-fungi/SKILL.md";
7
+ readonly content: "---\nname: debug-fungi\ndescription:\n Diagnose a tool call that failed, was refused or returned something wrong, a\n Computer command that did not succeed, or a missing Home. Use when a call\n errors more than once, a result looks wrong, or a tool you expect is not\n there.\n---\n\n# Debug Fungi\n\nWhen a call does not work, find out why before you call it again.\n\n1. Discover first. Inside `execute`, `forage.search` finds operations by one\n short keyword, `forage.list` pages through all of them, and\n `forage.describe({ path })` shows the input of one. Describe an operation\n before you call it.\n2. Call an operation by its exact dotted path, for example\n `await env.computers.<name>.exec({ command: \"pwd\" })`. A bare path such as\n `computers.<name>.exec` is not defined.\n3. Each `execute` call starts a fresh sandbox. Nothing you defined survives to\n the next call, so redefine helpers or save state to a file.\n4. Before you treat a shell or process result as success, check `status`,\n `exitCode` and `stderr`.\n\n`REFERENCE.md` in this folder lists the limits that most often explain a\nfailure, and what a refusal, a `pending_approval` result and a missing Home\nmean.\n";
8
+ }, {
9
+ readonly path: "fungible-computing/SKILL.md";
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
+ }];
@@ -0,0 +1,16 @@
1
+ // Generated by scripts/platform-skills.mjs from skills/. Do not edit.
2
+ /** Built-in skill files, paths relative to skills/. */
3
+ export const platformSkillFiles = [
4
+ {
5
+ path: "debug-fungi/REFERENCE.md",
6
+ content: "# Debugging Fungi reference\n\n## Limits that explain a failure\n\n- A synchronous Computer command stops at ten minutes. An `execute` run may last\n one minute longer than that.\n- Work that must outlive ten minutes starts as a process. A process has no\n run-time bound of its own and lives within the Computer's awake window.\n- Stdout and stderr are each kept to 64 KiB. A longer stream is cut and marked.\n\n## A refused call\n\nA refused call returns a value with `refused: true` and a `reason`. It is a\ntyped value, not an error.\n\n## A result that says `pending_approval`\n\nFor an App's generation call, `pending_approval` does not confirm that anything\nwas generated. Wait for the result to be delivered in the ordinary way. Do not\nretry the approval to fetch the output.\n\n## No Home\n\nHome is your default Computer. When none is selected, or the selected Computer\nis detached, only a person can choose one, with `/home <name>`. There is no\nfallback Computer.\n",
7
+ },
8
+ {
9
+ path: "debug-fungi/SKILL.md",
10
+ content: '---\nname: debug-fungi\ndescription:\n Diagnose a tool call that failed, was refused or returned something wrong, a\n Computer command that did not succeed, or a missing Home. Use when a call\n errors more than once, a result looks wrong, or a tool you expect is not\n there.\n---\n\n# Debug Fungi\n\nWhen a call does not work, find out why before you call it again.\n\n1. Discover first. Inside `execute`, `forage.search` finds operations by one\n short keyword, `forage.list` pages through all of them, and\n `forage.describe({ path })` shows the input of one. Describe an operation\n before you call it.\n2. Call an operation by its exact dotted path, for example\n `await env.computers.<name>.exec({ command: "pwd" })`. A bare path such as\n `computers.<name>.exec` is not defined.\n3. Each `execute` call starts a fresh sandbox. Nothing you defined survives to\n the next call, so redefine helpers or save state to a file.\n4. Before you treat a shell or process result as success, check `status`,\n `exitCode` and `stderr`.\n\n`REFERENCE.md` in this folder lists the limits that most often explain a\nfailure, and what a refusal, a `pending_approval` result and a missing Home\nmean.\n',
11
+ },
12
+ {
13
+ path: "fungible-computing/SKILL.md",
14
+ 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",
15
+ },
16
+ ];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The recovery pages load no asset, so their styling travels inline. They stay
3
+ * readable in light and dark when the selected App or Shell cannot load.
4
+ */
5
+ export declare const recoveryStyle: import("hono/utils/html").HtmlEscapedString;
@@ -0,0 +1,32 @@
1
+ import { raw } from "hono/html";
2
+ /**
3
+ * The recovery pages load no asset, so their styling travels inline. They stay
4
+ * readable in light and dark when the selected App or Shell cannot load.
5
+ */
6
+ export const recoveryStyle = raw(`<style>
7
+ :root{color-scheme:light dark;--bg:#faf8f4;--card:#fff;--ink:#2a2622;--muted:#6f675e;--line:#e4ded4;--accent:#1f6f54;--accent-ink:#fff;--warn:#8a5a00}
8
+ @media (prefers-color-scheme:dark){:root{--bg:#171512;--card:#211e1a;--ink:#f0ebe3;--muted:#a39a8e;--line:#3a352e;--accent:#58c29b;--accent-ink:#0f1a15;--warn:#e0b04a}}
9
+ *{box-sizing:border-box}
10
+ body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif}
11
+ main{max-width:44rem;margin:0 auto;padding:2rem 1rem 3rem}
12
+ h1{font-size:1.5rem;margin:0 0 .5rem}
13
+ h2{font-size:1.1rem;margin:0 0 .5rem;overflow-wrap:anywhere}
14
+ p{margin:.35rem 0}
15
+ .lede,.muted{color:var(--muted)}
16
+ .card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:1rem 1.25rem;margin:1rem 0}
17
+ .row{display:flex;flex-wrap:wrap;gap:.5rem 1rem;align-items:center;margin-top:.75rem}
18
+ dl{margin:.5rem 0;display:grid;grid-template-columns:max-content 1fr;gap:.2rem 1rem}
19
+ dt{color:var(--muted)}dd{margin:0;overflow-wrap:anywhere}
20
+ button{font:inherit;font-weight:600;cursor:pointer;border-radius:8px;padding:.5rem 1rem;border:1px solid var(--line);background:transparent;color:var(--ink)}
21
+ button.primary,a.button{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
22
+ button:focus-visible,a:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
23
+ a{color:var(--accent)}
24
+ a.button{display:inline-block;font-weight:600;border-radius:8px;padding:.5rem 1rem;border:1px solid var(--line);text-decoration:none}
25
+ a.button.primary{color:var(--accent-ink)}
26
+ small{font-size:.8rem;margin-left:.4rem}
27
+ .status{display:inline-block;border:1px solid var(--line);border-radius:999px;padding:0 .6rem;font-size:.9rem}
28
+ .warn{color:var(--warn)}
29
+ form{margin:0}
30
+ header.bar{padding:.75rem 1rem;border-bottom:1px solid var(--line);background:var(--card)}
31
+ header.bar p{margin:.25rem 0}
32
+ </style>`);
@@ -613,7 +613,7 @@ export declare const agentFrameMethods: {
613
613
  readonly kind: "workflow-review";
614
614
  readonly installationId: string;
615
615
  readonly workflowId: string | null;
616
- readonly state: "pending" | "delivered" | "answered" | "timed_out" | "closed";
616
+ readonly state: "pending" | "closed" | "delivered" | "answered" | "timed_out";
617
617
  readonly workflowTitle: string;
618
618
  readonly reviewTitle: string;
619
619
  readonly reviewers: "owners" | "runner";
@@ -1279,6 +1279,7 @@ export class StandaloneAgentBase extends ShiitakeDO {
1279
1279
  // Skills the owner put on the Agent's Computer, found by the rules Local uses on a disk.
1280
1280
  const extensions = oysterAgentExtensions(conversationAgents.source(this.controlDirectory()), {
1281
1281
  source: createComputerSkillSource({
1282
+ platform: ["debug-fungi", "fungible-computing"],
1282
1283
  computers: async () => {
1283
1284
  await this.preparedComputerSnapshot();
1284
1285
  return readAgentComputerConnections(this.computerConnections()).map(({ name, files }) => ({ name, port: files.port }));
@@ -1,5 +1,6 @@
1
1
  import type { FilesPort } from "@fungi.computer/knapsack";
2
2
  import type { SkillSource } from "@fungi.computer/shiitake-extensions/skills/source";
3
+ import { platformSkillFiles } from "../platform-skills.generated.js";
3
4
  /**
4
5
  * Skills on an Agent's own Computer. Discovery follows the same rules Local
5
6
  * applies on a disk (frontmatter, naming, bounds, first name wins): this
@@ -11,10 +12,20 @@ export type SkillComputer = Readonly<{
11
12
  name: string;
12
13
  port: FilesPort;
13
14
  }>;
15
+ /** The built-in skills this build bundles, by folder name. */
16
+ export type PlatformSkillName = (typeof platformSkillFiles)[number]["path"] extends infer Path ? Path extends `${infer Name}/${string}` ? Name : never : never;
14
17
  /** What a person is told when no skill is installed on the Computer. */
15
18
  export declare const computerSkillsEmpty = "No skills are installed; put one at .agents/skills/<name>/SKILL.md on the Computer.";
16
19
  /** Discover and load the skills on the Agent's attached Computers. */
17
20
  export declare function createComputerSkillSource(options: Readonly<{
18
- /** The Computers the Agent may use now; read at each discovery. */
19
- computers: () => Promise<readonly SkillComputer[]>;
21
+ /**
22
+ * The Computers this Session's run may use now; read at each discovery. A
23
+ * host that refuses a Session its Computers answers with none.
24
+ */
25
+ computers: (sessionId: string) => Promise<readonly SkillComputer[]>;
26
+ /**
27
+ * Built-in skills this host offers, after the Computers' own: a Computer
28
+ * skill of the same name wins and discovery records the collision.
29
+ */
30
+ platform: readonly PlatformSkillName[];
20
31
  }>): SkillSource;
@@ -1,5 +1,6 @@
1
1
  import { admitSkill, maximumDirectoryEntries, maximumFileBytes, newSkillAdmission, parseSkill, skillCatalogOf, skillDiagnostic, skillExplanation, skillFileSchema, SkillSourceError, } from "@fungi.computer/shiitake-extensions/skills/discovery";
2
2
  import { defineIdFamily } from "@fungi.computer/cairn/id";
3
+ import { platformSkillFiles } from "../platform-skills.generated.js";
3
4
  import { z } from "zod";
4
5
  /** Each Files call this source makes is its own invocation. */
5
6
  const skillIds = defineIdFamily({
@@ -7,6 +8,8 @@ const skillIds = defineIdFamily({
7
8
  version: 1,
8
9
  kinds: { execution: { prefix: "skill_exec" } },
9
10
  });
11
+ /** Built-in skills have no Computer path; this prefix says so. */
12
+ const builtInDirectory = (name) => `built-in: ${name}`;
10
13
  /** Where the Computer keeps skills, searched in this order; the first name wins. */
11
14
  const skillRoots = [".fungi/skills", ".agents/skills"];
12
15
  /** What a person is told when no skill is installed on the Computer. */
@@ -75,10 +78,49 @@ async function findSkillFiles(port, root, signal, diagnostics) {
75
78
  }
76
79
  return files.sort();
77
80
  }
81
+ /** One bundled file's text, or a plain refusal. */
82
+ function bundled(path) {
83
+ const file = platformSkillFiles.find((candidate) => candidate.path === path);
84
+ if (file === undefined)
85
+ throw new SkillSourceError("Built-in skill file does not exist");
86
+ return file.content;
87
+ }
88
+ /** A built-in skill's body or one supporting file, read from the bundle. */
89
+ function readPlatform(name, folder, file) {
90
+ const selected = file ?? "SKILL.md";
91
+ const content = bundled(`${folder}/${selected}`);
92
+ const prefix = `${folder}/`;
93
+ const supportingFiles = selected === "SKILL.md"
94
+ ? platformSkillFiles
95
+ .map((candidate) => candidate.path)
96
+ .filter((path) => path.startsWith(prefix) && path !== `${prefix}SKILL.md`)
97
+ .map((path) => path.slice(prefix.length))
98
+ .sort()
99
+ : [];
100
+ if (selected === "SKILL.md") {
101
+ const parsed = parseSkill(content, folder);
102
+ if (parsed.metadata["disable-model-invocation"])
103
+ throw new Error(`Hidden skill: ${name}`);
104
+ return {
105
+ name,
106
+ file: selected,
107
+ content: parsed.body,
108
+ baseDirectory: builtInDirectory(folder),
109
+ supportingFiles,
110
+ };
111
+ }
112
+ return {
113
+ name,
114
+ file: selected,
115
+ content,
116
+ baseDirectory: builtInDirectory(folder),
117
+ supportingFiles,
118
+ };
119
+ }
78
120
  /** Discover and load the skills on the Agent's attached Computers. */
79
121
  export function createComputerSkillSource(options) {
80
- const scan = async (signal) => {
81
- const computers = await options.computers();
122
+ const scan = async (sessionId, signal) => {
123
+ const computers = await options.computers(sessionId);
82
124
  const several = computers.length > 1;
83
125
  const state = newSkillAdmission();
84
126
  const homes = new Map();
@@ -101,7 +143,11 @@ export function createComputerSkillSource(options) {
101
143
  origin: { kind: "project" },
102
144
  });
103
145
  if (state.skills.length > before)
104
- homes.set(metadata.name, { computer, location: path });
146
+ homes.set(metadata.name, {
147
+ kind: "computer",
148
+ computer,
149
+ location: path,
150
+ });
105
151
  }
106
152
  catch (cause) {
107
153
  signal.throwIfAborted();
@@ -115,19 +161,47 @@ export function createComputerSkillSource(options) {
115
161
  }
116
162
  }
117
163
  }
164
+ for (const name of options.platform) {
165
+ const path = `${name}/SKILL.md`;
166
+ const skillPath = `${builtInDirectory(name)}/SKILL.md`;
167
+ try {
168
+ const { metadata } = parseSkill(bundled(path), name);
169
+ const before = state.skills.length;
170
+ admitSkill(state, {
171
+ metadata,
172
+ directoryName: name,
173
+ skillPath,
174
+ location: skillPath,
175
+ displayLocation: skillPath,
176
+ origin: { kind: "platform" },
177
+ });
178
+ if (state.skills.length > before)
179
+ homes.set(metadata.name, { kind: "platform", folder: name });
180
+ }
181
+ catch (cause) {
182
+ state.diagnostics.push({
183
+ path: skillPath,
184
+ reason: "invalid",
185
+ message: skillExplanation(cause, "Skill metadata or file is invalid"),
186
+ cause,
187
+ });
188
+ }
189
+ }
118
190
  if (state.skills.length === 0 && state.diagnostics.length === 0)
119
191
  state.diagnostics.push(skillDiagnostic(".agents/skills", "empty", "No skill folders on the Computer"));
120
192
  return { catalog: skillCatalogOf(state), homes };
121
193
  };
122
194
  return {
123
- catalog: async (signal) => (await scan(signal)).catalog,
124
- read: async (name, file, signal) => {
195
+ catalog: async ({ sessionId, signal }) => (await scan(sessionId, signal)).catalog,
196
+ read: async ({ sessionId, name, file, signal }) => {
125
197
  nameLength.parse(name);
126
- const { catalog, homes } = await scan(signal);
198
+ const { catalog, homes } = await scan(sessionId, signal);
127
199
  const home = homes.get(name);
128
200
  const found = catalog.skills.find((skill) => skill.name === name);
129
201
  if (home === undefined || found === undefined)
130
202
  throw new Error(`Unknown or hidden skill: ${name}`);
203
+ if (home.kind === "platform")
204
+ return readPlatform(name, home.folder, file === undefined ? undefined : skillFileSchema.parse(file));
131
205
  const baseDirectory = directoryOf(home.location);
132
206
  const selected = file === undefined ? "SKILL.md" : skillFileSchema.parse(file);
133
207
  const content = await readWhole(home.computer.port, `${baseDirectory}/${selected}`, signal);
@@ -588,8 +588,8 @@ export declare function createStandaloneWorkflowHost(owner: WatchdogSqliteOwner,
588
588
  readonly values: {
589
589
  readonly [x: string]: import("@fungi.computer/braid").Mapping;
590
590
  };
591
- readonly id: string;
592
591
  readonly kind: "app";
592
+ readonly id: string;
593
593
  readonly method: string;
594
594
  readonly app: string;
595
595
  readonly methodDigest: string;
@@ -606,8 +606,8 @@ export declare function createStandaloneWorkflowHost(owner: WatchdogSqliteOwner,
606
606
  access: "read";
607
607
  } | undefined;
608
608
  } | {
609
- readonly id: string;
610
609
  readonly kind: "review";
610
+ readonly id: string;
611
611
  readonly title: string;
612
612
  readonly timeout: number;
613
613
  readonly reviewers: "owners" | "runner";
@@ -685,8 +685,8 @@ export declare function createStandaloneWorkflowHost(owner: WatchdogSqliteOwner,
685
685
  readonly values: {
686
686
  readonly [x: string]: import("@fungi.computer/braid").Mapping;
687
687
  };
688
- readonly id: string;
689
688
  readonly kind: "app";
689
+ readonly id: string;
690
690
  readonly method: string;
691
691
  readonly app: string;
692
692
  readonly methodDigest: string;
@@ -703,8 +703,8 @@ export declare function createStandaloneWorkflowHost(owner: WatchdogSqliteOwner,
703
703
  access: "read";
704
704
  } | undefined;
705
705
  } | {
706
- readonly id: string;
707
706
  readonly kind: "review";
707
+ readonly id: string;
708
708
  readonly title: string;
709
709
  readonly timeout: number;
710
710
  readonly reviewers: "owners" | "runner";
@@ -321,8 +321,8 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
321
321
  readonly values: {
322
322
  readonly [x: string]: import("@fungi.computer/braid").Mapping;
323
323
  };
324
- readonly id: string;
325
324
  readonly kind: "app";
325
+ readonly id: string;
326
326
  readonly method: string;
327
327
  readonly app: string;
328
328
  readonly methodDigest: string;
@@ -339,8 +339,8 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
339
339
  access: "read";
340
340
  } | undefined;
341
341
  } | {
342
- readonly id: string;
343
342
  readonly kind: "review";
343
+ readonly id: string;
344
344
  readonly title: string;
345
345
  readonly timeout: number;
346
346
  readonly reviewers: "owners" | "runner";
@@ -418,8 +418,8 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
418
418
  readonly values: {
419
419
  readonly [x: string]: import("@fungi.computer/braid").Mapping;
420
420
  };
421
- readonly id: string;
422
421
  readonly kind: "app";
422
+ readonly id: string;
423
423
  readonly method: string;
424
424
  readonly app: string;
425
425
  readonly methodDigest: string;
@@ -436,8 +436,8 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
436
436
  access: "read";
437
437
  } | undefined;
438
438
  } | {
439
- readonly id: string;
440
439
  readonly kind: "review";
440
+ readonly id: string;
441
441
  readonly title: string;
442
442
  readonly timeout: number;
443
443
  readonly reviewers: "owners" | "runner";
@@ -607,7 +607,7 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
607
607
  readonly title: string;
608
608
  readonly status?: {
609
609
  readonly label: string;
610
- readonly tone: "success" | "error" | "neutral" | "primary" | "secondary" | "accent" | "info" | "warning";
610
+ readonly tone: "success" | "error" | "warning" | "neutral" | "primary" | "secondary" | "accent" | "info";
611
611
  } | undefined;
612
612
  readonly media?: {
613
613
  readonly path: string;
@@ -655,7 +655,7 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
655
655
  events: readonly {
656
656
  readonly runId: string;
657
657
  readonly nodeId: string;
658
- readonly state: "failed" | "running" | "complete" | "skipped" | "queued" | "waiting";
658
+ readonly state: "skipped" | "failed" | "running" | "complete" | "queued" | "waiting";
659
659
  readonly iteration: string;
660
660
  readonly attempt: number;
661
661
  readonly output?: {
@@ -673,7 +673,7 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
673
673
  readonly title: string;
674
674
  readonly status?: {
675
675
  readonly label: string;
676
- readonly tone: "success" | "error" | "neutral" | "primary" | "secondary" | "accent" | "info" | "warning";
676
+ readonly tone: "success" | "error" | "warning" | "neutral" | "primary" | "secondary" | "accent" | "info";
677
677
  } | undefined;
678
678
  readonly media?: {
679
679
  readonly path: string;
@@ -746,7 +746,7 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
746
746
  events: readonly {
747
747
  readonly runId: string;
748
748
  readonly nodeId: string;
749
- readonly state: "failed" | "running" | "complete" | "skipped" | "queued" | "waiting";
749
+ readonly state: "skipped" | "failed" | "running" | "complete" | "queued" | "waiting";
750
750
  readonly iteration: string;
751
751
  readonly attempt: number;
752
752
  readonly output?: {
@@ -764,7 +764,7 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
764
764
  readonly title: string;
765
765
  readonly status?: {
766
766
  readonly label: string;
767
- readonly tone: "success" | "error" | "neutral" | "primary" | "secondary" | "accent" | "info" | "warning";
767
+ readonly tone: "success" | "error" | "warning" | "neutral" | "primary" | "secondary" | "accent" | "info";
768
768
  } | undefined;
769
769
  readonly media?: {
770
770
  readonly path: string;
@@ -21,7 +21,7 @@ export declare const storageFrameMethods: {
21
21
  };
22
22
  } | {
23
23
  readonly kind: "rejected";
24
- readonly code: "unavailable" | "invalid" | "conflict" | "undeclared_key" | "scope_not_declared" | "owner_required" | "too_large" | "quota_exceeded";
24
+ readonly code: "invalid" | "unavailable" | "conflict" | "undeclared_key" | "scope_not_declared" | "owner_required" | "too_large" | "quota_exceeded";
25
25
  };
26
26
  requiredOperations: () => string[];
27
27
  };
@@ -39,7 +39,7 @@ export declare const storageFrameMethods: {
39
39
  };
40
40
  } | {
41
41
  readonly kind: "rejected";
42
- readonly code: "unavailable" | "invalid" | "conflict" | "undeclared_key" | "scope_not_declared" | "owner_required" | "too_large" | "quota_exceeded";
42
+ readonly code: "invalid" | "unavailable" | "conflict" | "undeclared_key" | "scope_not_declared" | "owner_required" | "too_large" | "quota_exceeded";
43
43
  };
44
44
  requiredOperations: () => string[];
45
45
  };
@@ -56,7 +56,7 @@ export declare const storageFrameMethods: {
56
56
  };
57
57
  } | {
58
58
  readonly kind: "rejected";
59
- readonly code: "unavailable" | "invalid" | "conflict" | "undeclared_key" | "scope_not_declared" | "owner_required" | "too_large" | "quota_exceeded";
59
+ readonly code: "invalid" | "unavailable" | "conflict" | "undeclared_key" | "scope_not_declared" | "owner_required" | "too_large" | "quota_exceeded";
60
60
  };
61
61
  requiredOperations: () => string[];
62
62
  };
@@ -0,0 +1,2 @@
1
+ /** Export-only ingress: every request except owner GET is refused here. */
2
+ export declare function oldRegistrySqlRequest(request: Request, ownerKey: string, exportRegistry: () => Promise<Response>): Promise<Response>;
@@ -0,0 +1,22 @@
1
+ import { ownerKeyAuth } from "../auth.js";
2
+ import { OysterArchivingError } from "./old-worker-readonly.js";
3
+ const path = "/__upgrade/registry-sql";
4
+ const noStore = { "Cache-Control": "no-store" };
5
+ function archivingResponse() {
6
+ const refusal = new OysterArchivingError();
7
+ return Response.json({ error: refusal.code, message: refusal.message }, { status: 503, headers: noStore });
8
+ }
9
+ /** Export-only ingress: every request except owner GET is refused here. */
10
+ export async function oldRegistrySqlRequest(request, ownerKey, exportRegistry) {
11
+ if (new URL(request.url).pathname !== path || request.method !== "GET")
12
+ return archivingResponse();
13
+ if (request.headers.get("Authorization")?.startsWith("Bearer ") !== true)
14
+ return new Response(null, { status: 401, headers: noStore });
15
+ const result = await ownerKeyAuth(ownerKey).authenticate(request);
16
+ if (result.kind !== "admitted" ||
17
+ result.principal.actor.kind !== "member" ||
18
+ !("role" in result.principal) ||
19
+ result.principal.role !== "owner")
20
+ return new Response(null, { status: 401, headers: noStore });
21
+ return exportRegistry();
22
+ }
@@ -0,0 +1,14 @@
1
+ import { DurableObject } from "cloudflare:workers";
2
+ /**
3
+ * Every class bound to an old DO name uses this constructor, not the published
4
+ * host constructor: the latter can create tables or start background work.
5
+ */
6
+ export declare class ReadOnlyOldOysterDO extends DurableObject {
7
+ alarm(): Promise<void>;
8
+ /** Capture the alarm as observed when this DO is read, never at construction. */
9
+ readPendingAlarm(): Promise<number | null>;
10
+ }
11
+ export declare class OysterArchivingError extends Error {
12
+ readonly code = "oyster_archiving";
13
+ constructor();
14
+ }
@@ -0,0 +1,22 @@
1
+ import { DurableObject } from "cloudflare:workers";
2
+ /**
3
+ * Every class bound to an old DO name uses this constructor, not the published
4
+ * host constructor: the latter can create tables or start background work.
5
+ */
6
+ export class ReadOnlyOldOysterDO extends DurableObject {
7
+ // Do not run old work, re-arm, delete, or write a receipt on native delivery.
8
+ alarm() {
9
+ return Promise.resolve();
10
+ }
11
+ /** Capture the alarm as observed when this DO is read, never at construction. */
12
+ readPendingAlarm() {
13
+ return this.ctx.storage.getAlarm();
14
+ }
15
+ }
16
+ export class OysterArchivingError extends Error {
17
+ code = "oyster_archiving";
18
+ constructor() {
19
+ super("Oyster is archiving");
20
+ this.name = "OysterArchivingError";
21
+ }
22
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Read SQLite through the old Durable Object's own storage API. Call inside
3
+ * that object's blockConcurrencyWhile and keep the old Worker quiescent:
4
+ * neither SQLite nor a multi-DO/R2 archive is an atomic global snapshot.
5
+ * A safety ceiling throws instead of turning an incomplete scan into a part.
6
+ */
7
+ export declare function snapshotOldSql(sql: SqlStorage): Generator<{
8
+ name: string;
9
+ bytes: Uint8Array<ArrayBufferLike>;
10
+ }, void, unknown>;
@@ -0,0 +1,68 @@
1
+ import { encode } from "@msgpack/msgpack";
2
+ import { z } from "zod";
3
+ const maxTables = 128;
4
+ const maxRows = 100_000;
5
+ const rowsPerPart = 128;
6
+ const maxPartBytes = 8 * 1024 * 1024;
7
+ const schemaRow = z.object({
8
+ type: z.string(),
9
+ name: z.string(),
10
+ tbl_name: z.string(),
11
+ sql: z.string().nullable(),
12
+ });
13
+ function packet(name, bytes) {
14
+ if (bytes.byteLength > maxPartBytes)
15
+ throw new Error("Old Worker SQL snapshot part exceeds the safety ceiling");
16
+ return { name, bytes };
17
+ }
18
+ /** A SQLite identifier from sqlite_master, quoted by the SQLite dialect. */
19
+ function tableIdentifier(name) {
20
+ return `"${name.replaceAll('"', '""')}"`;
21
+ }
22
+ /**
23
+ * Read SQLite through the old Durable Object's own storage API. Call inside
24
+ * that object's blockConcurrencyWhile and keep the old Worker quiescent:
25
+ * neither SQLite nor a multi-DO/R2 archive is an atomic global snapshot.
26
+ * A safety ceiling throws instead of turning an incomplete scan into a part.
27
+ */
28
+ export function* snapshotOldSql(sql) {
29
+ const schema = z
30
+ .array(schemaRow)
31
+ .parse(sql
32
+ .exec("SELECT type, name, tbl_name, sql FROM sqlite_master ORDER BY type, name")
33
+ .toArray());
34
+ if (schema.length > maxTables)
35
+ throw new Error("Old Worker SQL schema exceeds the safety ceiling");
36
+ yield packet("sql/schema", encode({ schema }));
37
+ let totalRows = 0;
38
+ for (const entry of schema) {
39
+ if (entry.type !== "table")
40
+ continue;
41
+ const table = tableIdentifier(entry.name);
42
+ const count = sql
43
+ .exec(`SELECT count(*) AS n FROM ${table}`)
44
+ .one().n;
45
+ if (!Number.isSafeInteger(count) ||
46
+ count < 0 ||
47
+ totalRows + count > maxRows)
48
+ throw new Error("Old Worker SQL row count exceeds the safety ceiling");
49
+ for (let offset = 0; offset < count; offset += rowsPerPart) {
50
+ const rows = sql
51
+ .exec(`SELECT * FROM ${table} LIMIT ? OFFSET ?`, rowsPerPart, offset)
52
+ .toArray()
53
+ .map((row) => Object.fromEntries(Object.entries(row).map(([column, value]) => [
54
+ column,
55
+ value instanceof ArrayBuffer ? new Uint8Array(value) : value,
56
+ ])));
57
+ if (rows.length !== Math.min(rowsPerPart, count - offset))
58
+ throw new Error("Old Worker SQL table changed during snapshot");
59
+ yield packet(`sql/${entry.name}/${String(offset)}`, encode({ table: entry.name, rows }));
60
+ }
61
+ const after = sql
62
+ .exec(`SELECT count(*) AS n FROM ${table}`)
63
+ .one().n;
64
+ if (after !== count)
65
+ throw new Error("Old Worker SQL table changed during snapshot");
66
+ totalRows += count;
67
+ }
68
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Expose the old Durable Object's own SQLite and its pending alarm observation
3
+ * as a backpressured byte stream. The alarm is read when export starts, not at
4
+ * bridge deployment: null does not prove no alarm was pending at t0.
5
+ * The Worker must require its owner key before obtaining this response. A
6
+ * normally closed stream carries a terminal inventory; an error never does.
7
+ * MessagePack's maintained multi-stream decoder owns the wire framing.
8
+ */
9
+ export declare function streamOldSql(sql: SqlStorage, alarm: Readonly<{
10
+ pendingAt: number | null;
11
+ observedAt: number;
12
+ }>): Response;
@@ -0,0 +1,54 @@
1
+ import { encode } from "@msgpack/msgpack";
2
+ import { snapshotOldSql } from "./old-worker-sql.js";
3
+ /**
4
+ * Expose the old Durable Object's own SQLite and its pending alarm observation
5
+ * as a backpressured byte stream. The alarm is read when export starts, not at
6
+ * bridge deployment: null does not prove no alarm was pending at t0.
7
+ * The Worker must require its owner key before obtaining this response. A
8
+ * normally closed stream carries a terminal inventory; an error never does.
9
+ * MessagePack's maintained multi-stream decoder owns the wire framing.
10
+ */
11
+ export function streamOldSql(sql, alarm) {
12
+ const packets = snapshotOldSql(sql);
13
+ let count = 0;
14
+ let alarmSent = false;
15
+ const body = new ReadableStream({
16
+ pull(controller) {
17
+ try {
18
+ const next = packets.next();
19
+ if (next.done) {
20
+ if (!alarmSent) {
21
+ controller.enqueue(encode({ kind: "part", name: "alarm", bytes: encode(alarm) }));
22
+ alarmSent = true;
23
+ count += 1;
24
+ }
25
+ else {
26
+ controller.enqueue(encode({ kind: "complete", partCount: count }));
27
+ controller.close();
28
+ }
29
+ }
30
+ else {
31
+ controller.enqueue(encode({
32
+ kind: "part",
33
+ name: next.value.name,
34
+ bytes: next.value.bytes,
35
+ }));
36
+ count += 1;
37
+ }
38
+ }
39
+ catch (cause) {
40
+ controller.error(cause);
41
+ }
42
+ },
43
+ cancel() {
44
+ packets.return();
45
+ },
46
+ });
47
+ return new Response(body, {
48
+ headers: {
49
+ "Content-Type": "application/msgpack",
50
+ "Cache-Control": "no-store",
51
+ "X-Content-Type-Options": "nosniff",
52
+ },
53
+ });
54
+ }