@singularity-layer/grid 0.1.0 → 0.3.0
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 +1 -1
- package/dist/index.d.mts +144 -2
- package/dist/index.d.ts +144 -2
- package/dist/index.js +444 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +434 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -3
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -97,9 +97,115 @@ interface ChatCompletionResponse {
|
|
|
97
97
|
completion_tokens: number;
|
|
98
98
|
total_tokens: number;
|
|
99
99
|
};
|
|
100
|
+
/** Confidential-compute attestation of the serving node (E2E path). */
|
|
101
|
+
attestation?: Attestation;
|
|
102
|
+
}
|
|
103
|
+
/** Confidential-compute attestation of the node that served the request. */
|
|
104
|
+
interface Attestation {
|
|
105
|
+
nodeId: string;
|
|
106
|
+
teeType: string | null;
|
|
107
|
+
verified: boolean;
|
|
108
|
+
}
|
|
109
|
+
/** Response from POST /v1/reserve — the node + the X25519 key to seal the prompt to. */
|
|
110
|
+
interface ReserveResponse {
|
|
111
|
+
reservation_token: string;
|
|
112
|
+
node_id: string;
|
|
113
|
+
node_x25519_pubkey: string;
|
|
114
|
+
node_ed25519_pubkey: string | null;
|
|
115
|
+
tee_type?: string | null;
|
|
116
|
+
attestation_verified?: boolean;
|
|
117
|
+
expires_in_ms: number;
|
|
118
|
+
}
|
|
119
|
+
interface DeployProcessorOptions {
|
|
120
|
+
name: string;
|
|
121
|
+
code: string;
|
|
122
|
+
runtime?: "deno" | "wasm";
|
|
123
|
+
memory_mb?: number;
|
|
124
|
+
timeout_seconds?: number;
|
|
125
|
+
tee_type_required?: string;
|
|
126
|
+
metadata?: Record<string, unknown>;
|
|
127
|
+
}
|
|
128
|
+
interface ProcessorInfo {
|
|
129
|
+
id: string;
|
|
130
|
+
name: string;
|
|
131
|
+
owner_wallet: string;
|
|
132
|
+
owner_chain: string;
|
|
133
|
+
runtime: string;
|
|
134
|
+
memory_mb: number;
|
|
135
|
+
timeout_seconds: number;
|
|
136
|
+
tee_type_required?: string;
|
|
137
|
+
invocation_count: number;
|
|
138
|
+
last_invoked_at?: string;
|
|
139
|
+
status: string;
|
|
140
|
+
code_hash?: string;
|
|
141
|
+
deployment_stake_sgl: number;
|
|
142
|
+
invoke_url: string;
|
|
143
|
+
created_at: string;
|
|
144
|
+
updated_at?: string;
|
|
145
|
+
metadata?: Record<string, unknown>;
|
|
146
|
+
}
|
|
147
|
+
interface ProcessorDeployResult {
|
|
148
|
+
id: string;
|
|
149
|
+
name: string;
|
|
150
|
+
runtime: string;
|
|
151
|
+
memory_mb: number;
|
|
152
|
+
timeout_seconds: number;
|
|
153
|
+
status: string;
|
|
154
|
+
code_hash: string;
|
|
155
|
+
invoke_url: string;
|
|
156
|
+
tier: string;
|
|
157
|
+
sgl_staked: number;
|
|
158
|
+
created_at: string;
|
|
159
|
+
}
|
|
160
|
+
interface ProcessorInvokeResult {
|
|
161
|
+
job_id: string;
|
|
162
|
+
processor: string;
|
|
163
|
+
status: string;
|
|
164
|
+
output?: unknown;
|
|
165
|
+
duration_ms?: number;
|
|
166
|
+
payment?: {
|
|
167
|
+
amount_usd: string;
|
|
168
|
+
token: string;
|
|
169
|
+
discount_pct: number;
|
|
170
|
+
};
|
|
171
|
+
tee?: {
|
|
172
|
+
node_id: string;
|
|
173
|
+
tee_type: string;
|
|
174
|
+
attestation_verified: boolean;
|
|
175
|
+
};
|
|
176
|
+
message?: string;
|
|
177
|
+
}
|
|
178
|
+
interface ProcessorListResponse {
|
|
179
|
+
processors: ProcessorInfo[];
|
|
180
|
+
total: number;
|
|
181
|
+
page: number;
|
|
182
|
+
limit: number;
|
|
183
|
+
}
|
|
184
|
+
interface ProcessorLogEntry {
|
|
185
|
+
id: string;
|
|
186
|
+
processor_id: string;
|
|
187
|
+
job_id: string;
|
|
188
|
+
node_id: string;
|
|
189
|
+
duration_ms?: number;
|
|
190
|
+
status: string;
|
|
191
|
+
error_message?: string;
|
|
192
|
+
created_at: string;
|
|
193
|
+
}
|
|
194
|
+
interface ProcessorLogsResponse {
|
|
195
|
+
logs: ProcessorLogEntry[];
|
|
196
|
+
total: number;
|
|
197
|
+
page: number;
|
|
198
|
+
limit: number;
|
|
199
|
+
}
|
|
200
|
+
interface WalletAuth {
|
|
201
|
+
address: string;
|
|
202
|
+
chain?: string;
|
|
203
|
+
signature: string;
|
|
204
|
+
timestamp: string;
|
|
205
|
+
nonce: string;
|
|
100
206
|
}
|
|
101
207
|
|
|
102
|
-
declare const DEFAULT_BASE_URL = "https://
|
|
208
|
+
declare const DEFAULT_BASE_URL = "https://grid.x402compute.cc";
|
|
103
209
|
declare class GridClient {
|
|
104
210
|
private readonly baseUrl;
|
|
105
211
|
private readonly headers;
|
|
@@ -115,7 +221,43 @@ declare class GridClient {
|
|
|
115
221
|
}): Promise<JobResponse>;
|
|
116
222
|
getJob(jobId: string): Promise<JobResult>;
|
|
117
223
|
getAttestation(jobId: string): Promise<AttestationProof>;
|
|
224
|
+
/** Reserve a node + learn its X25519 key so we can seal the prompt to it. */
|
|
225
|
+
private reserve;
|
|
226
|
+
/**
|
|
227
|
+
* End-to-end encrypted chat completion. The prompt is sealed in this client to
|
|
228
|
+
* the serving node's key and only decrypts inside its TEE — the orchestrator
|
|
229
|
+
* only relays ciphertext. Requires an `apiKey` (credits); without one the grid
|
|
230
|
+
* replies 402 (the SDK does not sign x402 payments — use the wallet/browser flow).
|
|
231
|
+
*/
|
|
118
232
|
chatCompletions(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
|
|
233
|
+
/**
|
|
234
|
+
* Streaming end-to-end encrypted chat completion. Yields decoded text as it
|
|
235
|
+
* arrives; each chunk is decrypted and its ordering + termination verified (a
|
|
236
|
+
* truncated stream throws). Requires `apiKey` (credits). If the server isn't
|
|
237
|
+
* streaming (toggle off), the whole reply is yielded as a single chunk.
|
|
238
|
+
*/
|
|
239
|
+
chatCompletionStream(request: ChatCompletionRequest): AsyncGenerator<string, void, unknown>;
|
|
240
|
+
private requestWithWalletAuth;
|
|
241
|
+
private requestWithPayment;
|
|
242
|
+
deployProcessor(wallet: WalletAuth, options: DeployProcessorOptions): Promise<ProcessorDeployResult>;
|
|
243
|
+
invokeProcessor(processorName: string, input: Record<string, unknown>, options?: {
|
|
244
|
+
paymentHeader?: string;
|
|
245
|
+
paymentToken?: "USDC" | "SGL";
|
|
246
|
+
}): Promise<ProcessorInvokeResult>;
|
|
247
|
+
listProcessors(options?: {
|
|
248
|
+
owner?: string;
|
|
249
|
+
page?: number;
|
|
250
|
+
limit?: number;
|
|
251
|
+
}): Promise<ProcessorListResponse>;
|
|
252
|
+
getProcessor(processorId: string): Promise<ProcessorInfo>;
|
|
253
|
+
deleteProcessor(processorId: string, wallet: WalletAuth): Promise<{
|
|
254
|
+
deleted: boolean;
|
|
255
|
+
id: string;
|
|
256
|
+
}>;
|
|
257
|
+
getProcessorLogs(processorId: string, wallet: WalletAuth, options?: {
|
|
258
|
+
page?: number;
|
|
259
|
+
limit?: number;
|
|
260
|
+
}): Promise<ProcessorLogsResponse>;
|
|
119
261
|
}
|
|
120
262
|
|
|
121
263
|
declare class SGLError extends Error {
|
|
@@ -136,4 +278,4 @@ declare class SGLConnectionError extends SGLError {
|
|
|
136
278
|
constructor(message: string);
|
|
137
279
|
}
|
|
138
280
|
|
|
139
|
-
export { type AttestationProof, type CapacityResponse, type ChatChoice, type ChatCompletionRequest, type ChatCompletionResponse, type ChatMessage, DEFAULT_BASE_URL, GridClient, type GridClientOptions, type JobResponse, type JobResult, type JobSubmission, type ModelInfo, type ModelPricing, type PricingInfo, SGLAPIError, SGLAuthError, SGLConnectionError, SGLError, SGLNotFoundError, type TeeCapacity };
|
|
281
|
+
export { type Attestation, type AttestationProof, type CapacityResponse, type ChatChoice, type ChatCompletionRequest, type ChatCompletionResponse, type ChatMessage, DEFAULT_BASE_URL, type DeployProcessorOptions, GridClient, type GridClientOptions, type JobResponse, type JobResult, type JobSubmission, type ModelInfo, type ModelPricing, type PricingInfo, type ProcessorDeployResult, type ProcessorInfo, type ProcessorInvokeResult, type ProcessorListResponse, type ProcessorLogEntry, type ProcessorLogsResponse, type ReserveResponse, SGLAPIError, SGLAuthError, SGLConnectionError, SGLError, SGLNotFoundError, type TeeCapacity, type WalletAuth };
|
package/dist/index.d.ts
CHANGED
|
@@ -97,9 +97,115 @@ interface ChatCompletionResponse {
|
|
|
97
97
|
completion_tokens: number;
|
|
98
98
|
total_tokens: number;
|
|
99
99
|
};
|
|
100
|
+
/** Confidential-compute attestation of the serving node (E2E path). */
|
|
101
|
+
attestation?: Attestation;
|
|
102
|
+
}
|
|
103
|
+
/** Confidential-compute attestation of the node that served the request. */
|
|
104
|
+
interface Attestation {
|
|
105
|
+
nodeId: string;
|
|
106
|
+
teeType: string | null;
|
|
107
|
+
verified: boolean;
|
|
108
|
+
}
|
|
109
|
+
/** Response from POST /v1/reserve — the node + the X25519 key to seal the prompt to. */
|
|
110
|
+
interface ReserveResponse {
|
|
111
|
+
reservation_token: string;
|
|
112
|
+
node_id: string;
|
|
113
|
+
node_x25519_pubkey: string;
|
|
114
|
+
node_ed25519_pubkey: string | null;
|
|
115
|
+
tee_type?: string | null;
|
|
116
|
+
attestation_verified?: boolean;
|
|
117
|
+
expires_in_ms: number;
|
|
118
|
+
}
|
|
119
|
+
interface DeployProcessorOptions {
|
|
120
|
+
name: string;
|
|
121
|
+
code: string;
|
|
122
|
+
runtime?: "deno" | "wasm";
|
|
123
|
+
memory_mb?: number;
|
|
124
|
+
timeout_seconds?: number;
|
|
125
|
+
tee_type_required?: string;
|
|
126
|
+
metadata?: Record<string, unknown>;
|
|
127
|
+
}
|
|
128
|
+
interface ProcessorInfo {
|
|
129
|
+
id: string;
|
|
130
|
+
name: string;
|
|
131
|
+
owner_wallet: string;
|
|
132
|
+
owner_chain: string;
|
|
133
|
+
runtime: string;
|
|
134
|
+
memory_mb: number;
|
|
135
|
+
timeout_seconds: number;
|
|
136
|
+
tee_type_required?: string;
|
|
137
|
+
invocation_count: number;
|
|
138
|
+
last_invoked_at?: string;
|
|
139
|
+
status: string;
|
|
140
|
+
code_hash?: string;
|
|
141
|
+
deployment_stake_sgl: number;
|
|
142
|
+
invoke_url: string;
|
|
143
|
+
created_at: string;
|
|
144
|
+
updated_at?: string;
|
|
145
|
+
metadata?: Record<string, unknown>;
|
|
146
|
+
}
|
|
147
|
+
interface ProcessorDeployResult {
|
|
148
|
+
id: string;
|
|
149
|
+
name: string;
|
|
150
|
+
runtime: string;
|
|
151
|
+
memory_mb: number;
|
|
152
|
+
timeout_seconds: number;
|
|
153
|
+
status: string;
|
|
154
|
+
code_hash: string;
|
|
155
|
+
invoke_url: string;
|
|
156
|
+
tier: string;
|
|
157
|
+
sgl_staked: number;
|
|
158
|
+
created_at: string;
|
|
159
|
+
}
|
|
160
|
+
interface ProcessorInvokeResult {
|
|
161
|
+
job_id: string;
|
|
162
|
+
processor: string;
|
|
163
|
+
status: string;
|
|
164
|
+
output?: unknown;
|
|
165
|
+
duration_ms?: number;
|
|
166
|
+
payment?: {
|
|
167
|
+
amount_usd: string;
|
|
168
|
+
token: string;
|
|
169
|
+
discount_pct: number;
|
|
170
|
+
};
|
|
171
|
+
tee?: {
|
|
172
|
+
node_id: string;
|
|
173
|
+
tee_type: string;
|
|
174
|
+
attestation_verified: boolean;
|
|
175
|
+
};
|
|
176
|
+
message?: string;
|
|
177
|
+
}
|
|
178
|
+
interface ProcessorListResponse {
|
|
179
|
+
processors: ProcessorInfo[];
|
|
180
|
+
total: number;
|
|
181
|
+
page: number;
|
|
182
|
+
limit: number;
|
|
183
|
+
}
|
|
184
|
+
interface ProcessorLogEntry {
|
|
185
|
+
id: string;
|
|
186
|
+
processor_id: string;
|
|
187
|
+
job_id: string;
|
|
188
|
+
node_id: string;
|
|
189
|
+
duration_ms?: number;
|
|
190
|
+
status: string;
|
|
191
|
+
error_message?: string;
|
|
192
|
+
created_at: string;
|
|
193
|
+
}
|
|
194
|
+
interface ProcessorLogsResponse {
|
|
195
|
+
logs: ProcessorLogEntry[];
|
|
196
|
+
total: number;
|
|
197
|
+
page: number;
|
|
198
|
+
limit: number;
|
|
199
|
+
}
|
|
200
|
+
interface WalletAuth {
|
|
201
|
+
address: string;
|
|
202
|
+
chain?: string;
|
|
203
|
+
signature: string;
|
|
204
|
+
timestamp: string;
|
|
205
|
+
nonce: string;
|
|
100
206
|
}
|
|
101
207
|
|
|
102
|
-
declare const DEFAULT_BASE_URL = "https://
|
|
208
|
+
declare const DEFAULT_BASE_URL = "https://grid.x402compute.cc";
|
|
103
209
|
declare class GridClient {
|
|
104
210
|
private readonly baseUrl;
|
|
105
211
|
private readonly headers;
|
|
@@ -115,7 +221,43 @@ declare class GridClient {
|
|
|
115
221
|
}): Promise<JobResponse>;
|
|
116
222
|
getJob(jobId: string): Promise<JobResult>;
|
|
117
223
|
getAttestation(jobId: string): Promise<AttestationProof>;
|
|
224
|
+
/** Reserve a node + learn its X25519 key so we can seal the prompt to it. */
|
|
225
|
+
private reserve;
|
|
226
|
+
/**
|
|
227
|
+
* End-to-end encrypted chat completion. The prompt is sealed in this client to
|
|
228
|
+
* the serving node's key and only decrypts inside its TEE — the orchestrator
|
|
229
|
+
* only relays ciphertext. Requires an `apiKey` (credits); without one the grid
|
|
230
|
+
* replies 402 (the SDK does not sign x402 payments — use the wallet/browser flow).
|
|
231
|
+
*/
|
|
118
232
|
chatCompletions(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
|
|
233
|
+
/**
|
|
234
|
+
* Streaming end-to-end encrypted chat completion. Yields decoded text as it
|
|
235
|
+
* arrives; each chunk is decrypted and its ordering + termination verified (a
|
|
236
|
+
* truncated stream throws). Requires `apiKey` (credits). If the server isn't
|
|
237
|
+
* streaming (toggle off), the whole reply is yielded as a single chunk.
|
|
238
|
+
*/
|
|
239
|
+
chatCompletionStream(request: ChatCompletionRequest): AsyncGenerator<string, void, unknown>;
|
|
240
|
+
private requestWithWalletAuth;
|
|
241
|
+
private requestWithPayment;
|
|
242
|
+
deployProcessor(wallet: WalletAuth, options: DeployProcessorOptions): Promise<ProcessorDeployResult>;
|
|
243
|
+
invokeProcessor(processorName: string, input: Record<string, unknown>, options?: {
|
|
244
|
+
paymentHeader?: string;
|
|
245
|
+
paymentToken?: "USDC" | "SGL";
|
|
246
|
+
}): Promise<ProcessorInvokeResult>;
|
|
247
|
+
listProcessors(options?: {
|
|
248
|
+
owner?: string;
|
|
249
|
+
page?: number;
|
|
250
|
+
limit?: number;
|
|
251
|
+
}): Promise<ProcessorListResponse>;
|
|
252
|
+
getProcessor(processorId: string): Promise<ProcessorInfo>;
|
|
253
|
+
deleteProcessor(processorId: string, wallet: WalletAuth): Promise<{
|
|
254
|
+
deleted: boolean;
|
|
255
|
+
id: string;
|
|
256
|
+
}>;
|
|
257
|
+
getProcessorLogs(processorId: string, wallet: WalletAuth, options?: {
|
|
258
|
+
page?: number;
|
|
259
|
+
limit?: number;
|
|
260
|
+
}): Promise<ProcessorLogsResponse>;
|
|
119
261
|
}
|
|
120
262
|
|
|
121
263
|
declare class SGLError extends Error {
|
|
@@ -136,4 +278,4 @@ declare class SGLConnectionError extends SGLError {
|
|
|
136
278
|
constructor(message: string);
|
|
137
279
|
}
|
|
138
280
|
|
|
139
|
-
export { type AttestationProof, type CapacityResponse, type ChatChoice, type ChatCompletionRequest, type ChatCompletionResponse, type ChatMessage, DEFAULT_BASE_URL, GridClient, type GridClientOptions, type JobResponse, type JobResult, type JobSubmission, type ModelInfo, type ModelPricing, type PricingInfo, SGLAPIError, SGLAuthError, SGLConnectionError, SGLError, SGLNotFoundError, type TeeCapacity };
|
|
281
|
+
export { type Attestation, type AttestationProof, type CapacityResponse, type ChatChoice, type ChatCompletionRequest, type ChatCompletionResponse, type ChatMessage, DEFAULT_BASE_URL, type DeployProcessorOptions, GridClient, type GridClientOptions, type JobResponse, type JobResult, type JobSubmission, type ModelInfo, type ModelPricing, type PricingInfo, type ProcessorDeployResult, type ProcessorInfo, type ProcessorInvokeResult, type ProcessorListResponse, type ProcessorLogEntry, type ProcessorLogsResponse, type ReserveResponse, SGLAPIError, SGLAuthError, SGLConnectionError, SGLError, SGLNotFoundError, type TeeCapacity, type WalletAuth };
|