bnpanel 0.5.8 → 0.6.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/client.js +325 -16
- package/index.js +157 -46
- 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,15 +1109,20 @@
|
|
|
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 ? '已授权' : '未授权'),
|
|
964
1122
|
h('button', { type: 'button', onClick: openManual }, '手册'),
|
|
965
1123
|
h('button', { type: 'button', onClick: openCases }, '案例'),
|
|
966
1124
|
);
|
|
967
|
-
const campaigns = state.campaigns || [];
|
|
1125
|
+
const campaigns = state.license && state.license.canExport ? [] : (state.campaigns || []);
|
|
968
1126
|
const camp = campaigns.length ? campaigns[((campIdx % campaigns.length) + campaigns.length) % campaigns.length] : null;
|
|
969
1127
|
const campIcons = { spark: '✨', gift: '🎁', rocket: '🚀', crown: '👑', star: '⭐', bolt: '⚡', box: '📦', heart: '💛', fire: '🔥', gem: '💎', party: '🎉', tag: '🏷️' };
|
|
970
1128
|
const campHref = camp && state.buyUrl
|
|
@@ -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' },
|
|
@@ -1240,6 +1416,25 @@
|
|
|
1240
1416
|
: ''),
|
|
1241
1417
|
) : null,
|
|
1242
1418
|
h('p', { className: 'bn-sub', style: { marginTop: 8 } }, '面板更新提示:手动卸载旧面板,再次通过 bnpanel 安装最新版本即可'),
|
|
1419
|
+
state.device && state.device.hash ? h('div', { style: { marginTop: 18 } },
|
|
1420
|
+
h('div', { className: 'bn-sub' }, '本机指纹'),
|
|
1421
|
+
h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', marginTop: 6 } },
|
|
1422
|
+
h('code', { className: 'bn-mono', style: { fontSize: 12, wordBreak: 'break-all' } }, state.device.hash),
|
|
1423
|
+
h('button', {
|
|
1424
|
+
type: 'button',
|
|
1425
|
+
className: 'bn-btn',
|
|
1426
|
+
onClick: () => {
|
|
1427
|
+
const hash = state.device && state.device.hash;
|
|
1428
|
+
if (!hash) return;
|
|
1429
|
+
void navigator.clipboard.writeText(hash).then(
|
|
1430
|
+
() => setToast({ text: '设备指纹已复制' }),
|
|
1431
|
+
() => setToast({ text: '复制失败,请手动选择指纹', bad: true }),
|
|
1432
|
+
);
|
|
1433
|
+
},
|
|
1434
|
+
}, '复制'),
|
|
1435
|
+
),
|
|
1436
|
+
h('p', { className: 'bn-sub', style: { marginTop: 6 } }, '把指纹发给管理员,可让这台电脑不显示活动。已有有效授权的电脑会自动隐藏。'),
|
|
1437
|
+
) : null,
|
|
1243
1438
|
h('p', { className: 'bn-sub', style: { marginTop: 18 } }, Number(state.trialRuns) > 0
|
|
1244
1439
|
? '安装免费;每个 Agent 首次安装赠送 ' + state.trialRuns + ' 次试用生成。正式授权请到「我的授权」。'
|
|
1245
1440
|
: '安装免费。正式授权请到「我的授权」。'),
|
|
@@ -1267,6 +1462,26 @@
|
|
|
1267
1462
|
) : null,
|
|
1268
1463
|
),
|
|
1269
1464
|
|
|
1465
|
+
tab === 'agents' ? h('p', { className: 'bn-foot-note' },
|
|
1466
|
+
h('span', null, '开了新任务,到左侧聊天窗口看进度。'),
|
|
1467
|
+
h('span', null, '开拍前,在聊天窗口给 DSH 全部权限。'),
|
|
1468
|
+
h('span', null, '其他问题,点右下角客服。'),
|
|
1469
|
+
) : null,
|
|
1470
|
+
h('button', {
|
|
1471
|
+
type: 'button',
|
|
1472
|
+
className: 'bn-cs' + (contactOpen ? ' on' : ''),
|
|
1473
|
+
'aria-label': '在线客服',
|
|
1474
|
+
title: '在线客服',
|
|
1475
|
+
onClick: () => { void openContact(); },
|
|
1476
|
+
},
|
|
1477
|
+
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 },
|
|
1478
|
+
h('path', { d: 'M4 13a8 8 0 0 1 16 0' }),
|
|
1479
|
+
h('path', { d: 'M4 13v3a2 2 0 0 0 2 2h1.5v-7H6a2 2 0 0 0-2 2z' }),
|
|
1480
|
+
h('path', { d: 'M20 13v3a2 2 0 0 1-2 2h-1.5v-7H18a2 2 0 0 1 2 2z' }),
|
|
1481
|
+
h('path', { d: 'M12 20h2.5a2 2 0 0 0 2-2' }),
|
|
1482
|
+
),
|
|
1483
|
+
),
|
|
1484
|
+
|
|
1270
1485
|
contactOpen ? h('div', { className: 'bn-modal-back', onClick: (e) => { if (e.target === e.currentTarget) setContactOpen(false); } },
|
|
1271
1486
|
h('div', { className: 'bn-modal bn-contact', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'bn-contact-title' },
|
|
1272
1487
|
h('div', { className: 'bn-contact-head' },
|
|
@@ -1384,12 +1599,81 @@
|
|
|
1384
1599
|
),
|
|
1385
1600
|
) : null,
|
|
1386
1601
|
|
|
1602
|
+
marketOpen ? (() => {
|
|
1603
|
+
const rows = caseRows();
|
|
1604
|
+
const slugs = [];
|
|
1605
|
+
AGENT_ORDER.forEach((slug) => { if (rows.some((row) => row.agent === slug)) slugs.push(slug); });
|
|
1606
|
+
rows.forEach((row) => { if (row.agent && slugs.indexOf(row.agent) < 0) slugs.push(row.agent); });
|
|
1607
|
+
const visible = marketFilter === 'all' ? rows : rows.filter((row) => row.agent === marketFilter);
|
|
1608
|
+
return h('div', { className: 'bn-market-back bn-layer', popover: 'manual', onClick: (event) => { if (event.target === event.currentTarget) closeMarket(); } },
|
|
1609
|
+
h('div', { className: 'bn-market', role: 'dialog', 'aria-modal': 'true', 'aria-label': '案例' },
|
|
1610
|
+
h('div', { className: 'bn-market-head' },
|
|
1611
|
+
h('div', { className: 'bn-market-kicker' }, rows.length + ' 条成片'),
|
|
1612
|
+
h('h2', null, '看成品,拿提示词去拍'),
|
|
1613
|
+
h('p', null, '公开的可以直接复制或做同款。标了专享的,要先激活对应的 Agent。'),
|
|
1614
|
+
h('button', { type: 'button', className: 'bn-market-x', onClick: closeMarket, 'aria-label': '关闭' }, '×'),
|
|
1615
|
+
h('div', { className: 'bn-market-filters' },
|
|
1616
|
+
h('button', { type: 'button', className: marketFilter === 'all' ? 'on' : '', 'aria-pressed': marketFilter === 'all', onClick: () => setMarketFilter('all') }, '全部'),
|
|
1617
|
+
slugs.map((slug) => h('button', {
|
|
1618
|
+
key: slug,
|
|
1619
|
+
type: 'button',
|
|
1620
|
+
className: marketFilter === slug ? 'on' : '',
|
|
1621
|
+
'aria-pressed': marketFilter === slug,
|
|
1622
|
+
onClick: () => setMarketFilter(slug),
|
|
1623
|
+
}, agentName(slug))),
|
|
1624
|
+
),
|
|
1625
|
+
),
|
|
1626
|
+
h('div', { className: 'bn-market-body' },
|
|
1627
|
+
visible.length
|
|
1628
|
+
? h('div', { className: 'bn-market-grid' }, visible.map((item) => h('button', {
|
|
1629
|
+
key: item.id,
|
|
1630
|
+
type: 'button',
|
|
1631
|
+
className: 'bn-case',
|
|
1632
|
+
onClick: () => openPlayer(item),
|
|
1633
|
+
},
|
|
1634
|
+
h('div', { className: 'bn-case-cover' },
|
|
1635
|
+
item.coverUrl
|
|
1636
|
+
? h('img', { src: item.coverUrl, alt: '' })
|
|
1637
|
+
: h('div', { className: 'bn-case-fallback' }, agentName(item.agent)),
|
|
1638
|
+
item.access === 'licensed' ? h('span', { className: 'bn-case-lock' }, '专享') : null,
|
|
1639
|
+
h('span', { className: 'bn-case-play', 'aria-hidden': true },
|
|
1640
|
+
h('svg', { width: 12, height: 12, viewBox: '0 0 24 24' }, h('path', { d: 'M8 5v14l11-7z', fill: 'currentColor' })),
|
|
1641
|
+
),
|
|
1642
|
+
),
|
|
1643
|
+
h('div', { className: 'bn-case-body' },
|
|
1644
|
+
h('div', { className: 'bn-case-title' }, item.title),
|
|
1645
|
+
h('div', { className: 'bn-case-blurb' }, item.blurb || (item.access === 'licensed' ? '激活后可查看提示词,并一键做同款。' : '看完这条,就可以按同样的提示词再拍一条。')),
|
|
1646
|
+
h('div', { className: 'bn-case-meta' },
|
|
1647
|
+
item.agent ? h('span', null, agentName(item.agent)) : null,
|
|
1648
|
+
item.style ? h('span', null, item.style) : null,
|
|
1649
|
+
),
|
|
1650
|
+
),
|
|
1651
|
+
)))
|
|
1652
|
+
: h('div', { className: 'bn-empty' },
|
|
1653
|
+
h('h3', null, '这个 Agent 还没有案例'),
|
|
1654
|
+
h('p', null, '换一个筛选,或者等新的成片上架。'),
|
|
1655
|
+
),
|
|
1656
|
+
),
|
|
1657
|
+
),
|
|
1658
|
+
);
|
|
1659
|
+
})() : null,
|
|
1660
|
+
|
|
1387
1661
|
player ? (() => {
|
|
1388
1662
|
const rows = playerRows();
|
|
1389
1663
|
const at = Math.max(0, rows.findIndex((row) => row.id === player.id));
|
|
1390
1664
|
const many = rows.length > 1;
|
|
1665
|
+
const licensed = player.access === 'licensed';
|
|
1666
|
+
const owned = holdsProduct(player.agent);
|
|
1667
|
+
const known = Object.prototype.hasOwnProperty.call(unlocked, player.id);
|
|
1668
|
+
const text = licensed ? (known ? unlocked[player.id] : '') : (player.prompt || '');
|
|
1669
|
+
const waiting = promptsOn && licensed && owned && !known && !promptError[player.id];
|
|
1670
|
+
const failed = promptsOn && licensed && owned && promptError[player.id];
|
|
1671
|
+
const locked = promptsOn && licensed && !owned;
|
|
1672
|
+
const shoot = player.agent
|
|
1673
|
+
? h('button', { type: 'button', className: 'bn-btn play', onClick: () => { void shootLike(player); } }, locked ? '去激活' : '用同款开拍')
|
|
1674
|
+
: null;
|
|
1391
1675
|
return h('div', { className: 'bn-player-back bn-layer', popover: 'manual', onClick: (event) => { if (event.target === event.currentTarget) closePlayer(); } },
|
|
1392
|
-
h('div', { id: 'bn-player', className: 'bn-player', style: { '--ar': String(playerRatio) }, role: 'dialog' },
|
|
1676
|
+
h('div', { id: 'bn-player', className: 'bn-player' + (promptsOn ? ' has-script' : ''), style: { '--ar': String(playerRatio) }, role: 'dialog', 'aria-label': player.title },
|
|
1393
1677
|
h('video', {
|
|
1394
1678
|
key: player.id,
|
|
1395
1679
|
id: 'bn-player-video',
|
|
@@ -1403,11 +1687,36 @@
|
|
|
1403
1687
|
if (node.videoWidth && node.videoHeight) setPlayerRatio(node.videoWidth / node.videoHeight);
|
|
1404
1688
|
},
|
|
1405
1689
|
}),
|
|
1406
|
-
h('div', { className: 'bn-player-
|
|
1690
|
+
promptsOn ? h('div', { className: 'bn-player-dock' },
|
|
1691
|
+
h('div', { className: 'bn-player-top' },
|
|
1692
|
+
h('strong', null, player.title),
|
|
1693
|
+
many ? h('span', { className: 'bn-player-count' }, (at + 1) + ' / ' + rows.length) : null,
|
|
1694
|
+
h('button', { type: 'button', className: 'bn-btn ghost', onClick: closePlayer }, '关闭'),
|
|
1695
|
+
),
|
|
1696
|
+
locked
|
|
1697
|
+
? h('p', { className: 'bn-player-quote lock' }, '激活 ' + agentName(player.agent) + ' 后可查看提示词并做同款')
|
|
1698
|
+
: h('p', { className: 'bn-player-quote' + (text ? '' : ' quiet') },
|
|
1699
|
+
waiting ? '正在打开这条提示词…'
|
|
1700
|
+
: failed ? promptError[player.id]
|
|
1701
|
+
: text || '这条还没有提示词。做同款会按它的风格模板开拍。'),
|
|
1702
|
+
h('div', { className: 'bn-player-foot' },
|
|
1703
|
+
many ? h('div', { className: 'bn-player-nav' },
|
|
1704
|
+
h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(-1) }, '上一条'),
|
|
1705
|
+
h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(1) }, '下一条'),
|
|
1706
|
+
) : null,
|
|
1707
|
+
h('div', { className: 'bn-player-actions' },
|
|
1708
|
+
text ? h('button', { type: 'button', className: 'bn-btn', onClick: () => { void copyPrompt(text); } }, '复制') : null,
|
|
1709
|
+
failed ? h('button', { type: 'button', className: 'bn-btn', onClick: () => { setPromptError((cur) => { const next = { ...cur }; delete next[player.id]; return next; }); primePrompt(player); } }, '重试') : null,
|
|
1710
|
+
locked
|
|
1711
|
+
? h('button', { type: 'button', className: 'bn-btn play', onClick: () => goActivate(player.agent) }, '去激活')
|
|
1712
|
+
: shoot,
|
|
1713
|
+
),
|
|
1714
|
+
),
|
|
1715
|
+
) : h('div', { className: 'bn-player-bar' },
|
|
1407
1716
|
many ? h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(-1) }, '上一条') : null,
|
|
1408
1717
|
h('span', { className: 'bn-player-count' }, '案例' + (many ? ' ' + (at + 1) + ' / ' + rows.length : '')),
|
|
1409
1718
|
h('strong', null, player.title),
|
|
1410
|
-
|
|
1719
|
+
shoot,
|
|
1411
1720
|
many ? h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(1) }, '下一条') : null,
|
|
1412
1721
|
h('button', { type: 'button', className: 'bn-btn ghost', onClick: closePlayer }, '关闭'),
|
|
1413
1722
|
),
|
package/index.js
CHANGED
|
@@ -8447,6 +8447,9 @@ function chatDenialCopy(name2, kind) {
|
|
|
8447
8447
|
if (kind === "trial") {
|
|
8448
8448
|
return `\u300C${who}\u300D\u514D\u8D39\u4F53\u9A8C\u6B21\u6570\u5DF2\u7528\u5B8C\uFF0C\u8FD9\u4E2A\u5BF9\u8BDD\u4E0D\u80FD\u518D\u5F00\u65B0\u4EFB\u52A1\u3002\u8BF7\u5230\u9762\u677F\u300C\u6211\u7684\u6388\u6743\u300D\u6FC0\u6D3B\u540E\u518D\u4ECE Studio \u7ACB\u9879\u3002`;
|
|
8449
8449
|
}
|
|
8450
|
+
if (kind === "session") {
|
|
8451
|
+
return `\u300C${who}\u300D\u8FD9\u6B21\u4F53\u9A8C\u5DF2\u7ECF\u5728\u8FD9\u4E2A\u5BF9\u8BDD\u91CC\u7528\u8FC7\u4E86\u3002\u8BF7\u56DE\u5230 Studio \u518D\u7ACB\u9879\u4E00\u6B21\uFF0C\u4E0D\u8981\u5728\u8FD9\u4E2A\u5BF9\u8BDD\u91CC\u5F00\u65B0\u4EFB\u52A1\u3002`;
|
|
8452
|
+
}
|
|
8450
8453
|
return `\u300C${who}\u300D\u5F53\u524D\u672A\u6FC0\u6D3B\uFF0C\u8FD9\u4E2A\u5BF9\u8BDD\u4E0D\u80FD\u518D\u5F00\u65B0\u4EFB\u52A1\u3002\u8BF7\u5230\u9762\u677F\u300C\u6211\u7684\u6388\u6743\u300D\u91CD\u65B0\u6FC0\u6D3B\u540E\u518D\u4ECE Studio \u7ACB\u9879\u3002`;
|
|
8451
8454
|
}
|
|
8452
8455
|
function classifyChatTurn(input) {
|
|
@@ -8454,7 +8457,7 @@ function classifyChatTurn(input) {
|
|
|
8454
8457
|
if (input.trialRun && !input.seen) return { action: "allow", remember: true };
|
|
8455
8458
|
const remaining = Number(input.trialRemaining) || 0;
|
|
8456
8459
|
if (remaining > 0 && !input.seen) return { action: "allow", remember: true };
|
|
8457
|
-
if (remaining > 0) return { action: "block", kind: "
|
|
8460
|
+
if (remaining > 0) return { action: "block", kind: "session" };
|
|
8458
8461
|
if (input.trialGranted) return { action: "block", kind: "trial" };
|
|
8459
8462
|
return { action: "block", kind: "unlicensed" };
|
|
8460
8463
|
}
|
|
@@ -8469,18 +8472,34 @@ function cwdOf(agent) {
|
|
|
8469
8472
|
function isSubagent(agent) {
|
|
8470
8473
|
return agent?.session?.header?.origin === "subagent";
|
|
8471
8474
|
}
|
|
8472
|
-
function
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8475
|
+
function isUserMessage(message) {
|
|
8476
|
+
const role = message?.role || message?.type;
|
|
8477
|
+
if (role === "assistant" || role === "tool" || role === "system" || role === "developer") return false;
|
|
8478
|
+
const kind = message?.source?.kind;
|
|
8479
|
+
if (kind && kind !== "user") return false;
|
|
8480
|
+
return true;
|
|
8481
|
+
}
|
|
8482
|
+
function textOf(message) {
|
|
8483
|
+
const content = message?.content;
|
|
8484
|
+
if (typeof content === "string") return content.trim();
|
|
8485
|
+
if (!Array.isArray(content)) return "";
|
|
8486
|
+
return content.map((block) => {
|
|
8487
|
+
if (!block || typeof block !== "object") return "";
|
|
8488
|
+
if (block.type === "text") return String(block.text || "").trim();
|
|
8489
|
+
if (block.type === "image" || block.type === "file" || block.type === "attachment") return block.type;
|
|
8490
|
+
return "";
|
|
8491
|
+
}).filter(Boolean).join("\n").trim();
|
|
8492
|
+
}
|
|
8493
|
+
function userTurnKey(messages) {
|
|
8494
|
+
if (!Array.isArray(messages) || !messages.length) return "";
|
|
8495
|
+
const parts = [];
|
|
8496
|
+
for (const message of messages) {
|
|
8497
|
+
if (!isUserMessage(message)) continue;
|
|
8498
|
+
const text = textOf(message);
|
|
8499
|
+
if (!text) continue;
|
|
8500
|
+
parts.push(message.id ? `${message.id}:${text.slice(0, 160)}` : text.slice(0, 160));
|
|
8501
|
+
}
|
|
8502
|
+
return parts.join("\n");
|
|
8484
8503
|
}
|
|
8485
8504
|
function annotate(messages, sentence) {
|
|
8486
8505
|
const note = [
|
|
@@ -8501,38 +8520,56 @@ function annotate(messages, sentence) {
|
|
|
8501
8520
|
});
|
|
8502
8521
|
return copy;
|
|
8503
8522
|
}
|
|
8504
|
-
function
|
|
8523
|
+
function readState(file) {
|
|
8505
8524
|
try {
|
|
8506
8525
|
const data = JSON.parse(fs12.readFileSync(file, "utf8"));
|
|
8507
|
-
const ids = Array.isArray(data?.ids) ? data.ids : [];
|
|
8508
|
-
|
|
8526
|
+
const ids = Array.isArray(data?.ids) ? data.ids.map((id) => String(id)).filter(Boolean) : [];
|
|
8527
|
+
const open = {};
|
|
8528
|
+
if (data?.open && typeof data.open === "object") {
|
|
8529
|
+
for (const [id, key] of Object.entries(data.open)) {
|
|
8530
|
+
if (id && typeof key === "string" && key) open[id] = key;
|
|
8531
|
+
}
|
|
8532
|
+
}
|
|
8533
|
+
return { ids, open };
|
|
8509
8534
|
} catch {
|
|
8510
|
-
return [];
|
|
8535
|
+
return { ids: [], open: {} };
|
|
8511
8536
|
}
|
|
8512
8537
|
}
|
|
8513
8538
|
function createTurnGate() {
|
|
8514
8539
|
let assess = () => ({ action: "ignore" });
|
|
8515
8540
|
const seen = /* @__PURE__ */ new Set();
|
|
8516
8541
|
const blocked = /* @__PURE__ */ new Map();
|
|
8542
|
+
const openTurn = /* @__PURE__ */ new Map();
|
|
8517
8543
|
let turnsFile = "";
|
|
8518
8544
|
function setAssessor(fn, file) {
|
|
8519
8545
|
if (typeof fn === "function") assess = fn;
|
|
8520
8546
|
if (file && file !== turnsFile) {
|
|
8521
8547
|
turnsFile = file;
|
|
8522
|
-
|
|
8548
|
+
const state = readState(file);
|
|
8549
|
+
for (const id of state.ids) seen.add(id);
|
|
8550
|
+
for (const [id, key] of Object.entries(state.open)) openTurn.set(id, key);
|
|
8523
8551
|
}
|
|
8524
8552
|
}
|
|
8525
|
-
function
|
|
8526
|
-
if (!id || seen.has(id)) return;
|
|
8527
|
-
seen.add(id);
|
|
8553
|
+
function persist() {
|
|
8528
8554
|
if (!turnsFile) return;
|
|
8529
8555
|
const ids = [...seen].slice(-4e3);
|
|
8556
|
+
const open = {};
|
|
8557
|
+
for (const id of ids) {
|
|
8558
|
+
const key = openTurn.get(id);
|
|
8559
|
+
if (key) open[id] = key;
|
|
8560
|
+
}
|
|
8530
8561
|
try {
|
|
8531
8562
|
fs12.mkdirSync(path12.dirname(turnsFile), { recursive: true });
|
|
8532
|
-
fs12.writeFileSync(turnsFile, JSON.stringify({ ids }, null, 2));
|
|
8563
|
+
fs12.writeFileSync(turnsFile, JSON.stringify({ ids, open }, null, 2));
|
|
8533
8564
|
} catch {
|
|
8534
8565
|
}
|
|
8535
8566
|
}
|
|
8567
|
+
function remember(id, key) {
|
|
8568
|
+
if (!id) return;
|
|
8569
|
+
seen.add(id);
|
|
8570
|
+
if (key) openTurn.set(id, key);
|
|
8571
|
+
persist();
|
|
8572
|
+
}
|
|
8536
8573
|
async function onPreStep(payload, next) {
|
|
8537
8574
|
let forwarded = false;
|
|
8538
8575
|
const forward = () => {
|
|
@@ -8541,11 +8578,16 @@ function createTurnGate() {
|
|
|
8541
8578
|
};
|
|
8542
8579
|
try {
|
|
8543
8580
|
const messages = payload?.messages;
|
|
8544
|
-
|
|
8581
|
+
const key = userTurnKey(messages);
|
|
8582
|
+
if (!key) return forward();
|
|
8545
8583
|
if (isSubagent(payload?.agent)) return forward();
|
|
8546
8584
|
const cwd = cwdOf(payload?.agent);
|
|
8547
8585
|
if (!cwd) return forward();
|
|
8548
8586
|
const id = sessionIdOf(payload.agent);
|
|
8587
|
+
if (id && openTurn.get(id) === key) {
|
|
8588
|
+
blocked.delete(id);
|
|
8589
|
+
return forward();
|
|
8590
|
+
}
|
|
8549
8591
|
const verdict = assess(String(cwd), id ? seen.has(id) : false, id) || { action: "ignore" };
|
|
8550
8592
|
const downstream = await forward();
|
|
8551
8593
|
if (downstream?.kind === "reject") return downstream;
|
|
@@ -8559,7 +8601,7 @@ function createTurnGate() {
|
|
|
8559
8601
|
}
|
|
8560
8602
|
}
|
|
8561
8603
|
if (id) blocked.delete(id);
|
|
8562
|
-
if (verdict.action === "allow" && id) remember(id);
|
|
8604
|
+
if (verdict.action === "allow" && id) remember(id, key);
|
|
8563
8605
|
return downstream;
|
|
8564
8606
|
} catch (err) {
|
|
8565
8607
|
console.warn("[biunow-panel] chat turn gate failed:", err?.message || err);
|
|
@@ -9401,7 +9443,8 @@ function createPanelApp(options = {}) {
|
|
|
9401
9443
|
panelCallbackToken: token,
|
|
9402
9444
|
product: product ?? agent.id,
|
|
9403
9445
|
canExport: entitled,
|
|
9404
|
-
trial: !licensed && trialLeft > 0
|
|
9446
|
+
trial: !licensed && trialLeft > 0,
|
|
9447
|
+
extraEnv: { PANEL_MEMBER: licensed ? "1" : "0" }
|
|
9405
9448
|
});
|
|
9406
9449
|
started.set(agent.id, running);
|
|
9407
9450
|
syncAgentSkills(agent);
|
|
@@ -9519,6 +9562,7 @@ function createPanelApp(options = {}) {
|
|
|
9519
9562
|
buyUrl: buyPageUrl(),
|
|
9520
9563
|
licenseBaseUrl: settings.licenseBaseUrl,
|
|
9521
9564
|
trialRuns,
|
|
9565
|
+
device: { hash: license.deviceHash(), label: license.device().label },
|
|
9522
9566
|
campaigns: await loadPublicCampaigns(),
|
|
9523
9567
|
showcase: await loadPublicShowcase(),
|
|
9524
9568
|
docs: await loadPublicDocs(),
|
|
@@ -9558,8 +9602,9 @@ function createPanelApp(options = {}) {
|
|
|
9558
9602
|
buyUrl: buyPageUrl(),
|
|
9559
9603
|
licenseBaseUrl: settings.licenseBaseUrl,
|
|
9560
9604
|
trialRuns,
|
|
9605
|
+
device: { hash: license.deviceHash(), label: license.device().label },
|
|
9561
9606
|
campaigns: [],
|
|
9562
|
-
showcase: { cases: [], tutorials: [] },
|
|
9607
|
+
showcase: { promptsEnabled: false, cases: [], tutorials: [] },
|
|
9563
9608
|
docs: [],
|
|
9564
9609
|
storeError: null,
|
|
9565
9610
|
tasks: queue.list(),
|
|
@@ -9579,7 +9624,7 @@ function createPanelApp(options = {}) {
|
|
|
9579
9624
|
}
|
|
9580
9625
|
let campaignCache = { at: 0, items: [] };
|
|
9581
9626
|
async function loadPublicCampaigns() {
|
|
9582
|
-
if (resellerCode) return [];
|
|
9627
|
+
if (resellerCode || license.canExport()) return [];
|
|
9583
9628
|
const now = Date.now();
|
|
9584
9629
|
if (now - campaignCache.at < 6e4) return campaignCache.items;
|
|
9585
9630
|
const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
|
|
@@ -9588,7 +9633,8 @@ function createPanelApp(options = {}) {
|
|
|
9588
9633
|
return [];
|
|
9589
9634
|
}
|
|
9590
9635
|
try {
|
|
9591
|
-
const
|
|
9636
|
+
const device = encodeURIComponent(license.deviceHash());
|
|
9637
|
+
const res = await fetch(`${base}/v1/commerce/campaigns?device=${device}`, { signal: AbortSignal.timeout(4e3) });
|
|
9592
9638
|
const data = await res.json().catch(() => ({}));
|
|
9593
9639
|
if (!res.ok) throw new Error("campaigns unavailable");
|
|
9594
9640
|
const items = (Array.isArray(data.campaigns) ? data.campaigns : []).map((item) => ({
|
|
@@ -9607,7 +9653,7 @@ function createPanelApp(options = {}) {
|
|
|
9607
9653
|
return campaignCache.items;
|
|
9608
9654
|
}
|
|
9609
9655
|
}
|
|
9610
|
-
let showcaseCache = { at: 0, cases: [], tutorials: [] };
|
|
9656
|
+
let showcaseCache = { at: 0, promptsEnabled: false, cases: [], tutorials: [] };
|
|
9611
9657
|
let docsCache = { at: 0, items: [] };
|
|
9612
9658
|
async function loadPublicDocs() {
|
|
9613
9659
|
const now = Date.now();
|
|
@@ -9638,31 +9684,88 @@ function createPanelApp(options = {}) {
|
|
|
9638
9684
|
if (now - showcaseCache.at < 6e4) return showcaseCache;
|
|
9639
9685
|
const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
|
|
9640
9686
|
if (!base) {
|
|
9641
|
-
showcaseCache = { at: now, cases: [], tutorials: [] };
|
|
9687
|
+
showcaseCache = { at: now, promptsEnabled: false, cases: [], tutorials: [] };
|
|
9642
9688
|
return showcaseCache;
|
|
9643
9689
|
}
|
|
9644
9690
|
try {
|
|
9645
9691
|
const res = await fetch(`${base}/v1/showcase`, { signal: AbortSignal.timeout(4e3) });
|
|
9646
9692
|
const data = await res.json().catch(() => ({}));
|
|
9647
9693
|
if (!res.ok) throw new Error("showcase unavailable");
|
|
9648
|
-
const
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9694
|
+
const promptsEnabled = data.promptsEnabled === true;
|
|
9695
|
+
const mapItem = (item) => {
|
|
9696
|
+
const access = item.access === "licensed" ? "licensed" : "public";
|
|
9697
|
+
return {
|
|
9698
|
+
id: String(item.id || ""),
|
|
9699
|
+
title: String(item.title || ""),
|
|
9700
|
+
blurb: String(item.blurb || ""),
|
|
9701
|
+
agent: String(item.agent || ""),
|
|
9702
|
+
style: String(item.style || ""),
|
|
9703
|
+
coverUrl: String(item.coverUrl || ""),
|
|
9704
|
+
videoUrl: String(item.videoUrl || ""),
|
|
9705
|
+
access,
|
|
9706
|
+
locked: promptsEnabled && access === "licensed",
|
|
9707
|
+
prompt: promptsEnabled && access !== "licensed" ? String(item.prompt || "") : ""
|
|
9708
|
+
};
|
|
9709
|
+
};
|
|
9657
9710
|
const cases = (Array.isArray(data.cases) ? data.cases : []).map(mapItem).filter((item) => item.id && item.videoUrl);
|
|
9658
9711
|
const tutorials = (Array.isArray(data.tutorials) ? data.tutorials : []).map(mapItem).filter((item) => item.id && item.videoUrl);
|
|
9659
|
-
showcaseCache = { at: now, cases, tutorials };
|
|
9712
|
+
showcaseCache = { at: now, promptsEnabled, cases, tutorials };
|
|
9660
9713
|
return showcaseCache;
|
|
9661
9714
|
} catch {
|
|
9662
|
-
showcaseCache = {
|
|
9715
|
+
showcaseCache = {
|
|
9716
|
+
at: now,
|
|
9717
|
+
promptsEnabled: showcaseCache.promptsEnabled,
|
|
9718
|
+
cases: showcaseCache.cases,
|
|
9719
|
+
tutorials: showcaseCache.tutorials
|
|
9720
|
+
};
|
|
9663
9721
|
return showcaseCache;
|
|
9664
9722
|
}
|
|
9665
9723
|
}
|
|
9724
|
+
async function fetchCasePrompt(id) {
|
|
9725
|
+
const showcase = await loadPublicShowcase();
|
|
9726
|
+
const item = (showcase.cases || []).find((row) => row.id === id);
|
|
9727
|
+
if (!item) {
|
|
9728
|
+
const err = new Error("\u627E\u4E0D\u5230\u8FD9\u4E2A\u6848\u4F8B");
|
|
9729
|
+
err.status = 404;
|
|
9730
|
+
throw err;
|
|
9731
|
+
}
|
|
9732
|
+
if (!showcase.promptsEnabled) {
|
|
9733
|
+
const err = new Error("\u63D0\u793A\u8BCD\u672A\u5F00\u653E");
|
|
9734
|
+
err.status = 404;
|
|
9735
|
+
throw err;
|
|
9736
|
+
}
|
|
9737
|
+
if (item.access !== "licensed") {
|
|
9738
|
+
return { prompt: item.prompt || "", style: item.style || "", agent: item.agent || "" };
|
|
9739
|
+
}
|
|
9740
|
+
if (!license.canUseProduct(item.agent)) {
|
|
9741
|
+
const err = new Error("\u8BF7\u5148\u6FC0\u6D3B\u5BF9\u5E94 Agent");
|
|
9742
|
+
err.status = 403;
|
|
9743
|
+
throw err;
|
|
9744
|
+
}
|
|
9745
|
+
const token = license.tokenFor(item.agent);
|
|
9746
|
+
const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
|
|
9747
|
+
if (!token || !base) {
|
|
9748
|
+
const err = new Error("\u8BF7\u5148\u6FC0\u6D3B\u5BF9\u5E94 Agent");
|
|
9749
|
+
err.status = 403;
|
|
9750
|
+
throw err;
|
|
9751
|
+
}
|
|
9752
|
+
const res = await fetch(`${base}/v1/showcase/${encodeURIComponent(id)}/prompt`, {
|
|
9753
|
+
headers: { authorization: `Bearer ${token}` },
|
|
9754
|
+
signal: AbortSignal.timeout(8e3)
|
|
9755
|
+
});
|
|
9756
|
+
const data = await res.json().catch(() => ({}));
|
|
9757
|
+
if (!res.ok) {
|
|
9758
|
+
const msg = data?.error?.message;
|
|
9759
|
+
const err = new Error(typeof msg === "string" && msg ? msg : "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u63D0\u793A\u8BCD");
|
|
9760
|
+
err.status = res.status || 502;
|
|
9761
|
+
throw err;
|
|
9762
|
+
}
|
|
9763
|
+
return {
|
|
9764
|
+
prompt: String(data.prompt || ""),
|
|
9765
|
+
style: String(data.style || item.style || ""),
|
|
9766
|
+
agent: String(data.agent || item.agent || "")
|
|
9767
|
+
};
|
|
9768
|
+
}
|
|
9666
9769
|
async function loadPublicContact() {
|
|
9667
9770
|
const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
|
|
9668
9771
|
if (!base) return { wechatId: "", hasQr: false, configured: false };
|
|
@@ -9708,6 +9811,16 @@ function createPanelApp(options = {}) {
|
|
|
9708
9811
|
switch (route) {
|
|
9709
9812
|
case "GET /state":
|
|
9710
9813
|
return send(res, 200, await stateAsync());
|
|
9814
|
+
case "POST /showcase/prompt": {
|
|
9815
|
+
try {
|
|
9816
|
+
const body = await readJson(req);
|
|
9817
|
+
const id = String(body.id || "").trim();
|
|
9818
|
+
if (!id) return send(res, 400, { error: "\u627E\u4E0D\u5230\u8FD9\u4E2A\u6848\u4F8B" });
|
|
9819
|
+
return send(res, 200, await fetchCasePrompt(id));
|
|
9820
|
+
} catch (error) {
|
|
9821
|
+
return send(res, error.status || 502, { error: error.message || "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u63D0\u793A\u8BCD" });
|
|
9822
|
+
}
|
|
9823
|
+
}
|
|
9711
9824
|
case "GET /contact": {
|
|
9712
9825
|
try {
|
|
9713
9826
|
return send(res, 200, { contact: await loadPublicContact() });
|
|
@@ -10213,9 +10326,7 @@ function createPanelApp(options = {}) {
|
|
|
10213
10326
|
const agent = permit.agentId ? listInstalled(paths).find((a) => a.id === permit.agentId) : null;
|
|
10214
10327
|
const product = permit.product || (agent ? productOf(agent) || agent.id : "");
|
|
10215
10328
|
if (product) {
|
|
10216
|
-
|
|
10217
|
-
const fresh = Number.isFinite(age) && age < 2 * 60 * 1e3 && age > -6e4;
|
|
10218
|
-
return { product, name: agent?.manifest?.name || product, fresh };
|
|
10329
|
+
return { product, name: agent?.manifest?.name || product };
|
|
10219
10330
|
}
|
|
10220
10331
|
}
|
|
10221
10332
|
const parent = path14.dirname(cur);
|
|
@@ -10227,7 +10338,7 @@ function createPanelApp(options = {}) {
|
|
|
10227
10338
|
if (rel && !rel.startsWith("..") && !path14.isAbsolute(rel)) {
|
|
10228
10339
|
const agentId = rel.split(path14.sep)[0];
|
|
10229
10340
|
const agent = listInstalled(paths).find((a) => a.id === agentId);
|
|
10230
|
-
if (agent) return { product: productOf(agent) || agent.id, name: agent.manifest?.name || agent.id
|
|
10341
|
+
if (agent) return { product: productOf(agent) || agent.id, name: agent.manifest?.name || agent.id };
|
|
10231
10342
|
}
|
|
10232
10343
|
return null;
|
|
10233
10344
|
}
|
|
@@ -10241,7 +10352,7 @@ function createPanelApp(options = {}) {
|
|
|
10241
10352
|
licensed: license.canUseProduct(binding.product),
|
|
10242
10353
|
trialRemaining: trial.remaining,
|
|
10243
10354
|
trialGranted: !!trial.granted,
|
|
10244
|
-
seen:
|
|
10355
|
+
seen: !!seen,
|
|
10245
10356
|
trialRun: paidFirst
|
|
10246
10357
|
});
|
|
10247
10358
|
if (classified.action === "allow") return { action: "allow" };
|