solrouter 0.4.0 → 0.4.1
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/package.json +1 -1
- package/src/server.js +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solrouter",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Local privacy router for coding tools: pseudonymises every request before it leaves your machine, and sends work a frontier model would refuse to an uncensored open-weight model you control.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/server.js
CHANGED
|
@@ -102,7 +102,7 @@ export function startServer(cfg) {
|
|
|
102
102
|
// stream live. If the whole short response is a refusal and mode is auto,
|
|
103
103
|
// we discard it and reroute to the private/uncensored leg.
|
|
104
104
|
const COMMIT_AT = 380; // chars of answer text that means "real answer"
|
|
105
|
-
let committed = false, held = "", acc = "";
|
|
105
|
+
let committed = false, held = "", acc = "", refusalLikely = false;
|
|
106
106
|
for (;;) {
|
|
107
107
|
const { done, value } = await reader.read();
|
|
108
108
|
if (done) break;
|
|
@@ -110,11 +110,14 @@ export function startServer(cfg) {
|
|
|
110
110
|
acc += extractSseText(chunk);
|
|
111
111
|
if (committed) { emit(chunk); continue; }
|
|
112
112
|
held += chunk;
|
|
113
|
-
|
|
113
|
+
// Lock onto a refusal as soon as its opening matches — then never commit,
|
|
114
|
+
// so even a long, multi-paragraph refusal gets fully buffered and rerouted.
|
|
115
|
+
if (!refusalLikely && isRefusal(acc)) refusalLikely = true;
|
|
116
|
+
if (!refusalLikely && acc.replace(/\s/g, "").length >= COMMIT_AT) { committed = true; emit(held); held = ""; }
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
let leg = s.leg, refused = false, model = s.model;
|
|
117
|
-
if (!committed && s.mode === "auto" &&
|
|
120
|
+
if (!committed && s.mode === "auto" && refusalLikely) {
|
|
118
121
|
// Streamed refusal → reroute to the uncensored private leg.
|
|
119
122
|
const pr = await privateReply(cfg, s.maskedPrompt);
|
|
120
123
|
if (pr.ok && pr.reply) {
|