makaron-cli 0.17.23 → 0.17.25

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makaron-cli",
3
- "version": "0.17.23",
3
+ "version": "0.17.25",
4
4
  "description": "Give Claude Code a creative agent. Pass complete creative requests and source media to Makaron Chat.",
5
5
  "author": {
6
6
  "name": "Versa AI",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makaron-cli",
3
- "version": "0.17.23",
3
+ "version": "0.17.25",
4
4
  "description": "Give Codex a creative agent. Pass complete creative requests and source media to Makaron Chat.",
5
5
  "author": {
6
6
  "name": "Versa AI",
package/README.md CHANGED
@@ -72,6 +72,20 @@ npx makaron-cli claim
72
72
  ```
73
73
  Share the `claim_url` with a human. They log in and the API key gets linked to their account. Claim links are valid for 7 days. Run `claim` again anytime to get a new link.
74
74
 
75
+
76
+ ## Check generation credits on demand
77
+
78
+ Use `makaron price` when the user asks about price, budget, or how models compare. For routine creation, go directly to the requested workflow. `price list` discovers model IDs and supported resolutions. The quote includes customer-facing credits and applicable billing factors. It does not start a run, upload media or read your balance.
79
+
80
+ ```bash
81
+ makaron price list --json
82
+ makaron price video --model kling-4-flash --model seedance-2.5-native --duration 5 --resolution 720p
83
+ makaron price image --model seedream-5.5 --operation edit --image-count 3 --resolution 2K --json
84
+ makaron price audio --model evolink-seed-audio --duration 20
85
+ ```
86
+
87
+ For video references, pass both `--video-reference-count` and the total `--reference-video-seconds`. Count an edit's base image in `--image-count`. Use `--input <file|-> --json` for up to six requests with different parameters. The JSON body is `{"requests":[{"kind":"video","model":"kling-4-flash","duration_seconds":5,"image_count":0,"resolution":"720p"}]}`. Exit `2` means at least one quote is unavailable, unsupported or missing inputs. A `preflight_only` amount is an estimate that may differ from the final charge.
88
+
75
89
  ## Core Workflow
76
90
 
77
91
  ```bash
package/bin/makaron.mjs CHANGED
@@ -17,6 +17,7 @@ import path from 'path';
17
17
  import { createInterface } from 'readline';
18
18
  import { execFileSync } from 'child_process';
19
19
  import { fileURLToPath } from 'url';
20
+ import { printPriceHelp, runPrice } from './price.mjs';
20
21
 
21
22
  // ─── Config ──────────────────────────────────────────────────────────────────
22
23
 
@@ -2312,6 +2313,7 @@ Commands:
2312
2313
  claim Get claim URL for human to link account
2313
2314
  login Log in to Makaron (human interactive)
2314
2315
  credits Show current credit balance
2316
+ price list|image|video|audio Estimate generation credits and compare models
2315
2317
  usage [--run <id>] [--project <id>] Credit usage history (chat prints per-run usage)
2316
2318
  list (ls) List all projects
2317
2319
  project media <projectId> --json List timeline media for a project
@@ -2418,6 +2420,7 @@ function setupMakaron(values = []) {
2418
2420
  }
2419
2421
 
2420
2422
  function printHelp(topic, subtopic) {
2423
+ if (topic === 'price') { printPriceHelp(); return; }
2421
2424
  if (topic === 'layerize') { printLayerizeHelp(); return; }
2422
2425
  if (topic === 'login') {
2423
2426
  console.log('Usage: makaron login');
@@ -2590,6 +2593,13 @@ if (!command || command === '--help' || command === '-h' || command === 'help')
2590
2593
  console.log('Subscription: none');
2591
2594
  }
2592
2595
  }
2596
+ } else if (command === 'price') {
2597
+ try {
2598
+ await runPrice(args.slice(1), getAuth);
2599
+ } catch (error) {
2600
+ console.error(error.message);
2601
+ process.exitCode = 1;
2602
+ }
2593
2603
  } else if (command === 'usage') {
2594
2604
  const { headers, baseUrl } = getAuth();
2595
2605
  const params = new URLSearchParams();
package/bin/price.mjs ADDED
@@ -0,0 +1,157 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { parseArgs } from 'node:util';
3
+
4
+ const quoteKinds = ['image', 'video', 'audio'];
5
+ const textFields = {
6
+ resolution: 'resolution', operation: 'operation', aspect: 'aspect_ratio', background: 'background',
7
+ quality: 'image_quality', 'image-reasoning': 'image_reasoning_effort', 'output-format': 'output_format',
8
+ };
9
+ const numberFields = {
10
+ duration: 'duration_seconds', 'image-count': 'image_count', 'video-reference-count': 'video_reference_count',
11
+ 'reference-video-seconds': 'reference_video_seconds', 'reference-image-pixels': 'reference_image_pixels',
12
+ 'audio-reference-count': 'audio_reference_count', 'reference-audio-seconds': 'reference_audio_seconds',
13
+ fps: 'output_fps', 'frame-count': 'frame_count',
14
+ };
15
+ const fields = [...Object.keys(textFields), ...Object.keys(numberFields)];
16
+ const options = {
17
+ json: { type: 'boolean' }, input: { type: 'string' }, model: { type: 'string', multiple: true },
18
+ 'content-filter': { type: 'string' },
19
+ ...Object.fromEntries(fields.map(name => [name, { type: 'string' }])),
20
+ };
21
+ const statuses = {
22
+ usage_only: 'Priced after generation', unknown: 'Price unavailable', needs_inputs: 'Missing inputs', unsupported: 'Unsupported request',
23
+ };
24
+
25
+ export function printPriceHelp() {
26
+ console.log(`Makaron price — check media credits on demand
27
+
28
+ Usage:
29
+ makaron price list [--json]
30
+ makaron price <image|video|audio> --model <id> [--model <id>] [options]
31
+ makaron price --input <file|-> [--json]
32
+
33
+ --model <id> Repeat to compare up to six models with the same parameters
34
+ --duration <seconds> Requested output duration for video/audio
35
+ --resolution <tier> Output resolution (for example 720p or 2K)
36
+ --operation <mode> generate, edit or extend
37
+ --image-count <n> All input images, including the edit base (default 0)
38
+ --video-reference-count <n> --reference-video-seconds <seconds>
39
+ Count and total duration of video inputs
40
+ --reference-image-pixels <n> Total input pixels for usage-based video references
41
+ --audio-reference-count <n> --reference-audio-seconds <seconds>
42
+ Count and total duration of audio inputs
43
+ --fps <n> --content-filter <true|false>
44
+ --aspect <ratio> --background <mode> --quality <tier> --image-reasoning <level>
45
+ --output-format <format> --frame-count <n>
46
+ --input <file|-> JSON {"requests":[...]} for different parameters per quote
47
+ --json Machine-readable result with per-quote status
48
+
49
+ Examples:
50
+ makaron price video --model kling-4-flash --model seedance-2.5-native --duration 5 --resolution 720p
51
+ makaron price image --model seedream-5.5 --resolution 2K --operation edit --image-count 3
52
+ makaron price audio --model evolink-seed-audio --duration 20
53
+
54
+ Quotes are read-only and cover generation credits. Exit 2 if any requested quote is unavailable,
55
+ unsupported or missing inputs. Preflight estimates are labeled. API and usage errors exit 1.
56
+ `);
57
+ }
58
+
59
+ function parsePriceRequest(args) {
60
+ const { positionals, values } = parseArgs({ args, options, allowPositionals: true });
61
+ const [kind] = positionals;
62
+ const quoteFlags = [...fields, 'content-filter', 'model'];
63
+ if (values.input != null) {
64
+ if (positionals.length || quoteFlags.some(flag => values[flag] !== undefined)) {
65
+ throw new Error('--input cannot be combined with quote flags or a media kind.');
66
+ }
67
+ let input;
68
+ try {
69
+ input = JSON.parse(readFileSync(values.input === '-' ? 0 : values.input, 'utf8'));
70
+ } catch {
71
+ throw new Error('Could not read pricing JSON. Pass a file path or - for stdin.');
72
+ }
73
+ if (!Array.isArray(input?.requests) || input.requests.length > 6) {
74
+ throw new Error('Pricing JSON must contain a requests array with at most six quotes.');
75
+ }
76
+ return { input, json: values.json };
77
+ }
78
+ if (positionals.length <= 1 && (!kind || kind === 'list') && quoteFlags.every(flag => values[flag] === undefined)) {
79
+ return { input: { requests: [] }, json: values.json };
80
+ }
81
+ if (positionals.length !== 1 || !quoteKinds.includes(kind) || !values.model?.length || values.model.length > 6 || values.model.some(model => !model.trim())) {
82
+ throw new Error('Choose image, video or audio and supply one to six --model IDs. See makaron price --help.');
83
+ }
84
+ const parameters = { kind, image_count: 0 };
85
+ for (const [flag, field] of Object.entries(textFields)) {
86
+ if (values[flag] !== undefined) parameters[field] = values[flag];
87
+ }
88
+ for (const [flag, field] of Object.entries(numberFields)) {
89
+ if (values[flag] === undefined) continue;
90
+ const raw = values[flag];
91
+ const number = Number(raw);
92
+ if (!raw.trim() || !Number.isFinite(number) || number < 0) throw new Error(`--${flag} requires a nonnegative number.`);
93
+ parameters[field] = number;
94
+ }
95
+ if (values['content-filter'] !== undefined) {
96
+ if (!['true', 'false'].includes(values['content-filter'])) throw new Error('--content-filter requires true or false.');
97
+ parameters.content_filter = values['content-filter'] === 'true';
98
+ }
99
+ return { input: { requests: values.model.map(model => ({ ...parameters, model })) }, json: values.json };
100
+ }
101
+
102
+ function printPrices(result) {
103
+ if (result.catalog) {
104
+ for (const [kind, models] of Object.entries(result.catalog)) {
105
+ console.log(`${kind}:`);
106
+ for (const model of models) {
107
+ const resolution = model.resolutions?.length ? ` (${model.resolutions.join(', ')})` : '';
108
+ const duration = model.maxSeconds ? ` · ${model.minSeconds ? `${model.minSeconds}–` : 'up to '}${model.maxSeconds}s` : '';
109
+ console.log(` ${model.model}${resolution}${duration}`);
110
+ }
111
+ }
112
+ return;
113
+ }
114
+ for (const row of result.estimates) {
115
+ const label = [row.request.model, row.resolution ?? row.request.resolution, row.request.duration_seconds ? `${row.request.duration_seconds}s` : null].filter(Boolean).join(' · ');
116
+ if (row.status === 'estimated' || row.status === 'preflight_only') {
117
+ console.log(`${label}: ${row.credits} credits${row.status === 'preflight_only' ? ' (preflight estimate; final charge may vary)' : ''}`);
118
+ if (row.details?.billableInputImages) console.log(` Includes ${row.details.billableInputImages} billable input image(s).`);
119
+ for (const item of row.billingBasis ?? []) {
120
+ if (item.billableReferenceVideoSeconds) console.log(` Includes ${item.billableReferenceVideoSeconds}s of billable reference video.`);
121
+ if (item.billableInputImages) console.log(` Includes ${item.billableInputImages} billable input image(s).`);
122
+ }
123
+ if (row.details?.settlement && row.status !== 'preflight_only') console.log(` ${row.details.settlement}`);
124
+ } else {
125
+ console.log(`${label}: ${statuses[row.status] ?? row.status}. ${row.reason ?? ''}${row.missing?.length ? ` (${row.missing.join(', ')})` : ''}`.trim());
126
+ }
127
+ }
128
+ const ranked = result.comparison?.rows ?? [];
129
+ if (ranked.length > 1) {
130
+ console.log(`Lowest known estimate: ${result.comparison.lowestKnownCredits} credits among comparable requests.`);
131
+ if (ranked.length === 2) console.log(`Difference: ${Math.abs(ranked[0].credits - ranked[1].credits)} credits.`);
132
+ }
133
+ console.log(`Observed: ${result.observedAt}`);
134
+ }
135
+
136
+ export async function runPrice(args, getAuth) {
137
+ const { input, json } = parsePriceRequest(args);
138
+ const { headers, baseUrl } = getAuth();
139
+ const response = await fetch(`${baseUrl}/api/billing/model-prices`, {
140
+ method: 'POST', headers: { ...headers, 'Content-Type': 'application/json' },
141
+ body: JSON.stringify(input), signal: AbortSignal.timeout(30_000),
142
+ });
143
+ if (response.status === 401 || response.status === 403) throw new Error('Authentication failed. Check your Makaron login or API key.');
144
+ if (response.status === 404) throw new Error('This Makaron server does not support price quotes yet.');
145
+ const result = await response.json().catch(() => null);
146
+ if (!response.ok) {
147
+ const fields = Array.isArray(result?.invalidFields) ? ` (${result.invalidFields.join(', ')})` : '';
148
+ throw new Error(response.status === 400 ? `Invalid pricing request${fields}.` : `Pricing request failed (HTTP ${response.status}).`);
149
+ }
150
+ const rows = result?.estimates;
151
+ if (result?.currency !== 'credits' || (input.requests.length ? !Array.isArray(rows) || rows.length !== input.requests.length : !result.catalog)) {
152
+ throw new Error('Invalid Makaron price response.');
153
+ }
154
+ if (json) console.log(JSON.stringify(result));
155
+ else printPrices(result);
156
+ if (rows?.some(row => !['estimated', 'preflight_only'].includes(row.status))) process.exitCode = 2;
157
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makaron-cli",
3
- "version": "0.17.23",
3
+ "version": "0.17.25",
4
4
  "description": "Talk to Makaron Agent from the terminal — create projects, edit images, generate videos",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -59,6 +59,20 @@ npx makaron-cli usage --run <runId> # per-tool breakdown
59
59
  npx makaron-cli usage --limit 20 # recent usage rows (all sources)
60
60
  ```
61
61
 
62
+
63
+ ## Check generation credits on demand
64
+
65
+ Use `makaron price` when the user asks about price, budget, or how models compare. For routine creation, go directly to the requested workflow. `price list` discovers model IDs and supported resolutions. The quote includes customer-facing credits and applicable billing factors. It does not start a run, upload media or read your balance.
66
+
67
+ ```bash
68
+ makaron price list --json
69
+ makaron price video --model kling-4-flash --model seedance-2.5-native --duration 5 --resolution 720p
70
+ makaron price image --model seedream-5.5 --operation edit --image-count 3 --resolution 2K --json
71
+ makaron price audio --model evolink-seed-audio --duration 20
72
+ ```
73
+
74
+ For video references, pass both `--video-reference-count` and the total `--reference-video-seconds`. Count an edit's base image in `--image-count`. Use `--input <file|-> --json` for up to six requests with different parameters. The JSON body is `{"requests":[{"kind":"video","model":"kling-4-flash","duration_seconds":5,"image_count":0,"resolution":"720p"}]}`. Exit `2` means at least one quote is unavailable, unsupported or missing inputs. A `preflight_only` amount is an estimate that may differ from the final charge.
75
+
62
76
  ## Core Workflow
63
77
 
64
78
  ```bash