@opengeni/contracts 3.3.0 → 3.4.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.
@@ -2806,6 +2806,17 @@ export const BrowserSessionMutationResponse = /* @__PURE__ */ defineSchema(() =>
2806
2806
  .object({
2807
2807
  session: BrowserSession,
2808
2808
  operation: InteractionLifecycleOperationReceipt,
2809
+ /** Set only by a create that launched the browser in this request: the
2810
+ * tabs and the opened tab's observation exactly as the controller
2811
+ * produced them, so a caller does not need two more reads. A replayed
2812
+ * or failed create omits it; read the targets and observe instead. */
2813
+ initialView: z
2814
+ .object({
2815
+ targets: z.array(BrowserTarget).max(10_000),
2816
+ observation: BrowserObservation,
2817
+ })
2818
+ .strict()
2819
+ .optional(),
2809
2820
  })
2810
2821
  .strict(),
2811
2822
  );
@@ -2820,6 +2831,137 @@ export const BrowserSessionLifecycleRequest = /* @__PURE__ */ defineSchema(() =>
2820
2831
  );
2821
2832
  export type BrowserSessionLifecycleRequest = z.infer<typeof BrowserSessionLifecycleRequest>;
2822
2833
 
2834
+ /** Why a preserved working copy cannot be adopted as it is. */
2835
+ export const BrowserWorkingCopyRefusal = /* @__PURE__ */ defineSchema(() =>
2836
+ z.enum([
2837
+ "unsupported_platform",
2838
+ "unsupported_browser",
2839
+ "browser_running",
2840
+ "working_copy_invalid",
2841
+ "receipt_not_adoptable",
2842
+ "authority_changed",
2843
+ "process_state_unknown",
2844
+ "adoption_not_needed",
2845
+ "adoption_unresolved",
2846
+ ]),
2847
+ );
2848
+ export type BrowserWorkingCopyRefusal = z.infer<typeof BrowserWorkingCopyRefusal>;
2849
+
2850
+ /** One adoption of a copied working directory, as its controller recorded it.
2851
+ * `adopted` is the only phase in which the browser runs from the copy; the
2852
+ * other terminal phases left the browser's own directory untouched or
2853
+ * restored, and every directory kept is listed for separate cleanup. */
2854
+ export const BrowserWorkingCopyAdoption = /* @__PURE__ */ defineSchema(() =>
2855
+ z
2856
+ .object({
2857
+ operationId: z.string().uuid(),
2858
+ browserSessionId: z.string().uuid(),
2859
+ controllerGeneration: opaqueGeneration,
2860
+ manifestDigest: sha256Hex,
2861
+ phase: z.enum([
2862
+ "intent",
2863
+ "copied",
2864
+ "receipt",
2865
+ "source_preserved",
2866
+ "adopted",
2867
+ "interrupted",
2868
+ "failed",
2869
+ "collision",
2870
+ "reverting",
2871
+ "reverted",
2872
+ ]),
2873
+ failureCode: z.string().min(1).max(64).nullable(),
2874
+ retainedDirectories: z.array(z.string().min(1).max(256)).max(64),
2875
+ createdAt: z.string().datetime({ offset: true }),
2876
+ updatedAt: z.string().datetime({ offset: true }),
2877
+ })
2878
+ .strict(),
2879
+ );
2880
+ export type BrowserWorkingCopyAdoption = z.infer<typeof BrowserWorkingCopyAdoption>;
2881
+
2882
+ /** Evidence about a browser's preserved working copy after its controller
2883
+ * lost it, for example after the machine's disk was restored from a copy.
2884
+ * Machine evidence (receipt, profile identity, process proof, exact byte
2885
+ * digest) is kept separate from freshness, which is never proven: whoever
2886
+ * adopts the copy selects it as the browser's state. */
2887
+ export const BrowserWorkingCopyInspection = /* @__PURE__ */ defineSchema(() =>
2888
+ z
2889
+ .object({
2890
+ browserSessionId: z.string().uuid(),
2891
+ controllerGeneration: opaqueGeneration,
2892
+ adoptable: z.boolean(),
2893
+ refusal: BrowserWorkingCopyRefusal.nullable(),
2894
+ /** Plain explanation of the state and the next action. */
2895
+ explanation: z.string().min(1).max(2_048),
2896
+ /** Exact digest of the bytes an adoption would take; pass it to adopt. */
2897
+ manifest: z
2898
+ .object({
2899
+ digest: sha256Hex,
2900
+ entries: z.number().int().nonnegative(),
2901
+ bytes: z.number().int().nonnegative(),
2902
+ /** Controller-owned derived entries left out of the copy (journal
2903
+ * shared-memory indexes and the per-launch launcher folder). */
2904
+ excluded: z.array(z.string().min(1).max(256)).max(16),
2905
+ })
2906
+ .strict()
2907
+ .nullable(),
2908
+ platformSupported: z.boolean(),
2909
+ profileIdentityMatches: z.boolean(),
2910
+ profileInUse: z.boolean().nullable(),
2911
+ receipt: z
2912
+ .object({
2913
+ operationId: z.string().uuid(),
2914
+ intent: z.enum(["launch", "suspend", "retire", "adopt"]),
2915
+ state: z.string().min(1).max(64),
2916
+ directoryLaunchAllowed: z.boolean(),
2917
+ authorityMatches: z.boolean(),
2918
+ launchedFromCheckpoint: z.boolean(),
2919
+ adoption: z
2920
+ .object({ operationId: z.string().uuid(), manifestDigest: sha256Hex })
2921
+ .strict()
2922
+ .nullable(),
2923
+ })
2924
+ .strict()
2925
+ .nullable(),
2926
+ freshness: z
2927
+ .object({
2928
+ /** How recent the copy's contents are is not machine-proven. */
2929
+ status: z.literal("unknown"),
2930
+ /** When the browser's latest saved checkpoint was taken, if any. */
2931
+ latestCheckpointAt: z.string().datetime({ offset: true }).nullable(),
2932
+ })
2933
+ .strict(),
2934
+ activeAdoption: BrowserWorkingCopyAdoption.nullable(),
2935
+ })
2936
+ .strict(),
2937
+ );
2938
+ export type BrowserWorkingCopyInspection = z.infer<typeof BrowserWorkingCopyInspection>;
2939
+
2940
+ export const BrowserWorkingCopyAdoptionRequest = /* @__PURE__ */ defineSchema(() =>
2941
+ z
2942
+ .object({
2943
+ operationId: z.string().uuid(),
2944
+ /** The manifest digest from an inspection of the exact bytes to adopt. */
2945
+ manifestDigest: sha256Hex,
2946
+ })
2947
+ .strict(),
2948
+ );
2949
+ export type BrowserWorkingCopyAdoptionRequest = z.infer<typeof BrowserWorkingCopyAdoptionRequest>;
2950
+
2951
+ export const BrowserWorkingCopyAdoptionResponse = /* @__PURE__ */ defineSchema(() =>
2952
+ z
2953
+ .object({
2954
+ /** True while the controller is still running this adoption. */
2955
+ inFlight: z.boolean(),
2956
+ /** Null when the controller has no record of the operation, which
2957
+ * proves it changed nothing there. */
2958
+ adoption: BrowserWorkingCopyAdoption.nullable(),
2959
+ explanation: z.string().min(1).max(2_048),
2960
+ })
2961
+ .strict(),
2962
+ );
2963
+ export type BrowserWorkingCopyAdoptionResponse = z.infer<typeof BrowserWorkingCopyAdoptionResponse>;
2964
+
2823
2965
  export const BrowserOpenTargetRequest = /* @__PURE__ */ defineSchema(() =>
2824
2966
  z
2825
2967
  .object({
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+
3
+ /** Operator-managed catalog; monetary amounts are USD micro-units. */
4
+ export const SubscriptionPlan = z.strictObject({
5
+ key: z.string().regex(/^[a-z][a-z0-9_-]{0,39}$/),
6
+ label: z.string().trim().min(1).max(120),
7
+ stripePriceId: z.string().trim().min(1).max(200).nullable(),
8
+ monthlyPriceMicros: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).nullable(),
9
+ monthlyCreditMicros: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
10
+ seatLimit: z.number().int().positive().max(1_000_000).nullable(),
11
+ freeCredit: z.boolean(),
12
+ });
13
+ export type SubscriptionPlan = z.infer<typeof SubscriptionPlan>;
14
+
15
+ export const SubscriptionPlanCatalog = z
16
+ .array(SubscriptionPlan)
17
+ .min(1)
18
+ .max(100)
19
+ .superRefine((plans, context) => {
20
+ if (new Set(plans.map((plan) => plan.key)).size !== plans.length) {
21
+ context.addIssue({ code: "custom", message: "Plan keys must be unique" });
22
+ }
23
+ const prices = plans.flatMap((plan) => (plan.stripePriceId ? [plan.stripePriceId] : []));
24
+ if (new Set(prices).size !== prices.length) {
25
+ context.addIssue({ code: "custom", message: "Stripe price IDs must be unique" });
26
+ }
27
+ });
28
+ export type SubscriptionPlanCatalog = z.infer<typeof SubscriptionPlanCatalog>;
29
+
30
+ export const BillingPlanBalance = z.object({
31
+ key: z.string(),
32
+ label: z.string(),
33
+ status: z.string(),
34
+ creditGrantedMicros: z.number().int().nonnegative(),
35
+ creditRemainingMicros: z.number().int().nonnegative(),
36
+ /** Already unavailable, but not yet removed from the physical ledger. */
37
+ creditPendingExpiryMicros: z.number().int().nonnegative().optional(),
38
+ periodResetAt: z.string().nullable(),
39
+ seatLimit: z.number().int().positive().nullable(),
40
+ seatsUsed: z.number().int().nonnegative(),
41
+ cancelAtPeriodEnd: z.boolean(),
42
+ });
43
+ export type BillingPlanBalance = z.infer<typeof BillingPlanBalance>;