@opengeni/contracts 2.5.0-canary.2 → 2.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.
package/src/index.ts CHANGED
@@ -13,6 +13,12 @@ import { ClientResumableVoiceInputConfig } from "./transcription-recordings";
13
13
  import { MediaGenerationResult } from "./video-generation";
14
14
  import { KnowledgeProviderCitation } from "./knowledge";
15
15
  import { XaiProviderAccountAuthoritySnapshotV1 } from "./xai-provider-account-authority";
16
+ import {
17
+ MAX_NESTED_AGENT_DEPTH,
18
+ NestedAgentDepthValue,
19
+ SessionGoalStatus,
20
+ SessionStatus,
21
+ } from "./session-topology-primitives";
16
22
 
17
23
  export * from "./slack-bot-scopes";
18
24
  export * from "./slack-task-policy";
@@ -31,6 +37,9 @@ export * from "./interaction";
31
37
  export * from "./sandbox-file-artifacts";
32
38
  export * from "./permissions";
33
39
  export * from "./session-titles";
40
+ export * from "./session-topology-primitives";
41
+ export * from "./agent-topology";
42
+ export * from "./work-claims";
34
43
 
35
44
  export {
36
45
  CreateWorkspaceArtifactRequest,
@@ -149,18 +158,6 @@ export {
149
158
  type ModalCheckpointProviderBinding,
150
159
  } from "./checkpoint-provider-bindings";
151
160
 
152
- export const SessionStatus = z.enum([
153
- "queued",
154
- "running",
155
- "idle",
156
- "requires_action",
157
- "recovering",
158
- "waiting_capacity",
159
- "failed",
160
- "cancelled",
161
- ]);
162
- export type SessionStatus = z.infer<typeof SessionStatus>;
163
-
164
161
  // 12 backends; 3-way enum parity (contracts / sdk / deployment) is pinned by
165
162
  // `packages/sdk/test/contract-parity.test.ts`. Every member is ADDITIVE AT THE
166
163
  // END (the parity test pins positions): the original four, then the six cloud
@@ -680,10 +677,6 @@ export const ErrorEnvelope = z.object({
680
677
  });
681
678
  export type ErrorEnvelope = z.infer<typeof ErrorEnvelope>;
682
679
 
683
- /** Physical ceiling of the PostgreSQL integer columns that persist depth policy. */
684
- export const MAX_NESTED_AGENT_DEPTH = 2_147_483_647;
685
- export const NestedAgentDepthValue = z.number().int().nonnegative().max(MAX_NESTED_AGENT_DEPTH);
686
- export type NestedAgentDepthValue = z.infer<typeof NestedAgentDepthValue>;
687
680
  /** A denied child can be one greater than the persisted PostgreSQL int ceiling. */
688
681
  export const NestedAgentDepthAttemptValue = z
689
682
  .number()
@@ -779,6 +772,8 @@ export const FIRST_PARTY_MCP_TOOL_NAMES = [
779
772
  "task_note_save",
780
773
  "task_note_archive",
781
774
  "task_note_replace",
775
+ "work_claim_upsert",
776
+ "work_claim_release",
782
777
  "knowledge_propose",
783
778
  "knowledge_correct",
784
779
  "task_note_promote_knowledge",
@@ -2965,13 +2960,15 @@ export const CreateWorkspaceRequest = z.object({
2965
2960
  });
2966
2961
  export type CreateWorkspaceRequest = z.infer<typeof CreateWorkspaceRequest>;
2967
2962
 
2968
- export const UpdateWorkspaceRequest = z.object({
2969
- name: z.string().min(1).optional(),
2970
- slug: z.string().min(1).nullable().optional(),
2971
- // White-label persona override. Pass null to clear it back to the deployment
2972
- // default; omit to leave it unchanged.
2973
- agentInstructions: z.string().min(1).nullable().optional(),
2974
- });
2963
+ export const UpdateWorkspaceRequest = z
2964
+ .object({
2965
+ name: z.string().min(1).optional(),
2966
+ slug: z.string().min(1).nullable().optional(),
2967
+ // White-label persona override. Pass null to clear it back to the deployment
2968
+ // default; omit to leave it unchanged.
2969
+ agentInstructions: z.string().min(1).nullable().optional(),
2970
+ })
2971
+ .strict();
2975
2972
  export type UpdateWorkspaceRequest = z.infer<typeof UpdateWorkspaceRequest>;
2976
2973
 
2977
2974
  export const ApiKey = z.object({
@@ -5561,9 +5558,6 @@ export type SessionControlState = z.infer<typeof SessionControlState>;
5561
5558
  export const WorkspaceInferenceState = z.enum(["active", "paused"]);
5562
5559
  export type WorkspaceInferenceState = z.infer<typeof WorkspaceInferenceState>;
5563
5560
 
5564
- export const SessionGoalStatus = z.enum(["active", "paused", "completed"]);
5565
- export type SessionGoalStatus = z.infer<typeof SessionGoalStatus>;
5566
-
5567
5561
  export const SessionGoalCreatedBy = z.enum(["api", "agent", "scheduled_task"]);
5568
5562
  export type SessionGoalCreatedBy = z.infer<typeof SessionGoalCreatedBy>;
5569
5563
 
@@ -7727,6 +7721,44 @@ export type VariableSetSecret = z.infer<typeof VariableSetSecret>;
7727
7721
  export const VariableSetScope = z.enum(["organization", "workspace", "user"]);
7728
7722
  export type VariableSetScope = z.infer<typeof VariableSetScope>;
7729
7723
 
7724
+ /**
7725
+ * Exact-ID metadata used only to validate attachments. This deliberately omits
7726
+ * names, descriptions, and variable-name metadata so attach/use authority does
7727
+ * not become general catalog access.
7728
+ */
7729
+ export const VariableSetAttachmentMetadata = z.object({
7730
+ id: z.string().uuid(),
7731
+ scope: VariableSetScope,
7732
+ });
7733
+ export type VariableSetAttachmentMetadata = z.infer<typeof VariableSetAttachmentMetadata>;
7734
+
7735
+ export const MAX_RESOLVED_VARIABLE_SET_ATTACHMENTS = MAX_SELECTED_VARIABLE_SETS * 2;
7736
+ export const ResolveVariableSetAttachmentsRequest = z
7737
+ .object({
7738
+ // One create can carry 25 explicit selections plus 25 defaults from its Rig.
7739
+ variableSetIds: z.array(z.string().uuid()).max(MAX_RESOLVED_VARIABLE_SET_ATTACHMENTS),
7740
+ })
7741
+ .strict()
7742
+ .superRefine((value, context) => {
7743
+ if (new Set(value.variableSetIds).size !== value.variableSetIds.length) {
7744
+ context.addIssue({
7745
+ code: z.ZodIssueCode.custom,
7746
+ path: ["variableSetIds"],
7747
+ message: "variableSetIds must not contain duplicates",
7748
+ });
7749
+ }
7750
+ });
7751
+ export type ResolveVariableSetAttachmentsRequest = z.infer<
7752
+ typeof ResolveVariableSetAttachmentsRequest
7753
+ >;
7754
+
7755
+ export const ResolveVariableSetAttachmentsResponse = z.object({
7756
+ variableSets: z.array(VariableSetAttachmentMetadata),
7757
+ });
7758
+ export type ResolveVariableSetAttachmentsResponse = z.infer<
7759
+ typeof ResolveVariableSetAttachmentsResponse
7760
+ >;
7761
+
7730
7762
  export const VariableSet = z.object({
7731
7763
  id: z.string().uuid(),
7732
7764
  accountId: z.string().uuid(),
@@ -8008,6 +8040,10 @@ export const RigChange = z.object({
8008
8040
  });
8009
8041
  export type RigChange = z.infer<typeof RigChange>;
8010
8042
 
8043
+ // Rig setup payloads are transferred to sandboxes in bounded chunks. Keep the
8044
+ // public definition limit independent from provider command-argument ceilings.
8045
+ export const RIG_SETUP_SCRIPT_MAX_CHARS = 1024 * 1024;
8046
+
8011
8047
  export const CreateRigRequest = z.object({
8012
8048
  // Omitted remains the compatibility workspace-owned creation path.
8013
8049
  scope: ResourceAuthorityScope.default("workspace"),
@@ -8020,7 +8056,7 @@ export const CreateRigRequest = z.object({
8020
8056
  // explicit never-field instead of silently stripping `image` from older
8021
8057
  // clients: callers must receive a validation error and remove the override.
8022
8058
  image: z.never().optional(),
8023
- setupScript: z.string().max(131072).optional(),
8059
+ setupScript: z.string().max(RIG_SETUP_SCRIPT_MAX_CHARS).optional(),
8024
8060
  checks: z.array(RigCheck).max(100).default([]),
8025
8061
  credentialHooks: z.array(z.string().min(1).max(200)).max(50).default([]),
8026
8062
  defaultVariableSetIds: z.array(z.string().uuid()).max(25).default([]),
@@ -8090,7 +8126,7 @@ export const RigDefinitionEditPayload = z.object({
8090
8126
  // the read model for compatibility, but no new definition may set or clear
8091
8127
  // one through the public write contract.
8092
8128
  image: z.never().optional(),
8093
- setupScript: z.string().max(131072).nullish(),
8129
+ setupScript: z.string().max(RIG_SETUP_SCRIPT_MAX_CHARS).nullish(),
8094
8130
  checks: z.array(RigCheck).max(100).optional(),
8095
8131
  credentialHooks: z.array(z.string().min(1).max(200)).max(50).optional(),
8096
8132
  defaultVariableSetIds: z.array(z.string().uuid()).max(25).optional(),
@@ -11681,57 +11717,6 @@ export const SessionListResponse = z.object({
11681
11717
  });
11682
11718
  export type SessionListResponse = z.infer<typeof SessionListResponse>;
11683
11719
 
11684
- /** Compact, bounded session projection for workspace agent-topology browsers. */
11685
- export const AgentTopologySession = z.object({
11686
- id: z.string().uuid(),
11687
- title: z.string().nullable(),
11688
- titleTruncated: z.boolean(),
11689
- parentSessionId: z.string().uuid().nullable(),
11690
- rootSessionId: z.string().uuid(),
11691
- nestedAgentDepth: NestedAgentDepthValue,
11692
- ancestorPath: z.array(
11693
- z.object({
11694
- id: z.string().uuid(),
11695
- title: z.string().nullable(),
11696
- titleTruncated: z.boolean(),
11697
- }),
11698
- ),
11699
- status: SessionStatus,
11700
- pause: z.object({
11701
- state: z.enum(["active", "paused"]),
11702
- additionalBlockerCount: z.number().int().nonnegative(),
11703
- source: z
11704
- .object({
11705
- kind: z.enum(["session", "workspace"]),
11706
- sessionId: z.string().uuid().optional(),
11707
- displayName: z.string(),
11708
- displayNameTruncated: z.boolean(),
11709
- })
11710
- .nullable(),
11711
- }),
11712
- children: z.object({
11713
- directChildren: z.number().int().nonnegative(),
11714
- totalDescendants: z.number().int().nonnegative(),
11715
- runningDescendants: z.number().int().nonnegative(),
11716
- queuedDescendants: z.number().int().nonnegative(),
11717
- attentionDescendants: z.number().int().nonnegative(),
11718
- pausedDescendants: z.number().int().nonnegative(),
11719
- failedDescendants: z.number().int().nonnegative(),
11720
- truncated: z.boolean(),
11721
- }),
11722
- createdAt: z.string(),
11723
- updatedAt: z.string(),
11724
- });
11725
- export type AgentTopologySession = z.infer<typeof AgentTopologySession>;
11726
-
11727
- export const AgentTopologyPageResponse = z.object({
11728
- sessions: z.array(AgentTopologySession),
11729
- total: z.number().int().nonnegative(),
11730
- hasMore: z.boolean(),
11731
- nextCursor: z.string().nullable(),
11732
- });
11733
- export type AgentTopologyPageResponse = z.infer<typeof AgentTopologyPageResponse>;
11734
-
11735
11720
  // Recursive: the TS type is declared first so the schema annotation can carry
11736
11721
  // the FULL recursive shape (a shallow annotation loses type information for
11737
11722
  // contracts consumers after one level of nesting).
@@ -15704,8 +15689,7 @@ export type WorkspaceModelCatalogResponse = z.infer<typeof WorkspaceModelCatalog
15704
15689
  * that rollout boundary. Mutating clients send this value in
15705
15690
  * `x-opengeni-api-contract`; the API rejects any other value before routing.
15706
15691
  */
15707
- export const OPENGENI_API_CONTRACT_REVISION =
15708
- "2026-08-personal-only-organization-setup-v1" as const;
15692
+ export const OPENGENI_API_CONTRACT_REVISION = "2026-08-organization-recovery-custody-v1" as const;
15709
15693
  export const OPENGENI_API_CONTRACT_HEADER = "x-opengeni-api-contract" as const;
15710
15694
  /** Bounded request/response identifier shared by browser, ingress, and API diagnostics. */
15711
15695
  export const OPENGENI_CORRELATION_HEADER = "x-opengeni-correlation-id" as const;
@@ -15755,6 +15739,9 @@ export const ClientConfig = /* @__PURE__ */ defineModelContractSchema(() =>
15755
15739
  acceptedMimeTypes: [...VOICE_INPUT_ACCEPTED_MIME_TYPES],
15756
15740
  }),
15757
15741
  productAccessMode: ProductAccessMode,
15742
+ // Safe rollout discriminator: the browser only mounts the optional
15743
+ // @opengeni/sdk/accounts controller when this is dual or broker.
15744
+ managedAuthSessionSetMode: z.enum(["legacy", "dual", "broker"]).default("legacy"),
15758
15745
  auth: ClientAuthConfig.default({ mode: "none" }),
15759
15746
  analytics: z
15760
15747
  .object({
@@ -15891,6 +15878,7 @@ export * from "./governed-learning-activation";
15891
15878
  export * from "./knowledge";
15892
15879
  export * from "./task-notes";
15893
15880
  export * from "./canonical-human-identities";
15881
+ export * from "./organization-recovery";
15894
15882
  export * from "./organization-membership-lifecycle";
15895
15883
  export * from "./remember";
15896
15884
  export * from "./agent-authored-durable-text";
@@ -0,0 +1,208 @@
1
+ import { z } from "zod";
2
+
3
+ export const MANAGED_AUTH_SESSION_SET_MAX_SLOTS = 8 as const;
4
+ export const MANAGED_AUTH_TRANSACTION_TTL_SECONDS = 600 as const;
5
+ export const MANAGED_AUTH_RETURN_INTENT_MAX_BYTES = 2_048 as const;
6
+ export const MANAGED_AUTH_SESSION_SET_API_CONTRACT_HEADER = "x-opengeni-api-contract" as const;
7
+ export const MANAGED_AUTH_SESSION_SET_API_CONTRACT_REVISION =
8
+ "2026-08-personal-only-organization-setup-v1" as const;
9
+
10
+ export const ManagedAuthSessionSetMode = z.enum(["legacy", "dual", "broker"]);
11
+ export type ManagedAuthSessionSetMode = z.infer<typeof ManagedAuthSessionSetMode>;
12
+
13
+ export const ManagedAuthLoginSlotState = z.enum(["active", "reauth_required"]);
14
+ export type ManagedAuthLoginSlotState = z.infer<typeof ManagedAuthLoginSlotState>;
15
+
16
+ export const ManagedAuthVerifiedClaim = z.object({
17
+ kind: z.literal("email"),
18
+ value: z.string().email().max(320),
19
+ });
20
+ export type ManagedAuthVerifiedClaim = z.infer<typeof ManagedAuthVerifiedClaim>;
21
+
22
+ /** Secret-free, browser-safe summary. Provider session ids and tokens never enter this shape. */
23
+ export const ManagedAuthLoginSlot = z.object({
24
+ id: z.string().uuid(),
25
+ displayName: z.string().min(1).max(256),
26
+ verifiedClaim: ManagedAuthVerifiedClaim,
27
+ state: ManagedAuthLoginSlotState,
28
+ });
29
+ export type ManagedAuthLoginSlot = z.infer<typeof ManagedAuthLoginSlot>;
30
+
31
+ export const ManagedAuthSessionSetState = z.enum(["ready", "actor_change_required"]);
32
+ export type ManagedAuthSessionSetState = z.infer<typeof ManagedAuthSessionSetState>;
33
+
34
+ export const ManagedAuthSessionSetProjection = z.object({
35
+ mode: ManagedAuthSessionSetMode,
36
+ generation: z.string().regex(/^[1-9][0-9]*$/),
37
+ actorEpoch: z.string().regex(/^[1-9][0-9]*$/),
38
+ csrfToken: z.string().min(32).max(512),
39
+ selectedSlotId: z.string().uuid().nullable(),
40
+ state: ManagedAuthSessionSetState,
41
+ slots: z.array(ManagedAuthLoginSlot).max(MANAGED_AUTH_SESSION_SET_MAX_SLOTS),
42
+ });
43
+ export type ManagedAuthSessionSetProjection = z.infer<typeof ManagedAuthSessionSetProjection>;
44
+
45
+ export const ManagedAuthOperationIdentity = z.object({
46
+ operationId: z.string().uuid(),
47
+ expectedGeneration: z.string().regex(/^[1-9][0-9]*$/),
48
+ });
49
+ export type ManagedAuthOperationIdentity = z.infer<typeof ManagedAuthOperationIdentity>;
50
+
51
+ export const BootstrapManagedAuthSessionSetRequest = ManagedAuthOperationIdentity;
52
+ export type BootstrapManagedAuthSessionSetRequest = z.infer<
53
+ typeof BootstrapManagedAuthSessionSetRequest
54
+ >;
55
+
56
+ export const ManagedAuthReturnIntent = z
57
+ .string()
58
+ .min(1)
59
+ .superRefine((value, context) => {
60
+ if (new TextEncoder().encode(value).byteLength > MANAGED_AUTH_RETURN_INTENT_MAX_BYTES) {
61
+ context.addIssue({ code: "custom", message: "return intent exceeds its UTF-8 byte limit" });
62
+ }
63
+ if (
64
+ !value.startsWith("/") ||
65
+ value.startsWith("//") ||
66
+ value.includes("?") ||
67
+ value.includes("#") ||
68
+ /[\u0000-\u001f\u007f\\]/.test(value)
69
+ ) {
70
+ context.addIssue({
71
+ code: "custom",
72
+ message: "return intent must be a safe same-origin path",
73
+ });
74
+ return;
75
+ }
76
+ try {
77
+ const parsed = new URL(value, "https://opengeni.invalid");
78
+ const uuid = "[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}";
79
+ const supportedPath = new RegExp(
80
+ `^/(?:sessions/${uuid}|workspaces/${uuid}(?:/sessions(?:/${uuid})?)?)$`,
81
+ "i",
82
+ );
83
+ if (
84
+ parsed.origin !== "https://opengeni.invalid" ||
85
+ parsed.username ||
86
+ parsed.password ||
87
+ parsed.search ||
88
+ parsed.hash ||
89
+ !supportedPath.test(value) ||
90
+ parsed.pathname !== value
91
+ ) {
92
+ context.addIssue({
93
+ code: "custom",
94
+ message: "return intent contains unsafe authority data",
95
+ });
96
+ }
97
+ } catch {
98
+ context.addIssue({
99
+ code: "custom",
100
+ message: "return intent is not a valid same-origin path",
101
+ });
102
+ }
103
+ });
104
+
105
+ export const BeginManagedAuthLoginTransactionRequest = ManagedAuthOperationIdentity.extend({
106
+ kind: z.enum(["add", "reauth"]),
107
+ slotId: z.string().uuid().optional(),
108
+ returnIntent: ManagedAuthReturnIntent.optional(),
109
+ }).superRefine((value, context) => {
110
+ if ((value.kind === "reauth") !== Boolean(value.slotId)) {
111
+ context.addIssue({
112
+ code: "custom",
113
+ path: ["slotId"],
114
+ message: "reauth requires exactly one slot id and add forbids one",
115
+ });
116
+ }
117
+ });
118
+ export type BeginManagedAuthLoginTransactionRequest = z.infer<
119
+ typeof BeginManagedAuthLoginTransactionRequest
120
+ >;
121
+
122
+ export const ManagedAuthLoginTransaction = z.object({
123
+ id: z.string().uuid(),
124
+ kind: z.enum(["add", "reauth"]),
125
+ expiresAt: z.string().datetime(),
126
+ returnIntentId: z.string().uuid().nullable(),
127
+ });
128
+ export type ManagedAuthLoginTransaction = z.infer<typeof ManagedAuthLoginTransaction>;
129
+
130
+ export const CompleteManagedAuthEmailPasswordTransactionRequest =
131
+ ManagedAuthOperationIdentity.extend({
132
+ transactionId: z.string().uuid(),
133
+ email: z.string().email().max(320),
134
+ password: z.string().min(1).max(1_024),
135
+ });
136
+ export type CompleteManagedAuthEmailPasswordTransactionRequest = z.infer<
137
+ typeof CompleteManagedAuthEmailPasswordTransactionRequest
138
+ >;
139
+
140
+ export const CompleteManagedAuthLoginTransactionResponse = z.object({
141
+ projection: ManagedAuthSessionSetProjection,
142
+ returnIntent: ManagedAuthReturnIntent.nullable(),
143
+ });
144
+ export type CompleteManagedAuthLoginTransactionResponse = z.infer<
145
+ typeof CompleteManagedAuthLoginTransactionResponse
146
+ >;
147
+
148
+ export const CancelManagedAuthLoginTransactionRequest = ManagedAuthOperationIdentity.extend({
149
+ transactionId: z.string().uuid(),
150
+ });
151
+ export type CancelManagedAuthLoginTransactionRequest = z.infer<
152
+ typeof CancelManagedAuthLoginTransactionRequest
153
+ >;
154
+
155
+ export const SelectManagedAuthLoginSlotRequest = ManagedAuthOperationIdentity.extend({
156
+ slotId: z.string().uuid(),
157
+ });
158
+ export type SelectManagedAuthLoginSlotRequest = z.infer<typeof SelectManagedAuthLoginSlotRequest>;
159
+
160
+ export const LogoutManagedAuthLoginSlotRequest = ManagedAuthOperationIdentity.extend({
161
+ slotId: z.string().uuid(),
162
+ replacementSlotId: z.string().uuid().nullable(),
163
+ });
164
+ export type LogoutManagedAuthLoginSlotRequest = z.infer<typeof LogoutManagedAuthLoginSlotRequest>;
165
+
166
+ export const LogoutManagedAuthSessionSetRequest = ManagedAuthOperationIdentity;
167
+ export type LogoutManagedAuthSessionSetRequest = z.infer<typeof LogoutManagedAuthSessionSetRequest>;
168
+
169
+ export const ManagedAuthLogoutAllReceipt = z.object({
170
+ generation: z.string().regex(/^[1-9][0-9]*$/),
171
+ actorEpoch: z.string().regex(/^[1-9][0-9]*$/),
172
+ state: z.literal("logged_out"),
173
+ });
174
+ export type ManagedAuthLogoutAllReceipt = z.infer<typeof ManagedAuthLogoutAllReceipt>;
175
+
176
+ export const ResolveManagedAuthDeepLinkRequest = z.object({
177
+ path: ManagedAuthReturnIntent,
178
+ });
179
+ export type ResolveManagedAuthDeepLinkRequest = z.infer<typeof ResolveManagedAuthDeepLinkRequest>;
180
+
181
+ export const ManagedAuthDeepLinkResolution = z.discriminatedUnion("kind", [
182
+ z.object({ kind: z.literal("current") }),
183
+ z.object({ kind: z.literal("switch_required"), slot: ManagedAuthLoginSlot }),
184
+ z.object({ kind: z.literal("unavailable") }),
185
+ ]);
186
+ export type ManagedAuthDeepLinkResolution = z.infer<typeof ManagedAuthDeepLinkResolution>;
187
+
188
+ export const ManagedAuthSessionSetErrorCode = z.enum([
189
+ "actor_change_required",
190
+ "actor_mutation_in_flight",
191
+ "api_contract_changed",
192
+ "browser_session_set_required",
193
+ "browser_session_set_unavailable",
194
+ "generation_conflict",
195
+ "invalid_browser_session_set_request",
196
+ "invalid_transaction",
197
+ "managed_authentication_required",
198
+ "managed_authentication_unavailable",
199
+ "operation_outcome_unknown",
200
+ "operation_reused",
201
+ "origin_rejected",
202
+ "login_transaction_rate_limited",
203
+ "provider_route_blocked",
204
+ "slot_limit_reached",
205
+ "slot_already_exists",
206
+ "slot_unavailable",
207
+ ]);
208
+ export type ManagedAuthSessionSetErrorCode = z.infer<typeof ManagedAuthSessionSetErrorCode>;
@@ -0,0 +1,186 @@
1
+ import { z } from "zod";
2
+
3
+ const Uuid = z.string().uuid();
4
+ const Timestamp = z.string().datetime({ offset: true });
5
+
6
+ export const OrganizationRecoveryPolicyState = z.enum([
7
+ "pending_acceptance",
8
+ "active",
9
+ "degraded",
10
+ "superseded",
11
+ "disabled",
12
+ ]);
13
+ export type OrganizationRecoveryPolicyState = z.infer<typeof OrganizationRecoveryPolicyState>;
14
+
15
+ export const OrganizationRecoveryOperationState = z.enum([
16
+ "collecting",
17
+ "cooling",
18
+ "executed",
19
+ "cancelled",
20
+ "expired",
21
+ "superseded",
22
+ ]);
23
+ export type OrganizationRecoveryOperationState = z.infer<typeof OrganizationRecoveryOperationState>;
24
+
25
+ export const OrganizationRecoveryUnavailableReason = z.enum([
26
+ "no_policy",
27
+ "pending_acceptance",
28
+ "degraded",
29
+ "disabled",
30
+ "identity_unavailable",
31
+ ]);
32
+ export type OrganizationRecoveryUnavailableReason = z.infer<
33
+ typeof OrganizationRecoveryUnavailableReason
34
+ >;
35
+
36
+ export const OrganizationRecoveryMemberSummary = z
37
+ .object({
38
+ membershipId: Uuid,
39
+ name: z.string().trim().min(1).max(1024).nullable(),
40
+ email: z.string().email().max(320).nullable(),
41
+ })
42
+ .strict();
43
+ export type OrganizationRecoveryMemberSummary = z.infer<typeof OrganizationRecoveryMemberSummary>;
44
+
45
+ export const OrganizationRecoveryCustodian = OrganizationRecoveryMemberSummary.extend({
46
+ ordinal: z.number().int().min(1).max(3),
47
+ enrollmentState: z.enum(["pending_acceptance", "accepted", "ineligible"]),
48
+ acceptedAt: Timestamp.nullable(),
49
+ }).strict();
50
+ export type OrganizationRecoveryCustodian = z.infer<typeof OrganizationRecoveryCustodian>;
51
+
52
+ export const OrganizationRecoveryPolicy = z
53
+ .object({
54
+ id: Uuid,
55
+ organizationId: Uuid,
56
+ revision: z.number().int().positive(),
57
+ state: OrganizationRecoveryPolicyState,
58
+ custodians: z.array(OrganizationRecoveryCustodian).length(3),
59
+ createdAt: Timestamp,
60
+ updatedAt: Timestamp,
61
+ })
62
+ .strict();
63
+ export type OrganizationRecoveryPolicy = z.infer<typeof OrganizationRecoveryPolicy>;
64
+
65
+ export const OrganizationRecoveryApproval = OrganizationRecoveryMemberSummary.extend({
66
+ approvedAt: Timestamp,
67
+ }).strict();
68
+ export type OrganizationRecoveryApproval = z.infer<typeof OrganizationRecoveryApproval>;
69
+
70
+ export const OrganizationRecoveryOperation = z
71
+ .object({
72
+ id: Uuid,
73
+ organizationId: Uuid,
74
+ policyId: Uuid,
75
+ policyRevision: z.number().int().positive(),
76
+ revision: z.number().int().positive(),
77
+ state: OrganizationRecoveryOperationState,
78
+ target: OrganizationRecoveryMemberSummary,
79
+ approvals: z.array(OrganizationRecoveryApproval).max(3),
80
+ approvalCount: z.number().int().min(0).max(3),
81
+ quorumAt: Timestamp.nullable(),
82
+ executableAt: Timestamp.nullable(),
83
+ expiresAt: Timestamp,
84
+ executedAt: Timestamp.nullable(),
85
+ cancelledAt: Timestamp.nullable(),
86
+ notificationJournaled: z.boolean(),
87
+ createdAt: Timestamp,
88
+ updatedAt: Timestamp,
89
+ })
90
+ .strict();
91
+ export type OrganizationRecoveryOperation = z.infer<typeof OrganizationRecoveryOperation>;
92
+
93
+ export const OrganizationRecoveryCapabilities = z
94
+ .object({
95
+ configure: z.boolean(),
96
+ accept: z.boolean(),
97
+ disable: z.boolean(),
98
+ start: z.boolean(),
99
+ approve: z.boolean(),
100
+ cancel: z.boolean(),
101
+ execute: z.boolean(),
102
+ })
103
+ .strict();
104
+ export type OrganizationRecoveryCapabilities = z.infer<typeof OrganizationRecoveryCapabilities>;
105
+
106
+ export const OrganizationRecoveryOverview = z
107
+ .object({
108
+ organizationId: Uuid,
109
+ availability: z.enum(["available", "recovery_unavailable"]),
110
+ unavailableReason: OrganizationRecoveryUnavailableReason.nullable(),
111
+ recentReauthenticationAt: Timestamp.nullable(),
112
+ eligibleMembers: z.array(OrganizationRecoveryMemberSummary).max(1000),
113
+ policy: OrganizationRecoveryPolicy.nullable(),
114
+ operation: OrganizationRecoveryOperation.nullable(),
115
+ capabilities: OrganizationRecoveryCapabilities,
116
+ })
117
+ .strict();
118
+ export type OrganizationRecoveryOverview = z.infer<typeof OrganizationRecoveryOverview>;
119
+
120
+ const ExpectedPolicyRevision = z.number().int().nonnegative();
121
+ const ExpectedOperationRevision = z.number().int().positive();
122
+ const CommandOperationId = Uuid;
123
+
124
+ export const ConfigureOrganizationRecoveryPolicyRequest = z
125
+ .object({
126
+ custodianMembershipIds: z.tuple([Uuid, Uuid, Uuid]).superRefine((ids, context) => {
127
+ if (new Set(ids).size !== 3) {
128
+ context.addIssue({
129
+ code: "custom",
130
+ message: "recovery custodians must be three distinct memberships",
131
+ });
132
+ }
133
+ }),
134
+ expectedPolicyRevision: ExpectedPolicyRevision,
135
+ operationId: CommandOperationId,
136
+ })
137
+ .strict();
138
+ export type ConfigureOrganizationRecoveryPolicyRequest = z.infer<
139
+ typeof ConfigureOrganizationRecoveryPolicyRequest
140
+ >;
141
+
142
+ export const AcceptOrganizationRecoveryCustodyRequest = z
143
+ .object({
144
+ expectedPolicyRevision: ExpectedPolicyRevision,
145
+ operationId: CommandOperationId,
146
+ })
147
+ .strict();
148
+ export type AcceptOrganizationRecoveryCustodyRequest = z.infer<
149
+ typeof AcceptOrganizationRecoveryCustodyRequest
150
+ >;
151
+
152
+ export const DisableOrganizationRecoveryPolicyRequest = AcceptOrganizationRecoveryCustodyRequest;
153
+ export type DisableOrganizationRecoveryPolicyRequest = z.infer<
154
+ typeof DisableOrganizationRecoveryPolicyRequest
155
+ >;
156
+
157
+ export const StartOrganizationRecoveryOperationRequest = z
158
+ .object({
159
+ targetMembershipId: Uuid,
160
+ expectedPolicyRevision: z.number().int().positive(),
161
+ operationId: CommandOperationId,
162
+ })
163
+ .strict();
164
+ export type StartOrganizationRecoveryOperationRequest = z.infer<
165
+ typeof StartOrganizationRecoveryOperationRequest
166
+ >;
167
+
168
+ export const OrganizationRecoveryOperationCommandRequest = z
169
+ .object({
170
+ expectedOperationRevision: ExpectedOperationRevision,
171
+ operationId: CommandOperationId,
172
+ })
173
+ .strict();
174
+ export type OrganizationRecoveryOperationCommandRequest = z.infer<
175
+ typeof OrganizationRecoveryOperationCommandRequest
176
+ >;
177
+
178
+ export const OrganizationRecoveryMutationResponse = z
179
+ .object({
180
+ replay: z.boolean(),
181
+ overview: OrganizationRecoveryOverview,
182
+ })
183
+ .strict();
184
+ export type OrganizationRecoveryMutationResponse = z.infer<
185
+ typeof OrganizationRecoveryMutationResponse
186
+ >;
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+
3
+ export const SessionStatus = z.enum([
4
+ "queued",
5
+ "running",
6
+ "idle",
7
+ "requires_action",
8
+ "recovering",
9
+ "waiting_capacity",
10
+ "failed",
11
+ "cancelled",
12
+ ]);
13
+ export type SessionStatus = z.infer<typeof SessionStatus>;
14
+
15
+ export const SessionGoalStatus = z.enum(["active", "paused", "completed"]);
16
+ export type SessionGoalStatus = z.infer<typeof SessionGoalStatus>;
17
+
18
+ /** Physical ceiling of the PostgreSQL integer columns that persist depth policy. */
19
+ export const MAX_NESTED_AGENT_DEPTH = 2_147_483_647;
20
+ export const NestedAgentDepthValue = z.number().int().nonnegative().max(MAX_NESTED_AGENT_DEPTH);
21
+ export type NestedAgentDepthValue = z.infer<typeof NestedAgentDepthValue>;