@magpie-community/opencode-workbuddy-auth 0.2.4 → 0.2.6

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.
Files changed (3) hide show
  1. package/README.md +5 -0
  2. package/index.mjs +11 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -249,6 +249,11 @@ instead of passing it to the agent as an answer. Only text that is still
249
249
  the filter's line is held, so any other reply's words go as they come; the
250
250
  same words ending `stop`, or the filter cutting off a reply after other
251
251
  words, go through as they came.
252
+ copilot.tencent.com sends the line with a newline on each side
253
+ (`"\nSorry, I can't respond to this question.\n"`); since 0.2.5 white
254
+ space around it no longer lets it through. It also puts `"tool_calls": []` on
255
+ every delta; since 0.2.6 only a list with a call in it lets the reply
256
+ through as it came.
252
257
 
253
258
  ## Models
254
259
 
package/index.mjs CHANGED
@@ -1605,10 +1605,14 @@ function renamed(res, names) {
1605
1605
  // no output tokens counted (itspig, plugins #540).
1606
1606
  const FILTER_SAYS = ["Sorry, I can't respond to this question."]
1607
1607
 
1608
- // filterSaid tells whether text said so far may still be FILTER_SAYS.
1608
+ // filterSaid tells whether text said so far may still be FILTER_SAYS, with
1609
+ // white space on either side: copilot.tencent.com sends it as
1610
+ // "\nSorry, I can't respond to this question.\n" (itspig, plugins #540).
1611
+ // Text that is only white space so far may still be it; text that goes on
1612
+ // past it is not.
1609
1613
  const filterSaid = (text) => {
1610
- const t = text.replace(/’/g, "'").trimStart()
1611
- return t !== "" && FILTER_SAYS.some((s) => s.startsWith(t))
1614
+ const t = text.replace(/’/g, "'").trim()
1615
+ return FILTER_SAYS.some((s) => s.startsWith(t))
1612
1616
  }
1613
1617
 
1614
1618
  // unsaid is a streamed chat whose reply WorkBuddy's filter refused with its
@@ -1656,7 +1660,10 @@ function unsaid(res) {
1656
1660
  const c = chunkOf(ev)?.choices?.[0]
1657
1661
  const text = typeof c?.delta?.content === "string" ? c.delta.content : ""
1658
1662
  const finish = c?.finish_reason
1659
- if (c?.delta?.tool_calls || (text && !filterSaid(said + text))) {
1663
+ // copilot.tencent.com sends "tool_calls": [] on every delta, text
1664
+ // too: only a list with a call in it is one
1665
+ const calls = c?.delta?.tool_calls
1666
+ if ((Array.isArray(calls) ? calls.length > 0 : calls) || (text && !filterSaid(said + text))) {
1660
1667
  open = false
1661
1668
  const out = [...held, ev]
1662
1669
  held = []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-workbuddy-auth",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",