@openai/agents-core 0.8.5 → 0.9.1
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/dist/agentToolRunConfig.js +3 -0
- package/dist/agentToolRunConfig.js.map +1 -1
- package/dist/agentToolRunConfig.mjs +3 -0
- package/dist/agentToolRunConfig.mjs.map +1 -1
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +15 -1
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +13 -0
- package/dist/errors.mjs.map +1 -1
- package/dist/handoff.js +1 -1
- package/dist/handoff.js.map +1 -1
- package/dist/handoff.mjs +1 -1
- package/dist/handoff.mjs.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/items.d.ts +13 -0
- package/dist/items.js +15 -0
- package/dist/items.js.map +1 -1
- package/dist/items.mjs +15 -0
- package/dist/items.mjs.map +1 -1
- package/dist/memory/historyMutations.d.ts +6 -0
- package/dist/memory/historyMutations.js +32 -0
- package/dist/memory/historyMutations.js.map +1 -0
- package/dist/memory/historyMutations.mjs +29 -0
- package/dist/memory/historyMutations.mjs.map +1 -0
- package/dist/memory/memorySession.d.ts +3 -2
- package/dist/memory/memorySession.js +7 -0
- package/dist/memory/memorySession.js.map +1 -1
- package/dist/memory/memorySession.mjs +7 -0
- package/dist/memory/memorySession.mjs.map +1 -1
- package/dist/memory/session.d.ts +22 -0
- package/dist/memory/session.js +6 -0
- package/dist/memory/session.js.map +1 -1
- package/dist/memory/session.mjs +5 -0
- package/dist/memory/session.mjs.map +1 -1
- package/dist/metadata.js +2 -2
- package/dist/metadata.mjs +2 -2
- package/dist/model.d.ts +21 -0
- package/dist/run.d.ts +7 -1
- package/dist/run.js +152 -57
- package/dist/run.js.map +1 -1
- package/dist/run.mjs +153 -58
- package/dist/run.mjs.map +1 -1
- package/dist/runState.d.ts +110 -3
- package/dist/runState.js +414 -53
- package/dist/runState.js.map +1 -1
- package/dist/runState.mjs +412 -53
- package/dist/runState.mjs.map +1 -1
- package/dist/runner/errorHandlers.d.ts +13 -4
- package/dist/runner/errorHandlers.js +22 -4
- package/dist/runner/errorHandlers.js.map +1 -1
- package/dist/runner/errorHandlers.mjs +21 -4
- package/dist/runner/errorHandlers.mjs.map +1 -1
- package/dist/runner/items.js +11 -1
- package/dist/runner/items.js.map +1 -1
- package/dist/runner/items.mjs +11 -1
- package/dist/runner/items.mjs.map +1 -1
- package/dist/runner/modelPreparation.d.ts +1 -1
- package/dist/runner/modelPreparation.js +7 -7
- package/dist/runner/modelPreparation.js.map +1 -1
- package/dist/runner/modelPreparation.mjs +7 -7
- package/dist/runner/modelPreparation.mjs.map +1 -1
- package/dist/runner/runLoop.d.ts +2 -1
- package/dist/runner/runLoop.js +2 -2
- package/dist/runner/runLoop.js.map +1 -1
- package/dist/runner/runLoop.mjs +2 -2
- package/dist/runner/runLoop.mjs.map +1 -1
- package/dist/runner/sandbox.d.ts +33 -0
- package/dist/runner/sandbox.js +92 -0
- package/dist/runner/sandbox.js.map +1 -0
- package/dist/runner/sandbox.mjs +83 -0
- package/dist/runner/sandbox.mjs.map +1 -0
- package/dist/runner/sessionPersistence.js +33 -12
- package/dist/runner/sessionPersistence.js.map +1 -1
- package/dist/runner/sessionPersistence.mjs +33 -12
- package/dist/runner/sessionPersistence.mjs.map +1 -1
- package/dist/runner/streamReconciliation.d.ts +14 -0
- package/dist/runner/streamReconciliation.js +80 -0
- package/dist/runner/streamReconciliation.js.map +1 -0
- package/dist/runner/streamReconciliation.mjs +72 -0
- package/dist/runner/streamReconciliation.mjs.map +1 -0
- package/dist/runner/toolExecution.js +25 -13
- package/dist/runner/toolExecution.js.map +1 -1
- package/dist/runner/toolExecution.mjs +25 -13
- package/dist/runner/toolExecution.mjs.map +1 -1
- package/dist/runner/toolUseTracker.d.ts +3 -1
- package/dist/runner/toolUseTracker.js +2 -2
- package/dist/runner/toolUseTracker.js.map +1 -1
- package/dist/runner/toolUseTracker.mjs +2 -2
- package/dist/runner/toolUseTracker.mjs.map +1 -1
- package/dist/runner/tracing.js +1 -0
- package/dist/runner/tracing.js.map +1 -1
- package/dist/runner/tracing.mjs +1 -0
- package/dist/runner/tracing.mjs.map +1 -1
- package/dist/runner/turnPreparation.d.ts +2 -4
- package/dist/runner/turnPreparation.js +7 -3
- package/dist/runner/turnPreparation.js.map +1 -1
- package/dist/runner/turnPreparation.mjs +7 -3
- package/dist/runner/turnPreparation.mjs.map +1 -1
- package/dist/runner/turnResolution.js +158 -31
- package/dist/runner/turnResolution.js.map +1 -1
- package/dist/runner/turnResolution.mjs +160 -33
- package/dist/runner/turnResolution.mjs.map +1 -1
- package/dist/runner/types.d.ts +8 -8
- package/dist/sandbox/agent.d.ts +24 -0
- package/dist/sandbox/agent.js +68 -0
- package/dist/sandbox/agent.js.map +1 -0
- package/dist/sandbox/agent.mjs +64 -0
- package/dist/sandbox/agent.mjs.map +1 -0
- package/dist/sandbox/brand.d.ts +1 -0
- package/dist/sandbox/brand.js +5 -0
- package/dist/sandbox/brand.js.map +1 -0
- package/dist/sandbox/brand.mjs +2 -0
- package/dist/sandbox/brand.mjs.map +1 -0
- package/dist/sandbox/capabilities/base.d.ts +25 -0
- package/dist/sandbox/capabilities/base.js +89 -0
- package/dist/sandbox/capabilities/base.js.map +1 -0
- package/dist/sandbox/capabilities/base.mjs +84 -0
- package/dist/sandbox/capabilities/base.mjs.map +1 -0
- package/dist/sandbox/capabilities/compaction.d.ts +33 -0
- package/dist/sandbox/capabilities/compaction.js +172 -0
- package/dist/sandbox/capabilities/compaction.js.map +1 -0
- package/dist/sandbox/capabilities/compaction.mjs +164 -0
- package/dist/sandbox/capabilities/compaction.mjs.map +1 -0
- package/dist/sandbox/capabilities/filesystem.d.ts +14 -0
- package/dist/sandbox/capabilities/filesystem.js +447 -0
- package/dist/sandbox/capabilities/filesystem.js.map +1 -0
- package/dist/sandbox/capabilities/filesystem.mjs +444 -0
- package/dist/sandbox/capabilities/filesystem.mjs.map +1 -0
- package/dist/sandbox/capabilities/index.d.ts +19 -0
- package/dist/sandbox/capabilities/index.js +31 -0
- package/dist/sandbox/capabilities/index.js.map +1 -0
- package/dist/sandbox/capabilities/index.mjs +17 -0
- package/dist/sandbox/capabilities/index.mjs.map +1 -0
- package/dist/sandbox/capabilities/memory.d.ts +52 -0
- package/dist/sandbox/capabilities/memory.js +290 -0
- package/dist/sandbox/capabilities/memory.js.map +1 -0
- package/dist/sandbox/capabilities/memory.mjs +286 -0
- package/dist/sandbox/capabilities/memory.mjs.map +1 -0
- package/dist/sandbox/capabilities/shell.d.ts +15 -0
- package/dist/sandbox/capabilities/shell.js +130 -0
- package/dist/sandbox/capabilities/shell.js.map +1 -0
- package/dist/sandbox/capabilities/shell.mjs +127 -0
- package/dist/sandbox/capabilities/shell.mjs.map +1 -0
- package/dist/sandbox/capabilities/skills.d.ts +47 -0
- package/dist/sandbox/capabilities/skills.js +453 -0
- package/dist/sandbox/capabilities/skills.js.map +1 -0
- package/dist/sandbox/capabilities/skills.mjs +449 -0
- package/dist/sandbox/capabilities/skills.mjs.map +1 -0
- package/dist/sandbox/capabilities/transport.d.ts +3 -0
- package/dist/sandbox/capabilities/transport.js +33 -0
- package/dist/sandbox/capabilities/transport.js.map +1 -0
- package/dist/sandbox/capabilities/transport.mjs +28 -0
- package/dist/sandbox/capabilities/transport.mjs.map +1 -0
- package/dist/sandbox/client.d.ts +53 -0
- package/dist/sandbox/client.js +34 -0
- package/dist/sandbox/client.js.map +1 -0
- package/dist/sandbox/client.mjs +31 -0
- package/dist/sandbox/client.mjs.map +1 -0
- package/dist/sandbox/entries/factories.d.ts +17 -0
- package/dist/sandbox/entries/factories.js +112 -0
- package/dist/sandbox/entries/factories.js.map +1 -0
- package/dist/sandbox/entries/factories.mjs +94 -0
- package/dist/sandbox/entries/factories.mjs.map +1 -0
- package/dist/sandbox/entries/guards.d.ts +5 -0
- package/dist/sandbox/entries/guards.js +19 -0
- package/dist/sandbox/entries/guards.js.map +1 -0
- package/dist/sandbox/entries/guards.mjs +13 -0
- package/dist/sandbox/entries/guards.mjs.map +1 -0
- package/dist/sandbox/entries/index.d.ts +3 -0
- package/dist/sandbox/entries/index.js +26 -0
- package/dist/sandbox/entries/index.js.map +1 -0
- package/dist/sandbox/entries/index.mjs +3 -0
- package/dist/sandbox/entries/index.mjs.map +1 -0
- package/dist/sandbox/entries/types.d.ts +177 -0
- package/dist/sandbox/entries/types.js +3 -0
- package/dist/sandbox/entries/types.js.map +1 -0
- package/dist/sandbox/entries/types.mjs +2 -0
- package/dist/sandbox/entries/types.mjs.map +1 -0
- package/dist/sandbox/errors.d.ts +151 -0
- package/dist/sandbox/errors.js +303 -0
- package/dist/sandbox/errors.js.map +1 -0
- package/dist/sandbox/errors.mjs +251 -0
- package/dist/sandbox/errors.mjs.map +1 -0
- package/dist/sandbox/events.d.ts +51 -0
- package/dist/sandbox/events.js +104 -0
- package/dist/sandbox/events.js.map +1 -0
- package/dist/sandbox/events.mjs +95 -0
- package/dist/sandbox/events.mjs.map +1 -0
- package/dist/sandbox/index.d.ts +14 -0
- package/dist/sandbox/index.js +31 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/index.mjs +15 -0
- package/dist/sandbox/index.mjs.map +1 -0
- package/dist/sandbox/internal.d.ts +7 -0
- package/dist/sandbox/internal.js +46 -0
- package/dist/sandbox/internal.js.map +1 -0
- package/dist/sandbox/internal.mjs +8 -0
- package/dist/sandbox/internal.mjs.map +1 -0
- package/dist/sandbox/local.d.ts +3 -0
- package/dist/sandbox/local.js +20 -0
- package/dist/sandbox/local.js.map +1 -0
- package/dist/sandbox/local.mjs +4 -0
- package/dist/sandbox/local.mjs.map +1 -0
- package/dist/sandbox/localSkills.d.ts +13 -0
- package/dist/sandbox/localSkills.js +62 -0
- package/dist/sandbox/localSkills.js.map +1 -0
- package/dist/sandbox/localSkills.mjs +59 -0
- package/dist/sandbox/localSkills.mjs.map +1 -0
- package/dist/sandbox/manifest.d.ts +86 -0
- package/dist/sandbox/manifest.js +553 -0
- package/dist/sandbox/manifest.js.map +1 -0
- package/dist/sandbox/manifest.mjs +545 -0
- package/dist/sandbox/manifest.mjs.map +1 -0
- package/dist/sandbox/memory/generation.d.ts +56 -0
- package/dist/sandbox/memory/generation.js +426 -0
- package/dist/sandbox/memory/generation.js.map +1 -0
- package/dist/sandbox/memory/generation.mjs +385 -0
- package/dist/sandbox/memory/generation.mjs.map +1 -0
- package/dist/sandbox/memory/prompts.d.ts +16 -0
- package/dist/sandbox/memory/prompts.js +1685 -0
- package/dist/sandbox/memory/prompts.js.map +1 -0
- package/dist/sandbox/memory/prompts.mjs +1679 -0
- package/dist/sandbox/memory/prompts.mjs.map +1 -0
- package/dist/sandbox/memory/rollouts.d.ts +33 -0
- package/dist/sandbox/memory/rollouts.js +228 -0
- package/dist/sandbox/memory/rollouts.js.map +1 -0
- package/dist/sandbox/memory/rollouts.mjs +221 -0
- package/dist/sandbox/memory/rollouts.mjs.map +1 -0
- package/dist/sandbox/memory/storage.d.ts +70 -0
- package/dist/sandbox/memory/storage.js +543 -0
- package/dist/sandbox/memory/storage.js.map +1 -0
- package/dist/sandbox/memory/storage.mjs +537 -0
- package/dist/sandbox/memory/storage.mjs.map +1 -0
- package/dist/sandbox/pathGrants.d.ts +11 -0
- package/dist/sandbox/pathGrants.js +28 -0
- package/dist/sandbox/pathGrants.js.map +1 -0
- package/dist/sandbox/pathGrants.mjs +25 -0
- package/dist/sandbox/pathGrants.mjs.map +1 -0
- package/dist/sandbox/permissions.d.ts +29 -0
- package/dist/sandbox/permissions.js +140 -0
- package/dist/sandbox/permissions.js.map +1 -0
- package/dist/sandbox/permissions.mjs +134 -0
- package/dist/sandbox/permissions.mjs.map +1 -0
- package/dist/sandbox/runtime/agentKeys.d.ts +7 -0
- package/dist/sandbox/runtime/agentKeys.js +76 -0
- package/dist/sandbox/runtime/agentKeys.js.map +1 -0
- package/dist/sandbox/runtime/agentKeys.mjs +69 -0
- package/dist/sandbox/runtime/agentKeys.mjs.map +1 -0
- package/dist/sandbox/runtime/agentPreparation.d.ts +20 -0
- package/dist/sandbox/runtime/agentPreparation.js +178 -0
- package/dist/sandbox/runtime/agentPreparation.js.map +1 -0
- package/dist/sandbox/runtime/agentPreparation.mjs +172 -0
- package/dist/sandbox/runtime/agentPreparation.mjs.map +1 -0
- package/dist/sandbox/runtime/index.d.ts +5 -0
- package/dist/sandbox/runtime/index.js +22 -0
- package/dist/sandbox/runtime/index.js.map +1 -0
- package/dist/sandbox/runtime/index.mjs +6 -0
- package/dist/sandbox/runtime/index.mjs.map +1 -0
- package/dist/sandbox/runtime/livePreservedSessions.d.ts +25 -0
- package/dist/sandbox/runtime/livePreservedSessions.js +58 -0
- package/dist/sandbox/runtime/livePreservedSessions.js.map +1 -0
- package/dist/sandbox/runtime/livePreservedSessions.mjs +51 -0
- package/dist/sandbox/runtime/livePreservedSessions.mjs.map +1 -0
- package/dist/sandbox/runtime/manager.d.ts +68 -0
- package/dist/sandbox/runtime/manager.js +704 -0
- package/dist/sandbox/runtime/manager.js.map +1 -0
- package/dist/sandbox/runtime/manager.mjs +697 -0
- package/dist/sandbox/runtime/manager.mjs.map +1 -0
- package/dist/sandbox/runtime/prompts.d.ts +6 -0
- package/dist/sandbox/runtime/prompts.js +108 -0
- package/dist/sandbox/runtime/prompts.js.map +1 -0
- package/dist/sandbox/runtime/prompts.mjs +101 -0
- package/dist/sandbox/runtime/prompts.mjs.map +1 -0
- package/dist/sandbox/runtime/providedSessionManifest.d.ts +3 -0
- package/dist/sandbox/runtime/providedSessionManifest.js +175 -0
- package/dist/sandbox/runtime/providedSessionManifest.js.map +1 -0
- package/dist/sandbox/runtime/providedSessionManifest.mjs +172 -0
- package/dist/sandbox/runtime/providedSessionManifest.mjs.map +1 -0
- package/dist/sandbox/runtime/runAsManifest.d.ts +4 -0
- package/dist/sandbox/runtime/runAsManifest.js +40 -0
- package/dist/sandbox/runtime/runAsManifest.js.map +1 -0
- package/dist/sandbox/runtime/runAsManifest.mjs +36 -0
- package/dist/sandbox/runtime/runAsManifest.mjs.map +1 -0
- package/dist/sandbox/runtime/sessionLifecycle.d.ts +6 -0
- package/dist/sandbox/runtime/sessionLifecycle.js +222 -0
- package/dist/sandbox/runtime/sessionLifecycle.js.map +1 -0
- package/dist/sandbox/runtime/sessionLifecycle.mjs +215 -0
- package/dist/sandbox/runtime/sessionLifecycle.mjs.map +1 -0
- package/dist/sandbox/runtime/sessionSerialization.d.ts +12 -0
- package/dist/sandbox/runtime/sessionSerialization.js +74 -0
- package/dist/sandbox/runtime/sessionSerialization.js.map +1 -0
- package/dist/sandbox/runtime/sessionSerialization.mjs +71 -0
- package/dist/sandbox/runtime/sessionSerialization.mjs.map +1 -0
- package/dist/sandbox/runtime/sessionState.d.ts +26 -0
- package/dist/sandbox/runtime/sessionState.js +113 -0
- package/dist/sandbox/runtime/sessionState.js.map +1 -0
- package/dist/sandbox/runtime/sessionState.mjs +104 -0
- package/dist/sandbox/runtime/sessionState.mjs.map +1 -0
- package/dist/sandbox/runtime/spans.d.ts +1 -0
- package/dist/sandbox/runtime/spans.js +51 -0
- package/dist/sandbox/runtime/spans.js.map +1 -0
- package/dist/sandbox/runtime/spans.mjs +48 -0
- package/dist/sandbox/runtime/spans.mjs.map +1 -0
- package/dist/sandbox/runtime/toolRehydration.d.ts +34 -0
- package/dist/sandbox/runtime/toolRehydration.js +207 -0
- package/dist/sandbox/runtime/toolRehydration.js.map +1 -0
- package/dist/sandbox/runtime/toolRehydration.mjs +200 -0
- package/dist/sandbox/runtime/toolRehydration.mjs.map +1 -0
- package/dist/sandbox/sandboxes/docker.d.ts +75 -0
- package/dist/sandbox/sandboxes/docker.js +2015 -0
- package/dist/sandbox/sandboxes/docker.js.map +1 -0
- package/dist/sandbox/sandboxes/docker.mjs +2010 -0
- package/dist/sandbox/sandboxes/docker.mjs.map +1 -0
- package/dist/sandbox/sandboxes/index.d.ts +3 -0
- package/dist/sandbox/sandboxes/index.js +20 -0
- package/dist/sandbox/sandboxes/index.js.map +1 -0
- package/dist/sandbox/sandboxes/index.mjs +4 -0
- package/dist/sandbox/sandboxes/index.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/localSnapshotPaths.d.ts +1 -0
- package/dist/sandbox/sandboxes/shared/localSnapshotPaths.js +22 -0
- package/dist/sandbox/sandboxes/shared/localSnapshotPaths.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/localSnapshotPaths.mjs +19 -0
- package/dist/sandbox/sandboxes/shared/localSnapshotPaths.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/localSnapshots.d.ts +34 -0
- package/dist/sandbox/sandboxes/shared/localSnapshots.js +525 -0
- package/dist/sandbox/sandboxes/shared/localSnapshots.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/localSnapshots.mjs +508 -0
- package/dist/sandbox/sandboxes/shared/localSnapshots.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/localWorkspace.d.ts +27 -0
- package/dist/sandbox/sandboxes/shared/localWorkspace.js +693 -0
- package/dist/sandbox/sandboxes/shared/localWorkspace.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/localWorkspace.mjs +684 -0
- package/dist/sandbox/sandboxes/shared/localWorkspace.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/manifestPersistence.d.ts +15 -0
- package/dist/sandbox/sandboxes/shared/manifestPersistence.js +191 -0
- package/dist/sandbox/sandboxes/shared/manifestPersistence.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/manifestPersistence.mjs +182 -0
- package/dist/sandbox/sandboxes/shared/manifestPersistence.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/pty.d.ts +9 -0
- package/dist/sandbox/sandboxes/shared/pty.js +151 -0
- package/dist/sandbox/sandboxes/shared/pty.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/pty.mjs +148 -0
- package/dist/sandbox/sandboxes/shared/pty.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/runProcess.d.ts +16 -0
- package/dist/sandbox/sandboxes/shared/runProcess.js +90 -0
- package/dist/sandbox/sandboxes/shared/runProcess.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/runProcess.mjs +86 -0
- package/dist/sandbox/sandboxes/shared/runProcess.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/sessionStateValues.d.ts +18 -0
- package/dist/sandbox/sandboxes/shared/sessionStateValues.js +40 -0
- package/dist/sandbox/sandboxes/shared/sessionStateValues.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/sessionStateValues.mjs +35 -0
- package/dist/sandbox/sandboxes/shared/sessionStateValues.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/shellCommand.d.ts +17 -0
- package/dist/sandbox/sandboxes/shared/shellCommand.js +38 -0
- package/dist/sandbox/sandboxes/shared/shellCommand.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/shellCommand.mjs +34 -0
- package/dist/sandbox/sandboxes/shared/shellCommand.mjs.map +1 -0
- package/dist/sandbox/sandboxes/types.d.ts +11 -0
- package/dist/sandbox/sandboxes/types.js +3 -0
- package/dist/sandbox/sandboxes/types.js.map +1 -0
- package/dist/sandbox/sandboxes/types.mjs +2 -0
- package/dist/sandbox/sandboxes/types.mjs.map +1 -0
- package/dist/sandbox/sandboxes/unixLocal.d.ts +95 -0
- package/dist/sandbox/sandboxes/unixLocal.js +863 -0
- package/dist/sandbox/sandboxes/unixLocal.js.map +1 -0
- package/dist/sandbox/sandboxes/unixLocal.mjs +858 -0
- package/dist/sandbox/sandboxes/unixLocal.mjs.map +1 -0
- package/dist/sandbox/session.d.ts +123 -0
- package/dist/sandbox/session.js +58 -0
- package/dist/sandbox/session.js.map +1 -0
- package/dist/sandbox/session.mjs +50 -0
- package/dist/sandbox/session.mjs.map +1 -0
- package/dist/sandbox/shared/compare.d.ts +2 -0
- package/dist/sandbox/shared/compare.js +13 -0
- package/dist/sandbox/shared/compare.js.map +1 -0
- package/dist/sandbox/shared/compare.mjs +9 -0
- package/dist/sandbox/shared/compare.mjs.map +1 -0
- package/dist/sandbox/shared/environment.d.ts +14 -0
- package/dist/sandbox/shared/environment.js +69 -0
- package/dist/sandbox/shared/environment.js.map +1 -0
- package/dist/sandbox/shared/environment.mjs +59 -0
- package/dist/sandbox/shared/environment.mjs.map +1 -0
- package/dist/sandbox/shared/hostPath.d.ts +4 -0
- package/dist/sandbox/shared/hostPath.js +22 -0
- package/dist/sandbox/shared/hostPath.js.map +1 -0
- package/dist/sandbox/shared/hostPath.mjs +16 -0
- package/dist/sandbox/shared/hostPath.mjs.map +1 -0
- package/dist/sandbox/shared/manifestCollections.d.ts +12 -0
- package/dist/sandbox/shared/manifestCollections.js +40 -0
- package/dist/sandbox/shared/manifestCollections.js.map +1 -0
- package/dist/sandbox/shared/manifestCollections.mjs +34 -0
- package/dist/sandbox/shared/manifestCollections.mjs.map +1 -0
- package/dist/sandbox/shared/media.d.ts +6 -0
- package/dist/sandbox/shared/media.js +126 -0
- package/dist/sandbox/shared/media.js.map +1 -0
- package/dist/sandbox/shared/media.mjs +119 -0
- package/dist/sandbox/shared/media.mjs.map +1 -0
- package/dist/sandbox/shared/output.d.ts +12 -0
- package/dist/sandbox/shared/output.js +108 -0
- package/dist/sandbox/shared/output.js.map +1 -0
- package/dist/sandbox/shared/output.mjs +103 -0
- package/dist/sandbox/shared/output.mjs.map +1 -0
- package/dist/sandbox/shared/posixPath.d.ts +7 -0
- package/dist/sandbox/shared/posixPath.js +90 -0
- package/dist/sandbox/shared/posixPath.js.map +1 -0
- package/dist/sandbox/shared/posixPath.mjs +81 -0
- package/dist/sandbox/shared/posixPath.mjs.map +1 -0
- package/dist/sandbox/shared/remoteMountCommandAllowlist.d.ts +3 -0
- package/dist/sandbox/shared/remoteMountCommandAllowlist.js +33 -0
- package/dist/sandbox/shared/remoteMountCommandAllowlist.js.map +1 -0
- package/dist/sandbox/shared/remoteMountCommandAllowlist.mjs +28 -0
- package/dist/sandbox/shared/remoteMountCommandAllowlist.mjs.map +1 -0
- package/dist/sandbox/shared/shell.d.ts +1 -0
- package/dist/sandbox/shared/shell.js +7 -0
- package/dist/sandbox/shared/shell.js.map +1 -0
- package/dist/sandbox/shared/shell.mjs +4 -0
- package/dist/sandbox/shared/shell.mjs.map +1 -0
- package/dist/sandbox/shared/stableJson.d.ts +12 -0
- package/dist/sandbox/shared/stableJson.js +40 -0
- package/dist/sandbox/shared/stableJson.js.map +1 -0
- package/dist/sandbox/shared/stableJson.mjs +35 -0
- package/dist/sandbox/shared/stableJson.mjs.map +1 -0
- package/dist/sandbox/shared/typeGuards.d.ts +6 -0
- package/dist/sandbox/shared/typeGuards.js +34 -0
- package/dist/sandbox/shared/typeGuards.js.map +1 -0
- package/dist/sandbox/shared/typeGuards.mjs +26 -0
- package/dist/sandbox/shared/typeGuards.mjs.map +1 -0
- package/dist/sandbox/snapshot.d.ts +60 -0
- package/dist/sandbox/snapshot.js +45 -0
- package/dist/sandbox/snapshot.js.map +1 -0
- package/dist/sandbox/snapshot.mjs +39 -0
- package/dist/sandbox/snapshot.mjs.map +1 -0
- package/dist/sandbox/users.d.ts +11 -0
- package/dist/sandbox/users.js +31 -0
- package/dist/sandbox/users.js.map +1 -0
- package/dist/sandbox/users.mjs +26 -0
- package/dist/sandbox/users.mjs.map +1 -0
- package/dist/sandbox/workspacePaths.d.ts +20 -0
- package/dist/sandbox/workspacePaths.js +73 -0
- package/dist/sandbox/workspacePaths.js.map +1 -0
- package/dist/sandbox/workspacePaths.mjs +69 -0
- package/dist/sandbox/workspacePaths.mjs.map +1 -0
- package/dist/tool.js +1 -1
- package/dist/tool.js.map +1 -1
- package/dist/tool.mjs +1 -1
- package/dist/tool.mjs.map +1 -1
- package/dist/types/protocol.d.ts +8 -0
- package/dist/types/protocol.js +1 -0
- package/dist/types/protocol.js.map +1 -1
- package/dist/types/protocol.mjs +1 -0
- package/dist/types/protocol.mjs.map +1 -1
- package/dist/utils/messages.d.ts +6 -0
- package/dist/utils/messages.js +21 -0
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/messages.mjs +20 -0
- package/dist/utils/messages.mjs.map +1 -1
- package/dist/utils/strictToolSchema.d.ts +4 -0
- package/dist/utils/strictToolSchema.js +358 -0
- package/dist/utils/strictToolSchema.js.map +1 -0
- package/dist/utils/strictToolSchema.mjs +353 -0
- package/dist/utils/strictToolSchema.mjs.map +1 -0
- package/dist/utils/tools.d.ts +3 -1
- package/dist/utils/tools.js +18 -7
- package/dist/utils/tools.js.map +1 -1
- package/dist/utils/tools.mjs +18 -7
- package/dist/utils/tools.mjs.map +1 -1
- package/dist/utils/zodJsonSchemaCompat.js +18 -16
- package/dist/utils/zodJsonSchemaCompat.js.map +1 -1
- package/dist/utils/zodJsonSchemaCompat.mjs +18 -16
- package/dist/utils/zodJsonSchemaCompat.mjs.map +1 -1
- package/package.json +25 -1
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.materializeLocalWorkspaceManifest = materializeLocalWorkspaceManifest;
|
|
4
|
+
exports.assertLocalWorkspaceManifestMetadataSupported = assertLocalWorkspaceManifestMetadataSupported;
|
|
5
|
+
exports.materializeLocalWorkspaceManifestEntry = materializeLocalWorkspaceManifestEntry;
|
|
6
|
+
exports.materializeLocalWorkspaceManifestMounts = materializeLocalWorkspaceManifestMounts;
|
|
7
|
+
exports.applyOwnershipRecursive = applyOwnershipRecursive;
|
|
8
|
+
exports.pathExists = pathExists;
|
|
9
|
+
exports.joinSandboxLogicalPath = joinSandboxLogicalPath;
|
|
10
|
+
const errors_1 = require("../../../errors.js");
|
|
11
|
+
const errors_2 = require("../../errors.js");
|
|
12
|
+
const entries_1 = require("../../entries/index.js");
|
|
13
|
+
const manifest_1 = require("../../manifest.js");
|
|
14
|
+
const permissions_1 = require("../../permissions.js");
|
|
15
|
+
const workspacePaths_1 = require("../../workspacePaths.js");
|
|
16
|
+
const runProcess_1 = require("./runProcess.js");
|
|
17
|
+
const promises_1 = require("node:fs/promises");
|
|
18
|
+
const node_fs_1 = require("node:fs");
|
|
19
|
+
const node_path_1 = require("node:path");
|
|
20
|
+
const node_os_1 = require("node:os");
|
|
21
|
+
const hostPath_1 = require("../../shared/hostPath.js");
|
|
22
|
+
const GIT_VERSION_TIMEOUT_MS = 10_000;
|
|
23
|
+
const GIT_CLONE_TIMEOUT_MS = 5 * 60_000;
|
|
24
|
+
const COMMIT_REF_PATTERN = /^[0-9a-fA-F]{7,40}$/;
|
|
25
|
+
const MATERIALIZATION_FILE_WRITE_FLAGS = node_fs_1.constants.O_WRONLY |
|
|
26
|
+
node_fs_1.constants.O_CREAT |
|
|
27
|
+
node_fs_1.constants.O_TRUNC |
|
|
28
|
+
node_fs_1.constants.O_NOFOLLOW;
|
|
29
|
+
const LOCAL_SOURCE_FILE_READ_FLAGS = node_fs_1.constants.O_RDONLY | node_fs_1.constants.O_NOFOLLOW;
|
|
30
|
+
const LOCAL_SOURCE_DIRECTORY_READ_FLAGS = node_fs_1.constants.O_RDONLY | node_fs_1.constants.O_NOFOLLOW | node_fs_1.constants.O_DIRECTORY;
|
|
31
|
+
async function materializeLocalWorkspaceManifest(manifest, workspaceRootPath, options = {}) {
|
|
32
|
+
assertLocalWorkspaceManifestMetadataSupported('Local sandbox materialization', manifest, {
|
|
33
|
+
supportsMount: options.supportsMount,
|
|
34
|
+
allowLocalBindMounts: options.allowLocalBindMounts,
|
|
35
|
+
allowIdentityMetadata: options.allowIdentityMetadata,
|
|
36
|
+
});
|
|
37
|
+
await (0, promises_1.mkdir)(workspaceRootPath, { recursive: true });
|
|
38
|
+
await materializeEntries(workspaceRootPath, manifest.entries, '', {
|
|
39
|
+
...options,
|
|
40
|
+
manifestRoot: manifest.root,
|
|
41
|
+
skipMountEntries: true,
|
|
42
|
+
});
|
|
43
|
+
await materializeLocalWorkspaceManifestMounts(manifest, workspaceRootPath, options);
|
|
44
|
+
}
|
|
45
|
+
function assertLocalWorkspaceManifestMetadataSupported(providerName, manifest, options = {}) {
|
|
46
|
+
if (!options.allowIdentityMetadata && manifest.users.length > 0) {
|
|
47
|
+
throw new errors_2.SandboxUnsupportedFeatureError(`${providerName} does not support manifest users yet.`);
|
|
48
|
+
}
|
|
49
|
+
if (!options.allowIdentityMetadata && manifest.groups.length > 0) {
|
|
50
|
+
throw new errors_2.SandboxUnsupportedFeatureError(`${providerName} does not support manifest groups yet.`);
|
|
51
|
+
}
|
|
52
|
+
for (const [logicalPath, entry] of Object.entries(manifest.entries)) {
|
|
53
|
+
assertLocalWorkspaceEntryMetadataSupported(providerName, logicalPath, entry, options);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function materializeLocalWorkspaceManifestEntry(workspaceRootPath, logicalPath, entry, options = {}) {
|
|
57
|
+
assertLocalWorkspaceEntryMetadataSupported('Local sandbox materialization', logicalPath, entry, {
|
|
58
|
+
supportsMount: options.supportsMount,
|
|
59
|
+
allowLocalBindMounts: options.allowLocalBindMounts,
|
|
60
|
+
allowIdentityMetadata: options.allowIdentityMetadata,
|
|
61
|
+
});
|
|
62
|
+
if ((0, entries_1.isMount)(entry)) {
|
|
63
|
+
if (options.materializeMount) {
|
|
64
|
+
await options.materializeMount({ logicalPath, entry });
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
await materializeLocalBindMountEntry(workspaceRootPath, logicalPath, entry, options);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const destination = logicalPath
|
|
71
|
+
? (0, node_path_1.resolve)(workspaceRootPath, logicalPath)
|
|
72
|
+
: workspaceRootPath;
|
|
73
|
+
switch (entry.type) {
|
|
74
|
+
case 'dir':
|
|
75
|
+
await materializeDirEntry(workspaceRootPath, destination, entry, logicalPath, options);
|
|
76
|
+
break;
|
|
77
|
+
case 'file':
|
|
78
|
+
await materializeFileEntry(workspaceRootPath, destination, entry, logicalPath);
|
|
79
|
+
break;
|
|
80
|
+
case 'local_file':
|
|
81
|
+
await materializeLocalFileEntry(workspaceRootPath, destination, entry, logicalPath);
|
|
82
|
+
break;
|
|
83
|
+
case 'local_dir':
|
|
84
|
+
await materializeLocalDirEntry(workspaceRootPath, destination, entry, logicalPath, options);
|
|
85
|
+
break;
|
|
86
|
+
case 'git_repo':
|
|
87
|
+
await materializeGitRepoEntry(workspaceRootPath, destination, entry, logicalPath);
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
throw new errors_1.UserError(`Unsupported sandbox entry type: ${entry.type}`);
|
|
91
|
+
}
|
|
92
|
+
await applyEntryPermissions(workspaceRootPath, destination, entry, logicalPath);
|
|
93
|
+
}
|
|
94
|
+
async function materializeLocalWorkspaceManifestMounts(manifest, workspaceRootPath, options = {}) {
|
|
95
|
+
assertLocalWorkspaceManifestMetadataSupported('Local sandbox materialization', manifest, {
|
|
96
|
+
supportsMount: options.supportsMount,
|
|
97
|
+
allowLocalBindMounts: options.allowLocalBindMounts,
|
|
98
|
+
allowIdentityMetadata: options.allowIdentityMetadata,
|
|
99
|
+
});
|
|
100
|
+
for (const { logicalPath, entry, } of manifest.mountTargetsForMaterialization()) {
|
|
101
|
+
await materializeLocalWorkspaceManifestEntry(workspaceRootPath, logicalPath, entry, {
|
|
102
|
+
...options,
|
|
103
|
+
manifestRoot: manifest.root,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function applyOwnershipRecursive(targetPath, uid, gid) {
|
|
108
|
+
const info = await (0, promises_1.lstat)(targetPath).catch(() => null);
|
|
109
|
+
if (!info) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (info.isSymbolicLink()) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
await (0, promises_1.chown)(targetPath, uid, gid);
|
|
116
|
+
if (!info.isDirectory()) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const children = await (0, promises_1.readdir)(targetPath);
|
|
120
|
+
await Promise.all(children.map(async (child) => {
|
|
121
|
+
await applyOwnershipRecursive((0, node_path_1.join)(targetPath, child), uid, gid);
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
async function pathExists(path) {
|
|
125
|
+
try {
|
|
126
|
+
await (0, promises_1.stat)(path);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function joinSandboxLogicalPath(root, logicalPath) {
|
|
134
|
+
if (!logicalPath) {
|
|
135
|
+
return root;
|
|
136
|
+
}
|
|
137
|
+
return root === '/' ? `/${logicalPath}` : `${root}/${logicalPath}`;
|
|
138
|
+
}
|
|
139
|
+
function assertLocalWorkspaceEntryMetadataSupported(providerName, logicalPath, entry, options = {}) {
|
|
140
|
+
const displayPath = logicalPath || '.';
|
|
141
|
+
if ((0, entries_1.isMount)(entry)) {
|
|
142
|
+
if (options.supportsMount?.(entry) ||
|
|
143
|
+
(options.allowLocalBindMounts !== false &&
|
|
144
|
+
isSupportedLocalBindMount(entry))) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
throw new errors_2.SandboxUnsupportedFeatureError(`${providerName} does not support this mount entry: ${displayPath}`);
|
|
148
|
+
}
|
|
149
|
+
if (entry.group !== undefined) {
|
|
150
|
+
throw new errors_2.SandboxUnsupportedFeatureError(`${providerName} does not support sandbox entry group ownership yet: ${displayPath}`);
|
|
151
|
+
}
|
|
152
|
+
if (entry.type !== 'dir' || !entry.children) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
for (const [childPath, childEntry] of Object.entries(entry.children)) {
|
|
156
|
+
assertLocalWorkspaceEntryMetadataSupported(providerName, joinLogicalPath(logicalPath, childPath), childEntry, options);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async function materializeEntries(workspaceRootPath, entries, prefix = '', options = {}) {
|
|
160
|
+
await runLimited(Object.entries(entries), resolveManifestEntryConcurrency(options.concurrencyLimits), async ([path, entry]) => {
|
|
161
|
+
if (options.skipMountEntries && (0, entries_1.isMount)(entry)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const logicalPath = prefix
|
|
165
|
+
? `${prefix}/${(0, manifest_1.normalizeRelativePath)(path)}`
|
|
166
|
+
: (0, manifest_1.normalizeRelativePath)(path);
|
|
167
|
+
await materializeLocalWorkspaceManifestEntry(workspaceRootPath, logicalPath, entry, options);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
async function materializeLocalBindMountEntry(workspaceRootPath, logicalPath, entry, options) {
|
|
171
|
+
if (!isSupportedLocalBindMount(entry)) {
|
|
172
|
+
throw new errors_2.SandboxUnsupportedFeatureError(`Local sandbox materialization only supports mount entries with an absolute source and localBindMountStrategy(): ${logicalPath || '.'}`);
|
|
173
|
+
}
|
|
174
|
+
if (entry.readOnly !== false) {
|
|
175
|
+
throw new errors_2.SandboxUnsupportedFeatureError(`Local sandbox materialization cannot enforce read-only local bind mounts: ${logicalPath || '.'}`);
|
|
176
|
+
}
|
|
177
|
+
// A local bind mount is implemented as a symlink, so read-only semantics cannot be
|
|
178
|
+
// enforced by this materializer itself.
|
|
179
|
+
const source = await (0, promises_1.realpath)(entry.source).catch(() => {
|
|
180
|
+
throw new errors_1.UserError(`Local bind mount source does not exist: ${entry.source}`);
|
|
181
|
+
});
|
|
182
|
+
const sourceInfo = await (0, promises_1.lstat)(source);
|
|
183
|
+
if (!sourceInfo.isDirectory()) {
|
|
184
|
+
throw new errors_1.UserError(`Local bind mount source must be a directory: ${source}`);
|
|
185
|
+
}
|
|
186
|
+
const mountLogicalPath = resolveMountLogicalPath(options.manifestRoot ?? '/workspace', logicalPath, entry.mountPath);
|
|
187
|
+
if (!mountLogicalPath) {
|
|
188
|
+
throw new errors_2.SandboxUnsupportedFeatureError('Local sandbox materialization does not support mounting over the workspace root.');
|
|
189
|
+
}
|
|
190
|
+
const destination = (0, node_path_1.resolve)(workspaceRootPath, mountLogicalPath);
|
|
191
|
+
await createMaterializationParentDirectory(workspaceRootPath, destination, mountLogicalPath);
|
|
192
|
+
await (0, promises_1.rm)(destination, { recursive: true, force: true });
|
|
193
|
+
await (0, promises_1.symlink)(source, destination, 'dir');
|
|
194
|
+
}
|
|
195
|
+
function isSupportedLocalBindMount(entry) {
|
|
196
|
+
return (entry.type === 'mount' &&
|
|
197
|
+
typeof entry.source === 'string' &&
|
|
198
|
+
(0, node_path_1.isAbsolute)(entry.source) &&
|
|
199
|
+
(entry.mountStrategy === undefined ||
|
|
200
|
+
entry.mountStrategy.type === 'local_bind'));
|
|
201
|
+
}
|
|
202
|
+
function resolveMountLogicalPath(root, logicalPath, mountPath) {
|
|
203
|
+
if (mountPath === undefined) {
|
|
204
|
+
return (0, manifest_1.normalizeRelativePath)(logicalPath);
|
|
205
|
+
}
|
|
206
|
+
const resolved = new workspacePaths_1.WorkspacePathPolicy({ root }).resolve(mountPath, {
|
|
207
|
+
forWrite: true,
|
|
208
|
+
});
|
|
209
|
+
if (typeof resolved.workspaceRelativePath !== 'string') {
|
|
210
|
+
throw new errors_1.UserError(`Mount path "${mountPath}" escapes the workspace root.`);
|
|
211
|
+
}
|
|
212
|
+
return (0, manifest_1.normalizeRelativePath)(resolved.workspaceRelativePath);
|
|
213
|
+
}
|
|
214
|
+
async function createMaterializationDirectory(workspaceRootPath, destination, logicalPath) {
|
|
215
|
+
await assertSafeMaterializationPath(workspaceRootPath, destination, logicalPath);
|
|
216
|
+
await (0, promises_1.mkdir)(destination, { recursive: true });
|
|
217
|
+
await assertSafeMaterializationPath(workspaceRootPath, destination, logicalPath);
|
|
218
|
+
}
|
|
219
|
+
async function createMaterializationParentDirectory(workspaceRootPath, destination, logicalPath) {
|
|
220
|
+
const parent = (0, node_path_1.dirname)(destination);
|
|
221
|
+
await assertSafeMaterializationPath(workspaceRootPath, parent, logicalPath);
|
|
222
|
+
await (0, promises_1.mkdir)(parent, { recursive: true });
|
|
223
|
+
await assertSafeMaterializationPath(workspaceRootPath, parent, logicalPath);
|
|
224
|
+
await assertSafeMaterializationPath(workspaceRootPath, destination, logicalPath);
|
|
225
|
+
}
|
|
226
|
+
async function assertSafeMaterializationPath(workspaceRootPath, destination, logicalPath) {
|
|
227
|
+
// Check after directory creation and again before writes so a concurrent symlink swap
|
|
228
|
+
// cannot redirect manifest materialization outside the workspace root.
|
|
229
|
+
const workspaceRootRealPath = await (0, promises_1.realpath)(workspaceRootPath).catch(() => {
|
|
230
|
+
throw materializationEscapesWorkspaceError(logicalPath);
|
|
231
|
+
});
|
|
232
|
+
const relativeDestination = (0, node_path_1.relative)(workspaceRootPath, destination);
|
|
233
|
+
if ((0, hostPath_1.relativeHostPathEscapesRoot)(relativeDestination)) {
|
|
234
|
+
throw materializationEscapesWorkspaceError(logicalPath);
|
|
235
|
+
}
|
|
236
|
+
if (relativeDestination === '') {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
let current = workspaceRootPath;
|
|
240
|
+
for (const segment of relativeDestination.split(node_path_1.sep)) {
|
|
241
|
+
if (!segment) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
current = (0, node_path_1.join)(current, segment);
|
|
245
|
+
const info = await (0, promises_1.lstat)(current).catch((error) => {
|
|
246
|
+
if (error.code === 'ENOENT') {
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
throw error;
|
|
250
|
+
});
|
|
251
|
+
if (!info) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (info.isSymbolicLink()) {
|
|
255
|
+
throw new errors_1.UserError(`Sandbox materialization path "${logicalPath || '.'}" escapes the workspace root through a symbolic link.`);
|
|
256
|
+
}
|
|
257
|
+
const currentRealPath = await (0, promises_1.realpath)(current).catch(() => {
|
|
258
|
+
throw materializationEscapesWorkspaceError(logicalPath);
|
|
259
|
+
});
|
|
260
|
+
if (!(0, hostPath_1.isHostPathWithinRoot)(workspaceRootRealPath, currentRealPath)) {
|
|
261
|
+
throw materializationEscapesWorkspaceError(logicalPath);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
async function materializeDirEntry(workspaceRootPath, destination, entry, logicalPath, options) {
|
|
266
|
+
await createMaterializationDirectory(workspaceRootPath, destination, logicalPath);
|
|
267
|
+
if (entry.children) {
|
|
268
|
+
await materializeEntries(workspaceRootPath, entry.children, logicalPath, options);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
async function materializeFileEntry(workspaceRootPath, destination, entry, logicalPath) {
|
|
272
|
+
await createMaterializationParentDirectory(workspaceRootPath, destination, logicalPath);
|
|
273
|
+
await writeMaterializationFile(workspaceRootPath, destination, logicalPath, entry.content);
|
|
274
|
+
}
|
|
275
|
+
async function materializeLocalFileEntry(workspaceRootPath, destination, entry, logicalPath) {
|
|
276
|
+
await createMaterializationParentDirectory(workspaceRootPath, destination, logicalPath);
|
|
277
|
+
await writeMaterializationFile(workspaceRootPath, destination, logicalPath, await readStableLocalFile(entry.src));
|
|
278
|
+
}
|
|
279
|
+
async function materializeLocalDirEntry(workspaceRootPath, destination, entry, logicalPath, options) {
|
|
280
|
+
await copyLocalDirectory(entry.src, destination, options, workspaceRootPath, logicalPath);
|
|
281
|
+
}
|
|
282
|
+
async function copyLocalDirectory(sourceDir, destination, options, workspaceRootPath, logicalPath, expectedSourceStat) {
|
|
283
|
+
const source = await resolveStableLocalDirSource(sourceDir, expectedSourceStat);
|
|
284
|
+
await createMaterializationDirectory(workspaceRootPath, destination, logicalPath);
|
|
285
|
+
const children = await readStableLocalDirEntries(sourceDir, source.stat);
|
|
286
|
+
await runLimited(children, resolveLocalDirEntryConcurrency(options.concurrencyLimits), async (child) => {
|
|
287
|
+
const sourcePath = (0, node_path_1.join)(sourceDir, child.name);
|
|
288
|
+
const destinationPath = (0, node_path_1.join)(destination, child.name);
|
|
289
|
+
const childLogicalPath = joinLogicalPath(logicalPath, child.name);
|
|
290
|
+
if (child.isDirectory()) {
|
|
291
|
+
const childSourceStat = await assertStableLocalDirChild(source.root, sourcePath);
|
|
292
|
+
await copyLocalDirectory(sourcePath, destinationPath, options, workspaceRootPath, childLogicalPath, childSourceStat);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (child.isFile()) {
|
|
296
|
+
await writeMaterializationFile(workspaceRootPath, destinationPath, childLogicalPath, await readStableLocalDirFile(source.root, sourcePath));
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (child.isSymbolicLink()) {
|
|
300
|
+
throw new errors_1.UserError(`local_dir entries do not support symbolic links: ${sourcePath}`);
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
async function writeMaterializationFile(workspaceRootPath, destination, logicalPath, content) {
|
|
305
|
+
await assertSafeMaterializationPath(workspaceRootPath, destination, logicalPath);
|
|
306
|
+
let handle;
|
|
307
|
+
try {
|
|
308
|
+
handle = await (0, promises_1.open)(destination, MATERIALIZATION_FILE_WRITE_FLAGS);
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
if (isPathChangedError(error)) {
|
|
312
|
+
throw materializationEscapesWorkspaceError(logicalPath);
|
|
313
|
+
}
|
|
314
|
+
throw error;
|
|
315
|
+
}
|
|
316
|
+
try {
|
|
317
|
+
await handle.writeFile(content);
|
|
318
|
+
}
|
|
319
|
+
finally {
|
|
320
|
+
await handle.close();
|
|
321
|
+
}
|
|
322
|
+
await assertSafeMaterializationPath(workspaceRootPath, destination, logicalPath);
|
|
323
|
+
}
|
|
324
|
+
async function resolveStableLocalDirSource(sourceDir, expectedSourceStat) {
|
|
325
|
+
await assertNoLocalSourceSymlinkAncestors(sourceDir, 'local_dir', localDirPathChangedError);
|
|
326
|
+
const sourceStat = await statStableLocalSourcePath(sourceDir);
|
|
327
|
+
if (sourceStat.isSymbolicLink()) {
|
|
328
|
+
throw new errors_1.UserError(`local_dir entries do not support symbolic links: ${sourceDir}`);
|
|
329
|
+
}
|
|
330
|
+
if (!sourceStat.isDirectory()) {
|
|
331
|
+
throw new errors_1.UserError(`local_dir source must be a directory: ${sourceDir}`);
|
|
332
|
+
}
|
|
333
|
+
if (expectedSourceStat &&
|
|
334
|
+
!sameFilesystemEntry(sourceStat, expectedSourceStat)) {
|
|
335
|
+
throw localDirPathChangedError(sourceDir);
|
|
336
|
+
}
|
|
337
|
+
const sourceRoot = await realpathStableLocalSourcePath(sourceDir);
|
|
338
|
+
let handle;
|
|
339
|
+
try {
|
|
340
|
+
handle = await (0, promises_1.open)(sourceDir, LOCAL_SOURCE_DIRECTORY_READ_FLAGS);
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
if (isPathChangedError(error)) {
|
|
344
|
+
throw localDirPathChangedError(sourceDir);
|
|
345
|
+
}
|
|
346
|
+
throw error;
|
|
347
|
+
}
|
|
348
|
+
try {
|
|
349
|
+
const openedStat = await handle.stat();
|
|
350
|
+
if (!openedStat.isDirectory() ||
|
|
351
|
+
!sameFilesystemEntry(openedStat, sourceStat)) {
|
|
352
|
+
throw localDirPathChangedError(sourceDir);
|
|
353
|
+
}
|
|
354
|
+
return { root: sourceRoot, stat: openedStat };
|
|
355
|
+
}
|
|
356
|
+
finally {
|
|
357
|
+
await handle.close();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
async function readStableLocalDirEntries(sourceDir, expectedStat) {
|
|
361
|
+
let children;
|
|
362
|
+
try {
|
|
363
|
+
children = await (0, promises_1.readdir)(sourceDir, { withFileTypes: true });
|
|
364
|
+
}
|
|
365
|
+
catch (error) {
|
|
366
|
+
if (isPathChangedError(error)) {
|
|
367
|
+
throw localDirPathChangedError(sourceDir);
|
|
368
|
+
}
|
|
369
|
+
throw error;
|
|
370
|
+
}
|
|
371
|
+
await assertStableLocalDirPath(sourceDir, expectedStat);
|
|
372
|
+
return children;
|
|
373
|
+
}
|
|
374
|
+
async function assertStableLocalDirPath(sourcePath, expectedStat) {
|
|
375
|
+
const currentStat = await statStableLocalSourcePath(sourcePath);
|
|
376
|
+
if (currentStat.isSymbolicLink() ||
|
|
377
|
+
!currentStat.isDirectory() ||
|
|
378
|
+
!sameFilesystemEntry(currentStat, expectedStat)) {
|
|
379
|
+
throw localDirPathChangedError(sourcePath);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
async function readStableLocalFile(sourcePath) {
|
|
383
|
+
await assertNoLocalSourceSymlinkAncestors(sourcePath, 'local_file', localFilePathChangedError);
|
|
384
|
+
const sourceStat = await statStableLocalSourcePath(sourcePath, localFilePathChangedError);
|
|
385
|
+
if (sourceStat.isSymbolicLink()) {
|
|
386
|
+
throw new errors_1.UserError(`local_file entries do not support symbolic links: ${sourcePath}`);
|
|
387
|
+
}
|
|
388
|
+
if (!sourceStat.isFile()) {
|
|
389
|
+
throw localFilePathChangedError(sourcePath);
|
|
390
|
+
}
|
|
391
|
+
let handle;
|
|
392
|
+
try {
|
|
393
|
+
handle = await (0, promises_1.open)(sourcePath, LOCAL_SOURCE_FILE_READ_FLAGS);
|
|
394
|
+
}
|
|
395
|
+
catch (error) {
|
|
396
|
+
if (isPathChangedError(error)) {
|
|
397
|
+
throw localFilePathChangedError(sourcePath);
|
|
398
|
+
}
|
|
399
|
+
throw error;
|
|
400
|
+
}
|
|
401
|
+
try {
|
|
402
|
+
const openedStat = await handle.stat();
|
|
403
|
+
if (!openedStat.isFile() || !sameFilesystemEntry(openedStat, sourceStat)) {
|
|
404
|
+
throw localFilePathChangedError(sourcePath);
|
|
405
|
+
}
|
|
406
|
+
return await handle.readFile();
|
|
407
|
+
}
|
|
408
|
+
finally {
|
|
409
|
+
await handle.close();
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
async function assertNoLocalSourceSymlinkAncestors(sourcePath, entryType, pathChangedError) {
|
|
413
|
+
const resolvedPath = (0, node_path_1.resolve)(sourcePath);
|
|
414
|
+
let current = (0, node_path_1.dirname)(resolvedPath);
|
|
415
|
+
while (current !== (0, node_path_1.dirname)(current)) {
|
|
416
|
+
const parent = (0, node_path_1.dirname)(current);
|
|
417
|
+
if (parent === (0, node_path_1.dirname)(parent)) {
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
let currentStat;
|
|
421
|
+
try {
|
|
422
|
+
currentStat = await (0, promises_1.lstat)(current);
|
|
423
|
+
}
|
|
424
|
+
catch (error) {
|
|
425
|
+
if (isPathChangedError(error)) {
|
|
426
|
+
throw pathChangedError(sourcePath);
|
|
427
|
+
}
|
|
428
|
+
throw error;
|
|
429
|
+
}
|
|
430
|
+
if (currentStat.isSymbolicLink()) {
|
|
431
|
+
throw new errors_1.UserError(`${entryType} entries do not support symbolic link ancestors: ${sourcePath}`);
|
|
432
|
+
}
|
|
433
|
+
current = parent;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
async function readStableLocalDirFile(sourceRoot, sourcePath) {
|
|
437
|
+
const sourceStat = await statStableLocalSourcePath(sourcePath);
|
|
438
|
+
if (sourceStat.isSymbolicLink()) {
|
|
439
|
+
throw new errors_1.UserError(`local_dir entries do not support symbolic links: ${sourcePath}`);
|
|
440
|
+
}
|
|
441
|
+
if (!sourceStat.isFile()) {
|
|
442
|
+
throw localDirPathChangedError(sourcePath);
|
|
443
|
+
}
|
|
444
|
+
const resolvedSourcePath = await realpathStableLocalSourcePath(sourcePath);
|
|
445
|
+
if (!(0, hostPath_1.isHostPathStrictlyWithinRoot)(sourceRoot, resolvedSourcePath)) {
|
|
446
|
+
throw localDirPathChangedError(sourcePath);
|
|
447
|
+
}
|
|
448
|
+
let handle;
|
|
449
|
+
try {
|
|
450
|
+
handle = await (0, promises_1.open)(sourcePath, LOCAL_SOURCE_FILE_READ_FLAGS);
|
|
451
|
+
}
|
|
452
|
+
catch (error) {
|
|
453
|
+
if (isPathChangedError(error)) {
|
|
454
|
+
throw localDirPathChangedError(sourcePath);
|
|
455
|
+
}
|
|
456
|
+
throw error;
|
|
457
|
+
}
|
|
458
|
+
try {
|
|
459
|
+
const openedStat = await handle.stat();
|
|
460
|
+
if (!openedStat.isFile() || !sameFilesystemEntry(openedStat, sourceStat)) {
|
|
461
|
+
throw localDirPathChangedError(sourcePath);
|
|
462
|
+
}
|
|
463
|
+
return await handle.readFile();
|
|
464
|
+
}
|
|
465
|
+
finally {
|
|
466
|
+
await handle.close();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
async function statStableLocalSourcePath(sourcePath, pathChangedError = localDirPathChangedError) {
|
|
470
|
+
try {
|
|
471
|
+
return await (0, promises_1.lstat)(sourcePath);
|
|
472
|
+
}
|
|
473
|
+
catch (error) {
|
|
474
|
+
if (isPathChangedError(error)) {
|
|
475
|
+
throw pathChangedError(sourcePath);
|
|
476
|
+
}
|
|
477
|
+
throw error;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
async function realpathStableLocalSourcePath(sourcePath, pathChangedError = localDirPathChangedError) {
|
|
481
|
+
try {
|
|
482
|
+
return await (0, promises_1.realpath)(sourcePath);
|
|
483
|
+
}
|
|
484
|
+
catch (error) {
|
|
485
|
+
if (isPathChangedError(error)) {
|
|
486
|
+
throw pathChangedError(sourcePath);
|
|
487
|
+
}
|
|
488
|
+
throw error;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function localDirPathChangedError(sourcePath) {
|
|
492
|
+
return new errors_1.UserError(`local_dir entry path changed while materializing: ${sourcePath}`);
|
|
493
|
+
}
|
|
494
|
+
function localFilePathChangedError(sourcePath) {
|
|
495
|
+
return new errors_1.UserError(`local_file entry path changed while materializing: ${sourcePath}`);
|
|
496
|
+
}
|
|
497
|
+
function isPathChangedError(error) {
|
|
498
|
+
return (typeof error === 'object' &&
|
|
499
|
+
error !== null &&
|
|
500
|
+
'code' in error &&
|
|
501
|
+
(error.code === 'ELOOP' ||
|
|
502
|
+
error.code === 'ENOENT' ||
|
|
503
|
+
error.code === 'ENOTDIR'));
|
|
504
|
+
}
|
|
505
|
+
async function assertStableLocalDirChild(sourceRoot, sourcePath) {
|
|
506
|
+
// local_dir deliberately rejects symlinks so a host-side source cannot smuggle
|
|
507
|
+
// files outside the declared directory into the sandbox.
|
|
508
|
+
const sourceStat = await statStableLocalSourcePath(sourcePath);
|
|
509
|
+
if (sourceStat.isSymbolicLink()) {
|
|
510
|
+
throw new errors_1.UserError(`local_dir entries do not support symbolic links: ${sourcePath}`);
|
|
511
|
+
}
|
|
512
|
+
if (!sourceStat.isDirectory()) {
|
|
513
|
+
throw localDirPathChangedError(sourcePath);
|
|
514
|
+
}
|
|
515
|
+
const resolvedSourcePath = await realpathStableLocalSourcePath(sourcePath);
|
|
516
|
+
if (!(0, hostPath_1.isHostPathStrictlyWithinRoot)(sourceRoot, resolvedSourcePath)) {
|
|
517
|
+
throw localDirPathChangedError(sourcePath);
|
|
518
|
+
}
|
|
519
|
+
return sourceStat;
|
|
520
|
+
}
|
|
521
|
+
function sameFilesystemEntry(left, right) {
|
|
522
|
+
return left.dev === right.dev && left.ino === right.ino;
|
|
523
|
+
}
|
|
524
|
+
async function materializeGitRepoEntry(workspaceRootPath, destination, entry, logicalPath) {
|
|
525
|
+
const gitVersion = await (0, runProcess_1.runSandboxProcess)('git', ['--version'], {
|
|
526
|
+
timeoutMs: GIT_VERSION_TIMEOUT_MS,
|
|
527
|
+
});
|
|
528
|
+
if (gitVersion.status !== 0) {
|
|
529
|
+
throw new errors_1.UserError('git_repo entries require a local `git` executable, but `git` was not found.');
|
|
530
|
+
}
|
|
531
|
+
const repository = normalizeGitRepository(entry);
|
|
532
|
+
const cloneIntoTemporaryDirectory = Boolean(entry.subpath) ||
|
|
533
|
+
Boolean(entry.ref && looksLikeCommitRef(entry.ref));
|
|
534
|
+
const cloneDestination = cloneIntoTemporaryDirectory
|
|
535
|
+
? await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'openai-agents-git-repo-'))
|
|
536
|
+
: destination;
|
|
537
|
+
try {
|
|
538
|
+
if (cloneIntoTemporaryDirectory) {
|
|
539
|
+
await (0, promises_1.mkdir)((0, node_path_1.dirname)(cloneDestination), { recursive: true });
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
await createMaterializationParentDirectory(workspaceRootPath, cloneDestination, logicalPath);
|
|
543
|
+
}
|
|
544
|
+
const { result: cloneResult, commitFetchError } = await cloneGitRepo(repository, cloneDestination, entry.ref);
|
|
545
|
+
if (cloneResult.status !== 0) {
|
|
546
|
+
throw new errors_1.UserError(`Failed to materialize git_repo entry ${entry.repo}: ${(0, runProcess_1.formatSandboxProcessError)(commitFetchError ?? cloneResult)}`);
|
|
547
|
+
}
|
|
548
|
+
if (!cloneIntoTemporaryDirectory) {
|
|
549
|
+
await assertSafeMaterializationPath(workspaceRootPath, destination, logicalPath);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
const sourcePath = entry.subpath
|
|
553
|
+
? (0, node_path_1.resolve)(cloneDestination, entry.subpath)
|
|
554
|
+
: cloneDestination;
|
|
555
|
+
if (entry.subpath) {
|
|
556
|
+
const cloneRoot = await (0, promises_1.realpath)(cloneDestination);
|
|
557
|
+
const subpathRealpath = await (0, promises_1.realpath)(sourcePath);
|
|
558
|
+
if (!(0, hostPath_1.isHostPathStrictlyWithinRoot)(cloneRoot, subpathRealpath)) {
|
|
559
|
+
throw new errors_1.UserError(`git_repo subpath escapes the cloned repository: ${entry.subpath}`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
const sourceInfo = await (0, promises_1.lstat)(sourcePath);
|
|
563
|
+
if (sourceInfo.isDirectory()) {
|
|
564
|
+
await copyLocalDirectory(sourcePath, destination, {}, workspaceRootPath, logicalPath);
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
if (sourceInfo.isFile()) {
|
|
568
|
+
await createMaterializationParentDirectory(workspaceRootPath, destination, logicalPath);
|
|
569
|
+
await writeMaterializationFile(workspaceRootPath, destination, logicalPath, await (0, promises_1.readFile)(sourcePath));
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
throw new errors_1.UserError(`git_repo subpath must resolve to a file or directory: ${entry.subpath}`);
|
|
573
|
+
}
|
|
574
|
+
finally {
|
|
575
|
+
if (cloneIntoTemporaryDirectory) {
|
|
576
|
+
await (0, promises_1.rm)(cloneDestination, { recursive: true, force: true });
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
async function cloneGitRepo(repository, destination, ref) {
|
|
581
|
+
if (!ref || !looksLikeCommitRef(ref)) {
|
|
582
|
+
return { result: await cloneNamedRef(repository, destination, ref) };
|
|
583
|
+
}
|
|
584
|
+
// Branch/tag shallow clone does not reliably fetch arbitrary SHAs, so commit-looking
|
|
585
|
+
// refs take the explicit init/fetch/checkout path first.
|
|
586
|
+
const result = await fetchCommitRef(repository, destination, ref);
|
|
587
|
+
if (result.status === 0) {
|
|
588
|
+
return { result };
|
|
589
|
+
}
|
|
590
|
+
await (0, promises_1.rm)(destination, { recursive: true, force: true });
|
|
591
|
+
return {
|
|
592
|
+
result: await cloneNamedRef(repository, destination, ref),
|
|
593
|
+
commitFetchError: result,
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
async function cloneNamedRef(repository, destination, ref) {
|
|
597
|
+
const args = ['clone', '--depth', '1'];
|
|
598
|
+
if (ref) {
|
|
599
|
+
args.push('--branch', ref);
|
|
600
|
+
}
|
|
601
|
+
args.push(repository, destination);
|
|
602
|
+
return await (0, runProcess_1.runSandboxProcess)('git', args, {
|
|
603
|
+
timeoutMs: GIT_CLONE_TIMEOUT_MS,
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
async function fetchCommitRef(repository, destination, ref) {
|
|
607
|
+
const steps = [
|
|
608
|
+
['init', destination],
|
|
609
|
+
['-C', destination, 'remote', 'add', 'origin', repository],
|
|
610
|
+
['-C', destination, 'fetch', '--depth', '1', '--no-tags', 'origin', ref],
|
|
611
|
+
['-C', destination, 'checkout', '--detach', 'FETCH_HEAD'],
|
|
612
|
+
];
|
|
613
|
+
for (const args of steps) {
|
|
614
|
+
const result = await (0, runProcess_1.runSandboxProcess)('git', args, {
|
|
615
|
+
timeoutMs: GIT_CLONE_TIMEOUT_MS,
|
|
616
|
+
});
|
|
617
|
+
if (result.status !== 0) {
|
|
618
|
+
return result;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
return {
|
|
622
|
+
status: 0,
|
|
623
|
+
signal: null,
|
|
624
|
+
stdout: '',
|
|
625
|
+
stderr: '',
|
|
626
|
+
timedOut: false,
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
function looksLikeCommitRef(ref) {
|
|
630
|
+
return COMMIT_REF_PATTERN.test(ref);
|
|
631
|
+
}
|
|
632
|
+
async function runLimited(items, limit, fn) {
|
|
633
|
+
if (items.length === 0) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (limit <= 1) {
|
|
637
|
+
for (const item of items) {
|
|
638
|
+
await fn(item);
|
|
639
|
+
}
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
let nextIndex = 0;
|
|
643
|
+
// This intentionally stays as a tiny work queue rather than adding a dependency for
|
|
644
|
+
// the few manifest and local_dir concurrency limits used here.
|
|
645
|
+
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
646
|
+
while (nextIndex < items.length) {
|
|
647
|
+
const item = items[nextIndex++];
|
|
648
|
+
await fn(item);
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
await Promise.all(workers);
|
|
652
|
+
}
|
|
653
|
+
function resolveManifestEntryConcurrency(limits) {
|
|
654
|
+
return normalizeConcurrencyLimit(limits?.manifestEntries, 4);
|
|
655
|
+
}
|
|
656
|
+
function resolveLocalDirEntryConcurrency(limits) {
|
|
657
|
+
return normalizeConcurrencyLimit(limits?.localDirFiles, 4);
|
|
658
|
+
}
|
|
659
|
+
function normalizeConcurrencyLimit(value, fallback) {
|
|
660
|
+
if (value === undefined) {
|
|
661
|
+
return fallback;
|
|
662
|
+
}
|
|
663
|
+
if (!Number.isFinite(value) || value < 1) {
|
|
664
|
+
throw new errors_1.UserError('Sandbox concurrency limits must be positive numbers.');
|
|
665
|
+
}
|
|
666
|
+
return Math.floor(value);
|
|
667
|
+
}
|
|
668
|
+
function joinLogicalPath(parent, child) {
|
|
669
|
+
const normalizedChild = (0, manifest_1.normalizeRelativePath)(child);
|
|
670
|
+
if (!parent || parent === '.') {
|
|
671
|
+
return normalizedChild;
|
|
672
|
+
}
|
|
673
|
+
return `${parent.replace(/\/+$/u, '')}/${normalizedChild}`;
|
|
674
|
+
}
|
|
675
|
+
async function applyEntryPermissions(workspaceRootPath, destination, entry, logicalPath) {
|
|
676
|
+
await assertSafeMaterializationPath(workspaceRootPath, destination, logicalPath);
|
|
677
|
+
const permissions = (0, permissions_1.permissionsForSandboxEntry)(entry.permissions);
|
|
678
|
+
await (0, promises_1.chmod)(destination, permissions.toMode() & 0o777);
|
|
679
|
+
}
|
|
680
|
+
function materializationEscapesWorkspaceError(logicalPath) {
|
|
681
|
+
return new errors_1.UserError(`Sandbox materialization path "${logicalPath || '.'}" escapes the workspace root.`);
|
|
682
|
+
}
|
|
683
|
+
function normalizeGitRepository(entry) {
|
|
684
|
+
const repository = entry.repo;
|
|
685
|
+
if (!repository) {
|
|
686
|
+
throw new errors_1.UserError('git_repo entries require a repo.');
|
|
687
|
+
}
|
|
688
|
+
if (repository.includes('://') || repository.startsWith('git@')) {
|
|
689
|
+
return repository;
|
|
690
|
+
}
|
|
691
|
+
return `https://${entry.host ?? 'github.com'}/${repository}.git`;
|
|
692
|
+
}
|
|
693
|
+
//# sourceMappingURL=localWorkspace.js.map
|