@wix/ditto-codegen-public 1.0.516 → 1.0.518
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/opencode-tools/env-tools/upload-media.ts +387 -0
- package/dist/out.js +65 -3
- package/package.json +2 -2
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import {
|
|
4
|
+
mkdir,
|
|
5
|
+
mkdtemp,
|
|
6
|
+
readFile,
|
|
7
|
+
realpath,
|
|
8
|
+
writeFile,
|
|
9
|
+
} from "node:fs/promises";
|
|
10
|
+
import { join, parse, resolve, sep } from "node:path";
|
|
11
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
12
|
+
import { promisify } from "node:util";
|
|
13
|
+
import { tool } from "@opencode-ai/plugin";
|
|
14
|
+
|
|
15
|
+
const execFileAsync = promisify(execFile);
|
|
16
|
+
|
|
17
|
+
const MEDIA_FILES_API = "https://www.wixapis.com/site-media/v1/files";
|
|
18
|
+
const WORK_DIR = "/tmp/user-images";
|
|
19
|
+
const INSTALL_TIMEOUT_MS = 180_000;
|
|
20
|
+
const CHILD_TIMEOUT_MS = 120_000;
|
|
21
|
+
const UPLOAD_TIMEOUT_MS = 120_000;
|
|
22
|
+
const IMPORT_POLL_MS = 1_000;
|
|
23
|
+
const IMPORT_TIMEOUT_MS = 30_000;
|
|
24
|
+
const IMAGE_ENV = {
|
|
25
|
+
PATH: "/usr/local/bin:/usr/bin:/bin",
|
|
26
|
+
HOME: WORK_DIR,
|
|
27
|
+
TMPDIR: WORK_DIR,
|
|
28
|
+
LANG: process.env.LANG ?? "C.UTF-8",
|
|
29
|
+
};
|
|
30
|
+
const CROP =
|
|
31
|
+
/^(\d+(?:\.\d+)?)%,(\d+(?:\.\d+)?)%,(\d+(?:\.\d+)?)%,(\d+(?:\.\d+)?)%$/;
|
|
32
|
+
|
|
33
|
+
interface Image {
|
|
34
|
+
source?: string;
|
|
35
|
+
crop?: string;
|
|
36
|
+
render?: { file: string; export: string; args: unknown[] };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const CHILD_SOURCE = String.raw`
|
|
40
|
+
const fs = require("fs");
|
|
41
|
+
const { createRequire } = require("module");
|
|
42
|
+
const load = createRequire(__filename);
|
|
43
|
+
const [mode, input, output, ...rest] = process.argv.slice(2);
|
|
44
|
+
|
|
45
|
+
async function crop() {
|
|
46
|
+
const sharp = load("sharp");
|
|
47
|
+
const image = sharp(input).autoOrient();
|
|
48
|
+
const { autoOrient: { width, height } } = await image.metadata();
|
|
49
|
+
const [left, top, w, h] = rest.map(Number);
|
|
50
|
+
const x = Math.round((left / 100) * width);
|
|
51
|
+
const y = Math.round((top / 100) * height);
|
|
52
|
+
const area = {
|
|
53
|
+
left: x,
|
|
54
|
+
top: y,
|
|
55
|
+
width: Math.min(Math.round((w / 100) * width), width - x),
|
|
56
|
+
height: Math.min(Math.round((h / 100) * height), height - y),
|
|
57
|
+
};
|
|
58
|
+
fs.writeFileSync(output, await image.extract(area).webp({ quality: 90 }).toBuffer());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function render() {
|
|
62
|
+
const canvas = load("@napi-rs/canvas");
|
|
63
|
+
const esbuild = load("esbuild");
|
|
64
|
+
globalThis.window = globalThis;
|
|
65
|
+
globalThis.devicePixelRatio = 1;
|
|
66
|
+
globalThis.document = {
|
|
67
|
+
hidden: false,
|
|
68
|
+
createElement(tag) {
|
|
69
|
+
if (String(tag).toLowerCase() !== "canvas") {
|
|
70
|
+
throw new Error("document.createElement('" + tag + "') isn't available while rendering");
|
|
71
|
+
}
|
|
72
|
+
return canvas.createCanvas(300, 150);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
globalThis.OffscreenCanvas = class {
|
|
76
|
+
constructor(width, height) {
|
|
77
|
+
return canvas.createCanvas(width, height);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
globalThis.Image = canvas.Image;
|
|
81
|
+
const [exportName, args] = rest;
|
|
82
|
+
const bundle = esbuild.buildSync({
|
|
83
|
+
entryPoints: [input],
|
|
84
|
+
bundle: true,
|
|
85
|
+
write: false,
|
|
86
|
+
platform: "node",
|
|
87
|
+
format: "cjs",
|
|
88
|
+
logLevel: "silent",
|
|
89
|
+
});
|
|
90
|
+
const module = { exports: {} };
|
|
91
|
+
new Function("module", "exports", "require", bundle.outputFiles[0].text)(
|
|
92
|
+
module,
|
|
93
|
+
module.exports,
|
|
94
|
+
createRequire(input),
|
|
95
|
+
);
|
|
96
|
+
const paint = module.exports[exportName];
|
|
97
|
+
if (typeof paint !== "function") throw new Error(input + ' exports no function "' + exportName + '"');
|
|
98
|
+
const result = await paint(...JSON.parse(args));
|
|
99
|
+
const dataUrl = typeof result === "string" && /^data:image\/[\w+.-]+;base64,(.*)$/s.exec(result);
|
|
100
|
+
if (dataUrl) return fs.writeFileSync(output, Buffer.from(dataUrl[1], "base64"));
|
|
101
|
+
if (typeof result?.toBuffer === "function") return fs.writeFileSync(output, result.toBuffer("image/png"));
|
|
102
|
+
throw new Error("The function returned neither a data:image URL nor a canvas");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
(mode === "crop" ? crop() : render()).catch((error) => {
|
|
106
|
+
console.error(error.message);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
});
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
function imageType(bytes: Buffer): { mimeType: string; extension: string } {
|
|
112
|
+
const ascii = (start: number, end: number) =>
|
|
113
|
+
bytes.subarray(start, end).toString("latin1");
|
|
114
|
+
if (bytes[0] === 0x89 && ascii(1, 4) === "PNG")
|
|
115
|
+
return { mimeType: "image/png", extension: ".png" };
|
|
116
|
+
if (bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff)
|
|
117
|
+
return { mimeType: "image/jpeg", extension: ".jpg" };
|
|
118
|
+
if (ascii(0, 4) === "RIFF" && ascii(8, 12) === "WEBP")
|
|
119
|
+
return { mimeType: "image/webp", extension: ".webp" };
|
|
120
|
+
if (ascii(0, 4) === "GIF8")
|
|
121
|
+
return { mimeType: "image/gif", extension: ".gif" };
|
|
122
|
+
if (ascii(4, 12) === "ftypavif")
|
|
123
|
+
return { mimeType: "image/avif", extension: ".avif" };
|
|
124
|
+
throw new Error("Not a PNG, JPEG, WebP, GIF or AVIF image");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function cropPercents(crop: string): string[] {
|
|
128
|
+
const match = CROP.exec(crop.replace(/\s+/g, ""));
|
|
129
|
+
const [left, top, width, height] = (match ?? []).slice(1).map(Number);
|
|
130
|
+
if (!match || !width || !height || left + width > 100 || top + height > 100) {
|
|
131
|
+
throw new Error(
|
|
132
|
+
`Invalid crop "${crop}"; use left,top,width,height in % inside the image`,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
return match.slice(1);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function install(packages: string[]): Promise<void> {
|
|
139
|
+
const missing = packages.filter(
|
|
140
|
+
(name) => !existsSync(join(WORK_DIR, "node_modules", name, "package.json")),
|
|
141
|
+
);
|
|
142
|
+
if (missing.length === 0) return;
|
|
143
|
+
await execFileAsync(
|
|
144
|
+
"npm",
|
|
145
|
+
[
|
|
146
|
+
"install",
|
|
147
|
+
"--prefix",
|
|
148
|
+
WORK_DIR,
|
|
149
|
+
"--no-save",
|
|
150
|
+
"--no-audit",
|
|
151
|
+
"--no-fund",
|
|
152
|
+
"--loglevel=error",
|
|
153
|
+
...missing,
|
|
154
|
+
],
|
|
155
|
+
{ cwd: WORK_DIR, env: IMAGE_ENV, timeout: INSTALL_TIMEOUT_MS },
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function runChild(args: string[], output: string): Promise<Buffer> {
|
|
160
|
+
const script = join(WORK_DIR, "media-child.cjs");
|
|
161
|
+
await writeFile(script, CHILD_SOURCE);
|
|
162
|
+
try {
|
|
163
|
+
await execFileAsync("node", [script, ...args], {
|
|
164
|
+
cwd: WORK_DIR,
|
|
165
|
+
env: IMAGE_ENV,
|
|
166
|
+
timeout: CHILD_TIMEOUT_MS,
|
|
167
|
+
});
|
|
168
|
+
} catch (error) {
|
|
169
|
+
const { stderr, message } = error as { stderr?: string; message: string };
|
|
170
|
+
throw new Error(stderr?.trim().split("\n").pop() || message);
|
|
171
|
+
}
|
|
172
|
+
return readFile(output);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function allowedFile(directory: string, file: string): Promise<string> {
|
|
176
|
+
const path = await realpath(resolve(directory, file));
|
|
177
|
+
const roots = await Promise.all(
|
|
178
|
+
[directory, WORK_DIR].map((root) => realpath(root)),
|
|
179
|
+
);
|
|
180
|
+
if (!roots.some((root) => path.startsWith(root + sep)))
|
|
181
|
+
throw new Error(`${file} is outside the project and ${WORK_DIR}`);
|
|
182
|
+
return path;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async function imageBytes(
|
|
186
|
+
image: Image,
|
|
187
|
+
directory: string,
|
|
188
|
+
output: string,
|
|
189
|
+
): Promise<Buffer> {
|
|
190
|
+
if (image.render) {
|
|
191
|
+
const { file, export: exportName, args } = image.render;
|
|
192
|
+
await install(["@napi-rs/canvas", "esbuild"]);
|
|
193
|
+
return runChild(
|
|
194
|
+
[
|
|
195
|
+
"render",
|
|
196
|
+
await allowedFile(directory, file),
|
|
197
|
+
output,
|
|
198
|
+
exportName,
|
|
199
|
+
JSON.stringify(args),
|
|
200
|
+
],
|
|
201
|
+
output,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
if (!image.source) throw new Error("Give each image a source or a render");
|
|
205
|
+
const source = await allowedFile(directory, image.source);
|
|
206
|
+
if (!image.crop) return readFile(source);
|
|
207
|
+
const percents = cropPercents(image.crop);
|
|
208
|
+
await install(["sharp"]);
|
|
209
|
+
return runChild(["crop", source, output, ...percents], output);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async function httpError(step: string, response: Response): Promise<Error> {
|
|
213
|
+
const body = (await response.text()).slice(0, 300);
|
|
214
|
+
return new Error(`${step} failed, HTTP ${response.status}: ${body}`);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function mediaFile(
|
|
218
|
+
step: string,
|
|
219
|
+
response: Response,
|
|
220
|
+
): Promise<{ uri: string; url: string }> {
|
|
221
|
+
if (!response.ok) throw await httpError(step, response);
|
|
222
|
+
const { file } = (await response.json()) as {
|
|
223
|
+
file?: { id?: string; url?: string };
|
|
224
|
+
};
|
|
225
|
+
if (!file?.id || !file.url)
|
|
226
|
+
throw new Error(`${step} response has no file id or url`);
|
|
227
|
+
return { uri: file.id, url: file.url };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function postMedia(
|
|
231
|
+
path: string,
|
|
232
|
+
body: object,
|
|
233
|
+
token: string,
|
|
234
|
+
signal?: AbortSignal,
|
|
235
|
+
) {
|
|
236
|
+
return fetch(`${MEDIA_FILES_API}/${path}`, {
|
|
237
|
+
method: "POST",
|
|
238
|
+
headers: { Authorization: token, "Content-Type": "application/json" },
|
|
239
|
+
body: JSON.stringify(body),
|
|
240
|
+
signal,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
async function upload(bytes: Buffer, name: string, token: string) {
|
|
245
|
+
const { mimeType, extension } = imageType(bytes);
|
|
246
|
+
const fileName = `${name.replace(/[^a-z0-9]+/gi, "-").replace(/^-|-$/g, "") || "image"}${extension}`;
|
|
247
|
+
const signal = AbortSignal.timeout(UPLOAD_TIMEOUT_MS);
|
|
248
|
+
const generated = await postMedia(
|
|
249
|
+
"generate-upload-url",
|
|
250
|
+
{ mimeType, fileName },
|
|
251
|
+
token,
|
|
252
|
+
signal,
|
|
253
|
+
);
|
|
254
|
+
if (!generated.ok)
|
|
255
|
+
throw await httpError("Generate File Upload URL", generated);
|
|
256
|
+
const { uploadUrl } = (await generated.json()) as { uploadUrl: string };
|
|
257
|
+
const uploaded = await fetch(
|
|
258
|
+
`${uploadUrl}?filename=${encodeURIComponent(fileName)}`,
|
|
259
|
+
{
|
|
260
|
+
method: "PUT",
|
|
261
|
+
headers: { "Content-Type": mimeType },
|
|
262
|
+
body: bytes,
|
|
263
|
+
signal,
|
|
264
|
+
},
|
|
265
|
+
);
|
|
266
|
+
return mediaFile("Upload", uploaded);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Import File answers while the file is still PENDING; wait until Wix has it.
|
|
270
|
+
async function importFile(url: string, token: string) {
|
|
271
|
+
const signal = AbortSignal.timeout(IMPORT_TIMEOUT_MS);
|
|
272
|
+
const file = await mediaFile(
|
|
273
|
+
"Import File",
|
|
274
|
+
await postMedia("import", { url, mediaType: "IMAGE" }, token, signal),
|
|
275
|
+
);
|
|
276
|
+
while (!signal.aborted) {
|
|
277
|
+
const response = await fetch(
|
|
278
|
+
`${MEDIA_FILES_API}/get-file-by-id?fileId=${encodeURIComponent(file.uri)}`,
|
|
279
|
+
{ headers: { Authorization: token }, signal },
|
|
280
|
+
);
|
|
281
|
+
if (!response.ok) throw await httpError("Get File Descriptor", response);
|
|
282
|
+
const { file: descriptor } = (await response.json()) as {
|
|
283
|
+
file?: { operationStatus?: string };
|
|
284
|
+
};
|
|
285
|
+
if (descriptor?.operationStatus === "READY") return file;
|
|
286
|
+
if (descriptor?.operationStatus === "FAILED")
|
|
287
|
+
throw new Error("Wix could not import the image from this URL");
|
|
288
|
+
await sleep(IMPORT_POLL_MS, undefined, { signal });
|
|
289
|
+
}
|
|
290
|
+
throw new Error(
|
|
291
|
+
`Wix did not finish importing the image in ${IMPORT_TIMEOUT_MS / 1000} s`,
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
async function uploadImage(
|
|
296
|
+
image: Image,
|
|
297
|
+
directory: string,
|
|
298
|
+
output: string,
|
|
299
|
+
token: string,
|
|
300
|
+
) {
|
|
301
|
+
if (image.source && /^https?:\/\//i.test(image.source)) {
|
|
302
|
+
if (image.crop) throw new Error("Only a file source can be cropped");
|
|
303
|
+
return importFile(image.source, token);
|
|
304
|
+
}
|
|
305
|
+
const name = image.render?.export ?? parse(image.source ?? "").name;
|
|
306
|
+
return upload(await imageBytes(image, directory, output), name, token);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
async function getWixAccessToken(): Promise<string> {
|
|
310
|
+
const { stdout } = await execFileAsync("wix", ["token", "--json"], {
|
|
311
|
+
timeout: 30_000,
|
|
312
|
+
});
|
|
313
|
+
const { accessToken } = JSON.parse(stdout) as { accessToken?: string };
|
|
314
|
+
if (!accessToken) throw new Error("wix token returned empty accessToken");
|
|
315
|
+
return accessToken;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export default tool({
|
|
319
|
+
description:
|
|
320
|
+
"Upload images to the site's Media Manager and get the `{ uri, url }` an `Image` default needs. " +
|
|
321
|
+
"Each image is a project file or an image URL (`source`), a file optionally cropped to a region (`crop`), " +
|
|
322
|
+
"or an image the user's code paints (`render`). Returns one result per image, in order: " +
|
|
323
|
+
"`image` when it uploaded, `error` when it didn't, and for a crop the cropped `file` to look at.",
|
|
324
|
+
args: {
|
|
325
|
+
images: tool.schema
|
|
326
|
+
.array(
|
|
327
|
+
tool.schema.object({
|
|
328
|
+
source: tool.schema
|
|
329
|
+
.string()
|
|
330
|
+
.optional()
|
|
331
|
+
.describe(
|
|
332
|
+
"A project-relative file path (attachments under .wix/agentInput/attachments/ too) or an image URL.",
|
|
333
|
+
),
|
|
334
|
+
crop: tool.schema
|
|
335
|
+
.string()
|
|
336
|
+
.optional()
|
|
337
|
+
.describe(
|
|
338
|
+
"Crop a file `source` first: `left,top,width,height` in % of the image, e.g. `0%,12%,25%,74%`.",
|
|
339
|
+
),
|
|
340
|
+
render: tool.schema
|
|
341
|
+
.object({
|
|
342
|
+
file: tool.schema
|
|
343
|
+
.string()
|
|
344
|
+
.describe("The project file that exports the painter."),
|
|
345
|
+
export: tool.schema
|
|
346
|
+
.string()
|
|
347
|
+
.describe("The painter's export name."),
|
|
348
|
+
args: tool.schema
|
|
349
|
+
.array(tool.schema.unknown())
|
|
350
|
+
.describe("The painter's arguments for this image."),
|
|
351
|
+
})
|
|
352
|
+
.optional()
|
|
353
|
+
.describe(
|
|
354
|
+
"Paint the image with the user's function, which returns a data:image URL or a canvas.",
|
|
355
|
+
),
|
|
356
|
+
}),
|
|
357
|
+
)
|
|
358
|
+
.min(1),
|
|
359
|
+
},
|
|
360
|
+
async execute({ images }, context) {
|
|
361
|
+
let token: string;
|
|
362
|
+
try {
|
|
363
|
+
token = await getWixAccessToken();
|
|
364
|
+
} catch (error) {
|
|
365
|
+
const message = `Could not get a Wix token: ${(error as Error).message}`;
|
|
366
|
+
return JSON.stringify(
|
|
367
|
+
images.map((image) => ({ ...image, error: message })),
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
await mkdir(WORK_DIR, { recursive: true });
|
|
371
|
+
const folder = await mkdtemp(join(WORK_DIR, "upload-"));
|
|
372
|
+
const results = [];
|
|
373
|
+
for (const [index, image] of images.entries()) {
|
|
374
|
+
const output = join(folder, `image-${index + 1}`);
|
|
375
|
+
try {
|
|
376
|
+
results.push({
|
|
377
|
+
...image,
|
|
378
|
+
...(image.crop ? { file: output } : {}),
|
|
379
|
+
image: await uploadImage(image, context.directory, output, token),
|
|
380
|
+
});
|
|
381
|
+
} catch (error) {
|
|
382
|
+
results.push({ ...image, error: (error as Error).message });
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return JSON.stringify(results);
|
|
386
|
+
},
|
|
387
|
+
});
|
package/dist/out.js
CHANGED
|
@@ -13891,6 +13891,8 @@ var require_checkpoint = __commonJS({
|
|
|
13891
13891
|
var http_client_1 = require_index_node();
|
|
13892
13892
|
var ditto_codegen_types_12 = require_dist4();
|
|
13893
13893
|
var MAX_CHECKPOINT_ERROR_LENGTH = 1e3;
|
|
13894
|
+
var BUSY_CODES = /* @__PURE__ */ new Set(["RESTORE_BUSY", "CHECKPOINT_BUSY"]);
|
|
13895
|
+
var OPERATION_IN_PROGRESS_RETRY_DELAYS_MS = [5e3, 1e4, 15e3];
|
|
13894
13896
|
var TRUNCATION_SUFFIX = "\u2026";
|
|
13895
13897
|
var COMMON_CONFIG_BY_ENVIRONMENT = {
|
|
13896
13898
|
STUDIO_2: { host: "STUDIO2", brand: "studio" }
|
|
@@ -13953,12 +13955,33 @@ Likely cause: a context provider's or function library's moduleSpecifier either
|
|
|
13953
13955
|
return false;
|
|
13954
13956
|
return Object.keys(requestHeaders).some((key) => key.toLowerCase() === "authorization");
|
|
13955
13957
|
};
|
|
13958
|
+
var isOperationInProgress = (error) => {
|
|
13959
|
+
const code = readApplicationErrorCode(error);
|
|
13960
|
+
return code !== void 0 && BUSY_CODES.has(code);
|
|
13961
|
+
};
|
|
13962
|
+
var requestCheckpoint = async (client, siteBranchId, logger) => {
|
|
13963
|
+
for (let attempt = 0; ; attempt++) {
|
|
13964
|
+
try {
|
|
13965
|
+
return await client.request((0, http_1.createCheckpoint)({ siteBranchId }));
|
|
13966
|
+
} catch (error) {
|
|
13967
|
+
const delayMs = OPERATION_IN_PROGRESS_RETRY_DELAYS_MS[attempt];
|
|
13968
|
+
if (delayMs === void 0 || !isOperationInProgress(error))
|
|
13969
|
+
throw error;
|
|
13970
|
+
logger.warn("[Checkpoint] another operation is running, retrying", {
|
|
13971
|
+
siteBranchId,
|
|
13972
|
+
attempt: attempt + 1,
|
|
13973
|
+
delayMs
|
|
13974
|
+
});
|
|
13975
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
13976
|
+
}
|
|
13977
|
+
}
|
|
13978
|
+
};
|
|
13956
13979
|
var callCreateCheckpoint = async (client, job, logger) => {
|
|
13957
13980
|
if (!job.siteBranchId) {
|
|
13958
13981
|
throw new Error("[Checkpoint] SITE_BRANCH_ID is required for the code-project-orchestrator checkpoint");
|
|
13959
13982
|
}
|
|
13960
13983
|
try {
|
|
13961
|
-
const resp = await client
|
|
13984
|
+
const resp = await requestCheckpoint(client, job.siteBranchId, logger);
|
|
13962
13985
|
const revision = resp.data?.revision;
|
|
13963
13986
|
return {
|
|
13964
13987
|
checkpointId: revision?.revisionId,
|
|
@@ -14351,7 +14374,7 @@ ${permissions.toolRule}${(0, shared_rules_1.buildFileOperationsRules)("fixing ty
|
|
|
14351
14374
|
- NEVER write a Wix SDK method, field, or enum value you haven't seen in a skill or a method schema.
|
|
14352
14375
|
- \`report-wix-feedback\` \u2014 report problems with the Wix docs (dev.wix.com, via wix-mcp) or the wix-mcp tools to Wix (when: workflow step ${permissions.reportDocsStep}). NOT for skill references or your own code.
|
|
14353
14376
|
- NEVER run preview, dev, release, or promote commands.
|
|
14354
|
-
- The ONE exception to YOUR BOUNDARIES' ban on uploading files: when the \`wix-app\` skill tells you to run its \`upload-media.cjs\` script
|
|
14377
|
+
- The ONE exception to YOUR BOUNDARIES' ban on uploading files: when you have the \`upload-media\` tool, upload with it every image the \`wix-app\` skill tells you to upload, also where the skill says to run its \`upload-media.cjs\` script. It puts the user's images into the site's Media Manager and returns the \`{ uri, url }\` an \`Image\` default needs, which makes it part of writing code. When the user asks to crop or render an image, its default is the \`{ uri, url }\` the tool returns, even when the request names an uploaded copy of the original. Never run that script or any other script that changes the site \u2014 publishing, releasing, deleting, and every other product/platform action stay off-limits.
|
|
14355
14378
|
|
|
14356
14379
|
KNOWN WIX APIS (already documented \u2014 do NOT rediscover these from node_modules; for full detail consult the \`wix-app\` skill's references or \`ReadFullDocsMethodSchema\`):
|
|
14357
14380
|
- Wix Data items CRUD: \`import { items } from "@wix/data"\` \u2014 \`items.query(collectionId)\`, \`items.get\`, \`items.insert\`, \`items.update\` (replaces the WHOLE item \u2014 send all fields), \`items.remove\`.
|
|
@@ -14541,6 +14564,28 @@ var require_telemetry_tools = __commonJS({
|
|
|
14541
14564
|
}
|
|
14542
14565
|
});
|
|
14543
14566
|
|
|
14567
|
+
// dist/opencode-integration/upload-media-tool.js
|
|
14568
|
+
var require_upload_media_tool = __commonJS({
|
|
14569
|
+
"dist/opencode-integration/upload-media-tool.js"(exports2) {
|
|
14570
|
+
"use strict";
|
|
14571
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
14572
|
+
exports2.uploadMediaToolPluginFactory = void 0;
|
|
14573
|
+
var fs_1 = require("fs");
|
|
14574
|
+
var path_12 = require("path");
|
|
14575
|
+
var install_manifest_1 = require_install_manifest();
|
|
14576
|
+
var uploadMediaToolPluginFactory = () => ({
|
|
14577
|
+
name: "upload-media",
|
|
14578
|
+
tools: [
|
|
14579
|
+
{
|
|
14580
|
+
filename: "upload-media.ts",
|
|
14581
|
+
source: (0, fs_1.readFileSync)((0, path_12.join)(install_manifest_1.OPENCODE_TOOLS_DIR, "env-tools", "upload-media.ts"), "utf-8")
|
|
14582
|
+
}
|
|
14583
|
+
]
|
|
14584
|
+
});
|
|
14585
|
+
exports2.uploadMediaToolPluginFactory = uploadMediaToolPluginFactory;
|
|
14586
|
+
}
|
|
14587
|
+
});
|
|
14588
|
+
|
|
14544
14589
|
// dist/jobs/job-decision-manager.js
|
|
14545
14590
|
var require_job_decision_manager = __commonJS({
|
|
14546
14591
|
"dist/jobs/job-decision-manager.js"(exports2) {
|
|
@@ -14632,6 +14677,7 @@ var require_environments = __commonJS({
|
|
|
14632
14677
|
var git_conflicts_rules_1 = require_git_conflicts_rules();
|
|
14633
14678
|
var install_manifest_1 = require_install_manifest();
|
|
14634
14679
|
var telemetry_tools_1 = require_telemetry_tools();
|
|
14680
|
+
var upload_media_tool_1 = require_upload_media_tool();
|
|
14635
14681
|
var model_knobs_1 = require_model_knobs();
|
|
14636
14682
|
var job_decision_manager_1 = require_job_decision_manager();
|
|
14637
14683
|
var logger_12 = require_logger();
|
|
@@ -14680,7 +14726,11 @@ var require_environments = __commonJS({
|
|
|
14680
14726
|
case types_1.Environment.STUDIO_2:
|
|
14681
14727
|
return withSharedRules({
|
|
14682
14728
|
...codegen_studio_2_config_1.studio2CodegenConfig,
|
|
14683
|
-
plugins: [
|
|
14729
|
+
plugins: [
|
|
14730
|
+
...codegen_studio_2_config_1.studio2CodegenConfig.plugins,
|
|
14731
|
+
telemetry_tools_1.telemetryToolsPluginFactory,
|
|
14732
|
+
upload_media_tool_1.uploadMediaToolPluginFactory
|
|
14733
|
+
]
|
|
14684
14734
|
});
|
|
14685
14735
|
case types_1.Environment.APP_BUILDER:
|
|
14686
14736
|
return withSharedRules({
|
|
@@ -15019,6 +15069,10 @@ When done, summarize each error: message, file, root cause, fix. No diffs.`;
|
|
|
15019
15069
|
[
|
|
15020
15070
|
"call-telemetry-tool"
|
|
15021
15071
|
/* OpenCodeTool.CallTelemetryTool */
|
|
15072
|
+
]: "deny",
|
|
15073
|
+
[
|
|
15074
|
+
"upload-media"
|
|
15075
|
+
/* OpenCodeTool.UploadMedia */
|
|
15022
15076
|
]: "deny"
|
|
15023
15077
|
};
|
|
15024
15078
|
var READ_TOOLS = {
|
|
@@ -120539,6 +120593,10 @@ var require_config = __commonJS({
|
|
|
120539
120593
|
[
|
|
120540
120594
|
"call-telemetry-tool"
|
|
120541
120595
|
/* OpenCodeTool.CallTelemetryTool */
|
|
120596
|
+
]: "deny",
|
|
120597
|
+
[
|
|
120598
|
+
"upload-media"
|
|
120599
|
+
/* OpenCodeTool.UploadMedia */
|
|
120542
120600
|
]: "deny"
|
|
120543
120601
|
};
|
|
120544
120602
|
var ASK_PERMISSIONS = {
|
|
@@ -120567,6 +120625,10 @@ var require_config = __commonJS({
|
|
|
120567
120625
|
"uuid"
|
|
120568
120626
|
/* OpenCodeTool.Uuid */
|
|
120569
120627
|
]: "deny",
|
|
120628
|
+
[
|
|
120629
|
+
"upload-media"
|
|
120630
|
+
/* OpenCodeTool.UploadMedia */
|
|
120631
|
+
]: "deny",
|
|
120570
120632
|
external_directory: READABLE_EXTERNAL_DIRS
|
|
120571
120633
|
};
|
|
120572
120634
|
function buildConfig(projectId, instructionPaths, permission, { isCodeWritingFlow = false, withAgents = false } = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/ditto-codegen-public",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.518",
|
|
4
4
|
"description": "AI-powered Wix CLI app generator - standalone executable",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node build.mjs",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"esbuild": "^0.27.2",
|
|
30
30
|
"vitest": "^4.0.16"
|
|
31
31
|
},
|
|
32
|
-
"falconPackageHash": "
|
|
32
|
+
"falconPackageHash": "69eeb441bed0c625d05a6125c33241750860227f4a4ccde4fbf4fbba"
|
|
33
33
|
}
|