@singularity-layer/grid 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Singularity Layer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # @singularity-layer/grid
2
+
3
+ TypeScript SDK for the [SGL Network](https://singularitylayer.xyz) — a decentralized confidential compute grid with TEE-verified hardware.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @singularity-layer/grid
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### OpenAI-compatible chat
14
+
15
+ ```typescript
16
+ import { GridClient } from "@singularity-layer/grid";
17
+
18
+ const grid = new GridClient();
19
+
20
+ const response = await grid.chatCompletions({
21
+ model: "gemma2:2b",
22
+ messages: [{ role: "user", content: "What is 2+2?" }],
23
+ });
24
+
25
+ console.log(response.choices[0].message.content);
26
+ ```
27
+
28
+ ### With the OpenAI SDK
29
+
30
+ ```typescript
31
+ import OpenAI from "openai";
32
+
33
+ const client = new OpenAI({
34
+ baseURL:
35
+ "https://sgl-network-orchestrator.ivaavimusicproductions.workers.dev/v1",
36
+ apiKey: "sgl-anonymous",
37
+ });
38
+
39
+ const completion = await client.chat.completions.create({
40
+ model: "gemma2:2b",
41
+ messages: [{ role: "user", content: "Hello from the grid!" }],
42
+ });
43
+ ```
44
+
45
+ ### Grid discovery
46
+
47
+ ```typescript
48
+ import { GridClient } from "@singularity-layer/grid";
49
+
50
+ const grid = new GridClient();
51
+
52
+ // Check available capacity
53
+ const capacity = await grid.capacity();
54
+ console.log(`${capacity.active_nodes} nodes online`);
55
+
56
+ // List available models
57
+ const models = await grid.models();
58
+ models.forEach((m) => console.log(`${m.id} — ${m.sgl_node_count} nodes`));
59
+
60
+ // Get pricing
61
+ const pricing = await grid.pricing();
62
+ pricing.forEach((p) =>
63
+ console.log(`${p.model}: $${p.price_per_1k_input_tokens_usd}/1k tokens`),
64
+ );
65
+ ```
66
+
67
+ ### Submit a job
68
+
69
+ ```typescript
70
+ import { GridClient } from "@singularity-layer/grid";
71
+
72
+ const grid = new GridClient({ apiKey: "scg_..." });
73
+
74
+ const job = await grid.submitJob("gemma2:2b", {
75
+ messages: [{ role: "user", content: "Summarize quantum computing" }],
76
+ });
77
+
78
+ console.log(`Job ${job.job_id}: ${job.status}`);
79
+
80
+ // Poll for result
81
+ const result = await grid.getJob(job.job_id);
82
+ if (result.status === "completed") {
83
+ console.log(result.result);
84
+ }
85
+
86
+ // Verify TEE attestation
87
+ const attestation = await grid.getAttestation(job.job_id);
88
+ console.log(`Verified: ${attestation.verified}, TEE: ${attestation.tee_type}`);
89
+ ```
90
+
91
+ ## Configuration
92
+
93
+ ```typescript
94
+ const grid = new GridClient({
95
+ apiKey: "scg_...", // Optional — required for job submission
96
+ baseUrl: "https://custom-orchestrator.example.com", // Override orchestrator URL
97
+ timeout: 30_000, // Request timeout in ms (default: 60000)
98
+ });
99
+ ```
100
+
101
+ ## Error Handling
102
+
103
+ ```typescript
104
+ import {
105
+ GridClient,
106
+ SGLAPIError,
107
+ SGLAuthError,
108
+ SGLConnectionError,
109
+ SGLNotFoundError,
110
+ } from "@singularity-layer/grid";
111
+
112
+ try {
113
+ const result = await grid.getJob("nonexistent");
114
+ } catch (err) {
115
+ if (err instanceof SGLNotFoundError) {
116
+ console.log("Job not found");
117
+ } else if (err instanceof SGLAuthError) {
118
+ console.log("Invalid API key");
119
+ } else if (err instanceof SGLConnectionError) {
120
+ console.log("Orchestrator unreachable");
121
+ } else if (err instanceof SGLAPIError) {
122
+ console.log(`API error ${err.statusCode}: ${err.message}`);
123
+ }
124
+ }
125
+ ```
126
+
127
+ ## Requirements
128
+
129
+ - Node.js >= 18 (uses native `fetch`)
130
+ - Zero dependencies
131
+
132
+ ## License
133
+
134
+ MIT
@@ -0,0 +1,139 @@
1
+ interface TeeCapacity {
2
+ tee_type: string;
3
+ total_nodes: number;
4
+ active_nodes: number;
5
+ available_nodes: number;
6
+ }
7
+ interface CapacityResponse {
8
+ total_nodes: number;
9
+ active_nodes: number;
10
+ available_nodes: number;
11
+ by_tee_type: TeeCapacity[];
12
+ updated_at?: string;
13
+ }
14
+ interface ModelPricing {
15
+ price_per_1k_input_tokens_usd: number;
16
+ price_per_1k_output_tokens_usd: number;
17
+ }
18
+ interface ModelInfo {
19
+ id: string;
20
+ owned_by: string;
21
+ sgl_node_count: number;
22
+ sgl_tee_types: string[];
23
+ sgl_pricing?: ModelPricing;
24
+ }
25
+ interface PricingInfo {
26
+ model: string;
27
+ price_per_1k_input_tokens_usd: number;
28
+ price_per_1k_output_tokens_usd: number;
29
+ }
30
+ interface JobSubmission {
31
+ model: string;
32
+ input: Record<string, unknown>;
33
+ submitter_wallet?: string;
34
+ submitter_chain?: string;
35
+ }
36
+ interface JobResponse {
37
+ job_id: string;
38
+ status: string;
39
+ model: string;
40
+ node_id?: string;
41
+ tee_type?: string;
42
+ estimated_cost_usd?: number;
43
+ created_at?: string;
44
+ }
45
+ interface AttestationProof {
46
+ node_id: string;
47
+ tee_type: string;
48
+ job_id: string;
49
+ attestation_signature: string;
50
+ attestation_report?: string;
51
+ verified: boolean;
52
+ verified_at?: string;
53
+ }
54
+ interface JobResult {
55
+ id: string;
56
+ status: string;
57
+ model: string;
58
+ node_id?: string;
59
+ tee_type?: string;
60
+ result?: Record<string, unknown>;
61
+ encrypted_result?: string;
62
+ attestation_proof?: AttestationProof;
63
+ cost_usd?: number;
64
+ created_at?: string;
65
+ completed_at?: string;
66
+ error?: string;
67
+ }
68
+ interface GridClientOptions {
69
+ apiKey?: string;
70
+ baseUrl?: string;
71
+ timeout?: number;
72
+ }
73
+ interface ChatMessage {
74
+ role: "system" | "user" | "assistant";
75
+ content: string;
76
+ }
77
+ interface ChatCompletionRequest {
78
+ model: string;
79
+ messages: ChatMessage[];
80
+ temperature?: number;
81
+ max_tokens?: number;
82
+ stream?: boolean;
83
+ }
84
+ interface ChatChoice {
85
+ index: number;
86
+ message: ChatMessage;
87
+ finish_reason: string;
88
+ }
89
+ interface ChatCompletionResponse {
90
+ id: string;
91
+ object: string;
92
+ created: number;
93
+ model: string;
94
+ choices: ChatChoice[];
95
+ usage?: {
96
+ prompt_tokens: number;
97
+ completion_tokens: number;
98
+ total_tokens: number;
99
+ };
100
+ }
101
+
102
+ declare const DEFAULT_BASE_URL = "https://sgl-network-orchestrator.ivaavimusicproductions.workers.dev";
103
+ declare class GridClient {
104
+ private readonly baseUrl;
105
+ private readonly headers;
106
+ private readonly timeout;
107
+ constructor(options?: GridClientOptions);
108
+ private request;
109
+ capacity(): Promise<CapacityResponse>;
110
+ models(): Promise<ModelInfo[]>;
111
+ pricing(): Promise<PricingInfo[]>;
112
+ submitJob(model: string, input: Record<string, unknown>, options?: {
113
+ submitterWallet?: string;
114
+ submitterChain?: string;
115
+ }): Promise<JobResponse>;
116
+ getJob(jobId: string): Promise<JobResult>;
117
+ getAttestation(jobId: string): Promise<AttestationProof>;
118
+ chatCompletions(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
119
+ }
120
+
121
+ declare class SGLError extends Error {
122
+ constructor(message: string);
123
+ }
124
+ declare class SGLAPIError extends SGLError {
125
+ readonly statusCode: number;
126
+ readonly body?: Record<string, unknown>;
127
+ constructor(statusCode: number, message: string, body?: Record<string, unknown>);
128
+ }
129
+ declare class SGLAuthError extends SGLAPIError {
130
+ constructor(statusCode: number, message: string, body?: Record<string, unknown>);
131
+ }
132
+ declare class SGLNotFoundError extends SGLAPIError {
133
+ constructor(message: string, body?: Record<string, unknown>);
134
+ }
135
+ declare class SGLConnectionError extends SGLError {
136
+ constructor(message: string);
137
+ }
138
+
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 };
@@ -0,0 +1,139 @@
1
+ interface TeeCapacity {
2
+ tee_type: string;
3
+ total_nodes: number;
4
+ active_nodes: number;
5
+ available_nodes: number;
6
+ }
7
+ interface CapacityResponse {
8
+ total_nodes: number;
9
+ active_nodes: number;
10
+ available_nodes: number;
11
+ by_tee_type: TeeCapacity[];
12
+ updated_at?: string;
13
+ }
14
+ interface ModelPricing {
15
+ price_per_1k_input_tokens_usd: number;
16
+ price_per_1k_output_tokens_usd: number;
17
+ }
18
+ interface ModelInfo {
19
+ id: string;
20
+ owned_by: string;
21
+ sgl_node_count: number;
22
+ sgl_tee_types: string[];
23
+ sgl_pricing?: ModelPricing;
24
+ }
25
+ interface PricingInfo {
26
+ model: string;
27
+ price_per_1k_input_tokens_usd: number;
28
+ price_per_1k_output_tokens_usd: number;
29
+ }
30
+ interface JobSubmission {
31
+ model: string;
32
+ input: Record<string, unknown>;
33
+ submitter_wallet?: string;
34
+ submitter_chain?: string;
35
+ }
36
+ interface JobResponse {
37
+ job_id: string;
38
+ status: string;
39
+ model: string;
40
+ node_id?: string;
41
+ tee_type?: string;
42
+ estimated_cost_usd?: number;
43
+ created_at?: string;
44
+ }
45
+ interface AttestationProof {
46
+ node_id: string;
47
+ tee_type: string;
48
+ job_id: string;
49
+ attestation_signature: string;
50
+ attestation_report?: string;
51
+ verified: boolean;
52
+ verified_at?: string;
53
+ }
54
+ interface JobResult {
55
+ id: string;
56
+ status: string;
57
+ model: string;
58
+ node_id?: string;
59
+ tee_type?: string;
60
+ result?: Record<string, unknown>;
61
+ encrypted_result?: string;
62
+ attestation_proof?: AttestationProof;
63
+ cost_usd?: number;
64
+ created_at?: string;
65
+ completed_at?: string;
66
+ error?: string;
67
+ }
68
+ interface GridClientOptions {
69
+ apiKey?: string;
70
+ baseUrl?: string;
71
+ timeout?: number;
72
+ }
73
+ interface ChatMessage {
74
+ role: "system" | "user" | "assistant";
75
+ content: string;
76
+ }
77
+ interface ChatCompletionRequest {
78
+ model: string;
79
+ messages: ChatMessage[];
80
+ temperature?: number;
81
+ max_tokens?: number;
82
+ stream?: boolean;
83
+ }
84
+ interface ChatChoice {
85
+ index: number;
86
+ message: ChatMessage;
87
+ finish_reason: string;
88
+ }
89
+ interface ChatCompletionResponse {
90
+ id: string;
91
+ object: string;
92
+ created: number;
93
+ model: string;
94
+ choices: ChatChoice[];
95
+ usage?: {
96
+ prompt_tokens: number;
97
+ completion_tokens: number;
98
+ total_tokens: number;
99
+ };
100
+ }
101
+
102
+ declare const DEFAULT_BASE_URL = "https://sgl-network-orchestrator.ivaavimusicproductions.workers.dev";
103
+ declare class GridClient {
104
+ private readonly baseUrl;
105
+ private readonly headers;
106
+ private readonly timeout;
107
+ constructor(options?: GridClientOptions);
108
+ private request;
109
+ capacity(): Promise<CapacityResponse>;
110
+ models(): Promise<ModelInfo[]>;
111
+ pricing(): Promise<PricingInfo[]>;
112
+ submitJob(model: string, input: Record<string, unknown>, options?: {
113
+ submitterWallet?: string;
114
+ submitterChain?: string;
115
+ }): Promise<JobResponse>;
116
+ getJob(jobId: string): Promise<JobResult>;
117
+ getAttestation(jobId: string): Promise<AttestationProof>;
118
+ chatCompletions(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
119
+ }
120
+
121
+ declare class SGLError extends Error {
122
+ constructor(message: string);
123
+ }
124
+ declare class SGLAPIError extends SGLError {
125
+ readonly statusCode: number;
126
+ readonly body?: Record<string, unknown>;
127
+ constructor(statusCode: number, message: string, body?: Record<string, unknown>);
128
+ }
129
+ declare class SGLAuthError extends SGLAPIError {
130
+ constructor(statusCode: number, message: string, body?: Record<string, unknown>);
131
+ }
132
+ declare class SGLNotFoundError extends SGLAPIError {
133
+ constructor(message: string, body?: Record<string, unknown>);
134
+ }
135
+ declare class SGLConnectionError extends SGLError {
136
+ constructor(message: string);
137
+ }
138
+
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 };
package/dist/index.js ADDED
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
24
+ GridClient: () => GridClient,
25
+ SGLAPIError: () => SGLAPIError,
26
+ SGLAuthError: () => SGLAuthError,
27
+ SGLConnectionError: () => SGLConnectionError,
28
+ SGLError: () => SGLError,
29
+ SGLNotFoundError: () => SGLNotFoundError
30
+ });
31
+ module.exports = __toCommonJS(index_exports);
32
+
33
+ // src/errors.ts
34
+ var SGLError = class extends Error {
35
+ constructor(message) {
36
+ super(message);
37
+ this.name = "SGLError";
38
+ }
39
+ };
40
+ var SGLAPIError = class extends SGLError {
41
+ constructor(statusCode, message, body) {
42
+ super(`HTTP ${statusCode}: ${message}`);
43
+ this.name = "SGLAPIError";
44
+ this.statusCode = statusCode;
45
+ this.body = body;
46
+ }
47
+ };
48
+ var SGLAuthError = class extends SGLAPIError {
49
+ constructor(statusCode, message, body) {
50
+ super(statusCode, message, body);
51
+ this.name = "SGLAuthError";
52
+ }
53
+ };
54
+ var SGLNotFoundError = class extends SGLAPIError {
55
+ constructor(message, body) {
56
+ super(404, message, body);
57
+ this.name = "SGLNotFoundError";
58
+ }
59
+ };
60
+ var SGLConnectionError = class extends SGLError {
61
+ constructor(message) {
62
+ super(message);
63
+ this.name = "SGLConnectionError";
64
+ }
65
+ };
66
+
67
+ // src/client.ts
68
+ var DEFAULT_BASE_URL = "https://sgl-network-orchestrator.ivaavimusicproductions.workers.dev";
69
+ var DEFAULT_TIMEOUT = 6e4;
70
+ var GridClient = class {
71
+ constructor(options = {}) {
72
+ this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
73
+ this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
74
+ this.headers = { Accept: "application/json", "Content-Type": "application/json" };
75
+ if (options.apiKey) {
76
+ this.headers["Authorization"] = `Bearer ${options.apiKey}`;
77
+ }
78
+ }
79
+ async request(method, path, body) {
80
+ const url = `${this.baseUrl}${path}`;
81
+ const controller = new AbortController();
82
+ const timer = setTimeout(() => controller.abort(), this.timeout);
83
+ let response;
84
+ try {
85
+ response = await fetch(url, {
86
+ method,
87
+ headers: this.headers,
88
+ body: body ? JSON.stringify(body) : void 0,
89
+ signal: controller.signal
90
+ });
91
+ } catch (err) {
92
+ if (err instanceof Error && err.name === "AbortError") {
93
+ throw new SGLConnectionError(`Request to ${url} timed out`);
94
+ }
95
+ throw new SGLConnectionError(
96
+ `Could not connect to ${this.baseUrl}: ${err instanceof Error ? err.message : String(err)}`
97
+ );
98
+ } finally {
99
+ clearTimeout(timer);
100
+ }
101
+ if (!response.ok) {
102
+ let errorBody;
103
+ let message = response.statusText;
104
+ try {
105
+ errorBody = await response.json();
106
+ const err = errorBody?.error;
107
+ if (typeof err === "string") message = err;
108
+ else if (err && typeof err === "object" && "message" in err)
109
+ message = String(err.message);
110
+ } catch {
111
+ }
112
+ if (response.status === 401 || response.status === 403) {
113
+ throw new SGLAuthError(response.status, message, errorBody);
114
+ }
115
+ if (response.status === 404) {
116
+ throw new SGLNotFoundError(message, errorBody);
117
+ }
118
+ throw new SGLAPIError(response.status, message, errorBody);
119
+ }
120
+ if (response.status === 204) return {};
121
+ return await response.json();
122
+ }
123
+ // -- Public endpoints (no auth) ------------------------------------------
124
+ async capacity() {
125
+ return this.request("GET", "/grid/capacity");
126
+ }
127
+ async models() {
128
+ const data = await this.request("GET", "/grid/models");
129
+ return data.models ?? [];
130
+ }
131
+ async pricing() {
132
+ const data = await this.request("GET", "/grid/pricing");
133
+ return data.pricing ?? [];
134
+ }
135
+ // -- Authenticated endpoints ---------------------------------------------
136
+ async submitJob(model, input, options) {
137
+ const body = { model, input };
138
+ if (options?.submitterWallet) body.submitter_wallet = options.submitterWallet;
139
+ if (options?.submitterChain) body.submitter_chain = options.submitterChain;
140
+ return this.request("POST", "/grid/jobs", body);
141
+ }
142
+ async getJob(jobId) {
143
+ return this.request("GET", `/grid/jobs/${jobId}`);
144
+ }
145
+ async getAttestation(jobId) {
146
+ return this.request("GET", `/grid/jobs/${jobId}/attestation`);
147
+ }
148
+ // -- OpenAI-compatible ---------------------------------------------------
149
+ async chatCompletions(request) {
150
+ return this.request(
151
+ "POST",
152
+ "/v1/chat/completions",
153
+ request
154
+ );
155
+ }
156
+ };
157
+ // Annotate the CommonJS export names for ESM import in node:
158
+ 0 && (module.exports = {
159
+ DEFAULT_BASE_URL,
160
+ GridClient,
161
+ SGLAPIError,
162
+ SGLAuthError,
163
+ SGLConnectionError,
164
+ SGLError,
165
+ SGLNotFoundError
166
+ });
167
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/client.ts"],"sourcesContent":["export { GridClient, DEFAULT_BASE_URL } from \"./client.js\";\nexport {\n SGLError,\n SGLAPIError,\n SGLAuthError,\n SGLNotFoundError,\n SGLConnectionError,\n} from \"./errors.js\";\nexport type {\n AttestationProof,\n CapacityResponse,\n ChatChoice,\n ChatCompletionRequest,\n ChatCompletionResponse,\n ChatMessage,\n GridClientOptions,\n JobResponse,\n JobResult,\n JobSubmission,\n ModelInfo,\n ModelPricing,\n PricingInfo,\n TeeCapacity,\n} from \"./types.js\";\n","export class SGLError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"SGLError\";\n }\n}\n\nexport class SGLAPIError extends SGLError {\n readonly statusCode: number;\n readonly body?: Record<string, unknown>;\n\n constructor(\n statusCode: number,\n message: string,\n body?: Record<string, unknown>,\n ) {\n super(`HTTP ${statusCode}: ${message}`);\n this.name = \"SGLAPIError\";\n this.statusCode = statusCode;\n this.body = body;\n }\n}\n\nexport class SGLAuthError extends SGLAPIError {\n constructor(\n statusCode: number,\n message: string,\n body?: Record<string, unknown>,\n ) {\n super(statusCode, message, body);\n this.name = \"SGLAuthError\";\n }\n}\n\nexport class SGLNotFoundError extends SGLAPIError {\n constructor(message: string, body?: Record<string, unknown>) {\n super(404, message, body);\n this.name = \"SGLNotFoundError\";\n }\n}\n\nexport class SGLConnectionError extends SGLError {\n constructor(message: string) {\n super(message);\n this.name = \"SGLConnectionError\";\n }\n}\n","import { SGLAPIError, SGLAuthError, SGLConnectionError, SGLNotFoundError } from \"./errors.js\";\nimport type {\n AttestationProof,\n CapacityResponse,\n ChatCompletionRequest,\n ChatCompletionResponse,\n GridClientOptions,\n JobResponse,\n JobResult,\n ModelInfo,\n PricingInfo,\n} from \"./types.js\";\n\nexport const DEFAULT_BASE_URL =\n \"https://sgl-network-orchestrator.ivaavimusicproductions.workers.dev\";\n\nconst DEFAULT_TIMEOUT = 60_000;\n\nexport class GridClient {\n private readonly baseUrl: string;\n private readonly headers: Record<string, string>;\n private readonly timeout: number;\n\n constructor(options: GridClientOptions = {}) {\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n this.headers = { Accept: \"application/json\", \"Content-Type\": \"application/json\" };\n if (options.apiKey) {\n this.headers[\"Authorization\"] = `Bearer ${options.apiKey}`;\n }\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n let response: Response;\n try {\n response = await fetch(url, {\n method,\n headers: this.headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n } catch (err) {\n if (err instanceof Error && err.name === \"AbortError\") {\n throw new SGLConnectionError(`Request to ${url} timed out`);\n }\n throw new SGLConnectionError(\n `Could not connect to ${this.baseUrl}: ${err instanceof Error ? err.message : String(err)}`,\n );\n } finally {\n clearTimeout(timer);\n }\n\n if (!response.ok) {\n let errorBody: Record<string, unknown> | undefined;\n let message = response.statusText;\n try {\n errorBody = (await response.json()) as Record<string, unknown>;\n const err = errorBody?.error;\n if (typeof err === \"string\") message = err;\n else if (err && typeof err === \"object\" && \"message\" in err)\n message = String((err as { message: unknown }).message);\n } catch {\n /* body not JSON */\n }\n\n if (response.status === 401 || response.status === 403) {\n throw new SGLAuthError(response.status, message, errorBody);\n }\n if (response.status === 404) {\n throw new SGLNotFoundError(message, errorBody);\n }\n throw new SGLAPIError(response.status, message, errorBody);\n }\n\n if (response.status === 204) return {} as T;\n return (await response.json()) as T;\n }\n\n // -- Public endpoints (no auth) ------------------------------------------\n\n async capacity(): Promise<CapacityResponse> {\n return this.request<CapacityResponse>(\"GET\", \"/grid/capacity\");\n }\n\n async models(): Promise<ModelInfo[]> {\n const data = await this.request<{ models: ModelInfo[] }>(\"GET\", \"/grid/models\");\n return data.models ?? [];\n }\n\n async pricing(): Promise<PricingInfo[]> {\n const data = await this.request<{ pricing: PricingInfo[] }>(\"GET\", \"/grid/pricing\");\n return data.pricing ?? [];\n }\n\n // -- Authenticated endpoints ---------------------------------------------\n\n async submitJob(\n model: string,\n input: Record<string, unknown>,\n options?: { submitterWallet?: string; submitterChain?: string },\n ): Promise<JobResponse> {\n const body: Record<string, unknown> = { model, input };\n if (options?.submitterWallet) body.submitter_wallet = options.submitterWallet;\n if (options?.submitterChain) body.submitter_chain = options.submitterChain;\n return this.request<JobResponse>(\"POST\", \"/grid/jobs\", body);\n }\n\n async getJob(jobId: string): Promise<JobResult> {\n return this.request<JobResult>(\"GET\", `/grid/jobs/${jobId}`);\n }\n\n async getAttestation(jobId: string): Promise<AttestationProof> {\n return this.request<AttestationProof>(\"GET\", `/grid/jobs/${jobId}/attestation`);\n }\n\n // -- OpenAI-compatible ---------------------------------------------------\n\n async chatCompletions(\n request: ChatCompletionRequest,\n ): Promise<ChatCompletionResponse> {\n return this.request<ChatCompletionResponse>(\n \"POST\",\n \"/v1/chat/completions\",\n request,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA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,MAAM,KAAK,QAAiC,OAAO,cAAc;AAC9E,WAAO,KAAK,UAAU,CAAC;AAAA,EACzB;AAAA,EAEA,MAAM,UAAkC;AACtC,UAAM,OAAO,MAAM,KAAK,QAAoC,OAAO,eAAe;AAClF,WAAO,KAAK,WAAW,CAAC;AAAA,EAC1B;AAAA;AAAA,EAIA,MAAM,UACJ,OACA,OACA,SACsB;AACtB,UAAM,OAAgC,EAAE,OAAO,MAAM;AACrD,QAAI,SAAS,gBAAiB,MAAK,mBAAmB,QAAQ;AAC9D,QAAI,SAAS,eAAgB,MAAK,kBAAkB,QAAQ;AAC5D,WAAO,KAAK,QAAqB,QAAQ,cAAc,IAAI;AAAA,EAC7D;AAAA,EAEA,MAAM,OAAO,OAAmC;AAC9C,WAAO,KAAK,QAAmB,OAAO,cAAc,KAAK,EAAE;AAAA,EAC7D;AAAA,EAEA,MAAM,eAAe,OAA0C;AAC7D,WAAO,KAAK,QAA0B,OAAO,cAAc,KAAK,cAAc;AAAA,EAChF;AAAA;AAAA,EAIA,MAAM,gBACJ,SACiC;AACjC,WAAO,KAAK;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,134 @@
1
+ // src/errors.ts
2
+ var SGLError = class extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = "SGLError";
6
+ }
7
+ };
8
+ var SGLAPIError = class extends SGLError {
9
+ constructor(statusCode, message, body) {
10
+ super(`HTTP ${statusCode}: ${message}`);
11
+ this.name = "SGLAPIError";
12
+ this.statusCode = statusCode;
13
+ this.body = body;
14
+ }
15
+ };
16
+ var SGLAuthError = class extends SGLAPIError {
17
+ constructor(statusCode, message, body) {
18
+ super(statusCode, message, body);
19
+ this.name = "SGLAuthError";
20
+ }
21
+ };
22
+ var SGLNotFoundError = class extends SGLAPIError {
23
+ constructor(message, body) {
24
+ super(404, message, body);
25
+ this.name = "SGLNotFoundError";
26
+ }
27
+ };
28
+ var SGLConnectionError = class extends SGLError {
29
+ constructor(message) {
30
+ super(message);
31
+ this.name = "SGLConnectionError";
32
+ }
33
+ };
34
+
35
+ // src/client.ts
36
+ var DEFAULT_BASE_URL = "https://sgl-network-orchestrator.ivaavimusicproductions.workers.dev";
37
+ var DEFAULT_TIMEOUT = 6e4;
38
+ var GridClient = class {
39
+ constructor(options = {}) {
40
+ this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
41
+ this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
42
+ this.headers = { Accept: "application/json", "Content-Type": "application/json" };
43
+ if (options.apiKey) {
44
+ this.headers["Authorization"] = `Bearer ${options.apiKey}`;
45
+ }
46
+ }
47
+ async request(method, path, body) {
48
+ const url = `${this.baseUrl}${path}`;
49
+ const controller = new AbortController();
50
+ const timer = setTimeout(() => controller.abort(), this.timeout);
51
+ let response;
52
+ try {
53
+ response = await fetch(url, {
54
+ method,
55
+ headers: this.headers,
56
+ body: body ? JSON.stringify(body) : void 0,
57
+ signal: controller.signal
58
+ });
59
+ } catch (err) {
60
+ if (err instanceof Error && err.name === "AbortError") {
61
+ throw new SGLConnectionError(`Request to ${url} timed out`);
62
+ }
63
+ throw new SGLConnectionError(
64
+ `Could not connect to ${this.baseUrl}: ${err instanceof Error ? err.message : String(err)}`
65
+ );
66
+ } finally {
67
+ clearTimeout(timer);
68
+ }
69
+ if (!response.ok) {
70
+ let errorBody;
71
+ let message = response.statusText;
72
+ try {
73
+ errorBody = await response.json();
74
+ const err = errorBody?.error;
75
+ if (typeof err === "string") message = err;
76
+ else if (err && typeof err === "object" && "message" in err)
77
+ message = String(err.message);
78
+ } catch {
79
+ }
80
+ if (response.status === 401 || response.status === 403) {
81
+ throw new SGLAuthError(response.status, message, errorBody);
82
+ }
83
+ if (response.status === 404) {
84
+ throw new SGLNotFoundError(message, errorBody);
85
+ }
86
+ throw new SGLAPIError(response.status, message, errorBody);
87
+ }
88
+ if (response.status === 204) return {};
89
+ return await response.json();
90
+ }
91
+ // -- Public endpoints (no auth) ------------------------------------------
92
+ async capacity() {
93
+ return this.request("GET", "/grid/capacity");
94
+ }
95
+ async models() {
96
+ const data = await this.request("GET", "/grid/models");
97
+ return data.models ?? [];
98
+ }
99
+ async pricing() {
100
+ const data = await this.request("GET", "/grid/pricing");
101
+ return data.pricing ?? [];
102
+ }
103
+ // -- Authenticated endpoints ---------------------------------------------
104
+ async submitJob(model, input, options) {
105
+ const body = { model, input };
106
+ if (options?.submitterWallet) body.submitter_wallet = options.submitterWallet;
107
+ if (options?.submitterChain) body.submitter_chain = options.submitterChain;
108
+ return this.request("POST", "/grid/jobs", body);
109
+ }
110
+ async getJob(jobId) {
111
+ return this.request("GET", `/grid/jobs/${jobId}`);
112
+ }
113
+ async getAttestation(jobId) {
114
+ return this.request("GET", `/grid/jobs/${jobId}/attestation`);
115
+ }
116
+ // -- OpenAI-compatible ---------------------------------------------------
117
+ async chatCompletions(request) {
118
+ return this.request(
119
+ "POST",
120
+ "/v1/chat/completions",
121
+ request
122
+ );
123
+ }
124
+ };
125
+ export {
126
+ DEFAULT_BASE_URL,
127
+ GridClient,
128
+ SGLAPIError,
129
+ SGLAuthError,
130
+ SGLConnectionError,
131
+ SGLError,
132
+ SGLNotFoundError
133
+ };
134
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["export class SGLError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"SGLError\";\n }\n}\n\nexport class SGLAPIError extends SGLError {\n readonly statusCode: number;\n readonly body?: Record<string, unknown>;\n\n constructor(\n statusCode: number,\n message: string,\n body?: Record<string, unknown>,\n ) {\n super(`HTTP ${statusCode}: ${message}`);\n this.name = \"SGLAPIError\";\n this.statusCode = statusCode;\n this.body = body;\n }\n}\n\nexport class SGLAuthError extends SGLAPIError {\n constructor(\n statusCode: number,\n message: string,\n body?: Record<string, unknown>,\n ) {\n super(statusCode, message, body);\n this.name = \"SGLAuthError\";\n }\n}\n\nexport class SGLNotFoundError extends SGLAPIError {\n constructor(message: string, body?: Record<string, unknown>) {\n super(404, message, body);\n this.name = \"SGLNotFoundError\";\n }\n}\n\nexport class SGLConnectionError extends SGLError {\n constructor(message: string) {\n super(message);\n this.name = \"SGLConnectionError\";\n }\n}\n","import { SGLAPIError, SGLAuthError, SGLConnectionError, SGLNotFoundError } from \"./errors.js\";\nimport type {\n AttestationProof,\n CapacityResponse,\n ChatCompletionRequest,\n ChatCompletionResponse,\n GridClientOptions,\n JobResponse,\n JobResult,\n ModelInfo,\n PricingInfo,\n} from \"./types.js\";\n\nexport const DEFAULT_BASE_URL =\n \"https://sgl-network-orchestrator.ivaavimusicproductions.workers.dev\";\n\nconst DEFAULT_TIMEOUT = 60_000;\n\nexport class GridClient {\n private readonly baseUrl: string;\n private readonly headers: Record<string, string>;\n private readonly timeout: number;\n\n constructor(options: GridClientOptions = {}) {\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n this.headers = { Accept: \"application/json\", \"Content-Type\": \"application/json\" };\n if (options.apiKey) {\n this.headers[\"Authorization\"] = `Bearer ${options.apiKey}`;\n }\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n let response: Response;\n try {\n response = await fetch(url, {\n method,\n headers: this.headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n } catch (err) {\n if (err instanceof Error && err.name === \"AbortError\") {\n throw new SGLConnectionError(`Request to ${url} timed out`);\n }\n throw new SGLConnectionError(\n `Could not connect to ${this.baseUrl}: ${err instanceof Error ? err.message : String(err)}`,\n );\n } finally {\n clearTimeout(timer);\n }\n\n if (!response.ok) {\n let errorBody: Record<string, unknown> | undefined;\n let message = response.statusText;\n try {\n errorBody = (await response.json()) as Record<string, unknown>;\n const err = errorBody?.error;\n if (typeof err === \"string\") message = err;\n else if (err && typeof err === \"object\" && \"message\" in err)\n message = String((err as { message: unknown }).message);\n } catch {\n /* body not JSON */\n }\n\n if (response.status === 401 || response.status === 403) {\n throw new SGLAuthError(response.status, message, errorBody);\n }\n if (response.status === 404) {\n throw new SGLNotFoundError(message, errorBody);\n }\n throw new SGLAPIError(response.status, message, errorBody);\n }\n\n if (response.status === 204) return {} as T;\n return (await response.json()) as T;\n }\n\n // -- Public endpoints (no auth) ------------------------------------------\n\n async capacity(): Promise<CapacityResponse> {\n return this.request<CapacityResponse>(\"GET\", \"/grid/capacity\");\n }\n\n async models(): Promise<ModelInfo[]> {\n const data = await this.request<{ models: ModelInfo[] }>(\"GET\", \"/grid/models\");\n return data.models ?? [];\n }\n\n async pricing(): Promise<PricingInfo[]> {\n const data = await this.request<{ pricing: PricingInfo[] }>(\"GET\", \"/grid/pricing\");\n return data.pricing ?? [];\n }\n\n // -- Authenticated endpoints ---------------------------------------------\n\n async submitJob(\n model: string,\n input: Record<string, unknown>,\n options?: { submitterWallet?: string; submitterChain?: string },\n ): Promise<JobResponse> {\n const body: Record<string, unknown> = { model, input };\n if (options?.submitterWallet) body.submitter_wallet = options.submitterWallet;\n if (options?.submitterChain) body.submitter_chain = options.submitterChain;\n return this.request<JobResponse>(\"POST\", \"/grid/jobs\", body);\n }\n\n async getJob(jobId: string): Promise<JobResult> {\n return this.request<JobResult>(\"GET\", `/grid/jobs/${jobId}`);\n }\n\n async getAttestation(jobId: string): Promise<AttestationProof> {\n return this.request<AttestationProof>(\"GET\", `/grid/jobs/${jobId}/attestation`);\n }\n\n // -- OpenAI-compatible ---------------------------------------------------\n\n async chatCompletions(\n request: ChatCompletionRequest,\n ): Promise<ChatCompletionResponse> {\n return this.request<ChatCompletionResponse>(\n \"POST\",\n \"/v1/chat/completions\",\n request,\n );\n }\n}\n"],"mappings":";AAAO,IAAM,WA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AA,EAEA,MAAM,UAAkC;AACtC,UAAM,OAAO,MAAM,KAAK,QAAoC,OAAO,eAAe;AAClF,WAAO,KAAK,WAAW,CAAC;AAAA,EAC1B;AAAA;AAAA,EAIA,MAAM,UACJ,OACA,OACA,SACsB;AACtB,UAAM,OAAgC,EAAE,OAAO,MAAM;AACrD,QAAI,SAAS,gBAAiB,MAAK,mBAAmB,QAAQ;AAC9D,QAAI,SAAS,eAAgB,MAAK,kBAAkB,QAAQ;AAC5D,WAAO,KAAK,QAAqB,QAAQ,cAAc,IAAI;AAAA,EAC7D;AAAA,EAEA,MAAM,OAAO,OAAmC;AAC9C,WAAO,KAAK,QAAmB,OAAO,cAAc,KAAK,EAAE;AAAA,EAC7D;AAAA,EAEA,MAAM,eAAe,OAA0C;AAC7D,WAAO,KAAK,QAA0B,OAAO,cAAc,KAAK,cAAc;AAAA,EAChF;AAAA;AAAA,EAIA,MAAM,gBACJ,SACiC;AACjC,WAAO,KAAK;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@singularity-layer/grid",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for the SGL Network confidential compute grid",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "typecheck": "tsc --noEmit",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "keywords": [
25
+ "singularity",
26
+ "sgl",
27
+ "compute",
28
+ "grid",
29
+ "tee",
30
+ "confidential-computing",
31
+ "inference",
32
+ "ai",
33
+ "openai"
34
+ ],
35
+ "author": "Singularity Layer <dev@singularitylayer.xyz>",
36
+ "license": "MIT",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/Singularity-Layer/sgl-network-sdk-ts"
40
+ },
41
+ "homepage": "https://singularitylayer.xyz",
42
+ "engines": {
43
+ "node": ">=18"
44
+ },
45
+ "devDependencies": {
46
+ "tsup": "^8.0.0",
47
+ "typescript": "^5.4.0"
48
+ }
49
+ }