@llmsafespaces/sdk 0.5.2 → 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.
@@ -0,0 +1,455 @@
1
+ /** SDK configuration options. */
2
+ type FetchFn = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
3
+ interface ClientOptions {
4
+ baseUrl: string;
5
+ apiKey?: string;
6
+ credentials?: {
7
+ email: string;
8
+ password: string;
9
+ };
10
+ timeout?: number;
11
+ fetch?: FetchFn;
12
+ }
13
+ /** Workspace resource. */
14
+ interface Workspace {
15
+ id: string;
16
+ name: string;
17
+ userId: string;
18
+ runtime: string;
19
+ storageSize: string;
20
+ phase: string;
21
+ pvcName?: string;
22
+ labels?: Record<string, string>;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ }
26
+ interface CreateWorkspaceRequest {
27
+ name?: string;
28
+ runtime?: string;
29
+ storageSize?: string;
30
+ storageClass?: string;
31
+ labels?: Record<string, string>;
32
+ }
33
+ interface WorkspaceListResult {
34
+ items: WorkspaceListItem[];
35
+ pagination?: PaginationMetadata;
36
+ }
37
+ interface WorkspaceListItem {
38
+ id: string;
39
+ name: string;
40
+ userId: string;
41
+ runtime: string;
42
+ storageSize: string;
43
+ phase?: string;
44
+ maxActiveSessions?: number;
45
+ createdAt: string;
46
+ updatedAt: string;
47
+ }
48
+ interface PaginationMetadata {
49
+ total: number;
50
+ start: number;
51
+ end: number;
52
+ limit: number;
53
+ offset: number;
54
+ }
55
+ interface WorkspaceStatusResult {
56
+ phase: string;
57
+ pvcName?: string;
58
+ activeSessions: number;
59
+ lastActivityAt?: string;
60
+ message?: string;
61
+ conditions?: WorkspaceCondition[];
62
+ credentialState: {
63
+ available: boolean;
64
+ reason?: string;
65
+ message?: string;
66
+ };
67
+ agentHealth: {
68
+ status: string;
69
+ providersConfigured: number;
70
+ agentVersion?: string;
71
+ };
72
+ sessions?: {
73
+ id: string;
74
+ title?: string;
75
+ status: string;
76
+ }[];
77
+ diskUsedBytes?: number;
78
+ diskTotalBytes?: number;
79
+ }
80
+ interface WorkspaceCondition {
81
+ type: string;
82
+ status: string;
83
+ reason?: string;
84
+ message?: string;
85
+ }
86
+ interface ActivateWorkspaceResponse {
87
+ resumed: string;
88
+ suspended?: string;
89
+ }
90
+ interface RefreshWorkspaceResult {
91
+ restartGeneration: number;
92
+ }
93
+ interface EnsureSessionResponse {
94
+ workspaceId: string;
95
+ workspacePhase: string;
96
+ sessionId: string;
97
+ resumed: boolean;
98
+ }
99
+ interface SessionListItem {
100
+ id: string;
101
+ title?: string;
102
+ lastMessageAt?: string;
103
+ messageCount: number;
104
+ status: string;
105
+ }
106
+ interface ActiveSessionsResponse {
107
+ active: string[];
108
+ maxActive: number;
109
+ }
110
+ /** Opencode message response (proxy passthrough). */
111
+ interface MessageResponse {
112
+ raw: unknown;
113
+ content: string;
114
+ }
115
+ interface AuthResponse {
116
+ token: string;
117
+ user: User;
118
+ }
119
+ interface User {
120
+ id: string;
121
+ username: string;
122
+ email: string;
123
+ createdAt: string;
124
+ updatedAt: string;
125
+ active: boolean;
126
+ role: string;
127
+ }
128
+ interface APIKey {
129
+ id: string;
130
+ name: string;
131
+ key?: string;
132
+ prefix: string;
133
+ active: boolean;
134
+ createdAt: string;
135
+ expiresAt?: string;
136
+ }
137
+ interface TerminalTicket {
138
+ ticket: string;
139
+ expiresAt: string;
140
+ }
141
+ interface SecretResponse {
142
+ id: string;
143
+ name: string;
144
+ type: string;
145
+ metadata?: unknown;
146
+ createdAt: string;
147
+ updatedAt: string;
148
+ }
149
+ /** Regex pattern for valid secret names. Keep in sync with pkg/validation/name.go. */
150
+ declare const SECRET_NAME_PATTERN: RegExp;
151
+ interface CreateSecretRequest {
152
+ /** Lowercase alphanumeric, dots, underscores, hyphens only. Must not start with dot or hyphen. */
153
+ name: string;
154
+ type: "api-key" | "ssh-key" | "git-credential" | "secret-file" | "env-secret";
155
+ value: string;
156
+ metadata?: unknown;
157
+ }
158
+ interface ProviderCredential {
159
+ id: string;
160
+ name: string;
161
+ kind: string;
162
+ slug: string;
163
+ baseURL?: string;
164
+ modelAllowlist?: string[];
165
+ modelContextLimits?: Record<string, number>;
166
+ modelOutputLimits?: Record<string, number>;
167
+ createdAt: string;
168
+ updatedAt: string;
169
+ }
170
+ interface CreateProviderCredentialRequest {
171
+ name: string;
172
+ kind: string;
173
+ slug: string;
174
+ apiKey: string;
175
+ baseURL?: string;
176
+ }
177
+ interface UpdateProviderCredentialRequest {
178
+ name?: string;
179
+ apiKey?: string;
180
+ baseURL?: string;
181
+ modelAllowlist?: string[];
182
+ modelContextLimits?: Record<string, number>;
183
+ modelOutputLimits?: Record<string, number>;
184
+ }
185
+ interface QueuedMessage {
186
+ id: string;
187
+ text: string;
188
+ session_id: string;
189
+ workspace_id: string;
190
+ enqueued_at: string;
191
+ retry_count: number;
192
+ }
193
+
194
+ declare class LLMSafeSpaces {
195
+ private readonly baseUrl;
196
+ private readonly timeout;
197
+ private readonly fetchFn;
198
+ private token;
199
+ private apiKey;
200
+ private credentials;
201
+ private loggingIn;
202
+ readonly workspaces: WorkspacesAPI;
203
+ readonly sessions: SessionsAPI;
204
+ readonly auth: AuthAPI;
205
+ readonly secrets: SecretsAPI;
206
+ readonly terminal: TerminalAPI;
207
+ readonly userSettings: UserSettingsAPI;
208
+ readonly account: AccountAPI;
209
+ readonly providerCredentials: ProviderCredentialsAPI;
210
+ readonly adminProviderCredentials: AdminProviderCredentialsAPI;
211
+ readonly usage: UsageAPI;
212
+ readonly inputRequests: InputRequestsAPI;
213
+ readonly probe: ProbeAPI;
214
+ readonly prompts: PromptsAPI;
215
+ readonly agentRoles: AgentRolesAPI;
216
+ constructor(options: ClientOptions);
217
+ /** Internal: make an authenticated request. */
218
+ request<T>(method: string, path: string, body?: unknown, timeout?: number): Promise<T>;
219
+ private login;
220
+ }
221
+ declare class WorkspacesAPI {
222
+ private client;
223
+ constructor(client: LLMSafeSpaces);
224
+ list(limit?: number, offset?: number): Promise<WorkspaceListResult>;
225
+ create(req: CreateWorkspaceRequest): Promise<Workspace>;
226
+ get(id: string): Promise<Workspace>;
227
+ rename(id: string, name: string): Promise<void>;
228
+ delete(id: string): Promise<void>;
229
+ getStatus(id: string): Promise<WorkspaceStatusResult>;
230
+ activate(id: string): Promise<ActivateWorkspaceResponse>;
231
+ suspend(id: string): Promise<void>;
232
+ restart(id: string): Promise<void>;
233
+ refreshCompute(id: string): Promise<RefreshWorkspaceResult>;
234
+ setBindings(id: string, secretIds: string[]): Promise<void>;
235
+ getBindings(id: string): Promise<{
236
+ bindings: Array<{
237
+ id: string;
238
+ name: string;
239
+ type: string;
240
+ }>;
241
+ }>;
242
+ reloadSecrets(id: string): Promise<{
243
+ reloaded: number;
244
+ restarted: boolean;
245
+ }>;
246
+ setModel(id: string, model: string): Promise<void>;
247
+ getModels(id: string): Promise<{
248
+ models: unknown[];
249
+ currentModel: string;
250
+ }>;
251
+ setEnv(id: string, env: Record<string, string>): Promise<void>;
252
+ getEnv(id: string): Promise<{
253
+ vars: string[];
254
+ }>;
255
+ deleteEnv(id: string, varName: string): Promise<void>;
256
+ }
257
+ declare class SessionsAPI {
258
+ private client;
259
+ constructor(client: LLMSafeSpaces);
260
+ ensure(workspaceId: string): Promise<EnsureSessionResponse>;
261
+ list(workspaceId: string): Promise<SessionListItem[]>;
262
+ getActive(workspaceId: string): Promise<ActiveSessionsResponse>;
263
+ rename(workspaceId: string, sessionId: string, title: string): Promise<void>;
264
+ sendMessage(workspaceId: string, sessionId: string, content: string): Promise<MessageResponse>;
265
+ getHistory(workspaceId: string, sessionId: string): Promise<unknown[]>;
266
+ abort(workspaceId: string, sessionId: string): Promise<void>;
267
+ get(workspaceId: string, sessionId: string): Promise<Record<string, unknown>>;
268
+ sendPromptAsync(workspaceId: string, sessionId: string, message: string): Promise<void>;
269
+ delete(workspaceId: string, sessionId: string): Promise<void>;
270
+ enqueue(workspaceId: string, sessionId: string, text: string): Promise<{
271
+ messageID: string;
272
+ }>;
273
+ listQueue(workspaceId: string, sessionId: string): Promise<{
274
+ messages: QueuedMessage[];
275
+ }>;
276
+ dismissQueued(workspaceId: string, sessionId: string, messageId: string): Promise<void>;
277
+ markSeen(workspaceId: string, sessionId: string): Promise<void>;
278
+ }
279
+ declare class AuthAPI {
280
+ private client;
281
+ constructor(client: LLMSafeSpaces);
282
+ me(): Promise<User>;
283
+ listApiKeys(): Promise<APIKey[]>;
284
+ createApiKey(name: string): Promise<APIKey>;
285
+ deleteApiKey(id: string): Promise<void>;
286
+ }
287
+ declare class SecretsAPI {
288
+ private client;
289
+ constructor(client: LLMSafeSpaces);
290
+ create(req: CreateSecretRequest): Promise<SecretResponse>;
291
+ list(): Promise<any>;
292
+ get(id: string): Promise<SecretResponse>;
293
+ update(id: string, value: string): Promise<void>;
294
+ delete(id: string): Promise<void>;
295
+ reveal(id: string, password: string): Promise<{
296
+ value: string;
297
+ }>;
298
+ getAuditLog(): Promise<{
299
+ entries: unknown[];
300
+ }>;
301
+ getBindingsForSecret(id: string): Promise<{
302
+ workspaces: string[];
303
+ }>;
304
+ }
305
+ declare class TerminalAPI {
306
+ private client;
307
+ constructor(client: LLMSafeSpaces);
308
+ getTicket(workspaceId: string): Promise<TerminalTicket>;
309
+ }
310
+ declare class UserSettingsAPI {
311
+ private client;
312
+ constructor(client: LLMSafeSpaces);
313
+ get(): Promise<{
314
+ settings: Record<string, unknown>;
315
+ schemaVersion: number;
316
+ }>;
317
+ getSchema(): Promise<{
318
+ settings: unknown[];
319
+ schemaVersion: number;
320
+ }>;
321
+ set(key: string, value: unknown): Promise<{
322
+ key: string;
323
+ value: unknown;
324
+ }>;
325
+ }
326
+ declare class AccountAPI {
327
+ private client;
328
+ constructor(client: LLMSafeSpaces);
329
+ rotateKey(password: string): Promise<{
330
+ keyVersion: number;
331
+ recoveryKey: string;
332
+ }>;
333
+ changePassword(oldPassword: string, newPassword: string): Promise<void>;
334
+ recover(userId: string, recoveryKey: string, newPassword: string): Promise<{
335
+ recoveryKey: string;
336
+ }>;
337
+ }
338
+ declare class ProviderCredentialsAPI {
339
+ private client;
340
+ constructor(client: LLMSafeSpaces);
341
+ create(req: CreateProviderCredentialRequest): Promise<ProviderCredential>;
342
+ list(): Promise<ProviderCredential[]>;
343
+ get(id: string): Promise<ProviderCredential>;
344
+ delete(id: string): Promise<void>;
345
+ probeModels(id: string): Promise<{
346
+ models: unknown[];
347
+ }>;
348
+ listBindings(id: string): Promise<string[]>;
349
+ bind(credId: string, workspaceId: string): Promise<unknown>;
350
+ unbind(credId: string, workspaceId: string): Promise<void>;
351
+ }
352
+ declare class AdminProviderCredentialsAPI {
353
+ private client;
354
+ constructor(client: LLMSafeSpaces);
355
+ list(): Promise<ProviderCredential[]>;
356
+ create(req: CreateProviderCredentialRequest): Promise<ProviderCredential>;
357
+ get(id: string): Promise<ProviderCredential>;
358
+ update(id: string, req: UpdateProviderCredentialRequest): Promise<ProviderCredential>;
359
+ delete(id: string): Promise<void>;
360
+ probeModels(id: string): Promise<{
361
+ models: unknown[];
362
+ }>;
363
+ createAutoApply(id: string, req: {
364
+ targetType: string;
365
+ targetId?: string;
366
+ withinPriority?: number;
367
+ }): Promise<unknown>;
368
+ listAutoApply(id: string): Promise<unknown[]>;
369
+ deleteAutoApply(id: string, targetType: string, targetId: string): Promise<void>;
370
+ }
371
+ declare class UsageAPI {
372
+ private client;
373
+ constructor(client: LLMSafeSpaces);
374
+ get(): Promise<Record<string, unknown>>;
375
+ getWorkspace(workspaceId: string): Promise<Record<string, unknown>>;
376
+ getQuota(): Promise<Record<string, unknown>>;
377
+ }
378
+ declare class InputRequestsAPI {
379
+ private client;
380
+ constructor(client: LLMSafeSpaces);
381
+ listQuestions(workspaceId: string): Promise<unknown[]>;
382
+ replyQuestion(workspaceId: string, requestId: string, body: Record<string, unknown>): Promise<void>;
383
+ rejectQuestion(workspaceId: string, requestId: string): Promise<void>;
384
+ listPermissions(workspaceId: string): Promise<unknown[]>;
385
+ replyPermission(workspaceId: string, requestId: string, body: Record<string, unknown>): Promise<void>;
386
+ }
387
+ declare class ProbeAPI {
388
+ private client;
389
+ constructor(client: LLMSafeSpaces);
390
+ probeModels(apiKey: string, baseURL: string): Promise<{
391
+ models: unknown[];
392
+ }>;
393
+ }
394
+ declare class PromptsAPI {
395
+ private client;
396
+ constructor(client: LLMSafeSpaces);
397
+ getPlatform(): Promise<{
398
+ prompt: string;
399
+ }>;
400
+ setPlatform(prompt: string): Promise<void>;
401
+ getOrg(orgId: string): Promise<{
402
+ prompt: string;
403
+ allowUserPrompt: boolean;
404
+ }>;
405
+ setOrg(orgId: string, body: {
406
+ prompt?: string;
407
+ allowUserPrompt?: boolean;
408
+ }): Promise<void>;
409
+ getWorkspace(workspaceId: string): Promise<{
410
+ prompt: string;
411
+ }>;
412
+ setWorkspace(workspaceId: string, prompt: string): Promise<void>;
413
+ }
414
+ declare class AgentRolesAPI {
415
+ private client;
416
+ constructor(client: LLMSafeSpaces);
417
+ listPlatform(): Promise<unknown[]>;
418
+ createPlatform(body: Record<string, unknown>): Promise<unknown>;
419
+ getPlatform(roleId: string): Promise<unknown>;
420
+ updatePlatform(roleId: string, body: Record<string, unknown>): Promise<unknown>;
421
+ deletePlatform(roleId: string): Promise<void>;
422
+ listOrg(orgId: string): Promise<unknown[]>;
423
+ createOrg(orgId: string, body: Record<string, unknown>): Promise<unknown>;
424
+ getOrg(orgId: string, roleId: string): Promise<unknown>;
425
+ updateOrg(orgId: string, roleId: string, body: Record<string, unknown>): Promise<unknown>;
426
+ deleteOrg(orgId: string, roleId: string): Promise<void>;
427
+ getWorkspaceRole(workspaceId: string): Promise<unknown>;
428
+ setWorkspaceRole(workspaceId: string, roleId: string): Promise<void>;
429
+ clearWorkspaceRole(workspaceId: string): Promise<void>;
430
+ getEffectiveWorkspaceRole(workspaceId: string): Promise<unknown>;
431
+ }
432
+
433
+ /** Base error for all LLMSafeSpaces API errors. */
434
+ declare class LLMSafeSpacesError extends Error {
435
+ readonly status: number;
436
+ readonly code?: string | undefined;
437
+ constructor(message: string, status: number, code?: string | undefined);
438
+ }
439
+ declare class AuthError extends LLMSafeSpacesError {
440
+ constructor(message: string, status?: number);
441
+ }
442
+ declare class NotFoundError extends LLMSafeSpacesError {
443
+ constructor(message: string);
444
+ }
445
+ declare class ConflictError extends LLMSafeSpacesError {
446
+ constructor(message: string);
447
+ }
448
+ declare class TimeoutError extends LLMSafeSpacesError {
449
+ constructor(message?: string);
450
+ }
451
+ declare class RateLimitError extends LLMSafeSpacesError {
452
+ constructor(message?: string);
453
+ }
454
+
455
+ export { type APIKey, type ActivateWorkspaceResponse, type ActiveSessionsResponse, AuthError, type AuthResponse, type ClientOptions, ConflictError, type CreateProviderCredentialRequest, type CreateSecretRequest, type CreateWorkspaceRequest, type EnsureSessionResponse, type FetchFn, LLMSafeSpaces, LLMSafeSpacesError, type MessageResponse, NotFoundError, type PaginationMetadata, type ProviderCredential, type QueuedMessage, RateLimitError, type RefreshWorkspaceResult, SECRET_NAME_PATTERN, type SecretResponse, type SessionListItem, type TerminalTicket, TimeoutError, type UpdateProviderCredentialRequest, type User, type Workspace, type WorkspaceCondition, type WorkspaceListItem, type WorkspaceListResult, type WorkspaceStatusResult };