@oxyhq/contracts 0.26.0 → 0.27.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 (46) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/accountGraph.js +4 -3
  3. package/dist/cjs/index.js +143 -1
  4. package/dist/cjs/inference/attribution.js +101 -0
  5. package/dist/cjs/inference/catalogue.js +482 -0
  6. package/dist/cjs/inference/errors.js +195 -0
  7. package/dist/cjs/inference/identifiers.js +189 -0
  8. package/dist/cjs/inference/money.js +145 -0
  9. package/dist/cjs/inference/priceVersion.js +110 -0
  10. package/dist/cjs/inference/providerConnection.js +142 -0
  11. package/dist/cjs/inference/request.js +288 -0
  12. package/dist/cjs/inference/routingPolicy.js +213 -0
  13. package/dist/cjs/inference/streamEvents.js +219 -0
  14. package/dist/cjs/inference/usage.js +291 -0
  15. package/dist/cjs/inference/version.js +57 -0
  16. package/dist/esm/.tsbuildinfo +1 -1
  17. package/dist/esm/accountGraph.js +4 -3
  18. package/dist/esm/index.js +45 -0
  19. package/dist/esm/inference/attribution.js +98 -0
  20. package/dist/esm/inference/catalogue.js +479 -0
  21. package/dist/esm/inference/errors.js +192 -0
  22. package/dist/esm/inference/identifiers.js +186 -0
  23. package/dist/esm/inference/money.js +142 -0
  24. package/dist/esm/inference/priceVersion.js +107 -0
  25. package/dist/esm/inference/providerConnection.js +139 -0
  26. package/dist/esm/inference/request.js +285 -0
  27. package/dist/esm/inference/routingPolicy.js +210 -0
  28. package/dist/esm/inference/streamEvents.js +216 -0
  29. package/dist/esm/inference/usage.js +288 -0
  30. package/dist/esm/inference/version.js +54 -0
  31. package/dist/types/.tsbuildinfo +1 -1
  32. package/dist/types/accountGraph.d.ts +6 -5
  33. package/dist/types/index.d.ts +23 -0
  34. package/dist/types/inference/attribution.d.ts +171 -0
  35. package/dist/types/inference/catalogue.d.ts +1612 -0
  36. package/dist/types/inference/errors.d.ts +193 -0
  37. package/dist/types/inference/identifiers.d.ts +149 -0
  38. package/dist/types/inference/money.d.ts +142 -0
  39. package/dist/types/inference/priceVersion.d.ts +182 -0
  40. package/dist/types/inference/providerConnection.d.ts +297 -0
  41. package/dist/types/inference/request.d.ts +2364 -0
  42. package/dist/types/inference/routingPolicy.d.ts +426 -0
  43. package/dist/types/inference/streamEvents.d.ts +906 -0
  44. package/dist/types/inference/usage.d.ts +1133 -0
  45. package/dist/types/inference/version.d.ts +54 -0
  46. package/package.json +1 -1
@@ -22,9 +22,10 @@ const zod_1 = require("zod");
22
22
  * `db/schema/users.ts` mirrors to keep the `users_kind_check` CHECK honest.
23
23
  *
24
24
  * Deriving the union from the array instead would cost nothing here and be paid
25
- * by consumers: `kind` travels into `@oxyhq/services` through
26
- * `SwitchableAccount`, where an indexed-access type is materially more
27
- * expensive to check than a literal union.
25
+ * by consumers: `kind` travels into `@oxyhq/services` on every device-directory
26
+ * context (`deviceContextSchema.kind` `DeviceContext` the switcher rows),
27
+ * and an indexed-access type is materially more expensive to check there than a
28
+ * literal union.
28
29
  */
29
30
  exports.ACCOUNT_KINDS = [
30
31
  'personal',
package/dist/cjs/index.js CHANGED
@@ -16,7 +16,9 @@ exports.reputationBalanceBreakdownSchema = exports.reputationTransactionSchema =
16
16
  exports.reverseModerationEffectSchema = exports.finalizeModerationDecisionSchema = exports.moderationDecisionEventSchema = exports.moderationPolicyVersionsSchema = exports.moderationDecisionEventSubjectSchema = exports.moderationFindingSchema = exports.applicationModerationStandingSchema = exports.identityBindingStatusSchema = exports.identityBindingTypeSchema = exports.personhoodStatusSchema = exports.contributionTierSchema = exports.conductStandingSchema = exports.conductStrikeStatusSchema = exports.moderationEffectSkipReasonSchema = exports.moderationEffectStatusSchema = exports.moderationEffectTypeSchema = exports.moderationDecisionStatusSchema = exports.moderationAttributionSchema = exports.moderationFindingScopeSchema = exports.moderationSeveritySchema = exports.APPLICATION_MODERATION_STANDINGS = exports.IDENTITY_BINDING_STATUSES = exports.IDENTITY_BINDING_TYPES = exports.PERSONHOOD_STATUSES = exports.CONTRIBUTION_TIERS = exports.CONDUCT_STANDINGS = exports.CONDUCT_STRIKE_STATUSES = exports.MODERATION_EFFECT_SKIP_REASONS = exports.MODERATION_EFFECT_STATUSES = exports.MODERATION_EFFECT_TYPES = exports.MODERATION_DECISION_STATUSES = exports.MODERATION_ATTRIBUTIONS = exports.MODERATION_FINDING_SCOPES = exports.MODERATION_SEVERITIES = exports.isFullReputationBalance = exports.reverseReputationTransactionSchema = exports.upsertReputationRuleSchema = exports.resolveReputationDisputeSchema = exports.createReputationDisputeSchema = exports.awardReputationSchema = exports.reverseReputationTransactionResultSchema = exports.reputationInfluenceResultSchema = exports.reputationLeaderboardEntrySchema = exports.reputationLeaderboardUserSchema = exports.reputationRuleSchema = exports.reputationDisputeSchema = exports.reputationBalanceSchema = exports.reputationBalanceSummarySchema = exports.reputationReliabilitySchema = exports.reputationInfluenceSchema = void 0;
17
17
  exports.hubActivateRequestSchema = exports.hubClaimRequestSchema = exports.hubSessionSchema = exports.browserHubRevokeResponseSchema = exports.browserHubErrorSchema = exports.browserHubResolveResponseSchema = exports.browserHubHandleResponseSchema = exports.browserHubHandleRequestSchema = exports.browserHubHandleSchema = exports.BROWSER_HUB_HANDLE_TTL_MS = exports.BROWSER_HUB_COOKIE_ATTRIBUTES = exports.BROWSER_HUB_COOKIE_NAME = exports.oauthAuthorizeCodeResponseSchema = exports.oauthConsentDecisionSchema = exports.deviceDirectorySyncSchema = exports.deviceActivateResponseSchema = exports.deviceActivateRequestSchema = exports.deviceDirectorySchema = exports.devicePrincipalSchema = exports.deviceAccountContextSchema = exports.deviceDirectoryProfileSchema = exports.deviceContextRelationshipSchema = exports.sessionAccountsChangedEventSchema = exports.sessionAccountsChangedReasonSchema = exports.SESSION_ACCOUNTS_CHANGED_EVENT = exports.deviceBackgroundTokenResponseSchema = exports.deviceBackgroundTokenRequestSchema = exports.deviceBackgroundCredentialResponseSchema = exports.deviceTokenMintResponseSchema = exports.deviceTokenMintRequestSchema = exports.deviceSessionSyncSchema = exports.activeTokenSchema = exports.deviceSessionStateSchema = exports.sessionAccountSchema = exports.linkPreviewResponseSchema = exports.linkPreviewBatchResponseSchema = exports.linkPreviewBatchRequestSchema = exports.linkPreviewSchema = exports.applicationModerationTrustSchema = exports.reputationContextualInfluenceSchema = exports.reputationReviewingSchema = exports.reputationReportingSchema = exports.reputationConductSchema = exports.reputationContributionSchema = exports.reputationPersonhoodSchema = exports.identityBindingSchema = exports.registerIdentityBindingSchema = exports.reverseModerationEffectResultSchema = exports.applyModerationDecisionResultSchema = exports.moderationEffectSchema = void 0;
18
18
  exports.transparencyCheckpointSchema = exports.transparencyAnchorSchema = exports.transparencyCheckpointSignatureSchema = exports.deviceTransferDenyResponseSchema = exports.deviceTransferApproveResponseSchema = exports.deviceTransferApproveRequestSchema = exports.deviceTransferInfoResponseSchema = exports.deviceTransferInitResponseSchema = exports.deviceTransferInitRequestSchema = exports.devicePairingStatusSchema = exports.webauthnLoginVerifyRequestSchema = exports.webauthnRegisterVerifyRequestSchema = exports.webauthnLoginOptionsRequestSchema = exports.webauthnRegisterOptionsRequestSchema = exports.updateRolloutPatchSchema = exports.promoteRequestSchema = exports.rollbackToEmbeddedRequestSchema = exports.rollbackRequestSchema = exports.updateListResponseSchema = exports.channelListResponseSchema = exports.channelSchema = exports.rollbackToEmbeddedEntrySchema = exports.createUpdateResponseSchema = exports.updateSchema = exports.createUpdateRequestSchema = exports.updateAssetRefSchema = exports.assetCompleteResponseSchema = exports.assetCompleteResultItemSchema = exports.assetCompleteRequestSchema = exports.assetInitResponseSchema = exports.assetUploadTicketSchema = exports.assetInitRequestSchema = exports.assetInitItemSchema = exports.rolloutPercentSchema = exports.runtimeVersionSchema = exports.channelNameSchema = exports.sha256HexSchema = exports.updateAssetStatusSchema = exports.updateStatusSchema = exports.updatePlatformSchema = exports.backupStatusResponseSchema = exports.backupUploadRequestSchema = exports.encryptedBackupEnvelopeSchema = exports.backupLookupIdSchema = exports.rotateKeyCompleteResponseSchema = exports.rotateKeyCompleteRequestSchema = exports.rotateKeyChallengeResponseSchema = exports.loginResultSchema = exports.hubAuthorizeResultSchema = exports.hubAuthorizeRequestSchema = void 0;
19
- exports.transparencyCheckpointListSchema = exports.transparencyInclusionProofSchema = void 0;
19
+ exports.inferenceModalitySchema = exports.priceSnapshotSchema = exports.priceVersionSchema = exports.priceVersionStatusSchema = exports.inferenceErrorSchema = exports.providerErrorPassthroughSchema = exports.safeErrorTextSchema = exports.upstreamErrorCategorySchema = exports.inferenceErrorCodeSchema = exports.NON_RETRYABLE_INFERENCE_ERROR_CODES = exports.INFERENCE_ERROR_CODES = exports.inferenceAttributionSchema = exports.authenticatedPrincipalSchema = exports.billingPrincipalSchema = exports.inferenceScopeSchema = exports.INFERENCE_SCOPES = exports.unitPriceSchema = exports.usageQuantitySchema = exports.usageSourceSchema = exports.USAGE_SOURCES = exports.usageUnitSchema = exports.USAGE_UNITS = exports.moneySchema = exports.exactDecimalSchema = exports.INFERENCE_MONEY_SCALE = exports.currencyCodeSchema = exports.RESERVED_ALIA_PUBLISHER = exports.inferenceRegionSchema = exports.deploymentIdSchema = exports.inferenceProviderSlugSchema = exports.routingProfileSlugSchema = exports.modelReferenceSchema = exports.modelRevisionLabelSchema = exports.modelIdSchema = exports.modelSlugSchema = exports.publisherSlugSchema = exports.inferenceHttpsUrlSchema = exports.inferenceDateSchema = exports.inferenceTimestampSchema = exports.inferenceEnvironmentSchema = exports.idempotencyKeySchema = exports.generationIdSchema = exports.requestIdSchema = exports.oxyCredentialIdSchema = exports.oxyApplicationIdSchema = exports.delegatedUserIdSchema = exports.oxyAccountIdSchema = exports.INFERENCE_CONTRACT_VERSION = exports.transparencyCheckpointListSchema = exports.transparencyInclusionProofSchema = void 0;
20
+ exports.usageReservationSchema = exports.usageReservationStatusSchema = exports.usageReservationRequestSchema = exports.inferenceStreamEventSchema = exports.inferenceStreamDoneEventSchema = exports.inferenceFinishReasonSchema = exports.inferenceStreamErrorEventSchema = exports.inferenceStreamRouteSwitchEventSchema = exports.inferenceRouteSwitchReasonSchema = exports.inferenceRouteSwitchDetailSchema = exports.inferenceStreamUsageEventSchema = exports.inferenceStreamToolCallEventSchema = exports.inferenceStreamDeltaEventSchema = exports.inferenceStreamStartEventSchema = exports.inferenceRequestSchema = exports.clientRequestMetadataSchema = exports.responseFormatSchema = exports.toolChoiceSchema = exports.toolDefinitionSchema = exports.samplingParametersSchema = exports.inferenceInputSchema = exports.inferenceMessageSchema = exports.inferenceMessageRoleSchema = exports.inferenceToolCallSchema = exports.inferenceContentPartSchema = exports.inferenceContentSourceSchema = exports.routingPolicyReferenceSchema = exports.routingPolicySchema = exports.routingFallbackPolicySchema = exports.routingPolicyScopeSchema = exports.routingTargetSchema = exports.modelCatalogueEntrySchema = exports.catalogueServingProviderSummarySchema = exports.cataloguePublisherSummarySchema = exports.routingProfileSchema = exports.routingProfileCandidateSchema = exports.modelDeploymentSchema = exports.inferenceProviderSchema = exports.modelRevisionSchema = exports.catalogueModelSchema = exports.modelPublisherSchema = exports.modelSafetyMetadataSchema = exports.modelEvaluationResultSchema = exports.modelDeprecationSchema = exports.commercialPermissionSchema = exports.availabilityScopeSchema = exports.inferenceDataPolicySchema = exports.modelProvenanceSchema = exports.modelLicenseSchema = exports.modelCapabilitiesSchema = void 0;
21
+ exports.providerConnectionSchema = exports.providerConnectionStatusSchema = exports.providerConnectionValidationSchema = exports.providerSecretReferenceSchema = exports.providerConnectionScopeSchema = exports.usageRefundSchema = exports.usageRefundReasonSchema = exports.usageRefundSubjectSchema = exports.usageReceiptSchema = exports.normalizedUsageReportSchema = exports.inferenceRequestOutcomeSchema = void 0;
20
22
  var accountGraph_1 = require("./accountGraph");
21
23
  Object.defineProperty(exports, "ACCOUNT_KINDS", { enumerable: true, get: function () { return accountGraph_1.ACCOUNT_KINDS; } });
22
24
  Object.defineProperty(exports, "accountKindSchema", { enumerable: true, get: function () { return accountGraph_1.accountKindSchema; } });
@@ -330,3 +332,143 @@ Object.defineProperty(exports, "transparencyAnchorSchema", { enumerable: true, g
330
332
  Object.defineProperty(exports, "transparencyCheckpointSchema", { enumerable: true, get: function () { return transparency_1.transparencyCheckpointSchema; } });
331
333
  Object.defineProperty(exports, "transparencyInclusionProofSchema", { enumerable: true, get: function () { return transparency_1.transparencyInclusionProofSchema; } });
332
334
  Object.defineProperty(exports, "transparencyCheckpointListSchema", { enumerable: true, get: function () { return transparency_1.transparencyCheckpointListSchema; } });
335
+ /* -------------------------------------------------------------------------- */
336
+ /* Inference (Oxy↔data-plane) — issue #972 */
337
+ /* -------------------------------------------------------------------------- */
338
+ var version_1 = require("./inference/version");
339
+ // The version of the contract SET; per-shape versions live in the data.
340
+ Object.defineProperty(exports, "INFERENCE_CONTRACT_VERSION", { enumerable: true, get: function () { return version_1.INFERENCE_CONTRACT_VERSION; } });
341
+ var identifiers_1 = require("./inference/identifiers");
342
+ // Principal identifiers. `oxyAccountIdSchema` and `delegatedUserIdSchema`
343
+ // are branded apart so a delegated end user can never become the payer.
344
+ Object.defineProperty(exports, "oxyAccountIdSchema", { enumerable: true, get: function () { return identifiers_1.oxyAccountIdSchema; } });
345
+ Object.defineProperty(exports, "delegatedUserIdSchema", { enumerable: true, get: function () { return identifiers_1.delegatedUserIdSchema; } });
346
+ Object.defineProperty(exports, "oxyApplicationIdSchema", { enumerable: true, get: function () { return identifiers_1.oxyApplicationIdSchema; } });
347
+ Object.defineProperty(exports, "oxyCredentialIdSchema", { enumerable: true, get: function () { return identifiers_1.oxyCredentialIdSchema; } });
348
+ Object.defineProperty(exports, "requestIdSchema", { enumerable: true, get: function () { return identifiers_1.requestIdSchema; } });
349
+ Object.defineProperty(exports, "generationIdSchema", { enumerable: true, get: function () { return identifiers_1.generationIdSchema; } });
350
+ Object.defineProperty(exports, "idempotencyKeySchema", { enumerable: true, get: function () { return identifiers_1.idempotencyKeySchema; } });
351
+ Object.defineProperty(exports, "inferenceEnvironmentSchema", { enumerable: true, get: function () { return identifiers_1.inferenceEnvironmentSchema; } });
352
+ // Wire primitives
353
+ Object.defineProperty(exports, "inferenceTimestampSchema", { enumerable: true, get: function () { return identifiers_1.inferenceTimestampSchema; } });
354
+ Object.defineProperty(exports, "inferenceDateSchema", { enumerable: true, get: function () { return identifiers_1.inferenceDateSchema; } });
355
+ Object.defineProperty(exports, "inferenceHttpsUrlSchema", { enumerable: true, get: function () { return identifiers_1.inferenceHttpsUrlSchema; } });
356
+ // Catalogue references
357
+ Object.defineProperty(exports, "publisherSlugSchema", { enumerable: true, get: function () { return identifiers_1.publisherSlugSchema; } });
358
+ Object.defineProperty(exports, "modelSlugSchema", { enumerable: true, get: function () { return identifiers_1.modelSlugSchema; } });
359
+ Object.defineProperty(exports, "modelIdSchema", { enumerable: true, get: function () { return identifiers_1.modelIdSchema; } });
360
+ Object.defineProperty(exports, "modelRevisionLabelSchema", { enumerable: true, get: function () { return identifiers_1.modelRevisionLabelSchema; } });
361
+ Object.defineProperty(exports, "modelReferenceSchema", { enumerable: true, get: function () { return identifiers_1.modelReferenceSchema; } });
362
+ Object.defineProperty(exports, "routingProfileSlugSchema", { enumerable: true, get: function () { return identifiers_1.routingProfileSlugSchema; } });
363
+ Object.defineProperty(exports, "inferenceProviderSlugSchema", { enumerable: true, get: function () { return identifiers_1.inferenceProviderSlugSchema; } });
364
+ Object.defineProperty(exports, "deploymentIdSchema", { enumerable: true, get: function () { return identifiers_1.deploymentIdSchema; } });
365
+ Object.defineProperty(exports, "inferenceRegionSchema", { enumerable: true, get: function () { return identifiers_1.inferenceRegionSchema; } });
366
+ Object.defineProperty(exports, "RESERVED_ALIA_PUBLISHER", { enumerable: true, get: function () { return identifiers_1.RESERVED_ALIA_PUBLISHER; } });
367
+ var money_1 = require("./inference/money");
368
+ // Exact money and metered units — never floats, units never money.
369
+ Object.defineProperty(exports, "currencyCodeSchema", { enumerable: true, get: function () { return money_1.currencyCodeSchema; } });
370
+ Object.defineProperty(exports, "INFERENCE_MONEY_SCALE", { enumerable: true, get: function () { return money_1.INFERENCE_MONEY_SCALE; } });
371
+ Object.defineProperty(exports, "exactDecimalSchema", { enumerable: true, get: function () { return money_1.exactDecimalSchema; } });
372
+ Object.defineProperty(exports, "moneySchema", { enumerable: true, get: function () { return money_1.moneySchema; } });
373
+ Object.defineProperty(exports, "USAGE_UNITS", { enumerable: true, get: function () { return money_1.USAGE_UNITS; } });
374
+ Object.defineProperty(exports, "usageUnitSchema", { enumerable: true, get: function () { return money_1.usageUnitSchema; } });
375
+ Object.defineProperty(exports, "USAGE_SOURCES", { enumerable: true, get: function () { return money_1.USAGE_SOURCES; } });
376
+ Object.defineProperty(exports, "usageSourceSchema", { enumerable: true, get: function () { return money_1.usageSourceSchema; } });
377
+ Object.defineProperty(exports, "usageQuantitySchema", { enumerable: true, get: function () { return money_1.usageQuantitySchema; } });
378
+ Object.defineProperty(exports, "unitPriceSchema", { enumerable: true, get: function () { return money_1.unitPriceSchema; } });
379
+ var attribution_1 = require("./inference/attribution");
380
+ // Canonical attribution: who pays, which app, which credential, which user.
381
+ Object.defineProperty(exports, "INFERENCE_SCOPES", { enumerable: true, get: function () { return attribution_1.INFERENCE_SCOPES; } });
382
+ Object.defineProperty(exports, "inferenceScopeSchema", { enumerable: true, get: function () { return attribution_1.inferenceScopeSchema; } });
383
+ Object.defineProperty(exports, "billingPrincipalSchema", { enumerable: true, get: function () { return attribution_1.billingPrincipalSchema; } });
384
+ Object.defineProperty(exports, "authenticatedPrincipalSchema", { enumerable: true, get: function () { return attribution_1.authenticatedPrincipalSchema; } });
385
+ Object.defineProperty(exports, "inferenceAttributionSchema", { enumerable: true, get: function () { return attribution_1.inferenceAttributionSchema; } });
386
+ var errors_1 = require("./inference/errors");
387
+ // Closed error vocabulary + retryability + a leak-proof provider passthrough.
388
+ Object.defineProperty(exports, "INFERENCE_ERROR_CODES", { enumerable: true, get: function () { return errors_1.INFERENCE_ERROR_CODES; } });
389
+ Object.defineProperty(exports, "NON_RETRYABLE_INFERENCE_ERROR_CODES", { enumerable: true, get: function () { return errors_1.NON_RETRYABLE_INFERENCE_ERROR_CODES; } });
390
+ Object.defineProperty(exports, "inferenceErrorCodeSchema", { enumerable: true, get: function () { return errors_1.inferenceErrorCodeSchema; } });
391
+ Object.defineProperty(exports, "upstreamErrorCategorySchema", { enumerable: true, get: function () { return errors_1.upstreamErrorCategorySchema; } });
392
+ Object.defineProperty(exports, "safeErrorTextSchema", { enumerable: true, get: function () { return errors_1.safeErrorTextSchema; } });
393
+ Object.defineProperty(exports, "providerErrorPassthroughSchema", { enumerable: true, get: function () { return errors_1.providerErrorPassthroughSchema; } });
394
+ Object.defineProperty(exports, "inferenceErrorSchema", { enumerable: true, get: function () { return errors_1.inferenceErrorSchema; } });
395
+ var priceVersion_1 = require("./inference/priceVersion");
396
+ // Price versions and the snapshot a settled receipt keeps.
397
+ Object.defineProperty(exports, "priceVersionStatusSchema", { enumerable: true, get: function () { return priceVersion_1.priceVersionStatusSchema; } });
398
+ Object.defineProperty(exports, "priceVersionSchema", { enumerable: true, get: function () { return priceVersion_1.priceVersionSchema; } });
399
+ Object.defineProperty(exports, "priceSnapshotSchema", { enumerable: true, get: function () { return priceVersion_1.priceSnapshotSchema; } });
400
+ var catalogue_1 = require("./inference/catalogue");
401
+ // The six distinct catalogue objects + the customer-safe projection.
402
+ Object.defineProperty(exports, "inferenceModalitySchema", { enumerable: true, get: function () { return catalogue_1.inferenceModalitySchema; } });
403
+ Object.defineProperty(exports, "modelCapabilitiesSchema", { enumerable: true, get: function () { return catalogue_1.modelCapabilitiesSchema; } });
404
+ Object.defineProperty(exports, "modelLicenseSchema", { enumerable: true, get: function () { return catalogue_1.modelLicenseSchema; } });
405
+ Object.defineProperty(exports, "modelProvenanceSchema", { enumerable: true, get: function () { return catalogue_1.modelProvenanceSchema; } });
406
+ Object.defineProperty(exports, "inferenceDataPolicySchema", { enumerable: true, get: function () { return catalogue_1.inferenceDataPolicySchema; } });
407
+ Object.defineProperty(exports, "availabilityScopeSchema", { enumerable: true, get: function () { return catalogue_1.availabilityScopeSchema; } });
408
+ Object.defineProperty(exports, "commercialPermissionSchema", { enumerable: true, get: function () { return catalogue_1.commercialPermissionSchema; } });
409
+ Object.defineProperty(exports, "modelDeprecationSchema", { enumerable: true, get: function () { return catalogue_1.modelDeprecationSchema; } });
410
+ Object.defineProperty(exports, "modelEvaluationResultSchema", { enumerable: true, get: function () { return catalogue_1.modelEvaluationResultSchema; } });
411
+ Object.defineProperty(exports, "modelSafetyMetadataSchema", { enumerable: true, get: function () { return catalogue_1.modelSafetyMetadataSchema; } });
412
+ Object.defineProperty(exports, "modelPublisherSchema", { enumerable: true, get: function () { return catalogue_1.modelPublisherSchema; } });
413
+ Object.defineProperty(exports, "catalogueModelSchema", { enumerable: true, get: function () { return catalogue_1.catalogueModelSchema; } });
414
+ Object.defineProperty(exports, "modelRevisionSchema", { enumerable: true, get: function () { return catalogue_1.modelRevisionSchema; } });
415
+ Object.defineProperty(exports, "inferenceProviderSchema", { enumerable: true, get: function () { return catalogue_1.inferenceProviderSchema; } });
416
+ Object.defineProperty(exports, "modelDeploymentSchema", { enumerable: true, get: function () { return catalogue_1.modelDeploymentSchema; } });
417
+ Object.defineProperty(exports, "routingProfileCandidateSchema", { enumerable: true, get: function () { return catalogue_1.routingProfileCandidateSchema; } });
418
+ Object.defineProperty(exports, "routingProfileSchema", { enumerable: true, get: function () { return catalogue_1.routingProfileSchema; } });
419
+ Object.defineProperty(exports, "cataloguePublisherSummarySchema", { enumerable: true, get: function () { return catalogue_1.cataloguePublisherSummarySchema; } });
420
+ Object.defineProperty(exports, "catalogueServingProviderSummarySchema", { enumerable: true, get: function () { return catalogue_1.catalogueServingProviderSummarySchema; } });
421
+ Object.defineProperty(exports, "modelCatalogueEntrySchema", { enumerable: true, get: function () { return catalogue_1.modelCatalogueEntrySchema; } });
422
+ var routingPolicy_1 = require("./inference/routingPolicy");
423
+ // Routing policy: every control, plus the refinement that rejects a policy
424
+ // no route could ever satisfy.
425
+ Object.defineProperty(exports, "routingTargetSchema", { enumerable: true, get: function () { return routingPolicy_1.routingTargetSchema; } });
426
+ Object.defineProperty(exports, "routingPolicyScopeSchema", { enumerable: true, get: function () { return routingPolicy_1.routingPolicyScopeSchema; } });
427
+ Object.defineProperty(exports, "routingFallbackPolicySchema", { enumerable: true, get: function () { return routingPolicy_1.routingFallbackPolicySchema; } });
428
+ Object.defineProperty(exports, "routingPolicySchema", { enumerable: true, get: function () { return routingPolicy_1.routingPolicySchema; } });
429
+ Object.defineProperty(exports, "routingPolicyReferenceSchema", { enumerable: true, get: function () { return routingPolicy_1.routingPolicyReferenceSchema; } });
430
+ var request_1 = require("./inference/request");
431
+ // The normalized Oxy→data-plane request envelope.
432
+ Object.defineProperty(exports, "inferenceContentSourceSchema", { enumerable: true, get: function () { return request_1.inferenceContentSourceSchema; } });
433
+ Object.defineProperty(exports, "inferenceContentPartSchema", { enumerable: true, get: function () { return request_1.inferenceContentPartSchema; } });
434
+ Object.defineProperty(exports, "inferenceToolCallSchema", { enumerable: true, get: function () { return request_1.inferenceToolCallSchema; } });
435
+ Object.defineProperty(exports, "inferenceMessageRoleSchema", { enumerable: true, get: function () { return request_1.inferenceMessageRoleSchema; } });
436
+ Object.defineProperty(exports, "inferenceMessageSchema", { enumerable: true, get: function () { return request_1.inferenceMessageSchema; } });
437
+ Object.defineProperty(exports, "inferenceInputSchema", { enumerable: true, get: function () { return request_1.inferenceInputSchema; } });
438
+ Object.defineProperty(exports, "samplingParametersSchema", { enumerable: true, get: function () { return request_1.samplingParametersSchema; } });
439
+ Object.defineProperty(exports, "toolDefinitionSchema", { enumerable: true, get: function () { return request_1.toolDefinitionSchema; } });
440
+ Object.defineProperty(exports, "toolChoiceSchema", { enumerable: true, get: function () { return request_1.toolChoiceSchema; } });
441
+ Object.defineProperty(exports, "responseFormatSchema", { enumerable: true, get: function () { return request_1.responseFormatSchema; } });
442
+ Object.defineProperty(exports, "clientRequestMetadataSchema", { enumerable: true, get: function () { return request_1.clientRequestMetadataSchema; } });
443
+ Object.defineProperty(exports, "inferenceRequestSchema", { enumerable: true, get: function () { return request_1.inferenceRequestSchema; } });
444
+ var streamEvents_1 = require("./inference/streamEvents");
445
+ // Normalized SSE events.
446
+ Object.defineProperty(exports, "inferenceStreamStartEventSchema", { enumerable: true, get: function () { return streamEvents_1.inferenceStreamStartEventSchema; } });
447
+ Object.defineProperty(exports, "inferenceStreamDeltaEventSchema", { enumerable: true, get: function () { return streamEvents_1.inferenceStreamDeltaEventSchema; } });
448
+ Object.defineProperty(exports, "inferenceStreamToolCallEventSchema", { enumerable: true, get: function () { return streamEvents_1.inferenceStreamToolCallEventSchema; } });
449
+ Object.defineProperty(exports, "inferenceStreamUsageEventSchema", { enumerable: true, get: function () { return streamEvents_1.inferenceStreamUsageEventSchema; } });
450
+ Object.defineProperty(exports, "inferenceRouteSwitchDetailSchema", { enumerable: true, get: function () { return streamEvents_1.inferenceRouteSwitchDetailSchema; } });
451
+ Object.defineProperty(exports, "inferenceRouteSwitchReasonSchema", { enumerable: true, get: function () { return streamEvents_1.inferenceRouteSwitchReasonSchema; } });
452
+ Object.defineProperty(exports, "inferenceStreamRouteSwitchEventSchema", { enumerable: true, get: function () { return streamEvents_1.inferenceStreamRouteSwitchEventSchema; } });
453
+ Object.defineProperty(exports, "inferenceStreamErrorEventSchema", { enumerable: true, get: function () { return streamEvents_1.inferenceStreamErrorEventSchema; } });
454
+ Object.defineProperty(exports, "inferenceFinishReasonSchema", { enumerable: true, get: function () { return streamEvents_1.inferenceFinishReasonSchema; } });
455
+ Object.defineProperty(exports, "inferenceStreamDoneEventSchema", { enumerable: true, get: function () { return streamEvents_1.inferenceStreamDoneEventSchema; } });
456
+ Object.defineProperty(exports, "inferenceStreamEventSchema", { enumerable: true, get: function () { return streamEvents_1.inferenceStreamEventSchema; } });
457
+ var usage_1 = require("./inference/usage");
458
+ // Reserve → settle → refund.
459
+ Object.defineProperty(exports, "usageReservationRequestSchema", { enumerable: true, get: function () { return usage_1.usageReservationRequestSchema; } });
460
+ Object.defineProperty(exports, "usageReservationStatusSchema", { enumerable: true, get: function () { return usage_1.usageReservationStatusSchema; } });
461
+ Object.defineProperty(exports, "usageReservationSchema", { enumerable: true, get: function () { return usage_1.usageReservationSchema; } });
462
+ Object.defineProperty(exports, "inferenceRequestOutcomeSchema", { enumerable: true, get: function () { return usage_1.inferenceRequestOutcomeSchema; } });
463
+ Object.defineProperty(exports, "normalizedUsageReportSchema", { enumerable: true, get: function () { return usage_1.normalizedUsageReportSchema; } });
464
+ Object.defineProperty(exports, "usageReceiptSchema", { enumerable: true, get: function () { return usage_1.usageReceiptSchema; } });
465
+ Object.defineProperty(exports, "usageRefundSubjectSchema", { enumerable: true, get: function () { return usage_1.usageRefundSubjectSchema; } });
466
+ Object.defineProperty(exports, "usageRefundReasonSchema", { enumerable: true, get: function () { return usage_1.usageRefundReasonSchema; } });
467
+ Object.defineProperty(exports, "usageRefundSchema", { enumerable: true, get: function () { return usage_1.usageRefundSchema; } });
468
+ var providerConnection_1 = require("./inference/providerConnection");
469
+ // BYOK connection metadata that structurally cannot carry a secret.
470
+ Object.defineProperty(exports, "providerConnectionScopeSchema", { enumerable: true, get: function () { return providerConnection_1.providerConnectionScopeSchema; } });
471
+ Object.defineProperty(exports, "providerSecretReferenceSchema", { enumerable: true, get: function () { return providerConnection_1.providerSecretReferenceSchema; } });
472
+ Object.defineProperty(exports, "providerConnectionValidationSchema", { enumerable: true, get: function () { return providerConnection_1.providerConnectionValidationSchema; } });
473
+ Object.defineProperty(exports, "providerConnectionStatusSchema", { enumerable: true, get: function () { return providerConnection_1.providerConnectionStatusSchema; } });
474
+ Object.defineProperty(exports, "providerConnectionSchema", { enumerable: true, get: function () { return providerConnection_1.providerConnectionSchema; } });
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ /**
3
+ * Canonical attribution for an inference request.
4
+ *
5
+ * Every accepted request resolves to an Oxy account, an Oxy application, the
6
+ * Oxy credential that authenticated it, an optional delegated end user, and the
7
+ * ids that correlate it across the edge, the data plane and the ledger. The
8
+ * data plane may store these as immutable references; it never owns or mutates
9
+ * them, and it never mints a customer identity of its own.
10
+ *
11
+ * The rule this file encodes structurally, rather than restating in prose:
12
+ * **the delegated `userId` can never be the billing identity.** Two independent
13
+ * mechanisms enforce it, one at compile time and one at parse time, because a
14
+ * delegated identity being charged for somebody else's workload is the kind of
15
+ * mistake that produces a correct-looking invoice for the wrong customer:
16
+ *
17
+ * 1. `accountId` and `userId` carry DIFFERENT brands, so neither is assignable
18
+ * to the other in any consumer without a cast.
19
+ * 2. {@link billingPrincipalSchema} is `.strict()` and holds exactly one field,
20
+ * so a payload that smuggles `userId` into the billing block is rejected at
21
+ * the parse rather than stripped and forgotten.
22
+ *
23
+ * These shapes are EMBEDDED — they ride inside a request envelope, a receipt or
24
+ * a ledger record and inherit its `schemaVersion`. Versioning them separately
25
+ * would let one message claim two versions.
26
+ *
27
+ * Decided in: docs/adr/0007-canonical-request-attribution.md.
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.inferenceAttributionSchema = exports.authenticatedPrincipalSchema = exports.billingPrincipalSchema = exports.inferenceScopeSchema = exports.INFERENCE_SCOPES = void 0;
31
+ const zod_1 = require("zod");
32
+ const identifiers_1 = require("./identifiers");
33
+ /**
34
+ * The inference capability scopes the data plane needs to know about.
35
+ *
36
+ * A credential may carry many other Oxy scopes; only these cross the boundary,
37
+ * because the data plane's authorization questions are exactly "may this caller
38
+ * invoke", "may it read the catalogue", "may it read usage", "may it read or
39
+ * write routing", "may it read or write provider connections". Everything else
40
+ * is the control plane's business and is not the data plane's to hold.
41
+ */
42
+ exports.INFERENCE_SCOPES = [
43
+ 'inference:invoke',
44
+ 'inference:models:read',
45
+ 'inference:usage:read',
46
+ 'inference:routing:read',
47
+ 'inference:routing:write',
48
+ 'inference:providers:read',
49
+ 'inference:providers:write',
50
+ ];
51
+ exports.inferenceScopeSchema = zod_1.z.enum(exports.INFERENCE_SCOPES);
52
+ /**
53
+ * The financially responsible principal, and the ONLY identity a charge may be
54
+ * booked against.
55
+ *
56
+ * It is its own type — not a field on a larger principal object — precisely so
57
+ * that a function taking "who pays" cannot be handed a user, a session, a
58
+ * device or an application. It cannot be constructed from a delegated user id:
59
+ * the brands differ, and this object accepts no other key.
60
+ */
61
+ exports.billingPrincipalSchema = zod_1.z
62
+ .object({
63
+ accountId: identifiers_1.oxyAccountIdSchema,
64
+ })
65
+ .strict();
66
+ /**
67
+ * Who authenticated, as resolved by the Oxy edge before a request is forwarded.
68
+ *
69
+ * Mirrors what a verified Oxy service token carries (`appId`, `credentialId`,
70
+ * `ownerAccountId`, `environment`, effective scopes) so that the two
71
+ * authentication paths — a machine API key and a first-party service token —
72
+ * produce one shape downstream. The data plane authorizes against this
73
+ * envelope; it does not re-derive access from its own database, because it has
74
+ * no account graph to re-derive it from.
75
+ */
76
+ exports.authenticatedPrincipalSchema = zod_1.z.object({
77
+ billing: exports.billingPrincipalSchema,
78
+ applicationId: identifiers_1.oxyApplicationIdSchema,
79
+ credentialId: identifiers_1.oxyCredentialIdSchema,
80
+ environment: identifiers_1.inferenceEnvironmentSchema,
81
+ inferenceScopes: zod_1.z.array(exports.inferenceScopeSchema),
82
+ });
83
+ /**
84
+ * The attribution block carried by every request, receipt and ledger record.
85
+ *
86
+ * `userId` is the OPTIONAL delegated end user — Alia's `X-Oxy-User-Id`. It is
87
+ * attribution only: it never changes which account is charged, never grants
88
+ * access, and lives outside {@link billingPrincipalSchema} so that no code path
89
+ * can read it as the payer.
90
+ *
91
+ * `requestId` is generated by the data plane and always present; `generationId`
92
+ * is present
93
+ * once a generation exists, which is why it is optional on a request and
94
+ * expected on a receipt.
95
+ */
96
+ exports.inferenceAttributionSchema = zod_1.z.object({
97
+ principal: exports.authenticatedPrincipalSchema,
98
+ userId: identifiers_1.delegatedUserIdSchema.optional(),
99
+ requestId: identifiers_1.requestIdSchema,
100
+ generationId: identifiers_1.generationIdSchema.optional(),
101
+ });