@mux/ai 0.68.0 → 0.69.0-canary.116
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/README.md +2 -0
- package/dist/{index-DbEwilAW.d.ts → index-C5HUMIv0.d.ts} +1 -1
- package/dist/{index-CxDX1bX1.d.ts → index-D9gsq_-m.d.ts} +3 -3
- package/dist/index.d.ts +29 -6
- package/dist/index.js +159 -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 +155 -35
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DEFAULT_STORYBOARD_WIDTH, H as HeatmapOptions, a as HeatmapResponse, T as ThumbnailOptions, V as VTTCueBudgetChunkingOptions, b as VTTDurationChunk, c as VTTDurationChunkingOptions, d as chunkByTokens, e as chunkText, f as chunkVTTCues, g as chunkVTTCuesByBudget, h as chunkVTTCuesByDuration, j as estimateTokenCount, k as getHeatmapForAsset, l as getHeatmapForPlaybackId, m as getHeatmapForVideo, n as getStoryboardUrl, o as getThumbnailUrls } from '../index-
|
|
2
|
-
export {
|
|
1
|
+
export { D as DEFAULT_STORYBOARD_WIDTH, H as HeatmapOptions, a as HeatmapResponse, T as ThumbnailOptions, V as VTTCueBudgetChunkingOptions, b as VTTDurationChunk, c as VTTDurationChunkingOptions, d as chunkByTokens, e as chunkText, f as chunkVTTCues, g as chunkVTTCuesByBudget, h as chunkVTTCuesByDuration, j as estimateTokenCount, k as getHeatmapForAsset, l as getHeatmapForPlaybackId, m as getHeatmapForVideo, n as getStoryboardUrl, o as getThumbnailUrls } from '../index-C5HUMIv0.js';
|
|
2
|
+
export { 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, ab as VTTCue, 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';
|
|
3
3
|
import '@workflow/serde';
|
|
4
4
|
import '@mux/ts';
|
package/dist/primitives/index.js
CHANGED
|
@@ -689,6 +689,38 @@ async function fetchHotspots(identifierType, id, options) {
|
|
|
689
689
|
var WORKFLOW_SERIALIZE = /* @__PURE__ */ Symbol.for("workflow-serialize");
|
|
690
690
|
var WORKFLOW_DESERIALIZE = /* @__PURE__ */ Symbol.for("workflow-deserialize");
|
|
691
691
|
|
|
692
|
+
// src/lib/error-guards.ts
|
|
693
|
+
function isClassifiedError(value) {
|
|
694
|
+
return typeof value === "object" && value !== null && "__classified_error" in value && value.__classified_error === true;
|
|
695
|
+
}
|
|
696
|
+
function isLegacyMuxAiError(value) {
|
|
697
|
+
return typeof value === "object" && value !== null && "__robots_error" in value && value.__robots_error === true && typeof value.publicMessage === "string";
|
|
698
|
+
}
|
|
699
|
+
var MAX_CAUSE_DEPTH = 5;
|
|
700
|
+
function classifiedErrorOf(error) {
|
|
701
|
+
const seen = /* @__PURE__ */ new Set();
|
|
702
|
+
let current = error;
|
|
703
|
+
for (let depth = 0; depth < MAX_CAUSE_DEPTH && typeof current === "object" && current !== null && !seen.has(current); depth += 1) {
|
|
704
|
+
if (isLegacyMuxAiError(current)) {
|
|
705
|
+
return isClassifiedError(current) ? current : void 0;
|
|
706
|
+
}
|
|
707
|
+
if (isClassifiedError(current)) {
|
|
708
|
+
return current;
|
|
709
|
+
}
|
|
710
|
+
seen.add(current);
|
|
711
|
+
current = current.cause;
|
|
712
|
+
}
|
|
713
|
+
return void 0;
|
|
714
|
+
}
|
|
715
|
+
var WORKFLOW_CONTROL_FLOW_ERROR_NAMES = /* @__PURE__ */ new Set(["ReplayDivergenceError", "WorkflowSuspension"]);
|
|
716
|
+
function isWorkflowControlFlowError(value) {
|
|
717
|
+
if (typeof value !== "object" || value === null) {
|
|
718
|
+
return false;
|
|
719
|
+
}
|
|
720
|
+
const { name } = value;
|
|
721
|
+
return typeof name === "string" && WORKFLOW_CONTROL_FLOW_ERROR_NAMES.has(name);
|
|
722
|
+
}
|
|
723
|
+
|
|
692
724
|
// src/lib/prompt-fragments.ts
|
|
693
725
|
import dedent from "dedent";
|
|
694
726
|
var promptDedent = dedent.withOptions({ alignValues: true });
|
|
@@ -888,7 +920,8 @@ function getErrorTokenUsage(error) {
|
|
|
888
920
|
}
|
|
889
921
|
const usage = error.usage;
|
|
890
922
|
if (typeof usage !== "object" || usage === null) {
|
|
891
|
-
|
|
923
|
+
const classified = classifiedErrorOf(error);
|
|
924
|
+
return classified && classified !== error ? getErrorTokenUsage(classified) : void 0;
|
|
892
925
|
}
|
|
893
926
|
const source = usage;
|
|
894
927
|
const extracted = {};
|
|
@@ -1195,7 +1228,7 @@ var MUX_AI_DEPENDENCY_STATUS_CODES = {
|
|
|
1195
1228
|
RESPONSE_FAILED: MUX_AI_ERROR_CODES.DEPENDENCY_RESPONSE_FAILED
|
|
1196
1229
|
};
|
|
1197
1230
|
var MUX_AI_DEPENDENCY_STATUS_CODE_VALUES = Object.values(MUX_AI_DEPENDENCY_STATUS_CODES);
|
|
1198
|
-
var
|
|
1231
|
+
var MAX_CAUSE_DEPTH2 = 3;
|
|
1199
1232
|
var MAX_CAUSE_MESSAGE_LENGTH = 500;
|
|
1200
1233
|
function statusOf(value) {
|
|
1201
1234
|
if (typeof value !== "object" || value === null) {
|
|
@@ -1208,9 +1241,9 @@ function statusOf(value) {
|
|
|
1208
1241
|
function summarizeCauses(cause) {
|
|
1209
1242
|
const causes = [];
|
|
1210
1243
|
let current = cause;
|
|
1211
|
-
while (current !== void 0 && current !== null && causes.length <
|
|
1244
|
+
while (current !== void 0 && current !== null && causes.length < MAX_CAUSE_DEPTH2) {
|
|
1212
1245
|
if (ClassifiedError.isClassified(current)) {
|
|
1213
|
-
causes.push(...current.causes.slice(0,
|
|
1246
|
+
causes.push(...current.causes.slice(0, MAX_CAUSE_DEPTH2 - causes.length));
|
|
1214
1247
|
break;
|
|
1215
1248
|
}
|
|
1216
1249
|
const status = statusOf(current);
|
|
@@ -1250,7 +1283,7 @@ var ClassifiedError = class extends Error {
|
|
|
1250
1283
|
}
|
|
1251
1284
|
/** Whether `value` is any classified error, from this copy of the SDK or another. */
|
|
1252
1285
|
static isClassified(value) {
|
|
1253
|
-
return
|
|
1286
|
+
return isClassifiedError(value);
|
|
1254
1287
|
}
|
|
1255
1288
|
};
|
|
1256
1289
|
function serializeClassification(error) {
|
|
@@ -1260,6 +1293,8 @@ function serializeClassification(error) {
|
|
|
1260
1293
|
source: error.source,
|
|
1261
1294
|
...error.dependency && { dependency: error.dependency },
|
|
1262
1295
|
...error.code && { code: error.code },
|
|
1296
|
+
// JSON-safe by type, but not checked at runtime: a value Workflow DevKit can't serialize
|
|
1297
|
+
// would stop the step's failure from being recorded at all.
|
|
1263
1298
|
facts: error.facts,
|
|
1264
1299
|
retryable: error.retryable,
|
|
1265
1300
|
transient: error.transient,
|
|
@@ -1267,7 +1302,41 @@ function serializeClassification(error) {
|
|
|
1267
1302
|
stack: error.stack
|
|
1268
1303
|
};
|
|
1269
1304
|
}
|
|
1305
|
+
function readString2(value) {
|
|
1306
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
1307
|
+
}
|
|
1308
|
+
function readPlainRecord(value) {
|
|
1309
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
1310
|
+
}
|
|
1311
|
+
function readSerializedClassification(record) {
|
|
1312
|
+
const value = readPlainRecord(record) ?? {};
|
|
1313
|
+
const dependency = readString2(value.dependency);
|
|
1314
|
+
const code = readString2(value.code);
|
|
1315
|
+
const stack = readString2(value.stack);
|
|
1316
|
+
const causes = Array.isArray(value.causes) ? value.causes.flatMap((cause) => {
|
|
1317
|
+
const entry = readPlainRecord(cause);
|
|
1318
|
+
const name = readString2(entry?.name);
|
|
1319
|
+
const message = typeof entry?.message === "string" ? entry.message : void 0;
|
|
1320
|
+
if (!name || message === void 0) {
|
|
1321
|
+
return [];
|
|
1322
|
+
}
|
|
1323
|
+
return [{ name, message, ...typeof entry?.status === "number" && { status: entry.status } }];
|
|
1324
|
+
}) : [];
|
|
1325
|
+
return {
|
|
1326
|
+
message: typeof value.message === "string" ? value.message : "Unknown error",
|
|
1327
|
+
type: readString2(value.type) ?? MUX_AI_ERROR_TYPES.SERVER_ERROR,
|
|
1328
|
+
source: readString2(value.source) ?? MUX_AI_ERROR_SOURCES.INTERNAL,
|
|
1329
|
+
...dependency && { dependency },
|
|
1330
|
+
...code && { code },
|
|
1331
|
+
facts: readPlainRecord(value.facts) ?? {},
|
|
1332
|
+
retryable: value.retryable === true,
|
|
1333
|
+
transient: value.transient === true,
|
|
1334
|
+
causes,
|
|
1335
|
+
...stack && { stack }
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1270
1338
|
function classificationInit(record) {
|
|
1339
|
+
record = readSerializedClassification(record);
|
|
1271
1340
|
return {
|
|
1272
1341
|
type: record.type,
|
|
1273
1342
|
source: record.source,
|
|
@@ -1278,6 +1347,7 @@ function classificationInit(record) {
|
|
|
1278
1347
|
};
|
|
1279
1348
|
}
|
|
1280
1349
|
function restoreClassification(error, record) {
|
|
1350
|
+
record = readSerializedClassification(record);
|
|
1281
1351
|
if (record.code) {
|
|
1282
1352
|
Object.assign(error, { code: record.code });
|
|
1283
1353
|
}
|
|
@@ -1309,14 +1379,20 @@ var MuxAiError = class _MuxAiError extends ClassifiedError {
|
|
|
1309
1379
|
};
|
|
1310
1380
|
}
|
|
1311
1381
|
static [WORKFLOW_DESERIALIZE](value) {
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1382
|
+
try {
|
|
1383
|
+
const record = readSerializedClassification(value);
|
|
1384
|
+
const fields = readPlainRecord(value) ?? {};
|
|
1385
|
+
const error = restoreClassification(new _MuxAiError(record.message, classificationInit(record)), record);
|
|
1386
|
+
Object.assign(error, {
|
|
1387
|
+
usage: readPlainRecord(fields.usage),
|
|
1388
|
+
diagnostics: readPlainRecord(fields.diagnostics),
|
|
1389
|
+
...typeof fields.finishReason === "string" && { finishReason: fields.finishReason },
|
|
1390
|
+
...typeof fields.rawFinishReason === "string" && { rawFinishReason: fields.rawFinishReason }
|
|
1391
|
+
});
|
|
1392
|
+
return error;
|
|
1393
|
+
} catch {
|
|
1394
|
+
return new _MuxAiError("Unknown error", { type: MUX_AI_ERROR_TYPES.SERVER_ERROR, source: MUX_AI_ERROR_SOURCES.INTERNAL });
|
|
1395
|
+
}
|
|
1320
1396
|
}
|
|
1321
1397
|
};
|
|
1322
1398
|
function extractErrorDetail(error) {
|
|
@@ -1359,10 +1435,18 @@ function scrubDetail(detail, context) {
|
|
|
1359
1435
|
return "Upstream error details suppressed by safety filter";
|
|
1360
1436
|
}
|
|
1361
1437
|
function wrapError(error, message, facts) {
|
|
1438
|
+
if (isWorkflowControlFlowError(error)) {
|
|
1439
|
+
throw error;
|
|
1440
|
+
}
|
|
1441
|
+
const usage = getErrorTokenUsage(error);
|
|
1442
|
+
error = classifiedErrorOf(error) ?? error;
|
|
1362
1443
|
if (MuxAiError.is(error)) {
|
|
1363
1444
|
if (facts) {
|
|
1364
1445
|
Object.assign(error, { facts: { ...facts, ...error.facts } });
|
|
1365
1446
|
}
|
|
1447
|
+
if (usage) {
|
|
1448
|
+
error.usage = usage;
|
|
1449
|
+
}
|
|
1366
1450
|
throw error;
|
|
1367
1451
|
}
|
|
1368
1452
|
const wrapped = new MuxAiError(`${message}: ${scrubDetail(extractErrorDetail(error), message)}`, {
|
|
@@ -1371,7 +1455,6 @@ function wrapError(error, message, facts) {
|
|
|
1371
1455
|
facts,
|
|
1372
1456
|
cause: error
|
|
1373
1457
|
});
|
|
1374
|
-
const usage = getErrorTokenUsage(error);
|
|
1375
1458
|
if (usage) {
|
|
1376
1459
|
wrapped.usage = usage;
|
|
1377
1460
|
}
|
|
@@ -1428,9 +1511,6 @@ var LegacyMuxAiError = class _LegacyMuxAiError extends MuxAiError {
|
|
|
1428
1511
|
return error;
|
|
1429
1512
|
}
|
|
1430
1513
|
};
|
|
1431
|
-
function isLegacyMuxAiError(value) {
|
|
1432
|
-
return typeof value === "object" && value !== null && "__robots_error" in value && value.__robots_error === true && typeof value.publicMessage === "string";
|
|
1433
|
-
}
|
|
1434
1514
|
function legacyWrapError(error, message) {
|
|
1435
1515
|
if (MuxAiError.is(error) || isLegacyMuxAiError(error)) {
|
|
1436
1516
|
throw error;
|
|
@@ -2844,7 +2924,7 @@ async function fetchTranscriptForAsset(asset, playbackId, options = {}) {
|
|
|
2844
2924
|
try {
|
|
2845
2925
|
result = await fetchTranscriptDataForUrl(transcriptUrl, { cleanTranscript, scope, classifiedErrors });
|
|
2846
2926
|
} catch (error) {
|
|
2847
|
-
if (required) {
|
|
2927
|
+
if (required || isWorkflowControlFlowError(error)) {
|
|
2848
2928
|
throw error;
|
|
2849
2929
|
}
|
|
2850
2930
|
console.warn("Failed to fetch transcript:", error);
|