@nodetool-ai/topaz-nodes 0.8.1
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 +36 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/topaz-base.d.ts +72 -0
- package/dist/topaz-base.d.ts.map +1 -0
- package/dist/topaz-base.js +392 -0
- package/dist/topaz-base.js.map +1 -0
- package/dist/topaz-factory.d.ts +43 -0
- package/dist/topaz-factory.d.ts.map +1 -0
- package/dist/topaz-factory.js +163 -0
- package/dist/topaz-factory.js.map +1 -0
- package/dist/topaz-manifest.json +1084 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @nodetool-ai/topaz-nodes
|
|
2
|
+
|
|
3
|
+
Topaz Labs image and video enhancement nodes for [NodeTool](https://nodetool.ai).
|
|
4
|
+
|
|
5
|
+
Run the [Topaz Labs](https://www.topazlabs.com) API inside NodeTool workflows: upscale, sharpen, denoise, restore, and matte images, plus enhance and frame-interpolate video.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @nodetool-ai/topaz-nodes
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Nodes
|
|
14
|
+
|
|
15
|
+
| Node | Type | Description |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| Topaz Enhance Image | `topaz.image.EnhanceImage` | Precision upscale and enhance with Topaz models. |
|
|
18
|
+
| Topaz Enhance Image (Generative) | `topaz.image.EnhanceImageGenerative` | Generative upscale and enhance. |
|
|
19
|
+
| Topaz Sharpen Image | `topaz.image.SharpenImage` | Sharpen and deblur. |
|
|
20
|
+
| Topaz Sharpen Image (Generative) | `topaz.image.SharpenImageGenerative` | Generative sharpen. |
|
|
21
|
+
| Topaz Denoise Image | `topaz.image.DenoiseImage` | Remove noise. |
|
|
22
|
+
| Topaz Denoise Image (Generative) | `topaz.image.DenoiseImageGenerative` | Generative denoise. |
|
|
23
|
+
| Topaz Adjust Lighting | `topaz.image.AdjustLighting` | Adjust image lighting. |
|
|
24
|
+
| Topaz Restore Image | `topaz.image.RestoreImage` | Restore degraded images. |
|
|
25
|
+
| Topaz Matte Image | `topaz.image.MatteImage` | Generate a subject matte. |
|
|
26
|
+
| Topaz Enhance Video | `topaz.video.EnhanceVideo` | Upscale and enhance video. |
|
|
27
|
+
| Topaz Interpolate Video | `topaz.video.InterpolateVideo` | Interpolate frames for higher frame rate. |
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
Set `TOPAZ_API_KEY` in NodeTool's secret store (Settings → API Keys) or as an environment variable.
|
|
32
|
+
|
|
33
|
+
## Links
|
|
34
|
+
|
|
35
|
+
- [NodeTool](https://nodetool.ai)
|
|
36
|
+
- [GitHub](https://github.com/nodetool-ai/nodetool)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2026-09-28T09:19:09.718Z
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NodeClass } from "@nodetool-ai/node-sdk";
|
|
2
|
+
export { loadTopazNodesFromManifest, createTopazNodeClass } from "./topaz-factory.js";
|
|
3
|
+
export type { TopazManifestEntry, TopazFieldDef } from "./topaz-factory.js";
|
|
4
|
+
export { getApiKey, refToBytes, probeVideoMetadata, topazImageRef, topazExecuteImageTask, topazExecuteVideoTask, sourceContainerFromRef, containerContentType } from "./topaz-base.js";
|
|
5
|
+
export type { TopazImageSpec, TopazVideoSpec, TopazVideoMetadata } from "./topaz-base.js";
|
|
6
|
+
export declare const TOPAZ_NODES: readonly NodeClass[];
|
|
7
|
+
export declare function registerTopazNodes(registry: {
|
|
8
|
+
register: (nodeClass: NodeClass) => void;
|
|
9
|
+
}): void;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EACL,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AASzB,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAE3C,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE;IAC3C,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;CAC1C,GAAG,IAAI,CAIP"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { loadPackageAssetJson } from "@nodetool-ai/config";
|
|
2
|
+
import { loadTopazNodesFromManifest } from "./topaz-factory.js";
|
|
3
|
+
export { loadTopazNodesFromManifest, createTopazNodeClass } from "./topaz-factory.js";
|
|
4
|
+
export { getApiKey, refToBytes, probeVideoMetadata, topazImageRef, topazExecuteImageTask, topazExecuteVideoTask, sourceContainerFromRef, containerContentType } from "./topaz-base.js";
|
|
5
|
+
function loadManifest() {
|
|
6
|
+
return loadPackageAssetJson({ pkg: "@nodetool-ai/topaz-nodes", path: "topaz-manifest.json" }, import.meta.url);
|
|
7
|
+
}
|
|
8
|
+
export const TOPAZ_NODES = loadTopazNodesFromManifest(loadManifest());
|
|
9
|
+
export function registerTopazNodes(registry) {
|
|
10
|
+
for (const nodeClass of TOPAZ_NODES) {
|
|
11
|
+
registry.register(nodeClass);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAGhE,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAOzB,SAAS,YAAY;IACnB,OAAO,oBAAoB,CACzB,EAAE,GAAG,EAAE,0BAA0B,EAAE,IAAI,EAAE,qBAAqB,EAAE,EAChE,OAAO,IAAI,CAAC,GAAG,CAChB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAyB,0BAA0B,CACzE,YAAY,EAAE,CACf,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAAC,QAElC;IACC,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE,CAAC;QACpC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Topaz Labs API utilities.
|
|
3
|
+
*
|
|
4
|
+
* Two execution flows:
|
|
5
|
+
* - Image: multipart POST → poll status → GET download URL → fetch bytes.
|
|
6
|
+
* - Video: create job (with probed source metadata) → accept → PUT upload
|
|
7
|
+
* (single- or multi-part) → complete-upload → poll status → download.
|
|
8
|
+
*
|
|
9
|
+
* Wire spec (from developer.topazlabs.com/reference/api-endpoints):
|
|
10
|
+
* - Auth: `X-API-Key` header (not Bearer).
|
|
11
|
+
* - Image status states: Pending | Processing | Completed | Cancelled | Failed.
|
|
12
|
+
* - Image download response: { download_url, head_url, expiry }.
|
|
13
|
+
* - Video status states: requested | accepted | initializing | preprocessing
|
|
14
|
+
* | processing | postprocessing | complete | canceling | canceled | failed.
|
|
15
|
+
* - Video accept response: { uploadId, urls[] }. The signed download URL on a
|
|
16
|
+
* completed video request lives at `download.url` (nested).
|
|
17
|
+
*
|
|
18
|
+
* Uses native fetch (Node 18+) and the system `ffprobe` (installed via the
|
|
19
|
+
* package manager) to probe source video metadata, which Topaz requires at
|
|
20
|
+
* job-creation time.
|
|
21
|
+
*/
|
|
22
|
+
import type { ProcessingContext } from "@nodetool-ai/runtime";
|
|
23
|
+
import { imageRefFromBytes } from "@nodetool-ai/runtime/provider-transport";
|
|
24
|
+
export type TopazVideoKind = "upscale" | "interpolate";
|
|
25
|
+
export interface TopazImageSpec {
|
|
26
|
+
submitEndpoint: string;
|
|
27
|
+
statusEndpoint: string;
|
|
28
|
+
downloadEndpoint: string;
|
|
29
|
+
pollInterval: number;
|
|
30
|
+
maxAttempts: number;
|
|
31
|
+
}
|
|
32
|
+
export interface TopazVideoSpec {
|
|
33
|
+
submitEndpoint: string;
|
|
34
|
+
acceptEndpoint: string;
|
|
35
|
+
completeEndpoint: string;
|
|
36
|
+
statusEndpoint: string;
|
|
37
|
+
pollInterval: number;
|
|
38
|
+
maxAttempts: number;
|
|
39
|
+
videoKind: TopazVideoKind;
|
|
40
|
+
}
|
|
41
|
+
export interface TopazVideoMetadata {
|
|
42
|
+
resolution: {
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
};
|
|
46
|
+
container: string;
|
|
47
|
+
size: number;
|
|
48
|
+
duration: number;
|
|
49
|
+
frameRate: number;
|
|
50
|
+
frameCount: number;
|
|
51
|
+
}
|
|
52
|
+
export declare function containerContentType(container: string | null | undefined): string;
|
|
53
|
+
/**
|
|
54
|
+
* Derive the source container (file extension, no leading dot) from a VideoRef.
|
|
55
|
+
* Prefers an explicit `format` field, then the URI extension, then `mp4`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function sourceContainerFromRef(ref: unknown): string;
|
|
58
|
+
export declare function getApiKey(secrets: Record<string, string>): string;
|
|
59
|
+
/**
|
|
60
|
+
* Resolve an asset ref to raw bytes. Delegates to the canonical
|
|
61
|
+
* {@link loadMediaRefBytes}, which — unlike the copy this replaced — checks
|
|
62
|
+
* `data.length > 0` rather than bare truthiness (a zero-length `Uint8Array` is
|
|
63
|
+
* truthy and shadowed a perfectly good `uri`) and resolves an `asset_id`-only
|
|
64
|
+
* ref. Throws rather than returning null: every caller here needs the bytes.
|
|
65
|
+
*/
|
|
66
|
+
export declare function refToBytes(ref: unknown, context?: ProcessingContext): Promise<Uint8Array>;
|
|
67
|
+
/** Image result → ImageRef (with sharp metadata when available). */
|
|
68
|
+
export declare const topazImageRef: typeof imageRefFromBytes;
|
|
69
|
+
export declare function probeVideoMetadata(bytes: Uint8Array, container?: string): Promise<TopazVideoMetadata>;
|
|
70
|
+
export declare function topazExecuteImageTask(apiKey: string, spec: TopazImageSpec, fields: Record<string, unknown>, imageBytes: Uint8Array): Promise<Uint8Array>;
|
|
71
|
+
export declare function topazExecuteVideoTask(apiKey: string, spec: TopazVideoSpec, fields: Record<string, unknown>, videoBytes: Uint8Array, sourceMeta: TopazVideoMetadata): Promise<Uint8Array>;
|
|
72
|
+
//# sourceMappingURL=topaz-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topaz-base.d.ts","sourceRoot":"","sources":["../src/topaz-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AASH,OAAO,KAAK,EAAiB,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAEL,iBAAiB,EAElB,MAAM,yCAAyC,CAAC;AAIjD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,aAAa,CAAC;A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AC,kBAAkB,CAAC,CAoD7B;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,UAAU,CAAC,CA6DrB;AA0GD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,kBAAkB,GAC7B,OAAO,CAAC,UAAU,CAAC,CAkHrB"}
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Topaz Labs API utilities.
|
|
3
|
+
*
|
|
4
|
+
* Two execution flows:
|
|
5
|
+
* - Image: multipart POST → poll status → GET download URL → fetch bytes.
|
|
6
|
+
* - Video: create job (with probed source metadata) → accept → PUT upload
|
|
7
|
+
* (single- or multi-part) → complete-upload → poll status → download.
|
|
8
|
+
*
|
|
9
|
+
* Wire spec (from developer.topazlabs.com/reference/api-endpoints):
|
|
10
|
+
* - Auth: `X-API-Key` header (not Bearer).
|
|
11
|
+
* - Image status states: Pending | Processing | Completed | Cancelled | Failed.
|
|
12
|
+
* - Image download response: { download_url, head_url, expiry }.
|
|
13
|
+
* - Video status states: requested | accepted | initializing | preprocessing
|
|
14
|
+
* | processing | postprocessing | complete | canceling | canceled | failed.
|
|
15
|
+
* - Video accept response: { uploadId, urls[] }. The signed download URL on a
|
|
16
|
+
* completed video request lives at `download.url` (nested).
|
|
17
|
+
*
|
|
18
|
+
* Uses native fetch (Node 18+) and the system `ffprobe` (installed via the
|
|
19
|
+
* package manager) to probe source video metadata, which Topaz requires at
|
|
20
|
+
* job-creation time.
|
|
21
|
+
*/
|
|
22
|
+
import { execFile as execFileCb } from "node:child_process";
|
|
23
|
+
import { promises as fs } from "node:fs";
|
|
24
|
+
import os from "node:os";
|
|
25
|
+
import path from "node:path";
|
|
26
|
+
import { promisify } from "node:util";
|
|
27
|
+
import { loadMediaRefBytes, safeFetch, sniffImageMime } from "@nodetool-ai/runtime";
|
|
28
|
+
import { fetchWithRetry, imageRefFromBytes, pollUntilTerminal } from "@nodetool-ai/runtime/provider-transport";
|
|
29
|
+
const execFile = promisify(execFileCb);
|
|
30
|
+
const CONTAINER_CONTENT_TYPES = {
|
|
31
|
+
mp4: "video/mp4",
|
|
32
|
+
m4v: "video/mp4",
|
|
33
|
+
mov: "video/quicktime",
|
|
34
|
+
mkv: "video/x-matroska",
|
|
35
|
+
webm: "video/webm",
|
|
36
|
+
avi: "video/x-msvideo"
|
|
37
|
+
};
|
|
38
|
+
export function containerContentType(container) {
|
|
39
|
+
if (!container)
|
|
40
|
+
return "application/octet-stream";
|
|
41
|
+
const key = container.replace(/^\./, "").toLowerCase();
|
|
42
|
+
return CONTAINER_CONTENT_TYPES[key] ?? "application/octet-stream";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Derive the source container (file extension, no leading dot) from a VideoRef.
|
|
46
|
+
* Prefers an explicit `format` field, then the URI extension, then `mp4`.
|
|
47
|
+
*/
|
|
48
|
+
export function sourceContainerFromRef(ref) {
|
|
49
|
+
if (!ref || typeof ref !== "object")
|
|
50
|
+
return "mp4";
|
|
51
|
+
const r = ref;
|
|
52
|
+
if (r.format)
|
|
53
|
+
return r.format.replace(/^\./, "").toLowerCase();
|
|
54
|
+
if (r.uri) {
|
|
55
|
+
const m = r.uri.match(/\.(mp4|m4v|mov|mkv|webm|avi)(?:[?#]|$)/i);
|
|
56
|
+
if (m)
|
|
57
|
+
return m[1].toLowerCase();
|
|
58
|
+
}
|
|
59
|
+
return "mp4";
|
|
60
|
+
}
|
|
61
|
+
export function getApiKey(secrets) {
|
|
62
|
+
const key = secrets?.TOPAZ_API_KEY || process.env.TOPAZ_API_KEY || "";
|
|
63
|
+
if (!key)
|
|
64
|
+
throw new Error("TOPAZ_API_KEY is not configured");
|
|
65
|
+
return key;
|
|
66
|
+
}
|
|
67
|
+
function authHeaders(apiKey, extra = {}) {
|
|
68
|
+
return { "X-API-Key": apiKey, ...extra };
|
|
69
|
+
}
|
|
70
|
+
// Image API status states (per /reference/api-endpoints/image/status):
|
|
71
|
+
// Pending | Processing | Completed | Cancelled | Failed
|
|
72
|
+
// Video API status states (per /reference/api-endpoints/video/get-request-status):
|
|
73
|
+
// requested | accepted | initializing | preprocessing | processing |
|
|
74
|
+
// postprocessing | complete | canceling | canceled | failed
|
|
75
|
+
// Both vocabularies are covered by the shared terminal-state sets; callers point
|
|
76
|
+
// us at the right endpoint and the status is lowercased before comparison.
|
|
77
|
+
async function pollTopazStatus(url, headers, pollInterval, maxAttempts) {
|
|
78
|
+
return pollUntilTerminal(async () => {
|
|
79
|
+
const resp = await fetchWithRetry(url, { headers });
|
|
80
|
+
if (!resp.ok)
|
|
81
|
+
throw new Error(`Topaz status poll failed: ${resp.status}`);
|
|
82
|
+
return (await resp.json());
|
|
83
|
+
}, {
|
|
84
|
+
intervalMs: pollInterval,
|
|
85
|
+
maxAttempts,
|
|
86
|
+
onFailure: (data) => new Error(`Topaz job failed: ${JSON.stringify(data)}`),
|
|
87
|
+
onTimeout: () => new Error(`Topaz job did not complete within ${maxAttempts} poll attempts`)
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Resolve an asset ref to raw bytes. Delegates to the canonical
|
|
92
|
+
* {@link loadMediaRefBytes}, which — unlike the copy this replaced — checks
|
|
93
|
+
* `data.length > 0` rather than bare truthiness (a zero-length `Uint8Array` is
|
|
94
|
+
* truthy and shadowed a perfectly good `uri`) and resolves an `asset_id`-only
|
|
95
|
+
* ref. Throws rather than returning null: every caller here needs the bytes.
|
|
96
|
+
*/
|
|
97
|
+
export async function refToBytes(ref, context) {
|
|
98
|
+
if (!ref || typeof ref !== "object") {
|
|
99
|
+
throw new Error("Asset is required");
|
|
100
|
+
}
|
|
101
|
+
const bytes = await loadMediaRefBytes(ref, context);
|
|
102
|
+
if (!bytes)
|
|
103
|
+
throw new Error("Asset has no data or URI");
|
|
104
|
+
return bytes;
|
|
105
|
+
}
|
|
106
|
+
/** Image result → ImageRef (with sharp metadata when available). */
|
|
107
|
+
export const topazImageRef = imageRefFromBytes;
|
|
108
|
+
function parseFrameRate(raw) {
|
|
109
|
+
if (typeof raw !== "string" || !raw)
|
|
110
|
+
return 0;
|
|
111
|
+
const [num, den] = raw.split("/");
|
|
112
|
+
const n = Number(num);
|
|
113
|
+
const d = den === undefined ? 1 : Number(den);
|
|
114
|
+
if (!Number.isFinite(n) || !Number.isFinite(d) || d === 0)
|
|
115
|
+
return 0;
|
|
116
|
+
return n / d;
|
|
117
|
+
}
|
|
118
|
+
async function withTempFile(bytes, suffix, fn) {
|
|
119
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "nodetool-topaz-"));
|
|
120
|
+
const file = path.join(dir, `input${suffix}`);
|
|
121
|
+
await fs.writeFile(file, bytes);
|
|
122
|
+
try {
|
|
123
|
+
return await fn(file);
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export async function probeVideoMetadata(bytes, container = "mp4") {
|
|
130
|
+
return withTempFile(bytes, `.${container}`, async (filePath) => {
|
|
131
|
+
let stdout;
|
|
132
|
+
try {
|
|
133
|
+
({ stdout } = await execFile("ffprobe", [
|
|
134
|
+
"-v",
|
|
135
|
+
"error",
|
|
136
|
+
"-show_entries",
|
|
137
|
+
"format=duration,format_name,size:stream=width,height,avg_frame_rate,nb_frames,codec_type",
|
|
138
|
+
"-of",
|
|
139
|
+
"json",
|
|
140
|
+
filePath
|
|
141
|
+
]));
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
throw new Error("Failed to probe video metadata with ffprobe. Ensure ffmpeg is " +
|
|
145
|
+
`installed (the Package Manager UI can do this for you). ${String(err)}`);
|
|
146
|
+
}
|
|
147
|
+
const probe = JSON.parse(stdout);
|
|
148
|
+
const video = (probe.streams ?? []).find((s) => s.codec_type === "video");
|
|
149
|
+
if (!video || !video.width || !video.height) {
|
|
150
|
+
throw new Error("ffprobe did not report a video stream with dimensions");
|
|
151
|
+
}
|
|
152
|
+
const duration = Number(probe.format?.duration ?? 0) || 0;
|
|
153
|
+
const frameRate = parseFrameRate(video.avg_frame_rate);
|
|
154
|
+
const frameCount = Number(video.nb_frames ?? 0) || Math.round(duration * frameRate);
|
|
155
|
+
return {
|
|
156
|
+
resolution: { width: video.width, height: video.height },
|
|
157
|
+
container,
|
|
158
|
+
size: Number(probe.format?.size ?? bytes.byteLength) || bytes.byteLength,
|
|
159
|
+
duration,
|
|
160
|
+
frameRate,
|
|
161
|
+
frameCount
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
export async function topazExecuteImageTask(apiKey, spec, fields, imageBytes) {
|
|
166
|
+
const form = new FormData();
|
|
167
|
+
const blob = new Blob([new Uint8Array(imageBytes)], { type: sniffImageMime(imageBytes) ?? "application/octet-stream" });
|
|
168
|
+
form.set("image", blob, "input");
|
|
169
|
+
for (const [k, v] of Object.entries(fields)) {
|
|
170
|
+
if (v === null || v === undefined || v === "")
|
|
171
|
+
continue;
|
|
172
|
+
// 0 for output_width/output_height means "infer from the other dim" — omit.
|
|
173
|
+
if ((k === "output_width" || k === "output_height") && v === 0)
|
|
174
|
+
continue;
|
|
175
|
+
form.set(k, String(v));
|
|
176
|
+
}
|
|
177
|
+
const submit = await fetchWithRetry(spec.submitEndpoint, {
|
|
178
|
+
method: "POST",
|
|
179
|
+
headers: authHeaders(apiKey),
|
|
180
|
+
body: form
|
|
181
|
+
});
|
|
182
|
+
if (!submit.ok) {
|
|
183
|
+
throw new Error(`Topaz submit failed: ${submit.status} ${await submit.text()}`);
|
|
184
|
+
}
|
|
185
|
+
// Spec returns { process_id, source_id, eta }. The process_id is also
|
|
186
|
+
// available in the X-Process-ID response header.
|
|
187
|
+
const submitJson = (await submit.json());
|
|
188
|
+
const processId = submitJson.process_id ??
|
|
189
|
+
submit.headers?.get("X-Process-ID") ??
|
|
190
|
+
undefined;
|
|
191
|
+
if (!processId) {
|
|
192
|
+
throw new Error(`Topaz did not return a process_id: ${JSON.stringify(submitJson)}`);
|
|
193
|
+
}
|
|
194
|
+
const statusUrl = spec.statusEndpoint.replace("{process_id}", processId);
|
|
195
|
+
await pollTopazStatus(statusUrl, authHeaders(apiKey), spec.pollInterval, spec.maxAttempts);
|
|
196
|
+
// Spec: { download_url, head_url, expiry }.
|
|
197
|
+
const downloadUrl = spec.downloadEndpoint.replace("{process_id}", processId);
|
|
198
|
+
const dl = await fetchWithRetry(downloadUrl, { headers: authHeaders(apiKey) });
|
|
199
|
+
if (!dl.ok)
|
|
200
|
+
throw new Error(`Topaz download lookup failed: ${dl.status}`);
|
|
201
|
+
const dlJson = (await dl.json());
|
|
202
|
+
const finalUrl = (dlJson.download_url ?? dlJson.url);
|
|
203
|
+
if (!finalUrl) {
|
|
204
|
+
throw new Error(`No download URL in response: ${JSON.stringify(dlJson)}`);
|
|
205
|
+
}
|
|
206
|
+
// Provider-returned download URL — screened like every other one.
|
|
207
|
+
const result = await safeFetch(finalUrl);
|
|
208
|
+
if (!result.ok) {
|
|
209
|
+
throw new Error(`Failed to fetch Topaz result: ${result.status}`);
|
|
210
|
+
}
|
|
211
|
+
return new Uint8Array(await result.arrayBuffer());
|
|
212
|
+
}
|
|
213
|
+
const INTERPOLATION_MODELS = new Set([
|
|
214
|
+
"apf-2",
|
|
215
|
+
"apo-8",
|
|
216
|
+
"chf-3",
|
|
217
|
+
"chr-2",
|
|
218
|
+
"aion-1"
|
|
219
|
+
]);
|
|
220
|
+
const AUDIO_MODE_MAP = {
|
|
221
|
+
copy: { audioTransfer: "Copy", audioCodec: "AAC" },
|
|
222
|
+
aac: { audioTransfer: "Convert", audioCodec: "AAC" },
|
|
223
|
+
ac3: { audioTransfer: "Convert", audioCodec: "AC3" },
|
|
224
|
+
pcm: { audioTransfer: "Convert", audioCodec: "PCM" },
|
|
225
|
+
none: { audioTransfer: "None" }
|
|
226
|
+
};
|
|
227
|
+
function num(value) {
|
|
228
|
+
if (value === null || value === undefined || value === "")
|
|
229
|
+
return undefined;
|
|
230
|
+
const n = Number(value);
|
|
231
|
+
return Number.isFinite(n) ? n : undefined;
|
|
232
|
+
}
|
|
233
|
+
function buildUpscaleFilter(fields) {
|
|
234
|
+
const filter = { model: String(fields.model) };
|
|
235
|
+
if (fields.video_type)
|
|
236
|
+
filter.videoType = String(fields.video_type);
|
|
237
|
+
if (fields.auto)
|
|
238
|
+
filter.auto = String(fields.auto);
|
|
239
|
+
// Manual-mode tuning. The API ignores out-of-range or unsupported values
|
|
240
|
+
// for a given model — the swagger says these are the documented controls.
|
|
241
|
+
const numericMap = {
|
|
242
|
+
compression: "compression",
|
|
243
|
+
details: "details",
|
|
244
|
+
noise: "noise",
|
|
245
|
+
halo: "halo",
|
|
246
|
+
blur: "blur",
|
|
247
|
+
recover_original_detail: "recoverOriginalDetailValue"
|
|
248
|
+
};
|
|
249
|
+
for (const [src, dst] of Object.entries(numericMap)) {
|
|
250
|
+
const v = num(fields[src]);
|
|
251
|
+
if (v !== undefined && v !== 0)
|
|
252
|
+
filter[dst] = v;
|
|
253
|
+
}
|
|
254
|
+
return filter;
|
|
255
|
+
}
|
|
256
|
+
function buildInterpolationFilter(fields) {
|
|
257
|
+
const filter = { model: String(fields.model) };
|
|
258
|
+
const slowmo = num(fields.slowmo);
|
|
259
|
+
if (slowmo !== undefined && slowmo !== 1)
|
|
260
|
+
filter.slowmo = slowmo;
|
|
261
|
+
const fps = num(fields.fps);
|
|
262
|
+
if (fps !== undefined && fps > 0)
|
|
263
|
+
filter.fps = fps;
|
|
264
|
+
if (fields.duplicate)
|
|
265
|
+
filter.duplicate = true;
|
|
266
|
+
const threshold = num(fields.duplicate_threshold);
|
|
267
|
+
if (threshold !== undefined && fields.duplicate) {
|
|
268
|
+
filter.duplicateThreshold = threshold;
|
|
269
|
+
}
|
|
270
|
+
return filter;
|
|
271
|
+
}
|
|
272
|
+
function buildVideoFilters(spec, fields) {
|
|
273
|
+
if (spec.videoKind === "interpolate") {
|
|
274
|
+
return [buildInterpolationFilter(fields)];
|
|
275
|
+
}
|
|
276
|
+
// Default to upscale when the model code is a known upscale model.
|
|
277
|
+
if (INTERPOLATION_MODELS.has(String(fields.model))) {
|
|
278
|
+
// Caller wired a frame-interpolation model into the Enhance node. Build
|
|
279
|
+
// the appropriate filter so the API call still succeeds.
|
|
280
|
+
return [buildInterpolationFilter(fields)];
|
|
281
|
+
}
|
|
282
|
+
return [buildUpscaleFilter(fields)];
|
|
283
|
+
}
|
|
284
|
+
function buildVideoOutput(fields, sourceMeta) {
|
|
285
|
+
const audioMode = String(fields.audio_mode ?? "copy").toLowerCase();
|
|
286
|
+
const audio = AUDIO_MODE_MAP[audioMode] ?? AUDIO_MODE_MAP.copy;
|
|
287
|
+
const output = {
|
|
288
|
+
resolution: {
|
|
289
|
+
width: num(fields.output_width) || sourceMeta.resolution.width,
|
|
290
|
+
height: num(fields.output_height) || sourceMeta.resolution.height
|
|
291
|
+
},
|
|
292
|
+
frameRate: num(fields.output_frame_rate) || sourceMeta.frameRate,
|
|
293
|
+
container: String(fields.output_container ?? "mp4"),
|
|
294
|
+
videoEncoder: String(fields.video_encoder ?? "H264"),
|
|
295
|
+
// One of dynamicCompressionLevel or videoBitrate is required.
|
|
296
|
+
dynamicCompressionLevel: String(fields.dynamic_compression_level ?? "Mid"),
|
|
297
|
+
audioTransfer: audio.audioTransfer
|
|
298
|
+
};
|
|
299
|
+
if (audio.audioCodec)
|
|
300
|
+
output.audioCodec = audio.audioCodec;
|
|
301
|
+
if (fields.crop_to_fit)
|
|
302
|
+
output.cropToFit = true;
|
|
303
|
+
return output;
|
|
304
|
+
}
|
|
305
|
+
export async function topazExecuteVideoTask(apiKey, spec, fields, videoBytes, sourceMeta) {
|
|
306
|
+
const filters = buildVideoFilters(spec, fields);
|
|
307
|
+
const output = buildVideoOutput(fields, sourceMeta);
|
|
308
|
+
const createBody = { source: sourceMeta, output, filters };
|
|
309
|
+
// 1. Create request
|
|
310
|
+
const create = await fetchWithRetry(spec.submitEndpoint, {
|
|
311
|
+
method: "POST",
|
|
312
|
+
headers: authHeaders(apiKey, { "Content-Type": "application/json" }),
|
|
313
|
+
body: JSON.stringify(createBody)
|
|
314
|
+
});
|
|
315
|
+
if (!create.ok) {
|
|
316
|
+
throw new Error(`Topaz create failed: ${create.status} ${await create.text()}`);
|
|
317
|
+
}
|
|
318
|
+
const createJson = (await create.json());
|
|
319
|
+
const requestId = (createJson.requestId ?? createJson.id);
|
|
320
|
+
if (!requestId) {
|
|
321
|
+
throw new Error(`No request ID returned: ${JSON.stringify(createJson)}`);
|
|
322
|
+
}
|
|
323
|
+
// 2. Accept → get multi-part upload URLs
|
|
324
|
+
const accept = await fetchWithRetry(spec.acceptEndpoint.replace("{request_id}", requestId), { method: "PATCH", headers: authHeaders(apiKey) });
|
|
325
|
+
if (!accept.ok) {
|
|
326
|
+
throw new Error(`Topaz accept failed: ${accept.status} ${await accept.text()}`);
|
|
327
|
+
}
|
|
328
|
+
const acceptJson = (await accept.json());
|
|
329
|
+
// Spec: { uploadId, urls[] }. Tolerate legacy shapes just in case.
|
|
330
|
+
const uploadId = (acceptJson.uploadId ?? acceptJson.upload_id);
|
|
331
|
+
const uploadUrls = (acceptJson.urls ??
|
|
332
|
+
acceptJson.uploadUrls ??
|
|
333
|
+
(acceptJson.uploadUrl ? [acceptJson.uploadUrl] : []));
|
|
334
|
+
if (!uploadUrls.length) {
|
|
335
|
+
throw new Error(`No upload URL returned: ${JSON.stringify(acceptJson)}`);
|
|
336
|
+
}
|
|
337
|
+
// 3. PUT bytes (single- or multi-part)
|
|
338
|
+
const size = videoBytes.byteLength;
|
|
339
|
+
const partSize = Math.max(1, Math.ceil(size / uploadUrls.length));
|
|
340
|
+
const uploadResults = [];
|
|
341
|
+
const uploadContentType = containerContentType(sourceMeta.container);
|
|
342
|
+
for (let i = 0; i < uploadUrls.length; i++) {
|
|
343
|
+
const start = i * partSize;
|
|
344
|
+
// Equal ceil-sized chunks can leave trailing presigned URLs with no bytes
|
|
345
|
+
// (e.g. 9 bytes across 4 URLs → parts 3/3/3/0). Stop once the source is
|
|
346
|
+
// fully consumed rather than PUT empty parts, which the API rejects.
|
|
347
|
+
if (start >= size)
|
|
348
|
+
break;
|
|
349
|
+
const slice = videoBytes.slice(start, Math.min(start + partSize, size));
|
|
350
|
+
const put = await fetchWithRetry(uploadUrls[i], {
|
|
351
|
+
method: "PUT",
|
|
352
|
+
headers: { "Content-Type": uploadContentType },
|
|
353
|
+
body: slice
|
|
354
|
+
});
|
|
355
|
+
if (!put.ok) {
|
|
356
|
+
throw new Error(`Topaz upload part ${i + 1} failed: ${put.status}`);
|
|
357
|
+
}
|
|
358
|
+
uploadResults.push({
|
|
359
|
+
partNum: i + 1,
|
|
360
|
+
eTag: (put.headers.get("ETag") ?? "").replace(/"/g, "")
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
// 4. Complete upload. Echo back the uploadId from accept when present so the
|
|
364
|
+
// API can correlate the multipart upload it handed out.
|
|
365
|
+
const completeBody = uploadId ? { uploadId, uploadResults } : { uploadResults };
|
|
366
|
+
const complete = await fetchWithRetry(spec.completeEndpoint.replace("{request_id}", requestId), {
|
|
367
|
+
method: "PATCH",
|
|
368
|
+
headers: authHeaders(apiKey, { "Content-Type": "application/json" }),
|
|
369
|
+
body: JSON.stringify(completeBody)
|
|
370
|
+
});
|
|
371
|
+
if (!complete.ok) {
|
|
372
|
+
throw new Error(`Topaz complete-upload failed: ${complete.status} ${await complete.text()}`);
|
|
373
|
+
}
|
|
374
|
+
// 5. Poll status
|
|
375
|
+
const final = await pollTopazStatus(spec.statusEndpoint.replace("{request_id}", requestId), authHeaders(apiKey), spec.pollInterval, spec.maxAttempts);
|
|
376
|
+
// 6. Download result. Spec: { download: { url, expiresIn, expiresAt } }.
|
|
377
|
+
const download = (final.download ?? {});
|
|
378
|
+
const downloadUrl = (download.url ??
|
|
379
|
+
final.downloadUrl ??
|
|
380
|
+
final.download_url ??
|
|
381
|
+
final.url);
|
|
382
|
+
if (!downloadUrl) {
|
|
383
|
+
throw new Error(`No download URL in final status: ${JSON.stringify(final)}`);
|
|
384
|
+
}
|
|
385
|
+
// Provider-returned download URL — screened like every other one.
|
|
386
|
+
const result = await safeFetch(downloadUrl);
|
|
387
|
+
if (!result.ok) {
|
|
388
|
+
throw new Error(`Failed to fetch Topaz video result: ${result.status}`);
|
|
389
|
+
}
|
|
390
|
+
return new Uint8Array(await result.arrayBuffer());
|
|
391
|
+
}
|
|
392
|
+
//# sourceMappingURL=topaz-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topaz-base.js","sourceRoot":"","sources":["../src/topaz-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEpF,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,yCAAyC,CAAC;AAEjD,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;AA+BvC,MAAM,uBAAuB,GAA2B;IACtD,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,iBAAi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C;IACJ,CAAC;IACD,kEAAkE;IAClE,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,CAAC;IAC5C,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,uCAAuC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic Topaz node class factory.
|
|
3
|
+
*
|
|
4
|
+
* Generates node classes from `topaz-manifest.json` at runtime, mirroring the
|
|
5
|
+
* kie-nodes factory. Image nodes upload bytes directly to the Topaz image API;
|
|
6
|
+
* the video node probes source metadata locally (ffprobe) before driving the
|
|
7
|
+
* multi-step video upload pipeline.
|
|
8
|
+
*/
|
|
9
|
+
import type { NodeClass } from "@nodetool-ai/node-sdk";
|
|
10
|
+
import { type TopazVideoKind } from "./topaz-base.js";
|
|
11
|
+
export interface TopazFieldDef {
|
|
12
|
+
name: string;
|
|
13
|
+
type: "str" | "int" | "float" | "bool" | "enum" | "image" | "video";
|
|
14
|
+
default?: unknown;
|
|
15
|
+
title?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
values?: string[];
|
|
18
|
+
min?: number;
|
|
19
|
+
max?: number;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
uploadField?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface TopazManifestEntry {
|
|
24
|
+
className: string;
|
|
25
|
+
moduleName: string;
|
|
26
|
+
modelId: string;
|
|
27
|
+
title: string;
|
|
28
|
+
description: string;
|
|
29
|
+
outputType: "image" | "video";
|
|
30
|
+
videoKind?: TopazVideoKind;
|
|
31
|
+
requiredRuntimes?: string[];
|
|
32
|
+
submitEndpoint: string;
|
|
33
|
+
statusEndpoint: string;
|
|
34
|
+
downloadEndpoint?: string;
|
|
35
|
+
acceptEndpoint?: string;
|
|
36
|
+
completeEndpoint?: string;
|
|
37
|
+
pollInterval: number;
|
|
38
|
+
maxAttempts: number;
|
|
39
|
+
fields: TopazFieldDef[];
|
|
40
|
+
}
|
|
41
|
+
export declare function createTopazNodeClass(spec: TopazManifestEntry): NodeClass;
|
|
42
|
+
export declare function loadTopazNodesFromManifest(manifest: TopazManifestEntry[]): NodeClass[];
|
|
43
|
+
//# sourceMappingURL=topaz-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topaz-factory.d.ts","sourceRoot":"","sources":["../src/topaz-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,uBAAuB,CAAC;AACpE,OAAO,EASL,KAAK,cAAc,EAEpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC;IAC9B,SAAS,CA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