shiva-code 0.5.1 → 0.5.3
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/chunk-EGRMFBG6.js +472 -0
- package/dist/chunk-OP4HYQZZ.js +163 -0
- package/dist/client-Z6ZMO5QE.js +8 -0
- package/dist/config-FGMZONWV.js +49 -0
- package/dist/index.js +612 -1036
- package/package.json +1 -1
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getApiEndpoint,
|
|
3
|
+
getToken
|
|
4
|
+
} from "./chunk-OP4HYQZZ.js";
|
|
5
|
+
|
|
6
|
+
// src/services/api/client.ts
|
|
7
|
+
var ApiClient = class {
|
|
8
|
+
getHeaders() {
|
|
9
|
+
const headers = {
|
|
10
|
+
"Content-Type": "application/json"
|
|
11
|
+
};
|
|
12
|
+
const token = getToken();
|
|
13
|
+
if (token) {
|
|
14
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
15
|
+
}
|
|
16
|
+
return headers;
|
|
17
|
+
}
|
|
18
|
+
async request(endpoint, options = {}) {
|
|
19
|
+
const baseUrl = getApiEndpoint();
|
|
20
|
+
const url = `${baseUrl}${endpoint}`;
|
|
21
|
+
const response = await fetch(url, {
|
|
22
|
+
...options,
|
|
23
|
+
headers: {
|
|
24
|
+
...this.getHeaders(),
|
|
25
|
+
...options.headers
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
30
|
+
throw new Error(error.error || error.message || `HTTP ${response.status}`);
|
|
31
|
+
}
|
|
32
|
+
return response.json();
|
|
33
|
+
}
|
|
34
|
+
// Auth endpoints
|
|
35
|
+
async requestOtp(email) {
|
|
36
|
+
return this.request("/auth/otp/request", {
|
|
37
|
+
method: "POST",
|
|
38
|
+
body: JSON.stringify({ email })
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async verifyOtp(token, otp) {
|
|
42
|
+
return this.request("/auth/otp/verify", {
|
|
43
|
+
method: "POST",
|
|
44
|
+
body: JSON.stringify({ token, otp })
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async getCurrentUser() {
|
|
48
|
+
return this.request("/auth/me");
|
|
49
|
+
}
|
|
50
|
+
// Project endpoints
|
|
51
|
+
async getProjects() {
|
|
52
|
+
return this.request("/projects");
|
|
53
|
+
}
|
|
54
|
+
async getProject(id) {
|
|
55
|
+
return this.request(`/projects/${id}`);
|
|
56
|
+
}
|
|
57
|
+
async createOrUpdateProject(data) {
|
|
58
|
+
return this.request("/projects", {
|
|
59
|
+
method: "POST",
|
|
60
|
+
body: JSON.stringify(data)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async syncProject(id, data) {
|
|
64
|
+
return this.request(`/projects/${id}/sync`, {
|
|
65
|
+
method: "POST",
|
|
66
|
+
body: JSON.stringify(data)
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async deleteProject(id) {
|
|
70
|
+
return this.request(`/projects/${id}`, {
|
|
71
|
+
method: "DELETE"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async addMemory(projectId, memory) {
|
|
75
|
+
return this.request(`/projects/${projectId}/memories`, {
|
|
76
|
+
method: "POST",
|
|
77
|
+
body: JSON.stringify(memory)
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async deleteMemory(projectId, memoryId) {
|
|
81
|
+
return this.request(`/projects/${projectId}/memories/${memoryId}`, {
|
|
82
|
+
method: "DELETE"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async connectProjects(projectA, projectB, connectionType) {
|
|
86
|
+
return this.request("/projects/connect", {
|
|
87
|
+
method: "POST",
|
|
88
|
+
body: JSON.stringify({
|
|
89
|
+
projectA,
|
|
90
|
+
projectB,
|
|
91
|
+
connectionType: connectionType || "related"
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async disconnectProjects(projectA, projectB) {
|
|
96
|
+
return this.request("/projects/disconnect", {
|
|
97
|
+
method: "DELETE",
|
|
98
|
+
body: JSON.stringify({ projectA, projectB })
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async getStats() {
|
|
102
|
+
return this.request("/projects/stats");
|
|
103
|
+
}
|
|
104
|
+
// Find project by path
|
|
105
|
+
async findProjectByPath(path) {
|
|
106
|
+
const projects = await this.getProjects();
|
|
107
|
+
return projects.find((p) => p.path === path) || null;
|
|
108
|
+
}
|
|
109
|
+
// ============================================
|
|
110
|
+
// Secrets Vault Endpoints
|
|
111
|
+
// ============================================
|
|
112
|
+
/**
|
|
113
|
+
* List all secrets (metadata only, no values)
|
|
114
|
+
*/
|
|
115
|
+
async listSecrets(projectId) {
|
|
116
|
+
const params = projectId ? `?projectId=${projectId}` : "";
|
|
117
|
+
return this.request(`/secrets${params}`);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Add a new secret
|
|
121
|
+
*/
|
|
122
|
+
async addSecret(data) {
|
|
123
|
+
return this.request("/secrets", {
|
|
124
|
+
method: "POST",
|
|
125
|
+
body: JSON.stringify(data)
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get a secret value (decrypted)
|
|
130
|
+
*/
|
|
131
|
+
async getSecret(key, projectId) {
|
|
132
|
+
const params = projectId ? `?projectId=${projectId}` : "";
|
|
133
|
+
return this.request(`/secrets/${encodeURIComponent(key)}${params}`);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Delete a secret
|
|
137
|
+
*/
|
|
138
|
+
async deleteSecret(key, projectId) {
|
|
139
|
+
const params = projectId ? `?projectId=${projectId}` : "";
|
|
140
|
+
return this.request(`/secrets/${encodeURIComponent(key)}${params}`, {
|
|
141
|
+
method: "DELETE"
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get all secrets for injection (decrypted values)
|
|
146
|
+
* Used by session start hook
|
|
147
|
+
*/
|
|
148
|
+
async getSecretsForInjection(projectId) {
|
|
149
|
+
const params = projectId ? `?projectId=${projectId}` : "";
|
|
150
|
+
return this.request(`/secrets/inject${params}`);
|
|
151
|
+
}
|
|
152
|
+
// ============================================
|
|
153
|
+
// Settings Sync Endpoints (Phase 10)
|
|
154
|
+
// Pfad: /api/settings (nicht /api/user/settings)
|
|
155
|
+
// ============================================
|
|
156
|
+
/**
|
|
157
|
+
* Get current user settings from cloud
|
|
158
|
+
*/
|
|
159
|
+
async getUserSettings() {
|
|
160
|
+
return this.request("/settings");
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Update user settings in cloud
|
|
164
|
+
*/
|
|
165
|
+
async updateUserSettings(data) {
|
|
166
|
+
return this.request("/settings", {
|
|
167
|
+
method: "PUT",
|
|
168
|
+
body: JSON.stringify(data)
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Sync settings with conflict detection
|
|
173
|
+
*/
|
|
174
|
+
async syncUserSettings(data) {
|
|
175
|
+
return this.request("/settings/sync", {
|
|
176
|
+
method: "POST",
|
|
177
|
+
body: JSON.stringify(data)
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get settings change history
|
|
182
|
+
*/
|
|
183
|
+
async getSettingsHistory() {
|
|
184
|
+
return this.request("/settings/history");
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Export settings
|
|
188
|
+
*/
|
|
189
|
+
async exportSettings() {
|
|
190
|
+
return this.request("/settings/export");
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Import settings
|
|
194
|
+
*/
|
|
195
|
+
async importSettings(data) {
|
|
196
|
+
return this.request("/settings/import", {
|
|
197
|
+
method: "POST",
|
|
198
|
+
body: JSON.stringify(data)
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
// ============================================
|
|
202
|
+
// Dashboard/Analytics Endpoints (Phase 12)
|
|
203
|
+
// Pfad: /api/analytics (nicht /api/dashboard)
|
|
204
|
+
// ============================================
|
|
205
|
+
/**
|
|
206
|
+
* Get dashboard overview data (Pro Feature)
|
|
207
|
+
*/
|
|
208
|
+
async getDashboardOverview() {
|
|
209
|
+
return this.request("/analytics/overview");
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Get usage statistics (Pro Feature)
|
|
213
|
+
*/
|
|
214
|
+
async getUsageStats() {
|
|
215
|
+
return this.request("/analytics/usage");
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get project analytics (Pro Feature)
|
|
219
|
+
*/
|
|
220
|
+
async getProjectAnalytics() {
|
|
221
|
+
return this.request("/analytics/projects");
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Get activity feed (Pro Feature)
|
|
225
|
+
*/
|
|
226
|
+
async getActivityFeed() {
|
|
227
|
+
return this.request("/analytics/activity");
|
|
228
|
+
}
|
|
229
|
+
// Legacy aliases for backwards compatibility
|
|
230
|
+
async getDashboardProjects() {
|
|
231
|
+
return this.getProjectAnalytics();
|
|
232
|
+
}
|
|
233
|
+
async getDashboardAnalytics(days) {
|
|
234
|
+
return this.getUsageStats();
|
|
235
|
+
}
|
|
236
|
+
// ============================================
|
|
237
|
+
// Sessions Endpoints (Cloud-synced sessions)
|
|
238
|
+
// ============================================
|
|
239
|
+
/**
|
|
240
|
+
* Get all sessions from cloud
|
|
241
|
+
*/
|
|
242
|
+
async getSessions() {
|
|
243
|
+
return this.request("/sessions");
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Sync a session to cloud
|
|
247
|
+
*/
|
|
248
|
+
async syncSession(data) {
|
|
249
|
+
return this.request("/sessions", {
|
|
250
|
+
method: "POST",
|
|
251
|
+
body: JSON.stringify(data)
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Get a specific session from cloud
|
|
256
|
+
*/
|
|
257
|
+
async getSession(sessionId) {
|
|
258
|
+
return this.request(`/sessions/${sessionId}`);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Delete a session from cloud
|
|
262
|
+
*/
|
|
263
|
+
async deleteSession(sessionId) {
|
|
264
|
+
return this.request(`/sessions/${sessionId}`, {
|
|
265
|
+
method: "DELETE"
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
// ============================================
|
|
269
|
+
// Memories Endpoints (standalone)
|
|
270
|
+
// ============================================
|
|
271
|
+
/**
|
|
272
|
+
* Get all memories across projects
|
|
273
|
+
*/
|
|
274
|
+
async getAllMemories() {
|
|
275
|
+
return this.request("/memories");
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Search memories
|
|
279
|
+
*/
|
|
280
|
+
async searchMemories(query) {
|
|
281
|
+
return this.request(`/memories/search?q=${encodeURIComponent(query)}`);
|
|
282
|
+
}
|
|
283
|
+
// ============================================
|
|
284
|
+
// Hooks Endpoints (Cloud-managed hooks)
|
|
285
|
+
// ============================================
|
|
286
|
+
/**
|
|
287
|
+
* Get hook configuration from cloud
|
|
288
|
+
*/
|
|
289
|
+
async getHooks() {
|
|
290
|
+
return this.request("/hooks");
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Update hook configuration
|
|
294
|
+
*/
|
|
295
|
+
async updateHooks(hooks) {
|
|
296
|
+
return this.request("/hooks", {
|
|
297
|
+
method: "PUT",
|
|
298
|
+
body: JSON.stringify({ hooks })
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
// ============================================
|
|
302
|
+
// Two-Factor Authentication Endpoints (Phase 15)
|
|
303
|
+
// ============================================
|
|
304
|
+
/**
|
|
305
|
+
* Initialize 2FA setup
|
|
306
|
+
*/
|
|
307
|
+
async setup2FA() {
|
|
308
|
+
return this.request("/auth/2fa/setup", {
|
|
309
|
+
method: "POST"
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Verify 2FA setup with code
|
|
314
|
+
*/
|
|
315
|
+
async verify2FA(code) {
|
|
316
|
+
return this.request("/auth/2fa/verify", {
|
|
317
|
+
method: "POST",
|
|
318
|
+
body: JSON.stringify({ code })
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Verify 2FA code during login
|
|
323
|
+
*/
|
|
324
|
+
async verify2FACode(code) {
|
|
325
|
+
return this.request("/auth/2fa/check", {
|
|
326
|
+
method: "POST",
|
|
327
|
+
body: JSON.stringify({ code })
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Verify backup code
|
|
332
|
+
*/
|
|
333
|
+
async verifyBackupCode(code) {
|
|
334
|
+
return this.request("/auth/2fa/backup", {
|
|
335
|
+
method: "POST",
|
|
336
|
+
body: JSON.stringify({ code })
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Get 2FA status
|
|
341
|
+
*/
|
|
342
|
+
async get2FAStatus() {
|
|
343
|
+
return this.request("/auth/2fa/status");
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Disable 2FA
|
|
347
|
+
*/
|
|
348
|
+
async disable2FA(code) {
|
|
349
|
+
return this.request("/auth/2fa", {
|
|
350
|
+
method: "DELETE",
|
|
351
|
+
body: JSON.stringify({ code })
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Regenerate backup codes
|
|
356
|
+
*/
|
|
357
|
+
async regenerateBackupCodes() {
|
|
358
|
+
return this.request("/auth/2fa/backup-codes", {
|
|
359
|
+
method: "POST"
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
// ============================================
|
|
363
|
+
// Trusted Devices Endpoints (Phase 15)
|
|
364
|
+
// ============================================
|
|
365
|
+
/**
|
|
366
|
+
* Get all trusted devices
|
|
367
|
+
*/
|
|
368
|
+
async getDevices() {
|
|
369
|
+
return this.request("/auth/devices");
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Trust a device
|
|
373
|
+
*/
|
|
374
|
+
async trustDevice(data) {
|
|
375
|
+
return this.request("/auth/devices", {
|
|
376
|
+
method: "POST",
|
|
377
|
+
body: JSON.stringify(data)
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Revoke a device
|
|
382
|
+
*/
|
|
383
|
+
async revokeDevice(deviceId) {
|
|
384
|
+
return this.request(`/auth/devices/${deviceId}`, {
|
|
385
|
+
method: "DELETE"
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Revoke all devices
|
|
390
|
+
*/
|
|
391
|
+
async revokeAllDevices() {
|
|
392
|
+
return this.request("/auth/devices/all", {
|
|
393
|
+
method: "DELETE"
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
// ============================================
|
|
397
|
+
// Project Security Endpoints (Phase 15)
|
|
398
|
+
// ============================================
|
|
399
|
+
/**
|
|
400
|
+
* Get project security config
|
|
401
|
+
*/
|
|
402
|
+
async getProjectSecurity(projectId) {
|
|
403
|
+
return this.request(`/projects/${projectId}/security`);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Update project security config
|
|
407
|
+
*/
|
|
408
|
+
async updateProjectSecurity(projectId, security) {
|
|
409
|
+
return this.request(`/projects/${projectId}/security`, {
|
|
410
|
+
method: "PUT",
|
|
411
|
+
body: JSON.stringify({ security })
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
// ============================================
|
|
415
|
+
// Project Team/Collaborators Endpoints (Phase 15)
|
|
416
|
+
// ============================================
|
|
417
|
+
/**
|
|
418
|
+
* Get project team
|
|
419
|
+
*/
|
|
420
|
+
async getProjectTeam(projectId) {
|
|
421
|
+
return this.request(`/projects/${projectId}/team`);
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Add collaborator
|
|
425
|
+
*/
|
|
426
|
+
async addCollaborator(projectId, email, role) {
|
|
427
|
+
return this.request(`/projects/${projectId}/team`, {
|
|
428
|
+
method: "POST",
|
|
429
|
+
body: JSON.stringify({ email, role })
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Remove collaborator
|
|
434
|
+
*/
|
|
435
|
+
async removeCollaborator(projectId, userId) {
|
|
436
|
+
return this.request(`/projects/${projectId}/team/${userId}`, {
|
|
437
|
+
method: "DELETE"
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Update collaborator role
|
|
442
|
+
*/
|
|
443
|
+
async updateCollaboratorRole(projectId, userId, role) {
|
|
444
|
+
return this.request(`/projects/${projectId}/team/${userId}`, {
|
|
445
|
+
method: "PATCH",
|
|
446
|
+
body: JSON.stringify({ role })
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Send project invitation
|
|
451
|
+
*/
|
|
452
|
+
async sendProjectInvite(projectId, email, role) {
|
|
453
|
+
return this.request(`/projects/${projectId}/invite`, {
|
|
454
|
+
method: "POST",
|
|
455
|
+
body: JSON.stringify({ email, role })
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Transfer project ownership
|
|
460
|
+
*/
|
|
461
|
+
async transferProjectOwnership(projectId, newOwnerEmail) {
|
|
462
|
+
return this.request(`/projects/${projectId}/transfer`, {
|
|
463
|
+
method: "POST",
|
|
464
|
+
body: JSON.stringify({ email: newOwnerEmail })
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
var api = new ApiClient();
|
|
469
|
+
|
|
470
|
+
export {
|
|
471
|
+
api
|
|
472
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// src/utils/config.ts
|
|
2
|
+
import Conf from "conf";
|
|
3
|
+
import * as os from "os";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
var DEFAULT_API_ENDPOINT = "https://shiva.li/api";
|
|
6
|
+
var OLD_API_ENDPOINTS = [
|
|
7
|
+
"https://shiva-ai-api.slither-mutiplayer.workers.dev/api",
|
|
8
|
+
"https://shiva-ai-api.slither-multiplayer.workers.dev/api"
|
|
9
|
+
];
|
|
10
|
+
var DEFAULT_CLAUDE_PROJECTS_PATH = path.join(os.homedir(), ".claude", "projects");
|
|
11
|
+
var config = new Conf({
|
|
12
|
+
projectName: "shiva-code",
|
|
13
|
+
defaults: {
|
|
14
|
+
apiEndpoint: DEFAULT_API_ENDPOINT,
|
|
15
|
+
token: null,
|
|
16
|
+
tokenExpiry: null,
|
|
17
|
+
userId: null,
|
|
18
|
+
email: null,
|
|
19
|
+
tier: null,
|
|
20
|
+
// Control Station defaults
|
|
21
|
+
packages: {},
|
|
22
|
+
defaultTerminal: "auto",
|
|
23
|
+
claudeProjectsPath: DEFAULT_CLAUDE_PROJECTS_PATH,
|
|
24
|
+
// Claude Code launch settings
|
|
25
|
+
claudeArgs: [],
|
|
26
|
+
claudeSkipPermissions: true
|
|
27
|
+
// Default: skip permissions for smoother workflow
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
function getConfig() {
|
|
31
|
+
return {
|
|
32
|
+
apiEndpoint: config.get("apiEndpoint"),
|
|
33
|
+
token: config.get("token"),
|
|
34
|
+
tokenExpiry: config.get("tokenExpiry"),
|
|
35
|
+
userId: config.get("userId"),
|
|
36
|
+
email: config.get("email"),
|
|
37
|
+
tier: config.get("tier")
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function setConfig(key, value) {
|
|
41
|
+
config.set(key, value);
|
|
42
|
+
}
|
|
43
|
+
function getToken() {
|
|
44
|
+
const token = config.get("token");
|
|
45
|
+
const expiry = config.get("tokenExpiry");
|
|
46
|
+
if (token && expiry && Date.now() > expiry) {
|
|
47
|
+
clearAuth();
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return token;
|
|
51
|
+
}
|
|
52
|
+
function setAuth(token, user) {
|
|
53
|
+
let expiry;
|
|
54
|
+
try {
|
|
55
|
+
const payload = JSON.parse(atob(token.includes(".") ? token.split(".")[1] : token));
|
|
56
|
+
expiry = payload.exp > 1e12 ? payload.exp : payload.exp * 1e3;
|
|
57
|
+
} catch {
|
|
58
|
+
expiry = Date.now() + 7 * 24 * 60 * 60 * 1e3;
|
|
59
|
+
}
|
|
60
|
+
config.set("token", token);
|
|
61
|
+
config.set("tokenExpiry", expiry);
|
|
62
|
+
config.set("userId", user.id);
|
|
63
|
+
config.set("email", user.email);
|
|
64
|
+
config.set("tier", user.tier);
|
|
65
|
+
}
|
|
66
|
+
function clearAuth() {
|
|
67
|
+
config.set("token", null);
|
|
68
|
+
config.set("tokenExpiry", null);
|
|
69
|
+
config.set("userId", null);
|
|
70
|
+
config.set("email", null);
|
|
71
|
+
config.set("tier", null);
|
|
72
|
+
}
|
|
73
|
+
function isAuthenticated() {
|
|
74
|
+
return getToken() !== null;
|
|
75
|
+
}
|
|
76
|
+
function getApiEndpoint() {
|
|
77
|
+
return config.get("apiEndpoint");
|
|
78
|
+
}
|
|
79
|
+
function setApiEndpoint(endpoint) {
|
|
80
|
+
config.set("apiEndpoint", endpoint);
|
|
81
|
+
}
|
|
82
|
+
function getConfigPath() {
|
|
83
|
+
return config.path;
|
|
84
|
+
}
|
|
85
|
+
var CONFIG_PATH = config.path;
|
|
86
|
+
function clearConfig() {
|
|
87
|
+
config.clear();
|
|
88
|
+
config.set("apiEndpoint", DEFAULT_API_ENDPOINT);
|
|
89
|
+
}
|
|
90
|
+
function getExtendedConfig() {
|
|
91
|
+
return {
|
|
92
|
+
...getConfig(),
|
|
93
|
+
packages: config.get("packages") || {},
|
|
94
|
+
defaultTerminal: config.get("defaultTerminal") || "auto",
|
|
95
|
+
claudeProjectsPath: config.get("claudeProjectsPath") || DEFAULT_CLAUDE_PROJECTS_PATH,
|
|
96
|
+
claudeArgs: config.get("claudeArgs") || [],
|
|
97
|
+
claudeSkipPermissions: config.get("claudeSkipPermissions") ?? true
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function getDefaultTerminal() {
|
|
101
|
+
return config.get("defaultTerminal") || "auto";
|
|
102
|
+
}
|
|
103
|
+
function setDefaultTerminal(terminal) {
|
|
104
|
+
config.set("defaultTerminal", terminal);
|
|
105
|
+
}
|
|
106
|
+
function getClaudeProjectsPath() {
|
|
107
|
+
return config.get("claudeProjectsPath") || DEFAULT_CLAUDE_PROJECTS_PATH;
|
|
108
|
+
}
|
|
109
|
+
function setClaudeProjectsPath(path2) {
|
|
110
|
+
config.set("claudeProjectsPath", path2);
|
|
111
|
+
}
|
|
112
|
+
function getClaudeSkipPermissions() {
|
|
113
|
+
return config.get("claudeSkipPermissions") ?? true;
|
|
114
|
+
}
|
|
115
|
+
function setClaudeSkipPermissions(skip) {
|
|
116
|
+
config.set("claudeSkipPermissions", skip);
|
|
117
|
+
}
|
|
118
|
+
function getClaudeArgs() {
|
|
119
|
+
return config.get("claudeArgs") || [];
|
|
120
|
+
}
|
|
121
|
+
function setClaudeArgs(args) {
|
|
122
|
+
config.set("claudeArgs", args);
|
|
123
|
+
}
|
|
124
|
+
function getClaudeLaunchArgs() {
|
|
125
|
+
const args = [];
|
|
126
|
+
if (config.get("claudeSkipPermissions") ?? true) {
|
|
127
|
+
args.push("--dangerously-skip-permissions");
|
|
128
|
+
}
|
|
129
|
+
const customArgs = config.get("claudeArgs") || [];
|
|
130
|
+
args.push(...customArgs);
|
|
131
|
+
return args;
|
|
132
|
+
}
|
|
133
|
+
function migrateConfig() {
|
|
134
|
+
const currentEndpoint = config.get("apiEndpoint");
|
|
135
|
+
if (currentEndpoint && OLD_API_ENDPOINTS.includes(currentEndpoint)) {
|
|
136
|
+
config.set("apiEndpoint", DEFAULT_API_ENDPOINT);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
getConfig,
|
|
142
|
+
setConfig,
|
|
143
|
+
getToken,
|
|
144
|
+
setAuth,
|
|
145
|
+
clearAuth,
|
|
146
|
+
isAuthenticated,
|
|
147
|
+
getApiEndpoint,
|
|
148
|
+
setApiEndpoint,
|
|
149
|
+
getConfigPath,
|
|
150
|
+
CONFIG_PATH,
|
|
151
|
+
clearConfig,
|
|
152
|
+
getExtendedConfig,
|
|
153
|
+
getDefaultTerminal,
|
|
154
|
+
setDefaultTerminal,
|
|
155
|
+
getClaudeProjectsPath,
|
|
156
|
+
setClaudeProjectsPath,
|
|
157
|
+
getClaudeSkipPermissions,
|
|
158
|
+
setClaudeSkipPermissions,
|
|
159
|
+
getClaudeArgs,
|
|
160
|
+
setClaudeArgs,
|
|
161
|
+
getClaudeLaunchArgs,
|
|
162
|
+
migrateConfig
|
|
163
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CONFIG_PATH,
|
|
3
|
+
clearAuth,
|
|
4
|
+
clearConfig,
|
|
5
|
+
getApiEndpoint,
|
|
6
|
+
getClaudeArgs,
|
|
7
|
+
getClaudeLaunchArgs,
|
|
8
|
+
getClaudeProjectsPath,
|
|
9
|
+
getClaudeSkipPermissions,
|
|
10
|
+
getConfig,
|
|
11
|
+
getConfigPath,
|
|
12
|
+
getDefaultTerminal,
|
|
13
|
+
getExtendedConfig,
|
|
14
|
+
getToken,
|
|
15
|
+
isAuthenticated,
|
|
16
|
+
migrateConfig,
|
|
17
|
+
setApiEndpoint,
|
|
18
|
+
setAuth,
|
|
19
|
+
setClaudeArgs,
|
|
20
|
+
setClaudeProjectsPath,
|
|
21
|
+
setClaudeSkipPermissions,
|
|
22
|
+
setConfig,
|
|
23
|
+
setDefaultTerminal
|
|
24
|
+
} from "./chunk-OP4HYQZZ.js";
|
|
25
|
+
import "./chunk-3RG5ZIWI.js";
|
|
26
|
+
export {
|
|
27
|
+
CONFIG_PATH,
|
|
28
|
+
clearAuth,
|
|
29
|
+
clearConfig,
|
|
30
|
+
getApiEndpoint,
|
|
31
|
+
getClaudeArgs,
|
|
32
|
+
getClaudeLaunchArgs,
|
|
33
|
+
getClaudeProjectsPath,
|
|
34
|
+
getClaudeSkipPermissions,
|
|
35
|
+
getConfig,
|
|
36
|
+
getConfigPath,
|
|
37
|
+
getDefaultTerminal,
|
|
38
|
+
getExtendedConfig,
|
|
39
|
+
getToken,
|
|
40
|
+
isAuthenticated,
|
|
41
|
+
migrateConfig,
|
|
42
|
+
setApiEndpoint,
|
|
43
|
+
setAuth,
|
|
44
|
+
setClaudeArgs,
|
|
45
|
+
setClaudeProjectsPath,
|
|
46
|
+
setClaudeSkipPermissions,
|
|
47
|
+
setConfig,
|
|
48
|
+
setDefaultTerminal
|
|
49
|
+
};
|