@oxyhq/contracts 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/identity.js +33 -1
- package/dist/cjs/index.js +20 -7
- package/dist/cjs/inference/aliaModelRelease.js +250 -0
- package/dist/cjs/inference/catalogue.js +1 -4
- package/dist/cjs/inference/errors.js +108 -9
- package/dist/cjs/inference/identifiers.js +23 -3
- package/dist/cjs/inference/request.js +188 -5
- package/dist/cjs/inference/routingPolicy.js +81 -2
- package/dist/cjs/inference/streamEvents.js +38 -1
- package/dist/cjs/inference/usage.js +32 -1
- package/dist/cjs/inference/version.js +24 -4
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/identity.js +32 -0
- package/dist/esm/index.js +8 -3
- package/dist/esm/inference/aliaModelRelease.js +247 -0
- package/dist/esm/inference/catalogue.js +2 -5
- package/dist/esm/inference/errors.js +108 -9
- package/dist/esm/inference/identifiers.js +22 -2
- package/dist/esm/inference/request.js +189 -6
- package/dist/esm/inference/routingPolicy.js +81 -2
- package/dist/esm/inference/streamEvents.js +38 -1
- package/dist/esm/inference/usage.js +32 -1
- package/dist/esm/inference/version.js +24 -4
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/identity.d.ts +59 -1
- package/dist/types/index.d.ts +7 -5
- package/dist/types/inference/accountBilling.d.ts +26 -26
- package/dist/types/inference/aliaModelRelease.d.ts +597 -0
- package/dist/types/inference/catalogue.d.ts +6 -6
- package/dist/types/inference/entitlement.d.ts +4 -4
- package/dist/types/inference/errors.d.ts +46 -10
- package/dist/types/inference/identifiers.d.ts +20 -2
- package/dist/types/inference/money.d.ts +4 -4
- package/dist/types/inference/priceVersion.d.ts +14 -14
- package/dist/types/inference/providerConnection.d.ts +4 -4
- package/dist/types/inference/request.d.ts +291 -5
- package/dist/types/inference/routingPolicy.d.ts +109 -13
- package/dist/types/inference/streamEvents.d.ts +84 -48
- package/dist/types/inference/usage.d.ts +103 -79
- package/dist/types/inference/version.d.ts +24 -4
- package/dist/types/keyRecovery.d.ts +4 -4
- package/package.json +1 -1
package/dist/cjs/identity.js
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
* `require()`).
|
|
40
40
|
*/
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.exportBundleSchema = exports.exportAttestationSchema = exports.authMethodsResponseSchema = exports.authMethodEntrySchema = exports.domainVerificationInstructionsSchema = exports.domainVerificationRequestSchema = exports.verifiedDomainSchema = exports.signedRecordEnvelopeSchema = exports.didDocumentSchema = exports.didServiceSchema = exports.verificationMethodSchema = void 0;
|
|
42
|
+
exports.exportBundleSchema = exports.exportFinancialSectionSchema = exports.exportUsageReservationSchema = exports.exportLedgerEntrySchema = exports.exportUsageReceiptSchema = exports.exportAttestationSchema = exports.authMethodsResponseSchema = exports.authMethodEntrySchema = exports.domainVerificationInstructionsSchema = exports.domainVerificationRequestSchema = exports.verifiedDomainSchema = exports.signedRecordEnvelopeSchema = exports.didDocumentSchema = exports.didServiceSchema = exports.verificationMethodSchema = void 0;
|
|
43
43
|
const zod_1 = require("zod");
|
|
44
44
|
// The option schemas are left UN-annotated so they keep their concrete
|
|
45
45
|
// `ZodObject` type — `z.discriminatedUnion` requires object options and an
|
|
@@ -207,6 +207,37 @@ exports.exportAttestationSchema = zod_1.z.object({
|
|
|
207
207
|
signature: zod_1.z.string(),
|
|
208
208
|
signedAt: zod_1.z.number(),
|
|
209
209
|
});
|
|
210
|
+
exports.exportUsageReceiptSchema = zod_1.z.object({
|
|
211
|
+
receiptId: zod_1.z.string(),
|
|
212
|
+
requestId: zod_1.z.string(),
|
|
213
|
+
settledAt: zod_1.z.string(),
|
|
214
|
+
billedAmount: zod_1.z.string(),
|
|
215
|
+
currency: zod_1.z.string(),
|
|
216
|
+
outcome: zod_1.z.string(),
|
|
217
|
+
resolvedModelReference: zod_1.z.string(),
|
|
218
|
+
servingProvider: zod_1.z.string(),
|
|
219
|
+
platformFeeOnly: zod_1.z.boolean(),
|
|
220
|
+
});
|
|
221
|
+
exports.exportLedgerEntrySchema = zod_1.z.object({
|
|
222
|
+
entryId: zod_1.z.string(),
|
|
223
|
+
kind: zod_1.z.string(),
|
|
224
|
+
currency: zod_1.z.string(),
|
|
225
|
+
createdAt: zod_1.z.string(),
|
|
226
|
+
});
|
|
227
|
+
exports.exportUsageReservationSchema = zod_1.z.object({
|
|
228
|
+
reservationId: zod_1.z.string(),
|
|
229
|
+
requestId: zod_1.z.string(),
|
|
230
|
+
status: zod_1.z.string(),
|
|
231
|
+
reservedAmount: zod_1.z.string(),
|
|
232
|
+
currency: zod_1.z.string(),
|
|
233
|
+
createdAt: zod_1.z.string(),
|
|
234
|
+
expiresAt: zod_1.z.string(),
|
|
235
|
+
});
|
|
236
|
+
exports.exportFinancialSectionSchema = zod_1.z.object({
|
|
237
|
+
receipts: zod_1.z.array(exports.exportUsageReceiptSchema),
|
|
238
|
+
ledgerEntries: zod_1.z.array(exports.exportLedgerEntrySchema),
|
|
239
|
+
reservations: zod_1.z.array(exports.exportUsageReservationSchema),
|
|
240
|
+
});
|
|
210
241
|
exports.exportBundleSchema = zod_1.z.object({
|
|
211
242
|
'$schema': zod_1.z.string(),
|
|
212
243
|
exportedAt: zod_1.z.string(),
|
|
@@ -221,6 +252,7 @@ exports.exportBundleSchema = zod_1.z.object({
|
|
|
221
252
|
following: zod_1.z.array(zod_1.z.string()),
|
|
222
253
|
followers: zod_1.z.array(zod_1.z.string()),
|
|
223
254
|
}),
|
|
255
|
+
financial: exports.exportFinancialSectionSchema,
|
|
224
256
|
attestation: exports.exportAttestationSchema.nullable(),
|
|
225
257
|
proof: exports.exportAttestationSchema.optional(),
|
|
226
258
|
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,13 +12,14 @@
|
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.appInterestInputSchema = exports.appEndorsementInputSchema = exports.recommendationResponseSchema = exports.recommendationItemSchema = exports.recommendationCountSchema = exports.recommendationRequestSchema = exports.recommendationSignalWeightsSchema = exports.recommendationBoostSchema = exports.recommendationExcludeTypeSchema = exports.oxyUserInvalidationEventSchema = exports.isPublishedOxyUserChangeReason = exports.OXY_PUBLISHED_USER_CHANGE_REASONS = exports.OXY_USER_CHANGE_REASONS = exports.OXY_USER_INVALIDATION_CHANNEL = exports.inboxEmailPushDataSchema = exports.INBOX_EMAIL_PUSH_TYPE = exports.INBOX_EMAIL_PUSH_CHANNEL = exports.IDENTITY_APPROVAL_PUSH_CHANNEL = exports.commonsDenyReasonSchema = exports.COMMONS_DENY_REASONS = exports.sessionStatusSchema = exports.publicApplicationSchema = exports.applicationTypeSchema = exports.safeParseContract = exports.resolveUserId = exports.deviceLinkedSessionsResponseSchema = exports.deviceLinkedSessionSchema = exports.currentUserResponseSchema = exports.userProfileUpdateSchema = exports.userResponseSchema = exports.themePreferenceSchema = exports.userRelationshipSchema = exports.userNameSchema = exports.createAccountRequestSchema = exports.SELECTABLE_ACCOUNT_CATEGORY_IDS = exports.RETIRED_ACCOUNT_CATEGORY_IDS = exports.newlyAddedRetiredCategories = exports.MAX_ACCOUNT_CATEGORIES = exports.kindAcceptsAccountCategories = exports.isSelectableAccountCategoryId = exports.accountCategoryIdSchema = exports.accountCategoriesSchema = exports.ACCOUNT_CATEGORY_KINDS = exports.ACCOUNT_CATEGORY_IDS = exports.isActAsEligibleKind = exports.isAccountKind = exports.childAccountKindSchema = exports.CHILD_ACCOUNT_KINDS = exports.accountKindSchema = exports.ACCOUNT_KINDS = void 0;
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
15
|
+
exports.reputationTargetEntityTypeSchema = exports.trustTierSchema = exports.reputationTransactionStatusSchema = exports.reputationCategorySchema = exports.REPUTATION_INFLUENCE_CONTEXTS = exports.REPUTATION_DISPUTE_STATUSES = exports.REPUTATION_TARGET_ENTITY_TYPES = exports.TRUST_TIERS = exports.REPUTATION_TRANSACTION_STATUSES = exports.REPUTATION_CATEGORIES = exports.credentialVerifyResultSchema = exports.credentialListResultSchema = exports.credentialIssueResultSchema = exports.verifiableCredentialResponseSchema = exports.credentialRecordSchema = exports.vouchResultSchema = exports.personhoodStatusResultSchema = exports.personhoodBreakdownSchema = exports.personhoodVouchRecordSchema = exports.validationVoteResultSchema = exports.validationRequestSummarySchema = exports.validationOpenResultSchema = exports.validationOpenRequestSchema = exports.validationVerdictRecordSchema = exports.realLifeAttestationResultSchema = exports.realLifeAttestationRecordSchema = exports.signedPublicCardSchema = exports.publicCardSchema = exports.logPageResponseSchema = exports.chainHeadResponseSchema = exports.oxySignedRecordTypeSchema = exports.exportBundleSchema = exports.exportFinancialSectionSchema = exports.exportUsageReservationSchema = exports.exportLedgerEntrySchema = exports.exportUsageReceiptSchema = exports.exportAttestationSchema = exports.authMethodsResponseSchema = exports.authMethodEntrySchema = exports.domainVerificationInstructionsSchema = exports.domainVerificationRequestSchema = exports.verifiedDomainSchema = exports.signedRecordEnvelopeSchema = exports.didDocumentSchema = exports.didServiceSchema = exports.verificationMethodSchema = exports.appAffinityEventsIngestSchema = exports.appAffinityEventSchema = exports.appAffinityEventTypeSchema = exports.appUserSignalIngestSchema = void 0;
|
|
16
|
+
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 = exports.reputationBalanceBreakdownSchema = exports.reputationTransactionSchema = exports.reputationInfluenceContextSchema = exports.reputationDisputeStatusSchema = void 0;
|
|
17
|
+
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 = exports.reverseModerationEffectSchema = exports.finalizeModerationDecisionSchema = exports.moderationDecisionEventSchema = exports.moderationPolicyVersionsSchema = void 0;
|
|
18
|
+
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 = exports.hubActivateRequestSchema = exports.hubClaimRequestSchema = exports.hubSessionSchema = exports.browserHubRevokeResponseSchema = void 0;
|
|
19
|
+
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.sha256DigestSchema = 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 = exports.transparencyCheckpointSchema = exports.transparencyAnchorSchema = exports.transparencyCheckpointSignatureSchema = exports.deviceTransferDenyResponseSchema = void 0;
|
|
20
|
+
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.aliaModelReleaseManifestSchema = exports.aliaReleaseSignatureSchema = exports.aliaReleaseArtifactSchema = exports.authorizedRouteSchema = 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 = exports.inferenceModalitySchema = exports.priceSnapshotSchema = exports.priceVersionSchema = exports.priceVersionStatusSchema = exports.inferenceErrorSchema = void 0;
|
|
21
|
+
exports.productPlanSchema = exports.planAllowanceSchema = exports.LIVE_PRODUCT_PLAN_STATUSES = exports.productPlanStatusSchema = exports.PRODUCT_PLAN_STATUSES = exports.reconciliationReportSchema = exports.reconciliationRunSchema = exports.reconciliationDiscrepancySchema = exports.reconciliationRunStatusSchema = exports.RECONCILIATION_RUN_STATUSES = exports.reconciliationDiscrepancyKindSchema = exports.RECONCILIATION_DISCREPANCY_KINDS = exports.autoRechargeAttemptSchema = exports.autoRechargeStatusSchema = exports.AUTO_RECHARGE_STATUSES = exports.externalPaymentSchema = exports.externalPaymentKindSchema = exports.EXTERNAL_PAYMENT_KINDS = exports.externalPaymentProviderSchema = exports.EXTERNAL_PAYMENT_PROVIDERS = exports.billingInvoiceSchema = exports.billingInvoiceStatusSchema = exports.BILLING_INVOICE_STATUSES = exports.accountBillingStateSchema = exports.billingProfileSchema = exports.autoRechargeSchema = exports.billingProfileStatusSchema = exports.BILLING_PROFILE_STATUSES = exports.billingModeSchema = exports.BILLING_MODES = exports.providerConnectionSchema = exports.providerConnectionStatusSchema = exports.providerConnectionValidationSchema = exports.providerSecretReferenceSchema = exports.providerConnectionScopeSchema = exports.usageRefundSchema = exports.usageRefundReasonSchema = exports.usageRefundSubjectSchema = exports.usageReceiptSchema = exports.normalizedUsageReportSchema = exports.inferenceRequestOutcomeSchema = exports.usageReservationSchema = exports.usageReservationStatusSchema = exports.usageReservationRequestSchema = exports.inferenceStreamEventSchema = exports.inferenceStreamDoneEventSchema = exports.inferenceFinishReasonSchema = exports.inferenceStreamErrorEventSchema = exports.inferenceStreamRouteSwitchEventSchema = exports.inferenceRouteSwitchReasonSchema = void 0;
|
|
22
|
+
exports.productEntitlementSchema = exports.costCenterSpendSchema = exports.costCenterSchema = exports.costCenterStatusSchema = exports.COST_CENTER_STATUSES = exports.payAsYouGoEntitlementSchema = void 0;
|
|
22
23
|
var accountGraph_1 = require("./accountGraph");
|
|
23
24
|
Object.defineProperty(exports, "ACCOUNT_KINDS", { enumerable: true, get: function () { return accountGraph_1.ACCOUNT_KINDS; } });
|
|
24
25
|
Object.defineProperty(exports, "accountKindSchema", { enumerable: true, get: function () { return accountGraph_1.accountKindSchema; } });
|
|
@@ -99,6 +100,10 @@ Object.defineProperty(exports, "domainVerificationInstructionsSchema", { enumera
|
|
|
99
100
|
Object.defineProperty(exports, "authMethodEntrySchema", { enumerable: true, get: function () { return identity_1.authMethodEntrySchema; } });
|
|
100
101
|
Object.defineProperty(exports, "authMethodsResponseSchema", { enumerable: true, get: function () { return identity_1.authMethodsResponseSchema; } });
|
|
101
102
|
Object.defineProperty(exports, "exportAttestationSchema", { enumerable: true, get: function () { return identity_1.exportAttestationSchema; } });
|
|
103
|
+
Object.defineProperty(exports, "exportUsageReceiptSchema", { enumerable: true, get: function () { return identity_1.exportUsageReceiptSchema; } });
|
|
104
|
+
Object.defineProperty(exports, "exportLedgerEntrySchema", { enumerable: true, get: function () { return identity_1.exportLedgerEntrySchema; } });
|
|
105
|
+
Object.defineProperty(exports, "exportUsageReservationSchema", { enumerable: true, get: function () { return identity_1.exportUsageReservationSchema; } });
|
|
106
|
+
Object.defineProperty(exports, "exportFinancialSectionSchema", { enumerable: true, get: function () { return identity_1.exportFinancialSectionSchema; } });
|
|
102
107
|
Object.defineProperty(exports, "exportBundleSchema", { enumerable: true, get: function () { return identity_1.exportBundleSchema; } });
|
|
103
108
|
var oxyRecordTypes_1 = require("./oxyRecordTypes");
|
|
104
109
|
// Schemas
|
|
@@ -353,6 +358,7 @@ Object.defineProperty(exports, "inferenceEnvironmentSchema", { enumerable: true,
|
|
|
353
358
|
Object.defineProperty(exports, "inferenceTimestampSchema", { enumerable: true, get: function () { return identifiers_1.inferenceTimestampSchema; } });
|
|
354
359
|
Object.defineProperty(exports, "inferenceDateSchema", { enumerable: true, get: function () { return identifiers_1.inferenceDateSchema; } });
|
|
355
360
|
Object.defineProperty(exports, "inferenceHttpsUrlSchema", { enumerable: true, get: function () { return identifiers_1.inferenceHttpsUrlSchema; } });
|
|
361
|
+
Object.defineProperty(exports, "sha256DigestSchema", { enumerable: true, get: function () { return identifiers_1.sha256DigestSchema; } });
|
|
356
362
|
// Catalogue references
|
|
357
363
|
Object.defineProperty(exports, "publisherSlugSchema", { enumerable: true, get: function () { return identifiers_1.publisherSlugSchema; } });
|
|
358
364
|
Object.defineProperty(exports, "modelSlugSchema", { enumerable: true, get: function () { return identifiers_1.modelSlugSchema; } });
|
|
@@ -427,6 +433,13 @@ Object.defineProperty(exports, "routingPolicyScopeSchema", { enumerable: true, g
|
|
|
427
433
|
Object.defineProperty(exports, "routingFallbackPolicySchema", { enumerable: true, get: function () { return routingPolicy_1.routingFallbackPolicySchema; } });
|
|
428
434
|
Object.defineProperty(exports, "routingPolicySchema", { enumerable: true, get: function () { return routingPolicy_1.routingPolicySchema; } });
|
|
429
435
|
Object.defineProperty(exports, "routingPolicyReferenceSchema", { enumerable: true, get: function () { return routingPolicy_1.routingPolicyReferenceSchema; } });
|
|
436
|
+
// What the data plane actually receives: the routes the policy authorized.
|
|
437
|
+
Object.defineProperty(exports, "authorizedRouteSchema", { enumerable: true, get: function () { return routingPolicy_1.authorizedRouteSchema; } });
|
|
438
|
+
var aliaModelRelease_1 = require("./inference/aliaModelRelease");
|
|
439
|
+
// The signed Alia model release manifest (ingestion contract; no endpoint).
|
|
440
|
+
Object.defineProperty(exports, "aliaReleaseArtifactSchema", { enumerable: true, get: function () { return aliaModelRelease_1.aliaReleaseArtifactSchema; } });
|
|
441
|
+
Object.defineProperty(exports, "aliaReleaseSignatureSchema", { enumerable: true, get: function () { return aliaModelRelease_1.aliaReleaseSignatureSchema; } });
|
|
442
|
+
Object.defineProperty(exports, "aliaModelReleaseManifestSchema", { enumerable: true, get: function () { return aliaModelRelease_1.aliaModelReleaseManifestSchema; } });
|
|
430
443
|
var request_1 = require("./inference/request");
|
|
431
444
|
// The normalized Oxy→data-plane request envelope.
|
|
432
445
|
Object.defineProperty(exports, "inferenceContentSourceSchema", { enumerable: true, get: function () { return request_1.inferenceContentSourceSchema; } });
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The signed Alia model release manifest — the ingestion contract for a
|
|
4
|
+
* first-party model release.
|
|
5
|
+
*
|
|
6
|
+
* The catalogue already STORES everything such a manifest carries: the model
|
|
7
|
+
* card, the licence block, the provenance and base model, the evaluation table,
|
|
8
|
+
* the safety metadata, and an artifact digest with a `sha256:<64 hex>` CHECK.
|
|
9
|
+
* What did not exist was the manifest itself — a single document Alia SIGNS,
|
|
10
|
+
* asserting all of it at once — and that is the gap this shape closes. Nothing
|
|
11
|
+
* here re-declares a catalogue field; the manifest COMPOSES the published shapes
|
|
12
|
+
* so a manifest and the catalogue row it produces cannot describe a release
|
|
13
|
+
* differently.
|
|
14
|
+
*
|
|
15
|
+
* ## The manifest tightens the revision it carries
|
|
16
|
+
*
|
|
17
|
+
* `modelRevisionSchema` makes `modelCardUrl`, `artifactDigest`, `evaluations`
|
|
18
|
+
* and `safety` optional, because a third-party route legitimately has none of
|
|
19
|
+
* them — Oxy did not train those weights and cannot publish a card for them. A
|
|
20
|
+
* FIRST-PARTY release has no such excuse: the documentation trail is the reason
|
|
21
|
+
* a release manifest exists at all, and a model Alia ships without one is not a
|
|
22
|
+
* release, it is a deployment. So the refinement below requires all four,
|
|
23
|
+
* without changing the catalogue shape that a third-party entry still parses
|
|
24
|
+
* through.
|
|
25
|
+
*
|
|
26
|
+
* ## `.strict()` at the top level, and here that is forced rather than chosen
|
|
27
|
+
*
|
|
28
|
+
* The shapes exchanged with the data plane tolerate an unknown field, because
|
|
29
|
+
* refusing a producer one minor version ahead is a worse failure than ignoring
|
|
30
|
+
* its addition (`version.ts`). A SIGNED document inverts that: the signature is
|
|
31
|
+
* over the canonical bytes of the manifest, so a field silently stripped at this
|
|
32
|
+
* parse is a field missing from the bytes Oxy re-canonicalizes, and verification
|
|
33
|
+
* fails. A tolerant parse would therefore report "the signature is invalid" for
|
|
34
|
+
* what is really "this build does not understand this manifest" — the wrong
|
|
35
|
+
* diagnosis of the right problem. Strict says the true thing, and the cost is
|
|
36
|
+
* bounded: ingestion is a release-time operation an operator retries once Oxy
|
|
37
|
+
* takes the newer contract, not a served request that becomes unsettleable.
|
|
38
|
+
*
|
|
39
|
+
* ## What is deliberately NOT here
|
|
40
|
+
*
|
|
41
|
+
* **No HTTP write path.** The catalogue's emptiness is currently a safety
|
|
42
|
+
* property — `scripts/seed-inference-catalogue.ts` refuses to invent a licence
|
|
43
|
+
* or a retention flag because "a plausible invented value in a catalogue is
|
|
44
|
+
* worse than an absent one" — and a staff write path into it with nothing to
|
|
45
|
+
* ingest is an unexercised hazard. The schema lands; the endpoint waits for a
|
|
46
|
+
* real manifest to ingest.
|
|
47
|
+
*
|
|
48
|
+
* **No `payloadDigest` field.** The signature is over the canonical
|
|
49
|
+
* serialization of this manifest with `signatures` removed, and a verifier
|
|
50
|
+
* recomputes it. Storing the digest beside the document it digests would be a
|
|
51
|
+
* second source of truth for one fact, and a verifier that compared the
|
|
52
|
+
* signature against the DECLARED digest rather than the recomputed one would
|
|
53
|
+
* verify nothing at all.
|
|
54
|
+
*
|
|
55
|
+
* **No verification RESULT.** Whether a signature checked out is Oxy's finding
|
|
56
|
+
* about the document, not a claim the document makes about itself; a `verified`
|
|
57
|
+
* field inside a signed manifest is the signer asserting its own signature.
|
|
58
|
+
*
|
|
59
|
+
* ## The open owner decision this shape does not take
|
|
60
|
+
*
|
|
61
|
+
* **What signs, and what verifies, is not decided.** Oxy holds no Alia signing
|
|
62
|
+
* key, and whether to resolve `keyId` through the existing attestation machinery
|
|
63
|
+
* (`services/oxyVerificationResolver.ts`, the civic attestation code) or to
|
|
64
|
+
* introduce a dedicated Alia release key is a real choice with different
|
|
65
|
+
* custody, rotation and revocation consequences. So `keyId` is an OPAQUE
|
|
66
|
+
* identifier and this file names no registry that resolves it: either answer
|
|
67
|
+
* fits, and neither is presupposed. Until it is answered a manifest can be
|
|
68
|
+
* parsed and cannot be verified, which is the second reason no endpoint ships.
|
|
69
|
+
*
|
|
70
|
+
* Decided in: docs/adr/0008-catalogue-concept-separation.md,
|
|
71
|
+
* docs/adr/0017-authorized-routes-in-the-envelope.md, issue #972 §12.
|
|
72
|
+
*/
|
|
73
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
+
exports.aliaModelReleaseManifestSchema = exports.aliaReleaseSignatureSchema = exports.aliaReleaseArtifactSchema = void 0;
|
|
75
|
+
const zod_1 = require("zod");
|
|
76
|
+
const catalogue_1 = require("./catalogue");
|
|
77
|
+
const identifiers_1 = require("./identifiers");
|
|
78
|
+
/**
|
|
79
|
+
* One artifact of a release, by path and digest.
|
|
80
|
+
*
|
|
81
|
+
* `sizeBytes` is required beside the digest so a verifier can refuse a stream
|
|
82
|
+
* that is the wrong length before reading it to the end, rather than only after.
|
|
83
|
+
*/
|
|
84
|
+
exports.aliaReleaseArtifactSchema = zod_1.z
|
|
85
|
+
.object({
|
|
86
|
+
/** Path within the release, e.g. `model-00001-of-00004.safetensors`. */
|
|
87
|
+
path: zod_1.z.string().min(1).max(512),
|
|
88
|
+
digest: identifiers_1.sha256DigestSchema,
|
|
89
|
+
sizeBytes: zod_1.z.number().int().positive().safe(),
|
|
90
|
+
mediaType: zod_1.z.string().min(1).max(255).optional(),
|
|
91
|
+
})
|
|
92
|
+
.strict();
|
|
93
|
+
/**
|
|
94
|
+
* One detached signature over the manifest.
|
|
95
|
+
*
|
|
96
|
+
* `algorithm` is a CLOSED enum with one member, and both halves of that are
|
|
97
|
+
* deliberate. Closed, because a verifier that trusts a document's own algorithm
|
|
98
|
+
* name accepts whatever that document nominates, `none` included. One member,
|
|
99
|
+
* because Ed25519 is the scheme ADR 0012 already chose for asymmetric
|
|
100
|
+
* verification on this platform, and naming a scheme nothing here can check
|
|
101
|
+
* would be advertising a capability that does not exist. A second member lands
|
|
102
|
+
* when a verifier for it does — which is a closed enum gaining a member, and
|
|
103
|
+
* therefore a MINOR contract-set change the handshake surfaces (`version.ts`).
|
|
104
|
+
*
|
|
105
|
+
* `keyId` is opaque on purpose: see the header. It identifies the public key
|
|
106
|
+
* without saying what resolves it.
|
|
107
|
+
*
|
|
108
|
+
* The signature covers the canonical serialization (RFC 8785 JCS) of the
|
|
109
|
+
* manifest with `signatures` removed. The canonicalization is NAMED rather than
|
|
110
|
+
* left implicit because a digest over "the manifest" is not verifiable by two
|
|
111
|
+
* implementations that serialize JSON differently; naming it is a mechanical
|
|
112
|
+
* necessity and is independent of the open question of which key signs.
|
|
113
|
+
*/
|
|
114
|
+
exports.aliaReleaseSignatureSchema = zod_1.z
|
|
115
|
+
.object({
|
|
116
|
+
algorithm: zod_1.z.enum(['ed25519']),
|
|
117
|
+
canonicalization: zod_1.z.enum(['jcs']),
|
|
118
|
+
/** Opaque identifier of the public key. Resolving it is undecided. */
|
|
119
|
+
keyId: zod_1.z.string().min(1).max(256),
|
|
120
|
+
/**
|
|
121
|
+
* Unpadded base64url. Exactly 86 characters, which is a 64-byte Ed25519
|
|
122
|
+
* signature — the one algorithm above. A second algorithm moves this length
|
|
123
|
+
* into a refinement keyed on `algorithm`.
|
|
124
|
+
*/
|
|
125
|
+
signature: zod_1.z
|
|
126
|
+
.string()
|
|
127
|
+
.regex(/^[A-Za-z0-9_-]{86}$/, 'signature must be a 64-byte ed25519 signature in unpadded base64url'),
|
|
128
|
+
signedAt: identifiers_1.inferenceTimestampSchema,
|
|
129
|
+
})
|
|
130
|
+
.strict();
|
|
131
|
+
/**
|
|
132
|
+
* A signed release of an `alia/*` model revision.
|
|
133
|
+
*
|
|
134
|
+
* `signatures` is a LIST rather than one signature, because "what signs" is
|
|
135
|
+
* undecided: a single field would presuppose one signer, while a list lets an
|
|
136
|
+
* Alia release key and an existing attestation co-sign the same document without
|
|
137
|
+
* either being retrofitted later.
|
|
138
|
+
*/
|
|
139
|
+
exports.aliaModelReleaseManifestSchema = zod_1.z
|
|
140
|
+
.object({
|
|
141
|
+
/** See `version.ts`: an ingestion payload is a whole message on the wire. */
|
|
142
|
+
schemaVersion: zod_1.z.literal(1),
|
|
143
|
+
/** The release's own identity, so ingestion is idempotent on it. */
|
|
144
|
+
releaseId: zod_1.z.string().min(1).max(128),
|
|
145
|
+
issuedAt: identifiers_1.inferenceTimestampSchema,
|
|
146
|
+
/**
|
|
147
|
+
* The revision being released. Carries its OWN `schemaVersion`, like
|
|
148
|
+
* `billingProfileSchema` inside `accountBillingStateSchema`: the manifest's
|
|
149
|
+
* version governs the manifest and the revision's governs the revision,
|
|
150
|
+
* which is two versions of two things rather than two versions of one.
|
|
151
|
+
*/
|
|
152
|
+
revision: catalogue_1.modelRevisionSchema,
|
|
153
|
+
/** On the MODEL rather than the revision in the catalogue, so carried here. */
|
|
154
|
+
provenance: catalogue_1.modelProvenanceSchema,
|
|
155
|
+
license: catalogue_1.modelLicenseSchema,
|
|
156
|
+
artifacts: zod_1.z.array(exports.aliaReleaseArtifactSchema).min(1),
|
|
157
|
+
signatures: zod_1.z.array(exports.aliaReleaseSignatureSchema).min(1),
|
|
158
|
+
})
|
|
159
|
+
.strict()
|
|
160
|
+
.superRefine((manifest, ctx) => {
|
|
161
|
+
// The same rule `catalogueModelSchema` enforces on a model, applied to the
|
|
162
|
+
// carrier that creates one: `alia/*` names models Alia actually owns or
|
|
163
|
+
// derived, and a manifest is the document that would launder somebody else's
|
|
164
|
+
// weights into the namespace.
|
|
165
|
+
const publisher = manifest.revision.modelId.slice(0, manifest.revision.modelId.indexOf('/'));
|
|
166
|
+
if (publisher !== identifiers_1.RESERVED_ALIA_PUBLISHER) {
|
|
167
|
+
ctx.addIssue({
|
|
168
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
169
|
+
path: ['revision', 'modelId'],
|
|
170
|
+
message: `an Alia release manifest releases a ${identifiers_1.RESERVED_ALIA_PUBLISHER}/* model`,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (manifest.provenance.releaseKind !== 'first_party_original' &&
|
|
174
|
+
manifest.provenance.releaseKind !== 'first_party_derived') {
|
|
175
|
+
ctx.addIssue({
|
|
176
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
177
|
+
path: ['provenance', 'releaseKind'],
|
|
178
|
+
message: 'an Alia release manifest describes a first-party release',
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
// A derived model's base is the licence-attribution trail. Recording the
|
|
182
|
+
// derivation without naming what it derives from loses exactly the fact
|
|
183
|
+
// attribution needs.
|
|
184
|
+
if (manifest.provenance.releaseKind === 'first_party_derived' &&
|
|
185
|
+
manifest.provenance.baseModelId === undefined) {
|
|
186
|
+
ctx.addIssue({
|
|
187
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
188
|
+
path: ['provenance', 'baseModelId'],
|
|
189
|
+
message: 'a derived release names the model it derives from',
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
// The four fields a third-party catalogue entry may omit and a first-party
|
|
193
|
+
// release may not. See the header.
|
|
194
|
+
if (manifest.revision.modelCardUrl === undefined) {
|
|
195
|
+
ctx.addIssue({
|
|
196
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
197
|
+
path: ['revision', 'modelCardUrl'],
|
|
198
|
+
message: 'a first-party release publishes a model card',
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (manifest.revision.safety === undefined) {
|
|
202
|
+
ctx.addIssue({
|
|
203
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
204
|
+
path: ['revision', 'safety'],
|
|
205
|
+
message: 'a first-party release publishes its safety metadata',
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if (manifest.revision.evaluations.length === 0) {
|
|
209
|
+
ctx.addIssue({
|
|
210
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
211
|
+
path: ['revision', 'evaluations'],
|
|
212
|
+
message: 'a first-party release publishes at least one evaluation result',
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// The digest the catalogue will serve has to be one of the digests this
|
|
216
|
+
// manifest signed. Otherwise the signature covers a set of artifacts that
|
|
217
|
+
// does not include the weights anybody runs.
|
|
218
|
+
if (manifest.revision.artifactDigest === undefined) {
|
|
219
|
+
ctx.addIssue({
|
|
220
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
221
|
+
path: ['revision', 'artifactDigest'],
|
|
222
|
+
message: 'a first-party release names the digest of the artifact it serves',
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
else if (!manifest.artifacts.some((artifact) => artifact.digest === manifest.revision.artifactDigest)) {
|
|
226
|
+
ctx.addIssue({
|
|
227
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
228
|
+
path: ['revision', 'artifactDigest'],
|
|
229
|
+
message: 'the served artifact digest must appear among the signed artifacts',
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
const paths = manifest.artifacts.map((artifact) => artifact.path);
|
|
233
|
+
if (new Set(paths).size !== paths.length) {
|
|
234
|
+
ctx.addIssue({
|
|
235
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
236
|
+
path: ['artifacts'],
|
|
237
|
+
message: 'each artifact path appears once in a release',
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
// Two signatures from one key are one signature written twice, and a
|
|
241
|
+
// duplicate would make a "two independent signers" check pass on one signer.
|
|
242
|
+
const keyIds = manifest.signatures.map((signature) => signature.keyId);
|
|
243
|
+
if (new Set(keyIds).size !== keyIds.length) {
|
|
244
|
+
ctx.addIssue({
|
|
245
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
246
|
+
path: ['signatures'],
|
|
247
|
+
message: 'each signing key signs a manifest once',
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
});
|
|
@@ -282,10 +282,7 @@ exports.modelRevisionSchema = zod_1.z
|
|
|
282
282
|
releasedAt: identifiers_1.inferenceTimestampSchema,
|
|
283
283
|
retiredAt: identifiers_1.inferenceTimestampSchema.optional(),
|
|
284
284
|
/** Digest of the served artifact, where Oxy hosts the weights itself. */
|
|
285
|
-
artifactDigest:
|
|
286
|
-
.string()
|
|
287
|
-
.regex(/^sha256:[a-f0-9]{64}$/, 'artifact digest must be sha256:<64 lowercase hex>')
|
|
288
|
-
.optional(),
|
|
285
|
+
artifactDigest: identifiers_1.sha256DigestSchema.optional(),
|
|
289
286
|
modelCardUrl: identifiers_1.inferenceHttpsUrlSchema.optional(),
|
|
290
287
|
evaluations: zod_1.z.array(exports.modelEvaluationResultSchema).default([]),
|
|
291
288
|
safety: exports.modelSafetyMetadataSchema.optional(),
|
|
@@ -41,6 +41,11 @@ const identifiers_1 = require("./identifiers");
|
|
|
41
41
|
* PLATFORM's own credential fails every identical retry until an operator
|
|
42
42
|
* rotates a key, so classifying it as `provider_error` would send every client
|
|
43
43
|
* into a retry loop against a request that cannot succeed.
|
|
44
|
+
*
|
|
45
|
+
* `provider_billing_refused` is in that group for the same reason and was found
|
|
46
|
+
* the same way — an upstream declining to bill OXY (Anthropic answers 402) has
|
|
47
|
+
* to be distinguishable from the customer's own balance running out, or the
|
|
48
|
+
* error tells them to go and top up an account that is not the one at fault.
|
|
44
49
|
*/
|
|
45
50
|
exports.INFERENCE_ERROR_CODES = [
|
|
46
51
|
'invalid_request',
|
|
@@ -68,6 +73,7 @@ exports.INFERENCE_ERROR_CODES = [
|
|
|
68
73
|
'provider_timeout',
|
|
69
74
|
'provider_overloaded',
|
|
70
75
|
'provider_credential_invalid',
|
|
76
|
+
'provider_billing_refused',
|
|
71
77
|
'service_unavailable',
|
|
72
78
|
'internal_error',
|
|
73
79
|
];
|
|
@@ -87,6 +93,12 @@ exports.inferenceErrorCodeSchema = zod_1.z.enum(exports.INFERENCE_ERROR_CODES);
|
|
|
87
93
|
* one because only the first names an action the customer can take. Both are
|
|
88
94
|
* non-retryable for the same reason: a credential an upstream has refused keeps
|
|
89
95
|
* being refused until somebody replaces it.
|
|
96
|
+
*
|
|
97
|
+
* `quota_exceeded` and `provider_billing_refused` divide along the same line:
|
|
98
|
+
* both are money, but one is the CUSTOMER's ceiling and the other is Oxy's
|
|
99
|
+
* account with an upstream. Reporting the second as the first is retryability-
|
|
100
|
+
* correct and diagnostically wrong, which is the worst combination — it reads
|
|
101
|
+
* as actionable and the action does nothing.
|
|
90
102
|
*/
|
|
91
103
|
exports.NON_RETRYABLE_INFERENCE_ERROR_CODES = [
|
|
92
104
|
'invalid_request',
|
|
@@ -109,27 +121,114 @@ exports.NON_RETRYABLE_INFERENCE_ERROR_CODES = [
|
|
|
109
121
|
'upstream_content_filtered',
|
|
110
122
|
'cancelled',
|
|
111
123
|
'provider_credential_invalid',
|
|
124
|
+
'provider_billing_refused',
|
|
112
125
|
];
|
|
113
126
|
const NON_RETRYABLE_CODE_SET = new Set(exports.NON_RETRYABLE_INFERENCE_ERROR_CODES);
|
|
127
|
+
/* -------------------------------------------------------------------------- */
|
|
128
|
+
/* Credential-shaped text */
|
|
129
|
+
/* -------------------------------------------------------------------------- */
|
|
130
|
+
/**
|
|
131
|
+
* A run of characters long enough and opaque enough to BE a credential.
|
|
132
|
+
*
|
|
133
|
+
* The alphabet every bearer token, API key and base64/base64url secret is
|
|
134
|
+
* written in. The LENGTH floors below are what keep this from being an entropy
|
|
135
|
+
* heuristic: nothing here fires on a short word, so `authorization: none` and
|
|
136
|
+
* `api_key=***` read as what they are.
|
|
137
|
+
*/
|
|
138
|
+
const OPAQUE_ALPHABET = '[A-Za-z0-9][A-Za-z0-9._~+/=-]';
|
|
114
139
|
/**
|
|
115
|
-
*
|
|
140
|
+
* Words a producer substitutes FOR a credential.
|
|
116
141
|
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
142
|
+
* Excluded at the value position so a message whose secret has already been
|
|
143
|
+
* replaced is accepted. That acceptance is deliberate and is half the fix for
|
|
144
|
+
* issue #1027: the previous pattern refused `Authorization: [redacted]` — a
|
|
145
|
+
* correctly redacted string — which is precisely what pushed a producer into
|
|
146
|
+
* redacting the MARKER instead, and a marker-redacted string carries the secret
|
|
147
|
+
* and passes.
|
|
121
148
|
*/
|
|
122
|
-
const
|
|
149
|
+
const PLACEHOLDER_WORDS = 'redacted|removed|hidden|masked|scrubbed|elided|omitted|filtered|sanitized|sanitised|none|null|undefined|empty';
|
|
150
|
+
/** A value position whose contents are a placeholder rather than a secret. */
|
|
151
|
+
const NOT_A_PLACEHOLDER = `(?!(?:${PLACEHOLDER_WORDS})\\b)`;
|
|
123
152
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
153
|
+
* Header and parameter names that carry a credential, as any provider spells
|
|
154
|
+
* them.
|
|
155
|
+
*
|
|
156
|
+
* The prefix group is the whole point of the rewrite: `authorization` and
|
|
157
|
+
* `api_key` were matched literally, so `x-api-key`, `anthropic-api-key`,
|
|
158
|
+
* `x-goog-api-key` and `proxy-authorization` — the spellings an upstream
|
|
159
|
+
* actually echoes — went unrecognised.
|
|
160
|
+
*/
|
|
161
|
+
const CREDENTIAL_NAME = '(?:[a-z0-9]{1,20}[-_]){0,3}(?:api[-_]?(?:key|token|secret)|authorization|auth[-_]?(?:token|key)?|access[-_]?token|id[-_]?token|refresh[-_]?token|bearer[-_]?token|secret[-_]?key|private[-_]?key|client[-_]?secret|session[-_]?(?:id|key|token)|passwords?|passwd|cookie|credentials?|tokens?|secrets?)';
|
|
162
|
+
/** An auth scheme sitting between the marker and the value. */
|
|
163
|
+
const AUTH_SCHEME = '(?:(?:bearer|basic|token|apikey|digest)\\s+)?';
|
|
164
|
+
/**
|
|
165
|
+
* The four ways a credential is recognisable in free text.
|
|
166
|
+
*
|
|
167
|
+
* Each is checked independently, so removing one signal does not clear the
|
|
168
|
+
* string — which is the failure #1027 reported. All four are load-bearing:
|
|
169
|
+
* `inference.errors.test.ts` has a case that only one of them catches, and
|
|
170
|
+
* deleting any one entry turns a test red.
|
|
171
|
+
*/
|
|
172
|
+
const CREDENTIAL_PATTERNS = [
|
|
173
|
+
// 1. A credential-bearing name ASSIGNED a value that is long enough to be a
|
|
174
|
+
// credential. The value is anchored to the separator so a placeholder at
|
|
175
|
+
// that position ends the match rather than being skipped over.
|
|
176
|
+
new RegExp(`(?:^|[^a-z0-9])${CREDENTIAL_NAME}["']?\\s*[:=]\\s*["']?${AUTH_SCHEME}${NOT_A_PLACEHOLDER}${OPAQUE_ALPHABET}{7,}`, 'i'),
|
|
177
|
+
// 2. A bearer token with no marker in front of it, which is how an upstream
|
|
178
|
+
// quotes the header value alone.
|
|
179
|
+
new RegExp(`\\bbearer\\s+${NOT_A_PLACEHOLDER}${OPAQUE_ALPHABET}{7,}`, 'i'),
|
|
180
|
+
// 3. Token grammars that ARE credentials wherever they appear, marker or not.
|
|
181
|
+
// This is the layer that survives a producer stripping the marker, and it
|
|
182
|
+
// is a closed list of issued shapes rather than an entropy score, so a
|
|
183
|
+
// request id or a base64 image fragment is unaffected.
|
|
184
|
+
//
|
|
185
|
+
// Case-SENSITIVE on purpose: `AKIA`, `AIza` and `gh[pousr]_` are issued in
|
|
186
|
+
// exactly that case, and matching them case-insensitively would start
|
|
187
|
+
// firing on ordinary words.
|
|
188
|
+
/\b(?:sk-[A-Za-z0-9_-]{8,}|[sprk]k_(?:live|test)_[A-Za-z0-9]{8,}|AKIA[0-9A-Z]{12,}|ASIA[0-9A-Z]{12,}|AIza[0-9A-Za-z_-]{20,}|gh[pousr]_[A-Za-z0-9]{16,}|github_pat_[A-Za-z0-9_]{20,}|xox[abeprs]-[A-Za-z0-9-]{10,}|glpat-[A-Za-z0-9_-]{16,}|npm_[A-Za-z0-9]{20,}|eyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{4,})/,
|
|
189
|
+
// 4. A redaction placeholder standing NEXT TO a surviving opaque value — the
|
|
190
|
+
// exact residue of the span redaction in #1027 (`{x-[redacted] <key>}`).
|
|
191
|
+
// A correct redaction puts the placeholder WHERE the value was, so the two
|
|
192
|
+
// never appear side by side; a marker-span redaction leaves them adjacent.
|
|
193
|
+
// Both signals are required, which is what keeps an ordinary redacted
|
|
194
|
+
// message from being refused.
|
|
195
|
+
new RegExp(`(?:[[<({]\\s*(?:${PLACEHOLDER_WORDS})[^\\])}>]{0,16}[\\])}>]|\\*{3,})[^A-Za-z0-9]{0,4}${OPAQUE_ALPHABET}{11,}`, 'i'),
|
|
196
|
+
];
|
|
197
|
+
/**
|
|
198
|
+
* Free text that is safe to hand a customer: bounded, and refused if it still
|
|
199
|
+
* looks like it carries a credential. Applied to BOTH the Oxy message and the
|
|
126
200
|
* upstream one — a leak is no less a leak for having been written by a provider.
|
|
201
|
+
*
|
|
202
|
+
* ## This is a last-resort REFUSAL, not protection
|
|
203
|
+
*
|
|
204
|
+
* A pattern over the OUTPUT cannot be the control that keeps a credential out of
|
|
205
|
+
* an error, and a producer that treats it as one has the hole #1027 reported.
|
|
206
|
+
* The only reliable control is redacting the KNOWN SECRET VALUE at the point
|
|
207
|
+
* where the producer still holds the bytes it sent — which is an adapter's job
|
|
208
|
+
* and is available to nobody else. This refinement exists to catch what that
|
|
209
|
+
* control missed, and nothing here is a licence to skip it.
|
|
210
|
+
*
|
|
211
|
+
* Two rules follow, and they are the whole reason this text is longer than the
|
|
212
|
+
* pattern it describes:
|
|
213
|
+
*
|
|
214
|
+
* - **Never redact by replacing the span this pattern matched.** The span is
|
|
215
|
+
* the MARKER; the secret is what follows it. OxyHQ/Relay#3 measured the
|
|
216
|
+
* result: `{x-api-key: <key>}` is refused, `{x-[redacted] <key>}` was
|
|
217
|
+
* accepted, and both carry the key. Redaction made the leak worse by
|
|
218
|
+
* converting "this string is dangerous" into "this string is fine".
|
|
219
|
+
* - **This package deliberately ships no redaction helper.** One keyed on these
|
|
220
|
+
* patterns would rebuild the same defect one layer up, and one that took the
|
|
221
|
+
* secret as an argument would only restate what the producer already has.
|
|
222
|
+
*
|
|
223
|
+
* What it still cannot see, stated so nobody relies on it: a credential with no
|
|
224
|
+
* marker, no issued-token prefix and no placeholder beside it is bytes that look
|
|
225
|
+
* like a request id, and refusing those means refusing request ids.
|
|
127
226
|
*/
|
|
128
227
|
exports.safeErrorTextSchema = zod_1.z
|
|
129
228
|
.string()
|
|
130
229
|
.min(1)
|
|
131
230
|
.max(2000)
|
|
132
|
-
.refine((value) => !
|
|
231
|
+
.refine((value) => !CREDENTIAL_PATTERNS.some((pattern) => pattern.test(value)), 'error text must not contain credential-shaped material');
|
|
133
232
|
/**
|
|
134
233
|
* A coarse classification of an upstream failure (ADR 0010's `upstreamCategory`).
|
|
135
234
|
*
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* Decided in: docs/adr/0007-canonical-request-attribution.md, docs/adr/0008-catalogue-concept-separation.md.
|
|
20
20
|
*/
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
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 = void 0;
|
|
22
|
+
exports.RESERVED_ALIA_PUBLISHER = exports.inferenceRegionSchema = exports.deploymentIdSchema = exports.inferenceProviderSlugSchema = 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
23
|
const zod_1 = require("zod");
|
|
24
24
|
/* -------------------------------------------------------------------------- */
|
|
25
25
|
/* Principal identifiers */
|
|
@@ -62,8 +62,16 @@ exports.oxyCredentialIdSchema = zod_1.z.string().min(1).max(64);
|
|
|
62
62
|
* traceable as one that was served (ADR 0007, and step 1 of ADR 0010's edge
|
|
63
63
|
* order). It is required on the inbound envelope, which is what makes the data
|
|
64
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
|
|
66
|
-
* about later.
|
|
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.
|
|
67
75
|
*
|
|
68
76
|
* Correlates the Oxy edge, the data plane, the financial ledger and the
|
|
69
77
|
* customer-visible receipt, so it appears on every stream event and every
|
|
@@ -109,6 +117,18 @@ exports.inferenceHttpsUrlSchema = zod_1.z
|
|
|
109
117
|
.string()
|
|
110
118
|
.max(2048)
|
|
111
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>');
|
|
112
132
|
/* -------------------------------------------------------------------------- */
|
|
113
133
|
/* Catalogue references */
|
|
114
134
|
/* -------------------------------------------------------------------------- */
|