@vgai/sdk 0.4.0-canary.20260715.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 (51) hide show
  1. package/package.json +27 -0
  2. package/src/cinematic/capabilities-operations.ts +128 -0
  3. package/src/cinematic/cue-operations.ts +198 -0
  4. package/src/cinematic/gsap-operations.ts +126 -0
  5. package/src/cinematic/index.ts +59 -0
  6. package/src/cinematic/preview-operations.ts +279 -0
  7. package/src/cinematic/preview-transport.ts +244 -0
  8. package/src/cinematic/render-operations.ts +409 -0
  9. package/src/cinematic/render-transport.ts +238 -0
  10. package/src/cinematic/theatre-operations.ts +306 -0
  11. package/src/editor/camera-operations.ts +169 -0
  12. package/src/editor/console-operations.ts +87 -0
  13. package/src/editor/hierarchy-operations.ts +95 -0
  14. package/src/editor/index.ts +62 -0
  15. package/src/editor/open-operations.ts +209 -0
  16. package/src/editor/screenshot-operations.ts +99 -0
  17. package/src/editor/selection-operations.ts +144 -0
  18. package/src/editor/session-operations.ts +73 -0
  19. package/src/editor/source-location-operations.ts +106 -0
  20. package/src/editor/transport.ts +647 -0
  21. package/src/errors.ts +72 -0
  22. package/src/http/http-projection.ts +349 -0
  23. package/src/http/index.ts +11 -0
  24. package/src/index.ts +67 -0
  25. package/src/mcp/index.ts +16 -0
  26. package/src/mcp/mcp-projection.ts +288 -0
  27. package/src/operations.ts +83 -0
  28. package/src/play/control-operations.ts +205 -0
  29. package/src/play/debug-command-operations.ts +245 -0
  30. package/src/play/index.ts +66 -0
  31. package/src/play/input-operations.ts +316 -0
  32. package/src/play/lifecycle-operations.ts +271 -0
  33. package/src/play/log-operations.ts +279 -0
  34. package/src/play/run-ticks-operations.ts +141 -0
  35. package/src/play/state-operations.ts +210 -0
  36. package/src/play/status-operations.ts +160 -0
  37. package/src/play/transport.ts +728 -0
  38. package/src/project/asset-operations.ts +243 -0
  39. package/src/project/component-operations.ts +337 -0
  40. package/src/project/discovery-operations.ts +269 -0
  41. package/src/project/entity-operations.ts +366 -0
  42. package/src/project/index.ts +55 -0
  43. package/src/project/input-map-operations.ts +233 -0
  44. package/src/project/manifest-operations.ts +355 -0
  45. package/src/project/scene-operations.ts +426 -0
  46. package/src/project/shared.ts +299 -0
  47. package/src/registry.ts +285 -0
  48. package/src/render/capabilities/ffmpeg.ts +141 -0
  49. package/src/render/index.ts +15 -0
  50. package/src/render/render-cinematic.ts +1847 -0
  51. package/src/types.ts +101 -0
@@ -0,0 +1,141 @@
1
+ /**
2
+ * FFmpeg/ffprobe capability check (spec A1 AC: "FFmpeg absence produces a
3
+ * named capability error with installation guidance"; §17 Artifact
4
+ * Verification requires `ffprobe` alongside `ffmpeg`).
5
+ *
6
+ * The cinematic render pipeline (Workstream I) shells out to the system
7
+ * `ffmpeg`/`ffprobe` binaries directly — the same approach the e2e suite
8
+ * already uses (`packages/editor/e2e/helpers/record.ts`'s `spawnSync('ffmpeg',
9
+ * ...)`) — rather than depending on an npm "ffmpeg discovery/wrapper"
10
+ * package. This module is the single place that probes for both binaries and
11
+ * turns their absence into a structured, named error instead of a raw
12
+ * ENOENT bubbling out of a later `spawnSync` call deep in the render
13
+ * pipeline.
14
+ *
15
+ * Deliberately dependency-free (only `node:child_process`) so it can be
16
+ * called early — before any browser/render machinery spins up — from the
17
+ * CLI, the SDK's `cinematic.render` operation, or a `doctor`-style
18
+ * preflight check.
19
+ */
20
+ import { type SpawnSyncReturns, spawnSync } from 'node:child_process';
21
+
22
+ /** The two binaries this module checks. */
23
+ export type FfmpegBinaryName = 'ffmpeg' | 'ffprobe';
24
+
25
+ /** Structured, named error codes — never a bare "not found" string an agent has to pattern-match. */
26
+ export type FfmpegCapabilityErrorCode = 'FFMPEG_NOT_FOUND' | 'FFPROBE_NOT_FOUND';
27
+
28
+ export interface FfmpegCapabilityError {
29
+ readonly code: FfmpegCapabilityErrorCode;
30
+ readonly binary: FfmpegBinaryName;
31
+ /** The command that was probed (honors the `ffmpegBin`/`ffprobeBin` overrides passed to `checkFfmpegCapability`). */
32
+ readonly command: string;
33
+ readonly message: string;
34
+ /** Platform-appropriate install guidance, ready to print as-is. */
35
+ readonly installGuidance: string;
36
+ }
37
+
38
+ export interface FfmpegCapabilityOk {
39
+ readonly ok: true;
40
+ readonly ffmpeg: { readonly command: string; readonly version: string };
41
+ readonly ffprobe: { readonly command: string; readonly version: string };
42
+ }
43
+
44
+ export interface FfmpegCapabilityFailure {
45
+ readonly ok: false;
46
+ /** One entry per missing binary — both `ffmpeg` and `ffprobe` are always probed, so this can hold 1 or 2 entries. */
47
+ readonly errors: readonly FfmpegCapabilityError[];
48
+ }
49
+
50
+ export type FfmpegCapabilityResult = FfmpegCapabilityOk | FfmpegCapabilityFailure;
51
+
52
+ export interface CheckFfmpegCapabilityOptions {
53
+ /** Override the `ffmpeg` command/path probed (default: `"ffmpeg"`, resolved via PATH). Test-only escape hatch to simulate absence deterministically. */
54
+ ffmpegBin?: string;
55
+ /** Override the `ffprobe` command/path probed (default: `"ffprobe"`, resolved via PATH). Test-only escape hatch to simulate absence deterministically. */
56
+ ffprobeBin?: string;
57
+ }
58
+
59
+ const INSTALL_GUIDANCE = [
60
+ 'Install FFmpeg (which bundles both `ffmpeg` and `ffprobe`) and ensure it is on PATH:',
61
+ ' macOS: brew install ffmpeg',
62
+ ' Debian/Ubuntu: sudo apt-get update && sudo apt-get install -y ffmpeg',
63
+ ' Windows: choco install ffmpeg (or winget install Gyan.FFmpeg)',
64
+ ' Other/manual: https://ffmpeg.org/download.html',
65
+ 'Then verify with: ffmpeg -version && ffprobe -version',
66
+ ].join('\n');
67
+
68
+ function probe(
69
+ binary: FfmpegBinaryName,
70
+ command: string,
71
+ ): { command: string; version: string } | FfmpegCapabilityError {
72
+ let result: SpawnSyncReturns<string>;
73
+ try {
74
+ result = spawnSync(command, ['-version'], { encoding: 'utf-8' });
75
+ } catch (err) {
76
+ return notFoundError(binary, command, err);
77
+ }
78
+
79
+ // `spawnSync` reports a missing executable via `result.error` (ENOENT),
80
+ // not a thrown exception — check both that and a non-zero/`null` status
81
+ // (a `null` status means the process couldn't even start, e.g. denied
82
+ // permission on the resolved path).
83
+ if (result.error || result.status !== 0) {
84
+ return notFoundError(binary, command, result.error);
85
+ }
86
+
87
+ const firstLine = (result.stdout ?? '').split('\n')[0]?.trim() || `${command} (version unknown)`;
88
+ return { command, version: firstLine };
89
+ }
90
+
91
+ function notFoundError(
92
+ binary: FfmpegBinaryName,
93
+ command: string,
94
+ cause: unknown,
95
+ ): FfmpegCapabilityError {
96
+ const causeDetail = cause instanceof Error ? ` (${cause.message})` : '';
97
+ return {
98
+ code: binary === 'ffmpeg' ? 'FFMPEG_NOT_FOUND' : 'FFPROBE_NOT_FOUND',
99
+ binary,
100
+ command,
101
+ message:
102
+ `${binary} was not found on PATH${causeDetail}. Both ffmpeg and ffprobe are required ` +
103
+ 'system binaries for cinematic export (encode/mux) and §17 artifact verification ' +
104
+ '(duration/frame-count/A-V-sync checks via ffprobe).',
105
+ installGuidance: INSTALL_GUIDANCE,
106
+ };
107
+ }
108
+
109
+ /**
110
+ * Probe for both `ffmpeg` and `ffprobe` on PATH (or at the overridden
111
+ * command/path in `options`). Never throws — absence of either binary is
112
+ * reported as a structured `FfmpegCapabilityError`, not an exception.
113
+ *
114
+ * Both binaries are always probed (even if the first is missing) so a
115
+ * caller gets the complete picture in one call rather than discovering the
116
+ * second failure only after fixing the first.
117
+ */
118
+ export function checkFfmpegCapability(
119
+ options: CheckFfmpegCapabilityOptions = {},
120
+ ): FfmpegCapabilityResult {
121
+ const ffmpegCommand = options.ffmpegBin ?? 'ffmpeg';
122
+ const ffprobeCommand = options.ffprobeBin ?? 'ffprobe';
123
+
124
+ const ffmpeg = probe('ffmpeg', ffmpegCommand);
125
+ const ffprobe = probe('ffprobe', ffprobeCommand);
126
+
127
+ const errors: FfmpegCapabilityError[] = [];
128
+ if ('code' in ffmpeg) errors.push(ffmpeg);
129
+ if ('code' in ffprobe) errors.push(ffprobe);
130
+
131
+ if (errors.length > 0) return { ok: false, errors };
132
+
133
+ // TypeScript can't narrow `ffmpeg`/`ffprobe` from the `errors.length`
134
+ // check above, but the two pushes above guarantee both are the success
135
+ // shape here.
136
+ return {
137
+ ok: true,
138
+ ffmpeg: ffmpeg as { command: string; version: string },
139
+ ffprobe: ffprobe as { command: string; version: string },
140
+ };
141
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The render pipeline core (I0/I2-I8, A1) — relocated INTO `@vgai/sdk` so the
3
+ * dependency direction is CLI -> SDK -> engine, never SDK -> CLI (per
4
+ * `docs/AI-NATIVE-AUTHORING-IMPLEMENTATION-SPEC.md` §3.4: the SDK is the
5
+ * authoritative operation core; CLI/HTTP/MCP are projections on top of it).
6
+ * Formerly `packages/vgai-cli/src/render-cinematic.ts` +
7
+ * `packages/vgai-cli/src/capabilities/ffmpeg.ts`, imported by the SDK's own
8
+ * `cinematic.*` operations (`../cinematic/`) via a deep-src `@vgai/cli`
9
+ * tsconfig path alias — a package-layering inversion once B6 makes the CLI
10
+ * invoke SDK operations. This barrel is what lets `@vgai/cli` import the
11
+ * pipeline back FROM `@vgai/sdk`'s public entry point instead.
12
+ */
13
+
14
+ export * from './capabilities/ffmpeg.js';
15
+ export * from './render-cinematic.js';