super-dsh 0.1.5 → 0.1.9

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 (79) hide show
  1. package/client/index.js +1010 -345
  2. package/cordis.patch.yml +22 -5
  3. package/package.json +8 -3
  4. package/superd-hub/dist/a2a-delivery.d.ts +189 -0
  5. package/superd-hub/dist/a2a-delivery.js +240 -0
  6. package/superd-hub/dist/a2a-host.d.ts +76 -0
  7. package/superd-hub/dist/a2a-host.js +145 -0
  8. package/superd-hub/dist/a2a-ingest.d.ts +31 -0
  9. package/superd-hub/dist/a2a-ingest.js +636 -0
  10. package/superd-hub/dist/a2a-log.d.ts +17 -0
  11. package/superd-hub/dist/a2a-log.js +42 -0
  12. package/superd-hub/dist/a2a-row.d.ts +65 -0
  13. package/superd-hub/dist/a2a-row.js +162 -0
  14. package/superd-hub/dist/a2a-service.d.ts +357 -0
  15. package/superd-hub/dist/a2a-service.js +980 -0
  16. package/superd-hub/dist/a2a-wire.d.ts +220 -0
  17. package/superd-hub/dist/a2a-wire.js +305 -0
  18. package/superd-hub/dist/agent-ids.d.ts +10 -0
  19. package/superd-hub/dist/agent-ids.js +68 -0
  20. package/superd-hub/dist/agent-roster.d.ts +32 -17
  21. package/superd-hub/dist/agent-roster.js +54 -15
  22. package/superd-hub/dist/agent-status.d.ts +119 -0
  23. package/superd-hub/dist/agent-status.js +386 -0
  24. package/superd-hub/dist/client/mesh-api.d.ts +134 -0
  25. package/superd-hub/dist/client/mesh-api.js +219 -0
  26. package/superd-hub/dist/client/mesh-groups.d.ts +63 -0
  27. package/superd-hub/dist/client/mesh-groups.js +66 -0
  28. package/superd-hub/dist/client/roster.d.ts +48 -0
  29. package/superd-hub/dist/client/roster.js +96 -0
  30. package/superd-hub/dist/exec-pty-channel.d.ts +58 -0
  31. package/superd-hub/dist/exec-pty-channel.js +162 -0
  32. package/superd-hub/dist/exec-pty-framing.d.ts +32 -0
  33. package/superd-hub/dist/exec-pty-framing.js +81 -0
  34. package/superd-hub/dist/exec-pty-rpc.d.ts +21 -0
  35. package/superd-hub/dist/exec-pty-rpc.js +128 -0
  36. package/superd-hub/dist/exec-pty-session.d.ts +76 -0
  37. package/superd-hub/dist/exec-pty-session.js +234 -0
  38. package/superd-hub/dist/exec.d.ts +56 -0
  39. package/superd-hub/dist/exec.js +225 -0
  40. package/superd-hub/dist/fusion-transport.d.ts +23 -21
  41. package/superd-hub/dist/fusion-transport.js +12 -40
  42. package/superd-hub/dist/gateway.d.ts +39 -2
  43. package/superd-hub/dist/gateway.js +62 -3
  44. package/superd-hub/dist/hub-tool.d.ts +174 -0
  45. package/superd-hub/dist/hub-tool.js +464 -0
  46. package/superd-hub/dist/index.d.ts +18 -4
  47. package/superd-hub/dist/index.js +19 -3
  48. package/superd-hub/dist/machines.d.ts +45 -0
  49. package/superd-hub/dist/machines.js +125 -0
  50. package/superd-hub/dist/mesh-federate.d.ts +138 -0
  51. package/superd-hub/dist/mesh-federate.js +223 -0
  52. package/superd-hub/dist/mesh-gateway.d.ts +67 -0
  53. package/superd-hub/dist/mesh-gateway.js +408 -0
  54. package/superd-hub/dist/mesh-link.d.ts +274 -0
  55. package/superd-hub/dist/mesh-link.js +441 -0
  56. package/superd-hub/dist/mesh-rpc.d.ts +123 -0
  57. package/superd-hub/dist/mesh-rpc.js +250 -0
  58. package/superd-hub/dist/mux-client.d.ts +71 -0
  59. package/superd-hub/dist/mux-client.js +281 -0
  60. package/superd-hub/dist/pack-version.d.ts +2 -0
  61. package/superd-hub/dist/pack-version.js +30 -0
  62. package/superd-hub/dist/roster.d.ts +10 -0
  63. package/superd-hub/dist/roster.js +9 -1
  64. package/superd-hub/dist/rpc.d.ts +18 -2
  65. package/superd-hub/dist/rpc.js +34 -4
  66. package/superd-hub/dist/spawn-world.js +3 -1
  67. package/superd-hub/dist/switch-core.d.ts +98 -21
  68. package/superd-hub/dist/switch-core.js +123 -28
  69. package/superd-hub/dist/system-head.d.ts +22 -12
  70. package/superd-hub/dist/system-head.js +100 -84
  71. package/superd-hub/dist/toast-core.d.ts +43 -0
  72. package/superd-hub/dist/toast-core.js +63 -0
  73. package/superd-hub/dist/wire-endpoints.d.ts +264 -0
  74. package/superd-hub/dist/wire-endpoints.js +180 -0
  75. package/superd-hub/dist/world-join.js +8 -3
  76. package/superd-hub/dist/world-mount.d.ts +27 -0
  77. package/superd-hub/dist/world-mount.js +67 -0
  78. package/superd-hub/lib/client/index.js +1010 -345
  79. package/superd-hub/package.json +11 -2
@@ -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;