@program-video/cli 0.1.10 → 0.1.12
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.
- package/dist/index.js +1062 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/commands/auth/login.ts","../src/lib/auth/credentials.ts","../src/lib/auth/device.ts","../src/lib/config.ts","../src/lib/output.ts","../src/commands/auth/logout.ts","../src/commands/auth/status.ts","../src/commands/project/create.ts","../src/lib/auth/oauth.ts","../src/lib/convex.ts","../src/commands/project/get.ts","../src/commands/project/list.ts","../src/commands/workflow/list.ts","../src/commands/workflow/run.ts","../src/commands/workflow/status.ts","../src/commands/tool/execute.ts","../src/lib/agent-detect.ts","../src/commands/tool/list.ts","../src/commands/message/send.ts","../src/commands/message/list.ts","../src/commands/docs.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { createRequire } from \"node:module\";\nimport { loginCommand } from \"./commands/auth/login.js\";\nimport type { LoginOptions } from \"./commands/auth/login.js\";\nimport { logoutCommand } from \"./commands/auth/logout.js\";\nimport type { LogoutOptions } from \"./commands/auth/logout.js\";\nimport { statusCommand as authStatusCommand } from \"./commands/auth/status.js\";\nimport type { StatusOptions as AuthStatusOptions } from \"./commands/auth/status.js\";\nimport { createCommand as projectCreateCommand } from \"./commands/project/create.js\";\nimport type { CreateOptions } from \"./commands/project/create.js\";\nimport { getCommand as projectGetCommand } from \"./commands/project/get.js\";\nimport type { GetOptions } from \"./commands/project/get.js\";\nimport { listCommand as projectListCommand } from \"./commands/project/list.js\";\nimport type { ListOptions as ProjectListOptions } from \"./commands/project/list.js\";\nimport { listCommand as workflowListCommand } from \"./commands/workflow/list.js\";\nimport type { ListOptions as WorkflowListOptions } from \"./commands/workflow/list.js\";\nimport { runCommand as workflowRunCommand } from \"./commands/workflow/run.js\";\nimport type { RunOptions } from \"./commands/workflow/run.js\";\nimport { statusCommand as workflowStatusCommand } from \"./commands/workflow/status.js\";\nimport type { StatusOptions as WorkflowStatusOptions } from \"./commands/workflow/status.js\";\nimport { executeCommand as toolExecuteCommand } from \"./commands/tool/execute.js\";\nimport type { ExecuteOptions } from \"./commands/tool/execute.js\";\nimport { listCommand as toolListCommand } from \"./commands/tool/list.js\";\nimport type { ListOptions as ToolListOptions } from \"./commands/tool/list.js\";\nimport { sendCommand as messageSendCommand } from \"./commands/message/send.js\";\nimport type { SendMessageOptions } from \"./commands/message/send.js\";\nimport { listCommand as messageListCommand } from \"./commands/message/list.js\";\nimport type { ListMessageOptions } from \"./commands/message/list.js\";\nimport { docsCommand } from \"./commands/docs.js\";\nimport type { DocsOptions } from \"./commands/docs.js\";\n\nconst program = new Command();\nconst require = createRequire(import.meta.url);\nconst packageJson = require(\"../package.json\") as { version: string };\n\nprogram\n .name(\"program\")\n .description(\"CLI for the Program video creation platform\")\n .version(packageJson.version);\n\n// Auth commands\nconst auth = program.command(\"auth\").description(\"Authentication commands\");\n\nauth\n .command(\"login\")\n .description(\"Authenticate with the Program platform\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: LoginOptions) => {\n await loginCommand(options);\n });\n\nauth\n .command(\"logout\")\n .description(\"Log out from the Program platform\")\n .option(\"--json\", \"Output as JSON\")\n .action((options: LogoutOptions) => {\n logoutCommand(options);\n });\n\nauth\n .command(\"status\")\n .description(\"Check authentication status\")\n .option(\"--json\", \"Output as JSON\")\n .action((options: AuthStatusOptions) => {\n authStatusCommand(options);\n });\n\n// Project commands\nconst project = program.command(\"project\").description(\"Project management commands\");\n\nproject\n .command(\"create\")\n .description(\"Create a new project\")\n .option(\"--title <title>\", \"Project title\")\n .option(\"--description <description>\", \"Project description\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: CreateOptions) => {\n await projectCreateCommand(options);\n });\n\nproject\n .command(\"list\")\n .description(\"List projects\")\n .option(\"--limit <limit>\", \"Maximum number of projects to return\", parseInt)\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: ProjectListOptions) => {\n await projectListCommand(options);\n });\n\nproject\n .command(\"get <id>\")\n .description(\"Get project details including composition\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (id: string, options: GetOptions) => {\n await projectGetCommand(id, options);\n });\n\n// Workflow commands\nconst workflow = program.command(\"workflow\").description(\"Workflow template commands\");\n\nworkflow\n .command(\"list\")\n .description(\"List available workflow templates\")\n .option(\"--limit <limit>\", \"Maximum number of templates to return\", parseInt)\n .option(\"--public-only\", \"Only show public templates\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: WorkflowListOptions) => {\n await workflowListCommand(options);\n });\n\nworkflow\n .command(\"run <templateId>\")\n .description(\"Execute a workflow template\")\n .option(\"--project <projectId>\", \"Project ID to associate with execution\")\n .option(\"--input <json>\", \"JSON input for the workflow\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (templateId: string, options: RunOptions) => {\n await workflowRunCommand(templateId, options);\n });\n\nworkflow\n .command(\"status <executionId>\")\n .description(\"Check workflow execution status\")\n .option(\"--watch\", \"Continuously poll for status updates\")\n .option(\"--interval <ms>\", \"Poll interval in milliseconds\", parseInt)\n .option(\"--json\", \"Output as JSON\")\n .action(async (executionId: string, options: WorkflowStatusOptions) => {\n await workflowStatusCommand(executionId, options);\n });\n\n// Tool commands (direct agent tool access)\nconst tool = program.command(\"tool\").description(\"Execute agent tools directly\");\ntool.addHelpText(\n \"after\",\n `\nAgent Hint:\n Start with:\n program tool exec assessComposition --project <projectId> --params '{}'\n Then inspect models before generation:\n program tool exec listImageModels --project <projectId> --params '{}'\n program tool exec listSpeechModels --project <projectId> --params '{}'`,\n);\n\ntool\n .command(\"list\")\n .description(\"List available agent tools\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: ToolListOptions) => {\n await toolListCommand(options);\n });\n\nconst toolExec = tool\n .command(\"exec <toolName>\")\n .description(\"Execute an agent tool\")\n .requiredOption(\"--project <projectId>\", \"Project ID to execute tool against\")\n .option(\"--params <json>\", \"JSON parameters for the tool\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (toolName: string, options: ExecuteOptions) => {\n await toolExecuteCommand(toolName, options);\n });\n\ntoolExec.addHelpText(\n \"after\",\n `\nUpload examples:\n Path-based upload (recommended for larger files):\n program tool exec uploadFile --project <projectId> --params '{\"path\":\"/tmp/recording.mp4\",\"category\":\"video\"}'\n Base64 upload:\n program tool exec uploadFile --project <projectId> --params '{\"fileName\":\"notes.txt\",\"mimeType\":\"text/plain\",\"dataBase64\":\"SGVsbG8=\"}'`,\n);\n\n// Message commands (send and list messages in project chat)\nconst message = program.command(\"message\").description(\"Manage messages in project chat\");\n\nmessage\n .command(\"list\")\n .description(\"List messages in the project chat\")\n .requiredOption(\"--project <projectId>\", \"Project ID to list messages from\")\n .option(\"--limit <limit>\", \"Maximum number of messages to return\", parseInt)\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: ListMessageOptions) => {\n await messageListCommand(options);\n });\n\nmessage\n .command(\"send <text>\")\n .description(\n \"Log a text message to the project chat. NOTE: This only adds a message to the chat history - it does NOT trigger the AI agent. To perform actions, use 'tool exec' instead.\",\n )\n .requiredOption(\"--project <projectId>\", \"Project ID to send message to\")\n .option(\"--role <role>\", \"Message role: user or assistant (default: assistant)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (text: string, options: SendMessageOptions) => {\n await messageSendCommand(text, options);\n });\n\n// Docs command\nprogram\n .command(\"docs\")\n .description(\"Display CLI documentation and command schema\")\n .option(\"--schema\", \"Output full command schema as JSON\")\n .option(\"--json\", \"Output as JSON\")\n .action((options: DocsOptions) => {\n docsCommand(options);\n });\n\n// Parse arguments\nprogram.parse();\n","import chalk from \"chalk\";\nimport open from \"open\";\nimport ora from \"ora\";\nimport { startDeviceAuth } from \"../../lib/auth/device.js\";\nimport { oauthConfig } from \"../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\n\nexport type LoginOptions = OutputOptions;\n\n/**\n * Format user code with dash for readability (ABCD1234 -> ABCD-1234)\n */\nfunction formatUserCode(code: string): string {\n if (code.length === 8) {\n return `${code.slice(0, 4)}-${code.slice(4)}`;\n }\n return code;\n}\n\n/**\n * Device authorization flow - works everywhere including headless environments\n * User visits a URL on any device and enters the code shown in the terminal\n */\nexport async function loginCommand(options: LoginOptions): Promise<void> {\n const showSpinner = process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Requesting device code...\").start() : null;\n\n try {\n const deviceAuth = await startDeviceAuth(oauthConfig);\n spinner?.stop();\n spinner?.clear();\n\n // Try to open the browser automatically (use base URL, not the one with code embedded)\n // User must manually enter the code for security\n void open(deviceAuth.verificationUrl).catch(() => {\n // Silently ignore - URL is displayed below for manual access\n });\n\n // Always display the code and URL (essential for agents/headless environments)\n console.log();\n console.log(chalk.bold(\" Sign in to Program\"));\n console.log();\n console.log(` URL: ${chalk.cyan(deviceAuth.verificationUrl)}`);\n console.log(` Code: ${chalk.bold.yellow(formatUserCode(deviceAuth.userCode))}`);\n console.log();\n console.log(chalk.dim(\" Enter the code above in your browser to authorize.\"));\n console.log();\n\n const waitingSpinner = showSpinner ? ora(\"Waiting for authorization...\").start() : null;\n\n // Poll until the user completes auth\n const credentials = await deviceAuth.pollForCompletion();\n\n waitingSpinner?.stop();\n waitingSpinner?.clear();\n\n if (options.json) {\n outputSuccess(\n {\n authenticated: true,\n email: credentials.email,\n userId: credentials.userId,\n organizationId: credentials.organizationId,\n },\n options\n );\n } else {\n console.log(formatSuccess(`Authenticated as ${chalk.cyan(credentials.email)}`));\n if (credentials.organizationId) {\n console.log(chalk.dim(` Organization: ${credentials.organizationId}`));\n }\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Authentication failed\";\n outputError(message, options);\n process.exit(1);\n }\n}\n","import Conf from \"conf\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as os from \"node:os\";\n\nexport interface Credentials {\n accessToken: string;\n refreshToken: string;\n expiresAt: number;\n userId: string;\n organizationId: string;\n email: string;\n}\n\n// Use ~/.program/ for credentials storage\nconst CREDENTIALS_DIR = path.join(os.homedir(), \".program\");\nconst CREDENTIALS_FILE = path.join(CREDENTIALS_DIR, \"credentials.json\");\n\n// Ensure directory exists with proper permissions\nfunction ensureCredentialsDir(): void {\n if (!fs.existsSync(CREDENTIALS_DIR)) {\n fs.mkdirSync(CREDENTIALS_DIR, { mode: 0o700, recursive: true });\n }\n}\n\n// Using conf for secure credential storage with automatic file permissions\nconst store = new Conf<{ credentials: Credentials | null }>({\n projectName: \"program-cli\",\n cwd: CREDENTIALS_DIR,\n configName: \"credentials\",\n fileExtension: \"json\",\n defaults: {\n credentials: null,\n },\n});\n\nexport function saveCredentials(credentials: Credentials): void {\n ensureCredentialsDir();\n store.set(\"credentials\", credentials);\n\n // Ensure file has restrictive permissions (owner read/write only)\n try {\n fs.chmodSync(CREDENTIALS_FILE, 0o600);\n } catch {\n // Ignore chmod errors on Windows\n }\n}\n\nexport function getCredentials(): Credentials | null {\n return store.get(\"credentials\");\n}\n\nexport function clearCredentials(): void {\n store.delete(\"credentials\");\n}\n\nexport function isAuthenticated(): boolean {\n const creds = getCredentials();\n if (!creds) return false;\n\n // Check if token is expired (with 5 minute buffer)\n const now = Date.now();\n const expiresAt = creds.expiresAt * 1000; // Convert to milliseconds\n const bufferMs = 5 * 60 * 1000; // 5 minutes\n\n return now < expiresAt - bufferMs;\n}\n\nexport function needsRefresh(): boolean {\n const creds = getCredentials();\n if (!creds) return false;\n\n // Needs refresh if within 5 minutes of expiry\n const now = Date.now();\n const expiresAt = creds.expiresAt * 1000;\n const bufferMs = 5 * 60 * 1000;\n\n return now >= expiresAt - bufferMs && now < expiresAt;\n}\n","import { saveCredentials, getCredentials } from \"./credentials.js\";\nimport type { Credentials } from \"./credentials.js\";\n\n// OAuth client ID - same as the main oauth.ts\nconst CLIENT_ID = \"program-cli\";\nconst SCOPES = [\"openid\", \"profile\", \"email\", \"offline_access\"];\n\nexport interface DeviceAuthConfig {\n baseUrl: string;\n}\n\ninterface DeviceCodeResponse {\n device_code: string;\n user_code: string;\n verification_uri: string;\n verification_uri_complete?: string;\n expires_in: number;\n interval: number;\n}\n\ninterface TokenResponse {\n access_token: string;\n refresh_token?: string;\n expires_in?: number;\n token_type?: string;\n scope?: string;\n}\n\ninterface TokenErrorResponse {\n error: string;\n error_description?: string;\n}\n\ninterface UserInfo {\n id: string;\n email: string;\n name: string;\n organizationId?: string;\n}\n\n/**\n * Request a device code from the server\n */\nexport async function requestDeviceCode(\n config: DeviceAuthConfig\n): Promise<DeviceCodeResponse> {\n const url = new URL(\"/api/auth/device/code\", config.baseUrl);\n\n const response = await fetch(url.toString(), {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n client_id: CLIENT_ID,\n scope: SCOPES.join(\" \"),\n }),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Failed to get device code: ${response.status} ${errorText}`);\n }\n\n return response.json() as Promise<DeviceCodeResponse>;\n}\n\n/**\n * Poll for the token after user authorizes\n * Returns the token response or an error code\n */\nexport async function pollForToken(\n config: DeviceAuthConfig,\n deviceCode: string\n): Promise<TokenResponse | TokenErrorResponse> {\n const url = new URL(\"/api/auth/device/token\", config.baseUrl);\n\n const response = await fetch(url.toString(), {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n device_code: deviceCode,\n client_id: CLIENT_ID,\n }),\n });\n\n // Device flow uses 400 status for pending/slow_down errors\n const data = (await response.json()) as TokenResponse | TokenErrorResponse;\n\n if (!response.ok) {\n // Check if it's an expected error (authorization_pending, slow_down)\n if (\"error\" in data) {\n return data;\n }\n throw new Error(`Token request failed: ${response.status}`);\n }\n\n return data as TokenResponse;\n}\n\n/**\n * Get user info from the BetterAuth session endpoint\n * Device authorization returns a BetterAuth token, not an OIDC token\n */\nasync function getUserInfo(\n config: DeviceAuthConfig,\n accessToken: string\n): Promise<UserInfo> {\n // Use the BetterAuth get-session endpoint with Bearer token\n const sessionUrl = new URL(\"/api/auth/get-session\", config.baseUrl);\n\n const response = await fetch(sessionUrl.toString(), {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n // Try the token/session endpoint if get-session doesn't work\n const tokenUrl = new URL(\"/api/auth/token\", config.baseUrl);\n const tokenResponse = await fetch(tokenUrl.toString(), {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!tokenResponse.ok) {\n throw new Error(`Failed to get user info: ${response.status}`);\n }\n\n const tokenData = (await tokenResponse.json()) as {\n user?: { id?: string; email?: string; name?: string };\n session?: { activeOrganizationId?: string };\n };\n\n if (!tokenData.user?.id || !tokenData.user.email) {\n throw new Error(\"Invalid token response: missing user info\");\n }\n\n return {\n id: tokenData.user.id,\n email: tokenData.user.email,\n name: tokenData.user.name ?? tokenData.user.email,\n organizationId: tokenData.session?.activeOrganizationId,\n };\n }\n\n const data = (await response.json()) as {\n user?: {\n id?: string;\n email?: string;\n name?: string;\n };\n session?: {\n activeOrganizationId?: string;\n };\n };\n\n if (!data.user?.id || !data.user.email) {\n throw new Error(\"Invalid session response: missing user info\");\n }\n\n return {\n id: data.user.id,\n email: data.user.email,\n name: data.user.name ?? data.user.email,\n organizationId: data.session?.activeOrganizationId,\n };\n}\n\n/**\n * Start the device authorization flow\n * Returns display info for the CLI to show the user\n */\nexport interface DeviceAuthDisplay {\n userCode: string;\n verificationUrl: string;\n verificationUrlComplete?: string;\n expiresIn: number;\n interval: number;\n pollForCompletion: () => Promise<Credentials>;\n}\n\nexport async function startDeviceAuth(\n config: DeviceAuthConfig\n): Promise<DeviceAuthDisplay> {\n const deviceCode = await requestDeviceCode(config);\n\n return {\n userCode: deviceCode.user_code,\n verificationUrl: deviceCode.verification_uri,\n verificationUrlComplete: deviceCode.verification_uri_complete,\n expiresIn: deviceCode.expires_in,\n interval: deviceCode.interval,\n pollForCompletion: async () => {\n return pollUntilComplete(config, deviceCode);\n },\n };\n}\n\n/**\n * Poll until the user completes authorization or the code expires\n */\nasync function pollUntilComplete(\n config: DeviceAuthConfig,\n deviceCode: DeviceCodeResponse\n): Promise<Credentials> {\n const startTime = Date.now();\n const expiresAt = startTime + deviceCode.expires_in * 1000;\n let interval = deviceCode.interval * 1000;\n\n while (Date.now() < expiresAt) {\n // Wait for the interval before polling\n await new Promise((resolve) => setTimeout(resolve, interval));\n\n const result = await pollForToken(config, deviceCode.device_code);\n\n // Check if it's an error response\n if (\"error\" in result) {\n switch (result.error) {\n case \"authorization_pending\":\n // User hasn't completed authorization yet, continue polling\n continue;\n\n case \"slow_down\":\n // Server asked us to slow down, increase interval\n interval += 5000;\n continue;\n\n case \"expired_token\":\n throw new Error(\"Device code expired. Please start a new login.\");\n\n case \"access_denied\":\n throw new Error(\"Access denied. You denied the authorization request.\");\n\n default:\n throw new Error(\n result.error_description ?? `Authorization failed: ${result.error}`\n );\n }\n }\n\n // Success! We got tokens\n const tokens = result;\n\n // Get user info\n const userInfo = await getUserInfo(config, tokens.access_token);\n\n // Calculate expiry timestamp (default to 1 hour if not provided)\n const expiresIn = tokens.expires_in ?? 3600;\n const expiresAtTimestamp = Math.floor(Date.now() / 1000) + expiresIn;\n\n // Save credentials (refresh token may not be present for device flow)\n const credentials: Credentials = {\n accessToken: tokens.access_token,\n refreshToken: tokens.refresh_token ?? \"\",\n expiresAt: expiresAtTimestamp,\n userId: userInfo.id,\n organizationId: userInfo.organizationId ?? \"\",\n email: userInfo.email,\n };\n\n saveCredentials(credentials);\n\n return credentials;\n }\n\n throw new Error(\"Device code expired. Please start a new login.\");\n}\n\n/**\n * Check if we have valid credentials\n */\nexport function hasValidCredentials(): boolean {\n const creds = getCredentials();\n if (!creds) return false;\n\n // Check if token is expired (with 5 min buffer)\n const now = Date.now();\n const expiresAt = creds.expiresAt * 1000;\n const bufferMs = 5 * 60 * 1000;\n\n return now < expiresAt - bufferMs;\n}\n","import type { OAuthConfig } from \"./auth/index.js\";\nimport type { ConvexConfig } from \"./convex.js\";\n\n// Production URLs - hardcoded to prevent credential theft via env var manipulation\nexport const BASE_URL = \"https://program.video\";\n\n// Convex deployment URL (production)\nexport const CONVEX_URL = \"https://keen-eel-920.convex.cloud\";\n\nexport const oauthConfig: OAuthConfig = {\n baseUrl: BASE_URL,\n};\n\nexport const convexConfig: ConvexConfig = {\n convexUrl: CONVEX_URL,\n oauthConfig,\n};\n","import chalk from \"chalk\";\n\nexport interface OutputOptions {\n json?: boolean;\n}\n\nexport interface SuccessResult<T> {\n success: true;\n data: T;\n}\n\nexport interface ErrorResult {\n success: false;\n error: string;\n}\n\nexport type Result<T> = SuccessResult<T> | ErrorResult;\n\n/**\n * Output a success result in the appropriate format\n */\nexport function outputSuccess<T>(data: T, options: OutputOptions = {}): void {\n if (options.json) {\n const result: SuccessResult<T> = { success: true, data };\n console.log(JSON.stringify(result, null, 2));\n } else {\n // For human-readable output, we'll handle this per-command\n // This is a fallback that just pretty-prints\n console.log(data);\n }\n}\n\n/**\n * Output an error result in the appropriate format\n */\nexport function outputError(error: string, options: OutputOptions = {}): void {\n if (options.json) {\n const result: ErrorResult = { success: false, error };\n console.log(JSON.stringify(result, null, 2));\n } else {\n console.error(chalk.red(\"Error:\"), error);\n }\n}\n\n/**\n * Format a table for human-readable output\n */\nexport function formatTable(\n headers: string[],\n rows: string[][],\n options: { indent?: number } = {}\n): string {\n const indent = \" \".repeat(options.indent ?? 0);\n\n // Calculate column widths\n const widths = headers.map((h, i) => {\n const maxRow = Math.max(...rows.map((r) => (r[i] ?? \"\").length));\n return Math.max(h.length, maxRow);\n });\n\n // Format header\n const headerLine = headers\n .map((h, i) => chalk.bold(h.padEnd(widths[i] ?? 0)))\n .join(\" \");\n\n // Format separator\n const separator = widths.map((w) => \"-\".repeat(w)).join(\" \");\n\n // Format rows\n const formattedRows = rows.map((row) =>\n row.map((cell, i) => (cell || \"\").padEnd(widths[i] ?? 0)).join(\" \")\n );\n\n return [indent + headerLine, indent + separator, ...formattedRows.map((r) => indent + r)].join(\n \"\\n\"\n );\n}\n\n/**\n * Format a key-value list for human-readable output\n */\nexport function formatKeyValue(\n items: { key: string; value: string }[],\n options: { indent?: number } = {}\n): string {\n const indent = \" \".repeat(options.indent ?? 0);\n const maxKeyLength = Math.max(...items.map((item) => item.key.length));\n\n return items\n .map(\n (item) =>\n indent + chalk.dim(item.key.padEnd(maxKeyLength) + \":\") + \" \" + item.value\n )\n .join(\"\\n\");\n}\n\n/**\n * Format a success message\n */\nexport function formatSuccess(message: string): string {\n return chalk.green(\"✓\") + \" \" + message;\n}\n\n/**\n * Format a warning message\n */\nexport function formatWarning(message: string): string {\n return chalk.yellow(\"⚠\") + \" \" + message;\n}\n\n/**\n * Format an info message\n */\nexport function formatInfo(message: string): string {\n return chalk.blue(\"ℹ\") + \" \" + message;\n}\n","import { clearCredentials, getCredentials } from \"../../lib/auth/credentials.js\";\nimport { formatSuccess, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport type LogoutOptions = OutputOptions;\n\nexport function logoutCommand(options: LogoutOptions): void {\n const credentials = getCredentials();\n\n if (!credentials) {\n if (options.json) {\n outputSuccess({ loggedOut: true, wasAuthenticated: false }, options);\n } else {\n console.log(\"Not currently logged in.\");\n }\n return;\n }\n\n const email = credentials.email;\n clearCredentials();\n\n if (options.json) {\n outputSuccess({ loggedOut: true, wasAuthenticated: true, email }, options);\n } else {\n console.log(formatSuccess(`Logged out from ${email}`));\n }\n}\n","import chalk from \"chalk\";\nimport { getCredentials, isAuthenticated, needsRefresh } from \"../../lib/auth/credentials.js\";\nimport { formatKeyValue, formatSuccess, formatWarning, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport type StatusOptions = OutputOptions;\n\nexport function statusCommand(options: StatusOptions): void {\n const credentials = getCredentials();\n\n if (!credentials) {\n if (options.json) {\n outputSuccess({ authenticated: false }, options);\n } else {\n console.log(\"Not logged in. Run 'program auth login' to authenticate.\");\n }\n return;\n }\n\n const authenticated = isAuthenticated();\n const expiresAt = credentials.expiresAt;\n const now = Math.floor(Date.now() / 1000);\n const expiresIn = expiresAt - now;\n\n if (options.json) {\n outputSuccess(\n {\n authenticated,\n user: credentials.email,\n userId: credentials.userId,\n organizationId: credentials.organizationId,\n expiresAt,\n expiresIn,\n needsRefresh: needsRefresh(),\n },\n options\n );\n } else {\n if (!authenticated) {\n console.log(formatWarning(\"Token expired. Run 'program auth login' to re-authenticate.\"));\n return;\n }\n\n console.log(formatSuccess(\"Logged in\"));\n console.log();\n console.log(\n formatKeyValue([\n { key: \"Email\", value: credentials.email },\n { key: \"User ID\", value: credentials.userId },\n { key: \"Organization\", value: credentials.organizationId || chalk.dim(\"(none)\") },\n { key: \"Token expires\", value: formatExpiresIn(expiresIn) },\n ])\n );\n }\n}\n\nfunction formatExpiresIn(seconds: number): string {\n if (seconds <= 0) {\n return chalk.red(\"expired\");\n }\n\n if (seconds < 60) {\n return chalk.yellow(`in ${seconds} seconds`);\n }\n\n if (seconds < 3600) {\n const minutes = Math.floor(seconds / 60);\n return chalk.green(`in ${minutes} minute${minutes === 1 ? \"\" : \"s\"}`);\n }\n\n const hours = Math.floor(seconds / 3600);\n const minutes = Math.floor((seconds % 3600) / 60);\n return chalk.green(`in ${hours}h ${minutes}m`);\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport interface CreateOptions extends OutputOptions {\n title?: string;\n description?: string;\n}\n\ninterface CreateResult {\n id: string;\n title: string;\n}\n\nexport async function createCommand(options: CreateOptions): Promise<void> {\n // Only show spinner in TTY environments (not through npx/pipes)\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Creating project...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.mutation<string>(\"projects.create\", {\n title: options.title,\n description: options.description,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to create project\", options);\n process.exit(1);\n }\n\n const projectData: CreateResult = {\n id: result.data,\n title: options.title ?? \"Untitled Project\",\n };\n\n if (options.json) {\n outputSuccess(projectData, options);\n } else {\n console.log(formatSuccess(`Created project ${chalk.cyan(projectData.title)}`));\n console.log(chalk.dim(` ID: ${projectData.id}`));\n }\n}\n","import { getCredentials } from \"./credentials.js\";\n\nexport interface OAuthConfig {\n baseUrl: string;\n}\n\n/**\n * Ensure we have a valid access token.\n * For device auth, we don't refresh - user must re-authenticate if expired.\n */\nexport function ensureValidToken(_config: OAuthConfig): string | null {\n const creds = getCredentials();\n if (!creds) {\n return null;\n }\n\n const now = Date.now();\n const expiresAt = creds.expiresAt * 1000;\n const bufferMs = 5 * 60 * 1000; // 5 minutes\n\n // If token is still valid, return it\n if (now < expiresAt - bufferMs) {\n return creds.accessToken;\n }\n\n // Token expired - user needs to re-authenticate\n return null;\n}\n","import { getCredentials, ensureValidToken } from \"./auth/index.js\";\nimport type {OAuthConfig} from \"./auth/index.js\";\n\nexport interface ConvexConfig {\n convexUrl: string;\n oauthConfig: OAuthConfig;\n}\n\nexport interface ConvexResponse<T> {\n success: boolean;\n data?: T;\n error?: string;\n}\n\n/**\n * Create a Convex HTTP client for calling Convex functions via the CLI gateway\n */\nexport function createConvexClient(config: ConvexConfig) {\n const { convexUrl } = config;\n\n // The CLI gateway is on the .convex.site endpoint\n const gatewayUrl = convexUrl.replace(\".convex.cloud\", \".convex.site\");\n\n /**\n * Call a Convex query function via the CLI gateway\n */\n async function query<T>(\n functionPath: string,\n args: Record<string, unknown> = {}\n ): Promise<ConvexResponse<T>> {\n return callGateway<T>(functionPath, args);\n }\n\n /**\n * Call a Convex mutation function via the CLI gateway\n */\n async function mutation<T>(\n functionPath: string,\n args: Record<string, unknown> = {}\n ): Promise<ConvexResponse<T>> {\n return callGateway<T>(functionPath, args);\n }\n\n /**\n * Call a Convex action function via the CLI gateway\n */\n async function action<T>(\n functionPath: string,\n args: Record<string, unknown> = {}\n ): Promise<ConvexResponse<T>> {\n return callGateway<T>(functionPath, args);\n }\n\n /**\n * Call the CLI gateway with OAuth authentication\n */\n async function callGateway<T>(\n functionPath: string,\n args: Record<string, unknown>\n ): Promise<ConvexResponse<T>> {\n // Get valid access token\n const accessToken = ensureValidToken(config.oauthConfig);\n if (!accessToken) {\n return {\n success: false,\n error: \"Not authenticated. Run 'program auth login' first.\",\n };\n }\n\n // Build the gateway URL\n const url = new URL(\"/cli\", gatewayUrl);\n\n try {\n const response = await fetch(url.toString(), {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify({\n fn: functionPath,\n params: args,\n }),\n });\n\n const result = (await response.json()) as {\n success: boolean;\n data?: T;\n error?: string;\n };\n\n if (!response.ok || !result.success) {\n return {\n success: false,\n error: result.error ?? `Gateway error: ${response.status}`,\n };\n }\n\n return { success: true, data: result.data };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }\n\n /**\n * Get the current credentials (for checking auth status)\n */\n function getAuth() {\n return getCredentials();\n }\n\n return {\n query,\n mutation,\n action,\n getAuth,\n };\n}\n\nexport type ConvexClient = ReturnType<typeof createConvexClient>;\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatKeyValue, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport type GetOptions = OutputOptions;\n\ninterface ProjectWithComposition {\n _id: string;\n title: string;\n description?: string;\n createdAt: number;\n updatedAt: number;\n latestVersion: {\n _id: string;\n version: number;\n compositionId: string;\n createdAt: number;\n } | null;\n composition: {\n _id: string;\n title: string;\n description?: string;\n duration: number;\n fps: number;\n width: number;\n height: number;\n sceneCount: number;\n scenes: unknown[];\n } | null;\n}\n\nexport async function getCommand(projectId: string, options: GetOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching project...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<ProjectWithComposition>(\"projects.byId\", {\n id: projectId,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to get project\", options);\n process.exit(1);\n }\n\n const project = result.data;\n\n if (options.json) {\n outputSuccess(project, options);\n } else {\n console.log(chalk.bold(project.title || \"Untitled Project\"));\n if (project.description) {\n console.log(chalk.dim(project.description));\n }\n console.log();\n\n console.log(\n formatKeyValue([\n { key: \"ID\", value: project._id },\n { key: \"Created\", value: new Date(project.createdAt).toLocaleString() },\n { key: \"Updated\", value: new Date(project.updatedAt).toLocaleString() },\n ])\n );\n\n if (project.latestVersion) {\n console.log(chalk.bold(\"\\nVersion\"));\n console.log(\n formatKeyValue([\n { key: \"Version\", value: String(project.latestVersion.version) },\n { key: \"Composition ID\", value: project.latestVersion.compositionId },\n ])\n );\n } else {\n console.log(chalk.dim(\"\\nNo versions yet\"));\n }\n\n if (project.composition) {\n console.log(chalk.bold(\"\\nComposition\"));\n console.log(\n formatKeyValue([\n { key: \"Title\", value: project.composition.title },\n { key: \"Resolution\", value: `${project.composition.width}x${project.composition.height}` },\n { key: \"FPS\", value: String(project.composition.fps) },\n { key: \"Duration\", value: `${(project.composition.duration / 1000).toFixed(1)}s` },\n { key: \"Scenes\", value: String(project.composition.sceneCount) },\n ])\n );\n\n if (project.composition.sceneCount > 0 && Array.isArray(project.composition.scenes)) {\n console.log(chalk.bold(\"\\nScenes\"));\n for (const scene of project.composition.scenes as { id: string; type: string; duration: number }[]) {\n console.log(chalk.dim(` - ${scene.type} (${(scene.duration / 1000).toFixed(1)}s)`));\n }\n }\n } else {\n console.log(chalk.dim(\"\\nNo composition yet\"));\n }\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatTable, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport interface ListOptions extends OutputOptions {\n limit?: number;\n}\n\ninterface Project {\n _id: string;\n title: string;\n description?: string;\n createdAt: number;\n updatedAt: number;\n}\n\ninterface ListResult {\n items: Project[];\n nextCursor: string | null;\n}\n\nexport async function listCommand(options: ListOptions): Promise<void> {\n // Only show spinner in TTY environments (not through npx/pipes)\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching projects...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<ListResult>(\"projects.list\", {\n limit: options.limit,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to list projects\", options);\n process.exit(1);\n }\n\n const projects = result.data.items;\n\n if (options.json) {\n outputSuccess(projects, options);\n } else {\n if (projects.length === 0) {\n console.log(chalk.dim(\"No projects found. Create one with 'program project create'\"));\n return;\n }\n\n console.log(`Found ${chalk.cyan(projects.length)} project${projects.length === 1 ? \"\" : \"s\"}:\\n`);\n\n const rows = projects.map((p) => [\n p._id,\n p.title || chalk.dim(\"Untitled\"),\n formatDate(p.createdAt),\n ]);\n\n console.log(formatTable([\"ID\", \"Title\", \"Created\"], rows));\n }\n}\n\nfunction formatDate(timestamp: number): string {\n const date = new Date(timestamp);\n const now = new Date();\n const diffMs = now.getTime() - date.getTime();\n const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));\n\n if (diffDays === 0) {\n return \"today\";\n } else if (diffDays === 1) {\n return \"yesterday\";\n } else if (diffDays < 7) {\n return `${diffDays} days ago`;\n } else {\n return date.toLocaleDateString();\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatTable, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport interface ListOptions extends OutputOptions {\n limit?: number;\n publicOnly?: boolean;\n}\n\ninterface Template {\n _id: string;\n name: string;\n description?: string;\n public: boolean;\n createdAt: number;\n updatedAt: number;\n}\n\nexport async function listCommand(options: ListOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching workflow templates...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<Template[]>(\"workflows.listTemplates\", {\n category: options.publicOnly ? \"public\" : undefined,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to list templates\", options);\n process.exit(1);\n }\n\n const templates = result.data;\n\n if (options.json) {\n outputSuccess(\n templates.map((t) => ({\n id: t._id,\n name: t.name,\n description: t.description,\n public: t.public,\n })),\n options\n );\n } else {\n if (templates.length === 0) {\n console.log(chalk.dim(\"No workflow templates found.\"));\n return;\n }\n\n console.log(`Found ${chalk.cyan(templates.length)} template${templates.length === 1 ? \"\" : \"s\"}:\\n`);\n\n const rows = templates.map((t) => [\n t._id,\n t.name,\n t.description?.substring(0, 40) ?? chalk.dim(\"No description\"),\n t.public ? chalk.green(\"public\") : chalk.dim(\"private\"),\n ]);\n\n console.log(formatTable([\"ID\", \"Name\", \"Description\", \"Visibility\"], rows));\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport interface RunOptions extends OutputOptions {\n project?: string;\n input?: string;\n}\n\nexport async function runCommand(templateId: string, options: RunOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Starting workflow execution...\").start() : null;\n\n // Parse input JSON if provided\n let input: Record<string, unknown> | undefined;\n if (options.input) {\n try {\n input = JSON.parse(options.input) as Record<string, unknown>;\n } catch {\n spinner?.stop();\n spinner?.clear();\n outputError(\"Invalid JSON in --input parameter\", options);\n process.exit(1);\n }\n }\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.mutation<string>(\"workflows.run\", {\n templateId,\n projectId: options.project,\n input,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to start workflow\", options);\n process.exit(1);\n }\n\n const executionId = result.data;\n\n if (options.json) {\n outputSuccess({ executionId }, options);\n } else {\n console.log(formatSuccess(`Workflow started`));\n console.log(chalk.dim(` Execution ID: ${executionId}`));\n console.log(chalk.dim(` Check status with: program workflow status ${executionId}`));\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatKeyValue, formatSuccess, formatWarning, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport interface StatusOptions extends OutputOptions {\n watch?: boolean;\n interval?: number;\n}\n\ninterface ExecutionStatus {\n status: \"pending\" | \"running\" | \"success\" | \"error\" | \"cancelled\";\n output?: unknown;\n error?: string;\n completedAt?: number;\n nodeStatuses?: { nodeId: string; status: string }[];\n}\n\nexport async function statusCommand(executionId: string, options: StatusOptions): Promise<void> {\n const client = createConvexClient(convexConfig);\n const pollInterval = options.interval ?? 2000;\n\n if (options.watch) {\n await watchStatus(client, executionId, pollInterval, options);\n } else {\n await getStatusOnce(client, executionId, options);\n }\n}\n\nasync function getStatusOnce(\n client: ReturnType<typeof createConvexClient>,\n executionId: string,\n options: StatusOptions\n): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching execution status...\").start() : null;\n\n const result = await client.query<ExecutionStatus>(\"workflows.status\", {\n executionId,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success) {\n outputError(result.error ?? \"Failed to get status\", options);\n process.exit(1);\n }\n\n const status = result.data;\n\n if (!status) {\n outputError(\"Execution not found\", options);\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess(status, options);\n } else {\n printStatus(status);\n }\n}\n\nasync function watchStatus(\n client: ReturnType<typeof createConvexClient>,\n executionId: string,\n pollInterval: number,\n options: StatusOptions\n): Promise<void> {\n let lastStatus: string | null = null;\n\n const poll = async (): Promise<boolean> => {\n const result = await client.query<ExecutionStatus>(\"workflows.status\", {\n executionId,\n });\n\n if (!result.success) {\n outputError(result.error ?? \"Failed to get status\", options);\n return true; // Stop polling\n }\n\n const status = result.data;\n\n if (!status) {\n outputError(\"Execution not found\", options);\n return true;\n }\n\n // For JSON mode, output each status change\n if (options.json) {\n if (status.status !== lastStatus) {\n console.log(JSON.stringify(status));\n lastStatus = status.status;\n }\n } else {\n // For human mode, clear and reprint\n if (status.status !== lastStatus) {\n console.clear();\n console.log(chalk.dim(`Watching execution ${executionId}...\\n`));\n printStatus(status);\n lastStatus = status.status;\n }\n }\n\n // Stop polling if complete\n if ([\"success\", \"error\", \"cancelled\"].includes(status.status)) {\n return true;\n }\n\n return false;\n };\n\n // Initial poll\n let done = await poll();\n\n // Continue polling until complete\n while (!done) {\n await new Promise((resolve) => setTimeout(resolve, pollInterval));\n done = await poll();\n }\n}\n\nfunction printStatus(status: ExecutionStatus): void {\n const statusColor = getStatusColor(status.status);\n\n console.log(\n formatKeyValue([\n { key: \"Status\", value: statusColor(status.status) },\n ...(status.completedAt\n ? [{ key: \"Completed\", value: new Date(status.completedAt).toLocaleString() }]\n : []),\n ])\n );\n\n if (status.nodeStatuses && status.nodeStatuses.length > 0) {\n console.log(chalk.dim(\"\\nStep progress:\"));\n for (const node of status.nodeStatuses) {\n const nodeColor = getStatusColor(node.status);\n console.log(` ${nodeColor(getStatusIcon(node.status))} ${node.nodeId}`);\n }\n }\n\n if (status.error) {\n console.log(formatWarning(`\\nError: ${status.error}`));\n }\n\n if (status.status === \"success\" && status.output) {\n console.log(formatSuccess(\"\\nOutput:\"));\n console.log(JSON.stringify(status.output, null, 2));\n }\n}\n\nfunction getStatusColor(status: string): (text: string) => string {\n switch (status) {\n case \"success\":\n return chalk.green;\n case \"error\":\n return chalk.red;\n case \"cancelled\":\n return chalk.yellow;\n case \"running\":\n return chalk.blue;\n case \"pending\":\n default:\n return chalk.dim;\n }\n}\n\nfunction getStatusIcon(status: string): string {\n switch (status) {\n case \"success\":\n return \"✓\";\n case \"error\":\n return \"✕\";\n case \"running\":\n return \"●\";\n case \"pending\":\n default:\n return \"○\";\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createReadStream } from \"node:fs\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { ensureValidToken } from \"../../lib/auth/index.js\";\nimport { oauthConfig, BASE_URL } from \"../../lib/config.js\";\nimport { outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\nimport { detectAgentSource } from \"../../lib/agent-detect.js\";\n\nexport interface ExecuteOptions extends OutputOptions {\n project: string;\n params?: string;\n}\n\nconst MIME_TYPES_BY_EXTENSION: Record<string, string> = {\n \".aac\": \"audio/aac\",\n \".flac\": \"audio/flac\",\n \".gif\": \"image/gif\",\n \".jpeg\": \"image/jpeg\",\n \".jpg\": \"image/jpeg\",\n \".json\": \"application/json\",\n \".m4a\": \"audio/mp4\",\n \".mov\": \"video/quicktime\",\n \".mp3\": \"audio/mpeg\",\n \".mp4\": \"video/mp4\",\n \".ogg\": \"audio/ogg\",\n \".png\": \"image/png\",\n \".svg\": \"image/svg+xml\",\n \".txt\": \"text/plain\",\n \".wav\": \"audio/wav\",\n \".webm\": \"video/webm\",\n};\n\nfunction inferMimeType(fileName: string): string | null {\n const extension = path.extname(fileName).toLowerCase();\n return MIME_TYPES_BY_EXTENSION[extension] ?? null;\n}\n\ninterface ToolResponse {\n success: boolean;\n data?: unknown;\n error?: string;\n compositionId?: string;\n}\n\ninterface UploadInitResponse extends ToolResponse {\n data?: {\n uploadUrl: string;\n fileName: string;\n mimeType: string;\n fileSize: number;\n };\n}\n\ninterface UploadStorageResponse {\n storageId?: string;\n}\n\nasync function uploadFileFromPath(\n params: Record<string, unknown>,\n projectId: string,\n accessToken: string,\n source?: string,\n): Promise<ToolResponse> {\n const filePath = params.path;\n if (typeof filePath !== \"string\" || filePath.length === 0) {\n throw new Error(\"uploadFile path must be a non-empty string\");\n }\n if (!path.isAbsolute(filePath)) {\n throw new Error(\"uploadFile path must be an absolute file path\");\n }\n\n const fileStat = await fs.stat(filePath);\n if (!fileStat.isFile()) {\n throw new Error(`uploadFile path is not a file: ${filePath}`);\n }\n\n const fileName =\n typeof params.fileName === \"string\" && params.fileName.length > 0\n ? params.fileName\n : path.basename(filePath);\n if (fileName.includes(\"/\") || fileName.includes(\"\\\\\")) {\n throw new Error(\"fileName must be a plain file name, not a path\");\n }\n const inferredMimeType = inferMimeType(fileName);\n const mimeType =\n typeof params.mimeType === \"string\" && params.mimeType.length > 0\n ? params.mimeType\n : inferredMimeType;\n if (!mimeType) {\n throw new Error(\n \"Could not infer MIME type from file extension. Provide params.mimeType explicitly.\",\n );\n }\n\n const category =\n typeof params.category === \"string\" && params.category.length > 0\n ? params.category\n : undefined;\n if (category && !/^[a-z0-9_-]{1,32}$/i.test(category)) {\n throw new Error(\"category must match /^[a-z0-9_-]{1,32}$/i\");\n }\n const metadata =\n params.metadata && typeof params.metadata === \"object\"\n ? params.metadata\n : undefined;\n\n const initRequest: RequestInit = {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n \"x-project-id\": projectId,\n ...(source ? { \"x-source\": source } : {}),\n },\n body: JSON.stringify({\n step: \"init\",\n fileName,\n mimeType,\n fileSize: fileStat.size,\n category,\n metadata,\n }),\n };\n\n const initResponse = await fetch(`${BASE_URL}/api/cli/upload`, initRequest);\n const initResult = (await initResponse\n .json()\n .catch(() => null)) as UploadInitResponse | null;\n\n if (!initResponse.ok || !initResult?.success || !initResult.data) {\n throw new Error(\n initResult?.error ?? `Upload init failed (${initResponse.status})`,\n );\n }\n\n const fileStream = createReadStream(filePath);\n const uploadRequest: RequestInit & { duplex: \"half\" } = {\n method: \"POST\",\n headers: {\n \"Content-Type\": mimeType,\n \"Content-Length\": String(fileStat.size),\n },\n body: fileStream as unknown as NonNullable<RequestInit[\"body\"]>,\n duplex: \"half\",\n };\n const storageUploadResponse = await fetch(\n initResult.data.uploadUrl,\n uploadRequest,\n );\n const storageUploadJson = (await storageUploadResponse\n .json()\n .catch(() => null)) as UploadStorageResponse | null;\n\n if (\n !storageUploadResponse.ok ||\n !storageUploadJson ||\n typeof storageUploadJson.storageId !== \"string\"\n ) {\n throw new Error(\n `Failed to upload bytes to storage (${storageUploadResponse.status})`,\n );\n }\n\n const finalizeRequest: RequestInit = {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n \"x-project-id\": projectId,\n ...(source ? { \"x-source\": source } : {}),\n },\n body: JSON.stringify({\n step: \"finalize\",\n storageId: storageUploadJson.storageId,\n fileName,\n mimeType,\n fileSize: fileStat.size,\n category,\n metadata,\n }),\n };\n\n const finalizeResponse = await fetch(\n `${BASE_URL}/api/cli/upload`,\n finalizeRequest,\n );\n\n const finalizeResult = (await finalizeResponse\n .json()\n .catch(() => null)) as ToolResponse | null;\n if (!finalizeResponse.ok || !finalizeResult?.success) {\n throw new Error(\n finalizeResult?.error ??\n `File finalize failed (${finalizeResponse.status})`,\n );\n }\n\n return finalizeResult;\n}\n\nexport async function executeCommand(\n toolName: string,\n options: ExecuteOptions\n): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(`Executing ${toolName}...`).start() : null;\n\n // Get valid access token\n const accessToken = ensureValidToken(oauthConfig);\n if (!accessToken) {\n spinner?.stop();\n spinner?.clear();\n outputError(\"Not authenticated. Run 'program auth login' first.\", options);\n process.exit(1);\n }\n\n // Parse params if provided\n let params: Record<string, unknown> = {};\n if (options.params) {\n try {\n params = JSON.parse(options.params) as Record<string, unknown>;\n } catch {\n spinner?.stop();\n spinner?.clear();\n outputError(\"Invalid JSON in --params\", options);\n process.exit(1);\n }\n }\n\n // Detect agent at runtime (not login time) for correct multi-agent support\n const source = detectAgentSource();\n\n if (toolName === \"uploadFile\" && typeof params.path === \"string\") {\n try {\n if (spinner) {\n spinner.text = \"Uploading file...\";\n }\n const result = await uploadFileFromPath(\n params,\n options.project,\n accessToken,\n source,\n );\n if (spinner) {\n spinner.stop();\n spinner.clear();\n }\n if (options.json) {\n outputSuccess(result.data, options);\n } else {\n console.log(chalk.green(`✓ ${toolName} executed successfully`));\n if (result.compositionId) {\n console.log(chalk.dim(` Composition: ${result.compositionId}`));\n }\n console.log();\n console.log(JSON.stringify(result.data, null, 2));\n }\n return;\n } catch (error) {\n spinner?.stop();\n spinner?.clear();\n outputError(\n error instanceof Error ? error.message : \"Failed to upload file\",\n options,\n );\n process.exit(1);\n }\n }\n\n try {\n const response = await fetch(`${BASE_URL}/api/cli/tool`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify({\n projectId: options.project,\n tool: toolName,\n params,\n source,\n }),\n });\n\n const result = (await response.json()) as ToolResponse;\n\n spinner?.stop();\n spinner?.clear();\n\n if (!response.ok || !result.success) {\n outputError(result.error ?? `Tool execution failed: ${response.status}`, options);\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess(result.data, options);\n } else {\n console.log(chalk.green(`✓ ${toolName} executed successfully`));\n if (result.compositionId) {\n console.log(chalk.dim(` Composition: ${result.compositionId}`));\n }\n console.log();\n console.log(JSON.stringify(result.data, null, 2));\n }\n } catch (error) {\n spinner?.stop();\n spinner?.clear();\n outputError(error instanceof Error ? error.message : \"Request failed\", options);\n process.exit(1);\n }\n}\n","/**\n * Runtime agent detection\n *\n * Detects which agent/IDE is running the CLI based on environment variables.\n * This is checked per-request, not at login time, so multiple agents can\n * use the same credentials simultaneously with correct attribution.\n */\n\n/**\n * Detect which agent is currently running this CLI command.\n * Returns undefined for unknown agents (will show as \"Agent via CLI\").\n */\nexport function detectAgentSource(): string | undefined {\n if (process.env.CLAUDECODE === \"1\") {\n return \"claude-code\";\n }\n\n if (process.env.OPENCODE === \"1\") {\n return \"opencode\";\n }\n\n // Codex environments can expose CODEX_HOME, CODEX_CI, or a Codex bundle identifier.\n if (process.env.CODEX_CI === \"1\") {\n return \"codex\";\n }\n\n if (\n typeof process.env.__CFBundleIdentifier === \"string\" &&\n process.env.__CFBundleIdentifier.includes(\"codex\")\n ) {\n return \"codex\";\n }\n\n if (typeof process.env.CODEX_HOME === \"string\") {\n return \"codex\";\n }\n\n // OpenClaw and other agents will fall back to \"Agent via CLI\" until\n // they implement detection env vars\n return undefined;\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { BASE_URL } from \"../../lib/config.js\";\nimport { outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport type ListOptions = OutputOptions;\n\ninterface Tool {\n name: string;\n description: string;\n inputs: string[];\n}\n\nexport async function listCommand(options: ListOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching available tools...\").start() : null;\n\n try {\n const response = await fetch(`${BASE_URL}/api/cli/tool`, {\n method: \"GET\",\n });\n\n const result = (await response.json()) as {\n success: boolean;\n tools?: Tool[];\n error?: string;\n };\n\n spinner?.stop();\n spinner?.clear();\n\n if (!response.ok || !result.success) {\n outputError(result.error ?? \"Failed to list tools\", options);\n process.exit(1);\n }\n\n const tools = result.tools ?? [];\n\n if (options.json) {\n outputSuccess(tools, options);\n } else {\n console.log(chalk.bold(`Available Tools (${tools.length}):\\n`));\n\n for (const tool of tools) {\n console.log(chalk.cyan(` ${tool.name}`));\n console.log(chalk.dim(` ${tool.description}`));\n if (tool.inputs.length > 0) {\n console.log(chalk.dim(` Inputs: ${tool.inputs.join(\", \")}`));\n }\n console.log();\n }\n\n console.log(chalk.dim(\"Usage: program tool exec <toolName> --project <id> --params '{...}'\"));\n }\n } catch (error) {\n spinner?.stop();\n spinner?.clear();\n outputError(error instanceof Error ? error.message : \"Request failed\", options);\n process.exit(1);\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { ensureValidToken } from \"../../lib/auth/index.js\";\nimport { oauthConfig, BASE_URL } from \"../../lib/config.js\";\nimport { outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\nimport { detectAgentSource } from \"../../lib/agent-detect.js\";\n\nexport interface SendMessageOptions extends OutputOptions {\n project: string;\n role?: \"user\" | \"assistant\";\n}\n\nexport async function sendCommand(\n text: string,\n options: SendMessageOptions\n): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Sending message...\").start() : null;\n\n // Get valid access token\n const accessToken = ensureValidToken(oauthConfig);\n if (!accessToken) {\n spinner?.stop();\n spinner?.clear();\n outputError(\"Not authenticated. Run 'program auth login' first.\", options);\n process.exit(1);\n }\n\n const role = options.role ?? \"assistant\";\n\n // Detect agent at runtime (not login time) for correct multi-agent support\n const source = detectAgentSource();\n\n try {\n const response = await fetch(`${BASE_URL}/api/cli/message`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify({\n projectId: options.project,\n role,\n text,\n source,\n }),\n });\n\n const result = (await response.json()) as {\n success: boolean;\n messageId?: string;\n error?: string;\n };\n\n spinner?.stop();\n spinner?.clear();\n\n if (!response.ok || !result.success) {\n outputError(result.error ?? `Failed to send message: ${response.status}`, options);\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess({ messageId: result.messageId, role, text }, options);\n } else {\n console.log(chalk.green(`✓ Message sent as ${role}`));\n if (result.messageId) {\n console.log(chalk.dim(` Message ID: ${result.messageId}`));\n }\n }\n } catch (error) {\n spinner?.stop();\n spinner?.clear();\n outputError(error instanceof Error ? error.message : \"Request failed\", options);\n process.exit(1);\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { ensureValidToken } from \"../../lib/auth/index.js\";\nimport { oauthConfig, BASE_URL } from \"../../lib/config.js\";\nimport { outputError, outputSuccess } from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\n\nexport interface ListMessageOptions extends OutputOptions {\n project: string;\n limit?: number;\n}\n\ninterface MessagePart {\n type: string;\n text?: string;\n toolName?: string;\n toolCallId?: string;\n state?: string;\n}\n\ninterface Message {\n id: string;\n role: \"user\" | \"assistant\";\n parts: MessagePart[];\n source?: string;\n createdAt: number;\n}\n\nexport async function listCommand(options: ListMessageOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching messages...\").start() : null;\n\n // Get valid access token\n const accessToken = ensureValidToken(oauthConfig);\n if (!accessToken) {\n spinner?.stop();\n spinner?.clear();\n outputError(\n \"Not authenticated. Run 'program auth login' first.\",\n options\n );\n process.exit(1);\n }\n\n try {\n const url = new URL(`${BASE_URL}/api/cli/message`);\n url.searchParams.set(\"projectId\", options.project);\n if (options.limit) {\n url.searchParams.set(\"limit\", options.limit.toString());\n }\n\n const response = await fetch(url.toString(), {\n method: \"GET\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n const result = (await response.json()) as {\n success: boolean;\n chatId?: string;\n messages?: Message[];\n error?: string;\n };\n\n spinner?.stop();\n spinner?.clear();\n\n if (!response.ok || !result.success) {\n outputError(\n result.error ?? `Failed to fetch messages: ${response.status}`,\n options\n );\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess(result, options);\n } else {\n const messages = result.messages ?? [];\n if (messages.length === 0) {\n console.log(chalk.dim(\"No messages in this chat yet.\"));\n return;\n }\n\n console.log(chalk.bold(`Chat Messages (${messages.length}):\\n`));\n\n for (const msg of messages) {\n // Format the role with source if available\n let roleLabel = msg.role === \"user\" ? \"You\" : \"Assistant\";\n if (msg.source) {\n if (msg.source === \"cli:claude-code\") {\n roleLabel = \"Claude via CLI\";\n } else if (msg.source === \"cli:codex\") {\n roleLabel = \"Codex via CLI\";\n } else if (msg.source.startsWith(\"cli:\")) {\n roleLabel = `${roleLabel} via CLI`;\n }\n }\n\n // Get text content from parts\n const textContent = msg.parts\n .filter((p): p is MessagePart & { text: string } => p.type === \"text\" && !!p.text)\n .map((p) => p.text)\n .join(\"\\n\");\n\n // Get tool calls\n const toolCalls = msg.parts.filter(\n (p) => p.type === \"tool-invocation\" || p.type === \"tool-call\"\n );\n\n // Format timestamp\n const time = new Date(msg.createdAt).toLocaleTimeString();\n\n // Print message\n const roleColor = msg.role === \"user\" ? chalk.blue : chalk.green;\n console.log(roleColor(`[${time}] ${roleLabel}:`));\n\n if (textContent) {\n // Indent and truncate long messages\n const truncated =\n textContent.length > 500\n ? textContent.substring(0, 500) + \"...\"\n : textContent;\n console.log(\n truncated\n .split(\"\\n\")\n .map((line) => ` ${line}`)\n .join(\"\\n\")\n );\n }\n\n if (toolCalls.length > 0) {\n console.log(\n chalk.dim(` [${toolCalls.length} tool call(s)]`)\n );\n }\n\n console.log();\n }\n }\n } catch (error) {\n spinner?.stop();\n spinner?.clear();\n outputError(\n error instanceof Error ? error.message : \"Request failed\",\n options\n );\n process.exit(1);\n }\n}\n","import { outputSuccess } from \"../lib/output.js\";\nimport type {OutputOptions} from \"../lib/output.js\";\n\nexport interface DocsOptions extends OutputOptions {\n schema?: boolean;\n}\n\n// Command schema for agents\nconst COMMAND_SCHEMA = {\n name: \"program\",\n version: \"0.1.0\",\n description: \"CLI for interacting with the Program video creation platform\",\n commands: {\n auth: {\n description: \"Authentication commands\",\n subcommands: {\n login: {\n description: \"Authenticate with the Program platform\",\n options: {\n \"--json\": \"Output as JSON\",\n },\n example: \"program auth login\",\n },\n logout: {\n description: \"Log out from the Program platform\",\n options: {\n \"--json\": \"Output as JSON\",\n },\n example: \"program auth logout\",\n },\n status: {\n description: \"Check authentication status\",\n options: {\n \"--json\": \"Output as JSON\",\n },\n example: \"program auth status --json\",\n },\n },\n },\n project: {\n description: \"Project management commands\",\n subcommands: {\n create: {\n description: \"Create a new project\",\n options: {\n \"--title <title>\": \"Project title\",\n \"--description <desc>\": \"Project description\",\n \"--json\": \"Output as JSON\",\n },\n example: 'program project create --title \"My Video\" --json',\n },\n list: {\n description: \"List projects\",\n options: {\n \"--limit <n>\": \"Maximum number of projects to return\",\n \"--json\": \"Output as JSON\",\n },\n example: \"program project list --json\",\n },\n },\n },\n workflow: {\n description: \"Workflow template commands\",\n subcommands: {\n list: {\n description: \"List available workflow templates\",\n options: {\n \"--limit <n>\": \"Maximum number of templates to return\",\n \"--public-only\": \"Only show public templates\",\n \"--json\": \"Output as JSON\",\n },\n example: \"program workflow list --json\",\n },\n run: {\n description: \"Execute a workflow template\",\n args: {\n templateId: \"ID of the template to run\",\n },\n options: {\n \"--project <id>\": \"Project ID to associate with execution\",\n \"--input <json>\": \"JSON input for the workflow\",\n \"--json\": \"Output as JSON\",\n },\n example: \"program workflow run tmpl_abc --project proj_123 --input '{\\\"files\\\":[\\\"src/main.ts\\\"]}' --json\",\n },\n status: {\n description: \"Check workflow execution status\",\n args: {\n executionId: \"ID of the execution to check\",\n },\n options: {\n \"--watch\": \"Continuously poll for status updates\",\n \"--interval <ms>\": \"Poll interval in milliseconds (default: 2000)\",\n \"--json\": \"Output as JSON\",\n },\n example: \"program workflow status exec_789 --watch --json\",\n },\n },\n },\n docs: {\n description: \"Display CLI documentation\",\n options: {\n \"--schema\": \"Output full command schema as JSON\",\n },\n example: \"program docs --schema\",\n },\n },\n globalOptions: {\n \"--help\": \"Display help information\",\n \"--version\": \"Display version number\",\n },\n notes: [\n \"Always use --json flag for parseable output when integrating with agents\",\n \"Workflow inputs should be valid JSON strings\",\n \"Run 'program auth login' first to authenticate\",\n ],\n};\n\nexport function docsCommand(options: DocsOptions): void {\n if (options.schema ?? options.json) {\n outputSuccess(COMMAND_SCHEMA, { json: true });\n } else {\n printHumanDocs();\n }\n}\n\nfunction printHumanDocs(): void {\n console.log(`\nProgram CLI v${COMMAND_SCHEMA.version}\n${COMMAND_SCHEMA.description}\n\nCOMMANDS:\n\n auth login Authenticate with the Program platform\n auth logout Log out from the Program platform\n auth status Check authentication status\n\n project create Create a new project\n project list List projects\n\n workflow list List available workflow templates\n workflow run <id> Execute a workflow template\n workflow status <id> Check workflow execution status\n\n docs Display this documentation\n docs --schema Output full command schema as JSON\n\nGLOBAL OPTIONS:\n\n --json Output as JSON (recommended for agents)\n --help Display help information\n --version Display version number\n\nEXAMPLES:\n\n # Authenticate\n program auth login\n\n # Create a project\n program project create --title \"My Video\" --json\n\n # Run a workflow\n program workflow run tmpl_abc --project proj_123 --json\n\n # Watch execution progress\n program workflow status exec_789 --watch --json\n\nFor agent integration, always use the --json flag.\n`);\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,SAAS,qBAAqB;;;ACD9B,OAAOA,YAAW;AAClB,OAAO,UAAU;AACjB,OAAO,SAAS;;;ACFhB,OAAO,UAAU;AACjB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,QAAQ;AAYpB,IAAM,kBAAuB,UAAQ,WAAQ,GAAG,UAAU;AAC1D,IAAM,mBAAwB,UAAK,iBAAiB,kBAAkB;AAGtE,SAAS,uBAA6B;AACpC,MAAI,CAAI,cAAW,eAAe,GAAG;AACnC,IAAG,aAAU,iBAAiB,EAAE,MAAM,KAAO,WAAW,KAAK,CAAC;AAAA,EAChE;AACF;AAGA,IAAM,Q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AO,MAAc,YAAgC;AAC3D,QAAM,YAAmB,MAAM,OAAO;AACxC,CAAC;AAGH,QACG,QAAQ,MAAM,EACd,YAAY,8CAA8C,EAC1D,OAAO,YAAY,oCAAoC,EACvD,OAAO,UAAU,gBAAgB,EACjC,OAAO,CAAC,YAAyB;AAChC,cAAY,OAAO;AACrB,CAAC;AAGH,QAAQ,MAAM;","names":["chalk","message","chalk","message","chalk","chalk","minutes","chalk","ora","ora","chalk","chalk","ora","ora","project","chalk","chalk","ora","ora","chalk","chalk","ora","listCommand","ora","chalk","chalk","ora","ora","chalk","chalk","ora","statusCommand","ora","chalk","chalk","ora","fs","path","ora","chalk","chalk","ora","listCommand","ora","chalk","tool","chalk","ora","ora","chalk","chalk","ora","listCommand","ora","chalk","require","listCommand","statusCommand"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/commands/auth/login.ts","../src/lib/auth/credentials.ts","../src/lib/auth/device.ts","../src/lib/config.ts","../src/lib/output.ts","../src/commands/auth/logout.ts","../src/commands/auth/status.ts","../src/commands/project/create.ts","../src/lib/auth/oauth.ts","../src/lib/convex.ts","../src/commands/project/get.ts","../src/commands/project/list.ts","../src/commands/workflow/list.ts","../src/commands/workflow/run.ts","../src/commands/workflow/status.ts","../src/commands/tool/execute.ts","../src/lib/agent-detect.ts","../src/commands/tool/list.ts","../src/commands/message/send.ts","../src/commands/message/list.ts","../src/commands/docs.ts","../src/commands/template/list.ts","../src/commands/template/get.ts","../src/lib/context.ts","../src/commands/template/create.ts","../src/commands/template/update.ts","../src/commands/template/remove.ts","../src/commands/template/run.ts","../src/commands/template/status.ts","../src/commands/template/use.ts","../src/commands/template/step/list.ts","../src/commands/template/step/info.ts","../src/commands/template/step/add.ts","../src/commands/template/step/remove.ts","../src/commands/template/step/update.ts","../src/commands/template/model/list.ts","../src/commands/template/model/schema.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { createRequire } from \"node:module\";\nimport { loginCommand } from \"./commands/auth/login.js\";\nimport type { LoginOptions } from \"./commands/auth/login.js\";\nimport { logoutCommand } from \"./commands/auth/logout.js\";\nimport type { LogoutOptions } from \"./commands/auth/logout.js\";\nimport { statusCommand as authStatusCommand } from \"./commands/auth/status.js\";\nimport type { StatusOptions as AuthStatusOptions } from \"./commands/auth/status.js\";\nimport { createCommand as projectCreateCommand } from \"./commands/project/create.js\";\nimport type { CreateOptions } from \"./commands/project/create.js\";\nimport { getCommand as projectGetCommand } from \"./commands/project/get.js\";\nimport type { GetOptions } from \"./commands/project/get.js\";\nimport { listCommand as projectListCommand } from \"./commands/project/list.js\";\nimport type { ListOptions as ProjectListOptions } from \"./commands/project/list.js\";\nimport { listCommand as workflowListCommand } from \"./commands/workflow/list.js\";\nimport type { ListOptions as WorkflowListOptions } from \"./commands/workflow/list.js\";\nimport { runCommand as workflowRunCommand } from \"./commands/workflow/run.js\";\nimport type { RunOptions } from \"./commands/workflow/run.js\";\nimport { statusCommand as workflowStatusCommand } from \"./commands/workflow/status.js\";\nimport type { StatusOptions as WorkflowStatusOptions } from \"./commands/workflow/status.js\";\nimport { executeCommand as toolExecuteCommand } from \"./commands/tool/execute.js\";\nimport type { ExecuteOptions } from \"./commands/tool/execute.js\";\nimport { listCommand as toolListCommand } from \"./commands/tool/list.js\";\nimport type { ListOptions as ToolListOptions } from \"./commands/tool/list.js\";\nimport { sendCommand as messageSendCommand } from \"./commands/message/send.js\";\nimport type { SendMessageOptions } from \"./commands/message/send.js\";\nimport { listCommand as messageListCommand } from \"./commands/message/list.js\";\nimport type { ListMessageOptions } from \"./commands/message/list.js\";\nimport { docsCommand } from \"./commands/docs.js\";\nimport type { DocsOptions } from \"./commands/docs.js\";\n\n// Template command imports\nimport { listCommand as templateListCommand } from \"./commands/template/list.js\";\nimport type { ListOptions as TemplateListOptions } from \"./commands/template/list.js\";\nimport { getCommand as templateGetCommand } from \"./commands/template/get.js\";\nimport type { GetOptions as TemplateGetOptions } from \"./commands/template/get.js\";\nimport { createCommand as templateCreateCommand } from \"./commands/template/create.js\";\nimport type { CreateOptions as TemplateCreateOptions } from \"./commands/template/create.js\";\nimport { updateCommand as templateUpdateCommand } from \"./commands/template/update.js\";\nimport type { UpdateOptions as TemplateUpdateOptions } from \"./commands/template/update.js\";\nimport { removeCommand as templateRemoveCommand } from \"./commands/template/remove.js\";\nimport type { RemoveOptions as TemplateRemoveOptions } from \"./commands/template/remove.js\";\nimport { runCommand as templateRunCommand } from \"./commands/template/run.js\";\nimport type { RunOptions as TemplateRunOptions } from \"./commands/template/run.js\";\nimport { statusCommand as templateStatusCommand } from \"./commands/template/status.js\";\nimport type { StatusOptions as TemplateStatusOptions } from \"./commands/template/status.js\";\nimport { useCommand as templateUseCommand } from \"./commands/template/use.js\";\nimport type { UseOptions as TemplateUseOptions } from \"./commands/template/use.js\";\n\n// Template step command imports\nimport { stepListCommand } from \"./commands/template/step/list.js\";\nimport type { StepListOptions } from \"./commands/template/step/list.js\";\nimport { stepInfoCommand } from \"./commands/template/step/info.js\";\nimport type { StepInfoOptions } from \"./commands/template/step/info.js\";\nimport { stepAddCommand } from \"./commands/template/step/add.js\";\nimport type { StepAddOptions } from \"./commands/template/step/add.js\";\nimport { stepRemoveCommand } from \"./commands/template/step/remove.js\";\nimport type { StepRemoveOptions } from \"./commands/template/step/remove.js\";\nimport { stepUpdateCommand } from \"./commands/template/step/update.js\";\nimport type { StepUpdateOptions } from \"./commands/template/step/update.js\";\n\n// Template model command imports\nimport { modelListCommand } from \"./commands/template/model/list.js\";\nimport type { ModelListOptions } from \"./commands/template/model/list.js\";\nimport { modelSchemaCommand } from \"./commands/template/model/schema.js\";\nimport type { ModelSchemaOptions } from \"./commands/template/model/schema.js\";\n\nconst program = new Command();\nconst require = createRequire(import.meta.url);\nconst packageJson = require(\"../package.json\") as { version: string };\n\nprogram\n .name(\"program\")\n .description(\"CLI for the Program video creation platform\")\n .version(packageJson.version);\n\n// Auth commands\nconst auth = program.command(\"auth\").description(\"Authentication commands\");\n\nauth\n .command(\"login\")\n .description(\"Authenticate with the Program platform\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: LoginOptions) => {\n await loginCommand(options);\n });\n\nauth\n .command(\"logout\")\n .description(\"Log out from the Program platform\")\n .option(\"--json\", \"Output as JSON\")\n .action((options: LogoutOptions) => {\n logoutCommand(options);\n });\n\nauth\n .command(\"status\")\n .description(\"Check authentication status\")\n .option(\"--json\", \"Output as JSON\")\n .action((options: AuthStatusOptions) => {\n authStatusCommand(options);\n });\n\n// Project commands\nconst project = program.command(\"project\").description(\"Project management commands\");\n\nproject\n .command(\"create\")\n .description(\"Create a new project\")\n .option(\"--title <title>\", \"Project title\")\n .option(\"--description <description>\", \"Project description\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: CreateOptions) => {\n await projectCreateCommand(options);\n });\n\nproject\n .command(\"list\")\n .description(\"List projects\")\n .option(\"--limit <limit>\", \"Maximum number of projects to return\", parseInt)\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: ProjectListOptions) => {\n await projectListCommand(options);\n });\n\nproject\n .command(\"get <id>\")\n .description(\"Get project details including composition\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (id: string, options: GetOptions) => {\n await projectGetCommand(id, options);\n });\n\n// Workflow commands (deprecated — use 'template' commands instead)\nconst workflow = program.command(\"workflow\").description(\"Workflow template commands (use 'template' for full management)\");\n\nworkflow\n .command(\"list\")\n .description(\"List available workflow templates\")\n .option(\"--limit <limit>\", \"Maximum number of templates to return\", parseInt)\n .option(\"--public-only\", \"Only show public templates\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: WorkflowListOptions) => {\n await workflowListCommand(options);\n });\n\nworkflow\n .command(\"run <templateId>\")\n .description(\"Execute a workflow template\")\n .option(\"--project <projectId>\", \"Project ID to associate with execution\")\n .option(\"--input <json>\", \"JSON input for the workflow\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (templateId: string, options: RunOptions) => {\n await workflowRunCommand(templateId, options);\n });\n\nworkflow\n .command(\"status <executionId>\")\n .description(\"Check workflow execution status\")\n .option(\"--watch\", \"Continuously poll for status updates\")\n .option(\"--interval <ms>\", \"Poll interval in milliseconds\", parseInt)\n .option(\"--json\", \"Output as JSON\")\n .action(async (executionId: string, options: WorkflowStatusOptions) => {\n await workflowStatusCommand(executionId, options);\n });\n\n// Template commands\nconst template = program.command(\"template\").description(\"Template management commands\");\n\ntemplate\n .command(\"list\")\n .description(\"List templates\")\n .option(\"--public-only\", \"Only show public templates\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: TemplateListOptions) => {\n await templateListCommand(options);\n });\n\ntemplate\n .command(\"get [id]\")\n .description(\"Get template details (uses active template if no ID)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (id: string | undefined, options: TemplateGetOptions) => {\n await templateGetCommand(id, options);\n });\n\ntemplate\n .command(\"create\")\n .description(\"Create a new template (auto-sets as active)\")\n .requiredOption(\"--name <name>\", \"Template name\")\n .option(\"--description <description>\", \"Template description\")\n .option(\"--public\", \"Make template public\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: TemplateCreateOptions) => {\n await templateCreateCommand(options);\n });\n\ntemplate\n .command(\"update [id]\")\n .description(\"Update template metadata (uses active template if no ID)\")\n .option(\"--name <name>\", \"New template name\")\n .option(\"--description <description>\", \"New template description\")\n .option(\"--public\", \"Make template public\")\n .option(\"--steps <json>\", \"Replace steps array with JSON\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (id: string | undefined, options: TemplateUpdateOptions) => {\n await templateUpdateCommand(id, options);\n });\n\ntemplate\n .command(\"remove [id]\")\n .description(\"Delete a template (uses active template if no ID)\")\n .option(\"--force\", \"Skip confirmation prompt\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (id: string | undefined, options: TemplateRemoveOptions) => {\n await templateRemoveCommand(id, options);\n });\n\ntemplate\n .command(\"run [id]\")\n .description(\"Execute a template (uses active template if no ID)\")\n .option(\"--project <projectId>\", \"Project ID to associate with execution\")\n .option(\"--input <json>\", \"JSON input for the workflow\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (id: string | undefined, options: TemplateRunOptions) => {\n await templateRunCommand(id, options);\n });\n\ntemplate\n .command(\"status <executionId>\")\n .description(\"Check execution status\")\n .option(\"--watch\", \"Continuously poll for status updates\")\n .option(\"--interval <ms>\", \"Poll interval in milliseconds\", parseInt)\n .option(\"--json\", \"Output as JSON\")\n .action(async (executionId: string, options: TemplateStatusOptions) => {\n await templateStatusCommand(executionId, options);\n });\n\ntemplate\n .command(\"use <id>\")\n .description(\"Set the active template context\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (id: string, options: TemplateUseOptions) => {\n await templateUseCommand(id, options);\n });\n\n// Template step subgroup\nconst step = template.command(\"step\").description(\"Manage template steps and discover step types\");\n\nstep\n .command(\"list\")\n .description(\"List available step types\")\n .option(\"--category <category>\", \"Filter by category\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: StepListOptions) => {\n await stepListCommand(options);\n });\n\nstep\n .command(\"info <stepType>\")\n .description(\"Show step type details (inputs, outputs)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (stepType: string, options: StepInfoOptions) => {\n await stepInfoCommand(stepType, options);\n });\n\nstep\n .command(\"add <stepType>\")\n .description(\"Add a step to the active template\")\n .option(\"--config <json>\", \"Step configuration as JSON\")\n .option(\"--at <position>\", \"Insert at position (0-indexed)\", parseInt)\n .option(\"--after <id>\", \"Insert after step with this ID\")\n .option(\"--template <id>\", \"Template ID (overrides active template)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (stepType: string, options: StepAddOptions) => {\n await stepAddCommand(stepType, options);\n });\n\nstep\n .command(\"remove <id>\")\n .description(\"Remove a step by its instance ID\")\n .option(\"--template <id>\", \"Template ID (overrides active template)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (id: string, options: StepRemoveOptions) => {\n await stepRemoveCommand(id, options);\n });\n\nstep\n .command(\"update <id>\")\n .description(\"Update a step's config by its instance ID\")\n .option(\"--config <json>\", \"Config to merge as JSON\")\n .option(\"--template <id>\", \"Template ID (overrides active template)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (id: string, options: StepUpdateOptions) => {\n await stepUpdateCommand(id, options);\n });\n\n// Template model subgroup\nconst model = template.command(\"model\").description(\"Browse models and schemas\");\n\nmodel\n .command(\"list <category>\")\n .description(\"List models for a category (image, video, speech, text)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (category: string, options: ModelListOptions) => {\n await modelListCommand(category, options);\n });\n\nmodel\n .command(\"schema <modelId>\")\n .description(\"Show full input schema for a model\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (modelId: string, options: ModelSchemaOptions) => {\n await modelSchemaCommand(modelId, options);\n });\n\n// Tool commands (direct agent tool access)\nconst tool = program.command(\"tool\").description(\"Execute agent tools directly\");\ntool.addHelpText(\n \"after\",\n `\nAgent Hint:\n Start with:\n program tool exec assessComposition --project <projectId> --params '{}'\n Then inspect models before generation:\n program tool exec listImageModels --project <projectId> --params '{}'\n program tool exec listSpeechModels --project <projectId> --params '{}'`,\n);\n\ntool\n .command(\"list\")\n .description(\"List available agent tools\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: ToolListOptions) => {\n await toolListCommand(options);\n });\n\nconst toolExec = tool\n .command(\"exec <toolName>\")\n .description(\"Execute an agent tool\")\n .requiredOption(\"--project <projectId>\", \"Project ID to execute tool against\")\n .option(\"--params <json>\", \"JSON parameters for the tool\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (toolName: string, options: ExecuteOptions) => {\n await toolExecuteCommand(toolName, options);\n });\n\ntoolExec.addHelpText(\n \"after\",\n `\nUpload examples:\n Path-based upload (recommended for larger files):\n program tool exec uploadFile --project <projectId> --params '{\"path\":\"/tmp/recording.mp4\",\"category\":\"video\"}'\n Base64 upload:\n program tool exec uploadFile --project <projectId> --params '{\"fileName\":\"notes.txt\",\"mimeType\":\"text/plain\",\"dataBase64\":\"SGVsbG8=\"}'`,\n);\n\n// Message commands (send and list messages in project chat)\nconst message = program.command(\"message\").description(\"Manage messages in project chat\");\n\nmessage\n .command(\"list\")\n .description(\"List messages in the project chat\")\n .requiredOption(\"--project <projectId>\", \"Project ID to list messages from\")\n .option(\"--limit <limit>\", \"Maximum number of messages to return\", parseInt)\n .option(\"--json\", \"Output as JSON\")\n .action(async (options: ListMessageOptions) => {\n await messageListCommand(options);\n });\n\nmessage\n .command(\"send <text>\")\n .description(\n \"Log a text message to the project chat. NOTE: This only adds a message to the chat history - it does NOT trigger the AI agent. To perform actions, use 'tool exec' instead.\",\n )\n .requiredOption(\"--project <projectId>\", \"Project ID to send message to\")\n .option(\"--role <role>\", \"Message role: user or assistant (default: assistant)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (text: string, options: SendMessageOptions) => {\n await messageSendCommand(text, options);\n });\n\n// Docs command\nprogram\n .command(\"docs\")\n .description(\"Display CLI documentation and command schema\")\n .option(\"--schema\", \"Output full command schema as JSON\")\n .option(\"--json\", \"Output as JSON\")\n .action((options: DocsOptions) => {\n docsCommand(options);\n });\n\n// Parse arguments\nprogram.parse();\n","import chalk from \"chalk\";\nimport open from \"open\";\nimport ora from \"ora\";\nimport { startDeviceAuth } from \"../../lib/auth/device.js\";\nimport { oauthConfig } from \"../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\n\nexport type LoginOptions = OutputOptions;\n\n/**\n * Format user code with dash for readability (ABCD1234 -> ABCD-1234)\n */\nfunction formatUserCode(code: string): string {\n if (code.length === 8) {\n return `${code.slice(0, 4)}-${code.slice(4)}`;\n }\n return code;\n}\n\n/**\n * Device authorization flow - works everywhere including headless environments\n * User visits a URL on any device and enters the code shown in the terminal\n */\nexport async function loginCommand(options: LoginOptions): Promise<void> {\n const showSpinner = process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Requesting device code...\").start() : null;\n\n try {\n const deviceAuth = await startDeviceAuth(oauthConfig);\n spinner?.stop();\n spinner?.clear();\n\n // Try to open the browser automatically (use base URL, not the one with code embedded)\n // User must manually enter the code for security\n void open(deviceAuth.verificationUrl).catch(() => {\n // Silently ignore - URL is displayed below for manual access\n });\n\n // Always display the code and URL (essential for agents/headless environments)\n console.log();\n console.log(chalk.bold(\" Sign in to Program\"));\n console.log();\n console.log(` URL: ${chalk.cyan(deviceAuth.verificationUrl)}`);\n console.log(` Code: ${chalk.bold.yellow(formatUserCode(deviceAuth.userCode))}`);\n console.log();\n console.log(chalk.dim(\" Enter the code above in your browser to authorize.\"));\n console.log();\n\n const waitingSpinner = showSpinner ? ora(\"Waiting for authorization...\").start() : null;\n\n // Poll until the user completes auth\n const credentials = await deviceAuth.pollForCompletion();\n\n waitingSpinner?.stop();\n waitingSpinner?.clear();\n\n if (options.json) {\n outputSuccess(\n {\n authenticated: true,\n email: credentials.email,\n userId: credentials.userId,\n organizationId: credentials.organizationId,\n },\n options\n );\n } else {\n console.log(formatSuccess(`Authenticated as ${chalk.cyan(credentials.email)}`));\n if (credentials.organizationId) {\n console.log(chalk.dim(` Organization: ${credentials.organizationId}`));\n }\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Authentication failed\";\n outputError(message, options);\n process.exit(1);\n }\n}\n","import Conf from \"conf\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as os from \"node:os\";\n\nexport interface Credentials {\n accessToken: string;\n refreshToken: string;\n expiresAt: number;\n userId: string;\n organizationId: string;\n email: string;\n}\n\n// Use ~/.program/ for credentials storage\nconst CREDENTIALS_DIR = path.join(os.homedir(), \".program\");\nconst CREDENTIALS_FILE = path.join(CREDENTIALS_DIR, \"credentials.json\");\n\n// Ensure directory exists with proper permissions\nfunction ensureCredentialsDir(): void {\n if (!fs.existsSync(CREDENTIALS_DIR)) {\n fs.mkdirSync(CREDENTIALS_DIR, { mode: 0o700, recursive: true });\n }\n}\n\n// Using conf for secure credential storage with automatic file permissions\nconst store = new Conf<{ credentials: Credentials | null }>({\n projectName: \"program-cli\",\n cwd: CREDENTIALS_DIR,\n configName: \"credentials\",\n fileExtension: \"json\",\n defaults: {\n credentials: null,\n },\n});\n\nexport function saveCredentials(credentials: Credentials): void {\n ensureCredentialsDir();\n store.set(\"credentials\", credentials);\n\n // Ensure file has restrictive permissions (owner read/write only)\n try {\n fs.chmodSync(CREDENTIALS_FILE, 0o600);\n } catch {\n // Ignore chmod errors on Windows\n }\n}\n\nexport function getCredentials(): Credentials | null {\n return store.get(\"credentials\");\n}\n\nexport function clearCredentials(): void {\n store.delete(\"credentials\");\n}\n\nexport function isAuthenticated(): boolean {\n const creds = getCredentials();\n if (!creds) return false;\n\n // Check if token is expired (with 5 minute buffer)\n const now = Date.now();\n const expiresAt = creds.expiresAt * 1000; // Convert to milliseconds\n const bufferMs = 5 * 60 * 1000; // 5 minutes\n\n return now < expiresAt - bufferMs;\n}\n\nexport function needsRefresh(): boolean {\n const creds = getCredentials();\n if (!creds) return false;\n\n // Needs refresh if within 5 minutes of expiry\n const now = Date.now();\n const expiresAt = creds.expiresAt * 1000;\n const bufferMs = 5 * 60 * 1000;\n\n return now >= expiresAt - bufferMs && now < expiresAt;\n}\n","import { saveCredentials, getCredentials } from \"./credentials.js\";\nimport type { Credentials } from \"./credentials.js\";\n\n// OAuth client ID - same as the main oauth.ts\nconst CLIENT_ID = \"program-cli\";\nconst SCOPES = [\"openid\", \"profile\", \"email\", \"offline_access\"];\n\nexport interface DeviceAuthConfig {\n baseUrl: string;\n}\n\ninterface DeviceCodeResponse {\n device_code: string;\n user_code: string;\n verification_uri: string;\n verification_uri_complete?: string;\n expires_in: number;\n interval: number;\n}\n\ninterface TokenResponse {\n access_token: string;\n refresh_token?: string;\n expires_in?: number;\n token_type?: string;\n scope?: string;\n}\n\ninterface TokenErrorResponse {\n error: string;\n error_description?: string;\n}\n\ninterface UserInfo {\n id: string;\n email: string;\n name: string;\n organizationId?: string;\n}\n\n/**\n * Request a device code from the server\n */\nexport async function requestDeviceCode(\n config: DeviceAuthConfig\n): Promise<DeviceCodeResponse> {\n const url = new URL(\"/api/auth/device/code\", config.baseUrl);\n\n const response = await fetch(url.toString(), {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n client_id: CLIENT_ID,\n scope: SCOPES.join(\" \"),\n }),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Failed to get device code: ${response.status} ${errorText}`);\n }\n\n return response.json() as Promise<DeviceCodeResponse>;\n}\n\n/**\n * Poll for the token after user authorizes\n * Returns the token response or an error code\n */\nexport async function pollForToken(\n config: DeviceAuthConfig,\n deviceCode: string\n): Promise<TokenResponse | TokenErrorResponse> {\n const url = new URL(\"/api/auth/device/token\", config.baseUrl);\n\n const response = await fetch(url.toString(), {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n device_code: deviceCode,\n client_id: CLIENT_ID,\n }),\n });\n\n // Device flow uses 400 status for pending/slow_down errors\n const data = (await response.json()) as TokenResponse | TokenErrorResponse;\n\n if (!response.ok) {\n // Check if it's an expected error (authorization_pending, slow_down)\n if (\"error\" in data) {\n return data;\n }\n throw new Error(`Token request failed: ${response.status}`);\n }\n\n return data as TokenResponse;\n}\n\n/**\n * Get user info from the BetterAuth session endpoint\n * Device authorization returns a BetterAuth token, not an OIDC token\n */\nasync function getUserInfo(\n config: DeviceAuthConfig,\n accessToken: string\n): Promise<UserInfo> {\n // Use the BetterAuth get-session endpoint with Bearer token\n const sessionUrl = new URL(\"/api/auth/get-session\", config.baseUrl);\n\n const response = await fetch(sessionUrl.toString(), {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n // Try the token/session endpoint if get-session doesn't work\n const tokenUrl = new URL(\"/api/auth/token\", config.baseUrl);\n const tokenResponse = await fetch(tokenUrl.toString(), {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!tokenResponse.ok) {\n throw new Error(`Failed to get user info: ${response.status}`);\n }\n\n const tokenData = (await tokenResponse.json()) as {\n user?: { id?: string; email?: string; name?: string };\n session?: { activeOrganizationId?: string };\n };\n\n if (!tokenData.user?.id || !tokenData.user.email) {\n throw new Error(\"Invalid token response: missing user info\");\n }\n\n return {\n id: tokenData.user.id,\n email: tokenData.user.email,\n name: tokenData.user.name ?? tokenData.user.email,\n organizationId: tokenData.session?.activeOrganizationId,\n };\n }\n\n const data = (await response.json()) as {\n user?: {\n id?: string;\n email?: string;\n name?: string;\n };\n session?: {\n activeOrganizationId?: string;\n };\n };\n\n if (!data.user?.id || !data.user.email) {\n throw new Error(\"Invalid session response: missing user info\");\n }\n\n return {\n id: data.user.id,\n email: data.user.email,\n name: data.user.name ?? data.user.email,\n organizationId: data.session?.activeOrganizationId,\n };\n}\n\n/**\n * Start the device authorization flow\n * Returns display info for the CLI to show the user\n */\nexport interface DeviceAuthDisplay {\n userCode: string;\n verificationUrl: string;\n verificationUrlComplete?: string;\n expiresIn: number;\n interval: number;\n pollForCompletion: () => Promise<Credentials>;\n}\n\nexport async function startDeviceAuth(\n config: DeviceAuthConfig\n): Promise<DeviceAuthDisplay> {\n const deviceCode = await requestDeviceCode(config);\n\n return {\n userCode: deviceCode.user_code,\n verificationUrl: deviceCode.verification_uri,\n verificationUrlComplete: deviceCode.verification_uri_complete,\n expiresIn: deviceCode.expires_in,\n interval: deviceCode.interval,\n pollForCompletion: async () => {\n return pollUntilComplete(config, deviceCode);\n },\n };\n}\n\n/**\n * Poll until the user completes authorization or the code expires\n */\nasync function pollUntilComplete(\n config: DeviceAuthConfig,\n deviceCode: DeviceCodeResponse\n): Promise<Credentials> {\n const startTime = Date.now();\n const expiresAt = startTime + deviceCode.expires_in * 1000;\n let interval = deviceCode.interval * 1000;\n\n while (Date.now() < expiresAt) {\n // Wait for the interval before polling\n await new Promise((resolve) => setTimeout(resolve, interval));\n\n const result = await pollForToken(config, deviceCode.device_code);\n\n // Check if it's an error response\n if (\"error\" in result) {\n switch (result.error) {\n case \"authorization_pending\":\n // User hasn't completed authorization yet, continue polling\n continue;\n\n case \"slow_down\":\n // Server asked us to slow down, increase interval\n interval += 5000;\n continue;\n\n case \"expired_token\":\n throw new Error(\"Device code expired. Please start a new login.\");\n\n case \"access_denied\":\n throw new Error(\"Access denied. You denied the authorization request.\");\n\n default:\n throw new Error(\n result.error_description ?? `Authorization failed: ${result.error}`\n );\n }\n }\n\n // Success! We got tokens\n const tokens = result;\n\n // Get user info\n const userInfo = await getUserInfo(config, tokens.access_token);\n\n // Calculate expiry timestamp (default to 1 hour if not provided)\n const expiresIn = tokens.expires_in ?? 3600;\n const expiresAtTimestamp = Math.floor(Date.now() / 1000) + expiresIn;\n\n // Save credentials (refresh token may not be present for device flow)\n const credentials: Credentials = {\n accessToken: tokens.access_token,\n refreshToken: tokens.refresh_token ?? \"\",\n expiresAt: expiresAtTimestamp,\n userId: userInfo.id,\n organizationId: userInfo.organizationId ?? \"\",\n email: userInfo.email,\n };\n\n saveCredentials(credentials);\n\n return credentials;\n }\n\n throw new Error(\"Device code expired. Please start a new login.\");\n}\n\n/**\n * Check if we have valid credentials\n */\nexport function hasValidCredentials(): boolean {\n const creds = getCredentials();\n if (!creds) return false;\n\n // Check if token is expired (with 5 min buffer)\n const now = Date.now();\n const expiresAt = creds.expiresAt * 1000;\n const bufferMs = 5 * 60 * 1000;\n\n return now < expiresAt - bufferMs;\n}\n","import type { OAuthConfig } from \"./auth/index.js\";\nimport type { ConvexConfig } from \"./convex.js\";\n\n// Production URLs - hardcoded to prevent credential theft via env var manipulation\nexport const BASE_URL = \"https://program.video\";\n\n// Convex deployment URL (production)\nexport const CONVEX_URL = \"https://keen-eel-920.convex.cloud\";\n\nexport const oauthConfig: OAuthConfig = {\n baseUrl: BASE_URL,\n};\n\nexport const convexConfig: ConvexConfig = {\n convexUrl: CONVEX_URL,\n oauthConfig,\n};\n","import chalk from \"chalk\";\n\nexport interface OutputOptions {\n json?: boolean;\n}\n\nexport interface SuccessResult<T> {\n success: true;\n data: T;\n}\n\nexport interface ErrorResult {\n success: false;\n error: string;\n}\n\nexport type Result<T> = SuccessResult<T> | ErrorResult;\n\n/**\n * Output a success result in the appropriate format\n */\nexport function outputSuccess<T>(data: T, options: OutputOptions = {}): void {\n if (options.json) {\n const result: SuccessResult<T> = { success: true, data };\n console.log(JSON.stringify(result, null, 2));\n } else {\n // For human-readable output, we'll handle this per-command\n // This is a fallback that just pretty-prints\n console.log(data);\n }\n}\n\n/**\n * Output an error result in the appropriate format\n */\nexport function outputError(error: string, options: OutputOptions = {}): void {\n if (options.json) {\n const result: ErrorResult = { success: false, error };\n console.log(JSON.stringify(result, null, 2));\n } else {\n console.error(chalk.red(\"Error:\"), error);\n }\n}\n\n/**\n * Format a table for human-readable output\n */\nexport function formatTable(\n headers: string[],\n rows: string[][],\n options: { indent?: number } = {}\n): string {\n const indent = \" \".repeat(options.indent ?? 0);\n\n // Calculate column widths\n const widths = headers.map((h, i) => {\n const maxRow = Math.max(...rows.map((r) => (r[i] ?? \"\").length));\n return Math.max(h.length, maxRow);\n });\n\n // Format header\n const headerLine = headers\n .map((h, i) => chalk.bold(h.padEnd(widths[i] ?? 0)))\n .join(\" \");\n\n // Format separator\n const separator = widths.map((w) => \"-\".repeat(w)).join(\" \");\n\n // Format rows\n const formattedRows = rows.map((row) =>\n row.map((cell, i) => (cell || \"\").padEnd(widths[i] ?? 0)).join(\" \")\n );\n\n return [indent + headerLine, indent + separator, ...formattedRows.map((r) => indent + r)].join(\n \"\\n\"\n );\n}\n\n/**\n * Format a key-value list for human-readable output\n */\nexport function formatKeyValue(\n items: { key: string; value: string }[],\n options: { indent?: number } = {}\n): string {\n const indent = \" \".repeat(options.indent ?? 0);\n const maxKeyLength = Math.max(...items.map((item) => item.key.length));\n\n return items\n .map(\n (item) =>\n indent + chalk.dim(item.key.padEnd(maxKeyLength) + \":\") + \" \" + item.value\n )\n .join(\"\\n\");\n}\n\n/**\n * Format a success message\n */\nexport function formatSuccess(message: string): string {\n return chalk.green(\"✓\") + \" \" + message;\n}\n\n/**\n * Format a warning message\n */\nexport function formatWarning(message: string): string {\n return chalk.yellow(\"⚠\") + \" \" + message;\n}\n\n/**\n * Format an info message\n */\nexport function formatInfo(message: string): string {\n return chalk.blue(\"ℹ\") + \" \" + message;\n}\n","import { clearCredentials, getCredentials } from \"../../lib/auth/credentials.js\";\nimport { formatSuccess, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport type LogoutOptions = OutputOptions;\n\nexport function logoutCommand(options: LogoutOptions): void {\n const credentials = getCredentials();\n\n if (!credentials) {\n if (options.json) {\n outputSuccess({ loggedOut: true, wasAuthenticated: false }, options);\n } else {\n console.log(\"Not currently logged in.\");\n }\n return;\n }\n\n const email = credentials.email;\n clearCredentials();\n\n if (options.json) {\n outputSuccess({ loggedOut: true, wasAuthenticated: true, email }, options);\n } else {\n console.log(formatSuccess(`Logged out from ${email}`));\n }\n}\n","import chalk from \"chalk\";\nimport { getCredentials, isAuthenticated, needsRefresh } from \"../../lib/auth/credentials.js\";\nimport { formatKeyValue, formatSuccess, formatWarning, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport type StatusOptions = OutputOptions;\n\nexport function statusCommand(options: StatusOptions): void {\n const credentials = getCredentials();\n\n if (!credentials) {\n if (options.json) {\n outputSuccess({ authenticated: false }, options);\n } else {\n console.log(\"Not logged in. Run 'program auth login' to authenticate.\");\n }\n return;\n }\n\n const authenticated = isAuthenticated();\n const expiresAt = credentials.expiresAt;\n const now = Math.floor(Date.now() / 1000);\n const expiresIn = expiresAt - now;\n\n if (options.json) {\n outputSuccess(\n {\n authenticated,\n user: credentials.email,\n userId: credentials.userId,\n organizationId: credentials.organizationId,\n expiresAt,\n expiresIn,\n needsRefresh: needsRefresh(),\n },\n options\n );\n } else {\n if (!authenticated) {\n console.log(formatWarning(\"Token expired. Run 'program auth login' to re-authenticate.\"));\n return;\n }\n\n console.log(formatSuccess(\"Logged in\"));\n console.log();\n console.log(\n formatKeyValue([\n { key: \"Email\", value: credentials.email },\n { key: \"User ID\", value: credentials.userId },\n { key: \"Organization\", value: credentials.organizationId || chalk.dim(\"(none)\") },\n { key: \"Token expires\", value: formatExpiresIn(expiresIn) },\n ])\n );\n }\n}\n\nfunction formatExpiresIn(seconds: number): string {\n if (seconds <= 0) {\n return chalk.red(\"expired\");\n }\n\n if (seconds < 60) {\n return chalk.yellow(`in ${seconds} seconds`);\n }\n\n if (seconds < 3600) {\n const minutes = Math.floor(seconds / 60);\n return chalk.green(`in ${minutes} minute${minutes === 1 ? \"\" : \"s\"}`);\n }\n\n const hours = Math.floor(seconds / 3600);\n const minutes = Math.floor((seconds % 3600) / 60);\n return chalk.green(`in ${hours}h ${minutes}m`);\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport interface CreateOptions extends OutputOptions {\n title?: string;\n description?: string;\n}\n\ninterface CreateResult {\n id: string;\n title: string;\n}\n\nexport async function createCommand(options: CreateOptions): Promise<void> {\n // Only show spinner in TTY environments (not through npx/pipes)\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Creating project...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.mutation<string>(\"projects.create\", {\n title: options.title,\n description: options.description,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to create project\", options);\n process.exit(1);\n }\n\n const projectData: CreateResult = {\n id: result.data,\n title: options.title ?? \"Untitled Project\",\n };\n\n if (options.json) {\n outputSuccess(projectData, options);\n } else {\n console.log(formatSuccess(`Created project ${chalk.cyan(projectData.title)}`));\n console.log(chalk.dim(` ID: ${projectData.id}`));\n }\n}\n","import { getCredentials } from \"./credentials.js\";\n\nexport interface OAuthConfig {\n baseUrl: string;\n}\n\n/**\n * Ensure we have a valid access token.\n * For device auth, we don't refresh - user must re-authenticate if expired.\n */\nexport function ensureValidToken(_config: OAuthConfig): string | null {\n const creds = getCredentials();\n if (!creds) {\n return null;\n }\n\n const now = Date.now();\n const expiresAt = creds.expiresAt * 1000;\n const bufferMs = 5 * 60 * 1000; // 5 minutes\n\n // If token is still valid, return it\n if (now < expiresAt - bufferMs) {\n return creds.accessToken;\n }\n\n // Token expired - user needs to re-authenticate\n return null;\n}\n","import { getCredentials, ensureValidToken } from \"./auth/index.js\";\nimport type {OAuthConfig} from \"./auth/index.js\";\n\nexport interface ConvexConfig {\n convexUrl: string;\n oauthConfig: OAuthConfig;\n}\n\nexport interface ConvexResponse<T> {\n success: boolean;\n data?: T;\n error?: string;\n}\n\n/**\n * Create a Convex HTTP client for calling Convex functions via the CLI gateway\n */\nexport function createConvexClient(config: ConvexConfig) {\n const { convexUrl } = config;\n\n // The CLI gateway is on the .convex.site endpoint\n const gatewayUrl = convexUrl.replace(\".convex.cloud\", \".convex.site\");\n\n /**\n * Call a Convex query function via the CLI gateway\n */\n async function query<T>(\n functionPath: string,\n args: Record<string, unknown> = {}\n ): Promise<ConvexResponse<T>> {\n return callGateway<T>(functionPath, args);\n }\n\n /**\n * Call a Convex mutation function via the CLI gateway\n */\n async function mutation<T>(\n functionPath: string,\n args: Record<string, unknown> = {}\n ): Promise<ConvexResponse<T>> {\n return callGateway<T>(functionPath, args);\n }\n\n /**\n * Call a Convex action function via the CLI gateway\n */\n async function action<T>(\n functionPath: string,\n args: Record<string, unknown> = {}\n ): Promise<ConvexResponse<T>> {\n return callGateway<T>(functionPath, args);\n }\n\n /**\n * Call the CLI gateway with OAuth authentication\n */\n async function callGateway<T>(\n functionPath: string,\n args: Record<string, unknown>\n ): Promise<ConvexResponse<T>> {\n // Get valid access token\n const accessToken = ensureValidToken(config.oauthConfig);\n if (!accessToken) {\n return {\n success: false,\n error: \"Not authenticated. Run 'program auth login' first.\",\n };\n }\n\n // Build the gateway URL\n const url = new URL(\"/cli\", gatewayUrl);\n\n try {\n const response = await fetch(url.toString(), {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify({\n fn: functionPath,\n params: args,\n }),\n });\n\n const result = (await response.json()) as {\n success: boolean;\n data?: T;\n error?: string;\n };\n\n if (!response.ok || !result.success) {\n return {\n success: false,\n error: result.error ?? `Gateway error: ${response.status}`,\n };\n }\n\n return { success: true, data: result.data };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }\n\n /**\n * Get the current credentials (for checking auth status)\n */\n function getAuth() {\n return getCredentials();\n }\n\n return {\n query,\n mutation,\n action,\n getAuth,\n };\n}\n\nexport type ConvexClient = ReturnType<typeof createConvexClient>;\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatKeyValue, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport type GetOptions = OutputOptions;\n\ninterface ProjectWithComposition {\n _id: string;\n title: string;\n description?: string;\n createdAt: number;\n updatedAt: number;\n latestVersion: {\n _id: string;\n version: number;\n compositionId: string;\n createdAt: number;\n } | null;\n composition: {\n _id: string;\n title: string;\n description?: string;\n duration: number;\n fps: number;\n width: number;\n height: number;\n sceneCount: number;\n scenes: unknown[];\n } | null;\n}\n\nexport async function getCommand(projectId: string, options: GetOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching project...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<ProjectWithComposition>(\"projects.byId\", {\n id: projectId,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to get project\", options);\n process.exit(1);\n }\n\n const project = result.data;\n\n if (options.json) {\n outputSuccess(project, options);\n } else {\n console.log(chalk.bold(project.title || \"Untitled Project\"));\n if (project.description) {\n console.log(chalk.dim(project.description));\n }\n console.log();\n\n console.log(\n formatKeyValue([\n { key: \"ID\", value: project._id },\n { key: \"Created\", value: new Date(project.createdAt).toLocaleString() },\n { key: \"Updated\", value: new Date(project.updatedAt).toLocaleString() },\n ])\n );\n\n if (project.latestVersion) {\n console.log(chalk.bold(\"\\nVersion\"));\n console.log(\n formatKeyValue([\n { key: \"Version\", value: String(project.latestVersion.version) },\n { key: \"Composition ID\", value: project.latestVersion.compositionId },\n ])\n );\n } else {\n console.log(chalk.dim(\"\\nNo versions yet\"));\n }\n\n if (project.composition) {\n console.log(chalk.bold(\"\\nComposition\"));\n console.log(\n formatKeyValue([\n { key: \"Title\", value: project.composition.title },\n { key: \"Resolution\", value: `${project.composition.width}x${project.composition.height}` },\n { key: \"FPS\", value: String(project.composition.fps) },\n { key: \"Duration\", value: `${(project.composition.duration / 1000).toFixed(1)}s` },\n { key: \"Scenes\", value: String(project.composition.sceneCount) },\n ])\n );\n\n if (project.composition.sceneCount > 0 && Array.isArray(project.composition.scenes)) {\n console.log(chalk.bold(\"\\nScenes\"));\n for (const scene of project.composition.scenes as { id: string; type: string; duration: number }[]) {\n console.log(chalk.dim(` - ${scene.type} (${(scene.duration / 1000).toFixed(1)}s)`));\n }\n }\n } else {\n console.log(chalk.dim(\"\\nNo composition yet\"));\n }\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatTable, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport interface ListOptions extends OutputOptions {\n limit?: number;\n}\n\ninterface Project {\n _id: string;\n title: string;\n description?: string;\n createdAt: number;\n updatedAt: number;\n}\n\ninterface ListResult {\n items: Project[];\n nextCursor: string | null;\n}\n\nexport async function listCommand(options: ListOptions): Promise<void> {\n // Only show spinner in TTY environments (not through npx/pipes)\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching projects...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<ListResult>(\"projects.list\", {\n limit: options.limit,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to list projects\", options);\n process.exit(1);\n }\n\n const projects = result.data.items;\n\n if (options.json) {\n outputSuccess(projects, options);\n } else {\n if (projects.length === 0) {\n console.log(chalk.dim(\"No projects found. Create one with 'program project create'\"));\n return;\n }\n\n console.log(`Found ${chalk.cyan(projects.length)} project${projects.length === 1 ? \"\" : \"s\"}:\\n`);\n\n const rows = projects.map((p) => [\n p._id,\n p.title || chalk.dim(\"Untitled\"),\n formatDate(p.createdAt),\n ]);\n\n console.log(formatTable([\"ID\", \"Title\", \"Created\"], rows));\n }\n}\n\nfunction formatDate(timestamp: number): string {\n const date = new Date(timestamp);\n const now = new Date();\n const diffMs = now.getTime() - date.getTime();\n const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));\n\n if (diffDays === 0) {\n return \"today\";\n } else if (diffDays === 1) {\n return \"yesterday\";\n } else if (diffDays < 7) {\n return `${diffDays} days ago`;\n } else {\n return date.toLocaleDateString();\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatTable, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport interface ListOptions extends OutputOptions {\n limit?: number;\n publicOnly?: boolean;\n}\n\ninterface Template {\n _id: string;\n name: string;\n description?: string;\n public: boolean;\n createdAt: number;\n updatedAt: number;\n}\n\nexport async function listCommand(options: ListOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching workflow templates...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<Template[]>(\"workflows.listTemplates\", {\n category: options.publicOnly ? \"public\" : undefined,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to list templates\", options);\n process.exit(1);\n }\n\n const templates = result.data;\n\n if (options.json) {\n outputSuccess(\n templates.map((t) => ({\n id: t._id,\n name: t.name,\n description: t.description,\n public: t.public,\n })),\n options\n );\n } else {\n if (templates.length === 0) {\n console.log(chalk.dim(\"No workflow templates found.\"));\n return;\n }\n\n console.log(`Found ${chalk.cyan(templates.length)} template${templates.length === 1 ? \"\" : \"s\"}:\\n`);\n\n const rows = templates.map((t) => [\n t._id,\n t.name,\n t.description?.substring(0, 40) ?? chalk.dim(\"No description\"),\n t.public ? chalk.green(\"public\") : chalk.dim(\"private\"),\n ]);\n\n console.log(formatTable([\"ID\", \"Name\", \"Description\", \"Visibility\"], rows));\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport interface RunOptions extends OutputOptions {\n project?: string;\n input?: string;\n}\n\nexport async function runCommand(templateId: string, options: RunOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Starting workflow execution...\").start() : null;\n\n // Parse input JSON if provided\n let input: Record<string, unknown> | undefined;\n if (options.input) {\n try {\n input = JSON.parse(options.input) as Record<string, unknown>;\n } catch {\n spinner?.stop();\n spinner?.clear();\n outputError(\"Invalid JSON in --input parameter\", options);\n process.exit(1);\n }\n }\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.mutation<string>(\"workflows.run\", {\n templateId,\n projectId: options.project,\n input,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to start workflow\", options);\n process.exit(1);\n }\n\n const executionId = result.data;\n\n if (options.json) {\n outputSuccess({ executionId }, options);\n } else {\n console.log(formatSuccess(`Workflow started`));\n console.log(chalk.dim(` Execution ID: ${executionId}`));\n console.log(chalk.dim(` Check status with: program workflow status ${executionId}`));\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatKeyValue, formatSuccess, formatWarning, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport interface StatusOptions extends OutputOptions {\n watch?: boolean;\n interval?: number;\n}\n\ninterface ExecutionStatus {\n status: \"pending\" | \"running\" | \"success\" | \"error\" | \"cancelled\";\n output?: unknown;\n error?: string;\n completedAt?: number;\n nodeStatuses?: { nodeId: string; status: string }[];\n}\n\nexport async function statusCommand(executionId: string, options: StatusOptions): Promise<void> {\n const client = createConvexClient(convexConfig);\n const pollInterval = options.interval ?? 2000;\n\n if (options.watch) {\n await watchStatus(client, executionId, pollInterval, options);\n } else {\n await getStatusOnce(client, executionId, options);\n }\n}\n\nasync function getStatusOnce(\n client: ReturnType<typeof createConvexClient>,\n executionId: string,\n options: StatusOptions\n): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching execution status...\").start() : null;\n\n const result = await client.query<ExecutionStatus>(\"workflows.status\", {\n executionId,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success) {\n outputError(result.error ?? \"Failed to get status\", options);\n process.exit(1);\n }\n\n const status = result.data;\n\n if (!status) {\n outputError(\"Execution not found\", options);\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess(status, options);\n } else {\n printStatus(status);\n }\n}\n\nasync function watchStatus(\n client: ReturnType<typeof createConvexClient>,\n executionId: string,\n pollInterval: number,\n options: StatusOptions\n): Promise<void> {\n let lastStatus: string | null = null;\n\n const poll = async (): Promise<boolean> => {\n const result = await client.query<ExecutionStatus>(\"workflows.status\", {\n executionId,\n });\n\n if (!result.success) {\n outputError(result.error ?? \"Failed to get status\", options);\n return true; // Stop polling\n }\n\n const status = result.data;\n\n if (!status) {\n outputError(\"Execution not found\", options);\n return true;\n }\n\n // For JSON mode, output each status change\n if (options.json) {\n if (status.status !== lastStatus) {\n console.log(JSON.stringify(status));\n lastStatus = status.status;\n }\n } else {\n // For human mode, clear and reprint\n if (status.status !== lastStatus) {\n console.clear();\n console.log(chalk.dim(`Watching execution ${executionId}...\\n`));\n printStatus(status);\n lastStatus = status.status;\n }\n }\n\n // Stop polling if complete\n if ([\"success\", \"error\", \"cancelled\"].includes(status.status)) {\n return true;\n }\n\n return false;\n };\n\n // Initial poll\n let done = await poll();\n\n // Continue polling until complete\n while (!done) {\n await new Promise((resolve) => setTimeout(resolve, pollInterval));\n done = await poll();\n }\n}\n\nfunction printStatus(status: ExecutionStatus): void {\n const statusColor = getStatusColor(status.status);\n\n console.log(\n formatKeyValue([\n { key: \"Status\", value: statusColor(status.status) },\n ...(status.completedAt\n ? [{ key: \"Completed\", value: new Date(status.completedAt).toLocaleString() }]\n : []),\n ])\n );\n\n if (status.nodeStatuses && status.nodeStatuses.length > 0) {\n console.log(chalk.dim(\"\\nStep progress:\"));\n for (const node of status.nodeStatuses) {\n const nodeColor = getStatusColor(node.status);\n console.log(` ${nodeColor(getStatusIcon(node.status))} ${node.nodeId}`);\n }\n }\n\n if (status.error) {\n console.log(formatWarning(`\\nError: ${status.error}`));\n }\n\n if (status.status === \"success\" && status.output) {\n console.log(formatSuccess(\"\\nOutput:\"));\n console.log(JSON.stringify(status.output, null, 2));\n }\n}\n\nfunction getStatusColor(status: string): (text: string) => string {\n switch (status) {\n case \"success\":\n return chalk.green;\n case \"error\":\n return chalk.red;\n case \"cancelled\":\n return chalk.yellow;\n case \"running\":\n return chalk.blue;\n case \"pending\":\n default:\n return chalk.dim;\n }\n}\n\nfunction getStatusIcon(status: string): string {\n switch (status) {\n case \"success\":\n return \"✓\";\n case \"error\":\n return \"✕\";\n case \"running\":\n return \"●\";\n case \"pending\":\n default:\n return \"○\";\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createReadStream } from \"node:fs\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { ensureValidToken } from \"../../lib/auth/index.js\";\nimport { oauthConfig, BASE_URL } from \"../../lib/config.js\";\nimport { outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\nimport { detectAgentSource } from \"../../lib/agent-detect.js\";\n\nexport interface ExecuteOptions extends OutputOptions {\n project: string;\n params?: string;\n}\n\nconst MIME_TYPES_BY_EXTENSION: Record<string, string> = {\n \".aac\": \"audio/aac\",\n \".flac\": \"audio/flac\",\n \".gif\": \"image/gif\",\n \".jpeg\": \"image/jpeg\",\n \".jpg\": \"image/jpeg\",\n \".json\": \"application/json\",\n \".m4a\": \"audio/mp4\",\n \".mov\": \"video/quicktime\",\n \".mp3\": \"audio/mpeg\",\n \".mp4\": \"video/mp4\",\n \".ogg\": \"audio/ogg\",\n \".png\": \"image/png\",\n \".svg\": \"image/svg+xml\",\n \".txt\": \"text/plain\",\n \".wav\": \"audio/wav\",\n \".webm\": \"video/webm\",\n};\n\nfunction inferMimeType(fileName: string): string | null {\n const extension = path.extname(fileName).toLowerCase();\n return MIME_TYPES_BY_EXTENSION[extension] ?? null;\n}\n\ninterface ToolResponse {\n success: boolean;\n data?: unknown;\n error?: string;\n compositionId?: string;\n}\n\ninterface UploadInitResponse extends ToolResponse {\n data?: {\n uploadUrl: string;\n fileName: string;\n mimeType: string;\n fileSize: number;\n };\n}\n\ninterface UploadStorageResponse {\n storageId?: string;\n}\n\nfunction normalizeToolParams(\n toolName: string,\n params: Record<string, unknown>,\n): Record<string, unknown> {\n if (toolName !== \"addScene\") {\n return params;\n }\n\n const next = { ...params };\n if (\n typeof next.name === \"string\" &&\n next.name.length > 0 &&\n (typeof next.title !== \"string\" || next.title.length === 0)\n ) {\n next.title = next.name;\n }\n\n return next;\n}\n\nasync function uploadFileFromPath(\n params: Record<string, unknown>,\n projectId: string,\n accessToken: string,\n source?: string,\n): Promise<ToolResponse> {\n const filePath = params.path;\n if (typeof filePath !== \"string\" || filePath.length === 0) {\n throw new Error(\"uploadFile path must be a non-empty string\");\n }\n if (!path.isAbsolute(filePath)) {\n throw new Error(\"uploadFile path must be an absolute file path\");\n }\n\n const fileStat = await fs.stat(filePath);\n if (!fileStat.isFile()) {\n throw new Error(`uploadFile path is not a file: ${filePath}`);\n }\n\n const fileName =\n typeof params.fileName === \"string\" && params.fileName.length > 0\n ? params.fileName\n : path.basename(filePath);\n if (fileName.includes(\"/\") || fileName.includes(\"\\\\\")) {\n throw new Error(\"fileName must be a plain file name, not a path\");\n }\n const inferredMimeType = inferMimeType(fileName);\n const mimeType =\n typeof params.mimeType === \"string\" && params.mimeType.length > 0\n ? params.mimeType\n : inferredMimeType;\n if (!mimeType) {\n throw new Error(\n \"Could not infer MIME type from file extension. Provide params.mimeType explicitly.\",\n );\n }\n\n const category =\n typeof params.category === \"string\" && params.category.length > 0\n ? params.category\n : undefined;\n if (category && !/^[a-z0-9_-]{1,32}$/i.test(category)) {\n throw new Error(\"category must match /^[a-z0-9_-]{1,32}$/i\");\n }\n const metadata =\n params.metadata && typeof params.metadata === \"object\"\n ? params.metadata\n : undefined;\n\n const initRequest: RequestInit = {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n \"x-project-id\": projectId,\n ...(source ? { \"x-source\": source } : {}),\n },\n body: JSON.stringify({\n step: \"init\",\n fileName,\n mimeType,\n fileSize: fileStat.size,\n category,\n metadata,\n }),\n };\n\n const initResponse = await fetch(`${BASE_URL}/api/cli/upload`, initRequest);\n const initResult = (await initResponse\n .json()\n .catch(() => null)) as UploadInitResponse | null;\n\n if (!initResponse.ok || !initResult?.success || !initResult.data) {\n throw new Error(\n initResult?.error ?? `Upload init failed (${initResponse.status})`,\n );\n }\n\n const fileStream = createReadStream(filePath);\n const uploadRequest: RequestInit & { duplex: \"half\" } = {\n method: \"POST\",\n headers: {\n \"Content-Type\": mimeType,\n \"Content-Length\": String(fileStat.size),\n },\n body: fileStream as unknown as NonNullable<RequestInit[\"body\"]>,\n duplex: \"half\",\n };\n const storageUploadResponse = await fetch(\n initResult.data.uploadUrl,\n uploadRequest,\n );\n const storageUploadJson = (await storageUploadResponse\n .json()\n .catch(() => null)) as UploadStorageResponse | null;\n\n if (\n !storageUploadResponse.ok ||\n !storageUploadJson ||\n typeof storageUploadJson.storageId !== \"string\"\n ) {\n throw new Error(\n `Failed to upload bytes to storage (${storageUploadResponse.status})`,\n );\n }\n\n const finalizeRequest: RequestInit = {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n \"x-project-id\": projectId,\n ...(source ? { \"x-source\": source } : {}),\n },\n body: JSON.stringify({\n step: \"finalize\",\n storageId: storageUploadJson.storageId,\n fileName,\n mimeType,\n fileSize: fileStat.size,\n category,\n metadata,\n }),\n };\n\n const finalizeResponse = await fetch(\n `${BASE_URL}/api/cli/upload`,\n finalizeRequest,\n );\n\n const finalizeResult = (await finalizeResponse\n .json()\n .catch(() => null)) as ToolResponse | null;\n if (!finalizeResponse.ok || !finalizeResult?.success) {\n throw new Error(\n finalizeResult?.error ??\n `File finalize failed (${finalizeResponse.status})`,\n );\n }\n\n return finalizeResult;\n}\n\nexport async function executeCommand(\n toolName: string,\n options: ExecuteOptions\n): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(`Executing ${toolName}...`).start() : null;\n\n // Get valid access token\n const accessToken = ensureValidToken(oauthConfig);\n if (!accessToken) {\n spinner?.stop();\n spinner?.clear();\n outputError(\"Not authenticated. Run 'program auth login' first.\", options);\n process.exit(1);\n }\n\n // Parse params if provided\n let params: Record<string, unknown> = {};\n if (options.params) {\n try {\n params = JSON.parse(options.params) as Record<string, unknown>;\n params = normalizeToolParams(toolName, params);\n } catch {\n spinner?.stop();\n spinner?.clear();\n outputError(\"Invalid JSON in --params\", options);\n process.exit(1);\n }\n }\n\n // Detect agent at runtime (not login time) for correct multi-agent support\n const source = detectAgentSource();\n\n if (toolName === \"uploadFile\" && typeof params.path === \"string\") {\n try {\n if (spinner) {\n spinner.text = \"Uploading file...\";\n }\n const result = await uploadFileFromPath(\n params,\n options.project,\n accessToken,\n source,\n );\n if (spinner) {\n spinner.stop();\n spinner.clear();\n }\n if (options.json) {\n outputSuccess(result.data, options);\n } else {\n console.log(chalk.green(`✓ ${toolName} executed successfully`));\n if (result.compositionId) {\n console.log(chalk.dim(` Composition: ${result.compositionId}`));\n }\n console.log();\n console.log(JSON.stringify(result.data, null, 2));\n }\n return;\n } catch (error) {\n spinner?.stop();\n spinner?.clear();\n outputError(\n error instanceof Error ? error.message : \"Failed to upload file\",\n options,\n );\n process.exit(1);\n }\n }\n\n try {\n const response = await fetch(`${BASE_URL}/api/cli/tool`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify({\n projectId: options.project,\n tool: toolName,\n params,\n source,\n }),\n });\n\n const result = (await response.json()) as ToolResponse;\n\n spinner?.stop();\n spinner?.clear();\n\n if (!response.ok || !result.success) {\n outputError(result.error ?? `Tool execution failed: ${response.status}`, options);\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess(result.data, options);\n } else {\n console.log(chalk.green(`✓ ${toolName} executed successfully`));\n if (result.compositionId) {\n console.log(chalk.dim(` Composition: ${result.compositionId}`));\n }\n console.log();\n console.log(JSON.stringify(result.data, null, 2));\n }\n } catch (error) {\n spinner?.stop();\n spinner?.clear();\n outputError(error instanceof Error ? error.message : \"Request failed\", options);\n process.exit(1);\n }\n}\n","/**\n * Runtime agent detection\n *\n * Detects which agent/IDE is running the CLI based on environment variables.\n * This is checked per-request, not at login time, so multiple agents can\n * use the same credentials simultaneously with correct attribution.\n */\n\n/**\n * Detect which agent is currently running this CLI command.\n * Returns undefined for unknown agents (will show as \"Agent via CLI\").\n */\nexport function detectAgentSource(): string | undefined {\n if (process.env.CLAUDECODE === \"1\") {\n return \"claude-code\";\n }\n\n if (process.env.OPENCODE === \"1\") {\n return \"opencode\";\n }\n\n // Codex environments can expose CODEX_HOME, CODEX_CI, or a Codex bundle identifier.\n if (process.env.CODEX_CI === \"1\") {\n return \"codex\";\n }\n\n if (\n typeof process.env.__CFBundleIdentifier === \"string\" &&\n process.env.__CFBundleIdentifier.includes(\"codex\")\n ) {\n return \"codex\";\n }\n\n if (typeof process.env.CODEX_HOME === \"string\") {\n return \"codex\";\n }\n\n // OpenClaw and other agents will fall back to \"Agent via CLI\" until\n // they implement detection env vars\n return undefined;\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { BASE_URL } from \"../../lib/config.js\";\nimport { outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\n\nexport type ListOptions = OutputOptions;\n\ninterface Tool {\n name: string;\n description: string;\n inputs: string[];\n}\n\nexport async function listCommand(options: ListOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching available tools...\").start() : null;\n\n try {\n const response = await fetch(`${BASE_URL}/api/cli/tool`, {\n method: \"GET\",\n });\n\n const result = (await response.json()) as {\n success: boolean;\n tools?: Tool[];\n error?: string;\n };\n\n spinner?.stop();\n spinner?.clear();\n\n if (!response.ok || !result.success) {\n outputError(result.error ?? \"Failed to list tools\", options);\n process.exit(1);\n }\n\n const tools = result.tools ?? [];\n\n if (options.json) {\n outputSuccess(tools, options);\n } else {\n console.log(chalk.bold(`Available Tools (${tools.length}):\\n`));\n\n for (const tool of tools) {\n console.log(chalk.cyan(` ${tool.name}`));\n console.log(chalk.dim(` ${tool.description}`));\n if (tool.inputs.length > 0) {\n console.log(chalk.dim(` Inputs: ${tool.inputs.join(\", \")}`));\n }\n console.log();\n }\n\n console.log(chalk.dim(\"Usage: program tool exec <toolName> --project <id> --params '{...}'\"));\n }\n } catch (error) {\n spinner?.stop();\n spinner?.clear();\n outputError(error instanceof Error ? error.message : \"Request failed\", options);\n process.exit(1);\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { ensureValidToken } from \"../../lib/auth/index.js\";\nimport { oauthConfig, BASE_URL } from \"../../lib/config.js\";\nimport { outputError, outputSuccess } from \"../../lib/output.js\";\nimport type {OutputOptions} from \"../../lib/output.js\";\nimport { detectAgentSource } from \"../../lib/agent-detect.js\";\n\nexport interface SendMessageOptions extends OutputOptions {\n project: string;\n role?: \"user\" | \"assistant\";\n}\n\nexport async function sendCommand(\n text: string,\n options: SendMessageOptions\n): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Sending message...\").start() : null;\n\n // Get valid access token\n const accessToken = ensureValidToken(oauthConfig);\n if (!accessToken) {\n spinner?.stop();\n spinner?.clear();\n outputError(\"Not authenticated. Run 'program auth login' first.\", options);\n process.exit(1);\n }\n\n const role = options.role ?? \"assistant\";\n\n // Detect agent at runtime (not login time) for correct multi-agent support\n const source = detectAgentSource();\n\n try {\n const response = await fetch(`${BASE_URL}/api/cli/message`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify({\n projectId: options.project,\n role,\n text,\n source,\n }),\n });\n\n const result = (await response.json()) as {\n success: boolean;\n messageId?: string;\n error?: string;\n };\n\n spinner?.stop();\n spinner?.clear();\n\n if (!response.ok || !result.success) {\n outputError(result.error ?? `Failed to send message: ${response.status}`, options);\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess({ messageId: result.messageId, role, text }, options);\n } else {\n console.log(chalk.green(`✓ Message sent as ${role}`));\n if (result.messageId) {\n console.log(chalk.dim(` Message ID: ${result.messageId}`));\n }\n }\n } catch (error) {\n spinner?.stop();\n spinner?.clear();\n outputError(error instanceof Error ? error.message : \"Request failed\", options);\n process.exit(1);\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { ensureValidToken } from \"../../lib/auth/index.js\";\nimport { oauthConfig, BASE_URL } from \"../../lib/config.js\";\nimport { outputError, outputSuccess } from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\n\nexport interface ListMessageOptions extends OutputOptions {\n project: string;\n limit?: number;\n}\n\ninterface MessagePart {\n type: string;\n text?: string;\n toolName?: string;\n toolCallId?: string;\n state?: string;\n}\n\ninterface Message {\n id: string;\n role: \"user\" | \"assistant\";\n parts: MessagePart[];\n source?: string;\n createdAt: number;\n}\n\nexport async function listCommand(options: ListMessageOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching messages...\").start() : null;\n\n // Get valid access token\n const accessToken = ensureValidToken(oauthConfig);\n if (!accessToken) {\n spinner?.stop();\n spinner?.clear();\n outputError(\n \"Not authenticated. Run 'program auth login' first.\",\n options\n );\n process.exit(1);\n }\n\n try {\n const url = new URL(`${BASE_URL}/api/cli/message`);\n url.searchParams.set(\"projectId\", options.project);\n if (options.limit) {\n url.searchParams.set(\"limit\", options.limit.toString());\n }\n\n const response = await fetch(url.toString(), {\n method: \"GET\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n const result = (await response.json()) as {\n success: boolean;\n chatId?: string;\n messages?: Message[];\n error?: string;\n };\n\n spinner?.stop();\n spinner?.clear();\n\n if (!response.ok || !result.success) {\n outputError(\n result.error ?? `Failed to fetch messages: ${response.status}`,\n options\n );\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess(result, options);\n } else {\n const messages = result.messages ?? [];\n if (messages.length === 0) {\n console.log(chalk.dim(\"No messages in this chat yet.\"));\n return;\n }\n\n console.log(chalk.bold(`Chat Messages (${messages.length}):\\n`));\n\n for (const msg of messages) {\n // Format the role with source if available\n let roleLabel = msg.role === \"user\" ? \"You\" : \"Assistant\";\n if (msg.source) {\n if (msg.source === \"cli:claude-code\") {\n roleLabel = \"Claude via CLI\";\n } else if (msg.source === \"cli:codex\") {\n roleLabel = \"Codex via CLI\";\n } else if (msg.source.startsWith(\"cli:\")) {\n roleLabel = `${roleLabel} via CLI`;\n }\n }\n\n // Get text content from parts\n const textContent = msg.parts\n .filter((p): p is MessagePart & { text: string } => p.type === \"text\" && !!p.text)\n .map((p) => p.text)\n .join(\"\\n\");\n\n // Get tool calls\n const toolCalls = msg.parts.filter(\n (p) => p.type === \"tool-invocation\" || p.type === \"tool-call\"\n );\n\n // Format timestamp\n const time = new Date(msg.createdAt).toLocaleTimeString();\n\n // Print message\n const roleColor = msg.role === \"user\" ? chalk.blue : chalk.green;\n console.log(roleColor(`[${time}] ${roleLabel}:`));\n\n if (textContent) {\n // Indent and truncate long messages\n const truncated =\n textContent.length > 500\n ? textContent.substring(0, 500) + \"...\"\n : textContent;\n console.log(\n truncated\n .split(\"\\n\")\n .map((line) => ` ${line}`)\n .join(\"\\n\")\n );\n }\n\n if (toolCalls.length > 0) {\n console.log(\n chalk.dim(` [${toolCalls.length} tool call(s)]`)\n );\n }\n\n console.log();\n }\n }\n } catch (error) {\n spinner?.stop();\n spinner?.clear();\n outputError(\n error instanceof Error ? error.message : \"Request failed\",\n options\n );\n process.exit(1);\n }\n}\n","import { outputSuccess } from \"../lib/output.js\";\nimport type {OutputOptions} from \"../lib/output.js\";\n\nexport interface DocsOptions extends OutputOptions {\n schema?: boolean;\n}\n\n// Command schema for agents\nconst COMMAND_SCHEMA = {\n name: \"program\",\n version: \"0.1.0\",\n description: \"CLI for interacting with the Program video creation platform\",\n commands: {\n auth: {\n description: \"Authentication commands\",\n subcommands: {\n login: {\n description: \"Authenticate with the Program platform\",\n options: {\n \"--json\": \"Output as JSON\",\n },\n example: \"program auth login\",\n },\n logout: {\n description: \"Log out from the Program platform\",\n options: {\n \"--json\": \"Output as JSON\",\n },\n example: \"program auth logout\",\n },\n status: {\n description: \"Check authentication status\",\n options: {\n \"--json\": \"Output as JSON\",\n },\n example: \"program auth status --json\",\n },\n },\n },\n project: {\n description: \"Project management commands\",\n subcommands: {\n create: {\n description: \"Create a new project\",\n options: {\n \"--title <title>\": \"Project title\",\n \"--description <desc>\": \"Project description\",\n \"--json\": \"Output as JSON\",\n },\n example: 'program project create --title \"My Video\" --json',\n },\n list: {\n description: \"List projects\",\n options: {\n \"--limit <n>\": \"Maximum number of projects to return\",\n \"--json\": \"Output as JSON\",\n },\n example: \"program project list --json\",\n },\n },\n },\n workflow: {\n description: \"Workflow template commands\",\n subcommands: {\n list: {\n description: \"List available workflow templates\",\n options: {\n \"--limit <n>\": \"Maximum number of templates to return\",\n \"--public-only\": \"Only show public templates\",\n \"--json\": \"Output as JSON\",\n },\n example: \"program workflow list --json\",\n },\n run: {\n description: \"Execute a workflow template\",\n args: {\n templateId: \"ID of the template to run\",\n },\n options: {\n \"--project <id>\": \"Project ID to associate with execution\",\n \"--input <json>\": \"JSON input for the workflow\",\n \"--json\": \"Output as JSON\",\n },\n example: \"program workflow run tmpl_abc --project proj_123 --input '{\\\"files\\\":[\\\"src/main.ts\\\"]}' --json\",\n },\n status: {\n description: \"Check workflow execution status\",\n args: {\n executionId: \"ID of the execution to check\",\n },\n options: {\n \"--watch\": \"Continuously poll for status updates\",\n \"--interval <ms>\": \"Poll interval in milliseconds (default: 2000)\",\n \"--json\": \"Output as JSON\",\n },\n example: \"program workflow status exec_789 --watch --json\",\n },\n },\n },\n docs: {\n description: \"Display CLI documentation\",\n options: {\n \"--schema\": \"Output full command schema as JSON\",\n },\n example: \"program docs --schema\",\n },\n },\n globalOptions: {\n \"--help\": \"Display help information\",\n \"--version\": \"Display version number\",\n },\n notes: [\n \"Always use --json flag for parseable output when integrating with agents\",\n \"Workflow inputs should be valid JSON strings\",\n \"Run 'program auth login' first to authenticate\",\n ],\n};\n\nexport function docsCommand(options: DocsOptions): void {\n if (options.schema ?? options.json) {\n outputSuccess(COMMAND_SCHEMA, { json: true });\n } else {\n printHumanDocs();\n }\n}\n\nfunction printHumanDocs(): void {\n console.log(`\nProgram CLI v${COMMAND_SCHEMA.version}\n${COMMAND_SCHEMA.description}\n\nCOMMANDS:\n\n auth login Authenticate with the Program platform\n auth logout Log out from the Program platform\n auth status Check authentication status\n\n project create Create a new project\n project list List projects\n\n workflow list List available workflow templates\n workflow run <id> Execute a workflow template\n workflow status <id> Check workflow execution status\n\n docs Display this documentation\n docs --schema Output full command schema as JSON\n\nGLOBAL OPTIONS:\n\n --json Output as JSON (recommended for agents)\n --help Display help information\n --version Display version number\n\nEXAMPLES:\n\n # Authenticate\n program auth login\n\n # Create a project\n program project create --title \"My Video\" --json\n\n # Run a workflow\n program workflow run tmpl_abc --project proj_123 --json\n\n # Watch execution progress\n program workflow status exec_789 --watch --json\n\nFor agent integration, always use the --json flag.\n`);\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatTable, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\n\nexport interface ListOptions extends OutputOptions {\n limit?: number;\n publicOnly?: boolean;\n}\n\ninterface Template {\n _id: string;\n name: string;\n description?: string;\n public: boolean;\n steps?: unknown[];\n createdAt: number;\n updatedAt: number;\n}\n\nexport async function listCommand(options: ListOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching templates...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<Template[]>(\"templates.list\", {\n category: options.publicOnly ? \"public\" : undefined,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to list templates\", options);\n process.exit(1);\n }\n\n const templates = result.data;\n\n if (options.json) {\n outputSuccess(\n templates.map((t) => ({\n id: t._id,\n name: t.name,\n description: t.description,\n public: t.public,\n stepCount: Array.isArray(t.steps) ? t.steps.length : 0,\n })),\n options,\n );\n } else {\n if (templates.length === 0) {\n console.log(chalk.dim(\"No templates found.\"));\n return;\n }\n\n console.log(\n `Found ${chalk.cyan(templates.length)} template${templates.length === 1 ? \"\" : \"s\"}:\\n`,\n );\n\n const rows = templates.map((t) => [\n t._id,\n t.name,\n t.description?.substring(0, 40) ?? chalk.dim(\"No description\"),\n String(Array.isArray(t.steps) ? t.steps.length : 0),\n t.public ? chalk.green(\"public\") : chalk.dim(\"private\"),\n ]);\n\n console.log(\n formatTable([\"ID\", \"Name\", \"Description\", \"Steps\", \"Visibility\"], rows),\n );\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport {\n formatKeyValue,\n formatTable,\n outputError,\n outputSuccess,\n} from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\nimport { getActiveTemplate } from \"../../lib/context.js\";\n\nexport type GetOptions = OutputOptions;\n\ninterface Step {\n id?: string;\n stepId: string;\n config: Record<string, unknown>;\n order: number;\n nestedSteps?: Step[];\n}\n\ninterface Template {\n _id: string;\n name: string;\n description?: string;\n public: boolean;\n steps?: Step[];\n metadata?: Record<string, unknown>;\n createdAt: number;\n updatedAt: number;\n}\n\nexport async function getCommand(\n id: string | undefined,\n options: GetOptions,\n): Promise<void> {\n const templateId = id ?? getActiveTemplate();\n if (!templateId) {\n outputError(\n \"No template ID provided and no active template set. Use 'template use <id>' to set one.\",\n options,\n );\n process.exit(1);\n }\n\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner\n ? ora(\"Fetching template...\").start()\n : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<Template>(\"templates.byId\", {\n id: templateId,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Template not found\", options);\n process.exit(1);\n }\n\n const template = result.data;\n\n if (options.json) {\n outputSuccess(template, options);\n } else {\n console.log(\n formatKeyValue([\n { key: \"ID\", value: template._id },\n { key: \"Name\", value: template.name },\n {\n key: \"Description\",\n value: template.description ?? chalk.dim(\"None\"),\n },\n {\n key: \"Visibility\",\n value: template.public\n ? chalk.green(\"public\")\n : chalk.dim(\"private\"),\n },\n {\n key: \"Created\",\n value: new Date(template.createdAt).toLocaleString(),\n },\n {\n key: \"Updated\",\n value: new Date(template.updatedAt).toLocaleString(),\n },\n ]),\n );\n\n const steps = template.steps ?? [];\n if (steps.length === 0) {\n console.log(chalk.dim(\"\\nNo steps configured.\"));\n } else {\n console.log(`\\n${chalk.bold(\"Steps\")} (${steps.length}):\\n`);\n\n const rows = steps.map((s, i) => [\n String(i),\n s.id ?? chalk.dim(\"—\"),\n s.stepId,\n summarizeConfig(s.config),\n ]);\n\n console.log(formatTable([\"#\", \"ID\", \"Type\", \"Config\"], rows));\n }\n }\n}\n\nfunction summarizeConfig(config: Record<string, unknown>): string {\n const keys = Object.keys(config);\n if (keys.length === 0) return chalk.dim(\"{}\");\n const summary = keys\n .slice(0, 3)\n .map((k) => {\n const v = config[k];\n const vs =\n typeof v === \"string\"\n ? v.length > 20\n ? v.substring(0, 20) + \"...\"\n : v\n : JSON.stringify(v);\n return `${k}=${vs}`;\n })\n .join(\", \");\n return keys.length > 3 ? summary + `, +${keys.length - 3} more` : summary;\n}\n","import Conf from \"conf\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as os from \"node:os\";\n\ninterface ContextData {\n activeTemplateId: string | null;\n}\n\nconst CONTEXT_DIR = path.join(os.homedir(), \".program\");\n\nfunction ensureContextDir(): void {\n if (!fs.existsSync(CONTEXT_DIR)) {\n fs.mkdirSync(CONTEXT_DIR, { mode: 0o700, recursive: true });\n }\n}\n\nconst store = new Conf<ContextData>({\n projectName: \"program-cli\",\n cwd: CONTEXT_DIR,\n configName: \"context\",\n fileExtension: \"json\",\n defaults: {\n activeTemplateId: null,\n },\n});\n\nexport function setActiveTemplate(id: string): void {\n ensureContextDir();\n store.set(\"activeTemplateId\", id);\n}\n\nexport function getActiveTemplate(): string | null {\n return store.get(\"activeTemplateId\");\n}\n\nexport function clearActiveTemplate(): void {\n store.set(\"activeTemplateId\", null);\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\nimport { setActiveTemplate } from \"../../lib/context.js\";\n\nexport interface CreateOptions extends OutputOptions {\n name: string;\n description?: string;\n public?: boolean;\n}\n\nexport async function createCommand(options: CreateOptions): Promise<void> {\n if (!options.name) {\n outputError(\"--name is required\", options);\n process.exit(1);\n }\n\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Creating template...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.mutation<string>(\"templates.create\", {\n name: options.name,\n description: options.description,\n public: options.public ?? false,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to create template\", options);\n process.exit(1);\n }\n\n const templateId = result.data;\n\n // Auto-set as active template\n setActiveTemplate(templateId);\n\n if (options.json) {\n outputSuccess({ id: templateId, active: true }, options);\n } else {\n console.log(formatSuccess(\"Template created (now active)\"));\n console.log(chalk.dim(` ID: ${templateId}`));\n }\n}\n","import ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\nimport { getActiveTemplate } from \"../../lib/context.js\";\n\nexport interface UpdateOptions extends OutputOptions {\n name?: string;\n description?: string;\n public?: boolean;\n steps?: string;\n}\n\nexport async function updateCommand(\n id: string | undefined,\n options: UpdateOptions,\n): Promise<void> {\n const templateId = id ?? getActiveTemplate();\n if (!templateId) {\n outputError(\n \"No template ID provided and no active template set. Use 'template use <id>' to set one.\",\n options,\n );\n process.exit(1);\n }\n\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Updating template...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const params: Record<string, unknown> = { id: templateId };\n if (options.name !== undefined) params.name = options.name;\n if (options.description !== undefined) params.description = options.description;\n if (options.public !== undefined) params.public = options.public;\n if (options.steps !== undefined) {\n try {\n params.steps = JSON.parse(options.steps) as unknown[];\n } catch {\n spinner?.stop();\n spinner?.clear();\n outputError(\"Invalid JSON in --steps parameter\", options);\n process.exit(1);\n }\n }\n\n const result = await client.mutation<string>(\"templates.update\", params);\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success) {\n outputError(result.error ?? \"Failed to update template\", options);\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess({ id: templateId, updated: true }, options);\n } else {\n console.log(formatSuccess(\"Template updated\"));\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\nimport { getActiveTemplate, clearActiveTemplate } from \"../../lib/context.js\";\n\nexport interface RemoveOptions extends OutputOptions {\n force?: boolean;\n}\n\nexport async function removeCommand(\n id: string | undefined,\n options: RemoveOptions,\n): Promise<void> {\n const templateId = id ?? getActiveTemplate();\n if (!templateId) {\n outputError(\n \"No template ID provided and no active template set. Use 'template use <id>' to set one.\",\n options,\n );\n process.exit(1);\n }\n\n if (!options.force && !options.json) {\n // Prompt for confirmation\n const readline = await import(\"node:readline\");\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n const answer = await new Promise<string>((resolve) => {\n rl.question(\n chalk.yellow(`Are you sure you want to delete template ${templateId}? (y/N) `),\n resolve,\n );\n });\n rl.close();\n\n if (answer.toLowerCase() !== \"y\") {\n console.log(chalk.dim(\"Cancelled.\"));\n return;\n }\n }\n\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Deleting template...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.mutation<string>(\"templates.remove\", {\n id: templateId,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success) {\n outputError(result.error ?? \"Failed to delete template\", options);\n process.exit(1);\n }\n\n // Clear active template if it was the deleted one\n if (getActiveTemplate() === templateId) {\n clearActiveTemplate();\n }\n\n if (options.json) {\n outputSuccess({ id: templateId, deleted: true }, options);\n } else {\n console.log(formatSuccess(\"Template deleted\"));\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\nimport { getActiveTemplate } from \"../../lib/context.js\";\n\nexport interface RunOptions extends OutputOptions {\n project?: string;\n input?: string;\n}\n\nexport async function runCommand(\n id: string | undefined,\n options: RunOptions,\n): Promise<void> {\n const templateId = id ?? getActiveTemplate();\n if (!templateId) {\n outputError(\n \"No template ID provided and no active template set. Use 'template use <id>' to set one.\",\n options,\n );\n process.exit(1);\n }\n\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner\n ? ora(\"Starting workflow execution...\")\n .start()\n : null;\n\n // Parse input JSON if provided\n let input: Record<string, unknown> | undefined;\n if (options.input) {\n try {\n input = JSON.parse(options.input) as Record<string, unknown>;\n } catch {\n spinner?.stop();\n spinner?.clear();\n outputError(\"Invalid JSON in --input parameter\", options);\n process.exit(1);\n }\n }\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.mutation<string>(\"workflows.run\", {\n templateId,\n projectId: options.project,\n input,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to start workflow\", options);\n process.exit(1);\n }\n\n const executionId = result.data;\n\n if (options.json) {\n outputSuccess({ executionId }, options);\n } else {\n console.log(formatSuccess(\"Workflow started\"));\n console.log(chalk.dim(` Execution ID: ${executionId}`));\n console.log(\n chalk.dim(` Check status with: program template status ${executionId}`),\n );\n }\n}\n","import chalk from \"chalk\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport {\n formatKeyValue,\n formatSuccess,\n formatWarning,\n outputError,\n outputSuccess,\n} from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\nimport ora from \"ora\";\n\nexport interface StatusOptions extends OutputOptions {\n watch?: boolean;\n interval?: number;\n}\n\ninterface ExecutionStatus {\n status: \"pending\" | \"running\" | \"success\" | \"error\" | \"cancelled\";\n output?: unknown;\n error?: string;\n completedAt?: number;\n nodeStatuses?: { nodeId: string; status: string }[];\n}\n\nexport async function statusCommand(\n executionId: string,\n options: StatusOptions,\n): Promise<void> {\n const client = createConvexClient(convexConfig);\n const pollInterval = options.interval ?? 2000;\n\n if (options.watch) {\n await watchStatus(client, executionId, pollInterval, options);\n } else {\n await getStatusOnce(client, executionId, options);\n }\n}\n\nasync function getStatusOnce(\n client: ReturnType<typeof createConvexClient>,\n executionId: string,\n options: StatusOptions,\n): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner\n ? ora(\"Fetching execution status...\").start()\n : null;\n\n const result = await client.query<ExecutionStatus>(\"workflows.status\", {\n executionId,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success) {\n outputError(result.error ?? \"Failed to get status\", options);\n process.exit(1);\n }\n\n const status = result.data;\n\n if (!status) {\n outputError(\"Execution not found\", options);\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess(status, options);\n } else {\n printStatus(status);\n }\n}\n\nasync function watchStatus(\n client: ReturnType<typeof createConvexClient>,\n executionId: string,\n pollInterval: number,\n options: StatusOptions,\n): Promise<void> {\n let lastStatus: string | null = null;\n\n const poll = async (): Promise<boolean> => {\n const result = await client.query<ExecutionStatus>(\"workflows.status\", {\n executionId,\n });\n\n if (!result.success) {\n outputError(result.error ?? \"Failed to get status\", options);\n return true;\n }\n\n const status = result.data;\n\n if (!status) {\n outputError(\"Execution not found\", options);\n return true;\n }\n\n if (options.json) {\n if (status.status !== lastStatus) {\n console.log(JSON.stringify(status));\n lastStatus = status.status;\n }\n } else {\n if (status.status !== lastStatus) {\n console.clear();\n console.log(chalk.dim(`Watching execution ${executionId}...\\n`));\n printStatus(status);\n lastStatus = status.status;\n }\n }\n\n if ([\"success\", \"error\", \"cancelled\"].includes(status.status)) {\n return true;\n }\n\n return false;\n };\n\n let done = await poll();\n\n while (!done) {\n await new Promise((resolve) => setTimeout(resolve, pollInterval));\n done = await poll();\n }\n}\n\nfunction printStatus(status: ExecutionStatus): void {\n const statusColor = getStatusColor(status.status);\n\n console.log(\n formatKeyValue([\n { key: \"Status\", value: statusColor(status.status) },\n ...(status.completedAt\n ? [\n {\n key: \"Completed\",\n value: new Date(status.completedAt).toLocaleString(),\n },\n ]\n : []),\n ]),\n );\n\n if (status.nodeStatuses && status.nodeStatuses.length > 0) {\n console.log(chalk.dim(\"\\nStep progress:\"));\n for (const node of status.nodeStatuses) {\n const nodeColor = getStatusColor(node.status);\n console.log(` ${nodeColor(getStatusIcon(node.status))} ${node.nodeId}`);\n }\n }\n\n if (status.error) {\n console.log(formatWarning(`\\nError: ${status.error}`));\n }\n\n if (status.status === \"success\" && status.output) {\n console.log(formatSuccess(\"\\nOutput:\"));\n console.log(JSON.stringify(status.output, null, 2));\n }\n}\n\nfunction getStatusColor(status: string): (text: string) => string {\n switch (status) {\n case \"success\":\n return chalk.green;\n case \"error\":\n return chalk.red;\n case \"cancelled\":\n return chalk.yellow;\n case \"running\":\n return chalk.blue;\n case \"pending\":\n default:\n return chalk.dim;\n }\n}\n\nfunction getStatusIcon(status: string): string {\n switch (status) {\n case \"success\":\n return \"✓\";\n case \"error\":\n return \"✕\";\n case \"running\":\n return \"●\";\n case \"pending\":\n default:\n return \"○\";\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../lib/convex.js\";\nimport { convexConfig } from \"../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../lib/output.js\";\nimport type { OutputOptions } from \"../../lib/output.js\";\nimport { setActiveTemplate } from \"../../lib/context.js\";\n\nexport type UseOptions = OutputOptions;\n\ninterface Template {\n _id: string;\n name: string;\n}\n\nexport async function useCommand(\n id: string,\n options: UseOptions,\n): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner\n ? ora(\"Verifying template...\").start()\n : null;\n\n // Verify the template exists and is accessible\n const client = createConvexClient(convexConfig);\n const result = await client.query<Template>(\"templates.byId\", { id });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Template not found or not accessible\", options);\n process.exit(1);\n }\n\n setActiveTemplate(id);\n\n if (options.json) {\n outputSuccess({ id, name: result.data.name, active: true }, options);\n } else {\n console.log(formatSuccess(`Active template set to \"${result.data.name}\"`));\n console.log(chalk.dim(` ID: ${id}`));\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../../lib/convex.js\";\nimport { convexConfig } from \"../../../lib/config.js\";\nimport { formatTable, outputError, outputSuccess } from \"../../../lib/output.js\";\nimport type { OutputOptions } from \"../../../lib/output.js\";\n\nexport interface StepListOptions extends OutputOptions {\n category?: string;\n}\n\ninterface StepType {\n id: string;\n name: string;\n description: string;\n category: string;\n isPrimitive: boolean;\n}\n\nexport async function stepListCommand(options: StepListOptions): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching step types...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<StepType[]>(\"templates.steps\", {\n category: options.category,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to list step types\", options);\n process.exit(1);\n }\n\n const steps = result.data;\n\n if (options.json) {\n outputSuccess(steps, options);\n } else {\n if (steps.length === 0) {\n console.log(chalk.dim(\"No step types found.\"));\n return;\n }\n\n console.log(\n `Found ${chalk.cyan(steps.length)} step type${steps.length === 1 ? \"\" : \"s\"}:\\n`,\n );\n\n const rows = steps.map((s) => [\n s.id,\n s.name,\n s.category,\n s.isPrimitive ? chalk.yellow(\"primitive\") : \"\",\n ]);\n\n console.log(formatTable([\"Type\", \"Name\", \"Category\", \"\"], rows));\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../../lib/convex.js\";\nimport { convexConfig } from \"../../../lib/config.js\";\nimport {\n formatKeyValue,\n formatTable,\n outputError,\n outputSuccess,\n} from \"../../../lib/output.js\";\nimport type { OutputOptions } from \"../../../lib/output.js\";\n\nexport type StepInfoOptions = OutputOptions;\n\ninterface StepInput {\n key: string;\n label: string;\n type: string;\n required: boolean;\n description: string;\n hidden?: boolean;\n}\n\ninterface StepOutput {\n key: string;\n label: string;\n type: string;\n description: string;\n}\n\ninterface StepType {\n id: string;\n name: string;\n description: string;\n category: string;\n inputs: StepInput[];\n outputs: StepOutput[];\n isPrimitive: boolean;\n}\n\nexport async function stepInfoCommand(\n stepType: string,\n options: StepInfoOptions,\n): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner\n ? ora(\"Fetching step info...\").start()\n : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<StepType | null>(\"templates.stepInfo\", {\n stepId: stepType,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success) {\n outputError(result.error ?? \"Failed to get step info\", options);\n process.exit(1);\n }\n\n if (!result.data) {\n outputError(`Step type \"${stepType}\" not found`, options);\n process.exit(1);\n }\n\n const step = result.data;\n\n if (options.json) {\n outputSuccess(step, options);\n } else {\n console.log(\n formatKeyValue([\n { key: \"Type\", value: step.id },\n { key: \"Name\", value: step.name },\n { key: \"Category\", value: step.category },\n { key: \"Description\", value: step.description },\n {\n key: \"Primitive\",\n value: step.isPrimitive ? chalk.yellow(\"yes\") : \"no\",\n },\n ]),\n );\n\n // Show inputs\n const visibleInputs = step.inputs.filter((i) => !i.hidden);\n if (visibleInputs.length > 0) {\n console.log(`\\n${chalk.bold(\"Inputs\")}:\\n`);\n const inputRows = visibleInputs.map((i) => [\n i.key,\n i.type,\n i.required ? chalk.green(\"yes\") : chalk.dim(\"no\"),\n i.description,\n ]);\n console.log(\n formatTable([\"Key\", \"Type\", \"Required\", \"Description\"], inputRows),\n );\n }\n\n // Show outputs\n if (step.outputs.length > 0) {\n console.log(`\\n${chalk.bold(\"Outputs\")}:\\n`);\n const outputRows = step.outputs.map((o) => [\n o.key,\n o.type,\n o.description,\n ]);\n console.log(formatTable([\"Key\", \"Type\", \"Description\"], outputRows));\n }\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport crypto from \"node:crypto\";\nimport { createConvexClient } from \"../../../lib/convex.js\";\nimport { convexConfig } from \"../../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../../lib/output.js\";\nimport type { OutputOptions } from \"../../../lib/output.js\";\nimport { getActiveTemplate } from \"../../../lib/context.js\";\n\nexport interface StepAddOptions extends OutputOptions {\n config?: string;\n at?: number;\n after?: string;\n template?: string;\n}\n\ninterface Step {\n id?: string;\n stepId: string;\n config: Record<string, unknown>;\n order: number;\n nestedSteps?: Step[];\n}\n\ninterface Template {\n _id: string;\n steps?: Step[];\n}\n\nexport async function stepAddCommand(\n stepType: string,\n options: StepAddOptions,\n): Promise<void> {\n const templateId = options.template ?? getActiveTemplate();\n if (!templateId) {\n outputError(\n \"No template ID. Use --template <id> or set active template with 'template use <id>'.\",\n options,\n );\n process.exit(1);\n }\n\n // Parse config\n let config: Record<string, unknown> = {};\n if (options.config) {\n try {\n config = JSON.parse(options.config) as Record<string, unknown>;\n } catch {\n outputError(\"Invalid JSON in --config parameter\", options);\n process.exit(1);\n }\n }\n\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Adding step...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n // Fetch current template\n const getResult = await client.query<Template>(\"templates.byId\", {\n id: templateId,\n });\n\n if (!getResult.success || !getResult.data) {\n spinner?.stop();\n spinner?.clear();\n outputError(getResult.error ?? \"Template not found\", options);\n process.exit(1);\n }\n\n const steps: Step[] = (getResult.data.steps ?? []).map((s) => ({ ...s }));\n\n // Generate unique ID for the new step\n const newId = crypto.randomUUID().slice(0, 8);\n\n // Determine insertion position\n let insertAt: number;\n if (options.at !== undefined) {\n insertAt = Math.max(0, Math.min(options.at, steps.length));\n } else if (options.after) {\n const afterIndex = steps.findIndex((s) => s.id === options.after);\n if (afterIndex === -1) {\n spinner?.stop();\n spinner?.clear();\n outputError(`Step with id \"${options.after}\" not found`, options);\n process.exit(1);\n }\n insertAt = afterIndex + 1;\n } else {\n insertAt = steps.length;\n }\n\n // Create the new step\n const newStep: Step = {\n id: newId,\n stepId: stepType,\n config,\n order: insertAt,\n };\n\n // Insert and re-number\n steps.splice(insertAt, 0, newStep);\n for (let i = 0; i < steps.length; i++) {\n const s = steps[i];\n if (s) s.order = i;\n }\n\n // Update template\n const updateResult = await client.mutation<string>(\"templates.update\", {\n id: templateId,\n steps,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!updateResult.success) {\n outputError(updateResult.error ?? \"Failed to update template\", options);\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess(\n { id: newId, stepId: stepType, order: insertAt, templateId },\n options,\n );\n } else {\n console.log(formatSuccess(`Step added: ${stepType}`));\n console.log(chalk.dim(` Step ID: ${newId}`));\n console.log(chalk.dim(` Position: ${insertAt}`));\n }\n}\n","import ora from \"ora\";\nimport { createConvexClient } from \"../../../lib/convex.js\";\nimport { convexConfig } from \"../../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../../lib/output.js\";\nimport type { OutputOptions } from \"../../../lib/output.js\";\nimport { getActiveTemplate } from \"../../../lib/context.js\";\n\nexport interface StepRemoveOptions extends OutputOptions {\n template?: string;\n}\n\ninterface Step {\n id?: string;\n stepId: string;\n config: Record<string, unknown>;\n order: number;\n nestedSteps?: Step[];\n}\n\ninterface Template {\n _id: string;\n steps?: Step[];\n}\n\nexport async function stepRemoveCommand(\n stepInstanceId: string,\n options: StepRemoveOptions,\n): Promise<void> {\n const templateId = options.template ?? getActiveTemplate();\n if (!templateId) {\n outputError(\n \"No template ID. Use --template <id> or set active template with 'template use <id>'.\",\n options,\n );\n process.exit(1);\n }\n\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Removing step...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n // Fetch current template\n const getResult = await client.query<Template>(\"templates.byId\", {\n id: templateId,\n });\n\n if (!getResult.success || !getResult.data) {\n spinner?.stop();\n spinner?.clear();\n outputError(getResult.error ?? \"Template not found\", options);\n process.exit(1);\n }\n\n const steps: Step[] = getResult.data.steps ?? [];\n const removeIndex = steps.findIndex((s) => s.id === stepInstanceId);\n\n if (removeIndex === -1) {\n spinner?.stop();\n spinner?.clear();\n outputError(`Step with id \"${stepInstanceId}\" not found in template`, options);\n process.exit(1);\n }\n\n const removed = steps[removeIndex];\n if (!removed) {\n spinner?.stop();\n spinner?.clear();\n outputError(`Step at index ${removeIndex} not found`, options);\n process.exit(1);\n }\n\n // Remove and re-number\n const newSteps = steps.filter((_, i) => i !== removeIndex);\n for (let i = 0; i < newSteps.length; i++) {\n const s = newSteps[i];\n if (s) s.order = i;\n }\n\n // Update template\n const updateResult = await client.mutation<string>(\"templates.update\", {\n id: templateId,\n steps: newSteps,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!updateResult.success) {\n outputError(updateResult.error ?? \"Failed to update template\", options);\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess(\n { removed: stepInstanceId, stepId: removed.stepId, templateId },\n options,\n );\n } else {\n console.log(formatSuccess(`Removed step: ${removed.stepId} (${stepInstanceId})`));\n }\n}\n","import ora from \"ora\";\nimport { createConvexClient } from \"../../../lib/convex.js\";\nimport { convexConfig } from \"../../../lib/config.js\";\nimport { formatSuccess, outputError, outputSuccess } from \"../../../lib/output.js\";\nimport type { OutputOptions } from \"../../../lib/output.js\";\nimport { getActiveTemplate } from \"../../../lib/context.js\";\n\nexport interface StepUpdateOptions extends OutputOptions {\n config?: string;\n template?: string;\n}\n\ninterface Step {\n id?: string;\n stepId: string;\n config: Record<string, unknown>;\n order: number;\n nestedSteps?: Step[];\n}\n\ninterface Template {\n _id: string;\n steps?: Step[];\n}\n\nexport async function stepUpdateCommand(\n stepInstanceId: string,\n options: StepUpdateOptions,\n): Promise<void> {\n const templateId = options.template ?? getActiveTemplate();\n if (!templateId) {\n outputError(\n \"No template ID. Use --template <id> or set active template with 'template use <id>'.\",\n options,\n );\n process.exit(1);\n }\n\n if (!options.config) {\n outputError(\"--config is required\", options);\n process.exit(1);\n }\n\n // Parse config to merge\n let configPatch: Record<string, unknown>;\n try {\n configPatch = JSON.parse(options.config) as Record<string, unknown>;\n } catch {\n outputError(\"Invalid JSON in --config parameter\", options);\n process.exit(1);\n }\n\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Updating step...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n // Fetch current template\n const getResult = await client.query<Template>(\"templates.byId\", {\n id: templateId,\n });\n\n if (!getResult.success || !getResult.data) {\n spinner?.stop();\n spinner?.clear();\n outputError(getResult.error ?? \"Template not found\", options);\n process.exit(1);\n }\n\n const steps: Step[] = (getResult.data.steps ?? []).map((s) => ({ ...s }));\n const stepIndex = steps.findIndex((s) => s.id === stepInstanceId);\n\n if (stepIndex === -1) {\n spinner?.stop();\n spinner?.clear();\n outputError(`Step with id \"${stepInstanceId}\" not found in template`, options);\n process.exit(1);\n }\n\n const targetStep = steps[stepIndex];\n if (!targetStep) {\n spinner?.stop();\n spinner?.clear();\n outputError(`Step at index ${stepIndex} not found`, options);\n process.exit(1);\n }\n\n // Merge config\n targetStep.config = {\n ...targetStep.config,\n ...configPatch,\n };\n\n // Update template\n const updateResult = await client.mutation<string>(\"templates.update\", {\n id: templateId,\n steps,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!updateResult.success) {\n outputError(updateResult.error ?? \"Failed to update template\", options);\n process.exit(1);\n }\n\n if (options.json) {\n outputSuccess(\n {\n id: stepInstanceId,\n stepId: targetStep.stepId,\n config: targetStep.config,\n templateId,\n },\n options,\n );\n } else {\n console.log(\n formatSuccess(\n `Updated step: ${targetStep.stepId} (${stepInstanceId})`,\n ),\n );\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../../lib/convex.js\";\nimport { convexConfig } from \"../../../lib/config.js\";\nimport { formatTable, outputError, outputSuccess } from \"../../../lib/output.js\";\nimport type { OutputOptions } from \"../../../lib/output.js\";\n\nexport type ModelListOptions = OutputOptions;\n\ninterface Model {\n _id: string;\n modelId: string;\n modelName: string;\n displayName?: string;\n provider: string;\n description?: string;\n}\n\nexport async function modelListCommand(\n category: string,\n options: ModelListOptions,\n): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner ? ora(\"Fetching models...\").start() : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<Model[]>(\"models.list\", { category });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success || !result.data) {\n outputError(result.error ?? \"Failed to list models\", options);\n process.exit(1);\n }\n\n const models = result.data;\n\n if (options.json) {\n outputSuccess(\n models.map((m) => ({\n modelId: m.modelId,\n name: m.displayName ?? m.modelName,\n provider: m.provider,\n description: m.description,\n })),\n options,\n );\n } else {\n if (models.length === 0) {\n console.log(chalk.dim(`No ${category} models found.`));\n return;\n }\n\n console.log(\n `Found ${chalk.cyan(models.length)} ${category} model${models.length === 1 ? \"\" : \"s\"}:\\n`,\n );\n\n const rows = models.map((m) => [\n m.modelId,\n m.displayName ?? m.modelName,\n m.provider,\n ]);\n\n console.log(formatTable([\"Model ID\", \"Name\", \"Provider\"], rows));\n }\n}\n","import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { createConvexClient } from \"../../../lib/convex.js\";\nimport { convexConfig } from \"../../../lib/config.js\";\nimport {\n formatKeyValue,\n formatTable,\n outputError,\n outputSuccess,\n} from \"../../../lib/output.js\";\nimport type { OutputOptions } from \"../../../lib/output.js\";\n\nexport type ModelSchemaOptions = OutputOptions;\n\ninterface SchemaProperty {\n type?: string;\n description?: string;\n default?: unknown;\n enum?: unknown[];\n minimum?: number;\n maximum?: number;\n items?: { type?: string };\n}\n\ninterface InputSchema {\n type?: string;\n properties?: Record<string, SchemaProperty>;\n required?: string[];\n [key: string]: unknown;\n}\n\ninterface Model {\n _id: string;\n modelId: string;\n modelName: string;\n displayName?: string;\n provider: string;\n category: string;\n description?: string;\n inputSchema?: InputSchema;\n}\n\nexport async function modelSchemaCommand(\n modelId: string,\n options: ModelSchemaOptions,\n): Promise<void> {\n const showSpinner = !options.json && process.stdout.isTTY;\n const spinner = showSpinner\n ? ora(\"Fetching model schema...\").start()\n : null;\n\n const client = createConvexClient(convexConfig);\n\n const result = await client.query<Model | null>(\"models.byModelId\", {\n modelId,\n });\n\n spinner?.stop();\n spinner?.clear();\n\n if (!result.success) {\n outputError(result.error ?? \"Failed to get model\", options);\n process.exit(1);\n }\n\n if (!result.data) {\n outputError(`Model \"${modelId}\" not found`, options);\n process.exit(1);\n }\n\n const model = result.data;\n\n if (options.json) {\n outputSuccess(\n {\n modelId: model.modelId,\n name: model.displayName ?? model.modelName,\n provider: model.provider,\n category: model.category,\n description: model.description,\n inputSchema: model.inputSchema,\n },\n options,\n );\n } else {\n console.log(\n formatKeyValue([\n { key: \"Model ID\", value: model.modelId },\n { key: \"Name\", value: model.displayName ?? model.modelName },\n { key: \"Provider\", value: model.provider },\n { key: \"Category\", value: model.category },\n {\n key: \"Description\",\n value: model.description ?? chalk.dim(\"None\"),\n },\n ]),\n );\n\n const schema = model.inputSchema;\n if (!schema?.properties) {\n console.log(chalk.dim(\"\\nNo input schema available.\"));\n return;\n }\n\n const required = new Set(schema.required ?? []);\n const props = schema.properties;\n\n console.log(`\\n${chalk.bold(\"Input Parameters\")}:\\n`);\n\n const rows = Object.entries(props).map(([key, prop]) => [\n key,\n prop.type ?? \"unknown\",\n required.has(key) ? chalk.green(\"yes\") : chalk.dim(\"no\"),\n formatDefault(prop.default),\n formatConstraints(prop),\n ]);\n\n console.log(\n formatTable(\n [\"Parameter\", \"Type\", \"Required\", \"Default\", \"Constraints\"],\n rows,\n ),\n );\n\n // Show detailed descriptions for each parameter\n const withDescriptions = Object.entries(props).filter(\n ([, p]) => p.description,\n );\n if (withDescriptions.length > 0) {\n console.log(`\\n${chalk.bold(\"Parameter Details\")}:\\n`);\n for (const [key, prop] of withDescriptions) {\n console.log(` ${chalk.cyan(key)}: ${prop.description}`);\n if (prop.enum) {\n console.log(\n ` Values: ${prop.enum.map((v) => chalk.green(String(v))).join(\", \")}`,\n );\n }\n }\n }\n }\n}\n\nfunction formatDefault(value: unknown): string {\n if (value === undefined || value === null) return chalk.dim(\"—\");\n if (typeof value === \"object\") return JSON.stringify(value);\n return String(value as string | number | boolean);\n}\n\nfunction formatConstraints(prop: SchemaProperty): string {\n const parts: string[] = [];\n\n if (prop.enum) {\n const enumStr = prop.enum.map(String).join(\"|\");\n parts.push(enumStr.length > 40 ? enumStr.substring(0, 37) + \"...\" : enumStr);\n }\n if (prop.minimum !== undefined) parts.push(`min:${prop.minimum}`);\n if (prop.maximum !== undefined) parts.push(`max:${prop.maximum}`);\n\n return parts.length > 0 ? parts.join(\",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AA;AAMF;AAGA,IAAM,UAAU,QAAQ,QAAQ,SAAS,EAAE,YAAY,iCAAiC;AAExF,QACG,QAAQ,MAAM,EACd,YAAY,mCAAmC,EAC/C,eAAe,yBAAyB,kCAAkC,EAC1E,OAAO,mBAAmB,wCAAwC,QAAQ,EAC1E,OAAO,UAAU,gBAAgB,EACjC,OAAO,OAAO,YAAgC;AAC7C,QAAMA,aAAmB,OAAO;AAClC,CAAC;AAEH,QACG,QAAQ,aAAa,EACrB;AAAA,EACC;AACF,EACC,eAAe,yBAAyB,+BAA+B,EACvE,OAAO,iBAAiB,sDAAsD,EAC9E,OAAO,UAAU,gBAAgB,EACjC,OAAO,OAAO,MAAc,YAAgC;AAC3D,QAAM,YAAmB,MAAM,OAAO;AACxC,CAAC;AAGH,QACG,QAAQ,MAAM,EACd,YAAY,8CAA8C,EAC1D,OAAO,YAAY,oCAAoC,EACvD,OAAO,UAAU,gBAAgB,EACjC,OAAO,CAAC,YAAyB;AAChC,cAAY,OAAO;AACrB,CAAC;AAGH,QAAQ,MAAM;","names":["chalk","message","chalk","message","chalk","chalk","minutes","chalk","ora","ora","chalk","chalk","ora","ora","project","chalk","chalk","ora","ora","chalk","chalk","ora","listCommand","ora","chalk","chalk","ora","ora","chalk","chalk","ora","statusCommand","ora","chalk","chalk","ora","fs","path","ora","chalk","chalk","ora","listCommand","ora","chalk","tool","chalk","ora","ora","chalk","chalk","ora","listCommand","ora","chalk","chalk","ora","listCommand","ora","chalk","chalk","ora","Conf","fs","path","os","store","getCommand","ora","template","chalk","chalk","ora","createCommand","ora","chalk","ora","ora","chalk","ora","chalk","ora","chalk","ora","runCommand","ora","chalk","chalk","ora","statusCommand","watchStatus","getStatusOnce","printStatus","chalk","getStatusColor","getStatusIcon","chalk","ora","ora","chalk","chalk","ora","ora","chalk","chalk","ora","ora","step","chalk","chalk","ora","ora","chalk","ora","ora","ora","ora","chalk","ora","ora","chalk","chalk","ora","ora","model","chalk","require","listCommand","statusCommand","getCommand","createCommand","runCommand"]}
|