tenzro-sdk 0.1.0 → 0.2.0

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 (111) hide show
  1. package/LICENSE +4 -15
  2. package/README.md +196 -3
  3. package/dist/adaptive-burn.d.ts +40 -0
  4. package/dist/adaptive-burn.d.ts.map +1 -0
  5. package/dist/adaptive-burn.js +53 -0
  6. package/dist/adaptive-burn.js.map +1 -0
  7. package/dist/agent.d.ts +8 -1
  8. package/dist/agent.d.ts.map +1 -1
  9. package/dist/agent.js +14 -2
  10. package/dist/agent.js.map +1 -1
  11. package/dist/ap2.d.ts +96 -0
  12. package/dist/ap2.d.ts.map +1 -1
  13. package/dist/ap2.js +65 -0
  14. package/dist/ap2.js.map +1 -1
  15. package/dist/app.js +4 -4
  16. package/dist/app.js.map +1 -1
  17. package/dist/auth.d.ts +357 -0
  18. package/dist/auth.d.ts.map +1 -0
  19. package/dist/auth.js +226 -0
  20. package/dist/auth.js.map +1 -0
  21. package/dist/bond.d.ts +70 -0
  22. package/dist/bond.d.ts.map +1 -0
  23. package/dist/bond.js +172 -0
  24. package/dist/bond.js.map +1 -0
  25. package/dist/cct.d.ts +53 -0
  26. package/dist/cct.d.ts.map +1 -0
  27. package/dist/cct.js +30 -0
  28. package/dist/cct.js.map +1 -0
  29. package/dist/client.d.ts +134 -2
  30. package/dist/client.d.ts.map +1 -1
  31. package/dist/client.js +196 -12
  32. package/dist/client.js.map +1 -1
  33. package/dist/cortex.d.ts +227 -0
  34. package/dist/cortex.d.ts.map +1 -0
  35. package/dist/cortex.js +137 -0
  36. package/dist/cortex.js.map +1 -0
  37. package/dist/custody.d.ts +251 -0
  38. package/dist/custody.d.ts.map +1 -1
  39. package/dist/custody.js +216 -0
  40. package/dist/custody.js.map +1 -1
  41. package/dist/eip6963.d.ts +63 -0
  42. package/dist/eip6963.d.ts.map +1 -0
  43. package/dist/eip6963.js +67 -0
  44. package/dist/eip6963.js.map +1 -0
  45. package/dist/erc8004.d.ts +97 -0
  46. package/dist/erc8004.d.ts.map +1 -0
  47. package/dist/erc8004.js +182 -0
  48. package/dist/erc8004.js.map +1 -0
  49. package/dist/identity.d.ts +15 -1
  50. package/dist/identity.d.ts.map +1 -1
  51. package/dist/identity.js +18 -0
  52. package/dist/identity.js.map +1 -1
  53. package/dist/index.d.ts +28 -4
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +49 -1
  56. package/dist/index.js.map +1 -1
  57. package/dist/insurance.d.ts +38 -0
  58. package/dist/insurance.d.ts.map +1 -0
  59. package/dist/insurance.js +51 -0
  60. package/dist/insurance.js.map +1 -0
  61. package/dist/lifecycle.d.ts +41 -0
  62. package/dist/lifecycle.d.ts.map +1 -0
  63. package/dist/lifecycle.js +56 -0
  64. package/dist/lifecycle.js.map +1 -0
  65. package/dist/marketplace.d.ts +30 -2
  66. package/dist/marketplace.d.ts.map +1 -1
  67. package/dist/marketplace.js +36 -2
  68. package/dist/marketplace.js.map +1 -1
  69. package/dist/payment.d.ts +14 -1
  70. package/dist/payment.d.ts.map +1 -1
  71. package/dist/payment.js +15 -0
  72. package/dist/payment.js.map +1 -1
  73. package/dist/principal-chain.d.ts +41 -0
  74. package/dist/principal-chain.d.ts.map +1 -0
  75. package/dist/principal-chain.js +56 -0
  76. package/dist/principal-chain.js.map +1 -0
  77. package/dist/provider.d.ts +2 -2
  78. package/dist/provider.js +1 -1
  79. package/dist/quota.d.ts +54 -0
  80. package/dist/quota.d.ts.map +1 -0
  81. package/dist/quota.js +71 -0
  82. package/dist/quota.js.map +1 -0
  83. package/dist/rpc.d.ts +43 -4
  84. package/dist/rpc.d.ts.map +1 -1
  85. package/dist/rpc.js +110 -3
  86. package/dist/rpc.js.map +1 -1
  87. package/dist/seed-agent.d.ts +52 -0
  88. package/dist/seed-agent.d.ts.map +1 -0
  89. package/dist/seed-agent.js +69 -0
  90. package/dist/seed-agent.js.map +1 -0
  91. package/dist/settlement.d.ts +52 -10
  92. package/dist/settlement.d.ts.map +1 -1
  93. package/dist/settlement.js +197 -16
  94. package/dist/settlement.js.map +1 -1
  95. package/dist/streaming.js.map +1 -1
  96. package/dist/svm-cross-vm.d.ts +109 -0
  97. package/dist/svm-cross-vm.d.ts.map +1 -0
  98. package/dist/svm-cross-vm.js +215 -0
  99. package/dist/svm-cross-vm.js.map +1 -0
  100. package/dist/types.d.ts +175 -6
  101. package/dist/types.d.ts.map +1 -1
  102. package/dist/types.js.map +1 -1
  103. package/dist/wallet.d.ts +26 -9
  104. package/dist/wallet.d.ts.map +1 -1
  105. package/dist/wallet.js +34 -19
  106. package/dist/wallet.js.map +1 -1
  107. package/dist/wormhole.d.ts +76 -0
  108. package/dist/wormhole.d.ts.map +1 -0
  109. package/dist/wormhole.js +56 -0
  110. package/dist/wormhole.js.map +1 -0
  111. package/package.json +2 -2
@@ -0,0 +1,227 @@
1
+ import { RpcClient } from "./rpc";
2
+ /**
3
+ * Service tier for a Cortex reasoning request.
4
+ *
5
+ * Each tier implies a default loop range, an expected latency profile,
6
+ * and whether hardware attestation / ZK inference proofs are required.
7
+ */
8
+ export type ReasoningTier = "fast" | "standard" | "deep" | "institutional";
9
+ /**
10
+ * Attestation requirement for a Cortex inference request.
11
+ *
12
+ * - `none` — no attestation, cheapest.
13
+ * - `tee` — Intel TDX / AMD SEV-SNP / AWS Nitro / NVIDIA CC quote required.
14
+ * - `tee_and_zk` — TEE quote AND a Plonky3 STARK inference-verification proof.
15
+ */
16
+ export type AttestationRequirement = "none" | "tee" | "tee_and_zk";
17
+ /**
18
+ * Reasoning-specific metadata captured during a Cortex inference.
19
+ */
20
+ export interface CortexMetadata {
21
+ input_tokens: number;
22
+ output_tokens: number;
23
+ /** Number of recurrent loops actually executed. */
24
+ loops_used: number;
25
+ /** Wall-clock latency in milliseconds. */
26
+ latency_ms: number;
27
+ model_version?: string | null;
28
+ /** "stop" | "length" | "converged" | etc. */
29
+ finish_reason?: string | null;
30
+ /** Distinct MoE experts activated, if known. */
31
+ experts_activated?: number | null;
32
+ }
33
+ /**
34
+ * Signed execution receipt for a Cortex reasoning call.
35
+ *
36
+ * Every Cortex response carries a receipt. Deep / Institutional receipts
37
+ * also anchor on Tenzro Ledger and may carry TEE quotes or Plonky3 STARK
38
+ * inference-verification proofs.
39
+ *
40
+ * Receipts let auditors reconstruct:
41
+ * 1. Which model weights were used (`weights_hash`, `runtime_hash`).
42
+ * 2. What input produced what output (`input_commitment`, `output_commitment`).
43
+ * 3. How much compute was spent (`loops_used`, `tokens_in`, `tokens_out`).
44
+ * 4. Who executed it (`worker_did`, `signature`).
45
+ * 5. Optional hardware / ZK evidence.
46
+ */
47
+ export interface CortexReceipt {
48
+ model_id: string;
49
+ /** Hex-encoded SHA-256 hash of the model weights. */
50
+ weights_hash: string;
51
+ /** Hex-encoded SHA-256 hash of the serving runtime (container / binary). */
52
+ runtime_hash: string;
53
+ /** Number of loops the worker was asked to run at most. */
54
+ loops_requested: number;
55
+ /** Number of loops actually run. */
56
+ loops_used: number;
57
+ /** Hex-encoded hash of the canonical request payload. */
58
+ input_commitment: string;
59
+ /** Hex-encoded hash of the canonical response payload. */
60
+ output_commitment: string;
61
+ /** DID of the worker that executed the inference. */
62
+ worker_did: string;
63
+ /** Worker wallet address (for settlement). Hex string. */
64
+ worker_address: string;
65
+ /** Optional TEE attestation quote bytes (base64-encoded over JSON-RPC). */
66
+ tee_quote?: number[] | null;
67
+ /** Optional Plonky3 STARK inference-verification proof bytes. */
68
+ zk_proof?: number[] | null;
69
+ /** Input tokens charged. */
70
+ tokens_in: number;
71
+ /** Output tokens charged. */
72
+ tokens_out: number;
73
+ /** Final settled price in smallest TNZO unit (uint64 — may overflow JS number; treat as bigint where precision matters). */
74
+ price_tnzo: number;
75
+ /** Receipt creation timestamp. */
76
+ timestamp?: unknown;
77
+ /** Worker signature over the canonical receipt preimage. */
78
+ signature?: unknown;
79
+ }
80
+ /**
81
+ * A Cortex reasoning request.
82
+ *
83
+ * Only `model_id` and `input` are required. All other fields default to the
84
+ * `Standard` tier values when omitted.
85
+ */
86
+ export interface CortexRequest {
87
+ request_id?: string;
88
+ model_id: string;
89
+ /** Plain-text prompt input. */
90
+ input: string;
91
+ tier?: ReasoningTier;
92
+ /** Override `min_loops` (defaults from tier). */
93
+ min_loops?: number;
94
+ /** Override `max_loops` (defaults from tier). */
95
+ max_loops?: number;
96
+ /** Hard cap on billed cost in smallest TNZO unit. */
97
+ max_cost_tnzo?: number;
98
+ /** Wall-clock deadline in milliseconds. */
99
+ deadline_ms?: number;
100
+ attestation?: AttestationRequirement;
101
+ /** Caller address (also the payer). Hex string. */
102
+ requester?: string;
103
+ /** Free-form generation parameters forwarded to the sidecar. */
104
+ params?: Record<string, string>;
105
+ }
106
+ /**
107
+ * A Cortex reasoning response.
108
+ */
109
+ export interface CortexResponse {
110
+ request_id: string;
111
+ response_id: string;
112
+ model_id: string;
113
+ /** Worker address that executed the inference. Hex string. */
114
+ worker: string;
115
+ /** Raw response payload. May arrive as a byte-array or string. */
116
+ output: number[] | string;
117
+ metadata: CortexMetadata;
118
+ /** Final price charged in smallest TNZO unit. */
119
+ price_tnzo: number;
120
+ /** Receipt binding this response to its inputs, weights, and worker. */
121
+ receipt: CortexReceipt;
122
+ /** Whether on-chain settlement of `price_tnzo` succeeded on this node. */
123
+ settled: boolean;
124
+ /** Response creation timestamp (server-side). */
125
+ timestamp?: unknown;
126
+ }
127
+ /**
128
+ * A locally-registered Cortex worker entry.
129
+ */
130
+ export interface CortexWorkerEntry {
131
+ model_id: string;
132
+ worker_did?: string;
133
+ family?: unknown;
134
+ pricing?: unknown;
135
+ }
136
+ /**
137
+ * Worker list response.
138
+ */
139
+ export interface CortexWorkerList {
140
+ workers: unknown[];
141
+ count: number;
142
+ }
143
+ /**
144
+ * Loop-aware pricing configuration for a Cortex model.
145
+ *
146
+ * Total cost formula (smallest TNZO unit):
147
+ *
148
+ * cost = base_request_fee
149
+ * + tokens_in * price_per_input_token
150
+ * + tokens_out * price_per_output_token
151
+ * + loops_used * price_per_loop
152
+ * + tee_premium (if attestation includes Tee)
153
+ * + zk_premium (if attestation includes Zk)
154
+ */
155
+ export interface CortexPricing {
156
+ base_request_fee: number;
157
+ price_per_input_token: number;
158
+ price_per_output_token: number;
159
+ price_per_loop: number;
160
+ tee_premium: number;
161
+ zk_premium: number;
162
+ }
163
+ /** Default Cortex pricing — mirror of the on-node `CortexPricing::default()`. */
164
+ export declare const DEFAULT_CORTEX_PRICING: CortexPricing;
165
+ /**
166
+ * Compute the total cost for a settled Cortex inference (mirror of the on-node logic).
167
+ *
168
+ * Uses native `number` arithmetic — fine for testnet pricing, but if you need
169
+ * full uint64 precision use bigint by hand.
170
+ */
171
+ export declare function computeCortexCost(pricing: CortexPricing, tokensIn: number, tokensOut: number, loopsUsed: number, attestation: AttestationRequirement): number;
172
+ /**
173
+ * Client for Cortex recurrent-depth reasoning operations on Tenzro Network.
174
+ *
175
+ * Cortex treats recurrent-loop depth as a first-class billable primitive.
176
+ * Use this to submit reasoning requests with explicit budget envelopes
177
+ * (Fast / Standard / Deep / Institutional tiers) and receive signed
178
+ * receipts binding inputs, outputs, and worker identity.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * const cortex = new CortexClient(rpc);
183
+ * const resp = await cortex.reason("openmythos-3b", "Plan a trade", "deep");
184
+ * console.log("loops_used:", resp.metadata.loops_used);
185
+ * console.log("cost:", resp.price_tnzo);
186
+ * console.log("worker:", resp.receipt.worker_did);
187
+ * ```
188
+ */
189
+ export declare class CortexClient {
190
+ private rpc;
191
+ constructor(rpc: RpcClient);
192
+ /**
193
+ * Submit a Cortex reasoning request via `tenzro_cortexReason` (one-shot helper).
194
+ *
195
+ * For full control over budget, attestation, params, etc., use {@link reasonWithRequest}.
196
+ */
197
+ reason(modelId: string, input: string, tier?: ReasoningTier): Promise<CortexResponse>;
198
+ /**
199
+ * Submit a Cortex reasoning request with full request parameters.
200
+ */
201
+ reasonWithRequest(req: CortexRequest): Promise<CortexResponse>;
202
+ /**
203
+ * List Cortex workers registered locally on the connected node.
204
+ */
205
+ listWorkers(): Promise<CortexWorkerList>;
206
+ /**
207
+ * List remote Cortex workers learned via the `tenzro/cortex`
208
+ * gossip topic (signed advertisements still within their TTL).
209
+ */
210
+ listRemoteWorkers(): Promise<CortexWorkerList>;
211
+ /**
212
+ * Register a Cortex worker on the connected node. The worker forwards
213
+ * Cortex requests to a sidecar HTTP backend.
214
+ *
215
+ * @param modelId Model id (must be unique on this node).
216
+ * @param sidecarUrl HTTP endpoint of the recurrent-depth model sidecar.
217
+ * @param familyArch Architecture identifier ("rdt-moe", "rdt-dense", etc.).
218
+ * @param maxLoops Hard ceiling on recurrent loops this model supports.
219
+ * @param opts Optional bearer token, pricing, supported tiers.
220
+ */
221
+ registerWorker(modelId: string, sidecarUrl: string, familyArch: string, maxLoops: number, opts?: {
222
+ bearerToken?: string;
223
+ pricing?: CortexPricing;
224
+ supportedTiers?: ReasoningTier[];
225
+ }): Promise<unknown>;
226
+ }
227
+ //# sourceMappingURL=cortex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cortex.d.ts","sourceRoot":"","sources":["../src/cortex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,eAAe,CAAC;AAE3E;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,6CAA6C;IAC7C,aAAa,CAAC,EAAE,MAAM,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AE,MAAM,CAAC;CACpB;AAED,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,EAAE,aAOpC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,sBAAsB,GAClC,MAAM,CAYR;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAElC;;;;OAIG;IACG,MAAM,CACV,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,aAA0B,GAC/B,OAAO,CAAC,cAAc,CAAC;IAQ1B;;OAEG;IACG,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAmBpE;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAI9C;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAOpD;;;;;;;;;OASG;IACG,cAAc,CAClB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE;QACL,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,aAAa,CAAC;QACxB,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;KAClC,GACA,OAAO,CAAC,OAAO,CAAC;CAcpB"}
package/dist/cortex.js ADDED
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CortexClient = exports.DEFAULT_CORTEX_PRICING = void 0;
4
+ exports.computeCortexCost = computeCortexCost;
5
+ /** Default Cortex pricing — mirror of the on-node `CortexPricing::default()`. */
6
+ exports.DEFAULT_CORTEX_PRICING = {
7
+ base_request_fee: 100,
8
+ price_per_input_token: 10,
9
+ price_per_output_token: 20,
10
+ price_per_loop: 1_000,
11
+ tee_premium: 10_000,
12
+ zk_premium: 100_000,
13
+ };
14
+ /**
15
+ * Compute the total cost for a settled Cortex inference (mirror of the on-node logic).
16
+ *
17
+ * Uses native `number` arithmetic — fine for testnet pricing, but if you need
18
+ * full uint64 precision use bigint by hand.
19
+ */
20
+ function computeCortexCost(pricing, tokensIn, tokensOut, loopsUsed, attestation) {
21
+ let cost = pricing.base_request_fee;
22
+ cost += tokensIn * pricing.price_per_input_token;
23
+ cost += tokensOut * pricing.price_per_output_token;
24
+ cost += loopsUsed * pricing.price_per_loop;
25
+ if (attestation === "tee" || attestation === "tee_and_zk") {
26
+ cost += pricing.tee_premium;
27
+ }
28
+ if (attestation === "tee_and_zk") {
29
+ cost += pricing.zk_premium;
30
+ }
31
+ return cost;
32
+ }
33
+ /**
34
+ * Client for Cortex recurrent-depth reasoning operations on Tenzro Network.
35
+ *
36
+ * Cortex treats recurrent-loop depth as a first-class billable primitive.
37
+ * Use this to submit reasoning requests with explicit budget envelopes
38
+ * (Fast / Standard / Deep / Institutional tiers) and receive signed
39
+ * receipts binding inputs, outputs, and worker identity.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const cortex = new CortexClient(rpc);
44
+ * const resp = await cortex.reason("openmythos-3b", "Plan a trade", "deep");
45
+ * console.log("loops_used:", resp.metadata.loops_used);
46
+ * console.log("cost:", resp.price_tnzo);
47
+ * console.log("worker:", resp.receipt.worker_did);
48
+ * ```
49
+ */
50
+ class CortexClient {
51
+ rpc;
52
+ constructor(rpc) {
53
+ this.rpc = rpc;
54
+ }
55
+ /**
56
+ * Submit a Cortex reasoning request via `tenzro_cortexReason` (one-shot helper).
57
+ *
58
+ * For full control over budget, attestation, params, etc., use {@link reasonWithRequest}.
59
+ */
60
+ async reason(modelId, input, tier = "standard") {
61
+ return this.rpc.call("tenzro_cortexReason", {
62
+ model_id: modelId,
63
+ input,
64
+ tier,
65
+ });
66
+ }
67
+ /**
68
+ * Submit a Cortex reasoning request with full request parameters.
69
+ */
70
+ async reasonWithRequest(req) {
71
+ const params = {
72
+ model_id: req.model_id,
73
+ input: req.input,
74
+ };
75
+ if (req.tier !== undefined)
76
+ params.tier = req.tier;
77
+ if (req.min_loops !== undefined)
78
+ params.min_loops = req.min_loops;
79
+ if (req.max_loops !== undefined)
80
+ params.max_loops = req.max_loops;
81
+ if (req.max_cost_tnzo !== undefined)
82
+ params.max_cost_tnzo = req.max_cost_tnzo;
83
+ if (req.deadline_ms !== undefined)
84
+ params.deadline_ms = req.deadline_ms;
85
+ if (req.attestation !== undefined)
86
+ params.attestation = req.attestation;
87
+ if (req.requester !== undefined)
88
+ params.requester = req.requester;
89
+ if (req.params !== undefined && Object.keys(req.params).length > 0) {
90
+ params.params = req.params;
91
+ }
92
+ if (req.request_id !== undefined)
93
+ params.request_id = req.request_id;
94
+ return this.rpc.call("tenzro_cortexReason", params);
95
+ }
96
+ /**
97
+ * List Cortex workers registered locally on the connected node.
98
+ */
99
+ async listWorkers() {
100
+ return this.rpc.call("tenzro_listCortexWorkers", []);
101
+ }
102
+ /**
103
+ * List remote Cortex workers learned via the `tenzro/cortex`
104
+ * gossip topic (signed advertisements still within their TTL).
105
+ */
106
+ async listRemoteWorkers() {
107
+ return this.rpc.call("tenzro_listRemoteCortexWorkers", []);
108
+ }
109
+ /**
110
+ * Register a Cortex worker on the connected node. The worker forwards
111
+ * Cortex requests to a sidecar HTTP backend.
112
+ *
113
+ * @param modelId Model id (must be unique on this node).
114
+ * @param sidecarUrl HTTP endpoint of the recurrent-depth model sidecar.
115
+ * @param familyArch Architecture identifier ("rdt-moe", "rdt-dense", etc.).
116
+ * @param maxLoops Hard ceiling on recurrent loops this model supports.
117
+ * @param opts Optional bearer token, pricing, supported tiers.
118
+ */
119
+ async registerWorker(modelId, sidecarUrl, familyArch, maxLoops, opts) {
120
+ const params = {
121
+ model_id: modelId,
122
+ sidecar_url: sidecarUrl,
123
+ arch: familyArch,
124
+ max_loops: maxLoops,
125
+ };
126
+ if (opts?.bearerToken !== undefined)
127
+ params.bearer_token = opts.bearerToken;
128
+ if (opts?.pricing !== undefined)
129
+ params.pricing = opts.pricing;
130
+ if (opts?.supportedTiers !== undefined) {
131
+ params.supported_tiers = opts.supportedTiers;
132
+ }
133
+ return this.rpc.call("tenzro_registerCortexWorker", params);
134
+ }
135
+ }
136
+ exports.CortexClient = CortexClient;
137
+ //# sourceMappingURL=cortex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cortex.js","sourceRoot":"","sources":["../src/cortex.ts"],"names":[],"mappings":";;;AA4LA,8CAkBC;AAlCD,iFAAiF;AACpE,QAAA,sBAAsB,GAAkB;IACnD,gBAAgB,EAAE,GAAG;IACrB,qBAAqB,EAAE,EAAE;IACzB,sBAAsB,EAAE,EAAE;IAC1B,cAAc,EAAE,KAAK;IACrB,WAAW,EAAE,MAAM;IACnB,UAAU,EAAE,OAAO;CACpB,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,OAAsB,EACtB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,WAAmC;IAEnC,IAAI,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC;IACpC,IAAI,IAAI,QAAQ,GAAG,OAAO,CAAC,qBAAqB,CAAC;IACjD,IAAI,IAAI,SAAS,GAAG,OAAO,CAAC,sBAAsB,CAAC;IACnD,IAAI,IAAI,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC;IAC3C,IAAI,WAAW,KAAK,KAAK,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;QAC1D,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;IAC9B,CAAC;IACD,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;QACjC,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAC7B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;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package/dist/custody.d.ts CHANGED
@@ -110,5 +110,256 @@ export declare class CustodyClient {
110
110
  * @param operations - Allowed operations (e.g., "transfer", "stake")
111
111
  */
112
112
  authorizeSession(walletId: string, durationSecs: number, operations: string[]): Promise<SessionKey>;
113
+ /**
114
+ * Discover the node's ML-DSA-65 signing mode.
115
+ *
116
+ * Always `tee-only` on testnet. The wallet uses this to decide
117
+ * whether to invoke threshold-coordination methods (skipped in
118
+ * `tee-only`) or fall through to the single-shot {@link mldsaSign}.
119
+ *
120
+ * Required AAP capability: `wallet.mldsa.sign`.
121
+ */
122
+ mldsaCapabilities(bearerJwt: string, dpopProof: string): Promise<MlDsaCapabilities>;
123
+ /**
124
+ * Sign a preimage with the node-held ML-DSA-65 key bound to
125
+ * `(did, surfaceKey)`. The returned signature is 3309 bytes per
126
+ * FIPS 204 §4 Table 2.
127
+ *
128
+ * Required AAP capability: `wallet.mldsa.sign`.
129
+ *
130
+ * @param bearerJwt - DPoP-bound bearer JWT.
131
+ * @param dpopProof - Fresh DPoP proof signed over `(POST, "<base>/wallet/mldsa/sign")`.
132
+ * @param did - Bearer DID owning the surface key.
133
+ * @param surfaceKey - Wallet-defined surface identifier (e.g. `"vault.0"`).
134
+ * @param preimage - Raw bytes to be signed (encoded base64url no-pad on the wire).
135
+ * @param purpose - Optional caller-supplied purpose string for audit logging.
136
+ */
137
+ mldsaSign(bearerJwt: string, dpopProof: string, did: string, surfaceKey: string, preimage: Uint8Array, purpose?: string): Promise<MlDsaSignature>;
138
+ /**
139
+ * Start a FROST signing session.
140
+ *
141
+ * Server allocates a session, runs Round 1, and returns its
142
+ * commitments together with both participant identifiers. The
143
+ * wallet then runs its own Round 1 against the same `preimage`
144
+ * and the returned identifiers, and submits its commitments via
145
+ * {@link frostCommit}.
146
+ *
147
+ * Required AAP capability: `wallet.frost.sign`.
148
+ */
149
+ frostStart(bearerJwt: string, dpopProof: string, scheme: FrostScheme, did: string, surfaceKey: string, preimage: Uint8Array): Promise<FrostStartResponse>;
150
+ /**
151
+ * Submit the wallet's Round 1 commitments.
152
+ *
153
+ * Transitions the session from `pending` to `committed`. After this
154
+ * call the wallet should call {@link frostAwaitChallenge} to receive
155
+ * the `SigningPackage` it must feed into the FROST crate's
156
+ * `round2::sign`.
157
+ *
158
+ * Required AAP capability: `wallet.frost.sign`.
159
+ */
160
+ frostCommit(bearerJwt: string, dpopProof: string, scheme: FrostScheme, sessionId: string, deviceCommitments: Uint8Array): Promise<FrostStateResponse>;
161
+ /**
162
+ * Long-poll for the challenge (`SigningPackage`).
163
+ *
164
+ * Returns immediately if the session is already `committed`. Polls
165
+ * for up to ~5s otherwise. The wallet feeds `signing_package_b64`
166
+ * into `round2::sign(signing_package, signer_nonces, key_package)`
167
+ * to produce its signature share.
168
+ *
169
+ * Required AAP capability: `wallet.frost.sign`.
170
+ */
171
+ frostAwaitChallenge(bearerJwt: string, dpopProof: string, scheme: FrostScheme, sessionId: string): Promise<FrostChallengeResponse>;
172
+ /**
173
+ * Submit the wallet's Round 2 signature share.
174
+ *
175
+ * Server runs its own Round 2, aggregates the two shares, and
176
+ * transitions the session to `finalized`. The aggregated signature
177
+ * is then retrievable via {@link frostFinalize}.
178
+ *
179
+ * Required AAP capability: `wallet.frost.sign`.
180
+ */
181
+ frostRespond(bearerJwt: string, dpopProof: string, scheme: FrostScheme, sessionId: string, deviceSignatureShare: Uint8Array): Promise<FrostStateResponse>;
182
+ /**
183
+ * Long-poll for the aggregated signature.
184
+ *
185
+ * Returns immediately if the session is already `finalized`. Polls
186
+ * for up to ~5s otherwise. `signature_b64` is the canonical Schnorr
187
+ * signature: 64 bytes for Ed25519, 65 for secp256k1 (Taproot).
188
+ *
189
+ * Required AAP capability: `wallet.frost.sign`.
190
+ */
191
+ frostFinalize(bearerJwt: string, dpopProof: string, scheme: FrostScheme, sessionId: string): Promise<FrostFinalizeResponse>;
192
+ /**
193
+ * Abort an in-flight FROST session.
194
+ *
195
+ * Idempotent: an already-aborted session returns `aborted`. A
196
+ * session that has already finalized stays `finalized` (the abort
197
+ * is a no-op rather than an error).
198
+ *
199
+ * Required AAP capability: `wallet.frost.sign`.
200
+ */
201
+ frostAbort(bearerJwt: string, dpopProof: string, scheme: FrostScheme, sessionId: string): Promise<FrostStateResponse>;
202
+ /**
203
+ * Fetch the wrapped FROST share for `(credentialId, surfaceKey)`.
204
+ *
205
+ * Idempotent — repeated calls return identical bytes for the same
206
+ * pair. The returned blob is useless on its own; the wallet must
207
+ * also obtain the per-assertion pepper via {@link shareEscrowUnwrap}
208
+ * and combine the two through its local KDF to recover the cleartext
209
+ * share.
210
+ *
211
+ * Required AAP capability: `wallet.share.unwrap`.
212
+ */
213
+ shareEnvelope(bearerJwt: string, dpopProof: string, credentialId: string, surfaceKey: string): Promise<ShareEnvelopeResponse>;
214
+ /**
215
+ * Mint a single-use, 30-second-TTL nonce for an upcoming WebAuthn
216
+ * ceremony.
217
+ *
218
+ * The wallet must use the returned `nonce_b64` value verbatim as
219
+ * the WebAuthn `challenge` field when prompting the user's passkey.
220
+ * Server-side the nonce is held in an in-memory escrow; it is
221
+ * consumed by {@link shareEscrowUnwrap} regardless of whether the
222
+ * assertion verifies.
223
+ *
224
+ * Required AAP capability: `wallet.share.unwrap`.
225
+ */
226
+ shareEscrowChallenge(bearerJwt: string, dpopProof: string, credentialId: string, surfaceKey: string): Promise<ShareEscrowChallengeResponse>;
227
+ /**
228
+ * Verify a WebAuthn assertion, consume the escrow nonce, and return
229
+ * `(wrapped_share, pepper)`.
230
+ *
231
+ * Single-use: the nonce is removed from the escrow before the
232
+ * assertion is verified, so a successful unwrap cannot be replayed
233
+ * and a failed verification still consumes the nonce. The wallet
234
+ * must request a fresh challenge before retrying.
235
+ *
236
+ * Required AAP capability: `wallet.share.unwrap`.
237
+ */
238
+ shareEscrowUnwrap(bearerJwt: string, dpopProof: string, credentialId: string, surfaceKey: string, nonceB64: string, assertion: PasskeyAssertion): Promise<ShareEscrowUnwrapResponse>;
239
+ }
240
+ /** Discovery response from `GET /wallet/mldsa/capabilities`. */
241
+ export interface MlDsaCapabilities {
242
+ /** Mode of the ML-DSA-65 signing surface. `"tee-only"` on testnet. */
243
+ mode: string;
244
+ }
245
+ /** Sign-response from `POST /wallet/mldsa/sign`. */
246
+ export interface MlDsaSignature {
247
+ /** 3309-byte ML-DSA-65 signature, base64url no-pad. */
248
+ signature_b64: string;
249
+ }
250
+ /**
251
+ * FROST signing scheme — selects the curve via the `:scheme` path
252
+ * segment of the `/wallet/frost/:scheme/*` endpoints.
253
+ */
254
+ export type FrostScheme = 'ed25519' | 'secp256k1';
255
+ /** Session-state discriminator returned by every FROST endpoint. */
256
+ export type FrostSessionState = 'pending' | 'committed' | 'finalized' | 'aborted';
257
+ /** Response from `POST /wallet/frost/:scheme/start`. */
258
+ export interface FrostStartResponse {
259
+ /** Opaque session identifier — pass back into every subsequent call. */
260
+ session_id: string;
261
+ /** Unix-millis at which the session is evicted regardless of state. */
262
+ expires_at_ms: number;
263
+ /** Stable participant identifier the node uses for itself. */
264
+ node_identifier_b64: string;
265
+ /**
266
+ * Stable participant identifier the wallet must use for itself
267
+ * (must match what the node will look up in the `KeyPackage`).
268
+ */
269
+ device_identifier_b64: string;
270
+ /**
271
+ * Node's Round 1 `SigningCommitments`, serialized via the FROST
272
+ * crate's canonical `.serialize()`.
273
+ */
274
+ node_commitments_b64: string;
275
+ }
276
+ /**
277
+ * Response from FROST endpoints that only carry a state transition
278
+ * (`commit`, `respond`, `abort`).
279
+ */
280
+ export interface FrostStateResponse {
281
+ state: FrostSessionState;
282
+ }
283
+ /** Response from `POST /wallet/frost/:scheme/await-challenge`. */
284
+ export interface FrostChallengeResponse {
285
+ state: FrostSessionState;
286
+ /**
287
+ * Present only when `state === 'committed'`. Serialized
288
+ * `SigningPackage` — feed straight into the FROST crate's
289
+ * `round2::sign(signing_package, signer_nonces, key_package)`.
290
+ */
291
+ signing_package_b64?: string;
292
+ }
293
+ /** Response from `POST /wallet/frost/:scheme/finalize`. */
294
+ export interface FrostFinalizeResponse {
295
+ state: FrostSessionState;
296
+ /**
297
+ * Present only when `state === 'finalized'`. The aggregated Schnorr
298
+ * signature: 64 bytes for Ed25519, 65 bytes for secp256k1.
299
+ */
300
+ signature_b64?: string;
301
+ }
302
+ /**
303
+ * WebAuthn assertion submitted to `/wallet/share/escrow/unwrap`.
304
+ *
305
+ * All three fields are base64url no-pad. The wallet kernel performs
306
+ * the WebAuthn ceremony (`navigator.credentials.get()`) and forwards
307
+ * the resulting bytes verbatim — the SDK is transport-only and does
308
+ * not parse or validate the assertion.
309
+ */
310
+ export interface PasskeyAssertion {
311
+ /** `AuthenticatorAssertionResponse.authenticatorData`. */
312
+ authenticator_data_b64: string;
313
+ /**
314
+ * `AuthenticatorAssertionResponse.clientDataJSON`. The embedded
315
+ * `challenge` field must equal the `nonce_b64` returned by
316
+ * {@link CustodyClient.shareEscrowChallenge}.
317
+ */
318
+ client_data_json_b64: string;
319
+ /**
320
+ * `AuthenticatorAssertionResponse.signature` — Ed25519 (COSE alg
321
+ * `-8`) signature over `authenticatorData || SHA-256(clientDataJSON)`
322
+ * per WebAuthn L3 §7.2.
323
+ */
324
+ signature_b64: string;
325
+ }
326
+ /** Response from `GET /wallet/share/envelope`. */
327
+ export interface ShareEnvelopeResponse {
328
+ /**
329
+ * Wrapped FROST share — AES-256-GCM ciphertext of the cleartext
330
+ * share, AAD-bound to `(credential_id, surface_key)`. Base64url
331
+ * no-pad.
332
+ */
333
+ wrapped_share_b64: string;
334
+ /** Wrap algorithm identifier — `"aes-256-gcm"` on testnet. */
335
+ alg: string;
336
+ /** Salt used by the wallet's local unwrap KDF, base64url no-pad. */
337
+ salt_b64: string;
338
+ }
339
+ /** Response from `POST /wallet/share/escrow/challenge`. */
340
+ export interface ShareEscrowChallengeResponse {
341
+ /**
342
+ * 32-byte random nonce, base64url no-pad. Must be passed verbatim
343
+ * as the WebAuthn `challenge` field.
344
+ */
345
+ nonce_b64: string;
346
+ /** Unix-millis at which the escrow entry is swept (30s TTL). */
347
+ expires_at_ms: number;
348
+ }
349
+ /** Response from `POST /wallet/share/escrow/unwrap`. */
350
+ export interface ShareEscrowUnwrapResponse {
351
+ /**
352
+ * Same wrapped FROST share returned by
353
+ * {@link CustodyClient.shareEnvelope}. Returned again here so a
354
+ * wallet can perform challenge → unwrap in a single round-trip
355
+ * without holding the envelope client-side.
356
+ */
357
+ wrapped_share_b64: string;
358
+ /**
359
+ * Per-assertion entropy mixed into the wallet's local unwrap KDF.
360
+ * Without this value the wrapped share is gibberish even to a
361
+ * caller holding a valid AAP token. Base64url no-pad.
362
+ */
363
+ pepper_b64: string;
113
364
  }
114
365
  //# sourceMappingURL=custody.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"custody.d.ts","sourceRoot":"","sources":["../src/custody.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,wCAAwC;AACxC,MAAM,WAAW,SAAS;IACxB,wBAAwB;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,iCAAiC;AACjC,MAAM,WAAW,iBAAiB;IAChC,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,0DAA0D;AAC1D,MAAM,WAAW,QAAQ;IACvB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,0CAA0C;AAC1C,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,+BAA+B;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,yBAAyB;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