@fungi.computer/oyster 0.6.0 → 0.8.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 (163) hide show
  1. package/README.md +133 -78
  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 +61 -0
  5. package/dist/agent-schedules.js +19 -0
  6. package/dist/agents.d.ts +35 -14
  7. package/dist/agents.js +93 -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.d.ts +1 -24
  24. package/dist/auth.js +9 -39
  25. package/dist/authorization.d.ts +307 -0
  26. package/dist/authorization.js +542 -0
  27. package/dist/boot-host-script.js +1 -1
  28. package/dist/build/build-jobs.d.ts +2 -2
  29. package/dist/build/candidate-builder.d.ts +2 -0
  30. package/dist/build/candidate-builder.js +5 -1
  31. package/dist/build/candidate-cli.js +3 -0
  32. package/dist/build/candidate-cli.mjs +70 -22
  33. package/dist/build/job-log.d.ts +23 -0
  34. package/dist/build/job-log.js +88 -0
  35. package/dist/build/local-build.d.ts +9 -1
  36. package/dist/build/local-build.js +11 -9
  37. package/dist/cloudflare.d.ts +4 -1
  38. package/dist/cloudflare.js +1 -1
  39. package/dist/files.js +9 -8
  40. package/dist/git-admission.d.ts +3 -3
  41. package/dist/git-admission.js +4 -6
  42. package/dist/git-door.d.ts +8 -7
  43. package/dist/git-door.js +18 -17
  44. package/dist/git.d.ts +1 -1
  45. package/dist/host.d.ts +33 -40
  46. package/dist/host.js +156 -275
  47. package/dist/installation-execution.js +14 -5
  48. package/dist/installation-operations.d.ts +4 -180
  49. package/dist/installation-operations.js +1 -5
  50. package/dist/installation-store-generation.d.ts +4 -1
  51. package/dist/installation-store-generation.js +59 -6
  52. package/dist/internal/delivery.js +0 -1
  53. package/dist/internal/host-gate.d.ts +3 -2
  54. package/dist/internal/host-gate.js +5 -18
  55. package/dist/internal/invocation-timing.d.ts +16 -0
  56. package/dist/internal/invocation-timing.js +23 -0
  57. package/dist/internal/registry-installations.js +1 -0
  58. package/dist/invocation.d.ts +15 -14
  59. package/dist/invocation.js +58 -26
  60. package/dist/keys.d.ts +2 -19
  61. package/dist/keys.js +1 -37
  62. package/dist/mcp.d.ts +15 -27
  63. package/dist/mcp.js +105 -155
  64. package/dist/page/agent-browser.d.ts +15 -0
  65. package/dist/page/agent-browser.js +162 -0
  66. package/dist/page/app-permissions-port.d.ts +3 -0
  67. package/dist/page/app-permissions-port.js +43 -0
  68. package/dist/page/app-permissions.d.ts +11 -0
  69. package/dist/page/app-permissions.js +296 -0
  70. package/dist/page/isolated-page-theme.d.ts +2 -0
  71. package/dist/page/isolated-page-theme.js +11 -0
  72. package/dist/page/mount.d.ts +2 -13
  73. package/dist/page/mount.js +7 -93
  74. package/dist/page-script.d.ts +0 -3
  75. package/dist/page-script.js +3 -4
  76. package/dist/standalone/agent-archive-owner.d.ts +42 -0
  77. package/dist/standalone/agent-archive-owner.js +116 -0
  78. package/dist/standalone/agent-archive-schedules.d.ts +6 -0
  79. package/dist/standalone/agent-archive-schedules.js +76 -0
  80. package/dist/standalone/agent-archive.d.ts +31 -0
  81. package/dist/standalone/agent-archive.js +67 -0
  82. package/dist/standalone/agent-computers.d.ts +7 -6
  83. package/dist/standalone/agent-computers.js +4 -7
  84. package/dist/standalone/agent-mail.d.ts +2 -2
  85. package/dist/standalone/agents.d.ts +186 -20
  86. package/dist/standalone/agents.js +251 -30
  87. package/dist/standalone/app-builds-binding.js +1 -1
  88. package/dist/standalone/app-set.js +2 -54
  89. package/dist/standalone/app-source.d.ts +3 -4
  90. package/dist/standalone/app-source.js +12 -9
  91. package/dist/standalone/builds.d.ts +2 -14
  92. package/dist/standalone/builds.js +15 -13
  93. package/dist/standalone/computer-fleet.d.ts +4 -4
  94. package/dist/standalone/computer-fleet.js +13 -42
  95. package/dist/standalone/computer.d.ts +4 -3
  96. package/dist/standalone/computer.js +52 -53
  97. package/dist/standalone/dashboard-approval.d.ts +10 -0
  98. package/dist/standalone/dashboard-approval.js +66 -0
  99. package/dist/standalone/machine-link.d.ts +4 -221
  100. package/dist/standalone/machine-link.js +21 -15
  101. package/dist/standalone/media.d.ts +1 -0
  102. package/dist/standalone/media.js +20 -14
  103. package/dist/standalone/owner-routes.d.ts +16 -0
  104. package/dist/standalone/owner-routes.js +21 -0
  105. package/dist/standalone/permission-resources.d.ts +5 -0
  106. package/dist/standalone/permission-resources.js +31 -0
  107. package/dist/standalone/registry.d.ts +7 -0
  108. package/dist/standalone/registry.js +3 -0
  109. package/dist/standalone/tenancy.d.ts +0 -3
  110. package/dist/standalone/tenancy.js +2 -5
  111. package/dist/standalone/worker-routes.d.ts +19 -0
  112. package/dist/standalone/worker-routes.js +9 -0
  113. package/dist/standalone/worker.d.ts +1 -1
  114. package/dist/standalone/worker.js +27 -35
  115. package/dist/standalone/workflow-binding.d.ts +10 -3
  116. package/dist/standalone/workflow-binding.js +22 -5
  117. package/dist/standalone/workflow-git-capture.js +2 -1
  118. package/dist/standalone/workflow-host.d.ts +8 -103
  119. package/dist/standalone/workflow-host.js +1 -1
  120. package/dist/standalone/workflow-node-capture.js +2 -2
  121. package/dist/standalone/workflow-root-authority.d.ts +1 -1
  122. package/dist/standalone/workflow-root-authority.js +1 -1
  123. package/dist/standalone/workflow-schedules.d.ts +31 -4
  124. package/dist/standalone/workflow-schedules.js +18 -5
  125. package/dist/standalone/workflow-webhooks.d.ts +4 -18
  126. package/dist/standalone/workflow-webhooks.js +5 -5
  127. package/dist/standalone/workflows.d.ts +53 -27
  128. package/dist/standalone/workflows.js +9 -3
  129. package/dist/storage-frame.d.ts +6 -6
  130. package/dist/testing/capabilities.d.ts +7 -6
  131. package/dist/testing/capabilities.js +3 -6
  132. package/dist/testing/installation.d.ts +0 -1
  133. package/dist/testing/installation.js +2 -5
  134. package/dist/workers-git.d.ts +12 -4
  135. package/dist/workers-git.js +38 -35
  136. package/dist/workers.d.ts +9 -1
  137. package/dist/workers.js +44 -8
  138. package/dist/workflows.d.ts +4 -0
  139. package/dist/workflows.js +2 -0
  140. package/docs/api/README.md +7 -0
  141. package/docs/api/agent-schedules.md +176 -0
  142. package/docs/api/agents.md +34 -13
  143. package/docs/api/app-storage.md +1 -1
  144. package/docs/api/apps.md +323 -225
  145. package/docs/api/auth.md +0 -55
  146. package/docs/api/authorization.md +1300 -0
  147. package/docs/api/build.md +42 -38
  148. package/docs/api/cloudflare.md +3 -3
  149. package/docs/api/git.md +20 -11
  150. package/docs/api/host.md +64 -192
  151. package/docs/api/index.md +1 -1
  152. package/docs/api/invocation.md +14 -14
  153. package/docs/api/keys.md +1 -98
  154. package/docs/api/mcp.md +43 -40
  155. package/docs/api/modules.md +2 -0
  156. package/docs/api/page/mount.md +16 -19
  157. package/docs/api/workers-git.md +46 -12
  158. package/docs/api/workers.md +111 -222
  159. package/package.json +41 -22
  160. package/dist/page/computer-target.d.ts +0 -3
  161. package/dist/page/computer-target.js +0 -9
  162. package/dist/standalone/channel-session-door.d.ts +0 -4
  163. package/dist/standalone/channel-session-door.js +0 -72
@@ -0,0 +1,1300 @@
1
+ <!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
2
+
3
+ [**@fungi.computer/oyster**](README.md)
4
+
5
+ ---
6
+
7
+ [@fungi.computer/oyster](modules.md) / authorization
8
+
9
+ # authorization
10
+
11
+ ## Classes
12
+
13
+ ### Requirement
14
+
15
+ One route's declared requirement: an opaque, frozen value only this module
16
+ mints. Its label and decision live in private fields that only this module
17
+ reads, so a copy, a look-alike, an overridden method or a relabelled field
18
+ changes nothing a route serves, and registering a non-minted value throws.
19
+
20
+ #### Type Parameters
21
+
22
+ | Type Parameter |
23
+ | -------------- |
24
+ | `Admitted` |
25
+
26
+ #### Constructors
27
+
28
+ ##### Constructor
29
+
30
+ ```ts
31
+ new Requirement<Admitted>(
32
+ token,
33
+ declared,
34
+ admit
35
+ ): Requirement<Admitted>;
36
+ ```
37
+
38
+ Module-private: use the requirement constructors below.
39
+
40
+ ###### Parameters
41
+
42
+ | Parameter | Type |
43
+ | ---------- | -------------------------------------------------- |
44
+ | `token` | `symbol` |
45
+ | `declared` | [`DeclaredRequirement`](#declaredrequirement) |
46
+ | `admit` | (`facts`) => `Promise`\<`Response` \| `Admitted`\> |
47
+
48
+ ###### Returns
49
+
50
+ [`Requirement`](#requirement)\<`Admitted`\>
51
+
52
+ #### Properties
53
+
54
+ ##### admitted?
55
+
56
+ ```ts
57
+ readonly optional admitted?: Admitted;
58
+ ```
59
+
60
+ Type-only: what the requirement admits. Never present at run time.
61
+
62
+ ---
63
+
64
+ ### Routes
65
+
66
+ A declared route table: a frozen, opaque value only [routes](#routes-1) builds.
67
+ Its routes live in a private record; including or serving reads only that
68
+ record, never a method a copy could override. A table cannot serve itself: only
69
+ [serveHost](#servehost), [serveDoors](#servedoors) and
70
+ [serveCapability](#servecapability) do, each with the principal its composition
71
+ root admits. There is no `use`: a path-wide middleware could serve a path no
72
+ route declares.
73
+
74
+ #### Type Parameters
75
+
76
+ | Type Parameter |
77
+ | ------------------- |
78
+ | `E` _extends_ `Env` |
79
+
80
+ #### Constructors
81
+
82
+ ##### Constructor
83
+
84
+ ```ts
85
+ new Routes<E>(token): Routes<E>;
86
+ ```
87
+
88
+ Module-private: use [routes](#routes-1).
89
+
90
+ ###### Parameters
91
+
92
+ | Parameter | Type |
93
+ | --------- | -------- |
94
+ | `token` | `symbol` |
95
+
96
+ ###### Returns
97
+
98
+ [`Routes`](#routes)\<`E`\>
99
+
100
+ #### Methods
101
+
102
+ ##### get()
103
+
104
+ ```ts
105
+ get<P, A>(
106
+ path,
107
+ requirement,
108
+ handler,
109
+ options?
110
+ ): this;
111
+ ```
112
+
113
+ Register one GET route.
114
+
115
+ ###### Type Parameters
116
+
117
+ | Type Parameter |
118
+ | ---------------------- |
119
+ | `P` _extends_ `string` |
120
+ | `A` |
121
+
122
+ ###### Parameters
123
+
124
+ | Parameter | Type |
125
+ | ------------- | ------------------------------------------------------------------------------------------- |
126
+ | `path` | `P` |
127
+ | `requirement` | [`Requirement`](#requirement)\<`A`\> |
128
+ | `handler` | [`Handler`](#handler)\<`E`, `P`, `A`\> |
129
+ | `options?` | `Readonly`\<\{ `middleware?`: readonly `MiddlewareHandler`\<`E`, `NoInfer`\<`P`\>\>[]; \}\> |
130
+
131
+ ###### Returns
132
+
133
+ `this`
134
+
135
+ ##### post()
136
+
137
+ ```ts
138
+ post<P, A>(
139
+ path,
140
+ requirement,
141
+ handler,
142
+ options?
143
+ ): this;
144
+ ```
145
+
146
+ Register one POST route.
147
+
148
+ ###### Type Parameters
149
+
150
+ | Type Parameter |
151
+ | ---------------------- |
152
+ | `P` _extends_ `string` |
153
+ | `A` |
154
+
155
+ ###### Parameters
156
+
157
+ | Parameter | Type |
158
+ | ------------- | ------------------------------------------------------------------------------------------- |
159
+ | `path` | `P` |
160
+ | `requirement` | [`Requirement`](#requirement)\<`A`\> |
161
+ | `handler` | [`Handler`](#handler)\<`E`, `P`, `A`\> |
162
+ | `options?` | `Readonly`\<\{ `middleware?`: readonly `MiddlewareHandler`\<`E`, `NoInfer`\<`P`\>\>[]; \}\> |
163
+
164
+ ###### Returns
165
+
166
+ `this`
167
+
168
+ ##### put()
169
+
170
+ ```ts
171
+ put<P, A>(
172
+ path,
173
+ requirement,
174
+ handler,
175
+ options?
176
+ ): this;
177
+ ```
178
+
179
+ Register one PUT route.
180
+
181
+ ###### Type Parameters
182
+
183
+ | Type Parameter |
184
+ | ---------------------- |
185
+ | `P` _extends_ `string` |
186
+ | `A` |
187
+
188
+ ###### Parameters
189
+
190
+ | Parameter | Type |
191
+ | ------------- | ------------------------------------------------------------------------------------------- |
192
+ | `path` | `P` |
193
+ | `requirement` | [`Requirement`](#requirement)\<`A`\> |
194
+ | `handler` | [`Handler`](#handler)\<`E`, `P`, `A`\> |
195
+ | `options?` | `Readonly`\<\{ `middleware?`: readonly `MiddlewareHandler`\<`E`, `NoInfer`\<`P`\>\>[]; \}\> |
196
+
197
+ ###### Returns
198
+
199
+ `this`
200
+
201
+ ##### delete()
202
+
203
+ ```ts
204
+ delete<P, A>(
205
+ path,
206
+ requirement,
207
+ handler,
208
+ options?
209
+ ): this;
210
+ ```
211
+
212
+ Register one DELETE route.
213
+
214
+ ###### Type Parameters
215
+
216
+ | Type Parameter |
217
+ | ---------------------- |
218
+ | `P` _extends_ `string` |
219
+ | `A` |
220
+
221
+ ###### Parameters
222
+
223
+ | Parameter | Type |
224
+ | ------------- | ------------------------------------------------------------------------------------------- |
225
+ | `path` | `P` |
226
+ | `requirement` | [`Requirement`](#requirement)\<`A`\> |
227
+ | `handler` | [`Handler`](#handler)\<`E`, `P`, `A`\> |
228
+ | `options?` | `Readonly`\<\{ `middleware?`: readonly `MiddlewareHandler`\<`E`, `NoInfer`\<`P`\>\>[]; \}\> |
229
+
230
+ ###### Returns
231
+
232
+ `this`
233
+
234
+ ##### all()
235
+
236
+ ```ts
237
+ all<P, A>(
238
+ path,
239
+ requirement,
240
+ handler,
241
+ options?
242
+ ): this;
243
+ ```
244
+
245
+ Register one route for every method.
246
+
247
+ ###### Type Parameters
248
+
249
+ | Type Parameter |
250
+ | ---------------------- |
251
+ | `P` _extends_ `string` |
252
+ | `A` |
253
+
254
+ ###### Parameters
255
+
256
+ | Parameter | Type |
257
+ | ------------- | ------------------------------------------------------------------------------------------- |
258
+ | `path` | `P` |
259
+ | `requirement` | [`Requirement`](#requirement)\<`A`\> |
260
+ | `handler` | [`Handler`](#handler)\<`E`, `P`, `A`\> |
261
+ | `options?` | `Readonly`\<\{ `middleware?`: readonly `MiddlewareHandler`\<`E`, `NoInfer`\<`P`\>\>[]; \}\> |
262
+
263
+ ###### Returns
264
+
265
+ `this`
266
+
267
+ ##### on()
268
+
269
+ ```ts
270
+ on<P, A>(
271
+ methods,
272
+ path,
273
+ requirement,
274
+ handler,
275
+ options?
276
+ ): this;
277
+ ```
278
+
279
+ Register one route for several methods.
280
+
281
+ ###### Type Parameters
282
+
283
+ | Type Parameter |
284
+ | ---------------------- |
285
+ | `P` _extends_ `string` |
286
+ | `A` |
287
+
288
+ ###### Parameters
289
+
290
+ | Parameter | Type |
291
+ | ------------- | ------------------------------------------------------------------------------------------- |
292
+ | `methods` | readonly [`Method`](#method)[] |
293
+ | `path` | `P` |
294
+ | `requirement` | [`Requirement`](#requirement)\<`A`\> |
295
+ | `handler` | [`Handler`](#handler)\<`E`, `P`, `A`\> |
296
+ | `options?` | `Readonly`\<\{ `middleware?`: readonly `MiddlewareHandler`\<`E`, `NoInfer`\<`P`\>\>[]; \}\> |
297
+
298
+ ###### Returns
299
+
300
+ `this`
301
+
302
+ ##### include()
303
+
304
+ ```ts
305
+ include(other): this;
306
+ ```
307
+
308
+ Serve another table's routes at this position, keeping its own error handler.
309
+
310
+ ###### Parameters
311
+
312
+ | Parameter | Type |
313
+ | --------- | -------------------------- |
314
+ | `other` | [`Routes`](#routes)\<`E`\> |
315
+
316
+ ###### Returns
317
+
318
+ `this`
319
+
320
+ ##### onError()
321
+
322
+ ```ts
323
+ onError(handler): this;
324
+ ```
325
+
326
+ Answer an error thrown by this table's own handlers.
327
+
328
+ ###### Parameters
329
+
330
+ | Parameter | Type |
331
+ | --------- | --------------------- |
332
+ | `handler` | `ErrorHandler`\<`E`\> |
333
+
334
+ ###### Returns
335
+
336
+ `this`
337
+
338
+ ##### declarations()
339
+
340
+ ```ts
341
+ declarations(): readonly Readonly<{
342
+ methods: readonly Method[] | "ALL";
343
+ path: string;
344
+ requirement: DeclaredRequirement;
345
+ }>[];
346
+ ```
347
+
348
+ Every route this table and its included tables declare, in serving order.
349
+
350
+ ###### Returns
351
+
352
+ readonly `Readonly`\<\{ `methods`: readonly [`Method`](#method)[] \| `"ALL"`;
353
+ `path`: `string`; `requirement`: [`DeclaredRequirement`](#declaredrequirement);
354
+ \}\>[]
355
+
356
+ ## Type Aliases
357
+
358
+ ### OwnerPrincipal
359
+
360
+ ```ts
361
+ type OwnerPrincipal = Readonly<{
362
+ actor: Extract<
363
+ HostActor,
364
+ {
365
+ kind: "member";
366
+ }
367
+ >;
368
+ role: "owner";
369
+ }>;
370
+ ```
371
+
372
+ The owner, as every owner route receives it.
373
+
374
+ ---
375
+
376
+ ### MemberPrincipal
377
+
378
+ ```ts
379
+ type MemberPrincipal = Extract<
380
+ TenantPrincipal,
381
+ {
382
+ role: "owner" | "member";
383
+ }
384
+ >;
385
+ ```
386
+
387
+ A member, owner or not, as member routes receive it.
388
+
389
+ ---
390
+
391
+ ### AuthorityPorts
392
+
393
+ ```ts
394
+ type AuthorityPorts = Readonly<{
395
+ liveKey: (keyId) => Promise<LiveOysterKey | null>;
396
+ appToolPolicy: (
397
+ actor,
398
+ ) => AppToolPolicy | null | Promise<AppToolPolicy | null>;
399
+ }>;
400
+ ```
401
+
402
+ The live facts this module reads to decide; every host supplies the same ports.
403
+
404
+ ---
405
+
406
+ ### Authority
407
+
408
+ ```ts
409
+ type Authority =
410
+ | Readonly<{
411
+ kind: "owner";
412
+ principal: OwnerPrincipal;
413
+ }>
414
+ | Readonly<{
415
+ kind: "member";
416
+ principal: MemberPrincipal;
417
+ }>
418
+ | Readonly<{
419
+ kind: "key";
420
+ principal: TenantPrincipal;
421
+ key: LiveOysterKey | null;
422
+ }>
423
+ | Readonly<{
424
+ kind: "agent";
425
+ principal: TenantPrincipal;
426
+ actor: Extract<
427
+ HostActor,
428
+ {
429
+ kind: "agent";
430
+ }
431
+ >;
432
+ }>;
433
+ ```
434
+
435
+ One request's authority, resolved once from its principal. A key carries its
436
+ live grants, or `null` once it is no longer live, which reaches nothing.
437
+
438
+ ---
439
+
440
+ ### ReachableInstallation
441
+
442
+ ```ts
443
+ type ReachableInstallation = Readonly<{
444
+ installationId: string;
445
+ }>;
446
+ ```
447
+
448
+ One installation as reach decisions see it.
449
+
450
+ ---
451
+
452
+ ### RequestFacts
453
+
454
+ ```ts
455
+ type RequestFacts = Readonly<{
456
+ request: Request;
457
+ param: (name) => string | undefined;
458
+ body: <T>(schema) => Promise<T | null>;
459
+ principal: () => Promise<OysterAuthResult>;
460
+ mediated: boolean;
461
+ ports: AuthorityPorts;
462
+ }>;
463
+ ```
464
+
465
+ The request facts a requirement reads.
466
+
467
+ ---
468
+
469
+ ### RequirementKind
470
+
471
+ ```ts
472
+ type RequirementKind =
473
+ | "public"
474
+ | "door"
475
+ | "owner"
476
+ | "member"
477
+ | "app"
478
+ | "apps"
479
+ | "agent"
480
+ | "agents"
481
+ | "computer";
482
+ ```
483
+
484
+ Every requirement kind; the law test proves each has both outcomes.
485
+
486
+ ---
487
+
488
+ ### DeclaredRequirement
489
+
490
+ ```ts
491
+ type DeclaredRequirement = Readonly<{
492
+ kind: RequirementKind;
493
+ via?: "direct" | "direct-or-app";
494
+ reason?: string;
495
+ }>;
496
+ ```
497
+
498
+ How the law and the host table read one route's requirement.
499
+
500
+ ---
501
+
502
+ ### OwnerOrigin
503
+
504
+ ```ts
505
+ type OwnerOrigin = "owner-direct" | "app";
506
+ ```
507
+
508
+ Where an owner request came from: the owner directly, or an App acting through
509
+ the shell.
510
+
511
+ ---
512
+
513
+ ### OwnerAdmission
514
+
515
+ ```ts
516
+ type OwnerAdmission = Readonly<{
517
+ principal: OwnerPrincipal;
518
+ origin: OwnerOrigin;
519
+ }>;
520
+ ```
521
+
522
+ What an owner route receives.
523
+
524
+ ---
525
+
526
+ ### CollectionAdmission
527
+
528
+ ```ts
529
+ type CollectionAdmission<Item> = Readonly<{
530
+ authority: Authority;
531
+ reaches: (item) => Promise<boolean>;
532
+ }>;
533
+ ```
534
+
535
+ What a collection route receives: the authority and its reach over each item.
536
+
537
+ #### Type Parameters
538
+
539
+ | Type Parameter |
540
+ | -------------- |
541
+ | `Item` |
542
+
543
+ ---
544
+
545
+ ### AgentAdmission
546
+
547
+ ```ts
548
+ type AgentAdmission = Readonly<{
549
+ authority: Authority;
550
+ principal: TenantPrincipal;
551
+ agentId: string;
552
+ }>;
553
+ ```
554
+
555
+ What an Agent route receives.
556
+
557
+ ---
558
+
559
+ ### Method
560
+
561
+ ```ts
562
+ type Method = "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
563
+ ```
564
+
565
+ An HTTP method a route may declare.
566
+
567
+ ---
568
+
569
+ ### RouteDeclaration
570
+
571
+ ```ts
572
+ type RouteDeclaration = Readonly<{
573
+ methods: readonly Method[] | "ALL";
574
+ path: string;
575
+ requirement: DeclaredRequirement;
576
+ }>;
577
+ ```
578
+
579
+ One declared route, as the law test and the host's table read it.
580
+
581
+ ---
582
+
583
+ ### Handler
584
+
585
+ ```ts
586
+ type Handler<E, P, Admitted> = (
587
+ context,
588
+ admitted,
589
+ ) => Response | Promise<Response>;
590
+ ```
591
+
592
+ A handler receives the request and exactly what its requirement admitted.
593
+
594
+ #### Type Parameters
595
+
596
+ | Type Parameter |
597
+ | ---------------------- |
598
+ | `E` _extends_ `Env` |
599
+ | `P` _extends_ `string` |
600
+ | `Admitted` |
601
+
602
+ #### Parameters
603
+
604
+ | Parameter | Type |
605
+ | ---------- | --------------------- |
606
+ | `context` | `Context`\<`E`, `P`\> |
607
+ | `admitted` | `Admitted` |
608
+
609
+ #### Returns
610
+
611
+ `Response` \| `Promise`\<`Response`\>
612
+
613
+ ---
614
+
615
+ ### RouteOptions
616
+
617
+ ```ts
618
+ type RouteOptions<E, P> = Readonly<{
619
+ middleware?: readonly MiddlewareHandler<E, P>[];
620
+ }>;
621
+ ```
622
+
623
+ Per-route options; middleware runs after the requirement admits.
624
+
625
+ #### Type Parameters
626
+
627
+ | Type Parameter |
628
+ | ---------------------- |
629
+ | `E` _extends_ `Env` |
630
+ | `P` _extends_ `string` |
631
+
632
+ ---
633
+
634
+ ### ResponseView
635
+
636
+ ```ts
637
+ type ResponseView = Readonly<{
638
+ status: number;
639
+ headers: Headers;
640
+ }>;
641
+ ```
642
+
643
+ What a header hook may read of a finished response: never its body or request.
644
+
645
+ ---
646
+
647
+ ### ResponseHeaders
648
+
649
+ ```ts
650
+ type ResponseHeaders = (response) => Readonly<Record<string, string>> | null;
651
+ ```
652
+
653
+ One header hook: the headers to add to a finished response, if any.
654
+
655
+ #### Parameters
656
+
657
+ | Parameter | Type |
658
+ | ---------- | ------------------------------- |
659
+ | `response` | [`ResponseView`](#responseview) |
660
+
661
+ #### Returns
662
+
663
+ `Readonly`\<`Record`\<`string`, `string`\>\> \| `null`
664
+
665
+ ---
666
+
667
+ ### HostServeOptions
668
+
669
+ ```ts
670
+ type HostServeOptions = Readonly<{
671
+ headers?: readonly ResponseHeaders[];
672
+ serverTiming?: Readonly<{
673
+ totalDescription: string;
674
+ }>;
675
+ }>;
676
+ ```
677
+
678
+ How the host table is served beyond its principal and ports.
679
+
680
+ ---
681
+
682
+ ### ServedTable
683
+
684
+ ```ts
685
+ type ServedTable<E> = Readonly<{
686
+ fetch: (...request) => Promise<Response>;
687
+ request: (...request) => Promise<Response>;
688
+ servedPaths: () => readonly string[];
689
+ }>;
690
+ ```
691
+
692
+ A served table: it answers requests and names what it serves, and is never a
693
+ router.
694
+
695
+ #### Type Parameters
696
+
697
+ | Type Parameter |
698
+ | ------------------- |
699
+ | `E` _extends_ `Env` |
700
+
701
+ ## Functions
702
+
703
+ ### keyAppAccess()
704
+
705
+ ```ts
706
+ function keyAppAccess(
707
+ key,
708
+ installationId,
709
+ ): {
710
+ level: "read" | "write";
711
+ revision: string;
712
+ grantedBy: string;
713
+ } | null;
714
+ ```
715
+
716
+ One live key's access to one installation: `write` when its grants admit
717
+ `apps.use` there, `read` when they admit `apps.read`, otherwise `null` --
718
+ including for an installation added after the key was issued, unless the key
719
+ holds "All Apps" (`targets: {kind: "all"}`). The same shape as an Agent's stored
720
+ [AppToolPolicy](apps.md#apptoolpolicy); its caller adds `bindingName` (which
721
+ varies by caller: the plain installation id for the gate, the uppercased binding
722
+ name for MCP) to reach the full `AppToolAccess`.
723
+
724
+ #### Parameters
725
+
726
+ | Parameter | Type |
727
+ | ---------------- | ---------------------------------------- |
728
+ | `key` | [`LiveOysterKey`](keys.md#liveoysterkey) |
729
+ | `installationId` | `string` |
730
+
731
+ #### Returns
732
+
733
+ \| \{ `level`: `"read"` \| `"write"`; `revision`: `string`; `grantedBy`:
734
+ `string`; \} \| `null`
735
+
736
+ ---
737
+
738
+ ### keyAgentAccess()
739
+
740
+ ```ts
741
+ function keyAgentAccess(key, agentId): boolean;
742
+ ```
743
+
744
+ Agent access is scoped to the granted Agent ids, never inferred from App grants.
745
+
746
+ #### Parameters
747
+
748
+ | Parameter | Type |
749
+ | --------- | ---------------------------------------- |
750
+ | `key` | [`LiveOysterKey`](keys.md#liveoysterkey) |
751
+ | `agentId` | `string` |
752
+
753
+ #### Returns
754
+
755
+ `boolean`
756
+
757
+ ---
758
+
759
+ ### keyAllowsComputerUse()
760
+
761
+ ```ts
762
+ function keyAllowsComputerUse(key): boolean;
763
+ ```
764
+
765
+ Whether a live key's own grants turn its Computer access on. Off by default.
766
+
767
+ #### Parameters
768
+
769
+ | Parameter | Type |
770
+ | --------- | ---------------------------------------- |
771
+ | `key` | [`LiveOysterKey`](keys.md#liveoysterkey) |
772
+
773
+ #### Returns
774
+
775
+ `boolean`
776
+
777
+ ---
778
+
779
+ ### oysterPrincipalIsOwner()
780
+
781
+ ```ts
782
+ function oysterPrincipalIsOwner(
783
+ principal,
784
+ ): principal is Readonly<{
785
+ actor: { kind: "member"; memberId: string };
786
+ role: "owner";
787
+ }>;
788
+ ```
789
+
790
+ True only for a member admitted with the owner role.
791
+
792
+ #### Parameters
793
+
794
+ | Parameter | Type |
795
+ | ----------- | ---------------------------------------------- |
796
+ | `principal` | [`TenantPrincipal`](tenant.md#tenantprincipal) |
797
+
798
+ #### Returns
799
+
800
+ `principal is Readonly<{ actor: { kind: "member"; memberId: string }; role: "owner" }>`
801
+
802
+ ---
803
+
804
+ ### hostAuthorityPorts()
805
+
806
+ ```ts
807
+ function hostAuthorityPorts(host): AuthorityPorts;
808
+ ```
809
+
810
+ A host's own ports: its key store's liveness and its Agents' tool policy.
811
+
812
+ #### Parameters
813
+
814
+ | Parameter | Type |
815
+ | --------- | --------------------------------------------------------------------------- |
816
+ | `host` | `Pick`\<[`OysterHost`](host.md#oysterhost), `"keys"` \| `"appToolPolicy"`\> |
817
+
818
+ #### Returns
819
+
820
+ [`AuthorityPorts`](#authorityports)
821
+
822
+ ---
823
+
824
+ ### authorityOf()
825
+
826
+ ```ts
827
+ function authorityOf(principal, ports): Promise<Authority>;
828
+ ```
829
+
830
+ Resolve one principal's authority through the live key port.
831
+
832
+ #### Parameters
833
+
834
+ | Parameter | Type |
835
+ | ----------- | ---------------------------------------------- |
836
+ | `principal` | [`TenantPrincipal`](tenant.md#tenantprincipal) |
837
+ | `ports` | [`AuthorityPorts`](#authorityports) |
838
+
839
+ #### Returns
840
+
841
+ `Promise`\<[`Authority`](#authority)\>
842
+
843
+ ---
844
+
845
+ ### reachesAgent()
846
+
847
+ ```ts
848
+ function reachesAgent(authority, agentId): boolean;
849
+ ```
850
+
851
+ Whether this authority reaches one Agent and its Sessions. Only the owner and
852
+ granted keys do.
853
+
854
+ #### Parameters
855
+
856
+ | Parameter | Type |
857
+ | ----------- | ------------------------- |
858
+ | `authority` | [`Authority`](#authority) |
859
+ | `agentId` | `string` |
860
+
861
+ #### Returns
862
+
863
+ `boolean`
864
+
865
+ ---
866
+
867
+ ### reachesComputer()
868
+
869
+ ```ts
870
+ function reachesComputer(authority): boolean;
871
+ ```
872
+
873
+ Whether this authority reaches the host's Computer, its workspace files and the
874
+ media written there. Members do; a key only with `computer.use`; Agents reach a
875
+ Computer only through their own attachment owner.
876
+
877
+ #### Parameters
878
+
879
+ | Parameter | Type |
880
+ | ----------- | ------------------------- |
881
+ | `authority` | [`Authority`](#authority) |
882
+
883
+ #### Returns
884
+
885
+ `boolean`
886
+
887
+ ---
888
+
889
+ ### appToolAccess()
890
+
891
+ ```ts
892
+ function appToolAccess(
893
+ authority,
894
+ installationId,
895
+ ports,
896
+ ): Promise<{
897
+ level: "read" | "write";
898
+ revision: string;
899
+ grantedBy: string;
900
+ } | null>;
901
+ ```
902
+
903
+ A key's or Agent's tool access to one installation, in the App gate's policy
904
+ shape; `null` when it reaches none. Members and the owner hold no tool policy:
905
+ the App gate decides them by role.
906
+
907
+ #### Parameters
908
+
909
+ | Parameter | Type |
910
+ | ---------------- | ----------------------------------- |
911
+ | `authority` | [`Authority`](#authority) |
912
+ | `installationId` | `string` |
913
+ | `ports` | [`AuthorityPorts`](#authorityports) |
914
+
915
+ #### Returns
916
+
917
+ `Promise`\< \| \{ `level`: `"read"` \| `"write"`; `revision`: `string`;
918
+ `grantedBy`: `string`; \} \| `null`\>
919
+
920
+ ---
921
+
922
+ ### reachesInstallation()
923
+
924
+ ```ts
925
+ function reachesInstallation(
926
+ authority,
927
+ installation,
928
+ access,
929
+ ports,
930
+ ): Promise<boolean>;
931
+ ```
932
+
933
+ Whether this authority may see or open one installation at all (the home list,
934
+ Git). A key needs `apps.read` there; `use` needs `apps.use`. Nothing anonymous
935
+ reaches one.
936
+
937
+ #### Parameters
938
+
939
+ | Parameter | Type |
940
+ | -------------- | ------------------------------------------------- |
941
+ | `authority` | [`Authority`](#authority) |
942
+ | `installation` | [`ReachableInstallation`](#reachableinstallation) |
943
+ | `access` | `"read"` \| `"use"` |
944
+ | `ports` | [`AuthorityPorts`](#authorityports) |
945
+
946
+ #### Returns
947
+
948
+ `Promise`\<`boolean`\>
949
+
950
+ ---
951
+
952
+ ### allowsMachineEnrollment()
953
+
954
+ ```ts
955
+ function allowsMachineEnrollment(key): boolean;
956
+ ```
957
+
958
+ Whether a live key's grants permit a one-use device enrollment.
959
+
960
+ #### Parameters
961
+
962
+ | Parameter | Type |
963
+ | --------- | ---------------------------------------- |
964
+ | `key` | [`LiveOysterKey`](keys.md#liveoysterkey) |
965
+
966
+ #### Returns
967
+
968
+ `boolean`
969
+
970
+ ---
971
+
972
+ ### unauthenticated()
973
+
974
+ ```ts
975
+ function unauthenticated(request, result): Response;
976
+ ```
977
+
978
+ A browser page asks to sign in; every other refused request gets its status.
979
+
980
+ #### Parameters
981
+
982
+ | Parameter | Type |
983
+ | --------- | --------------------------------------------------------------------------------------- |
984
+ | `request` | `Request` |
985
+ | `result` | `Extract`\<[`OysterAuthResult`](host.md#oysterauthresult), \{ `kind`: `"refused"`; \}\> |
986
+
987
+ #### Returns
988
+
989
+ `Response`
990
+
991
+ ---
992
+
993
+ ### publicRoute()
994
+
995
+ ```ts
996
+ function publicRoute(reason): Requirement<null>;
997
+ ```
998
+
999
+ Served without any principal: sandboxed App bytes, page assets, sign-in.
1000
+
1001
+ #### Parameters
1002
+
1003
+ | Parameter | Type |
1004
+ | --------- | -------- |
1005
+ | `reason` | `string` |
1006
+
1007
+ #### Returns
1008
+
1009
+ [`Requirement`](#requirement)\<`null`\>
1010
+
1011
+ ---
1012
+
1013
+ ### door()
1014
+
1015
+ ```ts
1016
+ function door(reason): Requirement<null>;
1017
+ ```
1018
+
1019
+ The route verifies its own credential (MCP, Git, signed webhook delivery, device
1020
+ enrollment); `reason` names that credential. A door that reads an Oyster
1021
+ principal decides its reach through this module's functions.
1022
+
1023
+ #### Parameters
1024
+
1025
+ | Parameter | Type |
1026
+ | --------- | -------- |
1027
+ | `reason` | `string` |
1028
+
1029
+ #### Returns
1030
+
1031
+ [`Requirement`](#requirement)\<`null`\>
1032
+
1033
+ ---
1034
+
1035
+ ### owner()
1036
+
1037
+ ```ts
1038
+ function owner(via): Requirement<
1039
+ Readonly<{
1040
+ principal: OwnerPrincipal;
1041
+ origin: OwnerOrigin;
1042
+ }>
1043
+ >;
1044
+ ```
1045
+
1046
+ The owner only. `direct` also refuses an App-mediated request (one the page
1047
+ bridge sends with `X-Oyster-Installation`, and every request a capability table
1048
+ serves): consent and secrets never ride an App.
1049
+
1050
+ #### Parameters
1051
+
1052
+ | Parameter | Type |
1053
+ | --------- | ------------------------------- |
1054
+ | `via` | `"direct"` \| `"direct-or-app"` |
1055
+
1056
+ #### Returns
1057
+
1058
+ [`Requirement`](#requirement)\<`Readonly`\<\{ `principal`:
1059
+ [`OwnerPrincipal`](#ownerprincipal); `origin`: [`OwnerOrigin`](#ownerorigin);
1060
+ \}\>\>
1061
+
1062
+ ---
1063
+
1064
+ ### member()
1065
+
1066
+ ```ts
1067
+ function member(deny?): Requirement<
1068
+ Readonly<{
1069
+ principal: MemberPrincipal;
1070
+ }>
1071
+ >;
1072
+ ```
1073
+
1074
+ Any member, owner or not; never a key or Agent. `deny` shapes the refusal for a
1075
+ contract whose wire already names one.
1076
+
1077
+ #### Parameters
1078
+
1079
+ | Parameter | Type |
1080
+ | --------- | ---------------- |
1081
+ | `deny` | () => `Response` |
1082
+
1083
+ #### Returns
1084
+
1085
+ [`Requirement`](#requirement)\<`Readonly`\<\{ `principal`:
1086
+ [`MemberPrincipal`](#memberprincipal); \}\>\>
1087
+
1088
+ ---
1089
+
1090
+ ### app()
1091
+
1092
+ ```ts
1093
+ function app(): Requirement<
1094
+ Readonly<{
1095
+ principal: TenantPrincipal;
1096
+ }>
1097
+ >;
1098
+ ```
1099
+
1100
+ An App route: any signed-in principal, decided per call by the App gate, which
1101
+ reads this module's [appToolAccess](#apptoolaccess).
1102
+
1103
+ #### Returns
1104
+
1105
+ [`Requirement`](#requirement)\<`Readonly`\<\{ `principal`:
1106
+ [`TenantPrincipal`](tenant.md#tenantprincipal); \}\>\>
1107
+
1108
+ ---
1109
+
1110
+ ### apps()
1111
+
1112
+ ```ts
1113
+ function apps(): Requirement<
1114
+ Readonly<{
1115
+ authority: Authority;
1116
+ reaches: (item) => Promise<boolean>;
1117
+ }>
1118
+ >;
1119
+ ```
1120
+
1121
+ The installation list (the home page): the owner sees all, keys their granted
1122
+ ones.
1123
+
1124
+ #### Returns
1125
+
1126
+ [`Requirement`](#requirement)\<`Readonly`\<\{ `authority`:
1127
+ [`Authority`](#authority); `reaches`: (`item`) => `Promise`\<`boolean`\>; \}\>\>
1128
+
1129
+ ---
1130
+
1131
+ ### agent()
1132
+
1133
+ ```ts
1134
+ function agent(id?): Requirement<
1135
+ Readonly<{
1136
+ authority: Authority;
1137
+ principal: TenantPrincipal;
1138
+ agentId: string;
1139
+ }>
1140
+ >;
1141
+ ```
1142
+
1143
+ One Agent, named by the route's `:agentId` (or by `id` from the request): the
1144
+ owner, or a key granted `agents.use` for that Agent id.
1145
+
1146
+ #### Parameters
1147
+
1148
+ | Parameter | Type |
1149
+ | --------- | -------------------------------------------- |
1150
+ | `id` | (`facts`) => `Promise`\<`string` \| `null`\> |
1151
+
1152
+ #### Returns
1153
+
1154
+ [`Requirement`](#requirement)\<`Readonly`\<\{ `authority`:
1155
+ [`Authority`](#authority); `principal`:
1156
+ [`TenantPrincipal`](tenant.md#tenantprincipal); `agentId`: `string`; \}\>\>
1157
+
1158
+ ---
1159
+
1160
+ ### agents()
1161
+
1162
+ ```ts
1163
+ function agents(): Requirement<
1164
+ Readonly<{
1165
+ authority: Authority;
1166
+ reaches: (item) => Promise<boolean>;
1167
+ }>
1168
+ >;
1169
+ ```
1170
+
1171
+ Agents (and their inbox rows): the owner sees all, a key its granted Agents.
1172
+
1173
+ #### Returns
1174
+
1175
+ [`Requirement`](#requirement)\<`Readonly`\<\{ `authority`:
1176
+ [`Authority`](#authority); `reaches`: (`item`) => `Promise`\<`boolean`\>; \}\>\>
1177
+
1178
+ ---
1179
+
1180
+ ### computer()
1181
+
1182
+ ```ts
1183
+ function computer(): Requirement<
1184
+ Readonly<{
1185
+ principal: TenantPrincipal;
1186
+ }>
1187
+ >;
1188
+ ```
1189
+
1190
+ The host's Computer, its workspace files and media: see
1191
+ [reachesComputer](#reachescomputer).
1192
+
1193
+ #### Returns
1194
+
1195
+ [`Requirement`](#requirement)\<`Readonly`\<\{ `principal`:
1196
+ [`TenantPrincipal`](tenant.md#tenantprincipal); \}\>\>
1197
+
1198
+ ---
1199
+
1200
+ ### routes()
1201
+
1202
+ ```ts
1203
+ function routes<E>(): Routes<E>;
1204
+ ```
1205
+
1206
+ Start a declared route table.
1207
+
1208
+ #### Type Parameters
1209
+
1210
+ | Type Parameter |
1211
+ | ------------------- |
1212
+ | `E` _extends_ `Env` |
1213
+
1214
+ #### Returns
1215
+
1216
+ [`Routes`](#routes)\<`E`\>
1217
+
1218
+ ---
1219
+
1220
+ ### serveHost()
1221
+
1222
+ ```ts
1223
+ function serveHost<E>(table, authenticate, ports, options?): ServedTable<E>;
1224
+ ```
1225
+
1226
+ Serve a tenant host's table: the composition root (`oysterRouteTable`) supplies
1227
+ how a request authenticates. An option this function does not know is refused
1228
+ rather than ignored.
1229
+
1230
+ #### Type Parameters
1231
+
1232
+ | Type Parameter |
1233
+ | ------------------- |
1234
+ | `E` _extends_ `Env` |
1235
+
1236
+ #### Parameters
1237
+
1238
+ | Parameter | Type |
1239
+ | -------------- | -------------------------------------------------------------------------- |
1240
+ | `table` | [`Routes`](#routes)\<`E`\> |
1241
+ | `authenticate` | (`request`) => `Promise`\<[`OysterAuthResult`](host.md#oysterauthresult)\> |
1242
+ | `ports` | [`AuthorityPorts`](#authorityports) |
1243
+ | `options` | [`HostServeOptions`](#hostserveoptions) |
1244
+
1245
+ #### Returns
1246
+
1247
+ [`ServedTable`](#servedtable)\<`E`\>
1248
+
1249
+ ---
1250
+
1251
+ ### serveDoors()
1252
+
1253
+ ```ts
1254
+ function serveDoors<E>(table): ServedTable<E>;
1255
+ ```
1256
+
1257
+ Serve a table of doors and public routes only (a Worker's top-level dispatch,
1258
+ before any tenant is selected): a route that needs an Oyster principal is
1259
+ refused, never admitted.
1260
+
1261
+ #### Type Parameters
1262
+
1263
+ | Type Parameter |
1264
+ | ------------------- |
1265
+ | `E` _extends_ `Env` |
1266
+
1267
+ #### Parameters
1268
+
1269
+ | Parameter | Type |
1270
+ | --------- | -------------------------- |
1271
+ | `table` | [`Routes`](#routes)\<`E`\> |
1272
+
1273
+ #### Returns
1274
+
1275
+ [`ServedTable`](#servedtable)\<`E`\>
1276
+
1277
+ ---
1278
+
1279
+ ### serveCapability()
1280
+
1281
+ ```ts
1282
+ function serveCapability(table, ports): ServedTable<CapabilityEnv>;
1283
+ ```
1284
+
1285
+ Serve one capability's declared table under the host dispatcher's admission,
1286
+ read from `c.env`: the App already holds the capability, and each route still
1287
+ decides its own resource. Every request here is App-mediated, however it was
1288
+ admitted (a header or a browser socket's query), so `owner("direct")` always
1289
+ refuses inside a capability.
1290
+
1291
+ #### Parameters
1292
+
1293
+ | Parameter | Type |
1294
+ | --------- | --------------------------------------------------------------- |
1295
+ | `table` | [`Routes`](#routes)\<[`CapabilityEnv`](host.md#capabilityenv)\> |
1296
+ | `ports` | [`AuthorityPorts`](#authorityports) |
1297
+
1298
+ #### Returns
1299
+
1300
+ [`ServedTable`](#servedtable)\<[`CapabilityEnv`](host.md#capabilityenv)\>