@magpie-community/opencode-agy-tui-auth 0.1.4 → 0.1.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.
package/live.mjs CHANGED
@@ -4,7 +4,9 @@
4
4
  // model's reply there as each piece of it arrives: a row of `steps` with
5
5
  // step_type 15 (the PLANNER_RESPONSE the transcript gets at the end),
6
6
  // status 8 while it comes and 3 once whole, its text, as the model wrote
7
- // it, in field 20.1 of step_payload. The transcript is written only when
7
+ // it, in field 20.1 of step_payload, and its thinking (the thought parts
8
+ // Gemini streams before the text, which agy asks for with includeThoughts)
9
+ // in field 20.3, filled in first. The transcript is written only when
8
10
  // the reply is whole, and the screen shows it drawn (markup taken out,
9
11
  // lines wrapped), so this is the one place the reply can be read as it
10
12
  // comes. Read-only, never waiting on a lock; anything unreadable is null,
@@ -104,23 +106,35 @@ function fields(buf, fn) {
104
106
 
105
107
  const bytesOf = (v) => v instanceof Uint8Array ? v : ArrayBuffer.isView(v) ? new Uint8Array(v.buffer, v.byteOffset, v.byteLength) : v instanceof ArrayBuffer ? new Uint8Array(v) : null
106
108
 
107
- // replyOf is a PLANNER_RESPONSE step's text (field 20.1 of its payload),
108
- // "" when it has none yet, null when the payload isn't one.
109
- export function replyOf(payload) {
109
+ // stepOf is a PLANNER_RESPONSE step's text (field 20.1 of its payload)
110
+ // and thinking (field 20.3), each "" when it has none yet; null when the
111
+ // payload isn't one.
112
+ export function stepOf(payload) {
110
113
  const buf = bytesOf(payload)
111
114
  if (!buf) return null
112
115
  let response = null
113
116
  if (!fields(buf, (f, w, v) => { if (f === 20 && w === 2) response = v })) return null
114
- if (!response) return ""
115
- let text = ""
116
- if (!fields(response, (f, w, v) => { if (f === 1 && w === 2) text = new TextDecoder().decode(v) })) return null
117
- return text
117
+ const step = { text: "", thinking: "" }
118
+ if (!response) return step
119
+ const dec = new TextDecoder()
120
+ if (!fields(response, (f, w, v) => {
121
+ if (w !== 2) return
122
+ if (f === 1) step.text = dec.decode(v)
123
+ else if (f === 3) step.thinking = dec.decode(v)
124
+ })) return null
125
+ return step
118
126
  }
119
127
 
120
- // liveText is what agy's model has said so far in the conversation id of
121
- // the account at home: each reply's text, in order, a blank line between
122
- // two; null when the store can't be read.
123
- export function liveText(home, id) {
128
+ // replyOf is a PLANNER_RESPONSE step's text, "" when it has none yet, null
129
+ // when the payload isn't one.
130
+ export function replyOf(payload) {
131
+ return stepOf(payload)?.text ?? null
132
+ }
133
+
134
+ // liveReply is what agy's model has said so far in the conversation id of
135
+ // the account at home: { text, thinking }, each the replies' own, in
136
+ // order, a blank line between two; null when the store can't be read.
137
+ export function liveReply(home, id) {
124
138
  const file = conversationDb(home, id)
125
139
  if (!file || !fs.existsSync(file)) return null
126
140
  const open = loadOpener()
@@ -130,14 +144,21 @@ export function liveText(home, id) {
130
144
  db = open(file)
131
145
  const rows = db.all(`SELECT idx, step_payload FROM steps WHERE step_type = ${MODEL_STEP} ORDER BY idx`)
132
146
  const texts = []
147
+ const thoughts = []
133
148
  for (const row of rows) {
134
- const text = replyOf(row.step_payload)
135
- if (text) texts.push(text)
149
+ const step = stepOf(row.step_payload)
150
+ if (step?.text) texts.push(step.text)
151
+ if (step?.thinking) thoughts.push(step.thinking)
136
152
  }
137
- return texts.join("\n\n")
153
+ return { text: texts.join("\n\n"), thinking: thoughts.join("\n\n") }
138
154
  } catch {
139
155
  return null
140
156
  } finally {
141
157
  try { db?.close() } catch {}
142
158
  }
143
159
  }
160
+
161
+ // liveText is liveReply's text alone.
162
+ export function liveText(home, id) {
163
+ return liveReply(home, id)?.text ?? null
164
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-agy-tui-auth",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Magpie/OpenCode model provider that runs Antigravity's models through agy's own interactive mode: each request is typed into the real agy TUI and its answer streamed from agy's own conversation store as the model writes it",
5
5
  "type": "module",
6
6
  "main": "./opencode.mjs",
@@ -14,6 +14,11 @@
14
14
  "default-agent.mjs",
15
15
  "agy-version.mjs",
16
16
  "tool-gate.mjs",
17
+ "tools.mjs",
18
+ "tool-schema.mjs",
19
+ "re2-pattern.mjs",
20
+ "array-items.mjs",
21
+ "tool-budget.mjs",
17
22
  "opencode.mjs",
18
23
  "opencode2.mjs",
19
24
  "README.md",
@@ -39,7 +44,7 @@
39
44
  "test": "bun test"
40
45
  },
41
46
  "engines": {
42
- "magpie": ">=0.1.5027"
47
+ "magpie": ">=0.1.5217"
43
48
  },
44
49
  "magpie": {
45
50
  "maxConcurrency": 4