@magpie-community/opencode-trae-auth 0.2.1 → 0.2.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.
Files changed (2) hide show
  1. package/index.mjs +14 -0
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1083,6 +1083,7 @@ class NativeCalls {
1083
1083
  const next = c.arguments
1084
1084
  if (!next || prev.startsWith(next)) return // nothing new
1085
1085
  if (next.startsWith(prev) || done(prev)) o.arguments = next // the arguments so far
1086
+ else if (resent(prev, next)) o.arguments = next // the whole call again, written apart (plugins#24)
1086
1087
  else o.arguments = prev + next // a piece
1087
1088
  }
1088
1089
  take(tools = []) {
@@ -1100,6 +1101,19 @@ class NativeCalls {
1100
1101
  }
1101
1102
  }
1102
1103
 
1104
+ // resent says next is the call's whole arguments sent again after a
1105
+ // partial snapshot, not a piece of them: Trae resends a snapshot whose
1106
+ // punctuation isn't the first one's (− for -, ′ for '), so it doesn't
1107
+ // start with it. A whole object under the same first key as prev's, which
1108
+ // prev and it joined don't make whole; a piece that is a value of its own
1109
+ // (12, "ls", {}) doesn't open with prev's first key.
1110
+ function resent(prev, next) {
1111
+ const key = (s) => s.match(/^\s*\{\s*"((?:[^"\\]|\\.)*)"/)?.[1]
1112
+ if (!next.trimStart().startsWith("{") || !done(next) || done(prev + next)) return false
1113
+ const k = key(prev)
1114
+ return k !== undefined && k === key(next)
1115
+ }
1116
+
1103
1117
  // done says arguments are a whole JSON value already
1104
1118
  function done(a) {
1105
1119
  if (!a) return false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-trae-auth",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "OpenCode provider plugins for Trae: Trae CN (trae.cn) and Trae Global (trae.ai), free tier included, with Trae's own browser sign-in",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",