@teinai/cli 1.1.10 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/index.js +859 -811
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var
|
|
3
|
+
var Yt = Object.create;
|
|
4
|
+
var fe = Object.defineProperty;
|
|
5
|
+
var Qt = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var Xt = Object.getOwnPropertyNames;
|
|
7
|
+
var Zt = Object.getPrototypeOf,
|
|
8
|
+
ei = Object.prototype.hasOwnProperty;
|
|
9
|
+
var b = (e, t, i) => () => {
|
|
10
10
|
if (i) throw i[0];
|
|
11
11
|
try {
|
|
12
12
|
return (e && (t = e((e = 0))), t);
|
|
@@ -14,94 +14,94 @@ var y = (e, t, i) => () => {
|
|
|
14
14
|
throw ((i = [r]), r);
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
var
|
|
18
|
-
for (var i in t)
|
|
17
|
+
var ti = (e, t) => {
|
|
18
|
+
for (var i in t) fe(e, i, { get: t[i], enumerable: !0 });
|
|
19
19
|
},
|
|
20
|
-
|
|
20
|
+
ii = (e, t, i, r) => {
|
|
21
21
|
if ((t && typeof t == 'object') || typeof t == 'function')
|
|
22
|
-
for (let n of
|
|
23
|
-
!
|
|
22
|
+
for (let n of Xt(t))
|
|
23
|
+
!ei.call(e, n) &&
|
|
24
24
|
n !== i &&
|
|
25
|
-
|
|
25
|
+
fe(e, n, { get: () => t[n], enumerable: !(r = Qt(t, n)) || r.enumerable });
|
|
26
26
|
return e;
|
|
27
27
|
};
|
|
28
|
-
var
|
|
29
|
-
(i = e != null ?
|
|
30
|
-
|
|
28
|
+
var I = (e, t, i) => (
|
|
29
|
+
(i = e != null ? Yt(Zt(e)) : {}),
|
|
30
|
+
ii(t || !e || !e.__esModule ? fe(i, 'default', { value: e, enumerable: !0 }) : i, e)
|
|
31
31
|
);
|
|
32
|
-
function
|
|
32
|
+
function L() {
|
|
33
33
|
try {
|
|
34
|
-
if (
|
|
35
|
-
let e =
|
|
34
|
+
if (C.default.existsSync(D)) {
|
|
35
|
+
let e = C.default.readFileSync(D, 'utf-8');
|
|
36
36
|
return JSON.parse(e);
|
|
37
37
|
}
|
|
38
38
|
} catch {}
|
|
39
39
|
return {};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function he(e) {
|
|
42
42
|
try {
|
|
43
|
-
|
|
44
|
-
let i = { ...
|
|
45
|
-
(
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
C.default.existsSync(te) || C.default.mkdirSync(te, { recursive: !0, mode: 448 });
|
|
44
|
+
let i = { ...L(), ...e };
|
|
45
|
+
(C.default.writeFileSync(D, JSON.stringify(i, null, 2), { encoding: 'utf-8', mode: 384 }),
|
|
46
|
+
C.default.chmodSync(te, 448),
|
|
47
|
+
C.default.chmodSync(D, 384));
|
|
48
48
|
} catch (t) {
|
|
49
|
-
throw new Error(`Failed to save config to ${
|
|
49
|
+
throw new Error(`Failed to save config to ${D}: ${t}`);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function S(e) {
|
|
53
53
|
if (e && e.trim()) return e.trim();
|
|
54
54
|
let t = process.env.TEIN_API_KEY || process.env.TEIN_KEY;
|
|
55
55
|
if (t && t.trim()) return t.trim();
|
|
56
|
-
let i =
|
|
56
|
+
let i = L();
|
|
57
57
|
return i.apiKey && i.apiKey.trim() ? i.apiKey.trim() : '';
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function x(e) {
|
|
60
60
|
if (e && e.trim()) return e.trim().replace(/\/+$/, '');
|
|
61
61
|
let t = process.env.TEIN_API_URL;
|
|
62
62
|
if (t && t.trim()) return t.trim().replace(/\/+$/, '');
|
|
63
|
-
let i =
|
|
63
|
+
let i = L();
|
|
64
64
|
return i.apiUrl && i.apiUrl.trim() ? i.apiUrl.trim().replace(/\/+$/, '') : 'https://api.tein.ai';
|
|
65
65
|
}
|
|
66
66
|
function ie() {
|
|
67
|
-
return
|
|
67
|
+
return D;
|
|
68
68
|
}
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
var C,
|
|
70
|
+
Je,
|
|
71
|
+
ge,
|
|
72
72
|
te,
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
D,
|
|
74
|
+
E = b(() => {
|
|
75
75
|
'use strict';
|
|
76
|
-
((
|
|
77
|
-
(
|
|
78
|
-
(
|
|
79
|
-
(te =
|
|
80
|
-
(
|
|
76
|
+
((C = I(require('node:fs'))),
|
|
77
|
+
(Je = I(require('node:os'))),
|
|
78
|
+
(ge = I(require('node:path'))),
|
|
79
|
+
(te = ge.default.join(Je.default.homedir(), '.tein')),
|
|
80
|
+
(D = ge.default.join(te, 'config.json')));
|
|
81
81
|
});
|
|
82
|
-
var
|
|
83
|
-
Je,
|
|
82
|
+
var li,
|
|
84
83
|
He,
|
|
85
|
-
|
|
84
|
+
ze,
|
|
85
|
+
We = b(() => {
|
|
86
86
|
'use strict';
|
|
87
|
-
((
|
|
88
|
-
(
|
|
89
|
-
(
|
|
87
|
+
((li = ['1:1', '16:9', '9:16', '21:9', '3:2', '2:3', '4:3', '3:4']),
|
|
88
|
+
(He = [...li, 'auto']),
|
|
89
|
+
(ze =
|
|
90
90
|
'The medium endpoint renders non-square images at 1K only. Use resolution 1K, aspect_ratio 1:1, or the dynamic endpoint for a non-square 2K or 4K image.'));
|
|
91
91
|
});
|
|
92
92
|
var B,
|
|
93
|
-
|
|
93
|
+
ye = b(() => {
|
|
94
94
|
'use strict';
|
|
95
95
|
B = new Set(['nano-banana-2.1', 'seedance-2-lite', 'seedance-2-5-lite']);
|
|
96
96
|
});
|
|
97
|
-
function
|
|
97
|
+
function be(e) {
|
|
98
98
|
return !1;
|
|
99
99
|
}
|
|
100
|
-
var
|
|
100
|
+
var Ye = b(() => {
|
|
101
101
|
'use strict';
|
|
102
102
|
});
|
|
103
103
|
var re,
|
|
104
|
-
|
|
104
|
+
Qe = b(() => {
|
|
105
105
|
'use strict';
|
|
106
106
|
re = {
|
|
107
107
|
source: 'TEIN Price Board',
|
|
@@ -190,6 +190,36 @@ var re,
|
|
|
190
190
|
unit: '/sec',
|
|
191
191
|
api: { model: 'seedance-2-5' },
|
|
192
192
|
variants: [
|
|
193
|
+
{
|
|
194
|
+
id: '4k-with-video',
|
|
195
|
+
price: { starter: 0.7374, plus: 0.6806, scale: 0.6523 },
|
|
196
|
+
label: '4K \xB7 Omni Reference \xB7 with reference video',
|
|
197
|
+
resolution: '4k',
|
|
198
|
+
task: 'omni',
|
|
199
|
+
withVideo: !0,
|
|
200
|
+
unfiltered: { starter: 0.7742, plus: 0.7146, scale: 0.6849 },
|
|
201
|
+
priority: { starter: 0.7816, plus: 0.7214, scale: 0.6914 },
|
|
202
|
+
unfilteredPriority: { starter: 0.8206, plus: 0.7574, scale: 0.7259 },
|
|
203
|
+
draft: { starter: 0.7374, plus: 0.6806, scale: 0.6523 },
|
|
204
|
+
unfilteredDraft: { starter: 0.7742, plus: 0.7146, scale: 0.6849 },
|
|
205
|
+
priorityDraft: { starter: 0.7816, plus: 0.7214, scale: 0.6914 },
|
|
206
|
+
unfilteredPriorityDraft: { starter: 0.8206, plus: 0.7574, scale: 0.7259 },
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
id: '4k-no-video',
|
|
210
|
+
price: { starter: 1.2003, plus: 1.108, scale: 1.0618 },
|
|
211
|
+
label: '4K \xB7 Text to Video',
|
|
212
|
+
resolution: '4k',
|
|
213
|
+
task: 't2v',
|
|
214
|
+
withVideo: !1,
|
|
215
|
+
unfiltered: { starter: 1.2603, plus: 1.1634, scale: 1.1148 },
|
|
216
|
+
priority: { starter: 1.2723, plus: 1.1744, scale: 1.1255 },
|
|
217
|
+
unfilteredPriority: { starter: 1.3359, plus: 1.2332, scale: 1.1816 },
|
|
218
|
+
draft: { starter: 1.2003, plus: 1.108, scale: 1.0618 },
|
|
219
|
+
unfilteredDraft: { starter: 1.2603, plus: 1.1634, scale: 1.1148 },
|
|
220
|
+
priorityDraft: { starter: 1.2723, plus: 1.1744, scale: 1.1255 },
|
|
221
|
+
unfilteredPriorityDraft: { starter: 1.3359, plus: 1.2332, scale: 1.1816 },
|
|
222
|
+
},
|
|
193
223
|
{
|
|
194
224
|
id: '1080p-with-video',
|
|
195
225
|
price: { starter: 0.4349, plus: 0.4132, scale: 0.378 },
|
|
@@ -481,7 +511,7 @@ var re,
|
|
|
481
511
|
unfiltered: 0.05,
|
|
482
512
|
priority: 0.06,
|
|
483
513
|
draft: { off: 0.03, draft: '480p', finalize: '1080p', expiresDays: 7 },
|
|
484
|
-
axes: { resolution: ['480p', '720p', '1080p'] },
|
|
514
|
+
axes: { resolution: ['480p', '720p', '1080p', '4k'] },
|
|
485
515
|
from: { variant: '480p-no-video-omni' },
|
|
486
516
|
},
|
|
487
517
|
{
|
|
@@ -4522,10 +4552,10 @@ var re,
|
|
|
4522
4552
|
],
|
|
4523
4553
|
};
|
|
4524
4554
|
});
|
|
4525
|
-
function
|
|
4555
|
+
function xe(e, t) {
|
|
4526
4556
|
return `${e.trim().toLowerCase()}|${(t ?? '').trim().toLowerCase()}`;
|
|
4527
4557
|
}
|
|
4528
|
-
function
|
|
4558
|
+
function di(e, t) {
|
|
4529
4559
|
if (e === 'seedance-2-mini') return 'mini';
|
|
4530
4560
|
if (e !== 'seedance-2') return;
|
|
4531
4561
|
let i = typeof t?.quality == 'string' ? t.quality.trim().toLowerCase() : '';
|
|
@@ -4535,79 +4565,79 @@ function pi(e, t) {
|
|
|
4535
4565
|
? 'fast'
|
|
4536
4566
|
: 'standard';
|
|
4537
4567
|
}
|
|
4538
|
-
function
|
|
4568
|
+
function ci(e, t) {
|
|
4539
4569
|
let i = e
|
|
4540
4570
|
.trim()
|
|
4541
4571
|
.toLowerCase()
|
|
4542
4572
|
.replace(/-(?:unfiltered|uncensored)$/, '');
|
|
4543
4573
|
if (i === 'seedance-2' || i === 'seedance-2-mini') {
|
|
4544
|
-
let n =
|
|
4545
|
-
s =
|
|
4574
|
+
let n = di(i, t),
|
|
4575
|
+
s = we.get(xe('seedance-2', n));
|
|
4546
4576
|
return s ? s.slug : null;
|
|
4547
4577
|
}
|
|
4548
|
-
let r = ae.get(i) ??
|
|
4578
|
+
let r = ae.get(i) ?? we.get(xe(i));
|
|
4549
4579
|
return r ? r.slug : null;
|
|
4550
4580
|
}
|
|
4551
|
-
function
|
|
4552
|
-
return ae.has(e) && !(
|
|
4581
|
+
function mi(e, t) {
|
|
4582
|
+
return ae.has(e) && !(ui.has(e) && t) ? e : ci(e, t);
|
|
4553
4583
|
}
|
|
4554
4584
|
function F(e, t) {
|
|
4555
|
-
let i =
|
|
4585
|
+
let i = mi(e, t);
|
|
4556
4586
|
return i ? (ae.get(i) ?? null) : null;
|
|
4557
4587
|
}
|
|
4558
4588
|
function ne() {
|
|
4559
|
-
return
|
|
4589
|
+
return ve.models;
|
|
4560
4590
|
}
|
|
4561
|
-
var
|
|
4591
|
+
var ve,
|
|
4562
4592
|
ae,
|
|
4563
|
-
be,
|
|
4564
|
-
Qe,
|
|
4565
|
-
li,
|
|
4566
4593
|
we,
|
|
4567
|
-
|
|
4568
|
-
|
|
4594
|
+
Xe,
|
|
4595
|
+
pi,
|
|
4596
|
+
ke,
|
|
4597
|
+
ui,
|
|
4598
|
+
V = b(() => {
|
|
4569
4599
|
'use strict';
|
|
4570
|
-
ze();
|
|
4571
4600
|
Ye();
|
|
4572
|
-
(
|
|
4601
|
+
Qe();
|
|
4602
|
+
((ve = {
|
|
4573
4603
|
...re,
|
|
4574
|
-
families: re.families.map((e) => ({ ...e, models: e.models.filter((t) => !
|
|
4575
|
-
models: re.models.filter((e) => !
|
|
4604
|
+
families: re.families.map((e) => ({ ...e, models: e.models.filter((t) => !be(t)) })),
|
|
4605
|
+
models: re.models.filter((e) => !be(e.slug)),
|
|
4576
4606
|
}),
|
|
4577
4607
|
(ae = new Map()),
|
|
4578
|
-
(
|
|
4579
|
-
(
|
|
4580
|
-
(
|
|
4581
|
-
(
|
|
4582
|
-
for (let e of
|
|
4583
|
-
(ae.set(e.slug, e),
|
|
4584
|
-
for (let t of e.variants)
|
|
4608
|
+
(we = new Map()),
|
|
4609
|
+
(Xe = new Map()),
|
|
4610
|
+
(pi = new Map()),
|
|
4611
|
+
(ke = new Map()));
|
|
4612
|
+
for (let e of ve.models) {
|
|
4613
|
+
(ae.set(e.slug, e), we.set(xe(e.api.model, e.api.quality), e));
|
|
4614
|
+
for (let t of e.variants) Xe.set(`${e.slug}/${t.id}`, { model: e, variant: t, edit: !1 });
|
|
4585
4615
|
for (let t of e.editVariants ?? [])
|
|
4586
|
-
|
|
4587
|
-
for (let t of e.addons ?? [])
|
|
4588
|
-
|
|
4616
|
+
Xe.set(`${e.slug}/edit/${t.id}`, { model: e, variant: t, edit: !0 });
|
|
4617
|
+
for (let t of e.addons ?? []) pi.set(`${e.slug}/addon/${t.id}`, { model: e, addon: t });
|
|
4618
|
+
ke.set(e.slug, e.family);
|
|
4589
4619
|
}
|
|
4590
|
-
for (let e of
|
|
4591
|
-
|
|
4620
|
+
for (let e of ve.families) for (let t of e.models) ke.has(t) || ke.set(t, e.slug);
|
|
4621
|
+
ui = new Set(['seedance-2']);
|
|
4592
4622
|
});
|
|
4593
4623
|
function se(e) {
|
|
4594
4624
|
let t = e.from?.variant;
|
|
4595
4625
|
return (t && e.variants.find((i) => i.id === t)) || e.variants[0];
|
|
4596
4626
|
}
|
|
4597
|
-
function
|
|
4627
|
+
function Ie(e) {
|
|
4598
4628
|
if (e.endpoints?.length)
|
|
4599
|
-
return e.editVariants?.length && e.endpoints.some((t) => t.id ===
|
|
4600
|
-
?
|
|
4629
|
+
return e.editVariants?.length && e.endpoints.some((t) => t.id === Ze)
|
|
4630
|
+
? Ze
|
|
4601
4631
|
: (e.defaultEndpoint ?? e.endpoints[0].id);
|
|
4602
4632
|
}
|
|
4603
|
-
var
|
|
4604
|
-
|
|
4633
|
+
var Ze,
|
|
4634
|
+
_e = b(() => {
|
|
4605
4635
|
'use strict';
|
|
4606
|
-
|
|
4607
|
-
|
|
4636
|
+
V();
|
|
4637
|
+
Ze = 'dynamic';
|
|
4608
4638
|
});
|
|
4609
4639
|
var oe,
|
|
4610
|
-
|
|
4640
|
+
Pe = b(() => {
|
|
4611
4641
|
'use strict';
|
|
4612
4642
|
oe = {
|
|
4613
4643
|
'gemini-3-8-flash': 'gemini-3.8-flash',
|
|
@@ -4617,29 +4647,29 @@ var oe,
|
|
|
4617
4647
|
'gpt-image-2-5-sunburst': 'gpt-image-2.5-sunburst',
|
|
4618
4648
|
};
|
|
4619
4649
|
});
|
|
4620
|
-
var
|
|
4650
|
+
var et = b(() => {
|
|
4621
4651
|
'use strict';
|
|
4622
4652
|
});
|
|
4623
|
-
function
|
|
4624
|
-
return typeof t == 'string' && (
|
|
4653
|
+
function tt(e, t) {
|
|
4654
|
+
return typeof t == 'string' && (fi[e]?.includes(t) ?? !1);
|
|
4625
4655
|
}
|
|
4626
|
-
var
|
|
4627
|
-
|
|
4656
|
+
var fi,
|
|
4657
|
+
it = b(() => {
|
|
4628
4658
|
'use strict';
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4659
|
+
V();
|
|
4660
|
+
_e();
|
|
4661
|
+
et();
|
|
4662
|
+
fi = {};
|
|
4633
4663
|
});
|
|
4634
|
-
function
|
|
4635
|
-
return e === 'nano-banana-pro' ?
|
|
4664
|
+
function rt(e) {
|
|
4665
|
+
return e === 'nano-banana-pro' ? gi : hi;
|
|
4636
4666
|
}
|
|
4637
|
-
var
|
|
4638
|
-
|
|
4639
|
-
|
|
4667
|
+
var gi,
|
|
4668
|
+
hi,
|
|
4669
|
+
at = b(() => {
|
|
4640
4670
|
'use strict';
|
|
4641
|
-
((
|
|
4642
|
-
(
|
|
4671
|
+
((gi = ['auto', '1:1', '2:3', '3:2', '3:4', '4:3', '4:5', '5:4', '9:16', '16:9', '21:9']),
|
|
4672
|
+
(hi = [
|
|
4643
4673
|
'auto',
|
|
4644
4674
|
'1:1',
|
|
4645
4675
|
'1:4',
|
|
@@ -4657,10 +4687,10 @@ var fi,
|
|
|
4657
4687
|
'21:9',
|
|
4658
4688
|
]));
|
|
4659
4689
|
});
|
|
4660
|
-
var
|
|
4661
|
-
|
|
4690
|
+
var nt,
|
|
4691
|
+
st = b(() => {
|
|
4662
4692
|
'use strict';
|
|
4663
|
-
|
|
4693
|
+
nt = [
|
|
4664
4694
|
'prompt',
|
|
4665
4695
|
'system',
|
|
4666
4696
|
'messages',
|
|
@@ -4674,10 +4704,10 @@ var at,
|
|
|
4674
4704
|
'endpoint',
|
|
4675
4705
|
];
|
|
4676
4706
|
});
|
|
4677
|
-
var
|
|
4678
|
-
|
|
4707
|
+
var ot,
|
|
4708
|
+
lt = b(() => {
|
|
4679
4709
|
'use strict';
|
|
4680
|
-
|
|
4710
|
+
ot = [
|
|
4681
4711
|
{
|
|
4682
4712
|
slug: 'claude-fable-5-1',
|
|
4683
4713
|
family: 'fable-5-1',
|
|
@@ -4746,13 +4776,13 @@ var st,
|
|
|
4746
4776
|
},
|
|
4747
4777
|
];
|
|
4748
4778
|
});
|
|
4749
|
-
function
|
|
4779
|
+
function pt(e) {
|
|
4750
4780
|
return `$${e}`;
|
|
4751
4781
|
}
|
|
4752
|
-
function
|
|
4782
|
+
function Te(e, t, i) {
|
|
4753
4783
|
return F(e)?.variants.find((n) => n.endpoint === t && n.component === i)?.price.starter ?? null;
|
|
4754
4784
|
}
|
|
4755
|
-
function
|
|
4785
|
+
function yi(e) {
|
|
4756
4786
|
return [
|
|
4757
4787
|
{
|
|
4758
4788
|
name: 'prompt',
|
|
@@ -4818,13 +4848,13 @@ function hi(e) {
|
|
|
4818
4848
|
},
|
|
4819
4849
|
];
|
|
4820
4850
|
}
|
|
4821
|
-
function
|
|
4851
|
+
function dt() {
|
|
4822
4852
|
return Object.fromEntries(
|
|
4823
|
-
|
|
4824
|
-
let t =
|
|
4825
|
-
i =
|
|
4826
|
-
r =
|
|
4827
|
-
n = t != null && i != null ? `${
|
|
4853
|
+
ot.map((e) => {
|
|
4854
|
+
let t = Te(e.slug, 'cheap', 'input'),
|
|
4855
|
+
i = Te(e.slug, 'cheap', 'output'),
|
|
4856
|
+
r = Te(e.slug, 'stable', 'input') != null,
|
|
4857
|
+
n = t != null && i != null ? `${pt(t)}/M in \xB7 ${pt(i)}/M out` : '',
|
|
4828
4858
|
s = {
|
|
4829
4859
|
slug: e.slug,
|
|
4830
4860
|
name: e.name,
|
|
@@ -4835,20 +4865,20 @@ function pt() {
|
|
|
4835
4865
|
priceFormatted: n,
|
|
4836
4866
|
unit: '/M tokens',
|
|
4837
4867
|
primaryToolName: 'run_task',
|
|
4838
|
-
parameters:
|
|
4868
|
+
parameters: yi(r),
|
|
4839
4869
|
};
|
|
4840
4870
|
return [e.slug, s];
|
|
4841
4871
|
}),
|
|
4842
4872
|
);
|
|
4843
4873
|
}
|
|
4844
|
-
var
|
|
4874
|
+
var ct = b(() => {
|
|
4845
4875
|
'use strict';
|
|
4846
|
-
|
|
4847
|
-
|
|
4876
|
+
lt();
|
|
4877
|
+
V();
|
|
4848
4878
|
});
|
|
4849
4879
|
var G,
|
|
4850
4880
|
le,
|
|
4851
|
-
|
|
4881
|
+
Me = b(() => {
|
|
4852
4882
|
'use strict';
|
|
4853
4883
|
((G = ['seedance-2-5', 'seedance-2', 'seedance-2-mini', 'seedream-5-pro', 'wan-3-0']),
|
|
4854
4884
|
(le =
|
|
@@ -4857,7 +4887,7 @@ var G,
|
|
|
4857
4887
|
function J(e) {
|
|
4858
4888
|
return `$${Number(e.toFixed(5))}`;
|
|
4859
4889
|
}
|
|
4860
|
-
function
|
|
4890
|
+
function xi(e) {
|
|
4861
4891
|
if (e.kind === 'llm') {
|
|
4862
4892
|
let t = e.defaultEndpoint,
|
|
4863
4893
|
i = (s) =>
|
|
@@ -4875,14 +4905,14 @@ function ki(e) {
|
|
|
4875
4905
|
}
|
|
4876
4906
|
return `from ${J(se(e).price.starter)}${e.unit}`;
|
|
4877
4907
|
}
|
|
4878
|
-
function
|
|
4908
|
+
function vi(e, t) {
|
|
4879
4909
|
let i = t.filter((r) => Number.isFinite(r) && r > 0);
|
|
4880
4910
|
return i.length ? `from ${J(Math.min(...i))}${e}` : null;
|
|
4881
4911
|
}
|
|
4882
|
-
function
|
|
4912
|
+
function gt(e) {
|
|
4883
4913
|
for (let t of B) {
|
|
4884
4914
|
let i = de[t],
|
|
4885
|
-
r = i ?
|
|
4915
|
+
r = i ? vi(i.unit, e[t] ?? []) : null;
|
|
4886
4916
|
i && r && (i.priceFormatted = r);
|
|
4887
4917
|
}
|
|
4888
4918
|
}
|
|
@@ -4898,13 +4928,13 @@ function H(e, t) {
|
|
|
4898
4928
|
...(t ? { description: t } : {}),
|
|
4899
4929
|
};
|
|
4900
4930
|
}
|
|
4901
|
-
function
|
|
4931
|
+
function ht(e) {
|
|
4902
4932
|
if (!e.endpoints?.length) return null;
|
|
4903
|
-
let t = e.endpoints.filter((i) =>
|
|
4933
|
+
let t = e.endpoints.filter((i) => tt(e.slug, i.id));
|
|
4904
4934
|
return {
|
|
4905
4935
|
name: 'endpoint',
|
|
4906
4936
|
type: 'select',
|
|
4907
|
-
default:
|
|
4937
|
+
default: Ie(e),
|
|
4908
4938
|
options: e.endpoints.filter((i) => !t.includes(i)).map((i) => i.id),
|
|
4909
4939
|
description:
|
|
4910
4940
|
(e.slug === 'gemini-3.1-pro-preview'
|
|
@@ -4913,27 +4943,32 @@ function gt(e) {
|
|
|
4913
4943
|
(t.length ? ` ${t.map((i) => i.label).join(' and ')}: coming soon.` : ''),
|
|
4914
4944
|
};
|
|
4915
4945
|
}
|
|
4916
|
-
function
|
|
4946
|
+
function Pi(e, t) {
|
|
4917
4947
|
if (e.unfiltered == null || t.some((r) => r.name === 'creative_mode')) return t;
|
|
4918
4948
|
let i = G.includes(e.api.model);
|
|
4919
|
-
return [...t.filter((r) =>
|
|
4949
|
+
return [...t.filter((r) => !Ce.has(r.name)), i ? yt : Ii];
|
|
4920
4950
|
}
|
|
4921
|
-
function
|
|
4922
|
-
let i = e.filter((n) =>
|
|
4923
|
-
r = [
|
|
4924
|
-
return (r.push(
|
|
4951
|
+
function Ke(e, t) {
|
|
4952
|
+
let i = e.filter((n) => !Ce.has(n.name)),
|
|
4953
|
+
r = [yt, _i];
|
|
4954
|
+
return (r.push(bt, wt), [...i, ...r]);
|
|
4925
4955
|
}
|
|
4926
|
-
function
|
|
4956
|
+
function ut(e, t = {}) {
|
|
4927
4957
|
return [
|
|
4928
4958
|
...e
|
|
4929
|
-
.filter((
|
|
4930
|
-
.map((
|
|
4931
|
-
|
|
4932
|
-
? {
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4959
|
+
.filter((i) => !Ti.has(i.name) && !Ce.has(i.name))
|
|
4960
|
+
.map((i) =>
|
|
4961
|
+
i.name === 'prompt'
|
|
4962
|
+
? { ...i, required: !0 }
|
|
4963
|
+
: i.name === 'resolution'
|
|
4964
|
+
? {
|
|
4965
|
+
...i,
|
|
4966
|
+
...(t.no4k && i.options
|
|
4967
|
+
? { options: i.options.filter((r) => String(r).toLowerCase() !== '4k') }
|
|
4968
|
+
: {}),
|
|
4969
|
+
description: `Output resolution. TEIN LITE is the lower-priced endpoint for getting started. Stability and reliability are not guaranteed. ${pe}`,
|
|
4970
|
+
}
|
|
4971
|
+
: i,
|
|
4937
4972
|
),
|
|
4938
4973
|
{
|
|
4939
4974
|
name: 'bitrate_mode',
|
|
@@ -4942,13 +4977,13 @@ function ct(e) {
|
|
|
4942
4977
|
options: ['standard'],
|
|
4943
4978
|
description: 'LITE uses standard bitrate. High bitrate is on the standard endpoint.',
|
|
4944
4979
|
},
|
|
4945
|
-
yt,
|
|
4946
4980
|
bt,
|
|
4981
|
+
wt,
|
|
4947
4982
|
];
|
|
4948
4983
|
}
|
|
4949
|
-
function
|
|
4984
|
+
function Se(e, t) {
|
|
4950
4985
|
return [
|
|
4951
|
-
|
|
4986
|
+
$('Text prompt describing the video.'),
|
|
4952
4987
|
{ name: 'mode', type: 'select', required: !0, default: t.modes[0], options: t.modes },
|
|
4953
4988
|
{
|
|
4954
4989
|
name: 'duration',
|
|
@@ -4975,10 +5010,10 @@ function Ke(e, t) {
|
|
|
4975
5010
|
),
|
|
4976
5011
|
];
|
|
4977
5012
|
}
|
|
4978
|
-
function
|
|
4979
|
-
let t =
|
|
5013
|
+
function Mi(e) {
|
|
5014
|
+
let t = ht(e);
|
|
4980
5015
|
return [
|
|
4981
|
-
|
|
5016
|
+
$('Image prompt text. Supports complex composition and text instructions.'),
|
|
4982
5017
|
...(t ? [t] : []),
|
|
4983
5018
|
{
|
|
4984
5019
|
name: 'quality',
|
|
@@ -4989,14 +5024,14 @@ function Ti(e) {
|
|
|
4989
5024
|
H(
|
|
4990
5025
|
e,
|
|
4991
5026
|
e.slug === 'gpt-image-2'
|
|
4992
|
-
? `1:1 is 1024, 2048 or 2880 px; other ratios keep about the same pixel count. ${
|
|
5027
|
+
? `1:1 is 1024, 2048 or 2880 px; other ratios keep about the same pixel count. ${ze}`
|
|
4993
5028
|
: '1:1 is 1024, 2048 or 2880 px; other ratios keep about the same pixel count.',
|
|
4994
5029
|
),
|
|
4995
5030
|
{
|
|
4996
5031
|
name: 'aspect_ratio',
|
|
4997
5032
|
type: 'select',
|
|
4998
5033
|
default: 'auto',
|
|
4999
|
-
options: [...
|
|
5034
|
+
options: [...He],
|
|
5000
5035
|
description:
|
|
5001
5036
|
"The frame. auto: an edit keeps its first input image's ratio (the nearest listed one), text to image is 1:1. The image is delivered at exactly the size for the ratio and resolution.",
|
|
5002
5037
|
},
|
|
@@ -5043,15 +5078,15 @@ function Ti(e) {
|
|
|
5043
5078
|
},
|
|
5044
5079
|
];
|
|
5045
5080
|
}
|
|
5046
|
-
function
|
|
5081
|
+
function Ki(e) {
|
|
5047
5082
|
return [
|
|
5048
|
-
|
|
5083
|
+
$('Image prompt text.'),
|
|
5049
5084
|
{
|
|
5050
5085
|
name: 'input_images',
|
|
5051
5086
|
type: 'string[]',
|
|
5052
5087
|
description: 'Images to edit or use as reference (up to 14).',
|
|
5053
5088
|
},
|
|
5054
|
-
{ name: 'aspect_ratio', type: 'select', default: '1:1', options: [...
|
|
5089
|
+
{ name: 'aspect_ratio', type: 'select', default: '1:1', options: [...rt(e.slug)] },
|
|
5055
5090
|
H(e),
|
|
5056
5091
|
{
|
|
5057
5092
|
name: 'n',
|
|
@@ -5077,10 +5112,10 @@ function Mi(e) {
|
|
|
5077
5112
|
},
|
|
5078
5113
|
];
|
|
5079
5114
|
}
|
|
5080
|
-
function
|
|
5081
|
-
let e =
|
|
5115
|
+
function Ei() {
|
|
5116
|
+
let e = nt,
|
|
5082
5117
|
t = [];
|
|
5083
|
-
for (let i of
|
|
5118
|
+
for (let i of kt(!0))
|
|
5084
5119
|
e.includes(i.name) &&
|
|
5085
5120
|
(t.push({
|
|
5086
5121
|
...i,
|
|
@@ -5102,9 +5137,9 @@ function Ci() {
|
|
|
5102
5137
|
}));
|
|
5103
5138
|
return t;
|
|
5104
5139
|
}
|
|
5105
|
-
function
|
|
5140
|
+
function kt(e) {
|
|
5106
5141
|
return [
|
|
5107
|
-
|
|
5142
|
+
$('The user message or task.'),
|
|
5108
5143
|
{ name: 'system', type: 'string', description: 'Optional system instructions.' },
|
|
5109
5144
|
{
|
|
5110
5145
|
name: 'messages',
|
|
@@ -5197,40 +5232,40 @@ function wt(e) {
|
|
|
5197
5232
|
},
|
|
5198
5233
|
];
|
|
5199
5234
|
}
|
|
5200
|
-
function
|
|
5201
|
-
if (e.slug === 'seed-2-1-turbo') return
|
|
5202
|
-
let t =
|
|
5235
|
+
function qi(e) {
|
|
5236
|
+
if (e.slug === 'seed-2-1-turbo') return $i;
|
|
5237
|
+
let t = ht(e);
|
|
5203
5238
|
return [
|
|
5204
5239
|
...(e.slug === 'gemini-3.1-pro-preview'
|
|
5205
|
-
?
|
|
5206
|
-
: e.slug === 'gpt-6-astra' ||
|
|
5207
|
-
?
|
|
5208
|
-
:
|
|
5240
|
+
? Ei()
|
|
5241
|
+
: e.slug === 'gpt-6-astra' || Ci.includes(e.slug)
|
|
5242
|
+
? kt(e.slug !== 'gpt-6-astra')
|
|
5243
|
+
: Si),
|
|
5209
5244
|
...(t ? [t] : []),
|
|
5210
5245
|
];
|
|
5211
5246
|
}
|
|
5212
|
-
function
|
|
5247
|
+
function Ai(e) {
|
|
5213
5248
|
let t = e.slug;
|
|
5214
|
-
if (e.kind === 'llm') return
|
|
5215
|
-
if (e.editVariants?.length) return
|
|
5249
|
+
if (e.kind === 'llm') return qi(e);
|
|
5250
|
+
if (e.editVariants?.length) return Mi(e);
|
|
5216
5251
|
switch (t) {
|
|
5217
5252
|
case 'seedance-2-5':
|
|
5218
|
-
return
|
|
5253
|
+
return Ke(mt, t);
|
|
5219
5254
|
case 'seedance-2-5-lite':
|
|
5220
|
-
return
|
|
5255
|
+
return ut(mt, { no4k: !0 });
|
|
5221
5256
|
case 'seedance-2':
|
|
5222
|
-
return
|
|
5257
|
+
return Ke(ft, t);
|
|
5223
5258
|
case 'seedance-2-lite':
|
|
5224
|
-
return
|
|
5259
|
+
return ut(ft);
|
|
5225
5260
|
case 'seedance-2-mini':
|
|
5226
|
-
return
|
|
5261
|
+
return Ke(Ri, t);
|
|
5227
5262
|
case 'nano-banana-2':
|
|
5228
5263
|
case 'nano-banana-2.1':
|
|
5229
5264
|
case 'nano-banana-pro':
|
|
5230
|
-
return
|
|
5265
|
+
return Ki(e);
|
|
5231
5266
|
case 'seedream-5-pro':
|
|
5232
5267
|
return [
|
|
5233
|
-
|
|
5268
|
+
$('Detailed description of the image to generate.'),
|
|
5234
5269
|
{ name: 'images', type: 'string[]', description: 'Reference images (the first is free).' },
|
|
5235
5270
|
H(e),
|
|
5236
5271
|
{
|
|
@@ -5244,7 +5279,7 @@ function qi(e) {
|
|
|
5244
5279
|
case 'qwen-3':
|
|
5245
5280
|
case 'qwen-3-pro':
|
|
5246
5281
|
return [
|
|
5247
|
-
|
|
5282
|
+
$('Image prompt text; dense layouts and multilingual text work well.'),
|
|
5248
5283
|
{
|
|
5249
5284
|
name: 'images',
|
|
5250
5285
|
type: 'string[]',
|
|
@@ -5290,7 +5325,7 @@ function qi(e) {
|
|
|
5290
5325
|
];
|
|
5291
5326
|
case 'wan-3-0':
|
|
5292
5327
|
case 'wan-3-0-prime':
|
|
5293
|
-
return
|
|
5328
|
+
return Se(e, {
|
|
5294
5329
|
modes: ['text_to_video', 'first_n_last_frames', 'multi_reference'],
|
|
5295
5330
|
aspects: ['16:9', '9:16', '4:3', '3:4', '1:1', 'adaptive'],
|
|
5296
5331
|
minSec: 2,
|
|
@@ -5300,7 +5335,7 @@ function qi(e) {
|
|
|
5300
5335
|
});
|
|
5301
5336
|
case 'happy-horse-1-1':
|
|
5302
5337
|
case 'happy-horse-1-0':
|
|
5303
|
-
return
|
|
5338
|
+
return Se(e, {
|
|
5304
5339
|
modes:
|
|
5305
5340
|
t === 'happy-horse-1-0'
|
|
5306
5341
|
? ['text-to-video', 'single-image', 'multi-reference', 'video-editing']
|
|
@@ -5311,7 +5346,7 @@ function qi(e) {
|
|
|
5311
5346
|
references: t === 'happy-horse-1-0' ? ['images', 'videos'] : ['images'],
|
|
5312
5347
|
});
|
|
5313
5348
|
case 'minimax-h3':
|
|
5314
|
-
return
|
|
5349
|
+
return Se(e, {
|
|
5315
5350
|
modes: ['text_to_video', 'first_n_last_frames', 'multi_reference'],
|
|
5316
5351
|
aspects: ['16:9', '21:9', '4:3', '1:1', '3:4', '9:16', 'adaptive'],
|
|
5317
5352
|
minSec: 4,
|
|
@@ -5319,146 +5354,162 @@ function qi(e) {
|
|
|
5319
5354
|
references: ['images', 'videos', 'audios', 'first_frame_image', 'last_frame_image'],
|
|
5320
5355
|
});
|
|
5321
5356
|
default:
|
|
5322
|
-
return [
|
|
5357
|
+
return [$('Prompt text.')];
|
|
5323
5358
|
}
|
|
5324
5359
|
}
|
|
5325
|
-
function
|
|
5360
|
+
function $e(e, t = e.api.model) {
|
|
5326
5361
|
return {
|
|
5327
5362
|
slug: t,
|
|
5328
5363
|
name: e.name,
|
|
5329
|
-
category:
|
|
5330
|
-
kind:
|
|
5364
|
+
category: bi[e.kind],
|
|
5365
|
+
kind: ki[e.kind],
|
|
5331
5366
|
vendor: e.vendor ?? '',
|
|
5332
5367
|
description: e.desc ?? e.name,
|
|
5333
|
-
priceFormatted:
|
|
5368
|
+
priceFormatted: xi(e),
|
|
5334
5369
|
unit: e.unit,
|
|
5335
|
-
primaryToolName:
|
|
5336
|
-
parameters:
|
|
5370
|
+
primaryToolName: wi[e.kind],
|
|
5371
|
+
parameters: Pi(e, Ai(e)),
|
|
5337
5372
|
};
|
|
5338
5373
|
}
|
|
5339
|
-
function
|
|
5374
|
+
function Oi() {
|
|
5340
5375
|
let e = {};
|
|
5341
5376
|
for (let t of ne())
|
|
5342
5377
|
if (t.slug !== 'seedance-2-fast') {
|
|
5343
5378
|
if (t.slug === 'seedance-2-mini') {
|
|
5344
|
-
e['seedance-2-mini'] =
|
|
5379
|
+
e['seedance-2-mini'] = $e(t, 'seedance-2-mini');
|
|
5345
5380
|
continue;
|
|
5346
5381
|
}
|
|
5347
5382
|
if (t.slug === 'seedance-2') {
|
|
5348
|
-
let i =
|
|
5383
|
+
let i = $e(t);
|
|
5349
5384
|
((i.description = `${t.desc ?? t.name} Send quality fast or mini for Seedance 2.0 Fast or Mini.`),
|
|
5350
5385
|
(e['seedance-2'] = i));
|
|
5351
5386
|
continue;
|
|
5352
5387
|
}
|
|
5353
|
-
t.slug.startsWith('claude-') || (e[t.api.model] =
|
|
5388
|
+
t.slug.startsWith('claude-') || (e[t.api.model] = $e(t));
|
|
5354
5389
|
}
|
|
5355
|
-
Object.assign(e,
|
|
5390
|
+
Object.assign(e, dt());
|
|
5356
5391
|
for (let [t, i] of Object.entries(oe))
|
|
5357
5392
|
e[i] && Object.defineProperty(e, t, { value: e[i], enumerable: !1 });
|
|
5358
5393
|
return e;
|
|
5359
5394
|
}
|
|
5360
|
-
function
|
|
5395
|
+
function N(e) {
|
|
5361
5396
|
return de[e] ?? null;
|
|
5362
5397
|
}
|
|
5363
|
-
function
|
|
5398
|
+
function Di(e, t, i) {
|
|
5364
5399
|
if ((e === 'seedance-2-5' || e === 'seedance-2-5-lite') && t === 'duration') {
|
|
5365
5400
|
let r = (n) => (typeof n == 'string' ? n.trim().toLowerCase() : '');
|
|
5366
5401
|
if (r(i.mode) === 'edit' || r(i.omni_reference_task_type) === 'edit') return !1;
|
|
5367
5402
|
}
|
|
5368
5403
|
return !0;
|
|
5369
5404
|
}
|
|
5370
|
-
function
|
|
5405
|
+
function It(e, t) {
|
|
5406
|
+
let i = { ...t };
|
|
5407
|
+
if (e?.slug === 'seedance-2-5') {
|
|
5408
|
+
let r = (n) => typeof n != 'string' || !n.trim();
|
|
5409
|
+
for (let n of Li) (r(i.finalize) && !r(i[n]) && (i.finalize = i[n]), delete i[n]);
|
|
5410
|
+
if (!r(i.finalize)) return i;
|
|
5411
|
+
}
|
|
5412
|
+
for (let r of e?.parameters ?? [])
|
|
5413
|
+
r.default !== void 0 &&
|
|
5414
|
+
i[r.name] === void 0 &&
|
|
5415
|
+
Di(e.slug, r.name, t) &&
|
|
5416
|
+
(i[r.name] = r.default);
|
|
5417
|
+
return i;
|
|
5418
|
+
}
|
|
5419
|
+
function q() {
|
|
5371
5420
|
return Object.values(de);
|
|
5372
5421
|
}
|
|
5373
|
-
var
|
|
5374
|
-
bi,
|
|
5422
|
+
var bi,
|
|
5375
5423
|
wi,
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
vi,
|
|
5379
|
-
Ii,
|
|
5424
|
+
ki,
|
|
5425
|
+
$,
|
|
5380
5426
|
yt,
|
|
5427
|
+
Ii,
|
|
5428
|
+
_i,
|
|
5381
5429
|
bt,
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5430
|
+
wt,
|
|
5431
|
+
Ce,
|
|
5432
|
+
Ti,
|
|
5385
5433
|
Si,
|
|
5386
5434
|
$i,
|
|
5435
|
+
Ci,
|
|
5387
5436
|
pe,
|
|
5388
|
-
ut,
|
|
5389
|
-
kt,
|
|
5390
|
-
xt,
|
|
5391
5437
|
mt,
|
|
5392
|
-
|
|
5438
|
+
xt,
|
|
5439
|
+
vt,
|
|
5440
|
+
ft,
|
|
5441
|
+
Ri,
|
|
5393
5442
|
de,
|
|
5394
|
-
|
|
5443
|
+
Li,
|
|
5444
|
+
z = b(() => {
|
|
5395
5445
|
'use strict';
|
|
5396
5446
|
We();
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
Ie();
|
|
5447
|
+
ye();
|
|
5448
|
+
V();
|
|
5400
5449
|
_e();
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
(
|
|
5407
|
-
|
|
5450
|
+
Pe();
|
|
5451
|
+
it();
|
|
5452
|
+
at();
|
|
5453
|
+
st();
|
|
5454
|
+
ct();
|
|
5455
|
+
Me();
|
|
5456
|
+
((bi = { video: 'Video', image: 'Image', audio: 'Audio', llm: 'Text' }),
|
|
5457
|
+
(wi = {
|
|
5408
5458
|
video: 'generate_video',
|
|
5409
5459
|
image: 'generate_image',
|
|
5410
5460
|
audio: 'generate_audio',
|
|
5411
5461
|
llm: 'run_task',
|
|
5412
5462
|
}),
|
|
5413
|
-
(
|
|
5463
|
+
(ki = {
|
|
5414
5464
|
video: 'Text-to-Video',
|
|
5415
5465
|
image: 'Text-to-Image',
|
|
5416
5466
|
audio: 'Text-to-Audio',
|
|
5417
5467
|
llm: 'Reasoning (LLM)',
|
|
5418
5468
|
}));
|
|
5419
|
-
|
|
5420
|
-
((
|
|
5469
|
+
$ = (e) => ({ name: 'prompt', type: 'string', required: !0, description: e });
|
|
5470
|
+
((yt = {
|
|
5421
5471
|
name: 'creative_mode',
|
|
5422
5472
|
type: 'boolean',
|
|
5423
5473
|
default: !1,
|
|
5424
5474
|
description:
|
|
5425
5475
|
'Runs the Creative mode checkpoint at its published price (+5%). The Acceptable Use Policy applies.',
|
|
5426
5476
|
}),
|
|
5427
|
-
(
|
|
5477
|
+
(Ii = {
|
|
5428
5478
|
name: 'creative_mode',
|
|
5429
5479
|
type: 'boolean',
|
|
5430
5480
|
default: !1,
|
|
5431
5481
|
description: `Not available yet on this model: ${le}.`,
|
|
5432
5482
|
}),
|
|
5433
|
-
(
|
|
5483
|
+
(_i = {
|
|
5434
5484
|
name: 'priority',
|
|
5435
5485
|
type: 'boolean',
|
|
5436
5486
|
default: !1,
|
|
5437
5487
|
description: 'Guaranteed speed and no queue, at the published Priority price (+6%).',
|
|
5438
5488
|
}),
|
|
5439
|
-
(
|
|
5489
|
+
(bt = {
|
|
5440
5490
|
name: 'reference_roles',
|
|
5441
5491
|
type: 'json',
|
|
5442
5492
|
description: `Omni Reference only. Role of each reference, by tag { "@Image1": "prop" } or by kind { "image": ["prop"] }. Image: appearance, clothing, prop, scene_layout, lighting, first_frame, last_frame; Seedance 2.5 also keyframe, storyboard. Video: motion, camera, style; Seedance 2.5 also blockout_coarse, blockout_fine. Audio: voice, ambience, music, sound_effect. On a tag, the value image, video or audio uses that kind's default (appearance, motion, voice).`,
|
|
5443
5493
|
}),
|
|
5444
|
-
(
|
|
5494
|
+
(wt = {
|
|
5445
5495
|
name: 'auto_fit_images',
|
|
5446
5496
|
type: 'boolean',
|
|
5447
5497
|
default: !1,
|
|
5448
5498
|
description:
|
|
5449
5499
|
'Fits a reference image whose aspect ratio (width / height) is outside 0.40-2.50 just inside it: a slight stretch, or the image on a blurred copy of itself, never cropped. Off: such an image is refused with a 422. First and last frames are never changed. Same price.',
|
|
5450
5500
|
}),
|
|
5451
|
-
(
|
|
5452
|
-
|
|
5501
|
+
(Ce = new Set(['full_access', 'is_uncensored', 'unfiltered', 'verificationSignature'])));
|
|
5502
|
+
Ti = new Set([
|
|
5453
5503
|
'quality',
|
|
5454
5504
|
'bitrate_mode',
|
|
5455
5505
|
'draft',
|
|
5506
|
+
'finalize',
|
|
5456
5507
|
'draft_task_id',
|
|
5457
5508
|
'draft_generation_id',
|
|
5458
5509
|
'pass_faces',
|
|
5459
5510
|
]);
|
|
5460
|
-
((
|
|
5461
|
-
|
|
5511
|
+
((Si = [
|
|
5512
|
+
$('The user message or task.'),
|
|
5462
5513
|
{ name: 'system', type: 'string', description: 'Optional system instructions.' },
|
|
5463
5514
|
{
|
|
5464
5515
|
name: 'messages',
|
|
@@ -5475,8 +5526,8 @@ var yi,
|
|
|
5475
5526
|
{ name: 'temperature', type: 'slider', min: 0, max: 1, step: 0.1 },
|
|
5476
5527
|
{ name: 'top_p', type: 'slider', min: 0, max: 1, step: 0.05 },
|
|
5477
5528
|
]),
|
|
5478
|
-
(
|
|
5479
|
-
|
|
5529
|
+
($i = [
|
|
5530
|
+
$('The user message or task.'),
|
|
5480
5531
|
{ name: 'system', type: 'string', description: 'Optional system instructions.' },
|
|
5481
5532
|
{
|
|
5482
5533
|
name: 'messages',
|
|
@@ -5557,15 +5608,14 @@ var yi,
|
|
|
5557
5608
|
description: 'Video frames read a second.',
|
|
5558
5609
|
},
|
|
5559
5610
|
]),
|
|
5560
|
-
(
|
|
5611
|
+
(Ci = ['gemini-3.8-flash', 'gemini-3.7-flash']));
|
|
5561
5612
|
((pe = 'Left out: 480p, the same default as the API, the playground and workflow steps.'),
|
|
5562
|
-
(
|
|
5613
|
+
(mt = [
|
|
5563
5614
|
{
|
|
5564
5615
|
name: 'prompt',
|
|
5565
5616
|
type: 'string',
|
|
5566
|
-
required: !0,
|
|
5567
5617
|
description:
|
|
5568
|
-
'Text prompt describing the desired video scene, actions, camera angles, lighting, and style.',
|
|
5618
|
+
'Required, except with finalize. Text prompt describing the desired video scene, actions, camera angles, lighting, and style.',
|
|
5569
5619
|
},
|
|
5570
5620
|
{
|
|
5571
5621
|
name: 'mode',
|
|
@@ -5597,8 +5647,8 @@ var yi,
|
|
|
5597
5647
|
name: 'resolution',
|
|
5598
5648
|
type: 'select',
|
|
5599
5649
|
default: '480p',
|
|
5600
|
-
options: ['480p', '720p', '1080p'],
|
|
5601
|
-
description: `Output resolution. 480p and 720p are 8-bit. 1080p
|
|
5650
|
+
options: ['480p', '720p', '1080p', '4k'],
|
|
5651
|
+
description: `Output resolution. 480p and 720p are 8-bit. 1080p and 4k are 10-bit H.265/HEVC. 4k is 3840x2160 at 16:9, works with Creative mode, and runs on one dedicated endpoint with no fallback, so it can be busy. ${pe}`,
|
|
5602
5652
|
},
|
|
5603
5653
|
{
|
|
5604
5654
|
name: 'aspect_ratio',
|
|
@@ -5647,19 +5697,23 @@ var yi,
|
|
|
5647
5697
|
type: 'boolean',
|
|
5648
5698
|
default: !1,
|
|
5649
5699
|
description:
|
|
5650
|
-
'480p preview, billed at the 480p rate. Resolution must be 480p. Render the final 1080p video with
|
|
5700
|
+
'480p preview, billed at the 480p rate. Resolution must be 480p. Render the final 1080p or 4k video with finalize within 7 days.',
|
|
5651
5701
|
},
|
|
5652
5702
|
{
|
|
5653
|
-
name: '
|
|
5703
|
+
name: 'finalize',
|
|
5654
5704
|
type: 'string',
|
|
5655
5705
|
description:
|
|
5656
|
-
'Job id of a succeeded Seedance 2.5 draft. Renders that draft at 1080p at the finalize price.
|
|
5706
|
+
'Job id of a succeeded Seedance 2.5 draft. Renders that draft at 1080p (default) or at 4k with resolution "4k", at the finalize price. Send only finalize, resolution and output options: the prompt, references and other settings are reused from the draft.',
|
|
5707
|
+
},
|
|
5708
|
+
{
|
|
5709
|
+
name: 'draft_task_id',
|
|
5710
|
+
type: 'string',
|
|
5711
|
+
description: 'Older name for finalize. Same final render.',
|
|
5657
5712
|
},
|
|
5658
5713
|
{
|
|
5659
5714
|
name: 'draft_generation_id',
|
|
5660
5715
|
type: 'string',
|
|
5661
|
-
description:
|
|
5662
|
-
'Tein generation id of a succeeded Seedance 2.5 draft. Same final render as draft_task_id.',
|
|
5716
|
+
description: 'Older name for finalize. Same final render.',
|
|
5663
5717
|
},
|
|
5664
5718
|
{
|
|
5665
5719
|
name: 'images',
|
|
@@ -5705,19 +5759,19 @@ var yi,
|
|
|
5705
5759
|
'Keeps real faces in reference images. On by default. Send false to turn it off.',
|
|
5706
5760
|
},
|
|
5707
5761
|
]),
|
|
5708
|
-
(
|
|
5762
|
+
(xt = {
|
|
5709
5763
|
name: 'images',
|
|
5710
5764
|
type: 'string[]',
|
|
5711
5765
|
description:
|
|
5712
5766
|
'Reference images as public http(s) URLs or data URIs (up to 9). The Tein CLI and local MCP client read a file path on your machine and upload it before the request is sent.',
|
|
5713
5767
|
}),
|
|
5714
|
-
(
|
|
5768
|
+
(vt = {
|
|
5715
5769
|
name: 'audios',
|
|
5716
5770
|
type: 'string[]',
|
|
5717
5771
|
description:
|
|
5718
5772
|
'Reference audio as public http(s) URLs or data URIs (up to 3; each 2 to 15s, combined 15s or less). Needs at least one photo in images. A first or last frame sent with it is used only as a reference image, with mode multi_reference. The Tein CLI and local MCP client read a file path on your machine and upload it before the request is sent.',
|
|
5719
5773
|
}),
|
|
5720
|
-
(
|
|
5774
|
+
(ft = [
|
|
5721
5775
|
{
|
|
5722
5776
|
name: 'prompt',
|
|
5723
5777
|
type: 'string',
|
|
@@ -5795,8 +5849,8 @@ var yi,
|
|
|
5795
5849
|
description:
|
|
5796
5850
|
'Also returns the last frame as a JPEG, the same size as the video and without a watermark.',
|
|
5797
5851
|
},
|
|
5798
|
-
kt,
|
|
5799
5852
|
xt,
|
|
5853
|
+
vt,
|
|
5800
5854
|
{
|
|
5801
5855
|
name: 'first_frame_image',
|
|
5802
5856
|
type: 'string',
|
|
@@ -5817,7 +5871,7 @@ var yi,
|
|
|
5817
5871
|
'Keeps real faces in reference images. On by default. Send false to turn it off.',
|
|
5818
5872
|
},
|
|
5819
5873
|
]),
|
|
5820
|
-
(
|
|
5874
|
+
(Ri = [
|
|
5821
5875
|
{
|
|
5822
5876
|
name: 'prompt',
|
|
5823
5877
|
type: 'string',
|
|
@@ -5872,8 +5926,8 @@ var yi,
|
|
|
5872
5926
|
description:
|
|
5873
5927
|
'Also returns the last frame as a JPEG, the same size as the video and without a watermark.',
|
|
5874
5928
|
},
|
|
5875
|
-
kt,
|
|
5876
5929
|
xt,
|
|
5930
|
+
vt,
|
|
5877
5931
|
{
|
|
5878
5932
|
name: 'first_frame_image',
|
|
5879
5933
|
type: 'string',
|
|
@@ -5888,52 +5942,53 @@ var yi,
|
|
|
5888
5942
|
'Keeps real faces in reference images. On by default. Send false to turn it off.',
|
|
5889
5943
|
},
|
|
5890
5944
|
]));
|
|
5891
|
-
de =
|
|
5945
|
+
de = Oi();
|
|
5946
|
+
Li = ['draft_task_id', 'draft_generation_id'];
|
|
5892
5947
|
});
|
|
5893
5948
|
function ce(e) {
|
|
5894
5949
|
let t = '/v1/pricing/models',
|
|
5895
5950
|
i = e?.trim();
|
|
5896
5951
|
return i ? `${t}?model=${encodeURIComponent(i)}` : t;
|
|
5897
5952
|
}
|
|
5898
|
-
var
|
|
5953
|
+
var qe = b(() => {
|
|
5899
5954
|
'use strict';
|
|
5900
5955
|
});
|
|
5901
|
-
function
|
|
5956
|
+
function At(e) {
|
|
5902
5957
|
return e.length <= 1 ? (e[0] ?? '') : `${e.slice(0, -1).join(', ')} and ${e[e.length - 1]}`;
|
|
5903
5958
|
}
|
|
5904
|
-
function
|
|
5959
|
+
function Rt(e) {
|
|
5905
5960
|
let t = ne().filter((s) => s.kind === e && s.unfiltered != null),
|
|
5906
5961
|
i = t.filter((s) => G.includes(s.api.model)).map((s) => s.name),
|
|
5907
5962
|
r = t.filter((s) => !G.includes(s.api.model)).map((s) => s.name);
|
|
5908
5963
|
return [
|
|
5909
5964
|
...(i.length
|
|
5910
|
-
? [`${
|
|
5965
|
+
? [`${At(i)}: runs the Creative mode checkpoint at its published price (+5%).`]
|
|
5911
5966
|
: []),
|
|
5912
|
-
...(r.length ? [`Not available yet on ${
|
|
5967
|
+
...(r.length ? [`Not available yet on ${At(r)}: ${le}.`] : []),
|
|
5913
5968
|
'The Acceptable Use Policy applies.',
|
|
5914
5969
|
].join(' ');
|
|
5915
5970
|
}
|
|
5916
|
-
function
|
|
5917
|
-
if (
|
|
5971
|
+
function or(e) {
|
|
5972
|
+
if (nr.has(e.name)) return e;
|
|
5918
5973
|
let t = e.inputSchema.properties;
|
|
5919
5974
|
return !t || t.callback_url
|
|
5920
5975
|
? e
|
|
5921
|
-
: { ...e, inputSchema: { ...e.inputSchema, properties: { ...t, callback_url:
|
|
5976
|
+
: { ...e, inputSchema: { ...e.inputSchema, properties: { ...t, callback_url: ar } } };
|
|
5922
5977
|
}
|
|
5923
|
-
function
|
|
5978
|
+
function lr(e) {
|
|
5924
5979
|
let t = e.inputSchema.properties;
|
|
5925
5980
|
if (!t) return e;
|
|
5926
5981
|
let i = !1,
|
|
5927
5982
|
r = {};
|
|
5928
5983
|
for (let [n, s] of Object.entries(t))
|
|
5929
|
-
|
|
5984
|
+
Ot.has(n) && s.type === 'string' && !s.format
|
|
5930
5985
|
? ((r[n] = { ...s, format: 'uri' }), (i = !0))
|
|
5931
|
-
:
|
|
5986
|
+
: Ot.has(n) && s.type === 'array' && s.items?.type === 'string' && !s.items.format
|
|
5932
5987
|
? ((r[n] = { ...s, items: { ...s.items, format: 'uri' } }), (i = !0))
|
|
5933
5988
|
: (r[n] = s);
|
|
5934
5989
|
return i ? { ...e, inputSchema: { ...e.inputSchema, properties: r } } : e;
|
|
5935
5990
|
}
|
|
5936
|
-
function
|
|
5991
|
+
function pr(e) {
|
|
5937
5992
|
switch (e.type) {
|
|
5938
5993
|
case 'string':
|
|
5939
5994
|
return {
|
|
@@ -5988,11 +6043,11 @@ function sr(e) {
|
|
|
5988
6043
|
return { type: 'string', description: e.description };
|
|
5989
6044
|
}
|
|
5990
6045
|
}
|
|
5991
|
-
function
|
|
6046
|
+
function dr(e, t) {
|
|
5992
6047
|
let i = t || e.slug.replace(/[^a-zA-Z0-9_-]/g, '_'),
|
|
5993
6048
|
r = {},
|
|
5994
6049
|
n = [];
|
|
5995
|
-
for (let o of e.parameters) ((r[o.name] =
|
|
6050
|
+
for (let o of e.parameters) ((r[o.name] = pr(o)), o.required && n.push(o.name));
|
|
5996
6051
|
let s = {
|
|
5997
6052
|
type: 'object',
|
|
5998
6053
|
properties: r,
|
|
@@ -6005,11 +6060,11 @@ function or(e, t) {
|
|
|
6005
6060
|
inputSchema: s,
|
|
6006
6061
|
};
|
|
6007
6062
|
}
|
|
6008
|
-
function
|
|
6009
|
-
let e =
|
|
6010
|
-
t =
|
|
6011
|
-
i =
|
|
6012
|
-
r =
|
|
6063
|
+
function cr() {
|
|
6064
|
+
let e = q().filter((d) => d.category === 'Image'),
|
|
6065
|
+
t = q().filter((d) => d.category === 'Video'),
|
|
6066
|
+
i = q().filter((d) => d.category === 'Text'),
|
|
6067
|
+
r = q().filter((d) => d.category === 'Audio'),
|
|
6013
6068
|
n = {
|
|
6014
6069
|
name: 'generate_image',
|
|
6015
6070
|
description:
|
|
@@ -6023,7 +6078,7 @@ function lr() {
|
|
|
6023
6078
|
},
|
|
6024
6079
|
model: {
|
|
6025
6080
|
type: 'string',
|
|
6026
|
-
enum: e.map((
|
|
6081
|
+
enum: e.map((d) => d.slug),
|
|
6027
6082
|
default: 'gpt-image-2',
|
|
6028
6083
|
description: 'The image model to use (default: gpt-image-2).',
|
|
6029
6084
|
},
|
|
@@ -6101,7 +6156,7 @@ function lr() {
|
|
|
6101
6156
|
maximum: 2147483647,
|
|
6102
6157
|
description: 'Nano Banana 2 and Nano Banana Pro. Omit it for a new image each time.',
|
|
6103
6158
|
},
|
|
6104
|
-
creative_mode: { type: 'boolean', default: !1, description:
|
|
6159
|
+
creative_mode: { type: 'boolean', default: !1, description: Rt('image') },
|
|
6105
6160
|
},
|
|
6106
6161
|
required: ['prompt'],
|
|
6107
6162
|
additionalProperties: !0,
|
|
@@ -6121,7 +6176,7 @@ function lr() {
|
|
|
6121
6176
|
},
|
|
6122
6177
|
model: {
|
|
6123
6178
|
type: 'string',
|
|
6124
|
-
enum: t.map((
|
|
6179
|
+
enum: t.map((d) => d.slug),
|
|
6125
6180
|
default: 'seedance-2-5',
|
|
6126
6181
|
description: 'The video model to use (default: seedance-2-5).',
|
|
6127
6182
|
},
|
|
@@ -6138,7 +6193,7 @@ function lr() {
|
|
|
6138
6193
|
default: '480p',
|
|
6139
6194
|
description: 'Video resolution (the lowest price is the default; see each model tool).',
|
|
6140
6195
|
},
|
|
6141
|
-
creative_mode: { type: 'boolean', default: !1, description:
|
|
6196
|
+
creative_mode: { type: 'boolean', default: !1, description: Rt('video') },
|
|
6142
6197
|
priority: {
|
|
6143
6198
|
type: 'boolean',
|
|
6144
6199
|
default: !1,
|
|
@@ -6206,7 +6261,7 @@ function lr() {
|
|
|
6206
6261
|
prompt: { type: 'string', description: 'The reasoning task or query to execute.' },
|
|
6207
6262
|
model: {
|
|
6208
6263
|
type: 'string',
|
|
6209
|
-
enum: i.map((
|
|
6264
|
+
enum: i.map((d) => d.slug),
|
|
6210
6265
|
default: 'gpt-6-astra',
|
|
6211
6266
|
description: 'The reasoning model to use (default: gpt-6-astra).',
|
|
6212
6267
|
},
|
|
@@ -6227,7 +6282,7 @@ function lr() {
|
|
|
6227
6282
|
additionalProperties: !0,
|
|
6228
6283
|
},
|
|
6229
6284
|
},
|
|
6230
|
-
|
|
6285
|
+
l = {
|
|
6231
6286
|
name: 'generate_mesh',
|
|
6232
6287
|
description: 'Split an image into layers with Seedream 5.0 Pro (layer decomposition).',
|
|
6233
6288
|
inputSchema: {
|
|
@@ -6244,7 +6299,7 @@ function lr() {
|
|
|
6244
6299
|
additionalProperties: !0,
|
|
6245
6300
|
},
|
|
6246
6301
|
},
|
|
6247
|
-
|
|
6302
|
+
c = {
|
|
6248
6303
|
name: 'get_generation_status',
|
|
6249
6304
|
description:
|
|
6250
6305
|
'Check the progress and retrieve final output URLs for any in-progress generation using its request_id.',
|
|
@@ -6260,10 +6315,10 @@ function lr() {
|
|
|
6260
6315
|
additionalProperties: !0,
|
|
6261
6316
|
},
|
|
6262
6317
|
},
|
|
6263
|
-
|
|
6264
|
-
return [n, s, o, u,
|
|
6318
|
+
p = ur();
|
|
6319
|
+
return [n, s, o, u, l, p, c, sr];
|
|
6265
6320
|
}
|
|
6266
|
-
function
|
|
6321
|
+
function ur() {
|
|
6267
6322
|
return {
|
|
6268
6323
|
name: 'upload_asset',
|
|
6269
6324
|
description:
|
|
@@ -6310,26 +6365,26 @@ function pr() {
|
|
|
6310
6365
|
},
|
|
6311
6366
|
};
|
|
6312
6367
|
}
|
|
6313
|
-
function
|
|
6314
|
-
let e =
|
|
6315
|
-
t =
|
|
6316
|
-
return [...e, ...t].map(
|
|
6368
|
+
function Ve() {
|
|
6369
|
+
let e = cr(),
|
|
6370
|
+
t = q().map((i) => dr(i));
|
|
6371
|
+
return [...e, ...t].map(or).map(lr);
|
|
6317
6372
|
}
|
|
6318
|
-
var
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6373
|
+
var ar,
|
|
6374
|
+
nr,
|
|
6375
|
+
sr,
|
|
6376
|
+
Ot,
|
|
6377
|
+
Dt = b(() => {
|
|
6323
6378
|
'use strict';
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
((
|
|
6379
|
+
V();
|
|
6380
|
+
Me();
|
|
6381
|
+
z();
|
|
6382
|
+
((ar = {
|
|
6328
6383
|
type: 'string',
|
|
6329
6384
|
description:
|
|
6330
6385
|
'Optional HTTPS URL. Tein POSTs the finished job here when it succeeds, fails, expires, or is cancelled. The body matches GET /v1/jobs/:id and is signed with X-Tein-Signature.',
|
|
6331
6386
|
}),
|
|
6332
|
-
(
|
|
6387
|
+
(nr = new Set([
|
|
6333
6388
|
'upload_asset',
|
|
6334
6389
|
'upload_media',
|
|
6335
6390
|
'upload_image',
|
|
@@ -6337,7 +6392,7 @@ var tr,
|
|
|
6337
6392
|
'check_status',
|
|
6338
6393
|
'get_pricing',
|
|
6339
6394
|
])),
|
|
6340
|
-
(
|
|
6395
|
+
(sr = {
|
|
6341
6396
|
name: 'get_pricing',
|
|
6342
6397
|
description:
|
|
6343
6398
|
'Published USD prices for every Tein model: Starter, Plus and Scale on each variant, plus Creative mode, Priority and draft tables where they are published, and Admin prices for models that are not on the board. No API key is required. Pass model to keep one catalog slug or API model id (for example seedance-2-5). The same payload as GET /v1/pricing/models.',
|
|
@@ -6352,7 +6407,7 @@ var tr,
|
|
|
6352
6407
|
additionalProperties: !1,
|
|
6353
6408
|
},
|
|
6354
6409
|
}));
|
|
6355
|
-
|
|
6410
|
+
Ot = new Set([
|
|
6356
6411
|
'image',
|
|
6357
6412
|
'images',
|
|
6358
6413
|
'image_url',
|
|
@@ -6369,19 +6424,19 @@ var tr,
|
|
|
6369
6424
|
'lipsyncing_audio',
|
|
6370
6425
|
]);
|
|
6371
6426
|
});
|
|
6372
|
-
var
|
|
6373
|
-
|
|
6374
|
-
forgetToolSchemas: () =>
|
|
6375
|
-
jsonRpcAnswer: () =>
|
|
6376
|
-
preprocessLocalFiles: () =>
|
|
6377
|
-
startStdioServer: () =>
|
|
6427
|
+
var Ht = {};
|
|
6428
|
+
ti(Ht, {
|
|
6429
|
+
forgetToolSchemas: () => yr,
|
|
6430
|
+
jsonRpcAnswer: () => Ut,
|
|
6431
|
+
preprocessLocalFiles: () => Gt,
|
|
6432
|
+
startStdioServer: () => Jt,
|
|
6378
6433
|
});
|
|
6379
|
-
function
|
|
6434
|
+
function mr(e) {
|
|
6380
6435
|
let t = (i) =>
|
|
6381
6436
|
!!i && typeof i == 'object' && i.jsonrpc === '2.0' && ('result' in i || 'error' in i);
|
|
6382
6437
|
return Array.isArray(e) ? e.length > 0 && e.every(t) : t(e);
|
|
6383
6438
|
}
|
|
6384
|
-
function
|
|
6439
|
+
function Ut(e, t, i) {
|
|
6385
6440
|
let r = e?.id,
|
|
6386
6441
|
n = r == null,
|
|
6387
6442
|
s = null;
|
|
@@ -6390,7 +6445,7 @@ function Nt(e, t, i) {
|
|
|
6390
6445
|
} catch {
|
|
6391
6446
|
s = null;
|
|
6392
6447
|
}
|
|
6393
|
-
if (s !== null &&
|
|
6448
|
+
if (s !== null && mr(s)) return n ? null : s;
|
|
6394
6449
|
if (n) return null;
|
|
6395
6450
|
if (!i && t >= 200 && t < 300) return;
|
|
6396
6451
|
let o = s?.error,
|
|
@@ -6400,60 +6455,60 @@ function Nt(e, t, i) {
|
|
|
6400
6455
|
: o && typeof o == 'object' && typeof o.message == 'string'
|
|
6401
6456
|
? o.message
|
|
6402
6457
|
: `Tein answered with HTTP ${t}.`,
|
|
6403
|
-
|
|
6458
|
+
l = o && typeof o == 'object' && typeof o.code == 'string' ? o.code : null;
|
|
6404
6459
|
return {
|
|
6405
6460
|
jsonrpc: '2.0',
|
|
6406
6461
|
id: r,
|
|
6407
6462
|
error: {
|
|
6408
6463
|
code: t === 401 ? -32001 : -32603,
|
|
6409
6464
|
message: u,
|
|
6410
|
-
data: { status: t, ...(
|
|
6465
|
+
data: { status: t, ...(l ? { code: l } : {}) },
|
|
6411
6466
|
},
|
|
6412
6467
|
};
|
|
6413
6468
|
}
|
|
6414
|
-
function
|
|
6469
|
+
function fr() {
|
|
6415
6470
|
let e = process.argv.slice(2),
|
|
6416
6471
|
t = e.indexOf('--api-key');
|
|
6417
|
-
return
|
|
6472
|
+
return S(t >= 0 ? e[t + 1] : void 0);
|
|
6418
6473
|
}
|
|
6419
|
-
async function
|
|
6420
|
-
let r =
|
|
6421
|
-
if (!
|
|
6474
|
+
async function jt(e, t, i) {
|
|
6475
|
+
let r = U.default.resolve(e);
|
|
6476
|
+
if (!R.default.existsSync(r) || !R.default.statSync(r).isFile())
|
|
6422
6477
|
throw new Error(`File not found: ${e}`);
|
|
6423
|
-
let n =
|
|
6478
|
+
let n = R.default.readFileSync(r),
|
|
6424
6479
|
s = n.toString('base64'),
|
|
6425
6480
|
o = n.length,
|
|
6426
6481
|
u = `${i.replace(/\/$/, '')}/v1/upload`,
|
|
6427
|
-
|
|
6482
|
+
l = await fetch(u, {
|
|
6428
6483
|
method: 'POST',
|
|
6429
6484
|
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${t}` },
|
|
6430
6485
|
body: JSON.stringify({ data: s }),
|
|
6431
6486
|
});
|
|
6432
|
-
if (!
|
|
6433
|
-
let
|
|
6487
|
+
if (!l.ok) {
|
|
6488
|
+
let p = `Upload failed (HTTP ${l.status})`;
|
|
6434
6489
|
try {
|
|
6435
|
-
let
|
|
6436
|
-
|
|
6490
|
+
let d = await l.json();
|
|
6491
|
+
p = (typeof d.error == 'string' ? d.error : d.error?.message) || d.message || p;
|
|
6437
6492
|
} catch {}
|
|
6438
|
-
throw new Error(
|
|
6493
|
+
throw new Error(p);
|
|
6439
6494
|
}
|
|
6440
|
-
let
|
|
6495
|
+
let c = await l.json();
|
|
6441
6496
|
return {
|
|
6442
|
-
url:
|
|
6443
|
-
key:
|
|
6444
|
-
sizeBytes:
|
|
6445
|
-
mimeType:
|
|
6497
|
+
url: c.url,
|
|
6498
|
+
key: c.key,
|
|
6499
|
+
sizeBytes: c.size_bytes || o,
|
|
6500
|
+
mimeType: c.mime_type || c.mimeType || 'image/png',
|
|
6446
6501
|
};
|
|
6447
6502
|
}
|
|
6448
|
-
function jt(e) {
|
|
6449
|
-
return ur.has(N.default.extname(e).toLowerCase());
|
|
6450
|
-
}
|
|
6451
6503
|
function Bt(e) {
|
|
6504
|
+
return gr.has(U.default.extname(e).toLowerCase());
|
|
6505
|
+
}
|
|
6506
|
+
function Ft(e) {
|
|
6452
6507
|
return new Error(
|
|
6453
|
-
`Tein uploads image, video and audio files only, and ${
|
|
6508
|
+
`Tein uploads image, video and audio files only, and ${U.default.basename(e)} is not one.`,
|
|
6454
6509
|
);
|
|
6455
6510
|
}
|
|
6456
|
-
function
|
|
6511
|
+
function hr(e) {
|
|
6457
6512
|
let t = e.trim();
|
|
6458
6513
|
if (
|
|
6459
6514
|
!t ||
|
|
@@ -6463,10 +6518,10 @@ function mr(e) {
|
|
|
6463
6518
|
`)
|
|
6464
6519
|
)
|
|
6465
6520
|
return null;
|
|
6466
|
-
let i =
|
|
6467
|
-
return
|
|
6521
|
+
let i = U.default.resolve(t);
|
|
6522
|
+
return R.default.existsSync(i) && R.default.statSync(i).isFile() ? i : null;
|
|
6468
6523
|
}
|
|
6469
|
-
function
|
|
6524
|
+
function Ue(e) {
|
|
6470
6525
|
if (Array.isArray(e))
|
|
6471
6526
|
for (let t of e) {
|
|
6472
6527
|
let i = t;
|
|
@@ -6476,12 +6531,12 @@ function Ne(e) {
|
|
|
6476
6531
|
Q.set(i.name, i.inputSchema);
|
|
6477
6532
|
}
|
|
6478
6533
|
}
|
|
6479
|
-
function
|
|
6480
|
-
(Q.clear(), (
|
|
6534
|
+
function yr() {
|
|
6535
|
+
(Q.clear(), (Ne = 0));
|
|
6481
6536
|
}
|
|
6482
|
-
async function
|
|
6483
|
-
if (!(Date.now() -
|
|
6484
|
-
|
|
6537
|
+
async function br(e, t) {
|
|
6538
|
+
if (!(Date.now() - Ne < 6e4)) {
|
|
6539
|
+
Ne = Date.now();
|
|
6485
6540
|
try {
|
|
6486
6541
|
let r = await (
|
|
6487
6542
|
await fetch(e, {
|
|
@@ -6491,39 +6546,39 @@ async function gr(e, t) {
|
|
|
6491
6546
|
signal: AbortSignal.timeout(1e4),
|
|
6492
6547
|
})
|
|
6493
6548
|
).json();
|
|
6494
|
-
|
|
6549
|
+
Ue(r.result?.tools);
|
|
6495
6550
|
} catch {}
|
|
6496
6551
|
}
|
|
6497
6552
|
}
|
|
6498
|
-
function
|
|
6553
|
+
function wr(e) {
|
|
6499
6554
|
return e
|
|
6500
6555
|
? e.type === 'string'
|
|
6501
6556
|
? e.format === 'uri'
|
|
6502
6557
|
: e.type === 'array' && e.items?.format === 'uri'
|
|
6503
6558
|
: !1;
|
|
6504
6559
|
}
|
|
6505
|
-
async function
|
|
6560
|
+
async function Lt(e, t, i) {
|
|
6506
6561
|
if (typeof e != 'string') return e;
|
|
6507
|
-
let r =
|
|
6562
|
+
let r = hr(e);
|
|
6508
6563
|
if (!r) return e;
|
|
6509
|
-
if (!
|
|
6510
|
-
return (await
|
|
6564
|
+
if (!Bt(r)) throw Ft(r);
|
|
6565
|
+
return (await jt(r, t, i)).url;
|
|
6511
6566
|
}
|
|
6512
|
-
async function
|
|
6513
|
-
(Q.size === 0 &&
|
|
6567
|
+
async function Gt(e, t, i, r, n) {
|
|
6568
|
+
(Q.size === 0 && Ue(Ve()), Q.has(e) || (await br(n, i)));
|
|
6514
6569
|
let s = Q.get(e)?.properties;
|
|
6515
6570
|
if (!s) return t;
|
|
6516
6571
|
let o = { ...t };
|
|
6517
|
-
for (let [u,
|
|
6518
|
-
if (
|
|
6519
|
-
if (Array.isArray(
|
|
6520
|
-
let
|
|
6521
|
-
for (let
|
|
6522
|
-
o[u] =
|
|
6523
|
-
} else o[u] = await
|
|
6572
|
+
for (let [u, l] of Object.entries(t))
|
|
6573
|
+
if (wr(s[u]))
|
|
6574
|
+
if (Array.isArray(l)) {
|
|
6575
|
+
let c = [];
|
|
6576
|
+
for (let p of l) c.push(await Lt(p, i, r));
|
|
6577
|
+
o[u] = c;
|
|
6578
|
+
} else o[u] = await Lt(l, i, r);
|
|
6524
6579
|
return o;
|
|
6525
6580
|
}
|
|
6526
|
-
function
|
|
6581
|
+
function kr(e) {
|
|
6527
6582
|
let t = e.id ?? null;
|
|
6528
6583
|
switch (e.method) {
|
|
6529
6584
|
case 'initialize':
|
|
@@ -6541,7 +6596,7 @@ function yr(e) {
|
|
|
6541
6596
|
case 'ping':
|
|
6542
6597
|
return { jsonrpc: '2.0', id: t, result: {} };
|
|
6543
6598
|
case 'tools/list':
|
|
6544
|
-
return { jsonrpc: '2.0', id: t, result: { tools:
|
|
6599
|
+
return { jsonrpc: '2.0', id: t, result: { tools: Ve() } };
|
|
6545
6600
|
case 'tools/call':
|
|
6546
6601
|
return {
|
|
6547
6602
|
jsonrpc: '2.0',
|
|
@@ -6564,13 +6619,13 @@ function yr(e) {
|
|
|
6564
6619
|
};
|
|
6565
6620
|
}
|
|
6566
6621
|
}
|
|
6567
|
-
async function
|
|
6568
|
-
if (
|
|
6569
|
-
|
|
6570
|
-
let e =
|
|
6571
|
-
t =
|
|
6622
|
+
async function Jt() {
|
|
6623
|
+
if (Vt) return;
|
|
6624
|
+
Vt = !0;
|
|
6625
|
+
let e = fr(),
|
|
6626
|
+
t = x(),
|
|
6572
6627
|
i = process.env.TEIN_MCP_URL || 'https://mcp.tein.ai/mcp';
|
|
6573
|
-
(
|
|
6628
|
+
(Nt.default
|
|
6574
6629
|
.createInterface({ input: process.stdin, output: process.stdout, terminal: !1 })
|
|
6575
6630
|
.on('line', async (n) => {
|
|
6576
6631
|
let s = n.trim();
|
|
@@ -6578,14 +6633,14 @@ async function Gt() {
|
|
|
6578
6633
|
try {
|
|
6579
6634
|
let o = JSON.parse(s);
|
|
6580
6635
|
if (o && o.method === 'tools/call' && o.params) {
|
|
6581
|
-
let
|
|
6582
|
-
|
|
6583
|
-
if (
|
|
6584
|
-
let
|
|
6585
|
-
|
|
6636
|
+
let l = o.params.name,
|
|
6637
|
+
c = o.params.arguments || {};
|
|
6638
|
+
if (l === 'get_pricing') {
|
|
6639
|
+
let p = typeof c.model == 'string' ? c.model.trim() : '',
|
|
6640
|
+
d = `${t.replace(/\/+$/, '')}${ce(p)}`;
|
|
6586
6641
|
try {
|
|
6587
|
-
let m = await fetch(
|
|
6588
|
-
|
|
6642
|
+
let m = await fetch(d, { signal: AbortSignal.timeout(1e4) }),
|
|
6643
|
+
h = await m.text();
|
|
6589
6644
|
process.stdout.write(
|
|
6590
6645
|
JSON.stringify({
|
|
6591
6646
|
jsonrpc: '2.0',
|
|
@@ -6594,7 +6649,7 @@ async function Gt() {
|
|
|
6594
6649
|
content: [
|
|
6595
6650
|
{
|
|
6596
6651
|
type: 'text',
|
|
6597
|
-
text: m.ok ?
|
|
6652
|
+
text: m.ok ? h : `Pricing request failed (${m.status}). ${h}`,
|
|
6598
6653
|
},
|
|
6599
6654
|
],
|
|
6600
6655
|
isError: !m.ok,
|
|
@@ -6604,13 +6659,13 @@ async function Gt() {
|
|
|
6604
6659
|
`,
|
|
6605
6660
|
);
|
|
6606
6661
|
} catch (m) {
|
|
6607
|
-
let
|
|
6662
|
+
let h = m instanceof Error ? m.message : String(m);
|
|
6608
6663
|
process.stdout.write(
|
|
6609
6664
|
JSON.stringify({
|
|
6610
6665
|
jsonrpc: '2.0',
|
|
6611
6666
|
id: o.id,
|
|
6612
6667
|
result: {
|
|
6613
|
-
content: [{ type: 'text', text: `Could not reach Tein prices: ${
|
|
6668
|
+
content: [{ type: 'text', text: `Could not reach Tein prices: ${h}` }],
|
|
6614
6669
|
isError: !0,
|
|
6615
6670
|
},
|
|
6616
6671
|
}) +
|
|
@@ -6620,20 +6675,20 @@ async function Gt() {
|
|
|
6620
6675
|
}
|
|
6621
6676
|
return;
|
|
6622
6677
|
}
|
|
6623
|
-
if (
|
|
6624
|
-
let
|
|
6678
|
+
if (l === 'upload_asset' || l === 'upload_media' || l === 'upload_image') {
|
|
6679
|
+
let p = c.path || c.filepath || c.file_path || c.file || c.data;
|
|
6625
6680
|
if (
|
|
6626
|
-
typeof
|
|
6627
|
-
!
|
|
6628
|
-
!
|
|
6629
|
-
!
|
|
6681
|
+
typeof p == 'string' &&
|
|
6682
|
+
!p.startsWith('http://') &&
|
|
6683
|
+
!p.startsWith('https://') &&
|
|
6684
|
+
!p.startsWith('data:')
|
|
6630
6685
|
)
|
|
6631
6686
|
try {
|
|
6632
|
-
let
|
|
6633
|
-
if (
|
|
6634
|
-
if (!
|
|
6635
|
-
let m = await
|
|
6636
|
-
|
|
6687
|
+
let d = U.default.resolve(p.trim());
|
|
6688
|
+
if (R.default.existsSync(d) && R.default.statSync(d).isFile() && e) {
|
|
6689
|
+
if (!Bt(d)) throw Ft(d);
|
|
6690
|
+
let m = await jt(d, e, t),
|
|
6691
|
+
h = (m.sizeBytes / 1024).toFixed(1),
|
|
6637
6692
|
ue =
|
|
6638
6693
|
m.mimeType.startsWith('image/') ||
|
|
6639
6694
|
/\.(png|jpe?g|webp|gif|svg)$/i.test(m.url)
|
|
@@ -6641,7 +6696,7 @@ async function Gt() {
|
|
|
6641
6696
|
|
|
6642
6697
|
`
|
|
6643
6698
|
: '',
|
|
6644
|
-
|
|
6699
|
+
me = {
|
|
6645
6700
|
jsonrpc: '2.0',
|
|
6646
6701
|
id: o.id,
|
|
6647
6702
|
result: {
|
|
@@ -6652,7 +6707,7 @@ async function Gt() {
|
|
|
6652
6707
|
|
|
6653
6708
|
- **URL:** ${m.url}
|
|
6654
6709
|
- **Type:** \`${m.mimeType}\`
|
|
6655
|
-
- **Size:** ${
|
|
6710
|
+
- **Size:** ${h} KB${ue}
|
|
6656
6711
|
|
|
6657
6712
|
Pass this URL to any Tein generation tool.`,
|
|
6658
6713
|
},
|
|
@@ -6661,14 +6716,14 @@ Pass this URL to any Tein generation tool.`,
|
|
|
6661
6716
|
},
|
|
6662
6717
|
};
|
|
6663
6718
|
process.stdout.write(
|
|
6664
|
-
JSON.stringify(
|
|
6719
|
+
JSON.stringify(me) +
|
|
6665
6720
|
`
|
|
6666
6721
|
`,
|
|
6667
6722
|
);
|
|
6668
6723
|
return;
|
|
6669
6724
|
}
|
|
6670
|
-
} catch (
|
|
6671
|
-
let m =
|
|
6725
|
+
} catch (d) {
|
|
6726
|
+
let m = d instanceof Error ? d.message : String(d);
|
|
6672
6727
|
process.stdout.write(
|
|
6673
6728
|
JSON.stringify({
|
|
6674
6729
|
jsonrpc: '2.0',
|
|
@@ -6688,9 +6743,9 @@ Pass this URL to any Tein generation tool.`,
|
|
|
6688
6743
|
}
|
|
6689
6744
|
if (e)
|
|
6690
6745
|
try {
|
|
6691
|
-
o.params.arguments = await
|
|
6692
|
-
} catch (
|
|
6693
|
-
let
|
|
6746
|
+
o.params.arguments = await Gt(String(l), c, e, t, i);
|
|
6747
|
+
} catch (p) {
|
|
6748
|
+
let d = p instanceof Error ? p.message : String(p);
|
|
6694
6749
|
process.stdout.write(
|
|
6695
6750
|
JSON.stringify({
|
|
6696
6751
|
jsonrpc: '2.0',
|
|
@@ -6699,7 +6754,7 @@ Pass this URL to any Tein generation tool.`,
|
|
|
6699
6754
|
content: [
|
|
6700
6755
|
{
|
|
6701
6756
|
type: 'text',
|
|
6702
|
-
text: `Failed to read or upload a local file before calling Tein: ${
|
|
6757
|
+
text: `Failed to read or upload a local file before calling Tein: ${d}`,
|
|
6703
6758
|
},
|
|
6704
6759
|
],
|
|
6705
6760
|
isError: !0,
|
|
@@ -6713,25 +6768,25 @@ Pass this URL to any Tein generation tool.`,
|
|
|
6713
6768
|
}
|
|
6714
6769
|
if (e)
|
|
6715
6770
|
try {
|
|
6716
|
-
let
|
|
6771
|
+
let l = await fetch(i, {
|
|
6717
6772
|
method: 'POST',
|
|
6718
6773
|
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${e}` },
|
|
6719
6774
|
body: JSON.stringify(o),
|
|
6720
6775
|
}),
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
if (
|
|
6724
|
-
if (
|
|
6725
|
-
(o?.method === 'tools/list' &&
|
|
6776
|
+
c = await l.text(),
|
|
6777
|
+
p = Ut(o, l.status, c);
|
|
6778
|
+
if (p === null) return;
|
|
6779
|
+
if (p) {
|
|
6780
|
+
(o?.method === 'tools/list' && Ue(p.result?.tools),
|
|
6726
6781
|
process.stdout.write(
|
|
6727
|
-
JSON.stringify(
|
|
6782
|
+
JSON.stringify(p) +
|
|
6728
6783
|
`
|
|
6729
6784
|
`,
|
|
6730
6785
|
));
|
|
6731
6786
|
return;
|
|
6732
6787
|
}
|
|
6733
6788
|
} catch {}
|
|
6734
|
-
let u =
|
|
6789
|
+
let u = kr(o);
|
|
6735
6790
|
u !== null &&
|
|
6736
6791
|
process.stdout.write(
|
|
6737
6792
|
JSON.stringify(u) +
|
|
@@ -6754,22 +6809,22 @@ Pass this URL to any Tein generation tool.`,
|
|
|
6754
6809
|
process.stderr.write(`Tein AI MCP Server running on stdio transport.
|
|
6755
6810
|
`));
|
|
6756
6811
|
}
|
|
6757
|
-
var
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6812
|
+
var R,
|
|
6813
|
+
U,
|
|
6814
|
+
Nt,
|
|
6815
|
+
gr,
|
|
6761
6816
|
Q,
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6817
|
+
Ne,
|
|
6818
|
+
Vt,
|
|
6819
|
+
zt = b(() => {
|
|
6765
6820
|
'use strict';
|
|
6766
|
-
((
|
|
6767
|
-
(
|
|
6768
|
-
(
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6821
|
+
((R = I(require('node:fs'))),
|
|
6822
|
+
(U = I(require('node:path'))),
|
|
6823
|
+
(Nt = I(require('node:readline'))));
|
|
6824
|
+
qe();
|
|
6825
|
+
Dt();
|
|
6826
|
+
E();
|
|
6827
|
+
gr = new Set([
|
|
6773
6828
|
'.png',
|
|
6774
6829
|
'.jpg',
|
|
6775
6830
|
'.jpeg',
|
|
@@ -6795,42 +6850,42 @@ var A,
|
|
|
6795
6850
|
'.flac',
|
|
6796
6851
|
'.opus',
|
|
6797
6852
|
]);
|
|
6798
|
-
((Q = new Map()), (
|
|
6799
|
-
|
|
6853
|
+
((Q = new Map()), (Ne = 0));
|
|
6854
|
+
Vt = !1;
|
|
6800
6855
|
require.main === module &&
|
|
6801
|
-
|
|
6856
|
+
Jt().catch((e) => {
|
|
6802
6857
|
(process.stderr.write(`Fatal error in Tein MCP CLI: ${e}
|
|
6803
6858
|
`),
|
|
6804
6859
|
process.exit(1));
|
|
6805
6860
|
});
|
|
6806
6861
|
});
|
|
6807
|
-
var
|
|
6862
|
+
var ri =
|
|
6808
6863
|
!process.env.NO_COLOR &&
|
|
6809
6864
|
(process.stdout.isTTY || process.env.FORCE_COLOR === '1' || process.env.TERM !== 'dumb');
|
|
6810
|
-
function
|
|
6811
|
-
return (i) => (
|
|
6865
|
+
function w(e, t) {
|
|
6866
|
+
return (i) => (ri ? `\x1B[${e}m${i}\x1B[${t}m` : String(i));
|
|
6812
6867
|
}
|
|
6813
6868
|
var a = {
|
|
6814
|
-
bold:
|
|
6815
|
-
dim:
|
|
6816
|
-
italic:
|
|
6817
|
-
underline:
|
|
6818
|
-
inverse:
|
|
6819
|
-
black:
|
|
6820
|
-
red:
|
|
6821
|
-
green:
|
|
6822
|
-
yellow:
|
|
6823
|
-
blue:
|
|
6824
|
-
magenta:
|
|
6825
|
-
cyan:
|
|
6826
|
-
white:
|
|
6827
|
-
gray:
|
|
6828
|
-
bgBlue:
|
|
6829
|
-
bgMagenta:
|
|
6830
|
-
bgCyan:
|
|
6831
|
-
bgGreen:
|
|
6869
|
+
bold: w(1, 22),
|
|
6870
|
+
dim: w(2, 22),
|
|
6871
|
+
italic: w(3, 23),
|
|
6872
|
+
underline: w(4, 24),
|
|
6873
|
+
inverse: w(7, 27),
|
|
6874
|
+
black: w(30, 39),
|
|
6875
|
+
red: w(31, 39),
|
|
6876
|
+
green: w(32, 39),
|
|
6877
|
+
yellow: w(33, 39),
|
|
6878
|
+
blue: w(34, 39),
|
|
6879
|
+
magenta: w(35, 39),
|
|
6880
|
+
cyan: w(36, 39),
|
|
6881
|
+
white: w(37, 39),
|
|
6882
|
+
gray: w(90, 39),
|
|
6883
|
+
bgBlue: w(44, 49),
|
|
6884
|
+
bgMagenta: w(45, 49),
|
|
6885
|
+
bgCyan: w(46, 49),
|
|
6886
|
+
bgGreen: w(42, 49),
|
|
6832
6887
|
},
|
|
6833
|
-
|
|
6888
|
+
T = class {
|
|
6834
6889
|
constructor(t = '') {
|
|
6835
6890
|
this.frames = [
|
|
6836
6891
|
'\u280B',
|
|
@@ -6892,22 +6947,22 @@ var a = {
|
|
|
6892
6947
|
process.stdout.isTTY && process.stdout.write('\r\x1B[K'));
|
|
6893
6948
|
}
|
|
6894
6949
|
};
|
|
6895
|
-
var
|
|
6896
|
-
|
|
6897
|
-
var ee =
|
|
6898
|
-
|
|
6899
|
-
|
|
6950
|
+
var O = I(require('node:fs')),
|
|
6951
|
+
A = I(require('node:path'));
|
|
6952
|
+
var ee = I(require('node:fs')),
|
|
6953
|
+
Fe = I(require('node:path')),
|
|
6954
|
+
Ge = require('node:stream/promises');
|
|
6900
6955
|
var Z = '1.1.7';
|
|
6901
|
-
var
|
|
6956
|
+
var ai = new Set([
|
|
6902
6957
|
'account_suspended',
|
|
6903
6958
|
'account_terminated',
|
|
6904
6959
|
'creative_mode_restricted',
|
|
6905
6960
|
'unfiltered_restricted',
|
|
6906
6961
|
'workspace_paused',
|
|
6907
6962
|
]),
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6963
|
+
_ = 1,
|
|
6964
|
+
ni = 3,
|
|
6965
|
+
k = class extends Error {
|
|
6911
6966
|
constructor(t, i, r, n = {}) {
|
|
6912
6967
|
(super(i),
|
|
6913
6968
|
(this.name = 'TeinApiError'),
|
|
@@ -6916,29 +6971,29 @@ var ri = new Set([
|
|
|
6916
6971
|
(this.fields = n));
|
|
6917
6972
|
}
|
|
6918
6973
|
get exitCode() {
|
|
6919
|
-
return this.code &&
|
|
6974
|
+
return this.code && ai.has(this.code) ? ni : _;
|
|
6920
6975
|
}
|
|
6921
6976
|
};
|
|
6922
|
-
function
|
|
6977
|
+
function si(e, t, i) {
|
|
6923
6978
|
let r = `HTTP ${e}${t ? ` ${t}` : ''}`;
|
|
6924
|
-
if (!i || typeof i != 'object') return new
|
|
6979
|
+
if (!i || typeof i != 'object') return new k(e, r);
|
|
6925
6980
|
let n = i;
|
|
6926
6981
|
if (n.error && typeof n.error == 'object' && !Array.isArray(n.error)) {
|
|
6927
|
-
let
|
|
6928
|
-
{ code:
|
|
6929
|
-
return new
|
|
6982
|
+
let p = n.error,
|
|
6983
|
+
{ code: d, message: m, ...h } = p;
|
|
6984
|
+
return new k(e, typeof m == 'string' && m ? m : r, typeof d == 'string' ? d : void 0, h);
|
|
6930
6985
|
}
|
|
6931
|
-
let { error: s, code: o, message: u, ...
|
|
6932
|
-
|
|
6933
|
-
return new
|
|
6986
|
+
let { error: s, code: o, message: u, ...l } = n,
|
|
6987
|
+
c = (typeof s == 'string' && s) || (typeof u == 'string' && u) || r;
|
|
6988
|
+
return new k(e, c, typeof o == 'string' ? o : void 0, l);
|
|
6934
6989
|
}
|
|
6935
|
-
function
|
|
6990
|
+
function je(e) {
|
|
6936
6991
|
return typeof e == 'number' && Number.isFinite(e) ? `$${e.toFixed(4)}` : null;
|
|
6937
6992
|
}
|
|
6938
|
-
function
|
|
6993
|
+
function K(e) {
|
|
6939
6994
|
let t = [e.message],
|
|
6940
|
-
i =
|
|
6941
|
-
r =
|
|
6995
|
+
i = je(e.fields.required),
|
|
6996
|
+
r = je(e.fields.balance);
|
|
6942
6997
|
(i || r) &&
|
|
6943
6998
|
t.push([i ? `Required: ${i}` : '', r ? `Balance: ${r}` : ''].filter(Boolean).join(' '));
|
|
6944
6999
|
let n = e.fields.org_name ?? e.fields.orgName;
|
|
@@ -6946,22 +7001,22 @@ function M(e) {
|
|
|
6946
7001
|
let s = e.fields.url ?? e.fields.appeal_url ?? e.fields.top_up_url;
|
|
6947
7002
|
return (typeof s == 'string' && s && t.push(s), e.code && t.push(`(${e.code})`), t);
|
|
6948
7003
|
}
|
|
6949
|
-
function
|
|
7004
|
+
function oi(e) {
|
|
6950
7005
|
return /\.(mp4|webm|mov)(\?|$)/i.test(e)
|
|
6951
7006
|
? 'video'
|
|
6952
7007
|
: /\.(mp3|wav|ogg|flac)(\?|$)/i.test(e)
|
|
6953
7008
|
? 'audio'
|
|
6954
7009
|
: 'image';
|
|
6955
7010
|
}
|
|
6956
|
-
function
|
|
7011
|
+
function Be(e) {
|
|
6957
7012
|
let t = [];
|
|
6958
7013
|
for (let i of e.data ?? [])
|
|
6959
7014
|
typeof i.message?.content == 'string'
|
|
6960
7015
|
? t.push({ type: 'text', text: i.message.content })
|
|
6961
|
-
: i.url && t.push({ type:
|
|
7016
|
+
: i.url && t.push({ type: oi(i.url), url: i.url });
|
|
6962
7017
|
return t;
|
|
6963
7018
|
}
|
|
6964
|
-
var
|
|
7019
|
+
var M = class {
|
|
6965
7020
|
constructor(t, i) {
|
|
6966
7021
|
((this.apiKey = t), (this.baseUrl = i.replace(/\/+$/, '')));
|
|
6967
7022
|
}
|
|
@@ -6984,16 +7039,13 @@ var T = class {
|
|
|
6984
7039
|
try {
|
|
6985
7040
|
s = await n.json();
|
|
6986
7041
|
} catch {}
|
|
6987
|
-
throw
|
|
7042
|
+
throw si(n.status, n.statusText, s);
|
|
6988
7043
|
}
|
|
6989
7044
|
return await n.json();
|
|
6990
7045
|
}
|
|
6991
7046
|
async checkKey() {
|
|
6992
7047
|
await this.send('GET', '/v1/jobs?limit=1');
|
|
6993
7048
|
}
|
|
6994
|
-
runJob(t, i) {
|
|
6995
|
-
return this.send('POST', '/v1/run', { model: t, parameters: i });
|
|
6996
|
-
}
|
|
6997
7049
|
queueJob(t, i) {
|
|
6998
7050
|
return this.send('POST', '/v1/generate', { model: t, ...i }).then((r) => {
|
|
6999
7051
|
let n = r.status,
|
|
@@ -7001,7 +7053,7 @@ var T = class {
|
|
|
7001
7053
|
n === 'succeeded' || n === 'failed' || n === 'expired' || n === 'cancelled'
|
|
7002
7054
|
? n
|
|
7003
7055
|
: 'processing',
|
|
7004
|
-
o =
|
|
7056
|
+
o = Be(r);
|
|
7005
7057
|
return {
|
|
7006
7058
|
request_id: r.request_id || r.id || '',
|
|
7007
7059
|
model: r.model,
|
|
@@ -7019,7 +7071,7 @@ var T = class {
|
|
|
7019
7071
|
r === 'succeeded' || r === 'failed' || r === 'expired' || r === 'cancelled'
|
|
7020
7072
|
? r
|
|
7021
7073
|
: 'processing',
|
|
7022
|
-
s =
|
|
7074
|
+
s = Be(i),
|
|
7023
7075
|
o = i.error && typeof i.error.message == 'string' ? i.error.message : null;
|
|
7024
7076
|
return {
|
|
7025
7077
|
request_id: i.id || t,
|
|
@@ -7037,50 +7089,50 @@ var T = class {
|
|
|
7037
7089
|
async downloadOutput(t, i) {
|
|
7038
7090
|
let r = await fetch(t);
|
|
7039
7091
|
if (!r.ok) throw new Error(`The file could not be downloaded (HTTP ${r.status})`);
|
|
7040
|
-
let n =
|
|
7092
|
+
let n = Fe.default.dirname(i);
|
|
7041
7093
|
ee.default.existsSync(n) || ee.default.mkdirSync(n, { recursive: !0 });
|
|
7042
7094
|
let s = ee.default.createWriteStream(i);
|
|
7043
|
-
return (await (0,
|
|
7095
|
+
return (await (0, Ge.pipeline)(r.body, s), i);
|
|
7044
7096
|
}
|
|
7045
7097
|
};
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
var
|
|
7049
|
-
function
|
|
7050
|
-
for (let t of
|
|
7098
|
+
E();
|
|
7099
|
+
z();
|
|
7100
|
+
var _t = ['images', 'input_images', 'videos', 'audios'];
|
|
7101
|
+
function Vi(e) {
|
|
7102
|
+
for (let t of _t) typeof e[t] == 'string' && (e[t] = [e[t]]);
|
|
7051
7103
|
}
|
|
7052
|
-
function
|
|
7104
|
+
function Ni(e) {
|
|
7053
7105
|
if (e.startsWith('http://') || e.startsWith('https://')) return null;
|
|
7054
|
-
let t =
|
|
7055
|
-
return
|
|
7106
|
+
let t = A.default.resolve(e);
|
|
7107
|
+
return O.default.existsSync(t) && O.default.statSync(t).isFile() ? t : null;
|
|
7056
7108
|
}
|
|
7057
|
-
async function
|
|
7058
|
-
for (let i of
|
|
7109
|
+
async function Ui(e, t) {
|
|
7110
|
+
for (let i of _t) {
|
|
7059
7111
|
if (!Array.isArray(e[i])) continue;
|
|
7060
7112
|
let r = [];
|
|
7061
7113
|
for (let n of e[i]) {
|
|
7062
7114
|
if (typeof n != 'string') continue;
|
|
7063
|
-
let s =
|
|
7115
|
+
let s = Ni(n);
|
|
7064
7116
|
r.push(s ? await t(s) : n);
|
|
7065
7117
|
}
|
|
7066
7118
|
e[i] = r;
|
|
7067
7119
|
}
|
|
7068
7120
|
}
|
|
7069
|
-
var
|
|
7070
|
-
function
|
|
7121
|
+
var W = { starter: 10, plus: 25, scale: 40, enterprise: 300 };
|
|
7122
|
+
function ji(e) {
|
|
7071
7123
|
if (e.count === void 0 || e.count === !0) return 1;
|
|
7072
7124
|
let t = typeof e.count == 'number' ? e.count : Number(e.count),
|
|
7073
|
-
i =
|
|
7125
|
+
i = W.enterprise;
|
|
7074
7126
|
return (
|
|
7075
7127
|
(!Number.isInteger(t) || t < 1 || t > i) &&
|
|
7076
7128
|
(process.stderr
|
|
7077
|
-
.write(`${a.red('Error:')} --count must be a whole number from 1 to ${i}. The API allows Starter ${
|
|
7129
|
+
.write(`${a.red('Error:')} --count must be a whole number from 1 to ${i}. The API allows Starter ${W.starter}, Plus ${W.plus}, Scale ${W.scale}, Enterprise ${W.enterprise} at once, including polling.
|
|
7078
7130
|
`),
|
|
7079
7131
|
process.exit(1)),
|
|
7080
7132
|
t
|
|
7081
7133
|
);
|
|
7082
7134
|
}
|
|
7083
|
-
async function
|
|
7135
|
+
async function Bi(e, t, i, r, n) {
|
|
7084
7136
|
n.isJson ||
|
|
7085
7137
|
process.stderr.write(`Starting ${r} ${t} jobs together...
|
|
7086
7138
|
`);
|
|
@@ -7088,51 +7140,51 @@ async function Ni(e, t, i, r, n) {
|
|
|
7088
7140
|
Array.from({ length: r }, async () => {
|
|
7089
7141
|
try {
|
|
7090
7142
|
return { job: await e.queueJob(t, i) };
|
|
7091
|
-
} catch (
|
|
7092
|
-
return { err:
|
|
7143
|
+
} catch (l) {
|
|
7144
|
+
return { err: l };
|
|
7093
7145
|
}
|
|
7094
7146
|
}),
|
|
7095
7147
|
),
|
|
7096
7148
|
o = [],
|
|
7097
7149
|
u = [];
|
|
7098
|
-
for (let
|
|
7099
|
-
'job' in
|
|
7100
|
-
? o.push(
|
|
7101
|
-
: 'err' in
|
|
7150
|
+
for (let l of s)
|
|
7151
|
+
'job' in l && l.job
|
|
7152
|
+
? o.push(l.job)
|
|
7153
|
+
: 'err' in l &&
|
|
7102
7154
|
u.push(
|
|
7103
|
-
|
|
7104
|
-
?
|
|
7105
|
-
: new
|
|
7155
|
+
l.err instanceof k
|
|
7156
|
+
? l.err
|
|
7157
|
+
: new k(0, l.err instanceof Error ? l.err.message : String(l.err)),
|
|
7106
7158
|
);
|
|
7107
7159
|
if (!n.isAsync) {
|
|
7108
|
-
let
|
|
7109
|
-
|
|
7110
|
-
for (;
|
|
7111
|
-
if ((await new Promise((
|
|
7112
|
-
let
|
|
7113
|
-
process.stderr.write(`Waiting on ${
|
|
7160
|
+
let l = Date.now(),
|
|
7161
|
+
c = o.filter((p) => p.status === 'processing' && p.request_id);
|
|
7162
|
+
for (; c.length;) {
|
|
7163
|
+
if ((await new Promise((d) => setTimeout(d, 2e3)), !n.isJson)) {
|
|
7164
|
+
let d = Math.round((Date.now() - l) / 1e3);
|
|
7165
|
+
process.stderr.write(`Waiting on ${c.length} of ${r} (${d}s)...
|
|
7114
7166
|
`);
|
|
7115
7167
|
}
|
|
7116
|
-
let
|
|
7117
|
-
|
|
7168
|
+
let p = await Promise.all(
|
|
7169
|
+
c.map(async (d) => {
|
|
7118
7170
|
try {
|
|
7119
|
-
return await e.getStatus(
|
|
7171
|
+
return await e.getStatus(d.request_id);
|
|
7120
7172
|
} catch {
|
|
7121
|
-
return
|
|
7173
|
+
return d;
|
|
7122
7174
|
}
|
|
7123
7175
|
}),
|
|
7124
7176
|
);
|
|
7125
|
-
for (let
|
|
7126
|
-
let m = o.findIndex((
|
|
7127
|
-
m >= 0 && (o[m] =
|
|
7177
|
+
for (let d of p) {
|
|
7178
|
+
let m = o.findIndex((h) => h.request_id === d.request_id);
|
|
7179
|
+
m >= 0 && (o[m] = d);
|
|
7128
7180
|
}
|
|
7129
|
-
|
|
7181
|
+
c = o.filter((d) => d.status === 'processing' && d.request_id);
|
|
7130
7182
|
}
|
|
7131
7183
|
}
|
|
7132
7184
|
if (n.isJson)
|
|
7133
7185
|
process.stdout.write(
|
|
7134
7186
|
JSON.stringify(
|
|
7135
|
-
{ jobs: o, errors: u.map((
|
|
7187
|
+
{ jobs: o, errors: u.map((l) => ({ code: l.code ?? null, message: l.message })) },
|
|
7136
7188
|
null,
|
|
7137
7189
|
2,
|
|
7138
7190
|
) +
|
|
@@ -7140,22 +7192,22 @@ async function Ni(e, t, i, r, n) {
|
|
|
7140
7192
|
`,
|
|
7141
7193
|
);
|
|
7142
7194
|
else {
|
|
7143
|
-
for (let
|
|
7144
|
-
(process.stdout.write(`${
|
|
7145
|
-
|
|
7146
|
-
|
|
7195
|
+
for (let l of o)
|
|
7196
|
+
(process.stdout.write(`${l.request_id} ${l.status}`),
|
|
7197
|
+
l.usage?.cost !== void 0 && process.stdout.write(` $${l.usage.cost.toFixed(4)}`),
|
|
7198
|
+
l.error && process.stdout.write(` ${l.error}`),
|
|
7147
7199
|
process.stdout.write(`
|
|
7148
7200
|
`));
|
|
7149
|
-
for (let
|
|
7150
|
-
process.stderr.write(`${
|
|
7201
|
+
for (let l of u)
|
|
7202
|
+
process.stderr.write(`${K(l).join(`
|
|
7151
7203
|
`)}
|
|
7152
7204
|
`);
|
|
7153
7205
|
}
|
|
7154
7206
|
(u.length ||
|
|
7155
|
-
o.some((
|
|
7156
|
-
process.exit(
|
|
7207
|
+
o.some((l) => l.status === 'failed' || l.status === 'expired' || l.status === 'cancelled')) &&
|
|
7208
|
+
process.exit(_);
|
|
7157
7209
|
}
|
|
7158
|
-
function
|
|
7210
|
+
function Pt(e) {
|
|
7159
7211
|
let t = {},
|
|
7160
7212
|
i = new Set(),
|
|
7161
7213
|
r = [];
|
|
@@ -7164,8 +7216,8 @@ function _t(e) {
|
|
|
7164
7216
|
if (s.startsWith('--')) {
|
|
7165
7217
|
let o = s.slice(2);
|
|
7166
7218
|
if (o.includes('=')) {
|
|
7167
|
-
let [u,
|
|
7168
|
-
t[u.replace(/-/g, '_')] =
|
|
7219
|
+
let [u, l] = o.split('=', 2);
|
|
7220
|
+
t[u.replace(/-/g, '_')] = l;
|
|
7169
7221
|
} else if (n + 1 < e.length && !e[n + 1].startsWith('-')) {
|
|
7170
7222
|
let u = e[n + 1];
|
|
7171
7223
|
(u === 'true'
|
|
@@ -7179,7 +7231,7 @@ function _t(e) {
|
|
|
7179
7231
|
} else ((t[o.replace(/-/g, '_')] = !0), i.add(o));
|
|
7180
7232
|
} else if (s.startsWith('-') && s.length === 2) {
|
|
7181
7233
|
let o = s[1],
|
|
7182
|
-
|
|
7234
|
+
l =
|
|
7183
7235
|
{
|
|
7184
7236
|
p: 'prompt',
|
|
7185
7237
|
o: 'output',
|
|
@@ -7192,17 +7244,17 @@ function _t(e) {
|
|
|
7192
7244
|
v: 'version',
|
|
7193
7245
|
}[o] || o;
|
|
7194
7246
|
o === 'j' || o === 'h' || o === 'v'
|
|
7195
|
-
? ((t[
|
|
7247
|
+
? ((t[l] = !0), i.add(l))
|
|
7196
7248
|
: n + 1 < e.length && !e[n + 1].startsWith('-')
|
|
7197
|
-
? ((t[
|
|
7198
|
-
: (t[
|
|
7249
|
+
? ((t[l] = e[n + 1]), n++)
|
|
7250
|
+
: (t[l] = !0);
|
|
7199
7251
|
} else r.push(s);
|
|
7200
7252
|
}
|
|
7201
7253
|
return { command: r[0] || '', subcommand: r[1], modelSlug: r[1] || r[0], options: t, flags: i };
|
|
7202
7254
|
}
|
|
7203
|
-
async function
|
|
7204
|
-
let i =
|
|
7205
|
-
r =
|
|
7255
|
+
async function Ee(e, t) {
|
|
7256
|
+
let i = S(typeof t.api_key == 'string' ? t.api_key : void 0),
|
|
7257
|
+
r = x(typeof t.api_url == 'string' ? t.api_url : void 0);
|
|
7206
7258
|
(i ||
|
|
7207
7259
|
(process.stderr.write(`${a.red('Error:')} Authentication required.
|
|
7208
7260
|
`),
|
|
@@ -7218,46 +7270,39 @@ async function Ce(e, t) {
|
|
|
7218
7270
|
process.stderr.write(`Run ${a.cyan('tein models')} to list all available models.
|
|
7219
7271
|
`),
|
|
7220
7272
|
process.exit(1)));
|
|
7221
|
-
let n =
|
|
7273
|
+
let n = N(e),
|
|
7222
7274
|
s = !!t.json,
|
|
7223
7275
|
o = !!(t.async || t.no_wait),
|
|
7224
7276
|
u = typeof t.output == 'string' ? t.output : void 0,
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
delete
|
|
7230
|
-
delete
|
|
7231
|
-
delete
|
|
7232
|
-
delete
|
|
7233
|
-
delete
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
l[h.name] === void 0 &&
|
|
7240
|
-
vt(n.slug, h.name, t) &&
|
|
7241
|
-
(l[h.name] = h.default);
|
|
7242
|
-
(Oi(l),
|
|
7243
|
-
typeof l.image == 'string' && !l.images && ((l.images = [l.image]), delete l.image),
|
|
7244
|
-
l.image_url &&
|
|
7245
|
-
!l.first_frame_image &&
|
|
7277
|
+
l = ji(t),
|
|
7278
|
+
c = { ...t };
|
|
7279
|
+
(delete c.json,
|
|
7280
|
+
delete c.async,
|
|
7281
|
+
delete c.no_wait,
|
|
7282
|
+
delete c.output,
|
|
7283
|
+
delete c.api_key,
|
|
7284
|
+
delete c.api_url,
|
|
7285
|
+
delete c.count);
|
|
7286
|
+
let p = It(n, c);
|
|
7287
|
+
(Vi(p),
|
|
7288
|
+
typeof p.image == 'string' && !p.images && ((p.images = [p.image]), delete p.image),
|
|
7289
|
+
p.image_url &&
|
|
7290
|
+
!p.first_frame_image &&
|
|
7246
7291
|
(e.startsWith('seedance') || e.startsWith('happy-horse')) &&
|
|
7247
|
-
(
|
|
7248
|
-
let d = new
|
|
7249
|
-
|
|
7250
|
-
for (let
|
|
7251
|
-
let
|
|
7252
|
-
if (typeof
|
|
7253
|
-
let
|
|
7254
|
-
if (
|
|
7255
|
-
let
|
|
7256
|
-
s ||
|
|
7292
|
+
(p.first_frame_image = p.image_url));
|
|
7293
|
+
let d = new M(i, r),
|
|
7294
|
+
m = ['image', 'first_frame_image', 'last_frame_image', 'lipsyncing_audio', 'audio', 'video'];
|
|
7295
|
+
for (let y of m) {
|
|
7296
|
+
let f = p[y];
|
|
7297
|
+
if (typeof f == 'string' && !f.startsWith('http://') && !f.startsWith('https://')) {
|
|
7298
|
+
let v = A.default.resolve(f);
|
|
7299
|
+
if (O.default.existsSync(v) && O.default.statSync(v).isFile()) {
|
|
7300
|
+
let P = new T(`Uploading local file ${A.default.basename(v)} to CDN...`);
|
|
7301
|
+
s || P.start();
|
|
7257
7302
|
try {
|
|
7258
|
-
let j =
|
|
7303
|
+
let j = O.default.readFileSync(v),
|
|
7259
7304
|
X = await d.uploadAsset(j.toString('base64'));
|
|
7260
|
-
((
|
|
7305
|
+
((p[y] = X.url), s || P.succeed(`Uploaded ${A.default.basename(v)} to CDN`));
|
|
7261
7306
|
} catch (j) {
|
|
7262
7307
|
let X = j instanceof Error ? j.message : String(j);
|
|
7263
7308
|
(s
|
|
@@ -7266,108 +7311,108 @@ async function Ce(e, t) {
|
|
|
7266
7311
|
`
|
|
7267
7312
|
`,
|
|
7268
7313
|
)
|
|
7269
|
-
:
|
|
7314
|
+
: P.fail(`Upload failed: ${X}`),
|
|
7270
7315
|
process.exit(1));
|
|
7271
7316
|
}
|
|
7272
7317
|
}
|
|
7273
7318
|
}
|
|
7274
7319
|
}
|
|
7275
|
-
await
|
|
7276
|
-
let
|
|
7277
|
-
s ||
|
|
7320
|
+
await Ui(p, async (y) => {
|
|
7321
|
+
let f = new T(`Uploading local file ${A.default.basename(y)} to CDN...`);
|
|
7322
|
+
s || f.start();
|
|
7278
7323
|
try {
|
|
7279
|
-
let
|
|
7280
|
-
|
|
7281
|
-
return (s ||
|
|
7282
|
-
} catch (
|
|
7283
|
-
let
|
|
7324
|
+
let v = O.default.readFileSync(y),
|
|
7325
|
+
P = await d.uploadAsset(v.toString('base64'));
|
|
7326
|
+
return (s || f.succeed(`Uploaded ${A.default.basename(y)} to CDN`), P.url);
|
|
7327
|
+
} catch (v) {
|
|
7328
|
+
let P = v instanceof Error ? v.message : String(v);
|
|
7284
7329
|
(s
|
|
7285
7330
|
? process.stdout.write(
|
|
7286
|
-
JSON.stringify({ error:
|
|
7331
|
+
JSON.stringify({ error: P }) +
|
|
7287
7332
|
`
|
|
7288
7333
|
`,
|
|
7289
7334
|
)
|
|
7290
|
-
:
|
|
7335
|
+
: f.fail(`Upload failed: ${P}`),
|
|
7291
7336
|
process.exit(1));
|
|
7292
7337
|
}
|
|
7293
7338
|
});
|
|
7294
|
-
let
|
|
7295
|
-
s ||
|
|
7296
|
-
let
|
|
7339
|
+
let h = new T(`Submitting task for ${a.bold(e)}...`);
|
|
7340
|
+
s || h.start();
|
|
7341
|
+
let g;
|
|
7297
7342
|
try {
|
|
7298
|
-
if (
|
|
7299
|
-
await
|
|
7343
|
+
if (l > 1) {
|
|
7344
|
+
await Bi(d, e, p, l, { isJson: s, isAsync: o });
|
|
7300
7345
|
return;
|
|
7301
7346
|
}
|
|
7302
|
-
|
|
7303
|
-
} catch (
|
|
7304
|
-
let
|
|
7347
|
+
g = await d.queueJob(e, p);
|
|
7348
|
+
} catch (y) {
|
|
7349
|
+
let f = y instanceof k ? y : null;
|
|
7305
7350
|
(s
|
|
7306
7351
|
? process.stdout.write(
|
|
7307
7352
|
JSON.stringify(
|
|
7308
|
-
|
|
7309
|
-
? { error: { code:
|
|
7310
|
-
: { error: { code: null, message:
|
|
7353
|
+
f
|
|
7354
|
+
? { error: { code: f.code ?? null, message: f.message, ...f.fields } }
|
|
7355
|
+
: { error: { code: null, message: y instanceof Error ? y.message : String(y) } },
|
|
7311
7356
|
null,
|
|
7312
7357
|
2,
|
|
7313
7358
|
) +
|
|
7314
7359
|
`
|
|
7315
7360
|
`,
|
|
7316
7361
|
)
|
|
7317
|
-
:
|
|
7318
|
-
|
|
7319
|
-
?
|
|
7362
|
+
: h.fail(
|
|
7363
|
+
f
|
|
7364
|
+
? K(f).join(`
|
|
7320
7365
|
`)
|
|
7321
|
-
: `Failed to start generation: ${
|
|
7366
|
+
: `Failed to start generation: ${y instanceof Error ? y.message : y}`,
|
|
7322
7367
|
),
|
|
7323
|
-
process.exit(
|
|
7368
|
+
process.exit(f ? f.exitCode : _));
|
|
7324
7369
|
}
|
|
7325
7370
|
if (o) {
|
|
7326
7371
|
s
|
|
7327
7372
|
? process.stdout.write(
|
|
7328
|
-
JSON.stringify(
|
|
7373
|
+
JSON.stringify(g, null, 2) +
|
|
7329
7374
|
`
|
|
7330
7375
|
`,
|
|
7331
7376
|
)
|
|
7332
|
-
: (
|
|
7333
|
-
process.stdout.write(`Check status anytime with: ${a.cyan(`tein status ${
|
|
7377
|
+
: (h.succeed(`Queued successfully! Request ID: ${a.bold(g.request_id)}`),
|
|
7378
|
+
process.stdout.write(`Check status anytime with: ${a.cyan(`tein status ${g.request_id}`)}
|
|
7334
7379
|
`));
|
|
7335
7380
|
return;
|
|
7336
7381
|
}
|
|
7337
|
-
let
|
|
7338
|
-
|
|
7339
|
-
for (;
|
|
7340
|
-
let
|
|
7341
|
-
(s ||
|
|
7342
|
-
await new Promise((
|
|
7382
|
+
let ue = Date.now(),
|
|
7383
|
+
me = 1500;
|
|
7384
|
+
for (; g.status === 'processing';) {
|
|
7385
|
+
let y = Math.round((Date.now() - ue) / 1e3);
|
|
7386
|
+
(s || h.update(`Rendering ${a.bold(e)} (${y}s elapsed)... [ID: ${g.request_id}]`),
|
|
7387
|
+
await new Promise((f) => setTimeout(f, me)));
|
|
7343
7388
|
try {
|
|
7344
|
-
|
|
7345
|
-
} catch (
|
|
7346
|
-
|
|
7347
|
-
|
|
7389
|
+
g = await d.getStatus(g.request_id);
|
|
7390
|
+
} catch (f) {
|
|
7391
|
+
f instanceof k &&
|
|
7392
|
+
f.exitCode !== _ &&
|
|
7348
7393
|
(s ||
|
|
7349
|
-
|
|
7350
|
-
|
|
7394
|
+
h.fail(
|
|
7395
|
+
K(f).join(`
|
|
7351
7396
|
`),
|
|
7352
7397
|
),
|
|
7353
|
-
process.exit(
|
|
7398
|
+
process.exit(f.exitCode));
|
|
7354
7399
|
}
|
|
7355
7400
|
}
|
|
7356
7401
|
if (
|
|
7357
|
-
((
|
|
7402
|
+
((g.status === 'failed' || g.status === 'expired' || g.status === 'cancelled') &&
|
|
7358
7403
|
(s
|
|
7359
7404
|
? process.stdout.write(
|
|
7360
|
-
JSON.stringify(
|
|
7405
|
+
JSON.stringify(g, null, 2) +
|
|
7361
7406
|
`
|
|
7362
7407
|
`,
|
|
7363
7408
|
)
|
|
7364
|
-
:
|
|
7365
|
-
process.exit(
|
|
7366
|
-
s ||
|
|
7409
|
+
: h.fail(`Generation ${g.status}: ${g.error || 'Something failed on our side.'}`),
|
|
7410
|
+
process.exit(_)),
|
|
7411
|
+
s || h.succeed(`Generation completed for ${a.bold(n?.name || e)}!`),
|
|
7367
7412
|
s)
|
|
7368
7413
|
) {
|
|
7369
7414
|
process.stdout.write(
|
|
7370
|
-
JSON.stringify(
|
|
7415
|
+
JSON.stringify(g, null, 2) +
|
|
7371
7416
|
`
|
|
7372
7417
|
`,
|
|
7373
7418
|
);
|
|
@@ -7378,57 +7423,57 @@ async function Ce(e, t) {
|
|
|
7378
7423
|
`),
|
|
7379
7424
|
process.stdout.write(` ${a.bold('Status:')} ${a.green('Succeeded')}
|
|
7380
7425
|
`),
|
|
7381
|
-
process.stdout.write(` ${a.bold('Request ID:')} ${
|
|
7426
|
+
process.stdout.write(` ${a.bold('Request ID:')} ${g.request_id}
|
|
7382
7427
|
`),
|
|
7383
|
-
|
|
7384
|
-
process.stdout.write(` ${a.bold('Cost:')} $${
|
|
7428
|
+
g.usage?.cost !== void 0 &&
|
|
7429
|
+
process.stdout.write(` ${a.bold('Cost:')} $${g.usage.cost.toFixed(4)}
|
|
7385
7430
|
`),
|
|
7386
|
-
|
|
7431
|
+
g.output && g.output.length > 0)
|
|
7387
7432
|
) {
|
|
7388
7433
|
process.stdout.write(`
|
|
7389
7434
|
${a.bold('Outputs:')}
|
|
7390
7435
|
`);
|
|
7391
|
-
for (let
|
|
7392
|
-
let
|
|
7393
|
-
if (
|
|
7436
|
+
for (let y = 0; y < g.output.length; y++) {
|
|
7437
|
+
let f = g.output[y];
|
|
7438
|
+
if (f.url) {
|
|
7394
7439
|
if (
|
|
7395
|
-
(process.stdout.write(` [${
|
|
7440
|
+
(process.stdout.write(` [${f.type.toUpperCase()}] ${a.cyan(a.underline(f.url))}
|
|
7396
7441
|
`),
|
|
7397
7442
|
u)
|
|
7398
7443
|
) {
|
|
7399
|
-
let
|
|
7444
|
+
let v = new T(`Downloading output to ${u}...`).start();
|
|
7400
7445
|
try {
|
|
7401
|
-
(await d.downloadOutput(
|
|
7402
|
-
|
|
7403
|
-
} catch (
|
|
7404
|
-
|
|
7446
|
+
(await d.downloadOutput(f.url, A.default.resolve(process.cwd(), u)),
|
|
7447
|
+
v.succeed(`Saved to ${a.bold(u)}`));
|
|
7448
|
+
} catch (P) {
|
|
7449
|
+
v.fail(`Failed to download: ${P instanceof Error ? P.message : P}`);
|
|
7405
7450
|
}
|
|
7406
7451
|
}
|
|
7407
7452
|
} else
|
|
7408
|
-
|
|
7453
|
+
f.text &&
|
|
7409
7454
|
process.stdout.write(`
|
|
7410
|
-
${
|
|
7455
|
+
${f.text}
|
|
7411
7456
|
`);
|
|
7412
7457
|
}
|
|
7413
7458
|
}
|
|
7414
7459
|
process.stdout.write(`
|
|
7415
7460
|
`);
|
|
7416
7461
|
}
|
|
7417
|
-
var
|
|
7418
|
-
|
|
7419
|
-
async function
|
|
7462
|
+
var Tt = I(require('node:readline'));
|
|
7463
|
+
E();
|
|
7464
|
+
async function Fi(e) {
|
|
7420
7465
|
try {
|
|
7421
|
-
return (await new
|
|
7466
|
+
return (await new M(e, x()).checkKey(), 'ok');
|
|
7422
7467
|
} catch (t) {
|
|
7423
|
-
if (t instanceof
|
|
7468
|
+
if (t instanceof k) {
|
|
7424
7469
|
if (t.status === 401) return 'invalid';
|
|
7425
7470
|
if (t.status === 403) return 'blocked';
|
|
7426
7471
|
}
|
|
7427
7472
|
return 'unchecked';
|
|
7428
7473
|
}
|
|
7429
7474
|
}
|
|
7430
|
-
function
|
|
7431
|
-
let t =
|
|
7475
|
+
function Gi(e) {
|
|
7476
|
+
let t = Tt.default.createInterface({ input: process.stdin, output: process.stdout });
|
|
7432
7477
|
return new Promise((i) => {
|
|
7433
7478
|
t.question(e, (r) => {
|
|
7434
7479
|
(t.close(), i(r.trim()));
|
|
@@ -7447,20 +7492,20 @@ ${a.bold('Tein AI Authentication')}
|
|
|
7447
7492
|
process.stdout.write(`Get your API key at: ${a.cyan('https://tein.ai/dashboard/keys')}
|
|
7448
7493
|
|
|
7449
7494
|
`),
|
|
7450
|
-
(i = await
|
|
7495
|
+
(i = await Gi('Enter your Tein API Key (sk_live_...): '))),
|
|
7451
7496
|
!i.startsWith('sk_live_') &&
|
|
7452
7497
|
!i.startsWith('sk_test_') &&
|
|
7453
7498
|
(process.stderr
|
|
7454
7499
|
.write(`${a.red('Error:')} Invalid key format. Tein API keys start with 'sk_live_' or 'sk_test_'.
|
|
7455
7500
|
`),
|
|
7456
7501
|
process.exit(1)));
|
|
7457
|
-
let r = await
|
|
7502
|
+
let r = await Fi(i);
|
|
7458
7503
|
(r === 'invalid' &&
|
|
7459
7504
|
(process.stderr
|
|
7460
7505
|
.write(`${a.red('Error:')} Tein did not accept this key. Copy it again from ${a.cyan('https://tein.ai/dashboard/keys')}. Nothing was saved.
|
|
7461
7506
|
`),
|
|
7462
7507
|
process.exit(1)),
|
|
7463
|
-
|
|
7508
|
+
he({ apiKey: i }),
|
|
7464
7509
|
process.stdout.write(`
|
|
7465
7510
|
${a.green('\u2713')} API key saved to ${a.dim(ie())}
|
|
7466
7511
|
`),
|
|
@@ -7479,22 +7524,22 @@ ${a.green('\u2713')} API key saved to ${a.dim(ie())}
|
|
|
7479
7524
|
break;
|
|
7480
7525
|
}
|
|
7481
7526
|
case 'logout': {
|
|
7482
|
-
if (!
|
|
7527
|
+
if (!L().apiKey) {
|
|
7483
7528
|
process.stdout
|
|
7484
7529
|
.write(`${a.yellow('\u2139')} No active API key found. You are already logged out.
|
|
7485
7530
|
`);
|
|
7486
7531
|
break;
|
|
7487
7532
|
}
|
|
7488
|
-
(
|
|
7533
|
+
(he({ apiKey: '' }),
|
|
7489
7534
|
process.stdout
|
|
7490
7535
|
.write(`${a.green('\u2713')} Logged out successfully. Stored API key has been cleared from ${a.dim(ie())}
|
|
7491
7536
|
`));
|
|
7492
7537
|
break;
|
|
7493
7538
|
}
|
|
7494
7539
|
default: {
|
|
7495
|
-
let i =
|
|
7496
|
-
r =
|
|
7497
|
-
n =
|
|
7540
|
+
let i = S(),
|
|
7541
|
+
r = x(),
|
|
7542
|
+
n = L();
|
|
7498
7543
|
if (
|
|
7499
7544
|
(process.stdout.write(`
|
|
7500
7545
|
${a.bold('Tein AI CLI Configuration')}
|
|
@@ -7523,13 +7568,13 @@ ${a.bold('Tein AI CLI Configuration')}
|
|
|
7523
7568
|
}
|
|
7524
7569
|
}
|
|
7525
7570
|
}
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
var
|
|
7530
|
-
async function
|
|
7571
|
+
E();
|
|
7572
|
+
ye();
|
|
7573
|
+
z();
|
|
7574
|
+
var Ji = 3e3;
|
|
7575
|
+
async function Mt(e) {
|
|
7531
7576
|
try {
|
|
7532
|
-
let t = await fetch(`${
|
|
7577
|
+
let t = await fetch(`${x(e)}/v1/pricing`, { signal: AbortSignal.timeout(Ji) });
|
|
7533
7578
|
if (!t.ok) return;
|
|
7534
7579
|
let i = await t.json(),
|
|
7535
7580
|
r = {};
|
|
@@ -7537,18 +7582,18 @@ async function Tt(e) {
|
|
|
7537
7582
|
let s = String(n.modelSlug ?? '');
|
|
7538
7583
|
B.has(s) && (r[s] ??= []).push(Number(n.starterPrice));
|
|
7539
7584
|
}
|
|
7540
|
-
|
|
7585
|
+
gt(r);
|
|
7541
7586
|
} catch {}
|
|
7542
7587
|
}
|
|
7543
|
-
var
|
|
7544
|
-
|
|
7545
|
-
async function
|
|
7546
|
-
await
|
|
7547
|
-
let i =
|
|
7588
|
+
var Hi = new Set(['video', 'image', 'text', 'audio', '3d']),
|
|
7589
|
+
zi = { llm: 'text', chat: 'text', reasoning: 'text' };
|
|
7590
|
+
async function Kt(e, t) {
|
|
7591
|
+
await Mt(t);
|
|
7592
|
+
let i = q();
|
|
7548
7593
|
if (e) {
|
|
7549
7594
|
let s = e.toLowerCase(),
|
|
7550
|
-
o =
|
|
7551
|
-
i =
|
|
7595
|
+
o = zi[s] ?? s;
|
|
7596
|
+
i = Hi.has(o)
|
|
7552
7597
|
? i.filter((u) => u.category.toLowerCase() === o)
|
|
7553
7598
|
: i.filter((u) => u.kind.toLowerCase().includes(s) || u.slug.toLowerCase().includes(s));
|
|
7554
7599
|
}
|
|
@@ -7571,10 +7616,10 @@ ${a.bold('Tein AI Models Catalog')} (${i.length} available)
|
|
|
7571
7616
|
process.stdout.write(`${a.bold(a.cyan(`\u2500\u2500 ${s} Models \u2500\u2500`))}
|
|
7572
7617
|
`);
|
|
7573
7618
|
for (let u of o) {
|
|
7574
|
-
let
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
process.stdout.write(` ${a.bold(
|
|
7619
|
+
let l = u.slug.padEnd(24),
|
|
7620
|
+
c = u.name.padEnd(22),
|
|
7621
|
+
p = u.priceFormatted.padEnd(22);
|
|
7622
|
+
process.stdout.write(` ${a.bold(l)} ${a.gray(c)} ${a.green(p)} ${a.dim(u.vendor)}
|
|
7578
7623
|
`);
|
|
7579
7624
|
}
|
|
7580
7625
|
process.stdout.write(`
|
|
@@ -7586,9 +7631,9 @@ ${a.bold('Tein AI Models Catalog')} (${i.length} available)
|
|
|
7586
7631
|
|
|
7587
7632
|
`);
|
|
7588
7633
|
}
|
|
7589
|
-
async function
|
|
7590
|
-
B.has(e) && (await
|
|
7591
|
-
let i =
|
|
7634
|
+
async function St(e, t) {
|
|
7635
|
+
B.has(e) && (await Mt(t));
|
|
7636
|
+
let i = N(e);
|
|
7592
7637
|
(i ||
|
|
7593
7638
|
(process.stderr.write(`${a.red('Error:')} Model "${e}" not found in Tein AI registry.
|
|
7594
7639
|
`),
|
|
@@ -7667,10 +7712,10 @@ ${a.bold(a.cyan(i.name))} (${a.bold(i.slug)})
|
|
|
7667
7712
|
|
|
7668
7713
|
`);
|
|
7669
7714
|
}
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
var
|
|
7673
|
-
|
|
7715
|
+
E();
|
|
7716
|
+
qe();
|
|
7717
|
+
var Wi = 1e4,
|
|
7718
|
+
Re = {
|
|
7674
7719
|
price: '',
|
|
7675
7720
|
creativeMode: 'Creative mode',
|
|
7676
7721
|
priority: 'Priority',
|
|
@@ -7680,22 +7725,22 @@ var Ji = 1e4,
|
|
|
7680
7725
|
priorityDraft: 'Priority + Draft',
|
|
7681
7726
|
creativeModePriorityDraft: 'Creative mode + Priority + Draft',
|
|
7682
7727
|
},
|
|
7683
|
-
|
|
7684
|
-
|
|
7728
|
+
Yi = Object.keys(Re),
|
|
7729
|
+
Qi = {
|
|
7685
7730
|
creativeMode: 'unfiltered',
|
|
7686
7731
|
creativeModePriority: 'unfilteredPriority',
|
|
7687
7732
|
creativeModeDraft: 'unfilteredDraft',
|
|
7688
7733
|
creativeModePriorityDraft: 'unfilteredPriorityDraft',
|
|
7689
7734
|
};
|
|
7690
|
-
function
|
|
7691
|
-
let i =
|
|
7735
|
+
function Xi(e, t) {
|
|
7736
|
+
let i = Qi[t];
|
|
7692
7737
|
return e[t] ?? (i ? e[i] : void 0);
|
|
7693
7738
|
}
|
|
7694
|
-
async function
|
|
7695
|
-
let i = `${
|
|
7739
|
+
async function Zi(e, t) {
|
|
7740
|
+
let i = `${x(e)}${ce(t)}`,
|
|
7696
7741
|
r;
|
|
7697
7742
|
try {
|
|
7698
|
-
r = await fetch(i, { signal: AbortSignal.timeout(
|
|
7743
|
+
r = await fetch(i, { signal: AbortSignal.timeout(Wi) });
|
|
7699
7744
|
} catch {
|
|
7700
7745
|
throw new Error(`Could not reach ${i}`);
|
|
7701
7746
|
}
|
|
@@ -7711,18 +7756,18 @@ async function Yi(e, t) {
|
|
|
7711
7756
|
}
|
|
7712
7757
|
return n;
|
|
7713
7758
|
}
|
|
7714
|
-
function
|
|
7759
|
+
function Ae(e) {
|
|
7715
7760
|
let t = e.toFixed(4).replace(/0+$/, '').replace(/\.$/, ''),
|
|
7716
7761
|
[i, r = ''] = t.split('.');
|
|
7717
7762
|
return `$${i}.${r.padEnd(2, '0')}`;
|
|
7718
7763
|
}
|
|
7719
|
-
function
|
|
7764
|
+
function Oe(e) {
|
|
7720
7765
|
if (!e || typeof e.starter != 'number') return null;
|
|
7721
7766
|
let t = typeof e.plus == 'number' ? e.plus : e.starter,
|
|
7722
7767
|
i = typeof e.scale == 'number' ? e.scale : t;
|
|
7723
|
-
return `Starter ${
|
|
7768
|
+
return `Starter ${Ae(e.starter)} Plus ${Ae(t)} Scale ${Ae(i)}`;
|
|
7724
7769
|
}
|
|
7725
|
-
function
|
|
7770
|
+
function er(e) {
|
|
7726
7771
|
if (typeof e.label == 'string' && e.label.trim()) return e.label.trim();
|
|
7727
7772
|
let t = [];
|
|
7728
7773
|
for (let i of ['endpoint', 'resolution', 'quality', 'mode', 'task', 'component', 'token']) {
|
|
@@ -7734,33 +7779,33 @@ function Qi(e) {
|
|
|
7734
7779
|
t.length ? t.join(' \xB7 ') : String(e.id ?? 'default')
|
|
7735
7780
|
);
|
|
7736
7781
|
}
|
|
7737
|
-
function
|
|
7738
|
-
let i =
|
|
7739
|
-
for (let r of
|
|
7740
|
-
let n =
|
|
7782
|
+
function tr(e, t) {
|
|
7783
|
+
let i = er(e);
|
|
7784
|
+
for (let r of Yi) {
|
|
7785
|
+
let n = Oe(Xi(e, r));
|
|
7741
7786
|
if (!n) continue;
|
|
7742
|
-
let s =
|
|
7787
|
+
let s = Re[r] ? ` (${Re[r]})` : '';
|
|
7743
7788
|
t.push(` ${i}${s} ${n}`);
|
|
7744
7789
|
}
|
|
7745
7790
|
}
|
|
7746
|
-
function
|
|
7791
|
+
function ir(e, t) {
|
|
7747
7792
|
let i = e.quality ? ` quality=${e.quality}` : '';
|
|
7748
7793
|
t.push(
|
|
7749
7794
|
` ${a.bold(e.slug.padEnd(26))} ${a.gray(e.name)} ${a.dim(`${e.kind} ${e.unit} model=${e.model}${i}`)}`,
|
|
7750
7795
|
);
|
|
7751
|
-
for (let n of e.variants ?? [])
|
|
7796
|
+
for (let n of e.variants ?? []) tr(n, t);
|
|
7752
7797
|
let r = e.addons;
|
|
7753
7798
|
if (Array.isArray(r))
|
|
7754
7799
|
for (let n of r) {
|
|
7755
7800
|
if (!n || typeof n != 'object') continue;
|
|
7756
7801
|
let s = n,
|
|
7757
7802
|
o = typeof s.label == 'string' ? s.label : String(s.id ?? 'add-on'),
|
|
7758
|
-
u =
|
|
7803
|
+
u = Oe(s.price);
|
|
7759
7804
|
u && t.push(` ${o} (add-on) ${u}`);
|
|
7760
7805
|
}
|
|
7761
7806
|
t.push('');
|
|
7762
7807
|
}
|
|
7763
|
-
function
|
|
7808
|
+
function rr(e) {
|
|
7764
7809
|
let t = [],
|
|
7765
7810
|
i = e.board.checked ? ` \xB7 checked ${e.board.checked}` : '';
|
|
7766
7811
|
(t.push(`${a.bold('Tein prices')} ${a.green(e.currency)} ${e.count} models${i}`),
|
|
@@ -7769,38 +7814,38 @@ function er(e) {
|
|
|
7769
7814
|
),
|
|
7770
7815
|
t.push(''));
|
|
7771
7816
|
let r = new Map();
|
|
7772
|
-
for (let
|
|
7773
|
-
let
|
|
7774
|
-
|
|
7775
|
-
(
|
|
7817
|
+
for (let l of e.board.models) {
|
|
7818
|
+
let c = l.kind || 'other',
|
|
7819
|
+
p = r.get(c) ?? [];
|
|
7820
|
+
(p.push(l), r.set(c, p));
|
|
7776
7821
|
}
|
|
7777
7822
|
let n = ['video', 'image', 'audio', 'llm', 'text', '3d'],
|
|
7778
|
-
s = [...r.keys()].sort((
|
|
7779
|
-
let
|
|
7780
|
-
|
|
7781
|
-
return (
|
|
7823
|
+
s = [...r.keys()].sort((l, c) => {
|
|
7824
|
+
let p = n.indexOf(l),
|
|
7825
|
+
d = n.indexOf(c);
|
|
7826
|
+
return (p === -1 ? 99 : p) - (d === -1 ? 99 : d);
|
|
7782
7827
|
});
|
|
7783
|
-
for (let
|
|
7784
|
-
t.push(`${a.bold(a.cyan(`\u2500\u2500 ${
|
|
7785
|
-
for (let
|
|
7828
|
+
for (let l of s) {
|
|
7829
|
+
t.push(`${a.bold(a.cyan(`\u2500\u2500 ${l} \u2500\u2500`))}`);
|
|
7830
|
+
for (let c of r.get(l) ?? []) ir(c, t);
|
|
7786
7831
|
}
|
|
7787
|
-
let o = new Set(e.board.models.map((
|
|
7788
|
-
u = (e.configs ?? []).filter((
|
|
7832
|
+
let o = new Set(e.board.models.map((l) => l.slug.toLowerCase())),
|
|
7833
|
+
u = (e.configs ?? []).filter((l) => !o.has(String(l.modelSlug ?? '').toLowerCase()));
|
|
7789
7834
|
if (u.length) {
|
|
7790
7835
|
t.push(`${a.bold(a.cyan('\u2500\u2500 other prices \u2500\u2500'))}`);
|
|
7791
|
-
let
|
|
7792
|
-
for (let
|
|
7793
|
-
let
|
|
7794
|
-
|
|
7795
|
-
(
|
|
7836
|
+
let l = new Map();
|
|
7837
|
+
for (let c of u) {
|
|
7838
|
+
let p = String(c.modelSlug ?? ''),
|
|
7839
|
+
d = l.get(p) ?? [];
|
|
7840
|
+
(d.push(c), l.set(p, d));
|
|
7796
7841
|
}
|
|
7797
|
-
for (let [
|
|
7798
|
-
let
|
|
7799
|
-
t.push(` ${a.bold(
|
|
7800
|
-
for (let m of
|
|
7801
|
-
let
|
|
7802
|
-
|
|
7803
|
-
|
|
7842
|
+
for (let [c, p] of l) {
|
|
7843
|
+
let d = String(p[0]?.modelName ?? c);
|
|
7844
|
+
t.push(` ${a.bold(c.padEnd(26))} ${a.gray(d)}`);
|
|
7845
|
+
for (let m of p) {
|
|
7846
|
+
let h = String(m.displayLabel ?? m.billingUnit ?? 'price'),
|
|
7847
|
+
g = Oe(m.prices);
|
|
7848
|
+
g && t.push(` ${h} ${g}`);
|
|
7804
7849
|
}
|
|
7805
7850
|
t.push('');
|
|
7806
7851
|
}
|
|
@@ -7812,10 +7857,10 @@ function er(e) {
|
|
|
7812
7857
|
`
|
|
7813
7858
|
);
|
|
7814
7859
|
}
|
|
7815
|
-
async function
|
|
7860
|
+
async function $t(e) {
|
|
7816
7861
|
let t;
|
|
7817
7862
|
try {
|
|
7818
|
-
t = await
|
|
7863
|
+
t = await Zi(e.apiUrl, e.model);
|
|
7819
7864
|
} catch (i) {
|
|
7820
7865
|
let r = i instanceof Error ? i.message : String(i);
|
|
7821
7866
|
(process.stderr.write(`${a.red('Error:')} ${r}
|
|
@@ -7826,14 +7871,14 @@ async function St(e) {
|
|
|
7826
7871
|
e.json
|
|
7827
7872
|
? `${JSON.stringify(t, null, 2)}
|
|
7828
7873
|
`
|
|
7829
|
-
:
|
|
7874
|
+
: rr(t),
|
|
7830
7875
|
);
|
|
7831
7876
|
}
|
|
7832
|
-
var
|
|
7833
|
-
|
|
7834
|
-
async function
|
|
7835
|
-
let i =
|
|
7836
|
-
r =
|
|
7877
|
+
var Ct = I(require('node:path'));
|
|
7878
|
+
E();
|
|
7879
|
+
async function Et(e, t) {
|
|
7880
|
+
let i = S(typeof t.api_key == 'string' ? t.api_key : void 0),
|
|
7881
|
+
r = x(typeof t.api_url == 'string' ? t.api_url : void 0);
|
|
7837
7882
|
(i ||
|
|
7838
7883
|
(process.stderr.write(`${a.red('Error:')} Authentication required.
|
|
7839
7884
|
`),
|
|
@@ -7850,54 +7895,54 @@ async function Ct(e, t) {
|
|
|
7850
7895
|
let n = !!t.json,
|
|
7851
7896
|
s = !!t.wait,
|
|
7852
7897
|
o = typeof t.output == 'string' ? t.output : void 0,
|
|
7853
|
-
u = new
|
|
7854
|
-
|
|
7855
|
-
n ||
|
|
7856
|
-
let
|
|
7898
|
+
u = new M(i, r),
|
|
7899
|
+
l = new T(`Checking status of ${a.bold(e)}...`);
|
|
7900
|
+
n || l.start();
|
|
7901
|
+
let c;
|
|
7857
7902
|
try {
|
|
7858
|
-
|
|
7859
|
-
} catch (
|
|
7860
|
-
(
|
|
7903
|
+
c = await u.getStatus(e);
|
|
7904
|
+
} catch (p) {
|
|
7905
|
+
(p instanceof k &&
|
|
7861
7906
|
(n
|
|
7862
7907
|
? process.stdout.write(
|
|
7863
7908
|
JSON.stringify(
|
|
7864
|
-
{ error: { code:
|
|
7909
|
+
{ error: { code: p.code ?? null, message: p.message, ...p.fields } },
|
|
7865
7910
|
null,
|
|
7866
7911
|
2,
|
|
7867
7912
|
) +
|
|
7868
7913
|
`
|
|
7869
7914
|
`,
|
|
7870
7915
|
)
|
|
7871
|
-
:
|
|
7872
|
-
|
|
7916
|
+
: l.fail(
|
|
7917
|
+
K(p).join(`
|
|
7873
7918
|
`),
|
|
7874
7919
|
),
|
|
7875
|
-
process.exit(
|
|
7876
|
-
n ||
|
|
7877
|
-
process.exit(
|
|
7920
|
+
process.exit(p.exitCode)),
|
|
7921
|
+
n || l.fail(p instanceof Error ? p.message : String(p)),
|
|
7922
|
+
process.exit(_));
|
|
7878
7923
|
}
|
|
7879
|
-
if (s &&
|
|
7880
|
-
let
|
|
7881
|
-
for (;
|
|
7882
|
-
let
|
|
7883
|
-
(n ||
|
|
7924
|
+
if (s && c.status === 'processing') {
|
|
7925
|
+
let p = Date.now();
|
|
7926
|
+
for (; c.status === 'processing';) {
|
|
7927
|
+
let d = Math.round((Date.now() - p) / 1e3);
|
|
7928
|
+
(n || l.update(`Waiting for ${a.bold(c.model)} (${d}s elapsed)...`),
|
|
7884
7929
|
await new Promise((m) => setTimeout(m, 1500)));
|
|
7885
7930
|
try {
|
|
7886
|
-
|
|
7931
|
+
c = await u.getStatus(e);
|
|
7887
7932
|
} catch {}
|
|
7888
7933
|
}
|
|
7889
7934
|
}
|
|
7890
7935
|
if (
|
|
7891
7936
|
(n ||
|
|
7892
|
-
(
|
|
7893
|
-
?
|
|
7894
|
-
:
|
|
7895
|
-
?
|
|
7896
|
-
:
|
|
7937
|
+
(c.status === 'succeeded'
|
|
7938
|
+
? l.succeed('Task completed!')
|
|
7939
|
+
: c.status === 'failed' || c.status === 'expired' || c.status === 'cancelled'
|
|
7940
|
+
? l.fail(`Task ${c.status}: ${c.error || 'Something failed on our side.'}`)
|
|
7941
|
+
: l.stop()),
|
|
7897
7942
|
n)
|
|
7898
7943
|
) {
|
|
7899
7944
|
process.stdout.write(
|
|
7900
|
-
JSON.stringify(
|
|
7945
|
+
JSON.stringify(c, null, 2) +
|
|
7901
7946
|
`
|
|
7902
7947
|
`,
|
|
7903
7948
|
);
|
|
@@ -7905,48 +7950,48 @@ async function Ct(e, t) {
|
|
|
7905
7950
|
}
|
|
7906
7951
|
if (
|
|
7907
7952
|
(process.stdout.write(`
|
|
7908
|
-
${a.bold('Model:')} ${
|
|
7953
|
+
${a.bold('Model:')} ${c.model}
|
|
7909
7954
|
`),
|
|
7910
7955
|
process.stdout
|
|
7911
|
-
.write(` ${a.bold('Status:')} ${
|
|
7956
|
+
.write(` ${a.bold('Status:')} ${c.status === 'succeeded' ? a.green(c.status) : c.status === 'processing' ? a.yellow(c.status) : a.red(c.status)}
|
|
7912
7957
|
`),
|
|
7913
|
-
process.stdout.write(` ${a.bold('Request ID:')} ${
|
|
7958
|
+
process.stdout.write(` ${a.bold('Request ID:')} ${c.request_id}
|
|
7914
7959
|
`),
|
|
7915
|
-
|
|
7960
|
+
c.output && c.output.length > 0)
|
|
7916
7961
|
) {
|
|
7917
7962
|
process.stdout.write(`
|
|
7918
7963
|
${a.bold('Outputs:')}
|
|
7919
7964
|
`);
|
|
7920
|
-
for (let
|
|
7921
|
-
if (
|
|
7965
|
+
for (let p of c.output)
|
|
7966
|
+
if (p.url) {
|
|
7922
7967
|
if (
|
|
7923
|
-
(process.stdout.write(` [${
|
|
7968
|
+
(process.stdout.write(` [${p.type.toUpperCase()}] ${a.cyan(a.underline(p.url))}
|
|
7924
7969
|
`),
|
|
7925
7970
|
o)
|
|
7926
7971
|
) {
|
|
7927
|
-
let
|
|
7972
|
+
let d = new T(`Downloading output to ${o}...`).start();
|
|
7928
7973
|
try {
|
|
7929
|
-
(await u.downloadOutput(
|
|
7930
|
-
|
|
7974
|
+
(await u.downloadOutput(p.url, Ct.default.resolve(process.cwd(), o)),
|
|
7975
|
+
d.succeed(`Saved to ${a.bold(o)}`));
|
|
7931
7976
|
} catch (m) {
|
|
7932
|
-
|
|
7977
|
+
d.fail(`Failed to download: ${m instanceof Error ? m.message : m}`);
|
|
7933
7978
|
}
|
|
7934
7979
|
}
|
|
7935
7980
|
} else
|
|
7936
|
-
|
|
7981
|
+
p.text &&
|
|
7937
7982
|
process.stdout.write(`
|
|
7938
|
-
${
|
|
7983
|
+
${p.text}
|
|
7939
7984
|
`);
|
|
7940
7985
|
}
|
|
7941
7986
|
process.stdout.write(`
|
|
7942
7987
|
`);
|
|
7943
7988
|
}
|
|
7944
|
-
var
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
async function
|
|
7948
|
-
let i =
|
|
7949
|
-
r =
|
|
7989
|
+
var De = I(require('node:fs')),
|
|
7990
|
+
Le = I(require('node:path'));
|
|
7991
|
+
E();
|
|
7992
|
+
async function qt(e, t = {}) {
|
|
7993
|
+
let i = S(typeof t.api_key == 'string' ? t.api_key : void 0),
|
|
7994
|
+
r = x(typeof t.api_url == 'string' ? t.api_url : void 0),
|
|
7950
7995
|
n = !!t.json;
|
|
7951
7996
|
(i ||
|
|
7952
7997
|
(process.stderr.write(`${a.red('Error:')} Authentication required.
|
|
@@ -7961,55 +8006,55 @@ async function Et(e, t = {}) {
|
|
|
7961
8006
|
process.stderr.write(`Usage: ${a.cyan('tein upload <image.png|video.mp4>')}
|
|
7962
8007
|
`),
|
|
7963
8008
|
process.exit(1)));
|
|
7964
|
-
let s =
|
|
7965
|
-
|
|
8009
|
+
let s = Le.default.resolve(e);
|
|
8010
|
+
De.default.existsSync(s) ||
|
|
7966
8011
|
(process.stderr.write(`${a.red('Error:')} File not found: ${s}
|
|
7967
8012
|
`),
|
|
7968
8013
|
process.exit(1));
|
|
7969
|
-
let o =
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
n ||
|
|
8014
|
+
let o = Le.default.basename(s),
|
|
8015
|
+
l = De.default.readFileSync(s).toString('base64'),
|
|
8016
|
+
c = new M(i, r),
|
|
8017
|
+
p = new T(`Uploading ${a.bold(o)} to Tein AI CDN...`);
|
|
8018
|
+
n || p.start();
|
|
7974
8019
|
try {
|
|
7975
|
-
let
|
|
8020
|
+
let d = await c.uploadAsset(l);
|
|
7976
8021
|
n
|
|
7977
8022
|
? process.stdout.write(
|
|
7978
|
-
JSON.stringify(
|
|
8023
|
+
JSON.stringify(d, null, 2) +
|
|
7979
8024
|
`
|
|
7980
8025
|
`,
|
|
7981
8026
|
)
|
|
7982
|
-
: (
|
|
8027
|
+
: (p.succeed('Upload successful!'),
|
|
7983
8028
|
process.stdout.write(`
|
|
7984
|
-
${a.bold('CDN URL:')} ${a.green(
|
|
8029
|
+
${a.bold('CDN URL:')} ${a.green(d.url)}
|
|
7985
8030
|
`),
|
|
7986
|
-
process.stdout.write(`${a.dim(`Key: ${
|
|
8031
|
+
process.stdout.write(`${a.dim(`Key: ${d.key}`)}
|
|
7987
8032
|
|
|
7988
8033
|
`),
|
|
7989
8034
|
process.stdout.write(`Use this CDN URL directly in your CLI runs:
|
|
7990
|
-
${a.cyan(`tein run seedance-2-5 --prompt "Animate this scene" --image "${
|
|
8035
|
+
${a.cyan(`tein run seedance-2-5 --prompt "Animate this scene" --image "${d.url}"`)}
|
|
7991
8036
|
|
|
7992
8037
|
`));
|
|
7993
|
-
} catch (
|
|
7994
|
-
let m =
|
|
7995
|
-
|
|
7996
|
-
?
|
|
8038
|
+
} catch (d) {
|
|
8039
|
+
let m = d instanceof k ? d : null,
|
|
8040
|
+
h = m
|
|
8041
|
+
? K(m).join(`
|
|
7997
8042
|
`)
|
|
7998
|
-
:
|
|
7999
|
-
?
|
|
8000
|
-
: String(
|
|
8043
|
+
: d instanceof Error
|
|
8044
|
+
? d.message
|
|
8045
|
+
: String(d);
|
|
8001
8046
|
(n
|
|
8002
8047
|
? process.stdout.write(
|
|
8003
|
-
JSON.stringify({ error: { code: m?.code ?? null, message: m?.message ??
|
|
8048
|
+
JSON.stringify({ error: { code: m?.code ?? null, message: m?.message ?? h } }, null, 2) +
|
|
8004
8049
|
`
|
|
8005
8050
|
`,
|
|
8006
8051
|
)
|
|
8007
|
-
:
|
|
8008
|
-
process.exit(m ? m.exitCode :
|
|
8052
|
+
: p.fail(`Upload failed: ${h}`),
|
|
8053
|
+
process.exit(m ? m.exitCode : _));
|
|
8009
8054
|
}
|
|
8010
8055
|
}
|
|
8011
|
-
|
|
8012
|
-
|
|
8056
|
+
z();
|
|
8057
|
+
Pe();
|
|
8013
8058
|
function Wt() {
|
|
8014
8059
|
process.stdout.write(`
|
|
8015
8060
|
${a.bold(a.cyan('Tein AI CLI'))} - Official Command-Line Interface for Tein AI models
|
|
@@ -8037,6 +8082,7 @@ ${a.bold('GENERATION OPTIONS (for `tein run`):')}
|
|
|
8037
8082
|
${a.cyan('-s, --speaker')} <speaker_id> Voice speaker ID for audio TTS models
|
|
8038
8083
|
${a.cyan('--image')} <url> Input image URL for image-to-video or image-to-image
|
|
8039
8084
|
${a.cyan('--generate-audio')} Enable native synchronized audio (Seedance 2.5)
|
|
8085
|
+
${a.cyan('--finalize')} <job-id> Render a Seedance 2.5 draft at 1080p, or 4K with -r 4k (no prompt)
|
|
8040
8086
|
${a.cyan('--callback-url')} <url> HTTPS URL that receives the finished job
|
|
8041
8087
|
${a.cyan('--async, --no-wait')} Queue task and return request ID immediately
|
|
8042
8088
|
${a.cyan('--json')} Output response in raw JSON format
|
|
@@ -8058,6 +8104,8 @@ ${a.bold('EXAMPLES:')}
|
|
|
8058
8104
|
|
|
8059
8105
|
${a.dim('# 5. Generate a video using Seedance 2.5 with audio')}
|
|
8060
8106
|
${a.cyan('tein run seedance-2-5 --prompt "Drone shot of ocean waves at sunrise" --duration 5 -o ocean.mp4')}
|
|
8107
|
+
${a.dim('# The same at 4K (10-bit H.265; add --creative-mode true for Creative mode)')}
|
|
8108
|
+
${a.cyan('tein run seedance-2-5 --prompt "Drone shot of ocean waves at sunrise" --duration 5 -r 4k -o ocean-4k.mp4')}
|
|
8061
8109
|
|
|
8062
8110
|
${a.dim('# 6. Generate speech with Seed Audio 1.0')}
|
|
8063
8111
|
${a.cyan('tein run seed-audio-1-0 --prompt "Welcome to Tein AI CLI" -o welcome.wav')}
|
|
@@ -8067,9 +8115,9 @@ ${a.bold('EXAMPLES:')}
|
|
|
8067
8115
|
|
|
8068
8116
|
`);
|
|
8069
8117
|
}
|
|
8070
|
-
async function
|
|
8118
|
+
async function xr() {
|
|
8071
8119
|
let e = process.argv.slice(2),
|
|
8072
|
-
t =
|
|
8120
|
+
t = Pt(e);
|
|
8073
8121
|
if (t.flags.has('help') || t.options.help || t.command === 'help') {
|
|
8074
8122
|
Wt();
|
|
8075
8123
|
return;
|
|
@@ -8098,14 +8146,14 @@ async function br() {
|
|
|
8098
8146
|
}
|
|
8099
8147
|
case 'models':
|
|
8100
8148
|
case 'list': {
|
|
8101
|
-
await
|
|
8149
|
+
await Kt(t.subcommand, typeof t.options.api_url == 'string' ? t.options.api_url : void 0);
|
|
8102
8150
|
break;
|
|
8103
8151
|
}
|
|
8104
8152
|
case 'pricing':
|
|
8105
8153
|
case 'prices': {
|
|
8106
8154
|
let i = t.options.model,
|
|
8107
8155
|
r = t.subcommand || (typeof i == 'string' ? i : void 0);
|
|
8108
|
-
await
|
|
8156
|
+
await $t({
|
|
8109
8157
|
model: r,
|
|
8110
8158
|
json: !!t.options.json,
|
|
8111
8159
|
apiUrl: typeof t.options.api_url == 'string' ? t.options.api_url : void 0,
|
|
@@ -8120,40 +8168,40 @@ async function br() {
|
|
|
8120
8168
|
process.stderr.write(`Usage: ${a.cyan('tein info <model-slug>')}
|
|
8121
8169
|
`),
|
|
8122
8170
|
process.exit(1)),
|
|
8123
|
-
await
|
|
8171
|
+
await St(t.subcommand, typeof t.options.api_url == 'string' ? t.options.api_url : void 0));
|
|
8124
8172
|
break;
|
|
8125
8173
|
}
|
|
8126
8174
|
case 'upload': {
|
|
8127
8175
|
let i = t.subcommand || '';
|
|
8128
|
-
await
|
|
8176
|
+
await qt(i, t.options);
|
|
8129
8177
|
break;
|
|
8130
8178
|
}
|
|
8131
8179
|
case 'run':
|
|
8132
8180
|
case 'generate': {
|
|
8133
8181
|
let i = t.subcommand || '';
|
|
8134
|
-
await
|
|
8182
|
+
await Ee(i, t.options);
|
|
8135
8183
|
break;
|
|
8136
8184
|
}
|
|
8137
8185
|
case 'status': {
|
|
8138
8186
|
let i = t.subcommand || '';
|
|
8139
|
-
await
|
|
8187
|
+
await Et(i, t.options);
|
|
8140
8188
|
break;
|
|
8141
8189
|
}
|
|
8142
8190
|
case 'mcp': {
|
|
8143
|
-
let { startStdioServer: i } = await Promise.resolve().then(() => (
|
|
8191
|
+
let { startStdioServer: i } = await Promise.resolve().then(() => (zt(), Ht));
|
|
8144
8192
|
await i();
|
|
8145
8193
|
break;
|
|
8146
8194
|
}
|
|
8147
8195
|
default: {
|
|
8148
8196
|
if (t.command && !t.command.startsWith('-')) {
|
|
8149
|
-
(!
|
|
8197
|
+
(!N(t.command) &&
|
|
8150
8198
|
!oe[t.command] &&
|
|
8151
8199
|
(process.stderr.write(`
|
|
8152
8200
|
${a.red('Error:')} Unknown command or model "${t.command}".
|
|
8153
8201
|
Run ${a.cyan('tein --help')} for the commands, or ${a.cyan('tein models')} for the model slugs.
|
|
8154
8202
|
`),
|
|
8155
|
-
process.exit(
|
|
8156
|
-
await
|
|
8203
|
+
process.exit(_)),
|
|
8204
|
+
await Ee(t.command, t.options));
|
|
8157
8205
|
return;
|
|
8158
8206
|
}
|
|
8159
8207
|
Wt();
|
|
@@ -8161,15 +8209,15 @@ Run ${a.cyan('tein --help')} for the commands, or ${a.cyan('tein models')} for t
|
|
|
8161
8209
|
}
|
|
8162
8210
|
}
|
|
8163
8211
|
}
|
|
8164
|
-
|
|
8165
|
-
(e instanceof
|
|
8212
|
+
xr().catch((e) => {
|
|
8213
|
+
(e instanceof k &&
|
|
8166
8214
|
(process.stderr.write(`
|
|
8167
|
-
${a.red('Error:')} ${
|
|
8215
|
+
${a.red('Error:')} ${K(e).join(`
|
|
8168
8216
|
`)}
|
|
8169
8217
|
`),
|
|
8170
8218
|
process.exit(e.exitCode)),
|
|
8171
8219
|
process.stderr.write(`
|
|
8172
8220
|
${a.red('Fatal error:')} ${e instanceof Error ? e.message : e}
|
|
8173
8221
|
`),
|
|
8174
|
-
process.exit(
|
|
8222
|
+
process.exit(_));
|
|
8175
8223
|
});
|