@cello-protocol/client 0.0.2
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/agent-hash-queue.d.ts +206 -0
- package/dist/agent-hash-queue.d.ts.map +1 -0
- package/dist/agent-hash-queue.js +380 -0
- package/dist/agent-hash-queue.js.map +1 -0
- package/dist/backup-key-derivation.d.ts +37 -0
- package/dist/backup-key-derivation.d.ts.map +1 -0
- package/dist/backup-key-derivation.js +48 -0
- package/dist/backup-key-derivation.js.map +1 -0
- package/dist/client-backup.d.ts +144 -0
- package/dist/client-backup.d.ts.map +1 -0
- package/dist/client-backup.js +273 -0
- package/dist/client-backup.js.map +1 -0
- package/dist/client.d.ts +249 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +4664 -0
- package/dist/client.js.map +1 -0
- package/dist/connection-policy.d.ts +163 -0
- package/dist/connection-policy.d.ts.map +1 -0
- package/dist/connection-policy.js +248 -0
- package/dist/connection-policy.js.map +1 -0
- package/dist/db-key-derivation.d.ts +26 -0
- package/dist/db-key-derivation.d.ts.map +1 -0
- package/dist/db-key-derivation.js +37 -0
- package/dist/db-key-derivation.js.map +1 -0
- package/dist/encrypted-file-signing-key-provider.d.ts +92 -0
- package/dist/encrypted-file-signing-key-provider.d.ts.map +1 -0
- package/dist/encrypted-file-signing-key-provider.js +251 -0
- package/dist/encrypted-file-signing-key-provider.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.d.ts +270 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +1155 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/network-directory-node.d.ts +85 -0
- package/dist/network-directory-node.d.ts.map +1 -0
- package/dist/network-directory-node.js +584 -0
- package/dist/network-directory-node.js.map +1 -0
- package/dist/s3-cloud-storage-provider.d.ts +54 -0
- package/dist/s3-cloud-storage-provider.d.ts.map +1 -0
- package/dist/s3-cloud-storage-provider.js +78 -0
- package/dist/s3-cloud-storage-provider.js.map +1 -0
- package/dist/sqlcipher-client-store.d.ts +68 -0
- package/dist/sqlcipher-client-store.d.ts.map +1 -0
- package/dist/sqlcipher-client-store.js +382 -0
- package/dist/sqlcipher-client-store.js.map +1 -0
- package/dist/types.d.ts +408 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @cello-protocol/client — types.ts
|
|
3
|
+
*
|
|
4
|
+
* Public types for the CelloClient (MSG-002, SESSION-002, MSG-004, ADAPTER-003).
|
|
5
|
+
*/
|
|
6
|
+
export type SessionStatus = "active" | "transport_lost" | "sealing" | "sealed" | "seal_rejected" | "seal_deferred";
|
|
7
|
+
export interface SessionRecord {
|
|
8
|
+
session_id: Uint8Array;
|
|
9
|
+
counterparty_pubkey: Uint8Array;
|
|
10
|
+
counterparty_peer_id: string;
|
|
11
|
+
counterparty_multiaddrs: string[];
|
|
12
|
+
relay_endpoint: {
|
|
13
|
+
peer_id: string;
|
|
14
|
+
multiaddrs: string[];
|
|
15
|
+
};
|
|
16
|
+
directory_endpoint: {
|
|
17
|
+
peer_id: string;
|
|
18
|
+
multiaddrs: string[];
|
|
19
|
+
};
|
|
20
|
+
directory_pubkey: Uint8Array;
|
|
21
|
+
genesis_prev_root: Uint8Array;
|
|
22
|
+
/**
|
|
23
|
+
* MSG-004: highest global relay sequence_number of *counterparty* leaves confirmed on this session.
|
|
24
|
+
* Used as `last_seen_seq` in the next outbound Structure 1 TBS.
|
|
25
|
+
* Updated only when a counterparty leaf is confirmed (never on own-send echoes).
|
|
26
|
+
* Starts at 0 (no counterparty messages confirmed yet).
|
|
27
|
+
*/
|
|
28
|
+
last_seen_seq: number;
|
|
29
|
+
/**
|
|
30
|
+
* MSG-004: highest global relay sequence_number of *own* leaves echoed back.
|
|
31
|
+
* Used by the client-side causal-chain check: incoming last_seen_seq must be <= this.
|
|
32
|
+
* Updated only when own-send echoes are confirmed.
|
|
33
|
+
* Starts at 0.
|
|
34
|
+
*/
|
|
35
|
+
last_sent_seq: number;
|
|
36
|
+
status: SessionStatus;
|
|
37
|
+
/** Sealed root after seal completes. SESSION-003. */
|
|
38
|
+
sealed_root?: Uint8Array;
|
|
39
|
+
/** Directory-identity signature over the SealNotarization. SESSION-003. MCP-002 AC-004. */
|
|
40
|
+
directory_signature?: Uint8Array;
|
|
41
|
+
/** Unix timestamp (ms) when the seal was confirmed. SESSION-003. MCP-002 AC-004. */
|
|
42
|
+
close_timestamp?: number;
|
|
43
|
+
/**
|
|
44
|
+
* SESSION-005: seal notarization type.
|
|
45
|
+
* 'frost' — directory co-signed via FROST ceremony; fully notarized.
|
|
46
|
+
* 'bilateral' — directory unreachable at seal time; bilateral K_local seal only.
|
|
47
|
+
* Undefined until a seal ceremony completes (status becomes 'sealed' or 'seal_deferred').
|
|
48
|
+
*/
|
|
49
|
+
seal_type?: "frost" | "bilateral" | "unilateral";
|
|
50
|
+
/**
|
|
51
|
+
* SESSION-005: FROST combined signature on the SealNotarization.
|
|
52
|
+
* Populated when seal_type === 'frost'.
|
|
53
|
+
*/
|
|
54
|
+
frost_signature?: Uint8Array;
|
|
55
|
+
/**
|
|
56
|
+
* SESSION-005: signer_pubkey from the session_sealed frame — initiator's primary_pubkey.
|
|
57
|
+
* Used by the counterparty to verify the FROST signature without a directory lookup.
|
|
58
|
+
*/
|
|
59
|
+
signer_pubkey?: Uint8Array;
|
|
60
|
+
/** Ordered list of accepted leaves; used to recompute prev_root locally. MSG-004. */
|
|
61
|
+
local_tree_leaves: Array<{
|
|
62
|
+
kind: "msg" | "ctrl";
|
|
63
|
+
s2_cbor: Uint8Array;
|
|
64
|
+
}>;
|
|
65
|
+
/** Next expected sequence number from the relay (starts at 1). MSG-004. */
|
|
66
|
+
next_expected_seq: number;
|
|
67
|
+
/** Fail-closed flag. Once true all send/receive return session_desynchronized. MSG-004. */
|
|
68
|
+
desynchronized: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Result of receiveSessionAssignment().
|
|
72
|
+
*
|
|
73
|
+
* Failure reasons:
|
|
74
|
+
* relay_auth_failed — relay explicitly rejected the auth response.
|
|
75
|
+
* relay_auth_error — could not open a stream to the relay or read the challenge.
|
|
76
|
+
* dial_counterparty_failed — reserved for future use.
|
|
77
|
+
* unsupported_signature_type — SESSION-004: M1 'single' signature type refused by M2+ clients.
|
|
78
|
+
* frost_signature_invalid — SESSION-004: FROST threshold signature verification failed.
|
|
79
|
+
* frost_signer_not_configured — SESSION-004: initiator has no IThresholdSigner injected;
|
|
80
|
+
* cannot derive verification key for own primary_pubkey.
|
|
81
|
+
*
|
|
82
|
+
* NOTE (SESSION-004 L-5): `directory_signature_invalid` has been removed.
|
|
83
|
+
* It was the M1 Ed25519 single-key failure reason. In M2, `signature_type: 'single'` frames
|
|
84
|
+
* are hard-refused with `unsupported_signature_type` before any signature verification,
|
|
85
|
+
* and FROST signature failures surface as `frost_signature_invalid`. There is no code path
|
|
86
|
+
* that returns `directory_signature_invalid` in M2.
|
|
87
|
+
*/
|
|
88
|
+
export type ReceiveAssignmentResult = {
|
|
89
|
+
ok: true;
|
|
90
|
+
sessionId: Uint8Array;
|
|
91
|
+
} | {
|
|
92
|
+
ok: false;
|
|
93
|
+
reason: "relay_auth_failed" | "relay_auth_error" | "dial_counterparty_failed" | "unsupported_signature_type" | "frost_signature_invalid" | "frost_signer_not_configured";
|
|
94
|
+
};
|
|
95
|
+
export interface PeerEntry {
|
|
96
|
+
/** libp2p transport Peer ID string */
|
|
97
|
+
peerId: string;
|
|
98
|
+
/** multiaddrs for this peer */
|
|
99
|
+
multiaddrs: string[];
|
|
100
|
+
/** whether a live connection exists */
|
|
101
|
+
connected: boolean;
|
|
102
|
+
}
|
|
103
|
+
export type SendFailureReason = "peer_not_connected" | "content_too_large" | "peer_unreachable" | "remote_rejected" | "connection_lost" | "transport_not_started";
|
|
104
|
+
export type SendResult = {
|
|
105
|
+
delivered: true;
|
|
106
|
+
contentHash: string;
|
|
107
|
+
} | {
|
|
108
|
+
delivered: false;
|
|
109
|
+
reason: SendFailureReason;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* A cross-checked, verified message OR lifecycle event delivered from a session.
|
|
113
|
+
* SESSION-007 extends this from a plain message shape to a discriminated union so
|
|
114
|
+
* that session_sealed lifecycle events can be surfaced inline by receiveMessage /
|
|
115
|
+
* receiveAnyMessage without a separate API.
|
|
116
|
+
*/
|
|
117
|
+
export type ReceivedMessage = {
|
|
118
|
+
type: "message";
|
|
119
|
+
content: Uint8Array;
|
|
120
|
+
senderPubkey: Uint8Array;
|
|
121
|
+
sequenceNumber: number;
|
|
122
|
+
/** SHA-256(leaf_kind_byte || structure2_cbor) per MERKLE-001 (RFC 6962). */
|
|
123
|
+
leafHash: Uint8Array;
|
|
124
|
+
/** SESSION-007: other active sessions that have queued messages. */
|
|
125
|
+
otherSessionsPending?: string[];
|
|
126
|
+
} | {
|
|
127
|
+
type: "session_sealed";
|
|
128
|
+
sessionIdHex: string;
|
|
129
|
+
sealedRoot: Uint8Array;
|
|
130
|
+
closeTimestamp: number;
|
|
131
|
+
checkpointStatus: "pending" | "confirmed";
|
|
132
|
+
/** SESSION-007: other active sessions that have queued messages. */
|
|
133
|
+
otherSessionsPending?: string[];
|
|
134
|
+
};
|
|
135
|
+
export type SendMessageFailureReason = "session_not_found" | "session_desynchronized" | "session_sealed" | "transport_unavailable" | "relay_rejected" | "content_path_failed";
|
|
136
|
+
export type SendMessageResult = {
|
|
137
|
+
ok: true;
|
|
138
|
+
} | {
|
|
139
|
+
ok: false;
|
|
140
|
+
reason: SendMessageFailureReason;
|
|
141
|
+
};
|
|
142
|
+
export interface ReceivedEnvelope {
|
|
143
|
+
content: Uint8Array;
|
|
144
|
+
senderPubkey: Uint8Array;
|
|
145
|
+
contentHash: Uint8Array;
|
|
146
|
+
timestamp: number;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Result of initiateSession().
|
|
150
|
+
*
|
|
151
|
+
* Success: session_id and genesis_prev_root from the directory-signed SessionAssignment.
|
|
152
|
+
* Failure reasons:
|
|
153
|
+
* target_offline — directory reports the target pubkey has no authenticated stream.
|
|
154
|
+
* relay_unavailable — directory cannot assign a relay for the session.
|
|
155
|
+
* target_busy — simultaneous initiation: target is already mid-handshake.
|
|
156
|
+
* timeout — no directory response within the configured timeout.
|
|
157
|
+
* directory_unreachable — cannot open or authenticate the signaling stream.
|
|
158
|
+
*/
|
|
159
|
+
export type InitiateSessionResult = {
|
|
160
|
+
ok: true;
|
|
161
|
+
sessionId: Uint8Array;
|
|
162
|
+
genesisPrevRoot: Uint8Array;
|
|
163
|
+
} | {
|
|
164
|
+
ok: false;
|
|
165
|
+
reason: "target_offline" | "relay_unavailable" | "target_busy" | "timeout" | "directory_unreachable" | "frost_signer_not_configured" | "directory_below_threshold" | "ceremony_conflict" | "no_connection";
|
|
166
|
+
};
|
|
167
|
+
export interface CelloClient {
|
|
168
|
+
/**
|
|
169
|
+
* Register this agent with the directory.
|
|
170
|
+
* Generates (or loads) ML-DSA-44 keypair, opens signaling stream, and completes
|
|
171
|
+
* the REG-001 registration ceremony (register_request → register_success).
|
|
172
|
+
*
|
|
173
|
+
* Returns RegistrationState on success, or { error: reason } on failure.
|
|
174
|
+
* Idempotent: second call returns { error: 'already_registered' } if already done.
|
|
175
|
+
*
|
|
176
|
+
* REG-001 AC-001, AC-002, AC-008, AC-010.
|
|
177
|
+
*/
|
|
178
|
+
register(phoneStub: string, preAuthToken?: string): Promise<import("@cello-protocol/protocol-types").RegistrationState | {
|
|
179
|
+
error: string;
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Return the cached registration state, or null if not yet registered.
|
|
183
|
+
* CELLO-MCP-003.
|
|
184
|
+
*/
|
|
185
|
+
getRegistrationState(): import("@cello-protocol/protocol-types").RegistrationState | null;
|
|
186
|
+
/**
|
|
187
|
+
* Return the configured directory peer ID (from CELLO_DIRECTORY_MULTIADDR), or null.
|
|
188
|
+
* Used by directoryReachable() to check live libp2p connection state.
|
|
189
|
+
*/
|
|
190
|
+
getDirectoryPeerId(): string | null;
|
|
191
|
+
/**
|
|
192
|
+
* Set the connection policy for evaluating inbound connection requests.
|
|
193
|
+
* Replaces any previously configured policy.
|
|
194
|
+
* CELLO-MCP-003.
|
|
195
|
+
*/
|
|
196
|
+
setPolicy(policy: import("./connection-policy.js").SignalRequirementPolicy): void;
|
|
197
|
+
/**
|
|
198
|
+
* Return the current connection policy.
|
|
199
|
+
* CELLO-MCP-003.
|
|
200
|
+
*/
|
|
201
|
+
getPolicy(): import("./connection-policy.js").SignalRequirementPolicy;
|
|
202
|
+
/**
|
|
203
|
+
* Check if a connection exists with the given counterparty pubkey.
|
|
204
|
+
* Returns the connection_id if found, null otherwise.
|
|
205
|
+
* CELLO-MCP-003.
|
|
206
|
+
*/
|
|
207
|
+
hasConnection(counterpartyPubkeyHex: string): string | null;
|
|
208
|
+
/**
|
|
209
|
+
* Accept a pending inbound connection request (inference review mode).
|
|
210
|
+
* Sends connection_response { verdict: 'accept' } to the directory.
|
|
211
|
+
* Returns { accepted: true, connection_id } on success, or { error: { reason } }.
|
|
212
|
+
* CELLO-MCP-003.
|
|
213
|
+
*/
|
|
214
|
+
acceptConnection(connectionRequestId: string): Promise<{
|
|
215
|
+
accepted: true;
|
|
216
|
+
connection_id: string;
|
|
217
|
+
} | {
|
|
218
|
+
error: {
|
|
219
|
+
reason: "no_pending_request" | "already_decided";
|
|
220
|
+
};
|
|
221
|
+
}>;
|
|
222
|
+
/**
|
|
223
|
+
* Reject a pending inbound connection request (inference review mode).
|
|
224
|
+
* Sends connection_response { verdict: 'reject' } to the directory.
|
|
225
|
+
* Returns { rejected: true } on success, or { error: { reason } }.
|
|
226
|
+
* CELLO-MCP-003.
|
|
227
|
+
*/
|
|
228
|
+
rejectConnection(connectionRequestId: string, reason?: string): Promise<{
|
|
229
|
+
rejected: true;
|
|
230
|
+
} | {
|
|
231
|
+
error: {
|
|
232
|
+
reason: "no_pending_request" | "already_decided";
|
|
233
|
+
};
|
|
234
|
+
}>;
|
|
235
|
+
/**
|
|
236
|
+
* Ask for more disclosure from sender (Round 2 initiation by target).
|
|
237
|
+
* Returns { request_sent: true } on success, or { error: { reason } }.
|
|
238
|
+
* CELLO-MCP-003.
|
|
239
|
+
*/
|
|
240
|
+
requestMoreDisclosure(connectionRequestId: string, requestedItems: unknown[]): Promise<{
|
|
241
|
+
request_sent: true;
|
|
242
|
+
} | {
|
|
243
|
+
error: {
|
|
244
|
+
reason: "no_pending_request" | "already_decided" | "max_rounds_reached";
|
|
245
|
+
};
|
|
246
|
+
}>;
|
|
247
|
+
/**
|
|
248
|
+
* Block until an inbound connection request arrives for agent review,
|
|
249
|
+
* or until timeoutMs elapses.
|
|
250
|
+
* Returns pending_review with ConnectionReport, or { type: 'timeout' }.
|
|
251
|
+
* CELLO-MCP-003.
|
|
252
|
+
*/
|
|
253
|
+
awaitConnectionRequest(timeoutMs?: number): Promise<{
|
|
254
|
+
type: "pending_review";
|
|
255
|
+
connection_request_id: string;
|
|
256
|
+
from_pubkey: string;
|
|
257
|
+
report: Extract<import("./connection-policy.js").ConnectionReport, {
|
|
258
|
+
verdict: "pending_agent_review";
|
|
259
|
+
}>;
|
|
260
|
+
} | {
|
|
261
|
+
type: "timeout";
|
|
262
|
+
}>;
|
|
263
|
+
/**
|
|
264
|
+
* List all active connection records.
|
|
265
|
+
* CELLO-MCP-003.
|
|
266
|
+
*/
|
|
267
|
+
listConnections(): import("@cello-protocol/protocol-types").ClientConnectionRecord[];
|
|
268
|
+
/**
|
|
269
|
+
* Register a peer in the local registry.
|
|
270
|
+
* Called by MCP-001 cello_connect_peer after dialing succeeds.
|
|
271
|
+
*/
|
|
272
|
+
addPeer(peerPubkeyHex: string, peerId: string, multiaddrs: string[]): void;
|
|
273
|
+
/**
|
|
274
|
+
* Send content to the peer identified by their K_local pubkey hex.
|
|
275
|
+
* Resolves with the delivery outcome — never throws.
|
|
276
|
+
*/
|
|
277
|
+
send(peerPubkeyHex: string, content: Uint8Array): Promise<SendResult>;
|
|
278
|
+
/**
|
|
279
|
+
* Register the inbound stream handler on the node.
|
|
280
|
+
* Must be called once after node.start().
|
|
281
|
+
*/
|
|
282
|
+
registerHandler(): Promise<void>;
|
|
283
|
+
/**
|
|
284
|
+
* Dequeue the oldest received envelope from a given sender.
|
|
285
|
+
* Returns null if the queue is empty.
|
|
286
|
+
*/
|
|
287
|
+
receive(senderPubkeyHex: string): ReceivedEnvelope | null;
|
|
288
|
+
/**
|
|
289
|
+
* Return all queued envelopes (in arrival order) regardless of sender.
|
|
290
|
+
* Non-destructive — items remain in the queue until receive() drains them.
|
|
291
|
+
*/
|
|
292
|
+
peekAll(): Array<{
|
|
293
|
+
senderPubkeyHex: string;
|
|
294
|
+
envelope: ReceivedEnvelope;
|
|
295
|
+
}>;
|
|
296
|
+
/**
|
|
297
|
+
* Process an inbound SessionAssignment pushed by the directory.
|
|
298
|
+
* Verifies the directory signature, computes genesis prev_root, dials the relay
|
|
299
|
+
* on /cello/relay/1.0.0, authenticates, dials the counterparty on /cello/content/1.0.0,
|
|
300
|
+
* and stores the session record.
|
|
301
|
+
* Resolves with ok:true and the session_id on success, ok:false with a reason on failure.
|
|
302
|
+
* SESSION-002 AC-002, AC-003, AC-004, AC-005, SI-003.
|
|
303
|
+
*/
|
|
304
|
+
receiveSessionAssignment(assignment: import("@cello-protocol/protocol-types").SessionAssignment, myPubkey: Uint8Array): Promise<ReceiveAssignmentResult>;
|
|
305
|
+
/**
|
|
306
|
+
* Return all currently known session records.
|
|
307
|
+
* SESSION-002 AC-004.
|
|
308
|
+
*/
|
|
309
|
+
listSessions(): SessionRecord[];
|
|
310
|
+
/**
|
|
311
|
+
* Send content on an active session using the dual-path protocol:
|
|
312
|
+
* hash on /cello/relay/1.0.0 and content on /cello/content/1.0.0.
|
|
313
|
+
* Serializes sends per session; the next send is not constructed until
|
|
314
|
+
* the relay has echoed back our own Structure 2 leaf_deliver.
|
|
315
|
+
* Never throws — returns SendMessageResult.
|
|
316
|
+
* MSG-004.
|
|
317
|
+
*/
|
|
318
|
+
sendMessage(sessionIdHex: string, content: Uint8Array): Promise<SendMessageResult>;
|
|
319
|
+
/**
|
|
320
|
+
* Dequeue the oldest verified ReceivedMessage for the given session.
|
|
321
|
+
* Returns null if the queue is empty. MSG-004.
|
|
322
|
+
*/
|
|
323
|
+
receiveMessage(sessionIdHex: string): ReceivedMessage | null;
|
|
324
|
+
/**
|
|
325
|
+
* Dequeue the oldest verified ReceivedMessage from any session (FIFO arrival order).
|
|
326
|
+
* Returns null if all queues are empty. MSG-004.
|
|
327
|
+
*/
|
|
328
|
+
receiveAnyMessage(): {
|
|
329
|
+
sessionIdHex: string;
|
|
330
|
+
message: ReceivedMessage;
|
|
331
|
+
} | null;
|
|
332
|
+
/**
|
|
333
|
+
* SESSION-007: Block until a message (or session_sealed event) arrives on ANY active
|
|
334
|
+
* session, or timeout_ms elapses. Returns { type: 'timeout' } on timeout.
|
|
335
|
+
* The response includes sessionIdHex so the caller knows which session it came from.
|
|
336
|
+
* Wakes immediately if any queue is non-empty.
|
|
337
|
+
*/
|
|
338
|
+
receiveMessageAsync(timeoutMs: number): Promise<(ReceivedMessage & {
|
|
339
|
+
sessionIdHex: string;
|
|
340
|
+
}) | {
|
|
341
|
+
type: "timeout";
|
|
342
|
+
}>;
|
|
343
|
+
/**
|
|
344
|
+
* SESSION-007: Block until a message (or session_sealed event) arrives on the given
|
|
345
|
+
* session, or timeout_ms elapses. Returns null on timeout.
|
|
346
|
+
* Wakes immediately if a message is already queued.
|
|
347
|
+
*/
|
|
348
|
+
receiveSessionMessageAsync(sessionIdHex: string, timeoutMs: number): Promise<ReceivedMessage | null>;
|
|
349
|
+
/**
|
|
350
|
+
* Initiate the bilateral SEAL ceremony. Constructs and submits the initiator SEAL
|
|
351
|
+
* ctrl leaf, transitions session to `sealing`. SESSION-003.
|
|
352
|
+
* Returns ok:false if the session is not active, already sealing/sealed, or if the
|
|
353
|
+
* relay submit fails.
|
|
354
|
+
*/
|
|
355
|
+
initiateSessionSeal(sessionIdHex: string): Promise<{
|
|
356
|
+
ok: true;
|
|
357
|
+
} | {
|
|
358
|
+
ok: false;
|
|
359
|
+
reason: string;
|
|
360
|
+
}>;
|
|
361
|
+
/**
|
|
362
|
+
* Close and remove a session record. Call after a desynchronized or sealed session
|
|
363
|
+
* can no longer be used. Idempotent — no-op if the session does not exist. MSG-004.
|
|
364
|
+
*/
|
|
365
|
+
closeSession(sessionIdHex: string): void;
|
|
366
|
+
/**
|
|
367
|
+
* Register a handler that fires when a `session_assignment` frame arrives for an
|
|
368
|
+
* inbound session (one where this client is participant B — the session was initiated
|
|
369
|
+
* by a remote peer). The MCP server uses this to populate its inbound session queue
|
|
370
|
+
* so `cello_await_session` can return the new session to the agent.
|
|
371
|
+
*
|
|
372
|
+
* The handler receives a rich event with all session fields pre-encoded as hex strings
|
|
373
|
+
* so the MCP layer does not need to re-encode them.
|
|
374
|
+
* Multiple calls to onSessionAssignment replace the previous handler (last-writer wins).
|
|
375
|
+
* CELLO-MCP-002.
|
|
376
|
+
*/
|
|
377
|
+
onSessionAssignment(handler: (event: SessionAssignmentEvent) => void): void;
|
|
378
|
+
/**
|
|
379
|
+
* Send a `session_request` over the persistent directory signaling stream and await
|
|
380
|
+
* the `session_assignment` or error response. On success, completes relay auth and
|
|
381
|
+
* content-path dial (same as receiveSessionAssignment), and returns the session_id
|
|
382
|
+
* and genesis_prev_root.
|
|
383
|
+
*
|
|
384
|
+
* Opens the signaling stream inline if not already open (DB-001: single retry).
|
|
385
|
+
* Returns { ok: false, reason: 'directory_unreachable' } if the stream cannot be
|
|
386
|
+
* established within the tool's timeout.
|
|
387
|
+
*
|
|
388
|
+
* CELLO-ADAPTER-003.
|
|
389
|
+
*/
|
|
390
|
+
initiateSession(targetPubkeyHex: string, opts?: {
|
|
391
|
+
/** Directory peer ID to connect to (overrides configured directoryEndpoint). */
|
|
392
|
+
directoryPeerId?: string;
|
|
393
|
+
/** Directory multiaddr for initial dial (overrides configured directoryEndpoint). */
|
|
394
|
+
directoryMultiaddr?: string;
|
|
395
|
+
/** Timeout in ms. Default: 30_000. */
|
|
396
|
+
timeoutMs?: number;
|
|
397
|
+
}): Promise<InitiateSessionResult>;
|
|
398
|
+
}
|
|
399
|
+
/** Event fired by CelloClient when an inbound session_assignment arrives. CELLO-MCP-002. */
|
|
400
|
+
export interface SessionAssignmentEvent {
|
|
401
|
+
/** Session ID as lowercase hex. */
|
|
402
|
+
sessionIdHex: string;
|
|
403
|
+
/** Counterparty K_local pubkey as lowercase hex. */
|
|
404
|
+
counterpartyPubkeyHex: string;
|
|
405
|
+
/** Genesis prev_root as lowercase hex. */
|
|
406
|
+
genesisPrevRootHex: string;
|
|
407
|
+
}
|
|
408
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,eAAe,GAAG,eAAe,CAAC;AAEnH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,mBAAmB,EAAE,UAAU,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uBAAuB,EAAE,MAAM,EAAE,CAAC;IAClC,cAAc,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC1D,kBAAkB,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;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;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,GAAG,IAAI,CAAC;IAE5E;;;;;;;;;;;OAWG;IACH,eAAe,CACb,eAAe,EAAE,MAAM,EACvB,IAAI,CAAC,EAAE;QACL,gFAAgF;QAChF,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,qFAAqF;QACrF,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,sCAAsC;QACtC,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACnC;AAED,4FAA4F;AAC5F,MAAM,WAAW,sBAAsB;IACrC,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,0CAA0C;IAC1C,kBAAkB,EAAE,MAAM,CAAC;CAC5B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cello-protocol/client",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=24"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/",
|
|
22
|
+
"package.json"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@aws-sdk/client-s3": "3.1051.0",
|
|
26
|
+
"@cello-protocol/interfaces": "0.0.1",
|
|
27
|
+
"@journeyapps/sqlcipher": "^6.0.0",
|
|
28
|
+
"@libp2p/interface": "^3.2.2",
|
|
29
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
30
|
+
"@noble/curves": "^2.2.0",
|
|
31
|
+
"cbor-x": "^1.6.0",
|
|
32
|
+
"it-length-prefixed": "^10.0.1",
|
|
33
|
+
"it-pipe": "^3.0.1",
|
|
34
|
+
"zod": "^4.4.2",
|
|
35
|
+
"@cello-protocol/crypto": "0.0.2",
|
|
36
|
+
"@cello-protocol/protocol-types": "0.0.2",
|
|
37
|
+
"@cello-protocol/transport": "0.0.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@claude-flow/testing": "3.0.0-alpha.6",
|
|
41
|
+
"@types/node": "^25.6.2",
|
|
42
|
+
"@cello-protocol/test-fixtures": "0.0.2"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"typecheck": "tsc --build",
|
|
46
|
+
"test": "vitest run"
|
|
47
|
+
}
|
|
48
|
+
}
|