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
@@ -0,0 +1,76 @@
1
+ import type { A2aAddress, A2aGateway, A2aInitiator, A2aService } from './a2a-service.js';
2
+ /** Host wiring inputs: the hub home plus the local native session-plane face. */
3
+ export interface A2aHostOptions {
4
+ /** Hub home (a6 id store + machines registry live under `<home>/superd/`). */
5
+ home: string;
6
+ /**
7
+ * ctx0's own RAW in-process typertGateway instance — serves the LOCAL
8
+ * 'native' row (its a6); injected by the plugin wiring, undefined before
9
+ * the hub process has its own face. Bridged to T2's face by the resolver
10
+ * ({@link bridgeTypertGateway}).
11
+ */
12
+ nativeGateway?: RawTypertGatewayFace;
13
+ }
14
+ /**
15
+ * The RAW typertGateway service face — upstream canonical stream order
16
+ * `openWireStream(endpoint, payload, uplink, peer, signal, control)`
17
+ * (dsh-api-gateway/src/index.ts:434; the 0.1.3-j positional-misbind lesson).
18
+ * LOCAL worlds and ctx0's own row hand out RAW instances (world-join.ts
19
+ * registers `ctxW.get('typertGateway')` verbatim); FEDERATED rows hand out
20
+ * mesh-gateway wire adapters (dual-face, 3rd-argument dispatch).
21
+ */
22
+ export interface RawTypertGatewayFace {
23
+ dispatchRpc(endpoint: string, payload: unknown, signal: AbortSignal): Promise<unknown>;
24
+ openWireStream(endpoint: string, payload: unknown, uplink: undefined, peer: undefined, signal: AbortSignal, control: AbortController): Promise<AsyncIterable<unknown>> | AsyncIterable<unknown>;
25
+ }
26
+ /**
27
+ * Bridge one RAW typertGateway instance to Task 2's 3-arg `A2aGateway` face
28
+ * (fix round 1, 2026-09-28 review: the positional mismatch stranded completion
29
+ * streams). `uplink: undefined` is the canonical NO-LANE spelling upstream —
30
+ * the gateway substitutes `EMPTY_ASYNC_ITERABLE` itself
31
+ * (dsh-api-gateway/src/index.ts:712) — and `dispatchRpc` passes through as-is.
32
+ *
33
+ * FEDERATED WIRE ADAPTERS MUST NOT BE WRAPPED: mesh-gateway's dual-face
34
+ * dispatch reads the THIRD argument (`isUplinkLane(undefined)` → false), so a
35
+ * canonical 6-arg call would take its 3-arg branch and read the abort signal
36
+ * from position 3 (undefined) — silently losing cancellation. The resolver
37
+ * therefore passes federated rows through untouched.
38
+ * @param real - a raw in-process typertGateway instance (ctx0's own or a local world's).
39
+ * @returns the gateway Task 2's service consumes.
40
+ */
41
+ export declare function bridgeTypertGateway(real: RawTypertGatewayFace): A2aGateway;
42
+ /**
43
+ * Build the gatewayFor resolver Task 2's service consumes: federated table
44
+ * first, shared target registry second, local id-map inversion third,
45
+ * injected native face last. LOCAL rows (runtime-key targets + the native
46
+ * seam) are RAW instances and get {@link bridgeTypertGateway}; FEDERATED rows
47
+ * (federation memo + a6-keyed registry entries) are wire adapters and pass
48
+ * through UNTOWRAPPED (see the bridge's JSDoc for why wrapping them loses
49
+ * the abort signal).
50
+ *
51
+ * A MISS THROWS the typed {@link A2aAddressError} (D7): a roster-known a6 whose
52
+ * plane is down → 'unreachable'; an a6 no store has ever seen → 'unknown-agent'
53
+ * when the addressed machine is self or paired, else 'unknown-machine' — the
54
+ * WHY survives the resolver boundary for future consumers (P4 exec, P5
55
+ * injection) to branch on.
56
+ * @param options - hub home + optional raw in-process native gateway.
57
+ * @returns the resolver (a gateway, or it throws A2aAddressError).
58
+ */
59
+ export declare function resolveA2aGatewayFor(options: A2aHostOptions): (addr: A2aAddress) => A2aGateway;
60
+ /**
61
+ * Build the LOCAL machine's initiator identity from the calling world's
62
+ * roster key and the live DSH session driving the tool call.
63
+ * @param home - hub home (self m4 + a6 id store).
64
+ * @param agentKey - roster key of the calling world ('native' for ctx0's own agent).
65
+ * @param sessionId - the live DSH session id making the call (T4: the tool call's agent context).
66
+ * @returns the initiator envelope Task 2's service teaches the peer.
67
+ */
68
+ export declare function localA2aInitiator(home: string, agentKey: string, sessionId: string): A2aInitiator;
69
+ /**
70
+ * Assemble the full A2A service on the hub's live surfaces: Task 2's pure
71
+ * core with the host gatewayFor resolution (delivery glue is per-conversation
72
+ * — T4's tool wires `wireCompletionToDelivery` after each send).
73
+ * @param options - hub home + optional in-process native gateway.
74
+ * @returns the A2A conversation service.
75
+ */
76
+ export declare function createA2aHost(options: A2aHostOptions): A2aService;
@@ -0,0 +1,145 @@
1
+ /**
2
+ * A2A host assembly (mesh P3 Task 3): wires Task 2's pure conversation
3
+ * service to the hub's live surfaces — the gatewayFor resolution over the
4
+ * P2 federation table and the local target registry, plus the LOCAL
5
+ * machine's initiator identity.
6
+ *
7
+ * Resolution order (the carrier precedent, gateway.ts:87 —
8
+ * `federatedGatewayOf(label) ?? getTarget(label)`):
9
+ * 1. FEDERATED rows: the P2 mesh-federate memo table by a6
10
+ * (`federatedGatewayOf`) — remote machines' agents, owner-minted a6
11
+ * adopted verbatim.
12
+ * 2. FEDERATED a6s in the SHARED target registry — `federateAgents`
13
+ * registers the same pair (same gateway instance) into both stores, so
14
+ * a cold memo still resolves; locals are keyed by runtime key, never by
15
+ * a6, so this step never hits a local row.
16
+ * 3. LOCAL rows: the a6 id store (`agent-ids.json`, roster key → a6)
17
+ * inverted to the world's runtime key, then `getTarget(key)` — the
18
+ * world's typertGateway service instance. The LOCAL 'native' row has no
19
+ * registry target ('native' is the implicit first key of
20
+ * `listRuntimeKeys` and the `/hub` family is foreign-only): its
21
+ * session-plane face is the hub process's own in-process gateway,
22
+ * INJECTED here by the plugin wiring.
23
+ *
24
+ * The initiator identity is the REAL machine/agent ids: machine = the
25
+ * owner-minted self m4 (`machines.json`), agent = the roster a6 of the
26
+ * world whose DSH session made the tool call (T4 supplies the live session
27
+ * id from the tool call's agent context; T3 only builds the envelope).
28
+ */
29
+ import { agentIdMap, ensureAgentId } from './agent-ids.js';
30
+ import { ensureSelf, listRemotes } from './machines.js';
31
+ import { agentLinks } from './agent-roster.js';
32
+ import { federatedGatewayOf } from './mesh-federate.js';
33
+ import { getTarget } from './targets.js';
34
+ import { createA2aService } from './a2a-service.js';
35
+ import { A2aAddressError } from './a2a-service.js';
36
+ /**
37
+ * The roster key (world runtime key) owning one a6 in the LOCAL id store —
38
+ * read-only (never mints): resolution must observe, not mutate.
39
+ */
40
+ function localKeyOfA6(home, a6) {
41
+ for (const [key, id] of Object.entries(agentIdMap(home))) {
42
+ if (id === a6)
43
+ return key;
44
+ }
45
+ return undefined;
46
+ }
47
+ /**
48
+ * Bridge one RAW typertGateway instance to Task 2's 3-arg `A2aGateway` face
49
+ * (fix round 1, 2026-09-28 review: the positional mismatch stranded completion
50
+ * streams). `uplink: undefined` is the canonical NO-LANE spelling upstream —
51
+ * the gateway substitutes `EMPTY_ASYNC_ITERABLE` itself
52
+ * (dsh-api-gateway/src/index.ts:712) — and `dispatchRpc` passes through as-is.
53
+ *
54
+ * FEDERATED WIRE ADAPTERS MUST NOT BE WRAPPED: mesh-gateway's dual-face
55
+ * dispatch reads the THIRD argument (`isUplinkLane(undefined)` → false), so a
56
+ * canonical 6-arg call would take its 3-arg branch and read the abort signal
57
+ * from position 3 (undefined) — silently losing cancellation. The resolver
58
+ * therefore passes federated rows through untouched.
59
+ * @param real - a raw in-process typertGateway instance (ctx0's own or a local world's).
60
+ * @returns the gateway Task 2's service consumes.
61
+ */
62
+ export function bridgeTypertGateway(real) {
63
+ return {
64
+ dispatchRpc: (endpoint, payload, signal) => real.dispatchRpc(endpoint, payload, signal),
65
+ openWireStream: (endpoint, payload, signal) => real.openWireStream(endpoint, payload, undefined, undefined, signal, new AbortController()),
66
+ };
67
+ }
68
+ /**
69
+ * Build the gatewayFor resolver Task 2's service consumes: federated table
70
+ * first, shared target registry second, local id-map inversion third,
71
+ * injected native face last. LOCAL rows (runtime-key targets + the native
72
+ * seam) are RAW instances and get {@link bridgeTypertGateway}; FEDERATED rows
73
+ * (federation memo + a6-keyed registry entries) are wire adapters and pass
74
+ * through UNTOWRAPPED (see the bridge's JSDoc for why wrapping them loses
75
+ * the abort signal).
76
+ *
77
+ * A MISS THROWS the typed {@link A2aAddressError} (D7): a roster-known a6 whose
78
+ * plane is down → 'unreachable'; an a6 no store has ever seen → 'unknown-agent'
79
+ * when the addressed machine is self or paired, else 'unknown-machine' — the
80
+ * WHY survives the resolver boundary for future consumers (P4 exec, P5
81
+ * injection) to branch on.
82
+ * @param options - hub home + optional raw in-process native gateway.
83
+ * @returns the resolver (a gateway, or it throws A2aAddressError).
84
+ */
85
+ export function resolveA2aGatewayFor(options) {
86
+ return (addr) => {
87
+ const federated = federatedGatewayOf(addr.id);
88
+ if (federated !== undefined)
89
+ return federated;
90
+ const registered = getTarget(addr.id)?.gateway;
91
+ if (registered !== undefined)
92
+ return registered;
93
+ const key = localKeyOfA6(options.home, addr.id);
94
+ if (key !== undefined) {
95
+ if (key === 'native') {
96
+ if (options.nativeGateway === undefined)
97
+ throw new A2aAddressError('unreachable', addr);
98
+ return bridgeTypertGateway(options.nativeGateway);
99
+ }
100
+ // The registry's declared GatewayFace (targets.ts) types the stream
101
+ // face as the 3-arg subset, but a LOCAL row's runtime object is the RAW
102
+ // typertGateway instance (world-join.ts registers it verbatim) — re-cast
103
+ // to RawTypertGatewayFace so the bridge above binds the canonical 6-arg
104
+ // positional order instead of the declared subset.
105
+ const local = getTarget(key)?.gateway;
106
+ if (local === undefined)
107
+ throw new A2aAddressError('unreachable', addr);
108
+ return bridgeTypertGateway(local);
109
+ }
110
+ // The a6 resolves nowhere — classify the miss (D7): a roster row exists →
111
+ // its plane is down; else the machine decides agent-vs-machine blame.
112
+ if (agentLinks(options.home).some((l) => l.id === addr.id))
113
+ throw new A2aAddressError('unreachable', addr);
114
+ const self = ensureSelf(options.home, 'local');
115
+ if (addr.machine === self.id || listRemotes(options.home).some((r) => r.id === addr.machine)) {
116
+ throw new A2aAddressError('unknown-agent', addr);
117
+ }
118
+ throw new A2aAddressError('unknown-machine', addr);
119
+ };
120
+ }
121
+ /**
122
+ * Build the LOCAL machine's initiator identity from the calling world's
123
+ * roster key and the live DSH session driving the tool call.
124
+ * @param home - hub home (self m4 + a6 id store).
125
+ * @param agentKey - roster key of the calling world ('native' for ctx0's own agent).
126
+ * @param sessionId - the live DSH session id making the call (T4: the tool call's agent context).
127
+ * @returns the initiator envelope Task 2's service teaches the peer.
128
+ */
129
+ export function localA2aInitiator(home, agentKey, sessionId) {
130
+ return {
131
+ machine: ensureSelf(home, 'local').id,
132
+ agent: ensureAgentId(home, agentKey),
133
+ sessionId,
134
+ };
135
+ }
136
+ /**
137
+ * Assemble the full A2A service on the hub's live surfaces: Task 2's pure
138
+ * core with the host gatewayFor resolution (delivery glue is per-conversation
139
+ * — T4's tool wires `wireCompletionToDelivery` after each send).
140
+ * @param options - hub home + optional in-process native gateway.
141
+ * @returns the A2A conversation service.
142
+ */
143
+ export function createA2aHost(options) {
144
+ return createA2aService({ home: options.home, gatewayFor: resolveA2aGatewayFor(options) });
145
+ }
@@ -0,0 +1,31 @@
1
+ import { type A2aAddress, type A2aGateway } from './a2a-service.js';
2
+ import type { A2aDeliveryCtx, A2aDeliveryOutcome, A2aNoticeReason } from './a2a-delivery.js';
3
+ import { type A2aEnvelope, type A2aNoticeEnvelope, type A2aReplyEnvelope, type A2aWireReceipt } from './a2a-wire.js';
4
+ import type { A2aLogFn } from './a2a-log.js';
5
+ /** Ingest assembly inputs: hub home + the LOCAL resolver + the in-process delivery face. */
6
+ export interface A2aIngestDeps {
7
+ home: string;
8
+ /** The local leg of a2a-host's resolver: an address on THIS machine → its session-plane gateway. */
9
+ gatewayFor(addr: A2aAddress): A2aGateway;
10
+ /** The initiator-side delivery face (live agents + the bounded unread buffer). */
11
+ delivery: A2aDeliveryCtx;
12
+ fetchImpl?: typeof fetch;
13
+ /** Operational journal (0.1.7-b): one greppable line per machine event; the cordis host wires it onto ctx.logger, tests inject a collector. */
14
+ log?: A2aLogFn;
15
+ now?(): number;
16
+ }
17
+ /** Where one return envelope landed (R5's sweep and tests observe this). */
18
+ export type A2aReturnRoute = 'delivered' | 'posted' | 'outbox';
19
+ /** The full ingest surface. */
20
+ export interface A2aIngest {
21
+ /** Handle one envelope (request kinds execute; return kinds deliver locally). */
22
+ ingest(envelope: A2aEnvelope): Promise<A2aWireReceipt | A2aDeliveryOutcome>;
23
+ /** Claim & clear the outbox entries addressed to `machine` (the GET ?machine= leg). */
24
+ claimOutbox(machine: string): A2aEnvelope[];
25
+ /** Route one return envelope now (self / wire / outbox) — the completion watcher's leg. */
26
+ routeReturn(envelope: A2aReplyEnvelope | A2aNoticeEnvelope, meta: {
27
+ responderAgent: string;
28
+ noticeReason?: A2aNoticeReason;
29
+ }): Promise<A2aReturnRoute>;
30
+ }
31
+ export declare function createA2aIngest(deps: A2aIngestDeps): A2aIngest;