workbuddy 0.2.23: hide DeepSeek Harness's name, on by default
NancyTom18 on X: a WorkBuddy account used from DeepSeek Harness through magpie was banned, and a reply said Tencent recognises dsh's built-in prompt. A new per-site switch, "Hide DeepSeek Harness's name" (hide_dsh), on by default and on in OpenCode, takes the name out of the system prompt, user and assistant text and tool descriptions: dsh's opener becomes "You are an AI agent.", the runtime context's checkout and Web GUI lines lose the name. Tool results, paths, commands, DSH_HOME and ~/.dsh are kept. Labels in zh, zh-TW, ja, de. README section added. Run: bun test packages/workbuddy on mote, 332 pass 0 fail, at this tree. hidedsh.test.mjs uses dsh 0.2.1's literal strings from @deepseek-ai/dsh-system-prompt and dsh-harness-dev-context. Broken by hand: with the hook as `if (false && ...)` the new file went 6 pass 4 fail (the four "name doesn't go" cases). Not tried: a real dsh request capture, a real WorkBuddy account. Whether this prevents a ban can't be verified.
This commit is contained in:
@@ -339,6 +339,19 @@ and says `filtersModels`, so while it is on magpie says under the models
|
||||
that the list is filtered (#590). Both are magpie's own fields; an older
|
||||
magpie shows the English words and no note.
|
||||
|
||||
### Hide DeepSeek Harness's name
|
||||
|
||||
Since 0.2.23 each site also has a "Hide DeepSeek Harness's name" switch, on
|
||||
by default, and on in OpenCode, which has no switches. A user reported a
|
||||
WorkBuddy account banned after use from DeepSeek Harness, with a reply saying
|
||||
its built-in prompt is recognised. With the switch on, the harness's name is
|
||||
taken out of the system prompt, the user's and assistant's text and the
|
||||
tools' descriptions: "You are an AI agent powered by DeepSeek Harness."
|
||||
becomes "You are an AI agent.", and the runtime lines naming its checkout and
|
||||
Web GUI say "agent implementation checkout" and "Web GUI". Tools' results,
|
||||
paths, commands and names such as `DSH_HOME` or `~/.dsh` go as they were.
|
||||
Whether this keeps an account from being banned is not known.
|
||||
|
||||
## Credits in magpie
|
||||
|
||||
magpie's usage card shows the account's credits from the resource summary.
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
// NancyTom on X: an account used from DeepSeek Harness through magpie was
|
||||
// banned, a reply there saying Tencent recognizes dsh's built-in prompt.
|
||||
// "Hide DeepSeek Harness's name" (on unless turned off) takes the name out
|
||||
// of what goes to WorkBuddy. The lines below are dsh 0.2.1's own, copied from
|
||||
// @deepseek-ai/dsh-system-prompt and dsh-harness-dev-context. Every fetch
|
||||
// here is a fake; nothing reaches the network.
|
||||
import { afterEach, expect, test } from "bun:test"
|
||||
import { WorkBuddyAuthPlugin, WorkBuddyAIAuthPlugin, _internal } from "./index.mjs"
|
||||
import { unz } from "./testdata/unz.mjs"
|
||||
|
||||
const real = globalThis.fetch
|
||||
afterEach(() => (globalThis.fetch = real))
|
||||
|
||||
const KEY = "ck_test0000000000abcdefgh"
|
||||
|
||||
const OPENER = "You are an AI agent powered by DeepSeek Harness."
|
||||
const SOURCE =
|
||||
"The runtime context names the DeepSeek Harness implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself."
|
||||
const WEB =
|
||||
'You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI.'
|
||||
const LEGACY = "The DeepSeek Harness implementation checkout is at /opt/dsh. Use this checkout only to inspect or extend DSH itself."
|
||||
// the runtime context, which dsh sends as a user message
|
||||
const CONTEXT =
|
||||
'Current DeepSeek Harness implementation checkout: "/opt/homebrew/lib/node_modules/@deepseek-ai/dsh".\nCurrent DeepSeek Harness Web GUI URL: "http://127.0.0.1:5173/".'
|
||||
const BADGE =
|
||||
"Add the official “powered by dsh” badge to documents, pull requests, merge requests, and other content produced with DeepSeek Harness. Use whenever creating a pull request or merge request."
|
||||
|
||||
const chatBody = () => ({
|
||||
model: "glm-5.3",
|
||||
stream: true,
|
||||
messages: [
|
||||
{ role: "system", content: [OPENER, SOURCE, WEB].join("\n\n") },
|
||||
{ role: "user", content: [{ type: "text", text: CONTEXT }, { type: "text", text: "run the tests in ~/.dsh/profiles" }] },
|
||||
{ role: "assistant", content: "I run in DeepSeek Harness; DSH_HOME is ~/.dsh." },
|
||||
{ role: "tool", tool_call_id: "c1", content: "README: DeepSeek Harness (DSH) is …" },
|
||||
],
|
||||
tools: [{ type: "function", function: { name: "dsh-badge", description: BADGE, parameters: { type: "object", properties: { at: { type: "string", description: "where DSH puts it" } } } } }],
|
||||
})
|
||||
|
||||
const named = (s) => /DeepSeek Harness|\bDSH\b(?!_)/.test(s)
|
||||
|
||||
test("dshHidden: each of dsh's lines says what it said, without the name", () => {
|
||||
const h = _internal.dshHidden
|
||||
expect(h(OPENER)).toBe("You are an AI agent.")
|
||||
// the line FLAGGED has set a comma in already
|
||||
expect(h("You are an AI agent, powered by DeepSeek Harness.")).toBe("You are an AI agent.")
|
||||
expect(h(SOURCE)).toBe(
|
||||
"The runtime context names the agent implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend the agent itself.",
|
||||
)
|
||||
expect(h(WEB)).toStartWith("You are interacting with the user through the Web GUI whose URL the runtime context names.")
|
||||
expect(h(LEGACY)).toBe("The agent implementation checkout is at /opt/dsh. Use this checkout only to inspect or extend the agent itself.")
|
||||
expect(h(CONTEXT)).toBe(
|
||||
'Current agent implementation checkout: "/opt/homebrew/lib/node_modules/@deepseek-ai/dsh".\nCurrent Web GUI URL: "http://127.0.0.1:5173/".',
|
||||
)
|
||||
expect(h(BADGE)).toContain("produced with the agent harness.")
|
||||
// what the agent calls by name stays
|
||||
expect(h(BADGE)).toContain("“powered by dsh”")
|
||||
expect(h("DSH_HOME=~/.dsh dsh-session:abc")).toBe("DSH_HOME=~/.dsh dsh-session:abc")
|
||||
for (const s of [OPENER, SOURCE, WEB, LEGACY, CONTEXT, BADGE]) expect(named(h(s))).toBe(false)
|
||||
})
|
||||
|
||||
test("hideDsh: Messages' system and text parts too, never a tool's result", () => {
|
||||
const chat = {
|
||||
system: [{ type: "text", text: OPENER }],
|
||||
messages: [
|
||||
{ role: "user", content: [{ type: "tool_result", tool_use_id: "t", content: "DeepSeek Harness" }, { type: "text", text: CONTEXT }] },
|
||||
],
|
||||
tools: [{ name: "x", description: BADGE, input_schema: {} }],
|
||||
}
|
||||
expect(_internal.hideDsh(chat)).toBe(true)
|
||||
expect(chat.system[0].text).toBe("You are an AI agent.")
|
||||
expect(chat.messages[0].content[0].content).toBe("DeepSeek Harness")
|
||||
expect(named(chat.messages[0].content[1].text)).toBe(false)
|
||||
expect(named(chat.tools[0].description)).toBe(false)
|
||||
expect(_internal.hideDsh({ messages: [{ role: "user", content: "hi" }] })).toBe(false)
|
||||
})
|
||||
|
||||
function serve() {
|
||||
const sent = []
|
||||
globalThis.fetch = async (url, init) => {
|
||||
sent.push({ url: String(url), body: unz(init?.body) })
|
||||
return new Response("data: [DONE]\n\n", { headers: { "content-type": "text/event-stream" } })
|
||||
}
|
||||
return sent
|
||||
}
|
||||
|
||||
const magpieWith = (v) => ({ option: (provider, key) => (key in (v[provider] ?? {}) ? v[provider][key] : key === _internal.HIDE_DSH) })
|
||||
|
||||
for (const [plugin, site, url] of [
|
||||
[WorkBuddyAuthPlugin, "workbuddy", "https://copilot.tencent.com/v2/chat/completions"],
|
||||
[WorkBuddyAIAuthPlugin, "workbuddy-ai", "https://www.workbuddy.ai/v2/chat/completions"],
|
||||
]) {
|
||||
test(`${site}: declares the switch, on by default`, async () => {
|
||||
const h = await plugin({ client: {} })
|
||||
const o = h.auth.options.find((x) => x.key === _internal.HIDE_DSH)
|
||||
expect(o.default).toBe(true)
|
||||
expect(o.label.length).toBeLessThanOrEqual(60)
|
||||
expect(o.description.length).toBeLessThanOrEqual(300)
|
||||
for (const l of ["zh", "zh-TW", "ja", "de"]) {
|
||||
expect(o.labels[l]).toBeTruthy()
|
||||
expect(o.descriptions[l]).toBeTruthy()
|
||||
}
|
||||
})
|
||||
|
||||
for (const [how, magpie] of [
|
||||
["on by default in magpie", magpieWith({})],
|
||||
["with no magpie (OpenCode)", undefined],
|
||||
]) {
|
||||
test(`${site}: ${how}, dsh's name doesn't go`, async () => {
|
||||
const sent = serve()
|
||||
const h = await plugin({ client: {}, magpie })
|
||||
const opts = await h.auth.loader(async () => ({ type: "api", key: KEY }), {})
|
||||
await opts.fetch(url, { method: "POST", body: JSON.stringify(chatBody()) })
|
||||
const out = JSON.parse(sent.at(-1).body)
|
||||
const said = JSON.stringify({ messages: out.messages.filter((m) => m.role !== "tool"), tools: out.tools })
|
||||
expect(named(said)).toBe(false)
|
||||
expect(out.messages[0].content).toStartWith("You are an AI agent.")
|
||||
// a tool's result is what a file said, and goes as it came
|
||||
expect(out.messages.find((m) => m.role === "tool").content).toBe("README: DeepSeek Harness (DSH) is …")
|
||||
expect(said).toContain("~/.dsh/profiles")
|
||||
expect(said).toContain("DSH_HOME")
|
||||
})
|
||||
}
|
||||
|
||||
test(`${site}: turned off, the prompt goes as dsh wrote it (FLAGGED's comma aside)`, async () => {
|
||||
const sent = serve()
|
||||
const h = await plugin({ client: {}, magpie: magpieWith({ [site]: { [_internal.HIDE_DSH]: false } }) })
|
||||
const opts = await h.auth.loader(async () => ({ type: "api", key: KEY }), {})
|
||||
await opts.fetch(url, { method: "POST", body: JSON.stringify(chatBody()) })
|
||||
const out = JSON.parse(sent.at(-1).body)
|
||||
expect(out.messages[0].content).toContain("You are an AI agent, powered by DeepSeek Harness.")
|
||||
expect(out.messages[0].content).toContain("extend DSH itself")
|
||||
})
|
||||
}
|
||||
@@ -3466,6 +3466,76 @@ function replyAfterToolsOn(b) {
|
||||
return true
|
||||
}
|
||||
|
||||
// HIDE_DSH is the switch, on unless the user turns it off, that takes
|
||||
// DeepSeek Harness's name out of what it sends (NancyTom on X: an account
|
||||
// used from dsh through magpie was banned, and a reply there had Tencent
|
||||
// recognize dsh's built-in prompt). FLAGGED's comma gets a chat past the
|
||||
// live 11128 check; this is for a check that reads the prompt afterwards.
|
||||
// The lines are dsh 0.2.1's own (@deepseek-ai/dsh-system-prompt and
|
||||
// dsh-harness-dev-context): the opener, the checkout and Web GUI lines in
|
||||
// the system prompt and in the runtime context dsh sends as a user message,
|
||||
// and their earlier wording (LEGACY_SOURCE, LEGACY_WEB_SURFACE). Only the
|
||||
// name in prose goes: lower-case dsh, which names paths (~/.dsh), commands,
|
||||
// URIs (dsh-session:) and skills the agent calls, stays, as does a tool's
|
||||
// result, which is what a file or command said. Case counts, so the name
|
||||
// in an identifier (DSH_HOME) is left too.
|
||||
const HIDE_DSH = "hide_dsh"
|
||||
const DSH_NAMED = [
|
||||
[/You are an AI agent,? powered by DeepSeek Harness\.?/g, "You are an AI agent."],
|
||||
[/DeepSeek Harness (Web GUI)/g, "$1"],
|
||||
[/DeepSeek Harness (implementation checkout)/g, "agent $1"],
|
||||
[/\bDSH itself\b/g, "the agent itself"],
|
||||
[/\b([Tt]he )?DeepSeek Harness\b/g, (_, the) => (the ?? "the ") + "agent harness"],
|
||||
[/\bDSH\b(?!_)/g, "the agent harness"],
|
||||
]
|
||||
|
||||
function dshHidden(text) {
|
||||
for (const [re, to] of DSH_NAMED) text = text.replace(re, to)
|
||||
return text
|
||||
}
|
||||
|
||||
// hideDsh puts dshHidden on the text of a chat's messages (Chat
|
||||
// Completions or Messages: a string, or a part of type text), on Messages'
|
||||
// system, and on the tools' descriptions; true when it changed any.
|
||||
// A tool's result (role tool, or a tool_result part) is left as it came.
|
||||
function hideDsh(chat) {
|
||||
if (!chat || typeof chat !== "object") return false
|
||||
let changed = false
|
||||
const parts = (content) => {
|
||||
if (typeof content === "string") {
|
||||
const t = dshHidden(content)
|
||||
if (t !== content) changed = true
|
||||
return t
|
||||
}
|
||||
if (!Array.isArray(content)) return content
|
||||
return content.map((p) => {
|
||||
if (!p || typeof p.text !== "string" || (p.type !== undefined && p.type !== "text")) return p
|
||||
const t = dshHidden(p.text)
|
||||
if (t === p.text) return p
|
||||
changed = true
|
||||
return { ...p, text: t }
|
||||
})
|
||||
}
|
||||
if (Array.isArray(chat.messages))
|
||||
for (const m of chat.messages) if (m && typeof m === "object" && m.role !== "tool") m.content = parts(m.content)
|
||||
if (chat.system !== undefined) chat.system = parts(chat.system)
|
||||
const described = (o) => {
|
||||
if (!o || typeof o !== "object") return
|
||||
if (Array.isArray(o)) return o.forEach(described)
|
||||
for (const k of Object.keys(o)) {
|
||||
if (k === "description" && typeof o[k] === "string") {
|
||||
const t = dshHidden(o[k])
|
||||
if (t !== o[k]) {
|
||||
o[k] = t
|
||||
changed = true
|
||||
}
|
||||
} else described(o[k])
|
||||
}
|
||||
}
|
||||
if (Array.isArray(chat.tools)) described(chat.tools)
|
||||
return changed
|
||||
}
|
||||
|
||||
// FREE_ONLY is the switch that keeps an account off credits (#430): its
|
||||
// list holds only the models WorkBuddy serves at no cost (priceOf's free),
|
||||
// and a request for any other is answered here, never sent. A price that
|
||||
@@ -3536,6 +3606,9 @@ function makePlugin(site) {
|
||||
}
|
||||
}
|
||||
const freeOnly = () => magpie?.option?.(site.id, FREE_ONLY) === true
|
||||
// on by default: magpie hands over the user's value, else the default;
|
||||
// OpenCode, with no magpie, has it on
|
||||
const dshOff = () => magpie?.option?.(site.id, HIDE_DSH) !== false
|
||||
// onlyFree is a list with the switch on: its free models, or a failure
|
||||
// when there are none to tell (magpie then keeps the list it had)
|
||||
const onlyFree = (ms) => {
|
||||
@@ -3644,6 +3717,19 @@ function makePlugin(site) {
|
||||
},
|
||||
filtersModels: true,
|
||||
},
|
||||
{
|
||||
key: HIDE_DSH,
|
||||
label: "Hide DeepSeek Harness's name",
|
||||
description: `Takes DeepSeek Harness's name out of what it sends to ${site.name}: its opening line, and the lines naming its checkout and Web GUI. Paths, commands and tools stay as they are.`,
|
||||
default: true,
|
||||
labels: { zh: "隐去 DeepSeek Harness 的名字", "zh-TW": "隱去 DeepSeek Harness 的名字", ja: "DeepSeek Harness の名前を伏せる", de: "Namen von DeepSeek Harness ausblenden" },
|
||||
descriptions: {
|
||||
zh: `把 DeepSeek Harness 的名字从发给 ${site.name} 的内容里去掉:开头那句,以及说明它源码目录和 Web GUI 的几行。路径、命令和工具保持不变。`,
|
||||
"zh-TW": `把 DeepSeek Harness 的名字從送給 ${site.name} 的內容裡去掉:開頭那句,以及說明它原始碼目錄和 Web GUI 的幾行。路徑、指令和工具保持不變。`,
|
||||
ja: `${site.name} に送る内容から DeepSeek Harness の名前を外します。冒頭の一文と、チェックアウトや Web GUI を示す行が対象です。パス、コマンド、ツールはそのままです。`,
|
||||
de: `Entfernt den Namen von DeepSeek Harness aus dem, was an ${site.name} gesendet wird: die erste Zeile sowie die Zeilen zu seinem Checkout und seiner Web-GUI. Pfade, Befehle und Tools bleiben unverändert.`,
|
||||
},
|
||||
},
|
||||
],
|
||||
async loader(getAuth) {
|
||||
const auth = await getAuth()
|
||||
@@ -3684,6 +3770,7 @@ function makePlugin(site) {
|
||||
let chat, changed, names
|
||||
;({ body, chat, changed, names } = prepared(body, native))
|
||||
if (native) names = {}
|
||||
if (dshOff() && hideDsh(chat)) changed = true
|
||||
// the switch is checked before anything is sent: a model not
|
||||
// free, or one whose price can't be read, never reaches
|
||||
// WorkBuddy. The model is read off the chat parsed above; a body
|
||||
@@ -4089,4 +4176,4 @@ export const WorkBuddyAuthPlugin = makePlugin(SITES.workbuddy)
|
||||
export const WorkBuddyAIAuthPlugin = makePlugin(SITES["workbuddy-ai"])
|
||||
|
||||
// for tests
|
||||
export const _internal = { planCodes, listedExtra, idFor, OFF_TAKEN, replyAfterToolsOn, withDefaultEffort, SMALL_BUDGET, defaultEffortOf, gzipped, FREE_ONLY, PRICE_TTL, keyAccount, remoteConfig, cycleOf, typeUnions, systemAsUser, systemKey, DEFAULT_SYSTEM, EDGE_READS, fitShape, replyAfterTools, AFTER_TOOLS_REFUSED, enterpriseUsageOf, accountName, notDesktop, textOnly, runsOutOf, packagesOf, endOf, enterpriseHeaders, enterpriseOf, liveModels, browserSignIn, withSystem, asReasoning, normalizeToolChoice, fitTools, fitted, renamed, unsaid, FILTER_SAYS, unflagged, usageOf, desktopHeld, explained, REFUSED_HINT, RESTRICTED_HINT, EXHAUSTED_HINT, REFUSED_DOC, commaPaused, commaPausedOn, opened, freeCredits, creditsOf, priceOf, fresh, SITES, renewing, renewed, SESSION, attend, scopeOf, turnKey, conversationKey, signatureOf, isMessages, withoutUnsigned, withoutSignedThinking, prepared, answeredBefore, nativeOf, modelOf, configModels, freeWindowOf, tokensShort, freeWindowRows, freeWindowLedger, readLedgerTail, pinned, pinning, rowTime, rowAccount, ofAccount, windowOffset, windowReset, CN_ESTIMATED_WINDOWS, FREE_WINDOW_AI, FREE_WINDOW_SPAN, FREE_WINDOW_GAP, FREE_WINDOW_LEAD, checkinOf, API_MESSAGES: NPM_MESSAGES, API_CHAT: NPM }
|
||||
export const _internal = { HIDE_DSH, hideDsh, dshHidden, planCodes, listedExtra, idFor, OFF_TAKEN, replyAfterToolsOn, withDefaultEffort, SMALL_BUDGET, defaultEffortOf, gzipped, FREE_ONLY, PRICE_TTL, keyAccount, remoteConfig, cycleOf, typeUnions, systemAsUser, systemKey, DEFAULT_SYSTEM, EDGE_READS, fitShape, replyAfterTools, AFTER_TOOLS_REFUSED, enterpriseUsageOf, accountName, notDesktop, textOnly, runsOutOf, packagesOf, endOf, enterpriseHeaders, enterpriseOf, liveModels, browserSignIn, withSystem, asReasoning, normalizeToolChoice, fitTools, fitted, renamed, unsaid, FILTER_SAYS, unflagged, usageOf, desktopHeld, explained, REFUSED_HINT, RESTRICTED_HINT, EXHAUSTED_HINT, REFUSED_DOC, commaPaused, commaPausedOn, opened, freeCredits, creditsOf, priceOf, fresh, SITES, renewing, renewed, SESSION, attend, scopeOf, turnKey, conversationKey, signatureOf, isMessages, withoutUnsigned, withoutSignedThinking, prepared, answeredBefore, nativeOf, modelOf, configModels, freeWindowOf, tokensShort, freeWindowRows, freeWindowLedger, readLedgerTail, pinned, pinning, rowTime, rowAccount, ofAccount, windowOffset, windowReset, CN_ESTIMATED_WINDOWS, FREE_WINDOW_AI, FREE_WINDOW_SPAN, FREE_WINDOW_GAP, FREE_WINDOW_LEAD, checkinOf, API_MESSAGES: NPM_MESSAGES, API_CHAT: NPM }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-workbuddy-auth",
|
||||
"version": "0.2.22",
|
||||
"version": "0.2.23",
|
||||
"description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
|
||||
"type": "module",
|
||||
"main": "./opencode.mjs",
|
||||
|
||||
Reference in New Issue
Block a user