tenzro-sdk 0.2.0 → 0.4.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 (141) hide show
  1. package/README.md +11 -1
  2. package/dist/adaptive-burn.js +4 -4
  3. package/dist/adaptive-burn.js.map +1 -1
  4. package/dist/agent.d.ts +119 -11
  5. package/dist/agent.d.ts.map +1 -1
  6. package/dist/agent.js +162 -13
  7. package/dist/agent.js.map +1 -1
  8. package/dist/api-key.d.ts +128 -0
  9. package/dist/api-key.d.ts.map +1 -0
  10. package/dist/api-key.js +94 -0
  11. package/dist/api-key.js.map +1 -0
  12. package/dist/app.js +1 -1
  13. package/dist/app.js.map +1 -1
  14. package/dist/auth.d.ts +37 -0
  15. package/dist/auth.d.ts.map +1 -1
  16. package/dist/auth.js +11 -0
  17. package/dist/auth.js.map +1 -1
  18. package/dist/axelar.d.ts +54 -0
  19. package/dist/axelar.d.ts.map +1 -0
  20. package/dist/axelar.js +30 -0
  21. package/dist/axelar.js.map +1 -0
  22. package/dist/babylon.d.ts +46 -0
  23. package/dist/babylon.d.ts.map +1 -0
  24. package/dist/babylon.js +37 -0
  25. package/dist/babylon.js.map +1 -0
  26. package/dist/caip.d.ts +43 -0
  27. package/dist/caip.d.ts.map +1 -0
  28. package/dist/caip.js +29 -0
  29. package/dist/caip.js.map +1 -0
  30. package/dist/canton.d.ts +16 -18
  31. package/dist/canton.d.ts.map +1 -1
  32. package/dist/canton.js +16 -18
  33. package/dist/canton.js.map +1 -1
  34. package/dist/capital.d.ts +167 -0
  35. package/dist/capital.d.ts.map +1 -0
  36. package/dist/capital.js +117 -0
  37. package/dist/capital.js.map +1 -0
  38. package/dist/client.d.ts +108 -1
  39. package/dist/client.d.ts.map +1 -1
  40. package/dist/client.js +136 -0
  41. package/dist/client.js.map +1 -1
  42. package/dist/eip7702.d.ts +110 -0
  43. package/dist/eip7702.d.ts.map +1 -0
  44. package/dist/eip7702.js +73 -0
  45. package/dist/eip7702.js.map +1 -0
  46. package/dist/erc7683.d.ts +79 -0
  47. package/dist/erc7683.d.ts.map +1 -0
  48. package/dist/erc7683.js +82 -0
  49. package/dist/erc7683.js.map +1 -0
  50. package/dist/events.d.ts +45 -15
  51. package/dist/events.d.ts.map +1 -1
  52. package/dist/events.js +38 -8
  53. package/dist/events.js.map +1 -1
  54. package/dist/hyperlane.d.ts +47 -0
  55. package/dist/hyperlane.d.ts.map +1 -0
  56. package/dist/hyperlane.js +27 -0
  57. package/dist/hyperlane.js.map +1 -0
  58. package/dist/identity.d.ts +1 -1
  59. package/dist/identity.js +1 -1
  60. package/dist/index.d.ts +44 -4
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +55 -2
  63. package/dist/index.js.map +1 -1
  64. package/dist/iroh.d.ts +104 -0
  65. package/dist/iroh.d.ts.map +1 -0
  66. package/dist/iroh.js +102 -0
  67. package/dist/iroh.js.map +1 -0
  68. package/dist/marketplace.d.ts +2 -2
  69. package/dist/marketplace.js +2 -2
  70. package/dist/memory.d.ts +78 -0
  71. package/dist/memory.d.ts.map +1 -0
  72. package/dist/memory.js +60 -0
  73. package/dist/memory.js.map +1 -0
  74. package/dist/multimodal.d.ts +294 -0
  75. package/dist/multimodal.d.ts.map +1 -0
  76. package/dist/multimodal.js +160 -0
  77. package/dist/multimodal.js.map +1 -0
  78. package/dist/passkey.d.ts +193 -0
  79. package/dist/passkey.d.ts.map +1 -0
  80. package/dist/passkey.js +481 -0
  81. package/dist/passkey.js.map +1 -0
  82. package/dist/permit2.d.ts +49 -0
  83. package/dist/permit2.d.ts.map +1 -0
  84. package/dist/permit2.js +30 -0
  85. package/dist/permit2.js.map +1 -0
  86. package/dist/provider.d.ts +5 -4
  87. package/dist/provider.d.ts.map +1 -1
  88. package/dist/provider.js +8 -5
  89. package/dist/provider.js.map +1 -1
  90. package/dist/rpc.d.ts.map +1 -1
  91. package/dist/rpc.js +16 -0
  92. package/dist/rpc.js.map +1 -1
  93. package/dist/secure-mint.d.ts +39 -0
  94. package/dist/secure-mint.d.ts.map +1 -0
  95. package/dist/secure-mint.js +44 -0
  96. package/dist/secure-mint.js.map +1 -0
  97. package/dist/seed-agent.js +7 -7
  98. package/dist/seed-agent.js.map +1 -1
  99. package/dist/settlement.d.ts +23 -6
  100. package/dist/settlement.d.ts.map +1 -1
  101. package/dist/settlement.js +30 -7
  102. package/dist/settlement.js.map +1 -1
  103. package/dist/signer.d.ts +181 -0
  104. package/dist/signer.d.ts.map +1 -0
  105. package/dist/signer.js +69 -0
  106. package/dist/signer.js.map +1 -0
  107. package/dist/sla.d.ts +95 -0
  108. package/dist/sla.d.ts.map +1 -0
  109. package/dist/sla.js +70 -0
  110. package/dist/sla.js.map +1 -0
  111. package/dist/snapshot.d.ts +122 -0
  112. package/dist/snapshot.d.ts.map +1 -0
  113. package/dist/snapshot.js +80 -0
  114. package/dist/snapshot.js.map +1 -0
  115. package/dist/staking.d.ts +5 -5
  116. package/dist/staking.d.ts.map +1 -1
  117. package/dist/staking.js +8 -6
  118. package/dist/staking.js.map +1 -1
  119. package/dist/task.d.ts +56 -22
  120. package/dist/task.d.ts.map +1 -1
  121. package/dist/task.js +65 -31
  122. package/dist/task.js.map +1 -1
  123. package/dist/token.d.ts +41 -11
  124. package/dist/token.d.ts.map +1 -1
  125. package/dist/token.js.map +1 -1
  126. package/dist/training.d.ts +108 -0
  127. package/dist/training.d.ts.map +1 -0
  128. package/dist/training.js +53 -0
  129. package/dist/training.js.map +1 -0
  130. package/dist/types.d.ts +165 -38
  131. package/dist/types.d.ts.map +1 -1
  132. package/dist/types.js.map +1 -1
  133. package/dist/validator.d.ts +76 -0
  134. package/dist/validator.d.ts.map +1 -0
  135. package/dist/validator.js +47 -0
  136. package/dist/validator.js.map +1 -0
  137. package/dist/workflow.d.ts +98 -0
  138. package/dist/workflow.d.ts.map +1 -0
  139. package/dist/workflow.js +131 -0
  140. package/dist/workflow.js.map +1 -0
  141. package/package.json +2 -1
package/dist/signer.js ADDED
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ /**
3
+ * Pluggable signing surface for custom wallet developers — the
4
+ * TypeScript mirror of `tenzro-sdk::signer` (Rust). See
5
+ * `docs/SPECIFICATION.md` §15.10.2 for the full contract.
6
+ *
7
+ * The high-level surface (`createPasskeyWallet` / `signWithPasskey`)
8
+ * is built on these interfaces; there is no internal-only API.
9
+ *
10
+ * Why interfaces, not classes:
11
+ * - Custom MPC topologies, custom HSM integrations, air-gapped flows,
12
+ * and social-recovery topologies need to extend the surface without
13
+ * forking the SDK.
14
+ * - The SDK's defaults consume the same surface, so any feature that
15
+ * works for the SDK's `PasskeyWallet` works for a third-party
16
+ * wallet.
17
+ *
18
+ * Why this lives in the SDK and not in `tenzro-vm`:
19
+ * - `tenzro-vm` owns the on-chain validator modules; the SDK owns
20
+ * how an off-chain wallet produces the signature and the
21
+ * `validatorData` blob the user op carries.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.RecoveryError = exports.StorageError = exports.ValidatorError = exports.SignerError = exports.Erc7579ModuleType = void 0;
25
+ /** ERC-7579 module type. Numeric values match the on-chain enum. */
26
+ var Erc7579ModuleType;
27
+ (function (Erc7579ModuleType) {
28
+ Erc7579ModuleType[Erc7579ModuleType["Validator"] = 1] = "Validator";
29
+ Erc7579ModuleType[Erc7579ModuleType["Executor"] = 2] = "Executor";
30
+ Erc7579ModuleType[Erc7579ModuleType["Fallback"] = 3] = "Fallback";
31
+ Erc7579ModuleType[Erc7579ModuleType["Hook"] = 4] = "Hook";
32
+ })(Erc7579ModuleType || (exports.Erc7579ModuleType = Erc7579ModuleType = {}));
33
+ class SignerError extends Error {
34
+ kind;
35
+ constructor(kind, message) {
36
+ super(message);
37
+ this.kind = kind;
38
+ this.name = "SignerError";
39
+ }
40
+ }
41
+ exports.SignerError = SignerError;
42
+ class ValidatorError extends Error {
43
+ kind;
44
+ constructor(kind, message) {
45
+ super(message);
46
+ this.kind = kind;
47
+ this.name = "ValidatorError";
48
+ }
49
+ }
50
+ exports.ValidatorError = ValidatorError;
51
+ class StorageError extends Error {
52
+ kind;
53
+ constructor(kind, message) {
54
+ super(message);
55
+ this.kind = kind;
56
+ this.name = "StorageError";
57
+ }
58
+ }
59
+ exports.StorageError = StorageError;
60
+ class RecoveryError extends Error {
61
+ kind;
62
+ constructor(kind, message) {
63
+ super(message);
64
+ this.kind = kind;
65
+ this.name = "RecoveryError";
66
+ }
67
+ }
68
+ exports.RecoveryError = RecoveryError;
69
+ //# sourceMappingURL=signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAwBH,oEAAoE;AACpE,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,mEAAa,CAAA;IACb,iEAAY,CAAA;IACZ,iEAAY,CAAA;IACZ,yDAAQ,CAAA;AACV,CAAC,EALW,iBAAiB,iCAAjB,iBAAiB,QAK5B;AAwCD,MAAa,WAAY,SAAQ,KAAK;IACR;IAA5B,YAA4B,IAAqB,EAAE,OAAe;QAChE,KAAK,CAAC,OAAO,CAAC,CAAC;QADW,SAAI,GAAJ,IAAI,CAAiB;QAE/C,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AALD,kCAKC;AAUD,MAAa,cAAe,SAAQ,KAAK;IACX;IAA5B,YAA4B,IAAwB,EAAE,OAAe;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC;QADW,SAAI,GAAJ,IAAI,CAAoB;QAElD,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AALD,wCAKC;AA4BD,MAAa,YAAa,SAAQ,KAAK;IACT;IAA5B,YAA4B,IAAsB,EAAE,OAAe;QACjE,KAAK,CAAC,OAAO,CAAC,CAAC;QADW,SAAI,GAAJ,IAAI,CAAkB;QAEhD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAyDD,MAAa,aAAc,SAAQ,KAAK;IACV;IAA5B,YAA4B,IAAuB,EAAE,OAAe;QAClE,KAAK,CAAC,OAAO,CAAC,CAAC;QADW,SAAI,GAAJ,IAAI,CAAmB;QAEjD,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AALD,sCAKC"}
package/dist/sla.d.ts ADDED
@@ -0,0 +1,95 @@
1
+ import type { RpcClient } from './rpc';
2
+ /**
3
+ * Probe issued by `tenzro_slaIssueProbe`. The `challenge_nonce` is the
4
+ * 32-byte VRF output used to address the probe through its lifecycle.
5
+ */
6
+ export interface SlaProbeIssued {
7
+ /** 0x-prefixed hex of the issuing validator's address (32 bytes). */
8
+ issuer: string;
9
+ /** DID of the provider being probed. */
10
+ provider_did: string;
11
+ /** Validator epoch the probe was issued in. */
12
+ epoch: number;
13
+ /** Probe round within the epoch. */
14
+ round: number;
15
+ /** 0x-prefixed hex of the 32-byte VRF output addressing this probe. */
16
+ challenge_nonce: string;
17
+ /** Unix-millisecond deadline by which the provider must respond. */
18
+ deadline_ms: number;
19
+ /** 0x-prefixed hex of the issuing validator's VRF public key. */
20
+ vrf_pubkey: string;
21
+ }
22
+ /** A single entry in the outstanding-probes reflector. */
23
+ export interface SlaOutstandingProbe {
24
+ challenge_nonce: string;
25
+ provider_did: string;
26
+ epoch: number;
27
+ round: number;
28
+ deadline_ms: number;
29
+ /** 0x-prefixed hex of the issuing validator's address. */
30
+ issuer: string;
31
+ }
32
+ /** Result of `tenzro_slaListOutstandingProbes`. */
33
+ export interface SlaOutstandingProbes {
34
+ count: number;
35
+ probes: SlaOutstandingProbe[];
36
+ }
37
+ /** Result of `tenzro_slaGetParams`. */
38
+ export interface SlaParams {
39
+ /** Number of missed probes before slashing fires for a provider. */
40
+ slash_threshold: number;
41
+ /** Per-crossing slash amount in wei, as a decimal string. */
42
+ slash_amount_wei: string;
43
+ /** 0x-prefixed hex of this validator's VRF public key. */
44
+ vrf_pubkey: string;
45
+ }
46
+ /**
47
+ * Validator-side SLA fault-detector inspection client.
48
+ *
49
+ * Wraps:
50
+ * - `tenzro_slaIssueProbe` — issue a VRF-bound liveness probe to a
51
+ * ModelProvider / TeeProvider DID and broadcast it on the
52
+ * `tenzro/sla` gossipsub topic. **Validator-only** — non-validator
53
+ * nodes return `-32000 SlaManager not initialized`.
54
+ * - `tenzro_slaListOutstandingProbes` — list every in-flight probe
55
+ * awaiting a response, regardless of who issued it. Used by
56
+ * operators to spot stuck probes whose deadline has already
57
+ * elapsed without a response.
58
+ * - `tenzro_slaGetParams` — read-only surface for the fault-detector
59
+ * parameters (`slash_threshold`, `slash_amount_wei`, this
60
+ * validator's VRF public key).
61
+ */
62
+ export declare class SlaClient {
63
+ private readonly rpc;
64
+ constructor(rpc: RpcClient);
65
+ /**
66
+ * Issue a VRF-bound liveness probe to `providerDid`. Validator-only.
67
+ *
68
+ * The issuing node computes the VRF output over
69
+ * `(provider_did, epoch, round)`, registers the probe in its
70
+ * in-memory outstanding-probe map (so a fast response cannot race
71
+ * the insertion), and broadcasts it on the `tenzro/sla` gossipsub
72
+ * topic.
73
+ *
74
+ * @param providerDid - DID of the provider being probed
75
+ * @param epoch - Validator epoch the probe is issued in
76
+ * @param round - Probe round within the epoch
77
+ * @param deadlineMs - Unix-millisecond timestamp by which the
78
+ * provider must respond before the probe is considered missed
79
+ */
80
+ issueProbe(providerDid: string, epoch: number, round: number, deadlineMs: number): Promise<SlaProbeIssued>;
81
+ /**
82
+ * List every in-flight probe awaiting a response from any provider,
83
+ * regardless of issuer. Used by operators to spot probes whose
84
+ * `deadline_ms` has already elapsed without a matching response.
85
+ */
86
+ listOutstandingProbes(): Promise<SlaOutstandingProbes>;
87
+ /**
88
+ * Read the fault-detector parameters this validator is using.
89
+ * Returns the slash threshold (missed probes before slashing
90
+ * fires), the per-crossing slash amount in wei, and this
91
+ * validator's VRF public key.
92
+ */
93
+ getParams(): Promise<SlaParams>;
94
+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EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC;IAW1B;;;;OAIG;IACG,qBAAqB,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAO5D;;;;;OAKG;IACG,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;CAGtC"}
package/dist/sla.js ADDED
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SlaClient = void 0;
4
+ // ── Client ──
5
+ /**
6
+ * Validator-side SLA fault-detector inspection client.
7
+ *
8
+ * Wraps:
9
+ * - `tenzro_slaIssueProbe` — issue a VRF-bound liveness probe to a
10
+ * ModelProvider / TeeProvider DID and broadcast it on the
11
+ * `tenzro/sla` gossipsub topic. **Validator-only** — non-validator
12
+ * nodes return `-32000 SlaManager not initialized`.
13
+ * - `tenzro_slaListOutstandingProbes` — list every in-flight probe
14
+ * awaiting a response, regardless of who issued it. Used by
15
+ * operators to spot stuck probes whose deadline has already
16
+ * elapsed without a response.
17
+ * - `tenzro_slaGetParams` — read-only surface for the fault-detector
18
+ * parameters (`slash_threshold`, `slash_amount_wei`, this
19
+ * validator's VRF public key).
20
+ */
21
+ class SlaClient {
22
+ rpc;
23
+ constructor(rpc) {
24
+ this.rpc = rpc;
25
+ }
26
+ /**
27
+ * Issue a VRF-bound liveness probe to `providerDid`. Validator-only.
28
+ *
29
+ * The issuing node computes the VRF output over
30
+ * `(provider_did, epoch, round)`, registers the probe in its
31
+ * in-memory outstanding-probe map (so a fast response cannot race
32
+ * the insertion), and broadcasts it on the `tenzro/sla` gossipsub
33
+ * topic.
34
+ *
35
+ * @param providerDid - DID of the provider being probed
36
+ * @param epoch - Validator epoch the probe is issued in
37
+ * @param round - Probe round within the epoch
38
+ * @param deadlineMs - Unix-millisecond timestamp by which the
39
+ * provider must respond before the probe is considered missed
40
+ */
41
+ async issueProbe(providerDid, epoch, round, deadlineMs) {
42
+ return this.rpc.call('tenzro_slaIssueProbe', [
43
+ {
44
+ provider_did: providerDid,
45
+ epoch,
46
+ round,
47
+ deadline_ms: deadlineMs,
48
+ },
49
+ ]);
50
+ }
51
+ /**
52
+ * List every in-flight probe awaiting a response from any provider,
53
+ * regardless of issuer. Used by operators to spot probes whose
54
+ * `deadline_ms` has already elapsed without a matching response.
55
+ */
56
+ async listOutstandingProbes() {
57
+ return this.rpc.call('tenzro_slaListOutstandingProbes', []);
58
+ }
59
+ /**
60
+ * Read the fault-detector parameters this validator is using.
61
+ * Returns the slash threshold (missed probes before slashing
62
+ * fires), the per-crossing slash amount in wei, and this
63
+ * validator's VRF public key.
64
+ */
65
+ async getParams() {
66
+ return this.rpc.call('tenzro_slaGetParams', []);
67
+ }
68
+ }
69
+ exports.SlaClient = SlaClient;
70
+ //# sourceMappingURL=sla.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sla.js","sourceRoot":"","sources":["../src/sla.ts"],"names":[],"mappings":";;;AAoDA,eAAe;AAEf;;;;;;;;;;;;;;;GAeG;AACH,MAAa,SAAS;IACS;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,UAAU,CACd,WAAmB,EACnB,KAAa,EACb,KAAa,EACb,UAAkB;QAElB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAiB,sBAAsB,EAAE;YAC3D;gBACE,YAAY,EAAE,WAAW;gBACzB,KAAK;gBACL,KAAK;gBACL,WAAW,EAAE,UAAU;aACxB;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,qBAAqB;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAClB,iCAAiC,EACjC,EAAE,CACH,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAY,qBAAqB,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF;AAvDD,8BAuDC"}
@@ -0,0 +1,122 @@
1
+ import type { RpcClient } from './rpc';
2
+ /**
3
+ * Compact summary returned by `tenzro_listSnapshots`. Per-chunk hashes
4
+ * are elided here — fetch the full manifest with
5
+ * `getSnapshotManifest(height)` to verify chunks.
6
+ */
7
+ export interface SnapshotSummary {
8
+ height: number;
9
+ state_root_hex: string;
10
+ num_chunks: number;
11
+ created_at: string;
12
+ format: number;
13
+ }
14
+ /** Result of `tenzro_listSnapshots`. */
15
+ export interface SnapshotList {
16
+ snapshots: SnapshotSummary[];
17
+ }
18
+ /**
19
+ * Full snapshot manifest with per-chunk SHA-256 hashes. Returned by
20
+ * `tenzro_getSnapshotManifest` and consumed by `tenzro_offerSnapshot`.
21
+ */
22
+ export interface SnapshotManifest {
23
+ /** Block height at which this snapshot was taken. */
24
+ height: number;
25
+ /**
26
+ * State root committed at `height`. The caller MUST verify this
27
+ * against a trusted QC at the same height before offering or
28
+ * applying this snapshot.
29
+ */
30
+ state_root_hex: string;
31
+ /** Number of chunks. Chunk indices are `0..num_chunks`. */
32
+ num_chunks: number;
33
+ /**
34
+ * Per-chunk SHA-256 hash (hex), indexed by chunk number. Used by the
35
+ * receiver to verify chunks before disk write.
36
+ */
37
+ chunk_hashes_hex: string[];
38
+ /** Wall-clock time the snapshot was produced (ISO 8601, UTC). */
39
+ created_at: string;
40
+ /** Manifest format version. */
41
+ format: number;
42
+ }
43
+ /**
44
+ * Result of `tenzro_getSnapshotChunk`. `data_b64` is the base64-encoded
45
+ * chunk bytes.
46
+ */
47
+ export interface SnapshotChunk {
48
+ height: number;
49
+ chunk_index: number;
50
+ data_b64: string;
51
+ }
52
+ /** Result of `tenzro_offerSnapshot`. */
53
+ export interface SnapshotOfferAccepted {
54
+ accepted: boolean;
55
+ height: number;
56
+ num_chunks: number;
57
+ }
58
+ /**
59
+ * Result of `tenzro_applySnapshotChunk`. `complete` flips to `true` on
60
+ * the final chunk, after which the snapshot has been atomically
61
+ * committed via `write_batch_sync`.
62
+ */
63
+ export interface SnapshotChunkApplied {
64
+ complete: boolean;
65
+ height: number;
66
+ chunk_index: number;
67
+ }
68
+ /**
69
+ * State-sync snapshot client.
70
+ *
71
+ * Wraps the five snapshot RPCs that drive state-sync between nodes:
72
+ * - `tenzro_listSnapshots` — enumerate local snapshots
73
+ * - `tenzro_getSnapshotManifest` — full manifest including per-chunk hashes
74
+ * - `tenzro_getSnapshotChunk` — fetch a single chunk by index
75
+ * - `tenzro_offerSnapshot` — register an inbound manifest from a peer
76
+ * - `tenzro_applySnapshotChunk` — write one inbound chunk
77
+ *
78
+ * **Trust model:** Callers MUST verify `manifest.state_root_hex` against
79
+ * a trusted QC at the same height before calling `offerSnapshot` /
80
+ * `applySnapshotChunk`. The node verifies per-chunk SHA-256 against
81
+ * the manifest before any disk write, and atomically commits on the
82
+ * final chunk via `write_batch_sync`.
83
+ */
84
+ export declare class SnapshotClient {
85
+ private readonly rpc;
86
+ constructor(rpc: RpcClient);
87
+ /**
88
+ * Enumerate local snapshots. Per-chunk hashes are elided for
89
+ * compactness — use `getSnapshotManifest(height)` to retrieve the
90
+ * full manifest.
91
+ */
92
+ listSnapshots(): Promise<SnapshotList>;
93
+ /**
94
+ * Fetch the full manifest for the snapshot at `height`, including
95
+ * per-chunk SHA-256 hashes. Returns the node's `-32004 no snapshot
96
+ * at height` error if no snapshot is taken at that height.
97
+ */
98
+ getSnapshotManifest(height: number): Promise<SnapshotManifest>;
99
+ /**
100
+ * Fetch one chunk by `(height, chunkIndex)`. The returned `data_b64`
101
+ * is the base64-encoded chunk bytes; verify against
102
+ * `manifest.chunk_hashes_hex[chunkIndex]` before applying.
103
+ */
104
+ getSnapshotChunk(height: number, chunkIndex: number): Promise<SnapshotChunk>;
105
+ /**
106
+ * Register an inbound manifest from a peer.
107
+ *
108
+ * **Caller MUST verify `manifest.state_root_hex` against a trusted QC
109
+ * at the same height before invoking.** This RPC only registers the
110
+ * offer and provisions the spool directory; it does not itself
111
+ * validate the manifest against chain state.
112
+ */
113
+ offerSnapshot(manifest: SnapshotManifest): Promise<SnapshotOfferAccepted>;
114
+ /**
115
+ * Write one inbound chunk. The chunk's SHA-256 is verified against
116
+ * `manifest.chunk_hashes_hex[chunkIndex]` before any disk write. On
117
+ * the final chunk, all chunks are decoded and atomically committed
118
+ * via `write_batch_sync`; `complete` will be `true` on that call.
119
+ */
120
+ applySnapshotChunk(height: number, chunkIndex: number, dataB64: string): Promise<SnapshotChunkApplied>;
121
+ }
122
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wCAAwC;AACxC,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wCAAwC;AACxC,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAID;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAE3C;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC;IAI5C;;;;OAIG;IACG,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAMpE;;;;OAIG;IACG,gBAAgB,CACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,CAAC;IAMzB;;;;;;;OAOG;IACG,aAAa,CACjB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,CAAC;IAMjC;;;;;OAKG;IACG,kBAAkB,CACtB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC;CAKjC"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SnapshotClient = void 0;
4
+ // ── Client ──
5
+ /**
6
+ * State-sync snapshot client.
7
+ *
8
+ * Wraps the five snapshot RPCs that drive state-sync between nodes:
9
+ * - `tenzro_listSnapshots` — enumerate local snapshots
10
+ * - `tenzro_getSnapshotManifest` — full manifest including per-chunk hashes
11
+ * - `tenzro_getSnapshotChunk` — fetch a single chunk by index
12
+ * - `tenzro_offerSnapshot` — register an inbound manifest from a peer
13
+ * - `tenzro_applySnapshotChunk` — write one inbound chunk
14
+ *
15
+ * **Trust model:** Callers MUST verify `manifest.state_root_hex` against
16
+ * a trusted QC at the same height before calling `offerSnapshot` /
17
+ * `applySnapshotChunk`. The node verifies per-chunk SHA-256 against
18
+ * the manifest before any disk write, and atomically commits on the
19
+ * final chunk via `write_batch_sync`.
20
+ */
21
+ class SnapshotClient {
22
+ rpc;
23
+ constructor(rpc) {
24
+ this.rpc = rpc;
25
+ }
26
+ /**
27
+ * Enumerate local snapshots. Per-chunk hashes are elided for
28
+ * compactness — use `getSnapshotManifest(height)` to retrieve the
29
+ * full manifest.
30
+ */
31
+ async listSnapshots() {
32
+ return this.rpc.call('tenzro_listSnapshots', []);
33
+ }
34
+ /**
35
+ * Fetch the full manifest for the snapshot at `height`, including
36
+ * per-chunk SHA-256 hashes. Returns the node's `-32004 no snapshot
37
+ * at height` error if no snapshot is taken at that height.
38
+ */
39
+ async getSnapshotManifest(height) {
40
+ return this.rpc.call('tenzro_getSnapshotManifest', [
41
+ { height },
42
+ ]);
43
+ }
44
+ /**
45
+ * Fetch one chunk by `(height, chunkIndex)`. The returned `data_b64`
46
+ * is the base64-encoded chunk bytes; verify against
47
+ * `manifest.chunk_hashes_hex[chunkIndex]` before applying.
48
+ */
49
+ async getSnapshotChunk(height, chunkIndex) {
50
+ return this.rpc.call('tenzro_getSnapshotChunk', [
51
+ { height, chunk_index: chunkIndex },
52
+ ]);
53
+ }
54
+ /**
55
+ * Register an inbound manifest from a peer.
56
+ *
57
+ * **Caller MUST verify `manifest.state_root_hex` against a trusted QC
58
+ * at the same height before invoking.** This RPC only registers the
59
+ * offer and provisions the spool directory; it does not itself
60
+ * validate the manifest against chain state.
61
+ */
62
+ async offerSnapshot(manifest) {
63
+ return this.rpc.call('tenzro_offerSnapshot', [
64
+ manifest,
65
+ ]);
66
+ }
67
+ /**
68
+ * Write one inbound chunk. The chunk's SHA-256 is verified against
69
+ * `manifest.chunk_hashes_hex[chunkIndex]` before any disk write. On
70
+ * the final chunk, all chunks are decoded and atomically committed
71
+ * via `write_batch_sync`; `complete` will be `true` on that call.
72
+ */
73
+ async applySnapshotChunk(height, chunkIndex, dataB64) {
74
+ return this.rpc.call('tenzro_applySnapshotChunk', [
75
+ { height, chunk_index: chunkIndex, data_b64: dataB64 },
76
+ ]);
77
+ }
78
+ }
79
+ exports.SnapshotClient = SnapshotClient;
80
+ //# sourceMappingURL=snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":";;;AA4EA,eAAe;AAEf;;;;;;;;;;;;;;;GAeG;AACH,MAAa,cAAc;IACI;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C;;;;OAIG;IACH,KAAK,CAAC,aAAa;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAe,sBAAsB,EAAE,EAAE,CAAC,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,mBAAmB,CAAC,MAAc;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAmB,4BAA4B,EAAE;YACnE,EAAE,MAAM,EAAE;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CACpB,MAAc,EACd,UAAkB;QAElB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAgB,yBAAyB,EAAE;YAC7D,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,aAAa,CACjB,QAA0B;QAE1B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAwB,sBAAsB,EAAE;YAClE,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,kBAAkB,CACtB,MAAc,EACd,UAAkB,EAClB,OAAe;QAEf,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAuB,2BAA2B,EAAE;YACtE,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE;SACvD,CAAC,CAAC;IACL,CAAC;CACF;AApED,wCAoEC"}
package/dist/staking.d.ts CHANGED
@@ -8,15 +8,15 @@ export declare class StakingClient {
8
8
  private readonly rpc;
9
9
  constructor(rpc: RpcClient);
10
10
  /**
11
- * Stake TNZO tokens for a given role.
12
- * @param amount - Amount of TNZO to stake (decimal string, e.g. "1000")
13
- * @param role - Staking role: "validator", "model_provider", or "tee_provider"
11
+ * Stake TNZO tokens for a given provider type.
12
+ * @param amount - Amount in wei (10^-18 TNZO) as decimal string, e.g. "1000000000000000000000" for 1000 TNZO
13
+ * @param providerType - Provider type: "validator", "model_provider", "tee_provider", or "storage_provider"
14
14
  * @returns Stake result with transaction hash and status
15
15
  */
16
- stake(amount: string, role: StakingRole): Promise<StakeResult>;
16
+ stake(amount: string, providerType: StakingRole): Promise<StakeResult>;
17
17
  /**
18
18
  * Unstake TNZO tokens (initiates the unbonding period).
19
- * @param amount - Amount of TNZO to unstake (decimal string)
19
+ * @param amount - Amount in wei (10^-18 TNZO) as decimal string
20
20
  * @returns Unstake result with transaction hash, status, and unbonding end time
21
21
  */
22
22
  unstake(amount: string): Promise<UnstakeResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAE3C;;;;;OAKG;IACG,KAAK,CAAC,MA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ingClient {
11
11
  this.rpc = rpc;
12
12
  }
13
13
  /**
14
- * Stake TNZO tokens for a given role.
15
- * @param amount - Amount of TNZO to stake (decimal string, e.g. "1000")
16
- * @param role - Staking role: "validator", "model_provider", or "tee_provider"
14
+ * Stake TNZO tokens for a given provider type.
15
+ * @param amount - Amount in wei (10^-18 TNZO) as decimal string, e.g. "1000000000000000000000" for 1000 TNZO
16
+ * @param providerType - Provider type: "validator", "model_provider", "tee_provider", or "storage_provider"
17
17
  * @returns Stake result with transaction hash and status
18
18
  */
19
- async stake(amount, role) {
20
- return this.rpc.call('tenzro_stake', [{ amount, role }]);
19
+ async stake(amount, providerType) {
20
+ return this.rpc.call('tenzro_stake', [
21
+ { amount, provider_type: providerType },
22
+ ]);
21
23
  }
22
24
  /**
23
25
  * Unstake TNZO tokens (initiates the unbonding period).
24
- * @param amount - Amount of TNZO to unstake (decimal string)
26
+ * @param amount - Amount in wei (10^-18 TNZO) as decimal string
25
27
  * @returns Unstake result with transaction hash, status, and unbonding end time
26
28
  */
27
29
  async unstake(amount) {
@@ -1 +1 @@
1
- {"version":3,"file":"staking.js","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":";;;AAUA;;;GAGG;AACH,MAAa,aAAa;IACK;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C;;;;;OAKG;IACH,KAAK,CAAC,KAAK,CAAC,MAAc,EAAE,IAAiB;QAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAc,cAAc,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,MAAc;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAgB,gBAAgB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB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,CAAC,OAAe;QAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAiB,0BAA0B,EAAE;YAC/D,EAAE,OAAO,EAAE;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAAC,OAAe;QAChC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAmB,qBAAqB,EAAE;YAC5D,EAAE,OAAO,EAAE;SACZ,CAAC,CAAC;IACL,CAAC;CACF;AAxDD,sCAwDC"}
package/dist/task.d.ts CHANGED
@@ -1,5 +1,19 @@
1
1
  import type { RpcClient } from './rpc';
2
2
  import type { TaskInfo, TaskQuote, TaskFilter, PostTaskParams, AssignTaskResult, CompleteTaskResult } from './types';
3
+ /**
4
+ * Task-marketplace client.
5
+ *
6
+ * Full settlement cycle on the live testnet:
7
+ *
8
+ * await client.task.postTask({ title, poster, max_price, task_type, input })
9
+ * await client.task.quoteTask(taskId, providerAddress, price, { model_id, ... })
10
+ * await client.task.assignTask(taskId, providerAddress, quotedPrice)
11
+ * await client.task.completeTask(taskId, output) // <- triggers TNZO transfer
12
+ *
13
+ * `completeTask` performs the on-chain settlement: `tenzro-token`
14
+ * transfers `final_price` (the quoted price, or `max_price` if unquoted)
15
+ * from poster to assignee through the unified token registry.
16
+ */
3
17
  export declare class TaskClient {
4
18
  private readonly rpc;
5
19
  constructor(rpc: RpcClient);
@@ -7,40 +21,60 @@ export declare class TaskClient {
7
21
  listTasks(filter?: TaskFilter): Promise<TaskInfo[]>;
8
22
  getTask(taskId: string): Promise<TaskInfo>;
9
23
  cancelTask(taskId: string): Promise<boolean>;
10
- submitQuote(taskId: string, price: string, modelId: string, estimatedDurationSecs: number): Promise<TaskQuote>;
11
24
  /**
12
- * Submit a quote for a task with price and estimated completion time.
13
- * @param taskId - The task to quote
14
- * @param price - Quoted price (in TNZO wei)
15
- * @param estimatedTime - Estimated completion time (e.g., "120s", "5m", "1h")
16
- * @returns Quote result
25
+ * Submit a quote for a task.
26
+ *
27
+ * @param taskId - The task to quote.
28
+ * @param provider - Provider address (hex). Required the live RPC
29
+ * rejects quotes that lack a provider address.
30
+ * @param price - Quoted price in TNZO wei (u128 as decimal string).
31
+ * @param opts.modelId - Optional model identifier (default: `"any"`).
32
+ * @param opts.confidence - Quote confidence 0–100 (default: 80).
33
+ * @param opts.estimatedDurationSecs - Estimated runtime in seconds (default: 60).
34
+ * @param opts.notes - Optional free-form notes.
17
35
  */
18
- quoteTask(taskId: string, price: number, estimatedTime: string): Promise<any>;
36
+ quoteTask(taskId: string, provider: string, price: string, opts?: {
37
+ modelId?: string;
38
+ confidence?: number;
39
+ estimatedDurationSecs?: number;
40
+ notes?: string;
41
+ }): Promise<TaskQuote>;
19
42
  /**
20
- * Assign a task to a specific agent.
21
- * @param taskId - The task to assign
22
- * @param agentId - The agent to assign it to
23
- * @returns Assignment result with status
43
+ * Assign a task to a specific provider address.
44
+ *
45
+ * The live RPC handler keys assignment on the provider's wallet
46
+ * address, not an agent_id — the task's `assignee` field is set to
47
+ * `provider`, and `quoted_price` is stored on the task so that
48
+ * `completeTask` can settle to it.
49
+ *
50
+ * @param taskId - The task to assign.
51
+ * @param provider - Provider wallet address (hex).
52
+ * @param quotedPrice - Optional locked-in price in TNZO wei
53
+ * (u128 as decimal string). If omitted, the task's `max_price`
54
+ * is used at settlement time.
24
55
  */
25
- assignTask(taskId: string, agentId: string): Promise<AssignTaskResult>;
56
+ assignTask(taskId: string, provider: string, quotedPrice?: string): Promise<AssignTaskResult>;
26
57
  /**
27
- * Mark a task as completed with the final result.
28
- * @param taskId - The task to complete
29
- * @param result - The output / result of the task
30
- * @returns Completion result with status and optional settlement tx hash
58
+ * Mark a task as completed and trigger on-chain TNZO settlement.
59
+ *
60
+ * The live RPC handler:
61
+ * 1. transfers `final_price` from poster to assignee via the token registry,
62
+ * 2. sets `task.status = Completed`,
63
+ * 3. stores `output` on the task,
64
+ * 4. returns the new poster/assignee balances under `settlement`.
65
+ *
66
+ * @param taskId - The task to complete.
67
+ * @param output - The result / output text to attach to the task.
31
68
  */
32
- completeTask(taskId: string, result: string): Promise<CompleteTaskResult>;
69
+ completeTask(taskId: string, output: string): Promise<CompleteTaskResult>;
33
70
  /**
34
- * Update an existing task.
35
- * @param taskId - The task to update
36
- * @param options - Fields to update (partial)
37
- * @returns Updated task information
71
+ * Update an existing task (creator only).
38
72
  */
39
73
  updateTask(taskId: string, options?: {
40
74
  title?: string;
41
75
  description?: string;
42
76
  status?: string;
43
77
  output?: string;
44
- }): Promise<any>;
78
+ }): Promise<TaskInfo>;
45
79
  }
46
80
  //# sourceMappingURL=task.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../src/task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAErH,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAInD,SAAS,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAInD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI1C,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI5C,WAAW,CACf,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,qBAAqB,EAAE,MAAM,GAC5B,OAAO,CAAC,SAAS,CAAC;IASrB;;;;;;OAMG;IACG,SAAS,CACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,aAAa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