@oxy.so/contracts 4.15.0 → 4.16.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 (37) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/index.js +15 -10
  3. package/dist/cjs/inference/money.js +10 -0
  4. package/dist/cjs/inference/version.js +1 -1
  5. package/dist/cjs/products/billing.js +0 -1
  6. package/dist/cjs/products/checkout.js +1 -14
  7. package/dist/cjs/products/plans.js +2 -18
  8. package/dist/cjs/signIn.js +40 -1
  9. package/dist/cjs/userResponse.js +1 -8
  10. package/dist/esm/.tsbuildinfo +1 -1
  11. package/dist/esm/index.js +2 -2
  12. package/dist/esm/inference/money.js +10 -0
  13. package/dist/esm/inference/version.js +1 -1
  14. package/dist/esm/products/billing.js +0 -1
  15. package/dist/esm/products/checkout.js +0 -13
  16. package/dist/esm/products/plans.js +1 -17
  17. package/dist/esm/signIn.js +38 -0
  18. package/dist/esm/userResponse.js +1 -8
  19. package/dist/types/.tsbuildinfo +1 -1
  20. package/dist/types/externalIdentity.d.ts +0 -33
  21. package/dist/types/index.d.ts +3 -3
  22. package/dist/types/inference/catalogue.d.ts +7 -7
  23. package/dist/types/inference/decisions.d.ts +31 -31
  24. package/dist/types/inference/economics.d.ts +5 -5
  25. package/dist/types/inference/money.d.ts +17 -8
  26. package/dist/types/inference/priceVersion.d.ts +12 -12
  27. package/dist/types/inference/realtime.d.ts +24 -24
  28. package/dist/types/inference/routingPolicy.d.ts +7 -7
  29. package/dist/types/inference/streamEvents.d.ts +10 -10
  30. package/dist/types/inference/usage.d.ts +28 -28
  31. package/dist/types/inference/version.d.ts +1 -1
  32. package/dist/types/products/billing.d.ts +0 -8
  33. package/dist/types/products/checkout.d.ts +0 -36
  34. package/dist/types/products/plans.d.ts +5 -102
  35. package/dist/types/signIn.d.ts +82 -1
  36. package/dist/types/userResponse.d.ts +3 -139
  37. package/package.json +1 -1
package/dist/esm/index.js CHANGED
@@ -100,7 +100,7 @@ export {
100
100
  EMAIL_VERIFICATION_PURPOSES, EMAIL_CODE_LENGTH, EMAIL_CODE_TTL_MS, EMAIL_CODE_MAX_ATTEMPTS, EMAIL_TICKET_TTL_MS, EMAIL_VERIFICATION_ERROR_CODES, emailAddressSchema, emailTicketSchema, emailVerificationStartRequestSchema, emailVerificationStartResponseSchema, emailVerificationConfirmRequestSchema, emailVerificationConfirmResponseSchema, } from './accountEmail.js';
101
101
  export {
102
102
  // Email code/link, password and authenticator sign-in
103
- EMAIL_SIGNIN_LINK_TTL_MS, SIGNIN_SECOND_FACTOR_TTL_MS, SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS, PASSWORD_MIN_LENGTH, PASSWORD_MAX_LENGTH, TOTP_DIGITS, TOTP_PERIOD_SECONDS, TOTP_BACKUP_CODE_COUNT, SIGN_IN_ERROR_CODES, signInIdentifierSchema, passwordInputSchema, newPasswordSchema, secondFactorCodeSchema, emailSignInStartRequestSchema, emailSignInStartResponseSchema, emailSignInConfirmRequestSchema, emailSignInCodeSchema, normalizeEmailSignInCode, EMAIL_SIGNIN_LONG_CODE_ALPHABET, EMAIL_SIGNIN_LONG_CODE_LENGTH, emailSignInCollectRequestSchema, emailSignInLinkRequestSchema, emailSignInLinkResponseSchema, emailSignInPendingSchema, passwordSignInRequestSchema, secondFactorSignInRequestSchema, secondFactorRequiredSchema, signUpRequestSchema, isSecondFactorRequired, reauthProofSchema, emailReauthProofSchema, REAUTH_ACTIONS, reauthEmailStartRequestSchema, passwordSetRequestSchema, signInMethodsSchema, totpEnrollResponseSchema, totpConfirmRequestSchema, totpReauthRequestSchema, totpBackupCodesResponseSchema, } from './signIn.js';
103
+ EMAIL_SIGNIN_LINK_TTL_MS, SIGNIN_SECOND_FACTOR_TTL_MS, SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS, PASSWORD_MIN_LENGTH, PASSWORD_MAX_LENGTH, TOTP_DIGITS, TOTP_PERIOD_SECONDS, TOTP_BACKUP_CODE_COUNT, SIGN_IN_ERROR_CODES, signInIdentifierSchema, passwordInputSchema, newPasswordSchema, secondFactorCodeSchema, emailSignInStartRequestSchema, emailSignInStartResponseSchema, emailSignInConfirmRequestSchema, emailSignInCodeSchema, normalizeEmailSignInCode, EMAIL_SIGNIN_LONG_CODE_ALPHABET, EMAIL_SIGNIN_LONG_CODE_LENGTH, emailSignInCollectRequestSchema, emailSignInLinkRequestSchema, emailSignInLinkResponseSchema, emailSignInPendingSchema, EMAIL_SIGNIN_CHOICE_TTL_MS, EMAIL_ACCOUNTS_MAX, emailSignInAccountOptionSchema, emailSignInChooseAccountSchema, emailSignInChooseRequestSchema, isEmailSignInChooseAccount, passwordSignInRequestSchema, secondFactorSignInRequestSchema, secondFactorRequiredSchema, signUpRequestSchema, isSecondFactorRequired, reauthProofSchema, emailReauthProofSchema, REAUTH_ACTIONS, reauthEmailStartRequestSchema, passwordSetRequestSchema, signInMethodsSchema, totpEnrollResponseSchema, totpConfirmRequestSchema, totpReauthRequestSchema, totpBackupCodesResponseSchema, } from './signIn.js';
104
104
  export {
105
105
  // Linking Commons to an account without a key (ADR 0029 D3)
106
106
  IDENTITY_LINK_STATUSES, IDENTITY_LINK_QR_PREFIX, identityLinkIdSchema, buildIdentityLinkQrPayload, parseIdentityLinkQrPayload, identityLinkCreateResponseSchema, identityLinkStateSchema, identityLinkProofRequestSchema, identityLinkCompleteRequestSchema, } from './identityLink.js';
@@ -200,7 +200,7 @@ export { meteredGenerationSchema } from './inference/economics.js';
200
200
  export { canonicalCapabilityJson, inputSatisfiesCapabilityLimits, isLoopbackOrigin, } from './capabilityBindings.js';
201
201
  export * from './agentKeys.js';
202
202
  export { productSubscriptionSummarySchema, productSubscriptionsResponseSchema, subscriptionCreditGrantSchema, subscriptionCreditGrantsResponseSchema, cancelProductSubscriptionSchema, productSubscriptionCancellationResultSchema, } from './products/billing.js';
203
- export { personalPlanDisplayPriceSchema, personalPlanCatalogueSchema, productPlanCatalogueSchema, } from './products/plans.js';
203
+ export { personalPlanDisplayPriceSchema, personalPlanCatalogueSchema, } from './products/plans.js';
204
204
  export * from './products/checkout.js';
205
205
  export * from './organizations.js';
206
206
  export * from './safety.js';
@@ -144,6 +144,15 @@ export const moneySchema = z
144
144
  * estimated from the audio, and a provider billed by the audio it carries (or
145
145
  * by tokens) never reports it.
146
146
  *
147
+ * **`input_transcription_milliseconds` is a second model's reading** (added in
148
+ * contract set 3.9.0, mirroring `@kaana.ai/contracts` 4.1.0): milliseconds of a
149
+ * realtime session's input audio that the deployment's own TRANSCRIPTION model
150
+ * transcribed, when the provider bills that model apart from the session model
151
+ * (OpenAI bills input transcription at the ASR model's price). The session
152
+ * model's `audio_input_tokens` and this unit are two charges for two models,
153
+ * each read once, so the partition rule holds. A provider whose session price
154
+ * already includes the transcription (xAI's Voice Agent) never reports it.
155
+ *
147
156
  * No refinement in this package can enforce it, and saying so is part of the
148
157
  * rule: a nested report and a disjoint one are the same four non-negative
149
158
  * integers, so no predicate over a single report can tell them apart. The two
@@ -181,6 +190,7 @@ export const USAGE_UNITS = [
181
190
  'cached_audio_input_tokens',
182
191
  'audio_output_tokens',
183
192
  'session_milliseconds',
193
+ 'input_transcription_milliseconds',
184
194
  ];
185
195
  export const usageUnitSchema = z.enum(USAGE_UNITS);
186
196
  /**
@@ -99,4 +99,4 @@
99
99
  * change to, say, the catalogue reject every in-flight inference request; the
100
100
  * per-shape `schemaVersion` is what a message is validated against.
101
101
  */
102
- export const INFERENCE_CONTRACT_VERSION = '3.8.0';
102
+ export const INFERENCE_CONTRACT_VERSION = '3.9.0';
@@ -24,7 +24,6 @@ export const productSubscriptionSummarySchema = z
24
24
  period,
25
25
  cancelAtPeriodEnd: z.boolean(),
26
26
  canCancel: z.boolean(),
27
- canRenew: z.boolean().optional(),
28
27
  offers: z.array(z
29
28
  .object({
30
29
  segmentId: id,
@@ -30,16 +30,3 @@ export const personalPlanCheckoutResultSchema = z.discriminatedUnion('state', [
30
30
  z.object({ state: z.literal('closed'), intentId: z.string().min(1).max(160) }).strict(),
31
31
  z.object({ state: z.literal('fulfilled'), intentId: z.string().min(1).max(160) }).strict(),
32
32
  ]);
33
- /** Explicit individual product offer; still owned and paid through Oxy. */
34
- export const productPlanCheckoutRequestSchema = personalPlanCheckoutRequestSchema
35
- .extend({
36
- productId: z.string().min(1).max(160),
37
- })
38
- .strict();
39
- export const productSubscriptionRenewalRequestSchema = z
40
- .object({
41
- expectedSubjectAccountId: oxyAccountIdSchema,
42
- sourceId: z.string().min(1).max(160),
43
- idempotencyKey: personalPlanCheckoutRequestSchema.shape.idempotencyKey,
44
- })
45
- .strict();
@@ -16,7 +16,7 @@ export const personalPlanCatalogueSchema = z
16
16
  .object({
17
17
  schemaVersion: z.literal(1),
18
18
  state: z.enum(['unconfigured', 'configured']),
19
- purchase: z.enum(['unavailable', 'available']),
19
+ purchase: z.literal('unavailable'),
20
20
  plans: z.array(z
21
21
  .object({
22
22
  offerId: z.string().min(1).max(160),
@@ -33,19 +33,3 @@ export const personalPlanCatalogueSchema = z
33
33
  })
34
34
  .strict()
35
35
  .refine((value) => (value.state === 'unconfigured') === (value.plans.length === 0), 'Catalogue state must match published plans');
36
- export const productPlanCatalogueSchema = z
37
- .object({
38
- schemaVersion: z.literal(1),
39
- productId: z.string().min(1).max(160),
40
- purchase: z.enum(['unavailable', 'available']),
41
- plans: z.array(z
42
- .object({
43
- productId: z.string().min(1).max(160),
44
- offerId: z.string().min(1).max(160),
45
- offerVersion: z.number().int().positive().safe(),
46
- displayName: z.string().min(1).max(100),
47
- price: personalPlanDisplayPriceSchema.extend({ interval: z.enum(['month', 'year']) }),
48
- })
49
- .strict()),
50
- })
51
- .strict();
@@ -18,6 +18,11 @@
18
18
  * one-use second-factor challenge instead of a session, and
19
19
  * `POST /auth/signin/second-factor` takes the TOTP (or a backup code).
20
20
  *
21
+ * An email may hold several accounts (up to `EMAIL_ACCOUNTS_MAX`). Signing in
22
+ * with the email, once the code or the link proves it, answers the accounts to
23
+ * choose from when there are several, and `POST /auth/signin/email/choose`
24
+ * names one. A username always names one account.
25
+ *
21
26
  * `POST /auth/signup` creates an account from a username and an email confirmed
22
27
  * with `POST /auth/email/verify/{start,confirm}` (purpose `signup`).
23
28
  *
@@ -188,10 +193,41 @@ export const emailSignInPendingSchema = z.object({
188
193
  status: z.literal('pending'),
189
194
  expiresAt: z.number().int().positive(),
190
195
  });
196
+ /**
197
+ * How long, once the email is proven, the person has to choose which of its
198
+ * accounts signs in.
199
+ */
200
+ export const EMAIL_SIGNIN_CHOICE_TTL_MS = 5 * 60 * 1000;
201
+ /** Most accounts one email can hold; sign-up refuses another past it. */
202
+ export const EMAIL_ACCOUNTS_MAX = 20;
203
+ export const emailSignInAccountOptionSchema = z.object({
204
+ id: z.string().min(1).max(64),
205
+ username: z.string().min(1).optional(),
206
+ displayName: z.string().min(1).optional(),
207
+ avatar: z.string().min(1).optional(),
208
+ });
209
+ export const emailSignInChooseAccountSchema = z.object({
210
+ chooseAccount: z.literal(true),
211
+ accounts: z.array(emailSignInAccountOptionSchema).min(2).max(EMAIL_ACCOUNTS_MAX),
212
+ expiresAt: z.number().int().positive(),
213
+ });
214
+ /** `POST /auth/signin/email/choose` — the account, from those {@link EmailSignInChooseAccount} listed. */
215
+ export const emailSignInChooseRequestSchema = z
216
+ .object({
217
+ requestId: z.string().trim().min(1).max(64),
218
+ requestSecret: opaqueTokenSchema,
219
+ userId: z.string().trim().min(1).max(64),
220
+ ...sessionEnvelope,
221
+ })
222
+ .strict();
191
223
  /** Narrow a {@link SignInStepResult}. */
192
224
  export function isSecondFactorRequired(result) {
193
225
  return result.secondFactorRequired === true;
194
226
  }
227
+ /** Narrow an {@link EmailSignInStepResult}. */
228
+ export function isEmailSignInChooseAccount(result) {
229
+ return result.chooseAccount === true;
230
+ }
195
231
  /**
196
232
  * What a re-verification email code confirms. The code is bound to it: a code
197
233
  * asked for one change never authorises another, and the email names it.
@@ -309,4 +345,6 @@ export const SIGN_IN_ERROR_CODES = {
309
345
  originNotAllowed: 'SIGNIN_ORIGIN_NOT_ALLOWED',
310
346
  /** The username is taken. */
311
347
  usernameTaken: 'USERNAME_TAKEN',
348
+ /** The email already holds `EMAIL_ACCOUNTS_MAX` accounts: no sign-up adds another. */
349
+ emailAccountsFull: 'EMAIL_ACCOUNTS_FULL',
312
350
  };
@@ -241,10 +241,6 @@ export const userResponseSchema = z
241
241
  * so it is present on the current-user DTO (`GET /users/me`,
242
242
  * `GET /session/user/:sessionId`) and absent until the user sets it.
243
243
  */
244
- userPreferences: z
245
- .object({ displayCurrency: z.enum(['USD', 'EUR', 'FAIR']).optional() })
246
- .catchall(z.unknown())
247
- .optional(),
248
244
  themePreference: themePreferenceSchema.optional(),
249
245
  personalization: z
250
246
  .object({
@@ -305,10 +301,7 @@ export const userProfileUpdateSchema = z
305
301
  languages: z.array(z.string()).optional(),
306
302
  accountExpiresAfterInactivityDays: z.number().nullable().optional(),
307
303
  notificationPreferences: z.record(z.unknown()).optional(),
308
- userPreferences: z
309
- .object({ displayCurrency: z.enum(['USD', 'EUR', 'FAIR']).optional() })
310
- .catchall(z.unknown())
311
- .optional(),
304
+ userPreferences: z.record(z.unknown()).optional(),
312
305
  privacySettings: z.record(z.unknown()).optional(),
313
306
  /**
314
307
  * Portable theme preference. Written through the same `PUT /users/me`