@magpie-community/opencode-agy-tui-auth 0.1.10 → 0.1.11

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 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
 
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
 
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
 
@@ -1609,6 +1609,11 @@ export const AgyTuiPlugin = async () => ({
1609
1609
  authorize: async () => {
1610
1610
  const agy = findAgy()
1611
1611
  if (!agy) return { type: "failed", error: `agy CLI not found. Install Antigravity CLI: ${AGY_MANUAL}` }
1612
+ // an agy too old for this plugin (one before 1.5.0 has no
1613
+ // `agy acp --login`) says what to run, not agy's own complaint
1614
+ // about the arguments (wangmaoning on X)
1615
+ const version = await agyVersion(agy)
1616
+ if (version && agyTooOld(version)) return { type: "failed", error: oldAgyError(version, agy) }
1612
1617
  return signIn(agy)
1613
1618
  },
1614
1619
  },
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
- if (/Usage:/.test(out) && !SIGN_IN_LINK.test(out)) {
81
- settle({ error: "this agy can't sign in from magpie (it has no `agy acp --login`): update it with `agy update`" })
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.10",
3
+ "version": "0.1.11",
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",