@open-insight/core 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-2V5_4nlu.mjs","names":["make","make","makeName","make","Context.resolve","Context.ModeSchema","ProviderService","make","Snapshot.hash","Spawn","CP"],"sources":["../src/sandbox/snapshot/instruction.ts","../src/sandbox/snapshot/schema.ts","../src/sandbox/snapshot/decode.ts","../src/sandbox/snapshot/derive.ts","../src/sandbox/context/schema.ts","../src/sandbox/context/dist.ts","../src/sandbox/context/index.ts","../src/sandbox/snapshot/build.ts","../src/sandbox/snapshot/index.ts","../src/sandbox/error.ts","../src/sandbox/provider/service.ts","../src/sandbox/provider/utils.ts","../src/sandbox/provider/index.ts","../../utils/dist/rolldown-runtime-D7D4PA-g.mjs","../../utils/dist/index.mjs","../src/sandbox/sandbox/promise.ts","../src/sandbox/sandbox/index.ts","../src/sandbox/resource.ts","../src/sandbox/index.ts","../src/agent/error.ts","../src/agent/service.ts","../src/agent/index.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nexport const Instruction = Schema.TaggedUnion({\n Workdir: {\n path: Schema.String,\n },\n User: {\n /**\n * Accepts either `\"user\"` or `\"user:group\"`.\n */\n user: Schema.String,\n },\n Run: {\n cmd: Schema.String,\n },\n Env: {\n env: Schema.Record(Schema.String, Schema.String),\n },\n Copy: {\n src: Schema.Array(Schema.String),\n dest: Schema.String,\n },\n Cmd: {\n cmd: Schema.Array(Schema.String),\n },\n Entrypoint: {\n cmd: Schema.Array(Schema.String),\n },\n});\nexport type Instruction = Schema.Schema.Type<typeof Instruction>;\n\nexport const workdir = (workdir: string): Instruction =>\n Instruction.make({ _tag: \"Workdir\", path: workdir });\n\nexport const user = (user: string): Instruction => Instruction.make({ _tag: \"User\", user });\n\nexport const run = (cmd: string): Instruction => Instruction.make({ _tag: \"Run\", cmd });\n\nexport const assert = (...cmd: string[]): Instruction =>\n Instruction.make({ _tag: \"Run\", cmd: cmd.join(\" && \") + \" || exit 1\" });\n\nexport const available = (...program: string[]): Instruction =>\n assert(...program.map((p) => `command -v ${p}`));\n\nexport const env = (env: Record<string, string>): Instruction =>\n Instruction.make({ _tag: \"Env\", env });\n\nexport const copy = (src: string[], dest: string): Instruction =>\n Instruction.make({ _tag: \"Copy\", src, dest });\n\nexport const cmd = (cmd: string[]): Instruction => Instruction.make({ _tag: \"Cmd\", cmd });\n\nexport const entrypoint = (cmd: string[]): Instruction =>\n Instruction.make({ _tag: \"Entrypoint\", cmd });\n\nexport const Instructions = Schema.Array(Instruction);\nexport type Instructions = Schema.Schema.Type<typeof Instructions>;\n\nexport const make = (...instructions: Instruction[]): Instructions =>\n Instructions.make(instructions);\n","import { Schema } from \"effect\";\nimport { Instructions } from \"./instruction.ts\";\n\n/**\n * OCI image reference (e.g. `docker.io/library/node:18-alpine`).\n */\nexport const Image = Schema.String;\nexport type Image = Schema.Schema.Type<typeof Image>;\n\nexport class Snapshot extends Schema.Class<Snapshot>(\"Snapshot\")({\n image: Image,\n instructions: Instructions,\n}) {}\n\n/**\n * The name of the snapshot.\n *\n * Each snapshot must use this name and mapped to different hash tags.\n */\nexport const SNAPSHOT_NAME = \"open-insight-snapshot\";\n\nexport const make: typeof Snapshot.make = (args) => Snapshot.make(args);\n","import {\n Cmd,\n Copy,\n DockerfileParser,\n Entrypoint,\n Env,\n type Instruction as DockerfileInstruction,\n Run,\n User,\n Workdir,\n} from \"dockerfile-ast\";\nimport { Effect, Option, Schema, SchemaGetter, SchemaIssue } from \"effect\";\nimport { Instruction } from \"./instruction.ts\";\nimport { Snapshot } from \"./schema.ts\";\n\nconst encodeInstruction = (instruction: Instruction): string =>\n Instruction.match(instruction, {\n Workdir: ({ path }) => `WORKDIR ${path}`,\n User: ({ user }) => `USER ${user}`,\n Run: ({ cmd }) => `RUN ${cmd}`,\n Env: ({ env }) => {\n const keys = Object.keys(env).sort();\n return `ENV ${keys.map((key) => `${key}=${env[key]}`).join(\" \")}`;\n },\n Copy: ({ src, dest }) => `COPY ${JSON.stringify([...src, dest])}`,\n Cmd: ({ cmd }) => `CMD ${JSON.stringify(cmd)}`,\n Entrypoint: ({ cmd }) => `ENTRYPOINT ${JSON.stringify(cmd)}`,\n });\n\nconst invalidContainerfile = (containerfile: string, message: string) =>\n new SchemaIssue.InvalidValue(Option.some(containerfile), { message });\n\nconst requireArguments = Effect.fn(\"containerfile/requireArguments\")(function* (\n containerfile: string,\n instruction: DockerfileInstruction,\n) {\n const argumentsContent = instruction.getArgumentsContent();\n if (argumentsContent === null) {\n return yield* Effect.fail(\n invalidContainerfile(\n containerfile,\n `${instruction.getKeyword()} instruction is missing arguments`,\n ),\n );\n }\n return argumentsContent;\n});\n\nconst requireNoFlags = Effect.fn(\"containerfile/requireNoFlags\")(function* (\n containerfile: string,\n instruction: Run | Copy | Cmd | Entrypoint,\n) {\n if (instruction.getFlags().length !== 0) {\n return yield* Effect.fail(\n invalidContainerfile(\n containerfile,\n `${instruction.getKeyword()} flags are not supported by Snapshot`,\n ),\n );\n }\n});\n\nconst decodeJsonArguments = Effect.fn(\"containerfile/decodeJsonArguments\")(function* (\n containerfile: string,\n instruction: Cmd | Entrypoint,\n) {\n const openingBracket = instruction.getOpeningBracket();\n const closingBracket = instruction.getClosingBracket();\n if (openingBracket === null || closingBracket === null) {\n return yield* Effect.fail(\n invalidContainerfile(containerfile, `${instruction.getKeyword()} must use JSON array form`),\n );\n }\n return instruction.getJSONStrings().map((argument) => argument.getJSONValue());\n});\n\nconst decodeCopyArguments = Effect.fn(\"containerfile/decodeCopyArguments\")(function* (\n containerfile: string,\n instruction: Copy,\n) {\n const openingBracket = instruction.getOpeningBracket();\n const closingBracket = instruction.getClosingBracket();\n if (openingBracket === null && closingBracket === null) {\n return instruction.getArguments().map((argument) => argument.getValue());\n }\n if (openingBracket !== null && closingBracket !== null) {\n return instruction.getJSONStrings().map((argument) => argument.getJSONValue());\n }\n return yield* Effect.fail(\n invalidContainerfile(containerfile, \"COPY has an incomplete JSON array\"),\n );\n});\n\nconst decodeInstruction = Effect.fn(\"containerfile/decodeInstruction\")(function* (\n containerfile: string,\n instruction: DockerfileInstruction,\n) {\n if (instruction instanceof Workdir) {\n return Instruction.make({\n _tag: \"Workdir\",\n path: yield* requireArguments(containerfile, instruction),\n });\n }\n\n if (instruction instanceof User) {\n return Instruction.make({\n _tag: \"User\",\n user: yield* requireArguments(containerfile, instruction),\n });\n }\n\n if (instruction instanceof Run) {\n yield* requireNoFlags(containerfile, instruction);\n return Instruction.make({\n _tag: \"Run\",\n cmd: yield* requireArguments(containerfile, instruction),\n });\n }\n\n if (instruction instanceof Env) {\n const env: Record<string, string> = {};\n for (const property of instruction.getProperties()) {\n const key = property.getName();\n const value = property.getValue();\n if (value === null) {\n return yield* Effect.fail(\n invalidContainerfile(containerfile, `ENV ${key} is missing a value`),\n );\n }\n env[key] = value;\n }\n return Instruction.make({ _tag: \"Env\", env });\n }\n\n if (instruction instanceof Copy) {\n yield* requireNoFlags(containerfile, instruction);\n const argumentsContent = yield* decodeCopyArguments(containerfile, instruction);\n if (argumentsContent.length < 2) {\n return yield* Effect.fail(\n invalidContainerfile(\n containerfile,\n \"COPY must include at least one source and one destination\",\n ),\n );\n }\n return Instruction.make({\n _tag: \"Copy\",\n src: argumentsContent.slice(0, -1),\n dest: argumentsContent[argumentsContent.length - 1],\n });\n }\n\n if (instruction instanceof Cmd) {\n yield* requireNoFlags(containerfile, instruction);\n return Instruction.make({\n _tag: \"Cmd\",\n cmd: yield* decodeJsonArguments(containerfile, instruction),\n });\n }\n\n if (instruction instanceof Entrypoint) {\n yield* requireNoFlags(containerfile, instruction);\n return Instruction.make({\n _tag: \"Entrypoint\",\n cmd: yield* decodeJsonArguments(containerfile, instruction),\n });\n }\n\n return yield* Effect.fail(\n invalidContainerfile(\n containerfile,\n `${instruction.getKeyword()} instruction is not supported by Snapshot`,\n ),\n );\n});\n\nconst decodeContainerfile = Effect.fn(\"containerfile\")(function* (containerfile: string) {\n const dockerfile = yield* Effect.try({\n try: () => DockerfileParser.parse(containerfile),\n catch: (cause) =>\n invalidContainerfile(containerfile, `Failed to parse Containerfile: ${String(cause)}`),\n });\n\n const froms = dockerfile.getFROMs();\n if (froms.length !== 1) {\n return yield* Effect.fail(\n invalidContainerfile(\n containerfile,\n `Expected exactly one FROM instruction, found ${froms.length}`,\n ),\n );\n }\n\n const image = froms[0].getImage();\n if (image === null) {\n return yield* Effect.fail(\n invalidContainerfile(containerfile, \"FROM instruction is missing an image\"),\n );\n }\n\n const instructions: Array<Instruction> = [];\n for (const instruction of dockerfile.getInstructions()) {\n if (instruction === froms[0]) {\n continue;\n }\n instructions.push(yield* decodeInstruction(containerfile, instruction));\n }\n\n return Snapshot.make({ image, instructions });\n});\n\nexport const Containerfile = Schema.String.pipe(\n Schema.decodeTo(Snapshot, {\n decode: SchemaGetter.transformOrFail(decodeContainerfile),\n encode: SchemaGetter.transform(({ image, instructions }) => {\n const lines = [`FROM ${image}`, ...instructions.map(encodeInstruction)];\n return `${lines.join(\"\\n\")}\\n`;\n }),\n }),\n);\n\nexport const encode = (snapshot: Snapshot) => Schema.encodeEffect(Containerfile)(snapshot);\n\nexport const decode = (containerfile: string) => Schema.decodeEffect(Containerfile)(containerfile);\n","import { Crypto, Effect, Encoding } from \"effect\";\nimport { encode } from \"./decode.ts\";\nimport { type Instructions } from \"./instruction.ts\";\nimport { type Image, Snapshot, SNAPSHOT_NAME } from \"./schema.ts\";\n\nexport const hash = Effect.fn(function* (snapshot: Snapshot) {\n const crypto = yield* Crypto.Crypto;\n const containerfile = yield* encode(snapshot);\n const bytes = new TextEncoder().encode(containerfile);\n const digest = yield* crypto.digest(\"SHA-256\", bytes);\n return Encoding.encodeHex(digest);\n});\n\n/**\n * Get the name of a snapshot. The built snapshot must be tagged with this name.\n *\n * - The name of a snapshot is always `open-insight-snapshot`.\n * - The tag of a snapshot is the SHA-256 hash of the snapshot's content.\n */\nexport const makeName = Effect.fn(function* (snapshot: Snapshot) {\n const hashed = yield* hash(snapshot);\n return `${SNAPSHOT_NAME}:${hashed}`;\n});\n\n/**\n * Create a snapshot from an OCI image reference.\n */\nexport const fromImage = (image: Image): Snapshot => Snapshot.make({ image, instructions: [] });\n\n/**\n * Extend an existing snapshot with a set of new instructions, without changing the base image.\n */\nexport const extend = ({\n snapshot,\n instructions,\n}: {\n snapshot: Snapshot;\n instructions: Instructions;\n}): Snapshot =>\n Snapshot.make({\n image: snapshot.image,\n instructions: [...snapshot.instructions, ...instructions],\n });\n\n/**\n * Derive a new snapshot from an existing snapshot with a set of new instructions.\n *\n * Note that the base image of the given snapshot must exist.\n */\nexport const derive = Effect.fn(function* ({\n snapshot,\n instructions,\n}: {\n snapshot: Snapshot;\n instructions: Instructions;\n}) {\n const image = yield* makeName(snapshot);\n return Snapshot.make({ image, instructions });\n});\n","import { Schema } from \"effect\";\n\nexport const DistFileType = Schema.Literal(\".tar.gz\");\nexport type DistFileType = Schema.Schema.Type<typeof DistFileType>;\n\nexport const ModeSchema = Schema.TaggedUnion({\n Dir: {\n path: Schema.String,\n },\n Dist: {\n url: Schema.String,\n fileType: DistFileType,\n },\n Script: {},\n Cwd: {},\n});\nexport type Mode = Schema.Schema.Type<typeof ModeSchema>;\n\n/**\n * Context dir for snapshot update operations.\n *\n * Any file operations (e.g. COPY) must be resolved relative to this path.\n */\nexport const ContextSchema = Schema.String;\nexport type Context = Schema.Schema.Type<typeof ContextSchema>;\n","import { Effect, FileSystem, Schema } from \"effect\";\nimport { HttpClient, HttpClientResponse } from \"effect/unstable/http\";\nimport { ChildProcess } from \"effect/unstable/process\";\nimport { ChildProcessSpawner } from \"effect/unstable/process/ChildProcessSpawner\";\nimport { SandboxError } from \"../error.ts\";\nimport { type Context, type Mode } from \"./schema.ts\";\n\nconst decodeUrl = Schema.decodeUnknownEffect(Schema.URLFromString);\n\nconst extractTarGz = Effect.fn(function* (archivePath: string) {\n const fs = yield* FileSystem.FileSystem;\n const spawner = yield* ChildProcessSpawner;\n const dir = yield* fs.makeTempDirectory({\n prefix: \"open-insight-dist-\",\n });\n\n const exitCode = yield* spawner.exitCode(\n ChildProcess.make(\"tar\", [\"-xzf\", archivePath, \"-C\", dir]),\n );\n\n if (exitCode !== 0) {\n return yield* Effect.fail(new Error(`tar exited with code ${exitCode}`));\n }\n\n return dir;\n});\n\nconst resolveDistContext = Effect.fn(function* ({\n url,\n fileType,\n}: Extract<Mode, { _tag: \"Dist\" }>) {\n const fs = yield* FileSystem.FileSystem;\n const parsedUrl = yield* decodeUrl(url);\n const archivePath = yield* fs.makeTempFile({\n prefix: \"open-insight-dist-\",\n suffix: fileType,\n });\n\n const bytes = yield* HttpClient.get(parsedUrl).pipe(\n Effect.flatMap(HttpClientResponse.filterStatusOk),\n Effect.flatMap((response) => response.arrayBuffer),\n Effect.map((buffer) => new Uint8Array(buffer)),\n );\n yield* fs.writeFile(archivePath, bytes);\n\n if (fileType === \".tar.gz\") {\n return yield* extractTarGz(archivePath);\n }\n\n return yield* Effect.fail(new Error(`Unsupported dist file type: ${String(fileType)}`));\n});\n\nexport const resolveDist = Effect.fn(function* (\n mode: Extract<Mode, { _tag: \"Dist\" }>,\n): Effect.fn.Return<\n Context,\n SandboxError,\n ChildProcessSpawner | FileSystem.FileSystem | HttpClient.HttpClient\n> {\n return yield* resolveDistContext(mode).pipe(Effect.mapError(SandboxError.contextResolve(mode)));\n});\n","import { Effect, FileSystem, Path } from \"effect\";\nimport { HttpClient } from \"effect/unstable/http\";\nimport { ChildProcessSpawner } from \"effect/unstable/process/ChildProcessSpawner\";\nimport { resolveDist } from \"./dist.ts\";\nimport { type Context, type DistFileType, type Mode, ModeSchema } from \"./schema.ts\";\nimport { SandboxError } from \"../error.ts\";\n\nexport const resolve = Effect.fn(function* (\n mode: Mode,\n): Effect.fn.Return<\n Context,\n SandboxError,\n ChildProcessSpawner | FileSystem.FileSystem | HttpClient.HttpClient | Path.Path\n> {\n const path = yield* Path.Path;\n\n return yield* ModeSchema.match(mode, {\n Dir: ({ path }) => Effect.succeed(path),\n Dist: resolveDist,\n Script: () => Effect.succeed(import.meta.dirname!),\n Cwd: () => Effect.succeed(path.resolve(\".\")),\n });\n});\n\nexport const make: typeof ModeSchema.make = (args) => ModeSchema.make(args);\n\n/**\n * Indicates that the context should be a specific directory.\n */\nexport const makeDir = (path: string) => ModeSchema.make({ _tag: \"Dir\", path });\n\n/**\n * Indicates that the context should be downloaded from a distribution archive.\n */\nexport const makeDist = ({ url, fileType }: { url: string; fileType: DistFileType }) =>\n ModeSchema.make({ _tag: \"Dist\", url, fileType });\n\n/**\n * Indicates that the context should be the script's directory.\n * This is useful for resolving relative paths in scripts.\n */\nexport const Script = ModeSchema.make({ _tag: \"Script\" });\n\n/**\n * Indicates that the context should be the current working directory.\n */\nexport const Cwd = ModeSchema.make({ _tag: \"Cwd\" });\n\nexport * from \"./schema.ts\";\n","import { Effect, FileSystem, Path } from \"effect\";\nimport * as Context from \"../context/index.ts\";\nimport { decode } from \"./decode.ts\";\n\nexport const fromContainerfile = Effect.fn(function* ({\n context,\n filePath,\n}: {\n context: Context.Mode;\n filePath: string;\n}) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n\n const contextDir = yield* Context.resolve(context);\n const containerfilePath = path.join(contextDir, filePath);\n\n const content = yield* fs.readFileString(containerfilePath);\n return yield* decode(content);\n});\n","export * from \"./decode.ts\";\nexport * from \"./derive.ts\";\nexport * from \"./schema.ts\";\nexport * from \"./build.ts\";\n\nexport * as Inst from \"./instruction.ts\";\n","import { Schema } from \"effect\";\nimport { Snapshot } from \"./snapshot/index.ts\";\nimport { Instruction } from \"./snapshot/instruction.ts\";\nimport * as Context from \"./context/schema.ts\";\n\nexport class ContextResolveError extends Schema.TaggedErrorClass<ContextResolveError>()(\n \"ContextResolveError\",\n {\n mode: Context.ModeSchema,\n cause: Schema.Defect(),\n },\n) {}\n\nexport class SnapshotError extends Schema.TaggedErrorClass<SnapshotError>()(\"SnapshotError\", {\n kind: Schema.Union([Schema.Literal(\"build\"), Schema.Literal(\"use\")]),\n snapshot: Snapshot,\n cause: Schema.Defect(),\n message: Schema.optional(Schema.String),\n}) {}\n\nexport class ProviderError extends Schema.TaggedErrorClass<ProviderError>()(\"ProviderError\", {\n name: Schema.String,\n cause: Schema.Defect(),\n}) {}\n\nexport class SandboxExecError extends Schema.TaggedErrorClass<SandboxExecError>()(\n \"SandboxExecError\",\n {\n name: Schema.String,\n operation: Schema.String,\n cause: Schema.Defect(),\n },\n) {}\n\nexport class SandboxExposeError extends Schema.TaggedErrorClass<SandboxExposeError>()(\n \"SandboxExposeError\",\n {\n name: Schema.String,\n sandboxPort: Schema.Number,\n hostPort: Schema.Number,\n cause: Schema.Defect(),\n },\n) {}\n\nexport class SnapshotUnsupportedError extends Schema.TaggedErrorClass<SnapshotUnsupportedError>()(\n \"SnapshotUnsupportedError\",\n {\n name: Schema.String,\n snapshot: Snapshot,\n cause: Schema.Defect(),\n },\n) {}\n\nexport class InstructionUnsupportedError extends Schema.TaggedErrorClass<InstructionUnsupportedError>()(\n \"InstructionUnsupportedError\",\n {\n name: Schema.String,\n snapshot: Snapshot,\n instruction: Instruction,\n },\n) {}\n\nexport const SandboxErrorReason = Schema.Union([\n ContextResolveError,\n ProviderError,\n SnapshotError,\n SandboxExecError,\n SandboxExposeError,\n SnapshotUnsupportedError,\n InstructionUnsupportedError,\n]);\n\nexport class SandboxError extends Schema.TaggedErrorClass<SandboxError>()(\"SandboxError\", {\n reason: SandboxErrorReason,\n}) {\n static contextResolve = (mode: Context.Mode) => (cause: unknown) =>\n this.make({\n reason: ContextResolveError.make({\n mode,\n cause,\n }),\n });\n\n static provider = (name: string) => (cause: unknown) =>\n this.make({\n reason: ProviderError.make({\n name,\n cause,\n }),\n });\n\n static snapshotBuild = (snapshot: Snapshot) => (cause: unknown) =>\n this.make({\n reason: SnapshotError.make({\n kind: \"build\",\n snapshot,\n cause,\n }),\n });\n\n static snapshotUsage = (snapshot: Snapshot) => (cause: unknown) =>\n this.make({\n reason: SnapshotError.make({\n kind: \"use\",\n snapshot,\n cause,\n }),\n });\n\n static sandboxExec =\n ({ name, operation }: { name: string; operation: string }) =>\n (cause: unknown) =>\n this.make({\n reason: SandboxExecError.make({\n name,\n operation,\n cause,\n }),\n });\n\n static sandboxExpose =\n ({ name, sandboxPort, hostPort }: { name: string; sandboxPort: number; hostPort: number }) =>\n (cause: unknown) =>\n this.make({\n reason: SandboxExposeError.make({\n name,\n sandboxPort,\n hostPort,\n cause,\n }),\n });\n\n static snapshotUnsupported = (name: string, snapshot: Snapshot) => (cause: unknown) =>\n this.make({\n reason: SnapshotUnsupportedError.make({\n name,\n snapshot,\n cause,\n }),\n });\n\n static instructionUnsupported = (name: string, snapshot: Snapshot, instruction: Instruction) =>\n this.make({\n reason: InstructionUnsupportedError.make({\n name,\n snapshot,\n instruction,\n }),\n });\n}\n","import { Context, Effect, type Scope } from \"effect\";\nimport type * as SandboxContext from \"../context/index.ts\";\nimport type { SandboxError } from \"../error.ts\";\nimport type { ResourceLimits } from \"../resource.ts\";\nimport type { Sandbox } from \"../sandbox/index.ts\";\nimport type { Instructions } from \"../snapshot/instruction.ts\";\nimport type { Snapshot } from \"../snapshot/index.ts\";\n\nexport type Provider = Readonly<{\n /**\n * Ensure that the given snapshot exists in the provider's storage.\n *\n * The snapshot must be indexed with the hash of the snapshot's containerfile.\n */\n ensureSnapshot(\n options: Readonly<{\n snapshot: Snapshot;\n context: SandboxContext.Mode;\n }>,\n ): Effect.Effect<void, SandboxError>;\n\n /**\n * Derive a new snapshot from an existing snapshot and a set of instructions.\n *\n * The new snapshot must be indexed with the hash of the derived snapshot's containerfile.\n */\n deriveSnapshot(\n options: Readonly<{\n snapshot: Snapshot;\n context: SandboxContext.Mode;\n instructions: Instructions;\n }>,\n ): Effect.Effect<void, SandboxError>;\n\n /**\n * Remove a snapshot from the provider's storage.\n */\n removeSnapshot(\n options: Readonly<{\n snapshot: Snapshot;\n }>,\n ): Effect.Effect<void, SandboxError>;\n\n /**\n * Run a sandbox with the given snapshot.\n *\n * The sandbox is scoped and will be automatically cleaned up.\n */\n runSandbox(\n options: Readonly<{\n snapshot: Snapshot;\n resources: ResourceLimits | null;\n }>,\n ): Effect.Effect<Sandbox, SandboxError, Scope.Scope>;\n}>;\n\nexport class ProviderService extends Context.Service<ProviderService, Provider>()(\n \"sandbox/ProviderService\",\n) {}\n","import { ChildProcess as CP } from \"effect/unstable/process\";\n\nexport const bashQuote = (value: string) => `'${value.replaceAll(\"'\", `'\\\\''`)}'`;\n\nexport const formatBash = (command: CP.StandardCommand) =>\n [command.command, ...command.args].map(bashQuote).join(\" \");\n","export * from \"./service.ts\";\nexport * from \"./utils.ts\";\n","//#region \\0rolldown/runtime.js\nvar __defProp = Object.defineProperty;\nvar __exportAll = (all, no_symbols) => {\n\tlet target = {};\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n\tif (!no_symbols) __defProp(target, Symbol.toStringTag, { value: \"Module\" });\n\treturn target;\n};\n//#endregion\nexport { __exportAll as t };\n","import { t as __exportAll } from \"./rolldown-runtime-D7D4PA-g.mjs\";\nimport { Context, Data, Effect, Latch, Layer, Ref, Stream } from \"effect\";\nimport { ChildProcessSpawner } from \"effect/unstable/process/ChildProcessSpawner\";\n//#region src/spawn.ts\nvar spawn_exports = /* @__PURE__ */ __exportAll({\n\tSpawnError: () => SpawnError,\n\tSpawnExitCodeError: () => SpawnExitCodeError,\n\tSpawnService: () => SpawnService\n});\nvar SpawnExitCodeError = class extends Data.TaggedError(\"SpawnExitCodeError\") {\n\tget message() {\n\t\treturn `process exited with code ${this.exitCode}`;\n\t}\n};\nvar SpawnError = class SpawnError extends Data.TaggedError(\"SpawnError\") {\n\tget message() {\n\t\treturn this.reason.message;\n\t}\n\tstatic platform = (err) => new SpawnError({ reason: err });\n\tstatic exit = ({ exitCode, stdout, stderr }) => new SpawnError({ reason: new SpawnExitCodeError({\n\t\texitCode,\n\t\tstdout,\n\t\tstderr\n\t}) });\n};\nvar SpawnService = class SpawnService extends Context.Service()(\"packages/utils/SpawnService\") {\n\tstatic layer = Layer.effect(SpawnService, Effect.gen(function* () {\n\t\tconst spawner = yield* ChildProcessSpawner;\n\t\tconst streamText = (stream) => Stream.mkString(Stream.decodeText(stream));\n\t\tconst spawn = Effect.fn(function* (command) {\n\t\t\tconst handle = yield* spawner.spawn(command).pipe(Effect.mapError(SpawnError.platform));\n\t\t\tconst exitCode = yield* handle.exitCode.pipe(Effect.mapError(SpawnError.platform));\n\t\t\tif (exitCode !== 0) {\n\t\t\t\tconst output = yield* Effect.all({\n\t\t\t\t\tstdout: streamText(handle.stdout),\n\t\t\t\t\tstderr: streamText(handle.stderr)\n\t\t\t\t}, { concurrency: \"unbounded\" }).pipe(Effect.mapError(SpawnError.platform));\n\t\t\t\treturn yield* SpawnError.exit({\n\t\t\t\t\texitCode,\n\t\t\t\t\t...output\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn handle;\n\t\t});\n\t\tconst streamString = (command, options) => spawn(command).pipe(Effect.map((handle) => Stream.decodeText(options?.includeStderr === true ? handle.all : handle.stdout).pipe(Stream.mapError(SpawnError.platform))), Stream.unwrap);\n\t\tconst streamLines = (command, options) => Stream.splitLines(streamString(command, options));\n\t\tconst exitCode = (command) => spawn(command).pipe(Effect.scoped, Effect.flatMap((handle) => handle.exitCode.pipe(Effect.mapError(SpawnError.platform))));\n\t\tconst string = (command, options) => Stream.mkString(streamString(command, options));\n\t\tconst lines = (command, options) => Stream.runCollect(streamLines(command, options));\n\t\treturn {\n\t\t\tspawn,\n\t\t\texitCode,\n\t\t\tstreamString,\n\t\t\tstreamLines,\n\t\t\tlines,\n\t\t\tstring\n\t\t};\n\t}));\n};\n//#endregion\n//#region src/countdown.ts\nvar countdown_exports = /* @__PURE__ */ __exportAll({ make: () => make });\nconst make = Effect.fn(function* (count) {\n\tconst countDown = yield* Ref.make(count);\n\tconst latch = yield* Latch.make();\n\treturn {\n\t\topen: Effect.gen(function* () {\n\t\t\tif ((yield* Ref.updateAndGet(countDown, (c) => c - 1)) <= 0) yield* latch.open;\n\t\t}),\n\t\tawait: latch.await\n\t};\n});\n//#endregion\nexport { countdown_exports as Countdown, spawn_exports as Spawn };\n\n//# sourceMappingURL=index.mjs.map","import { type Sandbox } from \"./index.ts\";\n\nexport type SandboxPromise = {\n $(options: {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n cwd?: string;\n }): Promise<string>;\n readFile(options: Readonly<{ sandboxPath: string }>): Promise<string>;\n writeFile(options: Readonly<{ sandboxPath: string; content: string }>): Promise<void>;\n download(options: Readonly<{ sandboxPath: string; hostPath: string }>): Promise<void>;\n upload(options: Readonly<{ sandboxPath: string; hostPath: string }>): Promise<void>;\n expose(\n options: Readonly<{ sandboxPort: number; hostPort: number }>,\n ): Promise<{ hostUrl: string }>;\n};\n\nexport const asPromise = (_sandbox: Sandbox): SandboxPromise => {\n throw new Error(\"Not implemented yet\");\n};\n","import { Crypto, Effect, Match, Stream } from \"effect\";\nimport { ChildProcess as CP } from \"effect/unstable/process\";\nimport { Spawn } from \"@open-insight/utils\";\nimport { SandboxError } from \"../error.ts\";\nimport * as Snapshot from \"../snapshot/index.ts\";\n\nexport const SANDBOX_NAME = \"open-insight-sandbox\";\n\nexport const makeName = Effect.fn(function* (snapshot: Snapshot.Snapshot) {\n const crypto = yield* Crypto.Crypto;\n\n const snapshotHash = yield* Snapshot.hash(snapshot);\n const sandboxID = yield* crypto.randomUUIDv4;\n\n return `${SANDBOX_NAME}-${snapshotHash}-${sandboxID}`;\n});\n\nexport type Sandbox = Readonly<{\n $(process: CP.Command): Effect.Effect<string, SandboxError>;\n readFile(options: Readonly<{ sandboxPath: string }>): Effect.Effect<string, SandboxError>;\n writeFile(\n options: Readonly<{ sandboxPath: string; content: string }>,\n ): Effect.Effect<void, SandboxError>;\n download(\n options: Readonly<{ sandboxPath: string; hostPath: string }>,\n ): Effect.Effect<void, SandboxError>;\n upload(\n options: Readonly<{ sandboxPath: string; hostPath: string }>,\n ): Effect.Effect<void, SandboxError>;\n expose(\n options: Readonly<{ sandboxPort: number; hostPort: number }>,\n ): Effect.Effect<{ hostUrl: string }, SandboxError>;\n}>;\n\nexport type MakeSandboxOptions = Readonly<{\n $(process: CP.StandardCommand, stdin?: string): Effect.Effect<string, SandboxError>;\n expose: Sandbox[\"expose\"];\n\n download: Sandbox[\"download\"] | \"rsync\";\n upload: Sandbox[\"upload\"] | \"rsync\";\n readFile: Sandbox[\"readFile\"] | \"cat\";\n writeFile: Sandbox[\"writeFile\"] | \"tee\";\n}>;\n\nexport const make = Effect.fn(function* ({\n $: sandbox$,\n expose,\n download,\n upload,\n readFile,\n writeFile,\n}: MakeSandboxOptions): Effect.fn.Return<Sandbox, SandboxError, Spawn.SpawnService> {\n const spawner = yield* Spawn.SpawnService;\n\n const $ = Effect.fn(function* (\n command: CP.Command,\n input?: string,\n ): Effect.fn.Return<string, SandboxError> {\n return yield* Match.value(command).pipe(\n Match.tag(\"StandardCommand\", (cmd) => sandbox$(cmd, input)),\n Match.tag(\"PipedCommand\", (cmd) =>\n Effect.gen(function* () {\n const output = yield* $(cmd.left, input);\n return yield* $(cmd.right, output);\n }),\n ),\n Match.exhaustive,\n );\n });\n\n const readFileImpl: Sandbox[\"readFile\"] =\n readFile === \"cat\"\n ? Effect.fn(function* ({ sandboxPath }) {\n return yield* $(CP.make`cat ${sandboxPath}`);\n })\n : readFile;\n\n const writeFileImpl: Sandbox[\"writeFile\"] =\n writeFile === \"tee\"\n ? Effect.fn(function* ({ sandboxPath, content }) {\n yield* $(CP.make`tee ${sandboxPath}`, content);\n })\n : writeFile;\n\n const downloadImpl: Sandbox[\"download\"] =\n download === \"rsync\"\n ? Effect.fn(function* ({ sandboxPath, hostPath }) {\n const content = yield* $(CP.make`cat ${sandboxPath}`);\n yield* spawner\n .string(\n CP.make(\"tee\", [hostPath], {\n stdin: {\n stream: Stream.make(content).pipe(Stream.encodeText),\n },\n } satisfies CP.CommandOptions),\n )\n .pipe(\n Effect.mapError((e) =>\n SandboxError.sandboxExec({\n name: \"host\",\n operation: `download ${sandboxPath} -> ${hostPath}`,\n })(e),\n ),\n );\n })\n : download;\n\n const uploadImpl: Sandbox[\"upload\"] =\n upload === \"rsync\"\n ? Effect.fn(function* ({ sandboxPath, hostPath }) {\n const content = yield* spawner.string(CP.make`cat ${hostPath}`).pipe(\n Effect.mapError((e) =>\n SandboxError.sandboxExec({\n name: \"host\",\n operation: `upload ${hostPath} -> ${sandboxPath}`,\n })(e),\n ),\n );\n yield* $(CP.make`tee ${sandboxPath}`, content);\n })\n : upload;\n\n return {\n $,\n readFile: readFileImpl,\n writeFile: writeFileImpl,\n download: downloadImpl,\n upload: uploadImpl,\n expose,\n } satisfies Sandbox;\n});\n\nexport * from \"./promise.ts\";\n","import { Schema } from \"effect\";\n\nconst NonNegativeNumber = Schema.Number.check(Schema.isGreaterThanOrEqualTo(0));\nconst NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));\n\nexport const ResourceLimitsSchema = Schema.Struct({\n numCPUs: Schema.optionalKey(NonNegativeNumber).annotate({\n description:\n \"Maximum CPU cores available to the sandbox. Use fractional values such as 0.5 for half a core.\",\n }),\n numGPUs: Schema.optionalKey(NonNegativeInt).annotate({\n description: \"Maximum GPU devices available to the sandbox.\",\n }),\n memoryMiB: Schema.optionalKey(NonNegativeInt).annotate({\n description: \"Maximum memory available to the sandbox, in MiB.\",\n }),\n diskMiB: Schema.optionalKey(NonNegativeInt).annotate({\n description: \"Maximum writable disk space available to the sandbox, in MiB.\",\n }),\n}).annotate({\n description: \"Sandbox resource limit configuration.\",\n});\n\nexport type ResourceLimits = Schema.Schema.Type<typeof ResourceLimitsSchema>;\n","export * from \"./error.ts\";\nexport * as Error from \"./error.ts\";\nexport * from \"./provider/index.ts\";\nexport * from \"./sandbox/index.ts\";\nexport * as Context from \"./context/index.ts\";\nexport * as Snapshot from \"./snapshot/index.ts\";\nexport * from \"./resource.ts\";\nexport * from \"./config.ts\";\n","import { Schema } from \"effect\";\nimport { AiError } from \"effect/unstable/ai\";\n\nexport class StreamError extends Schema.TaggedErrorClass<StreamError>()(\"StreamError\", {\n cause: Schema.Defect(),\n}) {}\n\nexport const AgentErrorReason = Schema.Union([StreamError]);\n\nexport class AgentError extends Schema.TaggedErrorClass<AgentError>()(\"AgentError\", {\n reason: AgentErrorReason,\n}) {\n static stream = (error: AiError.AiError) =>\n new AgentError({ reason: new StreamError({ cause: error }) });\n}\n","import * as Sandbox from \"@/sandbox/index.ts\";\nimport { Context, Effect, Stream } from \"effect\";\nimport { Prompt, Response } from \"effect/unstable/ai\";\nimport { type AgentError } from \"./error.ts\";\nimport type { Prompt as Trajectory } from \"effect/unstable/ai/Prompt\";\n\nexport type Agent = Readonly<{\n trajectory(): Effect.Effect<Trajectory, AgentError>;\n prompt(options: {\n prompt: ReadonlyArray<Prompt.UserMessage>;\n }): Effect.Effect<Stream.Stream<Response.StreamPart<any>, AgentError>>;\n}>;\n\nexport type Provider = Readonly<{\n deriveSnapshot: (\n options: Readonly<{ snapshot: Sandbox.Snapshot.Snapshot; context: Sandbox.Context.Mode }>,\n ) => Effect.Effect<Sandbox.Snapshot.Snapshot, AgentError>;\n\n runSession(options: Readonly<{ sandbox: Sandbox.Sandbox }>): Effect.Effect<Agent, AgentError>;\n}>;\n\nexport class ProviderService extends Context.Service<ProviderService, Provider>()(\n \"agent/AgentService\",\n) {}\n","export * from \"effect/unstable/ai\";\nexport * from \"./error.ts\";\nexport * from \"./service.ts\";\nexport {\n AssistantMessage,\n Message,\n Prompt as Trajectory,\n SystemMessage,\n ToolMessage,\n UserMessage,\n} from \"effect/unstable/ai/Prompt\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,cAAc,OAAO,YAAY;CAC5C,SAAS,EACP,MAAM,OAAO,OACf;CACA,MAAM;;;;AAIJ,MAAM,OAAO,OACf;CACA,KAAK,EACH,KAAK,OAAO,OACd;CACA,KAAK,EAC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