@vivipilot/cli 0.1.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 (58) hide show
  1. package/README.md +57 -0
  2. package/dist/api.d.ts +86 -0
  3. package/dist/api.d.ts.map +1 -0
  4. package/dist/api.js +77 -0
  5. package/dist/api.js.map +1 -0
  6. package/dist/args.d.ts +11 -0
  7. package/dist/args.d.ts.map +1 -0
  8. package/dist/args.js +53 -0
  9. package/dist/args.js.map +1 -0
  10. package/dist/browser.d.ts +31 -0
  11. package/dist/browser.d.ts.map +1 -0
  12. package/dist/browser.js +162 -0
  13. package/dist/browser.js.map +1 -0
  14. package/dist/cli.d.ts +12 -0
  15. package/dist/cli.d.ts.map +1 -0
  16. package/dist/cli.js +536 -0
  17. package/dist/cli.js.map +1 -0
  18. package/dist/config.d.ts +15 -0
  19. package/dist/config.d.ts.map +1 -0
  20. package/dist/config.js +58 -0
  21. package/dist/config.js.map +1 -0
  22. package/dist/errors.d.ts +6 -0
  23. package/dist/errors.d.ts.map +1 -0
  24. package/dist/errors.js +12 -0
  25. package/dist/errors.js.map +1 -0
  26. package/dist/index.d.ts +7 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +7 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/manifest.d.ts +40 -0
  31. package/dist/manifest.d.ts.map +1 -0
  32. package/dist/manifest.js +90 -0
  33. package/dist/manifest.js.map +1 -0
  34. package/dist/mcp.d.ts +13 -0
  35. package/dist/mcp.d.ts.map +1 -0
  36. package/dist/mcp.js +392 -0
  37. package/dist/mcp.js.map +1 -0
  38. package/dist/render.d.ts +21 -0
  39. package/dist/render.d.ts.map +1 -0
  40. package/dist/render.js +369 -0
  41. package/dist/render.js.map +1 -0
  42. package/package.json +42 -0
  43. package/src/api.ts +163 -0
  44. package/src/args.test.ts +21 -0
  45. package/src/args.ts +64 -0
  46. package/src/browser.test.ts +103 -0
  47. package/src/browser.ts +174 -0
  48. package/src/cli.ts +656 -0
  49. package/src/config.test.ts +30 -0
  50. package/src/config.ts +71 -0
  51. package/src/errors.ts +14 -0
  52. package/src/index.ts +25 -0
  53. package/src/manifest.test.ts +105 -0
  54. package/src/manifest.ts +126 -0
  55. package/src/mcp.test.ts +48 -0
  56. package/src/mcp.ts +438 -0
  57. package/src/render.ts +424 -0
  58. package/tsconfig.json +26 -0
@@ -0,0 +1,6 @@
1
+ export declare class CliError extends Error {
2
+ readonly exitCode: number;
3
+ constructor(message: string, exitCode?: number);
4
+ }
5
+ export declare function isCliError(error: unknown): error is CliError;
6
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAI;CAK1C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D"}
package/dist/errors.js ADDED
@@ -0,0 +1,12 @@
1
+ export class CliError extends Error {
2
+ exitCode;
3
+ constructor(message, exitCode = 1) {
4
+ super(message);
5
+ this.name = "CliError";
6
+ this.exitCode = exitCode;
7
+ }
8
+ }
9
+ export function isCliError(error) {
10
+ return error instanceof CliError;
11
+ }
12
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,QAAQ,CAAS;IAE1B,YAAY,OAAe,EAAE,QAAQ,GAAG,CAAC;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,KAAK,YAAY,QAAQ,CAAC;AACnC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { parseArgv, flagBoolean, flagNumber, flagString, type ParsedArgs } from "./args.js";
2
+ export { DEFAULT_API_URL, defaultConfigPath, deleteConfig, readConfig, resolveApiKey, resolveApiUrl, resolvePublicKeys, writeConfig, type CliConfig, type Env, } from "./config.js";
3
+ export { VivipilotApiClient, type BalanceResponse, type EstimateRequest, type EstimateResponse, type GenerateRequest, type GenerateResponse, type StatusResponse, } from "./api.js";
4
+ export { readManifestFile, verifyManifestFile } from "./manifest.js";
5
+ export { startMcpServer, type McpServerOptions } from "./mcp.js";
6
+ export { CliError, isCliError } from "./errors.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5F,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,KAAK,SAAS,EACd,KAAK,GAAG,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { parseArgv, flagBoolean, flagNumber, flagString } from "./args.js";
2
+ export { DEFAULT_API_URL, defaultConfigPath, deleteConfig, readConfig, resolveApiKey, resolveApiUrl, resolvePublicKeys, writeConfig, } from "./config.js";
3
+ export { VivipilotApiClient, } from "./api.js";
4
+ export { readManifestFile, verifyManifestFile } from "./manifest.js";
5
+ export { startMcpServer } from "./mcp.js";
6
+ export { CliError, isCliError } from "./errors.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,WAAW,CAAC;AAC5F,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,WAAW,GAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,GAOnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,cAAc,EAAyB,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { type RenderManifestVerificationResult, type VivipilotRenderManifestV1 } from "@vivipilot/render-manifest";
2
+ import { type CliConfig, type Env } from "./config.js";
3
+ export declare function readManifestFile(path: string): Promise<unknown>;
4
+ export declare function verifyManifestFile(path: string, config: CliConfig, env?: Env): Promise<RenderManifestVerificationResult>;
5
+ /**
6
+ * Best-effort online revocation check. Calls
7
+ * `GET /api/v1/manifests/{manifestId}/revocation`. Returns `revoked: false`
8
+ * when the network is unavailable or the endpoint errors — the offline
9
+ * cryptographic signature verification remains authoritative.
10
+ *
11
+ * Pass `apiKey` to authenticate the request. When no key is configured the
12
+ * check is skipped (offline mode).
13
+ */
14
+ export declare function checkManifestRevocationOnline(manifest: VivipilotRenderManifestV1, config: CliConfig, env?: Env, fetchImpl?: typeof fetch): Promise<{
15
+ revoked: boolean;
16
+ revokedAt: number | null;
17
+ checked: boolean;
18
+ error?: string;
19
+ }>;
20
+ export declare function assertNotRevoked(result: {
21
+ revoked: boolean;
22
+ checked: boolean;
23
+ revokedAt?: number | null;
24
+ error?: string;
25
+ }): void;
26
+ export type RenderEntitlementRequest = {
27
+ format?: "mp4" | "webm" | "gif" | "mov";
28
+ width?: number;
29
+ height?: number;
30
+ };
31
+ export type RenderEntitlementViolation = {
32
+ ok: false;
33
+ reason: "resolution_exceeds_entitlement" | "format_not_allowed";
34
+ message: string;
35
+ };
36
+ export type RenderEntitlementResult = {
37
+ ok: true;
38
+ } | RenderEntitlementViolation;
39
+ export declare function checkRenderEntitlement(manifest: VivipilotRenderManifestV1, request: RenderEntitlementRequest): RenderEntitlementResult;
40
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,gCAAgC,EACrC,KAAK,yBAAyB,EAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAAmD,MAAM,aAAa,CAAC;AAGxG,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAErE;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,GAAE,GAAiB,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAK3I;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CACjD,QAAQ,EAAE,yBAAyB,EACnC,MAAM,EAAE,SAAS,EACjB,GAAG,GAAE,GAAiB,EACtB,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAgC3F;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAIhI;AASD,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAAE,gCAAgC,GAAG,oBAAoB,CAAC;IAChE,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GACZ,0BAA0B,CAAC;AAE/B,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,yBAAyB,EACnC,OAAO,EAAE,wBAAwB,GAChC,uBAAuB,CAsBzB"}
@@ -0,0 +1,90 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { verifyRenderManifest, } from "@vivipilot/render-manifest";
3
+ import { resolveApiUrl, resolveApiKey, resolvePublicKeys } from "./config.js";
4
+ import { CliError } from "./errors.js";
5
+ export async function readManifestFile(path) {
6
+ return JSON.parse(await readFile(path, "utf8"));
7
+ }
8
+ export async function verifyManifestFile(path, config, env = process.env) {
9
+ const manifest = await readManifestFile(path);
10
+ return verifyRenderManifest(manifest, {
11
+ publicKeys: resolvePublicKeys(config, env),
12
+ });
13
+ }
14
+ /**
15
+ * Best-effort online revocation check. Calls
16
+ * `GET /api/v1/manifests/{manifestId}/revocation`. Returns `revoked: false`
17
+ * when the network is unavailable or the endpoint errors — the offline
18
+ * cryptographic signature verification remains authoritative.
19
+ *
20
+ * Pass `apiKey` to authenticate the request. When no key is configured the
21
+ * check is skipped (offline mode).
22
+ */
23
+ export async function checkManifestRevocationOnline(manifest, config, env = process.env, fetchImpl = fetch) {
24
+ const apiKey = resolveApiKey(config, env);
25
+ if (!apiKey)
26
+ return { revoked: false, revokedAt: null, checked: false, error: "no_api_key" };
27
+ const apiUrl = resolveApiUrl(config, env);
28
+ const url = `${apiUrl}/api/v1/manifests/${encodeURIComponent(manifest.manifestId)}/revocation`;
29
+ const controller = new AbortController();
30
+ const timeout = setTimeout(() => controller.abort(), 5_000);
31
+ try {
32
+ const response = await fetchImpl(url, {
33
+ headers: { authorization: `Bearer ${apiKey}` },
34
+ signal: controller.signal,
35
+ });
36
+ if (!response.ok) {
37
+ return { revoked: false, revokedAt: null, checked: false, error: `http_${response.status}` };
38
+ }
39
+ const payload = await response.json();
40
+ return {
41
+ revoked: payload.revoked === true,
42
+ revokedAt: payload.revokedAt ?? null,
43
+ checked: true,
44
+ };
45
+ }
46
+ catch (error) {
47
+ return {
48
+ revoked: false,
49
+ revokedAt: null,
50
+ checked: false,
51
+ error: error instanceof Error ? error.message : String(error),
52
+ };
53
+ }
54
+ finally {
55
+ clearTimeout(timeout);
56
+ }
57
+ }
58
+ export function assertNotRevoked(result) {
59
+ if (result.checked && result.revoked) {
60
+ throw new CliError(`Manifest has been revoked server-side${result.revokedAt ? ` at ${new Date(result.revokedAt).toISOString()}` : ""}. Generate a new manifest with \`vivipilot generate\`.`, 1);
61
+ }
62
+ }
63
+ const RESOLUTION_HEIGHT_CEILINGS = {
64
+ "720p": 720,
65
+ "1080p": 1080,
66
+ "2k": 1440,
67
+ "4k": 2160,
68
+ };
69
+ export function checkRenderEntitlement(manifest, request) {
70
+ const maxCeiling = RESOLUTION_HEIGHT_CEILINGS[manifest.entitlement.maxResolution];
71
+ const requestedHeight = request.height ?? manifest.render.canvas.height;
72
+ if (requestedHeight > maxCeiling) {
73
+ return {
74
+ ok: false,
75
+ reason: "resolution_exceeds_entitlement",
76
+ message: `Requested height ${requestedHeight}px exceeds the manifest entitlement (${manifest.entitlement.maxResolution}, max ${maxCeiling}px). Top up or generate a higher-entitlement manifest.`,
77
+ };
78
+ }
79
+ if (request.format && Array.isArray(manifest.entitlement.allowedFormats) && manifest.entitlement.allowedFormats.length > 0) {
80
+ if (!manifest.entitlement.allowedFormats.includes(request.format)) {
81
+ return {
82
+ ok: false,
83
+ reason: "format_not_allowed",
84
+ message: `Format ${request.format} is not allowed by this manifest entitlement. Allowed: ${manifest.entitlement.allowedFormats.join(", ")}.`,
85
+ };
86
+ }
87
+ }
88
+ return { ok: true };
89
+ }
90
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACL,oBAAoB,GAIrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAA4B,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAY;IACjD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAY,CAAC;AAC7D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY,EAAE,MAAiB,EAAE,MAAW,OAAO,CAAC,GAAG;IAC9F,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,o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EAAE,EAAE,KAAK;YACT,MAAM,EAAE,gCAAgC;YACxC,OAAO,EAAE,oBAAoB,eAAe,wCAAwC,QAAQ,CAAC,WAAW,CAAC,aAAa,SAAS,UAAU,wDAAwD;SAClM,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,QAAQ,CAAC,WAAW,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3H,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClE,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,MAAM,EAAE,oBAAoB;gBAC5B,OAAO,EAAE,UAAU,OAAO,CAAC,MAAM,0DAA0D,QAAQ,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;aAC7I,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { type CliConfig, type Env } from "./config.js";
2
+ type StdioLike = {
3
+ stdin: NodeJS.ReadableStream;
4
+ stdout: NodeJS.WritableStream;
5
+ stderr: NodeJS.WritableStream;
6
+ };
7
+ export type McpServerOptions = {
8
+ config: CliConfig;
9
+ env?: Env;
10
+ } & StdioLike;
11
+ export declare function startMcpServer(options: McpServerOptions): Promise<void>;
12
+ export {};
13
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAAiB,MAAM,aAAa,CAAC;AAEtE,KAAK,SAAS,GAAG;IACf,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;CAC/B,CAAC;AAgBF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,SAAS,CAAC;IAClB,GAAG,CAAC,EAAE,GAAG,CAAC;CACX,GAAG,SAAS,CAAC;AA8Vd,wBAAsB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyD7E"}
package/dist/mcp.js ADDED
@@ -0,0 +1,392 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import { dirname } from "node:path";
3
+ import { createInterface } from "node:readline";
4
+ import { randomUUID } from "node:crypto";
5
+ import { VivipilotApiClient } from "./api.js";
6
+ import { resolveApiUrl } from "./config.js";
7
+ const PROTOCOL_VERSION = "2025-06-18";
8
+ function isRecord(value) {
9
+ return typeof value === "object" && value !== null && !Array.isArray(value);
10
+ }
11
+ function optionalNumber(args, key) {
12
+ const value = args[key];
13
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
14
+ }
15
+ function optionalString(args, key) {
16
+ const value = args[key];
17
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
18
+ }
19
+ function estimateRequestFromToolArgs(args) {
20
+ const prompt = optionalString(args, "prompt");
21
+ if (!prompt)
22
+ throw new Error("prompt is required");
23
+ const engine = optionalString(args, "engine");
24
+ const enginePreference = engine === "pixi" || engine === "three" || engine === "auto" ? engine : undefined;
25
+ const width = optionalNumber(args, "width");
26
+ const height = optionalNumber(args, "height");
27
+ const fps = optionalNumber(args, "fps");
28
+ const durationSeconds = optionalNumber(args, "durationSeconds") ?? optionalNumber(args, "duration");
29
+ return {
30
+ prompt,
31
+ ...(width || height || fps ? { canvas: { width, height, fps } } : {}),
32
+ ...(durationSeconds ? { durationSeconds } : {}),
33
+ ...(enginePreference ? { enginePreference } : {}),
34
+ };
35
+ }
36
+ function jsonToolResult(value, isError = false) {
37
+ return {
38
+ content: [{ type: "text", text: JSON.stringify(value, null, 2) }],
39
+ structuredContent: value,
40
+ isError,
41
+ };
42
+ }
43
+ function toolError(error) {
44
+ const message = error instanceof Error ? error.message : String(error);
45
+ return jsonToolResult({ ok: false, error: message }, true);
46
+ }
47
+ async function writeJsonFile(path, value) {
48
+ await mkdir(dirname(path), { recursive: true });
49
+ await writeFile(path, `${JSON.stringify(value, null, 2)}\n`, "utf8");
50
+ }
51
+ async function verifyLocalManifest(manifestPath, config, env) {
52
+ const { verifyManifestFile } = await import("./manifest.js");
53
+ return verifyManifestFile(manifestPath, config, env);
54
+ }
55
+ function tools() {
56
+ return [
57
+ {
58
+ name: "vivipilot_get_balance",
59
+ title: "Get Vivipilot paid credit balance",
60
+ description: "Returns Vivipilot account balance and paid top-up balance. CLI/MCP generation is paid-only and never grants trial credits.",
61
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
62
+ },
63
+ {
64
+ name: "vivipilot_estimate_motion_layout",
65
+ title: "Estimate Vivipilot motion layout credits",
66
+ description: "Estimates paid credits for a cloud layout generation. This does not burn credits.",
67
+ inputSchema: {
68
+ type: "object",
69
+ properties: {
70
+ prompt: { type: "string" },
71
+ width: { type: "number" },
72
+ height: { type: "number" },
73
+ fps: { type: "number" },
74
+ durationSeconds: { type: "number" },
75
+ engine: { type: "string", enum: ["pixi", "three", "auto"] },
76
+ },
77
+ required: ["prompt"],
78
+ additionalProperties: false,
79
+ },
80
+ },
81
+ {
82
+ name: "vivipilot_generate_motion_layout",
83
+ title: "Generate signed Vivipilot render manifest",
84
+ description: "Paid-only cloud generation. Burns paid credits only after cloud orchestration is wired; local rendering uses the client's hardware.",
85
+ inputSchema: {
86
+ type: "object",
87
+ properties: {
88
+ prompt: { type: "string" },
89
+ out: { type: "string" },
90
+ idempotencyKey: { type: "string" },
91
+ width: { type: "number" },
92
+ height: { type: "number" },
93
+ fps: { type: "number" },
94
+ durationSeconds: { type: "number" },
95
+ engine: { type: "string", enum: ["pixi", "three", "auto"] },
96
+ },
97
+ required: ["prompt"],
98
+ additionalProperties: false,
99
+ },
100
+ },
101
+ {
102
+ name: "vivipilot_verify_manifest",
103
+ title: "Verify Vivipilot render manifest",
104
+ description: "Verifies a signed Vivipilot manifest locally using public keys. This does not burn credits.",
105
+ inputSchema: {
106
+ type: "object",
107
+ properties: { manifestPath: { type: "string" } },
108
+ required: ["manifestPath"],
109
+ additionalProperties: false,
110
+ },
111
+ },
112
+ {
113
+ name: "vivipilot_render_video",
114
+ title: "Render Vivipilot video locally",
115
+ description: "Renders a signed manifest on local hardware after signature verification. No cloud rendering is used.",
116
+ inputSchema: {
117
+ type: "object",
118
+ properties: {
119
+ manifestPath: { type: "string" },
120
+ out: { type: "string" },
121
+ verifyOnly: { type: "boolean" },
122
+ },
123
+ required: ["manifestPath"],
124
+ additionalProperties: false,
125
+ },
126
+ },
127
+ {
128
+ name: "vivipilot_get_generation_status",
129
+ title: "Get Vivipilot generation status",
130
+ description: "Checks cloud status for a Vivipilot layout generation. This does not burn credits.",
131
+ inputSchema: {
132
+ type: "object",
133
+ properties: { generationId: { type: "string" } },
134
+ required: ["generationId"],
135
+ additionalProperties: false,
136
+ },
137
+ },
138
+ ];
139
+ }
140
+ async function callTool(name, args, client, config, env) {
141
+ const toolArgs = isRecord(args) ? args : {};
142
+ try {
143
+ switch (name) {
144
+ case "vivipilot_get_balance": {
145
+ const balance = await client.balance();
146
+ const paidBalance = typeof balance.paidBalance === "number" ? balance.paidBalance : 0;
147
+ const nextActions = paidBalance > 0
148
+ ? [
149
+ { tool: "vivipilot_estimate_motion_layout", reason: "Estimate credits for a generation before spending." },
150
+ { tool: "vivipilot_generate_motion_layout", reason: "Generate a signed manifest (paid credits will be burned)." },
151
+ ]
152
+ : [
153
+ { action: "topup", reason: `Buy credits at ${resolveApiUrl(config, env)}/edit?billing=topup before generating. CLI/MCP generation is paid-only.` },
154
+ ];
155
+ return jsonToolResult({ ok: true, ...balance, nextActions });
156
+ }
157
+ case "vivipilot_estimate_motion_layout": {
158
+ const estimate = await client.estimate(estimateRequestFromToolArgs(toolArgs));
159
+ const estimatedCredits = typeof estimate.estimatedCredits === "number" ? estimate.estimatedCredits : 0;
160
+ return jsonToolResult({
161
+ ok: true,
162
+ ...estimate,
163
+ nextActions: [
164
+ { tool: "vivipilot_generate_motion_layout", reason: `Generate now for ~${estimatedCredits} credits (paid-only).` },
165
+ { tool: "vivipilot_get_balance", reason: "Check balance before generating." },
166
+ ],
167
+ });
168
+ }
169
+ case "vivipilot_generate_motion_layout": {
170
+ const out = optionalString(toolArgs, "out") ?? "scene.vivi.json";
171
+ const idempotencyKey = optionalString(toolArgs, "idempotencyKey") ?? `mcp_${randomUUID()}`;
172
+ const request = estimateRequestFromToolArgs(toolArgs);
173
+ // Use async start + poll for progress visibility
174
+ const startResult = await client.startGenerate({ ...request, outputFormat: "manifest" }, idempotencyKey);
175
+ const generationId = startResult.generationId;
176
+ // If already completed (idempotent replay), fetch manifest
177
+ if (startResult.idempotentReplay && startResult.status === "completed") {
178
+ const status = await client.generationProgress(generationId);
179
+ if (status.manifestData) {
180
+ await writeJsonFile(out, status.manifestData);
181
+ return jsonToolResult({
182
+ ok: true,
183
+ generationId,
184
+ manifestPath: out,
185
+ creditsCharged: status.creditsCharged ?? null,
186
+ status: "completed",
187
+ nextActions: [
188
+ { tool: "vivipilot_verify_manifest", args: { manifestPath: out }, reason: "Verify the signed manifest locally before rendering." },
189
+ { tool: "vivipilot_render_video", args: { manifestPath: out }, reason: "Render the manifest to video on local hardware." },
190
+ ],
191
+ });
192
+ }
193
+ }
194
+ // Poll until terminal
195
+ const maxWaitMs = 300_000;
196
+ const pollInterval = 2000;
197
+ const startTime = Date.now();
198
+ let lastProgress = "";
199
+ while (Date.now() - startTime < maxWaitMs) {
200
+ await new Promise((r) => setTimeout(r, pollInterval));
201
+ let status;
202
+ try {
203
+ status = await client.generationProgress(generationId);
204
+ }
205
+ catch {
206
+ continue;
207
+ }
208
+ if (status.progressMessage && status.progressMessage !== lastProgress) {
209
+ lastProgress = status.progressMessage;
210
+ }
211
+ if (status.status === "completed" && status.manifestData) {
212
+ await writeJsonFile(out, status.manifestData);
213
+ return jsonToolResult({
214
+ ok: true,
215
+ generationId,
216
+ manifestPath: out,
217
+ creditsCharged: status.creditsCharged ?? null,
218
+ engine: status.engine,
219
+ status: "completed",
220
+ progressLog: lastProgress,
221
+ nextActions: [
222
+ { tool: "vivipilot_verify_manifest", args: { manifestPath: out }, reason: "Verify the signed manifest locally before rendering." },
223
+ { tool: "vivipilot_render_video", args: { manifestPath: out }, reason: "Render the manifest to video on local hardware." },
224
+ ],
225
+ });
226
+ }
227
+ if (status.status === "failed") {
228
+ return jsonToolResult({
229
+ ok: false,
230
+ generationId,
231
+ error: status.error ?? "Generation failed.",
232
+ progressLog: lastProgress,
233
+ nextActions: [
234
+ { tool: "vivipilot_generate_motion_layout", reason: "Retry with a new prompt or idempotency key." },
235
+ { tool: "vivipilot_get_balance", reason: "Check balance before retrying." },
236
+ ],
237
+ }, true);
238
+ }
239
+ }
240
+ return jsonToolResult({
241
+ ok: false,
242
+ generationId,
243
+ error: "Generation timed out after 5 minutes.",
244
+ nextActions: [
245
+ { tool: "vivipilot_get_generation_status", args: { generationId }, reason: "Check if generation completed after timeout." },
246
+ ],
247
+ }, true);
248
+ }
249
+ case "vivipilot_verify_manifest": {
250
+ const manifestPath = optionalString(toolArgs, "manifestPath");
251
+ if (!manifestPath)
252
+ throw new Error("manifestPath is required");
253
+ const result = await verifyLocalManifest(manifestPath, config, env);
254
+ if (!result.ok)
255
+ throw new Error(result.message);
256
+ return jsonToolResult({
257
+ ok: true,
258
+ manifestId: result.manifest.manifestId,
259
+ generationId: result.manifest.generationId,
260
+ canonicalPayloadHash: result.canonicalPayloadHash,
261
+ nextActions: [
262
+ { tool: "vivipilot_render_video", args: { manifestPath }, reason: "Render the verified manifest to video." },
263
+ ],
264
+ });
265
+ }
266
+ case "vivipilot_render_video": {
267
+ const manifestPath = optionalString(toolArgs, "manifestPath");
268
+ if (!manifestPath)
269
+ throw new Error("manifestPath is required");
270
+ const out = optionalString(toolArgs, "out") ?? "video.mp4";
271
+ const format = optionalString(toolArgs, "format");
272
+ const scale = optionalNumber(toolArgs, "scale");
273
+ const fps = optionalNumber(toolArgs, "fps");
274
+ const transparent = toolArgs.transparent === true;
275
+ const verifyOnly = toolArgs.verifyOnly === true;
276
+ const { renderManifest } = await import("./render.js");
277
+ const result = await renderManifest({
278
+ manifestPath,
279
+ outPath: out,
280
+ ...(format ? { format } : {}),
281
+ ...(scale ? { scale } : {}),
282
+ ...(fps ? { fps } : {}),
283
+ ...(transparent ? { transparent } : {}),
284
+ verifyOnly,
285
+ }, config, env);
286
+ return jsonToolResult({
287
+ ok: true,
288
+ manifestId: result.manifestId,
289
+ out: result.outPath,
290
+ size: result.size,
291
+ nextActions: [
292
+ { action: "file_ready", reason: `Video written to ${result.outPath} (${(result.size / 1024 / 1024).toFixed(2)} MB).` },
293
+ ],
294
+ });
295
+ }
296
+ case "vivipilot_get_generation_status": {
297
+ const generationId = optionalString(toolArgs, "generationId");
298
+ if (!generationId)
299
+ throw new Error("generationId is required");
300
+ const status = await client.generationProgress(generationId);
301
+ const nextActions = [];
302
+ if (status.status === "completed" && status.manifest) {
303
+ nextActions.push({ tool: "vivipilot_verify_manifest", reason: "Verify the completed manifest." });
304
+ nextActions.push({ tool: "vivipilot_render_video", reason: "Render the completed manifest to video." });
305
+ }
306
+ else if (status.status === "failed") {
307
+ nextActions.push({ tool: "vivipilot_generate_motion_layout", reason: "Retry with a new idempotency key." });
308
+ nextActions.push({ tool: "vivipilot_get_balance", reason: "Check balance before retrying." });
309
+ }
310
+ else {
311
+ nextActions.push({ tool: "vivipilot_get_generation_status", args: { generationId }, reason: "Poll again — generation still in progress." });
312
+ }
313
+ return jsonToolResult({ ok: true, ...status, nextActions });
314
+ }
315
+ default:
316
+ throw new Error(`Unknown tool: ${name}`);
317
+ }
318
+ }
319
+ catch (error) {
320
+ return toolError(error);
321
+ }
322
+ }
323
+ function send(stdout, message) {
324
+ stdout.write(`${JSON.stringify(message)}\n`);
325
+ }
326
+ function sendResult(stdout, id, result) {
327
+ send(stdout, { jsonrpc: "2.0", id, result });
328
+ }
329
+ function sendError(stdout, id, code, message) {
330
+ send(stdout, { jsonrpc: "2.0", id: id ?? null, error: { code, message } });
331
+ }
332
+ export async function startMcpServer(options) {
333
+ const env = options.env ?? process.env;
334
+ const client = new VivipilotApiClient({ config: options.config, env });
335
+ const lines = createInterface({ input: options.stdin });
336
+ for await (const line of lines) {
337
+ const trimmed = line.trim();
338
+ if (!trimmed)
339
+ continue;
340
+ let message;
341
+ try {
342
+ message = JSON.parse(trimmed);
343
+ }
344
+ catch {
345
+ sendError(options.stdout, null, -32700, "Parse error");
346
+ continue;
347
+ }
348
+ const id = message.id;
349
+ try {
350
+ switch (message.method) {
351
+ case "initialize":
352
+ sendResult(options.stdout, id ?? null, {
353
+ protocolVersion: PROTOCOL_VERSION,
354
+ capabilities: { tools: { listChanged: false } },
355
+ serverInfo: {
356
+ name: "vivipilot",
357
+ title: "Vivipilot MCP",
358
+ version: "0.1.0",
359
+ },
360
+ instructions: "Vivipilot generation tools are paid-only and require VIVIPILOT_API_KEY or `vivipilot login` configuration. Local render tools use the client's hardware.",
361
+ });
362
+ break;
363
+ case "notifications/initialized":
364
+ break;
365
+ case "ping":
366
+ sendResult(options.stdout, id ?? null, {});
367
+ break;
368
+ case "tools/list":
369
+ sendResult(options.stdout, id ?? null, { tools: tools() });
370
+ break;
371
+ case "tools/call": {
372
+ if (!isRecord(message.params) || typeof message.params.name !== "string") {
373
+ sendError(options.stdout, id, -32602, "tools/call requires params.name");
374
+ break;
375
+ }
376
+ const result = await callTool(message.params.name, message.params.arguments, client, options.config, env);
377
+ sendResult(options.stdout, id ?? null, result);
378
+ break;
379
+ }
380
+ default:
381
+ if (id !== undefined)
382
+ sendError(options.stdout, id, -32601, `Method not found: ${message.method ?? ""}`);
383
+ }
384
+ }
385
+ catch (error) {
386
+ const messageText = error instanceof Error ? error.message : String(error);
387
+ if (id !== undefined)
388
+ sendError(options.stdout, id, -32603, messageText);
389
+ }
390
+ }
391
+ }
392
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAwB,MAAM,UAAU,CAAC;AACpE,OAAO,EAA4B,aAAa,EAAE,MAAM,aAAa,CAAC;AA2BtE,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAEtC,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,cAAc,CAAC,IAA6B,EAAE,GAAW;IAChE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC;AAED,SAAS,cAAc,CAAC,IAA6B,EAAE,GAAW;IAChE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC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