@tangle-network/sandbox 0.60.16 → 0.60.17-develop.20261006080745.649508b
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 +21 -0
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/agent/preview.d.ts +1 -1
- package/dist/{client-CbOQtx9b.d.ts → client-6u7a1HMx.d.ts} +105 -2
- package/dist/{client-CT9Td-BV.js → client-BtsaKP2y.js} +93 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/gpu-lease/index.d.ts +503 -0
- package/dist/gpu-lease/index.js +410 -0
- package/dist/index.d.ts +12 -12
- package/dist/index.js +2 -2
- package/dist/intelligence/index.d.ts +75 -1
- package/dist/intelligence/index.js +71 -20
- package/dist/{preview-T96_mF5c.d.ts → preview-BXglWD2M.d.ts} +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
//#region src/gpu-lease/intent.d.ts
|
|
2
|
+
declare const INTENT_VERSION = 1;
|
|
3
|
+
/** keccak256 of the canonical intent string. */
|
|
4
|
+
declare function gpuLeaseIntentHash(input: {
|
|
5
|
+
intentVersion: number;
|
|
6
|
+
gpuClass: string;
|
|
7
|
+
durationSeconds: bigint | number;
|
|
8
|
+
confidentiality: number;
|
|
9
|
+
region: string;
|
|
10
|
+
}): `0x${string}`;
|
|
11
|
+
/** ABI shape of GpuLeaseRequest — mirrors the blueprint's sol! type. */
|
|
12
|
+
declare const GPU_LEASE_REQUEST_ABI: never;
|
|
13
|
+
interface GpuLeaseRequestParams {
|
|
14
|
+
intentVersion: number;
|
|
15
|
+
intentHash: `0x${string}`;
|
|
16
|
+
pricePerSecondWei: bigint;
|
|
17
|
+
durationSeconds: bigint;
|
|
18
|
+
confidentiality: number;
|
|
19
|
+
gpuClass: string;
|
|
20
|
+
region: string;
|
|
21
|
+
lessee: `0x${string}`;
|
|
22
|
+
leaseId: `0x${string}`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* ABI-encoded GpuLeaseRequest — the LEASE job calldata payload.
|
|
26
|
+
* Positional (ABI order) — order is pinned by the blueprint's generated
|
|
27
|
+
* encodeType in metadata/blueprint.json.
|
|
28
|
+
*/
|
|
29
|
+
declare function encodeGpuLeaseRequest(params: GpuLeaseRequestParams): `0x${string}`;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/gpu-lease/types.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* GPU lease client types — mirrors the gpu-lease-blueprint operator API
|
|
34
|
+
* (gpu-lease-blueprint/gpu-lease-blueprint-lib/src/api.rs) and the on-chain
|
|
35
|
+
* ABI (contracts/src/GpuLeaseBlueprint.sol sol! mirror).
|
|
36
|
+
*
|
|
37
|
+
* Every on-chain and off-chain surface is schemaVersioned; unknown versions
|
|
38
|
+
* fail closed (SPEC §3 of the blueprint).
|
|
39
|
+
*/
|
|
40
|
+
/** The only schema this client understands. */
|
|
41
|
+
declare const GPU_LEASE_SCHEMA_VERSION: 1;
|
|
42
|
+
interface ClassCapability {
|
|
43
|
+
id: string;
|
|
44
|
+
tee: boolean;
|
|
45
|
+
unit: string;
|
|
46
|
+
/** Indicative policy price (wei/second) — the binding price is the quote. */
|
|
47
|
+
pricePerSecond: string;
|
|
48
|
+
idleCount: number;
|
|
49
|
+
}
|
|
50
|
+
interface Capabilities {
|
|
51
|
+
schemaVersion: number;
|
|
52
|
+
compute: {
|
|
53
|
+
kind: string;
|
|
54
|
+
classes: ClassCapability[];
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
interface OperatorQuote {
|
|
58
|
+
schemaVersion: number;
|
|
59
|
+
gpuClass: string;
|
|
60
|
+
/** The operator's EVM address — who the escrow names (I5 binding).
|
|
61
|
+
* When the quote is signed this MUST equal the recovered signer (verified
|
|
62
|
+
* in quotes.ts); config-supplied values are interim-trust only. */
|
|
63
|
+
operatorAddress: `0x${string}`;
|
|
64
|
+
/** EIP-191 personal_sign over the canonical quote payload (0x RSV). */
|
|
65
|
+
signature?: `0x${string}`;
|
|
66
|
+
/** wei/second, from the operator's signed policy at request time. */
|
|
67
|
+
pricePerSecond: string;
|
|
68
|
+
durationSeconds: number;
|
|
69
|
+
confidentiality: number;
|
|
70
|
+
/** wei — pricePerSecond × durationSeconds exactly. */
|
|
71
|
+
escrowTotal: string;
|
|
72
|
+
/** Utilization the price was struck at (bps of 10_000) — the surge "why". */
|
|
73
|
+
utilizationBps: number;
|
|
74
|
+
/** keccak256(canonical intent) — binds the RFQ and the vault lease (I5). */
|
|
75
|
+
intentHash: `0x${string}`;
|
|
76
|
+
/** Unix seconds after which the quote is stale. */
|
|
77
|
+
validUntil: number;
|
|
78
|
+
}
|
|
79
|
+
interface LeaseStatus {
|
|
80
|
+
schemaVersion: number;
|
|
81
|
+
leaseId: `0x${string}`;
|
|
82
|
+
deviceId: string;
|
|
83
|
+
lessee: string;
|
|
84
|
+
/** Unix seconds — the chain-of-truth session end (parking meter). */
|
|
85
|
+
expiresAt: number;
|
|
86
|
+
endpoint: string;
|
|
87
|
+
}
|
|
88
|
+
interface SessionChallenge {
|
|
89
|
+
nonce: `0x${string}`;
|
|
90
|
+
/** The exact string the lessee must EIP-191 personal_sign. */
|
|
91
|
+
message: string;
|
|
92
|
+
expiresAt: number;
|
|
93
|
+
}
|
|
94
|
+
interface SessionCredential {
|
|
95
|
+
token: string;
|
|
96
|
+
leaseId: `0x${string}`;
|
|
97
|
+
scopes: string[];
|
|
98
|
+
expiresAt: number;
|
|
99
|
+
}
|
|
100
|
+
/** A validated, ready-to-escrow quote. */
|
|
101
|
+
interface ValidatedQuote {
|
|
102
|
+
quote: OperatorQuote;
|
|
103
|
+
pricePerSecondWei: bigint;
|
|
104
|
+
escrowTotalWei: bigint;
|
|
105
|
+
}
|
|
106
|
+
/** A resolved lease handed to the caller by `gpuLease()`. */
|
|
107
|
+
interface GpuLease {
|
|
108
|
+
leaseId: `0x${string}`;
|
|
109
|
+
/** Public endpoint descriptor (versioned union; v1 = local-attach). */
|
|
110
|
+
endpoint: string;
|
|
111
|
+
schemaVersion: number;
|
|
112
|
+
quote: ValidatedQuote;
|
|
113
|
+
}
|
|
114
|
+
interface RefundReceipt {
|
|
115
|
+
leaseId: `0x${string}`;
|
|
116
|
+
/** Exact wei refunded: pricePerSecond × remainingSeconds at settle time. */
|
|
117
|
+
refundWei: bigint;
|
|
118
|
+
operatorTakeWei: bigint;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/gpu-lease/operators.d.ts
|
|
122
|
+
interface QuoteParams {
|
|
123
|
+
gpuClass: string;
|
|
124
|
+
durationSeconds: number;
|
|
125
|
+
confidentiality?: number;
|
|
126
|
+
region?: string;
|
|
127
|
+
}
|
|
128
|
+
interface OperatorEndpoint {
|
|
129
|
+
/** Operator base URL, e.g. https://gpu.example.com */
|
|
130
|
+
baseUrl: string;
|
|
131
|
+
/** The operator's EVM address (escrow + job binding). */
|
|
132
|
+
address: `0x${string}`;
|
|
133
|
+
fetch?: typeof fetch;
|
|
134
|
+
}
|
|
135
|
+
/** JSON request body — named at the I/O boundary (anti-slop: no `unknown`). */
|
|
136
|
+
type JsonRequestBody = Record<string, unknown>;
|
|
137
|
+
declare class GpuLeaseOperatorClient {
|
|
138
|
+
private readonly endpoint;
|
|
139
|
+
constructor(endpoint: OperatorEndpoint);
|
|
140
|
+
capabilities(): Promise<Capabilities>;
|
|
141
|
+
quote(params: QuoteParams): Promise<OperatorQuote>;
|
|
142
|
+
leaseStatus(leaseId: `0x${string}`): Promise<LeaseStatus>;
|
|
143
|
+
sessionChallenge(leaseId: `0x${string}`, lessee: string): Promise<SessionChallenge>;
|
|
144
|
+
sessionVerify(nonce: `0x${string}`, signature: `0x${string}`): Promise<SessionCredential>;
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/gpu-lease/output.d.ts
|
|
148
|
+
interface GpuLeaseOutputDecoded {
|
|
149
|
+
leaseId: `0x${string}`;
|
|
150
|
+
endpoint: string;
|
|
151
|
+
schemaVersion: number;
|
|
152
|
+
}
|
|
153
|
+
/** Decode + fail closed on unknown schemaVersion (blueprint SPEC §3). */
|
|
154
|
+
declare function decodeGpuLeaseOutput(encoded: `0x${string}`): GpuLeaseOutputDecoded;
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/gpu-lease/quotes.d.ts
|
|
157
|
+
/** The exact string the operator signs — mirrors the blueprint's
|
|
158
|
+
* `canonical_quote_payload` byte-for-byte. Every priced field is bound. */
|
|
159
|
+
declare function canonicalQuotePayload(quote: {
|
|
160
|
+
gpuClass: string;
|
|
161
|
+
pricePerSecond: string;
|
|
162
|
+
durationSeconds: number;
|
|
163
|
+
confidentiality: number;
|
|
164
|
+
escrowTotal: string;
|
|
165
|
+
intentHash: string;
|
|
166
|
+
validUntil: number;
|
|
167
|
+
}): string;
|
|
168
|
+
/** Offline EIP-191 recovery over the canonical payload. */
|
|
169
|
+
declare function verifyOperatorQuote(quote: OperatorQuote): Promise<`0x${string}`>;
|
|
170
|
+
type QuoteRejection = {
|
|
171
|
+
kind: "stale";
|
|
172
|
+
validUntil: number;
|
|
173
|
+
now: number;
|
|
174
|
+
} | {
|
|
175
|
+
kind: "class-mismatch";
|
|
176
|
+
requested: string;
|
|
177
|
+
quoted: string;
|
|
178
|
+
} | {
|
|
179
|
+
kind: "escrow-inconsistent";
|
|
180
|
+
expected: bigint;
|
|
181
|
+
actual: bigint;
|
|
182
|
+
} | {
|
|
183
|
+
kind: "confidentiality-mismatch";
|
|
184
|
+
requested: number;
|
|
185
|
+
quoted: number;
|
|
186
|
+
} | {
|
|
187
|
+
kind: "signature-mismatch";
|
|
188
|
+
claimed: string;
|
|
189
|
+
recovered: string;
|
|
190
|
+
} | {
|
|
191
|
+
kind: "unsigned";
|
|
192
|
+
operator: string;
|
|
193
|
+
};
|
|
194
|
+
interface QuoteFilterInput {
|
|
195
|
+
requestedClass: string;
|
|
196
|
+
requestedDurationSeconds: number;
|
|
197
|
+
requestedConfidentiality: number;
|
|
198
|
+
now?: () => number;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Validate one quote. Fail-closed on every field the RFQ binds:
|
|
202
|
+
* class, duration-derived escrow, confidentiality, and expiry.
|
|
203
|
+
*/
|
|
204
|
+
declare function validateQuote(quote: OperatorQuote, input: QuoteFilterInput): ValidatedQuote | QuoteRejection;
|
|
205
|
+
/**
|
|
206
|
+
* Collect validated quotes from N operators and rank cheapest-first.
|
|
207
|
+
* Operators that fail validation (or whose fetch rejects) are reported,
|
|
208
|
+
* never silently dropped — the buyer sees why an operator lost.
|
|
209
|
+
*/
|
|
210
|
+
declare function selectQuotes(quotes: {
|
|
211
|
+
operator: string;
|
|
212
|
+
quote: OperatorQuote;
|
|
213
|
+
}[], input: QuoteFilterInput): {
|
|
214
|
+
ranked: {
|
|
215
|
+
operator: string;
|
|
216
|
+
validated: ValidatedQuote;
|
|
217
|
+
}[];
|
|
218
|
+
rejected: {
|
|
219
|
+
operator: string;
|
|
220
|
+
reason: QuoteRejection;
|
|
221
|
+
}[];
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Enforce the signed RFQ envelope when present:
|
|
225
|
+
* - signature present => it MUST recover to the claimed operator address;
|
|
226
|
+
* invalid signature => reject (config-trust is dead on this path).
|
|
227
|
+
* - no signature => the endpoint-config address is used (interim fallback);
|
|
228
|
+
* strict mode rejects unsigned quotes outright.
|
|
229
|
+
*/
|
|
230
|
+
declare function validateQuoteIdentity(quote: OperatorQuote, opts?: {
|
|
231
|
+
strict?: boolean;
|
|
232
|
+
}): Promise<ValidatedQuote | QuoteRejection>;
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/gpu-lease/vault.d.ts
|
|
235
|
+
declare const GPU_LEASE_VAULT_ABI: readonly [{
|
|
236
|
+
readonly name: "create";
|
|
237
|
+
readonly type: "function";
|
|
238
|
+
readonly stateMutability: "payable";
|
|
239
|
+
readonly inputs: readonly [{
|
|
240
|
+
readonly type: "address";
|
|
241
|
+
readonly name: "operator";
|
|
242
|
+
}, {
|
|
243
|
+
readonly type: "uint128";
|
|
244
|
+
readonly name: "pricePerSecond";
|
|
245
|
+
}, {
|
|
246
|
+
readonly type: "uint64";
|
|
247
|
+
readonly name: "durationSeconds";
|
|
248
|
+
}, {
|
|
249
|
+
readonly type: "bytes32";
|
|
250
|
+
readonly name: "intentHash";
|
|
251
|
+
}, {
|
|
252
|
+
readonly type: "uint8";
|
|
253
|
+
readonly name: "confidentiality";
|
|
254
|
+
}, {
|
|
255
|
+
readonly type: "bytes";
|
|
256
|
+
readonly name: "endpointInfo";
|
|
257
|
+
}];
|
|
258
|
+
readonly outputs: readonly [{
|
|
259
|
+
readonly type: "bytes32";
|
|
260
|
+
readonly name: "leaseId";
|
|
261
|
+
}];
|
|
262
|
+
}, {
|
|
263
|
+
readonly name: "extend";
|
|
264
|
+
readonly type: "function";
|
|
265
|
+
readonly stateMutability: "payable";
|
|
266
|
+
readonly inputs: readonly [{
|
|
267
|
+
readonly type: "bytes32";
|
|
268
|
+
readonly name: "leaseId";
|
|
269
|
+
}, {
|
|
270
|
+
readonly type: "uint64";
|
|
271
|
+
readonly name: "addSeconds";
|
|
272
|
+
}];
|
|
273
|
+
readonly outputs: readonly [];
|
|
274
|
+
}, {
|
|
275
|
+
readonly name: "release";
|
|
276
|
+
readonly type: "function";
|
|
277
|
+
readonly stateMutability: "nonpayable";
|
|
278
|
+
readonly inputs: readonly [{
|
|
279
|
+
readonly type: "bytes32";
|
|
280
|
+
readonly name: "leaseId";
|
|
281
|
+
}];
|
|
282
|
+
readonly outputs: readonly [];
|
|
283
|
+
}, {
|
|
284
|
+
readonly name: "reap";
|
|
285
|
+
readonly type: "function";
|
|
286
|
+
readonly stateMutability: "nonpayable";
|
|
287
|
+
readonly inputs: readonly [{
|
|
288
|
+
readonly type: "bytes32";
|
|
289
|
+
readonly name: "leaseId";
|
|
290
|
+
}];
|
|
291
|
+
readonly outputs: readonly [];
|
|
292
|
+
}, {
|
|
293
|
+
readonly name: "withdrawEarnings";
|
|
294
|
+
readonly type: "function";
|
|
295
|
+
readonly stateMutability: "nonpayable";
|
|
296
|
+
readonly inputs: readonly [];
|
|
297
|
+
readonly outputs: readonly [];
|
|
298
|
+
}, {
|
|
299
|
+
readonly name: "totalEscrowed";
|
|
300
|
+
readonly type: "function";
|
|
301
|
+
readonly stateMutability: "view";
|
|
302
|
+
readonly inputs: readonly [];
|
|
303
|
+
readonly outputs: readonly [{
|
|
304
|
+
readonly type: "uint256";
|
|
305
|
+
}];
|
|
306
|
+
}, {
|
|
307
|
+
readonly name: "operatorEarnings";
|
|
308
|
+
readonly type: "function";
|
|
309
|
+
readonly stateMutability: "view";
|
|
310
|
+
readonly inputs: readonly [];
|
|
311
|
+
readonly outputs: readonly [{
|
|
312
|
+
readonly type: "uint256";
|
|
313
|
+
}];
|
|
314
|
+
}, {
|
|
315
|
+
readonly name: "leases";
|
|
316
|
+
readonly type: "function";
|
|
317
|
+
readonly stateMutability: "view";
|
|
318
|
+
readonly inputs: readonly [{
|
|
319
|
+
readonly type: "bytes32";
|
|
320
|
+
}];
|
|
321
|
+
readonly outputs: readonly [{
|
|
322
|
+
readonly type: "address";
|
|
323
|
+
readonly name: "operator";
|
|
324
|
+
}, {
|
|
325
|
+
readonly type: "address";
|
|
326
|
+
readonly name: "lessee";
|
|
327
|
+
}, {
|
|
328
|
+
readonly type: "uint128";
|
|
329
|
+
readonly name: "escrow";
|
|
330
|
+
}, {
|
|
331
|
+
readonly type: "uint128";
|
|
332
|
+
readonly name: "pricePerSecond";
|
|
333
|
+
}, {
|
|
334
|
+
readonly type: "uint64";
|
|
335
|
+
readonly name: "expiry";
|
|
336
|
+
}, {
|
|
337
|
+
readonly type: "bytes32";
|
|
338
|
+
readonly name: "intentHash";
|
|
339
|
+
}, {
|
|
340
|
+
readonly type: "uint8";
|
|
341
|
+
readonly name: "confidentiality";
|
|
342
|
+
}, {
|
|
343
|
+
readonly type: "uint8";
|
|
344
|
+
readonly name: "state";
|
|
345
|
+
}];
|
|
346
|
+
}, {
|
|
347
|
+
readonly name: "LeaseCreated";
|
|
348
|
+
readonly type: "event";
|
|
349
|
+
readonly inputs: readonly [{
|
|
350
|
+
readonly type: "bytes32";
|
|
351
|
+
readonly name: "leaseId";
|
|
352
|
+
readonly indexed: true;
|
|
353
|
+
}, {
|
|
354
|
+
readonly type: "address";
|
|
355
|
+
readonly name: "operator";
|
|
356
|
+
readonly indexed: true;
|
|
357
|
+
}, {
|
|
358
|
+
readonly type: "address";
|
|
359
|
+
readonly name: "lessee";
|
|
360
|
+
readonly indexed: true;
|
|
361
|
+
}, {
|
|
362
|
+
readonly type: "uint128";
|
|
363
|
+
readonly name: "escrow";
|
|
364
|
+
}, {
|
|
365
|
+
readonly type: "uint128";
|
|
366
|
+
readonly name: "pricePerSecond";
|
|
367
|
+
}, {
|
|
368
|
+
readonly type: "uint64";
|
|
369
|
+
readonly name: "expiry";
|
|
370
|
+
}, {
|
|
371
|
+
readonly type: "bytes32";
|
|
372
|
+
readonly name: "intentHash";
|
|
373
|
+
}, {
|
|
374
|
+
readonly type: "uint8";
|
|
375
|
+
readonly name: "confidentiality";
|
|
376
|
+
}, {
|
|
377
|
+
readonly type: "bytes";
|
|
378
|
+
readonly name: "endpointInfo";
|
|
379
|
+
}, {
|
|
380
|
+
readonly type: "uint16";
|
|
381
|
+
readonly name: "schemaVersion";
|
|
382
|
+
}];
|
|
383
|
+
}, {
|
|
384
|
+
readonly name: "LeaseReleased";
|
|
385
|
+
readonly type: "event";
|
|
386
|
+
readonly inputs: readonly [{
|
|
387
|
+
readonly type: "bytes32";
|
|
388
|
+
readonly name: "leaseId";
|
|
389
|
+
readonly indexed: true;
|
|
390
|
+
}, {
|
|
391
|
+
readonly type: "uint128";
|
|
392
|
+
readonly name: "refund";
|
|
393
|
+
}, {
|
|
394
|
+
readonly type: "uint128";
|
|
395
|
+
readonly name: "operatorTake";
|
|
396
|
+
}];
|
|
397
|
+
}, {
|
|
398
|
+
readonly name: "LeaseReaped";
|
|
399
|
+
readonly type: "event";
|
|
400
|
+
readonly inputs: readonly [{
|
|
401
|
+
readonly type: "bytes32";
|
|
402
|
+
readonly name: "leaseId";
|
|
403
|
+
readonly indexed: true;
|
|
404
|
+
}, {
|
|
405
|
+
readonly type: "uint128";
|
|
406
|
+
readonly name: "operatorTake";
|
|
407
|
+
}, {
|
|
408
|
+
readonly type: "address";
|
|
409
|
+
readonly name: "caller";
|
|
410
|
+
}];
|
|
411
|
+
}];
|
|
412
|
+
/** Vault lease states (mirrors the contract). */
|
|
413
|
+
declare const LEASE_STATE: {
|
|
414
|
+
readonly LIVE: 0;
|
|
415
|
+
readonly RELEASED: 1;
|
|
416
|
+
readonly REAPED: 2;
|
|
417
|
+
};
|
|
418
|
+
interface VaultLeaseView {
|
|
419
|
+
operator: `0x${string}`;
|
|
420
|
+
lessee: `0x${string}`;
|
|
421
|
+
escrowWei: bigint;
|
|
422
|
+
pricePerSecondWei: bigint;
|
|
423
|
+
/** Unix seconds — the chain clock is the parking meter's truth. */
|
|
424
|
+
expiry: bigint;
|
|
425
|
+
intentHash: `0x${string}`;
|
|
426
|
+
confidentiality: number;
|
|
427
|
+
state: number;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Exact refund projection (I3): pricePerSecond × max(expiry − now, 0).
|
|
431
|
+
* Exact by construction because escrow === price × paidSeconds in the vault.
|
|
432
|
+
*/
|
|
433
|
+
declare function projectRefundWei(lease: VaultLeaseView, nowSeconds: bigint): {
|
|
434
|
+
refundWei: bigint;
|
|
435
|
+
operatorTakeWei: bigint;
|
|
436
|
+
};
|
|
437
|
+
/** I2 from the client side: unpayable time can never be requested. */
|
|
438
|
+
declare function maxAffordableSeconds(escrowWei: bigint, pricePerSecondWei: bigint): bigint;
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/gpu-lease/resolver.d.ts
|
|
441
|
+
/** Job ids — MUST match the blueprint router (sequential, no gaps). */
|
|
442
|
+
declare const GPU_LEASE_JOBS: {
|
|
443
|
+
readonly LEASE: 0;
|
|
444
|
+
readonly RELEASE: 1;
|
|
445
|
+
readonly EXTEND: 2;
|
|
446
|
+
readonly REAP: 3;
|
|
447
|
+
};
|
|
448
|
+
interface GpuLeaseChain {
|
|
449
|
+
/** The buyer's address (the RFQ binds the requester — I5). */
|
|
450
|
+
readonly account: `0x${string}`;
|
|
451
|
+
/** Create the escrowed lease on the vault; returns the vault leaseId. */
|
|
452
|
+
createVaultLease(input: {
|
|
453
|
+
operator: `0x${string}`;
|
|
454
|
+
pricePerSecondWei: bigint;
|
|
455
|
+
durationSeconds: bigint;
|
|
456
|
+
intentHash: `0x${string}`;
|
|
457
|
+
confidentiality: number;
|
|
458
|
+
endpointInfo: string;
|
|
459
|
+
escrowWei: bigint;
|
|
460
|
+
}): Promise<`0x${string}`>;
|
|
461
|
+
/** Submit a job through tnt-core; resolves with the result payload. */
|
|
462
|
+
submitJob(jobId: number, encodedInput: `0x${string}`): Promise<`0x${string}`>;
|
|
463
|
+
/** Read a vault lease (chain clock truth for projections). */
|
|
464
|
+
readLease(leaseId: `0x${string}`): Promise<VaultLeaseView>;
|
|
465
|
+
/** The chain's current timestamp (unix seconds) — meter truth, not Date.now(). */
|
|
466
|
+
chainNow?(): Promise<bigint>;
|
|
467
|
+
/** Voluntary release on the vault; returns {refund, take} wei. */
|
|
468
|
+
releaseLease(leaseId: `0x${string}`): Promise<{
|
|
469
|
+
refundWei: bigint;
|
|
470
|
+
operatorTakeWei: bigint;
|
|
471
|
+
}>;
|
|
472
|
+
}
|
|
473
|
+
interface GpuLeaseOptions {
|
|
474
|
+
gpuClass: string;
|
|
475
|
+
durationSeconds: number;
|
|
476
|
+
confidentiality?: number;
|
|
477
|
+
region?: string;
|
|
478
|
+
/** Operators to request quotes from (multi-quote = the decentralized scheduler). */
|
|
479
|
+
operators: OperatorEndpoint[];
|
|
480
|
+
chain: GpuLeaseChain;
|
|
481
|
+
now?: () => number;
|
|
482
|
+
}
|
|
483
|
+
interface GpuLeaseOutcome {
|
|
484
|
+
lease: GpuLease;
|
|
485
|
+
/** Operators ranked cheapest-first. */
|
|
486
|
+
rankedOperators: string[];
|
|
487
|
+
}
|
|
488
|
+
/** Resolve a GPU lease end-to-end. Throws with the full picture on failure. */
|
|
489
|
+
declare function gpuLease(options: GpuLeaseOptions): Promise<GpuLeaseOutcome>;
|
|
490
|
+
/** Teardown: voluntary release with an exact-refund receipt (I3/I4). */
|
|
491
|
+
declare function releaseGpuLease(leaseId: `0x${string}`, chain: GpuLeaseChain): Promise<RefundReceipt>;
|
|
492
|
+
/**
|
|
493
|
+
* Refund projection for UI meters. Uses the chain clock when the injected
|
|
494
|
+
* chain provides `chainNow()`; otherwise requires an explicit timestamp.
|
|
495
|
+
* Never Date.now() — the drift lesson from the blueprint's own E2E.
|
|
496
|
+
*/
|
|
497
|
+
declare function projectGpuLeaseRefund(leaseId: `0x${string}`, chain: GpuLeaseChain, explicitNowSeconds?: bigint): Promise<{
|
|
498
|
+
refundWei: bigint;
|
|
499
|
+
operatorTakeWei: bigint;
|
|
500
|
+
nowSeconds: bigint;
|
|
501
|
+
}>;
|
|
502
|
+
//#endregion
|
|
503
|
+
export { Capabilities, ClassCapability, GPU_LEASE_JOBS, GPU_LEASE_REQUEST_ABI, GPU_LEASE_SCHEMA_VERSION, GPU_LEASE_VAULT_ABI, GpuLease, GpuLeaseChain, GpuLeaseOperatorClient, GpuLeaseOptions, GpuLeaseOutcome, GpuLeaseOutputDecoded, GpuLeaseRequestParams, INTENT_VERSION, JsonRequestBody, LEASE_STATE, LeaseStatus, OperatorEndpoint, OperatorQuote, QuoteFilterInput, QuoteParams, QuoteRejection, RefundReceipt, SessionChallenge, SessionCredential, ValidatedQuote, VaultLeaseView, canonicalQuotePayload, decodeGpuLeaseOutput, encodeGpuLeaseRequest, gpuLease, gpuLeaseIntentHash, maxAffordableSeconds, projectGpuLeaseRefund, projectRefundWei, releaseGpuLease, selectQuotes, validateQuote, validateQuoteIdentity, verifyOperatorQuote };
|