@opengeni/api-router 4.2.1-canary.39642758903001 → 4.3.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/dist/app.js +1 -1
- package/dist/{chunk-3WOFRCYO.js → chunk-CFZCR2OW.js} +99 -24
- package/dist/{chunk-3WOFRCYO.js.map → chunk-CFZCR2OW.js.map} +1 -1
- package/dist/index.js +1 -1
- package/package.json +24 -24
- package/src/integrations/oauth-client.ts +18 -21
- package/src/routes/model-connection-access.ts +27 -0
- package/src/routes/organization-model-providers.ts +57 -9
- package/src/routes/workspaces.ts +13 -1
package/dist/app.js
CHANGED
|
@@ -20813,10 +20813,10 @@ import {
|
|
|
20813
20813
|
selectCanonicalPersonalSlackConnection
|
|
20814
20814
|
} from "@opengeni/contracts";
|
|
20815
20815
|
import {
|
|
20816
|
-
connectMcpStreamableHttpClient,
|
|
20817
20816
|
integrationKeyForConnectProvider,
|
|
20818
20817
|
legacyMcpClientError,
|
|
20819
|
-
requireEnvironmentEncryption as requireEnvironmentEncryption4
|
|
20818
|
+
requireEnvironmentEncryption as requireEnvironmentEncryption4,
|
|
20819
|
+
withMcpStreamableHttpClient
|
|
20820
20820
|
} from "@opengeni/core";
|
|
20821
20821
|
import { ExternalActorContinuation } from "@opengeni/contracts/external-identities";
|
|
20822
20822
|
import {
|
|
@@ -23150,9 +23150,8 @@ async function oauthErrorFromResponse(response, signal) {
|
|
|
23150
23150
|
return error;
|
|
23151
23151
|
}
|
|
23152
23152
|
async function verifyMcpToolsList(settings, resource, token, signal) {
|
|
23153
|
-
|
|
23154
|
-
|
|
23155
|
-
client = await connectMcpStreamableHttpClient({
|
|
23153
|
+
const listed2 = await withMcpStreamableHttpClient(
|
|
23154
|
+
{
|
|
23156
23155
|
url: resource,
|
|
23157
23156
|
clientName: "opengeni-integration-verify",
|
|
23158
23157
|
clientVersion: "0.1.0",
|
|
@@ -23166,20 +23165,18 @@ async function verifyMcpToolsList(settings, resource, token, signal) {
|
|
|
23166
23165
|
...init,
|
|
23167
23166
|
signal: init?.signal ? AbortSignal.any([signal, init.signal]) : signal
|
|
23168
23167
|
})
|
|
23169
|
-
}
|
|
23170
|
-
|
|
23168
|
+
},
|
|
23169
|
+
(client) => client.listTools(void 0, {
|
|
23171
23170
|
timeout: 1e4,
|
|
23172
23171
|
maxTotalTimeout: 1e4
|
|
23173
23172
|
}).catch((error) => {
|
|
23174
23173
|
throw legacyMcpClientError(error);
|
|
23175
|
-
})
|
|
23176
|
-
|
|
23177
|
-
|
|
23178
|
-
|
|
23179
|
-
}
|
|
23180
|
-
}
|
|
23181
|
-
await client?.close().catch(() => void 0);
|
|
23182
|
-
}
|
|
23174
|
+
})
|
|
23175
|
+
);
|
|
23176
|
+
return listed2.tools.map((tool) => ({
|
|
23177
|
+
name: tool.name,
|
|
23178
|
+
...tool.description ? { description: tool.description } : {}
|
|
23179
|
+
}));
|
|
23183
23180
|
}
|
|
23184
23181
|
async function verifyMcpToolsListNonFatal(observability, settings, state, token, deadline) {
|
|
23185
23182
|
let grantRejected = false;
|
|
@@ -65898,7 +65895,9 @@ import {
|
|
|
65898
65895
|
withXaiSubscriptionCatalogProvider,
|
|
65899
65896
|
withOrganizationGatewayCatalogProvider,
|
|
65900
65897
|
withOrganizationOpenRouterCatalogProvider,
|
|
65901
|
-
withOrganizationOpperCatalogProvider
|
|
65898
|
+
withOrganizationOpperCatalogProvider,
|
|
65899
|
+
withOrganizationDirectCatalogProvider,
|
|
65900
|
+
organizationDirectModelIdPrefix
|
|
65902
65901
|
} from "@opengeni/config";
|
|
65903
65902
|
import { ModelConnectionAccessPolicy as ModelConnectionAccessPolicy2, ModelConnectionAccessResponse } from "@opengeni/contracts";
|
|
65904
65903
|
import {
|
|
@@ -65921,6 +65920,7 @@ import {
|
|
|
65921
65920
|
updateSubscriptionCoreProviderModelConnectionAccess,
|
|
65922
65921
|
getOrganizationAdministrationOverview,
|
|
65923
65922
|
listOrganizationModelProviderCustomModels,
|
|
65923
|
+
getOrganizationModelProviderConnection,
|
|
65924
65924
|
getWorkspaceProviderApiKeyConnectionMetadata as getWorkspaceProviderApiKeyConnectionMetadata2
|
|
65925
65925
|
} from "@opengeni/db";
|
|
65926
65926
|
import { HTTPException as HTTPException56 } from "hono/http-exception";
|
|
@@ -65932,9 +65932,13 @@ var Kind2 = z33.enum([
|
|
|
65932
65932
|
"openrouter",
|
|
65933
65933
|
"anthropic",
|
|
65934
65934
|
"claude_subscription",
|
|
65935
|
-
"opper"
|
|
65935
|
+
"opper",
|
|
65936
|
+
"openai",
|
|
65937
|
+
"azure_openai"
|
|
65936
65938
|
]);
|
|
65937
65939
|
function modelPrefix(target) {
|
|
65940
|
+
if (target.kind === "openai" || target.kind === "azure_openai")
|
|
65941
|
+
return organizationDirectModelIdPrefix(target.kind);
|
|
65938
65942
|
if (target.kind === "anthropic" || target.kind === "claude_subscription")
|
|
65939
65943
|
return claudeProviderId2(target.kind, target.workspaceId === null ? "organization" : "workspace") + "/";
|
|
65940
65944
|
if (target.kind === "codex" || target.kind === "supergrok") return `${target.kind}/`;
|
|
@@ -65973,6 +65977,8 @@ function registerModelConnectionAccessRoutes(app, deps) {
|
|
|
65973
65977
|
core: await coreAccessDisposition(deps, kind, scopeId) === "core"
|
|
65974
65978
|
};
|
|
65975
65979
|
}
|
|
65980
|
+
if (kind === "openai" || kind === "azure_openai")
|
|
65981
|
+
throw new HTTPException56(404, { message: "Connection not found" });
|
|
65976
65982
|
const grant = await requireAccessGrant20(c, deps, scopeId, "workspace:read");
|
|
65977
65983
|
const sharedCore = (kind === "supergrok" || kind === "claude_subscription") && await coreAccessDisposition(deps, kind, grant.accountId) === "core";
|
|
65978
65984
|
if (mutate2) {
|
|
@@ -66038,6 +66044,22 @@ function registerModelConnectionAccessRoutes(app, deps) {
|
|
|
66038
66044
|
});
|
|
66039
66045
|
settings = connection.kind === "vercel_gateway" ? withOrganizationGatewayCatalogProvider(settings, models) : connection.kind === "opper" ? withOrganizationOpperCatalogProvider(settings, models) : withOrganizationOpenRouterCatalogProvider(settings, models);
|
|
66040
66046
|
}
|
|
66047
|
+
if (connection.kind === "openai" || connection.kind === "azure_openai") {
|
|
66048
|
+
const [models, direct] = await Promise.all([
|
|
66049
|
+
listOrganizationModelProviderCustomModels(deps.db, {
|
|
66050
|
+
...actor,
|
|
66051
|
+
providerKind: connection.kind
|
|
66052
|
+
}),
|
|
66053
|
+
getOrganizationModelProviderConnection(deps.db, {
|
|
66054
|
+
...actor,
|
|
66055
|
+
providerKind: connection.kind
|
|
66056
|
+
})
|
|
66057
|
+
]);
|
|
66058
|
+
settings = withOrganizationDirectCatalogProvider(settings, connection.kind, {
|
|
66059
|
+
endpoint: direct?.endpoint ?? null,
|
|
66060
|
+
models
|
|
66061
|
+
});
|
|
66062
|
+
}
|
|
66041
66063
|
}
|
|
66042
66064
|
const people = organizationCore && coreAccess?.peopleSupported ? await listOrganizationAdministrationMembers(deps.db, {
|
|
66043
66065
|
organizationId: connection.accountId,
|
|
@@ -97457,6 +97479,7 @@ function ifNoneMatchSatisfied(header2, etag) {
|
|
|
97457
97479
|
import { claudeProviderId as claudeProviderId3, opperCredentialProblem } from "@opengeni/config";
|
|
97458
97480
|
import {
|
|
97459
97481
|
CreateOrganizationProviderCustomModelRequest as CreateOrganizationProviderCustomModelRequest2,
|
|
97482
|
+
DirectModelName,
|
|
97460
97483
|
DeleteOrganizationProviderCustomModelRequest as DeleteOrganizationProviderCustomModelRequest2,
|
|
97461
97484
|
OrganizationModelProviderConnectionResponse,
|
|
97462
97485
|
OrganizationModelProviderKind as OrganizationModelProviderKind2,
|
|
@@ -97465,12 +97488,16 @@ import {
|
|
|
97465
97488
|
RevokeOrganizationModelProviderConnectionRequest as RevokeOrganizationModelProviderConnectionRequest2,
|
|
97466
97489
|
UpsertOrganizationModelProviderConnectionRequest as UpsertOrganizationModelProviderConnectionRequest2
|
|
97467
97490
|
} from "@opengeni/contracts";
|
|
97468
|
-
import {
|
|
97491
|
+
import {
|
|
97492
|
+
requireEnvironmentEncryption as requireEnvironmentEncryption10,
|
|
97493
|
+
verifyOrganizationDirectModel
|
|
97494
|
+
} from "@opengeni/core";
|
|
97469
97495
|
import {
|
|
97470
97496
|
createOrganizationModelProviderCustomModel,
|
|
97471
97497
|
encryptEnvironmentValue as encryptEnvironmentValue12,
|
|
97472
|
-
getOrganizationModelProviderConnection,
|
|
97498
|
+
getOrganizationModelProviderConnection as getOrganizationModelProviderConnection2,
|
|
97473
97499
|
listOrganizationModelProviderCustomModels as listOrganizationModelProviderCustomModels2,
|
|
97500
|
+
loadOrganizationModelProviderCredentialForAdministrator,
|
|
97474
97501
|
organizationModelProviderCredentialDigest,
|
|
97475
97502
|
OrganizationModelProviderConflictError,
|
|
97476
97503
|
OrganizationModelProviderLimitError,
|
|
@@ -97502,8 +97529,10 @@ function modelProviderKind(value) {
|
|
|
97502
97529
|
return kind;
|
|
97503
97530
|
}
|
|
97504
97531
|
function connectionJson(connection) {
|
|
97532
|
+
const { endpoint, ...rest } = connection;
|
|
97505
97533
|
return OrganizationModelProviderConnectionResponse.parse({
|
|
97506
|
-
...
|
|
97534
|
+
...rest,
|
|
97535
|
+
...endpoint ? { endpoint } : {},
|
|
97507
97536
|
createdAt: connection.createdAt.toISOString(),
|
|
97508
97537
|
updatedAt: connection.updatedAt.toISOString()
|
|
97509
97538
|
});
|
|
@@ -97541,7 +97570,7 @@ function registerOrganizationModelProviderRoutes(app, deps) {
|
|
|
97541
97570
|
const human = await requireOrganizationCodexHuman(c, deps, organizationId2);
|
|
97542
97571
|
if (c.req.param("providerKind") === "claude_subscription")
|
|
97543
97572
|
throw new HTTPException58(410, { message: "Claude subscriptions use individual accounts." });
|
|
97544
|
-
const connection = await
|
|
97573
|
+
const connection = await getOrganizationModelProviderConnection2(deps.db, {
|
|
97545
97574
|
organizationId: organizationId2,
|
|
97546
97575
|
actorSubjectId: human.subjectId,
|
|
97547
97576
|
providerKind: providerKind(c.req.param("providerKind"))
|
|
@@ -97590,6 +97619,14 @@ function registerOrganizationModelProviderRoutes(app, deps) {
|
|
|
97590
97619
|
});
|
|
97591
97620
|
const opperProblem = kind === "opper" ? opperCredentialProblem(payload.apiKey) : null;
|
|
97592
97621
|
if (opperProblem) throw new HTTPException58(422, { message: opperProblem });
|
|
97622
|
+
if (kind === "azure_openai" && !payload.endpoint)
|
|
97623
|
+
throw new HTTPException58(422, {
|
|
97624
|
+
message: "Enter your Azure OpenAI resource endpoint (https://RESOURCE.openai.azure.com)."
|
|
97625
|
+
});
|
|
97626
|
+
if (kind !== "azure_openai" && payload.endpoint !== void 0)
|
|
97627
|
+
throw new HTTPException58(422, {
|
|
97628
|
+
message: "An endpoint is only valid for an Azure OpenAI connection."
|
|
97629
|
+
});
|
|
97593
97630
|
if (payload.claudeIdentity)
|
|
97594
97631
|
throw new HTTPException58(422, {
|
|
97595
97632
|
message: "Claude identity is only valid for subscription connections."
|
|
@@ -97605,6 +97642,7 @@ function registerOrganizationModelProviderRoutes(app, deps) {
|
|
|
97605
97642
|
credential
|
|
97606
97643
|
),
|
|
97607
97644
|
credentialDigest: organizationModelProviderCredentialDigest(credential),
|
|
97645
|
+
...kind === "azure_openai" ? { endpoint: payload.endpoint ?? null } : {},
|
|
97608
97646
|
operationId: payload.operationId,
|
|
97609
97647
|
...payload.expectedVersion === void 0 ? {} : { expectedVersion: payload.expectedVersion }
|
|
97610
97648
|
});
|
|
@@ -97674,6 +97712,31 @@ function registerOrganizationModelProviderRoutes(app, deps) {
|
|
|
97674
97712
|
const kind = modelProviderKind(c.req.param("providerKind"));
|
|
97675
97713
|
if ((kind === "anthropic" || kind === "claude_subscription") && `${claudeProviderId3(kind)}/${payload.upstreamModelId}`.length > 256)
|
|
97676
97714
|
throw new HTTPException58(422, { message: "Claude model ID is too long" });
|
|
97715
|
+
if (kind === "openai" || kind === "azure_openai") {
|
|
97716
|
+
const title = kind === "openai" ? "OpenAI" : "Azure OpenAI";
|
|
97717
|
+
if (!DirectModelName.safeParse(payload.upstreamModelId).success)
|
|
97718
|
+
throw new HTTPException58(422, {
|
|
97719
|
+
message: kind === "openai" ? "Enter the exact OpenAI model ID." : "Enter the exact Azure OpenAI deployment name."
|
|
97720
|
+
});
|
|
97721
|
+
const credential = await loadOrganizationModelProviderCredentialForAdministrator(
|
|
97722
|
+
deps.db,
|
|
97723
|
+
deps.settings,
|
|
97724
|
+
{ organizationId: organizationId2, actorSubjectId: human.subjectId, providerKind: kind }
|
|
97725
|
+
);
|
|
97726
|
+
if (!credential || kind === "azure_openai" && !credential.endpoint)
|
|
97727
|
+
throw new HTTPException58(409, {
|
|
97728
|
+
message: `Connect ${title} for the organization before adding ${kind === "openai" ? "models" : "deployments"}.`
|
|
97729
|
+
});
|
|
97730
|
+
await verifyOrganizationDirectModel(
|
|
97731
|
+
kind === "openai" ? { provider: "openai", model: payload.upstreamModelId } : {
|
|
97732
|
+
provider: "azure_openai",
|
|
97733
|
+
model: payload.upstreamModelId,
|
|
97734
|
+
endpoint: credential.endpoint
|
|
97735
|
+
},
|
|
97736
|
+
credential.apiKey,
|
|
97737
|
+
deps.directModelFetch
|
|
97738
|
+
);
|
|
97739
|
+
}
|
|
97677
97740
|
try {
|
|
97678
97741
|
const model = await createOrganizationModelProviderCustomModel(deps.db, {
|
|
97679
97742
|
organizationId: organizationId2,
|
|
@@ -128879,7 +128942,8 @@ function registerWorkspaceRoutes(app, deps) {
|
|
|
128879
128942
|
getOrganizationModelProviderCatalogForWorkspace(deps.db, {
|
|
128880
128943
|
accountId: grant.accountId,
|
|
128881
128944
|
workspaceId,
|
|
128882
|
-
|
|
128945
|
+
// Organization Azure OpenAI has no workspace custom-model rail.
|
|
128946
|
+
providerKinds: [...providerKinds, "openai", "azure_openai"]
|
|
128883
128947
|
}),
|
|
128884
128948
|
getWorkspace7(deps.db, workspaceId),
|
|
128885
128949
|
getOrganizationModelDefaults3(deps.db, grant.accountId),
|
|
@@ -128926,7 +128990,18 @@ function registerWorkspaceRoutes(app, deps) {
|
|
|
128926
128990
|
workspaceOpperConnectionActive: workspaceConnectionActive("opper"),
|
|
128927
128991
|
workspaceOpperCustomModels: workspaceCustomModels.opper,
|
|
128928
128992
|
organizationOpperConnectionActive: organizationProviders.opper.active,
|
|
128929
|
-
organizationOpperCustomModels: organizationProviders.opper.models
|
|
128993
|
+
organizationOpperCustomModels: organizationProviders.opper.models,
|
|
128994
|
+
organizationDirect: {
|
|
128995
|
+
openai: {
|
|
128996
|
+
active: organizationProviders.openai?.active === true,
|
|
128997
|
+
models: organizationProviders.openai?.models ?? []
|
|
128998
|
+
},
|
|
128999
|
+
azure_openai: {
|
|
129000
|
+
active: organizationProviders.azure_openai?.active === true,
|
|
129001
|
+
endpoint: organizationProviders.azure_openai?.endpoint ?? null,
|
|
129002
|
+
models: organizationProviders.azure_openai?.models ?? []
|
|
129003
|
+
}
|
|
129004
|
+
}
|
|
128930
129005
|
});
|
|
128931
129006
|
const workspaceSettings = workspace?.settings ?? {};
|
|
128932
129007
|
const defaultSelection = await resolveDefaultSessionModelForSelections(deps.db, {
|
|
@@ -151955,4 +152030,4 @@ export {
|
|
|
151955
152030
|
withDefaultEnabledCapabilityMcpTools,
|
|
151956
152031
|
workflowIdForSession4 as workflowIdForSession
|
|
151957
152032
|
};
|
|
151958
|
-
//# sourceMappingURL=chunk-
|
|
152033
|
+
//# sourceMappingURL=chunk-CFZCR2OW.js.map
|