jungle-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/dist/api.d.ts +208 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +118 -0
- package/dist/api.js.map +1 -0
- package/dist/auth.d.ts +66 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +151 -0
- package/dist/auth.js.map +1 -0
- package/dist/banner.d.ts +5 -0
- package/dist/banner.d.ts.map +1 -0
- package/dist/banner.js +11 -0
- package/dist/banner.js.map +1 -0
- package/dist/config.d.ts +30 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +114 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1769 -0
- package/dist/index.js.map +1 -0
- package/dist/node-agent-installer.d.ts +56 -0
- package/dist/node-agent-installer.d.ts.map +1 -0
- package/dist/node-agent-installer.js +332 -0
- package/dist/node-agent-installer.js.map +1 -0
- package/dist/node-config.d.ts +40 -0
- package/dist/node-config.d.ts.map +1 -0
- package/dist/node-config.js +129 -0
- package/dist/node-config.js.map +1 -0
- package/dist/prompt.d.ts +4 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +58 -0
- package/dist/prompt.js.map +1 -0
- package/dist/repl.d.ts +10 -0
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +200 -0
- package/dist/repl.js.map +1 -0
- package/dist/ui.d.ts +29 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +165 -0
- package/dist/ui.js.map +1 -0
- package/dist/version.d.ts +22 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +83 -0
- package/dist/version.js.map +1 -0
- package/package.json +27 -0
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* api.ts — Typed HTTP client for the Jungle Grid orchestrator REST API.
|
|
3
|
+
*
|
|
4
|
+
* Architecture role: Pillar 1 (Abstract GPU Selection) enforcement boundary.
|
|
5
|
+
* This module is the ONLY place the CLI makes HTTP requests to the orchestrator.
|
|
6
|
+
* All requests go through apiRequest(), which:
|
|
7
|
+
* - Injects the Bearer token from stored credentials (auth.ts)
|
|
8
|
+
* - Resolves the base URL from config (config.ts)
|
|
9
|
+
* - Returns typed responses matching the orchestrator's JSON envelope
|
|
10
|
+
*
|
|
11
|
+
* DISPLAY CONTRACT:
|
|
12
|
+
* - Job-oriented responses should stay workload-first and scheduling-focused.
|
|
13
|
+
* - Provider and marketplace node inspection may intentionally include full
|
|
14
|
+
* node capability data such as GPU type, VRAM, or CUDA support.
|
|
15
|
+
* - Secrets or node authentication material must never be modeled here.
|
|
16
|
+
*
|
|
17
|
+
* Upstream: Called by command handlers in index.ts.
|
|
18
|
+
* Downstream: Calls orchestrator REST API; reads token via auth.ts; reads
|
|
19
|
+
* API URL via config.ts.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Response from POST /v1/jobs — job submission confirmation.
|
|
23
|
+
* Note: no hardware details in the response. The user sees a job ID and status,
|
|
24
|
+
* never which GPU was selected. That is an internal scheduling decision.
|
|
25
|
+
*/
|
|
26
|
+
export interface SubmitJobResponse {
|
|
27
|
+
job_id: string;
|
|
28
|
+
status: string;
|
|
29
|
+
queued_at: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Score breakdown returned as part of job status.
|
|
33
|
+
* These are abstract quality scores, not hardware metrics.
|
|
34
|
+
*/
|
|
35
|
+
export interface ScoreBreakdown {
|
|
36
|
+
price: number;
|
|
37
|
+
reliability: number;
|
|
38
|
+
latency: number;
|
|
39
|
+
performance: number;
|
|
40
|
+
queue_depth: number;
|
|
41
|
+
thermal: number;
|
|
42
|
+
total: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Response from GET /v1/jobs/:id — job status details.
|
|
46
|
+
* assigned_node_id is an opaque identifier, not a hardware description.
|
|
47
|
+
*/
|
|
48
|
+
export interface JobStatusResponse {
|
|
49
|
+
job_id: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
status: string;
|
|
52
|
+
status_reason?: string;
|
|
53
|
+
workload_type?: string;
|
|
54
|
+
model_size_gb?: number;
|
|
55
|
+
batch_size?: number;
|
|
56
|
+
precision?: string;
|
|
57
|
+
optimize_for?: string;
|
|
58
|
+
image?: string;
|
|
59
|
+
command?: string;
|
|
60
|
+
args?: string[];
|
|
61
|
+
assigned_node_id?: string;
|
|
62
|
+
last_failed_node_id?: string;
|
|
63
|
+
dispatch_attempt?: number;
|
|
64
|
+
score_breakdown?: ScoreBreakdown;
|
|
65
|
+
created_at: string;
|
|
66
|
+
queued_at?: string;
|
|
67
|
+
started_at?: string;
|
|
68
|
+
updated_at: string;
|
|
69
|
+
completed_at?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface JobRuntimeResponse {
|
|
72
|
+
job_id: string;
|
|
73
|
+
status: string;
|
|
74
|
+
status_reason?: string;
|
|
75
|
+
image: string;
|
|
76
|
+
command?: string;
|
|
77
|
+
args?: string[];
|
|
78
|
+
exit_code?: number;
|
|
79
|
+
timed_out?: boolean;
|
|
80
|
+
started_at?: string;
|
|
81
|
+
finished_at?: string;
|
|
82
|
+
stdout_tail?: string;
|
|
83
|
+
stderr_tail?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Raw job item from GET /v1/jobs.
|
|
87
|
+
*
|
|
88
|
+
* The orchestrator currently serializes Go struct field names as PascalCase.
|
|
89
|
+
* The CLI reads only abstract workload fields and intentionally ignores any
|
|
90
|
+
* hardware-specific fields that may exist in the payload.
|
|
91
|
+
*/
|
|
92
|
+
export interface JobListItem {
|
|
93
|
+
ID: string;
|
|
94
|
+
Name?: string;
|
|
95
|
+
Status?: string;
|
|
96
|
+
WorkloadType?: string;
|
|
97
|
+
OptimizeFor?: string;
|
|
98
|
+
CreatedAtUnix?: number;
|
|
99
|
+
UpdatedAtUnix?: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Response from GET /v1/jobs — owner-filtered list of the current user's jobs.
|
|
103
|
+
*/
|
|
104
|
+
export interface JobListResponse {
|
|
105
|
+
jobs?: JobListItem[];
|
|
106
|
+
}
|
|
107
|
+
export interface NodeRegisterRequest {
|
|
108
|
+
node_id: string;
|
|
109
|
+
email: string;
|
|
110
|
+
payout: {
|
|
111
|
+
bank_name: string;
|
|
112
|
+
account_number: string;
|
|
113
|
+
account_name: string;
|
|
114
|
+
};
|
|
115
|
+
hardware: {
|
|
116
|
+
gpu: string;
|
|
117
|
+
vram_gb: number;
|
|
118
|
+
gpu_count: number;
|
|
119
|
+
cpu_cores: number;
|
|
120
|
+
cpu_mhz: number;
|
|
121
|
+
ram_gb: number;
|
|
122
|
+
cuda_version: string;
|
|
123
|
+
cuda_support: boolean;
|
|
124
|
+
compute_capability: string;
|
|
125
|
+
};
|
|
126
|
+
network: {
|
|
127
|
+
latency_ms: number;
|
|
128
|
+
};
|
|
129
|
+
environment: {
|
|
130
|
+
os: string;
|
|
131
|
+
location: string;
|
|
132
|
+
dispatch_url: string;
|
|
133
|
+
};
|
|
134
|
+
price_per_hour: number;
|
|
135
|
+
reliability_score: number;
|
|
136
|
+
performance_score: number;
|
|
137
|
+
}
|
|
138
|
+
export interface NodeRegisterResponse {
|
|
139
|
+
node_id: string;
|
|
140
|
+
api_key: string;
|
|
141
|
+
status: string;
|
|
142
|
+
}
|
|
143
|
+
export interface NodeActivateResponse {
|
|
144
|
+
node_id: string;
|
|
145
|
+
status: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Response from POST /auth/device — initiates the device login flow.
|
|
149
|
+
*/
|
|
150
|
+
export interface DeviceAuthResponse {
|
|
151
|
+
login_url: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Response from GET /auth/token — returned when login is complete.
|
|
155
|
+
* The token field is an opaque JWT. The CLI never inspects its payload.
|
|
156
|
+
*/
|
|
157
|
+
export interface TokenResponse {
|
|
158
|
+
token: string;
|
|
159
|
+
user: {
|
|
160
|
+
id: string;
|
|
161
|
+
email: string;
|
|
162
|
+
role?: string;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Response from GET /auth/me — current user info.
|
|
167
|
+
*/
|
|
168
|
+
export interface MeResponse {
|
|
169
|
+
id: string;
|
|
170
|
+
email: string;
|
|
171
|
+
role: string;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Error thrown when the API returns a non-2xx status.
|
|
175
|
+
* Carries the status code and parsed error body for display.
|
|
176
|
+
*/
|
|
177
|
+
export declare class ApiError extends Error {
|
|
178
|
+
readonly status: number;
|
|
179
|
+
readonly code: string;
|
|
180
|
+
constructor(status: number, code: string, message: string);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Makes an authenticated HTTP request to the orchestrator API.
|
|
184
|
+
*
|
|
185
|
+
* Automatically injects the Bearer token if the user is logged in.
|
|
186
|
+
* If no token is stored, the request is sent without auth (the server
|
|
187
|
+
* decides whether to allow unauthenticated access).
|
|
188
|
+
*
|
|
189
|
+
* @param method - HTTP method (GET, POST, etc.)
|
|
190
|
+
* @param urlPath - Path relative to the API base URL (e.g., "/v1/jobs")
|
|
191
|
+
* @param body - Optional request body; will be JSON-serialized.
|
|
192
|
+
* @returns Parsed JSON response body, typed as T.
|
|
193
|
+
* @throws ApiError if the server returns a non-2xx status.
|
|
194
|
+
*
|
|
195
|
+
* Side effects: Reads token from ~/.jungle-grid/credentials.json via auth.ts.
|
|
196
|
+
*/
|
|
197
|
+
export declare function apiRequest<T>(method: string, urlPath: string, body?: unknown): Promise<T>;
|
|
198
|
+
/**
|
|
199
|
+
* Convenience: makes a GET request expecting a JSON response,
|
|
200
|
+
* but returns null on 202 (pending) instead of throwing.
|
|
201
|
+
* Used by the device-flow token polling loop.
|
|
202
|
+
*
|
|
203
|
+
* @param urlPath - Path relative to the API base URL.
|
|
204
|
+
* @returns Parsed response, or null if status is 202.
|
|
205
|
+
* @throws ApiError for non-2xx statuses other than 202.
|
|
206
|
+
*/
|
|
207
|
+
export declare function apiPoll<T>(urlPath: string): Promise<T | null>;
|
|
208
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,M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M,CAAC;CACd;AAID;;;GAGG;AACH,qBAAa,QAAS,SAAQ,KAAK;aAEf,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;gBADZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM;CAKlB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAAC,CAAC,CAAC,CAqCZ;AAED;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAgCnE"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* api.ts — Typed HTTP client for the Jungle Grid orchestrator REST API.
|
|
4
|
+
*
|
|
5
|
+
* Architecture role: Pillar 1 (Abstract GPU Selection) enforcement boundary.
|
|
6
|
+
* This module is the ONLY place the CLI makes HTTP requests to the orchestrator.
|
|
7
|
+
* All requests go through apiRequest(), which:
|
|
8
|
+
* - Injects the Bearer token from stored credentials (auth.ts)
|
|
9
|
+
* - Resolves the base URL from config (config.ts)
|
|
10
|
+
* - Returns typed responses matching the orchestrator's JSON envelope
|
|
11
|
+
*
|
|
12
|
+
* DISPLAY CONTRACT:
|
|
13
|
+
* - Job-oriented responses should stay workload-first and scheduling-focused.
|
|
14
|
+
* - Provider and marketplace node inspection may intentionally include full
|
|
15
|
+
* node capability data such as GPU type, VRAM, or CUDA support.
|
|
16
|
+
* - Secrets or node authentication material must never be modeled here.
|
|
17
|
+
*
|
|
18
|
+
* Upstream: Called by command handlers in index.ts.
|
|
19
|
+
* Downstream: Calls orchestrator REST API; reads token via auth.ts; reads
|
|
20
|
+
* API URL via config.ts.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.ApiError = void 0;
|
|
24
|
+
exports.apiRequest = apiRequest;
|
|
25
|
+
exports.apiPoll = apiPoll;
|
|
26
|
+
const config_1 = require("./config");
|
|
27
|
+
const auth_1 = require("./auth");
|
|
28
|
+
// ─── HTTP client ───────────────────────────────────────────────────────────
|
|
29
|
+
/**
|
|
30
|
+
* Error thrown when the API returns a non-2xx status.
|
|
31
|
+
* Carries the status code and parsed error body for display.
|
|
32
|
+
*/
|
|
33
|
+
class ApiError extends Error {
|
|
34
|
+
status;
|
|
35
|
+
code;
|
|
36
|
+
constructor(status, code, message) {
|
|
37
|
+
super(message);
|
|
38
|
+
this.status = status;
|
|
39
|
+
this.code = code;
|
|
40
|
+
this.name = "ApiError";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.ApiError = ApiError;
|
|
44
|
+
/**
|
|
45
|
+
* Makes an authenticated HTTP request to the orchestrator API.
|
|
46
|
+
*
|
|
47
|
+
* Automatically injects the Bearer token if the user is logged in.
|
|
48
|
+
* If no token is stored, the request is sent without auth (the server
|
|
49
|
+
* decides whether to allow unauthenticated access).
|
|
50
|
+
*
|
|
51
|
+
* @param method - HTTP method (GET, POST, etc.)
|
|
52
|
+
* @param urlPath - Path relative to the API base URL (e.g., "/v1/jobs")
|
|
53
|
+
* @param body - Optional request body; will be JSON-serialized.
|
|
54
|
+
* @returns Parsed JSON response body, typed as T.
|
|
55
|
+
* @throws ApiError if the server returns a non-2xx status.
|
|
56
|
+
*
|
|
57
|
+
* Side effects: Reads token from ~/.jungle-grid/credentials.json via auth.ts.
|
|
58
|
+
*/
|
|
59
|
+
async function apiRequest(method, urlPath, body) {
|
|
60
|
+
const baseUrl = (0, config_1.getApiUrl)();
|
|
61
|
+
const url = `${baseUrl}${urlPath}`;
|
|
62
|
+
// Build headers. Content-Type is always JSON for consistency.
|
|
63
|
+
const headers = {
|
|
64
|
+
"Content-Type": "application/json",
|
|
65
|
+
Accept: "application/json",
|
|
66
|
+
};
|
|
67
|
+
// Inject Bearer token if available. The token is read fresh on every
|
|
68
|
+
// request so that login/logout within the same process takes effect
|
|
69
|
+
// immediately without restarting.
|
|
70
|
+
const token = (0, auth_1.readToken)();
|
|
71
|
+
if (token) {
|
|
72
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
73
|
+
}
|
|
74
|
+
const response = await fetch(url, {
|
|
75
|
+
method,
|
|
76
|
+
headers,
|
|
77
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
78
|
+
});
|
|
79
|
+
// Parse response body. Even error responses are JSON from the orchestrator.
|
|
80
|
+
const data = await response.json();
|
|
81
|
+
if (!response.ok) {
|
|
82
|
+
const errBody = data?.error;
|
|
83
|
+
throw new ApiError(response.status, errBody?.code ?? "UNKNOWN", errBody?.message ?? `Request failed with status ${response.status}`);
|
|
84
|
+
}
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Convenience: makes a GET request expecting a JSON response,
|
|
89
|
+
* but returns null on 202 (pending) instead of throwing.
|
|
90
|
+
* Used by the device-flow token polling loop.
|
|
91
|
+
*
|
|
92
|
+
* @param urlPath - Path relative to the API base URL.
|
|
93
|
+
* @returns Parsed response, or null if status is 202.
|
|
94
|
+
* @throws ApiError for non-2xx statuses other than 202.
|
|
95
|
+
*/
|
|
96
|
+
async function apiPoll(urlPath) {
|
|
97
|
+
const baseUrl = (0, config_1.getApiUrl)();
|
|
98
|
+
const url = `${baseUrl}${urlPath}`;
|
|
99
|
+
const headers = {
|
|
100
|
+
Accept: "application/json",
|
|
101
|
+
};
|
|
102
|
+
const token = (0, auth_1.readToken)();
|
|
103
|
+
if (token) {
|
|
104
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
105
|
+
}
|
|
106
|
+
const response = await fetch(url, { method: "GET", headers });
|
|
107
|
+
// 202 means "still pending" in the device auth flow.
|
|
108
|
+
if (response.status === 202) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
const data = await response.json();
|
|
112
|
+
if (!response.ok) {
|
|
113
|
+
const errBody = data?.error;
|
|
114
|
+
throw new ApiError(response.status, errBody?.code ?? "UNKNOWN", errBody?.message ?? `Request failed with status ${response.status}`);
|
|
115
|
+
}
|
|
116
|
+
return data;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AA6MH,gCAyCC;AAWD,0BAgCC;AA/RD,qCAAqC;AACrC,iCAAmC;AA0KnC,8EAA8E;AAE9E;;;GAGG;AACH,MAAa,QAAS,SAAQ,KAAK;IAEf;IACA;IAFlB,YACkB,MAAc,EACd,IAAY,EAC5B,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAI5B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AATD,4BASC;AAED;;;;;;;;;;;;;;GAcG;AACI,KAAK,UAAU,UAAU,CAC9B,MAAc,EACd,OAAe,EACf,IAAc;IAEd,MAAM,OAAO,GAAG,IAAA,kBAAS,GAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,GAAG,OAAO,GAAG,OAAO,EAAE,CAAC;IAEnC,8DAA8D;IAC9D,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,kBAAkB;QAClC,MAAM,EAAE,kBAAkB;KAC3B,CAAC;IAEF,qEAAqE;IACrE,oEAAoE;IACpE,kCAAkC;IAClC,MAAM,KAAK,GAAG,IAAA,gBAAS,GAAE,CAAC;IAC1B,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,EAAE,CAAC;IAC/C,CA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AI,EAAE,CAAC;IAEnC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,OAAO,GAAG,IAAI,EAAE,KAAK,CAAC;QAC5B,MAAM,IAAI,QAAQ,CAChB,QAAQ,CAAC,MAAM,EACf,OAAO,EAAE,IAAI,IAAI,SAAS,EAC1B,OAAO,EAAE,OAAO,IAAI,8BAA8B,QAAQ,CAAC,MAAM,EAAE,CACpE,CAAC;IACJ,CAAC;IAED,OAAO,IAAS,CAAC;AACnB,CAAC"}
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* auth.ts — Token storage and retrieval for Jungle Grid CLI.
|
|
3
|
+
*
|
|
4
|
+
* Architecture role: Pillar 1 (Abstract GPU Selection) support module.
|
|
5
|
+
* This module manages the JWT token that authenticates CLI users against
|
|
6
|
+
* the orchestrator API. It reads/writes ~/.jungle-grid/credentials.json.
|
|
7
|
+
*
|
|
8
|
+
* SECURITY INVARIANTS:
|
|
9
|
+
* - The token is NEVER logged, printed, or included in error messages.
|
|
10
|
+
* - The credentials file is written with mode 0600 (owner-only read/write).
|
|
11
|
+
* - The token is a JWT signed server-side; the CLI treats it as opaque.
|
|
12
|
+
*
|
|
13
|
+
* Upstream: Called by api.ts (to read token for Bearer header) and
|
|
14
|
+
* index.ts login/logout commands (to write/clear token).
|
|
15
|
+
* Downstream: Reads/writes ~/.jungle-grid/credentials.json.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Shape of the credentials stored on disk.
|
|
19
|
+
* The token field is an opaque JWT — the CLI never decodes or validates it.
|
|
20
|
+
* The user fields are convenience copies for display (e.g., `jungle whoami`).
|
|
21
|
+
*/
|
|
22
|
+
export interface StoredCredentials {
|
|
23
|
+
/** JWT Bearer token issued by the orchestrator. Opaque to the CLI. */
|
|
24
|
+
token: string;
|
|
25
|
+
/** Basic user info returned alongside the token during login. */
|
|
26
|
+
user: {
|
|
27
|
+
id: string;
|
|
28
|
+
email: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Reads stored credentials from disk.
|
|
33
|
+
*
|
|
34
|
+
* @returns The stored credentials, or null if not logged in or file is corrupt.
|
|
35
|
+
* Never throws — a missing or malformed file simply means "not authenticated".
|
|
36
|
+
*/
|
|
37
|
+
export declare function readCredentials(): StoredCredentials | null;
|
|
38
|
+
/**
|
|
39
|
+
* Reads just the Bearer token from stored credentials.
|
|
40
|
+
* Convenience wrapper used by the API client.
|
|
41
|
+
*
|
|
42
|
+
* @returns The JWT token string, or null if not authenticated.
|
|
43
|
+
*/
|
|
44
|
+
export declare function readToken(): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Persists credentials to disk after a successful login.
|
|
47
|
+
*
|
|
48
|
+
* Creates the config directory if it doesn't exist.
|
|
49
|
+
* Writes with restrictive permissions to protect the token.
|
|
50
|
+
*
|
|
51
|
+
* @param credentials - The token and user info to store.
|
|
52
|
+
*
|
|
53
|
+
* Side effects: Creates ~/.jungle-grid/ directory if missing.
|
|
54
|
+
* Writes ~/.jungle-grid/credentials.json with mode 0600.
|
|
55
|
+
*/
|
|
56
|
+
export declare function writeCredentials(credentials: StoredCredentials): void;
|
|
57
|
+
/**
|
|
58
|
+
* Removes stored credentials (logout).
|
|
59
|
+
*
|
|
60
|
+
* Deletes the credentials file entirely rather than zeroing it,
|
|
61
|
+
* so readCredentials() returns null immediately after.
|
|
62
|
+
*
|
|
63
|
+
* Side effects: Deletes ~/.jungle-grid/credentials.json if it exists.
|
|
64
|
+
*/
|
|
65
|
+
export declare function clearCredentials(): void;
|
|
66
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAaH;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAWD;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,iBAAiB,GAAG,IAAI,CAkB1D;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,IAAI,CAGzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAerE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CASvC"}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* auth.ts — Token storage and retrieval for Jungle Grid CLI.
|
|
4
|
+
*
|
|
5
|
+
* Architecture role: Pillar 1 (Abstract GPU Selection) support module.
|
|
6
|
+
* This module manages the JWT token that authenticates CLI users against
|
|
7
|
+
* the orchestrator API. It reads/writes ~/.jungle-grid/credentials.json.
|
|
8
|
+
*
|
|
9
|
+
* SECURITY INVARIANTS:
|
|
10
|
+
* - The token is NEVER logged, printed, or included in error messages.
|
|
11
|
+
* - The credentials file is written with mode 0600 (owner-only read/write).
|
|
12
|
+
* - The token is a JWT signed server-side; the CLI treats it as opaque.
|
|
13
|
+
*
|
|
14
|
+
* Upstream: Called by api.ts (to read token for Bearer header) and
|
|
15
|
+
* index.ts login/logout commands (to write/clear token).
|
|
16
|
+
* Downstream: Reads/writes ~/.jungle-grid/credentials.json.
|
|
17
|
+
*/
|
|
18
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
21
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
23
|
+
}
|
|
24
|
+
Object.defineProperty(o, k2, desc);
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
30
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
31
|
+
}) : function(o, v) {
|
|
32
|
+
o["default"] = v;
|
|
33
|
+
});
|
|
34
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
35
|
+
var ownKeys = function(o) {
|
|
36
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
37
|
+
var ar = [];
|
|
38
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
39
|
+
return ar;
|
|
40
|
+
};
|
|
41
|
+
return ownKeys(o);
|
|
42
|
+
};
|
|
43
|
+
return function (mod) {
|
|
44
|
+
if (mod && mod.__esModule) return mod;
|
|
45
|
+
var result = {};
|
|
46
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
47
|
+
__setModuleDefault(result, mod);
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
})();
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.readCredentials = readCredentials;
|
|
53
|
+
exports.readToken = readToken;
|
|
54
|
+
exports.writeCredentials = writeCredentials;
|
|
55
|
+
exports.clearCredentials = clearCredentials;
|
|
56
|
+
const fs = __importStar(require("fs"));
|
|
57
|
+
const path = __importStar(require("path"));
|
|
58
|
+
const config_1 = require("./config");
|
|
59
|
+
/**
|
|
60
|
+
* Filename for stored credentials.
|
|
61
|
+
* Contains the JWT token and basic user info (email, id).
|
|
62
|
+
* Changing this name would break existing authenticated sessions.
|
|
63
|
+
*/
|
|
64
|
+
const CREDENTIALS_FILE = "credentials.json";
|
|
65
|
+
/**
|
|
66
|
+
* Returns the full path to the credentials file.
|
|
67
|
+
*
|
|
68
|
+
* @returns Absolute path to ~/.jungle-grid/credentials.json
|
|
69
|
+
*/
|
|
70
|
+
function credentialsPath() {
|
|
71
|
+
return path.join((0, config_1.getConfigDir)(), CREDENTIALS_FILE);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Reads stored credentials from disk.
|
|
75
|
+
*
|
|
76
|
+
* @returns The stored credentials, or null if not logged in or file is corrupt.
|
|
77
|
+
* Never throws — a missing or malformed file simply means "not authenticated".
|
|
78
|
+
*/
|
|
79
|
+
function readCredentials() {
|
|
80
|
+
try {
|
|
81
|
+
const filePath = credentialsPath();
|
|
82
|
+
if (!fs.existsSync(filePath)) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const raw = fs.readFileSync(filePath, "utf-8");
|
|
86
|
+
const parsed = JSON.parse(raw);
|
|
87
|
+
// Minimal validation — we need at least a token string to be useful.
|
|
88
|
+
if (!parsed.token || typeof parsed.token !== "string") {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return parsed;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Corrupt file — treat as not authenticated.
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Reads just the Bearer token from stored credentials.
|
|
100
|
+
* Convenience wrapper used by the API client.
|
|
101
|
+
*
|
|
102
|
+
* @returns The JWT token string, or null if not authenticated.
|
|
103
|
+
*/
|
|
104
|
+
function readToken() {
|
|
105
|
+
const creds = readCredentials();
|
|
106
|
+
return creds?.token ?? null;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Persists credentials to disk after a successful login.
|
|
110
|
+
*
|
|
111
|
+
* Creates the config directory if it doesn't exist.
|
|
112
|
+
* Writes with restrictive permissions to protect the token.
|
|
113
|
+
*
|
|
114
|
+
* @param credentials - The token and user info to store.
|
|
115
|
+
*
|
|
116
|
+
* Side effects: Creates ~/.jungle-grid/ directory if missing.
|
|
117
|
+
* Writes ~/.jungle-grid/credentials.json with mode 0600.
|
|
118
|
+
*/
|
|
119
|
+
function writeCredentials(credentials) {
|
|
120
|
+
const dir = (0, config_1.getConfigDir)();
|
|
121
|
+
// Ensure the config directory exists. The recursive flag is safe
|
|
122
|
+
// even if the directory already exists.
|
|
123
|
+
if (!fs.existsSync(dir)) {
|
|
124
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
125
|
+
}
|
|
126
|
+
const filePath = credentialsPath();
|
|
127
|
+
const content = JSON.stringify(credentials, null, 2) + "\n";
|
|
128
|
+
// Write with owner-only permissions. On Windows this is a no-op for the
|
|
129
|
+
// mode parameter, but we set it for correctness on Unix systems.
|
|
130
|
+
fs.writeFileSync(filePath, content, { mode: 0o600 });
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Removes stored credentials (logout).
|
|
134
|
+
*
|
|
135
|
+
* Deletes the credentials file entirely rather than zeroing it,
|
|
136
|
+
* so readCredentials() returns null immediately after.
|
|
137
|
+
*
|
|
138
|
+
* Side effects: Deletes ~/.jungle-grid/credentials.json if it exists.
|
|
139
|
+
*/
|
|
140
|
+
function clearCredentials() {
|
|
141
|
+
const filePath = credentialsPath();
|
|
142
|
+
try {
|
|
143
|
+
if (fs.existsSync(filePath)) {
|
|
144
|
+
fs.unlinkSync(filePath);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// If we can't delete, the file may already be gone. Not critical.
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;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AC,GAAG,CAAC,EAAE,CAAC;QACxB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;IAE5D,wEAAwE;IACxE,iEAAiE;IACjE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,IAAI,CAAC;QACH,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,kEAAkE;IACpE,CAAC;AACH,CAAC"}
|
package/dist/banner.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,wBAAgB,WAAW,CAAC,OAAO,SAAU,GAAG,IAAI,CAEnD"}
|
package/dist/banner.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* banner.ts - Shared banner output for the Jungle Grid CLI.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.printBanner = printBanner;
|
|
7
|
+
const ui_1 = require("./ui");
|
|
8
|
+
function printBanner(version = "0.1.0") {
|
|
9
|
+
process.stdout.write(`${(0, ui_1.renderBanner)(version)}\n`);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAIH,kCAEC;AAJD,6BAAoC;AAEpC,SAAgB,WAAW,CAAC,OAAO,GAAG,OAAO;IAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAA,iBAAY,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config.ts — CLI configuration loader for Jungle Grid.
|
|
3
|
+
*
|
|
4
|
+
* Architecture role: Pillar 1 (Abstract GPU Selection) support module.
|
|
5
|
+
* The CLI must know where the orchestrator API lives, but never what
|
|
6
|
+
* hardware sits behind it. This module resolves the API base URL from
|
|
7
|
+
* three sources in priority order:
|
|
8
|
+
* 1. JUNGLE_GRID_API environment variable (highest priority)
|
|
9
|
+
* 2. ~/.jungle-grid/config.json file
|
|
10
|
+
* 3. Built-in default (http://api.junglegrid.jaguarbuilds.dev:8080)
|
|
11
|
+
*
|
|
12
|
+
* Upstream: Called by api.ts to build request URLs.
|
|
13
|
+
* Downstream: Reads from filesystem (~/.jungle-grid/config.json).
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the orchestrator API base URL.
|
|
17
|
+
*
|
|
18
|
+
* Priority: JUNGLE_GRID_API env > config.json > default.
|
|
19
|
+
*
|
|
20
|
+
* @returns The API base URL string, never empty, never trailing-slashed.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getApiUrl(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the path to the Jungle Grid config directory.
|
|
25
|
+
* Used by auth.ts to know where to write credentials.
|
|
26
|
+
*
|
|
27
|
+
* @returns Absolute path to ~/.jungle-grid/
|
|
28
|
+
*/
|
|
29
|
+
export declare function getConfigDir(): string;
|
|
30
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAoCH;;;;;;GAMG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAyBlC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
|