bnpanel 0.5.3 → 0.5.5
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/index.js +40 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8392,6 +8392,9 @@ function createChatBridge() {
|
|
|
8392
8392
|
} catch {
|
|
8393
8393
|
}
|
|
8394
8394
|
}
|
|
8395
|
+
if (typeof opts.beforePrompt === "function") {
|
|
8396
|
+
await opts.beforePrompt(sessionId);
|
|
8397
|
+
}
|
|
8395
8398
|
const requestId = crypto7.randomUUID();
|
|
8396
8399
|
await sessionController.prompt(
|
|
8397
8400
|
{
|
|
@@ -8447,6 +8450,7 @@ function chatDenialCopy(name2, kind) {
|
|
|
8447
8450
|
}
|
|
8448
8451
|
function classifyChatTurn(input) {
|
|
8449
8452
|
if (input.licensed) return { action: "allow", remember: true };
|
|
8453
|
+
if (input.trialRun && !input.seen) return { action: "allow", remember: true };
|
|
8450
8454
|
const remaining = Number(input.trialRemaining) || 0;
|
|
8451
8455
|
if (remaining > 0 && !input.seen) return { action: "allow", remember: true };
|
|
8452
8456
|
if (remaining > 0) return { action: "block", kind: "unlicensed" };
|
|
@@ -8541,7 +8545,7 @@ function createTurnGate() {
|
|
|
8541
8545
|
const cwd = cwdOf(payload?.agent);
|
|
8542
8546
|
if (!cwd) return forward();
|
|
8543
8547
|
const id = sessionIdOf(payload.agent);
|
|
8544
|
-
const verdict = assess(String(cwd), id ? seen.has(id) : false) || { action: "ignore" };
|
|
8548
|
+
const verdict = assess(String(cwd), id ? seen.has(id) : false, id) || { action: "ignore" };
|
|
8545
8549
|
const downstream = await forward();
|
|
8546
8550
|
if (downstream?.kind === "reject") return downstream;
|
|
8547
8551
|
if (verdict.action === "block" && verdict.message) {
|
|
@@ -8912,6 +8916,32 @@ function createPanelApp(options = {}) {
|
|
|
8912
8916
|
} catch {
|
|
8913
8917
|
}
|
|
8914
8918
|
}
|
|
8919
|
+
const trialRunSessions = /* @__PURE__ */ new Set();
|
|
8920
|
+
function trialRunsPath() {
|
|
8921
|
+
return path14.join(paths.root, "trial-runs.json");
|
|
8922
|
+
}
|
|
8923
|
+
function loadTrialRuns() {
|
|
8924
|
+
try {
|
|
8925
|
+
const data = JSON.parse(fs14.readFileSync(trialRunsPath(), "utf8"));
|
|
8926
|
+
const ids = Array.isArray(data?.ids) ? data.ids : [];
|
|
8927
|
+
for (const id of ids) {
|
|
8928
|
+
if (id) trialRunSessions.add(String(id));
|
|
8929
|
+
}
|
|
8930
|
+
} catch {
|
|
8931
|
+
}
|
|
8932
|
+
}
|
|
8933
|
+
function rememberTrialRun(sessionId) {
|
|
8934
|
+
const id = String(sessionId || "");
|
|
8935
|
+
if (!id || trialRunSessions.has(id)) return;
|
|
8936
|
+
trialRunSessions.add(id);
|
|
8937
|
+
const ids = [...trialRunSessions].slice(-400);
|
|
8938
|
+
try {
|
|
8939
|
+
fs14.mkdirSync(paths.root, { recursive: true });
|
|
8940
|
+
fs14.writeFileSync(trialRunsPath(), JSON.stringify({ ids }, null, 2));
|
|
8941
|
+
} catch {
|
|
8942
|
+
}
|
|
8943
|
+
}
|
|
8944
|
+
loadTrialRuns();
|
|
8915
8945
|
function canRunProduct(product) {
|
|
8916
8946
|
if (!product) return license.canExport();
|
|
8917
8947
|
if (license.canUseProduct(product)) return true;
|
|
@@ -9008,12 +9038,16 @@ function createPanelApp(options = {}) {
|
|
|
9008
9038
|
if (!dsh?.chat?.startSkillRun) {
|
|
9009
9039
|
return { ok: false, reason: "chat-unavailable", promptText: text };
|
|
9010
9040
|
}
|
|
9041
|
+
const product = agent ? productOf(agent) || agent.id : agentId;
|
|
9011
9042
|
return dsh.chat.startSkillRun({
|
|
9012
9043
|
agentId,
|
|
9013
9044
|
skill: skill || agentId,
|
|
9014
9045
|
projectPath,
|
|
9015
9046
|
promptText: text,
|
|
9016
|
-
title: title || `${skill || agentId} \xB7 \u521B\u4F5C
|
|
9047
|
+
title: title || `${skill || agentId} \xB7 \u521B\u4F5C`,
|
|
9048
|
+
beforePrompt: (sessionId) => {
|
|
9049
|
+
if (!license.canUseProduct(product)) rememberTrialRun(sessionId);
|
|
9050
|
+
}
|
|
9017
9051
|
});
|
|
9018
9052
|
}
|
|
9019
9053
|
function isRequiredNpmRuntime(spec) {
|
|
@@ -10018,16 +10052,18 @@ function createPanelApp(options = {}) {
|
|
|
10018
10052
|
}
|
|
10019
10053
|
return null;
|
|
10020
10054
|
}
|
|
10021
|
-
function assessChatTurn(cwd, seen) {
|
|
10055
|
+
function assessChatTurn(cwd, seen, sessionId) {
|
|
10022
10056
|
try {
|
|
10023
10057
|
const binding = bindChatProduct(cwd);
|
|
10024
10058
|
if (!binding) return { action: "ignore" };
|
|
10025
10059
|
const trial = trialOf(binding.product);
|
|
10060
|
+
const paidFirst = !!(sessionId && trialRunSessions.has(String(sessionId)) && !seen);
|
|
10026
10061
|
const classified = classifyChatTurn({
|
|
10027
10062
|
licensed: license.canUseProduct(binding.product),
|
|
10028
10063
|
trialRemaining: trial.remaining,
|
|
10029
10064
|
trialGranted: !!trial.granted,
|
|
10030
|
-
seen: !!seen || !binding.fresh
|
|
10065
|
+
seen: paidFirst ? false : !!seen || !binding.fresh,
|
|
10066
|
+
trialRun: paidFirst
|
|
10031
10067
|
});
|
|
10032
10068
|
if (classified.action === "allow") return { action: "allow" };
|
|
10033
10069
|
return { action: "block", message: chatDenialCopy(binding.name, classified.kind) };
|