@contenthero/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +108 -0
  2. package/dist/args.d.ts +13 -0
  3. package/dist/args.d.ts.map +1 -0
  4. package/dist/args.js +35 -0
  5. package/dist/args.js.map +1 -0
  6. package/dist/commands/account.d.ts +7 -0
  7. package/dist/commands/account.d.ts.map +1 -0
  8. package/dist/commands/account.js +22 -0
  9. package/dist/commands/account.js.map +1 -0
  10. package/dist/commands/auth.d.ts +35 -0
  11. package/dist/commands/auth.d.ts.map +1 -0
  12. package/dist/commands/auth.js +210 -0
  13. package/dist/commands/auth.js.map +1 -0
  14. package/dist/commands/brandkit.d.ts +12 -0
  15. package/dist/commands/brandkit.d.ts.map +1 -0
  16. package/dist/commands/brandkit.js +159 -0
  17. package/dist/commands/brandkit.js.map +1 -0
  18. package/dist/commands/config.d.ts +11 -0
  19. package/dist/commands/config.d.ts.map +1 -0
  20. package/dist/commands/config.js +69 -0
  21. package/dist/commands/config.js.map +1 -0
  22. package/dist/commands/connected.d.ts +13 -0
  23. package/dist/commands/connected.d.ts.map +1 -0
  24. package/dist/commands/connected.js +86 -0
  25. package/dist/commands/connected.js.map +1 -0
  26. package/dist/commands/generate.d.ts +15 -0
  27. package/dist/commands/generate.d.ts.map +1 -0
  28. package/dist/commands/generate.js +215 -0
  29. package/dist/commands/generate.js.map +1 -0
  30. package/dist/commands/generation.d.ts +12 -0
  31. package/dist/commands/generation.d.ts.map +1 -0
  32. package/dist/commands/generation.js +61 -0
  33. package/dist/commands/generation.js.map +1 -0
  34. package/dist/commands/identity.d.ts +10 -0
  35. package/dist/commands/identity.d.ts.map +1 -0
  36. package/dist/commands/identity.js +83 -0
  37. package/dist/commands/identity.js.map +1 -0
  38. package/dist/commands/inspiration.d.ts +17 -0
  39. package/dist/commands/inspiration.d.ts.map +1 -0
  40. package/dist/commands/inspiration.js +124 -0
  41. package/dist/commands/inspiration.js.map +1 -0
  42. package/dist/commands/media.d.ts +11 -0
  43. package/dist/commands/media.d.ts.map +1 -0
  44. package/dist/commands/media.js +76 -0
  45. package/dist/commands/media.js.map +1 -0
  46. package/dist/commands/model.d.ts +10 -0
  47. package/dist/commands/model.d.ts.map +1 -0
  48. package/dist/commands/model.js +27 -0
  49. package/dist/commands/model.js.map +1 -0
  50. package/dist/commands/pipeline.d.ts +10 -0
  51. package/dist/commands/pipeline.d.ts.map +1 -0
  52. package/dist/commands/pipeline.js +21 -0
  53. package/dist/commands/pipeline.js.map +1 -0
  54. package/dist/commands/post.d.ts +14 -0
  55. package/dist/commands/post.d.ts.map +1 -0
  56. package/dist/commands/post.js +267 -0
  57. package/dist/commands/post.js.map +1 -0
  58. package/dist/commands/schema.d.ts +11 -0
  59. package/dist/commands/schema.d.ts.map +1 -0
  60. package/dist/commands/schema.js +82 -0
  61. package/dist/commands/schema.js.map +1 -0
  62. package/dist/commands/upscale.d.ts +11 -0
  63. package/dist/commands/upscale.d.ts.map +1 -0
  64. package/dist/commands/upscale.js +56 -0
  65. package/dist/commands/upscale.js.map +1 -0
  66. package/dist/config.d.ts +35 -0
  67. package/dist/config.d.ts.map +1 -0
  68. package/dist/config.js +68 -0
  69. package/dist/config.js.map +1 -0
  70. package/dist/context.d.ts +45 -0
  71. package/dist/context.d.ts.map +1 -0
  72. package/dist/context.js +63 -0
  73. package/dist/context.js.map +1 -0
  74. package/dist/errors.d.ts +32 -0
  75. package/dist/errors.d.ts.map +1 -0
  76. package/dist/errors.js +51 -0
  77. package/dist/errors.js.map +1 -0
  78. package/dist/generation.d.ts +34 -0
  79. package/dist/generation.d.ts.map +1 -0
  80. package/dist/generation.js +111 -0
  81. package/dist/generation.js.map +1 -0
  82. package/dist/index.d.ts +11 -0
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/index.js +42 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/output.d.ts +14 -0
  87. package/dist/output.d.ts.map +1 -0
  88. package/dist/output.js +33 -0
  89. package/dist/output.js.map +1 -0
  90. package/dist/program.d.ts +11 -0
  91. package/dist/program.d.ts.map +1 -0
  92. package/dist/program.js +69 -0
  93. package/dist/program.js.map +1 -0
  94. package/package.json +52 -0
@@ -0,0 +1,267 @@
1
+ /**
2
+ * `contenthero post` - the content pipeline (posts, destinations, assets).
3
+ * post list | get | create | update | archive | schedule | publish
4
+ * post destination add | update
5
+ * post asset add
6
+ *
7
+ * A post is the container: create it, attach destinations (platforms) and assets
8
+ * (media URLs), then schedule or publish. Stages accept an id, slug, or name and
9
+ * resolve server-side. Writes need pipeline:write (assets need assets:write,
10
+ * publish needs publish:write); the key's scopes are the consent.
11
+ */
12
+ import { makeClient } from '../context.js';
13
+ import { emit, keyValues, table } from '../output.js';
14
+ import { CliError, EXIT } from '../errors.js';
15
+ import { compact } from '../generation.js';
16
+ import { toInt } from '../args.js';
17
+ const PLATFORMS = [
18
+ 'youtube',
19
+ 'instagram',
20
+ 'tiktok',
21
+ 'facebook',
22
+ 'linkedin',
23
+ 'x',
24
+ 'threads',
25
+ 'general',
26
+ ];
27
+ const STATUSES = ['draft', 'active', 'completed', 'archived'];
28
+ const CLEAR = ['null', 'clear', 'none'];
29
+ function assertPlatform(value) {
30
+ if (value && !PLATFORMS.includes(value)) {
31
+ throw new CliError(`Invalid platform "${value}". Expected one of: ${PLATFORMS.join(', ')}.`, EXIT.USAGE);
32
+ }
33
+ }
34
+ function assertStatus(value) {
35
+ if (value && !STATUSES.includes(value)) {
36
+ throw new CliError(`Invalid status "${value}". Expected one of: ${STATUSES.join(', ')}.`, EXIT.USAGE);
37
+ }
38
+ }
39
+ function summaryHuman(p, action) {
40
+ return keyValues([
41
+ ...(action ? [[action, p.title]] : [['Title', p.title]]),
42
+ ['Id', p.id],
43
+ ['Status', p.status],
44
+ ['Platform', p.platform ?? ''],
45
+ ...(p.scheduledAt ? [['Scheduled', p.scheduledAt]] : []),
46
+ ...(p.publishedAt ? [['Published', p.publishedAt]] : []),
47
+ ]);
48
+ }
49
+ function destinationHuman(d) {
50
+ return keyValues([
51
+ ['Destination', d.id],
52
+ ['Platform', d.platform ?? ''],
53
+ ['Format', d.format ?? ''],
54
+ ['Connected account', d.connectedAccountId ?? '(none)'],
55
+ ['Status', d.status ?? ''],
56
+ ...(d.scheduledAt ? [['Scheduled', d.scheduledAt]] : []),
57
+ ]);
58
+ }
59
+ export function registerPost(program) {
60
+ const post = program.command('post').description('Content pipeline: posts, destinations, assets');
61
+ post
62
+ .command('list')
63
+ .description('List posts (newest-updated first)')
64
+ .option('--status <status>', `filter by status: ${STATUSES.join(', ')}`)
65
+ .option('--platform <platform>', 'filter by platform')
66
+ .option('--stage <stage>', 'filter by pipeline stage (id, slug, or name)')
67
+ .option('--search <text>', 'case-insensitive title search')
68
+ .option('--favorite', 'only favorited posts')
69
+ .option('--limit <n>', 'how many to return (default 50)', toInt)
70
+ .option('--offset <n>', 'pagination offset', toInt)
71
+ .action(async (opts, command) => {
72
+ assertStatus(opts.status);
73
+ assertPlatform(opts.platform);
74
+ const { client, ctx } = makeClient(command);
75
+ const result = await client.listPosts({
76
+ status: opts.status,
77
+ platform: opts.platform,
78
+ pipelineStage: opts.stage,
79
+ search: opts.search,
80
+ isFavorite: opts.favorite === true ? true : undefined,
81
+ limit: opts.limit,
82
+ offset: opts.offset,
83
+ });
84
+ emit(result, ctx, (r) => {
85
+ const t = table(['ID', 'STATUS', 'PLATFORM', 'TITLE'], r.posts.map((p) => [p.id.slice(0, 8), p.status, p.platform ?? '', p.title]));
86
+ return `${t}\n\n${r.posts.length} of ${r.total}${r.hasMore ? ' (more available)' : ''}`;
87
+ });
88
+ });
89
+ post
90
+ .command('get')
91
+ .description('Get one post with its destinations and assets')
92
+ .argument('<id>', 'the post id')
93
+ .action(async (id, _opts, command) => {
94
+ const { client, ctx } = makeClient(command);
95
+ const p = await client.getPost(id);
96
+ emit(p, ctx, (post) => {
97
+ const head = keyValues([
98
+ ['Title', post.title],
99
+ ['Id', post.id],
100
+ ['Status', post.status],
101
+ ['Platform', post.platform ?? ''],
102
+ ...(post.scheduledAt ? [['Scheduled', post.scheduledAt]] : []),
103
+ ...(post.description ? [['Description', post.description]] : []),
104
+ ]);
105
+ const dests = post.destinations.length
106
+ ? '\n\nDestinations:\n' +
107
+ table(['PLATFORM', 'FORMAT', 'ACCOUNT', 'STATUS'], post.destinations.map((d) => [
108
+ d.platform ?? '',
109
+ d.format ?? '',
110
+ d.connectedAccountId ?? '',
111
+ d.status ?? '',
112
+ ]))
113
+ : '';
114
+ const assets = post.assets.length
115
+ ? '\n\nAssets:\n' +
116
+ table(['TYPE', 'NAME', 'URL'], post.assets.map((a) => [a.assetType ?? '', a.displayName ?? '', a.assetUrl ?? '']))
117
+ : '';
118
+ return head + dests + assets;
119
+ });
120
+ });
121
+ post
122
+ .command('create')
123
+ .description('Create a post (requires pipeline:write)')
124
+ .argument('<title>', 'post title')
125
+ .requiredOption('--platform <platform>', `primary platform: ${PLATFORMS.join(', ')}`)
126
+ .option('--description <text>', 'description / caption draft')
127
+ .option('--stage <stage>', 'pipeline stage id, slug, or name (defaults to the first stage)')
128
+ .action(async (title, opts, command) => {
129
+ assertPlatform(opts.platform);
130
+ const { client, ctx } = makeClient(command);
131
+ const input = compact({
132
+ title,
133
+ platform: opts.platform,
134
+ description: opts.description,
135
+ stage: opts.stage,
136
+ });
137
+ emit(await client.createPost(input), ctx, (p) => summaryHuman(p, 'Created'));
138
+ });
139
+ post
140
+ .command('update')
141
+ .description("Update a post's fields, including its pipeline stage (requires pipeline:write)")
142
+ .argument('<id>', 'the post id')
143
+ .option('--title <text>')
144
+ .option('--description <text>')
145
+ .option('--platform <platform>')
146
+ .option('--status <status>')
147
+ .option('--stage <stage>', 'move the post to this stage (id, slug, or name)')
148
+ .option('--script <text>')
149
+ .option('--notes <text>')
150
+ .action(async (id, opts, command) => {
151
+ assertPlatform(opts.platform);
152
+ assertStatus(opts.status);
153
+ const { client, ctx } = makeClient(command);
154
+ const input = compact({
155
+ title: opts.title,
156
+ description: opts.description,
157
+ platform: opts.platform,
158
+ status: opts.status,
159
+ stage: opts.stage,
160
+ script: opts.script,
161
+ notes: opts.notes,
162
+ });
163
+ emit(await client.updatePost(id, input), ctx, (p) => summaryHuman(p, 'Updated'));
164
+ });
165
+ post
166
+ .command('archive')
167
+ .description('Archive a post (status -> archived; reversible)')
168
+ .argument('<id>', 'the post id')
169
+ .action(async (id, _opts, command) => {
170
+ const { client, ctx } = makeClient(command);
171
+ emit(await client.archivePost(id), ctx, (p) => summaryHuman(p, 'Archived'));
172
+ });
173
+ post
174
+ .command('schedule')
175
+ .description('Set or clear the scheduled publish time on a post and its destinations')
176
+ .argument('<id>', 'the post id')
177
+ .argument('<when>', 'ISO-8601 timestamp, or "clear" to unschedule')
178
+ .action(async (id, when, _opts, command) => {
179
+ const { client, ctx } = makeClient(command);
180
+ const scheduledAt = CLEAR.includes(when.toLowerCase()) ? null : when;
181
+ emit(await client.schedulePost(id, scheduledAt), ctx, (p) => summaryHuman(p, scheduledAt ? 'Scheduled' : 'Unscheduled'));
182
+ });
183
+ post
184
+ .command('publish')
185
+ .description('Publish a post NOW to its destinations (requires publish:write; pushes to live socials)')
186
+ .argument('<id>', 'the post id')
187
+ .option('--platform <platform>', 'publish only this platform (default: all destinations)')
188
+ .action(async (id, opts, command) => {
189
+ assertPlatform(opts.platform);
190
+ const { client, ctx } = makeClient(command);
191
+ const result = await client.publishPost(id, { platform: opts.platform });
192
+ emit(result, ctx, (r) => {
193
+ const t = table(['PLATFORM', 'OK', 'URL / ERROR'], r.results.map((d) => [d.platform, d.success ? 'yes' : 'no', d.url ?? d.error ?? '']));
194
+ return `${t}\n\nPublished ${r.publishedCount}, failed ${r.failedCount}`;
195
+ });
196
+ if (result.failedCount > 0)
197
+ process.exitCode = EXIT.GENERAL;
198
+ });
199
+ // -- post destination -----------------------------------------------------
200
+ const destination = post.command('destination').description('Manage a post\'s publish destinations');
201
+ destination
202
+ .command('add')
203
+ .description('Attach (or replace) a destination on a post (requires pipeline:write)')
204
+ .argument('<postId>', 'the post id')
205
+ .requiredOption('--platform <platform>', `destination platform: ${PLATFORMS.join(', ')}`)
206
+ .option('--format <format>', "platform format, e.g. post, reel, story, short, thread")
207
+ .option('--account <id>', 'connected account id (from `connected-account list`)')
208
+ .option('--scheduled <iso>', 'ISO-8601 scheduled time for this destination')
209
+ .action(async (postId, opts, command) => {
210
+ assertPlatform(opts.platform);
211
+ const { client, ctx } = makeClient(command);
212
+ const d = await client.addPostDestination(postId, {
213
+ platform: opts.platform,
214
+ format: opts.format,
215
+ connectedAccountId: opts.account,
216
+ scheduledAt: opts.scheduled,
217
+ });
218
+ emit(d, ctx, destinationHuman);
219
+ });
220
+ destination
221
+ .command('update')
222
+ .description('Update one of a post\'s destinations (requires pipeline:write)')
223
+ .argument('<postId>', 'the post id')
224
+ .argument('<destinationId>', 'the destination id (from `post get`)')
225
+ .option('--format <format>')
226
+ .option('--account <id>', 'connected account id')
227
+ .option('--scheduled <iso>', 'ISO-8601 scheduled time')
228
+ .option('--status <status>')
229
+ .action(async (postId, destinationId, opts, command) => {
230
+ const { client, ctx } = makeClient(command);
231
+ const d = await client.updatePostDestination(postId, destinationId, {
232
+ format: opts.format,
233
+ connectedAccountId: opts.account,
234
+ scheduledAt: opts.scheduled,
235
+ status: opts.status,
236
+ });
237
+ emit(d, ctx, destinationHuman);
238
+ });
239
+ // -- post asset -----------------------------------------------------------
240
+ const asset = post.command('asset').description('Manage a post\'s assets');
241
+ asset
242
+ .command('add')
243
+ .description('Attach an asset to a post by URL (requires assets:write)')
244
+ .argument('<postId>', 'the post id')
245
+ .requiredOption('--type <type>', 'asset type: image, video, audio, document, link')
246
+ .requiredOption('--url <url>', 'public URL of the asset')
247
+ .option('--name <name>', 'optional display name')
248
+ .action(async (postId, opts, command) => {
249
+ const types = ['image', 'video', 'audio', 'document', 'link'];
250
+ if (!types.includes(opts.type)) {
251
+ throw new CliError(`Invalid --type "${opts.type}". Expected one of: ${types.join(', ')}.`, EXIT.USAGE);
252
+ }
253
+ const { client, ctx } = makeClient(command);
254
+ const a = await client.addPostAsset(postId, {
255
+ assetType: opts.type,
256
+ assetUrl: opts.url,
257
+ displayName: opts.name,
258
+ });
259
+ emit(a, ctx, () => keyValues([
260
+ ['Asset', a.id],
261
+ ['Type', a.assetType ?? ''],
262
+ ['Name', a.displayName ?? ''],
263
+ ['URL', a.assetUrl ?? ''],
264
+ ]));
265
+ });
266
+ }
267
+ //# sourceMappingURL=post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post.js","sourceRoot":"","sources":["../../src/commands/post.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAcH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,MAAM,SAAS,GAAmB;IAChC,SAAS;IACT,WAAW;IACX,QAAQ;IACR,UAAU;IACV,UAAU;IACV,GAAG;IACH,SAAS;IACT,SAAS;CACV,CAAA;AACD,MAAM,QAAQ,GAAiB,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,CAAC,CAAA;AAC3E,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAEvC,SAAS,cAAc,CAAC,KAAyB;IAC/C,IAAI,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAqB,CAAC,EAAE,CAAC;QACxD,MAAM,IAAI,QAAQ,CAAC,qBAAqB,KAAK,uBAAuB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA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;YACzE,QAAQ,EAAE,IAAI,CAAC,GAAa;YAC5B,WAAW,EAAE,IAAI,CAAC,IAA0B;SAC7C,CAAC,CAAA;QACF,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAChB,SAAS,CAAC;YACR,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC;YACf,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC;YAC3B,CAAC,MAAM,EAAE,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC;YAC7B,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC;SAC1B,CAAC,CACH,CAAA;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `contenthero schema [command...]` - dump the input schema of the CLI's commands
3
+ * as JSON, so an agent can discover argument and option shapes without docs (our
4
+ * analog to HeyGen's `--request-schema`). With no argument it dumps every leaf
5
+ * command; with a path (e.g. `schema generate image`) it dumps just that subtree.
6
+ *
7
+ * Needs no API key: it reflects over the command tree, it does not call the API.
8
+ */
9
+ import type { Command } from 'commander';
10
+ export declare function registerSchema(program: Command): void;
11
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/commands/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAU,MAAM,WAAW,CAAA;AAqEhD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4BrD"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * `contenthero schema [command...]` - dump the input schema of the CLI's commands
3
+ * as JSON, so an agent can discover argument and option shapes without docs (our
4
+ * analog to HeyGen's `--request-schema`). With no argument it dumps every leaf
5
+ * command; with a path (e.g. `schema generate image`) it dumps just that subtree.
6
+ *
7
+ * Needs no API key: it reflects over the command tree, it does not call the API.
8
+ */
9
+ import { globalsOf } from '../context.js';
10
+ import { emit } from '../output.js';
11
+ import { CliError, EXIT } from '../errors.js';
12
+ /** Subcommands minus the auto-added `help`. */
13
+ function realSubcommands(cmd) {
14
+ return cmd.commands.filter((c) => c.name() !== 'help');
15
+ }
16
+ function describeOption(o) {
17
+ const schema = {
18
+ flags: o.flags,
19
+ required: o.mandatory === true,
20
+ takesValue: o.required === true || o.optional === true,
21
+ };
22
+ if (o.description)
23
+ schema.description = o.description;
24
+ if (o.defaultValue !== undefined)
25
+ schema.default = o.defaultValue;
26
+ return schema;
27
+ }
28
+ function describe(cmd, path) {
29
+ const args = (cmd.registeredArguments ?? []).map((a) => {
30
+ const schema = { name: a.name(), required: a.required, variadic: a.variadic };
31
+ if (a.description)
32
+ schema.description = a.description;
33
+ return schema;
34
+ });
35
+ return {
36
+ command: path,
37
+ description: cmd.description(),
38
+ arguments: args,
39
+ options: cmd.options.map(describeOption),
40
+ };
41
+ }
42
+ /** Collect every leaf (action-bearing) command, with its full space-joined path. */
43
+ function collectLeaves(cmd, prefix) {
44
+ const out = [];
45
+ for (const sub of realSubcommands(cmd)) {
46
+ const path = [...prefix, sub.name()];
47
+ if (realSubcommands(sub).length === 0) {
48
+ out.push(describe(sub, path.join(' ')));
49
+ }
50
+ else {
51
+ out.push(...collectLeaves(sub, path));
52
+ }
53
+ }
54
+ return out;
55
+ }
56
+ export function registerSchema(program) {
57
+ program
58
+ .command('schema')
59
+ .description('Dump the input schema of the CLI commands as JSON (for agents)')
60
+ .argument('[command...]', 'a command path to scope the dump, e.g. "generate image"')
61
+ .action((parts, _opts, command) => {
62
+ const target = parts.join(' ');
63
+ const all = collectLeaves(program, []);
64
+ const commands = target
65
+ ? all.filter((c) => c.command === target || c.command.startsWith(target + ' '))
66
+ : all;
67
+ if (target && commands.length === 0) {
68
+ throw new CliError(`No command matches "${target}". Run \`contenthero schema\` for the full list.`, EXIT.USAGE);
69
+ }
70
+ const globalOptions = program.options.map(describeOption);
71
+ const data = { globalOptions, commands };
72
+ const { json } = globalsOf(command);
73
+ emit(data, { json }, (d) => d.commands
74
+ .map((c) => {
75
+ const argline = c.arguments.map((a) => (a.required ? `<${a.name}>` : `[${a.name}]`)).join(' ');
76
+ const opts = c.options.map((o) => ` ${o.flags}${o.description ? ` - ${o.description}` : ''}`);
77
+ return [`contenthero ${c.command}${argline ? ' ' + argline : ''}`, ...opts].join('\n');
78
+ })
79
+ .join('\n\n'));
80
+ });
81
+ }
82
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/commands/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAsB7C,+CAA+C;AAC/C,SAAS,eAAe,CAAC,GAAY;IACnC,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC,CAAA;AACxD,CAAC;AAED,SAAS,cAAc,CAAC,CAAS;IAC/B,MAAM,MAAM,GAAiB;QAC3B,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,QAAQ,EAAE,CAAC,CAAC,SAAS,KAAK,IAAI;QAC9B,UAAU,EAAE,CAAC,CAAC,QAAQ,KAAK,IAAI,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI;KACvD,CAAA;IACD,IAAI,CAAC,CAAC,WAAW;QAAE,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAA;IACrD,IAAI,CAAC,CAAC,YAAY,KAAK,SAAS;QAAE,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,YAAY,CAAA;IACjE,OAAO,MAAM,CAAA;AACf,CAAC;AAED,S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AI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAC9F,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;YACjG,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACxF,CAAC,CAAC;aACD,IAAI,CAAC,MAAM,CAAC,CAChB,CAAA;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `contenthero upscale <source>` - upscale an existing image or video.
3
+ *
4
+ * Whether the source is bucketed as an image or a video reference depends on the
5
+ * model, so we resolve the model's content type from the discovery catalog first
6
+ * (rather than asking the user to declare it). Video upscalers also price on the
7
+ * source duration, so --duration is required for them.
8
+ */
9
+ import type { Command } from 'commander';
10
+ export declare function registerUpscale(program: Command): void;
11
+ //# sourceMappingURL=upscale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upscale.d.ts","sourceRoot":"","sources":["../../src/commands/upscale.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASxC,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkDtD"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * `contenthero upscale <source>` - upscale an existing image or video.
3
+ *
4
+ * Whether the source is bucketed as an image or a video reference depends on the
5
+ * model, so we resolve the model's content type from the discovery catalog first
6
+ * (rather than asking the user to declare it). Video upscalers also price on the
7
+ * source duration, so --duration is required for them.
8
+ */
9
+ import { makeClient } from '../context.js';
10
+ import { compact, runGeneration } from '../generation.js';
11
+ import { CliError, EXIT } from '../errors.js';
12
+ import { toFloat, toInt } from '../args.js';
13
+ const DEFAULT_TIMEOUT_SEC = 600;
14
+ export function registerUpscale(program) {
15
+ program
16
+ .command('upscale')
17
+ .description('Upscale an existing image or video to a higher resolution')
18
+ .argument('<source>', 'source media (URL or output id) to upscale')
19
+ .requiredOption('-m, --model <id>', 'upscale model id (see `contenthero model list`)')
20
+ .requiredOption('--factor <factor>', 'upscale factor, e.g. 2x, 4x (model-dependent)')
21
+ .option('--duration <seconds>', 'source video length in seconds (required for video upscalers)', toFloat)
22
+ .option('--cost', 'estimate the credit cost instead of upscaling')
23
+ .option('--no-wait', 'return the outputId immediately instead of waiting')
24
+ .option('--timeout <seconds>', 'how long to wait before handing back the outputId', toInt, DEFAULT_TIMEOUT_SEC)
25
+ .action(async (source, opts, command) => {
26
+ const { client, ctx } = makeClient(command);
27
+ // Resolve the model so we bucket the source correctly and validate it is
28
+ // actually an upscaler. listModels is the discovery source of truth.
29
+ const modelId = opts.model;
30
+ const models = await client.listModels();
31
+ const model = models.find((m) => m.modelId === modelId);
32
+ if (!model) {
33
+ throw new CliError(`Unknown model "${modelId}". See \`contenthero model list\`.`, EXIT.USAGE);
34
+ }
35
+ if (model.kind !== 'upscale') {
36
+ throw new CliError(`Model "${modelId}" is a ${model.kind} model, not an upscaler.`, EXIT.USAGE);
37
+ }
38
+ const isVideo = model.contentType === 'video';
39
+ if (isVideo && opts.duration == null) {
40
+ throw new CliError('Video upscalers require --duration <seconds> for pricing.', EXIT.USAGE);
41
+ }
42
+ const request = compact({
43
+ contentType: isVideo ? 'video' : 'image',
44
+ modelId,
45
+ upscaleFactor: opts.factor,
46
+ duration: isVideo ? opts.duration : undefined,
47
+ references: isVideo ? { videos: [source] } : { images: [source] },
48
+ });
49
+ await runGeneration(client, ctx, request, {
50
+ cost: opts.cost === true,
51
+ wait: opts.wait !== false,
52
+ timeoutSec: opts.timeout ?? DEFAULT_TIMEOUT_SEC,
53
+ });
54
+ });
55
+ }
56
+ //# sourceMappingURL=upscale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upscale.js","sourceRoot":"","sources":["../../src/commands/upscale.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE3C,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAE/B,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,2DAA2D,CAAC;SACxE,QAAQ,CAAC,UAAU,EAAE,4CAA4C,CAAC;SAClE,cAAc,CAAC,kBAAkB,EAAE,iDAAiD,CAAC;SACrF,cAAc,CAAC,mBAAmB,EAAE,+CAA+C,CAAC;SACpF,MAAM,CAAC,sBAAsB,EAAE,+DAA+D,EAAE,OAAO,CAAC;SACxG,MAAM,CAAC,QAAQ,EAAE,+CAA+C,CAAC;SACjE,MAAM,CAAC,WAAW,EAAE,oDAAoD,CAAC;SACzE,MAAM,CAAC,qBAAqB,EAAE,mDAAmD,EAAE,KAAK,EAAE,mBAAmB,CAAC;SAC9G,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,IAA6B,EAAE,OAAgB,EAAE,EAAE;QAChF,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;QAE3C,yEAAyE;QACzE,qE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C,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,IAAI;YACxB,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,KAAK;YACzB,UAAU,EAAG,IAAI,CAAC,OAAkB,IAAI,mBAAmB;SAC5D,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * On-disk config + credential storage for the CLI.
3
+ *
4
+ * Two files under the config dir (default `~/.contenthero`, override with
5
+ * CONTENTHERO_CONFIG_DIR):
6
+ * - `credentials` : the stored API key (written by `contenthero login`).
7
+ * Mode 0600; it is the only secret on disk.
8
+ * - `config.json` : non-secret preferences (e.g. baseUrl).
9
+ *
10
+ * Reads tolerate a missing or malformed file by returning empty, so a fresh
11
+ * machine just falls through the auth ladder to env / flag. Writes create the
12
+ * dir at 0700 first.
13
+ */
14
+ /** A stored credential. JSON so we can grow it (label, createdAt) without a format break. */
15
+ export interface StoredCredential {
16
+ apiKey: string;
17
+ /** The key's display label, when minted via the browser flow (e.g. "CLI (host)"). */
18
+ label?: string;
19
+ /** ISO timestamp the credential was stored. */
20
+ createdAt?: string;
21
+ }
22
+ /** Non-secret CLI preferences. */
23
+ export interface StoredConfig {
24
+ /** Override API base URL (e.g. a preview deployment). */
25
+ baseUrl?: string;
26
+ }
27
+ export declare function configDir(): string;
28
+ export declare function credentialsPath(): string;
29
+ export declare function configPath(): string;
30
+ export declare function readCredential(): StoredCredential | undefined;
31
+ export declare function writeCredential(cred: StoredCredential): void;
32
+ export declare function clearCredential(): boolean;
33
+ export declare function readConfig(): StoredConfig;
34
+ export declare function writeConfig(config: StoredConfig): void;
35
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAaH,6FAA6F;AAC7F,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,kCAAkC;AAClC,MAAM,WAAW,YAAY;IAC3B,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAkBD,wBAAgB,cAAc,IAAI,gBAAgB,GAAG,SAAS,CAE7D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAM5D;AAED,wBAAgB,eAAe,IAAI,OAAO,CAKzC;AAED,wBAAgB,UAAU,IAAI,YAAY,CAEzC;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAGtD"}
package/dist/config.js ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * On-disk config + credential storage for the CLI.
3
+ *
4
+ * Two files under the config dir (default `~/.contenthero`, override with
5
+ * CONTENTHERO_CONFIG_DIR):
6
+ * - `credentials` : the stored API key (written by `contenthero login`).
7
+ * Mode 0600; it is the only secret on disk.
8
+ * - `config.json` : non-secret preferences (e.g. baseUrl).
9
+ *
10
+ * Reads tolerate a missing or malformed file by returning empty, so a fresh
11
+ * machine just falls through the auth ladder to env / flag. Writes create the
12
+ * dir at 0700 first.
13
+ */
14
+ import { homedir } from 'node:os';
15
+ import { join } from 'node:path';
16
+ import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, } from 'node:fs';
17
+ export function configDir() {
18
+ return process.env.CONTENTHERO_CONFIG_DIR || join(homedir(), '.contenthero');
19
+ }
20
+ export function credentialsPath() {
21
+ return join(configDir(), 'credentials');
22
+ }
23
+ export function configPath() {
24
+ return join(configDir(), 'config.json');
25
+ }
26
+ function ensureDir() {
27
+ const dir = configDir();
28
+ if (!existsSync(dir))
29
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
30
+ }
31
+ function readJson(path) {
32
+ try {
33
+ if (!existsSync(path))
34
+ return undefined;
35
+ const raw = readFileSync(path, 'utf8').trim();
36
+ if (!raw)
37
+ return undefined;
38
+ return JSON.parse(raw);
39
+ }
40
+ catch {
41
+ return undefined;
42
+ }
43
+ }
44
+ export function readCredential() {
45
+ return readJson(credentialsPath());
46
+ }
47
+ export function writeCredential(cred) {
48
+ ensureDir();
49
+ const path = credentialsPath();
50
+ writeFileSync(path, JSON.stringify(cred, null, 2) + '\n', { mode: 0o600 });
51
+ // writeFileSync only applies mode on create; force it in case the file existed.
52
+ chmodSync(path, 0o600);
53
+ }
54
+ export function clearCredential() {
55
+ const path = credentialsPath();
56
+ if (!existsSync(path))
57
+ return false;
58
+ rmSync(path);
59
+ return true;
60
+ }
61
+ export function readConfig() {
62
+ return readJson(configPath()) ?? {};
63
+ }
64
+ export function writeConfig(config) {
65
+ ensureDir();
66
+ writeFileSync(configPath(), JSON.stringify(config, null, 2) + '\n', { mode: 0o644 });
67
+ }
68
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAA;AAiBhB,MAAM,UAAU,SAAS;IACvB,OAAO,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,cAAc,CAAC,CAAA;AAC9E,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,IAAI,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAA;AACzC,CAA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AA;IACnC,MAAM,CAAC,IAAI,CAAC,CAAA;IACZ,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,QAAQ,CAAe,UAAU,EAAE,CAAC,IAAI,EAAE,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAoB;IAC9C,SAAS,EAAE,CAAA;IACX,aAAa,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;AACtF,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Per-invocation context: resolve global options, the API key, and the SDK client.
3
+ *
4
+ * Auth ladder (highest priority first):
5
+ * 1. --api-key flag
6
+ * 2. CONTENTHERO_API_KEY env
7
+ * 3. the stored credential file (written by `contenthero login`)
8
+ *
9
+ * Base URL ladder: --base-url flag, then CONTENTHERO_BASE_URL env, then the
10
+ * stored config, then the SDK default. The SDK reads the same env vars itself,
11
+ * but resolving here keeps the precedence explicit and lets us report the key
12
+ * source in `auth status` / `config list`.
13
+ */
14
+ import { ContentHero } from '@contenthero/sdk';
15
+ import type { Command } from 'commander';
16
+ /** Where the active key came from (for diagnostics, never the key itself). */
17
+ export type KeySource = 'flag' | 'env' | 'file' | 'none';
18
+ /** Global options merged onto every command. */
19
+ export interface GlobalOptions {
20
+ json: boolean;
21
+ human: boolean;
22
+ apiKey?: string;
23
+ baseUrl?: string;
24
+ }
25
+ /** The resolved invocation context. */
26
+ export interface Context {
27
+ /** True when output should be raw JSON (the default). */
28
+ json: boolean;
29
+ apiKey?: string;
30
+ keySource: KeySource;
31
+ baseUrl?: string;
32
+ }
33
+ /** Read the merged global options off any command in the tree. */
34
+ export declare function globalsOf(command: Command): GlobalOptions;
35
+ /** Resolve the API key and where it came from, without constructing a client. */
36
+ export declare function resolveContext(command: Command): Context;
37
+ /**
38
+ * Build an authenticated SDK client for this command, or throw a CliError with
39
+ * the auth exit code when no key is configured anywhere in the ladder.
40
+ */
41
+ export declare function makeClient(command: Command): {
42
+ client: ContentHero;
43
+ ctx: Context;
44
+ };
45
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAIxC,8EAA8E;AAC9E,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAExD,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,uCAAuC;AACvC,MAAM,WAAW,OAAO;IACtB,yDAAyD;IACzD,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CASzD;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAuBxD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,CAUlF"}