@evolinkai/cli 0.14.0 → 0.14.1

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/README.md CHANGED
@@ -122,15 +122,15 @@ evolink tasks batch --ids TASK_A,TASK_B --json
122
122
  evolink generate image --model MODEL --input-file input.json --skip-estimate --json
123
123
  ```
124
124
 
125
- For video/audio, choose the corresponding generation command and a model's documented input. `estimate` never submits a task. Quotes are current for at most 24 hours and never outlive the returned pricing approval. They bind to the login and exact input, and are checked again before generation. A changed quote requires a new approval; an expired quote whose input and price are unchanged is submitted under its approval, and the result says so (`approval_expired`). `--confirm` conveys the user's approval; the CLI cannot verify a conversation by itself.
125
+ For video/audio, choose the corresponding generation command and a model's documented input. `estimate` never submits a task. Quotes are current for at most 24 hours and never outlive the returned pricing approval. They bind to the login and exact input. Before submitting, `generate` estimates again: the same input at the approved price or lower submits, also under later pricing rules; a higher price (`price_changed`), a changed input (`quote_input_changed`) or an expired quote (`quote_expired`) needs a new estimate and approval. For a partial estimate only the part it prices is compared. `--confirm` conveys the user's approval; the CLI cannot verify a conversation by itself.
126
126
 
127
- Show the estimated cost and ask the user to confirm the task. The CLI does not turn that estimate into a spending cap. If the user explicitly specifies a budget, compare the estimate with it; pause if it exceeds that budget or cannot be fully estimated. The legacy `--max-cost-usd` option remains compatible for this estimate comparison and does not limit the final charge. `--media-seconds` is a pricing hint, never a model parameter. Actual-usage billing requires explaining the relevant uncertainty; a missing price is refused. GPT Image token models (`gpt-image-1.5`, `gpt-image-2`, `gpt-image-2.5-*`, `gpt-image-2.6-*`) return a `token_billed` reference price, what EvoLink reserves at submission for the exact input; the task settles at the tokens it actually uses, and a `--max-cost-usd` budget must cover 1.5 times the reference price. Gemini Omni Flash video models (`gemini-omni-flash-*`, `gemini-omni-1.1-flash-*`, `gemini-omni-1.2-flash-*`) get a reference price the same way; give an input or reference video's length with `--media-seconds` (for several reference videos, the longest one's). EvoLink reads that video's resolution at submission, so the reference counts it at 4k and the estimate also gives the price at a lower resolution.
127
+ Show the estimated cost and ask the user to confirm the task. The CLI does not turn that estimate into a spending cap. If the user explicitly specifies a budget, compare the estimate with it; pause if it exceeds that budget or cannot be fully estimated. The legacy `--max-cost-usd` option remains compatible for this estimate comparison and does not limit the final charge. `--media-seconds` is a pricing hint, never a model parameter. Actual-usage billing requires explaining the relevant uncertainty; a missing price is refused. GPT Image token models (`gpt-image-1.5`, `gpt-image-2`, `gpt-image-2.5-*`, `gpt-image-2.6-*`) return a `token_billed` reference price, what EvoLink reserves at submission for the exact input; the task settles at the tokens it actually uses, and a `--max-cost-usd` budget must cover 1.5 times the reference price. Gemini Omni Flash video models (`gemini-omni-flash-*`, `gemini-omni-1.1-flash-*`, `gemini-omni-1.2-flash-*`) get a reference price the same way; give an input or reference video's length with `--media-seconds` (for several reference videos, the longest one's). EvoLink reads that video's resolution at submission, so the reference counts it at 4k, and the estimate also gives the price at each input resolution (`reference_usage.input_resolution_prices`). `qwen-audio-3.1-tts-flash` gets a reference price the same way, from the length and kinds of characters of its text.
128
128
 
129
129
  A failed or blocked estimate is not a quote. Catalog starting prices must not replace a task quote. Fix the reported problem and quote again while retaining the user's cap; do not ask for generation approval or submit using an invented total. Quote errors report `submission_allowed: false` and preserve the supplied budget.
130
130
 
131
131
  `--skip-estimate` is for a user who explicitly said not to estimate or confirm, for one task, a batch or the rest of a conversation. `generate --model MODEL --input-file FILE --skip-estimate` (or `--inputs-file`) submits without a quote: the price is not checked, the task is charged by actual usage, and the result says so (`estimate_skipped`, `estimate_skip_reason`). Invalid input and an explicit `--max-cost-usd` are still refused; the command saves a record with its own request ID, so `tasks resume --quote QUOTE_ID` recovers an uncertain submission. When an estimate fails and the user has not opted out, ask once whether to generate anyway; on yes use `--skip-estimate`.
132
132
 
133
- `--inputs-file` takes a JSON array, or JSONL with one input object per line, of 1-50 inputs for one model. `estimate --inputs-file` returns each input's price, the total and one quote for the batch; `generate --quote QUOTE_ID --confirm` submits every input at once (up to 10 at a time) and returns each input's task ID or error without waiting (`--wait` is for one task). Collect the results with `tasks batch --ids`. If some inputs were not submitted or their outcome is unknown, `tasks resume --quote QUOTE_ID` finishes the batch with the same request ID within 24 hours: accepted inputs return their original tasks without a new charge. Never resubmit those inputs with a new estimate or generate command.
133
+ `--inputs-file` takes a JSON array, or JSONL with one input object per line, of 1-50 inputs for one model. `estimate --inputs-file` returns each input's price, the total and one quote for the batch; `generate --quote QUOTE_ID --confirm` submits every input at once (up to 10 at a time) and returns each input's task ID or error without waiting (`--wait` is for one task). Collect the results with `tasks batch --ids`. If some inputs were not submitted or their outcome is unknown, `tasks resume --quote QUOTE_ID` finishes the batch with the same request ID within 23 hours of its first submission: accepted inputs return their original tasks without a new charge. Never resubmit those inputs with a new estimate or generate command. `tasks resume` follows the same rule as `generate`: after a price rise or the quote's expiry nothing is sent; check `tasks batch --ids` and `tasks list` for what went through, then estimate only the inputs that did not and submit them as a new batch after approval.
134
134
 
135
135
  For the five Seedance 2.5 generation models, `draft: true` with omitted `quality` uses `480p` for both pricing and submission. Estimates expose `effective_input` and `defaults_applied`; show these applied defaults before approval. Draft-to-video conversion and other model IDs retain their own inputs. The new checks match the resolved model and endpoint, including when catalog documentation is borrowed through an alias.
136
136
 
@@ -286,7 +286,8 @@ A failed task is not charged: the credits reserved at submission are returned au
286
286
  The local `quote_id` stores input binding, pricing fingerprint, integer UC subtotal
287
287
  and expiry; there is no backend `estimate_id`. The local quote shares the core's
288
288
  24-hour approval window and never outlives the returned approval. Before first submission, the CLI reads the rules
289
- again and refuses changed prices, policy or usage until a new estimate is approved.
289
+ again: the same input at the approved price or lower submits, also under a later policy; a higher price, a changed
290
+ input or usage, or an expired quote needs a new estimate and approval.
290
291
  Neither backend Quote nor new OAuth quote access is required. Existing login,
291
292
  shared MCP key, quota and permissions remain.
292
293
 
@@ -303,6 +304,6 @@ Supply required measured or expected billing usage with
303
304
  `--pricing-parameters '{"input_seconds":5.77}'`. Default `--pricing-source pricing_rules`
304
305
  and old `account`/`public_reference` aliases use the same published full rules.
305
306
  Partial estimates name missing usage and cannot check a budget. GPT Image token
306
- models and Gemini Omni Flash video models need no token counts; `--pricing-parameters`
307
- token counts are not used for them. Estimates exclude personal discounts and do not reserve quota or guarantee
307
+ models, Gemini Omni Flash video models and `qwen-audio-3.1-tts-flash` need no token
308
+ counts; `--pricing-parameters` token counts are not used for them. Estimates exclude personal discounts and do not reserve quota or guarantee
308
309
  the final charge.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evolinkai/cli",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "Generate images, video and audio with EvoLink, with browser login and quoted submissions.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -63,7 +63,7 @@ For image edits, reference-based video, speech or music, read [media workflows](
63
63
  - When comparing reference support, retrieving schemas or searching model documentation, read [Discovery and delivery extensions](references/capabilities.md). Use `models recommend`, `models schema` and `docs search` only when the installed CLI supports them. Keep the user's chosen model; recommendations explain alternatives, not automatic approval.
64
64
  - For a local reference, run `evolink upload /absolute/path --json` and use its `file_url` in the model input. A chat attachment must have a readable local file or public URL. Keep the original `upload_id` if a response is lost. `uploads get ID` reads the saved receipt and, when supported by the file service, recovers a completed upload without resending bytes. If it returns `outcome_unknown` and `result_verified: false`, no result was verified; check the user's files before uploading again. A missing receipt from an older service does not prove the file failed to arrive. Legacy MCP upload slots require the older CLI version.
65
65
  - Prepare a JSON input file using the model's documented parameters. Run `evolink estimate --model MODEL --input-file /absolute/input.json --json`, adding `--max-cost-usd` only for a user-specified cap. `--media-seconds` is an estimation hint, not a model `duration` parameter or a billing guarantee.
66
- - Show the user the model, input/reference, number/duration, output settings, estimated total and material uncertainties. For a `token_billed` reference price (GPT Image token models and Gemini Omni Flash video models), present it as a reference price: billed by actual token usage and settled when the task finishes, so the final charge may be lower or slightly higher. For a Gemini Omni video with an input or reference video, pass its length as `--media-seconds`; the reference counts that video at the highest resolution (4k), so also show the lower-resolution price the estimate gives. For other token billing or unknown duration, show the rates and state that the total is unknown. A partial estimate is not a total. Do not add a separate cap to the default confirmation; if the user gave a budget, say whether the estimate fits it.
66
+ - Show the user the model, input/reference, number/duration, output settings, estimated total and material uncertainties. For a `token_billed` reference price (GPT Image token models, Gemini Omni Flash video models and `qwen-audio-3.1-tts-flash`), present it as a reference price: billed by actual token usage and settled when the task finishes, so the final charge may be lower or slightly higher. For a Gemini Omni video with an input or reference video, pass its length as `--media-seconds`; the reference counts that video at the highest resolution (4k), so also show the price the estimate gives at each input resolution. For other token billing or unknown duration, show the rates and state that the total is unknown. A partial estimate is not a total. Do not add a separate cap to the default confirmation; if the user gave a budget, say whether the estimate fits it.
67
67
 
68
68
  Only a successful `estimate` response with `ok: true` and a returned `quote_id` can be approved. For invalid input, unavailable pricing, insufficient balance or an uncheckable cap, report the error and correct that problem before quoting again with the same budget. Do not invent a total or quote ID, run `generate --confirm`, or disable host permission controls.
69
69
 
@@ -75,17 +75,17 @@ Every paid task requires an explicit user approval of the quoted task, unless th
75
75
 
76
76
  `evolink generate image|video|audio --quote QUOTE_ID --confirm --json`
77
77
 
78
- The saved model and input are the submitted model and input. A changed quote requires a new estimate and approval. An expired quote still holds while its input and price are unchanged: `generate` estimates again before submitting, refuses a changed price with `price_changed`, and otherwise submits under the original approval and says so (`approval_expired`). Do not remove or increase a user cap to make a request succeed. `--confirm` conveys an approval already obtained; it is not permission to approve on the user's behalf.
78
+ The saved model and input are the submitted model and input. A quote holds for its exact input until it expires (24 hours from the estimate) at the approved price or lower: `generate` estimates again before submitting and refuses a higher price (`price_changed`), a changed input (`quote_input_changed`) or an expired quote (`quote_expired`); then estimate again (free) and ask the user to approve the new quote. Do not remove or increase a user cap to make a request succeed. `--confirm` conveys an approval already obtained; it is not permission to approve on the user's behalf.
79
79
 
80
80
  ## Several images or tasks
81
81
 
82
82
  For several images or tasks of one model, write the inputs (1–50, each like a single input) to a JSON array or JSONL file and run `evolink estimate --model MODEL --inputs-file /absolute/inputs.json --json`: one quote shows each input's price and the total, and one approval covers that batch. After approval, `evolink generate image|video|audio --quote QUOTE_ID --confirm --json` submits every input at once and returns each input's task ID or error right away (`--wait` does not apply to a batch). Collect the results with `evolink tasks batch --ids ID,ID --json` (free, up to 50 IDs). Tell the user the tasks generate at the same time. For tasks of different models, quote and submit each one separately. Do not rely on `n` for the count: some models, such as GPT Image, often return fewer images than `n`.
83
83
 
84
- If some inputs were not submitted or their outcome is unknown, finish the batch with `evolink tasks resume --quote QUOTE_ID --json` within 24 hours: accepted inputs return their original tasks without a new charge, and only the rest are submitted. Never resubmit accepted, not-submitted or unknown-outcome inputs with a new estimate or generate command: that creates and charges new tasks. An input refused because it differs from what its request ID submitted earlier is a new task that needs a new estimate and approval.
84
+ If some inputs were not submitted or their outcome is unknown, finish the batch with `evolink tasks resume --quote QUOTE_ID --json` within 23 hours of its first submission: accepted inputs return their original tasks without a new charge, and only the rest are submitted. `tasks resume` sends nothing after a price rise or the quote's expiry: then check `evolink tasks batch --ids` and `evolink tasks list --since 2d` for what went through, estimate only the inputs that did not, and submit them as a new batch after the user approves. Never resubmit accepted, not-submitted or unknown-outcome inputs with a new estimate or generate command: that creates and charges new tasks. An input refused because it differs from what its request ID submitted earlier is a new task that needs a new estimate and approval.
85
85
 
86
86
  ## Recover and deliver
87
87
 
88
- - Preserve `quote_id`, `client_request_id` and `task_id`. If submission outcome is unknown, use `tasks resume --quote QUOTE_ID` or `tasks list --since 30m --json`. Do not create a new quote/request ID to retry an uncertain submission. `tasks resume` replays the original request ID only within 23 hours of the first submission; after that (`recovery_window_passed`) check recent tasks instead. A known refused request can be corrected and quoted again.
88
+ - Preserve `quote_id`, `client_request_id` and `task_id`. If submission outcome is unknown, use `tasks resume --quote QUOTE_ID` or `tasks list --since 30m --json`. Do not create a new quote/request ID to retry an uncertain submission. `tasks resume` replays the original request ID only within 23 hours of the first submission; after that (`recovery_window_passed`) check recent tasks instead. It also sends nothing after a price rise (`price_changed`) or the quote's expiry (`quote_expired`): check `tasks list --since 2d` first, and only if the task did not go through, estimate again and ask for approval. A known refused request can be corrected and quoted again.
89
89
  - `tasks list --status` accepts only the case-sensitive filters `processing`, `completed`, `failed`, `cancelled`. `processing` includes queued tasks. Do not use `pending`, `queued`, `canceled` or `all` as filter values. A task response may report `pending`; do not copy that response value into `--status`. Omit `--status` to read recent tasks across states, especially when recovering an uncertain submission that may already have completed or failed.
90
90
  - For active tasks, use `evolink tasks list --status processing --json`. To find recent completed videos, use `evolink tasks list --status completed --type video --limit 50 --json`. Task-list `--type` accepts only `image`, `video`, `audio`; omit it for all types. `--limit` is 1–50 (default 20); `--since` accepts ISO 8601, Unix seconds or a relative time such as `30m`, `2h`, `1d`. It filters the selected page, not the entire history. Use `--page` and follow `next_page`; `--model` and `--until` narrow results. `total` is before time filtering. An empty list does not prove no task was submitted; retain the original IDs and use recovery. `cancelled` is a read filter, not a CLI cancellation feature.
91
91
  - Poll with `tasks get TASK_ID --json` or `tasks wait TASK_ID --json`. Never poll with `generate`. Ctrl-C and the `tasks wait --timeout` limit stop only local waiting; they do not cancel the paid task. A `wait_timeout` error reports `status_check`: `verified` gives the last read `last_status` and its `read_at`, not a live status; `unverified` means the latest status could not be read. Continue with the returned `recovery` command, never with a new generation.
@@ -105,14 +105,14 @@ For setup problems, run `evolink doctor --agent NAME --json` if the installed ve
105
105
 
106
106
 
107
107
  Estimates use published full pricing rules and show public default prices, excluding
108
- personal discounts. Local approvals are current for up to 24 hours; submission verifies fresh rules, and an expired approval still submits while the input and price are unchanged.
108
+ personal discounts. Local approvals are current for up to 24 hours from the estimate; submission verifies fresh rules: the same input at the approved price or lower submits, while a higher price, a changed input or an expired approval needs a new estimate and approval.
109
109
  Use `evolink estimate --refresh-quote ID` only for an unsubmitted approval; preserve
110
110
  the input and explicit user budget and obtain approval again. The refreshed quote
111
111
  replaces the old one and keeps its request ID: submit only the newest quote, which
112
112
  `quote_superseded` names. Supply missing billing
113
113
  usage with `--pricing-parameters JSON`; never invent unknown token counts or media
114
- lengths. GPT Image token models and Gemini Omni Flash video models (`gemini-omni-flash-*`, `gemini-omni-1.1-flash-*`, `gemini-omni-1.2-flash-*`) need no
114
+ lengths. GPT Image token models, Gemini Omni Flash video models (`gemini-omni-flash-*`, `gemini-omni-1.1-flash-*`, `gemini-omni-1.2-flash-*`) and `qwen-audio-3.1-tts-flash` need no
115
115
  token counts: their reference price comes from the input, and a `--max-cost-usd` budget must cover 1.5 times it.
116
- For a Gemini Omni video, give an input or reference video's length with `--media-seconds` (for several reference videos, the longest one's). EvoLink reads that video's resolution at submission, so the reference counts it at 4k and the estimate also gives the price at a lower resolution. Partial subtotals cannot check a budget. If rules are unavailable or change,
116
+ For a Gemini Omni video, give an input or reference video's length with `--media-seconds` (for several reference videos, the longest one's). EvoLink reads that video's resolution at submission, so the reference counts it at 4k, and the estimate also gives the price at each input resolution. Partial subtotals cannot check a budget. If rules are unavailable or change,
117
117
  pause and preserve the budget. Actual usage can change the final charge; final
118
118
  settlement caps require gateway/Worker support.
@@ -18,15 +18,15 @@ A final task/workflow cap requires server-side reservation and settlement enforc
18
18
 
19
19
 
20
20
  Estimates use published full pricing rules and show public default prices, excluding
21
- personal discounts. Local approvals are current for up to 24 hours; submission verifies fresh rules, and an expired approval still submits while the input and price are unchanged.
21
+ personal discounts. Local approvals are current for up to 24 hours from the estimate; submission verifies fresh rules: the same input at the approved price or lower submits, while a higher price, a changed input or an expired approval needs a new estimate and approval.
22
22
  Use `evolink estimate --refresh-quote ID` only for an unsubmitted approval; preserve
23
23
  the input and explicit user budget and obtain approval again. The refreshed quote
24
24
  replaces the old one and keeps its request ID: submit only the newest quote, which
25
25
  `quote_superseded` names. Supply missing billing
26
26
  usage with `--pricing-parameters JSON`; never invent unknown token counts or media
27
- lengths. GPT Image token models and Gemini Omni Flash video models (`gemini-omni-flash-*`, `gemini-omni-1.1-flash-*`, `gemini-omni-1.2-flash-*`) need no
27
+ lengths. GPT Image token models, Gemini Omni Flash video models (`gemini-omni-flash-*`, `gemini-omni-1.1-flash-*`, `gemini-omni-1.2-flash-*`) and `qwen-audio-3.1-tts-flash` need no
28
28
  token counts: their reference price comes from the input, and a `--max-cost-usd` budget must cover 1.5 times it.
29
- For a Gemini Omni video, give an input or reference video's length with `--media-seconds` (for several reference videos, the longest one's). EvoLink reads that video's resolution at submission, so the reference counts it at 4k and the estimate also gives the price at a lower resolution. Partial subtotals cannot check a budget. If rules are unavailable or change,
29
+ For a Gemini Omni video, give an input or reference video's length with `--media-seconds` (for several reference videos, the longest one's). EvoLink reads that video's resolution at submission, so the reference counts it at 4k, and the estimate also gives the price at each input resolution. Partial subtotals cannot check a budget. If rules are unavailable or change,
30
30
  pause and preserve the budget. Actual usage can change the final charge; final
31
31
  settlement caps require gateway/Worker support.
32
32
 
package/src/cli.mjs CHANGED
@@ -109,12 +109,12 @@ newer release exists. EVOLINK_CLI_UPDATE_CHECK=0 turns these npm registry checks
109
109
  Login timeout: 30-900 seconds, default 180. On SSH, forward the callback port.
110
110
  The CLI verifies skill files; your assistant must confirm it loads evolink-cli.
111
111
  Quotes are current for at most 24 hours, never beyond the returned approval expiry.
112
- generate estimates again before submitting: an expired quote whose input and price
113
- are unchanged is submitted under its approval; a changed price needs a new approval.
112
+ generate estimates again before submitting: the same input at the approved price or
113
+ lower submits; a higher price, a changed input or an expired quote needs a new approval.
114
114
  --confirm is only for an already approved quote. --skip-estimate is only for a user
115
115
  who explicitly said not to estimate or confirm.
116
116
  A batch quote submits all its inputs in one call; tasks resume finishes the rest
117
- with the same request ID within 24 hours.
117
+ with the same request ID within 23 hours, while the quote holds.
118
118
  Spending caps protect the estimate at submission, not final settlement.
119
119
  Ctrl-C stops local waiting; submitted tasks continue on EvoLink.
120
120
  `;
package/src/help.mjs CHANGED
@@ -24,7 +24,7 @@ const COMMANDS = {
24
24
  'models schema': ['MODEL', 'Read versioned input and generation-submission response schemas. The response schema may omit final task outputs; runtime constraints also apply.', {}],
25
25
  'models recommend': ['--type TYPE [options]', 'Compare documented available alternatives with selection reasons. Unit rates are not total quotes.', { type: media, query: string('Search keywords; every term must match'), references: string('Comma-separated image,video,audio'), limit: integer(1, 10, 3) }],
26
26
  'docs search': ['--query TEXT [options]', 'Search versioned official model reference excerpts, not the live full website.', { query: string('Required model reference keywords'), type: allMedia, limit: integer(1, 20, 5) }],
27
- estimate: ['--model MODEL --input-file FILE|--inputs-file FILE [options] | --refresh-quote ID', 'Prepare an estimate valid until the returned approval expiry, at most 24 hours; generate estimates again and still submits an expired quote whose input and price are unchanged. Show the estimated cost and material uncertainty, then obtain user approval. No spending cap is created from the estimate. --inputs-file prepares one quote for a batch: one approval covers all its inputs.', {
27
+ estimate: ['--model MODEL --input-file FILE|--inputs-file FILE [options] | --refresh-quote ID', 'Prepare an estimate valid until the returned approval expiry, at most 24 hours from the estimate. generate estimates again before submitting: the same input at the approved price or lower submits; a higher price, a changed input or an expired quote needs a new estimate and approval. Show the estimated cost and material uncertainty, then obtain user approval. No spending cap is created from the estimate. --inputs-file prepares one quote for a batch: one approval covers all its inputs.', {
28
28
  model: string('Required model ID'), input: string('JSON object; mutually exclusive with input-file and inputs-file'), 'input-file': string('Local JSON file; mutually exclusive with input and inputs-file'),
29
29
  'inputs-file': string('Local JSON array or JSONL file of 1-50 inputs for one model, estimated and later submitted together'), prompt: string('Optional prompt; not with inputs-file'),
30
30
  'pricing-source': choice(['account', 'public_reference']), 'pricing-parameters': string('JSON object containing declared billing usage'),
@@ -37,7 +37,7 @@ const COMMANDS = {
37
37
  'tasks list': ['[options]', 'Page through account tasks. since/until filter only the selected page; total is before time filtering. Empty results do not prove no task was submitted.', {
38
38
  status: choice(['processing', 'completed', 'failed', 'cancelled']), type: media, since: time, until: time, model: string('Exact model ID'), page: integer(1, 100000, 1), limit: integer(1, 50, 20),
39
39
  }],
40
- 'tasks resume': ['--quote ID', 'Recover an uncertain submission, or finish a partly submitted batch, with the original request ID within 24 hours of its first submission. Accepted inputs return their tasks without a new charge. Use generate for an approved quote that has never been submitted.', { quote: string('Original quote ID') }],
40
+ 'tasks resume': ['--quote ID', 'Recover an uncertain submission, or finish a partly submitted batch, with the original request ID within 23 hours of its first submission. Accepted inputs return their tasks without a new charge. Its quote must still hold: after a price rise or its expiry nothing is sent; check tasks list for what went through and estimate only the rest as a new generation or batch. Use generate for an approved quote that has never been submitted.', { quote: string('Original quote ID') }],
41
41
  usage: ['[options]', 'Summarize reported completed-task credits by creation time. Account-wide retained tasks; bounded scan with coverage and missing-cost metadata. Excludes payments/refunds and pending reservations. Not a bill or final budget.', {
42
42
  since: { ...time, default: '30d' }, until: time, model: string('Exact model ID'), type: media, 'max-pages': integer(1, 20, 5),
43
43
  }],
package/src/media.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { hash } from './state.mjs';
3
3
  import { CliError, requireThat, fileError } from './errors.mjs';
4
- import { APPROVAL_TTL_MS, REFERENCE_BUDGET_FACTOR, referenceBudgetExceeded, rulesBudgetExceeded } from './platform/core/src/services/pricing-rules-estimate.js';
4
+ import { APPROVAL_TTL_MS, REFERENCE_BUDGET_FACTOR, priceRose, referenceBudgetExceeded, rulesBudgetExceeded } from './platform/core/src/services/pricing-rules-estimate.js';
5
5
  import { compareDecimal } from './platform/core/src/services/pricing-quote-client.js';
6
6
  import { DASHBOARD_URL } from './platform/core/src/services/http-policy.js';
7
7
  import { dashboardCheck } from './platform/core/src/tools/shared.js';
@@ -26,12 +26,34 @@ const RECOVERABLE = ['submitting', 'outcome_unknown', 'partial'];
26
26
  /** A quote for several inputs of one model (estimate --inputs-file), submitted in one call. */
27
27
  const isBatch = quote => Array.isArray(quote.args?.inputs);
28
28
 
29
- /** A first submission of an expired quote whose input and price were unchanged says so in its result. */
30
- function withExpiry(view, quote) {
31
- if (!quote) return view;
32
- const at = new Date(quote.expires_at).toISOString();
33
- const line = `The quote expired at ${at}, but its input and price are unchanged, so it was submitted under the original approval.`;
34
- return { ...view, approval_expired: true, quote_expired_at: at, text: view.text ? `${view.text}\n${line}` : line };
29
+ /**
30
+ * A quote holds until its expires_at, 24 hours after the estimate at most. Past it a first submission needs a new
31
+ * estimate and approval; recovery cannot replay it either, so the user checks what already went through first.
32
+ */
33
+ function expiredQuote(quote, id, resume) {
34
+ const at = new Date(quote.expires_at).toISOString(), batch = isBatch(quote), ids = quote.task_ids ?? [];
35
+ const list = 'evolink tasks list --since 2d', collect = ids.length ? `evolink tasks batch --ids ${ids.join(',')}` : undefined;
36
+ const message = !resume ? `This quote expired at ${at}. Refresh it with evolink estimate --refresh-quote ${id} and obtain the user's approval again. Nothing was submitted.`
37
+ : batch ? `This quote expired at ${at}, so its batch cannot be finished with it. Check ${collect ? `${collect} and ${list}` : list} first to see which inputs went through; then estimate only the inputs that did not and, after the user approves, submit them as a new batch. Nothing was submitted.`
38
+ : `This quote expired at ${at}, so its submission cannot be recovered with it. Check ${list} first to see whether it went through; only if it did not, estimate it again and, after the user approves, submit it as a new generation. Nothing was submitted.`;
39
+ return new CliError('quote_expired', message, { quote_id: id, client_request_id: quote.client_request_id, expired_at: at, submission_allowed: false,
40
+ ...(ids.length ? { task_ids: ids } : {}), next_step: resume ? collect ?? list : `evolink estimate --refresh-quote ${id}`, ...(resume ? dashboardCheck() : {}) });
41
+ }
42
+
43
+ /**
44
+ * Whether a fresh estimate still matches the approved quote: the same input at the approved price or lower. With the
45
+ * core's approval record that is its request hash and total, whatever else changed in the rules. Without one on both
46
+ * sides (an older service, or rules that cannot be read now), any change to the estimate needs a new approval.
47
+ */
48
+ export function approvalHolds(fresh, quote) {
49
+ const approved = quote.args?.pricing_quote, now = fresh.pricing_quote;
50
+ if (approved && now) {
51
+ return { input: approved.request_hash === now.request_hash && approved.model_id === now.model_id && approved.batch_items === now.batch_items,
52
+ rose: priceRose(approved, now) };
53
+ }
54
+ const account = quote.account_quote, current = fresh.account_quote;
55
+ if (account && current) return { input: account.request_hash === current.request_hash, rose: compareDecimal(current.quote.amount, account.quote.amount) > 0 };
56
+ return { input: true, rose: priceFingerprint(fresh) !== quote.fingerprint, byFingerprint: true };
35
57
  }
36
58
 
37
59
  /** The shared core's batch result names its own tool calls; for the CLI these lines name the CLI commands instead. */
@@ -39,7 +61,9 @@ export function cliBatchText(text, id, taskIds) {
39
61
  return (text ?? '').split('\n').map(line => {
40
62
  if (line.startsWith('Collect the results with list_tasks')) return `Collect the results with evolink tasks batch --ids ${taskIds.join(',')}; it is free and read-only.`;
41
63
  if (line.startsWith('To finish the batch, call ')) {
42
- return line.replace(/^To finish the batch, call \S+ again with client_request_id "[^"]*" and exactly the same inputs/, `To finish the batch, run evolink tasks resume --quote ${id}`);
64
+ // tasks resume replays the request ID for 23 of the gateway's 24 hours (RECOVERY_WINDOW_MS).
65
+ return line.replace(/^To finish the batch, call \S+ again with client_request_id "[^"]*" and exactly the same inputs/, `To finish the batch, run evolink tasks resume --quote ${id}`)
66
+ .replace(' within 24 hours of its first submission', ' within 23 hours of its first submission');
43
67
  }
44
68
  if (line.startsWith('The outcome of ')) {
45
69
  return line.replace(/retry later with the same client_request_id and inputs, or check list_tasks\.$/, `run evolink tasks resume --quote ${id} later, or check evolink tasks list --since 30m.`);
@@ -49,6 +73,12 @@ export function cliBatchText(text, id, taskIds) {
49
73
  }).join('\n');
50
74
  }
51
75
 
76
+ /** The shared core's refusal of a replayed approval, before anything is sent: its price rose, or it expired. */
77
+ function replayRefusal(error) {
78
+ const code = error?.details?.error?.code;
79
+ return ['price_changed', 'quote_expired'].includes(code) && error.details.charged === 'no' ? code : undefined;
80
+ }
81
+
52
82
  function interrupted(taskId) {
53
83
  return new CliError('interrupted', 'Stopped waiting locally. The EvoLink task continues.', { task_id: taskId }, 130);
54
84
  }
@@ -277,17 +307,22 @@ export class Media {
277
307
  if (resume) requireThat(this.now() < (quote.approved_at ?? quote.created_at) + RECOVERY_WINDOW_MS, 'recovery_window_passed',
278
308
  'This request ID was first submitted more than 23 hours ago. EvoLink keeps a request ID for 24 hours, so replaying it now could create and charge a new task. Check recent tasks with evolink tasks list --since 2d instead.',
279
309
  { quote_id: id, client_request_id: quote.client_request_id, submission_allowed: false, ...dashboardCheck() });
280
- // An expired quote still holds for its unchanged input and price: the fresh estimate below refuses a changed one.
281
- const expired = !resume && !quote.skip_estimate && this.now() >= quote.expires_at;
310
+ if (!quote.skip_estimate && this.now() >= quote.expires_at) throw expiredQuote(quote, id, resume);
282
311
  const { max_cost_usd, account_quote, pricing_quote, skip_estimate, ...checkArgs } = quote.args;
283
312
  // skip_estimate: the user opted out of estimates; the shared core still refuses invalid input and an unpriceable budget.
284
313
  if (!quote.skip_estimate) {
285
314
  let fresh;
286
315
  try {
287
- // Preserve the original approved request during uncertain submission recovery.
288
- fresh = resume && (account_quote || pricing_quote) ? { model: quote.args.model, type: quote.type, input_valid: true, estimate: quote.estimate, account_quote, pricing_quote }
316
+ // Recovery sends the original approved request, which the shared core checks against the current price itself.
317
+ const replay = resume && (account_quote || pricing_quote);
318
+ fresh = replay ? { model: quote.args.model, type: quote.type, input_valid: true, estimate: quote.estimate, account_quote, pricing_quote }
289
319
  : await this.client.call('estimate_cost', checkArgs);
290
- requireThat(resume && (account_quote || pricing_quote) || priceFingerprint(fresh) === quote.fingerprint, 'price_changed', 'The quote changed. Estimate again and obtain approval for the new quote.', { estimate: fresh.estimate });
320
+ if (!replay) {
321
+ const held = approvalHolds(fresh, quote);
322
+ requireThat(held.input, 'quote_input_changed', 'The input as EvoLink reads it changed since the quote. Estimate again and obtain approval for the new quote.', { estimate: fresh.estimate });
323
+ requireThat(!held.rose, 'price_changed', held.byFingerprint ? 'The quote changed. Estimate again and obtain approval for the new quote.'
324
+ : 'The price rose since the quote was approved. Estimate again and obtain approval for the new quote.', { estimate: fresh.estimate });
325
+ }
291
326
  checkEstimate(fresh, max_cost_usd);
292
327
  } catch (error) { throw quoteError(error, max_cost_usd); }
293
328
  if (!resume && fresh.pricing_quote) {
@@ -311,7 +346,7 @@ export class Media {
311
346
  await this.state.write('quotes', id, quote);
312
347
  const { pricing_source, ...generationArgs } = quote.args;
313
348
  const request = { ...generationArgs, client_request_id: quote.client_request_id };
314
- if (batch) return this.submitBatch(kind, id, quote, request, { resume, previous, expired });
349
+ if (batch) return this.submitBatch(kind, id, quote, request, { resume, previous });
315
350
  let result;
316
351
  try {
317
352
  result = await this.client.call(`generate_${kind}`, request);
@@ -331,20 +366,25 @@ export class Media {
331
366
  }
332
367
  quote.state = !resume && e.details?.charged === 'no' && ['not_submitted', 'rejected'].includes(e.details?.submission_state) ? 'refused' : 'outcome_unknown';
333
368
  await this.state.write('quotes', id, quote);
369
+ // The shared core refused the replay before sending it: the approval no longer holds (price or age).
370
+ const approval = resume && replayRefusal(e);
371
+ if (approval) throw new CliError(approval, `${approval === 'price_changed' ? 'The price rose since the quote was approved' : 'The quote expired'}, so the replay was not sent, and the original submission remains unverified. Check evolink tasks list --since 2d first to see whether it went through; only if it did not, estimate it again and, after the user approves, submit it as a new generation.`,
372
+ { ...(e.details || {}), charged: 'unknown', submission_state: 'outcome_unknown', quote_id: id, client_request_id: quote.client_request_id, submission_allowed: false,
373
+ next_step: 'evolink tasks list --since 2d', ...dashboardCheck() }, e.exitCode);
334
374
  throw new CliError(resume ? 'outcome_unknown' : e.code || 'outcome_unknown', resume ? 'The original submission remains unverified. The replay could not proceed; check recent tasks with the original request ID before preparing any new generation.' : e.message, { ...(e.details || {}), ...(quote.state === 'outcome_unknown' ? { charged: 'unknown', submission_state: 'outcome_unknown' } : {}), quote_id: id, client_request_id: quote.client_request_id,
335
375
  recovery: `evolink tasks resume --quote ${id}` }, e.exitCode);
336
376
  }
337
377
  quote.state = 'submitted';
338
378
  quote.task_id = result.task_id;
339
379
  await this.state.write('quotes', id, quote);
340
- return withExpiry({ ...result, quote_id: id, client_request_id: quote.client_request_id }, expired && quote);
380
+ return { ...result, quote_id: id, client_request_id: quote.client_request_id };
341
381
  });
342
382
  }
343
383
  /**
344
384
  * Submits a batch quote's inputs in one shared-core call and records each input's outcome. The same request ID and
345
385
  * inputs (tasks resume) later return accepted inputs without a new charge and submit only those still to finish.
346
386
  */
347
- async submitBatch(kind, id, quote, request, { resume, previous, expired }) {
387
+ async submitBatch(kind, id, quote, request, { resume, previous }) {
348
388
  let result, failure;
349
389
  try { result = await this.client.call(`generate_${kind}`, request); } catch (error) { failure = error; }
350
390
  const outcome = result ?? failure?.details ?? {};
@@ -365,10 +405,14 @@ export class Media {
365
405
  const view = { ...outcome, quote_id: id, client_request_id: quote.client_request_id, task_ids: taskIds, text: cliBatchText(outcome.text, id, taskIds),
366
406
  ...(taskIds.length ? { collect: `evolink tasks batch --ids ${taskIds.join(',')}` } : {}),
367
407
  ...(RECOVERABLE.includes(quote.state) ? { recovery: `evolink tasks resume --quote ${id}` } : {}) };
368
- if (result) return withExpiry(view, expired && quote);
408
+ if (result) return view;
369
409
  if (items) throw new CliError(failure.code || 'batch_not_submitted', failure.message, view, failure.exitCode);
370
- throw new CliError(resume && !refusedBefore ? 'outcome_unknown' : failure.code || 'outcome_unknown', resume && !refusedBefore
371
- ? 'The batch submission remains unverified. The replay could not proceed; check recent tasks with the original request ID before preparing any new generation.' : failure.message, {
410
+ // The shared core refused the replay before sending anything because the approval no longer holds (price or age).
411
+ const approval = resume && refusedBefore && replayRefusal(failure);
412
+ const check = `${taskIds.length ? `evolink tasks batch --ids ${taskIds.join(',')} and ` : ''}evolink tasks list --since 2d`;
413
+ throw new CliError(approval || (resume && !refusedBefore ? 'outcome_unknown' : failure.code || 'outcome_unknown'), approval
414
+ ? `${approval === 'price_changed' ? 'The total price rose since the quote was approved' : 'The quote expired'}, so nothing was sent. Check ${check} first to see which inputs went through; then estimate only the inputs that did not and, after the user approves, submit them as a new batch.`
415
+ : resume && !refusedBefore ? 'The batch submission remains unverified. The replay could not proceed; check recent tasks with the original request ID before preparing any new generation.' : failure.message, {
372
416
  ...view, ...(quote.state === 'outcome_unknown' ? { charged: 'unknown', submission_state: 'outcome_unknown' } : {}),
373
417
  ...(refusedBefore && quote.state === 'partial' ? { items: quote.items, next_step: 'This call submitted nothing. Accepted inputs keep their tasks (task_ids). Resolve the error; then finish the rest with tasks resume, or estimate them again as a new batch if their price or input changed.' } : {}),
374
418
  }, failure.exitCode);
@@ -3,7 +3,7 @@
3
3
  import { ApiHttpError, submitTask } from './api-client.js';
4
4
  import { remainingMs } from './http-policy.js';
5
5
  import { QuoteError, quoteRequestHash } from './pricing-quote-client.js';
6
- import { APPROVAL_TTL_MS, MAX_BATCH_ITEMS, amountsForUC } from './pricing-rules-estimate.js';
6
+ import { APPROVAL_TTL_MS, MAX_BATCH_ITEMS, amountsForUC, approvalExpired, priceRose } from './pricing-rules-estimate.js';
7
7
  export { MAX_BATCH_ITEMS };
8
8
  /** Submissions of one batch in flight at once. */
9
9
  export const BATCH_SUBMIT_CONCURRENCY = 10;
@@ -53,21 +53,21 @@ export function batchTotal(model, items) {
53
53
  }
54
54
  function fail(code, message) { throw new QuoteError(code, message); }
55
55
  /**
56
- * A batch approval holds for the same inputs, in the same order, at the same total; past its expires_at it still holds
57
- * when neither changed. An approval of one input never approves a batch.
56
+ * A batch approval holds for the same inputs, in the same order, until its expires_at, at the approved total or lower:
57
+ * the total counts, not any one input's price. An approval of one input never approves a batch.
58
58
  */
59
59
  export function checkBatchApproval(approval, fresh) {
60
- const expired = Date.parse(approval.expires_at) <= Date.now();
61
60
  if (approval.batch_items === undefined) {
62
61
  fail('quote_input_changed', 'This pricing_quote approves one input; estimate these inputs together (inputs) and obtain approval.');
63
62
  }
64
63
  if (approval.batch_items !== fresh.batch_items || approval.request_hash !== fresh.request_hash || approval.model_id !== fresh.model_id) {
65
64
  fail('quote_input_changed', 'The inputs differ from the approved batch estimate (the same inputs, in the same order).');
66
65
  }
67
- if (approval.fingerprint !== fresh.fingerprint || approval.total_uc !== fresh.total_uc) {
68
- fail('price_changed', 'The pricing rules or estimated price changed. Estimate again and obtain approval.');
66
+ if (approvalExpired(approval)) {
67
+ fail('quote_expired', `The approved batch estimate expired at ${approval.expires_at}. Estimate these inputs again and obtain approval. If this call finishes a batch submitted earlier, check list_tasks first: within 24 hours of its first submission, finish it with the new pricing_quote, the same client_request_id and the same inputs; past that, submit only the inputs that did not go through, as a new batch with a new client_request_id.`);
69
68
  }
70
- return { expired };
69
+ if (priceRose(approval, fresh))
70
+ fail('price_changed', 'The estimated total of the batch rose after it was approved. Estimate again and obtain approval.');
71
71
  }
72
72
  /**
73
73
  * The gateway answered every attempt without running it: a rate limit (it releases the key, so the same key can be
@@ -234,6 +234,19 @@ function reservation10(id, route, input, mediaSeconds, tokensOf) {
234
234
  ...(input_videos ? { input_videos } : {}),
235
235
  tokens: { input_tokens: inputTokens, video_output_tokens: seconds * V10.output, other_output_tokens: OMNI_OTHER_OUTPUT_TOKENS } };
236
236
  }
237
+ /**
238
+ * The input resolutions a reference price is also given at, lowest first, when the gateway reads the input's own at
239
+ * submission: every tier for an input or reference video, or for an upscale each source it accepts for the target.
240
+ */
241
+ export function omniInputTiers(reservation) {
242
+ if (reservation.upscale) {
243
+ const target = reservation.upscale.target;
244
+ return reservation.upscale.source_assumed ? TIERS.filter(tier => UPSCALE[`${tier}>${target}`] !== undefined) : [];
245
+ }
246
+ return reservation.input_videos?.resolution_assumed ? [...TIERS] : [];
247
+ }
248
+ /** The resolution the reference price itself counts the input at: the highest, or the upscale source that costs most. */
249
+ export const omniQuotedTier = (reservation) => reservation.upscale?.source ?? reservation.input_videos?.resolution;
237
250
  /** The lower-resolution input a reference price can also be given for: 720p, or for an upscale the cheaper source. */
238
251
  export function omniLowerInputTier(reservation) {
239
252
  if (reservation.upscale) {