@fungi.computer/oyster 0.35.1 → 0.37.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 (39) hide show
  1. package/dist/boot-host-script.js +1 -1
  2. package/dist/build/candidate-cli.mjs +50 -15
  3. package/dist/catalog-frame.js +8 -0
  4. package/dist/cloudflare.js +1 -0
  5. package/dist/embed-metafiles.js +2 -2
  6. package/dist/embed-scripts.js +1 -1
  7. package/dist/hello-app-script.js +1 -1
  8. package/dist/host.d.ts +3 -1
  9. package/dist/host.js +9 -9
  10. package/dist/internal/delivery.js +1 -1
  11. package/dist/invocation.d.ts +27 -5
  12. package/dist/invocation.js +9 -7
  13. package/dist/mcp.d.ts +3 -3
  14. package/dist/mcp.js +1 -1
  15. package/dist/page-script.js +2 -2
  16. package/dist/standalone/agent-self.d.ts +19 -0
  17. package/dist/standalone/agent-self.js +72 -0
  18. package/dist/standalone/agents.d.ts +2 -2
  19. package/dist/standalone/agents.js +30 -8
  20. package/dist/standalone/workflow-git-capture.d.ts +1 -1
  21. package/dist/standalone/workflow-git-capture.js +1 -1
  22. package/dist/standalone/workflow-host.d.ts +63 -26
  23. package/dist/standalone/workflow-host.js +21 -3
  24. package/dist/standalone/workflow-node-capture.d.ts +1 -1
  25. package/dist/standalone/workflow-node-capture.js +1 -1
  26. package/dist/standalone/workflow-trigger-host.d.ts +193 -73
  27. package/dist/standalone/workflows.d.ts +54 -24
  28. package/dist/testing/capabilities.js +2 -0
  29. package/dist/testing/worker.js +1 -0
  30. package/dist/workers-git.js +2 -1
  31. package/dist/workers.js +5 -0
  32. package/docs/api/build-contract.md +27 -27
  33. package/docs/api/build.md +51 -60
  34. package/docs/api/host.md +19 -34
  35. package/docs/api/invocation.md +135 -97
  36. package/docs/api/mcp.md +5 -5
  37. package/docs/api/workers-git.md +180 -179
  38. package/docs/api/workers.md +217 -215
  39. package/package.json +18 -18
@@ -14455,6 +14455,15 @@ function withConstructorDefault2(defaultValue) {
14455
14455
  function toIssueEffect(self) {
14456
14456
  return catchCause2(self, (cause) => failCauseSync2(() => map3(cause, (error2) => error2.issue)));
14457
14457
  }
14458
+ function withDecodingDefaultKey(defaultValue, options) {
14459
+ const encode4 = options?.encodingStrategy === "omit" ? omit() : passthrough();
14460
+ return (self) => {
14461
+ return optionalKey2(toEncoded2(self)).pipe(decodeTo2(self, {
14462
+ decode: withDefault(toIssueEffect(defaultValue)),
14463
+ encode: encode4
14464
+ }));
14465
+ };
14466
+ }
14458
14467
  function withDecodingDefault(defaultValue, options) {
14459
14468
  const encode4 = options?.encodingStrategy === "omit" ? omit() : passthrough();
14460
14469
  return (self) => {
@@ -20154,6 +20163,10 @@ var appApiReservedMethodNames = Object.freeze({
20154
20163
  ]
20155
20164
  });
20156
20165
  var identity2 = string5().check(_minLength(1), _maxLength(256));
20166
+ var appCallerScopeSchema = discriminatedUnion("kind", [
20167
+ strictObject({ kind: literal2("team"), teamId: identity2 }),
20168
+ strictObject({ kind: literal2("standalone"), tenant: identity2 })
20169
+ ]);
20157
20170
  var memberActor = object2({ kind: literal2("member"), memberId: identity2 });
20158
20171
  var agentActor = object2({ kind: literal2("agent"), agentId: identity2 });
20159
20172
  var keyActor = object2({ kind: literal2("team-key"), keyId: identity2 });
@@ -20177,6 +20190,7 @@ var backgroundOrigin = _lazy(() => strictObject({
20177
20190
  seal: string5().check(_regex(/^[A-Za-z0-9_-]{43}$/u))
20178
20191
  }));
20179
20192
  var appMethodCallerSchema = object2({
20193
+ scope: appCallerScopeSchema,
20180
20194
  computerId: nullable2(identity2),
20181
20195
  actor: hostActorSchema,
20182
20196
  /** Host-attested enqueue eligibility for this ordinary write; absent otherwise. */
@@ -20746,20 +20760,35 @@ var appGillWatchSchema = Union2([
20746
20760
  Struct({ storage: meaningful }),
20747
20761
  Struct({ binding: meaningful })
20748
20762
  ]);
20749
- var appDeclaredGillSchema = Struct({
20750
- id: meaningful.pipe(check(makeFilter2((id) => !id.includes(":"), {
20751
- message: "Gill IDs are App-local"
20752
- }))),
20763
+ var identity3 = meaningful.pipe(check(makeFilter2((id) => !id.includes(":"), {
20764
+ message: "Gill IDs are App-local"
20765
+ })));
20766
+ var desktop = Struct({
20767
+ sizes: ArraySchema(Literals(["S", "M", "L"])).check(isMinLength(1), isMaxLength(3), makeFilter2(isUnique, {
20768
+ message: "Desktop Gill sizes must be unique"
20769
+ }))
20770
+ });
20771
+ var rowGill = (view) => Struct({
20772
+ id: identity3,
20773
+ view,
20753
20774
  title: meaningful,
20754
20775
  source: meaningful,
20755
20776
  params: optional2(appGillParamsSchema),
20756
20777
  watch: optional2(appGillWatchSchema),
20757
- desktop: optional2(Struct({
20758
- sizes: ArraySchema(Literals(["S", "M", "L"])).check(isMinLength(1), isMaxLength(3), makeFilter2(isUnique, {
20759
- message: "Desktop Gill sizes must be unique"
20760
- }))
20761
- }))
20778
+ desktop: optional2(desktop)
20762
20779
  });
20780
+ var appDeclaredRowGillSchema = rowGill(Literal2("rows"));
20781
+ var appDeclaredSurfaceGillSchema = Struct({
20782
+ id: identity3,
20783
+ title: meaningful,
20784
+ view: Literal2("surface"),
20785
+ desktop
20786
+ });
20787
+ var appDeclaredGillSchema = Union2([appDeclaredRowGillSchema, appDeclaredSurfaceGillSchema]);
20788
+ var appStoredGillSchema = Union2([
20789
+ rowGill(Literal2("rows").pipe(withDecodingDefaultKey(succeed5("rows")))),
20790
+ appDeclaredSurfaceGillSchema
20791
+ ]);
20763
20792
 
20764
20793
  // ../gills/dist/gill.js
20765
20794
  var gillParamsSchema = Record(appGillParamKeySchema, String4.check(isMaxLength(256))).check(makeFilter2((params) => Object.keys(params).length <= 4, {
@@ -20907,7 +20936,7 @@ var appCallSchema = declareConstructor()([appCallFields], ([fields]) => (input,
20907
20936
  toCodecJson: () => new Link(appCallFields.ast, passthrough2())
20908
20937
  });
20909
20938
  var appCallsSchema = ArraySchema(appCallSchema).check(isMinLength(1), isMaxLength(16), makeFilter2((calls) => isUnique2(calls.map((call) => call.appId)), unique2));
20910
- var appDeclarationSchema = Struct({
20939
+ var declarationSchemaFor = (gill) => Struct({
20911
20940
  api: optionalKey2(appApiSchema),
20912
20941
  displayName: optional2(String4.pipe(check(isMinLength(1)), check(isMaxLength(64)))),
20913
20942
  capabilities: ArraySchema(appCapabilityIdSchema).pipe(check(makeFilter2(isUnique2, unique2))),
@@ -20921,16 +20950,22 @@ var appDeclarationSchema = Struct({
20921
20950
  commands: optional2(ArraySchema(appDeclaredCommandSchema).pipe(check(isMaxLength(64)), check(makeFilter2(commandsAreUnique, {
20922
20951
  message: "Declared command IDs and slash aliases must be unique"
20923
20952
  })))),
20924
- gills: optional2(ArraySchema(appDeclaredGillSchema).pipe(check(isMaxLength(16)), check(makeFilter2(gillsAreUnique, {
20953
+ gills: optional2(ArraySchema(gill).pipe(check(isMaxLength(16)), check(makeFilter2(gillsAreUnique, {
20925
20954
  message: "Declared Gill IDs must be unique"
20926
20955
  })))),
20927
20956
  backend: optional2(Struct({
20928
20957
  bindings: appBackendBindingsSchema,
20929
20958
  sync: optionalKey2(Struct({ method: appApiMethodNameSchema }))
20930
20959
  }))
20931
- }).pipe(check(makeFilter2((declaration3) => declaration3.calls === void 0 || declaration3.capabilities.includes("apps.call"), { message: "App calls require apps.call" })), check(makeFilter2((declaration3) => declaration3.backend?.bindings.every((binding) => binding.name !== "BACKGROUND") ?? true, { message: "BACKGROUND is host-minted and cannot be declared by an App" })), check(makeFilter2((declaration3) => backgroundSyncAllowed(declaration3.api, declaration3.backend?.sync), {
20960
+ }).pipe(check(makeFilter2((declaration3) => declaration3.calls === void 0 || declaration3.capabilities.includes("apps.call"), { message: "App calls require apps.call" })), check(makeFilter2((declaration3) => declaration3.backend?.bindings.every((binding) => binding.name !== "BACKGROUND") ?? true, {
20961
+ message: "BACKGROUND is host-minted and cannot be declared by an App"
20962
+ })), check(makeFilter2((declaration3) => backgroundSyncAllowed(declaration3.api, declaration3.backend?.sync), {
20932
20963
  message: "Background continuation must be a declared write covering all write requirements"
20933
- })), check(makeFilter2((declaration3) => !(declaration3.receives?.includes("git.push") ?? false) || declaration3.capabilities.includes("git.repository"), { message: "Git push reception requires git.repository" })), check(makeFilter2((declaration3) => declaration3.backend?.bindings.every((binding) => binding.operations.every((name) => appBackendBindingOperation(binding.name, name)?.requires.every((capability) => declaration3.capabilities.includes(capability)) === true)) ?? true, { message: "Backend bindings require declared App capabilities" })), check(makeFilter2((declaration3) => !declaration3.backend?.bindings.some((binding) => binding.name === "APP_STORAGE") || (declaration3.storage?.length ?? 0) > 0, { message: "App storage bindings require declared keys" })), check(makeFilter2((declaration3) => Object.values(declaration3.api?.methods ?? {}).every((method2) => method2.requires.every((capability) => declaration3.capabilities.includes(capability))), { message: "App API requires capabilities outside the App declaration" })));
20964
+ })), check(makeFilter2((declaration3) => !(declaration3.receives?.includes("git.push") ?? false) || declaration3.capabilities.includes("git.repository"), { message: "Git push reception requires git.repository" })), check(makeFilter2((declaration3) => declaration3.backend?.bindings.every((binding) => binding.operations.every((name) => appBackendBindingOperation(binding.name, name)?.requires.every((capability) => declaration3.capabilities.includes(capability)) === true)) ?? true, { message: "Backend bindings require declared App capabilities" })), check(makeFilter2((declaration3) => !declaration3.backend?.bindings.some((binding) => binding.name === "APP_STORAGE") || (declaration3.storage?.length ?? 0) > 0, { message: "App storage bindings require declared keys" })), check(makeFilter2((declaration3) => Object.values(declaration3.api?.methods ?? {}).every((method2) => method2.requires.every((capability) => declaration3.capabilities.includes(capability))), {
20965
+ message: "App API requires capabilities outside the App declaration"
20966
+ })));
20967
+ var appDeclarationSchema = declarationSchemaFor(appDeclaredGillSchema);
20968
+ var storedAppDeclarationSchema = declarationSchemaFor(appStoredGillSchema);
20934
20969
 
20935
20970
  // ../../node_modules/.pnpm/nanoid@5.1.16/node_modules/nanoid/index.js
20936
20971
  import { webcrypto as crypto2 } from "node:crypto";
@@ -21317,7 +21352,7 @@ var verifiedAppDescriptionSchema = Struct({
21317
21352
  profile: verifiedBackendProfileSchema
21318
21353
  })),
21319
21354
  // Metadata verified before declarations existed requested nothing.
21320
- declaration: appDeclarationSchema.pipe(withDecodingDefaultType(succeed5(emptyAppDeclaration)))
21355
+ declaration: storedAppDeclarationSchema.pipe(withDecodingDefaultType(succeed5(emptyAppDeclaration)))
21321
21356
  });
21322
21357
  var verifiedArtifactReadSchema = Struct({
21323
21358
  kind: Literal2("verified"),
@@ -21537,7 +21572,7 @@ var appBackendBuildSchema = Struct({
21537
21572
  mediaType: Literal2("application/vnd.fungi.app-backend+json")
21538
21573
  });
21539
21574
  var declaration = {
21540
- declaration: optionalKey2(appDeclarationSchema)
21575
+ declaration: optionalKey2(storedAppDeclarationSchema)
21541
21576
  };
21542
21577
  var appBuildSchema = Union2([
21543
21578
  Struct({
@@ -35,7 +35,15 @@ export function oysterAppCatalog(directory) {
35
35
  surfaceId: app.surfaceId,
36
36
  appId: app.appId,
37
37
  gills: app.gills.map((gill) => {
38
+ if (gill.view === "surface")
39
+ return {
40
+ id: gill.id,
41
+ title: gill.title,
42
+ view: gill.view,
43
+ desktop: { sizes: [...gill.desktop.sizes] },
44
+ };
38
45
  const metadata = {
46
+ view: "rows",
39
47
  id: gill.id,
40
48
  title: gill.title,
41
49
  };
@@ -466,6 +466,7 @@ export function createCloudflareAppTestCopies(ctx, loader, ports, limits) {
466
466
  throw new AppInstanceError("invalid_invocation_facts");
467
467
  // Attribution is not a live call frame: no Computer, workflow or durable lane.
468
468
  const context = parseAppMethodCallContext({
469
+ scope: decoded.scope,
469
470
  actor: decoded.actor,
470
471
  role: "owner",
471
472
  computerId: null,