makefx 1.0.3 → 1.0.4
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 +1 -1
- package/makefx.mjs +112 -12
- package/package.json +1 -1
package/README.md
CHANGED
package/makefx.mjs
CHANGED
|
@@ -7235,8 +7235,8 @@ function validateAudioModeRequiredVoiceOptions(options, mode) {
|
|
|
7235
7235
|
async function executeGenerate(parsed, ctx, client, deps, mediaKind, followOptions = {}) {
|
|
7236
7236
|
const prompt = getPrompt(parsed, "generate");
|
|
7237
7237
|
const outputPath = getOutputPath$1(parsed);
|
|
7238
|
-
const name = requireOption(parsed, "name");
|
|
7239
|
-
const assetType = requireOption(parsed, "type");
|
|
7238
|
+
const name = requireOption$1(parsed, "name");
|
|
7239
|
+
const assetType = requireOption$1(parsed, "type");
|
|
7240
7240
|
const musicProvider = parseMusicProviderOption(parsed, mediaKind, assetType);
|
|
7241
7241
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7242
7242
|
const videoFrameRefs = parseVideoFrameReferenceOptions(parsed, "generate", mediaKind).refs;
|
|
@@ -7331,7 +7331,7 @@ function parseMusicProviderOption(parsed, mediaKind, assetType) {
|
|
|
7331
7331
|
async function executeRefine(parsed, ctx, client, deps, mediaKind) {
|
|
7332
7332
|
const prompt = getPrompt(parsed, "refine");
|
|
7333
7333
|
const outputPath = getOutputPath$1(parsed);
|
|
7334
|
-
const sourceVariantId = requireOption(parsed, "variant");
|
|
7334
|
+
const sourceVariantId = requireOption$1(parsed, "variant");
|
|
7335
7335
|
const state = await requestSpaceState(client);
|
|
7336
7336
|
const sourceVariant = state.variants.find((variant) => variant.id === sourceVariantId);
|
|
7337
7337
|
if (!sourceVariant) throw new Error(`Variant not found in space sync state: ${sourceVariantId}`);
|
|
@@ -7400,10 +7400,10 @@ async function executeRefine(parsed, ctx, client, deps, mediaKind) {
|
|
|
7400
7400
|
async function executeDerive(parsed, ctx, client, deps, mediaKind, followOptions = {}) {
|
|
7401
7401
|
const prompt = getPrompt(parsed, "derive");
|
|
7402
7402
|
const outputPath = getOutputPath$1(parsed);
|
|
7403
|
-
const name = requireOption(parsed, "name");
|
|
7404
|
-
const assetType = requireOption(parsed, "type");
|
|
7403
|
+
const name = requireOption$1(parsed, "name");
|
|
7404
|
+
const assetType = requireOption$1(parsed, "type");
|
|
7405
7405
|
const videoFrameRefs = parseVideoFrameReferenceOptions(parsed, "derive", mediaKind).refs;
|
|
7406
|
-
const refs = parsed.options.refs ? parseRefs(requireOption(parsed, "refs")) : [];
|
|
7406
|
+
const refs = parsed.options.refs ? parseRefs(requireOption$1(parsed, "refs")) : [];
|
|
7407
7407
|
const referenceRefs = videoFrameRefs.length > 0 ? videoFrameRefs : refs;
|
|
7408
7408
|
if (referenceRefs.length === 0) throw new Error("--refs is required");
|
|
7409
7409
|
const imageOptions = parseImageGenerationOptions(parsed, mediaKind);
|
|
@@ -7614,10 +7614,10 @@ function timestampToIso(timestamp) {
|
|
|
7614
7614
|
async function executeBatch(parsed, ctx, client, deps, mediaKind, saveBatchManifest) {
|
|
7615
7615
|
const prompt = getPrompt(parsed, "batch");
|
|
7616
7616
|
const outputDir = getOutputDir(parsed);
|
|
7617
|
-
const name = requireOption(parsed, "name");
|
|
7618
|
-
const assetType = requireOption(parsed, "type");
|
|
7617
|
+
const name = requireOption$1(parsed, "name");
|
|
7618
|
+
const assetType = requireOption$1(parsed, "type");
|
|
7619
7619
|
const musicProvider = parseMusicProviderOption(parsed, mediaKind, assetType);
|
|
7620
|
-
const count = parseBatchCount(requireOption(parsed, "count"));
|
|
7620
|
+
const count = parseBatchCount(requireOption$1(parsed, "count"));
|
|
7621
7621
|
const mode = parseBatchMode(parsed.options.mode || "explore");
|
|
7622
7622
|
const refs = parsed.options.refs ? parseRefs(parsed.options.refs) : [];
|
|
7623
7623
|
const imageOptions = parseImageGenerationOptions(parsed, mediaKind);
|
|
@@ -8205,7 +8205,7 @@ function getOutputExtension(variant, mediaKind) {
|
|
|
8205
8205
|
function isImageManifestMedia(media) {
|
|
8206
8206
|
return media.mediaKind === "image" && Boolean(media.imageKey);
|
|
8207
8207
|
}
|
|
8208
|
-
function requireOption(parsed, name) {
|
|
8208
|
+
function requireOption$1(parsed, name) {
|
|
8209
8209
|
const value = parsed.options[name];
|
|
8210
8210
|
if (!value || value === "true") throw new Error(`--${name} is required`);
|
|
8211
8211
|
return value;
|
|
@@ -8651,8 +8651,10 @@ async function handleAssets(parsed) {
|
|
|
8651
8651
|
}
|
|
8652
8652
|
}
|
|
8653
8653
|
async function executeAssets(parsed, deps = defaultDeps$3) {
|
|
8654
|
-
const ctx = await buildContext$3(parsed, deps);
|
|
8655
8654
|
const subcommand = parsed.positionals[0] || "list";
|
|
8655
|
+
if (subcommand === "search") return searchAssets(parsed, deps);
|
|
8656
|
+
if (subcommand === "clone") return cloneAsset(parsed, deps);
|
|
8657
|
+
const ctx = await buildContext$3(parsed, deps);
|
|
8656
8658
|
if (subcommand === "list") {
|
|
8657
8659
|
const assets = await listAssets(ctx, deps);
|
|
8658
8660
|
if (parsed.options.json === "true") deps.print(JSON.stringify(assets.map(toAssetJson), null, 2));
|
|
@@ -8754,6 +8756,85 @@ async function buildContext$3(parsed, deps) {
|
|
|
8754
8756
|
projectRoot: projectConfig?.projectRoot
|
|
8755
8757
|
};
|
|
8756
8758
|
}
|
|
8759
|
+
async function buildAuthContext(parsed, deps) {
|
|
8760
|
+
const env = resolveCommandEnvironment(parsed, await deps.loadProjectConfig());
|
|
8761
|
+
const config = await deps.loadConfig(env);
|
|
8762
|
+
if (!config) throw new Error(`Not logged in to ${env} environment. Run: ${loginCommandForEnvironment(env)}`);
|
|
8763
|
+
if (config.token.expiresAt < Date.now()) throw new Error(`Token expired for ${env} environment. Run: ${loginCommandForEnvironment(env)}`);
|
|
8764
|
+
if (env === "local") process$1.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
8765
|
+
return {
|
|
8766
|
+
env,
|
|
8767
|
+
baseUrl: deps.resolveBaseUrl(env),
|
|
8768
|
+
accessToken: config.token.accessToken
|
|
8769
|
+
};
|
|
8770
|
+
}
|
|
8771
|
+
function requireOption(parsed, names, usage) {
|
|
8772
|
+
for (const name of names) {
|
|
8773
|
+
const value = normalizeOption(parsed.options[name]);
|
|
8774
|
+
if (value) return value;
|
|
8775
|
+
}
|
|
8776
|
+
throw new Error(usage);
|
|
8777
|
+
}
|
|
8778
|
+
async function searchAssets(parsed, deps) {
|
|
8779
|
+
const ctx = await buildAuthContext(parsed, deps);
|
|
8780
|
+
const query = parsed.positionals.slice(1).join(" ").trim();
|
|
8781
|
+
const params = new URLSearchParams();
|
|
8782
|
+
if (query) params.set("q", query);
|
|
8783
|
+
const mediaKind = normalizeOption(parsed.options.media) ?? normalizeOption(parsed.options["media-kind"]);
|
|
8784
|
+
const assetType = normalizeOption(parsed.options.type);
|
|
8785
|
+
const limit = normalizeOption(parsed.options.limit);
|
|
8786
|
+
if (mediaKind) params.set("media_kind", mediaKind);
|
|
8787
|
+
if (assetType) params.set("type", assetType);
|
|
8788
|
+
if (limit) params.set("limit", limit);
|
|
8789
|
+
const response = await deps.fetch(`${ctx.baseUrl}/api/assets/search?${params.toString()}`, { headers: { Authorization: `Bearer ${ctx.accessToken}` } });
|
|
8790
|
+
if (!response.ok) throw new Error(`Search failed: ${response.status} - ${await response.text()}`);
|
|
8791
|
+
const results = (await response.json()).results ?? [];
|
|
8792
|
+
if (parsed.options.json === "true") deps.print(JSON.stringify(results, null, 2));
|
|
8793
|
+
else printAssetSearchResults(results, deps.print);
|
|
8794
|
+
return {
|
|
8795
|
+
type: "search",
|
|
8796
|
+
results
|
|
8797
|
+
};
|
|
8798
|
+
}
|
|
8799
|
+
async function cloneAsset(parsed, deps) {
|
|
8800
|
+
const ctx = await buildAuthContext(parsed, deps);
|
|
8801
|
+
const sourceVariantId = parsed.positionals[1] ?? normalizeOption(parsed.options.variant);
|
|
8802
|
+
if (!sourceVariantId) throw new Error("Usage: makefx assets clone <variant-id> --from-space <source-space-id> --to-space <target-space-id>");
|
|
8803
|
+
const sourceSpaceId = requireOption(parsed, ["from-space", "source-space"], "Usage: makefx assets clone <variant-id> --from-space <source-space-id> --to-space <target-space-id>");
|
|
8804
|
+
const targetSpaceId = requireOption(parsed, ["to-space", "target-space"], "Usage: makefx assets clone <variant-id> --from-space <source-space-id> --to-space <target-space-id>");
|
|
8805
|
+
const body = {
|
|
8806
|
+
sourceSpaceId,
|
|
8807
|
+
sourceVariantId
|
|
8808
|
+
};
|
|
8809
|
+
const name = normalizeOption(parsed.options.name);
|
|
8810
|
+
const type = normalizeOption(parsed.options.type);
|
|
8811
|
+
if (name) body.name = name;
|
|
8812
|
+
if (type) body.type = type;
|
|
8813
|
+
const response = await deps.fetch(`${ctx.baseUrl}/api/spaces/${encodeURIComponent(targetSpaceId)}/assets/clone`, {
|
|
8814
|
+
method: "POST",
|
|
8815
|
+
headers: {
|
|
8816
|
+
Authorization: `Bearer ${ctx.accessToken}`,
|
|
8817
|
+
"Content-Type": "application/json"
|
|
8818
|
+
},
|
|
8819
|
+
body: JSON.stringify(body)
|
|
8820
|
+
});
|
|
8821
|
+
if (!response.ok) throw new Error(`Clone failed: ${response.status} - ${await response.text()}`);
|
|
8822
|
+
const payload = await response.json();
|
|
8823
|
+
if (parsed.options.json === "true") deps.print(JSON.stringify(payload, null, 2));
|
|
8824
|
+
else {
|
|
8825
|
+
const asset = payload.asset;
|
|
8826
|
+
const variantPayload = payload.variant;
|
|
8827
|
+
const variant = variantPayload?.variant ?? variantPayload;
|
|
8828
|
+
deps.print(`Cloned variant ${sourceVariantId} into space ${targetSpaceId}`);
|
|
8829
|
+
if (asset?.id) deps.print(` Asset: ${asset.id}${asset.name ? ` (${asset.name})` : ""}`);
|
|
8830
|
+
if (variant?.id) deps.print(` Variant: ${variant.id}`);
|
|
8831
|
+
}
|
|
8832
|
+
return {
|
|
8833
|
+
type: "clone",
|
|
8834
|
+
asset: payload.asset,
|
|
8835
|
+
variant: payload.variant
|
|
8836
|
+
};
|
|
8837
|
+
}
|
|
8757
8838
|
async function recordDownloadedMirror(input) {
|
|
8758
8839
|
const variant = input.variant;
|
|
8759
8840
|
if (!variant || !input.deps.recordMirrorForFile) return;
|
|
@@ -8859,6 +8940,19 @@ function printAssetList(assets, print) {
|
|
|
8859
8940
|
print("-".repeat(113));
|
|
8860
8941
|
for (const asset of assets) print(formatTimestamp(asset.updated_at).padEnd(21) + truncate(asset.type || "unknown", 12).padEnd(14) + truncate(asset.media_kind || "-", 7).padEnd(9) + truncate(asset.active_variant_id || "-", 24).padEnd(26) + truncate(asset.id, 26).padEnd(28) + truncate(asset.name, 32));
|
|
8861
8942
|
}
|
|
8943
|
+
function printAssetSearchResults(results, print) {
|
|
8944
|
+
if (results.length === 0) {
|
|
8945
|
+
print("No matching assets found.");
|
|
8946
|
+
return;
|
|
8947
|
+
}
|
|
8948
|
+
for (const result of results) {
|
|
8949
|
+
print(`${result.assetName} (${result.assetId})`);
|
|
8950
|
+
print(` Space: ${result.spaceName} (${result.spaceId})`);
|
|
8951
|
+
print(` Type: ${result.assetType ?? "-"} Media: ${result.mediaKind}`);
|
|
8952
|
+
print(` Active: ${result.activeVariantId ?? "-"}${result.activeVariantStatus ? ` (${result.activeVariantStatus})` : ""}`);
|
|
8953
|
+
print(` Counts: variants=${result.variantCount} completed=${result.completedVariantCount} starred=${result.starredVariantCount}`);
|
|
8954
|
+
}
|
|
8955
|
+
}
|
|
8862
8956
|
function printAssetDetails(details, ctx, print) {
|
|
8863
8957
|
const { asset, variants, lineage } = details;
|
|
8864
8958
|
print(`\nAsset ${asset.id}\n`);
|
|
@@ -8950,9 +9044,11 @@ function printUsage$2() {
|
|
|
8950
9044
|
Usage:
|
|
8951
9045
|
makefx assets
|
|
8952
9046
|
makefx assets --json
|
|
9047
|
+
makefx assets search "query" [--media image|audio|video] [--type <type>] [--json]
|
|
8953
9048
|
makefx assets show <asset-id>
|
|
8954
9049
|
makefx assets show <asset-id> --json
|
|
8955
9050
|
makefx assets download <variant-id|legacy-image-key> -o output-file
|
|
9051
|
+
makefx assets clone <variant-id> --from-space <source-space-id> --to-space <target-space-id>
|
|
8956
9052
|
makefx assets delete <asset-id>
|
|
8957
9053
|
makefx assets rename <asset-id> "<new-name>"
|
|
8958
9054
|
makefx assets set-active <asset-id> <variant-id>
|
|
@@ -9364,7 +9460,7 @@ Options:
|
|
|
9364
9460
|
}
|
|
9365
9461
|
//#endregion
|
|
9366
9462
|
//#region src/cli/index.ts
|
|
9367
|
-
var CLI_VERSION = "1.0.
|
|
9463
|
+
var CLI_VERSION = "1.0.4+20bbdda462d5";
|
|
9368
9464
|
async function main() {
|
|
9369
9465
|
const argv = process$1.argv.slice(2);
|
|
9370
9466
|
if (argv[0] === "--") argv.shift();
|
|
@@ -9551,8 +9647,10 @@ Continue:
|
|
|
9551
9647
|
|
|
9552
9648
|
Inspect:
|
|
9553
9649
|
assets List assets
|
|
9650
|
+
assets search "query" Search assets across Spaces
|
|
9554
9651
|
assets show <asset-id> Show variants and lineage
|
|
9555
9652
|
assets download <variant-id> -o <file> Download variant media
|
|
9653
|
+
assets clone <variant-id> --from-space <id> --to-space <id>
|
|
9556
9654
|
variants rate <variant-id> approved|rejected
|
|
9557
9655
|
variants star <variant-id>
|
|
9558
9656
|
|
|
@@ -9939,9 +10037,11 @@ function printAssetsHelp() {
|
|
|
9939
10037
|
Usage:
|
|
9940
10038
|
makefx assets
|
|
9941
10039
|
makefx assets --json
|
|
10040
|
+
makefx assets search "query" [--media image|audio|video] [--type <type>] [--json]
|
|
9942
10041
|
makefx assets show <asset-id>
|
|
9943
10042
|
makefx assets show <asset-id> --json
|
|
9944
10043
|
makefx assets download <variant-id|legacy-image-key> -o output-file
|
|
10044
|
+
makefx assets clone <variant-id> --from-space <source-space-id> --to-space <target-space-id>
|
|
9945
10045
|
makefx assets delete <asset-id>
|
|
9946
10046
|
makefx assets rename <asset-id> "<new-name>"
|
|
9947
10047
|
makefx assets set-active <asset-id> <variant-id>
|