@cello-protocol/daemon 0.0.53 → 0.0.54

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 (173) hide show
  1. package/dist/agent-handlers.d.ts +57 -0
  2. package/dist/agent-handlers.d.ts.map +1 -0
  3. package/dist/agent-handlers.js +360 -0
  4. package/dist/agent-handlers.js.map +1 -0
  5. package/dist/agent-id-migration.d.ts.map +1 -1
  6. package/dist/agent-id-migration.js +1 -0
  7. package/dist/agent-id-migration.js.map +1 -1
  8. package/dist/agent-loader.d.ts +3 -4
  9. package/dist/agent-loader.d.ts.map +1 -1
  10. package/dist/agent-loader.js +3 -4
  11. package/dist/agent-loader.js.map +1 -1
  12. package/dist/cbor-blob-migration.d.ts +8 -0
  13. package/dist/cbor-blob-migration.d.ts.map +1 -0
  14. package/dist/cbor-blob-migration.js +115 -0
  15. package/dist/cbor-blob-migration.js.map +1 -0
  16. package/dist/close-session-handler.d.ts +41 -0
  17. package/dist/close-session-handler.d.ts.map +1 -0
  18. package/dist/close-session-handler.js +399 -0
  19. package/dist/close-session-handler.js.map +1 -0
  20. package/dist/consortium-bootstrap.d.ts +83 -0
  21. package/dist/consortium-bootstrap.d.ts.map +1 -0
  22. package/dist/consortium-bootstrap.js +120 -0
  23. package/dist/consortium-bootstrap.js.map +1 -0
  24. package/dist/contact-handlers.d.ts +56 -0
  25. package/dist/contact-handlers.d.ts.map +1 -0
  26. package/dist/contact-handlers.js +303 -0
  27. package/dist/contact-handlers.js.map +1 -0
  28. package/dist/content-park-client.d.ts.map +1 -1
  29. package/dist/content-park-client.js +7 -7
  30. package/dist/content-park-client.js.map +1 -1
  31. package/dist/content-park.d.ts +15 -0
  32. package/dist/content-park.d.ts.map +1 -0
  33. package/dist/content-park.js +227 -0
  34. package/dist/content-park.js.map +1 -0
  35. package/dist/daemon.d.ts +0 -11
  36. package/dist/daemon.d.ts.map +1 -1
  37. package/dist/daemon.js +407 -4552
  38. package/dist/daemon.js.map +1 -1
  39. package/dist/db-identity-store.d.ts +31 -35
  40. package/dist/db-identity-store.d.ts.map +1 -1
  41. package/dist/db-identity-store.js +62 -66
  42. package/dist/db-identity-store.js.map +1 -1
  43. package/dist/directory-bootstrap.d.ts +27 -31
  44. package/dist/directory-bootstrap.d.ts.map +1 -1
  45. package/dist/directory-bootstrap.js +18 -21
  46. package/dist/directory-bootstrap.js.map +1 -1
  47. package/dist/frame-values.d.ts +3 -0
  48. package/dist/frame-values.d.ts.map +1 -0
  49. package/dist/frame-values.js +73 -0
  50. package/dist/frame-values.js.map +1 -0
  51. package/dist/identity-migration.d.ts +8 -8
  52. package/dist/identity-migration.d.ts.map +1 -1
  53. package/dist/identity-migration.js +30 -31
  54. package/dist/identity-migration.js.map +1 -1
  55. package/dist/inbound-seal-request.d.ts +17 -0
  56. package/dist/inbound-seal-request.d.ts.map +1 -0
  57. package/dist/inbound-seal-request.js +155 -0
  58. package/dist/inbound-seal-request.js.map +1 -0
  59. package/dist/inbound-sessions.d.ts +54 -0
  60. package/dist/inbound-sessions.d.ts.map +1 -0
  61. package/dist/inbound-sessions.js +603 -0
  62. package/dist/inbound-sessions.js.map +1 -0
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +8 -10
  65. package/dist/index.js.map +1 -1
  66. package/dist/initiate-session-handler.d.ts +22 -0
  67. package/dist/initiate-session-handler.d.ts.map +1 -0
  68. package/dist/initiate-session-handler.js +150 -0
  69. package/dist/initiate-session-handler.js.map +1 -0
  70. package/dist/network-directory-node.d.ts +6 -6
  71. package/dist/network-directory-node.d.ts.map +1 -1
  72. package/dist/network-directory-node.js +29 -28
  73. package/dist/network-directory-node.js.map +1 -1
  74. package/dist/notification-handlers.d.ts +32 -0
  75. package/dist/notification-handlers.d.ts.map +1 -0
  76. package/dist/notification-handlers.js +73 -0
  77. package/dist/notification-handlers.js.map +1 -0
  78. package/dist/outbound-sessions.d.ts +54 -0
  79. package/dist/outbound-sessions.d.ts.map +1 -0
  80. package/dist/outbound-sessions.js +429 -0
  81. package/dist/outbound-sessions.js.map +1 -0
  82. package/dist/park-envelope.d.ts.map +1 -1
  83. package/dist/park-envelope.js +3 -2
  84. package/dist/park-envelope.js.map +1 -1
  85. package/dist/register-handler.d.ts +35 -0
  86. package/dist/register-handler.d.ts.map +1 -0
  87. package/dist/register-handler.js +179 -0
  88. package/dist/register-handler.js.map +1 -0
  89. package/dist/registration-manager.d.ts.map +1 -1
  90. package/dist/registration-manager.js +3 -6
  91. package/dist/registration-manager.js.map +1 -1
  92. package/dist/relay-receipt-store.d.ts.map +1 -1
  93. package/dist/relay-receipt-store.js +1 -2
  94. package/dist/relay-receipt-store.js.map +1 -1
  95. package/dist/retry-queue.d.ts +18 -60
  96. package/dist/retry-queue.d.ts.map +1 -1
  97. package/dist/retry-queue.js +46 -97
  98. package/dist/retry-queue.js.map +1 -1
  99. package/dist/seal-coordinator.d.ts +47 -0
  100. package/dist/seal-coordinator.d.ts.map +1 -0
  101. package/dist/seal-coordinator.js +551 -0
  102. package/dist/seal-coordinator.js.map +1 -0
  103. package/dist/seal-flows.d.ts +50 -0
  104. package/dist/seal-flows.d.ts.map +1 -0
  105. package/dist/seal-flows.js +454 -0
  106. package/dist/seal-flows.js.map +1 -0
  107. package/dist/seal-frontier-verify.d.ts +9 -9
  108. package/dist/seal-frontier-verify.d.ts.map +1 -1
  109. package/dist/seal-frontier-verify.js +11 -12
  110. package/dist/seal-frontier-verify.js.map +1 -1
  111. package/dist/seal-leaf.d.ts +58 -0
  112. package/dist/seal-leaf.d.ts.map +1 -0
  113. package/dist/seal-leaf.js +111 -0
  114. package/dist/seal-leaf.js.map +1 -0
  115. package/dist/seal-receipt-upgrade.d.ts +1 -1
  116. package/dist/seal-receipt-upgrade.js +1 -1
  117. package/dist/seal-upgrade.d.ts +10 -10
  118. package/dist/seal-upgrade.d.ts.map +1 -1
  119. package/dist/seal-upgrade.js +23 -24
  120. package/dist/seal-upgrade.js.map +1 -1
  121. package/dist/session-assignment-parser.d.ts +16 -19
  122. package/dist/session-assignment-parser.d.ts.map +1 -1
  123. package/dist/session-assignment-parser.js +30 -29
  124. package/dist/session-assignment-parser.js.map +1 -1
  125. package/dist/session-ceremony.d.ts +3 -6
  126. package/dist/session-ceremony.d.ts.map +1 -1
  127. package/dist/session-ceremony.js +7 -9
  128. package/dist/session-ceremony.js.map +1 -1
  129. package/dist/session-content-handlers.d.ts +25 -0
  130. package/dist/session-content-handlers.d.ts.map +1 -0
  131. package/dist/session-content-handlers.js +436 -0
  132. package/dist/session-content-handlers.js.map +1 -0
  133. package/dist/session-name.d.ts +35 -0
  134. package/dist/session-name.d.ts.map +1 -0
  135. package/dist/session-name.js +60 -0
  136. package/dist/session-name.js.map +1 -0
  137. package/dist/session-node-manager.d.ts +26 -62
  138. package/dist/session-node-manager.d.ts.map +1 -1
  139. package/dist/session-node-manager.js +115 -92
  140. package/dist/session-node-manager.js.map +1 -1
  141. package/dist/session-read-handlers.d.ts +38 -0
  142. package/dist/session-read-handlers.d.ts.map +1 -0
  143. package/dist/session-read-handlers.js +233 -0
  144. package/dist/session-read-handlers.js.map +1 -0
  145. package/dist/session-relay-client.d.ts +8 -8
  146. package/dist/session-relay-client.d.ts.map +1 -1
  147. package/dist/session-relay-client.js +44 -46
  148. package/dist/session-relay-client.js.map +1 -1
  149. package/dist/session-tree.d.ts +11 -23
  150. package/dist/session-tree.d.ts.map +1 -1
  151. package/dist/session-tree.js +14 -26
  152. package/dist/session-tree.js.map +1 -1
  153. package/dist/signaling-connect.d.ts +2 -5
  154. package/dist/signaling-connect.d.ts.map +1 -1
  155. package/dist/signaling-connect.js +7 -12
  156. package/dist/signaling-connect.js.map +1 -1
  157. package/dist/sqlcipher-db.d.ts +18 -19
  158. package/dist/sqlcipher-db.d.ts.map +1 -1
  159. package/dist/sqlcipher-db.js +30 -30
  160. package/dist/sqlcipher-db.js.map +1 -1
  161. package/dist/telegram-doorbell.d.ts +38 -0
  162. package/dist/telegram-doorbell.d.ts.map +1 -0
  163. package/dist/telegram-doorbell.js +139 -0
  164. package/dist/telegram-doorbell.js.map +1 -0
  165. package/dist/types.d.ts +86 -79
  166. package/dist/types.d.ts.map +1 -1
  167. package/dist/types.js +0 -1
  168. package/dist/types.js.map +1 -1
  169. package/dist/vocabulary.d.ts +30 -30
  170. package/dist/vocabulary.d.ts.map +1 -1
  171. package/dist/vocabulary.js +41 -49
  172. package/dist/vocabulary.js.map +1 -1
  173. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,MAAM,EACN,eAAe,EACf,UAAU,EACV,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACtG,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzG,OAAO,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACpI,OAAO,EAAE,eAAe,EAAE,KAA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xB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kCAAkC,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAK7G,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,aAAa,EACb,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC"}
package/dist/index.js CHANGED
@@ -8,22 +8,20 @@ export { connectToDaemon, IpcError } from "./ipc-client.js";
8
8
  export { connectOrStart } from "./connect-or-start.js";
9
9
  export { RetryQueue, RETRY_QUEUE_CAP } from "./retry-queue.js";
10
10
  export { NonceDedupStore, NONCE_DEDUP_CAP } from "./nonce-dedup.js";
11
- // CELLO-M7-TRANSPORT-001: direct-P2P transport selection with relay fallback + dcutr
11
+ // Direct-P2P transport selection with relay fallback + dcutr
12
12
  export { TransportSelector, LocalTransportSelectorStub, TRANSPORT_ERROR, DEFAULT_DIRECT_DIAL_TIMEOUT_MS, selectAdvertisedAddress, } from "./transport-selector.js";
13
- // M7-MANIFEST-002: manifest loading, verification, and polling
13
+ // Manifest loading, verification, and polling
14
14
  export { FileManifestProvider } from "./manifest-loader.js";
15
15
  export { RandomizedPollScheduler, ImmediatePollScheduler } from "./manifest-poll-scheduler.js";
16
16
  export { InMemoryManifestVersionStore } from "./manifest-version-store.js";
17
17
  export { DbManifestVersionStore } from "./manifest-version-store-db.js";
18
18
  export { ManifestDirectoryChallengeVerifier, TestDirectoryChallengeVerifier } from "./challenge-verifier.js";
19
- // DOD-ONBOARD-HELP-1 §2b — the ONE vocabulary (capability → {cli, mcp}). Exported so the CLI
20
- // registry and the connect shim's audit test derive their names from the SAME table the daemon
21
- // renders its guidance from, instead of three lists of literals that drift.
19
+ // The ONE vocabulary (capability → {cli, mcp}). Exported so the CLI registry and the connect shim's
20
+ // audit test derive their names from the SAME table the daemon renders its guidance from, instead of
21
+ // three lists of literals that drift.
22
22
  export { DUAL_SURFACE_VERBS, MCP_ONLY_TOOLS, NON_TOOL_IDENTIFIERS, DEAD_CLI_VERBS, deadCliVerbPattern, RENAMED_AWAY_TOOLS, knownToolNames, toCliGuidance, renderForSurface, } from "./vocabulary.js";
23
- // The FROST/DKG directory-node client. This lives in the daemon because the daemon is the only
24
- // process that runs a ceremony it reimplements natively what the retired @cello-protocol/client
25
- // used to own (daemon.ts: "the daemon never imports @cello-protocol/client"). Exported so
26
- // trustless-cello's directory tests can drive a real DKG against a real directory without
27
- // resurrecting the dead client package they used to import this from.
23
+ // The FROST/DKG directory-node client. It lives in the daemon because the daemon is the only process
24
+ // that runs a ceremony, and the daemon never imports @cello-protocol/client. Exported so
25
+ // trustless-cello's directory tests can drive a real DKG against a real directory.
28
26
  export { NetworkDirectoryNode, bootstrapNetworkKeyShares, runNetworkDkg, runNetworkRefresh, } from "./network-directory-node.js";
29
27
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,W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AC;AACxE,OAAO,EAAE,kCAAkC,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAE7G,oGAAoG;AACpG,qGAAqG;AACrG,sCAAsC;AACtC,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,GAGjB,MAAM,iBAAiB,CAAC;AAEzB,qGAAqG;AACrG,yFAAyF;AACzF,mFAAmF;AACnF,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,aAAa,EACb,iBAAiB,GAClB,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { IpcHandler } from "./ipc-server.js";
2
+ import type { SessionNodeManager, RelayConnectParams } from "./session-node-manager.js";
3
+ import type { Logger } from "./types.js";
4
+ import type { ConnState } from "./contact-handlers.js";
5
+ import { type ITransportSelector, type SessionNegotiator } from "./transport-selector.js";
6
+ import type { SessionAssignment } from "@cello-protocol/protocol-types";
7
+ import type { IAutoNatService } from "@cello-protocol/transport";
8
+ export interface InitiateSessionDeps {
9
+ handlers: Map<string, IpcHandler>;
10
+ logger: Logger;
11
+ sessionNodeManager: SessionNodeManager;
12
+ getConnState: (connectionId: string) => ConnState | undefined;
13
+ resolveCurrentAgent: (connState: ConnState | undefined, explicitAgent?: string) => string | null;
14
+ NO_CURRENT_AGENT_RESPONSE: unknown;
15
+ resolvedSessionNegotiator: SessionNegotiator;
16
+ transportSelector: ITransportSelector;
17
+ autoNatService: IAutoNatService;
18
+ buildRelayConnectParams: (agentName: string, assignment: SessionAssignment) => Promise<RelayConnectParams | undefined>;
19
+ getRelayCircuitAddress?: () => string;
20
+ }
21
+ export declare function registerInitiateSessionHandler(deps: InitiateSessionDeps): void;
22
+ //# sourceMappingURL=initiate-session-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initiate-session-handler.d.ts","sourceRoot":"","sources":["../src/initiate-session-handler.ts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+ *
4
+ * Asks the negotiator to find the counterparty and broker a session (cross-node if they live on a
5
+ * different directory node), then stands up the local session node and the relay witness.
6
+ *
7
+ * The relay witness is BEST-EFFORT by design: a session with no relay still runs on the direct
8
+ * content path. Degraded, never blocked — refusing to open a session because the witness is
9
+ * unavailable would hand any relay outage a veto over the whole protocol.
10
+ */
11
+ import { randomUUID } from "node:crypto";
12
+ import { selectAdvertisedAddress } from "./transport-selector.js";
13
+ import { TIER } from "./contacts-tier-migration.js";
14
+ export function registerInitiateSessionHandler(deps) {
15
+ const { handlers, logger, sessionNodeManager, getConnState, resolveCurrentAgent, NO_CURRENT_AGENT_RESPONSE, resolvedSessionNegotiator, transportSelector, autoNatService, buildRelayConnectParams, getRelayCircuitAddress, } = deps;
16
+ // ─── CELLO-M7-TRANSPORT-001: cello_initiate_session ─────────────────────────
17
+ // Direct-P2P-by-default transport selection (AC-005/AC-006/AC-008/AC-010c).
18
+ // Flow:
19
+ // 1. Require a current agent.
20
+ // 2. Mint a correlationId for the whole session-establishment flow.
21
+ // 3. Read the standing receiver's AutoNAT dialability → choose the advertised
22
+ // address (direct when dialable, relay circuit otherwise — AC-004/AC-019).
23
+ // 4. Negotiate the FROST-signed SessionAssignment via the directory
24
+ // (sessionNegotiator — WIRE-001/SIGNAL-001). When no negotiator is wired,
25
+ // return directory_signaling_not_configured (graceful — the transport
26
+ // adapters ARE wired; this proves it does not crash with "adapter not wired").
27
+ // 5. Drive the transport selector to dial the counterparty using the
28
+ // assignment's authoritative transport_mode (SI-001). Map the TransportResult
29
+ // to the MCP response.
30
+ handlers.set("cello_initiate_session", async (params, connectionId) => {
31
+ const connState = getConnState(connectionId);
32
+ // CC-3 / M8C-AUTOSTART-1 F18: resolve the target agent — explicit { agent } wins, else this
33
+ // connection's current agent, else the sole online agent (removes the no_current_agent papercut
34
+ // after a /mcp reconnect when exactly one agent is online). 2+ online with none selected → null.
35
+ const agentName = resolveCurrentAgent(connState, params?.agent);
36
+ if (!agentName) {
37
+ return NO_CURRENT_AGENT_RESPONSE;
38
+ }
39
+ const correlationId = randomUUID();
40
+ // AC-004/AC-019: the advertised address is chosen from the standing receiver's
41
+ // current dialability. Not dialable (or AutoNAT unavailable) → relay circuit.
42
+ const dialability = autoNatService.getDialability();
43
+ const relayCircuitAddr = getRelayCircuitAddress ? getRelayCircuitAddress() : "";
44
+ const advertisedAddress = selectAdvertisedAddress(dialability, relayCircuitAddr);
45
+ // resolvedSessionNegotiator is always defined (the daemon builds a real internal
46
+ // negotiator when none is injected), so directory_signaling_not_configured no longer
47
+ // fires on the live binary — session_request is actually negotiated with the directory.
48
+ const negotiation = await resolvedSessionNegotiator.negotiate({
49
+ agentName,
50
+ correlationId,
51
+ advertisedAddress,
52
+ params: params ?? {},
53
+ });
54
+ if (!negotiation.ok) {
55
+ return { ok: false, reason: negotiation.reason, guidance: negotiation.guidance };
56
+ }
57
+ // SI-001: the selector consumes the assignment's signed transport_mode as the
58
+ // sole dial authority — never inferred from address format.
59
+ const assignment = negotiation.assignment;
60
+ // M8B F13: validate-what-you-receive at the trust boundary. When the responder cannot
61
+ // proceed it aborts SILENTLY (session-ceremony.ts wireSessionOfferHandler sends nothing)
62
+ // and the directory folds an EMPTY counterparty endpoint into the FROST-signed
63
+ // assignment. Accepting that assignment produced a false ok:true + a phantom session
64
+ // whose failure only surfaced on the first cello_send. Reject it HERE — before any
65
+ // local session state exists — covering every cause of a missing accept (abort,
66
+ // offline, crash, timeout) without needing a directory change.
67
+ if (!assignment.counterparty_session_peer_id) {
68
+ logger.warn("session.initiate.counterparty_unavailable", {
69
+ sessionId: Buffer.from(assignment.session_id).toString("hex"),
70
+ agentName,
71
+ correlationId,
72
+ });
73
+ return {
74
+ ok: false,
75
+ reason: "counterparty_unavailable",
76
+ guidance: "The counterparty did not accept the session offer (it may be offline or unable to receive). No session was established. Verify the counterparty agent is online (its operator can check cello_status), then retry cello_initiate_session.",
77
+ };
78
+ }
79
+ const result = await transportSelector.dial(assignment, { correlationId });
80
+ const sessionId = Buffer.from(assignment.session_id).toString("hex");
81
+ if (!result.ok) {
82
+ // Terminal: both direct and relay failed (AC-008). Pass the error through.
83
+ return { ok: false, reason: result.reason, guidance: result.guidance };
84
+ }
85
+ // SEAM (initiate → DAEMON-004 session-core): transport is now established, but the
86
+ // session does not yet exist in the daemon's session-core. Without this, initiate
87
+ // would set up a connection no session can use and a subsequent cello_send would
88
+ // report session_not_found. Create the DAEMON-004 session node + DB row, bound (via
89
+ // its connection gater) to the counterparty's negotiated session peer id, so the
90
+ // session is queryable and usable (cello_send / cello_receive / cello_close_session).
91
+ //
92
+ // NOTE (seam 1b, next): the session node N_A created here does NOT yet share the
93
+ // connection that transportSelector.dial established on the separate transportDialer
94
+ // node — so its content newStream cannot ride that link until the dial is routed
95
+ // THROUGH N_A. Tracked as the dialer/session-node reconciliation; this seam only
96
+ // establishes that initiate creates the session-core session.
97
+ // The initiator's session row must record WHO this session is with, so an interrupted
98
+ // initiator session surfaces its counterparty at next login (DOD-INT-1). The public
99
+ // tool param is `target_pubkey` (the counterparty's K_local) — the same field the
100
+ // negotiator reads above; `counterparty_pubkey` is the legacy fallback. Reading only
101
+ // the legacy field stored an EMPTY counterparty on every initiator session.
102
+ const counterpartyPubkey = typeof params?.target_pubkey === "string"
103
+ ? params.target_pubkey
104
+ : typeof params?.counterparty_pubkey === "string"
105
+ ? params.counterparty_pubkey
106
+ : "";
107
+ const counterpartyPeerId = assignment.counterparty_session_peer_id ?? "";
108
+ // M7 DOD-SPINE-6 / MSG-001-3b: relay witness params from the FROST-signed assignment
109
+ // + this agent's K_local. N_A connects to the relay and submits message-leaf hashes.
110
+ const relayParams = await buildRelayConnectParams(agentName, assignment);
111
+ const created = await sessionNodeManager.createSessionNode(sessionId, agentName, counterpartyPubkey, counterpartyPeerId, correlationId,
112
+ // Reuse the standing receiver as N_A so its peer id matches the session endpoint the
113
+ // negotiator advertised — the counterparty's gater admits the dial (WIRE-002).
114
+ true, relayParams);
115
+ if (!created.ok) {
116
+ return { ok: false, reason: created.reason, guidance: created.guidance };
117
+ }
118
+ // SEAM 1b: the session node N_A must hold the connection its content stream rides — so
119
+ // dial the counterparty THROUGH N_A. The counterparty's advertised SESSION addresses are
120
+ // the source of truth for dialability (a NATed node advertises a relay-circuit address; a
121
+ // directly-reachable one — localhost or a public addr — advertises a direct multiaddr), so
122
+ // attempt the dial whenever the assignment carries counterparty session addrs, regardless
123
+ // of the transport_mode LABEL (the local selector stub labels everything "relay" even when
124
+ // the addrs are directly dialable). A failure is NOT fatal: per the dead-channel contract,
125
+ // the session stays active and a later cello_send queues the content in the durable retry
126
+ // queue until a route exists (the relay-park path is MSG-001-3b).
127
+ const counterpartyAddrs = assignment.counterparty_session_addrs ?? [];
128
+ if (counterpartyAddrs.length > 0) {
129
+ const connected = await sessionNodeManager.connectToCounterparty(agentName, sessionId, counterpartyAddrs);
130
+ if (!connected.ok) {
131
+ logger.warn("session.initiate.connect.failed", {
132
+ sessionId,
133
+ reason: connected.reason,
134
+ error: connected.error,
135
+ transportMode: assignment.transport_mode,
136
+ correlationId,
137
+ });
138
+ }
139
+ }
140
+ // M8C-CONTACT-1 (D6): "initiating a session to X adds X" — pin at the pubkey the negotiator
141
+ // actually used (not re-resolved later). DOD-TIER-4 AC3: a deliberate outbound initiate makes the
142
+ // counterparty KNOWN, provenance 'initiated'. (Not WHITELISTED — auto-accept stays an explicit
143
+ // cello_contact_set_tier act, design §1.)
144
+ sessionNodeManager.addContact(agentName, counterpartyPubkey, undefined, "initiated", TIER.KNOWN);
145
+ // AC-007: the session is usable immediately upon (relay) connection — the dcutr
146
+ // upgrade runs in the background and is intentionally NOT awaited here.
147
+ return { ok: true, sessionId, transportMode: result.mode, correlationId };
148
+ });
149
+ }
150
+ //# sourceMappingURL=initiate-session-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initiate-session-handler.js","sourceRoot":"","sources":["../src/initiate-session-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,U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,CAAC,0BAA0B,IAAI,EAAE,CAAC;QACtE,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,SAAS,GAAG,MAAM,kBAAkB,CAAC,qBAAqB,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;YAC1G,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;gBAClB,MAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE;oBAC7C,SAAS;oBACT,MAAM,EAAE,SAAS,CAAC,MAAM;oBACxB,KAAK,EAAE,SAAS,CAAC,KAAK;oBACtB,aAAa,EAAE,UAAU,CAAC,cAAc;oBACxC,aAAa;iBACd,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,4FAA4F;QAC5F,kGAAkG;QAClG,+FAA+F;QAC/F,0CAA0C;QAC1C,kBAAkB,CAAC,UAAU,CAAC,SAAS,EAAE,kBAAkB,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAEjG,gFAAgF;QAChF,wEAAwE;QACxE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -41,8 +41,8 @@ export declare class NetworkDirectoryNode implements DirectoryNodeStub {
41
41
  * /cello/frost/1.0.0 network protocol. Returns a FrostThresholdSigner configured
42
42
  * to use NetworkDirectoryNodes, plus the primaryPubkey.
43
43
  *
44
- * NODE_ENV=test guard is kept because this still uses the trustedDealer shortcut.
45
- * Real DKG (M3) will replace this entirely.
44
+ * TEST-ONLY: this uses the trustedDealer shortcut, so it is guarded by NODE_ENV=test. The production
45
+ * path is runNetworkDkg.
46
46
  */
47
47
  export declare function bootstrapNetworkKeyShares(agentPubkey: Uint8Array, opts: {
48
48
  threshold: number;
@@ -79,14 +79,14 @@ export declare function runNetworkDkg(agentPubkey: Uint8Array, opts: {
79
79
  threshold: number;
80
80
  participants: number;
81
81
  directoryNodes: NetworkDirectoryNode[];
82
- /** OPS-AGENT-001: Pre-authorization token to present in Round 1 frame. */
82
+ /** Pre-authorization token to present in the Round 1 frame. */
83
83
  preAuthToken?: string;
84
- /** SEC-2: K_local signer for the DKG-time commit/sign requests' auth. */
84
+ /** K_local signer for the DKG-time commit/sign requests' auth. */
85
85
  signAuth?: FrostAuthSigner;
86
86
  }): Promise<{
87
87
  signer: FrostThresholdSigner;
88
88
  primaryPubkey: Uint8Array;
89
- /** PERSIST-024: serializable FROST share data for DB persistence. SI-001: never log signingShare. */
89
+ /** Serializable FROST share data for DB persistence. NEVER log signingShare. */
90
90
  signingShare: Uint8Array;
91
91
  identifier: string;
92
92
  commitments: Uint8Array[];
@@ -104,7 +104,7 @@ export declare function runNetworkRefresh(agentPubkey: Uint8Array, opts: {
104
104
  participants: number;
105
105
  directoryNodes: NetworkDirectoryNode[];
106
106
  fromEpochN: number;
107
- /** SEC-2: K_local signer for any commit/sign auth during the refresh. */
107
+ /** K_local signer for any commit/sign auth during the refresh. */
108
108
  signAuth?: FrostAuthSigner;
109
109
  }): Promise<{
110
110
  toEpochN: number;
@@ -1 +1 @@
1
- {"version":3,"file":"network-directory-node.d.ts","sourceRoot":"","sources":["../src/network-directory-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAiB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAS7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,cAAc,EAEf,MAAM,uCAAuC,CAAC;AA4B/C,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAQxE,qBAAa,oBAAqB,YAAW,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AAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAC7C,CAAC,CA2DD"}
@@ -10,7 +10,8 @@
10
10
  * frost_sign_request: ask directory to compute a partial signature
11
11
  */
12
12
  import { createHash } from "node:crypto";
13
- import { Encoder, decode as cborDecode } from "cbor-x";
13
+ import { decode as cborDecode } from "cbor-x";
14
+ import { encodeCbor } from "@cello-protocol/protocol-types";
14
15
  import * as lp from "it-length-prefixed";
15
16
  import { ed25519_FROST, FrostThresholdSigner } from "@cello-protocol/crypto";
16
17
  import { bootstrapKeyShares, storeDkgResult, getClientFrostIdentifier, getClientRefreshRoster, generateClientRefreshContribution, applyRefreshToLocalShare, } from "@cello-protocol/crypto/frost/frost-threshold-signer.js";
@@ -21,7 +22,6 @@ const NOOP_LOGGER = {
21
22
  debug: () => { },
22
23
  };
23
24
  const FROST_PROTOCOL_ID = "/cello/frost/1.0.0";
24
- const CBOR_ENC = new Encoder({ tagUint8Array: false });
25
25
  const FROST_AUTH_DOMAIN = "CELLO-FROST-AUTH-v1";
26
26
  // Domain separation (must match the directory's verifyFrostAuth): 0x00 = commit; 0x01 || framedMsg = sign.
27
27
  const FROST_AUTH_COMMIT_TAIL = new Uint8Array([0x00]);
@@ -36,7 +36,7 @@ export class NetworkDirectoryNode {
36
36
  // Set during bootstrapKeyShares — used to identify which agent's share to retrieve
37
37
  #agentPubkeyHex = null;
38
38
  #epochId = null;
39
- // SEC-2: signs the K_local auth on commit/sign requests (set via setBootstrapContext).
39
+ // Signs the K_local auth on commit/sign requests (set via setBootstrapContext).
40
40
  #signAuth = null;
41
41
  // Stored during receiveShare — used by tests to get the FrostPublic for signRound calls
42
42
  #lastPub = null;
@@ -72,7 +72,7 @@ export class NetworkDirectoryNode {
72
72
  commitments: pub.commitments,
73
73
  verifyingShares: pub.verifyingShares,
74
74
  };
75
- const frame = CBOR_ENC.encode({
75
+ const frame = encodeCbor({
76
76
  type: "frost_bootstrap",
77
77
  agentPubkey: this.#agentPubkeyHex,
78
78
  epochId: this.#epochId,
@@ -105,7 +105,7 @@ export class NetworkDirectoryNode {
105
105
  this.#logger.debug("frost.directory.commitment.abort", { reason: "missing_context", hasAgent: !!this.#agentPubkeyHex, hasEpochId: !!this.#epochId });
106
106
  throw new Error("NetworkDirectoryNode: setBootstrapContext must be called before generateCommitment");
107
107
  }
108
- const frame = CBOR_ENC.encode({
108
+ const frame = encodeCbor({
109
109
  type: "frost_commit_request",
110
110
  agentPubkey: this.#agentPubkeyHex,
111
111
  epochId: this.#epochId,
@@ -143,7 +143,7 @@ export class NetworkDirectoryNode {
143
143
  this.#logger.debug("frost.directory.sign.abort", { reason: "missing_context" });
144
144
  throw new Error("NetworkDirectoryNode: setBootstrapContext must be called before signRound");
145
145
  }
146
- const frame = CBOR_ENC.encode({
146
+ const frame = encodeCbor({
147
147
  type: "frost_sign_request",
148
148
  agentPubkey: this.#agentPubkeyHex,
149
149
  epochId: this.#epochId,
@@ -151,7 +151,7 @@ export class NetworkDirectoryNode {
151
151
  commitmentList: params.commitmentList,
152
152
  ceremonyId: params.ceremonyId,
153
153
  peerIdString: params.ceremonyId,
154
- // SEC-2: bound to THIS framedMsg, with the 0x01 sign-frame domain-separation prefix.
154
+ // Bound to THIS framedMsg, with the 0x01 sign-frame domain-separation prefix.
155
155
  authSig: await this.#buildAuthSig(Buffer.concat([Buffer.from([FROST_AUTH_SIGN_PREFIX]), Buffer.from(params.msg)])),
156
156
  });
157
157
  this.#logger.debug("frost.directory.sign.stream.opening", {});
@@ -178,16 +178,16 @@ export class NetworkDirectoryNode {
178
178
  }
179
179
  return null;
180
180
  }
181
- // Called by the network-aware bootstrapKeyShares before distributing shares. SEC-2: `signAuth`
182
- // is the agent's K_local signer, used to authenticate every subsequent commit/sign request; every
183
- // ceremony path (session/seal, DKG, refresh) passes it so the enforcing directory accepts the request.
181
+ // Called by the network-aware bootstrapKeyShares before distributing shares. `signAuth` is the
182
+ // agent's K_local signer, used to authenticate every subsequent commit/sign request; EVERY ceremony
183
+ // path (session/seal, DKG, refresh) must pass it or the enforcing directory refuses the request.
184
184
  setBootstrapContext(agentPubkeyHex, epochId, signAuth) {
185
185
  this.#agentPubkeyHex = agentPubkeyHex;
186
186
  this.#epochId = epochId;
187
187
  if (signAuth)
188
188
  this.#signAuth = signAuth;
189
189
  }
190
- // SEC-2: hash bound by the directory's verifyFrostAuth. tail = utf8("commit") | framedMsg.
190
+ // Hash bound by the directory's verifyFrostAuth. tail = utf8("commit") | framedMsg.
191
191
  #frostAuthHash(tail) {
192
192
  return new Uint8Array(createHash("sha256")
193
193
  .update(Buffer.concat([
@@ -198,8 +198,8 @@ export class NetworkDirectoryNode {
198
198
  ]))
199
199
  .digest());
200
200
  }
201
- // SEC-2: the K_local auth signature to attach, or undefined if no signer was threaded (which the
202
- // enforcing directory then refuses AUTH_REQUIRED surfacing an un-threaded path loudly, not silently).
201
+ // The K_local auth signature to attach, or undefined if no signer was threaded which the enforcing
202
+ // directory then refuses with AUTH_REQUIRED, surfacing an un-threaded path loudly, not silently.
203
203
  async #buildAuthSig(tail) {
204
204
  if (!this.#signAuth) {
205
205
  this.#logger.warn("frost.directory.auth.no_signer", { agent: this.#agentPubkeyHex?.slice(0, 16), epochId: this.#epochId });
@@ -244,12 +244,12 @@ export class NetworkDirectoryNode {
244
244
  * Opens a new stream, sends frost_dkg_round1_request, returns the broadcast.
245
245
  */
246
246
  async function dkgRound1WithNode(node, agentPubkeyHex, epochId, signers, preAuthToken) {
247
- const frame = CBOR_ENC.encode({
247
+ const frame = encodeCbor({
248
248
  type: "frost_dkg_round1_request",
249
249
  agentPubkey: agentPubkeyHex,
250
250
  epochId,
251
251
  signers,
252
- // OPS-AGENT-001: include preAuthToken when present (mandatory in M6+)
252
+ // Include preAuthToken when present.
253
253
  ...(preAuthToken !== undefined ? { preAuthToken } : {}),
254
254
  });
255
255
  const stream = await node.openStream();
@@ -278,7 +278,7 @@ async function dkgRound1WithNode(node, agentPubkeyHex, epochId, signers, preAuth
278
278
  * Opens a new stream, sends frost_dkg_round2_request, returns sharesForOthers.
279
279
  */
280
280
  async function dkgRound2WithNode(node, agentPubkeyHex, epochId, othersRound1) {
281
- const frame = CBOR_ENC.encode({
281
+ const frame = encodeCbor({
282
282
  type: "frost_dkg_round2_request",
283
283
  agentPubkey: agentPubkeyHex,
284
284
  epochId,
@@ -311,7 +311,7 @@ async function dkgRound2WithNode(node, agentPubkeyHex, epochId, othersRound1) {
311
311
  * Opens a new stream, sends frost_dkg_round3_request, returns shareCommitment.
312
312
  */
313
313
  async function dkgRound3WithNode(node, agentPubkeyHex, epochId, sharesForMe, allRound1) {
314
- const frame = CBOR_ENC.encode({
314
+ const frame = encodeCbor({
315
315
  type: "frost_dkg_round3_request",
316
316
  agentPubkey: agentPubkeyHex,
317
317
  epochId,
@@ -355,7 +355,8 @@ function parseDkgRound1Response(bytes) {
355
355
  if (typeof obj !== "object" || obj === null)
356
356
  return { kind: "invalid" };
357
357
  const o = obj;
358
- // Handle preauth_error frames from the directory (CRIT-1: previously silently dropped)
358
+ // preauth_error frames from the directory MUST be surfaced, never dropped as "invalid" — a silently
359
+ // discarded rejection reads to the caller as a malformed frame instead of a refused authorization.
359
360
  if (o["type"] === "preauth_error") {
360
361
  const reason = typeof o["reason"] === "string" ? o["reason"] : "PRE_AUTH_TOKEN_MISSING";
361
362
  return { kind: "preauth_error", reason };
@@ -474,12 +475,12 @@ function parseU8Array(v) {
474
475
  * /cello/frost/1.0.0 network protocol. Returns a FrostThresholdSigner configured
475
476
  * to use NetworkDirectoryNodes, plus the primaryPubkey.
476
477
  *
477
- * NODE_ENV=test guard is kept because this still uses the trustedDealer shortcut.
478
- * Real DKG (M3) will replace this entirely.
478
+ * TEST-ONLY: this uses the trustedDealer shortcut, so it is guarded by NODE_ENV=test. The production
479
+ * path is runNetworkDkg.
479
480
  */
480
481
  export async function bootstrapNetworkKeyShares(agentPubkey, opts) {
481
- // bootstrapKeyShares uses trustedDealer — a test-harness shortcut, not real DKG (M3+).
482
- // This function inherits that constraint. The caller (cello-mcp.ts) guards with NODE_ENV=test.
482
+ // bootstrapKeyShares uses trustedDealer — a test-harness shortcut, not a real DKG. This function
483
+ // inherits that constraint, so it must never run outside tests.
483
484
  if (process.env.NODE_ENV !== "test") {
484
485
  throw new Error("bootstrapNetworkKeyShares uses trustedDealer which is test-only. Real DKG (M3) required in production.");
485
486
  }
@@ -633,8 +634,8 @@ export async function runNetworkDkg(agentPubkey, opts) {
633
634
  }
634
635
  catch { /* ignore */ }
635
636
  // Set signing context on each directory node so generateCommitment/signRound can
636
- // identify which agent's share to use in future FROST signing ceremonies. SEC-2: thread the
637
- // K_local signer so the DKG-time and later signing requests carry a valid auth.
637
+ // identify which agent's share to use in future FROST signing ceremonies. The K_local signer MUST be
638
+ // threaded here so the DKG-time and later signing requests carry a valid auth.
638
639
  for (const node of opts.directoryNodes) {
639
640
  node.setBootstrapContext(agentPubkeyHex, epochId, opts.signAuth);
640
641
  }
@@ -644,7 +645,7 @@ export async function runNetworkDkg(agentPubkey, opts) {
644
645
  participants: opts.participants,
645
646
  directoryNodeStubs: opts.directoryNodes,
646
647
  }, agentPubkey);
647
- // PERSIST-024: extract serializable FROST share data for DB persistence (SI-001: never log signingShare)
648
+ // Extract serializable FROST share data for DB persistence. NEVER log signingShare.
648
649
  const serializedSecret = clientKey.secret;
649
650
  const serializedPub = clientKey.public;
650
651
  return {
@@ -658,13 +659,13 @@ export async function runNetworkDkg(agentPubkey, opts) {
658
659
  participants: opts.participants,
659
660
  };
660
661
  }
661
- // ─── M8B DOD-REFRESH-1: proactive share resharing (PSS) orchestration ─────────
662
+ // ─── Proactive share resharing (PSS) orchestration ─────────
662
663
  // A client-coordinated 2-round refresh that rotates every shareholder's share to a new epoch while keeping
663
664
  // the group public key unchanged (frost-resharing.ts). The client is the UNIFORM RELAY: it collects one
664
665
  // contribution per node (round 1) and distributes the agreed set — narrowed to each node's own sub-share
665
666
  // (round 2) — so a directory cannot equivocate and a node never sees another party's sub-shares.
666
667
  async function refreshRound1WithNode(node, agentPubkeyHex, fromEpochId, toEpochId, signers, participantIds) {
667
- const frame = CBOR_ENC.encode({
668
+ const frame = encodeCbor({
668
669
  type: "frost_refresh_round1_request",
669
670
  agentPubkey: agentPubkeyHex,
670
671
  fromEpochId,
@@ -691,7 +692,7 @@ async function refreshRound1WithNode(node, agentPubkeyHex, fromEpochId, toEpochI
691
692
  throw new Error("refreshRound1: no response received");
692
693
  }
693
694
  async function refreshRound2WithNode(node, agentPubkeyHex, fromEpochId, toEpochId, signers, participantIds, contributions) {
694
- const frame = CBOR_ENC.encode({
695
+ const frame = encodeCbor({
695
696
  type: "frost_refresh_round2_request",
696
697
  agentPubkey: agentPubkeyHex,
697
698
  fromEpochId,