@mux/ai 0.69.0-canary.115 → 0.69.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-DbEwilAW.d.ts → index-C5HUMIv0.d.ts} +1 -1
- package/dist/{index-D3BlSXNl.d.ts → index-D9gsq_-m.d.ts} +1 -1
- package/dist/index.d.ts +29 -6
- package/dist/index.js +156 -36
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -2
- package/dist/primitives/index.js +98 -18
- package/dist/primitives/index.js.map +1 -1
- package/dist/{transcripts-Cs-n8X_l.d.ts → transcripts-S4CdWuUq.d.ts} +18 -4
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +152 -35
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Z as WorkflowCredentialsInput, $ as WorkflowScope, T as TextChunk, n as ChunkingStrategy,
|
|
1
|
+
import { Z as WorkflowCredentialsInput, $ as WorkflowScope, T as TextChunk, n as ChunkingStrategy, ab as VTTCue, ac as CompletedShotsResult, ad as DeletedShotsResult, ae as ErroredShotsResult, af as Hotspot, ag as HotspotOptions, ah as HotspotResponse, ai as LOW_CONFIDENCE_THRESHOLD, aj as MAX_CUE_TEXT_CHARS, ak as ParseVTTCuesOptions, al as PendingShotsResult, am as Shot, an as ShotRequestOptions, ao as ShotsResult, ap as SkippedShotsResult, aq as TranscriptEmptyReason, ar as TranscriptFetchOptions, as as TranscriptFetchStepResult, at as TranscriptResult, au as WaitForShotsOptions, av as buildTranscriptUrl, aw as buildVttFromCueBlocks, ax as buildVttFromTranslatedCueBlocks, ay as concatenateVttSegments, az as extractTextFromVTT, aA as extractTimestampedTranscript, aB as fetchTranscriptDataForUrl, aC as fetchTranscriptForAsset, aD as filterVttByScope, aE as findCaptionTrack, aF as getHotspotsForAsset, aG as getHotspotsForPlaybackId, aH as getHotspotsForVideo, aI as getReadyTextTracks, aJ as getReliableLanguageCode, aK as getShotsForAsset, aL as parseVTTCues, aM as replaceCueText, aN as requestShotsForAsset, aO as sanitizeUntrustedText, aP as secondsToTimestamp, aQ as splitVttPreambleAndCueBlocks, aR as stripVttMetadataBlocks, aS as vttTimestampToSeconds, aT as waitForShotsForAsset } from './transcripts-S4CdWuUq.js';
|
|
2
2
|
|
|
3
3
|
interface HeatmapOptions {
|
|
4
4
|
/** Time window for results, e.g., '7:days' (default: '7:days') */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LanguageModel, generateText as generateText$1 } from 'ai';
|
|
2
|
-
import { f as MuxAiError, k as ClassifiedErrorsOption, Z as WorkflowCredentialsInput, h as MuxAsset, A as AssetTextTrack, a as MuxAiErrorFacts, R as TokenUsage, K as ScopedMuxAIOptions, I as ImageSubmissionMode, G as MuxAIOptions, n as ChunkingStrategy, Y as VideoEmbeddingsResult,
|
|
2
|
+
import { f as MuxAiError, k as ClassifiedErrorsOption, Z as WorkflowCredentialsInput, h as MuxAsset, A as AssetTextTrack, a as MuxAiErrorFacts, R as TokenUsage, K as ScopedMuxAIOptions, I as ImageSubmissionMode, G as MuxAIOptions, n as ChunkingStrategy, Y as VideoEmbeddingsResult, af as Hotspot, am as Shot, ab as VTTCue, U as ToneType, O as StorageAdapter } from './transcripts-S4CdWuUq.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { S as SafetyReport, e as PromptOverrides, h as SceneContextItemV1, D as DEFAULT_DESCRIPTION_LENGTH, a as DEFAULT_SUMMARY_KEYWORD_LIMIT, b as DEFAULT_TITLE_LENGTH } from './summarization-BFmhXeAu.js';
|
|
5
5
|
import { createAnthropic } from '@ai-sdk/anthropic';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, M as MUX_TRACK_PASSTHROUGH_MAX_CHARS, b as ModelCallContext, R as ReplaceAndCreateTextTrackInput, c as ReplaceAndCreateTextTrackResult, d as ReplaceAndCreateTrackInput, e as ReplaceExistingTracksPolicy, f as ReplaceSourceTrackInput, g as ReplaceableTrackType, S as SourceTrackReplacementPolicy, h as SupportedISO639_1, i as SupportedISO639_3, T as TextTrackReplacementPlan, j as TextTrackSummary, k as TextTrackTarget, l as TrackReplacementBlocked, m as TrackReplacementBlockedReason, n as TrackSummary, o as TrackTarget, p as buildMuxAiTrackPassthrough, q as findNameCollisionTextTracks, r as findSameLanguageTextTracks, s as getLanguageCodePair, t as getLanguageName, u as isDuplicateTrackNameError, v as isMuxGeneratedTextTrack, w as isUndeterminedLanguageCode, x as isValidISO639_1, y as isValidISO639_3, z as modelCallError, A as normalizeTrackLanguageCode, B as normalizeTrackName, C as planSourceTrackReplacement, D as planTextTrackReplacement, E as replaceAndCreateTextTrack, F as replaceAndCreateTrack, G as replaceSourceTrack, H as summarizeTextTrack, J as toISO639_1, K as toISO639_3, N as trackReplacementBlockedError, O as trackTargetFacts, P as validateTrackPassthrough, Q as workflows } from './index-
|
|
2
|
-
import { M as MuxAiErrorDependency, a as MuxAiErrorFacts, b as MUX_AI_ERROR_SOURCES, c as MuxAiErrorSource, d as MuxAiSiteDependencyCode, e as MuxAiErrorType, f as MuxAiError, g as MuxAiDependencyStatusCode, h as MuxAsset, i as MuxAiErrorFactValue, j as MuxAiErrorCode,
|
|
3
|
-
export { A as AssetTextTrack, m as ChunkEmbedding, n as ChunkingStrategy, o as ClassifiedErrorInit, p as CodedClassification, E as Encrypted, q as EncryptedPayload, r as ErrorCatalogEntry, s as ErrorCauseSummary, I as ImageSubmissionMode, t as MUX_AI_DEPENDENCY_STATUS_CODES, u as MUX_AI_DEPENDENCY_STATUS_CODE_VALUES, v as MUX_AI_ERROR_CATALOG, w as MUX_AI_ERROR_CODES, x as MUX_AI_ERROR_CODE_VALUES, y as MUX_AI_ERROR_DEPENDENCIES, z as MUX_AI_ERROR_DEPENDENCY_VALUES, B as MUX_AI_ERROR_SOURCE_VALUES, D as MUX_AI_ERROR_TYPES, F as MUX_AI_ERROR_TYPE_VALUES, G as MuxAIOptions, H as MuxAiErrorInit, P as PlaybackAsset, J as PlaybackPolicy, K as ScopedMuxAIOptions, L as SerializedClassification, N as SourceAndDependency, O as StorageAdapter, T as TextChunk, Q as TokenChunkingConfig, R as TokenUsage, U as ToneType, V as UsageMetadata, X as VTTChunkingConfig, Y as VideoEmbeddingsResult, Z as WorkflowCredentialsInput, _ as WorkflowMuxClient, $ as WorkflowScope, a0 as assertNever, a1 as classificationInit, a2 as decryptFromWorkflow, a3 as encryptForWorkflow, a4 as errorDetailFact, a5 as internalError, a6 as isTransientStatus, a7 as
|
|
1
|
+
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, M as MUX_TRACK_PASSTHROUGH_MAX_CHARS, b as ModelCallContext, R as ReplaceAndCreateTextTrackInput, c as ReplaceAndCreateTextTrackResult, d as ReplaceAndCreateTrackInput, e as ReplaceExistingTracksPolicy, f as ReplaceSourceTrackInput, g as ReplaceableTrackType, S as SourceTrackReplacementPolicy, h as SupportedISO639_1, i as SupportedISO639_3, T as TextTrackReplacementPlan, j as TextTrackSummary, k as TextTrackTarget, l as TrackReplacementBlocked, m as TrackReplacementBlockedReason, n as TrackSummary, o as TrackTarget, p as buildMuxAiTrackPassthrough, q as findNameCollisionTextTracks, r as findSameLanguageTextTracks, s as getLanguageCodePair, t as getLanguageName, u as isDuplicateTrackNameError, v as isMuxGeneratedTextTrack, w as isUndeterminedLanguageCode, x as isValidISO639_1, y as isValidISO639_3, z as modelCallError, A as normalizeTrackLanguageCode, B as normalizeTrackName, C as planSourceTrackReplacement, D as planTextTrackReplacement, E as replaceAndCreateTextTrack, F as replaceAndCreateTrack, G as replaceSourceTrack, H as summarizeTextTrack, J as toISO639_1, K as toISO639_3, N as trackReplacementBlockedError, O as trackTargetFacts, P as validateTrackPassthrough, Q as workflows } from './index-D9gsq_-m.js';
|
|
2
|
+
import { C as ClassifiedError, M as MuxAiErrorDependency, a as MuxAiErrorFacts, b as MUX_AI_ERROR_SOURCES, c as MuxAiErrorSource, d as MuxAiSiteDependencyCode, e as MuxAiErrorType, f as MuxAiError, g as MuxAiDependencyStatusCode, h as MuxAsset, i as MuxAiErrorFactValue, j as MuxAiErrorCode, W as WorkflowCredentials, k as ClassifiedErrorsOption, S as StoragePutObjectInput, l as StoragePresignGetObjectInput } from './transcripts-S4CdWuUq.js';
|
|
3
|
+
export { A as AssetTextTrack, m as ChunkEmbedding, n as ChunkingStrategy, o as ClassifiedErrorInit, p as CodedClassification, E as Encrypted, q as EncryptedPayload, r as ErrorCatalogEntry, s as ErrorCauseSummary, I as ImageSubmissionMode, t as MUX_AI_DEPENDENCY_STATUS_CODES, u as MUX_AI_DEPENDENCY_STATUS_CODE_VALUES, v as MUX_AI_ERROR_CATALOG, w as MUX_AI_ERROR_CODES, x as MUX_AI_ERROR_CODE_VALUES, y as MUX_AI_ERROR_DEPENDENCIES, z as MUX_AI_ERROR_DEPENDENCY_VALUES, B as MUX_AI_ERROR_SOURCE_VALUES, D as MUX_AI_ERROR_TYPES, F as MUX_AI_ERROR_TYPE_VALUES, G as MuxAIOptions, H as MuxAiErrorInit, P as PlaybackAsset, J as PlaybackPolicy, K as ScopedMuxAIOptions, L as SerializedClassification, N as SourceAndDependency, O as StorageAdapter, T as TextChunk, Q as TokenChunkingConfig, R as TokenUsage, U as ToneType, V as UsageMetadata, X as VTTChunkingConfig, Y as VideoEmbeddingsResult, Z as WorkflowCredentialsInput, _ as WorkflowMuxClient, $ as WorkflowScope, a0 as assertNever, a1 as classificationInit, a2 as decryptFromWorkflow, a3 as encryptForWorkflow, a4 as errorDetailFact, a5 as internalError, a6 as isTransientStatus, a7 as readSerializedClassification, a8 as restoreClassification, a9 as serializeClassification, aa as wrapError } from './transcripts-S4CdWuUq.js';
|
|
4
4
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
|
|
5
|
-
export { i as primitives } from './index-
|
|
5
|
+
export { i as primitives } from './index-C5HUMIv0.js';
|
|
6
6
|
import 'ai';
|
|
7
7
|
import 'zod';
|
|
8
8
|
import './summarization-BFmhXeAu.js';
|
|
@@ -11,7 +11,30 @@ import '@ai-sdk/google';
|
|
|
11
11
|
import '@ai-sdk/openai';
|
|
12
12
|
import '@mux/ts';
|
|
13
13
|
|
|
14
|
-
var version = "0.69.0
|
|
14
|
+
var version = "0.69.0";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The classified error `error` is, or the first one in its `cause` chain.
|
|
18
|
+
*
|
|
19
|
+
* Workflow DevKit doesn't always hand a workflow the error a step threw. Once a step's last
|
|
20
|
+
* attempt fails, it throws a new `FatalError` ("Step "…" failed after N retries: …", or "…
|
|
21
|
+
* exceeded max retries …") with the step's error as its `cause`, so a workflow body that inspects
|
|
22
|
+
* what a step threw sees an unclassified wrapper once a transient failure has used up its retries.
|
|
23
|
+
* Looking down the chain, rather than matching that wrapper's shape or message, also covers any
|
|
24
|
+
* other wrapper that keeps the original as its `cause`.
|
|
25
|
+
*
|
|
26
|
+
* Stops at a legacy error: returns it when it's classified (the SDK's are) and `undefined` when
|
|
27
|
+
* it isn't, so a legacy error is never mistaken for the classified error it wraps. Returns
|
|
28
|
+
* `undefined` for anything else with no classified error within {@link MAX_CAUSE_DEPTH} links.
|
|
29
|
+
* Callers that want the original back use `classifiedErrorOf(error) ?? error`.
|
|
30
|
+
*/
|
|
31
|
+
declare function classifiedErrorOf(error: unknown): ClassifiedError | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Whether `value` is one of Workflow DevKit's control-flow errors. Workflow code that catches a
|
|
34
|
+
* step's error must rethrow one unchanged: wrapping it, swallowing it or recording it as a
|
|
35
|
+
* failure turns a run the runtime would recover into a failed one.
|
|
36
|
+
*/
|
|
37
|
+
declare function isWorkflowControlFlowError(value: unknown): value is Error;
|
|
15
38
|
|
|
16
39
|
interface DependencyErrorInit {
|
|
17
40
|
dependency: MuxAiErrorDependency;
|
|
@@ -415,4 +438,4 @@ declare class WorkflowStorageClient {
|
|
|
415
438
|
}
|
|
416
439
|
declare function createWorkflowStorageClient(options?: WorkflowStorageClientOptions): WorkflowStorageClient;
|
|
417
440
|
|
|
418
|
-
export { ClassifiedError, type DependencyErrorInit, type DependencyFailureInit, type ElevenLabsFailure, type LegacyMp4SupportRendition, MUX_AI_ERROR_GENERIC_MESSAGES, MUX_AI_ERROR_PUBLIC_MAPPINGS, MUX_AI_ERROR_SOURCES, MuxAiDependencyStatusCode, MuxAiError, MuxAiErrorCode, MuxAiErrorDependency, MuxAiErrorFactValue, MuxAiErrorFacts, MuxAiErrorSource, MuxAiErrorType, type MuxAiPublicError, MuxAiSiteDependencyCode, MuxAsset, type MuxPlaybackService, type PublicError, type PublicErrorMapping, type RecognizedDependencyErrorInit, STATIC_RENDITIONS_GUIDE_URL, StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, classifyDependencyFailure, createPublicErrorView, createWorkflowStorageClient, dependencyError, dependencyFailureCode, elevenLabsErrorRule, elevenLabsFailureError, elevenLabsResponseFailure, elevenLabsSdkFailure, genericPublicMessage, getLegacyMp4SupportRenditionSizeError, getMuxPlaybackOrigin, httpStatusOf, requestIdOf, resolveLegacyMp4SupportRendition, setWorkflowCredentialsProvider, toPublicError, usesLegacyMp4Support, version };
|
|
441
|
+
export { ClassifiedError, type DependencyErrorInit, type DependencyFailureInit, type ElevenLabsFailure, type LegacyMp4SupportRendition, MUX_AI_ERROR_GENERIC_MESSAGES, MUX_AI_ERROR_PUBLIC_MAPPINGS, MUX_AI_ERROR_SOURCES, MuxAiDependencyStatusCode, MuxAiError, MuxAiErrorCode, MuxAiErrorDependency, MuxAiErrorFactValue, MuxAiErrorFacts, MuxAiErrorSource, MuxAiErrorType, type MuxAiPublicError, MuxAiSiteDependencyCode, MuxAsset, type MuxPlaybackService, type PublicError, type PublicErrorMapping, type RecognizedDependencyErrorInit, STATIC_RENDITIONS_GUIDE_URL, StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, classifiedErrorOf, classifyDependencyFailure, createPublicErrorView, createWorkflowStorageClient, dependencyError, dependencyFailureCode, elevenLabsErrorRule, elevenLabsFailureError, elevenLabsResponseFailure, elevenLabsSdkFailure, genericPublicMessage, getLegacyMp4SupportRenditionSizeError, getMuxPlaybackOrigin, httpStatusOf, isWorkflowControlFlowError, requestIdOf, resolveLegacyMp4SupportRendition, setWorkflowCredentialsProvider, toPublicError, usesLegacyMp4Support, version };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.69.0
|
|
8
|
+
var version = "0.69.0";
|
|
9
9
|
|
|
10
10
|
// src/lib/content-policy-error.ts
|
|
11
11
|
import { APICallError as APICallError2, NoObjectGeneratedError, NoOutputGeneratedError as NoOutputGeneratedError2, RetryError, TypeValidationError } from "ai";
|
|
@@ -15,6 +15,38 @@ import { z as z4 } from "zod";
|
|
|
15
15
|
var WORKFLOW_SERIALIZE = /* @__PURE__ */ Symbol.for("workflow-serialize");
|
|
16
16
|
var WORKFLOW_DESERIALIZE = /* @__PURE__ */ Symbol.for("workflow-deserialize");
|
|
17
17
|
|
|
18
|
+
// src/lib/error-guards.ts
|
|
19
|
+
function isClassifiedError(value) {
|
|
20
|
+
return typeof value === "object" && value !== null && "__classified_error" in value && value.__classified_error === true;
|
|
21
|
+
}
|
|
22
|
+
function isLegacyMuxAiError(value) {
|
|
23
|
+
return typeof value === "object" && value !== null && "__robots_error" in value && value.__robots_error === true && typeof value.publicMessage === "string";
|
|
24
|
+
}
|
|
25
|
+
var MAX_CAUSE_DEPTH = 5;
|
|
26
|
+
function classifiedErrorOf(error) {
|
|
27
|
+
const seen = /* @__PURE__ */ new Set();
|
|
28
|
+
let current = error;
|
|
29
|
+
for (let depth = 0; depth < MAX_CAUSE_DEPTH && typeof current === "object" && current !== null && !seen.has(current); depth += 1) {
|
|
30
|
+
if (isLegacyMuxAiError(current)) {
|
|
31
|
+
return isClassifiedError(current) ? current : void 0;
|
|
32
|
+
}
|
|
33
|
+
if (isClassifiedError(current)) {
|
|
34
|
+
return current;
|
|
35
|
+
}
|
|
36
|
+
seen.add(current);
|
|
37
|
+
current = current.cause;
|
|
38
|
+
}
|
|
39
|
+
return void 0;
|
|
40
|
+
}
|
|
41
|
+
var WORKFLOW_CONTROL_FLOW_ERROR_NAMES = /* @__PURE__ */ new Set(["ReplayDivergenceError", "WorkflowSuspension"]);
|
|
42
|
+
function isWorkflowControlFlowError(value) {
|
|
43
|
+
if (typeof value !== "object" || value === null) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const { name } = value;
|
|
47
|
+
return typeof name === "string" && WORKFLOW_CONTROL_FLOW_ERROR_NAMES.has(name);
|
|
48
|
+
}
|
|
49
|
+
|
|
18
50
|
// src/lib/prompt-fragments.ts
|
|
19
51
|
import dedent from "dedent";
|
|
20
52
|
|
|
@@ -493,7 +525,8 @@ function getErrorTokenUsage(error) {
|
|
|
493
525
|
}
|
|
494
526
|
const usage = error.usage;
|
|
495
527
|
if (typeof usage !== "object" || usage === null) {
|
|
496
|
-
|
|
528
|
+
const classified = classifiedErrorOf(error);
|
|
529
|
+
return classified && classified !== error ? getErrorTokenUsage(classified) : void 0;
|
|
497
530
|
}
|
|
498
531
|
const source = usage;
|
|
499
532
|
const extracted = {};
|
|
@@ -524,8 +557,12 @@ function getErrorTokenUsage(error) {
|
|
|
524
557
|
return Object.keys(extracted).length > 0 ? extracted : void 0;
|
|
525
558
|
}
|
|
526
559
|
function rethrowWithTokenUsage(error, collectedUsage) {
|
|
527
|
-
|
|
560
|
+
if (isWorkflowControlFlowError(error)) {
|
|
561
|
+
throw error;
|
|
562
|
+
}
|
|
528
563
|
const errorUsage = getErrorTokenUsage(error);
|
|
564
|
+
error = classifiedErrorOf(error) ?? error;
|
|
565
|
+
const usages = [...collectedUsage];
|
|
529
566
|
if (errorUsage) {
|
|
530
567
|
usages.push(errorUsage);
|
|
531
568
|
}
|
|
@@ -811,7 +848,7 @@ var MUX_AI_DEPENDENCY_STATUS_CODES = {
|
|
|
811
848
|
RESPONSE_FAILED: MUX_AI_ERROR_CODES.DEPENDENCY_RESPONSE_FAILED
|
|
812
849
|
};
|
|
813
850
|
var MUX_AI_DEPENDENCY_STATUS_CODE_VALUES = Object.values(MUX_AI_DEPENDENCY_STATUS_CODES);
|
|
814
|
-
var
|
|
851
|
+
var MAX_CAUSE_DEPTH2 = 3;
|
|
815
852
|
var MAX_CAUSE_MESSAGE_LENGTH = 500;
|
|
816
853
|
function statusOf(value) {
|
|
817
854
|
if (typeof value !== "object" || value === null) {
|
|
@@ -824,9 +861,9 @@ function statusOf(value) {
|
|
|
824
861
|
function summarizeCauses(cause) {
|
|
825
862
|
const causes = [];
|
|
826
863
|
let current = cause;
|
|
827
|
-
while (current !== void 0 && current !== null && causes.length <
|
|
864
|
+
while (current !== void 0 && current !== null && causes.length < MAX_CAUSE_DEPTH2) {
|
|
828
865
|
if (ClassifiedError.isClassified(current)) {
|
|
829
|
-
causes.push(...current.causes.slice(0,
|
|
866
|
+
causes.push(...current.causes.slice(0, MAX_CAUSE_DEPTH2 - causes.length));
|
|
830
867
|
break;
|
|
831
868
|
}
|
|
832
869
|
const status = statusOf(current);
|
|
@@ -866,7 +903,7 @@ var ClassifiedError = class extends Error {
|
|
|
866
903
|
}
|
|
867
904
|
/** Whether `value` is any classified error, from this copy of the SDK or another. */
|
|
868
905
|
static isClassified(value) {
|
|
869
|
-
return
|
|
906
|
+
return isClassifiedError(value);
|
|
870
907
|
}
|
|
871
908
|
};
|
|
872
909
|
function serializeClassification(error) {
|
|
@@ -876,6 +913,8 @@ function serializeClassification(error) {
|
|
|
876
913
|
source: error.source,
|
|
877
914
|
...error.dependency && { dependency: error.dependency },
|
|
878
915
|
...error.code && { code: error.code },
|
|
916
|
+
// JSON-safe by type, but not checked at runtime: a value Workflow DevKit can't serialize
|
|
917
|
+
// would stop the step's failure from being recorded at all.
|
|
879
918
|
facts: error.facts,
|
|
880
919
|
retryable: error.retryable,
|
|
881
920
|
transient: error.transient,
|
|
@@ -883,7 +922,41 @@ function serializeClassification(error) {
|
|
|
883
922
|
stack: error.stack
|
|
884
923
|
};
|
|
885
924
|
}
|
|
925
|
+
function readString(value) {
|
|
926
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
927
|
+
}
|
|
928
|
+
function readPlainRecord(value) {
|
|
929
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
930
|
+
}
|
|
931
|
+
function readSerializedClassification(record) {
|
|
932
|
+
const value = readPlainRecord(record) ?? {};
|
|
933
|
+
const dependency = readString(value.dependency);
|
|
934
|
+
const code = readString(value.code);
|
|
935
|
+
const stack = readString(value.stack);
|
|
936
|
+
const causes = Array.isArray(value.causes) ? value.causes.flatMap((cause) => {
|
|
937
|
+
const entry = readPlainRecord(cause);
|
|
938
|
+
const name = readString(entry?.name);
|
|
939
|
+
const message = typeof entry?.message === "string" ? entry.message : void 0;
|
|
940
|
+
if (!name || message === void 0) {
|
|
941
|
+
return [];
|
|
942
|
+
}
|
|
943
|
+
return [{ name, message, ...typeof entry?.status === "number" && { status: entry.status } }];
|
|
944
|
+
}) : [];
|
|
945
|
+
return {
|
|
946
|
+
message: typeof value.message === "string" ? value.message : "Unknown error",
|
|
947
|
+
type: readString(value.type) ?? MUX_AI_ERROR_TYPES.SERVER_ERROR,
|
|
948
|
+
source: readString(value.source) ?? MUX_AI_ERROR_SOURCES.INTERNAL,
|
|
949
|
+
...dependency && { dependency },
|
|
950
|
+
...code && { code },
|
|
951
|
+
facts: readPlainRecord(value.facts) ?? {},
|
|
952
|
+
retryable: value.retryable === true,
|
|
953
|
+
transient: value.transient === true,
|
|
954
|
+
causes,
|
|
955
|
+
...stack && { stack }
|
|
956
|
+
};
|
|
957
|
+
}
|
|
886
958
|
function classificationInit(record) {
|
|
959
|
+
record = readSerializedClassification(record);
|
|
887
960
|
return {
|
|
888
961
|
type: record.type,
|
|
889
962
|
source: record.source,
|
|
@@ -894,6 +967,7 @@ function classificationInit(record) {
|
|
|
894
967
|
};
|
|
895
968
|
}
|
|
896
969
|
function restoreClassification(error, record) {
|
|
970
|
+
record = readSerializedClassification(record);
|
|
897
971
|
if (record.code) {
|
|
898
972
|
Object.assign(error, { code: record.code });
|
|
899
973
|
}
|
|
@@ -925,14 +999,20 @@ var MuxAiError = class _MuxAiError extends ClassifiedError {
|
|
|
925
999
|
};
|
|
926
1000
|
}
|
|
927
1001
|
static [WORKFLOW_DESERIALIZE](value) {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1002
|
+
try {
|
|
1003
|
+
const record = readSerializedClassification(value);
|
|
1004
|
+
const fields = readPlainRecord(value) ?? {};
|
|
1005
|
+
const error = restoreClassification(new _MuxAiError(record.message, classificationInit(record)), record);
|
|
1006
|
+
Object.assign(error, {
|
|
1007
|
+
usage: readPlainRecord(fields.usage),
|
|
1008
|
+
diagnostics: readPlainRecord(fields.diagnostics),
|
|
1009
|
+
...typeof fields.finishReason === "string" && { finishReason: fields.finishReason },
|
|
1010
|
+
...typeof fields.rawFinishReason === "string" && { rawFinishReason: fields.rawFinishReason }
|
|
1011
|
+
});
|
|
1012
|
+
return error;
|
|
1013
|
+
} catch {
|
|
1014
|
+
return new _MuxAiError("Unknown error", { type: MUX_AI_ERROR_TYPES.SERVER_ERROR, source: MUX_AI_ERROR_SOURCES.INTERNAL });
|
|
1015
|
+
}
|
|
936
1016
|
}
|
|
937
1017
|
};
|
|
938
1018
|
function extractErrorDetail(error) {
|
|
@@ -978,10 +1058,18 @@ function scrubDetail(detail, context) {
|
|
|
978
1058
|
return "Upstream error details suppressed by safety filter";
|
|
979
1059
|
}
|
|
980
1060
|
function wrapError(error, message, facts) {
|
|
1061
|
+
if (isWorkflowControlFlowError(error)) {
|
|
1062
|
+
throw error;
|
|
1063
|
+
}
|
|
1064
|
+
const usage = getErrorTokenUsage(error);
|
|
1065
|
+
error = classifiedErrorOf(error) ?? error;
|
|
981
1066
|
if (MuxAiError.is(error)) {
|
|
982
1067
|
if (facts) {
|
|
983
1068
|
Object.assign(error, { facts: { ...facts, ...error.facts } });
|
|
984
1069
|
}
|
|
1070
|
+
if (usage) {
|
|
1071
|
+
error.usage = usage;
|
|
1072
|
+
}
|
|
985
1073
|
throw error;
|
|
986
1074
|
}
|
|
987
1075
|
const wrapped = new MuxAiError(`${message}: ${scrubDetail(extractErrorDetail(error), message)}`, {
|
|
@@ -990,7 +1078,6 @@ function wrapError(error, message, facts) {
|
|
|
990
1078
|
facts,
|
|
991
1079
|
cause: error
|
|
992
1080
|
});
|
|
993
|
-
const usage = getErrorTokenUsage(error);
|
|
994
1081
|
if (usage) {
|
|
995
1082
|
wrapped.usage = usage;
|
|
996
1083
|
}
|
|
@@ -1262,9 +1349,6 @@ var LegacyMuxAiError = class _LegacyMuxAiError extends MuxAiError {
|
|
|
1262
1349
|
return error;
|
|
1263
1350
|
}
|
|
1264
1351
|
};
|
|
1265
|
-
function isLegacyMuxAiError(value) {
|
|
1266
|
-
return typeof value === "object" && value !== null && "__robots_error" in value && value.__robots_error === true && typeof value.publicMessage === "string";
|
|
1267
|
-
}
|
|
1268
1352
|
function legacyWrapError(error, message) {
|
|
1269
1353
|
if (MuxAiError.is(error) || isLegacyMuxAiError(error)) {
|
|
1270
1354
|
throw error;
|
|
@@ -2669,16 +2753,16 @@ async function resolveWorkflowCredentials(credentials) {
|
|
|
2669
2753
|
}
|
|
2670
2754
|
return { ...resolved, ...credentials };
|
|
2671
2755
|
}
|
|
2672
|
-
function
|
|
2756
|
+
function readString2(record, key) {
|
|
2673
2757
|
const value = record?.[key];
|
|
2674
2758
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
2675
2759
|
}
|
|
2676
2760
|
function resolveDirectMuxCredentials(record) {
|
|
2677
|
-
const tokenId =
|
|
2678
|
-
const tokenSecret =
|
|
2679
|
-
const authorizationToken =
|
|
2680
|
-
const signingKey =
|
|
2681
|
-
const privateKey =
|
|
2761
|
+
const tokenId = readString2(record, "muxTokenId");
|
|
2762
|
+
const tokenSecret = readString2(record, "muxTokenSecret");
|
|
2763
|
+
const authorizationToken = readString2(record, "muxAuthorizationToken");
|
|
2764
|
+
const signingKey = readString2(record, "muxSigningKey");
|
|
2765
|
+
const privateKey = readString2(record, "muxPrivateKey");
|
|
2682
2766
|
if (!tokenId && !tokenSecret && !authorizationToken && !signingKey && !privateKey) {
|
|
2683
2767
|
return void 0;
|
|
2684
2768
|
}
|
|
@@ -2736,13 +2820,13 @@ async function resolveMuxClient(credentials) {
|
|
|
2736
2820
|
}
|
|
2737
2821
|
function resolveProviderApiKeyFromCredentials(provider, resolved) {
|
|
2738
2822
|
const record = resolved;
|
|
2739
|
-
const openaiApiKey =
|
|
2740
|
-
const basetenApiKey =
|
|
2741
|
-
const anthropicApiKey =
|
|
2742
|
-
const googleApiKey =
|
|
2743
|
-
const googleVisionApiKey =
|
|
2744
|
-
const hiveApiKey =
|
|
2745
|
-
const elevenLabsApiKey =
|
|
2823
|
+
const openaiApiKey = readString2(record, "openaiApiKey");
|
|
2824
|
+
const basetenApiKey = readString2(record, "basetenApiKey");
|
|
2825
|
+
const anthropicApiKey = readString2(record, "anthropicApiKey");
|
|
2826
|
+
const googleApiKey = readString2(record, "googleApiKey");
|
|
2827
|
+
const googleVisionApiKey = readString2(record, "googleVisionApiKey");
|
|
2828
|
+
const hiveApiKey = readString2(record, "hiveApiKey");
|
|
2829
|
+
const elevenLabsApiKey = readString2(record, "elevenLabsApiKey");
|
|
2746
2830
|
const apiKeyMap = {
|
|
2747
2831
|
"openai": openaiApiKey ?? env_default.OPENAI_API_KEY,
|
|
2748
2832
|
"baseten": basetenApiKey ?? env_default.BASETEN_API_KEY,
|
|
@@ -2776,8 +2860,8 @@ async function resolveProviderApiKey(provider, credentials) {
|
|
|
2776
2860
|
async function resolveMuxSigningContext(credentials) {
|
|
2777
2861
|
const resolved = await resolveWorkflowCredentials(credentials);
|
|
2778
2862
|
const resolvedRecord = resolved;
|
|
2779
|
-
const keyId =
|
|
2780
|
-
const keySecret =
|
|
2863
|
+
const keyId = readString2(resolvedRecord, "muxSigningKey") ?? env_default.MUX_SIGNING_KEY;
|
|
2864
|
+
const keySecret = readString2(resolvedRecord, "muxPrivateKey") ?? env_default.MUX_PRIVATE_KEY;
|
|
2781
2865
|
if (!keyId || !keySecret) {
|
|
2782
2866
|
return void 0;
|
|
2783
2867
|
}
|
|
@@ -5578,7 +5662,7 @@ async function fetchTranscriptForAsset(asset, playbackId, options = {}) {
|
|
|
5578
5662
|
try {
|
|
5579
5663
|
result = await fetchTranscriptDataForUrl(transcriptUrl, { cleanTranscript, scope, classifiedErrors });
|
|
5580
5664
|
} catch (error) {
|
|
5581
|
-
if (required) {
|
|
5665
|
+
if (required || isWorkflowControlFlowError(error)) {
|
|
5582
5666
|
throw error;
|
|
5583
5667
|
}
|
|
5584
5668
|
console.warn("Failed to fetch transcript:", error);
|
|
@@ -7794,6 +7878,7 @@ async function deleteTrackOnMux(assetId, trackId, credentials) {
|
|
|
7794
7878
|
}
|
|
7795
7879
|
}
|
|
7796
7880
|
function restoreFailureFacts(error) {
|
|
7881
|
+
error = classifiedErrorOf(error) ?? error;
|
|
7797
7882
|
if (!MuxAiError.is(error)) {
|
|
7798
7883
|
return { restoreError: errorDetailFact(extractErrorDetail(error)) };
|
|
7799
7884
|
}
|
|
@@ -8131,6 +8216,9 @@ async function editCaptionsInternal(assetId, trackId, options, collectedUsage) {
|
|
|
8131
8216
|
restoreNote = ` The source track was restored as ${restoredTrackId}.`;
|
|
8132
8217
|
restoreFacts = { sourceRestored: true, restoredTrackId };
|
|
8133
8218
|
} catch (restoreError) {
|
|
8219
|
+
if (isWorkflowControlFlowError(restoreError)) {
|
|
8220
|
+
throw restoreError;
|
|
8221
|
+
}
|
|
8134
8222
|
restoreNote = " Restoring the source track also failed.";
|
|
8135
8223
|
restoreFacts = { sourceRestored: false, ...restoreFailureFacts(restoreError) };
|
|
8136
8224
|
}
|
|
@@ -8765,6 +8853,11 @@ async function generateEngagementInsightsInternal(assetId, options, collectedUsa
|
|
|
8765
8853
|
}),
|
|
8766
8854
|
storyboardPromise
|
|
8767
8855
|
]);
|
|
8856
|
+
for (const result of [engagementResult, shotsResult, transcriptResult, storyboardResult]) {
|
|
8857
|
+
if (result.status === "rejected" && isWorkflowControlFlowError(result.reason)) {
|
|
8858
|
+
throw result.reason;
|
|
8859
|
+
}
|
|
8860
|
+
}
|
|
8768
8861
|
if (engagementResult.status === "rejected") {
|
|
8769
8862
|
wrapError(engagementResult.reason, `Failed to fetch engagement data for asset ${assetId}`, { assetId, timeframe });
|
|
8770
8863
|
}
|
|
@@ -9148,7 +9241,10 @@ async function getCompletedShots(assetId, credentials) {
|
|
|
9148
9241
|
return result;
|
|
9149
9242
|
}
|
|
9150
9243
|
console.warn(`[@mux/ai] Shots are not ready for asset ${assetId} (status: ${result.status}). Using the storyboard only.`);
|
|
9151
|
-
} catch {
|
|
9244
|
+
} catch (error) {
|
|
9245
|
+
if (isWorkflowControlFlowError(error)) {
|
|
9246
|
+
throw error;
|
|
9247
|
+
}
|
|
9152
9248
|
console.warn(`[@mux/ai] Shots lookup failed for asset ${assetId}. Using the storyboard only.`);
|
|
9153
9249
|
}
|
|
9154
9250
|
return void 0;
|
|
@@ -9584,6 +9680,10 @@ async function generateArtifactsInBatches(requests, collectedUsage, provider, mo
|
|
|
9584
9680
|
}
|
|
9585
9681
|
}
|
|
9586
9682
|
if (failures.length > 0) {
|
|
9683
|
+
const controlFlow = failures.find(isWorkflowControlFlowError);
|
|
9684
|
+
if (controlFlow) {
|
|
9685
|
+
throw controlFlow;
|
|
9686
|
+
}
|
|
9587
9687
|
for (const failure of failures.slice(1)) {
|
|
9588
9688
|
const usage = getErrorTokenUsage(failure);
|
|
9589
9689
|
if (usage) {
|
|
@@ -10640,6 +10740,13 @@ function allSamplesFailedError(message, failures, facts) {
|
|
|
10640
10740
|
}
|
|
10641
10741
|
async function getModerationScores(assetId, options = {}) {
|
|
10642
10742
|
"use workflow";
|
|
10743
|
+
try {
|
|
10744
|
+
return await getModerationScoresInternal(assetId, options);
|
|
10745
|
+
} catch (error) {
|
|
10746
|
+
rethrowWithTokenUsage(error, []);
|
|
10747
|
+
}
|
|
10748
|
+
}
|
|
10749
|
+
async function getModerationScoresInternal(assetId, options) {
|
|
10643
10750
|
const {
|
|
10644
10751
|
provider = DEFAULT_PROVIDER2,
|
|
10645
10752
|
model = provider === "openai" ? "omni-moderation-latest" : void 0,
|
|
@@ -12038,6 +12145,13 @@ async function attachDubbedCaptions(input) {
|
|
|
12038
12145
|
}
|
|
12039
12146
|
async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
12040
12147
|
"use workflow";
|
|
12148
|
+
try {
|
|
12149
|
+
return await translateAudioInternal(assetId, toLanguageCode, options);
|
|
12150
|
+
} catch (error) {
|
|
12151
|
+
rethrowWithTokenUsage(error, []);
|
|
12152
|
+
}
|
|
12153
|
+
}
|
|
12154
|
+
async function translateAudioInternal(assetId, toLanguageCode, options) {
|
|
12041
12155
|
const {
|
|
12042
12156
|
provider = "elevenlabs",
|
|
12043
12157
|
fromLanguageCode,
|
|
@@ -12393,6 +12507,9 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
12393
12507
|
}
|
|
12394
12508
|
}
|
|
12395
12509
|
} catch (error) {
|
|
12510
|
+
if (isWorkflowControlFlowError(error)) {
|
|
12511
|
+
throw error;
|
|
12512
|
+
}
|
|
12396
12513
|
captionsOutcome = captionsPresignedUrl ? { status: "failed", message: CAPTIONS_ATTACHMENT_FAILED_MESSAGE, retryable: true, replacedTracks: [] } : { status: "unavailable", message: CAPTIONS_UNAVAILABLE_MESSAGE, retryable: true };
|
|
12397
12514
|
console.warn(`\u26A0\uFE0F Failed to attach dubbed captions: ${extractErrorDetail(error)}`);
|
|
12398
12515
|
if (captionsPresignedUrl) {
|
|
@@ -13332,6 +13449,7 @@ export {
|
|
|
13332
13449
|
assertNever,
|
|
13333
13450
|
buildMuxAiTrackPassthrough,
|
|
13334
13451
|
classificationInit,
|
|
13452
|
+
classifiedErrorOf,
|
|
13335
13453
|
classifyDependencyFailure,
|
|
13336
13454
|
createPublicErrorView,
|
|
13337
13455
|
createWorkflowStorageClient,
|
|
@@ -13359,12 +13477,14 @@ export {
|
|
|
13359
13477
|
isUndeterminedLanguageCode,
|
|
13360
13478
|
isValidISO639_1,
|
|
13361
13479
|
isValidISO639_3,
|
|
13480
|
+
isWorkflowControlFlowError,
|
|
13362
13481
|
modelCallError,
|
|
13363
13482
|
normalizeTrackLanguageCode,
|
|
13364
13483
|
normalizeTrackName,
|
|
13365
13484
|
planSourceTrackReplacement,
|
|
13366
13485
|
planTextTrackReplacement,
|
|
13367
13486
|
primitives_exports as primitives,
|
|
13487
|
+
readSerializedClassification,
|
|
13368
13488
|
replaceAndCreateTextTrack,
|
|
13369
13489
|
replaceAndCreateTrack,
|
|
13370
13490
|
replaceSourceTrack,
|