@nodaro/sdk 2.34.0 → 2.39.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-JMOKD6ZP.js → chunk-7CUWAVWB.js} +3 -3
- package/dist/{chunk-JMOKD6ZP.js.map → chunk-7CUWAVWB.js.map} +1 -1
- package/dist/{chunk-E5BM4BLO.js → chunk-7IWVDWSP.js} +20 -3
- package/dist/chunk-7IWVDWSP.js.map +1 -0
- package/dist/{chunk-RHJRLXKY.cjs → chunk-7XOK277W.cjs} +9 -9
- package/dist/{chunk-RHJRLXKY.cjs.map → chunk-7XOK277W.cjs.map} +1 -1
- package/dist/{chunk-3QBH2VE2.cjs → chunk-A7QSOD2S.cjs} +20 -3
- package/dist/chunk-A7QSOD2S.cjs.map +1 -0
- package/dist/chunk-AQHU7EI5.js +54 -0
- package/dist/chunk-AQHU7EI5.js.map +1 -0
- package/dist/{chunk-VV4TZG5S.js → chunk-AUKHMT53.js} +3 -3
- package/dist/chunk-AUKHMT53.js.map +1 -0
- package/dist/{chunk-CWH642B2.js → chunk-CIUZMTER.js} +22 -18
- package/dist/chunk-CIUZMTER.js.map +1 -0
- package/dist/{chunk-I6CXC345.js → chunk-D2ILCSOQ.js} +3 -3
- package/dist/{chunk-I6CXC345.js.map → chunk-D2ILCSOQ.js.map} +1 -1
- package/dist/{chunk-4NLVBYMW.js → chunk-DQAYIVVS.js} +42 -8
- package/dist/chunk-DQAYIVVS.js.map +1 -0
- package/dist/{chunk-5ALNFATQ.cjs → chunk-EK672FFM.cjs} +2 -2
- package/dist/chunk-EK672FFM.cjs.map +1 -0
- package/dist/{chunk-OXQKE5EG.cjs → chunk-ETX3TLNB.cjs} +43 -9
- package/dist/{chunk-4NLVBYMW.js.map → chunk-ETX3TLNB.cjs.map} +1 -1
- package/dist/{chunk-BRV7Z4GD.cjs → chunk-FHVNTS4E.cjs} +2 -2
- package/dist/{chunk-BRV7Z4GD.cjs.map → chunk-FHVNTS4E.cjs.map} +1 -1
- package/dist/{chunk-N6GLZOE4.cjs → chunk-FM2KM5TY.cjs} +52 -10
- package/dist/chunk-FM2KM5TY.cjs.map +1 -0
- package/dist/{chunk-53SXNN3A.js → chunk-FQNCIP6K.js} +2 -2
- package/dist/chunk-FQNCIP6K.js.map +1 -0
- package/dist/{chunk-KNMW722T.cjs → chunk-FRQJNGJS.cjs} +5 -5
- package/dist/{chunk-KNMW722T.cjs.map → chunk-FRQJNGJS.cjs.map} +1 -1
- package/dist/{chunk-4CXB7RA6.js → chunk-IGMWFEFB.js} +6 -4
- package/dist/chunk-IGMWFEFB.js.map +1 -0
- package/dist/{chunk-6OGGJQVA.js → chunk-ILG5DHQQ.js} +2 -2
- package/dist/chunk-ILG5DHQQ.js.map +1 -0
- package/dist/{chunk-CFY6XXOT.cjs → chunk-IXCJ26F5.cjs} +37 -33
- package/dist/chunk-IXCJ26F5.cjs.map +1 -0
- package/dist/{chunk-ZQQABQMH.cjs → chunk-JTOEHQQJ.cjs} +12 -2
- package/dist/chunk-JTOEHQQJ.cjs.map +1 -0
- package/dist/{chunk-ZXJQSFIA.js → chunk-JUON5NXA.js} +2 -2
- package/dist/{chunk-ZXJQSFIA.js.map → chunk-JUON5NXA.js.map} +1 -1
- package/dist/{chunk-JGS6YBDW.js → chunk-L6T44A3G.js} +51 -11
- package/dist/chunk-L6T44A3G.js.map +1 -0
- package/dist/{chunk-U4T3Z3K7.cjs → chunk-NKH2UFSD.cjs} +5 -5
- package/dist/chunk-NKH2UFSD.cjs.map +1 -0
- package/dist/{chunk-VFMWBW2Q.js → chunk-NU4QSOMH.js} +4 -4
- package/dist/{chunk-VFMWBW2Q.js.map → chunk-NU4QSOMH.js.map} +1 -1
- package/dist/{chunk-E2ZXHS6E.js → chunk-OIPPTBW4.js} +2 -2
- package/dist/chunk-OIPPTBW4.js.map +1 -0
- package/dist/{chunk-DKEYSJCE.cjs → chunk-OIYMTGYN.cjs} +2 -2
- package/dist/chunk-OIYMTGYN.cjs.map +1 -0
- package/dist/{chunk-NLQQHJ25.cjs → chunk-OSMKIRKI.cjs} +4 -4
- package/dist/{chunk-NLQQHJ25.cjs.map → chunk-OSMKIRKI.cjs.map} +1 -1
- package/dist/chunk-PG2GBS3K.cjs +4 -0
- package/dist/chunk-PG2GBS3K.cjs.map +1 -0
- package/dist/{chunk-GB724HW2.cjs → chunk-PQ7OKM3E.cjs} +6 -4
- package/dist/chunk-PQ7OKM3E.cjs.map +1 -0
- package/dist/chunk-QGOEQGAE.js +102 -0
- package/dist/chunk-QGOEQGAE.js.map +1 -0
- package/dist/{chunk-EAGD6NEE.cjs → chunk-QZHRXPN5.cjs} +22 -22
- package/dist/chunk-QZHRXPN5.cjs.map +1 -0
- package/dist/{chunk-5MTCKWKA.cjs → chunk-QZMI7364.cjs} +5 -5
- package/dist/{chunk-5MTCKWKA.cjs.map → chunk-QZMI7364.cjs.map} +1 -1
- package/dist/chunk-SRBYCGRC.cjs +56 -0
- package/dist/chunk-SRBYCGRC.cjs.map +1 -0
- package/dist/{chunk-KGKCAGRD.cjs → chunk-TCLNSVYA.cjs} +2 -2
- package/dist/chunk-TCLNSVYA.cjs.map +1 -0
- package/dist/chunk-VCEYLJ2Q.cjs +104 -0
- package/dist/chunk-VCEYLJ2Q.cjs.map +1 -0
- package/dist/{chunk-VGWOIWRQ.cjs → chunk-VHSMOBU7.cjs} +2 -2
- package/dist/{chunk-VGWOIWRQ.cjs.map → chunk-VHSMOBU7.cjs.map} +1 -1
- package/dist/{chunk-T3SYREY4.js → chunk-WY4QRJZW.js} +12 -2
- package/dist/chunk-WY4QRJZW.js.map +1 -0
- package/dist/chunk-YCVRQZT3.js +3 -0
- package/dist/chunk-YCVRQZT3.js.map +1 -0
- package/dist/{chunk-DPSMVOM3.js → chunk-YSZM3N7Q.js} +2 -2
- package/dist/chunk-YSZM3N7Q.js.map +1 -0
- package/dist/{chunk-5A7J24LN.js → chunk-Z7UZ3FD3.js} +3 -3
- package/dist/{chunk-5A7J24LN.js.map → chunk-Z7UZ3FD3.js.map} +1 -1
- package/dist/{chunk-4JKI6JRC.js → chunk-ZDSC6KBT.js} +3 -3
- package/dist/chunk-ZDSC6KBT.js.map +1 -0
- package/dist/entries/apps.cjs +2 -2
- package/dist/entries/apps.d.cts +4 -0
- package/dist/entries/apps.d.ts +4 -0
- package/dist/entries/apps.js +1 -1
- package/dist/entries/cast-swap.cjs +2 -2
- package/dist/entries/cast-swap.d.cts +278 -18
- package/dist/entries/cast-swap.d.ts +278 -18
- package/dist/entries/cast-swap.js +1 -1
- package/dist/entries/characters.d.cts +2 -2
- package/dist/entries/characters.d.ts +2 -2
- package/dist/entries/client.cjs +25 -24
- package/dist/entries/client.d.cts +5 -2
- package/dist/entries/client.d.ts +5 -2
- package/dist/entries/client.js +20 -19
- 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 +2 -2
- package/dist/entries/creatures.d.ts +2 -2
- package/dist/entries/credits.cjs +2 -2
- package/dist/entries/credits.d.cts +37 -2
- package/dist/entries/credits.d.ts +37 -2
- package/dist/entries/credits.js +1 -1
- package/dist/entries/edit.cjs +7 -7
- package/dist/entries/edit.d.cts +3 -0
- package/dist/entries/edit.d.ts +3 -0
- package/dist/entries/edit.js +2 -2
- package/dist/entries/errors.cjs +30 -22
- package/dist/entries/errors.d.cts +42 -4
- package/dist/entries/errors.d.ts +42 -4
- package/dist/entries/errors.js +1 -1
- package/dist/entries/jobs.cjs +2 -2
- package/dist/entries/jobs.d.cts +76 -4
- package/dist/entries/jobs.d.ts +76 -4
- package/dist/entries/jobs.js +1 -1
- package/dist/entries/locations.d.cts +2 -2
- package/dist/entries/locations.d.ts +2 -2
- package/dist/entries/media.cjs +4 -4
- package/dist/entries/media.d.cts +39 -5
- package/dist/entries/media.d.ts +39 -5
- package/dist/entries/media.js +3 -3
- package/dist/entries/nodes.cjs +3 -3
- package/dist/entries/nodes.d.cts +2 -2
- package/dist/entries/nodes.d.ts +2 -2
- package/dist/entries/nodes.js +2 -2
- package/dist/entries/objects.d.cts +2 -2
- package/dist/entries/objects.d.ts +2 -2
- package/dist/entries/prompt-helper.cjs +2 -2
- package/dist/entries/prompt-helper.d.cts +3 -1
- package/dist/entries/prompt-helper.d.ts +3 -1
- package/dist/entries/prompt-helper.js +1 -1
- package/dist/entries/scene3d.d.cts +3 -3
- package/dist/entries/scene3d.d.ts +3 -3
- package/dist/entries/studio.cjs +5 -5
- package/dist/entries/studio.d.cts +2 -2
- package/dist/entries/studio.d.ts +2 -2
- package/dist/entries/studio.js +2 -2
- package/dist/entries/templates.cjs +2 -2
- package/dist/entries/templates.d.cts +4 -0
- package/dist/entries/templates.d.ts +4 -0
- package/dist/entries/templates.js +1 -1
- package/dist/entries/trends.cjs +13 -0
- package/dist/entries/trends.cjs.map +1 -0
- package/dist/entries/trends.d.cts +295 -0
- package/dist/entries/trends.d.ts +295 -0
- package/dist/entries/trends.js +4 -0
- package/dist/entries/trends.js.map +1 -0
- package/dist/entries/tutorials.cjs +2 -2
- package/dist/entries/tutorials.d.cts +4 -0
- package/dist/entries/tutorials.d.ts +4 -0
- package/dist/entries/tutorials.js +1 -1
- package/dist/entries/uploads.cjs +2 -2
- package/dist/entries/uploads.d.cts +14 -1
- package/dist/entries/uploads.d.ts +14 -1
- package/dist/entries/uploads.js +1 -1
- package/dist/entries/workflows.cjs +2 -2
- package/dist/entries/workflows.d.cts +6 -0
- package/dist/entries/workflows.d.ts +6 -0
- package/dist/entries/workflows.js +1 -1
- package/dist/index.cjs +85 -71
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +22 -20
- package/dist/{nodes-D2tbtzt7.d.ts → nodes-9WpYNWtS.d.ts} +13 -1
- package/dist/{nodes-CTujw6Qd.d.cts → nodes-BDUk5Aej.d.cts} +13 -1
- package/dist/{studio-productions-vbCNSbtf.d.ts → studio-productions-DtTE8mdl.d.ts} +35 -1
- package/dist/{studio-productions-DUHvdSvk.d.cts → studio-productions-r2-VZsKj.d.cts} +35 -1
- package/package.json +7 -2
- package/dist/chunk-3QBH2VE2.cjs.map +0 -1
- package/dist/chunk-4CXB7RA6.js.map +0 -1
- package/dist/chunk-4JKI6JRC.js.map +0 -1
- package/dist/chunk-53SXNN3A.js.map +0 -1
- package/dist/chunk-5ALNFATQ.cjs.map +0 -1
- package/dist/chunk-6OGGJQVA.js.map +0 -1
- package/dist/chunk-CFY6XXOT.cjs.map +0 -1
- package/dist/chunk-CWH642B2.js.map +0 -1
- package/dist/chunk-DKEYSJCE.cjs.map +0 -1
- package/dist/chunk-DPSMVOM3.js.map +0 -1
- package/dist/chunk-E2ZXHS6E.js.map +0 -1
- package/dist/chunk-E5BM4BLO.js.map +0 -1
- package/dist/chunk-EAGD6NEE.cjs.map +0 -1
- package/dist/chunk-GB724HW2.cjs.map +0 -1
- package/dist/chunk-GDXS4EJ5.js +0 -28
- package/dist/chunk-GDXS4EJ5.js.map +0 -1
- package/dist/chunk-GVBSOZDI.cjs +0 -30
- package/dist/chunk-GVBSOZDI.cjs.map +0 -1
- package/dist/chunk-JGS6YBDW.js.map +0 -1
- package/dist/chunk-KGKCAGRD.cjs.map +0 -1
- package/dist/chunk-N6GLZOE4.cjs.map +0 -1
- package/dist/chunk-OXQKE5EG.cjs.map +0 -1
- package/dist/chunk-T3SYREY4.js.map +0 -1
- package/dist/chunk-U4T3Z3K7.cjs.map +0 -1
- package/dist/chunk-VV4TZG5S.js.map +0 -1
- package/dist/chunk-ZQQABQMH.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { throwFromResponse, NodaroError } from './chunk-
|
|
1
|
+
import { throwFromResponse, NodaroError } from './chunk-L6T44A3G.js';
|
|
2
2
|
|
|
3
3
|
// src/sse.ts
|
|
4
4
|
async function* readSseStream(res, opts = {}) {
|
|
@@ -42,5 +42,5 @@ async function* readSseStream(res, opts = {}) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export { readSseStream };
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-7CUWAVWB.js.map
|
|
46
|
+
//# sourceMappingURL=chunk-7CUWAVWB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sse.ts"],"names":[],"mappings":";;;AAyBA,gBAAuB,aAAA,CACrB,GAAA,EACA,IAAA,GAGI,EAAC,EAC+B;AACpC,EAAA,IAAI,CAAC,IAAI,EAAA,EAAI;AACX,IAAA,IAAI,UAAmC,EAAC;AACxC,IAAA,IAAI;AACF,MAAA,OAAA,GAAW,MAAM,IAAI,IAAA,EAAK;AAAA,IAC5B,CAAA,CAAA,MAAQ;AAAA,IAER;AACA,IAAA,iBAAA,CAAkB,GAAA,CAAI,QAAQ,OAAO,CAAA;AAAA,EACvC;AACA,EAAA,IAAI,CAAC,IAAI,IAAA,EAAM;AACb,IAAA,MAAM,IAAI,YAAY,CAAA,EAAG,IAAA,CAAK,SAAS,cAAc,CAAA,qBAAA,CAAA,EAAyB,cAAA,EAAgB,GAAA,CAAI,MAAM,CAAA;AAAA,EAC1G;AAEA,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,IAAA,CAAK,SAAA,EAAU;AAClC,EAAA,MAAM,OAAA,GAAU,IAAI,WAAA,EAAY;AAChC,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,IAAI;AACF,IAAA,WAAS;AACP,MAAA,MAAM,EAAE,IAAA,EAAM,KAAA,EAAM,GAAI,MAAM,OAAO,IAAA,EAAK;AAC1C,MAAA,IAAI,IAAA,EAAM;AACV,MAAA,MAAA,IAAU,QAAQ,MAAA,CAAO,KAAA,EAAO,EAAE,MAAA,EAAQ,MAAM,CAAA;AAChD,MAAA,IAAI,GAAA;AACJ,MAAA,OAAA,CAAQ,GAAA,GAAM,MAAA,CAAO,OAAA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in this package.\n *\n * Every streaming route here writes the same minimal shape — `data: <json>\\n\\n`\n * frames, with the event kind INSIDE the JSON rather than on an `event:` line —\n * so one reader serves them all, and a second hand-rolled parse loop is the\n * thing this file exists to prevent. Deliberately minimal, matching the\n * server's writer rather than the whole SSE grammar: split on blank lines,\n * JSON-parse each `data:` line on its own, skip what does not parse (the next\n * frame re-reports state), and ignore every other line — keepalive comments\n * (`: keepalive`) included.\n *\n * Frames are separated by a bare `\\n\\n` and each `data:` line is parsed on its\n * own, exactly as the server writes them. Both halves are literal: a stream\n * whose frames arrive CRLF-terminated, or whose JSON was split across two\n * `data:` lines, yields NOTHING rather than erroring — so an intermediary that\n * normalises line endings would show up as an empty stream, not a parse\n * failure. The server's writer produces neither shape.\n *\n * No timeout is applied. The caller owns the lifetime: pass the `AbortSignal`\n * to the `fetch` that produced `res`, or just stop iterating — the `finally`\n * cancels the body, which ends the HTTP request.\n */\nexport async function* readSseStream<T>(\n res: Response,\n opts: {\n /** Names the stream in the \"no response body\" error. */\n label?: string\n } = {},\n): AsyncGenerator<T, void, undefined> {\n if (!res.ok) {\n let errBody: Record<string, unknown> = {}\n try {\n errBody = (await res.json()) as Record<string, unknown>\n } catch {\n // Empty/non-JSON body — fall through with empty errBody\n }\n throwFromResponse(res.status, errBody)\n }\n if (!res.body) {\n throw new NodaroError(`${opts.label ?? \"event stream\"} has no response body`, \"empty_stream\", res.status)\n }\n\n const reader = res.body.getReader()\n const decoder = new TextDecoder()\n let buffer = \"\"\n try {\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n buffer += decoder.decode(value, { stream: true })\n let sep: number\n while ((sep = buffer.indexOf(\"\\n\\n\")) >= 0) {\n const frame = buffer.slice(0, sep)\n buffer = buffer.slice(sep + 2)\n for (const line of frame.split(\"\\n\")) {\n if (!line.startsWith(\"data:\")) continue\n try {\n yield JSON.parse(line.slice(5).trim()) as T\n } catch {\n // Skip malformed frames — the next tick re-reports full state.\n }\n }\n }\n }\n } finally {\n // Ends the HTTP request when the consumer breaks out of the loop early.\n reader.releaseLock()\n await res.body.cancel().catch(() => {})\n }\n}\n"]}
|
|
@@ -26,6 +26,18 @@ var JobsResource = class {
|
|
|
26
26
|
query: { ...rest, status: listParam(status), type: listParam(type) }
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Record an image edited in the browser as a job (`POST /v1/jobs/from-upload`):
|
|
31
|
+
* a completed, private, free `image-edit` job whose `output_data.imageUrl` is
|
|
32
|
+
* the upload, linked to its source in `input_data` (`sourceJobId` /
|
|
33
|
+
* `sourceAssetId`, `sourceImageUrl`). It then lists, rates, favorites and
|
|
34
|
+
* files into a session like any image job. One upload is one job: the same
|
|
35
|
+
* `assetId` again returns the same job. OAuth apps need the `assets:write`
|
|
36
|
+
* scope. A deployment's job policy can refuse the image ({@link JobBlockedError}).
|
|
37
|
+
*/
|
|
38
|
+
fromUpload(params) {
|
|
39
|
+
return this.client.request("POST", "/v1/jobs/from-upload", { body: params });
|
|
40
|
+
}
|
|
29
41
|
/**
|
|
30
42
|
* Rate one of your jobs `"good"` or `"bad"`, or clear the rating with
|
|
31
43
|
* `null` (`PUT /v1/jobs/:id/rating`). Only the job's owner rates it — anyone
|
|
@@ -51,7 +63,12 @@ var JobsResource = class {
|
|
|
51
63
|
}
|
|
52
64
|
/**
|
|
53
65
|
* Cancel a job. Server route is `POST /v1/jobs/:jobId/cancel`.
|
|
54
|
-
* Refunds any reserved credit holds.
|
|
66
|
+
* Refunds any reserved credit holds. A running LLM job priced per model
|
|
67
|
+
* (metered) whose call has already started answers
|
|
68
|
+
* `{ success: true, cancelled: 0, inFlight: true }`: it finishes and is
|
|
69
|
+
* charged only what it used. A job stopped before its call starts is
|
|
70
|
+
* refunded, except for what an earlier attempt of the same job already used
|
|
71
|
+
* (a retry after a billed attempt): that is charged.
|
|
55
72
|
*/
|
|
56
73
|
cancel(id) {
|
|
57
74
|
return this.client.request(
|
|
@@ -74,5 +91,5 @@ var JobsResource = class {
|
|
|
74
91
|
};
|
|
75
92
|
|
|
76
93
|
export { JobsResource };
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-7IWVDWSP.js.map
|
|
95
|
+
//# sourceMappingURL=chunk-7IWVDWSP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resources/jobs.ts"],"names":[],"mappings":";AA0PA,SAAS,UAAU,KAAA,EAAmE;AACpF,EAAA,IAAI,KAAA,KAAU,QAAW,OAAO,MAAA;AAChC,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,GAAW,KAAA,GAAQ,KAAA,CAAM,KAAK,GAAG,CAAA;AAC3D;AAgCO,IAAM,eAAN,MAAmB;AAAA,EACxB,YAAoB,MAAA,EAA0B;AAA1B,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAA2B;AAAA,EAA3B,MAAA;AAAA;AAAA,EAGpB,IAAI,EAAA,EAAoC;AACtC,IAAA,OAAO,IAAA,CAAK,OAAO,OAAA,CAAQ,KAAA,EAAO,YAAY,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAE,CAAA;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,IAAA,CAAK,MAAA,GAAyB,EAAC,EAA0B;AACvD,IAAA,MAAM,EAAE,MAAA,EAAQ,IAAA,EAAM,GAAG,MAAK,GAAI,MAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,OAAA,CAAsB,KAAA,EAAO,UAAA,EAAY;AAAA,MAC1D,KAAA,EAAO,EAAE,GAAG,IAAA,EAAM,MAAA,EAAQ,SAAA,CAAU,MAAM,CAAA,EAAG,IAAA,EAAM,SAAA,CAAU,IAAI,CAAA;AAAE,KACpE,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAW,MAAA,EAAqD;AAC9D,IAAA,OAAO,IAAA,CAAK,OAAO,OAAA,CAAuB,MAAA,EAAQ,wBAAwB,EAAE,IAAA,EAAM,QAAQ,CAAA;AAAA,EAC5F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAA,CAAK,IAAY,MAAA,EAAkD;AACjE,IAAA,OAAO,IAAA,CAAK,OAAO,OAAA,CAAuB,KAAA,EAAO,YAAY,kBAAA,CAAmB,EAAE,CAAC,CAAA,OAAA,CAAA,EAAW;AAAA,MAC5F,IAAA,EAAM,EAAE,MAAA;AAAO,KAChB,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,UAAU,EAAA,EAAgD;AACxD,IAAA,OAAO,KAAK,MAAA,CAAO,OAAA;AAAA,MACjB,KAAA;AAAA,MACA,CAAA,SAAA,EAAY,kBAAA,CAAmB,EAAE,CAAC,CAAA,OAAA;AAAA,KACpC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,OAAO,EAAA,EAAsC;AAC3C,IAAA,OAAO,KAAK,MAAA,CAAO,OAAA;AAAA,MACjB,MAAA;AAAA,MACA,CAAA,SAAA,EAAY,kBAAA,CAAmB,EAAE,CAAC,CAAA,OAAA;AAAA,KACpC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,EAAA,EAAsC;AAC3C,IAAA,OAAO,KAAK,MAAA,CAAO,OAAA;AAAA,MACjB,QAAA;AAAA,MACA,CAAA,SAAA,EAAY,kBAAA,CAAmB,EAAE,CAAC,CAAA;AAAA,KACpC;AAAA,EACF;AACF","file":"chunk-7IWVDWSP.js","sourcesContent":["import type { NodaroClientCore } from \"../core.js\"\n\n/**\n * A job's lifecycle status. Hand-copied mirror of `JOB_STATUSES` in the\n * platform's `backend/src/lib/job-status.ts` — nothing links the two at build\n * time, so a new member has to be added here in the same change.\n *\n * `pending_review` is IN-FLIGHT, NOT TERMINAL: a job policy registered by the\n * deployment held the output for a human reviewer. Treat it like `processing`\n * in a `switch` — keep waiting, do not re-run — and it resolves to `completed`\n * (approved), `failed` (rejected, carrying an `error_hint` with\n * `kind: \"policy-block\"`) or `cancelled` (a held job is cancellable like any\n * in-flight job). `credit_status` reads `\"reserved\"` for the whole hold. Only\n * appears on deployments that register a job policy; `runAndWait` throws\n * {@link JobHeldError} on the first held tick rather than waiting it out.\n */\nexport type JobStatus =\n | \"pending\"\n | \"queued\"\n | \"processing\"\n | \"pending_review\"\n | \"completed\"\n | \"failed\"\n | \"cancelled\"\n\n/**\n * A PROVIDER's verdict: the model's own safety filter refused the output.\n * `class` distinguishes a deterministic block (copyright/likeness — retrying\n * the same request never helps) from `safety`, whose filter is known to be\n * non-deterministic for some models: `retried` says whether the worker\n * already spent its one extra attempt, and `suggestedProvider` — present\n * only when the catalog declares a fallback for the model that failed — is a\n * real model id the SAME prompt/references can be retried on.\n */\nexport type SafetyBlockHint = {\n kind: \"safety-block\"\n class: \"copyright\" | \"likeness\" | \"safety\"\n retried: boolean\n suggestedProvider?: string\n /**\n * Present when the provider refused the INPUT VIDEO itself — not the prompt,\n * a reference image or the output. Sending a different clip is the fix.\n */\n subject?: \"input_video\"\n}\n\n/**\n * A NODARO-side verdict, not a provider's: a job policy registered by the\n * deployment rejected the request (`hookPoint: \"request\"` — nothing ran, and\n * the call itself failed with {@link JobBlockedError}) or the finished output\n * (`hookPoint: \"result\"` — the result was blocked and never published).\n *\n * `reason` is USER-SAFE BY CONTRACT — the platform guarantees the policy's\n * machine text (scores, labels) never reaches it — so show it to the person\n * who made the request as-is. `policyId` identifies the deployment's policy,\n * not a Nodaro product feature. Only occurs on deployments that register a\n * job policy.\n */\nexport type PolicyBlockHint = {\n kind: \"policy-block\"\n policyId: string\n reason: string\n hookPoint: \"request\" | \"result\"\n}\n\n/**\n * The job ran out of credits partway: a step that reserves its own credits\n * (for example, the video a Cast Swap or trend run dispatches) was refused —\n * the balance could not cover it, or a plan or workspace cap was reached. The\n * job failed and its credits were refunded; ask the person to top up (or raise\n * the cap), then run it again.\n *\n * `code` is the refusal's own code, a lowercase snake_case token — for\n * example `insufficient_credits`, `free_video_limit`, `instance_cap_reached`,\n * `budget_exceeded`, `member_cap_exceeded` or `user_allowance_exceeded`. Treat\n * an unknown code like `insufficient_credits`.\n */\nexport type CreditsHint = {\n kind: \"credits\"\n code: string\n}\n\n/**\n * The provider refused the job's input video without naming a content-policy\n * class (its message is about the file, not a policy). Treat it like any\n * other failure — no fallback model is offered — except that the input to\n * change is known: send a different clip.\n */\nexport type InputRefusedHint = {\n kind: \"input-refused\"\n subject: \"input_video\"\n}\n\n/**\n * A job's `jobs.error_hint` (migration 376) — a user-safe, machine-readable\n * failure verdict, so a caller can act on it without parsing `error_message`\n * prose. One column, several verdict sources; `kind` is the discriminant.\n *\n * HAND-COPIED MIRROR of `ErrorHint` in the platform's\n * `backend/src/lib/safety-block.ts` (which names this file in its own\n * comment). Nothing links the two at build time: a new arm there has to be\n * pasted here verbatim in the same change, with a changeset.\n * `packages/client/dist/index.d.ts` is REBUILT, never hand-edited.\n */\nexport type JobErrorHint = SafetyBlockHint | PolicyBlockHint | CreditsHint | InputRefusedHint\n\n/**\n * The billing lifecycle of a job's credit reservation — `usage_logs.status`\n * for the job's `usage_log_id`. `null` when the job has no usage log (e.g. a\n * free run) or hasn't reserved credits yet.\n */\nexport type CreditStatus = \"reserved\" | \"committed\" | \"refunded\"\n\n/** A job owner's rating of their job — set with {@link JobsResource.rate}. */\nexport type JobRating = \"good\" | \"bad\"\n\n/**\n * The `rating` filter of {@link JobsResource.list}: one rating, any rating\n * (`\"rated\"`) or none (`\"unrated\"`).\n */\nexport type JobRatingFilter = JobRating | \"rated\" | \"unrated\"\n\n/**\n * Job record returned to non-admin SDK consumers. Field names are snake_case\n * to match the wire format (per the OpenAPI fix in Phase 1).\n *\n * Sensitive fields stripped server-side for non-admin callers:\n * `provider`, `provider_cost`, `display_cost`, `credits_actual`. USD\n * pricing is admin-only across api/sdk/mcp — non-admin consumers see\n * only the `credits` abstraction. Server-only nested job data (including\n * Recast's private remux base) is stripped for every caller, including admins.\n */\nexport interface Job {\n id: string\n status: JobStatus\n progress: number\n user_id: string\n input_data: unknown\n output_data: unknown\n error_message: string | null\n /** Present on a failed job the worker classified as a provider\n * content-policy block (`kind: \"safety-block\"`) or that a deployment's job\n * policy rejected (`kind: \"policy-block\"`); absent/null otherwise.\n * User-safe by construction — narrow on `kind` before reading the rest. */\n error_hint?: JobErrorHint | null\n /** PR9: the job's credit reservation lifecycle, derived server-side from\n * `usage_logs.status`. `null` when there is no usage log to report. Never\n * changes the meaning of `credits` (the reserved amount) below. */\n credit_status?: CreditStatus | null\n /** The credits HELD when the job was accepted. Never changes — a job can\n * settle below it; read {@link Job.credits_charged} for what it cost. */\n credits: number | null\n /**\n * What the job actually cost once its hold settled. Can be lower than\n * `credits` (the unused part goes back to the balance), `0` when the hold was\n * refunded, `null` while the job is still running or when it reserved\n * nothing of its own. Sum this — not `credits` — to total spend. Returned by\n * `get()` and `list()`.\n */\n credits_charged?: number | null\n job_type: string | null\n created_at: string\n started_at: string | null\n completed_at: string | null\n /**\n * Provenance: which kind of caller created the job — one of\n * `\"internal\" | \"mcp\" | \"app\" | \"cli\" | \"sdk\" | \"extension\" | \"web\" | \"api\"`.\n * `source_detail` narrows it (origin host, `extension/<name>` label,\n * `sdk/<version>`, MCP client name, developer-app id). Descriptive only;\n * lets a library view label or filter media by origin.\n */\n source?: string | null\n source_detail?: string | null\n /** The generation session this job was born in (the `sessionId` sent with\n * the generation request), or null. See `client.sessions`. */\n session_id?: string | null\n /**\n * Whether the job's owner favorited it (`client.gallery.toggleFavorite`).\n * Returned by `get()` and `list()`. Absent from an older server, and when\n * the server could not read it for a moment — treat absent as unknown,\n * never as `false`.\n */\n favorited?: boolean\n /**\n * The owner's rating of the job ({@link JobsResource.rate}), or `null` when\n * unrated. Returned by `get()` and `list()`; absent like `favorited`.\n */\n rating?: JobRating | null\n}\n\nexport interface CancelJobResult {\n success: true\n cancelled: number\n /**\n * `true` when the job could not be stopped because its provider call is\n * already running — a metered LLM job's call, an external provider task. It\n * finishes and is charged only what it used.\n */\n inFlight?: boolean\n}\n\nexport interface DeleteJobResult {\n success: true\n}\n\nexport interface ListJobsParams {\n /** One status or several (a job matching any of them). An unknown status is a 400. */\n status?: JobStatus | readonly JobStatus[]\n /** Exact match on `input_data.type` — the route that created the job\n * (`\"llm-structured\"`, `\"video-analysis\"`, …). One value or several (up to 20). */\n type?: string | readonly string[]\n /** Exact match on `input_data.origin` — the client app that sent it. */\n origin?: string\n /** `true`: only jobs you favorited; `false`: only jobs you did not. */\n favorited?: boolean\n /** Your rating: `\"good\"`, `\"bad\"`, any (`\"rated\"`) or none (`\"unrated\"`). */\n rating?: JobRatingFilter\n /** The jobs of one generate-image batch (`count` / `models`) — its `batchId`. */\n batchId?: string\n /** Page size, 1–100 (server default 50). */\n limit?: number\n /** The previous page's `next`. */\n cursor?: string\n}\n\n/** What {@link JobsResource.rate} answers: the job's rating now. */\nexport interface RateJobResult {\n data: { jobId: string; rating: JobRating | null }\n}\n\n/**\n * {@link JobsResource.fromUpload}'s body: an image edited in the browser,\n * already stored with `client.uploads.upload`, and what it was made from.\n */\nexport interface JobFromUploadParams {\n /** The edited image's `assetId`, as `client.uploads.upload` returned it. */\n assetId: string\n /** The job whose image was edited. */\n sourceJobId?: string\n /** Which of `sourceJobId`'s images was edited, when it made several. Default: its `imageUrl`. */\n sourceImageUrl?: string\n /** The upload that was edited, when the source is not a job. Not with `sourceJobId`. */\n sourceAssetId?: string\n /** The editor's design state, stored with `client.uploads.uploadJson`, so the edit can be reopened. */\n editStateUrl?: string\n /** The generation session to file the job in. */\n sessionId?: string\n}\n\n/** A list filter value as the query string carries it: several are comma-separated. */\nfunction listParam(value: string | readonly string[] | undefined): string | undefined {\n if (value === undefined) return undefined\n return typeof value === \"string\" ? value : value.join(\",\")\n}\n\nexport interface ListJobsPage {\n /**\n * A page may hold fewer than `limit` rows — even none — and still carry a\n * `next`. Page on `next`, never on `data.length`.\n */\n data: Job[]\n /** Pass back as `cursor` for the next page; `null` on the last one. */\n next: string | null\n}\n\n/**\n * Lean job status returned by `GET /v1/jobs/:id/status`. Skips the\n * `input_data` JSONB and cost columns. Its `output_data` still goes\n * through the server-only nested-field redaction. Intended for poll loops that\n * only need progress/output/error, and when the job finished.\n */\nexport interface JobStatusResult {\n id: string\n status: JobStatus\n progress?: number\n output_data?: unknown\n error_message?: string | null\n /** PR9: see {@link Job.error_hint}. */\n error_hint?: JobErrorHint | null\n /** PR9: see {@link Job.credit_status}. */\n credit_status?: CreditStatus | null\n /** When the job finished, on the server's clock; null until it has. */\n completed_at?: string | null\n}\n\nexport class JobsResource {\n constructor(private client: NodaroClientCore) {}\n\n /** Get a single job by ID. */\n get(id: string): Promise<{ data: Job }> {\n return this.client.request(\"GET\", `/v1/jobs/${encodeURIComponent(id)}`)\n }\n\n /**\n * Your jobs, newest first (`GET /v1/jobs`), cursor-paginated. `type` and\n * `origin` filter on the job's own `input_data`, which every job carries —\n * a client app lists its runs with `{ type: \"llm-structured\", origin: \"studio\" }`.\n * `status` and `type` take one value or a list; `favorited` and `rating`\n * filter on your own marks. Every filter combines with AND, and each job\n * carries `favorited` and `rating`.\n */\n list(params: ListJobsParams = {}): Promise<ListJobsPage> {\n const { status, type, ...rest } = params\n return this.client.request<ListJobsPage>(\"GET\", \"/v1/jobs\", {\n query: { ...rest, status: listParam(status), type: listParam(type) },\n })\n }\n\n /**\n * Record an image edited in the browser as a job (`POST /v1/jobs/from-upload`):\n * a completed, private, free `image-edit` job whose `output_data.imageUrl` is\n * the upload, linked to its source in `input_data` (`sourceJobId` /\n * `sourceAssetId`, `sourceImageUrl`). It then lists, rates, favorites and\n * files into a session like any image job. One upload is one job: the same\n * `assetId` again returns the same job. OAuth apps need the `assets:write`\n * scope. A deployment's job policy can refuse the image ({@link JobBlockedError}).\n */\n fromUpload(params: JobFromUploadParams): Promise<{ data: Job }> {\n return this.client.request<{ data: Job }>(\"POST\", \"/v1/jobs/from-upload\", { body: params })\n }\n\n /**\n * Rate one of your jobs `\"good\"` or `\"bad\"`, or clear the rating with\n * `null` (`PUT /v1/jobs/:id/rating`). Only the job's owner rates it — anyone\n * else's job is a `NotFoundError`. The rating reads back as `Job.rating`\n * and filters {@link list}. OAuth apps need the `assets:write` scope.\n */\n rate(id: string, rating: JobRating | null): Promise<RateJobResult> {\n return this.client.request<RateJobResult>(\"PUT\", `/v1/jobs/${encodeURIComponent(id)}/rating`, {\n body: { rating },\n })\n }\n\n /**\n * Get the lean status of a single job (poll-loop friendly).\n * Hits `GET /v1/jobs/:id/status` — returns only id/status/progress/\n * output_data/error_message, with far less wire/CPU cost than `get()`.\n * Same auth + ownership semantics as {@link get}.\n */\n getStatus(id: string): Promise<{ data: JobStatusResult }> {\n return this.client.request(\n \"GET\",\n `/v1/jobs/${encodeURIComponent(id)}/status`,\n )\n }\n\n /**\n * Cancel a job. Server route is `POST /v1/jobs/:jobId/cancel`.\n * Refunds any reserved credit holds. A running LLM job priced per model\n * (metered) whose call has already started answers\n * `{ success: true, cancelled: 0, inFlight: true }`: it finishes and is\n * charged only what it used. A job stopped before its call starts is\n * refunded, except for what an earlier attempt of the same job already used\n * (a retry after a billed attempt): that is charged.\n */\n cancel(id: string): Promise<CancelJobResult> {\n return this.client.request(\n \"POST\",\n `/v1/jobs/${encodeURIComponent(id)}/cancel`,\n )\n }\n\n /**\n * Delete a job and the private media it produced. Server route is\n * `DELETE /v1/jobs/:jobId`. Only the job's owner (or an admin) may delete it;\n * a job that is still running is deleted as-is — cancel it first when its\n * worker should stop ({@link cancel}).\n */\n delete(id: string): Promise<DeleteJobResult> {\n return this.client.request(\n \"DELETE\",\n `/v1/jobs/${encodeURIComponent(id)}`,\n )\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkFM2KM5TY_cjs = require('./chunk-FM2KM5TY.cjs');
|
|
4
4
|
var edl = require('@nodaro/shared/edl');
|
|
5
5
|
var nodes = require('@nodaro/shared/nodes');
|
|
6
6
|
|
|
@@ -277,7 +277,7 @@ var EditResource = class {
|
|
|
277
277
|
*/
|
|
278
278
|
async continueUseCase(input, options) {
|
|
279
279
|
if (input.nodeType !== void 0 && !nodes.isUseCaseNodeType(input.nodeType)) {
|
|
280
|
-
throw new
|
|
280
|
+
throw new chunkFM2KM5TY_cjs.NodaroError(
|
|
281
281
|
`continueUseCase: nodeType "${String(input.nodeType)}" is not a use-case node type (${nodes.USE_CASE_NODE_TYPES.join(", ")})`,
|
|
282
282
|
"invalid_node_type",
|
|
283
283
|
400
|
|
@@ -298,12 +298,12 @@ var EditResource = class {
|
|
|
298
298
|
* Any other failure of the read, any other 403 included, is thrown as is.
|
|
299
299
|
*/
|
|
300
300
|
async runTypeOf(jobId) {
|
|
301
|
-
const unknown = () => new
|
|
301
|
+
const unknown = () => new chunkFM2KM5TY_cjs.NodaroError("continueUseCase: the run's node type cannot be read \u2014 pass nodeType", "use_case_type_unknown", 400);
|
|
302
302
|
let row;
|
|
303
303
|
try {
|
|
304
304
|
row = (await this.client.request("GET", `/v1/jobs/${encodeURIComponent(jobId)}`)).data;
|
|
305
305
|
} catch (err) {
|
|
306
|
-
if (err instanceof
|
|
306
|
+
if (err instanceof chunkFM2KM5TY_cjs.ForbiddenError && err.missingScope === "jobs:read") throw unknown();
|
|
307
307
|
throw err;
|
|
308
308
|
}
|
|
309
309
|
const input = row?.input_data;
|
|
@@ -330,7 +330,7 @@ var EditResource = class {
|
|
|
330
330
|
});
|
|
331
331
|
if (!planned.ok) {
|
|
332
332
|
const message = planned.issues.map((issue) => edl.describeAudioSyncOffsetIssue(issue)).join("; ");
|
|
333
|
-
return Promise.reject(new
|
|
333
|
+
return Promise.reject(new chunkFM2KM5TY_cjs.NodaroError(`editPlan: ${message}`, "edit_plan_sources", 400));
|
|
334
334
|
}
|
|
335
335
|
const transcript = planned.transcriptSourceId ? { ...input.transcript, sourceId: planned.transcriptSourceId } : input.transcript;
|
|
336
336
|
return this.client.request("POST", "/v1/edit-plan", {
|
|
@@ -360,14 +360,14 @@ var EditResource = class {
|
|
|
360
360
|
*/
|
|
361
361
|
cameraSwitch(input) {
|
|
362
362
|
if (edl.transcriptSpeakerLabels(input.transcript).length === 0) {
|
|
363
|
-
return Promise.reject(new
|
|
363
|
+
return Promise.reject(new chunkFM2KM5TY_cjs.NodaroError(
|
|
364
364
|
"cameraSwitch: the transcript has no speaker labels \u2014 transcribe with speaker detection on",
|
|
365
365
|
"no_speakers",
|
|
366
366
|
422
|
|
367
367
|
));
|
|
368
368
|
}
|
|
369
369
|
const result = input.speakerMapResult;
|
|
370
|
-
if (result !== void 0 && !edl.speakerMapResultOf(result)) return Promise.reject(new
|
|
370
|
+
if (result !== void 0 && !edl.speakerMapResultOf(result)) return Promise.reject(new chunkFM2KM5TY_cjs.NodaroError("cameraSwitch: speakerMapResult is not a Speaker Map result \u2014 pass that job's output_data.json", "not_a_speaker_map", 400));
|
|
371
371
|
const speakerMap = result !== void 0 ? edl.cameraSwitchSpeakerMap({ speakerMap: input.speakerMap }, input.edl, input.transcript, { speakerMap: result }) : input.speakerMap;
|
|
372
372
|
return this.client.request("POST", "/v1/camera-switch", {
|
|
373
373
|
body: {
|
|
@@ -404,5 +404,5 @@ exports.CLIP_PACK_MAX_TARGET_SEC = CLIP_PACK_MAX_TARGET_SEC;
|
|
|
404
404
|
exports.CLIP_PACK_MIN_TARGET_SEC = CLIP_PACK_MIN_TARGET_SEC;
|
|
405
405
|
exports.EditResource = EditResource;
|
|
406
406
|
exports.TRAILER_FORMATS = TRAILER_FORMATS;
|
|
407
|
-
//# sourceMappingURL=chunk-
|
|
408
|
-
//# sourceMappingURL=chunk-
|
|
407
|
+
//# sourceMappingURL=chunk-7XOK277W.cjs.map
|
|
408
|
+
//# sourceMappingURL=chunk-7XOK277W.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resources/edit-use-case-inputs.ts","../src/resources/edit.ts"],"names":["isUseCaseNodeType","NodaroError","USE_CASE_NODE_TYPES","ForbiddenError","resolveEditPlanSources","describeAudioSyncOffsetIssue","transcriptSpeakerLabels","speakerMapResultOf","cameraSwitchSpeakerMap","edl","remapTranscriptThroughEdl"],"mappings":";;;;;;;AA+GO,IAAM,eAAA,GAAkB,CAAC,MAAA,EAAQ,KAAA,EAAO,OAAO,MAAM;AA4BrD,IAAM,wBAAA,GAA2B;AACjC,IAAM,wBAAA,GAA2B;AAyGxC,SAAS,eAAiD,KAAA,EAAmC;AAC3F,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAW,gBAAgB,OAAA,EAAS,GAAG,MAAK,GAAI,KAAA;AAClE,EAAA,IAAI,aAAa,MAAA,IAAa,SAAA,KAAc,QAAW,MAAM,IAAI,UAAU,sCAAsC,CAAA;AACjH,EAAA,MAAM,aAAa,SAAA,KAAc,QAAA,KAAa,MAAA,GAAY,CAAC,QAAQ,CAAA,GAAI,MAAA,CAAA;AACvE,EAAA,IAAI,CAAC,UAAA,EAAY,MAAM,IAAI,UAAU,4BAA4B,CAAA;AACjE,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,CAAC,GAAG,UAAU,CAAA;AAAA,IACzB,GAAI,cAAA,KAAmB,MAAA,GAAY,EAAE,cAAA,KAAmB,EAAC;AAAA,IACzD,GAAI,OAAA,KAAY,MAAA,GAAY,EAAE,OAAA,KAAY,EAAC;AAAA,IAC3C,GAAG,MAAA,CAAO,WAAA,CAAY,MAAA,CAAO,QAAQ,IAAI,CAAA,CAAE,MAAA,CAAO,CAAC,GAAG,CAAC,CAAA,KAAM,CAAA,KAAM,MAAS,CAAC;AAAA,GAC/E;AACF;AAOO,SAAS,eAAA,CAAmB,OAAsC,IAAA,EAAiE;AACxI,EAAA,IAAI,IAAA;A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,UAAA,EAAW,GAAI;AAAC;AAC3E,KACD,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,eAAA,CAAgBC,OAAU,UAAA,EAAoC;AAC5D,IAAA,OAAOC,6BAAA,CAA0BD,OAAK,UAAU,CAAA;AAAA,EAClD;AACF","file":"chunk-RHJRLXKY.cjs","sourcesContent":["/**\n * The inputs of the podcast use-case runs on the `edit` resource (Tighten\n * Episode, Chapters, Trailer, Clip Pack, Speaker Layout) and the request body each one sends.\n * Split from `edit.ts`, which holds the methods, the type list and the\n * continue routes; every name here is re-exported from there.\n */\nimport type { EditPlanTier, EdlTargetAspect, SpeakerEmphasisStyle, SpeakerSwitchId } from \"@nodaro/shared/edl\"\nimport type { CaptionStyle } from \"@nodaro/shared/captions\"\n\n/**\n * The recordings of a use-case run: one (`mediaUrl`), or the recordings of one\n * conversation (`mediaUrls`, in order — the cameras; one may be sound only),\n * an optional Master audio and the Cameras settings. Pass `mediaUrl` or\n * `mediaUrls`, not both.\n *\n * Several recordings or a Master audio need Speaker Map, which tells who is on\n * which camera: where it is not available to you (not yet on nodaro.ai) the\n * request is refused `403 node_not_available` — send one recording.\n */\nexport interface UseCaseRecordingsInput {\n /** The recording — a video or audio URL, up to 3 hours. */\n mediaUrl?: string\n /**\n * Instead of `mediaUrl`: the recordings of one conversation, in order — up\n * to six in all with the Master audio; without one, two or more cameras keep\n * a place for the sound, so up to five. With two or more the run lines them\n * up, works out who is on which camera and cuts to whoever is talking.\n */\n mediaUrls?: string[]\n /** The mixer or recorder track: the episode's sound and the clock the recordings are lined up to. */\n masterAudioUrl?: string\n /** With several recordings or a Master audio: the Cameras settings (ignored with one recording and no Master audio). */\n cameras?: {\n /** Which recording (1-based) is the wide shot, shown when a speaker has no camera of their own; `null` for none. */\n wide?: number | null\n /** The recordings already share one clock: skip lining them up. */\n synced?: boolean\n /** Who is on which camera: speaker number (`\"1\"` = the first voice heard) → recording number, 0 = the wide shot. Overrides the automatic map. */\n speakerCameras?: Record<string, number>\n }\n}\n\n/**\n * Input for {@link EditResource.tightenEpisode} and\n * {@link EditResource.estimateTightenEpisode}: the recording (or the\n * recordings of one conversation, see {@link UseCaseRecordingsInput}) in, the\n * tightened episode out. Only the recording is required; every other field\n * left out takes the node's default.\n */\nexport interface TightenEpisodeInput extends UseCaseRecordingsInput {\n /** Optional music bed, ducked under the voice and ending with the episode. */\n musicUrl?: string\n /** `\"video\"` or `\"audio\"`; an audio recording always makes an audio episode. */\n output?: \"video\" | \"audio\"\n /**\n * Frame a video episode with Speaker View: an output aspect and a layout,\n * over automatic boxes on the speakers on screen. A layout the aspect does\n * not draw is snapped to one it does. `null` or absent: no framing.\n */\n framing?: {\n aspect: EdlTargetAspect\n layout: \"auto\" | \"single\" | \"side-by-side\" | \"stacked\" | \"grid\" | \"pip\"\n } | null\n /**\n * With a framing, how it follows the speakers: `\"static\"` (the default)\n * splits the frame evenly by speaker; `\"tracking\"` follows faces with\n * Speaker Frames (charged per started block of 1,000 sampled frames; a\n * camera shared by several speakers keeps the even split until faces are\n * named; refused 403 where Speaker Frames is not available to the caller);\n * `\"auto\"` follows faces while Speaker Frames is available to the caller,\n * else the even split. Ignored without a framing.\n */\n framingSource?: \"auto\" | \"static\" | \"tracking\"\n /** Captions on a video episode (on by default). */\n captions?: boolean\n /** The captions' look. */\n captionStyle?: CaptionStyle\n /**\n * Stop at a quick preview for a person to review; render the full-quality\n * episode afterwards with {@link EditResource.continueUseCase}\n * (`mode: \"render-final\"`).\n */\n reviewBeforeRender?: boolean\n /** The planner's tier. */\n planTier?: EditPlanTier\n /** Editing instructions for the planner (up to 4 000 characters). */\n instructions?: string\n /** A style guide for the planner (up to 4 000 characters). */\n styleGuide?: string\n /** How far the music dips under the voice, 0–100 (default 75). */\n musicDuckAmount?: number\n}\n\n/**\n * Input for {@link EditResource.episodeChapters} and\n * {@link EditResource.estimateEpisodeChapters}: one recording in, its chapters\n * out. Only `mediaUrl` is required; every other field left out takes the\n * node's default.\n */\nexport interface EpisodeChaptersInput {\n /** The recording — a video or audio URL, up to 3 hours. */\n mediaUrl: string\n /** The planner's tier (default `\"economy\"`). */\n planTier?: EditPlanTier\n /** Instructions for the chapters, e.g. \"5 to 8 chapters\" (up to 4 000 characters). */\n instructions?: string\n /** A style guide for the chapter titles (up to 4 000 characters). */\n styleGuide?: string\n}\n\n/** The formats a Trailer is delivered in, in delivery order (16:9 is a 1920×1080 landscape). */\nexport const TRAILER_FORMATS = [\"9:16\", \"1:1\", \"4:5\", \"16:9\"] as const\n/** One Trailer format (see {@link TRAILER_FORMATS}). */\nexport type TrailerFormat = (typeof TRAILER_FORMATS)[number]\n\n/**\n * Input for {@link EditResource.episodeTrailer} and\n * {@link EditResource.estimateEpisodeTrailer}: one video recording (or the\n * recordings of one conversation, see {@link UseCaseRecordingsInput}) in, a\n * 20–40 s trailer out in each chosen format. Only the recording is required.\n */\nexport interface EpisodeTrailerInput extends UseCaseRecordingsInput {\n /** The recording — a video URL, up to 3 hours (a run with no picture is refused). Or `mediaUrls`. */\n mediaUrl?: string\n /** An optional intro card: a short video (15 s at most) played before the trailer. */\n introCardUrl?: string\n /** The formats to deliver, padded, never cropped (default `[\"9:16\", \"1:1\", \"4:5\"]`; an empty list is refused). */\n formats?: TrailerFormat[]\n /** Stop at a preview of the trailer; render every format with {@link EditResource.continueUseCase} (`mode: \"render-final\"`). */\n reviewBeforeRender?: boolean\n /** The planner's tier (default `\"standard\"`). */\n planTier?: EditPlanTier\n /** Instructions for the trailer (up to 4 000 characters). */\n instructions?: string\n /** A style guide for the planner (up to 4 000 characters). */\n styleGuide?: string\n}\n\n/** The shortest and longest clip a Clip Pack asks the plan for, in seconds. */\nexport const CLIP_PACK_MIN_TARGET_SEC = 5\nexport const CLIP_PACK_MAX_TARGET_SEC = 180\n\n/**\n * A Clip Pack emphasis: `\"none\"`, or one or more of `\"scale\"`, `\"border\"` and\n * `\"dim\"` joined with `\"+\"` (each once — the route refuses a repeat).\n */\nexport type ClipPackEmphasis = SpeakerEmphasisStyle | `${Exclude<SpeakerEmphasisStyle, \"none\">}+${string}`\n\n/**\n * Input for {@link EditResource.clipPack} and\n * {@link EditResource.estimateClipPack}: the recording (or the recordings of\n * one conversation, see {@link UseCaseRecordingsInput} — each clip then cuts\n * to whoever is talking) in, a pack of short clips out. An audio recording\n * makes audio clips (no framing, no captions). Only the recording is\n * required; every other field left out takes the node's default.\n */\nexport interface ClipPackInput extends UseCaseRecordingsInput {\n /** How many clips to find, 1–50 (default 8). The plan may find fewer. */\n count?: number\n /** Each clip's target length in seconds, {@link CLIP_PACK_MIN_TARGET_SEC}–{@link CLIP_PACK_MAX_TARGET_SEC} (default 60). */\n targetDurationSec?: number\n /**\n * Frame each video clip with Speaker View on automatic boxes over the\n * episode's speakers: the shape, and optionally the layout (default\n * `\"stacked\"`; one the shape does not draw is snapped), the switch at each\n * speaker change (default `\"pan\"`) and the emphasis (default `\"scale\"`;\n * `\"none\"`, or `\"scale\"`, `\"border\"` and `\"dim\"` joined with `\"+\"`). Left\n * out: 9:16, stacked, pan, scale. `null`: no framing (the recording's shape).\n */\n framing?: {\n aspect: EdlTargetAspect\n layout?: \"auto\" | \"single\" | \"side-by-side\" | \"stacked\" | \"grid\" | \"pip\"\n switchType?: SpeakerSwitchId\n emphasisStyle?: ClipPackEmphasis\n } | null\n /**\n * With a framing, how it follows the speakers: `\"static\"` splits the frame\n * evenly by speaker (what a request that leaves this out gets); `\"tracking\"`\n * runs Speaker Frames once over the whole pack to follow faces (charged per\n * started block of 1,000 sampled frames; refused 403 where Speaker Frames is\n * not available to the caller); `\"auto\"` follows faces while Speaker Frames\n * is available to the caller, else the even split. Ignored without a framing.\n */\n framingSource?: \"auto\" | \"static\" | \"tracking\"\n /** Caption each video clip (on by default). */\n captions?: boolean\n /** The captions' look (default `\"karaoke\"`). */\n captionStyle?: CaptionStyle\n /**\n * Stop at quick previews of the clips for a person to review; render the\n * kept clips at full quality with {@link EditResource.continueUseCase}\n * (`mode: \"render-final\"`, an `editedEdl` that keeps or drops clips).\n */\n reviewBeforeRender?: boolean\n /** The planner's tier (default `\"standard\"`). */\n planTier?: EditPlanTier\n /** Instructions for picking the clips (up to 4 000 characters). */\n instructions?: string\n /** A style guide for the planner (up to 4 000 characters). */\n styleGuide?: string\n}\n\n/**\n * Input for {@link EditResource.speakerLayout} and\n * {@link EditResource.estimateSpeakerLayout}: one video recording (or the\n * recordings of one conversation, see {@link UseCaseRecordingsInput}) in, the\n * whole recording framed by speaker out — the same length, nothing cut. Only\n * the recording is required; every other field left out takes the node's\n * default.\n */\nexport interface SpeakerLayoutInput extends UseCaseRecordingsInput {\n /** The recording — a video URL, up to 3 hours (an audio-only recording is refused). Or `mediaUrls`. */\n mediaUrl?: string\n /** The video's shape (default `\"9:16\"`). With one recording, a video already as narrow as the shape (or narrower) is refused `400 media_shape`. */\n targetAspect?: EdlTargetAspect\n /** How the speakers are laid out (default `\"stacked\"`; one the shape does not draw is snapped to one it does). */\n layout?: \"auto\" | \"single\" | \"side-by-side\" | \"stacked\" | \"grid\" | \"pip\"\n /** The switch at each speaker change (default `\"cut\"`). */\n switchType?: SpeakerSwitchId\n /** How the speaker talking is emphasised (default `\"scale\"`): `\"none\"`, or `\"scale\"`, `\"border\"` and `\"dim\"` joined with `\"+\"`. */\n emphasisStyle?: ClipPackEmphasis\n /**\n * How the speakers are followed: `\"auto\"` (the default) follows faces with\n * Speaker Frames while it is available to the caller, else splits the frame\n * evenly; `\"static\"` splits the frame evenly by speaker; `\"tracking\"`\n * follows faces (charged per started block of 1,000 sampled frames;\n * refused 403 where Speaker Frames is not available to the caller). Faces\n * aren't named after a speaker yet, so a camera shared by several speakers\n * keeps the even split.\n */\n framingSource?: \"auto\" | \"static\" | \"tracking\"\n /**\n * Stop at a quick preview for a person to review; render it at full\n * quality with {@link EditResource.continueUseCase}\n * (`mode: \"render-final\"`, no `editedEdl`: the layout has no cut to change).\n */\n reviewBeforeRender?: boolean\n}\n\n/**\n * The body's recordings (`mediaUrls`, then `masterAudioUrl` and `cameras` when\n * given), and the rest of the input as it came: the one mapper every use-case\n * body goes through. Throws before any request when the input names both\n * `mediaUrl` and `mediaUrls`, or neither.\n */\nfunction withRecordings<T extends UseCaseRecordingsInput>(input: T): Record<string, unknown> {\n const { mediaUrl, mediaUrls, masterAudioUrl, cameras, ...rest } = input\n if (mediaUrl !== undefined && mediaUrls !== undefined) throw new TypeError(\"pass mediaUrl or mediaUrls, not both\")\n const recordings = mediaUrls ?? (mediaUrl !== undefined ? [mediaUrl] : undefined)\n if (!recordings) throw new TypeError(\"pass mediaUrl or mediaUrls\")\n return {\n mediaUrls: [...recordings],\n ...(masterAudioUrl !== undefined ? { masterAudioUrl } : {}),\n ...(cameras !== undefined ? { cameras } : {}),\n ...Object.fromEntries(Object.entries(rest).filter(([, v]) => v !== undefined)),\n }\n}\n\n/**\n * Sends `send` the body `build` makes, or rejects (never throws) with the\n * error of an input the body cannot take — before any request, as every input\n * check of the `edit` resource rejects.\n */\nexport function withUseCaseBody<T>(build: () => Record<string, unknown>, send: (body: Record<string, unknown>) => Promise<T>): Promise<T> {\n let body: Record<string, unknown>\n try {\n body = build()\n } catch (err) {\n return Promise.reject(err)\n }\n return send(body)\n}\n\nexport function tightenBody(input: TightenEpisodeInput): Record<string, unknown> {\n return withRecordings(input)\n}\n\nexport function chaptersBody(input: EpisodeChaptersInput): Record<string, unknown> {\n return withRecordings({\n mediaUrl: input.mediaUrl,\n ...(input.planTier !== undefined ? { planTier: input.planTier } : {}),\n ...(input.instructions !== undefined ? { instructions: input.instructions } : {}),\n ...(input.styleGuide !== undefined ? { styleGuide: input.styleGuide } : {}),\n })\n}\n\nexport function trailerBody(input: EpisodeTrailerInput): Record<string, unknown> {\n return withRecordings({\n mediaUrl: input.mediaUrl,\n mediaUrls: input.mediaUrls,\n masterAudioUrl: input.masterAudioUrl,\n cameras: input.cameras,\n ...(input.introCardUrl !== undefined ? { introCardUrl: input.introCardUrl } : {}),\n // An empty list is sent as is: the route refuses it (at least one format).\n ...(input.formats !== undefined ? { formats: input.formats } : {}),\n ...(input.reviewBeforeRender !== undefined ? { reviewBeforeRender: input.reviewBeforeRender } : {}),\n ...(input.planTier !== undefined ? { planTier: input.planTier } : {}),\n ...(input.instructions !== undefined ? { instructions: input.instructions } : {}),\n ...(input.styleGuide !== undefined ? { styleGuide: input.styleGuide } : {}),\n })\n}\n\n/** Clip Pack's body: what the caller set, `framing: null` included (no framing). */\nexport function clipPackBody(input: ClipPackInput): Record<string, unknown> {\n return withRecordings(input)\n}\n\n/** Speaker Layout's body: the recordings, then what the caller set. */\nexport function speakerLayoutBody(input: SpeakerLayoutInput): Record<string, unknown> {\n return withRecordings(input)\n}\n","import type { NodaroClientCore } from \"../core.js\"\nimport { ForbiddenError, NodaroError } from \"../errors.js\"\nimport {\n remapTranscriptThroughEdl,\n unwrapEditPlanOutput,\n resolveEditPlanSources,\n describeAudioSyncOffsetIssue,\n transcriptSpeakerLabels,\n cameraSwitchSpeakerMap, speakerMapResultOf, type SpeakerMapResult,\n type Edl,\n type Transcript,\n type EditPlanMode,\n type EditPlanTier,\n type EdlClipSet,\n type ChapterSet,\n type EdlTargetAspect\n} from \"@nodaro/shared/edl\"\nimport { USE_CASE_NODE_TYPES, isUseCaseNodeType, type UseCaseNodeType } from \"@nodaro/shared/nodes\"\nimport type { SpeakerMapInput } from \"./speaker-map-inputs.js\"\nimport {\n chaptersBody,\n clipPackBody,\n speakerLayoutBody,\n tightenBody,\n trailerBody,\n withUseCaseBody,\n type ClipPackInput,\n type EpisodeChaptersInput,\n type EpisodeTrailerInput,\n type SpeakerLayoutInput,\n type TightenEpisodeInput,\n} from \"./edit-use-case-inputs.js\"\n\nexport { CLIP_PACK_MAX_TARGET_SEC, CLIP_PACK_MIN_TARGET_SEC, TRAILER_FORMATS } from \"./edit-use-case-inputs.js\"\nexport type { ClipPackEmphasis, ClipPackInput, EpisodeChaptersInput, EpisodeTrailerInput, SpeakerLayoutInput, TightenEpisodeInput, TrailerFormat, UseCaseRecordingsInput } from \"./edit-use-case-inputs.js\"\n\n// Re-export the canonical EDL / transcript vocabulary from `@nodaro/shared`\n// (single source of truth — the shapes live at `packages/shared/src/edl.ts`).\n// `@nodaro/shared` is already a hard dep of this package, so there is no\n// bundle-size cost to importing from it, and an integration builds requests and\n// reads results with one dependency. `EdlClipSet` / `ChapterSet` are the raw\n// `output_data` shapes of the `clips` / `chapters` modes, and\n// `unwrapEditPlanOutput` is the sanctioned way to normalize any edit-plan job's\n// `output_data` (it also strips the relay's `viaNodaroCloud` marker).\nexport type { Edl, Transcript, EditPlanMode, EditPlanTier, EdlClipSet, ChapterSet }\nexport { unwrapEditPlanOutput }\n\n/**\n * A silence-detect job's `output_data.json` — the value to pass as\n * {@link EditPlanInput.silence}. It is NOT what {@link EditResource.silenceDetect}\n * returns (that is `{ jobId }`); fetch the finished job and read its\n * `output_data.json`. The planner reads the `ranges` array — an input without\n * one is silently ignored, so pass this whole object.\n */\nexport interface SilenceRanges {\n /** Wire version of the payload. */\n version?: number\n /** Silence spans on the source clock, in ms. */\n ranges: ReadonlyArray<{ startMs: number; endMs: number }>\n /** Total source duration, in ms. */\n durationMs?: number\n}\n\n/** Every editorial route answers with the queued job to poll. */\nexport interface EditJobResult {\n /** The queued job id — follow it via `client.jobs.getStatus(jobId)`. */\n jobId: string\n}\n\nexport interface SilenceDetectInput {\n /**\n * An audio OR video source. A single ffmpeg `silencedetect` pass runs over the\n * source's audio proxy either way — no provider key required.\n */\n audioUrl: string\n /** dBFS threshold, always ≤ 0. Default -35 (a good podcast default). */\n thresholdDb?: number\n /** Minimum silence length to report, in ms. Default 700. */\n minSilenceMs?: number\n /** Padding kept around speech, in ms — shrinks each reported range inward. Default 120. */\n padMs?: number\n /**\n * Optionally associate this run with a workflow execution (display only — it\n * ties the standalone job back to a workflow for the execution history).\n */\n workflowId?: string\n}\n\n/** One recording for {@link EditResource.audioSync}. */\nexport interface AudioSyncSource {\n /**\n * Your id for this recording (1–200 chars, unique within the request) —\n * echoed back as its offset's `sourceId`. Use the id your EDL gives the same\n * recording (`EdlSource.id`) and the result folds straight into it.\n */\n id: string\n /** An audio OR video URL — the audio track is read either way. */\n url: string\n}\n\nexport interface AudioSyncInput {\n /** The 2–6 recordings of one conversation to line up (camera files and/or a master mic). */\n sources: AudioSyncSource[]\n /**\n * The id of the source every offset is measured against (its own offset is\n * 0). Must be one of `sources`' ids; default: the first source.\n */\n reference?: string\n /** Optionally associate this run with a workflow execution (display only). */\n workflowId?: string\n}\n\n/** One recording's measured clock offset in an {@link AudioSyncResult}. */\nexport interface AudioSyncOffset {\n /** The recording's `id` from the request. */\n sourceId: string\n /**\n * Where this recording sits on the reference's clock, in integer ms:\n * `referenceMs = sourceMs + offsetMs` (the EDL's D19 sign — the value\n * `EdlSource.offsetMs` takes when the reference is the master).\n */\n offsetMs: number\n /** 0–1. Below 0.5 a `notes` line asks for a check by ear. */\n confidence: number\n /**\n * Measured clock drift against the reference, in ms gained per hour; `null`\n * when the shared stretch was too short to measure it. Drift is reported,\n * never corrected — the offset is taken at the middle of the overlap.\n */\n driftMsPerHour: number | null\n}\n\n/**\n * An audio-sync job's `output_data.json`. It is NOT what\n * {@link EditResource.audioSync} returns (that is `{ jobId }`); fetch the\n * finished job and read its `output_data.json`.\n */\nexport interface AudioSyncResult {\n /** Wire version of the payload. */\n version: number\n /** The source every offset is measured against (its own offset is 0). */\n reference: string\n offsets: AudioSyncOffset[]\n /** Human-readable warnings: low confidence, measured drift, no shared sound. */\n notes: string[]\n}\n\nexport interface ApplyEdlInput {\n /** The edit decision list to render. Media resolves from each `edl.sources[i].url`. */\n edl: Edl\n /**\n * Optional media-URL overrides for `edl.sources[i].url`, POSITIONAL in this\n * array's order. Each URL is SSRF-guarded server-side like any media the\n * platform fetches.\n */\n sources?: string[]\n /**\n * Optional transcript to remap through the cut. The rendered job returns the\n * remapped transcript on its `json` output. A word-level multi-hour transcript\n * is several MB — if you only need the re-timed transcript (not a render), use\n * {@link EditResource.remapTranscript} locally instead of sending it here.\n */\n transcript?: Transcript\n /** Render a full video (default) or an audio-only cut. */\n output?: \"video\" | \"audio\"\n /** Fast proxy draft or the final render. Default \"final\". */\n quality?: \"proxy\" | \"final\"\n /**\n * Default crossfade (ms) on boundaries with no explicit transition; 0 = hard\n * cuts. Per-boundary clamped to the ffmpeg-xfade limit server-side. Default 0.\n */\n crossfadeMs?: number\n /**\n * The plan clip this render cuts — `edlSpanKey(clip)` from `@nodaro/shared`\n * (`\"<first inMs>-<last outMs>\"`). The job's result carries it back as\n * `output_data.clipKey`, so renders of a clip set can be matched to their\n * clips. Omit for a render of no plan clip.\n */\n clipKey?: string\n /**\n * The plan value this render cuts — `renderReadBasis(value)` from\n * `@nodaro/shared` (16 lowercase hex digits), where `value` is the Edit\n * Plan's Tighten EDL with any review applied, or the clip this render cuts.\n * The job's result carries it back as `output_data.planBasis`, so a take can\n * be told apart from one cut from an earlier plan. Send it only when the EDL\n * you send IS that value (not one an intermediate step re-cut from an older\n * plan); omit it otherwise. The result's `output_data.renderBasis` (the\n * render's own settings and sources) is stamped by the server.\n */\n planBasis?: string\n /** Optionally associate this run with a workflow execution (display only). */\n workflowId?: string\n}\n\n/**\n * One media source for an edit-plan run. Mirrors the shape the workflow engine\n * sends: a stable `id` (adopted verbatim as the plan's `EdlSource` id), the\n * media `url`, and the `kind`, plus optional per-source annotations the planner\n * honors.\n */\nexport interface EditPlanSource {\n /** Stable id for this source — becomes the `EdlSource` id in the returned plan. */\n id: string\n /** The source's media URL (SSRF-guarded server-side). */\n url: string\n /** This source's medium. */\n kind: \"video\" | \"audio\"\n /** Role annotation. `\"master-audio\"` marks the clock the plan is reserved on. */\n role?: \"master-audio\" | \"camera\" | \"wide\" | \"screen\"\n /** Speaker labels present in this source. */\n speakers?: string[]\n /**\n * This source's origin on the master clock (masterMs = sourceMs + offsetMs).\n * Set by hand, it wins over a measured offset from `offsets`.\n */\n offsetMs?: number\n}\n\nexport interface EditPlanInput {\n /**\n * Planning mode. The finished job's `output_data` carries the plan — read it\n * with {@link unwrapEditPlanOutput}, which also strips the relay's\n * `viaNodaroCloud` marker:\n * - `\"tighten\"` → an `Edl`.\n * - `\"clips\"` → an {@link EdlClipSet} (`{ version, clips: Edl[] }`);\n * `unwrapEditPlanOutput` returns the bare `Edl[]`.\n * - `\"chapters\"` → a {@link ChapterSet} (`{ version, chapters: [...] }`).\n * - `\"trailer\"` → an `Edl` (one short teaser cut from the strongest moments).\n */\n mode: EditPlanMode\n /** Reasoning tier — affects plan quality AND the credit bucket. */\n planTier: EditPlanTier\n /** The timed transcript driving the plan. */\n transcript: Transcript\n /**\n * Optional detected silence ranges. Pass the silence-detect JOB'S RESULT —\n * `getStatus(jobId).data.output_data.json` (a {@link SilenceRanges} object),\n * NOT the `{ jobId }` that {@link EditResource.silenceDetect} returns. The\n * planner reads the `ranges` array; an input without one is silently ignored.\n */\n silence?: SilenceRanges\n /** The recording's media sources (1–6). */\n sources: EditPlanSource[]\n /**\n * Multicam: an {@link AudioSyncResult} (the audio-sync job's\n * `output_data.json`) measured over these same source ids. Each source's\n * measured offset is written onto its `offsetMs` BEFORE the request, on the\n * master's clock (the `master-audio` source, else the first) — a source's\n * own `offsetMs` wins. `editPlan` rejects with a {@link NodaroError}\n * (`code: \"edit_plan_sources\"`), before any request or charge, when a\n * source was not measured or matched weakly (confidence < 0.5 — set its\n * `offsetMs` by hand), or the master was not measured.\n */\n offsets?: AudioSyncResult | string\n /**\n * The id of the source the transcript was made from, when you know it. The\n * plan follows the master's clock, so a transcript made from a source that\n * is off it is rejected the same way.\n */\n transcriptSourceId?: string\n /** Free-text editing steer. */\n instructions?: string\n /** Style-guide text applied to the plan. */\n styleGuide?: string\n /** `\"clips\"` mode only: how many clips to cut. */\n count?: number\n /** `\"clips\"` mode only: target duration per clip, in seconds. */\n targetDurationSec?: number\n /** Target aspect for cut clips (`\"clips\"`) or the teaser (`\"trailer\"`). */\n targetAspect?: \"16:9\" | \"9:16\" | \"1:1\" | \"4:5\"\n /** Target platform hint (e.g. a social platform name). */\n platform?: string\n /** Optionally associate this run with a workflow execution (display only). */\n workflowId?: string\n}\n\n/** Input for {@link EditResource.cameraSwitch} (podcast B5). */\nexport interface CameraSwitchInput {\n /** One EDL — an `editPlan` result (`unwrapEditPlanOutput`), not a clip set. */\n edl: Edl\n /** The word transcript WITH speaker labels (transcribe with speaker detection). */\n transcript: Transcript\n /** Speaker label → the EDL source id of that speaker's camera. A speaker\n * left out shows the source whose `speakers` list names them, else the\n * `wide` camera, else any camera that filmed them. */\n speakerMap?: Record<string, string>\n /** A {@link EditResource.speakerMap} job's `output_data.json`: a label in `speakerMap`\n * wins, then this result, then the n-th speaker heard gets the n-th camera. */\n speakerMapResult?: SpeakerMapResult | string\n /** Speaker label → display name (on the segments and the returned transcript). */\n speakerNames?: Record<string, string>\n /** The shortest shot in ms (default 2 500): a shorter turn holds the shot. */\n minShotMs?: number\n /** Cut this long before the new speaker starts, ms (default 200). */\n leadMs?: number\n /** With a `wide` source: break to it after this long on one camera, ms (default 20 000). */\n maxShotMs?: number\n /** With a `wide` source: every N-th cut goes to the wide (default 0 = off). */\n wideEvery?: number\n /** Overlapping speech → a layout hint (default false; Apply EDL renders cut-only edits). */\n layoutHints?: boolean\n /** Optionally associate this run with a workflow execution (display only). */\n workflowId?: string\n}\n\n/**\n * The podcast use-case node types, each one a route (`POST /v1/<type>`, and\n * `POST /v1/<type>/continue` to continue one of its runs).\n */\nexport { USE_CASE_NODE_TYPES, type UseCaseNodeType }\n\n/** The route that continues a run of `type`. */\nconst continuePathOf = (type: UseCaseNodeType): `/v1/${UseCaseNodeType}/continue` => `/v1/${type}/continue`\n\n/** What a use-case run (`tightenEpisode`, `episodeChapters`, `episodeTrailer`, `clipPack`, `speakerLayout`) and `continueUseCase` answer: the run's job to poll. */\nexport interface UseCaseJobResult extends EditJobResult {\n /** The run's execution (absent on a deduplicated retry). */\n executionId?: string\n /** `true` when an `Idempotency-Key` retry found the run already started: `jobId` is that run. */\n deduped?: boolean\n}\n\n/** What `tightenEpisode` answers (a {@link UseCaseJobResult}). */\nexport type TightenEpisodeJobResult = UseCaseJobResult\n\n/**\n * What a use-case run is estimated at (`data`). Every credit amount is 0\n * on an edition without credits; `durationSec` is `null` when the recording's\n * length could not be read.\n */\nexport interface UseCaseEstimate {\n /** The whole run: its steps plus the fee. */\n totalCredits: number\n /** The steps at their own rates. */\n stepsCredits: number\n /** The per-run fee. */\n feeCredits: number\n /** The recording's length, in seconds. */\n durationSec: number | null\n}\n\n/** What a Tighten Episode run is estimated at (a {@link UseCaseEstimate}). */\nexport type TightenEpisodeEstimate = UseCaseEstimate\n\n/** Input for {@link EditResource.continueUseCase}. */\nexport interface UseCaseContinueInput {\n /** The run to continue: the job `tightenEpisode`, `episodeChapters`, `episodeTrailer`, `clipPack` or `speakerLayout` (or an earlier continuation) answered. */\n jobId: string\n /**\n * `\"from-failed\"` re-runs what did not finish of a failed run;\n * `\"render-final\"` renders the full-quality result after a review-on preview\n * (a Chapters run has no preview: it is refused `render_final_not_preview`;\n * a Clip Pack edit that drops every clip is refused `use_case_nothing_kept`).\n */\n mode: \"from-failed\" | \"render-final\"\n /** Render final only: the reviewer's edit of the plan (an EDL). A Speaker Layout run has no plan: an edit is refused `400 use_case_no_plan`. */\n editedEdl?: unknown\n /**\n * The run's node type: its continuation goes to `POST /v1/<nodeType>/continue`.\n * Optional: when absent the job is read first (`GET /v1/jobs/:id`, which\n * needs the `jobs:read` scope on an app token) for the type the run records.\n * Required when that read cannot answer: a key without `jobs:read`, or a job\n * that records no use-case type (the call rejects with `use_case_type_unknown`).\n */\n nodeType?: UseCaseNodeType\n}\n\n/** Per-call options for the use-case requests (Tighten Episode, Chapters, Trailer, Clip Pack, Speaker Layout, and their continuations). */\nexport interface UseCaseRequestOptions {\n /**\n * Sent as the `Idempotency-Key` header. Reuse the same value when retrying\n * the same request and the server answers the run it already started\n * (`deduped: true`) instead of starting a second one.\n */\n idempotencyKey?: string\n}\n\nfunction idempotencyHeaders(options?: UseCaseRequestOptions): { headers?: Record<string, string> } {\n return options?.idempotencyKey ? { headers: { \"Idempotency-Key\": options.idempotencyKey } } : {}\n}\n\n/**\n * Editorial primitives for podcast / long-form video editing, single-camera\n * and multicam: measure the cameras' offsets ({@link audioSync}), plan the cut\n * ({@link editPlan}), put each cut on the speaker's camera\n * ({@link cameraSwitch}), render a Preview to review (`applyEdl` with\n * `quality: \"proxy\"`), then the final (`quality: \"final\"`).\n *\n * - {@link silenceDetect}, {@link audioSync} and {@link applyEdl} are core nodes\n * available on every edition.\n * - {@link editPlan} and {@link cameraSwitch} run on nodaro.ai; a self-hosted\n * install relays them once it is connected (a 503\n * `code: \"nodaro_connection_required\"` otherwise).\n * - {@link tightenEpisode} runs the whole chain (transcribe, plan, render, and\n * optionally captions, music and framing) in one call. It is core, but a\n * self-hosted install needs a nodaro.ai connection for the steps that run\n * there (a 503 `code: \"nodaro_connection_required\"` otherwise).\n * {@link continueUseCase} continues one of its runs.\n * - {@link episodeChapters} lists a recording's chapters (transcribe, then the\n * plan in chapters mode) in one call; nothing renders. Like\n * {@link tightenEpisode}, a self-hosted install needs a nodaro.ai connection.\n * - {@link episodeTrailer} cuts a 20–40 s trailer of a recording and delivers\n * it in each chosen format in one call; the same connection applies.\n * - {@link clipPack} cuts a recording into a pack of short clips (framed and\n * captioned by default) in one call; the same connection applies.\n * - {@link speakerLayout} frames a whole recording by speaker (the same\n * length, nothing cut) in one call; the same connection applies.\n * - {@link remapTranscript} is a PURE local transform (no request) — the same\n * remap `applyEdl` performs on its `transcript`, exposed for callers that hold\n * an EDL and a transcript and only want the re-timed transcript.\n *\n * Every request method except the estimates ({@link estimateTightenEpisode},\n * {@link estimateEpisodeChapters}, {@link estimateEpisodeTrailer},\n * {@link estimateClipPack}, {@link estimateSpeakerLayout}: a quote, `{ data }`) returns\n * {@link EditJobResult} (the use-case runs a {@link UseCaseJobResult}); poll the\n * `jobId` with `client.jobs.getStatus(jobId)`.\n */\nexport class EditResource {\n constructor(private client: NodaroClientCore) {}\n\n /**\n * Detect silence ranges in an audio/video source (`POST /v1/silence-detect`).\n * Keyless — one ffmpeg pass over the source's audio proxy.\n */\n silenceDetect(input: SilenceDetectInput): Promise<EditJobResult> {\n return this.client.request(\"POST\", \"/v1/silence-detect\", {\n body: {\n audioUrl: input.audioUrl,\n ...(input.thresholdDb !== undefined ? { thresholdDb: input.thresholdDb } : {}),\n ...(input.minSilenceMs !== undefined ? { minSilenceMs: input.minSilenceMs } : {}),\n ...(input.padMs !== undefined ? { padMs: input.padMs } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Measure how far apart the clocks of 2–6 recordings of one conversation are\n * (`POST /v1/audio-sync`), by cross-correlating their audio — keyless, one\n * ffmpeg decode per source. The finished job's `output_data.json` is an\n * {@link AudioSyncResult}. A malformed request (fewer than 2 or more than 6\n * sources, a repeated id, a `reference` that is not one of the ids) throws a\n * typed `NodaroError` (400, `code: \"validation_error\"`) before any credits\n * are reserved.\n */\n audioSync(input: AudioSyncInput): Promise<EditJobResult> {\n return this.client.request(\"POST\", \"/v1/audio-sync\", {\n body: {\n sources: input.sources.map((s) => ({ id: s.id, url: s.url })),\n ...(input.reference !== undefined ? { reference: input.reference } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Which camera each speaker is on, from the cameras' own microphones (`POST\n * /v1/speaker-map`), keyless. `output_data.json` is a `SpeakerMapResult`: pass\n * it to {@link cameraSwitch} as `speakerMapResult`. A malformed request throws\n * a `NodaroError` (400 `validation_error`; 422 `no_speakers` for a transcript\n * with no speaker labels) before any credits are reserved.\n */\n speakerMap(input: SpeakerMapInput): Promise<EditJobResult> {\n return this.client.request(\"POST\", \"/v1/speaker-map\", {\n body: {\n sources: input.sources.map((s) => ({ id: s.id, url: s.url, ...(s.kind ? { kind: s.kind } : {}) })),\n transcript: input.transcript,\n ...(input.offsets !== undefined ? { offsets: input.offsets } : {}),\n ...(input.masterSourceId !== undefined ? { masterSourceId: input.masterSourceId } : {}),\n ...(input.wideSourceId !== undefined ? { wideSourceId: input.wideSourceId } : {}),\n ...(input.marginDb !== undefined ? { marginDb: input.marginDb } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Render an edit decision list into a video or audio cut (`POST /v1/apply-edl`).\n * The EDL is validated at ingress — an unresolvable source or a picture-less\n * segment on a video edit throws a typed `NodaroError` (400, `code:\n * \"invalid_edl\"`) before any credits are reserved.\n */\n applyEdl(input: ApplyEdlInput): Promise<EditJobResult> {\n return this.client.request(\"POST\", \"/v1/apply-edl\", {\n body: {\n edl: input.edl,\n ...(input.sources !== undefined ? { sources: input.sources } : {}),\n ...(input.transcript !== undefined ? { transcript: input.transcript } : {}),\n ...(input.output !== undefined ? { output: input.output } : {}),\n ...(input.quality !== undefined ? { quality: input.quality } : {}),\n ...(input.crossfadeMs !== undefined ? { crossfadeMs: input.crossfadeMs } : {}),\n ...(input.clipKey !== undefined ? { clipKey: input.clipKey } : {}),\n ...(input.planBasis !== undefined ? { planBasis: input.planBasis } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Tighten Episode (`POST /v1/tighten-episode`): tighten a podcast recording\n * in one call — transcribe, cut the silences and filler, render, with\n * optional captions, music and framing. Answers the run's job to poll; its\n * `output_data` holds the episode. The run is priced as its steps at their own\n * rates plus the listed per-run fee. Quote it first with\n * {@link estimateTightenEpisode}.\n */\n tightenEpisode(input: TightenEpisodeInput, options?: UseCaseRequestOptions): Promise<TightenEpisodeJobResult> {\n return withUseCaseBody(() => tightenBody(input), (body) => this.client.request(\"POST\", \"/v1/tighten-episode\", { body, ...idempotencyHeaders(options) }))\n }\n\n /**\n * What a Tighten Episode run is estimated at (`POST /v1/tighten-episode/estimate`):\n * its steps at their own rates plus its per-run fee. Nothing is created or\n * charged. The estimate leans high: the render is priced at the recording's\n * full length, while the charge follows the minutes actually rendered.\n */\n estimateTightenEpisode(input: TightenEpisodeInput): Promise<{ data: TightenEpisodeEstimate }> {\n return withUseCaseBody(() => tightenBody(input), (body) => this.client.request(\"POST\", \"/v1/tighten-episode/estimate\", { body }))\n }\n\n /**\n * Chapters (`POST /v1/episode-chapters`): transcribe a recording and list its\n * chapters in one call. Answers the run's job to poll; the finished job's\n * `output_data.text` is the list as show notes (one `0:00 Title` line per\n * chapter; once a chapter starts at 1:00:00 or later, every line is\n * `H:MM:SS`), `output_data.json` the list itself (`{ startMs, title }[]`, the\n * same rows; the first starts at 0). A run that finds no chapters fails,\n * and its fee is refunded. Priced as its steps at their own rates plus the\n * listed per-run fee; quote it first with {@link estimateEpisodeChapters}.\n */\n episodeChapters(input: EpisodeChaptersInput, options?: UseCaseRequestOptions): Promise<UseCaseJobResult> {\n return withUseCaseBody(() => chaptersBody(input), (body) => this.client.request(\"POST\", \"/v1/episode-chapters\", { body, ...idempotencyHeaders(options) }))\n }\n\n /**\n * What a Chapters run is estimated at (`POST /v1/episode-chapters/estimate`):\n * its steps at their own rates plus its per-run fee. Nothing is created or\n * charged. A recording whose length cannot be read is estimated at the\n * 180-minute ceiling.\n */\n estimateEpisodeChapters(input: EpisodeChaptersInput): Promise<{ data: UseCaseEstimate }> {\n return withUseCaseBody(() => chaptersBody(input), (body) => this.client.request(\"POST\", \"/v1/episode-chapters/estimate\", { body }))\n }\n\n /**\n * Trailer (`POST /v1/episode-trailer`): cut a 20–40 s trailer of a recording\n * and deliver it in each chosen format (padded, never cropped), optionally\n * after an intro card, in one call. The finished job's `output_data.formats`\n * is `{ format, url }[]` in format order, the first also `output_data.videoUrl`;\n * a format that failed is named in `output_data.failedFormats` (the run keeps\n * the others). With `reviewBeforeRender` the run stops at a preview\n * (`videoUrl`, no formats yet). Priced as its steps at their own rates plus\n * the listed per-run fee; quote it first with {@link estimateEpisodeTrailer}.\n */\n episodeTrailer(input: EpisodeTrailerInput, options?: UseCaseRequestOptions): Promise<UseCaseJobResult> {\n return withUseCaseBody(() => trailerBody(input), (body) => this.client.request(\"POST\", \"/v1/episode-trailer\", { body, ...idempotencyHeaders(options) }))\n }\n\n /**\n * What a Trailer run is estimated at (`POST /v1/episode-trailer/estimate`):\n * its steps at their own rates plus its per-run fee. Nothing is created or\n * charged. The trailer is quoted at 40 seconds, the longest trailer the\n * plan cuts; a Render final is quoted on the trailer the run cut (with the\n * review's edits), plus the intro card.\n */\n estimateEpisodeTrailer(input: EpisodeTrailerInput): Promise<{ data: UseCaseEstimate }> {\n return withUseCaseBody(() => trailerBody(input), (body) => this.client.request(\"POST\", \"/v1/episode-trailer/estimate\", { body }))\n }\n\n /**\n * Clip Pack (`POST /v1/clip-pack`): cut a recording into a pack of short\n * clips in one call — the plan finds the best moments (`count`, default 8,\n * of about `targetDurationSec`, default 60), each is rendered (framed 9:16\n * with the speakers stacked by default; `framing: null` keeps the\n * recording's shape) and captioned. An audio recording makes audio clips.\n * The finished job's `output_data.clips` is `{ url, title?, hook?, clipKey,\n * thumbnailUrl?, captionsFailed? }[]` in plan order, the first also\n * `output_data.videoUrl` (`audioUrl` for audio clips). Every clip is tried:\n * one that cannot be rendered is skipped, not charged and counted on\n * `failedClips` (the pack keeps the others and its fee); a clip whose\n * captions failed comes uncaptioned (`captionsFailed`, counted on\n * `failedCaptions`). When no clip renders the run fails and its fee is\n * refunded. With `reviewBeforeRender` the run stops at previews; Render\n * final ({@link continueUseCase}) renders only the clips the edit keeps.\n * Priced as its steps at their own rates plus the listed per-run fee;\n * quote it first with {@link estimateClipPack}.\n */\n clipPack(input: ClipPackInput, options?: UseCaseRequestOptions): Promise<UseCaseJobResult> {\n return withUseCaseBody(() => clipPackBody(input), (body) => this.client.request(\"POST\", \"/v1/clip-pack\", { body, ...idempotencyHeaders(options) }))\n }\n\n /**\n * What a Clip Pack run is estimated at (`POST /v1/clip-pack/estimate`): its\n * steps at their own rates plus its per-run fee. Nothing is created or\n * charged. Each clip is quoted at twice the target length (the plan may cut\n * a clip longer than asked); the charge follows each clip's real length.\n */\n estimateClipPack(input: ClipPackInput): Promise<{ data: UseCaseEstimate }> {\n return withUseCaseBody(() => clipPackBody(input), (body) => this.client.request(\"POST\", \"/v1/clip-pack/estimate\", { body }))\n }\n\n /**\n * Speaker Layout (`POST /v1/speaker-layout`): frame a whole recording by\n * speaker in one call — the same length, nothing cut. One recording: each\n * speaker framed in turn; several recordings of one conversation: lined up,\n * each speaker shown on their own camera. The finished job's\n * `output_data.videoUrl` is the framed video, `output_data.json` the edit\n * Speaker View drew. With `reviewBeforeRender` the run stops at a preview;\n * {@link continueUseCase} (`mode: \"render-final\"`, no `editedEdl`) renders\n * it at full quality. Priced as its steps at their own rates plus the listed\n * per-run fee; quote it first with {@link estimateSpeakerLayout}.\n */\n speakerLayout(input: SpeakerLayoutInput, options?: UseCaseRequestOptions): Promise<UseCaseJobResult> {\n return withUseCaseBody(() => speakerLayoutBody(input), (body) => this.client.request(\"POST\", \"/v1/speaker-layout\", { body, ...idempotencyHeaders(options) }))\n }\n\n /**\n * What a Speaker Layout run is estimated at (`POST /v1/speaker-layout/estimate`):\n * its steps at their own rates plus its per-run fee. Nothing is created or\n * charged. A recording whose length cannot be read is estimated at the\n * 180-minute ceiling.\n */\n estimateSpeakerLayout(input: SpeakerLayoutInput): Promise<{ data: UseCaseEstimate }> {\n return withUseCaseBody(() => speakerLayoutBody(input), (body) => this.client.request(\"POST\", \"/v1/speaker-layout/estimate\", { body }))\n }\n\n /**\n * Continue a use-case run as a new job (`POST /v1/<type>/continue`, the\n * run's own type: `input.nodeType`, else the type the job records, read with\n * `GET /v1/jobs/:id`; when that read cannot tell, this rejects with a\n * `NodaroError` coded `use_case_type_unknown` — pass `nodeType` then):\n * `\"from-failed\"` keeps the steps that finished and runs the rest (the fee\n * is held again; the failed run's was refunded);\n * `\"render-final\"` renders the full-quality result after a review-on preview,\n * with the preview's settings and no fee. A refusal that names another job\n * (`already_running`, `continuation_superseded`,\n * `render_final_already_rendered`) throws a `ContinuationRefusedError`\n * carrying that `jobId`.\n */\n async continueUseCase(input: UseCaseContinueInput, options?: UseCaseRequestOptions): Promise<UseCaseJobResult> {\n if (input.nodeType !== undefined && !isUseCaseNodeType(input.nodeType)) {\n throw new NodaroError(\n `continueUseCase: nodeType \"${String(input.nodeType)}\" is not a use-case node type (${USE_CASE_NODE_TYPES.join(\", \")})`,\n \"invalid_node_type\",\n 400,\n )\n }\n const type = input.nodeType ?? (await this.runTypeOf(input.jobId))\n return this.client.request(\"POST\", continuePathOf(type), {\n body: { jobId: input.jobId, mode: input.mode, ...(input.editedEdl !== undefined ? { editedEdl: input.editedEdl } : {}) },\n ...idempotencyHeaders(options),\n })\n }\n\n /**\n * The use-case type a run records (`input_data.type`, else its `job_type`).\n * When the key lacks the `jobs:read` scope (403 naming that scope) or the job\n * names no use-case type, the type cannot be read: this rejects with a\n * `NodaroError` (`use_case_type_unknown`, 400) asking for `nodeType`, and\n * nothing is posted (decided 2026-10-18: no route is guessed for the run).\n * Any other failure of the read, any other 403 included, is thrown as is.\n */\n private async runTypeOf(jobId: string): Promise<UseCaseNodeType> {\n const unknown = () =>\n new NodaroError(\"continueUseCase: the run's node type cannot be read — pass nodeType\", \"use_case_type_unknown\", 400)\n let row: { job_type?: unknown; input_data?: unknown } | undefined\n try {\n row = (await this.client.request<{ data?: { job_type?: unknown; input_data?: unknown } }>(\"GET\", `/v1/jobs/${encodeURIComponent(jobId)}`)).data\n } catch (err) {\n if (err instanceof ForbiddenError && err.missingScope === \"jobs:read\") throw unknown()\n throw err\n }\n const input = row?.input_data\n const recorded = input && typeof input === \"object\" && !Array.isArray(input) ? (input as { type?: unknown }).type : undefined\n const type = typeof recorded === \"string\" && recorded.length > 0 ? recorded : row?.job_type\n if (!isUseCaseNodeType(type)) throw unknown()\n return type\n }\n\n /**\n * Plan a transcript-driven cut (`POST /v1/edit-plan`). Reads a timed\n * transcript (plus optional silence ranges) and the media sources, and plans\n * the edit. The finished job's `output_data` holds the plan: an `Edl`\n * (`\"tighten\"` or `\"trailer\"`), an {@link EdlClipSet} (`\"clips\"`), or a\n * {@link ChapterSet} (`\"chapters\"`) — normalize it with {@link unwrapEditPlanOutput}.\n *\n * On a self-hosted install the request relays to nodaro.ai and needs the\n * install connected (a 503 `code: \"nodaro_connection_required\"` otherwise);\n * on nodaro.ai it runs directly.\n */\n editPlan(input: EditPlanInput): Promise<EditJobResult> {\n // The same pre-dispatch check the canvas and MCP run (B4): the server never\n // sees `offsets` — they are written onto the sources here.\n const planned = resolveEditPlanSources(input.sources, {\n offsets: input.offsets,\n transcriptSourceId: input.transcriptSourceId,\n })\n if (!planned.ok) {\n const message = planned.issues.map((issue) => describeAudioSyncOffsetIssue(issue)).join(\"; \")\n return Promise.reject(new NodaroError(`editPlan: ${message}`, \"edit_plan_sources\", 400))\n }\n const transcript = planned.transcriptSourceId\n ? { ...input.transcript, sourceId: planned.transcriptSourceId }\n : input.transcript\n return this.client.request(\"POST\", \"/v1/edit-plan\", {\n body: {\n mode: input.mode,\n planTier: input.planTier,\n transcript,\n sources: planned.sources,\n ...(input.silence !== undefined ? { silence: input.silence } : {}),\n ...(input.instructions !== undefined ? { instructions: input.instructions } : {}),\n ...(input.styleGuide !== undefined ? { styleGuide: input.styleGuide } : {}),\n ...(input.count !== undefined ? { count: input.count } : {}),\n ...(input.targetDurationSec !== undefined ? { targetDurationSec: input.targetDurationSec } : {}),\n ...(input.targetAspect !== undefined ? { targetAspect: input.targetAspect } : {}),\n ...(input.platform !== undefined ? { platform: input.platform } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Camera Switch (podcast B5): choose which camera shows each cut of `edl`\n * by who is speaking — the sound never changes. Cloud edition; a flat\n * price. The finished job's `output_data.json` is the switched EDL (feed it\n * to {@link applyEdl}) and `output_data.transcript` the transcript with\n * `speakerNames` applied. A transcript with no speaker labels rejects with\n * a {@link NodaroError} (`code: \"no_speakers\"`) before any request or charge.\n */\n cameraSwitch(input: CameraSwitchInput): Promise<EditJobResult> {\n if (transcriptSpeakerLabels(input.transcript).length === 0) {\n return Promise.reject(new NodaroError(\n \"cameraSwitch: the transcript has no speaker labels — transcribe with speaker detection on\",\n \"no_speakers\",\n 422,\n ))\n }\n const result = input.speakerMapResult\n if (result !== undefined && !speakerMapResultOf(result)) return Promise.reject(new NodaroError(\"cameraSwitch: speakerMapResult is not a Speaker Map result — pass that job's output_data.json\", \"not_a_speaker_map\", 400))\n const speakerMap = result !== undefined ? cameraSwitchSpeakerMap({ speakerMap: input.speakerMap }, input.edl, input.transcript, { speakerMap: result }) : input.speakerMap\n return this.client.request(\"POST\", \"/v1/camera-switch\", {\n body: {\n edl: input.edl,\n transcript: input.transcript,\n ...(speakerMap !== undefined ? { speakerMap } : {}),\n ...(input.speakerNames !== undefined ? { speakerNames: input.speakerNames } : {}),\n ...(input.minShotMs !== undefined ? { minShotMs: input.minShotMs } : {}),\n ...(input.leadMs !== undefined ? { leadMs: input.leadMs } : {}),\n ...(input.maxShotMs !== undefined ? { maxShotMs: input.maxShotMs } : {}),\n ...(input.wideEvery !== undefined ? { wideEvery: input.wideEvery } : {}),\n ...(input.layoutHints !== undefined ? { layoutHints: input.layoutHints } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Remap a transcript through an EDL — a PURE client-side transform (NO\n * request). Returns a new transcript whose word (and segment) timings are on\n * the EDL's rendered output clock, dropping words that fall in cut regions and\n * clipping straddlers. Runs `@nodaro/shared`'s canonical\n * `remapTranscriptThroughEdl`, the same remap `applyEdl` performs server-side.\n */\n remapTranscript(edl: Edl, transcript: Transcript): Transcript {\n return remapTranscriptThroughEdl(edl, transcript)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/resources/edit-use-case-inputs.ts","../src/resources/edit.ts"],"names":["isUseCaseNodeType","NodaroError","USE_CASE_NODE_TYPES","ForbiddenError","resolveEditPlanSources","describeAudioSyncO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,EAClD;AACF","file":"chunk-7XOK277W.cjs","sourcesContent":["/**\n * The inputs of the podcast use-case runs on the `edit` resource (Tighten\n * Episode, Chapters, Trailer, Clip Pack, Speaker Layout) and the request body each one sends.\n * Split from `edit.ts`, which holds the methods, the type list and the\n * continue routes; every name here is re-exported from there.\n */\nimport type { EditPlanTier, EdlTargetAspect, SpeakerEmphasisStyle, SpeakerSwitchId } from \"@nodaro/shared/edl\"\nimport type { CaptionStyle } from \"@nodaro/shared/captions\"\n\n/**\n * The recordings of a use-case run: one (`mediaUrl`), or the recordings of one\n * conversation (`mediaUrls`, in order — the cameras; one may be sound only),\n * an optional Master audio and the Cameras settings. Pass `mediaUrl` or\n * `mediaUrls`, not both.\n *\n * Several recordings or a Master audio need Speaker Map, which tells who is on\n * which camera: where it is not available to you (not yet on nodaro.ai) the\n * request is refused `403 node_not_available` — send one recording.\n */\nexport interface UseCaseRecordingsInput {\n /** The recording — a video or audio URL, up to 3 hours. */\n mediaUrl?: string\n /**\n * Instead of `mediaUrl`: the recordings of one conversation, in order — up\n * to six in all with the Master audio; without one, two or more cameras keep\n * a place for the sound, so up to five. With two or more the run lines them\n * up, works out who is on which camera and cuts to whoever is talking.\n */\n mediaUrls?: string[]\n /** The mixer or recorder track: the episode's sound and the clock the recordings are lined up to. */\n masterAudioUrl?: string\n /** With several recordings or a Master audio: the Cameras settings (ignored with one recording and no Master audio). */\n cameras?: {\n /** Which recording (1-based) is the wide shot, shown when a speaker has no camera of their own; `null` for none. */\n wide?: number | null\n /** The recordings already share one clock: skip lining them up. */\n synced?: boolean\n /** Who is on which camera: speaker number (`\"1\"` = the first voice heard) → recording number, 0 = the wide shot. Overrides the automatic map. */\n speakerCameras?: Record<string, number>\n }\n}\n\n/**\n * Input for {@link EditResource.tightenEpisode} and\n * {@link EditResource.estimateTightenEpisode}: the recording (or the\n * recordings of one conversation, see {@link UseCaseRecordingsInput}) in, the\n * tightened episode out. Only the recording is required; every other field\n * left out takes the node's default.\n */\nexport interface TightenEpisodeInput extends UseCaseRecordingsInput {\n /** Optional music bed, ducked under the voice and ending with the episode. */\n musicUrl?: string\n /** `\"video\"` or `\"audio\"`; an audio recording always makes an audio episode. */\n output?: \"video\" | \"audio\"\n /**\n * Frame a video episode with Speaker View: an output aspect and a layout,\n * over automatic boxes on the speakers on screen. A layout the aspect does\n * not draw is snapped to one it does. `null` or absent: no framing.\n */\n framing?: {\n aspect: EdlTargetAspect\n layout: \"auto\" | \"single\" | \"side-by-side\" | \"stacked\" | \"grid\" | \"pip\"\n } | null\n /**\n * With a framing, how it follows the speakers: `\"static\"` (the default)\n * splits the frame evenly by speaker; `\"tracking\"` follows faces with\n * Speaker Frames (charged per started block of 1,000 sampled frames; a\n * camera shared by several speakers keeps the even split until faces are\n * named; refused 403 where Speaker Frames is not available to the caller);\n * `\"auto\"` follows faces while Speaker Frames is available to the caller,\n * else the even split. Ignored without a framing.\n */\n framingSource?: \"auto\" | \"static\" | \"tracking\"\n /** Captions on a video episode (on by default). */\n captions?: boolean\n /** The captions' look. */\n captionStyle?: CaptionStyle\n /**\n * Stop at a quick preview for a person to review; render the full-quality\n * episode afterwards with {@link EditResource.continueUseCase}\n * (`mode: \"render-final\"`).\n */\n reviewBeforeRender?: boolean\n /** The planner's tier. */\n planTier?: EditPlanTier\n /** Editing instructions for the planner (up to 4 000 characters). */\n instructions?: string\n /** A style guide for the planner (up to 4 000 characters). */\n styleGuide?: string\n /** How far the music dips under the voice, 0–100 (default 75). */\n musicDuckAmount?: number\n}\n\n/**\n * Input for {@link EditResource.episodeChapters} and\n * {@link EditResource.estimateEpisodeChapters}: one recording in, its chapters\n * out. Only `mediaUrl` is required; every other field left out takes the\n * node's default.\n */\nexport interface EpisodeChaptersInput {\n /** The recording — a video or audio URL, up to 3 hours. */\n mediaUrl: string\n /** The planner's tier (default `\"economy\"`). */\n planTier?: EditPlanTier\n /** Instructions for the chapters, e.g. \"5 to 8 chapters\" (up to 4 000 characters). */\n instructions?: string\n /** A style guide for the chapter titles (up to 4 000 characters). */\n styleGuide?: string\n}\n\n/** The formats a Trailer is delivered in, in delivery order (16:9 is a 1920×1080 landscape). */\nexport const TRAILER_FORMATS = [\"9:16\", \"1:1\", \"4:5\", \"16:9\"] as const\n/** One Trailer format (see {@link TRAILER_FORMATS}). */\nexport type TrailerFormat = (typeof TRAILER_FORMATS)[number]\n\n/**\n * Input for {@link EditResource.episodeTrailer} and\n * {@link EditResource.estimateEpisodeTrailer}: one video recording (or the\n * recordings of one conversation, see {@link UseCaseRecordingsInput}) in, a\n * 20–40 s trailer out in each chosen format. Only the recording is required.\n */\nexport interface EpisodeTrailerInput extends UseCaseRecordingsInput {\n /** The recording — a video URL, up to 3 hours (a run with no picture is refused). Or `mediaUrls`. */\n mediaUrl?: string\n /** An optional intro card: a short video (15 s at most) played before the trailer. */\n introCardUrl?: string\n /** The formats to deliver, padded, never cropped (default `[\"9:16\", \"1:1\", \"4:5\"]`; an empty list is refused). */\n formats?: TrailerFormat[]\n /** Stop at a preview of the trailer; render every format with {@link EditResource.continueUseCase} (`mode: \"render-final\"`). */\n reviewBeforeRender?: boolean\n /** The planner's tier (default `\"standard\"`). */\n planTier?: EditPlanTier\n /** Instructions for the trailer (up to 4 000 characters). */\n instructions?: string\n /** A style guide for the planner (up to 4 000 characters). */\n styleGuide?: string\n}\n\n/** The shortest and longest clip a Clip Pack asks the plan for, in seconds. */\nexport const CLIP_PACK_MIN_TARGET_SEC = 5\nexport const CLIP_PACK_MAX_TARGET_SEC = 180\n\n/**\n * A Clip Pack emphasis: `\"none\"`, or one or more of `\"scale\"`, `\"border\"` and\n * `\"dim\"` joined with `\"+\"` (each once — the route refuses a repeat).\n */\nexport type ClipPackEmphasis = SpeakerEmphasisStyle | `${Exclude<SpeakerEmphasisStyle, \"none\">}+${string}`\n\n/**\n * Input for {@link EditResource.clipPack} and\n * {@link EditResource.estimateClipPack}: the recording (or the recordings of\n * one conversation, see {@link UseCaseRecordingsInput} — each clip then cuts\n * to whoever is talking) in, a pack of short clips out. An audio recording\n * makes audio clips (no framing, no captions). Only the recording is\n * required; every other field left out takes the node's default.\n */\nexport interface ClipPackInput extends UseCaseRecordingsInput {\n /** How many clips to find, 1–50 (default 8). The plan may find fewer. */\n count?: number\n /** Each clip's target length in seconds, {@link CLIP_PACK_MIN_TARGET_SEC}–{@link CLIP_PACK_MAX_TARGET_SEC} (default 60). */\n targetDurationSec?: number\n /**\n * Frame each video clip with Speaker View on automatic boxes over the\n * episode's speakers: the shape, and optionally the layout (default\n * `\"stacked\"`; one the shape does not draw is snapped), the switch at each\n * speaker change (default `\"pan\"`) and the emphasis (default `\"scale\"`;\n * `\"none\"`, or `\"scale\"`, `\"border\"` and `\"dim\"` joined with `\"+\"`). Left\n * out: 9:16, stacked, pan, scale. `null`: no framing (the recording's shape).\n */\n framing?: {\n aspect: EdlTargetAspect\n layout?: \"auto\" | \"single\" | \"side-by-side\" | \"stacked\" | \"grid\" | \"pip\"\n switchType?: SpeakerSwitchId\n emphasisStyle?: ClipPackEmphasis\n } | null\n /**\n * With a framing, how it follows the speakers: `\"static\"` splits the frame\n * evenly by speaker (what a request that leaves this out gets); `\"tracking\"`\n * runs Speaker Frames once over the whole pack to follow faces (charged per\n * started block of 1,000 sampled frames; refused 403 where Speaker Frames is\n * not available to the caller); `\"auto\"` follows faces while Speaker Frames\n * is available to the caller, else the even split. Ignored without a framing.\n */\n framingSource?: \"auto\" | \"static\" | \"tracking\"\n /** Caption each video clip (on by default). */\n captions?: boolean\n /** The captions' look (default `\"karaoke\"`). */\n captionStyle?: CaptionStyle\n /**\n * Stop at quick previews of the clips for a person to review; render the\n * kept clips at full quality with {@link EditResource.continueUseCase}\n * (`mode: \"render-final\"`, an `editedEdl` that keeps or drops clips).\n */\n reviewBeforeRender?: boolean\n /** The planner's tier (default `\"standard\"`). */\n planTier?: EditPlanTier\n /** Instructions for picking the clips (up to 4 000 characters). */\n instructions?: string\n /** A style guide for the planner (up to 4 000 characters). */\n styleGuide?: string\n}\n\n/**\n * Input for {@link EditResource.speakerLayout} and\n * {@link EditResource.estimateSpeakerLayout}: one video recording (or the\n * recordings of one conversation, see {@link UseCaseRecordingsInput}) in, the\n * whole recording framed by speaker out — the same length, nothing cut. Only\n * the recording is required; every other field left out takes the node's\n * default.\n */\nexport interface SpeakerLayoutInput extends UseCaseRecordingsInput {\n /** The recording — a video URL, up to 3 hours (an audio-only recording is refused). Or `mediaUrls`. */\n mediaUrl?: string\n /** The video's shape (default `\"9:16\"`). With one recording, a video already as narrow as the shape (or narrower) is refused `400 media_shape`. */\n targetAspect?: EdlTargetAspect\n /** How the speakers are laid out (default `\"stacked\"`; one the shape does not draw is snapped to one it does). */\n layout?: \"auto\" | \"single\" | \"side-by-side\" | \"stacked\" | \"grid\" | \"pip\"\n /** The switch at each speaker change (default `\"cut\"`). */\n switchType?: SpeakerSwitchId\n /** How the speaker talking is emphasised (default `\"scale\"`): `\"none\"`, or `\"scale\"`, `\"border\"` and `\"dim\"` joined with `\"+\"`. */\n emphasisStyle?: ClipPackEmphasis\n /**\n * How the speakers are followed: `\"auto\"` (the default) follows faces with\n * Speaker Frames while it is available to the caller, else splits the frame\n * evenly; `\"static\"` splits the frame evenly by speaker; `\"tracking\"`\n * follows faces (charged per started block of 1,000 sampled frames;\n * refused 403 where Speaker Frames is not available to the caller). Faces\n * aren't named after a speaker yet, so a camera shared by several speakers\n * keeps the even split.\n */\n framingSource?: \"auto\" | \"static\" | \"tracking\"\n /**\n * Stop at a quick preview for a person to review; render it at full\n * quality with {@link EditResource.continueUseCase}\n * (`mode: \"render-final\"`, no `editedEdl`: the layout has no cut to change).\n */\n reviewBeforeRender?: boolean\n}\n\n/**\n * The body's recordings (`mediaUrls`, then `masterAudioUrl` and `cameras` when\n * given), and the rest of the input as it came: the one mapper every use-case\n * body goes through. Throws before any request when the input names both\n * `mediaUrl` and `mediaUrls`, or neither.\n */\nfunction withRecordings<T extends UseCaseRecordingsInput>(input: T): Record<string, unknown> {\n const { mediaUrl, mediaUrls, masterAudioUrl, cameras, ...rest } = input\n if (mediaUrl !== undefined && mediaUrls !== undefined) throw new TypeError(\"pass mediaUrl or mediaUrls, not both\")\n const recordings = mediaUrls ?? (mediaUrl !== undefined ? [mediaUrl] : undefined)\n if (!recordings) throw new TypeError(\"pass mediaUrl or mediaUrls\")\n return {\n mediaUrls: [...recordings],\n ...(masterAudioUrl !== undefined ? { masterAudioUrl } : {}),\n ...(cameras !== undefined ? { cameras } : {}),\n ...Object.fromEntries(Object.entries(rest).filter(([, v]) => v !== undefined)),\n }\n}\n\n/**\n * Sends `send` the body `build` makes, or rejects (never throws) with the\n * error of an input the body cannot take — before any request, as every input\n * check of the `edit` resource rejects.\n */\nexport function withUseCaseBody<T>(build: () => Record<string, unknown>, send: (body: Record<string, unknown>) => Promise<T>): Promise<T> {\n let body: Record<string, unknown>\n try {\n body = build()\n } catch (err) {\n return Promise.reject(err)\n }\n return send(body)\n}\n\nexport function tightenBody(input: TightenEpisodeInput): Record<string, unknown> {\n return withRecordings(input)\n}\n\nexport function chaptersBody(input: EpisodeChaptersInput): Record<string, unknown> {\n return withRecordings({\n mediaUrl: input.mediaUrl,\n ...(input.planTier !== undefined ? { planTier: input.planTier } : {}),\n ...(input.instructions !== undefined ? { instructions: input.instructions } : {}),\n ...(input.styleGuide !== undefined ? { styleGuide: input.styleGuide } : {}),\n })\n}\n\nexport function trailerBody(input: EpisodeTrailerInput): Record<string, unknown> {\n return withRecordings({\n mediaUrl: input.mediaUrl,\n mediaUrls: input.mediaUrls,\n masterAudioUrl: input.masterAudioUrl,\n cameras: input.cameras,\n ...(input.introCardUrl !== undefined ? { introCardUrl: input.introCardUrl } : {}),\n // An empty list is sent as is: the route refuses it (at least one format).\n ...(input.formats !== undefined ? { formats: input.formats } : {}),\n ...(input.reviewBeforeRender !== undefined ? { reviewBeforeRender: input.reviewBeforeRender } : {}),\n ...(input.planTier !== undefined ? { planTier: input.planTier } : {}),\n ...(input.instructions !== undefined ? { instructions: input.instructions } : {}),\n ...(input.styleGuide !== undefined ? { styleGuide: input.styleGuide } : {}),\n })\n}\n\n/** Clip Pack's body: what the caller set, `framing: null` included (no framing). */\nexport function clipPackBody(input: ClipPackInput): Record<string, unknown> {\n return withRecordings(input)\n}\n\n/** Speaker Layout's body: the recordings, then what the caller set. */\nexport function speakerLayoutBody(input: SpeakerLayoutInput): Record<string, unknown> {\n return withRecordings(input)\n}\n","import type { NodaroClientCore } from \"../core.js\"\nimport { ForbiddenError, NodaroError } from \"../errors.js\"\nimport {\n remapTranscriptThroughEdl,\n unwrapEditPlanOutput,\n resolveEditPlanSources,\n describeAudioSyncOffsetIssue,\n transcriptSpeakerLabels,\n cameraSwitchSpeakerMap, speakerMapResultOf, type SpeakerMapResult,\n type Edl,\n type Transcript,\n type EditPlanMode,\n type EditPlanTier,\n type EdlClipSet,\n type ChapterSet,\n type EdlTargetAspect\n} from \"@nodaro/shared/edl\"\nimport { USE_CASE_NODE_TYPES, isUseCaseNodeType, type UseCaseNodeType } from \"@nodaro/shared/nodes\"\nimport type { SpeakerMapInput } from \"./speaker-map-inputs.js\"\nimport {\n chaptersBody,\n clipPackBody,\n speakerLayoutBody,\n tightenBody,\n trailerBody,\n withUseCaseBody,\n type ClipPackInput,\n type EpisodeChaptersInput,\n type EpisodeTrailerInput,\n type SpeakerLayoutInput,\n type TightenEpisodeInput,\n} from \"./edit-use-case-inputs.js\"\n\nexport { CLIP_PACK_MAX_TARGET_SEC, CLIP_PACK_MIN_TARGET_SEC, TRAILER_FORMATS } from \"./edit-use-case-inputs.js\"\nexport type { ClipPackEmphasis, ClipPackInput, EpisodeChaptersInput, EpisodeTrailerInput, SpeakerLayoutInput, TightenEpisodeInput, TrailerFormat, UseCaseRecordingsInput } from \"./edit-use-case-inputs.js\"\n\n// Re-export the canonical EDL / transcript vocabulary from `@nodaro/shared`\n// (single source of truth — the shapes live at `packages/shared/src/edl.ts`).\n// `@nodaro/shared` is already a hard dep of this package, so there is no\n// bundle-size cost to importing from it, and an integration builds requests and\n// reads results with one dependency. `EdlClipSet` / `ChapterSet` are the raw\n// `output_data` shapes of the `clips` / `chapters` modes, and\n// `unwrapEditPlanOutput` is the sanctioned way to normalize any edit-plan job's\n// `output_data` (it also strips the relay's `viaNodaroCloud` marker).\nexport type { Edl, Transcript, EditPlanMode, EditPlanTier, EdlClipSet, ChapterSet }\nexport { unwrapEditPlanOutput }\n\n/**\n * A silence-detect job's `output_data.json` — the value to pass as\n * {@link EditPlanInput.silence}. It is NOT what {@link EditResource.silenceDetect}\n * returns (that is `{ jobId }`); fetch the finished job and read its\n * `output_data.json`. The planner reads the `ranges` array — an input without\n * one is silently ignored, so pass this whole object.\n */\nexport interface SilenceRanges {\n /** Wire version of the payload. */\n version?: number\n /** Silence spans on the source clock, in ms. */\n ranges: ReadonlyArray<{ startMs: number; endMs: number }>\n /** Total source duration, in ms. */\n durationMs?: number\n}\n\n/** Every editorial route answers with the queued job to poll. */\nexport interface EditJobResult {\n /** The queued job id — follow it via `client.jobs.getStatus(jobId)`. */\n jobId: string\n}\n\nexport interface SilenceDetectInput {\n /**\n * An audio OR video source. A single ffmpeg `silencedetect` pass runs over the\n * source's audio proxy either way — no provider key required.\n */\n audioUrl: string\n /** dBFS threshold, always ≤ 0. Default -35 (a good podcast default). */\n thresholdDb?: number\n /** Minimum silence length to report, in ms. Default 700. */\n minSilenceMs?: number\n /** Padding kept around speech, in ms — shrinks each reported range inward. Default 120. */\n padMs?: number\n /**\n * Optionally associate this run with a workflow execution (display only — it\n * ties the standalone job back to a workflow for the execution history).\n */\n workflowId?: string\n}\n\n/** One recording for {@link EditResource.audioSync}. */\nexport interface AudioSyncSource {\n /**\n * Your id for this recording (1–200 chars, unique within the request) —\n * echoed back as its offset's `sourceId`. Use the id your EDL gives the same\n * recording (`EdlSource.id`) and the result folds straight into it.\n */\n id: string\n /** An audio OR video URL — the audio track is read either way. */\n url: string\n}\n\nexport interface AudioSyncInput {\n /** The 2–6 recordings of one conversation to line up (camera files and/or a master mic). */\n sources: AudioSyncSource[]\n /**\n * The id of the source every offset is measured against (its own offset is\n * 0). Must be one of `sources`' ids; default: the first source.\n */\n reference?: string\n /** Optionally associate this run with a workflow execution (display only). */\n workflowId?: string\n}\n\n/** One recording's measured clock offset in an {@link AudioSyncResult}. */\nexport interface AudioSyncOffset {\n /** The recording's `id` from the request. */\n sourceId: string\n /**\n * Where this recording sits on the reference's clock, in integer ms:\n * `referenceMs = sourceMs + offsetMs` (the EDL's D19 sign — the value\n * `EdlSource.offsetMs` takes when the reference is the master).\n */\n offsetMs: number\n /** 0–1. Below 0.5 a `notes` line asks for a check by ear. */\n confidence: number\n /**\n * Measured clock drift against the reference, in ms gained per hour; `null`\n * when the shared stretch was too short to measure it. Drift is reported,\n * never corrected — the offset is taken at the middle of the overlap.\n */\n driftMsPerHour: number | null\n}\n\n/**\n * An audio-sync job's `output_data.json`. It is NOT what\n * {@link EditResource.audioSync} returns (that is `{ jobId }`); fetch the\n * finished job and read its `output_data.json`.\n */\nexport interface AudioSyncResult {\n /** Wire version of the payload. */\n version: number\n /** The source every offset is measured against (its own offset is 0). */\n reference: string\n offsets: AudioSyncOffset[]\n /** Human-readable warnings: low confidence, measured drift, no shared sound. */\n notes: string[]\n}\n\nexport interface ApplyEdlInput {\n /** The edit decision list to render. Media resolves from each `edl.sources[i].url`. */\n edl: Edl\n /**\n * Optional media-URL overrides for `edl.sources[i].url`, POSITIONAL in this\n * array's order. Each URL is SSRF-guarded server-side like any media the\n * platform fetches.\n */\n sources?: string[]\n /**\n * Optional transcript to remap through the cut. The rendered job returns the\n * remapped transcript on its `json` output. A word-level multi-hour transcript\n * is several MB — if you only need the re-timed transcript (not a render), use\n * {@link EditResource.remapTranscript} locally instead of sending it here.\n */\n transcript?: Transcript\n /** Render a full video (default) or an audio-only cut. */\n output?: \"video\" | \"audio\"\n /** Fast proxy draft or the final render. Default \"final\". */\n quality?: \"proxy\" | \"final\"\n /**\n * Default crossfade (ms) on boundaries with no explicit transition; 0 = hard\n * cuts. Per-boundary clamped to the ffmpeg-xfade limit server-side. Default 0.\n */\n crossfadeMs?: number\n /**\n * The plan clip this render cuts — `edlSpanKey(clip)` from `@nodaro/shared`\n * (`\"<first inMs>-<last outMs>\"`). The job's result carries it back as\n * `output_data.clipKey`, so renders of a clip set can be matched to their\n * clips. Omit for a render of no plan clip.\n */\n clipKey?: string\n /**\n * The plan value this render cuts — `renderReadBasis(value)` from\n * `@nodaro/shared` (16 lowercase hex digits), where `value` is the Edit\n * Plan's Tighten EDL with any review applied, or the clip this render cuts.\n * The job's result carries it back as `output_data.planBasis`, so a take can\n * be told apart from one cut from an earlier plan. Send it only when the EDL\n * you send IS that value (not one an intermediate step re-cut from an older\n * plan); omit it otherwise. The result's `output_data.renderBasis` (the\n * render's own settings and sources) is stamped by the server.\n */\n planBasis?: string\n /** Optionally associate this run with a workflow execution (display only). */\n workflowId?: string\n}\n\n/**\n * One media source for an edit-plan run. Mirrors the shape the workflow engine\n * sends: a stable `id` (adopted verbatim as the plan's `EdlSource` id), the\n * media `url`, and the `kind`, plus optional per-source annotations the planner\n * honors.\n */\nexport interface EditPlanSource {\n /** Stable id for this source — becomes the `EdlSource` id in the returned plan. */\n id: string\n /** The source's media URL (SSRF-guarded server-side). */\n url: string\n /** This source's medium. */\n kind: \"video\" | \"audio\"\n /** Role annotation. `\"master-audio\"` marks the clock the plan is reserved on. */\n role?: \"master-audio\" | \"camera\" | \"wide\" | \"screen\"\n /** Speaker labels present in this source. */\n speakers?: string[]\n /**\n * This source's origin on the master clock (masterMs = sourceMs + offsetMs).\n * Set by hand, it wins over a measured offset from `offsets`.\n */\n offsetMs?: number\n}\n\nexport interface EditPlanInput {\n /**\n * Planning mode. The finished job's `output_data` carries the plan — read it\n * with {@link unwrapEditPlanOutput}, which also strips the relay's\n * `viaNodaroCloud` marker:\n * - `\"tighten\"` → an `Edl`.\n * - `\"clips\"` → an {@link EdlClipSet} (`{ version, clips: Edl[] }`);\n * `unwrapEditPlanOutput` returns the bare `Edl[]`.\n * - `\"chapters\"` → a {@link ChapterSet} (`{ version, chapters: [...] }`).\n * - `\"trailer\"` → an `Edl` (one short teaser cut from the strongest moments).\n */\n mode: EditPlanMode\n /** Reasoning tier — affects plan quality AND the credit bucket. */\n planTier: EditPlanTier\n /** The timed transcript driving the plan. */\n transcript: Transcript\n /**\n * Optional detected silence ranges. Pass the silence-detect JOB'S RESULT —\n * `getStatus(jobId).data.output_data.json` (a {@link SilenceRanges} object),\n * NOT the `{ jobId }` that {@link EditResource.silenceDetect} returns. The\n * planner reads the `ranges` array; an input without one is silently ignored.\n */\n silence?: SilenceRanges\n /** The recording's media sources (1–6). */\n sources: EditPlanSource[]\n /**\n * Multicam: an {@link AudioSyncResult} (the audio-sync job's\n * `output_data.json`) measured over these same source ids. Each source's\n * measured offset is written onto its `offsetMs` BEFORE the request, on the\n * master's clock (the `master-audio` source, else the first) — a source's\n * own `offsetMs` wins. `editPlan` rejects with a {@link NodaroError}\n * (`code: \"edit_plan_sources\"`), before any request or charge, when a\n * source was not measured or matched weakly (confidence < 0.5 — set its\n * `offsetMs` by hand), or the master was not measured.\n */\n offsets?: AudioSyncResult | string\n /**\n * The id of the source the transcript was made from, when you know it. The\n * plan follows the master's clock, so a transcript made from a source that\n * is off it is rejected the same way.\n */\n transcriptSourceId?: string\n /** Free-text editing steer. */\n instructions?: string\n /** Style-guide text applied to the plan. */\n styleGuide?: string\n /** `\"clips\"` mode only: how many clips to cut. */\n count?: number\n /** `\"clips\"` mode only: target duration per clip, in seconds. */\n targetDurationSec?: number\n /** Target aspect for cut clips (`\"clips\"`) or the teaser (`\"trailer\"`). */\n targetAspect?: \"16:9\" | \"9:16\" | \"1:1\" | \"4:5\"\n /** Target platform hint (e.g. a social platform name). */\n platform?: string\n /** Optionally associate this run with a workflow execution (display only). */\n workflowId?: string\n}\n\n/** Input for {@link EditResource.cameraSwitch} (podcast B5). */\nexport interface CameraSwitchInput {\n /** One EDL — an `editPlan` result (`unwrapEditPlanOutput`), not a clip set. */\n edl: Edl\n /** The word transcript WITH speaker labels (transcribe with speaker detection). */\n transcript: Transcript\n /** Speaker label → the EDL source id of that speaker's camera. A speaker\n * left out shows the source whose `speakers` list names them, else the\n * `wide` camera, else any camera that filmed them. */\n speakerMap?: Record<string, string>\n /** A {@link EditResource.speakerMap} job's `output_data.json`: a label in `speakerMap`\n * wins, then this result, then the n-th speaker heard gets the n-th camera. */\n speakerMapResult?: SpeakerMapResult | string\n /** Speaker label → display name (on the segments and the returned transcript). */\n speakerNames?: Record<string, string>\n /** The shortest shot in ms (default 2 500): a shorter turn holds the shot. */\n minShotMs?: number\n /** Cut this long before the new speaker starts, ms (default 200). */\n leadMs?: number\n /** With a `wide` source: break to it after this long on one camera, ms (default 20 000). */\n maxShotMs?: number\n /** With a `wide` source: every N-th cut goes to the wide (default 0 = off). */\n wideEvery?: number\n /** Overlapping speech → a layout hint (default false; Apply EDL renders cut-only edits). */\n layoutHints?: boolean\n /** Optionally associate this run with a workflow execution (display only). */\n workflowId?: string\n}\n\n/**\n * The podcast use-case node types, each one a route (`POST /v1/<type>`, and\n * `POST /v1/<type>/continue` to continue one of its runs).\n */\nexport { USE_CASE_NODE_TYPES, type UseCaseNodeType }\n\n/** The route that continues a run of `type`. */\nconst continuePathOf = (type: UseCaseNodeType): `/v1/${UseCaseNodeType}/continue` => `/v1/${type}/continue`\n\n/** What a use-case run (`tightenEpisode`, `episodeChapters`, `episodeTrailer`, `clipPack`, `speakerLayout`) and `continueUseCase` answer: the run's job to poll. */\nexport interface UseCaseJobResult extends EditJobResult {\n /** The run's execution (absent on a deduplicated retry). */\n executionId?: string\n /** `true` when an `Idempotency-Key` retry found the run already started: `jobId` is that run. */\n deduped?: boolean\n}\n\n/** What `tightenEpisode` answers (a {@link UseCaseJobResult}). */\nexport type TightenEpisodeJobResult = UseCaseJobResult\n\n/**\n * What a use-case run is estimated at (`data`). Every credit amount is 0\n * on an edition without credits; `durationSec` is `null` when the recording's\n * length could not be read.\n */\nexport interface UseCaseEstimate {\n /** The whole run: its steps plus the fee. */\n totalCredits: number\n /** The steps at their own rates. */\n stepsCredits: number\n /** The per-run fee. */\n feeCredits: number\n /** A step is a metered LLM call's ESTIMATE (charged its actual usage), so the\n * total is one: show it `~N`. Absent for a fixed figure. */\n estimate?: true\n /** The recording's length, in seconds. */\n durationSec: number | null\n}\n\n/** What a Tighten Episode run is estimated at (a {@link UseCaseEstimate}). */\nexport type TightenEpisodeEstimate = UseCaseEstimate\n\n/** Input for {@link EditResource.continueUseCase}. */\nexport interface UseCaseContinueInput {\n /** The run to continue: the job `tightenEpisode`, `episodeChapters`, `episodeTrailer`, `clipPack` or `speakerLayout` (or an earlier continuation) answered. */\n jobId: string\n /**\n * `\"from-failed\"` re-runs what did not finish of a failed run;\n * `\"render-final\"` renders the full-quality result after a review-on preview\n * (a Chapters run has no preview: it is refused `render_final_not_preview`;\n * a Clip Pack edit that drops every clip is refused `use_case_nothing_kept`).\n */\n mode: \"from-failed\" | \"render-final\"\n /** Render final only: the reviewer's edit of the plan (an EDL). A Speaker Layout run has no plan: an edit is refused `400 use_case_no_plan`. */\n editedEdl?: unknown\n /**\n * The run's node type: its continuation goes to `POST /v1/<nodeType>/continue`.\n * Optional: when absent the job is read first (`GET /v1/jobs/:id`, which\n * needs the `jobs:read` scope on an app token) for the type the run records.\n * Required when that read cannot answer: a key without `jobs:read`, or a job\n * that records no use-case type (the call rejects with `use_case_type_unknown`).\n */\n nodeType?: UseCaseNodeType\n}\n\n/** Per-call options for the use-case requests (Tighten Episode, Chapters, Trailer, Clip Pack, Speaker Layout, and their continuations). */\nexport interface UseCaseRequestOptions {\n /**\n * Sent as the `Idempotency-Key` header. Reuse the same value when retrying\n * the same request and the server answers the run it already started\n * (`deduped: true`) instead of starting a second one.\n */\n idempotencyKey?: string\n}\n\nfunction idempotencyHeaders(options?: UseCaseRequestOptions): { headers?: Record<string, string> } {\n return options?.idempotencyKey ? { headers: { \"Idempotency-Key\": options.idempotencyKey } } : {}\n}\n\n/**\n * Editorial primitives for podcast / long-form video editing, single-camera\n * and multicam: measure the cameras' offsets ({@link audioSync}), plan the cut\n * ({@link editPlan}), put each cut on the speaker's camera\n * ({@link cameraSwitch}), render a Preview to review (`applyEdl` with\n * `quality: \"proxy\"`), then the final (`quality: \"final\"`).\n *\n * - {@link silenceDetect}, {@link audioSync} and {@link applyEdl} are core nodes\n * available on every edition.\n * - {@link editPlan} and {@link cameraSwitch} run on nodaro.ai; a self-hosted\n * install relays them once it is connected (a 503\n * `code: \"nodaro_connection_required\"` otherwise).\n * - {@link tightenEpisode} runs the whole chain (transcribe, plan, render, and\n * optionally captions, music and framing) in one call. It is core, but a\n * self-hosted install needs a nodaro.ai connection for the steps that run\n * there (a 503 `code: \"nodaro_connection_required\"` otherwise).\n * {@link continueUseCase} continues one of its runs.\n * - {@link episodeChapters} lists a recording's chapters (transcribe, then the\n * plan in chapters mode) in one call; nothing renders. Like\n * {@link tightenEpisode}, a self-hosted install needs a nodaro.ai connection.\n * - {@link episodeTrailer} cuts a 20–40 s trailer of a recording and delivers\n * it in each chosen format in one call; the same connection applies.\n * - {@link clipPack} cuts a recording into a pack of short clips (framed and\n * captioned by default) in one call; the same connection applies.\n * - {@link speakerLayout} frames a whole recording by speaker (the same\n * length, nothing cut) in one call; the same connection applies.\n * - {@link remapTranscript} is a PURE local transform (no request) — the same\n * remap `applyEdl` performs on its `transcript`, exposed for callers that hold\n * an EDL and a transcript and only want the re-timed transcript.\n *\n * Every request method except the estimates ({@link estimateTightenEpisode},\n * {@link estimateEpisodeChapters}, {@link estimateEpisodeTrailer},\n * {@link estimateClipPack}, {@link estimateSpeakerLayout}: a quote, `{ data }`) returns\n * {@link EditJobResult} (the use-case runs a {@link UseCaseJobResult}); poll the\n * `jobId` with `client.jobs.getStatus(jobId)`.\n */\nexport class EditResource {\n constructor(private client: NodaroClientCore) {}\n\n /**\n * Detect silence ranges in an audio/video source (`POST /v1/silence-detect`).\n * Keyless — one ffmpeg pass over the source's audio proxy.\n */\n silenceDetect(input: SilenceDetectInput): Promise<EditJobResult> {\n return this.client.request(\"POST\", \"/v1/silence-detect\", {\n body: {\n audioUrl: input.audioUrl,\n ...(input.thresholdDb !== undefined ? { thresholdDb: input.thresholdDb } : {}),\n ...(input.minSilenceMs !== undefined ? { minSilenceMs: input.minSilenceMs } : {}),\n ...(input.padMs !== undefined ? { padMs: input.padMs } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Measure how far apart the clocks of 2–6 recordings of one conversation are\n * (`POST /v1/audio-sync`), by cross-correlating their audio — keyless, one\n * ffmpeg decode per source. The finished job's `output_data.json` is an\n * {@link AudioSyncResult}. A malformed request (fewer than 2 or more than 6\n * sources, a repeated id, a `reference` that is not one of the ids) throws a\n * typed `NodaroError` (400, `code: \"validation_error\"`) before any credits\n * are reserved.\n */\n audioSync(input: AudioSyncInput): Promise<EditJobResult> {\n return this.client.request(\"POST\", \"/v1/audio-sync\", {\n body: {\n sources: input.sources.map((s) => ({ id: s.id, url: s.url })),\n ...(input.reference !== undefined ? { reference: input.reference } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Which camera each speaker is on, from the cameras' own microphones (`POST\n * /v1/speaker-map`), keyless. `output_data.json` is a `SpeakerMapResult`: pass\n * it to {@link cameraSwitch} as `speakerMapResult`. A malformed request throws\n * a `NodaroError` (400 `validation_error`; 422 `no_speakers` for a transcript\n * with no speaker labels) before any credits are reserved.\n */\n speakerMap(input: SpeakerMapInput): Promise<EditJobResult> {\n return this.client.request(\"POST\", \"/v1/speaker-map\", {\n body: {\n sources: input.sources.map((s) => ({ id: s.id, url: s.url, ...(s.kind ? { kind: s.kind } : {}) })),\n transcript: input.transcript,\n ...(input.offsets !== undefined ? { offsets: input.offsets } : {}),\n ...(input.masterSourceId !== undefined ? { masterSourceId: input.masterSourceId } : {}),\n ...(input.wideSourceId !== undefined ? { wideSourceId: input.wideSourceId } : {}),\n ...(input.marginDb !== undefined ? { marginDb: input.marginDb } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Render an edit decision list into a video or audio cut (`POST /v1/apply-edl`).\n * The EDL is validated at ingress — an unresolvable source or a picture-less\n * segment on a video edit throws a typed `NodaroError` (400, `code:\n * \"invalid_edl\"`) before any credits are reserved.\n */\n applyEdl(input: ApplyEdlInput): Promise<EditJobResult> {\n return this.client.request(\"POST\", \"/v1/apply-edl\", {\n body: {\n edl: input.edl,\n ...(input.sources !== undefined ? { sources: input.sources } : {}),\n ...(input.transcript !== undefined ? { transcript: input.transcript } : {}),\n ...(input.output !== undefined ? { output: input.output } : {}),\n ...(input.quality !== undefined ? { quality: input.quality } : {}),\n ...(input.crossfadeMs !== undefined ? { crossfadeMs: input.crossfadeMs } : {}),\n ...(input.clipKey !== undefined ? { clipKey: input.clipKey } : {}),\n ...(input.planBasis !== undefined ? { planBasis: input.planBasis } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Tighten Episode (`POST /v1/tighten-episode`): tighten a podcast recording\n * in one call — transcribe, cut the silences and filler, render, with\n * optional captions, music and framing. Answers the run's job to poll; its\n * `output_data` holds the episode. The run is priced as its steps at their own\n * rates plus the listed per-run fee. Quote it first with\n * {@link estimateTightenEpisode}.\n */\n tightenEpisode(input: TightenEpisodeInput, options?: UseCaseRequestOptions): Promise<TightenEpisodeJobResult> {\n return withUseCaseBody(() => tightenBody(input), (body) => this.client.request(\"POST\", \"/v1/tighten-episode\", { body, ...idempotencyHeaders(options) }))\n }\n\n /**\n * What a Tighten Episode run is estimated at (`POST /v1/tighten-episode/estimate`):\n * its steps at their own rates plus its per-run fee. Nothing is created or\n * charged. The estimate leans high: the render is priced at the recording's\n * full length, while the charge follows the minutes actually rendered.\n */\n estimateTightenEpisode(input: TightenEpisodeInput): Promise<{ data: TightenEpisodeEstimate }> {\n return withUseCaseBody(() => tightenBody(input), (body) => this.client.request(\"POST\", \"/v1/tighten-episode/estimate\", { body }))\n }\n\n /**\n * Chapters (`POST /v1/episode-chapters`): transcribe a recording and list its\n * chapters in one call. Answers the run's job to poll; the finished job's\n * `output_data.text` is the list as show notes (one `0:00 Title` line per\n * chapter; once a chapter starts at 1:00:00 or later, every line is\n * `H:MM:SS`), `output_data.json` the list itself (`{ startMs, title }[]`, the\n * same rows; the first starts at 0). A run that finds no chapters fails,\n * and its fee is refunded. Priced as its steps at their own rates plus the\n * listed per-run fee; quote it first with {@link estimateEpisodeChapters}.\n */\n episodeChapters(input: EpisodeChaptersInput, options?: UseCaseRequestOptions): Promise<UseCaseJobResult> {\n return withUseCaseBody(() => chaptersBody(input), (body) => this.client.request(\"POST\", \"/v1/episode-chapters\", { body, ...idempotencyHeaders(options) }))\n }\n\n /**\n * What a Chapters run is estimated at (`POST /v1/episode-chapters/estimate`):\n * its steps at their own rates plus its per-run fee. Nothing is created or\n * charged. A recording whose length cannot be read is estimated at the\n * 180-minute ceiling.\n */\n estimateEpisodeChapters(input: EpisodeChaptersInput): Promise<{ data: UseCaseEstimate }> {\n return withUseCaseBody(() => chaptersBody(input), (body) => this.client.request(\"POST\", \"/v1/episode-chapters/estimate\", { body }))\n }\n\n /**\n * Trailer (`POST /v1/episode-trailer`): cut a 20–40 s trailer of a recording\n * and deliver it in each chosen format (padded, never cropped), optionally\n * after an intro card, in one call. The finished job's `output_data.formats`\n * is `{ format, url }[]` in format order, the first also `output_data.videoUrl`;\n * a format that failed is named in `output_data.failedFormats` (the run keeps\n * the others). With `reviewBeforeRender` the run stops at a preview\n * (`videoUrl`, no formats yet). Priced as its steps at their own rates plus\n * the listed per-run fee; quote it first with {@link estimateEpisodeTrailer}.\n */\n episodeTrailer(input: EpisodeTrailerInput, options?: UseCaseRequestOptions): Promise<UseCaseJobResult> {\n return withUseCaseBody(() => trailerBody(input), (body) => this.client.request(\"POST\", \"/v1/episode-trailer\", { body, ...idempotencyHeaders(options) }))\n }\n\n /**\n * What a Trailer run is estimated at (`POST /v1/episode-trailer/estimate`):\n * its steps at their own rates plus its per-run fee. Nothing is created or\n * charged. The trailer is quoted at 40 seconds, the longest trailer the\n * plan cuts; a Render final is quoted on the trailer the run cut (with the\n * review's edits), plus the intro card.\n */\n estimateEpisodeTrailer(input: EpisodeTrailerInput): Promise<{ data: UseCaseEstimate }> {\n return withUseCaseBody(() => trailerBody(input), (body) => this.client.request(\"POST\", \"/v1/episode-trailer/estimate\", { body }))\n }\n\n /**\n * Clip Pack (`POST /v1/clip-pack`): cut a recording into a pack of short\n * clips in one call — the plan finds the best moments (`count`, default 8,\n * of about `targetDurationSec`, default 60), each is rendered (framed 9:16\n * with the speakers stacked by default; `framing: null` keeps the\n * recording's shape) and captioned. An audio recording makes audio clips.\n * The finished job's `output_data.clips` is `{ url, title?, hook?, clipKey,\n * thumbnailUrl?, captionsFailed? }[]` in plan order, the first also\n * `output_data.videoUrl` (`audioUrl` for audio clips). Every clip is tried:\n * one that cannot be rendered is skipped, not charged and counted on\n * `failedClips` (the pack keeps the others and its fee); a clip whose\n * captions failed comes uncaptioned (`captionsFailed`, counted on\n * `failedCaptions`). When no clip renders the run fails and its fee is\n * refunded. With `reviewBeforeRender` the run stops at previews; Render\n * final ({@link continueUseCase}) renders only the clips the edit keeps.\n * Priced as its steps at their own rates plus the listed per-run fee;\n * quote it first with {@link estimateClipPack}.\n */\n clipPack(input: ClipPackInput, options?: UseCaseRequestOptions): Promise<UseCaseJobResult> {\n return withUseCaseBody(() => clipPackBody(input), (body) => this.client.request(\"POST\", \"/v1/clip-pack\", { body, ...idempotencyHeaders(options) }))\n }\n\n /**\n * What a Clip Pack run is estimated at (`POST /v1/clip-pack/estimate`): its\n * steps at their own rates plus its per-run fee. Nothing is created or\n * charged. Each clip is quoted at twice the target length (the plan may cut\n * a clip longer than asked); the charge follows each clip's real length.\n */\n estimateClipPack(input: ClipPackInput): Promise<{ data: UseCaseEstimate }> {\n return withUseCaseBody(() => clipPackBody(input), (body) => this.client.request(\"POST\", \"/v1/clip-pack/estimate\", { body }))\n }\n\n /**\n * Speaker Layout (`POST /v1/speaker-layout`): frame a whole recording by\n * speaker in one call — the same length, nothing cut. One recording: each\n * speaker framed in turn; several recordings of one conversation: lined up,\n * each speaker shown on their own camera. The finished job's\n * `output_data.videoUrl` is the framed video, `output_data.json` the edit\n * Speaker View drew. With `reviewBeforeRender` the run stops at a preview;\n * {@link continueUseCase} (`mode: \"render-final\"`, no `editedEdl`) renders\n * it at full quality. Priced as its steps at their own rates plus the listed\n * per-run fee; quote it first with {@link estimateSpeakerLayout}.\n */\n speakerLayout(input: SpeakerLayoutInput, options?: UseCaseRequestOptions): Promise<UseCaseJobResult> {\n return withUseCaseBody(() => speakerLayoutBody(input), (body) => this.client.request(\"POST\", \"/v1/speaker-layout\", { body, ...idempotencyHeaders(options) }))\n }\n\n /**\n * What a Speaker Layout run is estimated at (`POST /v1/speaker-layout/estimate`):\n * its steps at their own rates plus its per-run fee. Nothing is created or\n * charged. A recording whose length cannot be read is estimated at the\n * 180-minute ceiling.\n */\n estimateSpeakerLayout(input: SpeakerLayoutInput): Promise<{ data: UseCaseEstimate }> {\n return withUseCaseBody(() => speakerLayoutBody(input), (body) => this.client.request(\"POST\", \"/v1/speaker-layout/estimate\", { body }))\n }\n\n /**\n * Continue a use-case run as a new job (`POST /v1/<type>/continue`, the\n * run's own type: `input.nodeType`, else the type the job records, read with\n * `GET /v1/jobs/:id`; when that read cannot tell, this rejects with a\n * `NodaroError` coded `use_case_type_unknown` — pass `nodeType` then):\n * `\"from-failed\"` keeps the steps that finished and runs the rest (the fee\n * is held again; the failed run's was refunded);\n * `\"render-final\"` renders the full-quality result after a review-on preview,\n * with the preview's settings and no fee. A refusal that names another job\n * (`already_running`, `continuation_superseded`,\n * `render_final_already_rendered`) throws a `ContinuationRefusedError`\n * carrying that `jobId`.\n */\n async continueUseCase(input: UseCaseContinueInput, options?: UseCaseRequestOptions): Promise<UseCaseJobResult> {\n if (input.nodeType !== undefined && !isUseCaseNodeType(input.nodeType)) {\n throw new NodaroError(\n `continueUseCase: nodeType \"${String(input.nodeType)}\" is not a use-case node type (${USE_CASE_NODE_TYPES.join(\", \")})`,\n \"invalid_node_type\",\n 400,\n )\n }\n const type = input.nodeType ?? (await this.runTypeOf(input.jobId))\n return this.client.request(\"POST\", continuePathOf(type), {\n body: { jobId: input.jobId, mode: input.mode, ...(input.editedEdl !== undefined ? { editedEdl: input.editedEdl } : {}) },\n ...idempotencyHeaders(options),\n })\n }\n\n /**\n * The use-case type a run records (`input_data.type`, else its `job_type`).\n * When the key lacks the `jobs:read` scope (403 naming that scope) or the job\n * names no use-case type, the type cannot be read: this rejects with a\n * `NodaroError` (`use_case_type_unknown`, 400) asking for `nodeType`, and\n * nothing is posted (decided 2026-10-18: no route is guessed for the run).\n * Any other failure of the read, any other 403 included, is thrown as is.\n */\n private async runTypeOf(jobId: string): Promise<UseCaseNodeType> {\n const unknown = () =>\n new NodaroError(\"continueUseCase: the run's node type cannot be read — pass nodeType\", \"use_case_type_unknown\", 400)\n let row: { job_type?: unknown; input_data?: unknown } | undefined\n try {\n row = (await this.client.request<{ data?: { job_type?: unknown; input_data?: unknown } }>(\"GET\", `/v1/jobs/${encodeURIComponent(jobId)}`)).data\n } catch (err) {\n if (err instanceof ForbiddenError && err.missingScope === \"jobs:read\") throw unknown()\n throw err\n }\n const input = row?.input_data\n const recorded = input && typeof input === \"object\" && !Array.isArray(input) ? (input as { type?: unknown }).type : undefined\n const type = typeof recorded === \"string\" && recorded.length > 0 ? recorded : row?.job_type\n if (!isUseCaseNodeType(type)) throw unknown()\n return type\n }\n\n /**\n * Plan a transcript-driven cut (`POST /v1/edit-plan`). Reads a timed\n * transcript (plus optional silence ranges) and the media sources, and plans\n * the edit. The finished job's `output_data` holds the plan: an `Edl`\n * (`\"tighten\"` or `\"trailer\"`), an {@link EdlClipSet} (`\"clips\"`), or a\n * {@link ChapterSet} (`\"chapters\"`) — normalize it with {@link unwrapEditPlanOutput}.\n *\n * On a self-hosted install the request relays to nodaro.ai and needs the\n * install connected (a 503 `code: \"nodaro_connection_required\"` otherwise);\n * on nodaro.ai it runs directly.\n */\n editPlan(input: EditPlanInput): Promise<EditJobResult> {\n // The same pre-dispatch check the canvas and MCP run (B4): the server never\n // sees `offsets` — they are written onto the sources here.\n const planned = resolveEditPlanSources(input.sources, {\n offsets: input.offsets,\n transcriptSourceId: input.transcriptSourceId,\n })\n if (!planned.ok) {\n const message = planned.issues.map((issue) => describeAudioSyncOffsetIssue(issue)).join(\"; \")\n return Promise.reject(new NodaroError(`editPlan: ${message}`, \"edit_plan_sources\", 400))\n }\n const transcript = planned.transcriptSourceId\n ? { ...input.transcript, sourceId: planned.transcriptSourceId }\n : input.transcript\n return this.client.request(\"POST\", \"/v1/edit-plan\", {\n body: {\n mode: input.mode,\n planTier: input.planTier,\n transcript,\n sources: planned.sources,\n ...(input.silence !== undefined ? { silence: input.silence } : {}),\n ...(input.instructions !== undefined ? { instructions: input.instructions } : {}),\n ...(input.styleGuide !== undefined ? { styleGuide: input.styleGuide } : {}),\n ...(input.count !== undefined ? { count: input.count } : {}),\n ...(input.targetDurationSec !== undefined ? { targetDurationSec: input.targetDurationSec } : {}),\n ...(input.targetAspect !== undefined ? { targetAspect: input.targetAspect } : {}),\n ...(input.platform !== undefined ? { platform: input.platform } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Camera Switch (podcast B5): choose which camera shows each cut of `edl`\n * by who is speaking — the sound never changes. Cloud edition; a flat\n * price. The finished job's `output_data.json` is the switched EDL (feed it\n * to {@link applyEdl}) and `output_data.transcript` the transcript with\n * `speakerNames` applied. A transcript with no speaker labels rejects with\n * a {@link NodaroError} (`code: \"no_speakers\"`) before any request or charge.\n */\n cameraSwitch(input: CameraSwitchInput): Promise<EditJobResult> {\n if (transcriptSpeakerLabels(input.transcript).length === 0) {\n return Promise.reject(new NodaroError(\n \"cameraSwitch: the transcript has no speaker labels — transcribe with speaker detection on\",\n \"no_speakers\",\n 422,\n ))\n }\n const result = input.speakerMapResult\n if (result !== undefined && !speakerMapResultOf(result)) return Promise.reject(new NodaroError(\"cameraSwitch: speakerMapResult is not a Speaker Map result — pass that job's output_data.json\", \"not_a_speaker_map\", 400))\n const speakerMap = result !== undefined ? cameraSwitchSpeakerMap({ speakerMap: input.speakerMap }, input.edl, input.transcript, { speakerMap: result }) : input.speakerMap\n return this.client.request(\"POST\", \"/v1/camera-switch\", {\n body: {\n edl: input.edl,\n transcript: input.transcript,\n ...(speakerMap !== undefined ? { speakerMap } : {}),\n ...(input.speakerNames !== undefined ? { speakerNames: input.speakerNames } : {}),\n ...(input.minShotMs !== undefined ? { minShotMs: input.minShotMs } : {}),\n ...(input.leadMs !== undefined ? { leadMs: input.leadMs } : {}),\n ...(input.maxShotMs !== undefined ? { maxShotMs: input.maxShotMs } : {}),\n ...(input.wideEvery !== undefined ? { wideEvery: input.wideEvery } : {}),\n ...(input.layoutHints !== undefined ? { layoutHints: input.layoutHints } : {}),\n ...(input.workflowId !== undefined ? { workflowId: input.workflowId } : {}),\n },\n })\n }\n\n /**\n * Remap a transcript through an EDL — a PURE client-side transform (NO\n * request). Returns a new transcript whose word (and segment) timings are on\n * the EDL's rendered output clock, dropping words that fall in cut regions and\n * clipping straddlers. Runs `@nodaro/shared`'s canonical\n * `remapTranscriptThroughEdl`, the same remap `applyEdl` performs server-side.\n */\n remapTranscript(edl: Edl, transcript: Transcript): Transcript {\n return remapTranscriptThroughEdl(edl, transcript)\n }\n}\n"]}
|
|
@@ -28,6 +28,18 @@ var JobsResource = class {
|
|
|
28
28
|
query: { ...rest, status: listParam(status), type: listParam(type) }
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Record an image edited in the browser as a job (`POST /v1/jobs/from-upload`):
|
|
33
|
+
* a completed, private, free `image-edit` job whose `output_data.imageUrl` is
|
|
34
|
+
* the upload, linked to its source in `input_data` (`sourceJobId` /
|
|
35
|
+
* `sourceAssetId`, `sourceImageUrl`). It then lists, rates, favorites and
|
|
36
|
+
* files into a session like any image job. One upload is one job: the same
|
|
37
|
+
* `assetId` again returns the same job. OAuth apps need the `assets:write`
|
|
38
|
+
* scope. A deployment's job policy can refuse the image ({@link JobBlockedError}).
|
|
39
|
+
*/
|
|
40
|
+
fromUpload(params) {
|
|
41
|
+
return this.client.request("POST", "/v1/jobs/from-upload", { body: params });
|
|
42
|
+
}
|
|
31
43
|
/**
|
|
32
44
|
* Rate one of your jobs `"good"` or `"bad"`, or clear the rating with
|
|
33
45
|
* `null` (`PUT /v1/jobs/:id/rating`). Only the job's owner rates it — anyone
|
|
@@ -53,7 +65,12 @@ var JobsResource = class {
|
|
|
53
65
|
}
|
|
54
66
|
/**
|
|
55
67
|
* Cancel a job. Server route is `POST /v1/jobs/:jobId/cancel`.
|
|
56
|
-
* Refunds any reserved credit holds.
|
|
68
|
+
* Refunds any reserved credit holds. A running LLM job priced per model
|
|
69
|
+
* (metered) whose call has already started answers
|
|
70
|
+
* `{ success: true, cancelled: 0, inFlight: true }`: it finishes and is
|
|
71
|
+
* charged only what it used. A job stopped before its call starts is
|
|
72
|
+
* refunded, except for what an earlier attempt of the same job already used
|
|
73
|
+
* (a retry after a billed attempt): that is charged.
|
|
57
74
|
*/
|
|
58
75
|
cancel(id) {
|
|
59
76
|
return this.client.request(
|
|
@@ -76,5 +93,5 @@ var JobsResource = class {
|
|
|
76
93
|
};
|
|
77
94
|
|
|
78
95
|
exports.JobsResource = JobsResource;
|
|
79
|
-
//# sourceMappingURL=chunk-
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
96
|
+
//# sourceMappingURL=chunk-A7QSOD2S.cjs.map
|
|
97
|
+
//# sourceMappingURL=chunk-A7QSOD2S.cjs.map
|