@magpie-community/opencode-agy-tui-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.en.md +2 -2
- package/README.md +2 -2
- package/agy-version.mjs +16 -0
- package/index.mjs +32 -2
- package/login.mjs +7 -3
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -6,7 +6,7 @@ Antigravity's models through agy's own interactive mode (its TUI). Each request
|
|
|
6
6
|
|
|
7
7
|
## Use
|
|
8
8
|
|
|
9
|
-
1. Install the [Antigravity CLI](https://antigravity.google/docs/cli) (`agy`), version 1.5.19 or newer. An older agy is refused with "Update agy".
|
|
9
|
+
1. Install the [Antigravity CLI](https://antigravity.google/docs/cli) (`agy`), version 1.5.19 or newer. An older agy is refused with "Update agy", and its sign-in says to run `agy update` (one before 1.5.0 has no `agy acp --login`).
|
|
10
10
|
2. Install this plugin from magpie's Plugins page, add **Antigravity (agy TUI)** under Providers and pick "Sign in with Google": magpie opens agy's sign-in link, and you paste back the code the page shows.
|
|
11
11
|
3. The models are the ones `agy models` lists: asked at sign-in and kept in the account's folder, and asked again only when you refresh the list.
|
|
12
12
|
|
|
@@ -27,7 +27,7 @@ A request's tools (`tools`, function tools) are given to the model through magpi
|
|
|
27
27
|
- The models say a context of 64K tokens (about what fits in agy's message, with agy's own ~10K of instructions), and each response has the usage agy recorded (`usage`: the call's input, cache read and write, and every call's output and thinking), so an agent compacts its conversation before a request that pastes it whole would be cut.
|
|
28
28
|
- A streamed request gets the answer as the model writes it: agy commits each piece of the reply to its own conversation store (`conversations/<id>.db`), and the plugin reads what is new, read-only. When the store can't be read, the answer comes whole when the turn ends. The model's thinking (agy asks Gemini for it) comes the same way, as `reasoning_content`, before the answer; not streamed, it is the message's `reasoning_content`. The response ends when the answer is whole, without waiting for agy to exit (it sends its own telemetry on the way out).
|
|
29
29
|
- agy takes seconds to start (signed in with Google, it asks Google for the account, its plan and its models before it takes a message), so each request leaves an agy started, at its prompt, for the next request with the same account, model and tools, which only types its message into it, and a turn that keeps its conversation leaves one with that conversation for the chat's next request. One waits for each such kind (three at most), for 10 minutes at most; `AGY_TUI_SPARES=0` starts each request's agy when it comes instead.
|
|
30
|
-
- It needs magpie 0.1.5217 or newer (with `tui-helper` and its tool server); an older magpie is told
|
|
30
|
+
- It needs magpie 0.1.5217 or newer (with `tui-helper` and its tool server); an older magpie is told which version the magpie running the plugin needs when a request has tools (as a Remote magpie, the server's; a Docker image never updates itself, while its plugins update every hour). Not yet tried on Windows.
|
|
31
31
|
|
|
32
32
|
## Options (environment)
|
|
33
33
|
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## 用法
|
|
8
8
|
|
|
9
|
-
1. 安装 [Antigravity CLI](https://antigravity.google/docs/cli)(`agy`),需要 1.5.19 或更新;更旧的 agy 会被拒绝,并提示「Update agy
|
|
9
|
+
1. 安装 [Antigravity CLI](https://antigravity.google/docs/cli)(`agy`),需要 1.5.19 或更新;更旧的 agy 会被拒绝,并提示「Update agy」,登录时会提示运行 `agy update`(1.5.0 之前的 agy 没有 `agy acp --login`)。
|
|
10
10
|
2. 在 magpie 的插件页安装本插件,然后在 Providers 里添加 **Antigravity (agy TUI)**,选「使用 Google 登录」:magpie 打开 agy 的登录链接,把页面上显示的代码粘贴回来即可。
|
|
11
11
|
3. 模型列表来自 `agy models`:登录时问一次,存在账号目录里,之后只在你刷新列表时再问。
|
|
12
12
|
|
|
@@ -27,7 +27,7 @@ agy 运行的是它的默认 agent,不用自定义 agent(`--agent`):agy
|
|
|
27
27
|
- 模型宣告的上下文是 64K token(大约是 agy 一条消息能放下的量,加上 agy 自己约 10K 的指令),每次响应都会带上 agy 记录的用量(`usage`:本次调用的输入、缓存读写,以及所有调用的输出和思考),这样 agent 会在整段粘贴的请求被截断之前压缩对话。
|
|
28
28
|
- 流式请求边生成边返回:agy 每收到模型的一段回答就写进它自己的对话库(`conversations/<id>.db`),插件只读地读出新增的部分发出去;读不到时在一轮结束后返回完整回答。模型的思考(agy 向 Gemini 要了思考内容)同样边生成边作为 `reasoning_content` 返回,在回答之前;非流式时放在消息的 `reasoning_content` 里。回答写完就结束响应,不等 agy 退出(它退出前会先发完自己的遥测)。
|
|
29
29
|
- agy 启动要好几秒(用 Google 账号登录时,它先向 Google 查询账号、套餐和模型,然后才接收消息),所以每个请求都会为下一个账号、模型和工具相同的请求预先启动一个 agy,停在输入框;下一个请求来了只需输入消息。保留了会话的一轮,还会为这段对话的下一个请求预先启动一个带着这个会话的 agy。每种组合最多留一个(总共最多三个),最多等 10 分钟;设置 `AGY_TUI_SPARES=0` 就改回请求来了才启动 agy。
|
|
30
|
-
- 需要 magpie 0.1.5217 或更新(带 `tui-helper` 及其工具服务器);magpie
|
|
30
|
+
- 需要 magpie 0.1.5217 或更新(带 `tui-helper` 及其工具服务器);magpie 太旧时,带工具的请求会说明运行这个插件的 magpie 需要哪个版本(作为远程 magpie 使用时是服务器上的那个;Docker 镜像不会自己更新,插件却每小时更新)。Windows 尚未测试。
|
|
31
31
|
|
|
32
32
|
## 选项(环境变量)
|
|
33
33
|
|
package/agy-version.mjs
CHANGED
|
@@ -14,3 +14,19 @@ export function agyTooOld(version) {
|
|
|
14
14
|
}
|
|
15
15
|
return null
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
// agy 1.5.0 added `agy acp --login`, the Google sign-in magpie runs. An
|
|
19
|
+
// agy before it has no acp and takes "acp" for a prompt: `Error: unexpected
|
|
20
|
+
// argument "acp".` then `Prompts are read only from -p/--print,
|
|
21
|
+
// -i/--prompt-interactive, or stdin, so this argument would have been
|
|
22
|
+
// ignored.` (wangmaoning on X, Intel Mac).
|
|
23
|
+
export const LOGIN_AGY_VERSION = "1.5.0"
|
|
24
|
+
|
|
25
|
+
// oldAgyError is what a sign-in on an agy too old for this plugin says:
|
|
26
|
+
// which agy, the version it needs, and the command that updates it. why is
|
|
27
|
+
// what was tried already, if anything.
|
|
28
|
+
export function oldAgyError(version = "", file = "", why = "") {
|
|
29
|
+
const which = `${version ? `agy ${version}` : "this agy"}${file ? ` (${file})` : ""}`
|
|
30
|
+
return `${which} is too old to sign in from magpie: the sign-in runs "agy acp --login", which came in agy ${LOGIN_AGY_VERSION}, ` +
|
|
31
|
+
`and this plugin needs agy ${MIN_AGY_VERSION} or newer.${why ? ` ${why}.` : ""} Run "agy update" in a terminal, then sign in again.`
|
|
32
|
+
}
|
package/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import os from "node:os"
|
|
|
5
5
|
import path from "node:path"
|
|
6
6
|
import { startLogin } from "./login.mjs"
|
|
7
7
|
import { writeDefaultAgentFiles } from "./default-agent.mjs"
|
|
8
|
-
import { agyTooOld, MIN_AGY_VERSION } from "./agy-version.mjs"
|
|
8
|
+
import { agyTooOld, MIN_AGY_VERSION, oldAgyError } from "./agy-version.mjs"
|
|
9
9
|
import { liveReply, callsAfter, usageOf, lastStep } from "./live.mjs"
|
|
10
10
|
import { mcpToolsOf } from "./tools.mjs"
|
|
11
11
|
|
|
@@ -614,6 +614,28 @@ export function screenTail(screen, n = 8) {
|
|
|
614
614
|
return lines.slice(-n).join("\n")
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
+
// The magpie each part of this plugin needs: tui-helper (and MAGPIE_EXE)
|
|
618
|
+
// came in 0.1.5027, its tools line in 0.1.5217 (package.json's
|
|
619
|
+
// engines.magpie). A magpie isn't updated with its plugins everywhere: a
|
|
620
|
+
// Docker image, or a server's `magpie serve`, keeps the version it was
|
|
621
|
+
// started with while plugins update every hour, so the message says which
|
|
622
|
+
// magpie and which version (earayu on X: a server reached as a Remote
|
|
623
|
+
// magpie, told only "update magpie").
|
|
624
|
+
const TUI_HELPER_MAGPIE = "0.1.5027"
|
|
625
|
+
const TOOLS_MAGPIE = "0.1.5217"
|
|
626
|
+
|
|
627
|
+
// noToolsHelper is whether what tui-helper said is a tui-helper from
|
|
628
|
+
// before its tools line: it asks for start first, and names no tools
|
|
629
|
+
export function noToolsHelper(said) {
|
|
630
|
+
return typeof said === "string" && said.includes('the first line is {"start"') && !said.includes('"tools"')
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// oldMagpie is the error for a magpie older than version, for what that
|
|
634
|
+
// version is the first to do
|
|
635
|
+
export function oldMagpie(version, what) {
|
|
636
|
+
return `the magpie running this plugin is older than ${version}, the first that ${what}: update that magpie (on a server you reach as a Remote magpie, the server's own; in Docker, pull ghcr.io/yetone/magpie:latest and start the container again)`
|
|
637
|
+
}
|
|
638
|
+
|
|
617
639
|
class Failure extends Error {
|
|
618
640
|
constructor(status, message, headers) {
|
|
619
641
|
super(message)
|
|
@@ -765,7 +787,7 @@ export async function closeSpares() {
|
|
|
765
787
|
// prompt, media, signal, messages }) waits until it is at its prompt,
|
|
766
788
|
// types the request in and resolves with the turn
|
|
767
789
|
async function launch({ agy, home, model, tools = [], helper = process.env.MAGPIE_EXE, conversation = null }) {
|
|
768
|
-
if (!helper) throw new Failure(501, "
|
|
790
|
+
if (!helper) throw new Failure(501, oldMagpie(TUI_HELPER_MAGPIE, "has a terminal for agy"))
|
|
769
791
|
settleHome(home)
|
|
770
792
|
const withTools = tools.length > 0
|
|
771
793
|
const ws = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "agy-tui-")))
|
|
@@ -954,6 +976,9 @@ async function launch({ agy, home, model, tools = [], helper = process.env.MAGPI
|
|
|
954
976
|
await waitFor("tool server", () => mcp, START_MS)
|
|
955
977
|
} catch (error) {
|
|
956
978
|
if (error.status === 499) throw error
|
|
979
|
+
// a tui-helper from before tools turns the tools line away as
|
|
980
|
+
// not its first line: the magpie running this plugin is too old
|
|
981
|
+
if (noToolsHelper(errorLine)) throw new Failure(501, oldMagpie(TOOLS_MAGPIE, "gives agy the agent's tools"))
|
|
957
982
|
throw new Failure(501, `this magpie's terminal can't give agy tools (${errorLine || error.message}): update magpie`)
|
|
958
983
|
}
|
|
959
984
|
fs.writeFileSync(path.join(ownHome, ".gemini", "config", "mcp_config.json"), JSON.stringify(mcpConfig(mcp, tools)), { mode: 0o600 })
|
|
@@ -1609,6 +1634,11 @@ export const AgyTuiPlugin = async () => ({
|
|
|
1609
1634
|
authorize: async () => {
|
|
1610
1635
|
const agy = findAgy()
|
|
1611
1636
|
if (!agy) return { type: "failed", error: `agy CLI not found. Install Antigravity CLI: ${AGY_MANUAL}` }
|
|
1637
|
+
// an agy too old for this plugin (one before 1.5.0 has no
|
|
1638
|
+
// `agy acp --login`) says what to run, not agy's own complaint
|
|
1639
|
+
// about the arguments (wangmaoning on X)
|
|
1640
|
+
const version = await agyVersion(agy)
|
|
1641
|
+
if (version && agyTooOld(version)) return { type: "failed", error: oldAgyError(version, agy) }
|
|
1612
1642
|
return signIn(agy)
|
|
1613
1643
|
},
|
|
1614
1644
|
},
|
package/login.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process"
|
|
2
2
|
import os from "node:os"
|
|
3
|
+
import { oldAgyError } from "./agy-version.mjs"
|
|
3
4
|
|
|
4
5
|
// The Google sign-in, run by agy itself (from the agy-cli plugin's
|
|
5
6
|
// login.mjs): `agy acp --login` prints Google's sign-in link, then reads
|
|
@@ -12,6 +13,9 @@ export const LOGIN_START_MS = 30_000
|
|
|
12
13
|
export const LOGIN_FINISH_MS = 60_000
|
|
13
14
|
|
|
14
15
|
const SIGN_IN_LINK = /https:\/\/accounts\.google\.com\/[^\s"'<>]+/
|
|
16
|
+
// An agy with no `agy acp --login` (before 1.5.0): one older still has no
|
|
17
|
+
// acp and takes "acp" for a prompt, a later one prints acp's usage.
|
|
18
|
+
const NO_LOGIN = /Prompts are read only from|unexpected argument "acp|Usage:/
|
|
15
19
|
|
|
16
20
|
let pending = null
|
|
17
21
|
|
|
@@ -77,9 +81,9 @@ export function startLogin(agy, env, { waitMs = LOGIN_WAIT_MS, startMs = LOGIN_S
|
|
|
77
81
|
if (pending === child) pending = null
|
|
78
82
|
exited = exited ?? { code }
|
|
79
83
|
for (const w of waiters.splice(0)) w()
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
84
|
+
// an agy too old to sign in says so, with what to run, not its own
|
|
85
|
+
// complaint about the arguments
|
|
86
|
+
if (NO_LOGIN.test(out) && !SIGN_IN_LINK.test(out)) settle({ error: oldAgyError("", agy) })
|
|
83
87
|
settle({ error: `agy exited before printing a sign-in link${lastLine(out) ? `: ${lastLine(out)}` : ""}` })
|
|
84
88
|
})
|
|
85
89
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-agy-tui-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
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",
|