@opengeni/core 0.20.13 → 0.21.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.
@@ -7,7 +7,7 @@ import type { Observability } from "@opengeni/observability";
7
7
  import type { createObjectStorage } from "@opengeni/storage";
8
8
  import type { ManagedAuth } from "./managed-auth-type";
9
9
  import type { ApiSandboxClient, ResumeBoxByIdInput, ResumedSandboxSession } from "./sandbox-types";
10
- import type { TranscriptionService } from "./transcription";
10
+ import type { TranscriptionSegmenter, TranscriptionService } from "./transcription";
11
11
  export type SessionWorkflowClient = {
12
12
  signalUserMessage: (input: {
13
13
  sessionId: string;
@@ -113,6 +113,8 @@ export type AppDependencies = {
113
113
  oauthCallbackDeadlineMs?: number;
114
114
  /** Optional host-owned voice-input transcription service. */
115
115
  transcription?: TranscriptionService | null;
116
+ /** Optional host-owned long-form audio normalization/segmentation service. */
117
+ transcriptionSegmenter?: TranscriptionSegmenter | null;
116
118
  sandboxClient?: ApiSandboxClient;
117
119
  /**
118
120
  * Resume a box by id from a serialized resume_state envelope (the lease's
@@ -45,12 +45,17 @@ export declare function disableCapability(input: {
45
45
  }): Promise<CapabilityInstallation>;
46
46
  export declare function settingsWithEnabledCapabilityMcpServers(db: Database, workspaceId: string, settings: Settings): Promise<Settings>;
47
47
  /**
48
- * Register Codex Apps as an optional runtime MCP when the deployment enables
49
- * it. Registration only makes the server selectable; the session tool policy
50
- * decides whether the model sees it, and Codex credential resolution
51
- * independently decides whether calls can authenticate.
48
+ * Resolve executable Apps authority. The connector must remain active and its
49
+ * exact owner must still hold workspace connection-management permission.
52
50
  */
53
- export declare function settingsWithCodexAppsMcpServer(settings: Settings): Settings;
51
+ export declare function resolveCodexAppsCredentialIdForRun(db: Database, workspaceId: string): Promise<string | null>;
52
+ /**
53
+ * Register Codex Apps as an optional runtime MCP only when the deployment is
54
+ * enabled and this workspace has an active explicit Apps designation.
55
+ * Registration only makes the server selectable; session policy decides
56
+ * whether the model sees it.
57
+ */
58
+ export declare function settingsWithCodexAppsMcpServer(settings: Settings, credentialAvailable: boolean): Settings;
54
59
  export declare function settingsWithMcpCapabilityServers(settings: Settings, enabled: EnabledMcpCapabilityServer[]): Settings;
55
60
  export declare function discoverMcpRegistryCapabilities(input: {
56
61
  query?: string;
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ var SESSION_WORKFLOW_WAKE_DISPATCHER_WORKFLOW_TYPE = "sessionWorkflowWakeDispatc
4
4
  var SESSION_WORKFLOW_WAKE_DISPATCHER_PERIOD_MS = 1e4;
5
5
 
6
6
  // src/transcription.ts
7
+ var TRANSCRIPTION_PROVIDER_REQUEST_TIMEOUT_MILLISECONDS = 10 * 60 * 1e3;
7
8
  var TranscriptionServiceError = class extends Error {
8
9
  code;
9
10
  status;
@@ -1383,6 +1384,8 @@ import {
1383
1384
  getCapabilityCatalogItem,
1384
1385
  getCapabilityInstallation,
1385
1386
  getConnectionMetadata,
1387
+ getCodexAppsCredentialAuthorizationForRun,
1388
+ getWorkspaceGrant as getWorkspaceGrant2,
1386
1389
  getPackInstallation,
1387
1390
  getStoredCapabilityHeaderCiphertext,
1388
1391
  getVariableSet as getVariableSet2,
@@ -1792,6 +1795,11 @@ async function createCatalogItem(input) {
1792
1795
  message: "skill ids are managed by the OpenGeni skill library or runtime adapters"
1793
1796
  });
1794
1797
  }
1798
+ if (input.payload.kind === "mcp" && typeof input.payload.metadata.mcpServerId === "string" && input.payload.metadata.mcpServerId.trim() === CODEX_APPS_MCP_SERVER_ID) {
1799
+ throw new HTTPException6(422, {
1800
+ message: `${CODEX_APPS_MCP_SERVER_ID} is reserved for the canonical Codex Apps service`
1801
+ });
1802
+ }
1795
1803
  const source = input.payload.source === "built_in" || input.payload.source === "library" || input.payload.source === "configured" || input.payload.source === "registry" ? "manual" : input.payload.source;
1796
1804
  const metadata = {
1797
1805
  ...input.payload.metadata,
@@ -2236,26 +2244,45 @@ async function disableCapability(input) {
2236
2244
  return await disableCapabilityInstallation(input.db, input.workspaceId, item.id);
2237
2245
  }
2238
2246
  async function settingsWithEnabledCapabilityMcpServers(db, workspaceId, settings) {
2239
- const enabled = await listEnabledMcpCapabilityServers(db, workspaceId);
2240
- return settingsWithCodexAppsMcpServer(settingsWithMcpCapabilityServers(settings, enabled));
2247
+ const [enabled, codexAppsCredentialId] = await Promise.all([
2248
+ listEnabledMcpCapabilityServers(db, workspaceId),
2249
+ resolveCodexAppsCredentialIdForRun(db, workspaceId)
2250
+ ]);
2251
+ return settingsWithCodexAppsMcpServer(
2252
+ settingsWithMcpCapabilityServers(settings, enabled),
2253
+ codexAppsCredentialId !== null
2254
+ );
2241
2255
  }
2242
- function settingsWithCodexAppsMcpServer(settings) {
2243
- if (!settings.codexConnectedAppsEnabled || settings.mcpServers.some((server) => server.id === CODEX_APPS_MCP_SERVER_ID)) {
2256
+ async function resolveCodexAppsCredentialIdForRun(db, workspaceId) {
2257
+ const authorization = await getCodexAppsCredentialAuthorizationForRun(db, workspaceId);
2258
+ if (!authorization) return null;
2259
+ const grant = await getWorkspaceGrant2(db, authorization.ownerSubjectId, workspaceId);
2260
+ return grant && hasPermission(grant.permissions, "connections:write") ? authorization.credentialId : null;
2261
+ }
2262
+ function settingsWithCodexAppsMcpServer(settings, credentialAvailable) {
2263
+ const canonicalServer = {
2264
+ id: CODEX_APPS_MCP_SERVER_ID,
2265
+ name: CODEX_APPS_MCP_SERVER_NAME,
2266
+ url: CODEX_APPS_MCP_URL,
2267
+ timeoutMs: CODEX_APPS_STARTUP_TIMEOUT_MS,
2268
+ // Availability is credential-specific, so discover on every run.
2269
+ cacheToolsList: false
2270
+ };
2271
+ const withoutReservedId = settings.mcpServers.filter(
2272
+ (server) => server.id !== CODEX_APPS_MCP_SERVER_ID
2273
+ );
2274
+ if (!settings.codexConnectedAppsEnabled || !credentialAvailable) {
2275
+ return withoutReservedId.length === settings.mcpServers.length ? settings : { ...settings, mcpServers: withoutReservedId };
2276
+ }
2277
+ const existing = settings.mcpServers.at(-1);
2278
+ if (withoutReservedId.length === settings.mcpServers.length - 1 && existing !== void 0 && Object.keys(existing).length === Object.keys(canonicalServer).length && Object.entries(canonicalServer).every(
2279
+ ([key, value]) => existing[key] === value
2280
+ )) {
2244
2281
  return settings;
2245
2282
  }
2246
2283
  return {
2247
2284
  ...settings,
2248
- mcpServers: [
2249
- ...settings.mcpServers,
2250
- {
2251
- id: CODEX_APPS_MCP_SERVER_ID,
2252
- name: CODEX_APPS_MCP_SERVER_NAME,
2253
- url: CODEX_APPS_MCP_URL,
2254
- timeoutMs: CODEX_APPS_STARTUP_TIMEOUT_MS,
2255
- // Availability is credential-specific, so discover on every run.
2256
- cacheToolsList: false
2257
- }
2258
- ]
2285
+ mcpServers: [...withoutReservedId, canonicalServer]
2259
2286
  };
2260
2287
  }
2261
2288
  function settingsWithMcpCapabilityServers(settings, enabled) {
@@ -3229,7 +3256,7 @@ async function listRigChangesForApi(deps, workspaceId, rigId, limit) {
3229
3256
  import {
3230
3257
  getSessionTurnPersonalConnectionDelegations,
3231
3258
  getSocialConnection,
3232
- getWorkspaceGrant as getWorkspaceGrant2,
3259
+ getWorkspaceGrant as getWorkspaceGrant3,
3233
3260
  listConnectionsMetadata as listConnectionsMetadata2,
3234
3261
  listSocialConnections as listSocialConnections2
3235
3262
  } from "@opengeni/db";
@@ -3282,7 +3309,7 @@ async function authorizedSocialConnectionsForGrant(input) {
3282
3309
  )).filter((item) => item.connectionType === "social");
3283
3310
  const personal = [];
3284
3311
  for (const delegation of delegations) {
3285
- if (!await getWorkspaceGrant2(input.db, delegation.ownerSubjectId, input.grant.workspaceId))
3312
+ if (!await getWorkspaceGrant3(input.db, delegation.ownerSubjectId, input.grant.workspaceId))
3286
3313
  continue;
3287
3314
  const connection = await getSocialConnection(
3288
3315
  input.db,
@@ -3421,7 +3448,7 @@ async function freezePersonalConnectionDelegations(input) {
3421
3448
  });
3422
3449
  return includeSocial ? inherited : inherited.filter((item) => item.connectionType !== "social");
3423
3450
  }
3424
- const membership = await getWorkspaceGrant2(input.db, input.source.subjectId, input.workspaceId);
3451
+ const membership = await getWorkspaceGrant3(input.db, input.source.subjectId, input.workspaceId);
3425
3452
  if (!membership) return [];
3426
3453
  const mcp = personalConnectionDelegationsFromVisibleConnections({
3427
3454
  servers,
@@ -7096,6 +7123,7 @@ export {
7096
7123
  SessionAuthorizationDeniedError,
7097
7124
  SessionAuthorizationUnavailableError,
7098
7125
  SessionSpawnDeniedError,
7126
+ TRANSCRIPTION_PROVIDER_REQUEST_TIMEOUT_MILLISECONDS,
7099
7127
  TranscriptionServiceError,
7100
7128
  acceptSessionUserMessage,
7101
7129
  accessGrantAuthorizationFromContext,
@@ -7205,6 +7233,7 @@ export {
7205
7233
  requireVariableSetEncryption,
7206
7234
  requireVariableSetForApi,
7207
7235
  resolveCapabilityPack,
7236
+ resolveCodexAppsCredentialIdForRun,
7208
7237
  resolveFirstPartyMcpToolsForCreate,
7209
7238
  resolveMemberSubjectId,
7210
7239
  resolveSessionToolPolicy,