@fungi.computer/oyster 0.47.1 → 0.47.3

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/workers.js CHANGED
@@ -18,6 +18,7 @@ import { installationWorkerEntrypoint } from "./installation-execution.js";
18
18
  export { installationWorkerEntrypoint };
19
19
  import { approvedBindingGrants, scopedBindings } from "./apps/gate.js";
20
20
  import { appMethodReplySchema } from "@fungi.computer/agar/backend";
21
+ import { storageWatchStream } from "./storage-watch-stream.js";
21
22
  import { nativeGitFrameMethods, nativeGitMethodNameSchema, } from "@fungi.computer/agar/git-rpc";
22
23
  import { backgroundOriginKey, actorLane, mayDefer, } from "@fungi.computer/puffball/background-replay";
23
24
  import { emptyAppDeclaration, appBackendBindingKinds, } from "@fungi.computer/puffball/app";
@@ -33,7 +34,6 @@ import { fileCapabilities } from "./files.js";
33
34
  import { DurableObject } from "cloudflare:workers";
34
35
  import * as Effect from "effect/Effect";
35
36
  import * as Schema from "effect/Schema";
36
- import * as Stream from "effect/Stream";
37
37
  import { parseReleaseId, parseSha256Digest, } from "@fungi.computer/puffball";
38
38
  import { releaseSchema } from "@fungi.computer/puffball/effect";
39
39
  import { AppInstanceError, } from "./index.js";
@@ -275,21 +275,14 @@ export class OysterRegistry extends DurableObject {
275
275
  return Promise.resolve({ kind: "rejected", code: "invalid" });
276
276
  }
277
277
  }
278
- /** Open the existing App-storage invalidation stream under fresh owner admission. */
279
- async storageEvents(installationId, ownerId, key) {
280
- const view = this.storageView(installationId, () => Promise.resolve(ownerId));
281
- const admitted = await this.storageResult(view.read(key));
282
- if (admitted.kind === "rejected")
283
- return Response.json(admitted, { status: 403 });
284
- return new Response(Stream.toReadableStream(view
285
- .events(key)
286
- .pipe(Stream.map((event) => new TextEncoder().encode(event === null
287
- ? "event: ready\ndata: {}\n\n"
288
- : `event: changed\ndata: ${JSON.stringify(event)}\n\n`)))), {
289
- headers: {
290
- "Content-Type": "text/event-stream",
291
- "Cache-Control": "no-store",
292
- },
278
+ /** Watch many storage keys as one stream, each under fresh owner admission. */
279
+ storageWatch(ownerId, watches) {
280
+ return storageWatchStream(watches, async ([installationId, key]) => {
281
+ const view = this.storageView(installationId, () => Promise.resolve(ownerId));
282
+ const admitted = await this.storageResult(view.read(key));
283
+ return admitted.kind === "rejected"
284
+ ? admitted
285
+ : { kind: "accepted", value: view.events(key) };
293
286
  });
294
287
  }
295
288
  storageResult(program) {
@@ -1424,8 +1417,8 @@ export function oysterWorkerHost(env, auth, options = {}) {
1424
1417
  write: (input) => registry().storageWrite(installationId, ownerId, input),
1425
1418
  reset: (input) => registry().storageReset(installationId, ownerId, input),
1426
1419
  claim: (input) => registry().storageClaim(installationId, ownerId, input),
1427
- events: (key) => registry().storageEvents(installationId, ownerId, key),
1428
1420
  }),
1421
+ watchStorage: (ownerId, watches) => registry().storageWatch(ownerId, watches),
1429
1422
  },
1430
1423
  guestLimits: guestLimits(options.guestLimits),
1431
1424
  artifacts,
@@ -685,6 +685,8 @@ What one Vault command answers: a listing, an id, a version, usage or a refusal.
685
685
  ```ts
686
686
  type StarterOutcome =
687
687
  | "created"
688
+ | "seeding"
689
+ | "starting"
688
690
  | "already-offered"
689
691
  | "team-not-empty"
690
692
  | "unfunded"
@@ -692,7 +694,9 @@ type StarterOutcome =
692
694
  | "failed";
693
695
  ```
694
696
 
695
- How one offer of the starter Agent settled; only `created` made an Agent.
697
+ How one offer of the starter Agent settled. `created` and `seeding` both mean
698
+ the Agent exists; `seeding` means its Home seed is still running; `starting`
699
+ means its create is still running.
696
700
 
697
701
  ## Variables
698
702
 
package/docs/api/host.md CHANGED
@@ -528,9 +528,8 @@ type OysterHost = Readonly<{
528
528
  }>;
529
529
  installing?: readonly InstallingApp[];
530
530
  }>>;
531
- storage: Pick<AppStorageWire, "read" | "write" | "reset" | "claim"> & Readonly<{
532
- events: Promise<Response>;
533
- }>;
531
+ storage: Pick<AppStorageWire, "read" | "write" | "reset" | "claim">;
532
+ watchStorage: Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
534
533
  }>;
535
534
  homeInstallationId?: string;
536
535
  pageScript?: string;