@playdrop/playdrop-cli 0.7.13 → 0.7.16
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/config/client-meta.json +1 -1
- package/node_modules/@playdrop/ai-client/dist/index.js +461 -444
- package/node_modules/@playdrop/ai-client/package.json +1 -1
- package/node_modules/@playdrop/api-client/dist/client.js +903 -882
- package/node_modules/@playdrop/api-client/dist/core/errors.js +69 -45
- package/node_modules/@playdrop/api-client/dist/core/request.js +188 -159
- package/node_modules/@playdrop/api-client/dist/domains/admin.js +516 -491
- package/node_modules/@playdrop/api-client/dist/domains/ai.js +40 -14
- package/node_modules/@playdrop/api-client/dist/domains/apps.js +480 -462
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.js +439 -419
- package/node_modules/@playdrop/api-client/dist/domains/assets.js +696 -676
- package/node_modules/@playdrop/api-client/dist/domains/auth.js +346 -320
- package/node_modules/@playdrop/api-client/dist/domains/comments.js +124 -98
- package/node_modules/@playdrop/api-client/dist/domains/free-credits.js +91 -65
- package/node_modules/@playdrop/api-client/dist/domains/me.js +71 -45
- package/node_modules/@playdrop/api-client/dist/domains/payments.js +407 -386
- package/node_modules/@playdrop/api-client/dist/domains/player-meta.js +144 -118
- package/node_modules/@playdrop/api-client/dist/domains/search.js +117 -104
- package/node_modules/@playdrop/api-client/dist/domains/tags.js +188 -162
- package/node_modules/@playdrop/api-client/dist/index.js +993 -552
- package/node_modules/@playdrop/api-client/package.json +1 -1
- package/node_modules/@playdrop/boxel-three/dist/src/animations.js +84 -62
- package/node_modules/@playdrop/boxel-three/dist/src/builders.js +341 -308
- package/node_modules/@playdrop/boxel-three/dist/src/context.js +55 -29
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.js +856 -858
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.js +267 -261
- package/node_modules/@playdrop/boxel-three/dist/src/index.js +64 -15
- package/node_modules/@playdrop/boxel-three/dist/src/instantiate.js +89 -63
- package/node_modules/@playdrop/boxel-three/dist/src/nodes.js +81 -56
- package/node_modules/@playdrop/boxel-three/dist/src/overlays.js +112 -86
- package/node_modules/@playdrop/boxel-three/dist/src/primitives.js +45 -17
- package/node_modules/@playdrop/boxel-three/dist/src/scene.js +160 -136
- package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.js +582 -584
- package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.js +123 -97
- package/node_modules/@playdrop/boxel-three/dist/src/textures.js +207 -182
- package/node_modules/@playdrop/boxel-three/dist/src/types.js +15 -1
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.js +451 -425
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.js +109 -84
- package/node_modules/@playdrop/boxel-three/dist/test/export-image.playwright.test.js +127 -106
- package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.js +73 -51
- package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.js +97 -79
- package/node_modules/@playdrop/boxel-three/dist/test/index.test.js +29 -7
- package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.js +80 -60
- package/node_modules/@playdrop/boxel-three/dist/test/overlays.test.js +41 -19
- package/node_modules/@playdrop/boxel-three/dist/test/scene-filter.test.js +72 -50
- package/node_modules/@playdrop/boxel-three/dist/test/scene-smoke.test.js +84 -62
- package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.js +69 -47
- package/node_modules/@playdrop/boxel-three/dist/test/textured-overlay.test.js +129 -109
- package/node_modules/@playdrop/boxel-three/dist/test/voxels.test.js +40 -18
- package/node_modules/@playdrop/boxel-three/package.json +1 -1
- package/node_modules/@playdrop/config/client-meta.json +1 -1
- package/node_modules/@playdrop/config/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@playdrop/types/dist/api.js +289 -203
- package/node_modules/@playdrop/types/dist/app-capability-filters.js +112 -62
- package/node_modules/@playdrop/types/dist/app.js +91 -45
- package/node_modules/@playdrop/types/dist/asset-pack.js +37 -5
- package/node_modules/@playdrop/types/dist/asset-spec.js +170 -90
- package/node_modules/@playdrop/types/dist/asset.js +186 -108
- package/node_modules/@playdrop/types/dist/content-license.js +49 -15
- package/node_modules/@playdrop/types/dist/creator-public-image.js +60 -32
- package/node_modules/@playdrop/types/dist/ecs.js +102 -82
- package/node_modules/@playdrop/types/dist/engine-builtins.js +603 -573
- package/node_modules/@playdrop/types/dist/entity.js +63 -53
- package/node_modules/@playdrop/types/dist/graph.js +116 -80
- package/node_modules/@playdrop/types/dist/index.js +47 -20
- package/node_modules/@playdrop/types/dist/owned-assets.js +55 -33
- package/node_modules/@playdrop/types/dist/player-meta.js +151 -100
- package/node_modules/@playdrop/types/dist/realtime.js +27 -7
- package/node_modules/@playdrop/types/dist/version.js +182 -124
- package/node_modules/@playdrop/types/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,481 +1,498 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var dist_exports = {};
|
|
19
|
+
__export(dist_exports, {
|
|
20
|
+
GENERATION_JOB_ETA_BASELINE_SECONDS: () => GENERATION_JOB_ETA_BASELINE_SECONDS,
|
|
21
|
+
createAiClient: () => createAiClient
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(dist_exports);
|
|
24
|
+
const GENERATION_JOB_ETA_BASELINE_SECONDS = {
|
|
25
|
+
IMAGE: 20,
|
|
26
|
+
MUSIC: 40,
|
|
27
|
+
SFX: 15,
|
|
28
|
+
SPEECH: 15,
|
|
29
|
+
VIDEO: 90,
|
|
30
|
+
MODEL_3D: 420
|
|
31
|
+
};
|
|
32
|
+
const DEFAULT_LOCAL_BASE = "http://localhost:8083";
|
|
10
33
|
const CLIENT_HEADER_NAMES = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
34
|
+
client: "x-playdrop-client",
|
|
35
|
+
clientVersion: "x-playdrop-client-version",
|
|
36
|
+
clientBuild: "x-playdrop-client-build",
|
|
37
|
+
platform: "x-playdrop-platform",
|
|
38
|
+
platformVersion: "x-playdrop-platform-version"
|
|
16
39
|
};
|
|
17
40
|
function stripTrailingSlash(value) {
|
|
18
|
-
|
|
41
|
+
return value.endsWith("/") ? value.slice(0, -1) : value;
|
|
19
42
|
}
|
|
20
43
|
function normalizeProtocol(protocol) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
44
|
+
if (!protocol) {
|
|
45
|
+
return "http";
|
|
46
|
+
}
|
|
47
|
+
return protocol.replace(/:$/, "") || "http";
|
|
25
48
|
}
|
|
26
49
|
function isIpv4Hostname(hostname) {
|
|
27
|
-
|
|
50
|
+
return /^\d{1,3}(?:\.\d{1,3}){3}$/.test(hostname);
|
|
28
51
|
}
|
|
29
52
|
function isLocalHostname(hostname) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
if (!hostname) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
const normalizedHostname = hostname.trim().toLowerCase();
|
|
57
|
+
if (!normalizedHostname) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
if (normalizedHostname === "localhost" || normalizedHostname === "0.0.0.0") {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
if (isIpv4Hostname(normalizedHostname)) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
return normalizedHostname.includes(":");
|
|
44
67
|
}
|
|
45
68
|
function formatHostnameForUrl(hostname) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
69
|
+
const normalizedHostname = hostname.trim();
|
|
70
|
+
if (!normalizedHostname) {
|
|
71
|
+
return "localhost";
|
|
72
|
+
}
|
|
73
|
+
if (normalizedHostname.includes(":") && !normalizedHostname.startsWith("[")) {
|
|
74
|
+
return `[${normalizedHostname}]`;
|
|
75
|
+
}
|
|
76
|
+
return normalizedHostname;
|
|
54
77
|
}
|
|
55
78
|
function inferBaseFromHostname(hostname, protocol) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
.replace(/^ai\./, '')
|
|
66
|
-
.replace(/^assets\./, '');
|
|
67
|
-
return `${protocol}://ai.${domain}`;
|
|
68
|
-
}
|
|
69
|
-
const host = formatHostnameForUrl(hostname || 'localhost');
|
|
70
|
-
return `${protocol}://${host}:8083`;
|
|
79
|
+
if (isLocalHostname(hostname)) {
|
|
80
|
+
return `${protocol}://${formatHostnameForUrl(hostname)}:8083`;
|
|
81
|
+
}
|
|
82
|
+
if (hostname.includes(".")) {
|
|
83
|
+
const domain = hostname.replace(/^www\./, "").replace(/^api\./, "").replace(/^play\./, "").replace(/^admin\./, "").replace(/^ai\./, "").replace(/^assets\./, "");
|
|
84
|
+
return `${protocol}://ai.${domain}`;
|
|
85
|
+
}
|
|
86
|
+
const host = formatHostnameForUrl(hostname || "localhost");
|
|
87
|
+
return `${protocol}://${host}:8083`;
|
|
71
88
|
}
|
|
72
89
|
function inferBaseUrl() {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
if (typeof process !== "undefined" && process.env.NEXT_PUBLIC_AI_BASE) {
|
|
91
|
+
return process.env.NEXT_PUBLIC_AI_BASE;
|
|
92
|
+
}
|
|
93
|
+
if (typeof window !== "undefined" && window.location) {
|
|
94
|
+
const { hostname, protocol } = window.location;
|
|
95
|
+
return inferBaseFromHostname(hostname, normalizeProtocol(protocol));
|
|
96
|
+
}
|
|
97
|
+
return DEFAULT_LOCAL_BASE;
|
|
81
98
|
}
|
|
82
99
|
function resolveBrowserRequestCredentials() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
100
|
+
if (typeof window === "undefined") {
|
|
101
|
+
return void 0;
|
|
102
|
+
}
|
|
103
|
+
return "include";
|
|
87
104
|
}
|
|
88
105
|
function readBrowserRuntimeClientMeta() {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
if (typeof window === "undefined") {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const raw = globalThis.__PLAYDROP_CLIENT_META;
|
|
110
|
+
const version = typeof raw?.version === "string" ? raw.version.trim() : "";
|
|
111
|
+
const build = typeof raw?.build === "string" ? raw.build.trim() : "";
|
|
112
|
+
if (!version || !build) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return { version, build };
|
|
99
116
|
}
|
|
100
117
|
function normalizeBrowserPlatformName(raw) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
118
|
+
const value = raw.trim().toLowerCase();
|
|
119
|
+
if (value.includes("mac"))
|
|
120
|
+
return "macos";
|
|
121
|
+
if (value.includes("win"))
|
|
122
|
+
return "windows";
|
|
123
|
+
if (value.includes("linux"))
|
|
124
|
+
return "linux";
|
|
125
|
+
if (value.includes("ios") || value.includes("iphone") || value.includes("ipad"))
|
|
126
|
+
return "ios";
|
|
127
|
+
if (value.includes("android"))
|
|
128
|
+
return "android";
|
|
129
|
+
return value || "browser";
|
|
113
130
|
}
|
|
114
|
-
// eslint-disable-next-line complexity
|
|
115
131
|
function resolveBrowserPlatform() {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
132
|
+
if (typeof window === "undefined") {
|
|
133
|
+
return { name: "browser", version: "0.0.0" };
|
|
134
|
+
}
|
|
135
|
+
const envPlatform = (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_PLAYDROP_PLATFORM : "")?.trim() ?? "";
|
|
136
|
+
const envPlatformVersion = (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_PLAYDROP_PLATFORM_VERSION : "")?.trim() ?? "";
|
|
137
|
+
if (envPlatform && envPlatformVersion) {
|
|
138
|
+
return { name: envPlatform.toLowerCase(), version: envPlatformVersion };
|
|
139
|
+
}
|
|
140
|
+
const nav = window.navigator;
|
|
141
|
+
const userAgent = nav.userAgent || "";
|
|
142
|
+
const data = nav.userAgentData;
|
|
143
|
+
if (data?.platform) {
|
|
144
|
+
const platformName = normalizeBrowserPlatformName(data.platform);
|
|
145
|
+
const version = (data.platformVersion || "").replace(/_/g, ".").trim();
|
|
146
|
+
if (version) {
|
|
147
|
+
return { name: platformName, version };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const macMatch = /Mac OS X ([0-9_]+(?:_[0-9_]+)*)/i.exec(userAgent);
|
|
151
|
+
if (macMatch?.[1]) {
|
|
152
|
+
return { name: "macos", version: macMatch[1].replace(/_/g, ".") };
|
|
153
|
+
}
|
|
154
|
+
const iosMatch = /(iPhone|iPad|iPod).*OS ([0-9_]+)/i.exec(userAgent);
|
|
155
|
+
if (iosMatch?.[2]) {
|
|
156
|
+
return { name: "ios", version: iosMatch[2].replace(/_/g, ".") };
|
|
157
|
+
}
|
|
158
|
+
const winMatch = /Windows NT ([0-9.]+)/i.exec(userAgent);
|
|
159
|
+
if (winMatch?.[1]) {
|
|
160
|
+
return { name: "windows", version: winMatch[1] };
|
|
161
|
+
}
|
|
162
|
+
const androidMatch = /Android ([0-9.]+)/i.exec(userAgent);
|
|
163
|
+
if (androidMatch?.[1]) {
|
|
164
|
+
return { name: "android", version: androidMatch[1] };
|
|
165
|
+
}
|
|
166
|
+
if (/Linux/i.test(userAgent)) {
|
|
167
|
+
return { name: "linux", version: "0.0.0" };
|
|
168
|
+
}
|
|
169
|
+
return { name: "browser", version: "0.0.0" };
|
|
154
170
|
}
|
|
155
171
|
function resolveBrowserDefaultClientHeaders() {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
172
|
+
const clientMeta = readBrowserRuntimeClientMeta();
|
|
173
|
+
if (!clientMeta) {
|
|
174
|
+
return {};
|
|
175
|
+
}
|
|
176
|
+
const platform = resolveBrowserPlatform();
|
|
177
|
+
return {
|
|
178
|
+
[CLIENT_HEADER_NAMES.client]: "web",
|
|
179
|
+
[CLIENT_HEADER_NAMES.clientVersion]: clientMeta.version,
|
|
180
|
+
[CLIENT_HEADER_NAMES.clientBuild]: clientMeta.build,
|
|
181
|
+
[CLIENT_HEADER_NAMES.platform]: platform.name,
|
|
182
|
+
[CLIENT_HEADER_NAMES.platformVersion]: platform.version
|
|
183
|
+
};
|
|
168
184
|
}
|
|
169
185
|
function fillMissingClientHeaders(headers) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
186
|
+
if (typeof window === "undefined") {
|
|
187
|
+
return headers;
|
|
188
|
+
}
|
|
189
|
+
const inferredHeaders = resolveBrowserDefaultClientHeaders();
|
|
190
|
+
if (!Object.keys(inferredHeaders).length) {
|
|
191
|
+
return headers;
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
...inferredHeaders,
|
|
195
|
+
...headers
|
|
196
|
+
};
|
|
181
197
|
}
|
|
182
198
|
async function resolveAiClientToken(config) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
199
|
+
if (config.tokenProvider) {
|
|
200
|
+
const token = await config.tokenProvider();
|
|
201
|
+
return token ?? null;
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
188
204
|
}
|
|
189
205
|
async function resolveAiClientHeaders(config) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return {};
|
|
206
|
+
if (config.clientHeaders) {
|
|
207
|
+
try {
|
|
208
|
+
const headers = await config.clientHeaders();
|
|
209
|
+
return headers && typeof headers === "object" ? { ...headers } : {};
|
|
210
|
+
} catch {
|
|
211
|
+
return {};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return {};
|
|
200
215
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
216
|
+
function createAiClient(config = {}) {
|
|
217
|
+
const fetchImpl = config.fetchImpl ?? globalThis.fetch?.bind(globalThis);
|
|
218
|
+
if (!fetchImpl) {
|
|
219
|
+
throw new Error("ai_client_missing_fetch");
|
|
220
|
+
}
|
|
221
|
+
const baseUrl = stripTrailingSlash(config.baseUrl ?? inferBaseUrl());
|
|
222
|
+
async function buildHeaders() {
|
|
223
|
+
const headers = fillMissingClientHeaders({
|
|
224
|
+
...await resolveAiClientHeaders(config)
|
|
225
|
+
});
|
|
226
|
+
const token = await resolveAiClientToken(config);
|
|
227
|
+
if (token && !headers.Authorization) {
|
|
228
|
+
headers.Authorization = `Bearer ${token}`;
|
|
229
|
+
}
|
|
230
|
+
return headers;
|
|
231
|
+
}
|
|
232
|
+
async function buildRequestInit(payload, signal) {
|
|
233
|
+
const headers = await buildHeaders();
|
|
234
|
+
headers["Content-Type"] = "application/json";
|
|
235
|
+
return {
|
|
236
|
+
method: "POST",
|
|
237
|
+
headers,
|
|
238
|
+
body: JSON.stringify(payload),
|
|
239
|
+
credentials: resolveBrowserRequestCredentials(),
|
|
240
|
+
signal
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
async function throwHttpError(response) {
|
|
244
|
+
let payload = null;
|
|
245
|
+
try {
|
|
246
|
+
const text = await response.text();
|
|
247
|
+
if (text) {
|
|
230
248
|
try {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
payload = JSON.parse(text);
|
|
235
|
-
}
|
|
236
|
-
catch {
|
|
237
|
-
payload = { message: text };
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
catch {
|
|
242
|
-
payload = null;
|
|
243
|
-
}
|
|
244
|
-
const code = payload?.error ?? `http_${response.status}`;
|
|
245
|
-
const message = payload?.message ?? response.statusText ?? 'Request failed';
|
|
246
|
-
const error = new Error(`${code}: ${message}`);
|
|
247
|
-
error.status = response.status;
|
|
248
|
-
error.code = code;
|
|
249
|
-
error.details = payload;
|
|
250
|
-
throw error;
|
|
251
|
-
}
|
|
252
|
-
async function ensureOk(response) {
|
|
253
|
-
if (!response.ok) {
|
|
254
|
-
await throwHttpError(response);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
async function generateText(input, options) {
|
|
258
|
-
const normalizedInput = input?.trim();
|
|
259
|
-
if (!normalizedInput) {
|
|
260
|
-
throw new Error('ai_client_missing_input');
|
|
261
|
-
}
|
|
262
|
-
const size = options?.size ?? 'small';
|
|
263
|
-
const mode = options?.mode ?? 'text';
|
|
264
|
-
const rawSystem = options?.system?.trim();
|
|
265
|
-
const system = rawSystem && rawSystem.length ? rawSystem : undefined;
|
|
266
|
-
const response = await fetchImpl(`${baseUrl}/text/generate`, await buildRequestInit({
|
|
267
|
-
input: normalizedInput,
|
|
268
|
-
size,
|
|
269
|
-
mode,
|
|
270
|
-
system,
|
|
271
|
-
}, options?.signal));
|
|
272
|
-
await ensureOk(response);
|
|
273
|
-
const data = (await response.json());
|
|
274
|
-
return data;
|
|
275
|
-
}
|
|
276
|
-
function applyMediaGenerationPayload(payload, request) {
|
|
277
|
-
if (request.modality === 'IMAGE') {
|
|
278
|
-
payload.mode = 'image';
|
|
279
|
-
payload.image1 = request.image1 ?? undefined;
|
|
280
|
-
payload.image2 = request.image2 ?? undefined;
|
|
281
|
-
payload.aspectRatio = request.aspectRatio;
|
|
282
|
-
payload.imageSize = request.imageSize;
|
|
283
|
-
return true;
|
|
284
|
-
}
|
|
285
|
-
if (request.modality === 'VIDEO') {
|
|
286
|
-
payload.durationSeconds = typeof request.durationSeconds === 'number' ? request.durationSeconds : undefined;
|
|
287
|
-
payload.aspectRatio = request.aspectRatio;
|
|
288
|
-
payload.resolution = '720p';
|
|
289
|
-
payload.image1 = request.image1 ?? undefined;
|
|
290
|
-
payload.image2 = request.image2 ?? undefined;
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
return false;
|
|
294
|
-
}
|
|
295
|
-
function applyAudioGenerationPayload(payload, request) {
|
|
296
|
-
if (request.modality === 'MUSIC') {
|
|
297
|
-
payload.durationMs = typeof request.durationMs === 'number' ? request.durationMs : undefined;
|
|
298
|
-
payload.forceInstrumental = typeof request.forceInstrumental === 'boolean' ? request.forceInstrumental : undefined;
|
|
299
|
-
payload.coverPrompt = typeof request.coverPrompt === 'string' ? request.coverPrompt : undefined;
|
|
300
|
-
return true;
|
|
301
|
-
}
|
|
302
|
-
if (request.modality === 'SFX') {
|
|
303
|
-
payload.durationSeconds = typeof request.durationSeconds === 'number' ? request.durationSeconds : undefined;
|
|
304
|
-
payload.loop = typeof request.loop === 'boolean' ? request.loop : undefined;
|
|
305
|
-
payload.coverPrompt = typeof request.coverPrompt === 'string' ? request.coverPrompt : undefined;
|
|
306
|
-
return true;
|
|
307
|
-
}
|
|
308
|
-
if (request.modality === 'SPEECH') {
|
|
309
|
-
payload.speechVoice = typeof request.speechVoice === 'string' ? request.speechVoice : undefined;
|
|
310
|
-
payload.speechProviderVoiceId =
|
|
311
|
-
typeof request.speechProviderVoiceId === 'string' ? request.speechProviderVoiceId : undefined;
|
|
312
|
-
return true;
|
|
313
|
-
}
|
|
314
|
-
return false;
|
|
315
|
-
}
|
|
316
|
-
function applyGenerateAssetPayloadByModality(payload, request) {
|
|
317
|
-
if (applyMediaGenerationPayload(payload, request) || applyAudioGenerationPayload(payload, request)) {
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
if (request.modality === 'MODEL_3D') {
|
|
321
|
-
payload.sourceMode = request.sourceMode;
|
|
322
|
-
payload.image1 = request.image1 ?? undefined;
|
|
323
|
-
payload.image2 = request.image2 ?? undefined;
|
|
324
|
-
payload.topology = request.topology;
|
|
325
|
-
payload.targetPolycount = typeof request.targetPolycount === 'number' ? request.targetPolycount : undefined;
|
|
326
|
-
payload.shouldRemesh = typeof request.shouldRemesh === 'boolean' ? request.shouldRemesh : undefined;
|
|
327
|
-
payload.shouldTexture = typeof request.shouldTexture === 'boolean' ? request.shouldTexture : undefined;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
function buildGenerateAssetPayload(request) {
|
|
331
|
-
const normalizedInput = request.input?.trim();
|
|
332
|
-
if (!normalizedInput) {
|
|
333
|
-
throw new Error('ai_client_missing_input');
|
|
334
|
-
}
|
|
335
|
-
const payload = {
|
|
336
|
-
modality: request.modality,
|
|
337
|
-
input: normalizedInput,
|
|
338
|
-
assetName: request.assetName,
|
|
339
|
-
assetDisplayName: request.assetDisplayName,
|
|
340
|
-
assetDescription: request.assetDescription,
|
|
341
|
-
assetVisibility: request.assetVisibility,
|
|
342
|
-
attachAppVersionId: request.attachAppVersionId,
|
|
343
|
-
remixAssetVersionRef: request.remixAssetVersionRef,
|
|
344
|
-
};
|
|
345
|
-
if (request.modality !== 'SPEECH') {
|
|
346
|
-
payload.assetSubcategory = request.assetSubcategory;
|
|
249
|
+
payload = JSON.parse(text);
|
|
250
|
+
} catch {
|
|
251
|
+
payload = { message: text };
|
|
347
252
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
params.set('type', options.type);
|
|
452
|
-
}
|
|
453
|
-
if (typeof options.limit === 'number' && Number.isFinite(options.limit)) {
|
|
454
|
-
params.set('limit', String(options.limit));
|
|
455
|
-
}
|
|
456
|
-
if (typeof options.offset === 'number' && Number.isFinite(options.offset)) {
|
|
457
|
-
params.set('offset', String(options.offset));
|
|
458
|
-
}
|
|
459
|
-
const queryString = params.toString();
|
|
460
|
-
const query = queryString ? `?${queryString}` : '';
|
|
461
|
-
const response = await fetchImpl(`${baseUrl}/generations/discover${query}`, {
|
|
462
|
-
method: 'GET',
|
|
463
|
-
headers: await buildHeaders(),
|
|
464
|
-
credentials: resolveBrowserRequestCredentials(),
|
|
465
|
-
signal: options.signal,
|
|
466
|
-
});
|
|
467
|
-
await ensureOk(response);
|
|
468
|
-
const data = (await response.json());
|
|
469
|
-
return data;
|
|
470
|
-
}
|
|
471
|
-
return {
|
|
472
|
-
generateText,
|
|
473
|
-
createGenerationJob,
|
|
474
|
-
getGenerationJob,
|
|
475
|
-
listGenerationJobs,
|
|
476
|
-
deleteGenerationJob,
|
|
477
|
-
generateJson,
|
|
478
|
-
listGenerations,
|
|
479
|
-
listDiscoverGenerations,
|
|
253
|
+
}
|
|
254
|
+
} catch {
|
|
255
|
+
payload = null;
|
|
256
|
+
}
|
|
257
|
+
const code = payload?.error ?? `http_${response.status}`;
|
|
258
|
+
const message = payload?.message ?? response.statusText ?? "Request failed";
|
|
259
|
+
const error = new Error(`${code}: ${message}`);
|
|
260
|
+
error.status = response.status;
|
|
261
|
+
error.code = code;
|
|
262
|
+
error.details = payload;
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
async function ensureOk(response) {
|
|
266
|
+
if (!response.ok) {
|
|
267
|
+
await throwHttpError(response);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async function generateText(input, options) {
|
|
271
|
+
const normalizedInput = input?.trim();
|
|
272
|
+
if (!normalizedInput) {
|
|
273
|
+
throw new Error("ai_client_missing_input");
|
|
274
|
+
}
|
|
275
|
+
const size = options?.size ?? "small";
|
|
276
|
+
const mode = options?.mode ?? "text";
|
|
277
|
+
const rawSystem = options?.system?.trim();
|
|
278
|
+
const system = rawSystem && rawSystem.length ? rawSystem : void 0;
|
|
279
|
+
const response = await fetchImpl(`${baseUrl}/text/generate`, await buildRequestInit({
|
|
280
|
+
input: normalizedInput,
|
|
281
|
+
size,
|
|
282
|
+
mode,
|
|
283
|
+
system
|
|
284
|
+
}, options?.signal));
|
|
285
|
+
await ensureOk(response);
|
|
286
|
+
const data = await response.json();
|
|
287
|
+
return data;
|
|
288
|
+
}
|
|
289
|
+
function applyMediaGenerationPayload(payload, request) {
|
|
290
|
+
if (request.modality === "IMAGE") {
|
|
291
|
+
payload.mode = "image";
|
|
292
|
+
payload.image1 = request.image1 ?? void 0;
|
|
293
|
+
payload.image2 = request.image2 ?? void 0;
|
|
294
|
+
payload.aspectRatio = request.aspectRatio;
|
|
295
|
+
payload.imageSize = request.imageSize;
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
if (request.modality === "VIDEO") {
|
|
299
|
+
payload.durationSeconds = typeof request.durationSeconds === "number" ? request.durationSeconds : void 0;
|
|
300
|
+
payload.aspectRatio = request.aspectRatio;
|
|
301
|
+
payload.resolution = "720p";
|
|
302
|
+
payload.image1 = request.image1 ?? void 0;
|
|
303
|
+
payload.image2 = request.image2 ?? void 0;
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
function applyAudioGenerationPayload(payload, request) {
|
|
309
|
+
if (request.modality === "MUSIC") {
|
|
310
|
+
payload.durationMs = typeof request.durationMs === "number" ? request.durationMs : void 0;
|
|
311
|
+
payload.forceInstrumental = typeof request.forceInstrumental === "boolean" ? request.forceInstrumental : void 0;
|
|
312
|
+
payload.coverPrompt = typeof request.coverPrompt === "string" ? request.coverPrompt : void 0;
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
if (request.modality === "SFX") {
|
|
316
|
+
payload.durationSeconds = typeof request.durationSeconds === "number" ? request.durationSeconds : void 0;
|
|
317
|
+
payload.loop = typeof request.loop === "boolean" ? request.loop : void 0;
|
|
318
|
+
payload.coverPrompt = typeof request.coverPrompt === "string" ? request.coverPrompt : void 0;
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
if (request.modality === "SPEECH") {
|
|
322
|
+
payload.speechVoice = typeof request.speechVoice === "string" ? request.speechVoice : void 0;
|
|
323
|
+
payload.speechProviderVoiceId = typeof request.speechProviderVoiceId === "string" ? request.speechProviderVoiceId : void 0;
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
function applyGenerateAssetPayloadByModality(payload, request) {
|
|
329
|
+
if (applyMediaGenerationPayload(payload, request) || applyAudioGenerationPayload(payload, request)) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (request.modality === "MODEL_3D") {
|
|
333
|
+
payload.sourceMode = request.sourceMode;
|
|
334
|
+
payload.image1 = request.image1 ?? void 0;
|
|
335
|
+
payload.image2 = request.image2 ?? void 0;
|
|
336
|
+
payload.topology = request.topology;
|
|
337
|
+
payload.targetPolycount = typeof request.targetPolycount === "number" ? request.targetPolycount : void 0;
|
|
338
|
+
payload.shouldRemesh = typeof request.shouldRemesh === "boolean" ? request.shouldRemesh : void 0;
|
|
339
|
+
payload.shouldTexture = typeof request.shouldTexture === "boolean" ? request.shouldTexture : void 0;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function buildGenerateAssetPayload(request) {
|
|
343
|
+
const normalizedInput = request.input?.trim();
|
|
344
|
+
if (!normalizedInput) {
|
|
345
|
+
throw new Error("ai_client_missing_input");
|
|
346
|
+
}
|
|
347
|
+
const payload = {
|
|
348
|
+
modality: request.modality,
|
|
349
|
+
input: normalizedInput,
|
|
350
|
+
assetName: request.assetName,
|
|
351
|
+
assetDisplayName: request.assetDisplayName,
|
|
352
|
+
assetDescription: request.assetDescription,
|
|
353
|
+
assetVisibility: request.assetVisibility,
|
|
354
|
+
attachAppVersionId: request.attachAppVersionId,
|
|
355
|
+
remixAssetVersionRef: request.remixAssetVersionRef
|
|
480
356
|
};
|
|
357
|
+
if (request.modality !== "SPEECH") {
|
|
358
|
+
payload.assetSubcategory = request.assetSubcategory;
|
|
359
|
+
}
|
|
360
|
+
applyGenerateAssetPayloadByModality(payload, request);
|
|
361
|
+
return payload;
|
|
362
|
+
}
|
|
363
|
+
async function createGenerationJob(request) {
|
|
364
|
+
const payload = buildGenerateAssetPayload(request);
|
|
365
|
+
const response = await fetchImpl(`${baseUrl}/ai/assets/jobs`, await buildRequestInit(payload, request.signal));
|
|
366
|
+
await ensureOk(response);
|
|
367
|
+
return await response.json();
|
|
368
|
+
}
|
|
369
|
+
async function getGenerationJob(id, options = {}) {
|
|
370
|
+
const normalizedId = id?.trim();
|
|
371
|
+
if (!normalizedId) {
|
|
372
|
+
throw new Error("ai_client_missing_job_id");
|
|
373
|
+
}
|
|
374
|
+
const response = await fetchImpl(`${baseUrl}/ai/assets/jobs/${encodeURIComponent(normalizedId)}`, {
|
|
375
|
+
method: "GET",
|
|
376
|
+
headers: await buildHeaders(),
|
|
377
|
+
credentials: resolveBrowserRequestCredentials(),
|
|
378
|
+
signal: options.signal
|
|
379
|
+
});
|
|
380
|
+
await ensureOk(response);
|
|
381
|
+
return await response.json();
|
|
382
|
+
}
|
|
383
|
+
async function listGenerationJobs(options = {}) {
|
|
384
|
+
const params = new URLSearchParams();
|
|
385
|
+
if (options.modality) {
|
|
386
|
+
params.set("modality", options.modality);
|
|
387
|
+
}
|
|
388
|
+
if (options.status) {
|
|
389
|
+
params.set("status", options.status);
|
|
390
|
+
}
|
|
391
|
+
if (typeof options.limit === "number" && Number.isFinite(options.limit)) {
|
|
392
|
+
params.set("limit", String(options.limit));
|
|
393
|
+
}
|
|
394
|
+
if (typeof options.offset === "number" && Number.isFinite(options.offset)) {
|
|
395
|
+
params.set("offset", String(options.offset));
|
|
396
|
+
}
|
|
397
|
+
const queryString = params.toString();
|
|
398
|
+
const query = queryString ? `?${queryString}` : "";
|
|
399
|
+
const response = await fetchImpl(`${baseUrl}/ai/assets/jobs${query}`, {
|
|
400
|
+
method: "GET",
|
|
401
|
+
headers: await buildHeaders(),
|
|
402
|
+
credentials: resolveBrowserRequestCredentials(),
|
|
403
|
+
signal: options.signal
|
|
404
|
+
});
|
|
405
|
+
await ensureOk(response);
|
|
406
|
+
return await response.json();
|
|
407
|
+
}
|
|
408
|
+
async function deleteGenerationJob(id, options = {}) {
|
|
409
|
+
const normalizedId = id?.trim();
|
|
410
|
+
if (!normalizedId) {
|
|
411
|
+
throw new Error("ai_client_missing_job_id");
|
|
412
|
+
}
|
|
413
|
+
const response = await fetchImpl(`${baseUrl}/ai/assets/jobs/${encodeURIComponent(normalizedId)}`, {
|
|
414
|
+
method: "DELETE",
|
|
415
|
+
headers: await buildHeaders(),
|
|
416
|
+
credentials: resolveBrowserRequestCredentials(),
|
|
417
|
+
signal: options.signal
|
|
418
|
+
});
|
|
419
|
+
await ensureOk(response);
|
|
420
|
+
}
|
|
421
|
+
async function generateJson(input, options) {
|
|
422
|
+
const normalizedInput = input?.trim();
|
|
423
|
+
if (!normalizedInput) {
|
|
424
|
+
throw new Error("ai_client_missing_input");
|
|
425
|
+
}
|
|
426
|
+
const normalizedSystem = options?.system?.trim();
|
|
427
|
+
const response = await fetchImpl(`${baseUrl}/json/generate`, await buildRequestInit({
|
|
428
|
+
input: normalizedInput,
|
|
429
|
+
size: options?.size ?? "small",
|
|
430
|
+
system: normalizedSystem && normalizedSystem.length ? normalizedSystem : void 0,
|
|
431
|
+
responseJsonSchema: options?.responseJsonSchema
|
|
432
|
+
}, options?.signal));
|
|
433
|
+
await ensureOk(response);
|
|
434
|
+
const data = await response.json();
|
|
435
|
+
return data;
|
|
436
|
+
}
|
|
437
|
+
async function listGenerations(options = {}) {
|
|
438
|
+
const params = new URLSearchParams();
|
|
439
|
+
if (options.type) {
|
|
440
|
+
params.set("type", options.type);
|
|
441
|
+
}
|
|
442
|
+
if (typeof options.limit === "number" && Number.isFinite(options.limit)) {
|
|
443
|
+
params.set("limit", String(options.limit));
|
|
444
|
+
}
|
|
445
|
+
if (typeof options.offset === "number" && Number.isFinite(options.offset)) {
|
|
446
|
+
params.set("offset", String(options.offset));
|
|
447
|
+
}
|
|
448
|
+
const queryString = params.toString();
|
|
449
|
+
const query = queryString ? `?${queryString}` : "";
|
|
450
|
+
const response = await fetchImpl(`${baseUrl}/generations${query}`, {
|
|
451
|
+
method: "GET",
|
|
452
|
+
headers: await buildHeaders(),
|
|
453
|
+
credentials: resolveBrowserRequestCredentials(),
|
|
454
|
+
signal: options.signal
|
|
455
|
+
});
|
|
456
|
+
await ensureOk(response);
|
|
457
|
+
const data = await response.json();
|
|
458
|
+
return data;
|
|
459
|
+
}
|
|
460
|
+
async function listDiscoverGenerations(options = {}) {
|
|
461
|
+
const params = new URLSearchParams();
|
|
462
|
+
if (options.type) {
|
|
463
|
+
params.set("type", options.type);
|
|
464
|
+
}
|
|
465
|
+
if (typeof options.limit === "number" && Number.isFinite(options.limit)) {
|
|
466
|
+
params.set("limit", String(options.limit));
|
|
467
|
+
}
|
|
468
|
+
if (typeof options.offset === "number" && Number.isFinite(options.offset)) {
|
|
469
|
+
params.set("offset", String(options.offset));
|
|
470
|
+
}
|
|
471
|
+
const queryString = params.toString();
|
|
472
|
+
const query = queryString ? `?${queryString}` : "";
|
|
473
|
+
const response = await fetchImpl(`${baseUrl}/generations/discover${query}`, {
|
|
474
|
+
method: "GET",
|
|
475
|
+
headers: await buildHeaders(),
|
|
476
|
+
credentials: resolveBrowserRequestCredentials(),
|
|
477
|
+
signal: options.signal
|
|
478
|
+
});
|
|
479
|
+
await ensureOk(response);
|
|
480
|
+
const data = await response.json();
|
|
481
|
+
return data;
|
|
482
|
+
}
|
|
483
|
+
return {
|
|
484
|
+
generateText,
|
|
485
|
+
createGenerationJob,
|
|
486
|
+
getGenerationJob,
|
|
487
|
+
listGenerationJobs,
|
|
488
|
+
deleteGenerationJob,
|
|
489
|
+
generateJson,
|
|
490
|
+
listGenerations,
|
|
491
|
+
listDiscoverGenerations
|
|
492
|
+
};
|
|
481
493
|
}
|
|
494
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
495
|
+
0 && (module.exports = {
|
|
496
|
+
GENERATION_JOB_ETA_BASELINE_SECONDS,
|
|
497
|
+
createAiClient
|
|
498
|
+
});
|