@opengeni/runtime 0.11.0 → 0.13.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.
@@ -0,0 +1,78 @@
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_MAX_AGGREGATE_TOOL_LIST_ENTRIES = 4096;
15
+ declare const MCP_MAX_AGGREGATE_TOOL_LIST_BYTES: number;
16
+ declare const MCP_MAX_TOOL_SEARCH_SOURCES = 64;
17
+ declare const MCP_MAX_TOOL_SEARCH_SOURCE_LABEL_LENGTH = 120;
18
+ declare const MCP_MAX_TOOL_SEARCH_DESCRIPTION_BYTES: number;
19
+ declare class McpPayloadTooLargeError extends Error {
20
+ readonly label: string;
21
+ readonly actualBytes: number;
22
+ readonly maxBytes: number;
23
+ constructor(label: string, actualBytes: number, maxBytes: number);
24
+ }
25
+ declare function mcpSerializedSizeBytes(value: unknown): number;
26
+ declare function assertMcpPayloadWithinBytes(value: unknown, maxBytes: number, label: string): void;
27
+ declare function assertMcpToolListWithinBounds<T>(tools: readonly T[]): readonly T[];
28
+ declare function assertMcpServerSelectionWithinBounds<T>(servers: readonly T[]): readonly T[];
29
+ type McpToolListContribution = {
30
+ entries: number;
31
+ bytes: number;
32
+ };
33
+ /**
34
+ * Atomic aggregate accounting shared by every exposed tools/list in one run.
35
+ * A repeated list for the same source REPLACES its prior contribution, so
36
+ * cache invalidation/relisting cannot ratchet the budget upward. Failed
37
+ * replacements leave the previous accounting intact.
38
+ */
39
+ declare class McpAggregateToolListBudget {
40
+ private readonly label;
41
+ private readonly maxEntries;
42
+ private readonly maxBytes;
43
+ private readonly contributions;
44
+ private totalEntries;
45
+ private totalBytes;
46
+ constructor(label?: string, maxEntries?: number, maxBytes?: number);
47
+ replace<T>(sourceId: string, tools: readonly T[]): readonly T[];
48
+ remove(sourceId: string): void;
49
+ snapshot(): Readonly<McpToolListContribution>;
50
+ }
51
+ /** Stable-order parallel map with a hard in-flight ceiling and fail-stop drain. */
52
+ declare function boundedParallelMap<T, R>(values: readonly T[], concurrency: number, mapper: (value: T, index: number) => Promise<R>): Promise<R[]>;
53
+ /**
54
+ * Guard normal MCP traffic with the same deployment policy as OAuth traffic.
55
+ * The pinned transport resolves and policy-checks the destination after the
56
+ * caller has composed any credential headers, then performs the final network
57
+ * call through the vetted Agent. It forces manual redirects, so an
58
+ * Authorization-bearing request never follows a provider-controlled Location
59
+ * to an unvalidated host.
60
+ *
61
+ * This module is deliberately agent-loop-free. API code imports the explicit
62
+ * `@opengeni/runtime/mcp-network` leaf rather than the runtime root barrel.
63
+ */
64
+ declare function guardedMcpFetch<TInput extends string | URL | Request>(settings: Pick<Settings, "environment" | "integrationsAllowPrivateNetworkTargets">, fetchImpl: (input: TInput, init?: RequestInit) => Promise<Response>, options?: {
65
+ maxResponseBytes?: number;
66
+ dnsLookup?: DnsLookup;
67
+ requireHttpsOutsideLocalTest?: boolean;
68
+ }): (input: TInput, init?: RequestInit) => Promise<Response>;
69
+ declare function boundMcpResponseBody(response: Response, maxBytes: number): Response;
70
+ declare function cancelMcpResponseBody(response: Response): Promise<void>;
71
+ /** Read and rebuild an inbound MCP request before the SDK parses it. */
72
+ declare function boundedMcpRequest(request: Request, maxBytes?: number): Promise<Request>;
73
+ declare function assertMcpDestinationAllowed(rawUrl: string, settings: Pick<Settings, "environment" | "integrationsAllowPrivateNetworkTargets">, options?: {
74
+ dnsLookup?: DnsLookup;
75
+ }): Promise<void>;
76
+ declare const isNonPublicMcpAddress: typeof isNonPublicAddress;
77
+
78
+ export { 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, mcpSerializedSizeBytes };
@@ -0,0 +1,62 @@
1
+ import {
2
+ MCP_MAX_AGGREGATE_TOOL_LIST_BYTES,
3
+ MCP_MAX_AGGREGATE_TOOL_LIST_ENTRIES,
4
+ MCP_MAX_CONCURRENT_SERVER_OPERATIONS,
5
+ MCP_MAX_INBOUND_REQUEST_BYTES,
6
+ MCP_MAX_RESPONSE_BYTES,
7
+ MCP_MAX_SELECTED_SERVERS,
8
+ MCP_MAX_TOOL_DEFINITION_BYTES,
9
+ MCP_MAX_TOOL_LIST_BYTES,
10
+ MCP_MAX_TOOL_LIST_ENTRIES,
11
+ MCP_MAX_TOOL_RESULT_BYTES,
12
+ MCP_MAX_TOOL_SEARCH_DESCRIPTION_BYTES,
13
+ MCP_MAX_TOOL_SEARCH_DISCLOSURE_BYTES,
14
+ MCP_MAX_TOOL_SEARCH_SOURCES,
15
+ MCP_MAX_TOOL_SEARCH_SOURCE_LABEL_LENGTH,
16
+ McpAggregateToolListBudget,
17
+ McpPayloadTooLargeError,
18
+ assertMcpDestinationAllowed,
19
+ assertMcpPayloadWithinBytes,
20
+ assertMcpServerSelectionWithinBounds,
21
+ assertMcpToolListWithinBounds,
22
+ boundMcpResponseBody,
23
+ boundedMcpRequest,
24
+ boundedParallelMap,
25
+ cancelMcpResponseBody,
26
+ guardedMcpFetch,
27
+ isNonPublicMcpAddress,
28
+ mcpSerializedSizeBytes,
29
+ undiciFetch
30
+ } from "./chunk-HAN5D27J.js";
31
+ import "./chunk-PZ5AY32C.js";
32
+ export {
33
+ MCP_MAX_AGGREGATE_TOOL_LIST_BYTES,
34
+ MCP_MAX_AGGREGATE_TOOL_LIST_ENTRIES,
35
+ MCP_MAX_CONCURRENT_SERVER_OPERATIONS,
36
+ MCP_MAX_INBOUND_REQUEST_BYTES,
37
+ MCP_MAX_RESPONSE_BYTES,
38
+ MCP_MAX_SELECTED_SERVERS,
39
+ MCP_MAX_TOOL_DEFINITION_BYTES,
40
+ MCP_MAX_TOOL_LIST_BYTES,
41
+ MCP_MAX_TOOL_LIST_ENTRIES,
42
+ MCP_MAX_TOOL_RESULT_BYTES,
43
+ MCP_MAX_TOOL_SEARCH_DESCRIPTION_BYTES,
44
+ MCP_MAX_TOOL_SEARCH_DISCLOSURE_BYTES,
45
+ MCP_MAX_TOOL_SEARCH_SOURCES,
46
+ MCP_MAX_TOOL_SEARCH_SOURCE_LABEL_LENGTH,
47
+ McpAggregateToolListBudget,
48
+ McpPayloadTooLargeError,
49
+ assertMcpDestinationAllowed,
50
+ assertMcpPayloadWithinBytes,
51
+ assertMcpServerSelectionWithinBounds,
52
+ assertMcpToolListWithinBounds,
53
+ boundMcpResponseBody,
54
+ boundedMcpRequest,
55
+ boundedParallelMap,
56
+ cancelMcpResponseBody,
57
+ guardedMcpFetch,
58
+ isNonPublicMcpAddress,
59
+ mcpSerializedSizeBytes,
60
+ undiciFetch
61
+ };
62
+ //# 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 DesktopGeometry, o as DisplayStackCallerKind, p as DisplayStackClassification, q as DisplayStackError, r as DisplayStackTelemetryContext, s as DisplayStackTelemetryEvent, t as DisplayStackTelemetryStatus, u as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, v as EnsureDisplayStackResult, w as EnsureTerminalServerOptions, x as EnsureTerminalServerResult, y as EstablishedSandboxSession, z as ExposeStreamPortInput, F as ExposeStreamPortResult, G as ExposedPortEndpoint, H as FAULT_FIELD_WHAT_HAPPENED, I as FAULT_FIELD_WHAT_PRESERVED, J as FAULT_FIELD_WHAT_TO_TRY, K as FAULT_FIELD_WHICH_LAYER, L as LiveModalSandboxLeaseAttribution, M as MaterializeRunCredentialsOptions, N as MintStreamTokenInput, O as MockAgentResponder, P as MockAgentResponderOptions, Q as MockExecHandler, S as ModalModuleLoader, T as ModalOrphanSweepResult, U as ModalOrphanSweepTermination, V as ModalSandboxAttribution, W as NEVER_SENT_DETAIL_KEY, X as NatsControlRpc, Y as NatsOpStreamConnection, Z as NatsOpStreamTransport, _ as NatsRequestConnection, $ as NegotiationContext, a0 as NormalizedRunCredentialMaterial, a1 as NumstatEntry, a2 as OP_STREAM_ACK_INTERVAL_MS, a3 as OP_STREAM_DEFAULT_WINDOW_BYTES, a4 as OP_STREAM_RECONNECT_HOLD_MS, a5 as OP_STREAM_SILENCE_TIMEOUT_MS, a6 as OpStreamExecOutcome, a7 as OpStreamJournal, a8 as OpStreamSubscription, a9 as OpStreamTransport, aa as OpStreamUnavailableError, ab as PROVIDER_REGISTRY, ac as ProviderConstructionContext, ad as ProviderRegistration, ae as REPOSITORY_DISCOVERY_LIMIT, af as RecordingArtifactMetadata, ag as RecordingCodec, ah as RecordingContentType, ai as RecordingError, aj as RecordingProcess, ak as RecordingUnavailableError, al as RepositoryDiscoveryDegradedReason, am as RepositoryDiscoveryResult, an as ResolvedActiveBackend, ao as RevalidateModalOrphanTermination, ap as RoutableBackendSession, aq as RoutableSandbox, ar as RoutingSandboxSession, as as RoutingSandboxSessionDeps, at as RoutingTransitionEvent, au as RoutingUnsupportedError, av as RunCredentialCommandRunner, aw as RunCredentialCommandSession, ax as RunCredentialExpectedScope, R as RunCredentialSessionReady, ay as RunCredentialValidationError, az as SELFHOSTED_DEFAULT_TIMEOUT_MS, aA as SELFHOSTED_DRAINING_MAX_RETRIES, aB as SELFHOSTED_EXEC_DRAINING_MAX_RETRIES, aC as SELFHOSTED_IDEMPOTENT_READONLY_OPS, aD as SELFHOSTED_INFRASTRUCTURE_FAULT_CLASSES, aE as SELFHOSTED_NEVER_SENT_MAX_RETRIES, aF as SELFHOSTED_RECONNECT_WINDOW_MS, aG as SELFHOSTED_RELAY_STREAM_PATH, aH as SELFHOSTED_RETRY_BACKOFF_BASE_MS, aI as SELFHOSTED_RETRY_BACKOFF_CAP_MS, aJ as SELFHOSTED_RETRY_BACKOFF_FACTOR, aK as SELFHOSTED_TIMEOUT_MAX_RETRIES, aL as STREAM_PORT, aM as STREAM_TOKEN_DEFAULT_TTL_SECONDS, aN as SandboxChannelAService, aO as SandboxChannelAServiceOptions, aP as SandboxConfigError, aQ as SandboxCreatedCallback, aR as SandboxProviderUnavailableError, aS as SandboxResumeStateUnavailableError, aT as SelfhostedApplyDiff, aU as SelfhostedControlError, aV as SelfhostedEditor, aW as SelfhostedEnrollment, aX as SelfhostedExecArgs, aY as SelfhostedExecResult, aZ as SelfhostedImageOutput, a_ as SelfhostedLivenessState, a$ as SelfhostedNegotiationInput, b0 as SelfhostedOpObservation, b1 as SelfhostedOpObserver, b2 as SelfhostedOpStreamDeps, b3 as SelfhostedRelayConfig, b4 as SelfhostedRetryClock, b5 as SelfhostedRetryDecision, b6 as SelfhostedSandboxClient, b7 as SelfhostedSession, b8 as SelfhostedSessionBuild, b9 as SelfhostedSessionDeps, ba as SelfhostedSessionState, bb as SelfhostedUnavailableReason, bc as StartRecordingInput, bd as StreamPortUnavailableError, be as SwapTargetEstablishability, bf as TERMINAL_SERVER_TIMEOUT_MS, bg as TerminalServerError, bh as TerminalServerUnsupportedError, bi as ToolspaceTokenPathError, bj as agentErrorToControlError, bk as assertDescriptorRegistryInvariants, bl as assertProviderRegistryInvariants, bm as assertSafeRelPath, bn as backendSupportsOs, bo as buildDisplayStackScript, bp as buildSelfhostedBackendSession, bq as buildStreamUrl, br as buildTerminalServerScript, bs as clearRunCredentials, bt as clearRunCredentialsForAttempt, bu as contentTypeForCodec, bv as createSandboxClient, bw as createSandboxClientForBackend, bx as decideSelfhostedRetry, by as decodeModalSnapshotId, bz as defaultSelfhostedRetryClock, bA as deletePriorPersistedSnapshot, bB as deleteRecordingArtifacts, bC as deserializeSandboxSessionStateEnvelope, bD as desktopCapableBackend, bE as drainingExhaustedError, bF as drainingMessage, bG as ensureDisplayStack, bH as ensureModalRegistryImage, bI as ensureTerminalServer, bJ as establishSandboxSessionFromEnvelope, bK as execDeadlineHint, bL as exposeStreamPort, bM as extForCodec, bN as inspectRecordingArtifact, bO as isExecSessionLostBanner, bP as isProviderSandboxNotFoundError, bQ as isSelfhostedProviderNotFoundError, bR as makeActiveBackendResolver, bS as materializeRunCredentials, bT as mintStreamToken, bU as modalSandboxAttributionEnvironment, bV as modalSandboxAttributionTags, bW as negotiateCapabilities, bX as negotiateSelfhostedCapabilities, bY as nextDurableOpId, bZ as normalizeRunCredentialsResolution, b_ as offlineAgentError, b$ as offlineControlResponse, c0 as opAckSubject, c1 as opFrameSubject, c2 as parseExecBannerExitCode, c3 as parseExecBannerSessionId, c4 as parseNumstatZ, c5 as parsePorcelainV2, c6 as parseUnifiedPatch, c7 as payloadTooLargeMessage, c8 as readWorkspaceArchiveFromEnvelopeSessionState, c9 as recordingStorageKey, ca as renderSelfhostedFault, 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 setSelfhostedApplyDiff, cn as startRecording, co as stopRecording, cp as stripExecBanner, cq as subjectFor, cr as swapTargetEstablishability, cs as sweepModalOrphanSandboxes, ct as tagModalSandbox, cu as tearDownDisplayStack, cv as tearDownTerminalServer, cw as terminateModalSandboxById, cx as timeoutAgentError, cy as timeoutControlResponse, cz as toolspaceTokenFileForSession, cA as toolspaceTokenFileFromEnvironment, cB as uploadRecordingArtifact, cC as verifyStreamToken, cD as withRunCredentialEnvironment, cE as withRunCredentialsClient, cF as withRunCredentialsSession, cG as withToolspaceTokenClient, cH as withToolspaceTokenEnvironment, cI as withToolspaceTokenSession } from '../index-DGUrY_yR.js';
5
5
  import 'modal';
6
6
  import '@opengeni/agent-proto';
@@ -151,7 +151,7 @@ import {
151
151
  withToolspaceTokenClient,
152
152
  withToolspaceTokenEnvironment,
153
153
  withToolspaceTokenSession
154
- } from "../chunk-YUAFQEFY.js";
154
+ } from "../chunk-65UDUFUO.js";
155
155
  import "../chunk-4YJ5Z52Z.js";
156
156
  import "../chunk-K4V4QYCL.js";
157
157
  import "../chunk-PZ5AY32C.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/runtime",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
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.6.9",
54
+ "@opengeni/contracts": "^0.18.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();