@opengeni/sdk 3.1.0 → 3.3.2-canary.1
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 +60 -8
- package/dist/accounts.d.ts +5 -1
- package/dist/accounts.js +13 -1
- package/dist/accounts.js.map +1 -1
- package/dist/artifacts.js +6 -6
- package/dist/browser.d.ts +2 -1
- package/dist/browser.js +6 -4
- package/dist/{chunk-C2H7HBNP.js → chunk-6NEPJ7NC.js} +2 -2
- package/dist/{chunk-TX3EIENU.js → chunk-BESZFWMU.js} +2 -2
- package/dist/{chunk-YTAWBDO2.js → chunk-E5BNEG2D.js} +2 -1
- package/dist/chunk-E5BNEG2D.js.map +1 -0
- package/dist/{chunk-7ZXBPJZP.js → chunk-GY6RQPCG.js} +282 -43
- package/dist/chunk-GY6RQPCG.js.map +1 -0
- package/dist/{chunk-C4DJPZRU.js → chunk-OO5LPTO7.js} +14 -1
- package/dist/chunk-OO5LPTO7.js.map +1 -0
- package/dist/{chunk-GW3EJ2GP.js → chunk-QTBAMHEF.js} +28 -3
- package/dist/{chunk-GW3EJ2GP.js.map → chunk-QTBAMHEF.js.map} +1 -1
- package/dist/{chunk-VUQZAB3O.js → chunk-TFCLHRZK.js} +2 -2
- package/dist/client.d.ts +47 -11
- package/dist/codex-realtime-controller.js +2 -2
- package/dist/company-profile.d.ts +13 -0
- package/dist/core.d.ts +2 -1
- package/dist/core.js +7 -5
- package/dist/document-authority.js +5 -5
- package/dist/editable-artifacts.js +1 -1
- package/dist/errors.d.ts +12 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +219 -7
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +3 -0
- package/dist/interaction.js +4 -2
- package/dist/model-picker-order.d.ts +1 -0
- package/dist/model-picker-order.js +10 -0
- package/dist/model-picker-order.js.map +1 -0
- package/dist/realtime.d.ts +3 -1
- package/dist/realtime.js +2 -2
- package/dist/realtime.js.map +1 -1
- package/dist/session-titles.d.ts +28 -0
- package/dist/types.d.ts +90 -3
- package/package.json +6 -2
- package/src/accounts.ts +18 -0
- package/src/browser.ts +2 -0
- package/src/client.ts +407 -35
- package/src/company-profile.ts +13 -0
- package/src/core.ts +2 -0
- package/src/errors.ts +23 -0
- package/src/index.ts +29 -0
- package/src/interaction.ts +32 -0
- package/src/model-picker-order.ts +6 -0
- package/src/realtime.ts +1 -0
- package/src/session-titles.ts +84 -0
- package/src/types.ts +105 -2
- package/dist/chunk-7ZXBPJZP.js.map +0 -1
- package/dist/chunk-C4DJPZRU.js.map +0 -1
- package/dist/chunk-YTAWBDO2.js.map +0 -1
- /package/dist/{chunk-C2H7HBNP.js.map → chunk-6NEPJ7NC.js.map} +0 -0
- /package/dist/{chunk-TX3EIENU.js.map → chunk-BESZFWMU.js.map} +0 -0
- /package/dist/{chunk-VUQZAB3O.js.map → chunk-TFCLHRZK.js.map} +0 -0
|
@@ -5,18 +5,20 @@ import {
|
|
|
5
5
|
OPENGENI_API_CONTRACT_REVISION,
|
|
6
6
|
OPENGENI_CORRELATION_HEADER,
|
|
7
7
|
RETAINED_OUTPUT_MAX_PAGE_BYTES
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-E5BNEG2D.js";
|
|
9
9
|
import {
|
|
10
|
-
OpenGeniInteractionClient
|
|
11
|
-
|
|
10
|
+
OpenGeniInteractionClient,
|
|
11
|
+
decodeComputerFrameMetadataHeader
|
|
12
|
+
} from "./chunk-QTBAMHEF.js";
|
|
12
13
|
import {
|
|
13
14
|
OpenGeniApiContractMismatchError,
|
|
14
15
|
OpenGeniApiError,
|
|
16
|
+
OpenGeniSecureContextRequiredError,
|
|
15
17
|
OpenGeniSessionListCursorError,
|
|
16
18
|
OpenGeniStreamError,
|
|
17
19
|
isAbortError,
|
|
18
20
|
isRetryableStreamError
|
|
19
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-OO5LPTO7.js";
|
|
20
22
|
|
|
21
23
|
// src/sse.ts
|
|
22
24
|
async function* parseSseStream(stream) {
|
|
@@ -772,6 +774,8 @@ function createSingleFlightReadEntry(generation, onRequestStart) {
|
|
|
772
774
|
reject = entryReject;
|
|
773
775
|
});
|
|
774
776
|
return {
|
|
777
|
+
controller: new AbortController(),
|
|
778
|
+
consumers: 0,
|
|
775
779
|
generation,
|
|
776
780
|
promise,
|
|
777
781
|
resolve,
|
|
@@ -787,6 +791,26 @@ function assertNoMessageTools(input) {
|
|
|
787
791
|
);
|
|
788
792
|
}
|
|
789
793
|
}
|
|
794
|
+
function normalizeScheduledTaskMachineTarget(request) {
|
|
795
|
+
if (!("agentConfig" in request) || !request.agentConfig?.machineTarget) {
|
|
796
|
+
return request;
|
|
797
|
+
}
|
|
798
|
+
const { workingDir, ...machineTarget } = request.agentConfig.machineTarget;
|
|
799
|
+
if (workingDir === void 0) {
|
|
800
|
+
return request;
|
|
801
|
+
}
|
|
802
|
+
const normalizedWorkingDir = workingDir.trim();
|
|
803
|
+
return {
|
|
804
|
+
...request,
|
|
805
|
+
agentConfig: {
|
|
806
|
+
...request.agentConfig,
|
|
807
|
+
machineTarget: {
|
|
808
|
+
...machineTarget,
|
|
809
|
+
...normalizedWorkingDir ? { workingDir: normalizedWorkingDir } : {}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
}
|
|
790
814
|
var OpenGeniClient = class {
|
|
791
815
|
baseUrl;
|
|
792
816
|
options;
|
|
@@ -1007,7 +1031,11 @@ var OpenGeniClient = class {
|
|
|
1007
1031
|
}
|
|
1008
1032
|
async getSession(workspaceId, sessionId, options = {}) {
|
|
1009
1033
|
const path = `/v1/workspaces/${workspaceId}/sessions/${sessionId}`;
|
|
1010
|
-
return await this.sharedRead(
|
|
1034
|
+
return await this.sharedRead(
|
|
1035
|
+
path,
|
|
1036
|
+
(signal) => this.requestJson("GET", path, void 0, {}, { signal }),
|
|
1037
|
+
options
|
|
1038
|
+
);
|
|
1011
1039
|
}
|
|
1012
1040
|
async updateSession(workspaceId, sessionId, request) {
|
|
1013
1041
|
return await this.requestJson(
|
|
@@ -1107,7 +1135,8 @@ var OpenGeniClient = class {
|
|
|
1107
1135
|
...search ? { search } : {},
|
|
1108
1136
|
...options.pinsOnly ? { pinsOnly: "true" } : {},
|
|
1109
1137
|
...options.archivedOnly ? { archivedOnly: "true" } : {}
|
|
1110
|
-
}
|
|
1138
|
+
},
|
|
1139
|
+
{ signal: options.signal }
|
|
1111
1140
|
);
|
|
1112
1141
|
} catch (error) {
|
|
1113
1142
|
if (error instanceof OpenGeniApiError && error.status === 410) {
|
|
@@ -1201,47 +1230,48 @@ var OpenGeniClient = class {
|
|
|
1201
1230
|
const path = `/v1/workspaces/${workspaceId}/sessions/${sessionId}/lineage`;
|
|
1202
1231
|
return await this.sharedRead(
|
|
1203
1232
|
path,
|
|
1204
|
-
() => this.requestJson("GET", path),
|
|
1233
|
+
(signal) => this.requestJson("GET", path, void 0, {}, { signal }),
|
|
1205
1234
|
options
|
|
1206
1235
|
);
|
|
1207
1236
|
}
|
|
1208
1237
|
sharedRead(key, read, options = {}) {
|
|
1238
|
+
if (options.signal?.aborted) {
|
|
1239
|
+
return Promise.reject(
|
|
1240
|
+
options.signal.reason ?? new DOMException("Request aborted", "AbortError")
|
|
1241
|
+
);
|
|
1242
|
+
}
|
|
1209
1243
|
const existing = this.active.get(key);
|
|
1210
1244
|
if (existing) {
|
|
1211
1245
|
if (!options.fresh) {
|
|
1212
1246
|
this.observeRead(existing, options.onRequestStart);
|
|
1213
|
-
return existing.
|
|
1247
|
+
return this.consumeSharedRead(key, existing, options.signal);
|
|
1214
1248
|
}
|
|
1215
1249
|
const requiredGeneration = existing.generation + 1;
|
|
1216
1250
|
const queued2 = this.queued.get(key);
|
|
1217
1251
|
if (queued2 && queued2.generation >= requiredGeneration) {
|
|
1218
1252
|
this.observeRead(queued2, options.onRequestStart);
|
|
1219
|
-
return queued2.
|
|
1253
|
+
return this.consumeSharedRead(key, queued2, options.signal);
|
|
1220
1254
|
}
|
|
1221
1255
|
const predecessor = queued2?.promise ?? existing.promise;
|
|
1222
|
-
return this.queueRead(key, predecessor, requiredGeneration, read, options
|
|
1256
|
+
return this.queueRead(key, predecessor, requiredGeneration, read, options);
|
|
1223
1257
|
}
|
|
1224
1258
|
const queued = this.queued.get(key);
|
|
1225
1259
|
if (queued && (!options.fresh || !queued.started)) {
|
|
1226
1260
|
this.observeRead(queued, options.onRequestStart);
|
|
1227
|
-
return queued.
|
|
1261
|
+
return this.consumeSharedRead(key, queued, options.signal);
|
|
1228
1262
|
}
|
|
1229
1263
|
if (queued) {
|
|
1230
|
-
return this.queueRead(
|
|
1231
|
-
key,
|
|
1232
|
-
queued.promise,
|
|
1233
|
-
queued.generation + 1,
|
|
1234
|
-
read,
|
|
1235
|
-
options.onRequestStart
|
|
1236
|
-
);
|
|
1264
|
+
return this.queueRead(key, queued.promise, queued.generation + 1, read, options);
|
|
1237
1265
|
}
|
|
1238
1266
|
const generation = (this.generations.get(key) ?? 0) + 1;
|
|
1239
1267
|
const entry = createSingleFlightReadEntry(generation, options.onRequestStart);
|
|
1268
|
+
const consumed = this.consumeSharedRead(key, entry, options.signal);
|
|
1240
1269
|
this.launchRead(key, entry, read);
|
|
1241
|
-
return
|
|
1270
|
+
return consumed;
|
|
1242
1271
|
}
|
|
1243
|
-
queueRead(key, predecessor, generation, read,
|
|
1244
|
-
const entry = createSingleFlightReadEntry(generation, onRequestStart);
|
|
1272
|
+
queueRead(key, predecessor, generation, read, options) {
|
|
1273
|
+
const entry = createSingleFlightReadEntry(generation, options.onRequestStart);
|
|
1274
|
+
const consumed = this.consumeSharedRead(key, entry, options.signal);
|
|
1245
1275
|
this.queued.set(key, entry);
|
|
1246
1276
|
const launch = () => this.launchRead(key, entry, read);
|
|
1247
1277
|
void predecessor.then(launch, launch);
|
|
@@ -1251,9 +1281,10 @@ var OpenGeniClient = class {
|
|
|
1251
1281
|
if (!this.active.has(key)) this.generations.delete(key);
|
|
1252
1282
|
};
|
|
1253
1283
|
void entry.promise.then(clear, clear);
|
|
1254
|
-
return
|
|
1284
|
+
return consumed;
|
|
1255
1285
|
}
|
|
1256
1286
|
launchRead(key, entry, read) {
|
|
1287
|
+
if (entry.controller.signal.aborted) return;
|
|
1257
1288
|
entry.started = true;
|
|
1258
1289
|
this.generations.set(key, entry.generation);
|
|
1259
1290
|
this.active.set(key, entry);
|
|
@@ -1275,7 +1306,7 @@ var OpenGeniClient = class {
|
|
|
1275
1306
|
};
|
|
1276
1307
|
let request;
|
|
1277
1308
|
try {
|
|
1278
|
-
request = read();
|
|
1309
|
+
request = read(entry.controller.signal);
|
|
1279
1310
|
} catch (error) {
|
|
1280
1311
|
settle();
|
|
1281
1312
|
entry.reject(error);
|
|
@@ -1292,6 +1323,28 @@ var OpenGeniClient = class {
|
|
|
1292
1323
|
}
|
|
1293
1324
|
);
|
|
1294
1325
|
}
|
|
1326
|
+
consumeSharedRead(key, entry, signal) {
|
|
1327
|
+
entry.consumers += 1;
|
|
1328
|
+
let released = false;
|
|
1329
|
+
const release = () => {
|
|
1330
|
+
if (released) return;
|
|
1331
|
+
released = true;
|
|
1332
|
+
entry.consumers -= 1;
|
|
1333
|
+
if (!signal?.aborted || entry.consumers > 0) return;
|
|
1334
|
+
const reason = signal.reason;
|
|
1335
|
+
entry.controller.abort(reason);
|
|
1336
|
+
if (this.active.get(key) === entry) this.active.delete(key);
|
|
1337
|
+
if (this.queued.get(key) === entry) this.queued.delete(key);
|
|
1338
|
+
if (!this.active.has(key) && !this.queued.has(key)) this.generations.delete(key);
|
|
1339
|
+
entry.reject(reason);
|
|
1340
|
+
};
|
|
1341
|
+
signal?.addEventListener("abort", release, { once: true });
|
|
1342
|
+
const consumed = awaitWithAbort(entry.promise, signal);
|
|
1343
|
+
return consumed.finally(() => {
|
|
1344
|
+
signal?.removeEventListener("abort", release);
|
|
1345
|
+
release();
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1295
1348
|
observeRead(entry, listener) {
|
|
1296
1349
|
if (!listener) return;
|
|
1297
1350
|
if (!entry.started) {
|
|
@@ -1384,13 +1437,15 @@ var OpenGeniClient = class {
|
|
|
1384
1437
|
{
|
|
1385
1438
|
...options.limit !== void 0 ? { limit: String(options.limit) } : {},
|
|
1386
1439
|
...options.latestStarted ? { latestStarted: "1" } : {}
|
|
1387
|
-
}
|
|
1440
|
+
},
|
|
1441
|
+
{ signal: options.signal }
|
|
1388
1442
|
);
|
|
1389
1443
|
}
|
|
1390
1444
|
/** Newest turn that durably emitted `turn.started`, or null before any admission. */
|
|
1391
|
-
async getLatestStartedTurn(workspaceId, sessionId) {
|
|
1445
|
+
async getLatestStartedTurn(workspaceId, sessionId, options = {}) {
|
|
1392
1446
|
const turns = await this.listTurns(workspaceId, sessionId, {
|
|
1393
|
-
latestStarted: true
|
|
1447
|
+
latestStarted: true,
|
|
1448
|
+
signal: options.signal
|
|
1394
1449
|
});
|
|
1395
1450
|
return turns[0] ?? null;
|
|
1396
1451
|
}
|
|
@@ -1777,10 +1832,12 @@ var OpenGeniClient = class {
|
|
|
1777
1832
|
request
|
|
1778
1833
|
);
|
|
1779
1834
|
}
|
|
1780
|
-
async getComposerDraft(workspaceId, sessionId) {
|
|
1835
|
+
async getComposerDraft(workspaceId, sessionId, options = {}) {
|
|
1781
1836
|
return await this.requestSessionCommand(
|
|
1782
1837
|
"GET",
|
|
1783
|
-
`/v1/workspaces/${workspaceId}/sessions/${sessionId}/composer-draft
|
|
1838
|
+
`/v1/workspaces/${workspaceId}/sessions/${sessionId}/composer-draft`,
|
|
1839
|
+
void 0,
|
|
1840
|
+
options
|
|
1784
1841
|
);
|
|
1785
1842
|
}
|
|
1786
1843
|
async saveComposerDraft(workspaceId, sessionId, request) {
|
|
@@ -1965,9 +2022,13 @@ var OpenGeniClient = class {
|
|
|
1965
2022
|
}
|
|
1966
2023
|
// --- Goals -------------------------------------------------------------------
|
|
1967
2024
|
/** The session's goal. 404s when the session never had one. */
|
|
1968
|
-
async getGoal(workspaceId, sessionId) {
|
|
2025
|
+
async getGoal(workspaceId, sessionId, options = {}) {
|
|
1969
2026
|
const path = `/v1/workspaces/${workspaceId}/sessions/${sessionId}/goal`;
|
|
1970
|
-
return await this.sharedRead(
|
|
2027
|
+
return await this.sharedRead(
|
|
2028
|
+
path,
|
|
2029
|
+
(signal) => this.requestJson("GET", path, void 0, {}, { signal }),
|
|
2030
|
+
options
|
|
2031
|
+
);
|
|
1971
2032
|
}
|
|
1972
2033
|
async updateGoal(workspaceId, sessionId, request) {
|
|
1973
2034
|
return await this.requestJson(
|
|
@@ -2844,6 +2905,42 @@ var OpenGeniClient = class {
|
|
|
2844
2905
|
options
|
|
2845
2906
|
);
|
|
2846
2907
|
}
|
|
2908
|
+
async captureComputerTarget(workspaceId, computerSessionId, targetId, options = {}) {
|
|
2909
|
+
const response = await this.requestResponse(
|
|
2910
|
+
"GET",
|
|
2911
|
+
`/v1/workspaces/${workspaceId}/computer-sessions/${encodeURIComponent(computerSessionId)}/targets/${encodeURIComponent(targetId)}/screenshot`,
|
|
2912
|
+
{},
|
|
2913
|
+
options
|
|
2914
|
+
);
|
|
2915
|
+
const mediaType = response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase();
|
|
2916
|
+
if (mediaType !== "image/jpeg" && mediaType !== "image/png") {
|
|
2917
|
+
await cancelResponseBody(response, "computer frame media type is invalid");
|
|
2918
|
+
throw new OpenGeniApiError(502, "computer frame media type is invalid");
|
|
2919
|
+
}
|
|
2920
|
+
const metadataHeader = response.headers.get("x-opengeni-computer-frame");
|
|
2921
|
+
if (!metadataHeader || metadataHeader.length > 32 * 1024) {
|
|
2922
|
+
await cancelResponseBody(response, "computer frame metadata is invalid");
|
|
2923
|
+
throw new OpenGeniApiError(502, "computer frame metadata is invalid");
|
|
2924
|
+
}
|
|
2925
|
+
let metadata;
|
|
2926
|
+
try {
|
|
2927
|
+
metadata = decodeComputerFrameMetadataHeader(metadataHeader);
|
|
2928
|
+
} catch {
|
|
2929
|
+
await cancelResponseBody(response, "computer frame metadata is invalid");
|
|
2930
|
+
throw new OpenGeniApiError(502, "computer frame metadata is invalid");
|
|
2931
|
+
}
|
|
2932
|
+
const bytes = await readBoundedResponseBytes(response, 256 * 1024, null);
|
|
2933
|
+
const mismatchReason = computerFrameEvidenceMismatchReason(metadata, {
|
|
2934
|
+
computerSessionId,
|
|
2935
|
+
targetId,
|
|
2936
|
+
mediaType,
|
|
2937
|
+
sha256: await sha256Hex(bytes)
|
|
2938
|
+
});
|
|
2939
|
+
if (mismatchReason) {
|
|
2940
|
+
throw new OpenGeniApiError(502, "computer frame evidence does not match its request");
|
|
2941
|
+
}
|
|
2942
|
+
return { ...metadata, data: bytes };
|
|
2943
|
+
}
|
|
2847
2944
|
async actInComputer(workspaceId, computerSessionId, request, options = {}) {
|
|
2848
2945
|
return await this.requestJson(
|
|
2849
2946
|
"POST",
|
|
@@ -2897,8 +2994,14 @@ var OpenGeniClient = class {
|
|
|
2897
2994
|
* expected to authenticate. Drives a composer's model picker without prior
|
|
2898
2995
|
* knowledge of the host setup; safe to call before any auth is established.
|
|
2899
2996
|
*/
|
|
2900
|
-
async getClientConfig() {
|
|
2901
|
-
const config = await this.requestJson(
|
|
2997
|
+
async getClientConfig(options = {}) {
|
|
2998
|
+
const config = await this.requestJson(
|
|
2999
|
+
"GET",
|
|
3000
|
+
"/v1/config/client",
|
|
3001
|
+
void 0,
|
|
3002
|
+
{},
|
|
3003
|
+
options
|
|
3004
|
+
);
|
|
2902
3005
|
if (config.apiContractRevision !== OPENGENI_API_CONTRACT_REVISION) {
|
|
2903
3006
|
throw new OpenGeniApiContractMismatchError(
|
|
2904
3007
|
OPENGENI_API_CONTRACT_REVISION,
|
|
@@ -2908,10 +3011,69 @@ var OpenGeniClient = class {
|
|
|
2908
3011
|
return config;
|
|
2909
3012
|
}
|
|
2910
3013
|
/** Authenticated model definitions plus workspace-specific selectability. */
|
|
2911
|
-
async getWorkspaceModelCatalog(workspaceId) {
|
|
3014
|
+
async getWorkspaceModelCatalog(workspaceId, options = {}) {
|
|
3015
|
+
return await this.requestJson(
|
|
3016
|
+
"GET",
|
|
3017
|
+
`/v1/workspaces/${workspaceId}/model-catalog`,
|
|
3018
|
+
void 0,
|
|
3019
|
+
{},
|
|
3020
|
+
options
|
|
3021
|
+
);
|
|
3022
|
+
}
|
|
3023
|
+
/** List workspace-owned unpinned Vercel AI Gateway model slugs. */
|
|
3024
|
+
async listWorkspaceGatewayCustomModels(workspaceId) {
|
|
3025
|
+
return await this.requestJson(
|
|
3026
|
+
"GET",
|
|
3027
|
+
`/v1/workspaces/${workspaceId}/gateway-custom-models`
|
|
3028
|
+
);
|
|
3029
|
+
}
|
|
3030
|
+
/** Add one exact upstream Vercel AI Gateway slug. */
|
|
3031
|
+
async createWorkspaceGatewayCustomModel(workspaceId, request) {
|
|
3032
|
+
return await this.requestJson(
|
|
3033
|
+
"POST",
|
|
3034
|
+
`/v1/workspaces/${workspaceId}/gateway-custom-models`,
|
|
3035
|
+
request
|
|
3036
|
+
);
|
|
3037
|
+
}
|
|
3038
|
+
/** Remove one workspace custom Gateway model by its stable row id. */
|
|
3039
|
+
async deleteWorkspaceGatewayCustomModel(workspaceId, customModelId, request) {
|
|
3040
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(
|
|
3041
|
+
customModelId
|
|
3042
|
+
)) {
|
|
3043
|
+
throw new TypeError("customModelId must be a UUID");
|
|
3044
|
+
}
|
|
3045
|
+
await this.requestVoid(
|
|
3046
|
+
"DELETE",
|
|
3047
|
+
`/v1/workspaces/${workspaceId}/gateway-custom-models/${encodeURIComponent(customModelId)}`,
|
|
3048
|
+
request
|
|
3049
|
+
);
|
|
3050
|
+
}
|
|
3051
|
+
/** List workspace-owned unpinned OpenRouter model slugs. */
|
|
3052
|
+
async listWorkspaceOpenRouterCustomModels(workspaceId) {
|
|
2912
3053
|
return await this.requestJson(
|
|
2913
3054
|
"GET",
|
|
2914
|
-
`/v1/workspaces/${workspaceId}/
|
|
3055
|
+
`/v1/workspaces/${workspaceId}/openrouter-custom-models`
|
|
3056
|
+
);
|
|
3057
|
+
}
|
|
3058
|
+
/** Add one exact upstream OpenRouter slug. */
|
|
3059
|
+
async createWorkspaceOpenRouterCustomModel(workspaceId, request) {
|
|
3060
|
+
return await this.requestJson(
|
|
3061
|
+
"POST",
|
|
3062
|
+
`/v1/workspaces/${workspaceId}/openrouter-custom-models`,
|
|
3063
|
+
request
|
|
3064
|
+
);
|
|
3065
|
+
}
|
|
3066
|
+
/** Remove one workspace custom OpenRouter model by its stable row id. */
|
|
3067
|
+
async deleteWorkspaceOpenRouterCustomModel(workspaceId, customModelId, request) {
|
|
3068
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(
|
|
3069
|
+
customModelId
|
|
3070
|
+
)) {
|
|
3071
|
+
throw new TypeError("customModelId must be a UUID");
|
|
3072
|
+
}
|
|
3073
|
+
await this.requestVoid(
|
|
3074
|
+
"DELETE",
|
|
3075
|
+
`/v1/workspaces/${workspaceId}/openrouter-custom-models/${encodeURIComponent(customModelId)}`,
|
|
3076
|
+
request
|
|
2915
3077
|
);
|
|
2916
3078
|
}
|
|
2917
3079
|
/** Read the workspace's hard provider/model allowlist. */
|
|
@@ -2930,10 +3092,13 @@ var OpenGeniClient = class {
|
|
|
2930
3092
|
);
|
|
2931
3093
|
}
|
|
2932
3094
|
/** Authenticated realtime voice models and credential readiness. */
|
|
2933
|
-
async getWorkspaceRealtimeModelCatalog(workspaceId) {
|
|
3095
|
+
async getWorkspaceRealtimeModelCatalog(workspaceId, options = {}) {
|
|
2934
3096
|
return await this.requestJson(
|
|
2935
3097
|
"GET",
|
|
2936
|
-
`/v1/workspaces/${workspaceId}/realtime-model-catalog
|
|
3098
|
+
`/v1/workspaces/${workspaceId}/realtime-model-catalog`,
|
|
3099
|
+
void 0,
|
|
3100
|
+
{},
|
|
3101
|
+
options
|
|
2937
3102
|
);
|
|
2938
3103
|
}
|
|
2939
3104
|
/** The caller's access context: subject, account + workspace grants, defaults. */
|
|
@@ -3165,6 +3330,17 @@ var OpenGeniClient = class {
|
|
|
3165
3330
|
async createWorkspace(request) {
|
|
3166
3331
|
return await this.requestJson("POST", "/v1/workspaces", request);
|
|
3167
3332
|
}
|
|
3333
|
+
/**
|
|
3334
|
+
* Create an organization workspace once for a stable external tenant
|
|
3335
|
+
* identity, or return the existing workspace without overwriting it.
|
|
3336
|
+
*/
|
|
3337
|
+
async ensureWorkspace(request) {
|
|
3338
|
+
return await this.requestJson(
|
|
3339
|
+
"PUT",
|
|
3340
|
+
"/v1/workspaces/external",
|
|
3341
|
+
request
|
|
3342
|
+
);
|
|
3343
|
+
}
|
|
3168
3344
|
async getWorkspace(workspaceId) {
|
|
3169
3345
|
return await this.requestJson("GET", `/v1/workspaces/${workspaceId}`);
|
|
3170
3346
|
}
|
|
@@ -3346,6 +3522,19 @@ var OpenGeniClient = class {
|
|
|
3346
3522
|
`/v1/workspaces/${workspaceId}/company-profile/revisions/${encodeURIComponent(revisionId)}`
|
|
3347
3523
|
);
|
|
3348
3524
|
}
|
|
3525
|
+
async getCompanyProfileAgentPolicy(workspaceId) {
|
|
3526
|
+
return await this.requestJson(
|
|
3527
|
+
"GET",
|
|
3528
|
+
`/v1/workspaces/${workspaceId}/company-profile/agent-policy`
|
|
3529
|
+
);
|
|
3530
|
+
}
|
|
3531
|
+
async updateCompanyProfileAgentPolicy(workspaceId, request) {
|
|
3532
|
+
return await this.requestJson(
|
|
3533
|
+
"PATCH",
|
|
3534
|
+
`/v1/workspaces/${workspaceId}/company-profile/agent-policy`,
|
|
3535
|
+
request
|
|
3536
|
+
);
|
|
3537
|
+
}
|
|
3349
3538
|
async updateCompanyProfile(workspaceId, request) {
|
|
3350
3539
|
return await this.requestJson(
|
|
3351
3540
|
"PUT",
|
|
@@ -3469,9 +3658,16 @@ var OpenGeniClient = class {
|
|
|
3469
3658
|
);
|
|
3470
3659
|
return response.members;
|
|
3471
3660
|
}
|
|
3661
|
+
/** Active organization members who can be added to this workspace. */
|
|
3662
|
+
async listWorkspaceMemberCandidates(workspaceId) {
|
|
3663
|
+
const response = await this.requestJson(
|
|
3664
|
+
"GET",
|
|
3665
|
+
`/v1/workspaces/${workspaceId}/member-candidates`
|
|
3666
|
+
);
|
|
3667
|
+
return response.members;
|
|
3668
|
+
}
|
|
3472
3669
|
/**
|
|
3473
|
-
* Add
|
|
3474
|
-
* exists (email invites for unknown users are deferred).
|
|
3670
|
+
* Add one active member selected from the workspace candidate inventory.
|
|
3475
3671
|
*/
|
|
3476
3672
|
async addWorkspaceMember(workspaceId, request) {
|
|
3477
3673
|
return await this.requestJson(
|
|
@@ -3551,14 +3747,14 @@ var OpenGeniClient = class {
|
|
|
3551
3747
|
return await this.requestJson(
|
|
3552
3748
|
"POST",
|
|
3553
3749
|
`/v1/workspaces/${workspaceId}/scheduled-tasks`,
|
|
3554
|
-
request
|
|
3750
|
+
normalizeScheduledTaskMachineTarget(request)
|
|
3555
3751
|
);
|
|
3556
3752
|
}
|
|
3557
3753
|
async updateScheduledTask(workspaceId, taskId, request) {
|
|
3558
3754
|
return await this.requestJson(
|
|
3559
3755
|
"PATCH",
|
|
3560
3756
|
`/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}`,
|
|
3561
|
-
request
|
|
3757
|
+
normalizeScheduledTaskMachineTarget(request)
|
|
3562
3758
|
);
|
|
3563
3759
|
}
|
|
3564
3760
|
async pauseScheduledTask(workspaceId, taskId) {
|
|
@@ -3853,6 +4049,7 @@ var OpenGeniClient = class {
|
|
|
3853
4049
|
if (input.timeoutMs !== void 0 && (!Number.isFinite(input.timeoutMs) || input.timeoutMs <= 0)) {
|
|
3854
4050
|
throw new Error("File upload timeout must be a positive number");
|
|
3855
4051
|
}
|
|
4052
|
+
assertBrowserFileUploadSecureContext();
|
|
3856
4053
|
const withTimeout = async (timeoutMs, operation) => {
|
|
3857
4054
|
const controller = new AbortController();
|
|
3858
4055
|
let timeout;
|
|
@@ -4867,6 +5064,28 @@ var OpenGeniClient = class {
|
|
|
4867
5064
|
`/v1/workspaces/${workspaceId}/api-keys/${apiKeyId}`
|
|
4868
5065
|
);
|
|
4869
5066
|
}
|
|
5067
|
+
async listOrganizationApiKeys(organizationId) {
|
|
5068
|
+
const response = await this.requestJson(
|
|
5069
|
+
"GET",
|
|
5070
|
+
`/v1/organizations/${organizationId}/api-keys`
|
|
5071
|
+
);
|
|
5072
|
+
return response.apiKeys;
|
|
5073
|
+
}
|
|
5074
|
+
/** The returned `token` is shown once; only its prefix is stored. */
|
|
5075
|
+
async createOrganizationApiKey(organizationId, request) {
|
|
5076
|
+
return await this.requestJson(
|
|
5077
|
+
"POST",
|
|
5078
|
+
`/v1/organizations/${organizationId}/api-keys`,
|
|
5079
|
+
request
|
|
5080
|
+
);
|
|
5081
|
+
}
|
|
5082
|
+
/** Revoke an organization-scoped API key. Returns the revoked key. */
|
|
5083
|
+
async deleteOrganizationApiKey(organizationId, apiKeyId) {
|
|
5084
|
+
return await this.requestJson(
|
|
5085
|
+
"DELETE",
|
|
5086
|
+
`/v1/organizations/${organizationId}/api-keys/${apiKeyId}`
|
|
5087
|
+
);
|
|
5088
|
+
}
|
|
4870
5089
|
// --- Billing (account-scoped) --------------------------------------------------------------------
|
|
4871
5090
|
async getBilling(options = {}) {
|
|
4872
5091
|
return await this.requestJson("GET", "/v1/billing", void 0, {
|
|
@@ -5107,14 +5326,15 @@ var OpenGeniClient = class {
|
|
|
5107
5326
|
return await this.requestJson("DELETE", `/v1/workspaces/${workspaceId}/supergrok/accounts/${accountId}`, {});
|
|
5108
5327
|
}
|
|
5109
5328
|
/** Contract-checked JSON transport shared by opt-in typed SDK clients. */
|
|
5110
|
-
async requestSessionCommand(method, path, body) {
|
|
5329
|
+
async requestSessionCommand(method, path, body, options = {}) {
|
|
5111
5330
|
return await this.requestJson(
|
|
5112
5331
|
method,
|
|
5113
5332
|
path,
|
|
5114
5333
|
body,
|
|
5115
5334
|
{},
|
|
5116
5335
|
{
|
|
5117
|
-
|
|
5336
|
+
signal: options.signal,
|
|
5337
|
+
timeoutMs: options.timeoutMs ?? this.sessionCommandTimeoutMs
|
|
5118
5338
|
}
|
|
5119
5339
|
);
|
|
5120
5340
|
}
|
|
@@ -5376,6 +5596,16 @@ function mutationTransportError(correlationId) {
|
|
|
5376
5596
|
displayMessage: "OpenGeni could not confirm the request \u2014 reconcile before retrying."
|
|
5377
5597
|
});
|
|
5378
5598
|
}
|
|
5599
|
+
function assertBrowserFileUploadSecureContext() {
|
|
5600
|
+
const secureContext = typeof window !== "undefined" ? window.isSecureContext : typeof globalThis.isSecureContext === "boolean" ? globalThis.isSecureContext : void 0;
|
|
5601
|
+
if (secureContext === void 0) return;
|
|
5602
|
+
if (!secureContext) {
|
|
5603
|
+
throw new OpenGeniSecureContextRequiredError("insecure_context");
|
|
5604
|
+
}
|
|
5605
|
+
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.digest !== "function") {
|
|
5606
|
+
throw new OpenGeniSecureContextRequiredError("web_crypto_unavailable");
|
|
5607
|
+
}
|
|
5608
|
+
}
|
|
5379
5609
|
async function sha256ForUpload(body) {
|
|
5380
5610
|
const bytes = typeof body === "string" ? new TextEncoder().encode(body) : body instanceof Blob ? new Uint8Array(await body.arrayBuffer()) : new Uint8Array(body);
|
|
5381
5611
|
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
@@ -5386,6 +5616,15 @@ async function sha256Hex(bytes) {
|
|
|
5386
5616
|
const digest = await globalThis.crypto.subtle.digest("SHA-256", owned.buffer);
|
|
5387
5617
|
return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
5388
5618
|
}
|
|
5619
|
+
function computerFrameEvidenceMismatchReason(metadata, expected) {
|
|
5620
|
+
if (metadata.computerSessionId !== expected.computerSessionId) {
|
|
5621
|
+
return "frame_session_mismatch";
|
|
5622
|
+
}
|
|
5623
|
+
if (metadata.targetId !== expected.targetId) return "frame_target_mismatch";
|
|
5624
|
+
if (metadata.mediaType !== expected.mediaType) return "frame_media_mismatch";
|
|
5625
|
+
if (metadata.sha256 !== expected.sha256) return "frame_digest_mismatch";
|
|
5626
|
+
return null;
|
|
5627
|
+
}
|
|
5389
5628
|
async function cancelResponseBody(response, reason) {
|
|
5390
5629
|
await response.body?.cancel(reason).catch(() => void 0);
|
|
5391
5630
|
}
|
|
@@ -5478,4 +5717,4 @@ export {
|
|
|
5478
5717
|
parseMediaGenerationResult,
|
|
5479
5718
|
OpenGeniClient
|
|
5480
5719
|
};
|
|
5481
|
-
//# sourceMappingURL=chunk-
|
|
5720
|
+
//# sourceMappingURL=chunk-GY6RQPCG.js.map
|