@magpie-community/opencode-zen-free-auth 0.1.10 → 0.1.12

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/README.md CHANGED
@@ -56,15 +56,18 @@ The agent's tools are preserved. Zen's models often call OpenCode's own
56
56
  tool names; such a call is given the agent's tool whose name differs only
57
57
  in case (`bash` to `Bash`), or else only in case and `_`/`-` (`todowrite`
58
58
  to `todo_write`, `webfetch` to `web_fetch`), when exactly one does. A
59
- call with no such tool (or with no name) is left out of the reply, and
60
- the reply's text says which name was left out; a turn whose every call
61
- was left out ends as an ordinary answer. Tools run in the agent.
59
+ call of a tool the agent has no spelling of (`psh` beside `pwsh`, `bedit`)
60
+ reaches the agent as the model called it, as with any other provider: the
61
+ agent answers it with its own unknown-tool error, and the model corrects
62
+ the name and goes on. Only a call with no name is left out, and the
63
+ reply's text says so; a turn whose every call was left out ends as an
64
+ ordinary answer. Tools run in the agent.
62
65
 
63
66
  Zen's free tier only answers a request that carries tools, so a request
64
67
  is sent with the five core OpenCode tools the agent doesn't declare
65
68
  itself (`bash`, `edit`, `glob`, `grep`, `read`), described as not
66
- available. A call of one of them the agent doesn't have is left out like
67
- any other.
69
+ available. A call of one of them the agent doesn't have reaches the agent
70
+ like any other.
68
71
 
69
72
  Now and then Zen closes a streamed Chat Completions reply before its
70
73
  `[DONE]`. When the reply has said something and no tool call of it is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-zen-free-auth",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "OpenCode Zen free models through the public credential, with native streaming protocols",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",
package/tool-response.mjs CHANGED
@@ -48,8 +48,13 @@ function foldsTo(declared, key) {
48
48
  return folded;
49
49
  }
50
50
 
51
- // nameGuard answers the agent's name for a call, or null for a call of no
52
- // tool the agent has (a missing name included).
51
+ // nameGuard answers the agent's name for a call: the agent's spelling when
52
+ // one folds to it, else the name as the model wrote it. A call of a tool
53
+ // the agent doesn't have (bedit, psh, mcp__netcatcatty__unused) goes to the
54
+ // agent as called, like any other provider's: the agent answers it with
55
+ // its own unknown-tool error, and the model corrects the name and goes on
56
+ // (#209). Leaving it out ended an agent's turn as a plain answer. Only a
57
+ // call with no name answers null, and is left out.
53
58
  function nameGuard(policy) {
54
59
  const declared = new Set(policy.declared);
55
60
  const lower = (name) => name.toLowerCase();
@@ -61,16 +66,15 @@ function nameGuard(policy) {
61
66
  if (declared.has(name)) return name;
62
67
  const match =
63
68
  byCase.get(lower(name)) ?? (byCase.has(lower(name)) ? null : byShape.get(bare(name)));
64
- return match || null;
69
+ return match || name;
65
70
  };
66
71
  }
67
72
 
68
- // The models also call tools no agent has: bedit, bcp, ash, a mangled
69
- // mcp__netcatcatty__unused (#76). Such a call can't be run or named onto
70
- // one the agent has, and failing the reply for it threw away the whole
71
- // turn. It is left out instead, and the reply says so in its text, where
72
- // the agent's user and the model's next turn both read it. A reply left
73
- // with no call ends as a plain stop.
73
+ // A call with no name can't be answered by any agent, and failing the
74
+ // reply for it threw away the whole turn (#76). It is left out instead,
75
+ // and the reply says so in its text, where the agent's user and the
76
+ // model's next turn both read it. A reply left with no call ends as a
77
+ // plain stop.
74
78
  export function droppedNote(name) {
75
79
  return typeof name === "string" && name
76
80
  ? `(The model called a tool this agent doesn't have: ${JSON.stringify(name.slice(0, 128))}. The call was left out.)`
@@ -246,6 +250,8 @@ function appendFunction(target, fragment) {
246
250
  if (!object(fragment)) throw new GuardError("Invalid upstream function delta");
247
251
  for (const [key, value] of Object.entries(fragment)) {
248
252
  if (key === "name" || key === "arguments") {
253
+ // Nullable stream fields carry no new bytes; keep prior fragments intact.
254
+ if (value == null) continue;
249
255
  if (typeof value !== "string") throw new GuardError("Invalid upstream function delta");
250
256
  target[key] = (target[key] ?? "") + value;
251
257
  } else {