provider: Send requests unmasked for subscriptions and plugin providers too (isee1_1)
isee1_1 on Discord uses a community translation plugin as a provider and asked why "Send requests unmasked" (请求不脱敏) isn't offered for it.698da36f3(lc) left a signed-in account, a plugin's provider and another magpie out because the switch was then for local addresses only, and none of those is local.380032cda(AcMilan) made it the user's word at any address, with a caution while on for one not local, but kept the exclusion. Nothing still stands behind it for a subscription or a plugin: the setting lives with the account's model picks, and every route reads SkipsRedaction. Another magpie stays excluded, as it masks on its own side. - provider.SkipsRedaction: an account (subscription or plugin) skips when set; another magpie never. Save keeps Unredacted in the picks record, withPicks applies it (AlsoOn accounts too). - gateway: serve, count_tokens, embeddings, Jev and the plugin's fetch already go by unredactedRoute (every fallback and group member must be set too). The Codex relay on a ChatGPT sign-in masked always: it now sends the turn whole when the Codex subscription is set (codexRouteUnmasked; only for the ChatGPT backend, not the Codex API key route), codexMaskRoute stands aside then, and ChatGPT web search (alphaSearchOn) goes unmasked only when every provider it is on is set. Speech and video stay masked whatever the switch (maskTextHits), as before, for every provider. - GUI: the editor's Redaction row is shared (unmaskRow); a subscription or plugin provider has it too, its caution naming the provider while on, since its vendor is never local; saved with the account's body. Another magpie has none. No new strings; app.js stays in its budget. - CLI help/show text, gateway-routing.md and the masking docs (en, zh, ja) say so. Run (mote, through mote-run): - go test ./internal/provider ./internal/cli: ok - go test -timeout 45m ./internal/gateway: ok (676s) - go test -run 'Budget|Redact|Unmask|I18n' ./internal/gui: ok (TestCoreScriptBudget at +45 bytes) - GOOS=linux go vet ./internal/gateway ./internal/provider, GOOS=windows go vet ./internal/gateway ./internal/provider ./internal/cli: clean (GOOS=linux vet of internal/cli fails in wails without cgo, as on main) - node --test provider-unmasked (chromium): 36/36; i18n-keys: 4/4. WebKit on mote can't launch (#4125); WebKit ran through wsl-run: the whole file in chromium and webkit, 72/72. At 440 in Linux WebKit the list's sticky foot covers the last row (another magpie's), so the test clicks that row as an event (#4484). - gofmt -l: clean Broken by hand: - SkipsRedaction's account branch back to false: TestSkipsRedaction (an account, a plugin's provider), TestPluginProviderUnmaskedSwitch/set and TestCodexSignInUnmaskedSwitch/set go red. - Unredacted dropped from Save's account whitelist: the plugin test's "saved as" goes red. - codexRouteUnmasked forced off: TestCodexSignInUnmaskedSwitch/set red. The unset and falls-back-to-a-vendor cases stay masked in each. Not tried: a real plugin provider or a real Codex/Claude account with the switch on (fakes only: the fake bun plugin and a fake ChatGPT backend); the Claude bridge path; the full Go and GUI suites run after the push.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -136,7 +136,8 @@ const providerUsage = `usage:
|
||||
URLs moves there, keeping its path; address= alone puts it back at the default)
|
||||
magpie provider set ollama unmasked=yes
|
||||
(Settings' redaction leaves its requests as written, at any address: your call,
|
||||
so mind a relay that passes them on to a vendor; never a signed-in account)
|
||||
so mind a relay that passes them on to a vendor; a subscription or a plugin's
|
||||
provider too, whose vendor gets them so; never another magpie)
|
||||
magpie provider add "My Relay" url=https://relay.example.com/v1 key=sk-… balance=https://relay.example.com/api/usage/token balance.path='$data.total_available / 500000'
|
||||
magpie provider set my-relay balance.path='(1 - credits.monthlyCredits / 70) %'
|
||||
magpie provider set my-relay balance.method=POST
|
||||
@@ -842,7 +843,7 @@ func showProvider(p provider.Provider) error {
|
||||
if p.Unredacted {
|
||||
why := " Settings' redaction leaves its requests as written"
|
||||
if !p.SkipsRedaction() {
|
||||
why = " but masked: a signed-in account, another magpie or no address"
|
||||
why = " but masked: another magpie or no address"
|
||||
}
|
||||
kv("unmasked", "yes"+muted.Render(why))
|
||||
}
|
||||
@@ -1184,8 +1185,8 @@ func applyPairs(p *provider.Provider, pairs []string) error {
|
||||
case "unmasked":
|
||||
// yes: the provider gets the requests as written, unmasked by
|
||||
// Settings' redaction (lc, AcMilan on Discord): the user's word
|
||||
// at any address, never for an account or another magpie
|
||||
// (provider.SkipsRedaction)
|
||||
// at any address, a subscription's or a plugin's provider's too
|
||||
// (isee1_1), never another magpie's (provider.SkipsRedaction)
|
||||
if v != "yes" && v != "no" {
|
||||
return fmt.Errorf("unmasked=yes|no, not %q", v)
|
||||
}
|
||||
|
||||
@@ -945,8 +945,16 @@ func (s *Server) codexUpstreamOn(w http.ResponseWriter, r *http.Request, rest st
|
||||
// Claude's blocks magpie gave Codex (claudeseal) are Claude's alone:
|
||||
// to OpenAI each item is its summary, as before magpie carried them
|
||||
body = withoutClaudeSeals(body)
|
||||
base := provider.CodexBase
|
||||
if apiKey(r.Header) && rest != "/models" {
|
||||
base = codexAPIBase
|
||||
}
|
||||
var maskedHits maskHits
|
||||
if r.Method == http.MethodPost {
|
||||
// the ChatGPT sign-in the user set to go unmasked, and its fallbacks
|
||||
// (codexFallBack masks for its own route), gets the turn as written
|
||||
// (isee1_1 on Discord); Codex's own API key is no account of magpie's
|
||||
sentWhole := base == provider.CodexBase && codexRouteUnmasked(on)
|
||||
if r.Method == http.MethodPost && !sentWhole {
|
||||
var unmask func()
|
||||
var err error
|
||||
to := provider.Provider{ID: "codex"} // the ChatGPT backend
|
||||
@@ -960,10 +968,6 @@ func (s *Server) codexUpstreamOn(w http.ResponseWriter, r *http.Request, rest st
|
||||
return
|
||||
}
|
||||
}
|
||||
base := provider.CodexBase
|
||||
if apiKey(r.Header) && rest != "/models" {
|
||||
base = codexAPIBase
|
||||
}
|
||||
if r.Method == http.MethodPost && rest == "/responses" && base == provider.CodexBase {
|
||||
// a replayed web search the request doesn't declare the tool for
|
||||
// is refused by the ChatGPT backend (#1270), as on an account's
|
||||
@@ -1028,7 +1032,7 @@ func (s *Server) codexUpstreamOn(w http.ResponseWriter, r *http.Request, rest st
|
||||
if m := noteMasked(r, "chat", maskedHits, sentOf(maskedHits, body), tr.ID, "openai", model); m != nil {
|
||||
s.trace.update(tr, func(t *Route) { t.Masked = m })
|
||||
}
|
||||
promptRead := s.inspectPrompt(tr, provider.Responses, body, body, false)
|
||||
promptRead := s.inspectPrompt(tr, provider.Responses, body, body, sentWhole)
|
||||
end = func(status int, msg string, tokens, out int) {
|
||||
ms := time.Since(start).Milliseconds()
|
||||
ttft, text := first.ms()
|
||||
@@ -1502,6 +1506,21 @@ func codexBusy(status int, msg []byte) bool {
|
||||
return busy(status, msg)
|
||||
}
|
||||
|
||||
// codexRouteUnmasked says a turn relayed to the ChatGPT backend on the
|
||||
// account on, or on Codex's own sign-in (the codex subscription) when on
|
||||
// is nil, goes there as written: the user set that subscription to go
|
||||
// unmasked, and every fallback of it too (unredactedRoute).
|
||||
func codexRouteUnmasked(on *provider.Provider) bool {
|
||||
if on != nil {
|
||||
return unredactedRoute(*on, false, nil)
|
||||
}
|
||||
p, err := provider.Find("codex")
|
||||
if err != nil || p.Account == nil || p.Account.Agent != "codex" {
|
||||
return false
|
||||
}
|
||||
return unredactedRoute(*p, false, nil)
|
||||
}
|
||||
|
||||
// codexFallsBack says Codex's turn on one of its own models has fallbacks
|
||||
// to go on to (codexFallBack): the Codex subscription's, set in magpie, at
|
||||
// least one of them found. A turn compacting natively is the backend's to
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -123,12 +124,23 @@ func chatGPTSearchers(r *http.Request, model string) ([]provider.Provider, strin
|
||||
// with why returned.
|
||||
func (s *Server) alphaSearchOn(w http.ResponseWriter, r *http.Request, body []byte, model string, ons []provider.Provider) (bool, string) {
|
||||
start := time.Now()
|
||||
// as written only when every account it may be asked on is set to go
|
||||
// unmasked (provider.SkipsRedaction, isee1_1 on Discord); magpie's own
|
||||
// search in its place masks its query itself (maskedQuery)
|
||||
if len(ons) > 0 && !slices.ContainsFunc(ons, func(p provider.Provider) bool { return !p.SkipsRedaction() }) {
|
||||
return s.alphaSearchAsked(w, r, body, model, ons, start)
|
||||
}
|
||||
w, body, unmask, hits, err := redactedHits(r.Context(), w, body)
|
||||
defer unmask()
|
||||
if err != nil {
|
||||
return false, err.Error()
|
||||
}
|
||||
noteMasked(r, "search", hits, sentOf(hits, body), 0, "openai", model)
|
||||
return s.alphaSearchAsked(w, r, body, model, ons, start)
|
||||
}
|
||||
|
||||
// alphaSearchAsked is alphaSearchOn once body is as it goes.
|
||||
func (s *Server) alphaSearchAsked(w http.ResponseWriter, r *http.Request, body []byte, model string, ons []provider.Provider, start time.Time) (bool, string) {
|
||||
var errs []string
|
||||
for _, on := range ons {
|
||||
who := "OpenAI (" + on.Account.User + "): "
|
||||
|
||||
@@ -405,6 +405,11 @@ func codexMaskRoute(r *http.Request, rest string, body []byte) string {
|
||||
if rest != "/responses" || !MaskRoute(settings.Shared().RedactRouteTo) {
|
||||
return ""
|
||||
}
|
||||
// one the user set to go unmasked goes there as written anyway
|
||||
// (codexUpstreamOn), and stays on it
|
||||
if !apiKey(r.Header) && codexRouteUnmasked(nil) {
|
||||
return ""
|
||||
}
|
||||
_, _, _, hits, err := redactedHits(r.Context(), httptest.NewRecorder(), body)
|
||||
if err != nil {
|
||||
return ""
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/plugin"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
"github.com/yetone/magpie/internal/testenv"
|
||||
)
|
||||
|
||||
const unmaskedKey = "sk-proj-abcdEFGH1234ijklMNOP5678qrst"
|
||||
|
||||
// isee1_1 on Discord: a plugin's provider (a translation plugin there)
|
||||
// takes "Send requests unmasked" as any provider does. Set, the plugin's
|
||||
// fetch gets the request as the agent wrote it, with Settings' redaction
|
||||
// on; unset, or able to fall back to a vendor that isn't set, it is masked.
|
||||
func TestPluginProviderUnmaskedSwitch(t *testing.T) {
|
||||
bun := testenv.Bun(t)
|
||||
fresh(t)
|
||||
t.Setenv("MAGPIE_BUN", bun)
|
||||
t.Cleanup(plugin.Settle)
|
||||
var mu sync.Mutex
|
||||
var got string
|
||||
up := testenv.FakeVendor(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
b, _ := io.ReadAll(r.Body)
|
||||
mu.Lock()
|
||||
got = string(b)
|
||||
mu.Unlock()
|
||||
w.Header().Set("Content-Type", "text/event-stream")
|
||||
io.WriteString(w, `data: {"id":"c","object":"chat.completion.chunk","model":"fake-1","choices":[{"index":0,"delta":{"role":"assistant","content":"ok"},"finish_reason":"stop"}]}`+"\n\ndata: [DONE]\n\n")
|
||||
}))
|
||||
defer up.Close()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
abs, _ := filepath.Abs("../plugin/testdata/fake/index.js")
|
||||
if _, err := plugin.Add(ctx, abs); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := plugin.Providers(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := plugin.APIKey(ctx, "fakeco", 0, nil, "k1", plugin.NewAccount); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := settings.Save(settings.Settings{Redact: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
vendor := provider.Provider{ID: "vendor", Name: "Vendor", Key: "k", Models: []string{"m9"}, Anthropic: "https://api.vendor.example"}
|
||||
if err := provider.Save(vendor); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := New()
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
on bool
|
||||
fallback []string
|
||||
whole bool
|
||||
}{
|
||||
{name: "set", on: true, whole: true},
|
||||
{name: "unset"},
|
||||
{name: "set, falls back to a vendor", on: true, fallback: []string{"vendor/m9"}},
|
||||
} {
|
||||
p, err := provider.Find("fakeco")
|
||||
if err != nil || !p.IsPlugin() {
|
||||
t.Fatalf("%s: Find = %+v, %v", tc.name, p, err)
|
||||
}
|
||||
p.Unredacted, p.Fallback = tc.on, tc.fallback
|
||||
if err := provider.Save(*p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if q, _ := provider.Find("fakeco"); q == nil || q.Unredacted != tc.on {
|
||||
t.Fatalf("%s: saved as %+v", tc.name, q)
|
||||
}
|
||||
code, body := postAs(t, s, "", `{"model":"fakeco/fake-1","messages":[{"role":"user","content":"my key is `+unmaskedKey+`"}]}`)
|
||||
if code != 200 {
|
||||
t.Fatalf("%s: %d %s", tc.name, code, body)
|
||||
}
|
||||
mu.Lock()
|
||||
sent := got
|
||||
mu.Unlock()
|
||||
if whole := strings.Contains(sent, unmaskedKey); whole != tc.whole {
|
||||
t.Fatalf("%s: sent whole %v, want %v: %s", tc.name, whole, tc.whole, sent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A turn relayed on Codex's own ChatGPT sign-in goes as Codex wrote it
|
||||
// when the user set the Codex subscription to go unmasked, and masked
|
||||
// when not.
|
||||
func TestCodexSignInUnmaskedSwitch(t *testing.T) {
|
||||
for _, on := range []bool{true, false} {
|
||||
t.Run(map[bool]string{true: "set", false: "unset"}[on], func(t *testing.T) { codexUnmasked(t, on) })
|
||||
}
|
||||
}
|
||||
|
||||
func codexUnmasked(t *testing.T, on bool) {
|
||||
{
|
||||
codexSignedIn(t)
|
||||
var got []byte
|
||||
chatgptBase(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
got, _ = io.ReadAll(r.Body)
|
||||
w.Header().Set("Content-Type", "text/event-stream")
|
||||
io.WriteString(w, sse(
|
||||
`data: {"type":"response.created","response":{"id":"r1","model":"gpt-5.5"}}`,
|
||||
`data: {"type":"response.completed","response":{"id":"r1","usage":{"input_tokens":7,"output_tokens":1}}}`))
|
||||
}))
|
||||
if err := settings.Save(settings.Settings{Redact: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p, err := provider.Find("codex")
|
||||
if err != nil || p.Account == nil {
|
||||
t.Fatalf("Find(codex) = %+v, %v", p, err)
|
||||
}
|
||||
p.Unredacted = on
|
||||
if err := provider.Save(*p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
code, body := codexPost(t, `{"model":"gpt-5.5","stream":true,"input":"my key is `+unmaskedKey+`"}`)
|
||||
if code != 200 {
|
||||
t.Fatalf("%d %s", code, body)
|
||||
}
|
||||
if whole := strings.Contains(string(got), unmaskedKey); whole != on {
|
||||
t.Fatalf("sent whole %v, set %v: %s", whole, on, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// chatgptBase stands the ChatGPT backend in with h for this test.
|
||||
func chatgptBase(t *testing.T, h http.Handler) {
|
||||
t.Helper()
|
||||
up := httptest.NewServer(h)
|
||||
t.Cleanup(up.Close)
|
||||
was := provider.CodexBase
|
||||
provider.CodexBase = up.URL + "/backend-api/codex"
|
||||
t.Cleanup(func() { provider.CodexBase = was })
|
||||
}
|
||||
+18
-17
@@ -9494,6 +9494,20 @@ function drawEditor(p, presetID) {
|
||||
const advIn = el("div", "inner");
|
||||
adv.append(advIn);
|
||||
|
||||
const unmaskRow = (hint, urls) => {
|
||||
const [ltk, lcb] = tick(t("Send requests unmasked"), !!draft.unredacted);
|
||||
const row = field(t("Redaction"), ltk, hint), note = el("div", "hint unmasked-away");
|
||||
row[1].append(note);
|
||||
showLocal = () => {
|
||||
const host = draft.unredacted && (urls ? awayHost(urls()) : p.name);
|
||||
note.hidden = !(note.textContent = host ? t("{host} isn't on this computer or your local network: turned on, requests go to it unmasked.", { host }) : "");
|
||||
if (draft.unredacted && urls) askLANNames(urls(), showLocal);
|
||||
};
|
||||
lcb.onchange = () => { draft.unredacted = lcb.checked; showLocal(); };
|
||||
showLocal();
|
||||
return row;
|
||||
};
|
||||
|
||||
if (p?.account) {
|
||||
// the sign-in belongs to the agent; magpie only borrows it
|
||||
const a = p.account;
|
||||
@@ -9526,6 +9540,7 @@ function drawEditor(p, presetID) {
|
||||
advIn.append(...concurrencyField(p));
|
||||
advIn.append(...priceRateField(), ...rateWindowsField());
|
||||
if (p.cline) advIn.append(...upstreamField());
|
||||
advIn.append(...unmaskRow(""));
|
||||
ed.append(...pluginOptionsField(subOf(a.agent)));
|
||||
// a plugin's provider is reached inside magpie: its plugin:// URLs go
|
||||
// nowhere to show or test
|
||||
@@ -9567,7 +9582,7 @@ function drawEditor(p, presetID) {
|
||||
if (priceTypedError(ed)) return;
|
||||
const picked = accountModelsDraft(p);
|
||||
if (picked === false) return pickError();
|
||||
const body = { id: p.id, models: chosenIds(), noModels: noneChosen(), bestInFamily: bestChosen(), unlisted: draft.unlisted, hiddenDrawers: draft.hiddenDrawers, fallback: draft.fallback, contexts: cx.map, outputs: ox.map, compacts: cpx.map, proxy, accountProxies: own.map, maxConcurrency, ...queue, priceRate, rateWindows, modelPrefs: modelPrefsOfDraft(), pinUpstream: !!draft.pinUpstream, ...(p.carriesCompaction ? { nativeCompaction: !!draft.nativeCompaction } : {}), ...routingOfDraft(p) };
|
||||
const body = { id: p.id, models: chosenIds(), noModels: noneChosen(), bestInFamily: bestChosen(), unlisted: draft.unlisted, hiddenDrawers: draft.hiddenDrawers, fallback: draft.fallback, contexts: cx.map, outputs: ox.map, compacts: cpx.map, proxy, accountProxies: own.map, maxConcurrency, ...queue, priceRate, rateWindows, modelPrefs: modelPrefsOfDraft(), pinUpstream: !!draft.pinUpstream, unredacted: !!draft.unredacted, ...(p.carriesCompaction ? { nativeCompaction: !!draft.nativeCompaction } : {}), ...routingOfDraft(p) };
|
||||
saving(saveBtn, t("Saving…"));
|
||||
saveAccountModelsDraft(picked).then(() => savePluginOptions(subOf(a.agent))).then(() => providerAction("save", body, t("{name} saved", { name: p.name })), (e) => { doneSaving(saveBtn); editorError(e.message || String(e)); }); };
|
||||
bar.append(cancel, saveBtn);
|
||||
@@ -9795,24 +9810,10 @@ function drawEditor(p, presetID) {
|
||||
advIn.append(...field(t("User-Agent"), utk, t("For a plan that serves only the coding agents it names: each request goes with the User-Agent the agent sent (pi, OpenCode, Claude Code…), not magpie's. Requests magpie makes itself, and ones the agent sent without one, still go as magpie. A User-Agent set in Headers above always wins.")));
|
||||
}
|
||||
|
||||
// the user's switch at any address (AcMilan), with a caution while on
|
||||
const addressOf = (k) => (draft[k] ?? (isNew && pr ? pr[k] : "")) || "";
|
||||
const unmaskable = () => !p?.account && (p?.preset || pr?.id) !== "remote-magpie";
|
||||
const unmaskable = () => (p?.preset || pr?.id) !== "remote-magpie";
|
||||
if (unmaskable()) {
|
||||
const [ltk, lcb] = tick(t("Send requests unmasked"), !!draft.unredacted);
|
||||
lcb.onchange = () => { draft.unredacted = lcb.checked; showLocal(); };
|
||||
const row = field(t("Redaction"), ltk, t("For a model running on this computer or your local network: secrets, personal data and your masked words go to it as written. Leave it off for a local relay or proxy that passes requests on to a vendor."));
|
||||
const away = el("div", "hint unmasked-away");
|
||||
row[1].append(away);
|
||||
showLocal = () => {
|
||||
const urls = ["chat", "responses", "anthropic", "gemini", "decide"].map(addressOf);
|
||||
const host = draft.unredacted ? awayHost(urls) : "";
|
||||
away.textContent = host ? t("{host} isn't on this computer or your local network: turned on, requests go to it unmasked.", { host }) : "";
|
||||
away.hidden = !host;
|
||||
if (draft.unredacted) askLANNames(urls, showLocal);
|
||||
};
|
||||
showLocal();
|
||||
advIn.append(...row);
|
||||
advIn.append(...unmaskRow(t("For a model running on this computer or your local network: secrets, personal data and your masked words go to it as written. Leave it off for a local relay or proxy that passes requests on to a vendor."), () => ["chat", "responses", "anthropic", "gemini", "decide"].map(addressOf)));
|
||||
}
|
||||
|
||||
// a user's provider whose certificate nothing trusts (#2383, provider.TakesInsecureTLS)
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
// /api/local-hosts); a local one (localhost, a private IP, a name of the
|
||||
// user's own DNS resolving only to the local network) has none. A
|
||||
// name is asked about only once the switch is on, so an editor merely
|
||||
// opened asks nothing. A signed-in account has no row. In English and Chinese, wide and narrow.
|
||||
// opened asks nothing. A signed-in account or a plugin's provider has the
|
||||
// row too (isee1_1 on Discord), its caution always shown while on: its
|
||||
// vendor is never local. Another magpie has none. In English and Chinese,
|
||||
// wide and narrow.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -39,9 +42,15 @@ const codex = {
|
||||
account: { agent: "codex", agentName: "Codex", user: "me@example.com", plan: "PLUS", logins: [{ user: "me@example.com", plan: "PLUS", active: true, on: true }] },
|
||||
proxy: "",
|
||||
};
|
||||
// a community plugin's provider, keyless, and another magpie
|
||||
const plugin = {
|
||||
...base, id: "translate", name: "Translate Plugin", chat: "plugin://translate", unredacted: true,
|
||||
account: { agent: "translate", agentName: "Translate Plugin", user: "translate", plan: "", logins: [{ user: "translate", active: true, on: true }] },
|
||||
};
|
||||
const home = { ...base, id: "home", name: "Home magpie", preset: "remote-magpie", anthropic: "http://192.168.1.5:3425" };
|
||||
|
||||
function serve(lang, posts, asked) {
|
||||
const providers = { providers: [local, lan, relay, named, codex], presets: [], excluded: [], gateway: { running: true, window: true } };
|
||||
const providers = { providers: [local, lan, relay, named, codex, plugin, home], presets: [], excluded: [], gateway: { running: true, window: true } };
|
||||
const state = { agents: [], profiles: [], settings: { lang, theme: "light" } };
|
||||
return async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
@@ -94,7 +103,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const asked = [];
|
||||
await page.route("**/*", serve(lang, posts, asked));
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
await page.locator(".row.provider", { hasText: name }).click();
|
||||
// another magpie's row is the list's last, under its sticky foot
|
||||
// at 440 in Linux WebKit (#4484): it is clicked as an event
|
||||
const pick = page.locator(".row.provider", { hasText: name });
|
||||
await (name === "Home magpie" ? pick.dispatchEvent("click") : pick.click());
|
||||
await unfold(page);
|
||||
await page.locator(".editor .bar").waitFor();
|
||||
return { page, errors, posts, asked };
|
||||
@@ -212,8 +224,40 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang} ${width}: a signed-in account has no such row`, async (t) => {
|
||||
const { page, errors } = await open(t, "Codex");
|
||||
test(`${engine} ${lang} ${width}: a signed-in account has the row, its caution shown once on, and is saved so`, async (t) => {
|
||||
const { page, errors, posts, asked } = await open(t, "Codex");
|
||||
assert.equal(await row(page).isVisible(), true);
|
||||
assert.equal(await box(page).isChecked(), false, "opens masked");
|
||||
await cautionSays(page, "");
|
||||
await box(page).scrollIntoViewIfNeeded();
|
||||
await box(page).check();
|
||||
await cautionSays(page, w.away("Codex"));
|
||||
await caution(page).scrollIntoViewIfNeeded();
|
||||
const c = await caution(page).boundingBox();
|
||||
assert.ok(c.x >= 0 && c.x + c.width <= width, `the caution fits: ${JSON.stringify(c)}`);
|
||||
const saved = await save(page, posts);
|
||||
assert.equal(saved.action, "save");
|
||||
assert.equal(saved.body.id, "codex");
|
||||
assert.equal(saved.body.unredacted, true);
|
||||
assert.deepEqual(asked, [], "a vendor's service is never asked about");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang} ${width}: a plugin's provider saved unmasked opens ticked with its caution, and is saved masked`, async (t) => {
|
||||
const { page, errors, posts } = await open(t, "Translate Plugin");
|
||||
assert.equal(await box(page).isChecked(), true);
|
||||
await cautionSays(page, w.away("Translate Plugin"));
|
||||
await box(page).scrollIntoViewIfNeeded();
|
||||
await box(page).uncheck();
|
||||
await cautionSays(page, "");
|
||||
const saved = await save(page, posts);
|
||||
assert.equal(saved.body.id, "translate");
|
||||
assert.equal(saved.body.unredacted, false);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang} ${width}: another magpie has no such row`, async (t) => {
|
||||
const { page, errors } = await open(t, "Home magpie");
|
||||
assert.equal(await row(page).count(), 0);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
@@ -331,9 +331,12 @@ type Provider struct {
|
||||
// unmasked by Settings' redaction, which keeps secrets from vendors:
|
||||
// for a model on this machine or the local network (Ollama, LM Studio,
|
||||
// a vLLM box; lc on Discord). It is the user's word, not the
|
||||
// address's (AcMilan on Discord): the editor cautions when an address
|
||||
// isn't local, and a relay run locally, or Ollama's cloud models, pass
|
||||
// a request on to a vendor whatever the address. See SkipsRedaction.
|
||||
// address's (AcMilan on Discord), on a subscription or a plugin's
|
||||
// provider too (isee1_1 on Discord): the editor cautions while it is
|
||||
// on for one not local, and a relay run locally, or Ollama's cloud
|
||||
// models, pass a request on to a vendor whatever the address. A
|
||||
// signed-in account keeps it with its model picks (withPicks). See
|
||||
// SkipsRedaction.
|
||||
Unredacted bool `json:"unredacted,omitempty"`
|
||||
|
||||
// InsecureTLS has magpie take the certificate of the provider's own
|
||||
@@ -790,6 +793,9 @@ func withPicks(a, pk Provider) Provider {
|
||||
a.Sink, a.NoModels, a.BestInFamily = pk.Sink, pk.NoModels, pk.BestInFamily
|
||||
a.NativeCompaction = pk.NativeCompaction
|
||||
a.PromptAsWritten = pk.PromptAsWritten
|
||||
// Send requests unmasked, the user's for a subscription and a
|
||||
// plugin's provider too (isee1_1 on Discord)
|
||||
a.Unredacted = pk.Unredacted
|
||||
a.Proxy, a.AccountProxies, a.AccountModels = pk.Proxy, pk.AccountProxies, pk.AccountModels
|
||||
a.AccountCaps, a.AccountWindowCaps = pk.AccountCaps, pk.AccountWindowCaps
|
||||
a.CapStop, a.CapCareful = pk.CapStop, pk.CapCareful
|
||||
@@ -937,7 +943,7 @@ func Save(p Provider) error {
|
||||
if p.ID == "kiro" {
|
||||
key = p.Key
|
||||
}
|
||||
p = Provider{ID: p.ID, Key: key, Models: p.Models, NoModels: p.NoModels, BestInFamily: p.BestInFamily, RateWindows: p.RateWindows, PickedFrom: p.PickedFrom, Delisted: p.Delisted, Unlisted: p.Unlisted, HiddenDrawers: p.HiddenDrawers, Off: p.Off, Fallback: p.Fallback, Routing: p.Routing, Sink: p.Sink, Affinity: p.Affinity, KeepLogin: p.KeepLogin, KeepLoginAs: p.KeepLoginAs, SwitchOnly: p.SwitchOnly, Contexts: p.Contexts, Family: p.Family, Proxy: p.Proxy, AccountProxies: p.AccountProxies, AccountModels: p.AccountModels, AccountCaps: p.AccountCaps, AccountWindowCaps: p.AccountWindowCaps, CapStop: p.CapStop, CapCareful: p.CapCareful, AccountNames: p.AccountNames, MaxConcurrency: p.MaxConcurrency, AccountConcurrency: p.AccountConcurrency, QueueLimit: p.QueueLimit, QueueWait: p.QueueWait, MaxRPM: p.MaxRPM, PriceRate: p.PriceRate, QuotaRest: p.QuotaRest, QuotaResetAt: p.QuotaResetAt, RestCap: p.RestCap, PinUpstream: p.PinUpstream, NativeCompaction: p.NativeCompaction, PromptAsWritten: p.PromptAsWritten, Hidden: hiddenAccount(p.ID), Quiet: quietAccount(p.ID), Tucked: tuckedAccount(p.ID)}
|
||||
p = Provider{ID: p.ID, Key: key, Models: p.Models, NoModels: p.NoModels, BestInFamily: p.BestInFamily, RateWindows: p.RateWindows, PickedFrom: p.PickedFrom, Delisted: p.Delisted, Unlisted: p.Unlisted, HiddenDrawers: p.HiddenDrawers, Off: p.Off, Fallback: p.Fallback, Routing: p.Routing, Sink: p.Sink, Affinity: p.Affinity, KeepLogin: p.KeepLogin, KeepLoginAs: p.KeepLoginAs, SwitchOnly: p.SwitchOnly, Contexts: p.Contexts, Family: p.Family, Proxy: p.Proxy, AccountProxies: p.AccountProxies, AccountModels: p.AccountModels, AccountCaps: p.AccountCaps, AccountWindowCaps: p.AccountWindowCaps, CapStop: p.CapStop, CapCareful: p.CapCareful, AccountNames: p.AccountNames, MaxConcurrency: p.MaxConcurrency, AccountConcurrency: p.AccountConcurrency, QueueLimit: p.QueueLimit, QueueWait: p.QueueWait, MaxRPM: p.MaxRPM, PriceRate: p.PriceRate, QuotaRest: p.QuotaRest, QuotaResetAt: p.QuotaResetAt, RestCap: p.RestCap, PinUpstream: p.PinUpstream, NativeCompaction: p.NativeCompaction, PromptAsWritten: p.PromptAsWritten, Unredacted: p.Unredacted, Hidden: hiddenAccount(p.ID), Quiet: quietAccount(p.ID), Tucked: tuckedAccount(p.ID)}
|
||||
} else {
|
||||
p.AccountProxies = keyProxies(p) // a provider of keys proxies each key apart
|
||||
if subscriptionID(p.ID) && !stored(p.ID) {
|
||||
|
||||
@@ -7,16 +7,21 @@ import (
|
||||
)
|
||||
|
||||
// SkipsRedaction says requests to p go unmasked: the user set Unredacted
|
||||
// ("Send requests unmasked") and p has an address. It is the user's word
|
||||
// whatever the address (AcMilan on Discord: the user decides for each
|
||||
// provider); the editor cautions when an address isn't on this machine or
|
||||
// the local network (LocalHost), and nothing here looks one up. A
|
||||
// signed-in account, a plugin's provider and another magpie are always
|
||||
// masked: each reaches a vendor.
|
||||
// ("Send requests unmasked") and p has somewhere they go. It is the user's
|
||||
// word for each provider whatever the address (AcMilan on Discord), a
|
||||
// subscription's and a plugin's too (isee1_1 on Discord: a plugin's
|
||||
// provider never had the switch): the editor cautions while it is on for
|
||||
// one not on this computer or the local network, which a signed-in
|
||||
// account's or a plugin's vendor never is, and nothing here looks one up.
|
||||
// Another magpie is always masked: it masks on its own side, and what it
|
||||
// is sent goes on to its vendors.
|
||||
func (p Provider) SkipsRedaction() bool {
|
||||
if !p.Unredacted || p.Account != nil || p.IsRemoteMagpie() {
|
||||
if !p.Unredacted || p.IsRemoteMagpie() {
|
||||
return false
|
||||
}
|
||||
if p.Account != nil {
|
||||
return true // the agent's sign-in or a plugin's: its vendor is where it goes
|
||||
}
|
||||
for _, b := range []string{p.Chat, p.Responses, p.Anthropic, p.Gemini, p.Decide} {
|
||||
if b != "" {
|
||||
return true
|
||||
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
// "Send requests unmasked" is the user's switch for each provider
|
||||
// (AcMilan on Discord): set, a provider goes unmasked at whatever address,
|
||||
// a name of the user's own DNS or a vendor's; unset, it is masked. A
|
||||
// signed-in account or another magpie never goes unmasked. Nothing is
|
||||
// signed-in account and a plugin's provider take it too (isee1_1); another
|
||||
// magpie never goes unmasked, as it masks on its own side. Nothing is
|
||||
// looked up to decide: the lookup fails the test if it is.
|
||||
func TestSkipsRedaction(t *testing.T) {
|
||||
t.Cleanup(netproxy.SetLookup(func(_ context.Context, host string) ([]net.IPAddr, error) {
|
||||
@@ -32,7 +33,9 @@ func TestSkipsRedaction(t *testing.T) {
|
||||
{"through its own proxy", Provider{Unredacted: true, Chat: "http://llm.corp.lan:8000/v1", Proxy: "socks5://127.0.0.1:1080"}, true},
|
||||
{"not set", Provider{Chat: "http://localhost:11434/v1"}, false},
|
||||
{"no address", Provider{Unredacted: true}, false},
|
||||
{"an account", Provider{Unredacted: true, Chat: "http://localhost:1/v1", Account: &Account{Agent: "codex"}}, false},
|
||||
{"an account", Provider{Unredacted: true, Account: &Account{Agent: "codex"}}, true},
|
||||
{"an account, off", Provider{Account: &Account{Agent: "codex"}}, false},
|
||||
{"a plugin's provider", Provider{Unredacted: true, Chat: "plugin://translate", Account: &Account{Agent: "translate"}}, true},
|
||||
{"another magpie", Provider{Unredacted: true, Preset: RemoteMagpiePreset, Anthropic: "http://192.168.1.5:3425"}, false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
<li><b>ID とツール定義はそのまま:</b>モデル ID、メッセージや呼び出しの ID、UUID、ツール名、MCP サーバー名、ツールのスキーマ(説明文はマスクされます)。ベンダーやツールが検証できるようにするためです。</li>
|
||||
<li><b>画像とファイルのデータはそのまま送られます。</b>スクリーンショット内の文字はマスクされません。</li>
|
||||
<li><b>動かなければ送りません。</b>マスクがオンなのに動かないとき(<span class="ui">プライバシーマスキング</span> プラグインを手で止めた、自分でオンにしたローカルモデルが応答しない)、リクエストは何も送らなかったことを示す 503 になります。マスクなしで送ることはありません。既定でオンのモデルが応答しないときは、ルールだけでマスクします。</li>
|
||||
<li><b>ローカルモデルは外せます。</b>すべてのアドレスがこのコンピュータかローカルネットワーク上にあるプロバイダ(Ollama、LM Studio)は、<span class="ui">リクエストをマスクしない</span> でそのまま送れます。CLI では <code>magpie provider set ollama unmasked=yes</code>。ログにはマスク後の内容が残ります。</li>
|
||||
<li><b>プロバイダごとに外せます。</b>プロバイダの <span class="ui">リクエストをマスクしない</span> をオンにすると、そのリクエストはそのまま送られます。このコンピュータやローカルネットワーク上のモデル(Ollama、LM Studio)のほか、選べばほかのどのプロバイダでも、サブスクリプションやプラグインのプロバイダでもかまいません。ローカルでないものでオンにすると、エディタはそのベンダーにマスクせずに届くと注意します。まだマスクするプロバイダへフォールバックしうるリクエストはマスクされます。CLI では <code>magpie provider set ollama unmasked=yes</code>。</li>
|
||||
<li><b>マスクされるリクエストをそちらへ送ることもできます。</b><span class="ui">設定 › プライバシー</span> の <span class="ui">マスクせずに送る先</span> でそのようなモデルを選ぶと、マスクの対象を含むエージェントのリクエストはそのままそのモデルへ送られ、本当の名前のまま答えられます。マスクするものがないリクエストはこれまでどおりの送り先へ。そのモデルが失敗したらリクエストも失敗し、マスクしてベンダーへ送り直すことはありません。初期設定はオフです。</li>
|
||||
<li><b>モデルにはプレースホルダーしか見えません。</b>マスクされた値を読んだり推論したりはできず、受け渡すだけです。モデルが読む必要のある値は <span class="ui">マスクしない</span> へ。</li>
|
||||
<li><b>ルールは形で見つけます。</b>他の国の形式の電話番号や自由文中の名前には、<span class="ui">ローカルモデルで検出</span>、または自分の <span class="ui">マスクする語</span> と <span class="ui">マスクルール</span> が必要です。まず自分のテキストを <span class="ui">試す</span> で確かめてください。</li>
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
<li><b>Ids and tool definitions go as written:</b> model ids, message and call ids, UUIDs, tool names, MCP server names, and tool schemas (their descriptions are masked), so a vendor or a tool can still check them.</li>
|
||||
<li><b>Images and file data are sent as they are.</b> Text inside a screenshot is not masked.</li>
|
||||
<li><b>It fails closed.</b> If masking is on and can’t run (the <span class="ui">Privacy masking</span> plugin turned off by hand, or the local model you turned on can’t answer), the request gets a 503 that says nothing was sent. It is never sent unmasked instead. The model on by default that can’t answer leaves the rules to mask alone.</li>
|
||||
<li><b>Local models can skip it.</b> <span class="ui">Send requests unmasked</span> on a provider whose every address is on this computer or your local network (Ollama, LM Studio) sends its requests as written; <code>magpie provider set ollama unmasked=yes</code> does the same. The logs keep the masked body.</li>
|
||||
<li><b>A provider can skip it.</b> <span class="ui">Send requests unmasked</span> on a provider sends its requests as written: a model on this computer or your local network (Ollama, LM Studio), and, if you choose, any other provider, a subscription or a plugin’s provider too. Turned on for one that isn’t local, the editor says its vendor gets your requests unmasked. A request that can fall back to a provider still masked is masked. <code>magpie provider set ollama unmasked=yes</code> does the same.</li>
|
||||
<li><b>Or send what masking would change to one of them.</b> In <span class="ui">Settings › Privacy</span>, <span class="ui">Instead of masking, send to</span> picks such a model. An agent’s request that masking would change then goes to it as written, so it can answer about the real names, and a request with nothing to mask goes where it was going. If that model fails, the request fails: it is never masked and sent to a vendor instead. Off by default.</li>
|
||||
<li><b>The model sees placeholders.</b> It can’t read or reason about a masked value; it can only pass it on. Put a value it must read under <span class="ui">Never mask</span>.</li>
|
||||
<li><b>Rules find shapes.</b> A phone number in another country’s format or a name in free text needs <span class="ui">Find with a local model</span>, or your own <span class="ui">Masked words</span> and <span class="ui">Masking rules</span>. Try your own text in <span class="ui">Try it</span> first.</li>
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
<li><b>ID 和工具定义原样发送:</b>模型 ID、消息和调用 ID、UUID、工具名、MCP 服务名、工具 schema(其中的描述文字会脱敏),这样厂商和工具还能校验它们。</li>
|
||||
<li><b>图片和文件数据原样发送。</b>截图里的文字不会被遮。</li>
|
||||
<li><b>失败即不发送。</b>脱敏已打开却运行不了(手动关掉了 <span class="ui">隐私遮盖</span> 插件,或你打开的本地模型没响应),请求返回 503,说明什么都没发出,绝不会退回成不脱敏直接发送。默认打开的模型没响应时,只用规则脱敏。</li>
|
||||
<li><b>本地模型可以跳过。</b>供应商的每个地址都在本机或局域网(Ollama、LM Studio)时,打开它的 <span class="ui">请求不脱敏</span>,请求就原样发出;命令行是 <code>magpie provider set ollama unmasked=yes</code>。日志里保存的仍是脱敏后的内容。</li>
|
||||
<li><b>供应商可以跳过。</b>打开供应商的 <span class="ui">请求不脱敏</span>,它的请求就原样发出:本机或局域网的模型(Ollama、LM Studio),以及你选择的任何其他供应商,订阅和插件提供的供应商也可以。对不在本地的供应商打开时,编辑器会提示请求会不脱敏地发给它的服务商。可能回退到仍在脱敏的供应商的请求照样脱敏。命令行是 <code>magpie provider set ollama unmasked=yes</code>。</li>
|
||||
<li><b>也可以把会被脱敏的请求改发给它。</b>在 <span class="ui">设置 › 隐私</span> 的 <span class="ui">命中脱敏时改用</span> 里选一个这样的模型。智能体的请求一旦命中脱敏规则,就原样发给它,它能按真实名称回答;没有要脱敏内容的请求照常发往原来的模型。这个模型失败时请求直接失败,绝不会脱敏后改发给云端厂商。默认关闭。</li>
|
||||
<li><b>模型只看到占位符。</b>它无法读懂或推理被遮掉的值,只能原样传递。需要模型读的值放进 <span class="ui">从不脱敏</span>。</li>
|
||||
<li><b>规则按格式匹配。</b>其他国家格式的电话号码、自由文本里的人名,需要 <span class="ui">用本地模型查找</span>,或者自己的 <span class="ui">脱敏词</span> 和 <span class="ui">自定义脱敏规则</span>。先用 <span class="ui">试一试</span> 测一下你自己的文本。</li>
|
||||
|
||||
Reference in New Issue
Block a user