@celljs/ta-offer 4.38.0 → 4.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extension/index.mjs +16 -6
- package/host/index.mjs +2084 -48
- package/package.json +3 -3
- package/web/index.js +542 -57
package/web/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var NAME = "@celljs/ta-offer";
|
|
|
25
25
|
var OFFERS_VIEW = `${NAME}/offers`;
|
|
26
26
|
var DATA_KEY = "data";
|
|
27
27
|
var PAYEE_KEY = "payee";
|
|
28
|
-
var LIMITS = { name: 40, intro: 300, plans: 6, planName: 20, note: 300, picture: 400000 };
|
|
28
|
+
var LIMITS = { name: 40, intro: 300, plans: 6, planName: 20, note: 300, picture: 400000, keys: 5, keyName: 30, clients: 10 };
|
|
29
29
|
|
|
30
30
|
// ../ta-protocol/esm/common/language.js
|
|
31
31
|
var TaLanguageUtil;
|
|
@@ -113,7 +113,6 @@ var ZH = {
|
|
|
113
113
|
planTokens: "总额度",
|
|
114
114
|
tokenUnit: "万 token",
|
|
115
115
|
planDaily: "每天上限",
|
|
116
|
-
planTrial: "试用",
|
|
117
116
|
planPack: "按量包",
|
|
118
117
|
planMonth: "包月",
|
|
119
118
|
planNew: "新方案",
|
|
@@ -131,6 +130,14 @@ var ZH = {
|
|
|
131
130
|
addPlan: "添加方案",
|
|
132
131
|
trial: "新使用者先得到",
|
|
133
132
|
trialNone: "什么都不给,付款后才能用",
|
|
133
|
+
charge: "怎么收费",
|
|
134
|
+
chargeFree: "免费",
|
|
135
|
+
chargePaid: "收费",
|
|
136
|
+
freeEach: "每人能用多少",
|
|
137
|
+
freeHint: "空着就是不限;用的是你的模型额度,建议设每天上限。",
|
|
138
|
+
giftSwitch: "新使用者先送免费额度",
|
|
139
|
+
giftOn: "用完再选方案付款",
|
|
140
|
+
planGift: "免费额度",
|
|
134
141
|
runsHere: "别人的对话跑在你的电脑上、用这个智能体的模型和说明;每人一个自己的对话和文件夹,互相看不到,也看不到你的对话、文件和记忆。电脑关机时暂停服务。",
|
|
135
142
|
accountModel: "这个智能体用的是账号登录的模型({model}),这类订阅一般不允许转给别人用来收费。换成自己按量付费的 API Key 后再开放收费方案,或者只留免费方案。",
|
|
136
143
|
cancel: "取消",
|
|
@@ -200,7 +207,38 @@ var ZH = {
|
|
|
200
207
|
buyHint: "选一个方案,扫码付款,提供者确认后就开通。",
|
|
201
208
|
buyHintOffline: "选一个方案,然后和 {owner} 约好怎么付款。",
|
|
202
209
|
privacyUser: "对话保存在 {owner} 的电脑上,30 天后可能被清理;不要在这里发密码等私密信息。",
|
|
203
|
-
emptyUser: "没有开放给你的智能体"
|
|
210
|
+
emptyUser: "没有开放给你的智能体",
|
|
211
|
+
apiTitle: "用 API 调用",
|
|
212
|
+
apiBase: "API 地址",
|
|
213
|
+
apiHint: "兼容 OpenAI 接口:base_url 填上面的地址,api_key 填你的 Key,model 随便填。请求头带 Ta-Conversation 能接着上次的对话。用量计入你的方案。",
|
|
214
|
+
newKey: "新建 API Key",
|
|
215
|
+
keyName: "名字",
|
|
216
|
+
keyNameHint: "比如:笔记本、我的脚本",
|
|
217
|
+
keyMade: "API Key 已创建",
|
|
218
|
+
keyOnce: "只显示这一次,关掉就看不到了,现在复制存好。",
|
|
219
|
+
copy: "复制",
|
|
220
|
+
copied: "已复制",
|
|
221
|
+
keyLine: "{hint} · {date}创建",
|
|
222
|
+
keyUsed: "{date}用过",
|
|
223
|
+
removeKey: "删除",
|
|
224
|
+
removeKeyTitle: "删除「{name}」?",
|
|
225
|
+
removeKeyHint: "用这个 Key 的程序会马上调用不了。",
|
|
226
|
+
keyTry: "试一下",
|
|
227
|
+
copyCurl: "复制命令",
|
|
228
|
+
apiSwitch: "也能用 API 调用",
|
|
229
|
+
apiOn: "对方可以用 API Key 或 MCP 客户端从程序里调用,用量同样计入方案",
|
|
230
|
+
apiOff: "只能在网页里用",
|
|
231
|
+
keysCount: "{n} 个 API Key",
|
|
232
|
+
mcpTitle: "在 MCP 客户端里用",
|
|
233
|
+
mcpAddress: "MCP 地址",
|
|
234
|
+
mcpConnect: "连接 MCP 客户端",
|
|
235
|
+
mcpHint: "在客户端里添加上面的地址(Streamable HTTP),它会打开一个网页让你登录:点「连接 MCP 客户端」,把连接码填进去。用量计入你的方案。",
|
|
236
|
+
mcpCodeTitle: "连接码",
|
|
237
|
+
mcpCodeHint: "填在客户端打开的那个网页里。",
|
|
238
|
+
mcpCodeUntil: "{time} 前有效,只能用一次",
|
|
239
|
+
clientLine: "{date}连接",
|
|
240
|
+
removeClientHint: "这个客户端会马上调用不了,要用得重新连接。",
|
|
241
|
+
clientsCount: "{n} 个 MCP 客户端"
|
|
204
242
|
};
|
|
205
243
|
var ZH_TW = {
|
|
206
244
|
title: "開放給別人用",
|
|
@@ -248,7 +286,6 @@ var ZH_TW = {
|
|
|
248
286
|
planTokens: "總額度",
|
|
249
287
|
tokenUnit: "萬 token",
|
|
250
288
|
planDaily: "每天上限",
|
|
251
|
-
planTrial: "試用",
|
|
252
289
|
planPack: "按量包",
|
|
253
290
|
planMonth: "包月",
|
|
254
291
|
planNew: "新方案",
|
|
@@ -266,6 +303,14 @@ var ZH_TW = {
|
|
|
266
303
|
addPlan: "新增方案",
|
|
267
304
|
trial: "新使用者先得到",
|
|
268
305
|
trialNone: "什麼都不給,付款後才能用",
|
|
306
|
+
charge: "怎麼收費",
|
|
307
|
+
chargeFree: "免費",
|
|
308
|
+
chargePaid: "收費",
|
|
309
|
+
freeEach: "每人能用多少",
|
|
310
|
+
freeHint: "空著就是不限;用的是你的模型額度,建議設每天上限。",
|
|
311
|
+
giftSwitch: "新使用者先送免費額度",
|
|
312
|
+
giftOn: "用完再選方案付款",
|
|
313
|
+
planGift: "免費額度",
|
|
269
314
|
runsHere: "別人的對話跑在你的電腦上、用這個智慧體的模型和說明;每人一個自己的對話和資料夾,互相看不到,也看不到你的對話、檔案和記憶。電腦關機時暫停服務。",
|
|
270
315
|
accountModel: "這個智慧體用的是帳號登入的模型({model}),這類訂閱一般不允許轉給別人用來收費。換成自己按量付費的 API Key 後再開放收費方案,或者只留免費方案。",
|
|
271
316
|
cancel: "取消",
|
|
@@ -335,7 +380,38 @@ var ZH_TW = {
|
|
|
335
380
|
buyHint: "選一個方案,掃碼付款,提供者確認後就開通。",
|
|
336
381
|
buyHintOffline: "選一個方案,然後和 {owner} 約好怎麼付款。",
|
|
337
382
|
privacyUser: "對話儲存在 {owner} 的電腦上,30 天後可能被清理;不要在這裡傳密碼等私密資訊。",
|
|
338
|
-
emptyUser: "沒有開放給你的智慧體"
|
|
383
|
+
emptyUser: "沒有開放給你的智慧體",
|
|
384
|
+
apiTitle: "用 API 呼叫",
|
|
385
|
+
apiBase: "API 位址",
|
|
386
|
+
apiHint: "相容 OpenAI 介面:base_url 填上面的位址,api_key 填你的 Key,model 隨便填。請求標頭帶 Ta-Conversation 能接著上次的對話。用量計入你的方案。",
|
|
387
|
+
newKey: "新建 API Key",
|
|
388
|
+
keyName: "名字",
|
|
389
|
+
keyNameHint: "例如:筆電、我的腳本",
|
|
390
|
+
keyMade: "API Key 已建立",
|
|
391
|
+
keyOnce: "只顯示這一次,關掉就看不到了,現在複製存好。",
|
|
392
|
+
copy: "複製",
|
|
393
|
+
copied: "已複製",
|
|
394
|
+
keyLine: "{hint} · {date}建立",
|
|
395
|
+
keyUsed: "{date}用過",
|
|
396
|
+
removeKey: "刪除",
|
|
397
|
+
removeKeyTitle: "刪除「{name}」?",
|
|
398
|
+
removeKeyHint: "用這個 Key 的程式會馬上呼叫不了。",
|
|
399
|
+
keyTry: "試一下",
|
|
400
|
+
copyCurl: "複製命令",
|
|
401
|
+
apiSwitch: "也能用 API 呼叫",
|
|
402
|
+
apiOn: "對方可以用 API Key 或 MCP 用戶端從程式裡呼叫,用量同樣計入方案",
|
|
403
|
+
apiOff: "只能在網頁裡用",
|
|
404
|
+
keysCount: "{n} 個 API Key",
|
|
405
|
+
mcpTitle: "在 MCP 用戶端裡用",
|
|
406
|
+
mcpAddress: "MCP 位址",
|
|
407
|
+
mcpConnect: "連接 MCP 用戶端",
|
|
408
|
+
mcpHint: "在用戶端裡新增上面的位址(Streamable HTTP),它會打開一個網頁讓你登入:點「連接 MCP 用戶端」,把連接碼填進去。用量計入你的方案。",
|
|
409
|
+
mcpCodeTitle: "連接碼",
|
|
410
|
+
mcpCodeHint: "填在用戶端打開的那個網頁裡。",
|
|
411
|
+
mcpCodeUntil: "{time} 前有效,只能用一次",
|
|
412
|
+
clientLine: "{date}連接",
|
|
413
|
+
removeClientHint: "這個用戶端會馬上呼叫不了,要用得重新連接。",
|
|
414
|
+
clientsCount: "{n} 個 MCP 用戶端"
|
|
339
415
|
};
|
|
340
416
|
var EN = {
|
|
341
417
|
title: "Open to others",
|
|
@@ -383,7 +459,6 @@ var EN = {
|
|
|
383
459
|
planTokens: "In all",
|
|
384
460
|
tokenUnit: "K tokens",
|
|
385
461
|
planDaily: "A day at most",
|
|
386
|
-
planTrial: "Trial",
|
|
387
462
|
planPack: "Pack",
|
|
388
463
|
planMonth: "Monthly",
|
|
389
464
|
planNew: "New plan",
|
|
@@ -401,6 +476,14 @@ var EN = {
|
|
|
401
476
|
addPlan: "Add a plan",
|
|
402
477
|
trial: "New users first get",
|
|
403
478
|
trialNone: "Nothing until they pay",
|
|
479
|
+
charge: "Charging",
|
|
480
|
+
chargeFree: "Free",
|
|
481
|
+
chargePaid: "Paid",
|
|
482
|
+
freeEach: "How much each one may use",
|
|
483
|
+
freeHint: "Empty is no limit. It runs on your models, so a limit a day is wise.",
|
|
484
|
+
giftSwitch: "Give newcomers a free allowance",
|
|
485
|
+
giftOn: "Once it is used, they pick a plan and pay",
|
|
486
|
+
planGift: "Free allowance",
|
|
404
487
|
runsHere: "Their conversations run on your computer, on this agent’s model and role; each has their own conversations and folder, apart from the others and from your conversations, files and memory. Paused while your computer is off.",
|
|
405
488
|
accountModel: "This agent uses a model signed in by an account ({model}); such subscriptions rarely allow serving others for money. Use an API key you pay per request for paid plans, or keep only free ones.",
|
|
406
489
|
cancel: "Cancel",
|
|
@@ -470,7 +553,38 @@ var EN = {
|
|
|
470
553
|
buyHint: "Pick a plan and pay by the code; it opens once its owner confirms.",
|
|
471
554
|
buyHintOffline: "Pick a plan, then agree with {owner} how to pay.",
|
|
472
555
|
privacyUser: "Conversations are kept on {owner}’s computer and may be cleared after 30 days; send no passwords or private details here.",
|
|
473
|
-
emptyUser: "Nothing is opened to you"
|
|
556
|
+
emptyUser: "Nothing is opened to you",
|
|
557
|
+
apiTitle: "Use it by API",
|
|
558
|
+
apiBase: "API address",
|
|
559
|
+
apiHint: "Works as OpenAI’s API: set base_url to the address above, api_key to your key, and any model. Send the header Ta-Conversation to go on with a conversation. What it uses counts in your plan.",
|
|
560
|
+
newKey: "New API key",
|
|
561
|
+
keyName: "Name",
|
|
562
|
+
keyNameHint: "Say, laptop or my script",
|
|
563
|
+
keyMade: "API key made",
|
|
564
|
+
keyOnce: "Shown this once: copy it now, it cannot be seen again.",
|
|
565
|
+
copy: "Copy",
|
|
566
|
+
copied: "Copied",
|
|
567
|
+
keyLine: "{hint} · made {date}",
|
|
568
|
+
keyUsed: "used {date}",
|
|
569
|
+
removeKey: "Remove",
|
|
570
|
+
removeKeyTitle: "Remove “{name}”?",
|
|
571
|
+
removeKeyHint: "Programs using this key stop working at once.",
|
|
572
|
+
keyTry: "Try it",
|
|
573
|
+
copyCurl: "Copy the command",
|
|
574
|
+
apiSwitch: "Usable by API too",
|
|
575
|
+
apiOn: "They can call it from programs, by an API key or an MCP client, counted in their plan",
|
|
576
|
+
apiOff: "Only in the page",
|
|
577
|
+
keysCount: "{n} API keys",
|
|
578
|
+
mcpTitle: "Use it in an MCP client",
|
|
579
|
+
mcpAddress: "MCP address",
|
|
580
|
+
mcpConnect: "Connect an MCP client",
|
|
581
|
+
mcpHint: "Add the address above in the client (Streamable HTTP); it opens a page to sign in: tap Connect an MCP client and type the code there. What it uses counts in your plan.",
|
|
582
|
+
mcpCodeTitle: "Code to connect",
|
|
583
|
+
mcpCodeHint: "Type it in the page the client opened.",
|
|
584
|
+
mcpCodeUntil: "Good till {time}, once",
|
|
585
|
+
clientLine: "connected {date}",
|
|
586
|
+
removeClientHint: "This client stops working at once; connect it again to use it.",
|
|
587
|
+
clientsCount: "{n} MCP clients"
|
|
474
588
|
};
|
|
475
589
|
var JA = {
|
|
476
590
|
title: "ほかの人に公開",
|
|
@@ -518,7 +632,6 @@ var JA = {
|
|
|
518
632
|
planTokens: "合計",
|
|
519
633
|
tokenUnit: "万トークン",
|
|
520
634
|
planDaily: "1 日の上限",
|
|
521
|
-
planTrial: "お試し",
|
|
522
635
|
planPack: "従量パック",
|
|
523
636
|
planMonth: "月額",
|
|
524
637
|
planNew: "新しいプラン",
|
|
@@ -536,6 +649,14 @@ var JA = {
|
|
|
536
649
|
addPlan: "プランを追加",
|
|
537
650
|
trial: "新しい利用者がまず得るもの",
|
|
538
651
|
trialNone: "支払うまで何もなし",
|
|
652
|
+
charge: "料金",
|
|
653
|
+
chargeFree: "無料",
|
|
654
|
+
chargePaid: "有料",
|
|
655
|
+
freeEach: "1 人あたりの利用量",
|
|
656
|
+
freeHint: "空欄は無制限です。あなたのモデル枠を使うので、1 日の上限を設けるのがおすすめです。",
|
|
657
|
+
giftSwitch: "新しい利用者に無料枠を付ける",
|
|
658
|
+
giftOn: "使い切ったらプランを選んで支払い",
|
|
659
|
+
planGift: "無料枠",
|
|
539
660
|
runsHere: "相手の会話はあなたのコンピューターで、このエージェントのモデルと説明で動きます。ひとりずつ自分の会話とフォルダーを持ち、互いにも、あなたの会話・ファイル・記憶にも触れられません。コンピューターの電源が切れている間は停止します。",
|
|
540
661
|
accountModel: "このエージェントはアカウントでサインインしたモデル({model})を使っています。こうしたサブスクリプションは他人への有料提供をほぼ認めていません。有料プランには従量課金の API キーを使うか、無料プランだけにしてください。",
|
|
541
662
|
cancel: "キャンセル",
|
|
@@ -605,7 +726,38 @@ var JA = {
|
|
|
605
726
|
buyHint: "プランを選んでコードで支払うと、提供者の確認後に開通します。",
|
|
606
727
|
buyHintOffline: "プランを選び、{owner} さんと支払い方法を決めてください。",
|
|
607
728
|
privacyUser: "会話は {owner} さんのコンピューターに保存され、30 日後に消えることがあります。パスワードなどの個人情報は送らないでください。",
|
|
608
|
-
emptyUser: "あなたに公開されたものはありません"
|
|
729
|
+
emptyUser: "あなたに公開されたものはありません",
|
|
730
|
+
apiTitle: "API で使う",
|
|
731
|
+
apiBase: "API アドレス",
|
|
732
|
+
apiHint: "OpenAI 互換の API です。base_url に上のアドレス、api_key にあなたのキーを設定し、model は任意です。ヘッダー Ta-Conversation で前回の会話を続けられます。使用量はプランに計上されます。",
|
|
733
|
+
newKey: "API キーを作成",
|
|
734
|
+
keyName: "名前",
|
|
735
|
+
keyNameHint: "例:ノートパソコン、スクリプト",
|
|
736
|
+
keyMade: "API キーを作成しました",
|
|
737
|
+
keyOnce: "表示はこの一度だけです。閉じると見られないので、今コピーして保管してください。",
|
|
738
|
+
copy: "コピー",
|
|
739
|
+
copied: "コピーしました",
|
|
740
|
+
keyLine: "{hint} · {date}作成",
|
|
741
|
+
keyUsed: "{date}に使用",
|
|
742
|
+
removeKey: "削除",
|
|
743
|
+
removeKeyTitle: "「{name}」を削除しますか?",
|
|
744
|
+
removeKeyHint: "このキーを使うプログラムはすぐに呼び出せなくなります。",
|
|
745
|
+
keyTry: "試す",
|
|
746
|
+
copyCurl: "コマンドをコピー",
|
|
747
|
+
apiSwitch: "API でも使えるようにする",
|
|
748
|
+
apiOn: "相手は API キーや MCP クライアントでプログラムから呼び出せます。使用量はプランに計上されます",
|
|
749
|
+
apiOff: "ウェブページでのみ利用",
|
|
750
|
+
keysCount: "API キー {n} 個",
|
|
751
|
+
mcpTitle: "MCP クライアントで使う",
|
|
752
|
+
mcpAddress: "MCP アドレス",
|
|
753
|
+
mcpConnect: "MCP クライアントを接続",
|
|
754
|
+
mcpHint: "クライアントに上のアドレス(Streamable HTTP)を追加すると、ログイン用のページが開きます。「MCP クライアントを接続」を押して、接続コードを入力してください。利用分はプランに計上されます。",
|
|
755
|
+
mcpCodeTitle: "接続コード",
|
|
756
|
+
mcpCodeHint: "クライアントが開いたページに入力してください。",
|
|
757
|
+
mcpCodeUntil: "{time} まで有効、1 回限り",
|
|
758
|
+
clientLine: "{date}に接続",
|
|
759
|
+
removeClientHint: "このクライアントはすぐに使えなくなります。使うには接続し直してください。",
|
|
760
|
+
clientsCount: "MCP クライアント {n} 個"
|
|
609
761
|
};
|
|
610
762
|
var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
|
|
611
763
|
var OfferWords;
|
|
@@ -653,6 +805,11 @@ async function act(run) {
|
|
|
653
805
|
return;
|
|
654
806
|
}
|
|
655
807
|
}
|
|
808
|
+
function copy(text) {
|
|
809
|
+
navigator.clipboard.writeText(text).then(() => pi.ui.notify(t("copied"), "info"), () => {
|
|
810
|
+
return;
|
|
811
|
+
});
|
|
812
|
+
}
|
|
656
813
|
function price(fen) {
|
|
657
814
|
return fen > 0 ? `¥${(fen / 100).toFixed(fen % 100 === 0 ? 0 : 2)}` : t("free");
|
|
658
815
|
}
|
|
@@ -735,7 +892,7 @@ function useBook() {
|
|
|
735
892
|
return book.get();
|
|
736
893
|
}
|
|
737
894
|
|
|
738
|
-
// web-src/
|
|
895
|
+
// web-src/pricing-editor.tsx
|
|
739
896
|
var num = (value) => value.trim() === "" ? undefined : Number(value);
|
|
740
897
|
function toRow(plan) {
|
|
741
898
|
const factor = tokenFactor();
|
|
@@ -762,13 +919,11 @@ function toPlan(row) {
|
|
|
762
919
|
...num(row.days) !== undefined ? { days: num(row.days) } : {}
|
|
763
920
|
};
|
|
764
921
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
].map(toRow);
|
|
771
|
-
}
|
|
922
|
+
var giftOf = (charge) => toRow(charge ? { id: "trial", name: t("planGift"), price: 0, tokens: 200000, days: 7 } : { id: "free", name: t("free"), price: 0, daily: 200000 });
|
|
923
|
+
var paidStart = () => [
|
|
924
|
+
{ id: "pack", name: t("planPack"), price: 2000, tokens: 2000000 },
|
|
925
|
+
{ id: "month", name: t("planMonth"), price: 3000, tokens: 15000000, daily: 1e6, days: 30 }
|
|
926
|
+
].map(toRow);
|
|
772
927
|
function PlanEditor({ row, onChange, onRemove }) {
|
|
773
928
|
const X = pi.ui.icons.X;
|
|
774
929
|
const field = (key, label, suffix) => /* @__PURE__ */ React.createElement("label", {
|
|
@@ -791,7 +946,7 @@ function PlanEditor({ row, onChange, onRemove }) {
|
|
|
791
946
|
value: row.name,
|
|
792
947
|
maxLength: LIMITS.planName,
|
|
793
948
|
onChange: (event) => onChange({ ...row, name: event.target.value })
|
|
794
|
-
}), /* @__PURE__ */ React.createElement("button", {
|
|
949
|
+
}), onRemove && /* @__PURE__ */ React.createElement("button", {
|
|
795
950
|
type: "button",
|
|
796
951
|
className: "tof-icon",
|
|
797
952
|
"aria-label": t("removePlan"),
|
|
@@ -802,6 +957,105 @@ function PlanEditor({ row, onChange, onRemove }) {
|
|
|
802
957
|
className: "tof-plan-grid"
|
|
803
958
|
}, field("price", t("planPrice"), t("yuan")), field("days", t("planDays"), t("daysUnit")), field("tokens", t("planTokens"), t("tokenUnit")), field("daily", t("planDaily"), t("tokenUnit"))));
|
|
804
959
|
}
|
|
960
|
+
var priced = (row) => (num(row.price) ?? 0) > 0;
|
|
961
|
+
var PricingUtil;
|
|
962
|
+
((PricingUtil) => {
|
|
963
|
+
function of(offer) {
|
|
964
|
+
if (!offer) {
|
|
965
|
+
return { charge: false, gift: giftOf(false), paid: [] };
|
|
966
|
+
}
|
|
967
|
+
const rows = offer.plans.map(toRow);
|
|
968
|
+
const gift = rows.find((row) => row.id === offer.trial);
|
|
969
|
+
const rest = rows.filter((row) => row !== gift);
|
|
970
|
+
const charge = rest.some(priced) || !gift && rows.length > 0;
|
|
971
|
+
return charge ? { charge, ...gift ? { gift } : {}, paid: rest } : { charge, gift: gift ?? rest[0] ?? giftOf(false), paid: [] };
|
|
972
|
+
}
|
|
973
|
+
PricingUtil.of = of;
|
|
974
|
+
function plans(pricing) {
|
|
975
|
+
const gift = pricing.gift && { ...pricing.gift, price: "" };
|
|
976
|
+
const rows = pricing.charge ? [...gift ? [gift] : [], ...pricing.paid] : gift ? [gift] : [];
|
|
977
|
+
return { plans: rows.map(toPlan), ...gift ? { trial: gift.id } : {} };
|
|
978
|
+
}
|
|
979
|
+
PricingUtil.plans = plans;
|
|
980
|
+
function ready(pricing) {
|
|
981
|
+
return pricing.charge ? pricing.paid.some(priced) : !!pricing.gift;
|
|
982
|
+
}
|
|
983
|
+
PricingUtil.ready = ready;
|
|
984
|
+
})(PricingUtil ||= {});
|
|
985
|
+
function GiftEditor({ row, onChange }) {
|
|
986
|
+
const field = (key, label, suffix) => /* @__PURE__ */ React.createElement("label", {
|
|
987
|
+
className: "tof-plan-field"
|
|
988
|
+
}, /* @__PURE__ */ React.createElement("span", null, label, " ", /* @__PURE__ */ React.createElement("small", null, suffix)), /* @__PURE__ */ React.createElement("input", {
|
|
989
|
+
className: "tof-input",
|
|
990
|
+
inputMode: "decimal",
|
|
991
|
+
value: row[key],
|
|
992
|
+
placeholder: t("noLimit"),
|
|
993
|
+
onChange: (event) => onChange({ ...row, [key]: event.target.value.replace(/[^\d.]/g, "") })
|
|
994
|
+
}));
|
|
995
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
996
|
+
className: "tof-plan"
|
|
997
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
998
|
+
className: "tof-plan-grid tof-plan-grid-3"
|
|
999
|
+
}, field("tokens", t("planTokens"), t("tokenUnit")), field("daily", t("planDaily"), t("tokenUnit")), field("days", t("planDays"), t("daysUnit"))));
|
|
1000
|
+
}
|
|
1001
|
+
function PricingEditor({ pricing, onChange }) {
|
|
1002
|
+
const { charge, gift, paid } = pricing;
|
|
1003
|
+
const choose = (next) => {
|
|
1004
|
+
if (next === charge) {
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
onChange(next ? { charge: true, gift: giftOf(true), paid: paid.length ? paid : paidStart() } : { charge: false, gift: giftOf(false), paid });
|
|
1008
|
+
};
|
|
1009
|
+
const add = () => {
|
|
1010
|
+
const id = `p${Date.now().toString(36)}`;
|
|
1011
|
+
onChange({ ...pricing, paid: [...paid, { id, name: t("planNew"), price: "", tokens: "", daily: "", days: "" }] });
|
|
1012
|
+
};
|
|
1013
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
1014
|
+
className: "tof-field"
|
|
1015
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("charge")), /* @__PURE__ */ React.createElement("fieldset", {
|
|
1016
|
+
className: "ta-segmented",
|
|
1017
|
+
"aria-label": t("charge")
|
|
1018
|
+
}, [false, true].map((value) => /* @__PURE__ */ React.createElement("button", {
|
|
1019
|
+
key: String(value),
|
|
1020
|
+
type: "button",
|
|
1021
|
+
"aria-pressed": charge === value,
|
|
1022
|
+
className: charge === value ? "ta-on" : "",
|
|
1023
|
+
onClick: () => choose(value)
|
|
1024
|
+
}, value ? t("chargePaid") : t("chargeFree"))))), !charge && gift && /* @__PURE__ */ React.createElement("div", {
|
|
1025
|
+
className: "tof-field"
|
|
1026
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("freeEach")), /* @__PURE__ */ React.createElement(GiftEditor, {
|
|
1027
|
+
row: gift,
|
|
1028
|
+
onChange: (row) => onChange({ ...pricing, gift: row })
|
|
1029
|
+
}), /* @__PURE__ */ React.createElement("small", {
|
|
1030
|
+
className: "tof-hint"
|
|
1031
|
+
}, t("freeHint"))), charge && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
1032
|
+
className: "tof-switch-row"
|
|
1033
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1034
|
+
className: "tof-row-text"
|
|
1035
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("giftSwitch")), /* @__PURE__ */ React.createElement("small", null, gift ? t("giftOn") : t("trialNone"))), /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
1036
|
+
checked: !!gift,
|
|
1037
|
+
label: t("giftSwitch"),
|
|
1038
|
+
onChange: (on) => onChange({ charge, paid, ...on ? { gift: giftOf(true) } : {} })
|
|
1039
|
+
})), gift && /* @__PURE__ */ React.createElement(GiftEditor, {
|
|
1040
|
+
row: gift,
|
|
1041
|
+
onChange: (row) => onChange({ ...pricing, gift: row })
|
|
1042
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
1043
|
+
className: "tof-field"
|
|
1044
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("plans")), /* @__PURE__ */ React.createElement("ul", {
|
|
1045
|
+
className: "tof-plans"
|
|
1046
|
+
}, paid.map((row, index) => /* @__PURE__ */ React.createElement(PlanEditor, {
|
|
1047
|
+
key: row.id,
|
|
1048
|
+
row,
|
|
1049
|
+
onChange: (next) => onChange({ ...pricing, paid: paid.map((one, at) => at === index ? next : one) }),
|
|
1050
|
+
onRemove: () => onChange({ ...pricing, paid: paid.filter((_, at) => at !== index) })
|
|
1051
|
+
}))), paid.length < LIMITS.plans - 1 && /* @__PURE__ */ React.createElement("button", {
|
|
1052
|
+
type: "button",
|
|
1053
|
+
className: "tof-link",
|
|
1054
|
+
onClick: add
|
|
1055
|
+
}, t("addPlan")))));
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// web-src/offer-dialog.tsx
|
|
805
1059
|
async function accountModel(agent) {
|
|
806
1060
|
const settings = await pi.settings.getSettings().catch(() => {
|
|
807
1061
|
return;
|
|
@@ -820,8 +1074,8 @@ function OfferDialog({ offer, close }) {
|
|
|
820
1074
|
const [name, setName] = React.useState(offer?.name ?? "");
|
|
821
1075
|
const [intro, setIntro] = React.useState(offer?.intro ?? "");
|
|
822
1076
|
const [approve, setApprove] = React.useState(offer?.approve ?? true);
|
|
823
|
-
const [
|
|
824
|
-
const [
|
|
1077
|
+
const [api, setApi] = React.useState(offer?.api !== false);
|
|
1078
|
+
const [pricing, setPricing] = React.useState(() => PricingUtil.of(offer));
|
|
825
1079
|
const [account, setAccount] = React.useState();
|
|
826
1080
|
const [busy, run] = pi.ui.useBusy();
|
|
827
1081
|
React.useEffect(() => {
|
|
@@ -834,9 +1088,7 @@ function OfferDialog({ offer, close }) {
|
|
|
834
1088
|
React.useEffect(() => {
|
|
835
1089
|
accountModel(picked).then(setAccount);
|
|
836
1090
|
}, [picked]);
|
|
837
|
-
const
|
|
838
|
-
const charged = rows.some((row) => (num(row.price) ?? 0) > 0);
|
|
839
|
-
const blocked = charged && !!account;
|
|
1091
|
+
const blocked = pricing.charge && !!account;
|
|
840
1092
|
const save = async () => {
|
|
841
1093
|
const saved = await act(() => call("save", {
|
|
842
1094
|
...offer ? { id: offer.id } : {},
|
|
@@ -844,18 +1096,14 @@ function OfferDialog({ offer, close }) {
|
|
|
844
1096
|
name: name.trim() || picked?.name,
|
|
845
1097
|
intro,
|
|
846
1098
|
approve,
|
|
847
|
-
|
|
848
|
-
|
|
1099
|
+
api,
|
|
1100
|
+
...PricingUtil.plans(pricing),
|
|
849
1101
|
language: pi.ui.language
|
|
850
1102
|
}));
|
|
851
1103
|
if (saved) {
|
|
852
1104
|
close();
|
|
853
1105
|
}
|
|
854
1106
|
};
|
|
855
|
-
const add = () => {
|
|
856
|
-
const id = `p${Date.now().toString(36)}`;
|
|
857
|
-
setRows([...rows, { id, name: t("planNew"), price: "", tokens: "", daily: "", days: "" }]);
|
|
858
|
-
};
|
|
859
1107
|
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
860
1108
|
title: offer ? t("editTitle") : t("openTitle"),
|
|
861
1109
|
onClose: close
|
|
@@ -900,30 +1148,17 @@ function OfferDialog({ offer, close }) {
|
|
|
900
1148
|
label: t("approve"),
|
|
901
1149
|
onChange: setApprove
|
|
902
1150
|
})), /* @__PURE__ */ React.createElement("div", {
|
|
903
|
-
className: "tof-
|
|
904
|
-
}, /* @__PURE__ */ React.createElement("span",
|
|
905
|
-
className: "tof-
|
|
906
|
-
},
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
onChange:
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
onClick: add
|
|
915
|
-
}, t("addPlan"))), free.length > 0 && /* @__PURE__ */ React.createElement("label", {
|
|
916
|
-
className: "tof-field"
|
|
917
|
-
}, /* @__PURE__ */ React.createElement("span", null, t("trial")), /* @__PURE__ */ React.createElement("select", {
|
|
918
|
-
className: "tof-input",
|
|
919
|
-
value: free.some((row) => row.id === trial) ? trial : "",
|
|
920
|
-
onChange: (event) => setTrial(event.target.value)
|
|
921
|
-
}, /* @__PURE__ */ React.createElement("option", {
|
|
922
|
-
value: ""
|
|
923
|
-
}, t("trialNone")), free.map((row) => /* @__PURE__ */ React.createElement("option", {
|
|
924
|
-
key: row.id,
|
|
925
|
-
value: row.id
|
|
926
|
-
}, row.name)))), /* @__PURE__ */ React.createElement("p", {
|
|
1151
|
+
className: "tof-switch-row"
|
|
1152
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1153
|
+
className: "tof-row-text"
|
|
1154
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("apiSwitch")), /* @__PURE__ */ React.createElement("small", null, api ? t("apiOn") : t("apiOff"))), /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
1155
|
+
checked: api,
|
|
1156
|
+
label: t("apiSwitch"),
|
|
1157
|
+
onChange: setApi
|
|
1158
|
+
})), /* @__PURE__ */ React.createElement(PricingEditor, {
|
|
1159
|
+
pricing,
|
|
1160
|
+
onChange: setPricing
|
|
1161
|
+
}), /* @__PURE__ */ React.createElement("p", {
|
|
927
1162
|
className: "tof-hint"
|
|
928
1163
|
}, t("runsHere")), blocked && /* @__PURE__ */ React.createElement("p", {
|
|
929
1164
|
className: "tof-warn"
|
|
@@ -936,7 +1171,7 @@ function OfferDialog({ offer, close }) {
|
|
|
936
1171
|
}, t("cancel")), /* @__PURE__ */ React.createElement("button", {
|
|
937
1172
|
type: "button",
|
|
938
1173
|
className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
|
|
939
|
-
disabled: busy || blocked || !agent || !
|
|
1174
|
+
disabled: busy || blocked || !agent || !PricingUtil.ready(pricing),
|
|
940
1175
|
onClick: () => void run(save)
|
|
941
1176
|
}, offer ? t("save") : t("openIt"))))));
|
|
942
1177
|
}
|
|
@@ -1001,7 +1236,13 @@ function UserRow({ user, offer }) {
|
|
|
1001
1236
|
await act(() => call("removeUser", user.id));
|
|
1002
1237
|
}
|
|
1003
1238
|
};
|
|
1004
|
-
const line = [
|
|
1239
|
+
const line = [
|
|
1240
|
+
user.grant ? user.grant.name : t("noPlan"),
|
|
1241
|
+
leftLine(user.state),
|
|
1242
|
+
user.used.total ? t("usedAll", { n: tokens(user.used.total) }) : undefined,
|
|
1243
|
+
user.keys ? t("keysCount", { n: user.keys }) : undefined,
|
|
1244
|
+
user.clients ? t("clientsCount", { n: user.clients }) : undefined
|
|
1245
|
+
].filter(Boolean).join(" · ");
|
|
1005
1246
|
return /* @__PURE__ */ React.createElement("li", {
|
|
1006
1247
|
className: `tof-row tof-row-wrap${busy ? " ta-pending" : ""}`
|
|
1007
1248
|
}, /* @__PURE__ */ React.createElement(Face, {
|
|
@@ -1125,7 +1366,7 @@ function DetailDialog({ id, close }) {
|
|
|
1125
1366
|
className: "tof-section"
|
|
1126
1367
|
}, /* @__PURE__ */ React.createElement("h3", null, t("plans")), /* @__PURE__ */ React.createElement("p", {
|
|
1127
1368
|
className: "tof-hint tof-pad-x"
|
|
1128
|
-
}, offer.plans.map((plan) => `${plan.name} ${price(plan.price)}
|
|
1369
|
+
}, offer.plans.map((plan) => plan.price ? `${plan.name} ${price(plan.price)}` : plan.id === offer.trial && offer.plans.some((one) => one.price) ? `${plan.name} (${t("trialTag")})` : plan.name).join(" · "))), /* @__PURE__ */ React.createElement("section", {
|
|
1129
1370
|
className: "tof-section"
|
|
1130
1371
|
}, /* @__PURE__ */ React.createElement("h3", null, t("users")), users.length ? /* @__PURE__ */ React.createElement("ul", {
|
|
1131
1372
|
className: "tof-card"
|
|
@@ -1602,6 +1843,7 @@ var STYLE = `
|
|
|
1602
1843
|
.tof-plan-head { display: flex; align-items: center; gap: 6px; }
|
|
1603
1844
|
.tof-plan-name { font-weight: 500; }
|
|
1604
1845
|
.tof-plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
|
|
1846
|
+
.tof-plan-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1605
1847
|
.tof-plan-field { display: flex; flex-direction: column; gap: 4px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
1606
1848
|
.tof-plan-input { display: flex; align-items: center; gap: 6px; }
|
|
1607
1849
|
.tof-plan-input small { flex: none; color: var(--ta-muted); }
|
|
@@ -1623,6 +1865,10 @@ var STYLE = `
|
|
|
1623
1865
|
.tof-pay-amount { font-size: calc(30px * var(--ta-font-scale)); font-weight: 600; text-align: center; }
|
|
1624
1866
|
.tof-code { align-self: center; padding: 6px 18px; border: 1px dashed var(--ta-border); border-radius: 10px; font: 600 24px/1.2 var(--ta-mono, ui-monospace, monospace); letter-spacing: 0.18em; user-select: all; }
|
|
1625
1867
|
.tof-qr-box { display: flex; align-items: center; justify-content: center; min-height: 160px; padding: 12px; border-radius: 14px; background: var(--ta-raised); }
|
|
1868
|
+
.tof-mono { font-family: var(--ta-mono, ui-monospace, monospace); word-break: break-all; }
|
|
1869
|
+
.tof-secret { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--ta-raised); }
|
|
1870
|
+
.tof-secret code { flex: 1; min-width: 0; font: 500 calc(12.5px * var(--ta-font-scale))/1.45 var(--ta-mono, ui-monospace, monospace); word-break: break-all; user-select: all; }
|
|
1871
|
+
.tof-pre { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--ta-raised); font: calc(12px * var(--ta-font-scale))/1.5 var(--ta-mono, ui-monospace, monospace); white-space: pre-wrap; word-break: break-all; user-select: all; }
|
|
1626
1872
|
.tof-qr { display: block; max-width: min(240px, 70vw); max-height: 320px; border-radius: 8px; }
|
|
1627
1873
|
`;
|
|
1628
1874
|
function injectStyle() {
|
|
@@ -1633,6 +1879,239 @@ function injectStyle() {
|
|
|
1633
1879
|
return () => element.remove();
|
|
1634
1880
|
}
|
|
1635
1881
|
|
|
1882
|
+
// web-src/api-section.tsx
|
|
1883
|
+
function KeyDialog({ made, close }) {
|
|
1884
|
+
const curl = [
|
|
1885
|
+
`curl ${made.base}/v1/chat/completions \\`,
|
|
1886
|
+
` -H "Authorization: Bearer ${made.key}" \\`,
|
|
1887
|
+
` -H "Content-Type: application/json" \\`,
|
|
1888
|
+
` -d '{"model":"agent","messages":[{"role":"user","content":"Hi"}]}'`
|
|
1889
|
+
].join(`
|
|
1890
|
+
`);
|
|
1891
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
1892
|
+
title: t("keyMade"),
|
|
1893
|
+
onClose: close
|
|
1894
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1895
|
+
className: "tof-dialog"
|
|
1896
|
+
}, /* @__PURE__ */ React.createElement("p", {
|
|
1897
|
+
className: "tof-warn"
|
|
1898
|
+
}, t("keyOnce")), /* @__PURE__ */ React.createElement("div", {
|
|
1899
|
+
className: "tof-secret"
|
|
1900
|
+
}, /* @__PURE__ */ React.createElement("code", null, made.key), /* @__PURE__ */ React.createElement("button", {
|
|
1901
|
+
type: "button",
|
|
1902
|
+
className: "ta-button",
|
|
1903
|
+
onClick: () => copy(made.key)
|
|
1904
|
+
}, t("copy"))), /* @__PURE__ */ React.createElement("div", {
|
|
1905
|
+
className: "tof-field"
|
|
1906
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("apiBase")), /* @__PURE__ */ React.createElement("div", {
|
|
1907
|
+
className: "tof-secret"
|
|
1908
|
+
}, /* @__PURE__ */ React.createElement("code", null, made.base, "/v1"), /* @__PURE__ */ React.createElement("button", {
|
|
1909
|
+
type: "button",
|
|
1910
|
+
className: "ta-button",
|
|
1911
|
+
onClick: () => copy(`${made.base}/v1`)
|
|
1912
|
+
}, t("copy")))), /* @__PURE__ */ React.createElement("div", {
|
|
1913
|
+
className: "tof-field"
|
|
1914
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("keyTry")), /* @__PURE__ */ React.createElement("pre", {
|
|
1915
|
+
className: "tof-pre"
|
|
1916
|
+
}, curl)), /* @__PURE__ */ React.createElement("div", {
|
|
1917
|
+
className: "tof-actions"
|
|
1918
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1919
|
+
type: "button",
|
|
1920
|
+
className: "ta-button",
|
|
1921
|
+
onClick: () => copy(curl)
|
|
1922
|
+
}, t("copyCurl")), /* @__PURE__ */ React.createElement("button", {
|
|
1923
|
+
type: "button",
|
|
1924
|
+
className: "ta-button ta-primary",
|
|
1925
|
+
onClick: close
|
|
1926
|
+
}, t("done")))));
|
|
1927
|
+
}
|
|
1928
|
+
function NewKeyDialog({ offer, close }) {
|
|
1929
|
+
const [name, setName] = React.useState("");
|
|
1930
|
+
const [busy, run] = pi.ui.useBusy();
|
|
1931
|
+
const make = async () => {
|
|
1932
|
+
const made = await act(() => call("createKey", offer, name));
|
|
1933
|
+
close();
|
|
1934
|
+
if (made) {
|
|
1935
|
+
pi.ui.custom(({ close: done }) => /* @__PURE__ */ React.createElement(KeyDialog, {
|
|
1936
|
+
made,
|
|
1937
|
+
close: done
|
|
1938
|
+
}));
|
|
1939
|
+
}
|
|
1940
|
+
};
|
|
1941
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
1942
|
+
title: t("newKey"),
|
|
1943
|
+
onClose: close
|
|
1944
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1945
|
+
className: "tof-dialog"
|
|
1946
|
+
}, /* @__PURE__ */ React.createElement("label", {
|
|
1947
|
+
className: "tof-field"
|
|
1948
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("keyName")), /* @__PURE__ */ React.createElement("input", {
|
|
1949
|
+
className: "tof-input",
|
|
1950
|
+
value: name,
|
|
1951
|
+
maxLength: 30,
|
|
1952
|
+
placeholder: t("keyNameHint"),
|
|
1953
|
+
onChange: (event) => setName(event.target.value)
|
|
1954
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
1955
|
+
className: "tof-actions"
|
|
1956
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1957
|
+
type: "button",
|
|
1958
|
+
className: "ta-button",
|
|
1959
|
+
onClick: close
|
|
1960
|
+
}, t("cancel")), /* @__PURE__ */ React.createElement("button", {
|
|
1961
|
+
type: "button",
|
|
1962
|
+
className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
|
|
1963
|
+
disabled: busy,
|
|
1964
|
+
onClick: () => void run(make)
|
|
1965
|
+
}, t("newKey")))));
|
|
1966
|
+
}
|
|
1967
|
+
function ApiSection({ offer, api }) {
|
|
1968
|
+
const [busy, run] = pi.ui.useBusy();
|
|
1969
|
+
const Copy = pi.ui.icons.Copy;
|
|
1970
|
+
const remove = async (key) => {
|
|
1971
|
+
if (await pi.ui.confirm(t("removeKeyTitle", { name: key.name }), t("removeKeyHint"), { confirmLabel: t("removeKey"), danger: true })) {
|
|
1972
|
+
await act(() => call("removeKey", offer, key.id));
|
|
1973
|
+
}
|
|
1974
|
+
};
|
|
1975
|
+
return /* @__PURE__ */ React.createElement("section", {
|
|
1976
|
+
className: "tof-section"
|
|
1977
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("apiTitle")), /* @__PURE__ */ React.createElement("ul", {
|
|
1978
|
+
className: "tof-card"
|
|
1979
|
+
}, /* @__PURE__ */ React.createElement("li", {
|
|
1980
|
+
className: "tof-row"
|
|
1981
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1982
|
+
className: "tof-row-text"
|
|
1983
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1984
|
+
className: "tof-row-title"
|
|
1985
|
+
}, t("apiBase")), /* @__PURE__ */ React.createElement("span", {
|
|
1986
|
+
className: "tof-row-line tof-mono"
|
|
1987
|
+
}, api.base, "/v1")), /* @__PURE__ */ React.createElement("button", {
|
|
1988
|
+
type: "button",
|
|
1989
|
+
className: "tof-icon",
|
|
1990
|
+
"aria-label": t("copy"),
|
|
1991
|
+
onClick: () => copy(`${api.base}/v1`)
|
|
1992
|
+
}, Copy ? /* @__PURE__ */ React.createElement(Copy, {
|
|
1993
|
+
size: 15
|
|
1994
|
+
}) : t("copy"))), api.keys.map((key) => /* @__PURE__ */ React.createElement("li", {
|
|
1995
|
+
key: key.id,
|
|
1996
|
+
className: "tof-row"
|
|
1997
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1998
|
+
className: "tof-row-text"
|
|
1999
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2000
|
+
className: "tof-row-title"
|
|
2001
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2002
|
+
className: "tof-ellipsis"
|
|
2003
|
+
}, key.name)), /* @__PURE__ */ React.createElement("span", {
|
|
2004
|
+
className: "tof-row-line"
|
|
2005
|
+
}, [
|
|
2006
|
+
t("keyLine", { hint: key.hint, date: dateOf(key.createdAt) }),
|
|
2007
|
+
key.lastAt ? t("keyUsed", { date: dateOf(key.lastAt) }) : undefined
|
|
2008
|
+
].filter(Boolean).join(" · "))), /* @__PURE__ */ React.createElement("button", {
|
|
2009
|
+
type: "button",
|
|
2010
|
+
className: `ta-button${busy ? " ta-busy" : ""}`,
|
|
2011
|
+
disabled: busy,
|
|
2012
|
+
onClick: () => void run(() => remove(key))
|
|
2013
|
+
}, t("removeKey")))), api.keys.length < 5 && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
2014
|
+
type: "button",
|
|
2015
|
+
className: "tof-row tof-button-row tof-add",
|
|
2016
|
+
onClick: () => pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(NewKeyDialog, {
|
|
2017
|
+
offer,
|
|
2018
|
+
close
|
|
2019
|
+
}))
|
|
2020
|
+
}, t("newKey")))), /* @__PURE__ */ React.createElement("p", {
|
|
2021
|
+
className: "tof-hint tof-pad-x"
|
|
2022
|
+
}, t("apiHint")));
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
// web-src/mcp-section.tsx
|
|
2026
|
+
function CodeDialog({ made, close }) {
|
|
2027
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
2028
|
+
title: t("mcpCodeTitle"),
|
|
2029
|
+
onClose: close
|
|
2030
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
2031
|
+
className: "tof-dialog"
|
|
2032
|
+
}, /* @__PURE__ */ React.createElement("p", {
|
|
2033
|
+
className: "tof-hint"
|
|
2034
|
+
}, t("mcpCodeHint")), /* @__PURE__ */ React.createElement("code", {
|
|
2035
|
+
className: "tof-code"
|
|
2036
|
+
}, made.code), /* @__PURE__ */ React.createElement("p", {
|
|
2037
|
+
className: "tof-hint"
|
|
2038
|
+
}, t("mcpCodeUntil", { time: timeOf(made.expiresAt) })), /* @__PURE__ */ React.createElement("div", {
|
|
2039
|
+
className: "tof-actions"
|
|
2040
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
2041
|
+
type: "button",
|
|
2042
|
+
className: "ta-button",
|
|
2043
|
+
onClick: () => copy(made.code)
|
|
2044
|
+
}, t("copy")), /* @__PURE__ */ React.createElement("button", {
|
|
2045
|
+
type: "button",
|
|
2046
|
+
className: "ta-button ta-primary",
|
|
2047
|
+
onClick: close
|
|
2048
|
+
}, t("done")))));
|
|
2049
|
+
}
|
|
2050
|
+
function McpSection({ offer, api }) {
|
|
2051
|
+
const [busy, run] = pi.ui.useBusy();
|
|
2052
|
+
const Copy = pi.ui.icons.Copy;
|
|
2053
|
+
const connect = async () => {
|
|
2054
|
+
const made = await act(() => call("connectCode", offer));
|
|
2055
|
+
if (made) {
|
|
2056
|
+
pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(CodeDialog, {
|
|
2057
|
+
made,
|
|
2058
|
+
close
|
|
2059
|
+
}));
|
|
2060
|
+
}
|
|
2061
|
+
};
|
|
2062
|
+
const remove = async (client) => {
|
|
2063
|
+
if (await pi.ui.confirm(t("removeKeyTitle", { name: client.name }), t("removeClientHint"), { confirmLabel: t("removeKey"), danger: true })) {
|
|
2064
|
+
await act(() => call("removeClient", offer, client.id));
|
|
2065
|
+
}
|
|
2066
|
+
};
|
|
2067
|
+
return /* @__PURE__ */ React.createElement("section", {
|
|
2068
|
+
className: "tof-section"
|
|
2069
|
+
}, /* @__PURE__ */ React.createElement("h3", null, t("mcpTitle")), /* @__PURE__ */ React.createElement("ul", {
|
|
2070
|
+
className: "tof-card"
|
|
2071
|
+
}, /* @__PURE__ */ React.createElement("li", {
|
|
2072
|
+
className: "tof-row"
|
|
2073
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
2074
|
+
className: "tof-row-text"
|
|
2075
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2076
|
+
className: "tof-row-title"
|
|
2077
|
+
}, t("mcpAddress")), /* @__PURE__ */ React.createElement("span", {
|
|
2078
|
+
className: "tof-row-line tof-mono"
|
|
2079
|
+
}, api.mcp)), /* @__PURE__ */ React.createElement("button", {
|
|
2080
|
+
type: "button",
|
|
2081
|
+
className: "tof-icon",
|
|
2082
|
+
"aria-label": t("copy"),
|
|
2083
|
+
onClick: () => copy(api.mcp)
|
|
2084
|
+
}, Copy ? /* @__PURE__ */ React.createElement(Copy, {
|
|
2085
|
+
size: 15
|
|
2086
|
+
}) : t("copy"))), api.clients.map((client) => /* @__PURE__ */ React.createElement("li", {
|
|
2087
|
+
key: client.id,
|
|
2088
|
+
className: "tof-row"
|
|
2089
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
2090
|
+
className: "tof-row-text"
|
|
2091
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2092
|
+
className: "tof-row-title"
|
|
2093
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2094
|
+
className: "tof-ellipsis"
|
|
2095
|
+
}, client.name)), /* @__PURE__ */ React.createElement("span", {
|
|
2096
|
+
className: "tof-row-line"
|
|
2097
|
+
}, [
|
|
2098
|
+
t("clientLine", { date: dateOf(client.createdAt) }),
|
|
2099
|
+
client.lastAt ? t("keyUsed", { date: dateOf(client.lastAt) }) : undefined
|
|
2100
|
+
].filter(Boolean).join(" · "))), /* @__PURE__ */ React.createElement("button", {
|
|
2101
|
+
type: "button",
|
|
2102
|
+
className: `ta-button${busy ? " ta-busy" : ""}`,
|
|
2103
|
+
disabled: busy,
|
|
2104
|
+
onClick: () => void run(() => remove(client))
|
|
2105
|
+
}, t("removeKey")))), /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
2106
|
+
type: "button",
|
|
2107
|
+
className: `tof-row tof-button-row tof-add${busy ? " ta-busy" : ""}`,
|
|
2108
|
+
disabled: busy,
|
|
2109
|
+
onClick: () => void run(connect)
|
|
2110
|
+
}, t("mcpConnect")))), /* @__PURE__ */ React.createElement("p", {
|
|
2111
|
+
className: "tof-hint tof-pad-x"
|
|
2112
|
+
}, t("mcpHint")));
|
|
2113
|
+
}
|
|
2114
|
+
|
|
1636
2115
|
// web-src/user-page.tsx
|
|
1637
2116
|
function inMiniProgram() {
|
|
1638
2117
|
const wx = window.__wxjs_environment;
|
|
@@ -1775,7 +2254,13 @@ function MineCard({ mine }) {
|
|
|
1775
2254
|
}))
|
|
1776
2255
|
}, price(plan.price))))), /* @__PURE__ */ React.createElement("p", {
|
|
1777
2256
|
className: "tof-hint tof-pad-x"
|
|
1778
|
-
}, mine.payable ? t("buyHint") : t("buyHintOffline", { owner: offer.owner }))), /* @__PURE__ */ React.createElement(
|
|
2257
|
+
}, mine.payable ? t("buyHint") : t("buyHintOffline", { owner: offer.owner }))), mine.api && /* @__PURE__ */ React.createElement(ApiSection, {
|
|
2258
|
+
offer: offer.id,
|
|
2259
|
+
api: mine.api
|
|
2260
|
+
}), mine.api && /* @__PURE__ */ React.createElement(McpSection, {
|
|
2261
|
+
offer: offer.id,
|
|
2262
|
+
api: mine.api
|
|
2263
|
+
}), /* @__PURE__ */ React.createElement("p", {
|
|
1779
2264
|
className: "tof-hint tof-pad-x"
|
|
1780
2265
|
}, t("privacyUser", { owner: offer.owner })));
|
|
1781
2266
|
}
|