@gobing-ai/knowledge-kit 0.1.29 → 0.1.30

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 (114) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/board/api.js +8724 -3861
  3. package/dist/board/collect/index.js +69 -1
  4. package/dist/board/daily-voice/index.js +474 -265
  5. package/dist/board/itc/index.js +69 -1
  6. package/dist/board/wiki/index.css +1305 -0
  7. package/dist/board/wiki/index.js +1621 -0
  8. package/dist/index.js +34689 -28532
  9. package/package.json +1 -1
  10. package/plugins/generations/content-gen/dist/index.js +14 -1
  11. package/plugins/generations/core-facts-gen/dist/index.js +14 -1
  12. package/plugins/generations/daily-article-gen/dist/index.js +14 -1
  13. package/plugins/generations/dailynews-gen/dist/index.js +14 -1
  14. package/plugins/generations/episode-plan-gen/dist/index.js +32 -2
  15. package/plugins/generations/episode-plan-gen/src/index.ts +19 -1
  16. package/plugins/generations/gemini-tts/dist/index.js +14 -1
  17. package/plugins/generations/image-gen/dist/index.js +14 -1
  18. package/plugins/generations/music-gen/dist/index.js +15 -2
  19. package/plugins/generations/news-report-gen/dist/index.js +14 -1
  20. package/plugins/generations/vibe-voice-tts/dist/index.js +14 -1
  21. package/plugins/generations/video-gen/README.md +245 -8
  22. package/plugins/generations/video-gen/dist/index.js +22447 -4763
  23. package/plugins/generations/video-gen/package.json +1 -0
  24. package/plugins/generations/video-gen/presets/formats/avatar.yaml +5 -0
  25. package/plugins/generations/video-gen/presets/formats/editorial.yaml +6 -0
  26. package/plugins/generations/video-gen/presets/formats/hybrid-pip.yaml +5 -0
  27. package/plugins/generations/video-gen/presets/styles/daily-ai.yaml +5 -0
  28. package/plugins/generations/video-gen/presets/styles/neutral.yaml +3 -0
  29. package/plugins/generations/video-gen/python/colab_comfyui_h3.py +322 -0
  30. package/plugins/generations/video-gen/python/comfyui-h3-i2v-api.json +47 -0
  31. package/plugins/generations/video-gen/python/comfyui-h3-models.json +32 -0
  32. package/plugins/generations/video-gen/python/comfyui_model_cache.py +388 -0
  33. package/plugins/generations/video-gen/python/drive_client.py +187 -0
  34. package/plugins/generations/video-gen/src/brief-cli.ts +65 -0
  35. package/plugins/generations/video-gen/src/brief.ts +464 -0
  36. package/plugins/generations/video-gen/src/ccu-ledger.ts +206 -3
  37. package/plugins/generations/video-gen/src/colab-runner.ts +346 -35
  38. package/plugins/generations/video-gen/src/index.ts +141 -109
  39. package/plugins/generations/video-gen/src/inputs.ts +162 -4
  40. package/plugins/generations/video-gen/src/layout.ts +33 -0
  41. package/plugins/generations/video-gen/src/props.ts +27 -3
  42. package/plugins/generations/video-gen/src/remotion/AvatarReel.tsx +17 -1
  43. package/plugins/generations/video-gen/src/remotion/EditorialReel.tsx +17 -1
  44. package/plugins/generations/video-gen/src/remotion/Root.tsx +2 -0
  45. package/plugins/generations/video-gen/src/remotion/engine.ts +3 -7
  46. package/plugins/generations/video-gen/src/render.ts +25 -0
  47. package/plugins/generations/video-gen/src/request.ts +150 -20
  48. package/plugins/generations/video-gen/src/visual-provider.ts +116 -3
  49. package/plugins/generations/voice-gen/dist/index.js +14 -1
  50. package/plugins/generations/voxcpm-tts/dist/index.js +14 -1
  51. package/plugins/ingestions/aihot-ingest/dist/index.js +14 -1
  52. package/plugins/ingestions/horizon-ingest/dist/index.js +14 -1
  53. package/plugins/ingestions/last30days-ingest/dist/index.js +14 -1
  54. package/plugins/ingestions/web-search/dist/index.js +14 -1
  55. package/plugins/kk/config.example.yaml +1 -1
  56. package/plugins/kk/mcp-tools.yaml +47 -0
  57. package/plugins/kk/plugin.json +1 -1
  58. package/plugins/kk/publish-presets/itc-surfdash-locales.json +42 -0
  59. package/plugins/kk/scripts/daily-stages.ts +87 -6
  60. package/plugins/kk/scripts/kk-workflow-stages.ts +64 -9
  61. package/plugins/kk/scripts/video-stages.ts +332 -0
  62. package/plugins/kk/scripts/wiki-normalize-audio.ts +354 -0
  63. package/plugins/kk/scripts/wiki-normalize-document.ts +495 -0
  64. package/plugins/kk/scripts/wiki-normalize-stages.ts +96 -0
  65. package/plugins/kk/scripts/wiki-stage-runtime.ts +39 -0
  66. package/plugins/kk/skills/news-editorial/SKILL.md +2 -1
  67. package/plugins/kk/workflows/kk-collect.yaml +10 -0
  68. package/plugins/kk/workflows/kk-news-generate.yaml +70 -8
  69. package/plugins/kk/workflows/kk-smart-seo.yaml +8 -0
  70. package/plugins/kk/workflows/kk-storm-research.yaml +10 -0
  71. package/plugins/kk/workflows/kk-video-generate.yaml +169 -0
  72. package/plugins/kk/workflows/kk-wiki-digest.yaml +49 -0
  73. package/plugins/publishings/bilibili-pub/dist/index.js +281 -268
  74. package/plugins/publishings/bilibili-pub/dist/profile-check.js +202 -0
  75. package/plugins/publishings/cnblogs-pub/dist/index.js +281 -268
  76. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +202 -0
  77. package/plugins/publishings/csdn-pub/dist/index.js +281 -268
  78. package/plugins/publishings/csdn-pub/dist/profile-check.js +216 -1
  79. package/plugins/publishings/emdash-pub/dist/index.js +33 -3
  80. package/plugins/publishings/infoq-pub/dist/index.js +281 -268
  81. package/plugins/publishings/infoq-pub/dist/profile-check.js +216 -1
  82. package/plugins/publishings/jike-pub/dist/index.js +281 -268
  83. package/plugins/publishings/jike-pub/dist/profile-check.js +216 -1
  84. package/plugins/publishings/juejin-pub/dist/index.js +281 -268
  85. package/plugins/publishings/juejin-pub/dist/profile-check.js +216 -1
  86. package/plugins/publishings/linkedin-pub/dist/index.js +281 -268
  87. package/plugins/publishings/linkedin-pub/dist/profile-check.js +216 -1
  88. package/plugins/publishings/medium-pub/dist/index.js +281 -268
  89. package/plugins/publishings/medium-pub/dist/profile-check.js +216 -1
  90. package/plugins/publishings/podcast-pub/dist/index.js +39 -9
  91. package/plugins/publishings/qiita-pub/dist/index.js +33 -3
  92. package/plugins/publishings/shipinhao-pub/dist/index.js +281 -268
  93. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +175 -0
  94. package/plugins/publishings/sspai-pub/dist/index.js +281 -268
  95. package/plugins/publishings/sspai-pub/dist/profile-check.js +202 -0
  96. package/plugins/publishings/substack-pub/dist/index.js +281 -268
  97. package/plugins/publishings/substack-pub/dist/profile-check.js +216 -1
  98. package/plugins/publishings/surfdash-pub/dist/index.js +99 -39
  99. package/plugins/publishings/surfdash-pub/plugin.json +54 -0
  100. package/plugins/publishings/surfdash-pub/src/index.ts +36 -5
  101. package/plugins/publishings/threads-pub/dist/index.js +281 -268
  102. package/plugins/publishings/threads-pub/dist/profile-check.js +216 -1
  103. package/plugins/publishings/wechatmp-pub/dist/index.js +665 -451
  104. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +215 -3
  105. package/plugins/publishings/weibo-pub/dist/index.js +281 -268
  106. package/plugins/publishings/weibo-pub/dist/profile-check.js +189 -1
  107. package/plugins/publishings/x-pub/dist/index.js +281 -268
  108. package/plugins/publishings/x-pub/dist/profile-check.js +216 -1
  109. package/plugins/publishings/xhs-pub/dist/index.js +281 -268
  110. package/plugins/publishings/xhs-pub/dist/profile-check.js +119 -1
  111. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +281 -268
  112. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +202 -0
  113. package/plugins/publishings/youtube-pub/dist/index.js +14 -1
  114. package/plugins/publishings/zenn-pub/dist/index.js +37 -7
@@ -1,4 +1,5 @@
1
1
  import { buildWaveform, type CaptionChunk } from './layout';
2
+ import type { VideoPresentation } from './request';
2
3
  import type { VisualLayer } from './visual-provider';
3
4
 
4
5
  /**
@@ -6,9 +7,16 @@ import type { VisualLayer } from './visual-provider';
6
7
  * files stay declarative and the composition contract is asserted without a render (R4/AC3).
7
8
  */
8
9
 
9
- /** Podcast CTA in the outro card; the only copy the shell owns. */
10
+ /** Podcast CTA in the outro card; the daily path's copy, overridable by a standalone brief. */
10
11
  export const PODCAST_CTA = '完整节目见播客 · 搜索「AI 日报」';
11
12
 
13
+ /**
14
+ * Presentation as the shell consumes it: a standalone brief may turn kinetic captions off (the
15
+ * caption track still ships in the props and in the Content metadata) and may name its own brand
16
+ * label and CTA. Daily runs resolve to kinetic + {@link PODCAST_CTA} in the adapter.
17
+ */
18
+ export type PresentationContract = VideoPresentation;
19
+
12
20
  /** One waveform bar: stable id plus a normalised height. */
13
21
  export interface WaveformBar {
14
22
  id: string;
@@ -29,6 +37,10 @@ export interface EditorialReelProps {
29
37
  headline: string;
30
38
  /** Outro CTA copy. */
31
39
  cta: string;
40
+ /** Kinetic word highlighting, or `off` for a caption-free frame. */
41
+ captionStyle: 'kinetic' | 'off';
42
+ /** Optional brand chip printed under the headline. */
43
+ brandLabel?: string;
32
44
  /** Public-dir-relative teaser audio name. */
33
45
  audioSrc: string;
34
46
  /** Teaser length; the composition length is this value. */
@@ -55,6 +67,7 @@ export function buildEditorialProps(args: {
55
67
  width: number;
56
68
  height: number;
57
69
  fps: number;
70
+ presentation?: PresentationContract | undefined;
58
71
  }): EditorialReelProps {
59
72
  const images = args.layer.kind === 'stills' ? args.layer.images : [];
60
73
  const clips = args.layer.kind === 'clips' ? args.layer.clips : [];
@@ -70,9 +83,13 @@ export function buildEditorialProps(args: {
70
83
  return {
71
84
  images,
72
85
  clips,
86
+ // The track always ships: `captionStyle: off` hides it in the shell without losing the
87
+ // transcript the Content metadata points at.
73
88
  captions: args.captions,
74
89
  headline: args.headline,
75
- cta: PODCAST_CTA,
90
+ cta: args.presentation?.cta ?? PODCAST_CTA,
91
+ captionStyle: args.presentation?.captionStyle ?? 'kinetic',
92
+ ...(args.presentation?.brandLabel === undefined ? {} : { brandLabel: args.presentation.brandLabel }),
76
93
  audioSrc: args.audioName,
77
94
  durationSec: args.durationSec,
78
95
  waveform: (args.waveform ?? buildWaveform(args.captions)).map((height, position) => ({
@@ -94,6 +111,8 @@ export interface AvatarReelProps {
94
111
  captions: CaptionChunk[];
95
112
  headline: string;
96
113
  cta: string;
114
+ captionStyle: 'kinetic' | 'off';
115
+ brandLabel?: string;
97
116
  audioSrc: string;
98
117
  durationSec: number;
99
118
  waveform: WaveformBar[];
@@ -122,6 +141,7 @@ export function buildAvatarProps(args: {
122
141
  width: number;
123
142
  height: number;
124
143
  fps: number;
144
+ presentation?: PresentationContract | undefined;
125
145
  }): AvatarReelProps {
126
146
  const clip = requireSingleClip(args.layer, 'avatar');
127
147
  assertCaptionTrack(args.captions, args.durationSec);
@@ -129,7 +149,9 @@ export function buildAvatarProps(args: {
129
149
  presenterClip: clip,
130
150
  captions: args.captions,
131
151
  headline: args.headline,
132
- cta: PODCAST_CTA,
152
+ cta: args.presentation?.cta ?? PODCAST_CTA,
153
+ captionStyle: args.presentation?.captionStyle ?? 'kinetic',
154
+ ...(args.presentation?.brandLabel === undefined ? {} : { brandLabel: args.presentation.brandLabel }),
133
155
  audioSrc: args.audioName,
134
156
  durationSec: args.durationSec,
135
157
  waveform: (args.waveform ?? buildWaveform(args.captions)).map((height, position) => ({
@@ -154,6 +176,7 @@ export function buildHybridPipProps(args: {
154
176
  width: number;
155
177
  height: number;
156
178
  fps: number;
179
+ presentation?: PresentationContract | undefined;
157
180
  }): HybridPipReelProps {
158
181
  const editorial = buildEditorialProps({
159
182
  layer: args.layer,
@@ -165,6 +188,7 @@ export function buildHybridPipProps(args: {
165
188
  width: args.width,
166
189
  height: args.height,
167
190
  fps: args.fps,
191
+ presentation: args.presentation,
168
192
  });
169
193
  return { ...editorial, presenterClip: requireSingleClip(args.presenterLayer, 'hybrid-pip') };
170
194
  }
@@ -44,10 +44,26 @@ export const AvatarReel = (props: AvatarReelProps) => {
44
44
  {props.headline}
45
45
  </div>
46
46
  </AbsoluteFill>
47
+ {props.brandLabel === undefined ? null : (
48
+ <AbsoluteFill style={{ alignItems: 'center', paddingTop: 148 }}>
49
+ <div
50
+ style={{
51
+ padding: '8px 20px',
52
+ borderRadius: 999,
53
+ background: 'rgba(61, 220, 151, 0.16)',
54
+ color: '#3ddc97',
55
+ fontSize: 30,
56
+ fontWeight: 600,
57
+ }}
58
+ >
59
+ {props.brandLabel}
60
+ </div>
61
+ </AbsoluteFill>
62
+ )}
47
63
  <AbsoluteFill style={{ alignItems: 'center', justifyContent: 'center', opacity: 0.9 }}>
48
64
  <WaveformBar waveform={props.waveform} />
49
65
  </AbsoluteFill>
50
- <KineticCaptions captions={props.captions} timeSec={timeSec} />
66
+ {props.captionStyle === 'off' ? null : <KineticCaptions captions={props.captions} timeSec={timeSec} />}
51
67
  <Sequence from={ctaFrom} durationInFrames={Math.max(1, durationInFrames - ctaFrom)}>
52
68
  <AbsoluteFill
53
69
  style={{
@@ -69,10 +69,26 @@ export const EditorialReel = (props: EditorialReelProps) => {
69
69
  {props.headline}
70
70
  </div>
71
71
  </AbsoluteFill>
72
+ {props.brandLabel === undefined ? null : (
73
+ <AbsoluteFill style={{ alignItems: 'center', paddingTop: 148 }}>
74
+ <div
75
+ style={{
76
+ padding: '8px 20px',
77
+ borderRadius: 999,
78
+ background: 'rgba(61, 220, 151, 0.16)',
79
+ color: '#3ddc97',
80
+ fontSize: 32,
81
+ fontWeight: 600,
82
+ }}
83
+ >
84
+ {props.brandLabel}
85
+ </div>
86
+ </AbsoluteFill>
87
+ )}
72
88
  <AbsoluteFill style={{ alignItems: 'center', justifyContent: 'center', opacity: 0.9 }}>
73
89
  <WaveformBar waveform={props.waveform} />
74
90
  </AbsoluteFill>
75
- <KineticCaptions captions={props.captions} timeSec={timeSec} />
91
+ {props.captionStyle === 'off' ? null : <KineticCaptions captions={props.captions} timeSec={timeSec} />}
76
92
  <Sequence from={ctaFrom} durationInFrames={Math.max(1, durationInFrames - ctaFrom)}>
77
93
  <AbsoluteFill
78
94
  style={{
@@ -15,6 +15,7 @@ const DEFAULT_PROPS: EditorialReelProps = {
15
15
  captions: DEFAULT_CAPTIONS,
16
16
  headline: '',
17
17
  cta: '',
18
+ captionStyle: 'kinetic',
18
19
  audioSrc: 'teaser.wav',
19
20
  durationSec: 50,
20
21
  waveform: DEFAULT_WAVEFORM,
@@ -28,6 +29,7 @@ const DEFAULT_AVATAR_PROPS: AvatarReelProps = {
28
29
  captions: DEFAULT_CAPTIONS,
29
30
  headline: '',
30
31
  cta: '',
32
+ captionStyle: 'kinetic',
31
33
  audioSrc: 'teaser.wav',
32
34
  durationSec: 50,
33
35
  waveform: DEFAULT_WAVEFORM,
@@ -1,10 +1,6 @@
1
1
  import { bundle } from '@remotion/bundler';
2
2
  import { renderMedia, selectComposition } from '@remotion/renderer';
3
- import { describeRenderFailure, type RenderVideo } from '../render';
4
-
5
- function requireCachedBrowser(): never {
6
- throw new Error('video-gen: Chromium cache is missing');
7
- }
3
+ import { describeRenderFailure, type RenderVideo, refuseBrowserDownload } from '../render';
8
4
 
9
5
  /**
10
6
  * The only module that touches Remotion's native side. The plugin entry loads it lazily so the fast
@@ -31,7 +27,7 @@ async function renderWith(
31
27
  serveUrl,
32
28
  id: compositionId,
33
29
  inputProps,
34
- onBrowserDownload: requireCachedBrowser,
30
+ onBrowserDownload: refuseBrowserDownload,
35
31
  });
36
32
  await renderMedia({
37
33
  composition,
@@ -40,7 +36,7 @@ async function renderWith(
40
36
  audioCodec: 'aac',
41
37
  outputLocation: outputPath,
42
38
  inputProps,
43
- onBrowserDownload: requireCachedBrowser,
39
+ onBrowserDownload: refuseBrowserDownload,
44
40
  chromiumOptions: { gl: 'swangle' },
45
41
  concurrency: 2,
46
42
  });
@@ -43,6 +43,17 @@ export async function stageAssets(args: {
43
43
  return { imageNames, audioName: STAGED_AUDIO_NAME };
44
44
  }
45
45
 
46
+ /**
47
+ * Copy the teaser audio into the public dir without any stills: an avatar brief renders a
48
+ * presenter-only frame, so it has a track to hear and nothing to stage (0455).
49
+ */
50
+ export async function stageAudio(args: { audioPath: string; publicDir: string; fs?: FileSystem }): Promise<string> {
51
+ const fs = args.fs ?? nodeFileSystem;
52
+ await fs.ensureDir(args.publicDir);
53
+ await fs.copy(args.audioPath, join(args.publicDir, STAGED_AUDIO_NAME));
54
+ return STAGED_AUDIO_NAME;
55
+ }
56
+
46
57
  /** One render request handed to the Remotion engine. */
47
58
  export interface RenderArgs {
48
59
  /** Composition to render: the editorial shell or one of 0452's avatar shells. */
@@ -83,6 +94,20 @@ export async function renderReel(
83
94
  return { outputPath: args.outputPath, sizeBytes };
84
95
  }
85
96
 
97
+ /**
98
+ * Remotion's `onBrowserDownload` hook: refuse to download Chromium at render time and fail closed.
99
+ * A cold cache is an operator provisioning step, not something a scheduled run may spend minutes on —
100
+ * and the message routes through {@link describeRenderFailure} to the exact command to run.
101
+ *
102
+ * Exported so the missing-cache branch can be asserted directly: driving it through a real render
103
+ * leaves @remotion/renderer's module-level `internalEnsureBrowser` promise chain rejected, and every
104
+ * later render in that process then reports a missing browser even though the cache is present
105
+ * (run 46727472651 — the Wan clip render failed after render-e2e's probe).
106
+ */
107
+ export function refuseBrowserDownload(): never {
108
+ throw new Error('video-gen: Chromium cache is missing');
109
+ }
110
+
86
111
  /**
87
112
  * Point a browser-cache failure at the one-time local provisioning command.
88
113
  */
@@ -1,5 +1,10 @@
1
- import { extname, isAbsolute } from 'node:path';
2
- import { VideoRenderProviderSchema, type VideoVisualMode, VideoVisualModeSchema } from '@gobing-ai/kk-core';
1
+ import { extname, isAbsolute, resolve } from 'node:path';
2
+ import {
3
+ type VideoRenderProvider,
4
+ VideoRenderProviderSchema,
5
+ type VideoVisualMode,
6
+ VideoVisualModeSchema,
7
+ } from '@gobing-ai/kk-core';
3
8
  import { z } from 'zod';
4
9
 
5
10
  /**
@@ -11,10 +16,16 @@ import { z } from 'zod';
11
16
  export const SHIPPED_VISUAL_MODES = ['editorial', 'avatar', 'hybrid-pip'] as const;
12
17
 
13
18
  /** Visual providers this build can actually produce. */
14
- export const SHIPPED_PROVIDERS = ['local-ken-burns', 'wan21-i2v', 'musetalk', 'echomimic-v2'] as const;
19
+ export const SHIPPED_PROVIDERS = [
20
+ 'local-ken-burns',
21
+ 'wan21-i2v',
22
+ 'comfyui-minimax-h3',
23
+ 'musetalk',
24
+ 'echomimic-v2',
25
+ ] as const;
15
26
 
16
27
  /** Providers an editorial reel can render. */
17
- export const EDITORIAL_PROVIDERS = ['local-ken-burns', 'wan21-i2v'] as const;
28
+ export const EDITORIAL_PROVIDERS = ['local-ken-burns', 'wan21-i2v', 'comfyui-minimax-h3'] as const;
18
29
 
19
30
  /** Providers an avatar request may name; `hybrid-pip` overlays a MuseTalk bubble only. */
20
31
  export const AVATAR_PROVIDERS = ['musetalk', 'echomimic-v2'] as const;
@@ -39,6 +50,9 @@ export const ColabRequestSchema = z.strictObject({
39
50
  /**
40
51
  * Plugin-local generator request (`--in`). The output contract is shared in `@gobing-ai/kk-core`;
41
52
  * the request stays here because generators own their own input shape (no `Brief` schema in core).
53
+ *
54
+ * This is the **legacy daily** shape: it carries no discriminator and resolves its own work-dir
55
+ * artifacts. A standalone brief sends `inputKind: "explicit"` instead (D91/0454).
42
56
  */
43
57
  export const VideoGenRequestSchema = z.strictObject({
44
58
  workDir: z.string().min(1),
@@ -55,9 +69,59 @@ export const VideoGenRequestSchema = z.strictObject({
55
69
  /** Parsed {@link VideoGenRequestSchema} payload. */
56
70
  export type VideoGenRequest = z.infer<typeof VideoGenRequestSchema>;
57
71
 
72
+ /** Parsed {@link ColabRequestSchema} payload. */
73
+ export type ColabRequest = z.infer<typeof ColabRequestSchema>;
74
+
58
75
  /** Parsed explicit hook window from {@link HookWindowSchema}. */
59
76
  export type RequestedHookWindow = z.infer<typeof HookWindowSchema>;
60
77
 
78
+ /**
79
+ * Copy overrides a standalone brief may carry. Daily runs keep the shipped kinetic captions and the
80
+ * podcast CTA, so nothing here can leak into the legacy path.
81
+ */
82
+ export const VideoPresentationSchema = z.strictObject({
83
+ captionStyle: z.enum(['kinetic', 'off']),
84
+ brandLabel: z.string().min(1).optional(),
85
+ cta: z.string().min(1).optional(),
86
+ });
87
+
88
+ /** Parsed {@link VideoPresentationSchema} payload. */
89
+ export type VideoPresentation = z.infer<typeof VideoPresentationSchema>;
90
+
91
+ /**
92
+ * Standalone (non-news) render brief (D91 R1). The discriminator is what separates it from the
93
+ * daily request: without it, the strict daily parser judges the payload. Every path is resolved
94
+ * against the request file's directory before the value leaves this module, so no later step
95
+ * guesses a base directory.
96
+ */
97
+ export const ExplicitVideoRequestSchema = z.strictObject({
98
+ inputKind: z.literal('explicit'),
99
+ title: z.string().min(1),
100
+ description: z.string().min(1).optional(),
101
+ audioPath: z.string().min(1),
102
+ /** Empty is legal only for `avatar`, which needs a portrait instead of stills (0455). */
103
+ imagePaths: z.array(z.string().min(1)),
104
+ hostPortraitPath: z.string().min(1).optional(),
105
+ outputDir: z.string().min(1),
106
+ visualMode: VideoVisualModeSchema,
107
+ /** Reel length when the brief names no hook window. */
108
+ durationTargetSec: z.number().positive(),
109
+ hook: HookWindowSchema.optional(),
110
+ presentation: VideoPresentationSchema,
111
+ provider: VideoRenderProviderSchema.optional(),
112
+ /** Standalone editorial GPU failures propagate unless this is explicitly `true`. */
113
+ allowEditorialFallback: z.boolean().optional(),
114
+ colab: ColabRequestSchema.optional(),
115
+ });
116
+
117
+ /** Parsed {@link ExplicitVideoRequestSchema} payload (paths already absolute). */
118
+ export type ExplicitVideoRequest = z.infer<typeof ExplicitVideoRequestSchema>;
119
+
120
+ /** A normalized request plus the shape it arrived in. */
121
+ export type VideoGenRequestInput =
122
+ | { inputKind: 'daily'; request: VideoGenRequest }
123
+ | { inputKind: 'explicit'; request: ExplicitVideoRequest };
124
+
61
125
  function describeIssues(error: z.ZodError): string {
62
126
  return error.issues.map((issue) => `${issue.path.join('.') || '(root)'}: ${issue.message}`).join('; ');
63
127
  }
@@ -66,15 +130,18 @@ function describeIssues(error: z.ZodError): string {
66
130
  * Validate the request JSON, failing closed on shape and on a mode this milestone does not ship.
67
131
  * Runs before any `ffprobe`/`ffmpeg`/`uv`/Chromium spawn (R6).
68
132
  */
69
- export function parseVideoGenRequest(raw: unknown): VideoGenRequest {
70
- const parsed = VideoGenRequestSchema.safeParse(raw);
71
- if (!parsed.success) {
72
- throw new Error(`video-gen: invalid request: ${describeIssues(parsed.error)}`);
73
- }
74
- // The zod enum already refuses an unknown mode/provider, and every enumerated value is shipped
75
- // (0452 lifts the editorial-only guard) — the checks below are about MODE/PROVIDER agreement.
76
- const mode: VideoVisualMode = parsed.data.visualMode;
77
- const provider = parsed.data.provider;
133
+ /**
134
+ * Mode/provider agreement, shared by the daily and standalone parsers so both fail closed on one
135
+ * ladder (0452 R4). The zod enums already refuse unknown values; the checks below are about which
136
+ * mode may name which provider, and about the portrait an avatar mode needs.
137
+ */
138
+ function resolveModeProvider(args: {
139
+ visualMode: VideoVisualMode;
140
+ provider: VideoRenderProvider | undefined;
141
+ hostPortraitPath: string | undefined;
142
+ }): VideoRenderProvider | undefined {
143
+ const mode = args.visualMode;
144
+ const provider = args.provider;
78
145
  if (mode === 'editorial') {
79
146
  // The avatar providers drive the presenter shells; an editorial reel cannot use them.
80
147
  if (provider !== undefined && !(EDITORIAL_PROVIDERS as readonly string[]).includes(provider)) {
@@ -82,7 +149,7 @@ export function parseVideoGenRequest(raw: unknown): VideoGenRequest {
82
149
  `video-gen: visualMode "editorial" renders ${EDITORIAL_PROVIDERS.join(' or ')}; "${provider}" needs visualMode "avatar"`,
83
150
  );
84
151
  }
85
- return parsed.data;
152
+ return provider;
86
153
  }
87
154
  // 0452 R4: avatar modes fail closed on the request before any Colab spawn.
88
155
  const avatarProvider = provider ?? 'musetalk';
@@ -94,7 +161,7 @@ export function parseVideoGenRequest(raw: unknown): VideoGenRequest {
94
161
  if (mode === 'hybrid-pip' && avatarProvider !== 'musetalk') {
95
162
  throw new Error(`video-gen: hybrid-pip overlays a musetalk bubble only; got provider "${avatarProvider}"`);
96
163
  }
97
- const portrait = parsed.data.hostPortraitPath;
164
+ const portrait = args.hostPortraitPath;
98
165
  if (portrait === undefined) {
99
166
  throw new Error(
100
167
  `video-gen: visualMode "${mode}" requires hostPortraitPath (the operator's own or consented portrait)`,
@@ -109,7 +176,54 @@ export function parseVideoGenRequest(raw: unknown): VideoGenRequest {
109
176
  `video-gen: hostPortraitPath must be an image (${PORTRAIT_EXTENSIONS.join(', ')}), got "${portraitExtension || '(none)'}"`,
110
177
  );
111
178
  }
112
- return { ...parsed.data, provider: avatarProvider };
179
+ return avatarProvider;
180
+ }
181
+
182
+ export function parseVideoGenRequest(raw: unknown): VideoGenRequest {
183
+ const parsed = VideoGenRequestSchema.safeParse(raw);
184
+ if (!parsed.success) {
185
+ throw new Error(`video-gen: invalid request: ${describeIssues(parsed.error)}`);
186
+ }
187
+ const provider = resolveModeProvider({
188
+ visualMode: parsed.data.visualMode,
189
+ provider: parsed.data.provider,
190
+ hostPortraitPath: parsed.data.hostPortraitPath,
191
+ });
192
+ return provider === parsed.data.provider ? parsed.data : { ...parsed.data, provider };
193
+ }
194
+
195
+ /**
196
+ * Parse a standalone brief, resolving every path against `baseDir` (the request file's directory)
197
+ * so downstream steps never re-derive a base directory.
198
+ */
199
+ export function parseExplicitVideoRequest(raw: unknown, baseDir: string = process.cwd()): ExplicitVideoRequest {
200
+ const parsed = ExplicitVideoRequestSchema.safeParse(raw);
201
+ if (!parsed.success) {
202
+ throw new Error(`video-gen: invalid explicit request: ${describeIssues(parsed.error)}`);
203
+ }
204
+ const absolute = (path: string): string => (isAbsolute(path) ? path : resolve(baseDir, path));
205
+ const request: ExplicitVideoRequest = {
206
+ ...parsed.data,
207
+ audioPath: absolute(parsed.data.audioPath),
208
+ imagePaths: parsed.data.imagePaths.map((path) => absolute(path)),
209
+ outputDir: absolute(parsed.data.outputDir),
210
+ ...(parsed.data.hostPortraitPath === undefined
211
+ ? {}
212
+ : { hostPortraitPath: absolute(parsed.data.hostPortraitPath) }),
213
+ };
214
+ // A standalone brief names its own media, so the still requirement is checked here: only the
215
+ // full-frame avatar format can render without one (D91 R2, 0455).
216
+ if (request.visualMode !== 'avatar' && request.imagePaths.length === 0) {
217
+ throw new Error(
218
+ `video-gen: visualMode "${request.visualMode}" needs at least one image (avatar is the only mode without stills)`,
219
+ );
220
+ }
221
+ const provider = resolveModeProvider({
222
+ visualMode: request.visualMode,
223
+ provider: request.provider,
224
+ hostPortraitPath: request.hostPortraitPath,
225
+ });
226
+ return provider === request.provider ? request : { ...request, provider };
113
227
  }
114
228
 
115
229
  /**
@@ -120,15 +234,31 @@ export function parseVideoGenRequest(raw: unknown): VideoGenRequest {
120
234
  * the same way every other generator receives its work. A bare request object stays accepted for a
121
235
  * direct `bun src/index.ts --in request.json` run (dogfood/debug).
122
236
  */
123
- export function parseVideoGenRequestInput(raw: unknown): VideoGenRequest {
124
- if (!Array.isArray(raw)) return parseVideoGenRequest(raw);
237
+ export function parseVideoGenRequestInput(raw: unknown, baseDir?: string): VideoGenRequestInput {
238
+ const payload = unwrapRequestPayload(raw);
239
+ const record = payload as Record<string, unknown>;
240
+ const discriminator = record.inputKind;
241
+ if (discriminator === 'explicit') {
242
+ return { inputKind: 'explicit', request: parseExplicitVideoRequest(record, baseDir) };
243
+ }
244
+ if (discriminator !== undefined) {
245
+ throw new Error(
246
+ `video-gen: unknown inputKind "${String(discriminator)}" (send "explicit" for a standalone brief, or no inputKind for a daily request)`,
247
+ );
248
+ }
249
+ return { inputKind: 'daily', request: parseVideoGenRequest(record) };
250
+ }
251
+
252
+ /** The request payload from either a bare object or the `Doc[]` envelope `kk executor run` sends. */
253
+ function unwrapRequestPayload(raw: unknown): unknown {
254
+ if (!Array.isArray(raw)) return raw;
125
255
  const first = raw[0];
126
256
  if (typeof first !== 'object' || first === null) {
127
257
  throw new Error('video-gen: --in must be a Doc[] whose first entry carries the request in metadata');
128
258
  }
129
259
  const metadata = (first as { metadata?: unknown }).metadata;
130
260
  if (typeof metadata !== 'object' || metadata === null) {
131
- throw new Error('video-gen: --in Doc[0] carries no metadata (workDir/runDate/visualMode are required)');
261
+ throw new Error('video-gen: --in Doc[0] carries no metadata (the request rides in the first Doc)');
132
262
  }
133
- return parseVideoGenRequest(metadata);
263
+ return metadata;
134
264
  }
@@ -1,4 +1,5 @@
1
- import type { VideoRenderProvider, VideoVisualMode } from '@gobing-ai/kk-core';
1
+ import { dirname, join } from 'node:path';
2
+ import type { RenderProvenance, VideoRenderProvider, VideoVisualMode } from '@gobing-ai/kk-core';
2
3
  import type { ColabGpu } from './ccu-ledger';
3
4
  import type { ColabJob, ColabJobResult } from './colab-runner';
4
5
 
@@ -14,7 +15,10 @@ export interface VisualContext {
14
15
  }
15
16
 
16
17
  /** A stills reel (Ken-Burns animates each image) or pre-rendered clips composited beneath the shell. */
17
- export type VisualLayer = { kind: 'stills'; images: string[] } | { kind: 'clips'; clips: string[] };
18
+ export type VisualLayer =
19
+ | { kind: 'stills'; images: string[] }
20
+ // `provenance` is set by Colab providers that report it (H3); renderers ignore it.
21
+ | { kind: 'clips'; clips: string[]; provenance?: RenderProvenance };
18
22
 
19
23
  /** One visual provider: an id matching the shared enum, and a prepare step. */
20
24
  export interface VisualProvider {
@@ -114,11 +118,83 @@ export function createWan21Provider(options: Wan21ProviderOptions): VisualProvid
114
118
  };
115
119
  }
116
120
 
121
+ /**
122
+ * The `comfyui-minimax-h3` provider (D91 R7, 0459): first-frame → motion clips through the pinned
123
+ * ComfyUI API graph, executed on Colab by the shared budgeted runner.
124
+ *
125
+ * Same seam as Wan — it returns a `clips` layer — but it names its own worker (`colab_comfyui_h3.py`),
126
+ * its own pinned graph (`python/comfyui-h3-i2v-api.json`) and its own GPU policy (A100 or L4; the
127
+ * pruned int8 checkpoint does not fit a 16 GB T4 with the text encoder resident).
128
+ */
129
+ export const H3_DEFAULT_GPU: ColabGpu = 'A100';
130
+ export const H3_REFUSED_GPUS: readonly ColabGpu[] = ['T4'];
131
+ export const H3_DEFAULT_TIMEOUT_MS = 1_800_000;
132
+ /** Siblings `colab_comfyui_h3.py` imports or reads on the VM (it restores weights through 0458's cache). */
133
+ export const H3_SUPPORT_FILES = [
134
+ 'drive_client.py',
135
+ 'comfyui_model_cache.py',
136
+ 'comfyui-h3-i2v-api.json',
137
+ 'comfyui-h3-models.json',
138
+ ] as const;
139
+
140
+ export function createComfyuiH3Provider(options: Wan21ProviderOptions): VisualProvider {
141
+ const gpu = options.gpu ?? H3_DEFAULT_GPU;
142
+ return {
143
+ id: 'comfyui-minimax-h3',
144
+ prepare: async (ctx) => {
145
+ if (ctx.images.length === 0) {
146
+ throw new Error('video-gen: comfyui-minimax-h3 needs a first frame (one still)');
147
+ }
148
+ if (H3_REFUSED_GPUS.includes(gpu)) {
149
+ throw new Error(
150
+ `video-gen: comfyui-minimax-h3 cannot run on ${gpu} (the pruned int8 graph plus the text encoder need an A100 or an L4)`,
151
+ );
152
+ }
153
+ const outputNames = ctx.images.map((_, index) => `${options.runDate}_clip-${index}.mp4`);
154
+ const result = await options.runJob({
155
+ jobType: 'comfyui-minimax-h3',
156
+ gpu,
157
+ script: options.script,
158
+ inputPaths: ctx.images,
159
+ supportPaths: H3_SUPPORT_FILES.map((name) => join(dirname(options.script), name)),
160
+ outputNames,
161
+ remoteDir: options.remoteDir,
162
+ runDate: options.runDate,
163
+ timeoutMs: options.timeoutMs ?? H3_DEFAULT_TIMEOUT_MS,
164
+ env: options.env ?? {},
165
+ });
166
+ if (!result.ok) {
167
+ throw new Error(result.error ?? 'comfyui-minimax-h3 job failed');
168
+ }
169
+ if (result.outputs.length === 0) {
170
+ throw new Error('comfyui-minimax-h3 job produced no clips');
171
+ }
172
+ if (options.exists !== undefined) {
173
+ for (const clip of result.outputs) {
174
+ if (!(await options.exists(clip))) {
175
+ throw new Error(`comfyui-minimax-h3 reported ${clip} but the file is not on disk`);
176
+ }
177
+ }
178
+ }
179
+ return {
180
+ kind: 'clips',
181
+ clips: result.outputs,
182
+ provenance: { cache: result.cache, ...result.provenance },
183
+ };
184
+ },
185
+ };
186
+ }
187
+
117
188
  /** Options for the `wan21-i2v` fallback decision. */
118
189
  export interface PrepareLayerArgs {
119
190
  mode: VideoVisualMode;
120
191
  providerId: VideoRenderProvider;
121
192
  images: string[];
193
+ /**
194
+ * `false` propagates a GPU failure instead of falling back (D91 R1, standalone briefs). The
195
+ * daily adapter passes `true`: the cron must always get a video.
196
+ */
197
+ allowFallback?: boolean;
122
198
  /** Present only when the request asked for `wan21-i2v`. */
123
199
  wan21?: Wan21ProviderOptions;
124
200
  }
@@ -134,11 +210,47 @@ export interface PreparedLayer {
134
210
  /**
135
211
  * Resolve the visual layer (R4/R5): `wan21-i2v` when asked and available, otherwise — or on **any**
136
212
  * Colab failure, which includes a budget refusal — the local Ken-Burns reel with a named warning.
137
- * A fallback never fails the run: the daily cron must always get a video.
213
+ * A fallback never fails the daily run: the cron must always get a video. A standalone brief that
214
+ * did not ask for the fallback gets the GPU error instead (`allowFallback: false`).
138
215
  */
139
216
  export async function prepareVisualLayer(args: PrepareLayerArgs): Promise<PreparedLayer> {
217
+ const allowFallback = args.allowFallback ?? true;
218
+ if (args.providerId === 'comfyui-minimax-h3') {
219
+ // Opt-in provider (D91 R7): the same fallback rule as Wan — daily keeps rendering, a
220
+ // standalone brief without the switch fails.
221
+ if (args.wan21 === undefined) {
222
+ if (!allowFallback) {
223
+ throw new Error(
224
+ 'video-gen: comfyui-minimax-h3 requested without Colab options, and fallback was not requested',
225
+ );
226
+ }
227
+ return {
228
+ layer: await localKenBurns.prepare({ images: args.images }),
229
+ providerId: 'local-ken-burns',
230
+ fallbackUsed: true,
231
+ warnings: ['comfyui-minimax-h3 requested without Colab options; used local Ken-Burns'],
232
+ };
233
+ }
234
+ try {
235
+ const layer = await createComfyuiH3Provider(args.wan21).prepare({ images: args.images });
236
+ return { layer, providerId: 'comfyui-minimax-h3', fallbackUsed: false, warnings: [] };
237
+ } catch (error: unknown) {
238
+ if (!allowFallback) throw error;
239
+ return {
240
+ layer: await localKenBurns.prepare({ images: args.images }),
241
+ providerId: 'local-ken-burns',
242
+ fallbackUsed: true,
243
+ warnings: [
244
+ `comfyui-minimax-h3 failed, fell back to local Ken-Burns: ${error instanceof Error ? error.message : String(error)}`,
245
+ ],
246
+ };
247
+ }
248
+ }
140
249
  if (args.providerId === 'wan21-i2v') {
141
250
  if (args.wan21 === undefined) {
251
+ if (!allowFallback) {
252
+ throw new Error('video-gen: wan21-i2v requested without Colab options, and fallback was not requested');
253
+ }
142
254
  return {
143
255
  layer: await localKenBurns.prepare({ images: args.images }),
144
256
  providerId: 'local-ken-burns',
@@ -150,6 +262,7 @@ export async function prepareVisualLayer(args: PrepareLayerArgs): Promise<Prepar
150
262
  const layer = await createWan21Provider(args.wan21).prepare({ images: args.images });
151
263
  return { layer, providerId: 'wan21-i2v', fallbackUsed: false, warnings: [] };
152
264
  } catch (error: unknown) {
265
+ if (!allowFallback) throw error;
153
266
  return {
154
267
  layer: await localKenBurns.prepare({ images: args.images }),
155
268
  providerId: 'local-ken-burns',
@@ -17438,7 +17438,19 @@ var omniVoiceGenContentSchema = ContentSchema.extend({
17438
17438
  })
17439
17439
  });
17440
17440
  var VideoVisualModeSchema = _enum(["editorial", "avatar", "hybrid-pip"]);
17441
- var VideoRenderProviderSchema = _enum(["local-ken-burns", "wan21-i2v", "musetalk", "echomimic-v2"]);
17441
+ var VideoRenderProviderSchema = _enum([
17442
+ "local-ken-burns",
17443
+ "wan21-i2v",
17444
+ "comfyui-minimax-h3",
17445
+ "musetalk",
17446
+ "echomimic-v2"
17447
+ ]);
17448
+ var RenderProvenanceSchema = object({
17449
+ cache: _enum(["drive", "local"]),
17450
+ comfyuiCommit: string2().min(1).optional(),
17451
+ comfyuiRuntimeCommit: string2().min(1).nullable().optional(),
17452
+ modelCache: object({ verified: boolean2(), restored: number2().int().nonnegative() }).optional()
17453
+ });
17442
17454
  var videoGenContentSchema = ContentSchema.extend({
17443
17455
  format: literal("video"),
17444
17456
  metadata: looseObject({
@@ -17451,6 +17463,7 @@ var videoGenContentSchema = ContentSchema.extend({
17451
17463
  durationSec: number2().positive(),
17452
17464
  visualMode: VideoVisualModeSchema,
17453
17465
  renderProvider: VideoRenderProviderSchema,
17466
+ renderProvenance: RenderProvenanceSchema.optional(),
17454
17467
  fallbackUsed: boolean2().optional(),
17455
17468
  warnings: array(string2()).optional(),
17456
17469
  ccuEstimated: number2().nonnegative().optional(),