@fungi.computer/oyster 0.32.0 → 0.34.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 (77) hide show
  1. package/README.md +59 -0
  2. package/dist/app-sandbox.d.ts +2 -2
  3. package/dist/app-sandbox.js +2 -2
  4. package/dist/app-test-copies.d.ts +87 -0
  5. package/dist/app-test-copies.js +170 -0
  6. package/dist/app-test-copy-page.d.ts +4 -0
  7. package/dist/app-test-copy-page.js +89 -0
  8. package/dist/approval-deadline.d.ts +2 -0
  9. package/dist/approval-deadline.js +7 -0
  10. package/dist/approval-home.d.ts +26 -3
  11. package/dist/approval-home.js +148 -18
  12. package/dist/apps/index.d.ts +1 -1
  13. package/dist/apps/index.js +1 -1
  14. package/dist/browser/operations.d.ts +1 -1
  15. package/dist/cloudflare.d.ts +68 -3
  16. package/dist/cloudflare.js +214 -3
  17. package/dist/embed-metafiles.js +2 -2
  18. package/dist/embed-scripts.js +1 -1
  19. package/dist/host.d.ts +20 -4
  20. package/dist/host.js +314 -3
  21. package/dist/installation-operations.d.ts +247 -8
  22. package/dist/installation-operations.js +145 -7
  23. package/dist/installation-recovery-page.d.ts +24 -0
  24. package/dist/installation-recovery-page.js +168 -0
  25. package/dist/mcp.js +42 -13
  26. package/dist/older-oyster-store.d.ts +1 -1
  27. package/dist/older-oyster-store.js +2 -4
  28. package/dist/page/app-permissions.js +8 -7
  29. package/dist/page/computer-handles.d.ts +0 -1
  30. package/dist/page/mount.d.ts +2 -101
  31. package/dist/page/mount.js +1 -22
  32. package/dist/page-config.d.ts +102 -0
  33. package/dist/page-config.js +24 -0
  34. package/dist/page-script.js +2 -2
  35. package/dist/platform-skills.generated.d.ts +5 -2
  36. package/dist/platform-skills.generated.js +6 -2
  37. package/dist/recovery-style.d.ts +5 -0
  38. package/dist/recovery-style.js +32 -0
  39. package/dist/standalone/agents.d.ts +1 -1
  40. package/dist/standalone/agents.js +43 -7
  41. package/dist/standalone/computer-fleet.js +3 -0
  42. package/dist/standalone/computer.d.ts +6 -2
  43. package/dist/standalone/computer.js +27 -14
  44. package/dist/standalone/media.js +7 -2
  45. package/dist/standalone/preview.d.ts +21 -20
  46. package/dist/standalone/preview.js +147 -151
  47. package/dist/standalone/registry.d.ts +14 -21
  48. package/dist/standalone/registry.js +74 -28
  49. package/dist/standalone/worker.js +6 -3
  50. package/dist/starter-agent.d.ts +6 -2
  51. package/dist/starter-agent.js +25 -4
  52. package/dist/upgrade/old-worker-http.d.ts +2 -0
  53. package/dist/upgrade/old-worker-http.js +22 -0
  54. package/dist/upgrade/old-worker-readonly.d.ts +14 -0
  55. package/dist/upgrade/old-worker-readonly.js +22 -0
  56. package/dist/upgrade/old-worker-sql.d.ts +10 -0
  57. package/dist/upgrade/old-worker-sql.js +68 -0
  58. package/dist/upgrade/old-worker-stream.d.ts +12 -0
  59. package/dist/upgrade/old-worker-stream.js +54 -0
  60. package/dist/upgrade/private-stage.d.ts +23 -0
  61. package/dist/upgrade/private-stage.js +109 -0
  62. package/dist/upgrade/standalone-001.d.ts +16 -0
  63. package/dist/upgrade/standalone-001.js +31 -0
  64. package/dist/upgrade/standalone-01.d.ts +37 -0
  65. package/dist/upgrade/standalone-01.js +55 -0
  66. package/dist/upgrade/standalone-02.d.ts +37 -0
  67. package/dist/upgrade/standalone-02.js +55 -0
  68. package/dist/workers.d.ts +45 -14
  69. package/dist/workers.js +198 -21
  70. package/docs/api/README.md +8 -3
  71. package/docs/api/apps.md +21 -0
  72. package/docs/api/cloudflare.md +57 -0
  73. package/docs/api/host.md +263 -25
  74. package/docs/api/page/mount.md +13 -81
  75. package/docs/api/workers-git.md +246 -1
  76. package/docs/api/workers.md +518 -95
  77. package/package.json +38 -24
@@ -328,7 +328,12 @@ export declare const installationOperationSchema: z.ZodDiscriminatedUnion<[z.Zod
328
328
  }, z.core.$strict>], "state">;
329
329
  /** The owner's answer about one installation request. */
330
330
  export type InstallationOperation = z.output<typeof installationOperationSchema>;
331
- declare const installationAdmissionSchema: z.ZodObject<{
331
+ /** The owner selects the recovery Release; the caller only fences its observation. */
332
+ export declare const installationRecoverySelectionSchema: z.ZodObject<{
333
+ authorityVersion: z.ZodNumber;
334
+ storeGeneration: z.ZodString;
335
+ }, z.core.$strict>;
336
+ declare const installationAdmissionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
332
337
  requestId: z.ZodString;
333
338
  installationId: z.ZodLazy<z.ZodString>;
334
339
  release: z.ZodPipe<z.ZodUnknown, z.ZodTransform<{
@@ -363,11 +368,92 @@ declare const installationAdmissionSchema: z.ZodObject<{
363
368
  "owner-direct": "owner-direct";
364
369
  workflow: "workflow";
365
370
  }>;
366
- }, z.core.$strict>;
371
+ }, z.core.$strict>, z.ZodObject<{
372
+ authorityVersion: z.ZodNumber;
373
+ storeGeneration: z.ZodString;
374
+ requestId: z.ZodString;
375
+ installationId: z.ZodLazy<z.ZodString>;
376
+ actor: import("zod/mini").ZodMiniDiscriminatedUnion<[import("zod/mini").ZodMiniObject<{
377
+ kind: import("zod/mini").ZodMiniLiteral<"member">;
378
+ memberId: import("zod/mini").ZodMiniString<string>;
379
+ }, z.core.$strip>, import("zod/mini").ZodMiniObject<{
380
+ kind: import("zod/mini").ZodMiniLiteral<"agent">;
381
+ agentId: import("zod/mini").ZodMiniString<string>;
382
+ }, z.core.$strip>, import("zod/mini").ZodMiniObject<{
383
+ kind: import("zod/mini").ZodMiniLiteral<"team-key">;
384
+ keyId: import("zod/mini").ZodMiniString<string>;
385
+ }, z.core.$strip>], "kind">;
386
+ intent: z.ZodLiteral<"rollback">;
387
+ origin: z.ZodLiteral<"owner-direct">;
388
+ }, z.core.$strict>], "intent">;
367
389
  export type InstallationAdmission = z.output<typeof installationAdmissionSchema>;
390
+ declare const installationRecoverySchema: z.ZodObject<{
391
+ authorityVersion: z.ZodNumber;
392
+ storeGeneration: z.ZodString;
393
+ release: z.ZodPipe<z.ZodUnknown, z.ZodTransform<{
394
+ readonly releaseId: import("@fungi.computer/puffball").ReleaseId;
395
+ readonly appId: import("@fungi.computer/puffball").AppId;
396
+ readonly artifact: {
397
+ readonly artifactRef: import("@fungi.computer/puffball").ArtifactRef;
398
+ readonly artifactDigest: import("@fungi.computer/puffball").Sha256Digest;
399
+ readonly provenance: {
400
+ readonly sourceRevision: import("@fungi.computer/puffball").SourceRevision;
401
+ readonly sourceTreeDigest: import("@fungi.computer/puffball").Sha256Digest;
402
+ readonly buildRecipeDigest: import("@fungi.computer/puffball").Sha256Digest;
403
+ };
404
+ };
405
+ }, unknown>>;
406
+ uiCheck: z.ZodDiscriminatedUnion<[z.ZodObject<{
407
+ kind: z.ZodLiteral<"passed">;
408
+ }, z.core.$strict>, z.ZodObject<{
409
+ kind: z.ZodLiteral<"failed">;
410
+ code: z.ZodLiteral<"ui_mount_failed">;
411
+ diagnostics: z.ZodOptional<z.ZodObject<{
412
+ failedPredicate: z.ZodEnum<{
413
+ unexpected_candidate_request: "unexpected_candidate_request";
414
+ response_status: "response_status";
415
+ request_failed: "request_failed";
416
+ page_error: "page_error";
417
+ candidate_not_mounted: "candidate_not_mounted";
418
+ }>;
419
+ errorName: z.ZodOptional<z.ZodEnum<{
420
+ TypeError: "TypeError";
421
+ RangeError: "RangeError";
422
+ SyntaxError: "SyntaxError";
423
+ AbortError: "AbortError";
424
+ TimeoutError: "TimeoutError";
425
+ Other: "Other";
426
+ Error: "Error";
427
+ }>>;
428
+ finalUrlPath: z.ZodString;
429
+ consoleErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
430
+ pageErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
431
+ failedRequests: z.ZodArray<z.ZodObject<{
432
+ path: z.ZodString;
433
+ status: z.ZodOptional<z.ZodNumber>;
434
+ failureKind: z.ZodOptional<z.ZodEnum<{
435
+ unexpected_candidate_request: "unexpected_candidate_request";
436
+ response_status: "response_status";
437
+ request_failed: "request_failed";
438
+ }>>;
439
+ }, z.core.$strict>>;
440
+ droppedCount: z.ZodNumber;
441
+ }, z.core.$strict>>;
442
+ }, z.core.$strict>, z.ZodObject<{
443
+ kind: z.ZodLiteral<"not_checked">;
444
+ code: z.ZodEnum<{
445
+ boot_runner_unavailable: "boot_runner_unavailable";
446
+ boot_browser_binding_missing: "boot_browser_binding_missing";
447
+ boot_clone_unavailable: "boot_clone_unavailable";
448
+ boot_timeout: "boot_timeout";
449
+ boot_cleanup_failed: "boot_cleanup_failed";
450
+ ui_check_not_run_on_host: "ui_check_not_run_on_host";
451
+ }>;
452
+ }, z.core.$strict>], "kind">;
453
+ }, z.core.$strict>;
368
454
  /** Retained intent and exact baseline; recovery never re-reduces a newer row. */
369
455
  export declare const retainedInstallationCommandSchema: z.ZodObject<{
370
- admission: z.ZodObject<{
456
+ admission: z.ZodDiscriminatedUnion<[z.ZodObject<{
371
457
  requestId: z.ZodString;
372
458
  installationId: z.ZodLazy<z.ZodString>;
373
459
  release: z.ZodPipe<z.ZodUnknown, z.ZodTransform<{
@@ -402,7 +488,37 @@ export declare const retainedInstallationCommandSchema: z.ZodObject<{
402
488
  "owner-direct": "owner-direct";
403
489
  workflow: "workflow";
404
490
  }>;
405
- }, z.core.$strict>;
491
+ }, z.core.$strict>, z.ZodObject<{
492
+ authorityVersion: z.ZodNumber;
493
+ storeGeneration: z.ZodString;
494
+ requestId: z.ZodString;
495
+ installationId: z.ZodLazy<z.ZodString>;
496
+ actor: import("zod/mini").ZodMiniDiscriminatedUnion<[import("zod/mini").ZodMiniObject<{
497
+ kind: import("zod/mini").ZodMiniLiteral<"member">;
498
+ memberId: import("zod/mini").ZodMiniString<string>;
499
+ }, z.core.$strip>, import("zod/mini").ZodMiniObject<{
500
+ kind: import("zod/mini").ZodMiniLiteral<"agent">;
501
+ agentId: import("zod/mini").ZodMiniString<string>;
502
+ }, z.core.$strip>, import("zod/mini").ZodMiniObject<{
503
+ kind: import("zod/mini").ZodMiniLiteral<"team-key">;
504
+ keyId: import("zod/mini").ZodMiniString<string>;
505
+ }, z.core.$strip>], "kind">;
506
+ intent: z.ZodLiteral<"rollback">;
507
+ origin: z.ZodLiteral<"owner-direct">;
508
+ release: z.ZodPipe<z.ZodUnknown, z.ZodTransform<{
509
+ readonly releaseId: import("@fungi.computer/puffball").ReleaseId;
510
+ readonly appId: import("@fungi.computer/puffball").AppId;
511
+ readonly artifact: {
512
+ readonly artifactRef: import("@fungi.computer/puffball").ArtifactRef;
513
+ readonly artifactDigest: import("@fungi.computer/puffball").Sha256Digest;
514
+ readonly provenance: {
515
+ readonly sourceRevision: import("@fungi.computer/puffball").SourceRevision;
516
+ readonly sourceTreeDigest: import("@fungi.computer/puffball").Sha256Digest;
517
+ readonly buildRecipeDigest: import("@fungi.computer/puffball").Sha256Digest;
518
+ };
519
+ };
520
+ }, unknown>>;
521
+ }, z.core.$strict>], "intent">;
406
522
  scope: z.ZodObject<{
407
523
  tenantId: z.ZodPipe<z.ZodUnknown, z.ZodTransform<string & import("effect/Brand").Brand<"OysterTenantId">, unknown>>;
408
524
  origin: z.ZodURL;
@@ -600,6 +716,8 @@ export declare const retainedInstallationCommandSchema: z.ZodObject<{
600
716
  export type RetainedInstallationCommand = z.output<typeof retainedInstallationCommandSchema>;
601
717
  /** Host-side port; RPC transport and tenant context belong to the adapter. */
602
718
  export type InstallationOperations = Readonly<{
719
+ /** The prior confirmed activation, fenced to the current store and authority. */
720
+ recovery(installationId: string): Promise<InstallationRecovery | null>;
603
721
  /** Accept one command, or replay the retained operation for its request id. */
604
722
  admit(input: InstallationAdmission): Promise<InstallationOperation>;
605
723
  /** The operation's current state, when it names this installation. */
@@ -617,6 +735,7 @@ export type InstallationOperations = Readonly<{
617
735
  /** Commit the planned installation against its exact baseline. */
618
736
  commit(requestId: string, uiCheck: UiBootCheckOutcome | null): Promise<InstallationCommit>;
619
737
  }>;
738
+ export type InstallationRecovery = z.output<typeof installationRecoverySchema>;
620
739
  /**
621
740
  * One owner wait's bound, under ordinary HTTP idle timeouts; an observer that
622
741
  * needs longer simply waits again.
@@ -625,12 +744,19 @@ export declare const maxSettlementWaitMs = 25000;
625
744
  /** The status door's optional `waitMs` query: whole milliseconds, bounded. */
626
745
  export declare const installationWaitQuerySchema: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
627
746
  declare const installationOperationRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
747
+ action: z.ZodLiteral<"recovery">;
748
+ scope: z.ZodObject<{
749
+ tenantId: z.ZodPipe<z.ZodUnknown, z.ZodTransform<string & import("effect/Brand").Brand<"OysterTenantId">, unknown>>;
750
+ origin: z.ZodURL;
751
+ }, z.core.$strict>;
752
+ installationId: z.ZodLazy<z.ZodString>;
753
+ }, z.core.$strict>, z.ZodObject<{
628
754
  action: z.ZodLiteral<"admit">;
629
755
  scope: z.ZodObject<{
630
756
  tenantId: z.ZodPipe<z.ZodUnknown, z.ZodTransform<string & import("effect/Brand").Brand<"OysterTenantId">, unknown>>;
631
757
  origin: z.ZodURL;
632
758
  }, z.core.$strict>;
633
- input: z.ZodObject<{
759
+ input: z.ZodDiscriminatedUnion<[z.ZodObject<{
634
760
  requestId: z.ZodString;
635
761
  installationId: z.ZodLazy<z.ZodString>;
636
762
  release: z.ZodPipe<z.ZodUnknown, z.ZodTransform<{
@@ -665,7 +791,24 @@ declare const installationOperationRequestSchema: z.ZodDiscriminatedUnion<[z.Zod
665
791
  "owner-direct": "owner-direct";
666
792
  workflow: "workflow";
667
793
  }>;
668
- }, z.core.$strict>;
794
+ }, z.core.$strict>, z.ZodObject<{
795
+ authorityVersion: z.ZodNumber;
796
+ storeGeneration: z.ZodString;
797
+ requestId: z.ZodString;
798
+ installationId: z.ZodLazy<z.ZodString>;
799
+ actor: import("zod/mini").ZodMiniDiscriminatedUnion<[import("zod/mini").ZodMiniObject<{
800
+ kind: import("zod/mini").ZodMiniLiteral<"member">;
801
+ memberId: import("zod/mini").ZodMiniString<string>;
802
+ }, z.core.$strip>, import("zod/mini").ZodMiniObject<{
803
+ kind: import("zod/mini").ZodMiniLiteral<"agent">;
804
+ agentId: import("zod/mini").ZodMiniString<string>;
805
+ }, z.core.$strip>, import("zod/mini").ZodMiniObject<{
806
+ kind: import("zod/mini").ZodMiniLiteral<"team-key">;
807
+ keyId: import("zod/mini").ZodMiniString<string>;
808
+ }, z.core.$strip>], "kind">;
809
+ intent: z.ZodLiteral<"rollback">;
810
+ origin: z.ZodLiteral<"owner-direct">;
811
+ }, z.core.$strict>], "intent">;
669
812
  }, z.core.$strict>, z.ZodObject<{
670
813
  action: z.ZodLiteral<"read">;
671
814
  scope: z.ZodObject<{
@@ -810,6 +953,72 @@ declare const installationOperationRequestSchema: z.ZodDiscriminatedUnion<[z.Zod
810
953
  }, z.core.$strict>], "action">;
811
954
  export type InstallationOperationRequest = z.output<typeof installationOperationRequestSchema>;
812
955
  declare const installationOperationReplySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
956
+ kind: z.ZodLiteral<"recovery">;
957
+ recovery: z.ZodNullable<z.ZodObject<{
958
+ authorityVersion: z.ZodNumber;
959
+ storeGeneration: z.ZodString;
960
+ release: z.ZodPipe<z.ZodUnknown, z.ZodTransform<{
961
+ readonly releaseId: import("@fungi.computer/puffball").ReleaseId;
962
+ readonly appId: import("@fungi.computer/puffball").AppId;
963
+ readonly artifact: {
964
+ readonly artifactRef: import("@fungi.computer/puffball").ArtifactRef;
965
+ readonly artifactDigest: import("@fungi.computer/puffball").Sha256Digest;
966
+ readonly provenance: {
967
+ readonly sourceRevision: import("@fungi.computer/puffball").SourceRevision;
968
+ readonly sourceTreeDigest: import("@fungi.computer/puffball").Sha256Digest;
969
+ readonly buildRecipeDigest: import("@fungi.computer/puffball").Sha256Digest;
970
+ };
971
+ };
972
+ }, unknown>>;
973
+ uiCheck: z.ZodDiscriminatedUnion<[z.ZodObject<{
974
+ kind: z.ZodLiteral<"passed">;
975
+ }, z.core.$strict>, z.ZodObject<{
976
+ kind: z.ZodLiteral<"failed">;
977
+ code: z.ZodLiteral<"ui_mount_failed">;
978
+ diagnostics: z.ZodOptional<z.ZodObject<{
979
+ failedPredicate: z.ZodEnum<{
980
+ unexpected_candidate_request: "unexpected_candidate_request";
981
+ response_status: "response_status";
982
+ request_failed: "request_failed";
983
+ page_error: "page_error";
984
+ candidate_not_mounted: "candidate_not_mounted";
985
+ }>;
986
+ errorName: z.ZodOptional<z.ZodEnum<{
987
+ TypeError: "TypeError";
988
+ RangeError: "RangeError";
989
+ SyntaxError: "SyntaxError";
990
+ AbortError: "AbortError";
991
+ TimeoutError: "TimeoutError";
992
+ Other: "Other";
993
+ Error: "Error";
994
+ }>>;
995
+ finalUrlPath: z.ZodString;
996
+ consoleErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
997
+ pageErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
998
+ failedRequests: z.ZodArray<z.ZodObject<{
999
+ path: z.ZodString;
1000
+ status: z.ZodOptional<z.ZodNumber>;
1001
+ failureKind: z.ZodOptional<z.ZodEnum<{
1002
+ unexpected_candidate_request: "unexpected_candidate_request";
1003
+ response_status: "response_status";
1004
+ request_failed: "request_failed";
1005
+ }>>;
1006
+ }, z.core.$strict>>;
1007
+ droppedCount: z.ZodNumber;
1008
+ }, z.core.$strict>>;
1009
+ }, z.core.$strict>, z.ZodObject<{
1010
+ kind: z.ZodLiteral<"not_checked">;
1011
+ code: z.ZodEnum<{
1012
+ boot_runner_unavailable: "boot_runner_unavailable";
1013
+ boot_browser_binding_missing: "boot_browser_binding_missing";
1014
+ boot_clone_unavailable: "boot_clone_unavailable";
1015
+ boot_timeout: "boot_timeout";
1016
+ boot_cleanup_failed: "boot_cleanup_failed";
1017
+ ui_check_not_run_on_host: "ui_check_not_run_on_host";
1018
+ }>;
1019
+ }, z.core.$strict>], "kind">;
1020
+ }, z.core.$strict>>;
1021
+ }, z.core.$strict>, z.ZodObject<{
813
1022
  kind: z.ZodLiteral<"refused">;
814
1023
  code: z.ZodEnum<{
815
1024
  unavailable: "unavailable";
@@ -1020,7 +1229,7 @@ declare const installationOperationReplySchema: z.ZodDiscriminatedUnion<[z.ZodOb
1020
1229
  }, z.core.$strict>, z.ZodObject<{
1021
1230
  kind: z.ZodLiteral<"command">;
1022
1231
  command: z.ZodNullable<z.ZodObject<{
1023
- admission: z.ZodObject<{
1232
+ admission: z.ZodDiscriminatedUnion<[z.ZodObject<{
1024
1233
  requestId: z.ZodString;
1025
1234
  installationId: z.ZodLazy<z.ZodString>;
1026
1235
  release: z.ZodPipe<z.ZodUnknown, z.ZodTransform<{
@@ -1055,7 +1264,37 @@ declare const installationOperationReplySchema: z.ZodDiscriminatedUnion<[z.ZodOb
1055
1264
  "owner-direct": "owner-direct";
1056
1265
  workflow: "workflow";
1057
1266
  }>;
1058
- }, z.core.$strict>;
1267
+ }, z.core.$strict>, z.ZodObject<{
1268
+ authorityVersion: z.ZodNumber;
1269
+ storeGeneration: z.ZodString;
1270
+ requestId: z.ZodString;
1271
+ installationId: z.ZodLazy<z.ZodString>;
1272
+ actor: import("zod/mini").ZodMiniDiscriminatedUnion<[import("zod/mini").ZodMiniObject<{
1273
+ kind: import("zod/mini").ZodMiniLiteral<"member">;
1274
+ memberId: import("zod/mini").ZodMiniString<string>;
1275
+ }, z.core.$strip>, import("zod/mini").ZodMiniObject<{
1276
+ kind: import("zod/mini").ZodMiniLiteral<"agent">;
1277
+ agentId: import("zod/mini").ZodMiniString<string>;
1278
+ }, z.core.$strip>, import("zod/mini").ZodMiniObject<{
1279
+ kind: import("zod/mini").ZodMiniLiteral<"team-key">;
1280
+ keyId: import("zod/mini").ZodMiniString<string>;
1281
+ }, z.core.$strip>], "kind">;
1282
+ intent: z.ZodLiteral<"rollback">;
1283
+ origin: z.ZodLiteral<"owner-direct">;
1284
+ release: z.ZodPipe<z.ZodUnknown, z.ZodTransform<{
1285
+ readonly releaseId: import("@fungi.computer/puffball").ReleaseId;
1286
+ readonly appId: import("@fungi.computer/puffball").AppId;
1287
+ readonly artifact: {
1288
+ readonly artifactRef: import("@fungi.computer/puffball").ArtifactRef;
1289
+ readonly artifactDigest: import("@fungi.computer/puffball").Sha256Digest;
1290
+ readonly provenance: {
1291
+ readonly sourceRevision: import("@fungi.computer/puffball").SourceRevision;
1292
+ readonly sourceTreeDigest: import("@fungi.computer/puffball").Sha256Digest;
1293
+ readonly buildRecipeDigest: import("@fungi.computer/puffball").Sha256Digest;
1294
+ };
1295
+ };
1296
+ }, unknown>>;
1297
+ }, z.core.$strict>], "intent">;
1059
1298
  scope: z.ZodObject<{
1060
1299
  tenantId: z.ZodPipe<z.ZodUnknown, z.ZodTransform<string & import("effect/Brand").Brand<"OysterTenantId">, unknown>>;
1061
1300
  origin: z.ZodURL;
@@ -87,7 +87,7 @@ export const installationOperationSchema = z.discriminatedUnion("state", [
87
87
  refusalSchema.extend(identity),
88
88
  unconfirmedSchema.extend(identity),
89
89
  ]);
90
- const installationAdmissionSchema = z.strictObject({
90
+ const directInstallationAdmissionSchema = z.strictObject({
91
91
  requestId: installationRequestIdSchema,
92
92
  installationId: installationIdSchema,
93
93
  release: releaseCodec,
@@ -96,6 +96,41 @@ const installationAdmissionSchema = z.strictObject({
96
96
  // A Workflow may reuse the owner's approval, never grant new authority.
97
97
  origin: z.enum(["owner-direct", "workflow"]),
98
98
  });
99
+ /** The owner selects the recovery Release; the caller only fences its observation. */
100
+ export const installationRecoverySelectionSchema = z.strictObject({
101
+ authorityVersion: z.number().int().positive(),
102
+ storeGeneration: z.string().min(1),
103
+ });
104
+ const rollbackAdmissionSchema = installationRecoverySelectionSchema.extend({
105
+ requestId: installationRequestIdSchema,
106
+ installationId: installationIdSchema,
107
+ actor: hostActorSchema,
108
+ intent: z.literal("rollback"),
109
+ origin: z.literal("owner-direct"),
110
+ });
111
+ const installationAdmissionSchema = z.discriminatedUnion("intent", [
112
+ directInstallationAdmissionSchema,
113
+ rollbackAdmissionSchema,
114
+ ]);
115
+ const resolvedAdmissionSchema = z.discriminatedUnion("intent", [
116
+ directInstallationAdmissionSchema,
117
+ rollbackAdmissionSchema.extend({ release: releaseCodec }),
118
+ ]);
119
+ const activatedReleaseSchema = z.strictObject({
120
+ release: releaseCodec,
121
+ uiCheck: uiBootCheckOutcomeSchema,
122
+ });
123
+ const recoveryRecordSchema = z.strictObject({
124
+ scope: scopeSchema,
125
+ generation: z.string().min(1),
126
+ instanceId: ownerCodec(instanceIdSchema).nullable(),
127
+ current: activatedReleaseSchema,
128
+ previous: activatedReleaseSchema.nullable(),
129
+ });
130
+ const installationRecoverySchema = installationRecoverySelectionSchema.extend({
131
+ release: releaseCodec,
132
+ uiCheck: uiBootCheckOutcomeSchema,
133
+ });
99
134
  const planSchema = z
100
135
  .strictObject({
101
136
  installation: installationSchema,
@@ -108,7 +143,7 @@ const planSchema = z
108
143
  (plan.installation.status !== "enabled" || plan.uiCheck !== null)));
109
144
  /** Retained intent and exact baseline; recovery never re-reduces a newer row. */
110
145
  export const retainedInstallationCommandSchema = z.strictObject({
111
- admission: installationAdmissionSchema,
146
+ admission: resolvedAdmissionSchema,
112
147
  scope: scopeSchema,
113
148
  installationId: installationIdSchema,
114
149
  instanceId: ownerCodec(instanceIdSchema),
@@ -133,7 +168,11 @@ const storedCommandSchema = z.union([
133
168
  settledInstallationCommandSchema,
134
169
  ]);
135
170
  const inputDigest = (input) => createHash("sha256")
136
- .update(JSON.stringify(installationAdmissionSchema.parse(input)))
171
+ .update(JSON.stringify(
172
+ // A resolved rollback adds the owner's Release, not caller input.
173
+ (input.intent === "rollback"
174
+ ? rollbackAdmissionSchema.strip()
175
+ : directInstallationAdmissionSchema).parse(input)))
137
176
  .digest("hex");
138
177
  /**
139
178
  * One owner wait's bound, under ordinary HTTP idle timeouts; an observer that
@@ -148,6 +187,11 @@ export const installationWaitQuerySchema = z
148
187
  .pipe(z.number().int().max(maxSettlementWaitMs))
149
188
  .optional();
150
189
  const installationOperationRequestSchema = z.discriminatedUnion("action", [
190
+ z.strictObject({
191
+ action: z.literal("recovery"),
192
+ scope: scopeSchema,
193
+ installationId: installationIdSchema,
194
+ }),
151
195
  z.strictObject({
152
196
  action: z.literal("admit"),
153
197
  scope: scopeSchema,
@@ -186,6 +230,10 @@ const installationOperationRequestSchema = z.discriminatedUnion("action", [
186
230
  }),
187
231
  ]);
188
232
  const installationOperationReplySchema = z.discriminatedUnion("kind", [
233
+ z.strictObject({
234
+ kind: z.literal("recovery"),
235
+ recovery: installationRecoverySchema.nullable(),
236
+ }),
189
237
  z.strictObject({
190
238
  kind: z.literal("refused"),
191
239
  code: z.enum([
@@ -233,6 +281,12 @@ export function installationOperationsPort(send, scope) {
233
281
  return reply;
234
282
  };
235
283
  return {
284
+ async recovery(installationId) {
285
+ const reply = await call({ action: "recovery", scope, installationId });
286
+ if (reply.kind !== "recovery")
287
+ throw new InstallationOperationError("unavailable");
288
+ return reply.recovery;
289
+ },
236
290
  async admit(input) {
237
291
  const reply = await call({ action: "admit", scope, input });
238
292
  if (reply.kind !== "operation" || reply.operation === null)
@@ -354,6 +408,40 @@ export async function createInstallationOperations(ports) {
354
408
  ON installation_commands(retention_due_at)
355
409
  WHERE retention_due_at IS NOT NULL`);
356
410
  migrateCommandRows(owner);
411
+ // Two activations per Installation, independent of expiring command history.
412
+ owner.sql.exec(`CREATE TABLE IF NOT EXISTS installation_recovery (
413
+ installation_id TEXT PRIMARY KEY, record TEXT NOT NULL
414
+ ) STRICT`);
415
+ const readRecovery = (installationId) => {
416
+ const row = owner.sql
417
+ .exec("SELECT record FROM installation_recovery WHERE installation_id=?", installationId)
418
+ .toArray()[0];
419
+ return row === undefined
420
+ ? null
421
+ : readStored(recoveryRecordSchema, z.strictObject({ record: z.string() }).parse(row).record);
422
+ };
423
+ const recoveryOf = (installationId, scope) => {
424
+ const current = ports.get(installationId);
425
+ if (current === null || current.status === "deleted")
426
+ return null;
427
+ const recorded = readRecovery(installationId);
428
+ if (recorded?.generation !== ports.generation() ||
429
+ recorded.instanceId !== current.instanceId ||
430
+ !same(recorded.scope, scope))
431
+ return null;
432
+ // An unconfirmed/failed newer selection recovers to the latest activation,
433
+ // not the release preceding that good activation.
434
+ const target = same(current.release, recorded.current.release)
435
+ ? recorded.previous
436
+ : recorded.current;
437
+ return target?.release.appId !== current.appId
438
+ ? null
439
+ : {
440
+ ...target,
441
+ authorityVersion: current.authority.authorityVersion,
442
+ storeGeneration: recorded.generation,
443
+ };
444
+ };
357
445
  const load = (requestId) => {
358
446
  const row = owner.sql
359
447
  .exec("SELECT command,provisional_outcome FROM installation_commands WHERE request_id=?", requestId)
@@ -485,6 +573,37 @@ export async function createInstallationOperations(ports) {
485
573
  state: "unconfirmed",
486
574
  outcome: stopped ? settled.outcome : "outcome_unknown",
487
575
  };
576
+ if (result.state === "succeeded" &&
577
+ result.installation.status === "enabled" &&
578
+ result.uiCheck !== null &&
579
+ result.uiCheck.kind !== "failed") {
580
+ const prior = readRecovery(command.installationId);
581
+ const sameOwner = prior !== null &&
582
+ prior.generation === command.generation &&
583
+ prior.instanceId === result.installation.instanceId &&
584
+ same(prior.scope, command.scope);
585
+ const activated = {
586
+ release: result.installation.release,
587
+ // Preserve not_checked explicitly; activation is not a green UI check.
588
+ uiCheck: result.uiCheck,
589
+ };
590
+ const recorded = recoveryRecordSchema.parse({
591
+ scope: command.scope,
592
+ generation: command.generation,
593
+ instanceId: result.installation.instanceId,
594
+ current: activated,
595
+ previous: sameOwner
596
+ ? same(prior.current.release, activated.release)
597
+ ? prior.previous
598
+ : prior.current
599
+ : null,
600
+ });
601
+ owner.sql.exec(`INSERT INTO installation_recovery(installation_id,record) VALUES(?,?)
602
+ ON CONFLICT(installation_id) DO UPDATE SET record=excluded.record`, command.installationId, JSON.stringify(recorded));
603
+ }
604
+ if (result.state === "succeeded" &&
605
+ result.installation.status === "deleted")
606
+ owner.sql.exec("DELETE FROM installation_recovery WHERE installation_id=?", command.installationId);
488
607
  const operation = terminalOperationSchema.parse(result.state === "succeeded"
489
608
  ? {
490
609
  ...command.operation,
@@ -573,6 +692,11 @@ export async function createInstallationOperations(ports) {
573
692
  const scope = tenantScope(request.scope.tenantId, request.scope.origin);
574
693
  if (scope.durableName("registry") !== ports.registryName)
575
694
  throw new InstallationOperationError("unavailable");
695
+ if (request.action === "recovery")
696
+ return {
697
+ kind: "recovery",
698
+ recovery: recoveryOf(request.installationId, request.scope),
699
+ };
576
700
  if (request.action === "admit") {
577
701
  if (request.input.actor.kind !== "member")
578
702
  throw new InstallationOperationError("unavailable");
@@ -584,8 +708,8 @@ export async function createInstallationOperations(ports) {
584
708
  const prior = load(request.input.requestId);
585
709
  if (prior !== null) {
586
710
  if (("admission" in prior
587
- ? !same(prior.admission, request.input)
588
- : prior.inputDigest !== inputDigest(request.input)) ||
711
+ ? inputDigest(prior.admission)
712
+ : prior.inputDigest) !== inputDigest(request.input) ||
589
713
  !same(prior.scope, request.scope))
590
714
  throw new InstallationOperationError("request_conflict");
591
715
  return { kind: "operation", operation: operationOf(prior) };
@@ -595,6 +719,20 @@ export async function createInstallationOperations(ports) {
595
719
  if (scheduled.status === "found")
596
720
  throw new InstallationOperationError("unavailable");
597
721
  const requested = ports.get(request.input.installationId);
722
+ const admission = (() => {
723
+ if (request.input.intent !== "rollback")
724
+ return request.input;
725
+ if (requested === null ||
726
+ requested.status === "deleted" ||
727
+ requested.authority.authorityVersion !==
728
+ request.input.authorityVersion ||
729
+ ports.generation() !== request.input.storeGeneration)
730
+ throw new InstallationOperationError("stale_authority");
731
+ const recovery = recoveryOf(request.input.installationId, request.scope);
732
+ if (recovery === null)
733
+ throw new InstallationOperationError("unavailable");
734
+ return { ...request.input, release: recovery.release };
735
+ })();
598
736
  let installationId = request.input.installationId;
599
737
  let creation = requested === null ? "fresh" : "replacement";
600
738
  if (requested?.status === "deleted" &&
@@ -614,11 +752,11 @@ export async function createInstallationOperations(ports) {
614
752
  requestId: request.input.requestId,
615
753
  requestedInstallationId: request.input.installationId,
616
754
  installationId,
617
- release: request.input.release,
755
+ release: admission.release,
618
756
  state: "pending",
619
757
  });
620
758
  save({
621
- admission: request.input,
759
+ admission,
622
760
  scope: request.scope,
623
761
  installationId,
624
762
  instanceId: baseline?.instanceId ?? instanceIds.instance.generate(),
@@ -0,0 +1,24 @@
1
+ import { z } from "zod";
2
+ import type { Installation } from "./apps/installation.js";
3
+ import { type AppTestCopy, type AppTestCopyAuthority } from "./app-test-copies.js";
4
+ import { type InstallationOperation, type InstallationRecovery } from "./installation-operations.js";
5
+ export declare const installationRecoveryFormSchema: z.ZodObject<{
6
+ storeGeneration: z.ZodString;
7
+ authorityVersion: z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodNumber>;
8
+ requestId: z.ZodString;
9
+ }, z.core.$strict>;
10
+ /** Discard names a resource, not the creation request whose receipt may expire. */
11
+ export declare const appTestCopyDiscardFormSchema: z.ZodObject<{
12
+ authorityVersion: z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodNumber>;
13
+ storeGeneration: z.ZodString;
14
+ copyId: z.ZodString;
15
+ }, z.core.$strict>;
16
+ /** No selected App, editable Shell, JavaScript or asset loader is needed. */
17
+ export declare function installationRecoveryPage(entries: readonly Readonly<{
18
+ installation: Installation;
19
+ recovery: InstallationRecovery | null;
20
+ copy: AppTestCopy | null;
21
+ copyAuthority: AppTestCopyAuthority | null;
22
+ }>[], operation: InstallationOperation | null,
23
+ /** The App whose rollback awaits an in-page confirmation. */
24
+ confirming?: string | null): Promise<Response>;