@opengeni/db 0.22.1 → 0.22.2

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.d.ts CHANGED
@@ -1476,6 +1476,9 @@ export declare function loadConnectionCredentialForBroker(db: Database, settings
1476
1476
  subjectId?: string | null;
1477
1477
  allowSubjectOwned?: boolean;
1478
1478
  }): Promise<ConnectionCredentialForBroker | null>;
1479
+ export declare function workspaceVercelAiGatewayConnectionActive(db: Database, workspaceId: string): Promise<boolean>;
1480
+ /** Resolve only the reviewed workspace-shared AI Gateway credential shape. */
1481
+ export declare function loadWorkspaceVercelAiGatewayApiKey(db: Database, settings: Settings, workspaceId: string): Promise<string | null>;
1479
1482
  export declare function recordConnectionTokenRefresh(db: Database, input: {
1480
1483
  id: string;
1481
1484
  version: number;
package/dist/index.js CHANGED
@@ -174,7 +174,11 @@ import {
174
174
  SubmitHumanInputResponseRequest,
175
175
  TurnExecutionPolicyV1
176
176
  } from "@opengeni/contracts";
177
- import { environmentsEncryptionKeyBytes as environmentsEncryptionKeyBytes3 } from "@opengeni/config";
177
+ import {
178
+ environmentsEncryptionKeyBytes as environmentsEncryptionKeyBytes3,
179
+ VERCEL_AI_GATEWAY_CONNECTION_DOMAIN,
180
+ VERCEL_AI_GATEWAY_CONNECTION_ROLE
181
+ } from "@opengeni/config";
178
182
  import { boundModelToolOutputItem as boundModelToolOutputItem2, isCodexBilledModel } from "@opengeni/codex";
179
183
  import { isCodexBilledModel as isCodexBilledModel2 } from "@opengeni/codex";
180
184
  import {
@@ -14016,6 +14020,32 @@ async function loadConnectionCredentialForBroker(db, settings, input) {
14016
14020
  }
14017
14021
  );
14018
14022
  }
14023
+ async function workspaceVercelAiGatewayConnectionActive(db, workspaceId) {
14024
+ const connections2 = await listConnectionsMetadata(db, workspaceId, null);
14025
+ return connections2.some(
14026
+ (connection) => connection.subjectId === null && connection.providerDomain === VERCEL_AI_GATEWAY_CONNECTION_DOMAIN && connection.kind === "api_key" && connection.status === "active" && connection.metadata.credentialRole === VERCEL_AI_GATEWAY_CONNECTION_ROLE
14027
+ );
14028
+ }
14029
+ async function loadWorkspaceVercelAiGatewayApiKey(db, settings, workspaceId) {
14030
+ const metadata = (await listConnectionsMetadata(db, workspaceId, null)).find(
14031
+ (connection2) => connection2.subjectId === null && connection2.providerDomain === VERCEL_AI_GATEWAY_CONNECTION_DOMAIN && connection2.kind === "api_key" && connection2.status === "active" && connection2.metadata.credentialRole === VERCEL_AI_GATEWAY_CONNECTION_ROLE
14032
+ );
14033
+ if (!metadata) {
14034
+ return null;
14035
+ }
14036
+ const connection = await loadConnectionCredentialForBroker(db, settings, {
14037
+ workspaceId,
14038
+ connectionId: metadata.id,
14039
+ providerDomain: VERCEL_AI_GATEWAY_CONNECTION_DOMAIN,
14040
+ kind: "api_key",
14041
+ allowSubjectOwned: false
14042
+ });
14043
+ if (!connection || connection.status !== "active" || connection.metadata.credentialRole !== VERCEL_AI_GATEWAY_CONNECTION_ROLE) {
14044
+ return null;
14045
+ }
14046
+ const apiKey = connection.credential.apiKey;
14047
+ return typeof apiKey === "string" && apiKey.trim().length > 0 ? apiKey : null;
14048
+ }
14019
14049
  async function recordConnectionTokenRefresh(db, input) {
14020
14050
  return await withConnectionSubjectRls(
14021
14051
  db,
@@ -37144,6 +37174,7 @@ export {
37144
37174
  loadSocialConnectionCredential,
37145
37175
  loadVariableSetForRun,
37146
37176
  loadWorkspaceEnvironmentForRun,
37177
+ loadWorkspaceVercelAiGatewayApiKey,
37147
37178
  lockSessionEventWriteRows,
37148
37179
  lockWorkspaceInferenceControl,
37149
37180
  markFileUploadFailed,
@@ -37410,6 +37441,7 @@ export {
37410
37441
  withWorkspaceSubjectRls,
37411
37442
  withWorkspaceUsageLock,
37412
37443
  workspaceCaptureAtRevision,
37413
- workspaceCodexSubscriptionActive
37444
+ workspaceCodexSubscriptionActive,
37445
+ workspaceVercelAiGatewayConnectionActive
37414
37446
  };
37415
37447
  //# sourceMappingURL=index.js.map