mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* feat(cli): define every command through one factory and test them all as an agent Every command now comes from defineCommand in utils/defineCommand.ts. A lint rule bans importing defineCommand from citty anywhere else, and a new contract test walks the command registry in cli.ts, checks each command was built by the factory, and runs it the way a coding agent does: no terminal, stdin closed, CI=1, CLAUDECODE=1 and a home folder of its own. Usage errors now exit 2: unknown flags, extra positionals, and citty's own parse errors (missing argument, bad value, unknown or missing subcommand). An unknown flag names the help command instead of printing nothing else. isUnattended() in utils/attendedTerminal.ts is the one answer to "can a person respond here". It is true without a TTY on stdin or stdout, under CI (any value except "false" or "0"), when the existing agent detection finds an agent, or with HYPERFRAMES_AGENT=1. Color is off when it is true. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(cli): spawn preview in the agent-mode test only when the studio packages are built From source, preview refuses to load until the studio workspace packages are built, and the CLI test jobs do not build them. preview is still checked for being defined with the shared factory. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(cli): count only agent-run shells as unattended, and exit 2 for missing arguments isUnattended() used the telemetry fingerprint detectAgentRuntime(), which also matches a person typing in Cursor's or Windsurf's terminal (TERM_PROGRAM) and any Replit shell (REPL_ID, REPLIT_USER). It now uses isAgentDriven(), which keeps only markers an agent sets on the shells it runs: CURSOR_AGENT counts, TERM_PROGRAM=cursor, TERM_PROGRAM=windsurf and the Replit variables do not. The hand-written argument checks in lambda, cloudrun, lambda policies, capture, remove-background, init (--resolution), tts (--lang) and cloud render (--idempotency-key, --dry-run) exited 1. They are usage errors and now exit 2. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
71 lines
2.9 KiB
TypeScript
71 lines
2.9 KiB
TypeScript
/**
|
|
* `hyperframes cloud` — top-level dispatcher for cloud-render subverbs.
|
|
*
|
|
* Each subverb lives in `./cloud/<name>.ts`. The dispatcher loads them
|
|
* dynamically so the cloud surface doesn't impact CLI cold-start when
|
|
* the user is running `render` / `preview` / etc.
|
|
*
|
|
* Auth is the existing `cli/src/auth/` chain — `cloud` subverbs call
|
|
* into `cloud/auth.ts` which bridges `resolveCredential` +
|
|
* `buildAuthHeaders` into the generated client. There is no new
|
|
* credentials store and no new env var.
|
|
*/
|
|
|
|
import { defineCommand } from "../utils/defineCommand.js";
|
|
import type { Example } from "./_examples.js";
|
|
import { c } from "../ui/colors.js";
|
|
|
|
export const examples: Example[] = [
|
|
["Render the current directory in the cloud", "hyperframes cloud render"],
|
|
["Render a specific project", "hyperframes cloud render ./my-video"],
|
|
["Inspect the project zip without uploading", "hyperframes cloud render --dry-run"],
|
|
[
|
|
"Render at 60fps + high quality, save to a path",
|
|
"hyperframes cloud render ./my-video --fps 60 --quality high -o ./out.mp4",
|
|
],
|
|
[
|
|
"Fire-and-forget with a webhook",
|
|
"hyperframes cloud render ./my-video --callback-url https://example.com/hf-hook --no-wait",
|
|
],
|
|
["Resubmit an already-uploaded zip", "hyperframes cloud render --asset-id asst_abc123"],
|
|
[
|
|
"Render from a public HTTPS zip",
|
|
"hyperframes cloud render --url https://cdn.example.com/site.zip",
|
|
],
|
|
["List recent cloud renders", "hyperframes cloud list"],
|
|
["Fetch one render's status + signed URLs", "hyperframes cloud get hfr_abc123"],
|
|
["Soft-delete a render", "hyperframes cloud delete hfr_abc123"],
|
|
];
|
|
|
|
const HELP = `
|
|
${c.bold("hyperframes cloud")} ${c.dim("<subcommand> [args]")}
|
|
|
|
Render HyperFrames compositions on HeyGen's cloud infrastructure. The
|
|
project zip is uploaded, the render is dispatched, and the resulting
|
|
video is downloaded locally — without spinning up Chrome or ffmpeg
|
|
on your machine.
|
|
|
|
${c.bold("SUBCOMMANDS:")}
|
|
${c.accent("render")} ${c.dim("Submit a project (or asset_id / url) and download the result")}
|
|
${c.accent("list")} ${c.dim("List recent renders in your account")}
|
|
${c.accent("get")} ${c.dim("Fetch one render's status + signed URLs")}
|
|
${c.accent("delete")} ${c.dim("Soft-delete a render (GET 404s afterward)")}
|
|
|
|
${c.bold("AUTH:")}
|
|
Uses the credential you signed in with via ${c.accent("hyperframes auth login")}.
|
|
Override the API base with ${c.accent("HEYGEN_API_URL")} (default https://api.heygen.com).
|
|
`;
|
|
|
|
export default defineCommand({
|
|
meta: { name: "cloud", description: "Render HyperFrames compositions on the HeyGen cloud" },
|
|
subCommands: {
|
|
render: () => import("./cloud/render.js").then((m) => m.default),
|
|
list: () => import("./cloud/list.js").then((m) => m.default),
|
|
get: () => import("./cloud/get.js").then((m) => m.default),
|
|
delete: () => import("./cloud/delete.js").then((m) => m.default),
|
|
},
|
|
async run({ args }) {
|
|
if (!args._?.[0]) console.log(HELP);
|
|
},
|
|
});
|