@evolinkai/cli 0.10.2 → 0.11.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 (29) hide show
  1. package/README.md +27 -3
  2. package/package.json +1 -1
  3. package/skills/evolink-cli/SKILL.md +10 -2
  4. package/skills/evolink-cli/references/usage-and-budget.md +16 -1
  5. package/src/api.mjs +5 -3
  6. package/src/cli.mjs +2 -1
  7. package/src/help.mjs +1 -1
  8. package/src/media.mjs +18 -3
  9. package/src/platform/core/src/data/model-constraints.js +27 -0
  10. package/src/platform/core/src/data/model-params.js +8 -1
  11. package/src/platform/core/src/data/model-params.overrides.generated.js +4 -0
  12. package/src/platform/core/src/services/api-client.js +8 -10
  13. package/src/platform/core/src/services/http-policy.js +2 -1
  14. package/src/platform/core/src/services/pricing-quote-client.js +16 -2
  15. package/src/platform/core/src/services/pricing-rules-estimate.js +31 -2
  16. package/src/platform/core/src/services/public-error.js +1 -1
  17. package/src/platform/core/src/services/search-usage.js +22 -0
  18. package/src/platform/core/src/services/seedance-input.js +75 -0
  19. package/src/platform/core/src/services/task-response.js +176 -0
  20. package/src/platform/core/src/tool-guidance.js +3 -1
  21. package/src/platform/core/src/tools/estimate-cost.js +12 -2
  22. package/src/platform/core/src/tools/generate.js +27 -8
  23. package/src/platform/core/src/tools/get-model.js +8 -3
  24. package/src/platform/core/src/tools/get-task.js +3 -2
  25. package/src/platform/core/src/tools/list-tasks.js +69 -29
  26. package/src/platform/core/src/tools/shared.js +22 -2
  27. package/src/platform/core/src/tools/task-format.js +27 -9
  28. package/src/platform/core/src/version.js +1 -1
  29. package/src/platform/source.json +45 -37
@@ -0,0 +1,75 @@
1
+ // Copyright 2024 EvoLink AI. SPDX-License-Identifier: Apache-2.0
2
+ // Generated from Evolink-AI/evolink-mcp; adapted for direct REST operations. See platform/LICENSE and platform/NOTICE.
3
+ const GENERATION_MODELS = new Set([
4
+ 'seedance-2.5-text-to-video',
5
+ 'seedance-2.5-image-to-video',
6
+ 'seedance-2.5-reference-to-video',
7
+ 'seedance-2.5-video-edit',
8
+ 'seedance-2.5-video-extend',
9
+ ]);
10
+ /** Match the resolved catalog identity, never a borrowed documentation alias. */
11
+ export function isSeedanceGeneration(entry) {
12
+ return entry.id !== undefined && GENERATION_MODELS.has(entry.id)
13
+ && entry.kind === 'video' && entry.spec?.path === '/v1/videos/generations';
14
+ }
15
+ export function isSeedanceSearch(entry) {
16
+ return isSeedanceGeneration(entry) && entry.id === 'seedance-2.5-text-to-video';
17
+ }
18
+ export function seedanceSearchEnabled(entry, input) {
19
+ const params = input.model_params;
20
+ return isSeedanceSearch(entry) && !!params && typeof params === 'object' && !Array.isArray(params)
21
+ && params.web_search === true;
22
+ }
23
+ /** Only reviewed gateway checks are blocking. Documentation-only differences warn. */
24
+ export function prepareSeedanceInput(entry, input) {
25
+ const applies = isSeedanceGeneration(entry);
26
+ const errors = [], warnings = [];
27
+ const defaults = [];
28
+ if (!applies)
29
+ return { applies, input, errors, warnings, defaults };
30
+ // Do not mutate the shared catalog spec, caller input, or nested references.
31
+ const effective = { ...input };
32
+ const params = input.model_params && typeof input.model_params === 'object' && !Array.isArray(input.model_params)
33
+ ? input.model_params : undefined;
34
+ if (input.web_search !== undefined)
35
+ errors.push({ param: 'web_search', problem: 'must be provided as model_params.web_search for this model.' });
36
+ if (params?.draft !== undefined)
37
+ errors.push({ param: 'model_params.draft', problem: 'must be provided as the top-level draft field.' });
38
+ if (params?.web_search !== undefined && typeof params.web_search !== 'boolean') {
39
+ errors.push({ param: 'model_params.web_search', problem: 'must be a boolean.' });
40
+ }
41
+ if (input.draft === true) {
42
+ if (input.quality === undefined) {
43
+ effective.quality = '480p';
44
+ defaults.push({ param: 'quality', value: '480p', reason: 'draft=true requires 480p' });
45
+ }
46
+ else if (input.quality !== '480p') {
47
+ errors.push({ param: 'quality', problem: 'must be 480p when draft is true; omit quality to use the 480p draft default.' });
48
+ }
49
+ }
50
+ if (typeof input.duration === 'number' && (input.duration === 0 || input.duration < -1)) {
51
+ errors.push({ param: 'duration', problem: 'must be an integer between 4 and 30 seconds, or -1 for automatic duration.' });
52
+ }
53
+ else if (entry.id !== 'seedance-2.5-video-edit' && typeof input.duration === 'number' && Number.isInteger(input.duration)
54
+ && input.duration !== -1 && (input.duration < 4 || input.duration > 30)) {
55
+ warnings.push({ param: 'duration', problem: 'is outside the documented 4–30 seconds or -1; acceptance by the service has not been verified.' });
56
+ }
57
+ if (seedanceSearchEnabled(entry, input) && input.content_filter === false) {
58
+ warnings.push({ param: 'content_filter', problem: 'false with model_params.web_search=true is documented as unsupported; service acceptance has not been verified.' });
59
+ }
60
+ return { applies, input: effective, errors, warnings, defaults };
61
+ }
62
+ /** A fresh object for the resolved model; never augment the shared docs index. */
63
+ export function seedanceInputRules(entry) {
64
+ if (!isSeedanceGeneration(entry))
65
+ return undefined;
66
+ return {
67
+ model: entry.id, endpoint: entry.spec.path,
68
+ conditional_defaults: [{ when: { draft: true }, parameter: 'quality', value: '480p' }],
69
+ blocking: ['draft=true requires quality=480p or omitted', 'duration=0 and duration<-1 are rejected',
70
+ 'draft must be top-level', 'model_params.web_search must be boolean when provided'],
71
+ warnings_only: ['Other unverified duration boundaries and search/content_filter combinations do not add blocking checks.'],
72
+ ...(entry.id === 'seedance-2.5-video-edit' ? { duration_usage: 'duration=-1 selects video editing; supply expected output seconds separately as pricing_parameters.duration_seconds, not as input.duration.' } : {}),
73
+ ...(isSeedanceSearch(entry) ? { search_usage: 'Search defaults to off. When model_params.web_search=true, missing search_count produces a partial subtotal assuming zero searches, with separate per-search rates. Expected counts are not execution limits; one task may search multiple times.' } : {}),
74
+ };
75
+ }
@@ -0,0 +1,176 @@
1
+ // Copyright 2024 EvoLink AI. SPDX-License-Identifier: Apache-2.0
2
+ // Generated from Evolink-AI/evolink-mcp; adapted for direct REST operations. See platform/LICENSE and platform/NOTICE.
3
+ import { publicIdentifier, publicNumber, publicText } from './public-error.js';
4
+ import { publicTaskMessage } from './error-handler.js';
5
+ const STATUSES = new Set(['pending', 'processing', 'completed', 'failed', 'cancelled']);
6
+ const taskIdentifier = (value) => typeof value === 'string' && /^[A-Za-z0-9._:-]{1,128}$/.test(value);
7
+ const record = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
8
+ /** A failed read is not a failed generation or evidence about its charge. */
9
+ export class TaskResponseError extends Error {
10
+ code;
11
+ taskId;
12
+ requestId;
13
+ rawStatus;
14
+ constructor(code, taskId, requestId, rawStatus) {
15
+ super(code === 'task_identity_mismatch' ? 'The response did not match the requested task.'
16
+ : code === 'task_status_unknown' ? 'The task status could not be verified.' : 'The task response could not be verified.');
17
+ this.code = code;
18
+ this.taskId = taskId;
19
+ this.requestId = requestId;
20
+ this.rawStatus = rawStatus;
21
+ this.name = 'TaskResponseError';
22
+ }
23
+ }
24
+ const outputSchema = {
25
+ voice: 'id', voice_id: 'id', persona_id: 'id', result_id: 'id', id: 'id', title: 'text', tags: 'text',
26
+ duration: 'number', seed: 'number', video_url: 'url', image_url: 'url', audio_url: 'url', stream_audio_url: 'url',
27
+ };
28
+ const schema = {
29
+ model: 'text', object: 'text', type: 'text', created: 'number', progress: 'number', duration: 'number', video_duration: 'number',
30
+ task_info: { can_cancel: 'boolean', estimated_time: 'number', video_duration: 'number' },
31
+ usage: { billing_rule: 'text', credits_reserved: 'number', credits_used: 'number',
32
+ cost: { credits: 'number', usd: 'number', cny: 'number' }, user_group: 'text' },
33
+ billing: { charge_status: ['unknown', 'reserved', 'charged', 'released'],
34
+ refund_status: ['unknown', 'not_required', 'pending', 'completed', 'failed'],
35
+ refund_scope: ['account_balance'], limit_restoration: ['unknown'], reserved_credits: 'number', charged_credits: 'number',
36
+ refunded_credits: 'number', refunded_at: 'text' },
37
+ error: { code: 'text', message: 'task_message', type: 'text', suggestion: 'text' }, request_id: 'id',
38
+ };
39
+ function url(value) {
40
+ if (typeof value !== 'string' || value.length > 16384)
41
+ return;
42
+ try {
43
+ const parsed = new URL(value);
44
+ if (['http:', 'https:'].includes(parsed.protocol) && !parsed.username && !parsed.password)
45
+ return value;
46
+ }
47
+ catch { /* Invalid optional URLs are omitted without fetching them. */ }
48
+ }
49
+ function normalize(value, rule, path, warnings) {
50
+ if (value === undefined)
51
+ return;
52
+ let result;
53
+ if (rule === 'text')
54
+ result = typeof value === 'string' ? publicText(value).slice(0, 2000) : undefined;
55
+ else if (rule === 'task_message')
56
+ result = publicTaskMessage(value);
57
+ else if (rule === 'id')
58
+ result = publicIdentifier(value);
59
+ else if (rule === 'number')
60
+ result = publicNumber(value);
61
+ else if (rule === 'boolean')
62
+ result = typeof value === 'boolean' ? value : undefined;
63
+ else if (rule === 'url')
64
+ result = url(value);
65
+ else if (Array.isArray(rule))
66
+ result = typeof value === 'string' && rule.includes(value) ? value : undefined;
67
+ else if (record(value)) {
68
+ const fields = {};
69
+ for (const [key, child] of Object.entries(rule)) {
70
+ const parsed = normalize(value[key], child, `${path}.${key}`, warnings);
71
+ if (parsed !== undefined)
72
+ fields[key] = parsed;
73
+ }
74
+ result = fields;
75
+ }
76
+ if (result === undefined)
77
+ warnings.add(path);
78
+ return result;
79
+ }
80
+ /** Project known public fields; model-specific omissions do not invalidate a task. */
81
+ export function parseTaskReceipt(value, requestId) {
82
+ if (!record(value) || !taskIdentifier(value.id))
83
+ throw new TaskResponseError('task_response_invalid', undefined, requestId);
84
+ const warnings = new Set();
85
+ const task = { id: value.id };
86
+ for (const [key, rule] of Object.entries(schema)) {
87
+ const parsed = normalize(value[key], rule, key, warnings);
88
+ if (parsed !== undefined)
89
+ task[key] = parsed;
90
+ }
91
+ if (typeof task.progress === 'number' && task.progress > 100) {
92
+ delete task.progress;
93
+ warnings.add('progress');
94
+ }
95
+ // Limit dates before consumers convert them to ISO strings.
96
+ if (typeof task.created === 'number' && task.created > 253402300799) {
97
+ delete task.created;
98
+ warnings.add('created');
99
+ }
100
+ if (typeof value.status === 'string' && STATUSES.has(value.status))
101
+ task.status = value.status;
102
+ else
103
+ warnings.add('status');
104
+ if (value.results !== undefined) {
105
+ if (Array.isArray(value.results)) {
106
+ task.results = value.results.slice(0, 100).flatMap((item, index) => {
107
+ const parsed = normalize(item, 'url', `results[${index}]`, warnings);
108
+ return typeof parsed === 'string' ? [parsed] : [];
109
+ });
110
+ if (value.results.length > 100)
111
+ warnings.add('results.truncated');
112
+ }
113
+ else
114
+ warnings.add('results');
115
+ }
116
+ if (value.result_data !== undefined) {
117
+ if (Array.isArray(value.result_data)) {
118
+ task.result_data = value.result_data.slice(0, 100).flatMap((item, index) => {
119
+ const parsed = normalize(item, outputSchema, `result_data[${index}]`, warnings);
120
+ return parsed === undefined ? [] : [parsed];
121
+ });
122
+ if (value.result_data.length > 100)
123
+ warnings.add('result_data.truncated');
124
+ }
125
+ else {
126
+ const parsed = normalize(value.result_data, outputSchema, 'result_data', warnings);
127
+ if (parsed !== undefined)
128
+ task.result_data = parsed;
129
+ }
130
+ }
131
+ if (requestId && publicIdentifier(requestId))
132
+ task.request_id = requestId;
133
+ if (warnings.size)
134
+ task.response_warnings = [...warnings].slice(0, 100);
135
+ return task;
136
+ }
137
+ export function parseTaskResponse(value, taskId, requestId) {
138
+ if (!record(value) || !taskIdentifier(value.id))
139
+ throw new TaskResponseError('task_response_invalid', taskId, requestId);
140
+ if (value.id !== taskId)
141
+ throw new TaskResponseError('task_identity_mismatch', taskId, requestId);
142
+ if (typeof value.status !== 'string' || !STATUSES.has(value.status)) {
143
+ const raw = typeof value.status === 'string' && /^[a-z_]{1,32}$/.test(value.status) ? value.status : undefined;
144
+ throw new TaskResponseError('task_status_unknown', taskId, requestId, raw);
145
+ }
146
+ return parseTaskReceipt(value, requestId);
147
+ }
148
+ export function parseBatchTasks(value, taskIds, requestId) {
149
+ if (!record(value) || !Array.isArray(value.data))
150
+ throw new TaskResponseError('task_response_invalid', undefined, requestId);
151
+ const requested = new Set(taskIds.filter(taskIdentifier)), counts = new Map();
152
+ for (const item of value.data)
153
+ if (record(item) && typeof item.id === 'string' && requested.has(item.id))
154
+ counts.set(item.id, (counts.get(item.id) ?? 0) + 1);
155
+ const tasks = [], issues = [];
156
+ for (const item of value.data) {
157
+ const id = record(item) && typeof item.id === 'string' && requested.has(item.id) ? item.id : undefined;
158
+ if (!id) {
159
+ issues.push({ code: 'unexpected_task_response' });
160
+ continue;
161
+ }
162
+ if (counts.get(id) > 1) {
163
+ if (!issues.some(issue => issue.task_id === id))
164
+ issues.push({ task_id: id, code: 'duplicate_task_response' });
165
+ continue;
166
+ }
167
+ try {
168
+ tasks.push(parseTaskResponse(item, id, requestId));
169
+ }
170
+ catch (error) {
171
+ issues.push({ task_id: id, code: error instanceof TaskResponseError ? error.code : 'task_response_invalid' });
172
+ }
173
+ }
174
+ const found = new Set(tasks.map(task => task.id));
175
+ return { tasks, missing: [...requested].filter(id => !found.has(id)), issues };
176
+ }
@@ -13,7 +13,7 @@ export const PAID_GENERATION_GUIDANCE = [
13
13
  ].join(' ');
14
14
  /** Shared confirmation wording; approval and spending rules above still apply. */
15
15
  export const GENERATION_CONFIRMATION_GUIDANCE = [
16
- 'When spending approval is needed, use the following layout in the user\'s language. Fill it from the exact model and input checked by `estimate_cost`; summarize the content in one sentence. Render normal text and bullets; the code blocks below only illustrate the layout.',
16
+ 'When spending approval is needed, use the following layout in English by default unless the user explicitly requests another language. Fill it from the exact model and input checked by `estimate_cost`; summarize the content in one sentence. Render normal text and bullets; the code blocks below only illustrate the layout.',
17
17
  '',
18
18
  'Chinese:',
19
19
  '',
@@ -43,6 +43,8 @@ export const GENERATION_CONFIRMATION_GUIDANCE = [
43
43
  '- For a complete estimate, show the returned amount or range in credits and approximate USD. Label it as an estimate, not a guaranteed final charge.',
44
44
  '- Do not add a separate estimated cap or max_cost_usd to the default confirmation. If the user specified a budget, state whether the estimate fits it; pause if it exceeds the budget. A budget comparison does not limit the final settlement.',
45
45
  '- For a partial estimate, label it "部分估价" / "Partial estimate", state what is excluded, and say it is neither the total nor an upper bound.',
46
+ '- Keep model web and image search off unless the user explicitly requests or approves enabling it. Never enable search on your own or just because a copied example enables it. If you think search is needed, first explain its extra per-search rates and unknown total, end the reply, and wait for explicit user consent before enabling it. Approval of a task without search does not authorize adding search; changed search settings require a fresh estimate and approval.',
47
+ '- When search_charges is returned, disclose each enabled search type and its per-search rate before generation approval, even when the user requested search. A zero-search subtotal excludes unknown search fees; one task may search multiple times or not at all. Expected counts are assumptions, not execution limits. Actual counts depend on the task and model strategy. Do not add a search-fee warning when search is off.',
46
48
  '- For token billing, say "按实际 token 用量计费,生成前无法确定总价" / "Billed by actual token usage; the total is unknown before generation." Include the applicable published unit rates when returned. If no price is available, say so rather than assuming token billing.',
47
49
  '- If the user set a fixed cap that cannot be checked, explain that gap and replace the usual closing with an explicit question about proceeding without that cap. Do not treat a generic "Confirm generation" as consent to remove or raise a cap.',
48
50
  '- The suggested confirmation phrase is not a required command; any clear approval of the quoted task is valid. Existing task or batch approval still follows the spending approval rules; do not ask again when it already covers this request.',
@@ -8,6 +8,7 @@ import { formatEstimateRange } from '../services/pricing-client.js';
8
8
  import { PricingRulesError } from '../services/pricing-rules-client.js';
9
9
  import { QuoteError, QuoteParameters } from '../services/pricing-quote-client.js';
10
10
  import { createRulesEstimate } from '../services/pricing-rules-estimate.js';
11
+ import { prepareSeedanceInput } from '../services/seedance-input.js';
11
12
  import { API_KEYS_URL, MCP_CONSOLE_URL, MCP_KEY_NAME, TOP_UP_URL } from '../services/http-policy.js';
12
13
  import { trackedLink } from '../services/utm.js';
13
14
  import { currentCredentialMode } from '../request-context.js';
@@ -25,7 +26,7 @@ export function registerEstimateCost(server, config) {
25
26
  input: z.record(z.unknown()).optional()
26
27
  .describe('The input you plan to pass to the generate tool, e.g. {"prompt":"…","duration":5,"quality":"1080p"}.'),
27
28
  pricing_source: z.enum(['pricing_rules', 'account', 'public_reference']).default('pricing_rules').describe('Use published full pricing rules for public default estimates. The old account/public_reference values are compatibility aliases; neither requests a backend account quote.'),
28
- pricing_parameters: QuoteParameters.optional().describe('Measured or expected billing usage declared by the pricing policy, such as input_seconds. Do not include user_group, prices or generation prompts.'),
29
+ pricing_parameters: QuoteParameters.optional().describe('Measured or explicitly expected usage declared by the pricing policy, such as input_seconds or search_count. Missing enabled-search counts produce a zero-search partial subtotal and per-search rates. Do not invent counts, include user_group/prices/prompts, or treat expected counts as execution limits.'),
29
30
  media_seconds: z.number().positive().max(MEDIA_SECONDS_MAX).optional().describe(MEDIA_SECONDS_DESCRIPTION),
30
31
  },
31
32
  annotations: { title: 'Estimate cost', ...READ_ONLY },
@@ -36,8 +37,11 @@ export function registerEstimateCost(server, config) {
36
37
  const suggestions = suggestModels(catalog, model);
37
38
  return failure(`Unknown model "${model}".${suggestions.length ? ` Did you mean: ${suggestions.join(', ')}?` : ''} Use search_models to find model IDs.`, { error: { category: 'not_found', param: 'model' }, suggestions });
38
39
  }
39
- const values = input ?? {};
40
+ const prepared = prepareSeedanceInput(entry, input ?? {});
41
+ const values = prepared.input;
40
42
  const validation = entry.spec ? validateInput(entry.spec, values) : undefined;
43
+ validation?.errors.push(...prepared.errors);
44
+ validation?.warnings.push(...prepared.warnings);
41
45
  if (validation?.errors.length)
42
46
  return failure('The generation input is invalid; no estimate was created.', { input_valid: false, problems: validation.errors, error: { category: 'invalid_request' }, charged: 'no' });
43
47
  const rulesEstimate = await createRulesEstimate(entry, values, { mediaSeconds, pricingParameters });
@@ -54,6 +58,8 @@ export function registerEstimateCost(server, config) {
54
58
  }
55
59
  if (validation?.warnings.length)
56
60
  lines.push('Warnings:', ...formatIssues(validation.warnings));
61
+ for (const applied of prepared.defaults)
62
+ lines.push(`Applied default: ${applied.param}=${applied.value} (${applied.reason}); this effective value is used for pricing and submission.`);
57
63
  const range = formatEstimateRange(estimate);
58
64
  if (estimate.status === 'estimated' && range)
59
65
  lines.push(`Estimated cost: ${range}`);
@@ -91,6 +97,10 @@ export function registerEstimateCost(server, config) {
91
97
  problems: validation?.errors ?? [],
92
98
  warnings: validation?.warnings ?? [],
93
99
  estimate,
100
+ ...(estimate.search_charges?.length ? { search_charges: estimate.search_charges,
101
+ amount_scope: estimate.status === 'partial' ? 'known_components_subtotal' : estimate.status === 'estimated' ? 'expected_usage_estimate' : 'not_established' } : {}),
102
+ ...(prepared.applies ? { effective_input: values, defaults_applied: prepared.defaults,
103
+ amount_scope: estimate.status === 'partial' ? 'known_components_subtotal' : estimate.status === 'estimated' ? 'expected_usage_estimate' : 'not_established' } : {}),
94
104
  };
95
105
  try {
96
106
  const credits = await getCredits(config, 'estimate_cost');
@@ -14,6 +14,7 @@ import { MEDIA_SECONDS_DESCRIPTION, MEDIA_SECONDS_MAX, PAID, errorResult, failur
14
14
  import { RESULT_DELIVERY_GUIDANCE, TERMINAL_STATUSES, describeTask, waitForTask } from './task-format.js';
15
15
  import { PAID_GENERATION_GUIDANCE } from '../tool-guidance.js';
16
16
  import { currentRequestCredentials } from '../request-context.js';
17
+ import { prepareSeedanceInput } from '../services/seedance-input.js';
17
18
  const PATHS = {
18
19
  image: '/v1/images/generations',
19
20
  video: '/v1/videos/generations',
@@ -141,9 +142,13 @@ function registerGenerate(server, config, kind) {
141
142
  charged: 'no',
142
143
  });
143
144
  }
145
+ const prepared = prepareSeedanceInput(entry, input);
146
+ const effectiveInput = prepared.input;
144
147
  const warnings = [];
145
148
  if (entry.spec) {
146
- const validation = validateInput(entry.spec, input);
149
+ const validation = validateInput(entry.spec, effectiveInput);
150
+ validation.errors.push(...prepared.errors);
151
+ validation.warnings.push(...prepared.warnings);
147
152
  if (validation.errors.length > 0) {
148
153
  return failure([
149
154
  `The input for ${entry.id} has problems; nothing was submitted or charged:`,
@@ -159,7 +164,7 @@ function registerGenerate(server, config, kind) {
159
164
  // media_seconds only prices the request; the body below is built from input alone.
160
165
  if (args.account_quote)
161
166
  throw new QuoteError('quote_refresh_required', 'Refresh the legacy account estimate with estimate_cost and obtain user approval.');
162
- const rulesEstimate = await createRulesEstimate(entry, input, { mediaSeconds: args.media_seconds, pricingParameters: args.pricing_parameters });
167
+ const rulesEstimate = await createRulesEstimate(entry, effectiveInput, { mediaSeconds: args.media_seconds, pricingParameters: args.pricing_parameters });
163
168
  if (args.pricing_quote)
164
169
  checkRulesApproval(args.pricing_quote, rulesEstimate);
165
170
  const estimate = rulesEstimate.estimate;
@@ -183,7 +188,7 @@ function registerGenerate(server, config, kind) {
183
188
  if (estimate.status === 'needs_input')
184
189
  throw new QuoteError('quote_usage_required', 'No charge can be estimated yet; supply the missing pricing usage before submission.');
185
190
  clientRequestId = args.client_request_id ?? newRunId();
186
- const body = { ...input, model: entry.id };
191
+ const body = { ...effectiveInput, model: entry.id };
187
192
  const submitted = await submitTask(config, {
188
193
  path: entry.spec?.path ?? PATHS[kind],
189
194
  body,
@@ -192,24 +197,27 @@ function registerGenerate(server, config, kind) {
192
197
  });
193
198
  acceptedTaskId = submitted.id;
194
199
  let task = submitted;
200
+ let statusCheck = 'not_requested';
195
201
  const waitUntil = started + WAIT_MS[kind];
196
- if (!TERMINAL_STATUSES.has(task.status) && WAIT_MS[kind] > 0 && Date.now() + 3_000 < waitUntil) {
202
+ if ((!task.status || !TERMINAL_STATUSES.has(task.status)) && WAIT_MS[kind] > 0 && Date.now() + 3_000 < waitUntil) {
197
203
  const report = progressReporter(extra, WAIT_MS[kind] / 1000);
198
204
  try {
199
205
  task = await waitForTask(config, submitted.id, {
200
206
  deadline: waitUntil,
201
207
  tool: name,
202
208
  signal: extra.signal,
203
- onPoll: current => report((Date.now() - started) / 1000, `${current.status}, ${current.progress ?? 0}%`),
209
+ onPoll: current => report((Date.now() - started) / 1000, `${current.status}${current.progress !== undefined ? `, ${current.progress}%` : ''}`),
204
210
  });
211
+ statusCheck = 'verified';
205
212
  }
206
213
  catch {
207
214
  // The task exists; a failed status read must not turn a successful submit into an error.
208
215
  task = submitted;
216
+ statusCheck = 'unverified';
209
217
  }
210
218
  task.usage = { ...submitted.usage, ...task.usage };
211
219
  }
212
- const view = describeTask({ ...task, request_id: task.request_id ?? submitted.request_id });
220
+ const view = describeTask({ ...task, request_id: task.request_id ?? submitted.request_id }, statusCheck);
213
221
  const header = submitted.idempotency_replayed
214
222
  ? `This client_request_id was used before: returning the original task (no new charge).`
215
223
  : `Submitted ${entry.id}.`;
@@ -220,6 +228,12 @@ function registerGenerate(server, config, kind) {
220
228
  }
221
229
  if (estimate.status === 'estimated')
222
230
  lines.push(`Estimate before submitting: ${rangeText(estimate)}`);
231
+ if (estimate.search_charges?.length && estimate.status === 'estimated') {
232
+ for (const note of estimate.notes.filter(note => /^(Web|Image) search is enabled\./.test(note)))
233
+ lines.push(`Note: ${note}`);
234
+ }
235
+ for (const applied of prepared.defaults)
236
+ lines.push(`Applied default: ${applied.param}=${applied.value} (${applied.reason}).`);
223
237
  if (estimate.status === 'partial') {
224
238
  lines.push(`Partial estimate at published rates: ${rangeText(estimate)} (not a total or an upper bound).`);
225
239
  for (const extra of estimate.possible_extras)
@@ -232,15 +246,20 @@ function registerGenerate(server, config, kind) {
232
246
  lines.push(`client_request_id: ${clientRequestId}`);
233
247
  return ok(lines.join('\n'), {
234
248
  ...view.structured,
235
- submitted: { model: entry.id, input },
249
+ submitted: { model: entry.id, input: effectiveInput },
250
+ ...(prepared.applies ? { effective_input: effectiveInput, defaults_applied: prepared.defaults,
251
+ usage_assumptions: estimate.notes.filter(note => note.startsWith('Web search is enabled.')) } : {}),
236
252
  pricing_scope: 'public_default',
237
253
  pricing_source: 'pricing_rules',
238
254
  amounts: rulesEstimate.amounts,
239
255
  final_budget_enforced: false,
256
+ ...(estimate.search_charges?.length ? { search_charges: estimate.search_charges, estimate,
257
+ amount_scope: estimate.status === 'partial' ? 'known_components_subtotal' : 'expected_usage_estimate' } : {}),
240
258
  client_request_id: clientRequestId,
259
+ submission_state: 'accepted',
241
260
  replayed: submitted.idempotency_replayed === true,
242
261
  ...(typeof reserved === 'number' ? { reserved_credits: reserved, reserved_usd: usdOf(reserved) } : {}),
243
- ...(estimate.status === 'estimated' ? { estimate: { min_usd: estimate.min_usd, max_usd: estimate.max_usd } } : {}),
262
+ ...(estimate.status === 'estimated' && !estimate.search_charges?.length ? { estimate: { min_usd: estimate.min_usd, max_usd: estimate.max_usd } } : {}),
244
263
  ...(estimate.status === 'partial' ? { estimate } : {}),
245
264
  ...(warnings.length ? { warnings } : {}),
246
265
  }, view.resources);
@@ -9,6 +9,7 @@ import { trackedLink } from '../services/utm.js';
9
9
  import { READ_ONLY, errorResult, failure, ok } from './shared.js';
10
10
  import { modelTitle } from './search-models.js';
11
11
  import { referenceInputs } from '../services/model-capabilities.js';
12
+ import { seedanceInputRules } from '../services/seedance-input.js';
12
13
  function value(v) {
13
14
  return JSON.stringify(v);
14
15
  }
@@ -60,6 +61,7 @@ export function registerGetModel(server, config) {
60
61
  return failure(`Unknown model "${model}".${suggestions.length ? ` Did you mean: ${suggestions.join(', ')}?` : ''} Use search_models to find model IDs.`, { error: { category: 'not_found', param: 'model' }, suggestions });
61
62
  }
62
63
  const { spec, priced } = entry;
64
+ const modelRules = seedanceInputRules(entry);
63
65
  const title = modelTitle(entry);
64
66
  const lines = [`${entry.id} (${entry.kind})${title ? ` — ${title}` : ''}`, `Generate with: generate_${entry.kind}`];
65
67
  const structured = {
@@ -89,8 +91,9 @@ export function registerGetModel(server, config) {
89
91
  parameters: spec.params,
90
92
  constraints: spec.constraints,
91
93
  example_input: spec.example,
92
- parameters_source: modelParamsMeta(),
93
- input_schema: spec.inputSchema?.schema,
94
+ parameters_source: modelParamsMeta(entry.id),
95
+ input_schema: modelRules && spec.inputSchema ? { ...spec.inputSchema.schema, 'x-evolink-model-rules': modelRules } : spec.inputSchema?.schema,
96
+ ...(modelRules ? { model_input_rules: modelRules } : {}),
94
97
  response_schema: spec.responseSchema?.schema,
95
98
  schema_info: {
96
99
  dialect: spec.inputSchema?.dialect,
@@ -99,13 +102,15 @@ export function registerGetModel(server, config) {
99
102
  response_scope: 'generation_submission_response_not_final_task_result',
100
103
  omitted_fields: { input: ['model', 'callback_url'], response: ['task_info.can_cancel'] },
101
104
  additional_runtime_constraints: spec.constraints,
102
- source: modelParamsMeta(),
105
+ source: modelParamsMeta(entry.id),
103
106
  validation_scope: 'documented_schema_plus_runtime_constraints',
104
107
  runtime_constraints_source: 'reviewed_gateway_supplements',
105
108
  },
106
109
  reference_inputs: referenceInputs(spec),
107
110
  });
108
111
  lines.push('Schemas are versioned official OpenAPI references. response_schema describes submission, not necessarily the final task output. Apply the additional runtime constraints above.');
112
+ if (modelRules)
113
+ lines.push('Model-specific rules: draft=true uses quality=480p when omitted and rejects another quality. These rules apply only to this resolved model and generation endpoint.', ...(modelRules.search_usage ? [modelRules.search_usage] : []), ...(modelRules.duration_usage ? [modelRules.duration_usage] : []));
109
114
  }
110
115
  else {
111
116
  lines.push('', 'Parameters for this model are not documented here; the gateway checks the input when you submit.');
@@ -15,6 +15,7 @@ export function registerGetTask(server, config) {
15
15
  'Check one generation task and, while it is still running, wait up to wait_seconds (max 45) for it to finish. Free.',
16
16
  'Returns the status, progress, result links (they expire after 24 hours, so give them to the user right away), the final charge, or the error with a next step.',
17
17
  'If the task is still running when this returns, call get_task again.',
18
+ 'Invalid bodies, mismatched IDs and unknown states return a query error with the original task ID and status_check unverified. Retry the free query; do not infer generation failure, zero charge or a refund. Missing optional fields are not zero. Completed resource tasks may return voice/persona IDs without links.',
18
19
  'Never call generate_image, generate_video or generate_audio again to check progress: that creates and charges a new task.',
19
20
  RESULT_DELIVERY_GUIDANCE,
20
21
  ].join(' '),
@@ -39,7 +40,7 @@ export function registerGetTask(server, config) {
39
40
  if (elapsed - lastReport < PROGRESS_EVERY_SECONDS)
40
41
  return;
41
42
  lastReport = elapsed;
42
- await report(elapsed, `${current.status}, ${current.progress ?? 0}%`);
43
+ await report(elapsed, `${current.status}${current.progress !== undefined ? `, ${current.progress}%` : ''}`);
43
44
  },
44
45
  });
45
46
  const view = describeTask(task);
@@ -51,7 +52,7 @@ export function registerGetTask(server, config) {
51
52
  return ok(view.lines.join('\n'), view.structured, view.resources);
52
53
  }
53
54
  catch (error) {
54
- return errorResult(error);
55
+ return errorResult(error, { phase: 'query', taskId: task_id });
55
56
  }
56
57
  });
57
58
  }