@mux/ai 0.7.4 → 0.7.5
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-Bavk1Y8-.d.ts → index-B0U9upb4.d.ts} +7 -3
- package/dist/{index-DZlygsvb.d.ts → index-Nxf6BaBO.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +27 -19
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -2
- package/dist/primitives/index.js +11 -8
- package/dist/primitives/index.js.map +1 -1
- package/dist/{types-BQVi_wnh.d.ts → types-BRbaGW3t.d.ts} +2 -0
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +26 -18
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
package/dist/workflows/index.js
CHANGED
|
@@ -424,12 +424,13 @@ function readString(record, key) {
|
|
|
424
424
|
function resolveDirectMuxCredentials(record) {
|
|
425
425
|
const tokenId = readString(record, "muxTokenId");
|
|
426
426
|
const tokenSecret = readString(record, "muxTokenSecret");
|
|
427
|
+
const authorizationToken = readString(record, "muxAuthorizationToken");
|
|
427
428
|
const signingKey = readString(record, "muxSigningKey");
|
|
428
429
|
const privateKey = readString(record, "muxPrivateKey");
|
|
429
|
-
if (!tokenId && !tokenSecret && !signingKey && !privateKey) {
|
|
430
|
+
if (!tokenId && !tokenSecret && !authorizationToken && !signingKey && !privateKey) {
|
|
430
431
|
return void 0;
|
|
431
432
|
}
|
|
432
|
-
if (!tokenId || !tokenSecret) {
|
|
433
|
+
if ((!tokenId || !tokenSecret) && !authorizationToken) {
|
|
433
434
|
throw new Error(
|
|
434
435
|
"Both muxTokenId and muxTokenSecret are required when passing direct Mux workflow credentials."
|
|
435
436
|
);
|
|
@@ -437,6 +438,7 @@ function resolveDirectMuxCredentials(record) {
|
|
|
437
438
|
return {
|
|
438
439
|
tokenId,
|
|
439
440
|
tokenSecret,
|
|
441
|
+
authorizationToken,
|
|
440
442
|
signingKey,
|
|
441
443
|
privateKey
|
|
442
444
|
};
|
|
@@ -447,7 +449,8 @@ function createWorkflowMuxClient(options) {
|
|
|
447
449
|
const { default: MuxClient } = await import("@mux/mux-node");
|
|
448
450
|
return new MuxClient({
|
|
449
451
|
tokenId: options.tokenId,
|
|
450
|
-
tokenSecret: options.tokenSecret
|
|
452
|
+
tokenSecret: options.tokenSecret,
|
|
453
|
+
authorizationToken: options.authorizationToken
|
|
451
454
|
});
|
|
452
455
|
},
|
|
453
456
|
getSigningKey() {
|
|
@@ -856,9 +859,9 @@ async function signPlaybackId(playbackId, context, type = "video", params) {
|
|
|
856
859
|
params: stringParams
|
|
857
860
|
});
|
|
858
861
|
}
|
|
859
|
-
async function signUrl(url, playbackId,
|
|
862
|
+
async function signUrl(url, playbackId, type = "video", params, credentials) {
|
|
860
863
|
"use step";
|
|
861
|
-
const resolvedContext =
|
|
864
|
+
const resolvedContext = await resolveMuxSigningContext(credentials);
|
|
862
865
|
if (!resolvedContext) {
|
|
863
866
|
throw new Error(
|
|
864
867
|
"Signed playback ID requires signing credentials. Provide muxSigningKey and muxPrivateKey via workflow credentials or set MUX_SIGNING_KEY and MUX_PRIVATE_KEY environment variables."
|
|
@@ -875,7 +878,7 @@ async function getStoryboardUrl(playbackId, width = DEFAULT_STORYBOARD_WIDTH, sh
|
|
|
875
878
|
"use step";
|
|
876
879
|
const baseUrl = `https://image.mux.com/${playbackId}/storyboard.png`;
|
|
877
880
|
if (shouldSign) {
|
|
878
|
-
return signUrl(baseUrl, playbackId,
|
|
881
|
+
return signUrl(baseUrl, playbackId, "storyboard", { width }, credentials);
|
|
879
882
|
}
|
|
880
883
|
return `${baseUrl}?width=${width}`;
|
|
881
884
|
}
|
|
@@ -992,7 +995,7 @@ async function buildTranscriptUrl(playbackId, trackId, shouldSign = false, crede
|
|
|
992
995
|
"use step";
|
|
993
996
|
const baseUrl = `https://stream.mux.com/${playbackId}/text/${trackId}.vtt`;
|
|
994
997
|
if (shouldSign) {
|
|
995
|
-
return signUrl(baseUrl, playbackId,
|
|
998
|
+
return signUrl(baseUrl, playbackId, "video", void 0, credentials);
|
|
996
999
|
}
|
|
997
1000
|
return baseUrl;
|
|
998
1001
|
}
|
|
@@ -2085,7 +2088,7 @@ async function getThumbnailUrls(playbackId, duration, options = {}) {
|
|
|
2085
2088
|
const baseUrl = `https://image.mux.com/${playbackId}/thumbnail.png`;
|
|
2086
2089
|
const urlPromises = timestamps.map(async (time) => {
|
|
2087
2090
|
if (shouldSign) {
|
|
2088
|
-
return signUrl(baseUrl, playbackId,
|
|
2091
|
+
return signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials);
|
|
2089
2092
|
}
|
|
2090
2093
|
return `${baseUrl}?time=${time}&width=${width}`;
|
|
2091
2094
|
});
|
|
@@ -2101,11 +2104,10 @@ var DEFAULT_PROVIDER2 = "openai";
|
|
|
2101
2104
|
var HIVE_ENDPOINT = "https://api.thehive.ai/api/v2/task/sync";
|
|
2102
2105
|
var HIVE_SEXUAL_CATEGORIES = [
|
|
2103
2106
|
"general_nsfw",
|
|
2104
|
-
"general_suggestive",
|
|
2105
2107
|
"yes_sexual_activity",
|
|
2106
|
-
"
|
|
2107
|
-
"
|
|
2108
|
-
"
|
|
2108
|
+
"yes_sex_toy",
|
|
2109
|
+
"yes_female_nudity",
|
|
2110
|
+
"yes_male_nudity"
|
|
2109
2111
|
];
|
|
2110
2112
|
var HIVE_VIOLENCE_CATEGORIES = [
|
|
2111
2113
|
"gun_in_hand",
|
|
@@ -2116,10 +2118,8 @@ var HIVE_VIOLENCE_CATEGORIES = [
|
|
|
2116
2118
|
"hanging",
|
|
2117
2119
|
"noose",
|
|
2118
2120
|
"human_corpse",
|
|
2119
|
-
"
|
|
2120
|
-
"
|
|
2121
|
-
"animal_abuse",
|
|
2122
|
-
"fights",
|
|
2121
|
+
"yes_emaciated_body",
|
|
2122
|
+
"yes_self_harm",
|
|
2123
2123
|
"garm_death_injury_or_military_conflict"
|
|
2124
2124
|
];
|
|
2125
2125
|
async function processConcurrently(items, processor, maxConcurrent = 5) {
|
|
@@ -2263,6 +2263,12 @@ function getHiveCategoryScores(classes, categoryNames) {
|
|
|
2263
2263
|
const scoreMap = Object.fromEntries(
|
|
2264
2264
|
classes.map((c) => [c.class, c.score])
|
|
2265
2265
|
);
|
|
2266
|
+
const missingCategories = categoryNames.filter((category) => !(category in scoreMap));
|
|
2267
|
+
if (missingCategories.length > 0) {
|
|
2268
|
+
console.warn(
|
|
2269
|
+
`Hive response missing expected categories: ${missingCategories.join(", ")}`
|
|
2270
|
+
);
|
|
2271
|
+
}
|
|
2266
2272
|
const scores = categoryNames.map((category) => scoreMap[category] || 0);
|
|
2267
2273
|
return Math.max(...scores, 0);
|
|
2268
2274
|
}
|
|
@@ -2360,7 +2366,7 @@ async function getThumbnailUrlsFromTimestamps(playbackId, timestampsMs, options)
|
|
|
2360
2366
|
const urlPromises = timestampsMs.map(async (tsMs) => {
|
|
2361
2367
|
const time = Number((tsMs / 1e3).toFixed(2));
|
|
2362
2368
|
if (shouldSign) {
|
|
2363
|
-
return signUrl(baseUrl, playbackId,
|
|
2369
|
+
return signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials);
|
|
2364
2370
|
}
|
|
2365
2371
|
return `${baseUrl}?time=${time}&width=${width}`;
|
|
2366
2372
|
});
|
|
@@ -3633,7 +3639,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
3633
3639
|
}
|
|
3634
3640
|
let audioUrl = `https://stream.mux.com/${playbackId}/audio.m4a`;
|
|
3635
3641
|
if (policy === "signed") {
|
|
3636
|
-
audioUrl = await signUrl(audioUrl, playbackId,
|
|
3642
|
+
audioUrl = await signUrl(audioUrl, playbackId, "video", void 0, credentials);
|
|
3637
3643
|
}
|
|
3638
3644
|
console.warn("\u{1F399}\uFE0F Fetching audio from Mux...");
|
|
3639
3645
|
let audioBuffer;
|
|
@@ -4013,6 +4019,8 @@ async function translateCaptions(assetId, fromLanguageCode, toLanguageCode, opti
|
|
|
4013
4019
|
};
|
|
4014
4020
|
}
|
|
4015
4021
|
export {
|
|
4022
|
+
HIVE_SEXUAL_CATEGORIES,
|
|
4023
|
+
HIVE_VIOLENCE_CATEGORIES,
|
|
4016
4024
|
SUMMARY_KEYWORD_LIMIT,
|
|
4017
4025
|
askQuestions,
|
|
4018
4026
|
burnedInCaptionsSchema,
|