@fungi.computer/oyster 0.5.0 → 0.7.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 (185) hide show
  1. package/README.md +155 -63
  2. package/dist/agent-archive-projection.d.ts +8 -0
  3. package/dist/agent-archive-projection.js +49 -0
  4. package/dist/agent-schedules.d.ts +50 -0
  5. package/dist/agent-schedules.js +17 -0
  6. package/dist/agents.d.ts +35 -14
  7. package/dist/agents.js +97 -144
  8. package/dist/app-builds.d.ts +7 -2
  9. package/dist/app-builds.js +19 -2
  10. package/dist/approval-capability.d.ts +1 -1
  11. package/dist/approval-capability.js +11 -16
  12. package/dist/approval-home.d.ts +2 -1
  13. package/dist/approval-home.js +5 -3
  14. package/dist/apps/catalog.js +1 -1
  15. package/dist/apps/gate.d.ts +4 -7
  16. package/dist/apps/gate.js +14 -29
  17. package/dist/apps/index.d.ts +1 -1
  18. package/dist/apps/installation.d.ts +4 -42
  19. package/dist/apps/installation.js +7 -75
  20. package/dist/apps/operations.js +0 -10
  21. package/dist/apps/permissions.d.ts +18 -8
  22. package/dist/apps/permissions.js +7 -1
  23. package/dist/auth.js +9 -1
  24. package/dist/authorization.d.ts +307 -0
  25. package/dist/authorization.js +542 -0
  26. package/dist/boot-host-script.js +1 -1
  27. package/dist/build/build-jobs.d.ts +2 -2
  28. package/dist/build/candidate-builder.d.ts +2 -0
  29. package/dist/build/candidate-builder.js +5 -1
  30. package/dist/build/candidate-cli.js +3 -0
  31. package/dist/build/candidate-cli.mjs +67 -22
  32. package/dist/build/job-log.d.ts +23 -0
  33. package/dist/build/job-log.js +88 -0
  34. package/dist/build/local-build.d.ts +2 -0
  35. package/dist/build/local-build.js +11 -9
  36. package/dist/channels/binding.d.ts +8 -1
  37. package/dist/channels/binding.js +12 -0
  38. package/dist/channels/conversations.d.ts +16 -5
  39. package/dist/channels/visitor-channel.d.ts +53 -0
  40. package/dist/channels/visitor-channel.js +124 -0
  41. package/dist/channels/visitor-edge.d.ts +115 -0
  42. package/dist/channels/visitor-edge.js +582 -0
  43. package/dist/channels/visitor-request.d.ts +7 -0
  44. package/dist/channels/visitor-request.js +17 -0
  45. package/dist/channels/visitor-stream-slots.d.ts +2 -0
  46. package/dist/channels/visitor-stream-slots.js +33 -0
  47. package/dist/channels/visitors.d.ts +47 -0
  48. package/dist/channels/visitors.js +181 -0
  49. package/dist/cloudflare.d.ts +11 -2
  50. package/dist/cloudflare.js +27 -1
  51. package/dist/{page/computer-target.d.ts → computer-target.d.ts} +2 -0
  52. package/dist/{page/computer-target.js → computer-target.js} +3 -1
  53. package/dist/files.js +9 -8
  54. package/dist/git-admission.d.ts +3 -3
  55. package/dist/git-admission.js +4 -6
  56. package/dist/git-door.d.ts +8 -7
  57. package/dist/git-door.js +18 -17
  58. package/dist/git.d.ts +1 -1
  59. package/dist/host.d.ts +38 -42
  60. package/dist/host.js +182 -239
  61. package/dist/installation-execution.js +10 -5
  62. package/dist/installation-operations.d.ts +4 -180
  63. package/dist/installation-operations.js +1 -5
  64. package/dist/installation-store-generation.d.ts +4 -1
  65. package/dist/installation-store-generation.js +59 -6
  66. package/dist/internal/delivery.js +0 -1
  67. package/dist/internal/host-gate.d.ts +9 -6
  68. package/dist/internal/host-gate.js +19 -25
  69. package/dist/internal/invocation-timing.d.ts +16 -0
  70. package/dist/internal/invocation-timing.js +23 -0
  71. package/dist/internal/registry-installations.js +1 -0
  72. package/dist/invocation.d.ts +19 -11
  73. package/dist/invocation.js +171 -96
  74. package/dist/keys.d.ts +2 -19
  75. package/dist/keys.js +1 -37
  76. package/dist/mcp.d.ts +15 -27
  77. package/dist/mcp.js +105 -155
  78. package/dist/page/agent-browser.d.ts +15 -0
  79. package/dist/page/agent-browser.js +162 -0
  80. package/dist/page/app-permissions-port.d.ts +3 -0
  81. package/dist/page/app-permissions-port.js +43 -0
  82. package/dist/page/app-permissions.d.ts +11 -0
  83. package/dist/page/app-permissions.js +296 -0
  84. package/dist/page/capabilities.js +1 -1
  85. package/dist/page/child-selection.d.ts +27 -0
  86. package/dist/page/child-selection.js +38 -0
  87. package/dist/page/isolated-page-theme.d.ts +2 -0
  88. package/dist/page/isolated-page-theme.js +11 -0
  89. package/dist/page/mount.d.ts +2 -13
  90. package/dist/page/mount.js +8 -94
  91. package/dist/page-script.d.ts +0 -3
  92. package/dist/page-script.js +3 -4
  93. package/dist/release.d.ts +13 -0
  94. package/dist/release.js +10 -0
  95. package/dist/request-origin.d.ts +4 -0
  96. package/dist/request-origin.js +10 -0
  97. package/dist/standalone/agent-archive-owner.d.ts +42 -0
  98. package/dist/standalone/agent-archive-owner.js +116 -0
  99. package/dist/standalone/agent-archive-schedules.d.ts +6 -0
  100. package/dist/standalone/agent-archive-schedules.js +76 -0
  101. package/dist/standalone/agent-archive.d.ts +31 -0
  102. package/dist/standalone/agent-archive.js +67 -0
  103. package/dist/standalone/agent-computers.d.ts +7 -6
  104. package/dist/standalone/agent-computers.js +4 -7
  105. package/dist/standalone/agent-mail.d.ts +2 -2
  106. package/dist/standalone/agents.d.ts +157 -20
  107. package/dist/standalone/agents.js +242 -38
  108. package/dist/standalone/app-builds-binding.js +1 -1
  109. package/dist/standalone/app-set.js +2 -54
  110. package/dist/standalone/app-source.d.ts +3 -4
  111. package/dist/standalone/app-source.js +12 -9
  112. package/dist/standalone/builds.d.ts +2 -14
  113. package/dist/standalone/builds.js +15 -13
  114. package/dist/standalone/computer-fleet.d.ts +4 -4
  115. package/dist/standalone/computer-fleet.js +20 -43
  116. package/dist/standalone/computer.d.ts +4 -3
  117. package/dist/standalone/computer.js +52 -53
  118. package/dist/standalone/dashboard-approval.d.ts +10 -0
  119. package/dist/standalone/dashboard-approval.js +66 -0
  120. package/dist/standalone/machine-link.d.ts +4 -221
  121. package/dist/standalone/machine-link.js +21 -15
  122. package/dist/standalone/media.d.ts +1 -0
  123. package/dist/standalone/media.js +20 -14
  124. package/dist/standalone/owner-routes.d.ts +16 -0
  125. package/dist/standalone/owner-routes.js +21 -0
  126. package/dist/standalone/permission-resources.d.ts +5 -0
  127. package/dist/standalone/permission-resources.js +31 -0
  128. package/dist/standalone/registry.d.ts +7 -0
  129. package/dist/standalone/registry.js +3 -0
  130. package/dist/standalone/tenancy.js +3 -1
  131. package/dist/standalone/worker-routes.d.ts +19 -0
  132. package/dist/standalone/worker-routes.js +9 -0
  133. package/dist/standalone/worker.d.ts +1 -1
  134. package/dist/standalone/worker.js +27 -35
  135. package/dist/standalone/workflow-binding.d.ts +8 -3
  136. package/dist/standalone/workflow-binding.js +14 -5
  137. package/dist/standalone/workflow-git-capture.js +2 -1
  138. package/dist/standalone/workflow-host.d.ts +8 -103
  139. package/dist/standalone/workflow-host.js +1 -1
  140. package/dist/standalone/workflow-node-capture.js +2 -2
  141. package/dist/standalone/workflow-root-authority.d.ts +1 -1
  142. package/dist/standalone/workflow-root-authority.js +1 -1
  143. package/dist/standalone/workflow-schedules.d.ts +14 -5
  144. package/dist/standalone/workflow-schedules.js +11 -5
  145. package/dist/standalone/workflow-webhooks.d.ts +4 -18
  146. package/dist/standalone/workflow-webhooks.js +5 -5
  147. package/dist/standalone/workflows.d.ts +36 -28
  148. package/dist/standalone/workflows.js +6 -3
  149. package/dist/storage-frame.d.ts +6 -6
  150. package/dist/testing/capabilities.d.ts +7 -6
  151. package/dist/testing/capabilities.js +3 -6
  152. package/dist/testing/installation.d.ts +0 -1
  153. package/dist/testing/installation.js +2 -5
  154. package/dist/turnstile.d.ts +27 -0
  155. package/dist/turnstile.js +51 -0
  156. package/dist/workers-git.d.ts +12 -4
  157. package/dist/workers-git.js +58 -36
  158. package/dist/workers.d.ts +9 -1
  159. package/dist/workers.js +59 -20
  160. package/dist/workflows.d.ts +2 -0
  161. package/dist/workflows.js +1 -0
  162. package/docs/api/README.md +7 -0
  163. package/docs/api/agent-schedules.md +175 -0
  164. package/docs/api/agents.md +34 -13
  165. package/docs/api/app-storage.md +1 -1
  166. package/docs/api/apps.md +323 -225
  167. package/docs/api/authorization.md +1300 -0
  168. package/docs/api/build-contract.md +2 -2
  169. package/docs/api/build.md +40 -37
  170. package/docs/api/cloudflare.md +27 -2
  171. package/docs/api/git.md +20 -11
  172. package/docs/api/host.md +80 -199
  173. package/docs/api/index.md +1 -1
  174. package/docs/api/invocation.md +15 -11
  175. package/docs/api/keys.md +1 -98
  176. package/docs/api/mcp.md +43 -40
  177. package/docs/api/modules.md +2 -0
  178. package/docs/api/page/mount.md +16 -19
  179. package/docs/api/workers-git.md +46 -12
  180. package/docs/api/workers.md +125 -235
  181. package/docs/site/agent-quickstart.mdx +6 -2
  182. package/examples/standalone/wrangler.celld.jsonc +66 -0
  183. package/package.json +64 -21
  184. package/dist/standalone/channel-session-door.d.ts +0 -4
  185. package/dist/standalone/channel-session-door.js +0 -42
package/dist/host.d.ts CHANGED
@@ -13,12 +13,14 @@ import { type AppGitPushFact, type GitPushQuestion, type GitPushVerdict, type Gi
13
13
  import { type GuestLimits } from "./guest-policy.js";
14
14
  import { type InvocationFacts } from "./invocation.js";
15
15
  export type { GuestLimits } from "./guest-policy.js";
16
- import { Hono } from "hono";
16
+ import { type TimingVariables } from "hono/timing";
17
17
  import * as Schema from "effect/Schema";
18
18
  import { type BackgroundSyncRefusal } from "@fungi.computer/puffball/background-replay";
19
19
  import { type Installation, type InstallationReader } from "./apps/installation.js";
20
+ import { type ResourceOption } from "./apps/permissions.js";
20
21
  import type { AppToolPolicy } from "./apps/tools.js";
21
- import { type LiveOysterKey } from "./keys.js";
22
+ import type { LiveOysterKey } from "./keys.js";
23
+ import { type ServedTable, type RouteDeclaration, type Routes } from "./authorization.js";
22
24
  import { type AppMethodReply } from "@fungi.computer/agar/backend";
23
25
  import type { AppCapabilityId, HostActor } from "@fungi.computer/puffball/app";
24
26
  import { type CapabilityDescriptor } from "./capability-descriptor.js";
@@ -26,32 +28,12 @@ export { capabilityDescriptorSchema, capabilityMethodKindSchema, capabilityMetho
26
28
  import type { Release } from "@fungi.computer/puffball";
27
29
  import type { UiBootCheckOutcome } from "./boot-gate.js";
28
30
  import { type Instance, type InstanceId, type OwnerState, type AppInstanceErrorCode } from "./index.js";
29
- import { type ArtifactStore } from "./release.js";
31
+ import { type ArtifactStore, type VerifiedObjectCache } from "./release.js";
30
32
  import { type GitDoorTarget } from "./git.js";
31
33
  import type { AdmittedGit } from "./git-admission.js";
32
34
  import { type PageAssetLoader } from "./page-assets.js";
33
35
  import { type AppApi } from "@fungi.computer/puffball";
34
- export { ReleaseError, defaultAssetPolicy, parseRelease, resolveBackend, sha256, verifyRelease, type ArtifactStore, type VerifiedRelease, } from "./release.js";
35
- /**
36
- * The anonymous reader of a public installation. The host admits it only when
37
- * authentication refuses; it reaches that App's page and its `read` methods.
38
- */
39
- export type OysterVisitor = Readonly<{
40
- actor: Readonly<{
41
- kind: "visitor";
42
- }>;
43
- }>;
44
- /** Who an admitted request acts for: an authenticated tenant principal or the visitor. */
45
- export type OysterPrincipal = TenantPrincipal | OysterVisitor;
46
- /** Narrow an admitted principal to the anonymous public reader. */
47
- export declare function oysterPrincipalIsVisitor(principal: OysterPrincipal): principal is OysterVisitor;
48
- /** True only for a member admitted with the owner role. */
49
- export declare function oysterPrincipalIsOwner(principal: OysterPrincipal): principal is Readonly<{
50
- actor: Extract<HostActor, {
51
- kind: "member";
52
- }>;
53
- role: "owner";
54
- }>;
36
+ export { ReleaseError, defaultAssetPolicy, parseRelease, resolveBackend, sha256, verifyRelease, type ArtifactStore, type VerifiedObjectCache, type VerifiedRelease, } from "./release.js";
55
37
  /** Stable actor identity for host storage and backend attribution. */
56
38
  export declare function oysterPrincipalId(principal: TenantPrincipal): string;
57
39
  /** The outcome of authenticating one request. */
@@ -85,6 +67,8 @@ export type InstallationStore = InstallationReader & Readonly<{
85
67
  operations?: InstallationOperations;
86
68
  /** Opaque identity of this store incarnation; replacing the store mints another. */
87
69
  generation: () => Promise<string>;
70
+ /** Registry-backed stores retain their reset audit; other hosts have none. */
71
+ resetAt?: () => Promise<number | null>;
88
72
  /**
89
73
  * Atomically commit one reducer-produced record only over the version it
90
74
  * was computed from (0: no record). Every writer reads, may await
@@ -169,17 +153,13 @@ export type CapabilityEnv = {
169
153
  export type OysterCapability = Readonly<CapabilityDescriptor & {
170
154
  /** The permission declared by an App Release to use this contract. */
171
155
  permission: AppCapabilityId;
172
- /** Routes relative to the descriptor's base path. */
173
- routes: Hono<CapabilityEnv>;
156
+ /** Declared routes relative to the descriptor's base path; each names
157
+ * its own requirement beyond the App holding this capability. */
158
+ routes: Routes<CapabilityEnv>;
174
159
  }>;
175
- /** What the host stamps once per request; inner routes read it with `c.get`. */
176
- export type OysterVariables = {
177
- principal: OysterPrincipal;
178
- installation?: Installation;
179
- };
180
- /** Owner routes run after the host's owner guard and read `c.get("principal")`. */
160
+ /** The host table's Hono env; every route receives its principal from its declared requirement. */
181
161
  export type OysterEnv = {
182
- Variables: OysterVariables;
162
+ Variables: TimingVariables;
183
163
  };
184
164
  /** Everything a host supplies to run Oyster. */
185
165
  export type OysterHost = Readonly<{
@@ -192,15 +172,19 @@ export type OysterHost = Readonly<{
192
172
  * Host-bound Workflow control; absence exposes no Workflow authority.
193
173
  * @inlineType WorkflowControl
194
174
  */
195
- workflows?: (principal: OysterPrincipal) => Promise<WorkflowControl | null>;
175
+ workflows?: (principal: TenantPrincipal) => Promise<WorkflowControl | null>;
196
176
  /** Owner-admitted durable Computer inventory, absent on hosts without a fleet. */
197
- computerControl?: (principal: OysterPrincipal) => ComputerControlPort | null;
177
+ computerControl?: (principal: TenantPrincipal) => ComputerControlPort | null;
178
+ /** Owner-direct picker facts from the host's existing resource directories. */
179
+ permissionResources?: (principal: TenantPrincipal) => Promise<readonly ResourceOption[]>;
198
180
  auth: OysterAuth;
199
181
  /** Host-held sealing key for member writes; never exposed to the guest.
200
182
  * Absence refuses eligible named member writes, even when the App has no sync continuation.
201
183
  */
202
184
  backgroundOriginKey?: () => Promise<CryptoKey>;
203
185
  artifacts: ArtifactStore;
186
+ /** Digest-keyed copies of verified UI objects; absent, every read is verified from `artifacts`. */
187
+ uiCache?: VerifiedObjectCache;
204
188
  installations: InstallationStore;
205
189
  instances: InstanceDirectory;
206
190
  /** Report-only host UI check; backend construction remains Instance-owned and blocking. */
@@ -212,7 +196,7 @@ export type OysterHost = Readonly<{
212
196
  * `computer.use` grant). The Computer owner accepts each call against the
213
197
  * authority the host issued.
214
198
  */
215
- computer?: (principal: OysterPrincipal) => KnapsackComputer | null | Promise<KnapsackComputer | null>;
199
+ computer?: (principal: TenantPrincipal) => KnapsackComputer | null | Promise<KnapsackComputer | null>;
216
200
  /** Host-attested Agent tool policy; absence grants no App tool access. A
217
201
  * key's App access is its own grants (Ear Tag), read through `keys.live`
218
202
  * and `keyAppAccess`, never this port. */
@@ -230,9 +214,9 @@ export type OysterHost = Readonly<{
230
214
  mcp?: OysterMcp;
231
215
  /** The git door for Apps that use GIT; mounted at `/git/*`. */
232
216
  git?: OysterGitHost;
233
- /** Owner-only `/api/*` routes the host adds (keys, webhooks); they read the
234
- * admitted owner with `c.get("principal")` and never authenticate again. */
235
- ownerRoutes?: Hono<OysterEnv>;
217
+ /** Further routes the host adds (keys, webhooks, builds); each declares
218
+ * its own requirement and receives the admitted principal from it. */
219
+ ownerRoutes?: Routes<OysterEnv>;
236
220
  /** Adapters granted only when the Release declares them and admission passes. */
237
221
  capabilities?: readonly OysterCapability[];
238
222
  /**
@@ -263,11 +247,23 @@ export type OysterHost = Readonly<{
263
247
  title?: string;
264
248
  }>;
265
249
  /** Completed selection, without re-deriving or executing outside Watchdog. */
266
- export declare function installOrSelect(host: OysterHost, installationId: string, release: Release, principal: OysterPrincipal, intent: "install-or-select" | "install-or-remint" | "create-only", origin: "owner-direct" | "workflow" | "app", requestId?: string, signal?: AbortSignal): Promise<Response>;
250
+ export declare function installOrSelect(host: OysterHost, installationId: string, release: Release, principal: TenantPrincipal, intent: "install-or-select" | "install-or-remint" | "create-only", origin: "owner-direct" | "workflow" | "app", requestId?: string, signal?: AbortSignal): Promise<Response>;
251
+ /** One host's declared routes and the one way to serve them. */
252
+ export type OysterRouteTable = Readonly<{
253
+ /** Every route this host serves, each with its declared requirement. */
254
+ declarations: () => readonly RouteDeclaration[];
255
+ /** Serve the table; only declared routes answer. */
256
+ serve: () => ServedTable<OysterEnv>;
257
+ }>;
267
258
  /**
268
- * Create the Oyster App server: a Hono app that installs App Releases, serves
259
+ * Create the Oyster App server: a served route table that installs App Releases, serves
269
260
  * their UI, forwards their backend requests and methods to their Instances,
270
261
  * and mounts the host's MCP endpoint. The host's adapters decide where state
271
262
  * lives and who may sign in.
272
263
  */
273
- export declare function createOyster(host: OysterHost): Hono<OysterEnv>;
264
+ export declare function createOyster(host: OysterHost): ServedTable<OysterEnv>;
265
+ /**
266
+ * The Oyster host's declared route table: every route names its requirement
267
+ * (`authorization.ts`), so an undeclared route is never served.
268
+ */
269
+ export declare function oysterRouteTable(host: OysterHost): OysterRouteTable;