@effect-uai/core 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AiError-Bf1pq4BB.d.mts → AiError-eLV9t1lU.d.mts} +12 -16
- package/dist/AiError-eLV9t1lU.d.mts.map +1 -0
- package/dist/{Audio-CR7CSljJ.d.mts → Audio-60lKKHxS.d.mts} +4 -5
- package/dist/Audio-60lKKHxS.d.mts.map +1 -0
- package/dist/{Image-C4vuBmu0.d.mts → Image-BK8-4H6s.d.mts} +12 -14
- package/dist/Image-BK8-4H6s.d.mts.map +1 -0
- package/dist/{Items-BKQgqJ8A.d.mts → Items-SfUabNuB.d.mts} +74 -76
- package/dist/Items-SfUabNuB.d.mts.map +1 -0
- package/dist/{Loop-D8nWpowc.d.mts → Loop-B54AB1ME.d.mts} +19 -21
- package/dist/Loop-B54AB1ME.d.mts.map +1 -0
- package/dist/{Media-D_CpcM1Z.d.mts → Media-DwgpifPD.d.mts} +1 -1
- package/dist/Media-DwgpifPD.d.mts.map +1 -0
- package/dist/{SandboxError-CIrVDOMV.d.mts → SandboxError-BN8b28Bh.d.mts} +11 -15
- package/dist/SandboxError-BN8b28Bh.d.mts.map +1 -0
- package/dist/{StructuredFormat-DHaUJBdd.d.mts → StructuredFormat-BlZhyOsi.d.mts} +3 -7
- package/dist/StructuredFormat-BlZhyOsi.d.mts.map +1 -0
- package/dist/{Tool-u5bag8SO.d.mts → Tool-DE-rnvkw.d.mts} +5 -8
- package/dist/Tool-DE-rnvkw.d.mts.map +1 -0
- package/dist/{ToolEvent-BBfOdhF_.d.mts → ToolEvent-D99MGQYH.d.mts} +56 -63
- package/dist/ToolEvent-D99MGQYH.d.mts.map +1 -0
- package/dist/{ToolResult-CRpmkBXR.d.mts → ToolResult-Cj8ChodL.d.mts} +49 -54
- package/dist/ToolResult-Cj8ChodL.d.mts.map +1 -0
- package/dist/{Toolkit-D4mQvhjq.d.mts → Toolkit-BEZrNPTI.d.mts} +13 -16
- package/dist/Toolkit-BEZrNPTI.d.mts.map +1 -0
- package/dist/browser/Browser.d.mts +11 -7
- package/dist/browser/Browser.d.mts.map +1 -1
- package/dist/browser/Browser.mjs +1 -1
- package/dist/browser/Browser.mjs.map +1 -1
- package/dist/browser/BrowserError.d.mts +9 -13
- package/dist/browser/BrowserError.d.mts.map +1 -1
- package/dist/browser/BrowserError.mjs +1 -1
- package/dist/browser/BrowserError.mjs.map +1 -1
- package/dist/browser/BrowserTool.d.mts +33 -36
- package/dist/browser/BrowserTool.d.mts.map +1 -1
- package/dist/browser/BrowserTool.mjs +1 -1
- package/dist/browser/BrowserTool.mjs.map +1 -1
- package/dist/capabilities/Capabilities.d.mts +8 -6
- package/dist/capabilities/Capabilities.d.mts.map +1 -1
- package/dist/capabilities/Capabilities.mjs +1 -1
- package/dist/capabilities/Capabilities.mjs.map +1 -1
- package/dist/chunker/Chunker.d.mts +32 -0
- package/dist/chunker/Chunker.d.mts.map +1 -0
- package/dist/chunker/Chunker.mjs +14 -0
- package/dist/chunker/Chunker.mjs.map +1 -0
- package/dist/dist-BaenoU1A.mjs +145 -0
- package/dist/dist-BaenoU1A.mjs.map +1 -0
- package/dist/{dist-C0m0QnUP.mjs → dist-nohcnkD6.mjs} +16 -15
- package/dist/dist-nohcnkD6.mjs.map +1 -0
- package/dist/domain/AiError.d.mts +1 -1
- package/dist/domain/AiError.mjs +1 -1
- package/dist/domain/AiError.mjs.map +1 -1
- package/dist/domain/Audio.d.mts +1 -1
- package/dist/domain/Audio.mjs +1 -1
- package/dist/domain/Citation.d.mts +0 -2
- package/dist/domain/Citation.d.mts.map +1 -1
- package/dist/domain/Citation.mjs +1 -1
- package/dist/domain/Image.d.mts +1 -1
- package/dist/domain/Image.mjs +1 -1
- package/dist/domain/Image.mjs.map +1 -1
- package/dist/domain/Items.d.mts +1 -1
- package/dist/domain/Items.mjs +1 -1
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Media.d.mts +1 -1
- package/dist/domain/Media.mjs +1 -1
- package/dist/domain/Music.d.mts +18 -11
- package/dist/domain/Music.d.mts.map +1 -1
- package/dist/domain/Music.mjs +1 -1
- package/dist/domain/Music.mjs.map +1 -1
- package/dist/domain/Research.d.mts +3 -4
- package/dist/domain/Research.d.mts.map +1 -1
- package/dist/domain/Research.mjs +1 -1
- package/dist/domain/Transcript.d.mts +2 -3
- package/dist/domain/Transcript.d.mts.map +1 -1
- package/dist/domain/Transcript.mjs +1 -1
- package/dist/domain/Turn.d.mts +143 -164
- package/dist/domain/Turn.d.mts.map +1 -1
- package/dist/domain/Turn.mjs +1 -1
- package/dist/domain/Turn.mjs.map +1 -1
- package/dist/domain/Turn.test.d.mts +1 -1
- package/dist/domain/Turn.test.mjs +28 -18
- package/dist/domain/Turn.test.mjs.map +1 -1
- package/dist/embedding-model/Embedding.d.mts +1 -3
- package/dist/embedding-model/Embedding.d.mts.map +1 -1
- package/dist/embedding-model/Embedding.mjs +1 -1
- package/dist/embedding-model/EmbeddingModel.d.mts +1 -3
- package/dist/embedding-model/EmbeddingModel.d.mts.map +1 -1
- package/dist/embedding-model/EmbeddingModel.mjs +1 -1
- package/dist/embedding-model/EmbeddingModel.mjs.map +1 -1
- package/dist/embedding-model/EmbeddingModel.test.d.mts +1 -1
- package/dist/embedding-model/EmbeddingModel.test.mjs +14 -9
- package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -1
- package/dist/index.d.mts +16 -13
- package/dist/index.mjs +4 -1
- package/dist/job/Job.d.mts +4 -4
- package/dist/job/Job.d.mts.map +1 -1
- package/dist/job/Job.mjs +1 -1
- package/dist/job/Job.mjs.map +1 -1
- package/dist/language-model/LanguageModel.d.mts +4 -6
- package/dist/language-model/LanguageModel.d.mts.map +1 -1
- package/dist/language-model/LanguageModel.mjs +1 -1
- package/dist/language-model/LanguageModel.mjs.map +1 -1
- package/dist/language-model/LanguageModel.test.d.mts +1 -1
- package/dist/language-model/LanguageModel.test.mjs +6 -3
- package/dist/language-model/LanguageModel.test.mjs.map +1 -1
- package/dist/loop/Loop.d.mts +1 -1
- package/dist/loop/Loop.mjs +1 -1
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.d.mts +1 -1
- package/dist/loop/Loop.test.mjs +60 -34
- package/dist/loop/Loop.test.mjs.map +1 -1
- package/dist/{magic-string.es-Dk-MMA0F.mjs → magic-string.es-CB2hOw9v.mjs} +14 -13
- package/dist/{magic-string.es-Dk-MMA0F.mjs.map → magic-string.es-CB2hOw9v.mjs.map} +1 -1
- package/dist/math/Vector.d.mts +0 -2
- package/dist/math/Vector.d.mts.map +1 -1
- package/dist/math/Vector.mjs +1 -1
- package/dist/math/Vector.mjs.map +1 -1
- package/dist/music-generator/MusicGenerator.d.mts +2 -4
- package/dist/music-generator/MusicGenerator.d.mts.map +1 -1
- package/dist/music-generator/MusicGenerator.mjs +1 -1
- package/dist/music-generator/MusicGenerator.mjs.map +1 -1
- package/dist/music-generator/MusicGenerator.test.d.mts +1 -1
- package/dist/music-generator/MusicGenerator.test.mjs +19 -10
- package/dist/music-generator/MusicGenerator.test.mjs.map +1 -1
- package/dist/observability/Metrics.d.mts +10 -7
- package/dist/observability/Metrics.d.mts.map +1 -1
- package/dist/observability/Metrics.mjs +1 -1
- package/dist/observability/Metrics.mjs.map +1 -1
- package/dist/observability/Metrics.test.d.mts +1 -1
- package/dist/observability/Metrics.test.mjs +50 -28
- package/dist/observability/Metrics.test.mjs.map +1 -1
- package/dist/observability/Telemetry.d.mts +2 -3
- package/dist/observability/Telemetry.d.mts.map +1 -1
- package/dist/observability/Telemetry.mjs +1 -1
- package/dist/observability/Telemetry.mjs.map +1 -1
- package/dist/observability/Telemetry.test.d.mts +1 -1
- package/dist/observability/Telemetry.test.mjs +15 -7
- package/dist/observability/Telemetry.test.mjs.map +1 -1
- package/dist/reranker/Reranker.d.mts +46 -0
- package/dist/reranker/Reranker.d.mts.map +1 -0
- package/dist/reranker/Reranker.mjs +14 -0
- package/dist/reranker/Reranker.mjs.map +1 -0
- package/dist/research/DeepResearch.d.mts +1 -3
- package/dist/research/DeepResearch.d.mts.map +1 -1
- package/dist/research/DeepResearch.mjs +1 -1
- package/dist/research/DeepResearch.mjs.map +1 -1
- package/dist/retry/Retry.d.mts +2 -6
- package/dist/retry/Retry.d.mts.map +1 -1
- package/dist/retry/Retry.mjs +1 -1
- package/dist/retry/Retry.mjs.map +1 -1
- package/dist/retry/Retry.test.d.mts +1 -1
- package/dist/retry/Retry.test.mjs +6 -3
- package/dist/retry/Retry.test.mjs.map +1 -1
- package/dist/sandbox/Memory.d.mts +0 -2
- package/dist/sandbox/Memory.d.mts.map +1 -1
- package/dist/sandbox/Memory.mjs +4 -4
- package/dist/sandbox/Memory.mjs.map +1 -1
- package/dist/sandbox/Sandbox.d.mts +144 -156
- package/dist/sandbox/Sandbox.d.mts.map +1 -1
- package/dist/sandbox/Sandbox.mjs +1 -1
- package/dist/sandbox/Sandbox.mjs.map +1 -1
- package/dist/sandbox/SandboxError.d.mts +1 -1
- package/dist/sandbox/SandboxError.mjs +1 -1
- package/dist/sandbox/SandboxError.mjs.map +1 -1
- package/dist/sandbox/SandboxImage.d.mts +0 -2
- package/dist/sandbox/SandboxImage.d.mts.map +1 -1
- package/dist/sandbox/SandboxImage.mjs +1 -1
- package/dist/sandbox/SandboxImage.mjs.map +1 -1
- package/dist/sandbox/SandboxNetwork.d.mts +0 -2
- package/dist/sandbox/SandboxNetwork.d.mts.map +1 -1
- package/dist/sandbox/SandboxNetwork.mjs +1 -1
- package/dist/sandbox/SandboxNetwork.mjs.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +8 -7
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.test.d.mts +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +31 -16
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs.map +1 -1
- package/dist/streaming/JSONL.d.mts +1 -5
- package/dist/streaming/JSONL.d.mts.map +1 -1
- package/dist/streaming/JSONL.mjs +1 -1
- package/dist/streaming/JSONL.mjs.map +1 -1
- package/dist/streaming/JSONL.test.d.mts +1 -1
- package/dist/streaming/JSONL.test.mjs +16 -8
- package/dist/streaming/JSONL.test.mjs.map +1 -1
- package/dist/streaming/Lines.d.mts +0 -2
- package/dist/streaming/Lines.d.mts.map +1 -1
- package/dist/streaming/Lines.mjs +1 -1
- package/dist/streaming/Lines.mjs.map +1 -1
- package/dist/streaming/SSE.d.mts +0 -2
- package/dist/streaming/SSE.d.mts.map +1 -1
- package/dist/streaming/SSE.mjs +1 -1
- package/dist/streaming/SSE.mjs.map +1 -1
- package/dist/streaming/SSE.test.d.mts +1 -1
- package/dist/streaming/SSE.test.mjs +34 -17
- package/dist/streaming/SSE.test.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.d.mts +1 -1
- package/dist/structured-format/StructuredFormat.mjs +1 -1
- package/dist/structured-format/StructuredFormat.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.test.d.mts +1 -1
- package/dist/structured-format/StructuredFormat.test.mjs +7 -4
- package/dist/structured-format/StructuredFormat.test.mjs.map +1 -1
- package/dist/{dist-CcRV3-A5.mjs → test.DNmyFkvJ-YPzDR0Co.mjs} +1644 -5172
- package/dist/test.DNmyFkvJ-YPzDR0Co.mjs.map +1 -0
- package/dist/testing/MockMusicGenerator.d.mts +4 -3
- package/dist/testing/MockMusicGenerator.d.mts.map +1 -1
- package/dist/testing/MockMusicGenerator.mjs.map +1 -1
- package/dist/testing/MockProvider.d.mts +1 -2
- package/dist/testing/MockProvider.d.mts.map +1 -1
- package/dist/testing/MockProvider.mjs.map +1 -1
- package/dist/testing/MockSandbox.d.mts +256 -290
- package/dist/testing/MockSandbox.d.mts.map +1 -1
- package/dist/testing/MockSandbox.mjs.map +1 -1
- package/dist/testing/MockSpeechSynthesizer.d.mts +10 -6
- package/dist/testing/MockSpeechSynthesizer.d.mts.map +1 -1
- package/dist/testing/MockSpeechSynthesizer.mjs.map +1 -1
- package/dist/testing/MockTranscriber.d.mts +3 -2
- package/dist/testing/MockTranscriber.d.mts.map +1 -1
- package/dist/testing/MockTranscriber.mjs.map +1 -1
- package/dist/tokenizer/Tokenizer.d.mts +22 -0
- package/dist/tokenizer/Tokenizer.d.mts.map +1 -0
- package/dist/tokenizer/Tokenizer.mjs +9 -0
- package/dist/tokenizer/Tokenizer.mjs.map +1 -0
- package/dist/tool/Approval.d.mts +31 -36
- package/dist/tool/Approval.d.mts.map +1 -1
- package/dist/tool/Approval.mjs +1 -1
- package/dist/tool/Approval.mjs.map +1 -1
- package/dist/tool/Approval.test.d.mts +1 -1
- package/dist/tool/Approval.test.mjs +37 -24
- package/dist/tool/Approval.test.mjs.map +1 -1
- package/dist/tool/HistoryCheck.d.mts +2 -4
- package/dist/tool/HistoryCheck.d.mts.map +1 -1
- package/dist/tool/HistoryCheck.mjs +1 -1
- package/dist/tool/HistoryCheck.mjs.map +1 -1
- package/dist/tool/Tool.d.mts +1 -1
- package/dist/tool/Tool.mjs +4 -4
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/Tool.test.d.mts +1 -1
- package/dist/tool/Tool.test.mjs +23 -11
- package/dist/tool/Tool.test.mjs.map +1 -1
- package/dist/tool/ToolEvent.d.mts +1 -1
- package/dist/tool/ToolEvent.mjs +1 -1
- package/dist/tool/ToolEvent.mjs.map +1 -1
- package/dist/tool/ToolResult.d.mts +1 -1
- package/dist/tool/ToolResult.mjs +1 -1
- package/dist/tool/ToolResult.mjs.map +1 -1
- package/dist/tool/Toolkit.d.mts +1 -1
- package/dist/tool/Toolkit.mjs +4 -3
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.d.mts +1 -1
- package/dist/tool/Toolkit.test.mjs +40 -21
- package/dist/tool/Toolkit.test.mjs.map +1 -1
- package/dist/transcriber/Transcriber.d.mts +6 -6
- package/dist/transcriber/Transcriber.d.mts.map +1 -1
- package/dist/transcriber/Transcriber.mjs +1 -1
- package/dist/transcriber/Transcriber.mjs.map +1 -1
- package/dist/transcriber/Transcriber.test.d.mts +1 -1
- package/dist/transcriber/Transcriber.test.mjs +20 -10
- package/dist/transcriber/Transcriber.test.mjs.map +1 -1
- package/dist/utils-CiH_DjFW.mjs +3918 -0
- package/dist/utils-CiH_DjFW.mjs.map +1 -0
- package/dist/web-read/WebRead.d.mts +15 -9
- package/dist/web-read/WebRead.d.mts.map +1 -1
- package/dist/web-read/WebRead.mjs +1 -1
- package/dist/web-read/WebRead.mjs.map +1 -1
- package/dist/web-read/WebReadTool.d.mts +4 -5
- package/dist/web-read/WebReadTool.d.mts.map +1 -1
- package/dist/web-read/WebReadTool.mjs +1 -1
- package/dist/web-read/WebReadTool.mjs.map +1 -1
- package/dist/web-search/WebSearch.d.mts +22 -13
- package/dist/web-search/WebSearch.d.mts.map +1 -1
- package/dist/web-search/WebSearch.mjs +1 -1
- package/dist/web-search/WebSearch.mjs.map +1 -1
- package/dist/web-search/WebSearchTool.d.mts +6 -6
- package/dist/web-search/WebSearchTool.d.mts.map +1 -1
- package/dist/web-search/WebSearchTool.mjs +1 -1
- package/dist/web-search/WebSearchTool.mjs.map +1 -1
- package/package.json +16 -4
- package/src/chunker/Chunker.ts +34 -0
- package/src/index.ts +3 -0
- package/src/loop/Loop.test.ts +13 -14
- package/src/loop/Loop.ts +74 -76
- package/src/reranker/Reranker.ts +51 -0
- package/src/testing/MockProvider.ts +8 -9
- package/src/tokenizer/Tokenizer.ts +19 -0
- package/src/tool/Tool.ts +13 -13
- package/dist/AiError-Bf1pq4BB.d.mts.map +0 -1
- package/dist/Audio-CR7CSljJ.d.mts.map +0 -1
- package/dist/Image-C4vuBmu0.d.mts.map +0 -1
- package/dist/Items-BKQgqJ8A.d.mts.map +0 -1
- package/dist/Loop-D8nWpowc.d.mts.map +0 -1
- package/dist/Media-D_CpcM1Z.d.mts.map +0 -1
- package/dist/SandboxError-CIrVDOMV.d.mts.map +0 -1
- package/dist/StructuredFormat-DHaUJBdd.d.mts.map +0 -1
- package/dist/Tool-u5bag8SO.d.mts.map +0 -1
- package/dist/ToolEvent-BBfOdhF_.d.mts.map +0 -1
- package/dist/ToolResult-CRpmkBXR.d.mts.map +0 -1
- package/dist/Toolkit-D4mQvhjq.d.mts.map +0 -1
- package/dist/dist-C0m0QnUP.mjs.map +0 -1
- package/dist/dist-CcRV3-A5.mjs.map +0 -1
- /package/dist/{chunk-uyGKjUfl.mjs → rolldown-runtime-EAsCxrDo.mjs} +0 -0
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { a as SandboxError } from "../SandboxError-
|
|
1
|
+
import { a as SandboxError } from "../SandboxError-BN8b28Bh.mjs";
|
|
2
2
|
import { Brand, Context, Data, Duration, Effect, Redacted, Scope, Stream } from "effect";
|
|
3
|
-
import * as _$effect_Unify0 from "effect/Unify";
|
|
4
|
-
|
|
5
|
-
//#region src/sandbox/Sandbox.d.ts
|
|
6
3
|
declare namespace Sandbox_d_exports {
|
|
7
4
|
export { BoundSecret, CommonCreateRequest, CommonExecRequest, CommonSpawnRequest, ExecEvent, ExecResult, FileEntry, FileEntryKind, ImageRef, NetworkPolicy, ProcessHandle, Sandbox, SandboxCustomImage, SandboxFilesystem, SandboxHostnameAllowlist, SandboxId, SandboxInstance, SandboxKernelSession, SandboxPauseResume, SandboxPortExposure, SandboxPortsApi, SandboxPty, SandboxRef, SandboxSecretInjection, SandboxService, SandboxSnapshots, SandboxSnapshotsApi, SandboxVolumes, SandboxVolumesApi, SnapshotId, VolumeId, VolumeMount, attach, create, createVolume, destroy, destroySnapshot, destroyVolume, exposePort, list, listSnapshots, listVolumes, snapshot };
|
|
8
5
|
}
|
|
@@ -58,23 +55,13 @@ type ImageRef = Data.TaggedEnum<{
|
|
|
58
55
|
};
|
|
59
56
|
}>;
|
|
60
57
|
declare const ImageRef: {
|
|
61
|
-
readonly Default:
|
|
58
|
+
readonly $is: <Tag extends "Default" | "Dockerfile" | "Registry" | "Snapshot">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
62
59
|
readonly _tag: "Default";
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
readonly ref: string;
|
|
67
|
-
}, "_tag">;
|
|
68
|
-
readonly Snapshot: Data.TaggedEnum.ConstructorFrom<{
|
|
69
|
-
readonly _tag: "Snapshot";
|
|
70
|
-
readonly id: SnapshotId;
|
|
71
|
-
}, "_tag">;
|
|
72
|
-
readonly Dockerfile: Data.TaggedEnum.ConstructorFrom<{
|
|
60
|
+
}, {
|
|
61
|
+
readonly _tag: Tag;
|
|
62
|
+
}> | Extract<{
|
|
73
63
|
readonly _tag: "Dockerfile";
|
|
74
64
|
readonly contents: string;
|
|
75
|
-
}, "_tag">;
|
|
76
|
-
readonly $is: <Tag extends "Default" | "Registry" | "Snapshot" | "Dockerfile">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
77
|
-
readonly _tag: "Default";
|
|
78
65
|
}, {
|
|
79
66
|
readonly _tag: Tag;
|
|
80
67
|
}> | Extract<{
|
|
@@ -87,70 +74,74 @@ declare const ImageRef: {
|
|
|
87
74
|
readonly id: SnapshotId;
|
|
88
75
|
}, {
|
|
89
76
|
readonly _tag: Tag;
|
|
90
|
-
}> | Extract<{
|
|
91
|
-
readonly _tag: "Dockerfile";
|
|
92
|
-
readonly contents: string;
|
|
93
|
-
}, {
|
|
94
|
-
readonly _tag: Tag;
|
|
95
77
|
}>;
|
|
96
78
|
readonly $match: {
|
|
97
|
-
<Cases extends {
|
|
98
|
-
readonly Default: (args: {
|
|
99
|
-
readonly _tag: "Default";
|
|
100
|
-
}) => any;
|
|
101
|
-
readonly Registry: (args: {
|
|
102
|
-
readonly _tag: "Registry";
|
|
103
|
-
readonly ref: string;
|
|
104
|
-
}) => any;
|
|
105
|
-
readonly Snapshot: (args: {
|
|
106
|
-
readonly _tag: "Snapshot";
|
|
107
|
-
readonly id: SnapshotId;
|
|
108
|
-
}) => any;
|
|
109
|
-
readonly Dockerfile: (args: {
|
|
110
|
-
readonly _tag: "Dockerfile";
|
|
111
|
-
readonly contents: string;
|
|
112
|
-
}) => any;
|
|
113
|
-
}>(cases: Cases): (value: {
|
|
79
|
+
<Cases extends { readonly [Tag in "Default" | "Dockerfile" | "Registry" | "Snapshot"]: (args: Extract<{
|
|
114
80
|
readonly _tag: "Default";
|
|
81
|
+
} | {
|
|
82
|
+
readonly _tag: "Dockerfile";
|
|
83
|
+
readonly contents: string;
|
|
115
84
|
} | {
|
|
116
85
|
readonly _tag: "Registry";
|
|
117
86
|
readonly ref: string;
|
|
118
87
|
} | {
|
|
119
88
|
readonly _tag: "Snapshot";
|
|
120
89
|
readonly id: SnapshotId;
|
|
90
|
+
}, {
|
|
91
|
+
readonly _tag: Tag;
|
|
92
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
93
|
+
readonly _tag: "Default";
|
|
121
94
|
} | {
|
|
122
95
|
readonly _tag: "Dockerfile";
|
|
123
96
|
readonly contents: string;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
readonly
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
readonly
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}) => any;
|
|
133
|
-
readonly Snapshot: (args: {
|
|
134
|
-
readonly _tag: "Snapshot";
|
|
135
|
-
readonly id: SnapshotId;
|
|
136
|
-
}) => any;
|
|
137
|
-
readonly Dockerfile: (args: {
|
|
138
|
-
readonly _tag: "Dockerfile";
|
|
139
|
-
readonly contents: string;
|
|
140
|
-
}) => any;
|
|
141
|
-
}>(value: {
|
|
97
|
+
} | {
|
|
98
|
+
readonly _tag: "Registry";
|
|
99
|
+
readonly ref: string;
|
|
100
|
+
} | {
|
|
101
|
+
readonly _tag: "Snapshot";
|
|
102
|
+
readonly id: SnapshotId;
|
|
103
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["Default" | "Dockerfile" | "Registry" | "Snapshot"]>>;
|
|
104
|
+
<Cases extends { readonly [Tag in "Default" | "Dockerfile" | "Registry" | "Snapshot"]: (args: Extract<{
|
|
142
105
|
readonly _tag: "Default";
|
|
106
|
+
} | {
|
|
107
|
+
readonly _tag: "Dockerfile";
|
|
108
|
+
readonly contents: string;
|
|
143
109
|
} | {
|
|
144
110
|
readonly _tag: "Registry";
|
|
145
111
|
readonly ref: string;
|
|
146
112
|
} | {
|
|
147
113
|
readonly _tag: "Snapshot";
|
|
148
114
|
readonly id: SnapshotId;
|
|
115
|
+
}, {
|
|
116
|
+
readonly _tag: Tag;
|
|
117
|
+
}>) => any; }>(value: {
|
|
118
|
+
readonly _tag: "Default";
|
|
149
119
|
} | {
|
|
150
120
|
readonly _tag: "Dockerfile";
|
|
151
121
|
readonly contents: string;
|
|
152
|
-
}
|
|
122
|
+
} | {
|
|
123
|
+
readonly _tag: "Registry";
|
|
124
|
+
readonly ref: string;
|
|
125
|
+
} | {
|
|
126
|
+
readonly _tag: "Snapshot";
|
|
127
|
+
readonly id: SnapshotId;
|
|
128
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Default" | "Dockerfile" | "Registry" | "Snapshot"]>>;
|
|
153
129
|
};
|
|
130
|
+
readonly Default: Data.TaggedEnum.ConstructorFrom<{
|
|
131
|
+
readonly _tag: "Default";
|
|
132
|
+
}, "_tag">;
|
|
133
|
+
readonly Dockerfile: Data.TaggedEnum.ConstructorFrom<{
|
|
134
|
+
readonly _tag: "Dockerfile";
|
|
135
|
+
readonly contents: string;
|
|
136
|
+
}, "_tag">;
|
|
137
|
+
readonly Registry: Data.TaggedEnum.ConstructorFrom<{
|
|
138
|
+
readonly _tag: "Registry";
|
|
139
|
+
readonly ref: string;
|
|
140
|
+
}, "_tag">;
|
|
141
|
+
readonly Snapshot: Data.TaggedEnum.ConstructorFrom<{
|
|
142
|
+
readonly _tag: "Snapshot";
|
|
143
|
+
readonly id: SnapshotId;
|
|
144
|
+
}, "_tag">;
|
|
154
145
|
};
|
|
155
146
|
/**
|
|
156
147
|
* Outbound network policy for a sandbox.
|
|
@@ -173,19 +164,10 @@ type NetworkPolicy = Data.TaggedEnum<{
|
|
|
173
164
|
};
|
|
174
165
|
}>;
|
|
175
166
|
declare const NetworkPolicy: {
|
|
176
|
-
readonly Open:
|
|
177
|
-
readonly _tag: "Open";
|
|
178
|
-
}, "_tag">;
|
|
179
|
-
readonly Blocked: Data.TaggedEnum.ConstructorFrom<{
|
|
180
|
-
readonly _tag: "Blocked";
|
|
181
|
-
}, "_tag">;
|
|
182
|
-
readonly Allowlist: Data.TaggedEnum.ConstructorFrom<{
|
|
167
|
+
readonly $is: <Tag extends "Allowlist" | "Blocked" | "Open">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
183
168
|
readonly _tag: "Allowlist";
|
|
184
169
|
readonly hosts?: ReadonlyArray<string>;
|
|
185
170
|
readonly cidrs?: ReadonlyArray<string>;
|
|
186
|
-
}, "_tag">;
|
|
187
|
-
readonly $is: <Tag extends "Open" | "Blocked" | "Allowlist">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
188
|
-
readonly _tag: "Open";
|
|
189
171
|
}, {
|
|
190
172
|
readonly _tag: Tag;
|
|
191
173
|
}> | Extract<{
|
|
@@ -193,56 +175,61 @@ declare const NetworkPolicy: {
|
|
|
193
175
|
}, {
|
|
194
176
|
readonly _tag: Tag;
|
|
195
177
|
}> | Extract<{
|
|
196
|
-
readonly _tag: "
|
|
197
|
-
readonly hosts?: ReadonlyArray<string>;
|
|
198
|
-
readonly cidrs?: ReadonlyArray<string>;
|
|
178
|
+
readonly _tag: "Open";
|
|
199
179
|
}, {
|
|
200
180
|
readonly _tag: Tag;
|
|
201
181
|
}>;
|
|
202
182
|
readonly $match: {
|
|
203
|
-
<Cases extends {
|
|
204
|
-
readonly
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
readonly Blocked: (args: {
|
|
208
|
-
readonly _tag: "Blocked";
|
|
209
|
-
}) => any;
|
|
210
|
-
readonly Allowlist: (args: {
|
|
211
|
-
readonly _tag: "Allowlist";
|
|
212
|
-
readonly hosts?: ReadonlyArray<string>;
|
|
213
|
-
readonly cidrs?: ReadonlyArray<string>;
|
|
214
|
-
}) => any;
|
|
215
|
-
}>(cases: Cases): (value: {
|
|
216
|
-
readonly _tag: "Open";
|
|
183
|
+
<Cases extends { readonly [Tag in "Allowlist" | "Blocked" | "Open"]: (args: Extract<{
|
|
184
|
+
readonly _tag: "Allowlist";
|
|
185
|
+
readonly hosts?: ReadonlyArray<string>;
|
|
186
|
+
readonly cidrs?: ReadonlyArray<string>;
|
|
217
187
|
} | {
|
|
218
188
|
readonly _tag: "Blocked";
|
|
219
189
|
} | {
|
|
190
|
+
readonly _tag: "Open";
|
|
191
|
+
}, {
|
|
192
|
+
readonly _tag: Tag;
|
|
193
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
220
194
|
readonly _tag: "Allowlist";
|
|
221
195
|
readonly hosts?: ReadonlyArray<string>;
|
|
222
196
|
readonly cidrs?: ReadonlyArray<string>;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
readonly _tag: "Open";
|
|
227
|
-
}) => any;
|
|
228
|
-
readonly Blocked: (args: {
|
|
229
|
-
readonly _tag: "Blocked";
|
|
230
|
-
}) => any;
|
|
231
|
-
readonly Allowlist: (args: {
|
|
232
|
-
readonly _tag: "Allowlist";
|
|
233
|
-
readonly hosts?: ReadonlyArray<string>;
|
|
234
|
-
readonly cidrs?: ReadonlyArray<string>;
|
|
235
|
-
}) => any;
|
|
236
|
-
}>(value: {
|
|
197
|
+
} | {
|
|
198
|
+
readonly _tag: "Blocked";
|
|
199
|
+
} | {
|
|
237
200
|
readonly _tag: "Open";
|
|
201
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["Allowlist" | "Blocked" | "Open"]>>;
|
|
202
|
+
<Cases extends { readonly [Tag in "Allowlist" | "Blocked" | "Open"]: (args: Extract<{
|
|
203
|
+
readonly _tag: "Allowlist";
|
|
204
|
+
readonly hosts?: ReadonlyArray<string>;
|
|
205
|
+
readonly cidrs?: ReadonlyArray<string>;
|
|
238
206
|
} | {
|
|
239
207
|
readonly _tag: "Blocked";
|
|
240
208
|
} | {
|
|
209
|
+
readonly _tag: "Open";
|
|
210
|
+
}, {
|
|
211
|
+
readonly _tag: Tag;
|
|
212
|
+
}>) => any; }>(value: {
|
|
241
213
|
readonly _tag: "Allowlist";
|
|
242
214
|
readonly hosts?: ReadonlyArray<string>;
|
|
243
215
|
readonly cidrs?: ReadonlyArray<string>;
|
|
244
|
-
}
|
|
216
|
+
} | {
|
|
217
|
+
readonly _tag: "Blocked";
|
|
218
|
+
} | {
|
|
219
|
+
readonly _tag: "Open";
|
|
220
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Allowlist" | "Blocked" | "Open"]>>;
|
|
245
221
|
};
|
|
222
|
+
readonly Allowlist: Data.TaggedEnum.ConstructorFrom<{
|
|
223
|
+
readonly _tag: "Allowlist";
|
|
224
|
+
readonly hosts?: ReadonlyArray<string>;
|
|
225
|
+
readonly cidrs?: ReadonlyArray<string>;
|
|
226
|
+
}, "_tag">;
|
|
227
|
+
readonly Blocked: Data.TaggedEnum.ConstructorFrom<{
|
|
228
|
+
readonly _tag: "Blocked";
|
|
229
|
+
}, "_tag">;
|
|
230
|
+
readonly Open: Data.TaggedEnum.ConstructorFrom<{
|
|
231
|
+
readonly _tag: "Open";
|
|
232
|
+
}, "_tag">;
|
|
246
233
|
};
|
|
247
234
|
/**
|
|
248
235
|
* A secret bound to a sandbox at create time. The code inside the
|
|
@@ -284,7 +271,8 @@ type VolumeMount = {
|
|
|
284
271
|
* footgun we're avoiding.
|
|
285
272
|
*/
|
|
286
273
|
type CommonCreateRequest = {
|
|
287
|
-
/** Image / snapshot to boot from. Omit for the provider's default. */
|
|
274
|
+
/** Image / snapshot to boot from. Omit for the provider's default. */
|
|
275
|
+
readonly image?: ImageRef;
|
|
288
276
|
/**
|
|
289
277
|
* Idle / hard timeout. Accepts a number (millis), a string like
|
|
290
278
|
* `"30 seconds"`, or a `Duration`. Providers default differently.
|
|
@@ -294,7 +282,8 @@ type CommonCreateRequest = {
|
|
|
294
282
|
* Env vars exposed to the sandbox. NOT for secrets you want hidden
|
|
295
283
|
* from the running code — use {@link BoundSecret} instead.
|
|
296
284
|
*/
|
|
297
|
-
readonly env?: Readonly<Record<string, string>>;
|
|
285
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
286
|
+
/** Outbound network policy. */
|
|
298
287
|
readonly network?: NetworkPolicy;
|
|
299
288
|
/**
|
|
300
289
|
* Bound secrets — code inside the sandbox sees a placeholder; the
|
|
@@ -364,22 +353,10 @@ type ExecEvent = Data.TaggedEnum<{
|
|
|
364
353
|
};
|
|
365
354
|
}>;
|
|
366
355
|
declare const ExecEvent: {
|
|
367
|
-
readonly Stdout:
|
|
368
|
-
readonly _tag: "Stdout";
|
|
369
|
-
readonly chunk: Uint8Array;
|
|
370
|
-
}, "_tag">;
|
|
371
|
-
readonly Stderr: Data.TaggedEnum.ConstructorFrom<{
|
|
372
|
-
readonly _tag: "Stderr";
|
|
373
|
-
readonly chunk: Uint8Array;
|
|
374
|
-
}, "_tag">;
|
|
375
|
-
readonly Complete: Data.TaggedEnum.ConstructorFrom<{
|
|
356
|
+
readonly $is: <Tag extends "Complete" | "Stderr" | "Stdout">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
376
357
|
readonly _tag: "Complete";
|
|
377
358
|
readonly exitCode: number;
|
|
378
359
|
readonly durationMs: number;
|
|
379
|
-
}, "_tag">;
|
|
380
|
-
readonly $is: <Tag extends "Stdout" | "Stderr" | "Complete">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
381
|
-
readonly _tag: "Stdout";
|
|
382
|
-
readonly chunk: Uint8Array;
|
|
383
360
|
}, {
|
|
384
361
|
readonly _tag: Tag;
|
|
385
362
|
}> | Extract<{
|
|
@@ -388,64 +365,72 @@ declare const ExecEvent: {
|
|
|
388
365
|
}, {
|
|
389
366
|
readonly _tag: Tag;
|
|
390
367
|
}> | Extract<{
|
|
391
|
-
readonly _tag: "
|
|
392
|
-
readonly
|
|
393
|
-
readonly durationMs: number;
|
|
368
|
+
readonly _tag: "Stdout";
|
|
369
|
+
readonly chunk: Uint8Array;
|
|
394
370
|
}, {
|
|
395
371
|
readonly _tag: Tag;
|
|
396
372
|
}>;
|
|
397
373
|
readonly $match: {
|
|
398
|
-
<Cases extends {
|
|
399
|
-
readonly
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}) => any;
|
|
403
|
-
readonly Stderr: (args: {
|
|
404
|
-
readonly _tag: "Stderr";
|
|
405
|
-
readonly chunk: Uint8Array;
|
|
406
|
-
}) => any;
|
|
407
|
-
readonly Complete: (args: {
|
|
408
|
-
readonly _tag: "Complete";
|
|
409
|
-
readonly exitCode: number;
|
|
410
|
-
readonly durationMs: number;
|
|
411
|
-
}) => any;
|
|
412
|
-
}>(cases: Cases): (value: {
|
|
413
|
-
readonly _tag: "Stdout";
|
|
414
|
-
readonly chunk: Uint8Array;
|
|
374
|
+
<Cases extends { readonly [Tag in "Complete" | "Stderr" | "Stdout"]: (args: Extract<{
|
|
375
|
+
readonly _tag: "Complete";
|
|
376
|
+
readonly exitCode: number;
|
|
377
|
+
readonly durationMs: number;
|
|
415
378
|
} | {
|
|
416
379
|
readonly _tag: "Stderr";
|
|
417
380
|
readonly chunk: Uint8Array;
|
|
418
381
|
} | {
|
|
382
|
+
readonly _tag: "Stdout";
|
|
383
|
+
readonly chunk: Uint8Array;
|
|
384
|
+
}, {
|
|
385
|
+
readonly _tag: Tag;
|
|
386
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
419
387
|
readonly _tag: "Complete";
|
|
420
388
|
readonly exitCode: number;
|
|
421
389
|
readonly durationMs: number;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
readonly
|
|
425
|
-
|
|
426
|
-
readonly chunk: Uint8Array;
|
|
427
|
-
}) => any;
|
|
428
|
-
readonly Stderr: (args: {
|
|
429
|
-
readonly _tag: "Stderr";
|
|
430
|
-
readonly chunk: Uint8Array;
|
|
431
|
-
}) => any;
|
|
432
|
-
readonly Complete: (args: {
|
|
433
|
-
readonly _tag: "Complete";
|
|
434
|
-
readonly exitCode: number;
|
|
435
|
-
readonly durationMs: number;
|
|
436
|
-
}) => any;
|
|
437
|
-
}>(value: {
|
|
390
|
+
} | {
|
|
391
|
+
readonly _tag: "Stderr";
|
|
392
|
+
readonly chunk: Uint8Array;
|
|
393
|
+
} | {
|
|
438
394
|
readonly _tag: "Stdout";
|
|
439
395
|
readonly chunk: Uint8Array;
|
|
396
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["Complete" | "Stderr" | "Stdout"]>>;
|
|
397
|
+
<Cases extends { readonly [Tag in "Complete" | "Stderr" | "Stdout"]: (args: Extract<{
|
|
398
|
+
readonly _tag: "Complete";
|
|
399
|
+
readonly exitCode: number;
|
|
400
|
+
readonly durationMs: number;
|
|
440
401
|
} | {
|
|
441
402
|
readonly _tag: "Stderr";
|
|
442
403
|
readonly chunk: Uint8Array;
|
|
443
404
|
} | {
|
|
405
|
+
readonly _tag: "Stdout";
|
|
406
|
+
readonly chunk: Uint8Array;
|
|
407
|
+
}, {
|
|
408
|
+
readonly _tag: Tag;
|
|
409
|
+
}>) => any; }>(value: {
|
|
444
410
|
readonly _tag: "Complete";
|
|
445
411
|
readonly exitCode: number;
|
|
446
412
|
readonly durationMs: number;
|
|
447
|
-
}
|
|
413
|
+
} | {
|
|
414
|
+
readonly _tag: "Stderr";
|
|
415
|
+
readonly chunk: Uint8Array;
|
|
416
|
+
} | {
|
|
417
|
+
readonly _tag: "Stdout";
|
|
418
|
+
readonly chunk: Uint8Array;
|
|
419
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Complete" | "Stderr" | "Stdout"]>>;
|
|
448
420
|
};
|
|
421
|
+
readonly Complete: Data.TaggedEnum.ConstructorFrom<{
|
|
422
|
+
readonly _tag: "Complete";
|
|
423
|
+
readonly exitCode: number;
|
|
424
|
+
readonly durationMs: number;
|
|
425
|
+
}, "_tag">;
|
|
426
|
+
readonly Stderr: Data.TaggedEnum.ConstructorFrom<{
|
|
427
|
+
readonly _tag: "Stderr";
|
|
428
|
+
readonly chunk: Uint8Array;
|
|
429
|
+
}, "_tag">;
|
|
430
|
+
readonly Stdout: Data.TaggedEnum.ConstructorFrom<{
|
|
431
|
+
readonly _tag: "Stdout";
|
|
432
|
+
readonly chunk: Uint8Array;
|
|
433
|
+
}, "_tag">;
|
|
449
434
|
};
|
|
450
435
|
type FileEntryKind = "file" | "directory" | "symlink" | "other";
|
|
451
436
|
type FileEntry = {
|
|
@@ -565,9 +550,12 @@ type SandboxService = {
|
|
|
565
550
|
* Escape hatch for destroying a sandbox from outside its owning
|
|
566
551
|
* scope. Most callers should let the scope finalizer handle this.
|
|
567
552
|
*/
|
|
568
|
-
readonly destroy: (id: SandboxId) => Effect.Effect<void, SandboxError>;
|
|
569
|
-
|
|
570
|
-
readonly
|
|
553
|
+
readonly destroy: (id: SandboxId) => Effect.Effect<void, SandboxError>;
|
|
554
|
+
/** Snapshot management. Capability-gated on {@link SandboxSnapshots}. */
|
|
555
|
+
readonly snapshots: SandboxSnapshotsApi;
|
|
556
|
+
/** Volume management. Capability-gated on {@link SandboxVolumes}. */
|
|
557
|
+
readonly volumes: SandboxVolumesApi;
|
|
558
|
+
/** Port exposure. Capability-gated on {@link SandboxPortExposure}. */
|
|
571
559
|
readonly ports: SandboxPortsApi;
|
|
572
560
|
};
|
|
573
561
|
declare const Sandbox_base: Context.ServiceClass<Sandbox, "@betalyra/effect-uai/Sandbox", SandboxService>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sandbox.d.mts","names":[],"sources":["../../src/sandbox/Sandbox.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Sandbox.d.mts","names":[],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-runtime-EAsCxrDo.mjs";
|
|
2
2
|
import { Brand, Context, Data, Effect } from "effect";
|
|
3
3
|
//#region src/sandbox/Sandbox.ts
|
|
4
4
|
var Sandbox_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sandbox.mjs","names":[],"sources":["../../src/sandbox/Sandbox.ts"],"sourcesContent":["import { Brand, Context, Data, type Duration, Effect, Redacted, Scope, Stream } from \"effect\"\nimport type * as SandboxError from \"./SandboxError.js\"\n\n// ---------------------------------------------------------------------------\n// Identity\n// ---------------------------------------------------------------------------\n\n/**\n * Sandbox identifier. Branded `string` so providers don't accidentally\n * accept a raw user-supplied id. Each provider mints these per its own\n * naming scheme (uuid for E2B/Vercel, user-supplied name for\n * Microsandbox/Modal, …); the core code treats them opaquely.\n *\n * Mint via the value-level `SandboxId(...)` smart constructor instead\n * of `as SandboxId` casts.\n */\nexport type SandboxId = Brand.Branded<string, \"SandboxId\">\nexport const SandboxId = Brand.nominal<SandboxId>()\n\n/**\n * Reference returned by `list`. Carries just enough to call `attach` —\n * provider-specific metadata (createdAt, region, tags, …) lives on the\n * narrowed per-provider ref.\n */\nexport type SandboxRef = {\n readonly id: SandboxId\n readonly name?: string\n}\n\nexport type VolumeId = Brand.Branded<string, \"VolumeId\">\nexport const VolumeId = Brand.nominal<VolumeId>()\n\nexport type SnapshotId = Brand.Branded<string, \"SnapshotId\">\nexport const SnapshotId = Brand.nominal<SnapshotId>()\n\n// ---------------------------------------------------------------------------\n// Image / runtime selection\n// ---------------------------------------------------------------------------\n\n/**\n * What runtime / filesystem to boot the sandbox from.\n *\n * - `Default` — provider picks its house image (Vercel: Amazon Linux\n * 2023; Microsandbox: requires user image but a builder default may\n * apply, …). Use when you don't care what's pre-installed.\n * - `Registry` — an OCI image reference. Supported by every provider\n * except those with a fixed base (Vercel ignores this and the\n * request-schema rejects at decode).\n * - `Snapshot` — restore from a captured state. Gated by\n * {@link SandboxSnapshots} at the call site — the marker is provided\n * by adapters whose provider supports snapshot-as-image.\n * - `Dockerfile` — provider builds a custom image from a Dockerfile.\n * Gated by {@link SandboxCustomImage}.\n */\nexport type ImageRef = Data.TaggedEnum<{\n Default: {}\n Registry: { readonly ref: string }\n Snapshot: { readonly id: SnapshotId }\n Dockerfile: { readonly contents: string }\n}>\n\nexport const ImageRef = Data.taggedEnum<ImageRef>()\n\n// ---------------------------------------------------------------------------\n// Network policy + secrets\n// ---------------------------------------------------------------------------\n\n/**\n * Outbound network policy for a sandbox.\n *\n * - `Open` — no egress restriction. The provider's defaults apply\n * (e.g. Microsandbox's \"public-only\" still blocks private ranges).\n * - `Blocked` — fully airgapped, no outbound connectivity at all.\n * - `Allowlist` — only the listed hosts / CIDRs may be reached.\n *\n * Providers vary in what they honour: hostname-allowlist requires\n * {@link SandboxHostnameAllowlist}; CIDR-only providers ignore `hosts`\n * and the adapter rejects at decode if `hosts` is non-empty.\n */\nexport type NetworkPolicy = Data.TaggedEnum<{\n Open: {}\n Blocked: {}\n Allowlist: {\n readonly hosts?: ReadonlyArray<string>\n readonly cidrs?: ReadonlyArray<string>\n }\n}>\n\nexport const NetworkPolicy = Data.taggedEnum<NetworkPolicy>()\n\n/**\n * A secret bound to a sandbox at create time. The code inside the\n * sandbox sees only a placeholder (`$MSB_<NAME>` for Microsandbox,\n * `{name}` for Vercel header-injection, etc.); the real `value` lives\n * on the provider's proxy and is substituted on outbound HTTPS to\n * `hosts`.\n *\n * Requires the {@link SandboxSecretInjection} capability marker —\n * provider Layers without proxy-layer secret rewriting do not ship the\n * marker and consumer code fails at `Effect.provide` with a type\n * error.\n *\n * `header` is the request header to inject (default\n * `\"Authorization: Bearer <value>\"`). Providers that do not let\n * callers pick the header (Microsandbox's `secretEnv` shorthand)\n * silently ignore this field; providers that require an explicit\n * header (Vercel's `transform.headers`) fail at decode if it's absent.\n */\nexport type BoundSecret = {\n readonly name: string\n readonly value: Redacted.Redacted<string>\n readonly hosts: ReadonlyArray<string>\n readonly header?: string\n}\n\n// ---------------------------------------------------------------------------\n// Volumes (capability-gated on `SandboxVolumes`)\n// ---------------------------------------------------------------------------\n\nexport type VolumeMount = {\n readonly id: VolumeId\n readonly mountPath: string\n readonly readonly?: boolean\n}\n\n// ---------------------------------------------------------------------------\n// Create / exec request shapes\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-provider create request. Provider-specific knobs (region,\n * cpus, memory, template id, …) live on each provider's narrowed\n * request type which extends this.\n *\n * Fields a provider can't honour fail at **decode time** (per the\n * per-provider request schema), not silently at runtime. The\n * ComputeSDK anti-pattern of \"drop unsupported fields\" is the\n * footgun we're avoiding.\n */\nexport type CommonCreateRequest = {\n /** Image / snapshot to boot from. Omit for the provider's default. */\n readonly image?: ImageRef\n /**\n * Idle / hard timeout. Accepts a number (millis), a string like\n * `\"30 seconds\"`, or a `Duration`. Providers default differently.\n */\n readonly timeout?: Duration.Input\n /**\n * Env vars exposed to the sandbox. NOT for secrets you want hidden\n * from the running code — use {@link BoundSecret} instead.\n */\n readonly env?: Readonly<Record<string, string>>\n /** Outbound network policy. */\n readonly network?: NetworkPolicy\n /**\n * Bound secrets — code inside the sandbox sees a placeholder; the\n * proxy substitutes the real value on outbound HTTPS to listed hosts.\n * Capability-gated on {@link SandboxSecretInjection}.\n */\n readonly secrets?: ReadonlyArray<BoundSecret>\n /**\n * Persistent volumes to mount. Volumes are created via\n * `Sandbox.volumes.create` and survive sandbox lifetime.\n * Capability-gated on {@link SandboxVolumes}.\n */\n readonly volumes?: ReadonlyArray<VolumeMount>\n}\n\n/**\n * Cross-provider exec request. Background / long-running processes\n * use `spawn` instead of `exec`; the semantics differ enough that\n * overloading `exec` with a `detached` flag was rejected during\n * design.\n */\nexport type CommonExecRequest = {\n /**\n * Argv-style command. Pass a string for \"run this through the\n * shell\" semantics (provider-dependent — most use `sh -c`); pass\n * an array for direct argv with no shell parsing.\n */\n readonly cmd: string | ReadonlyArray<string>\n readonly cwd?: string\n readonly env?: Readonly<Record<string, string>>\n readonly stdin?: string | Uint8Array\n /**\n * Per-exec timeout. Accepts a number (millis), a string like\n * `\"5 seconds\"`, or a `Duration`.\n */\n readonly timeout?: Duration.Input\n}\n\n/**\n * Spawn request — extends {@link CommonExecRequest} with the option\n * to provide stdin as a `Stream<Uint8Array>`. The provider takes one\n * chunk at a time and sends EOF when the stream completes. Useful\n * for piping LLM output into a sandboxed process, or feeding stdin\n * from another stream source. `exec` does not accept streams.\n */\nexport type CommonSpawnRequest = Omit<CommonExecRequest, \"stdin\"> & {\n readonly stdin?: string | Uint8Array | Stream.Stream<Uint8Array, never, never>\n}\n\nexport type ExecResult = {\n readonly exitCode: number\n readonly stdout: string\n readonly stderr: string\n readonly durationMs: number\n}\n\n/**\n * Streaming exec output. `Complete` is terminal — the stream\n * completes after emitting it.\n */\nexport type ExecEvent = Data.TaggedEnum<{\n Stdout: { readonly chunk: Uint8Array }\n Stderr: { readonly chunk: Uint8Array }\n Complete: { readonly exitCode: number; readonly durationMs: number }\n}>\n\nexport const ExecEvent = Data.taggedEnum<ExecEvent>()\n\n// ---------------------------------------------------------------------------\n// Filesystem\n// ---------------------------------------------------------------------------\n\nexport type FileEntryKind = \"file\" | \"directory\" | \"symlink\" | \"other\"\n\nexport type FileEntry = {\n readonly path: string\n readonly kind: FileEntryKind\n}\n\nexport type SandboxFilesystem = {\n readonly read: (path: string) => Effect.Effect<Uint8Array, SandboxError.SandboxError>\n readonly write: (\n path: string,\n contents: Uint8Array | string,\n ) => Effect.Effect<void, SandboxError.SandboxError>\n readonly remove: (path: string) => Effect.Effect<void, SandboxError.SandboxError>\n readonly mkdir: (path: string) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: (\n path: string,\n ) => Effect.Effect<ReadonlyArray<FileEntry>, SandboxError.SandboxError>\n readonly exists: (path: string) => Effect.Effect<boolean, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// Process handle (returned by `spawn`)\n// ---------------------------------------------------------------------------\n\n/**\n * Long-running process handle. Returned by `spawn` in a `Scope.Scope`\n * — the process is killed on scope close. To outlive the calling\n * scope, do `Effect.forkScoped` against a wider scope or use\n * `attach`-style reconnection per the provider's escape hatch.\n */\nexport type ProcessHandle = {\n readonly pid: number\n readonly events: Stream.Stream<ExecEvent, SandboxError.SandboxError>\n readonly kill: Effect.Effect<void, SandboxError.SandboxError>\n readonly exit: Effect.Effect<{ readonly exitCode: number }, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// SandboxInstance — the live handle returned from `create` / `attach`\n// ---------------------------------------------------------------------------\n\n/**\n * Live sandbox handle. Methods are plain `Effect` / `Stream` values\n * — no nullary thunks (`destroy()`, `pause()`) — to match Effect's\n * `Queue.shutdown` / `Fiber.interrupt` style. Destruction is the\n * scope finalizer, not a method here; for the rare \"kill from\n * another fiber\" case use the service-level escape hatch\n * `Sandbox.destroy(id)`.\n */\nexport type SandboxInstance = {\n readonly id: SandboxId\n readonly exec: (\n request: CommonExecRequest,\n ) => Effect.Effect<ExecResult, SandboxError.SandboxError>\n readonly execStream: (\n request: CommonExecRequest,\n ) => Stream.Stream<ExecEvent, SandboxError.SandboxError>\n /**\n * Spawn a background / long-running process. The returned handle is\n * scoped — the process is killed on scope close. Use this for\n * \"dev server / watcher / tail -f\" workloads. For one-shot\n * commands prefer `exec`.\n */\n readonly spawn: (\n request: CommonSpawnRequest,\n ) => Effect.Effect<ProcessHandle, SandboxError.SandboxError, Scope.Scope>\n readonly files: SandboxFilesystem\n}\n\n// ---------------------------------------------------------------------------\n// Snapshot / volume / port sub-services (capability-gated)\n// ---------------------------------------------------------------------------\n\nexport type SandboxSnapshotsApi = {\n readonly create: (\n from: SandboxInstance,\n name?: string,\n ) => Effect.Effect<SnapshotId, SandboxError.SandboxError>\n readonly destroy: (id: SnapshotId) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: Effect.Effect<\n ReadonlyArray<{ readonly id: SnapshotId; readonly name?: string }>,\n SandboxError.SandboxError\n >\n}\n\nexport type SandboxVolumesApi = {\n readonly create: (\n name: string,\n options?: { readonly quotaBytes?: number },\n ) => Effect.Effect<VolumeId, SandboxError.SandboxError>\n readonly destroy: (id: VolumeId) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: Effect.Effect<\n ReadonlyArray<{ readonly id: VolumeId; readonly name: string }>,\n SandboxError.SandboxError\n >\n}\n\nexport type SandboxPortsApi = {\n /**\n * Expose an internal sandbox port as a publicly reachable URL.\n * Gated by {@link SandboxPortExposure} on the free helper; adapters\n * that don't ship the marker leave this sub-API out of the public\n * surface entirely (callers can't construct an Effect against it).\n */\n readonly expose: (\n instance: SandboxInstance,\n port: number,\n ) => Effect.Effect<{ readonly url: string }, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// Service definition\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-provider sandbox service.\n *\n * Lifetime model: `create` returns a sandbox handle in `Scope.Scope`.\n * The scope finalizer destroys the sandbox. Use `Effect.scoped` to\n * bound a sandbox's lifetime to a single Effect, or manage the scope\n * explicitly via `Scope.make` for sandboxes that span many calls.\n * This is why there's no `destroy()` method on `SandboxInstance` —\n * the scope is the lifecycle handle.\n *\n * `snapshots` and `volumes` sub-APIs are present on the service but\n * are still capability-gated: provider Layers that don't support\n * them ship implementations that always fail with\n * `SandboxUnsupported`. The free helpers ({@link snapshot},\n * {@link createVolume}) additionally require the corresponding\n * capability marker on R, so misuses surface as type errors at\n * `Effect.provide`, not as runtime failures.\n */\nexport type SandboxService = {\n /**\n * Provision a new sandbox. The returned handle's lifetime is\n * bound to the caller's scope; the sandbox is destroyed on scope\n * close. To survive the scope, use `attach`-style reconnection or\n * promote into a wider scope.\n */\n readonly create: (\n request: CommonCreateRequest,\n ) => Effect.Effect<SandboxInstance, SandboxError.SandboxError, Scope.Scope>\n\n /**\n * Re-acquire an existing sandbox by id. The returned handle is\n * scope-bound but the finalizer is \"detach\" (no destroy) —\n * appropriate for paused / detached / persistent sandboxes that\n * outlive any single agent run.\n */\n readonly attach: (\n id: SandboxId,\n ) => Effect.Effect<SandboxInstance, SandboxError.SandboxError, Scope.Scope>\n\n /**\n * Enumerate sandboxes visible to the configured account / project.\n */\n readonly list: Effect.Effect<ReadonlyArray<SandboxRef>, SandboxError.SandboxError>\n\n /**\n * Escape hatch for destroying a sandbox from outside its owning\n * scope. Most callers should let the scope finalizer handle this.\n */\n readonly destroy: (id: SandboxId) => Effect.Effect<void, SandboxError.SandboxError>\n\n /** Snapshot management. Capability-gated on {@link SandboxSnapshots}. */\n readonly snapshots: SandboxSnapshotsApi\n\n /** Volume management. Capability-gated on {@link SandboxVolumes}. */\n readonly volumes: SandboxVolumesApi\n\n /** Port exposure. Capability-gated on {@link SandboxPortExposure}. */\n readonly ports: SandboxPortsApi\n}\n\nexport class Sandbox extends Context.Service<Sandbox, SandboxService>()(\n \"@betalyra/effect-uai/Sandbox\",\n) {}\n\n// ---------------------------------------------------------------------------\n// Capability markers\n// ---------------------------------------------------------------------------\n\n/**\n * Capability marker — provided by adapter Layers whose provider\n * supports a hostname-level egress allowlist (matching against host\n * names / wildcards, not just CIDRs). Vercel, Cloudflare, Deno,\n * Microsandbox, Runloop, Anthropic srt ship this marker; Modal and\n * Daytona (CIDR-only) do not.\n *\n * Phantom — the value is `void`; adapters register with\n * `Layer.succeed(SandboxHostnameAllowlist, undefined)`.\n */\nexport class SandboxHostnameAllowlist extends Context.Service<SandboxHostnameAllowlist, void>()(\n \"@betalyra/effect-uai/capability/SandboxHostnameAllowlist\",\n) {}\n\n/**\n * Capability marker — adapter's provider supports proxy-layer\n * secret rewriting (header injection on outbound HTTPS to bound\n * hosts; the running code never sees the real value). Deno,\n * Cloudflare, E2B, Vercel (firewall transform), Microsandbox,\n * Runloop (Agent Gateway) ship this. Modal, Daytona, CodeSandbox\n * do not.\n */\nexport class SandboxSecretInjection extends Context.Service<SandboxSecretInjection, void>()(\n \"@betalyra/effect-uai/capability/SandboxSecretInjection\",\n) {}\n\n/**\n * Capability marker — adapter supports snapshot-as-new-sandbox\n * (capture state, restore as a derived sandbox with a fresh id).\n * Distinct from {@link SandboxPauseResume}, which preserves the\n * same id and resumes in place.\n */\nexport class SandboxSnapshots extends Context.Service<SandboxSnapshots, void>()(\n \"@betalyra/effect-uai/capability/SandboxSnapshots\",\n) {}\n\n/**\n * Capability marker — adapter supports in-place pause and resume on\n * the same sandbox id (E2B, CodeSandbox). Memory + processes are\n * preserved across the pause boundary. Most providers without this\n * marker offer {@link SandboxSnapshots} instead.\n */\nexport class SandboxPauseResume extends Context.Service<SandboxPauseResume, void>()(\n \"@betalyra/effect-uai/capability/SandboxPauseResume\",\n) {}\n\n/**\n * Capability marker — adapter manages named persistent volumes\n * outside any single sandbox lifecycle (Modal Volume, Daytona,\n * Microsandbox, BoxLite). Providers without this marker leave\n * `Sandbox.volumes.*` returning `SandboxUnsupported`; the free\n * helpers ({@link createVolume}, {@link destroyVolume}) additionally\n * require this marker on R so misuses become a type error.\n */\nexport class SandboxVolumes extends Context.Service<SandboxVolumes, void>()(\n \"@betalyra/effect-uai/capability/SandboxVolumes\",\n) {}\n\n/**\n * Capability marker — adapter supports a stateful kernel session\n * (Jupyter-style: persistent Python / JS context that returns rich\n * outputs across many `runCode` calls). Cloudflare Code Interpreter\n * and E2B ship this; everyone else expects you to write your own\n * script and `exec` it.\n *\n * The actual `runCode` helper lives separately (not on\n * `SandboxInstance`) because the return shape is different — rich\n * outputs with images/tables, not buffered stdout strings.\n */\nexport class SandboxKernelSession extends Context.Service<SandboxKernelSession, void>()(\n \"@betalyra/effect-uai/capability/SandboxKernelSession\",\n) {}\n\n/**\n * Capability marker — adapter exposes an interactive PTY session\n * (Runloop, Cloudflare terminal). Distinct from `execStream` which\n * is byte-oriented and one-shot.\n */\nexport class SandboxPty extends Context.Service<SandboxPty, void>()(\n \"@betalyra/effect-uai/capability/SandboxPty\",\n) {}\n\n/**\n * Capability marker — adapter accepts a user-supplied Dockerfile (or\n * OCI image build) instead of just a registry reference. Vercel does\n * not ship this (fixed AL2023). Deno does not (snapshots only).\n * Most others do.\n */\nexport class SandboxCustomImage extends Context.Service<SandboxCustomImage, void>()(\n \"@betalyra/effect-uai/capability/SandboxCustomImage\",\n) {}\n\n/**\n * Capability marker — adapter can expose an internal port as a\n * publicly reachable URL. Most cloud providers ship this; local\n * providers (Microsandbox, BoxLite) typically only support\n * host-side port forwarding (handled by ignoring this marker and\n * documenting via the per-provider request type).\n */\nexport class SandboxPortExposure extends Context.Service<SandboxPortExposure, void>()(\n \"@betalyra/effect-uai/capability/SandboxPortExposure\",\n) {}\n\n// ---------------------------------------------------------------------------\n// Free helpers — accept Sandbox via Context, optionally require markers.\n// ---------------------------------------------------------------------------\n\n/**\n * Provision a sandbox bound to the caller's scope. Drop the\n * `Scope.Scope` requirement with `Effect.scoped`.\n */\nexport const create = (\n request: CommonCreateRequest,\n): Effect.Effect<SandboxInstance, SandboxError.SandboxError, Sandbox | Scope.Scope> =>\n Effect.flatMap(Sandbox, (s) => s.create(request))\n\n/**\n * Re-acquire an existing sandbox by id. Same scope semantics as\n * `create`, but the finalizer detaches rather than destroying.\n */\nexport const attach = (\n id: SandboxId,\n): Effect.Effect<SandboxInstance, SandboxError.SandboxError, Sandbox | Scope.Scope> =>\n Effect.flatMap(Sandbox, (s) => s.attach(id))\n\n/** Enumerate sandboxes for the configured account / project. */\nexport const list: Effect.Effect<\n ReadonlyArray<SandboxRef>,\n SandboxError.SandboxError,\n Sandbox\n> = Effect.flatMap(Sandbox, (s) => s.list)\n\n/**\n * Escape hatch for destroying a sandbox from outside its owning\n * scope. Most callers should let the scope finalizer handle this\n * automatically.\n */\nexport const destroy = (id: SandboxId): Effect.Effect<void, SandboxError.SandboxError, Sandbox> =>\n Effect.flatMap(Sandbox, (s) => s.destroy(id))\n\n/**\n * Create a snapshot of a live sandbox. Requires\n * {@link SandboxSnapshots} on the R channel — adapters whose\n * provider doesn't support snapshot-as-new-sandbox don't ship the\n * marker and calls fail at `Effect.provide` with a type error.\n */\nexport const snapshot = (\n from: SandboxInstance,\n name?: string,\n): Effect.Effect<SnapshotId, SandboxError.SandboxError, Sandbox | SandboxSnapshots> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.create(from, name)\n })\n\n/**\n * Create a named persistent volume. Requires {@link SandboxVolumes}.\n */\nexport const createVolume = (\n name: string,\n options?: { readonly quotaBytes?: number },\n): Effect.Effect<VolumeId, SandboxError.SandboxError, Sandbox | SandboxVolumes> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.create(name, options)\n })\n\n/** Destroy a named volume. Requires {@link SandboxVolumes}. */\nexport const destroyVolume = (\n id: VolumeId,\n): Effect.Effect<void, SandboxError.SandboxError, Sandbox | SandboxVolumes> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.destroy(id)\n })\n\n/** Enumerate persistent volumes. Requires {@link SandboxVolumes}. */\nexport const listVolumes: Effect.Effect<\n ReadonlyArray<{ readonly id: VolumeId; readonly name: string }>,\n SandboxError.SandboxError,\n Sandbox | SandboxVolumes\n> = Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.list\n})\n\n/** Destroy a snapshot. Requires {@link SandboxSnapshots}. */\nexport const destroySnapshot = (\n id: SnapshotId,\n): Effect.Effect<void, SandboxError.SandboxError, Sandbox | SandboxSnapshots> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.destroy(id)\n })\n\n/** Enumerate snapshots. Requires {@link SandboxSnapshots}. */\nexport const listSnapshots: Effect.Effect<\n ReadonlyArray<{ readonly id: SnapshotId; readonly name?: string }>,\n SandboxError.SandboxError,\n Sandbox | SandboxSnapshots\n> = Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.list\n})\n\n/**\n * Expose an internal port of a live sandbox as a publicly reachable\n * URL. Requires {@link SandboxPortExposure} — adapters whose provider\n * doesn't support runtime port exposure (e.g. Microsandbox, which\n * forwards at create time only) don't ship the marker, and calls\n * fail at `Effect.provide` with a type error.\n */\nexport const exposePort = (\n instance: SandboxInstance,\n port: number,\n): Effect.Effect<\n { readonly url: string },\n SandboxError.SandboxError,\n Sandbox | SandboxPortExposure\n> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxPortExposure\n return yield* s.ports.expose(instance, port)\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAa,YAAY,MAAM,SAAoB;AAanD,MAAa,WAAW,MAAM,SAAmB;AAGjD,MAAa,aAAa,MAAM,SAAqB;AA4BrD,MAAa,WAAW,KAAK,YAAsB;AA2BnD,MAAa,gBAAgB,KAAK,YAA2B;AAmI7D,MAAa,YAAY,KAAK,YAAuB;AAqLrD,IAAa,UAAb,cAA6B,QAAQ,SAAkC,CACrE,+BACD,CAAC;;;;;;;;;;;AAgBF,IAAa,2BAAb,cAA8C,QAAQ,SAAyC,CAC7F,2DACD,CAAC;;;;;;;;;AAUF,IAAa,yBAAb,cAA4C,QAAQ,SAAuC,CACzF,yDACD,CAAC;;;;;;;AAQF,IAAa,mBAAb,cAAsC,QAAQ,SAAiC,CAC7E,mDACD,CAAC;;;;;;;AAQF,IAAa,qBAAb,cAAwC,QAAQ,SAAmC,CACjF,qDACD,CAAC;;;;;;;;;AAUF,IAAa,iBAAb,cAAoC,QAAQ,SAA+B,CACzE,iDACD,CAAC;;;;;;;;;;;;AAaF,IAAa,uBAAb,cAA0C,QAAQ,SAAqC,CACrF,uDACD,CAAC;;;;;;AAOF,IAAa,aAAb,cAAgC,QAAQ,SAA2B,CACjE,6CACD,CAAC;;;;;;;AAQF,IAAa,qBAAb,cAAwC,QAAQ,SAAmC,CACjF,qDACD,CAAC;;;;;;;;AASF,IAAa,sBAAb,cAAyC,QAAQ,SAAoC,CACnF,sDACD,CAAC;;;;;AAUF,MAAa,UACX,YAEA,OA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../src/sandbox/Sandbox.ts"],"sourcesContent":["import { Brand, Context, Data, type Duration, Effect, Redacted, Scope, Stream } from \"effect\"\nimport type * as SandboxError from \"./SandboxError.js\"\n\n// ---------------------------------------------------------------------------\n// Identity\n// ---------------------------------------------------------------------------\n\n/**\n * Sandbox identifier. Branded `string` so providers don't accidentally\n * accept a raw user-supplied id. Each provider mints these per its own\n * naming scheme (uuid for E2B/Vercel, user-supplied name for\n * Microsandbox/Modal, …); the core code treats them opaquely.\n *\n * Mint via the value-level `SandboxId(...)` smart constructor instead\n * of `as SandboxId` casts.\n */\nexport type SandboxId = Brand.Branded<string, \"SandboxId\">\nexport const SandboxId = Brand.nominal<SandboxId>()\n\n/**\n * Reference returned by `list`. Carries just enough to call `attach` —\n * provider-specific metadata (createdAt, region, tags, …) lives on the\n * narrowed per-provider ref.\n */\nexport type SandboxRef = {\n readonly id: SandboxId\n readonly name?: string\n}\n\nexport type VolumeId = Brand.Branded<string, \"VolumeId\">\nexport const VolumeId = Brand.nominal<VolumeId>()\n\nexport type SnapshotId = Brand.Branded<string, \"SnapshotId\">\nexport const SnapshotId = Brand.nominal<SnapshotId>()\n\n// ---------------------------------------------------------------------------\n// Image / runtime selection\n// ---------------------------------------------------------------------------\n\n/**\n * What runtime / filesystem to boot the sandbox from.\n *\n * - `Default` — provider picks its house image (Vercel: Amazon Linux\n * 2023; Microsandbox: requires user image but a builder default may\n * apply, …). Use when you don't care what's pre-installed.\n * - `Registry` — an OCI image reference. Supported by every provider\n * except those with a fixed base (Vercel ignores this and the\n * request-schema rejects at decode).\n * - `Snapshot` — restore from a captured state. Gated by\n * {@link SandboxSnapshots} at the call site — the marker is provided\n * by adapters whose provider supports snapshot-as-image.\n * - `Dockerfile` — provider builds a custom image from a Dockerfile.\n * Gated by {@link SandboxCustomImage}.\n */\nexport type ImageRef = Data.TaggedEnum<{\n Default: {}\n Registry: { readonly ref: string }\n Snapshot: { readonly id: SnapshotId }\n Dockerfile: { readonly contents: string }\n}>\n\nexport const ImageRef = Data.taggedEnum<ImageRef>()\n\n// ---------------------------------------------------------------------------\n// Network policy + secrets\n// ---------------------------------------------------------------------------\n\n/**\n * Outbound network policy for a sandbox.\n *\n * - `Open` — no egress restriction. The provider's defaults apply\n * (e.g. Microsandbox's \"public-only\" still blocks private ranges).\n * - `Blocked` — fully airgapped, no outbound connectivity at all.\n * - `Allowlist` — only the listed hosts / CIDRs may be reached.\n *\n * Providers vary in what they honour: hostname-allowlist requires\n * {@link SandboxHostnameAllowlist}; CIDR-only providers ignore `hosts`\n * and the adapter rejects at decode if `hosts` is non-empty.\n */\nexport type NetworkPolicy = Data.TaggedEnum<{\n Open: {}\n Blocked: {}\n Allowlist: {\n readonly hosts?: ReadonlyArray<string>\n readonly cidrs?: ReadonlyArray<string>\n }\n}>\n\nexport const NetworkPolicy = Data.taggedEnum<NetworkPolicy>()\n\n/**\n * A secret bound to a sandbox at create time. The code inside the\n * sandbox sees only a placeholder (`$MSB_<NAME>` for Microsandbox,\n * `{name}` for Vercel header-injection, etc.); the real `value` lives\n * on the provider's proxy and is substituted on outbound HTTPS to\n * `hosts`.\n *\n * Requires the {@link SandboxSecretInjection} capability marker —\n * provider Layers without proxy-layer secret rewriting do not ship the\n * marker and consumer code fails at `Effect.provide` with a type\n * error.\n *\n * `header` is the request header to inject (default\n * `\"Authorization: Bearer <value>\"`). Providers that do not let\n * callers pick the header (Microsandbox's `secretEnv` shorthand)\n * silently ignore this field; providers that require an explicit\n * header (Vercel's `transform.headers`) fail at decode if it's absent.\n */\nexport type BoundSecret = {\n readonly name: string\n readonly value: Redacted.Redacted<string>\n readonly hosts: ReadonlyArray<string>\n readonly header?: string\n}\n\n// ---------------------------------------------------------------------------\n// Volumes (capability-gated on `SandboxVolumes`)\n// ---------------------------------------------------------------------------\n\nexport type VolumeMount = {\n readonly id: VolumeId\n readonly mountPath: string\n readonly readonly?: boolean\n}\n\n// ---------------------------------------------------------------------------\n// Create / exec request shapes\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-provider create request. Provider-specific knobs (region,\n * cpus, memory, template id, …) live on each provider's narrowed\n * request type which extends this.\n *\n * Fields a provider can't honour fail at **decode time** (per the\n * per-provider request schema), not silently at runtime. The\n * ComputeSDK anti-pattern of \"drop unsupported fields\" is the\n * footgun we're avoiding.\n */\nexport type CommonCreateRequest = {\n /** Image / snapshot to boot from. Omit for the provider's default. */\n readonly image?: ImageRef\n /**\n * Idle / hard timeout. Accepts a number (millis), a string like\n * `\"30 seconds\"`, or a `Duration`. Providers default differently.\n */\n readonly timeout?: Duration.Input\n /**\n * Env vars exposed to the sandbox. NOT for secrets you want hidden\n * from the running code — use {@link BoundSecret} instead.\n */\n readonly env?: Readonly<Record<string, string>>\n /** Outbound network policy. */\n readonly network?: NetworkPolicy\n /**\n * Bound secrets — code inside the sandbox sees a placeholder; the\n * proxy substitutes the real value on outbound HTTPS to listed hosts.\n * Capability-gated on {@link SandboxSecretInjection}.\n */\n readonly secrets?: ReadonlyArray<BoundSecret>\n /**\n * Persistent volumes to mount. Volumes are created via\n * `Sandbox.volumes.create` and survive sandbox lifetime.\n * Capability-gated on {@link SandboxVolumes}.\n */\n readonly volumes?: ReadonlyArray<VolumeMount>\n}\n\n/**\n * Cross-provider exec request. Background / long-running processes\n * use `spawn` instead of `exec`; the semantics differ enough that\n * overloading `exec` with a `detached` flag was rejected during\n * design.\n */\nexport type CommonExecRequest = {\n /**\n * Argv-style command. Pass a string for \"run this through the\n * shell\" semantics (provider-dependent — most use `sh -c`); pass\n * an array for direct argv with no shell parsing.\n */\n readonly cmd: string | ReadonlyArray<string>\n readonly cwd?: string\n readonly env?: Readonly<Record<string, string>>\n readonly stdin?: string | Uint8Array\n /**\n * Per-exec timeout. Accepts a number (millis), a string like\n * `\"5 seconds\"`, or a `Duration`.\n */\n readonly timeout?: Duration.Input\n}\n\n/**\n * Spawn request — extends {@link CommonExecRequest} with the option\n * to provide stdin as a `Stream<Uint8Array>`. The provider takes one\n * chunk at a time and sends EOF when the stream completes. Useful\n * for piping LLM output into a sandboxed process, or feeding stdin\n * from another stream source. `exec` does not accept streams.\n */\nexport type CommonSpawnRequest = Omit<CommonExecRequest, \"stdin\"> & {\n readonly stdin?: string | Uint8Array | Stream.Stream<Uint8Array, never, never>\n}\n\nexport type ExecResult = {\n readonly exitCode: number\n readonly stdout: string\n readonly stderr: string\n readonly durationMs: number\n}\n\n/**\n * Streaming exec output. `Complete` is terminal — the stream\n * completes after emitting it.\n */\nexport type ExecEvent = Data.TaggedEnum<{\n Stdout: { readonly chunk: Uint8Array }\n Stderr: { readonly chunk: Uint8Array }\n Complete: { readonly exitCode: number; readonly durationMs: number }\n}>\n\nexport const ExecEvent = Data.taggedEnum<ExecEvent>()\n\n// ---------------------------------------------------------------------------\n// Filesystem\n// ---------------------------------------------------------------------------\n\nexport type FileEntryKind = \"file\" | \"directory\" | \"symlink\" | \"other\"\n\nexport type FileEntry = {\n readonly path: string\n readonly kind: FileEntryKind\n}\n\nexport type SandboxFilesystem = {\n readonly read: (path: string) => Effect.Effect<Uint8Array, SandboxError.SandboxError>\n readonly write: (\n path: string,\n contents: Uint8Array | string,\n ) => Effect.Effect<void, SandboxError.SandboxError>\n readonly remove: (path: string) => Effect.Effect<void, SandboxError.SandboxError>\n readonly mkdir: (path: string) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: (\n path: string,\n ) => Effect.Effect<ReadonlyArray<FileEntry>, SandboxError.SandboxError>\n readonly exists: (path: string) => Effect.Effect<boolean, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// Process handle (returned by `spawn`)\n// ---------------------------------------------------------------------------\n\n/**\n * Long-running process handle. Returned by `spawn` in a `Scope.Scope`\n * — the process is killed on scope close. To outlive the calling\n * scope, do `Effect.forkScoped` against a wider scope or use\n * `attach`-style reconnection per the provider's escape hatch.\n */\nexport type ProcessHandle = {\n readonly pid: number\n readonly events: Stream.Stream<ExecEvent, SandboxError.SandboxError>\n readonly kill: Effect.Effect<void, SandboxError.SandboxError>\n readonly exit: Effect.Effect<{ readonly exitCode: number }, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// SandboxInstance — the live handle returned from `create` / `attach`\n// ---------------------------------------------------------------------------\n\n/**\n * Live sandbox handle. Methods are plain `Effect` / `Stream` values\n * — no nullary thunks (`destroy()`, `pause()`) — to match Effect's\n * `Queue.shutdown` / `Fiber.interrupt` style. Destruction is the\n * scope finalizer, not a method here; for the rare \"kill from\n * another fiber\" case use the service-level escape hatch\n * `Sandbox.destroy(id)`.\n */\nexport type SandboxInstance = {\n readonly id: SandboxId\n readonly exec: (\n request: CommonExecRequest,\n ) => Effect.Effect<ExecResult, SandboxError.SandboxError>\n readonly execStream: (\n request: CommonExecRequest,\n ) => Stream.Stream<ExecEvent, SandboxError.SandboxError>\n /**\n * Spawn a background / long-running process. The returned handle is\n * scoped — the process is killed on scope close. Use this for\n * \"dev server / watcher / tail -f\" workloads. For one-shot\n * commands prefer `exec`.\n */\n readonly spawn: (\n request: CommonSpawnRequest,\n ) => Effect.Effect<ProcessHandle, SandboxError.SandboxError, Scope.Scope>\n readonly files: SandboxFilesystem\n}\n\n// ---------------------------------------------------------------------------\n// Snapshot / volume / port sub-services (capability-gated)\n// ---------------------------------------------------------------------------\n\nexport type SandboxSnapshotsApi = {\n readonly create: (\n from: SandboxInstance,\n name?: string,\n ) => Effect.Effect<SnapshotId, SandboxError.SandboxError>\n readonly destroy: (id: SnapshotId) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: Effect.Effect<\n ReadonlyArray<{ readonly id: SnapshotId; readonly name?: string }>,\n SandboxError.SandboxError\n >\n}\n\nexport type SandboxVolumesApi = {\n readonly create: (\n name: string,\n options?: { readonly quotaBytes?: number },\n ) => Effect.Effect<VolumeId, SandboxError.SandboxError>\n readonly destroy: (id: VolumeId) => Effect.Effect<void, SandboxError.SandboxError>\n readonly list: Effect.Effect<\n ReadonlyArray<{ readonly id: VolumeId; readonly name: string }>,\n SandboxError.SandboxError\n >\n}\n\nexport type SandboxPortsApi = {\n /**\n * Expose an internal sandbox port as a publicly reachable URL.\n * Gated by {@link SandboxPortExposure} on the free helper; adapters\n * that don't ship the marker leave this sub-API out of the public\n * surface entirely (callers can't construct an Effect against it).\n */\n readonly expose: (\n instance: SandboxInstance,\n port: number,\n ) => Effect.Effect<{ readonly url: string }, SandboxError.SandboxError>\n}\n\n// ---------------------------------------------------------------------------\n// Service definition\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-provider sandbox service.\n *\n * Lifetime model: `create` returns a sandbox handle in `Scope.Scope`.\n * The scope finalizer destroys the sandbox. Use `Effect.scoped` to\n * bound a sandbox's lifetime to a single Effect, or manage the scope\n * explicitly via `Scope.make` for sandboxes that span many calls.\n * This is why there's no `destroy()` method on `SandboxInstance` —\n * the scope is the lifecycle handle.\n *\n * `snapshots` and `volumes` sub-APIs are present on the service but\n * are still capability-gated: provider Layers that don't support\n * them ship implementations that always fail with\n * `SandboxUnsupported`. The free helpers ({@link snapshot},\n * {@link createVolume}) additionally require the corresponding\n * capability marker on R, so misuses surface as type errors at\n * `Effect.provide`, not as runtime failures.\n */\nexport type SandboxService = {\n /**\n * Provision a new sandbox. The returned handle's lifetime is\n * bound to the caller's scope; the sandbox is destroyed on scope\n * close. To survive the scope, use `attach`-style reconnection or\n * promote into a wider scope.\n */\n readonly create: (\n request: CommonCreateRequest,\n ) => Effect.Effect<SandboxInstance, SandboxError.SandboxError, Scope.Scope>\n\n /**\n * Re-acquire an existing sandbox by id. The returned handle is\n * scope-bound but the finalizer is \"detach\" (no destroy) —\n * appropriate for paused / detached / persistent sandboxes that\n * outlive any single agent run.\n */\n readonly attach: (\n id: SandboxId,\n ) => Effect.Effect<SandboxInstance, SandboxError.SandboxError, Scope.Scope>\n\n /**\n * Enumerate sandboxes visible to the configured account / project.\n */\n readonly list: Effect.Effect<ReadonlyArray<SandboxRef>, SandboxError.SandboxError>\n\n /**\n * Escape hatch for destroying a sandbox from outside its owning\n * scope. Most callers should let the scope finalizer handle this.\n */\n readonly destroy: (id: SandboxId) => Effect.Effect<void, SandboxError.SandboxError>\n\n /** Snapshot management. Capability-gated on {@link SandboxSnapshots}. */\n readonly snapshots: SandboxSnapshotsApi\n\n /** Volume management. Capability-gated on {@link SandboxVolumes}. */\n readonly volumes: SandboxVolumesApi\n\n /** Port exposure. Capability-gated on {@link SandboxPortExposure}. */\n readonly ports: SandboxPortsApi\n}\n\nexport class Sandbox extends Context.Service<Sandbox, SandboxService>()(\n \"@betalyra/effect-uai/Sandbox\",\n) {}\n\n// ---------------------------------------------------------------------------\n// Capability markers\n// ---------------------------------------------------------------------------\n\n/**\n * Capability marker — provided by adapter Layers whose provider\n * supports a hostname-level egress allowlist (matching against host\n * names / wildcards, not just CIDRs). Vercel, Cloudflare, Deno,\n * Microsandbox, Runloop, Anthropic srt ship this marker; Modal and\n * Daytona (CIDR-only) do not.\n *\n * Phantom — the value is `void`; adapters register with\n * `Layer.succeed(SandboxHostnameAllowlist, undefined)`.\n */\nexport class SandboxHostnameAllowlist extends Context.Service<SandboxHostnameAllowlist, void>()(\n \"@betalyra/effect-uai/capability/SandboxHostnameAllowlist\",\n) {}\n\n/**\n * Capability marker — adapter's provider supports proxy-layer\n * secret rewriting (header injection on outbound HTTPS to bound\n * hosts; the running code never sees the real value). Deno,\n * Cloudflare, E2B, Vercel (firewall transform), Microsandbox,\n * Runloop (Agent Gateway) ship this. Modal, Daytona, CodeSandbox\n * do not.\n */\nexport class SandboxSecretInjection extends Context.Service<SandboxSecretInjection, void>()(\n \"@betalyra/effect-uai/capability/SandboxSecretInjection\",\n) {}\n\n/**\n * Capability marker — adapter supports snapshot-as-new-sandbox\n * (capture state, restore as a derived sandbox with a fresh id).\n * Distinct from {@link SandboxPauseResume}, which preserves the\n * same id and resumes in place.\n */\nexport class SandboxSnapshots extends Context.Service<SandboxSnapshots, void>()(\n \"@betalyra/effect-uai/capability/SandboxSnapshots\",\n) {}\n\n/**\n * Capability marker — adapter supports in-place pause and resume on\n * the same sandbox id (E2B, CodeSandbox). Memory + processes are\n * preserved across the pause boundary. Most providers without this\n * marker offer {@link SandboxSnapshots} instead.\n */\nexport class SandboxPauseResume extends Context.Service<SandboxPauseResume, void>()(\n \"@betalyra/effect-uai/capability/SandboxPauseResume\",\n) {}\n\n/**\n * Capability marker — adapter manages named persistent volumes\n * outside any single sandbox lifecycle (Modal Volume, Daytona,\n * Microsandbox, BoxLite). Providers without this marker leave\n * `Sandbox.volumes.*` returning `SandboxUnsupported`; the free\n * helpers ({@link createVolume}, {@link destroyVolume}) additionally\n * require this marker on R so misuses become a type error.\n */\nexport class SandboxVolumes extends Context.Service<SandboxVolumes, void>()(\n \"@betalyra/effect-uai/capability/SandboxVolumes\",\n) {}\n\n/**\n * Capability marker — adapter supports a stateful kernel session\n * (Jupyter-style: persistent Python / JS context that returns rich\n * outputs across many `runCode` calls). Cloudflare Code Interpreter\n * and E2B ship this; everyone else expects you to write your own\n * script and `exec` it.\n *\n * The actual `runCode` helper lives separately (not on\n * `SandboxInstance`) because the return shape is different — rich\n * outputs with images/tables, not buffered stdout strings.\n */\nexport class SandboxKernelSession extends Context.Service<SandboxKernelSession, void>()(\n \"@betalyra/effect-uai/capability/SandboxKernelSession\",\n) {}\n\n/**\n * Capability marker — adapter exposes an interactive PTY session\n * (Runloop, Cloudflare terminal). Distinct from `execStream` which\n * is byte-oriented and one-shot.\n */\nexport class SandboxPty extends Context.Service<SandboxPty, void>()(\n \"@betalyra/effect-uai/capability/SandboxPty\",\n) {}\n\n/**\n * Capability marker — adapter accepts a user-supplied Dockerfile (or\n * OCI image build) instead of just a registry reference. Vercel does\n * not ship this (fixed AL2023). Deno does not (snapshots only).\n * Most others do.\n */\nexport class SandboxCustomImage extends Context.Service<SandboxCustomImage, void>()(\n \"@betalyra/effect-uai/capability/SandboxCustomImage\",\n) {}\n\n/**\n * Capability marker — adapter can expose an internal port as a\n * publicly reachable URL. Most cloud providers ship this; local\n * providers (Microsandbox, BoxLite) typically only support\n * host-side port forwarding (handled by ignoring this marker and\n * documenting via the per-provider request type).\n */\nexport class SandboxPortExposure extends Context.Service<SandboxPortExposure, void>()(\n \"@betalyra/effect-uai/capability/SandboxPortExposure\",\n) {}\n\n// ---------------------------------------------------------------------------\n// Free helpers — accept Sandbox via Context, optionally require markers.\n// ---------------------------------------------------------------------------\n\n/**\n * Provision a sandbox bound to the caller's scope. Drop the\n * `Scope.Scope` requirement with `Effect.scoped`.\n */\nexport const create = (\n request: CommonCreateRequest,\n): Effect.Effect<SandboxInstance, SandboxError.SandboxError, Sandbox | Scope.Scope> =>\n Effect.flatMap(Sandbox, (s) => s.create(request))\n\n/**\n * Re-acquire an existing sandbox by id. Same scope semantics as\n * `create`, but the finalizer detaches rather than destroying.\n */\nexport const attach = (\n id: SandboxId,\n): Effect.Effect<SandboxInstance, SandboxError.SandboxError, Sandbox | Scope.Scope> =>\n Effect.flatMap(Sandbox, (s) => s.attach(id))\n\n/** Enumerate sandboxes for the configured account / project. */\nexport const list: Effect.Effect<\n ReadonlyArray<SandboxRef>,\n SandboxError.SandboxError,\n Sandbox\n> = Effect.flatMap(Sandbox, (s) => s.list)\n\n/**\n * Escape hatch for destroying a sandbox from outside its owning\n * scope. Most callers should let the scope finalizer handle this\n * automatically.\n */\nexport const destroy = (id: SandboxId): Effect.Effect<void, SandboxError.SandboxError, Sandbox> =>\n Effect.flatMap(Sandbox, (s) => s.destroy(id))\n\n/**\n * Create a snapshot of a live sandbox. Requires\n * {@link SandboxSnapshots} on the R channel — adapters whose\n * provider doesn't support snapshot-as-new-sandbox don't ship the\n * marker and calls fail at `Effect.provide` with a type error.\n */\nexport const snapshot = (\n from: SandboxInstance,\n name?: string,\n): Effect.Effect<SnapshotId, SandboxError.SandboxError, Sandbox | SandboxSnapshots> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.create(from, name)\n })\n\n/**\n * Create a named persistent volume. Requires {@link SandboxVolumes}.\n */\nexport const createVolume = (\n name: string,\n options?: { readonly quotaBytes?: number },\n): Effect.Effect<VolumeId, SandboxError.SandboxError, Sandbox | SandboxVolumes> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.create(name, options)\n })\n\n/** Destroy a named volume. Requires {@link SandboxVolumes}. */\nexport const destroyVolume = (\n id: VolumeId,\n): Effect.Effect<void, SandboxError.SandboxError, Sandbox | SandboxVolumes> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.destroy(id)\n })\n\n/** Enumerate persistent volumes. Requires {@link SandboxVolumes}. */\nexport const listVolumes: Effect.Effect<\n ReadonlyArray<{ readonly id: VolumeId; readonly name: string }>,\n SandboxError.SandboxError,\n Sandbox | SandboxVolumes\n> = Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxVolumes\n return yield* s.volumes.list\n})\n\n/** Destroy a snapshot. Requires {@link SandboxSnapshots}. */\nexport const destroySnapshot = (\n id: SnapshotId,\n): Effect.Effect<void, SandboxError.SandboxError, Sandbox | SandboxSnapshots> =>\n Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.destroy(id)\n })\n\n/** Enumerate snapshots. Requires {@link SandboxSnapshots}. */\nexport const listSnapshots: Effect.Effect<\n ReadonlyArray<{ readonly id: SnapshotId; readonly name?: string }>,\n SandboxError.SandboxError,\n Sandbox | SandboxSnapshots\n> = Effect.gen(function* () {\n const s = yield* Sandbox\n yield* SandboxSnapshots\n return yield* s.snapshots.list\n})\n\n/**\n * Expose an internal port of a live sandbox as a publicly reachable\n * URL. Requires {@link SandboxPortExposure} — adapters whose provider\n * doesn't support runtime port exposure (e.g. Microsandbox, which\n * forwards at create time only) don't ship the marker, and calls\n * fail at `Effect.provide` with a type error.\n */\nexport const exposePort = (\n instance: SandboxInstance,\n port: number,\n): Effect.Effect<\n { readonly url: string },\n SandboxError.SandboxError,\n Sandbox | SandboxPortExposure\n> =>\n Effect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SandboxError, c as SandboxInvalidRequest, d as SandboxQuotaExceeded, f as SandboxTimeout, i as SandboxCreateFailed, l as SandboxNetworkPolicyDenied, n as SandboxAuthFailed, p as SandboxUnsupported, r as SandboxAuthSubtype, s as SandboxExecFailed, t as SandboxAlreadyExists, u as SandboxNotFound } from "../SandboxError-
|
|
1
|
+
import { a as SandboxError, c as SandboxInvalidRequest, d as SandboxQuotaExceeded, f as SandboxTimeout, i as SandboxCreateFailed, l as SandboxNetworkPolicyDenied, n as SandboxAuthFailed, p as SandboxUnsupported, r as SandboxAuthSubtype, s as SandboxExecFailed, t as SandboxAlreadyExists, u as SandboxNotFound } from "../SandboxError-BN8b28Bh.mjs";
|
|
2
2
|
export { SandboxAlreadyExists, SandboxAuthFailed, SandboxAuthSubtype, SandboxCreateFailed, SandboxError, SandboxExecFailed, SandboxInvalidRequest, SandboxNetworkPolicyDenied, SandboxNotFound, SandboxQuotaExceeded, SandboxTimeout, SandboxUnsupported };
|