@cello-protocol/client 0.0.5 → 0.0.6

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.
package/dist/client.d.ts CHANGED
@@ -162,10 +162,15 @@ export declare function createClient(node: CelloNode, keyProvider: KeyProvider,
162
162
  }): void;
163
163
  /** CONNREQ-002: list active connection records. */
164
164
  listConnections(): import("@cello-protocol/protocol-types").ClientConnectionRecord[];
165
- /** CONNREQ-002: send connection_request to target B and await final outcome. */
165
+ /** CONNREQ-002 / AC-008 (DX-001): send connection_request to target B and await final outcome.
166
+ * Per-stage timeouts: dialTimeoutMs (stage 'dial'), sendTimeoutMs (stage 'send'),
167
+ * waitTimeoutMs (stage 'wait'). Timeout result includes the stage that fired. */
166
168
  cello_request_connection(opts: {
167
169
  target_pubkey: string;
168
170
  package_cbor: Uint8Array;
171
+ dialTimeoutMs?: number;
172
+ sendTimeoutMs?: number;
173
+ waitTimeoutMs?: number;
169
174
  }): Promise<{
170
175
  result: "established";
171
176
  connection_id: string;
@@ -181,6 +186,7 @@ export declare function createClient(node: CelloNode, keyProvider: KeyProvider,
181
186
  requested_items: unknown[];
182
187
  } | {
183
188
  result: "timeout";
189
+ stage: "dial" | "send" | "wait";
184
190
  } | {
185
191
  result: "error";
186
192
  reason: string;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2GG;AAaH,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAA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AG,IAAI,CAAC;IAC7I;;;OAGG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7D,uEAAuE;IACvE,sCAAsC,EAAE,MAAM,CAAC;IAC/C,wFAAwF;IACxF,kBAAkB,EAAE,MAAM,CAAC;IAC3B,8FAA8F;IAC9F,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,wFAAwF;IACxF,sBAAsB,IAAI,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC7F,CA8DA"}
package/dist/client.js CHANGED
@@ -491,13 +491,24 @@ class CelloClientImpl {
491
491
  return;
492
492
  }
493
493
  // Reconstruct FrostThresholdSigner (config only — secret is in module-level store).
494
- // HIGH-1: directoryEndpoint is NOT required for construction — the signer can verify
495
- // signatures even without a live directory. Pass undefined for directoryNodes.
494
+ // AC-003 (DX-001): directoryNodeStubs MUST be populated from the current directoryEndpoint
495
+ // so that the signer can participate in FROST signing ceremonies (round-trip frames
496
+ // to directory via libp2p). Without directoryNodeStubs, the signer can verify but cannot
497
+ // participate in ceremonies — causing directory_below_threshold on session initiation.
496
498
  if (!this.#thresholdSigner) {
499
+ let directoryNodeStubsForSigner;
500
+ if (this.#directoryEndpoint) {
501
+ directoryNodeStubsForSigner = [new NetworkDirectoryNode({
502
+ id: this.#directoryEndpoint.peer_id,
503
+ node: this.#node,
504
+ directoryPeerId: this.#directoryEndpoint.peer_id,
505
+ directoryMultiaddrs: this.#directoryEndpoint.multiaddrs,
506
+ })];
507
+ }
497
508
  this.#thresholdSigner = new FrostThresholdSigner({
498
509
  threshold: row.threshold,
499
510
  participants: row.participants,
500
- directoryNodes: undefined,
511
+ directoryNodeStubs: directoryNodeStubsForSigner,
501
512
  }, Buffer.from(myPubkeyHex, "hex"));
502
513
  }
503
514
  // Set primary_pubkey from stored commitments[0]
@@ -782,6 +793,29 @@ class CelloClientImpl {
782
793
  setHashQueue(queue) {
783
794
  this.#hashQueue = queue;
784
795
  }
796
+ /**
797
+ * AC-003 (DX-001): Set directory endpoint after construction (composition root pattern).
798
+ * Called by cello-mcp.ts background task before loadPersistedState() so that
799
+ * loadPersistedState() can populate directoryNodeStubs in the reconstructed FrostThresholdSigner.
800
+ */
801
+ setDirectoryEndpoint(endpoint) {
802
+ this.#directoryEndpoint = endpoint;
803
+ }
804
+ /**
805
+ * AC-003 (DX-001): Wire threshold signer after construction.
806
+ * Called by cello-mcp.ts background task only when the agent is not yet registered
807
+ * (bootstrap ran). Registered agents reconstruct the signer from DB in loadPersistedState().
808
+ */
809
+ setThresholdSigner(signer) {
810
+ this.#thresholdSigner = signer;
811
+ }
812
+ /**
813
+ * PERSIST-024: Wire persistence layer after construction.
814
+ * Called by cello-mcp.ts background task after SQLCipher store opens.
815
+ */
816
+ setPersistence(persistence) {
817
+ this.#persistence = persistence;
818
+ }
785
819
  addPeer(peerPubkeyHex, peerId, multiaddrs) {
786
820
  this.#peers.set(peerPubkeyHex, { peerId, multiaddrs, connected: true });
787
821
  // PERSIST-024: persist peer to DB
@@ -3189,7 +3223,7 @@ class CelloClientImpl {
3189
3223
  *
3190
3224
  * Crypto refs: NIST FIPS 204 (ML-DSA-44), RFC 9591 (FROST), FIPS 180-4 (SHA-256)
3191
3225
  */
3192
- async register(phoneStub, preAuthToken) {
3226
+ async register(phoneStub = "", preAuthToken) {
3193
3227
  // Step 1: already registered — return error
3194
3228
  if (this.#registrationState) {
3195
3229
  return { error: "already_registered" };
@@ -3765,8 +3799,13 @@ class CelloClientImpl {
3765
3799
  * { result: 'rejected', reason } — target rejected
3766
3800
  * { result: 'insufficient', unmet_requirements } — target found requirements unmet
3767
3801
  * { result: 'disclosure_requested', connection_request_id, requested_items } — Round 2 request (unblocks sender)
3768
- * { result: 'timeout' } — no response within connectionTimeoutMs
3802
+ * { result: 'timeout', stage } — no response within timeout; stage identifies which phase timed out
3769
3803
  * { result: 'error', reason } — directory-level error (not_registered, target_not_found, etc.)
3804
+ *
3805
+ * AC-008 (DX-001): per-stage timeouts:
3806
+ * dialTimeoutMs — stage 'dial': timeout for opening the persistent signaling stream (default: connectionTimeoutMs)
3807
+ * sendTimeoutMs — stage 'send': timeout for sending the frame (default: connectionTimeoutMs)
3808
+ * waitTimeoutMs — stage 'wait': timeout for target response (default: connectionTimeoutMs)
3770
3809
  */
3771
3810
  async cello_request_connection(opts) {
3772
3811
  const targetPubkeyHex = opts.target_pubkey;
@@ -3786,12 +3825,22 @@ class CelloClientImpl {
3786
3825
  resolveOutcome = resolve;
3787
3826
  });
3788
3827
  this.#pendingConnectionRequestResolvers.set(targetPubkeyHex, resolveOutcome);
3789
- // Ensure the persistent signaling stream is open
3828
+ // AC-008 (DX-001): per-stage timeouts. Fall back to #connectionTimeoutMs if not provided.
3829
+ const dialTimeoutMs = opts.dialTimeoutMs ?? this.#connectionTimeoutMs;
3830
+ const sendTimeoutMs = opts.sendTimeoutMs ?? this.#connectionTimeoutMs;
3831
+ const waitTimeoutMs = opts.waitTimeoutMs ?? this.#connectionTimeoutMs;
3832
+ // Stage 1 — dial: Ensure the persistent signaling stream is open within dialTimeoutMs.
3790
3833
  if (!this.#persistentSignalingStream) {
3791
- const opened = await this.#openPersistentSignalingStream();
3792
- if (!opened) {
3834
+ let dialTimedOut = false;
3835
+ let opened = false;
3836
+ await Promise.race([
3837
+ this.#openPersistentSignalingStream().then((result) => { opened = result; }),
3838
+ new Promise((resolve) => setTimeout(() => { dialTimedOut = true; resolve(); }, dialTimeoutMs)),
3839
+ ]);
3840
+ if (dialTimedOut || !opened) {
3793
3841
  this.#pendingConnectionRequestResolvers.delete(targetPubkeyHex);
3794
- return { result: "error", reason: "directory_unreachable" };
3842
+ this.#logger.warn("client.connection.request.stage.timeout", { stage: "dial", timeoutMs: dialTimeoutMs, targetPubkeyOrAgentId: targetPubkeyHex });
3843
+ return { result: "timeout", stage: "dial" };
3795
3844
  }
3796
3845
  }
3797
3846
  // Mint a correlationId for this outbound connection request flow.
@@ -3804,20 +3853,39 @@ class CelloClientImpl {
3804
3853
  target_pubkey: targetPubkeyHex,
3805
3854
  package_cbor: opts.package_cbor,
3806
3855
  });
3807
- try {
3808
- this.#persistentSignalingStream.send(lp.encode.single(frameBytes));
3856
+ // Stage 2 — send: Deliver the frame within sendTimeoutMs.
3857
+ // The .send() call is synchronous but may throw if the stream has disconnected.
3858
+ // Wrap in a race so an unresponsive stream doesn't block indefinitely.
3859
+ let sendTimedOut = false;
3860
+ let sendError = false;
3861
+ await Promise.race([
3862
+ new Promise((resolve) => {
3863
+ try {
3864
+ this.#persistentSignalingStream.send(lp.encode.single(frameBytes));
3865
+ }
3866
+ catch {
3867
+ sendError = true;
3868
+ }
3869
+ resolve();
3870
+ }),
3871
+ new Promise((resolve) => setTimeout(() => { sendTimedOut = true; resolve(); }, sendTimeoutMs)),
3872
+ ]);
3873
+ if (sendTimedOut) {
3874
+ this.#pendingConnectionRequestResolvers.delete(targetPubkeyHex);
3875
+ this.#logger.warn("client.connection.request.stage.timeout", { stage: "send", timeoutMs: sendTimeoutMs, targetPubkeyOrAgentId: targetPubkeyHex });
3876
+ return { result: "timeout", stage: "send" };
3809
3877
  }
3810
- catch {
3878
+ if (sendError) {
3811
3879
  this.#pendingConnectionRequestResolvers.delete(targetPubkeyHex);
3812
3880
  return { result: "error", reason: "directory_unreachable" };
3813
3881
  }
3814
- // Race: outcome vs connectionTimeoutMs
3882
+ // Stage 3 — wait: Race outcome vs waitTimeoutMs (was: connectionTimeoutMs).
3815
3883
  // DB-001: timeout cleans this slot without affecting concurrent requests to other targets.
3816
3884
  let frame = null;
3817
3885
  let timedOut = false;
3818
3886
  await Promise.race([
3819
3887
  outcomePromise.then((f) => { frame = f; }),
3820
- new Promise((resolve) => setTimeout(() => { timedOut = true; resolve(); }, this.#connectionTimeoutMs)),
3888
+ new Promise((resolve) => setTimeout(() => { timedOut = true; resolve(); }, waitTimeoutMs)),
3821
3889
  ]);
3822
3890
  // Clean up this target's resolver slot on timeout
3823
3891
  // (on successful resolution, the signaling reader already deleted it)
@@ -3825,7 +3893,8 @@ class CelloClientImpl {
3825
3893
  this.#pendingConnectionRequestResolvers.delete(targetPubkeyHex);
3826
3894
  }
3827
3895
  if (timedOut || !frame) {
3828
- return { result: "timeout" };
3896
+ this.#logger.warn("client.connection.request.stage.timeout", { stage: "wait", timeoutMs: waitTimeoutMs, targetPubkeyOrAgentId: targetPubkeyHex });
3897
+ return { result: "timeout", stage: "wait" };
3829
3898
  }
3830
3899
  const type = frame["type"];
3831
3900
  if (type === "connection_established") {