@magpie-community/opencode-agy-tui-auth 0.1.11 → 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 +1 -1
- package/README.md +1 -1
- package/index.mjs +26 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -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
|
@@ -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/index.mjs
CHANGED
|
@@ -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 })
|
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",
|