@opengeni/sdk 0.5.0 → 0.6.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/README.md +36 -1
- package/dist/index.d.ts +384 -7
- package/dist/index.js +145 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +204 -0
- package/src/index.ts +36 -0
- package/src/types.ts +338 -6
package/dist/index.js
CHANGED
|
@@ -237,6 +237,92 @@ var OpenGeniClient = class {
|
|
|
237
237
|
...options.limit !== void 0 ? { limit: String(options.limit) } : {}
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
|
+
// --- Bring-your-own-compute: Machines dashboard + metrics (M10) ------------
|
|
241
|
+
/**
|
|
242
|
+
* List the workspace's machines (the Machines dashboard). Each enrolled
|
|
243
|
+
* selfhosted machine carries its derived state + latest metrics +
|
|
244
|
+
* sharedSessionCount. Pass `sessionId` for an in-session view, which adds the
|
|
245
|
+
* session's synthetic Modal group box + the active-sandbox pointer.
|
|
246
|
+
*/
|
|
247
|
+
async listMachines(workspaceId, options = {}) {
|
|
248
|
+
return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/machines`, void 0, {
|
|
249
|
+
...options.sessionId !== void 0 ? { sessionId: options.sessionId } : {}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Read the downsampled (~1/min) metrics series for ONE machine over a time
|
|
254
|
+
* window (default 1h). The samples are oldest-first (a left-to-right chart).
|
|
255
|
+
*/
|
|
256
|
+
async machineMetricsSeries(workspaceId, enrollmentId, options = {}) {
|
|
257
|
+
const response = await this.requestJson(
|
|
258
|
+
"GET",
|
|
259
|
+
`/v1/workspaces/${workspaceId}/machines/${enrollmentId}/metrics/series`,
|
|
260
|
+
void 0,
|
|
261
|
+
{ ...options.window !== void 0 ? { window: options.window } : {} }
|
|
262
|
+
);
|
|
263
|
+
return response.samples;
|
|
264
|
+
}
|
|
265
|
+
// --- Self-hosted enrollment UX (design 11) --------------------------------
|
|
266
|
+
/**
|
|
267
|
+
* Resolve a pending device-enrollment flow by its user_code for the click-Grant
|
|
268
|
+
* approve page (EnrollmentConsent). NO workspace in the path — the server
|
|
269
|
+
* resolves the workspace from the (globally-unique-among-pending) code, then
|
|
270
|
+
* authorizes the caller against it (enrollments:read). Rejects (404) when the
|
|
271
|
+
* code is unknown/expired OR the caller lacks the grant — the two are
|
|
272
|
+
* indistinguishable by design (no cross-workspace disclosure). Does not consume
|
|
273
|
+
* the request.
|
|
274
|
+
*/
|
|
275
|
+
async lookupDeviceEnrollment(userCode) {
|
|
276
|
+
return await this.requestJson("POST", "/v1/enrollments/device/lookup", { userCode });
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Approve a pending device-enrollment flow (the LOUD consent step). `allowScreenControl`
|
|
280
|
+
* is the authoritative screen-control consent (whole-machine is mandatory/implicit).
|
|
281
|
+
* Lands an enrollment + a selfhosted sandbox and unblocks the agent's poll.
|
|
282
|
+
*/
|
|
283
|
+
async approveDeviceEnrollment(workspaceId, request) {
|
|
284
|
+
return await this.requestJson(
|
|
285
|
+
"POST",
|
|
286
|
+
`/v1/workspaces/${workspaceId}/enrollments/device/approve`,
|
|
287
|
+
{ userCode: request.userCode, allowScreenControl: request.allowScreenControl ?? false }
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
/** Deny a pending device-enrollment flow (the explicit "no" at the approve page). */
|
|
291
|
+
async denyDeviceEnrollment(workspaceId, request) {
|
|
292
|
+
return await this.requestJson(
|
|
293
|
+
"POST",
|
|
294
|
+
`/v1/workspaces/${workspaceId}/enrollments/device/deny`,
|
|
295
|
+
{ userCode: request.userCode }
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Mint a short-TTL headless enroll token (the `oget_` token) for the fleet /
|
|
300
|
+
* non-interactive enroll path. The returned `token` is SECRET — surface it once
|
|
301
|
+
* with a copy-now warning; it cannot be re-read. `allowScreenControl` bakes the
|
|
302
|
+
* screen-control consent into the token.
|
|
303
|
+
*/
|
|
304
|
+
async mintEnrollToken(workspaceId, request = {}) {
|
|
305
|
+
return await this.requestJson(
|
|
306
|
+
"POST",
|
|
307
|
+
`/v1/workspaces/${workspaceId}/enrollments/token`,
|
|
308
|
+
{ allowScreenControl: request.allowScreenControl ?? false }
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Swap a session's active sandbox (the user-authenticated equivalent of the
|
|
313
|
+
* M7 `sandbox_swap` MCP tool). `target` is a `MachineView.sandboxId` from
|
|
314
|
+
* `listMachines`, or "session"/"default" to swap back to the session's own
|
|
315
|
+
* group box. Validation (ownership/liveness/epoch fence) is server-side; the
|
|
316
|
+
* result echoes the resulting pointer (`swapped: false` + `reason` on a
|
|
317
|
+
* rejected target or a lost epoch fence).
|
|
318
|
+
*/
|
|
319
|
+
async swapActiveSandbox(workspaceId, sessionId, request) {
|
|
320
|
+
return await this.requestJson(
|
|
321
|
+
"POST",
|
|
322
|
+
`/v1/workspaces/${workspaceId}/sessions/${sessionId}/active-sandbox`,
|
|
323
|
+
request
|
|
324
|
+
);
|
|
325
|
+
}
|
|
240
326
|
// --- Scheduled tasks -------------------------------------------------------
|
|
241
327
|
async listScheduledTasks(workspaceId, options = {}) {
|
|
242
328
|
return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/scheduled-tasks`, void 0, {
|
|
@@ -906,6 +992,59 @@ var OpenGeniClient = class {
|
|
|
906
992
|
const params = new URLSearchParams(query).toString();
|
|
907
993
|
return `${this.baseUrl}${path}${params ? `?${params}` : ""}`;
|
|
908
994
|
}
|
|
995
|
+
// --- Codex (ChatGPT) subscription (workspace-scoped) --------------------------------------------
|
|
996
|
+
/** Connection state + the codex models the workspace may select (empty until connected). */
|
|
997
|
+
async codexStatus(workspaceId) {
|
|
998
|
+
return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/codex/status`);
|
|
999
|
+
}
|
|
1000
|
+
/** Begin device-code login: show `userCode` at `verificationUri`, then poll with `state`. */
|
|
1001
|
+
async codexConnectStart(workspaceId) {
|
|
1002
|
+
return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/codex/connect/start`);
|
|
1003
|
+
}
|
|
1004
|
+
/** Poll device-code authorization with the `state` from {@link codexConnectStart}. */
|
|
1005
|
+
async codexConnectPoll(workspaceId, state) {
|
|
1006
|
+
return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/codex/connect/poll`, { state });
|
|
1007
|
+
}
|
|
1008
|
+
/** Remaining usage / limits for the connected (ACTIVE) subscription. Back-compat. */
|
|
1009
|
+
async codexUsage(workspaceId) {
|
|
1010
|
+
return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/codex/usage`);
|
|
1011
|
+
}
|
|
1012
|
+
/** Live per-account usage read (refreshes THIS account's bearer; writes the cache). */
|
|
1013
|
+
async codexAccountUsage(workspaceId, accountId) {
|
|
1014
|
+
return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}/usage`);
|
|
1015
|
+
}
|
|
1016
|
+
/** Batched live refresh across every connected account, keyed by credential id. */
|
|
1017
|
+
async refreshCodexUsage(workspaceId) {
|
|
1018
|
+
return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/codex/usage/refresh`);
|
|
1019
|
+
}
|
|
1020
|
+
/** Disconnect ALL accounts (legacy workspace-wide). Prefer `disconnectCodexAccount`. */
|
|
1021
|
+
async codexDisconnect(workspaceId) {
|
|
1022
|
+
return await this.requestJson("DELETE", `/v1/workspaces/${workspaceId}/codex`);
|
|
1023
|
+
}
|
|
1024
|
+
/** List every connected Codex account + the workspace active pointer + settings. */
|
|
1025
|
+
async listCodexAccounts(workspaceId) {
|
|
1026
|
+
return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/codex/accounts`);
|
|
1027
|
+
}
|
|
1028
|
+
/** Switch the workspace ACTIVE Codex account (the one unpinned sessions use). */
|
|
1029
|
+
async activateCodexAccount(workspaceId, accountId) {
|
|
1030
|
+
return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}/activate`);
|
|
1031
|
+
}
|
|
1032
|
+
/** P3: enable/disable Codex auto-rotation and/or pick the strategy. Returns the effective settings. */
|
|
1033
|
+
async setCodexRotationSettings(workspaceId, patch) {
|
|
1034
|
+
return await this.requestJson("PATCH", `/v1/workspaces/${workspaceId}/codex/settings`, patch);
|
|
1035
|
+
}
|
|
1036
|
+
/** Disconnect ONE Codex account by id (re-picks active when the removed one was active). */
|
|
1037
|
+
async disconnectCodexAccount(workspaceId, accountId) {
|
|
1038
|
+
return await this.requestJson("DELETE", `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}`);
|
|
1039
|
+
}
|
|
1040
|
+
/** Rename a Codex account (label only in P1). */
|
|
1041
|
+
async renameCodexAccount(workspaceId, accountId, label) {
|
|
1042
|
+
return await this.requestJson("PATCH", `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}`, { label });
|
|
1043
|
+
}
|
|
1044
|
+
/** Pin (or unpin via "auto") a session's Codex account. Applies on the next turn. */
|
|
1045
|
+
async pinSessionCodexAccount(workspaceId, sessionId, target) {
|
|
1046
|
+
return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/codex-account`, { target });
|
|
1047
|
+
}
|
|
909
1048
|
async requestJson(method, path, body, query = {}) {
|
|
910
1049
|
const response = await this.fetchImpl(this.url(path, query), {
|
|
911
1050
|
method,
|
|
@@ -1182,7 +1321,9 @@ var SESSION_EVENT_TYPES = [
|
|
|
1182
1321
|
"terminal.pty.started",
|
|
1183
1322
|
"terminal.pty.output.delta",
|
|
1184
1323
|
"terminal.pty.exited",
|
|
1185
|
-
"session.title_set"
|
|
1324
|
+
"session.title_set",
|
|
1325
|
+
// Multi-account Codex (P1): the session's inference account changed.
|
|
1326
|
+
"codex.account.switched"
|
|
1186
1327
|
];
|
|
1187
1328
|
var KNOWN_PERMISSIONS = [
|
|
1188
1329
|
"account:read",
|
|
@@ -1216,7 +1357,9 @@ var KNOWN_PERMISSIONS = [
|
|
|
1216
1357
|
"api_keys:manage",
|
|
1217
1358
|
"environments:manage",
|
|
1218
1359
|
"environments:use",
|
|
1219
|
-
"goals:manage"
|
|
1360
|
+
"goals:manage",
|
|
1361
|
+
"enrollments:read",
|
|
1362
|
+
"enrollments:manage"
|
|
1220
1363
|
];
|
|
1221
1364
|
var KNOWN_USAGE_EVENT_TYPES = [
|
|
1222
1365
|
"agent_run.created",
|