super-dsh 0.1.6 → 0.1.10

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 (248) hide show
  1. package/README.md +25 -3
  2. package/agent-agy/cordis.patch.yml +7 -4
  3. package/agent-agy/dist/agent.d.ts +12 -11
  4. package/agent-agy/dist/agy-auth-gateway.d.ts +124 -0
  5. package/agent-agy/dist/agy-auth-gateway.js +233 -0
  6. package/agent-agy/dist/agy-auth.d.ts +153 -0
  7. package/agent-agy/dist/agy-auth.js +179 -0
  8. package/agent-agy/dist/agy-cli-client.d.ts +39 -9
  9. package/agent-agy/dist/agy-cli-client.js +82 -18
  10. package/agent-agy/dist/agy-store.d.ts +8 -0
  11. package/agent-agy/dist/index.d.ts +46 -16
  12. package/agent-agy/dist/index.js +82 -56
  13. package/agent-agy/dist/models.d.ts +70 -0
  14. package/agent-agy/dist/models.js +102 -3
  15. package/agent-agy/package.json +7 -5
  16. package/agent-agy-sdk/cordis.patch.yml +58 -0
  17. package/agent-agy-sdk/dist/adapter.d.ts +15 -0
  18. package/agent-agy-sdk/dist/adapter.js +42 -0
  19. package/agent-agy-sdk/dist/agent-preset-agy.d.ts +27 -0
  20. package/agent-agy-sdk/dist/agent-preset-agy.js +32 -0
  21. package/agent-agy-sdk/dist/agent.d.ts +138 -0
  22. package/agent-agy-sdk/dist/agent.js +494 -0
  23. package/{agent-agy → agent-agy-sdk}/dist/agy-client.d.ts +26 -6
  24. package/{agent-agy → agent-agy-sdk}/dist/agy-client.js +43 -25
  25. package/agent-agy-sdk/dist/agy-sessions.d.ts +25 -0
  26. package/agent-agy-sdk/dist/agy-sessions.js +107 -0
  27. package/agent-agy-sdk/dist/agy-store.d.ts +39 -0
  28. package/agent-agy-sdk/dist/agy-store.js +83 -0
  29. package/agent-agy-sdk/dist/inbox.d.ts +26 -0
  30. package/agent-agy-sdk/dist/inbox.js +53 -0
  31. package/agent-agy-sdk/dist/index.d.ts +93 -0
  32. package/agent-agy-sdk/dist/index.js +476 -0
  33. package/agent-agy-sdk/dist/models.d.ts +41 -0
  34. package/agent-agy-sdk/dist/models.js +74 -0
  35. package/agent-agy-sdk/dist/sdk-venv.d.ts +76 -0
  36. package/agent-agy-sdk/dist/sdk-venv.js +173 -0
  37. package/agent-agy-sdk/dist/world-plugin.d.ts +10 -0
  38. package/agent-agy-sdk/dist/world-plugin.js +82 -0
  39. package/agent-agy-sdk/package.json +64 -0
  40. package/agent-codex/README.md +141 -36
  41. package/agent-codex/cordis.patch.yml +14 -10
  42. package/agent-codex/dist/adapter.js +64 -28
  43. package/agent-codex/dist/agent.js +255 -81
  44. package/agent-codex/dist/app-server-approvals.js +165 -0
  45. package/agent-codex/dist/app-server-client.js +723 -0
  46. package/agent-codex/dist/app-server-events.js +432 -0
  47. package/agent-codex/dist/app-server-protocol.js +95 -0
  48. package/agent-codex/dist/app-server-wire.js +299 -0
  49. package/agent-codex/dist/codex-launch.js +78 -0
  50. package/agent-codex/dist/codex-native-config.js +392 -0
  51. package/agent-codex/dist/codex-provider-gateway.js +402 -0
  52. package/agent-codex/dist/codex-providers.js +376 -0
  53. package/agent-codex/dist/codex-route.js +86 -0
  54. package/agent-codex/dist/index.js +256 -115
  55. package/agent-codex/dist/permission.js +75 -1
  56. package/agent-codex/package.json +1 -2
  57. package/agent-codex-sdk/README.md +79 -0
  58. package/agent-codex-sdk/cordis.patch.yml +81 -0
  59. package/agent-codex-sdk/dist/adapter.js +91 -0
  60. package/agent-codex-sdk/dist/agent-preset-codex.js +32 -0
  61. package/agent-codex-sdk/dist/agent.js +1085 -0
  62. package/agent-codex-sdk/dist/codex-native-config.js +392 -0
  63. package/agent-codex-sdk/dist/codex-provider-gateway.js +402 -0
  64. package/agent-codex-sdk/dist/codex-providers.js +376 -0
  65. package/agent-codex-sdk/dist/codex-route.js +86 -0
  66. package/{agent-codex/dist/codex-client.js → agent-codex-sdk/dist/codex-sdk-client.js} +253 -32
  67. package/agent-codex-sdk/dist/codex-sdk-launch.js +92 -0
  68. package/agent-codex-sdk/dist/codex-store.js +180 -0
  69. package/agent-codex-sdk/dist/inbox.js +53 -0
  70. package/agent-codex-sdk/dist/index.js +739 -0
  71. package/agent-codex-sdk/dist/permission.js +71 -0
  72. package/agent-codex-sdk/dist/sdk-runtime.js +307 -0
  73. package/agent-codex-sdk/dist/session-map.js +167 -0
  74. package/agent-codex-sdk/dist/world-plugin.js +93 -0
  75. package/agent-codex-sdk/package.json +79 -0
  76. package/agent-codex-sdk/scripts/fetch-sdk-runtime.mjs +57 -0
  77. package/agent-omp/README.md +72 -55
  78. package/agent-omp/dist/agent.js +36 -11
  79. package/agent-omp/dist/index.js +92 -52
  80. package/agent-omp/dist/lazy-rpc.js +11 -4
  81. package/agent-omp/dist/omp-cli.js +114 -97
  82. package/agent-omp/dist/omp-store.js +12 -4
  83. package/agent-omp/dist/permission.js +70 -5
  84. package/agent-omp/dist/rpc-client.js +409 -0
  85. package/agent-omp/dist/world-plugin.js +36 -3
  86. package/agent-omp/package.json +2 -6
  87. package/agent-omp-sdk/README.md +103 -0
  88. package/agent-omp-sdk/cordis.patch.yml +108 -0
  89. package/agent-omp-sdk/dist/adapter.d.ts +21 -0
  90. package/agent-omp-sdk/dist/adapter.js +36 -0
  91. package/agent-omp-sdk/dist/agent-preset-omp.d.ts +31 -0
  92. package/agent-omp-sdk/dist/agent-preset-omp.js +32 -0
  93. package/agent-omp-sdk/dist/agent.d.ts +64 -0
  94. package/agent-omp-sdk/dist/agent.js +1178 -0
  95. package/agent-omp-sdk/dist/discovery.d.ts +57 -0
  96. package/agent-omp-sdk/dist/discovery.js +116 -0
  97. package/agent-omp-sdk/dist/inbox.d.ts +28 -0
  98. package/agent-omp-sdk/dist/inbox.js +53 -0
  99. package/agent-omp-sdk/dist/index.d.ts +60 -0
  100. package/agent-omp-sdk/dist/index.js +632 -0
  101. package/agent-omp-sdk/dist/knobs.d.ts +34 -0
  102. package/agent-omp-sdk/dist/knobs.js +50 -0
  103. package/agent-omp-sdk/dist/lazy-rpc.d.ts +98 -0
  104. package/agent-omp-sdk/dist/lazy-rpc.js +178 -0
  105. package/agent-omp-sdk/dist/mobile/zoom-guard.d.ts +187 -0
  106. package/agent-omp-sdk/dist/mobile/zoom-guard.js +294 -0
  107. package/agent-omp-sdk/dist/mobile-boot.d.ts +49 -0
  108. package/agent-omp-sdk/dist/mobile-boot.js +38 -0
  109. package/agent-omp-sdk/dist/models.d.ts +39 -0
  110. package/agent-omp-sdk/dist/models.js +299 -0
  111. package/agent-omp-sdk/dist/omp-cli.d.ts +67 -0
  112. package/agent-omp-sdk/dist/omp-cli.js +164 -0
  113. package/agent-omp-sdk/dist/omp-disk-discovery.d.ts +27 -0
  114. package/agent-omp-sdk/dist/omp-disk-discovery.js +178 -0
  115. package/agent-omp-sdk/dist/omp-executable.d.ts +2 -0
  116. package/agent-omp-sdk/dist/omp-executable.js +30 -0
  117. package/agent-omp-sdk/dist/omp-store.d.ts +134 -0
  118. package/agent-omp-sdk/dist/omp-store.js +526 -0
  119. package/agent-omp-sdk/dist/pairing.d.ts +7 -0
  120. package/agent-omp-sdk/dist/pairing.js +45 -0
  121. package/agent-omp-sdk/dist/permission.d.ts +138 -0
  122. package/agent-omp-sdk/dist/permission.js +161 -0
  123. package/agent-omp-sdk/dist/protocol.d.ts +189 -0
  124. package/agent-omp-sdk/dist/rpc-types.d.ts +77 -0
  125. package/agent-omp-sdk/dist/rpc-types.js +1 -0
  126. package/agent-omp-sdk/dist/sdk-client.d.ts +160 -0
  127. package/{agent-omp → agent-omp-sdk}/dist/sdk-client.js +108 -56
  128. package/agent-omp-sdk/dist/sdk-runtime.d.ts +211 -0
  129. package/agent-omp-sdk/dist/sdk-runtime.js +418 -0
  130. package/agent-omp-sdk/dist/sidecar-client.d.ts +87 -0
  131. package/agent-omp-sdk/dist/sidecar-client.js +197 -0
  132. package/agent-omp-sdk/dist/store/adapter.d.ts +17 -0
  133. package/agent-omp-sdk/dist/store/adapter.js +47 -0
  134. package/agent-omp-sdk/dist/store/db.d.ts +70 -0
  135. package/agent-omp-sdk/dist/store/db.js +210 -0
  136. package/agent-omp-sdk/dist/store/index.d.ts +23 -0
  137. package/agent-omp-sdk/dist/store/index.js +59 -0
  138. package/agent-omp-sdk/dist/store/reconcile.d.ts +15 -0
  139. package/agent-omp-sdk/dist/store/reconcile.js +51 -0
  140. package/agent-omp-sdk/dist/store/schema.d.ts +8 -0
  141. package/agent-omp-sdk/dist/store/schema.js +40 -0
  142. package/agent-omp-sdk/dist/transport.d.ts +49 -0
  143. package/agent-omp-sdk/dist/transport.js +35 -0
  144. package/agent-omp-sdk/dist/world-home.d.ts +4 -0
  145. package/agent-omp-sdk/dist/world-home.js +23 -0
  146. package/agent-omp-sdk/dist/world-plugin.d.ts +10 -0
  147. package/agent-omp-sdk/dist/world-plugin.js +137 -0
  148. package/agent-omp-sdk/package.json +87 -0
  149. package/client/index.js +1794 -287
  150. package/cordis.patch.yml +80 -0
  151. package/package.json +23 -8
  152. package/superd-hub/dist/a2a-delivery.d.ts +189 -0
  153. package/superd-hub/dist/a2a-delivery.js +240 -0
  154. package/superd-hub/dist/a2a-host.d.ts +76 -0
  155. package/superd-hub/dist/a2a-host.js +145 -0
  156. package/superd-hub/dist/a2a-ingest.d.ts +31 -0
  157. package/superd-hub/dist/a2a-ingest.js +636 -0
  158. package/superd-hub/dist/a2a-log.d.ts +17 -0
  159. package/superd-hub/dist/a2a-log.js +42 -0
  160. package/superd-hub/dist/a2a-row.d.ts +65 -0
  161. package/superd-hub/dist/a2a-row.js +162 -0
  162. package/superd-hub/dist/a2a-service.d.ts +357 -0
  163. package/superd-hub/dist/a2a-service.js +980 -0
  164. package/superd-hub/dist/a2a-wire.d.ts +220 -0
  165. package/superd-hub/dist/a2a-wire.js +305 -0
  166. package/superd-hub/dist/agent-ids.d.ts +10 -0
  167. package/superd-hub/dist/agent-ids.js +68 -0
  168. package/superd-hub/dist/agent-roster.d.ts +29 -18
  169. package/superd-hub/dist/agent-roster.js +54 -15
  170. package/superd-hub/dist/agent-status.d.ts +119 -0
  171. package/superd-hub/dist/agent-status.js +386 -0
  172. package/superd-hub/dist/client/agent-settings.d.ts +156 -0
  173. package/superd-hub/dist/client/agent-settings.js +229 -0
  174. package/superd-hub/dist/client/mesh-api.d.ts +134 -0
  175. package/superd-hub/dist/client/mesh-api.js +219 -0
  176. package/superd-hub/dist/client/mesh-groups.d.ts +63 -0
  177. package/superd-hub/dist/client/mesh-groups.js +66 -0
  178. package/superd-hub/dist/client/roster.d.ts +48 -0
  179. package/superd-hub/dist/client/roster.js +102 -0
  180. package/superd-hub/dist/client/runtime-settings-api.d.ts +76 -0
  181. package/superd-hub/dist/client/runtime-settings-api.js +137 -0
  182. package/superd-hub/dist/client/switch.d.ts +165 -0
  183. package/superd-hub/dist/client/switch.js +295 -0
  184. package/superd-hub/dist/exec-pty-channel.d.ts +58 -0
  185. package/superd-hub/dist/exec-pty-channel.js +162 -0
  186. package/superd-hub/dist/exec-pty-framing.d.ts +32 -0
  187. package/superd-hub/dist/exec-pty-framing.js +81 -0
  188. package/superd-hub/dist/exec-pty-rpc.d.ts +21 -0
  189. package/superd-hub/dist/exec-pty-rpc.js +128 -0
  190. package/superd-hub/dist/exec-pty-session.d.ts +76 -0
  191. package/superd-hub/dist/exec-pty-session.js +234 -0
  192. package/superd-hub/dist/exec.d.ts +56 -0
  193. package/superd-hub/dist/exec.js +225 -0
  194. package/superd-hub/dist/gateway.d.ts +39 -2
  195. package/superd-hub/dist/gateway.js +62 -3
  196. package/superd-hub/dist/hub-tool.d.ts +174 -0
  197. package/superd-hub/dist/hub-tool.js +464 -0
  198. package/superd-hub/dist/index.d.ts +15 -1
  199. package/superd-hub/dist/index.js +16 -0
  200. package/superd-hub/dist/machines.d.ts +45 -0
  201. package/superd-hub/dist/machines.js +125 -0
  202. package/superd-hub/dist/mesh-federate.d.ts +138 -0
  203. package/superd-hub/dist/mesh-federate.js +223 -0
  204. package/superd-hub/dist/mesh-gateway.d.ts +67 -0
  205. package/superd-hub/dist/mesh-gateway.js +408 -0
  206. package/superd-hub/dist/mesh-link.d.ts +274 -0
  207. package/superd-hub/dist/mesh-link.js +441 -0
  208. package/superd-hub/dist/mesh-rpc.d.ts +123 -0
  209. package/superd-hub/dist/mesh-rpc.js +250 -0
  210. package/superd-hub/dist/mux-client.d.ts +71 -0
  211. package/superd-hub/dist/mux-client.js +281 -0
  212. package/superd-hub/dist/pack-version.d.ts +2 -0
  213. package/superd-hub/dist/pack-version.js +30 -0
  214. package/superd-hub/dist/roster.d.ts +6 -0
  215. package/superd-hub/dist/rpc.d.ts +18 -2
  216. package/superd-hub/dist/rpc.js +34 -4
  217. package/superd-hub/dist/spawn-world.js +3 -1
  218. package/superd-hub/dist/switch-core.d.ts +62 -25
  219. package/superd-hub/dist/switch-core.js +53 -30
  220. package/superd-hub/dist/system-head.d.ts +22 -12
  221. package/superd-hub/dist/system-head.js +100 -84
  222. package/superd-hub/dist/wire-endpoints.d.ts +264 -0
  223. package/superd-hub/dist/wire-endpoints.js +180 -0
  224. package/superd-hub/lib/client/index.js +1794 -287
  225. package/superd-hub/package.json +11 -2
  226. package/agent-agy/dist/agent-preset-projection.d.ts +0 -31
  227. package/agent-agy/dist/agent-preset-projection.js +0 -33
  228. package/agent-claude/dist/agent-preset-projection.js +0 -30
  229. package/agent-codex/dist/agent-preset-projection.js +0 -37
  230. package/agent-codex/dist/app-home.js +0 -65
  231. package/agent-codex/dist/models.js +0 -152
  232. package/agent-codex/dist/spike.js +0 -46
  233. package/agent-hermes/dist/agent-preset-projection.js +0 -34
  234. package/agent-omp/dist/agent-preset-projection.js +0 -36
  235. package/agent-omp/dist/app-home.js +0 -86
  236. package/agent-omp/dist/sidecar-client.js +0 -195
  237. package/agent-pi/dist/agent-preset-projection.js +0 -29
  238. package/superd-hub/dist/client-shim.d.ts +0 -28
  239. package/superd-hub/dist/client-shim.js +0 -251
  240. package/superd-hub/dist/index-pass.d.ts +0 -22
  241. package/superd-hub/dist/index-pass.js +0 -47
  242. package/superd-hub/dist/labels.d.ts +0 -45
  243. package/superd-hub/dist/labels.js +0 -83
  244. /package/{agent-agy → agent-agy-sdk}/bridge/agy_bridge.py +0 -0
  245. /package/{agent-agy → agent-agy-sdk}/bridge/gemini_openai_server.mjs +0 -0
  246. /package/{agent-codex/dist/codex-events.js → agent-codex-sdk/dist/codex-sdk-events.js} +0 -0
  247. /package/{agent-omp → agent-omp-sdk}/dist/protocol.js +0 -0
  248. /package/{agent-omp → agent-omp-sdk}/sidecar/main.ts +0 -0
@@ -0,0 +1,179 @@
1
+ /**
2
+ * agy-auth.ts — the CLI adapter's auth-form detection, fallback ladder, and
3
+ * the mutation it applies to the user's LOCAL Antigravity configuration.
4
+ *
5
+ * The Antigravity CLI has four auth channels (dev-rules §16a, re-probed
6
+ * 2026-10-02 against `agy` 1.2.14):
7
+ *
8
+ * 1. account sign-in default, `cloudcode-pa.googleapis.com`; the token
9
+ * lives in the freedesktop Secret Service keyring
10
+ * (`gnome-keyring-daemon`, `org.freedesktop.secrets`,
11
+ * entry `service=gemini username=antigravity`) with a
12
+ * file fallback at `~/.gemini/antigravity-cli/
13
+ * antigravity-oauth-token`;
14
+ * 2. Gemini API key `modelProvider: "gemini"` in the CLI's settings.json
15
+ * + `GEMINI_API_KEY` in the launch environment
16
+ * (+ optional `GOOGLE_GEMINI_BASE_URL`);
17
+ * 3. ADC `AGY_ADC_AUTH=1` — `adc_auth.go` reports
18
+ * "authenticated via adc (effective: adc)". Credentials
19
+ * are `~/.config/gcloud/application_default_credentials
20
+ * .json` (or a GCE metadata server). NOT the keyring;
21
+ * 4. BYO gateway `AGY_LLM_GATEWAY_*` (out of scope; see the spec).
22
+ *
23
+ * user ruling 2026-10-02 (supersedes the dev-rules §5 "never write the native
24
+ * home" default for THIS adapter, under §12 per-adapter discretion):
25
+ *
26
+ * 「拥抱用户自己的使用环境」 — this adapter is deliberately the configuration
27
+ * surface for the user's LOCAL Antigravity. Selecting a form here really does
28
+ * rewrite their `~/.gemini/antigravity-cli/settings.json`, so the TUI they
29
+ * already use keeps working afterwards. Paths are hard-coded relative to the
30
+ * user's home for exactly that reason.
31
+ *
32
+ * Fallback order (same ruling) = Gemini API key → OAuth → ADC. OAuth stays a
33
+ * PLACEHOLDER this round: no eligible account exists to characterise the
34
+ * native fields a real sign-in stores, so nothing reports it present.
35
+ *
36
+ * Pure: every probe result is injected, so `node --test` pins the ladder; the
37
+ * one filesystem-touching helper (`nativeSettingsPath`) is a pure path fold.
38
+ *
39
+ * @module agent-agy/agy-auth
40
+ */
41
+ import { statSync } from "node:fs";
42
+ import { join } from "node:path";
43
+ /** Declared fallback order (user ruling 2026-10-02). Exported for the UI. */
44
+ export const AGY_AUTH_ORDER = ["apiKey", "oauth", "adc"];
45
+ /** Human labels, shared by the Hub settings panel and diagnostics. */
46
+ export const AGY_AUTH_LABELS = {
47
+ apiKey: "Gemini API key",
48
+ oauth: "OAuth (account sign-in)",
49
+ adc: "ADC (Vertex)",
50
+ };
51
+ /**
52
+ * The CLI's own app-data directory, hard-coded under the USER's home — the
53
+ * native Antigravity config we deliberately share with the TUI.
54
+ *
55
+ * @param realHome - the user's real `$HOME` (never an isolated override).
56
+ * @returns the absolute app-data directory.
57
+ */
58
+ export function nativeCliDir(realHome) {
59
+ return join(realHome, ".gemini", "antigravity-cli");
60
+ }
61
+ /**
62
+ * The CLI's settings file. The binary documents the auth flip here: "To switch
63
+ * back to signing in, remove `modelProvider` from settings.json and restart
64
+ * the CLI."
65
+ *
66
+ * @param realHome - the user's real `$HOME`.
67
+ * @returns the absolute settings.json path.
68
+ */
69
+ export function nativeSettingsPath(realHome) {
70
+ return join(nativeCliDir(realHome), "settings.json");
71
+ }
72
+ /**
73
+ * The credential file the CLI writes when a Google account signs in. This is
74
+ * the **Agent Platform** plane: `auth_method: "gcp"`, a `project_id`, and an
75
+ * access/refresh token pair. It is the backend the interactive TUI uses.
76
+ *
77
+ * @param realHome - the user's real `$HOME`.
78
+ * @returns the absolute path of the CLI's stored sign-in credential.
79
+ */
80
+ export function signinTokenPath(realHome) {
81
+ return join(nativeCliDir(realHome), "antigravity-oauth-token");
82
+ }
83
+ /**
84
+ * Is the CLI's own Google sign-in in place?
85
+ *
86
+ * Measured 2026-10-02 (this machine): headless CLI reads this plane first, and
87
+ * when it is present the transport works with NO Gemini API key, NO
88
+ * `AGY_ADC_AUTH`, and NO `modelProvider` in settings — the run reaches
89
+ * `result.status: SUCCESS`.
90
+ *
91
+ * This is what the auth ladder's middle rung means in practice: not a
92
+ * placeholder, but "let the CLI use the account it is already signed in as".
93
+ * It therefore must be DETECTED rather than assumed absent: treating it as
94
+ * permanently unavailable is what pushed the ladder onto ADC, whose project
95
+ * has `cloudcode-pa` disabled, and the adapter could never start a turn.
96
+ *
97
+ * @param realHome - the user's real `$HOME`.
98
+ * @returns whether a non-empty sign-in credential is on disk.
99
+ */
100
+ export function hasSigninCredential(realHome) {
101
+ try {
102
+ return statSync(signinTokenPath(realHome)).size > 0;
103
+ }
104
+ catch {
105
+ return false;
106
+ }
107
+ }
108
+ /**
109
+ * The settings.json change one form needs.
110
+ *
111
+ * Key mode pins the Gemini provider. ADC and OAuth need the DEFAULT backend, so
112
+ * `modelProvider` must be actively REMOVED — merely not setting it would leave
113
+ * a previously selected key mode in force and the TUI stuck on "Gemini API key"
114
+ * with no key exported.
115
+ *
116
+ * @param mode - the effective form.
117
+ * @returns the mutation to apply.
118
+ */
119
+ export function authSettingsMutation(mode) {
120
+ return mode === "apiKey"
121
+ ? { set: { modelProvider: "gemini" }, remove: [] }
122
+ : { set: {}, remove: ["modelProvider"] };
123
+ }
124
+ /**
125
+ * Is this mode usable at all right now?
126
+ *
127
+ * @param availability - probe result.
128
+ * @param mode - the form to test.
129
+ * @returns whether the form is present.
130
+ */
131
+ export function authAvailable(availability, mode) {
132
+ return availability[mode];
133
+ }
134
+ /**
135
+ * Resolve the effective mode: an explicit selection wins when that form is
136
+ * actually present; otherwise the ladder supplies the first available form.
137
+ * Nothing present ⇒ `undefined` (the caller gates into onboarding).
138
+ *
139
+ * A stale selection (user picked API key, key later removed) deliberately
140
+ * falls through to the ladder instead of failing — the adapter must not wedge
141
+ * on config that no longer matches the machine.
142
+ *
143
+ * @param availability - probe result.
144
+ * @param selected - the user's persisted choice, when any.
145
+ * @returns the effective form, or `undefined` when nothing is available.
146
+ */
147
+ export function resolveAuthMode(availability, selected) {
148
+ if (selected !== undefined && authAvailable(availability, selected))
149
+ return selected;
150
+ return AGY_AUTH_ORDER.find((mode) => authAvailable(availability, mode));
151
+ }
152
+ /**
153
+ * The environment additions the spawned CLI needs for one mode.
154
+ *
155
+ * `AGY_CLI_DISABLE_AUTO_UPDATE=1` rides every mode: the CLI silently
156
+ * self-updated 1.2.12 → 1.2.14 on this machine on 2026-10-02, which makes any
157
+ * acceptance run unreproducible.
158
+ *
159
+ * NOTE there is no HOME handling here at all: the adapter runs the CLI against
160
+ * the user's REAL home in every mode. Isolating HOME (the previous design) both
161
+ * hid the very settings.json we now maintain and silently destroyed ADC
162
+ * (`$HOME/.config/gcloud`) and the keyring — which is how this adapter
163
+ * previously mis-concluded "the CLI cannot use ADC".
164
+ *
165
+ * @param mode - the effective form.
166
+ * @param apiKey - the resolved key (env or adapter state); empty ⇒ omitted.
167
+ * @returns env entries to ADD to the child's environment.
168
+ */
169
+ export function authChildEnv(mode, apiKey) {
170
+ const env = { AGY_CLI_DISABLE_AUTO_UPDATE: "1" };
171
+ if (mode === "adc") {
172
+ env.AGY_ADC_AUTH = "1";
173
+ return env;
174
+ }
175
+ if (mode === "apiKey" && apiKey !== undefined && apiKey !== "") {
176
+ env.GEMINI_API_KEY = apiKey;
177
+ }
178
+ return env;
179
+ }
@@ -15,6 +15,7 @@
15
15
  *
16
16
  * Same surface as AgyBridgeClient so AgyAgent needs no changes.
17
17
  */
18
+ import { type AgyAuthMode, type AgySettingsMutation } from "./agy-auth.js";
18
19
  export interface AgyCliOptions {
19
20
  /** Key or a resolver (onboarding-saved keys become visible at first spawn). */
20
21
  apiKey: string | (() => string | undefined);
@@ -34,14 +35,18 @@ export interface AgyCliOptions {
34
35
  skipPermissions?: boolean;
35
36
  /** agy binary override (tests point at a mock). */
36
37
  agyBin?: string;
37
- /** Native CLI settings dir override (tests; prod: ~/.gemini). */
38
- nativeCliHome?: string;
39
38
  /**
40
- * HOME override for the spawned agy. The account-OAuth/gcp token in the
41
- * real home triggers the region-eligibility gate; an isolated home with
42
- * only settings.json + GEMINI_API_KEY runs the pure API-key path.
39
+ * The USER's real home. The CLI always runs against it (never an isolated
40
+ * override), and this is where the native Antigravity settings we maintain
41
+ * live — see the module header for the 2026-10-02 「拥抱用户自己的使用环境」
42
+ * ruling.
43
43
  */
44
- home?: string;
44
+ realHome?: string;
45
+ /**
46
+ * The resolved auth form (agy-auth.ts). Absent defaults to `apiKey`, so an
47
+ * unconfigured machine still reaches the §17 onboarding path.
48
+ */
49
+ authMode?: AgyAuthMode;
45
50
  spawnAttempts?: number;
46
51
  trace?: (...parts: unknown[]) => void;
47
52
  }
@@ -81,8 +86,21 @@ export type CliEvent = {
81
86
  error: string;
82
87
  recoverable: boolean;
83
88
  };
84
- /** Merge `modelProvider: "gemini"` into the CLI's own settings (single key). */
85
- export declare function ensureCliKeyMode(nativeCliHome: string): void;
89
+ /**
90
+ * Apply one auth form's mutation to the user's LOCAL Antigravity settings.
91
+ *
92
+ * user ruling 2026-10-02 (「拥抱用户自己的使用环境」): this adapter is
93
+ * deliberately the configuration surface for the user's own Antigravity, so it
94
+ * really does rewrite their `~/.gemini/antigravity-cli/settings.json` — pick
95
+ * Gemini API key here and their TUI runs on the Gemini API key too; pick ADC or
96
+ * OAuth and the `modelProvider` pin is REMOVED so the TUI falls back to the
97
+ * default backend. Idempotent, and a no-op when the file already matches.
98
+ *
99
+ * @param realHome - the user's real `$HOME` (never an isolated override).
100
+ * @param mutation - keys to set and keys to remove.
101
+ * @returns `true` when the file changed on disk.
102
+ */
103
+ export declare function applyAgySettings(realHome: string, mutation: AgySettingsMutation): boolean;
86
104
  export declare class AgyCliClient {
87
105
  private child?;
88
106
  private buffer;
@@ -121,8 +139,20 @@ export declare class AgyCliClient {
121
139
  total_tokens: number;
122
140
  } | undefined;
123
141
  private lastUsageValue;
124
- private nativeCliHome;
142
+ /** The user's real home (the CLI and the settings we maintain both live here). */
143
+ private realHome;
125
144
  private spawnCli;
145
+ /**
146
+ * Bounded tail of what the CLI said OUTSIDE its structured stream: stderr,
147
+ * plus stdout lines that were not JSONL frames. The CLI announces refusals
148
+ * this way and then exits (or reports a failed result), so dropping these
149
+ * lines is what turns every failure into "unknown error".
150
+ */
151
+ private diagnostics;
152
+ /** Record one diagnostic line, keeping only a short tail. */
153
+ private noteDiagnostic;
154
+ /** Append the recorded CLI diagnostics to a failure message, once. */
155
+ private withDiagnostics;
126
156
  private consume;
127
157
  private consumeStep;
128
158
  private dispatch;
@@ -18,11 +18,23 @@
18
18
  import { spawn } from "node:child_process";
19
19
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
20
20
  import { join } from "node:path";
21
- /** Merge `modelProvider: "gemini"` into the CLI's own settings (single key). */
22
- export function ensureCliKeyMode(nativeCliHome) {
23
- const dir = join(nativeCliHome, "antigravity-cli");
24
- mkdirSync(dir, { recursive: true });
25
- const p = join(dir, "settings.json");
21
+ import { authChildEnv, authSettingsMutation, nativeSettingsPath, } from "./agy-auth.js";
22
+ /**
23
+ * Apply one auth form's mutation to the user's LOCAL Antigravity settings.
24
+ *
25
+ * user ruling 2026-10-02 (「拥抱用户自己的使用环境」): this adapter is
26
+ * deliberately the configuration surface for the user's own Antigravity, so it
27
+ * really does rewrite their `~/.gemini/antigravity-cli/settings.json` — pick
28
+ * Gemini API key here and their TUI runs on the Gemini API key too; pick ADC or
29
+ * OAuth and the `modelProvider` pin is REMOVED so the TUI falls back to the
30
+ * default backend. Idempotent, and a no-op when the file already matches.
31
+ *
32
+ * @param realHome - the user's real `$HOME` (never an isolated override).
33
+ * @param mutation - keys to set and keys to remove.
34
+ * @returns `true` when the file changed on disk.
35
+ */
36
+ export function applyAgySettings(realHome, mutation) {
37
+ const p = nativeSettingsPath(realHome);
26
38
  let settings = {};
27
39
  if (existsSync(p)) {
28
40
  try {
@@ -32,10 +44,15 @@ export function ensureCliKeyMode(nativeCliHome) {
32
44
  settings = {};
33
45
  }
34
46
  }
35
- if (settings.modelProvider === "gemini")
36
- return;
37
- settings.modelProvider = "gemini";
47
+ const before = JSON.stringify(settings);
48
+ for (const key of mutation.remove)
49
+ delete settings[key];
50
+ Object.assign(settings, mutation.set);
51
+ if (JSON.stringify(settings) === before)
52
+ return false;
53
+ mkdirSync(join(p, ".."), { recursive: true });
38
54
  writeFileSync(p, JSON.stringify(settings, null, 2) + "\n");
55
+ return true;
39
56
  }
40
57
  export class AgyCliClient {
41
58
  child;
@@ -66,13 +83,21 @@ export class AgyCliClient {
66
83
  return this.lastUsageValue;
67
84
  }
68
85
  lastUsageValue;
69
- nativeCliHome() {
70
- return this.opts.nativeCliHome ?? join(process.env.HOME ?? "", ".gemini");
86
+ /** The user's real home (the CLI and the settings we maintain both live here). */
87
+ realHome() {
88
+ return this.opts.realHome ?? process.env.HOME ?? "";
71
89
  }
72
90
  spawnCli() {
73
91
  if (this.child || this.dead)
74
92
  return;
75
- ensureCliKeyMode(this.nativeCliHome());
93
+ const mode = this.opts.authMode ?? "apiKey";
94
+ // Only key mode patches settings (`modelProvider: "gemini"`); ADC and OAuth
95
+ // need the DEFAULT backend, where that key must be ABSENT — the binary
96
+ // documents the flip: "To switch back to signing in, remove modelProvider
97
+ // from settings.json and restart the CLI". Per the 2026-10-02 ruling this
98
+ // lands in the USER's real native settings, so their TUI behaves the same
99
+ // way afterwards (「拥抱用户自己的使用环境」).
100
+ applyAgySettings(this.realHome(), authSettingsMutation(mode));
76
101
  const attempts = this.opts.spawnAttempts ?? 3;
77
102
  const agyBin = this.opts.agyBin ?? "agy";
78
103
  // Order matters: --print swallows the next token as a prompt value
@@ -96,11 +121,16 @@ export class AgyCliClient {
96
121
  for (let attempt = 1; attempt <= attempts; attempt++) {
97
122
  try {
98
123
  const key = typeof this.opts.apiKey === "function" ? this.opts.apiKey() : this.opts.apiKey;
99
- if (!key)
124
+ if (mode === "apiKey" && !key)
100
125
  throw new Error("agy cli: no GEMINI_API_KEY resolved");
101
- const env = { ...process.env, GEMINI_API_KEY: key, NO_PROXY: "127.0.0.1,localhost" };
102
- if (this.opts.home)
103
- env.HOME = this.opts.home;
126
+ // The auth ladder rides the child env (agy-auth.ts): AGY_ADC_AUTH for
127
+ // ADC, the key for key mode, and the auto-update pin on EVERY mode.
128
+ // NO_PROXY keeps the dev3 loopback bridge reachable.
129
+ const env = { ...process.env, NO_PROXY: "127.0.0.1,localhost", ...authChildEnv(mode, key) };
130
+ // No HOME override, ever: the settings we just maintained live at
131
+ // `$HOME/.gemini`, ADC at `$HOME/.config/gcloud`, and the sign-in token
132
+ // in the keyring — isolating HOME destroys all three. That was the
133
+ // 2026-10-02 bug behind "the CLI cannot use ADC".
104
134
  if (this.opts.proxy) {
105
135
  env.HTTPS_PROXY = this.opts.proxy;
106
136
  env.HTTPS_PROXY = this.opts.proxy;
@@ -119,12 +149,45 @@ export class AgyCliClient {
119
149
  child.stdout.setEncoding("utf8");
120
150
  child.stdout.on("data", (d) => this.consume(d));
121
151
  child.stderr.setEncoding("utf8");
122
- child.stderr.on("data", (d) => this.opts.trace?.("[agy stderr]", d.trimEnd()));
152
+ child.stderr.on("data", (d) => {
153
+ this.opts.trace?.("[agy stderr]", d.trimEnd());
154
+ this.noteDiagnostic(d);
155
+ });
123
156
  child.on("exit", (code) => {
124
157
  this.child = undefined;
125
- this.dispatch({ event: "error", error: `agy exited code=${code}`, recoverable: !this.dead });
158
+ // The CLI reports its refusals on stderr / as non-JSON stdout lines and
159
+ // then exits non-zero. Those lines ARE the diagnosis ("--effort is not
160
+ // supported for model …", "Eligibility check failed: …"), so the exit
161
+ // error carries them: an opaque "exited code=1" leaves the user with a
162
+ // dead turn and nothing to act on.
163
+ this.dispatch({ event: "error", error: this.withDiagnostics(`agy exited code=${code}`), recoverable: !this.dead });
126
164
  });
127
165
  }
166
+ /**
167
+ * Bounded tail of what the CLI said OUTSIDE its structured stream: stderr,
168
+ * plus stdout lines that were not JSONL frames. The CLI announces refusals
169
+ * this way and then exits (or reports a failed result), so dropping these
170
+ * lines is what turns every failure into "unknown error".
171
+ */
172
+ diagnostics = [];
173
+ /** Record one diagnostic line, keeping only a short tail. */
174
+ noteDiagnostic(chunk) {
175
+ for (const raw of chunk.split("\n")) {
176
+ const line = raw.trim();
177
+ if (line === "")
178
+ continue;
179
+ this.diagnostics.push(line);
180
+ }
181
+ // A chatty child must not grow this without bound mid-turn.
182
+ if (this.diagnostics.length > 12)
183
+ this.diagnostics = this.diagnostics.slice(-12);
184
+ }
185
+ /** Append the recorded CLI diagnostics to a failure message, once. */
186
+ withDiagnostics(message) {
187
+ const tail = this.diagnostics.join(" | ");
188
+ this.diagnostics = [];
189
+ return tail === "" ? message : `${message}: ${tail}`;
190
+ }
128
191
  consume(data) {
129
192
  this.buffer += data;
130
193
  let idx;
@@ -138,6 +201,7 @@ export class AgyCliClient {
138
201
  parsed = JSON.parse(line);
139
202
  }
140
203
  catch (err) {
204
+ this.noteDiagnostic(line);
141
205
  this.opts.trace?.("bad agy json:", line.slice(0, 120), err);
142
206
  continue;
143
207
  }
@@ -154,7 +218,7 @@ export class AgyCliClient {
154
218
  if (r?.conversation_id)
155
219
  this.conversationIdValue = r.conversation_id;
156
220
  if (r?.status !== "SUCCESS") {
157
- this.dispatch({ event: "error", error: r?.error ?? `agy result status=${r?.status}`, recoverable: false });
221
+ this.dispatch({ event: "error", error: this.withDiagnostics(r?.error ?? `agy result status=${r?.status}`), recoverable: false });
158
222
  }
159
223
  else {
160
224
  this.dispatch({ event: "done", conversation_id: this.conversationIdValue, turn_ms: 0 });
@@ -9,11 +9,19 @@
9
9
  * injectable so tests use fixtures instead of env knobs (prod path has no
10
10
  * redirection).
11
11
  */
12
+ import type { AgyAuthMode } from "./agy-auth.js";
12
13
  export interface AgyAdapterState {
13
14
  /** Gemini API key the user pasted through the onboarding session. */
14
15
  apiKey?: string;
15
16
  /** Cached default model slug (from native settings or catalog head). */
16
17
  defaultModel?: string;
18
+ /**
19
+ * The user's explicit auth-form choice for the CLI transport (the Hub's
20
+ * single-select). Absent ⇒ the agy-auth ladder decides. A stale choice (the
21
+ * form is gone from the machine) deliberately falls through to the ladder
22
+ * rather than wedging the adapter.
23
+ */
24
+ authMode?: AgyAuthMode;
17
25
  }
18
26
  export declare function adapterStatePath(worldHome: string): string;
19
27
  export declare function readAdapterState(worldHome: string): AgyAdapterState;
@@ -1,25 +1,43 @@
1
+ /**
2
+ * agent-agy provider — Google Antigravity provider plugin for DeepSeek Harness
3
+ * (Super D, consumer-first line, 2026-09-18).
4
+ *
5
+ * An `AgentFactory` that drives an `AgyCliClient` — the user's OWN Antigravity
6
+ * CLI in headless stream-json mode. 2026-10-02 ruling 「拥抱用户自己的使用环境」:
7
+ * the adapter shares the user's real `~/.gemini` (native settings.json), their
8
+ * ADC (`~/.config/gcloud`), and their keyring, instead of isolating a HOME the
9
+ * CLI never had. The SDK/bridge transport lives in its own opt-in package,
10
+ * `@pgmi-builds/agent-agy-sdk`.
11
+ *
12
+ * Session identity ("mapping only"): the DSH session id is the authority,
13
+ * supplied by the harness. The CLI conversation id materializes after the
14
+ * first turn, so the pairing is persisted in `<worldHome>/dsh-sessions.json`
15
+ * (agy-sessions.ts). Resume resolves that record and fails CLOSED
16
+ * (CONVERSATION_NOT_FOUND) when no conversation is recorded. The DSH session
17
+ * log is the transcript authority, written through the upstream
18
+ * `sessionPersistence` service (hermes create/resume transaction shape).
19
+ */
1
20
  import { Context, Service } from "@deepseek-ai/cordis";
2
21
  import type { AgentFactory, AgentHandle, CreateAgentOptions, ResumeAgentOptions } from "@deepseek-ai/dsh-agent";
3
22
  /** Test/override knobs for the bridge child (prod: all unset). */
4
23
  export interface AgyProviderOptions {
5
- bridgePath?: string;
6
- pythonBin?: string;
7
24
  spawnAttempts?: number;
8
25
  /** Native home override for tests (prod: ~/.gemini, read-only). */
9
26
  nativeHome?: string;
10
- /** Vertex project/location override (ADC mode). Default: gcloud CLI config. */
11
- project?: string;
12
- location?: string;
13
- /** Tool-approval posture surfaced to every session's bridge start frame. */
14
- approvalMode?: "allow" | "ask";
15
27
  /** danger-full-access → CLI --dangerously-skip-permissions (default: true, patch default preset). */
16
28
  skipPermissions?: boolean;
17
29
  /** agy binary override (CLI path tests). */
18
30
  agyBin?: string;
19
31
  /** Forward proxy for the geo-fenced Gemini API (CLI path; dev3 gost). */
20
32
  proxy?: string;
21
- /** HOME override for the CLI child (isolated key-mode home; dev knob). */
22
- cliHome?: string;
33
+ /**
34
+ * The USER's real home (default `$HOME`). The CLI always runs against it —
35
+ * 2026-10-02 ruling: the adapter shares the user's own Antigravity
36
+ * configuration (settings.json, ADC, keyring) instead of isolating it. The
37
+ * old isolated-HOME knob was removed with that ruling: it both hid the
38
+ * settings.json we maintain and silently destroyed ADC + the keyring.
39
+ */
40
+ realHome?: string;
23
41
  }
24
42
  export declare class AgyProvider extends Service implements AgentFactory {
25
43
  static inject: string[];
@@ -30,6 +48,8 @@ export declare class AgyProvider extends Service implements AgentFactory {
30
48
  private readonly opts;
31
49
  private defaultModelKey;
32
50
  constructor(ctx: Context, opts?: AgyProviderOptions);
51
+ /** Which auth forms are present on this machine right now (probe, not choice). */
52
+ private authAvailability;
33
53
  /** The world's DSH home: boot-provided dshHomePath first, env last. */
34
54
  private resolveHome;
35
55
  /** Effective Gemini API key: adapter state first, then the environment. */
@@ -46,7 +66,7 @@ export declare class AgyProvider extends Service implements AgentFactory {
46
66
  private resolveDefaultModel;
47
67
  /** Static route: provider `agy` + the resolved default (or the explicit ask).
48
68
  * The selected model id (`slug` or `slug@level`) rides in `options.model`
49
- * so clientOptions can forward slug+thinkingLevel to the bridge start frame. */
69
+ * so cliOptions can forward slug+thinkingLevel to the CLI child. */
50
70
  private sessionAgentOptions;
51
71
  private requirePersistence;
52
72
  private agentRuntime;
@@ -58,12 +78,24 @@ export declare class AgyProvider extends Service implements AgentFactory {
58
78
  createAgent(ownerCtx: Context, options: CreateAgentOptions): Promise<AgentHandle>;
59
79
  resume(ownerCtx: Context, options: ResumeAgentOptions): Promise<AgentHandle>;
60
80
  /**
61
- * Live transport routing (2026-09-18 user ruling): gemini-api-key > oauth >
62
- * adc. Key present → CLI stream (richest surface). ADC-only → SDK bridge.
63
- * Neither → CLI as well (auth fails at first prompt; the §17 onboarding
64
- * branch answers locally before any spawn).
81
+ * Live transport: CLI-ONLY (2026-10-02 user ruling).
82
+ *
83
+ * The SDK/bridge route moved to its own package
84
+ * (`@pgmi-builds/agent-agy-sdk`, delivered disabled by default): the product
85
+ * case is that the user ALREADY runs Antigravity, so the CLI reuses that
86
+ * environment for free while the SDK is an opt-in extra. Auth-form selection
87
+ * still rides the agy-auth ladder.
65
88
  */
66
89
  private createLiveClient;
90
+ /**
91
+ * The auth form this machine should use: an explicitly selected, actually
92
+ * available form wins; otherwise the ladder Gemini API key → OAuth → ADC
93
+ * (user ruling 2026-10-02). OAuth is a placeholder this round — no eligible
94
+ * account exists to characterise which native fields a real sign-in stores —
95
+ * so nothing reports it present and it can never win. Falls back to `apiKey`
96
+ * so an unconfigured machine still reaches the §17 onboarding path.
97
+ */
98
+ private effectiveAuthMode;
67
99
  /**
68
100
  * The effective permission preset this provider was mounted with. The
69
101
  * cordis.patch.yml default is danger-full-access; a patch-level override
@@ -73,8 +105,6 @@ export declare class AgyProvider extends Service implements AgentFactory {
73
105
  private currentPermissionPreset;
74
106
  /** CLI transport options: key-first default is the cheapest live pair. */
75
107
  private cliOptions;
76
- /** Bridge child options: world cwd + overrides; the api key rides the start config. */
77
- private clientOptions;
78
108
  private createStoredSession;
79
109
  }
80
110
  export default AgyProvider;