@opengeni/sdk 3.3.2 → 3.5.1-canary.0
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 +15 -2
- package/dist/artifact-client.d.ts +2 -1
- package/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +6 -6
- package/dist/browser.d.ts +3 -2
- package/dist/browser.js +6 -4
- package/dist/{chunk-QT3KFVDP.js → chunk-3VIQGNRX.js} +2 -2
- package/dist/chunk-3VIQGNRX.js.map +1 -0
- package/dist/{chunk-C2H7HBNP.js → chunk-7S2MZ65L.js} +6 -6
- package/dist/{chunk-TRNI7KEO.js → chunk-GXC4RESV.js} +164 -15
- package/dist/chunk-GXC4RESV.js.map +1 -0
- package/dist/{chunk-JUS2UYRP.js → chunk-HILHQEZD.js} +1 -1
- package/dist/chunk-HILHQEZD.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-YXQX7RQT.js → chunk-PPWKSUDS.js} +2 -2
- package/dist/{chunk-KKRO2VCP.js → chunk-QTBAMHEF.js} +2 -2
- package/dist/client.d.ts +43 -4
- package/dist/codex-realtime-controller.js +2 -2
- package/dist/core.d.ts +3 -2
- package/dist/core.js +9 -7
- package/dist/document-authority.js +5 -5
- package/dist/editable-artifacts.js +4 -4
- package/dist/errors.d.ts +12 -0
- package/dist/github-repositories.d.ts +10 -0
- package/dist/github-repositories.js +36 -0
- package/dist/github-repositories.js.map +1 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +62 -52
- package/dist/index.js.map +1 -1
- package/dist/interaction.js +2 -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.js +2 -2
- package/dist/session-titles.d.ts +2 -28
- package/dist/stream.d.ts +2 -0
- package/dist/types.d.ts +121 -3
- package/package.json +10 -2
- package/src/artifact-client.ts +2 -1
- package/src/artifacts.ts +1 -0
- package/src/browser.ts +3 -0
- package/src/client.ts +261 -15
- package/src/core.ts +3 -0
- package/src/errors.ts +23 -0
- package/src/github-repositories.ts +60 -0
- package/src/index.ts +27 -1
- package/src/model-picker-order.ts +6 -0
- package/src/session-titles.ts +8 -82
- package/src/stream.ts +29 -8
- package/src/types.ts +147 -4
- package/dist/chunk-C4DJPZRU.js.map +0 -1
- package/dist/chunk-JUS2UYRP.js.map +0 -1
- package/dist/chunk-QT3KFVDP.js.map +0 -1
- package/dist/chunk-TRNI7KEO.js.map +0 -1
- /package/dist/{chunk-C2H7HBNP.js.map → chunk-7S2MZ65L.js.map} +0 -0
- /package/dist/{chunk-YXQX7RQT.js.map → chunk-PPWKSUDS.js.map} +0 -0
- /package/dist/{chunk-KKRO2VCP.js.map → chunk-QTBAMHEF.js.map} +0 -0
package/src/client.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OpenGeniApiContractMismatchError,
|
|
3
3
|
OpenGeniApiError,
|
|
4
|
+
OpenGeniSecureContextRequiredError,
|
|
4
5
|
OpenGeniSessionListCursorError,
|
|
5
6
|
} from "./errors";
|
|
6
7
|
import {
|
|
@@ -169,6 +170,22 @@ import type {
|
|
|
169
170
|
ClientConfig,
|
|
170
171
|
WorkspaceModelAccessPolicy,
|
|
171
172
|
WorkspaceModelCatalogResponse,
|
|
173
|
+
WorkspaceGatewayCustomModel,
|
|
174
|
+
WorkspaceGatewayCustomModelsResponse,
|
|
175
|
+
CreateWorkspaceGatewayCustomModelRequest,
|
|
176
|
+
DeleteWorkspaceGatewayCustomModelRequest,
|
|
177
|
+
WorkspaceOpenRouterCustomModel,
|
|
178
|
+
WorkspaceOpenRouterCustomModelsResponse,
|
|
179
|
+
CreateWorkspaceOpenRouterCustomModelRequest,
|
|
180
|
+
DeleteWorkspaceOpenRouterCustomModelRequest,
|
|
181
|
+
OrganizationModelProviderKind,
|
|
182
|
+
OrganizationModelProviderConnection,
|
|
183
|
+
UpsertOrganizationModelProviderConnectionRequest,
|
|
184
|
+
RevokeOrganizationModelProviderConnectionRequest,
|
|
185
|
+
OrganizationProviderCustomModel,
|
|
186
|
+
OrganizationProviderCustomModelsResponse,
|
|
187
|
+
CreateOrganizationProviderCustomModelRequest,
|
|
188
|
+
DeleteOrganizationProviderCustomModelRequest,
|
|
172
189
|
WorkspaceRealtimeModelCatalogResponse,
|
|
173
190
|
ClientSessionEventInput,
|
|
174
191
|
UserMessageEventInput,
|
|
@@ -261,6 +278,8 @@ import type {
|
|
|
261
278
|
AcceptOrganizationRecoveryCustodyRequest,
|
|
262
279
|
ConfigureOrganizationRecoveryPolicyRequest,
|
|
263
280
|
CreateOrganizationInvitationRequest,
|
|
281
|
+
CreateAdditionalOrganizationRequest,
|
|
282
|
+
CreateAdditionalOrganizationResponse,
|
|
264
283
|
CreateOrganizationRequest,
|
|
265
284
|
CreateOrganizationResponse,
|
|
266
285
|
CreateOrganizationWorkspaceRequest,
|
|
@@ -563,7 +582,22 @@ function sessionListQuery(options: {
|
|
|
563
582
|
};
|
|
564
583
|
}
|
|
565
584
|
|
|
566
|
-
|
|
585
|
+
/**
|
|
586
|
+
* Web-standard fetch response accepted by the SDK.
|
|
587
|
+
*
|
|
588
|
+
* The project global `Response` type includes Bun's non-standard `textStream()`
|
|
589
|
+
* method and the newer `bytes()` method. Fetch implementations such as Expo do
|
|
590
|
+
* not necessarily provide either member, and the SDK does not use them, so
|
|
591
|
+
* they must not be part of the adapter boundary.
|
|
592
|
+
*/
|
|
593
|
+
export type FetchResponse = Omit<Response, "bytes" | "clone" | "textStream"> & {
|
|
594
|
+
clone(): FetchResponse;
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
export type FetchLike = (
|
|
598
|
+
input: string | URL | Request,
|
|
599
|
+
init?: RequestInit,
|
|
600
|
+
) => Promise<FetchResponse>;
|
|
567
601
|
|
|
568
602
|
export type WorkspaceControlEventPage = {
|
|
569
603
|
events: WorkspaceControlEvent[];
|
|
@@ -789,7 +823,7 @@ export class OpenGeniClient {
|
|
|
789
823
|
if (input.durationSeconds !== undefined) {
|
|
790
824
|
form.append("durationSeconds", String(input.durationSeconds));
|
|
791
825
|
}
|
|
792
|
-
let response:
|
|
826
|
+
let response: FetchResponse;
|
|
793
827
|
try {
|
|
794
828
|
response = await this.fetchImpl(this.url(`/v1/workspaces/${workspaceId}/transcriptions`), {
|
|
795
829
|
method: "POST",
|
|
@@ -888,7 +922,7 @@ export class OpenGeniClient {
|
|
|
888
922
|
input: UploadTranscriptionRecordingChunkInput,
|
|
889
923
|
): Promise<UploadTranscriptionRecordingChunkResponse> {
|
|
890
924
|
const correlationId = crypto.randomUUID();
|
|
891
|
-
let response:
|
|
925
|
+
let response: FetchResponse;
|
|
892
926
|
try {
|
|
893
927
|
response = await this.fetchImpl(
|
|
894
928
|
this.url(
|
|
@@ -1639,7 +1673,11 @@ export class OpenGeniClient {
|
|
|
1639
1673
|
async listTurns(
|
|
1640
1674
|
workspaceId: string,
|
|
1641
1675
|
sessionId: string,
|
|
1642
|
-
options: {
|
|
1676
|
+
options: {
|
|
1677
|
+
limit?: number;
|
|
1678
|
+
latestStarted?: boolean;
|
|
1679
|
+
signal?: AbortSignal | undefined;
|
|
1680
|
+
} = {},
|
|
1643
1681
|
): Promise<SessionTurn[]> {
|
|
1644
1682
|
return await this.requestJson<SessionTurn[]>(
|
|
1645
1683
|
"GET",
|
|
@@ -4045,6 +4083,172 @@ export class OpenGeniClient {
|
|
|
4045
4083
|
);
|
|
4046
4084
|
}
|
|
4047
4085
|
|
|
4086
|
+
/** List workspace-owned unpinned Vercel AI Gateway model slugs. */
|
|
4087
|
+
async listWorkspaceGatewayCustomModels(
|
|
4088
|
+
workspaceId: string,
|
|
4089
|
+
): Promise<WorkspaceGatewayCustomModelsResponse> {
|
|
4090
|
+
return await this.requestJson<WorkspaceGatewayCustomModelsResponse>(
|
|
4091
|
+
"GET",
|
|
4092
|
+
`/v1/workspaces/${workspaceId}/gateway-custom-models`,
|
|
4093
|
+
);
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
/** Add one exact upstream Vercel AI Gateway slug. */
|
|
4097
|
+
async createWorkspaceGatewayCustomModel(
|
|
4098
|
+
workspaceId: string,
|
|
4099
|
+
request: CreateWorkspaceGatewayCustomModelRequest,
|
|
4100
|
+
): Promise<WorkspaceGatewayCustomModel> {
|
|
4101
|
+
return await this.requestJson<WorkspaceGatewayCustomModel>(
|
|
4102
|
+
"POST",
|
|
4103
|
+
`/v1/workspaces/${workspaceId}/gateway-custom-models`,
|
|
4104
|
+
request,
|
|
4105
|
+
);
|
|
4106
|
+
}
|
|
4107
|
+
|
|
4108
|
+
/** Remove one workspace custom Gateway model by its stable row id. */
|
|
4109
|
+
async deleteWorkspaceGatewayCustomModel(
|
|
4110
|
+
workspaceId: string,
|
|
4111
|
+
customModelId: string,
|
|
4112
|
+
request: DeleteWorkspaceGatewayCustomModelRequest,
|
|
4113
|
+
): Promise<void> {
|
|
4114
|
+
if (
|
|
4115
|
+
!/^[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(
|
|
4116
|
+
customModelId,
|
|
4117
|
+
)
|
|
4118
|
+
) {
|
|
4119
|
+
throw new TypeError("customModelId must be a UUID");
|
|
4120
|
+
}
|
|
4121
|
+
await this.requestVoid(
|
|
4122
|
+
"DELETE",
|
|
4123
|
+
`/v1/workspaces/${workspaceId}/gateway-custom-models/${encodeURIComponent(customModelId)}`,
|
|
4124
|
+
request,
|
|
4125
|
+
);
|
|
4126
|
+
}
|
|
4127
|
+
|
|
4128
|
+
/** List workspace-owned unpinned OpenRouter model slugs. */
|
|
4129
|
+
async listWorkspaceOpenRouterCustomModels(
|
|
4130
|
+
workspaceId: string,
|
|
4131
|
+
): Promise<WorkspaceOpenRouterCustomModelsResponse> {
|
|
4132
|
+
return await this.requestJson<WorkspaceOpenRouterCustomModelsResponse>(
|
|
4133
|
+
"GET",
|
|
4134
|
+
`/v1/workspaces/${workspaceId}/openrouter-custom-models`,
|
|
4135
|
+
);
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4138
|
+
/** Add one exact upstream OpenRouter slug. */
|
|
4139
|
+
async createWorkspaceOpenRouterCustomModel(
|
|
4140
|
+
workspaceId: string,
|
|
4141
|
+
request: CreateWorkspaceOpenRouterCustomModelRequest,
|
|
4142
|
+
): Promise<WorkspaceOpenRouterCustomModel> {
|
|
4143
|
+
return await this.requestJson<WorkspaceOpenRouterCustomModel>(
|
|
4144
|
+
"POST",
|
|
4145
|
+
`/v1/workspaces/${workspaceId}/openrouter-custom-models`,
|
|
4146
|
+
request,
|
|
4147
|
+
);
|
|
4148
|
+
}
|
|
4149
|
+
|
|
4150
|
+
/** Remove one workspace custom OpenRouter model by its stable row id. */
|
|
4151
|
+
async deleteWorkspaceOpenRouterCustomModel(
|
|
4152
|
+
workspaceId: string,
|
|
4153
|
+
customModelId: string,
|
|
4154
|
+
request: DeleteWorkspaceOpenRouterCustomModelRequest,
|
|
4155
|
+
): Promise<void> {
|
|
4156
|
+
if (
|
|
4157
|
+
!/^[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(
|
|
4158
|
+
customModelId,
|
|
4159
|
+
)
|
|
4160
|
+
) {
|
|
4161
|
+
throw new TypeError("customModelId must be a UUID");
|
|
4162
|
+
}
|
|
4163
|
+
await this.requestVoid(
|
|
4164
|
+
"DELETE",
|
|
4165
|
+
`/v1/workspaces/${workspaceId}/openrouter-custom-models/${encodeURIComponent(customModelId)}`,
|
|
4166
|
+
request,
|
|
4167
|
+
);
|
|
4168
|
+
}
|
|
4169
|
+
|
|
4170
|
+
/** Read metadata for one organization-owned model-provider connection. */
|
|
4171
|
+
async getOrganizationModelProviderConnection(
|
|
4172
|
+
organizationId: string,
|
|
4173
|
+
providerKind: OrganizationModelProviderKind,
|
|
4174
|
+
): Promise<OrganizationModelProviderConnection | null> {
|
|
4175
|
+
return await this.requestJson<OrganizationModelProviderConnection | null>(
|
|
4176
|
+
"GET",
|
|
4177
|
+
`/v1/organizations/${organizationId}/model-providers/${providerKind}`,
|
|
4178
|
+
);
|
|
4179
|
+
}
|
|
4180
|
+
|
|
4181
|
+
/** Connect or rotate one organization-owned provider credential. */
|
|
4182
|
+
async upsertOrganizationModelProviderConnection(
|
|
4183
|
+
organizationId: string,
|
|
4184
|
+
providerKind: OrganizationModelProviderKind,
|
|
4185
|
+
request: UpsertOrganizationModelProviderConnectionRequest,
|
|
4186
|
+
): Promise<OrganizationModelProviderConnection> {
|
|
4187
|
+
return await this.requestJson<OrganizationModelProviderConnection>(
|
|
4188
|
+
"PUT",
|
|
4189
|
+
`/v1/organizations/${organizationId}/model-providers/${providerKind}`,
|
|
4190
|
+
request,
|
|
4191
|
+
);
|
|
4192
|
+
}
|
|
4193
|
+
|
|
4194
|
+
/** Revoke one organization-owned provider credential. */
|
|
4195
|
+
async revokeOrganizationModelProviderConnection(
|
|
4196
|
+
organizationId: string,
|
|
4197
|
+
providerKind: OrganizationModelProviderKind,
|
|
4198
|
+
request: RevokeOrganizationModelProviderConnectionRequest,
|
|
4199
|
+
): Promise<OrganizationModelProviderConnection> {
|
|
4200
|
+
return await this.requestJson<OrganizationModelProviderConnection>(
|
|
4201
|
+
"DELETE",
|
|
4202
|
+
`/v1/organizations/${organizationId}/model-providers/${providerKind}`,
|
|
4203
|
+
request,
|
|
4204
|
+
);
|
|
4205
|
+
}
|
|
4206
|
+
|
|
4207
|
+
/** List organization-owned exact upstream model slugs. */
|
|
4208
|
+
async listOrganizationProviderCustomModels(
|
|
4209
|
+
organizationId: string,
|
|
4210
|
+
providerKind: OrganizationModelProviderKind,
|
|
4211
|
+
): Promise<OrganizationProviderCustomModelsResponse> {
|
|
4212
|
+
return await this.requestJson<OrganizationProviderCustomModelsResponse>(
|
|
4213
|
+
"GET",
|
|
4214
|
+
`/v1/organizations/${organizationId}/model-providers/${providerKind}/custom-models`,
|
|
4215
|
+
);
|
|
4216
|
+
}
|
|
4217
|
+
|
|
4218
|
+
/** Add one organization-owned exact upstream model slug. */
|
|
4219
|
+
async createOrganizationProviderCustomModel(
|
|
4220
|
+
organizationId: string,
|
|
4221
|
+
providerKind: OrganizationModelProviderKind,
|
|
4222
|
+
request: CreateOrganizationProviderCustomModelRequest,
|
|
4223
|
+
): Promise<OrganizationProviderCustomModel> {
|
|
4224
|
+
return await this.requestJson<OrganizationProviderCustomModel>(
|
|
4225
|
+
"POST",
|
|
4226
|
+
`/v1/organizations/${organizationId}/model-providers/${providerKind}/custom-models`,
|
|
4227
|
+
request,
|
|
4228
|
+
);
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4231
|
+
/** Retire one organization-owned custom model. */
|
|
4232
|
+
async deleteOrganizationProviderCustomModel(
|
|
4233
|
+
organizationId: string,
|
|
4234
|
+
providerKind: OrganizationModelProviderKind,
|
|
4235
|
+
customModelId: string,
|
|
4236
|
+
request: DeleteOrganizationProviderCustomModelRequest,
|
|
4237
|
+
): Promise<OrganizationProviderCustomModel> {
|
|
4238
|
+
if (
|
|
4239
|
+
!/^[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(
|
|
4240
|
+
customModelId,
|
|
4241
|
+
)
|
|
4242
|
+
) {
|
|
4243
|
+
throw new TypeError("customModelId must be a UUID");
|
|
4244
|
+
}
|
|
4245
|
+
return await this.requestJson<OrganizationProviderCustomModel>(
|
|
4246
|
+
"DELETE",
|
|
4247
|
+
`/v1/organizations/${organizationId}/model-providers/${providerKind}/custom-models/${encodeURIComponent(customModelId)}`,
|
|
4248
|
+
request,
|
|
4249
|
+
);
|
|
4250
|
+
}
|
|
4251
|
+
|
|
4048
4252
|
/** Read the workspace's hard provider/model allowlist. */
|
|
4049
4253
|
async getWorkspaceModelAccessPolicy(workspaceId: string): Promise<WorkspaceModelAccessPolicy> {
|
|
4050
4254
|
return await this.requestJson<WorkspaceModelAccessPolicy>(
|
|
@@ -4140,6 +4344,17 @@ export class OpenGeniClient {
|
|
|
4140
4344
|
return await this.requestJson<CreateOrganizationResponse>("POST", "/v1/organizations", request);
|
|
4141
4345
|
}
|
|
4142
4346
|
|
|
4347
|
+
/** Create another organization owned by the current managed human. */
|
|
4348
|
+
async createAdditionalOrganization(
|
|
4349
|
+
request: CreateAdditionalOrganizationRequest,
|
|
4350
|
+
): Promise<CreateAdditionalOrganizationResponse> {
|
|
4351
|
+
return await this.requestJson<CreateAdditionalOrganizationResponse>(
|
|
4352
|
+
"POST",
|
|
4353
|
+
"/v1/organizations/additional",
|
|
4354
|
+
request,
|
|
4355
|
+
);
|
|
4356
|
+
}
|
|
4357
|
+
|
|
4143
4358
|
/** Pending and historical invitations addressed to the current managed human. */
|
|
4144
4359
|
async listOrganizationInvitations(
|
|
4145
4360
|
options: { cursor?: string; limit?: number } = {},
|
|
@@ -4229,7 +4444,7 @@ export class OpenGeniClient {
|
|
|
4229
4444
|
);
|
|
4230
4445
|
}
|
|
4231
4446
|
|
|
4232
|
-
/** Create a shared workspace
|
|
4447
|
+
/** Create a shared workspace and grant its creator explicit workspace-admin access. */
|
|
4233
4448
|
async createOrganizationWorkspace(
|
|
4234
4449
|
organizationId: string,
|
|
4235
4450
|
request: CreateOrganizationWorkspaceRequest,
|
|
@@ -4266,6 +4481,14 @@ export class OpenGeniClient {
|
|
|
4266
4481
|
);
|
|
4267
4482
|
}
|
|
4268
4483
|
|
|
4484
|
+
/** Delete a shared workspace through organization-administrator authority. */
|
|
4485
|
+
async deleteOrganizationWorkspace(organizationId: string, workspaceId: string): Promise<void> {
|
|
4486
|
+
await this.requestVoid(
|
|
4487
|
+
"DELETE",
|
|
4488
|
+
`/v1/organizations/${organizationId}/workspaces/${workspaceId}`,
|
|
4489
|
+
);
|
|
4490
|
+
}
|
|
4491
|
+
|
|
4269
4492
|
async putOrganizationWorkspaceMember(
|
|
4270
4493
|
organizationId: string,
|
|
4271
4494
|
workspaceId: string,
|
|
@@ -5478,6 +5701,7 @@ export class OpenGeniClient {
|
|
|
5478
5701
|
) {
|
|
5479
5702
|
throw new Error("File upload timeout must be a positive number");
|
|
5480
5703
|
}
|
|
5704
|
+
assertBrowserFileUploadSecureContext();
|
|
5481
5705
|
const withTimeout = async <T>(
|
|
5482
5706
|
timeoutMs: number,
|
|
5483
5707
|
operation: (signal: AbortSignal) => Promise<T>,
|
|
@@ -7360,7 +7584,7 @@ export class OpenGeniClient {
|
|
|
7360
7584
|
const correlationId = crypto.randomUUID();
|
|
7361
7585
|
const abort = requestAbortSignal(options);
|
|
7362
7586
|
try {
|
|
7363
|
-
let response:
|
|
7587
|
+
let response: FetchResponse;
|
|
7364
7588
|
try {
|
|
7365
7589
|
response = await awaitWithAbort(
|
|
7366
7590
|
this.fetchImpl(this.url(path, query), {
|
|
@@ -7407,9 +7631,9 @@ export class OpenGeniClient {
|
|
|
7407
7631
|
path: string,
|
|
7408
7632
|
query: Record<string, string> = {},
|
|
7409
7633
|
options: OpenGeniRequestOptions = {},
|
|
7410
|
-
): Promise<
|
|
7634
|
+
): Promise<FetchResponse> {
|
|
7411
7635
|
const correlationId = crypto.randomUUID();
|
|
7412
|
-
let response:
|
|
7636
|
+
let response: FetchResponse;
|
|
7413
7637
|
try {
|
|
7414
7638
|
response = await this.fetchImpl(this.url(path, query), {
|
|
7415
7639
|
method,
|
|
@@ -7433,7 +7657,7 @@ export class OpenGeniClient {
|
|
|
7433
7657
|
/** Contract-checked transport shared by opt-in typed SDK clients for 204 responses. */
|
|
7434
7658
|
async requestVoid(method: string, path: string, body?: unknown): Promise<void> {
|
|
7435
7659
|
const correlationId = crypto.randomUUID();
|
|
7436
|
-
let response:
|
|
7660
|
+
let response: FetchResponse;
|
|
7437
7661
|
try {
|
|
7438
7662
|
response = await this.fetchImpl(this.url(path), {
|
|
7439
7663
|
method,
|
|
@@ -7457,7 +7681,7 @@ export class OpenGeniClient {
|
|
|
7457
7681
|
}
|
|
7458
7682
|
}
|
|
7459
7683
|
|
|
7460
|
-
function assertApiContractResponse(response:
|
|
7684
|
+
function assertApiContractResponse(response: FetchResponse): void {
|
|
7461
7685
|
const actual = response.headers.get(OPENGENI_API_CONTRACT_HEADER);
|
|
7462
7686
|
if (actual && actual !== OPENGENI_API_CONTRACT_REVISION) {
|
|
7463
7687
|
throw new OpenGeniApiContractMismatchError(OPENGENI_API_CONTRACT_REVISION, actual);
|
|
@@ -7640,7 +7864,7 @@ type ApiErrorRequestContext = {
|
|
|
7640
7864
|
};
|
|
7641
7865
|
|
|
7642
7866
|
async function apiErrorFromResponse(
|
|
7643
|
-
response:
|
|
7867
|
+
response: FetchResponse,
|
|
7644
7868
|
context: ApiErrorRequestContext,
|
|
7645
7869
|
): Promise<OpenGeniApiError> {
|
|
7646
7870
|
return new OpenGeniApiError(response.status, await readBoundedJsonErrorBody(response), {
|
|
@@ -7650,7 +7874,7 @@ async function apiErrorFromResponse(
|
|
|
7650
7874
|
}
|
|
7651
7875
|
|
|
7652
7876
|
async function assertJsonResponse(
|
|
7653
|
-
response:
|
|
7877
|
+
response: FetchResponse,
|
|
7654
7878
|
context: ApiErrorRequestContext,
|
|
7655
7879
|
): Promise<void> {
|
|
7656
7880
|
if (isJsonContentType(response.headers.get("content-type"))) return;
|
|
@@ -7664,7 +7888,7 @@ async function assertJsonResponse(
|
|
|
7664
7888
|
});
|
|
7665
7889
|
}
|
|
7666
7890
|
|
|
7667
|
-
async function readBoundedJsonErrorBody(response:
|
|
7891
|
+
async function readBoundedJsonErrorBody(response: FetchResponse): Promise<string> {
|
|
7668
7892
|
if (!isJsonContentType(response.headers.get("content-type"))) {
|
|
7669
7893
|
await cancelResponseBody(response, "discarding API error body");
|
|
7670
7894
|
return "";
|
|
@@ -7701,6 +7925,28 @@ function mutationTransportError(correlationId: string): OpenGeniApiError {
|
|
|
7701
7925
|
});
|
|
7702
7926
|
}
|
|
7703
7927
|
|
|
7928
|
+
function assertBrowserFileUploadSecureContext(): void {
|
|
7929
|
+
const secureContext =
|
|
7930
|
+
typeof window !== "undefined"
|
|
7931
|
+
? window.isSecureContext
|
|
7932
|
+
: typeof globalThis.isSecureContext === "boolean"
|
|
7933
|
+
? globalThis.isSecureContext
|
|
7934
|
+
: undefined;
|
|
7935
|
+
// The framework-agnostic SDK also runs in Node, Bun, Deno, and edge
|
|
7936
|
+
// runtimes. Preserve their existing upload behavior; this typed HTTPS error
|
|
7937
|
+
// is only meaningful where the browser exposes a secure-context state.
|
|
7938
|
+
if (secureContext === undefined) return;
|
|
7939
|
+
if (!secureContext) {
|
|
7940
|
+
throw new OpenGeniSecureContextRequiredError("insecure_context");
|
|
7941
|
+
}
|
|
7942
|
+
if (
|
|
7943
|
+
typeof globalThis.crypto === "undefined" ||
|
|
7944
|
+
typeof globalThis.crypto.subtle?.digest !== "function"
|
|
7945
|
+
) {
|
|
7946
|
+
throw new OpenGeniSecureContextRequiredError("web_crypto_unavailable");
|
|
7947
|
+
}
|
|
7948
|
+
}
|
|
7949
|
+
|
|
7704
7950
|
async function sha256ForUpload(body: Blob | ArrayBuffer | string): Promise<string> {
|
|
7705
7951
|
const bytes =
|
|
7706
7952
|
typeof body === "string"
|
|
@@ -7742,7 +7988,7 @@ function computerFrameEvidenceMismatchReason(
|
|
|
7742
7988
|
return null;
|
|
7743
7989
|
}
|
|
7744
7990
|
|
|
7745
|
-
async function cancelResponseBody(response:
|
|
7991
|
+
async function cancelResponseBody(response: FetchResponse, reason: string): Promise<void> {
|
|
7746
7992
|
await response.body?.cancel(reason).catch(() => undefined);
|
|
7747
7993
|
}
|
|
7748
7994
|
|
|
@@ -7811,7 +8057,7 @@ function parseBoundedContentLength(value: string | null): number | null {
|
|
|
7811
8057
|
}
|
|
7812
8058
|
|
|
7813
8059
|
async function readBoundedResponseBytes(
|
|
7814
|
-
response:
|
|
8060
|
+
response: FetchResponse,
|
|
7815
8061
|
maxBytes: number,
|
|
7816
8062
|
expectedBytes: number | null,
|
|
7817
8063
|
): Promise<Uint8Array> {
|
package/src/core.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export { OpenGeniDocumentAuthorityClient as OpenGeniCoreClient } from "./document-authority-client";
|
|
3
3
|
export type {
|
|
4
4
|
FetchLike,
|
|
5
|
+
FetchResponse,
|
|
5
6
|
GetSessionOptions,
|
|
6
7
|
OpenGeniClientOptions,
|
|
7
8
|
OpenGeniRequestOptions,
|
|
@@ -13,9 +14,11 @@ export type {
|
|
|
13
14
|
export {
|
|
14
15
|
OpenGeniApiContractMismatchError,
|
|
15
16
|
OpenGeniApiError,
|
|
17
|
+
OpenGeniSecureContextRequiredError,
|
|
16
18
|
OpenGeniSessionListCursorError,
|
|
17
19
|
OpenGeniStreamError,
|
|
18
20
|
isRetryableStreamError,
|
|
19
21
|
} from "./errors";
|
|
22
|
+
export type { OpenGeniSecureContextRequiredReason } from "./errors";
|
|
20
23
|
export { resolveWorkspaceVoiceInputEnabled } from "./transcription";
|
|
21
24
|
export { OPENGENI_API_CONTRACT_HEADER, OPENGENI_API_CONTRACT_REVISION } from "./types";
|
package/src/errors.ts
CHANGED
|
@@ -49,6 +49,29 @@ export class OpenGeniApiError extends Error {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
export type OpenGeniSecureContextRequiredReason = "insecure_context" | "web_crypto_unavailable";
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A browser operation requires secure-context-only platform capabilities.
|
|
56
|
+
* Callers may key UI behavior on the stable `secure_context_required` code;
|
|
57
|
+
* `reason` exists only to keep the human guidance truthful.
|
|
58
|
+
*/
|
|
59
|
+
export class OpenGeniSecureContextRequiredError extends Error {
|
|
60
|
+
readonly code = "secure_context_required" as const;
|
|
61
|
+
readonly retryable = false;
|
|
62
|
+
readonly reason: OpenGeniSecureContextRequiredReason;
|
|
63
|
+
|
|
64
|
+
constructor(reason: OpenGeniSecureContextRequiredReason) {
|
|
65
|
+
super(
|
|
66
|
+
reason === "insecure_context"
|
|
67
|
+
? "Couldn’t attach this file because OpenGeni is open over HTTP. Attachments require a secure HTTPS connection. Open the secure site or configure HTTPS for this deployment."
|
|
68
|
+
: "Couldn’t attach this file because secure browser cryptography is unavailable. Attachments require HTTPS and Web Crypto support. Open a secure site in a supported browser or configure HTTPS for this deployment.",
|
|
69
|
+
);
|
|
70
|
+
this.name = "OpenGeniSecureContextRequiredError";
|
|
71
|
+
this.reason = reason;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
52
75
|
function decodeApiErrorBody(body: string): {
|
|
53
76
|
code: string | undefined;
|
|
54
77
|
message: string | undefined;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { OpenGeniClient } from "./client";
|
|
2
|
+
import type {
|
|
3
|
+
GitHubRepositoryBranchesResponse,
|
|
4
|
+
ListGitHubRepositoryBranchesOptions,
|
|
5
|
+
VerifyPublicGitHubRepositoryRefRequest,
|
|
6
|
+
VerifyPublicGitHubRepositoryRefResponse,
|
|
7
|
+
} from "./types";
|
|
8
|
+
|
|
9
|
+
type GitHubRepositoryRequestClient = Pick<OpenGeniClient, "requestJson">;
|
|
10
|
+
|
|
11
|
+
/** Verify one exact public github.com repository and branch/tag/SHA anonymously. */
|
|
12
|
+
export async function verifyPublicGitHubRepositoryRef(
|
|
13
|
+
client: GitHubRepositoryRequestClient,
|
|
14
|
+
workspaceId: string,
|
|
15
|
+
request: VerifyPublicGitHubRepositoryRefRequest,
|
|
16
|
+
): Promise<VerifyPublicGitHubRepositoryRefResponse> {
|
|
17
|
+
return await client.requestJson<VerifyPublicGitHubRepositoryRefResponse>(
|
|
18
|
+
"POST",
|
|
19
|
+
`/v1/workspaces/${workspaceId}/github/public-repositories/verify`,
|
|
20
|
+
request,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** List one bounded page of branch suggestions for one exact workspace App repository. */
|
|
25
|
+
export async function listGitHubRepositoryBranches(
|
|
26
|
+
client: GitHubRepositoryRequestClient,
|
|
27
|
+
workspaceId: string,
|
|
28
|
+
installationId: number,
|
|
29
|
+
repositoryId: number,
|
|
30
|
+
options: ListGitHubRepositoryBranchesOptions = {},
|
|
31
|
+
): Promise<GitHubRepositoryBranchesResponse> {
|
|
32
|
+
return await client.requestJson<GitHubRepositoryBranchesResponse>(
|
|
33
|
+
"GET",
|
|
34
|
+
`/v1/workspaces/${workspaceId}/github/installations/${installationId}/repositories/${repositoryId}/branches`,
|
|
35
|
+
undefined,
|
|
36
|
+
{
|
|
37
|
+
...(options.cursor !== undefined ? { cursor: String(options.cursor) } : {}),
|
|
38
|
+
...(options.limit !== undefined ? { limit: String(options.limit) } : {}),
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** List one bounded page of branch suggestions for one currently selected personal repository. */
|
|
44
|
+
export async function listPersonalGitHubRepositoryBranches(
|
|
45
|
+
client: GitHubRepositoryRequestClient,
|
|
46
|
+
workspaceId: string,
|
|
47
|
+
connectionId: string,
|
|
48
|
+
repositoryId: string,
|
|
49
|
+
options: ListGitHubRepositoryBranchesOptions = {},
|
|
50
|
+
): Promise<GitHubRepositoryBranchesResponse> {
|
|
51
|
+
return await client.requestJson<GitHubRepositoryBranchesResponse>(
|
|
52
|
+
"GET",
|
|
53
|
+
`/v1/workspaces/${workspaceId}/connections/${connectionId}/github/repositories/${encodeURIComponent(repositoryId)}/branches`,
|
|
54
|
+
undefined,
|
|
55
|
+
{
|
|
56
|
+
...(options.cursor !== undefined ? { cursor: String(options.cursor) } : {}),
|
|
57
|
+
...(options.limit !== undefined ? { limit: String(options.limit) } : {}),
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { OpenGeniClient } from "./artifact-client";
|
|
2
2
|
export type {
|
|
3
3
|
FetchLike,
|
|
4
|
+
FetchResponse,
|
|
4
5
|
GetSessionOptions,
|
|
5
6
|
OpenGeniClientOptions,
|
|
6
7
|
OpenGeniRequestOptions,
|
|
@@ -26,12 +27,15 @@ export type {
|
|
|
26
27
|
export {
|
|
27
28
|
OpenGeniApiContractMismatchError,
|
|
28
29
|
OpenGeniApiError,
|
|
30
|
+
OpenGeniSecureContextRequiredError,
|
|
29
31
|
OpenGeniSessionListCursorError,
|
|
30
32
|
OpenGeniStreamError,
|
|
31
33
|
isRetryableStreamError,
|
|
32
34
|
} from "./errors";
|
|
35
|
+
export type { OpenGeniSecureContextRequiredReason } from "./errors";
|
|
33
36
|
export {
|
|
34
37
|
AUTOMATIC_SESSION_TITLE_FALLBACK,
|
|
38
|
+
deriveAutomaticSessionTitlePreview,
|
|
35
39
|
deriveSessionDisplayTitle,
|
|
36
40
|
sessionTitleIsPending,
|
|
37
41
|
} from "./session-titles";
|
|
@@ -134,7 +138,7 @@ export {
|
|
|
134
138
|
TtydClientCommand,
|
|
135
139
|
TtydServerCommand,
|
|
136
140
|
} from "./terminal";
|
|
137
|
-
export { streamSessionEvents } from "./stream";
|
|
141
|
+
export { sessionEventStreamCoveredThrough, streamSessionEvents } from "./stream";
|
|
138
142
|
export type {
|
|
139
143
|
SessionEventStreamTransport,
|
|
140
144
|
StreamConnectionState,
|
|
@@ -478,6 +482,7 @@ export type {
|
|
|
478
482
|
EndSessionRealtimeRequest,
|
|
479
483
|
ModelAvailabilityV1,
|
|
480
484
|
ModelBillingAttributionV1,
|
|
485
|
+
ModelCostClassV1,
|
|
481
486
|
ModelCapabilitiesV1,
|
|
482
487
|
ModelCapabilityStateV1,
|
|
483
488
|
ModelCapabilitySupportV1,
|
|
@@ -493,6 +498,22 @@ export type {
|
|
|
493
498
|
SessionRealtimeState,
|
|
494
499
|
WorkspaceModelCatalogModel,
|
|
495
500
|
WorkspaceModelCatalogResponse,
|
|
501
|
+
WorkspaceGatewayCustomModel,
|
|
502
|
+
WorkspaceGatewayCustomModelsResponse,
|
|
503
|
+
CreateWorkspaceGatewayCustomModelRequest,
|
|
504
|
+
DeleteWorkspaceGatewayCustomModelRequest,
|
|
505
|
+
WorkspaceOpenRouterCustomModel,
|
|
506
|
+
WorkspaceOpenRouterCustomModelsResponse,
|
|
507
|
+
CreateWorkspaceOpenRouterCustomModelRequest,
|
|
508
|
+
DeleteWorkspaceOpenRouterCustomModelRequest,
|
|
509
|
+
OrganizationModelProviderKind,
|
|
510
|
+
OrganizationModelProviderConnection,
|
|
511
|
+
UpsertOrganizationModelProviderConnectionRequest,
|
|
512
|
+
RevokeOrganizationModelProviderConnectionRequest,
|
|
513
|
+
OrganizationProviderCustomModel,
|
|
514
|
+
OrganizationProviderCustomModelsResponse,
|
|
515
|
+
CreateOrganizationProviderCustomModelRequest,
|
|
516
|
+
DeleteOrganizationProviderCustomModelRequest,
|
|
496
517
|
WorkspaceModelAccessPolicy,
|
|
497
518
|
WorkspaceRealtimeModelCatalogItem,
|
|
498
519
|
WorkspaceRealtimeModelCatalogResponse,
|
|
@@ -542,6 +563,7 @@ export type {
|
|
|
542
563
|
PersonalGitHubDisconnectRequest,
|
|
543
564
|
PersonalGitHubOAuthStartRequest,
|
|
544
565
|
PersonalGitHubOAuthStartResponse,
|
|
566
|
+
ListGitHubRepositoryBranchesOptions,
|
|
545
567
|
ListPersonalGitHubRepositoriesOptions,
|
|
546
568
|
ListPersonalGitHubRepositoriesResponse,
|
|
547
569
|
PersonalGitHubRepository,
|
|
@@ -644,6 +666,10 @@ export type {
|
|
|
644
666
|
GitHubBindingStatus,
|
|
645
667
|
GitHubInstallationBinding,
|
|
646
668
|
GitHubInstallationLifecycle,
|
|
669
|
+
GitHubRepositoryBranch,
|
|
670
|
+
GitHubRepositoryBranchesResponse,
|
|
671
|
+
VerifyPublicGitHubRepositoryRefRequest,
|
|
672
|
+
VerifyPublicGitHubRepositoryRefResponse,
|
|
647
673
|
GitHubRepositoriesResponse,
|
|
648
674
|
GoogleDriveBrowseItem,
|
|
649
675
|
GoogleDriveBrowseResponse,
|