@evolinkai/cli 0.7.0 → 0.8.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 (49) hide show
  1. package/README.md +16 -6
  2. package/package.json +27 -8
  3. package/skills/evolink-cli/SKILL.md +5 -5
  4. package/skills/evolink-cli/references/capabilities.md +1 -1
  5. package/src/api.mjs +55 -0
  6. package/src/auth.mjs +6 -7
  7. package/src/cli.mjs +34 -30
  8. package/src/doctor.mjs +9 -6
  9. package/src/files.mjs +49 -6
  10. package/src/help.mjs +8 -8
  11. package/src/media.mjs +9 -7
  12. package/src/network.mjs +12 -1
  13. package/src/oauth.mjs +82 -0
  14. package/src/platform/LICENSE +178 -0
  15. package/src/platform/NOTICE +6 -0
  16. package/src/platform/core/src/config.js +92 -0
  17. package/src/platform/core/src/data/model-constraints.js +37 -0
  18. package/src/platform/core/src/data/model-params.generated.js +4 -0
  19. package/src/platform/core/src/data/model-params.js +28 -0
  20. package/src/platform/core/src/platform-client.js +50 -0
  21. package/src/platform/core/src/platform-operations.js +22 -0
  22. package/src/platform/core/src/request-context.js +53 -0
  23. package/src/platform/core/src/services/api-client.js +205 -0
  24. package/src/platform/core/src/services/catalog-client.js +45 -0
  25. package/src/platform/core/src/services/error-handler.js +404 -0
  26. package/src/platform/core/src/services/file-client.js +133 -0
  27. package/src/platform/core/src/services/http-policy.js +136 -0
  28. package/src/platform/core/src/services/model-capabilities.js +24 -0
  29. package/src/platform/core/src/services/model-catalog.js +68 -0
  30. package/src/platform/core/src/services/model-recommendations.js +35 -0
  31. package/src/platform/core/src/services/param-validator.js +201 -0
  32. package/src/platform/core/src/services/pricing-client.js +451 -0
  33. package/src/platform/core/src/services/utm.js +65 -0
  34. package/src/platform/core/src/tool-guidance.js +50 -0
  35. package/src/platform/core/src/tools/check-balance.js +90 -0
  36. package/src/platform/core/src/tools/discovery.js +86 -0
  37. package/src/platform/core/src/tools/estimate-cost.js +136 -0
  38. package/src/platform/core/src/tools/generate.js +234 -0
  39. package/src/platform/core/src/tools/get-model.js +146 -0
  40. package/src/platform/core/src/tools/get-task.js +57 -0
  41. package/src/platform/core/src/tools/list-tasks.js +170 -0
  42. package/src/platform/core/src/tools/search-models.js +115 -0
  43. package/src/platform/core/src/tools/shared.js +138 -0
  44. package/src/platform/core/src/tools/task-format.js +245 -0
  45. package/src/platform/core/src/tools/task-usage.js +108 -0
  46. package/src/platform/core/src/version.js +4 -0
  47. package/src/platform/source.json +80 -0
  48. package/src/setup.mjs +9 -5
  49. package/src/mcp.mjs +0 -43
@@ -0,0 +1,245 @@
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 { queryTask } from '../services/api-client.js';
4
+ import { getTaskErrorInfo } from '../services/error-handler.js';
5
+ import { money, sleep, usdOf } from './shared.js';
6
+ /** Result links from the gateway stay downloadable for this long. */
7
+ export const RESULT_LINK_HOURS = 24;
8
+ /** Generation permission does not also authorize the assistant to alter the output. */
9
+ export const RESULT_DELIVERY_INSTRUCTIONS = [
10
+ 'Deliver the original EvoLink result links immediately on completion, with clear view/download labels and the 24-hour expiry notice. Use delivery_markdown as the primary reply when supplied.',
11
+ 'Do not delay delivery for inspection or post-processing. A generation request alone does not authorize local editing, compositing, repair or re-encoding; do that only when the user explicitly requests or authorizes post-processing.',
12
+ 'Report quality issues and offer options. Keep the original links and label any authorized edited version separately.',
13
+ 'Default to ordinary Markdown links for all media, including images; do not automatically add inline remote images or thumbnail placeholders. Only add an image preview when the user requests it and a supported working client preview route is available; otherwise keep the links.',
14
+ 'The server may supply small embedded MCP image thumbnails or video cover frames alongside the original links. These optional previews are not edited replacements; let the client display them and keep delivery_markdown and the original download links in the reply. Do not turn preview metadata into remote Markdown images.',
15
+ 'Use ordinary Markdown links for video/audio, never image syntax for a video URL. Inline previews depend on the client; do not promise them.',
16
+ 'When a requested local download uses Python urllib, explicitly set a truthful product User-Agent (for example EvoLinkClient/1.0) with urllib.request.Request instead of its default Python UA. Do not forward API keys or Authorization headers to media URLs. If 403/1010 persists, report it rather than regenerating or retrying blindly; client-controlled previews may need a separate fix. Downloading is optional and must not delay original-link delivery.',
17
+ ].join(' ');
18
+ /** Compact tool description; the full contract is sent in server instructions and completed results. */
19
+ export const RESULT_DELIVERY_GUIDANCE = 'On completion, promptly deliver original links with the 24-hour expiry and delivery_markdown. Edit only when the user explicitly requests or authorizes post-processing. Keep original links alongside optional embedded MCP thumbnails; do not add remote-image Markdown or use image syntax for video/audio.';
20
+ export const TERMINAL_STATUSES = new Set(['completed', 'failed', 'cancelled']);
21
+ const MEDIA_EXTENSIONS = {
22
+ png: { kind: 'image', mimeType: 'image/png' },
23
+ jpg: { kind: 'image', mimeType: 'image/jpeg' },
24
+ jpeg: { kind: 'image', mimeType: 'image/jpeg' },
25
+ webp: { kind: 'image', mimeType: 'image/webp' },
26
+ gif: { kind: 'image', mimeType: 'image/gif' },
27
+ bmp: { kind: 'image', mimeType: 'image/bmp' },
28
+ mp4: { kind: 'video', mimeType: 'video/mp4' },
29
+ mov: { kind: 'video', mimeType: 'video/quicktime' },
30
+ webm: { kind: 'video', mimeType: 'video/webm' },
31
+ m4v: { kind: 'video', mimeType: 'video/x-m4v' },
32
+ mp3: { kind: 'audio', mimeType: 'audio/mpeg' },
33
+ wav: { kind: 'audio', mimeType: 'audio/wav' },
34
+ m4a: { kind: 'audio', mimeType: 'audio/mp4' },
35
+ flac: { kind: 'audio', mimeType: 'audio/flac' },
36
+ ogg: { kind: 'audio', mimeType: 'audio/ogg' },
37
+ aac: { kind: 'audio', mimeType: 'audio/aac' },
38
+ };
39
+ /** Infer metadata from the path only: a signed query or fragment is not a file extension. */
40
+ function mediaOfUrl(url) {
41
+ try {
42
+ const extension = /\.([a-z0-9]+)$/i.exec(new URL(url).pathname)?.[1].toLowerCase();
43
+ return extension && Object.prototype.hasOwnProperty.call(MEDIA_EXTENSIONS, extension) ? MEDIA_EXTENSIONS[extension] : undefined;
44
+ }
45
+ catch {
46
+ return undefined;
47
+ }
48
+ }
49
+ function kindOfUrl(url, taskType, hint) {
50
+ const media = mediaOfUrl(url);
51
+ if (media)
52
+ return media.kind;
53
+ if (hint)
54
+ return hint;
55
+ if (taskType.includes('image'))
56
+ return 'image';
57
+ if (taskType.includes('video'))
58
+ return 'video';
59
+ if (taskType.includes('audio') || taskType.includes('music'))
60
+ return 'audio';
61
+ return 'file';
62
+ }
63
+ export function resultLinks(task) {
64
+ const seen = new Set();
65
+ const links = [];
66
+ const add = (url, kind) => {
67
+ if (typeof url !== 'string' || !/^https?:\/\//.test(url) || seen.has(url))
68
+ return;
69
+ seen.add(url);
70
+ links.push({ url, kind: kindOfUrl(url, task.type ?? '', kind) });
71
+ };
72
+ for (const url of task.results ?? [])
73
+ add(url);
74
+ if (task.result_data) {
75
+ const items = Array.isArray(task.result_data) ? task.result_data : [task.result_data];
76
+ for (const item of items) {
77
+ if (!item || typeof item !== 'object')
78
+ continue;
79
+ add(item.video_url, 'video');
80
+ add(item.image_url, 'image');
81
+ add(item.audio_url, 'audio');
82
+ }
83
+ }
84
+ return links;
85
+ }
86
+ /** Return reusable public result fields without forwarding provider metadata or account details. */
87
+ export function taskOutputs(task) {
88
+ const items = Array.isArray(task.result_data) ? task.result_data : task.result_data ? [task.result_data] : [];
89
+ const identifiers = new Set(['voice', 'voice_id', 'persona_id', 'result_id', 'id']);
90
+ const textFields = new Set(['title', 'tags']);
91
+ const urls = new Set(['video_url', 'image_url', 'audio_url', 'stream_audio_url']);
92
+ return items.slice(0, 100).flatMap(item => {
93
+ if (!item || typeof item !== 'object' || Array.isArray(item))
94
+ return [];
95
+ const output = {};
96
+ for (const [key, value] of Object.entries(item)) {
97
+ if (identifiers.has(key) && typeof value === 'string' && /^[A-Za-z0-9._:-]{1,128}$/.test(value))
98
+ output[key] = value;
99
+ else if (textFields.has(key) && typeof value === 'string')
100
+ output[key] = value.slice(0, 1000);
101
+ else if (urls.has(key) && typeof value === 'string' && /^https?:\/\//.test(value))
102
+ output[key] = value;
103
+ else if ((key === 'duration' || key === 'seed') && typeof value === 'number' && Number.isFinite(value) && value >= 0)
104
+ output[key] = value;
105
+ }
106
+ return Object.keys(output).length ? [output] : [];
107
+ });
108
+ }
109
+ /** Typed links complement the text fallback; they do not guarantee a client preview.
110
+ * Never fetch or transform media here, and never wrap a video URL in ImageContent.
111
+ * Unknown extensions deliberately omit MIME instead of guessing a container.
112
+ */
113
+ export function resultResources(taskId, links) {
114
+ return links.map((link, index) => {
115
+ const media = mediaOfUrl(link.url);
116
+ return {
117
+ type: 'resource_link',
118
+ uri: link.url,
119
+ name: `View/download original ${link.kind} ${index + 1} (${taskId})`,
120
+ description: `Original EvoLink generated ${link.kind}. View or download; result links expire after ${RESULT_LINK_HOURS} hours. Inline preview depends on the client.`,
121
+ ...(media ? { mimeType: media.mimeType } : {}),
122
+ };
123
+ });
124
+ }
125
+ /** A ready-to-send reply avoids triggering a client's remote-image fallback by default.
126
+ * Angle brackets keep parentheses in signed URLs inside the link destination.
127
+ * Resource URIs remain untouched; encode only characters unsafe in a Markdown destination.
128
+ */
129
+ export function resultDeliveryMarkdown(taskId, links) {
130
+ return [
131
+ `EvoLink task ${taskId} completed.`,
132
+ ...links.map((link, index) => {
133
+ const destination = link.url.replace(/[\u0000-\u0020<>\\]/g, char => encodeURIComponent(char));
134
+ return `[View/download original ${link.kind} ${index + 1}](<${destination}>)`;
135
+ }),
136
+ `Result links expire after ${RESULT_LINK_HOURS} hours; save them promptly.`,
137
+ ].join('\n\n');
138
+ }
139
+ /** One task as text lines and the same facts as structured content. */
140
+ export function describeTask(task) {
141
+ const status = task.status ?? 'pending';
142
+ const links = resultLinks(task);
143
+ const lines = [
144
+ `Task ${task.id}: ${status}${status === 'completed' || status === 'failed' ? '' : ` (${task.progress ?? 0}%)`}`,
145
+ `Model: ${task.model}`,
146
+ ];
147
+ const structured = {
148
+ task_id: task.id,
149
+ status,
150
+ progress: task.progress ?? 0,
151
+ model: task.model,
152
+ type: task.type,
153
+ };
154
+ const outputs = taskOutputs(task);
155
+ if (outputs.length) {
156
+ structured.outputs = outputs;
157
+ lines.push(`Public output metadata: ${JSON.stringify(outputs)}`);
158
+ }
159
+ if (links.length > 0) {
160
+ lines.push(`Results (download links expire after ${RESULT_LINK_HOURS} hours; save them now):`);
161
+ for (const link of links)
162
+ lines.push(`- ${link.kind}: ${link.url}`);
163
+ structured.results = links;
164
+ structured.links_expire_after_hours = RESULT_LINK_HOURS;
165
+ }
166
+ const used = task.usage?.credits_used ?? task.usage?.cost?.credits;
167
+ if (status === 'completed' && typeof used === 'number') {
168
+ lines.push(`Charged: ${money(used)}`);
169
+ structured.charged_credits = used;
170
+ structured.charged_usd = task.usage?.cost?.usd ?? usdOf(used);
171
+ }
172
+ const reserved = task.usage?.credits_reserved;
173
+ if (status !== 'completed' && status !== 'failed' && typeof reserved === 'number' && reserved > 0) {
174
+ lines.push(`Reserved: ${money(reserved)} (the final charge is settled when the task finishes)`);
175
+ structured.reserved_credits = reserved;
176
+ structured.reserved_usd = usdOf(reserved);
177
+ }
178
+ if (typeof task.duration === 'number' && task.duration > 0 && TERMINAL_STATUSES.has(status)) {
179
+ lines.push(`Took: ${task.duration} s`);
180
+ structured.took_seconds = task.duration;
181
+ }
182
+ if (status === 'failed' || status === 'cancelled') {
183
+ const code = task.error?.code ?? (status === 'cancelled' ? 'request_cancelled' : 'unknown_error');
184
+ const info = getTaskErrorInfo(code);
185
+ const suggestion = task.error?.suggestion ? `${info.suggestion} ${task.error.suggestion}` : info.suggestion;
186
+ lines.push(`Error: ${code}${task.error?.message ? ` — ${task.error.message}` : ''}`);
187
+ lines.push('Charge: failed tasks are refunded.');
188
+ lines.push(`Next step: ${info.retryable ? 'You can retry with a new generate call.' : 'Change the input before retrying.'} ${suggestion}`);
189
+ structured.error = { code, message: task.error?.message, retryable: info.retryable, suggestion };
190
+ structured.refunded = true;
191
+ }
192
+ else if (status === 'completed') {
193
+ if (links.length > 0) {
194
+ const delivery = resultDeliveryMarkdown(task.id, links);
195
+ structured.delivery_markdown = delivery;
196
+ lines.push(`Suggested reply (plain links; no automatic inline previews):\n${delivery}`);
197
+ }
198
+ lines.push(links.length > 0
199
+ ? `Next step: ${RESULT_DELIVERY_INSTRUCTIONS}`
200
+ : 'Next step: the task completed but returned no result links. Tell the user; use get_task or list_tasks to recover them. Do not generate again automatically.');
201
+ }
202
+ else {
203
+ const eta = task.task_info?.estimated_time;
204
+ if (eta) {
205
+ lines.push(`Estimated time left: ~${eta} s`);
206
+ structured.estimated_seconds = eta;
207
+ }
208
+ lines.push(`Next step: call get_task with task_id "${task.id}" again (it can wait up to 45 s). Do not call generate again to check progress: that starts and charges a new task.`);
209
+ }
210
+ if (task.request_id) {
211
+ lines.push(`Request ID: ${task.request_id}`);
212
+ structured.request_id = task.request_id;
213
+ }
214
+ return { lines, structured, resources: resultResources(task.id, links) };
215
+ }
216
+ let pollIntervalOverrideMs;
217
+ /** Tests only: shorten the pause between task reads. */
218
+ export function setPollIntervalForTests(ms) {
219
+ pollIntervalOverrideMs = ms;
220
+ }
221
+ /** Pause between task reads: each read of an unfinished task makes the gateway ask the provider. */
222
+ export function pollIntervalMs(type) {
223
+ if (pollIntervalOverrideMs !== undefined)
224
+ return pollIntervalOverrideMs;
225
+ if (type?.includes('video'))
226
+ return 8_000;
227
+ if (type?.includes('audio') || type?.includes('music'))
228
+ return 6_000;
229
+ return 3_000;
230
+ }
231
+ /** Reads a task until it finishes or the deadline passes, pacing reads by task type. */
232
+ export async function waitForTask(config, taskId, options) {
233
+ let task = options.initial ?? await queryTask(config, taskId, options.tool);
234
+ while (!TERMINAL_STATUSES.has(task.status) && !options.signal?.aborted) {
235
+ const interval = pollIntervalMs(task.type);
236
+ if (Date.now() + interval > options.deadline)
237
+ break;
238
+ await options.onPoll?.(task);
239
+ await sleep(interval, options.signal);
240
+ if (options.signal?.aborted)
241
+ break;
242
+ task = await queryTask(config, taskId, options.tool);
243
+ }
244
+ return task;
245
+ }
@@ -0,0 +1,108 @@
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 { z } from 'zod';
4
+ import { listTasks } from '../services/api-client.js';
5
+ import { parseSince } from './list-tasks.js';
6
+ import { READ_ONLY, errorResult, failure, ok, usdOf } from './shared.js';
7
+ const empty = () => ({ tasks: 0, completed: 0, cost_reported_tasks: 0, missing_cost_tasks: 0, reported_credits: 0 });
8
+ function add(totals, task) {
9
+ totals.tasks++;
10
+ if (task.status !== 'completed')
11
+ return;
12
+ totals.completed++;
13
+ if (typeof task.credits_used === 'number' && Number.isFinite(task.credits_used) && task.credits_used >= 0) {
14
+ if (!Number.isFinite(totals.reported_credits + task.credits_used)) {
15
+ throw new Error('The reported task cost total cannot be represented safely; no usage total is returned.');
16
+ }
17
+ totals.cost_reported_tasks++;
18
+ totals.reported_credits += task.credits_used;
19
+ }
20
+ else
21
+ totals.missing_cost_tasks++;
22
+ }
23
+ export function registerTaskUsage(server, config) {
24
+ server.registerTool('get_task_usage', {
25
+ title: 'Summarize reported task usage',
26
+ description: 'Free account-wide task summary by creation time and model. Scans at most max_pages × 50 retained tasks. Reports completed-task credits and missing costs. This is not an invoice, payment/refund ledger, MCP-only usage, or a settlement budget. Retention, concurrent changes and the scan bound can make it incomplete.',
27
+ inputSchema: {
28
+ since: z.string().min(1).max(40).default('30d').describe('Creation time lower bound: ISO 8601, Unix seconds or relative (30d).'),
29
+ until: z.string().min(1).max(40).optional().describe('Inclusive creation time upper bound, default now.'),
30
+ model: z.string().min(1).max(128).optional().describe('Exact model ID.'),
31
+ type: z.enum(['image', 'video', 'audio']).optional(),
32
+ max_pages: z.number().int().min(1).max(20).default(5).describe('Scan bound (1–20 pages of 50 tasks, default 5).'),
33
+ },
34
+ annotations: { title: 'Summarize reported task usage', ...READ_ONLY },
35
+ }, async ({ since, until, model, type, max_pages }, extra) => {
36
+ const now = Date.now();
37
+ const from = parseSince(since, now);
38
+ const to = until === undefined ? now : parseSince(until, now);
39
+ if (from === undefined || to === undefined || from > to) {
40
+ return failure('Use a valid since/until creation-time interval, with since at or before until.', { error: { category: 'invalid_request', param: 'since/until' } });
41
+ }
42
+ try {
43
+ const totals = empty();
44
+ const models = new Map();
45
+ const statuses = Object.create(null);
46
+ const seen = new Set();
47
+ let pages = 0, serverTotal = 0, changed = false, invalidRows = 0, exhausted = false;
48
+ for (let page = 1; page <= max_pages; page++) {
49
+ if (pages && Date.now() - now > 40_000)
50
+ break;
51
+ if (extra.signal.aborted)
52
+ throw new Error('Stopped reading task usage. Retry this read to obtain a summary.');
53
+ const batch = await listTasks(config, { model, type, page, pageSize: 50 }, 'get_task_usage', { timeoutMs: Math.max(1, Math.min(5_000, 40_000 - (Date.now() - now))), retries: 0 });
54
+ if (pages && serverTotal !== batch.total)
55
+ changed = true;
56
+ serverTotal = batch.total;
57
+ pages++;
58
+ if (batch.page !== page || batch.page_size !== 50 || batch.data.length > 50) {
59
+ return failure('The task pagination could not be verified; no usage total is returned.', { error: { category: 'server_error' } });
60
+ }
61
+ for (const task of batch.data) {
62
+ if (typeof task.id !== 'string' || typeof task.model !== 'string' || !Number.isSafeInteger(task.created_at) || task.created_at < 0 || typeof task.status !== 'string') {
63
+ invalidRows++;
64
+ continue;
65
+ }
66
+ if (seen.has(task.id)) {
67
+ changed = true;
68
+ continue;
69
+ }
70
+ seen.add(task.id);
71
+ if ((model && task.model !== model) || (type && task.type !== type)) {
72
+ invalidRows++;
73
+ continue;
74
+ }
75
+ const created = task.created_at * 1000;
76
+ if (created < from || created > to)
77
+ continue;
78
+ add(totals, task);
79
+ const group = models.get(task.model) ?? empty();
80
+ add(group, task);
81
+ models.set(task.model, group);
82
+ statuses[task.status] = (statuses[task.status] ?? 0) + 1;
83
+ }
84
+ if (page * 50 >= batch.total || batch.data.length === 0) {
85
+ exhausted = seen.size === batch.total;
86
+ break;
87
+ }
88
+ }
89
+ const complete = exhausted && !changed && invalidRows === 0;
90
+ const rounded = (value) => ({ ...value, reported_credits: Number(value.reported_credits.toFixed(6)), reported_usd_approx: usdOf(value.reported_credits) });
91
+ const note = 'Account-wide retained tasks, grouped by creation time. Completed-task reported costs only; excludes pending reservations, payments, refunds and non-task charges. USD is approximate (68 credits ≈ $1). This is not a bill or a final spending limit.';
92
+ return ok(`${totals.tasks} tasks in the scanned creation-time interval; ${totals.completed} completed. Reported completed-task cost: ${rounded(totals).reported_credits} credits. ${totals.missing_cost_tasks} completed tasks have no valid cost.\nCoverage: ${complete ? 'all currently retained matching tasks scanned' : 'incomplete; do not treat this as a full total'}.\n${note}`, {
93
+ scope: 'account_retained_task_summary', as_of: new Date(now).toISOString(),
94
+ interval: { since: new Date(from).toISOString(), until: new Date(to).toISOString(), basis: 'task_creation_time' },
95
+ filters: { model, type }, totals: rounded(totals), by_status: statuses,
96
+ by_model: [...models].sort(([a], [b]) => a.localeCompare(b)).map(([id, group]) => ({ model: id, ...rounded(group) })),
97
+ coverage: { complete_for_retained_tasks: complete, historical_completeness: 'unknown', scanned_pages: pages,
98
+ scanned_unique_tasks: seen.size, server_total: serverTotal, max_pages, truncated: !exhausted,
99
+ concurrent_change_detected: changed, invalid_rows: invalidRows },
100
+ consistent_snapshot_guaranteed: false,
101
+ is_bill: false, final_budget_enforced: false, note,
102
+ });
103
+ }
104
+ catch (error) {
105
+ return errorResult(error);
106
+ }
107
+ });
108
+ }
@@ -0,0 +1,4 @@
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
+ /** Version reported in serverInfo and in the X-Evo-Client-Version header. */
4
+ export const MCP_VERSION = '1.6.0';
@@ -0,0 +1,80 @@
1
+ {
2
+ "schema_version": 1,
3
+ "repository": "Evolink-AI/evolink-mcp",
4
+ "baseline": "acc9fd43b945e3917b47809fc94f85ba26c7c8db",
5
+ "source_sha256": "02e7c1fb2027b036325cff0b21f6de3f2a72eae649cbe3e5910cdd207d948bad",
6
+ "files": {
7
+ "packages/core/src/branding.ts": "534b944a1370f210a3858c1a85b1a23071aca8e26b7a3e70e4d859ba5b152ff7",
8
+ "packages/core/src/config.ts": "b7a51479f841e7c361c7ca682f8a6a6b879bdecf811876c50cd8658a98239db7",
9
+ "packages/core/src/data/model-constraints.ts": "c6a20af6ef181e5b620aa31944d1e8453b72f1794bda4c65397390184636542c",
10
+ "packages/core/src/data/model-params.generated.ts": "9641f2c80475259964104be11f1de86f64c23ccfa6defabb7614ff88ed93d819",
11
+ "packages/core/src/data/model-params.ts": "d387d10b7d888059df9c1bd2177e336a497981b63ecbac57009f399f4e1fd858",
12
+ "packages/core/src/platform-client.ts": "2e81e61448c0d0977e2ecff713bc738b8d52fcd189a03e9592996ca70d777cb2",
13
+ "packages/core/src/platform-operations.ts": "7f6d3512ef284a953125e57fa46e3021018e7f5f60c5381fd64511a9b70f082c",
14
+ "packages/core/src/request-context.ts": "c78d28379609779305aa2ebbf3c9cc503a98ed7f144eed48103ab518c9ef5539",
15
+ "packages/core/src/server.ts": "263c89c5cc52205704f4c468f376e47cbdeadf9574ca00a0c581ee90a68387bc",
16
+ "packages/core/src/services/api-client.ts": "8049192202a051d8c18e69279a01c499f184171d2c9b56cb9a07c770d3e0a24d",
17
+ "packages/core/src/services/catalog-client.ts": "c2bcfb0f2780112bcddf6a42537cf9f6264717d0b3685c896790339b0f9bb7df",
18
+ "packages/core/src/services/error-handler.ts": "ce053d8d212a1733e05c08d7e84d19945a1d99940df049dae43abb26d28199ba",
19
+ "packages/core/src/services/file-client.ts": "77446061322953c80e85f1806b20e8e7d5895164af1877d3a8395081bb880523",
20
+ "packages/core/src/services/http-policy.ts": "ab2b407c70bc96422dc600460e7de93eebe93ed3275d0a28d309181b391e8fa1",
21
+ "packages/core/src/services/media-preview.ts": "89410d8eb9a02e6fb9d9bc0de8a69b48bec7a06039e54569b9fea7e35527b6c4",
22
+ "packages/core/src/services/model-capabilities.ts": "b41c8b6dd34432cd2e44529e7f40aa1dd7c3b5d0d20e5964b78468517e1979df",
23
+ "packages/core/src/services/model-catalog.ts": "742b3ef24ab324b7d8e9fa6c7a6287b975ed7a8b6518b18625099e0976043291",
24
+ "packages/core/src/services/model-recommendations.ts": "e986db35ac3a5e3c0c8daa1d4b9e5426e081b90674740de96fbcb11ddc2baf35",
25
+ "packages/core/src/services/param-validator.ts": "506e6d6f6a1ad170024d6a24ffcd2434c73e7ac855a89bbba9fdbb81653416fb",
26
+ "packages/core/src/services/preview-download.ts": "719e100e05f7632f633551773159ba7202f755c6d6ff5ecf364b40eeb26bee7b",
27
+ "packages/core/src/services/pricing-client.ts": "904f7006149e1e573d23ee8d5ac23d0121502edea59660847b59bb3a85e19c04",
28
+ "packages/core/src/services/upload-policy.ts": "2dc36716a3b9e78b078c618b029499bf6e27448dd44900b6f917dda5f8046ce3",
29
+ "packages/core/src/services/upload-slots.ts": "54cdb2af01e00770f828bf88f991d84fac26620b7d184800a706c290e2a898a0",
30
+ "packages/core/src/services/utm.ts": "adb224e91531b0db809b5de086ddc97bb5a383184458554dcdf784a65cd941a5",
31
+ "packages/core/src/tool-guidance.ts": "2c554abc0937fa29fe76008fc390e1039100af620ac4c1a3dd9185c2e92d903f",
32
+ "packages/core/src/tools/check-balance.ts": "f27b269a3c3c838a54fe54005eb72f637ddfdc2982d932901282bbf072d1efca",
33
+ "packages/core/src/tools/discovery.ts": "50adaf61d2e159a78348661b1b49b0332d47079275f943da67b5f132f8997218",
34
+ "packages/core/src/tools/estimate-cost.ts": "d0c41bce5003ce873000cca7ea976a49fb753edf3737f6544481bd0e0f08d2c3",
35
+ "packages/core/src/tools/generate.ts": "4f69fa4bfedc9eebbc106a2b1f7e249cc105afa36abe9e403912d8d02a6ac06b",
36
+ "packages/core/src/tools/get-model.ts": "276be6bb4b1a655fec69aef7347ed24cdab93f16458ffc2af7d7d866cd54b84c",
37
+ "packages/core/src/tools/get-task.ts": "937a5ad4454956dd000abfd11149523d135527018d4d643ede600950d69e6205",
38
+ "packages/core/src/tools/list-tasks.ts": "22e5ac19bbe210fb11ea39afe12fa7f92fb40ffc0560c7bee3d1f9354fc78395",
39
+ "packages/core/src/tools/prepare-upload.ts": "4e2bb3c26a7d55c0a306cef0fd88f6200d1c222f88567f7d2bfd6cc813ffd84a",
40
+ "packages/core/src/tools/search-models.ts": "3b950140240ac6c5f0dfdc0264cb4b66d0583e05e220c67245b6e8a7616fc55e",
41
+ "packages/core/src/tools/shared.ts": "516d510dd32f6c0aaa8a8ea4623e40137411a8a8b1aeccb47f603d6419d50231",
42
+ "packages/core/src/tools/task-format.ts": "a3fdcf648c149a0edc0380364de39d0a36ec3d2c28930b494ff35f27b9615fa4",
43
+ "packages/core/src/tools/task-usage.ts": "ba05d054e1d60d67f6ab75cc6d9169f453c87e0e89c17a2c1be5fc429e8f9f47",
44
+ "packages/core/src/tools/upload-file.ts": "da6f239d1b1e6a13a7b418d24e738ebabf9823b2656111eeaa70eb247421ad40",
45
+ "packages/core/src/version.ts": "84d58feeac16c22e6f9a6e528b4a891f99f0aff9373b0f68e40ce78eebbde3d1"
46
+ },
47
+ "artifacts": {
48
+ "core/src/config.js": "c24132899ccbaca319709925f484bed7514cded3151c250866735f59751496fa",
49
+ "core/src/data/model-constraints.js": "78029eb010d93e87ba4262b69e80bcdd87b979d38ce620c29bab70f9c967df7b",
50
+ "core/src/data/model-params.generated.js": "9f6ee98f59b9571797ab8e3d5ed874724fe386ec7616ae338596db15de8f3f78",
51
+ "core/src/data/model-params.js": "1c746a0547674ca5fb5f2a8bf9f6ca5496e6897193651917c84023088fc749ec",
52
+ "core/src/platform-client.js": "d727810542e619b9d8f65d7e5b0cf22b989109a98a98909186e37c73c85e5ef7",
53
+ "core/src/platform-operations.js": "5e9752fb6660a846d35a5a39818090ee8ec09239c81e4039ebd135dbb6985738",
54
+ "core/src/request-context.js": "ed22b79db1fc8b20c57f0a58e938ff4a833bb6a75a16d2246f732a41256c21e8",
55
+ "core/src/services/api-client.js": "877b2ad34def3f1d53ff88167b44fe641b24d395d235231aeaa913e620aabfee",
56
+ "core/src/services/catalog-client.js": "f438fdb13fa9e9ddbf539b265bfcbb77c4d5024835130cbade3b83e9952893cf",
57
+ "core/src/services/error-handler.js": "6e5c4d68bf380a130a6c27bbbc473522cfbf8add7ea35834d000b283ead1a446",
58
+ "core/src/services/file-client.js": "88bf7eeca71e53f728437281d3113733ab5d34ee4e47f0144e523549183d7a1b",
59
+ "core/src/services/http-policy.js": "c4111adef9edb71c68ca8b349e581174c0424f79b2810c06459fcbc74ec4bbd0",
60
+ "core/src/services/model-capabilities.js": "2ad86bc08c82cce82964b18d6187632fc738f8cd17d03de1ef04f27b1e35cfe1",
61
+ "core/src/services/model-catalog.js": "0bda8fafa579fd33c7450807597e0798fd510450d9c7aee9211fb34e1748de72",
62
+ "core/src/services/model-recommendations.js": "f330f941d26aa9fc127c2f7479cb2be026d6111a3f3066e89442ff29ec33803a",
63
+ "core/src/services/param-validator.js": "9e3fba916a39140614851689fcf47f1aa644a30b6192b6126af4d78695f88b10",
64
+ "core/src/services/pricing-client.js": "2f0f74f7769442e4edf8c3f37a66bb1c6c099253189e9b2079ad265d1327225d",
65
+ "core/src/services/utm.js": "8aa328ddb92c3ef65568fab60226cb5fa2e940449d7ac3d6c2e35b6f9bcf835d",
66
+ "core/src/tool-guidance.js": "fc0d4bd4ce6bc60ba9d3f01efab386698c744b9dd9386d148abc3ebe68cfa7b7",
67
+ "core/src/tools/check-balance.js": "75baa61e57e289fd61a45251665df599967ba0beb4b33cc3976280a9d89421bf",
68
+ "core/src/tools/discovery.js": "6095a2f699fbf465bcae3387b137901ecdbbbb00bbfa6f4b3250a7c293c45b70",
69
+ "core/src/tools/estimate-cost.js": "d0f5a82b2c9d7770500870cf1a7bc7b41fd1677d08d1f8b72d8a03936c8b0a76",
70
+ "core/src/tools/generate.js": "09596e6cab0a6f886fa8fedc6a4a889b5f90dc26324e823df211262a99c9801a",
71
+ "core/src/tools/get-model.js": "e7d8d8165277fab474547527ad7f08cee3a6bb2b47162235357456534faebadb",
72
+ "core/src/tools/get-task.js": "1ef62167c629c7ad859d1d31cd8779eb98e3a22c8bb754b2c355e58515b308f0",
73
+ "core/src/tools/list-tasks.js": "e795aeebed047d3ba72c87d699f3bb1306bc626d04c69db2a2667607abce586e",
74
+ "core/src/tools/search-models.js": "9850b7d2d74a1d69229400d465b21ecb9ede79c75dddeb41787668f418c5bd06",
75
+ "core/src/tools/shared.js": "4f142981857d5de53b61366819fcc6edfb19e8654a9e27290deb606bc3a0012f",
76
+ "core/src/tools/task-format.js": "52a41e629ec318d6739f4daeaa58b58f4f7e4fd6c031ae2c441a313b4a7e56ab",
77
+ "core/src/tools/task-usage.js": "3aae5d7807efc2c762bf604cf9ecfecf8f9008185bcef584e6d4243404418dc5",
78
+ "core/src/version.js": "850acd6b3227ec266df6bfa3ef9c4db08752289eb073eb4f4c244925cde645cb"
79
+ }
80
+ }
package/src/setup.mjs CHANGED
@@ -5,12 +5,13 @@ import { CLI_VERSION } from './version.mjs';
5
5
 
6
6
  const LOGIN_ERRORS = new Set(['login_required', 'invalid_session', 'login_expired']);
7
7
 
8
- export async function setup({ state, server, credentials, mcp, agent = 'all', skillHome, noBrowser = false,
8
+ export async function setup({ state, server, credentials, client, mcp = client, agent = 'all', skillHome, noBrowser = false,
9
9
  timeout = 180_000, signal, progress = () => {}, version, platform }) {
10
+ client = mcp;
10
11
  validateAgent(agent);
11
12
  return state.lock('setup', async () => {
12
13
  const steps = [];
13
- let phase = 'preflight', connected = false, models = false, skills;
14
+ let phase = 'preflight', connected = false, models = false, skills, authorization;
14
15
  const recovery = () => `evolink setup --agent ${agent}${noBrowser ? ' --no-browser' : ''}`;
15
16
  try {
16
17
  progress('Setup: checking runtime, local state and secure credential storage.');
@@ -27,8 +28,9 @@ export async function setup({ state, server, credentials, mcp, agent = 'all', sk
27
28
  let needsLogin = !preflight.auth.authenticated;
28
29
  if (!needsLogin) {
29
30
  try {
30
- const balance = await mcp.call('check_balance');
31
+ const balance = await client.call('check_balance');
31
32
  requireThat(balance.ok === true, 'connection_failed', 'Balance verification failed. Retry the connection check.');
33
+ authorization = balance.authorization;
32
34
  connected = true;
33
35
  } catch (error) {
34
36
  if (!LOGIN_ERRORS.has(error.code)) throw error;
@@ -43,13 +45,14 @@ export async function setup({ state, server, credentials, mcp, agent = 'all', sk
43
45
  steps.push({ name: 'login', status: 'passed', reused: !needsLogin });
44
46
  phase = 'connection';
45
47
  if (!connected) {
46
- const balance = await mcp.call('check_balance');
48
+ const balance = await client.call('check_balance');
47
49
  requireThat(balance.ok === true, 'connection_failed', 'Balance verification failed. Retry evolink balance --json.');
50
+ authorization = balance.authorization;
48
51
  connected = true;
49
52
  }
50
53
  steps.push({ name: 'connection', status: 'passed', verified: true });
51
54
  phase = 'models';
52
- await verifyModels(mcp); models = true;
55
+ await verifyModels(client); models = true;
53
56
  steps.push({ name: 'models', status: 'passed', verified: true });
54
57
  phase = 'skills';
55
58
  const status = await skillStatus({ home: skillHome, agent });
@@ -57,6 +60,7 @@ export async function setup({ state, server, credentials, mcp, agent = 'all', sk
57
60
  progress('Setup: CLI connection, models and skill files verified. Ask your assistant to confirm skill discovery.');
58
61
  return { ok: true, setup_complete: true, cli_version: CLI_VERSION, agent, server: server.href,
59
62
  connection_verified: connected, model_discovery_verified: models, skills, steps,
63
+ ...(authorization ? { authorization } : {}), ...(client.apiUrl ? { transport: 'rest', api_origin: client.apiUrl.origin } : {}),
60
64
  assistant_discovery: 'not_checked', next_step: skills.next_step };
61
65
  } catch (error) {
62
66
  const view = errorView(error);
package/src/mcp.mjs DELETED
@@ -1,43 +0,0 @@
1
- import { CLI_VERSION } from './version.mjs';
2
- import { Client } from '@modelcontextprotocol/sdk/client/index.js';
3
- import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
4
- import { CliError, requireThat, safeMessage } from './errors.mjs';
5
-
6
- export class Mcp {
7
- constructor(credentials, { signal } = {}) { this.credentials = credentials; this.signal = signal; }
8
- async call(name, args = {}, { requireCapability = false, requiredInputs = [] } = {}) {
9
- for (let attempt = 0; attempt < 2; attempt++) {
10
- const access = await this.credentials.access(attempt > 0);
11
- const client = new Client({ name: 'EvoLink CLI', version: CLI_VERSION });
12
- const headers = { Authorization: `Bearer ${access.access_token}` };
13
- const transport = new StreamableHTTPClientTransport(this.credentials.server, { requestInit: { headers }, fetch: this.credentials.fetchFn });
14
- // The hosted service is stateless and does not expose an SSE GET stream.
15
- transport.onerror = () => {};
16
- try {
17
- await client.connect(transport, { signal: this.signal, timeout: 30_000 });
18
- if (requireCapability) {
19
- const list = await client.listTools(undefined, { signal: this.signal, timeout: 30_000 });
20
- const tool = list.tools.find(tool => tool.name === name);
21
- requireThat(tool && requiredInputs.every(key => Object.hasOwn(tool.inputSchema?.properties ?? {}, key)),
22
- 'capability_unavailable', 'This EvoLink service does not advertise the requested capability. Ask for the MCP service update; no tool was called.',
23
- { tool: name, required_inputs: requiredInputs, request_sent: false });
24
- }
25
- const result = await client.callTool({ name, arguments: args }, undefined, { signal: this.signal, timeout: 75_000 });
26
- const data = result.structuredContent;
27
- const text = (result.content ?? []).filter(c => c.type === 'text').map(c => c.text).join('\n');
28
- if (result.isError || data?.ok === false) {
29
- throw new CliError(data?.error?.category || 'tool_failed', safeMessage(data?.error?.message || text || 'The EvoLink tool refused this request.'),
30
- { ...data, text: safeMessage(text) });
31
- }
32
- requireThat(data?.ok === true, 'unsupported_response', 'EvoLink returned no structured result. Update the CLI or reconnect.');
33
- return { ...data, text, _binding: access.binding };
34
- } catch (e) {
35
- if (attempt === 0 && (e.code === 401 || e.constructor.name === 'UnauthorizedError')) continue;
36
- if (this.signal?.aborted) throw new CliError('interrupted', 'Stopped waiting locally. Submitted tasks continue on EvoLink.', undefined, 130);
37
- if (e instanceof CliError) throw e;
38
- throw new CliError('connection_failed', 'Could not complete the EvoLink request. For a submitted task, recover using the saved quote and request ID.');
39
- } finally { await client.close().catch(() => {}); }
40
- }
41
- throw new CliError('login_required', 'The login expired. Run auth login.');
42
- }
43
- }