@opendatalabs/vana-sdk 3.22.0-pr.208.28eb140 → 3.22.0-pr.208.e9c19e9

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.
@@ -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 * 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":[]}
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 * Full flow: personal-server-ts `docs/260903-jobs-contract.md`, section 1.\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];\n/** Payment lifecycle recorded for a queued job. */\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}\n/** Plaintext of the request box; the Gateway never sees it. */\nexport interface JobRequestEnvelope {\n request: JobRequest;\n /**\n * `Web3Signed <b64>.<sig>` by the builder: `aud` = Gateway origin,\n * `uri` = `/v1/jobs/execute`,\n * `bodyHash` = `sha256(canonicalJobRequestBytes(request))`.\n */\n auth: string;\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 /** Client UUID, echoed in `JobRequest.jobId`. */\n jobId: string;\n deadline?: string;\n /** Base64 ECIES from `sealJobRequest`. */\n requestCiphertext: string;\n}\n/** Response from `GET /v1/jobs/:id`. */\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}\n/** Request body for `POST /v1/jobs/claim`. */\nexport interface ClaimRequest {\n leaseSeconds?: number;\n capacity?: number;\n}\n/** Claimed job and owner identity returned by `POST /v1/jobs/claim`. */\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}\n/** Request body for `POST /v1/jobs/:id/heartbeat`. */\nexport interface HeartbeatRequest {\n leaseSeconds?: number;\n fencingToken: number;\n}\n/** Request body for `POST /v1/jobs/:id/complete`. */\nexport interface CompleteRequest {\n fencingToken: number;\n resultHash: Hex;\n resultSize: number;\n /** Inline when the decoded size is <= `MAX_INLINE_RESULT_BYTES`. */\n resultCiphertext?: string;\n /** v1.1, R2. */\n resultHandle?: string;\n}\n/** Request body for `POST /v1/jobs/:id/fail`. */\nexport interface FailRequest {\n fencingToken: number;\n reason: string; /* <= 1024, fail.ts:16 */\n}\n/** Successful response from a fenced job write endpoint. */\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}\n/** Admission lifecycle of a registered TEE node. */\nexport type TeeNodeState = \"pending\" | \"admitted\" | \"draining\" | \"removed\";\n/** Request body for `POST /v1/tee-nodes`. */\nexport interface TeeNodeRegistration {\n nodeId: string;\n appId: Hex;\n composeHash: Hex;\n publicUrl: string;\n capacity: number;\n secret: string;\n}\n/** Request body for `POST /v1/tee-nodes/:id/heartbeat`. */\nexport interface TeeNodeHeartbeat {\n composeHash: Hex;\n instanceId: string;\n activeSandboxes: number;\n capacity: number;\n}\n/** Public registration and capacity state for a TEE node. */\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;AAIO,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":[]}
@@ -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
- * See HANDOFF-contract.md section 1 for the complete flow.
12
+ * Full flow: personal-server-ts `docs/260903-jobs-contract.md`, section 1.
13
13
  *
14
14
  * @category Protocol
15
15
  */
@@ -20,6 +20,7 @@ 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. */
23
24
  export type PaymentState = "none" | "reserved" | "settled";
24
25
  export declare const DEFAULT_LEASE_SECONDS = 30;
25
26
  export declare const MAX_LEASE_SECONDS = 300;
@@ -42,8 +43,14 @@ export interface JobRequest {
42
43
  pinnedVersion: string | null;
43
44
  deadline: string;
44
45
  }
46
+ /** Plaintext of the request box; the Gateway never sees it. */
45
47
  export interface JobRequestEnvelope {
46
48
  request: JobRequest;
49
+ /**
50
+ * `Web3Signed <b64>.<sig>` by the builder: `aud` = Gateway origin,
51
+ * `uri` = `/v1/jobs/execute`,
52
+ * `bodyHash` = `sha256(canonicalJobRequestBytes(request))`.
53
+ */
47
54
  auth: string;
48
55
  }
49
56
  /** Outer body of POST /v1/jobs (signed Web3Signed by the builder). */
@@ -53,10 +60,13 @@ export interface JobSubmission {
53
60
  scope: string;
54
61
  operation: JobOperation;
55
62
  idempotencyKey: string;
63
+ /** Client UUID, echoed in `JobRequest.jobId`. */
56
64
  jobId: string;
57
65
  deadline?: string;
66
+ /** Base64 ECIES from `sealJobRequest`. */
58
67
  requestCiphertext: string;
59
68
  }
69
+ /** Response from `GET /v1/jobs/:id`. */
60
70
  export interface JobStatus {
61
71
  jobId: string;
62
72
  state: JobState;
@@ -79,10 +89,12 @@ export interface JobStatus {
79
89
  resultSize?: number;
80
90
  resultExpiresAt?: string;
81
91
  }
92
+ /** Request body for `POST /v1/jobs/claim`. */
82
93
  export interface ClaimRequest {
83
94
  leaseSeconds?: number;
84
95
  capacity?: number;
85
96
  }
97
+ /** Claimed job and owner identity returned by `POST /v1/jobs/claim`. */
86
98
  export interface ClaimResponse {
87
99
  job: {
88
100
  jobId: string;
@@ -106,21 +118,27 @@ export interface ClaimResponse {
106
118
  sealedEnvelope: SealedEnvelope;
107
119
  };
108
120
  }
121
+ /** Request body for `POST /v1/jobs/:id/heartbeat`. */
109
122
  export interface HeartbeatRequest {
110
123
  leaseSeconds?: number;
111
124
  fencingToken: number;
112
125
  }
126
+ /** Request body for `POST /v1/jobs/:id/complete`. */
113
127
  export interface CompleteRequest {
114
128
  fencingToken: number;
115
129
  resultHash: Hex;
116
130
  resultSize: number;
131
+ /** Inline when the decoded size is <= `MAX_INLINE_RESULT_BYTES`. */
117
132
  resultCiphertext?: string;
133
+ /** v1.1, R2. */
118
134
  resultHandle?: string;
119
135
  }
136
+ /** Request body for `POST /v1/jobs/:id/fail`. */
120
137
  export interface FailRequest {
121
138
  fencingToken: number;
122
139
  reason: string;
123
140
  }
141
+ /** Successful response from a fenced job write endpoint. */
124
142
  export interface FencedResponse {
125
143
  success: true;
126
144
  jobId: string;
@@ -136,7 +154,9 @@ export interface JobResult {
136
154
  contentType: string;
137
155
  body: string;
138
156
  }
157
+ /** Admission lifecycle of a registered TEE node. */
139
158
  export type TeeNodeState = "pending" | "admitted" | "draining" | "removed";
159
+ /** Request body for `POST /v1/tee-nodes`. */
140
160
  export interface TeeNodeRegistration {
141
161
  nodeId: string;
142
162
  appId: Hex;
@@ -145,12 +165,14 @@ export interface TeeNodeRegistration {
145
165
  capacity: number;
146
166
  secret: string;
147
167
  }
168
+ /** Request body for `POST /v1/tee-nodes/:id/heartbeat`. */
148
169
  export interface TeeNodeHeartbeat {
149
170
  composeHash: Hex;
150
171
  instanceId: string;
151
172
  activeSandboxes: number;
152
173
  capacity: number;
153
174
  }
175
+ /** Public registration and capacity state for a TEE node. */
154
176
  export interface TeeNode {
155
177
  nodeId: string;
156
178
  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 * 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":[]}
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 * Full flow: personal-server-ts `docs/260903-jobs-contract.md`, section 1.\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];\n/** Payment lifecycle recorded for a queued job. */\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}\n/** Plaintext of the request box; the Gateway never sees it. */\nexport interface JobRequestEnvelope {\n request: JobRequest;\n /**\n * `Web3Signed <b64>.<sig>` by the builder: `aud` = Gateway origin,\n * `uri` = `/v1/jobs/execute`,\n * `bodyHash` = `sha256(canonicalJobRequestBytes(request))`.\n */\n auth: string;\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 /** Client UUID, echoed in `JobRequest.jobId`. */\n jobId: string;\n deadline?: string;\n /** Base64 ECIES from `sealJobRequest`. */\n requestCiphertext: string;\n}\n/** Response from `GET /v1/jobs/:id`. */\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}\n/** Request body for `POST /v1/jobs/claim`. */\nexport interface ClaimRequest {\n leaseSeconds?: number;\n capacity?: number;\n}\n/** Claimed job and owner identity returned by `POST /v1/jobs/claim`. */\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}\n/** Request body for `POST /v1/jobs/:id/heartbeat`. */\nexport interface HeartbeatRequest {\n leaseSeconds?: number;\n fencingToken: number;\n}\n/** Request body for `POST /v1/jobs/:id/complete`. */\nexport interface CompleteRequest {\n fencingToken: number;\n resultHash: Hex;\n resultSize: number;\n /** Inline when the decoded size is <= `MAX_INLINE_RESULT_BYTES`. */\n resultCiphertext?: string;\n /** v1.1, R2. */\n resultHandle?: string;\n}\n/** Request body for `POST /v1/jobs/:id/fail`. */\nexport interface FailRequest {\n fencingToken: number;\n reason: string; /* <= 1024, fail.ts:16 */\n}\n/** Successful response from a fenced job write endpoint. */\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}\n/** Admission lifecycle of a registered TEE node. */\nexport type TeeNodeState = \"pending\" | \"admitted\" | \"draining\" | \"removed\";\n/** Request body for `POST /v1/tee-nodes`. */\nexport interface TeeNodeRegistration {\n nodeId: string;\n appId: Hex;\n composeHash: Hex;\n publicUrl: string;\n capacity: number;\n secret: string;\n}\n/** Request body for `POST /v1/tee-nodes/:id/heartbeat`. */\nexport interface TeeNodeHeartbeat {\n composeHash: Hex;\n instanceId: string;\n activeSandboxes: number;\n capacity: number;\n}\n/** Public registration and capacity state for a TEE node. */\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;AAIO,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendatalabs/vana-sdk",
3
- "version": "3.22.0-pr.208.28eb140",
3
+ "version": "3.22.0-pr.208.e9c19e9",
4
4
  "description": "A TypeScript library for interacting with Vana Network smart contracts.",
5
5
  "publishConfig": {
6
6
  "access": "public"