super-dsh 0.1.6 → 0.1.10-e

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 (260) 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-claude/dist/adapter.js +106 -31
  41. package/agent-claude/dist/agent.js +154 -17
  42. package/agent-claude/dist/claude-client.js +84 -43
  43. package/agent-claude/dist/claude-launch.js +101 -0
  44. package/agent-claude/dist/claude-native-config.js +169 -0
  45. package/agent-claude/dist/claude-provider-gateway.js +340 -0
  46. package/agent-claude/dist/claude-providers.js +391 -0
  47. package/agent-claude/dist/claude-route.js +152 -0
  48. package/agent-claude/dist/index.js +214 -37
  49. package/agent-claude/dist/models.js +14 -0
  50. package/agent-claude/dist/sdk-runtime.js +320 -0
  51. package/agent-claude/package.json +6 -4
  52. package/agent-codex/README.md +141 -36
  53. package/agent-codex/cordis.patch.yml +14 -10
  54. package/agent-codex/dist/adapter.js +64 -28
  55. package/agent-codex/dist/agent.js +255 -81
  56. package/agent-codex/dist/app-server-approvals.js +165 -0
  57. package/agent-codex/dist/app-server-client.js +723 -0
  58. package/agent-codex/dist/app-server-events.js +432 -0
  59. package/agent-codex/dist/app-server-protocol.js +95 -0
  60. package/agent-codex/dist/app-server-wire.js +299 -0
  61. package/agent-codex/dist/codex-launch.js +78 -0
  62. package/agent-codex/dist/codex-native-config.js +392 -0
  63. package/agent-codex/dist/codex-provider-gateway.js +402 -0
  64. package/agent-codex/dist/codex-providers.js +376 -0
  65. package/agent-codex/dist/codex-route.js +86 -0
  66. package/agent-codex/dist/index.js +256 -115
  67. package/agent-codex/dist/permission.js +75 -1
  68. package/agent-codex/package.json +1 -2
  69. package/agent-codex-sdk/README.md +79 -0
  70. package/agent-codex-sdk/cordis.patch.yml +81 -0
  71. package/agent-codex-sdk/dist/adapter.js +91 -0
  72. package/agent-codex-sdk/dist/agent-preset-codex.js +32 -0
  73. package/agent-codex-sdk/dist/agent.js +1085 -0
  74. package/agent-codex-sdk/dist/codex-native-config.js +392 -0
  75. package/agent-codex-sdk/dist/codex-provider-gateway.js +402 -0
  76. package/agent-codex-sdk/dist/codex-providers.js +376 -0
  77. package/agent-codex-sdk/dist/codex-route.js +86 -0
  78. package/{agent-codex/dist/codex-client.js → agent-codex-sdk/dist/codex-sdk-client.js} +253 -32
  79. package/agent-codex-sdk/dist/codex-sdk-launch.js +92 -0
  80. package/agent-codex-sdk/dist/codex-store.js +180 -0
  81. package/agent-codex-sdk/dist/inbox.js +53 -0
  82. package/agent-codex-sdk/dist/index.js +739 -0
  83. package/agent-codex-sdk/dist/permission.js +71 -0
  84. package/agent-codex-sdk/dist/sdk-runtime.js +307 -0
  85. package/agent-codex-sdk/dist/session-map.js +167 -0
  86. package/agent-codex-sdk/dist/world-plugin.js +93 -0
  87. package/agent-codex-sdk/package.json +79 -0
  88. package/agent-codex-sdk/scripts/fetch-sdk-runtime.mjs +57 -0
  89. package/agent-omp/README.md +72 -55
  90. package/agent-omp/dist/agent.js +36 -11
  91. package/agent-omp/dist/index.js +92 -52
  92. package/agent-omp/dist/lazy-rpc.js +11 -4
  93. package/agent-omp/dist/omp-cli.js +114 -97
  94. package/agent-omp/dist/omp-store.js +12 -4
  95. package/agent-omp/dist/permission.js +70 -5
  96. package/agent-omp/dist/rpc-client.js +409 -0
  97. package/agent-omp/dist/world-plugin.js +36 -3
  98. package/agent-omp/package.json +2 -6
  99. package/agent-omp-sdk/README.md +103 -0
  100. package/agent-omp-sdk/cordis.patch.yml +108 -0
  101. package/agent-omp-sdk/dist/adapter.d.ts +21 -0
  102. package/agent-omp-sdk/dist/adapter.js +36 -0
  103. package/agent-omp-sdk/dist/agent-preset-omp.d.ts +31 -0
  104. package/agent-omp-sdk/dist/agent-preset-omp.js +32 -0
  105. package/agent-omp-sdk/dist/agent.d.ts +64 -0
  106. package/agent-omp-sdk/dist/agent.js +1178 -0
  107. package/agent-omp-sdk/dist/discovery.d.ts +57 -0
  108. package/agent-omp-sdk/dist/discovery.js +116 -0
  109. package/agent-omp-sdk/dist/inbox.d.ts +28 -0
  110. package/agent-omp-sdk/dist/inbox.js +53 -0
  111. package/agent-omp-sdk/dist/index.d.ts +60 -0
  112. package/agent-omp-sdk/dist/index.js +632 -0
  113. package/agent-omp-sdk/dist/knobs.d.ts +34 -0
  114. package/agent-omp-sdk/dist/knobs.js +50 -0
  115. package/agent-omp-sdk/dist/lazy-rpc.d.ts +98 -0
  116. package/agent-omp-sdk/dist/lazy-rpc.js +178 -0
  117. package/agent-omp-sdk/dist/mobile/zoom-guard.d.ts +187 -0
  118. package/agent-omp-sdk/dist/mobile/zoom-guard.js +294 -0
  119. package/agent-omp-sdk/dist/mobile-boot.d.ts +49 -0
  120. package/agent-omp-sdk/dist/mobile-boot.js +38 -0
  121. package/agent-omp-sdk/dist/models.d.ts +39 -0
  122. package/agent-omp-sdk/dist/models.js +299 -0
  123. package/agent-omp-sdk/dist/omp-cli.d.ts +67 -0
  124. package/agent-omp-sdk/dist/omp-cli.js +164 -0
  125. package/agent-omp-sdk/dist/omp-disk-discovery.d.ts +27 -0
  126. package/agent-omp-sdk/dist/omp-disk-discovery.js +178 -0
  127. package/agent-omp-sdk/dist/omp-executable.d.ts +2 -0
  128. package/agent-omp-sdk/dist/omp-executable.js +30 -0
  129. package/agent-omp-sdk/dist/omp-store.d.ts +134 -0
  130. package/agent-omp-sdk/dist/omp-store.js +526 -0
  131. package/agent-omp-sdk/dist/pairing.d.ts +7 -0
  132. package/agent-omp-sdk/dist/pairing.js +45 -0
  133. package/agent-omp-sdk/dist/permission.d.ts +138 -0
  134. package/agent-omp-sdk/dist/permission.js +161 -0
  135. package/agent-omp-sdk/dist/protocol.d.ts +189 -0
  136. package/agent-omp-sdk/dist/rpc-types.d.ts +77 -0
  137. package/agent-omp-sdk/dist/rpc-types.js +1 -0
  138. package/agent-omp-sdk/dist/sdk-client.d.ts +160 -0
  139. package/{agent-omp → agent-omp-sdk}/dist/sdk-client.js +108 -56
  140. package/agent-omp-sdk/dist/sdk-runtime.d.ts +211 -0
  141. package/agent-omp-sdk/dist/sdk-runtime.js +418 -0
  142. package/agent-omp-sdk/dist/sidecar-client.d.ts +87 -0
  143. package/agent-omp-sdk/dist/sidecar-client.js +197 -0
  144. package/agent-omp-sdk/dist/store/adapter.d.ts +17 -0
  145. package/agent-omp-sdk/dist/store/adapter.js +47 -0
  146. package/agent-omp-sdk/dist/store/db.d.ts +70 -0
  147. package/agent-omp-sdk/dist/store/db.js +210 -0
  148. package/agent-omp-sdk/dist/store/index.d.ts +23 -0
  149. package/agent-omp-sdk/dist/store/index.js +59 -0
  150. package/agent-omp-sdk/dist/store/reconcile.d.ts +15 -0
  151. package/agent-omp-sdk/dist/store/reconcile.js +51 -0
  152. package/agent-omp-sdk/dist/store/schema.d.ts +8 -0
  153. package/agent-omp-sdk/dist/store/schema.js +40 -0
  154. package/agent-omp-sdk/dist/transport.d.ts +49 -0
  155. package/agent-omp-sdk/dist/transport.js +35 -0
  156. package/agent-omp-sdk/dist/world-home.d.ts +4 -0
  157. package/agent-omp-sdk/dist/world-home.js +23 -0
  158. package/agent-omp-sdk/dist/world-plugin.d.ts +10 -0
  159. package/agent-omp-sdk/dist/world-plugin.js +137 -0
  160. package/agent-omp-sdk/package.json +87 -0
  161. package/client/index.js +1883 -287
  162. package/cordis.patch.yml +80 -0
  163. package/package.json +23 -9
  164. package/superd-hub/dist/a2a-delivery.d.ts +189 -0
  165. package/superd-hub/dist/a2a-delivery.js +240 -0
  166. package/superd-hub/dist/a2a-host.d.ts +76 -0
  167. package/superd-hub/dist/a2a-host.js +145 -0
  168. package/superd-hub/dist/a2a-ingest.d.ts +31 -0
  169. package/superd-hub/dist/a2a-ingest.js +636 -0
  170. package/superd-hub/dist/a2a-log.d.ts +17 -0
  171. package/superd-hub/dist/a2a-log.js +42 -0
  172. package/superd-hub/dist/a2a-row.d.ts +65 -0
  173. package/superd-hub/dist/a2a-row.js +162 -0
  174. package/superd-hub/dist/a2a-service.d.ts +357 -0
  175. package/superd-hub/dist/a2a-service.js +980 -0
  176. package/superd-hub/dist/a2a-wire.d.ts +220 -0
  177. package/superd-hub/dist/a2a-wire.js +305 -0
  178. package/superd-hub/dist/agent-ids.d.ts +10 -0
  179. package/superd-hub/dist/agent-ids.js +68 -0
  180. package/superd-hub/dist/agent-roster.d.ts +29 -18
  181. package/superd-hub/dist/agent-roster.js +54 -15
  182. package/superd-hub/dist/agent-status.d.ts +119 -0
  183. package/superd-hub/dist/agent-status.js +386 -0
  184. package/superd-hub/dist/client/agent-settings.d.ts +210 -0
  185. package/superd-hub/dist/client/agent-settings.js +300 -0
  186. package/superd-hub/dist/client/mesh-api.d.ts +134 -0
  187. package/superd-hub/dist/client/mesh-api.js +219 -0
  188. package/superd-hub/dist/client/mesh-groups.d.ts +63 -0
  189. package/superd-hub/dist/client/mesh-groups.js +66 -0
  190. package/superd-hub/dist/client/roster.d.ts +48 -0
  191. package/superd-hub/dist/client/roster.js +102 -0
  192. package/superd-hub/dist/client/runtime-settings-api.d.ts +76 -0
  193. package/superd-hub/dist/client/runtime-settings-api.js +137 -0
  194. package/superd-hub/dist/client/switch.d.ts +165 -0
  195. package/superd-hub/dist/client/switch.js +295 -0
  196. package/superd-hub/dist/exec-pty-channel.d.ts +58 -0
  197. package/superd-hub/dist/exec-pty-channel.js +162 -0
  198. package/superd-hub/dist/exec-pty-framing.d.ts +32 -0
  199. package/superd-hub/dist/exec-pty-framing.js +81 -0
  200. package/superd-hub/dist/exec-pty-rpc.d.ts +21 -0
  201. package/superd-hub/dist/exec-pty-rpc.js +128 -0
  202. package/superd-hub/dist/exec-pty-session.d.ts +76 -0
  203. package/superd-hub/dist/exec-pty-session.js +234 -0
  204. package/superd-hub/dist/exec.d.ts +56 -0
  205. package/superd-hub/dist/exec.js +225 -0
  206. package/superd-hub/dist/gateway.d.ts +39 -2
  207. package/superd-hub/dist/gateway.js +62 -3
  208. package/superd-hub/dist/hub-tool.d.ts +174 -0
  209. package/superd-hub/dist/hub-tool.js +464 -0
  210. package/superd-hub/dist/index.d.ts +15 -1
  211. package/superd-hub/dist/index.js +16 -0
  212. package/superd-hub/dist/machines.d.ts +45 -0
  213. package/superd-hub/dist/machines.js +125 -0
  214. package/superd-hub/dist/mesh-federate.d.ts +138 -0
  215. package/superd-hub/dist/mesh-federate.js +223 -0
  216. package/superd-hub/dist/mesh-gateway.d.ts +67 -0
  217. package/superd-hub/dist/mesh-gateway.js +408 -0
  218. package/superd-hub/dist/mesh-link.d.ts +274 -0
  219. package/superd-hub/dist/mesh-link.js +441 -0
  220. package/superd-hub/dist/mesh-rpc.d.ts +123 -0
  221. package/superd-hub/dist/mesh-rpc.js +250 -0
  222. package/superd-hub/dist/mux-client.d.ts +71 -0
  223. package/superd-hub/dist/mux-client.js +281 -0
  224. package/superd-hub/dist/pack-version.d.ts +2 -0
  225. package/superd-hub/dist/pack-version.js +30 -0
  226. package/superd-hub/dist/roster.d.ts +6 -0
  227. package/superd-hub/dist/rpc.d.ts +18 -2
  228. package/superd-hub/dist/rpc.js +34 -4
  229. package/superd-hub/dist/spawn-world.js +3 -1
  230. package/superd-hub/dist/switch-core.d.ts +62 -25
  231. package/superd-hub/dist/switch-core.js +53 -30
  232. package/superd-hub/dist/system-head.d.ts +22 -12
  233. package/superd-hub/dist/system-head.js +100 -84
  234. package/superd-hub/dist/wire-endpoints.d.ts +264 -0
  235. package/superd-hub/dist/wire-endpoints.js +180 -0
  236. package/superd-hub/lib/client/index.js +1883 -287
  237. package/superd-hub/package.json +11 -2
  238. package/agent-agy/dist/agent-preset-projection.d.ts +0 -31
  239. package/agent-agy/dist/agent-preset-projection.js +0 -33
  240. package/agent-claude/dist/agent-preset-projection.js +0 -30
  241. package/agent-codex/dist/agent-preset-projection.js +0 -37
  242. package/agent-codex/dist/app-home.js +0 -65
  243. package/agent-codex/dist/models.js +0 -152
  244. package/agent-codex/dist/spike.js +0 -46
  245. package/agent-hermes/dist/agent-preset-projection.js +0 -34
  246. package/agent-omp/dist/agent-preset-projection.js +0 -36
  247. package/agent-omp/dist/app-home.js +0 -86
  248. package/agent-omp/dist/sidecar-client.js +0 -195
  249. package/agent-pi/dist/agent-preset-projection.js +0 -29
  250. package/superd-hub/dist/client-shim.d.ts +0 -28
  251. package/superd-hub/dist/client-shim.js +0 -251
  252. package/superd-hub/dist/index-pass.d.ts +0 -22
  253. package/superd-hub/dist/index-pass.js +0 -47
  254. package/superd-hub/dist/labels.d.ts +0 -45
  255. package/superd-hub/dist/labels.js +0 -83
  256. /package/{agent-agy → agent-agy-sdk}/bridge/agy_bridge.py +0 -0
  257. /package/{agent-agy → agent-agy-sdk}/bridge/gemini_openai_server.mjs +0 -0
  258. /package/{agent-codex/dist/codex-events.js → agent-codex-sdk/dist/codex-sdk-events.js} +0 -0
  259. /package/{agent-omp → agent-omp-sdk}/dist/protocol.js +0 -0
  260. /package/{agent-omp → agent-omp-sdk}/sidecar/main.ts +0 -0
@@ -5,6 +5,8 @@
5
5
  * Discipline (agent-adapter-dev-rules §14-i / §16a):
6
6
  * - LAZY: no python child until the first real prompt. `start` config is
7
7
  * buffered and flushed with the first `prompt` (one round trip).
8
+ * - LAZY VENV (2026-10-02 ruling): the durable Python venv is fetched on that
9
+ * same first use, into the world home — never at install time (sdk-venv.ts).
8
10
  * - Transient spawn failures retry in-place up to AGY_SPAWN_ATTEMPTS (3);
9
11
  * prompt-level errors are surfaced, never auto-retried.
10
12
  * - The agy CLI is never invoked; auth is transparent (api_key param or ADC
@@ -23,8 +25,17 @@ export interface AgyClientOptions {
23
25
  location?: string;
24
26
  workspaces?: string[];
25
27
  saveDir?: string;
26
- /** Python interpreter (test knob; prod resolves via PATH). */
28
+ /**
29
+ * Python interpreter override. Set → the durable venv is NOT fetched
30
+ * (tests point this at `process.execPath` for the mock bridge; an operator
31
+ * can point it at an interpreter that already has the SDK).
32
+ */
27
33
  pythonBin?: string;
34
+ /**
35
+ * World home anchoring the durable SDK venv (`<worldHome>/sdk-venv`). Absent
36
+ * ⇒ the venv root falls back to `$DSH_HOME/agents/agy-sdk`.
37
+ */
38
+ worldHome?: string;
28
39
  /** Bridge script override (tests point this at a mock). */
29
40
  bridgePath?: string;
30
41
  spawnAttempts?: number;
@@ -128,6 +139,8 @@ export declare class AgyBridgeClient {
128
139
  }) => void): void;
129
140
  private dead;
130
141
  private startedSent;
142
+ /** In-flight first-use bootstrap (venv fetch + spawn); cleared when it settles. */
143
+ private spawnPromise;
131
144
  private lastUsageValue;
132
145
  /** Per-turn token usage from the bridge (undefined when the bridge skipped it). */
133
146
  get lastUsage(): AgyTurnUsage | undefined;
@@ -137,9 +150,18 @@ export declare class AgyBridgeClient {
137
150
  constructor(opts?: AgyClientOptions);
138
151
  get conversationId(): string;
139
152
  private resolveBridgePath;
140
- /** Durable venv created by scripts/setup-venv.sh (pkg-root/.venv). */
141
- private resolvePackagedVenvPython;
142
- private spawnBridge;
153
+ /** The world home anchoring the durable venv (default `$DSH_HOME/agents/agy-sdk`). */
154
+ private worldHome;
155
+ /**
156
+ * Resolve the interpreter and spawn the child, once.
157
+ *
158
+ * Interpreter precedence: explicit `pythonBin` (tests / operator override) →
159
+ * `AGY_PYTHON` → the durable world-home venv, fetched on this first use.
160
+ * Concurrent first turns share one in-flight bootstrap.
161
+ */
162
+ private ensureChild;
163
+ private spawnOnce;
164
+ private spawnWith;
143
165
  private consume;
144
166
  private dispatch;
145
167
  private nextEvent;
@@ -156,5 +178,3 @@ export declare class AgyBridgeClient {
156
178
  turn(text: string): AsyncGenerator<string, string, void>;
157
179
  close(): Promise<void>;
158
180
  }
159
- /** Convenience: read the venv python path recorded by scripts/setup-venv.sh. */
160
- export declare function resolveVenvPython(worldHome: string): string | undefined;
@@ -5,15 +5,18 @@
5
5
  * Discipline (agent-adapter-dev-rules §14-i / §16a):
6
6
  * - LAZY: no python child until the first real prompt. `start` config is
7
7
  * buffered and flushed with the first `prompt` (one round trip).
8
+ * - LAZY VENV (2026-10-02 ruling): the durable Python venv is fetched on that
9
+ * same first use, into the world home — never at install time (sdk-venv.ts).
8
10
  * - Transient spawn failures retry in-place up to AGY_SPAWN_ATTEMPTS (3);
9
11
  * prompt-level errors are surfaced, never auto-retried.
10
12
  * - The agy CLI is never invoked; auth is transparent (api_key param or ADC
11
13
  * environment picked up by the SDK itself).
12
14
  */
13
15
  import { spawn } from "node:child_process";
14
- import { existsSync, readFileSync } from "node:fs";
16
+ import { existsSync } from "node:fs";
15
17
  import { dirname, join } from "node:path";
16
18
  import { fileURLToPath } from "node:url";
19
+ import { ensureSdkVenv, resolveSdkPython } from "./sdk-venv.js";
17
20
  const BRIDGE_RELATIVE = join("bridge", "agy_bridge.py");
18
21
  export class AgyBridgeClient {
19
22
  child;
@@ -30,6 +33,8 @@ export class AgyBridgeClient {
30
33
  setToolEventHandler(handler) { }
31
34
  dead = false;
32
35
  startedSent = false;
36
+ /** In-flight first-use bootstrap (venv fetch + spawn); cleared when it settles. */
37
+ spawnPromise;
33
38
  lastUsageValue = undefined;
34
39
  /** Per-turn token usage from the bridge (undefined when the bridge skipped it). */
35
40
  get lastUsage() {
@@ -59,25 +64,46 @@ export class AgyBridgeClient {
59
64
  }
60
65
  throw new Error(`agy bridge script not found (${BRIDGE_RELATIVE})`);
61
66
  }
62
- /** Durable venv created by scripts/setup-venv.sh (pkg-root/.venv). */
63
- resolvePackagedVenvPython() {
67
+ /** The world home anchoring the durable venv (default `$DSH_HOME/agents/agy-sdk`). */
68
+ worldHome() {
69
+ if (this.opts.worldHome)
70
+ return this.opts.worldHome;
71
+ const dshHome = process.env.DSH_HOME;
72
+ if (typeof dshHome === "string" && dshHome !== "")
73
+ return join(dshHome, "agents", "agy-sdk");
74
+ return join(process.env.HOME ?? "", ".dsh", "agents", "agy-sdk");
75
+ }
76
+ /**
77
+ * Resolve the interpreter and spawn the child, once.
78
+ *
79
+ * Interpreter precedence: explicit `pythonBin` (tests / operator override) →
80
+ * `AGY_PYTHON` → the durable world-home venv, fetched on this first use.
81
+ * Concurrent first turns share one in-flight bootstrap.
82
+ */
83
+ ensureChild() {
84
+ if (this.child || this.dead)
85
+ return Promise.resolve();
86
+ this.spawnPromise ??= this.spawnOnce();
87
+ return this.spawnPromise;
88
+ }
89
+ async spawnOnce() {
64
90
  try {
65
- const pkgRoot = join(dirname(this.resolveBridgePath()), "..");
66
- const venv = join(pkgRoot, ".venv", "bin", "python");
67
- return existsSync(venv) ? venv : undefined;
91
+ const worldHome = this.worldHome();
92
+ const pythonBin = this.opts.pythonBin
93
+ ?? process.env.AGY_PYTHON
94
+ ?? resolveSdkPython(worldHome)
95
+ ?? await ensureSdkVenv(worldHome, {
96
+ ...(this.opts.trace === undefined ? {} : { trace: this.opts.trace }),
97
+ });
98
+ if (!this.child && !this.dead)
99
+ this.spawnWith(pythonBin);
68
100
  }
69
- catch {
70
- return undefined;
101
+ finally {
102
+ this.spawnPromise = undefined;
71
103
  }
72
104
  }
73
- spawnBridge() {
74
- if (this.child || this.dead)
75
- return;
105
+ spawnWith(pythonBin) {
76
106
  const attempts = this.opts.spawnAttempts ?? 3;
77
- const pythonBin = this.opts.pythonBin
78
- ?? this.resolvePackagedVenvPython()
79
- ?? process.env.AGY_PYTHON
80
- ?? "python3";
81
107
  const bridgePath = this.resolveBridgePath();
82
108
  for (let attempt = 1; attempt <= attempts; attempt++) {
83
109
  try {
@@ -152,7 +178,7 @@ export class AgyBridgeClient {
152
178
  }
153
179
  /** Ping round trip (spawns the bridge if needed — use for liveness probes). */
154
180
  async ping() {
155
- this.spawnBridge();
181
+ await this.ensureChild();
156
182
  this.send({ op: "ping" });
157
183
  await this.expect("pong");
158
184
  }
@@ -162,7 +188,7 @@ export class AgyBridgeClient {
162
188
  * Yields streamed text chunks; resolves with the full turn text.
163
189
  */
164
190
  async *turn(text) {
165
- this.spawnBridge();
191
+ await this.ensureChild();
166
192
  if (!this.startedSent) {
167
193
  this.send({
168
194
  op: "start",
@@ -242,11 +268,3 @@ export class AgyBridgeClient {
242
268
  this.child = undefined;
243
269
  }
244
270
  }
245
- /** Convenience: read the venv python path recorded by scripts/setup-venv.sh. */
246
- export function resolveVenvPython(worldHome) {
247
- const p = join(worldHome, "agy-venv-python.txt");
248
- if (!existsSync(p))
249
- return undefined;
250
- const v = readFileSync(p, "utf8").trim();
251
- return v || undefined;
252
- }
@@ -0,0 +1,25 @@
1
+ /** Prod homes that must never be resolved into (repo red line). */
2
+ /** One persisted DSH → Antigravity conversation pairing. */
3
+ export interface AgySessionRecord {
4
+ /** The SDK conversation id; `null` until the first turn materializes it. */
5
+ readonly conversationId: string | null;
6
+ /** The cwd the bridge session was (or is to be) spawned in. */
7
+ readonly cwd: string;
8
+ /** Epoch ms of the DSH session's creation. */
9
+ readonly createdAt: number;
10
+ /** Record-only permission preset at create, when one was known. */
11
+ readonly preset: string | null;
12
+ }
13
+ export type AgySessionMap = Record<string, AgySessionRecord>;
14
+ /**
15
+ * The adapter's DSH-side world home. Form-A (boot home = DSH home root) nests
16
+ * `agents/agy`; Form-B (already `<root>/agents/agy`) passes through.
17
+ */
18
+ export declare function resolveAgyWorldHome(home?: string): string;
19
+ export declare function sessionMapPath(home?: string): string;
20
+ /** Read the map. Fail-soft: missing or malformed file reads as `{}`. */
21
+ export declare function readSessionMap(home?: string): AgySessionMap;
22
+ /** One session's record, or `undefined` when the id is unknown. */
23
+ export declare function sessionRecord(home: string | undefined, dshSessionId: string): AgySessionRecord | undefined;
24
+ /** Insert or merge one record, persisted atomically (temp file + rename). */
25
+ export declare function upsertSession(home: string | undefined, dshSessionId: string, patch: Partial<AgySessionRecord>): AgySessionRecord;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * DSH-session ↔ Antigravity-conversation identity map (the "mapping only"
3
+ * model, mirroring hermes-store.ts; 2026-09-18).
4
+ *
5
+ * The DSH session id is the authority. The SDK's `conversationId` only
6
+ * materializes after the first turn (first bridge prompt), so the pairing is
7
+ * persisted in the adapter's DSH-side app dir — `<worldHome>/dsh-sessions.json`
8
+ * (never the runtime's native `~/.gemini`). Mapping only: resume resolves the
9
+ * record or fails closed; native conversation storage is never scanned.
10
+ *
11
+ * Shape: `{ "<dshSessionId>": { conversationId, cwd, createdAt, preset } }` —
12
+ * `conversationId` is `null` until the first turn materializes it.
13
+ */
14
+ import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
15
+ import { basename, dirname, join, resolve } from "node:path";
16
+ /**
17
+ * The adapter's DSH-side world home. Form-A (boot home = DSH home root) nests
18
+ * `agents/agy`; Form-B (already `<root>/agents/agy`) passes through.
19
+ */
20
+ export function resolveAgyWorldHome(home) {
21
+ const base = resolve(home ?? process.env.DSH_HOME ?? join(process.cwd(), ".tests", "superd"));
22
+ const dir = basename(base) === "agy" && basename(dirname(base)) === "agents" ? base : join(base, "agents", "agy");
23
+ return dir;
24
+ }
25
+ export function sessionMapPath(home) {
26
+ return join(resolveAgyWorldHome(home), "dsh-sessions.json");
27
+ }
28
+ /** Read the map. Fail-soft: missing or malformed file reads as `{}`. */
29
+ export function readSessionMap(home) {
30
+ let raw;
31
+ try {
32
+ raw = readFileSync(sessionMapPath(home), "utf8");
33
+ }
34
+ catch {
35
+ return {};
36
+ }
37
+ let parsed;
38
+ try {
39
+ parsed = JSON.parse(raw);
40
+ }
41
+ catch {
42
+ return {};
43
+ }
44
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
45
+ return {};
46
+ const out = {};
47
+ for (const [id, value] of Object.entries(parsed)) {
48
+ const record = coerceRecord(value);
49
+ if (record !== undefined)
50
+ out[id] = record;
51
+ }
52
+ return out;
53
+ }
54
+ function coerceRecord(value) {
55
+ if (value === null || typeof value !== "object" || Array.isArray(value))
56
+ return undefined;
57
+ const raw = value;
58
+ const cwd = raw["cwd"];
59
+ const createdAt = raw["createdAt"];
60
+ if (typeof cwd !== "string" || cwd === "")
61
+ return undefined;
62
+ const conversationId = raw["conversationId"];
63
+ const preset = raw["preset"];
64
+ return {
65
+ conversationId: typeof conversationId === "string" && conversationId !== "" ? conversationId : null,
66
+ cwd,
67
+ createdAt: typeof createdAt === "number" && Number.isFinite(createdAt) ? createdAt : 0,
68
+ preset: typeof preset === "string" && preset !== "" ? preset : null,
69
+ };
70
+ }
71
+ /** One session's record, or `undefined` when the id is unknown. */
72
+ export function sessionRecord(home, dshSessionId) {
73
+ return readSessionMap(home)[dshSessionId];
74
+ }
75
+ /** Insert or merge one record, persisted atomically (temp file + rename). */
76
+ export function upsertSession(home, dshSessionId, patch) {
77
+ const path = sessionMapPath(home);
78
+ const map = readSessionMap(home);
79
+ const previous = map[dshSessionId];
80
+ const next = {
81
+ conversationId: patch.conversationId !== undefined ? patch.conversationId : previous?.conversationId ?? null,
82
+ cwd: patch.cwd !== undefined ? patch.cwd : previous?.cwd ?? "",
83
+ createdAt: patch.createdAt !== undefined ? patch.createdAt : previous?.createdAt ?? Date.now(),
84
+ preset: patch.preset !== undefined ? patch.preset : previous?.preset ?? null,
85
+ };
86
+ map[dshSessionId] = next;
87
+ writeMapAtomic(path, map);
88
+ return next;
89
+ }
90
+ function writeMapAtomic(path, map) {
91
+ const dir = dirname(path);
92
+ mkdirSync(dir, { recursive: true });
93
+ const temp = `${path}.${process.pid}.${Date.now()}.tmp`;
94
+ writeFileSync(temp, `${JSON.stringify(map, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
95
+ try {
96
+ renameSync(temp, path);
97
+ }
98
+ catch (error) {
99
+ try {
100
+ rmSync(temp, { force: true });
101
+ }
102
+ catch {
103
+ // The rename failure is primary.
104
+ }
105
+ throw error;
106
+ }
107
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * agy-store.ts — adapter-owned state + native-home read-only access.
3
+ *
4
+ * Home discipline (agent-adapter-dev-rules §5/§13/§16a):
5
+ * - Adapter state (Gemini API key, cached default model) lives in the WORLD
6
+ * DSH home: `<worldHome>/agy-adapter.json`. Never written into `~/.gemini`.
7
+ * - The native home (`~/.gemini`) is READ-ONLY for us: default model comes
8
+ * from `~/.gemini/antigravity-cli/settings.json` (`model` field). Paths are
9
+ * injectable so tests use fixtures instead of env knobs (prod path has no
10
+ * redirection).
11
+ */
12
+ export interface AgyAdapterState {
13
+ /** Gemini API key the user pasted through the onboarding session. */
14
+ apiKey?: string;
15
+ /** Cached default model slug (from native settings or catalog head). */
16
+ defaultModel?: string;
17
+ }
18
+ export declare function adapterStatePath(worldHome: string): string;
19
+ export declare function readAdapterState(worldHome: string): AgyAdapterState;
20
+ export declare function writeAdapterState(worldHome: string, state: AgyAdapterState): void;
21
+ /**
22
+ * ADC evidence probe: the SDK picks up Application Default Credentials on its
23
+ * own, so their mere existence satisfies auth (§16a transparency). Checks the
24
+ * two standard sources — the env-pointed service-account key and the gcloud
25
+ * user ADC file. Read-only; paths injectable for tests.
26
+ */
27
+ export declare function hasAdcEvidence(env: NodeJS.ProcessEnv, home: string): boolean;
28
+ /**
29
+ * Read the gcloud CLI default project (ADC companion): the SDK's Vertex
30
+ * endpoint needs an explicit project when no api_key is given. Parses
31
+ * `~/.config/gcloud/configurations/config_default` (read-only, fixture-friendly).
32
+ */
33
+ export declare function readGcloudProject(home: string): string | undefined;
34
+ /**
35
+ * Default model as the agy TUI would report it. Read-only probe of the
36
+ * native home; missing file / missing field → undefined (caller falls back
37
+ * to the static catalog head).
38
+ */
39
+ export declare function readNativeDefaultModel(nativeHome: string): string | undefined;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * agy-store.ts — adapter-owned state + native-home read-only access.
3
+ *
4
+ * Home discipline (agent-adapter-dev-rules §5/§13/§16a):
5
+ * - Adapter state (Gemini API key, cached default model) lives in the WORLD
6
+ * DSH home: `<worldHome>/agy-adapter.json`. Never written into `~/.gemini`.
7
+ * - The native home (`~/.gemini`) is READ-ONLY for us: default model comes
8
+ * from `~/.gemini/antigravity-cli/settings.json` (`model` field). Paths are
9
+ * injectable so tests use fixtures instead of env knobs (prod path has no
10
+ * redirection).
11
+ */
12
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
13
+ import { join } from "node:path";
14
+ export function adapterStatePath(worldHome) {
15
+ return join(worldHome, "agy-adapter.json");
16
+ }
17
+ export function readAdapterState(worldHome) {
18
+ const p = adapterStatePath(worldHome);
19
+ if (!existsSync(p))
20
+ return {};
21
+ try {
22
+ const parsed = JSON.parse(readFileSync(p, "utf8"));
23
+ return typeof parsed === "object" && parsed !== null ? parsed : {};
24
+ }
25
+ catch {
26
+ return {};
27
+ }
28
+ }
29
+ export function writeAdapterState(worldHome, state) {
30
+ writeFileSync(adapterStatePath(worldHome), JSON.stringify(state, null, 2) + "\n");
31
+ }
32
+ /**
33
+ * ADC evidence probe: the SDK picks up Application Default Credentials on its
34
+ * own, so their mere existence satisfies auth (§16a transparency). Checks the
35
+ * two standard sources — the env-pointed service-account key and the gcloud
36
+ * user ADC file. Read-only; paths injectable for tests.
37
+ */
38
+ export function hasAdcEvidence(env, home) {
39
+ const fromEnv = env.GOOGLE_APPLICATION_CREDENTIALS;
40
+ if (typeof fromEnv === "string" && fromEnv !== "" && existsSync(fromEnv))
41
+ return true;
42
+ return existsSync(join(home, ".config", "gcloud", "application_default_credentials.json"));
43
+ }
44
+ /**
45
+ * Read the gcloud CLI default project (ADC companion): the SDK's Vertex
46
+ * endpoint needs an explicit project when no api_key is given. Parses
47
+ * `~/.config/gcloud/configurations/config_default` (read-only, fixture-friendly).
48
+ */
49
+ export function readGcloudProject(home) {
50
+ const p = join(home, ".config", "gcloud", "configurations", "config_default");
51
+ if (!existsSync(p))
52
+ return undefined;
53
+ try {
54
+ for (const line of readFileSync(p, "utf8").split("\n")) {
55
+ const m = /^\s*project\s*=\s*(\S+)\s*$/.exec(line);
56
+ if (m)
57
+ return m[1];
58
+ }
59
+ }
60
+ catch {
61
+ /* fall through */
62
+ }
63
+ return undefined;
64
+ }
65
+ /**
66
+ * Default model as the agy TUI would report it. Read-only probe of the
67
+ * native home; missing file / missing field → undefined (caller falls back
68
+ * to the static catalog head).
69
+ */
70
+ export function readNativeDefaultModel(nativeHome) {
71
+ const p = join(nativeHome, "antigravity-cli", "settings.json");
72
+ if (!existsSync(p))
73
+ return undefined;
74
+ try {
75
+ const parsed = JSON.parse(readFileSync(p, "utf8"));
76
+ return typeof parsed.model === "string" && parsed.model.length > 0
77
+ ? parsed.model
78
+ : undefined;
79
+ }
80
+ catch {
81
+ return undefined;
82
+ }
83
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Minimal in-memory inbox for the Hermes agent shim.
3
+ *
4
+ * The 0.1.5 `dsh-agent` contract exposes the inbox as an interface
5
+ * (`Inbox` in `runtime-types`); the durable projection-backed implementation
6
+ * (`ReactLoopInbox`) lives inside the (disabled) `dsh-agent-loop`. Hermes owns
7
+ * its own transcript and the adapter delivers messages directly to the Hermes
8
+ * client (`HermesAgent.#deliver`), so this inbox is never queued into — it
9
+ * exists to satisfy the `Agent` interface's `inbox` surface with correct
10
+ * (empty) semantics: `nextTurn`/`nextStep` stay empty and every mutation is
11
+ * a faithful in-memory splice.
12
+ */
13
+ import type { Inbox as InboxContract, InboxTarget } from "@deepseek-ai/dsh-agent";
14
+ import type { UserMessage } from "@deepseek-ai/dsh-session";
15
+ import type { MessageId } from "@deepseek-ai/dsh-llm";
16
+ export declare class Inbox implements InboxContract {
17
+ #private;
18
+ get nextTurn(): readonly UserMessage[];
19
+ get nextStep(): readonly UserMessage[];
20
+ clear(): void;
21
+ append(target: InboxTarget, message: UserMessage): void;
22
+ prepend(target: InboxTarget, message: UserMessage): void;
23
+ replace(messageId: MessageId, newMessage: UserMessage): boolean;
24
+ remove(messageId: MessageId): boolean;
25
+ splice(target: InboxTarget, start: number, deleteCount: number, inserted: UserMessage[]): UserMessage[];
26
+ }
@@ -0,0 +1,53 @@
1
+ export class Inbox {
2
+ #nextTurn = [];
3
+ #nextStep = [];
4
+ get nextTurn() {
5
+ return this.#nextTurn;
6
+ }
7
+ get nextStep() {
8
+ return this.#nextStep;
9
+ }
10
+ clear() {
11
+ this.#nextTurn = [];
12
+ this.#nextStep = [];
13
+ }
14
+ append(target, message) {
15
+ this.#list(target).push(message);
16
+ }
17
+ prepend(target, message) {
18
+ this.#list(target).unshift(message);
19
+ }
20
+ replace(messageId, newMessage) {
21
+ const list = this.#find(messageId);
22
+ if (list === undefined)
23
+ return false;
24
+ const index = list.findIndex((message) => message.id === messageId);
25
+ if (index < 0)
26
+ return false;
27
+ list.splice(index, 1, newMessage);
28
+ return true;
29
+ }
30
+ remove(messageId) {
31
+ const list = this.#find(messageId);
32
+ if (list === undefined)
33
+ return false;
34
+ const index = list.findIndex((message) => message.id === messageId);
35
+ if (index < 0)
36
+ return false;
37
+ list.splice(index, 1);
38
+ return true;
39
+ }
40
+ splice(target, start, deleteCount, inserted) {
41
+ return this.#list(target).splice(start, deleteCount, ...inserted);
42
+ }
43
+ #list(target) {
44
+ return target === "next-turn" ? this.#nextTurn : this.#nextStep;
45
+ }
46
+ #find(messageId) {
47
+ if (this.#nextTurn.some((message) => message.id === messageId))
48
+ return this.#nextTurn;
49
+ if (this.#nextStep.some((message) => message.id === messageId))
50
+ return this.#nextStep;
51
+ return undefined;
52
+ }
53
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * agent-agy-sdk provider — Google Antigravity provider plugin for DeepSeek
3
+ * Harness (Super D, opt-in SDK line, 2026-10-02 split).
4
+ *
5
+ * The SDK half of the Antigravity split. An `AgentFactory` that drives an
6
+ * `AgyBridgeClient` (the Python google-antigravity SDK bridge child —
7
+ * localharness materializes inside it on the FIRST prompt, so create/resume
8
+ * spawn nothing). Auth is consumer-first: a Gemini API key persisted in the
9
+ * adapter's world-home state, or ADC via the environment (the SDK picks it up;
10
+ * this package NEVER invokes the agy CLI — dev-rules §16a). The CLI transport
11
+ * is the sibling package `@pgmi-builds/agent-agy`.
12
+ *
13
+ * Session identity ("mapping only"): the DSH session id is the authority,
14
+ * supplied by the harness. The SDK conversation id materializes after the
15
+ * first turn, so the pairing is persisted in `<worldHome>/dsh-sessions.json`
16
+ * (agy-sessions.ts). Resume resolves that record and fails CLOSED
17
+ * (CONVERSATION_NOT_FOUND) when no conversation is recorded. The DSH session
18
+ * log is the transcript authority, written through the upstream
19
+ * `sessionPersistence` service (hermes create/resume transaction shape).
20
+ *
21
+ * Deployment (2026-10-02 user ruling): the composite ships this row DISABLED
22
+ * and the package declares NO Python dependency and no postinstall — the
23
+ * durable venv under the world home is fetched lazily on first real use
24
+ * (sdk-venv.ts).
25
+ */
26
+ import { Context, Service } from "@deepseek-ai/cordis";
27
+ import type { AgentFactory, AgentHandle, CreateAgentOptions, ResumeAgentOptions } from "@deepseek-ai/dsh-agent";
28
+ /** Test/override knobs for the bridge child (prod: all unset). */
29
+ export interface AgyProviderOptions {
30
+ bridgePath?: string;
31
+ pythonBin?: string;
32
+ spawnAttempts?: number;
33
+ /** Native home override for tests (prod: ~/.gemini, read-only). */
34
+ nativeHome?: string;
35
+ /** Vertex project/location override (ADC mode). Default: gcloud CLI config. */
36
+ project?: string;
37
+ location?: string;
38
+ /** Tool-approval posture surfaced to every session's bridge start frame. */
39
+ approvalMode?: "allow" | "ask";
40
+ }
41
+ export declare class AgyProvider extends Service implements AgentFactory {
42
+ static inject: string[];
43
+ /** Plain holder — prevents Cordis re-tracing the factory's ctx through a caller shadow. */
44
+ private readonly runtime;
45
+ /** The world's DSH home — anchors adapter-owned state (session map, api-key state). */
46
+ private readonly home;
47
+ private readonly opts;
48
+ private defaultModelKey;
49
+ constructor(ctx: Context, opts?: AgyProviderOptions);
50
+ /** The world's DSH home: boot-provided dshHomePath first, env last. */
51
+ private resolveHome;
52
+ /** Effective Gemini API key: adapter state first, then the environment. */
53
+ private resolveApiKey;
54
+ /**
55
+ * Auth evidence for the §17 onboarding gate: an API key (state or env) OR
56
+ * ADC evidence is enough — the SDK consumes either transparently, so a user
57
+ * with gcloud ADC must NOT be pushed into key onboarding.
58
+ */
59
+ private hasAuthEvidence;
60
+ /** Default model id: adapter state → native TUI default (slug-normalized) → catalog head. */
61
+ private resolveDefaultModelId;
62
+ /** Legacy slug-only default (default-model push keeps slug form). */
63
+ private resolveDefaultModel;
64
+ /** Static route: provider `agy` + the resolved default (or the explicit ask).
65
+ * The selected model id (`slug` or `slug@level`) rides in `options.model`
66
+ * so clientOptions can forward slug+thinkingLevel to the bridge start frame. */
67
+ private sessionAgentOptions;
68
+ private requirePersistence;
69
+ private agentRuntime;
70
+ /** Persist the Dash↔conversation pairing once the first turn materializes it. */
71
+ private readonly followConversationId;
72
+ private registerModelCatalog;
73
+ /** Push the resolved default model into the world's `agentDefaultModel`. */
74
+ private registerDefaultModel;
75
+ createAgent(ownerCtx: Context, options: CreateAgentOptions): Promise<AgentHandle>;
76
+ resume(ownerCtx: Context, options: ResumeAgentOptions): Promise<AgentHandle>;
77
+ /**
78
+ * Live transport: SDK-ONLY (2026-10-02 user ruling).
79
+ *
80
+ * This package is the opt-in SDK half of the Antigravity split: it drives the
81
+ * Python google-antigravity SDK through the JSONL bridge and NEVER invokes the
82
+ * user's `agy` CLI (that transport is `@pgmi-builds/agent-agy`).
83
+ * Auth (§16a transparency): a key from adapter state / `GEMINI_API_KEY` rides
84
+ * the start frame; without one the SDK falls back to ADC (Vertex, project read
85
+ * from the gcloud default). Neither ⇒ the §17 onboarding branch answers the
86
+ * first turn locally, before anything spawns.
87
+ */
88
+ private createLiveClient;
89
+ /** Bridge child options: world cwd + overrides; the api key rides the start config. */
90
+ private clientOptions;
91
+ private createStoredSession;
92
+ }
93
+ export default AgyProvider;