@pixeldojo/mcp 0.2.1 → 0.4.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/cli.js CHANGED
@@ -1,29 +1,22 @@
1
+ import { stat, readFile } from 'fs/promises';
2
+ import { basename, extname } from 'path';
3
+ import { z } from 'zod';
1
4
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
5
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
6
  import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
4
7
  import { PixelDojoClient } from '@pixeldojo/sdk';
5
- import { z } from 'zod';
6
8
 
7
- // src/server.ts
8
- function makeAttributedClient(options) {
9
- const { mcpVersion, skillName, baseFetch, ...sdkOptions } = options;
10
- const real = baseFetch ?? globalThis.fetch.bind(globalThis);
11
- const wrappedFetch = (input, init) => {
12
- const headers = new Headers(init?.headers);
13
- headers.set("x-pixeldojo-source", `mcp/${mcpVersion}`);
14
- if (skillName) headers.set("x-pixeldojo-skill", skillName);
15
- return real(input, { ...init, headers });
16
- };
17
- return new PixelDojoClient({
18
- ...sdkOptions,
19
- fetch: wrappedFetch
20
- });
21
- }
9
+ var __defProp = Object.defineProperty;
10
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
+ var __esm = (fn, res) => function __init() {
12
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
13
+ };
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
22
18
 
23
19
  // src/poll.ts
24
- var DEFAULT_BACKOFF = [1e3, 2e3, 4e3, 8e3];
25
- var DEFAULT_MAX_INTERVAL = 8e3;
26
- var DEFAULT_SYNC_BUDGET_MS = 3e4;
27
20
  function defaultSleep(ms, signal) {
28
21
  return new Promise((resolve, reject) => {
29
22
  if (signal?.aborted) {
@@ -72,6 +65,14 @@ async function pollJobUntilDoneOrHandoff(jobId, fetchJob, buildStatusUrl, option
72
65
  attempt++;
73
66
  }
74
67
  }
68
+ var DEFAULT_BACKOFF, DEFAULT_MAX_INTERVAL, DEFAULT_SYNC_BUDGET_MS;
69
+ var init_poll = __esm({
70
+ "src/poll.ts"() {
71
+ DEFAULT_BACKOFF = [1e3, 2e3, 4e3, 8e3];
72
+ DEFAULT_MAX_INTERVAL = 8e3;
73
+ DEFAULT_SYNC_BUDGET_MS = 3e4;
74
+ }
75
+ });
75
76
 
76
77
  // src/skills/types.ts
77
78
  function pollResultToSkillResult(result, successText) {
@@ -106,46 +107,133 @@ function extractAssetUrls(job) {
106
107
  if (output?.video) return [output.video];
107
108
  return [];
108
109
  }
109
-
110
- // src/skills/generate.ts
111
- var InputSchema = z.object({
112
- prompt: z.string().min(1).max(8e3).describe("Prompt describing what to generate."),
113
- model: z.string().optional().describe(
114
- 'Override the model. Any apiId from /api/v1/models (e.g. "flux", "google-nano-banana", "veo-3.1", "kling-video"). Omit to use the default.'
115
- ),
116
- preset: z.string().optional().describe(
117
- 'Preset slug to seed the params (e.g. "cinematic-portrait", "product-floating-clean", "magazine-cover-text"). Browse the catalog at https://pixeldojo.ai/presets. Explicit fields override preset values.'
118
- ),
119
- aspect_ratio: z.string().optional().describe('Aspect ratio supported by the chosen model (e.g. "1:1", "16:9", "9:16").'),
120
- duration: z.number().int().positive().optional().describe("Video duration in seconds, when applicable."),
121
- image_url: z.string().url().optional().describe("Reference image URL for image-to-image / image-to-video tools.")
110
+ var init_types = __esm({
111
+ "src/skills/types.ts"() {
112
+ }
122
113
  });
123
- var DEFAULT_MODEL = "google-nano-banana";
124
- var InputJsonSchema = {
125
- type: "object",
126
- properties: {
127
- prompt: { type: "string", description: "Prompt describing what to generate." },
128
- model: {
129
- type: "string",
130
- description: 'Override the model. Any apiId from /api/v1/models (e.g. "flux", "google-nano-banana", "veo-3.1", "kling-video"). Omit to use the default.'
131
- },
132
- preset: {
133
- type: "string",
134
- description: 'Preset slug to seed the params (e.g. "cinematic-portrait", "product-floating-clean"). Explicit fields override preset values.'
135
- },
136
- aspect_ratio: { type: "string" },
137
- duration: { type: "integer" },
138
- image_url: { type: "string", format: "uri" }
139
- },
140
- required: ["prompt"]
141
- };
142
- async function run(input, ctx) {
143
- const apiId = input.model ?? DEFAULT_MODEL;
114
+ async function uploadLocalFile(path, client) {
115
+ const ext = extname(path).toLowerCase();
116
+ const mime = EXT_TO_MIME[ext];
117
+ if (!mime) {
118
+ throw new SkillUploadError(
119
+ `Unsupported file extension "${ext || "(none)"}" for "${path}". Allowed: ${Object.keys(EXT_TO_MIME).join(", ")}.`
120
+ );
121
+ }
122
+ let size;
123
+ try {
124
+ const info = await stat(path);
125
+ if (!info.isFile()) {
126
+ throw new SkillUploadError(`"${path}" is not a file.`);
127
+ }
128
+ size = info.size;
129
+ } catch (err) {
130
+ if (err instanceof SkillUploadError) throw err;
131
+ const code = err?.code;
132
+ if (code === "ENOENT") {
133
+ throw new SkillUploadError(
134
+ `File not found at "${path}". Pass an absolute path.`
135
+ );
136
+ }
137
+ throw new SkillUploadError(
138
+ `Cannot read "${path}": ${err instanceof Error ? err.message : String(err)}`
139
+ );
140
+ }
141
+ const isImage = mime.startsWith("image/");
142
+ const limit = isImage ? MAX_IMAGE_BYTES : MAX_VIDEO_BYTES;
143
+ if (size > limit) {
144
+ const gotMB = (size / 1024 / 1024).toFixed(1);
145
+ const limitMB = (limit / 1024 / 1024).toFixed(0);
146
+ throw new SkillUploadError(
147
+ `"${basename(path)}" is ${gotMB}MB; limit for ${isImage ? "images" : "videos"} is ${limitMB}MB. Downscale or re-encode and try again.`
148
+ );
149
+ }
150
+ const buffer = await readFile(path);
151
+ const blob = new Blob([new Uint8Array(buffer)], { type: mime });
152
+ const filename = basename(path);
153
+ const response = await client.uploadImage(blob, filename);
154
+ return response.url;
155
+ }
156
+ async function uploadLocalFiles(paths, client) {
157
+ return Promise.all(paths.map((p) => uploadLocalFile(p, client)));
158
+ }
159
+ var MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, EXT_TO_MIME, SkillUploadError;
160
+ var init_upload_helpers = __esm({
161
+ "src/skills/upload-helpers.ts"() {
162
+ MAX_IMAGE_BYTES = 50 * 1024 * 1024;
163
+ MAX_VIDEO_BYTES = 200 * 1024 * 1024;
164
+ EXT_TO_MIME = {
165
+ ".jpg": "image/jpeg",
166
+ ".jpeg": "image/jpeg",
167
+ ".png": "image/png",
168
+ ".webp": "image/webp",
169
+ ".gif": "image/gif",
170
+ ".mp4": "video/mp4",
171
+ ".webm": "video/webm",
172
+ ".mov": "video/quicktime"
173
+ };
174
+ SkillUploadError = class extends Error {
175
+ constructor(userMessage) {
176
+ super(userMessage);
177
+ this.userMessage = userMessage;
178
+ this.name = "SkillUploadError";
179
+ }
180
+ userMessage;
181
+ };
182
+ }
183
+ });
184
+ function buildPayload(apiId, input) {
144
185
  const body = { prompt: input.prompt };
145
186
  if (input.aspect_ratio) body.aspect_ratio = input.aspect_ratio;
146
- if (input.duration !== void 0) body.duration = input.duration;
147
- if (input.image_url) body.image_url = input.image_url;
148
187
  if (input.preset) body.preset = input.preset;
188
+ switch (apiId) {
189
+ case "grok-video-extend":
190
+ case "wan-video-edit":
191
+ case "seedance-video-edit":
192
+ if (input.image_url) {
193
+ body.video_url = input.image_url;
194
+ body.image_url = input.image_url;
195
+ }
196
+ if (input.duration !== void 0) {
197
+ body.video_duration = input.duration;
198
+ body.duration = input.duration;
199
+ }
200
+ break;
201
+ default:
202
+ if (input.image_url) body.image_url = input.image_url;
203
+ if (input.duration !== void 0) body.duration = input.duration;
204
+ break;
205
+ }
206
+ return body;
207
+ }
208
+ async function run(input, ctx) {
209
+ const apiId = input.model ?? DEFAULT_MODEL;
210
+ let resolved = input;
211
+ if (!input.image_url && input.image_path) {
212
+ try {
213
+ const uploadedUrl = await uploadLocalFile(input.image_path, ctx.client);
214
+ resolved = { ...input, image_url: uploadedUrl };
215
+ } catch (err) {
216
+ if (err instanceof SkillUploadError) {
217
+ return { kind: "text", text: `pixeldojo:generate (upload): ${err.userMessage}` };
218
+ }
219
+ throw err;
220
+ }
221
+ }
222
+ if (apiId === "grok-video-extend") {
223
+ if (!resolved.image_url) {
224
+ return {
225
+ kind: "text",
226
+ text: 'pixeldojo:generate with model="grok-video-extend" requires image_url (the source video URL to extend, or image_path for a local file).'
227
+ };
228
+ }
229
+ if (resolved.duration === void 0) {
230
+ return {
231
+ kind: "text",
232
+ text: 'pixeldojo:generate with model="grok-video-extend" requires duration (extension length in seconds).'
233
+ };
234
+ }
235
+ }
236
+ const body = buildPayload(apiId, resolved);
149
237
  const submitted = await ctx.client.run(apiId, body);
150
238
  const result = await pollJobUntilDoneOrHandoff(
151
239
  submitted.jobId,
@@ -161,41 +249,221 @@ async function run(input, ctx) {
161
249
  (urls) => urls.length === 0 ? `Job ${submitted.jobId} completed but returned no assets.` : urls.length === 1 ? `Generated. Asset: ${urls[0]}` : `Generated ${urls.length} assets. URLs: ${urls.join(", ")}`
162
250
  );
163
251
  }
164
- var generateSkill = {
165
- name: "pixeldojo:generate",
166
- description: "Generate any image or video from a prompt. Auto-routes to a sensible default model; pass `model` to pick a specific apiId from the catalog.",
167
- inputZod: InputSchema,
168
- inputJsonSchema: InputJsonSchema,
169
- allowedModels: null,
170
- defaultModel: DEFAULT_MODEL,
171
- run
172
- };
173
- var ALLOWED = ["ideogram-character", "flux-edit", "gpt-image-2-edit"];
174
- var DEFAULT_MODEL2 = "ideogram-character";
175
- var InputSchema2 = z.object({
176
- prompt: z.string().min(1).max(8e3),
177
- model: z.string().optional().describe(`One of: ${ALLOWED.join(", ")}. Defaults to ${DEFAULT_MODEL2}.`),
178
- reference_image_url: z.string().url().optional().describe(
179
- "Reference image of the character. Required by flux-edit and gpt-image-2-edit; optional for ideogram-character."
180
- ),
181
- aspect_ratio: z.string().optional()
252
+ var InputSchema, DEFAULT_MODEL, InputJsonSchema, generateSkill;
253
+ var init_generate = __esm({
254
+ "src/skills/generate.ts"() {
255
+ init_poll();
256
+ init_types();
257
+ init_upload_helpers();
258
+ InputSchema = z.object({
259
+ prompt: z.string().min(1).max(8e3).describe("Prompt describing what to generate."),
260
+ model: z.string().optional().describe(
261
+ 'Override the model. Any apiId from /api/v1/models (e.g. "flux", "google-nano-banana", "veo-3.1", "kling-video"). Omit to use the default.'
262
+ ),
263
+ preset: z.string().optional().describe(
264
+ 'Preset slug to seed the params (e.g. "cinematic-portrait", "product-floating-clean", "magazine-cover-text"). Browse the catalog at https://pixeldojo.ai/presets. Explicit fields override preset values.'
265
+ ),
266
+ aspect_ratio: z.string().optional().describe('Aspect ratio supported by the chosen model (e.g. "1:1", "16:9", "9:16").'),
267
+ duration: z.number().int().positive().optional().describe("Video duration in seconds, when applicable."),
268
+ image_url: z.string().url().optional().describe("Reference image URL for image-to-image / image-to-video tools."),
269
+ image_path: z.string().min(1).optional().describe(
270
+ "Absolute local file path to a reference image/video. The skill uploads it to PixelDojo first (24h temp storage) and then dispatches. Prefer this over image_url when the user has the file on disk."
271
+ )
272
+ });
273
+ DEFAULT_MODEL = "google-nano-banana";
274
+ InputJsonSchema = {
275
+ type: "object",
276
+ properties: {
277
+ prompt: { type: "string", description: "Prompt describing what to generate." },
278
+ model: {
279
+ type: "string",
280
+ description: 'Override the model. Any apiId from /api/v1/models (e.g. "flux", "google-nano-banana", "veo-3.1", "kling-video"). Omit to use the default.'
281
+ },
282
+ preset: {
283
+ type: "string",
284
+ description: 'Preset slug to seed the params (e.g. "cinematic-portrait", "product-floating-clean"). Explicit fields override preset values.'
285
+ },
286
+ aspect_ratio: { type: "string" },
287
+ duration: { type: "integer" },
288
+ image_url: { type: "string", format: "uri" },
289
+ image_path: {
290
+ type: "string",
291
+ description: "Absolute local file path. The skill uploads it to PixelDojo (24h temp storage) and uses the resulting URL as the reference image. Prefer this over image_url when the user has a local file."
292
+ }
293
+ },
294
+ required: ["prompt"]
295
+ };
296
+ generateSkill = {
297
+ name: "pixeldojo:generate",
298
+ description: "Generate any image or video from a prompt. Auto-routes to a sensible default model; pass `model` to pick a specific apiId from the catalog. For reference-image / image-to-video flows: pass `image_url` if you already have a URL, or `image_path` (absolute local path) and the skill uploads it to 24h temp storage automatically.",
299
+ inputZod: InputSchema,
300
+ inputJsonSchema: InputJsonSchema,
301
+ allowedModels: null,
302
+ defaultModel: DEFAULT_MODEL,
303
+ run
304
+ };
305
+ }
182
306
  });
183
- var InputJsonSchema2 = {
184
- type: "object",
185
- properties: {
186
- prompt: { type: "string" },
187
- model: {
188
- type: "string",
189
- enum: ALLOWED,
190
- description: `One of: ${ALLOWED.join(", ")}. Defaults to ${DEFAULT_MODEL2}.`
191
- },
192
- reference_image_url: { type: "string", format: "uri" },
193
- aspect_ratio: { type: "string" }
194
- },
195
- required: ["prompt"]
196
- };
307
+ function buildPayload2(apiId, input) {
308
+ const urls = input.image_urls && input.image_urls.length > 0 ? input.image_urls : input.image_url ? [input.image_url] : [];
309
+ switch (apiId) {
310
+ case "wan-2.7-image-edit":
311
+ case "wan-2.6-image-edit":
312
+ return {
313
+ prompt: input.prompt,
314
+ image_urls: urls
315
+ // wan-edit uses `size` not aspect_ratio. Default 2K, let model defaults handle it otherwise.
316
+ };
317
+ case "p-image-edit":
318
+ return {
319
+ prompt: input.prompt,
320
+ images: urls.slice(0, 5),
321
+ ...input.aspect_ratio ? { aspect_ratio: input.aspect_ratio } : {}
322
+ };
323
+ case "flux-edit":
324
+ case "xai-image-edit":
325
+ case "gpt-image-2-edit":
326
+ return {
327
+ prompt: input.prompt,
328
+ image_url: urls[0],
329
+ ...urls.length > 1 ? { image_urls: urls } : {},
330
+ ...input.aspect_ratio ? { aspect_ratio: input.aspect_ratio } : {}
331
+ };
332
+ case "google-nano-banana":
333
+ return {
334
+ prompt: input.prompt,
335
+ image_input: urls,
336
+ ...input.aspect_ratio ? { aspect_ratio: input.aspect_ratio } : {}
337
+ };
338
+ default:
339
+ return {
340
+ prompt: input.prompt,
341
+ image_url: urls[0]
342
+ };
343
+ }
344
+ }
197
345
  async function run2(input, ctx) {
198
- const requested = input.model ?? DEFAULT_MODEL2;
346
+ let resolved = input;
347
+ try {
348
+ if (input.image_paths && input.image_paths.length > 0) {
349
+ const urls = await uploadLocalFiles(input.image_paths, ctx.client);
350
+ resolved = {
351
+ ...input,
352
+ image_urls: [...input.image_urls ?? [], ...urls]
353
+ };
354
+ } else if (input.image_path && !input.image_url) {
355
+ const url = await uploadLocalFile(input.image_path, ctx.client);
356
+ resolved = { ...input, image_url: url };
357
+ }
358
+ } catch (err) {
359
+ if (err instanceof SkillUploadError) {
360
+ return { kind: "text", text: `pixeldojo:edit (upload): ${err.userMessage}` };
361
+ }
362
+ throw err;
363
+ }
364
+ if (!resolved.image_url && (!resolved.image_urls || resolved.image_urls.length === 0)) {
365
+ return {
366
+ kind: "text",
367
+ text: "pixeldojo:edit requires at least one reference image. Pass image_url / image_urls (hosted URL) or image_path / image_paths (local file)."
368
+ };
369
+ }
370
+ const apiId = resolved.model ?? DEFAULT_MODEL2;
371
+ const body = buildPayload2(apiId, resolved);
372
+ const submitted = await ctx.client.run(apiId, body);
373
+ const result = await pollJobUntilDoneOrHandoff(
374
+ submitted.jobId,
375
+ (id) => ctx.client.getJob(id),
376
+ ctx.buildStatusUrl,
377
+ {
378
+ now: ctx.pollOverrides?.now,
379
+ sleep: ctx.pollOverrides?.sleep
380
+ }
381
+ );
382
+ return pollResultToSkillResult(
383
+ result,
384
+ (urls) => urls.length === 0 ? `Edit job ${submitted.jobId} completed but returned no assets.` : urls.length === 1 ? `Edit complete. Asset: ${urls[0]}` : `Edit produced ${urls.length} assets. URLs: ${urls.join(", ")}`
385
+ );
386
+ }
387
+ var DEFAULT_MODEL2, ALLOWED_MODELS, InputSchema2, InputJsonSchema2, editSkill;
388
+ var init_edit = __esm({
389
+ "src/skills/edit.ts"() {
390
+ init_poll();
391
+ init_types();
392
+ init_upload_helpers();
393
+ DEFAULT_MODEL2 = "wan-2.7-image-edit";
394
+ ALLOWED_MODELS = [
395
+ "wan-2.7-image-edit",
396
+ "wan-2.6-image-edit",
397
+ "flux-edit",
398
+ "xai-image-edit",
399
+ "p-image-edit",
400
+ "gpt-image-2-edit",
401
+ "google-nano-banana"
402
+ ];
403
+ InputSchema2 = z.object({
404
+ prompt: z.string().min(1).max(5e3).describe("Edit instruction."),
405
+ image_url: z.string().url().optional().describe("Single reference image to edit. Pass image_urls for multi-image edits."),
406
+ image_urls: z.array(z.string().url()).min(1).max(9).optional().describe("Multiple reference images (1-9). Used for composition/multi-ref edits."),
407
+ image_path: z.string().min(1).optional().describe(
408
+ "Absolute local file path. Skill uploads it (24h temp storage) and edits it. Prefer over image_url when the user has the file on disk."
409
+ ),
410
+ image_paths: z.array(z.string().min(1)).min(1).max(9).optional().describe(
411
+ "Multiple absolute local file paths (1-9) for multi-image edits. Each uploaded to 24h temp storage before dispatch."
412
+ ),
413
+ model: z.enum(ALLOWED_MODELS).optional().describe(
414
+ "Override the default edit model. Defaults to wan-2.7-image-edit (most popular)."
415
+ ),
416
+ aspect_ratio: z.string().optional().describe('Aspect ratio when supported (e.g. "1:1", "16:9", "match_input_image").')
417
+ });
418
+ InputJsonSchema2 = {
419
+ type: "object",
420
+ properties: {
421
+ prompt: { type: "string", description: "Edit instruction." },
422
+ image_url: {
423
+ type: "string",
424
+ format: "uri",
425
+ description: "Single reference image. Pass image_urls for multi-image edits."
426
+ },
427
+ image_urls: {
428
+ type: "array",
429
+ items: { type: "string", format: "uri" },
430
+ minItems: 1,
431
+ maxItems: 9,
432
+ description: "Multiple reference images (1-9)."
433
+ },
434
+ image_path: {
435
+ type: "string",
436
+ description: "Absolute local file path. Skill uploads it (24h temp storage) and edits the resulting URL. Prefer over image_url when the user has a local file."
437
+ },
438
+ image_paths: {
439
+ type: "array",
440
+ items: { type: "string" },
441
+ minItems: 1,
442
+ maxItems: 9,
443
+ description: "Multiple absolute local file paths (1-9). Each uploaded before dispatch."
444
+ },
445
+ model: {
446
+ type: "string",
447
+ enum: [...ALLOWED_MODELS],
448
+ description: "Override edit model. Default: wan-2.7-image-edit."
449
+ },
450
+ aspect_ratio: { type: "string" }
451
+ },
452
+ required: ["prompt"]
453
+ };
454
+ editSkill = {
455
+ name: "pixeldojo:edit",
456
+ description: "Edit an existing image with a text instruction. Defaults to wan-2.7-image-edit; pass `model` to pick another edit-capable apiId. Supports up to 9 reference images for multi-image composition. For reference images: pass image_url(s) for hosted URLs or image_path(s) for absolute local file paths (skill uploads to 24h temp storage automatically).",
457
+ inputZod: InputSchema2,
458
+ inputJsonSchema: InputJsonSchema2,
459
+ allowedModels: [...ALLOWED_MODELS],
460
+ defaultModel: DEFAULT_MODEL2,
461
+ run: run2
462
+ };
463
+ }
464
+ });
465
+ async function run3(input, ctx) {
466
+ const requested = input.model ?? DEFAULT_MODEL3;
199
467
  if (!ALLOWED.includes(requested)) {
200
468
  return {
201
469
  kind: "text",
@@ -203,6 +471,12 @@ async function run2(input, ctx) {
203
471
  };
204
472
  }
205
473
  const apiId = requested;
474
+ if ((apiId === "flux-edit" || apiId === "gpt-image-2-edit") && !input.reference_image_url) {
475
+ return {
476
+ kind: "text",
477
+ text: `pixeldojo:character with model="${apiId}" requires reference_image_url (the source image of the character to edit). For generation from a prompt alone, use model="ideogram-character".`
478
+ };
479
+ }
206
480
  const body = { prompt: input.prompt };
207
481
  if (input.aspect_ratio) body.aspect_ratio = input.aspect_ratio;
208
482
  if (input.reference_image_url) {
@@ -224,42 +498,48 @@ async function run2(input, ctx) {
224
498
  (urls) => urls.length === 0 ? `Job ${submitted.jobId} completed but returned no assets.` : `Character shot ready. Asset: ${urls[0]}`
225
499
  );
226
500
  }
227
- var characterSkill = {
228
- name: "pixeldojo:character",
229
- description: "Generate or edit consistent characters across shots. Pass a reference_image_url for edit-style models.",
230
- inputZod: InputSchema2,
231
- inputJsonSchema: InputJsonSchema2,
232
- allowedModels: [...ALLOWED],
233
- defaultModel: DEFAULT_MODEL2,
234
- run: run2
235
- };
236
- var ALLOWED2 = ["veo-3.1", "kling-video", "seedance-2"];
237
- var DEFAULT_MODEL3 = "veo-3.1";
238
- var InputSchema3 = z.object({
239
- brief: z.string().min(1).max(8e3).describe("Storyboard brief: scene, shots, mood, action."),
240
- model: z.string().optional().describe(`One of: ${ALLOWED2.join(", ")}. Defaults to ${DEFAULT_MODEL3}.`),
241
- aspect_ratio: z.string().optional(),
242
- duration: z.number().int().positive().optional()
501
+ var ALLOWED, DEFAULT_MODEL3, InputSchema3, InputJsonSchema3, characterSkill;
502
+ var init_character = __esm({
503
+ "src/skills/character.ts"() {
504
+ init_poll();
505
+ init_types();
506
+ ALLOWED = ["ideogram-character", "flux-edit", "gpt-image-2-edit"];
507
+ DEFAULT_MODEL3 = "ideogram-character";
508
+ InputSchema3 = z.object({
509
+ prompt: z.string().min(1).max(8e3),
510
+ model: z.string().optional().describe(`One of: ${ALLOWED.join(", ")}. Defaults to ${DEFAULT_MODEL3}.`),
511
+ reference_image_url: z.string().url().optional().describe(
512
+ "Reference image of the character. Required by flux-edit and gpt-image-2-edit; optional for ideogram-character."
513
+ ),
514
+ aspect_ratio: z.string().optional()
515
+ });
516
+ InputJsonSchema3 = {
517
+ type: "object",
518
+ properties: {
519
+ prompt: { type: "string" },
520
+ model: {
521
+ type: "string",
522
+ enum: ALLOWED,
523
+ description: `One of: ${ALLOWED.join(", ")}. Defaults to ${DEFAULT_MODEL3}.`
524
+ },
525
+ reference_image_url: { type: "string", format: "uri" },
526
+ aspect_ratio: { type: "string" }
527
+ },
528
+ required: ["prompt"]
529
+ };
530
+ characterSkill = {
531
+ name: "pixeldojo:character",
532
+ description: "Generate or edit consistent characters across shots. Pass a reference_image_url for edit-style models.",
533
+ inputZod: InputSchema3,
534
+ inputJsonSchema: InputJsonSchema3,
535
+ allowedModels: [...ALLOWED],
536
+ defaultModel: DEFAULT_MODEL3,
537
+ run: run3
538
+ };
539
+ }
243
540
  });
244
- var InputJsonSchema3 = {
245
- type: "object",
246
- properties: {
247
- brief: {
248
- type: "string",
249
- description: "Storyboard brief: scene, shots, mood, action."
250
- },
251
- model: {
252
- type: "string",
253
- enum: ALLOWED2,
254
- description: `One of: ${ALLOWED2.join(", ")}. Defaults to ${DEFAULT_MODEL3}.`
255
- },
256
- aspect_ratio: { type: "string" },
257
- duration: { type: "integer" }
258
- },
259
- required: ["brief"]
260
- };
261
- async function run3(input, ctx) {
262
- const requested = input.model ?? DEFAULT_MODEL3;
541
+ async function run4(input, ctx) {
542
+ const requested = input.model ?? DEFAULT_MODEL4;
263
543
  if (!ALLOWED2.includes(requested)) {
264
544
  return {
265
545
  kind: "text",
@@ -285,35 +565,49 @@ async function run3(input, ctx) {
285
565
  (urls) => urls.length === 0 ? `Job ${submitted.jobId} completed but returned no assets.` : `Storyboard preview ready. Asset: ${urls[0]}`
286
566
  );
287
567
  }
288
- var storyboardSkill = {
289
- name: "pixeldojo:storyboard",
290
- description: "Generate a video storyboard preview from a single brief. v1: single-shot preview; multi-shot orchestration coming.",
291
- inputZod: InputSchema3,
292
- inputJsonSchema: InputJsonSchema3,
293
- allowedModels: [...ALLOWED2],
294
- defaultModel: DEFAULT_MODEL3,
295
- run: run3
296
- };
297
- var ALLOWED3 = ["magnific-upscaler", "creative-upscale", "face-enhance"];
298
- var DEFAULT_MODEL4 = "magnific-upscaler";
299
- var InputSchema4 = z.object({
300
- image_url: z.string().url().describe("URL of the source image to upscale."),
301
- model: z.string().optional().describe(`One of: ${ALLOWED3.join(", ")}. Defaults to ${DEFAULT_MODEL4}.`),
302
- scale_factor: z.number().int().min(1).max(4).optional().describe("Magnific only: 1, 2, or 4. Defaults to 2."),
303
- creativity: z.number().min(0).max(1).optional().describe("Magnific only: 0 (preserve) \u2192 1 (creative). Defaults to 0.")
568
+ var ALLOWED2, DEFAULT_MODEL4, InputSchema4, InputJsonSchema4, storyboardSkill;
569
+ var init_storyboard = __esm({
570
+ "src/skills/storyboard.ts"() {
571
+ init_poll();
572
+ init_types();
573
+ ALLOWED2 = ["veo-3.1", "kling-video", "seedance-2"];
574
+ DEFAULT_MODEL4 = "veo-3.1";
575
+ InputSchema4 = z.object({
576
+ brief: z.string().min(1).max(8e3).describe("Storyboard brief: scene, shots, mood, action."),
577
+ model: z.string().optional().describe(`One of: ${ALLOWED2.join(", ")}. Defaults to ${DEFAULT_MODEL4}.`),
578
+ aspect_ratio: z.string().optional(),
579
+ duration: z.number().int().positive().optional()
580
+ });
581
+ InputJsonSchema4 = {
582
+ type: "object",
583
+ properties: {
584
+ brief: {
585
+ type: "string",
586
+ description: "Storyboard brief: scene, shots, mood, action."
587
+ },
588
+ model: {
589
+ type: "string",
590
+ enum: ALLOWED2,
591
+ description: `One of: ${ALLOWED2.join(", ")}. Defaults to ${DEFAULT_MODEL4}.`
592
+ },
593
+ aspect_ratio: { type: "string" },
594
+ duration: { type: "integer" }
595
+ },
596
+ required: ["brief"]
597
+ };
598
+ storyboardSkill = {
599
+ name: "pixeldojo:storyboard",
600
+ description: "Generate a video storyboard preview from a single brief. v1: single-shot preview; multi-shot orchestration coming.",
601
+ inputZod: InputSchema4,
602
+ inputJsonSchema: InputJsonSchema4,
603
+ allowedModels: [...ALLOWED2],
604
+ defaultModel: DEFAULT_MODEL4,
605
+ run: run4
606
+ };
607
+ }
304
608
  });
305
- var InputJsonSchema4 = {
306
- type: "object",
307
- properties: {
308
- image_url: { type: "string", format: "uri" },
309
- model: { type: "string", enum: ALLOWED3 },
310
- scale_factor: { type: "integer", minimum: 1, maximum: 4 },
311
- creativity: { type: "number", minimum: 0, maximum: 1 }
312
- },
313
- required: ["image_url"]
314
- };
315
- async function run4(input, ctx) {
316
- const requested = input.model ?? DEFAULT_MODEL4;
609
+ async function run5(input, ctx) {
610
+ const requested = input.model ?? DEFAULT_MODEL5;
317
611
  if (!ALLOWED3.includes(requested)) {
318
612
  return {
319
613
  kind: "text",
@@ -344,31 +638,41 @@ async function run4(input, ctx) {
344
638
  (urls) => urls.length === 0 ? `Job ${submitted.jobId} completed but returned no assets.` : `Upscaled. Asset: ${urls[0]}`
345
639
  );
346
640
  }
347
- var upscaleSkill = {
348
- name: "pixeldojo:upscale",
349
- description: "Enhance an image. Magnific (default) supports configurable scale_factor and creativity; face-enhance for portraits.",
350
- inputZod: InputSchema4,
351
- inputJsonSchema: InputJsonSchema4,
352
- allowedModels: [...ALLOWED3],
353
- defaultModel: DEFAULT_MODEL4,
354
- run: run4
355
- };
356
- var InputSchema5 = z.object({
357
- jobId: z.string().min(1).max(200).describe("Job id returned from a prior pixeldojo:* skill handoff.")
641
+ var ALLOWED3, DEFAULT_MODEL5, InputSchema5, InputJsonSchema5, upscaleSkill;
642
+ var init_upscale = __esm({
643
+ "src/skills/upscale.ts"() {
644
+ init_poll();
645
+ init_types();
646
+ ALLOWED3 = ["magnific-upscaler", "creative-upscale", "face-enhance"];
647
+ DEFAULT_MODEL5 = "magnific-upscaler";
648
+ InputSchema5 = z.object({
649
+ image_url: z.string().url().describe("URL of the source image to upscale."),
650
+ model: z.string().optional().describe(`One of: ${ALLOWED3.join(", ")}. Defaults to ${DEFAULT_MODEL5}.`),
651
+ scale_factor: z.number().int().min(1).max(4).optional().describe("Magnific only: 1, 2, or 4. Defaults to 2."),
652
+ creativity: z.number().min(0).max(1).optional().describe("Magnific only: 0 (preserve) \u2192 1 (creative). Defaults to 0.")
653
+ });
654
+ InputJsonSchema5 = {
655
+ type: "object",
656
+ properties: {
657
+ image_url: { type: "string", format: "uri" },
658
+ model: { type: "string", enum: ALLOWED3 },
659
+ scale_factor: { type: "integer", minimum: 1, maximum: 4 },
660
+ creativity: { type: "number", minimum: 0, maximum: 1 }
661
+ },
662
+ required: ["image_url"]
663
+ };
664
+ upscaleSkill = {
665
+ name: "pixeldojo:upscale",
666
+ description: "Enhance an image. Magnific (default) supports configurable scale_factor and creativity; face-enhance for portraits.",
667
+ inputZod: InputSchema5,
668
+ inputJsonSchema: InputJsonSchema5,
669
+ allowedModels: [...ALLOWED3],
670
+ defaultModel: DEFAULT_MODEL5,
671
+ run: run5
672
+ };
673
+ }
358
674
  });
359
- var InputJsonSchema5 = {
360
- type: "object",
361
- properties: {
362
- jobId: {
363
- type: "string",
364
- description: "Job id returned from a prior pixeldojo:* skill handoff."
365
- }
366
- },
367
- required: ["jobId"]
368
- };
369
- var STUCK_HINT_MS = 5 * 60 * 1e3;
370
- var ABANDON_HINT_MS = 12 * 60 * 1e3;
371
- async function run5(input, ctx) {
675
+ async function run6(input, ctx) {
372
676
  const job = await ctx.client.getJob(input.jobId);
373
677
  if (job.status === "completed") {
374
678
  const urls = extractAssetUrls2(job);
@@ -432,30 +736,37 @@ function extractAssetUrls2(job) {
432
736
  if (output?.video) return [output.video];
433
737
  return [];
434
738
  }
435
- var statusSkill = {
436
- name: "pixeldojo:status",
437
- description: "Check the status of a long-running job after a 30s sync handoff. Returns assets when ready, failure reason if failed, or current state if still running.",
438
- inputZod: InputSchema5,
439
- inputJsonSchema: InputJsonSchema5,
440
- // status is special — it doesn't dispatch to a model
441
- allowedModels: [],
442
- defaultModel: "",
443
- run: run5
444
- };
445
- var InputSchema6 = z.object({
446
- url: z.string().min(1).max(2048).describe("Product page URL. Shopify, BigCommerce, WooCommerce, or any page with JSON-LD / OpenGraph product metadata.")
739
+ var InputSchema6, InputJsonSchema6, STUCK_HINT_MS, ABANDON_HINT_MS, statusSkill;
740
+ var init_status = __esm({
741
+ "src/skills/status.ts"() {
742
+ InputSchema6 = z.object({
743
+ jobId: z.string().min(1).max(200).describe("Job id returned from a prior pixeldojo:* skill handoff.")
744
+ });
745
+ InputJsonSchema6 = {
746
+ type: "object",
747
+ properties: {
748
+ jobId: {
749
+ type: "string",
750
+ description: "Job id returned from a prior pixeldojo:* skill handoff."
751
+ }
752
+ },
753
+ required: ["jobId"]
754
+ };
755
+ STUCK_HINT_MS = 5 * 60 * 1e3;
756
+ ABANDON_HINT_MS = 12 * 60 * 1e3;
757
+ statusSkill = {
758
+ name: "pixeldojo:status",
759
+ description: "Check the status of a long-running job after a 30s sync handoff. Returns assets when ready, failure reason if failed, or current state if still running.",
760
+ inputZod: InputSchema6,
761
+ inputJsonSchema: InputJsonSchema6,
762
+ // status is special — it doesn't dispatch to a model
763
+ allowedModels: [],
764
+ defaultModel: "",
765
+ run: run6
766
+ };
767
+ }
447
768
  });
448
- var InputJsonSchema6 = {
449
- type: "object",
450
- properties: {
451
- url: {
452
- type: "string",
453
- description: "Product page URL. Shopify, BigCommerce, WooCommerce, or any page with JSON-LD / OpenGraph product metadata."
454
- }
455
- },
456
- required: ["url"]
457
- };
458
- async function run6(input, ctx) {
769
+ async function run7(input, ctx) {
459
770
  const product = await ctx.client.extractProduct(input.url);
460
771
  const summary = [
461
772
  `Product: ${product.name}`,
@@ -472,61 +783,35 @@ function truncate(input, max) {
472
783
  if (input.length <= max) return input;
473
784
  return input.slice(0, max - 3) + "...";
474
785
  }
475
- var fromUrlSkill = {
476
- name: "pixeldojo:from_url",
477
- description: "Extract product info (name, description, images) from any product page URL. Use this as the first step before pixeldojo:campaign / :ad / :lookbook so the agent has structured product data instead of a free-text description.",
478
- inputZod: InputSchema6,
479
- inputJsonSchema: InputJsonSchema6,
480
- // No model dispatch — this skill calls a server-side scrape, not a generation.
481
- allowedModels: [],
482
- defaultModel: "",
483
- run: run6
484
- };
485
- var InputSchema7 = z.object({
486
- productUrl: z.string().url().optional().describe("Product page URL. We extract name + description + images automatically."),
487
- product: z.object({
488
- name: z.string().min(1).max(200),
489
- description: z.string().max(2e3).optional(),
490
- images: z.array(z.string().url()).max(5).optional()
491
- }).optional().describe("Manual product fields, used when productUrl is omitted."),
492
- tone: z.string().max(120).optional().describe('Optional creative direction ("premium minimalist", "playful Y2K"). Threaded through every prompt.'),
493
- variants: z.number().int().min(1).max(8).optional().describe("Lifestyle shots in addition to the hero (default 4, max 8)."),
494
- includeVideo: z.boolean().optional().describe("Whether to also generate a vertical launch video (default true)."),
495
- videoAspectRatio: z.enum(["9:16", "16:9", "1:1"]).optional().describe("Aspect ratio of the launch video (default 9:16 for Reels/TikTok)."),
496
- videoMode: z.enum(["lifestyle", "cgi", "ugc", "skip"]).optional().describe("Video styling \u2014 lifestyle (default), cgi, ugc, or skip to omit video.")
497
- }).refine((v) => v.productUrl || v.product, {
498
- message: "productUrl or product is required",
499
- path: ["productUrl"]
500
- });
501
- var InputJsonSchema7 = {
502
- type: "object",
503
- properties: {
504
- productUrl: {
505
- type: "string",
506
- format: "uri",
507
- description: "Product page URL. We extract name + description + images automatically."
508
- },
509
- product: {
786
+ var InputSchema7, InputJsonSchema7, fromUrlSkill;
787
+ var init_from_url = __esm({
788
+ "src/skills/from-url.ts"() {
789
+ InputSchema7 = z.object({
790
+ url: z.string().min(1).max(2048).describe("Product page URL. Shopify, BigCommerce, WooCommerce, or any page with JSON-LD / OpenGraph product metadata.")
791
+ });
792
+ InputJsonSchema7 = {
510
793
  type: "object",
511
794
  properties: {
512
- name: { type: "string" },
513
- description: { type: "string" },
514
- images: { type: "array", items: { type: "string", format: "uri" } }
795
+ url: {
796
+ type: "string",
797
+ description: "Product page URL. Shopify, BigCommerce, WooCommerce, or any page with JSON-LD / OpenGraph product metadata."
798
+ }
515
799
  },
516
- required: ["name"]
517
- },
518
- tone: {
519
- type: "string",
520
- description: "Creative direction threaded through every prompt."
521
- },
522
- variants: { type: "integer", minimum: 1, maximum: 8 },
523
- includeVideo: { type: "boolean" },
524
- videoAspectRatio: { type: "string", enum: ["9:16", "16:9", "1:1"] },
525
- videoMode: { type: "string", enum: ["lifestyle", "cgi", "ugc", "skip"] }
526
- },
527
- oneOf: [{ required: ["productUrl"] }, { required: ["product"] }]
528
- };
529
- async function run7(input, ctx) {
800
+ required: ["url"]
801
+ };
802
+ fromUrlSkill = {
803
+ name: "pixeldojo:from_url",
804
+ description: "Extract product info (name, description, images) from any product page URL. Use this as the first step before pixeldojo:campaign / :ad / :lookbook so the agent has structured product data instead of a free-text description.",
805
+ inputZod: InputSchema7,
806
+ inputJsonSchema: InputJsonSchema7,
807
+ // No model dispatch — this skill calls a server-side scrape, not a generation.
808
+ allowedModels: [],
809
+ defaultModel: "",
810
+ run: run7
811
+ };
812
+ }
813
+ });
814
+ async function run8(input, ctx) {
530
815
  const client = ctx.client;
531
816
  const result = await client.runCampaign(input);
532
817
  if (result.kind === "campaign") {
@@ -553,31 +838,67 @@ async function run7(input, ctx) {
553
838
  statusUrl: result.statusUrl ?? ctx.buildStatusUrl(result.campaignId)
554
839
  };
555
840
  }
556
- var campaignSkill = {
557
- name: "pixeldojo:campaign",
558
- description: "Generate a coherent product launch package (hero image + N lifestyle variants + optional vertical video) from one URL or product profile. Composes hero / lifestyle / video models server-side; returns assets in one call or a handoff with campaignId to poll via pixeldojo:campaign_status.",
559
- inputZod: InputSchema7,
560
- inputJsonSchema: InputJsonSchema7,
561
- // Composition skill — internal sub-jobs route to per-tool models, no
562
- // single allowed-models list applies here.
563
- allowedModels: [],
564
- defaultModel: "",
565
- run: run7
566
- };
567
- var InputSchema8 = z.object({
568
- campaignId: z.string().min(1).max(200).describe("Campaign id returned from a prior pixeldojo:campaign handoff.")
841
+ var InputSchema8, InputJsonSchema8, campaignSkill;
842
+ var init_campaign = __esm({
843
+ "src/skills/campaign.ts"() {
844
+ InputSchema8 = z.object({
845
+ productUrl: z.string().url().optional().describe("Product page URL. We extract name + description + images automatically."),
846
+ product: z.object({
847
+ name: z.string().min(1).max(200),
848
+ description: z.string().max(2e3).optional(),
849
+ images: z.array(z.string().url()).max(5).optional()
850
+ }).optional().describe("Manual product fields, used when productUrl is omitted."),
851
+ tone: z.string().max(120).optional().describe('Optional creative direction ("premium minimalist", "playful Y2K"). Threaded through every prompt.'),
852
+ variants: z.number().int().min(1).max(8).optional().describe("Lifestyle shots in addition to the hero (default 4, max 8)."),
853
+ includeVideo: z.boolean().optional().describe("Whether to also generate a vertical launch video (default true)."),
854
+ videoAspectRatio: z.enum(["9:16", "16:9", "1:1"]).optional().describe("Aspect ratio of the launch video (default 9:16 for Reels/TikTok)."),
855
+ videoMode: z.enum(["lifestyle", "cgi", "ugc", "skip"]).optional().describe("Video styling \u2014 lifestyle (default), cgi, ugc, or skip to omit video.")
856
+ }).refine((v) => v.productUrl || v.product, {
857
+ message: "productUrl or product is required",
858
+ path: ["productUrl"]
859
+ });
860
+ InputJsonSchema8 = {
861
+ type: "object",
862
+ properties: {
863
+ productUrl: {
864
+ type: "string",
865
+ format: "uri",
866
+ description: "Product page URL. We extract name + description + images automatically."
867
+ },
868
+ product: {
869
+ type: "object",
870
+ properties: {
871
+ name: { type: "string" },
872
+ description: { type: "string" },
873
+ images: { type: "array", items: { type: "string", format: "uri" } }
874
+ },
875
+ required: ["name"]
876
+ },
877
+ tone: {
878
+ type: "string",
879
+ description: "Creative direction threaded through every prompt."
880
+ },
881
+ variants: { type: "integer", minimum: 1, maximum: 8 },
882
+ includeVideo: { type: "boolean" },
883
+ videoAspectRatio: { type: "string", enum: ["9:16", "16:9", "1:1"] },
884
+ videoMode: { type: "string", enum: ["lifestyle", "cgi", "ugc", "skip"] }
885
+ },
886
+ oneOf: [{ required: ["productUrl"] }, { required: ["product"] }]
887
+ };
888
+ campaignSkill = {
889
+ name: "pixeldojo:campaign",
890
+ description: "Generate a coherent product launch package (hero image + N lifestyle variants + optional vertical video) from one URL or product profile. Composes hero / lifestyle / video models server-side; returns assets in one call or a handoff with campaignId to poll via pixeldojo:campaign_status.",
891
+ inputZod: InputSchema8,
892
+ inputJsonSchema: InputJsonSchema8,
893
+ // Composition skill — internal sub-jobs route to per-tool models, no
894
+ // single allowed-models list applies here.
895
+ allowedModels: [],
896
+ defaultModel: "",
897
+ run: run8
898
+ };
899
+ }
569
900
  });
570
- var InputJsonSchema8 = {
571
- type: "object",
572
- properties: {
573
- campaignId: {
574
- type: "string",
575
- description: "Campaign id returned from a prior pixeldojo:campaign handoff."
576
- }
577
- },
578
- required: ["campaignId"]
579
- };
580
- async function run8(input, ctx) {
901
+ async function run9(input, ctx) {
581
902
  const client = ctx.client;
582
903
  const result = await client.getCampaign(input.campaignId);
583
904
  if (result.kind === "campaign") {
@@ -607,30 +928,487 @@ async function run8(input, ctx) {
607
928
  statusUrl: result.statusUrl ?? ctx.buildStatusUrl(result.campaignId)
608
929
  };
609
930
  }
610
- var campaignStatusSkill = {
611
- name: "pixeldojo:campaign_status",
612
- description: "Poll a campaign by campaignId returned from pixeldojo:campaign. Returns assets when every sub-job is done, or a handoff describing what is still in flight.",
613
- inputZod: InputSchema8,
614
- inputJsonSchema: InputJsonSchema8,
615
- allowedModels: [],
616
- defaultModel: "",
617
- run: run8
618
- };
931
+ var InputSchema9, InputJsonSchema9, campaignStatusSkill;
932
+ var init_campaign_status = __esm({
933
+ "src/skills/campaign-status.ts"() {
934
+ InputSchema9 = z.object({
935
+ campaignId: z.string().min(1).max(200).describe("Campaign id returned from a prior pixeldojo:campaign handoff.")
936
+ });
937
+ InputJsonSchema9 = {
938
+ type: "object",
939
+ properties: {
940
+ campaignId: {
941
+ type: "string",
942
+ description: "Campaign id returned from a prior pixeldojo:campaign handoff."
943
+ }
944
+ },
945
+ required: ["campaignId"]
946
+ };
947
+ campaignStatusSkill = {
948
+ name: "pixeldojo:campaign_status",
949
+ description: "Poll a campaign by campaignId returned from pixeldojo:campaign. Returns assets when every sub-job is done, or a handoff describing what is still in flight.",
950
+ inputZod: InputSchema9,
951
+ inputJsonSchema: InputJsonSchema9,
952
+ allowedModels: [],
953
+ defaultModel: "",
954
+ run: run9
955
+ };
956
+ }
957
+ });
958
+ async function run10(input, ctx) {
959
+ let url;
960
+ try {
961
+ url = await uploadLocalFile(input.path, ctx.client);
962
+ } catch (err) {
963
+ if (err instanceof SkillUploadError) {
964
+ return { kind: "text", text: `pixeldojo:upload: ${err.userMessage}` };
965
+ }
966
+ throw err;
967
+ }
968
+ return {
969
+ kind: "text",
970
+ text: `Uploaded ${basename(input.path)} \u2192 ${url}
971
+ (temp storage; auto-deletes in ~24h \u2014 pass this URL as image_url to :generate or :edit)`
972
+ };
973
+ }
974
+ var InputSchema10, InputJsonSchema10, uploadSkill;
975
+ var init_upload = __esm({
976
+ "src/skills/upload.ts"() {
977
+ init_upload_helpers();
978
+ InputSchema10 = z.object({
979
+ path: z.string().min(1).max(4096).describe(
980
+ "Absolute local file path to upload. JPEG, PNG, WebP, GIF (\u226450MB) or MP4, WebM, MOV (\u2264200MB). Returns a public URL on the temp CDN; storage auto-expires after 24 hours."
981
+ )
982
+ });
983
+ InputJsonSchema10 = {
984
+ type: "object",
985
+ properties: {
986
+ path: {
987
+ type: "string",
988
+ description: "Absolute local file path. Allowed: JPEG, PNG, WebP, GIF (\u226450MB) or MP4, WebM, MOV (\u2264200MB). Returns a public URL on the temp CDN; auto-expires after 24h."
989
+ }
990
+ },
991
+ required: ["path"]
992
+ };
993
+ uploadSkill = {
994
+ name: "pixeldojo:upload",
995
+ description: "Upload a local image or video file and get back a public URL you can pass to :generate or :edit as image_url. Use when the user has a reference image on disk (drag-dropped into Claude Code, screenshot, etc.) and you need a URL. Storage auto-expires after 24 hours.",
996
+ inputZod: InputSchema10,
997
+ inputJsonSchema: InputJsonSchema10,
998
+ allowedModels: [],
999
+ defaultModel: "",
1000
+ run: run10
1001
+ };
1002
+ }
1003
+ });
1004
+ async function run11(input, ctx) {
1005
+ const requested = input.model ?? DEFAULT_MODEL6;
1006
+ if (!ALLOWED4.includes(requested)) {
1007
+ return {
1008
+ kind: "text",
1009
+ text: `Unknown model "${requested}" for pixeldojo:audio. Allowed: ${ALLOWED4.join(", ")}.`
1010
+ };
1011
+ }
1012
+ const apiId = requested;
1013
+ let audioUrls = input.audio_urls ?? [];
1014
+ if (input.audio_paths?.length) {
1015
+ try {
1016
+ const uploaded = await uploadLocalFiles(input.audio_paths, ctx.client);
1017
+ audioUrls = [...audioUrls, ...uploaded].slice(0, 3);
1018
+ } catch (err) {
1019
+ if (err instanceof SkillUploadError) {
1020
+ return { kind: "text", text: `pixeldojo:audio (upload): ${err.userMessage}` };
1021
+ }
1022
+ throw err;
1023
+ }
1024
+ }
1025
+ const body = { prompt: input.prompt };
1026
+ if (apiId === "seed-audio") {
1027
+ if (input.voice) body.voice = input.voice;
1028
+ if (audioUrls.length) body.audio_urls = audioUrls;
1029
+ if (input.output_format) body.output_format = input.output_format;
1030
+ if (input.speed !== void 0) body.speed = input.speed;
1031
+ } else {
1032
+ body.text = input.prompt;
1033
+ delete body.prompt;
1034
+ if (input.voice) body.voice_id = input.voice;
1035
+ if (input.output_format) body.audio_format = input.output_format;
1036
+ if (input.speed !== void 0) body.speed = input.speed;
1037
+ }
1038
+ const submitted = await ctx.client.run(apiId, body);
1039
+ const result = await pollJobUntilDoneOrHandoff(
1040
+ submitted.jobId,
1041
+ (id) => ctx.client.getJob(id),
1042
+ ctx.buildStatusUrl,
1043
+ {
1044
+ now: ctx.pollOverrides?.now,
1045
+ sleep: ctx.pollOverrides?.sleep
1046
+ }
1047
+ );
1048
+ return pollResultToSkillResult(
1049
+ result,
1050
+ (urls) => urls.length === 0 ? `Job ${submitted.jobId} completed but returned no assets.` : `Audio ready. Asset: ${urls[0]}`
1051
+ );
1052
+ }
1053
+ var ALLOWED4, DEFAULT_MODEL6, InputSchema11, InputJsonSchema11, audioSkill;
1054
+ var init_audio = __esm({
1055
+ "src/skills/audio.ts"() {
1056
+ init_poll();
1057
+ init_upload_helpers();
1058
+ init_types();
1059
+ ALLOWED4 = ["seed-audio", "text-to-speech"];
1060
+ DEFAULT_MODEL6 = "seed-audio";
1061
+ InputSchema11 = z.object({
1062
+ prompt: z.string().min(1).describe(
1063
+ "A script for speech, or a scene description for cinematic audio (dialogue + effects + music). Reference uploaded clips as @Audio1..@Audio3."
1064
+ ),
1065
+ model: z.string().optional().describe(`One of: ${ALLOWED4.join(", ")}. Defaults to ${DEFAULT_MODEL6}.`),
1066
+ voice: z.string().optional().describe("Optional voice preset name or cloned-voice id (seed-audio) / voice_id (text-to-speech)."),
1067
+ audio_urls: z.array(z.string().url()).max(3).optional().describe("seed-audio only: up to 3 reference audio URLs (30s / 10MB max each)."),
1068
+ audio_paths: z.array(z.string()).max(3).optional().describe("seed-audio only: absolute local paths to reference clips; uploaded automatically (24h temp storage)."),
1069
+ output_format: z.string().optional().describe("seed-audio: mp3 (default), wav, pcm, ogg_opus. text-to-speech: mp3, wav, flac, pcm."),
1070
+ speed: z.number().min(0.5).max(2).optional().describe("Speech speed multiplier (0.5\u20132).")
1071
+ });
1072
+ InputJsonSchema11 = {
1073
+ type: "object",
1074
+ properties: {
1075
+ prompt: { type: "string" },
1076
+ model: { type: "string", enum: ALLOWED4 },
1077
+ voice: { type: "string" },
1078
+ audio_urls: { type: "array", items: { type: "string", format: "uri" }, maxItems: 3 },
1079
+ audio_paths: { type: "array", items: { type: "string" }, maxItems: 3 },
1080
+ output_format: { type: "string" },
1081
+ speed: { type: "number", minimum: 0.5, maximum: 2 }
1082
+ },
1083
+ required: ["prompt"]
1084
+ };
1085
+ audioSkill = {
1086
+ name: "pixeldojo:audio",
1087
+ description: "Generate audio: speech, multi-character dialogue, sound effects, and background music from one prompt (Seed Audio 1.0 by default; plain TTS available).",
1088
+ inputZod: InputSchema11,
1089
+ inputJsonSchema: InputJsonSchema11,
1090
+ allowedModels: [...ALLOWED4],
1091
+ defaultModel: DEFAULT_MODEL6,
1092
+ run: run11
1093
+ };
1094
+ }
1095
+ });
1096
+ async function run12(input, ctx) {
1097
+ const res = await ctx.client.listLibrary({
1098
+ q: input.q,
1099
+ model: input.model,
1100
+ modality: input.modality,
1101
+ limit: input.limit ?? 10
1102
+ });
1103
+ if (res.items.length === 0) {
1104
+ return {
1105
+ kind: "text",
1106
+ text: input.q ? `No library items match "${input.q}". Try a broader query, or omit q to list recent generations.` : "Your library is empty. Generate something with pixeldojo:generate first."
1107
+ };
1108
+ }
1109
+ const lines = res.items.map((it) => {
1110
+ const parts = [
1111
+ `- ${it.url}`,
1112
+ it.modality ? `[${it.modality}]` : null,
1113
+ it.model ? `model=${it.model}` : null,
1114
+ `(${it.source}, ${it.createdAt.slice(0, 10)})`,
1115
+ it.prompt ? `"${it.prompt.slice(0, 90)}${it.prompt.length > 90 ? "\u2026" : ""}"` : null
1116
+ ].filter(Boolean);
1117
+ return parts.join(" ");
1118
+ });
1119
+ return {
1120
+ kind: "text",
1121
+ text: `${res.items.length} library item(s):
1122
+ ${lines.join("\n")}
1123
+
1124
+ Pass any URL back into :generate, :edit, :character, or :upscale as a reference input.`
1125
+ };
1126
+ }
1127
+ var InputSchema12, InputJsonSchema12, librarySkill;
1128
+ var init_library = __esm({
1129
+ "src/skills/library.ts"() {
1130
+ InputSchema12 = z.object({
1131
+ q: z.string().optional().describe("Substring match against the prompt that produced the asset."),
1132
+ model: z.string().optional().describe("Restrict to a single model (apiId)."),
1133
+ modality: z.enum(["image", "video", "audio"]).optional().describe("Restrict to one output type."),
1134
+ limit: z.number().int().min(1).max(50).optional().describe("Max results (default 10).")
1135
+ });
1136
+ InputJsonSchema12 = {
1137
+ type: "object",
1138
+ properties: {
1139
+ q: { type: "string" },
1140
+ model: { type: "string" },
1141
+ modality: { type: "string", enum: ["image", "video", "audio"] },
1142
+ limit: { type: "integer", minimum: 1, maximum: 50 }
1143
+ },
1144
+ required: []
1145
+ };
1146
+ librarySkill = {
1147
+ name: "pixeldojo:library",
1148
+ description: "Search your own generation history (API/MCP outputs + results kept in the web app). Returns asset URLs to reuse as reference inputs.",
1149
+ inputZod: InputSchema12,
1150
+ inputJsonSchema: InputJsonSchema12,
1151
+ allowedModels: [],
1152
+ defaultModel: "",
1153
+ run: run12
1154
+ };
1155
+ }
1156
+ });
1157
+ function substitutePlaceholders(args, inputs, prevUrl) {
1158
+ const missing = [];
1159
+ const fill = (value) => {
1160
+ if (typeof value === "string") {
1161
+ return value.replace(/\{\{(prev|input\.[a-zA-Z0-9_-]+)\}\}/g, (_, token) => {
1162
+ if (token === "prev") {
1163
+ if (!prevUrl) missing.push("{{prev}}");
1164
+ return prevUrl ?? "";
1165
+ }
1166
+ const key = token.slice("input.".length);
1167
+ if (!(key in inputs)) missing.push(`{{${token}}}`);
1168
+ return inputs[key] ?? "";
1169
+ });
1170
+ }
1171
+ if (Array.isArray(value)) return value.map(fill);
1172
+ if (value && typeof value === "object") {
1173
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, fill(v)]));
1174
+ }
1175
+ return value;
1176
+ };
1177
+ return { resolved: fill(args), missing };
1178
+ }
1179
+ function firstUrl(result) {
1180
+ if (result.kind === "assets" && result.assetUrls.length > 0) return result.assetUrls[0];
1181
+ if (result.kind === "text") {
1182
+ const m = result.text.match(/https?:\/\/\S+/);
1183
+ return m?.[0].replace(/[).,]+$/, "");
1184
+ }
1185
+ return void 0;
1186
+ }
1187
+ async function runSave(input, ctx) {
1188
+ const res = await ctx.client.saveWorkflow({
1189
+ name: input.name,
1190
+ description: input.description,
1191
+ steps: input.steps.map((s) => ({ skill: s.skill, args: s.args ?? {} }))
1192
+ });
1193
+ return {
1194
+ kind: "text",
1195
+ text: res.created ? `Saved workflow "${res.name}" (${res.steps} step${res.steps === 1 ? "" : "s"}). Run it with pixeldojo:run_workflow { name: "${res.name}" }.` : `Overwrote workflow "${res.name}" (${res.steps} step${res.steps === 1 ? "" : "s"}).`
1196
+ };
1197
+ }
1198
+ async function runList(_input, ctx) {
1199
+ const res = await ctx.client.listWorkflows();
1200
+ if (res.count === 0) {
1201
+ return {
1202
+ kind: "text",
1203
+ text: "No saved workflows yet. Save one with pixeldojo:save_workflow { name, steps: [{ skill, args }] }."
1204
+ };
1205
+ }
1206
+ const lines = res.workflows.map(
1207
+ (w) => `- ${w.name} (${w.steps.length} steps, ${w.runs} runs)${w.description ? `: ${w.description}` : ""}`
1208
+ );
1209
+ return { kind: "text", text: `${res.count} saved workflow(s):
1210
+ ${lines.join("\n")}` };
1211
+ }
1212
+ async function runWorkflow(input, ctx) {
1213
+ const workflow = await ctx.client.getWorkflow(input.name.toLowerCase(), { countRun: true });
1214
+ const { findSkill: findSkill2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
1215
+ const inputs = input.inputs ?? {};
1216
+ const outputs = [];
1217
+ let prevUrl;
1218
+ for (let i = 0; i < workflow.steps.length; i++) {
1219
+ const step = workflow.steps[i];
1220
+ const skill = findSkill2(step.skill);
1221
+ if (!skill) {
1222
+ return {
1223
+ kind: "text",
1224
+ text: `Step ${i + 1} names unknown skill "${step.skill}". Re-save the workflow.`
1225
+ };
1226
+ }
1227
+ const { resolved, missing } = substitutePlaceholders(step.args, inputs, prevUrl);
1228
+ if (missing.length > 0) {
1229
+ return {
1230
+ kind: "text",
1231
+ text: `Step ${i + 1} (${step.skill}) is missing ${Array.from(new Set(missing)).join(", ")}. ${missing.some((m) => m.includes("input.")) ? "Pass the value via run_workflow inputs." : "A previous step produced no asset URL."}`
1232
+ };
1233
+ }
1234
+ const parsed = skill.inputZod.safeParse(resolved);
1235
+ if (!parsed.success) {
1236
+ const issue = parsed.error.issues[0];
1237
+ return {
1238
+ kind: "text",
1239
+ text: `Step ${i + 1} (${step.skill}) has invalid args: ${issue?.path.join(".") || "input"} ${issue?.message || "invalid"}.`
1240
+ };
1241
+ }
1242
+ const result = await skill.run(parsed.data, ctx);
1243
+ const url = firstUrl(result);
1244
+ if (url) {
1245
+ prevUrl = url;
1246
+ outputs.push(`step ${i + 1} (${step.skill}): ${url}`);
1247
+ } else if (result.kind === "text" && /fail|error|invalid|unknown/i.test(result.text)) {
1248
+ return {
1249
+ kind: "text",
1250
+ text: `Workflow "${workflow.name}" stopped at step ${i + 1} (${step.skill}): ${result.text}`
1251
+ };
1252
+ } else {
1253
+ outputs.push(`step ${i + 1} (${step.skill}): done (no asset URL)`);
1254
+ }
1255
+ }
1256
+ return {
1257
+ kind: "text",
1258
+ text: `Workflow "${workflow.name}" completed ${workflow.steps.length} step(s):
1259
+ ${outputs.join("\n")}`
1260
+ };
1261
+ }
1262
+ var StepSchema, SaveInputSchema, RunInputSchema, ListInputSchema, stepJson, saveWorkflowSkill, runWorkflowSkill, listWorkflowsSkill;
1263
+ var init_workflows = __esm({
1264
+ "src/skills/workflows.ts"() {
1265
+ StepSchema = z.object({
1266
+ skill: z.string().regex(/^pixeldojo:(generate|edit|character|storyboard|upscale|audio|upload|from_url)$/, {
1267
+ message: "Runnable skills only: generate, edit, character, storyboard, upscale, audio, upload, from_url."
1268
+ }),
1269
+ args: z.record(z.string(), z.unknown()).optional()
1270
+ });
1271
+ SaveInputSchema = z.object({
1272
+ name: z.string().regex(/^[a-z0-9][a-z0-9-]{1,40}$/, {
1273
+ message: 'Kebab-case, 2-41 chars, e.g. "product-launch-pack".'
1274
+ }).describe("Workflow handle. Saving to an existing name overwrites it."),
1275
+ description: z.string().max(500).optional(),
1276
+ steps: z.array(StepSchema).min(1).max(8)
1277
+ });
1278
+ RunInputSchema = z.object({
1279
+ name: z.string().describe("Saved workflow name."),
1280
+ inputs: z.record(z.string(), z.string()).optional().describe("Values for {{input.<key>}} placeholders in the workflow steps.")
1281
+ });
1282
+ ListInputSchema = z.object({});
1283
+ stepJson = {
1284
+ type: "object",
1285
+ properties: {
1286
+ skill: { type: "string" },
1287
+ args: { type: "object" }
1288
+ },
1289
+ required: ["skill"]
1290
+ };
1291
+ saveWorkflowSkill = {
1292
+ name: "pixeldojo:save_workflow",
1293
+ description: "Save a named multi-step skill chain (generate \u2192 edit \u2192 upscale \u2026). String args may contain {{input.<key>}} and {{prev}} placeholders. Saving to an existing name overwrites it.",
1294
+ inputZod: SaveInputSchema,
1295
+ inputJsonSchema: {
1296
+ type: "object",
1297
+ properties: {
1298
+ name: { type: "string", pattern: "^[a-z0-9][a-z0-9-]{1,40}$" },
1299
+ description: { type: "string" },
1300
+ steps: { type: "array", items: stepJson, minItems: 1, maxItems: 8 }
1301
+ },
1302
+ required: ["name", "steps"]
1303
+ },
1304
+ allowedModels: [],
1305
+ defaultModel: "",
1306
+ run: runSave
1307
+ };
1308
+ runWorkflowSkill = {
1309
+ name: "pixeldojo:run_workflow",
1310
+ description: "Run a saved workflow by name. Pass inputs for its {{input.<key>}} placeholders; each step feeds the next via {{prev}}.",
1311
+ inputZod: RunInputSchema,
1312
+ inputJsonSchema: {
1313
+ type: "object",
1314
+ properties: {
1315
+ name: { type: "string" },
1316
+ inputs: { type: "object", additionalProperties: { type: "string" } }
1317
+ },
1318
+ required: ["name"]
1319
+ },
1320
+ allowedModels: [],
1321
+ defaultModel: "",
1322
+ run: runWorkflow
1323
+ };
1324
+ listWorkflowsSkill = {
1325
+ name: "pixeldojo:list_workflows",
1326
+ description: "List your saved workflows with step counts and run totals.",
1327
+ inputZod: ListInputSchema,
1328
+ inputJsonSchema: { type: "object", properties: {}, required: [] },
1329
+ allowedModels: [],
1330
+ defaultModel: "",
1331
+ run: runList
1332
+ };
1333
+ }
1334
+ });
619
1335
 
620
1336
  // src/skills/index.ts
621
- var ALL_SKILLS = [
622
- generateSkill,
623
- characterSkill,
624
- storyboardSkill,
625
- upscaleSkill,
626
- statusSkill,
627
- fromUrlSkill,
628
- campaignSkill,
629
- campaignStatusSkill
630
- ];
1337
+ var skills_exports = {};
1338
+ __export(skills_exports, {
1339
+ ALL_SKILLS: () => ALL_SKILLS,
1340
+ audioSkill: () => audioSkill,
1341
+ campaignSkill: () => campaignSkill,
1342
+ campaignStatusSkill: () => campaignStatusSkill,
1343
+ characterSkill: () => characterSkill,
1344
+ editSkill: () => editSkill,
1345
+ findSkill: () => findSkill,
1346
+ fromUrlSkill: () => fromUrlSkill,
1347
+ generateSkill: () => generateSkill,
1348
+ librarySkill: () => librarySkill,
1349
+ listWorkflowsSkill: () => listWorkflowsSkill,
1350
+ runWorkflowSkill: () => runWorkflowSkill,
1351
+ saveWorkflowSkill: () => saveWorkflowSkill,
1352
+ statusSkill: () => statusSkill,
1353
+ storyboardSkill: () => storyboardSkill,
1354
+ uploadSkill: () => uploadSkill,
1355
+ upscaleSkill: () => upscaleSkill
1356
+ });
631
1357
  function findSkill(name) {
632
1358
  return ALL_SKILLS.find((s) => s.name === name);
633
1359
  }
1360
+ var ALL_SKILLS;
1361
+ var init_skills = __esm({
1362
+ "src/skills/index.ts"() {
1363
+ init_generate();
1364
+ init_edit();
1365
+ init_character();
1366
+ init_storyboard();
1367
+ init_upscale();
1368
+ init_status();
1369
+ init_from_url();
1370
+ init_campaign();
1371
+ init_campaign_status();
1372
+ init_upload();
1373
+ init_audio();
1374
+ init_library();
1375
+ init_workflows();
1376
+ ALL_SKILLS = [
1377
+ generateSkill,
1378
+ editSkill,
1379
+ characterSkill,
1380
+ storyboardSkill,
1381
+ upscaleSkill,
1382
+ audioSkill,
1383
+ librarySkill,
1384
+ saveWorkflowSkill,
1385
+ runWorkflowSkill,
1386
+ listWorkflowsSkill,
1387
+ statusSkill,
1388
+ fromUrlSkill,
1389
+ uploadSkill,
1390
+ campaignSkill,
1391
+ campaignStatusSkill
1392
+ ];
1393
+ }
1394
+ });
1395
+ function makeAttributedClient(options) {
1396
+ const { mcpVersion, skillName, baseFetch, ...sdkOptions } = options;
1397
+ const real = baseFetch ?? globalThis.fetch.bind(globalThis);
1398
+ const wrappedFetch = (input, init) => {
1399
+ const headers = new Headers(init?.headers);
1400
+ headers.set("x-pixeldojo-source", `mcp/${mcpVersion}`);
1401
+ if (skillName) headers.set("x-pixeldojo-skill", skillName);
1402
+ return real(input, { ...init, headers });
1403
+ };
1404
+ return new PixelDojoClient({
1405
+ ...sdkOptions,
1406
+ fetch: wrappedFetch
1407
+ });
1408
+ }
1409
+
1410
+ // src/server.ts
1411
+ init_skills();
634
1412
 
635
1413
  // src/redact.ts
636
1414
  var PD_KEY_RE = /pd_[A-Za-z0-9_-]{8,}/g;