codai-sdk 0.54.1 → 0.62.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/index.d.ts +3849 -879
- package/dist/index.js +558 -84
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -80,7 +80,8 @@ const EXTENSION_HEADERS = {
|
|
|
80
80
|
deviceName: "x-codai-device-name",
|
|
81
81
|
devicePlatform: "x-codai-device-platform",
|
|
82
82
|
pushToken: "x-codai-push-token",
|
|
83
|
-
shareToken: "x-codai-share-token"
|
|
83
|
+
shareToken: "x-codai-share-token",
|
|
84
|
+
idempotencyKey: "Idempotency-Key"
|
|
84
85
|
};
|
|
85
86
|
/** Translate an extensions bag into raw `X-Codai-*` headers. Exported for tests. */
|
|
86
87
|
function extensionHeaders(ext) {
|
|
@@ -586,6 +587,20 @@ var Billing = class {
|
|
|
586
587
|
})).invoices];
|
|
587
588
|
}
|
|
588
589
|
/**
|
|
590
|
+
* `GET /v1/studio/quote` — what a Studio action costs (USD and wallet EUR micros) and your spendable balance,
|
|
591
|
+
* before you run it. Paid Studio calls answer 402 `insufficient_funds` when `sufficient` is false. Free.
|
|
592
|
+
*/
|
|
593
|
+
studioQuote(query, opts = {}) {
|
|
594
|
+
return this.http.json("/v1/studio/quote", {
|
|
595
|
+
query: {
|
|
596
|
+
...query,
|
|
597
|
+
audio: query.audio === void 0 ? void 0 : String(query.audio)
|
|
598
|
+
},
|
|
599
|
+
ext: opts.ext,
|
|
600
|
+
signal: opts.signal
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
589
604
|
* Poll `get()` every `intervalMs` and call `onLow` once each time the wallet
|
|
590
605
|
* balance crosses below `thresholdEur`. Read-only: never creates a checkout.
|
|
591
606
|
* Returns a function that stops the watcher.
|
|
@@ -1568,7 +1583,7 @@ function decodeBase64(b64) {
|
|
|
1568
1583
|
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
|
1569
1584
|
return out;
|
|
1570
1585
|
}
|
|
1571
|
-
function abortableSleep$
|
|
1586
|
+
function abortableSleep$6(ms, signal) {
|
|
1572
1587
|
return new Promise((resolve, reject) => {
|
|
1573
1588
|
if (signal?.aborted) return reject(signal.reason ?? /* @__PURE__ */ new Error("Aborted"));
|
|
1574
1589
|
const t = setTimeout(() => {
|
|
@@ -1683,7 +1698,7 @@ var Videos = class {
|
|
|
1683
1698
|
}
|
|
1684
1699
|
if (st.status === "failed" || st.status === "filtered") throw new Error(`codai video job ${st.status}: ${st.error ?? "no details"}`);
|
|
1685
1700
|
if (Date.now() + pollIntervalMs > deadline) throw new Error(`codai video job ${job.id} did not finish within ${timeoutMs} ms`);
|
|
1686
|
-
await abortableSleep$
|
|
1701
|
+
await abortableSleep$6(pollIntervalMs, signal);
|
|
1687
1702
|
}
|
|
1688
1703
|
}
|
|
1689
1704
|
};
|
|
@@ -1782,14 +1797,14 @@ var Renders = class {
|
|
|
1782
1797
|
}
|
|
1783
1798
|
if (st.status === "failed") throw new Error(`codai render failed: ${st.error ?? "no details"}`);
|
|
1784
1799
|
if (Date.now() + pollIntervalMs > deadline) throw new Error(`codai render ${job.id} did not finish within ${timeoutMs} ms`);
|
|
1785
|
-
await abortableSleep$
|
|
1800
|
+
await abortableSleep$6(pollIntervalMs, signal);
|
|
1786
1801
|
}
|
|
1787
1802
|
}
|
|
1788
1803
|
};
|
|
1789
1804
|
|
|
1790
1805
|
//#endregion
|
|
1791
1806
|
//#region src/resources/documents.ts
|
|
1792
|
-
function abortableSleep$
|
|
1807
|
+
function abortableSleep$5(ms, signal) {
|
|
1793
1808
|
return new Promise((resolve, reject) => {
|
|
1794
1809
|
if (signal?.aborted) return reject(signal.reason ?? /* @__PURE__ */ new Error("Aborted"));
|
|
1795
1810
|
const t = setTimeout(() => {
|
|
@@ -1882,7 +1897,7 @@ var Documents = class {
|
|
|
1882
1897
|
if (st.status === "succeeded") return st;
|
|
1883
1898
|
if (st.status === "failed") throw new Error(`codai document preview failed: ${st.error ?? "no details"}`);
|
|
1884
1899
|
if (Date.now() + pollIntervalMs > deadline) throw new Error(`codai document preview ${job.id} did not finish within ${timeoutMs} ms`);
|
|
1885
|
-
await abortableSleep$
|
|
1900
|
+
await abortableSleep$5(pollIntervalMs, signal);
|
|
1886
1901
|
}
|
|
1887
1902
|
}
|
|
1888
1903
|
/** Queue a deck video and poll `renders.retrieve` until it succeeds. Throws on `failed` or timeout. */
|
|
@@ -1914,15 +1929,15 @@ var Documents = class {
|
|
|
1914
1929
|
}
|
|
1915
1930
|
if (st.status === "failed") throw new Error(`codai deck video failed: ${st.error ?? "no details"}`);
|
|
1916
1931
|
if (Date.now() + pollIntervalMs > deadline) throw new Error(`codai deck video ${accepted.id} did not finish within ${timeoutMs} ms`);
|
|
1917
|
-
await abortableSleep$
|
|
1932
|
+
await abortableSleep$5(pollIntervalMs, signal);
|
|
1918
1933
|
}
|
|
1919
1934
|
}
|
|
1920
1935
|
};
|
|
1921
1936
|
|
|
1922
1937
|
//#endregion
|
|
1923
1938
|
//#region src/resources/exports.ts
|
|
1924
|
-
const path$
|
|
1925
|
-
function abortableSleep$
|
|
1939
|
+
const path$6 = (id) => `/v1/studio/exports/${encodeURIComponent(id)}`;
|
|
1940
|
+
function abortableSleep$4(ms, signal) {
|
|
1926
1941
|
return new Promise((resolve, reject) => {
|
|
1927
1942
|
if (signal?.aborted) return reject(signal.reason ?? /* @__PURE__ */ new Error("Aborted"));
|
|
1928
1943
|
const t = setTimeout(() => {
|
|
@@ -1943,7 +1958,7 @@ var Exports = class {
|
|
|
1943
1958
|
}
|
|
1944
1959
|
/** The export: `queued` / `running`, then `succeeded` (signed `url`, valid 1 h) or `failed` (`error`). Free. */
|
|
1945
1960
|
retrieve(id, opts = {}) {
|
|
1946
|
-
return this.http.json(path$
|
|
1961
|
+
return this.http.json(path$6(id), {
|
|
1947
1962
|
ext: opts.ext,
|
|
1948
1963
|
signal: opts.signal
|
|
1949
1964
|
});
|
|
@@ -1963,14 +1978,14 @@ var Exports = class {
|
|
|
1963
1978
|
});
|
|
1964
1979
|
if (st.status === "succeeded" || st.status === "failed") return st;
|
|
1965
1980
|
if (Date.now() + intervalMs > deadline) throw new Error(`codai export ${id} did not finish within ${timeoutMs} ms`);
|
|
1966
|
-
await abortableSleep$
|
|
1981
|
+
await abortableSleep$4(intervalMs, signal);
|
|
1967
1982
|
}
|
|
1968
1983
|
}
|
|
1969
1984
|
};
|
|
1970
1985
|
|
|
1971
1986
|
//#endregion
|
|
1972
1987
|
//#region src/resources/creatives.ts
|
|
1973
|
-
const path$
|
|
1988
|
+
const path$5 = (id, tail = "") => `/v1/studio/creatives/${encodeURIComponent(id)}${tail}`;
|
|
1974
1989
|
const lottieQuery = (q) => ({
|
|
1975
1990
|
format: q.format,
|
|
1976
1991
|
formats: q.formats,
|
|
@@ -2010,7 +2025,7 @@ var Creatives = class {
|
|
|
2010
2025
|
}
|
|
2011
2026
|
/** The document at the head (or `seq`) with signed `assets` (1 h URLs). */
|
|
2012
2027
|
retrieve(id, query = {}, opts = {}) {
|
|
2013
|
-
return this.http.json(path$
|
|
2028
|
+
return this.http.json(path$5(id), {
|
|
2014
2029
|
query: { seq: query.seq },
|
|
2015
2030
|
ext: opts.ext,
|
|
2016
2031
|
signal: opts.signal
|
|
@@ -2018,14 +2033,14 @@ var Creatives = class {
|
|
|
2018
2033
|
}
|
|
2019
2034
|
/** Compact text outline (+ formats and vars) — the cheapest structure for a prompt. */
|
|
2020
2035
|
outline(id, opts = {}) {
|
|
2021
|
-
return this.http.json(path$
|
|
2036
|
+
return this.http.json(path$5(id, "/outline"), {
|
|
2022
2037
|
ext: opts.ext,
|
|
2023
2038
|
signal: opts.signal
|
|
2024
2039
|
});
|
|
2025
2040
|
}
|
|
2026
2041
|
/** Node ids matching `query` (a string = text/name/id substring, or `{ text, type, sceneId, assetId, locked }`). */
|
|
2027
2042
|
find(id, query, opts = {}) {
|
|
2028
|
-
return this.http.json(path$
|
|
2043
|
+
return this.http.json(path$5(id, "/find"), {
|
|
2029
2044
|
method: "POST",
|
|
2030
2045
|
body: { query },
|
|
2031
2046
|
ext: opts.ext,
|
|
@@ -2034,7 +2049,7 @@ var Creatives = class {
|
|
|
2034
2049
|
}
|
|
2035
2050
|
/** Full JSON of `ids` (scene ids return whole scenes) or of one `sceneId`. */
|
|
2036
2051
|
subtree(id, body, opts = {}) {
|
|
2037
|
-
return this.http.json(path$
|
|
2052
|
+
return this.http.json(path$5(id, "/subtree"), {
|
|
2038
2053
|
method: "POST",
|
|
2039
2054
|
body,
|
|
2040
2055
|
ext: opts.ext,
|
|
@@ -2047,7 +2062,7 @@ var Creatives = class {
|
|
|
2047
2062
|
* ops throw 400 with `code` (`invalid`, `not_found`, `locked`, `duplicate_id`).
|
|
2048
2063
|
*/
|
|
2049
2064
|
edit(id, body, opts = {}) {
|
|
2050
|
-
return this.http.json(path$
|
|
2065
|
+
return this.http.json(path$5(id, "/ops"), {
|
|
2051
2066
|
method: "POST",
|
|
2052
2067
|
body: {
|
|
2053
2068
|
base_seq: body.baseSeq,
|
|
@@ -2063,7 +2078,7 @@ var Creatives = class {
|
|
|
2063
2078
|
}
|
|
2064
2079
|
/** Version history, newest first (`beforeSeq` pages). */
|
|
2065
2080
|
versions(id, query = {}, opts = {}) {
|
|
2066
|
-
return this.http.json(path$
|
|
2081
|
+
return this.http.json(path$5(id, "/versions"), {
|
|
2067
2082
|
query: {
|
|
2068
2083
|
before_seq: query.beforeSeq,
|
|
2069
2084
|
limit: query.limit
|
|
@@ -2074,7 +2089,7 @@ var Creatives = class {
|
|
|
2074
2089
|
}
|
|
2075
2090
|
/** New head whose document is version `seq`'s (undo / redo). */
|
|
2076
2091
|
revert(id, seq, opts = {}) {
|
|
2077
|
-
return this.http.json(path$
|
|
2092
|
+
return this.http.json(path$5(id, "/revert"), {
|
|
2078
2093
|
method: "POST",
|
|
2079
2094
|
body: { seq },
|
|
2080
2095
|
ext: opts.ext,
|
|
@@ -2084,7 +2099,7 @@ var Creatives = class {
|
|
|
2084
2099
|
}
|
|
2085
2100
|
/** New creative from version `seq` (default the head). */
|
|
2086
2101
|
fork(id, body = {}, opts = {}) {
|
|
2087
|
-
return this.http.json(path$
|
|
2102
|
+
return this.http.json(path$5(id, "/fork"), {
|
|
2088
2103
|
method: "POST",
|
|
2089
2104
|
body,
|
|
2090
2105
|
ext: opts.ext,
|
|
@@ -2094,7 +2109,7 @@ var Creatives = class {
|
|
|
2094
2109
|
}
|
|
2095
2110
|
/** Soft-delete the creative. */
|
|
2096
2111
|
delete(id, opts = {}) {
|
|
2097
|
-
return this.http.json(path$
|
|
2112
|
+
return this.http.json(path$5(id), {
|
|
2098
2113
|
method: "DELETE",
|
|
2099
2114
|
ext: opts.ext,
|
|
2100
2115
|
signal: opts.signal
|
|
@@ -2107,7 +2122,7 @@ var Creatives = class {
|
|
|
2107
2122
|
* `text_overflow_locale`); 404 `Locale not found.` for an unknown locale.
|
|
2108
2123
|
*/
|
|
2109
2124
|
lint(id, body = {}, opts = {}) {
|
|
2110
|
-
return this.http.json(path$
|
|
2125
|
+
return this.http.json(path$5(id, "/lint"), {
|
|
2111
2126
|
method: "POST",
|
|
2112
2127
|
...body.locale !== void 0 ? { body: { locale: body.locale } } : {},
|
|
2113
2128
|
ext: opts.ext,
|
|
@@ -2116,7 +2131,7 @@ var Creatives = class {
|
|
|
2116
2131
|
}
|
|
2117
2132
|
/** Preview HTML (signed asset URLs) for `format` / one `scene` / a translation (`locale`). */
|
|
2118
2133
|
compiled(id, query = {}, opts = {}) {
|
|
2119
|
-
return this.http.json(path$
|
|
2134
|
+
return this.http.json(path$5(id, "/compiled"), {
|
|
2120
2135
|
query: {
|
|
2121
2136
|
format: query.format,
|
|
2122
2137
|
scene: query.scene,
|
|
@@ -2135,7 +2150,7 @@ var Creatives = class {
|
|
|
2135
2150
|
* `corner` when the creative uses TTS narration or AI images, else `none` (`none` with narration: 400 `ai_label_required`).
|
|
2136
2151
|
*/
|
|
2137
2152
|
render(id, body = {}, opts = {}) {
|
|
2138
|
-
return this.http.json(path$
|
|
2153
|
+
return this.http.json(path$5(id, "/render"), {
|
|
2139
2154
|
method: "POST",
|
|
2140
2155
|
body,
|
|
2141
2156
|
ext: opts.ext,
|
|
@@ -2150,7 +2165,7 @@ var Creatives = class {
|
|
|
2150
2165
|
* jobs per UTC day are free, then billed (`billed_micro_usd`).
|
|
2151
2166
|
*/
|
|
2152
2167
|
frame(id, body, opts = {}) {
|
|
2153
|
-
return this.http.json(path$
|
|
2168
|
+
return this.http.json(path$5(id, "/frame"), {
|
|
2154
2169
|
method: "POST",
|
|
2155
2170
|
body,
|
|
2156
2171
|
ext: opts.ext,
|
|
@@ -2165,7 +2180,7 @@ var Creatives = class {
|
|
|
2165
2180
|
* Token-metered like any `codai` text call.
|
|
2166
2181
|
*/
|
|
2167
2182
|
comment(id, body, opts = {}) {
|
|
2168
|
-
return this.http.json(path$
|
|
2183
|
+
return this.http.json(path$5(id, "/comments"), {
|
|
2169
2184
|
method: "POST",
|
|
2170
2185
|
body,
|
|
2171
2186
|
ext: opts.ext,
|
|
@@ -2180,7 +2195,7 @@ var Creatives = class {
|
|
|
2180
2195
|
* until `pickVariant`. 422 `no_edit` when no valid variant came back, 504 `timeout` after 90 s. Token-metered.
|
|
2181
2196
|
*/
|
|
2182
2197
|
variants(id, body, opts = {}) {
|
|
2183
|
-
return this.http.json(path$
|
|
2198
|
+
return this.http.json(path$5(id, "/variants"), {
|
|
2184
2199
|
method: "POST",
|
|
2185
2200
|
body,
|
|
2186
2201
|
ext: opts.ext,
|
|
@@ -2190,7 +2205,7 @@ var Creatives = class {
|
|
|
2190
2205
|
}
|
|
2191
2206
|
/** The latest variant group of a creative (`group_id: null` when none) with statuses and stored render state. */
|
|
2192
2207
|
listVariants(id, opts = {}) {
|
|
2193
|
-
return this.http.json(path$
|
|
2208
|
+
return this.http.json(path$5(id, "/variants"), {
|
|
2194
2209
|
ext: opts.ext,
|
|
2195
2210
|
signal: opts.signal
|
|
2196
2211
|
});
|
|
@@ -2200,7 +2215,7 @@ var Creatives = class {
|
|
|
2200
2215
|
* else); the winner is marked `winner`, the rest of its group `rejected`.
|
|
2201
2216
|
*/
|
|
2202
2217
|
pickVariant(id, variantId, body, opts = {}) {
|
|
2203
|
-
return this.http.json(path$
|
|
2218
|
+
return this.http.json(path$5(id, `/variants/${encodeURIComponent(variantId)}/pick`), {
|
|
2204
2219
|
method: "POST",
|
|
2205
2220
|
body,
|
|
2206
2221
|
ext: opts.ext,
|
|
@@ -2214,7 +2229,7 @@ var Creatives = class {
|
|
|
2214
2229
|
* 400 `node_not_found` / `invalid_pick` / `duplicate_key`. Free.
|
|
2215
2230
|
*/
|
|
2216
2231
|
saveTemplate(id, body, opts = {}) {
|
|
2217
|
-
return this.http.json(path$
|
|
2232
|
+
return this.http.json(path$5(id, "/template"), {
|
|
2218
2233
|
method: "POST",
|
|
2219
2234
|
body,
|
|
2220
2235
|
ext: opts.ext,
|
|
@@ -2229,7 +2244,7 @@ var Creatives = class {
|
|
|
2229
2244
|
* rendered seconds are billed (final render price). 400 `unsupported_kind` / `unsupported_format` / `too_long`.
|
|
2230
2245
|
*/
|
|
2231
2246
|
exportFcpxml(id, query = {}, opts = {}) {
|
|
2232
|
-
return this.http.json(path$
|
|
2247
|
+
return this.http.json(path$5(id, "/export.fcpxml"), {
|
|
2233
2248
|
query: {
|
|
2234
2249
|
format: query.format,
|
|
2235
2250
|
seq: query.seq
|
|
@@ -2247,7 +2262,7 @@ var Creatives = class {
|
|
|
2247
2262
|
* 400 `unsupported_kind` / `invalid_request`, 413 `too_large` (over 20 MB).
|
|
2248
2263
|
*/
|
|
2249
2264
|
exportLottie(id, query = {}, opts = {}) {
|
|
2250
|
-
return this.http.json(path$
|
|
2265
|
+
return this.http.json(path$5(id, "/export.lottie"), {
|
|
2251
2266
|
query: lottieQuery(query),
|
|
2252
2267
|
ext: opts.ext,
|
|
2253
2268
|
signal: opts.signal,
|
|
@@ -2259,7 +2274,7 @@ var Creatives = class {
|
|
|
2259
2274
|
* for a dotLottie archive or a zip of JSON files (`formats: 'all'`). Same options and errors as `exportLottie`. Free.
|
|
2260
2275
|
*/
|
|
2261
2276
|
async downloadLottie(id, query = {}, opts = {}) {
|
|
2262
|
-
const res = await this.http.request(path$
|
|
2277
|
+
const res = await this.http.request(path$5(id, "/export.lottie"), {
|
|
2263
2278
|
query: {
|
|
2264
2279
|
...lottieQuery(query),
|
|
2265
2280
|
download: "1"
|
|
@@ -2295,7 +2310,7 @@ var Creatives = class {
|
|
|
2295
2310
|
* `documents.waitForPreview`). 400 `not_supported_for_kind` (video / image) or `invalid_spec`.
|
|
2296
2311
|
*/
|
|
2297
2312
|
build(id, body = {}, opts = {}) {
|
|
2298
|
-
return this.http.json(path$
|
|
2313
|
+
return this.http.json(path$5(id, "/build"), {
|
|
2299
2314
|
method: "POST",
|
|
2300
2315
|
body: stripUndefined(body),
|
|
2301
2316
|
ext: opts.ext,
|
|
@@ -2310,7 +2325,7 @@ var Creatives = class {
|
|
|
2310
2325
|
* logo is registered too. `base_seq` defaults to the head (rebased like `edit`, 409 `stale` else). Free.
|
|
2311
2326
|
*/
|
|
2312
2327
|
restyle(id, body, opts = {}) {
|
|
2313
|
-
return this.http.json(path$
|
|
2328
|
+
return this.http.json(path$5(id, "/restyle"), {
|
|
2314
2329
|
method: "POST",
|
|
2315
2330
|
body: stripUndefined(body),
|
|
2316
2331
|
ext: opts.ext,
|
|
@@ -2326,7 +2341,7 @@ var Creatives = class {
|
|
|
2326
2341
|
* `unsupported_kind`); 403 `residency_unavailable`, 503 `transcription_unavailable`.
|
|
2327
2342
|
*/
|
|
2328
2343
|
captions(id, body = {}, opts = {}) {
|
|
2329
|
-
return this.http.json(path$
|
|
2344
|
+
return this.http.json(path$5(id, "/captions"), {
|
|
2330
2345
|
method: "POST",
|
|
2331
2346
|
body: stripUndefined(body),
|
|
2332
2347
|
ext: opts.ext,
|
|
@@ -2336,7 +2351,7 @@ var Creatives = class {
|
|
|
2336
2351
|
}
|
|
2337
2352
|
/** The captions as SubRip text on the document timeline (`node_id`, `seq` optional); 404 without captions. Free. */
|
|
2338
2353
|
async captionsSrt(id, query = {}, opts = {}) {
|
|
2339
|
-
return (await this.http.request(path$
|
|
2354
|
+
return (await this.http.request(path$5(id, "/captions.srt"), {
|
|
2340
2355
|
query: {
|
|
2341
2356
|
node_id: query.node_id,
|
|
2342
2357
|
seq: query.seq,
|
|
@@ -2348,7 +2363,7 @@ var Creatives = class {
|
|
|
2348
2363
|
}
|
|
2349
2364
|
/** The captions as WebVTT text on the document timeline (`node_id`, `seq` optional); 404 without captions. Free. */
|
|
2350
2365
|
async captionsVtt(id, query = {}, opts = {}) {
|
|
2351
|
-
return (await this.http.request(path$
|
|
2366
|
+
return (await this.http.request(path$5(id, "/captions.vtt"), {
|
|
2352
2367
|
query: {
|
|
2353
2368
|
node_id: query.node_id,
|
|
2354
2369
|
seq: query.seq,
|
|
@@ -2364,7 +2379,7 @@ var Creatives = class {
|
|
|
2364
2379
|
* `focal: 'vision'` (token-metered) finds the focal point of full-bleed images; it fails open. Free otherwise.
|
|
2365
2380
|
*/
|
|
2366
2381
|
adapt(id, body, opts = {}) {
|
|
2367
|
-
return this.http.json(path$
|
|
2382
|
+
return this.http.json(path$5(id, "/adapt"), {
|
|
2368
2383
|
method: "POST",
|
|
2369
2384
|
body: stripUndefined(body),
|
|
2370
2385
|
ext: opts.ext,
|
|
@@ -2378,7 +2393,7 @@ var Creatives = class {
|
|
|
2378
2393
|
* to one `codai` turn. Nothing to fix: the current `seq`, empty `fixed`, no new version.
|
|
2379
2394
|
*/
|
|
2380
2395
|
lintFix(id, body = {}, opts = {}) {
|
|
2381
|
-
return this.http.json(path$
|
|
2396
|
+
return this.http.json(path$5(id, "/lint/fix"), {
|
|
2382
2397
|
method: "POST",
|
|
2383
2398
|
body: stripUndefined(body),
|
|
2384
2399
|
ext: opts.ext,
|
|
@@ -2391,7 +2406,7 @@ var Creatives = class {
|
|
|
2391
2406
|
* values with a `setVar` op and controls with a `setControl` op (`edit`). Free.
|
|
2392
2407
|
*/
|
|
2393
2408
|
controls(id, opts = {}) {
|
|
2394
|
-
return this.http.json(path$
|
|
2409
|
+
return this.http.json(path$5(id, "/controls"), {
|
|
2395
2410
|
ext: opts.ext,
|
|
2396
2411
|
signal: opts.signal
|
|
2397
2412
|
});
|
|
@@ -2401,7 +2416,7 @@ var Creatives = class {
|
|
|
2401
2416
|
* With `locale` (+ `units`, default 1) also the units of that locale (paged with `offset` / `limit` ≤ 500). Free.
|
|
2402
2417
|
*/
|
|
2403
2418
|
locales(id, query = {}, opts = {}) {
|
|
2404
|
-
return this.http.json(path$
|
|
2419
|
+
return this.http.json(path$5(id, "/locales"), {
|
|
2405
2420
|
query: {
|
|
2406
2421
|
locale: query.locale,
|
|
2407
2422
|
units: query.units,
|
|
@@ -2419,7 +2434,7 @@ var Creatives = class {
|
|
|
2419
2434
|
* 400 `nothing_to_translate`; 503 `localize_unavailable` when every locale failed.
|
|
2420
2435
|
*/
|
|
2421
2436
|
localize(id, body, opts = {}) {
|
|
2422
|
-
return this.http.json(path$
|
|
2437
|
+
return this.http.json(path$5(id, "/localize"), {
|
|
2423
2438
|
method: "POST",
|
|
2424
2439
|
body: stripUndefined(body),
|
|
2425
2440
|
ext: opts.ext,
|
|
@@ -2432,7 +2447,7 @@ var Creatives = class {
|
|
|
2432
2447
|
* title `<title> (<locale>)`). 404 `Locale not found.`. Free (HTTP 201).
|
|
2433
2448
|
*/
|
|
2434
2449
|
forkLocale(id, locale, body = {}, opts = {}) {
|
|
2435
|
-
return this.http.json(path$
|
|
2450
|
+
return this.http.json(path$5(id, `/locales/${encodeURIComponent(locale)}/fork`), {
|
|
2436
2451
|
method: "POST",
|
|
2437
2452
|
body: stripUndefined(body),
|
|
2438
2453
|
ext: opts.ext,
|
|
@@ -2446,7 +2461,7 @@ var Creatives = class {
|
|
|
2446
2461
|
* only in this answer (HTTP 201). 400 `unknown_seq`; 409 `too_many_shares` (20 active links). Free.
|
|
2447
2462
|
*/
|
|
2448
2463
|
createShare(id, body, opts = {}) {
|
|
2449
|
-
return this.http.json(path$
|
|
2464
|
+
return this.http.json(path$5(id, "/shares"), {
|
|
2450
2465
|
method: "POST",
|
|
2451
2466
|
body: stripUndefined(body),
|
|
2452
2467
|
ext: opts.ext,
|
|
@@ -2456,14 +2471,14 @@ var Creatives = class {
|
|
|
2456
2471
|
}
|
|
2457
2472
|
/** The active links (not revoked, not expired), newest first; `url` is always null. Free. */
|
|
2458
2473
|
listShares(id, opts = {}) {
|
|
2459
|
-
return this.http.json(path$
|
|
2474
|
+
return this.http.json(path$5(id, "/shares"), {
|
|
2460
2475
|
ext: opts.ext,
|
|
2461
2476
|
signal: opts.signal
|
|
2462
2477
|
});
|
|
2463
2478
|
}
|
|
2464
2479
|
/** Revoke a link: it answers 404 from now on. 404 when unknown or already revoked. Free. */
|
|
2465
2480
|
async revokeShare(id, shareId, opts = {}) {
|
|
2466
|
-
await this.http.request(path$
|
|
2481
|
+
await this.http.request(path$5(id, `/shares/${encodeURIComponent(shareId)}`), {
|
|
2467
2482
|
method: "DELETE",
|
|
2468
2483
|
ext: opts.ext,
|
|
2469
2484
|
signal: opts.signal
|
|
@@ -2474,14 +2489,14 @@ var Creatives = class {
|
|
|
2474
2489
|
* version (`approved_is_head` false once the creative changed), decider and thread counts. Free.
|
|
2475
2490
|
*/
|
|
2476
2491
|
review(id, opts = {}) {
|
|
2477
|
-
return this.http.json(path$
|
|
2492
|
+
return this.http.json(path$5(id, "/review"), {
|
|
2478
2493
|
ext: opts.ext,
|
|
2479
2494
|
signal: opts.signal
|
|
2480
2495
|
});
|
|
2481
2496
|
}
|
|
2482
2497
|
/** Send the head to review (`in_review`, earlier decision cleared) so approver links can decide. Free. */
|
|
2483
2498
|
requestReview(id, opts = {}) {
|
|
2484
|
-
return this.http.json(path$
|
|
2499
|
+
return this.http.json(path$5(id, "/review"), {
|
|
2485
2500
|
method: "POST",
|
|
2486
2501
|
body: { action: "request" },
|
|
2487
2502
|
ext: opts.ext,
|
|
@@ -2490,7 +2505,7 @@ var Creatives = class {
|
|
|
2490
2505
|
}
|
|
2491
2506
|
/** Back to `draft` (decision cleared, comments kept). Free. */
|
|
2492
2507
|
resetReview(id, opts = {}) {
|
|
2493
|
-
return this.http.json(path$
|
|
2508
|
+
return this.http.json(path$5(id, "/review"), {
|
|
2494
2509
|
method: "POST",
|
|
2495
2510
|
body: { action: "reset" },
|
|
2496
2511
|
ext: opts.ext,
|
|
@@ -2499,7 +2514,7 @@ var Creatives = class {
|
|
|
2499
2514
|
}
|
|
2500
2515
|
/** Comment threads, newest first (≤ 200), replies oldest first; `status` `open` | `resolved` | `all`. Free. */
|
|
2501
2516
|
reviewThreads(id, query = {}, opts = {}) {
|
|
2502
|
-
return this.http.json(path$
|
|
2517
|
+
return this.http.json(path$5(id, "/review/threads"), {
|
|
2503
2518
|
query: { status: query.status },
|
|
2504
2519
|
ext: opts.ext,
|
|
2505
2520
|
signal: opts.signal
|
|
@@ -2510,7 +2525,7 @@ var Creatives = class {
|
|
|
2510
2525
|
* 400 `unknown_node` / `unknown_scene`; HTTP 201). 409 `too_many_comments`. Free.
|
|
2511
2526
|
*/
|
|
2512
2527
|
createReviewThread(id, body, opts = {}) {
|
|
2513
|
-
return this.http.json(path$
|
|
2528
|
+
return this.http.json(path$5(id, "/review/threads"), {
|
|
2514
2529
|
method: "POST",
|
|
2515
2530
|
body: stripUndefined(body),
|
|
2516
2531
|
ext: opts.ext,
|
|
@@ -2520,7 +2535,7 @@ var Creatives = class {
|
|
|
2520
2535
|
}
|
|
2521
2536
|
/** Reply in a thread as the owner (HTTP 201) — returns the whole thread. Free. */
|
|
2522
2537
|
replyReviewThread(id, threadId, body, opts = {}) {
|
|
2523
|
-
return this.http.json(path$
|
|
2538
|
+
return this.http.json(path$5(id, `/review/threads/${encodeURIComponent(threadId)}/replies`), {
|
|
2524
2539
|
method: "POST",
|
|
2525
2540
|
body: { body: body.body },
|
|
2526
2541
|
ext: opts.ext,
|
|
@@ -2530,7 +2545,7 @@ var Creatives = class {
|
|
|
2530
2545
|
}
|
|
2531
2546
|
/** Resolve a thread. Free. */
|
|
2532
2547
|
resolveReviewThread(id, threadId, opts = {}) {
|
|
2533
|
-
return this.http.json(path$
|
|
2548
|
+
return this.http.json(path$5(id, `/review/threads/${encodeURIComponent(threadId)}/resolve`), {
|
|
2534
2549
|
method: "POST",
|
|
2535
2550
|
ext: opts.ext,
|
|
2536
2551
|
signal: opts.signal
|
|
@@ -2538,7 +2553,7 @@ var Creatives = class {
|
|
|
2538
2553
|
}
|
|
2539
2554
|
/** Reopen a resolved thread. Free. */
|
|
2540
2555
|
reopenReviewThread(id, threadId, opts = {}) {
|
|
2541
|
-
return this.http.json(path$
|
|
2556
|
+
return this.http.json(path$5(id, `/review/threads/${encodeURIComponent(threadId)}/reopen`), {
|
|
2542
2557
|
method: "POST",
|
|
2543
2558
|
ext: opts.ext,
|
|
2544
2559
|
signal: opts.signal
|
|
@@ -2546,7 +2561,7 @@ var Creatives = class {
|
|
|
2546
2561
|
}
|
|
2547
2562
|
/** Delete any comment (owner moderation; deleting a root hides the thread). 404 when unknown. Free. */
|
|
2548
2563
|
async deleteReviewComment(id, commentId, opts = {}) {
|
|
2549
|
-
await this.http.request(path$
|
|
2564
|
+
await this.http.request(path$5(id, `/review/comments/${encodeURIComponent(commentId)}`), {
|
|
2550
2565
|
method: "DELETE",
|
|
2551
2566
|
ext: opts.ext,
|
|
2552
2567
|
signal: opts.signal
|
|
@@ -2554,7 +2569,7 @@ var Creatives = class {
|
|
|
2554
2569
|
}
|
|
2555
2570
|
/** Poll a frame job: frames when done (`status: 'succeeded'`), `status: 'running'` meanwhile; 404 unknown job. */
|
|
2556
2571
|
frameJob(id, jobId, opts = {}) {
|
|
2557
|
-
return this.http.json(path$
|
|
2572
|
+
return this.http.json(path$5(id, `/frames/${encodeURIComponent(jobId)}`), {
|
|
2558
2573
|
ext: opts.ext,
|
|
2559
2574
|
signal: opts.signal
|
|
2560
2575
|
});
|
|
@@ -2563,7 +2578,7 @@ var Creatives = class {
|
|
|
2563
2578
|
|
|
2564
2579
|
//#endregion
|
|
2565
2580
|
//#region src/resources/brand-kits.ts
|
|
2566
|
-
const path$
|
|
2581
|
+
const path$4 = (id, tail = "") => `/v1/studio/brand-kits/${encodeURIComponent(id)}${tail}`;
|
|
2567
2582
|
var BrandKits = class {
|
|
2568
2583
|
http;
|
|
2569
2584
|
constructor(http) {
|
|
@@ -2588,7 +2603,7 @@ var BrandKits = class {
|
|
|
2588
2603
|
* `logo_asset_id: null` removes the logo. Creatives keep their tokens until `creatives.restyle`. Free.
|
|
2589
2604
|
*/
|
|
2590
2605
|
update(id, body, opts = {}) {
|
|
2591
|
-
return this.http.json(path$
|
|
2606
|
+
return this.http.json(path$4(id), {
|
|
2592
2607
|
method: "PATCH",
|
|
2593
2608
|
body,
|
|
2594
2609
|
ext: opts.ext,
|
|
@@ -2598,7 +2613,7 @@ var BrandKits = class {
|
|
|
2598
2613
|
}
|
|
2599
2614
|
/** The kit as a DTCG 2025.10 JSON document (`$extensions['ro.codai']` = kit id, name, logo asset id). Free. */
|
|
2600
2615
|
exportDtcg(id, opts = {}) {
|
|
2601
|
-
return this.http.json(path$
|
|
2616
|
+
return this.http.json(path$4(id, "/dtcg"), {
|
|
2602
2617
|
ext: opts.ext,
|
|
2603
2618
|
signal: opts.signal
|
|
2604
2619
|
});
|
|
@@ -2628,14 +2643,14 @@ var BrandKits = class {
|
|
|
2628
2643
|
}
|
|
2629
2644
|
/** One kit with a signed logo URL (1 h), its `dtcg` and the WCAG `contrast` pairs. Free. */
|
|
2630
2645
|
retrieve(id, opts = {}) {
|
|
2631
|
-
return this.http.json(path$
|
|
2646
|
+
return this.http.json(path$4(id), {
|
|
2632
2647
|
ext: opts.ext,
|
|
2633
2648
|
signal: opts.signal
|
|
2634
2649
|
});
|
|
2635
2650
|
}
|
|
2636
2651
|
/** Delete a kit (creatives keep their tokens; the logo asset stays). Free. */
|
|
2637
2652
|
delete(id, opts = {}) {
|
|
2638
|
-
return this.http.json(path$
|
|
2653
|
+
return this.http.json(path$4(id), {
|
|
2639
2654
|
method: "DELETE",
|
|
2640
2655
|
ext: opts.ext,
|
|
2641
2656
|
signal: opts.signal
|
|
@@ -2645,18 +2660,26 @@ var BrandKits = class {
|
|
|
2645
2660
|
|
|
2646
2661
|
//#endregion
|
|
2647
2662
|
//#region src/resources/templates.ts
|
|
2648
|
-
const path$
|
|
2663
|
+
const path$3 = (id) => `/v1/studio/templates/${encodeURIComponent(id)}`;
|
|
2649
2664
|
var Templates = class {
|
|
2650
2665
|
http;
|
|
2651
2666
|
constructor(http) {
|
|
2652
2667
|
this.http = http;
|
|
2653
2668
|
}
|
|
2654
|
-
/**
|
|
2669
|
+
/**
|
|
2670
|
+
* Your templates (newest first; `limit` 1–100, default 50), then the built-in starters in `locale` (`en` | `ro`,
|
|
2671
|
+
* default from Accept-Language) with in-season ones first (`month` 1–12). `source`: `own` | `starter` | `all`
|
|
2672
|
+
* (default). `kind` filters both. Without `doc`. Free. A starter id works anywhere a template id does
|
|
2673
|
+
* (`retrieve`, `creatives.create({ template })`, batches); starters cannot be deleted.
|
|
2674
|
+
*/
|
|
2655
2675
|
list(query = {}, opts = {}) {
|
|
2656
2676
|
return this.http.json("/v1/studio/templates", {
|
|
2657
2677
|
query: {
|
|
2658
2678
|
kind: query.kind,
|
|
2659
|
-
limit: query.limit
|
|
2679
|
+
limit: query.limit,
|
|
2680
|
+
source: query.source,
|
|
2681
|
+
locale: query.locale,
|
|
2682
|
+
month: query.month
|
|
2660
2683
|
},
|
|
2661
2684
|
ext: opts.ext,
|
|
2662
2685
|
signal: opts.signal
|
|
@@ -2664,14 +2687,14 @@ var Templates = class {
|
|
|
2664
2687
|
}
|
|
2665
2688
|
/** One template with its variables and `doc`. Free. */
|
|
2666
2689
|
retrieve(id, opts = {}) {
|
|
2667
|
-
return this.http.json(path$
|
|
2690
|
+
return this.http.json(path$3(id), {
|
|
2668
2691
|
ext: opts.ext,
|
|
2669
2692
|
signal: opts.signal
|
|
2670
2693
|
});
|
|
2671
2694
|
}
|
|
2672
2695
|
/** Delete a template (creatives made from it are not affected). Free. */
|
|
2673
2696
|
delete(id, opts = {}) {
|
|
2674
|
-
return this.http.json(path$
|
|
2697
|
+
return this.http.json(path$3(id), {
|
|
2675
2698
|
method: "DELETE",
|
|
2676
2699
|
ext: opts.ext,
|
|
2677
2700
|
signal: opts.signal
|
|
@@ -2679,6 +2702,68 @@ var Templates = class {
|
|
|
2679
2702
|
}
|
|
2680
2703
|
};
|
|
2681
2704
|
|
|
2705
|
+
//#endregion
|
|
2706
|
+
//#region src/resources/productions.ts
|
|
2707
|
+
const path$2 = (id) => `/v1/studio/productions/${encodeURIComponent(id)}`;
|
|
2708
|
+
function abortableSleep$3(ms, signal) {
|
|
2709
|
+
return new Promise((resolve, reject) => {
|
|
2710
|
+
if (signal?.aborted) return reject(signal.reason ?? /* @__PURE__ */ new Error("Aborted"));
|
|
2711
|
+
const t = setTimeout(() => {
|
|
2712
|
+
signal?.removeEventListener("abort", onAbort);
|
|
2713
|
+
resolve();
|
|
2714
|
+
}, ms);
|
|
2715
|
+
const onAbort = () => {
|
|
2716
|
+
clearTimeout(t);
|
|
2717
|
+
reject(signal?.reason ?? /* @__PURE__ */ new Error("Aborted"));
|
|
2718
|
+
};
|
|
2719
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
2720
|
+
});
|
|
2721
|
+
}
|
|
2722
|
+
const isProductionFinished = (p) => p.status === "succeeded" || p.status === "failed";
|
|
2723
|
+
var Productions = class {
|
|
2724
|
+
http;
|
|
2725
|
+
constructor(http) {
|
|
2726
|
+
this.http = http;
|
|
2727
|
+
}
|
|
2728
|
+
/** `POST /v1/studio/productions` — brief → storyboard → assets → creative → queued draft render (202). */
|
|
2729
|
+
create(body, opts = {}) {
|
|
2730
|
+
return this.http.json("/v1/studio/productions", {
|
|
2731
|
+
method: "POST",
|
|
2732
|
+
body,
|
|
2733
|
+
headers: opts.idempotencyKey ? { "Idempotency-Key": opts.idempotencyKey } : void 0,
|
|
2734
|
+
noRetry: !opts.idempotencyKey,
|
|
2735
|
+
ext: opts.ext,
|
|
2736
|
+
signal: opts.signal
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2739
|
+
/** `GET /v1/studio/productions/{id}` — advances the production and returns it (another account's id is a 404). */
|
|
2740
|
+
retrieve(id, opts = {}) {
|
|
2741
|
+
return this.http.json(path$2(id), {
|
|
2742
|
+
ext: opts.ext,
|
|
2743
|
+
signal: opts.signal
|
|
2744
|
+
});
|
|
2745
|
+
}
|
|
2746
|
+
/**
|
|
2747
|
+
* Poll `retrieve` every `intervalMs` (default 5 s) until the production `succeeded` or `failed` (a failed one
|
|
2748
|
+
* resolves too — check `status` / `error`). Throws after `timeoutMs` (default 10 min) or when `signal` aborts.
|
|
2749
|
+
*/
|
|
2750
|
+
async wait(id, opts = {}) {
|
|
2751
|
+
const interval = opts.intervalMs ?? 5e3;
|
|
2752
|
+
const deadline = Date.now() + (opts.timeoutMs ?? 6e5);
|
|
2753
|
+
for (;;) {
|
|
2754
|
+
const p = await this.retrieve(id, opts);
|
|
2755
|
+
if (isProductionFinished(p)) return p;
|
|
2756
|
+
if (Date.now() + interval > deadline) throw new Error(`codai: production ${id} did not finish in time (phase ${p.phase})`);
|
|
2757
|
+
await abortableSleep$3(interval, opts.signal);
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
/** `create` + `wait`. */
|
|
2761
|
+
async run(body, opts = {}) {
|
|
2762
|
+
const p = await this.create(body, opts);
|
|
2763
|
+
return isProductionFinished(p) ? p : this.wait(p.id, opts);
|
|
2764
|
+
}
|
|
2765
|
+
};
|
|
2766
|
+
|
|
2682
2767
|
//#endregion
|
|
2683
2768
|
//#region src/resources/batches.ts
|
|
2684
2769
|
const BATCH_DONE = [
|
|
@@ -2686,8 +2771,8 @@ const BATCH_DONE = [
|
|
|
2686
2771
|
"failed",
|
|
2687
2772
|
"cancelled"
|
|
2688
2773
|
];
|
|
2689
|
-
const path = (id, tail = "") => `/v1/studio/batches/${encodeURIComponent(id)}${tail}`;
|
|
2690
|
-
function abortableSleep$
|
|
2774
|
+
const path$1 = (id, tail = "") => `/v1/studio/batches/${encodeURIComponent(id)}${tail}`;
|
|
2775
|
+
function abortableSleep$2(ms, signal) {
|
|
2691
2776
|
return new Promise((resolve, reject) => {
|
|
2692
2777
|
if (signal?.aborted) return reject(signal.reason ?? /* @__PURE__ */ new Error("Aborted"));
|
|
2693
2778
|
const t = setTimeout(() => {
|
|
@@ -2747,7 +2832,7 @@ var Batches = class {
|
|
|
2747
2832
|
}
|
|
2748
2833
|
/** The batch (`rows: 1` adds rows; `status`, `offset`, `limit` ≤ 100). Each poll advances it a little. Free. */
|
|
2749
2834
|
get(id, query = {}, opts = {}) {
|
|
2750
|
-
return this.http.json(path(id), {
|
|
2835
|
+
return this.http.json(path$1(id), {
|
|
2751
2836
|
query: {
|
|
2752
2837
|
rows: query.rows,
|
|
2753
2838
|
status: query.status,
|
|
@@ -2760,7 +2845,7 @@ var Batches = class {
|
|
|
2760
2845
|
}
|
|
2761
2846
|
/** Stop the batch; rows not started become `skipped`. 409 `not_cancellable` when already finished. Free. */
|
|
2762
2847
|
cancel(id, opts = {}) {
|
|
2763
|
-
return this.http.json(path(id, "/cancel"), {
|
|
2848
|
+
return this.http.json(path$1(id, "/cancel"), {
|
|
2764
2849
|
method: "POST",
|
|
2765
2850
|
ext: opts.ext,
|
|
2766
2851
|
signal: opts.signal,
|
|
@@ -2769,7 +2854,7 @@ var Batches = class {
|
|
|
2769
2854
|
}
|
|
2770
2855
|
/** Queue the failed rows again (≤ 3 attempts each). 409 `nothing_to_retry`. Free. */
|
|
2771
2856
|
retry(id, opts = {}) {
|
|
2772
|
-
return this.http.json(path(id, "/retry"), {
|
|
2857
|
+
return this.http.json(path$1(id, "/retry"), {
|
|
2773
2858
|
method: "POST",
|
|
2774
2859
|
ext: opts.ext,
|
|
2775
2860
|
signal: opts.signal,
|
|
@@ -2778,7 +2863,7 @@ var Batches = class {
|
|
|
2778
2863
|
}
|
|
2779
2864
|
/** The original CSV plus `creative_id`, `status`, `error`, `render_url` per row (formula-safe). Free. */
|
|
2780
2865
|
async exportCsv(id, opts = {}) {
|
|
2781
|
-
return (await this.http.request(path(id, "/export.csv"), {
|
|
2866
|
+
return (await this.http.request(path$1(id, "/export.csv"), {
|
|
2782
2867
|
ext: opts.ext,
|
|
2783
2868
|
signal: opts.signal
|
|
2784
2869
|
})).text();
|
|
@@ -2788,7 +2873,7 @@ var Batches = class {
|
|
|
2788
2873
|
* ready). Poll `get` until `zip.status` is `ready` (signed `zip.url`). 409 `no_renders`. Free.
|
|
2789
2874
|
*/
|
|
2790
2875
|
zip(id, opts = {}) {
|
|
2791
|
-
return this.http.json(path(id, "/zip"), {
|
|
2876
|
+
return this.http.json(path$1(id, "/zip"), {
|
|
2792
2877
|
method: "POST",
|
|
2793
2878
|
ext: opts.ext,
|
|
2794
2879
|
signal: opts.signal,
|
|
@@ -2809,7 +2894,7 @@ var Batches = class {
|
|
|
2809
2894
|
});
|
|
2810
2895
|
if (BATCH_DONE.includes(batch.status)) return batch;
|
|
2811
2896
|
if (Date.now() + intervalMs > deadline) throw new Error(`codai batch ${id} did not finish within ${timeoutMs} ms`);
|
|
2812
|
-
await abortableSleep$
|
|
2897
|
+
await abortableSleep$2(intervalMs, signal);
|
|
2813
2898
|
}
|
|
2814
2899
|
}
|
|
2815
2900
|
};
|
|
@@ -2949,6 +3034,183 @@ var VoiceRevocations = class {
|
|
|
2949
3034
|
}
|
|
2950
3035
|
};
|
|
2951
3036
|
|
|
3037
|
+
//#endregion
|
|
3038
|
+
//#region src/resources/vault.ts
|
|
3039
|
+
const seg = (base, id, suffix = "") => `${base}/${encodeURIComponent(id)}${suffix}`;
|
|
3040
|
+
/** `/v1/vault/devices/*` — hardware-backed device approval keys (public keys only; revocation is instant). */
|
|
3041
|
+
var VaultDevices = class {
|
|
3042
|
+
http;
|
|
3043
|
+
constructor(http) {
|
|
3044
|
+
this.http = http;
|
|
3045
|
+
}
|
|
3046
|
+
/** `POST /v1/vault/devices/challenge` — single-use enrolment nonce, valid 5 minutes. */
|
|
3047
|
+
challenge(opts = {}) {
|
|
3048
|
+
return this.http.json("/v1/vault/devices/challenge", {
|
|
3049
|
+
method: "POST",
|
|
3050
|
+
body: {},
|
|
3051
|
+
ext: opts.ext,
|
|
3052
|
+
signal: opts.signal,
|
|
3053
|
+
noRetry: true
|
|
3054
|
+
});
|
|
3055
|
+
}
|
|
3056
|
+
/** `POST /v1/vault/devices` — enrol (or re-enrol) a device key; vault-signed, possession-proven, attested (201). */
|
|
3057
|
+
async enroll(body, opts = {}) {
|
|
3058
|
+
return (await this.http.json("/v1/vault/devices", {
|
|
3059
|
+
method: "POST",
|
|
3060
|
+
body: stripUndefined({ ...body }),
|
|
3061
|
+
ext: opts.ext,
|
|
3062
|
+
signal: opts.signal,
|
|
3063
|
+
noRetry: true
|
|
3064
|
+
})).device;
|
|
3065
|
+
}
|
|
3066
|
+
/** `GET /v1/vault/devices` — your device keys, revoked ones included, newest first. */
|
|
3067
|
+
async list(opts = {}) {
|
|
3068
|
+
return [...(await this.http.json("/v1/vault/devices", {
|
|
3069
|
+
ext: opts.ext,
|
|
3070
|
+
signal: opts.signal
|
|
3071
|
+
})).devices];
|
|
3072
|
+
}
|
|
3073
|
+
/** `PATCH /v1/vault/devices/{id}` — change the display name (1-80 characters). */
|
|
3074
|
+
async rename(id, name, opts = {}) {
|
|
3075
|
+
return (await this.http.json(seg("/v1/vault/devices", id), {
|
|
3076
|
+
method: "PATCH",
|
|
3077
|
+
body: { name },
|
|
3078
|
+
ext: opts.ext,
|
|
3079
|
+
signal: opts.signal,
|
|
3080
|
+
noRetry: true
|
|
3081
|
+
})).device;
|
|
3082
|
+
}
|
|
3083
|
+
/** `DELETE /v1/vault/devices/{id}` — revoke at once; later proofs answer 403 `device_revoked`. */
|
|
3084
|
+
revoke(id, opts = {}) {
|
|
3085
|
+
return this.http.json(seg("/v1/vault/devices", id), {
|
|
3086
|
+
method: "DELETE",
|
|
3087
|
+
ext: opts.ext,
|
|
3088
|
+
signal: opts.signal
|
|
3089
|
+
});
|
|
3090
|
+
}
|
|
3091
|
+
};
|
|
3092
|
+
var Vault = class {
|
|
3093
|
+
http;
|
|
3094
|
+
devices;
|
|
3095
|
+
constructor(http) {
|
|
3096
|
+
this.http = http;
|
|
3097
|
+
this.devices = new VaultDevices(http);
|
|
3098
|
+
}
|
|
3099
|
+
get(path, opts, query) {
|
|
3100
|
+
return this.http.json(path, {
|
|
3101
|
+
query,
|
|
3102
|
+
ext: opts.ext,
|
|
3103
|
+
signal: opts.signal
|
|
3104
|
+
});
|
|
3105
|
+
}
|
|
3106
|
+
send(method, path, opts, body) {
|
|
3107
|
+
return this.http.json(path, {
|
|
3108
|
+
method,
|
|
3109
|
+
...body ? { body: stripUndefined(body) } : {},
|
|
3110
|
+
ext: opts.ext,
|
|
3111
|
+
signal: opts.signal,
|
|
3112
|
+
noRetry: method !== "DELETE"
|
|
3113
|
+
});
|
|
3114
|
+
}
|
|
3115
|
+
/** `GET /v1/vault/account` — bundle, fingerprint, default tier, revision (404 `vault_not_setup` before setup). */
|
|
3116
|
+
account(opts = {}) {
|
|
3117
|
+
return this.get("/v1/vault/account", opts);
|
|
3118
|
+
}
|
|
3119
|
+
/** `PUT /v1/vault/account` — upload the client-built bundle; updates send the current `revision` (409 otherwise). */
|
|
3120
|
+
putAccount(body, opts = {}) {
|
|
3121
|
+
return this.send("PUT", "/v1/vault/account", opts, body);
|
|
3122
|
+
}
|
|
3123
|
+
/** `PATCH /v1/vault/settings` — default approval tier for items without a matching rule. */
|
|
3124
|
+
setDefaultTier(defaultTier, opts = {}) {
|
|
3125
|
+
return this.send("PATCH", "/v1/vault/settings", opts, { default_tier: defaultTier });
|
|
3126
|
+
}
|
|
3127
|
+
/** `GET /v1/vault/vaults` — vaults you belong to, with your role and sealed vault key. */
|
|
3128
|
+
vaults(opts = {}) {
|
|
3129
|
+
return this.get("/v1/vault/vaults", opts);
|
|
3130
|
+
}
|
|
3131
|
+
/** `POST /v1/vault/vaults` — register a vault created client-side (HTTP 201). */
|
|
3132
|
+
createVault(body, opts = {}) {
|
|
3133
|
+
return this.send("POST", "/v1/vault/vaults", opts, body);
|
|
3134
|
+
}
|
|
3135
|
+
/** `GET /v1/vault/items` — envelopes you can read; with `since` (ISO) only changes after it, tombstones included. */
|
|
3136
|
+
items(params = {}, opts = {}) {
|
|
3137
|
+
return this.get("/v1/vault/items", opts, { since: params.since });
|
|
3138
|
+
}
|
|
3139
|
+
/** `PUT /v1/vault/items/{id}` — store an envelope (new = revision 1, update = revision + 1, 409 otherwise). */
|
|
3140
|
+
putItem(id, envelope, opts = {}) {
|
|
3141
|
+
return this.send("PUT", seg("/v1/vault/items", id), opts, envelope);
|
|
3142
|
+
}
|
|
3143
|
+
/** `DELETE /v1/vault/items/{id}` — tombstone; revokes every grant on the item and drops its cloud copy. */
|
|
3144
|
+
deleteItem(id, opts = {}) {
|
|
3145
|
+
return this.send("DELETE", seg("/v1/vault/items", id), opts);
|
|
3146
|
+
}
|
|
3147
|
+
/** `PUT /v1/vault/items/{id}/cloud` — owner only: the decrypted item to seal with KMS for cloud agents, or null. */
|
|
3148
|
+
setItemCloud(id, item, opts = {}) {
|
|
3149
|
+
return this.http.json(seg("/v1/vault/items", id, "/cloud"), {
|
|
3150
|
+
method: "PUT",
|
|
3151
|
+
body: { item },
|
|
3152
|
+
ext: opts.ext,
|
|
3153
|
+
signal: opts.signal,
|
|
3154
|
+
noRetry: true
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3157
|
+
/** `GET /v1/vault/rules` — policy rules (item, agent glob, mode → tier). */
|
|
3158
|
+
rules(opts = {}) {
|
|
3159
|
+
return this.get("/v1/vault/rules", opts);
|
|
3160
|
+
}
|
|
3161
|
+
/** `POST /v1/vault/rules` — add a rule (HTTP 201). Host binding and honeytokens cannot be overridden. */
|
|
3162
|
+
createRule(body, opts = {}) {
|
|
3163
|
+
return this.send("POST", "/v1/vault/rules", opts, body);
|
|
3164
|
+
}
|
|
3165
|
+
/** `DELETE /v1/vault/rules/{id}`. */
|
|
3166
|
+
deleteRule(id, opts = {}) {
|
|
3167
|
+
return this.send("DELETE", seg("/v1/vault/rules", id), opts);
|
|
3168
|
+
}
|
|
3169
|
+
/** `GET /v1/vault/grants` — standing grants created by your approvals. */
|
|
3170
|
+
grants(opts = {}) {
|
|
3171
|
+
return this.get("/v1/vault/grants", opts);
|
|
3172
|
+
}
|
|
3173
|
+
/** `DELETE /v1/vault/grants/{id}` — revoke a grant immediately. */
|
|
3174
|
+
revokeGrant(id, opts = {}) {
|
|
3175
|
+
return this.send("DELETE", seg("/v1/vault/grants", id), opts);
|
|
3176
|
+
}
|
|
3177
|
+
/** `GET /v1/vault/events` — append-only audit log (never contains secret values). */
|
|
3178
|
+
events(params = {}, opts = {}) {
|
|
3179
|
+
return this.get("/v1/vault/events", opts, { limit: params.limit });
|
|
3180
|
+
}
|
|
3181
|
+
/** `GET /v1/vault/approvals` — agent requests waiting for your decision. */
|
|
3182
|
+
approvals(opts = {}) {
|
|
3183
|
+
return this.get("/v1/vault/approvals", opts);
|
|
3184
|
+
}
|
|
3185
|
+
/** `GET /v1/vault/approvals/{id}` — pending, approved, denied or expired. */
|
|
3186
|
+
approval(id, opts = {}) {
|
|
3187
|
+
return this.get(seg("/v1/vault/approvals", id), opts);
|
|
3188
|
+
}
|
|
3189
|
+
/**
|
|
3190
|
+
* `POST /v1/vault/approvals/{id}/decide` — send `signature` (v1 vault key) or `proof` (v2 device key / passkey),
|
|
3191
|
+
* never both. Deny needs no proof; a t4 approve needs a device or passkey proof (Wear: t3 only).
|
|
3192
|
+
*/
|
|
3193
|
+
decide(id, body, opts = {}) {
|
|
3194
|
+
return this.send("POST", seg("/v1/vault/approvals", id, "/decide"), opts, body);
|
|
3195
|
+
}
|
|
3196
|
+
/** `GET /v1/vault/catalog` — items exposed to agents (handle, title, kind, hosts, env name); no values. */
|
|
3197
|
+
catalog(opts = {}) {
|
|
3198
|
+
return this.get("/v1/vault/catalog", opts);
|
|
3199
|
+
}
|
|
3200
|
+
/** `POST /v1/vault/use` — a policy decision for one use; t3/t4 return a pending approval id. */
|
|
3201
|
+
use(body, opts = {}) {
|
|
3202
|
+
return this.send("POST", "/v1/vault/use", opts, body);
|
|
3203
|
+
}
|
|
3204
|
+
/** `POST /v1/vault/http` — brokered HTTPS call with `{{vault:<slug>}}` handles; 202 = approval required. */
|
|
3205
|
+
httpCall(body, opts = {}) {
|
|
3206
|
+
return this.send("POST", "/v1/vault/http", opts, body);
|
|
3207
|
+
}
|
|
3208
|
+
/** `POST /v1/vault/resolve` — codai local brokers only (cloud fallback of `codaid vault run`); 202 = approval. */
|
|
3209
|
+
resolve(body, opts = {}) {
|
|
3210
|
+
return this.send("POST", "/v1/vault/resolve", opts, body);
|
|
3211
|
+
}
|
|
3212
|
+
};
|
|
3213
|
+
|
|
2952
3214
|
//#endregion
|
|
2953
3215
|
//#region src/resources/abuse-reports.ts
|
|
2954
3216
|
var AbuseReports = class {
|
|
@@ -3770,7 +4032,7 @@ var Resolve = class {
|
|
|
3770
4032
|
if (until.has(job.status)) return job;
|
|
3771
4033
|
const left = deadline - Date.now();
|
|
3772
4034
|
if (left <= 0) throw new ResolveError(`codai-resolve job ${id} still ${job.status} after ${timeoutMs} ms`, 0, job);
|
|
3773
|
-
await abortableSleep(Math.min(intervalMs, left), opts.signal);
|
|
4035
|
+
await abortableSleep$1(Math.min(intervalMs, left), opts.signal);
|
|
3774
4036
|
}
|
|
3775
4037
|
}
|
|
3776
4038
|
async call(path, init) {
|
|
@@ -3808,7 +4070,7 @@ function toResolveError(path, err) {
|
|
|
3808
4070
|
const text = detail === null ? "" : `: ${typeof detail === "string" ? detail : JSON.stringify(detail)}`;
|
|
3809
4071
|
return new ResolveError(`codai-resolve ${path} → ${err.status}${text}`, err.status, err.body, meta);
|
|
3810
4072
|
}
|
|
3811
|
-
function abortableSleep(ms, signal) {
|
|
4073
|
+
function abortableSleep$1(ms, signal) {
|
|
3812
4074
|
return new Promise((resolve, reject) => {
|
|
3813
4075
|
if (signal?.aborted) return reject(signal.reason);
|
|
3814
4076
|
const onAbort = () => {
|
|
@@ -5066,7 +5328,11 @@ var Sandboxes = class {
|
|
|
5066
5328
|
this.http = http;
|
|
5067
5329
|
this.files = new SandboxFiles(http);
|
|
5068
5330
|
}
|
|
5069
|
-
/**
|
|
5331
|
+
/**
|
|
5332
|
+
* `POST /v1/sandboxes` — start a sandbox (`ttl_seconds` 60–86400, default 3600; `egress` none by default).
|
|
5333
|
+
* `backend: 'v2'` (closed canary) starts a long-lived pod with memory snapshots and accepts `template`
|
|
5334
|
+
* `codai-base` | `brivio-acte` | `desktop`; its reply may carry `restored`.
|
|
5335
|
+
*/
|
|
5070
5336
|
create(input = {}, opts = {}) {
|
|
5071
5337
|
return this.http.json("/v1/sandboxes", {
|
|
5072
5338
|
method: "POST",
|
|
@@ -5143,6 +5409,77 @@ var Sandboxes = class {
|
|
|
5143
5409
|
signal: opts.signal
|
|
5144
5410
|
});
|
|
5145
5411
|
}
|
|
5412
|
+
/**
|
|
5413
|
+
* `POST /v1/sandboxes/{id}/run_code` (v2) — run Python in the persistent kernel; globals survive between
|
|
5414
|
+
* calls, pause/resume and forks. The last expression comes back as `result`.
|
|
5415
|
+
*/
|
|
5416
|
+
runCode(id, input, opts = {}) {
|
|
5417
|
+
return this.http.json(`${base(id)}/run_code`, {
|
|
5418
|
+
method: "POST",
|
|
5419
|
+
body: {
|
|
5420
|
+
code: input.code,
|
|
5421
|
+
...input.timeoutSeconds !== void 0 ? { timeout_seconds: input.timeoutSeconds } : {}
|
|
5422
|
+
},
|
|
5423
|
+
timeoutMs: execTimeoutMs(input.timeoutSeconds),
|
|
5424
|
+
noRetry: true,
|
|
5425
|
+
ext: opts.ext,
|
|
5426
|
+
signal: opts.signal
|
|
5427
|
+
});
|
|
5428
|
+
}
|
|
5429
|
+
/** `POST /v1/sandboxes/{id}/kernel/reset` (v2) — restart the kernel; globals are lost, files kept. */
|
|
5430
|
+
async resetKernel(id, opts = {}) {
|
|
5431
|
+
await this.http.json(`${base(id)}/kernel/reset`, {
|
|
5432
|
+
method: "POST",
|
|
5433
|
+
ext: opts.ext,
|
|
5434
|
+
signal: opts.signal
|
|
5435
|
+
});
|
|
5436
|
+
}
|
|
5437
|
+
/** `POST /v1/sandboxes/{id}/pause` (v2) — memory snapshot, then stop the pod (status `paused`). */
|
|
5438
|
+
pause(id, opts = {}) {
|
|
5439
|
+
return this.http.json(`${base(id)}/pause`, {
|
|
5440
|
+
method: "POST",
|
|
5441
|
+
timeoutMs: LIFECYCLE_TIMEOUT_MS,
|
|
5442
|
+
noRetry: true,
|
|
5443
|
+
ext: opts.ext,
|
|
5444
|
+
signal: opts.signal
|
|
5445
|
+
});
|
|
5446
|
+
}
|
|
5447
|
+
/** `POST /v1/sandboxes/{id}/resume` (v2) — restore a paused sandbox; `restored: false` = cold start. */
|
|
5448
|
+
resume(id, opts = {}) {
|
|
5449
|
+
return this.http.json(`${base(id)}/resume`, {
|
|
5450
|
+
method: "POST",
|
|
5451
|
+
timeoutMs: LIFECYCLE_TIMEOUT_MS,
|
|
5452
|
+
noRetry: true,
|
|
5453
|
+
ext: opts.ext,
|
|
5454
|
+
signal: opts.signal
|
|
5455
|
+
});
|
|
5456
|
+
}
|
|
5457
|
+
/** `POST /v1/sandboxes/{id}/fork` (v2) — start 1–5 copies of a running sandbox from a memory snapshot. */
|
|
5458
|
+
fork(id, input, opts = {}) {
|
|
5459
|
+
return this.http.json(`${base(id)}/fork`, {
|
|
5460
|
+
method: "POST",
|
|
5461
|
+
body: {
|
|
5462
|
+
count: input.count,
|
|
5463
|
+
...input.ttlSeconds !== void 0 ? { ttl_seconds: input.ttlSeconds } : {}
|
|
5464
|
+
},
|
|
5465
|
+
timeoutMs: LIFECYCLE_TIMEOUT_MS,
|
|
5466
|
+
noRetry: true,
|
|
5467
|
+
ext: opts.ext,
|
|
5468
|
+
signal: opts.signal
|
|
5469
|
+
});
|
|
5470
|
+
}
|
|
5471
|
+
/** `POST /v1/sandboxes/{id}/preview` (v2) — signed HTTPS URL on `*.sbx.codai.ro` for a port (≤ 1 h). */
|
|
5472
|
+
preview(id, input, opts = {}) {
|
|
5473
|
+
return this.http.json(`${base(id)}/preview`, {
|
|
5474
|
+
method: "POST",
|
|
5475
|
+
body: {
|
|
5476
|
+
port: input.port,
|
|
5477
|
+
...input.ttlSeconds !== void 0 ? { ttl_seconds: input.ttlSeconds } : {}
|
|
5478
|
+
},
|
|
5479
|
+
ext: opts.ext,
|
|
5480
|
+
signal: opts.signal
|
|
5481
|
+
});
|
|
5482
|
+
}
|
|
5146
5483
|
/** `DELETE /v1/sandboxes/{id}` — destroy the sandbox and its workspace (204). */
|
|
5147
5484
|
async delete(id, opts = {}) {
|
|
5148
5485
|
await this.http.request(base(id), {
|
|
@@ -5167,6 +5504,8 @@ var Sandboxes = class {
|
|
|
5167
5504
|
});
|
|
5168
5505
|
}
|
|
5169
5506
|
};
|
|
5507
|
+
/** Pause / resume / fork wait for a snapshot or a pod start (server caps: 180 s snapshot, 240 s start). */
|
|
5508
|
+
const LIFECYCLE_TIMEOUT_MS = 48e4;
|
|
5170
5509
|
/** Client timeout for a blocking exec: the server limit plus a margin for restore and upload. */
|
|
5171
5510
|
function execTimeoutMs(timeoutSeconds) {
|
|
5172
5511
|
return ((timeoutSeconds ?? 120) + 60) * 1e3;
|
|
@@ -5633,7 +5972,12 @@ var Tools = class {
|
|
|
5633
5972
|
constructor(http) {
|
|
5634
5973
|
this.http = http;
|
|
5635
5974
|
}
|
|
5636
|
-
/**
|
|
5975
|
+
/**
|
|
5976
|
+
* `POST /v1/tools/search` — verified web search (never falls back to an unverified provider). Filters:
|
|
5977
|
+
* `include_domains` / `exclude_domains`, `freshness` or `published_after` / `published_before` (undated pages are
|
|
5978
|
+
* dropped), `content_chars` for a verified excerpt per result. Each result carries `published_at` (null when
|
|
5979
|
+
* unknown, never the crawl date) and `crawled_at`.
|
|
5980
|
+
*/
|
|
5637
5981
|
search(body, opts = {}) {
|
|
5638
5982
|
return this.http.json("/v1/tools/search", {
|
|
5639
5983
|
body,
|
|
@@ -5641,7 +5985,7 @@ var Tools = class {
|
|
|
5641
5985
|
signal: opts.signal
|
|
5642
5986
|
});
|
|
5643
5987
|
}
|
|
5644
|
-
/** `POST /v1/tools/fetch` — fetch + extract a public page (SSRF-guarded). */
|
|
5988
|
+
/** `POST /v1/tools/fetch` — fetch + extract a public page (SSRF-guarded; `max_chars` default 8000, max 40 000). */
|
|
5645
5989
|
fetch(body, opts = {}) {
|
|
5646
5990
|
return this.http.json("/v1/tools/fetch", {
|
|
5647
5991
|
body,
|
|
@@ -5662,6 +6006,82 @@ var Tools = class {
|
|
|
5662
6006
|
}
|
|
5663
6007
|
};
|
|
5664
6008
|
|
|
6009
|
+
//#endregion
|
|
6010
|
+
//#region src/resources/research.ts
|
|
6011
|
+
const path = (id) => `/v1/research/${encodeURIComponent(id)}`;
|
|
6012
|
+
function abortableSleep(ms, signal) {
|
|
6013
|
+
return new Promise((resolve, reject) => {
|
|
6014
|
+
if (signal?.aborted) return reject(signal.reason ?? /* @__PURE__ */ new Error("Aborted"));
|
|
6015
|
+
const t = setTimeout(() => {
|
|
6016
|
+
signal?.removeEventListener("abort", onAbort);
|
|
6017
|
+
resolve();
|
|
6018
|
+
}, ms);
|
|
6019
|
+
const onAbort = () => {
|
|
6020
|
+
clearTimeout(t);
|
|
6021
|
+
reject(signal?.reason ?? /* @__PURE__ */ new Error("Aborted"));
|
|
6022
|
+
};
|
|
6023
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
6024
|
+
});
|
|
6025
|
+
}
|
|
6026
|
+
const isResearchFinished = (job) => job.status === "done" || job.status === "failed";
|
|
6027
|
+
var Research = class {
|
|
6028
|
+
http;
|
|
6029
|
+
constructor(http) {
|
|
6030
|
+
this.http = http;
|
|
6031
|
+
}
|
|
6032
|
+
/**
|
|
6033
|
+
* `POST /v1/research` — start a deep-research job. With `wait_s` (0..55) the call waits that long and returns the
|
|
6034
|
+
* finished job; otherwise (or when it is still running) the job comes back `queued` / `running`.
|
|
6035
|
+
*/
|
|
6036
|
+
create(body, opts = {}) {
|
|
6037
|
+
return this.http.json("/v1/research", {
|
|
6038
|
+
method: "POST",
|
|
6039
|
+
body,
|
|
6040
|
+
headers: opts.idempotencyKey ? { "Idempotency-Key": opts.idempotencyKey } : void 0,
|
|
6041
|
+
noRetry: !opts.idempotencyKey,
|
|
6042
|
+
ext: opts.ext,
|
|
6043
|
+
signal: opts.signal
|
|
6044
|
+
});
|
|
6045
|
+
}
|
|
6046
|
+
/** `GET /v1/research/{id}` — one of your jobs (another account's id is a 404). Free. */
|
|
6047
|
+
retrieve(id, opts = {}) {
|
|
6048
|
+
return this.http.json(path(id), {
|
|
6049
|
+
ext: opts.ext,
|
|
6050
|
+
signal: opts.signal
|
|
6051
|
+
});
|
|
6052
|
+
}
|
|
6053
|
+
/**
|
|
6054
|
+
* Poll `retrieve` every `intervalMs` (default 3 s) until the job is `done` or `failed` and resolve with it (a
|
|
6055
|
+
* `failed` job resolves too — check `status` / `error`). Throws when it is not finished within `timeoutMs`
|
|
6056
|
+
* (default 6 min) or when `signal` aborts.
|
|
6057
|
+
*/
|
|
6058
|
+
async wait(id, opts = {}) {
|
|
6059
|
+
const { intervalMs = 3e3, timeoutMs = 36e4, signal, ext } = opts;
|
|
6060
|
+
const deadline = Date.now() + timeoutMs;
|
|
6061
|
+
for (;;) {
|
|
6062
|
+
const job = await this.retrieve(id, {
|
|
6063
|
+
ext,
|
|
6064
|
+
signal
|
|
6065
|
+
});
|
|
6066
|
+
if (isResearchFinished(job)) return job;
|
|
6067
|
+
if (Date.now() + intervalMs > deadline) throw new Error(`codai research job ${id} did not finish within ${timeoutMs} ms`);
|
|
6068
|
+
await abortableSleep(intervalMs, signal);
|
|
6069
|
+
}
|
|
6070
|
+
}
|
|
6071
|
+
/** `create` then `wait` until the job finishes. */
|
|
6072
|
+
async run(body, opts = {}) {
|
|
6073
|
+
const { intervalMs, timeoutMs, ...createOpts } = opts;
|
|
6074
|
+
const job = await this.create(body, createOpts);
|
|
6075
|
+
if (isResearchFinished(job)) return job;
|
|
6076
|
+
return this.wait(job.id, {
|
|
6077
|
+
ext: opts.ext,
|
|
6078
|
+
signal: opts.signal,
|
|
6079
|
+
...intervalMs !== void 0 ? { intervalMs } : {},
|
|
6080
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {}
|
|
6081
|
+
});
|
|
6082
|
+
}
|
|
6083
|
+
};
|
|
6084
|
+
|
|
5665
6085
|
//#endregion
|
|
5666
6086
|
//#region src/resources/usage-keys.ts
|
|
5667
6087
|
var Usage = class {
|
|
@@ -5836,6 +6256,33 @@ const OPERATION_METHODS = {
|
|
|
5836
6256
|
reopenPublicReviewThread: "shares.reopen",
|
|
5837
6257
|
decidePublicReview: "shares.decide",
|
|
5838
6258
|
createVoiceRevocation: "voiceRevocations.create",
|
|
6259
|
+
getVaultAccount: "vault.account",
|
|
6260
|
+
putVaultAccount: "vault.putAccount",
|
|
6261
|
+
patchVaultSettings: "vault.setDefaultTier",
|
|
6262
|
+
listVaults: "vault.vaults",
|
|
6263
|
+
createVault: "vault.createVault",
|
|
6264
|
+
listVaultItems: "vault.items",
|
|
6265
|
+
putVaultItem: "vault.putItem",
|
|
6266
|
+
deleteVaultItem: "vault.deleteItem",
|
|
6267
|
+
setVaultItemCloud: "vault.setItemCloud",
|
|
6268
|
+
listVaultRules: "vault.rules",
|
|
6269
|
+
createVaultRule: "vault.createRule",
|
|
6270
|
+
deleteVaultRule: "vault.deleteRule",
|
|
6271
|
+
listVaultGrants: "vault.grants",
|
|
6272
|
+
revokeVaultGrant: "vault.revokeGrant",
|
|
6273
|
+
listVaultEvents: "vault.events",
|
|
6274
|
+
listVaultApprovals: "vault.approvals",
|
|
6275
|
+
getVaultApproval: "vault.approval",
|
|
6276
|
+
decideVaultApproval: "vault.decide",
|
|
6277
|
+
createVaultDeviceChallenge: "vault.devices.challenge",
|
|
6278
|
+
enrollVaultDevice: "vault.devices.enroll",
|
|
6279
|
+
listVaultDevices: "vault.devices.list",
|
|
6280
|
+
renameVaultDevice: "vault.devices.rename",
|
|
6281
|
+
revokeVaultDevice: "vault.devices.revoke",
|
|
6282
|
+
vaultCatalog: "vault.catalog",
|
|
6283
|
+
vaultUse: "vault.use",
|
|
6284
|
+
vaultHttp: "vault.httpCall",
|
|
6285
|
+
vaultResolve: "vault.resolve",
|
|
5839
6286
|
createStudioAbuseReport: "abuseReports.create",
|
|
5840
6287
|
checkProvenance: "provenance.check",
|
|
5841
6288
|
createStudioBatch: "batches.create",
|
|
@@ -5847,6 +6294,8 @@ const OPERATION_METHODS = {
|
|
|
5847
6294
|
zipStudioBatch: "batches.zip",
|
|
5848
6295
|
saveCreativeTemplate: "creatives.saveTemplate",
|
|
5849
6296
|
listCreativeTemplates: "templates.list",
|
|
6297
|
+
createStudioProduction: "productions.create",
|
|
6298
|
+
getStudioProduction: "productions.retrieve",
|
|
5850
6299
|
getCreativeTemplate: "templates.retrieve",
|
|
5851
6300
|
deleteCreativeTemplate: "templates.delete",
|
|
5852
6301
|
exportCreativeFcpxml: "creatives.exportFcpxml",
|
|
@@ -5873,6 +6322,8 @@ const OPERATION_METHODS = {
|
|
|
5873
6322
|
toolsSearch: "tools.search",
|
|
5874
6323
|
toolsFetch: "tools.fetch",
|
|
5875
6324
|
toolsGround: "tools.ground",
|
|
6325
|
+
createResearch: "research.create",
|
|
6326
|
+
getResearch: "research.retrieve",
|
|
5876
6327
|
listTasks: "tasks.list",
|
|
5877
6328
|
listPendingTasks: "tasks.pending",
|
|
5878
6329
|
getTaskStats: "tasks.stats",
|
|
@@ -5991,6 +6442,12 @@ const OPERATION_METHODS = {
|
|
|
5991
6442
|
snapshotSandbox: "sandboxes.snapshot",
|
|
5992
6443
|
deleteSandbox: "sandboxes.delete",
|
|
5993
6444
|
runSandbox: "sandboxes.run",
|
|
6445
|
+
runSandboxCode: "sandboxes.runCode",
|
|
6446
|
+
resetSandboxKernel: "sandboxes.resetKernel",
|
|
6447
|
+
pauseSandbox: "sandboxes.pause",
|
|
6448
|
+
resumeSandbox: "sandboxes.resume",
|
|
6449
|
+
forkSandbox: "sandboxes.fork",
|
|
6450
|
+
previewSandbox: "sandboxes.preview",
|
|
5994
6451
|
createSession: "sessions.create",
|
|
5995
6452
|
listSessions: "sessions.list",
|
|
5996
6453
|
getSession: "sessions.get",
|
|
@@ -6067,6 +6524,7 @@ const OPERATION_METHODS = {
|
|
|
6067
6524
|
patchAccount: "account.update",
|
|
6068
6525
|
getBilling: "billing.get",
|
|
6069
6526
|
listBillingInvoices: "billing.invoices",
|
|
6527
|
+
getStudioQuote: "billing.studioQuote",
|
|
6070
6528
|
getReferrals: "referrals.get",
|
|
6071
6529
|
getSettings: "settings.get",
|
|
6072
6530
|
patchSettings: "settings.update",
|
|
@@ -6295,8 +6753,10 @@ var CodaiApps = class {
|
|
|
6295
6753
|
* client.brandKits.create / .update / .exportDtcg / .extract / .list / .retrieve / .delete (codai Studio brand
|
|
6296
6754
|
* kits as DTCG tokens, from a web page or a logo; extract is
|
|
6297
6755
|
* token-metered, the rest free; apply with creatives.create({ kind, brand_kit_id }))
|
|
6298
|
-
* client.templates.list / .retrieve / .delete (codai Studio templates saved with creatives.saveTemplate
|
|
6299
|
-
* use with creatives.create({ kind, template, vars }))
|
|
6756
|
+
* client.templates.list / .retrieve / .delete (codai Studio templates saved with creatives.saveTemplate plus the 40
|
|
6757
|
+
* built-in starters; free; use with creatives.create({ kind, template, vars }))
|
|
6758
|
+
* client.productions.create / .retrieve / .wait / .run (codai Studio brief → promo video: storyboard, images,
|
|
6759
|
+
* voice-over, editable creative, draft render, one review + repair; billed as the parts are produced)
|
|
6300
6760
|
* client.exports.retrieve / .wait (codai Studio FCPXML exports queued with creatives.exportFcpxml; only newly
|
|
6301
6761
|
* rendered seconds are billed; Lottie exports from creatives.exportLottie are free and ready at once)
|
|
6302
6762
|
* client.batches.create / .dryRun / .list / .get / .cancel / .retry / .exportCsv / .zip / .wait (codai Studio
|
|
@@ -6304,11 +6764,15 @@ var CodaiApps = class {
|
|
|
6304
6764
|
* client.shares.get / .remix / .comment / .reply / .resolve / .reopen / .decide (codai Studio share links from the
|
|
6305
6765
|
* outside: read a shared creative, remix a view link, comment and decide through a review link; free)
|
|
6306
6766
|
* client.voiceRevocations.create (public takedown ticket for a voice cloned in codai Studio; no key needed)
|
|
6767
|
+
* client.vault.account / .items / .putItem / .rules / .approvals / .decide / .catalog / .use / .httpCall / .resolve
|
|
6768
|
+
* client.vault.devices.challenge / .enroll / .list / .rename / .revoke (device approval keys, V-27)
|
|
6769
|
+
* (zero-knowledge credentials vault: ciphertext only; the broker calls never return secret values)
|
|
6307
6770
|
* client.abuseReports.create (public DSA notice about a codai Studio share / review link; no key needed)
|
|
6308
6771
|
* client.provenance.check (public: which codai AI-provenance marks a file carries; no key needed)
|
|
6309
6772
|
* client.systemOne.create / .batch (typed decisions, codai-s1)
|
|
6310
6773
|
* client.realtime.connect (WebSocket live STT / voice; not an OpenAPI operation)
|
|
6311
|
-
* client.agents.run + client.agents.runs.* client.tools.search / .fetch
|
|
6774
|
+
* client.agents.run + client.agents.runs.* client.tools.search / .fetch (metered web tools)
|
|
6775
|
+
* client.research.create / .retrieve / .wait / .run (async deep research, cited report)
|
|
6312
6776
|
* client.cards.weather / .places / .geocode / .staticMap / .fx / .unfurl (typed card data, `{ block, provenance }`)
|
|
6313
6777
|
* client.tasks.* client.sessions.* (events, controls, lease, shares, stream)
|
|
6314
6778
|
* client.devices.* / client.hosts.* client.orgs.* / client.account / client.receipt
|
|
@@ -6319,6 +6783,7 @@ var CodaiApps = class {
|
|
|
6319
6783
|
* client.projects.* client.environments.* (members, ports, secrets)
|
|
6320
6784
|
* client.sandboxes.create / .list / .retrieve / .exec / .execStream / .files.put / .files.get / .files.list
|
|
6321
6785
|
* / .artifacts / .snapshot / .delete / .run (agent sandboxes, beta: isolated gVisor workspaces, no network by default)
|
|
6786
|
+
* / .runCode / .resetKernel / .pause / .resume / .fork / .preview (backend v2, closed canary)
|
|
6322
6787
|
* client.verify.agentOutputKey / .agentOutput (EXPERIMENTAL HIDE-signed agent outputs)
|
|
6323
6788
|
* client.feedback / client.phoneModels
|
|
6324
6789
|
* client.resolve.* (verified bug fixes on https://resolve.codai.ro — resolve.yaml; .list / .iterate page your jobs)
|
|
@@ -6356,6 +6821,8 @@ var Codai = class {
|
|
|
6356
6821
|
brandKits;
|
|
6357
6822
|
/** codai Studio templates (`creatives.saveTemplate(id, { vars })` saves one; `templates.list()`; create with `creatives.create({ kind, template, vars })`). */
|
|
6358
6823
|
templates;
|
|
6824
|
+
/** codai Studio productions (`productions.run({ brief, language: 'ro' })` → a finished promo video + editable creative). */
|
|
6825
|
+
productions;
|
|
6359
6826
|
/** codai Studio FCPXML exports (`creatives.exportFcpxml(id)` queues one; `exports.wait(id)` polls until the zip is ready). */
|
|
6360
6827
|
exports;
|
|
6361
6828
|
/** codai Studio batches (`batches.create({ source: { template_id }, csv })` → one creative per row; `batches.wait(id)`). */
|
|
@@ -6364,6 +6831,8 @@ var Codai = class {
|
|
|
6364
6831
|
shares;
|
|
6365
6832
|
/** Public takedown tickets for voices cloned in codai Studio (`voiceRevocations.create({ email, … })`; no key needed). */
|
|
6366
6833
|
voiceRevocations;
|
|
6834
|
+
/** Zero-knowledge credentials vault (`vault.items()`, `vault.use({ handle, mode, action })`, `vault.decide(id, …)`). */
|
|
6835
|
+
vault;
|
|
6367
6836
|
/** Public abuse reports about codai Studio share / review links (`abuseReports.create({ share_token, … })`; no key needed). */
|
|
6368
6837
|
abuseReports;
|
|
6369
6838
|
/** Public AI-provenance checker (`provenance.check(file)` → C2PA / RIFF INFO / ID3 / MP4 / XMP marks; no key needed). */
|
|
@@ -6377,6 +6846,8 @@ var Codai = class {
|
|
|
6377
6846
|
health;
|
|
6378
6847
|
agents;
|
|
6379
6848
|
tools;
|
|
6849
|
+
/** Async deep research (`research.run({ question })` → cited report + sources). */
|
|
6850
|
+
research;
|
|
6380
6851
|
/** Typed card data (`cards.weather({ lat, lng })`, `.places({ q })`, `.fx()`, `.unfurl(url)` → `{ block, provenance }`). */
|
|
6381
6852
|
cards;
|
|
6382
6853
|
tasks;
|
|
@@ -6453,10 +6924,12 @@ var Codai = class {
|
|
|
6453
6924
|
this.creatives = new Creatives(http);
|
|
6454
6925
|
this.brandKits = new BrandKits(http);
|
|
6455
6926
|
this.templates = new Templates(http);
|
|
6927
|
+
this.productions = new Productions(http);
|
|
6456
6928
|
this.exports = new Exports(http);
|
|
6457
6929
|
this.batches = new Batches(http);
|
|
6458
6930
|
this.shares = new Shares(http);
|
|
6459
6931
|
this.voiceRevocations = new VoiceRevocations(http);
|
|
6932
|
+
this.vault = new Vault(http);
|
|
6460
6933
|
this.abuseReports = new AbuseReports(http);
|
|
6461
6934
|
this.provenance = new Provenance(http);
|
|
6462
6935
|
this.systemOne = new SystemOne(http);
|
|
@@ -6468,6 +6941,7 @@ var Codai = class {
|
|
|
6468
6941
|
this.health = new Health(http);
|
|
6469
6942
|
this.agents = new Agents(http);
|
|
6470
6943
|
this.tools = new Tools(http);
|
|
6944
|
+
this.research = new Research(http);
|
|
6471
6945
|
this.cards = new Cards(http);
|
|
6472
6946
|
this.tasks = new Tasks(http);
|
|
6473
6947
|
this.triggers = new Triggers(http);
|
|
@@ -6584,5 +7058,5 @@ function allKeys(obj) {
|
|
|
6584
7058
|
}
|
|
6585
7059
|
|
|
6586
7060
|
//#endregion
|
|
6587
|
-
export { AbuseReports, Account, AgentRuns, Agents, Assets, Audio, Batches, Billing, BrandKits, Cards, Chat, ChatCompletions, Codai, Codai as default, CodaiApps, CodaiError, Creatives, Devices, Documents, Embeddings, EnvironmentFiles, EnvironmentJobs, EnvironmentMembers, EnvironmentPorts, EnvironmentSecrets, EnvironmentTasks, Environments, Exports, Feedback, Health, Heartbeats, Hosts, HttpClient, Images, Keys, Lists, Memory, Messages, Models, Music, Notifications, OPERATION_METHODS, OrgMembers, Orgs, PROVENANCE_MAX_BYTES, PhoneModels, Projects, Prompts, Provenance, RESOLVE_ATTESTATION_PAYLOAD_TYPE, RESOLVE_OPERATION_METHODS, RESOLVE_TERMINAL_STATUSES, Realtime, RealtimeSession, Receipts, Referrals, Renders, Resolve, ResolveError, ResolveInsufficientFundsError, Responses, STREAMING_OPERATIONS, SandboxFiles, Sandboxes, ScheduleExecutor, SchedulerHosts, Schedules, SessionControls, SessionEvents, SessionLease, SessionShares, Sessions, Settings, Sfx, Shares, SystemOne, TUS_CHUNK_BYTES, Tasks, Templates, Tokens, Tools, Transcripts, Triggers, Usage, Verify, Videos, VoiceRevocations, extensionHeaders, frameJson, isAssetDto, mergeToolCall, readSse, realtimeUrl, resolveAttestationStatement, settingsConflictCurrent, shareTokenFrom, uploadIdFromLocation, verifyAttestationWithKeys, verifyResolveWebhook };
|
|
7061
|
+
export { AbuseReports, Account, AgentRuns, Agents, Assets, Audio, Batches, Billing, BrandKits, Cards, Chat, ChatCompletions, Codai, Codai as default, CodaiApps, CodaiError, Creatives, Devices, Documents, Embeddings, EnvironmentFiles, EnvironmentJobs, EnvironmentMembers, EnvironmentPorts, EnvironmentSecrets, EnvironmentTasks, Environments, Exports, Feedback, Health, Heartbeats, Hosts, HttpClient, Images, Keys, Lists, Memory, Messages, Models, Music, Notifications, OPERATION_METHODS, OrgMembers, Orgs, PROVENANCE_MAX_BYTES, PhoneModels, Productions, Projects, Prompts, Provenance, RESOLVE_ATTESTATION_PAYLOAD_TYPE, RESOLVE_OPERATION_METHODS, RESOLVE_TERMINAL_STATUSES, Realtime, RealtimeSession, Receipts, Referrals, Renders, Research, Resolve, ResolveError, ResolveInsufficientFundsError, Responses, STREAMING_OPERATIONS, SandboxFiles, Sandboxes, ScheduleExecutor, SchedulerHosts, Schedules, SessionControls, SessionEvents, SessionLease, SessionShares, Sessions, Settings, Sfx, Shares, SystemOne, TUS_CHUNK_BYTES, Tasks, Templates, Tokens, Tools, Transcripts, Triggers, Usage, Vault, VaultDevices, Verify, Videos, VoiceRevocations, extensionHeaders, frameJson, isAssetDto, isProductionFinished, isResearchFinished, mergeToolCall, readSse, realtimeUrl, resolveAttestationStatement, settingsConflictCurrent, shareTokenFrom, uploadIdFromLocation, verifyAttestationWithKeys, verifyResolveWebhook };
|
|
6588
7062
|
//# sourceMappingURL=index.js.map
|