@opengeni/runtime 0.13.11 → 0.13.13

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.
@@ -927,6 +927,19 @@ declare class SandboxChannelAService {
927
927
  fsDelete(req: FsDeleteRequest): Promise<FsDeleteResponse>;
928
928
  fsMove(req: FsMoveRequest): Promise<FsMoveResponse>;
929
929
  fsMkdir(req: FsMkdirRequest): Promise<FsMkdirResponse>;
930
+ /** Measure one Git command without returning its potentially large or
931
+ * NUL-bearing output through the provider's text transport. */
932
+ private measureConfinedCommandBytes;
933
+ /** Read an exact prefix of a command's output in chunks that remain below
934
+ * every supported execCommand retained-output ceiling. The producer is
935
+ * intentionally rerun per chunk; turn-end capture calls this only after the
936
+ * durable mutation authority has quiesced the workspace. */
937
+ private readConfinedCommandPrefix;
938
+ private readConfinedCommandBytes;
939
+ /** Read a regular untracked file without routing its body through one large
940
+ * execCommand response. Native provider reads are binary-safe; providers
941
+ * without that surface use the same bounded chunk protocol as Git patches. */
942
+ private readUntrackedRegularFile;
930
943
  gitStatus(req: GitStatusRequest): Promise<GitStatusResponse>;
931
944
  gitDiff(req: GitDiffRequest): Promise<GitDiffResponse>;
932
945
  gitLog(req: GitLogRequest): Promise<GitLogResponse>;
package/dist/index.d.ts CHANGED
@@ -7,8 +7,8 @@ import { HumanInputResponse, ReasoningEffort, GitCredentialProvider, GitCredenti
7
7
  export { CAPABILITY_DESCRIPTORS, CapabilityDescriptor, DESKTOP_STREAM_PORT, StreamTokenPayload, StreamTokenPayload as StreamTokenPayloadType, TERMINAL_STREAM_PORT } from '@opengeni/contracts';
8
8
  import { SandboxSessionLike, Capability, SandboxSessionState, Manifest, Capabilities, LocalDirLazySkillSource, SandboxClient } from '@openai/agents/sandbox';
9
9
  import OpenAI from 'openai';
10
- import { R as RunCredentialSessionReady, a as RuntimeMetricsHooks } from './index-Ciehex_q.js';
11
- export { A as ActiveBackendResolverDeps, b as ActiveBackendUnresolvableError, c as ActivePointer, B as BackendUnresolvableCode, C as ChannelAConflictError, d as ChannelAEmitter, e as ChannelAExecArgs, f as ChannelAExecResult, g as ChannelANotFoundError, h as ChannelASession, i as ChannelAUnavailableError, j as ChannelAUnsupportedError, k as ChannelAValidationError, l as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, m as DISPLAY_STACK_TIMEOUT_MS, n as DefaultBackendLossResult, o as DesktopGeometry, p as DisplayStackCallerKind, q as DisplayStackClassification, r as DisplayStackError, s as DisplayStackTelemetryContext, t as DisplayStackTelemetryEvent, u as DisplayStackTelemetryStatus, v as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, w as EnsureDisplayStackResult, x as EnsureTerminalServerOptions, y as EnsureTerminalServerResult, z as EstablishedSandboxSession, F as ExposeStreamPortInput, G as ExposeStreamPortResult, H as ExposedPortEndpoint, I as FAULT_FIELD_WHAT_HAPPENED, J as FAULT_FIELD_WHAT_PRESERVED, K as FAULT_FIELD_WHAT_TO_TRY, L as FAULT_FIELD_WHICH_LAYER, M as LiveModalSandboxLeaseAttribution, N as MaterializeRunCredentialsOptions, O as MintStreamTokenInput, P as MockAgentResponder, Q as MockAgentResponderOptions, S as MockExecHandler, T as ModalModuleLoader, U as ModalOrphanSweepResult, V as ModalOrphanSweepTermination, W as ModalSandboxAttribution, X as NEVER_SENT_DETAIL_KEY, Y as NatsControlRpc, Z as NatsOpStreamConnection, _ as NatsOpStreamTransport, $ as NatsRequestConnection, a0 as NegotiationContext, a1 as NormalizedRunCredentialMaterial, a2 as NumstatEntry, a3 as OP_STREAM_ACK_INTERVAL_MS, a4 as OP_STREAM_DEFAULT_WINDOW_BYTES, a5 as OP_STREAM_RECONNECT_HOLD_MS, a6 as OP_STREAM_SILENCE_TIMEOUT_MS, a7 as OpStreamExecOutcome, a8 as OpStreamJournal, a9 as OpStreamSubscription, aa as OpStreamTransport, ab as OpStreamUnavailableError, ac as PROVIDER_REGISTRY, ad as ProviderConstructionContext, ae as ProviderRegistration, af as ProviderSandboxFailure, ag as ProviderSandboxFailureKind, ah as REPOSITORY_DISCOVERY_LIMIT, ai as RecordingArtifactMetadata, aj as RecordingCodec, ak as RecordingContentType, al as RecordingError, am as RecordingProcess, an as RecordingUnavailableError, ao as RepositoryDiscoveryDegradedReason, ap as RepositoryDiscoveryResult, aq as ResolvedActiveBackend, ar as RevalidateModalOrphanTermination, as as RoutableBackendSession, at as RoutableSandbox, au as RoutingBackendRecoveryRequiredError, av as RoutingMutationOutcomeUnknownError, aw as RoutingMutationSettlementResult, ax as RoutingRetainedProcess, ay as RoutingRetainedProcessAdoption, az as RoutingRetainedProcessNotFoundError, aA as RoutingRetainedProcessTerminalProof, aB as RoutingSandboxSession, aC as RoutingSandboxSessionDeps, aD as RoutingTransitionEvent, aE as RoutingUnsupportedError, aF as RunCredentialCommandRunner, aG as RunCredentialCommandSession, aH as RunCredentialExpectedScope, aI as RunCredentialValidationError, aJ as SELFHOSTED_DEFAULT_TIMEOUT_MS, aK as SELFHOSTED_DRAINING_MAX_RETRIES, aL as SELFHOSTED_EXEC_DRAINING_MAX_RETRIES, aM as SELFHOSTED_IDEMPOTENT_READONLY_OPS, aN as SELFHOSTED_INFRASTRUCTURE_FAULT_CLASSES, aO as SELFHOSTED_NEVER_SENT_MAX_RETRIES, aP as SELFHOSTED_RECONNECT_WINDOW_MS, aQ as SELFHOSTED_RELAY_STREAM_PATH, aR as SELFHOSTED_RETRY_BACKOFF_BASE_MS, aS as SELFHOSTED_RETRY_BACKOFF_CAP_MS, aT as SELFHOSTED_RETRY_BACKOFF_FACTOR, aU as SELFHOSTED_TIMEOUT_MAX_RETRIES, aV as STREAM_PORT, aW as STREAM_TOKEN_DEFAULT_TTL_SECONDS, aX as SandboxChannelAService, aY as SandboxChannelAServiceOptions, aZ as SandboxConfigError, a_ as SandboxCreatedCallback, a$ as SandboxExecReadinessError, b0 as SandboxProviderUnavailableError, b1 as SandboxReplacementProviderStateError, b2 as SandboxResumeStateUnavailableError, b3 as SelfhostedApplyDiff, b4 as SelfhostedControlError, b5 as SelfhostedEditor, b6 as SelfhostedEnrollment, b7 as SelfhostedExecArgs, b8 as SelfhostedExecResult, b9 as SelfhostedImageOutput, ba as SelfhostedLivenessState, bb as SelfhostedNegotiationInput, bc as SelfhostedOpObservation, bd as SelfhostedOpObserver, be as SelfhostedOpStreamDeps, bf as SelfhostedRelayConfig, bg as SelfhostedRetryClock, bh as SelfhostedRetryDecision, bi as SelfhostedSandboxClient, bj as SelfhostedSession, bk as SelfhostedSessionBuild, bl as SelfhostedSessionDeps, bm as SelfhostedSessionState, bn as SelfhostedUnavailableReason, bo as StartRecordingInput, bp as StreamPortUnavailableError, bq as SwapTargetEstablishability, br as TERMINAL_SERVER_TIMEOUT_MS, bs as TerminalServerError, bt as TerminalServerUnsupportedError, bu as ToolspaceTokenPathError, bv as VerifiedWorkspaceArchive, bw as WORKSPACE_ARCHIVE_DESCRIPTOR_VERSION, bx as WorkspaceArchiveDescriptor, by as WorkspaceArchiveIntegrityCode, bz as WorkspaceArchiveIntegrityError, bA as WorkspaceTreeFingerprint, bB as agentErrorToControlError, bC as assertDescriptorRegistryInvariants, bD as assertProviderRegistryInvariants, bE as assertSafeRelPath, bF as backendSupportsOs, bG as buildDisplayStackScript, bH as buildSelfhostedBackendSession, bI as buildStreamUrl, bJ as buildTerminalServerScript, bK as captureVerifiedWorkspaceArchive, bL as classifyProviderSandboxFailure, bM as clearRunCredentials, bN as clearRunCredentialsForAttempt, bO as contentTypeForCodec, bP as createSandboxClient, bQ as createSandboxClientForBackend, bR as decideSelfhostedRetry, bS as decodeModalSnapshotId, bT as defaultSelfhostedRetryClock, bU as deletePriorPersistedSnapshot, bV as deleteRecordingArtifacts, bW as deserializeSandboxSessionStateEnvelope, bX as desktopCapableBackend, bY as drainingExhaustedError, bZ as drainingMessage, b_ as ensureDisplayStack, b$ as ensureModalRegistryImage, c0 as ensureTerminalServer, c1 as establishSandboxSessionFromEnvelope, c2 as execDeadlineHint, c3 as exposeStreamPort, c4 as extForCodec, c5 as fingerprintSandboxWorkspace, c6 as hasPersistableSandboxProviderIdentity, c7 as inspectRecordingArtifact, c8 as isExecSessionLostBanner, c9 as isProviderSandboxGoneDuringRoutedOperation, ca as isProviderSandboxNotFoundError, cb as isProviderSandboxTransientError, cc as isSelfhostedProviderNotFoundError, cd as makeActiveBackendResolver, ce as materializeRunCredentials, cf as mintStreamToken, cg as modalSandboxAttributionEnvironment, ch as modalSandboxAttributionTags, ci as negotiateCapabilities, cj as negotiateSelfhostedCapabilities, ck as nextDurableOpId, cl as normalizeRunCredentialsResolution, cm as offlineAgentError, cn as offlineControlResponse, co as opAckSubject, cp as opFrameSubject, cq as parseExecBannerExitCode, cr as parseExecBannerSessionId, cs as parseNumstatZ, ct as parsePorcelainV2, cu as parseUnifiedPatch, cv as parseWorkspaceArchiveDescriptor, cw as payloadTooLargeMessage, cx as readVerifiedWorkspaceArchive, cy as readWorkspaceArchiveFromEnvelopeSessionState, cz as recordingStorageKey, cA as renderSelfhostedFault, cB as requirePersistableReplacementSandboxEnvelope, cC as restoredSandboxSessionStateFromEntry, cD as runCredentialPointerFile, cE as runCredentialRoot, cF as runWithToolCallCorrelation, cG as sandboxStateEntryFromRunState, cH as sanitizeOpIdToken, cI as selectBackend, cJ as selfhostedFaultClass, cK as selfhostedLiveness, cL as selfhostedRetryBackoffMs, cM as serializeEstablishedSandboxEnvelope, cN as serializeReplacementSandboxEnvelope, cO as setSelfhostedApplyDiff, cP as startRecording, cQ as stopRecording, cR as stripExecBanner, cS as subjectFor, cT as swapTargetEstablishability, cU as sweepModalOrphanSandboxes, cV as tagModalSandbox, cW as tearDownDisplayStack, cX as tearDownTerminalServer, cY as terminateModalSandboxById, cZ as timeoutAgentError, c_ as timeoutControlResponse, c$ as toolspaceTokenFileForSession, d0 as toolspaceTokenFileFromEnvironment, d1 as uploadRecordingArtifact, d2 as verifyRestoredWorkspace, d3 as verifySandboxExecReadiness, d4 as verifyStreamToken, d5 as withRunCredentialEnvironment, d6 as withRunCredentialsClient, d7 as withRunCredentialsSession, d8 as withToolspaceTokenClient, d9 as withToolspaceTokenEnvironment, da as withToolspaceTokenSession } from './index-Ciehex_q.js';
10
+ import { R as RunCredentialSessionReady, a as RuntimeMetricsHooks } from './index-BraazrAO.js';
11
+ export { A as ActiveBackendResolverDeps, b as ActiveBackendUnresolvableError, c as ActivePointer, B as BackendUnresolvableCode, C as ChannelAConflictError, d as ChannelAEmitter, e as ChannelAExecArgs, f as ChannelAExecResult, g as ChannelANotFoundError, h as ChannelASession, i as ChannelAUnavailableError, j as ChannelAUnsupportedError, k as ChannelAValidationError, l as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, m as DISPLAY_STACK_TIMEOUT_MS, n as DefaultBackendLossResult, o as DesktopGeometry, p as DisplayStackCallerKind, q as DisplayStackClassification, r as DisplayStackError, s as DisplayStackTelemetryContext, t as DisplayStackTelemetryEvent, u as DisplayStackTelemetryStatus, v as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, w as EnsureDisplayStackResult, x as EnsureTerminalServerOptions, y as EnsureTerminalServerResult, z as EstablishedSandboxSession, F as ExposeStreamPortInput, G as ExposeStreamPortResult, H as ExposedPortEndpoint, I as FAULT_FIELD_WHAT_HAPPENED, J as FAULT_FIELD_WHAT_PRESERVED, K as FAULT_FIELD_WHAT_TO_TRY, L as FAULT_FIELD_WHICH_LAYER, M as LiveModalSandboxLeaseAttribution, N as MaterializeRunCredentialsOptions, O as MintStreamTokenInput, P as MockAgentResponder, Q as MockAgentResponderOptions, S as MockExecHandler, T as ModalModuleLoader, U as ModalOrphanSweepResult, V as ModalOrphanSweepTermination, W as ModalSandboxAttribution, X as NEVER_SENT_DETAIL_KEY, Y as NatsControlRpc, Z as NatsOpStreamConnection, _ as NatsOpStreamTransport, $ as NatsRequestConnection, a0 as NegotiationContext, a1 as NormalizedRunCredentialMaterial, a2 as NumstatEntry, a3 as OP_STREAM_ACK_INTERVAL_MS, a4 as OP_STREAM_DEFAULT_WINDOW_BYTES, a5 as OP_STREAM_RECONNECT_HOLD_MS, a6 as OP_STREAM_SILENCE_TIMEOUT_MS, a7 as OpStreamExecOutcome, a8 as OpStreamJournal, a9 as OpStreamSubscription, aa as OpStreamTransport, ab as OpStreamUnavailableError, ac as PROVIDER_REGISTRY, ad as ProviderConstructionContext, ae as ProviderRegistration, af as ProviderSandboxFailure, ag as ProviderSandboxFailureKind, ah as REPOSITORY_DISCOVERY_LIMIT, ai as RecordingArtifactMetadata, aj as RecordingCodec, ak as RecordingContentType, al as RecordingError, am as RecordingProcess, an as RecordingUnavailableError, ao as RepositoryDiscoveryDegradedReason, ap as RepositoryDiscoveryResult, aq as ResolvedActiveBackend, ar as RevalidateModalOrphanTermination, as as RoutableBackendSession, at as RoutableSandbox, au as RoutingBackendRecoveryRequiredError, av as RoutingMutationOutcomeUnknownError, aw as RoutingMutationSettlementResult, ax as RoutingRetainedProcess, ay as RoutingRetainedProcessAdoption, az as RoutingRetainedProcessNotFoundError, aA as RoutingRetainedProcessTerminalProof, aB as RoutingSandboxSession, aC as RoutingSandboxSessionDeps, aD as RoutingTransitionEvent, aE as RoutingUnsupportedError, aF as RunCredentialCommandRunner, aG as RunCredentialCommandSession, aH as RunCredentialExpectedScope, aI as RunCredentialValidationError, aJ as SELFHOSTED_DEFAULT_TIMEOUT_MS, aK as SELFHOSTED_DRAINING_MAX_RETRIES, aL as SELFHOSTED_EXEC_DRAINING_MAX_RETRIES, aM as SELFHOSTED_IDEMPOTENT_READONLY_OPS, aN as SELFHOSTED_INFRASTRUCTURE_FAULT_CLASSES, aO as SELFHOSTED_NEVER_SENT_MAX_RETRIES, aP as SELFHOSTED_RECONNECT_WINDOW_MS, aQ as SELFHOSTED_RELAY_STREAM_PATH, aR as SELFHOSTED_RETRY_BACKOFF_BASE_MS, aS as SELFHOSTED_RETRY_BACKOFF_CAP_MS, aT as SELFHOSTED_RETRY_BACKOFF_FACTOR, aU as SELFHOSTED_TIMEOUT_MAX_RETRIES, aV as STREAM_PORT, aW as STREAM_TOKEN_DEFAULT_TTL_SECONDS, aX as SandboxChannelAService, aY as SandboxChannelAServiceOptions, aZ as SandboxConfigError, a_ as SandboxCreatedCallback, a$ as SandboxExecReadinessError, b0 as SandboxProviderUnavailableError, b1 as SandboxReplacementProviderStateError, b2 as SandboxResumeStateUnavailableError, b3 as SelfhostedApplyDiff, b4 as SelfhostedControlError, b5 as SelfhostedEditor, b6 as SelfhostedEnrollment, b7 as SelfhostedExecArgs, b8 as SelfhostedExecResult, b9 as SelfhostedImageOutput, ba as SelfhostedLivenessState, bb as SelfhostedNegotiationInput, bc as SelfhostedOpObservation, bd as SelfhostedOpObserver, be as SelfhostedOpStreamDeps, bf as SelfhostedRelayConfig, bg as SelfhostedRetryClock, bh as SelfhostedRetryDecision, bi as SelfhostedSandboxClient, bj as SelfhostedSession, bk as SelfhostedSessionBuild, bl as SelfhostedSessionDeps, bm as SelfhostedSessionState, bn as SelfhostedUnavailableReason, bo as StartRecordingInput, bp as StreamPortUnavailableError, bq as SwapTargetEstablishability, br as TERMINAL_SERVER_TIMEOUT_MS, bs as TerminalServerError, bt as TerminalServerUnsupportedError, bu as ToolspaceTokenPathError, bv as VerifiedWorkspaceArchive, bw as WORKSPACE_ARCHIVE_DESCRIPTOR_VERSION, bx as WorkspaceArchiveDescriptor, by as WorkspaceArchiveIntegrityCode, bz as WorkspaceArchiveIntegrityError, bA as WorkspaceTreeFingerprint, bB as agentErrorToControlError, bC as assertDescriptorRegistryInvariants, bD as assertProviderRegistryInvariants, bE as assertSafeRelPath, bF as backendSupportsOs, bG as buildDisplayStackScript, bH as buildSelfhostedBackendSession, bI as buildStreamUrl, bJ as buildTerminalServerScript, bK as captureVerifiedWorkspaceArchive, bL as classifyProviderSandboxFailure, bM as clearRunCredentials, bN as clearRunCredentialsForAttempt, bO as contentTypeForCodec, bP as createSandboxClient, bQ as createSandboxClientForBackend, bR as decideSelfhostedRetry, bS as decodeModalSnapshotId, bT as defaultSelfhostedRetryClock, bU as deletePriorPersistedSnapshot, bV as deleteRecordingArtifacts, bW as deserializeSandboxSessionStateEnvelope, bX as desktopCapableBackend, bY as drainingExhaustedError, bZ as drainingMessage, b_ as ensureDisplayStack, b$ as ensureModalRegistryImage, c0 as ensureTerminalServer, c1 as establishSandboxSessionFromEnvelope, c2 as execDeadlineHint, c3 as exposeStreamPort, c4 as extForCodec, c5 as fingerprintSandboxWorkspace, c6 as hasPersistableSandboxProviderIdentity, c7 as inspectRecordingArtifact, c8 as isExecSessionLostBanner, c9 as isProviderSandboxGoneDuringRoutedOperation, ca as isProviderSandboxNotFoundError, cb as isProviderSandboxTransientError, cc as isSelfhostedProviderNotFoundError, cd as makeActiveBackendResolver, ce as materializeRunCredentials, cf as mintStreamToken, cg as modalSandboxAttributionEnvironment, ch as modalSandboxAttributionTags, ci as negotiateCapabilities, cj as negotiateSelfhostedCapabilities, ck as nextDurableOpId, cl as normalizeRunCredentialsResolution, cm as offlineAgentError, cn as offlineControlResponse, co as opAckSubject, cp as opFrameSubject, cq as parseExecBannerExitCode, cr as parseExecBannerSessionId, cs as parseNumstatZ, ct as parsePorcelainV2, cu as parseUnifiedPatch, cv as parseWorkspaceArchiveDescriptor, cw as payloadTooLargeMessage, cx as readVerifiedWorkspaceArchive, cy as readWorkspaceArchiveFromEnvelopeSessionState, cz as recordingStorageKey, cA as renderSelfhostedFault, cB as requirePersistableReplacementSandboxEnvelope, cC as restoredSandboxSessionStateFromEntry, cD as runCredentialPointerFile, cE as runCredentialRoot, cF as runWithToolCallCorrelation, cG as sandboxStateEntryFromRunState, cH as sanitizeOpIdToken, cI as selectBackend, cJ as selfhostedFaultClass, cK as selfhostedLiveness, cL as selfhostedRetryBackoffMs, cM as serializeEstablishedSandboxEnvelope, cN as serializeReplacementSandboxEnvelope, cO as setSelfhostedApplyDiff, cP as startRecording, cQ as stopRecording, cR as stripExecBanner, cS as subjectFor, cT as swapTargetEstablishability, cU as sweepModalOrphanSandboxes, cV as tagModalSandbox, cW as tearDownDisplayStack, cX as tearDownTerminalServer, cY as terminateModalSandboxById, cZ as timeoutAgentError, c_ as timeoutControlResponse, c$ as toolspaceTokenFileForSession, d0 as toolspaceTokenFileFromEnvironment, d1 as uploadRecordingArtifact, d2 as verifyRestoredWorkspace, d3 as verifySandboxExecReadiness, d4 as verifyStreamToken, d5 as withRunCredentialEnvironment, d6 as withRunCredentialsClient, d7 as withRunCredentialsSession, d8 as withToolspaceTokenClient, d9 as withToolspaceTokenEnvironment, da as withToolspaceTokenSession } from './index-BraazrAO.js';
12
12
  export { SkillLibraryEntry, SkillLibraryFile, SkillLibrarySkill, getSkillLibraryEntry, isSkillLibraryEntryId, listSkillLibraryEntries, loadSkillLibrarySkill } from './skill-library.js';
13
13
  import 'modal';
14
14
  import '@opengeni/agent-proto';
package/dist/index.js CHANGED
@@ -175,7 +175,7 @@ import {
175
175
  withToolspaceTokenEnvironment,
176
176
  withToolspaceTokenSession,
177
177
  wrapCapabilityToolsForTurnCancellation
178
- } from "./chunk-RHB7ETON.js";
178
+ } from "./chunk-3NUSY22C.js";
179
179
  import {
180
180
  getSkillLibraryEntry,
181
181
  isSkillLibraryEntryId,
@@ -1,6 +1,6 @@
1
1
  export { collectSandboxEnvironment, parseExposedPorts } from '@opengeni/config';
2
2
  export { CAPABILITY_DESCRIPTORS, CapabilityDescriptor, DESKTOP_STREAM_PORT, StreamTokenPayload, StreamTokenPayload as StreamTokenPayloadType, TERMINAL_STREAM_PORT } from '@opengeni/contracts';
3
3
  import '@openai/agents/sandbox';
4
- export { A as ActiveBackendResolverDeps, b as ActiveBackendUnresolvableError, c as ActivePointer, B as BackendUnresolvableCode, C as ChannelAConflictError, d as ChannelAEmitter, e as ChannelAExecArgs, f as ChannelAExecResult, g as ChannelANotFoundError, h as ChannelASession, i as ChannelAUnavailableError, j as ChannelAUnsupportedError, k as ChannelAValidationError, l as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, m as DISPLAY_STACK_TIMEOUT_MS, n as DefaultBackendLossResult, o as DesktopGeometry, p as DisplayStackCallerKind, q as DisplayStackClassification, r as DisplayStackError, s as DisplayStackTelemetryContext, t as DisplayStackTelemetryEvent, u as DisplayStackTelemetryStatus, v as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, w as EnsureDisplayStackResult, x as EnsureTerminalServerOptions, y as EnsureTerminalServerResult, z as EstablishedSandboxSession, F as ExposeStreamPortInput, G as ExposeStreamPortResult, H as ExposedPortEndpoint, I as FAULT_FIELD_WHAT_HAPPENED, J as FAULT_FIELD_WHAT_PRESERVED, K as FAULT_FIELD_WHAT_TO_TRY, L as FAULT_FIELD_WHICH_LAYER, M as LiveModalSandboxLeaseAttribution, N as MaterializeRunCredentialsOptions, O as MintStreamTokenInput, P as MockAgentResponder, Q as MockAgentResponderOptions, S as MockExecHandler, T as ModalModuleLoader, U as ModalOrphanSweepResult, V as ModalOrphanSweepTermination, W as ModalSandboxAttribution, X as NEVER_SENT_DETAIL_KEY, Y as NatsControlRpc, Z as NatsOpStreamConnection, _ as NatsOpStreamTransport, $ as NatsRequestConnection, a0 as NegotiationContext, a1 as NormalizedRunCredentialMaterial, a2 as NumstatEntry, a3 as OP_STREAM_ACK_INTERVAL_MS, a4 as OP_STREAM_DEFAULT_WINDOW_BYTES, a5 as OP_STREAM_RECONNECT_HOLD_MS, a6 as OP_STREAM_SILENCE_TIMEOUT_MS, a7 as OpStreamExecOutcome, a8 as OpStreamJournal, a9 as OpStreamSubscription, aa as OpStreamTransport, ab as OpStreamUnavailableError, ac as PROVIDER_REGISTRY, ad as ProviderConstructionContext, ae as ProviderRegistration, af as ProviderSandboxFailure, ag as ProviderSandboxFailureKind, ah as REPOSITORY_DISCOVERY_LIMIT, ai as RecordingArtifactMetadata, aj as RecordingCodec, ak as RecordingContentType, al as RecordingError, am as RecordingProcess, an as RecordingUnavailableError, ao as RepositoryDiscoveryDegradedReason, ap as RepositoryDiscoveryResult, aq as ResolvedActiveBackend, ar as RevalidateModalOrphanTermination, as as RoutableBackendSession, at as RoutableSandbox, au as RoutingBackendRecoveryRequiredError, av as RoutingMutationOutcomeUnknownError, aw as RoutingMutationSettlementResult, ax as RoutingRetainedProcess, ay as RoutingRetainedProcessAdoption, az as RoutingRetainedProcessNotFoundError, aA as RoutingRetainedProcessTerminalProof, aB as RoutingSandboxSession, aC as RoutingSandboxSessionDeps, aD as RoutingTransitionEvent, aE as RoutingUnsupportedError, aF as RunCredentialCommandRunner, aG as RunCredentialCommandSession, aH as RunCredentialExpectedScope, R as RunCredentialSessionReady, aI as RunCredentialValidationError, aJ as SELFHOSTED_DEFAULT_TIMEOUT_MS, aK as SELFHOSTED_DRAINING_MAX_RETRIES, aL as SELFHOSTED_EXEC_DRAINING_MAX_RETRIES, aM as SELFHOSTED_IDEMPOTENT_READONLY_OPS, aN as SELFHOSTED_INFRASTRUCTURE_FAULT_CLASSES, aO as SELFHOSTED_NEVER_SENT_MAX_RETRIES, aP as SELFHOSTED_RECONNECT_WINDOW_MS, aQ as SELFHOSTED_RELAY_STREAM_PATH, aR as SELFHOSTED_RETRY_BACKOFF_BASE_MS, aS as SELFHOSTED_RETRY_BACKOFF_CAP_MS, aT as SELFHOSTED_RETRY_BACKOFF_FACTOR, aU as SELFHOSTED_TIMEOUT_MAX_RETRIES, aV as STREAM_PORT, aW as STREAM_TOKEN_DEFAULT_TTL_SECONDS, aX as SandboxChannelAService, aY as SandboxChannelAServiceOptions, aZ as SandboxConfigError, a_ as SandboxCreatedCallback, a$ as SandboxExecReadinessError, b0 as SandboxProviderUnavailableError, b1 as SandboxReplacementProviderStateError, b2 as SandboxResumeStateUnavailableError, b3 as SelfhostedApplyDiff, b4 as SelfhostedControlError, b5 as SelfhostedEditor, b6 as SelfhostedEnrollment, b7 as SelfhostedExecArgs, b8 as SelfhostedExecResult, b9 as SelfhostedImageOutput, ba as SelfhostedLivenessState, bb as SelfhostedNegotiationInput, bc as SelfhostedOpObservation, bd as SelfhostedOpObserver, be as SelfhostedOpStreamDeps, bf as SelfhostedRelayConfig, bg as SelfhostedRetryClock, bh as SelfhostedRetryDecision, bi as SelfhostedSandboxClient, bj as SelfhostedSession, bk as SelfhostedSessionBuild, bl as SelfhostedSessionDeps, bm as SelfhostedSessionState, bn as SelfhostedUnavailableReason, bo as StartRecordingInput, bp as StreamPortUnavailableError, bq as SwapTargetEstablishability, br as TERMINAL_SERVER_TIMEOUT_MS, bs as TerminalServerError, bt as TerminalServerUnsupportedError, bu as ToolspaceTokenPathError, bv as VerifiedWorkspaceArchive, bw as WORKSPACE_ARCHIVE_DESCRIPTOR_VERSION, bx as WorkspaceArchiveDescriptor, by as WorkspaceArchiveIntegrityCode, bz as WorkspaceArchiveIntegrityError, bA as WorkspaceTreeFingerprint, bB as agentErrorToControlError, bC as assertDescriptorRegistryInvariants, bD as assertProviderRegistryInvariants, bE as assertSafeRelPath, bF as backendSupportsOs, bG as buildDisplayStackScript, bH as buildSelfhostedBackendSession, bI as buildStreamUrl, bJ as buildTerminalServerScript, bK as captureVerifiedWorkspaceArchive, bL as classifyProviderSandboxFailure, bM as clearRunCredentials, bN as clearRunCredentialsForAttempt, bO as contentTypeForCodec, bP as createSandboxClient, bQ as createSandboxClientForBackend, bR as decideSelfhostedRetry, bS as decodeModalSnapshotId, bT as defaultSelfhostedRetryClock, bU as deletePriorPersistedSnapshot, bV as deleteRecordingArtifacts, bW as deserializeSandboxSessionStateEnvelope, bX as desktopCapableBackend, bY as drainingExhaustedError, bZ as drainingMessage, b_ as ensureDisplayStack, b$ as ensureModalRegistryImage, c0 as ensureTerminalServer, c1 as establishSandboxSessionFromEnvelope, c2 as execDeadlineHint, c3 as exposeStreamPort, c4 as extForCodec, c5 as fingerprintSandboxWorkspace, c6 as hasPersistableSandboxProviderIdentity, c7 as inspectRecordingArtifact, c8 as isExecSessionLostBanner, c9 as isProviderSandboxGoneDuringRoutedOperation, ca as isProviderSandboxNotFoundError, cb as isProviderSandboxTransientError, cc as isSelfhostedProviderNotFoundError, cd as makeActiveBackendResolver, ce as materializeRunCredentials, cf as mintStreamToken, cg as modalSandboxAttributionEnvironment, ch as modalSandboxAttributionTags, ci as negotiateCapabilities, cj as negotiateSelfhostedCapabilities, ck as nextDurableOpId, cl as normalizeRunCredentialsResolution, cm as offlineAgentError, cn as offlineControlResponse, co as opAckSubject, cp as opFrameSubject, cq as parseExecBannerExitCode, cr as parseExecBannerSessionId, cs as parseNumstatZ, ct as parsePorcelainV2, cu as parseUnifiedPatch, cv as parseWorkspaceArchiveDescriptor, cw as payloadTooLargeMessage, cx as readVerifiedWorkspaceArchive, cy as readWorkspaceArchiveFromEnvelopeSessionState, cz as recordingStorageKey, cA as renderSelfhostedFault, cB as requirePersistableReplacementSandboxEnvelope, cC as restoredSandboxSessionStateFromEntry, cD as runCredentialPointerFile, cE as runCredentialRoot, cF as runWithToolCallCorrelation, cG as sandboxStateEntryFromRunState, cH as sanitizeOpIdToken, cI as selectBackend, cJ as selfhostedFaultClass, cK as selfhostedLiveness, cL as selfhostedRetryBackoffMs, cM as serializeEstablishedSandboxEnvelope, cN as serializeReplacementSandboxEnvelope, cO as setSelfhostedApplyDiff, cP as startRecording, cQ as stopRecording, cR as stripExecBanner, cS as subjectFor, cT as swapTargetEstablishability, cU as sweepModalOrphanSandboxes, cV as tagModalSandbox, cW as tearDownDisplayStack, cX as tearDownTerminalServer, cY as terminateModalSandboxById, cZ as timeoutAgentError, c_ as timeoutControlResponse, c$ as toolspaceTokenFileForSession, d0 as toolspaceTokenFileFromEnvironment, d1 as uploadRecordingArtifact, d2 as verifyRestoredWorkspace, d3 as verifySandboxExecReadiness, d4 as verifyStreamToken, d5 as withRunCredentialEnvironment, d6 as withRunCredentialsClient, d7 as withRunCredentialsSession, d8 as withToolspaceTokenClient, d9 as withToolspaceTokenEnvironment, da as withToolspaceTokenSession } from '../index-Ciehex_q.js';
4
+ export { A as ActiveBackendResolverDeps, b as ActiveBackendUnresolvableError, c as ActivePointer, B as BackendUnresolvableCode, C as ChannelAConflictError, d as ChannelAEmitter, e as ChannelAExecArgs, f as ChannelAExecResult, g as ChannelANotFoundError, h as ChannelASession, i as ChannelAUnavailableError, j as ChannelAUnsupportedError, k as ChannelAValidationError, l as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, m as DISPLAY_STACK_TIMEOUT_MS, n as DefaultBackendLossResult, o as DesktopGeometry, p as DisplayStackCallerKind, q as DisplayStackClassification, r as DisplayStackError, s as DisplayStackTelemetryContext, t as DisplayStackTelemetryEvent, u as DisplayStackTelemetryStatus, v as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, w as EnsureDisplayStackResult, x as EnsureTerminalServerOptions, y as EnsureTerminalServerResult, z as EstablishedSandboxSession, F as ExposeStreamPortInput, G as ExposeStreamPortResult, H as ExposedPortEndpoint, I as FAULT_FIELD_WHAT_HAPPENED, J as FAULT_FIELD_WHAT_PRESERVED, K as FAULT_FIELD_WHAT_TO_TRY, L as FAULT_FIELD_WHICH_LAYER, M as LiveModalSandboxLeaseAttribution, N as MaterializeRunCredentialsOptions, O as MintStreamTokenInput, P as MockAgentResponder, Q as MockAgentResponderOptions, S as MockExecHandler, T as ModalModuleLoader, U as ModalOrphanSweepResult, V as ModalOrphanSweepTermination, W as ModalSandboxAttribution, X as NEVER_SENT_DETAIL_KEY, Y as NatsControlRpc, Z as NatsOpStreamConnection, _ as NatsOpStreamTransport, $ as NatsRequestConnection, a0 as NegotiationContext, a1 as NormalizedRunCredentialMaterial, a2 as NumstatEntry, a3 as OP_STREAM_ACK_INTERVAL_MS, a4 as OP_STREAM_DEFAULT_WINDOW_BYTES, a5 as OP_STREAM_RECONNECT_HOLD_MS, a6 as OP_STREAM_SILENCE_TIMEOUT_MS, a7 as OpStreamExecOutcome, a8 as OpStreamJournal, a9 as OpStreamSubscription, aa as OpStreamTransport, ab as OpStreamUnavailableError, ac as PROVIDER_REGISTRY, ad as ProviderConstructionContext, ae as ProviderRegistration, af as ProviderSandboxFailure, ag as ProviderSandboxFailureKind, ah as REPOSITORY_DISCOVERY_LIMIT, ai as RecordingArtifactMetadata, aj as RecordingCodec, ak as RecordingContentType, al as RecordingError, am as RecordingProcess, an as RecordingUnavailableError, ao as RepositoryDiscoveryDegradedReason, ap as RepositoryDiscoveryResult, aq as ResolvedActiveBackend, ar as RevalidateModalOrphanTermination, as as RoutableBackendSession, at as RoutableSandbox, au as RoutingBackendRecoveryRequiredError, av as RoutingMutationOutcomeUnknownError, aw as RoutingMutationSettlementResult, ax as RoutingRetainedProcess, ay as RoutingRetainedProcessAdoption, az as RoutingRetainedProcessNotFoundError, aA as RoutingRetainedProcessTerminalProof, aB as RoutingSandboxSession, aC as RoutingSandboxSessionDeps, aD as RoutingTransitionEvent, aE as RoutingUnsupportedError, aF as RunCredentialCommandRunner, aG as RunCredentialCommandSession, aH as RunCredentialExpectedScope, R as RunCredentialSessionReady, aI as RunCredentialValidationError, aJ as SELFHOSTED_DEFAULT_TIMEOUT_MS, aK as SELFHOSTED_DRAINING_MAX_RETRIES, aL as SELFHOSTED_EXEC_DRAINING_MAX_RETRIES, aM as SELFHOSTED_IDEMPOTENT_READONLY_OPS, aN as SELFHOSTED_INFRASTRUCTURE_FAULT_CLASSES, aO as SELFHOSTED_NEVER_SENT_MAX_RETRIES, aP as SELFHOSTED_RECONNECT_WINDOW_MS, aQ as SELFHOSTED_RELAY_STREAM_PATH, aR as SELFHOSTED_RETRY_BACKOFF_BASE_MS, aS as SELFHOSTED_RETRY_BACKOFF_CAP_MS, aT as SELFHOSTED_RETRY_BACKOFF_FACTOR, aU as SELFHOSTED_TIMEOUT_MAX_RETRIES, aV as STREAM_PORT, aW as STREAM_TOKEN_DEFAULT_TTL_SECONDS, aX as SandboxChannelAService, aY as SandboxChannelAServiceOptions, aZ as SandboxConfigError, a_ as SandboxCreatedCallback, a$ as SandboxExecReadinessError, b0 as SandboxProviderUnavailableError, b1 as SandboxReplacementProviderStateError, b2 as SandboxResumeStateUnavailableError, b3 as SelfhostedApplyDiff, b4 as SelfhostedControlError, b5 as SelfhostedEditor, b6 as SelfhostedEnrollment, b7 as SelfhostedExecArgs, b8 as SelfhostedExecResult, b9 as SelfhostedImageOutput, ba as SelfhostedLivenessState, bb as SelfhostedNegotiationInput, bc as SelfhostedOpObservation, bd as SelfhostedOpObserver, be as SelfhostedOpStreamDeps, bf as SelfhostedRelayConfig, bg as SelfhostedRetryClock, bh as SelfhostedRetryDecision, bi as SelfhostedSandboxClient, bj as SelfhostedSession, bk as SelfhostedSessionBuild, bl as SelfhostedSessionDeps, bm as SelfhostedSessionState, bn as SelfhostedUnavailableReason, bo as StartRecordingInput, bp as StreamPortUnavailableError, bq as SwapTargetEstablishability, br as TERMINAL_SERVER_TIMEOUT_MS, bs as TerminalServerError, bt as TerminalServerUnsupportedError, bu as ToolspaceTokenPathError, bv as VerifiedWorkspaceArchive, bw as WORKSPACE_ARCHIVE_DESCRIPTOR_VERSION, bx as WorkspaceArchiveDescriptor, by as WorkspaceArchiveIntegrityCode, bz as WorkspaceArchiveIntegrityError, bA as WorkspaceTreeFingerprint, bB as agentErrorToControlError, bC as assertDescriptorRegistryInvariants, bD as assertProviderRegistryInvariants, bE as assertSafeRelPath, bF as backendSupportsOs, bG as buildDisplayStackScript, bH as buildSelfhostedBackendSession, bI as buildStreamUrl, bJ as buildTerminalServerScript, bK as captureVerifiedWorkspaceArchive, bL as classifyProviderSandboxFailure, bM as clearRunCredentials, bN as clearRunCredentialsForAttempt, bO as contentTypeForCodec, bP as createSandboxClient, bQ as createSandboxClientForBackend, bR as decideSelfhostedRetry, bS as decodeModalSnapshotId, bT as defaultSelfhostedRetryClock, bU as deletePriorPersistedSnapshot, bV as deleteRecordingArtifacts, bW as deserializeSandboxSessionStateEnvelope, bX as desktopCapableBackend, bY as drainingExhaustedError, bZ as drainingMessage, b_ as ensureDisplayStack, b$ as ensureModalRegistryImage, c0 as ensureTerminalServer, c1 as establishSandboxSessionFromEnvelope, c2 as execDeadlineHint, c3 as exposeStreamPort, c4 as extForCodec, c5 as fingerprintSandboxWorkspace, c6 as hasPersistableSandboxProviderIdentity, c7 as inspectRecordingArtifact, c8 as isExecSessionLostBanner, c9 as isProviderSandboxGoneDuringRoutedOperation, ca as isProviderSandboxNotFoundError, cb as isProviderSandboxTransientError, cc as isSelfhostedProviderNotFoundError, cd as makeActiveBackendResolver, ce as materializeRunCredentials, cf as mintStreamToken, cg as modalSandboxAttributionEnvironment, ch as modalSandboxAttributionTags, ci as negotiateCapabilities, cj as negotiateSelfhostedCapabilities, ck as nextDurableOpId, cl as normalizeRunCredentialsResolution, cm as offlineAgentError, cn as offlineControlResponse, co as opAckSubject, cp as opFrameSubject, cq as parseExecBannerExitCode, cr as parseExecBannerSessionId, cs as parseNumstatZ, ct as parsePorcelainV2, cu as parseUnifiedPatch, cv as parseWorkspaceArchiveDescriptor, cw as payloadTooLargeMessage, cx as readVerifiedWorkspaceArchive, cy as readWorkspaceArchiveFromEnvelopeSessionState, cz as recordingStorageKey, cA as renderSelfhostedFault, cB as requirePersistableReplacementSandboxEnvelope, cC as restoredSandboxSessionStateFromEntry, cD as runCredentialPointerFile, cE as runCredentialRoot, cF as runWithToolCallCorrelation, cG as sandboxStateEntryFromRunState, cH as sanitizeOpIdToken, cI as selectBackend, cJ as selfhostedFaultClass, cK as selfhostedLiveness, cL as selfhostedRetryBackoffMs, cM as serializeEstablishedSandboxEnvelope, cN as serializeReplacementSandboxEnvelope, cO as setSelfhostedApplyDiff, cP as startRecording, cQ as stopRecording, cR as stripExecBanner, cS as subjectFor, cT as swapTargetEstablishability, cU as sweepModalOrphanSandboxes, cV as tagModalSandbox, cW as tearDownDisplayStack, cX as tearDownTerminalServer, cY as terminateModalSandboxById, cZ as timeoutAgentError, c_ as timeoutControlResponse, c$ as toolspaceTokenFileForSession, d0 as toolspaceTokenFileFromEnvironment, d1 as uploadRecordingArtifact, d2 as verifyRestoredWorkspace, d3 as verifySandboxExecReadiness, d4 as verifyStreamToken, d5 as withRunCredentialEnvironment, d6 as withRunCredentialsClient, d7 as withRunCredentialsSession, d8 as withToolspaceTokenClient, d9 as withToolspaceTokenEnvironment, da as withToolspaceTokenSession } from '../index-BraazrAO.js';
5
5
  import 'modal';
6
6
  import '@opengeni/agent-proto';
@@ -170,7 +170,7 @@ import {
170
170
  withToolspaceTokenClient,
171
171
  withToolspaceTokenEnvironment,
172
172
  withToolspaceTokenSession
173
- } from "../chunk-RHB7ETON.js";
173
+ } from "../chunk-3NUSY22C.js";
174
174
  import "../chunk-4YJ5Z52Z.js";
175
175
  import "../chunk-K4V4QYCL.js";
176
176
  import "../chunk-PZ5AY32C.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/runtime",
3
- "version": "0.13.11",
3
+ "version": "0.13.13",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -50,8 +50,8 @@
50
50
  "@openai/agents-extensions": "0.13.3",
51
51
  "@opengeni/agent-proto": "^0.3.0",
52
52
  "@opengeni/codex": "^0.2.7",
53
- "@opengeni/config": "^0.7.7",
54
- "@opengeni/contracts": "^0.20.0",
53
+ "@opengeni/config": "^0.7.8",
54
+ "@opengeni/contracts": "^0.20.1",
55
55
  "@opengeni/network": "^0.1.1",
56
56
  "debug": "4.4.3",
57
57
  "modal": "0.7.6",
@@ -12,9 +12,10 @@
12
12
  // Built on `session.exec(args): Promise<SandboxExecResult>`, which
13
13
  // returns RAW {stdout,stderr,exitCode} on the agents-core local/docker sessions
14
14
  // (and Modal/the extensions providers expose the equivalent). `execCommand`
15
- // returns a BANNER-DECORATED string (formatExecResponse) — NEVER used for
16
- // parsing; only as a last-resort fallback when `exec` is absent, with the banner
17
- // stripped. `readFile` returns string|Uint8Array (binary-safe). Writes go
15
+ // returns a BANNER-DECORATED string (formatExecResponse). Structured reads use
16
+ // it only with bounded, explicit framing and strip the banner before parsing;
17
+ // raw `exec` remains preferred. `readFile` returns string|Uint8Array
18
+ // (binary-safe). Writes go
18
19
  // through `exec` (a base64 heredoc — raw + binary capable, unlike createEditor's
19
20
  // apply-patch-only path which cannot do binary, C4), falling back to
20
21
  // `createEditor` for text when `exec` is absent.
@@ -212,6 +213,12 @@ const FS_LIST_TRUNCATED_MARKER = "__OPENGENI_FS_LIST_TRUNCATED__";
212
213
  // stream. Leave ample framing/translation headroom and emit an explicit marker
213
214
  // instead of allowing the SDK to drop the tree's leading parent records.
214
215
  const FS_LIST_MAX_OUTPUT_BYTES = 768 * 1024;
216
+ // Modal and the local SDK retain at most 1 MiB of command output and discard
217
+ // the prefix when that limit is crossed. Git's NUL-delimited metadata and
218
+ // unified patches therefore travel as bounded base64 chunks. 512 KiB of raw
219
+ // data expands to ~683 KiB, leaving room for confinement/provider framing.
220
+ const GIT_COMMAND_CHUNK_BYTES = 512 * 1024;
221
+ const GIT_METADATA_MAX_BYTES = 2 * 1024 * 1024;
215
222
  const US = String.fromCharCode(0x1f); // \x1f unit sep — git-log field separator
216
223
  const RS = String.fromCharCode(0x1e); // \x1e record sep — git-log record separator
217
224
  const SELFHOSTED_VIRTUAL_ROOT = "/workspace";
@@ -256,8 +263,9 @@ export class SandboxChannelAService {
256
263
  // ════════════════════════════ exec primitive ══════════════════════════════
257
264
  // RAW exec — returns {stdout, stderr, exitCode}. Uses session.exec when present
258
265
  // (the local/docker sessions return raw output); falls back to execCommand +
259
- // a banner strip (last resort; banner-truncation can mangle, so exec is always
260
- // preferred). Throws ChannelAUnsupportedError when neither exists.
266
+ // a banner strip. Callers that parse output must independently bound/frame it
267
+ // because provider retained-output truncation drops command prefixes. Throws
268
+ // ChannelAUnsupportedError when neither exists.
261
269
  private async run(args: ChannelAExecArgs): Promise<{
262
270
  stdout: string;
263
271
  stderr: string;
@@ -797,6 +805,141 @@ export class SandboxChannelAService {
797
805
 
798
806
  // ════════════════════════════ Git (A2, read-only) ═════════════════════════
799
807
 
808
+ /** Measure one Git command without returning its potentially large or
809
+ * NUL-bearing output through the provider's text transport. */
810
+ private async measureConfinedCommandBytes(repo: string, command: string): Promise<number> {
811
+ const measured = await this.runInConfinedDirectory(repo, {
812
+ cmd: [
813
+ "set -o pipefail",
814
+ `{ ${command}; } 2>/dev/null | { bytes=$(wc -c | tr -d ' \\n'); printf '%s' "$bytes"; }`,
815
+ "producer_status=${PIPESTATUS[0]}",
816
+ "printf '\\t%s\\n' \"$producer_status\"",
817
+ ].join("; "),
818
+ maxOutputTokens: 1_024,
819
+ });
820
+ const match = measured.stdout.match(/^(\d+)\t(\d+)\n?$/);
821
+ if (
822
+ !match ||
823
+ (measured.exitCode !== null && measured.exitCode !== 0) ||
824
+ Number(match[2]) !== 0
825
+ ) {
826
+ throw new ChannelAUnavailableError(
827
+ "Workspace Git data is temporarily unavailable. Retry the operation.",
828
+ );
829
+ }
830
+ const size = Number(match[1]);
831
+ if (!Number.isSafeInteger(size) || size < 0) {
832
+ throw new ChannelAUnavailableError(
833
+ "Workspace Git data is temporarily unavailable. Retry the operation.",
834
+ );
835
+ }
836
+ return size;
837
+ }
838
+
839
+ /** Read an exact prefix of a command's output in chunks that remain below
840
+ * every supported execCommand retained-output ceiling. The producer is
841
+ * intentionally rerun per chunk; turn-end capture calls this only after the
842
+ * durable mutation authority has quiesced the workspace. */
843
+ private async readConfinedCommandPrefix(
844
+ repo: string,
845
+ command: string,
846
+ byteLength: number,
847
+ ): Promise<Buffer> {
848
+ if (byteLength === 0) return Buffer.alloc(0);
849
+ const chunks: Buffer[] = [];
850
+ for (let offset = 0; offset < byteLength; offset += GIT_COMMAND_CHUNK_BYTES) {
851
+ const expected = Math.min(GIT_COMMAND_CHUNK_BYTES, byteLength - offset);
852
+ const chunk = await this.runInConfinedDirectory(repo, {
853
+ cmd: [
854
+ `{ ${command}; } 2>/dev/null`,
855
+ `tail -c +${offset + 1}`,
856
+ `head -c ${expected}`,
857
+ "base64",
858
+ `tr -d '\\n'`,
859
+ ].join(" | "),
860
+ maxOutputTokens: Math.ceil((GIT_COMMAND_CHUNK_BYTES * 4) / 3) + 1_024,
861
+ });
862
+ if (chunk.exitCode !== null && chunk.exitCode !== 0) {
863
+ throw new ChannelAUnavailableError(
864
+ "Workspace Git data is temporarily unavailable. Retry the operation.",
865
+ );
866
+ }
867
+ const encoded = chunk.stdout.replace(/\s/g, "");
868
+ const bytes = Buffer.from(encoded, "base64");
869
+ if (bytes.byteLength !== expected || bytes.toString("base64") !== encoded) {
870
+ throw new ChannelAUnavailableError(
871
+ "Workspace Git data is temporarily unavailable. Retry the operation.",
872
+ );
873
+ }
874
+ chunks.push(bytes);
875
+ }
876
+ return Buffer.concat(chunks, byteLength);
877
+ }
878
+
879
+ private async readConfinedCommandBytes(
880
+ repo: string,
881
+ command: string,
882
+ maxBytes: number,
883
+ ): Promise<{ bytes: Buffer; sizeBytes: number; truncated: boolean }> {
884
+ const sizeBytes = await this.measureConfinedCommandBytes(repo, command);
885
+ if (sizeBytes > maxBytes) {
886
+ return { bytes: Buffer.alloc(0), sizeBytes, truncated: true };
887
+ }
888
+ return {
889
+ bytes: await this.readConfinedCommandPrefix(repo, command, sizeBytes),
890
+ sizeBytes,
891
+ truncated: false,
892
+ };
893
+ }
894
+
895
+ /** Read a regular untracked file without routing its body through one large
896
+ * execCommand response. Native provider reads are binary-safe; providers
897
+ * without that surface use the same bounded chunk protocol as Git patches. */
898
+ private async readUntrackedRegularFile(
899
+ repo: string,
900
+ target: string,
901
+ byteLength: number,
902
+ ): Promise<Buffer> {
903
+ if (byteLength === 0) return Buffer.alloc(0);
904
+ const path = repo ? `${repo}/${target}` : target;
905
+ assertSafeRelPath(path);
906
+ if (this.session.readFile) {
907
+ try {
908
+ const raw = await this.session.readFile({
909
+ path: this.joinRoot(path),
910
+ maxBytes: byteLength,
911
+ ...(this.runAs ? { runAs: this.runAs } : {}),
912
+ });
913
+ const bytes = typeof raw === "string" ? Buffer.from(raw, "utf8") : Buffer.from(raw);
914
+ if (bytes.byteLength !== byteLength) {
915
+ throw new ChannelAUnavailableError(
916
+ "Workspace Git data changed during capture. Retry the operation.",
917
+ );
918
+ }
919
+ return bytes;
920
+ } catch (error) {
921
+ if (error instanceof ChannelAUnavailableError) throw error;
922
+ if (isWorkspaceEscapeError(error)) {
923
+ throw new ChannelAValidationError(`path resolves outside workspace: ${path}`);
924
+ }
925
+ if (isDefinitePathNotFoundError(error)) {
926
+ throw new ChannelANotFoundError(`file not found: ${path}`);
927
+ }
928
+ if (!this.session.exec && !this.session.execCommand) {
929
+ throw new ChannelAUnavailableError(
930
+ "Workspace Git data is temporarily unavailable. Retry the operation.",
931
+ );
932
+ }
933
+ }
934
+ }
935
+ const fileArg = target.startsWith("./") ? target : `./${target}`;
936
+ return await this.readConfinedCommandPrefix(
937
+ repo,
938
+ `file=${shellQuote(fileArg)}; test ! -L "$file" && test -f "$file" || exit 66; cat -- "$file"`,
939
+ byteLength,
940
+ );
941
+ }
942
+
800
943
  async gitStatus(req: GitStatusRequest): Promise<GitStatusResponse> {
801
944
  const repo = assertSafeRelPathOrRoot(req.path);
802
945
  const inside = await this.runInConfinedDirectory(repo, {
@@ -814,10 +957,17 @@ export class SandboxChannelAService {
814
957
  revision: this.revision,
815
958
  };
816
959
  }
817
- const { stdout } = await this.runInConfinedDirectory(repo, {
818
- cmd: "git status --porcelain=v2 --branch -z",
819
- });
820
- return { ...parsePorcelainV2(stdout), revision: this.revision };
960
+ const status = await this.readConfinedCommandBytes(
961
+ repo,
962
+ "git status --porcelain=v2 --branch -z",
963
+ GIT_METADATA_MAX_BYTES,
964
+ );
965
+ if (status.truncated) {
966
+ throw new ChannelAUnavailableError(
967
+ "Workspace Git metadata exceeded the safe capture limit. Retry with a narrower path.",
968
+ );
969
+ }
970
+ return { ...parsePorcelainV2(status.bytes.toString("utf8")), revision: this.revision };
821
971
  }
822
972
 
823
973
  async gitDiff(req: GitDiffRequest): Promise<GitDiffResponse> {
@@ -826,16 +976,34 @@ export class SandboxChannelAService {
826
976
  // Selector precedence: refs > staged > worktree.
827
977
  let range = "";
828
978
  if (req.fromRef && req.toRef) range = `${shellQuote(req.fromRef)} ${shellQuote(req.toRef)}`;
829
- else if (req.fromRef) range = `${shellQuote(req.fromRef)}`;
830
- else if (req.staged) range = "--cached";
979
+ else if (req.fromRef) {
980
+ if (req.fromRef === "HEAD") {
981
+ const head = await this.runInConfinedDirectory(repo, {
982
+ cmd: "if git rev-parse --verify --quiet HEAD >/dev/null; then printf 'present'; else printf 'unborn'; fi",
983
+ });
984
+ // An unborn repository has no HEAD tree. `--cached` compares its index
985
+ // to Git's empty tree and preserves staged additions; every other
986
+ // invalid ref remains a real read failure in the bounded command path.
987
+ range = head.stdout.trim() === "present" ? shellQuote(req.fromRef) : "--cached";
988
+ } else {
989
+ range = shellQuote(req.fromRef);
990
+ }
991
+ } else if (req.staged) range = "--cached";
831
992
  const pathspec = req.pathspec.length ? ` -- ${req.pathspec.map(shellQuote).join(" ")}` : "";
832
993
 
833
994
  // Pass 1: numstat (stats + binary detection). -z gives NUL-separated fields;
834
995
  // a rename emits old\0new for that record's path fields.
835
- const numstat = await this.runInConfinedDirectory(repo, {
836
- cmd: `git -c core.quotePath=false diff --no-color -z --numstat ${range}${pathspec}`.trim(),
837
- });
838
- const stats = parseNumstatZ(numstat.stdout);
996
+ const numstat = await this.readConfinedCommandBytes(
997
+ repo,
998
+ `git -c core.quotePath=false diff --no-color -z --numstat ${range}${pathspec}`.trim(),
999
+ GIT_METADATA_MAX_BYTES,
1000
+ );
1001
+ if (numstat.truncated) {
1002
+ throw new ChannelAUnavailableError(
1003
+ "Workspace Git metadata exceeded the safe capture limit. Retry with a narrower path.",
1004
+ );
1005
+ }
1006
+ const stats = parseNumstatZ(numstat.bytes.toString("utf8"));
839
1007
 
840
1008
  const files: GitFileDiff[] = [];
841
1009
  for (const stat of stats) {
@@ -856,13 +1024,14 @@ export class SandboxChannelAService {
856
1024
  continue;
857
1025
  }
858
1026
  // Pass 2: the per-file unified patch -> hunks.
859
- const patch = await this.runInConfinedDirectory(repo, {
860
- cmd: `git -c core.quotePath=false diff --no-color -U${ctx} ${range} -- ${shellQuote(target)}`.trim(),
861
- });
862
- const oversized = Buffer.byteLength(patch.stdout, "utf8") > req.maxBytesPerFile;
863
- const parsed = oversized
1027
+ const patch = await this.readConfinedCommandBytes(
1028
+ repo,
1029
+ `git -c core.quotePath=false diff --no-color -U${ctx} ${range} -- ${shellQuote(target)}`.trim(),
1030
+ req.maxBytesPerFile,
1031
+ );
1032
+ const parsed = patch.truncated
864
1033
  ? { hunks: [] as GitDiffHunk[], status: "modified" as GitFileStatusCode }
865
- : parseUnifiedPatch(patch.stdout);
1034
+ : parseUnifiedPatch(patch.bytes.toString("utf8"));
866
1035
  files.push({
867
1036
  path: target,
868
1037
  oldPath: stat.oldPath,
@@ -872,7 +1041,7 @@ export class SandboxChannelAService {
872
1041
  additions: stat.additions,
873
1042
  deletions: stat.deletions,
874
1043
  hunks: parsed.hunks,
875
- truncated: oversized,
1044
+ truncated: patch.truncated,
876
1045
  });
877
1046
  }
878
1047
 
@@ -882,32 +1051,41 @@ export class SandboxChannelAService {
882
1051
  // Ask Git for the exact NUL-delimited set, then synthesize an added-file
883
1052
  // hunk from a bounded read. The explicit request flag keeps commit/staged
884
1053
  // consumers on native Git semantics.
885
- const untracked = await this.runInConfinedDirectory(repo, {
886
- cmd: `git -c core.quotePath=false ls-files --others --exclude-standard -z${pathspec}`,
887
- });
888
- for (const target of untracked.stdout.split(NUL).filter(Boolean)) {
1054
+ const untracked = await this.readConfinedCommandBytes(
1055
+ repo,
1056
+ `git -c core.quotePath=false ls-files --others --exclude-standard -z${pathspec}`,
1057
+ GIT_METADATA_MAX_BYTES,
1058
+ );
1059
+ if (untracked.truncated) {
1060
+ throw new ChannelAUnavailableError(
1061
+ "Workspace Git metadata exceeded the safe capture limit. Retry with a narrower path.",
1062
+ );
1063
+ }
1064
+ for (const target of untracked.bytes.toString("utf8").split(NUL).filter(Boolean)) {
889
1065
  const fileArg = target.startsWith("./") ? target : `./${target}`;
890
1066
  const read = await this.runInConfinedDirectory(repo, {
891
1067
  cmd: [
892
1068
  `file=${shellQuote(fileArg)}`,
893
- 'if [ -L "$file" ]; then printf "L\\n"; readlink -z -- "$file" | base64 | tr -d "\\n"; exit; fi',
1069
+ 'if [ -L "$file" ]; then printf "L\\t"; readlink -z -- "$file" | base64 | tr -d "\\n"; exit; fi',
894
1070
  'size=$(wc -c < "$file") || exit 66',
895
1071
  'line_count=$(wc -l < "$file") || exit 66',
896
1072
  'if [ "$size" -gt 0 ]; then last_byte=$(tail -c 1 "$file" | od -An -tu1 | tr -d " \\n"); if [ "$last_byte" != "10" ]; then line_count=$((line_count + 1)); fi; fi',
897
- 'printf "F\\t%s\\t%s\\n" "$size" "$line_count"',
898
- `head -c ${req.maxBytesPerFile + 1} "$file" | base64 | tr -d "\\n"`,
1073
+ 'printf "F\\t%s\\t%s" "$size" "$line_count"',
899
1074
  ].join("; "),
900
1075
  });
901
- if (read.exitCode !== null && read.exitCode !== 0) continue;
1076
+ if (read.exitCode !== null && read.exitCode !== 0) {
1077
+ throw new ChannelAUnavailableError(
1078
+ "Workspace Git data is temporarily unavailable. Retry the operation.",
1079
+ );
1080
+ }
902
1081
 
903
- const lineBreak = read.stdout.indexOf("\n");
904
- if (lineBreak < 0) continue;
905
- const header = read.stdout.slice(0, lineBreak);
906
- const encoded = read.stdout.slice(lineBreak + 1).replace(/\s/g, "");
907
- let sampled = Buffer.from(encoded, "base64");
1082
+ const [kind, first, second] = read.stdout.split("\t");
1083
+ let sampled: Buffer = Buffer.alloc(0);
908
1084
  let sizeBytes: number;
909
1085
  let lineCount: number;
910
- if (header === "L") {
1086
+ if (kind === "L") {
1087
+ const encoded = (first ?? "").replace(/\s/g, "");
1088
+ sampled = Buffer.from(encoded, "base64");
911
1089
  // GNU readlink -z preserves every byte (including trailing newlines)
912
1090
  // and adds one NUL framing byte. The diff shows the link destination
913
1091
  // itself, matching Git's symlink-blob semantics, never target content.
@@ -916,10 +1094,9 @@ export class SandboxChannelAService {
916
1094
  sizeBytes = sampled.length;
917
1095
  lineCount = addedLines(sampled).length;
918
1096
  } else {
919
- const [kind, sizeRaw, lineCountRaw] = header.split("\t");
920
1097
  if (kind !== "F") continue;
921
- const parsedSize = safeInt(sizeRaw);
922
- const parsedLineCount = safeInt(lineCountRaw);
1098
+ const parsedSize = safeInt(first);
1099
+ const parsedLineCount = safeInt(second);
923
1100
  if (
924
1101
  parsedSize === null ||
925
1102
  parsedSize < 0 ||
@@ -930,6 +1107,12 @@ export class SandboxChannelAService {
930
1107
  }
931
1108
  sizeBytes = parsedSize;
932
1109
  lineCount = parsedLineCount;
1110
+ const truncated = sizeBytes > req.maxBytesPerFile;
1111
+ const sampleSize = Math.min(sizeBytes, 8_192);
1112
+ sampled = await this.readUntrackedRegularFile(repo, target, sampleSize);
1113
+ if (!sniffBinary(sampled) && !truncated && sampleSize < sizeBytes) {
1114
+ sampled = await this.readUntrackedRegularFile(repo, target, sizeBytes);
1115
+ }
933
1116
  }
934
1117
  const truncated = sizeBytes > req.maxBytesPerFile || sampled.length > req.maxBytesPerFile;
935
1118
  const bytes = truncated ? sampled.subarray(0, req.maxBytesPerFile) : sampled;
@@ -536,14 +536,14 @@ function withDockerNetwork(client: SandboxClient, network: string | undefined):
536
536
  }
537
537
 
538
538
  async function connectDockerNetwork(network: string, containerId: string): Promise<void> {
539
- const result = Bun.spawnSync(["docker", "network", "connect", network, containerId], {
540
- stdout: "pipe",
541
- stderr: "pipe",
539
+ const { spawnSync } = await import("node:child_process");
540
+ const result = spawnSync("docker", ["network", "connect", network, containerId], {
541
+ encoding: "utf8",
542
542
  });
543
- if (result.exitCode === 0) {
543
+ if (result.status === 0) {
544
544
  return;
545
545
  }
546
- const stderr = new TextDecoder().decode(result.stderr);
546
+ const stderr = result.stderr ?? result.error?.message ?? "";
547
547
  if (stderr.includes("already exists")) {
548
548
  return;
549
549
  }