@opengeni/contracts 0.22.0 → 0.26.1

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.
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Adaptive Codex fleet policy, replay contract, and shadow evaluator.
3
+ *
4
+ * This module is deliberately pure and browser-safe. It accepts only bounded,
5
+ * metadata-only snapshots whose candidate keys are opaque aliases assigned by
6
+ * the caller. It never accepts credential ids, account emails, labels, token
7
+ * material, prompts, or tenant activity. The same normalized snapshot can be
8
+ * persisted in a session event, replayed offline, and compared byte-for-byte.
9
+ *
10
+ * V1 is shadow-only at the runtime integration boundary. The evaluator models
11
+ * later placement, admission, manager priority, borrowing, emergency-fuse, and
12
+ * named-overlay semantics so they can be proven with deterministic simulations
13
+ * before any independent kill switch is allowed to affect a live allocation.
14
+ */
15
+ export declare const CODEX_FLEET_POLICY_SCHEMA_VERSION: 1;
16
+ export declare const CODEX_FLEET_POLICY_VERSION: "adaptive-shadow-v1";
17
+ export declare const CODEX_FLEET_POLICY_MAX_CANDIDATES = 32;
18
+ export declare const CODEX_FLEET_POLICY_MAX_OVERLAYS_PER_CANDIDATE = 4;
19
+ /**
20
+ * Replay-integrity ordering for bounded ASCII-safe fleet keys and aliases.
21
+ *
22
+ * Locale-aware collation is intentionally forbidden here because its result
23
+ * can depend on locale and ICU data. Relational string comparison uses
24
+ * ECMAScript UTF-16 code-unit ordering and is therefore identical in Bun,
25
+ * Node, and browsers.
26
+ */
27
+ export declare function compareCodexFleetCanonicalStringsV1(left: string, right: string): number;
28
+ export type CodexFleetConfidence = "unknown" | "low" | "medium" | "high";
29
+ export type CodexFleetCandidateStatus = "active" | "needs_relogin" | "error" | "unknown";
30
+ export type CodexFleetCacheState = "unknown" | "healthy" | "collapsed";
31
+ export type CodexFleetPriority = "standard" | "manager";
32
+ export type CodexFleetPlacementKind = "new" | "fenced_in_flight";
33
+ export type CodexFleetOverlayMode = "none" | "prefer" | "isolate";
34
+ export type CodexFleetQuotaWindowV1 = {
35
+ /** Provider-reported percentage from a workspace-local cache, never inferred tenant truth. */
36
+ usedPercent: number | null;
37
+ /** Relative to input.observedAtMs. Zero means the reported window has reset. */
38
+ resetRemainingMs: number | null;
39
+ };
40
+ export type CodexFleetCandidateV1 = {
41
+ /** Opaque, event-local alias such as c00. Never a credential/account id. */
42
+ key: string;
43
+ status: CodexFleetCandidateStatus;
44
+ allocatorEnabled: boolean;
45
+ /** Relative cooldown. A positive value excludes only NEW placements. */
46
+ cooldownRemainingMs: number | null;
47
+ activeLeaseCount: number;
48
+ quota: {
49
+ primary: CodexFleetQuotaWindowV1;
50
+ secondary: CodexFleetQuotaWindowV1;
51
+ checkedAgeMs: number | null;
52
+ confidence: CodexFleetConfidence;
53
+ };
54
+ /**
55
+ * Runtime-observed cache evidence. It may be absent because the production
56
+ * baseline currently exists as aggregate metrics/logs rather than allocator
57
+ * state. Absence is explicit uncertainty, not a zero cache hit.
58
+ */
59
+ cache: {
60
+ hitRatio: number | null;
61
+ sampledTokens: number | null;
62
+ checkedAgeMs: number | null;
63
+ confidence: CodexFleetConfidence;
64
+ /** Previously latched state; the evaluator applies dwell and recovery thresholds. */
65
+ state: CodexFleetCacheState;
66
+ /** Duration of the current continuous below/above-threshold observation. */
67
+ thresholdObservedForMs: number | null;
68
+ };
69
+ /** Workspace-local observed burn, separate from unexplained/external inference. */
70
+ observedBurn: {
71
+ primaryPercentPerHour: number | null;
72
+ secondaryPercentPerHour: number | null;
73
+ confidence: CodexFleetConfidence;
74
+ };
75
+ /**
76
+ * Unexplained/external burn is an inference only. The name and confidence are
77
+ * load-bearing: consumers must never relabel it as provider or tenant truth.
78
+ */
79
+ inferredUnexplainedBurn: {
80
+ primaryPercentPerHour: number | null;
81
+ secondaryPercentPerHour: number | null;
82
+ confidence: CodexFleetConfidence;
83
+ };
84
+ /** Opaque named-policy keys. Ignored unless overlaysEnabled is independently true. */
85
+ overlayKeys: string[];
86
+ };
87
+ export type CodexFleetAdmissionSnapshotV1 = {
88
+ /** Dynamically observed capacity, not a static per-account slot allocation. */
89
+ dynamicCapacityUnits: number | null;
90
+ inUseUnits: number;
91
+ queuedManagerCount: number;
92
+ emergencyFuseActive: boolean;
93
+ };
94
+ export type CodexFleetDecisionInputV1 = {
95
+ observedAtMs: number;
96
+ request: {
97
+ placement: CodexFleetPlacementKind;
98
+ priority: CodexFleetPriority;
99
+ currentCandidateKey: string | null;
100
+ waitAgeMs: number;
101
+ overlayKey: string | null;
102
+ overlayMode: CodexFleetOverlayMode;
103
+ };
104
+ admission: CodexFleetAdmissionSnapshotV1;
105
+ candidates: CodexFleetCandidateV1[];
106
+ };
107
+ export type CodexFleetPolicyConfigV1 = {
108
+ maxCandidates: number;
109
+ quotaFreshForMs: number;
110
+ quotaStaleAfterMs: number;
111
+ placementUsageCeilingPercent: number;
112
+ cacheFreshForMs: number;
113
+ cacheCollapseThreshold: number;
114
+ cacheCollapseRecoveryThreshold: number;
115
+ cacheMinimumSampledTokens: number;
116
+ cacheCollapseDwellMs: number;
117
+ cacheRecoveryDwellMs: number;
118
+ activeLeaseScore: number;
119
+ unknownQuotaScore: number;
120
+ lowQuotaConfidenceScore: number;
121
+ mediumQuotaConfidenceScore: number;
122
+ inferredBurnScorePerPercentHour: number;
123
+ observedBurnScorePerPercentHour: number;
124
+ /** Maximum exhaustion-before-reset gap that contributes placement pressure. */
125
+ runwayRiskCapHours: number;
126
+ runwayScorePerAtRiskHour: number;
127
+ healthyCacheAffinityBenefit: number;
128
+ unknownCacheAffinityBenefit: number;
129
+ collapsedCacheAffinityBenefit: number;
130
+ switchHysteresisScore: number;
131
+ admissionPacingEnabled: boolean;
132
+ managerPriorityEnabled: boolean;
133
+ managerStandardStarvationMs: number;
134
+ emergencyFuseEnabled: boolean;
135
+ overlaysEnabled: boolean;
136
+ overlayPreferenceScore: number;
137
+ };
138
+ /**
139
+ * Experimental shadow defaults. None of the boolean control fields is enabled;
140
+ * production behavior therefore remains sticky-sharded until operators enable
141
+ * each independently after shadow acceptance.
142
+ */
143
+ export declare const DEFAULT_CODEX_FLEET_POLICY_V1: CodexFleetPolicyConfigV1;
144
+ export type CodexFleetScoreV1 = {
145
+ candidateKey: string;
146
+ eligible: boolean;
147
+ rejectionReason: "allocator_disabled" | "unavailable" | "cooling" | "quota_ceiling" | "overlay_isolation" | null;
148
+ quotaPressure: number;
149
+ leasePressure: number;
150
+ observedBurnPressure: number;
151
+ inferredBurnPressure: number;
152
+ runwayPressure: number;
153
+ uncertaintyPressure: number;
154
+ cacheAffinityBenefit: number;
155
+ cacheState: CodexFleetCacheState;
156
+ overlayPreferenceBenefit: number;
157
+ total: number;
158
+ confidence: CodexFleetConfidence;
159
+ };
160
+ export type CodexFleetAdmissionDecisionV1 = {
161
+ outcome: "admit" | "pace";
162
+ reason: "fenced_in_flight" | "pacing_disabled" | "capacity_unknown" | "capacity_available" | "work_conserving_borrow" | "manager_priority" | "standard_starvation_bound" | "capacity_saturated" | "emergency_fuse";
163
+ /** True only when standard work uses otherwise-idle capacity with no manager backlog. */
164
+ borrowedIdleCapacity: boolean;
165
+ };
166
+ export type CodexFleetDecisionV1 = {
167
+ outcome: "selected" | "paced" | "none";
168
+ selectedCandidateKey: string | null;
169
+ reason: "fenced_in_flight" | "fenced_candidate_missing" | "admission_paced" | "no_eligible_candidate" | "overlay_isolated_empty" | "best_score" | "affinity_best" | "hysteresis_hold";
170
+ admission: CodexFleetAdmissionDecisionV1;
171
+ borrowedOverlayCapacity: boolean;
172
+ strandedEligibleCount: number;
173
+ confidence: CodexFleetConfidence;
174
+ scores: CodexFleetScoreV1[];
175
+ };
176
+ export type CodexFleetReplayRecordV1 = {
177
+ schemaVersion: typeof CODEX_FLEET_POLICY_SCHEMA_VERSION;
178
+ policyVersion: typeof CODEX_FLEET_POLICY_VERSION;
179
+ mode: "shadow";
180
+ policy: CodexFleetPolicyConfigV1;
181
+ input: CodexFleetDecisionInputV1;
182
+ truncatedCandidateCount: number;
183
+ policyFingerprint: string;
184
+ inputFingerprint: string;
185
+ decision: CodexFleetDecisionV1;
186
+ decisionFingerprint: string;
187
+ };
188
+ export type CodexFleetReplayVerdictV1 = {
189
+ matches: boolean;
190
+ policyFingerprintMatches: boolean;
191
+ inputFingerprintMatches: boolean;
192
+ decisionFingerprintMatches: boolean;
193
+ recordedDecisionFingerprintMatches: boolean;
194
+ decision: CodexFleetDecisionV1;
195
+ };
196
+ export declare function createCodexFleetReplayRecordV1(input: CodexFleetDecisionInputV1, policy?: CodexFleetPolicyConfigV1): CodexFleetReplayRecordV1;
197
+ export declare function replayCodexFleetDecisionV1(value: unknown): CodexFleetReplayVerdictV1;
198
+ /**
199
+ * Canonical replay bytes for already-bounded, identity-free fleet values.
200
+ * This is exported so offline tools can prove the exact bytes across runtimes;
201
+ * it performs no redaction and must not be used with raw account metadata.
202
+ */
203
+ export declare function canonicalCodexFleetReplayJsonV1(value: CodexFleetReplayRecordV1): string;
204
+ /**
205
+ * Strict reader for durable/offline replay. Unknown fields, lossy normalization,
206
+ * malformed decisions, and non-SHA-256 digests are rejected before comparison.
207
+ */
208
+ export declare function readCodexFleetReplayRecordV1(value: unknown): CodexFleetReplayRecordV1;
209
+ export declare function evaluateCodexFleetDecisionV1(input: CodexFleetDecisionInputV1, policy?: CodexFleetPolicyConfigV1): CodexFleetDecisionV1;
210
+ export declare function effectiveCodexFleetCacheStateV1(cache: CodexFleetCandidateV1["cache"], policy: CodexFleetPolicyConfigV1): CodexFleetCacheState;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Canonical bounded representation for `session_events.payload`.
3
+ *
4
+ * Session events are the lossy human/audit projection, not model memory and not
5
+ * an evidence blob store. This helper keeps that projection useful while making
6
+ * the loss explicit. It deliberately has no server-only dependency so the DB,
7
+ * realtime transports, SDK/React, and tests can share one wire contract.
8
+ */
9
+ import { type RetainedOutputEvidence } from "./retained-output";
10
+ export declare const SESSION_EVENT_PAYLOAD_MAX_BYTES: number;
11
+ export type SessionEventBoundarySurface = "durable_audit" | "database_guard" | "database_read_projection" | "http_projection" | "nats_legacy_guard" | "sse_legacy_guard" | "browser_legacy_guard";
12
+ export type SessionEventPayloadTruncation = {
13
+ truncated: true;
14
+ surface: SessionEventBoundarySurface;
15
+ reason: "payload_bytes_exceeded" | "payload_not_serializable" | "payload_measurement_bounded" | "inline_media_not_retained" | "database_guard";
16
+ originalBytes: number | null;
17
+ deliveredBytes: number;
18
+ omittedBytes: number | null;
19
+ estimatedOriginalTokens: number | null;
20
+ estimatedDeliveredTokens: number;
21
+ fullEvidence: RetainedOutputEvidence;
22
+ details: Array<{
23
+ path: string;
24
+ kind: "string" | "array" | "object" | "depth" | "budget" | "media" | "binary" | "unserializable";
25
+ originalBytes?: number;
26
+ deliveredBytes?: number;
27
+ omittedEntries?: number | null;
28
+ mediaType?: string;
29
+ }>;
30
+ };
31
+ export type BoundSessionEventPayloadOptions = {
32
+ surface?: SessionEventBoundarySurface;
33
+ maxBytes?: number;
34
+ /**
35
+ * Separately trusted durable receipt. Producer payload fields never populate
36
+ * this slot; invalid values fail closed to not_retained.
37
+ */
38
+ fullEvidence?: unknown;
39
+ };
40
+ export type SessionEventJsonMeasurement = {
41
+ bytes: number;
42
+ reason: null;
43
+ } | {
44
+ bytes: null;
45
+ reason: "payload_not_serializable" | "payload_measurement_bounded";
46
+ };
47
+ export type SessionEventMediaPreview = {
48
+ type: "media_preview";
49
+ mediaType: string;
50
+ inlineBytes: number | null;
51
+ fullOutputAvailable: false;
52
+ preview: string;
53
+ };
54
+ /** UTF-8 bytes used by the JSON wire/storage representation. */
55
+ export declare function sessionEventJsonBytes(value: unknown): number;
56
+ /**
57
+ * Inspect a prospective event value without invoking accessors, custom
58
+ * serializers, or allocating its complete JSON representation. A null byte
59
+ * count is explicit: the traversal stopped at the global work/depth boundary
60
+ * or found serialization behavior that must first be normalized.
61
+ */
62
+ export declare function measureSessionEventJson(value: unknown): SessionEventJsonMeasurement;
63
+ /** The same deliberately coarse bytes/4 token estimate used by Codex parity code. */
64
+ export declare function approximateSessionEventTokens(bytes: number): number;
65
+ /** Truthful audit fact for inline media whose source bytes are not durably retained. */
66
+ export declare function sessionEventMediaPreview(mediaType: string, inlineBytes: number | null): SessionEventMediaPreview;
67
+ /** Parse a base64 data URL into a compact audit fact without decoding/copying its bytes. */
68
+ export declare function sessionEventMediaPreviewFromDataUrl(value: string): SessionEventMediaPreview | null;
69
+ /** Read explicit truncation metadata from a bounded object payload. */
70
+ export declare function sessionEventPayloadTruncation(payload: unknown): SessionEventPayloadTruncation | null;
71
+ /**
72
+ * Return a byte-bounded audit payload. Unchanged ordinary payloads retain their
73
+ * reference. Oversized strings/containers get deterministic head+tail previews;
74
+ * inline images/binary values become metadata because `session_events` does not
75
+ * durably retain their source bytes as independently retrievable evidence.
76
+ */
77
+ export declare function boundSessionEventPayload<T>(payload: T, options?: BoundSessionEventPayloadOptions): T;
@@ -0,0 +1,215 @@
1
+ import { z } from "zod";
2
+ export declare const GOOGLE_DRIVE_PROVIDER_DOMAIN: "googleapis.com";
3
+ export declare const GOOGLE_DRIVE_METADATA_READONLY_SCOPE: "https://www.googleapis.com/auth/drive.metadata.readonly";
4
+ export declare const GOOGLE_DRIVE_READONLY_SCOPE: "https://www.googleapis.com/auth/drive.readonly";
5
+ export declare const GOOGLE_DRIVE_CREDENTIAL_ROLE: "google_drive_metadata";
6
+ export declare const GOOGLE_DRIVE_CREDENTIAL_LABEL: "Google Drive metadata browser";
7
+ export declare const GoogleDriveTargetScope: z.ZodEnum<{
8
+ organization: "organization";
9
+ user: "user";
10
+ workspace: "workspace";
11
+ }>;
12
+ export type GoogleDriveTargetScope = z.infer<typeof GoogleDriveTargetScope>;
13
+ export declare const GoogleDriveSyncCadence: z.ZodEnum<{
14
+ daily: "daily";
15
+ hourly: "hourly";
16
+ manual: "manual";
17
+ }>;
18
+ export type GoogleDriveSyncCadence = z.infer<typeof GoogleDriveSyncCadence>;
19
+ export declare const GoogleDriveReadPolicy: z.ZodEnum<{
20
+ allow: "allow";
21
+ ask: "ask";
22
+ block: "block";
23
+ }>;
24
+ export type GoogleDriveReadPolicy = z.infer<typeof GoogleDriveReadPolicy>;
25
+ export declare const GoogleDriveSelectedSource: z.ZodObject<{
26
+ id: z.ZodString;
27
+ name: z.ZodString;
28
+ mimeType: z.ZodString;
29
+ driveId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
30
+ targetScope: z.ZodEnum<{
31
+ organization: "organization";
32
+ user: "user";
33
+ workspace: "workspace";
34
+ }>;
35
+ syncCadence: z.ZodDefault<z.ZodEnum<{
36
+ daily: "daily";
37
+ hourly: "hourly";
38
+ manual: "manual";
39
+ }>>;
40
+ readPolicy: z.ZodDefault<z.ZodEnum<{
41
+ allow: "allow";
42
+ ask: "ask";
43
+ block: "block";
44
+ }>>;
45
+ selectedAt: z.ZodString;
46
+ }, z.core.$strip>;
47
+ export type GoogleDriveSelectedSource = z.infer<typeof GoogleDriveSelectedSource>;
48
+ export declare const GoogleDriveConnectionMetadata: z.ZodObject<{
49
+ credentialRole: z.ZodLiteral<"google_drive_metadata">;
50
+ credentialLabel: z.ZodLiteral<"Google Drive metadata browser">;
51
+ googlePermissionId: z.ZodString;
52
+ googleEmail: z.ZodString;
53
+ googleDisplayName: z.ZodNullable<z.ZodString>;
54
+ verifiedAt: z.ZodString;
55
+ accessMode: z.ZodEnum<{
56
+ metadata_readonly: "metadata_readonly";
57
+ readonly: "readonly";
58
+ }>;
59
+ selectedSources: z.ZodOptional<z.ZodArray<z.ZodObject<{
60
+ id: z.ZodString;
61
+ name: z.ZodString;
62
+ mimeType: z.ZodString;
63
+ driveId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
64
+ targetScope: z.ZodEnum<{
65
+ organization: "organization";
66
+ user: "user";
67
+ workspace: "workspace";
68
+ }>;
69
+ syncCadence: z.ZodDefault<z.ZodEnum<{
70
+ daily: "daily";
71
+ hourly: "hourly";
72
+ manual: "manual";
73
+ }>>;
74
+ readPolicy: z.ZodDefault<z.ZodEnum<{
75
+ allow: "allow";
76
+ ask: "ask";
77
+ block: "block";
78
+ }>>;
79
+ selectedAt: z.ZodString;
80
+ }, z.core.$strip>>>;
81
+ selectedSource: z.ZodOptional<z.ZodNullable<z.ZodObject<{
82
+ id: z.ZodString;
83
+ name: z.ZodString;
84
+ mimeType: z.ZodString;
85
+ driveId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
86
+ targetScope: z.ZodEnum<{
87
+ organization: "organization";
88
+ user: "user";
89
+ workspace: "workspace";
90
+ }>;
91
+ syncCadence: z.ZodDefault<z.ZodEnum<{
92
+ daily: "daily";
93
+ hourly: "hourly";
94
+ manual: "manual";
95
+ }>>;
96
+ readPolicy: z.ZodDefault<z.ZodEnum<{
97
+ allow: "allow";
98
+ ask: "ask";
99
+ block: "block";
100
+ }>>;
101
+ selectedAt: z.ZodString;
102
+ }, z.core.$strip>>>;
103
+ }, z.core.$loose>;
104
+ export type GoogleDriveConnectionMetadata = z.infer<typeof GoogleDriveConnectionMetadata>;
105
+ export declare const GoogleDriveOAuthStartRequest: z.ZodObject<{
106
+ connectionId: z.ZodOptional<z.ZodString>;
107
+ }, z.core.$strip>;
108
+ export type GoogleDriveOAuthStartRequest = z.infer<typeof GoogleDriveOAuthStartRequest>;
109
+ export declare const GoogleDriveOAuthStartResponse: z.ZodObject<{
110
+ authorizationUrl: z.ZodString;
111
+ expiresAt: z.ZodString;
112
+ }, z.core.$strip>;
113
+ export type GoogleDriveOAuthStartResponse = z.infer<typeof GoogleDriveOAuthStartResponse>;
114
+ export declare const GoogleDriveBrowseItem: z.ZodObject<{
115
+ id: z.ZodString;
116
+ name: z.ZodString;
117
+ mimeType: z.ZodString;
118
+ kind: z.ZodEnum<{
119
+ file: "file";
120
+ folder: "folder";
121
+ }>;
122
+ driveId: z.ZodNullable<z.ZodString>;
123
+ modifiedTime: z.ZodNullable<z.ZodString>;
124
+ size: z.ZodNullable<z.ZodString>;
125
+ webViewLink: z.ZodNullable<z.ZodString>;
126
+ }, z.core.$strip>;
127
+ export type GoogleDriveBrowseItem = z.infer<typeof GoogleDriveBrowseItem>;
128
+ export declare const GoogleDriveBrowseResponse: z.ZodObject<{
129
+ connection: z.ZodLazy<z.ZodObject<{
130
+ id: z.ZodString;
131
+ accountId: z.ZodString;
132
+ workspaceId: z.ZodString;
133
+ subjectId: z.ZodNullable<z.ZodString>;
134
+ providerDomain: z.ZodString;
135
+ kind: z.ZodEnum<{
136
+ api_key: "api_key";
137
+ app_install: "app_install";
138
+ delegated: "delegated";
139
+ oauth2: "oauth2";
140
+ }>;
141
+ status: z.ZodEnum<{
142
+ active: "active";
143
+ error: "error";
144
+ needs_reauth: "needs_reauth";
145
+ revoked: "revoked";
146
+ }>;
147
+ grantedScopes: z.ZodArray<z.ZodString>;
148
+ expiresAt: z.ZodNullable<z.ZodString>;
149
+ lastRefreshAt: z.ZodNullable<z.ZodString>;
150
+ lastUsedAt: z.ZodNullable<z.ZodString>;
151
+ lastError: z.ZodNullable<z.ZodString>;
152
+ version: z.ZodNumber;
153
+ verifiedInstallAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
154
+ verifiedInstallVersion: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
155
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
156
+ createdBySubjectId: z.ZodNullable<z.ZodString>;
157
+ updatedBySubjectId: z.ZodNullable<z.ZodString>;
158
+ createdAt: z.ZodString;
159
+ updatedAt: z.ZodString;
160
+ }, z.core.$strip>>;
161
+ parentId: z.ZodString;
162
+ current: z.ZodNullable<z.ZodObject<{
163
+ id: z.ZodString;
164
+ name: z.ZodString;
165
+ mimeType: z.ZodString;
166
+ kind: z.ZodEnum<{
167
+ file: "file";
168
+ folder: "folder";
169
+ }>;
170
+ driveId: z.ZodNullable<z.ZodString>;
171
+ modifiedTime: z.ZodNullable<z.ZodString>;
172
+ size: z.ZodNullable<z.ZodString>;
173
+ webViewLink: z.ZodNullable<z.ZodString>;
174
+ }, z.core.$strip>>;
175
+ items: z.ZodArray<z.ZodObject<{
176
+ id: z.ZodString;
177
+ name: z.ZodString;
178
+ mimeType: z.ZodString;
179
+ kind: z.ZodEnum<{
180
+ file: "file";
181
+ folder: "folder";
182
+ }>;
183
+ driveId: z.ZodNullable<z.ZodString>;
184
+ modifiedTime: z.ZodNullable<z.ZodString>;
185
+ size: z.ZodNullable<z.ZodString>;
186
+ webViewLink: z.ZodNullable<z.ZodString>;
187
+ }, z.core.$strip>>;
188
+ nextPageToken: z.ZodNullable<z.ZodString>;
189
+ incompleteSearch: z.ZodBoolean;
190
+ }, z.core.$strip>;
191
+ export type GoogleDriveBrowseResponse = z.infer<typeof GoogleDriveBrowseResponse>;
192
+ export declare const SaveGoogleDriveSourceRequest: z.ZodObject<{
193
+ sources: z.ZodArray<z.ZodObject<{
194
+ id: z.ZodString;
195
+ name: z.ZodString;
196
+ mimeType: z.ZodString;
197
+ driveId: z.ZodNullable<z.ZodString>;
198
+ }, z.core.$strip>>;
199
+ targetScope: z.ZodEnum<{
200
+ organization: "organization";
201
+ user: "user";
202
+ workspace: "workspace";
203
+ }>;
204
+ syncCadence: z.ZodDefault<z.ZodEnum<{
205
+ daily: "daily";
206
+ hourly: "hourly";
207
+ manual: "manual";
208
+ }>>;
209
+ readPolicy: z.ZodDefault<z.ZodEnum<{
210
+ allow: "allow";
211
+ ask: "ask";
212
+ block: "block";
213
+ }>>;
214
+ }, z.core.$strip>;
215
+ export type SaveGoogleDriveSourceRequest = z.infer<typeof SaveGoogleDriveSourceRequest>;
@@ -0,0 +1,95 @@
1
+ import {
2
+ ConnectionMetadata
3
+ } from "./chunk-ESXP7QLV.js";
4
+ import "./chunk-3B3XEYMN.js";
5
+
6
+ // src/google-drive.ts
7
+ import { z } from "zod";
8
+ var GOOGLE_DRIVE_PROVIDER_DOMAIN = "googleapis.com";
9
+ var GOOGLE_DRIVE_METADATA_READONLY_SCOPE = "https://www.googleapis.com/auth/drive.metadata.readonly";
10
+ var GOOGLE_DRIVE_READONLY_SCOPE = "https://www.googleapis.com/auth/drive.readonly";
11
+ var GOOGLE_DRIVE_CREDENTIAL_ROLE = "google_drive_metadata";
12
+ var GOOGLE_DRIVE_CREDENTIAL_LABEL = "Google Drive metadata browser";
13
+ var GoogleDriveTargetScope = z.enum(["user", "workspace", "organization"]);
14
+ var GoogleDriveSyncCadence = z.enum(["manual", "hourly", "daily"]);
15
+ var GoogleDriveReadPolicy = z.enum(["allow", "ask", "block"]);
16
+ var GoogleDriveSelectedSource = z.object({
17
+ id: z.string().min(1).max(256),
18
+ name: z.string().min(1).max(1024),
19
+ mimeType: z.string().min(1).max(256),
20
+ driveId: z.string().min(1).max(256).nullable().default(null),
21
+ targetScope: GoogleDriveTargetScope,
22
+ syncCadence: GoogleDriveSyncCadence.default("hourly"),
23
+ readPolicy: GoogleDriveReadPolicy.default("allow"),
24
+ selectedAt: z.string().datetime({ offset: true })
25
+ });
26
+ var GoogleDriveConnectionMetadata = z.object({
27
+ credentialRole: z.literal(GOOGLE_DRIVE_CREDENTIAL_ROLE),
28
+ credentialLabel: z.literal(GOOGLE_DRIVE_CREDENTIAL_LABEL),
29
+ googlePermissionId: z.string().min(1).max(256),
30
+ googleEmail: z.string().email().max(320),
31
+ googleDisplayName: z.string().min(1).max(512).nullable(),
32
+ verifiedAt: z.string().datetime({ offset: true }),
33
+ accessMode: z.enum(["metadata_readonly", "readonly"]),
34
+ selectedSources: z.array(GoogleDriveSelectedSource).max(100).optional(),
35
+ /** @deprecated Read `selectedSources`; retained while existing connections migrate. */
36
+ selectedSource: GoogleDriveSelectedSource.nullable().optional()
37
+ }).passthrough();
38
+ var GoogleDriveOAuthStartRequest = z.object({
39
+ connectionId: z.string().uuid().optional()
40
+ });
41
+ var GoogleDriveOAuthStartResponse = z.object({
42
+ authorizationUrl: z.string().url(),
43
+ expiresAt: z.string().datetime({ offset: true })
44
+ });
45
+ var GoogleDriveBrowseItem = z.object({
46
+ id: z.string().min(1).max(256),
47
+ name: z.string().min(1).max(1024),
48
+ mimeType: z.string().min(1).max(256),
49
+ kind: z.enum(["folder", "file"]),
50
+ driveId: z.string().min(1).max(256).nullable(),
51
+ modifiedTime: z.string().datetime({ offset: true }).nullable(),
52
+ size: z.string().regex(/^\d+$/).nullable(),
53
+ webViewLink: z.string().url().nullable()
54
+ });
55
+ var GoogleDriveBrowseResponse = z.object({
56
+ connection: z.lazy(() => ConnectionMetadata),
57
+ parentId: z.string().min(1).max(256),
58
+ current: GoogleDriveBrowseItem.nullable(),
59
+ items: z.array(GoogleDriveBrowseItem),
60
+ nextPageToken: z.string().min(1).max(4096).nullable(),
61
+ incompleteSearch: z.boolean()
62
+ });
63
+ var SaveGoogleDriveSourceRequest = z.object({
64
+ sources: z.array(
65
+ GoogleDriveBrowseItem.pick({
66
+ id: true,
67
+ name: true,
68
+ mimeType: true,
69
+ driveId: true
70
+ })
71
+ ).max(100).refine((sources) => new Set(sources.map((source) => source.id)).size === sources.length, {
72
+ message: "Google Drive sources must be unique"
73
+ }),
74
+ targetScope: GoogleDriveTargetScope,
75
+ syncCadence: GoogleDriveSyncCadence.default("hourly"),
76
+ readPolicy: GoogleDriveReadPolicy.default("allow")
77
+ });
78
+ export {
79
+ GOOGLE_DRIVE_CREDENTIAL_LABEL,
80
+ GOOGLE_DRIVE_CREDENTIAL_ROLE,
81
+ GOOGLE_DRIVE_METADATA_READONLY_SCOPE,
82
+ GOOGLE_DRIVE_PROVIDER_DOMAIN,
83
+ GOOGLE_DRIVE_READONLY_SCOPE,
84
+ GoogleDriveBrowseItem,
85
+ GoogleDriveBrowseResponse,
86
+ GoogleDriveConnectionMetadata,
87
+ GoogleDriveOAuthStartRequest,
88
+ GoogleDriveOAuthStartResponse,
89
+ GoogleDriveReadPolicy,
90
+ GoogleDriveSelectedSource,
91
+ GoogleDriveSyncCadence,
92
+ GoogleDriveTargetScope,
93
+ SaveGoogleDriveSourceRequest
94
+ };
95
+ //# sourceMappingURL=google-drive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/google-drive.ts"],"sourcesContent":["import { z } from \"zod\";\n\nimport { ConnectionMetadata } from \"./index\";\n\nexport const GOOGLE_DRIVE_PROVIDER_DOMAIN = \"googleapis.com\" as const;\nexport const GOOGLE_DRIVE_METADATA_READONLY_SCOPE =\n \"https://www.googleapis.com/auth/drive.metadata.readonly\" as const;\nexport const GOOGLE_DRIVE_READONLY_SCOPE =\n \"https://www.googleapis.com/auth/drive.readonly\" as const;\nexport const GOOGLE_DRIVE_CREDENTIAL_ROLE = \"google_drive_metadata\" as const;\nexport const GOOGLE_DRIVE_CREDENTIAL_LABEL = \"Google Drive metadata browser\" as const;\n\nexport const GoogleDriveTargetScope = z.enum([\"user\", \"workspace\", \"organization\"]);\nexport type GoogleDriveTargetScope = z.infer<typeof GoogleDriveTargetScope>;\n\nexport const GoogleDriveSyncCadence = z.enum([\"manual\", \"hourly\", \"daily\"]);\nexport type GoogleDriveSyncCadence = z.infer<typeof GoogleDriveSyncCadence>;\n\nexport const GoogleDriveReadPolicy = z.enum([\"allow\", \"ask\", \"block\"]);\nexport type GoogleDriveReadPolicy = z.infer<typeof GoogleDriveReadPolicy>;\n\nexport const GoogleDriveSelectedSource = z.object({\n id: z.string().min(1).max(256),\n name: z.string().min(1).max(1024),\n mimeType: z.string().min(1).max(256),\n driveId: z.string().min(1).max(256).nullable().default(null),\n targetScope: GoogleDriveTargetScope,\n syncCadence: GoogleDriveSyncCadence.default(\"hourly\"),\n readPolicy: GoogleDriveReadPolicy.default(\"allow\"),\n selectedAt: z.string().datetime({ offset: true }),\n});\nexport type GoogleDriveSelectedSource = z.infer<typeof GoogleDriveSelectedSource>;\n\nexport const GoogleDriveConnectionMetadata = z\n .object({\n credentialRole: z.literal(GOOGLE_DRIVE_CREDENTIAL_ROLE),\n credentialLabel: z.literal(GOOGLE_DRIVE_CREDENTIAL_LABEL),\n googlePermissionId: z.string().min(1).max(256),\n googleEmail: z.string().email().max(320),\n googleDisplayName: z.string().min(1).max(512).nullable(),\n verifiedAt: z.string().datetime({ offset: true }),\n accessMode: z.enum([\"metadata_readonly\", \"readonly\"]),\n selectedSources: z.array(GoogleDriveSelectedSource).max(100).optional(),\n /** @deprecated Read `selectedSources`; retained while existing connections migrate. */\n selectedSource: GoogleDriveSelectedSource.nullable().optional(),\n })\n .passthrough();\nexport type GoogleDriveConnectionMetadata = z.infer<typeof GoogleDriveConnectionMetadata>;\n\nexport const GoogleDriveOAuthStartRequest = z.object({\n connectionId: z.string().uuid().optional(),\n});\nexport type GoogleDriveOAuthStartRequest = z.infer<typeof GoogleDriveOAuthStartRequest>;\n\nexport const GoogleDriveOAuthStartResponse = z.object({\n authorizationUrl: z.string().url(),\n expiresAt: z.string().datetime({ offset: true }),\n});\nexport type GoogleDriveOAuthStartResponse = z.infer<typeof GoogleDriveOAuthStartResponse>;\n\nexport const GoogleDriveBrowseItem = z.object({\n id: z.string().min(1).max(256),\n name: z.string().min(1).max(1024),\n mimeType: z.string().min(1).max(256),\n kind: z.enum([\"folder\", \"file\"]),\n driveId: z.string().min(1).max(256).nullable(),\n modifiedTime: z.string().datetime({ offset: true }).nullable(),\n size: z.string().regex(/^\\d+$/).nullable(),\n webViewLink: z.string().url().nullable(),\n});\nexport type GoogleDriveBrowseItem = z.infer<typeof GoogleDriveBrowseItem>;\n\nexport const GoogleDriveBrowseResponse = z.object({\n connection: z.lazy(() => ConnectionMetadata),\n parentId: z.string().min(1).max(256),\n current: GoogleDriveBrowseItem.nullable(),\n items: z.array(GoogleDriveBrowseItem),\n nextPageToken: z.string().min(1).max(4096).nullable(),\n incompleteSearch: z.boolean(),\n});\nexport type GoogleDriveBrowseResponse = z.infer<typeof GoogleDriveBrowseResponse>;\n\nexport const SaveGoogleDriveSourceRequest = z.object({\n sources: z\n .array(\n GoogleDriveBrowseItem.pick({\n id: true,\n name: true,\n mimeType: true,\n driveId: true,\n }),\n )\n .max(100)\n .refine((sources) => new Set(sources.map((source) => source.id)).size === sources.length, {\n message: \"Google Drive sources must be unique\",\n }),\n targetScope: GoogleDriveTargetScope,\n syncCadence: GoogleDriveSyncCadence.default(\"hourly\"),\n readPolicy: GoogleDriveReadPolicy.default(\"allow\"),\n});\nexport type SaveGoogleDriveSourceRequest = z.infer<typeof SaveGoogleDriveSourceRequest>;\n"],"mappings":"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","names":[]}