@tangle-network/sandbox 1.0.264 → 1.0.266
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 +17 -7
- package/dist/abi-pcDt2Adp.js +136 -0
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +5 -5
- package/dist/agent/preview.d.ts +1 -1
- package/dist/agent/preview.js +2 -2
- package/dist/{agent-run-outcome-DLLvOkbe.d.ts → agent-run-outcome-DThM9ULE.d.ts} +2 -2
- package/dist/{api-request-SBaqnuZB.js → api-request-gkPDymqn.js} +2 -2
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +2 -2
- package/dist/{browser-interactive-control-controller-Bg7mWDLX.d.ts → browser-interactive-control-controller-ClykJB9N.d.ts} +1 -1
- package/dist/{browser-interactive-control-controller-PiCGGheb.js → browser-interactive-control-controller-S_Uo-Zy7.js} +1 -1
- package/dist/{chunked-upload-D2S7tOJO.js → chunked-upload-ChZB-dYE.js} +1 -1
- package/dist/{chunked-upload-file-CfuaCSja.js → chunked-upload-file-BGaOS3iK.js} +1 -1
- package/dist/cli-auth-bundle-DXKH215p.js +2 -0
- package/dist/{cli-auth-bundle-C6DtK7GX-D8681c7j.js → cli-auth-bundle-DcxhAW23-C22MMIvx.js} +36 -36
- package/dist/{client-CkpH8MsM.js → client-BWD7-uaL.js} +40 -57
- package/dist/{client-DaZwQeOS.d.ts → client-BYGLoEiU.d.ts} +153 -198
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/collaboration/index.js +1 -1
- package/dist/{collaboration-Corlo5N0.js → collaboration-Bqk4jYQe.js} +2 -2
- package/dist/core.d.ts +6 -6
- package/dist/core.js +5 -5
- package/dist/{error-catalog-CWtp7Yg1.js → error-catalog-GS97N-Cm.js} +1 -1
- package/dist/{errors-C0S3TzhR.js → errors-D44qyFpy.js} +1 -1
- package/dist/{file-download-7lcgh1LR.js → file-download-BO-Hmn3x.js} +1 -1
- package/dist/gpu-lease/index.d.ts +192 -184
- package/dist/gpu-lease/index.js +390 -281
- package/dist/{index-dxhLhM8L.d.ts → index-DkB8WbjK.d.ts} +43 -99
- package/dist/index.d.ts +13 -13
- package/dist/index.js +178 -61
- package/dist/intelligence/index.d.ts +1 -1
- package/dist/intelligence/index.js +4 -4
- package/dist/interactive-control.d.ts +1 -1
- package/dist/interactive-control.js +1 -1
- package/dist/{interactive-controller-CRp4VQKD.d.ts → interactive-controller-DSYQTRwh.d.ts} +3 -3
- package/dist/{interactive-controller-CqJX-LcO.js → interactive-controller-llj6EdlZ.js} +4 -4
- package/dist/lib/prepared-evidence.js +1 -1
- package/dist/{lines-BTStaSM2.d.ts → lines-D7lE49lV.d.ts} +1 -1
- package/dist/{lines-NECw0OhS.js → lines-DwJ7AKx7.js} +1 -1
- package/dist/lines.d.ts +1 -1
- package/dist/lines.js +1 -1
- package/dist/{local-cli-auth-wyO74fdb.js → local-cli-auth-C2cETxK4.js} +1 -1
- package/dist/{mcp-local-CpQncJsf.js → mcp-local-DVzsBlqX.js} +3 -3
- package/dist/{preview-D6bMarHf.d.ts → preview-DsHoo8BC.d.ts} +3 -3
- package/dist/{public-templates-3diq9yKD.d.ts → public-templates-DRqOkshE.d.ts} +2 -2
- package/dist/public-templates.d.ts +1 -1
- package/dist/public-templates.js +1 -1
- package/dist/{raw-evidence-archive-B0oCpHY3.js → raw-evidence-archive-BJ1cA-sP.js} +3 -3
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.js +5 -5
- package/dist/{sandbox-BVN_aNT1.js → sandbox-C3PqmwfU.js} +136 -196
- package/dist/{secp256k1-ZiYFbGjz.js → secp256k1-DIwypP5B.js} +1 -1
- package/dist/{select-seat-Cu-9jRO-.js → select-seat-Dc7cQ8To.js} +3 -3
- package/dist/select-seat-command.d.ts +2 -2
- package/dist/select-seat-command.js +2 -2
- package/dist/session-gateway/index.js +1 -1
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +2 -1
- package/dist/{tangle-Bpv3pIjM.js → tangle-BP8F3ZN0.js} +58 -185
- package/dist/{terminal-stream-types-DLaXWiSA.d.ts → terminal-stream-types-Cdz3xrux.d.ts} +1 -1
- package/dist/{types-COnts0u7.d.ts → types-BikjtQi3.d.ts} +202 -224
- package/package.json +11 -11
- package/dist/cli-auth-bundle-D5ZBMpZ7.js +0 -2
- /package/dist/{cli-auth-bundle-eUl7Sa1x.d.ts → cli-auth-bundle-CQCt2mcZ.d.ts} +0 -0
- /package/dist/{direct-http2-zLxsvF44.js → direct-http2-CzeIT93P.js} +0 -0
- /package/dist/{index-ClusTWYM.d.ts → index-B6aMEMDR.d.ts} +0 -0
- /package/dist/{index-BTXyTVq4.d.ts → index-BsT3M4X-.d.ts} +0 -0
- /package/dist/{prepared-evidence-ibAysmX8.js → prepared-evidence-DIFfn4Ki.js} +0 -0
- /package/dist/{preview-operations-DWL78boI.js → preview-operations-BTHZR1w2.js} +0 -0
- /package/dist/{raw-evidence-export-C0ieFpi2.d.ts → raw-evidence-export-C-TDdAgC.d.ts} +0 -0
- /package/dist/{raw-evidence-export-C6Xdl3nC.js → raw-evidence-export-Dog7W5zP.js} +0 -0
- /package/dist/{utils-BT2q9nkO.js → utils-BvN0Mk3j.js} +0 -0
package/dist/core.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as ManagedProcessClient, r as WorkspaceImages, t as SandboxInstance } from "./sandbox-
|
|
2
|
-
import { C as SandboxError, D as TimeoutError, O as ValidationError, T as StateError, _ as NetworkError, b as ProfileFileMountPathError, c as AuthError, m as FileWriteConflictError, o as responseMetadata, r as parseErrorResponse, u as CapabilityError, v as NotFoundError, w as ServerError, x as QuotaError, y as PartialFailureError } from "./errors-
|
|
3
|
-
import { a as InstancesClient, d as backendRegistryInteractionKindSchema, f as backendRegistryResponseSchema, h as parseBackendRegistryResponseBody, i as InstanceRestartingError, l as backendRegistryCapabilitiesSchema, m as parseBackendRegistryResponse, p as isBackendRegistryInteractionKind, r as HostedInstance, t as Sandbox, u as backendRegistryEntrySchema } from "./client-
|
|
4
|
-
import { i as profileChannelReference, r as lineInstanceKey, t as LinesClient } from "./lines-
|
|
1
|
+
import { S as ManagedProcessClient, r as WorkspaceImages, t as SandboxInstance } from "./sandbox-C3PqmwfU.js";
|
|
2
|
+
import { C as SandboxError, D as TimeoutError, O as ValidationError, T as StateError, _ as NetworkError, b as ProfileFileMountPathError, c as AuthError, m as FileWriteConflictError, o as responseMetadata, r as parseErrorResponse, u as CapabilityError, v as NotFoundError, w as ServerError, x as QuotaError, y as PartialFailureError } from "./errors-D44qyFpy.js";
|
|
3
|
+
import { a as InstancesClient, d as backendRegistryInteractionKindSchema, f as backendRegistryResponseSchema, h as parseBackendRegistryResponseBody, i as InstanceRestartingError, l as backendRegistryCapabilitiesSchema, m as parseBackendRegistryResponse, p as isBackendRegistryInteractionKind, r as HostedInstance, t as Sandbox, u as backendRegistryEntrySchema } from "./client-BWD7-uaL.js";
|
|
4
|
+
import { i as profileChannelReference, r as lineInstanceKey, t as LinesClient } from "./lines-DwJ7AKx7.js";
|
|
5
5
|
import { PublicTemplatePublishError, PublicTemplatesClient } from "./public-templates.js";
|
|
6
6
|
import { a as parseLineApplicationResult, i as parseLineApplicationRequest, n as LINE_APPLICATION_REPLY_MAX_CHARS, o as sandboxFailureKind, r as LINE_APPLICATION_REQUEST_MAX_BYTES, t as ISOLATED_CREATION_ATTESTATION_VERSION } from "./core-CTkHtpap.js";
|
|
7
|
-
import { a as createSelectSeat, i as SeatSelectionError, o as gatewaySeatTransport } from "./select-seat-
|
|
7
|
+
import { a as createSelectSeat, i as SeatSelectionError, o as gatewaySeatTransport } from "./select-seat-Dc7cQ8To.js";
|
|
8
8
|
export { AuthError, CapabilityError, FileWriteConflictError, HostedInstance, ISOLATED_CREATION_ATTESTATION_VERSION, InstanceRestartingError, InstancesClient, LINE_APPLICATION_REPLY_MAX_CHARS, LINE_APPLICATION_REQUEST_MAX_BYTES, LinesClient, ManagedProcessClient, NetworkError, NotFoundError, PartialFailureError, ProfileFileMountPathError, PublicTemplatePublishError, PublicTemplatesClient, QuotaError, Sandbox, SandboxError, SandboxInstance, SeatSelectionError, ServerError, StateError, TimeoutError, ValidationError, WorkspaceImages, backendRegistryCapabilitiesSchema, backendRegistryEntrySchema, backendRegistryInteractionKindSchema, backendRegistryResponseSchema, createSelectSeat, gatewaySeatTransport, isBackendRegistryInteractionKind, lineInstanceKey, parseBackendRegistryResponse, parseBackendRegistryResponseBody, parseErrorResponse, parseLineApplicationRequest, parseLineApplicationResult, profileChannelReference, responseMetadata, sandboxFailureKind };
|
|
@@ -76,7 +76,7 @@ const ERROR_CATALOG = {
|
|
|
76
76
|
BRANCH_UFFD_UNAVAILABLE: "503 retry | The parent host cannot fork live memory now. | Retry, or branch from a snapshot.",
|
|
77
77
|
CAPACITY_EXHAUSTED: "503 retry | No host has room for this sandbox now. | Retry after the Retry-After interval.",
|
|
78
78
|
COMPLIANCE_CAPACITY_UNAVAILABLE: "503 retry | No verified compliance-scope host can take this sandbox now. | Retry after the Retry-After interval.",
|
|
79
|
-
FIRECRACKER_IMAGE_UNAVAILABLE: "503 final | No host carries the requested Firecracker image. | Choose an image
|
|
79
|
+
FIRECRACKER_IMAGE_UNAVAILABLE: "503 final | No host carries the requested Firecracker image. | Choose an image whose runtimes include firecracker in `environments list`, or set runtime: docker.",
|
|
80
80
|
PLACEMENT_WARMING: "503 retry | The cell's controller has just started and has not heard a host yet. | Retry after the Retry-After interval.",
|
|
81
81
|
HOST_UNAVAILABLE: "503 retry | The host did not answer; the sandbox and its files remain. | Retry after the Retry-After interval.",
|
|
82
82
|
HOST_PRESSURE: "503 retry | The host was too busy to create the sandbox and created nothing. | Retry after the Retry-After interval.",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as HOST_AGENT_RESTART_KINDS, r as catalogEntry, t as ERROR_CATALOG } from "./error-catalog-
|
|
1
|
+
import { n as HOST_AGENT_RESTART_KINDS, r as catalogEntry, t as ERROR_CATALOG } from "./error-catalog-GS97N-Cm.js";
|
|
2
2
|
import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-BZbs5rig.js";
|
|
3
3
|
//#region src/error-classes.ts
|
|
4
4
|
const STATUS_CODE = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as bytesToHex, t as sha256 } from "./sha2-BIoWepwn.js";
|
|
2
|
-
import { O as ValidationError } from "./errors-
|
|
2
|
+
import { O as ValidationError } from "./errors-D44qyFpy.js";
|
|
3
3
|
import { n as combineAbortSignals } from "./abort-signal-BsriwJ8L.js";
|
|
4
4
|
//#region src/lib/file-download.ts
|
|
5
5
|
function downloadBounds(options) {
|
|
@@ -1,49 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
1
|
+
import { Address, PublicClient } from "viem";
|
|
2
|
+
|
|
31
3
|
//#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
4
|
declare const GPU_LEASE_SCHEMA_VERSION: 1;
|
|
42
5
|
interface ClassCapability {
|
|
43
6
|
id: string;
|
|
44
7
|
tee: boolean;
|
|
45
8
|
unit: string;
|
|
46
|
-
/** Indicative policy price (wei/second) — the binding price is the quote. */
|
|
47
9
|
pricePerSecond: string;
|
|
48
10
|
idleCount: number;
|
|
49
11
|
}
|
|
@@ -57,39 +19,27 @@ interface Capabilities {
|
|
|
57
19
|
interface OperatorQuote {
|
|
58
20
|
schemaVersion: number;
|
|
59
21
|
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
22
|
operatorAddress: `0x${string}`;
|
|
64
|
-
/** EIP-191 personal_sign over the canonical quote payload (0x RSV). */
|
|
65
23
|
signature?: `0x${string}`;
|
|
66
|
-
/** wei/second per device, from the operator's signed policy at request time. */
|
|
67
24
|
pricePerSecond: string;
|
|
68
25
|
durationSeconds: number;
|
|
69
26
|
confidentiality: number;
|
|
70
|
-
/** Devices rented. The signed v2 payload binds this count. */
|
|
71
27
|
deviceCount: number;
|
|
72
|
-
/** wei — pricePerSecond × durationSeconds × deviceCount exactly. */
|
|
73
28
|
escrowTotal: string;
|
|
74
|
-
/** Utilization the price was struck at (bps of 10_000) — the surge "why". */
|
|
75
29
|
utilizationBps: number;
|
|
76
|
-
/** keccak256(canonical intent) — binds the RFQ and the vault lease (I5). */
|
|
77
30
|
intentHash: `0x${string}`;
|
|
78
|
-
/** Unix seconds after which the quote is stale. */
|
|
79
31
|
validUntil: number;
|
|
80
32
|
}
|
|
81
33
|
interface LeaseStatus {
|
|
82
34
|
schemaVersion: number;
|
|
83
35
|
leaseId: `0x${string}`;
|
|
84
|
-
|
|
36
|
+
deviceIds: string[];
|
|
85
37
|
lessee: string;
|
|
86
|
-
/** Unix seconds — the chain-of-truth session end (parking meter). */
|
|
87
38
|
expiresAt: number;
|
|
88
39
|
endpoint: string;
|
|
89
40
|
}
|
|
90
41
|
interface SessionChallenge {
|
|
91
42
|
nonce: `0x${string}`;
|
|
92
|
-
/** The exact string the lessee must EIP-191 personal_sign. */
|
|
93
43
|
message: string;
|
|
94
44
|
expiresAt: number;
|
|
95
45
|
}
|
|
@@ -99,7 +49,6 @@ interface SessionCredential {
|
|
|
99
49
|
scopes: string[];
|
|
100
50
|
expiresAt: number;
|
|
101
51
|
}
|
|
102
|
-
/** A validated, ready-to-escrow quote. */
|
|
103
52
|
interface ValidatedQuote {
|
|
104
53
|
quote: OperatorQuote;
|
|
105
54
|
pricePerSecondWei: bigint;
|
|
@@ -107,7 +56,6 @@ interface ValidatedQuote {
|
|
|
107
56
|
}
|
|
108
57
|
interface RefundReceipt {
|
|
109
58
|
leaseId: `0x${string}`;
|
|
110
|
-
/** Exact wei refunded: pricePerSecond × remainingSeconds at settle time. */
|
|
111
59
|
refundWei: bigint;
|
|
112
60
|
operatorTakeWei: bigint;
|
|
113
61
|
}
|
|
@@ -118,15 +66,14 @@ interface QuoteParams {
|
|
|
118
66
|
durationSeconds: number;
|
|
119
67
|
confidentiality?: number;
|
|
120
68
|
region?: string;
|
|
69
|
+
deviceCount?: number;
|
|
70
|
+
lessee?: `0x${string}`;
|
|
121
71
|
}
|
|
122
72
|
interface OperatorEndpoint {
|
|
123
|
-
/** Operator base URL, e.g. https://gpu.example.com */
|
|
124
73
|
baseUrl: string;
|
|
125
|
-
/** The operator's EVM address (escrow + job binding). */
|
|
126
74
|
address: `0x${string}`;
|
|
127
75
|
fetch?: typeof fetch;
|
|
128
76
|
}
|
|
129
|
-
/** JSON request body — named at the I/O boundary (anti-slop: no `unknown`). */
|
|
130
77
|
type JsonRequestBody = Record<string, unknown>;
|
|
131
78
|
declare class GpuLeaseOperatorClient {
|
|
132
79
|
private readonly endpoint;
|
|
@@ -136,114 +83,16 @@ declare class GpuLeaseOperatorClient {
|
|
|
136
83
|
leaseStatus(leaseId: `0x${string}`): Promise<LeaseStatus>;
|
|
137
84
|
sessionChallenge(leaseId: `0x${string}`, lessee: string): Promise<SessionChallenge>;
|
|
138
85
|
sessionVerify(nonce: `0x${string}`, signature: `0x${string}`): Promise<SessionCredential>;
|
|
86
|
+
access(leaseId: `0x${string}`, token: string): Promise<LeaseStatus>;
|
|
139
87
|
}
|
|
140
88
|
//#endregion
|
|
141
89
|
//#region src/gpu-lease/output.d.ts
|
|
142
|
-
|
|
90
|
+
type GpuLeaseOutputDecoded = ReturnType<typeof decodeGpuLeaseOutput>;
|
|
91
|
+
declare function decodeGpuLeaseOutput(encoded: `0x${string}`): {
|
|
143
92
|
leaseId: `0x${string}`;
|
|
144
93
|
endpoint: string;
|
|
145
94
|
schemaVersion: number;
|
|
146
|
-
}
|
|
147
|
-
/** Decode + fail closed on unknown schemaVersion (blueprint SPEC §3). */
|
|
148
|
-
declare function decodeGpuLeaseOutput(encoded: `0x${string}`): GpuLeaseOutputDecoded;
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region src/gpu-lease/quotes.d.ts
|
|
151
|
-
/** The exact string the operator signs — mirrors the blueprint's
|
|
152
|
-
* `canonical_quote_payload` (v2) byte-for-byte. Every priced field is bound,
|
|
153
|
-
* the device count included. */
|
|
154
|
-
declare function canonicalQuotePayload(quote: {
|
|
155
|
-
gpuClass: string;
|
|
156
|
-
pricePerSecond: string;
|
|
157
|
-
durationSeconds: number;
|
|
158
|
-
confidentiality: number;
|
|
159
|
-
deviceCount: number;
|
|
160
|
-
escrowTotal: string;
|
|
161
|
-
intentHash: string;
|
|
162
|
-
validUntil: number;
|
|
163
|
-
}): string;
|
|
164
|
-
/** Offline EIP-191 recovery over the canonical payload. */
|
|
165
|
-
declare function verifyOperatorQuote(quote: OperatorQuote): Promise<`0x${string}`>;
|
|
166
|
-
type QuoteRejection = {
|
|
167
|
-
kind: "stale";
|
|
168
|
-
validUntil: number;
|
|
169
|
-
now: number;
|
|
170
|
-
} | {
|
|
171
|
-
kind: "class-mismatch";
|
|
172
|
-
requested: string;
|
|
173
|
-
quoted: string;
|
|
174
|
-
} | {
|
|
175
|
-
kind: "duration-mismatch";
|
|
176
|
-
requested: number;
|
|
177
|
-
quoted: number;
|
|
178
|
-
} | {
|
|
179
|
-
kind: "count-mismatch";
|
|
180
|
-
requested: number;
|
|
181
|
-
quoted: number;
|
|
182
|
-
} | {
|
|
183
|
-
kind: "escrow-inconsistent";
|
|
184
|
-
expected: bigint;
|
|
185
|
-
actual: bigint;
|
|
186
|
-
} | {
|
|
187
|
-
kind: "confidentiality-mismatch";
|
|
188
|
-
requested: number;
|
|
189
|
-
quoted: number;
|
|
190
|
-
} | {
|
|
191
|
-
kind: "signature-mismatch";
|
|
192
|
-
claimed: string;
|
|
193
|
-
recovered: string;
|
|
194
|
-
} | {
|
|
195
|
-
kind: "operator-not-pinned";
|
|
196
|
-
pinned: string;
|
|
197
|
-
recovered: string;
|
|
198
|
-
} | {
|
|
199
|
-
kind: "unsigned";
|
|
200
|
-
operator: string;
|
|
201
95
|
};
|
|
202
|
-
interface QuoteFilterInput {
|
|
203
|
-
requestedClass: string;
|
|
204
|
-
requestedDurationSeconds: number;
|
|
205
|
-
requestedConfidentiality: number;
|
|
206
|
-
requestedDeviceCount: number;
|
|
207
|
-
now?: () => number;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Validate one quote. Fail-closed on every field the RFQ binds:
|
|
211
|
-
* class, duration, device count, the escrow derived from them,
|
|
212
|
-
* confidentiality, and expiry.
|
|
213
|
-
*/
|
|
214
|
-
declare function validateOperatorQuote(quote: OperatorQuote, input: QuoteFilterInput): ValidatedQuote | QuoteRejection;
|
|
215
|
-
/**
|
|
216
|
-
* Collect validated quotes from N operators and rank cheapest-first.
|
|
217
|
-
* Operators that fail validation (or whose fetch rejects) are reported,
|
|
218
|
-
* never silently dropped — the buyer sees why an operator lost.
|
|
219
|
-
*/
|
|
220
|
-
declare function selectQuotes(quotes: {
|
|
221
|
-
operator: string;
|
|
222
|
-
quote: OperatorQuote;
|
|
223
|
-
}[], input: QuoteFilterInput): {
|
|
224
|
-
ranked: {
|
|
225
|
-
operator: string;
|
|
226
|
-
validated: ValidatedQuote;
|
|
227
|
-
}[];
|
|
228
|
-
rejected: {
|
|
229
|
-
operator: string;
|
|
230
|
-
reason: QuoteRejection;
|
|
231
|
-
}[];
|
|
232
|
-
};
|
|
233
|
-
/**
|
|
234
|
-
* Enforce the signed RFQ envelope when present:
|
|
235
|
-
* - signature present => it MUST recover to the claimed operator address;
|
|
236
|
-
* invalid signature => reject (config-trust is dead on this path).
|
|
237
|
-
* - no signature => the endpoint-config address is used (interim fallback);
|
|
238
|
-
* strict mode rejects unsigned quotes outright.
|
|
239
|
-
* - `pinnedOperator` set => the quote must be signed AND recover to that
|
|
240
|
-
* address. A valid signature from any other key is rejected, so an
|
|
241
|
-
* endpoint cannot substitute its own signer for the one the caller trusts.
|
|
242
|
-
*/
|
|
243
|
-
declare function validateQuoteIdentity(quote: OperatorQuote, opts?: {
|
|
244
|
-
strict?: boolean;
|
|
245
|
-
pinnedOperator?: `0x${string}`;
|
|
246
|
-
}): Promise<ValidatedQuote | QuoteRejection>;
|
|
247
96
|
//#endregion
|
|
248
97
|
//#region src/gpu-lease/vault.d.ts
|
|
249
98
|
declare const GPU_LEASE_VAULT_ABI: readonly [{
|
|
@@ -259,6 +108,9 @@ declare const GPU_LEASE_VAULT_ABI: readonly [{
|
|
|
259
108
|
}, {
|
|
260
109
|
readonly type: "uint64";
|
|
261
110
|
readonly name: "durationSeconds";
|
|
111
|
+
}, {
|
|
112
|
+
readonly type: "uint16";
|
|
113
|
+
readonly name: "deviceCount";
|
|
262
114
|
}, {
|
|
263
115
|
readonly type: "bytes32";
|
|
264
116
|
readonly name: "intentHash";
|
|
@@ -356,6 +208,9 @@ declare const GPU_LEASE_VAULT_ABI: readonly [{
|
|
|
356
208
|
}, {
|
|
357
209
|
readonly type: "uint8";
|
|
358
210
|
readonly name: "state";
|
|
211
|
+
}, {
|
|
212
|
+
readonly type: "uint16";
|
|
213
|
+
readonly name: "deviceCount";
|
|
359
214
|
}];
|
|
360
215
|
}, {
|
|
361
216
|
readonly name: "LeaseCreated";
|
|
@@ -378,6 +233,9 @@ declare const GPU_LEASE_VAULT_ABI: readonly [{
|
|
|
378
233
|
}, {
|
|
379
234
|
readonly type: "uint128";
|
|
380
235
|
readonly name: "pricePerSecond";
|
|
236
|
+
}, {
|
|
237
|
+
readonly type: "uint16";
|
|
238
|
+
readonly name: "deviceCount";
|
|
381
239
|
}, {
|
|
382
240
|
readonly type: "uint64";
|
|
383
241
|
readonly name: "expiry";
|
|
@@ -428,35 +286,34 @@ interface VaultLeaseView {
|
|
|
428
286
|
lessee: `0x${string}`;
|
|
429
287
|
escrowWei: bigint;
|
|
430
288
|
pricePerSecondWei: bigint;
|
|
431
|
-
/** Unix seconds — the chain clock is the parking meter's truth. */
|
|
432
289
|
expiry: bigint;
|
|
433
290
|
intentHash: `0x${string}`;
|
|
434
291
|
confidentiality: number;
|
|
435
292
|
state: number;
|
|
293
|
+
deviceCount: number;
|
|
436
294
|
}
|
|
437
|
-
/**
|
|
438
|
-
* Exact refund projection (I3): pricePerSecond × max(expiry − now, 0).
|
|
439
|
-
* Exact by construction because escrow === price × paidSeconds in the vault.
|
|
440
|
-
*/
|
|
441
295
|
declare function projectRefundWei(lease: VaultLeaseView, nowSeconds: bigint): {
|
|
442
296
|
refundWei: bigint;
|
|
443
297
|
operatorTakeWei: bigint;
|
|
444
298
|
};
|
|
445
|
-
/** I2 from the client side: unpayable time can never be requested. */
|
|
446
|
-
declare function maxAffordableSeconds(escrowWei: bigint, pricePerSecondWei: bigint): bigint;
|
|
447
299
|
//#endregion
|
|
448
300
|
//#region src/gpu-lease/resolver.d.ts
|
|
449
|
-
/** Job ids — MUST match the blueprint router (sequential, no gaps). */
|
|
450
301
|
declare const GPU_LEASE_JOBS: {
|
|
451
302
|
readonly LEASE: 0;
|
|
452
303
|
readonly RELEASE: 1;
|
|
453
304
|
readonly EXTEND: 2;
|
|
454
305
|
readonly REAP: 3;
|
|
455
306
|
};
|
|
307
|
+
interface GpuLeaseSessionDomain {
|
|
308
|
+
chainId: number;
|
|
309
|
+
vaultAddress: `0x${string}`;
|
|
310
|
+
blueprintAddress: `0x${string}`;
|
|
311
|
+
}
|
|
456
312
|
interface GpuLeaseChain {
|
|
457
|
-
/**
|
|
313
|
+
/** Client-owned RPC/configuration context; never supplied by the operator challenge. */
|
|
314
|
+
sessionDomain(): Promise<GpuLeaseSessionDomain>;
|
|
458
315
|
readonly account: `0x${string}`;
|
|
459
|
-
|
|
316
|
+
signMessage(message: string): Promise<`0x${string}`>;
|
|
460
317
|
createVaultLease(input: {
|
|
461
318
|
operator: `0x${string}`;
|
|
462
319
|
pricePerSecondWei: bigint;
|
|
@@ -465,14 +322,11 @@ interface GpuLeaseChain {
|
|
|
465
322
|
confidentiality: number;
|
|
466
323
|
endpointInfo: string;
|
|
467
324
|
escrowWei: bigint;
|
|
325
|
+
deviceCount: number;
|
|
468
326
|
}): Promise<`0x${string}`>;
|
|
469
|
-
/** Submit a job through tnt-core; resolves with the result payload. */
|
|
470
327
|
submitJob(jobId: number, encodedInput: `0x${string}`): Promise<`0x${string}`>;
|
|
471
|
-
/** Read a vault lease (chain clock truth for projections). */
|
|
472
328
|
readLease(leaseId: `0x${string}`): Promise<VaultLeaseView>;
|
|
473
|
-
/** The chain's current timestamp (unix seconds) — meter truth, not Date.now(). */
|
|
474
329
|
chainNow?(): Promise<bigint>;
|
|
475
|
-
/** Voluntary release on the vault; returns {refund, take} wei. */
|
|
476
330
|
releaseLease(leaseId: `0x${string}`): Promise<{
|
|
477
331
|
refundWei: bigint;
|
|
478
332
|
operatorTakeWei: bigint;
|
|
@@ -483,32 +337,186 @@ interface GpuLeaseOptions {
|
|
|
483
337
|
durationSeconds: number;
|
|
484
338
|
confidentiality?: number;
|
|
485
339
|
region?: string;
|
|
486
|
-
|
|
340
|
+
deviceCount?: number;
|
|
341
|
+
sandboxId?: `0x${string}`;
|
|
342
|
+
sandboxTeeType?: number;
|
|
487
343
|
operators: OperatorEndpoint[];
|
|
488
344
|
chain: GpuLeaseChain;
|
|
489
345
|
now?: () => number;
|
|
346
|
+
/** Called once the escrow exists, before any job: persist the id to settle it after a crash. */
|
|
347
|
+
onEscrowed?: (leaseId: `0x${string}`) => void | Promise<void>;
|
|
348
|
+
}
|
|
349
|
+
/** A failure after escrow: `leaseId` settles it (`chain.releaseLease`) instead of escrowing again. */
|
|
350
|
+
declare class GpuLeaseEscrowError extends Error {
|
|
351
|
+
readonly leaseId: `0x${string}`;
|
|
352
|
+
readonly cleanupError?: unknown | undefined;
|
|
353
|
+
constructor(leaseId: `0x${string}`, cause: unknown, cleanupError?: unknown | undefined);
|
|
490
354
|
}
|
|
491
355
|
interface GpuLeaseOutcome {
|
|
492
|
-
/** Resolved lease with a versioned public endpoint descriptor (v1 = local-attach). */
|
|
493
356
|
lease: ReturnType<typeof decodeGpuLeaseOutput> & {
|
|
494
357
|
quote: ValidatedQuote;
|
|
358
|
+
credential: SessionCredential;
|
|
495
359
|
};
|
|
496
|
-
/** Operators ranked cheapest-first. */
|
|
497
360
|
rankedOperators: string[];
|
|
498
361
|
}
|
|
499
|
-
/** Resolve a GPU lease end-to-end. Throws with the full picture on failure. */
|
|
500
362
|
declare function gpuLease(options: GpuLeaseOptions): Promise<GpuLeaseOutcome>;
|
|
501
|
-
/**
|
|
363
|
+
/** Sign only the SDK owner message bound to client-owned chain, contracts, operator and lease. */
|
|
364
|
+
declare function openGpuLeaseSession(endpoint: OperatorEndpoint, leaseId: `0x${string}`, chain: Pick<GpuLeaseChain, "account" | "signMessage" | "sessionDomain">): Promise<{
|
|
365
|
+
credential: SessionCredential;
|
|
366
|
+
access: LeaseStatus;
|
|
367
|
+
}>;
|
|
502
368
|
declare function releaseGpuLease(leaseId: `0x${string}`, chain: GpuLeaseChain): Promise<RefundReceipt>;
|
|
503
|
-
/**
|
|
504
|
-
* Refund projection for UI meters. Uses the chain clock when the injected
|
|
505
|
-
* chain provides `chainNow()`; otherwise requires an explicit timestamp.
|
|
506
|
-
* Never Date.now() — the drift lesson from the blueprint's own E2E.
|
|
507
|
-
*/
|
|
508
369
|
declare function projectGpuLeaseRefund(leaseId: `0x${string}`, chain: GpuLeaseChain, explicitNowSeconds?: bigint): Promise<{
|
|
509
370
|
refundWei: bigint;
|
|
510
371
|
operatorTakeWei: bigint;
|
|
511
372
|
nowSeconds: bigint;
|
|
512
373
|
}>;
|
|
513
374
|
//#endregion
|
|
514
|
-
|
|
375
|
+
//#region src/gpu-lease/chain-viem.d.ts
|
|
376
|
+
interface ViemGpuLeaseChainConfig {
|
|
377
|
+
rpcUrl: string;
|
|
378
|
+
privateKey: `0x${string}`;
|
|
379
|
+
vaultAddress: Address;
|
|
380
|
+
blueprintAddress: Address;
|
|
381
|
+
tangleAddress: Address;
|
|
382
|
+
serviceId: bigint;
|
|
383
|
+
pollIntervalMs?: number;
|
|
384
|
+
resultTimeoutMs?: number;
|
|
385
|
+
}
|
|
386
|
+
interface ViemGpuLeaseChain extends GpuLeaseChain {
|
|
387
|
+
readonly publicClient: PublicClient;
|
|
388
|
+
}
|
|
389
|
+
declare function createViemGpuLeaseChain(config: ViemGpuLeaseChainConfig): ViemGpuLeaseChain;
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/gpu-lease/intent.d.ts
|
|
392
|
+
declare const INTENT_VERSION = 2;
|
|
393
|
+
declare function gpuLeaseIntentHash(input: {
|
|
394
|
+
intentVersion: number;
|
|
395
|
+
gpuClass: string;
|
|
396
|
+
durationSeconds: bigint | number;
|
|
397
|
+
confidentiality: number;
|
|
398
|
+
region: string;
|
|
399
|
+
deviceCount: number;
|
|
400
|
+
}): `0x${string}`;
|
|
401
|
+
declare const GPU_LEASE_REQUEST_ABI: readonly [{
|
|
402
|
+
readonly type: "tuple";
|
|
403
|
+
readonly components: readonly [{
|
|
404
|
+
readonly type: "uint8";
|
|
405
|
+
readonly name: "intentVersion";
|
|
406
|
+
}, {
|
|
407
|
+
readonly type: "bytes32";
|
|
408
|
+
readonly name: "intentHash";
|
|
409
|
+
}, {
|
|
410
|
+
readonly type: "uint128";
|
|
411
|
+
readonly name: "pricePerSecond";
|
|
412
|
+
}, {
|
|
413
|
+
readonly type: "uint64";
|
|
414
|
+
readonly name: "durationSeconds";
|
|
415
|
+
}, {
|
|
416
|
+
readonly type: "uint8";
|
|
417
|
+
readonly name: "confidentiality";
|
|
418
|
+
}, {
|
|
419
|
+
readonly type: "string";
|
|
420
|
+
readonly name: "gpuClass";
|
|
421
|
+
}, {
|
|
422
|
+
readonly type: "string";
|
|
423
|
+
readonly name: "region";
|
|
424
|
+
}, {
|
|
425
|
+
readonly type: "address";
|
|
426
|
+
readonly name: "lessee";
|
|
427
|
+
}, {
|
|
428
|
+
readonly type: "bytes32";
|
|
429
|
+
readonly name: "leaseId";
|
|
430
|
+
}, {
|
|
431
|
+
readonly type: "bytes32";
|
|
432
|
+
readonly name: "sandboxId";
|
|
433
|
+
}, {
|
|
434
|
+
readonly type: "uint8";
|
|
435
|
+
readonly name: "sandboxTeeType";
|
|
436
|
+
}, {
|
|
437
|
+
readonly type: "uint16";
|
|
438
|
+
readonly name: "deviceCount";
|
|
439
|
+
}];
|
|
440
|
+
}];
|
|
441
|
+
interface GpuLeaseRequestParams {
|
|
442
|
+
intentVersion: number;
|
|
443
|
+
intentHash: `0x${string}`;
|
|
444
|
+
pricePerSecondWei: bigint;
|
|
445
|
+
durationSeconds: bigint;
|
|
446
|
+
confidentiality: number;
|
|
447
|
+
gpuClass: string;
|
|
448
|
+
region: string;
|
|
449
|
+
lessee: `0x${string}`;
|
|
450
|
+
leaseId: `0x${string}`;
|
|
451
|
+
sandboxId: `0x${string}`;
|
|
452
|
+
sandboxTeeType: number;
|
|
453
|
+
deviceCount: number;
|
|
454
|
+
}
|
|
455
|
+
declare function encodeGpuLeaseRequest(params: GpuLeaseRequestParams): `0x${string}`;
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/gpu-lease/quotes.d.ts
|
|
458
|
+
/** Mirrors the operator API's signed quote payload. */
|
|
459
|
+
declare function canonicalQuotePayload(quote: Omit<OperatorQuote, "schemaVersion" | "operatorAddress" | "signature" | "utilizationBps">): string;
|
|
460
|
+
declare function verifyOperatorQuote(quote: OperatorQuote): Promise<`0x${string}`>;
|
|
461
|
+
type QuoteRejection = {
|
|
462
|
+
kind: "stale";
|
|
463
|
+
validUntil: number;
|
|
464
|
+
now: number;
|
|
465
|
+
} | {
|
|
466
|
+
kind: "class-mismatch";
|
|
467
|
+
requested: string;
|
|
468
|
+
quoted: string;
|
|
469
|
+
} | {
|
|
470
|
+
kind: "duration-mismatch";
|
|
471
|
+
requested: number;
|
|
472
|
+
quoted: number;
|
|
473
|
+
} | {
|
|
474
|
+
kind: "count-mismatch";
|
|
475
|
+
requested: number;
|
|
476
|
+
quoted: number;
|
|
477
|
+
} | {
|
|
478
|
+
kind: "escrow-inconsistent";
|
|
479
|
+
expected: bigint;
|
|
480
|
+
actual: bigint;
|
|
481
|
+
} | {
|
|
482
|
+
kind: "confidentiality-mismatch";
|
|
483
|
+
requested: number;
|
|
484
|
+
quoted: number;
|
|
485
|
+
} | {
|
|
486
|
+
kind: "signature-mismatch";
|
|
487
|
+
claimed: string;
|
|
488
|
+
recovered: string;
|
|
489
|
+
} | {
|
|
490
|
+
kind: "operator-not-pinned";
|
|
491
|
+
pinned: string;
|
|
492
|
+
recovered: string;
|
|
493
|
+
} | {
|
|
494
|
+
kind: "unsigned";
|
|
495
|
+
operator: string;
|
|
496
|
+
};
|
|
497
|
+
interface QuoteFilterInput {
|
|
498
|
+
requestedClass: string;
|
|
499
|
+
requestedDurationSeconds: number;
|
|
500
|
+
requestedConfidentiality: number;
|
|
501
|
+
requestedDeviceCount: number;
|
|
502
|
+
now?: () => number;
|
|
503
|
+
}
|
|
504
|
+
declare function validateOperatorQuote(quote: OperatorQuote, input: QuoteFilterInput): ValidatedQuote | QuoteRejection;
|
|
505
|
+
declare function selectQuotes(quotes: {
|
|
506
|
+
operator: string;
|
|
507
|
+
quote: OperatorQuote;
|
|
508
|
+
}[], input: QuoteFilterInput): {
|
|
509
|
+
ranked: {
|
|
510
|
+
operator: string;
|
|
511
|
+
validated: ValidatedQuote;
|
|
512
|
+
}[];
|
|
513
|
+
rejected: {
|
|
514
|
+
operator: string;
|
|
515
|
+
reason: QuoteRejection;
|
|
516
|
+
}[];
|
|
517
|
+
};
|
|
518
|
+
declare function validateQuoteIdentity(quote: OperatorQuote, opts?: {
|
|
519
|
+
pinnedOperator?: `0x${string}`;
|
|
520
|
+
}): Promise<ValidatedQuote | QuoteRejection>;
|
|
521
|
+
//#endregion
|
|
522
|
+
export { Capabilities, ClassCapability, GPU_LEASE_JOBS, GPU_LEASE_REQUEST_ABI, GPU_LEASE_SCHEMA_VERSION, GPU_LEASE_VAULT_ABI, GpuLeaseChain, GpuLeaseEscrowError, GpuLeaseOperatorClient, GpuLeaseOptions, GpuLeaseOutcome, GpuLeaseOutputDecoded, GpuLeaseRequestParams, GpuLeaseSessionDomain, INTENT_VERSION, JsonRequestBody, LeaseStatus, OperatorEndpoint, OperatorQuote, QuoteFilterInput, QuoteParams, QuoteRejection, RefundReceipt, SessionChallenge, SessionCredential, ValidatedQuote, VaultLeaseView, canonicalQuotePayload, createViemGpuLeaseChain, decodeGpuLeaseOutput, encodeGpuLeaseRequest, gpuLease, gpuLeaseIntentHash, openGpuLeaseSession, projectGpuLeaseRefund, projectRefundWei, releaseGpuLease, selectQuotes, validateOperatorQuote, validateQuoteIdentity, verifyOperatorQuote };
|