@mux/ai 0.68.0-canary.112 → 0.68.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/{index-DrQLwBMP.d.ts → index-CxDX1bX1.d.ts} +37 -15
- package/dist/{index-BP2WF8De.d.ts → index-DbEwilAW.d.ts} +1 -1
- package/dist/index.d.ts +12 -8
- package/dist/index.js +4091 -4020
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -2
- package/dist/primitives/index.js +5 -4
- package/dist/primitives/index.js.map +1 -1
- package/dist/{transcripts-DVMW9ZSs.d.ts → transcripts-Cs-n8X_l.d.ts} +20 -19
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +48 -8
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -282,21 +282,6 @@ interface TokenUsage {
|
|
|
282
282
|
metadata?: UsageMetadata;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
/**
|
|
286
|
-
* What a legacy error carries across a Workflow step boundary: the pre-classification
|
|
287
|
-
* shape, so it revives with its end-user message.
|
|
288
|
-
*/
|
|
289
|
-
interface LegacySerializedMuxAiError {
|
|
290
|
-
message: string;
|
|
291
|
-
publicType: MuxAiErrorType;
|
|
292
|
-
retryable: boolean;
|
|
293
|
-
stack?: string;
|
|
294
|
-
usage?: TokenUsage;
|
|
295
|
-
finishReason?: string;
|
|
296
|
-
rawFinishReason?: string;
|
|
297
|
-
diagnostics?: ModelCallDiagnostics;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
285
|
/**
|
|
301
286
|
* Public error categories for job outcomes. One list for the SDK and its consumers,
|
|
302
287
|
* which may extend it with their own types (e.g. request-time HTTP errors). Treat
|
|
@@ -478,14 +463,15 @@ declare const MUX_AI_ERROR_CODES: {
|
|
|
478
463
|
/**
|
|
479
464
|
* The provider says the account the service running the SDK uses is out of credits or
|
|
480
465
|
* quota, or hit a spend or usage limit. Retrying won't help until someone changes the
|
|
481
|
-
* account. The site names the dependency. Facts: `call`, `status`, `providerCode
|
|
466
|
+
* account. The site names the dependency. Facts: `call`, `status`, and `providerCode`
|
|
467
|
+
* when the provider gave one.
|
|
482
468
|
*/
|
|
483
469
|
readonly PROVIDER_QUOTA_EXHAUSTED: "provider_quota_exhausted";
|
|
484
|
-
/** The provider rejected the key the service running the SDK uses, or the key lacks permission for this model or feature. The site names the dependency. Facts: `call`, `status`, `providerCode
|
|
470
|
+
/** The provider rejected the key the service running the SDK uses, or the key lacks permission for this model or feature. The site names the dependency. Facts: `call`, `status`, and `providerCode` when the provider gave one. */
|
|
485
471
|
readonly PROVIDER_CREDENTIALS_REJECTED: "provider_credentials_rejected";
|
|
486
|
-
/** The provider says requests are over its rate or concurrency limit. The site names the dependency. Facts: `call`, `status`, `providerCode
|
|
472
|
+
/** The provider says requests are over its rate or concurrency limit. The site names the dependency. Facts: `call`, `status`, and `providerCode` when the provider gave one. */
|
|
487
473
|
readonly PROVIDER_RATE_LIMITED: "provider_rate_limited";
|
|
488
|
-
/** The provider says it's overloaded or down for maintenance. The site names the dependency. Facts: `call`, `status`, `providerCode
|
|
474
|
+
/** The provider says it's overloaded or down for maintenance. The site names the dependency. Facts: `call`, `status`, and `providerCode` when the provider gave one. */
|
|
489
475
|
readonly PROVIDER_UNAVAILABLE: "provider_unavailable";
|
|
490
476
|
/** The provider can't process the asset's audio. The site names the dependency. Facts: `call`, `status`, `providerCode`, `reason` (`corrupt`, `unsupported_format`, `too_long`, `too_short`). */
|
|
491
477
|
readonly AUDIO_UNPROCESSABLE: "audio_unprocessable";
|
|
@@ -1030,6 +1016,21 @@ declare function internalError(message: string, facts?: MuxAiErrorFacts, cause?:
|
|
|
1030
1016
|
/** Exhaustiveness guard for switch statements over closed unions. */
|
|
1031
1017
|
declare function assertNever(value: never, what?: string): never;
|
|
1032
1018
|
|
|
1019
|
+
/**
|
|
1020
|
+
* What a legacy error carries across a Workflow step boundary: the pre-classification
|
|
1021
|
+
* shape, so it revives with its end-user message.
|
|
1022
|
+
*/
|
|
1023
|
+
interface LegacySerializedMuxAiError {
|
|
1024
|
+
message: string;
|
|
1025
|
+
publicType: MuxAiErrorType;
|
|
1026
|
+
retryable: boolean;
|
|
1027
|
+
stack?: string;
|
|
1028
|
+
usage?: TokenUsage;
|
|
1029
|
+
finishReason?: string;
|
|
1030
|
+
rawFinishReason?: string;
|
|
1031
|
+
diagnostics?: ModelCallDiagnostics;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1033
1034
|
interface Hotspot {
|
|
1034
1035
|
/** Inclusive start time in milliseconds */
|
|
1035
1036
|
startMs: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { U as ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH, V as ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH, W as ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL, X as ASK_QUESTIONS_MAX_QUESTION_LENGTH, Y as AskQuestionsOptions, Z as AskQuestionsResult, _ as AskQuestionsType, $ as AudioTranslationOptions, a0 as AudioTranslationResult, a1 as AutoCensorProfanityOptions, a2 as BurnedInCaptionsAnalysis, a3 as BurnedInCaptionsOptions, a4 as BurnedInCaptionsPromptOverrides, a5 as BurnedInCaptionsPromptSections, a6 as BurnedInCaptionsResult, a7 as CaptionReplacement, a8 as CensorMode, a9 as Chapter, aa as ChapterSystemPromptSections, ab as ChaptersOptions, ac as ChaptersPromptOverrides, ad as ChaptersPromptSections, ae as ChaptersResult, af as ChaptersType, ag as DEFAULT_TRANSCRIPT_WINDOWING, ah as DubbedCaptionsOutcome, ai as EditCaptionsOptions, aj as EditCaptionsResult, ak as EmbeddingsOptions, al as EmbeddingsResult, am as EngagementInsightsOptions, an as EngagementInsightsResult, ao as GENERATE_TEXT_CALLS_TO_ACTION, ap as GENERATE_TEXT_CHANNELS, aq as GENERATE_TEXT_CHANNEL_CEILINGS, ar as GENERATE_TEXT_FORMATS, as as GENERATE_TEXT_LENGTH_BOUNDS, at as GENERATE_TEXT_MAX_ARTIFACTS, au as GENERATE_TEXT_MAX_AUDIENCE_CHARS, av as GENERATE_TEXT_MAX_BRAND_TERMS, aw as GENERATE_TEXT_MAX_BRAND_TERMS_TOTAL_CHARS, ax as GENERATE_TEXT_MAX_BRAND_TERM_CHARS, ay as GENERATE_TEXT_MAX_CONCURRENT_GENERATIONS, az as GENERATE_TEXT_MAX_INSTRUCTIONS_CHARS, aA as GENERATE_TEXT_MAX_SHOT_FRAMES, aB as GENERATE_TEXT_MAX_VARIANTS, aC as GENERATE_TEXT_VOICES, aD as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, aE as GenerateTextArtifact, aF as GenerateTextCallToAction, aG as GenerateTextChannel, aH as GenerateTextFormat, aI as GenerateTextKeyedItem, aJ as GenerateTextLengthLimit, aK as GenerateTextOptions, aL as GenerateTextResult, aM as GenerateTextVariant, aN as GenerateTextVoice, aO as GeneratedTextArtifact, aP as GeneratedTextVariant, aQ as HIVE_SEXUAL_CATEGORIES, aR as HIVE_VIOLENCE_CATEGORIES, aS as HiveModerationOutput, aT as HiveModerationSource, aU as ModerationOptions, aV as ModerationProvider, aW as ModerationResult, aX as ModerationSurfaceStatus, aY as MomentInsight, aZ as OverallInsight, a_ as ProfanityDetectionPayload, a$ as Question, b0 as QuestionAnswer, b1 as QuestionAnswerType, b2 as RepairAttempt, b3 as RepairCall, b4 as RepairFailureOutcome, b5 as RepairOptions, b6 as RepairPlan, b7 as RepairRejectionCode, b8 as RepairResult, b9 as RepairSpan, ba as ReplacementRecord, bb as SpeakerReplacement, bc as StaticRenditionCleanupOutcome, bd as SummarizationOptions, be as SummarizationPromptOverrides, bf as SummarizationPromptSections, bg as SummaryAndTagsResult, bh as SummaryType, bi as TextLengthLimit, bj as TextRepairModelOptions, bk as ThumbnailModerationScore, bl as ThumbnailModerationSkipReason, bm as ThumbnailModerationStatus, bn as TranscriptModerationScore, bo as TranscriptModerationSkipReason, bp as TranscriptModerationStatus, bq as TranslationChunkingOptions, br as TranslationOptions, bs as TranslationPayload, bt as TranslationResult, bu as aggregateTokenUsage, bv as applyOverrideLists, bw as applyReplacements, bx as applySpeakerReplacements, by as applyTextRepair, bz as askQuestions, bA as buildReplacementRegex, bB as buildTranscriptWindows, bC as burnedInCaptionsSchema, bD as censorVttContent, bE as chapterSchema, bF as chaptersSchema, bG as createReplacer, bH as createTextRepairGenerator, bI as editCaptions, bJ as extractTranscriptSegmentsForHotspots, bK as findGenerateTextLengthViolation, bL as generateChapters, bM as generateEmbeddings, bN as generateEngagementInsights, bO as generateText, bP as generateVideoEmbeddings, bQ as getModerationScores, bR as getSummaryAndTags, bS as hasBurnedInCaptions, bT as mapShotsToHotspots, bU as measureGenerateTextLength, bV as normalizeTranslatedVtt, bW as planTextRepair, bX as profanityDetectionSchema, bY as questionAnswerSchema, bZ as repairJsonSchema, b_ as repairText, b$ as resolveGenerateTextLengthLimit, c0 as resolveGenerateTextLengthLimits, c1 as resolveGenerateTextOptions, c2 as runTextRepairLoop, c3 as selectGenerateTextShotFrames, c4 as shouldSplitChunkTranslationError, c5 as summarySchema, c6 as transformCueText, c7 as translateAudio, c8 as translateCaptions, c9 as translationSchema, ca as validateNeverTranslateTerms, cb as verifyNeverTranslateTerms } from '../index-CxDX1bX1.js';
|
|
2
2
|
export { D as DEFAULT_DESCRIPTION_LENGTH, a as DEFAULT_SUMMARY_KEYWORD_LIMIT, b as DEFAULT_TITLE_LENGTH } from '../summarization-BFmhXeAu.js';
|
|
3
3
|
import 'ai';
|
|
4
|
-
import '../transcripts-
|
|
4
|
+
import '../transcripts-Cs-n8X_l.js';
|
|
5
5
|
import '@workflow/serde';
|
|
6
6
|
import '@mux/ts';
|
|
7
7
|
import 'zod';
|
package/dist/workflows/index.js
CHANGED
|
@@ -643,14 +643,15 @@ var MUX_AI_ERROR_CODES = {
|
|
|
643
643
|
/**
|
|
644
644
|
* The provider says the account the service running the SDK uses is out of credits or
|
|
645
645
|
* quota, or hit a spend or usage limit. Retrying won't help until someone changes the
|
|
646
|
-
* account. The site names the dependency. Facts: `call`, `status`, `providerCode
|
|
646
|
+
* account. The site names the dependency. Facts: `call`, `status`, and `providerCode`
|
|
647
|
+
* when the provider gave one.
|
|
647
648
|
*/
|
|
648
649
|
PROVIDER_QUOTA_EXHAUSTED: "provider_quota_exhausted",
|
|
649
|
-
/** The provider rejected the key the service running the SDK uses, or the key lacks permission for this model or feature. The site names the dependency. Facts: `call`, `status`, `providerCode
|
|
650
|
+
/** The provider rejected the key the service running the SDK uses, or the key lacks permission for this model or feature. The site names the dependency. Facts: `call`, `status`, and `providerCode` when the provider gave one. */
|
|
650
651
|
PROVIDER_CREDENTIALS_REJECTED: "provider_credentials_rejected",
|
|
651
|
-
/** The provider says requests are over its rate or concurrency limit. The site names the dependency. Facts: `call`, `status`, `providerCode
|
|
652
|
+
/** The provider says requests are over its rate or concurrency limit. The site names the dependency. Facts: `call`, `status`, and `providerCode` when the provider gave one. */
|
|
652
653
|
PROVIDER_RATE_LIMITED: "provider_rate_limited",
|
|
653
|
-
/** The provider says it's overloaded or down for maintenance. The site names the dependency. Facts: `call`, `status`, `providerCode
|
|
654
|
+
/** The provider says it's overloaded or down for maintenance. The site names the dependency. Facts: `call`, `status`, and `providerCode` when the provider gave one. */
|
|
654
655
|
PROVIDER_UNAVAILABLE: "provider_unavailable",
|
|
655
656
|
/** The provider can't process the asset's audio. The site names the dependency. Facts: `call`, `status`, `providerCode`, `reason` (`corrupt`, `unsupported_format`, `too_long`, `too_short`). */
|
|
656
657
|
AUDIO_UNPROCESSABLE: "audio_unprocessable",
|
|
@@ -1126,12 +1127,15 @@ function dependencyErrorFrom(error, message, init) {
|
|
|
1126
1127
|
|
|
1127
1128
|
// src/lib/google-errors.ts
|
|
1128
1129
|
import { z as z2 } from "zod";
|
|
1129
|
-
var GoogleTokenSchema = z2.string().regex(/^[\w.-]{1,128}$/);
|
|
1130
|
+
var GoogleTokenSchema = z2.string().regex(/^[\w.-]{1,128}$/).optional().catch(void 0);
|
|
1130
1131
|
var GoogleErrorBodySchema = z2.object({
|
|
1131
1132
|
error: z2.object({
|
|
1132
|
-
status: GoogleTokenSchema
|
|
1133
|
+
status: GoogleTokenSchema,
|
|
1134
|
+
code: z2.union([z2.string().regex(/^[\w.-]{1,128}$/), z2.number()]).optional().catch(void 0),
|
|
1133
1135
|
details: z2.array(z2.object({
|
|
1134
|
-
|
|
1136
|
+
// `ErrorInfo`'s reason, e.g. `API_KEY_INVALID`.
|
|
1137
|
+
reason: GoogleTokenSchema,
|
|
1138
|
+
violations: z2.array(z2.object({ quotaId: GoogleTokenSchema })).max(16).optional()
|
|
1135
1139
|
})).max(16).optional()
|
|
1136
1140
|
})
|
|
1137
1141
|
});
|
|
@@ -1150,18 +1154,54 @@ function googleErrorFacts(responseBody) {
|
|
|
1150
1154
|
return {};
|
|
1151
1155
|
}
|
|
1152
1156
|
const quotaIds = [...new Set((parsed.data.error.details ?? []).flatMap((detail) => detail.violations ?? []).map((violation) => violation.quotaId).filter((quotaId) => quotaId !== void 0))];
|
|
1157
|
+
const code = parsed.data.error.code;
|
|
1158
|
+
const reason = (parsed.data.error.details ?? []).find((detail) => detail.reason !== void 0)?.reason;
|
|
1153
1159
|
return {
|
|
1154
1160
|
...parsed.data.error.status && { providerStatus: parsed.data.error.status },
|
|
1161
|
+
// Google's own code, as every provider rule's `providerCode`: the snake_case code, else its status.
|
|
1162
|
+
...(typeof code === "string" || parsed.data.error.status) && { providerCode: typeof code === "string" ? code : parsed.data.error.status },
|
|
1163
|
+
...reason && { providerReason: reason },
|
|
1155
1164
|
...quotaIds.length > 0 && { quotaIds }
|
|
1156
1165
|
};
|
|
1157
1166
|
}
|
|
1167
|
+
var GOOGLE_PER_DAY_QUOTA = /PerDay/i;
|
|
1168
|
+
var GOOGLE_QUOTA_EXCEEDED_CODE = "quota_exceeded";
|
|
1169
|
+
var GOOGLE_API_KEY_REASONS = /* @__PURE__ */ new Set([
|
|
1170
|
+
"API_KEY_INVALID",
|
|
1171
|
+
"API_KEY_SERVICE_BLOCKED",
|
|
1172
|
+
"API_KEY_HTTP_REFERRER_BLOCKED",
|
|
1173
|
+
"API_KEY_IP_ADDRESS_BLOCKED",
|
|
1174
|
+
"API_KEY_ANDROID_APP_BLOCKED",
|
|
1175
|
+
"API_KEY_IOS_APP_BLOCKED"
|
|
1176
|
+
]);
|
|
1177
|
+
function googleCallRule(status, facts) {
|
|
1178
|
+
const quotaIds = Array.isArray(facts.quotaIds) ? facts.quotaIds.map(String) : [];
|
|
1179
|
+
if (status === 402) {
|
|
1180
|
+
return { code: MUX_AI_ERROR_CODES.PROVIDER_QUOTA_EXHAUSTED };
|
|
1181
|
+
}
|
|
1182
|
+
if (status === 429) {
|
|
1183
|
+
const perDay = facts.providerCode === GOOGLE_QUOTA_EXCEEDED_CODE || quotaIds.some((id) => GOOGLE_PER_DAY_QUOTA.test(id));
|
|
1184
|
+
return { code: perDay ? MUX_AI_ERROR_CODES.PROVIDER_QUOTA_EXHAUSTED : MUX_AI_ERROR_CODES.PROVIDER_RATE_LIMITED };
|
|
1185
|
+
}
|
|
1186
|
+
if (status === 401 || status === 403 || GOOGLE_API_KEY_REASONS.has(String(facts.providerReason))) {
|
|
1187
|
+
return { code: MUX_AI_ERROR_CODES.PROVIDER_CREDENTIALS_REJECTED };
|
|
1188
|
+
}
|
|
1189
|
+
if (status === 503) {
|
|
1190
|
+
return { code: MUX_AI_ERROR_CODES.PROVIDER_UNAVAILABLE };
|
|
1191
|
+
}
|
|
1192
|
+
return status === 504 ? { timedOut: true } : void 0;
|
|
1193
|
+
}
|
|
1158
1194
|
function googleCallError(apiError, message, init) {
|
|
1195
|
+
const facts = { ...init.facts, ...googleErrorFacts(apiError.responseBody) };
|
|
1196
|
+
const rule = googleCallRule(apiError.statusCode, facts);
|
|
1159
1197
|
return dependencyError(message, {
|
|
1160
1198
|
dependency: MUX_AI_ERROR_DEPENDENCIES.AI_PROVIDER,
|
|
1161
1199
|
call: init.call,
|
|
1162
1200
|
status: apiError.statusCode,
|
|
1163
1201
|
requestId: requestIdOf(apiError.responseHeaders),
|
|
1164
|
-
facts
|
|
1202
|
+
facts,
|
|
1203
|
+
...rule?.code && { code: rule.code },
|
|
1204
|
+
...rule?.timedOut && { timedOut: true },
|
|
1165
1205
|
cause: init.cause ?? apiError
|
|
1166
1206
|
});
|
|
1167
1207
|
}
|