solrouter 0.4.1 → 0.4.2
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/auth.js +2 -2
- package/src/index.js +2 -2
- package/src/server.js +12 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solrouter",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
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/auth.js
CHANGED
|
@@ -27,7 +27,7 @@ function openBrowser(url) {
|
|
|
27
27
|
|
|
28
28
|
/** Loopback browser login. Resolves once the callback delivers a token.
|
|
29
29
|
* `open` is injectable for testing (defaults to launching the real browser). */
|
|
30
|
-
export function browserLogin({ timeoutMs = 180000, open = openBrowser } = {}) {
|
|
30
|
+
export function browserLogin({ timeoutMs = 180000, open = openBrowser, save = saveAuth } = {}) {
|
|
31
31
|
return new Promise((resolve, reject) => {
|
|
32
32
|
const state = randomBytes(16).toString("hex");
|
|
33
33
|
const server = createServer((req, res) => {
|
|
@@ -45,7 +45,7 @@ export function browserLogin({ timeoutMs = 180000, open = openBrowser } = {}) {
|
|
|
45
45
|
res.end("<h2>SolRouter proxy connected.</h2><p>You can close this tab and return to the terminal.</p>");
|
|
46
46
|
server.close();
|
|
47
47
|
if (!token.access_token) return reject(new Error("no token in callback"));
|
|
48
|
-
|
|
48
|
+
save(token);
|
|
49
49
|
resolve(token);
|
|
50
50
|
});
|
|
51
51
|
server.listen(0, "127.0.0.1", () => {
|
package/src/index.js
CHANGED
|
@@ -120,11 +120,11 @@ export async function handleStream(body, ctx = {}, cfg) {
|
|
|
120
120
|
kind, mode, maskedPrompt: extractText(masked, kind) };
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
/** Call the private leg for a (masked) prompt. Returns { reply, ok }. */
|
|
123
|
+
/** Call the private leg for a (masked) prompt. Returns { reply, ok, status }. */
|
|
124
124
|
export async function privateReply(cfg, maskedPrompt) {
|
|
125
125
|
const { callSolrouterAgent } = await import("./providers.js");
|
|
126
126
|
const r = await callSolrouterAgent(cfg.private, maskedPrompt);
|
|
127
|
-
return { reply: r.reply || "", ok: r.ok };
|
|
127
|
+
return { reply: r.reply || "", ok: r.ok, status: r.status };
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
export { createMasker } from "./mask.js";
|
package/src/server.js
CHANGED
|
@@ -129,7 +129,18 @@ export function startServer(cfg) {
|
|
|
129
129
|
leg, reason: "reactive-refusal", model, entities: s.masker.entities(), refused: true, sentToProvider: s.sent });
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
|
-
//
|
|
132
|
+
// Reroute was needed but the uncensored leg failed — say so LOUDLY instead
|
|
133
|
+
// of silently relaying Claude's refusal (this is almost always "not logged
|
|
134
|
+
// in" / an invalid SolRouter key).
|
|
135
|
+
res.write(synthAnthropicSse(
|
|
136
|
+
`⚠️ [solrouter] Claude refused this, and the uncensored leg couldn't be reached (${pr.status || "error"}). ` +
|
|
137
|
+
`Run \`solrouter login --token sk_solrouter_…\` with a valid key from solrouter.com/sdk, then retry.`,
|
|
138
|
+
cfg.private.model));
|
|
139
|
+
res.end();
|
|
140
|
+
if (cfg.receipt?.enabled) writeReceipt(cfg.receipt.path, {
|
|
141
|
+
leg: "private", reason: "reroute-failed", model: cfg.private.model,
|
|
142
|
+
entities: s.masker.entities(), refused: true, sentToProvider: s.sent });
|
|
143
|
+
return;
|
|
133
144
|
}
|
|
134
145
|
if (!committed) emit(held); // short non-refusal: flush the buffer
|
|
135
146
|
if (restorer) res.write(restorer.flush());
|