bnpanel 0.5.7 → 0.5.9
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/client.js +311 -17
- package/index.js +169 -28
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
--bn-toast-bg:#34302c; --bn-toast-fg:#f6f3ec;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
.bn-root{display:grid;grid-template-columns:minmax(0,208px) minmax(0,1fr);height:100%;min-height:520px;width:100%;max-width:100%;min-width:0;overflow:hidden;background:var(--bn-bg);color:var(--bn-ink);font:13px/1.55 var(--bn-font);-webkit-font-smoothing:antialiased}
|
|
46
|
+
.bn-root{position:relative;display:grid;grid-template-columns:minmax(0,208px) minmax(0,1fr);height:100%;min-height:520px;width:100%;max-width:100%;min-width:0;overflow:hidden;background:var(--bn-bg);color:var(--bn-ink);font:13px/1.55 var(--bn-font);-webkit-font-smoothing:antialiased}
|
|
47
47
|
.bn-root *{box-sizing:border-box}
|
|
48
48
|
.bn-rail{display:flex;flex-direction:column;gap:2px;min-height:0;overflow:auto;padding:16px 10px;border-right:1px solid var(--bn-line);background:var(--bn-surface-2)}
|
|
49
49
|
.bn-logo{display:flex;align-items:center;gap:9px;padding:2px 8px 16px;font-weight:680;letter-spacing:-.01em}
|
|
@@ -93,6 +93,14 @@
|
|
|
93
93
|
.bn-wx .bn-btn{height:30px;padding:0 12px;background:var(--bn-solid);color:var(--bn-on-solid);border-color:var(--bn-solid)}
|
|
94
94
|
.bn-manual{display:flex;align-items:center;justify-content:center;width:100%;margin-top:14px;height:36px;text-decoration:none;box-sizing:border-box}
|
|
95
95
|
.bn-main{overflow:auto;overflow-x:hidden;padding:22px 26px 40px;min-width:0;max-width:100%}
|
|
96
|
+
.bn-main.has-note{padding-bottom:108px}
|
|
97
|
+
.bn-foot-note{position:absolute;z-index:4;left:208px;bottom:16px;margin:0;padding-left:26px;max-width:min(460px,calc(100% - 208px - 86px));display:flex;flex-direction:column;gap:3px;color:var(--bn-faint);font-size:12px;line-height:1.65;pointer-events:none}
|
|
98
|
+
.bn-cs{position:absolute;z-index:5;right:18px;bottom:16px;width:46px;height:46px;padding:0;border:0;border-radius:50%;display:grid;place-items:center;cursor:pointer;background:#111;color:#d4f07a;box-shadow:0 10px 24px rgba(0,0,0,.18),inset 0 0 0 2px #d4f07a}
|
|
99
|
+
.bn-cs svg{animation:bn-cs-breathe 2.2s ease-in-out infinite}
|
|
100
|
+
.bn-cs:hover{transform:translateY(-1px)}
|
|
101
|
+
.bn-cs.on{box-shadow:0 10px 24px rgba(0,0,0,.18),inset 0 0 0 2px #d4f07a,0 0 0 4px rgba(212,240,122,.28)}
|
|
102
|
+
@keyframes bn-cs-breathe{0%,100%{transform:scale(1)}50%{transform:scale(1.14)}}
|
|
103
|
+
@media (prefers-reduced-motion:reduce){.bn-cs svg{animation:none}}
|
|
96
104
|
.bn-head{display:flex;align-items:flex-start;gap:12px;margin-bottom:20px}
|
|
97
105
|
.bn-h1{font-size:19px;font-weight:680;letter-spacing:-.015em;margin:0}
|
|
98
106
|
.bn-sub{color:var(--bn-muted);font-size:12px;margin-top:3px}
|
|
@@ -140,6 +148,53 @@
|
|
|
140
148
|
.bn-player-count{flex:none;color:rgba(244,241,234,.55);font-size:12px;font-variant-numeric:tabular-nums}
|
|
141
149
|
.bn-player-bar .bn-btn{background:#1c1c1c;color:#f4f1ea;border-color:#333}
|
|
142
150
|
.bn-player-bar .bn-btn.ghost{background:transparent;color:#f4f1ea;border-color:transparent}
|
|
151
|
+
.bn-player.has-script video{max-height:calc(90vh - 196px)}
|
|
152
|
+
.bn-player-dock{flex:none;display:flex;flex-direction:column;gap:10px;padding:14px 16px 12px;background:#111;color:#f4f1ea}
|
|
153
|
+
.bn-player-top{display:flex;align-items:center;gap:12px;min-width:0}
|
|
154
|
+
.bn-player-top strong{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;font-weight:700;letter-spacing:-.01em}
|
|
155
|
+
.bn-player-dock .bn-player-count{color:rgba(244,241,234,.48)}
|
|
156
|
+
.bn-player-quote{margin:0;padding:10px 12px;border-radius:10px;background:#1c1c1c;color:rgba(244,241,234,.9);font-size:13px;line-height:1.55;max-height:4.65em;overflow:auto;white-space:pre-wrap}
|
|
157
|
+
.bn-player-quote.quiet{color:rgba(244,241,234,.62)}
|
|
158
|
+
.bn-player-quote.lock{color:#d4f07a;background:rgba(212,240,122,.08);box-shadow:inset 0 0 0 1px rgba(212,240,122,.32)}
|
|
159
|
+
.bn-player-foot{display:flex;align-items:center;gap:8px;min-width:0}
|
|
160
|
+
.bn-player-nav{display:flex;gap:6px;flex:none}
|
|
161
|
+
.bn-player-actions{display:flex;gap:8px;align-items:center;margin-left:auto}
|
|
162
|
+
.bn-player-dock .bn-btn{height:30px;padding:0 12px;background:#1c1c1c;color:#f4f1ea;border-color:#2c2c2c}
|
|
163
|
+
.bn-player-dock .bn-btn.play{background:#d4f07a;color:#111;border-color:#d4f07a;font-weight:700}
|
|
164
|
+
.bn-player-dock .bn-btn.ghost{background:transparent;border-color:transparent;color:rgba(244,241,234,.72);padding:0 4px}
|
|
165
|
+
.bn-market-back{position:fixed;inset:0;z-index:2147483000;background:rgba(10,10,10,.46);display:grid;place-items:center;padding:calc(28px + env(titlebar-area-height, 0px)) 28px 28px;width:auto;height:auto;max-width:none;max-height:none;margin:0;border:0;overflow:visible;color:inherit}
|
|
166
|
+
@supports selector(:popover-open){
|
|
167
|
+
.bn-market-back[popover]:popover-open{display:grid}
|
|
168
|
+
}
|
|
169
|
+
.bn-market{width:min(1080px,calc(100vw - 48px));max-height:min(820px,calc(100vh - 64px));display:flex;flex-direction:column;overflow:hidden;background:var(--bn-bg);color:var(--bn-ink);border:1px solid var(--bn-line);border-radius:22px;box-shadow:var(--bn-shadow-hover)}
|
|
170
|
+
.bn-market-head{position:relative;flex:none;padding:22px 24px 16px;border-bottom:1px solid var(--bn-line);background:radial-gradient(560px 180px at 100% 0%,rgba(212,240,122,.55),transparent 72%),var(--bn-surface)}
|
|
171
|
+
.bn-market-kicker{font-size:11px;letter-spacing:.14em;text-transform:uppercase;color:var(--bn-muted);font-weight:650}
|
|
172
|
+
.bn-market-head h2{margin:4px 70px 0 0;font-size:22px;line-height:1.2;letter-spacing:-.03em;font-weight:680}
|
|
173
|
+
.bn-market-head p{margin:6px 70px 0 0;color:var(--bn-muted);font-size:12.5px}
|
|
174
|
+
.bn-market-x{position:absolute;top:16px;right:16px;width:32px;height:32px;border:0;border-radius:10px;background:transparent;color:var(--bn-muted);font-size:20px;line-height:1;cursor:pointer}
|
|
175
|
+
.bn-market-x:hover{background:var(--bn-line);color:var(--bn-ink)}
|
|
176
|
+
.bn-market-filters{display:flex;flex-wrap:wrap;gap:6px;margin-top:14px}
|
|
177
|
+
.bn-market-filters button{border:1px solid var(--bn-line);background:var(--bn-surface);color:var(--bn-muted);border-radius:999px;padding:5px 12px;font:inherit;font-size:12px;font-weight:650;cursor:pointer}
|
|
178
|
+
.bn-market-filters button:hover{color:var(--bn-ink);border-color:var(--bn-line-strong)}
|
|
179
|
+
.bn-market-filters button.on{background:#111;color:#d4f07a;border-color:#111}
|
|
180
|
+
.bn-market-body{min-height:0;max-height:min(640px,calc(100vh - 230px));overflow:auto;padding:18px 22px 24px}
|
|
181
|
+
.bn-market-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:14px}
|
|
182
|
+
.bn-case{display:flex;flex-direction:column;width:100%;padding:0;overflow:hidden;text-align:left;color:inherit;font:inherit;cursor:pointer;background:var(--bn-surface);border:1px solid var(--bn-line);border-radius:16px;box-shadow:var(--bn-shadow)}
|
|
183
|
+
.bn-case:hover{box-shadow:var(--bn-shadow-hover);border-color:var(--bn-line-strong)}
|
|
184
|
+
.bn-case-cover{position:relative;aspect-ratio:16/9;background:#141414}
|
|
185
|
+
.bn-case-cover img{width:100%;height:100%;object-fit:cover;display:block}
|
|
186
|
+
.bn-case-fallback{width:100%;height:100%;display:grid;place-items:center;background:radial-gradient(120px 80px at 80% 20%,rgba(212,240,122,.45),transparent 70%),#141414;color:#d4f07a;font-weight:700;letter-spacing:.08em;font-size:13px}
|
|
187
|
+
.bn-case-play{position:absolute;right:10px;bottom:10px;width:34px;height:34px;border-radius:999px;display:grid;place-items:center;background:#d4f07a;color:#111;box-shadow:0 6px 16px rgba(0,0,0,.28)}
|
|
188
|
+
.bn-case-lock{position:absolute;left:10px;top:10px;padding:3px 8px;border-radius:999px;background:rgba(17,17,17,.78);color:#d4f07a;font-size:11px;font-weight:700;letter-spacing:.04em}
|
|
189
|
+
.bn-case-body{padding:12px 12px 14px}
|
|
190
|
+
.bn-case-title{font-weight:680;font-size:14px;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
191
|
+
.bn-case-blurb{margin-top:4px;color:var(--bn-muted);font-size:12px;line-height:1.45;min-height:2.9em;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
|
|
192
|
+
.bn-case-meta{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
|
|
193
|
+
.bn-case-meta span{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--bn-muted);background:var(--bn-line);border-radius:999px;padding:2px 8px}
|
|
194
|
+
@media (prefers-color-scheme:dark){
|
|
195
|
+
.bn-market-head{background:radial-gradient(560px 180px at 100% 0%,rgba(212,240,122,.16),transparent 72%),var(--bn-surface)}
|
|
196
|
+
.bn-case-fallback{background:radial-gradient(120px 80px at 80% 20%,rgba(212,240,122,.2),transparent 70%),#111}
|
|
197
|
+
}
|
|
143
198
|
.bn-docs-back{position:fixed;inset:0;z-index:2147483000;background:rgba(10,10,10,.28);width:auto;height:auto;max-width:none;max-height:none;margin:0;border:0;padding:0;overflow:visible;color:inherit}
|
|
144
199
|
@supports selector(:popover-open){
|
|
145
200
|
.bn-docs-back[popover]:popover-open{display:block}
|
|
@@ -597,6 +652,13 @@
|
|
|
597
652
|
const [contactOpen, setContactOpen] = useState(false);
|
|
598
653
|
const [campIdx, setCampIdx] = useState(0);
|
|
599
654
|
const [reelIdx, setReelIdx] = useState(0);
|
|
655
|
+
const [marketOpen, setMarketOpen] = useState(false);
|
|
656
|
+
const [marketFilter, setMarketFilter] = useState('all');
|
|
657
|
+
const [unlocked, setUnlocked] = useState({});
|
|
658
|
+
const [promptBusy, setPromptBusy] = useState('');
|
|
659
|
+
const [promptError, setPromptError] = useState({});
|
|
660
|
+
const [caseSeed, setCaseSeed] = useState(null);
|
|
661
|
+
const [seedNonce, setSeedNonce] = useState(0);
|
|
600
662
|
const [player, setPlayer] = useState(null);
|
|
601
663
|
const [playerRatio, setPlayerRatio] = useState(16 / 9);
|
|
602
664
|
const [docsOpen, setDocsOpen] = useState(false);
|
|
@@ -656,7 +718,7 @@
|
|
|
656
718
|
} catch (err) { /* 节点已经卸下 */ }
|
|
657
719
|
});
|
|
658
720
|
};
|
|
659
|
-
}, [docsOpen, caseOpen]);
|
|
721
|
+
}, [docsOpen, caseOpen, marketOpen]);
|
|
660
722
|
|
|
661
723
|
const openContact = async () => {
|
|
662
724
|
setContactOpen(true);
|
|
@@ -774,13 +836,55 @@
|
|
|
774
836
|
setPlayer(null);
|
|
775
837
|
};
|
|
776
838
|
|
|
839
|
+
const closeMarket = () => {
|
|
840
|
+
setMarketOpen(false);
|
|
841
|
+
closePlayer();
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
const primePrompt = (item) => {
|
|
845
|
+
if (!promptsOn || !item || item.access !== 'licensed' || !holdsProduct(item.agent)) return;
|
|
846
|
+
if (Object.prototype.hasOwnProperty.call(unlocked, item.id) || promptBusy === item.id) return;
|
|
847
|
+
setPromptBusy(item.id);
|
|
848
|
+
setPromptError((cur) => {
|
|
849
|
+
const next = { ...cur };
|
|
850
|
+
delete next[item.id];
|
|
851
|
+
return next;
|
|
852
|
+
});
|
|
853
|
+
api('/showcase/prompt', { method: 'POST', body: { id: item.id } })
|
|
854
|
+
.then((got) => {
|
|
855
|
+
setUnlocked((cur) => ({ ...cur, [item.id]: String((got && got.prompt) || '') }));
|
|
856
|
+
})
|
|
857
|
+
.catch((err) => {
|
|
858
|
+
setPromptError((cur) => ({ ...cur, [item.id]: err.message || '暂时无法获取提示词' }));
|
|
859
|
+
})
|
|
860
|
+
.finally(() => setPromptBusy((cur) => (cur === item.id ? '' : cur)));
|
|
861
|
+
};
|
|
862
|
+
|
|
777
863
|
const openPlayer = (item) => {
|
|
778
864
|
if (!item || !item.videoUrl) return;
|
|
779
865
|
setPlayerRatio(16 / 9);
|
|
780
866
|
setPlayer(item);
|
|
867
|
+
primePrompt(item);
|
|
781
868
|
};
|
|
782
869
|
|
|
783
|
-
const
|
|
870
|
+
const promptsOn = !!(state && state.showcase && state.showcase.promptsEnabled);
|
|
871
|
+
const AGENT_ORDER = ['biureel', 'biuremtion', 'biuvibe', 'biutalk'];
|
|
872
|
+
const AGENT_FALLBACK = { biureel: 'BiuReel', biuremtion: 'BiuRemo', biuvibe: 'BiuVibe', biutalk: 'BiuTalk' };
|
|
873
|
+
const agentName = (slug) => {
|
|
874
|
+
const hit = ((state && state.store) || []).find((item) => item.slug === slug);
|
|
875
|
+
if (hit && hit.name) return hit.name;
|
|
876
|
+
return AGENT_FALLBACK[slug] || slug || '这个 Agent';
|
|
877
|
+
};
|
|
878
|
+
const holdsProduct = (slug) => {
|
|
879
|
+
const row = ((state && state.licenses) || []).find((item) => item.product === slug);
|
|
880
|
+
return !!(row && row.status && row.status.canExport);
|
|
881
|
+
};
|
|
882
|
+
const caseRows = () => ((state && state.showcase && state.showcase.cases) || []);
|
|
883
|
+
const playerRows = () => {
|
|
884
|
+
const rows = caseRows();
|
|
885
|
+
if (!promptsOn || marketFilter === 'all') return rows;
|
|
886
|
+
return rows.filter((row) => row.agent === marketFilter);
|
|
887
|
+
};
|
|
784
888
|
|
|
785
889
|
const movePlayer = (delta) => {
|
|
786
890
|
const rows = playerRows();
|
|
@@ -790,6 +894,7 @@
|
|
|
790
894
|
setPlayerRatio(16 / 9);
|
|
791
895
|
setPlayer(rows[nextAt]);
|
|
792
896
|
setReelIdx(nextAt);
|
|
897
|
+
primePrompt(rows[nextAt]);
|
|
793
898
|
};
|
|
794
899
|
|
|
795
900
|
useEffect(() => {
|
|
@@ -803,24 +908,72 @@
|
|
|
803
908
|
};
|
|
804
909
|
window.addEventListener('keydown', onKey);
|
|
805
910
|
return () => window.removeEventListener('keydown', onKey);
|
|
806
|
-
}, [player, state]);
|
|
911
|
+
}, [player, state, marketFilter]);
|
|
807
912
|
|
|
808
|
-
|
|
913
|
+
useEffect(() => {
|
|
914
|
+
if (!marketOpen || player) return undefined;
|
|
915
|
+
const onKey = (ev) => { if (ev.key === 'Escape') closeMarket(); };
|
|
916
|
+
window.addEventListener('keydown', onKey);
|
|
917
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
918
|
+
}, [marketOpen, player]);
|
|
919
|
+
|
|
920
|
+
const goActivate = (slug) => {
|
|
921
|
+
closeMarket();
|
|
922
|
+
setProductInput(slug || 'biutalk');
|
|
923
|
+
setTab('account');
|
|
924
|
+
setToast({ text: '请激活「' + agentName(slug) + '」后查看提示词并做同款' });
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
const copyPrompt = async (text) => {
|
|
928
|
+
const value = String(text || '').trim();
|
|
929
|
+
if (!value) return;
|
|
930
|
+
try {
|
|
931
|
+
await navigator.clipboard.writeText(value);
|
|
932
|
+
setToast({ text: '提示词已复制' });
|
|
933
|
+
} catch {
|
|
934
|
+
setToast({ text: '复制失败,请手动选择提示词', bad: true });
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
const shootLike = async (item) => {
|
|
809
939
|
const slug = item && item.agent;
|
|
810
940
|
if (!slug) return;
|
|
941
|
+
if (promptsOn && item.access === 'licensed' && !holdsProduct(slug)) {
|
|
942
|
+
goActivate(slug);
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
811
945
|
const hit = (state.store || []).find((s) => s.slug === slug);
|
|
812
946
|
const installed = (state.agents || []).find((a) => a.id === slug || a.product === slug) || (hit && hit.agent);
|
|
813
947
|
if (!installed) {
|
|
814
948
|
setToast({ text: '请先安装对应 Agent,再使用同款开拍', bad: true });
|
|
815
949
|
return;
|
|
816
950
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
951
|
+
let prompt = '';
|
|
952
|
+
if (promptsOn && item.access === 'licensed') {
|
|
953
|
+
try {
|
|
954
|
+
const got = await api('/showcase/prompt', { method: 'POST', body: { id: item.id } });
|
|
955
|
+
prompt = String((got && got.prompt) || '');
|
|
956
|
+
setUnlocked((cur) => ({ ...cur, [item.id]: prompt }));
|
|
957
|
+
} catch (err) {
|
|
958
|
+
setToast({ text: err.message || '暂时无法获取提示词', bad: true });
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
} else if (promptsOn) {
|
|
962
|
+
prompt = item.prompt || '';
|
|
963
|
+
}
|
|
964
|
+
const nonce = seedNonce + 1;
|
|
965
|
+
setSeedNonce(nonce);
|
|
966
|
+
const parts = [];
|
|
967
|
+
if (item.style) parts.push('style=' + encodeURIComponent(item.style));
|
|
968
|
+
if (item.id) parts.push('case=' + encodeURIComponent(item.id));
|
|
969
|
+
parts.push('seed=' + nonce);
|
|
970
|
+
closeMarket();
|
|
971
|
+
return openStudio(installed.id, parts.join('&'), prompt ? { id: item.id, prompt, style: item.style || '' } : null);
|
|
820
972
|
};
|
|
821
973
|
|
|
822
|
-
const openStudio = async (id, query) => {
|
|
974
|
+
const openStudio = async (id, query, seed) => {
|
|
823
975
|
setStudioQuery(query || '');
|
|
976
|
+
setCaseSeed(seed || null);
|
|
824
977
|
const agent = (state.agents || []).find((a) => a.id === id);
|
|
825
978
|
if (agent && agent.needsPermissionAck && !agent.permissionsAck) {
|
|
826
979
|
setPendingPerm(agent);
|
|
@@ -956,8 +1109,13 @@
|
|
|
956
1109
|
setToast({ text: '还没有案例', bad: true });
|
|
957
1110
|
return;
|
|
958
1111
|
}
|
|
959
|
-
|
|
960
|
-
|
|
1112
|
+
if (!promptsOn) {
|
|
1113
|
+
const at = ((reelIdx % cases.length) + cases.length) % cases.length;
|
|
1114
|
+
openPlayer(cases[at]);
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
setMarketFilter('all');
|
|
1118
|
+
setMarketOpen(true);
|
|
961
1119
|
};
|
|
962
1120
|
const topSeg = h('div', { className: 'bn-seg' },
|
|
963
1121
|
h('span', { className: 'on', title: (state.license && state.license.reason) || '' }, licenseOn ? '已授权' : '未授权'),
|
|
@@ -1009,7 +1167,7 @@
|
|
|
1009
1167
|
h('div', { className: 'bn-mono', style: { marginTop: 4 } }, licenses.length ? (licenses.length + ' 产品授权') : state.license.state),
|
|
1010
1168
|
),
|
|
1011
1169
|
),
|
|
1012
|
-
h('main', { className: 'bn-main' },
|
|
1170
|
+
h('main', { className: 'bn-main' + (tab === 'agents' ? ' has-note' : '') },
|
|
1013
1171
|
tab !== 'studio' ? h('div', { className: 'bn-head' },
|
|
1014
1172
|
h('div', null,
|
|
1015
1173
|
h('h1', { className: 'bn-h1' }, tab === 'agents' ? '今天就出片' : tab === 'tasks' ? '任务' : tab === 'account' ? '我的授权' : '设置'),
|
|
@@ -1101,6 +1259,24 @@
|
|
|
1101
1259
|
title: studioAgent.name,
|
|
1102
1260
|
src: studioAgent.studioUrl + (studioQuery ? (String(studioAgent.studioUrl).indexOf('?') >= 0 ? '&' : '?') + studioQuery : ''),
|
|
1103
1261
|
allow: 'clipboard-read; clipboard-write; fullscreen',
|
|
1262
|
+
onLoad: (event) => {
|
|
1263
|
+
const frame = event.target;
|
|
1264
|
+
const seed = caseSeed;
|
|
1265
|
+
if (!seed || !seed.prompt || !frame.contentWindow) return;
|
|
1266
|
+
const send = () => {
|
|
1267
|
+
try {
|
|
1268
|
+
frame.contentWindow.postMessage({
|
|
1269
|
+
type: 'bn-case-prompt',
|
|
1270
|
+
prompt: seed.prompt,
|
|
1271
|
+
style: seed.style || '',
|
|
1272
|
+
caseId: seed.id || '',
|
|
1273
|
+
}, '*');
|
|
1274
|
+
} catch { /* Studio 还没挂上 */ }
|
|
1275
|
+
};
|
|
1276
|
+
send();
|
|
1277
|
+
window.setTimeout(send, 500);
|
|
1278
|
+
window.setTimeout(send, 1500);
|
|
1279
|
+
},
|
|
1104
1280
|
}),
|
|
1105
1281
|
)
|
|
1106
1282
|
: h('div', { className: 'bn-empty' },
|
|
@@ -1161,7 +1337,9 @@
|
|
|
1161
1337
|
);
|
|
1162
1338
|
}),
|
|
1163
1339
|
)
|
|
1164
|
-
: h('div', { className: 'bn-sub' },
|
|
1340
|
+
: h('div', { className: 'bn-sub' }, Number(state.trialRuns) > 0
|
|
1341
|
+
? '尚未激活正式授权。安装后每个 Agent 可试用 ' + state.trialRuns + ' 次;购买后激活码会发到邮箱。'
|
|
1342
|
+
: '尚未激活正式授权。购买后激活码会发到邮箱。'),
|
|
1165
1343
|
h('div', { className: 'bn-activate' },
|
|
1166
1344
|
h(BnDropdown, {
|
|
1167
1345
|
value: productInput,
|
|
@@ -1238,7 +1416,9 @@
|
|
|
1238
1416
|
: ''),
|
|
1239
1417
|
) : null,
|
|
1240
1418
|
h('p', { className: 'bn-sub', style: { marginTop: 8 } }, '面板更新提示:手动卸载旧面板,再次通过 bnpanel 安装最新版本即可'),
|
|
1241
|
-
h('p', { className: 'bn-sub', style: { marginTop: 18 } },
|
|
1419
|
+
h('p', { className: 'bn-sub', style: { marginTop: 18 } }, Number(state.trialRuns) > 0
|
|
1420
|
+
? '安装免费;每个 Agent 首次安装赠送 ' + state.trialRuns + ' 次试用生成。正式授权请到「我的授权」。'
|
|
1421
|
+
: '安装免费。正式授权请到「我的授权」。'),
|
|
1242
1422
|
checkNote ? h('p', { className: 'bn-sub', style: { marginTop: 8 } }, checkNote) : null,
|
|
1243
1423
|
h('div', { style: { marginTop: 16, display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
|
1244
1424
|
h('button', {
|
|
@@ -1263,6 +1443,26 @@
|
|
|
1263
1443
|
) : null,
|
|
1264
1444
|
),
|
|
1265
1445
|
|
|
1446
|
+
tab === 'agents' ? h('p', { className: 'bn-foot-note' },
|
|
1447
|
+
h('span', null, '开了新任务,到左侧聊天窗口看进度。'),
|
|
1448
|
+
h('span', null, '开拍前,在聊天窗口给 DSH 全部权限。'),
|
|
1449
|
+
h('span', null, '其他问题,点右下角客服。'),
|
|
1450
|
+
) : null,
|
|
1451
|
+
h('button', {
|
|
1452
|
+
type: 'button',
|
|
1453
|
+
className: 'bn-cs' + (contactOpen ? ' on' : ''),
|
|
1454
|
+
'aria-label': '在线客服',
|
|
1455
|
+
title: '在线客服',
|
|
1456
|
+
onClick: () => { void openContact(); },
|
|
1457
|
+
},
|
|
1458
|
+
h('svg', { width: 22, height: 22, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true },
|
|
1459
|
+
h('path', { d: 'M4 13a8 8 0 0 1 16 0' }),
|
|
1460
|
+
h('path', { d: 'M4 13v3a2 2 0 0 0 2 2h1.5v-7H6a2 2 0 0 0-2 2z' }),
|
|
1461
|
+
h('path', { d: 'M20 13v3a2 2 0 0 1-2 2h-1.5v-7H18a2 2 0 0 1 2 2z' }),
|
|
1462
|
+
h('path', { d: 'M12 20h2.5a2 2 0 0 0 2-2' }),
|
|
1463
|
+
),
|
|
1464
|
+
),
|
|
1465
|
+
|
|
1266
1466
|
contactOpen ? h('div', { className: 'bn-modal-back', onClick: (e) => { if (e.target === e.currentTarget) setContactOpen(false); } },
|
|
1267
1467
|
h('div', { className: 'bn-modal bn-contact', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'bn-contact-title' },
|
|
1268
1468
|
h('div', { className: 'bn-contact-head' },
|
|
@@ -1380,12 +1580,81 @@
|
|
|
1380
1580
|
),
|
|
1381
1581
|
) : null,
|
|
1382
1582
|
|
|
1583
|
+
marketOpen ? (() => {
|
|
1584
|
+
const rows = caseRows();
|
|
1585
|
+
const slugs = [];
|
|
1586
|
+
AGENT_ORDER.forEach((slug) => { if (rows.some((row) => row.agent === slug)) slugs.push(slug); });
|
|
1587
|
+
rows.forEach((row) => { if (row.agent && slugs.indexOf(row.agent) < 0) slugs.push(row.agent); });
|
|
1588
|
+
const visible = marketFilter === 'all' ? rows : rows.filter((row) => row.agent === marketFilter);
|
|
1589
|
+
return h('div', { className: 'bn-market-back bn-layer', popover: 'manual', onClick: (event) => { if (event.target === event.currentTarget) closeMarket(); } },
|
|
1590
|
+
h('div', { className: 'bn-market', role: 'dialog', 'aria-modal': 'true', 'aria-label': '案例' },
|
|
1591
|
+
h('div', { className: 'bn-market-head' },
|
|
1592
|
+
h('div', { className: 'bn-market-kicker' }, rows.length + ' 条成片'),
|
|
1593
|
+
h('h2', null, '看成品,拿提示词去拍'),
|
|
1594
|
+
h('p', null, '公开的可以直接复制或做同款。标了专享的,要先激活对应的 Agent。'),
|
|
1595
|
+
h('button', { type: 'button', className: 'bn-market-x', onClick: closeMarket, 'aria-label': '关闭' }, '×'),
|
|
1596
|
+
h('div', { className: 'bn-market-filters' },
|
|
1597
|
+
h('button', { type: 'button', className: marketFilter === 'all' ? 'on' : '', 'aria-pressed': marketFilter === 'all', onClick: () => setMarketFilter('all') }, '全部'),
|
|
1598
|
+
slugs.map((slug) => h('button', {
|
|
1599
|
+
key: slug,
|
|
1600
|
+
type: 'button',
|
|
1601
|
+
className: marketFilter === slug ? 'on' : '',
|
|
1602
|
+
'aria-pressed': marketFilter === slug,
|
|
1603
|
+
onClick: () => setMarketFilter(slug),
|
|
1604
|
+
}, agentName(slug))),
|
|
1605
|
+
),
|
|
1606
|
+
),
|
|
1607
|
+
h('div', { className: 'bn-market-body' },
|
|
1608
|
+
visible.length
|
|
1609
|
+
? h('div', { className: 'bn-market-grid' }, visible.map((item) => h('button', {
|
|
1610
|
+
key: item.id,
|
|
1611
|
+
type: 'button',
|
|
1612
|
+
className: 'bn-case',
|
|
1613
|
+
onClick: () => openPlayer(item),
|
|
1614
|
+
},
|
|
1615
|
+
h('div', { className: 'bn-case-cover' },
|
|
1616
|
+
item.coverUrl
|
|
1617
|
+
? h('img', { src: item.coverUrl, alt: '' })
|
|
1618
|
+
: h('div', { className: 'bn-case-fallback' }, agentName(item.agent)),
|
|
1619
|
+
item.access === 'licensed' ? h('span', { className: 'bn-case-lock' }, '专享') : null,
|
|
1620
|
+
h('span', { className: 'bn-case-play', 'aria-hidden': true },
|
|
1621
|
+
h('svg', { width: 12, height: 12, viewBox: '0 0 24 24' }, h('path', { d: 'M8 5v14l11-7z', fill: 'currentColor' })),
|
|
1622
|
+
),
|
|
1623
|
+
),
|
|
1624
|
+
h('div', { className: 'bn-case-body' },
|
|
1625
|
+
h('div', { className: 'bn-case-title' }, item.title),
|
|
1626
|
+
h('div', { className: 'bn-case-blurb' }, item.blurb || (item.access === 'licensed' ? '激活后可查看提示词,并一键做同款。' : '看完这条,就可以按同样的提示词再拍一条。')),
|
|
1627
|
+
h('div', { className: 'bn-case-meta' },
|
|
1628
|
+
item.agent ? h('span', null, agentName(item.agent)) : null,
|
|
1629
|
+
item.style ? h('span', null, item.style) : null,
|
|
1630
|
+
),
|
|
1631
|
+
),
|
|
1632
|
+
)))
|
|
1633
|
+
: h('div', { className: 'bn-empty' },
|
|
1634
|
+
h('h3', null, '这个 Agent 还没有案例'),
|
|
1635
|
+
h('p', null, '换一个筛选,或者等新的成片上架。'),
|
|
1636
|
+
),
|
|
1637
|
+
),
|
|
1638
|
+
),
|
|
1639
|
+
);
|
|
1640
|
+
})() : null,
|
|
1641
|
+
|
|
1383
1642
|
player ? (() => {
|
|
1384
1643
|
const rows = playerRows();
|
|
1385
1644
|
const at = Math.max(0, rows.findIndex((row) => row.id === player.id));
|
|
1386
1645
|
const many = rows.length > 1;
|
|
1646
|
+
const licensed = player.access === 'licensed';
|
|
1647
|
+
const owned = holdsProduct(player.agent);
|
|
1648
|
+
const known = Object.prototype.hasOwnProperty.call(unlocked, player.id);
|
|
1649
|
+
const text = licensed ? (known ? unlocked[player.id] : '') : (player.prompt || '');
|
|
1650
|
+
const waiting = promptsOn && licensed && owned && !known && !promptError[player.id];
|
|
1651
|
+
const failed = promptsOn && licensed && owned && promptError[player.id];
|
|
1652
|
+
const locked = promptsOn && licensed && !owned;
|
|
1653
|
+
const shoot = player.agent
|
|
1654
|
+
? h('button', { type: 'button', className: 'bn-btn play', onClick: () => { void shootLike(player); } }, locked ? '去激活' : '用同款开拍')
|
|
1655
|
+
: null;
|
|
1387
1656
|
return h('div', { className: 'bn-player-back bn-layer', popover: 'manual', onClick: (event) => { if (event.target === event.currentTarget) closePlayer(); } },
|
|
1388
|
-
h('div', { id: 'bn-player', className: 'bn-player', style: { '--ar': String(playerRatio) }, role: 'dialog' },
|
|
1657
|
+
h('div', { id: 'bn-player', className: 'bn-player' + (promptsOn ? ' has-script' : ''), style: { '--ar': String(playerRatio) }, role: 'dialog', 'aria-label': player.title },
|
|
1389
1658
|
h('video', {
|
|
1390
1659
|
key: player.id,
|
|
1391
1660
|
id: 'bn-player-video',
|
|
@@ -1399,11 +1668,36 @@
|
|
|
1399
1668
|
if (node.videoWidth && node.videoHeight) setPlayerRatio(node.videoWidth / node.videoHeight);
|
|
1400
1669
|
},
|
|
1401
1670
|
}),
|
|
1402
|
-
h('div', { className: 'bn-player-
|
|
1671
|
+
promptsOn ? h('div', { className: 'bn-player-dock' },
|
|
1672
|
+
h('div', { className: 'bn-player-top' },
|
|
1673
|
+
h('strong', null, player.title),
|
|
1674
|
+
many ? h('span', { className: 'bn-player-count' }, (at + 1) + ' / ' + rows.length) : null,
|
|
1675
|
+
h('button', { type: 'button', className: 'bn-btn ghost', onClick: closePlayer }, '关闭'),
|
|
1676
|
+
),
|
|
1677
|
+
locked
|
|
1678
|
+
? h('p', { className: 'bn-player-quote lock' }, '激活 ' + agentName(player.agent) + ' 后可查看提示词并做同款')
|
|
1679
|
+
: h('p', { className: 'bn-player-quote' + (text ? '' : ' quiet') },
|
|
1680
|
+
waiting ? '正在打开这条提示词…'
|
|
1681
|
+
: failed ? promptError[player.id]
|
|
1682
|
+
: text || '这条还没有提示词。做同款会按它的风格模板开拍。'),
|
|
1683
|
+
h('div', { className: 'bn-player-foot' },
|
|
1684
|
+
many ? h('div', { className: 'bn-player-nav' },
|
|
1685
|
+
h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(-1) }, '上一条'),
|
|
1686
|
+
h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(1) }, '下一条'),
|
|
1687
|
+
) : null,
|
|
1688
|
+
h('div', { className: 'bn-player-actions' },
|
|
1689
|
+
text ? h('button', { type: 'button', className: 'bn-btn', onClick: () => { void copyPrompt(text); } }, '复制') : null,
|
|
1690
|
+
failed ? h('button', { type: 'button', className: 'bn-btn', onClick: () => { setPromptError((cur) => { const next = { ...cur }; delete next[player.id]; return next; }); primePrompt(player); } }, '重试') : null,
|
|
1691
|
+
locked
|
|
1692
|
+
? h('button', { type: 'button', className: 'bn-btn play', onClick: () => goActivate(player.agent) }, '去激活')
|
|
1693
|
+
: shoot,
|
|
1694
|
+
),
|
|
1695
|
+
),
|
|
1696
|
+
) : h('div', { className: 'bn-player-bar' },
|
|
1403
1697
|
many ? h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(-1) }, '上一条') : null,
|
|
1404
1698
|
h('span', { className: 'bn-player-count' }, '案例' + (many ? ' ' + (at + 1) + ' / ' + rows.length : '')),
|
|
1405
1699
|
h('strong', null, player.title),
|
|
1406
|
-
|
|
1700
|
+
shoot,
|
|
1407
1701
|
many ? h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(1) }, '下一条') : null,
|
|
1408
1702
|
h('button', { type: 'button', className: 'bn-btn ghost', onClick: closePlayer }, '关闭'),
|
|
1409
1703
|
),
|
package/index.js
CHANGED
|
@@ -8848,6 +8848,24 @@ function createPanelApp(options = {}) {
|
|
|
8848
8848
|
function callbackBaseUrl() {
|
|
8849
8849
|
return getPanelPublicUrl();
|
|
8850
8850
|
}
|
|
8851
|
+
const DEFAULT_TRIAL_RUNS = 3;
|
|
8852
|
+
let trialRuns = DEFAULT_TRIAL_RUNS;
|
|
8853
|
+
let trialRunsAt = 0;
|
|
8854
|
+
async function refreshTrialRuns() {
|
|
8855
|
+
if (trialRunsAt && Date.now() - trialRunsAt < 10 * 60 * 1e3) return trialRuns;
|
|
8856
|
+
trialRunsAt = Date.now();
|
|
8857
|
+
const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
|
|
8858
|
+
if (!base) return trialRuns;
|
|
8859
|
+
try {
|
|
8860
|
+
const res = await fetch(`${base}/v1/commerce/site`, { cache: "no-store" });
|
|
8861
|
+
if (!res.ok) return trialRuns;
|
|
8862
|
+
const body = await res.json();
|
|
8863
|
+
const n = Number(body?.site?.trialRuns);
|
|
8864
|
+
if (Number.isFinite(n)) trialRuns = Math.max(0, Math.min(99, Math.floor(n)));
|
|
8865
|
+
} catch {
|
|
8866
|
+
}
|
|
8867
|
+
return trialRuns;
|
|
8868
|
+
}
|
|
8851
8869
|
function trialsPath() {
|
|
8852
8870
|
return path14.join(paths.root, "trials.json");
|
|
8853
8871
|
}
|
|
@@ -8863,14 +8881,15 @@ function createPanelApp(options = {}) {
|
|
|
8863
8881
|
fs14.mkdirSync(paths.root, { recursive: true });
|
|
8864
8882
|
fs14.writeFileSync(trialsPath(), JSON.stringify(data, null, 2));
|
|
8865
8883
|
}
|
|
8866
|
-
function grantTrial(product) {
|
|
8884
|
+
async function grantTrial(product) {
|
|
8867
8885
|
if (!product) return;
|
|
8886
|
+
if (readTrials()[product]?.granted) return readTrials()[product];
|
|
8887
|
+
await refreshTrialRuns();
|
|
8868
8888
|
const all = readTrials();
|
|
8869
8889
|
if (all[product]?.granted) return all[product];
|
|
8870
|
-
all[product] = { remaining:
|
|
8890
|
+
all[product] = { remaining: trialRuns, granted: true, grantedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
8871
8891
|
writeTrials(all);
|
|
8872
|
-
|
|
8873
|
-
return all[product];
|
|
8892
|
+
return await syncTrialCheck(product) || all[product];
|
|
8874
8893
|
}
|
|
8875
8894
|
function trialOf(product) {
|
|
8876
8895
|
if (!product) return { remaining: 0, granted: false };
|
|
@@ -8889,11 +8908,14 @@ function createPanelApp(options = {}) {
|
|
|
8889
8908
|
if (!res.ok) return null;
|
|
8890
8909
|
const data = await res.json();
|
|
8891
8910
|
const all = readTrials();
|
|
8911
|
+
const prev = all[product] || {};
|
|
8912
|
+
const remaining = Number(data.remaining);
|
|
8892
8913
|
all[product] = {
|
|
8893
|
-
remaining: Number(
|
|
8914
|
+
remaining: Number.isFinite(remaining) ? remaining : 0,
|
|
8894
8915
|
granted: true,
|
|
8895
|
-
grantedAt: data.grantedAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
8896
|
-
lastUsedAt: data.usedAt ||
|
|
8916
|
+
grantedAt: data.grantedAt || prev.grantedAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
8917
|
+
lastUsedAt: data.usedAt || prev.lastUsedAt,
|
|
8918
|
+
charged: prev.charged,
|
|
8897
8919
|
server: true
|
|
8898
8920
|
};
|
|
8899
8921
|
writeTrials(all);
|
|
@@ -8902,12 +8924,31 @@ function createPanelApp(options = {}) {
|
|
|
8902
8924
|
return null;
|
|
8903
8925
|
}
|
|
8904
8926
|
}
|
|
8905
|
-
function consumeTrial(product) {
|
|
8927
|
+
function consumeTrial(product, keys) {
|
|
8906
8928
|
if (!product) return false;
|
|
8907
8929
|
if (license.canUseProduct(product)) return false;
|
|
8930
|
+
const ids = [...new Set((Array.isArray(keys) ? keys : []).map((k2) => String(k2 || "").trim()).filter(Boolean))];
|
|
8931
|
+
if (!ids.length) return false;
|
|
8908
8932
|
const all = readTrials();
|
|
8909
8933
|
const row = all[product];
|
|
8910
8934
|
if (!row || !(row.remaining > 0)) return false;
|
|
8935
|
+
const charged = new Set(Array.isArray(row.charged) ? row.charged.map(String) : []);
|
|
8936
|
+
if (ids.some((id) => charged.has(id))) {
|
|
8937
|
+
let dirty = false;
|
|
8938
|
+
for (const id of ids) {
|
|
8939
|
+
if (!charged.has(id)) {
|
|
8940
|
+
charged.add(id);
|
|
8941
|
+
dirty = true;
|
|
8942
|
+
}
|
|
8943
|
+
}
|
|
8944
|
+
if (dirty) {
|
|
8945
|
+
row.charged = [...charged].slice(-400);
|
|
8946
|
+
writeTrials(all);
|
|
8947
|
+
}
|
|
8948
|
+
return false;
|
|
8949
|
+
}
|
|
8950
|
+
for (const id of ids) charged.add(id);
|
|
8951
|
+
row.charged = [...charged].slice(-400);
|
|
8911
8952
|
row.remaining -= 1;
|
|
8912
8953
|
row.lastUsedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
8913
8954
|
writeTrials(all);
|
|
@@ -8925,6 +8966,9 @@ function createPanelApp(options = {}) {
|
|
|
8925
8966
|
})();
|
|
8926
8967
|
return true;
|
|
8927
8968
|
}
|
|
8969
|
+
function trialChargeKeys(parts) {
|
|
8970
|
+
return (parts || []).map((k2) => String(k2 || "").trim()).filter(Boolean);
|
|
8971
|
+
}
|
|
8928
8972
|
function healTrialIfJobDone(product, agentId) {
|
|
8929
8973
|
if (!product || license.canUseProduct(product)) return;
|
|
8930
8974
|
const row = trialOf(product);
|
|
@@ -8934,8 +8978,19 @@ function createPanelApp(options = {}) {
|
|
|
8934
8978
|
const jobsFile = path14.join(ws2, "jobs", "index.json");
|
|
8935
8979
|
if (!fs14.existsSync(jobsFile)) return;
|
|
8936
8980
|
const jobs = JSON.parse(fs14.readFileSync(jobsFile, "utf8"))?.jobs || [];
|
|
8937
|
-
const
|
|
8938
|
-
|
|
8981
|
+
const grantedAt = Date.parse(row.grantedAt || "");
|
|
8982
|
+
for (const j2 of jobs) {
|
|
8983
|
+
if (!j2 || !(j2.status === "done" || j2.outputMp4 || j2.phase === "film")) continue;
|
|
8984
|
+
const stamp = Date.parse(j2.filmAt || j2.updatedAt || j2.createdAt || "");
|
|
8985
|
+
if (Number.isFinite(grantedAt) && Number.isFinite(stamp) && stamp < grantedAt) continue;
|
|
8986
|
+
const keys = trialChargeKeys([
|
|
8987
|
+
j2.panelTaskId ? `task:${j2.panelTaskId}` : "",
|
|
8988
|
+
j2.id ? `job:${j2.id}` : "",
|
|
8989
|
+
j2.projectPath ? `path:${j2.projectPath}` : "",
|
|
8990
|
+
j2.outputMp4 ? `artifact:${j2.outputMp4}` : ""
|
|
8991
|
+
]);
|
|
8992
|
+
if (keys.length) consumeTrial(product, keys);
|
|
8993
|
+
}
|
|
8939
8994
|
} catch {
|
|
8940
8995
|
}
|
|
8941
8996
|
}
|
|
@@ -9021,7 +9076,7 @@ function createPanelApp(options = {}) {
|
|
|
9021
9076
|
} catch (err) {
|
|
9022
9077
|
throw userFacingInstallError(err);
|
|
9023
9078
|
}
|
|
9024
|
-
grantTrial(productOf({ manifest: result.manifest }) || product);
|
|
9079
|
+
await grantTrial(productOf({ manifest: result.manifest }) || product);
|
|
9025
9080
|
ctx.setProgress(55, "\u6B63\u5728\u51C6\u5907\u8FD0\u884C\u73AF\u5883");
|
|
9026
9081
|
await ensureAgentRuntimes(result.dir, result.manifest.runtime?.shared ?? [], ctx);
|
|
9027
9082
|
try {
|
|
@@ -9421,6 +9476,7 @@ function createPanelApp(options = {}) {
|
|
|
9421
9476
|
}
|
|
9422
9477
|
}
|
|
9423
9478
|
async function stateAsync() {
|
|
9479
|
+
await refreshTrialRuns();
|
|
9424
9480
|
reconcileOrphanTasks();
|
|
9425
9481
|
for (const a of listInstalled(paths)) {
|
|
9426
9482
|
healTrialIfJobDone(productOf(a) || a.id, a.id);
|
|
@@ -9462,6 +9518,7 @@ function createPanelApp(options = {}) {
|
|
|
9462
9518
|
licenses: license.listProducts(),
|
|
9463
9519
|
buyUrl: buyPageUrl(),
|
|
9464
9520
|
licenseBaseUrl: settings.licenseBaseUrl,
|
|
9521
|
+
trialRuns,
|
|
9465
9522
|
campaigns: await loadPublicCampaigns(),
|
|
9466
9523
|
showcase: await loadPublicShowcase(),
|
|
9467
9524
|
docs: await loadPublicDocs(),
|
|
@@ -9500,8 +9557,9 @@ function createPanelApp(options = {}) {
|
|
|
9500
9557
|
licenses: license.listProducts(),
|
|
9501
9558
|
buyUrl: buyPageUrl(),
|
|
9502
9559
|
licenseBaseUrl: settings.licenseBaseUrl,
|
|
9560
|
+
trialRuns,
|
|
9503
9561
|
campaigns: [],
|
|
9504
|
-
showcase: { cases: [], tutorials: [] },
|
|
9562
|
+
showcase: { promptsEnabled: false, cases: [], tutorials: [] },
|
|
9505
9563
|
docs: [],
|
|
9506
9564
|
storeError: null,
|
|
9507
9565
|
tasks: queue.list(),
|
|
@@ -9549,7 +9607,7 @@ function createPanelApp(options = {}) {
|
|
|
9549
9607
|
return campaignCache.items;
|
|
9550
9608
|
}
|
|
9551
9609
|
}
|
|
9552
|
-
let showcaseCache = { at: 0, cases: [], tutorials: [] };
|
|
9610
|
+
let showcaseCache = { at: 0, promptsEnabled: false, cases: [], tutorials: [] };
|
|
9553
9611
|
let docsCache = { at: 0, items: [] };
|
|
9554
9612
|
async function loadPublicDocs() {
|
|
9555
9613
|
const now = Date.now();
|
|
@@ -9580,31 +9638,88 @@ function createPanelApp(options = {}) {
|
|
|
9580
9638
|
if (now - showcaseCache.at < 6e4) return showcaseCache;
|
|
9581
9639
|
const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
|
|
9582
9640
|
if (!base) {
|
|
9583
|
-
showcaseCache = { at: now, cases: [], tutorials: [] };
|
|
9641
|
+
showcaseCache = { at: now, promptsEnabled: false, cases: [], tutorials: [] };
|
|
9584
9642
|
return showcaseCache;
|
|
9585
9643
|
}
|
|
9586
9644
|
try {
|
|
9587
9645
|
const res = await fetch(`${base}/v1/showcase`, { signal: AbortSignal.timeout(4e3) });
|
|
9588
9646
|
const data = await res.json().catch(() => ({}));
|
|
9589
9647
|
if (!res.ok) throw new Error("showcase unavailable");
|
|
9590
|
-
const
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9648
|
+
const promptsEnabled = data.promptsEnabled === true;
|
|
9649
|
+
const mapItem = (item) => {
|
|
9650
|
+
const access = item.access === "licensed" ? "licensed" : "public";
|
|
9651
|
+
return {
|
|
9652
|
+
id: String(item.id || ""),
|
|
9653
|
+
title: String(item.title || ""),
|
|
9654
|
+
blurb: String(item.blurb || ""),
|
|
9655
|
+
agent: String(item.agent || ""),
|
|
9656
|
+
style: String(item.style || ""),
|
|
9657
|
+
coverUrl: String(item.coverUrl || ""),
|
|
9658
|
+
videoUrl: String(item.videoUrl || ""),
|
|
9659
|
+
access,
|
|
9660
|
+
locked: promptsEnabled && access === "licensed",
|
|
9661
|
+
prompt: promptsEnabled && access !== "licensed" ? String(item.prompt || "") : ""
|
|
9662
|
+
};
|
|
9663
|
+
};
|
|
9599
9664
|
const cases = (Array.isArray(data.cases) ? data.cases : []).map(mapItem).filter((item) => item.id && item.videoUrl);
|
|
9600
9665
|
const tutorials = (Array.isArray(data.tutorials) ? data.tutorials : []).map(mapItem).filter((item) => item.id && item.videoUrl);
|
|
9601
|
-
showcaseCache = { at: now, cases, tutorials };
|
|
9666
|
+
showcaseCache = { at: now, promptsEnabled, cases, tutorials };
|
|
9602
9667
|
return showcaseCache;
|
|
9603
9668
|
} catch {
|
|
9604
|
-
showcaseCache = {
|
|
9669
|
+
showcaseCache = {
|
|
9670
|
+
at: now,
|
|
9671
|
+
promptsEnabled: showcaseCache.promptsEnabled,
|
|
9672
|
+
cases: showcaseCache.cases,
|
|
9673
|
+
tutorials: showcaseCache.tutorials
|
|
9674
|
+
};
|
|
9605
9675
|
return showcaseCache;
|
|
9606
9676
|
}
|
|
9607
9677
|
}
|
|
9678
|
+
async function fetchCasePrompt(id) {
|
|
9679
|
+
const showcase = await loadPublicShowcase();
|
|
9680
|
+
const item = (showcase.cases || []).find((row) => row.id === id);
|
|
9681
|
+
if (!item) {
|
|
9682
|
+
const err = new Error("\u627E\u4E0D\u5230\u8FD9\u4E2A\u6848\u4F8B");
|
|
9683
|
+
err.status = 404;
|
|
9684
|
+
throw err;
|
|
9685
|
+
}
|
|
9686
|
+
if (!showcase.promptsEnabled) {
|
|
9687
|
+
const err = new Error("\u63D0\u793A\u8BCD\u672A\u5F00\u653E");
|
|
9688
|
+
err.status = 404;
|
|
9689
|
+
throw err;
|
|
9690
|
+
}
|
|
9691
|
+
if (item.access !== "licensed") {
|
|
9692
|
+
return { prompt: item.prompt || "", style: item.style || "", agent: item.agent || "" };
|
|
9693
|
+
}
|
|
9694
|
+
if (!license.canUseProduct(item.agent)) {
|
|
9695
|
+
const err = new Error("\u8BF7\u5148\u6FC0\u6D3B\u5BF9\u5E94 Agent");
|
|
9696
|
+
err.status = 403;
|
|
9697
|
+
throw err;
|
|
9698
|
+
}
|
|
9699
|
+
const token = license.tokenFor(item.agent);
|
|
9700
|
+
const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
|
|
9701
|
+
if (!token || !base) {
|
|
9702
|
+
const err = new Error("\u8BF7\u5148\u6FC0\u6D3B\u5BF9\u5E94 Agent");
|
|
9703
|
+
err.status = 403;
|
|
9704
|
+
throw err;
|
|
9705
|
+
}
|
|
9706
|
+
const res = await fetch(`${base}/v1/showcase/${encodeURIComponent(id)}/prompt`, {
|
|
9707
|
+
headers: { authorization: `Bearer ${token}` },
|
|
9708
|
+
signal: AbortSignal.timeout(8e3)
|
|
9709
|
+
});
|
|
9710
|
+
const data = await res.json().catch(() => ({}));
|
|
9711
|
+
if (!res.ok) {
|
|
9712
|
+
const msg = data?.error?.message;
|
|
9713
|
+
const err = new Error(typeof msg === "string" && msg ? msg : "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u63D0\u793A\u8BCD");
|
|
9714
|
+
err.status = res.status || 502;
|
|
9715
|
+
throw err;
|
|
9716
|
+
}
|
|
9717
|
+
return {
|
|
9718
|
+
prompt: String(data.prompt || ""),
|
|
9719
|
+
style: String(data.style || item.style || ""),
|
|
9720
|
+
agent: String(data.agent || item.agent || "")
|
|
9721
|
+
};
|
|
9722
|
+
}
|
|
9608
9723
|
async function loadPublicContact() {
|
|
9609
9724
|
const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
|
|
9610
9725
|
if (!base) return { wechatId: "", hasQr: false, configured: false };
|
|
@@ -9650,6 +9765,16 @@ function createPanelApp(options = {}) {
|
|
|
9650
9765
|
switch (route) {
|
|
9651
9766
|
case "GET /state":
|
|
9652
9767
|
return send(res, 200, await stateAsync());
|
|
9768
|
+
case "POST /showcase/prompt": {
|
|
9769
|
+
try {
|
|
9770
|
+
const body = await readJson(req);
|
|
9771
|
+
const id = String(body.id || "").trim();
|
|
9772
|
+
if (!id) return send(res, 400, { error: "\u627E\u4E0D\u5230\u8FD9\u4E2A\u6848\u4F8B" });
|
|
9773
|
+
return send(res, 200, await fetchCasePrompt(id));
|
|
9774
|
+
} catch (error) {
|
|
9775
|
+
return send(res, error.status || 502, { error: error.message || "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u63D0\u793A\u8BCD" });
|
|
9776
|
+
}
|
|
9777
|
+
}
|
|
9653
9778
|
case "GET /contact": {
|
|
9654
9779
|
try {
|
|
9655
9780
|
return send(res, 200, { contact: await loadPublicContact() });
|
|
@@ -9929,7 +10054,12 @@ function createPanelApp(options = {}) {
|
|
|
9929
10054
|
}
|
|
9930
10055
|
if (result.ok) {
|
|
9931
10056
|
const agentRow = listInstalled(paths).find((a) => a.id === agentId);
|
|
9932
|
-
|
|
10057
|
+
const keys = trialChargeKeys([
|
|
10058
|
+
body.taskId ? `task:${body.taskId}` : "",
|
|
10059
|
+
body.projectPath ? `path:${body.projectPath}` : "",
|
|
10060
|
+
result.sessionId ? `session:${result.sessionId}` : ""
|
|
10061
|
+
]);
|
|
10062
|
+
consumeTrial(agentRow ? productOf(agentRow) : agentId, keys.length ? keys : [`kickoff:${agentId}:${Date.now()}`]);
|
|
9933
10063
|
}
|
|
9934
10064
|
return send(res, result.ok ? 200 : 202, { ok: !!result.ok, kickoff: result });
|
|
9935
10065
|
}
|
|
@@ -10005,7 +10135,12 @@ function createPanelApp(options = {}) {
|
|
|
10005
10135
|
});
|
|
10006
10136
|
if (doneNow) {
|
|
10007
10137
|
const agent = listInstalled(paths).find((a) => a.id === agentId);
|
|
10008
|
-
|
|
10138
|
+
const keys = trialChargeKeys([
|
|
10139
|
+
body.taskId ? `task:${body.taskId}` : "",
|
|
10140
|
+
task.id ? `task:${task.id}` : "",
|
|
10141
|
+
body.artifact ? `artifact:${body.artifact}` : ""
|
|
10142
|
+
]);
|
|
10143
|
+
consumeTrial(agent ? productOf(agent) : agentId, keys.length ? keys : [`done:${agentId}:${Date.now()}`]);
|
|
10009
10144
|
}
|
|
10010
10145
|
return send(res, 202, { taskId: task.id });
|
|
10011
10146
|
}
|
|
@@ -10019,7 +10154,12 @@ function createPanelApp(options = {}) {
|
|
|
10019
10154
|
});
|
|
10020
10155
|
if (body.done) {
|
|
10021
10156
|
const agent = listInstalled(paths).find((a) => a.id === agentId);
|
|
10022
|
-
|
|
10157
|
+
const keys = trialChargeKeys([
|
|
10158
|
+
body.taskId ? `task:${body.taskId}` : "",
|
|
10159
|
+
existing.id ? `task:${existing.id}` : "",
|
|
10160
|
+
body.artifact ? `artifact:${body.artifact}` : ""
|
|
10161
|
+
]);
|
|
10162
|
+
consumeTrial(agent ? productOf(agent) : agentId, keys.length ? keys : [`done:${agentId}:${Date.now()}`]);
|
|
10023
10163
|
}
|
|
10024
10164
|
return send(res, 200, { ok: true, taskId: existing.id });
|
|
10025
10165
|
}
|
|
@@ -10128,6 +10268,7 @@ function createPanelApp(options = {}) {
|
|
|
10128
10268
|
}
|
|
10129
10269
|
}
|
|
10130
10270
|
void loadReleases();
|
|
10271
|
+
void refreshTrialRuns();
|
|
10131
10272
|
void reportInstalls();
|
|
10132
10273
|
const autoTimer = setInterval(() => void autoUpdateTick(), 6 * 36e5);
|
|
10133
10274
|
if (typeof autoTimer.unref === "function") autoTimer.unref();
|