@opendatalabs/vana-sdk 3.22.0-pr.208.e9c19e9 → 3.22.0-pr.209.13d545d
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/dist/crypto/envelope/job.cjs +26 -87
- package/dist/crypto/envelope/job.cjs.map +1 -1
- package/dist/crypto/envelope/job.d.ts +9 -95
- package/dist/crypto/envelope/job.js +27 -91
- package/dist/crypto/envelope/job.js.map +1 -1
- package/dist/direct/escrow-payment.cjs.map +1 -1
- package/dist/direct/escrow-payment.d.ts +2 -2
- package/dist/direct/escrow-payment.js.map +1 -1
- package/dist/index.browser.d.ts +2 -2
- package/dist/index.browser.js +39 -265
- package/dist/index.browser.js.map +3 -3
- package/dist/index.node.cjs +36 -267
- package/dist/index.node.cjs.map +3 -3
- package/dist/index.node.d.ts +2 -2
- package/dist/index.node.js +49 -275
- package/dist/index.node.js.map +3 -3
- package/dist/protocol/eip712.cjs +2 -28
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +0 -70
- package/dist/protocol/eip712.js +1 -24
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/escrow.cjs +2 -154
- package/dist/protocol/escrow.cjs.map +1 -1
- package/dist/protocol/escrow.d.ts +2 -145
- package/dist/protocol/escrow.js +1 -152
- package/dist/protocol/escrow.js.map +1 -1
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +38 -8
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/jobs.cjs.map +1 -1
- package/dist/protocol/jobs.d.ts +1 -23
- package/dist/protocol/jobs.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/protocol/jobs.ts"],"sourcesContent":["/**\n * Job queue protocol types for encrypted Personal Server execution.\n *\n * Builder -> GW -> Agent -> Sandbox\n * Builder -> GW: submit an enclave-encrypted request.\n * GW -> Agent: claim work with a fenced lease and sealed owner identity.\n * Agent -> Sandbox: decrypt, wake the owner sandbox, and execute privately.\n * Sandbox -> Agent: encrypt the result to the builder's public key.\n * Agent -> GW: complete with ciphertext hash and size, or fail the job.\n * GW -> Builder: return inline or polled status and opaque ciphertext.\n * Builder: decrypt and verify the result's job, scope, and version bindings.\n *
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/jobs.ts"],"sourcesContent":["/**\n * Job queue protocol types for encrypted Personal Server execution.\n *\n * Builder -> GW -> Agent -> Sandbox\n * Builder -> GW: submit an enclave-encrypted request.\n * GW -> Agent: claim work with a fenced lease and sealed owner identity.\n * Agent -> Sandbox: decrypt, wake the owner sandbox, and execute privately.\n * Sandbox -> Agent: encrypt the result to the builder's public key.\n * Agent -> GW: complete with ciphertext hash and size, or fail the job.\n * GW -> Builder: return inline or polled status and opaque ciphertext.\n * Builder: decrypt and verify the result's job, scope, and version bindings.\n * See HANDOFF-contract.md section 1 for the complete flow.\n *\n * @category Protocol\n */\n\nimport type { Address, Hex } from \"viem\";\nimport type { SealedEnvelope } from \"./identity\";\n\nexport const JOB_PROTOCOL_VERSION = 1;\nexport const JOB_OPERATIONS = [\"raw_read\", \"inference\"] as const;\nexport type JobOperation = (typeof JOB_OPERATIONS)[number];\nexport const JOB_STATES = [\n \"queued\",\n \"claimed\",\n \"running\",\n \"completed\",\n \"failed\",\n \"expired\",\n \"cancelled\",\n] as const;\nexport type JobState = (typeof JOB_STATES)[number];\nexport type PaymentState = \"none\" | \"reserved\" | \"settled\";\nexport const DEFAULT_LEASE_SECONDS = 30;\nexport const MAX_LEASE_SECONDS = 300;\nexport const MAX_ATTEMPTS = 3;\nexport const MAX_WAIT_SECONDS = 25;\nexport const CLAIM_POLL_FLOOR_MS = 1000;\nexport const MAX_INLINE_RESULT_BYTES = 1_048_576;\nexport const DEFAULT_JOB_DEADLINE_SECONDS = 600;\nexport const MAX_JOB_DEADLINE_SECONDS = 3600;\n\n/** Inner plaintext of the request box (ECIES to the enclave publicKey). */\nexport interface JobRequest {\n v: 1;\n jobId: string;\n owner: Address;\n builder: Address;\n builderPublicKey: Hex;\n grantId: Hex;\n scope: string;\n operation: JobOperation;\n pinnedVersion: string | null;\n deadline: string; /* ISO */\n}\nexport interface JobRequestEnvelope {\n request: JobRequest;\n auth: string; /* \"Web3Signed <b64>.<sig>\" by builder over uri /v1/jobs/execute, bodyHash = sha256(JSON(request)) */\n}\n/** Outer body of POST /v1/jobs (signed Web3Signed by the builder). */\nexport interface JobSubmission {\n owner: Address;\n grantId: Hex;\n scope: string;\n operation: JobOperation;\n idempotencyKey: string;\n jobId: string;\n /* client uuid, echoed in JobRequest */ deadline?: string;\n requestCiphertext: string; /* base64 ECIES */\n}\nexport interface JobStatus {\n jobId: string;\n state: JobState;\n operation: JobOperation;\n owner: Address;\n grantId: Hex;\n scope: string;\n pinnedVersion: string | null;\n attempt: number;\n price: string;\n payer: \"builder\";\n paymentState: PaymentState;\n createdAt: string;\n claimedAt: string | null;\n completedAt: string | null;\n failureReason: string | null;\n resultCiphertext?: string;\n resultHandle?: string;\n resultHash?: Hex;\n resultSize?: number;\n resultExpiresAt?: string;\n}\nexport interface ClaimRequest {\n leaseSeconds?: number;\n capacity?: number;\n}\nexport interface ClaimResponse {\n job: {\n jobId: string;\n owner: Address;\n builder: Address;\n grantId: Hex;\n scope: string;\n operation: JobOperation;\n pinnedVersion: string | null;\n requestCiphertext: string;\n attempt: number;\n deadlineAt: string | null;\n claimExpiresAt: string;\n fencingToken: number; /* = attempt; every node write echoes it */\n };\n identity: {\n userPsId: Hex;\n epoch: number;\n enclaveAddress: Address;\n enclavePublicKey: Hex;\n sealedEnvelope: SealedEnvelope;\n };\n}\nexport interface HeartbeatRequest {\n leaseSeconds?: number;\n fencingToken: number;\n}\nexport interface CompleteRequest {\n fencingToken: number;\n resultHash: Hex;\n resultSize: number;\n resultCiphertext?: string;\n /* inline <= MAX_INLINE_RESULT_BYTES */ resultHandle?: string; /* v1.1, R2 */\n}\nexport interface FailRequest {\n fencingToken: number;\n reason: string; /* <= 1024, fail.ts:16 */\n}\nexport interface FencedResponse {\n success: true;\n jobId: string;\n state: JobState;\n claimExpiresAt: string | null;\n}\n/** Inner plaintext of the result box (ECIES to builderPublicKey). */\nexport interface JobResult {\n v: 1;\n jobId: string;\n scope: string;\n version: string | null;\n contentType: string;\n body: string; /* base64 */\n}\nexport type TeeNodeState = \"pending\" | \"admitted\" | \"draining\" | \"removed\";\nexport interface TeeNodeRegistration {\n nodeId: string;\n appId: Hex;\n composeHash: Hex;\n publicUrl: string;\n capacity: number;\n secret: string;\n}\nexport interface TeeNodeHeartbeat {\n composeHash: Hex;\n instanceId: string;\n activeSandboxes: number;\n capacity: number;\n}\nexport interface TeeNode {\n nodeId: string;\n appId: Hex;\n composeHash: Hex;\n publicUrl: string;\n state: TeeNodeState;\n capacity: number;\n activeSandboxes: number;\n lastHeartbeatAt: string | null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBO,MAAM,uBAAuB;AAC7B,MAAM,iBAAiB,CAAC,YAAY,WAAW;AAE/C,MAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,MAAM,wBAAwB;AAC9B,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AACrB,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,0BAA0B;AAChC,MAAM,+BAA+B;AACrC,MAAM,2BAA2B;","names":[]}
|
package/dist/protocol/jobs.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Agent -> GW: complete with ciphertext hash and size, or fail the job.
|
|
10
10
|
* GW -> Builder: return inline or polled status and opaque ciphertext.
|
|
11
11
|
* Builder: decrypt and verify the result's job, scope, and version bindings.
|
|
12
|
-
*
|
|
12
|
+
* See HANDOFF-contract.md section 1 for the complete flow.
|
|
13
13
|
*
|
|
14
14
|
* @category Protocol
|
|
15
15
|
*/
|
|
@@ -20,7 +20,6 @@ export declare const JOB_OPERATIONS: readonly ["raw_read", "inference"];
|
|
|
20
20
|
export type JobOperation = (typeof JOB_OPERATIONS)[number];
|
|
21
21
|
export declare const JOB_STATES: readonly ["queued", "claimed", "running", "completed", "failed", "expired", "cancelled"];
|
|
22
22
|
export type JobState = (typeof JOB_STATES)[number];
|
|
23
|
-
/** Payment lifecycle recorded for a queued job. */
|
|
24
23
|
export type PaymentState = "none" | "reserved" | "settled";
|
|
25
24
|
export declare const DEFAULT_LEASE_SECONDS = 30;
|
|
26
25
|
export declare const MAX_LEASE_SECONDS = 300;
|
|
@@ -43,14 +42,8 @@ export interface JobRequest {
|
|
|
43
42
|
pinnedVersion: string | null;
|
|
44
43
|
deadline: string;
|
|
45
44
|
}
|
|
46
|
-
/** Plaintext of the request box; the Gateway never sees it. */
|
|
47
45
|
export interface JobRequestEnvelope {
|
|
48
46
|
request: JobRequest;
|
|
49
|
-
/**
|
|
50
|
-
* `Web3Signed <b64>.<sig>` by the builder: `aud` = Gateway origin,
|
|
51
|
-
* `uri` = `/v1/jobs/execute`,
|
|
52
|
-
* `bodyHash` = `sha256(canonicalJobRequestBytes(request))`.
|
|
53
|
-
*/
|
|
54
47
|
auth: string;
|
|
55
48
|
}
|
|
56
49
|
/** Outer body of POST /v1/jobs (signed Web3Signed by the builder). */
|
|
@@ -60,13 +53,10 @@ export interface JobSubmission {
|
|
|
60
53
|
scope: string;
|
|
61
54
|
operation: JobOperation;
|
|
62
55
|
idempotencyKey: string;
|
|
63
|
-
/** Client UUID, echoed in `JobRequest.jobId`. */
|
|
64
56
|
jobId: string;
|
|
65
57
|
deadline?: string;
|
|
66
|
-
/** Base64 ECIES from `sealJobRequest`. */
|
|
67
58
|
requestCiphertext: string;
|
|
68
59
|
}
|
|
69
|
-
/** Response from `GET /v1/jobs/:id`. */
|
|
70
60
|
export interface JobStatus {
|
|
71
61
|
jobId: string;
|
|
72
62
|
state: JobState;
|
|
@@ -89,12 +79,10 @@ export interface JobStatus {
|
|
|
89
79
|
resultSize?: number;
|
|
90
80
|
resultExpiresAt?: string;
|
|
91
81
|
}
|
|
92
|
-
/** Request body for `POST /v1/jobs/claim`. */
|
|
93
82
|
export interface ClaimRequest {
|
|
94
83
|
leaseSeconds?: number;
|
|
95
84
|
capacity?: number;
|
|
96
85
|
}
|
|
97
|
-
/** Claimed job and owner identity returned by `POST /v1/jobs/claim`. */
|
|
98
86
|
export interface ClaimResponse {
|
|
99
87
|
job: {
|
|
100
88
|
jobId: string;
|
|
@@ -118,27 +106,21 @@ export interface ClaimResponse {
|
|
|
118
106
|
sealedEnvelope: SealedEnvelope;
|
|
119
107
|
};
|
|
120
108
|
}
|
|
121
|
-
/** Request body for `POST /v1/jobs/:id/heartbeat`. */
|
|
122
109
|
export interface HeartbeatRequest {
|
|
123
110
|
leaseSeconds?: number;
|
|
124
111
|
fencingToken: number;
|
|
125
112
|
}
|
|
126
|
-
/** Request body for `POST /v1/jobs/:id/complete`. */
|
|
127
113
|
export interface CompleteRequest {
|
|
128
114
|
fencingToken: number;
|
|
129
115
|
resultHash: Hex;
|
|
130
116
|
resultSize: number;
|
|
131
|
-
/** Inline when the decoded size is <= `MAX_INLINE_RESULT_BYTES`. */
|
|
132
117
|
resultCiphertext?: string;
|
|
133
|
-
/** v1.1, R2. */
|
|
134
118
|
resultHandle?: string;
|
|
135
119
|
}
|
|
136
|
-
/** Request body for `POST /v1/jobs/:id/fail`. */
|
|
137
120
|
export interface FailRequest {
|
|
138
121
|
fencingToken: number;
|
|
139
122
|
reason: string;
|
|
140
123
|
}
|
|
141
|
-
/** Successful response from a fenced job write endpoint. */
|
|
142
124
|
export interface FencedResponse {
|
|
143
125
|
success: true;
|
|
144
126
|
jobId: string;
|
|
@@ -154,9 +136,7 @@ export interface JobResult {
|
|
|
154
136
|
contentType: string;
|
|
155
137
|
body: string;
|
|
156
138
|
}
|
|
157
|
-
/** Admission lifecycle of a registered TEE node. */
|
|
158
139
|
export type TeeNodeState = "pending" | "admitted" | "draining" | "removed";
|
|
159
|
-
/** Request body for `POST /v1/tee-nodes`. */
|
|
160
140
|
export interface TeeNodeRegistration {
|
|
161
141
|
nodeId: string;
|
|
162
142
|
appId: Hex;
|
|
@@ -165,14 +145,12 @@ export interface TeeNodeRegistration {
|
|
|
165
145
|
capacity: number;
|
|
166
146
|
secret: string;
|
|
167
147
|
}
|
|
168
|
-
/** Request body for `POST /v1/tee-nodes/:id/heartbeat`. */
|
|
169
148
|
export interface TeeNodeHeartbeat {
|
|
170
149
|
composeHash: Hex;
|
|
171
150
|
instanceId: string;
|
|
172
151
|
activeSandboxes: number;
|
|
173
152
|
capacity: number;
|
|
174
153
|
}
|
|
175
|
-
/** Public registration and capacity state for a TEE node. */
|
|
176
154
|
export interface TeeNode {
|
|
177
155
|
nodeId: string;
|
|
178
156
|
appId: Hex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/protocol/jobs.ts"],"sourcesContent":["/**\n * Job queue protocol types for encrypted Personal Server execution.\n *\n * Builder -> GW -> Agent -> Sandbox\n * Builder -> GW: submit an enclave-encrypted request.\n * GW -> Agent: claim work with a fenced lease and sealed owner identity.\n * Agent -> Sandbox: decrypt, wake the owner sandbox, and execute privately.\n * Sandbox -> Agent: encrypt the result to the builder's public key.\n * Agent -> GW: complete with ciphertext hash and size, or fail the job.\n * GW -> Builder: return inline or polled status and opaque ciphertext.\n * Builder: decrypt and verify the result's job, scope, and version bindings.\n *
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/jobs.ts"],"sourcesContent":["/**\n * Job queue protocol types for encrypted Personal Server execution.\n *\n * Builder -> GW -> Agent -> Sandbox\n * Builder -> GW: submit an enclave-encrypted request.\n * GW -> Agent: claim work with a fenced lease and sealed owner identity.\n * Agent -> Sandbox: decrypt, wake the owner sandbox, and execute privately.\n * Sandbox -> Agent: encrypt the result to the builder's public key.\n * Agent -> GW: complete with ciphertext hash and size, or fail the job.\n * GW -> Builder: return inline or polled status and opaque ciphertext.\n * Builder: decrypt and verify the result's job, scope, and version bindings.\n * See HANDOFF-contract.md section 1 for the complete flow.\n *\n * @category Protocol\n */\n\nimport type { Address, Hex } from \"viem\";\nimport type { SealedEnvelope } from \"./identity\";\n\nexport const JOB_PROTOCOL_VERSION = 1;\nexport const JOB_OPERATIONS = [\"raw_read\", \"inference\"] as const;\nexport type JobOperation = (typeof JOB_OPERATIONS)[number];\nexport const JOB_STATES = [\n \"queued\",\n \"claimed\",\n \"running\",\n \"completed\",\n \"failed\",\n \"expired\",\n \"cancelled\",\n] as const;\nexport type JobState = (typeof JOB_STATES)[number];\nexport type PaymentState = \"none\" | \"reserved\" | \"settled\";\nexport const DEFAULT_LEASE_SECONDS = 30;\nexport const MAX_LEASE_SECONDS = 300;\nexport const MAX_ATTEMPTS = 3;\nexport const MAX_WAIT_SECONDS = 25;\nexport const CLAIM_POLL_FLOOR_MS = 1000;\nexport const MAX_INLINE_RESULT_BYTES = 1_048_576;\nexport const DEFAULT_JOB_DEADLINE_SECONDS = 600;\nexport const MAX_JOB_DEADLINE_SECONDS = 3600;\n\n/** Inner plaintext of the request box (ECIES to the enclave publicKey). */\nexport interface JobRequest {\n v: 1;\n jobId: string;\n owner: Address;\n builder: Address;\n builderPublicKey: Hex;\n grantId: Hex;\n scope: string;\n operation: JobOperation;\n pinnedVersion: string | null;\n deadline: string; /* ISO */\n}\nexport interface JobRequestEnvelope {\n request: JobRequest;\n auth: string; /* \"Web3Signed <b64>.<sig>\" by builder over uri /v1/jobs/execute, bodyHash = sha256(JSON(request)) */\n}\n/** Outer body of POST /v1/jobs (signed Web3Signed by the builder). */\nexport interface JobSubmission {\n owner: Address;\n grantId: Hex;\n scope: string;\n operation: JobOperation;\n idempotencyKey: string;\n jobId: string;\n /* client uuid, echoed in JobRequest */ deadline?: string;\n requestCiphertext: string; /* base64 ECIES */\n}\nexport interface JobStatus {\n jobId: string;\n state: JobState;\n operation: JobOperation;\n owner: Address;\n grantId: Hex;\n scope: string;\n pinnedVersion: string | null;\n attempt: number;\n price: string;\n payer: \"builder\";\n paymentState: PaymentState;\n createdAt: string;\n claimedAt: string | null;\n completedAt: string | null;\n failureReason: string | null;\n resultCiphertext?: string;\n resultHandle?: string;\n resultHash?: Hex;\n resultSize?: number;\n resultExpiresAt?: string;\n}\nexport interface ClaimRequest {\n leaseSeconds?: number;\n capacity?: number;\n}\nexport interface ClaimResponse {\n job: {\n jobId: string;\n owner: Address;\n builder: Address;\n grantId: Hex;\n scope: string;\n operation: JobOperation;\n pinnedVersion: string | null;\n requestCiphertext: string;\n attempt: number;\n deadlineAt: string | null;\n claimExpiresAt: string;\n fencingToken: number; /* = attempt; every node write echoes it */\n };\n identity: {\n userPsId: Hex;\n epoch: number;\n enclaveAddress: Address;\n enclavePublicKey: Hex;\n sealedEnvelope: SealedEnvelope;\n };\n}\nexport interface HeartbeatRequest {\n leaseSeconds?: number;\n fencingToken: number;\n}\nexport interface CompleteRequest {\n fencingToken: number;\n resultHash: Hex;\n resultSize: number;\n resultCiphertext?: string;\n /* inline <= MAX_INLINE_RESULT_BYTES */ resultHandle?: string; /* v1.1, R2 */\n}\nexport interface FailRequest {\n fencingToken: number;\n reason: string; /* <= 1024, fail.ts:16 */\n}\nexport interface FencedResponse {\n success: true;\n jobId: string;\n state: JobState;\n claimExpiresAt: string | null;\n}\n/** Inner plaintext of the result box (ECIES to builderPublicKey). */\nexport interface JobResult {\n v: 1;\n jobId: string;\n scope: string;\n version: string | null;\n contentType: string;\n body: string; /* base64 */\n}\nexport type TeeNodeState = \"pending\" | \"admitted\" | \"draining\" | \"removed\";\nexport interface TeeNodeRegistration {\n nodeId: string;\n appId: Hex;\n composeHash: Hex;\n publicUrl: string;\n capacity: number;\n secret: string;\n}\nexport interface TeeNodeHeartbeat {\n composeHash: Hex;\n instanceId: string;\n activeSandboxes: number;\n capacity: number;\n}\nexport interface TeeNode {\n nodeId: string;\n appId: Hex;\n composeHash: Hex;\n publicUrl: string;\n state: TeeNodeState;\n capacity: number;\n activeSandboxes: number;\n lastHeartbeatAt: string | null;\n}\n"],"mappings":"AAmBO,MAAM,uBAAuB;AAC7B,MAAM,iBAAiB,CAAC,YAAY,WAAW;AAE/C,MAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,MAAM,wBAAwB;AAC9B,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AACrB,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,0BAA0B;AAChC,MAAM,+BAA+B;AACrC,MAAM,2BAA2B;","names":[]}
|
package/package.json
CHANGED