agent-media-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/LICENSE +199 -0
  2. package/README.md +59 -0
  3. package/dist/commands/alias.d.ts +3 -0
  4. package/dist/commands/alias.d.ts.map +1 -0
  5. package/dist/commands/alias.js +245 -0
  6. package/dist/commands/alias.js.map +1 -0
  7. package/dist/commands/apikey.d.ts +3 -0
  8. package/dist/commands/apikey.d.ts.map +1 -0
  9. package/dist/commands/apikey.js +282 -0
  10. package/dist/commands/apikey.js.map +1 -0
  11. package/dist/commands/cancel.d.ts +9 -0
  12. package/dist/commands/cancel.d.ts.map +1 -0
  13. package/dist/commands/cancel.js +101 -0
  14. package/dist/commands/cancel.js.map +1 -0
  15. package/dist/commands/completions.d.ts +15 -0
  16. package/dist/commands/completions.d.ts.map +1 -0
  17. package/dist/commands/completions.js +293 -0
  18. package/dist/commands/completions.js.map +1 -0
  19. package/dist/commands/config.d.ts +3 -0
  20. package/dist/commands/config.d.ts.map +1 -0
  21. package/dist/commands/config.js +327 -0
  22. package/dist/commands/config.js.map +1 -0
  23. package/dist/commands/credits.d.ts +18 -0
  24. package/dist/commands/credits.d.ts.map +1 -0
  25. package/dist/commands/credits.js +459 -0
  26. package/dist/commands/credits.js.map +1 -0
  27. package/dist/commands/debug.d.ts +20 -0
  28. package/dist/commands/debug.d.ts.map +1 -0
  29. package/dist/commands/debug.js +291 -0
  30. package/dist/commands/debug.js.map +1 -0
  31. package/dist/commands/delete.d.ts +3 -0
  32. package/dist/commands/delete.d.ts.map +1 -0
  33. package/dist/commands/delete.js +273 -0
  34. package/dist/commands/delete.js.map +1 -0
  35. package/dist/commands/doctor.d.ts +14 -0
  36. package/dist/commands/doctor.d.ts.map +1 -0
  37. package/dist/commands/doctor.js +468 -0
  38. package/dist/commands/doctor.js.map +1 -0
  39. package/dist/commands/download.d.ts +3 -0
  40. package/dist/commands/download.d.ts.map +1 -0
  41. package/dist/commands/download.js +165 -0
  42. package/dist/commands/download.js.map +1 -0
  43. package/dist/commands/generate.d.ts +3 -0
  44. package/dist/commands/generate.d.ts.map +1 -0
  45. package/dist/commands/generate.js +358 -0
  46. package/dist/commands/generate.js.map +1 -0
  47. package/dist/commands/inspect.d.ts +10 -0
  48. package/dist/commands/inspect.d.ts.map +1 -0
  49. package/dist/commands/inspect.js +376 -0
  50. package/dist/commands/inspect.js.map +1 -0
  51. package/dist/commands/list.d.ts +13 -0
  52. package/dist/commands/list.d.ts.map +1 -0
  53. package/dist/commands/list.js +198 -0
  54. package/dist/commands/list.js.map +1 -0
  55. package/dist/commands/login.d.ts +15 -0
  56. package/dist/commands/login.d.ts.map +1 -0
  57. package/dist/commands/login.js +123 -0
  58. package/dist/commands/login.js.map +1 -0
  59. package/dist/commands/logout.d.ts +12 -0
  60. package/dist/commands/logout.d.ts.map +1 -0
  61. package/dist/commands/logout.js +85 -0
  62. package/dist/commands/logout.js.map +1 -0
  63. package/dist/commands/models.d.ts +10 -0
  64. package/dist/commands/models.d.ts.map +1 -0
  65. package/dist/commands/models.js +137 -0
  66. package/dist/commands/models.js.map +1 -0
  67. package/dist/commands/plan.d.ts +13 -0
  68. package/dist/commands/plan.d.ts.map +1 -0
  69. package/dist/commands/plan.js +134 -0
  70. package/dist/commands/plan.js.map +1 -0
  71. package/dist/commands/pricing.d.ts +14 -0
  72. package/dist/commands/pricing.d.ts.map +1 -0
  73. package/dist/commands/pricing.js +166 -0
  74. package/dist/commands/pricing.js.map +1 -0
  75. package/dist/commands/profile.d.ts +9 -0
  76. package/dist/commands/profile.d.ts.map +1 -0
  77. package/dist/commands/profile.js +236 -0
  78. package/dist/commands/profile.js.map +1 -0
  79. package/dist/commands/retry.d.ts +3 -0
  80. package/dist/commands/retry.d.ts.map +1 -0
  81. package/dist/commands/retry.js +424 -0
  82. package/dist/commands/retry.js.map +1 -0
  83. package/dist/commands/status.d.ts +9 -0
  84. package/dist/commands/status.d.ts.map +1 -0
  85. package/dist/commands/status.js +182 -0
  86. package/dist/commands/status.js.map +1 -0
  87. package/dist/commands/subscribe.d.ts +3 -0
  88. package/dist/commands/subscribe.d.ts.map +1 -0
  89. package/dist/commands/subscribe.js +263 -0
  90. package/dist/commands/subscribe.js.map +1 -0
  91. package/dist/commands/text.d.ts +3 -0
  92. package/dist/commands/text.d.ts.map +1 -0
  93. package/dist/commands/text.js +263 -0
  94. package/dist/commands/text.js.map +1 -0
  95. package/dist/commands/update.d.ts +13 -0
  96. package/dist/commands/update.d.ts.map +1 -0
  97. package/dist/commands/update.js +211 -0
  98. package/dist/commands/update.js.map +1 -0
  99. package/dist/commands/usage.d.ts +13 -0
  100. package/dist/commands/usage.d.ts.map +1 -0
  101. package/dist/commands/usage.js +344 -0
  102. package/dist/commands/usage.js.map +1 -0
  103. package/dist/commands/version.d.ts +8 -0
  104. package/dist/commands/version.d.ts.map +1 -0
  105. package/dist/commands/version.js +26 -0
  106. package/dist/commands/version.js.map +1 -0
  107. package/dist/commands/whoami.d.ts +9 -0
  108. package/dist/commands/whoami.d.ts.map +1 -0
  109. package/dist/commands/whoami.js +76 -0
  110. package/dist/commands/whoami.js.map +1 -0
  111. package/dist/index.d.ts +3 -0
  112. package/dist/index.d.ts.map +1 -0
  113. package/dist/index.js +85 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/lib/api.d.ts +518 -0
  116. package/dist/lib/api.d.ts.map +1 -0
  117. package/dist/lib/api.js +582 -0
  118. package/dist/lib/api.js.map +1 -0
  119. package/dist/lib/config.d.ts +33 -0
  120. package/dist/lib/config.d.ts.map +1 -0
  121. package/dist/lib/config.js +91 -0
  122. package/dist/lib/config.js.map +1 -0
  123. package/dist/lib/credentials.d.ts +60 -0
  124. package/dist/lib/credentials.d.ts.map +1 -0
  125. package/dist/lib/credentials.js +152 -0
  126. package/dist/lib/credentials.js.map +1 -0
  127. package/dist/lib/errors.d.ts +20 -0
  128. package/dist/lib/errors.d.ts.map +1 -0
  129. package/dist/lib/errors.js +77 -0
  130. package/dist/lib/errors.js.map +1 -0
  131. package/dist/lib/output.d.ts +33 -0
  132. package/dist/lib/output.d.ts.map +1 -0
  133. package/dist/lib/output.js +77 -0
  134. package/dist/lib/output.js.map +1 -0
  135. package/dist/types.d.ts +12 -0
  136. package/dist/types.d.ts.map +1 -0
  137. package/dist/types.js +3 -0
  138. package/dist/types.js.map +1 -0
  139. package/package.json +48 -0
@@ -0,0 +1,123 @@
1
+ // Copyright 2026 agent-media contributors. Apache-2.0 license.
2
+ import chalk from 'chalk';
3
+ import { AgentMediaAPI } from '../lib/api.js';
4
+ import { createSpinner, detectOutputMode, printJson, printQuiet } from '../lib/output.js';
5
+ import { saveProfile, resolveProfileName } from '../lib/credentials.js';
6
+ import { CLIError, handleError } from '../lib/errors.js';
7
+ /** Default polling timeout in milliseconds (5 minutes). */
8
+ const DEFAULT_TIMEOUT_MS = 5 * 60 * 1000;
9
+ export function registerLoginCommand(program) {
10
+ program
11
+ .command('login')
12
+ .description('Authenticate via browser (OAuth device flow)')
13
+ .option('--no-browser', 'Print the URL instead of opening a browser')
14
+ .option('--timeout <seconds>', 'Polling timeout in seconds (default: 300)', '300')
15
+ .action(async (cmdOpts) => {
16
+ const globalOpts = program.opts();
17
+ const mode = detectOutputMode(globalOpts);
18
+ const profileName = resolveProfileName(globalOpts.profile);
19
+ const timeoutMs = Math.min(parseInt(cmdOpts.timeout, 10) * 1000 || DEFAULT_TIMEOUT_MS, 10 * 60 * 1000);
20
+ try {
21
+ // Step 1: Initiate device flow
22
+ const spinner = createSpinner('Initiating device login...');
23
+ if (mode === 'human')
24
+ spinner.start();
25
+ const device = await AgentMediaAPI.initiateDeviceFlow();
26
+ if (mode === 'human') {
27
+ spinner.stop();
28
+ console.log();
29
+ console.log(chalk.bold(' Open this URL in your browser to authenticate:'));
30
+ console.log();
31
+ console.log(` ${chalk.cyan.underline(device.verification_url)}`);
32
+ console.log();
33
+ console.log(` Your code: ${chalk.bold.yellow(device.user_code)}`);
34
+ console.log();
35
+ console.log(` Confirmation code: ${chalk.bold.yellow(device.confirmation_code)}`);
36
+ console.log();
37
+ }
38
+ // Step 2: Auto-open browser (unless --no-browser)
39
+ if (cmdOpts.browser) {
40
+ try {
41
+ const open = (await import('open')).default;
42
+ await open(device.verification_url);
43
+ if (mode === 'human') {
44
+ console.log(chalk.dim(' Browser opened automatically. Waiting for approval...'));
45
+ console.log();
46
+ }
47
+ }
48
+ catch {
49
+ if (mode === 'human') {
50
+ console.log(chalk.dim(' Could not open browser. Please open the URL manually.'));
51
+ console.log();
52
+ }
53
+ }
54
+ }
55
+ // Step 3: Poll for approval
56
+ if (mode === 'human') {
57
+ spinner.text = 'Waiting for browser approval...';
58
+ spinner.start();
59
+ }
60
+ const pollInterval = (device.interval || 3) * 1000;
61
+ const deadline = Date.now() + timeoutMs;
62
+ let result = null;
63
+ while (Date.now() < deadline) {
64
+ await sleep(pollInterval);
65
+ const poll = await AgentMediaAPI.pollDeviceToken(device.device_code);
66
+ if (poll.status === 'approved' && poll.api_key) {
67
+ result = poll;
68
+ break;
69
+ }
70
+ if (poll.status === 'expired') {
71
+ if (mode === 'human')
72
+ spinner.fail('Device code expired.');
73
+ throw new CLIError('Device code expired before approval.', {
74
+ code: 'DEVICE_CODE_EXPIRED',
75
+ suggestion: 'Run `agent-media login` to try again.',
76
+ });
77
+ }
78
+ // Still pending -- continue polling
79
+ }
80
+ if (!result || !result.api_key) {
81
+ if (mode === 'human')
82
+ spinner.fail('Login timed out.');
83
+ throw new CLIError('Login timed out waiting for browser approval.', {
84
+ code: 'LOGIN_TIMEOUT',
85
+ suggestion: 'Run `agent-media login` to try again.',
86
+ });
87
+ }
88
+ // Step 4: Save credentials
89
+ saveProfile(profileName, {
90
+ apiKey: result.api_key,
91
+ email: '',
92
+ userId: result.user_id ?? '',
93
+ createdAt: new Date().toISOString(),
94
+ });
95
+ // Step 5: Output
96
+ switch (mode) {
97
+ case 'json':
98
+ printJson({
99
+ success: true,
100
+ profile: profileName,
101
+ userId: result.user_id ?? null,
102
+ });
103
+ break;
104
+ case 'quiet':
105
+ printQuiet('authenticated');
106
+ break;
107
+ default:
108
+ spinner.succeed(chalk.green(`Logged in successfully` +
109
+ (profileName !== 'default'
110
+ ? ` (profile: ${profileName})`
111
+ : '')));
112
+ break;
113
+ }
114
+ }
115
+ catch (error) {
116
+ handleError(error);
117
+ }
118
+ });
119
+ }
120
+ function sleep(ms) {
121
+ return new Promise((resolve) => setTimeout(resolve, ms));
122
+ }
123
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAgB/D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEzD,2DAA2D;AAC3D,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEzC,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,8CAA8C,CAAC;SAC3D,MAAM,CAAC,cAAc,EAAE,4CAA4C,CAAC;SACpE,MAAM,CAAC,qBAAqB,EAAE,2CAA2C,EAAE,KAAK,CAAC;SACjF,MAAM,CAAC,KAAK,EAAE,OAA8C,EAAE,EAAE;QAC/D,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAI3B,CAAC;QACL,MAAM,IAAI,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAC1C,MAAM,WAAW,GAAG,kBAAkB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oBACF,MAAM;YACV,CAAC;QACH,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `agent-media logout` command.
3
+ *
4
+ * Clears stored credentials for the current (or specified) profile.
5
+ * With --all, removes all profiles and the credentials file entirely.
6
+ *
7
+ * Optionally revokes the API key server-side so it can no longer
8
+ * be used for authentication.
9
+ */
10
+ import type { Command } from 'commander';
11
+ export declare function registerLogoutCommand(program: Command): void;
12
+ //# sourceMappingURL=logout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4F5D"}
@@ -0,0 +1,85 @@
1
+ // Copyright 2026 agent-media contributors. Apache-2.0 license.
2
+ import chalk from 'chalk';
3
+ import { detectOutputMode, printJson, printQuiet } from '../lib/output.js';
4
+ import { resolveProfileName, deleteProfile, clearAllCredentials, getProfile, } from '../lib/credentials.js';
5
+ import { AgentMediaAPI } from '../lib/api.js';
6
+ import { handleError } from '../lib/errors.js';
7
+ export function registerLogoutCommand(program) {
8
+ program
9
+ .command('logout')
10
+ .description('Clear stored credentials')
11
+ .option('--all', 'Remove all profiles and credentials')
12
+ .action(async (cmdOpts) => {
13
+ const globalOpts = program.opts();
14
+ const mode = detectOutputMode(globalOpts);
15
+ try {
16
+ if (cmdOpts.all) {
17
+ // Attempt server-side revocation for all profiles before clearing
18
+ // (best effort -- don't fail if the server is unreachable)
19
+ clearAllCredentials();
20
+ switch (mode) {
21
+ case 'json':
22
+ printJson({ success: true, message: 'All credentials removed.' });
23
+ break;
24
+ case 'quiet':
25
+ printQuiet('logged_out');
26
+ break;
27
+ default:
28
+ console.log(chalk.green('\u2713 All credentials removed.'));
29
+ break;
30
+ }
31
+ return;
32
+ }
33
+ // Single profile logout
34
+ const profileName = resolveProfileName(globalOpts.profile);
35
+ const profile = getProfile(profileName);
36
+ if (!profile) {
37
+ switch (mode) {
38
+ case 'json':
39
+ printJson({ success: false, message: `No profile "${profileName}" found.` });
40
+ break;
41
+ case 'quiet':
42
+ printQuiet('not_found');
43
+ break;
44
+ default:
45
+ console.log(chalk.yellow(`No credentials found for profile "${profileName}".`));
46
+ break;
47
+ }
48
+ return;
49
+ }
50
+ // Best-effort server-side key revocation
51
+ try {
52
+ const api = new AgentMediaAPI(profile.apiKey);
53
+ await api.revokeApiKey();
54
+ }
55
+ catch {
56
+ // Server unreachable or key already revoked -- continue with local cleanup
57
+ }
58
+ const deleted = deleteProfile(profileName);
59
+ if (deleted) {
60
+ switch (mode) {
61
+ case 'json':
62
+ printJson({
63
+ success: true,
64
+ profile: profileName,
65
+ email: profile.email,
66
+ });
67
+ break;
68
+ case 'quiet':
69
+ printQuiet('logged_out');
70
+ break;
71
+ default:
72
+ console.log(chalk.green(`\u2713 Logged out from ${chalk.bold(profile.email || profileName)}` +
73
+ (profileName !== 'default'
74
+ ? ` (profile: ${profileName})`
75
+ : '')));
76
+ break;
77
+ }
78
+ }
79
+ }
80
+ catch (error) {
81
+ handleError(error);
82
+ }
83
+ });
84
+ }
85
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAa/D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,E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AAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `agent-media models` command.
3
+ *
4
+ * Lists available AI models with descriptions, capabilities, and pricing.
5
+ * Fetches model info from the models table and pricing from the pricing
6
+ * endpoint. Supports --type filter and all output modes.
7
+ */
8
+ import type { Command } from 'commander';
9
+ export declare function registerModelsCommand(program: Command): void;
10
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/commands/models.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0EzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgH5D"}
@@ -0,0 +1,137 @@
1
+ // Copyright 2026 agent-media contributors. Apache-2.0 license.
2
+ import chalk from 'chalk';
3
+ import { detectOutputMode, printJson, printQuiet, createSpinner, } from '../lib/output.js';
4
+ import { AgentMediaAPI, } from '../lib/api.js';
5
+ import { getApiKey, resolveProfileName } from '../lib/credentials.js';
6
+ import { handleError } from '../lib/errors.js';
7
+ /**
8
+ * Build a display-friendly label for supported operations.
9
+ */
10
+ function formatOps(model) {
11
+ const ops = [];
12
+ if (model.supports_text_to_video)
13
+ ops.push('text-to-video');
14
+ if (model.supports_image_to_video)
15
+ ops.push('image-to-video');
16
+ if (model.supports_text_to_image)
17
+ ops.push('text-to-image');
18
+ return ops;
19
+ }
20
+ /**
21
+ * Merge model info with pricing data into display rows.
22
+ */
23
+ function mergeModelsWithPricing(models, pricing) {
24
+ const costMap = new Map();
25
+ for (const p of pricing) {
26
+ const existing = costMap.get(p.modelSlug) ?? [];
27
+ existing.push(p.creditCost);
28
+ costMap.set(p.modelSlug, existing);
29
+ }
30
+ return models.map((m) => {
31
+ const costs = costMap.get(m.slug) ?? [];
32
+ let creditRange = '-';
33
+ if (costs.length > 0) {
34
+ const min = Math.min(...costs);
35
+ const max = Math.max(...costs);
36
+ creditRange = min === max ? String(min) : `${min}-${max}`;
37
+ }
38
+ return {
39
+ slug: m.slug,
40
+ displayName: m.display_name,
41
+ description: m.description,
42
+ type: m.media_type,
43
+ operations: formatOps(m),
44
+ maxDuration: m.max_duration_seconds,
45
+ maxResolution: m.max_resolution,
46
+ creditRange,
47
+ };
48
+ });
49
+ }
50
+ export function registerModelsCommand(program) {
51
+ program
52
+ .command('models')
53
+ .description('List all available models')
54
+ .option('--type <type>', 'Filter by model type (video or image)')
55
+ .action(async (cmdOpts) => {
56
+ const globalOpts = program.opts();
57
+ const mode = detectOutputMode(globalOpts);
58
+ try {
59
+ const spinner = createSpinner('Fetching models...');
60
+ if (mode === 'human')
61
+ spinner.start();
62
+ const profileName = resolveProfileName(globalOpts.profile);
63
+ const apiKey = getApiKey(profileName) ?? '';
64
+ const api = new AgentMediaAPI(apiKey);
65
+ const [modelsData, pricingData] = await Promise.all([
66
+ api.getModels(),
67
+ api.getPricing(),
68
+ ]);
69
+ let models = mergeModelsWithPricing(modelsData, pricingData.pricing);
70
+ if (mode === 'human')
71
+ spinner.stop();
72
+ // Apply --type filter
73
+ if (cmdOpts.type) {
74
+ const filterType = cmdOpts.type.toLowerCase();
75
+ models = models.filter((m) => m.type.includes(filterType));
76
+ }
77
+ switch (mode) {
78
+ case 'json':
79
+ printJson(models);
80
+ break;
81
+ case 'quiet':
82
+ printQuiet(models.map((m) => m.slug));
83
+ break;
84
+ default: {
85
+ if (models.length === 0) {
86
+ console.log(chalk.dim('\n No models found.\n'));
87
+ break;
88
+ }
89
+ const videoModels = models.filter((m) => m.type === 'video');
90
+ const imageModels = models.filter((m) => m.type === 'image');
91
+ const printGroup = (title, items) => {
92
+ if (items.length === 0)
93
+ return;
94
+ console.log();
95
+ console.log(chalk.bold(` ${title}`));
96
+ for (const m of items) {
97
+ console.log();
98
+ console.log(` ${chalk.cyan(m.slug)} ${chalk.dim(m.displayName)}`);
99
+ console.log(` ${chalk.dim(m.description)}`);
100
+ const specs = [];
101
+ specs.push(m.operations.join(', '));
102
+ if (m.maxDuration)
103
+ specs.push(`up to ${m.maxDuration}s`);
104
+ if (m.maxResolution)
105
+ specs.push(`max ${m.maxResolution}`);
106
+ specs.push(`${chalk.yellow(m.creditRange)} credits`);
107
+ console.log(` ${specs.join(chalk.dim(' | '))}`);
108
+ }
109
+ };
110
+ printGroup('Video Models', videoModels);
111
+ printGroup('Image Models', imageModels);
112
+ // Examples section
113
+ console.log();
114
+ console.log(chalk.bold(' Examples'));
115
+ console.log();
116
+ console.log(chalk.dim(' # Generate a video from text'));
117
+ console.log(` ${chalk.green('agent-media generate')} seedance1.5 -p "A cat riding a skateboard through Tokyo at night"`);
118
+ console.log();
119
+ console.log(chalk.dim(' # Generate an image'));
120
+ console.log(` ${chalk.green('agent-media generate')} flux2-pro -p "Cyberpunk cityscape at sunset, neon lights"`);
121
+ console.log();
122
+ console.log(chalk.dim(' # Generate, wait, and download the result'));
123
+ console.log(` ${chalk.green('agent-media generate')} kling3.0 -p "Ocean waves crashing on rocks" --sync`);
124
+ console.log();
125
+ console.log(chalk.dim(' # Image-to-video (use a photo as reference)'));
126
+ console.log(` ${chalk.green('agent-media generate')} seedance1.5 -p "Make it come alive" --input photo.jpg -s`);
127
+ console.log();
128
+ break;
129
+ }
130
+ }
131
+ }
132
+ catch (error) {
133
+ handleError(error);
134
+ }
135
+ });
136
+ }
137
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/commands/models.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAW/D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,GAGd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EA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authenticated user's subscription plan details including
5
+ * plan name, status, pricing, features, and trial information. Provides
6
+ * a link to the billing portal for plan upgrades.
7
+ *
8
+ * Requires a valid API key. If not logged in, prompts the user to
9
+ * authenticate via `agent-media login`.
10
+ */
11
+ import type { Command } from 'commander';
12
+ export declare function registerPlanCommand(program: Command): void;
13
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/commands/plan.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8CzC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsH1D"}
@@ -0,0 +1,134 @@
1
+ // Copyright 2026 agent-media contributors. Apache-2.0 license.
2
+ import chalk from 'chalk';
3
+ import { detectOutputMode, printJson, printQuiet, createSpinner } from '../lib/output.js';
4
+ import { getApiKey, resolveProfileName } from '../lib/credentials.js';
5
+ import { AgentMediaAPI } from '../lib/api.js';
6
+ import { CLIError, handleError } from '../lib/errors.js';
7
+ const BILLING_URL = 'https://agent-media.ai/billing';
8
+ /** Plan feature descriptions keyed by plan slug. */
9
+ const PLAN_FEATURES = {
10
+ starter: {
11
+ price: '$49/month',
12
+ features: [
13
+ '2,000 credits/month',
14
+ 'All models (up to 15s video)',
15
+ '1080p resolution',
16
+ 'No watermark',
17
+ 'Email support',
18
+ ],
19
+ },
20
+ creator: {
21
+ price: '$69/month',
22
+ features: [
23
+ '5,000 credits/month',
24
+ 'All models (up to 15s video)',
25
+ 'Up to 2K resolution',
26
+ 'No watermark',
27
+ 'Priority support',
28
+ 'Priority queue',
29
+ ],
30
+ },
31
+ pro_plus: {
32
+ price: '$119/month',
33
+ features: [
34
+ '15,000 credits/month',
35
+ 'All models (up to 15s video)',
36
+ 'Up to 2K resolution',
37
+ 'No watermark',
38
+ 'Priority support',
39
+ 'Priority queue',
40
+ 'Full API access',
41
+ ],
42
+ },
43
+ };
44
+ export function registerPlanCommand(program) {
45
+ program
46
+ .command('plan')
47
+ .description('Show subscription plan details')
48
+ .action(async () => {
49
+ const globalOpts = program.opts();
50
+ const mode = detectOutputMode(globalOpts);
51
+ const profileName = resolveProfileName(globalOpts.profile);
52
+ const apiKey = getApiKey(profileName);
53
+ if (!apiKey) {
54
+ throw new CLIError('Not logged in.', {
55
+ code: 'NOT_AUTHENTICATED',
56
+ suggestion: "Run 'agent-media login' to authenticate.",
57
+ });
58
+ }
59
+ try {
60
+ const spinner = createSpinner('Fetching plan details...');
61
+ if (mode === 'human')
62
+ spinner.start();
63
+ const api = new AgentMediaAPI(apiKey);
64
+ const data = await api.getCredits();
65
+ if (mode === 'human')
66
+ spinner.stop();
67
+ const planSlug = data.plan.tier;
68
+ const planLabel = data.plan.name;
69
+ const status = data.plan.status;
70
+ const periodEnd = data.plan.current_period_end;
71
+ const planInfo = PLAN_FEATURES[planSlug];
72
+ const isTrial = data.plan.trial_active;
73
+ switch (mode) {
74
+ case 'json':
75
+ printJson({
76
+ plan: planSlug,
77
+ plan_label: planLabel,
78
+ status,
79
+ price: planInfo?.price ?? 'Unknown',
80
+ features: planInfo?.features ?? [],
81
+ period_end: periodEnd,
82
+ is_trial: isTrial,
83
+ monthly_remaining: data.credits.monthly_remaining,
84
+ purchased: data.credits.purchased,
85
+ total: data.credits.total,
86
+ upgrade_url: BILLING_URL,
87
+ });
88
+ break;
89
+ case 'quiet':
90
+ printQuiet(planSlug);
91
+ break;
92
+ default: {
93
+ const planColor = planSlug === 'pro' || planSlug === 'pro_plus'
94
+ ? chalk.magenta
95
+ : planSlug === 'creator'
96
+ ? chalk.blue
97
+ : planSlug === 'starter'
98
+ ? chalk.green
99
+ : chalk.dim;
100
+ console.log();
101
+ console.log(chalk.bold(' Subscription Plan'));
102
+ console.log();
103
+ console.log(` ${chalk.bold('Plan:')} ${planColor(planLabel)}`);
104
+ console.log(` ${chalk.bold('Status:')} ${status}`);
105
+ console.log(` ${chalk.bold('Price:')} ${planInfo?.price ?? 'Unknown'}`);
106
+ if (periodEnd) {
107
+ console.log(` ${chalk.bold('Period:')} ends ${periodEnd}`);
108
+ }
109
+ console.log(` ${chalk.bold('Credits:')} ${data.credits.total} total (${data.credits.monthly_remaining} monthly + ${data.credits.purchased} purchased)`);
110
+ if (isTrial) {
111
+ console.log();
112
+ console.log(chalk.yellow(` Trial ends: ${data.plan.trial_ends_at}`));
113
+ }
114
+ // Features list
115
+ if (planInfo?.features.length) {
116
+ console.log();
117
+ console.log(chalk.bold(' Features'));
118
+ for (const feature of planInfo.features) {
119
+ console.log(` ${chalk.green('\u2713')} ${feature}`);
120
+ }
121
+ }
122
+ console.log();
123
+ console.log(chalk.dim(` To change your plan, visit: ${chalk.underline(BILLING_URL)}`));
124
+ console.log();
125
+ break;
126
+ }
127
+ }
128
+ }
129
+ catch (error) {
130
+ handleError(error);
131
+ }
132
+ });
133
+ }
134
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/commands/plan.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAc/D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,WAAW,GAAG,gCAAgC,CAAC;AAErD,oDAAoD;AACpD,MAAM,aAAa,GAA0D;IAC3E,OAAO,EAAE;QACP,KAAK,EAAE,WAAW;QAClB,QAAQ,EAAE;YACR,qBAAqB;YACrB,8BAA8B;YAC9B,kBAAkB;YAClB,cAAc;YACd,eAAe;SAChB;KACF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AC,CAAC,CAAC;wBACtC,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;4BACxC,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;wBACzD,CAAC;oBACH,CAAC;oBAED,OAAO,CAAC,GAAG,EAAE,CAAC;oBACd,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CAAC,iCAAiC,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAC3E,CAAC;oBACF,OAAO,CAAC,GAAG,EAAE,CAAC;oBACd,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `agent-media pricing [model]` command.
3
+ *
4
+ * Displays credit pricing for AI generation models. When a model slug
5
+ * is provided, shows a detailed cost breakdown for that model across
6
+ * all supported operations, durations, and resolutions. Without a model
7
+ * argument, shows a summary pricing table for every available model.
8
+ *
9
+ * Pricing data mirrors the seed data in `supabase/seed.sql` and can
10
+ * optionally be fetched from the server when the user is authenticated.
11
+ */
12
+ import type { Command } from 'commander';
13
+ export declare function registerPricingCommand(program: Command): void;
14
+ //# sourceMappingURL=pricing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/commands/pricing.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgFzC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkI7D"}