@oxy.so/contracts 1.0.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 (147) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +16 -0
  3. package/dist/cjs/.tsbuildinfo +1 -0
  4. package/dist/cjs/accountGraph.js +489 -0
  5. package/dist/cjs/agency.js +439 -0
  6. package/dist/cjs/browserHub.js +215 -0
  7. package/dist/cjs/civic.js +163 -0
  8. package/dist/cjs/commonsSignIn.js +59 -0
  9. package/dist/cjs/deviceBoot.js +50 -0
  10. package/dist/cjs/deviceDirectory.js +189 -0
  11. package/dist/cjs/devicePairing.js +138 -0
  12. package/dist/cjs/deviceSession.js +164 -0
  13. package/dist/cjs/emailAgentContext.js +32 -0
  14. package/dist/cjs/followGraph.js +28 -0
  15. package/dist/cjs/identity.js +258 -0
  16. package/dist/cjs/inboxPush.js +24 -0
  17. package/dist/cjs/index.js +618 -0
  18. package/dist/cjs/inference/accountBilling.js +334 -0
  19. package/dist/cjs/inference/aliaModelRelease.js +262 -0
  20. package/dist/cjs/inference/attribution.js +106 -0
  21. package/dist/cjs/inference/catalogue.js +487 -0
  22. package/dist/cjs/inference/entitlement.js +217 -0
  23. package/dist/cjs/inference/errors.js +309 -0
  24. package/dist/cjs/inference/identifiers.js +224 -0
  25. package/dist/cjs/inference/inbox.js +105 -0
  26. package/dist/cjs/inference/modelDocumentation.js +433 -0
  27. package/dist/cjs/inference/money.js +188 -0
  28. package/dist/cjs/inference/priceVersion.js +110 -0
  29. package/dist/cjs/inference/providerConnection.js +455 -0
  30. package/dist/cjs/inference/request.js +477 -0
  31. package/dist/cjs/inference/routingPolicy.js +318 -0
  32. package/dist/cjs/inference/streamEvents.js +258 -0
  33. package/dist/cjs/inference/usage.js +329 -0
  34. package/dist/cjs/inference/version.js +105 -0
  35. package/dist/cjs/keyRecovery.js +91 -0
  36. package/dist/cjs/keyRotation.js +75 -0
  37. package/dist/cjs/links.js +68 -0
  38. package/dist/cjs/moderationReputation.js +298 -0
  39. package/dist/cjs/oauth.js +66 -0
  40. package/dist/cjs/oxyRecordTypes.js +71 -0
  41. package/dist/cjs/protocol.js +53 -0
  42. package/dist/cjs/recommendations.js +168 -0
  43. package/dist/cjs/reputation.js +297 -0
  44. package/dist/cjs/sessionStatus.js +121 -0
  45. package/dist/cjs/transparency.js +89 -0
  46. package/dist/cjs/updates.js +252 -0
  47. package/dist/cjs/userInvalidation.js +89 -0
  48. package/dist/cjs/userResponse.js +245 -0
  49. package/dist/cjs/username.js +290 -0
  50. package/dist/cjs/webauthn.js +71 -0
  51. package/dist/esm/.tsbuildinfo +1 -0
  52. package/dist/esm/accountGraph.js +480 -0
  53. package/dist/esm/agency.js +436 -0
  54. package/dist/esm/browserHub.js +212 -0
  55. package/dist/esm/civic.js +160 -0
  56. package/dist/esm/commonsSignIn.js +56 -0
  57. package/dist/esm/deviceBoot.js +47 -0
  58. package/dist/esm/deviceDirectory.js +186 -0
  59. package/dist/esm/devicePairing.js +135 -0
  60. package/dist/esm/deviceSession.js +161 -0
  61. package/dist/esm/emailAgentContext.js +29 -0
  62. package/dist/esm/followGraph.js +27 -0
  63. package/dist/esm/identity.js +255 -0
  64. package/dist/esm/inboxPush.js +21 -0
  65. package/dist/esm/index.js +172 -0
  66. package/dist/esm/inference/accountBilling.js +331 -0
  67. package/dist/esm/inference/aliaModelRelease.js +259 -0
  68. package/dist/esm/inference/attribution.js +103 -0
  69. package/dist/esm/inference/catalogue.js +484 -0
  70. package/dist/esm/inference/entitlement.js +214 -0
  71. package/dist/esm/inference/errors.js +306 -0
  72. package/dist/esm/inference/identifiers.js +221 -0
  73. package/dist/esm/inference/inbox.js +102 -0
  74. package/dist/esm/inference/modelDocumentation.js +430 -0
  75. package/dist/esm/inference/money.js +185 -0
  76. package/dist/esm/inference/priceVersion.js +107 -0
  77. package/dist/esm/inference/providerConnection.js +452 -0
  78. package/dist/esm/inference/request.js +474 -0
  79. package/dist/esm/inference/routingPolicy.js +315 -0
  80. package/dist/esm/inference/streamEvents.js +255 -0
  81. package/dist/esm/inference/usage.js +326 -0
  82. package/dist/esm/inference/version.js +102 -0
  83. package/dist/esm/keyRecovery.js +88 -0
  84. package/dist/esm/keyRotation.js +72 -0
  85. package/dist/esm/links.js +65 -0
  86. package/dist/esm/moderationReputation.js +295 -0
  87. package/dist/esm/oauth.js +63 -0
  88. package/dist/esm/oxyRecordTypes.js +68 -0
  89. package/dist/esm/protocol.js +50 -0
  90. package/dist/esm/recommendations.js +165 -0
  91. package/dist/esm/reputation.js +293 -0
  92. package/dist/esm/sessionStatus.js +118 -0
  93. package/dist/esm/transparency.js +86 -0
  94. package/dist/esm/updates.js +249 -0
  95. package/dist/esm/userInvalidation.js +85 -0
  96. package/dist/esm/userResponse.js +240 -0
  97. package/dist/esm/username.js +283 -0
  98. package/dist/esm/webauthn.js +68 -0
  99. package/dist/types/.tsbuildinfo +1 -0
  100. package/dist/types/accountGraph.d.ts +378 -0
  101. package/dist/types/agency.d.ts +2162 -0
  102. package/dist/types/browserHub.d.ts +856 -0
  103. package/dist/types/civic.d.ts +338 -0
  104. package/dist/types/commonsSignIn.d.ts +58 -0
  105. package/dist/types/deviceBoot.d.ts +74 -0
  106. package/dist/types/deviceDirectory.d.ts +1317 -0
  107. package/dist/types/devicePairing.d.ts +130 -0
  108. package/dist/types/deviceSession.d.ts +411 -0
  109. package/dist/types/emailAgentContext.d.ts +248 -0
  110. package/dist/types/followGraph.d.ts +150 -0
  111. package/dist/types/identity.d.ts +402 -0
  112. package/dist/types/inboxPush.d.ts +30 -0
  113. package/dist/types/index.d.ts +100 -0
  114. package/dist/types/inference/accountBilling.d.ts +738 -0
  115. package/dist/types/inference/aliaModelRelease.d.ts +609 -0
  116. package/dist/types/inference/attribution.d.ts +176 -0
  117. package/dist/types/inference/catalogue.d.ts +1618 -0
  118. package/dist/types/inference/entitlement.d.ts +519 -0
  119. package/dist/types/inference/errors.d.ts +242 -0
  120. package/dist/types/inference/identifiers.d.ts +182 -0
  121. package/dist/types/inference/inbox.d.ts +374 -0
  122. package/dist/types/inference/modelDocumentation.d.ts +1603 -0
  123. package/dist/types/inference/money.d.ts +185 -0
  124. package/dist/types/inference/priceVersion.d.ts +182 -0
  125. package/dist/types/inference/providerConnection.d.ts +968 -0
  126. package/dist/types/inference/request.d.ts +2800 -0
  127. package/dist/types/inference/routingPolicy.d.ts +616 -0
  128. package/dist/types/inference/streamEvents.d.ts +950 -0
  129. package/dist/types/inference/usage.d.ts +1164 -0
  130. package/dist/types/inference/version.d.ts +102 -0
  131. package/dist/types/keyRecovery.d.ts +138 -0
  132. package/dist/types/keyRotation.d.ts +103 -0
  133. package/dist/types/links.d.ts +96 -0
  134. package/dist/types/moderationReputation.d.ts +487 -0
  135. package/dist/types/oauth.d.ts +86 -0
  136. package/dist/types/oxyRecordTypes.d.ts +62 -0
  137. package/dist/types/protocol.d.ts +86 -0
  138. package/dist/types/recommendations.d.ts +542 -0
  139. package/dist/types/reputation.d.ts +457 -0
  140. package/dist/types/sessionStatus.d.ts +231 -0
  141. package/dist/types/transparency.d.ts +392 -0
  142. package/dist/types/updates.d.ts +545 -0
  143. package/dist/types/userInvalidation.d.ts +94 -0
  144. package/dist/types/userResponse.d.ts +1706 -0
  145. package/dist/types/username.d.ts +265 -0
  146. package/dist/types/webauthn.d.ts +77 -0
  147. package/package.json +87 -0
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ /**
3
+ * Identifiers, references and wire primitives shared by every Oxy↔data-plane
4
+ * inference contract.
5
+ *
6
+ * Two kinds of identifier live here, and the difference matters:
7
+ *
8
+ * - **Principal identifiers** owned by Oxy (`accountId`, `applicationId`,
9
+ * `credentialId`, the optional delegated `userId`). The data plane may store
10
+ * them as immutable references; it never owns, mints or mutates them.
11
+ * - **Catalogue references** (`<publisher>/<model>`, `<publisher>/<model>@<revision>`,
12
+ * a routing-profile slug). These are the strings a customer types, so their
13
+ * grammar is part of the public contract, not an implementation detail.
14
+ *
15
+ * Platform-agnostic — zod only. Every regex here is plain ASCII: this package
16
+ * is imported by React Native apps running on Hermes, which rejects Unicode
17
+ * property escapes (`\p{…}`) at runtime.
18
+ *
19
+ * Decided in: docs/adr/0007-canonical-request-attribution.md, docs/adr/0008-catalogue-concept-separation.md.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.RESERVED_ALIA_PUBLISHER = exports.inferenceRegionSchema = exports.deploymentIdSchema = exports.inferenceProviderSlugSchema = exports.routingProfileIdSchema = exports.routingProfileSlugSchema = exports.modelReferenceSchema = exports.modelRevisionLabelSchema = exports.modelIdSchema = exports.modelSlugSchema = exports.publisherSlugSchema = exports.sha256DigestSchema = exports.inferenceHttpsUrlSchema = exports.inferenceDateSchema = exports.inferenceTimestampSchema = exports.inferenceEnvironmentSchema = exports.idempotencyKeySchema = exports.generationIdSchema = exports.requestIdSchema = exports.oxyCredentialIdSchema = exports.oxyApplicationIdSchema = exports.delegatedUserIdSchema = exports.oxyAccountIdSchema = void 0;
23
+ const zod_1 = require("zod");
24
+ /* -------------------------------------------------------------------------- */
25
+ /* Principal identifiers */
26
+ /* -------------------------------------------------------------------------- */
27
+ /**
28
+ * An Oxy account id — the account that owns the workload and is financially
29
+ * responsible for it.
30
+ *
31
+ * Branded, and that brand is load-bearing rather than decorative: it is the
32
+ * type-level half of the rule that a delegated end-user identity can never
33
+ * become the billing identity (see {@link delegatedUserIdSchema} and
34
+ * `billingPrincipalSchema`). A plain `string` — and therefore any id read out
35
+ * of a header, a JWT claim or a request body — is not assignable to it; the
36
+ * only way to obtain one is to parse a value through this schema.
37
+ */
38
+ exports.oxyAccountIdSchema = zod_1.z.string().min(1).max(64).brand();
39
+ /**
40
+ * A delegated end-user identity (Alia's `X-Oxy-User-Id`), branded with a
41
+ * DIFFERENT brand from {@link oxyAccountIdSchema} so the two cannot be
42
+ * substituted for one another in either direction, in any consumer, without a
43
+ * cast that review would catch.
44
+ *
45
+ * It exists for attribution and product-side personalisation only. It is never
46
+ * a billing principal, never an access-control principal, and its presence
47
+ * never changes which account is charged.
48
+ */
49
+ exports.delegatedUserIdSchema = zod_1.z.string().min(1).max(64).brand();
50
+ /**
51
+ * An Oxy `Application._id`. Not branded: no invariant in this contract turns on
52
+ * confusing it with another id, and brand inflation costs every producer a
53
+ * parse call for no safety. The two ids above are branded because ADR 0007's
54
+ * rule is exactly that they must not be interchangeable.
55
+ */
56
+ exports.oxyApplicationIdSchema = zod_1.z.string().min(1).max(64);
57
+ /** An Oxy `ApplicationCredential._id` — the credential used for this request. */
58
+ exports.oxyCredentialIdSchema = zod_1.z.string().min(1).max(64);
59
+ /**
60
+ * A request id allocated by the Oxy EDGE, at admission and BEFORE
61
+ * authentication, so that a request rejected for a bad credential is as
62
+ * traceable as one that was served (ADR 0007, and step 1 of ADR 0010's edge
63
+ * order). It is required on the inbound envelope, which is what makes the data
64
+ * plane a consumer of this id rather than its source: the data plane echoes it
65
+ * on every stream event, on the usage report, in its response header and on
66
+ * anything it can be asked about later. It never mints one for a request it
67
+ * received.
68
+ *
69
+ * The one case that is NOT an exception to that: an envelope the data plane
70
+ * cannot read or authenticate carries no id to echo, so its rejection is
71
+ * labelled with an id of the data plane's own — visibly local, and never
72
+ * correlated with an Oxy request, because there is no Oxy request it belongs to.
73
+ * Saying so is what stops "consumer, not source" from being read as forbidding
74
+ * the only id such a rejection could have.
75
+ *
76
+ * Correlates the Oxy edge, the data plane, the financial ledger and the
77
+ * customer-visible receipt, so it appears on every stream event and every
78
+ * ledger record.
79
+ */
80
+ exports.requestIdSchema = zod_1.z.string().min(1).max(128);
81
+ /**
82
+ * A generation id generated by the data plane, present when a request produced
83
+ * a generation that can be looked up later (`GET /v1/generations/:id`).
84
+ */
85
+ exports.generationIdSchema = zod_1.z.string().min(1).max(128);
86
+ /**
87
+ * A caller-supplied idempotency key. Every reserve/settle/refund call is keyed
88
+ * on one so a retry, a redelivered event or a duplicated webhook can never
89
+ * charge twice.
90
+ */
91
+ exports.idempotencyKeySchema = zod_1.z.string().min(1).max(255);
92
+ /** Credential environments. A credential is issued into exactly one of them. */
93
+ exports.inferenceEnvironmentSchema = zod_1.z.enum(['development', 'staging', 'production']);
94
+ /* -------------------------------------------------------------------------- */
95
+ /* Wire primitives */
96
+ /* -------------------------------------------------------------------------- */
97
+ /**
98
+ * An instant, as an ISO 8601 string in UTC (`2026-08-15T09:41:00.000Z`).
99
+ *
100
+ * Validated rather than left free-form — unlike the session contracts, which
101
+ * carry legacy expiry strings no consumer interprets, every instant here is
102
+ * read: a reservation expires, a price version starts applying, a receipt is
103
+ * settled. One canonical spelling (UTC, `Z`) so two records that describe the
104
+ * same moment compare and sort as equal, which a mix of offsets would not.
105
+ */
106
+ exports.inferenceTimestampSchema = zod_1.z.string().datetime();
107
+ /**
108
+ * A calendar DATE with no instant attached (`2026-05-01`) — a knowledge cutoff
109
+ * or a release date, which are published as days and become wrong when a
110
+ * timezone is invented for them.
111
+ */
112
+ exports.inferenceDateSchema = zod_1.z
113
+ .string()
114
+ .regex(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/, 'must be an ISO 8601 calendar date (YYYY-MM-DD)');
115
+ /** An absolute https URL, for model cards, licenses and provider documentation. */
116
+ exports.inferenceHttpsUrlSchema = zod_1.z
117
+ .string()
118
+ .max(2048)
119
+ .regex(/^https:\/\/[^\s]+$/, 'must be an absolute https URL');
120
+ /**
121
+ * A content digest, `sha256:<64 lowercase hex>`.
122
+ *
123
+ * ONE spelling, because a digest is compared for equality and nothing else: an
124
+ * uppercase or unprefixed variant of the same hash is a different string, so two
125
+ * records describing the same bytes would not match. Lowercase hex with the
126
+ * algorithm prefix is what the `inference_model_revisions` CHECK stores and what
127
+ * every artifact registry emits.
128
+ */
129
+ exports.sha256DigestSchema = zod_1.z
130
+ .string()
131
+ .regex(/^sha256:[a-f0-9]{64}$/, 'digest must be sha256:<64 lowercase hex>');
132
+ /* -------------------------------------------------------------------------- */
133
+ /* Catalogue references */
134
+ /* -------------------------------------------------------------------------- */
135
+ /** One path segment of a canonical model id: a lowercase, URL-safe slug. */
136
+ const SLUG_PATTERN = '[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?';
137
+ /** A revision label. Case-preserving, because upstream revisions often are. */
138
+ const REVISION_PATTERN = '[a-zA-Z0-9](?:[a-zA-Z0-9._-]*[a-zA-Z0-9])?';
139
+ /** A publisher slug, e.g. `openai`, `anthropic`, `meta`, `alia`. */
140
+ exports.publisherSlugSchema = zod_1.z
141
+ .string()
142
+ .max(64)
143
+ .regex(new RegExp(`^${SLUG_PATTERN}$`), 'publisher must be a lowercase URL-safe slug');
144
+ /** A model slug within its publisher's namespace, e.g. `gpt-5`, `llama-3.1-70b`. */
145
+ exports.modelSlugSchema = zod_1.z
146
+ .string()
147
+ .max(64)
148
+ .regex(new RegExp(`^${SLUG_PATTERN}$`), 'model must be a lowercase URL-safe slug');
149
+ /**
150
+ * A canonical model id, `<publisher>/<model>`. This names a MODEL — a
151
+ * long-lived product identity whose behaviour changes as revisions ship. It
152
+ * does not name a revision, a deployment or a provider.
153
+ */
154
+ exports.modelIdSchema = zod_1.z
155
+ .string()
156
+ .max(129)
157
+ .regex(new RegExp(`^${SLUG_PATTERN}/${SLUG_PATTERN}$`), 'model id must be <publisher>/<model>');
158
+ /** An immutable revision label, unique within its model, e.g. `2026-05-01`. */
159
+ exports.modelRevisionLabelSchema = zod_1.z
160
+ .string()
161
+ .max(64)
162
+ .regex(new RegExp(`^${REVISION_PATTERN}$`), 'revision must be a URL-safe label');
163
+ /**
164
+ * A model reference as a customer writes it: `<publisher>/<model>` (the model's
165
+ * current revision, chosen by Oxy) or `<publisher>/<model>@<revision>` (an
166
+ * immutable revision the customer pinned).
167
+ *
168
+ * Both forms name a CONCRETE MODEL. Neither can name a routing profile — see
169
+ * {@link routingProfileSlugSchema} — which is what makes "a request for a
170
+ * concrete model is never silently replaced with a different model" a
171
+ * distinction the type system can carry rather than a convention.
172
+ */
173
+ exports.modelReferenceSchema = zod_1.z
174
+ .string()
175
+ .max(194)
176
+ .regex(new RegExp(`^${SLUG_PATTERN}/${SLUG_PATTERN}(?:@${REVISION_PATTERN})?$`), 'model reference must be <publisher>/<model> or <publisher>/<model>@<revision>');
177
+ /**
178
+ * A routing-profile slug, e.g. `auto`, `fast`, `quality`.
179
+ *
180
+ * Deliberately refuses a `/`, so a profile can never be written in the shape of
181
+ * a model id and no caller can be confused about whether they asked for a
182
+ * concrete model or for Oxy to choose one. Modes like `auto`/`fast`/`quality`
183
+ * are profiles or product presets; they are never model objects.
184
+ */
185
+ exports.routingProfileSlugSchema = zod_1.z
186
+ .string()
187
+ .max(64)
188
+ .regex(new RegExp(`^${SLUG_PATTERN}$`), 'routing profile must be a lowercase URL-safe slug');
189
+ /**
190
+ * The opaque PostgreSQL identity of one routing profile.
191
+ *
192
+ * No trim, case-folding or format heuristic: callers selecting by id must name
193
+ * the exact stored bytes. The database lookup is the authority for existence.
194
+ */
195
+ exports.routingProfileIdSchema = zod_1.z.string().min(1).max(128);
196
+ /** An inference provider slug, e.g. `openai`, `bedrock`, `oxy-hosted`. */
197
+ exports.inferenceProviderSlugSchema = zod_1.z
198
+ .string()
199
+ .max(64)
200
+ .regex(new RegExp(`^${SLUG_PATTERN}$`), 'provider must be a lowercase URL-safe slug');
201
+ /**
202
+ * A deployment/endpoint id. Opaque to customers: which concrete endpoint served
203
+ * a request is the data plane's operational detail, and only the customer-safe
204
+ * subset of it is ever attributed back (see the catalogue's serving-boundary
205
+ * rules).
206
+ */
207
+ exports.deploymentIdSchema = zod_1.z.string().min(1).max(128);
208
+ /**
209
+ * A region identifier, e.g. `us-west-2`, `eu-central-1`. Free-form rather than
210
+ * a closed enum because the set is provider-defined and grows without any
211
+ * contract change; residency policies match on exact strings.
212
+ */
213
+ exports.inferenceRegionSchema = zod_1.z
214
+ .string()
215
+ .max(64)
216
+ .regex(new RegExp(`^${SLUG_PATTERN}$`), 'region must be a lowercase URL-safe slug');
217
+ /**
218
+ * The publisher namespace reserved for models Alia actually owns or derives.
219
+ *
220
+ * `alia/*` is never a re-badged third-party route and never a prompt preset —
221
+ * enforcing that is the job of `modelSchema`'s provenance refinement, which
222
+ * this constant exists to be checked against.
223
+ */
224
+ exports.RESERVED_ALIA_PUBLISHER = 'alia';
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inboxInferenceStreamEventSchema = exports.inboxThreadSummaryResponseSchema = exports.inboxSmartRepliesResponseSchema = exports.inboxNaturalSearchResponseSchema = exports.inboxInferenceTextResponseSchema = exports.inboxMessageInferenceParamsSchema = exports.inboxNaturalSearchRequestSchema = exports.inboxDailyBriefRequestSchema = exports.inboxComposeRequestSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const errors_1 = require("./errors");
6
+ const inboxTextSchema = zod_1.z.string().trim().min(1).max(20000);
7
+ const inboxMessageIdSchema = zod_1.z.string().min(1).max(128);
8
+ const DAILY_BRIEF_MIN_WINDOW_MS = 23 * 60 * 60 * 1000;
9
+ const DAILY_BRIEF_MAX_WINDOW_MS = 25 * 60 * 60 * 1000;
10
+ const inboxUtcTimestampSchema = zod_1.z
11
+ .string()
12
+ .datetime({ offset: false })
13
+ .refine((value) => value.endsWith('Z'), 'Timestamp must use the UTC Z suffix');
14
+ exports.inboxComposeRequestSchema = zod_1.z.discriminatedUnion('operation', [
15
+ zod_1.z.object({
16
+ operation: zod_1.z.literal('draft'),
17
+ prompt: inboxTextSchema,
18
+ tone: zod_1.z.enum(['professional', 'casual', 'friendly', 'formal']),
19
+ stream: zod_1.z.boolean().optional(),
20
+ }).strict(),
21
+ zod_1.z.object({ operation: zod_1.z.literal('polish'), text: inboxTextSchema }).strict(),
22
+ zod_1.z.object({
23
+ operation: zod_1.z.literal('change_tone'),
24
+ text: inboxTextSchema,
25
+ tone: zod_1.z.enum(['professional', 'casual', 'friendly', 'formal']),
26
+ }).strict(),
27
+ zod_1.z.object({
28
+ operation: zod_1.z.literal('adjust_length'),
29
+ text: inboxTextSchema,
30
+ direction: zod_1.z.enum(['shorter', 'longer']),
31
+ }).strict(),
32
+ zod_1.z.object({ operation: zod_1.z.literal('suggest_subject'), body: inboxTextSchema }).strict(),
33
+ ]);
34
+ /**
35
+ * The client owns the user's timezone and therefore supplies the UTC instants
36
+ * that bracket one local calendar day. The server treats this as [start, end):
37
+ * requiring a 23-25 hour window admits both DST transitions but refuses an
38
+ * arbitrary history export disguised as a brief.
39
+ */
40
+ exports.inboxDailyBriefRequestSchema = zod_1.z.object({
41
+ startAt: inboxUtcTimestampSchema,
42
+ endAt: inboxUtcTimestampSchema,
43
+ stream: zod_1.z.boolean().optional(),
44
+ }).strict().superRefine((value, context) => {
45
+ const durationMs = Date.parse(value.endAt) - Date.parse(value.startAt);
46
+ if (!Number.isFinite(durationMs) || durationMs <= 0) {
47
+ context.addIssue({
48
+ code: zod_1.z.ZodIssueCode.custom,
49
+ path: ['endAt'],
50
+ message: 'endAt must be after startAt',
51
+ });
52
+ return;
53
+ }
54
+ if (durationMs < DAILY_BRIEF_MIN_WINDOW_MS || durationMs > DAILY_BRIEF_MAX_WINDOW_MS) {
55
+ context.addIssue({
56
+ code: zod_1.z.ZodIssueCode.custom,
57
+ path: ['endAt'],
58
+ message: 'Daily brief window must be between 23 and 25 hours',
59
+ });
60
+ }
61
+ });
62
+ exports.inboxNaturalSearchRequestSchema = zod_1.z.object({ query: zod_1.z.string().trim().min(1).max(512) }).strict();
63
+ exports.inboxMessageInferenceParamsSchema = zod_1.z.object({ messageId: inboxMessageIdSchema }).strict();
64
+ exports.inboxInferenceTextResponseSchema = zod_1.z.object({
65
+ schemaVersion: zod_1.z.literal(1),
66
+ requestId: zod_1.z.string().min(1).max(128),
67
+ generationId: zod_1.z.string().min(1).max(128).optional(),
68
+ text: zod_1.z.string().max(40000),
69
+ }).strict();
70
+ exports.inboxNaturalSearchResponseSchema = zod_1.z.object({
71
+ query: zod_1.z.object({
72
+ q: zod_1.z.string().max(512).optional(),
73
+ from: zod_1.z.string().max(320).optional(),
74
+ to: zod_1.z.string().max(320).optional(),
75
+ subject: zod_1.z.string().max(512).optional(),
76
+ hasAttachment: zod_1.z.boolean().optional(),
77
+ starred: zod_1.z.boolean().optional(),
78
+ unread: zod_1.z.boolean().optional(),
79
+ after: zod_1.z.string().date().optional(),
80
+ before: zod_1.z.string().date().optional(),
81
+ mailbox: zod_1.z.enum(['inbox', 'sent', 'drafts', 'trash', 'spam', 'archive']).optional(),
82
+ }).strict(),
83
+ interpretation: zod_1.z.string().max(1000),
84
+ }).strict();
85
+ exports.inboxSmartRepliesResponseSchema = zod_1.z.object({
86
+ replies: zod_1.z.array(zod_1.z.string().trim().min(1).max(500)).max(3),
87
+ }).strict();
88
+ exports.inboxThreadSummaryResponseSchema = zod_1.z.object({
89
+ summary: zod_1.z.string().max(4000),
90
+ keyPoints: zod_1.z.array(zod_1.z.string().max(1000)).max(12),
91
+ actionItems: zod_1.z.array(zod_1.z.object({
92
+ text: zod_1.z.string().max(1000),
93
+ owner: zod_1.z.string().max(320).nullable(),
94
+ deadline: zod_1.z.string().max(128).nullable(),
95
+ }).strict()).max(12),
96
+ }).strict();
97
+ exports.inboxInferenceStreamEventSchema = zod_1.z.discriminatedUnion('type', [
98
+ zod_1.z.object({ type: zod_1.z.literal('delta'), text: zod_1.z.string().min(1).max(16384) }).strict(),
99
+ zod_1.z.object({
100
+ type: zod_1.z.literal('done'),
101
+ requestId: zod_1.z.string().min(1).max(128),
102
+ generationId: zod_1.z.string().min(1).max(128).optional(),
103
+ }).strict(),
104
+ zod_1.z.object({ type: zod_1.z.literal('error'), error: errors_1.inferenceErrorSchema }).strict(),
105
+ ]);