@tangle-network/tcloud 0.1.2 → 0.1.4
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/dist/{chunk-FL352XGA.js → chunk-KVXWEAK3.js} +204 -6
- package/dist/{chunk-76AB7HOV.js → chunk-PILYAKCF.js} +1 -1
- package/dist/cli.cjs +204 -6
- package/dist/cli.js +2 -2
- package/dist/index.cjs +204 -6
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{shielded-6uJexMiT.d.cts → shielded-BTi_OftW.d.cts} +173 -3
- package/dist/{shielded-6uJexMiT.d.ts → shielded-BTi_OftW.d.ts} +173 -3
- package/dist/shielded.cjs +204 -6
- package/dist/shielded.d.cts +1 -1
- package/dist/shielded.d.ts +1 -1
- package/dist/shielded.js +1 -1
- package/package.json +1 -1
|
@@ -38,8 +38,14 @@ interface SpendingLimits {
|
|
|
38
38
|
}) => void;
|
|
39
39
|
}
|
|
40
40
|
interface RoutingConfig {
|
|
41
|
-
/**
|
|
41
|
+
/** Routing mode: 'operator' (Tangle operators only), 'provider' (direct APIs only), 'auto' (try operators, fall back to providers) */
|
|
42
|
+
mode?: 'operator' | 'provider' | 'auto';
|
|
43
|
+
/** Preferred operator slug or address */
|
|
42
44
|
prefer?: string;
|
|
45
|
+
/** Blueprint ID — route to operators under this Blueprint */
|
|
46
|
+
blueprintId?: string;
|
|
47
|
+
/** Service instance ID — route to a specific service instance */
|
|
48
|
+
serviceId?: string;
|
|
43
49
|
/** Routing strategy */
|
|
44
50
|
strategy?: 'lowest-latency' | 'lowest-price' | 'highest-reputation' | 'round-robin';
|
|
45
51
|
/** Region filter */
|
|
@@ -47,6 +53,136 @@ interface RoutingConfig {
|
|
|
47
53
|
/** Fallback operator slugs (tried in order) */
|
|
48
54
|
fallback?: string[];
|
|
49
55
|
}
|
|
56
|
+
interface EmbeddingOptions {
|
|
57
|
+
model?: string;
|
|
58
|
+
input: string | string[];
|
|
59
|
+
}
|
|
60
|
+
interface EmbeddingResponse {
|
|
61
|
+
object: string;
|
|
62
|
+
data: {
|
|
63
|
+
object: string;
|
|
64
|
+
embedding: number[];
|
|
65
|
+
index: number;
|
|
66
|
+
}[];
|
|
67
|
+
model: string;
|
|
68
|
+
usage: {
|
|
69
|
+
prompt_tokens: number;
|
|
70
|
+
total_tokens: number;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
interface ImageGenerateOptions {
|
|
74
|
+
model?: string;
|
|
75
|
+
prompt: string;
|
|
76
|
+
n?: number;
|
|
77
|
+
size?: string;
|
|
78
|
+
quality?: string;
|
|
79
|
+
response_format?: 'url' | 'b64_json';
|
|
80
|
+
}
|
|
81
|
+
interface ImageResponse {
|
|
82
|
+
created: number;
|
|
83
|
+
data: {
|
|
84
|
+
url?: string;
|
|
85
|
+
b64_json?: string;
|
|
86
|
+
revised_prompt?: string;
|
|
87
|
+
}[];
|
|
88
|
+
}
|
|
89
|
+
interface RerankOptions {
|
|
90
|
+
model?: string;
|
|
91
|
+
query: string;
|
|
92
|
+
documents: string[];
|
|
93
|
+
top_n?: number;
|
|
94
|
+
}
|
|
95
|
+
interface RerankResponse {
|
|
96
|
+
results: {
|
|
97
|
+
index: number;
|
|
98
|
+
relevance_score: number;
|
|
99
|
+
}[];
|
|
100
|
+
}
|
|
101
|
+
interface CompletionOptions {
|
|
102
|
+
model?: string;
|
|
103
|
+
prompt: string;
|
|
104
|
+
temperature?: number;
|
|
105
|
+
maxTokens?: number;
|
|
106
|
+
stop?: string | string[];
|
|
107
|
+
topP?: number;
|
|
108
|
+
}
|
|
109
|
+
interface CompletionResponse {
|
|
110
|
+
id: string;
|
|
111
|
+
object: string;
|
|
112
|
+
created: number;
|
|
113
|
+
model: string;
|
|
114
|
+
choices: {
|
|
115
|
+
text: string;
|
|
116
|
+
index: number;
|
|
117
|
+
finish_reason: string;
|
|
118
|
+
}[];
|
|
119
|
+
usage?: {
|
|
120
|
+
prompt_tokens: number;
|
|
121
|
+
completion_tokens: number;
|
|
122
|
+
total_tokens: number;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
interface TranscriptionResponse {
|
|
126
|
+
text: string;
|
|
127
|
+
}
|
|
128
|
+
interface FineTuningJobOptions {
|
|
129
|
+
model: string;
|
|
130
|
+
training_file: string;
|
|
131
|
+
hyperparameters?: {
|
|
132
|
+
n_epochs?: number | 'auto';
|
|
133
|
+
batch_size?: number | 'auto';
|
|
134
|
+
learning_rate_multiplier?: number | 'auto';
|
|
135
|
+
};
|
|
136
|
+
suffix?: string;
|
|
137
|
+
}
|
|
138
|
+
interface FineTuningJob {
|
|
139
|
+
id: string;
|
|
140
|
+
object: string;
|
|
141
|
+
model: string;
|
|
142
|
+
status: string;
|
|
143
|
+
created_at: number;
|
|
144
|
+
finished_at: number | null;
|
|
145
|
+
fine_tuned_model: string | null;
|
|
146
|
+
error: {
|
|
147
|
+
code: string;
|
|
148
|
+
message: string;
|
|
149
|
+
} | null;
|
|
150
|
+
}
|
|
151
|
+
interface BatchRequest {
|
|
152
|
+
model: string;
|
|
153
|
+
messages: ChatMessage[];
|
|
154
|
+
temperature?: number;
|
|
155
|
+
max_tokens?: number;
|
|
156
|
+
}
|
|
157
|
+
interface BatchJobResponse {
|
|
158
|
+
id: string;
|
|
159
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
160
|
+
total_items: number;
|
|
161
|
+
completed: number;
|
|
162
|
+
failed: number;
|
|
163
|
+
results: ({
|
|
164
|
+
status: 'fulfilled';
|
|
165
|
+
data: ChatCompletion;
|
|
166
|
+
} | {
|
|
167
|
+
status: 'rejected';
|
|
168
|
+
error: string;
|
|
169
|
+
})[] | null;
|
|
170
|
+
error: string | null;
|
|
171
|
+
created_at: string;
|
|
172
|
+
completed_at: string | null;
|
|
173
|
+
}
|
|
174
|
+
interface VideoGenerateOptions {
|
|
175
|
+
model?: string;
|
|
176
|
+
prompt: string;
|
|
177
|
+
duration?: number;
|
|
178
|
+
resolution?: string;
|
|
179
|
+
}
|
|
180
|
+
interface VideoResponse {
|
|
181
|
+
id: string;
|
|
182
|
+
status: string;
|
|
183
|
+
url?: string;
|
|
184
|
+
error?: string;
|
|
185
|
+
}
|
|
50
186
|
interface PrivacyConfig {
|
|
51
187
|
/** 'direct' — no proxy (default). 'relayer' — route through tcloud-relayer. 'socks5' — route through SOCKS5 proxy (e.g. Tor). */
|
|
52
188
|
mode: 'direct' | 'relayer' | 'socks5';
|
|
@@ -225,7 +361,7 @@ declare class TCloudClient {
|
|
|
225
361
|
};
|
|
226
362
|
/** Check spending limits before a request. Throws TCloudError if blocked. */
|
|
227
363
|
private checkLimits;
|
|
228
|
-
/** Track cost after a response */
|
|
364
|
+
/** Track cost after a response, using actual pricing from response headers when available */
|
|
229
365
|
private trackCost;
|
|
230
366
|
/** Chat completion (non-streaming) */
|
|
231
367
|
chat(options: ChatOptions): Promise<ChatCompletion>;
|
|
@@ -265,6 +401,40 @@ declare class TCloudClient {
|
|
|
265
401
|
}[]>;
|
|
266
402
|
/** Revoke an API key */
|
|
267
403
|
revokeKey(id: string): Promise<void>;
|
|
404
|
+
/** Generate embeddings */
|
|
405
|
+
embeddings(options: EmbeddingOptions): Promise<EmbeddingResponse>;
|
|
406
|
+
/** Generate images */
|
|
407
|
+
imageGenerate(options: ImageGenerateOptions): Promise<ImageResponse>;
|
|
408
|
+
/** Rerank documents by relevance to a query */
|
|
409
|
+
rerank(options: RerankOptions): Promise<RerankResponse>;
|
|
410
|
+
/** Text-to-speech */
|
|
411
|
+
speech(options: {
|
|
412
|
+
model?: string;
|
|
413
|
+
input: string;
|
|
414
|
+
voice?: string;
|
|
415
|
+
}): Promise<ArrayBuffer>;
|
|
416
|
+
/** Legacy completions endpoint */
|
|
417
|
+
completions(options: CompletionOptions): Promise<CompletionResponse>;
|
|
418
|
+
/** Audio transcription (speech-to-text) */
|
|
419
|
+
transcribe(file: Blob, options?: {
|
|
420
|
+
model?: string;
|
|
421
|
+
language?: string;
|
|
422
|
+
prompt?: string;
|
|
423
|
+
}): Promise<TranscriptionResponse>;
|
|
424
|
+
/** Create a fine-tuning job */
|
|
425
|
+
fineTuneCreate(options: FineTuningJobOptions): Promise<FineTuningJob>;
|
|
426
|
+
/** List fine-tuning jobs */
|
|
427
|
+
fineTuneList(): Promise<{
|
|
428
|
+
data: FineTuningJob[];
|
|
429
|
+
}>;
|
|
430
|
+
/** Submit a batch of chat requests */
|
|
431
|
+
batch(requests: BatchRequest[]): Promise<BatchJobResponse>;
|
|
432
|
+
/** Get batch job status */
|
|
433
|
+
batchStatus(jobId: string): Promise<BatchJobResponse>;
|
|
434
|
+
/** Generate video */
|
|
435
|
+
videoGenerate(options: VideoGenerateOptions): Promise<VideoResponse>;
|
|
436
|
+
/** Get video generation status */
|
|
437
|
+
videoStatus(id: string): Promise<VideoResponse>;
|
|
268
438
|
/** Search models by name, provider, or capability */
|
|
269
439
|
searchModels(query: string): Promise<Model[]>;
|
|
270
440
|
/** Estimate cost for a request (without sending it) */
|
|
@@ -340,4 +510,4 @@ declare function createShieldedClient(config?: TCloudConfig & {
|
|
|
340
510
|
stopAutoReplenish: () => void;
|
|
341
511
|
};
|
|
342
512
|
|
|
343
|
-
export { type AutoReplenishOptions as A, type ChatCompletion as C, type Model as M, type Operator as O, type PrivacyConfig as P, type
|
|
513
|
+
export { type AutoReplenishOptions as A, type BatchJobResponse as B, type ChatCompletion as C, type EmbeddingOptions as E, type FineTuningJob as F, type ImageGenerateOptions as I, type Model as M, type Operator as O, type PrivacyConfig as P, type RerankOptions as R, type ShieldedWallet as S, TCloudClient as T, type VideoGenerateOptions as V, type TCloudConfig as a, type BatchRequest as b, type ChatCompletionChunk as c, type ChatMessage as d, type ChatOptions as e, type CompletionOptions as f, generateWallet as g, type CompletionResponse as h, type CreditBalance as i, type EmbeddingResponse as j, type FineTuningJobOptions as k, type ImageResponse as l, type RerankResponse as m, type RoutingConfig as n, type ShieldedConfig as o, type SpendAuth as p, type SpendingLimits as q, TCloudError as r, type TranscriptionResponse as s, type VideoResponse as t, createShieldedClient as u, estimateCost as v, signSpendAuth as w };
|
package/dist/shielded.cjs
CHANGED
|
@@ -97,14 +97,23 @@ var TCloudClient = class {
|
|
|
97
97
|
this.limits = config.limits;
|
|
98
98
|
this.headers = {
|
|
99
99
|
"Content-Type": "application/json",
|
|
100
|
-
"X-Tangle-Client": "tcloud-sdk/0.1.
|
|
100
|
+
"X-Tangle-Client": "tcloud-sdk/0.1.4"
|
|
101
101
|
};
|
|
102
102
|
if (this.apiKey) {
|
|
103
103
|
this.headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
104
104
|
}
|
|
105
|
+
if (config.routing?.mode) {
|
|
106
|
+
this.headers["X-Tangle-Routing"] = config.routing.mode;
|
|
107
|
+
}
|
|
105
108
|
if (config.routing?.prefer) {
|
|
106
109
|
this.headers["X-Tangle-Operator"] = config.routing.prefer;
|
|
107
110
|
}
|
|
111
|
+
if (config.routing?.blueprintId) {
|
|
112
|
+
this.headers["X-Tangle-Blueprint"] = config.routing.blueprintId;
|
|
113
|
+
}
|
|
114
|
+
if (config.routing?.serviceId) {
|
|
115
|
+
this.headers["X-Tangle-Service"] = config.routing.serviceId;
|
|
116
|
+
}
|
|
108
117
|
if (config.routing?.region) {
|
|
109
118
|
this.headers["X-Tangle-Region"] = config.routing.region;
|
|
110
119
|
}
|
|
@@ -141,12 +150,19 @@ var TCloudClient = class {
|
|
|
141
150
|
if (pct >= 0.8) this.limits.onLimitWarning({ type: "total", current: this._totalSpent, limit: this.limits.maxTotalSpend });
|
|
142
151
|
}
|
|
143
152
|
}
|
|
144
|
-
/** Track cost after a response */
|
|
145
|
-
trackCost(completion) {
|
|
153
|
+
/** Track cost after a response, using actual pricing from response headers when available */
|
|
154
|
+
trackCost(completion, res) {
|
|
146
155
|
this._requestCount++;
|
|
147
156
|
if (completion.usage) {
|
|
148
|
-
|
|
149
|
-
const
|
|
157
|
+
let estimatedCost;
|
|
158
|
+
const inputPrice = res ? parseFloat(res.headers.get("x-tangle-price-input") || "0") : 0;
|
|
159
|
+
const outputPrice = res ? parseFloat(res.headers.get("x-tangle-price-output") || "0") : 0;
|
|
160
|
+
if (inputPrice > 0 || outputPrice > 0) {
|
|
161
|
+
estimatedCost = (completion.usage.prompt_tokens || 0) * inputPrice + (completion.usage.completion_tokens || 0) * outputPrice;
|
|
162
|
+
} else {
|
|
163
|
+
const tokens = completion.usage.total_tokens || 0;
|
|
164
|
+
estimatedCost = tokens * 1e-6;
|
|
165
|
+
}
|
|
150
166
|
this._totalSpent += estimatedCost;
|
|
151
167
|
if (this.limits?.maxCostPerRequest && estimatedCost > this.limits.maxCostPerRequest) {
|
|
152
168
|
this.limits.onLimitReached?.({ type: "cost", current: estimatedCost, limit: this.limits.maxCostPerRequest });
|
|
@@ -184,7 +200,7 @@ var TCloudClient = class {
|
|
|
184
200
|
throw new TCloudError(res.status, err.error?.message || err.error || err.message || res.statusText);
|
|
185
201
|
}
|
|
186
202
|
const completion = await res.json();
|
|
187
|
-
this.trackCost(completion);
|
|
203
|
+
this.trackCost(completion, res);
|
|
188
204
|
return completion;
|
|
189
205
|
}
|
|
190
206
|
/** Chat completion (streaming) — returns an async iterator of chunks */
|
|
@@ -323,6 +339,188 @@ var TCloudClient = class {
|
|
|
323
339
|
}, false);
|
|
324
340
|
if (!res.ok) throw new TCloudError(res.status, "Failed to revoke key");
|
|
325
341
|
}
|
|
342
|
+
/** Generate embeddings */
|
|
343
|
+
async embeddings(options) {
|
|
344
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/embeddings`, {
|
|
345
|
+
method: "POST",
|
|
346
|
+
headers: this.headers,
|
|
347
|
+
body: JSON.stringify({
|
|
348
|
+
model: options.model || "text-embedding-3-small",
|
|
349
|
+
input: options.input
|
|
350
|
+
})
|
|
351
|
+
}, false);
|
|
352
|
+
if (!res.ok) {
|
|
353
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
354
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
355
|
+
}
|
|
356
|
+
this._requestCount++;
|
|
357
|
+
return res.json();
|
|
358
|
+
}
|
|
359
|
+
/** Generate images */
|
|
360
|
+
async imageGenerate(options) {
|
|
361
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/images/generations`, {
|
|
362
|
+
method: "POST",
|
|
363
|
+
headers: this.headers,
|
|
364
|
+
body: JSON.stringify({
|
|
365
|
+
model: options.model || "dall-e-3",
|
|
366
|
+
prompt: options.prompt,
|
|
367
|
+
n: options.n,
|
|
368
|
+
size: options.size,
|
|
369
|
+
quality: options.quality,
|
|
370
|
+
response_format: options.response_format
|
|
371
|
+
})
|
|
372
|
+
}, false);
|
|
373
|
+
if (!res.ok) {
|
|
374
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
375
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
376
|
+
}
|
|
377
|
+
this._requestCount++;
|
|
378
|
+
return res.json();
|
|
379
|
+
}
|
|
380
|
+
/** Rerank documents by relevance to a query */
|
|
381
|
+
async rerank(options) {
|
|
382
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/rerank`, {
|
|
383
|
+
method: "POST",
|
|
384
|
+
headers: this.headers,
|
|
385
|
+
body: JSON.stringify({
|
|
386
|
+
model: options.model || "rerank-english-v3.0",
|
|
387
|
+
query: options.query,
|
|
388
|
+
documents: options.documents,
|
|
389
|
+
top_n: options.top_n
|
|
390
|
+
})
|
|
391
|
+
}, false);
|
|
392
|
+
if (!res.ok) {
|
|
393
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
394
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
395
|
+
}
|
|
396
|
+
this._requestCount++;
|
|
397
|
+
return res.json();
|
|
398
|
+
}
|
|
399
|
+
/** Text-to-speech */
|
|
400
|
+
async speech(options) {
|
|
401
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/audio/speech`, {
|
|
402
|
+
method: "POST",
|
|
403
|
+
headers: this.headers,
|
|
404
|
+
body: JSON.stringify({
|
|
405
|
+
model: options.model || "tts-1",
|
|
406
|
+
input: options.input,
|
|
407
|
+
voice: options.voice || "alloy"
|
|
408
|
+
})
|
|
409
|
+
}, false);
|
|
410
|
+
if (!res.ok) {
|
|
411
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
412
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
413
|
+
}
|
|
414
|
+
this._requestCount++;
|
|
415
|
+
return res.arrayBuffer();
|
|
416
|
+
}
|
|
417
|
+
/** Legacy completions endpoint */
|
|
418
|
+
async completions(options) {
|
|
419
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/completions`, {
|
|
420
|
+
method: "POST",
|
|
421
|
+
headers: this.headers,
|
|
422
|
+
body: JSON.stringify({
|
|
423
|
+
model: options.model || this.model,
|
|
424
|
+
prompt: options.prompt,
|
|
425
|
+
temperature: options.temperature,
|
|
426
|
+
max_tokens: options.maxTokens,
|
|
427
|
+
stop: options.stop,
|
|
428
|
+
top_p: options.topP
|
|
429
|
+
})
|
|
430
|
+
}, false);
|
|
431
|
+
if (!res.ok) {
|
|
432
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
433
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
434
|
+
}
|
|
435
|
+
this._requestCount++;
|
|
436
|
+
return res.json();
|
|
437
|
+
}
|
|
438
|
+
/** Audio transcription (speech-to-text) */
|
|
439
|
+
async transcribe(file, options) {
|
|
440
|
+
const formData = new FormData();
|
|
441
|
+
formData.append("file", file, "audio.webm");
|
|
442
|
+
formData.append("model", options?.model || "whisper-1");
|
|
443
|
+
if (options?.language) formData.append("language", options.language);
|
|
444
|
+
if (options?.prompt) formData.append("prompt", options.prompt);
|
|
445
|
+
const headers = { ...this.headers };
|
|
446
|
+
delete headers["Content-Type"];
|
|
447
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/audio/transcriptions`, {
|
|
448
|
+
method: "POST",
|
|
449
|
+
headers,
|
|
450
|
+
body: formData
|
|
451
|
+
}, false);
|
|
452
|
+
if (!res.ok) {
|
|
453
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
454
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
455
|
+
}
|
|
456
|
+
this._requestCount++;
|
|
457
|
+
return res.json();
|
|
458
|
+
}
|
|
459
|
+
/** Create a fine-tuning job */
|
|
460
|
+
async fineTuneCreate(options) {
|
|
461
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/fine_tuning/jobs`, {
|
|
462
|
+
method: "POST",
|
|
463
|
+
headers: this.headers,
|
|
464
|
+
body: JSON.stringify(options)
|
|
465
|
+
}, false);
|
|
466
|
+
if (!res.ok) {
|
|
467
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
468
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
469
|
+
}
|
|
470
|
+
this._requestCount++;
|
|
471
|
+
return res.json();
|
|
472
|
+
}
|
|
473
|
+
/** List fine-tuning jobs */
|
|
474
|
+
async fineTuneList() {
|
|
475
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/fine_tuning/jobs`, {
|
|
476
|
+
headers: this.headers
|
|
477
|
+
}, false);
|
|
478
|
+
if (!res.ok) throw new TCloudError(res.status, "Failed to fetch fine-tuning jobs");
|
|
479
|
+
return res.json();
|
|
480
|
+
}
|
|
481
|
+
/** Submit a batch of chat requests */
|
|
482
|
+
async batch(requests) {
|
|
483
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/batch`, {
|
|
484
|
+
method: "POST",
|
|
485
|
+
headers: this.headers,
|
|
486
|
+
body: JSON.stringify({ requests })
|
|
487
|
+
}, false);
|
|
488
|
+
if (!res.ok) {
|
|
489
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
490
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
491
|
+
}
|
|
492
|
+
return res.json();
|
|
493
|
+
}
|
|
494
|
+
/** Get batch job status */
|
|
495
|
+
async batchStatus(jobId) {
|
|
496
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/batch?id=${jobId}`, {
|
|
497
|
+
headers: this.headers
|
|
498
|
+
}, false);
|
|
499
|
+
if (!res.ok) throw new TCloudError(res.status, "Failed to fetch batch status");
|
|
500
|
+
return res.json();
|
|
501
|
+
}
|
|
502
|
+
/** Generate video */
|
|
503
|
+
async videoGenerate(options) {
|
|
504
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/video/generate`, {
|
|
505
|
+
method: "POST",
|
|
506
|
+
headers: this.headers,
|
|
507
|
+
body: JSON.stringify(options)
|
|
508
|
+
}, false);
|
|
509
|
+
if (!res.ok) {
|
|
510
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
511
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
512
|
+
}
|
|
513
|
+
this._requestCount++;
|
|
514
|
+
return res.json();
|
|
515
|
+
}
|
|
516
|
+
/** Get video generation status */
|
|
517
|
+
async videoStatus(id) {
|
|
518
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/video?id=${id}`, {
|
|
519
|
+
headers: this.headers
|
|
520
|
+
}, false);
|
|
521
|
+
if (!res.ok) throw new TCloudError(res.status, "Failed to fetch video status");
|
|
522
|
+
return res.json();
|
|
523
|
+
}
|
|
326
524
|
/** Search models by name, provider, or capability */
|
|
327
525
|
async searchModels(query) {
|
|
328
526
|
const all = await this.models();
|
package/dist/shielded.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import 'viem';
|
|
2
|
-
export { A as AutoReplenishOptions, S as ShieldedWallet,
|
|
2
|
+
export { A as AutoReplenishOptions, S as ShieldedWallet, p as SpendAuth, u as createShieldedClient, v as estimateCost, g as generateWallet, w as signSpendAuth } from './shielded-BTi_OftW.cjs';
|
package/dist/shielded.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import 'viem';
|
|
2
|
-
export { A as AutoReplenishOptions, S as ShieldedWallet,
|
|
2
|
+
export { A as AutoReplenishOptions, S as ShieldedWallet, p as SpendAuth, u as createShieldedClient, v as estimateCost, g as generateWallet, w as signSpendAuth } from './shielded-BTi_OftW.js';
|
package/dist/shielded.js
CHANGED