@escro/sdk 0.3.0 → 0.4.1
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/README.md +6 -14
- package/dist/index.cjs +182 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -138
- package/dist/index.d.ts +210 -138
- package/dist/index.js +177 -46
- package/dist/index.js.map +1 -1
- package/package.json +16 -18
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Keypair } from '@solana/web3.js';
|
|
2
2
|
|
|
3
|
+
type SolanaCluster = "devnet" | "mainnet";
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* All possible lifecycle states of an AgentEscrow account on-chain.
|
|
5
7
|
*
|
|
@@ -61,20 +63,25 @@ interface EscrowAccount {
|
|
|
61
63
|
state: EscrowState;
|
|
62
64
|
/**
|
|
63
65
|
* SHA-256 hex digest of the canonical UTF-8 JSON serialisation of the {@link TaskSpec}.
|
|
64
|
-
*
|
|
66
|
+
* Recorded on-chain (the account's `spec_hash` holds this hash, bare, or as `ipfs://<hash>` on
|
|
67
|
+
* escrows created before P18.T0c), so the buyer and worker (and an arbitrator) can check that a
|
|
68
|
+
* spec is the one the escrow was created for.
|
|
65
69
|
*/
|
|
66
70
|
taskSpecHash: string;
|
|
67
71
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
72
|
+
* The exact string the escrow's on-chain `spec_hash` holds: the bare 64-hex `taskSpecHash`
|
|
73
|
+
* (escrows created since P18.T0c), `ipfs://<taskSpecHash>` (earlier), `null` before the
|
|
74
|
+
* spec_uri migration ran. A label for the {@link TaskSpec}'s hash, not a fetchable copy (Escro
|
|
75
|
+
* stores no spec body; the buyer shares the spec).
|
|
70
76
|
*/
|
|
71
77
|
taskSpecUri: string | null;
|
|
72
78
|
/** Base-58 public key of the oracle authority permitted to sign timeout_release / refund_buyer. */
|
|
73
79
|
oracle: string;
|
|
74
80
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
81
|
+
* Platform fee in basis points. The API serves the value it recorded at registration
|
|
82
|
+
* (`PLATFORM_FEE_BPS`, the mirror of PlatformConfig `fee_bps`); on chain `create_escrow`
|
|
83
|
+
* stores PlatformConfig's value. Additive: the buyer deposits `amount` plus the fee and
|
|
84
|
+
* the worker receives the full `amount`.
|
|
78
85
|
*/
|
|
79
86
|
oracleFeeBps: number;
|
|
80
87
|
/** Unix timestamp (seconds) when the escrow PDA was initialised. */
|
|
@@ -108,8 +115,8 @@ interface EscrowAccount {
|
|
|
108
115
|
/** Solana cluster this account belongs to. */
|
|
109
116
|
network: Network;
|
|
110
117
|
}
|
|
111
|
-
/**
|
|
112
|
-
interface
|
|
118
|
+
/** One set of `GET /v1/stats` figures: the public block, or the operator block. */
|
|
119
|
+
interface ProtocolStatsFigures {
|
|
113
120
|
totalEscrows: number;
|
|
114
121
|
totalVolumeUsdc: string;
|
|
115
122
|
/**
|
|
@@ -125,6 +132,20 @@ interface ProtocolStats {
|
|
|
125
132
|
byState: Record<EscrowState, number>;
|
|
126
133
|
activeEscrows: number;
|
|
127
134
|
}
|
|
135
|
+
/** Protocol-wide aggregate statistics: public, unauthenticated. */
|
|
136
|
+
interface ProtocolStats extends ProtocolStatsFigures {
|
|
137
|
+
/** The Solana cluster this API serves (its `CLUSTER`). */
|
|
138
|
+
cluster: SolanaCluster;
|
|
139
|
+
/** That cluster's one USDC mint (`getUsdcMint`): every figure here is in this token. */
|
|
140
|
+
usdcMint: string;
|
|
141
|
+
/**
|
|
142
|
+
* Escro-operated fleet figures (ARCHITECTURE section 9): the same fields over
|
|
143
|
+
* escrows whose buyer and assigned worker are both in the API's operator
|
|
144
|
+
* allowlist. They are real settlements but not third-party demand, so every
|
|
145
|
+
* public field excludes them; never sum this block with the public fields.
|
|
146
|
+
*/
|
|
147
|
+
operator: ProtocolStatsFigures;
|
|
148
|
+
}
|
|
128
149
|
|
|
129
150
|
/**
|
|
130
151
|
* Broad categories of agent work.
|
|
@@ -194,14 +215,16 @@ interface AcceptanceCriterion {
|
|
|
194
215
|
* This object is:
|
|
195
216
|
* 1. Serialised to canonical UTF-8 JSON (sorted keys, no trailing whitespace).
|
|
196
217
|
* 2. Hashed with SHA-256 → stored on-chain as `EscrowAccount.taskSpecHash`.
|
|
197
|
-
* 3.
|
|
218
|
+
* 3. Written into `create_escrow`'s `spec_hash` bare (since P18.T0c; `ipfs://<hash>` before) and
|
|
219
|
+
* recorded as `EscrowAccount.taskSpecUri` (a label for the hash; Escro stores no spec body,
|
|
220
|
+
* and the buyer shares the spec itself).
|
|
198
221
|
*
|
|
199
222
|
* Any mutation of the spec changes its hash, invalidating the on-chain record.
|
|
200
223
|
*/
|
|
201
224
|
interface TaskSpec {
|
|
202
225
|
/**
|
|
203
226
|
* Semver string identifying the task spec schema version (e.g. `"1.0.0"`).
|
|
204
|
-
*
|
|
227
|
+
* Lets the API, SDKs and bots handle format evolution gracefully.
|
|
205
228
|
* Increment the minor version for backwards-compatible additions;
|
|
206
229
|
* the major version for breaking changes.
|
|
207
230
|
*/
|
|
@@ -211,13 +234,14 @@ interface TaskSpec {
|
|
|
211
234
|
*/
|
|
212
235
|
taskType: TaskType;
|
|
213
236
|
/**
|
|
214
|
-
* Complete description of the task, written for both the
|
|
215
|
-
* and the
|
|
237
|
+
* Complete description of the task, written for both the worker performing it
|
|
238
|
+
* and the buyer judging the result (or, in a dispute, the human arbitrator
|
|
239
|
+
* reading it against the delivery). Escro never evaluates a deliverable.
|
|
216
240
|
*
|
|
217
241
|
* Good descriptions:
|
|
218
242
|
* - State the goal, not just the method.
|
|
219
243
|
* - Include any non-obvious constraints (language, style, performance bounds).
|
|
220
|
-
* - Are precise enough that
|
|
244
|
+
* - Are precise enough that the buyer can check the delivery without ambiguity.
|
|
221
245
|
*/
|
|
222
246
|
description: string;
|
|
223
247
|
/**
|
|
@@ -236,8 +260,9 @@ interface TaskSpec {
|
|
|
236
260
|
}
|
|
237
261
|
|
|
238
262
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
263
|
+
* Every machine-readable error code the escro.ai REST API's route handlers send in the `code`
|
|
264
|
+
* field of an error response (a test derives the set from the API source). A request Fastify
|
|
265
|
+
* refuses before a handler runs carries Fastify's own `FST_ERR_*` code instead.
|
|
241
266
|
*
|
|
242
267
|
* Consumers should switch on this value to handle errors programmatically
|
|
243
268
|
* rather than parsing the human-readable `error` string.
|
|
@@ -247,32 +272,40 @@ type EscrowErrorCode =
|
|
|
247
272
|
"ESCROW_NOT_FOUND"
|
|
248
273
|
/** The requested operation is not permitted in the escrow's current state. */
|
|
249
274
|
| "ESCROW_INVALID_STATE"
|
|
250
|
-
/**
|
|
251
|
-
| "
|
|
252
|
-
/** The submitted task spec failed schema validation. */
|
|
253
|
-
| "TASK_SPEC_INVALID"
|
|
254
|
-
/** The caller does not have permission to perform this action. */
|
|
255
|
-
| "UNAUTHORIZED"
|
|
256
|
-
/** The provided transaction signature is invalid or does not match the escrow. */
|
|
257
|
-
| "INVALID_SIGNATURE"
|
|
258
|
-
/** The requested token amount is zero, negative, or exceeds the u64 maximum. */
|
|
259
|
-
| "INVALID_AMOUNT"
|
|
260
|
-
/** The escrow's network does not match the caller's requested network. */
|
|
261
|
-
| "NETWORK_MISMATCH"
|
|
262
|
-
/** The caller has exceeded the rate limit; retry after the indicated backoff. */
|
|
263
|
-
| "RATE_LIMITED"
|
|
264
|
-
/** An unexpected server-side error occurred; report to escro.ai support. */
|
|
265
|
-
| "INTERNAL_ERROR"
|
|
266
|
-
/** Request body or query parameters failed schema validation. */
|
|
267
|
-
| "VALIDATION_ERROR"
|
|
275
|
+
/** Release: the API's RPC still shows the escrow account open at `confirmed`; retry once the release lands. */
|
|
276
|
+
| "ESCROW_NOT_SETTLED"
|
|
268
277
|
/** Confirm: no transaction for the signature at `confirmed` yet; retry once it lands. */
|
|
269
278
|
| "TX_NOT_FOUND"
|
|
270
279
|
/** Confirm: the transaction landed with an error. */
|
|
271
280
|
| "TX_FAILED"
|
|
272
281
|
/** Confirm: the transaction holds no single escrow instruction this route records for the escrow. */
|
|
273
282
|
| "TX_MISMATCH"
|
|
274
|
-
/**
|
|
275
|
-
| "RPC_UNAVAILABLE"
|
|
283
|
+
/** The Solana RPC read failed; retry. */
|
|
284
|
+
| "RPC_UNAVAILABLE"
|
|
285
|
+
/** Missing, invalid or expired authentication, or a caller not permitted the action. */
|
|
286
|
+
| "UNAUTHORIZED"
|
|
287
|
+
/** EscroBots removal: the signer is not the directory-admin wallet. */
|
|
288
|
+
| "FORBIDDEN"
|
|
289
|
+
/** EscroBots: the bot descriptor's wallet signature does not verify. */
|
|
290
|
+
| "INVALID_DESCRIPTOR_SIGNATURE"
|
|
291
|
+
/** EscroBots: the descriptor names a wallet other than the signer. */
|
|
292
|
+
| "WALLET_MISMATCH"
|
|
293
|
+
/** EscroBots: the wallet was removed from the directory for fraud. */
|
|
294
|
+
| "WALLET_REMOVED"
|
|
295
|
+
/** EscroBots: the descriptor's timestamp is outside the accepted window. */
|
|
296
|
+
| "STALE_DESCRIPTOR"
|
|
297
|
+
/** EscroBots: a newer or equal registration already exists for the wallet. */
|
|
298
|
+
| "DESCRIPTOR_REPLAYED"
|
|
299
|
+
/** EscroBots: no bot is registered for the wallet. */
|
|
300
|
+
| "BOT_NOT_FOUND"
|
|
301
|
+
/** EscroBots: the requested sort needs a reputation source the deployment lacks. */
|
|
302
|
+
| "SORT_UNAVAILABLE"
|
|
303
|
+
/** The caller has exceeded the rate limit; retry after the indicated backoff. */
|
|
304
|
+
| "RATE_LIMITED"
|
|
305
|
+
/** An unexpected server-side error occurred. */
|
|
306
|
+
| "INTERNAL_ERROR"
|
|
307
|
+
/** Request body or query parameters failed schema validation. */
|
|
308
|
+
| "VALIDATION_ERROR";
|
|
276
309
|
|
|
277
310
|
/**
|
|
278
311
|
* EscroBots v0 - the permissionless capability directory (ARCHITECTURE §8).
|
|
@@ -322,7 +355,34 @@ interface BotDescriptor extends UnsignedBotDescriptor {
|
|
|
322
355
|
signature: string;
|
|
323
356
|
}
|
|
324
357
|
|
|
325
|
-
|
|
358
|
+
/** The submitted deliverable as the Buyer's review reads it off the escrow read model. */
|
|
359
|
+
interface ReviewDeliverable {
|
|
360
|
+
/**
|
|
361
|
+
* SHA-256 hex the worker submitted on-chain (mirrored to the read model). It is the
|
|
362
|
+
* worker's claim about the artifact: a review re-hashes the real artifact and never
|
|
363
|
+
* trusts this value on its own.
|
|
364
|
+
*/
|
|
365
|
+
contentHash: string;
|
|
366
|
+
/** URI the worker gave for the deliverable or its proof, or null if it gave none. */
|
|
367
|
+
proofUri: string | null;
|
|
368
|
+
}
|
|
369
|
+
/** A release decision. */
|
|
370
|
+
interface ReviewResult {
|
|
371
|
+
/** Release payment to the worker. */
|
|
372
|
+
accept: boolean;
|
|
373
|
+
/**
|
|
374
|
+
* When NOT accepting, whether to raise a dispute (human arbitration) rather than hold.
|
|
375
|
+
* A held SUBMITTED escrow is auto-released to the worker by the 24h protocol timeout,
|
|
376
|
+
* so a real reject predicate disputes to contest.
|
|
377
|
+
*/
|
|
378
|
+
dispute: boolean;
|
|
379
|
+
reason: string;
|
|
380
|
+
}
|
|
381
|
+
/** A named release policy the Buyer's review wires in. */
|
|
382
|
+
interface ReviewPolicy {
|
|
383
|
+
name: string;
|
|
384
|
+
evaluate(deliverable: ReviewDeliverable): ReviewResult | Promise<ReviewResult>;
|
|
385
|
+
}
|
|
326
386
|
|
|
327
387
|
/** Dispute tally with its outcome split (from the wallet's perspective). */
|
|
328
388
|
interface DisputeRecord {
|
|
@@ -413,6 +473,64 @@ interface ServedWalletReputation extends SerializedWalletReputation {
|
|
|
413
473
|
walletAgeSeconds: number | null;
|
|
414
474
|
}
|
|
415
475
|
|
|
476
|
+
/**
|
|
477
|
+
* Base class for all errors thrown by the @escro/sdk. `retryAfterMs` is the
|
|
478
|
+
* server's Retry-After delay, when it sent one in seconds.
|
|
479
|
+
*/
|
|
480
|
+
declare class EscroError extends Error {
|
|
481
|
+
readonly code: string;
|
|
482
|
+
readonly retryAfterMs?: number | undefined;
|
|
483
|
+
constructor(message: string, code?: string, retryAfterMs?: number | undefined);
|
|
484
|
+
}
|
|
485
|
+
/** The requested escrow was not found (HTTP 404). */
|
|
486
|
+
declare class EscrowNotFoundError extends EscroError {
|
|
487
|
+
constructor(address: string);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* The reputation endpoint is not available on this deployment (HTTP 404). A 404
|
|
491
|
+
* from `GET /rep` means no `ReputationSource` is mounted (the surface is
|
|
492
|
+
* unmounted), NOT that a wallet is unknown - unknown wallets return zeroed raw
|
|
493
|
+
* components, never a 404. Kept distinct from {@link EscrowNotFoundError}, whose
|
|
494
|
+
* 404 is about a missing escrow.
|
|
495
|
+
*/
|
|
496
|
+
declare class ReputationUnavailableError extends EscroError {
|
|
497
|
+
constructor();
|
|
498
|
+
}
|
|
499
|
+
/** The operation is not valid for the escrow's current state (HTTP 409). */
|
|
500
|
+
declare class EscrowStateError extends EscroError {
|
|
501
|
+
constructor(message: string);
|
|
502
|
+
}
|
|
503
|
+
/** Polling timed out after 24 hours without reaching the expected state. */
|
|
504
|
+
declare class EscrowTimeoutError extends EscroError {
|
|
505
|
+
constructor(address: string);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* A transaction landed (or was sent) but the API did not record it. `code` is the
|
|
509
|
+
* server's code (e.g. TX_MISMATCH, TX_FAILED, or TX_NOT_FOUND after the retry
|
|
510
|
+
* window), `NETWORK_ERROR` when the last attempt never reached the API, or
|
|
511
|
+
* `HTTP_<status>` when the answer carried no code. Call {@link Escro.confirm} again
|
|
512
|
+
* with `address` and `signature` to retry, no sooner than `retryAfterMs` when the
|
|
513
|
+
* API sent one.
|
|
514
|
+
*/
|
|
515
|
+
declare class EscroConfirmError extends EscroError {
|
|
516
|
+
readonly address: string;
|
|
517
|
+
readonly signature: string;
|
|
518
|
+
constructor(address: string, signature: string, code: string, message: string, retryAfterMs?: number);
|
|
519
|
+
}
|
|
520
|
+
/** The caller is not authorized to perform this action (HTTP 401/403). */
|
|
521
|
+
declare class UnauthorizedError extends EscroError {
|
|
522
|
+
constructor(message?: string);
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* A payment rail was requested that is not enabled in this build. The `x402`
|
|
526
|
+
* (synchronous) rail is reserved (ARCHITECTURE §7a) and lands in Phase 9;
|
|
527
|
+
* {@link Escro.pay} throws this until then. `rail` names the unavailable rail.
|
|
528
|
+
*/
|
|
529
|
+
declare class EscroRailNotEnabledError extends EscroError {
|
|
530
|
+
readonly rail: string;
|
|
531
|
+
constructor(rail: string);
|
|
532
|
+
}
|
|
533
|
+
|
|
416
534
|
/** Constructor options for the {@link Escro} client. */
|
|
417
535
|
interface EscroOptions {
|
|
418
536
|
/**
|
|
@@ -430,7 +548,7 @@ interface EscroOptions {
|
|
|
430
548
|
}
|
|
431
549
|
/** Parameters for creating a new escrow. */
|
|
432
550
|
interface CreateEscrowParams {
|
|
433
|
-
/**
|
|
551
|
+
/** The full task specification; the API records its hash, never its body. */
|
|
434
552
|
taskSpec: TaskSpec;
|
|
435
553
|
/**
|
|
436
554
|
* Worker's net payment in μUSDC (1 USDC = 1_000_000). Minimum: 5_000_000.
|
|
@@ -456,6 +574,21 @@ interface CreateEscrowResult {
|
|
|
456
574
|
/** Solana transaction signature. */
|
|
457
575
|
signature: string;
|
|
458
576
|
}
|
|
577
|
+
/**
|
|
578
|
+
* Return value from {@link Escro.releasePaymentWithOutcome}. The release landed on
|
|
579
|
+
* chain either way; `confirm` says whether the API recorded it. A failed confirm
|
|
580
|
+
* carries an `EscroConfirmError` (`address`, `signature`, `code`).
|
|
581
|
+
*/
|
|
582
|
+
interface ReleasePaymentOutcome {
|
|
583
|
+
/** Solana transaction signature of the landed `release_payment`. */
|
|
584
|
+
signature: string;
|
|
585
|
+
confirm: {
|
|
586
|
+
landed: true;
|
|
587
|
+
} | {
|
|
588
|
+
landed: false;
|
|
589
|
+
error: EscroConfirmError;
|
|
590
|
+
};
|
|
591
|
+
}
|
|
459
592
|
/** Parameters for submitting a deliverable. */
|
|
460
593
|
interface SubmitDeliverableParams {
|
|
461
594
|
/** SHA-256 hex digest (or content-addressed hash) of the deliverable content. */
|
|
@@ -465,7 +598,7 @@ interface SubmitDeliverableParams {
|
|
|
465
598
|
}
|
|
466
599
|
/** Parameters for raising a dispute. */
|
|
467
600
|
interface RaiseDisputeParams {
|
|
468
|
-
/** Human-readable reason for the dispute
|
|
601
|
+
/** Human-readable reason for the dispute: non-empty, at most 200 UTF-8 bytes. */
|
|
469
602
|
reason: string;
|
|
470
603
|
/** Optional URL to evidence supporting the dispute. */
|
|
471
604
|
evidence?: string;
|
|
@@ -532,7 +665,7 @@ interface WorkerCandidate {
|
|
|
532
665
|
*
|
|
533
666
|
* PLUMBING ONLY. The escrow rail is the sole implemented backend; the `x402`
|
|
534
667
|
* (synchronous) rail is reserved and lands in Phase 9 as an additive backend.
|
|
535
|
-
* Every name here is a FREEZE CONTRACT that Phase 9
|
|
668
|
+
* Every name here is a FREEZE CONTRACT that Phase 9 inherits "by name":
|
|
536
669
|
* enabling x402 must not be a breaking change for any kit-generated bot. The
|
|
537
670
|
* shapes below are pinned by a type-level test (src/__tests__/payments.test.ts);
|
|
538
671
|
* Phase 9 may add only OPTIONAL fields.
|
|
@@ -607,12 +740,26 @@ declare class Escro {
|
|
|
607
740
|
/**
|
|
608
741
|
* Release payment to the worker. Buyer must be the wallet in the constructor.
|
|
609
742
|
* Builds and submits the `release_payment` on-chain tx FIRST (the chain is the
|
|
610
|
-
* source of truth), then
|
|
611
|
-
*
|
|
743
|
+
* source of truth), then has the API record it, retrying as
|
|
744
|
+
* {@link Escro.releasePaymentWithOutcome} does. Use that method to see whether the
|
|
745
|
+
* API recorded the release.
|
|
612
746
|
*
|
|
613
747
|
* @returns Solana transaction signature.
|
|
614
748
|
*/
|
|
615
749
|
releasePayment(address: string): Promise<string>;
|
|
750
|
+
/**
|
|
751
|
+
* {@link Escro.releasePayment}, reporting whether the API recorded the release.
|
|
752
|
+
* `ESCROW_NOT_SETTLED` (the API's RPC does not yet show the escrow closed), the codes
|
|
753
|
+
* {@link Escro.confirm} retries and a network failure are retried for about 30 s. A
|
|
754
|
+
* failed record never throws: the release already landed, so the signature is returned
|
|
755
|
+
* with `confirm.landed: false` and an `EscroConfirmError` (the API's code, or
|
|
756
|
+
* `NETWORK_ERROR` when the last call never reached it). A release that failed at
|
|
757
|
+
* execution on chain throws an {@link EscroError} with code `TX_FAILED`, and the API is
|
|
758
|
+
* never asked to record it.
|
|
759
|
+
*
|
|
760
|
+
* @returns `{ signature, confirm }`.
|
|
761
|
+
*/
|
|
762
|
+
releasePaymentWithOutcome(address: string): Promise<ReleasePaymentOutcome>;
|
|
616
763
|
/**
|
|
617
764
|
* Raise a dispute for an escrow. Either the buyer or the assigned worker
|
|
618
765
|
* may call this. Signs and submits the `raise_dispute` on-chain tx, then confirms it with the API.
|
|
@@ -720,6 +867,7 @@ declare class Escro {
|
|
|
720
867
|
confirm(address: string, signature: string, opts?: {
|
|
721
868
|
evidence?: string;
|
|
722
869
|
}): Promise<EscrowAccount>;
|
|
870
|
+
private retryRecord;
|
|
723
871
|
private send;
|
|
724
872
|
private sendAndConfirm;
|
|
725
873
|
/**
|
|
@@ -794,8 +942,11 @@ declare class ApiClient {
|
|
|
794
942
|
unsignedTx: string;
|
|
795
943
|
}>;
|
|
796
944
|
/**
|
|
797
|
-
* POST /v1/escrows/:address/release
|
|
798
|
-
* Requires auth (buyer). No on-chain tx returned.
|
|
945
|
+
* POST /v1/escrows/:address/release: records the landed release once the API's RPC shows
|
|
946
|
+
* the escrow closed. Requires auth (buyer). No on-chain tx returned. A 409
|
|
947
|
+
* `ESCROW_NOT_SETTLED`, a 5xx or a 429 throws an {@link EscroError} with the server's code,
|
|
948
|
+
* or `HTTP_<status>` when the answer carries none; {@link Escro.releasePaymentWithOutcome}
|
|
949
|
+
* decides which to retry. Other refusals throw as every route does.
|
|
799
950
|
*/
|
|
800
951
|
releasePaymentDb(address: string): Promise<void>;
|
|
801
952
|
/**
|
|
@@ -871,63 +1022,6 @@ interface ServiceAdapter {
|
|
|
871
1022
|
*/
|
|
872
1023
|
declare function serviceResultToSubmitParams(result: ServiceResult): SubmitDeliverableParams;
|
|
873
1024
|
|
|
874
|
-
/**
|
|
875
|
-
* Base class for all errors thrown by the @escro/sdk. `retryAfterMs` is the
|
|
876
|
-
* server's Retry-After delay, when it sent one in seconds.
|
|
877
|
-
*/
|
|
878
|
-
declare class EscroError extends Error {
|
|
879
|
-
readonly code: string;
|
|
880
|
-
readonly retryAfterMs?: number | undefined;
|
|
881
|
-
constructor(message: string, code?: string, retryAfterMs?: number | undefined);
|
|
882
|
-
}
|
|
883
|
-
/** The requested escrow was not found (HTTP 404). */
|
|
884
|
-
declare class EscrowNotFoundError extends EscroError {
|
|
885
|
-
constructor(address: string);
|
|
886
|
-
}
|
|
887
|
-
/**
|
|
888
|
-
* The reputation endpoint is not available on this deployment (HTTP 404). A 404
|
|
889
|
-
* from `GET /rep` means no `ReputationSource` is mounted (the surface is
|
|
890
|
-
* unmounted), NOT that a wallet is unknown - unknown wallets return zeroed raw
|
|
891
|
-
* components, never a 404. Kept distinct from {@link EscrowNotFoundError}, whose
|
|
892
|
-
* 404 is about a missing escrow.
|
|
893
|
-
*/
|
|
894
|
-
declare class ReputationUnavailableError extends EscroError {
|
|
895
|
-
constructor();
|
|
896
|
-
}
|
|
897
|
-
/** The operation is not valid for the escrow's current state (HTTP 409). */
|
|
898
|
-
declare class EscrowStateError extends EscroError {
|
|
899
|
-
constructor(message: string);
|
|
900
|
-
}
|
|
901
|
-
/** Polling timed out after 24 hours without reaching the expected state. */
|
|
902
|
-
declare class EscrowTimeoutError extends EscroError {
|
|
903
|
-
constructor(address: string);
|
|
904
|
-
}
|
|
905
|
-
/**
|
|
906
|
-
* A transaction landed (or was sent) but the API did not record it. `code` is the
|
|
907
|
-
* server's code (e.g. TX_MISMATCH, TX_FAILED, or TX_NOT_FOUND after the retry
|
|
908
|
-
* window), `NETWORK_ERROR` when the last attempt never reached the API, or
|
|
909
|
-
* `HTTP_<status>` when the answer carried no code. Call {@link Escro.confirm} again
|
|
910
|
-
* with `address` and `signature` to retry.
|
|
911
|
-
*/
|
|
912
|
-
declare class EscroConfirmError extends EscroError {
|
|
913
|
-
readonly address: string;
|
|
914
|
-
readonly signature: string;
|
|
915
|
-
constructor(address: string, signature: string, code: string, message: string);
|
|
916
|
-
}
|
|
917
|
-
/** The caller is not authorized to perform this action (HTTP 401/403). */
|
|
918
|
-
declare class UnauthorizedError extends EscroError {
|
|
919
|
-
constructor(message?: string);
|
|
920
|
-
}
|
|
921
|
-
/**
|
|
922
|
-
* A payment rail was requested that is not enabled in this build. The `x402`
|
|
923
|
-
* (synchronous) rail is reserved (ARCHITECTURE §7a) and lands in Phase 9;
|
|
924
|
-
* {@link Escro.pay} throws this until then. `rail` names the unavailable rail.
|
|
925
|
-
*/
|
|
926
|
-
declare class EscroRailNotEnabledError extends EscroError {
|
|
927
|
-
readonly rail: string;
|
|
928
|
-
constructor(rail: string);
|
|
929
|
-
}
|
|
930
|
-
|
|
931
1025
|
/** Options controlling {@link assertServiceAdapterContract}. */
|
|
932
1026
|
interface AdapterContractOptions {
|
|
933
1027
|
/**
|
|
@@ -1020,7 +1114,7 @@ interface GradientsAdapterConfig {
|
|
|
1020
1114
|
/** Health-check port. Default: resolves `true`. */
|
|
1021
1115
|
checkHealth?: () => Promise<boolean>;
|
|
1022
1116
|
}
|
|
1023
|
-
/** Stable id/capabilities, LOCKED against `ADAPTER_DESCRIPTORS.gradients` by a kit test
|
|
1117
|
+
/** Stable id/capabilities, LOCKED against `ADAPTER_DESCRIPTORS.gradients` by a kit test. */
|
|
1024
1118
|
declare const GRADIENTS_ADAPTER_ID = "bittensor:sn56";
|
|
1025
1119
|
declare const GRADIENTS_CAPABILITIES: readonly ["fine-tune"];
|
|
1026
1120
|
/** Stable marker on the demo spec's metadata so the default subnet stub recognizes it. */
|
|
@@ -1029,7 +1123,7 @@ declare const GRADIENTS_DEMO_MARKER = "gradients-sn56-demo-v1";
|
|
|
1029
1123
|
declare const GRADIENTS_DEMO_EVAL_FLOOR = 0.8;
|
|
1030
1124
|
/**
|
|
1031
1125
|
* The canned Gradients demo job. Deterministic; its specHash is pinned by a test
|
|
1032
|
-
*
|
|
1126
|
+
* because the buyer journey depends on hash stability.
|
|
1033
1127
|
*/
|
|
1034
1128
|
declare const gradientsDemoJobSpec: TaskSpec;
|
|
1035
1129
|
/**
|
|
@@ -1042,7 +1136,7 @@ declare function solveGradientsDemo(): string;
|
|
|
1042
1136
|
* The BUYER's independent recompute of the demo eval score in [0, 1]. Reads the
|
|
1043
1137
|
* substantive output (the predictions) and compares it to the target map the buyer
|
|
1044
1138
|
* itself defines; it deliberately IGNORES any self-reported `eval.score` in the
|
|
1045
|
-
* deliverable, so release can never be worker-controlled
|
|
1139
|
+
* deliverable, so release can never be worker-controlled. Malformed
|
|
1046
1140
|
* or unparseable content scores 0 and never throws.
|
|
1047
1141
|
*/
|
|
1048
1142
|
declare function scoreGradientsDemoDeliverable(content: string | Buffer): number;
|
|
@@ -1097,8 +1191,8 @@ declare function solveRidgesDemo(): string;
|
|
|
1097
1191
|
* The BUYER's independent recompute of the demo acceptance, as a score in [0, 1].
|
|
1098
1192
|
* It reads the substantive output (the delivered test outputs) and recomputes the
|
|
1099
1193
|
* expected FizzBuzz result for each; it deliberately IGNORES any self-reported
|
|
1100
|
-
* pass/coverage in the deliverable, so release can never be worker-controlled
|
|
1101
|
-
*
|
|
1194
|
+
* pass/coverage in the deliverable, so release can never be worker-controlled.
|
|
1195
|
+
* Semantics:
|
|
1102
1196
|
* - Any delivered test whose output is wrong = the suite did not pass (exit != 0):
|
|
1103
1197
|
* score 0, no matter how much of the battery is covered.
|
|
1104
1198
|
* - Otherwise the score is coverage = (distinct battery inputs delivered) / (battery
|
|
@@ -1114,7 +1208,7 @@ declare function createRidgesAdapter(config?: RidgesAdapterConfig): ServiceAdapt
|
|
|
1114
1208
|
|
|
1115
1209
|
/**
|
|
1116
1210
|
* 404gen (Bittensor SN17) ServiceAdapter: a batch 3D-generation reference adapter,
|
|
1117
|
-
* built to the pattern the shipped Gradients (SN56) adapter established
|
|
1211
|
+
* built to the pattern the shipped Gradients (SN56) adapter established. A
|
|
1118
1212
|
* Worker Bot wraps the 404gen text-to-3D subnet behind the `ServiceAdapter` interface:
|
|
1119
1213
|
* it swaps a per-task USDC budget into TAO internally, pays subnet miners in TAO to
|
|
1120
1214
|
* generate a batch of 3D assets, collects the batch deliverable, and returns a
|
|
@@ -1159,7 +1253,7 @@ interface Gen404AdapterConfig {
|
|
|
1159
1253
|
/** Health-check port. Default: resolves `true`. */
|
|
1160
1254
|
checkHealth?: () => Promise<boolean>;
|
|
1161
1255
|
}
|
|
1162
|
-
/** Stable id/capabilities, to be locked against `ADAPTER_DESCRIPTORS["404gen"]` by a kit test at merge
|
|
1256
|
+
/** Stable id/capabilities, to be locked against `ADAPTER_DESCRIPTORS["404gen"]` by a kit test at merge. */
|
|
1163
1257
|
declare const GEN404_ADAPTER_ID = "bittensor:sn17";
|
|
1164
1258
|
declare const GEN404_CAPABILITIES: readonly ["3d-generation"];
|
|
1165
1259
|
/** Stable marker on the demo spec's metadata so the default subnet stub recognizes it. */
|
|
@@ -1168,7 +1262,7 @@ declare const GEN404_DEMO_MARKER = "404gen-sn17-demo-v1";
|
|
|
1168
1262
|
declare const GEN404_DEMO_EVAL_FLOOR = 1;
|
|
1169
1263
|
/**
|
|
1170
1264
|
* The canned 404gen demo job. Deterministic; its specHash is pinned by a test
|
|
1171
|
-
*
|
|
1265
|
+
* because the buyer journey depends on hash stability.
|
|
1172
1266
|
*/
|
|
1173
1267
|
declare const gen404DemoJobSpec: TaskSpec;
|
|
1174
1268
|
/**
|
|
@@ -1432,7 +1526,7 @@ declare function solveRenderDemo(): string;
|
|
|
1432
1526
|
* the deliverable satisfies all three criteria and 0 otherwise. It checks completion
|
|
1433
1527
|
* (status), frame presence, and a frame match by RE-RENDERING the scripted scene and
|
|
1434
1528
|
* comparing the substantive frame; it deliberately IGNORES any self-reported
|
|
1435
|
-
* `frameHash`, so release can never be worker-controlled
|
|
1529
|
+
* `frameHash`, so release can never be worker-controlled. Malformed or
|
|
1436
1530
|
* unparseable content scores 0 and never throws.
|
|
1437
1531
|
*/
|
|
1438
1532
|
declare function scoreRenderDemoDeliverable(content: string | Buffer): number;
|
|
@@ -1562,7 +1656,7 @@ declare const gensynDemoJobSpec: TaskSpec;
|
|
|
1562
1656
|
*/
|
|
1563
1657
|
declare function createGensynAdapter(config?: GensynAdapterConfig): ServiceAdapter;
|
|
1564
1658
|
|
|
1565
|
-
/** Stable id/capabilities; locked against the EscroBots registry descriptor by a kit test at merge
|
|
1659
|
+
/** Stable id/capabilities; locked against the EscroBots registry descriptor by a kit test at merge. */
|
|
1566
1660
|
declare const ZKML_ADAPTER_ID = "zkml";
|
|
1567
1661
|
declare const ZKML_CAPABILITIES: readonly ["zk-verified-inference"];
|
|
1568
1662
|
/** Marker on the demo spec's metadata so the default inference port recognizes it. */
|
|
@@ -1637,34 +1731,11 @@ declare function verifyZkmlProof(proof: unknown, expected: ZkmlExpectation): Zkm
|
|
|
1637
1731
|
/** Decode an inline proof URI (or reject a missing/foreign one) and verify it. */
|
|
1638
1732
|
declare function verifyZkmlProofUri(uri: string | null | undefined, expected: ZkmlExpectation): ZkmlVerification;
|
|
1639
1733
|
/** The submitted deliverable as the Buyer's review reads it off the escrow read model. */
|
|
1640
|
-
|
|
1641
|
-
/**
|
|
1642
|
-
* SHA-256 hex the WORKER submitted on-chain (mirrored to the read model). It is the
|
|
1643
|
-
* worker's CLAIM about the artifact; {@link zkmlProofAutoRelease} re-hashes the real
|
|
1644
|
-
* artifact (via its `fetchContent` port) and never trusts this value on its own.
|
|
1645
|
-
*/
|
|
1646
|
-
contentHash: string;
|
|
1647
|
-
/** URI where the ZK proof is (inline `zkml-proof:` or a pinned `ipfs://`), or null. */
|
|
1648
|
-
proofUri: string | null;
|
|
1649
|
-
}
|
|
1734
|
+
type ZkmlDeliverable = ReviewDeliverable;
|
|
1650
1735
|
/** A release decision: release, and if not, whether to contest via dispute. */
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
reason: string;
|
|
1655
|
-
}
|
|
1656
|
-
/**
|
|
1657
|
-
* A named release policy the Buyer's review wires in. Field-for-field this mirrors the
|
|
1658
|
-
* buyer template's `ReviewPolicy`
|
|
1659
|
-
* (packages/create-escro-bot/templates/buyer/src/review.ts). The SDK cannot import the
|
|
1660
|
-
* scaffolding templates, and promoting the shared review shapes into `@escro/shared` is
|
|
1661
|
-
* a cross-package change owned by `main`, not this lane -- tracked as a merge-time
|
|
1662
|
-
* follow-up (LANE-NOTES).
|
|
1663
|
-
*/
|
|
1664
|
-
interface ZkmlReviewPolicy {
|
|
1665
|
-
name: string;
|
|
1666
|
-
evaluate(deliverable: ZkmlDeliverable): Promise<ZkmlReviewResult>;
|
|
1667
|
-
}
|
|
1736
|
+
type ZkmlReviewResult = ReviewResult;
|
|
1737
|
+
/** A named release policy the Buyer's review wires in; `evaluate` may be sync or async. */
|
|
1738
|
+
type ZkmlReviewPolicy = ReviewPolicy;
|
|
1668
1739
|
/** Options for {@link zkmlProofAutoRelease}. */
|
|
1669
1740
|
interface ZkmlProofAutoReleaseOptions {
|
|
1670
1741
|
/**
|
|
@@ -1751,4 +1822,5 @@ declare function solveZkmlDemo(): string;
|
|
|
1751
1822
|
*/
|
|
1752
1823
|
declare function createZkmlAdapter(config?: ZkmlAdapterConfig): ServiceAdapter;
|
|
1753
1824
|
|
|
1754
|
-
export { AKASH_ADAPTER_ID, AKASH_CAPABILITIES, AKASH_DEMO_ACCEPT_FLOOR, AKASH_DEMO_MARKER,
|
|
1825
|
+
export { AKASH_ADAPTER_ID, AKASH_CAPABILITIES, AKASH_DEMO_ACCEPT_FLOOR, AKASH_DEMO_MARKER, AdapterContractError, ApiClient, ENABLED_RAILS, Escro, EscroConfirmError, EscroError, EscroRailNotEnabledError, EscrowNotFoundError, EscrowPaymentRouter, EscrowState, EscrowStateError, EscrowTimeoutError, GEN404_ADAPTER_ID, GEN404_CAPABILITIES, GEN404_DEMO_EVAL_FLOOR, GEN404_DEMO_MARKER, GENSYN_ADAPTER_ID, GENSYN_CAPABILITIES, GENSYN_DEMO_MARKER, GENSYN_REE_SCHEME, GRADIENTS_ADAPTER_ID, GRADIENTS_CAPABILITIES, GRADIENTS_DEMO_EVAL_FLOOR, GRADIENTS_DEMO_MARKER, LIUM_ADAPTER_ID, LIUM_CAPABILITIES, LIUM_DEMO_ACCEPT_FLOOR, LIUM_DEMO_MARKER, RAILS, RAILS_DOCS_URL, REFERENCE_MICRO_USDC_PER_AKT, REFERENCE_MICRO_USDC_PER_RENDER, RENDER_ADAPTER_ID, RENDER_CAPABILITIES, RENDER_DEMO_ACCEPT_FLOOR, RENDER_DEMO_MARKER, RIDGES_ADAPTER_ID, RIDGES_CAPABILITIES, RIDGES_DEMO_COVERAGE_TARGET, RIDGES_DEMO_MARKER, ReputationUnavailableError, UnauthorizedError, ZKML_ADAPTER_ID, ZKML_CAPABILITIES, ZKML_DEMO_MARKER, ZKML_PROOF_SCHEME, ZKML_PROOF_URI_PREFIX, akashDemoJobSpec, akt, assertServiceAdapterContract, buildReeProof, buildZkmlProof, computeAkashDemoArtifact, computeLiumDemoArtifact, computeRenderDemoArtifact, create404genAdapter, createAkashAdapter, createGensynAdapter, createGradientsAdapter, createLiumAdapter, createRenderAdapter, createRidgesAdapter, createZkmlAdapter, decodeZkmlProofUri, encodeZkmlProofUri, gen404DemoJobSpec, gensynAutoRelease, gensynDemoJobSpec, gradientsDemoJobSpec, liumDemoJobSpec, renderAmount, renderDemoJobSpec, reproduceGensynCompute, ridgesDemoJobSpec, score404genDemoDeliverable, scoreAkashDemoDeliverable, scoreGradientsDemoDeliverable, scoreLiumDemoDeliverable, scoreRenderDemoDeliverable, scoreRidgesDemoDeliverable, serviceResultToSubmitParams, solveAkashDemo, solveGen404Demo, solveGradientsDemo, solveLiumDemo, solveRenderDemo, solveRidgesDemo, solveZkmlDemo, tao, verifyReeProof, verifyZkmlProof, verifyZkmlProofUri, zkmlDemoJobSpec, zkmlProofAutoRelease };
|
|
1826
|
+
export type { AcceptanceCriterion, AdapterContractOptions, AkashAdapterConfig, Akt, AutoReleaseDecision, BotDescriptor, BotRole, CreateEscrowParams, CreateEscrowResult, DeliverableFormat, DeliverableType, EscroOptions, EscrowAccount, EscrowErrorCode, Gen404AdapterConfig, GensynAdapterConfig, GensynDeliverableBundle, GradientsAdapterConfig, ListBotsParams, ListOptions, LiumAdapterConfig, Network, PaginatedResult, PayParams, PaymentResult, PaymentRouter, PinContent$3 as PinContent, PollOptions, ProtocolStats, Rail, RaiseDisputeParams, ReeExecution, ReeProof, ReeVerification, ReeVerifyContext, ReleasePaymentOutcome, Render, RenderAdapterConfig, ReproduceCompute, RidgesAdapterConfig, RunAkashDeployment, RunCodingAgent, RunGpuJob, RunRenderJob, ServedWalletReputation, ServiceAdapter, ServiceResult, SubmitDeliverableParams, SubnetCall, Tao, TaskSpec, TaskType, TxShape, UnsignedBotDescriptor, UsdcToAktSwap, UsdcToRenderSwap, UsdcToTaoSwap, WorkerCandidate, ZkmlAdapterConfig, ZkmlDeliverable, ZkmlExpectation, ZkmlInferenceOutput, ZkmlProof, ZkmlProofAutoReleaseOptions, ZkmlReviewPolicy, ZkmlReviewResult, ZkmlVerification };
|