@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.
- package/dist/index.cjs +602 -0
- package/dist/index.d.cts +455 -0
- package/dist/index.d.ts +455 -0
- package/dist/index.js +568 -0
- package/package.json +1 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,602 @@
|
|
|
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
|
+
AuthError: () => AuthError,
|
|
24
|
+
ConflictError: () => ConflictError,
|
|
25
|
+
LLMSafeSpaces: () => LLMSafeSpaces,
|
|
26
|
+
LLMSafeSpacesError: () => LLMSafeSpacesError,
|
|
27
|
+
NotFoundError: () => NotFoundError,
|
|
28
|
+
RateLimitError: () => RateLimitError,
|
|
29
|
+
SECRET_NAME_PATTERN: () => SECRET_NAME_PATTERN,
|
|
30
|
+
TimeoutError: () => TimeoutError
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(index_exports);
|
|
33
|
+
|
|
34
|
+
// src/errors.ts
|
|
35
|
+
var LLMSafeSpacesError = class extends Error {
|
|
36
|
+
constructor(message, status, code) {
|
|
37
|
+
super(message);
|
|
38
|
+
this.status = status;
|
|
39
|
+
this.code = code;
|
|
40
|
+
this.name = "LLMSafeSpacesError";
|
|
41
|
+
}
|
|
42
|
+
status;
|
|
43
|
+
code;
|
|
44
|
+
};
|
|
45
|
+
var AuthError = class extends LLMSafeSpacesError {
|
|
46
|
+
constructor(message, status = 401) {
|
|
47
|
+
super(message, status, "AUTH_ERROR");
|
|
48
|
+
this.name = "AuthError";
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var NotFoundError = class extends LLMSafeSpacesError {
|
|
52
|
+
constructor(message) {
|
|
53
|
+
super(message, 404, "NOT_FOUND");
|
|
54
|
+
this.name = "NotFoundError";
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var ConflictError = class extends LLMSafeSpacesError {
|
|
58
|
+
constructor(message) {
|
|
59
|
+
super(message, 409, "CONFLICT");
|
|
60
|
+
this.name = "ConflictError";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var TimeoutError = class extends LLMSafeSpacesError {
|
|
64
|
+
constructor(message = "Request timed out \u2014 the prompt may still be processing") {
|
|
65
|
+
super(message, 0, "TIMEOUT");
|
|
66
|
+
this.name = "TimeoutError";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var RateLimitError = class extends LLMSafeSpacesError {
|
|
70
|
+
constructor(message = "Rate limit exceeded") {
|
|
71
|
+
super(message, 429, "RATE_LIMIT");
|
|
72
|
+
this.name = "RateLimitError";
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/client.ts
|
|
77
|
+
var DEFAULT_TIMEOUT = 12e4;
|
|
78
|
+
var LLMSafeSpaces = class {
|
|
79
|
+
baseUrl;
|
|
80
|
+
timeout;
|
|
81
|
+
fetchFn;
|
|
82
|
+
token;
|
|
83
|
+
apiKey;
|
|
84
|
+
credentials;
|
|
85
|
+
loggingIn = false;
|
|
86
|
+
workspaces;
|
|
87
|
+
sessions;
|
|
88
|
+
auth;
|
|
89
|
+
secrets;
|
|
90
|
+
terminal;
|
|
91
|
+
userSettings;
|
|
92
|
+
account;
|
|
93
|
+
providerCredentials;
|
|
94
|
+
adminProviderCredentials;
|
|
95
|
+
usage;
|
|
96
|
+
inputRequests;
|
|
97
|
+
probe;
|
|
98
|
+
prompts;
|
|
99
|
+
agentRoles;
|
|
100
|
+
constructor(options) {
|
|
101
|
+
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
102
|
+
this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
|
|
103
|
+
this.apiKey = options.apiKey;
|
|
104
|
+
this.credentials = options.credentials;
|
|
105
|
+
this.fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
106
|
+
this.workspaces = new WorkspacesAPI(this);
|
|
107
|
+
this.sessions = new SessionsAPI(this);
|
|
108
|
+
this.auth = new AuthAPI(this);
|
|
109
|
+
this.secrets = new SecretsAPI(this);
|
|
110
|
+
this.terminal = new TerminalAPI(this);
|
|
111
|
+
this.userSettings = new UserSettingsAPI(this);
|
|
112
|
+
this.account = new AccountAPI(this);
|
|
113
|
+
this.providerCredentials = new ProviderCredentialsAPI(this);
|
|
114
|
+
this.adminProviderCredentials = new AdminProviderCredentialsAPI(this);
|
|
115
|
+
this.usage = new UsageAPI(this);
|
|
116
|
+
this.inputRequests = new InputRequestsAPI(this);
|
|
117
|
+
this.probe = new ProbeAPI(this);
|
|
118
|
+
this.prompts = new PromptsAPI(this);
|
|
119
|
+
this.agentRoles = new AgentRolesAPI(this);
|
|
120
|
+
}
|
|
121
|
+
/** Internal: make an authenticated request. */
|
|
122
|
+
async request(method, path, body, timeout) {
|
|
123
|
+
const url = `${this.baseUrl}/api/v1${path}`;
|
|
124
|
+
const headers = { "Content-Type": "application/json" };
|
|
125
|
+
if (this.apiKey) {
|
|
126
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
127
|
+
} else if (this.token) {
|
|
128
|
+
headers["Authorization"] = `Bearer ${this.token}`;
|
|
129
|
+
} else if (this.credentials && !this.loggingIn) {
|
|
130
|
+
await this.login();
|
|
131
|
+
headers["Authorization"] = `Bearer ${this.token}`;
|
|
132
|
+
}
|
|
133
|
+
const controller = new AbortController();
|
|
134
|
+
const timer = setTimeout(() => controller.abort(), timeout ?? this.timeout);
|
|
135
|
+
let res;
|
|
136
|
+
try {
|
|
137
|
+
res = await this.fetchFn(url, {
|
|
138
|
+
method,
|
|
139
|
+
headers,
|
|
140
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
141
|
+
signal: controller.signal
|
|
142
|
+
});
|
|
143
|
+
} catch (e) {
|
|
144
|
+
clearTimeout(timer);
|
|
145
|
+
if (e instanceof Error && e.name === "AbortError") {
|
|
146
|
+
throw new TimeoutError();
|
|
147
|
+
}
|
|
148
|
+
throw e;
|
|
149
|
+
}
|
|
150
|
+
clearTimeout(timer);
|
|
151
|
+
if (res.status === 401 && this.credentials && this.token) {
|
|
152
|
+
this.token = void 0;
|
|
153
|
+
return this.request(method, path, body, timeout);
|
|
154
|
+
}
|
|
155
|
+
if (!res.ok) {
|
|
156
|
+
const errBody = await res.json().catch(() => ({ error: res.statusText }));
|
|
157
|
+
const msg = errBody.error ?? res.statusText;
|
|
158
|
+
switch (res.status) {
|
|
159
|
+
case 401:
|
|
160
|
+
case 403:
|
|
161
|
+
throw new AuthError(msg, res.status);
|
|
162
|
+
case 404:
|
|
163
|
+
throw new NotFoundError(msg);
|
|
164
|
+
case 409:
|
|
165
|
+
throw new ConflictError(msg);
|
|
166
|
+
case 429:
|
|
167
|
+
throw new RateLimitError(msg);
|
|
168
|
+
default:
|
|
169
|
+
throw new LLMSafeSpacesError(msg, res.status);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (res.status === 204) return void 0;
|
|
173
|
+
const text = await res.text();
|
|
174
|
+
if (text === "") return void 0;
|
|
175
|
+
return JSON.parse(text);
|
|
176
|
+
}
|
|
177
|
+
async login() {
|
|
178
|
+
if (!this.credentials) throw new AuthError("No credentials configured");
|
|
179
|
+
this.loggingIn = true;
|
|
180
|
+
try {
|
|
181
|
+
const url = `${this.baseUrl}/api/v1/auth/login`;
|
|
182
|
+
const res = await this.fetchFn(url, {
|
|
183
|
+
method: "POST",
|
|
184
|
+
headers: { "Content-Type": "application/json" },
|
|
185
|
+
body: JSON.stringify(this.credentials)
|
|
186
|
+
});
|
|
187
|
+
if (!res.ok) throw new AuthError("Login failed", res.status);
|
|
188
|
+
const data = await res.json();
|
|
189
|
+
this.token = data.token;
|
|
190
|
+
} finally {
|
|
191
|
+
this.loggingIn = false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
var WorkspacesAPI = class {
|
|
196
|
+
constructor(client) {
|
|
197
|
+
this.client = client;
|
|
198
|
+
}
|
|
199
|
+
client;
|
|
200
|
+
list(limit = 20, offset = 0) {
|
|
201
|
+
return this.client.request("GET", `/workspaces?limit=${limit}&offset=${offset}`);
|
|
202
|
+
}
|
|
203
|
+
create(req) {
|
|
204
|
+
return this.client.request("POST", "/workspaces", req);
|
|
205
|
+
}
|
|
206
|
+
get(id) {
|
|
207
|
+
return this.client.request("GET", `/workspaces/${id}`);
|
|
208
|
+
}
|
|
209
|
+
rename(id, name) {
|
|
210
|
+
return this.client.request("PUT", `/workspaces/${id}`, { name });
|
|
211
|
+
}
|
|
212
|
+
delete(id) {
|
|
213
|
+
return this.client.request("DELETE", `/workspaces/${id}`);
|
|
214
|
+
}
|
|
215
|
+
getStatus(id) {
|
|
216
|
+
return this.client.request("GET", `/workspaces/${id}/status`);
|
|
217
|
+
}
|
|
218
|
+
activate(id) {
|
|
219
|
+
return this.client.request("POST", `/workspaces/${id}/activate`);
|
|
220
|
+
}
|
|
221
|
+
suspend(id) {
|
|
222
|
+
return this.client.request("POST", `/workspaces/${id}/suspend`);
|
|
223
|
+
}
|
|
224
|
+
restart(id) {
|
|
225
|
+
return this.client.request("POST", `/workspaces/${id}/restart`);
|
|
226
|
+
}
|
|
227
|
+
refreshCompute(id) {
|
|
228
|
+
return this.client.request("POST", `/workspaces/${id}/refresh-compute`);
|
|
229
|
+
}
|
|
230
|
+
setBindings(id, secretIds) {
|
|
231
|
+
return this.client.request("PUT", `/workspaces/${id}/bindings`, { secretIds });
|
|
232
|
+
}
|
|
233
|
+
getBindings(id) {
|
|
234
|
+
return this.client.request(
|
|
235
|
+
"GET",
|
|
236
|
+
`/workspaces/${id}/bindings`
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
reloadSecrets(id) {
|
|
240
|
+
return this.client.request("POST", `/workspaces/${id}/reload-secrets`);
|
|
241
|
+
}
|
|
242
|
+
setModel(id, model) {
|
|
243
|
+
return this.client.request("PUT", `/workspaces/${id}/model`, { model });
|
|
244
|
+
}
|
|
245
|
+
getModels(id) {
|
|
246
|
+
return this.client.request("GET", `/workspaces/${id}/models`);
|
|
247
|
+
}
|
|
248
|
+
setEnv(id, env) {
|
|
249
|
+
return this.client.request("PUT", `/workspaces/${id}/env`, { vars: env });
|
|
250
|
+
}
|
|
251
|
+
getEnv(id) {
|
|
252
|
+
return this.client.request("GET", `/workspaces/${id}/env`);
|
|
253
|
+
}
|
|
254
|
+
deleteEnv(id, varName) {
|
|
255
|
+
return this.client.request("DELETE", `/workspaces/${id}/env/${varName}`);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
var SessionsAPI = class {
|
|
259
|
+
constructor(client) {
|
|
260
|
+
this.client = client;
|
|
261
|
+
}
|
|
262
|
+
client;
|
|
263
|
+
ensure(workspaceId) {
|
|
264
|
+
return this.client.request("POST", `/workspaces/${workspaceId}/sessions/new`);
|
|
265
|
+
}
|
|
266
|
+
list(workspaceId) {
|
|
267
|
+
return this.client.request("GET", `/workspaces/${workspaceId}/sessions`);
|
|
268
|
+
}
|
|
269
|
+
getActive(workspaceId) {
|
|
270
|
+
return this.client.request("GET", `/workspaces/${workspaceId}/sessions/active`);
|
|
271
|
+
}
|
|
272
|
+
rename(workspaceId, sessionId, title) {
|
|
273
|
+
return this.client.request("PUT", `/workspaces/${workspaceId}/sessions/${sessionId}/title`, { title });
|
|
274
|
+
}
|
|
275
|
+
async sendMessage(workspaceId, sessionId, content) {
|
|
276
|
+
const raw = await this.client.request(
|
|
277
|
+
"POST",
|
|
278
|
+
`/workspaces/${workspaceId}/sessions/${sessionId}/message`,
|
|
279
|
+
{ content, parts: [{ type: "text", text: content }] }
|
|
280
|
+
);
|
|
281
|
+
return { raw, content: extractTextContent(raw) };
|
|
282
|
+
}
|
|
283
|
+
getHistory(workspaceId, sessionId) {
|
|
284
|
+
return this.client.request("GET", `/workspaces/${workspaceId}/sessions/${sessionId}/message`);
|
|
285
|
+
}
|
|
286
|
+
abort(workspaceId, sessionId) {
|
|
287
|
+
return this.client.request("POST", `/workspaces/${workspaceId}/sessions/${sessionId}/abort`);
|
|
288
|
+
}
|
|
289
|
+
get(workspaceId, sessionId) {
|
|
290
|
+
return this.client.request("GET", `/workspaces/${workspaceId}/sessions/${sessionId}`);
|
|
291
|
+
}
|
|
292
|
+
sendPromptAsync(workspaceId, sessionId, message) {
|
|
293
|
+
return this.client.request("POST", `/workspaces/${workspaceId}/sessions/${sessionId}/prompt`, { message });
|
|
294
|
+
}
|
|
295
|
+
delete(workspaceId, sessionId) {
|
|
296
|
+
return this.client.request("DELETE", `/workspaces/${workspaceId}/sessions/${sessionId}`);
|
|
297
|
+
}
|
|
298
|
+
enqueue(workspaceId, sessionId, text) {
|
|
299
|
+
return this.client.request("POST", `/workspaces/${workspaceId}/sessions/${sessionId}/queue`, { text });
|
|
300
|
+
}
|
|
301
|
+
listQueue(workspaceId, sessionId) {
|
|
302
|
+
return this.client.request("GET", `/workspaces/${workspaceId}/sessions/${sessionId}/queue`);
|
|
303
|
+
}
|
|
304
|
+
dismissQueued(workspaceId, sessionId, messageId) {
|
|
305
|
+
return this.client.request("DELETE", `/workspaces/${workspaceId}/sessions/${sessionId}/queue/${messageId}`);
|
|
306
|
+
}
|
|
307
|
+
markSeen(workspaceId, sessionId) {
|
|
308
|
+
return this.client.request("PUT", `/workspaces/${workspaceId}/sessions/${sessionId}/seen`);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
var AuthAPI = class {
|
|
312
|
+
constructor(client) {
|
|
313
|
+
this.client = client;
|
|
314
|
+
}
|
|
315
|
+
client;
|
|
316
|
+
me() {
|
|
317
|
+
return this.client.request("GET", "/auth/me");
|
|
318
|
+
}
|
|
319
|
+
listApiKeys() {
|
|
320
|
+
return this.client.request("GET", "/auth/api-keys");
|
|
321
|
+
}
|
|
322
|
+
createApiKey(name) {
|
|
323
|
+
return this.client.request("POST", "/auth/api-keys", { name });
|
|
324
|
+
}
|
|
325
|
+
deleteApiKey(id) {
|
|
326
|
+
return this.client.request("DELETE", `/auth/api-keys/${id}`);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
var SecretsAPI = class {
|
|
330
|
+
constructor(client) {
|
|
331
|
+
this.client = client;
|
|
332
|
+
}
|
|
333
|
+
client;
|
|
334
|
+
create(req) {
|
|
335
|
+
return this.client.request("POST", "/secrets", req);
|
|
336
|
+
}
|
|
337
|
+
list() {
|
|
338
|
+
return this.client.request("GET", "/secrets").then((r) => r?.secrets ?? r);
|
|
339
|
+
}
|
|
340
|
+
get(id) {
|
|
341
|
+
return this.client.request("GET", `/secrets/${id}`);
|
|
342
|
+
}
|
|
343
|
+
update(id, value) {
|
|
344
|
+
return this.client.request("PUT", `/secrets/${id}`, { value });
|
|
345
|
+
}
|
|
346
|
+
delete(id) {
|
|
347
|
+
return this.client.request("DELETE", `/secrets/${id}`);
|
|
348
|
+
}
|
|
349
|
+
reveal(id, password) {
|
|
350
|
+
return this.client.request("POST", `/secrets/${id}/reveal`, { password });
|
|
351
|
+
}
|
|
352
|
+
getAuditLog() {
|
|
353
|
+
return this.client.request("GET", "/secrets/audit");
|
|
354
|
+
}
|
|
355
|
+
getBindingsForSecret(id) {
|
|
356
|
+
return this.client.request("GET", `/secrets/${id}/bindings`);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
var TerminalAPI = class {
|
|
360
|
+
constructor(client) {
|
|
361
|
+
this.client = client;
|
|
362
|
+
}
|
|
363
|
+
client;
|
|
364
|
+
getTicket(workspaceId) {
|
|
365
|
+
return this.client.request("POST", `/workspaces/${workspaceId}/terminal/ticket`);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
var UserSettingsAPI = class {
|
|
369
|
+
constructor(client) {
|
|
370
|
+
this.client = client;
|
|
371
|
+
}
|
|
372
|
+
client;
|
|
373
|
+
get() {
|
|
374
|
+
return this.client.request("GET", "/users/me/settings");
|
|
375
|
+
}
|
|
376
|
+
getSchema() {
|
|
377
|
+
return this.client.request("GET", "/users/me/settings/schema");
|
|
378
|
+
}
|
|
379
|
+
set(key, value) {
|
|
380
|
+
return this.client.request("PUT", `/users/me/settings/${key}`, { value });
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
var AccountAPI = class {
|
|
384
|
+
constructor(client) {
|
|
385
|
+
this.client = client;
|
|
386
|
+
}
|
|
387
|
+
client;
|
|
388
|
+
rotateKey(password) {
|
|
389
|
+
return this.client.request("POST", "/account/rotate-key", { password });
|
|
390
|
+
}
|
|
391
|
+
changePassword(oldPassword, newPassword) {
|
|
392
|
+
return this.client.request("POST", "/account/change-password", { oldPassword, newPassword });
|
|
393
|
+
}
|
|
394
|
+
recover(userId, recoveryKey, newPassword) {
|
|
395
|
+
return this.client.request("POST", "/account/recover", { userId, recoveryKey, newPassword });
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
var ProviderCredentialsAPI = class {
|
|
399
|
+
constructor(client) {
|
|
400
|
+
this.client = client;
|
|
401
|
+
}
|
|
402
|
+
client;
|
|
403
|
+
create(req) {
|
|
404
|
+
return this.client.request("POST", "/provider-credentials", req).then((data) => {
|
|
405
|
+
if (data && typeof data === "object" && "credential" in data) {
|
|
406
|
+
return data.credential;
|
|
407
|
+
}
|
|
408
|
+
return data;
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
list() {
|
|
412
|
+
return this.client.request("GET", "/provider-credentials");
|
|
413
|
+
}
|
|
414
|
+
get(id) {
|
|
415
|
+
return this.client.request("GET", `/provider-credentials/${id}`);
|
|
416
|
+
}
|
|
417
|
+
delete(id) {
|
|
418
|
+
return this.client.request("DELETE", `/provider-credentials/${id}`);
|
|
419
|
+
}
|
|
420
|
+
probeModels(id) {
|
|
421
|
+
return this.client.request("GET", `/provider-credentials/${id}/models`);
|
|
422
|
+
}
|
|
423
|
+
listBindings(id) {
|
|
424
|
+
return this.client.request("GET", `/provider-credentials/${id}/bindings`).then((data) => data.workspaceIds);
|
|
425
|
+
}
|
|
426
|
+
bind(credId, workspaceId) {
|
|
427
|
+
return this.client.request("POST", `/provider-credentials/${credId}/bind/${workspaceId}`);
|
|
428
|
+
}
|
|
429
|
+
unbind(credId, workspaceId) {
|
|
430
|
+
return this.client.request("DELETE", `/provider-credentials/${credId}/bind/${workspaceId}`);
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
var AdminProviderCredentialsAPI = class {
|
|
434
|
+
constructor(client) {
|
|
435
|
+
this.client = client;
|
|
436
|
+
}
|
|
437
|
+
client;
|
|
438
|
+
list() {
|
|
439
|
+
return this.client.request("GET", "/admin/provider-credentials");
|
|
440
|
+
}
|
|
441
|
+
create(req) {
|
|
442
|
+
return this.client.request("POST", "/admin/provider-credentials", req);
|
|
443
|
+
}
|
|
444
|
+
get(id) {
|
|
445
|
+
return this.client.request("GET", `/admin/provider-credentials/${id}`);
|
|
446
|
+
}
|
|
447
|
+
update(id, req) {
|
|
448
|
+
return this.client.request("PUT", `/admin/provider-credentials/${id}`, req);
|
|
449
|
+
}
|
|
450
|
+
delete(id) {
|
|
451
|
+
return this.client.request("DELETE", `/admin/provider-credentials/${id}`);
|
|
452
|
+
}
|
|
453
|
+
probeModels(id) {
|
|
454
|
+
return this.client.request("GET", `/admin/provider-credentials/${id}/models`);
|
|
455
|
+
}
|
|
456
|
+
createAutoApply(id, req) {
|
|
457
|
+
return this.client.request("POST", `/admin/provider-credentials/${id}/auto-apply`, req);
|
|
458
|
+
}
|
|
459
|
+
listAutoApply(id) {
|
|
460
|
+
return this.client.request("GET", `/admin/provider-credentials/${id}/auto-apply`);
|
|
461
|
+
}
|
|
462
|
+
deleteAutoApply(id, targetType, targetId) {
|
|
463
|
+
return this.client.request("DELETE", `/admin/provider-credentials/${id}/auto-apply/${targetType}/${targetId}`);
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
var UsageAPI = class {
|
|
467
|
+
constructor(client) {
|
|
468
|
+
this.client = client;
|
|
469
|
+
}
|
|
470
|
+
client;
|
|
471
|
+
get() {
|
|
472
|
+
return this.client.request("GET", "/usage");
|
|
473
|
+
}
|
|
474
|
+
getWorkspace(workspaceId) {
|
|
475
|
+
return this.client.request("GET", `/usage/workspaces/${workspaceId}`);
|
|
476
|
+
}
|
|
477
|
+
getQuota() {
|
|
478
|
+
return this.client.request("GET", "/usage/quota");
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
var InputRequestsAPI = class {
|
|
482
|
+
constructor(client) {
|
|
483
|
+
this.client = client;
|
|
484
|
+
}
|
|
485
|
+
client;
|
|
486
|
+
listQuestions(workspaceId) {
|
|
487
|
+
return this.client.request("GET", `/workspaces/${workspaceId}/question`);
|
|
488
|
+
}
|
|
489
|
+
replyQuestion(workspaceId, requestId, body) {
|
|
490
|
+
return this.client.request("POST", `/workspaces/${workspaceId}/question/${requestId}/reply`, body);
|
|
491
|
+
}
|
|
492
|
+
rejectQuestion(workspaceId, requestId) {
|
|
493
|
+
return this.client.request("POST", `/workspaces/${workspaceId}/question/${requestId}/reject`);
|
|
494
|
+
}
|
|
495
|
+
listPermissions(workspaceId) {
|
|
496
|
+
return this.client.request("GET", `/workspaces/${workspaceId}/permission`);
|
|
497
|
+
}
|
|
498
|
+
replyPermission(workspaceId, requestId, body) {
|
|
499
|
+
return this.client.request("POST", `/workspaces/${workspaceId}/permission/${requestId}/reply`, body);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
var ProbeAPI = class {
|
|
503
|
+
constructor(client) {
|
|
504
|
+
this.client = client;
|
|
505
|
+
}
|
|
506
|
+
client;
|
|
507
|
+
probeModels(apiKey, baseURL) {
|
|
508
|
+
return this.client.request("POST", "/probe-models", { apiKey, baseURL });
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
function extractTextContent(raw) {
|
|
512
|
+
if (!raw || typeof raw !== "object") return "";
|
|
513
|
+
const obj = raw;
|
|
514
|
+
if (!Array.isArray(obj.parts)) return "";
|
|
515
|
+
return obj.parts.filter((p) => p.type === "text" && p.text).map((p) => p.text).join("");
|
|
516
|
+
}
|
|
517
|
+
var PromptsAPI = class {
|
|
518
|
+
constructor(client) {
|
|
519
|
+
this.client = client;
|
|
520
|
+
}
|
|
521
|
+
client;
|
|
522
|
+
getPlatform() {
|
|
523
|
+
return this.client.request("GET", "/admin/prompt");
|
|
524
|
+
}
|
|
525
|
+
setPlatform(prompt) {
|
|
526
|
+
return this.client.request("PUT", "/admin/prompt", { prompt });
|
|
527
|
+
}
|
|
528
|
+
getOrg(orgId) {
|
|
529
|
+
return this.client.request("GET", `/orgs/${orgId}/prompt`);
|
|
530
|
+
}
|
|
531
|
+
setOrg(orgId, body) {
|
|
532
|
+
return this.client.request("PUT", `/orgs/${orgId}/prompt`, body);
|
|
533
|
+
}
|
|
534
|
+
getWorkspace(workspaceId) {
|
|
535
|
+
return this.client.request("GET", `/workspaces/${workspaceId}/prompt`);
|
|
536
|
+
}
|
|
537
|
+
setWorkspace(workspaceId, prompt) {
|
|
538
|
+
return this.client.request("PUT", `/workspaces/${workspaceId}/prompt`, { prompt });
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
var AgentRolesAPI = class {
|
|
542
|
+
constructor(client) {
|
|
543
|
+
this.client = client;
|
|
544
|
+
}
|
|
545
|
+
client;
|
|
546
|
+
listPlatform() {
|
|
547
|
+
return this.client.request("GET", "/admin/agent-roles");
|
|
548
|
+
}
|
|
549
|
+
createPlatform(body) {
|
|
550
|
+
return this.client.request("POST", "/admin/agent-roles", body);
|
|
551
|
+
}
|
|
552
|
+
getPlatform(roleId) {
|
|
553
|
+
return this.client.request("GET", `/admin/agent-roles/${roleId}`);
|
|
554
|
+
}
|
|
555
|
+
updatePlatform(roleId, body) {
|
|
556
|
+
return this.client.request("PUT", `/admin/agent-roles/${roleId}`, body);
|
|
557
|
+
}
|
|
558
|
+
deletePlatform(roleId) {
|
|
559
|
+
return this.client.request("DELETE", `/admin/agent-roles/${roleId}`);
|
|
560
|
+
}
|
|
561
|
+
listOrg(orgId) {
|
|
562
|
+
return this.client.request("GET", `/orgs/${orgId}/agent-roles`);
|
|
563
|
+
}
|
|
564
|
+
createOrg(orgId, body) {
|
|
565
|
+
return this.client.request("POST", `/orgs/${orgId}/agent-roles`, body);
|
|
566
|
+
}
|
|
567
|
+
getOrg(orgId, roleId) {
|
|
568
|
+
return this.client.request("GET", `/orgs/${orgId}/agent-roles/${roleId}`);
|
|
569
|
+
}
|
|
570
|
+
updateOrg(orgId, roleId, body) {
|
|
571
|
+
return this.client.request("PUT", `/orgs/${orgId}/agent-roles/${roleId}`, body);
|
|
572
|
+
}
|
|
573
|
+
deleteOrg(orgId, roleId) {
|
|
574
|
+
return this.client.request("DELETE", `/orgs/${orgId}/agent-roles/${roleId}`);
|
|
575
|
+
}
|
|
576
|
+
getWorkspaceRole(workspaceId) {
|
|
577
|
+
return this.client.request("GET", `/workspaces/${workspaceId}/agent-role`);
|
|
578
|
+
}
|
|
579
|
+
setWorkspaceRole(workspaceId, roleId) {
|
|
580
|
+
return this.client.request("PUT", `/workspaces/${workspaceId}/agent-role`, { roleId });
|
|
581
|
+
}
|
|
582
|
+
clearWorkspaceRole(workspaceId) {
|
|
583
|
+
return this.client.request("DELETE", `/workspaces/${workspaceId}/agent-role`);
|
|
584
|
+
}
|
|
585
|
+
getEffectiveWorkspaceRole(workspaceId) {
|
|
586
|
+
return this.client.request("GET", `/workspaces/${workspaceId}/effective-agent-role`);
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
// src/types.ts
|
|
591
|
+
var SECRET_NAME_PATTERN = /^[a-z0-9._-]+$/;
|
|
592
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
593
|
+
0 && (module.exports = {
|
|
594
|
+
AuthError,
|
|
595
|
+
ConflictError,
|
|
596
|
+
LLMSafeSpaces,
|
|
597
|
+
LLMSafeSpacesError,
|
|
598
|
+
NotFoundError,
|
|
599
|
+
RateLimitError,
|
|
600
|
+
SECRET_NAME_PATTERN,
|
|
601
|
+
TimeoutError
|
|
602
|
+
});
|