@fungi.computer/oyster 0.32.0 → 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.
- package/README.md +59 -0
- package/dist/app-test-copies.d.ts +87 -0
- package/dist/app-test-copies.js +170 -0
- package/dist/app-test-copy-page.d.ts +4 -0
- package/dist/app-test-copy-page.js +89 -0
- package/dist/browser/operations.d.ts +1 -1
- package/dist/cloudflare.d.ts +68 -3
- package/dist/cloudflare.js +214 -3
- package/dist/embed-metafiles.js +2 -2
- package/dist/host.d.ts +16 -0
- package/dist/host.js +309 -1
- package/dist/installation-operations.d.ts +247 -8
- package/dist/installation-operations.js +145 -7
- package/dist/installation-recovery-page.d.ts +24 -0
- package/dist/installation-recovery-page.js +168 -0
- package/dist/older-oyster-store.d.ts +1 -1
- package/dist/older-oyster-store.js +2 -4
- package/dist/page/mount.d.ts +2 -101
- package/dist/page/mount.js +1 -22
- package/dist/page-config.d.ts +102 -0
- package/dist/page-config.js +24 -0
- package/dist/page-script.js +1 -1
- package/dist/recovery-style.d.ts +5 -0
- package/dist/recovery-style.js +32 -0
- package/dist/standalone/agents.d.ts +1 -1
- package/dist/upgrade/old-worker-http.d.ts +2 -0
- package/dist/upgrade/old-worker-http.js +22 -0
- package/dist/upgrade/old-worker-readonly.d.ts +14 -0
- package/dist/upgrade/old-worker-readonly.js +22 -0
- package/dist/upgrade/old-worker-sql.d.ts +10 -0
- package/dist/upgrade/old-worker-sql.js +68 -0
- package/dist/upgrade/old-worker-stream.d.ts +12 -0
- package/dist/upgrade/old-worker-stream.js +54 -0
- package/dist/upgrade/private-stage.d.ts +23 -0
- package/dist/upgrade/private-stage.js +109 -0
- package/dist/upgrade/standalone-001.d.ts +16 -0
- package/dist/upgrade/standalone-001.js +31 -0
- package/dist/upgrade/standalone-01.d.ts +37 -0
- package/dist/upgrade/standalone-01.js +55 -0
- package/dist/upgrade/standalone-02.d.ts +37 -0
- package/dist/upgrade/standalone-02.js +55 -0
- package/dist/workers.d.ts +15 -1
- package/dist/workers.js +117 -7
- package/docs/api/README.md +8 -3
- package/docs/api/cloudflare.md +57 -0
- package/docs/api/host.md +223 -14
- package/docs/api/page/mount.md +10 -78
- package/docs/api/workers-git.md +246 -1
- package/docs/api/workers.md +352 -14
- package/package.json +23 -10
|
@@ -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" | "
|
|
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";
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage supplied sources in a separate, private R2 binding. Even a complete
|
|
3
|
+
* stage is unverified: there is no proven no-writes window or DO/Git inventory.
|
|
4
|
+
* The real manifest belongs to the later certification step, not this module.
|
|
5
|
+
*/
|
|
6
|
+
export declare function stageUpgradeSources(input: Readonly<{
|
|
7
|
+
releases: R2Bucket;
|
|
8
|
+
privateBucket: R2Bucket;
|
|
9
|
+
snapshots: () => AsyncIterable<Readonly<{
|
|
10
|
+
kind: "part";
|
|
11
|
+
name: string;
|
|
12
|
+
bytes: Uint8Array;
|
|
13
|
+
}> | Readonly<{
|
|
14
|
+
kind: "complete";
|
|
15
|
+
partCount: number;
|
|
16
|
+
unreachable: readonly string[];
|
|
17
|
+
}>>;
|
|
18
|
+
oldWorkerName: string;
|
|
19
|
+
oldVersion: "0.0.1" | "0.1.0" | "0.2.0";
|
|
20
|
+
}>): Promise<Readonly<{
|
|
21
|
+
stageKey: string;
|
|
22
|
+
sha256: string;
|
|
23
|
+
}>>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { nanoid } from "@fungi.computer/cairn";
|
|
2
|
+
/** Private safety ceilings; exceeding one refuses a stage rather than omitting data. */
|
|
3
|
+
const partBytes = 8 * 1024 * 1024;
|
|
4
|
+
const maxParts = 10_000;
|
|
5
|
+
async function digest(bytes) {
|
|
6
|
+
return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes)))
|
|
7
|
+
.map((byte) => byte.toString(16).padStart(2, "0"))
|
|
8
|
+
.join("");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Stage supplied sources in a separate, private R2 binding. Even a complete
|
|
12
|
+
* stage is unverified: there is no proven no-writes window or DO/Git inventory.
|
|
13
|
+
* The real manifest belongs to the later certification step, not this module.
|
|
14
|
+
*/
|
|
15
|
+
export async function stageUpgradeSources(input) {
|
|
16
|
+
if (input.releases === input.privateBucket)
|
|
17
|
+
throw new Error("The archive must have a separate private R2 binding");
|
|
18
|
+
// A retry gets a fresh namespace: an old unsealed attempt can never be
|
|
19
|
+
// completed by a later invocation.
|
|
20
|
+
const prefix = `oyster-upgrade/${nanoid()}`;
|
|
21
|
+
const parts = [];
|
|
22
|
+
const store = async (name, bytes) => {
|
|
23
|
+
if (parts.length >= maxParts || bytes.byteLength > partBytes)
|
|
24
|
+
throw new Error("Archive safety ceiling reached; nothing was certified");
|
|
25
|
+
const key = `${prefix}/part-${String(parts.length)}`;
|
|
26
|
+
if ((await input.privateBucket.put(key, bytes)) === null)
|
|
27
|
+
throw new Error("Private archive write refused");
|
|
28
|
+
const saved = await input.privateBucket.get(key);
|
|
29
|
+
if (saved === null)
|
|
30
|
+
throw new Error("Private archive readback failed");
|
|
31
|
+
const readback = await saved.arrayBuffer();
|
|
32
|
+
const sha256 = await digest(bytes);
|
|
33
|
+
if (readback.byteLength !== bytes.byteLength ||
|
|
34
|
+
(await digest(readback)) !== sha256)
|
|
35
|
+
throw new Error("Private archive checksum mismatch");
|
|
36
|
+
parts.push({ name, key, size: bytes.byteLength, sha256 });
|
|
37
|
+
};
|
|
38
|
+
let cursor;
|
|
39
|
+
let pages = 0;
|
|
40
|
+
let truncated = true;
|
|
41
|
+
while (truncated) {
|
|
42
|
+
if (++pages > maxParts)
|
|
43
|
+
throw new Error("R2 listing safety ceiling reached");
|
|
44
|
+
const page = await input.releases.list({ cursor });
|
|
45
|
+
for (const object of page.objects) {
|
|
46
|
+
if (!Number.isSafeInteger(object.size) || object.size < 0)
|
|
47
|
+
throw new Error("Invalid R2 object size");
|
|
48
|
+
for (let offset = 0; offset < object.size || offset === 0; offset += partBytes) {
|
|
49
|
+
const length = Math.min(partBytes, object.size - offset);
|
|
50
|
+
const source = await input.releases.get(object.key, length === 0 ? undefined : { range: { offset, length } });
|
|
51
|
+
if (source?.etag !== object.etag)
|
|
52
|
+
throw new Error("R2 object changed during archive");
|
|
53
|
+
const bytes = await source.arrayBuffer();
|
|
54
|
+
if (bytes.byteLength !== length)
|
|
55
|
+
throw new Error("Incomplete R2 object read");
|
|
56
|
+
await store(`R2:${object.key}:${String(offset)}`, bytes);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (page.truncated) {
|
|
60
|
+
const next = page.cursor;
|
|
61
|
+
if (next.length === 0 || next === cursor)
|
|
62
|
+
throw new Error("Incomplete R2 listing");
|
|
63
|
+
cursor = next;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
truncated = false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
let completed;
|
|
70
|
+
let snapshotCount = 0;
|
|
71
|
+
let registryPresent = false;
|
|
72
|
+
for await (const record of input.snapshots()) {
|
|
73
|
+
if (completed !== undefined)
|
|
74
|
+
throw new Error("Incomplete DO snapshot");
|
|
75
|
+
if (record.kind === "part") {
|
|
76
|
+
const bytes = record.bytes;
|
|
77
|
+
if (!(bytes instanceof Uint8Array))
|
|
78
|
+
throw new Error("Invalid DO snapshot bytes");
|
|
79
|
+
await store(`DO:${record.name}`, Uint8Array.from(bytes).buffer);
|
|
80
|
+
if (record.name === "registry" || record.name.startsWith("registry/"))
|
|
81
|
+
registryPresent = true;
|
|
82
|
+
snapshotCount += 1;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
completed = record;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const unreachable = completed?.unreachable;
|
|
89
|
+
if (unreachable === undefined || completed?.partCount !== snapshotCount)
|
|
90
|
+
throw new Error("Incomplete DO snapshot");
|
|
91
|
+
if (!registryPresent)
|
|
92
|
+
throw new Error("Old Oyster registry snapshot missing");
|
|
93
|
+
const stage = {
|
|
94
|
+
kind: "oyster-unverified-stage-v1",
|
|
95
|
+
oldWorkerName: input.oldWorkerName,
|
|
96
|
+
oldVersion: input.oldVersion,
|
|
97
|
+
parts,
|
|
98
|
+
unreachable,
|
|
99
|
+
};
|
|
100
|
+
const stageKey = `${prefix}/stage.json`;
|
|
101
|
+
const bytes = new TextEncoder().encode(JSON.stringify(stage));
|
|
102
|
+
const sha256 = await digest(Uint8Array.from(bytes).buffer);
|
|
103
|
+
if ((await input.privateBucket.put(stageKey, bytes)) === null)
|
|
104
|
+
throw new Error("Private archive stage write refused");
|
|
105
|
+
const saved = await input.privateBucket.get(stageKey);
|
|
106
|
+
if (saved === null || (await digest(await saved.arrayBuffer())) !== sha256)
|
|
107
|
+
throw new Error("Private archive stage checksum mismatch");
|
|
108
|
+
return { stageKey, sha256 };
|
|
109
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { OysterWorkerEnv } from "@fungi.computer/oyster-old-001/workers";
|
|
2
|
+
import { WorkerEntrypoint } from "cloudflare:workers";
|
|
3
|
+
import { ReadOnlyOldOysterDO } from "./old-worker-readonly.js";
|
|
4
|
+
export declare class OysterBinding extends WorkerEntrypoint {
|
|
5
|
+
}
|
|
6
|
+
export declare class OysterInstance extends ReadOnlyOldOysterDO {
|
|
7
|
+
}
|
|
8
|
+
export declare class OysterMcp extends ReadOnlyOldOysterDO {
|
|
9
|
+
}
|
|
10
|
+
export declare class OysterRegistry extends ReadOnlyOldOysterDO {
|
|
11
|
+
fetch(): Promise<Response>;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: {
|
|
14
|
+
fetch(request: Request, env: OysterWorkerEnv): Promise<Response>;
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { WorkerEntrypoint } from "cloudflare:workers";
|
|
2
|
+
import { defaultTenant, tenantScope, } from "@fungi.computer/oyster-old-001/tenant";
|
|
3
|
+
import { oldRegistrySqlRequest } from "./old-worker-http.js";
|
|
4
|
+
import { ReadOnlyOldOysterDO } from "./old-worker-readonly.js";
|
|
5
|
+
import { streamOldSql } from "./old-worker-stream.js";
|
|
6
|
+
// The packaged 0.0.1 standalone has v1 and mcp-session-owner-v1, not oyster-v1.
|
|
7
|
+
export class OysterBinding extends WorkerEntrypoint {
|
|
8
|
+
}
|
|
9
|
+
export class OysterInstance extends ReadOnlyOldOysterDO {
|
|
10
|
+
}
|
|
11
|
+
export class OysterMcp extends ReadOnlyOldOysterDO {
|
|
12
|
+
}
|
|
13
|
+
export class OysterRegistry extends ReadOnlyOldOysterDO {
|
|
14
|
+
async fetch() {
|
|
15
|
+
const pendingAt = await this.readPendingAlarm();
|
|
16
|
+
return streamOldSql(this.ctx.storage.sql, {
|
|
17
|
+
pendingAt,
|
|
18
|
+
observedAt: Date.now(),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export default {
|
|
23
|
+
fetch(request, env) {
|
|
24
|
+
return oldRegistrySqlRequest(request, env.OYSTER_OWNER_KEY, () => {
|
|
25
|
+
const scope = tenantScope(defaultTenant, env.OYSTER_ORIGIN);
|
|
26
|
+
// The release-matched bridge binds REGISTRY to the OysterRegistry
|
|
27
|
+
// subclass exported here, whose fetch streams the export.
|
|
28
|
+
return env.REGISTRY.getByName(scope.durableName("registry")).fetch(new Request(request.url));
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { StandaloneEnv } from "@fungi.computer/oyster-old-01/standalone";
|
|
2
|
+
import { WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
|
|
3
|
+
import { ReadOnlyOldOysterDO } from "./old-worker-readonly.js";
|
|
4
|
+
export declare class StandaloneTenants extends ReadOnlyOldOysterDO {
|
|
5
|
+
}
|
|
6
|
+
export declare class OysterMcp extends ReadOnlyOldOysterDO {
|
|
7
|
+
}
|
|
8
|
+
export declare class StandaloneWorkflowRuns extends ReadOnlyOldOysterDO {
|
|
9
|
+
}
|
|
10
|
+
export declare class StandaloneInstance extends ReadOnlyOldOysterDO {
|
|
11
|
+
}
|
|
12
|
+
export declare class ComputerDO extends ReadOnlyOldOysterDO {
|
|
13
|
+
}
|
|
14
|
+
export declare class OysterKeys extends ReadOnlyOldOysterDO {
|
|
15
|
+
}
|
|
16
|
+
export declare class OysterWebhooks extends ReadOnlyOldOysterDO {
|
|
17
|
+
}
|
|
18
|
+
export declare class StandaloneAgent extends ReadOnlyOldOysterDO {
|
|
19
|
+
}
|
|
20
|
+
export declare class AgentDirectory extends ReadOnlyOldOysterDO {
|
|
21
|
+
}
|
|
22
|
+
export declare class MediaOperationDO extends ReadOnlyOldOysterDO {
|
|
23
|
+
}
|
|
24
|
+
export declare class OysterBinding extends WorkerEntrypoint {
|
|
25
|
+
}
|
|
26
|
+
export declare class OysterComputerEgress extends WorkerEntrypoint {
|
|
27
|
+
}
|
|
28
|
+
export declare class OysterRegistry extends ReadOnlyOldOysterDO {
|
|
29
|
+
fetch(): Promise<Response>;
|
|
30
|
+
}
|
|
31
|
+
export declare class StandaloneGraphWorkflow extends WorkflowEntrypoint {
|
|
32
|
+
run(): Promise<never>;
|
|
33
|
+
}
|
|
34
|
+
declare const _default: {
|
|
35
|
+
fetch(request: Request, env: StandaloneEnv): Promise<Response>;
|
|
36
|
+
};
|
|
37
|
+
export default _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
|
|
2
|
+
import { defaultTenant, tenantScope, } from "@fungi.computer/oyster-old-01/tenant";
|
|
3
|
+
import { oldRegistrySqlRequest } from "./old-worker-http.js";
|
|
4
|
+
import { OysterArchivingError, ReadOnlyOldOysterDO, } from "./old-worker-readonly.js";
|
|
5
|
+
import { streamOldSql } from "./old-worker-stream.js";
|
|
6
|
+
// These are the published class identities, with no published constructors or
|
|
7
|
+
// callback bodies. Keep the published oyster-v1 migration tag unchanged.
|
|
8
|
+
export class StandaloneTenants extends ReadOnlyOldOysterDO {
|
|
9
|
+
}
|
|
10
|
+
export class OysterMcp extends ReadOnlyOldOysterDO {
|
|
11
|
+
}
|
|
12
|
+
export class StandaloneWorkflowRuns extends ReadOnlyOldOysterDO {
|
|
13
|
+
}
|
|
14
|
+
export class StandaloneInstance extends ReadOnlyOldOysterDO {
|
|
15
|
+
}
|
|
16
|
+
export class ComputerDO extends ReadOnlyOldOysterDO {
|
|
17
|
+
}
|
|
18
|
+
export class OysterKeys extends ReadOnlyOldOysterDO {
|
|
19
|
+
}
|
|
20
|
+
export class OysterWebhooks extends ReadOnlyOldOysterDO {
|
|
21
|
+
}
|
|
22
|
+
export class StandaloneAgent extends ReadOnlyOldOysterDO {
|
|
23
|
+
}
|
|
24
|
+
export class AgentDirectory extends ReadOnlyOldOysterDO {
|
|
25
|
+
}
|
|
26
|
+
export class MediaOperationDO extends ReadOnlyOldOysterDO {
|
|
27
|
+
}
|
|
28
|
+
export class OysterBinding extends WorkerEntrypoint {
|
|
29
|
+
}
|
|
30
|
+
export class OysterComputerEgress extends WorkerEntrypoint {
|
|
31
|
+
}
|
|
32
|
+
export class OysterRegistry extends ReadOnlyOldOysterDO {
|
|
33
|
+
async fetch() {
|
|
34
|
+
const pendingAt = await this.readPendingAlarm();
|
|
35
|
+
return streamOldSql(this.ctx.storage.sql, {
|
|
36
|
+
pendingAt,
|
|
37
|
+
observedAt: Date.now(),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export class StandaloneGraphWorkflow extends WorkflowEntrypoint {
|
|
42
|
+
run() {
|
|
43
|
+
return Promise.reject(new OysterArchivingError());
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export default {
|
|
47
|
+
fetch(request, env) {
|
|
48
|
+
return oldRegistrySqlRequest(request, env.OYSTER_OWNER_KEY, () => {
|
|
49
|
+
const scope = tenantScope(defaultTenant, env.OYSTER_ORIGIN);
|
|
50
|
+
// The release-matched bridge binds REGISTRY to the OysterRegistry
|
|
51
|
+
// subclass exported here, whose fetch streams the export.
|
|
52
|
+
return env.REGISTRY.getByName(scope.durableName("registry")).fetch(new Request(request.url));
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { StandaloneEnv } from "@fungi.computer/oyster-old-02/standalone";
|
|
2
|
+
import { WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
|
|
3
|
+
import { ReadOnlyOldOysterDO } from "./old-worker-readonly.js";
|
|
4
|
+
export declare class StandaloneTenants extends ReadOnlyOldOysterDO {
|
|
5
|
+
}
|
|
6
|
+
export declare class OysterMcp extends ReadOnlyOldOysterDO {
|
|
7
|
+
}
|
|
8
|
+
export declare class StandaloneWorkflowRuns extends ReadOnlyOldOysterDO {
|
|
9
|
+
}
|
|
10
|
+
export declare class StandaloneInstance extends ReadOnlyOldOysterDO {
|
|
11
|
+
}
|
|
12
|
+
export declare class ComputerDO extends ReadOnlyOldOysterDO {
|
|
13
|
+
}
|
|
14
|
+
export declare class OysterKeys extends ReadOnlyOldOysterDO {
|
|
15
|
+
}
|
|
16
|
+
export declare class OysterWebhooks extends ReadOnlyOldOysterDO {
|
|
17
|
+
}
|
|
18
|
+
export declare class StandaloneAgent extends ReadOnlyOldOysterDO {
|
|
19
|
+
}
|
|
20
|
+
export declare class AgentDirectory extends ReadOnlyOldOysterDO {
|
|
21
|
+
}
|
|
22
|
+
export declare class MediaOperationDO extends ReadOnlyOldOysterDO {
|
|
23
|
+
}
|
|
24
|
+
export declare class OysterBinding extends WorkerEntrypoint {
|
|
25
|
+
}
|
|
26
|
+
export declare class OysterComputerEgress extends WorkerEntrypoint {
|
|
27
|
+
}
|
|
28
|
+
export declare class OysterRegistry extends ReadOnlyOldOysterDO {
|
|
29
|
+
fetch(): Promise<Response>;
|
|
30
|
+
}
|
|
31
|
+
export declare class StandaloneGraphWorkflow extends WorkflowEntrypoint {
|
|
32
|
+
run(): Promise<never>;
|
|
33
|
+
}
|
|
34
|
+
declare const _default: {
|
|
35
|
+
fetch(request: Request, env: StandaloneEnv): Promise<Response>;
|
|
36
|
+
};
|
|
37
|
+
export default _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
|
|
2
|
+
import { defaultTenant, tenantScope, } from "@fungi.computer/oyster-old-02/tenant";
|
|
3
|
+
import { oldRegistrySqlRequest } from "./old-worker-http.js";
|
|
4
|
+
import { OysterArchivingError, ReadOnlyOldOysterDO, } from "./old-worker-readonly.js";
|
|
5
|
+
import { streamOldSql } from "./old-worker-stream.js";
|
|
6
|
+
// These are the published class identities, with no published constructors or
|
|
7
|
+
// callback bodies. Keep the published oyster-v1 migration tag unchanged.
|
|
8
|
+
export class StandaloneTenants extends ReadOnlyOldOysterDO {
|
|
9
|
+
}
|
|
10
|
+
export class OysterMcp extends ReadOnlyOldOysterDO {
|
|
11
|
+
}
|
|
12
|
+
export class StandaloneWorkflowRuns extends ReadOnlyOldOysterDO {
|
|
13
|
+
}
|
|
14
|
+
export class StandaloneInstance extends ReadOnlyOldOysterDO {
|
|
15
|
+
}
|
|
16
|
+
export class ComputerDO extends ReadOnlyOldOysterDO {
|
|
17
|
+
}
|
|
18
|
+
export class OysterKeys extends ReadOnlyOldOysterDO {
|
|
19
|
+
}
|
|
20
|
+
export class OysterWebhooks extends ReadOnlyOldOysterDO {
|
|
21
|
+
}
|
|
22
|
+
export class StandaloneAgent extends ReadOnlyOldOysterDO {
|
|
23
|
+
}
|
|
24
|
+
export class AgentDirectory extends ReadOnlyOldOysterDO {
|
|
25
|
+
}
|
|
26
|
+
export class MediaOperationDO extends ReadOnlyOldOysterDO {
|
|
27
|
+
}
|
|
28
|
+
export class OysterBinding extends WorkerEntrypoint {
|
|
29
|
+
}
|
|
30
|
+
export class OysterComputerEgress extends WorkerEntrypoint {
|
|
31
|
+
}
|
|
32
|
+
export class OysterRegistry extends ReadOnlyOldOysterDO {
|
|
33
|
+
async fetch() {
|
|
34
|
+
const pendingAt = await this.readPendingAlarm();
|
|
35
|
+
return streamOldSql(this.ctx.storage.sql, {
|
|
36
|
+
pendingAt,
|
|
37
|
+
observedAt: Date.now(),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export class StandaloneGraphWorkflow extends WorkflowEntrypoint {
|
|
42
|
+
run() {
|
|
43
|
+
return Promise.reject(new OysterArchivingError());
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export default {
|
|
47
|
+
fetch(request, env) {
|
|
48
|
+
return oldRegistrySqlRequest(request, env.OYSTER_OWNER_KEY, () => {
|
|
49
|
+
const scope = tenantScope(defaultTenant, env.OYSTER_ORIGIN);
|
|
50
|
+
// The release-matched bridge binds REGISTRY to the OysterRegistry
|
|
51
|
+
// subclass exported here, whose fetch streams the export.
|
|
52
|
+
return env.REGISTRY.getByName(scope.durableName("registry")).fetch(new Request(request.url));
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|