@agent-vm/agent-portal-sdk 0.0.119 → 0.0.120
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/package.json +1 -1
- package/dist/adapter-boundary/index.d.ts +0 -2
- package/dist/adapter-boundary/index.js +0 -2
- package/dist/adapter-boundary-BIagsTUH.js +0 -29
- package/dist/adapter-boundary-BIagsTUH.js.map +0 -1
- package/dist/approval-surface/index.d.ts +0 -2
- package/dist/approval-surface/index.js +0 -2
- package/dist/approval-surface-en5VAY5h.js +0 -20
- package/dist/approval-surface-en5VAY5h.js.map +0 -1
- package/dist/artifact-reference-schema-CiEjxYPd.js +0 -13
- package/dist/artifact-reference-schema-CiEjxYPd.js.map +0 -1
- package/dist/artifact-surface/index.d.ts +0 -2
- package/dist/artifact-surface/index.js +0 -3
- package/dist/artifact-surface-BstQxq6b.js +0 -65
- package/dist/artifact-surface-BstQxq6b.js.map +0 -1
- package/dist/capability-description-surface/index.d.ts +0 -2
- package/dist/capability-description-surface/index.js +0 -3
- package/dist/capability-description-surface-BdzknTKT.js +0 -2
- package/dist/capability-descriptor-schema-zRnfGjBc.js +0 -86
- package/dist/capability-descriptor-schema-zRnfGjBc.js.map +0 -1
- package/dist/cli/tool-portal.d.ts +0 -1
- package/dist/cli/tool-portal.js +0 -207
- package/dist/cli/tool-portal.js.map +0 -1
- package/dist/contracts/index.d.ts +0 -2
- package/dist/contracts/index.js +0 -2
- package/dist/contracts-RgGW0RX2.js +0 -611
- package/dist/contracts-RgGW0RX2.js.map +0 -1
- package/dist/gateway-runtime-client/index.d.ts +0 -385
- package/dist/gateway-runtime-client/index.d.ts.map +0 -1
- package/dist/gateway-runtime-client/index.js +0 -1439
- package/dist/gateway-runtime-client/index.js.map +0 -1
- package/dist/gateway-runtime-local-exec/gateway-runtime-local-exec-helper.d.ts +0 -1
- package/dist/gateway-runtime-local-exec/gateway-runtime-local-exec-helper.js +0 -125
- package/dist/gateway-runtime-local-exec/gateway-runtime-local-exec-helper.js.map +0 -1
- package/dist/gateway-runtime-local-exec/index.d.ts +0 -54
- package/dist/gateway-runtime-local-exec/index.d.ts.map +0 -1
- package/dist/gateway-runtime-local-exec/index.js +0 -2
- package/dist/gateway-runtime-local-exec-transport-B1hy2A3Q.js +0 -427
- package/dist/gateway-runtime-local-exec-transport-B1hy2A3Q.js.map +0 -1
- package/dist/index-B5hgm1KH.d.ts +0 -84
- package/dist/index-B5hgm1KH.d.ts.map +0 -1
- package/dist/index-BWE2_BcN.d.ts +0 -64
- package/dist/index-BWE2_BcN.d.ts.map +0 -1
- package/dist/index-Bdnvj5j3.d.ts +0 -142
- package/dist/index-Bdnvj5j3.d.ts.map +0 -1
- package/dist/index-BmH68K78.d.ts +0 -41
- package/dist/index-BmH68K78.d.ts.map +0 -1
- package/dist/index-C-NPMMvc.d.ts +0 -2396
- package/dist/index-C-NPMMvc.d.ts.map +0 -1
- package/dist/index-DKBSYuxW.d.ts +0 -239
- package/dist/index-DKBSYuxW.d.ts.map +0 -1
- package/dist/index-Dj4galCJ.d.ts +0 -17
- package/dist/index-Dj4galCJ.d.ts.map +0 -1
- package/dist/index-Dxoz-ORl.d.ts +0 -229
- package/dist/index-Dxoz-ORl.d.ts.map +0 -1
- package/dist/index-v8suC0qe.d.ts +0 -69
- package/dist/index-v8suC0qe.d.ts.map +0 -1
- package/dist/index-yeFGRMdv.d.ts +0 -152
- package/dist/index-yeFGRMdv.d.ts.map +0 -1
- package/dist/index.d.ts +0 -12
- package/dist/index.js +0 -16
- package/dist/json-value-schema-M87sjwWL.d.ts +0 -18
- package/dist/json-value-schema-M87sjwWL.d.ts.map +0 -1
- package/dist/json-value-schema-hdPkabRZ.js +0 -29
- package/dist/json-value-schema-hdPkabRZ.js.map +0 -1
- package/dist/node-tool-portal-mcp-transport-Cl2VKbLY.js +0 -156
- package/dist/node-tool-portal-mcp-transport-Cl2VKbLY.js.map +0 -1
- package/dist/portable-contracts/index.d.ts +0 -2
- package/dist/portable-contracts/index.js +0 -3
- package/dist/portable-contracts-Bca33zVa.js +0 -326
- package/dist/portable-contracts-Bca33zVa.js.map +0 -1
- package/dist/portable-refinement-authoring-ZSmR-amG.js +0 -196
- package/dist/portable-refinement-authoring-ZSmR-amG.js.map +0 -1
- package/dist/portal-call-request-schema-Cp6CMGs9.js +0 -41
- package/dist/portal-call-request-schema-Cp6CMGs9.js.map +0 -1
- package/dist/portal-call-result-schema-ByxHRCEN.js +0 -158
- package/dist/portal-call-result-schema-ByxHRCEN.js.map +0 -1
- package/dist/portal-call-result-schema-wSCaz3mC.d.ts +0 -1485
- package/dist/portal-call-result-schema-wSCaz3mC.d.ts.map +0 -1
- package/dist/portal-call-surface/index.d.ts +0 -3
- package/dist/portal-call-surface/index.js +0 -5
- package/dist/portal-call-surface-DjZVquFt.js +0 -83
- package/dist/portal-call-surface-DjZVquFt.js.map +0 -1
- package/dist/portal-error-schema-CQHgoFq4.js +0 -71
- package/dist/portal-error-schema-CQHgoFq4.js.map +0 -1
- package/dist/portal-event-surface/index.d.ts +0 -2
- package/dist/portal-event-surface/index.js +0 -3
- package/dist/portal-event-surface-CdScrgoN.js +0 -51
- package/dist/portal-event-surface-CdScrgoN.js.map +0 -1
- package/dist/testing/index.d.ts +0 -19
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js +0 -36
- package/dist/testing/index.js.map +0 -1
- package/dist/tool-portal-mcp-client/index.d.ts +0 -2
- package/dist/tool-portal-mcp-client/index.js +0 -2
- package/dist/tool-portal-mcp-client/node-tool-portal-mcp-transport.d.ts +0 -17
- package/dist/tool-portal-mcp-client/node-tool-portal-mcp-transport.d.ts.map +0 -1
- package/dist/tool-portal-mcp-client/node-tool-portal-mcp-transport.js +0 -2
- package/dist/tool-portal-mcp-client-DwJF-48Y.js +0 -90
- package/dist/tool-portal-mcp-client-DwJF-48Y.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["#client","#limits","#buffer","#terminalError","#fail","#pendingFrameBody","isRecord","assertPositiveSafeInteger","#decoder","#frameLimits","#maxPendingRequests","#discardedRequestIds","#pendingRequests","#socket","#receiveChunk","#failConnection","#closed","#receiveMessage","#nextRequestId","#writeFrameImmediately","#writeFrame","#pendingWrite","#allocateRequestId","#deadlineScheduler","#forwardFrame","#onStreamCompleted","#pauseDeadlineMilliseconds","#socket","#streamStates","#pausedStreamId","#activePauseDeadline","#transitionStream","#createStreamState","#applyEffects","#client","#attachment","#socketPath","#startupRetryPolicy","#startupRetryScheduler","#traceContextProvider","#transportFactory","#connectOnce","#connectWithStartupRetry","#connection","#connecting","#handshakeComplete"],"sources":["../../src/gateway-runtime-client/gateway-runtime-sandbox-operations.ts","../../src/gateway-runtime-client/gateway-runtime-startup-retry.ts","../../src/gateway-runtime-client/gateway-runtime-trace-context.ts","../../src/gateway-runtime-client/gateway-runtime-protocol.ts","../../src/gateway-runtime-client/node-gateway-runtime-transport.ts","../../src/gateway-runtime-client/gateway-runtime-flow-control.ts","../../src/gateway-runtime-client/gateway-runtime-socket-read-flow.ts","../../src/gateway-runtime-client/index.ts"],"sourcesContent":["import {\n\tGatewayRuntimeTrustedInvocationContextSchema,\n\tSandboxEnvironmentCloseResultSchema,\n\tSandboxEnvironmentHandleRequestSchema,\n\tSandboxEnvironmentOpenRequestSchema,\n\tSandboxEnvironmentOpenResultSchema,\n\tSandboxEnvironmentStatusResultSchema,\n\tSandboxExecCancelRequestSchema,\n\tSandboxExecCancelResultSchema,\n\tSandboxExecStartRequestSchema,\n\tSandboxExecStartResultSchema,\n\tSandboxExecWaitRequestSchema,\n\tSandboxExecWaitResultSchema,\n\tSandboxFsListRequestSchema,\n\tSandboxFsListResultSchema,\n\tSandboxFsMkdirRequestSchema,\n\tSandboxFsMkdirResultSchema,\n\tSandboxFsReadRequestSchema,\n\tSandboxFsReadResultSchema,\n\tSandboxFsRemoveRequestSchema,\n\tSandboxFsRemoveResultSchema,\n\tSandboxFsRenameRequestSchema,\n\tSandboxFsRenameResultSchema,\n\tSandboxFsStatRequestSchema,\n\tSandboxFsStatResultSchema,\n\tSandboxFsWriteRequestSchema,\n\tSandboxFsWriteResultSchema,\n\tSandboxProcessCancelRequestSchema,\n\tSandboxProcessCancelResultSchema,\n\tSandboxProcessHandleRequestSchema,\n\tSandboxProcessLogsRequestSchema,\n\tSandboxProcessLogsResultSchema,\n\tSandboxProcessStartRequestSchema,\n\tSandboxProcessStartResultSchema,\n\tSandboxProcessStatusResultSchema,\n\tSandboxProcessWaitRequestSchema,\n\tSandboxProcessWaitResultSchema,\n\tSandboxRetainedResultLookupRequestSchema,\n\tSandboxRetainedResultLookupResultSchema,\n\tSandboxStreamCloseRequestSchema,\n\tSandboxStreamCloseResultSchema,\n\tSandboxStreamReadRequestSchema,\n\tSandboxStreamReadResultSchema,\n\tSandboxStreamWriteRequestSchema,\n\tSandboxStreamWriteResultSchema,\n\tSandboxTerminalAttachRequestSchema,\n\tSandboxTerminalAttachResultSchema,\n\tSandboxTerminalResizeRequestSchema,\n\tSandboxTerminalResizeResultSchema,\n\ttype GatewayRuntimeTrustedInvocationContext,\n\ttype SandboxEnvironmentCloseRequest,\n\ttype SandboxEnvironmentCloseResult,\n\ttype SandboxEnvironmentOpenRequest,\n\ttype SandboxEnvironmentOpenResult,\n\ttype SandboxEnvironmentStatusRequest,\n\ttype SandboxEnvironmentStatusResult,\n\ttype SandboxExecCancelRequest,\n\ttype SandboxExecCancelResult,\n\ttype SandboxExecStartRequest,\n\ttype SandboxExecStartResult,\n\ttype SandboxExecWaitRequest,\n\ttype SandboxExecWaitResult,\n\ttype SandboxFsListRequest,\n\ttype SandboxFsListResult,\n\ttype SandboxFsMkdirRequest,\n\ttype SandboxFsMkdirResult,\n\ttype SandboxFsReadRequest,\n\ttype SandboxFsReadResult,\n\ttype SandboxFsRemoveRequest,\n\ttype SandboxFsRemoveResult,\n\ttype SandboxFsRenameRequest,\n\ttype SandboxFsRenameResult,\n\ttype SandboxFsStatRequest,\n\ttype SandboxFsStatResult,\n\ttype SandboxFsWriteRequest,\n\ttype SandboxFsWriteResult,\n\ttype SandboxProcessCancelRequest,\n\ttype SandboxProcessCancelResult,\n\ttype SandboxProcessLogsRequest,\n\ttype SandboxProcessLogsResult,\n\ttype SandboxProcessStartRequest,\n\ttype SandboxProcessStartResult,\n\ttype SandboxProcessStatusRequest,\n\ttype SandboxProcessStatusResult,\n\ttype SandboxProcessWaitRequest,\n\ttype SandboxProcessWaitResult,\n\ttype SandboxRetainedResultLookupRequest,\n\ttype SandboxRetainedResultLookupResult,\n\ttype SandboxStreamCloseRequest,\n\ttype SandboxStreamCloseResult,\n\ttype SandboxStreamReadRequest,\n\ttype SandboxStreamReadResult,\n\ttype SandboxStreamWriteRequest,\n\ttype SandboxStreamWriteResult,\n\ttype SandboxTerminalAttachRequest,\n\ttype SandboxTerminalAttachResult,\n\ttype SandboxTerminalResizeRequest,\n\ttype SandboxTerminalResizeResult,\n} from '../contracts/index.js';\nimport type { GatewayRuntimeTraceContext } from './gateway-runtime-trace-context.js';\n\nexport interface GatewayRuntimeTrustedRequestOptions {\n\treadonly signal?: AbortSignal;\n\treadonly traceContext?: GatewayRuntimeTraceContext;\n\treadonly trustedContext: GatewayRuntimeTrustedInvocationContext;\n}\n\ninterface GatewayRuntimeSandboxRequestClient {\n\treadonly request: (\n\t\tmethod: string,\n\t\tparams: unknown,\n\t\toptions: {\n\t\t\treadonly signal?: AbortSignal;\n\t\t\treadonly traceContext?: GatewayRuntimeTraceContext;\n\t\t},\n\t) => Promise<unknown>;\n}\n\ninterface GatewayRuntimeCanonicalSchema<TValue> {\n\treadonly parse: (value: unknown) => TValue;\n}\n\ninterface SandboxOperationRequestProps<TRequest, TResult> {\n\treadonly client: GatewayRuntimeSandboxRequestClient;\n\treadonly method: string;\n\treadonly options: GatewayRuntimeTrustedRequestOptions;\n\treadonly request: TRequest;\n\treadonly requestSchema: GatewayRuntimeCanonicalSchema<TRequest>;\n\treadonly resultSchema: GatewayRuntimeCanonicalSchema<TResult>;\n}\n\nasync function requestSandboxOperation<TRequest, TResult>(\n\tprops: SandboxOperationRequestProps<TRequest, TResult>,\n): Promise<TResult> {\n\tconst publicRequest = props.requestSchema.parse(props.request);\n\tconst trustedContext = GatewayRuntimeTrustedInvocationContextSchema.parse(\n\t\tprops.options.trustedContext,\n\t);\n\tconst result = await props.client.request(\n\t\tprops.method,\n\t\t{ publicRequest, trustedContext },\n\t\t{\n\t\t\t...(props.options.signal === undefined ? {} : { signal: props.options.signal }),\n\t\t\t...(props.options.traceContext === undefined\n\t\t\t\t? {}\n\t\t\t\t: { traceContext: props.options.traceContext }),\n\t\t},\n\t);\n\treturn props.resultSchema.parse(result);\n}\n\nexport class GatewayRuntimeSandboxEnvironmentOperations {\n\treadonly #client: GatewayRuntimeSandboxRequestClient;\n\n\tconstructor(client: GatewayRuntimeSandboxRequestClient) {\n\t\tthis.#client = client;\n\t}\n\n\tasync open(\n\t\trequest: SandboxEnvironmentOpenRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxEnvironmentOpenResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.environment.open',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxEnvironmentOpenRequestSchema,\n\t\t\tresultSchema: SandboxEnvironmentOpenResultSchema,\n\t\t});\n\t}\n\n\tasync close(\n\t\trequest: SandboxEnvironmentCloseRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxEnvironmentCloseResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.environment.close',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxEnvironmentHandleRequestSchema,\n\t\t\tresultSchema: SandboxEnvironmentCloseResultSchema,\n\t\t});\n\t}\n\n\tasync status(\n\t\trequest: SandboxEnvironmentStatusRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxEnvironmentStatusResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.environment.status',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxEnvironmentHandleRequestSchema,\n\t\t\tresultSchema: SandboxEnvironmentStatusResultSchema,\n\t\t});\n\t}\n}\n\nexport class GatewayRuntimeSandboxExecutionOperations {\n\treadonly #client: GatewayRuntimeSandboxRequestClient;\n\n\tconstructor(client: GatewayRuntimeSandboxRequestClient) {\n\t\tthis.#client = client;\n\t}\n\n\tasync start(\n\t\trequest: SandboxExecStartRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxExecStartResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.exec.start',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxExecStartRequestSchema,\n\t\t\tresultSchema: SandboxExecStartResultSchema,\n\t\t});\n\t}\n\n\tasync wait(\n\t\trequest: SandboxExecWaitRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxExecWaitResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.exec.wait',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxExecWaitRequestSchema,\n\t\t\tresultSchema: SandboxExecWaitResultSchema,\n\t\t});\n\t}\n\n\tasync cancel(\n\t\trequest: SandboxExecCancelRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxExecCancelResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.exec.cancel',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxExecCancelRequestSchema,\n\t\t\tresultSchema: SandboxExecCancelResultSchema,\n\t\t});\n\t}\n}\n\nexport class GatewayRuntimeSandboxRetainedResultOperations {\n\treadonly #client: GatewayRuntimeSandboxRequestClient;\n\n\tconstructor(client: GatewayRuntimeSandboxRequestClient) {\n\t\tthis.#client = client;\n\t}\n\n\tasync lookup(\n\t\trequest: SandboxRetainedResultLookupRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxRetainedResultLookupResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.retained-result.lookup',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxRetainedResultLookupRequestSchema,\n\t\t\tresultSchema: SandboxRetainedResultLookupResultSchema,\n\t\t});\n\t}\n}\n\nexport class GatewayRuntimeSandboxFilesystemOperations {\n\treadonly #client: GatewayRuntimeSandboxRequestClient;\n\n\tconstructor(client: GatewayRuntimeSandboxRequestClient) {\n\t\tthis.#client = client;\n\t}\n\n\tasync stat(\n\t\trequest: SandboxFsStatRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxFsStatResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.fs.stat',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxFsStatRequestSchema,\n\t\t\tresultSchema: SandboxFsStatResultSchema,\n\t\t});\n\t}\n\n\tasync list(\n\t\trequest: SandboxFsListRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxFsListResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.fs.list',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxFsListRequestSchema,\n\t\t\tresultSchema: SandboxFsListResultSchema,\n\t\t});\n\t}\n\n\tasync read(\n\t\trequest: SandboxFsReadRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxFsReadResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.fs.read',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxFsReadRequestSchema,\n\t\t\tresultSchema: SandboxFsReadResultSchema,\n\t\t});\n\t}\n\n\tasync write(\n\t\trequest: SandboxFsWriteRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxFsWriteResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.fs.write',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxFsWriteRequestSchema,\n\t\t\tresultSchema: SandboxFsWriteResultSchema,\n\t\t});\n\t}\n\n\tasync mkdir(\n\t\trequest: SandboxFsMkdirRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxFsMkdirResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.fs.mkdir',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxFsMkdirRequestSchema,\n\t\t\tresultSchema: SandboxFsMkdirResultSchema,\n\t\t});\n\t}\n\n\tasync rename(\n\t\trequest: SandboxFsRenameRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxFsRenameResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.fs.rename',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxFsRenameRequestSchema,\n\t\t\tresultSchema: SandboxFsRenameResultSchema,\n\t\t});\n\t}\n\n\tasync remove(\n\t\trequest: SandboxFsRemoveRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxFsRemoveResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.fs.remove',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxFsRemoveRequestSchema,\n\t\t\tresultSchema: SandboxFsRemoveResultSchema,\n\t\t});\n\t}\n}\n\nexport class GatewayRuntimeSandboxProcessOperations {\n\treadonly #client: GatewayRuntimeSandboxRequestClient;\n\n\tconstructor(client: GatewayRuntimeSandboxRequestClient) {\n\t\tthis.#client = client;\n\t}\n\n\tasync start(\n\t\trequest: SandboxProcessStartRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxProcessStartResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.process.start',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxProcessStartRequestSchema,\n\t\t\tresultSchema: SandboxProcessStartResultSchema,\n\t\t});\n\t}\n\n\tasync status(\n\t\trequest: SandboxProcessStatusRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxProcessStatusResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.process.status',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxProcessHandleRequestSchema,\n\t\t\tresultSchema: SandboxProcessStatusResultSchema,\n\t\t});\n\t}\n\n\tasync wait(\n\t\trequest: SandboxProcessWaitRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxProcessWaitResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.process.wait',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxProcessWaitRequestSchema,\n\t\t\tresultSchema: SandboxProcessWaitResultSchema,\n\t\t});\n\t}\n\n\tasync logs(\n\t\trequest: SandboxProcessLogsRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxProcessLogsResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.process.logs',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxProcessLogsRequestSchema,\n\t\t\tresultSchema: SandboxProcessLogsResultSchema,\n\t\t});\n\t}\n\n\tasync cancel(\n\t\trequest: SandboxProcessCancelRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxProcessCancelResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.process.cancel',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxProcessCancelRequestSchema,\n\t\t\tresultSchema: SandboxProcessCancelResultSchema,\n\t\t});\n\t}\n}\n\nexport class GatewayRuntimeSandboxStreamOperations {\n\treadonly #client: GatewayRuntimeSandboxRequestClient;\n\n\tconstructor(client: GatewayRuntimeSandboxRequestClient) {\n\t\tthis.#client = client;\n\t}\n\n\tasync read(\n\t\trequest: SandboxStreamReadRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxStreamReadResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.stream.read',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxStreamReadRequestSchema,\n\t\t\tresultSchema: SandboxStreamReadResultSchema,\n\t\t});\n\t}\n\n\tasync write(\n\t\trequest: SandboxStreamWriteRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxStreamWriteResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.stream.write',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxStreamWriteRequestSchema,\n\t\t\tresultSchema: SandboxStreamWriteResultSchema,\n\t\t});\n\t}\n\n\tasync close(\n\t\trequest: SandboxStreamCloseRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxStreamCloseResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.stream.close',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxStreamCloseRequestSchema,\n\t\t\tresultSchema: SandboxStreamCloseResultSchema,\n\t\t});\n\t}\n}\n\nexport class GatewayRuntimeSandboxTerminalOperations {\n\treadonly #client: GatewayRuntimeSandboxRequestClient;\n\n\tconstructor(client: GatewayRuntimeSandboxRequestClient) {\n\t\tthis.#client = client;\n\t}\n\n\tasync attach(\n\t\trequest: SandboxTerminalAttachRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxTerminalAttachResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.terminal.attach',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxTerminalAttachRequestSchema,\n\t\t\tresultSchema: SandboxTerminalAttachResultSchema,\n\t\t});\n\t}\n\n\tasync resize(\n\t\trequest: SandboxTerminalResizeRequest,\n\t\toptions: GatewayRuntimeTrustedRequestOptions,\n\t): Promise<SandboxTerminalResizeResult> {\n\t\treturn await requestSandboxOperation({\n\t\t\tclient: this.#client,\n\t\t\tmethod: 'sandbox.terminal.resize',\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestSchema: SandboxTerminalResizeRequestSchema,\n\t\t\tresultSchema: SandboxTerminalResizeResultSchema,\n\t\t});\n\t}\n}\n\nexport class GatewayRuntimeSandboxOperations {\n\treadonly environment: GatewayRuntimeSandboxEnvironmentOperations;\n\treadonly execution: GatewayRuntimeSandboxExecutionOperations;\n\treadonly filesystem: GatewayRuntimeSandboxFilesystemOperations;\n\treadonly process: GatewayRuntimeSandboxProcessOperations;\n\treadonly retainedResults: GatewayRuntimeSandboxRetainedResultOperations;\n\treadonly stream: GatewayRuntimeSandboxStreamOperations;\n\treadonly terminal: GatewayRuntimeSandboxTerminalOperations;\n\n\tconstructor(client: GatewayRuntimeSandboxRequestClient) {\n\t\tthis.environment = new GatewayRuntimeSandboxEnvironmentOperations(client);\n\t\tthis.execution = new GatewayRuntimeSandboxExecutionOperations(client);\n\t\tthis.filesystem = new GatewayRuntimeSandboxFilesystemOperations(client);\n\t\tthis.process = new GatewayRuntimeSandboxProcessOperations(client);\n\t\tthis.retainedResults = new GatewayRuntimeSandboxRetainedResultOperations(client);\n\t\tthis.stream = new GatewayRuntimeSandboxStreamOperations(client);\n\t\tthis.terminal = new GatewayRuntimeSandboxTerminalOperations(client);\n\t\tObject.freeze(this.environment);\n\t\tObject.freeze(this.execution);\n\t\tObject.freeze(this.filesystem);\n\t\tObject.freeze(this.process);\n\t\tObject.freeze(this.retainedResults);\n\t\tObject.freeze(this.stream);\n\t\tObject.freeze(this.terminal);\n\t}\n}\n","export interface GatewayRuntimeStartupRetryPolicy {\n\treadonly deadlineMs: number;\n\treadonly intervalMs: number;\n\treadonly maxAttempts: number;\n}\n\nexport const DEFAULT_GATEWAY_RUNTIME_STARTUP_RETRY_POLICY = Object.freeze({\n\tdeadlineMs: 5_000,\n\tintervalMs: 100,\n\tmaxAttempts: 50,\n}) satisfies GatewayRuntimeStartupRetryPolicy;\n\nexport interface GatewayRuntimeStartupRetryScheduler {\n\treadonly now: () => number;\n\treadonly wait: (delayMs: number, signal: AbortSignal) => Promise<void>;\n}\n\nexport type GatewayRuntimeStartupUnavailableKind = 'socket-absent' | 'socket-refused';\n\n/** A pre-handshake socket publication race that is safe to retry within the startup budget. */\nexport class GatewayRuntimeStartupUnavailableError extends Error {\n\treadonly code = 'startup-unavailable';\n\treadonly kind: GatewayRuntimeStartupUnavailableKind;\n\n\tconstructor(kind: GatewayRuntimeStartupUnavailableKind, options: ErrorOptions = {}) {\n\t\tsuper(`Gateway runtime startup socket is unavailable: ${kind}.`, options);\n\t\tthis.name = 'GatewayRuntimeStartupUnavailableError';\n\t\tthis.kind = kind;\n\t}\n}\n\nexport const defaultGatewayRuntimeStartupRetryScheduler: GatewayRuntimeStartupRetryScheduler = {\n\tnow: () => performance.now(),\n\twait: async (delayMs, signal): Promise<void> => {\n\t\tif (signal.aborted) throw signal.reason;\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tcleanup();\n\t\t\t\tresolve();\n\t\t\t}, delayMs);\n\t\t\tconst onAbort = (): void => {\n\t\t\t\tcleanup();\n\t\t\t\treject(signal.reason);\n\t\t\t};\n\t\t\tconst cleanup = (): void => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t\t};\n\t\t\tsignal.addEventListener('abort', onAbort, { once: true });\n\t\t});\n\t},\n};\n","import { z } from 'zod/v4';\n\nexport const GATEWAY_RUNTIME_TRACEPARENT_MAX_LENGTH = 512;\nexport const GATEWAY_RUNTIME_TRACESTATE_MAX_LENGTH = 512;\nexport const GATEWAY_RUNTIME_TRACESTATE_MAX_MEMBERS = 32;\n\nconst lowercaseHexPattern = /^[0-9a-f]+$/u;\nconst tracestateSimpleKeyPattern = /^[a-z][a-z0-9_*/-]{0,255}$/u;\nconst tracestateMultiTenantKeyPattern = /^[a-z0-9][a-z0-9_*/-]{0,240}@[a-z][a-z0-9_*/-]{0,13}$/u;\nconst tracestateValuePattern =\n\t/^[\\x20-\\x2b\\x2d-\\x3c\\x3e-\\x7e]{0,255}[\\x21-\\x2b\\x2d-\\x3c\\x3e-\\x7e]$/u;\nconst futureTraceparentSuffixPattern = /^[\\x21-\\x7e]+$/u;\n\nfunction traceparentIsValid(traceparent: string): boolean {\n\tif (traceparent.length < 55 || traceparent.length > GATEWAY_RUNTIME_TRACEPARENT_MAX_LENGTH) {\n\t\treturn false;\n\t}\n\tif (traceparent[2] !== '-' || traceparent[35] !== '-' || traceparent[52] !== '-') {\n\t\treturn false;\n\t}\n\tconst version = traceparent.slice(0, 2);\n\tconst traceId = traceparent.slice(3, 35);\n\tconst parentId = traceparent.slice(36, 52);\n\tconst traceFlags = traceparent.slice(53, 55);\n\tif (\n\t\t!lowercaseHexPattern.test(version) ||\n\t\tversion === 'ff' ||\n\t\t!lowercaseHexPattern.test(traceId) ||\n\t\ttraceId === '0'.repeat(32) ||\n\t\t!lowercaseHexPattern.test(parentId) ||\n\t\tparentId === '0'.repeat(16) ||\n\t\t!lowercaseHexPattern.test(traceFlags)\n\t) {\n\t\treturn false;\n\t}\n\tif (traceparent.length === 55) return true;\n\tif (version === '00' || traceparent[55] !== '-') return false;\n\treturn futureTraceparentSuffixPattern.test(traceparent.slice(56));\n}\n\nfunction tracestateIsValid(tracestate: string): boolean {\n\tif (tracestate.length > GATEWAY_RUNTIME_TRACESTATE_MAX_LENGTH) return false;\n\tconst rawMembers = tracestate.split(',');\n\tif (rawMembers.length > GATEWAY_RUNTIME_TRACESTATE_MAX_MEMBERS) return false;\n\tconst seenKeys = new Set<string>();\n\tfor (const rawMember of rawMembers) {\n\t\tconst member = rawMember.replace(/^[ \\t]+|[ \\t]+$/gu, '');\n\t\tif (member.length === 0) continue;\n\t\tconst equalsIndex = member.indexOf('=');\n\t\tif (equalsIndex <= 0 || equalsIndex !== member.lastIndexOf('=')) return false;\n\t\tconst key = member.slice(0, equalsIndex);\n\t\tconst value = member.slice(equalsIndex + 1);\n\t\tif (\n\t\t\t(!tracestateSimpleKeyPattern.test(key) && !tracestateMultiTenantKeyPattern.test(key)) ||\n\t\t\t!tracestateValuePattern.test(value)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tif (seenKeys.has(key)) return false;\n\t\tseenKeys.add(key);\n\t}\n\treturn true;\n}\n\nconst GatewayRuntimeTraceparentSchema = z\n\t.string()\n\t.max(GATEWAY_RUNTIME_TRACEPARENT_MAX_LENGTH)\n\t.refine(traceparentIsValid, 'traceparent must follow the bounded W3C Trace Context grammar.');\n\nconst GatewayRuntimeTracestateSchema = z\n\t.string()\n\t.max(GATEWAY_RUNTIME_TRACESTATE_MAX_LENGTH)\n\t.refine(tracestateIsValid, 'tracestate must follow the bounded W3C Trace Context grammar.');\n\nexport const GatewayRuntimeTraceContextSchema = z\n\t.object({\n\t\ttraceparent: GatewayRuntimeTraceparentSchema,\n\t\ttracestate: GatewayRuntimeTracestateSchema.optional(),\n\t})\n\t.strict();\n\nexport type GatewayRuntimeTraceContext = z.infer<typeof GatewayRuntimeTraceContextSchema>;\n\n/** Read current invocation metadata; the client validates every returned value before transport. */\nexport type GatewayRuntimeTraceContextProvider = () => unknown;\n","export type GatewayRuntimeProtocolErrorCode =\n\t| 'BUFFER_LIMIT_EXCEEDED'\n\t| 'CONTENT_LENGTH_OVERFLOW'\n\t| 'CONTENT_TOO_LARGE'\n\t| 'DUPLICATE_CONTENT_LENGTH'\n\t| 'FRAME_LIMIT_EXCEEDED'\n\t| 'HEADER_TOO_LARGE'\n\t| 'INCOMPLETE_FRAME_BODY'\n\t| 'INCOMPLETE_FRAME_HEADER'\n\t| 'INVALID_JSON'\n\t| 'INVALID_JSON_RPC_ENVELOPE'\n\t| 'INVALID_UTF8'\n\t| 'JSON_RPC_BATCH_UNSUPPORTED'\n\t| 'MALFORMED_HEADER'\n\t| 'MISSING_HEADER_DELIMITER'\n\t| 'NEGATIVE_CONTENT_LENGTH'\n\t| 'NON_DECIMAL_CONTENT_LENGTH'\n\t| 'UNKNOWN_HEADER'\n\t| 'UNKNOWN_JSON_RPC_FIELD'\n\t| 'UNSAFE_CONTENT_LENGTH'\n\t| 'UNSUPPORTED_JSON_RPC_VERSION';\n\nexport interface GatewayRuntimeFrameLimits {\n\treadonly maxBufferedBytes: number;\n\treadonly maxContentBytes: number;\n\treadonly maxFramesPerChunk: number;\n\treadonly maxHeaderBytes: number;\n}\n\nexport const DEFAULT_GATEWAY_RUNTIME_FRAME_LIMITS = Object.freeze({\n\tmaxBufferedBytes: 1_056_768,\n\tmaxContentBytes: 1_048_576,\n\tmaxFramesPerChunk: 32,\n\tmaxHeaderBytes: 8_192,\n}) satisfies GatewayRuntimeFrameLimits;\n\nexport type GatewayRuntimeFrameLimitOverrides = Partial<GatewayRuntimeFrameLimits>;\n\nexport type GatewayRuntimeJsonRpcMessage = Readonly<Record<string, unknown>> & {\n\treadonly jsonrpc: '2.0';\n};\n\ninterface PendingFrameBody {\n\treadonly bodyStartOffset: number;\n\treadonly contentLength: number;\n}\n\nconst headerDelimiter = new Uint8Array([13, 10, 13, 10]);\nconst strictUtf8Decoder = new TextDecoder('utf-8', { fatal: true });\nconst utf8Encoder = new TextEncoder();\n\nexport class GatewayRuntimeProtocolError extends Error {\n\treadonly code: GatewayRuntimeProtocolErrorCode;\n\n\tconstructor(code: GatewayRuntimeProtocolErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = 'GatewayRuntimeProtocolError';\n\t\tthis.code = code;\n\t}\n}\n\nfunction protocolError(\n\tcode: GatewayRuntimeProtocolErrorCode,\n\tmessage: string,\n): GatewayRuntimeProtocolError {\n\treturn new GatewayRuntimeProtocolError(code, message);\n}\n\nfunction assertPositiveLimit(value: number, fieldName: keyof GatewayRuntimeFrameLimits): void {\n\tif (!Number.isSafeInteger(value) || value <= 0) {\n\t\tthrow new Error(`${fieldName} must be a positive safe integer.`);\n\t}\n}\n\nfunction resolveFrameLimits(\n\toverrides: GatewayRuntimeFrameLimitOverrides,\n): GatewayRuntimeFrameLimits {\n\tconst limits = {\n\t\t...DEFAULT_GATEWAY_RUNTIME_FRAME_LIMITS,\n\t\t...overrides,\n\t};\n\tassertPositiveLimit(limits.maxBufferedBytes, 'maxBufferedBytes');\n\tassertPositiveLimit(limits.maxContentBytes, 'maxContentBytes');\n\tassertPositiveLimit(limits.maxFramesPerChunk, 'maxFramesPerChunk');\n\tassertPositiveLimit(limits.maxHeaderBytes, 'maxHeaderBytes');\n\treturn Object.freeze(limits);\n}\n\nfunction concatenateBytes(left: Uint8Array, right: Uint8Array): Uint8Array {\n\tif (left.byteLength === 0) return new Uint8Array(right);\n\tif (right.byteLength === 0) return new Uint8Array(left);\n\tconst combinedBytes = new Uint8Array(left.byteLength + right.byteLength);\n\tcombinedBytes.set(left, 0);\n\tcombinedBytes.set(right, left.byteLength);\n\treturn combinedBytes;\n}\n\nfunction findHeaderDelimiter(bytes: Uint8Array): number {\n\touter: for (\n\t\tlet offset = 0;\n\t\toffset <= bytes.byteLength - headerDelimiter.byteLength;\n\t\toffset += 1\n\t) {\n\t\tfor (\n\t\t\tlet delimiterOffset = 0;\n\t\t\tdelimiterOffset < headerDelimiter.byteLength;\n\t\t\tdelimiterOffset += 1\n\t\t) {\n\t\t\tif (bytes[offset + delimiterOffset] !== headerDelimiter[delimiterOffset]) continue outer;\n\t\t}\n\t\treturn offset;\n\t}\n\treturn -1;\n}\n\nfunction decodeUtf8(bytes: Uint8Array, code: GatewayRuntimeProtocolErrorCode): string {\n\ttry {\n\t\treturn strictUtf8Decoder.decode(bytes);\n\t} catch {\n\t\tthrow protocolError(code, 'Gateway runtime frame contains invalid UTF-8.');\n\t}\n}\n\nfunction parseContentLength(headerBytes: Uint8Array): number {\n\tconst headerText = decodeUtf8(headerBytes, 'MALFORMED_HEADER');\n\tconst headerLines = headerText.split('\\r\\n');\n\tlet contentLengthText: string | undefined;\n\n\tfor (const headerLine of headerLines) {\n\t\tconst delimiterIndex = headerLine.indexOf(':');\n\t\tif (delimiterIndex <= 0) {\n\t\t\tthrow protocolError('MALFORMED_HEADER', 'Gateway runtime frame header is malformed.');\n\t\t}\n\t\tconst headerName = headerLine.slice(0, delimiterIndex).trim().toLowerCase();\n\t\tif (headerName !== 'content-length') {\n\t\t\tthrow protocolError(\n\t\t\t\t'UNKNOWN_HEADER',\n\t\t\t\t`Gateway runtime frame header '${headerName}' is unknown.`,\n\t\t\t);\n\t\t}\n\t\tif (contentLengthText !== undefined) {\n\t\t\tthrow protocolError(\n\t\t\t\t'DUPLICATE_CONTENT_LENGTH',\n\t\t\t\t'Gateway runtime frame contains duplicate Content-Length headers.',\n\t\t\t);\n\t\t}\n\t\tcontentLengthText = headerLine.slice(delimiterIndex + 1).trim();\n\t}\n\n\tif (contentLengthText === undefined || contentLengthText.length === 0) {\n\t\tthrow protocolError('MALFORMED_HEADER', 'Gateway runtime frame is missing Content-Length.');\n\t}\n\tif (contentLengthText.startsWith('-')) {\n\t\tthrow protocolError('NEGATIVE_CONTENT_LENGTH', 'Content-Length must not be negative.');\n\t}\n\tif (!/^\\d+$/u.test(contentLengthText)) {\n\t\tthrow protocolError(\n\t\t\t'NON_DECIMAL_CONTENT_LENGTH',\n\t\t\t'Content-Length must contain decimal digits.',\n\t\t);\n\t}\n\n\tconst contentLengthBigInt = BigInt(contentLengthText);\n\tif (contentLengthBigInt > BigInt(Number.MAX_SAFE_INTEGER)) {\n\t\tthrow protocolError('UNSAFE_CONTENT_LENGTH', 'Content-Length exceeds the safe integer range.');\n\t}\n\treturn Number(contentLengthBigInt);\n}\n\nfunction isJsonObject(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction hasSupportedJsonRpcVersion(\n\tvalue: Readonly<Record<string, unknown>>,\n): value is GatewayRuntimeJsonRpcMessage {\n\treturn value.jsonrpc === '2.0';\n}\n\nfunction jsonRpcIdIsValid(value: unknown): boolean {\n\treturn (\n\t\ttypeof value === 'string' ||\n\t\t(typeof value === 'number' && Number.isSafeInteger(value)) ||\n\t\tvalue === null\n\t);\n}\n\nfunction jsonRpcParamsAreValid(value: unknown): boolean {\n\treturn Array.isArray(value) || isJsonObject(value);\n}\n\nfunction hasOnlyKeys(\n\trecord: Readonly<Record<string, unknown>>,\n\tallowedKeys: ReadonlySet<string>,\n): boolean {\n\treturn Object.keys(record).every((key) => allowedKeys.has(key));\n}\n\nfunction validateJsonRpcErrorObject(value: unknown): void {\n\tif (!isJsonObject(value)) {\n\t\tthrow protocolError('INVALID_JSON_RPC_ENVELOPE', 'JSON-RPC error object is invalid.');\n\t}\n\tconst allowedErrorKeys = new Set(['code', 'data', 'message']);\n\tif (!hasOnlyKeys(value, allowedErrorKeys)) {\n\t\tthrow protocolError('UNKNOWN_JSON_RPC_FIELD', 'JSON-RPC error object has an unknown field.');\n\t}\n\tif (!Number.isSafeInteger(value.code) || typeof value.message !== 'string') {\n\t\tthrow protocolError('INVALID_JSON_RPC_ENVELOPE', 'JSON-RPC error object is invalid.');\n\t}\n}\n\nfunction validateJsonRpcEnvelope(value: unknown): GatewayRuntimeJsonRpcMessage {\n\tif (Array.isArray(value)) {\n\t\tthrow protocolError('JSON_RPC_BATCH_UNSUPPORTED', 'JSON-RPC batches are not supported.');\n\t}\n\tif (!isJsonObject(value)) {\n\t\tthrow protocolError('INVALID_JSON_RPC_ENVELOPE', 'JSON-RPC messages must be objects.');\n\t}\n\tif (!hasSupportedJsonRpcVersion(value)) {\n\t\tthrow protocolError(\n\t\t\t'UNSUPPORTED_JSON_RPC_VERSION',\n\t\t\t'Gateway runtime requires JSON-RPC version 2.0.',\n\t\t);\n\t}\n\n\tif (Object.hasOwn(value, 'method')) {\n\t\tconst allowedRequestKeys = new Set(['id', 'jsonrpc', 'method', 'params']);\n\t\tif (!hasOnlyKeys(value, allowedRequestKeys)) {\n\t\t\tthrow protocolError('UNKNOWN_JSON_RPC_FIELD', 'JSON-RPC request has an unknown field.');\n\t\t}\n\t\tif (\n\t\t\ttypeof value.method !== 'string' ||\n\t\t\tvalue.method.length === 0 ||\n\t\t\t(Object.hasOwn(value, 'id') && !jsonRpcIdIsValid(value.id)) ||\n\t\t\t(Object.hasOwn(value, 'params') && !jsonRpcParamsAreValid(value.params))\n\t\t) {\n\t\t\tthrow protocolError('INVALID_JSON_RPC_ENVELOPE', 'JSON-RPC request envelope is invalid.');\n\t\t}\n\t\treturn value;\n\t}\n\n\tconst hasResult = Object.hasOwn(value, 'result');\n\tconst hasError = Object.hasOwn(value, 'error');\n\tconst allowedResponseKeys = new Set(['error', 'id', 'jsonrpc', 'result']);\n\tif (!hasOnlyKeys(value, allowedResponseKeys)) {\n\t\tthrow protocolError('UNKNOWN_JSON_RPC_FIELD', 'JSON-RPC response has an unknown field.');\n\t}\n\tif (!Object.hasOwn(value, 'id') || !jsonRpcIdIsValid(value.id) || hasResult === hasError) {\n\t\tthrow protocolError('INVALID_JSON_RPC_ENVELOPE', 'JSON-RPC response envelope is invalid.');\n\t}\n\tif (hasError) validateJsonRpcErrorObject(value.error);\n\treturn value;\n}\n\nfunction parseFrameBody(bodyBytes: Uint8Array): GatewayRuntimeJsonRpcMessage {\n\tconst bodyText = decodeUtf8(bodyBytes, 'INVALID_UTF8');\n\tlet parsedBody: unknown;\n\ttry {\n\t\tparsedBody = JSON.parse(bodyText) as unknown;\n\t} catch {\n\t\tthrow protocolError('INVALID_JSON', 'Gateway runtime frame body is not valid JSON.');\n\t}\n\treturn validateJsonRpcEnvelope(parsedBody);\n}\n\nexport class GatewayRuntimeFrameDecoder {\n\treadonly #limits: GatewayRuntimeFrameLimits;\n\t#buffer: Uint8Array = new Uint8Array(0);\n\t#pendingFrameBody: PendingFrameBody | undefined;\n\t#terminalError: GatewayRuntimeProtocolError | undefined;\n\n\tconstructor(limitOverrides: GatewayRuntimeFrameLimitOverrides = {}) {\n\t\tthis.#limits = resolveFrameLimits(limitOverrides);\n\t}\n\n\tget bufferedByteLength(): number {\n\t\treturn this.#buffer.byteLength;\n\t}\n\n\t#fail(error: GatewayRuntimeProtocolError): never {\n\t\tthis.#terminalError ??= error;\n\t\tthrow this.#terminalError;\n\t}\n\n\tpush(chunk: Uint8Array): readonly GatewayRuntimeJsonRpcMessage[] {\n\t\tif (this.#terminalError !== undefined) throw this.#terminalError;\n\t\tif (chunk.byteLength > this.#limits.maxBufferedBytes - this.#buffer.byteLength) {\n\t\t\tthis.#fail(\n\t\t\t\tprotocolError(\n\t\t\t\t\t'BUFFER_LIMIT_EXCEEDED',\n\t\t\t\t\t'Gateway runtime decoder input exceeds its buffer limit.',\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tlet workingBuffer = concatenateBytes(this.#buffer, chunk);\n\t\tlet pendingFrameBody = this.#pendingFrameBody;\n\t\tconst decodedMessages: GatewayRuntimeJsonRpcMessage[] = [];\n\n\t\ttry {\n\t\t\twhile (workingBuffer.byteLength > 0) {\n\t\t\t\tif (pendingFrameBody === undefined) {\n\t\t\t\t\tconst headerDelimiterOffset = findHeaderDelimiter(workingBuffer);\n\t\t\t\t\tif (headerDelimiterOffset < 0) {\n\t\t\t\t\t\tif (workingBuffer.byteLength > this.#limits.maxHeaderBytes) {\n\t\t\t\t\t\t\tthis.#fail(\n\t\t\t\t\t\t\t\tprotocolError(\n\t\t\t\t\t\t\t\t\t'HEADER_TOO_LARGE',\n\t\t\t\t\t\t\t\t\t'Gateway runtime frame header exceeds its limit.',\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (workingBuffer.byteLength > this.#limits.maxBufferedBytes) {\n\t\t\t\t\t\t\tthis.#fail(\n\t\t\t\t\t\t\t\tprotocolError('BUFFER_LIMIT_EXCEEDED', 'Gateway runtime decoder buffer is full.'),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (headerDelimiterOffset > this.#limits.maxHeaderBytes) {\n\t\t\t\t\t\tthis.#fail(\n\t\t\t\t\t\t\tprotocolError('HEADER_TOO_LARGE', 'Gateway runtime frame header exceeds its limit.'),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst bodyStartOffset = headerDelimiterOffset + headerDelimiter.byteLength;\n\t\t\t\t\tconst contentLength = parseContentLength(\n\t\t\t\t\t\tworkingBuffer.subarray(0, headerDelimiterOffset),\n\t\t\t\t\t);\n\t\t\t\t\tif (contentLength > this.#limits.maxContentBytes) {\n\t\t\t\t\t\tthis.#fail(\n\t\t\t\t\t\t\tprotocolError('CONTENT_TOO_LARGE', 'Gateway runtime frame body exceeds its limit.'),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (bodyStartOffset + contentLength > this.#limits.maxBufferedBytes) {\n\t\t\t\t\t\tthis.#fail(\n\t\t\t\t\t\t\tprotocolError(\n\t\t\t\t\t\t\t\t'CONTENT_LENGTH_OVERFLOW',\n\t\t\t\t\t\t\t\t'Gateway runtime frame cannot fit within the decoder buffer limit.',\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tpendingFrameBody = { bodyStartOffset, contentLength };\n\t\t\t\t}\n\n\t\t\t\tconst bodyEndOffset = pendingFrameBody.bodyStartOffset + pendingFrameBody.contentLength;\n\t\t\t\tif (workingBuffer.byteLength < bodyEndOffset) break;\n\t\t\t\tif (decodedMessages.length >= this.#limits.maxFramesPerChunk) {\n\t\t\t\t\tthis.#fail(\n\t\t\t\t\t\tprotocolError(\n\t\t\t\t\t\t\t'FRAME_LIMIT_EXCEEDED',\n\t\t\t\t\t\t\t'Gateway runtime chunk contains too many complete frames.',\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tdecodedMessages.push(\n\t\t\t\t\tparseFrameBody(workingBuffer.subarray(pendingFrameBody.bodyStartOffset, bodyEndOffset)),\n\t\t\t\t);\n\t\t\t\tworkingBuffer = workingBuffer.slice(bodyEndOffset);\n\t\t\t\tpendingFrameBody = undefined;\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tif (error instanceof GatewayRuntimeProtocolError) this.#fail(error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tthis.#buffer = workingBuffer;\n\t\tthis.#pendingFrameBody = pendingFrameBody;\n\t\treturn decodedMessages;\n\t}\n\n\tfinish(): void {\n\t\tif (this.#terminalError !== undefined) throw this.#terminalError;\n\t\tif (this.#buffer.byteLength === 0) return;\n\t\tif (this.#pendingFrameBody !== undefined) {\n\t\t\tthis.#fail(protocolError('INCOMPLETE_FRAME_BODY', 'Gateway runtime frame body ended early.'));\n\t\t}\n\n\t\tconst bufferedHeader = new TextDecoder().decode(this.#buffer);\n\t\tconst code = bufferedHeader.includes('\\r\\n')\n\t\t\t? 'MISSING_HEADER_DELIMITER'\n\t\t\t: 'INCOMPLETE_FRAME_HEADER';\n\t\tthis.#fail(protocolError(code, 'Gateway runtime frame header ended early.'));\n\t}\n}\n\nexport function encodeGatewayRuntimeFrame(\n\tmessage: unknown,\n\tlimitOverrides: GatewayRuntimeFrameLimitOverrides = {},\n): Uint8Array {\n\tvalidateJsonRpcEnvelope(message);\n\tconst limits = resolveFrameLimits(limitOverrides);\n\tlet serializedMessage: string | undefined;\n\ttry {\n\t\tserializedMessage = JSON.stringify(message);\n\t} catch {\n\t\tthrow protocolError('INVALID_JSON_RPC_ENVELOPE', 'JSON-RPC message is not serializable.');\n\t}\n\tif (serializedMessage === undefined) {\n\t\tthrow protocolError('INVALID_JSON_RPC_ENVELOPE', 'JSON-RPC message is not serializable.');\n\t}\n\tvalidateJsonRpcEnvelope(JSON.parse(serializedMessage) as unknown);\n\tconst bodyBytes = utf8Encoder.encode(serializedMessage);\n\tif (bodyBytes.byteLength > limits.maxContentBytes) {\n\t\tthrow protocolError('CONTENT_TOO_LARGE', 'Gateway runtime frame body exceeds its limit.');\n\t}\n\tconst headerBytes = utf8Encoder.encode(`Content-Length: ${bodyBytes.byteLength}\\r\\n\\r\\n`);\n\tif (headerBytes.byteLength - headerDelimiter.byteLength > limits.maxHeaderBytes) {\n\t\tthrow protocolError('HEADER_TOO_LARGE', 'Gateway runtime frame header exceeds its limit.');\n\t}\n\tif (headerBytes.byteLength + bodyBytes.byteLength > limits.maxBufferedBytes) {\n\t\tthrow protocolError(\n\t\t\t'CONTENT_LENGTH_OVERFLOW',\n\t\t\t'Gateway runtime frame cannot fit within the buffer limit.',\n\t\t);\n\t}\n\treturn concatenateBytes(headerBytes, bodyBytes);\n}\n","import net from 'node:net';\n\nimport {\n\tGatewayRuntimeFrameDecoder,\n\tencodeGatewayRuntimeFrame,\n\ttype GatewayRuntimeFrameLimitOverrides,\n\ttype GatewayRuntimeJsonRpcMessage,\n} from './gateway-runtime-protocol.js';\nimport { GatewayRuntimeStartupUnavailableError } from './gateway-runtime-startup-retry.js';\nimport type {\n\tGatewayRuntimeAttachmentMetadata,\n\tGatewayRuntimeConnection,\n\tGatewayRuntimeRequestOptions,\n\tGatewayRuntimeTransportFactory,\n} from './index.js';\n\nexport type NodeGatewayRuntimeTransportErrorCode =\n\t| 'connection-closed'\n\t| 'connection-failed'\n\t| 'pending-request-limit-exceeded'\n\t| 'protocol-failed'\n\t| 'request-aborted'\n\t| 'request-id-exhausted'\n\t| 'request-write-failed'\n\t| 'unexpected-message';\n\nexport const GATEWAY_RUNTIME_REQUEST_CANCEL_NOTIFICATION_METHOD = 'notifications/cancelled';\n\nexport class NodeGatewayRuntimeTransportError extends Error {\n\treadonly code: NodeGatewayRuntimeTransportErrorCode;\n\n\tconstructor(\n\t\tcode: NodeGatewayRuntimeTransportErrorCode,\n\t\tmessage: string,\n\t\toptions: ErrorOptions = {},\n\t) {\n\t\tsuper(message, options);\n\t\tthis.name = 'NodeGatewayRuntimeTransportError';\n\t\tthis.code = code;\n\t}\n}\n\nexport class GatewayRuntimeRemoteError extends Error {\n\treadonly code: string;\n\treadonly data: unknown;\n\n\tconstructor(code: string, message: string, data?: unknown) {\n\t\tsuper(message);\n\t\tthis.name = 'GatewayRuntimeRemoteError';\n\t\tthis.code = code;\n\t\tthis.data = data;\n\t}\n}\n\nexport interface NodeGatewayRuntimeTransportOptions {\n\treadonly frameLimits?: GatewayRuntimeFrameLimitOverrides;\n\treadonly maxPendingRequests?: number;\n}\n\ninterface PendingRequest {\n\treadonly reject: (error: Error) => void;\n\treadonly resolve: (result: unknown) => void;\n}\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction nodeErrorCode(error: unknown): string | undefined {\n\treturn isRecord(error) && typeof error['code'] === 'string' ? error['code'] : undefined;\n}\n\nfunction assertPositiveSafeInteger(value: number, fieldName: string): void {\n\tif (!Number.isSafeInteger(value) || value <= 0) {\n\t\tthrow new Error(`${fieldName} must be a positive safe integer.`);\n\t}\n}\n\nfunction createRemoteError(errorObject: unknown): GatewayRuntimeRemoteError {\n\tif (\n\t\t!isRecord(errorObject) ||\n\t\t!Number.isSafeInteger(errorObject['code']) ||\n\t\ttypeof errorObject['message'] !== 'string'\n\t) {\n\t\treturn new GatewayRuntimeRemoteError(\n\t\t\t'invalid-remote-error',\n\t\t\t'Gateway runtime returned an invalid JSON-RPC error.',\n\t\t);\n\t}\n\treturn new GatewayRuntimeRemoteError(\n\t\tString(errorObject['code']),\n\t\terrorObject['message'],\n\t\terrorObject['data'],\n\t);\n}\n\nclass NodeGatewayRuntimeConnection implements GatewayRuntimeConnection {\n\treadonly #decoder: GatewayRuntimeFrameDecoder;\n\treadonly #frameLimits: GatewayRuntimeFrameLimitOverrides;\n\treadonly #maxPendingRequests: number;\n\treadonly #discardedRequestIds = new Set<number>();\n\treadonly #pendingRequests = new Map<number, PendingRequest>();\n\treadonly #socket: net.Socket;\n\t#closed = false;\n\t#nextRequestId = 1;\n\t#pendingWrite: Promise<void> = Promise.resolve();\n\n\tconstructor(options: {\n\t\treadonly frameLimits: GatewayRuntimeFrameLimitOverrides;\n\t\treadonly maxPendingRequests: number;\n\t\treadonly socket: net.Socket;\n\t}) {\n\t\tthis.#decoder = new GatewayRuntimeFrameDecoder(options.frameLimits);\n\t\tthis.#frameLimits = options.frameLimits;\n\t\tthis.#maxPendingRequests = options.maxPendingRequests;\n\t\tthis.#socket = options.socket;\n\t\tthis.#socket.on('data', (chunk: Buffer) => this.#receiveChunk(chunk));\n\t\tthis.#socket.once('close', () => {\n\t\t\tthis.#failConnection(\n\t\t\t\tnew NodeGatewayRuntimeTransportError(\n\t\t\t\t\t'connection-closed',\n\t\t\t\t\t'Gateway runtime connection closed.',\n\t\t\t\t),\n\t\t\t);\n\t\t});\n\t\tthis.#socket.once('error', (error) => {\n\t\t\tthis.#failConnection(\n\t\t\t\tnew NodeGatewayRuntimeTransportError(\n\t\t\t\t\t'connection-failed',\n\t\t\t\t\t'Gateway runtime connection failed.',\n\t\t\t\t\t{ cause: error },\n\t\t\t\t),\n\t\t\t);\n\t\t});\n\t}\n\n\t#failConnection(error: Error): void {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tfor (const pendingRequest of this.#pendingRequests.values()) {\n\t\t\tpendingRequest.reject(error);\n\t\t}\n\t\tthis.#pendingRequests.clear();\n\t\tthis.#discardedRequestIds.clear();\n\t\tif (!this.#socket.destroyed) this.#socket.destroy();\n\t}\n\n\t#receiveChunk(chunk: Uint8Array): void {\n\t\tif (this.#closed) return;\n\t\tlet messages: readonly GatewayRuntimeJsonRpcMessage[];\n\t\ttry {\n\t\t\tmessages = this.#decoder.push(chunk);\n\t\t} catch (error: unknown) {\n\t\t\tthis.#failConnection(\n\t\t\t\tnew NodeGatewayRuntimeTransportError(\n\t\t\t\t\t'protocol-failed',\n\t\t\t\t\t'Gateway runtime response framing failed.',\n\t\t\t\t\t{ cause: error },\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tfor (const message of messages) this.#receiveMessage(message);\n\t}\n\n\t#receiveMessage(message: GatewayRuntimeJsonRpcMessage): void {\n\t\tif (!Object.hasOwn(message, 'id') || Object.hasOwn(message, 'method')) {\n\t\t\tthis.#failConnection(\n\t\t\t\tnew NodeGatewayRuntimeTransportError(\n\t\t\t\t\t'unexpected-message',\n\t\t\t\t\t'Gateway runtime client received an unexpected request or notification.',\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst requestId = message['id'];\n\t\tif (typeof requestId !== 'number' || !Number.isSafeInteger(requestId)) {\n\t\t\tthis.#failConnection(\n\t\t\t\tnew NodeGatewayRuntimeTransportError(\n\t\t\t\t\t'unexpected-message',\n\t\t\t\t\t'Gateway runtime response id is not a pending integer request id.',\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst pendingRequest = this.#pendingRequests.get(requestId);\n\t\tif (pendingRequest === undefined) {\n\t\t\tif (this.#discardedRequestIds.delete(requestId)) return;\n\t\t\tthis.#failConnection(\n\t\t\t\tnew NodeGatewayRuntimeTransportError(\n\t\t\t\t\t'unexpected-message',\n\t\t\t\t\t'Gateway runtime response does not match a pending request.',\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis.#pendingRequests.delete(requestId);\n\t\tif (Object.hasOwn(message, 'error')) {\n\t\t\tpendingRequest.reject(createRemoteError(message['error']));\n\t\t\treturn;\n\t\t}\n\t\tpendingRequest.resolve(message['result']);\n\t}\n\n\t#allocateRequestId(): number {\n\t\tif (!Number.isSafeInteger(this.#nextRequestId)) {\n\t\t\tthrow new NodeGatewayRuntimeTransportError(\n\t\t\t\t'request-id-exhausted',\n\t\t\t\t'Gateway runtime request id space is exhausted.',\n\t\t\t);\n\t\t}\n\t\tconst requestId = this.#nextRequestId;\n\t\tthis.#nextRequestId += 1;\n\t\treturn requestId;\n\t}\n\n\tasync #writeFrameImmediately(frame: Uint8Array): Promise<void> {\n\t\tif (this.#closed) {\n\t\t\tthrow new NodeGatewayRuntimeTransportError(\n\t\t\t\t'connection-closed',\n\t\t\t\t'Gateway runtime connection is closed.',\n\t\t\t);\n\t\t}\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst onError = (error: Error): void => {\n\t\t\t\tcleanup();\n\t\t\t\treject(\n\t\t\t\t\tnew NodeGatewayRuntimeTransportError(\n\t\t\t\t\t\t'request-write-failed',\n\t\t\t\t\t\t'Gateway runtime request write failed.',\n\t\t\t\t\t\t{ cause: error },\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t};\n\t\t\tconst cleanup = (): void => {\n\t\t\t\tthis.#socket.off('error', onError);\n\t\t\t};\n\t\t\tthis.#socket.once('error', onError);\n\t\t\tthis.#socket.write(frame, (error?: Error | null) => {\n\t\t\t\tif (error !== undefined && error !== null) {\n\t\t\t\t\tonError(error);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcleanup();\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\t\tif (!this.#socket.writableNeedDrain) return;\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst onDrain = (): void => {\n\t\t\t\tcleanup();\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tconst onError = (error: Error): void => {\n\t\t\t\tcleanup();\n\t\t\t\treject(error);\n\t\t\t};\n\t\t\tconst cleanup = (): void => {\n\t\t\t\tthis.#socket.off('drain', onDrain);\n\t\t\t\tthis.#socket.off('error', onError);\n\t\t\t};\n\t\t\tthis.#socket.once('drain', onDrain);\n\t\t\tthis.#socket.once('error', onError);\n\t\t});\n\t}\n\n\tasync #writeFrame(frame: Uint8Array): Promise<void> {\n\t\tconst write = this.#pendingWrite.then(async () => await this.#writeFrameImmediately(frame));\n\t\tthis.#pendingWrite = write.catch(() => undefined);\n\t\tawait write;\n\t}\n\n\tasync handshake(\n\t\tattachment: GatewayRuntimeAttachmentMetadata,\n\t\toptions: GatewayRuntimeRequestOptions = {},\n\t): Promise<void> {\n\t\tconst decision = await this.request('managed-plugin.handshake', attachment, options);\n\t\tif (isRecord(decision) && decision['kind'] === 'accepted') return;\n\t\tconst rejectionCode = isRecord(decision) ? decision['code'] : undefined;\n\t\tthrow new GatewayRuntimeRemoteError(\n\t\t\ttypeof rejectionCode === 'string' ? rejectionCode : 'invalid-handshake',\n\t\t\t'Gateway runtime rejected the managed-plugin attachment.',\n\t\t\tdecision,\n\t\t);\n\t}\n\n\tasync request(\n\t\tmethod: string,\n\t\tparams: unknown,\n\t\toptions: GatewayRuntimeRequestOptions = {},\n\t): Promise<unknown> {\n\t\tif (options.signal?.aborted === true) {\n\t\t\tthrow new NodeGatewayRuntimeTransportError(\n\t\t\t\t'request-aborted',\n\t\t\t\t'Gateway runtime request was aborted before dispatch.',\n\t\t\t\t{ cause: options.signal.reason },\n\t\t\t);\n\t\t}\n\t\tif (this.#pendingRequests.size >= this.#maxPendingRequests) {\n\t\t\tthrow new NodeGatewayRuntimeTransportError(\n\t\t\t\t'pending-request-limit-exceeded',\n\t\t\t\t'Gateway runtime pending request limit was reached.',\n\t\t\t);\n\t\t}\n\t\tconst requestId = this.#allocateRequestId();\n\t\tconst frame = encodeGatewayRuntimeFrame(\n\t\t\t{ id: requestId, jsonrpc: '2.0', method, params },\n\t\t\tthis.#frameLimits,\n\t\t);\n\t\treturn await new Promise<unknown>((resolve, reject) => {\n\t\t\tlet settled = false;\n\t\t\tconst settleRejected = (error: Error): void => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\toptions.signal?.removeEventListener('abort', onAbort);\n\t\t\t\tthis.#pendingRequests.delete(requestId);\n\t\t\t\treject(error);\n\t\t\t};\n\t\t\tconst settleResolved = (result: unknown): void => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\toptions.signal?.removeEventListener('abort', onAbort);\n\t\t\t\tresolve(result);\n\t\t\t};\n\t\t\tconst onAbort = (): void => {\n\t\t\t\tif (settled) return;\n\t\t\t\tif (this.#discardedRequestIds.size >= this.#maxPendingRequests) {\n\t\t\t\t\tconst capacityError = new NodeGatewayRuntimeTransportError(\n\t\t\t\t\t\t'pending-request-limit-exceeded',\n\t\t\t\t\t\t'Gateway runtime discarded-request limit was reached.',\n\t\t\t\t\t);\n\t\t\t\t\tsettleRejected(capacityError);\n\t\t\t\t\tthis.#failConnection(capacityError);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.#discardedRequestIds.add(requestId);\n\t\t\t\tsettleRejected(\n\t\t\t\t\tnew NodeGatewayRuntimeTransportError(\n\t\t\t\t\t\t'request-aborted',\n\t\t\t\t\t\t'Gateway runtime request was aborted locally.',\n\t\t\t\t\t\t{ cause: options.signal?.reason },\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tconst cancellationFrame = encodeGatewayRuntimeFrame(\n\t\t\t\t\t{\n\t\t\t\t\t\tjsonrpc: '2.0',\n\t\t\t\t\t\tmethod: GATEWAY_RUNTIME_REQUEST_CANCEL_NOTIFICATION_METHOD,\n\t\t\t\t\t\tparams: { requestId },\n\t\t\t\t\t},\n\t\t\t\t\tthis.#frameLimits,\n\t\t\t\t);\n\t\t\t\tvoid this.#writeFrame(cancellationFrame).catch((error: unknown) => {\n\t\t\t\t\tthis.#failConnection(\n\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t: new NodeGatewayRuntimeTransportError(\n\t\t\t\t\t\t\t\t\t'request-write-failed',\n\t\t\t\t\t\t\t\t\t'Gateway runtime cancellation write failed.',\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t};\n\t\t\tthis.#pendingRequests.set(requestId, {\n\t\t\t\treject: settleRejected,\n\t\t\t\tresolve: settleResolved,\n\t\t\t});\n\t\t\toptions.signal?.addEventListener('abort', onAbort, { once: true });\n\t\t\tvoid this.#writeFrame(frame).catch(settleRejected);\n\t\t});\n\t}\n\n\tasync close(): Promise<void> {\n\t\tif (this.#closed) return;\n\t\tthis.#failConnection(\n\t\t\tnew NodeGatewayRuntimeTransportError(\n\t\t\t\t'connection-closed',\n\t\t\t\t'Gateway runtime connection closed locally.',\n\t\t\t),\n\t\t);\n\t}\n}\n\nexport function createNodeGatewayRuntimeTransportFactory(\n\toptions: NodeGatewayRuntimeTransportOptions = {},\n): GatewayRuntimeTransportFactory {\n\tconst frameLimits = options.frameLimits ?? {};\n\tconst maxPendingRequests = options.maxPendingRequests ?? 64;\n\tassertPositiveSafeInteger(maxPendingRequests, 'maxPendingRequests');\n\treturn {\n\t\tconnect: async ({ signal, socketPath }): Promise<GatewayRuntimeConnection> => {\n\t\t\tconst socket = net.createConnection({ path: socketPath, signal });\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tconst onConnect = (): void => {\n\t\t\t\t\tcleanup();\n\t\t\t\t\tresolve();\n\t\t\t\t};\n\t\t\t\tconst onError = (error: Error): void => {\n\t\t\t\t\tcleanup();\n\t\t\t\t\tconst errorCode = nodeErrorCode(error);\n\t\t\t\t\tif (errorCode === 'ENOENT' || errorCode === 'ECONNREFUSED') {\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew GatewayRuntimeStartupUnavailableError(\n\t\t\t\t\t\t\t\terrorCode === 'ENOENT' ? 'socket-absent' : 'socket-refused',\n\t\t\t\t\t\t\t\t{ cause: error },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew NodeGatewayRuntimeTransportError(\n\t\t\t\t\t\t\t'connection-failed',\n\t\t\t\t\t\t\t'Gateway runtime UDS connection failed.',\n\t\t\t\t\t\t\t{ cause: error },\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst cleanup = (): void => {\n\t\t\t\t\tsocket.off('connect', onConnect);\n\t\t\t\t\tsocket.off('error', onError);\n\t\t\t\t};\n\t\t\t\tsocket.once('connect', onConnect);\n\t\t\t\tsocket.once('error', onError);\n\t\t\t});\n\t\t\treturn new NodeGatewayRuntimeConnection({ frameLimits, maxPendingRequests, socket });\n\t\t},\n\t};\n}\n","export interface GatewayRuntimeRetainedByteMeasurements {\n\treadonly kernelSendBufferedBytes: number;\n\treadonly nodeWritableBufferedBytes: number;\n\treadonly parserBufferedBytes: number;\n\treadonly sourceOwnedApplicationChunkBytes: number;\n}\n\nexport interface GatewayRuntimeRetainedByteLimits {\n\treadonly maxKernelSendBufferedBytes: number;\n\treadonly maxNodeWritableBufferedBytes: number;\n\treadonly maxParserBufferedBytes: number;\n\treadonly maxSourceOwnedApplicationChunkBytes: number;\n}\n\nexport type GatewayRuntimeChunkSenderPhase =\n\t| 'idle'\n\t| 'reading-source'\n\t| 'writing-chunk'\n\t| 'waiting-for-drain'\n\t| 'disconnected';\n\nexport interface GatewayRuntimeChunkSenderState {\n\treadonly currentRetainedBytes: GatewayRuntimeRetainedByteMeasurements;\n\treadonly highWaterRetainedBytes: GatewayRuntimeRetainedByteMeasurements;\n\treadonly ownedApplicationChunkCount: 0 | 1;\n\treadonly phase: GatewayRuntimeChunkSenderPhase;\n\treadonly retainedByteLimits: GatewayRuntimeRetainedByteLimits;\n}\n\nexport type GatewayRuntimeChunkSenderEvent =\n\t| { readonly kind: 'disconnected' }\n\t| { readonly kind: 'drain' }\n\t| {\n\t\t\treadonly kernelSendBufferedBytes: number;\n\t\t\treadonly kind: 'retained-bytes-observed';\n\t\t\treadonly nodeWritableBufferedBytes: number;\n\t\t\treadonly parserBufferedBytes: number;\n\t }\n\t| { readonly chunk: Uint8Array; readonly kind: 'source-chunk-read' }\n\t| { readonly kind: 'start' }\n\t| { readonly kind: 'write-result'; readonly writableWithoutDrain: boolean };\n\nexport type GatewayRuntimeChunkSenderEffect =\n\t| { readonly chunk: Uint8Array; readonly kind: 'encode-and-write' }\n\t| { readonly kind: 'read-source' };\n\nexport interface GatewayRuntimeChunkSenderTransition {\n\treadonly effects: readonly GatewayRuntimeChunkSenderEffect[];\n\treadonly state: GatewayRuntimeChunkSenderState;\n}\n\nconst ZERO_RETAINED_BYTES = Object.freeze({\n\tkernelSendBufferedBytes: 0,\n\tnodeWritableBufferedBytes: 0,\n\tparserBufferedBytes: 0,\n\tsourceOwnedApplicationChunkBytes: 0,\n}) satisfies GatewayRuntimeRetainedByteMeasurements;\n\nfunction assertNonnegativeSafeInteger(value: number, fieldName: string): void {\n\tif (!Number.isSafeInteger(value) || value < 0) {\n\t\tthrow new Error(`${fieldName} must be a nonnegative safe integer.`);\n\t}\n}\n\nfunction assertPositiveSafeInteger(value: number, fieldName: string): void {\n\tif (!Number.isSafeInteger(value) || value <= 0) {\n\t\tthrow new Error(`${fieldName} must be a positive safe integer.`);\n\t}\n}\n\nfunction assertUnreachable(value: never): never {\n\tthrow new Error(`Unhandled Gateway runtime flow-control event: ${JSON.stringify(value)}`);\n}\n\nfunction assertWithinLimit(value: number, limit: number, measurementName: string): void {\n\tassertNonnegativeSafeInteger(value, measurementName);\n\tif (value > limit) {\n\t\tthrow new Error(`${measurementName} exceeds its configured retained-byte limit.`);\n\t}\n}\n\nfunction highWaterMeasurements(\n\tcurrent: GatewayRuntimeRetainedByteMeasurements,\n\tpreviousHighWater: GatewayRuntimeRetainedByteMeasurements,\n): GatewayRuntimeRetainedByteMeasurements {\n\treturn Object.freeze({\n\t\tkernelSendBufferedBytes: Math.max(\n\t\t\tcurrent.kernelSendBufferedBytes,\n\t\t\tpreviousHighWater.kernelSendBufferedBytes,\n\t\t),\n\t\tnodeWritableBufferedBytes: Math.max(\n\t\t\tcurrent.nodeWritableBufferedBytes,\n\t\t\tpreviousHighWater.nodeWritableBufferedBytes,\n\t\t),\n\t\tparserBufferedBytes: Math.max(\n\t\t\tcurrent.parserBufferedBytes,\n\t\t\tpreviousHighWater.parserBufferedBytes,\n\t\t),\n\t\tsourceOwnedApplicationChunkBytes: Math.max(\n\t\t\tcurrent.sourceOwnedApplicationChunkBytes,\n\t\t\tpreviousHighWater.sourceOwnedApplicationChunkBytes,\n\t\t),\n\t});\n}\n\nfunction transitionChunkSender(\n\tstate: GatewayRuntimeChunkSenderState,\n\teffects: readonly GatewayRuntimeChunkSenderEffect[] = [],\n): GatewayRuntimeChunkSenderTransition {\n\treturn { effects, state };\n}\n\nexport function createGatewayRuntimeChunkSenderState(\n\tretainedByteLimits: GatewayRuntimeRetainedByteLimits,\n): GatewayRuntimeChunkSenderState {\n\tassertPositiveSafeInteger(\n\t\tretainedByteLimits.maxKernelSendBufferedBytes,\n\t\t'maxKernelSendBufferedBytes',\n\t);\n\tassertPositiveSafeInteger(\n\t\tretainedByteLimits.maxNodeWritableBufferedBytes,\n\t\t'maxNodeWritableBufferedBytes',\n\t);\n\tassertPositiveSafeInteger(retainedByteLimits.maxParserBufferedBytes, 'maxParserBufferedBytes');\n\tassertPositiveSafeInteger(\n\t\tretainedByteLimits.maxSourceOwnedApplicationChunkBytes,\n\t\t'maxSourceOwnedApplicationChunkBytes',\n\t);\n\treturn {\n\t\tcurrentRetainedBytes: ZERO_RETAINED_BYTES,\n\t\thighWaterRetainedBytes: ZERO_RETAINED_BYTES,\n\t\townedApplicationChunkCount: 0,\n\t\tphase: 'idle',\n\t\tretainedByteLimits: Object.freeze({ ...retainedByteLimits }),\n\t};\n}\n\nexport function reduceGatewayRuntimeChunkSenderState(\n\tstate: GatewayRuntimeChunkSenderState,\n\tevent: GatewayRuntimeChunkSenderEvent,\n): GatewayRuntimeChunkSenderTransition {\n\tif (event.kind === 'disconnected') {\n\t\tif (state.phase === 'disconnected') return transitionChunkSender(state);\n\t\tconst currentRetainedBytes = Object.freeze({\n\t\t\t...state.currentRetainedBytes,\n\t\t\tsourceOwnedApplicationChunkBytes: 0,\n\t\t});\n\t\treturn transitionChunkSender({\n\t\t\t...state,\n\t\t\tcurrentRetainedBytes,\n\t\t\townedApplicationChunkCount: 0,\n\t\t\tphase: 'disconnected',\n\t\t});\n\t}\n\tif (state.phase === 'disconnected') return transitionChunkSender(state);\n\n\tswitch (event.kind) {\n\t\tcase 'start': {\n\t\t\tif (state.phase !== 'idle') {\n\t\t\t\tthrow new Error('Gateway runtime chunk sender can only start from idle.');\n\t\t\t}\n\t\t\treturn transitionChunkSender({ ...state, phase: 'reading-source' }, [\n\t\t\t\t{ kind: 'read-source' },\n\t\t\t]);\n\t\t}\n\t\tcase 'source-chunk-read': {\n\t\t\tif (state.phase !== 'reading-source' || state.ownedApplicationChunkCount !== 0) {\n\t\t\t\tthrow new Error('Gateway runtime chunk sender already owns an application chunk.');\n\t\t\t}\n\t\t\tassertWithinLimit(\n\t\t\t\tevent.chunk.byteLength,\n\t\t\t\tstate.retainedByteLimits.maxSourceOwnedApplicationChunkBytes,\n\t\t\t\t'source-owned application chunk',\n\t\t\t);\n\t\t\tconst currentRetainedBytes = Object.freeze({\n\t\t\t\t...state.currentRetainedBytes,\n\t\t\t\tsourceOwnedApplicationChunkBytes: event.chunk.byteLength,\n\t\t\t});\n\t\t\treturn transitionChunkSender(\n\t\t\t\t{\n\t\t\t\t\t...state,\n\t\t\t\t\tcurrentRetainedBytes,\n\t\t\t\t\thighWaterRetainedBytes: highWaterMeasurements(\n\t\t\t\t\t\tcurrentRetainedBytes,\n\t\t\t\t\t\tstate.highWaterRetainedBytes,\n\t\t\t\t\t),\n\t\t\t\t\townedApplicationChunkCount: 1,\n\t\t\t\t\tphase: 'writing-chunk',\n\t\t\t\t},\n\t\t\t\t[{ chunk: event.chunk, kind: 'encode-and-write' }],\n\t\t\t);\n\t\t}\n\t\tcase 'write-result': {\n\t\t\tif (state.phase !== 'writing-chunk' || state.ownedApplicationChunkCount !== 1) {\n\t\t\t\tthrow new Error('Gateway runtime chunk sender has no application chunk being written.');\n\t\t\t}\n\t\t\tconst currentRetainedBytes = Object.freeze({\n\t\t\t\t...state.currentRetainedBytes,\n\t\t\t\tsourceOwnedApplicationChunkBytes: 0,\n\t\t\t});\n\t\t\tconst nextState = {\n\t\t\t\t...state,\n\t\t\t\tcurrentRetainedBytes,\n\t\t\t\townedApplicationChunkCount: 0 as const,\n\t\t\t\tphase: event.writableWithoutDrain\n\t\t\t\t\t? ('reading-source' as const)\n\t\t\t\t\t: ('waiting-for-drain' as const),\n\t\t\t};\n\t\t\treturn transitionChunkSender(\n\t\t\t\tnextState,\n\t\t\t\tevent.writableWithoutDrain ? [{ kind: 'read-source' }] : [],\n\t\t\t);\n\t\t}\n\t\tcase 'drain': {\n\t\t\tif (state.phase !== 'waiting-for-drain') {\n\t\t\t\tthrow new Error('Gateway runtime chunk sender received drain while not waiting for drain.');\n\t\t\t}\n\t\t\treturn transitionChunkSender({ ...state, phase: 'reading-source' }, [\n\t\t\t\t{ kind: 'read-source' },\n\t\t\t]);\n\t\t}\n\t\tcase 'retained-bytes-observed': {\n\t\t\tassertWithinLimit(\n\t\t\t\tevent.kernelSendBufferedBytes,\n\t\t\t\tstate.retainedByteLimits.maxKernelSendBufferedBytes,\n\t\t\t\t'kernel send buffer',\n\t\t\t);\n\t\t\tassertWithinLimit(\n\t\t\t\tevent.nodeWritableBufferedBytes,\n\t\t\t\tstate.retainedByteLimits.maxNodeWritableBufferedBytes,\n\t\t\t\t'Node writable buffer',\n\t\t\t);\n\t\t\tassertWithinLimit(\n\t\t\t\tevent.parserBufferedBytes,\n\t\t\t\tstate.retainedByteLimits.maxParserBufferedBytes,\n\t\t\t\t'parser buffer',\n\t\t\t);\n\t\t\tconst currentRetainedBytes = Object.freeze({\n\t\t\t\tkernelSendBufferedBytes: event.kernelSendBufferedBytes,\n\t\t\t\tnodeWritableBufferedBytes: event.nodeWritableBufferedBytes,\n\t\t\t\tparserBufferedBytes: event.parserBufferedBytes,\n\t\t\t\tsourceOwnedApplicationChunkBytes:\n\t\t\t\t\tstate.currentRetainedBytes.sourceOwnedApplicationChunkBytes,\n\t\t\t});\n\t\t\treturn transitionChunkSender({\n\t\t\t\t...state,\n\t\t\t\tcurrentRetainedBytes,\n\t\t\t\thighWaterRetainedBytes: highWaterMeasurements(\n\t\t\t\t\tcurrentRetainedBytes,\n\t\t\t\t\tstate.highWaterRetainedBytes,\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\t}\n\treturn assertUnreachable(event);\n}\n\nexport type GatewayRuntimeClientReadPhase =\n\t| 'flowing'\n\t| 'downstream-paused'\n\t| 'discard-draining'\n\t| 'completed';\n\nexport type GatewayRuntimeStreamTerminalOutcome = string;\n\nexport type GatewayRuntimeClientFrame =\n\t| {\n\t\t\treadonly chunk: Uint8Array;\n\t\t\treadonly kind: 'stream-data';\n\t\t\treadonly streamId: string;\n\t }\n\t| {\n\t\t\treadonly kind: 'authoritative-stream-terminal';\n\t\t\treadonly outcome: GatewayRuntimeStreamTerminalOutcome;\n\t\t\treadonly streamId: string;\n\t }\n\t| { readonly kind: 'control'; readonly method: string };\n\nexport interface GatewayRuntimeClientReadState {\n\treadonly pauseDeadlineMilliseconds: number;\n\treadonly phase: GatewayRuntimeClientReadPhase;\n\treadonly streamId: string;\n}\n\nexport type GatewayRuntimeClientReadEvent =\n\t| { readonly kind: 'attachment-retired' }\n\t| { readonly kind: 'downstream-pressure' }\n\t| { readonly kind: 'downstream-resumed' }\n\t| { readonly frame: GatewayRuntimeClientFrame; readonly kind: 'frame-received' }\n\t| { readonly kind: 'local-cancel' }\n\t| { readonly kind: 'local-close' }\n\t| { readonly kind: 'pause-deadline-expired' };\n\nexport type GatewayRuntimeClientReadEffect =\n\t| { readonly kind: 'cancel-pause-deadline' }\n\t| {\n\t\t\treadonly kind: 'complete-stream';\n\t\t\treadonly outcome: GatewayRuntimeStreamTerminalOutcome;\n\t\t\treadonly streamId: string;\n\t }\n\t| { readonly kind: 'discard-stream-data'; readonly streamId: string }\n\t| { readonly frame: GatewayRuntimeClientFrame; readonly kind: 'forward-frame' }\n\t| { readonly kind: 'pause-socket-read' }\n\t| { readonly kind: 'resume-socket-read' }\n\t| { readonly afterMilliseconds: number; readonly kind: 'schedule-pause-deadline' };\n\nexport interface GatewayRuntimeClientReadTransition {\n\treadonly effects: readonly GatewayRuntimeClientReadEffect[];\n\treadonly state: GatewayRuntimeClientReadState;\n}\n\nfunction transitionClientRead(\n\tstate: GatewayRuntimeClientReadState,\n\teffects: readonly GatewayRuntimeClientReadEffect[] = [],\n): GatewayRuntimeClientReadTransition {\n\treturn { effects, state };\n}\n\nfunction enterDiscardDraining(\n\tstate: GatewayRuntimeClientReadState,\n): GatewayRuntimeClientReadTransition {\n\treturn transitionClientRead({ ...state, phase: 'discard-draining' }, [\n\t\t{ kind: 'cancel-pause-deadline' },\n\t\t{ kind: 'resume-socket-read' },\n\t]);\n}\n\nexport function createGatewayRuntimeClientReadState(options: {\n\treadonly pauseDeadlineMilliseconds: number;\n\treadonly streamId: string;\n}): GatewayRuntimeClientReadState {\n\tassertPositiveSafeInteger(options.pauseDeadlineMilliseconds, 'pauseDeadlineMilliseconds');\n\tif (options.streamId.length === 0) throw new Error('streamId must not be empty.');\n\treturn {\n\t\tpauseDeadlineMilliseconds: options.pauseDeadlineMilliseconds,\n\t\tphase: 'flowing',\n\t\tstreamId: options.streamId,\n\t};\n}\n\nexport function reduceGatewayRuntimeClientReadState(\n\tstate: GatewayRuntimeClientReadState,\n\tevent: GatewayRuntimeClientReadEvent,\n): GatewayRuntimeClientReadTransition {\n\tswitch (event.kind) {\n\t\tcase 'downstream-pressure': {\n\t\t\tif (state.phase !== 'flowing') {\n\t\t\t\tthrow new Error('Gateway runtime client read can only pause while flowing.');\n\t\t\t}\n\t\t\treturn transitionClientRead({ ...state, phase: 'downstream-paused' }, [\n\t\t\t\t{ kind: 'pause-socket-read' },\n\t\t\t\t{\n\t\t\t\t\tafterMilliseconds: state.pauseDeadlineMilliseconds,\n\t\t\t\t\tkind: 'schedule-pause-deadline',\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\t\tcase 'downstream-resumed': {\n\t\t\tif (state.phase !== 'downstream-paused') {\n\t\t\t\tthrow new Error('Gateway runtime client read can only resume from a downstream pause.');\n\t\t\t}\n\t\t\treturn transitionClientRead({ ...state, phase: 'flowing' }, [\n\t\t\t\t{ kind: 'cancel-pause-deadline' },\n\t\t\t\t{ kind: 'resume-socket-read' },\n\t\t\t]);\n\t\t}\n\t\tcase 'pause-deadline-expired': {\n\t\t\tif (state.phase !== 'downstream-paused') {\n\t\t\t\tthrow new Error('Gateway runtime pause deadline expired without a downstream pause.');\n\t\t\t}\n\t\t\treturn enterDiscardDraining(state);\n\t\t}\n\t\tcase 'attachment-retired':\n\t\tcase 'local-cancel':\n\t\tcase 'local-close': {\n\t\t\tif (state.phase === 'downstream-paused') return enterDiscardDraining(state);\n\t\t\tif (state.phase === 'completed') return transitionClientRead(state);\n\t\t\treturn transitionClientRead({ ...state, phase: 'discard-draining' });\n\t\t}\n\t\tcase 'frame-received': {\n\t\t\tif (state.phase === 'completed') return transitionClientRead(state);\n\t\t\tconst frame = event.frame;\n\t\t\tif (\n\t\t\t\tstate.phase === 'discard-draining' &&\n\t\t\t\tframe.kind === 'stream-data' &&\n\t\t\t\tframe.streamId === state.streamId\n\t\t\t) {\n\t\t\t\treturn transitionClientRead(state, [\n\t\t\t\t\t{ kind: 'discard-stream-data', streamId: state.streamId },\n\t\t\t\t]);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tstate.phase === 'discard-draining' &&\n\t\t\t\tframe.kind === 'authoritative-stream-terminal' &&\n\t\t\t\tframe.streamId === state.streamId\n\t\t\t) {\n\t\t\t\treturn transitionClientRead({ ...state, phase: 'completed' }, [\n\t\t\t\t\t{ frame, kind: 'forward-frame' },\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: 'complete-stream',\n\t\t\t\t\t\toutcome: frame.outcome,\n\t\t\t\t\t\tstreamId: state.streamId,\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t}\n\t\t\treturn transitionClientRead(state, [{ frame, kind: 'forward-frame' }]);\n\t\t}\n\t}\n\treturn assertUnreachable(event);\n}\n","import {\n\tcreateGatewayRuntimeClientReadState,\n\treduceGatewayRuntimeClientReadState,\n\ttype GatewayRuntimeClientFrame,\n\ttype GatewayRuntimeClientReadEffect,\n\ttype GatewayRuntimeClientReadEvent,\n\ttype GatewayRuntimeClientReadState,\n\ttype GatewayRuntimeStreamTerminalOutcome,\n} from './gateway-runtime-flow-control.js';\n\nexport interface GatewayRuntimeReadableSocketControl {\n\treadonly pause: () => unknown;\n\treadonly resume: () => unknown;\n}\n\nexport interface GatewayRuntimePauseDeadlineScheduler {\n\treadonly schedule: (options: {\n\t\treadonly afterMilliseconds: number;\n\t\treadonly onDeadline: () => void;\n\t}) => { readonly cancel: () => void };\n}\n\nexport interface GatewayRuntimeCompletedStreamEvidence {\n\treadonly outcome: GatewayRuntimeStreamTerminalOutcome;\n\treadonly streamId: string;\n}\n\nexport interface GatewayRuntimeSocketReadFlowOptions {\n\treadonly deadlineScheduler?: GatewayRuntimePauseDeadlineScheduler;\n\treadonly forwardFrame: (frame: GatewayRuntimeClientFrame) => void;\n\treadonly onStreamCompleted: (evidence: GatewayRuntimeCompletedStreamEvidence) => void;\n\treadonly pauseDeadlineMilliseconds: number;\n\treadonly socket: GatewayRuntimeReadableSocketControl;\n}\n\nconst defaultPauseDeadlineScheduler: GatewayRuntimePauseDeadlineScheduler = {\n\tschedule: ({ afterMilliseconds, onDeadline }) => {\n\t\tconst timeout = setTimeout(onDeadline, afterMilliseconds);\n\t\treturn { cancel: () => clearTimeout(timeout) };\n\t},\n};\n\n/** Apply bounded per-stream discard state to one globally paused UDS reader. */\nexport class GatewayRuntimeSocketReadFlow {\n\treadonly #deadlineScheduler: GatewayRuntimePauseDeadlineScheduler;\n\treadonly #forwardFrame: (frame: GatewayRuntimeClientFrame) => void;\n\treadonly #onStreamCompleted: (evidence: GatewayRuntimeCompletedStreamEvidence) => void;\n\treadonly #pauseDeadlineMilliseconds: number;\n\treadonly #socket: GatewayRuntimeReadableSocketControl;\n\treadonly #streamStates = new Map<string, GatewayRuntimeClientReadState>();\n\t#activePauseDeadline: { readonly cancel: () => void } | undefined;\n\t#pausedStreamId: string | undefined;\n\n\tconstructor(options: GatewayRuntimeSocketReadFlowOptions) {\n\t\tthis.#deadlineScheduler = options.deadlineScheduler ?? defaultPauseDeadlineScheduler;\n\t\tthis.#forwardFrame = options.forwardFrame;\n\t\tthis.#onStreamCompleted = options.onStreamCompleted;\n\t\tthis.#pauseDeadlineMilliseconds = options.pauseDeadlineMilliseconds;\n\t\tthis.#socket = options.socket;\n\t}\n\n\t#createStreamState(streamId: string): GatewayRuntimeClientReadState {\n\t\treturn createGatewayRuntimeClientReadState({\n\t\t\tpauseDeadlineMilliseconds: this.#pauseDeadlineMilliseconds,\n\t\t\tstreamId,\n\t\t});\n\t}\n\n\t#applyEffects(streamId: string, effects: readonly GatewayRuntimeClientReadEffect[]): void {\n\t\tfor (const effect of effects) {\n\t\t\tswitch (effect.kind) {\n\t\t\t\tcase 'pause-socket-read':\n\t\t\t\t\tthis.#socket.pause();\n\t\t\t\t\tthis.#pausedStreamId = streamId;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'resume-socket-read':\n\t\t\t\t\tthis.#socket.resume();\n\t\t\t\t\tif (this.#pausedStreamId === streamId) this.#pausedStreamId = undefined;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'schedule-pause-deadline':\n\t\t\t\t\tthis.#activePauseDeadline = this.#deadlineScheduler.schedule({\n\t\t\t\t\t\tafterMilliseconds: effect.afterMilliseconds,\n\t\t\t\t\t\tonDeadline: () => this.#transitionStream(streamId, { kind: 'pause-deadline-expired' }),\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'cancel-pause-deadline':\n\t\t\t\t\tthis.#activePauseDeadline?.cancel();\n\t\t\t\t\tthis.#activePauseDeadline = undefined;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'discard-stream-data':\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'forward-frame':\n\t\t\t\t\tthis.#forwardFrame(effect.frame);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'complete-stream':\n\t\t\t\t\tthis.#onStreamCompleted({ outcome: effect.outcome, streamId: effect.streamId });\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t#transitionStream(streamId: string, event: GatewayRuntimeClientReadEvent): void {\n\t\tconst currentState = this.#streamStates.get(streamId) ?? this.#createStreamState(streamId);\n\t\tconst transition = reduceGatewayRuntimeClientReadState(currentState, event);\n\t\tthis.#streamStates.set(streamId, transition.state);\n\t\tthis.#applyEffects(streamId, transition.effects);\n\t\tif (transition.state.phase === 'completed') this.#streamStates.delete(streamId);\n\t}\n\n\tapplyDownstreamPressure(streamId: string): void {\n\t\tif (this.#pausedStreamId !== undefined && this.#pausedStreamId !== streamId) {\n\t\t\tthrow new Error(\n\t\t\t\t`Gateway runtime socket is already paused for stream '${this.#pausedStreamId}'.`,\n\t\t\t);\n\t\t}\n\t\tthis.#transitionStream(streamId, { kind: 'downstream-pressure' });\n\t}\n\n\tresumeDownstream(streamId: string): void {\n\t\tthis.#transitionStream(streamId, { kind: 'downstream-resumed' });\n\t}\n\n\tcancelStream(streamId: string): void {\n\t\tthis.#transitionStream(streamId, { kind: 'local-cancel' });\n\t}\n\n\tcloseStream(streamId: string): void {\n\t\tthis.#transitionStream(streamId, { kind: 'local-close' });\n\t}\n\n\tretireAttachment(streamId: string): void {\n\t\tthis.#transitionStream(streamId, { kind: 'attachment-retired' });\n\t}\n\n\treceiveFrame(frame: GatewayRuntimeClientFrame): void {\n\t\tif (frame.kind === 'control') {\n\t\t\tthis.#forwardFrame(frame);\n\t\t\treturn;\n\t\t}\n\t\tconst streamState = this.#streamStates.get(frame.streamId);\n\t\tif (streamState === undefined) {\n\t\t\tthis.#forwardFrame(frame);\n\t\t\treturn;\n\t\t}\n\t\tthis.#transitionStream(frame.streamId, { frame, kind: 'frame-received' });\n\t}\n}\n","import {\n\tPortalArtifactReadRequestSchema,\n\tPortalArtifactReadResultSchema,\n\ttype PortalArtifactReadRequest,\n\ttype PortalArtifactReadResult,\n} from '../artifact-surface/index.js';\nimport {\n\tGatewayRuntimeAttachmentMetadataSchema,\n\tGatewayRuntimeTrustedInvocationCorrelationSchema,\n\tGatewayRuntimeTrustedInvocationContextSchema,\n\tGatewayRuntimeTrustedInvocationPrincipalSchema,\n\tGatewayRuntimeTrustedInvocationRequesterSchema,\n\ttype GatewayRuntimeAttachmentMetadata as CanonicalGatewayRuntimeAttachmentMetadata,\n\ttype GatewayRuntimeTrustedInvocationContext,\n} from '../contracts/index.js';\nimport {\n\tPortalCallRequestSchema,\n\tPortalCallResultSchema,\n\tPortalDescribeRequestSchema,\n\tPortalDescribeResultSchema,\n\tPortalListRequestSchema,\n\tPortalListResultSchema,\n\tPortalSearchRequestSchema,\n\tPortalSearchResultSchema,\n\ttype PortalCallRequest,\n\ttype PortalCallResult,\n\ttype PortalDescribeRequest,\n\ttype PortalDescribeResult,\n\ttype PortalListRequest,\n\ttype PortalListResult,\n\ttype PortalSearchRequest,\n\ttype PortalSearchResult,\n} from '../portal-call-surface/index.js';\nimport {\n\tGatewayRuntimeSandboxOperations,\n\ttype GatewayRuntimeTrustedRequestOptions,\n} from './gateway-runtime-sandbox-operations.js';\nimport {\n\tDEFAULT_GATEWAY_RUNTIME_STARTUP_RETRY_POLICY,\n\tGatewayRuntimeStartupUnavailableError,\n\tdefaultGatewayRuntimeStartupRetryScheduler,\n\ttype GatewayRuntimeStartupRetryPolicy,\n\ttype GatewayRuntimeStartupRetryScheduler,\n} from './gateway-runtime-startup-retry.js';\nimport {\n\tGatewayRuntimeTraceContextSchema,\n\ttype GatewayRuntimeTraceContext,\n\ttype GatewayRuntimeTraceContextProvider,\n} from './gateway-runtime-trace-context.js';\nimport { createNodeGatewayRuntimeTransportFactory } from './node-gateway-runtime-transport.js';\n\nexport const DEFAULT_GATEWAY_RUNTIME_SOCKET_PATH =\n\t'/run/agent-vm/gateway-runtime/managed-plugin.sock';\n\nexport type GatewayRuntimeAttachmentMetadata = Readonly<\n\tOmit<CanonicalGatewayRuntimeAttachmentMetadata, 'configuredAgentIds'> & {\n\t\treadonly configuredAgentIds: readonly string[];\n\t}\n>;\n\nexport type GatewayRuntimeClientTrustedInvocationContext = GatewayRuntimeTrustedInvocationContext;\n\nexport interface GatewayRuntimeRequestOptions {\n\treadonly signal?: AbortSignal;\n\treadonly traceContext?: GatewayRuntimeTraceContext;\n}\n\nexport interface GatewayRuntimeConnectOptions {\n\treadonly signal?: AbortSignal;\n}\n\nexport type GatewayRuntimePortalRequestOptions = GatewayRuntimeTrustedRequestOptions;\n\nexport interface GatewayRuntimeConnection {\n\treadonly close: () => Promise<void>;\n\treadonly handshake: (\n\t\thandshake: GatewayRuntimeAttachmentMetadata,\n\t\toptions?: GatewayRuntimeRequestOptions,\n\t) => Promise<void>;\n\treadonly request: (\n\t\tmethod: string,\n\t\tparams: unknown,\n\t\toptions?: { readonly signal?: AbortSignal },\n\t) => Promise<unknown>;\n}\n\nexport interface GatewayRuntimeTransportFactory {\n\treadonly connect: (options: {\n\t\treadonly signal: AbortSignal;\n\t\treadonly socketPath: string;\n\t}) => Promise<GatewayRuntimeConnection>;\n}\n\nexport interface GatewayRuntimeClientOptions {\n\treadonly attachment: GatewayRuntimeAttachmentMetadata;\n\treadonly socketPath?: string;\n\treadonly startupRetryPolicy?: Partial<GatewayRuntimeStartupRetryPolicy>;\n\treadonly startupRetryScheduler?: GatewayRuntimeStartupRetryScheduler;\n\treadonly traceContextProvider?: GatewayRuntimeTraceContextProvider;\n\treadonly transportFactory?: GatewayRuntimeTransportFactory;\n}\n\nexport type GatewayRuntimeClientErrorCode =\n\t| 'already-connected'\n\t| 'handshake-required'\n\t| 'invalid-attachment'\n\t| 'invalid-request-metadata'\n\t| 'invalid-startup-retry-policy'\n\t| 'public-authority-injection'\n\t| 'startup-aborted'\n\t| 'startup-retry-exhausted';\n\nexport class GatewayRuntimeClientError extends Error {\n\treadonly code: GatewayRuntimeClientErrorCode;\n\n\tconstructor(code: GatewayRuntimeClientErrorCode, message: string, options: ErrorOptions = {}) {\n\t\tsuper(message, options);\n\t\tthis.name = 'GatewayRuntimeClientError';\n\t\tthis.code = code;\n\t}\n}\n\nfunction resolveStartupRetryPolicy(\n\toverride: Partial<GatewayRuntimeStartupRetryPolicy> | undefined,\n): GatewayRuntimeStartupRetryPolicy {\n\tconst policy = { ...DEFAULT_GATEWAY_RUNTIME_STARTUP_RETRY_POLICY, ...override };\n\tif (\n\t\t!Number.isSafeInteger(policy.deadlineMs) ||\n\t\tpolicy.deadlineMs <= 0 ||\n\t\t!Number.isSafeInteger(policy.intervalMs) ||\n\t\tpolicy.intervalMs <= 0 ||\n\t\t!Number.isSafeInteger(policy.maxAttempts) ||\n\t\tpolicy.maxAttempts <= 0 ||\n\t\tpolicy.deadlineMs > 60_000 ||\n\t\tpolicy.maxAttempts > 1_000 ||\n\t\tpolicy.intervalMs > policy.deadlineMs\n\t) {\n\t\tthrow new GatewayRuntimeClientError(\n\t\t\t'invalid-startup-retry-policy',\n\t\t\t'Gateway runtime startup retry policy must contain positive bounded integers.',\n\t\t);\n\t}\n\treturn Object.freeze(policy);\n}\n\nfunction startupAbortedError(reason: unknown): GatewayRuntimeClientError {\n\treturn new GatewayRuntimeClientError(\n\t\t'startup-aborted',\n\t\t'Gateway runtime startup was aborted.',\n\t\treason instanceof Error ? { cause: reason } : {},\n\t);\n}\n\nfunction startupRetryExhaustedError(props: {\n\treadonly attempts: number;\n\treadonly cause?: Error;\n}): GatewayRuntimeClientError {\n\treturn new GatewayRuntimeClientError(\n\t\t'startup-retry-exhausted',\n\t\t`Gateway runtime startup retry was exhausted after ${props.attempts} attempts.`,\n\t\tprops.cause === undefined ? {} : { cause: props.cause },\n\t);\n}\n\nconst publicAuthorityFieldNames = [\n\t'allowedOperationGroups',\n\t'authority',\n\t'operationGroups',\n\t'principal',\n\t'surface',\n] as const;\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction validateAttachmentMetadata(\n\tattachment: GatewayRuntimeAttachmentMetadata,\n): GatewayRuntimeAttachmentMetadata {\n\tif (!isRecord(attachment)) {\n\t\tthrow new GatewayRuntimeClientError(\n\t\t\t'invalid-attachment',\n\t\t\t'Gateway runtime attachment metadata must be an object.',\n\t\t);\n\t}\n\tif (publicAuthorityFieldNames.some((fieldName) => Object.hasOwn(attachment, fieldName))) {\n\t\tthrow new GatewayRuntimeClientError(\n\t\t\t'public-authority-injection',\n\t\t\t'Gateway runtime attachment metadata cannot carry server-derived authority.',\n\t\t);\n\t}\n\tconst parsedAttachment = GatewayRuntimeAttachmentMetadataSchema.safeParse(attachment);\n\tif (!parsedAttachment.success) {\n\t\tthrow new GatewayRuntimeClientError(\n\t\t\t'invalid-attachment',\n\t\t\t'Gateway runtime attachment metadata is invalid.',\n\t\t\t{ cause: parsedAttachment.error },\n\t\t);\n\t}\n\tObject.freeze(parsedAttachment.data.configuredAgentIds);\n\treturn Object.freeze(parsedAttachment.data);\n}\n\nfunction createGatewayRuntimeRequestParams<TPublicRequest>(props: {\n\treadonly publicRequest: TPublicRequest;\n\treadonly trustedContext: GatewayRuntimeTrustedInvocationContext;\n}): {\n\treadonly publicRequest: TPublicRequest;\n\treadonly trustedContext: GatewayRuntimeTrustedInvocationContext;\n} {\n\treturn {\n\t\tpublicRequest: props.publicRequest,\n\t\ttrustedContext: GatewayRuntimeTrustedInvocationContextSchema.parse(props.trustedContext),\n\t};\n}\n\nfunction gatewayRuntimeRequestOptions(\n\toptions: GatewayRuntimePortalRequestOptions,\n): GatewayRuntimeRequestOptions {\n\treturn {\n\t\t...(options.signal === undefined ? {} : { signal: options.signal }),\n\t\t...(options.traceContext === undefined ? {} : { traceContext: options.traceContext }),\n\t};\n}\n\nclass GatewayRuntimePortalOperations {\n\treadonly #client: GatewayRuntimeClient;\n\n\tconstructor(client: GatewayRuntimeClient) {\n\t\tthis.#client = client;\n\t}\n\n\tasync list(\n\t\trequest: PortalListRequest,\n\t\toptions: GatewayRuntimePortalRequestOptions,\n\t): Promise<PortalListResult> {\n\t\tconst validatedRequest = PortalListRequestSchema.parse(request);\n\t\tconst result = await this.#client.request(\n\t\t\t'portal.list',\n\t\t\tcreateGatewayRuntimeRequestParams({\n\t\t\t\tpublicRequest: validatedRequest,\n\t\t\t\ttrustedContext: options.trustedContext,\n\t\t\t}),\n\t\t\tgatewayRuntimeRequestOptions(options),\n\t\t);\n\t\treturn PortalListResultSchema.parse(result);\n\t}\n\n\tasync search(\n\t\trequest: PortalSearchRequest,\n\t\toptions: GatewayRuntimePortalRequestOptions,\n\t): Promise<PortalSearchResult> {\n\t\tconst validatedRequest = PortalSearchRequestSchema.parse(request);\n\t\tconst result = await this.#client.request(\n\t\t\t'portal.search',\n\t\t\tcreateGatewayRuntimeRequestParams({\n\t\t\t\tpublicRequest: validatedRequest,\n\t\t\t\ttrustedContext: options.trustedContext,\n\t\t\t}),\n\t\t\tgatewayRuntimeRequestOptions(options),\n\t\t);\n\t\treturn PortalSearchResultSchema.parse(result);\n\t}\n\n\tasync describe(\n\t\trequest: PortalDescribeRequest,\n\t\toptions: GatewayRuntimePortalRequestOptions,\n\t): Promise<PortalDescribeResult> {\n\t\tconst validatedRequest = PortalDescribeRequestSchema.parse(request);\n\t\tconst result = await this.#client.request(\n\t\t\t'portal.describe',\n\t\t\tcreateGatewayRuntimeRequestParams({\n\t\t\t\tpublicRequest: validatedRequest,\n\t\t\t\ttrustedContext: options.trustedContext,\n\t\t\t}),\n\t\t\tgatewayRuntimeRequestOptions(options),\n\t\t);\n\t\treturn PortalDescribeResultSchema.parse(result);\n\t}\n\n\tasync call(\n\t\trequest: PortalCallRequest,\n\t\toptions: GatewayRuntimePortalRequestOptions,\n\t): Promise<PortalCallResult> {\n\t\tconst validatedRequest = PortalCallRequestSchema.parse(request);\n\t\tconst result = await this.#client.request(\n\t\t\t'portal.call',\n\t\t\tcreateGatewayRuntimeRequestParams({\n\t\t\t\tpublicRequest: validatedRequest,\n\t\t\t\ttrustedContext: options.trustedContext,\n\t\t\t}),\n\t\t\tgatewayRuntimeRequestOptions(options),\n\t\t);\n\t\treturn PortalCallResultSchema.parse(result);\n\t}\n}\n\nclass GatewayRuntimeArtifactOperations {\n\treadonly #client: GatewayRuntimeClient;\n\n\tconstructor(client: GatewayRuntimeClient) {\n\t\tthis.#client = client;\n\t}\n\n\tasync read(\n\t\trequest: PortalArtifactReadRequest,\n\t\toptions: GatewayRuntimePortalRequestOptions,\n\t): Promise<PortalArtifactReadResult> {\n\t\tconst validatedRequest = PortalArtifactReadRequestSchema.parse(request);\n\t\tconst result = await this.#client.request(\n\t\t\t'artifact.read',\n\t\t\tcreateGatewayRuntimeRequestParams({\n\t\t\t\tpublicRequest: validatedRequest,\n\t\t\t\ttrustedContext: options.trustedContext,\n\t\t\t}),\n\t\t\tgatewayRuntimeRequestOptions(options),\n\t\t);\n\t\treturn PortalArtifactReadResultSchema.parse(result);\n\t}\n}\n\n/** Rich private-UDS client for one current managed-framework attachment. */\nexport class GatewayRuntimeClient {\n\treadonly #attachment: GatewayRuntimeAttachmentMetadata;\n\treadonly #socketPath: string;\n\treadonly #startupRetryPolicy: GatewayRuntimeStartupRetryPolicy;\n\treadonly #startupRetryScheduler: GatewayRuntimeStartupRetryScheduler;\n\treadonly #traceContextProvider: GatewayRuntimeTraceContextProvider | undefined;\n\treadonly #transportFactory: GatewayRuntimeTransportFactory;\n\t#connection: GatewayRuntimeConnection | undefined;\n\t#connecting = false;\n\t#handshakeComplete = false;\n\treadonly artifacts: GatewayRuntimeArtifactOperations;\n\treadonly portal: GatewayRuntimePortalOperations;\n\treadonly sandbox: GatewayRuntimeSandboxOperations;\n\n\tconstructor(options: GatewayRuntimeClientOptions) {\n\t\tthis.#attachment = validateAttachmentMetadata(options.attachment);\n\t\tthis.#socketPath = options.socketPath ?? DEFAULT_GATEWAY_RUNTIME_SOCKET_PATH;\n\t\tthis.#startupRetryPolicy = resolveStartupRetryPolicy(options.startupRetryPolicy);\n\t\tthis.#startupRetryScheduler =\n\t\t\toptions.startupRetryScheduler ?? defaultGatewayRuntimeStartupRetryScheduler;\n\t\tthis.#traceContextProvider = options.traceContextProvider;\n\t\tthis.#transportFactory = options.transportFactory ?? createNodeGatewayRuntimeTransportFactory();\n\t\tthis.artifacts = new GatewayRuntimeArtifactOperations(this);\n\t\tthis.portal = new GatewayRuntimePortalOperations(this);\n\t\tthis.sandbox = Object.freeze(new GatewayRuntimeSandboxOperations(this));\n\t}\n\n\tasync #connectOnce(props: {\n\t\treadonly attemptNumber: number;\n\t\treadonly deadlineAtMs: number;\n\t\treadonly signal: AbortSignal;\n\t}): Promise<GatewayRuntimeConnection> {\n\t\tconst remainingMs = Math.max(1, props.deadlineAtMs - this.#startupRetryScheduler.now());\n\t\tconst attemptCancellation = new AbortController();\n\t\tlet deadlineExpired = false;\n\t\tconst deadline = setTimeout(() => {\n\t\t\tdeadlineExpired = true;\n\t\t\tattemptCancellation.abort(new Error('Gateway runtime startup deadline expired.'));\n\t\t}, remainingMs);\n\t\tconst abortAttempt = (): void => attemptCancellation.abort(props.signal.reason);\n\t\tprops.signal.addEventListener('abort', abortAttempt, { once: true });\n\t\tif (props.signal.aborted) abortAttempt();\n\t\tlet connection: GatewayRuntimeConnection | undefined;\n\t\ttry {\n\t\t\tconnection = await this.#transportFactory.connect({\n\t\t\t\tsignal: attemptCancellation.signal,\n\t\t\t\tsocketPath: this.#socketPath,\n\t\t\t});\n\t\t\tawait connection.handshake(this.#attachment, { signal: attemptCancellation.signal });\n\t\t\treturn connection;\n\t\t} catch (error: unknown) {\n\t\t\tif (connection !== undefined) await connection.close();\n\t\t\tif (props.signal.aborted) throw startupAbortedError(props.signal.reason);\n\t\t\tif (deadlineExpired) {\n\t\t\t\tthrow startupRetryExhaustedError({\n\t\t\t\t\tattempts: props.attemptNumber,\n\t\t\t\t\t...(error instanceof Error ? { cause: error } : {}),\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tclearTimeout(deadline);\n\t\t\tprops.signal.removeEventListener('abort', abortAttempt);\n\t\t}\n\t}\n\n\tasync #connectWithStartupRetry(props: {\n\t\treadonly attemptsCompleted: number;\n\t\treadonly deadlineAtMs: number;\n\t\treadonly signal: AbortSignal;\n\t}): Promise<GatewayRuntimeConnection> {\n\t\tconst attemptNumber = props.attemptsCompleted + 1;\n\t\tlet unavailableError: GatewayRuntimeStartupUnavailableError;\n\t\ttry {\n\t\t\treturn await this.#connectOnce({\n\t\t\t\tattemptNumber,\n\t\t\t\tdeadlineAtMs: props.deadlineAtMs,\n\t\t\t\tsignal: props.signal,\n\t\t\t});\n\t\t} catch (error: unknown) {\n\t\t\tif (error instanceof GatewayRuntimeClientError) throw error;\n\t\t\tif (!(error instanceof GatewayRuntimeStartupUnavailableError)) throw error;\n\t\t\tunavailableError = error;\n\t\t}\n\n\t\tconst remainingMs = props.deadlineAtMs - this.#startupRetryScheduler.now();\n\t\tif (attemptNumber >= this.#startupRetryPolicy.maxAttempts || remainingMs <= 0) {\n\t\t\tthrow startupRetryExhaustedError({\n\t\t\t\tattempts: attemptNumber,\n\t\t\t\tcause: unavailableError,\n\t\t\t});\n\t\t}\n\t\ttry {\n\t\t\tawait this.#startupRetryScheduler.wait(\n\t\t\t\tMath.min(this.#startupRetryPolicy.intervalMs, remainingMs),\n\t\t\t\tprops.signal,\n\t\t\t);\n\t\t} catch (error: unknown) {\n\t\t\tif (props.signal.aborted) throw startupAbortedError(props.signal.reason);\n\t\t\tthrow error;\n\t\t}\n\t\tif (this.#startupRetryScheduler.now() >= props.deadlineAtMs) {\n\t\t\tthrow startupRetryExhaustedError({\n\t\t\t\tattempts: attemptNumber,\n\t\t\t\tcause: unavailableError,\n\t\t\t});\n\t\t}\n\t\treturn await this.#connectWithStartupRetry({\n\t\t\tattemptsCompleted: attemptNumber,\n\t\t\tdeadlineAtMs: props.deadlineAtMs,\n\t\t\tsignal: props.signal,\n\t\t});\n\t}\n\n\tasync connect(options: GatewayRuntimeConnectOptions = {}): Promise<void> {\n\t\tif (this.#connection !== undefined || this.#connecting) {\n\t\t\tthrow new GatewayRuntimeClientError(\n\t\t\t\t'already-connected',\n\t\t\t\t'Gateway runtime client already has a connection.',\n\t\t\t);\n\t\t}\n\t\tconst signal = options.signal ?? new AbortController().signal;\n\t\tif (signal.aborted) throw startupAbortedError(signal.reason);\n\t\tthis.#connecting = true;\n\t\tconst deadlineAtMs = this.#startupRetryScheduler.now() + this.#startupRetryPolicy.deadlineMs;\n\t\ttry {\n\t\t\tconst connection = await this.#connectWithStartupRetry({\n\t\t\t\tattemptsCompleted: 0,\n\t\t\t\tdeadlineAtMs,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t\tthis.#connection = connection;\n\t\t\tthis.#handshakeComplete = true;\n\t\t} finally {\n\t\t\tthis.#connecting = false;\n\t\t}\n\t}\n\n\tasync disconnect(): Promise<void> {\n\t\tconst connection = this.#connection;\n\t\tthis.#connection = undefined;\n\t\tthis.#handshakeComplete = false;\n\t\tif (connection !== undefined) await connection.close();\n\t}\n\n\tasync reconnect(options: GatewayRuntimeConnectOptions = {}): Promise<void> {\n\t\tif (this.#connecting) {\n\t\t\tthrow new GatewayRuntimeClientError(\n\t\t\t\t'already-connected',\n\t\t\t\t'Gateway runtime client already has a connection attempt in progress.',\n\t\t\t);\n\t\t}\n\t\tthis.#connecting = true;\n\t\ttry {\n\t\t\tawait this.disconnect();\n\t\t\tconst signal = options.signal ?? new AbortController().signal;\n\t\t\tif (signal.aborted) throw startupAbortedError(signal.reason);\n\t\t\tconst connection = await this.#connectOnce({\n\t\t\t\tattemptNumber: 1,\n\t\t\t\tdeadlineAtMs: this.#startupRetryScheduler.now() + this.#startupRetryPolicy.deadlineMs,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t\tthis.#connection = connection;\n\t\t\tthis.#handshakeComplete = true;\n\t\t} finally {\n\t\t\tthis.#connecting = false;\n\t\t}\n\t}\n\n\tasync request(\n\t\tmethod: string,\n\t\tparams: unknown,\n\t\toptions: GatewayRuntimeRequestOptions = {},\n\t): Promise<unknown> {\n\t\tif (!this.#handshakeComplete || this.#connection === undefined) {\n\t\t\tthrow new GatewayRuntimeClientError(\n\t\t\t\t'handshake-required',\n\t\t\t\t'Gateway runtime attachment handshake must complete before method calls.',\n\t\t\t);\n\t\t}\n\t\tconst transportOptions = options.signal === undefined ? {} : { signal: options.signal };\n\t\tconst providedTraceContext = options.traceContext ?? this.#traceContextProvider?.();\n\t\tif (providedTraceContext === undefined) {\n\t\t\treturn await this.#connection.request(method, params, transportOptions);\n\t\t}\n\t\tif (!isRecord(params)) {\n\t\t\tthrow new GatewayRuntimeClientError(\n\t\t\t\t'invalid-request-metadata',\n\t\t\t\t'Gateway runtime trace context requires object request parameters.',\n\t\t\t);\n\t\t}\n\t\tconst traceContext = GatewayRuntimeTraceContextSchema.parse(providedTraceContext);\n\t\treturn await this.#connection.request(method, { ...params, traceContext }, transportOptions);\n\t}\n}\n\nexport {\n\tDEFAULT_GATEWAY_RUNTIME_STARTUP_RETRY_POLICY,\n\tGatewayRuntimeStartupUnavailableError,\n\ttype GatewayRuntimeStartupRetryPolicy,\n\ttype GatewayRuntimeStartupRetryScheduler,\n} from './gateway-runtime-startup-retry.js';\nexport {\n\tGATEWAY_RUNTIME_TRACEPARENT_MAX_LENGTH,\n\tGATEWAY_RUNTIME_TRACESTATE_MAX_LENGTH,\n\tGATEWAY_RUNTIME_TRACESTATE_MAX_MEMBERS,\n\tGatewayRuntimeTraceContextSchema,\n\ttype GatewayRuntimeTraceContext,\n\ttype GatewayRuntimeTraceContextProvider,\n} from './gateway-runtime-trace-context.js';\nexport {\n\tGatewayRuntimeSandboxEnvironmentOperations,\n\tGatewayRuntimeSandboxExecutionOperations,\n\tGatewayRuntimeSandboxFilesystemOperations,\n\tGatewayRuntimeSandboxOperations,\n\tGatewayRuntimeSandboxProcessOperations,\n\tGatewayRuntimeSandboxRetainedResultOperations,\n\tGatewayRuntimeSandboxStreamOperations,\n\tGatewayRuntimeSandboxTerminalOperations,\n\ttype GatewayRuntimeTrustedRequestOptions,\n} from './gateway-runtime-sandbox-operations.js';\n\nexport type {\n\tGatewayRuntimeManagedPluginClientKind,\n\tGatewayRuntimeTrustedInvocationCorrelation,\n\tGatewayRuntimeTrustedInvocationContext,\n\tGatewayRuntimeTrustedInvocationPrincipal,\n\tGatewayRuntimeTrustedInvocationRequester,\n} from '../contracts/index.js';\n\nexport {\n\tGatewayRuntimeTrustedInvocationCorrelationSchema,\n\tGatewayRuntimeTrustedInvocationContextSchema,\n\tGatewayRuntimeTrustedInvocationPrincipalSchema,\n\tGatewayRuntimeTrustedInvocationRequesterSchema,\n};\n\nexport {\n\tGATEWAY_RUNTIME_REQUEST_CANCEL_NOTIFICATION_METHOD,\n\tGatewayRuntimeRemoteError,\n\tNodeGatewayRuntimeTransportError,\n\tcreateNodeGatewayRuntimeTransportFactory,\n} from './node-gateway-runtime-transport.js';\nexport {\n\tGatewayRuntimeSocketReadFlow,\n\ttype GatewayRuntimeCompletedStreamEvidence,\n\ttype GatewayRuntimePauseDeadlineScheduler,\n\ttype GatewayRuntimeReadableSocketControl,\n\ttype GatewayRuntimeSocketReadFlowOptions,\n} from './gateway-runtime-socket-read-flow.js';\nexport * from './gateway-runtime-flow-control.js';\nexport * from './gateway-runtime-protocol.js';\n"],"mappings":";;;;;;;;AAmIA,eAAe,wBACd,OACmB;CACnB,MAAM,gBAAgB,MAAM,cAAc,MAAM,MAAM,QAAQ;CAC9D,MAAM,iBAAiB,6CAA6C,MACnE,MAAM,QAAQ,eACd;CACD,MAAM,SAAS,MAAM,MAAM,OAAO,QACjC,MAAM,QACN;EAAE;EAAe;EAAgB,EACjC;EACC,GAAI,MAAM,QAAQ,WAAW,KAAA,IAAY,EAAE,GAAG,EAAE,QAAQ,MAAM,QAAQ,QAAQ;EAC9E,GAAI,MAAM,QAAQ,iBAAiB,KAAA,IAChC,EAAE,GACF,EAAE,cAAc,MAAM,QAAQ,cAAc;EAC/C,CACD;CACD,OAAO,MAAM,aAAa,MAAM,OAAO;;AAGxC,IAAa,6CAAb,MAAwD;CACvD;CAEA,YAAY,QAA4C;EACvD,KAAKA,UAAU;;CAGhB,MAAM,KACL,SACA,SACwC;EACxC,OAAO,MAAM,wBAAwB;GACpC,QAAQ,KAAKA;GACb,QAAQ;GACR;GACA;GACA,eAAe;GACf,cAAc;GACd,CAAC;;CAGH,MAAM,MACL,SACA,SACyC;EACzC,OAAO,MAAM,wBAAwB;GACpC,QAAQ,KAAKA;GACb,QAAQ;GACR;GACA;GACA,eAAe;GACf,cAAc;GACd,CAAC;;CAGH,MAAM,OACL,SACA,SAC0C;EAC1C,OAAO,MAAM,wBAAwB;GACpC,QAAQ,KAAKA;GACb,QAAQ;GACR;GACA;GACA,eAAe;GACf,cAAc;GACd,CAAC;;;AAIJ,IAAa,2CAAb,MAAsD;CACrD;CAEA,YAAY,QAA4C;EACvD,KAAK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@@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { a as encodeGatewayRuntimeLocalExecFrame, i as GatewayRuntimeLocalExecLineDecoder, n as GATEWAY_RUNTIME_LOCAL_EXEC_TOKEN_ENV, o as parseGatewayRuntimeLocalExecServerFrame, t as GATEWAY_RUNTIME_LOCAL_EXEC_SOCKET_ENV } from "../gateway-runtime-local-exec-transport-B1hy2A3Q.js";
|
|
3
|
-
import { createConnection } from "node:net";
|
|
4
|
-
//#region src/gateway-runtime-local-exec/gateway-runtime-local-exec-helper.ts
|
|
5
|
-
const CONNECTION_DEADLINE_MS = 1e4;
|
|
6
|
-
function requireEnvironmentValue(name) {
|
|
7
|
-
const value = process.env[name];
|
|
8
|
-
if (value === void 0 || value.length === 0) throw new Error(`Required environment '${name}' is absent.`);
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
async function writeProcessOutput(stream, content) {
|
|
12
|
-
await new Promise((resolve, reject) => {
|
|
13
|
-
stream.write(content, (error) => {
|
|
14
|
-
if (error === void 0 || error === null) resolve();
|
|
15
|
-
else reject(error);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
async function writeClientFrame(socket, frame) {
|
|
20
|
-
if (socket.write(encodeGatewayRuntimeLocalExecFrame(frame))) return;
|
|
21
|
-
await new Promise((resolve, reject) => {
|
|
22
|
-
const cleanup = () => {
|
|
23
|
-
socket.off("drain", handleDrain);
|
|
24
|
-
socket.off("error", handleError);
|
|
25
|
-
};
|
|
26
|
-
const handleDrain = () => {
|
|
27
|
-
cleanup();
|
|
28
|
-
resolve();
|
|
29
|
-
};
|
|
30
|
-
const handleError = (error) => {
|
|
31
|
-
cleanup();
|
|
32
|
-
reject(error);
|
|
33
|
-
};
|
|
34
|
-
socket.once("drain", handleDrain);
|
|
35
|
-
socket.once("error", handleError);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
async function run() {
|
|
39
|
-
const socketPath = requireEnvironmentValue(GATEWAY_RUNTIME_LOCAL_EXEC_SOCKET_ENV);
|
|
40
|
-
const token = requireEnvironmentValue(GATEWAY_RUNTIME_LOCAL_EXEC_TOKEN_ENV);
|
|
41
|
-
const socket = createConnection(socketPath);
|
|
42
|
-
const decoder = new GatewayRuntimeLocalExecLineDecoder();
|
|
43
|
-
let accepted = false;
|
|
44
|
-
let exited = false;
|
|
45
|
-
let inputWrites = Promise.resolve();
|
|
46
|
-
let outputWrites = Promise.resolve();
|
|
47
|
-
const connectionDeadline = setTimeout(() => socket.destroy(/* @__PURE__ */ new Error("Local exec connection deadline expired.")), CONNECTION_DEADLINE_MS);
|
|
48
|
-
const cancelAndClose = () => {
|
|
49
|
-
process.stdin.destroy();
|
|
50
|
-
if (!socket.destroyed && accepted && !exited) writeClientFrame(socket, { kind: "cancel" }).catch(() => void 0).finally(() => socket.end());
|
|
51
|
-
};
|
|
52
|
-
process.once("SIGINT", cancelAndClose);
|
|
53
|
-
process.once("SIGTERM", cancelAndClose);
|
|
54
|
-
await new Promise((resolve, reject) => {
|
|
55
|
-
socket.once("connect", () => {
|
|
56
|
-
writeClientFrame(socket, {
|
|
57
|
-
kind: "authenticate",
|
|
58
|
-
token
|
|
59
|
-
}).catch(reject);
|
|
60
|
-
});
|
|
61
|
-
socket.on("data", (chunk) => {
|
|
62
|
-
try {
|
|
63
|
-
for (const line of decoder.push(chunk)) {
|
|
64
|
-
const frame = parseGatewayRuntimeLocalExecServerFrame(line);
|
|
65
|
-
switch (frame.kind) {
|
|
66
|
-
case "accepted":
|
|
67
|
-
accepted = true;
|
|
68
|
-
clearTimeout(connectionDeadline);
|
|
69
|
-
process.stdin.on("data", (stdinChunk) => {
|
|
70
|
-
if (!socket.destroyed) {
|
|
71
|
-
process.stdin.pause();
|
|
72
|
-
inputWrites = inputWrites.then(async () => await writeClientFrame(socket, {
|
|
73
|
-
contentBase64: stdinChunk.toString("base64"),
|
|
74
|
-
kind: "stdin-chunk"
|
|
75
|
-
}));
|
|
76
|
-
inputWrites.then(() => process.stdin.resume(), (error) => reject(error));
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
process.stdin.once("end", () => {
|
|
80
|
-
if (!socket.destroyed) {
|
|
81
|
-
inputWrites = inputWrites.then(async () => await writeClientFrame(socket, { kind: "stdin-end" }));
|
|
82
|
-
inputWrites.catch(reject);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
continue;
|
|
86
|
-
case "stdout-chunk":
|
|
87
|
-
outputWrites = outputWrites.then(async () => await writeProcessOutput(process.stdout, Buffer.from(frame.contentBase64, "base64")));
|
|
88
|
-
continue;
|
|
89
|
-
case "stderr-chunk":
|
|
90
|
-
outputWrites = outputWrites.then(async () => await writeProcessOutput(process.stderr, Buffer.from(frame.contentBase64, "base64")));
|
|
91
|
-
continue;
|
|
92
|
-
case "stdout-end":
|
|
93
|
-
case "stderr-end": continue;
|
|
94
|
-
case "exited":
|
|
95
|
-
exited = true;
|
|
96
|
-
process.exitCode = frame.exitCode ?? 1;
|
|
97
|
-
outputWrites.then(resolve, reject);
|
|
98
|
-
continue;
|
|
99
|
-
case "rejected":
|
|
100
|
-
reject(new Error(frame.message));
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
} catch (error) {
|
|
105
|
-
reject(error);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
socket.once("error", reject);
|
|
109
|
-
socket.once("close", () => {
|
|
110
|
-
if (!exited) reject(/* @__PURE__ */ new Error("Local exec relay closed before an exit result."));
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
clearTimeout(connectionDeadline);
|
|
114
|
-
process.off("SIGINT", cancelAndClose);
|
|
115
|
-
process.off("SIGTERM", cancelAndClose);
|
|
116
|
-
socket.destroy();
|
|
117
|
-
}
|
|
118
|
-
run().catch((error) => {
|
|
119
|
-
process.stderr.write(`${error instanceof Error ? error.message : "Local exec helper failed."}\n`);
|
|
120
|
-
process.exitCode = 1;
|
|
121
|
-
});
|
|
122
|
-
//#endregion
|
|
123
|
-
export {};
|
|
124
|
-
|
|
125
|
-
//# sourceMappingURL=gateway-runtime-local-exec-helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-runtime-local-exec-helper.js","names":[],"sources":["../../src/gateway-runtime-local-exec/gateway-runtime-local-exec-helper.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { createConnection } from 'node:net';\n\nimport {\n\tGatewayRuntimeLocalExecLineDecoder,\n\tencodeGatewayRuntimeLocalExecFrame,\n\tparseGatewayRuntimeLocalExecServerFrame,\n\ttype GatewayRuntimeLocalExecClientFrame,\n} from './gateway-runtime-local-exec-protocol.js';\nimport {\n\tGATEWAY_RUNTIME_LOCAL_EXEC_SOCKET_ENV,\n\tGATEWAY_RUNTIME_LOCAL_EXEC_TOKEN_ENV,\n} from './gateway-runtime-local-exec-transport.js';\n\nconst CONNECTION_DEADLINE_MS = 10_000;\n\nfunction requireEnvironmentValue(name: string): string {\n\tconst value = process.env[name];\n\tif (value === undefined || value.length === 0) {\n\t\tthrow new Error(`Required environment '${name}' is absent.`);\n\t}\n\treturn value;\n}\n\nasync function writeProcessOutput(stream: NodeJS.WriteStream, content: Buffer): Promise<void> {\n\tawait new Promise<void>((resolve, reject) => {\n\t\tstream.write(content, (error?: Error | null) => {\n\t\t\tif (error === undefined || error === null) resolve();\n\t\t\telse reject(error);\n\t\t});\n\t});\n}\n\nasync function writeClientFrame(\n\tsocket: ReturnType<typeof createConnection>,\n\tframe: GatewayRuntimeLocalExecClientFrame,\n): Promise<void> {\n\tif (socket.write(encodeGatewayRuntimeLocalExecFrame(frame))) return;\n\tawait new Promise<void>((resolve, reject) => {\n\t\tconst cleanup = (): void => {\n\t\t\tsocket.off('drain', handleDrain);\n\t\t\tsocket.off('error', handleError);\n\t\t};\n\t\tconst handleDrain = (): void => {\n\t\t\tcleanup();\n\t\t\tresolve();\n\t\t};\n\t\tconst handleError = (error: Error): void => {\n\t\t\tcleanup();\n\t\t\treject(error);\n\t\t};\n\t\tsocket.once('drain', handleDrain);\n\t\tsocket.once('error', handleError);\n\t});\n}\n\nasync function run(): Promise<void> {\n\tconst socketPath = requireEnvironmentValue(GATEWAY_RUNTIME_LOCAL_EXEC_SOCKET_ENV);\n\tconst token = requireEnvironmentValue(GATEWAY_RUNTIME_LOCAL_EXEC_TOKEN_ENV);\n\tconst socket = createConnection(socketPath);\n\tconst decoder = new GatewayRuntimeLocalExecLineDecoder();\n\tlet accepted = false;\n\tlet exited = false;\n\tlet inputWrites = Promise.resolve();\n\tlet outputWrites = Promise.resolve();\n\tconst connectionDeadline = setTimeout(\n\t\t() => socket.destroy(new Error('Local exec connection deadline expired.')),\n\t\tCONNECTION_DEADLINE_MS,\n\t);\n\tconst cancelAndClose = (): void => {\n\t\tprocess.stdin.destroy();\n\t\tif (!socket.destroyed && accepted && !exited) {\n\t\t\tvoid writeClientFrame(socket, { kind: 'cancel' })\n\t\t\t\t.catch(() => undefined)\n\t\t\t\t.finally(() => socket.end());\n\t\t}\n\t};\n\tprocess.once('SIGINT', cancelAndClose);\n\tprocess.once('SIGTERM', cancelAndClose);\n\n\tawait new Promise<void>((resolve, reject) => {\n\t\tsocket.once('connect', () => {\n\t\t\tvoid writeClientFrame(socket, { kind: 'authenticate', token }).catch(reject);\n\t\t});\n\t\tsocket.on('data', (chunk: Buffer) => {\n\t\t\ttry {\n\t\t\t\tfor (const line of decoder.push(chunk)) {\n\t\t\t\t\tconst frame = parseGatewayRuntimeLocalExecServerFrame(line);\n\t\t\t\t\tswitch (frame.kind) {\n\t\t\t\t\t\tcase 'accepted':\n\t\t\t\t\t\t\taccepted = true;\n\t\t\t\t\t\t\tclearTimeout(connectionDeadline);\n\t\t\t\t\t\t\tprocess.stdin.on('data', (stdinChunk: Buffer) => {\n\t\t\t\t\t\t\t\tif (!socket.destroyed) {\n\t\t\t\t\t\t\t\t\tprocess.stdin.pause();\n\t\t\t\t\t\t\t\t\tinputWrites = inputWrites.then(\n\t\t\t\t\t\t\t\t\t\tasync () =>\n\t\t\t\t\t\t\t\t\t\t\tawait writeClientFrame(socket, {\n\t\t\t\t\t\t\t\t\t\t\t\tcontentBase64: stdinChunk.toString('base64'),\n\t\t\t\t\t\t\t\t\t\t\t\tkind: 'stdin-chunk',\n\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tvoid inputWrites.then(\n\t\t\t\t\t\t\t\t\t\t() => process.stdin.resume(),\n\t\t\t\t\t\t\t\t\t\t(error: unknown) => reject(error),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tprocess.stdin.once('end', () => {\n\t\t\t\t\t\t\t\tif (!socket.destroyed) {\n\t\t\t\t\t\t\t\t\tinputWrites = inputWrites.then(\n\t\t\t\t\t\t\t\t\t\tasync () => await writeClientFrame(socket, { kind: 'stdin-end' }),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tvoid inputWrites.catch(reject);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tcase 'stdout-chunk':\n\t\t\t\t\t\t\toutputWrites = outputWrites.then(\n\t\t\t\t\t\t\t\tasync () =>\n\t\t\t\t\t\t\t\t\tawait writeProcessOutput(\n\t\t\t\t\t\t\t\t\t\tprocess.stdout,\n\t\t\t\t\t\t\t\t\t\tBuffer.from(frame.contentBase64, 'base64'),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tcase 'stderr-chunk':\n\t\t\t\t\t\t\toutputWrites = outputWrites.then(\n\t\t\t\t\t\t\t\tasync () =>\n\t\t\t\t\t\t\t\t\tawait writeProcessOutput(\n\t\t\t\t\t\t\t\t\t\tprocess.stderr,\n\t\t\t\t\t\t\t\t\t\tBuffer.from(frame.contentBase64, 'base64'),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tcase 'stdout-end':\n\t\t\t\t\t\tcase 'stderr-end':\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tcase 'exited':\n\t\t\t\t\t\t\texited = true;\n\t\t\t\t\t\t\tprocess.exitCode = frame.exitCode ?? 1;\n\t\t\t\t\t\t\tvoid outputWrites.then(resolve, reject);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tcase 'rejected':\n\t\t\t\t\t\t\treject(new Error(frame.message));\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error: unknown) {\n\t\t\t\treject(error);\n\t\t\t}\n\t\t});\n\t\tsocket.once('error', reject);\n\t\tsocket.once('close', () => {\n\t\t\tif (!exited) reject(new Error('Local exec relay closed before an exit result.'));\n\t\t});\n\t});\n\tclearTimeout(connectionDeadline);\n\tprocess.off('SIGINT', cancelAndClose);\n\tprocess.off('SIGTERM', cancelAndClose);\n\tsocket.destroy();\n}\n\nrun().catch((error: unknown) => {\n\tprocess.stderr.write(`${error instanceof Error ? error.message : 'Local exec helper failed.'}\\n`);\n\tprocess.exitCode = 1;\n});\n"],"mappings":";;;;AAcA,MAAM,yBAAyB;AAE/B,SAAS,wBAAwB,MAAsB;CACtD,MAAM,QAAQ,QAAQ,IAAI;CAC1B,IAAI,UAAU,KAAA,KAAa,MAAM,WAAW,GAC3C,MAAM,IAAI,MAAM,yBAAyB,KAAK,cAAc;CAE7D,OAAO;;AAGR,eAAe,mBAAmB,QAA4B,SAAgC;CAC7F,MAAM,IAAI,SAAe,SAAS,WAAW;EAC5C,OAAO,MAAM,UAAU,UAAyB;GAC/C,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,SAAS;QAC/C,OAAO,MAAM;IACjB;GACD;;AAGH,eAAe,iBACd,QACA,OACgB;CAChB,I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B,QAAQ,MAAM,UAAU,4BAA4B,IAAI;CACjG,QAAQ,WAAW;EAClB"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
//#region src/gateway-runtime-local-exec/gateway-runtime-local-exec-transport.d.ts
|
|
2
|
-
declare const GATEWAY_RUNTIME_LOCAL_EXEC_SOCKET_ENV = "AGENT_VM_LOCAL_EXEC_SOCKET";
|
|
3
|
-
declare const GATEWAY_RUNTIME_LOCAL_EXEC_TOKEN_ENV = "AGENT_VM_LOCAL_EXEC_TOKEN";
|
|
4
|
-
type GatewayRuntimeLocalExecReadResult = {
|
|
5
|
-
readonly content: Uint8Array;
|
|
6
|
-
readonly kind: 'chunk';
|
|
7
|
-
} | {
|
|
8
|
-
readonly kind: 'end';
|
|
9
|
-
};
|
|
10
|
-
interface GatewayRuntimeLocalExecOperation {
|
|
11
|
-
readonly cancel: () => Promise<void>;
|
|
12
|
-
readonly closeStdin: () => Promise<void>;
|
|
13
|
-
readonly readStderr: (maximumBytes: number) => Promise<GatewayRuntimeLocalExecReadResult>;
|
|
14
|
-
readonly readStdout: (maximumBytes: number) => Promise<GatewayRuntimeLocalExecReadResult>;
|
|
15
|
-
readonly resizeTerminal?: (size: {
|
|
16
|
-
readonly columns: number;
|
|
17
|
-
readonly rows: number;
|
|
18
|
-
}) => Promise<void>;
|
|
19
|
-
readonly wait: () => Promise<{
|
|
20
|
-
readonly exitCode: number | null;
|
|
21
|
-
}>;
|
|
22
|
-
readonly writeStdin: (content: Uint8Array) => Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
interface GatewayRuntimeLocalExecReservationScheduler {
|
|
25
|
-
readonly schedule: (callback: () => void, delayMs: number) => {
|
|
26
|
-
readonly cancel: () => void;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
interface GatewayRuntimeLocalExecFinalizeToken {
|
|
30
|
-
readonly kind: 'gateway-runtime-local-exec';
|
|
31
|
-
readonly reservationId: string;
|
|
32
|
-
}
|
|
33
|
-
interface GatewayRuntimeLocalExecSpec {
|
|
34
|
-
readonly argv: readonly string[];
|
|
35
|
-
readonly env: Readonly<Record<string, string>>;
|
|
36
|
-
readonly finalizeToken: GatewayRuntimeLocalExecFinalizeToken;
|
|
37
|
-
readonly stdinMode: 'pipe-open';
|
|
38
|
-
}
|
|
39
|
-
interface GatewayRuntimeLocalExecTransportOptions {
|
|
40
|
-
readonly helperArgv?: readonly string[];
|
|
41
|
-
readonly reservationScheduler?: GatewayRuntimeLocalExecReservationScheduler;
|
|
42
|
-
readonly reservationTimeoutMs?: number;
|
|
43
|
-
readonly temporaryDirectory?: string;
|
|
44
|
-
}
|
|
45
|
-
declare class GatewayRuntimeLocalExecTransport {
|
|
46
|
-
#private;
|
|
47
|
-
constructor(options?: GatewayRuntimeLocalExecTransportOptions);
|
|
48
|
-
reserve(operation: GatewayRuntimeLocalExecOperation): Promise<GatewayRuntimeLocalExecSpec>;
|
|
49
|
-
finalize(token: unknown): Promise<void>;
|
|
50
|
-
close(): Promise<void>;
|
|
51
|
-
}
|
|
52
|
-
//#endregion
|
|
53
|
-
export { GATEWAY_RUNTIME_LOCAL_EXEC_SOCKET_ENV, GATEWAY_RUNTIME_LOCAL_EXEC_TOKEN_ENV, type GatewayRuntimeLocalExecFinalizeToken, type GatewayRuntimeLocalExecOperation, type GatewayRuntimeLocalExecReadResult, type GatewayRuntimeLocalExecReservationScheduler, type GatewayRuntimeLocalExecSpec, GatewayRuntimeLocalExecTransport, type GatewayRuntimeLocalExecTransportOptions };
|
|
54
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/gateway-runtime-local-exec/gateway-runtime-local-exec-transport.ts"],"mappings":";cAca,qCAAA;AAAA,cACA,oCAAA;AAAA,KAMD,iCAAA;EAAA,SACE,OAAA,EAAS,UAAA;EAAA,SAAqB,IAAA;AAAA;EAAA,SAC9B,IAAA;AAAA;AAAA,UAEG,gCAAA;EA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IME_LOCAL_EXEC_TOKEN_ENV, GatewayRuntimeLocalExecTransport };
|