@smthrs/std 1.0.0-rc.5 → 1.0.0-rc.7
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/README.md +39 -39
- package/dist/cjs/Bash.d.ts +10 -0
- package/dist/cjs/Bash.d.ts.map +1 -1
- package/dist/cjs/Bash.js +13 -12
- package/dist/cjs/Bash.js.map +3 -3
- package/dist/cjs/ExaWebSearch.js +1 -1
- package/dist/cjs/ExaWebSearch.js.map +1 -1
- package/dist/cjs/Fetch.d.ts +1 -1
- package/dist/cjs/Fetch.d.ts.map +1 -1
- package/dist/cjs/Fetch.js +1 -1
- package/dist/cjs/Fetch.js.map +2 -2
- package/dist/cjs/HttpPost.d.ts +1 -1
- package/dist/cjs/HttpPost.d.ts.map +1 -1
- package/dist/cjs/HttpPost.js +1 -1
- package/dist/cjs/HttpPost.js.map +2 -2
- package/dist/cjs/Lsp.d.ts +1 -1
- package/dist/cjs/Manifest.d.ts +8 -8
- package/dist/cjs/NodeLanguageServer.js +1 -1
- package/dist/cjs/NodeLanguageServer.js.map +1 -1
- package/dist/cjs/WebFetch.d.ts.map +1 -1
- package/dist/cjs/WebFetch.js +1 -1
- package/dist/cjs/WebFetch.js.map +2 -2
- package/dist/cjs/internal/Exec.d.ts +14 -7
- package/dist/cjs/internal/Exec.d.ts.map +1 -1
- package/dist/cjs/internal/Exec.js +66 -28
- package/dist/cjs/internal/Exec.js.map +2 -2
- package/dist/cjs/internal/Http.d.ts +1 -1
- package/dist/cjs/internal/Http.d.ts.map +1 -1
- package/dist/cjs/internal/Http.js +1 -1
- package/dist/cjs/internal/Http.js.map +2 -2
- package/dist/cjs/internal/HttpNetwork.d.ts +2 -2
- package/dist/cjs/internal/HttpNetwork.d.ts.map +1 -1
- package/dist/cjs/internal/HttpNetwork.js +3 -3
- package/dist/cjs/internal/HttpNetwork.js.map +1 -1
- package/dist/cjs/internal/Text.d.ts +11 -0
- package/dist/cjs/internal/Text.d.ts.map +1 -1
- package/dist/cjs/internal/Text.js +3 -0
- package/dist/cjs/internal/Text.js.map +2 -2
- package/dist/esm/Bash.d.ts +10 -0
- package/dist/esm/Bash.d.ts.map +1 -1
- package/dist/esm/Bash.js +22 -13
- package/dist/esm/Bash.js.map +1 -1
- package/dist/esm/ExaWebSearch.js +1 -1
- package/dist/esm/ExaWebSearch.js.map +1 -1
- package/dist/esm/Fetch.d.ts +1 -1
- package/dist/esm/Fetch.d.ts.map +1 -1
- package/dist/esm/Fetch.js +1 -1
- package/dist/esm/Fetch.js.map +1 -1
- package/dist/esm/HttpPost.d.ts +1 -1
- package/dist/esm/HttpPost.d.ts.map +1 -1
- package/dist/esm/HttpPost.js +1 -1
- package/dist/esm/HttpPost.js.map +1 -1
- package/dist/esm/Lsp.d.ts +1 -1
- package/dist/esm/Manifest.d.ts +8 -8
- package/dist/esm/NodeLanguageServer.js +1 -1
- package/dist/esm/NodeLanguageServer.js.map +1 -1
- package/dist/esm/WebFetch.d.ts.map +1 -1
- package/dist/esm/WebFetch.js +1 -1
- package/dist/esm/WebFetch.js.map +1 -1
- package/dist/esm/internal/Exec.d.ts +14 -7
- package/dist/esm/internal/Exec.d.ts.map +1 -1
- package/dist/esm/internal/Exec.js +87 -22
- package/dist/esm/internal/Exec.js.map +1 -1
- package/dist/esm/internal/Http.d.ts +1 -1
- package/dist/esm/internal/Http.d.ts.map +1 -1
- package/dist/esm/internal/Http.js +1 -1
- package/dist/esm/internal/Http.js.map +1 -1
- package/dist/esm/internal/HttpNetwork.d.ts +2 -2
- package/dist/esm/internal/HttpNetwork.d.ts.map +1 -1
- package/dist/esm/internal/HttpNetwork.js +3 -3
- package/dist/esm/internal/HttpNetwork.js.map +1 -1
- package/dist/esm/internal/Text.d.ts +11 -0
- package/dist/esm/internal/Text.d.ts.map +1 -1
- package/dist/esm/internal/Text.js +11 -0
- package/dist/esm/internal/Text.js.map +1 -1
- package/docs/api.md +1 -1
- package/docs/concepts/limits-and-disclosure.md +8 -5
- package/docs/guides/run-a-shell-command.md +16 -6
- package/docs/installation.md +1 -1
- package/docs/reference/flows.md +2 -2
- package/docs/troubleshooting.md +3 -3
- package/package.json +10 -10
- package/src/Bash.ts +25 -13
- package/src/ExaWebSearch.ts +1 -1
- package/src/Fetch.ts +1 -1
- package/src/HttpPost.ts +1 -1
- package/src/NodeLanguageServer.ts +1 -1
- package/src/WebFetch.ts +1 -1
- package/src/internal/Exec.ts +126 -44
- package/src/internal/Http.ts +1 -1
- package/src/internal/HttpNetwork.ts +3 -3
- package/src/internal/Text.ts +15 -0
package/dist/esm/Bash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bash.js","sourceRoot":"","sources":["../../src/Bash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC1E,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAA;AAE1B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,G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AAS,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Bash flow declaration and portable handler.\n *\n * Two ways in, and the difference is where the payload is parsed. `command` is\n * a line for the platform shell, exactly as before. `script` is program text\n * delivered to an interpreter on standard input, as data: nothing quotes it,\n * escapes it, or terminates it with a heredoc marker, so the class of failure\n * that produced `docker exec c bash -lc '…python - <<EOF…'` cannot occur. Its\n * `args` reach the script as arguments rather than as interpolated text.\n *\n * `container` names a container the host knows how to reach, and the argv is\n * built by the injected {@link Container} transport rather than typed by the\n * caller. A host that binds no transport refuses such a call by saying so; the\n * requirement is optional here precisely so a host without containers is not\n * forced to declare one.\n *\n * @since 1.0.0\n */\n\nimport type * as ChildProcessSpawner from \"@smthrs/kernel/ChildProcessSpawner\"\nimport * as Path from \"@smthrs/kernel/Path\"\nimport * as Effect from \"effect/Effect\"\nimport * as Option from \"effect/Option\"\nimport * as Schema from \"effect/Schema\"\nimport * as Container from \"./Container.ts\"\nimport { capability, envelope } from \"./internal/Declaration.ts\"\nimport * as Diagnostics from \"./internal/Diagnostics.ts\"\nimport { outsideEnvelope } from \"./internal/EnvelopePrecheck.ts\"\nimport * as Exec from \"./internal/Exec.ts\"\nimport { MAX_SHELL_OUTPUT_BYTES, truncateBytes } from \"./internal/Text.ts\"\nimport * as Probe from \"./Probe.ts\"\nimport * as StdError from \"./StdError.ts\"\nimport * as TreeFingerprint from \"./TreeFingerprint.ts\"\n\n/**\n * Registry name for the bash flow.\n *\n * @category identifiers\n * @since 1.0.0\n */\nexport const name = \"bash\"\n\n/**\n * Model-facing description of the bash flow.\n *\n * Capped at 200 characters and read every frame, which is why the\n * invalid-probe contract is not restated here: the cell contract teaches it\n * once, and a result that has one explains itself.\n *\n * @category descriptions\n * @since 1.0.0\n */\nexport const description =\n \"Run a shell command, or an interpreter over a script passed as data instead of quoted into a line. container routes it through the host's container transport. mode:hermetic pre-checks path tokens.\"\n\n/**\n * Default command timeout in milliseconds.\n *\n * Ten minutes lets full builds and test suites finish while ensuring a stalled\n * process eventually releases the flow.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const DEFAULT_TIMEOUT_MS = 600_000\n\nconst Command = Schema.optional(Schema.String.annotate({\n description: \"Shell command line to execute; give this or script, never both\"\n}))\nconst Script = Schema.optional(Schema.String.annotate({\n description: \"Program text delivered to the interpreter on stdin as data, so it needs no quoting or heredoc\"\n}))\nconst Interpreter = Schema.optional(Schema.String.annotate({\n description:\n \"Program that reads script on stdin; defaults to bash. python, python3, sh, zsh, node, ruby and perl are known\"\n}))\nconst Args = Schema.optional(\n Schema.Array(Schema.String).annotate({\n description: \"Arguments passed to the script as data, never interpolated into it\"\n })\n)\nconst Stdin = Schema.optional(Schema.String.annotate({\n description: \"Text written to the command's standard input; use script instead when the text is the program\"\n}))\nconst ContainerName = Schema.optional(Schema.String.annotate({\n description: \"Run inside this container through the host's container transport; requires mode:unhermetic\"\n}))\nconst Cwd = Schema.optional(Schema.String).annotate({\n description: \"Working directory for the command\",\n message: \"cwd must be a path string. For a checkpoint, pass { at: ctx.base } as the third ctx.call argument.\"\n})\nconst Env = Schema.optional(\n Schema.Record(Schema.String, Schema.String).annotate({ description: \"Environment variables for the command\" })\n)\nconst TimeoutMs = Schema.optional(Schema.Number).annotate({\n description: \"Wall-clock timeout in milliseconds; defaults to 600000 ms\",\n message: \"timeoutMs must be a number of milliseconds.\"\n})\n\n/**\n * Input schema for the bash flow.\n *\n * The mode named `hermetic` requires explicit read and write envelopes for a\n * lexical pre-check; it does not by itself confine the process. Unhermetic mode\n * deliberately omits those declarations so the distinction stays visible in\n * the input shape.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Input = Schema.Union([\n Schema.Struct({\n mode: Schema.Literal(\"hermetic\").annotate({\n description: \"Lexically pre-check explicit path tokens against declared reads and writes; does not sandbox\"\n }),\n command: Command,\n script: Script,\n interpreter: Interpreter,\n args: Args,\n stdin: Stdin,\n container: ContainerName,\n reads: Schema.Array(Schema.NonEmptyString).annotate({ description: \"Paths or path globs the command may read\" }),\n writes: Schema.Array(Schema.NonEmptyString).annotate({ description: \"Paths or path globs the command may write\" }),\n cwd: Cwd,\n env: Env,\n timeoutMs: TimeoutMs\n }),\n Schema.Struct({\n // Omitted means unhermetic: it is the envelope `effects` already declares\n // for every call, so the default grants nothing a named mode would not.\n mode: Schema.Literal(\"unhermetic\").annotate({\n description: \"Run without a declared filesystem envelope as an irreversible effect; the default\"\n }).pipe(Schema.optionalKey, Schema.withDecodingDefaultKey(Effect.succeed(\"unhermetic\" as const))),\n command: Command,\n script: Script,\n interpreter: Interpreter,\n args: Args,\n stdin: Stdin,\n container: ContainerName,\n cwd: Cwd,\n env: Env,\n timeoutMs: TimeoutMs\n })\n])\n\n/**\n * Decoded input accepted by the bash handler.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Input = typeof Input.Type\n\n/**\n * Output schema for the bash flow.\n *\n * `invalidProbe` is present when the shell itself refused to start the\n * command, which its exit code says outright: 127 for a program it could not\n * find, 126 for one it could not execute. Only that. Reading a runner's own\n * wording is a judgment rather than a fact, and `Probe.classify` makes it with\n * Jev for the `test` flow, whose caller is asking about a suite; a shell call\n * is any command at all and stays free of the gateway. See `Probe`.\n *\n * The `<stream>Truncated` flags are a wire convention, not a display detail.\n * A truncated capture is a fragment of what the process printed, and the\n * harness reads these flags to refuse a later write of those exact bytes —\n * `@smthrs/harness/TruncatedOutput` is the consuming half. Renaming a flag, or\n * dropping it when the capture is cut, disarms that guard silently.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Output = Schema.Struct({\n exitCode: Schema.Number.annotate({ description: \"Command exit code, including non-zero codes\" }),\n stdout: Schema.String.annotate({\n description: \"Captured stdout; only the tail, and not the whole output, when stdoutTruncated is true\"\n }),\n stderr: Schema.String.annotate({\n description: \"Captured stderr; only the tail, and not the whole output, when stderrTruncated is true\"\n }),\n stdoutTruncated: Schema.Boolean.annotate({\n description:\n \"Whether stdout exceeded the capture limit, leaving stdout a fragment that must not be written to a file\"\n }),\n stderrTruncated: Schema.Boolean.annotate({\n description:\n \"Whether stderr exceeded the capture limit, leaving stderr a fragment that must not be written to a file\"\n }),\n stdoutDroppedBytes: Schema.Number.annotate({ description: \"UTF-8 bytes omitted from the start of stdout\" }),\n stderrDroppedBytes: Schema.Number.annotate({ description: \"UTF-8 bytes omitted from the start of stderr\" }),\n invalidProbe: Schema.optional(\n Probe.InvalidProbe.annotate({\n description: \"Reserved for a confirmed launch failure; an exit code alone does not establish one\"\n })\n ),\n mutated: Schema.optional(\n Schema.Boolean.annotate({\n description:\n \"Present for a containerised command whose working directory was measured before and after it: true when the tree changed, false when it held still. Absent when the tree was not measured, which is never read as unchanged.\"\n })\n )\n})\n\n/**\n * Decoded output returned by the bash handler.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Output = typeof Output.Type\n\n/**\n * Static conservative effect envelope for the bash flow.\n *\n * The declaration is the registry-time worst case because the mode is not\n * known until an invocation is decoded.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effects = envelope({\n tier: \"irreversible\",\n mode: \"expected\",\n reads: [],\n writes: []\n})\n\n/**\n * Narrows the effect envelope for a decoded invocation.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effectsFor = (input: Input) =>\n input.mode === \"hermetic\"\n ? envelope({\n tier: \"irreversible\",\n mode: \"hermetic\",\n reads: input.reads,\n writes: input.writes\n })\n : envelope({\n tier: \"irreversible\",\n mode: \"expected\",\n reads: [],\n writes: []\n })\n\n/**\n * Capabilities required by the bash flow.\n *\n * @category capabilities\n * @since 1.0.0\n */\nexport const capabilities = [capability(\"proc:spawn\", \"*\")]\n\n/**\n * Declaration-only bash flow.\n *\n * @category flows\n * @since 1.0.0\n */\nexport const flow = { name, description, input: Input, output: Output, capabilities, effects } as const\n\n/*\n * `bash` declares no activity on purpose. What a shell call does is in the\n * command, not in the declaration: the same flow runs a test suite, a type\n * check, and `cat`. A reader that recognises a direct runner says so from the\n * recorded command; everything else stays unknown, which is what an absent\n * activity means.\n */\n\n/**\n * How one recorded call to this flow reads: the verb for each settlement, the\n * input field that is its subject, and the measured output fields a one-line\n * summary may count.\n *\n * Display metadata only, governed by `@smthrs/registry`\n * `Descriptor.CallPresentation` and checked where `StandardFlows` binds it.\n *\n * @category presentation\n * @since 1.0.0-rc.0\n */\nexport const presentation = {\n verb: { pending: \"running\", success: \"ran\", failure: \"failed to run\" },\n subject: \"command\",\n result: \"command\"\n} as const\n\n/**\n * Select standard input explicitly. Shells need `--` before script arguments\n * so even an argument such as `-c` cannot replace the stdin program.\n * Other supported interpreters treat arguments after `-` as program data.\n */\nconst stdinArguments = (interpreter: string): ReadonlyArray<string> | undefined => {\n switch (interpreter) {\n case \"bash\":\n case \"zsh\":\n case \"sh\":\n case \"dash\":\n return [\"-s\", \"--\"]\n case \"python\":\n case \"python3\":\n case \"node\":\n case \"ruby\":\n case \"perl\":\n return [\"-\"]\n default:\n return undefined\n }\n}\n\n/** Whether a script is shell text the lexical pre-check can actually read. */\nconst shells = new Set([\"bash\", \"zsh\", \"sh\", \"dash\"])\n\n/** What one invocation runs, before any container transport rewrites it. */\ninterface Plan {\n readonly file: string\n readonly args: ReadonlyArray<string> | undefined\n readonly stdin: string | undefined\n readonly env: Record<string, string> | undefined\n readonly quoted: string\n}\n\nconst invalid = (message: string): StdError.StdError => new StdError.StdError({ code: \"invalid_input\", message })\n\n/** The invocation an input names, or the failure explaining why it names none. */\nconst plan = (input: Input): Plan | StdError.StdError => {\n const interpreter = input.interpreter ?? \"bash\"\n if (input.command !== undefined && input.script !== undefined) {\n return invalid(\"Give command or script, never both: a script is program text, a command is a shell line\")\n }\n if (input.command === undefined && input.script === undefined) {\n return invalid(\"Give either command (a shell line) or script (program text run by interpreter)\")\n }\n if (input.script !== undefined && input.stdin !== undefined) {\n return invalid(\"A script already arrives on standard input, so it cannot also carry stdin\")\n }\n if (input.command !== undefined && input.args !== undefined) {\n return invalid(\"args belong to a script; a command carries its own arguments in the line\")\n }\n if (input.command !== undefined && input.interpreter !== undefined) {\n return invalid(\"interpreter runs a script; a command runs in the platform shell\")\n }\n if (input.mode === \"hermetic\" && input.container !== undefined) {\n return invalid(\n \"A container has its own filesystem, so declared reads and writes cannot describe it. Use mode:unhermetic for a containerised command\"\n )\n }\n if (input.mode === \"hermetic\" && input.script !== undefined && !shells.has(interpreter)) {\n return invalid(\n `The hermetic pre-check reads shell text, and ${interpreter} is not a shell. Run this script with mode:unhermetic, or express it as shell`\n )\n }\n if (input.command !== undefined) {\n return { file: input.command, args: undefined, stdin: input.stdin, env: input.env, quoted: input.command }\n }\n const selector = stdinArguments(interpreter)\n if (selector === undefined) {\n return invalid(`Unsupported script interpreter: ${interpreter}`)\n }\n const args = [...selector, ...(input.args ?? [])]\n return {\n file: interpreter,\n args,\n stdin: input.script,\n env: input.env,\n quoted: [interpreter, ...args].join(\" \")\n }\n}\n\n/**\n * The plan, refused when its input names no one invocation or when a hermetic\n * call's paths fall outside its declared envelope. Spawned and terminal\n * execution share this one check.\n */\nconst precheck = (input: Input, path: Path.Path): Plan | StdError.StdError => {\n const intent = plan(input)\n if (intent instanceof StdError.StdError || input.mode !== \"hermetic\") return intent\n // A planned call carries exactly one of command or script.\n return outsideEnvelope(input, input.command ?? input.script!, path) ?? intent\n}\n\n/** The plan as the host will spawn it, once the container transport has had it. */\nconst routed = (\n plan: Plan,\n input: Input,\n transport: Option.Option<Container.Container>\n): Effect.Effect<Plan, StdError.StdError> => {\n if (input.container === undefined) return Effect.succeed(plan)\n if (Option.isNone(transport)) return Effect.fail(Container.unavailable(input.container))\n return Effect.map(\n transport.value.exec(request(plan, input, input.container)),\n (routing): Plan => ({\n file: routing.file,\n args: routing.args,\n stdin: plan.stdin,\n env: routing.env,\n // Diagnostics describe the logical invocation, not transport arguments.\n quoted: plan.quoted\n })\n )\n}\n\n/**\n * One containerised request, always through a login shell.\n *\n * A container's environment is what its profile makes it. The images this\n * harness runs against activate the project's interpreter — a conda env, a\n * virtualenv, a modified `PATH` — from `/etc/profile.d`, so a program spawned\n * directly by `docker exec` gets a different Python from the one that owns the\n * repository's dependencies. That is measured, not theoretical: r90 typed\n * `docker exec … bash -lc '…'` by hand and got the activation for free, r91\n * routed `interpreter: \"python3\"` straight at the container and filled its\n * traces with `ModuleNotFoundError: No module named 'numpy'` and\n * `exec: \"/usr/local/bin/python\": no such file or directory`. Thirty of 45\n * instances then spent 138 cells scanning `/opt` for the real interpreter.\n *\n * So the login shell is the transport's, not the caller's. A command line is\n * one argument to `bash -lc`, as before. A program run under an interpreter\n * becomes `bash -lc 'exec \"$@\"' bash <interpreter> <args…>`: the shell reads\n * the profile, then `exec` replaces it with the interpreter, so the script\n * still arrives on the inherited standard input and no argument is ever\n * re-parsed as shell text.\n */\nconst request = (plan: Plan, input: Input, container: string): Container.Request => ({\n container,\n file: \"bash\",\n args: plan.args === undefined\n ? [\"-lc\", plan.file]\n : [\"-lc\", `exec \"$@\"`, \"bash\", plan.file, ...plan.args],\n ...(input.cwd === undefined ? {} : { cwd: input.cwd }),\n ...(input.env === undefined ? {} : { env: input.env }),\n stdin: plan.stdin !== undefined\n})\n\n/** How long one fingerprint of the container's working directory may take. */\nconst FINGERPRINT_TIMEOUT_MS = 60_000\n\n/**\n * Measures the tree a containerised command is about to run in, or just ran in.\n *\n * The host's workspace walk cannot see a container's filesystem, so the\n * measurement is taken where the tree is: `TreeFingerprint.script` runs\n * through the same transport as the command, in the same working directory,\n * and answers with one checksum. Every way this can fail — no transport, a\n * container without `find` or `stat`, a timeout, a bounded listing — is read\n * as \"unmeasured\" and reported as an absent `mutated`, never as a tree that\n * held still. The time it costs is bounded by the command's own timeout so a\n * stalled container cannot spend more waiting to be measured than it may\n * spend running.\n */\nconst fingerprint = (\n input: Input,\n transport: Option.Option<Container.Container>\n): Effect.Effect<TreeFingerprint.Measurement | undefined, never, ChildProcessSpawner.ChildProcessSpawner> =>\n Effect.gen(function*() {\n if (input.container === undefined || Option.isNone(transport)) return undefined\n const routing = yield* transport.value.exec({\n container: input.container,\n file: \"sh\",\n args: [\"-c\", TreeFingerprint.script()],\n ...(input.cwd === undefined ? {} : { cwd: input.cwd }),\n stdin: false\n })\n const result = yield* Exec.exec(routing.file, {\n ...(routing.env === undefined ? {} : { env: routing.env }),\n timeoutMs: Math.min(input.timeoutMs ?? DEFAULT_TIMEOUT_MS, FINGERPRINT_TIMEOUT_MS),\n maxCaptureBytes: MAX_SHELL_OUTPUT_BYTES,\n args: routing.args\n })\n return result.exitCode === 0 ? TreeFingerprint.parse(result.stdout) : undefined\n }).pipe(Effect.orElseSucceed(() => undefined))\n\n/**\n * Executes a shell command through the permission-aware kernel service.\n *\n * Non-zero exit codes remain successful values. Only timeout, host, permission,\n * and declared-envelope pre-check failures use the typed error channel.\n *\n * @category handlers\n * @since 1.0.0\n */\nexport const run = Effect.fn(\"Bash.run\")(function*(\n input: Input\n): Effect.fn.Return<Output, StdError.StdError, ChildProcessSpawner.ChildProcessSpawner | Path.Path> {\n const intent = precheck(input, yield* Path.Path)\n if (intent instanceof StdError.StdError) return yield* Effect.fail(intent)\n // The working directory belongs to the container. The transport supplies\n // any environment overrides its host process needs to forward into it.\n const contained = input.container !== undefined\n const transport = yield* Effect.serviceOption(Container.Container)\n const spawned = yield* routed(intent, input, transport)\n\n // The tree the command runs in, before it runs. Measured in the container\n // because nothing on this host can see it; see `TreeFingerprint`.\n const before = yield* fingerprint(input, transport)\n const result = yield* Exec.exec(spawned.file, {\n ...(input.cwd === undefined || contained ? {} : { cwd: input.cwd }),\n ...(spawned.env === undefined ? {} : { env: spawned.env }),\n timeoutMs: input.timeoutMs ?? DEFAULT_TIMEOUT_MS,\n maxCaptureBytes: MAX_SHELL_OUTPUT_BYTES,\n ...(spawned.args === undefined ? {} : { args: spawned.args }),\n ...(spawned.stdin === undefined ? {} : { stdin: spawned.stdin })\n }).pipe(Effect.mapError((error) => Exec.toStdError(spawned.quoted, error)))\n const mutated = TreeFingerprint.moved(before, yield* fingerprint(input, transport))\n // A command on this host may have changed files a language server holds\n // open; a container's files are not the ones it was sent.\n if (!contained) yield* Diagnostics.refresh\n const stdout = truncateBytes(result.stdout, MAX_SHELL_OUTPUT_BYTES, { keep: \"tail\" })\n const stderr = truncateBytes(result.stderr, MAX_SHELL_OUTPUT_BYTES, { keep: \"tail\" })\n // Exit codes alone cannot establish whether the shell refused to launch a\n // command or a launched runner chose that status after executing tests.\n return {\n exitCode: result.exitCode,\n stdout: stdout.text,\n stderr: stderr.text,\n stdoutTruncated: result.stdoutDroppedBytes > 0 || stdout.truncated,\n stderrTruncated: result.stderrDroppedBytes > 0 || stderr.truncated,\n stdoutDroppedBytes: result.stdoutDroppedBytes + stdout.droppedBytes,\n stderrDroppedBytes: result.stderrDroppedBytes + stderr.droppedBytes,\n ...(mutated === undefined ? {} : { mutated })\n }\n})\n\n/**\n * What one call runs, after planning and before any transport: the program,\n * its arguments (absent for a shell command line), standard input, the\n * caller's environment, and the logical invocation as a person reads it.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface Invocation {\n readonly file: string\n readonly args: ReadonlyArray<string> | undefined\n readonly stdin: string | undefined\n readonly env: Record<string, string> | undefined\n readonly quoted: string\n}\n\n/**\n * The invocation `input` names, or the typed refusal explaining why it names\n * none. The same plan {@link run} spawns; a terminal provider runs it instead.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const invocation = (input: Input): Invocation | StdError.StdError => plan(input)\n\n/**\n * {@link run}'s contract through a registered terminal (T-TRM-05): the same\n * plan, hermetic pre-check, bounded output and diagnostics refresh, with\n * execution supplied by `execute` instead of a spawn on this host. A terminal\n * has no container transport, so a containerised call is refused before it\n * reaches `execute`.\n *\n * @category handlers\n * @since 1.0.0\n */\nexport const inTerminal = <R>(\n execute: (input: Input) => Effect.Effect<Output, StdError.StdError, R>\n) =>\n Effect.fn(\"Bash.inTerminal\")(function*(\n input: Input\n ): Effect.fn.Return<Output, StdError.StdError, R | Path.Path> {\n const intent = precheck(input, yield* Path.Path)\n if (intent instanceof StdError.StdError) return yield* Effect.fail(intent)\n if (input.container !== undefined) return yield* Effect.fail(Container.unavailable(input.container))\n const output = yield* execute(input)\n // The terminal ran on this workspace: files a language server holds may\n // have changed, exactly as after a spawn here.\n yield* Diagnostics.refresh\n return output\n })\n\n/**\n * The refusal a sealed host answers a call outside its container with.\n *\n * @category errors\n * @since 1.0.0-rc.1\n */\nexport const outsideContainer = (sealedTo: string, requested: string | undefined): StdError.StdError =>\n new StdError.StdError({\n code: \"outside_container\",\n message: requested === undefined\n ? `This host runs commands only inside container \"${sealedTo}\". Name it: { mode: \"unhermetic\", container: \"${sealedTo}\", command: \"...\" }.`\n : `This host runs commands only inside container \"${sealedTo}\", not \"${requested}\".`\n })\n\n/**\n * {@link run}, sealed to one container.\n *\n * A host that must not be reachable from the cell (a benchmark host holding\n * other tasks' tests and reference solutions, say) binds this instead of\n * {@link run}: a call naming `sealedTo` runs as usual, and every other call,\n * including one with no container that would run on the host, fails with\n * `outside_container` before anything is spawned.\n *\n * @category handlers\n * @since 1.0.0-rc.1\n */\nexport const sealed = (sealedTo: string) =>\n(\n input: Input\n): Effect.Effect<Output, StdError.StdError, ChildProcessSpawner.ChildProcessSpawner | Path.Path> =>\n input.container === sealedTo ? run(input) : Effect.fail(outsideContainer(sealedTo, input.container))\n"]}
|
|
1
|
+
{"version":3,"file":"Bash.js","sourceRoot":"","sources":["../../src/Bash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;A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KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Bash flow declaration and portable handler.\n *\n * Two ways in, and the difference is where the payload is parsed. `command` is\n * a line for the platform shell, exactly as before. `script` is program text\n * delivered to an interpreter on standard input, as data: nothing quotes it,\n * escapes it, or terminates it with a heredoc marker, so the class of failure\n * that produced `docker exec c bash -lc '…python - <<EOF…'` cannot occur. Its\n * `args` reach the script as arguments rather than as interpolated text.\n *\n * `container` names a container the host knows how to reach, and the argv is\n * built by the injected {@link Container} transport rather than typed by the\n * caller. A host that binds no transport refuses such a call by saying so; the\n * requirement is optional here precisely so a host without containers is not\n * forced to declare one.\n *\n * @since 1.0.0\n */\n\nimport type * as ChildProcessSpawner from \"@smthrs/kernel/ChildProcessSpawner\"\nimport * as Path from \"@smthrs/kernel/Path\"\nimport * as Effect from \"effect/Effect\"\nimport * as Option from \"effect/Option\"\nimport * as Schema from \"effect/Schema\"\nimport * as Container from \"./Container.ts\"\nimport { capability, envelope } from \"./internal/Declaration.ts\"\nimport * as Diagnostics from \"./internal/Diagnostics.ts\"\nimport { outsideEnvelope } from \"./internal/EnvelopePrecheck.ts\"\nimport * as Exec from \"./internal/Exec.ts\"\nimport { elideMiddle as elide, MAX_SHELL_OUTPUT_BYTES } from \"./internal/Text.ts\"\nimport * as Probe from \"./Probe.ts\"\nimport * as StdError from \"./StdError.ts\"\nimport * as TreeFingerprint from \"./TreeFingerprint.ts\"\n\n/**\n * Registry name for the bash flow.\n *\n * @category identifiers\n * @since 1.0.0\n */\nexport const name = \"bash\"\n\n/**\n * Model-facing description of the bash flow.\n *\n * Capped at 200 characters and read every frame, which is why the\n * invalid-probe contract is not restated here: the cell contract teaches it\n * once, and a result that has one explains itself.\n *\n * @category descriptions\n * @since 1.0.0\n */\nexport const description =\n \"Run a shell command, or an interpreter over a script passed as data instead of quoted into a line. container routes it through the host's container transport. mode:hermetic pre-checks path tokens.\"\n\n/**\n * Default command timeout in milliseconds.\n *\n * Ten minutes lets full builds and test suites finish while ensuring a stalled\n * process eventually releases the flow.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const DEFAULT_TIMEOUT_MS = 600_000\n\nconst Command = Schema.optional(Schema.String.annotate({\n description: \"Shell command line to execute; give this or script, never both\"\n}))\nconst Script = Schema.optional(Schema.String.annotate({\n description: \"Program text delivered to the interpreter on stdin as data, so it needs no quoting or heredoc\"\n}))\nconst Interpreter = Schema.optional(Schema.String.annotate({\n description:\n \"Program that reads script on stdin; defaults to bash. python, python3, sh, zsh, node, ruby and perl are known\"\n}))\nconst Args = Schema.optional(\n Schema.Array(Schema.String).annotate({\n description: \"Arguments passed to the script as data, never interpolated into it\"\n })\n)\nconst Stdin = Schema.optional(Schema.String.annotate({\n description: \"Text written to the command's standard input; use script instead when the text is the program\"\n}))\nconst ContainerName = Schema.optional(Schema.String.annotate({\n description: \"Run inside this container through the host's container transport; requires mode:unhermetic\"\n}))\nconst Cwd = Schema.optional(Schema.String).annotate({\n description: \"Working directory for the command\",\n message: \"cwd must be a path string. For a checkpoint, pass { at: ctx.base } as the third ctx.call argument.\"\n})\nconst Env = Schema.optional(\n Schema.Record(Schema.String, Schema.String).annotate({ description: \"Environment variables for the command\" })\n)\nconst TimeoutMs = Schema.optional(Schema.Number).annotate({\n description: \"Wall-clock timeout in milliseconds; defaults to 600000 ms\",\n message: \"timeoutMs must be a number of milliseconds.\"\n})\n\n/**\n * Input schema for the bash flow.\n *\n * The mode named `hermetic` requires explicit read and write envelopes for a\n * lexical pre-check; it does not by itself confine the process. Unhermetic mode\n * deliberately omits those declarations so the distinction stays visible in\n * the input shape.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Input = Schema.Union([\n Schema.Struct({\n mode: Schema.Literal(\"hermetic\").annotate({\n description: \"Lexically pre-check explicit path tokens against declared reads and writes; does not sandbox\"\n }),\n command: Command,\n script: Script,\n interpreter: Interpreter,\n args: Args,\n stdin: Stdin,\n container: ContainerName,\n reads: Schema.Array(Schema.NonEmptyString).annotate({ description: \"Paths or path globs the command may read\" }),\n writes: Schema.Array(Schema.NonEmptyString).annotate({ description: \"Paths or path globs the command may write\" }),\n cwd: Cwd,\n env: Env,\n timeoutMs: TimeoutMs\n }),\n Schema.Struct({\n // Omitted means unhermetic: it is the envelope `effects` already declares\n // for every call, so the default grants nothing a named mode would not.\n mode: Schema.Literal(\"unhermetic\").annotate({\n description: \"Run without a declared filesystem envelope as an irreversible effect; the default\"\n }).pipe(Schema.optionalKey, Schema.withDecodingDefaultKey(Effect.succeed(\"unhermetic\" as const))),\n command: Command,\n script: Script,\n interpreter: Interpreter,\n args: Args,\n stdin: Stdin,\n container: ContainerName,\n cwd: Cwd,\n env: Env,\n timeoutMs: TimeoutMs\n })\n])\n\n/**\n * Decoded input accepted by the bash handler.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Input = typeof Input.Type\n\n/**\n * Output schema for the bash flow.\n *\n * `invalidProbe` is present when the shell itself refused to start the\n * command, which its exit code says outright: 127 for a program it could not\n * find, 126 for one it could not execute. Only that. Reading a runner's own\n * wording is a judgment rather than a fact, and `Probe.classify` makes it with\n * Jev for the `test` flow, whose caller is asking about a suite; a shell call\n * is any command at all and stays free of the gateway. See `Probe`.\n *\n * The `<stream>Truncated` flags are a wire convention, not a display detail.\n * A truncated capture is a fragment of what the process printed, and the\n * harness reads these flags to refuse a later write of those exact bytes —\n * `@smthrs/harness/TruncatedOutput` is the consuming half. Renaming a flag, or\n * dropping it when the capture is cut, disarms that guard silently.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Output = Schema.Struct({\n exitCode: Schema.Number.annotate({ description: \"Command exit code, including non-zero codes\" }),\n stdout: Schema.String.annotate({\n description:\n \"Captured stdout; when stdoutTruncated is true, only its start and end, with one line naming the bytes omitted between them\"\n }),\n stderr: Schema.String.annotate({\n description:\n \"Captured stderr; when stderrTruncated is true, only its start and end, with one line naming the bytes omitted between them\"\n }),\n stdoutTruncated: Schema.Boolean.annotate({\n description:\n \"Whether stdout exceeded the capture limit, leaving stdout a fragment that must not be written to a file\"\n }),\n stderrTruncated: Schema.Boolean.annotate({\n description:\n \"Whether stderr exceeded the capture limit, leaving stderr a fragment that must not be written to a file\"\n }),\n stdoutDroppedBytes: Schema.Number.annotate({ description: \"UTF-8 bytes omitted from the middle of stdout\" }),\n stderrDroppedBytes: Schema.Number.annotate({ description: \"UTF-8 bytes omitted from the middle of stderr\" }),\n invalidProbe: Schema.optional(\n Probe.InvalidProbe.annotate({\n description: \"Reserved for a confirmed launch failure; an exit code alone does not establish one\"\n })\n ),\n mutated: Schema.optional(\n Schema.Boolean.annotate({\n description:\n \"Present for a containerised command whose working directory was measured before and after it: true when the tree changed, false when it held still. Absent when the tree was not measured, which is never read as unchanged.\"\n })\n )\n})\n\n/**\n * Decoded output returned by the bash handler.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Output = typeof Output.Type\n\n/**\n * The text of a stream cut to its start and end: the start, one line naming\n * the bytes omitted between them, and the end. A host that captures output\n * itself, such as a terminal behind {@link inTerminal}, cuts with this so every\n * {@link Output} reads the same.\n *\n * @category rendering\n * @since 1.0.0-rc.5\n */\nexport const elideMiddle: (start: string, droppedBytes: number, end: string) => string = elide\n\n/**\n * Static conservative effect envelope for the bash flow.\n *\n * The declaration is the registry-time worst case because the mode is not\n * known until an invocation is decoded.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effects = envelope({\n tier: \"irreversible\",\n mode: \"expected\",\n reads: [],\n writes: []\n})\n\n/**\n * Narrows the effect envelope for a decoded invocation.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effectsFor = (input: Input) =>\n input.mode === \"hermetic\"\n ? envelope({\n tier: \"irreversible\",\n mode: \"hermetic\",\n reads: input.reads,\n writes: input.writes\n })\n : envelope({\n tier: \"irreversible\",\n mode: \"expected\",\n reads: [],\n writes: []\n })\n\n/**\n * Capabilities required by the bash flow.\n *\n * @category capabilities\n * @since 1.0.0\n */\nexport const capabilities = [capability(\"proc:spawn\", \"*\")]\n\n/**\n * Declaration-only bash flow.\n *\n * @category flows\n * @since 1.0.0\n */\nexport const flow = { name, description, input: Input, output: Output, capabilities, effects } as const\n\n/*\n * `bash` declares no activity on purpose. What a shell call does is in the\n * command, not in the declaration: the same flow runs a test suite, a type\n * check, and `cat`. A reader that recognises a direct runner says so from the\n * recorded command; everything else stays unknown, which is what an absent\n * activity means.\n */\n\n/**\n * How one recorded call to this flow reads: the verb for each settlement, the\n * input field that is its subject, and the measured output fields a one-line\n * summary may count.\n *\n * Display metadata only, governed by `@smthrs/registry`\n * `Descriptor.CallPresentation` and checked where `StandardFlows` binds it.\n *\n * @category presentation\n * @since 1.0.0-rc.0\n */\nexport const presentation = {\n verb: { pending: \"running\", success: \"ran\", failure: \"failed to run\" },\n subject: \"command\",\n result: \"command\"\n} as const\n\n/**\n * Select standard input explicitly. Shells need `--` before script arguments\n * so even an argument such as `-c` cannot replace the stdin program.\n * Other supported interpreters treat arguments after `-` as program data.\n */\nconst stdinArguments = (interpreter: string): ReadonlyArray<string> | undefined => {\n switch (interpreter) {\n case \"bash\":\n case \"zsh\":\n case \"sh\":\n case \"dash\":\n return [\"-s\", \"--\"]\n case \"python\":\n case \"python3\":\n case \"node\":\n case \"ruby\":\n case \"perl\":\n return [\"-\"]\n default:\n return undefined\n }\n}\n\n/** Whether a script is shell text the lexical pre-check can actually read. */\nconst shells = new Set([\"bash\", \"zsh\", \"sh\", \"dash\"])\n\n/** What one invocation runs, before any container transport rewrites it. */\ninterface Plan {\n readonly file: string\n readonly args: ReadonlyArray<string> | undefined\n readonly stdin: string | undefined\n readonly env: Record<string, string> | undefined\n readonly quoted: string\n}\n\nconst invalid = (message: string): StdError.StdError => new StdError.StdError({ code: \"invalid_input\", message })\n\n/** The invocation an input names, or the failure explaining why it names none. */\nconst plan = (input: Input): Plan | StdError.StdError => {\n const interpreter = input.interpreter ?? \"bash\"\n if (input.command !== undefined && input.script !== undefined) {\n return invalid(\"Give command or script, never both: a script is program text, a command is a shell line\")\n }\n if (input.command === undefined && input.script === undefined) {\n return invalid(\"Give either command (a shell line) or script (program text run by interpreter)\")\n }\n if (input.script !== undefined && input.stdin !== undefined) {\n return invalid(\"A script already arrives on standard input, so it cannot also carry stdin\")\n }\n if (input.command !== undefined && input.args !== undefined) {\n return invalid(\"args belong to a script; a command carries its own arguments in the line\")\n }\n if (input.command !== undefined && input.interpreter !== undefined) {\n return invalid(\"interpreter runs a script; a command runs in the platform shell\")\n }\n if (input.mode === \"hermetic\" && input.container !== undefined) {\n return invalid(\n \"A container has its own filesystem, so declared reads and writes cannot describe it. Use mode:unhermetic for a containerised command\"\n )\n }\n if (input.mode === \"hermetic\" && input.script !== undefined && !shells.has(interpreter)) {\n return invalid(\n `The hermetic pre-check reads shell text, and ${interpreter} is not a shell. Run this script with mode:unhermetic, or express it as shell`\n )\n }\n if (input.command !== undefined) {\n return { file: input.command, args: undefined, stdin: input.stdin, env: input.env, quoted: input.command }\n }\n const selector = stdinArguments(interpreter)\n if (selector === undefined) {\n return invalid(`Unsupported script interpreter: ${interpreter}`)\n }\n const args = [...selector, ...(input.args ?? [])]\n return {\n file: interpreter,\n args,\n stdin: input.script,\n env: input.env,\n quoted: [interpreter, ...args].join(\" \")\n }\n}\n\n/**\n * The plan, refused when its input names no one invocation or when a hermetic\n * call's paths fall outside its declared envelope. Spawned and terminal\n * execution share this one check.\n */\nconst precheck = (input: Input, path: Path.Path): Plan | StdError.StdError => {\n const intent = plan(input)\n if (intent instanceof StdError.StdError || input.mode !== \"hermetic\") return intent\n // A planned call carries exactly one of command or script.\n return outsideEnvelope(input, input.command ?? input.script!, path) ?? intent\n}\n\n/** The plan as the host will spawn it, once the container transport has had it. */\nconst routed = (\n plan: Plan,\n input: Input,\n transport: Option.Option<Container.Container>\n): Effect.Effect<Plan, StdError.StdError> => {\n if (input.container === undefined) return Effect.succeed(plan)\n if (Option.isNone(transport)) return Effect.fail(Container.unavailable(input.container))\n return Effect.map(\n transport.value.exec(request(plan, input, input.container)),\n (routing): Plan => ({\n file: routing.file,\n args: routing.args,\n stdin: plan.stdin,\n env: routing.env,\n // Diagnostics describe the logical invocation, not transport arguments.\n quoted: plan.quoted\n })\n )\n}\n\n/**\n * One containerised request, always through a login shell.\n *\n * A container's environment is what its profile makes it. The images this\n * harness runs against activate the project's interpreter — a conda env, a\n * virtualenv, a modified `PATH` — from `/etc/profile.d`, so a program spawned\n * directly by `docker exec` gets a different Python from the one that owns the\n * repository's dependencies. That is measured, not theoretical: r90 typed\n * `docker exec … bash -lc '…'` by hand and got the activation for free, r91\n * routed `interpreter: \"python3\"` straight at the container and filled its\n * traces with `ModuleNotFoundError: No module named 'numpy'` and\n * `exec: \"/usr/local/bin/python\": no such file or directory`. Thirty of 45\n * instances then spent 138 cells scanning `/opt` for the real interpreter.\n *\n * So the login shell is the transport's, not the caller's. A command line is\n * one argument to `bash -lc`, as before. A program run under an interpreter\n * becomes `bash -lc 'exec \"$@\"' bash <interpreter> <args…>`: the shell reads\n * the profile, then `exec` replaces it with the interpreter, so the script\n * still arrives on the inherited standard input and no argument is ever\n * re-parsed as shell text.\n */\nconst request = (plan: Plan, input: Input, container: string): Container.Request => ({\n container,\n file: \"bash\",\n args: plan.args === undefined\n ? [\"-lc\", plan.file]\n : [\"-lc\", `exec \"$@\"`, \"bash\", plan.file, ...plan.args],\n ...(input.cwd === undefined ? {} : { cwd: input.cwd }),\n ...(input.env === undefined ? {} : { env: input.env }),\n stdin: plan.stdin !== undefined\n})\n\n/** How long one fingerprint of the container's working directory may take. */\nconst FINGERPRINT_TIMEOUT_MS = 60_000\n\n/**\n * Measures the tree a containerised command is about to run in, or just ran in.\n *\n * The host's workspace walk cannot see a container's filesystem, so the\n * measurement is taken where the tree is: `TreeFingerprint.script` runs\n * through the same transport as the command, in the same working directory,\n * and answers with one checksum. Every way this can fail — no transport, a\n * container without `find` or `stat`, a timeout, a bounded listing — is read\n * as \"unmeasured\" and reported as an absent `mutated`, never as a tree that\n * held still. The time it costs is bounded by the command's own timeout so a\n * stalled container cannot spend more waiting to be measured than it may\n * spend running.\n */\nconst fingerprint = (\n input: Input,\n transport: Option.Option<Container.Container>\n): Effect.Effect<TreeFingerprint.Measurement | undefined, never, ChildProcessSpawner.ChildProcessSpawner> =>\n Effect.gen(function*() {\n if (input.container === undefined || Option.isNone(transport)) return undefined\n const routing = yield* transport.value.exec({\n container: input.container,\n file: \"sh\",\n args: [\"-c\", TreeFingerprint.script()],\n ...(input.cwd === undefined ? {} : { cwd: input.cwd }),\n stdin: false\n })\n const result = yield* Exec.exec(routing.file, {\n ...(routing.env === undefined ? {} : { env: routing.env }),\n timeoutMs: Math.min(input.timeoutMs ?? DEFAULT_TIMEOUT_MS, FINGERPRINT_TIMEOUT_MS),\n maxCaptureBytes: MAX_SHELL_OUTPUT_BYTES,\n args: routing.args\n })\n return result.exitCode === 0 ? TreeFingerprint.parse(result.stdout) : undefined\n }).pipe(Effect.orElseSucceed(() => undefined))\n\n/**\n * Executes a shell command through the permission-aware kernel service.\n *\n * Non-zero exit codes remain successful values. Only timeout, host, permission,\n * and declared-envelope pre-check failures use the typed error channel.\n *\n * @category handlers\n * @since 1.0.0\n */\nexport const run = Effect.fn(\"Bash.run\")(function*(\n input: Input\n): Effect.fn.Return<Output, StdError.StdError, ChildProcessSpawner.ChildProcessSpawner | Path.Path> {\n const intent = precheck(input, yield* Path.Path)\n if (intent instanceof StdError.StdError) return yield* Effect.fail(intent)\n // The working directory belongs to the container. The transport supplies\n // any environment overrides its host process needs to forward into it.\n const contained = input.container !== undefined\n const transport = yield* Effect.serviceOption(Container.Container)\n const spawned = yield* routed(intent, input, transport)\n\n // The tree the command runs in, before it runs. Measured in the container\n // because nothing on this host can see it; see `TreeFingerprint`.\n const before = yield* fingerprint(input, transport)\n const result = yield* Exec.exec(spawned.file, {\n ...(input.cwd === undefined || contained ? {} : { cwd: input.cwd }),\n ...(spawned.env === undefined ? {} : { env: spawned.env }),\n timeoutMs: input.timeoutMs ?? DEFAULT_TIMEOUT_MS,\n maxCaptureBytes: MAX_SHELL_OUTPUT_BYTES,\n overflow: \"ends\",\n ...(spawned.args === undefined ? {} : { args: spawned.args }),\n ...(spawned.stdin === undefined ? {} : { stdin: spawned.stdin })\n }).pipe(Effect.mapError((error) => Exec.toStdError(spawned.quoted, error)))\n const mutated = TreeFingerprint.moved(before, yield* fingerprint(input, transport))\n // A command on this host may have changed files a language server holds\n // open; a container's files are not the ones it was sent.\n if (!contained) yield* Diagnostics.refresh\n // Exit codes alone cannot establish whether the shell refused to launch a\n // command or a launched runner chose that status after executing tests.\n return {\n exitCode: result.exitCode,\n stdout: result.stdout,\n stderr: result.stderr,\n stdoutTruncated: result.stdoutDroppedBytes > 0,\n stderrTruncated: result.stderrDroppedBytes > 0,\n stdoutDroppedBytes: result.stdoutDroppedBytes,\n stderrDroppedBytes: result.stderrDroppedBytes,\n ...(mutated === undefined ? {} : { mutated })\n }\n})\n\n/**\n * What one call runs, after planning and before any transport: the program,\n * its arguments (absent for a shell command line), standard input, the\n * caller's environment, and the logical invocation as a person reads it.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface Invocation {\n readonly file: string\n readonly args: ReadonlyArray<string> | undefined\n readonly stdin: string | undefined\n readonly env: Record<string, string> | undefined\n readonly quoted: string\n}\n\n/**\n * The invocation `input` names, or the typed refusal explaining why it names\n * none. The same plan {@link run} spawns; a terminal provider runs it instead.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const invocation = (input: Input): Invocation | StdError.StdError => plan(input)\n\n/**\n * {@link run}'s contract through a registered terminal (T-TRM-05): the same\n * plan, hermetic pre-check, bounded output and diagnostics refresh, with\n * execution supplied by `execute` instead of a spawn on this host. A terminal\n * has no container transport, so a containerised call is refused before it\n * reaches `execute`.\n *\n * @category handlers\n * @since 1.0.0\n */\nexport const inTerminal = <R>(\n execute: (input: Input) => Effect.Effect<Output, StdError.StdError, R>\n) =>\n Effect.fn(\"Bash.inTerminal\")(function*(\n input: Input\n ): Effect.fn.Return<Output, StdError.StdError, R | Path.Path> {\n const intent = precheck(input, yield* Path.Path)\n if (intent instanceof StdError.StdError) return yield* Effect.fail(intent)\n if (input.container !== undefined) return yield* Effect.fail(Container.unavailable(input.container))\n const output = yield* execute(input)\n // The terminal ran on this workspace: files a language server holds may\n // have changed, exactly as after a spawn here.\n yield* Diagnostics.refresh\n return output\n })\n\n/**\n * The refusal a sealed host answers a call outside its container with.\n *\n * @category errors\n * @since 1.0.0-rc.1\n */\nexport const outsideContainer = (sealedTo: string, requested: string | undefined): StdError.StdError =>\n new StdError.StdError({\n code: \"outside_container\",\n message: requested === undefined\n ? `This host runs commands only inside container \"${sealedTo}\". Name it: { mode: \"unhermetic\", container: \"${sealedTo}\", command: \"...\" }.`\n : `This host runs commands only inside container \"${sealedTo}\", not \"${requested}\".`\n })\n\n/**\n * {@link run}, sealed to one container.\n *\n * A host that must not be reachable from the cell (a benchmark host holding\n * other tasks' tests and reference solutions, say) binds this instead of\n * {@link run}: a call naming `sealedTo` runs as usual, and every other call,\n * including one with no container that would run on the host, fails with\n * `outside_container` before anything is spawned.\n *\n * @category handlers\n * @since 1.0.0-rc.1\n */\nexport const sealed = (sealedTo: string) =>\n(\n input: Input\n): Effect.Effect<Output, StdError.StdError, ChildProcessSpawner.ChildProcessSpawner | Path.Path> =>\n input.container === sealedTo ? run(input) : Effect.fail(outsideContainer(sealedTo, input.container))\n"]}
|
package/dist/esm/ExaWebSearch.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import * as Credential from "@smthrs/control/Credential";
|
|
11
11
|
import * as HttpClient from "@smthrs/kernel/HttpClient";
|
|
12
12
|
import { Clock, Effect, Layer, Redacted, Schema } from "effect";
|
|
13
|
-
import * as HttpClientRequest from "effect/
|
|
13
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
14
14
|
import { header, readBounded } from "./internal/Http.js";
|
|
15
15
|
import * as StdError from "./StdError.js";
|
|
16
16
|
import * as WebSearch from "./WebSearch.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExaWebSearch.js","sourceRoot":"","sources":["../../src/ExaWebSearch.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/D,OAAO,KAAK,iBAAiB,MAAM,wCAAwC,CAAA;AAC3E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C,MAAM,UAAU,GAAG,EAAE,CAAA;AACrB,MAAM,gBAAgB,GAAG,MAAM,CAAA;AAC/B,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACrC,GAAG,EAAE,MAAM,CAAC,MAAM;IAClB,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CAC9C,CAAC,CAAA;AACF,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;CACjC,CAAC,CAAA;AACF,MAAM,aAAa,GAAG;IACpB,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,GAAG;CACD,C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AAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;oBAC5C,GAAG,CAAC,MAAM,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;iBACrF,CAAC,CAAC;aACJ,CAAA;QACH,CAAC,CAAC;KACL,CAAC,CAAA;AACJ,CAAC,CAAC,CACH,CAAA","sourcesContent":["/**\n * The Exa provider for the `websearch` flow.\n *\n * {@link layer} binds `WebSearch.WebSearch` to the Exa search API. It reads the\n * API key from a named credential on every search, calls Exa through the\n * permission-checked `HttpClient`, and maps each hit onto `WebSearch.Result`.\n *\n * @since 1.0.0\n */\n\nimport * as Credential from \"@smthrs/control/Credential\"\nimport * as HttpClient from \"@smthrs/kernel/HttpClient\"\nimport { Clock, Effect, Layer, Redacted, Schema } from \"effect\"\nimport * as HttpClientRequest from \"effect/unstable/http/HttpClientRequest\"\nimport { header, readBounded } from \"./internal/Http.ts\"\nimport * as StdError from \"./StdError.ts\"\nimport * as WebSearch from \"./WebSearch.ts\"\n\nconst maxResults = 20\nconst requestTimeoutMs = 30_000\nconst ExaResult = Schema.Struct({\n title: Schema.optional(Schema.String),\n url: Schema.String,\n text: Schema.optional(Schema.String),\n publishedDate: Schema.optional(Schema.String)\n})\nconst ExaResponse = Schema.Struct({\n results: Schema.Array(ExaResult)\n})\nconst freshnessDays = {\n day: 1,\n week: 7,\n month: 31,\n year: 365\n} as const\n\nconst failure = (code: StdError.Code, message: string): StdError.StdError => new StdError.StdError({ code, message })\n\n/**\n * Provides {@link WebSearch.WebSearch} backed by the Exa API, reading its\n * key from the named credential.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layer = (\n credentialId: string\n): Layer.Layer<WebSearch.WebSearch, never, Credential.Credential | HttpClient.HttpClient> =>\n Layer.effect(\n WebSearch.WebSearch,\n Effect.gen(function*() {\n const credentials = yield* Credential.Credential\n const http = yield* HttpClient.HttpClient\n return WebSearch.make({\n search: (input): Effect.Effect<typeof WebSearch.Output.Type, StdError.StdError> =>\n Effect.gen(function*() {\n const reference = yield* credentials.get(credentialId).pipe(Effect.mapError(() =>\n new StdError.StdError({\n code: \"provider_unavailable\",\n message: \"Configured Exa credential is unavailable\"\n })\n ))\n const secret = yield* credentials.resolve(reference).pipe(Effect.mapError(() =>\n new StdError.StdError({\n code: \"provider_unavailable\",\n message: \"Configured Exa credential cannot be resolved\"\n })\n ))\n const now = yield* Clock.currentTimeMillis\n const request = HttpClientRequest.setHeaders(\n HttpClientRequest.bodyJsonUnsafe(HttpClientRequest.post(\"https://api.exa.ai/search\"), {\n query: input.query,\n numResults: Math.min(input.numResults ?? 8, maxResults),\n ...(input.freshness === undefined\n ? {}\n : { startPublishedDate: new Date(now - freshnessDays[input.freshness] * 86_400_000).toISOString() })\n }),\n { \"authorization\": `Bearer ${Redacted.value(secret)}`, \"content-type\": \"application/json\" }\n )\n const response = yield* http.execute(request).pipe(\n Effect.timeout(requestTimeoutMs),\n Effect.mapError((error) =>\n error._tag === \"TimeoutError\"\n ? failure(\"timeout\", \"Exa search request timed out\")\n : failure(\"request_failed\", \"Exa search request failed\")\n )\n )\n const retryAfter = header(response.headers, \"retry-after\")\n // Successful responses may carry pacing advice too; status decides refusal.\n const refused = response.status < 200 || response.status >= 300\n if (response.status === 429 || (refused && retryAfter !== undefined)) {\n const delay = retryAfter === undefined\n ? NaN\n : /^\\d+$/.test(retryAfter.trim())\n ? Number(retryAfter)\n : Math.max(0, Math.ceil((Date.parse(retryAfter) - (yield* Clock.currentTimeMillis)) / 1_000))\n return yield* Effect.fail(\n failure(\n \"rate_limited\",\n Number.isFinite(delay)\n ? `Exa search was throttled; retry after ${delay} seconds`\n : \"Exa search was throttled\"\n )\n )\n }\n if (response.status === 401 || response.status === 403) {\n return yield* Effect.fail(failure(\"provider_unavailable\", \"Exa search authentication was rejected\"))\n }\n if (response.status >= 500) {\n return yield* Effect.fail(failure(\"provider_unavailable\", `Exa search returned ${response.status}`))\n }\n if (response.status < 200 || response.status >= 300) {\n return yield* Effect.fail(failure(\"request_failed\", `Exa search returned ${response.status}`))\n }\n // Bound the body before decoding: an endpoint must not choose how\n // much of it the host buffers.\n const bytes = yield* readBounded(response.stream, \"https://api.exa.ai/search\").pipe(\n Effect.timeout(requestTimeoutMs),\n Effect.mapError((error) =>\n error._tag === \"TimeoutError\"\n ? failure(\"timeout\", \"Exa search response timed out\")\n : error instanceof StdError.StdError && error.code === \"response_too_large\"\n ? failure(\"response_too_large\", \"Exa search response exceeds the 5 MiB limit\")\n : failure(\"request_failed\", \"Exa search response was invalid\")\n )\n )\n const body = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(ExaResponse))(\n new TextDecoder().decode(bytes)\n ).pipe(\n Effect.mapError(() =>\n new StdError.StdError({ code: \"request_failed\", message: \"Exa search response was invalid\" })\n )\n )\n return {\n results: body.results.slice(0, Math.min(input.numResults ?? 8, maxResults)).map((result) => ({\n title: result.title ?? result.url,\n url: result.url,\n snippet: (result.text ?? \"\").slice(0, 2_000),\n ...(result.publishedDate === undefined ? {} : { publishedAt: result.publishedDate })\n }))\n }\n })\n })\n })\n )\n"]}
|
|
1
|
+
{"version":3,"file":"ExaWebSearch.js","sourceRoot":"","sources":["../../src/ExaWebSearch.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/D,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,O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AI,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAChF,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAChC,CAAC,IAAI,CACJ,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CACnB,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC,CAC9F,CACF,CAAA;YACD,OAAO;gBACL,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;oBAC3F,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,GAAG;oBACjC,GAAG,EAAE,MAAM,CAAC,GAAG;oBACf,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;oBAC5C,GAAG,CAAC,MAAM,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;iBACrF,CAAC,CAAC;aACJ,CAAA;QACH,CAAC,CAAC;KACL,CAAC,CAAA;AACJ,CAAC,CAAC,CACH,CAAA","sourcesContent":["/**\n * The Exa provider for the `websearch` flow.\n *\n * {@link layer} binds `WebSearch.WebSearch` to the Exa search API. It reads the\n * API key from a named credential on every search, calls Exa through the\n * permission-checked `HttpClient`, and maps each hit onto `WebSearch.Result`.\n *\n * @since 1.0.0\n */\n\nimport * as Credential from \"@smthrs/control/Credential\"\nimport * as HttpClient from \"@smthrs/kernel/HttpClient\"\nimport { Clock, Effect, Layer, Redacted, Schema } from \"effect\"\nimport * as HttpClientRequest from \"effect/http/HttpClientRequest\"\nimport { header, readBounded } from \"./internal/Http.ts\"\nimport * as StdError from \"./StdError.ts\"\nimport * as WebSearch from \"./WebSearch.ts\"\n\nconst maxResults = 20\nconst requestTimeoutMs = 30_000\nconst ExaResult = Schema.Struct({\n title: Schema.optional(Schema.String),\n url: Schema.String,\n text: Schema.optional(Schema.String),\n publishedDate: Schema.optional(Schema.String)\n})\nconst ExaResponse = Schema.Struct({\n results: Schema.Array(ExaResult)\n})\nconst freshnessDays = {\n day: 1,\n week: 7,\n month: 31,\n year: 365\n} as const\n\nconst failure = (code: StdError.Code, message: string): StdError.StdError => new StdError.StdError({ code, message })\n\n/**\n * Provides {@link WebSearch.WebSearch} backed by the Exa API, reading its\n * key from the named credential.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layer = (\n credentialId: string\n): Layer.Layer<WebSearch.WebSearch, never, Credential.Credential | HttpClient.HttpClient> =>\n Layer.effect(\n WebSearch.WebSearch,\n Effect.gen(function*() {\n const credentials = yield* Credential.Credential\n const http = yield* HttpClient.HttpClient\n return WebSearch.make({\n search: (input): Effect.Effect<typeof WebSearch.Output.Type, StdError.StdError> =>\n Effect.gen(function*() {\n const reference = yield* credentials.get(credentialId).pipe(Effect.mapError(() =>\n new StdError.StdError({\n code: \"provider_unavailable\",\n message: \"Configured Exa credential is unavailable\"\n })\n ))\n const secret = yield* credentials.resolve(reference).pipe(Effect.mapError(() =>\n new StdError.StdError({\n code: \"provider_unavailable\",\n message: \"Configured Exa credential cannot be resolved\"\n })\n ))\n const now = yield* Clock.currentTimeMillis\n const request = HttpClientRequest.setHeaders(\n HttpClientRequest.bodyJsonUnsafe(HttpClientRequest.post(\"https://api.exa.ai/search\"), {\n query: input.query,\n numResults: Math.min(input.numResults ?? 8, maxResults),\n ...(input.freshness === undefined\n ? {}\n : { startPublishedDate: new Date(now - freshnessDays[input.freshness] * 86_400_000).toISOString() })\n }),\n { \"authorization\": `Bearer ${Redacted.value(secret)}`, \"content-type\": \"application/json\" }\n )\n const response = yield* http.execute(request).pipe(\n Effect.timeout(requestTimeoutMs),\n Effect.mapError((error) =>\n error._tag === \"TimeoutError\"\n ? failure(\"timeout\", \"Exa search request timed out\")\n : failure(\"request_failed\", \"Exa search request failed\")\n )\n )\n const retryAfter = header(response.headers, \"retry-after\")\n // Successful responses may carry pacing advice too; status decides refusal.\n const refused = response.status < 200 || response.status >= 300\n if (response.status === 429 || (refused && retryAfter !== undefined)) {\n const delay = retryAfter === undefined\n ? NaN\n : /^\\d+$/.test(retryAfter.trim())\n ? Number(retryAfter)\n : Math.max(0, Math.ceil((Date.parse(retryAfter) - (yield* Clock.currentTimeMillis)) / 1_000))\n return yield* Effect.fail(\n failure(\n \"rate_limited\",\n Number.isFinite(delay)\n ? `Exa search was throttled; retry after ${delay} seconds`\n : \"Exa search was throttled\"\n )\n )\n }\n if (response.status === 401 || response.status === 403) {\n return yield* Effect.fail(failure(\"provider_unavailable\", \"Exa search authentication was rejected\"))\n }\n if (response.status >= 500) {\n return yield* Effect.fail(failure(\"provider_unavailable\", `Exa search returned ${response.status}`))\n }\n if (response.status < 200 || response.status >= 300) {\n return yield* Effect.fail(failure(\"request_failed\", `Exa search returned ${response.status}`))\n }\n // Bound the body before decoding: an endpoint must not choose how\n // much of it the host buffers.\n const bytes = yield* readBounded(response.stream, \"https://api.exa.ai/search\").pipe(\n Effect.timeout(requestTimeoutMs),\n Effect.mapError((error) =>\n error._tag === \"TimeoutError\"\n ? failure(\"timeout\", \"Exa search response timed out\")\n : error instanceof StdError.StdError && error.code === \"response_too_large\"\n ? failure(\"response_too_large\", \"Exa search response exceeds the 5 MiB limit\")\n : failure(\"request_failed\", \"Exa search response was invalid\")\n )\n )\n const body = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(ExaResponse))(\n new TextDecoder().decode(bytes)\n ).pipe(\n Effect.mapError(() =>\n new StdError.StdError({ code: \"request_failed\", message: \"Exa search response was invalid\" })\n )\n )\n return {\n results: body.results.slice(0, Math.min(input.numResults ?? 8, maxResults)).map((result) => ({\n title: result.title ?? result.url,\n url: result.url,\n snippet: (result.text ?? \"\").slice(0, 2_000),\n ...(result.publishedDate === undefined ? {} : { publishedAt: result.publishedDate })\n }))\n }\n })\n })\n })\n )\n"]}
|
package/dist/esm/Fetch.d.ts
CHANGED
|
@@ -126,5 +126,5 @@ export declare const run: (input: {
|
|
|
126
126
|
readonly body: string;
|
|
127
127
|
readonly truncated: boolean;
|
|
128
128
|
readonly notice?: string | undefined;
|
|
129
|
-
}, import("./StdError.ts").StdError, import("@smthrs/kernel/GrantStore").GrantStore | import("
|
|
129
|
+
}, import("./StdError.ts").StdError, import("@smthrs/kernel/GrantStore").GrantStore | import("effect/http/HttpClient").HttpClient>;
|
|
130
130
|
//# sourceMappingURL=Fetch.d.ts.map
|
package/dist/esm/Fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fetch.d.ts","sourceRoot":"","sources":["../../src/Fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"Fetch.d.ts","sourceRoot":"","sources":["../../src/Fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,UAAU,CAAA;AAE3B;;;;;GAKG;AACH,eAAO,MAAM,WAAW,kIACyG,CAAA;AAEjI;;;;;GAKG;AACH,eAAO,MAAM,KAAK;;;;EAQhB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,MAAM;;;;;EAAW,CAAA;AAE9B;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AAEvC;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,4CAAwE,CAAA;AAE5F;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,OAAO,KAAK,CAAC,IAAI,+CAAY,CAAA;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAA+B,CAAA;AAExD;;;;;GAKG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;CAAsF,CAAA;AAEvG;;;;;;;;GAQG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;kIAAkF,CAAA"}
|
package/dist/esm/Fetch.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @since 1.0.0
|
|
5
5
|
*/
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
7
8
|
import * as Schema from "effect/Schema";
|
|
8
|
-
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
|
|
9
9
|
import { capability, envelope } from "./internal/Declaration.js";
|
|
10
10
|
import { execute, Response, Timeout } from "./internal/Http.js";
|
|
11
11
|
/**
|
package/dist/esm/Fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fetch.js","sourceRoot":"","sources":["../../src/Fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Fetch.js","sourceRoot":"","sources":["../../src/Fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAA;AAClE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,2BA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,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAW,CAAA;AAEvG;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,KAAY,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA","sourcesContent":["/**\n * HTTP GET flow declaration and portable handler.\n *\n * @since 1.0.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as HttpClientRequest from \"effect/http/HttpClientRequest\"\nimport * as Schema from \"effect/Schema\"\nimport { capability, envelope } from \"./internal/Declaration.ts\"\nimport { execute, Response, Timeout } from \"./internal/Http.ts\"\n\n/**\n * Registry name for the fetch flow.\n *\n * @category identifiers\n * @since 1.0.0\n */\nexport const name = \"fetch\"\n\n/**\n * Model-facing description of the fetch flow.\n *\n * @category descriptions\n * @since 1.0.0\n */\nexport const description =\n \"Get an absolute URL and return its status and text body; long bodies are truncated with a notice. Use http-post to send data.\"\n\n/**\n * Input schema for the fetch flow.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Input = Schema.Struct({\n url: Schema.String.annotate({ description: \"Absolute http or https URL to retrieve\" }),\n headers: Schema.optional(Schema.Record(Schema.String, Schema.String)).annotate({\n description: \"Additional request headers\"\n }),\n timeout: Schema.optional(Timeout).annotate({\n description: \"Total request and response body timeout in seconds; defaults to 30, capped at 120\"\n })\n})\n\n/**\n * Decoded input accepted by the `fetch` flow.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Input = typeof Input.Type\n\n/**\n * Output schema for the fetch flow.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Output = Response\n\n/**\n * Decoded output returned by the `fetch` flow.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Output = typeof Output.Type\n\n/**\n * Static effect envelope for the fetch flow.\n *\n * A retrieval leaves no durable state behind, so it is sealed even though it\n * leaves the machine.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effects = envelope({ tier: \"sealed\", mode: \"expected\", reads: [], writes: [] })\n\n/**\n * Narrows the fetch effect envelope for one decoded input.\n *\n * Network reach is expressed as a capability rather than a path envelope, so\n * a retrieval has nothing left to narrow.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effectsFor = (_input: typeof Input.Type) => effects\n\n/**\n * Capabilities required by the fetch flow.\n *\n * @category capabilities\n * @since 1.0.0\n */\nexport const capabilities = [capability(\"net:get\", \"*\")]\n\n/**\n * Declaration-only fetch flow.\n *\n * @category flows\n * @since 1.0.0\n */\nexport const flow = { name, description, input: Input, output: Output, capabilities, effects } as const\n\n/**\n * Retrieves a URL through the permission-aware kernel HTTP client.\n *\n * Error statuses are ordinary results; only transport, permission, and body\n * decoding failures use the typed error channel.\n *\n * @category handlers\n * @since 1.0.0\n */\nexport const run = Effect.fn(\"Fetch.run\")((input: Input) => execute(input, HttpClientRequest.get))\n"]}
|
package/dist/esm/HttpPost.d.ts
CHANGED
|
@@ -126,5 +126,5 @@ export declare const run: (input: {
|
|
|
126
126
|
readonly body: string;
|
|
127
127
|
readonly truncated: boolean;
|
|
128
128
|
readonly notice?: string | undefined;
|
|
129
|
-
}, import("./StdError.ts").StdError, import("@smthrs/kernel/GrantStore").GrantStore | import("
|
|
129
|
+
}, import("./StdError.ts").StdError, import("@smthrs/kernel/GrantStore").GrantStore | import("effect/http/HttpClient").HttpClient>;
|
|
130
130
|
//# sourceMappingURL=HttpPost.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpPost.d.ts","sourceRoot":"","sources":["../../src/HttpPost.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"HttpPost.d.ts","sourceRoot":"","sources":["../../src/HttpPost.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,cAAc,CAAA;AAE/B;;;;;GAKG;AACH,eAAO,MAAM,WAAW,sIAC6G,CAAA;AAErI;;;;;GAKG;AACH,eAAO,MAAM,KAAK;;;;;;EAYhB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,MAAM;;;;;EAAW,CAAA;AAE9B;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,OAAO,4CAA8E,CAAA;AAElG;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,OAAO,KAAK,CAAC,IAAI,+CAAY,CAAA;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAgC,CAAA;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;CAAsF,CAAA;AAEvG;;;;;GAKG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;kIAKf,CAAA"}
|
package/dist/esm/HttpPost.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @since 1.0.0
|
|
5
5
|
*/
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
7
8
|
import * as Schema from "effect/Schema";
|
|
8
|
-
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
|
|
9
9
|
import { capability, envelope } from "./internal/Declaration.js";
|
|
10
10
|
import { execute, Response, Timeout } from "./internal/Http.js";
|
|
11
11
|
/**
|
package/dist/esm/HttpPost.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpPost.js","source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AO,CAAC,CAAC,QAAQ,CAAC;QACzC,WAAW,EAAE,mFAAmF;KACjG,CAAC;CACH,CAAC,CAAA;AAUF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAA;AAU9B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAA;AAElG;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAyB,EAAE,EAAE,CAAC,OAAO,CAAA;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAA;AAEzD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAW,CAAA;AAEvG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,KAAY,EAAE,EAAE,CAC5D,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CACrB,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAC9B,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,IAAI,kBAAkB,CAAC,CAChF,CAAC,CACL,CAAA","sourcesContent":["/**\n * HTTP POST flow declaration and portable handler.\n *\n * @since 1.0.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as HttpClientRequest from \"effect/http/HttpClientRequest\"\nimport * as Schema from \"effect/Schema\"\nimport { capability, envelope } from \"./internal/Declaration.ts\"\nimport { execute, Response, Timeout } from \"./internal/Http.ts\"\n\n/**\n * Registry name for the http-post flow.\n *\n * @category identifiers\n * @since 1.0.0\n */\nexport const name = \"http-post\"\n\n/**\n * Model-facing description of the http-post flow.\n *\n * @category descriptions\n * @since 1.0.0\n */\nexport const description =\n \"Post a text body to an absolute URL and return the response; this is irreversible because the remote side may already have acted.\"\n\n/**\n * Input schema for the http-post flow.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Input = Schema.Struct({\n url: Schema.String.annotate({ description: \"Absolute http or https URL to post to\" }),\n body: Schema.String.annotate({ description: \"Request body sent verbatim\" }),\n contentType: Schema.optional(Schema.String).annotate({\n description: \"Request content type; defaults to application/json\"\n }),\n headers: Schema.optional(Schema.Record(Schema.String, Schema.String)).annotate({\n description: \"Additional request headers\"\n }),\n timeout: Schema.optional(Timeout).annotate({\n description: \"Total request and response body timeout in seconds; defaults to 30, capped at 120\"\n })\n})\n\n/**\n * Decoded input accepted by the `http-post` flow.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Input = typeof Input.Type\n\n/**\n * Output schema for the http-post flow.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Output = Response\n\n/**\n * Decoded output returned by the `http-post` flow.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Output = typeof Output.Type\n\n/**\n * Static effect envelope for the http-post flow.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effects = envelope({ tier: \"irreversible\", mode: \"expected\", reads: [], writes: [] })\n\n/**\n * Narrows the http-post effect envelope for one decoded input.\n *\n * Network reach is expressed as a capability rather than a path envelope, so\n * a post has nothing left to narrow.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effectsFor = (_input: typeof Input.Type) => effects\n\n/**\n * Capabilities required by the http-post flow.\n *\n * @category capabilities\n * @since 1.0.0\n */\nexport const capabilities = [capability(\"net:post\", \"*\")]\n\n/**\n * Declaration-only http-post flow.\n *\n * @category flows\n * @since 1.0.0\n */\nexport const flow = { name, description, input: Input, output: Output, capabilities, effects } as const\n\n/**\n * Posts a body through the permission-aware kernel HTTP client.\n *\n * @category handlers\n * @since 1.0.0\n */\nexport const run = Effect.fn(\"HttpPost.run\")((input: Input) =>\n execute(input, (url) =>\n HttpClientRequest.post(url).pipe(\n HttpClientRequest.bodyText(input.body, input.contentType ?? \"application/json\")\n ))\n)\n"]}
|
package/dist/esm/Lsp.d.ts
CHANGED
|
@@ -114,7 +114,7 @@ export declare const flow: {
|
|
|
114
114
|
* @since 1.0.0
|
|
115
115
|
*/
|
|
116
116
|
export declare const run: (input: {
|
|
117
|
-
readonly operation: "
|
|
117
|
+
readonly operation: "references" | "hover" | "definition" | "implementation" | "documentSymbols" | "workspaceSymbols" | "prepareCallHierarchy" | "callHierarchyIncoming" | "callHierarchyOutgoing" | "diagnostics";
|
|
118
118
|
readonly path?: string | undefined;
|
|
119
119
|
readonly line?: number | undefined;
|
|
120
120
|
readonly character?: number | undefined;
|
package/dist/esm/Manifest.d.ts
CHANGED
|
@@ -669,7 +669,7 @@ export declare const handlers: Readonly<{
|
|
|
669
669
|
readonly message: string;
|
|
670
670
|
} | undefined;
|
|
671
671
|
readonly mutated?: boolean | undefined;
|
|
672
|
-
}, import("./StdError.ts").StdError, import("
|
|
672
|
+
}, import("./StdError.ts").StdError, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/Path").Path>;
|
|
673
673
|
test: (input: {
|
|
674
674
|
readonly timeoutMs?: number | undefined;
|
|
675
675
|
readonly selection?: readonly string[] | undefined;
|
|
@@ -708,7 +708,7 @@ export declare const handlers: Readonly<{
|
|
|
708
708
|
} | undefined;
|
|
709
709
|
readonly introduced?: readonly string[] | undefined;
|
|
710
710
|
readonly preexisting?: readonly string[] | undefined;
|
|
711
|
-
}, import("./StdError.ts").StdError, import("
|
|
711
|
+
}, import("./StdError.ts").StdError, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("@smthrs/model/Evaluator").Evaluator | import("./TestRunner.ts").TestRunner>;
|
|
712
712
|
shell_command: (input: {
|
|
713
713
|
readonly command: string;
|
|
714
714
|
readonly workdir?: string | undefined;
|
|
@@ -716,7 +716,7 @@ export declare const handlers: Readonly<{
|
|
|
716
716
|
}) => import("effect/Effect").Effect<{
|
|
717
717
|
readonly output: string;
|
|
718
718
|
readonly exitCode: number;
|
|
719
|
-
}, import("./StdError.ts").StdError, import("
|
|
719
|
+
}, import("./StdError.ts").StdError, import("effect/process/ChildProcessSpawner").ChildProcessSpawner>;
|
|
720
720
|
apply_patch: (input: {
|
|
721
721
|
readonly input: string;
|
|
722
722
|
}) => import("effect/Effect").Effect<{
|
|
@@ -745,7 +745,7 @@ export declare const handlers: Readonly<{
|
|
|
745
745
|
readonly body: string;
|
|
746
746
|
readonly truncated: boolean;
|
|
747
747
|
readonly notice?: string | undefined;
|
|
748
|
-
}, import("./StdError.ts").StdError, import("@smthrs/kernel/GrantStore").GrantStore | import("
|
|
748
|
+
}, import("./StdError.ts").StdError, import("@smthrs/kernel/GrantStore").GrantStore | import("effect/http/HttpClient").HttpClient>;
|
|
749
749
|
"http-post": (input: {
|
|
750
750
|
readonly body: string;
|
|
751
751
|
readonly url: string;
|
|
@@ -759,7 +759,7 @@ export declare const handlers: Readonly<{
|
|
|
759
759
|
readonly body: string;
|
|
760
760
|
readonly truncated: boolean;
|
|
761
761
|
readonly notice?: string | undefined;
|
|
762
|
-
}, import("./StdError.ts").StdError, import("@smthrs/kernel/GrantStore").GrantStore | import("
|
|
762
|
+
}, import("./StdError.ts").StdError, import("@smthrs/kernel/GrantStore").GrantStore | import("effect/http/HttpClient").HttpClient>;
|
|
763
763
|
webfetch: (input: {
|
|
764
764
|
readonly url: string;
|
|
765
765
|
readonly timeout?: number | undefined;
|
|
@@ -771,7 +771,7 @@ export declare const handlers: Readonly<{
|
|
|
771
771
|
readonly url: string;
|
|
772
772
|
readonly truncated: boolean;
|
|
773
773
|
readonly notice?: string | undefined;
|
|
774
|
-
}, import("./StdError.ts").StdError, import("@smthrs/kernel/GrantStore").GrantStore | import("
|
|
774
|
+
}, import("./StdError.ts").StdError, import("@smthrs/kernel/GrantStore").GrantStore | import("effect/http/HttpClient").HttpClient>;
|
|
775
775
|
websearch: (input: {
|
|
776
776
|
readonly query: string;
|
|
777
777
|
readonly numResults?: number | undefined;
|
|
@@ -785,7 +785,7 @@ export declare const handlers: Readonly<{
|
|
|
785
785
|
}[];
|
|
786
786
|
}, import("./StdError.ts").StdError, WebSearch.WebSearch>;
|
|
787
787
|
lsp: (input: {
|
|
788
|
-
readonly operation: "
|
|
788
|
+
readonly operation: "references" | "hover" | "definition" | "implementation" | "documentSymbols" | "workspaceSymbols" | "prepareCallHierarchy" | "callHierarchyIncoming" | "callHierarchyOutgoing" | "diagnostics";
|
|
789
789
|
readonly path?: string | undefined;
|
|
790
790
|
readonly line?: number | undefined;
|
|
791
791
|
readonly character?: number | undefined;
|
|
@@ -888,7 +888,7 @@ export declare const effectsFor: Readonly<{
|
|
|
888
888
|
readonly freshness?: "day" | "week" | "month" | "year" | undefined;
|
|
889
889
|
}) => import("@smthrs/plan/Effects").Declaration;
|
|
890
890
|
lsp: (_input: {
|
|
891
|
-
readonly operation: "
|
|
891
|
+
readonly operation: "references" | "hover" | "definition" | "implementation" | "documentSymbols" | "workspaceSymbols" | "prepareCallHierarchy" | "callHierarchyIncoming" | "callHierarchyOutgoing" | "diagnostics";
|
|
892
892
|
readonly path?: string | undefined;
|
|
893
893
|
readonly line?: number | undefined;
|
|
894
894
|
readonly character?: number | undefined;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import * as ChildProcessEnvironment from "@smthrs/kernel/ChildProcessEnvironment";
|
|
12
12
|
import * as ChildProcessSpawner from "@smthrs/kernel/ChildProcessSpawner";
|
|
13
13
|
import { Clock, Deferred, Effect, Fiber, Layer, Option, Queue, Semaphore, Stream } from "effect";
|
|
14
|
-
import * as ChildProcess from "effect/
|
|
14
|
+
import * as ChildProcess from "effect/process/ChildProcess";
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
16
|
import * as NodeFs from "node:fs";
|
|
17
17
|
import * as NodePath from "node:path";
|