agent-media-cli 1.0.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.
- package/LICENSE +199 -0
- package/README.md +59 -0
- package/dist/commands/alias.d.ts +3 -0
- package/dist/commands/alias.d.ts.map +1 -0
- package/dist/commands/alias.js +245 -0
- package/dist/commands/alias.js.map +1 -0
- package/dist/commands/apikey.d.ts +3 -0
- package/dist/commands/apikey.d.ts.map +1 -0
- package/dist/commands/apikey.js +282 -0
- package/dist/commands/apikey.js.map +1 -0
- package/dist/commands/cancel.d.ts +9 -0
- package/dist/commands/cancel.d.ts.map +1 -0
- package/dist/commands/cancel.js +101 -0
- package/dist/commands/cancel.js.map +1 -0
- package/dist/commands/completions.d.ts +15 -0
- package/dist/commands/completions.d.ts.map +1 -0
- package/dist/commands/completions.js +293 -0
- package/dist/commands/completions.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +327 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/credits.d.ts +18 -0
- package/dist/commands/credits.d.ts.map +1 -0
- package/dist/commands/credits.js +459 -0
- package/dist/commands/credits.js.map +1 -0
- package/dist/commands/debug.d.ts +20 -0
- package/dist/commands/debug.d.ts.map +1 -0
- package/dist/commands/debug.js +291 -0
- package/dist/commands/debug.js.map +1 -0
- package/dist/commands/delete.d.ts +3 -0
- package/dist/commands/delete.d.ts.map +1 -0
- package/dist/commands/delete.js +273 -0
- package/dist/commands/delete.js.map +1 -0
- package/dist/commands/doctor.d.ts +14 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +468 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/download.d.ts +3 -0
- package/dist/commands/download.d.ts.map +1 -0
- package/dist/commands/download.js +165 -0
- package/dist/commands/download.js.map +1 -0
- package/dist/commands/generate.d.ts +3 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +358 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/inspect.d.ts +10 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +376 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/list.d.ts +13 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +198 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/login.d.ts +15 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +123 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +12 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +85 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/models.d.ts +10 -0
- package/dist/commands/models.d.ts.map +1 -0
- package/dist/commands/models.js +137 -0
- package/dist/commands/models.js.map +1 -0
- package/dist/commands/plan.d.ts +13 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +134 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/pricing.d.ts +14 -0
- package/dist/commands/pricing.d.ts.map +1 -0
- package/dist/commands/pricing.js +166 -0
- package/dist/commands/pricing.js.map +1 -0
- package/dist/commands/profile.d.ts +9 -0
- package/dist/commands/profile.d.ts.map +1 -0
- package/dist/commands/profile.js +236 -0
- package/dist/commands/profile.js.map +1 -0
- package/dist/commands/retry.d.ts +3 -0
- package/dist/commands/retry.d.ts.map +1 -0
- package/dist/commands/retry.js +424 -0
- package/dist/commands/retry.js.map +1 -0
- package/dist/commands/status.d.ts +9 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +182 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/subscribe.d.ts +3 -0
- package/dist/commands/subscribe.d.ts.map +1 -0
- package/dist/commands/subscribe.js +263 -0
- package/dist/commands/subscribe.js.map +1 -0
- package/dist/commands/text.d.ts +3 -0
- package/dist/commands/text.d.ts.map +1 -0
- package/dist/commands/text.js +263 -0
- package/dist/commands/text.js.map +1 -0
- package/dist/commands/update.d.ts +13 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +211 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/usage.d.ts +13 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +344 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/version.d.ts +8 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +26 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/commands/whoami.d.ts +9 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +76 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +518 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +582 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/config.d.ts +33 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +91 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/credentials.d.ts +60 -0
- package/dist/lib/credentials.d.ts.map +1 -0
- package/dist/lib/credentials.js +152 -0
- package/dist/lib/credentials.js.map +1 -0
- package/dist/lib/errors.d.ts +20 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +77 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/output.d.ts +33 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +77 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
package/dist/lib/api.js
ADDED
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
// Copyright 2026 agent-media contributors. Apache-2.0 license.
|
|
2
|
+
/**
|
|
3
|
+
* AgentMediaAPI - HTTP client wrapping fetch to Supabase Edge Functions.
|
|
4
|
+
*
|
|
5
|
+
* All CLI-to-server communication goes through this class. It handles
|
|
6
|
+
* authentication headers, base URL resolution, JSON parsing, and
|
|
7
|
+
* structured error responses.
|
|
8
|
+
*/
|
|
9
|
+
import { CLIError } from './errors.js';
|
|
10
|
+
/** Default Supabase project URL. Override via AGENT_MEDIA_API_URL. */
|
|
11
|
+
const DEFAULT_API_URL = 'https://ppwvarkmpffljlqxkjux.supabase.co';
|
|
12
|
+
// Public anon key — safe to embed. All access is gated by RLS policies.
|
|
13
|
+
// This is equivalent to NEXT_PUBLIC_SUPABASE_ANON_KEY on the frontend.
|
|
14
|
+
// Override for local dev via AGENT_MEDIA_ANON_KEY env var.
|
|
15
|
+
const DEFAULT_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBwd3ZhcmttcGZmbGpscXhranV4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzEzMTI4MDksImV4cCI6MjA4Njg4ODgwOX0.H9tcntgnAJVziWNKUomlgdoCi7FGe-5RUxqzaVCZR44';
|
|
16
|
+
export class AgentMediaAPI {
|
|
17
|
+
baseUrl;
|
|
18
|
+
apiKey;
|
|
19
|
+
anonKey;
|
|
20
|
+
constructor(apiKey) {
|
|
21
|
+
this.apiKey = apiKey;
|
|
22
|
+
this.baseUrl =
|
|
23
|
+
process.env['AGENT_MEDIA_API_URL']?.replace(/\/+$/, '') ?? DEFAULT_API_URL;
|
|
24
|
+
this.anonKey =
|
|
25
|
+
process.env['AGENT_MEDIA_ANON_KEY'] ?? DEFAULT_ANON_KEY;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Initiate the device-code OAuth flow.
|
|
29
|
+
* No auth required -- the device is not yet authenticated.
|
|
30
|
+
*/
|
|
31
|
+
static async initiateDeviceFlow(baseUrl) {
|
|
32
|
+
const url = (baseUrl ?? process.env['AGENT_MEDIA_API_URL'] ?? DEFAULT_API_URL).replace(/\/+$/, '');
|
|
33
|
+
const anonKey = process.env['AGENT_MEDIA_ANON_KEY'] ?? DEFAULT_ANON_KEY;
|
|
34
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
35
|
+
if (anonKey) {
|
|
36
|
+
headers['apikey'] = anonKey;
|
|
37
|
+
headers['Authorization'] = `Bearer ${anonKey}`;
|
|
38
|
+
}
|
|
39
|
+
const res = await fetch(`${url}/functions/v1/device-token`, {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
headers,
|
|
42
|
+
body: JSON.stringify({}),
|
|
43
|
+
});
|
|
44
|
+
if (!res.ok) {
|
|
45
|
+
await throwApiError(res, 'Failed to initiate device login');
|
|
46
|
+
}
|
|
47
|
+
return (await res.json());
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Poll the device-token endpoint during the login flow.
|
|
51
|
+
* No auth required. Returns status-based responses without throwing on
|
|
52
|
+
* expected non-200 codes (428 pending, 410 expired, 403 denied).
|
|
53
|
+
*/
|
|
54
|
+
static async pollDeviceToken(deviceCode, baseUrl) {
|
|
55
|
+
const url = (baseUrl ?? process.env['AGENT_MEDIA_API_URL'] ?? DEFAULT_API_URL).replace(/\/+$/, '');
|
|
56
|
+
const anonKey = process.env['AGENT_MEDIA_ANON_KEY'] ?? DEFAULT_ANON_KEY;
|
|
57
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
58
|
+
if (anonKey) {
|
|
59
|
+
headers['apikey'] = anonKey;
|
|
60
|
+
headers['Authorization'] = `Bearer ${anonKey}`;
|
|
61
|
+
}
|
|
62
|
+
const res = await fetch(`${url}/functions/v1/device-token/poll`, {
|
|
63
|
+
method: 'POST',
|
|
64
|
+
headers,
|
|
65
|
+
body: JSON.stringify({ device_code: deviceCode }),
|
|
66
|
+
});
|
|
67
|
+
// 428 = authorization_pending (still waiting for user)
|
|
68
|
+
if (res.status === 428) {
|
|
69
|
+
return { status: 'pending' };
|
|
70
|
+
}
|
|
71
|
+
// 410 = expired token
|
|
72
|
+
if (res.status === 410) {
|
|
73
|
+
return { status: 'expired' };
|
|
74
|
+
}
|
|
75
|
+
// 403 = access denied
|
|
76
|
+
if (res.status === 403) {
|
|
77
|
+
return { status: 'denied' };
|
|
78
|
+
}
|
|
79
|
+
if (!res.ok) {
|
|
80
|
+
await throwApiError(res, 'Failed to poll device token');
|
|
81
|
+
}
|
|
82
|
+
const data = (await res.json());
|
|
83
|
+
return data;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the authenticated user's profile, subscription, and credit info.
|
|
87
|
+
*/
|
|
88
|
+
async whoami() {
|
|
89
|
+
const res = await this.request('GET', '/functions/v1/credits-check');
|
|
90
|
+
return (await res.json());
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get the authenticated user's credit balance and subscription info.
|
|
94
|
+
*
|
|
95
|
+
* Identical endpoint to whoami but semantically focused on credits.
|
|
96
|
+
* Returns the same shape, allowing credits/plan commands to share the call.
|
|
97
|
+
*/
|
|
98
|
+
async getCredits() {
|
|
99
|
+
const res = await this.request('GET', '/functions/v1/credits-check');
|
|
100
|
+
return (await res.json());
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a Stripe Checkout session for a subscription plan.
|
|
104
|
+
*
|
|
105
|
+
* Returns a checkout URL that can be opened in the user's browser.
|
|
106
|
+
*/
|
|
107
|
+
async createPlanCheckout(planTier) {
|
|
108
|
+
const res = await this.request('POST', '/functions/v1/checkout', {
|
|
109
|
+
plan_tier: planTier,
|
|
110
|
+
});
|
|
111
|
+
return (await res.json());
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Create a Stripe Checkout session for a PAYG credit pack.
|
|
115
|
+
*
|
|
116
|
+
* Returns a checkout URL that can be opened in the user's browser.
|
|
117
|
+
*/
|
|
118
|
+
async createPaygCheckout(packId) {
|
|
119
|
+
const res = await this.request('POST', '/functions/v1/checkout', {
|
|
120
|
+
payg_pack_id: packId,
|
|
121
|
+
});
|
|
122
|
+
return (await res.json());
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Create a Stripe Customer Portal session for managing subscription.
|
|
126
|
+
*
|
|
127
|
+
* Returns a portal URL that can be opened in the user's browser.
|
|
128
|
+
*/
|
|
129
|
+
async createPortalSession(returnUrl) {
|
|
130
|
+
const res = await this.request('POST', '/functions/v1/stripe-portal', {
|
|
131
|
+
returnUrl: returnUrl ?? 'https://agent-media.ai/billing',
|
|
132
|
+
});
|
|
133
|
+
return (await res.json());
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Revoke the current API key on the server side.
|
|
137
|
+
*/
|
|
138
|
+
async revokeApiKey() {
|
|
139
|
+
await this.request('POST', '/functions/v1/device-token', {
|
|
140
|
+
action: 'revoke',
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Submit a generation job or perform a dry-run cost estimate.
|
|
145
|
+
*
|
|
146
|
+
* When `params.dryRun` is true the server returns a cost estimate
|
|
147
|
+
* without creating a job or deducting credits.
|
|
148
|
+
*/
|
|
149
|
+
async submitGeneration(params) {
|
|
150
|
+
const body = {
|
|
151
|
+
model: params.modelSlug,
|
|
152
|
+
prompt: params.prompt,
|
|
153
|
+
dry_run: params.dryRun ?? false,
|
|
154
|
+
};
|
|
155
|
+
if (params.duration !== undefined)
|
|
156
|
+
body['duration'] = params.duration;
|
|
157
|
+
if (params.resolution !== undefined)
|
|
158
|
+
body['resolution'] = params.resolution;
|
|
159
|
+
if (params.aspectRatio !== undefined)
|
|
160
|
+
body['aspect_ratio'] = params.aspectRatio;
|
|
161
|
+
if (params.seed !== undefined)
|
|
162
|
+
body['seed'] = params.seed;
|
|
163
|
+
if (params.inputMediaUrl !== undefined)
|
|
164
|
+
body['input_media_url'] = params.inputMediaUrl;
|
|
165
|
+
if (params.idempotencyKey !== undefined)
|
|
166
|
+
body['idempotency_key'] = params.idempotencyKey;
|
|
167
|
+
const res = await this.request('POST', '/functions/v1/generate', body);
|
|
168
|
+
if (params.dryRun) {
|
|
169
|
+
return (await res.json());
|
|
170
|
+
}
|
|
171
|
+
return (await res.json());
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get a presigned upload URL for an input media file.
|
|
175
|
+
*
|
|
176
|
+
* The returned `uploadUrl` can be used with {@link uploadFile} to
|
|
177
|
+
* upload the file directly to storage.
|
|
178
|
+
*/
|
|
179
|
+
async getUploadUrl(filename, contentType) {
|
|
180
|
+
const res = await this.request('POST', '/functions/v1/upload-url', {
|
|
181
|
+
filename,
|
|
182
|
+
content_type: contentType,
|
|
183
|
+
});
|
|
184
|
+
return (await res.json());
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Upload a file to a presigned storage URL.
|
|
188
|
+
*
|
|
189
|
+
* This sends a PUT request directly to the storage endpoint
|
|
190
|
+
* (not through the API base URL).
|
|
191
|
+
*/
|
|
192
|
+
async uploadFile(uploadUrl, fileBuffer, contentType) {
|
|
193
|
+
const blob = new Blob([fileBuffer], { type: contentType });
|
|
194
|
+
const res = await fetch(uploadUrl, {
|
|
195
|
+
method: 'PUT',
|
|
196
|
+
headers: { 'Content-Type': contentType },
|
|
197
|
+
body: blob,
|
|
198
|
+
});
|
|
199
|
+
if (!res.ok) {
|
|
200
|
+
throw new CLIError(`File upload failed (HTTP ${res.status})`, {
|
|
201
|
+
code: 'UPLOAD_FAILED',
|
|
202
|
+
suggestion: 'Check the file path and try again.',
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Fetch the list of active models from the models table via PostgREST.
|
|
208
|
+
*
|
|
209
|
+
* Uses the anon key for auth since models are public data accessible
|
|
210
|
+
* to all roles (anon RLS policy: is_active = true).
|
|
211
|
+
*/
|
|
212
|
+
async getModels() {
|
|
213
|
+
const path = '/rest/v1/models?is_active=eq.true&select=slug,display_name,description,media_type,supports_text_to_video,supports_image_to_video,supports_text_to_image,max_duration_seconds,max_resolution,is_active&order=media_type.desc,slug.asc';
|
|
214
|
+
const url = `${this.baseUrl}${path}`;
|
|
215
|
+
const res = await fetch(url, {
|
|
216
|
+
method: 'GET',
|
|
217
|
+
headers: {
|
|
218
|
+
'Content-Type': 'application/json',
|
|
219
|
+
apikey: this.anonKey,
|
|
220
|
+
Authorization: `Bearer ${this.anonKey}`,
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
if (!res.ok) {
|
|
224
|
+
await throwApiError(res, 'Failed to fetch models');
|
|
225
|
+
}
|
|
226
|
+
return (await res.json());
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Fetch pricing information for all models or a specific model.
|
|
230
|
+
*
|
|
231
|
+
* When `modelSlug` is provided, only pricing rows for that model are
|
|
232
|
+
* returned. Otherwise the full pricing table is returned.
|
|
233
|
+
*/
|
|
234
|
+
async getPricing(modelSlug) {
|
|
235
|
+
const path = modelSlug
|
|
236
|
+
? `/functions/v1/pricing?model=${encodeURIComponent(modelSlug)}`
|
|
237
|
+
: '/functions/v1/pricing';
|
|
238
|
+
const res = await this.request('GET', path);
|
|
239
|
+
return (await res.json());
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Fetch a single generation job by ID via the job-status edge function.
|
|
243
|
+
*
|
|
244
|
+
* Uses edge function auth (supports API keys) instead of PostgREST.
|
|
245
|
+
*/
|
|
246
|
+
async getJob(jobId) {
|
|
247
|
+
const res = await this.request('POST', '/functions/v1/job-status', { jobId });
|
|
248
|
+
const job = (await res.json());
|
|
249
|
+
if (!job || !job.id) {
|
|
250
|
+
throw new CLIError(`Job not found: ${jobId}`, {
|
|
251
|
+
code: 'JOB_NOT_FOUND',
|
|
252
|
+
suggestion: 'Check the job ID and try again.',
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return job;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Poll the provider for a job's real status (triggers server-side provider check).
|
|
259
|
+
* Returns the provider-checked status including output_media_url if completed.
|
|
260
|
+
*/
|
|
261
|
+
async pollProvider(jobId) {
|
|
262
|
+
const res = await this.request('POST', '/functions/v1/poll-provider', { jobId });
|
|
263
|
+
return (await res.json());
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Cancel an active job and refund credits.
|
|
267
|
+
*/
|
|
268
|
+
async cancelJob(jobId) {
|
|
269
|
+
const res = await this.request('POST', '/functions/v1/job-status', {
|
|
270
|
+
cancel: true,
|
|
271
|
+
jobId,
|
|
272
|
+
});
|
|
273
|
+
return (await res.json());
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* List generation jobs via the job-status edge function.
|
|
277
|
+
*
|
|
278
|
+
* Uses edge function auth (supports API keys) instead of PostgREST.
|
|
279
|
+
*/
|
|
280
|
+
async listJobs(options) {
|
|
281
|
+
const res = await this.request('POST', '/functions/v1/job-status', {
|
|
282
|
+
list: true,
|
|
283
|
+
limit: options?.limit ?? 20,
|
|
284
|
+
offset: options?.offset ?? 0,
|
|
285
|
+
status: options?.status,
|
|
286
|
+
model: options?.model,
|
|
287
|
+
sort: options?.sort,
|
|
288
|
+
});
|
|
289
|
+
const data = (await res.json());
|
|
290
|
+
return { jobs: data.jobs ?? [], total: data.total ?? 0 };
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Download media from a URL and write it to a local file path.
|
|
294
|
+
*
|
|
295
|
+
* Streams the response body to disk and reports progress via an
|
|
296
|
+
* optional callback. Returns the total number of bytes written.
|
|
297
|
+
*/
|
|
298
|
+
async downloadMedia(url, outputPath, onProgress) {
|
|
299
|
+
const { createWriteStream } = await import('node:fs');
|
|
300
|
+
const { pipeline } = await import('node:stream/promises');
|
|
301
|
+
const { Readable } = await import('node:stream');
|
|
302
|
+
const res = await fetch(url);
|
|
303
|
+
if (!res.ok) {
|
|
304
|
+
throw new CLIError(`Download failed (HTTP ${res.status})`, {
|
|
305
|
+
code: 'DOWNLOAD_FAILED',
|
|
306
|
+
suggestion: 'The media file may have expired. Try re-checking the job status.',
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
const contentLength = res.headers.get('content-length');
|
|
310
|
+
const totalBytes = contentLength ? parseInt(contentLength, 10) : null;
|
|
311
|
+
let receivedBytes = 0;
|
|
312
|
+
if (!res.body) {
|
|
313
|
+
throw new CLIError('Download failed: empty response body', {
|
|
314
|
+
code: 'DOWNLOAD_FAILED',
|
|
315
|
+
suggestion: 'Try again later.',
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
const fileStream = createWriteStream(outputPath);
|
|
319
|
+
// Create a transform that tracks progress
|
|
320
|
+
const reader = res.body.getReader();
|
|
321
|
+
const nodeStream = new Readable({
|
|
322
|
+
async read() {
|
|
323
|
+
const { done, value } = await reader.read();
|
|
324
|
+
if (done) {
|
|
325
|
+
this.push(null);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
receivedBytes += value.byteLength;
|
|
329
|
+
if (onProgress)
|
|
330
|
+
onProgress(receivedBytes, totalBytes);
|
|
331
|
+
this.push(Buffer.from(value));
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
await pipeline(nodeStream, fileStream);
|
|
335
|
+
return receivedBytes;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Retry a failed or canceled generation job.
|
|
339
|
+
*
|
|
340
|
+
* Fetches the original job, verifies it is in a retryable state,
|
|
341
|
+
* then re-submits a new generation with the same parameters.
|
|
342
|
+
* Optional overrides allow changing the prompt or seed.
|
|
343
|
+
* A new idempotency key is generated to ensure a fresh submission.
|
|
344
|
+
*/
|
|
345
|
+
async retryJob(jobId, overrides) {
|
|
346
|
+
const originalJob = await this.getJob(jobId);
|
|
347
|
+
if (originalJob.status !== 'failed' && originalJob.status !== 'canceled') {
|
|
348
|
+
throw new CLIError(`Cannot retry job with status "${originalJob.status}". Only failed or canceled jobs can be retried.`, {
|
|
349
|
+
code: 'INVALID_JOB_STATUS',
|
|
350
|
+
suggestion: `Job ${jobId} is currently ${originalJob.status}. Use 'agent-media status ${jobId}' to check details.`,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
const params = {
|
|
354
|
+
modelSlug: originalJob.model_slug,
|
|
355
|
+
prompt: overrides?.prompt ?? originalJob.prompt,
|
|
356
|
+
duration: originalJob.duration_seconds ?? undefined,
|
|
357
|
+
resolution: originalJob.resolution ?? undefined,
|
|
358
|
+
aspectRatio: originalJob.aspect_ratio ?? undefined,
|
|
359
|
+
seed: overrides?.seed ?? originalJob.seed ?? undefined,
|
|
360
|
+
idempotencyKey: crypto.randomUUID(),
|
|
361
|
+
};
|
|
362
|
+
return (await this.submitGeneration(params));
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Soft-delete a generation job.
|
|
366
|
+
*
|
|
367
|
+
* Calls the gallery-delete edge function. The job is marked as
|
|
368
|
+
* soft-deleted and can be restored within the retention window.
|
|
369
|
+
*/
|
|
370
|
+
async deleteJob(jobId) {
|
|
371
|
+
const res = await this.request('POST', '/functions/v1/gallery-delete', {
|
|
372
|
+
jobId,
|
|
373
|
+
});
|
|
374
|
+
return (await res.json());
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Restore a soft-deleted generation job.
|
|
378
|
+
*
|
|
379
|
+
* Calls the gallery-delete edge function with the restore flag.
|
|
380
|
+
* Returns whether the job was successfully restored.
|
|
381
|
+
*/
|
|
382
|
+
async restoreJob(jobId) {
|
|
383
|
+
const res = await this.request('POST', '/functions/v1/gallery-delete', {
|
|
384
|
+
jobId,
|
|
385
|
+
restore: true,
|
|
386
|
+
});
|
|
387
|
+
return (await res.json());
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Get a presigned download URL for a job's output media or thumbnail.
|
|
391
|
+
*
|
|
392
|
+
* For Supabase Storage files, returns a freshly signed URL with a 1-hour TTL.
|
|
393
|
+
* For external provider-hosted files, returns the URL directly.
|
|
394
|
+
*/
|
|
395
|
+
async getPresignedUrl(jobId, type) {
|
|
396
|
+
const res = await this.request('POST', '/functions/v1/presigned-url', {
|
|
397
|
+
jobId,
|
|
398
|
+
type,
|
|
399
|
+
});
|
|
400
|
+
return (await res.json());
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Fetch the authenticated user's credit transaction history.
|
|
404
|
+
*
|
|
405
|
+
* Uses the PostgREST query syntax on the credit_transactions table.
|
|
406
|
+
* Supports filtering by transaction type and limiting the number of rows.
|
|
407
|
+
* Results are ordered by created_at descending (newest first).
|
|
408
|
+
*/
|
|
409
|
+
async getCreditHistory(options) {
|
|
410
|
+
const limit = options?.limit ?? 20;
|
|
411
|
+
const params = new URLSearchParams();
|
|
412
|
+
params.set('select', 'id,type,amount,plan_credits_after,purchased_credits_after,description,created_at');
|
|
413
|
+
params.set('order', 'created_at.desc');
|
|
414
|
+
params.set('limit', String(limit));
|
|
415
|
+
if (options?.type) {
|
|
416
|
+
params.set('type', `eq.${options.type}`);
|
|
417
|
+
}
|
|
418
|
+
const path = `/rest/v1/credit_transactions?${params.toString()}`;
|
|
419
|
+
const res = await this.request('GET', path);
|
|
420
|
+
return (await res.json());
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* List all active API keys for the authenticated user.
|
|
424
|
+
*
|
|
425
|
+
* Calls the apikey-manage edge function with action "list".
|
|
426
|
+
* Returns key metadata only -- raw key values are never returned after creation.
|
|
427
|
+
*/
|
|
428
|
+
async listApiKeys() {
|
|
429
|
+
const res = await this.request('POST', '/functions/v1/apikey-manage', {
|
|
430
|
+
action: 'list',
|
|
431
|
+
});
|
|
432
|
+
const body = (await res.json());
|
|
433
|
+
return body.keys;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Create a new API key with the given display name.
|
|
437
|
+
*
|
|
438
|
+
* Calls the apikey-manage edge function with action "create".
|
|
439
|
+
* The raw key is returned exactly once -- it cannot be retrieved later.
|
|
440
|
+
*/
|
|
441
|
+
async createApiKey(name) {
|
|
442
|
+
const res = await this.request('POST', '/functions/v1/apikey-manage', {
|
|
443
|
+
action: 'create',
|
|
444
|
+
name,
|
|
445
|
+
});
|
|
446
|
+
return (await res.json());
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Revoke a managed API key by its ID.
|
|
450
|
+
*
|
|
451
|
+
* Calls the apikey-manage edge function with action "revoke".
|
|
452
|
+
* The key is soft-deleted and can no longer be used for authentication.
|
|
453
|
+
*/
|
|
454
|
+
async revokeManagedApiKey(keyId) {
|
|
455
|
+
const res = await this.request('POST', '/functions/v1/apikey-manage', {
|
|
456
|
+
action: 'revoke',
|
|
457
|
+
keyId,
|
|
458
|
+
});
|
|
459
|
+
return (await res.json());
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Get the authenticated user's auto-top-up configuration.
|
|
463
|
+
*
|
|
464
|
+
* Returns the current settings or server-side defaults if none exist.
|
|
465
|
+
*/
|
|
466
|
+
async getAutoTopUpConfig() {
|
|
467
|
+
const res = await this.request('GET', '/functions/v1/auto-topup/config');
|
|
468
|
+
return (await res.json());
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Update the authenticated user's auto-top-up configuration.
|
|
472
|
+
*
|
|
473
|
+
* Accepts partial updates -- only provided fields are changed.
|
|
474
|
+
* Returns the full updated configuration.
|
|
475
|
+
*/
|
|
476
|
+
async updateAutoTopUpConfig(config) {
|
|
477
|
+
const res = await this.request('PUT', '/functions/v1/auto-topup/config', config);
|
|
478
|
+
return (await res.json());
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Fetch usage statistics for the authenticated user.
|
|
482
|
+
*
|
|
483
|
+
* Calls the usage-stats edge function with an optional period parameter.
|
|
484
|
+
* Returns aggregated summaries, per-model breakdowns, daily trends,
|
|
485
|
+
* and per-operation distributions.
|
|
486
|
+
*/
|
|
487
|
+
async getUsageStats(period) {
|
|
488
|
+
const queryPeriod = period ?? '30d';
|
|
489
|
+
const path = `/functions/v1/usage-stats?period=${encodeURIComponent(queryPeriod)}`;
|
|
490
|
+
const res = await this.request('GET', path);
|
|
491
|
+
return (await res.json());
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Fetch debug information for a specific generation job.
|
|
495
|
+
*
|
|
496
|
+
* Returns the job record, associated credit transactions,
|
|
497
|
+
* webhook delivery history, and any dead-letter entries for
|
|
498
|
+
* troubleshooting failed or stuck jobs.
|
|
499
|
+
*/
|
|
500
|
+
async getJobDebugInfo(jobId) {
|
|
501
|
+
const res = await this.request('POST', '/functions/v1/health-status', {
|
|
502
|
+
action: 'debug_job',
|
|
503
|
+
jobId,
|
|
504
|
+
});
|
|
505
|
+
return (await res.json());
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Fetch credit debug information for the authenticated user.
|
|
509
|
+
*
|
|
510
|
+
* Returns the current balance, full transaction history, and
|
|
511
|
+
* reconciliation status comparing the expected balance (computed
|
|
512
|
+
* from transaction log) against the actual stored balance.
|
|
513
|
+
*/
|
|
514
|
+
async getCreditDebugInfo() {
|
|
515
|
+
const res = await this.request('POST', '/functions/v1/health-status', {
|
|
516
|
+
action: 'debug_credits',
|
|
517
|
+
});
|
|
518
|
+
return (await res.json());
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Send an authenticated request to the API.
|
|
522
|
+
*/
|
|
523
|
+
async request(method, path, body) {
|
|
524
|
+
const url = `${this.baseUrl}${path}`;
|
|
525
|
+
const headers = {
|
|
526
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
527
|
+
'Content-Type': 'application/json',
|
|
528
|
+
};
|
|
529
|
+
if (this.anonKey) {
|
|
530
|
+
headers['apikey'] = this.anonKey;
|
|
531
|
+
}
|
|
532
|
+
const init = { method, headers };
|
|
533
|
+
if (body !== undefined) {
|
|
534
|
+
init.body = JSON.stringify(body);
|
|
535
|
+
}
|
|
536
|
+
const res = await fetch(url, init);
|
|
537
|
+
if (!res.ok) {
|
|
538
|
+
await throwApiError(res, `API request failed: ${method} ${path}`);
|
|
539
|
+
}
|
|
540
|
+
return res;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Parse an error response from the API and throw a CLIError.
|
|
545
|
+
*/
|
|
546
|
+
async function throwApiError(res, fallbackMessage) {
|
|
547
|
+
let message = fallbackMessage;
|
|
548
|
+
let code = `HTTP_${res.status}`;
|
|
549
|
+
let suggestion;
|
|
550
|
+
try {
|
|
551
|
+
const body = (await res.json());
|
|
552
|
+
if (body.error)
|
|
553
|
+
message = body.error;
|
|
554
|
+
if (body.code)
|
|
555
|
+
code = body.code;
|
|
556
|
+
if (body.suggestion)
|
|
557
|
+
suggestion = body.suggestion;
|
|
558
|
+
}
|
|
559
|
+
catch {
|
|
560
|
+
// Response body was not JSON -- use fallback
|
|
561
|
+
}
|
|
562
|
+
if (res.status === 401) {
|
|
563
|
+
throw new CLIError(message, {
|
|
564
|
+
code: 'AUTH_UNAUTHORIZED',
|
|
565
|
+
suggestion: 'Run `agent-media login` to authenticate.',
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
if (res.status === 402) {
|
|
569
|
+
throw new CLIError(message, {
|
|
570
|
+
code: 'INSUFFICIENT_CREDITS',
|
|
571
|
+
suggestion: 'Buy credits at https://agent-media.ai/billing',
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
if (res.status === 429) {
|
|
575
|
+
throw new CLIError(message, {
|
|
576
|
+
code: 'RATE_LIMITED',
|
|
577
|
+
suggestion: 'Wait a moment and try again, or upgrade your plan.',
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
throw new CLIError(message, { code, suggestion });
|
|
581
|
+
}
|
|
582
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAAA,+DAA+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C/C,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE;YAC1B,IAAI,EAAE,mBAAmB;YACzB,UAAU,EAAE,0CAA0C;SACvD,CAAC,CAAC;IACL,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE;YAC1B,IAAI,EAAE,sBAAsB;YAC5B,UAAU,EAAE,+CAA+C;SAC5D,CAAC,CAAC;IACL,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE;YAC1B,IAAI,EAAE,cAAc;YACpB,UAAU,EAAE,oDAAoD;SACjE,CAAC,CAAC;IACL,CAAC;IAED,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const CONFIG_DIR: string;
|
|
2
|
+
export declare const CONFIG_FILE: string;
|
|
3
|
+
export type ConfigData = Record<string, unknown>;
|
|
4
|
+
/** All recognized configuration keys. */
|
|
5
|
+
export declare const VALID_CONFIG_KEYS: readonly ["api_url", "output_format", "default_model", "auto_open_browser", "download_dir"];
|
|
6
|
+
export type ConfigKey = (typeof VALID_CONFIG_KEYS)[number];
|
|
7
|
+
/** Default values for configuration keys. */
|
|
8
|
+
export declare const CONFIG_DEFAULTS: Partial<Record<ConfigKey, unknown>>;
|
|
9
|
+
/**
|
|
10
|
+
* Check whether a string is a valid configuration key.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isValidConfigKey(key: string): key is ConfigKey;
|
|
13
|
+
/**
|
|
14
|
+
* Load the config file. Returns an empty object if it does not exist.
|
|
15
|
+
*/
|
|
16
|
+
export declare function loadConfig(): ConfigData;
|
|
17
|
+
/**
|
|
18
|
+
* Save the config object to disk.
|
|
19
|
+
*/
|
|
20
|
+
export declare function saveConfig(config: ConfigData): void;
|
|
21
|
+
/**
|
|
22
|
+
* Get a single config value by key.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getConfigValue(key: string): unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Set a single config value and persist to disk.
|
|
27
|
+
*/
|
|
28
|
+
export declare function setConfigValue(key: string, value: unknown): void;
|
|
29
|
+
/**
|
|
30
|
+
* Reset the config file by removing it entirely, restoring defaults.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resetConfig(): void;
|
|
33
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,UAAU,QAA2E,CAAC;AACnG,eAAO,MAAM,WAAW,QAAkC,CAAC;AAE3D,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,yCAAyC;AACzC,eAAO,MAAM,iBAAiB,6FAMpB,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,6CAA6C;AAC7C,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAG/D,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,SAAS,CAE9D;AAWD;;GAEG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAUvC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAGnD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAIhE;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAIlC"}
|