@nodaro/sdk 2.55.0 → 2.57.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/{chunk-XALPYUZI.cjs → chunk-3Y5TDB5K.cjs} +4 -4
- package/dist/{chunk-XALPYUZI.cjs.map → chunk-3Y5TDB5K.cjs.map} +1 -1
- package/dist/{chunk-DV6GTEX5.js → chunk-4SZUSZXK.js} +2 -2
- package/dist/{chunk-DV6GTEX5.js.map → chunk-4SZUSZXK.js.map} +1 -1
- package/dist/{chunk-HRV3VX22.cjs → chunk-7PYZCNLH.cjs} +5 -5
- package/dist/{chunk-HRV3VX22.cjs.map → chunk-7PYZCNLH.cjs.map} +1 -1
- package/dist/{chunk-47ULSVO2.js → chunk-ALDXFMD7.js} +3 -3
- package/dist/chunk-ALDXFMD7.js.map +1 -0
- package/dist/{chunk-SF2CMKWA.cjs → chunk-DOMNKVKA.cjs} +9 -9
- package/dist/{chunk-SF2CMKWA.cjs.map → chunk-DOMNKVKA.cjs.map} +1 -1
- package/dist/{chunk-WY4QRJZW.js → chunk-DTYN7QAZ.js} +25 -2
- package/dist/chunk-DTYN7QAZ.js.map +1 -0
- package/dist/{chunk-LUHAB7UJ.js → chunk-EDSODRRY.js} +10 -10
- package/dist/{chunk-LUHAB7UJ.js.map → chunk-EDSODRRY.js.map} +1 -1
- package/dist/{chunk-OSMKIRKI.cjs → chunk-GDUEOKBF.cjs} +4 -4
- package/dist/{chunk-OSMKIRKI.cjs.map → chunk-GDUEOKBF.cjs.map} +1 -1
- package/dist/{chunk-65VIIZEF.cjs → chunk-GJH73EGF.cjs} +2 -2
- package/dist/{chunk-65VIIZEF.cjs.map → chunk-GJH73EGF.cjs.map} +1 -1
- package/dist/{chunk-FM2KM5TY.cjs → chunk-GSE7SB3I.cjs} +25 -6
- package/dist/chunk-GSE7SB3I.cjs.map +1 -0
- package/dist/{chunk-VHTDOACT.cjs → chunk-GWTKYJJO.cjs} +22 -22
- package/dist/chunk-GWTKYJJO.cjs.map +1 -0
- package/dist/{chunk-L6T44A3G.js → chunk-JJMQ2EVL.js} +24 -7
- package/dist/chunk-JJMQ2EVL.js.map +1 -0
- package/dist/{chunk-I6Q4UDS2.cjs → chunk-JX3GYLV3.cjs} +18 -18
- package/dist/{chunk-I6Q4UDS2.cjs.map → chunk-JX3GYLV3.cjs.map} +1 -1
- package/dist/{chunk-FRQJNGJS.cjs → chunk-KU3UITCU.cjs} +5 -5
- package/dist/{chunk-FRQJNGJS.cjs.map → chunk-KU3UITCU.cjs.map} +1 -1
- package/dist/{chunk-RBX3QTKB.js → chunk-MUHRK4OI.js} +3 -3
- package/dist/{chunk-RBX3QTKB.js.map → chunk-MUHRK4OI.js.map} +1 -1
- package/dist/{chunk-24JE54FQ.js → chunk-ND7JMM5H.js} +3 -3
- package/dist/{chunk-24JE54FQ.js.map → chunk-ND7JMM5H.js.map} +1 -1
- package/dist/{chunk-JTOEHQQJ.cjs → chunk-NOZWIS7M.cjs} +25 -2
- package/dist/chunk-NOZWIS7M.cjs.map +1 -0
- package/dist/{chunk-D2ILCSOQ.js → chunk-RCD4HDBI.js} +3 -3
- package/dist/{chunk-D2ILCSOQ.js.map → chunk-RCD4HDBI.js.map} +1 -1
- package/dist/{chunk-CV2ZZAUO.js → chunk-SOR6K3XZ.js} +4 -4
- package/dist/{chunk-CV2ZZAUO.js.map → chunk-SOR6K3XZ.js.map} +1 -1
- package/dist/{chunk-NKH2UFSD.cjs → chunk-TSM3S2QS.cjs} +5 -5
- package/dist/{chunk-NKH2UFSD.cjs.map → chunk-TSM3S2QS.cjs.map} +1 -1
- package/dist/{chunk-AUKHMT53.js → chunk-VTL4DBX4.js} +3 -3
- package/dist/{chunk-AUKHMT53.js.map → chunk-VTL4DBX4.js.map} +1 -1
- package/dist/{chunk-7CUWAVWB.js → chunk-YYMX3VN7.js} +3 -3
- package/dist/{chunk-7CUWAVWB.js.map → chunk-YYMX3VN7.js.map} +1 -1
- package/dist/entries/cast-swap.cjs +2 -2
- package/dist/entries/cast-swap.d.cts +12 -0
- package/dist/entries/cast-swap.d.ts +12 -0
- package/dist/entries/cast-swap.js +1 -1
- package/dist/entries/characters.d.cts +1 -1
- package/dist/entries/characters.d.ts +1 -1
- package/dist/entries/client.cjs +16 -16
- package/dist/entries/client.d.cts +1 -1
- package/dist/entries/client.d.ts +1 -1
- package/dist/entries/client.js +11 -11
- package/dist/entries/copilot.cjs +4 -4
- package/dist/entries/copilot.js +3 -3
- package/dist/entries/core.cjs +6 -6
- package/dist/entries/core.js +2 -2
- package/dist/entries/creatures.d.cts +1 -1
- package/dist/entries/creatures.d.ts +1 -1
- package/dist/entries/edit.cjs +7 -7
- package/dist/entries/edit.js +2 -2
- package/dist/entries/errors.cjs +32 -24
- package/dist/entries/errors.d.cts +38 -3
- package/dist/entries/errors.d.ts +38 -3
- package/dist/entries/errors.js +1 -1
- package/dist/entries/locations.d.cts +1 -1
- package/dist/entries/locations.d.ts +1 -1
- package/dist/entries/media.cjs +4 -4
- package/dist/entries/media.js +3 -3
- package/dist/entries/nodes.cjs +3 -3
- package/dist/entries/nodes.d.cts +1 -1
- package/dist/entries/nodes.d.ts +1 -1
- package/dist/entries/nodes.js +2 -2
- package/dist/entries/objects.d.cts +1 -1
- package/dist/entries/objects.d.ts +1 -1
- package/dist/entries/scene3d.d.cts +2 -2
- package/dist/entries/scene3d.d.ts +2 -2
- package/dist/entries/studio.cjs +5 -5
- package/dist/entries/studio.js +2 -2
- package/dist/entries/uploads.cjs +2 -2
- package/dist/entries/uploads.d.cts +41 -1
- package/dist/entries/uploads.d.ts +41 -1
- package/dist/entries/uploads.js +1 -1
- package/dist/index.cjs +61 -53
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +11 -11
- package/dist/{nodes-B74WaY9r.d.ts → nodes-1u7MPrD5.d.ts} +10 -0
- package/dist/{nodes-Ceetyyh0.d.cts → nodes-BZavad1T.d.cts} +10 -0
- package/package.json +1 -1
- package/dist/chunk-47ULSVO2.js.map +0 -1
- package/dist/chunk-FM2KM5TY.cjs.map +0 -1
- package/dist/chunk-JTOEHQQJ.cjs.map +0 -1
- package/dist/chunk-L6T44A3G.js.map +0 -1
- package/dist/chunk-VHTDOACT.cjs.map +0 -1
- package/dist/chunk-WY4QRJZW.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkGSE7SB3I_cjs = require('./chunk-GSE7SB3I.cjs');
|
|
4
4
|
var nodes = require('@nodaro/shared/nodes');
|
|
5
5
|
var social = require('@nodaro/shared/social');
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ var DEFAULT_POLL_MS = 2e3;
|
|
|
8
8
|
var DEFAULT_MAX_MS = 15 * 60 * 1e3;
|
|
9
9
|
var sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
10
10
|
if (signal?.aborted) {
|
|
11
|
-
reject(new
|
|
11
|
+
reject(new chunkGSE7SB3I_cjs.JobAbortedError());
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
const timer = setTimeout(() => {
|
|
@@ -17,20 +17,20 @@ var sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
|
17
17
|
}, ms);
|
|
18
18
|
function onAbort() {
|
|
19
19
|
clearTimeout(timer);
|
|
20
|
-
reject(new
|
|
20
|
+
reject(new chunkGSE7SB3I_cjs.JobAbortedError());
|
|
21
21
|
}
|
|
22
22
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
23
23
|
});
|
|
24
24
|
function notRunnable(type, why) {
|
|
25
|
-
return new
|
|
25
|
+
return new chunkGSE7SB3I_cjs.NodaroError(`Node type "${type}" has no route of its own to run it directly: ${why}.`, "node_not_runnable", 0);
|
|
26
26
|
}
|
|
27
|
-
var isRouteNotFound = (err) => err instanceof
|
|
27
|
+
var isRouteNotFound = (err) => err instanceof chunkGSE7SB3I_cjs.NotFoundError && /^Route\b.*\bnot found\b/i.test(err.message);
|
|
28
28
|
function extractJobId(result, label) {
|
|
29
29
|
if (result && typeof result === "object" && "jobId" in result) {
|
|
30
30
|
const jobId = result.jobId;
|
|
31
31
|
if (typeof jobId === "string") return jobId;
|
|
32
32
|
}
|
|
33
|
-
throw new
|
|
33
|
+
throw new chunkGSE7SB3I_cjs.JobFailedError(`${label} did not return a jobId`, "");
|
|
34
34
|
}
|
|
35
35
|
function isImageBatchRequest(type, params) {
|
|
36
36
|
if (type !== "generate-image") return false;
|
|
@@ -41,7 +41,7 @@ function batchJobIds(result) {
|
|
|
41
41
|
return Array.isArray(ids) && ids.every((id) => typeof id === "string") ? ids : null;
|
|
42
42
|
}
|
|
43
43
|
function batchRefusal(detail) {
|
|
44
|
-
return new
|
|
44
|
+
return new chunkGSE7SB3I_cjs.NodaroError(
|
|
45
45
|
`${detail}: this waits for one job \u2014 use nodes.runBatchAndWait() for a batch (count above 1, or models).`,
|
|
46
46
|
"batch_requires_run_batch_and_wait",
|
|
47
47
|
0
|
|
@@ -88,7 +88,7 @@ var NodesResource = class {
|
|
|
88
88
|
return res.data;
|
|
89
89
|
}
|
|
90
90
|
async runAndWait(type, params = {}, opts = {}) {
|
|
91
|
-
if (opts.signal?.aborted) throw new
|
|
91
|
+
if (opts.signal?.aborted) throw new chunkGSE7SB3I_cjs.JobAbortedError();
|
|
92
92
|
if (isImageBatchRequest(type, params)) throw batchRefusal(`${type} with count above 1 or models makes several jobs`);
|
|
93
93
|
const result = await this.run(type, params, { idempotencyKey: opts.idempotencyKey });
|
|
94
94
|
const ids = batchJobIds(result);
|
|
@@ -113,9 +113,9 @@ var NodesResource = class {
|
|
|
113
113
|
* `not_a_batch`) — wait for it with {@link runAndWait}.
|
|
114
114
|
*/
|
|
115
115
|
async runBatchAndWait(type, params, opts = {}) {
|
|
116
|
-
if (opts.signal?.aborted) throw new
|
|
116
|
+
if (opts.signal?.aborted) throw new chunkGSE7SB3I_cjs.JobAbortedError();
|
|
117
117
|
if (!isImageBatchRequest(type, params)) {
|
|
118
|
-
throw new
|
|
118
|
+
throw new chunkGSE7SB3I_cjs.NodaroError(
|
|
119
119
|
"runBatchAndWait waits for a batch \u2014 count above 1, or models; wait for one image with nodes.runAndWait().",
|
|
120
120
|
"not_a_batch",
|
|
121
121
|
0
|
|
@@ -123,7 +123,7 @@ var NodesResource = class {
|
|
|
123
123
|
}
|
|
124
124
|
const result = await this.run(type, params, { idempotencyKey: opts.idempotencyKey });
|
|
125
125
|
const batch = batchResultOf(result);
|
|
126
|
-
if (!batch) throw new
|
|
126
|
+
if (!batch) throw new chunkGSE7SB3I_cjs.JobFailedError(`${type} did not answer with a batch`, "");
|
|
127
127
|
const modelOf = new Map(batch.groups.flatMap((group) => group.jobIds.map((id) => [id, group.model])));
|
|
128
128
|
const results = await Promise.all(
|
|
129
129
|
batch.jobIds.map(async (jobId) => {
|
|
@@ -131,7 +131,7 @@ var NodesResource = class {
|
|
|
131
131
|
try {
|
|
132
132
|
return { jobId, model, status: "completed", output: await this.pollJob(jobId, type, opts) };
|
|
133
133
|
} catch (err) {
|
|
134
|
-
if (err instanceof
|
|
134
|
+
if (err instanceof chunkGSE7SB3I_cjs.JobAbortedError || !(err instanceof chunkGSE7SB3I_cjs.NodaroError)) throw err;
|
|
135
135
|
return { jobId, model, status: "error", error: err };
|
|
136
136
|
}
|
|
137
137
|
})
|
|
@@ -152,13 +152,13 @@ var NodesResource = class {
|
|
|
152
152
|
* @param opts Shared `signal` / `cancelOnAbort` / `onProgress` / `pollMs` / `maxMs`.
|
|
153
153
|
*/
|
|
154
154
|
async runMany(type, paramsList, opts = {}) {
|
|
155
|
-
if (opts.signal?.aborted) throw new
|
|
155
|
+
if (opts.signal?.aborted) throw new chunkGSE7SB3I_cjs.JobAbortedError();
|
|
156
156
|
if (paramsList.some((params) => isImageBatchRequest(type, params))) {
|
|
157
157
|
throw batchRefusal(`a ${type} entry with count above 1 or models makes several jobs`);
|
|
158
158
|
}
|
|
159
159
|
return Promise.all(
|
|
160
160
|
paramsList.map(async (params) => {
|
|
161
|
-
if (opts.signal?.aborted) throw new
|
|
161
|
+
if (opts.signal?.aborted) throw new chunkGSE7SB3I_cjs.JobAbortedError();
|
|
162
162
|
const result = await this.run(type, params);
|
|
163
163
|
const jobId = extractJobId(result, type);
|
|
164
164
|
const output = await this.pollJob(jobId, type, opts);
|
|
@@ -173,9 +173,9 @@ var NodesResource = class {
|
|
|
173
173
|
try {
|
|
174
174
|
return await this.pollUntilSettled(jobId, label, opts);
|
|
175
175
|
} catch (err) {
|
|
176
|
-
if (!(err instanceof
|
|
176
|
+
if (!(err instanceof chunkGSE7SB3I_cjs.JobAbortedError)) throw err;
|
|
177
177
|
if (opts.cancelOnAbort) await this.client.jobs.cancel(jobId).catch(() => void 0);
|
|
178
|
-
throw err.jobId ? err : new
|
|
178
|
+
throw err.jobId ? err : new chunkGSE7SB3I_cjs.JobAbortedError(err.message, jobId);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
/** Poll an already-kicked job id until it stops moving; resolve output_data
|
|
@@ -187,24 +187,24 @@ var NodesResource = class {
|
|
|
187
187
|
const maxMs = opts.maxMs ?? DEFAULT_MAX_MS;
|
|
188
188
|
const deadline = Date.now() + maxMs;
|
|
189
189
|
for (; ; ) {
|
|
190
|
-
if (opts.signal?.aborted) throw new
|
|
190
|
+
if (opts.signal?.aborted) throw new chunkGSE7SB3I_cjs.JobAbortedError(void 0, jobId);
|
|
191
191
|
const { data } = await this.client.jobs.getStatus(jobId);
|
|
192
192
|
opts.onProgress?.(data);
|
|
193
193
|
if (data.status === "completed") {
|
|
194
194
|
return data.output_data ?? {};
|
|
195
195
|
}
|
|
196
196
|
if (data.status === "failed" || data.status === "cancelled") {
|
|
197
|
-
throw new
|
|
197
|
+
throw new chunkGSE7SB3I_cjs.JobFailedError(
|
|
198
198
|
data.error_message ?? `${label} ${data.status}`,
|
|
199
199
|
jobId,
|
|
200
200
|
data.status
|
|
201
201
|
);
|
|
202
202
|
}
|
|
203
203
|
if (data.status === "pending_review") {
|
|
204
|
-
throw new
|
|
204
|
+
throw new chunkGSE7SB3I_cjs.JobHeldError(`${label} is awaiting review`, jobId);
|
|
205
205
|
}
|
|
206
206
|
if (Date.now() > deadline) {
|
|
207
|
-
throw new
|
|
207
|
+
throw new chunkGSE7SB3I_cjs.JobTimeoutError(`${label} timed out`, jobId, maxMs);
|
|
208
208
|
}
|
|
209
209
|
await sleep(pollMs, opts.signal);
|
|
210
210
|
}
|
|
@@ -212,5 +212,5 @@ var NodesResource = class {
|
|
|
212
212
|
};
|
|
213
213
|
|
|
214
214
|
exports.NodesResource = NodesResource;
|
|
215
|
-
//# sourceMappingURL=chunk-
|
|
216
|
-
//# sourceMappingURL=chunk-
|
|
215
|
+
//# sourceMappingURL=chunk-GWTKYJJO.cjs.map
|
|
216
|
+
//# sourceMappingURL=chunk-GWTKYJJO.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resources/nodes.ts"],"names":["JobAbortedError","NodaroError","NotFoundError","JobFailedError","nodeRunRoute","NODE_TYPES_WITHOUT_RUN_ROUTE","SOCIAL_POST_NODE_PLATFORM","NODE_RUN_ROUTES","JobHeldError","JobTimeoutError"],"mappings":";;;;;;AAgtBA,IAAM,eAAA,GAAkB,GAAA;AAExB,IAAM,cAAA,GAAiB,KAAK,EAAA,GAAK,GAAA;AAEjC,IAAM,KAAA,GAAQ,CAAC,EAAA,EAAY,MAAA,KACzB,IAAI,OAAA,CAAc,CAAC,SAAS,MAAA,KAAW;AACrC,EAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,IAAA,MAAA,CAAO,IAAIA,mCAAiB,CAAA;AAC5B,IAAA;AAAA,EACF;AACA,EAAA,MAAM,KAAA,GAAQ,WAAW,MAAM;AAC7B,IAAA,MAAA,EAAQ,mBAAA,CAAoB,SAAS,OAAO,CAAA;AAC5C,IAAA,OAAA,EAAQ;AAAA,EACV,GAAG,EAAE,CAAA;AACL,EAAA,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F;AACF","file":"chunk-GWTKYJJO.cjs","sourcesContent":["import type { GenerateScene3DParams, EditScene3DParams, RenderScene3DParams, Scene3DJobOutput, Pro3DRenderRunParams, Pro3DRenderJobOutput } from \"./scene3d-types.js\"\nimport type { ImageToImageParams, EditImageParams, SplitImageParams, SplitImageResult, GenerateMaskParams, GenerateMaskJobOutput, ImageJobStarted } from \"./nodes-image-params.js\"\nimport type { VideoToVideoParams, NodeQuote } from \"./nodes-video-params.js\"\nimport type { NodaroClientCore } from \"../core.js\"\nimport type { JobStatusResult, JobsResource } from \"./jobs.js\"\nimport { JobAbortedError, JobFailedError, JobHeldError, JobTimeoutError, NodaroError, NotFoundError } from \"../errors.js\"\nimport type { ModelUnavailableError } from \"../errors.js\"\nimport { NODE_RUN_ROUTES, NODE_TYPES_WITHOUT_RUN_ROUTE, nodeRunRoute } from \"@nodaro/shared/nodes\"\nimport {\n SOCIAL_POST_NODE_PLATFORM,\n type SocialPost,\n type SocialPlatform,\n type SocialSearchMode,\n type SocialSearchParams\n} from \"@nodaro/shared/social\"\nimport type { ConnectedReference, DescribedReference } from \"@nodaro/shared/types\"\nimport type { VideoCharacterReference } from \"@nodaro/shared/video\"\nimport type { ModelInputAdjustment } from \"@nodaro/shared/model-catalog\"\nimport type { VideoDepthProvider, VideoDepthModelSize, VideoDepthColormap, VideoDepthResolution } from \"@nodaro/shared/media\"\nimport type { DirectionFields, SubjectFields } from \"@nodaro/prompts/prompt-builder\"\n\nexport type NodeCategory =\n | \"input\"\n | \"parameter\"\n | \"ai-image\"\n | \"ai-video\"\n | \"ai-audio\"\n | \"ai-text\"\n | \"processing\"\n | \"composition\"\n | \"trigger\"\n | \"output\"\n | \"control\"\n | \"entity\"\n | \"utility\"\n\nexport type OutputType = \"text\" | \"image\" | \"video\" | \"audio\" | \"data\" | \"none\"\n\n/**\n * Field shape inside a node's `inputSchema.fields[]`. Mirrors\n * `backend/src/lib/node-registry.ts`.\n */\nexport interface NodeInputField {\n key: string\n type: string\n required?: boolean\n options?: string[]\n}\n\nexport interface NodeInputSchema {\n fields: NodeInputField[]\n}\n\n/**\n * A per-unit price on a node descriptor. A run of N units is charged\n * `ceil(N × creditsPerUnit)`, rounded up once — so `GET /v1/credits/model-cost`\n * for `identifier` (one unit, rounded up: the least a run pays) times N can come\n * to more. `<identifier>:<N>u` is the exact price of N units; for a whole run\n * use `POST /v1/credits/estimate-workflow`.\n */\nexport interface NodeCreditRate {\n /** The price id the rate is read from. */\n identifier: string\n /** What one unit is, as a token (`\"1000-frames\"`: one started block of 1,000 sampled frames). */\n unit: string\n /** The credits one unit adds to a run's total — exact, not rounded. */\n creditsPerUnit: number\n /** The fewest units a run is charged for. */\n minUnits: number\n /** `\"ceil-run-total\"`: the run's total is rounded up to a whole credit once, never per unit. */\n rounding: \"ceil-run-total\"\n /** The rule in words. */\n note: string\n}\n\n/**\n * Node descriptor returned by `GET /v1/nodes` and `GET /v1/nodes/:type`.\n * Mirrors `backend/src/lib/node-registry.ts#NodeDescriptor`.\n */\nexport interface NodeDescriptor {\n type: string\n label: string\n category: NodeCategory\n description: string\n outputType: OutputType\n /** The credits a run is charged, the figure on the node's Run button.\n * Number when fixed, string range like \"10-80\" when model-dependent.\n * Undefined when the node is free — or on editions\n * without a credit system (community/business omit the field entirely;\n * it is meaningful on Cloud only). */\n creditCost?: number | string\n /** `creditCost` is an ESTIMATE: a metered LLM node's typical call on its\n * default model, charged its actual usage after the run (shown `≈N`).\n * Absent for a fixed price, and under the tier-pricing rollback. A metered\n * LLM node whose default model has no price yet lists `creditCost:\n * \"unpriced\"` (a run on it is refused `llm_model_unpriced`). */\n estimate?: true\n /** A node charged per unit of its own measure (its `creditCost` is a word\n * such as `\"per-1000-frames\"`): the charged price of one unit and how a run\n * rounds. Cloud only, like `creditCost`. */\n creditRate?: NodeCreditRate\n /** Input fields the node exposes for user override (subset of full config). */\n inputSchema?: NodeInputSchema\n /** For AI nodes: list of provider IDs supported. */\n providers?: string[]\n /** Capability flags such as \"supports-reference-image\" or \"supports-end-frame\". */\n capabilities?: string[]\n /** Hard duration ceiling in seconds (e.g. Generate Video Pro's env-configured cap). */\n maxDurationSec?: number\n /** Providers whose segment-duration menu is sparse (off-menu values snap to the nearest entry). */\n sparseProviders?: string[]\n /** Per-provider resolution tiers, e.g. `{ \"minimax-h3\": [\"2K\", \"768P\"] }`. */\n providerResolutions?: Record<string, string[]>\n /** Per-provider map of display resolution → the literal wire value the API expects. */\n providerResolutionWire?: Record<string, Record<string, string>>\n /** Generate Video Pro: the deployed engine accepts the `soundtrack` input (original-audio replay). */\n soundtrack?: boolean\n}\n\n/**\n * Result of a direct node execution. Most node types return `{ jobId }` and\n * are processed asynchronously by a worker — the caller polls\n * `client.jobs.get(jobId)` until status is `completed`/`failed`.\n *\n * Some node types (`meta-ads-scrape`, for one) answer synchronously and\n * return their full result body. The shape is route-specific; consumers\n * should branch on the presence of `jobId`.\n */\n/**\n * One parameter the server corrected because the chosen model does not accept\n * the value you sent (e.g. `gpt-image-2` has no 3:2 aspect ratio). The run\n * proceeds with the corrected value rather than failing — this is how you find\n * out what it actually used.\n *\n * Re-exports `@nodaro/shared`'s `ModelInputAdjustment` — the same shape the\n * server's `normalizeModelInput` / `resolveNormalizedImageGen` populate — under\n * the SDK's naming convention, rather than declaring a second copy of the\n * fields.\n */\nexport type RunNodeAdjustment = ModelInputAdjustment\n\n/**\n * WHO is in the shot, as picker-catalog option ids — the `subject` field of\n * `generate-image` (and `text-to-video`). The platform writes the wording from\n * the ids you send; you never write prompt text for the subject. It composes\n * with `prompt`: the subject clauses are folded in right after your prompt and\n * ahead of any `direction`.\n *\n * A flat map of field → id(s):\n * - **Keys** are the platform's own picker field names — every Person field\n * (`type`, `age`, `ethnicity`, `hairBase`, `lipState`, …), every Styling\n * field (`makeup`, `jewelry`, `outerwear`, …), and the prop keys `heldProp`,\n * `material` and `animal`. They and their ids come from the picker catalogs:\n * `pickerCatalogs.get(\"person\")` / `get(\"styling\")` list each dimension's\n * `field` with its `options[].id`; `get(\"held-prop\")`, `get(\"material\")` and\n * `get(\"animal\")` write their `options[].id` to the catalog's `valueField`.\n * - **Values** are one id or a list of ids. Ids past a dimension's own cap are\n * dropped, not rejected.\n * - **One number:** `customAge` (years, rounded and clamped to 0–120), read only\n * when `age` is `\"age-custom\"`. A number on any other key does nothing.\n * - **Bounds** (without `presetId`): at most 128 keys, 64 characters per key,\n * 8 ids per key and 100 characters per id — a map over any of them is a 400\n * `validation_error`. Unknown keys and unknown ids within them are skipped,\n * and the job's `input_data.subject` records the ids that were used.\n * - **With `presetId`** your `subject` replaces the preset's own and is folded\n * into the preset's prompt, as `direction` and `structured` are: an over-long\n * key, id or list is dropped rather than rejected, and `input_data` does not\n * record the subject.\n *\n * Same type as `@nodaro/prompts`' `SubjectFields`, under the SDK's name.\n */\nexport type Subject = SubjectFields\n\n/**\n * Something you asked for that the run did not send, with why — e.g.\n * `moodboard_images_not_sent`: some of a `moodboard:<id>` direction's images\n * did not fit the model's reference limit after your own references. The run\n * goes ahead; the same warnings are kept on the job's `input_data.warnings`.\n */\nexport interface RunNodeWarning {\n code: string\n message: string\n}\n\nexport type RunNodeResult =\n | { jobId: string; usageLogId?: string; adjustments?: RunNodeAdjustment[]; warnings?: RunNodeWarning[]; [k: string]: unknown }\n | Record<string, unknown>\n\n/**\n * Structured references — the editor's wired-reference shape — shared by\n * `generate-image` and `generate-video`. The route assembles them server-side\n * into per-ref `@image_N` directives and resolves `{image:N}` prompt tokens, so\n * a direct SDK run binds inline references exactly like the canvas. Pass the\n * same `ConnectedReference[]` the editor builds; the route dedupes + caps them\n * to the provider's image-reference limit.\n */\nexport interface StructuredReferenceParams {\n /** Wired references assembled server-side (deduped + capped per provider). */\n connectedReferences?: ConnectedReference[]\n /**\n * References you can NAME and DESCRIBE but have no media for — a cast role no\n * entity is bound to yet, a character that exists only in the script. They\n * carry no url, so nothing is attached and no `@image_N` seat is used: each\n * becomes a `<Name> — <description>.` line, and a name left in the prompt\n * prose reaches the model as a real, described subject. Up to 10.\n */\n describedReferences?: DescribedReference[]\n /** Reorder the assembled reference list by stable ref ids; renumbers `@image_N`. */\n referenceOrder?: string[]\n}\n\n/**\n * Captions for a node's video / audio rail references — INDEX-ALIGNED with\n * `referenceVideoUrls` / `referenceAudioUrls`, so `referenceVideoCaptions[0]`\n * describes `referenceVideoUrls[0]`. Each renders as `@video_N: <caption>.` /\n * `@audio_N: <caption>.` in the assembled prompt and is bounded by the number of\n * rail references that actually ship, so a caption can never bind a slot the\n * payload dropped. A blank entry is a hole in the alignment, not a line.\n */\nexport interface ReferenceCaptionParams {\n referenceVideoCaptions?: string[]\n referenceAudioCaptions?: string[]\n}\n\n/**\n * Typed request body for `nodes.run(\"text-to-speech\", …)` / `runAndWait`.\n * Common fields are typed; any other route field passes through.\n */\nexport interface TextToSpeechParams extends GenerationSessionParams {\n text: string\n /** A premade voice NAME (Rachel, George, …) or a library / custom voice id. */\n voice?: string\n voiceType?: \"premade\" | \"custom\" | \"library\"\n /** `elevenlabs-v4` (the default), `elevenlabs-v3`, `elevenlabs-v4-turbo`, `elevenlabs-turbo`, `elevenlabs-multilingual`. */\n provider?: string\n stability?: number\n similarityBoost?: number\n style?: number\n speed?: number\n languageCode?: string\n /**\n * Continuity across clips: the line spoken just BEFORE this one in the finished piece\n * (the previous clip's text). Context, not spoken — a model that stitches (v4, Turbo, Multilingual; not v3) carries the\n * intonation across the cut; others ignore it. Up to 1,000 characters (a 400 above, on a model that stitches).\n */\n previousText?: string\n /** The line spoken just AFTER this one. Same rule as `previousText`. */\n nextText?: string\n [k: string]: unknown\n}\n\n/**\n * Fields every job-creating request accepts beside its own params, on any\n * route: the platform stamps them on the job it creates. Typed on every\n * generation params type.\n */\nexport interface GenerationSessionParams {\n /** A session from `client.sessions.create()` — the job is born in it and\n * shows in its feed. Must be one of yours (404 otherwise). */\n sessionId?: string\n /** Your app's slug (`create-image`, …): stored on the job, and what\n * `jobs.list({ origin })` filters on. Lowercase letters, digits, dashes. */\n origin?: string\n}\n\n/**\n * Typed request body for `nodes.run(\"generate-image\", …)` / `runAndWait`.\n * Common fields are typed; any other route field passes through via the index\n * signature (the route Zod-validates the full body).\n *\n * `count` above 1 or `models` makes several jobs in one call: the answer is a\n * {@link GenerateImageBatchResult}, and {@link NodesResource.runBatchAndWait}\n * (not `runAndWait`) waits for it.\n */\nexport interface GenerateImageParams extends StructuredReferenceParams, GenerationSessionParams {\n prompt?: string\n /**\n * Apply a node preset (a factory id like `\"generate-image/cinematic-still\"`, from\n * `presets.listFactory(\"generate-image\")`, or one of yours) exactly as the editor does:\n * its prompt and pre/post text, placeholder defaults, style, negative prompt and\n * levers. Fields you pass override it; your `prompt` is wrapped in its pre/post text.\n */\n presetId?: string\n /** Values for the preset's placeholders that have no default, e.g. `{ BRAND: \"Acme\" }`.\n * Without them such a preset answers 400 `preset_variables_required`, naming them. */\n presetVariables?: Record<string, string>\n /** The prompt as your user typed it, when `prompt` is a version your app\n * expanded (filled-in fields, resolved references). Stored on the job as\n * `input_data.userPrompt` to show what the user wrote; never sent to the\n * model. Defaults to `prompt`. */\n userPrompt?: string\n /** Pre & post text wrapped around `prompt` (a preset's words), joined the\n * same way every AI prompt node joins them. */\n promptPrefix?: string\n promptSuffix?: string\n provider?: string\n /** How many images to make, 1–4 — each its own job, one image each, under\n * its own Idempotency-Key (`<key>:<i>`). With `models`, per model. */\n count?: number\n /** 2–4 distinct image model ids: the same request runs on each, instead of\n * `provider`. models × count is at most 8. With `presetId`, the preset is\n * applied once per model. */\n models?: string[]\n /** With `count`, image i gets `seed + i` — one seed would draw the same image every time. */\n seed?: number\n /** Flat reference image URLs — appended after `connectedReferences`. */\n referenceImageUrls?: string[]\n negativePrompt?: string\n /**\n * Cinematic direction as catalog IDS — the route renders the wording. Two\n * keys also take one of YOUR saved resources:\n * - `colorLook: \"palette:<id>\"` (`paletteDirectionId(id)`) — the palette's\n * colours, each by an everyday name and its hex, go into the prompt;\n * - `style: \"moodboard:<id>\"` (`moodboardDirectionId(id)`) — the moodboard's\n * description goes into the prompt and its images go to the model as style\n * references, after your own references and up to the model's reference\n * limit (the answer's `warnings` says when some did not fit). Its images\n * are references, so on models priced per reference the run costs what is\n * sent.\n * A malformed one answers 400; one that is not yours (or was deleted) 404\n * `direction_not_found`. The job keeps the id, so a re-run resolves it again.\n * Not combinable with `presetId` yet (400 `validation_error`).\n */\n direction?: DirectionFields\n /**\n * WHO is in the shot — person, styling and props as picker-catalog ids\n * ({@link Subject}). The platform writes the wording and folds it in after\n * `prompt`, ahead of `direction`. With `presetId`, it replaces the preset's own\n * and is folded into the preset's prompt (over-long values dropped, not 400).\n */\n subject?: Subject\n /**\n * The image to edit. Alone, the run is image-to-image on it (a text-to-image\n * model runs as its image-to-image sibling); with `maskUrl`, an inpaint.\n */\n baseImageUrl?: string\n /**\n * Inpaint mask — white = the area to change, black = keep (what\n * `generate-mask` writes). Needs a base: `baseImageUrl`, else the first\n * `referenceImageUrls` entry. Works on EVERY image model: the result's masked\n * area is composited back over the base, so everything outside the mask is\n * the base's own pixels. On the models whose `IMAGE_MASK_MODE` is `\"prompt\"`\n * (`@nodaro/shared`) the masked area's position is also described in the\n * prompt; the rest rely on the composite alone. (A model that takes the mask\n * itself is on `image-to-image` — `I2I_MASK_SUPPORT`.)\n */\n maskUrl?: string\n /** 0–1: how far the result may move from the base (taken by the models in `I2I_STRENGTH_SUPPORT`). */\n strength?: number\n /** 0–20: prompt adherence (taken by the models in `GUIDANCE_SCALE_SUPPORT`). */\n guidanceScale?: number\n [k: string]: unknown\n}\n\n/** One model's share of a generate-image batch. */\nexport interface GenerateImageBatchGroup {\n /** The model id as requested. */\n model: string\n jobIds: string[]\n /** Credits held for this model's images; absent where nothing is charged. */\n credits?: number\n /** Parameters corrected for this model, as on a single call. */\n adjustments?: RunNodeAdjustment[]\n /** Something asked for that was not sent on this model (e.g. a moodboard past its reference limit), as on a single call. */\n warnings?: RunNodeWarning[]\n}\n\n/**\n * What `nodes.run(\"generate-image\", …)` answers when `count` is above 1 or\n * `models` is set: every job, grouped by model. The whole batch was checked\n * against the balance and created, charged and queued together — or not at\n * all (`InsufficientCreditsError`'s `required` is then the batch's total).\n */\nexport interface GenerateImageBatchResult {\n /** The first job — so code reading the single-image answer keeps working. */\n jobId: string\n /** Every job: model by model, then image by image. */\n jobIds: string[]\n /** On every job of the batch as `input_data.batchId`; `jobs.list({ batchId })` lists them. */\n batchId: string\n groups: GenerateImageBatchGroup[]\n /** The groups' credits summed; absent where nothing is charged. */\n totalCredits?: number\n /** Every job already existed and this request charged nothing: a repeat of an earlier request with the same Idempotency-Key. */\n deduped?: true\n}\n\n/**\n * One job of a batch once {@link NodesResource.runBatchAndWait} stops waiting\n * for it: its output, or the typed error that ended the wait — a\n * `JobFailedError` (failed or cancelled), `JobHeldError` (held for review) or\n * `JobTimeoutError`. One job's error never discards the others' images.\n */\nexport type BatchJobOutcome =\n | { readonly jobId: string; readonly model: string; readonly status: \"completed\"; readonly output: NodeJobOutput }\n | { readonly jobId: string; readonly model: string; readonly status: \"error\"; readonly error: NodaroError }\n\n/** What {@link NodesResource.runBatchAndWait} resolves. */\nexport interface GenerateImageBatchOutput {\n /** The submit's answer: the ids, the groups, the credits. */\n readonly batch: GenerateImageBatchResult\n /** Every job, in `batch.jobIds` order. */\n readonly results: readonly BatchJobOutcome[]\n}\n\n/**\n * Typed request body for `nodes.run(\"generate-video\", …)` / `runAndWait`.\n * Common fields are typed; any other route field passes through.\n */\nexport interface GenerateVideoParams extends StructuredReferenceParams, ReferenceCaptionParams, GenerationSessionParams {\n prompt?: string\n provider?: string\n /** Start-frame image (image-to-video). */\n imageUrl?: string\n /** Closing frame, paired with `imageUrl` on models that support one. */\n endFrameUrl?: string\n referenceImageUrls?: string[]\n referenceVideoUrls?: string[]\n referenceAudioUrls?: string[]\n /**\n * Identity inputs that keep a real person's face — a portrait + description\n * per person. Only models with a dedicated character channel take them; any\n * other model answers `400`. Distinct from `referenceImageUrls`, which a\n * multimodal model treats as loose context. Adds no credit charge.\n *\n * - Gemini Omni (`gemini-omni-video`, `gemini-omni-flash`): up to 3. Cannot be\n * combined with a start frame (`imageUrl`); each character uses 1 of the\n * model's 7 input units (2 with a `bodyImageUrl`). Give a character a\n * `voice` to pin one voice persona (a Gemini preset + optional description /\n * example line) across clips — up to 3 distinct voices a request.\n * - Kling 4.0 (`kling-4`): up to 7 named subjects, written in the prompt as\n * `@Name`. A subject takes 2–4 images — the portrait, then `bodyImageUrl` /\n * `extraImageUrls`; one with a single image is sent as a reference image.\n * Counts toward the model's 15 materials. No `voice` (send a recorded\n * voice as `referenceAudioUrls`).\n */\n characterReferences?: VideoCharacterReference[]\n /** Kling 4.0 (`kling-4`): keep the reference videos' own sound instead of\n * generating new sound. Ignored without a reference video and by every\n * other model. */\n keepOriginalSound?: boolean\n /** Kling 4.0 (`kling-4`): play the first `referenceAudioUrls` clip as the\n * result's soundtrack — it is sent as one more reference video (a still\n * frame carrying the audio) with its sound kept, so it is priced as a\n * reference-video run; further clips stay voice samples. Default `true`;\n * `false` makes every clip a voice sample. Ignored by every other model. */\n audioSoundtrack?: boolean\n /** How a start/end frame is reshaped before the model sees it. Default\n * `\"resolution\"`: resize it to the pixel size that model actually renders,\n * which is what stops the provider reshaping it mid-clip. `\"ratio\"` corrects\n * only the aspect; `\"original\"` sends it untouched. */\n frameFit?: \"original\" | \"ratio\" | \"resolution\"\n /** Whether the frame travels as a real start frame or as a reference image\n * bound in the prompt as the opening frame. Default `\"auto\"`, which picks per\n * model. Ignored by models that take no reference images. */\n frameDelivery?: \"auto\" | \"frame\" | \"reference\"\n /** Seedance Draft (`seedance-2-5` only; ignored elsewhere): render a 480p\n * DRAFT — it costs the same as a 480p run and any `resolution` is replaced\n * by 480p. Finalize the take you like with `nodes.run(\"video-upscale\",\n * { provider: \"seedance-2-5-hd\", sourceJobId })`: the same take, frame for\n * frame, at 1080p. Drafts are kept about 7 days. */\n draft?: boolean\n [k: string]: unknown\n}\n\n/**\n * Typed request body for `nodes.run(\"text-to-video\", …)` / `runAndWait` — the\n * PROMPT-ONLY video lane (`POST /v1/text-to-video`).\n *\n * Which lane takes what: `text-to-video` renders from text (plus optional\n * references) and `prompt` is REQUIRED; frames belong to `generate-video`\n * alone, which is the image-to-video lane (`imageUrl` start frame, `endFrameUrl`\n * closing frame) and where a prompt is optional. A model with no text-to-video\n * mode answers this lane with a `400 image_required` naming itself.\n *\n * Common fields are typed; any other route field passes through.\n */\nexport interface TextToVideoParams extends StructuredReferenceParams, ReferenceCaptionParams, GenerationSessionParams {\n prompt: string\n provider?: string\n duration?: number\n /** Native audio toggle, on the models that render sound. */\n sound?: boolean\n negativePrompt?: string\n aspectRatio?: string\n resolution?: string\n seed?: number\n referenceImageUrls?: string[]\n referenceVideoUrls?: string[]\n referenceAudioUrls?: string[]\n /** Identity inputs that keep a real person's face — see {@link GenerateVideoParams.characterReferences}. */\n characterReferences?: VideoCharacterReference[]\n /** Kling 4.0 (`kling-4`): keep the reference videos' own sound — see {@link GenerateVideoParams.keepOriginalSound}. */\n keepOriginalSound?: boolean\n /** Kling 4.0 (`kling-4`): play the first audio clip as the soundtrack — see {@link GenerateVideoParams.audioSoundtrack}. */\n audioSoundtrack?: boolean\n /** Cinematic direction as catalog IDS — the route renders the wording. */\n direction?: DirectionFields\n /** WHO is in the shot as picker-catalog ids ({@link Subject}), folded ahead of the direction clauses. */\n subject?: Subject\n /** Seedance Draft (`seedance-2-5` only; ignored elsewhere): render a 480p\n * DRAFT — it costs the same as a 480p run and any `resolution` is replaced\n * by 480p. Finalize the take you like with `nodes.run(\"video-upscale\",\n * { provider: \"seedance-2-5-hd\", sourceJobId })`: the same take, frame for\n * frame, at 1080p. Drafts are kept about 7 days. */\n draft?: boolean\n /** Absent / `true`: a copyright refusal is retried once with a reworded\n * prompt. `false` = a copyright refusal fails the job instead of retrying\n * once with a reworded prompt. */\n contentPolicyRewrite?: boolean\n [k: string]: unknown\n}\n\n/**\n * Typed request body for `nodes.run(\"video-upscale\", …)` / `runAndWait`.\n *\n * - `topaz` (default): upscale any `videoUrl` to `targetResolution` (the\n * frame's short side: 720p / 1080p / 4k, default 1080p) at `targetFps`\n * (15–60, default the source's own rate; added frames are interpolated).\n * Metered: the run holds a ceiling read from its output size and is charged\n * what the upscale actually costs, never more. `upscaleFactor` is the legacy\n * lever, mapped over the source's short side when no `targetResolution` is set.\n * - `veo-1080p` / `veo-4k`: re-render a VEO generation by its `taskId`.\n * - `seedance-2-5-hd`: finalize a Seedance 2.5 DRAFT (a `draft: true` run) —\n * the same take re-rendered at 1080p at the draft's own length. Name the\n * draft by `sourceJobId` (its job id) or `taskId` (its providerTaskId). The\n * price comes from the draft (its length, and whether it used a reference\n * video), never from this body. A foreign, unfinished or non-draft source is\n * refused with a 4xx before anything is charged.\n *\n * Any other route field passes through.\n */\nexport interface VideoUpscaleParams extends GenerationSessionParams {\n provider?: \"topaz\" | \"veo-1080p\" | \"veo-4k\" | \"seedance-2-5-hd\"\n videoUrl?: string\n /** topaz: output resolution — the frame's short side. Default \"1080p\". */\n targetResolution?: \"720p\" | \"1080p\" | \"4k\"\n /** topaz: output frame rate, 15–60. Default: the source's own rate. */\n targetFps?: number\n /** @deprecated Legacy topaz lever — use `targetResolution`. */\n upscaleFactor?: \"1\" | \"2\" | \"4\"\n taskId?: string\n sourceJobId?: string\n [k: string]: unknown\n}\n\n/**\n * Typed request body for `nodes.run(\"assemble-narrated-video\", …)` / `runAndWait`.\n * Assembles blocks of video with audio narration into a single composed video.\n */\nexport interface AssembleNarratedVideoParams extends GenerationSessionParams {\n blocks: { videoUrl: string; audioUrl?: string }[]\n voiceVolume?: number\n clipAudioVolume?: number\n maxSlowdown?: number\n trimStartFrames?: number\n trimEndFrames?: number\n [k: string]: unknown\n}\n\n/**\n * Typed request body for `nodes.run(\"video-depth\", …)` / `runAndWait` — turns a\n * video into a depth video (`POST /v1/video-depth`, near is bright, far is\n * dark). The completed job writes `videoUrl` (MP4) and `thumbnailUrl`.\n *\n * Two providers: `video-depth-anything` (the default, temporally consistent)\n * honours every lever below; `depth-anything-frames` (Depth Anything per\n * frame) takes `modelSize` and `colormap` only, and renders only `grayscale` /\n * `inferno`. A lever the chosen provider does not take is dropped and a\n * colormap it cannot render becomes `grayscale` — coerced, never rejected (a\n * value outside the vocabularies below is still a `400 validation_error`).\n *\n * The clip is measured before any credits are reserved. Too long answers\n * `400 video_too_long` (`video-depth-anything`: more than 2,400 frames or\n * 300 s; `depth-anything-frames`: more than 80 s); a clip that cannot be read\n * answers `400 video_unreadable`; a provider the deployment has turned off\n * answers `403 model_not_available`.\n *\n * Common fields are typed; any other route field passes through.\n */\nexport interface VideoDepthParams extends GenerationSessionParams {\n /** The source video — a public http(s) URL. */\n videoUrl: string\n /** Default `video-depth-anything`. */\n provider?: VideoDepthProvider\n /** `small` / `base` / `large` (the default) — larger is more detailed and slower. */\n modelSize?: VideoDepthModelSize\n /** Default `grayscale`. `depth-anything-frames` renders only `grayscale` / `inferno`. */\n colormap?: VideoDepthColormap\n /** `video-depth-anything` only. Default `auto`. */\n resolution?: VideoDepthResolution\n /** `video-depth-anything` only: render the original and the depth next to each other. */\n sideBySide?: boolean\n [k: string]: unknown\n}\n\n/**\n * The `output_data` shape a finalized generation job writes. Every async\n * generation node persists one (or more) of these media URLs to\n * `jobs.output_data` on completion — `generate-image` → `imageUrl`,\n * `generate-video` / `combine-videos` / `merge-video-audio` / `video-upscale` /\n * `video-depth` → `videoUrl` (+ `thumbnailUrl`), `text-to-speech` / `generate-music` →\n * `audioUrl` (a `text-to-speech` run with `withTimestamps: true` on a model\n * that returns timings, and every `text-to-dialogue` run on one, also carries\n * `transcript`). Resolved by {@link NodesResource.runAndWait}. Extra fields may be\n * present, so the index signature is open.\n */\n/**\n * The completed `social-search` job's `output_data`: EVERY post the search\n * found, in the order it asked for (Social Search, Nodaro Cloud). Picking the\n * posts a workflow passes on is an editor step; a direct caller gets them all.\n */\nexport interface SocialSearchJobOutput extends NodeJobOutput {\n readonly json: readonly SocialPost[]\n readonly platform: SocialPlatform\n readonly mode: SocialSearchMode\n readonly query: string\n /** Non-fatal notes (\"only part of the results could be loaded\"). */\n readonly warnings?: readonly string[]\n}\n\nexport interface NodeJobOutput {\n /** `text-to-speech` / `generate-music` / audio nodes write here. For\n * `audio-separation` this is the primary stem (vocals). */\n readonly audioUrl?: string\n /** `audio-separation` (Demucs) per-stem URLs. `vocalUrl`/`instrumentalUrl`\n * in vocal/instrumental mode; the rest in full-stems mode. */\n readonly vocalUrl?: string\n readonly instrumentalUrl?: string\n readonly drumsUrl?: string\n readonly bassUrl?: string\n readonly otherUrl?: string\n readonly guitarUrl?: string\n readonly pianoUrl?: string\n /** `generate-video` / `combine-videos` / `merge-video-audio` / `video-upscale` / `video-depth` write here. */\n readonly videoUrl?: string\n /** `generate-image` / `edit-image` / `extract-frame` write here. */\n readonly imageUrl?: string\n /** Every image, when the job made more than one; `imageUrl` is the first. */\n readonly imageUrls?: readonly string[]\n /**\n * The output's pixel size. On an image job: the size of `imageUrl` as it is\n * stored — what you download, a free-tier watermark included — with EXIF\n * orientation applied, so the size a browser shows. Lay a grid tile out\n * before the image loads, or show and sort by size.\n *\n * Present on image jobs completed after this release (and on the jobs that\n * always recorded it: image overlay, video overlay, video mask, mask\n * composite). Absent when the size could not be read — never half a size.\n */\n readonly width?: number\n readonly height?: number\n /**\n * Beside `imageUrls`: each image with its pixel size, index-aligned\n * (`images[i]` is `imageUrls[i]`). Present on image jobs completed after\n * this release when at least one size was read; an entry whose size could\n * not be read has its `url` and no `width` / `height`.\n */\n readonly images?: readonly JobOutputImage[]\n /** Poster frame for video outputs. */\n readonly thumbnailUrl?: string\n readonly [k: string]: unknown\n}\n\n/** One image of a job that made several — see {@link NodeJobOutput.images}. */\nexport interface JobOutputImage {\n readonly url: string\n /** Pixel size as stored, EXIF orientation applied. Absent when it could not be read. */\n readonly width?: number\n readonly height?: number\n}\n\n/** Options for {@link NodesResource.runAndWait} and {@link NodesResource.runMany}. */\nexport interface RunAndWaitOptions {\n /**\n * Abort the run/poll loop. Aborting (or passing an already-aborted signal)\n * stops polling and rejects with {@link JobAbortedError}, whose `jobId`\n * names the job once it was submitted. Aborting stops the WAITING only: the\n * job keeps running and is charged, unless {@link cancelOnAbort} is set.\n */\n readonly signal?: AbortSignal\n /**\n * Also cancel the job when `signal` aborts after it was submitted\n * (`POST /v1/jobs/:id/cancel`, which refunds its credit hold — except a\n * metered LLM job whose call has started: it answers `inFlight: true`,\n * finishes, and is charged what it used). Best effort:\n * a failed cancel still rejects with the {@link JobAbortedError}. Default\n * `false` — aborting only stops waiting.\n */\n readonly cancelOnAbort?: boolean\n /** Called with each lean status the poll loop observes (running → terminal). */\n readonly onProgress?: (status: JobStatusResult) => void\n /** Poll interval in ms. Default 2000. */\n readonly pollMs?: number\n /** Wall-clock cap before giving up, in ms. Default ~15 min (900_000). */\n readonly maxMs?: number\n /**\n * `Idempotency-Key` for the submit half. Reuse the same value when retrying a\n * call that timed out, so the run is not started or charged twice. Omitted →\n * no key, which is the historical behaviour for every node that does not\n * require one.\n */\n readonly idempotencyKey?: string\n}\n\n/** Per-call transport controls for {@link NodesResource.run}. */\nexport interface RunNodeOptions {\n /** `Idempotency-Key` header. See {@link RunAndWaitOptions.idempotencyKey}. */\n readonly idempotencyKey?: string\n}\n\n/** One settled result from {@link NodesResource.runMany}. */\nexport interface RunManyResult {\n readonly jobId: string\n readonly output: NodeJobOutput\n}\n\n// Terminal statuses (poll loop stops on these) are handled explicitly in\n// `pollJob`: `completed` resolves output_data, `failed`/`cancelled` throw a\n// JobFailedError — matching studio's `completed | failed | cancelled` set.\nconst DEFAULT_POLL_MS = 2000\n/** Safety cap so a stuck job can't poll forever (~15 min at 2s). */\nconst DEFAULT_MAX_MS = 15 * 60 * 1000\n\nconst sleep = (ms: number, signal?: AbortSignal): Promise<void> =>\n new Promise<void>((resolve, reject) => {\n if (signal?.aborted) {\n reject(new JobAbortedError())\n return\n }\n const timer = setTimeout(() => {\n signal?.removeEventListener(\"abort\", onAbort)\n resolve()\n }, ms)\n function onAbort() {\n clearTimeout(timer)\n reject(new JobAbortedError())\n }\n signal?.addEventListener(\"abort\", onAbort, { once: true })\n })\n\n/** The error for a node type that cannot be run on its own. */\nfunction notRunnable(type: string, why: string): NodaroError {\n return new NodaroError(`Node type \"${type}\" has no route of its own to run it directly: ${why}.`, \"node_not_runnable\", 0)\n}\n\n/** A 404 for the route itself (the server has no such path), not for a missing resource. */\nconst isRouteNotFound = (err: unknown): boolean => err instanceof NotFoundError && /^Route\\b.*\\bnot found\\b/i.test(err.message)\n\n/** Pull a `{ jobId }` off a run result, or throw a labelled JobFailedError. */\nfunction extractJobId(result: RunNodeResult, label: string): string {\n if (result && typeof result === \"object\" && \"jobId\" in result) {\n const jobId = (result as { jobId: unknown }).jobId\n if (typeof jobId === \"string\") return jobId\n }\n // No jobId means the node ran inline/synchronously (meta-ads-scrape, etc.) or\n // the route shape changed — runAndWait is for async jobs, so this is an error.\n throw new JobFailedError(`${label} did not return a jobId`, \"\")\n}\n\n/** Whether a generate-image request makes several jobs: `count` above 1, or `models`. */\nfunction isImageBatchRequest(type: string, params: Record<string, unknown>): boolean {\n if (type !== \"generate-image\") return false\n return (typeof params.count === \"number\" && params.count > 1) || Array.isArray(params.models)\n}\n\n/** The job ids of a batch answer (several jobs from one call), or null for a single job. */\nfunction batchJobIds(result: RunNodeResult): string[] | null {\n const ids = (result as { jobIds?: unknown } | null)?.jobIds\n return Array.isArray(ids) && ids.every((id) => typeof id === \"string\") ? (ids as string[]) : null\n}\n\n/** A wait-for-one-job method asked to wait for a batch. */\nfunction batchRefusal(detail: string): NodaroError {\n return new NodaroError(\n `${detail}: this waits for one job — use nodes.runBatchAndWait() for a batch (count above 1, or models).`,\n \"batch_requires_run_batch_and_wait\",\n 0,\n )\n}\n\n/** The batch answer of a generate-image call, checked, or null. */\nfunction batchResultOf(result: RunNodeResult): GenerateImageBatchResult | null {\n const r = result as Partial<GenerateImageBatchResult> | null\n if (!r || typeof r.batchId !== \"string\" || !batchJobIds(result) || !Array.isArray(r.groups)) return null\n return r as GenerateImageBatchResult\n}\n\nexport class NodesResource {\n /** Runs poll through `jobs`, so the client must carry that resource too. */\n constructor(private client: NodaroClientCore & { readonly jobs: JobsResource }) {}\n\n /** List all known node descriptors. Server caches publicly for 5 minutes. */\n list(): Promise<{ data: NodeDescriptor[] }> {\n return this.client.request(\"GET\", \"/v1/nodes\")\n }\n\n /** Get a single node descriptor by type slug (e.g. \"generate-image\"). */\n get(type: string): Promise<{ data: NodeDescriptor }> {\n return this.client.request(\"GET\", `/v1/nodes/${encodeURIComponent(type)}`)\n }\n\n /**\n * Run a single node directly without wrapping it in a workflow. Posts\n * `params` as the request body to the node's API route. Most use\n * `POST /v1/<type>`; the rest are listed in `NODE_RUN_ROUTES` (exported by\n * `@nodaro/shared`): scene authoring uses `/v1/3d-scene/generate|edit`,\n * `llm-chat` uses `/v1/llm-chat/generate`, the Suno nodes `/v1/suno/…`, the\n * social post nodes `/v1/social/publish` (a per-platform node fills in its\n * `platform` when you leave it out), and render-video with a planType uses\n * `/v1/render-video/plan`.\n *\n * A node type with no route of its own (`NODE_TYPES_WITHOUT_RUN_ROUTE`, e.g.\n * `modify-image`, which runs through `image-to-image`) rejects with a\n * {@link NodaroError} of code `node_not_runnable` naming what to run\n * instead, without calling the API. A type that runs only inside a workflow\n * (an input, trigger, utility or parameter node such as `upload-image`)\n * rejects the same way once the API answers that it has no such route; a\n * 404 about a missing resource stays a `NotFoundError`.\n *\n * A model this deployment does not offer, or one an admin switched off,\n * is refused by the credit guard with a {@link ModelUnavailableError} (a\n * `ForbiddenError` whose `code` is `model_not_available` /\n * `model_disabled`) before any credits are held — pick another model;\n * retrying changes nothing. (The LLM and pipeline lanes still answer a\n * switched-off model with a 402 `InsufficientCreditsError` for now.)\n *\n * This is the SDK equivalent of the MCP server's verb tools — and the\n * path the Nodaro CLI uses for `nodaro nodes run <type>`.\n *\n * Most node types are async: the response includes `{ jobId }` and the\n * actual generation runs on a worker. Poll `client.jobs.get(jobId)` until\n * completed. Synchronous node types (`meta-ads-scrape`, etc.) return their\n * full result without a `jobId` field.\n *\n * @param type Node type slug — must match an entry in the registry\n * returned by `list()` (e.g. \"generate-image\").\n * @param params Request body. Field names must match the node's\n * `inputSchema` (see `get(type).inputSchema`).\n */\n run(type: \"generate-3d-scene\", params: GenerateScene3DParams): Promise<RunNodeResult>\n run(type: \"edit-3d-scene\", params: EditScene3DParams): Promise<RunNodeResult>\n run(type: \"render-video\", params: RenderScene3DParams): Promise<RunNodeResult>\n run(type: \"pro-3d-render\", params: Pro3DRenderRunParams, options?: RunNodeOptions): Promise<RunNodeResult>\n run(type: \"generate-image\", params: GenerateImageParams & ({ count: 2 | 3 | 4 } | { models: string[] }), options?: RunNodeOptions): Promise<GenerateImageBatchResult>\n run(type: \"generate-image\", params?: GenerateImageParams, options?: RunNodeOptions): Promise<RunNodeResult>\n run(type: \"text-to-speech\", params: TextToSpeechParams): Promise<RunNodeResult>\n run(type: \"generate-video\", params?: GenerateVideoParams, options?: RunNodeOptions): Promise<RunNodeResult>\n run(type: \"text-to-video\", params: TextToVideoParams, options?: RunNodeOptions): Promise<RunNodeResult>\n run(type: \"video-to-video\", params: VideoToVideoParams, options?: RunNodeOptions): Promise<RunNodeResult>\n run(type: \"video-upscale\", params: VideoUpscaleParams, options?: RunNodeOptions): Promise<RunNodeResult>\n run(type: \"assemble-narrated-video\", params?: AssembleNarratedVideoParams, options?: RunNodeOptions): Promise<RunNodeResult>\n run(type: \"social-search\", params: SocialSearchParams, options?: RunNodeOptions): Promise<RunNodeResult>\n run(type: \"video-depth\", params: VideoDepthParams, options?: RunNodeOptions): Promise<RunNodeResult>\n run(type: \"image-to-image\", params: ImageToImageParams, options?: RunNodeOptions): Promise<ImageJobStarted>\n run(type: \"edit-image\", params: EditImageParams, options?: RunNodeOptions): Promise<ImageJobStarted>\n run(type: \"generate-mask\", params: GenerateMaskParams, options?: RunNodeOptions): Promise<ImageJobStarted>\n /** Synchronous and free: answers the tiles, no job. */\n run(type: \"split-image\", params: SplitImageParams, options?: RunNodeOptions): Promise<SplitImageResult>\n run(type: string, params?: Record<string, unknown>, options?: RunNodeOptions): Promise<RunNodeResult>\n run(type: string, params: Record<string, unknown> = {}, options: RunNodeOptions = {}): Promise<RunNodeResult | GenerateImageBatchResult> {\n // The route comes from the table the platform's workflow engine uses\n // too; only render-video's plan route depends on the body.\n const route = type === \"render-video\" && typeof params.planType === \"string\" ? \"/v1/render-video/plan\" : nodeRunRoute(type)\n if (!route) return Promise.reject(notRunnable(type, NODE_TYPES_WITHOUT_RUN_ROUTE[type]!))\n // A per-platform social node publishes through the shared route, which\n // needs the platform the node type stands for.\n const platform = SOCIAL_POST_NODE_PLATFORM[type]\n const body = platform && params.platform === undefined ? { ...params, platform } : params\n // Only a type on the `/v1/<type>` convention is relabelled: a listed\n // route that 404s means a platform that predates it, not a node that\n // cannot run.\n const conventional = !Object.prototype.hasOwnProperty.call(NODE_RUN_ROUTES, type)\n return this.client\n .request<RunNodeResult>(\"POST\", route, {\n body,\n // Transport-level retry safety, opt-in per call. The platform reads the\n // standard header, so a caller that reuses a key on a retry gets the\n // same run back instead of a second charge.\n ...(options.idempotencyKey ? { headers: { \"Idempotency-Key\": options.idempotencyKey } } : {}),\n })\n .catch((err: unknown) => {\n if (conventional && isRouteNotFound(err)) throw notRunnable(type, \"it runs only inside a workflow (client.workflows.run)\")\n throw err\n })\n }\n\n /**\n * The price of a run before it starts (`POST /v1/quote`). Send exactly the\n * body you would send to {@link run}: the platform prices it with the same\n * code the run route reserves with — validation, measuring reference clips,\n * the price id and the credit amount — but starts nothing and charges\n * nothing.\n *\n * `reserve` is what the run will hold when it starts; `expected`, when\n * present, is what it should actually cost (a Seedance edit renders the\n * source clip's length). A run settles to what was generated, never above\n * `reserve`. Rejects with the same `400` the run would answer for an\n * invalid body. Typed for the video lanes; any other node type takes its\n * run body as-is.\n *\n * @param type Node type slug, as for {@link run}.\n * @param params The run body.\n */\n quote(type: \"text-to-video\", params: TextToVideoParams): Promise<NodeQuote>\n quote(type: \"generate-video\", params: GenerateVideoParams): Promise<NodeQuote>\n quote(type: \"video-to-video\", params: VideoToVideoParams): Promise<NodeQuote>\n /** A Seedance 2.5 draft's 1080p finalize (`seedance-2-5-hd`) is priced from\n * the draft itself, including the clips it was made with. */\n quote(type: \"video-upscale\", params: VideoUpscaleParams): Promise<NodeQuote>\n quote(type: string, params?: Record<string, unknown>): Promise<NodeQuote>\n async quote(type: string, params: Record<string, unknown> = {}): Promise<NodeQuote> {\n const res = await this.client.request<{ data: NodeQuote }>(\"POST\", \"/v1/quote\", { body: { type, params } })\n return res.data\n }\n\n /**\n * Run a single async node to completion: {@link run} it, extract the\n * `{ jobId }`, then client-poll `jobs.getStatus(jobId)` every `pollMs`\n * (default 2000) until a terminal status, up to `maxMs` (default ~15 min).\n *\n * Resolves the job's typed `output_data` ({@link NodeJobOutput}) on\n * `completed`. Throws (all typed, catchable by `instanceof`):\n * - {@link InsufficientCreditsError} / {@link StorageExceededError} etc. —\n * surfaced by the underlying {@link run} on 402/413/… before any poll.\n * - {@link ModelUnavailableError} — a model this deployment does not offer\n * (or one an admin switched off), refused by the credit guard in\n * {@link run} before credits are held.\n * - {@link JobFailedError} — terminal `failed`/`cancelled` (carries the\n * job's `error_message` + `jobId`).\n * - {@link JobTimeoutError} — `maxMs` deadline exceeded before terminal.\n * - {@link JobAbortedError} — `signal` fired (or was already aborted);\n * polling stops immediately.\n * - {@link JobHeldError} — the job entered `pending_review` on a deployment\n * that registers a job policy. Ends the poll on the FIRST held tick (that\n * status waits on a human, not on the job) and does NOT cancel it.\n * - {@link JobBlockedError} — a 422 from {@link run} before any poll: the\n * deployment's job policy refused the request outright.\n *\n * Polling is fully client-side (no server function blocks) — the same model\n * thin clients use, lifted out of their hand-rolled run→poll loops.\n *\n * @param type Node type slug (e.g. \"generate-video\"). See {@link run}.\n * @param params Request body — field names match the node's `inputSchema`.\n * @param opts `signal` / `onProgress` / `pollMs` / `maxMs`.\n */\n runAndWait(type: \"generate-3d-scene\", params: GenerateScene3DParams, options?: RunAndWaitOptions): Promise<Scene3DJobOutput>\n runAndWait(type: \"edit-3d-scene\", params: EditScene3DParams, options?: RunAndWaitOptions): Promise<Scene3DJobOutput>\n runAndWait(type: \"render-video\", params: RenderScene3DParams, options?: RunAndWaitOptions): Promise<NodeJobOutput>\n runAndWait(type: \"pro-3d-render\", params: Pro3DRenderRunParams, options?: RunAndWaitOptions): Promise<Pro3DRenderJobOutput>\n runAndWait(type: \"generate-image\", params?: GenerateImageParams, opts?: RunAndWaitOptions): Promise<NodeJobOutput>\n runAndWait(type: \"text-to-speech\", params: TextToSpeechParams, opts?: RunAndWaitOptions): Promise<NodeJobOutput>\n runAndWait(type: \"generate-video\", params?: GenerateVideoParams, opts?: RunAndWaitOptions): Promise<NodeJobOutput>\n runAndWait(type: \"text-to-video\", params: TextToVideoParams, opts?: RunAndWaitOptions): Promise<NodeJobOutput>\n runAndWait(type: \"video-to-video\", params: VideoToVideoParams, opts?: RunAndWaitOptions): Promise<NodeJobOutput>\n runAndWait(type: \"video-upscale\", params: VideoUpscaleParams, opts?: RunAndWaitOptions): Promise<NodeJobOutput>\n runAndWait(type: \"assemble-narrated-video\", params?: AssembleNarratedVideoParams, opts?: RunAndWaitOptions): Promise<NodeJobOutput>\n runAndWait(type: \"social-search\", params: SocialSearchParams, opts?: RunAndWaitOptions): Promise<SocialSearchJobOutput>\n runAndWait(type: \"video-depth\", params: VideoDepthParams, opts?: RunAndWaitOptions): Promise<NodeJobOutput>\n runAndWait(type: \"image-to-image\", params: ImageToImageParams, opts?: RunAndWaitOptions): Promise<NodeJobOutput>\n runAndWait(type: \"edit-image\", params: EditImageParams, opts?: RunAndWaitOptions): Promise<NodeJobOutput>\n runAndWait(type: \"generate-mask\", params: GenerateMaskParams, opts?: RunAndWaitOptions): Promise<GenerateMaskJobOutput>\n runAndWait<T extends string>(type: T, params?: Record<string, unknown>, opts?: RunAndWaitOptions): Promise<T extends \"pro-3d-render\" ? Pro3DRenderJobOutput : T extends \"generate-3d-scene\" | \"edit-3d-scene\" ? Scene3DJobOutput : T extends \"generate-mask\" ? GenerateMaskJobOutput : NodeJobOutput>\n async runAndWait(\n type: string,\n params: Record<string, unknown> = {},\n opts: RunAndWaitOptions = {},\n ): Promise<NodeJobOutput> {\n if (opts.signal?.aborted) throw new JobAbortedError()\n // A batch would be waited on as its first job alone — refused before\n // anything is submitted or charged.\n if (isImageBatchRequest(type, params)) throw batchRefusal(`${type} with count above 1 or models makes several jobs`)\n const result = await this.run(type, params, { idempotencyKey: opts.idempotencyKey })\n const ids = batchJobIds(result)\n if (ids && ids.length > 1) throw batchRefusal(`${type} started ${ids.length} jobs (${ids.join(\", \")}), which keep running`)\n const jobId = extractJobId(result, type)\n return this.pollJob(jobId, type, opts)\n }\n\n /**\n * Run a generate-image BATCH — `count` above 1 and/or `models` — to the end:\n * submit it once ({@link run}, with your `idempotencyKey` if any), then wait\n * for every job at once, each the way {@link runAndWait} waits.\n *\n * Resolves `{ batch, results }`: the submit's answer\n * ({@link GenerateImageBatchResult} — ids, groups by model, credits) and one\n * {@link BatchJobOutcome} per job, in `batch.jobIds` order — its output, or the\n * typed error that ended the wait for it. One image failing never discards the\n * others. Rejects only before any job exists (the submit's own errors, e.g.\n * `InsufficientCreditsError` with the batch total as `required`), and on\n * `signal` ({@link JobAbortedError}; `cancelOnAbort` cancels every job).\n *\n * A request for one image is refused before anything is sent (code\n * `not_a_batch`) — wait for it with {@link runAndWait}.\n */\n async runBatchAndWait(\n type: \"generate-image\",\n params: GenerateImageParams,\n opts: RunAndWaitOptions = {},\n ): Promise<GenerateImageBatchOutput> {\n if (opts.signal?.aborted) throw new JobAbortedError()\n if (!isImageBatchRequest(type, params)) {\n throw new NodaroError(\n \"runBatchAndWait waits for a batch — count above 1, or models; wait for one image with nodes.runAndWait().\",\n \"not_a_batch\",\n 0,\n )\n }\n const result = await this.run(type, params, { idempotencyKey: opts.idempotencyKey })\n const batch = batchResultOf(result)\n if (!batch) throw new JobFailedError(`${type} did not answer with a batch`, \"\")\n const modelOf = new Map(batch.groups.flatMap((group) => group.jobIds.map((id) => [id, group.model] as const)))\n const results = await Promise.all(\n batch.jobIds.map(async (jobId): Promise<BatchJobOutcome> => {\n const model = modelOf.get(jobId) ?? \"\"\n try {\n return { jobId, model, status: \"completed\", output: await this.pollJob(jobId, type, opts) }\n } catch (err) {\n if (err instanceof JobAbortedError || !(err instanceof NodaroError)) throw err\n return { jobId, model, status: \"error\", error: err }\n }\n }),\n )\n return { batch, results }\n }\n\n /**\n * Fan out N async runs of the same node `type` to completion concurrently —\n * the candidate-grid path (generate N stills/clips in parallel). Each runs\n * via {@link runAndWait}; resolves once ALL settle, to an array of\n * `{ jobId, output }` in input order. Rejects (and the rejection wins) if any\n * single run rejects — same typed errors as {@link runAndWait}, including\n * {@link JobHeldError} when one candidate is held for review while the\n * others complete. A shared `signal` aborts the whole batch.\n *\n * @param type Node type slug, applied to every entry.\n * @param paramsList One request body per candidate.\n * @param opts Shared `signal` / `cancelOnAbort` / `onProgress` / `pollMs` / `maxMs`.\n */\n async runMany(\n type: string,\n paramsList: Record<string, unknown>[],\n opts: RunAndWaitOptions = {},\n ): Promise<RunManyResult[]> {\n if (opts.signal?.aborted) throw new JobAbortedError()\n // Each entry is waited on as one job: a batch entry is refused up front.\n if (paramsList.some((params) => isImageBatchRequest(type, params))) {\n throw batchRefusal(`a ${type} entry with count above 1 or models makes several jobs`)\n }\n return Promise.all(\n paramsList.map(async (params) => {\n if (opts.signal?.aborted) throw new JobAbortedError()\n const result = await this.run(type, params)\n const jobId = extractJobId(result, type)\n const output = await this.pollJob(jobId, type, opts)\n return { jobId, output }\n }),\n )\n }\n\n /** {@link pollUntilSettled}, plus what an abort does to the job: it keeps\n * running unless `cancelOnAbort` asks to cancel it too, and the rejection\n * always names it (an abort landing mid-sleep carries no id of its own). */\n private async pollJob(\n jobId: string,\n label: string,\n opts: RunAndWaitOptions,\n ): Promise<NodeJobOutput> {\n try {\n return await this.pollUntilSettled(jobId, label, opts)\n } catch (err) {\n if (!(err instanceof JobAbortedError)) throw err\n if (opts.cancelOnAbort) await this.client.jobs.cancel(jobId).catch(() => undefined)\n throw err.jobId ? err : new JobAbortedError(err.message, jobId)\n }\n }\n\n /** Poll an already-kicked job id until it stops moving; resolve output_data\n * or throw. Two non-terminal statuses end the loop: an abort, and\n * `pending_review` (a job policy held the output for a human — see\n * {@link JobHeldError}). */\n private async pollUntilSettled(\n jobId: string,\n label: string,\n opts: RunAndWaitOptions,\n ): Promise<NodeJobOutput> {\n const pollMs = opts.pollMs ?? DEFAULT_POLL_MS\n const maxMs = opts.maxMs ?? DEFAULT_MAX_MS\n const deadline = Date.now() + maxMs\n for (;;) {\n if (opts.signal?.aborted) throw new JobAbortedError(undefined, jobId)\n const { data } = await this.client.jobs.getStatus(jobId)\n opts.onProgress?.(data)\n if (data.status === \"completed\") {\n return (data.output_data ?? {}) as NodeJobOutput\n }\n if (data.status === \"failed\" || data.status === \"cancelled\") {\n throw new JobFailedError(\n data.error_message ?? `${label} ${data.status}`,\n jobId,\n data.status,\n )\n }\n // `pending_review` is in-flight but PARKED ON A HUMAN — it does not\n // progress on its own, so continuing the loop would burn `maxMs` (15 min\n // by default) and then report a `JobTimeoutError` that misdescribes what\n // happened. End here instead, without cancelling: the output exists, the\n // reservation stays reserved, and a reviewer resolves it.\n if (data.status === \"pending_review\") {\n throw new JobHeldError(`${label} is awaiting review`, jobId)\n }\n if (Date.now() > deadline) {\n throw new JobTimeoutError(`${label} timed out`, jobId, maxMs)\n }\n await sleep(pollMs, opts.signal)\n }\n }\n}\n"]}
|
|
@@ -25,13 +25,24 @@ var UnauthorizedError = class extends NodaroError {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
var ForbiddenError = class extends NodaroError {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/** `code` defaults to `"forbidden"`; {@link ModelUnavailableError} passes its own. */
|
|
29
|
+
constructor(message = "Forbidden", missingScope, code = "forbidden") {
|
|
30
|
+
super(message, code, 403);
|
|
30
31
|
this.missingScope = missingScope;
|
|
31
32
|
this.name = "ForbiddenError";
|
|
32
33
|
}
|
|
33
34
|
missingScope;
|
|
34
35
|
};
|
|
36
|
+
var MODEL_UNAVAILABLE_CODES = /* @__PURE__ */ new Set([
|
|
37
|
+
"model_not_available",
|
|
38
|
+
"model_disabled"
|
|
39
|
+
]);
|
|
40
|
+
var ModelUnavailableError = class extends ForbiddenError {
|
|
41
|
+
constructor(code, message = "This model is not available") {
|
|
42
|
+
super(message, void 0, code);
|
|
43
|
+
this.name = "ModelUnavailableError";
|
|
44
|
+
}
|
|
45
|
+
};
|
|
35
46
|
var NotFoundError = class extends NodaroError {
|
|
36
47
|
constructor(message = "Not found") {
|
|
37
48
|
super(message, "not_found", 404);
|
|
@@ -66,12 +77,14 @@ var CreditCapExceededError = class extends InsufficientCreditsError {
|
|
|
66
77
|
}
|
|
67
78
|
};
|
|
68
79
|
var StorageExceededError = class extends NodaroError {
|
|
69
|
-
constructor(message = "Storage exceeded", limitBytes) {
|
|
80
|
+
constructor(message = "Storage exceeded", limitBytes, reason) {
|
|
70
81
|
super(message, "storage_exceeded", 413);
|
|
71
82
|
this.limitBytes = limitBytes;
|
|
83
|
+
this.reason = reason;
|
|
72
84
|
this.name = "StorageExceededError";
|
|
73
85
|
}
|
|
74
86
|
limitBytes;
|
|
87
|
+
reason;
|
|
75
88
|
};
|
|
76
89
|
var WorkflowConflictError = class extends NodaroError {
|
|
77
90
|
constructor(message = "Workflow was updated by another writer", currentUpdatedAt, currentVersion, currentRecord, code = "workflow_conflict") {
|
|
@@ -276,6 +289,10 @@ function selectError(status, body) {
|
|
|
276
289
|
throw new AppRunVersionChangedError(message, finite(parsed.runVersion), finite(parsed.appVersion));
|
|
277
290
|
}
|
|
278
291
|
if (status === 422 && code === "job_blocked") throw new JobBlockedError(read.message);
|
|
292
|
+
const modelCode = read.code;
|
|
293
|
+
if (status === 403 && modelCode !== void 0 && MODEL_UNAVAILABLE_CODES.has(modelCode)) {
|
|
294
|
+
throw new ModelUnavailableError(modelCode, read.message);
|
|
295
|
+
}
|
|
279
296
|
if (status === 403 && code === "insufficient_scope") {
|
|
280
297
|
throw new ForbiddenError(read.message, envelope.missingScope);
|
|
281
298
|
}
|
|
@@ -291,10 +308,10 @@ function selectError(status, body) {
|
|
|
291
308
|
}
|
|
292
309
|
throw new InsufficientCreditsError(read.message, required, available, read.code ?? "insufficient_credits");
|
|
293
310
|
}
|
|
294
|
-
if (status === 413) throw new StorageExceededError(read.message, envelope.limitBytes);
|
|
311
|
+
if (status === 413) throw new StorageExceededError(read.message, envelope.limitBytes, read.code);
|
|
295
312
|
throw new NodaroError(message, code, status);
|
|
296
313
|
}
|
|
297
314
|
|
|
298
|
-
export { AlreadyRunningError, AppRunVersionChangedError, CREDIT_CAP_CODES, ContinuationPreviewPendingError, ContinuationRefusedError, CreditCapExceededError, ForbiddenError, InsufficientCreditsError, JobAbortedError, JobBlockedError, JobFailedError, JobHeldError, JobTimeoutError, NodaroError, NotFoundError, RateLimitedError, StorageExceededError, StudioOpError, StudioPreviewAppliedError, StudioPreviewUnavailable, UnauthorizedError, WorkflowConflictError, throwFromResponse };
|
|
299
|
-
//# sourceMappingURL=chunk-
|
|
300
|
-
//# sourceMappingURL=chunk-
|
|
315
|
+
export { AlreadyRunningError, AppRunVersionChangedError, CREDIT_CAP_CODES, ContinuationPreviewPendingError, ContinuationRefusedError, CreditCapExceededError, ForbiddenError, InsufficientCreditsError, JobAbortedError, JobBlockedError, JobFailedError, JobHeldError, JobTimeoutError, MODEL_UNAVAILABLE_CODES, ModelUnavailableError, NodaroError, NotFoundError, RateLimitedError, StorageExceededError, StudioOpError, StudioPreviewAppliedError, StudioPreviewUnavailable, UnauthorizedError, WorkflowConflictError, throwFromResponse };
|
|
316
|
+
//# sourceMappingURL=chunk-JJMQ2EVL.js.map
|
|
317
|
+
//# sourceMappingURL=chunk-JJMQ2EVL.js.map
|
|
@@ -0,0 +1 @@
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AAK,OAAO,CAAA;AACxD,EAAA,IAAI,WAAW,GAAA,EAAK,MAAM,IAAI,gBAAA,CAAiB,KAAK,OAAO,CAAA;AAC3D,EAAA,IAAI,WAAW,GAAA,EAAK;AAIlB,IAAA,MAAM,WAAW,MAAA,CAAO,QAAA,CAAS,QAAQ,CAAA,IAAK,MAAA,CAAO,OAAO,QAAQ,CAAA;AACpE,IAAA,MAAM,SAAA,GAAY,MAAA,CAAO,QAAA,CAAS,SAAS,CAAA,IAAK,MAAA,CAAO,MAAA,CAAO,OAAO,CAAA,IAAK,MAAA,CAAO,MAAA,CAAO,SAAS,CAAA;AACjG,IAAA,MAAM,UAAU,IAAA,CAAK,IAAA;AACrB,IAAA,IAAI,OAAA,KAAY,MAAA,IAAa,gBAAA,CAAiB,GAAA,CAAI,OAAO,CAAA,EAAG;AAC1D,MAAA,MAAM,IAAI,sBAAA,CAAuB,OAAA,EAAS,IAAA,CAAK,OAAA,EAAS,UAAU,SAAS,CAAA;AAAA,IAC7E;AACA,IAAA,MAAM,IAAI,yBAAyB,IAAA,CAAK,OAAA,EAAS,UAAU,SAAA,EAAW,IAAA,CAAK,QAAQ,sBAAsB,CAAA;AAAA,EAC3G;AACA,EAAA,IAAI,MAAA,KAAW,GAAA,EAAK,MAAM,IAAI,oBAAA,CAAqB,KAAK,OAAA,EAAS,QAAA,CAAS,UAAA,EAAY,IAAA,CAAK,IAAI,CAAA;AAC/F,EAAA,MAAM,IAAI,WAAA,CAAY,OAAA,EAAS,IAAA,EAAM,MAAM,CAAA;AAC7C","file":"chunk-JJMQ2EVL.js","sourcesContent":["import type { StudioOpsResponse } from \"./resources/studio-productions.js\"\n\nexport class NodaroError extends Error {\n /**\n * Every other field of the server's error envelope (`{ error: { code,\n * message, … } }`), as it was sent: for example a trend refusal's `slot`, a\n * publish refusal's `reasons`, a validation error's `issues`. Empty when the\n * envelope had nothing else, or for an error the SDK made itself. A copy —\n * changing it changes nothing else.\n */\n public readonly details: Readonly<Record<string, unknown>> = {}\n\n constructor(\n message: string,\n public readonly code: string,\n public readonly status: number,\n details?: Readonly<Record<string, unknown>>,\n ) {\n super(message)\n this.name = \"NodaroError\"\n if (details) this.details = { ...details }\n }\n}\n\nexport class UnauthorizedError extends NodaroError {\n constructor(message = \"Authentication required\") {\n super(message, \"unauthorized\", 401)\n this.name = \"UnauthorizedError\"\n }\n}\n\nexport class ForbiddenError extends NodaroError {\n /** `code` defaults to `\"forbidden\"`; {@link ModelUnavailableError} passes its own. */\n constructor(message = \"Forbidden\", public readonly missingScope?: string, code = \"forbidden\") {\n super(message, code, 403)\n this.name = \"ForbiddenError\"\n }\n}\n\nexport type ModelUnavailableCode = \"model_not_available\" | \"model_disabled\"\n\n/**\n * The 403 codes {@link ModelUnavailableError} carries: a model this\n * deployment does not offer (`model_not_available` — outside its edition or\n * surface, or hidden by its operator) and a model an admin switched off on\n * the models page (`model_disabled`).\n */\nexport const MODEL_UNAVAILABLE_CODES: ReadonlySet<ModelUnavailableCode> = new Set<ModelUnavailableCode>([\n \"model_not_available\",\n \"model_disabled\",\n])\n\n/**\n * HTTP 403 refusing the MODEL, not the caller: this deployment does not offer\n * it, or an admin switched it off. Answered by the credit guard before any\n * credits are held (the LLM and pipeline lanes still answer a switched-off\n * model with a 402 for now).\n * Choosing another model is the remedy — retrying, topping up or a wider\n * scope changes nothing. A {@link ForbiddenError}, so existing catches keep\n * working; `code` is the server's own code and says which. The envelope\n * names no model: what was refused is the request's own `provider` (or, for\n * a fan-out, one of its `models`).\n */\nexport class ModelUnavailableError extends ForbiddenError {\n declare readonly code: ModelUnavailableCode\n\n constructor(code: ModelUnavailableCode, message = \"This model is not available\") {\n super(message, undefined, code)\n this.name = \"ModelUnavailableError\"\n }\n}\n\nexport class NotFoundError extends NodaroError {\n constructor(message = \"Not found\") {\n super(message, \"not_found\", 404)\n this.name = \"NotFoundError\"\n }\n}\n\nexport class RateLimitedError extends NodaroError {\n constructor(message = \"Rate limited\") {\n super(message, \"rate_limited\", 429)\n this.name = \"RateLimitedError\"\n }\n}\n\n/**\n * HTTP 402: the run costs more than the caller may spend. `code` is the\n * refusal's own code — `insufficient_credits` for the caller's own balance, or\n * another 402 code such as `free_video_limit`. A spending cap someone else set\n * (a workspace budget, a member cap, a per-user allowance) is the subclass\n * {@link CreditCapExceededError}, so `instanceof InsufficientCreditsError`\n * still catches every 402.\n */\nexport class InsufficientCreditsError extends NodaroError {\n constructor(\n message = \"Insufficient credits\",\n public readonly required?: number,\n public readonly available?: number,\n code = \"insufficient_credits\",\n ) {\n super(message, code, 402)\n this.name = \"InsufficientCreditsError\"\n }\n}\n\n/** The 402 codes of a spending cap set by someone other than the caller. */\nexport type CreditCapCode = \"budget_exceeded\" | \"member_cap_exceeded\" | \"user_allowance_exceeded\"\n\n/**\n * The 402 codes {@link CreditCapExceededError} carries: the workspace's budget\n * (`budget_exceeded`), the caller's cap in that workspace\n * (`member_cap_exceeded`), the deployment's per-user allowance\n * (`user_allowance_exceeded`).\n */\nexport const CREDIT_CAP_CODES: ReadonlySet<CreditCapCode> = new Set<CreditCapCode>([\n \"budget_exceeded\",\n \"member_cap_exceeded\",\n \"user_allowance_exceeded\",\n])\n\n/**\n * HTTP 402 from a spending cap, not from the caller's own balance: topping up\n * does not help — whoever set the cap (the workspace's owner, the deployment's\n * operator) has to raise it. An {@link InsufficientCreditsError}, so existing\n * catches keep working; `code` says which cap. `available`, when sent, is what\n * the cap has left.\n */\nexport class CreditCapExceededError extends InsufficientCreditsError {\n declare readonly code: CreditCapCode\n\n constructor(code: CreditCapCode, message = \"A credit cap cannot cover this run\", required?: number, available?: number) {\n super(message, required, available, code)\n this.name = \"CreditCapExceededError\"\n }\n}\n\n/**\n * HTTP 413: what was sent does not fit. `code` is always `storage_exceeded`;\n * `reason` is the platform's own code, when the answer carried one:\n * `storage_limit_exceeded` is a full storage, while `file_too_large` is a\n * single file over the limit, not a full storage (likewise\n * `payload_too_large`, `post_too_large`, `duration_exceeded`).\n */\nexport class StorageExceededError extends NodaroError {\n constructor(\n message = \"Storage exceeded\",\n public readonly limitBytes?: number,\n /** The platform's own code for this 413, e.g. `storage_limit_exceeded` or `file_too_large`. */\n public readonly reason?: string,\n ) {\n super(message, \"storage_exceeded\", 413)\n this.name = \"StorageExceededError\"\n }\n}\n\n/**\n * Optimistic-concurrency rejection (HTTP 409 `workflow_conflict`): the workflow\n * was written by another tab/device after the state carried in\n * `expectedUpdatedAt`/`expectedVersion` was read. `currentRecord` — when the\n * server includes it — is the full current workflow: merge your changes onto it\n * and retry with its fresh `updatedAt`, no follow-up GET needed.\n */\nexport class WorkflowConflictError extends NodaroError {\n constructor(\n message = \"Workflow was updated by another writer\",\n public readonly currentUpdatedAt?: string,\n public readonly currentVersion?: number,\n public readonly currentRecord?: Record<string, unknown>,\n /**\n * The wire code this conflict actually arrived with.\n *\n * `production_busy` is the studio production routes' own 409: the row\n * changed under a read-modify-write and the server exhausted its retries.\n * It is the same situation and the same remedy — re-read and apply again —\n * so it is the same ERROR, and a caller catching `WorkflowConflictError`\n * handles both. The code stays truthful because a caller that logs or\n * branches on it should see what the server said, not what the class is\n * usually called.\n */\n code: WorkflowConflictCode = \"workflow_conflict\",\n ) {\n super(message, code, 409)\n this.name = \"WorkflowConflictError\"\n }\n}\n\n/** The 409 codes that mean \"somebody else wrote first; re-read and retry\". */\nexport type WorkflowConflictCode = \"workflow_conflict\" | \"production_busy\"\n\n/**\n * A studio operation batch was refused, and the error names WHICH operation\n * (`opIndex`, zero-based) was wrong. Nothing in the batch was written: a batch\n * applies atomically or not at all, so fix that one operation and send the\n * whole batch again.\n *\n * Selected by SHAPE — any 4xx carrying a numeric `opIndex` — not by a list of\n * codes, so a new refusal reason (`op_invalid`, `op_target_missing`, whatever\n * the server adds next) reaches the caller as this error without an SDK\n * release. `code` is whatever the server sent.\n */\nexport class StudioOpError extends NodaroError {\n constructor(\n message: string,\n code: string,\n status: number,\n /** Zero-based index into the `ops` array that was sent. */\n public readonly opIndex: number,\n ) {\n super(message, code, status)\n this.name = \"StudioOpError\"\n }\n}\n\n/** The 409 codes whose answer names the job to turn to instead (a top-level `jobId`). */\nconst CONTINUATION_REFUSAL_CODES: ReadonlySet<string> = new Set([\n \"already_running\",\n \"continuation_superseded\",\n \"render_final_already_rendered\",\n])\n\n/**\n * A 409 that names the job to turn to instead: continuing a use-case run\n * (`client.edit.continueUseCase`) answers `already_running` (a continuation is\n * under way, or one that already completed — follow `jobId`),\n * `continuation_superseded` (a later continuation failed too — continue\n * `jobId` instead) or `render_final_already_rendered` (a Render final with this\n * very edit already completed — `jobId` holds the result). `code` and `status`\n * are what the server sent. Selected for exactly those three codes when the\n * answer carries a top-level `jobId`; every other 409 stays a plain\n * `NodaroError`.\n */\nexport class ContinuationRefusedError extends NodaroError {\n constructor(\n message: string,\n code: string,\n /** The job the refusal names. */\n public readonly jobId: string,\n ) {\n super(message, code, 409)\n this.name = \"ContinuationRefusedError\"\n }\n}\n\n/**\n * The one run that finishes a continuation held at a Preview review (the\n * `next` of {@link ContinuationPreviewPendingError}): pass these three fields\n * to `client.workflows.run`. It continues that execution, runs each held render\n * at Final and each held Tighten Episode continuing the run that made its\n * Preview, then every node after them.\n */\nexport interface HeldFinalRun {\n continueFromExecutionId: string\n /** The nodes it runs, in canvas order. */\n nodeIds: string[]\n /** For this run only: each held render at Final, each held use-case node's `useCaseContinue`. */\n inputOverrides: Record<string, Record<string, unknown>>\n}\n\n/**\n * HTTP 409 `continuation_preview_pending`: a continue-from-failed\n * (`client.workflows.run` with `continueMode: \"from-failed\"`) whose run's\n * newest later continuation completed by stopping at a Preview review, so\n * continuing again would stop there too. `executionId` is that continuation;\n * `renderNodeIds` the Apply EDL renders and `reviewNodeIds` the Tighten Episode\n * nodes holding it; `next` the run that finishes them — send it first\n * (`client.workflows.run(workflowId, error.next)`), then continue. Absent only\n * when the server could not name it. For a single held render, `next` is that\n * render's `client.workflows.renderFinal`.\n */\nexport class ContinuationPreviewPendingError extends NodaroError {\n constructor(\n message: string,\n public readonly executionId: string,\n public readonly renderNodeIds: readonly string[],\n public readonly reviewNodeIds: readonly string[],\n public readonly next?: HeldFinalRun,\n ) {\n super(message, \"continuation_preview_pending\", 409)\n this.name = \"ContinuationPreviewPendingError\"\n }\n}\n\nconst stringList = (v: unknown): string[] => (Array.isArray(v) ? v.filter((id): id is string => typeof id === \"string\") : [])\n\n/** A `next` as the server sends it, or undefined for anything else. */\nfunction heldFinalRunOf(v: unknown): HeldFinalRun | undefined {\n if (!v || typeof v !== \"object\") return undefined\n const r = v as Record<string, unknown>\n if (typeof r.continueFromExecutionId !== \"string\" || !Array.isArray(r.nodeIds)) return undefined\n if (!r.inputOverrides || typeof r.inputOverrides !== \"object\" || Array.isArray(r.inputOverrides)) return undefined\n return {\n continueFromExecutionId: r.continueFromExecutionId,\n nodeIds: stringList(r.nodeIds),\n inputOverrides: r.inputOverrides as Record<string, Record<string, unknown>>,\n }\n}\n\n/**\n * HTTP 409 `already_running` that names the execution under way (a top-level\n * `executionId`): the run you asked to start or continue is still running —\n * follow `executionId` (`client.executions.get`) instead of starting it again.\n * Sent by the workflow run route and by an app run's Retry\n * (`client.apps.resume`). An `already_running` that names a job instead stays\n * {@link ContinuationRefusedError}; one that names nothing, a plain\n * `NodaroError`.\n */\nexport class AlreadyRunningError extends NodaroError {\n constructor(\n message: string,\n /** The execution under way. */\n public readonly executionId: string,\n ) {\n super(message, \"already_running\", 409)\n this.name = \"AlreadyRunningError\"\n }\n}\n\n/**\n * HTTP 409 `app_run_version_changed`: a Retry of a failed app run\n * (`client.apps.resume`) refused because the app is on another version than\n * the one the run ran — continuing would mix them. `runVersion` is the run's\n * version, `appVersion` the one you are on (the `version` you sent, else the\n * app's latest). Start the run over (`client.apps.run`) to run `appVersion`,\n * or send `{ version: runVersion }` to continue on the run's own version.\n * Nothing was written or billed. Selected by code; the two numbers are\n * `undefined` when the answer does not carry them.\n */\nexport class AppRunVersionChangedError extends NodaroError {\n constructor(\n message: string,\n public readonly runVersion?: number,\n public readonly appVersion?: number,\n ) {\n super(message, \"app_run_version_changed\", 409)\n this.name = \"AppRunVersionChangedError\"\n }\n}\n\n/**\n * HTTP 422 `job_blocked`. A job policy registered by this deployment refused\n * the generation **before it ran** — no job was created, nothing was reserved\n * and nothing was charged. `message` is the policy's user-safe text: show it\n * as-is. Do not retry the identical request; whether the same input would be\n * judged differently is the deployment's policy's business.\n *\n * Only occurs on deployments that register a job policy. Selected by `code`,\n * not by status, the same way `workflow_conflict` narrows a 409 above — any\n * other 422 stays a plain `NodaroError`.\n */\nexport class JobBlockedError extends NodaroError {\n constructor(message = \"Blocked by this deployment's content policy\") {\n super(message, \"job_blocked\", 422)\n this.name = \"JobBlockedError\"\n }\n}\n\n/**\n * A job reached a terminal `failed`/`cancelled` status while being awaited by\n * `nodes.runAndWait` / `nodes.runMany`. Not an HTTP-level error (the polls\n * themselves succeeded), so `status` is 0 — distinguish it by type/`code`.\n * Carries the job's own `error_message` (as the message) and `jobId`.\n */\nexport class JobFailedError extends NodaroError {\n constructor(\n message: string,\n public readonly jobId: string,\n /** The terminal status that triggered the failure (`failed` | `cancelled`). */\n public readonly jobStatus: \"failed\" | \"cancelled\" = \"failed\",\n ) {\n super(message, \"job_failed\", 0)\n this.name = \"JobFailedError\"\n }\n}\n\n/**\n * `nodes.runAndWait` polled past its `maxMs` deadline without the job reaching\n * a terminal status. Not an HTTP error — `status` is 0; catch by type/`code`.\n */\nexport class JobTimeoutError extends NodaroError {\n constructor(\n message: string,\n public readonly jobId: string,\n /** The wall-clock deadline (ms) that was exceeded. */\n public readonly timeoutMs: number,\n ) {\n super(message, \"job_timeout\", 0)\n this.name = \"JobTimeoutError\"\n }\n}\n\n/**\n * The caller's `AbortSignal` fired while `nodes.runAndWait` was polling (or it\n * was already aborted on entry). Polling stops and this rejects. Not an HTTP\n * error — `status` is 0; catch by type/`code`.\n */\nexport class JobAbortedError extends NodaroError {\n constructor(message = \"Aborted\", public readonly jobId?: string) {\n super(message, \"job_aborted\", 0)\n this.name = \"JobAbortedError\"\n }\n}\n\n/**\n * A batch preview was asked for and this deployment cannot give one, so\n * NOTHING was sent: the batch is still unapplied and the production untouched.\n *\n * A preview is two requests because the route's body is parsed in strip mode —\n * a deployment that predates the preview silently DROPS the flag and APPLIES\n * the batch. So the SDK asks with an EMPTY batch first and sends the real one\n * only when that answer carries the `dryRun` marker. This is what it throws\n * when the answer does not: whatever the older deployment made of an empty\n * batch, the caller's batch never left.\n *\n * The remedy is a deployment that serves the preview — there is nothing to\n * retry here. To apply the batch instead, send it without the flag.\n *\n * A deployment that REFUSES the empty batch outright throws its own error\n * instead of this one, which is the right way round: the route's message says\n * more than \"unavailable\" does.\n *\n * Not an HTTP error: the request itself succeeded and answered the older shape.\n * `status` is 0; catch by type/`code`.\n */\nexport class StudioPreviewUnavailable extends NodaroError {\n constructor(\n message = \"This deployment does not preview operation batches; nothing was sent\",\n ) {\n super(message, \"studio_preview_unavailable\", 0)\n this.name = \"StudioPreviewUnavailable\"\n }\n}\n\n/**\n * A batch preview was asked for and the batch was APPLIED instead. The\n * production is written; this is the opposite of {@link\n * StudioPreviewUnavailable}, where nothing was sent.\n *\n * How it happens: the preview's proving ping and the batch are two requests,\n * and a fleet mid-rollout can serve them from different deployments. The ping\n * answers the marker, the batch reaches a deployment that predates the preview,\n * parses in strip mode, drops the flag and writes. The SDK cannot recall that\n * request — by the time the answer comes back the change has landed — so it\n * refuses to call the result a preview, which is the only thing still in its\n * gift. `receipts` and `warnings` are on both shapes, so an unchecked reply\n * would have shown a person what ALREADY happened under the heading of what\n * would.\n *\n * `applied` is what the route answered: the ordinary apply reply, whose\n * `production` and `version` are now the truth. Adopt them the way a plain\n * apply's caller does — do NOT re-send the batch, and do not present it for\n * approval.\n *\n * Not an HTTP error: the request succeeded, at the wrong thing. `status` is 0.\n */\nexport class StudioPreviewAppliedError extends NodaroError {\n constructor(\n /**\n * The apply reply the route sent back, as it sent it. An answer this\n * package does not recognise arrives here unchanged rather than being\n * dressed up: it is what the deployment said about a batch it took.\n *\n * `undefined` when the answer carried no body at all — a 204, an empty\n * envelope. The refusal still fires, because a non-preview answer is never\n * handed back as a preview, but there is nothing to report and the SDK will\n * not invent it: whether the batch was applied is unknown from here, and\n * the caller settles it by re-reading the production.\n */\n public readonly applied: StudioOpsResponse | undefined,\n message = applied\n ? \"Asked for a preview and this deployment APPLIED the batch; the change is written — see `applied`\"\n : \"Asked for a preview and this deployment answered with neither one nor a body to read; the batch may have been applied — re-read the production before deciding anything\",\n ) {\n super(message, \"studio_preview_applied\", 0)\n this.name = \"StudioPreviewAppliedError\"\n }\n}\n\n/**\n * The awaited job entered `pending_review`: a job policy registered by this\n * deployment held its output for a human reviewer. `pending_review` is\n * IN-FLIGHT, not terminal, so `nodes.runAndWait` / `nodes.runMany` end the\n * poll on the first tick they observe it rather than burning `maxMs` on a\n * status that no longer moves on its own.\n *\n * This does NOT cancel the job — the output exists, a human is reviewing it,\n * and the credit reservation stays `reserved` for the whole hold. Do not\n * re-run the request (a duplicate would be held too): re-fetch with\n * `jobs.get(jobId)` later, or surface \"awaiting review\" to your user and poll\n * `jobs.getStatus()` yourself. It resolves to `completed` (approved), `failed`\n * (rejected, with `error_hint.kind === \"policy-block\"`) or `cancelled`.\n *\n * Not an HTTP error — `status` is 0; catch by type/`code`.\n */\nexport class JobHeldError extends NodaroError {\n constructor(\n message: string,\n public readonly jobId: string,\n ) {\n super(message, \"job_held\", 0)\n this.name = \"JobHeldError\"\n }\n}\n\n/** The `{ error: { code, message, … } }` envelope every current route sends. */\ninterface ApiErrorEnvelope {\n code?: string\n message?: string\n missingScope?: string\n required?: number\n available?: number\n limitBytes?: number\n opIndex?: number\n [key: string]: unknown\n}\n\ninterface ApiErrorBody {\n /** The envelope — or, on an older route, a bare string (see {@link readErrorBody}). */\n error?: ApiErrorEnvelope | string\n /** A top-level message: an older route's, a bare validation answer's, or the server framework's own. */\n message?: unknown\n /** OAuth's human text (RFC 6749 §5.2), beside a bare-string `error`. */\n error_description?: unknown\n /** A bare validation answer's per-field issues (`{ message, issues }`). */\n issues?: unknown\n /** A refusal that names another job (see {@link ContinuationRefusedError}). */\n jobId?: unknown\n /** `continuation_preview_pending`: the held continuation, what holds it, and the run that finishes it. */\n executionId?: unknown\n renderNodeIds?: unknown\n reviewNodeIds?: unknown\n next?: unknown\n /** The credit guard's 402 sends its figures beside the envelope: what the run needs… */\n required?: unknown\n /** …and what the caller has (withheld on a deployment-paid instance). */\n balance?: unknown\n /** A per-user allowance's 402: what the allowance has left. */\n remaining?: unknown\n /** `app_run_version_changed`: the version the run ran, and the one the caller is on. */\n runVersion?: unknown\n appVersion?: unknown\n}\n\nconst finite = (v: unknown): number | undefined => (typeof v === \"number\" && Number.isFinite(v) ? v : undefined)\n\n/** A machine code as an older route writes it: lower snake_case, never a sentence or a reason phrase. */\nconst BARE_CODE = /^[a-z][a-z0-9_]*$/\n\nconst nonEmpty = (v: unknown): string | undefined => (typeof v === \"string\" && v.length > 0 ? v : undefined)\n\n/**\n * Where a body keeps its code and its human message. Most routes send the\n * envelope `{ error: { code, message } }`; three other shapes reach the SDK\n * too, and each is read for what it says rather than collapsed into\n * `internal_error` / \"Request failed\":\n *\n * - an older route's bare string, `{ error: \"<code>\", message?, … }` (character\n * training, a few profile and billing routes), and OAuth's\n * `{ error: \"<code>\", error_description }`. A snake_case string is the code;\n * a sentence (`\"Profile not found\"`) is the message.\n * - a bare validation answer, `{ message, issues: [...] }`: `validation_error`.\n * - the server framework's own answer, `{ statusCode, error: \"<reason phrase>\",\n * message }` (a route it does not have): the reason phrase is neither, the\n * message is kept — so \"no such route\" stays distinguishable from \"no such\n * resource\".\n *\n * At HTTP 500 and above only the CODE is read from outside the envelope. Text\n * there can be whatever the server failed with: the framework's own answer to\n * an uncaught throw is `{ statusCode: 500, error: \"Internal Server Error\",\n * message: <the raw error> }`, and the server's sanitizer rewrites only the\n * `internal_error` envelope. The envelope's own message is a route's chosen\n * sentence and is read at every status, as before.\n *\n * `message` is undefined when the body carries no human text it may show, so a\n * typed class keeps its own default (\"Not found\").\n */\nfunction readErrorBody(status: number, body: ApiErrorBody): { code: string | undefined; message: string | undefined; envelope: ApiErrorEnvelope } {\n const raw = body.error\n const envelope: ApiErrorEnvelope = raw && typeof raw === \"object\" ? raw : {}\n const bare = typeof raw === \"string\" ? raw : undefined\n const bareCode = bare !== undefined && BARE_CODE.test(bare) ? bare : undefined\n // Words with a space between them are human text: an older route's sentence,\n // or the framework's reason phrase — which always arrives with a real\n // `message`, read first. A single capitalised word (\"Unauthorized\") is a\n // reason phrase alone and says nothing the status does not.\n const bareSentence = bare !== undefined && bareCode === undefined && /\\s/.test(bare.trim()) ? bare : undefined\n const code =\n nonEmpty(envelope.code) ??\n bareCode ??\n (status === 400 && raw === undefined && Array.isArray(body.issues) ? \"validation_error\" : undefined)\n const outside = status >= 500 ? undefined : (nonEmpty(body.message) ?? nonEmpty(body.error_description) ?? bareSentence)\n const message = nonEmpty(envelope.message) ?? outside\n return { code, message, envelope }\n}\n\n/** The envelope's fields other than `code` and `message` (see {@link NodaroError.details}). */\nfunction envelopeDetails(envelope: ApiErrorEnvelope): Record<string, unknown> {\n const out: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(envelope)) {\n if (key !== \"code\" && key !== \"message\") out[key] = value\n }\n return out\n}\n\nexport function throwFromResponse(status: number, body: ApiErrorBody): never {\n try {\n selectError(status, body)\n } catch (err) {\n // Every class carries the envelope's other fields, whichever was chosen.\n if (err instanceof NodaroError) {\n const raw = body && typeof body === \"object\" ? body.error : undefined\n if (raw && typeof raw === \"object\") Object.defineProperty(err, \"details\", { value: envelopeDetails(raw), enumerable: true })\n }\n throw err\n }\n}\n\nfunction selectError(status: number, body: ApiErrorBody): never {\n // A body that is not an object (an empty answer, `null`, a bare string) still\n // throws by its status.\n const parsed: ApiErrorBody = body && typeof body === \"object\" ? body : {}\n const read = readErrorBody(status, parsed)\n const envelope = read.envelope\n const code = read.code ?? \"internal_error\"\n // A typed class falls back to its own default; a generic error to the code\n // it carries, which says more than \"Request failed\" does.\n const message = read.message ?? (read.code ? read.code : \"Request failed\")\n if (status === 401) throw new UnauthorizedError(read.message)\n if (status === 409 && (code === \"workflow_conflict\" || code === \"production_busy\")) {\n throw new WorkflowConflictError(\n read.message,\n envelope.currentUpdatedAt as string | undefined,\n envelope.currentVersion as number | undefined,\n envelope.currentRecord as Record<string, unknown> | undefined,\n code,\n )\n }\n // By shape, not by code — see StudioOpError. Only the studio operations route\n // sends an op index, so this cannot capture anyone else's 400.\n if (status >= 400 && status < 500 && typeof envelope.opIndex === \"number\") {\n throw new StudioOpError(message, code, status, envelope.opIndex)\n }\n if (status === 409 && CONTINUATION_REFUSAL_CODES.has(code) && typeof parsed.jobId === \"string\") {\n throw new ContinuationRefusedError(message, code, parsed.jobId)\n }\n if (status === 409 && code === \"continuation_preview_pending\" && typeof parsed.executionId === \"string\") {\n throw new ContinuationPreviewPendingError(\n message,\n parsed.executionId,\n stringList(parsed.renderNodeIds),\n stringList(parsed.reviewNodeIds),\n heldFinalRunOf(parsed.next),\n )\n }\n if (status === 409 && code === \"already_running\" && typeof parsed.executionId === \"string\") {\n throw new AlreadyRunningError(message, parsed.executionId)\n }\n if (status === 409 && code === \"app_run_version_changed\") {\n throw new AppRunVersionChangedError(message, finite(parsed.runVersion), finite(parsed.appVersion))\n }\n if (status === 422 && code === \"job_blocked\") throw new JobBlockedError(read.message)\n // The model, not the caller — before the scope line, so its own code is\n // kept (a plain ForbiddenError says \"forbidden\" whatever the server sent).\n const modelCode = read.code as ModelUnavailableCode | undefined\n if (status === 403 && modelCode !== undefined && MODEL_UNAVAILABLE_CODES.has(modelCode)) {\n throw new ModelUnavailableError(modelCode, read.message)\n }\n if (status === 403 && code === \"insufficient_scope\") {\n throw new ForbiddenError(read.message, envelope.missingScope)\n }\n if (status === 403) throw new ForbiddenError(read.message)\n // A 404 the framework answered itself (no route at that path) carries its\n // message at the top level, not under `error`; `readErrorBody` keeps it so\n // callers can tell \"no such route\" from \"no such resource\".\n if (status === 404) throw new NotFoundError(read.message)\n if (status === 429) throw new RateLimitedError(read.message)\n if (status === 402) {\n // The credit guard puts `required` / `balance` (an allowance: `remaining`)\n // beside the envelope; an envelope that carries them (`required` /\n // `available`) is read first.\n const required = finite(envelope.required) ?? finite(parsed.required)\n const available = finite(envelope.available) ?? finite(parsed.balance) ?? finite(parsed.remaining)\n const capCode = read.code as CreditCapCode | undefined\n if (capCode !== undefined && CREDIT_CAP_CODES.has(capCode)) {\n throw new CreditCapExceededError(capCode, read.message, required, available)\n }\n throw new InsufficientCreditsError(read.message, required, available, read.code ?? \"insufficient_credits\")\n }\n if (status === 413) throw new StorageExceededError(read.message, envelope.limitBytes, read.code)\n throw new NodaroError(message, code, status)\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkKMNSPC72_cjs = require('./chunk-KMNSPC72.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkNOZWIS7M_cjs = require('./chunk-NOZWIS7M.cjs');
|
|
5
5
|
var chunkUIDVH3GP_cjs = require('./chunk-UIDVH3GP.cjs');
|
|
6
6
|
var chunkW5VHATSR_cjs = require('./chunk-W5VHATSR.cjs');
|
|
7
7
|
var chunkR63TTR35_cjs = require('./chunk-R63TTR35.cjs');
|
|
@@ -12,7 +12,7 @@ var chunkSYVNY3AH_cjs = require('./chunk-SYVNY3AH.cjs');
|
|
|
12
12
|
var chunkYDRXBRW2_cjs = require('./chunk-YDRXBRW2.cjs');
|
|
13
13
|
var chunkWMT7HEBZ_cjs = require('./chunk-WMT7HEBZ.cjs');
|
|
14
14
|
var chunkMBFUMWI5_cjs = require('./chunk-MBFUMWI5.cjs');
|
|
15
|
-
var
|
|
15
|
+
var chunkTSM3S2QS_cjs = require('./chunk-TSM3S2QS.cjs');
|
|
16
16
|
var chunkUIBYZNDR_cjs = require('./chunk-UIBYZNDR.cjs');
|
|
17
17
|
var chunkLTZKNAXM_cjs = require('./chunk-LTZKNAXM.cjs');
|
|
18
18
|
var chunkPDX742CC_cjs = require('./chunk-PDX742CC.cjs');
|
|
@@ -25,14 +25,14 @@ var chunkTCLNSVYA_cjs = require('./chunk-TCLNSVYA.cjs');
|
|
|
25
25
|
var chunkKXEWTYS4_cjs = require('./chunk-KXEWTYS4.cjs');
|
|
26
26
|
var chunkGB6C5OEZ_cjs = require('./chunk-GB6C5OEZ.cjs');
|
|
27
27
|
var chunkMIXRL6I2_cjs = require('./chunk-MIXRL6I2.cjs');
|
|
28
|
-
var
|
|
28
|
+
var chunk3Y5TDB5K_cjs = require('./chunk-3Y5TDB5K.cjs');
|
|
29
29
|
var chunk7QOCWJKD_cjs = require('./chunk-7QOCWJKD.cjs');
|
|
30
30
|
var chunkZCWKX4V6_cjs = require('./chunk-ZCWKX4V6.cjs');
|
|
31
31
|
var chunkQ45PC4YD_cjs = require('./chunk-Q45PC4YD.cjs');
|
|
32
|
-
var
|
|
32
|
+
var chunkGWTKYJJO_cjs = require('./chunk-GWTKYJJO.cjs');
|
|
33
33
|
var chunkGVIFLUYZ_cjs = require('./chunk-GVIFLUYZ.cjs');
|
|
34
34
|
var chunk57GANTLV_cjs = require('./chunk-57GANTLV.cjs');
|
|
35
|
-
var
|
|
35
|
+
var chunkDOMNKVKA_cjs = require('./chunk-DOMNKVKA.cjs');
|
|
36
36
|
var chunkSBV5MWEL_cjs = require('./chunk-SBV5MWEL.cjs');
|
|
37
37
|
var chunkWUKIJJG2_cjs = require('./chunk-WUKIJJG2.cjs');
|
|
38
38
|
var chunk2KX5ZE6M_cjs = require('./chunk-2KX5ZE6M.cjs');
|
|
@@ -42,20 +42,20 @@ var chunkSS3B6PHT_cjs = require('./chunk-SS3B6PHT.cjs');
|
|
|
42
42
|
var chunkWK4VXPPZ_cjs = require('./chunk-WK4VXPPZ.cjs');
|
|
43
43
|
var chunk43FVH6LJ_cjs = require('./chunk-43FVH6LJ.cjs');
|
|
44
44
|
var chunkYFS2LMG4_cjs = require('./chunk-YFS2LMG4.cjs');
|
|
45
|
-
var
|
|
46
|
-
var
|
|
45
|
+
var chunkGDUEOKBF_cjs = require('./chunk-GDUEOKBF.cjs');
|
|
46
|
+
var chunk7PYZCNLH_cjs = require('./chunk-7PYZCNLH.cjs');
|
|
47
47
|
var chunkA3XA6UNM_cjs = require('./chunk-A3XA6UNM.cjs');
|
|
48
48
|
var chunk4BAHF762_cjs = require('./chunk-4BAHF762.cjs');
|
|
49
49
|
var chunkA3S55XGF_cjs = require('./chunk-A3S55XGF.cjs');
|
|
50
50
|
var chunkJOXZ4ZIF_cjs = require('./chunk-JOXZ4ZIF.cjs');
|
|
51
51
|
var chunkGA4LZZKQ_cjs = require('./chunk-GA4LZZKQ.cjs');
|
|
52
52
|
var chunkTVPYDC5T_cjs = require('./chunk-TVPYDC5T.cjs');
|
|
53
|
-
var
|
|
53
|
+
var chunkGJH73EGF_cjs = require('./chunk-GJH73EGF.cjs');
|
|
54
54
|
var chunkBPWUWUZ3_cjs = require('./chunk-BPWUWUZ3.cjs');
|
|
55
55
|
var chunkXZQ6Z4T6_cjs = require('./chunk-XZQ6Z4T6.cjs');
|
|
56
56
|
|
|
57
57
|
// src/client.ts
|
|
58
|
-
var NodaroClient = class _NodaroClient extends
|
|
58
|
+
var NodaroClient = class _NodaroClient extends chunk7PYZCNLH_cjs.NodaroClientCore {
|
|
59
59
|
workflows;
|
|
60
60
|
projects;
|
|
61
61
|
/** Generation sessions inside projects (Create Image / Video / Music). */
|
|
@@ -128,7 +128,7 @@ var NodaroClient = class _NodaroClient extends chunkHRV3VX22_cjs.NodaroClientCor
|
|
|
128
128
|
this.jobs = new chunk2KX5ZE6M_cjs.JobsResource(this);
|
|
129
129
|
this.videoPro = new chunkW5VHATSR_cjs.VideoProResource(this);
|
|
130
130
|
this.executions = new chunkSBV5MWEL_cjs.ExecutionsResource(this);
|
|
131
|
-
this.nodes = new
|
|
131
|
+
this.nodes = new chunkGWTKYJJO_cjs.NodesResource(this);
|
|
132
132
|
this.scene3d = new chunkYDRXBRW2_cjs.Scene3DResource(this);
|
|
133
133
|
this.developerApps = new chunkA3S55XGF_cjs.DeveloperAppsResource(this);
|
|
134
134
|
this.oauth = new chunkGVIFLUYZ_cjs.OAuthResource(this);
|
|
@@ -144,12 +144,12 @@ var NodaroClient = class _NodaroClient extends chunkHRV3VX22_cjs.NodaroClientCor
|
|
|
144
144
|
this.promptHelper = new chunkTCLNSVYA_cjs.PromptHelperResource(this);
|
|
145
145
|
this.voices = new chunkR63TTR35_cjs.VoicesResource(this);
|
|
146
146
|
this.llm = new chunkSS3B6PHT_cjs.LlmResource(this);
|
|
147
|
-
this.media = new
|
|
147
|
+
this.media = new chunk3Y5TDB5K_cjs.MediaResource(this);
|
|
148
148
|
this.audio = new chunkGA4LZZKQ_cjs.AudioResource(this);
|
|
149
149
|
this.credits = new chunk4BAHF762_cjs.CreditsResource(this);
|
|
150
150
|
this.userSettings = new chunkUIDVH3GP_cjs.UserSettingsResource(this);
|
|
151
151
|
this.billing = new chunkTVPYDC5T_cjs.BillingResource(this);
|
|
152
|
-
this.uploads = new
|
|
152
|
+
this.uploads = new chunkNOZWIS7M_cjs.UploadsResource(this);
|
|
153
153
|
this.library = new chunk2DZWWIJ4_cjs.LibraryResource(this);
|
|
154
154
|
this.gallery = new chunkWUKIJJG2_cjs.GalleryResource(this);
|
|
155
155
|
this.presets = new chunkQ45PC4YD_cjs.PresetsResource(this);
|
|
@@ -163,16 +163,16 @@ var NodaroClient = class _NodaroClient extends chunkHRV3VX22_cjs.NodaroClientCor
|
|
|
163
163
|
this.models = new chunk7QOCWJKD_cjs.ModelsResource(this);
|
|
164
164
|
this.shots = new chunkMBFUMWI5_cjs.ShotsResource(this);
|
|
165
165
|
this.recast = new chunkKXEWTYS4_cjs.RecastResource(this);
|
|
166
|
-
this.castSwap = new
|
|
166
|
+
this.castSwap = new chunkGJH73EGF_cjs.CastSwapResource(this);
|
|
167
167
|
this.trends = new chunkPDX742CC_cjs.TrendsResource(this);
|
|
168
|
-
this.studio = new
|
|
169
|
-
this.copilot = new
|
|
168
|
+
this.studio = new chunkTSM3S2QS_cjs.StudioResource(this);
|
|
169
|
+
this.copilot = new chunkGDUEOKBF_cjs.CopilotResource(this);
|
|
170
170
|
this.community = new chunk43FVH6LJ_cjs.CommunityResource(this);
|
|
171
171
|
this.templates = new chunkUIBYZNDR_cjs.TemplatesResource(this);
|
|
172
172
|
this.tutorials = new chunkKMNSPC72_cjs.TutorialsResource(this);
|
|
173
173
|
this.organizations = new chunkJ5LGGCAS_cjs.OrganizationsResource(this);
|
|
174
174
|
this.workspaces = new chunkLKH5M44B_cjs.WorkspacesResource(this);
|
|
175
|
-
this.edit = new
|
|
175
|
+
this.edit = new chunkDOMNKVKA_cjs.EditResource(this);
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
178
|
* A client that acts in `workspaceId`, sharing this one's auth and config.
|
|
@@ -203,5 +203,5 @@ function createClient(opts) {
|
|
|
203
203
|
|
|
204
204
|
exports.NodaroClient = NodaroClient;
|
|
205
205
|
exports.createClient = createClient;
|
|
206
|
-
//# sourceMappingURL=chunk-
|
|
207
|
-
//# sourceMappingURL=chunk-
|
|
206
|
+
//# sourceMappingURL=chunk-JX3GYLV3.cjs.map
|
|
207
|
+
//# sourceMappingURL=chunk-JX3GYLV3.cjs.map
|