@agentmedia/schema 0.3.0 → 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.
Files changed (54) hide show
  1. package/.memory/cursor.json +3 -0
  2. package/.memory/memories.json +1 -0
  3. package/.memory/project.json +5 -0
  4. package/CLAUDE.md +7 -0
  5. package/dist/__tests__/character-pipeline.test.d.ts +2 -0
  6. package/dist/__tests__/character-pipeline.test.d.ts.map +1 -0
  7. package/dist/__tests__/character-pipeline.test.js +296 -0
  8. package/dist/__tests__/character-pipeline.test.js.map +1 -0
  9. package/dist/__tests__/text-to-video.test.d.ts +2 -0
  10. package/dist/__tests__/text-to-video.test.d.ts.map +1 -0
  11. package/dist/__tests__/text-to-video.test.js +67 -0
  12. package/dist/__tests__/text-to-video.test.js.map +1 -0
  13. package/dist/generators.d.ts +67 -0
  14. package/dist/generators.d.ts.map +1 -1
  15. package/dist/generators.js +11 -1
  16. package/dist/generators.js.map +1 -1
  17. package/dist/v2/character.d.ts +32 -0
  18. package/dist/v2/character.d.ts.map +1 -0
  19. package/dist/v2/character.js +29 -0
  20. package/dist/v2/character.js.map +1 -0
  21. package/dist/v2/generators.d.ts +69 -0
  22. package/dist/v2/generators.d.ts.map +1 -0
  23. package/dist/v2/generators.js +105 -0
  24. package/dist/v2/generators.js.map +1 -0
  25. package/dist/v2/index.d.ts +13 -0
  26. package/dist/v2/index.d.ts.map +1 -0
  27. package/dist/v2/index.js +14 -0
  28. package/dist/v2/index.js.map +1 -0
  29. package/dist/v2/selfie.d.ts +78 -0
  30. package/dist/v2/selfie.d.ts.map +1 -0
  31. package/dist/v2/selfie.js +87 -0
  32. package/dist/v2/selfie.js.map +1 -0
  33. package/dist/v2/subtitle.d.ts +31 -0
  34. package/dist/v2/subtitle.d.ts.map +1 -0
  35. package/dist/v2/subtitle.js +53 -0
  36. package/dist/v2/subtitle.js.map +1 -0
  37. package/dist/video.d.ts +171 -0
  38. package/dist/video.d.ts.map +1 -1
  39. package/dist/video.js +89 -0
  40. package/dist/video.js.map +1 -1
  41. package/package.json +6 -1
  42. package/scripts/generate-v2-docs.ts +328 -0
  43. package/src/__tests__/character-pipeline.test.ts +356 -0
  44. package/src/__tests__/text-to-video.test.ts +79 -0
  45. package/src/generators.ts +12 -0
  46. package/src/v2/character.ts +39 -0
  47. package/src/v2/generators.ts +186 -0
  48. package/src/v2/index.ts +15 -0
  49. package/src/v2/selfie.ts +103 -0
  50. package/src/v2/subtitle.ts +62 -0
  51. package/src/video.ts +164 -0
  52. package/.turbo/turbo-build.log +0 -4
  53. package/.turbo/turbo-test.log +0 -14
  54. package/.turbo/turbo-typecheck.log +0 -4
package/src/video.ts CHANGED
@@ -417,3 +417,167 @@ export const ProductActingSchema = z.object({
417
417
  });
418
418
 
419
419
  export type ProductActingInput = z.infer<typeof ProductActingSchema>;
420
+
421
+ // ── Character Video ────────────────────────────────────────────────────────
422
+ //
423
+ // 3-step pipeline:
424
+ // Step 1: Character reference sheet (PNG)
425
+ // — POST /v1/character/sheet-generate
426
+ // — actor_slug returns portrait_url (free), description calls
427
+ // gpt-image-2 (~$0.04)
428
+ // Step 2: Storyboard sheet (PNG)
429
+ // — POST /v1/character/storyboard-generate
430
+ // — gpt-image-2 paints numbered panels using the character
431
+ // sheet as a reference so panels stay on-character (~$0.04)
432
+ // Step 3: Final video (this generator)
433
+ // — Seedance 2.0 multimodal: image_urls = [character, storyboard]
434
+ // + short action_prompt + duration/ratio settings
435
+ //
436
+ // All three URLs must be public HTTPS so Seedance can fetch them.
437
+
438
+ export const CHARACTER_VIDEO_DURATIONS = [5, 10] as const;
439
+ export const CHARACTER_VIDEO_RATIOS = ['9:16', '16:9', '1:1'] as const;
440
+
441
+ export const CharacterVideoSchema = z.object({
442
+ character_sheet_url: z.string().url().describe(
443
+ 'Public HTTPS URL of the character reference sheet PNG. Generate one via POST /v1/character/sheet-generate or upload your own.',
444
+ ),
445
+ storyboard_url: z.string().url().describe(
446
+ 'Public HTTPS URL of the storyboard panels PNG. Generate one via POST /v1/character/storyboard-generate or upload your own.',
447
+ ),
448
+ action_prompt: z.string().min(1).max(2000).optional().describe(
449
+ 'Optional scene/action description sent to Seedance as the primary scene driver (e.g. "Marco the chef in his Brooklyn kitchen at golden hour, takes a bite of fresh bread"). When omitted, the api-v2 server backstops it from the same session\'s storyboard job (script or beats) — without a real scene description Seedance picks the location arbitrarily.',
450
+ ),
451
+ duration: z.number().refine(
452
+ (v) => (CHARACTER_VIDEO_DURATIONS as readonly number[]).includes(v),
453
+ { message: 'duration must be 5 or 10' },
454
+ ).optional().default(10).describe('Video duration in seconds. Valid values: 5 or 10. Max 10s — Seedance i2v quality degrades past 10s with multimodal inputs.'),
455
+ aspect_ratio: z.enum(CHARACTER_VIDEO_RATIOS).optional().default('9:16').describe('Output aspect ratio. Default 9:16.'),
456
+ generate_audio: z.boolean().optional().default(true).describe('Whether Seedance synthesizes synchronized audio (ambient sounds, breath, etc.).'),
457
+ session_id: z.string().uuid().optional().describe('Optional UUID linking the three pipeline steps (sheet → storyboard → video) into one wizard session. Same value across calls makes inserts idempotent and lets api-v2 backstop action_prompt from the storyboard step.'),
458
+ webhook_url: z.string().url().optional().describe('HTTPS URL to receive a callback when the job completes or fails.'),
459
+ });
460
+
461
+ export type CharacterVideoInput = z.infer<typeof CharacterVideoSchema>;
462
+
463
+ // ── Text-to-Video (pure prompt, no character / no storyboard) ──────────────
464
+ //
465
+ // Drives Seedance 2.0 text-to-video. The prompt IS the whole creative —
466
+ // style, subject, mood, composition all baked into one string. Used by
467
+ // the "Use prompts" batch-schedule mode and as a one-shot generator
468
+ // for Claude Code / MCP / CLI workflows where the agent already has a
469
+ // fully-formed video prompt.
470
+
471
+ export const TEXT_TO_VIDEO_DURATIONS = [5, 10, 15] as const;
472
+ export const TEXT_TO_VIDEO_RATIOS = ['9:16', '16:9', '1:1'] as const;
473
+
474
+ export const TextToVideoSchema = z.object({
475
+ prompt: z.string().min(20).max(1000).describe(
476
+ 'The full video prompt. Style, subject, mood, composition, lighting, lens, motion — all in one string. Seedance reads this verbatim. Min 20 / max 1000 chars.',
477
+ ),
478
+ duration: z.number().refine(
479
+ (v) => (TEXT_TO_VIDEO_DURATIONS as readonly number[]).includes(v),
480
+ { message: 'duration must be 5, 10, or 15' },
481
+ ).optional().default(10).describe('Video duration in seconds. Valid: 5, 10, or 15.'),
482
+ aspect_ratio: z.enum(TEXT_TO_VIDEO_RATIOS).optional().default('9:16').describe(
483
+ 'Output aspect ratio. 9:16 portrait (TikTok / Reels / Shorts), 1:1 square (feed posts), 16:9 landscape (YouTube / X / LinkedIn). Default 9:16.',
484
+ ),
485
+ generate_audio: z.boolean().optional().default(true).describe(
486
+ 'Whether Seedance synthesizes synchronized audio. No extra charge.',
487
+ ),
488
+ webhook_url: z.string().url().optional().describe(
489
+ 'HTTPS URL to receive a callback when the job completes or fails.',
490
+ ),
491
+ /** When set, on completion the webhook-provider fans the rendered MP4
492
+ * out to these Postiz integrations (X, LinkedIn, etc.). Use the IDs
493
+ * returned from GET /v1/integrations/postiz/accounts. */
494
+ postiz_integration_ids: z.array(z.string()).optional().describe(
495
+ 'Postiz integration IDs to auto-publish to once the video is rendered. Get them from GET /v1/integrations/postiz/accounts.',
496
+ ),
497
+ /** How to compose the social caption. 'static' = use `caption` verbatim. 'ai' = Claude writes one using `caption_guidance` as bias. */
498
+ caption_mode: z.enum(['ai', 'static']).optional().default('static').describe(
499
+ "Caption mode for auto-publish. 'static' (default) uses the literal `caption` string. 'ai' has Claude Opus generate one each time, biased by `caption_guidance`.",
500
+ ),
501
+ caption: z.string().min(1).max(2000).optional().describe(
502
+ 'Literal caption text for the social post. Only used when caption_mode is omitted or "static".',
503
+ ),
504
+ caption_guidance: z.string().min(1).max(1000).optional().describe(
505
+ 'Tone / hashtag / length hints for the AI caption writer. Only used when caption_mode is "ai".',
506
+ ),
507
+ });
508
+
509
+ export type TextToVideoInput = z.infer<typeof TextToVideoSchema>;
510
+
511
+ // ── Step 1 of 3: Character Sheet generation ─────────────────────────────────
512
+ //
513
+ // POST /v1/character/sheet-generate. Async — returns 202 + job_id.
514
+ // Pricing: 12 credits ($0.12) for actor/reference (1 gpt-image-2 call),
515
+ // 20 credits ($0.20) for description-only (paint portrait + sheet).
516
+
517
+ export const CharacterSheetSchema = z.object({
518
+ description: z.string().min(3).max(400).optional().describe(
519
+ 'Free-text description of the character (e.g. "Marco, a 35yo Italian chef with curly black hair, white uniform"). When provided alongside a reference image, it adds context. When provided alone (no actor_slug, no reference_image_url), the worker first paints a portrait via gpt-image-2 text-to-image, then turns it into the sheet.',
520
+ ),
521
+ actor_slug: z.string().min(1).optional().describe(
522
+ 'Slug of an actor from the agent-media library. The actor\'s portrait is used as the reference image. List actors via GET /v1/actors. Mutually exclusive with reference_image_url.',
523
+ ),
524
+ reference_image_url: z.string().url().optional().describe(
525
+ 'Public HTTPS URL of a portrait/reference image (PNG/JPEG/WebP, <5MB recommended). Mutually exclusive with actor_slug.',
526
+ ),
527
+ session_id: z.string().uuid().optional().describe('Optional UUID linking the three pipeline steps. Same value across calls makes inserts idempotent.'),
528
+ }).refine(
529
+ (v) => Boolean(v.description) || Boolean(v.actor_slug) || Boolean(v.reference_image_url),
530
+ { message: 'Provide at least one of: description, actor_slug, or reference_image_url' },
531
+ ).refine(
532
+ (v) => !(v.actor_slug && v.reference_image_url),
533
+ { message: 'actor_slug and reference_image_url are mutually exclusive' },
534
+ );
535
+
536
+ export type CharacterSheetInput = z.infer<typeof CharacterSheetSchema>;
537
+
538
+ // ── Step 2 of 3: Storyboard generation ──────────────────────────────────────
539
+ //
540
+ // POST /v1/character/storyboard-generate. Async — returns 202 + job_id.
541
+ // Pricing: 12 credits ($0.12).
542
+ // Provide EITHER `beats` (3-10 short strings, gpt-image-2 paints them as
543
+ // numbered panels) OR `script` (free-text up to 1500 chars; gpt-image-2
544
+ // splits it into 4-6 panels itself).
545
+
546
+ export const STORYBOARD_RATIOS = ['9:16', '16:9', '1:1'] as const;
547
+
548
+ export const CharacterStoryboardSchema = z.object({
549
+ character_sheet_url: z.string().url().describe(
550
+ 'Public HTTPS URL of the character sheet PNG (from /v1/character/sheet-generate). Used as the visual reference so the character stays on-model across panels.',
551
+ ),
552
+ beats: z.array(z.string().min(3).max(200)).min(3).max(10).optional().describe(
553
+ 'Ordered list of 3-10 short beat descriptions, one per panel (e.g. ["Marco walks into kitchen", "pulls bread from oven", "takes a bite", "thumbs up"]). Mutually exclusive with `script`.',
554
+ ),
555
+ script: z.string().min(10).max(1500).optional().describe(
556
+ 'Free-text script (10-1500 chars). gpt-image-2 splits it into 4-6 sequential panels itself. Mutually exclusive with `beats`.',
557
+ ),
558
+ ratio: z.enum(STORYBOARD_RATIOS).optional().default('9:16').describe('Storyboard sheet aspect ratio. Default 9:16.'),
559
+ session_id: z.string().uuid().optional().describe('Optional UUID linking the three pipeline steps.'),
560
+ }).refine(
561
+ (v) => Boolean(v.beats) !== Boolean(v.script),
562
+ { message: 'Provide exactly one of: beats or script' },
563
+ );
564
+
565
+ export type CharacterStoryboardInput = z.infer<typeof CharacterStoryboardSchema>;
566
+
567
+ // ── Helper: AI-suggested beats ─────────────────────────────────────────────
568
+ //
569
+ // POST /v1/character/storyboard-suggest. Sync — returns immediately.
570
+ // No credits. Returns 3 distinct beat-sequence options for the wizard.
571
+
572
+ export const StoryboardSuggestSchema = z.object({
573
+ actor_slug: z.string().min(1).optional().describe('Library actor whose persona drives the suggestions. Mutually exclusive with character_description.'),
574
+ character_description: z.string().min(1).max(200).optional().describe('1-200 char description of the character. Mutually exclusive with actor_slug.'),
575
+ vibe: z.string().min(1).max(200).optional().describe('Optional vibe note that biases all 3 options (e.g. "wholesome", "chaotic", "cinematic").'),
576
+ duration: z.number().refine((v) => v === 5 || v === 10, { message: 'duration must be 5 or 10' }).optional().default(10),
577
+ n_panels: z.number().int().min(4).max(10).optional().default(6).describe('Panels per option (the storyboard sheet will be an n_panels-panel grid).'),
578
+ }).refine(
579
+ (v) => Boolean(v.actor_slug) !== Boolean(v.character_description),
580
+ { message: 'Provide exactly one of: actor_slug or character_description' },
581
+ );
582
+
583
+ export type StoryboardSuggestInput = z.infer<typeof StoryboardSuggestSchema>;
@@ -1,4 +0,0 @@
1
-
2
- > @agentmedia/schema@0.2.2 build /Users/suede/.codex/worktrees/b777/videoagent/packages/schema
3
- > tsc
4
-
@@ -1,14 +0,0 @@
1
-
2
- > @agentmedia/schema@0.2.2 test /Users/suede/.codex/worktrees/b777/videoagent/packages/schema
3
- > vitest run
4
-
5
-
6
- RUN v3.2.4 /Users/suede/.codex/worktrees/b777/videoagent/packages/schema
7
-
8
- ✓ src/__tests__/parity.test.ts (87 tests) 32ms
9
-
10
- Test Files 1 passed (1)
11
- Tests 87 passed (87)
12
- Start at 20:52:45
13
- Duration 1.53s (transform 212ms, setup 0ms, collect 284ms, tests 32ms, environment 0ms, prepare 297ms)
14
-
@@ -1,4 +0,0 @@
1
-
2
- > @agentmedia/schema@0.2.2 typecheck /Users/suede/.codex/worktrees/b777/videoagent/packages/schema
3
- > tsc --noEmit
4
-