@opengeni/runtime 0.11.0 → 0.13.3

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.
@@ -0,0 +1,80 @@
1
+ import { Settings } from '@opengeni/config';
2
+ import { DnsLookup, isNonPublicAddress } from '@opengeni/network';
3
+ export { undiciFetch } from '@opengeni/network';
4
+
5
+ declare const MCP_MAX_RESPONSE_BYTES: number;
6
+ declare const MCP_MAX_INBOUND_REQUEST_BYTES: number;
7
+ declare const MCP_MAX_TOOL_DEFINITION_BYTES: number;
8
+ declare const MCP_MAX_TOOL_LIST_BYTES: number;
9
+ declare const MCP_MAX_TOOL_LIST_ENTRIES = 1000;
10
+ declare const MCP_MAX_TOOL_RESULT_BYTES: number;
11
+ declare const MCP_MAX_TOOL_SEARCH_DISCLOSURE_BYTES: number;
12
+ declare const MCP_MAX_SELECTED_SERVERS = 64;
13
+ declare const MCP_MAX_CONCURRENT_SERVER_OPERATIONS = 8;
14
+ declare const MCP_DEFAULT_OUTER_CONNECT_TIMEOUT_MS = 10000;
15
+ declare const MCP_MAX_AGGREGATE_TOOL_LIST_ENTRIES = 4096;
16
+ declare const MCP_MAX_AGGREGATE_TOOL_LIST_BYTES: number;
17
+ declare const MCP_MAX_TOOL_SEARCH_SOURCES = 64;
18
+ declare const MCP_MAX_TOOL_SEARCH_SOURCE_LABEL_LENGTH = 120;
19
+ declare const MCP_MAX_TOOL_SEARCH_DESCRIPTION_BYTES: number;
20
+ declare class McpPayloadTooLargeError extends Error {
21
+ readonly label: string;
22
+ readonly actualBytes: number;
23
+ readonly maxBytes: number;
24
+ constructor(label: string, actualBytes: number, maxBytes: number);
25
+ }
26
+ declare function mcpSerializedSizeBytes(value: unknown): number;
27
+ declare function assertMcpPayloadWithinBytes(value: unknown, maxBytes: number, label: string): void;
28
+ declare function assertMcpToolListWithinBounds<T>(tools: readonly T[]): readonly T[];
29
+ declare function assertMcpServerSelectionWithinBounds<T>(servers: readonly T[]): readonly T[];
30
+ declare function mcpOuterConnectTimeoutMs(configuredTimeouts: readonly (number | undefined)[]): number;
31
+ type McpToolListContribution = {
32
+ entries: number;
33
+ bytes: number;
34
+ };
35
+ /**
36
+ * Atomic aggregate accounting shared by every exposed tools/list in one run.
37
+ * A repeated list for the same source REPLACES its prior contribution, so
38
+ * cache invalidation/relisting cannot ratchet the budget upward. Failed
39
+ * replacements leave the previous accounting intact.
40
+ */
41
+ declare class McpAggregateToolListBudget {
42
+ private readonly label;
43
+ private readonly maxEntries;
44
+ private readonly maxBytes;
45
+ private readonly contributions;
46
+ private totalEntries;
47
+ private totalBytes;
48
+ constructor(label?: string, maxEntries?: number, maxBytes?: number);
49
+ replace<T>(sourceId: string, tools: readonly T[]): readonly T[];
50
+ remove(sourceId: string): void;
51
+ snapshot(): Readonly<McpToolListContribution>;
52
+ }
53
+ /** Stable-order parallel map with a hard in-flight ceiling and fail-stop drain. */
54
+ declare function boundedParallelMap<T, R>(values: readonly T[], concurrency: number, mapper: (value: T, index: number) => Promise<R>): Promise<R[]>;
55
+ /**
56
+ * Guard normal MCP traffic with the same deployment policy as OAuth traffic.
57
+ * The pinned transport resolves and policy-checks the destination after the
58
+ * caller has composed any credential headers, then performs the final network
59
+ * call through the vetted Agent. It forces manual redirects, so an
60
+ * Authorization-bearing request never follows a provider-controlled Location
61
+ * to an unvalidated host.
62
+ *
63
+ * This module is deliberately agent-loop-free. API code imports the explicit
64
+ * `@opengeni/runtime/mcp-network` leaf rather than the runtime root barrel.
65
+ */
66
+ declare function guardedMcpFetch<TInput extends string | URL | Request>(settings: Pick<Settings, "environment" | "integrationsAllowPrivateNetworkTargets">, fetchImpl: (input: TInput, init?: RequestInit) => Promise<Response>, options?: {
67
+ maxResponseBytes?: number;
68
+ dnsLookup?: DnsLookup;
69
+ requireHttpsOutsideLocalTest?: boolean;
70
+ }): (input: TInput, init?: RequestInit) => Promise<Response>;
71
+ declare function boundMcpResponseBody(response: Response, maxBytes: number): Response;
72
+ declare function cancelMcpResponseBody(response: Response): Promise<void>;
73
+ /** Read and rebuild an inbound MCP request before the SDK parses it. */
74
+ declare function boundedMcpRequest(request: Request, maxBytes?: number): Promise<Request>;
75
+ declare function assertMcpDestinationAllowed(rawUrl: string, settings: Pick<Settings, "environment" | "integrationsAllowPrivateNetworkTargets">, options?: {
76
+ dnsLookup?: DnsLookup;
77
+ }): Promise<void>;
78
+ declare const isNonPublicMcpAddress: typeof isNonPublicAddress;
79
+
80
+ export { MCP_DEFAULT_OUTER_CONNECT_TIMEOUT_MS, MCP_MAX_AGGREGATE_TOOL_LIST_BYTES, MCP_MAX_AGGREGATE_TOOL_LIST_ENTRIES, MCP_MAX_CONCURRENT_SERVER_OPERATIONS, MCP_MAX_INBOUND_REQUEST_BYTES, MCP_MAX_RESPONSE_BYTES, MCP_MAX_SELECTED_SERVERS, MCP_MAX_TOOL_DEFINITION_BYTES, MCP_MAX_TOOL_LIST_BYTES, MCP_MAX_TOOL_LIST_ENTRIES, MCP_MAX_TOOL_RESULT_BYTES, MCP_MAX_TOOL_SEARCH_DESCRIPTION_BYTES, MCP_MAX_TOOL_SEARCH_DISCLOSURE_BYTES, MCP_MAX_TOOL_SEARCH_SOURCES, MCP_MAX_TOOL_SEARCH_SOURCE_LABEL_LENGTH, McpAggregateToolListBudget, McpPayloadTooLargeError, assertMcpDestinationAllowed, assertMcpPayloadWithinBytes, assertMcpServerSelectionWithinBounds, assertMcpToolListWithinBounds, boundMcpResponseBody, boundedMcpRequest, boundedParallelMap, cancelMcpResponseBody, guardedMcpFetch, isNonPublicMcpAddress, mcpOuterConnectTimeoutMs, mcpSerializedSizeBytes };
@@ -0,0 +1,66 @@
1
+ import {
2
+ MCP_DEFAULT_OUTER_CONNECT_TIMEOUT_MS,
3
+ MCP_MAX_AGGREGATE_TOOL_LIST_BYTES,
4
+ MCP_MAX_AGGREGATE_TOOL_LIST_ENTRIES,
5
+ MCP_MAX_CONCURRENT_SERVER_OPERATIONS,
6
+ MCP_MAX_INBOUND_REQUEST_BYTES,
7
+ MCP_MAX_RESPONSE_BYTES,
8
+ MCP_MAX_SELECTED_SERVERS,
9
+ MCP_MAX_TOOL_DEFINITION_BYTES,
10
+ MCP_MAX_TOOL_LIST_BYTES,
11
+ MCP_MAX_TOOL_LIST_ENTRIES,
12
+ MCP_MAX_TOOL_RESULT_BYTES,
13
+ MCP_MAX_TOOL_SEARCH_DESCRIPTION_BYTES,
14
+ MCP_MAX_TOOL_SEARCH_DISCLOSURE_BYTES,
15
+ MCP_MAX_TOOL_SEARCH_SOURCES,
16
+ MCP_MAX_TOOL_SEARCH_SOURCE_LABEL_LENGTH,
17
+ McpAggregateToolListBudget,
18
+ McpPayloadTooLargeError,
19
+ assertMcpDestinationAllowed,
20
+ assertMcpPayloadWithinBytes,
21
+ assertMcpServerSelectionWithinBounds,
22
+ assertMcpToolListWithinBounds,
23
+ boundMcpResponseBody,
24
+ boundedMcpRequest,
25
+ boundedParallelMap,
26
+ cancelMcpResponseBody,
27
+ guardedMcpFetch,
28
+ isNonPublicMcpAddress,
29
+ mcpOuterConnectTimeoutMs,
30
+ mcpSerializedSizeBytes,
31
+ undiciFetch
32
+ } from "./chunk-SSB7VOLE.js";
33
+ import "./chunk-PZ5AY32C.js";
34
+ export {
35
+ MCP_DEFAULT_OUTER_CONNECT_TIMEOUT_MS,
36
+ MCP_MAX_AGGREGATE_TOOL_LIST_BYTES,
37
+ MCP_MAX_AGGREGATE_TOOL_LIST_ENTRIES,
38
+ MCP_MAX_CONCURRENT_SERVER_OPERATIONS,
39
+ MCP_MAX_INBOUND_REQUEST_BYTES,
40
+ MCP_MAX_RESPONSE_BYTES,
41
+ MCP_MAX_SELECTED_SERVERS,
42
+ MCP_MAX_TOOL_DEFINITION_BYTES,
43
+ MCP_MAX_TOOL_LIST_BYTES,
44
+ MCP_MAX_TOOL_LIST_ENTRIES,
45
+ MCP_MAX_TOOL_RESULT_BYTES,
46
+ MCP_MAX_TOOL_SEARCH_DESCRIPTION_BYTES,
47
+ MCP_MAX_TOOL_SEARCH_DISCLOSURE_BYTES,
48
+ MCP_MAX_TOOL_SEARCH_SOURCES,
49
+ MCP_MAX_TOOL_SEARCH_SOURCE_LABEL_LENGTH,
50
+ McpAggregateToolListBudget,
51
+ McpPayloadTooLargeError,
52
+ assertMcpDestinationAllowed,
53
+ assertMcpPayloadWithinBytes,
54
+ assertMcpServerSelectionWithinBounds,
55
+ assertMcpToolListWithinBounds,
56
+ boundMcpResponseBody,
57
+ boundedMcpRequest,
58
+ boundedParallelMap,
59
+ cancelMcpResponseBody,
60
+ guardedMcpFetch,
61
+ isNonPublicMcpAddress,
62
+ mcpOuterConnectTimeoutMs,
63
+ mcpSerializedSizeBytes,
64
+ undiciFetch
65
+ };
66
+ //# sourceMappingURL=mcp-network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,6 @@
1
1
  export { collectSandboxEnvironment, parseExposedPorts } from '@opengeni/config';
2
2
  export { CAPABILITY_DESCRIPTORS, CapabilityDescriptor, DESKTOP_STREAM_PORT, StreamTokenPayload, StreamTokenPayload as StreamTokenPayloadType, TERMINAL_STREAM_PORT } from '@opengeni/contracts';
3
3
  import '@openai/agents/sandbox';
4
- export { A as ActiveBackendResolverDeps, b as ActiveBackendUnresolvableError, c as ActivePointer, B as BackendUnresolvableCode, C as ChannelAConflictError, d as ChannelAEmitter, e as ChannelAExecArgs, f as ChannelAExecResult, g as ChannelANotFoundError, h as ChannelASession, i as ChannelAUnavailableError, j as ChannelAUnsupportedError, k as ChannelAValidationError, l as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, m as DISPLAY_STACK_TIMEOUT_MS, n as DesktopGeometry, o as DisplayStackError, p as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, q as EnsureDisplayStackResult, r as EnsureTerminalServerOptions, s as EnsureTerminalServerResult, t as EstablishedSandboxSession, u as ExposeStreamPortInput, v as ExposeStreamPortResult, w as ExposedPortEndpoint, F as FAULT_FIELD_WHAT_HAPPENED, x as FAULT_FIELD_WHAT_PRESERVED, y as FAULT_FIELD_WHAT_TO_TRY, z as FAULT_FIELD_WHICH_LAYER, L as LiveModalSandboxLeaseAttribution, M as MaterializeRunCredentialsOptions, G as MintStreamTokenInput, H as MockAgentResponder, I as MockAgentResponderOptions, J as MockExecHandler, K as ModalModuleLoader, N as ModalOrphanSweepResult, O as ModalSandboxAttribution, P as NEVER_SENT_DETAIL_KEY, Q as NatsControlRpc, S as NatsOpStreamConnection, T as NatsOpStreamTransport, U as NatsRequestConnection, V as NegotiationContext, W as NormalizedRunCredentialMaterial, X as NumstatEntry, Y as OP_STREAM_ACK_INTERVAL_MS, Z as OP_STREAM_DEFAULT_WINDOW_BYTES, _ as OP_STREAM_RECONNECT_HOLD_MS, $ as OP_STREAM_SILENCE_TIMEOUT_MS, a0 as OpStreamExecOutcome, a1 as OpStreamJournal, a2 as OpStreamSubscription, a3 as OpStreamTransport, a4 as OpStreamUnavailableError, a5 as PROVIDER_REGISTRY, a6 as ProviderConstructionContext, a7 as ProviderRegistration, a8 as REPOSITORY_DISCOVERY_LIMIT, a9 as RecordingArtifactMetadata, aa as RecordingCodec, ab as RecordingContentType, ac as RecordingError, ad as RecordingProcess, ae as RecordingUnavailableError, af as RepositoryDiscoveryDegradedReason, ag as RepositoryDiscoveryResult, ah as ResolvedActiveBackend, ai as RoutableBackendSession, aj as RoutableSandbox, ak as RoutingSandboxSession, al as RoutingSandboxSessionDeps, am as RoutingTransitionEvent, an as RoutingUnsupportedError, ao as RunCredentialCommandRunner, ap as RunCredentialCommandSession, aq as RunCredentialExpectedScope, R as RunCredentialSessionReady, ar as RunCredentialValidationError, as as SELFHOSTED_DEFAULT_TIMEOUT_MS, at as SELFHOSTED_DRAINING_MAX_RETRIES, au as SELFHOSTED_EXEC_DRAINING_MAX_RETRIES, av as SELFHOSTED_IDEMPOTENT_READONLY_OPS, aw as SELFHOSTED_INFRASTRUCTURE_FAULT_CLASSES, ax as SELFHOSTED_NEVER_SENT_MAX_RETRIES, ay as SELFHOSTED_RECONNECT_WINDOW_MS, az as SELFHOSTED_RELAY_STREAM_PATH, aA as SELFHOSTED_RETRY_BACKOFF_BASE_MS, aB as SELFHOSTED_RETRY_BACKOFF_CAP_MS, aC as SELFHOSTED_RETRY_BACKOFF_FACTOR, aD as SELFHOSTED_TIMEOUT_MAX_RETRIES, aE as STREAM_PORT, aF as STREAM_TOKEN_DEFAULT_TTL_SECONDS, aG as SandboxChannelAService, aH as SandboxChannelAServiceOptions, aI as SandboxConfigError, aJ as SandboxCreatedCallback, aK as SandboxProviderUnavailableError, aL as SandboxResumeStateUnavailableError, aM as SelfhostedApplyDiff, aN as SelfhostedControlError, aO as SelfhostedEditor, aP as SelfhostedEnrollment, aQ as SelfhostedExecArgs, aR as SelfhostedExecResult, aS as SelfhostedImageOutput, aT as SelfhostedLivenessState, aU as SelfhostedNegotiationInput, aV as SelfhostedOpObservation, aW as SelfhostedOpObserver, aX as SelfhostedOpStreamDeps, aY as SelfhostedRelayConfig, aZ as SelfhostedRetryClock, a_ as SelfhostedRetryDecision, a$ as SelfhostedSandboxClient, b0 as SelfhostedSession, b1 as SelfhostedSessionBuild, b2 as SelfhostedSessionDeps, b3 as SelfhostedSessionState, b4 as SelfhostedUnavailableReason, b5 as StartRecordingInput, b6 as StreamPortUnavailableError, b7 as SwapTargetEstablishability, b8 as TERMINAL_SERVER_TIMEOUT_MS, b9 as TerminalServerError, ba as TerminalServerUnsupportedError, bb as ToolspaceTokenPathError, bc as agentErrorToControlError, bd as assertDescriptorRegistryInvariants, be as assertProviderRegistryInvariants, bf as assertSafeRelPath, bg as backendSupportsOs, bh as buildDisplayStackScript, bi as buildSelfhostedBackendSession, bj as buildStreamUrl, bk as buildTerminalServerScript, bl as clearRunCredentials, bm as clearRunCredentialsForAttempt, bn as contentTypeForCodec, bo as createSandboxClient, bp as createSandboxClientForBackend, bq as decideSelfhostedRetry, br as decodeModalSnapshotId, bs as defaultSelfhostedRetryClock, bt as deletePriorPersistedSnapshot, bu as deleteRecordingArtifacts, bv as deserializeSandboxSessionStateEnvelope, bw as desktopCapableBackend, bx as drainingExhaustedError, by as drainingMessage, bz as ensureDisplayStack, bA as ensureModalRegistryImage, bB as ensureTerminalServer, bC as establishSandboxSessionFromEnvelope, bD as execDeadlineHint, bE as exposeStreamPort, bF as extForCodec, bG as inspectRecordingArtifact, bH as isExecSessionLostBanner, bI as isProviderSandboxNotFoundError, bJ as isSelfhostedProviderNotFoundError, bK as makeActiveBackendResolver, bL as materializeRunCredentials, bM as mintStreamToken, bN as modalSandboxAttributionEnvironment, bO as modalSandboxAttributionTags, bP as negotiateCapabilities, bQ as negotiateSelfhostedCapabilities, bR as nextDurableOpId, bS as normalizeRunCredentialsResolution, bT as offlineAgentError, bU as offlineControlResponse, bV as opAckSubject, bW as opFrameSubject, bX as parseExecBannerExitCode, bY as parseExecBannerSessionId, bZ as parseNumstatZ, b_ as parsePorcelainV2, b$ as parseUnifiedPatch, c0 as payloadTooLargeMessage, c1 as readWorkspaceArchiveFromEnvelopeSessionState, c2 as recordingStorageKey, c3 as renderSelfhostedFault, c4 as restoredSandboxSessionStateFromEntry, c5 as runCredentialPointerFile, c6 as runCredentialRoot, c7 as runWithToolCallCorrelation, c8 as sandboxStateEntryFromRunState, c9 as sanitizeOpIdToken, ca as selectBackend, cb as selfhostedFaultClass, cc as selfhostedLiveness, cd as selfhostedRetryBackoffMs, ce as serializeEstablishedSandboxEnvelope, cf as setSelfhostedApplyDiff, cg as startRecording, ch as stopRecording, ci as stripExecBanner, cj as subjectFor, ck as swapTargetEstablishability, cl as sweepModalOrphanSandboxes, cm as tagModalSandbox, cn as tearDownDisplayStack, co as tearDownTerminalServer, cp as terminateModalSandboxById, cq as timeoutAgentError, cr as timeoutControlResponse, cs as toolspaceTokenFileForSession, ct as toolspaceTokenFileFromEnvironment, cu as uploadRecordingArtifact, cv as verifyStreamToken, cw as withRunCredentialEnvironment, cx as withRunCredentialsClient, cy as withRunCredentialsSession, cz as withToolspaceTokenClient, cA as withToolspaceTokenEnvironment, cB as withToolspaceTokenSession } from '../index-D6yi-JcU.js';
4
+ export { A as ActiveBackendResolverDeps, b as ActiveBackendUnresolvableError, c as ActivePointer, B as BackendUnresolvableCode, C as ChannelAConflictError, d as ChannelAEmitter, e as ChannelAExecArgs, f as ChannelAExecResult, g as ChannelANotFoundError, h as ChannelASession, i as ChannelAUnavailableError, j as ChannelAUnsupportedError, k as ChannelAValidationError, l as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, m as DISPLAY_STACK_TIMEOUT_MS, n as DefaultBackendLossResult, o as DesktopGeometry, p as DisplayStackCallerKind, q as DisplayStackClassification, r as DisplayStackError, s as DisplayStackTelemetryContext, t as DisplayStackTelemetryEvent, u as DisplayStackTelemetryStatus, v as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, w as EnsureDisplayStackResult, x as EnsureTerminalServerOptions, y as EnsureTerminalServerResult, z as EstablishedSandboxSession, F as ExposeStreamPortInput, G as ExposeStreamPortResult, H as ExposedPortEndpoint, I as FAULT_FIELD_WHAT_HAPPENED, J as FAULT_FIELD_WHAT_PRESERVED, K as FAULT_FIELD_WHAT_TO_TRY, L as FAULT_FIELD_WHICH_LAYER, M as LiveModalSandboxLeaseAttribution, N as MaterializeRunCredentialsOptions, O as MintStreamTokenInput, P as MockAgentResponder, Q as MockAgentResponderOptions, S as MockExecHandler, T as ModalModuleLoader, U as ModalOrphanSweepResult, V as ModalOrphanSweepTermination, W as ModalSandboxAttribution, X as NEVER_SENT_DETAIL_KEY, Y as NatsControlRpc, Z as NatsOpStreamConnection, _ as NatsOpStreamTransport, $ as NatsRequestConnection, a0 as NegotiationContext, a1 as NormalizedRunCredentialMaterial, a2 as NumstatEntry, a3 as OP_STREAM_ACK_INTERVAL_MS, a4 as OP_STREAM_DEFAULT_WINDOW_BYTES, a5 as OP_STREAM_RECONNECT_HOLD_MS, a6 as OP_STREAM_SILENCE_TIMEOUT_MS, a7 as OpStreamExecOutcome, a8 as OpStreamJournal, a9 as OpStreamSubscription, aa as OpStreamTransport, ab as OpStreamUnavailableError, ac as PROVIDER_REGISTRY, ad as ProviderConstructionContext, ae as ProviderRegistration, af as ProviderSandboxFailure, ag as ProviderSandboxFailureKind, ah as REPOSITORY_DISCOVERY_LIMIT, ai as RecordingArtifactMetadata, aj as RecordingCodec, ak as RecordingContentType, al as RecordingError, am as RecordingProcess, an as RecordingUnavailableError, ao as RepositoryDiscoveryDegradedReason, ap as RepositoryDiscoveryResult, aq as ResolvedActiveBackend, ar as RevalidateModalOrphanTermination, as as RoutableBackendSession, at as RoutableSandbox, au as RoutingBackendRecoveryRequiredError, av as RoutingMutationOutcomeUnknownError, aw as RoutingRetainedProcess, ax as RoutingRetainedProcessAdoption, ay as RoutingRetainedProcessNotFoundError, az as RoutingRetainedProcessTerminalProof, aA as RoutingSandboxSession, aB as RoutingSandboxSessionDeps, aC as RoutingTransitionEvent, aD as RoutingUnsupportedError, aE as RunCredentialCommandRunner, aF as RunCredentialCommandSession, aG as RunCredentialExpectedScope, R as RunCredentialSessionReady, aH as RunCredentialValidationError, aI as SELFHOSTED_DEFAULT_TIMEOUT_MS, aJ as SELFHOSTED_DRAINING_MAX_RETRIES, aK as SELFHOSTED_EXEC_DRAINING_MAX_RETRIES, aL as SELFHOSTED_IDEMPOTENT_READONLY_OPS, aM as SELFHOSTED_INFRASTRUCTURE_FAULT_CLASSES, aN as SELFHOSTED_NEVER_SENT_MAX_RETRIES, aO as SELFHOSTED_RECONNECT_WINDOW_MS, aP as SELFHOSTED_RELAY_STREAM_PATH, aQ as SELFHOSTED_RETRY_BACKOFF_BASE_MS, aR as SELFHOSTED_RETRY_BACKOFF_CAP_MS, aS as SELFHOSTED_RETRY_BACKOFF_FACTOR, aT as SELFHOSTED_TIMEOUT_MAX_RETRIES, aU as STREAM_PORT, aV as STREAM_TOKEN_DEFAULT_TTL_SECONDS, aW as SandboxChannelAService, aX as SandboxChannelAServiceOptions, aY as SandboxConfigError, aZ as SandboxCreatedCallback, a_ as SandboxExecReadinessError, a$ as SandboxProviderUnavailableError, b0 as SandboxReplacementProviderStateError, b1 as SandboxResumeStateUnavailableError, b2 as SelfhostedApplyDiff, b3 as SelfhostedControlError, b4 as SelfhostedEditor, b5 as SelfhostedEnrollment, b6 as SelfhostedExecArgs, b7 as SelfhostedExecResult, b8 as SelfhostedImageOutput, b9 as SelfhostedLivenessState, ba as SelfhostedNegotiationInput, bb as SelfhostedOpObservation, bc as SelfhostedOpObserver, bd as SelfhostedOpStreamDeps, be as SelfhostedRelayConfig, bf as SelfhostedRetryClock, bg as SelfhostedRetryDecision, bh as SelfhostedSandboxClient, bi as SelfhostedSession, bj as SelfhostedSessionBuild, bk as SelfhostedSessionDeps, bl as SelfhostedSessionState, bm as SelfhostedUnavailableReason, bn as StartRecordingInput, bo as StreamPortUnavailableError, bp as SwapTargetEstablishability, bq as TERMINAL_SERVER_TIMEOUT_MS, br as TerminalServerError, bs as TerminalServerUnsupportedError, bt as ToolspaceTokenPathError, bu as VerifiedWorkspaceArchive, bv as WORKSPACE_ARCHIVE_DESCRIPTOR_VERSION, bw as WorkspaceArchiveDescriptor, bx as WorkspaceArchiveIntegrityCode, by as WorkspaceArchiveIntegrityError, bz as WorkspaceTreeFingerprint, bA as agentErrorToControlError, bB as assertDescriptorRegistryInvariants, bC as assertProviderRegistryInvariants, bD as assertSafeRelPath, bE as backendSupportsOs, bF as buildDisplayStackScript, bG as buildSelfhostedBackendSession, bH as buildStreamUrl, bI as buildTerminalServerScript, bJ as captureVerifiedWorkspaceArchive, bK as classifyProviderSandboxFailure, bL as clearRunCredentials, bM as clearRunCredentialsForAttempt, bN as contentTypeForCodec, bO as createSandboxClient, bP as createSandboxClientForBackend, bQ as decideSelfhostedRetry, bR as decodeModalSnapshotId, bS as defaultSelfhostedRetryClock, bT as deletePriorPersistedSnapshot, bU as deleteRecordingArtifacts, bV as deserializeSandboxSessionStateEnvelope, bW as desktopCapableBackend, bX as drainingExhaustedError, bY as drainingMessage, bZ as ensureDisplayStack, b_ as ensureModalRegistryImage, b$ as ensureTerminalServer, c0 as establishSandboxSessionFromEnvelope, c1 as execDeadlineHint, c2 as exposeStreamPort, c3 as extForCodec, c4 as fingerprintSandboxWorkspace, c5 as hasPersistableSandboxProviderIdentity, c6 as inspectRecordingArtifact, c7 as isExecSessionLostBanner, c8 as isProviderSandboxGoneDuringRoutedOperation, c9 as isProviderSandboxNotFoundError, ca as isProviderSandboxTransientError, cb as isSelfhostedProviderNotFoundError, cc as makeActiveBackendResolver, cd as materializeRunCredentials, ce as mintStreamToken, cf as modalSandboxAttributionEnvironment, cg as modalSandboxAttributionTags, ch as negotiateCapabilities, ci as negotiateSelfhostedCapabilities, cj as nextDurableOpId, ck as normalizeRunCredentialsResolution, cl as offlineAgentError, cm as offlineControlResponse, cn as opAckSubject, co as opFrameSubject, cp as parseExecBannerExitCode, cq as parseExecBannerSessionId, cr as parseNumstatZ, cs as parsePorcelainV2, ct as parseUnifiedPatch, cu as parseWorkspaceArchiveDescriptor, cv as payloadTooLargeMessage, cw as readVerifiedWorkspaceArchive, cx as readWorkspaceArchiveFromEnvelopeSessionState, cy as recordingStorageKey, cz as renderSelfhostedFault, cA as requirePersistableReplacementSandboxEnvelope, cB as restoredSandboxSessionStateFromEntry, cC as runCredentialPointerFile, cD as runCredentialRoot, cE as runWithToolCallCorrelation, cF as sandboxStateEntryFromRunState, cG as sanitizeOpIdToken, cH as selectBackend, cI as selfhostedFaultClass, cJ as selfhostedLiveness, cK as selfhostedRetryBackoffMs, cL as serializeEstablishedSandboxEnvelope, cM as serializeReplacementSandboxEnvelope, cN as setSelfhostedApplyDiff, cO as startRecording, cP as stopRecording, cQ as stripExecBanner, cR as subjectFor, cS as swapTargetEstablishability, cT as sweepModalOrphanSandboxes, cU as tagModalSandbox, cV as tearDownDisplayStack, cW as tearDownTerminalServer, cX as terminateModalSandboxById, cY as timeoutAgentError, cZ as timeoutControlResponse, c_ as toolspaceTokenFileForSession, c$ as toolspaceTokenFileFromEnvironment, d0 as uploadRecordingArtifact, d1 as verifyRestoredWorkspace, d2 as verifySandboxExecReadiness, d3 as verifyStreamToken, d4 as withRunCredentialEnvironment, d5 as withRunCredentialsClient, d6 as withRunCredentialsSession, d7 as withToolspaceTokenClient, d8 as withToolspaceTokenEnvironment, d9 as withToolspaceTokenSession } from '../index-DU-KXVlx.js';
5
5
  import 'modal';
6
6
  import '@opengeni/agent-proto';
@@ -28,6 +28,9 @@ import {
28
28
  REPOSITORY_DISCOVERY_LIMIT,
29
29
  RecordingError,
30
30
  RecordingUnavailableError,
31
+ RoutingBackendRecoveryRequiredError,
32
+ RoutingMutationOutcomeUnknownError,
33
+ RoutingRetainedProcessNotFoundError,
31
34
  RoutingSandboxSession,
32
35
  RoutingUnsupportedError,
33
36
  RunCredentialValidationError,
@@ -47,7 +50,9 @@ import {
47
50
  STREAM_TOKEN_DEFAULT_TTL_SECONDS,
48
51
  SandboxChannelAService,
49
52
  SandboxConfigError,
53
+ SandboxExecReadinessError,
50
54
  SandboxProviderUnavailableError,
55
+ SandboxReplacementProviderStateError,
51
56
  SandboxResumeStateUnavailableError,
52
57
  SelfhostedControlError,
53
58
  SelfhostedSandboxClient,
@@ -59,6 +64,8 @@ import {
59
64
  TerminalServerError,
60
65
  TerminalServerUnsupportedError,
61
66
  ToolspaceTokenPathError,
67
+ WORKSPACE_ARCHIVE_DESCRIPTOR_VERSION,
68
+ WorkspaceArchiveIntegrityError,
62
69
  agentErrorToControlError,
63
70
  assertDescriptorRegistryInvariants,
64
71
  assertProviderRegistryInvariants,
@@ -68,6 +75,8 @@ import {
68
75
  buildSelfhostedBackendSession,
69
76
  buildStreamUrl,
70
77
  buildTerminalServerScript,
78
+ captureVerifiedWorkspaceArchive,
79
+ classifyProviderSandboxFailure,
71
80
  clearRunCredentials,
72
81
  clearRunCredentialsForAttempt,
73
82
  collectSandboxEnvironment,
@@ -90,9 +99,13 @@ import {
90
99
  execDeadlineHint,
91
100
  exposeStreamPort,
92
101
  extForCodec,
102
+ fingerprintSandboxWorkspace,
103
+ hasPersistableSandboxProviderIdentity,
93
104
  inspectRecordingArtifact,
94
105
  isExecSessionLostBanner,
106
+ isProviderSandboxGoneDuringRoutedOperation,
95
107
  isProviderSandboxNotFoundError,
108
+ isProviderSandboxTransientError,
96
109
  isSelfhostedProviderNotFoundError,
97
110
  makeActiveBackendResolver,
98
111
  materializeRunCredentials,
@@ -113,10 +126,13 @@ import {
113
126
  parseNumstatZ,
114
127
  parsePorcelainV2,
115
128
  parseUnifiedPatch,
129
+ parseWorkspaceArchiveDescriptor,
116
130
  payloadTooLargeMessage,
131
+ readVerifiedWorkspaceArchive,
117
132
  readWorkspaceArchiveFromEnvelopeSessionState,
118
133
  recordingStorageKey,
119
134
  renderSelfhostedFault,
135
+ requirePersistableReplacementSandboxEnvelope,
120
136
  restoredSandboxSessionStateFromEntry,
121
137
  runCredentialPointerFile,
122
138
  runCredentialRoot,
@@ -128,6 +144,7 @@ import {
128
144
  selfhostedLiveness,
129
145
  selfhostedRetryBackoffMs,
130
146
  serializeEstablishedSandboxEnvelope,
147
+ serializeReplacementSandboxEnvelope,
131
148
  setSelfhostedApplyDiff,
132
149
  startRecording,
133
150
  stopRecording,
@@ -144,6 +161,8 @@ import {
144
161
  toolspaceTokenFileForSession,
145
162
  toolspaceTokenFileFromEnvironment,
146
163
  uploadRecordingArtifact,
164
+ verifyRestoredWorkspace,
165
+ verifySandboxExecReadiness,
147
166
  verifyStreamToken,
148
167
  withRunCredentialEnvironment,
149
168
  withRunCredentialsClient,
@@ -151,7 +170,7 @@ import {
151
170
  withToolspaceTokenClient,
152
171
  withToolspaceTokenEnvironment,
153
172
  withToolspaceTokenSession
154
- } from "../chunk-YUAFQEFY.js";
173
+ } from "../chunk-JGUQSAG5.js";
155
174
  import "../chunk-4YJ5Z52Z.js";
156
175
  import "../chunk-K4V4QYCL.js";
157
176
  import "../chunk-PZ5AY32C.js";
@@ -185,6 +204,9 @@ export {
185
204
  REPOSITORY_DISCOVERY_LIMIT,
186
205
  RecordingError,
187
206
  RecordingUnavailableError,
207
+ RoutingBackendRecoveryRequiredError,
208
+ RoutingMutationOutcomeUnknownError,
209
+ RoutingRetainedProcessNotFoundError,
188
210
  RoutingSandboxSession,
189
211
  RoutingUnsupportedError,
190
212
  RunCredentialValidationError,
@@ -204,7 +226,9 @@ export {
204
226
  STREAM_TOKEN_DEFAULT_TTL_SECONDS,
205
227
  SandboxChannelAService,
206
228
  SandboxConfigError,
229
+ SandboxExecReadinessError,
207
230
  SandboxProviderUnavailableError,
231
+ SandboxReplacementProviderStateError,
208
232
  SandboxResumeStateUnavailableError,
209
233
  SelfhostedControlError,
210
234
  SelfhostedSandboxClient,
@@ -216,6 +240,8 @@ export {
216
240
  TerminalServerError,
217
241
  TerminalServerUnsupportedError,
218
242
  ToolspaceTokenPathError,
243
+ WORKSPACE_ARCHIVE_DESCRIPTOR_VERSION,
244
+ WorkspaceArchiveIntegrityError,
219
245
  agentErrorToControlError,
220
246
  assertDescriptorRegistryInvariants,
221
247
  assertProviderRegistryInvariants,
@@ -225,6 +251,8 @@ export {
225
251
  buildSelfhostedBackendSession,
226
252
  buildStreamUrl,
227
253
  buildTerminalServerScript,
254
+ captureVerifiedWorkspaceArchive,
255
+ classifyProviderSandboxFailure,
228
256
  clearRunCredentials,
229
257
  clearRunCredentialsForAttempt,
230
258
  collectSandboxEnvironment,
@@ -247,9 +275,13 @@ export {
247
275
  execDeadlineHint,
248
276
  exposeStreamPort,
249
277
  extForCodec,
278
+ fingerprintSandboxWorkspace,
279
+ hasPersistableSandboxProviderIdentity,
250
280
  inspectRecordingArtifact,
251
281
  isExecSessionLostBanner,
282
+ isProviderSandboxGoneDuringRoutedOperation,
252
283
  isProviderSandboxNotFoundError,
284
+ isProviderSandboxTransientError,
253
285
  isSelfhostedProviderNotFoundError,
254
286
  makeActiveBackendResolver,
255
287
  materializeRunCredentials,
@@ -270,10 +302,13 @@ export {
270
302
  parseNumstatZ,
271
303
  parsePorcelainV2,
272
304
  parseUnifiedPatch,
305
+ parseWorkspaceArchiveDescriptor,
273
306
  payloadTooLargeMessage,
307
+ readVerifiedWorkspaceArchive,
274
308
  readWorkspaceArchiveFromEnvelopeSessionState,
275
309
  recordingStorageKey,
276
310
  renderSelfhostedFault,
311
+ requirePersistableReplacementSandboxEnvelope,
277
312
  restoredSandboxSessionStateFromEntry,
278
313
  runCredentialPointerFile,
279
314
  runCredentialRoot,
@@ -285,6 +320,7 @@ export {
285
320
  selfhostedLiveness,
286
321
  selfhostedRetryBackoffMs,
287
322
  serializeEstablishedSandboxEnvelope,
323
+ serializeReplacementSandboxEnvelope,
288
324
  setSelfhostedApplyDiff,
289
325
  startRecording,
290
326
  stopRecording,
@@ -301,6 +337,8 @@ export {
301
337
  toolspaceTokenFileForSession,
302
338
  toolspaceTokenFileFromEnvironment,
303
339
  uploadRecordingArtifact,
340
+ verifyRestoredWorkspace,
341
+ verifySandboxExecReadiness,
304
342
  verifyStreamToken,
305
343
  withRunCredentialEnvironment,
306
344
  withRunCredentialsClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/runtime",
3
- "version": "0.11.0",
3
+ "version": "0.13.3",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,6 +28,10 @@
28
28
  "./skill-library": {
29
29
  "types": "./dist/skill-library.d.ts",
30
30
  "import": "./dist/skill-library.js"
31
+ },
32
+ "./mcp-network": {
33
+ "types": "./dist/mcp-network.d.ts",
34
+ "import": "./dist/mcp-network.js"
31
35
  }
32
36
  },
33
37
  "publishConfig": {
@@ -45,9 +49,10 @@
45
49
  "@openai/agents": "0.13.3",
46
50
  "@openai/agents-extensions": "0.13.3",
47
51
  "@opengeni/agent-proto": "^0.3.0",
48
- "@opengeni/codex": "^0.2.5",
49
- "@opengeni/config": "^0.6.2",
50
- "@opengeni/contracts": "^0.15.0",
52
+ "@opengeni/codex": "^0.2.7",
53
+ "@opengeni/config": "^0.7.0",
54
+ "@opengeni/contracts": "^0.19.0",
55
+ "@opengeni/network": "^0.1.1",
51
56
  "debug": "4.4.3",
52
57
  "modal": "0.7.6",
53
58
  "openai": "6.47.0",
@@ -26,6 +26,11 @@
26
26
  // all unchanged). Invocation is untouched; only the wire tool-set shrinks.
27
27
 
28
28
  import { toolSearchTool, type Tool } from "@openai/agents";
29
+ import {
30
+ MCP_MAX_TOOL_DEFINITION_BYTES,
31
+ MCP_MAX_TOOL_SEARCH_DISCLOSURE_BYTES,
32
+ mcpSerializedSizeBytes,
33
+ } from "./mcp-network";
29
34
 
30
35
  /** The prefix OpenGeni's PrefixedMcpServer stamps on codex_apps connector tools. */
31
36
  export const CODEX_APPS_TOOL_PREFIX = "codex_apps__";
@@ -239,7 +244,21 @@ function codexToolSearchExecutor(args: {
239
244
  const deferred = (args.availableTools ?? []).filter(isCodexAppsFunctionTool);
240
245
  if (deferred.length === 0) return [];
241
246
  const { query, limit } = parseSearchArgs(args.toolCall?.arguments);
242
- return bm25RankTools(deferred, query, limit);
247
+ const ranked = bm25RankTools(deferred, query, limit);
248
+ const bounded: Tool[] = [];
249
+ let disclosedBytes = 0;
250
+ for (const tool of ranked) {
251
+ const toolBytes = mcpSerializedSizeBytes(tool);
252
+ if (toolBytes > MCP_MAX_TOOL_DEFINITION_BYTES) {
253
+ continue;
254
+ }
255
+ if (disclosedBytes + toolBytes > MCP_MAX_TOOL_SEARCH_DISCLOSURE_BYTES) {
256
+ break;
257
+ }
258
+ disclosedBytes += toolBytes;
259
+ bounded.push(tool);
260
+ }
261
+ return bounded;
243
262
  }
244
263
 
245
264
  const NO_NAMESPACES: ReadonlySet<string> = new Set();