@smthrs/std 1.0.0-rc.7 → 1.0.0-rc.8
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/CHANGELOG.md +4 -0
- package/README.md +38 -36
- package/dist/cjs/Checkpoints.d.ts +37 -0
- package/dist/cjs/Checkpoints.d.ts.map +1 -1
- package/dist/cjs/Checkpoints.js +75 -0
- package/dist/cjs/Checkpoints.js.map +2 -2
- package/dist/cjs/internal/EnvelopePrecheck.d.ts +2 -0
- package/dist/cjs/internal/EnvelopePrecheck.d.ts.map +1 -1
- package/dist/cjs/internal/EnvelopePrecheck.js +217 -34
- package/dist/cjs/internal/EnvelopePrecheck.js.map +3 -3
- package/dist/cjs/internal/Exec.d.ts +12 -7
- package/dist/cjs/internal/Exec.d.ts.map +1 -1
- package/dist/cjs/internal/Exec.js +8 -4
- package/dist/cjs/internal/Exec.js.map +2 -2
- package/dist/esm/Checkpoints.d.ts +37 -0
- package/dist/esm/Checkpoints.d.ts.map +1 -1
- package/dist/esm/Checkpoints.js +85 -0
- package/dist/esm/Checkpoints.js.map +1 -1
- package/dist/esm/internal/EnvelopePrecheck.d.ts +2 -0
- package/dist/esm/internal/EnvelopePrecheck.d.ts.map +1 -1
- package/dist/esm/internal/EnvelopePrecheck.js +295 -60
- package/dist/esm/internal/EnvelopePrecheck.js.map +1 -1
- package/dist/esm/internal/Exec.d.ts +12 -7
- package/dist/esm/internal/Exec.d.ts.map +1 -1
- package/dist/esm/internal/Exec.js +30 -9
- package/dist/esm/internal/Exec.js.map +1 -1
- package/docs/README.md +3 -1
- package/docs/api.md +20 -17
- package/docs/guides/pin-a-checkpoint.md +20 -0
- package/docs/installation.md +13 -9
- package/docs/quickstart.md +1 -1
- package/docs/troubleshooting.md +12 -0
- package/package.json +6 -6
- package/src/Checkpoints.ts +137 -0
- package/src/internal/EnvelopePrecheck.ts +295 -63
- package/src/internal/Exec.ts +32 -8
package/CHANGELOG.md
CHANGED
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
|
|
38
38
|
### Added
|
|
39
39
|
|
|
40
|
+
- `Checkpoints.makeContainer` and `layerContainer` pin and check out trees
|
|
41
|
+
inside the container `bash` runs in, through the `Container` transport, for a
|
|
42
|
+
host whose repository lives only in that container (#3952).
|
|
43
|
+
|
|
40
44
|
- Added `TreeFingerprint`: the in-container tree measurement `bash` uses, and
|
|
41
45
|
the owner of the prune and suffix lists `@smthrs/agent/WorkspaceObservation`
|
|
42
46
|
now re-exports, so the host walk and the container measurement skip the
|
package/README.md
CHANGED
|
@@ -10,47 +10,49 @@ runtime.
|
|
|
10
10
|
|
|
11
11
|
The standard flows tool library for filesystem, search, HTTP, shell, language-server, and Jev judgment work. Each callable tool is an ordinary `@smthrs/core` flow declaration with explicit capabilities and effects, plus an injectable handler where execution is host-owned.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
```bash
|
|
14
|
+
npm install @smthrs/std@next effect
|
|
15
|
+
```
|
|
14
16
|
|
|
15
17
|
## Public API
|
|
16
18
|
|
|
17
19
|
The root entry point exports these namespaces; each is also importable from `@smthrs/std/<Module>`.
|
|
18
20
|
|
|
19
|
-
| Module | Public exports
|
|
20
|
-
| -------------------- |
|
|
21
|
-
| `ApplyPatch` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation`, `paths`
|
|
22
|
-
| `Bash` | `name`, `description`, `DEFAULT_TIMEOUT_MS`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `invocation`, `inTerminal`, `outsideContainer`, `sealed`, `presentation`, `elideMiddle`
|
|
23
|
-
| `Checkpoints` | `baseId`, `scratchDirectory`, `configSection`, `Snapshot`, `Materialized`, `Checkpoints`, `make`, `unavailable`, `makeNoop`, `layerNoop`, `GitOptions`, `makeGit`, `layerGit`, `Relocation`, `relocate`
|
|
24
|
-
| `Container` | `Request`, `Plan`, `Container`, `make`, `unavailable`, `makeNoop`, `layerNoop`, `makeCommand`, `layerCommand`
|
|
25
|
-
| `Edit` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation`
|
|
26
|
-
| `ExaWebSearch` | `layer`
|
|
27
|
-
| `Explore` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `make`, `flow`
|
|
28
|
-
| `Fetch` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`
|
|
29
|
-
| `Glob` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation`
|
|
30
|
-
| `Grep` | `name`, `description`, `Input`, `ContextLine`, `Symbol`, `Match`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation`
|
|
31
|
-
| `HttpPost` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`
|
|
32
|
-
| `LanguageServer` | `Position`, `LanguageServer`, `make`, `makeNoop`, `layerNoop`
|
|
33
|
-
| `Ls` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation`
|
|
34
|
-
| `Lsp` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`
|
|
35
|
-
| `Manifest` | `flows`, `handlers`, `effectsFor`, `names`, `readOnly`
|
|
36
|
-
| `NativeSearch` | `MAX_CAPTURE_BYTES`, `make`, `layer`
|
|
37
|
-
| `NodeLanguageServer` | `Config`, `MAX_QUEUED_FRAMES`, `MAX_PENDING_REQUESTS`, `make`, `makeLazy`, `layer`, `layerLazy`
|
|
38
|
-
| `PortableSearch` | `make`, `layer`
|
|
39
|
-
| `Probe` | `key`, `Reason`, `InvalidProbe`, `Attribution`, `CONFIDENCE_FLOOR`, `MAX_OUTPUT_BYTES`, `posix`, `probeAttribution`, `classify`, `unjudged`
|
|
40
|
-
| `Read` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation`, `MAX_READ_FILE_BYTES`, `Preconditions`, `ReadSession`, `VersionedFileSystem`
|
|
41
|
-
| `Relocate` | `Relocation`, `relocate`
|
|
42
|
-
| `Search` | `GrepInput`, `GrepLine`, `ContextLine`, `Symbol`, `GrepMatch`, `GrepOutput`, `GlobInput`, `GlobOutput`, `Search`, `make`, `makeNoop`, `layerNoop`
|
|
43
|
-
| `SearchConformance` | `GeneratedFile`, `Plan`, `Divergence`, `plan`, `materialize`, `compare`, `report`
|
|
44
|
-
| `SearchContract` | `validatePattern`, `validateGlob`, `canonicalGlob`, `matchesGlob`, `includedByGlobs`, `expression`, `unsatisfiableNotice`, `isContractRejection`
|
|
45
|
-
| `ShellCommand` | `name`, `description`, `DEFAULT_TIMEOUT_MS`, `MAX_CAPTURE_BYTES`, `DEFAULT_MAX_OUTPUT_TOKENS`, `TIMEOUT_EXIT_CODE`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`
|
|
46
|
-
| `StdError` | `Code`, `StdError`
|
|
47
|
-
| `TestRun` | `name`, `description`, `scratchDirectory`, `DEFAULT_TIMEOUT_MS`, `MAX_CAPTURE_BYTES`, `Input`, `Outcome`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation`
|
|
48
|
-
| `TreeFingerprint` | `key`, `defaultPrune`, `defaultIgnoreSuffixes`, `maxPaths`, `Measurement`, `script`, `parse`, `moved`
|
|
49
|
-
| `TestRunner` | `captureBase`, `Runner`, `TestRunner`, `make`, `makeNoop`, `layer`, `layerNoop`
|
|
50
|
-
| `UpdatePlan` | `name`, `description`, `StepStatus`, `Plan`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`
|
|
51
|
-
| `WebFetch` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`
|
|
52
|
-
| `WebSearch` | `name`, `description`, `Input`, `Result`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `WebSearch`, `make`, `makeNoop`, `layerNoop`, `run`
|
|
53
|
-
| `Write` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation`
|
|
21
|
+
| Module | Public exports | Description |
|
|
22
|
+
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
+
| `ApplyPatch` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation`, `paths` | Declares and applies a V4A patch. |
|
|
24
|
+
| `Bash` | `name`, `description`, `DEFAULT_TIMEOUT_MS`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `invocation`, `inTerminal`, `outsideContainer`, `sealed`, `presentation`, `elideMiddle` | Declares and runs bounded shell commands, here or in a registered terminal. |
|
|
25
|
+
| `Checkpoints` | `baseId`, `scratchDirectory`, `configSection`, `Snapshot`, `Materialized`, `Checkpoints`, `make`, `unavailable`, `makeNoop`, `layerNoop`, `GitOptions`, `makeGit`, `layerGit`, `ContainerOptions`, `makeContainer`, `layerContainer`, `Relocation`, `relocate` | Pins a working tree as a git checkpoint, on the host or in the container `bash` runs in, and materializes it again. |
|
|
26
|
+
| `Container` | `Request`, `Plan`, `Container`, `make`, `unavailable`, `makeNoop`, `layerNoop`, `makeCommand`, `layerCommand` | Routes a command into a named container. |
|
|
27
|
+
| `Edit` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation` | Declares and applies exact text replacements. |
|
|
28
|
+
| `ExaWebSearch` | `layer` | Provides WebSearch through the Exa API and kernel HTTP client. |
|
|
29
|
+
| `Explore` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `make`, `flow` | Declares a dynamic exploration flow composed from other standard flows. |
|
|
30
|
+
| `Fetch` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run` | Declares and runs raw HTTP GET requests. |
|
|
31
|
+
| `Glob` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation` | Declares and runs filesystem glob searches. |
|
|
32
|
+
| `Grep` | `name`, `description`, `Input`, `ContextLine`, `Symbol`, `Match`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation` | Declares and runs text searches over files. |
|
|
33
|
+
| `HttpPost` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run` | Declares and runs HTTP POST requests. |
|
|
34
|
+
| `LanguageServer` | `Position`, `LanguageServer`, `make`, `makeNoop`, `layerNoop` | Defines the language-server query service. |
|
|
35
|
+
| `Ls` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation` | Declares and runs directory listings. |
|
|
36
|
+
| `Lsp` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run` | Declares and runs ten language-server queries, from hover to diagnostics. |
|
|
37
|
+
| `Manifest` | `flows`, `handlers`, `effectsFor`, `names`, `readOnly` | Exposes frozen flow, handler, and narrowing registries plus the read-only set. |
|
|
38
|
+
| `NativeSearch` | `MAX_CAPTURE_BYTES`, `make`, `layer` | Implements Search through the ripgrep binary. |
|
|
39
|
+
| `NodeLanguageServer` | `Config`, `MAX_QUEUED_FRAMES`, `MAX_PENDING_REQUESTS`, `make`, `makeLazy`, `layer`, `layerLazy` | Implements LanguageServer with Node child processes, routed by extension. |
|
|
40
|
+
| `PortableSearch` | `make`, `layer` | Implements Search by walking the kernel filesystem in process. |
|
|
41
|
+
| `Probe` | `key`, `Reason`, `InvalidProbe`, `Attribution`, `CONFIDENCE_FLOOR`, `MAX_OUTPUT_BYTES`, `posix`, `probeAttribution`, `classify`, `unjudged` | Attributes a non-zero exit to the command or to the tree, with Jev. |
|
|
42
|
+
| `Read` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation`, `MAX_READ_FILE_BYTES`, `Preconditions`, `ReadSession`, `VersionedFileSystem` | Declares and runs bounded file reads. |
|
|
43
|
+
| `Relocate` | `Relocation`, `relocate` | Rewrites a call's input so the call runs against a materialized checkpoint. |
|
|
44
|
+
| `Search` | `GrepInput`, `GrepLine`, `ContextLine`, `Symbol`, `GrepMatch`, `GrepOutput`, `GlobInput`, `GlobOutput`, `Search`, `make`, `makeNoop`, `layerNoop` | Defines the search service both peers implement. |
|
|
45
|
+
| `SearchConformance` | `GeneratedFile`, `Plan`, `Divergence`, `plan`, `materialize`, `compare`, `report` | Generates a tree and calls, then reports where two Search peers disagree. |
|
|
46
|
+
| `SearchContract` | `validatePattern`, `validateGlob`, `canonicalGlob`, `matchesGlob`, `includedByGlobs`, `expression`, `unsatisfiableNotice`, `isContractRejection` | The shared matcher an external Search peer must build on. |
|
|
47
|
+
| `ShellCommand` | `name`, `description`, `DEFAULT_TIMEOUT_MS`, `MAX_CAPTURE_BYTES`, `DEFAULT_MAX_OUTPUT_TOKENS`, `TIMEOUT_EXIT_CODE`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run` | Declares and runs a Codex-shaped shell command. |
|
|
48
|
+
| `StdError` | `Code`, `StdError` | Defines typed standard-tool failures. |
|
|
49
|
+
| `TestRun` | `name`, `description`, `scratchDirectory`, `DEFAULT_TIMEOUT_MS`, `MAX_CAPTURE_BYTES`, `Input`, `Outcome`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation` | Runs the declared test suite and reads its report. |
|
|
50
|
+
| `TreeFingerprint` | `key`, `defaultPrune`, `defaultIgnoreSuffixes`, `maxPaths`, `Measurement`, `script`, `parse`, `moved` | Measures a container's working directory so `bash` can report a write there. |
|
|
51
|
+
| `TestRunner` | `captureBase`, `Runner`, `TestRunner`, `make`, `makeNoop`, `layer`, `layerNoop` | Declares how the project under test runs its suite. |
|
|
52
|
+
| `UpdatePlan` | `name`, `description`, `StepStatus`, `Plan`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run` | Acknowledges a Codex plan update. |
|
|
53
|
+
| `WebFetch` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run` | Declares and runs normalized web-page fetches. |
|
|
54
|
+
| `WebSearch` | `name`, `description`, `Input`, `Result`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `WebSearch`, `make`, `makeNoop`, `layerNoop`, `run` | Declares web search and its injectable provider service. |
|
|
55
|
+
| `Write` | `name`, `description`, `Input`, `Output`, `effects`, `effectsFor`, `capabilities`, `flow`, `run`, `activity`, `presentation` | Declares and runs file writes. |
|
|
54
56
|
|
|
55
57
|
```ts
|
|
56
58
|
import { Read } from "@smthrs/std"
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
*/
|
|
72
72
|
import { ChildProcessSpawner } from "@smthrs/kernel/ChildProcessSpawner";
|
|
73
73
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
74
|
+
import * as Container from "./Container.ts";
|
|
74
75
|
import * as StdError from "./StdError.ts";
|
|
75
76
|
/**
|
|
76
77
|
* The id naming the tree a run opened on.
|
|
@@ -265,6 +266,42 @@ export declare const makeGit: (options: GitOptions) => Effect.Effect<Checkpoints
|
|
|
265
266
|
* @since 1.0.0
|
|
266
267
|
*/
|
|
267
268
|
export declare const layerGit: (options: GitOptions) => Layer.Layer<Checkpoints, never, ChildProcessSpawner>;
|
|
269
|
+
/**
|
|
270
|
+
* What {@link makeContainer} needs to know about the container it pins in.
|
|
271
|
+
*
|
|
272
|
+
* @category models
|
|
273
|
+
* @since 1.0.0-rc.8
|
|
274
|
+
*/
|
|
275
|
+
export interface ContainerOptions {
|
|
276
|
+
/** The container `bash` runs in. */
|
|
277
|
+
readonly container: string;
|
|
278
|
+
/** A directory of the repository inside it; absent is the container's own working directory. */
|
|
279
|
+
readonly cwd?: string | undefined;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Builds the store for a host whose `bash` runs in one container.
|
|
283
|
+
*
|
|
284
|
+
* The repository is the container's, so every git command runs there, through
|
|
285
|
+
* the same {@link Container.Container} transport `bash` takes. The host store
|
|
286
|
+
* looked in the CLI's own directory instead and refused every `at` in 112 of
|
|
287
|
+
* 123 trials of the 2026-10-14 SWE-bench Pro run. This keeps that store's
|
|
288
|
+
* shape: a checkpoint is a `stash create` commit named in config, and a tree
|
|
289
|
+
* is checked out under the repository for one call, so a relocated `bash`
|
|
290
|
+
* call keeps its subdirectory and still finds what the workspace installs
|
|
291
|
+
* beside it. That git may run what the repository configures, but only inside
|
|
292
|
+
* the container the agent already commands.
|
|
293
|
+
*
|
|
294
|
+
* @category constructors
|
|
295
|
+
* @since 1.0.0-rc.8
|
|
296
|
+
*/
|
|
297
|
+
export declare const makeContainer: (options: ContainerOptions) => Effect.Effect<Checkpoints, never, ChildProcessSpawner | Container.Container>;
|
|
298
|
+
/**
|
|
299
|
+
* Provides {@link makeContainer}.
|
|
300
|
+
*
|
|
301
|
+
* @category layers
|
|
302
|
+
* @since 1.0.0-rc.8
|
|
303
|
+
*/
|
|
304
|
+
export declare const layerContainer: (options: ContainerOptions) => Layer.Layer<Checkpoints, never, ChildProcessSpawner | Container.Container>;
|
|
268
305
|
/**
|
|
269
306
|
* Rewrites one call's input so the call runs against a materialized checkpoint.
|
|
270
307
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkpoints.d.ts","sourceRoot":"","sources":["../../src/Checkpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM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AW,EAAE,KAAK,EAAE,mBAAmB,CACrD,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,gGAAgG;IAChG,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAClC;AA4CD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,gBAAgB,KACxB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,mBAAmB,GAAG,SAAS,CAAC,SAAS,CAgD1E,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,SAAS,gBAAgB,KACxB,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,mBAAmB,GAAG,SAAS,CAAC,SAAS,CACzB,CAAA;AAEnD;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/cjs/Checkpoints.js
CHANGED
|
@@ -32,9 +32,11 @@ __export(Checkpoints_exports, {
|
|
|
32
32
|
Snapshot: () => Snapshot,
|
|
33
33
|
baseId: () => baseId,
|
|
34
34
|
configSection: () => configSection,
|
|
35
|
+
layerContainer: () => layerContainer,
|
|
35
36
|
layerGit: () => layerGit,
|
|
36
37
|
layerNoop: () => layerNoop,
|
|
37
38
|
make: () => make,
|
|
39
|
+
makeContainer: () => makeContainer,
|
|
38
40
|
makeGit: () => makeGit,
|
|
39
41
|
makeNoop: () => makeNoop,
|
|
40
42
|
relocate: () => import_Relocate.relocate,
|
|
@@ -44,6 +46,8 @@ __export(Checkpoints_exports, {
|
|
|
44
46
|
module.exports = __toCommonJS(Checkpoints_exports);
|
|
45
47
|
var import_ChildProcessSpawner = require("@smthrs/kernel/ChildProcessSpawner");
|
|
46
48
|
var import_effect = require("effect");
|
|
49
|
+
var Container = __toESM(require("./Container.js"), 1);
|
|
50
|
+
var Exec = __toESM(require("./internal/Exec.js"), 1);
|
|
47
51
|
var import_GitWorktree = require("./internal/GitWorktree.js");
|
|
48
52
|
var import_Paths = require("./internal/Paths.js");
|
|
49
53
|
var Prune = __toESM(require("./internal/Prune.js"), 1);
|
|
@@ -142,4 +146,75 @@ const gitStore = (options, spawner) => {
|
|
|
142
146
|
return make({ capture, materialize });
|
|
143
147
|
};
|
|
144
148
|
const layerGit = (options) => import_effect.Layer.effect(Checkpoints)(makeGit(options));
|
|
149
|
+
const pinScript = [
|
|
150
|
+
"set -e",
|
|
151
|
+
'cd "$(git rev-parse --show-toplevel)"',
|
|
152
|
+
"copy=$(mktemp -d)",
|
|
153
|
+
`trap 'rm -rf -- "$copy"' EXIT`,
|
|
154
|
+
"index=$(git rev-parse --git-path index)",
|
|
155
|
+
'if [ -e "$index" ]; then cp -p -- "$index" "$copy/index"; fi',
|
|
156
|
+
'commit=$(GIT_INDEX_FILE="$copy/index" git -c user.name=flows -c user.email=flows@localhost stash create "flows checkpoint $1")',
|
|
157
|
+
`[ -n "$commit" ] || commit=$(git rev-parse --verify 'HEAD^{commit}')`,
|
|
158
|
+
`git config "${configSection}.$1" "$commit"`,
|
|
159
|
+
`printf '%s\\n' "$commit"`
|
|
160
|
+
].join("\n");
|
|
161
|
+
const checkoutScript = [
|
|
162
|
+
"set -e",
|
|
163
|
+
"top=$(git rev-parse --show-toplevel)",
|
|
164
|
+
'cd "$top"',
|
|
165
|
+
'common=$(cd "$(git rev-parse --git-common-dir)" && pwd -P)',
|
|
166
|
+
`if [ "$1" = ${baseId} ]; then`,
|
|
167
|
+
` commit=$(git rev-parse --verify --quiet '${TestRunner.captureBase}^{commit}' || git rev-parse --verify --quiet 'HEAD^{commit}') || { echo "No commit resolves from ${TestRunner.captureBase} or HEAD in $top." >&2; exit 1; }`,
|
|
168
|
+
"else",
|
|
169
|
+
` commit=$(git config --get "${configSection}.$1") || { echo "No checkpoint is stored under $1 in $top. Take the reading on the live tree instead." >&2; exit 1; }`,
|
|
170
|
+
"fi",
|
|
171
|
+
`dir="$top/${scratchDirectory}/$1-$2"`,
|
|
172
|
+
`trap 'rm -rf -- "$dir"' EXIT`,
|
|
173
|
+
`mkdir -p -- "$top/${scratchDirectory}"`,
|
|
174
|
+
'git init --quiet "$dir"',
|
|
175
|
+
`printf '%s/objects\\n' "$common" > "$dir/.git/objects/info/alternates"`,
|
|
176
|
+
'git -C "$dir" checkout --quiet --detach "$commit"',
|
|
177
|
+
"trap - EXIT",
|
|
178
|
+
`printf '%s\\n%s\\n' "$top" "$dir"`
|
|
179
|
+
].join("\n");
|
|
180
|
+
const makeContainer = (options) => import_effect.Effect.gen(function* () {
|
|
181
|
+
const spawner = yield* import_ChildProcessSpawner.ChildProcessSpawner;
|
|
182
|
+
const transport = yield* Container.Container;
|
|
183
|
+
const sh = (script, args) => transport.exec({
|
|
184
|
+
container: options.container,
|
|
185
|
+
file: "sh",
|
|
186
|
+
args: ["-c", script, "sh", ...args],
|
|
187
|
+
cwd: options.cwd,
|
|
188
|
+
stdin: false
|
|
189
|
+
}).pipe(
|
|
190
|
+
import_effect.Effect.flatMap(
|
|
191
|
+
(plan) => Exec.exec(plan.file, { args: plan.args, env: plan.env }).pipe(
|
|
192
|
+
import_effect.Effect.mapError((error) => Exec.toStdError(plan.file, error))
|
|
193
|
+
)
|
|
194
|
+
),
|
|
195
|
+
import_effect.Effect.flatMap(
|
|
196
|
+
(result) => result.exitCode === 0 ? import_effect.Effect.succeed(result.stdout.trim().split("\n")) : import_effect.Effect.fail(failed(`git in container ${options.container} failed: ${result.stderr.trim()}`))
|
|
197
|
+
),
|
|
198
|
+
import_effect.Effect.provideService(import_ChildProcessSpawner.ChildProcessSpawner, spawner)
|
|
199
|
+
);
|
|
200
|
+
const named = (id) => namable.test(id) ? import_effect.Effect.void : import_effect.Effect.fail(failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, "invalid_input"));
|
|
201
|
+
return make({
|
|
202
|
+
capture: (id) => named(id).pipe(
|
|
203
|
+
import_effect.Effect.andThen(sh(pinScript, [id])),
|
|
204
|
+
import_effect.Effect.map(([commit]) => new Snapshot({ id, ref: commit }))
|
|
205
|
+
),
|
|
206
|
+
materialize: (id, use) => named(id).pipe(import_effect.Effect.andThen(import_effect.Effect.acquireUseRelease(
|
|
207
|
+
sh(checkoutScript, [id, globalThis.crypto.randomUUID()]),
|
|
208
|
+
([root, checkout]) => use({ id, host: checkout, guest: checkout, root, guestRoot: root }),
|
|
209
|
+
([, checkout]) => sh('rm -rf -- "$1"', [checkout]).pipe(
|
|
210
|
+
import_effect.Effect.catch(
|
|
211
|
+
(error) => import_effect.Effect.logWarning("could not remove a scratch checkout").pipe(
|
|
212
|
+
import_effect.Effect.annotateLogs({ path: checkout, reason: error.message })
|
|
213
|
+
)
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
)))
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
const layerContainer = (options) => import_effect.Layer.effect(Checkpoints)(makeContainer(options));
|
|
145
220
|
//# sourceMappingURL=Checkpoints.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Checkpoints.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Pinned trees, and the scratch checkouts a call runs against.\n *\n * A checkpoint is a **value**: minting one changes nothing about the workspace,\n * and running a call against one leaves the live tree exactly as it stands.\n * That is the whole of what it buys. Before it existed, the only way a run\n * could answer \"did this command fail before my change\" was to undo the change\n * \u2014 and the journals price that exactly. On `sympy__sympy-13878` the r95repl\n * lane applied one byte-identical 4,789-character patch **five times**, four of\n * those applications preceded by `git checkout -- sympy/stats/crv_types.py`,\n * because a clean fails-before proof required reverting the very work it was\n * meant to prove.\n *\n * This module is the host half of `@smthrs/harness`'s `ctx.checkpoint()` and\n * `ctx.call(flow, input, { at })`. The harness owns the surface, the identity,\n * the bound and the refusals; nothing in it knows what a tree is. This owns the\n * two host operations that need one:\n *\n * - {@link Checkpoints.capture} records the working tree under an id, and\n * - {@link Checkpoints.materialize} gives that tree back as a directory for the\n * length of one call.\n *\n * ## The git binding, and the container constraint it is shaped by\n *\n * {@link layerGit} records a checkpoint with `git stash create`, then names the\n * commit it prints in this repository's own git config rather than with a ref \u2014\n * see {@link configSection} for why a ref would hand the agent its own edit back\n * as history. `stash create` is the one git command\n * that records the working tree and changes nothing else: it does not move the\n * worktree and does not touch the stash ref. It runs against a shadow\n * `GIT_DIR` over a copy of the workspace index (see `internal/GitWorktree.ts`),\n * so it never writes the repository's index and never runs a program the\n * workspace's `.git` names. That matters more than it sounds. The agent runs `git` in this same\n * workspace and its own `git diff` is the run's evidence, so a capture that\n * staged into the real index would be the harness editing the evidence while\n * recording it. A tree with nothing to record prints nothing, and the\n * checkpoint is then `HEAD` \u2014 which is exactly what the tree is.\n *\n * Untracked files are not in the recorded tree, which matches how the rig\n * captures a patch: `capture-patch.sh` drops paths that did not exist when the\n * agent started, so a checkpoint holds what a patch would hold.\n *\n * The materialization is a detached checkout at `<root>/.flows-checkpoints/<id>-<lease>`\n * \u2014 **inside** the workspace, which looks wrong and is the only thing that\n * works. A benchmark check runs through `docker exec` inside `/testbed`, and\n * `/testbed` is a bind mount of the live workspace. A scratch checkout anywhere\n * else on the host is simply not visible to the container, so the call would run\n * against a path that does not exist. Placed under the workspace it is visible\n * at the same subpath under the mount, needs no second mount, and needs no\n * change to how the rig starts its container. `TestRun`'s `against: \"base\"`\n * reached the same conclusion first and this reuses its shape;\n * `evals/swebench/run-instance.sh` excludes the directory from patch capture for\n * the same reason it excludes `.flows-test-base`.\n *\n * The checkout is added and removed around **one call**, which is stricter than\n * the frame lifetime the design asks for and much simpler: there is no cache to\n * invalidate, no id to leak, and a checkpoint used by three calls pays three\n * checkouts rather than risking one stale directory. A run that reuses a\n * checkpoint across frames simply re-materializes it, because the ref is what\n * persists.\n *\n * ## What can be pointed at a checkpoint, and what cannot\n *\n * {@link relocate} is the closed answer, and `Relocate.ts` owns it. That half\n * knows the input shapes of `bash`, `read`, `ls`, `grep` and `glob`; this half\n * knows git. They change for different reasons, so they are different modules,\n * and {@link relocate} is re-exported here because the harness reaches the whole\n * feature through this one.\n *\n * @since 1.0.0\n */\n\nimport { ChildProcessSpawner } from \"@smthrs/kernel/ChildProcessSpawner\"\nimport { Context, Effect, Layer, Schema } from \"effect\"\nimport { GitWorktree } from \"./internal/GitWorktree.ts\"\nimport { withoutTrailingSlash } from \"./internal/Paths.ts\"\nimport * as Prune from \"./internal/Prune.ts\"\nimport * as StdError from \"./StdError.ts\"\nimport * as TestRunner from \"./TestRunner.ts\"\n\n/**\n * The id naming the tree a run opened on.\n *\n * It is not minted: the host either recorded one before the agent started or it\n * did not. {@link layerGit} resolves it to {@link TestRunner.captureBase} and\n * then to `HEAD`, which is the same precedence `TestRun` uses for the same\n * question \u2014 so a workspace that has one answer for a baseline has one answer\n * for both.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const baseId = \"base\"\n\n/**\n * The directory checkpoints are materialized into, relative to the repository\n * root and therefore also relative to a container's view of it.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const scratchDirectory = Prune.checkpointScratch\n\n/**\n * The git-config section {@link layerGit} records minted checkpoints under.\n *\n * Config and **not a ref**, and that is the whole of the decision. A ref is\n * history: `git log --all` lists it, `git show` prints it, and `git log --all\n * -S` searches it \u2014 so a checkpoint named by a ref would hand an agent a commit\n * containing its own edit and let it read that back as if it were upstream\n * work. That exact class cost the measured program real money before the rig\n * moved jj's store out of the workspace (`evals/swebench/run-instance.sh`:\n * django-13346 applied two of its own snapshots as a fake fix), and a ref here\n * would reintroduce it one wave later.\n *\n * The commit object itself is unreferenced. It stays alive for the life of the\n * run \u2014 nothing in a run prunes \u2014 and a checkout by id works perfectly well,\n * which is measured in `CheckpointsFixture.test.ts`. So the tree is reachable\n * by id and no command that walks refs can reach it:\n * `git log`, `git log --all`, `git log -S` and `git show <ref>` all answer\n * exactly as they did before the capture.\n *\n * One command still sees it, measured rather than argued in\n * `CheckpointsFixture.test.ts`: `git fsck` reports it as a dangling commit,\n * because that is what an unreferenced commit is. A checkout is a standalone\n * repository, not a worktree of this one, so `git log --all` does not list it\n * even while a call runs in it. It is not reachable by a name that looks like project history, and the cell\n * contract's environment section says outright that a dangling commit is this\n * harness holding the agent's own tree \u2014 which is the half of the django-13346\n * lesson that a store cannot enforce.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const configSection = \"flows-checkpoint\"\n\n/**\n * One tree this run has pinned.\n *\n * `ref` is the store's own name for it. Nothing above this module interprets\n * it; it travels so the journal says which tree a checkpointed call read.\n *\n * @category models\n * @since 1.0.0\n */\nexport class Snapshot extends Schema.Class<Snapshot>(\"@smthrs/std/Checkpoints/Snapshot\")({\n id: Schema.String,\n ref: Schema.String\n}) {}\n\n/**\n * A tree handed back as a directory, for the length of one call.\n *\n * `host` is where the process running on this machine finds it. `guest` is\n * where a container finds the same directory, which is the same path when no\n * container is in play. They differ exactly as `TestRunner.Runner`'s `cwd` and\n * `root` differ, and for the same reason: one directory, two names.\n *\n * `root` and `guestRoot` are the workspace itself under those same two names.\n * They travel because a call that named a directory *inside* the workspace has\n * to keep it: a check that runs in `tests/` and is pointed at a checkpoint must\n * run in the checkpoint's `tests/`, not at its top. Silently dropping that\n * subpath is how a baseline comes back failing for a reason nobody chose, which\n * is the one failure a checkpoint exists to make impossible.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface Materialized {\n readonly id: string\n readonly host: string\n readonly guest: string\n /** The workspace this checkpoint is a tree of, as this machine names it. */\n readonly root: string\n /** The workspace as a container names it; the same as {@link Materialized.root} when none does. */\n readonly guestRoot: string\n}\n\n/**\n * The two host operations a checkpoint needs.\n *\n * @category services\n * @since 1.0.0\n */\nexport interface Checkpoints {\n /** Records the working tree as it stands, under `id`. */\n readonly capture: (id: string) => Effect.Effect<Snapshot, StdError.StdError>\n /**\n * Hands `id` back as a directory for the length of the effect it wraps.\n *\n * Scoped rather than returned, because the directory has to be removed\n * however the call ends \u2014 a benchmark run killed at its wall-clock budget\n * would otherwise leave a second checkout of the whole repository in a tree\n * whose diff is the run's answer.\n */\n readonly materialize: <A, E, R>(\n id: string,\n use: (materialized: Materialized) => Effect.Effect<A, E, R>\n ) => Effect.Effect<A, E | StdError.StdError, R>\n}\n\n/**\n * The {@link Checkpoints} service tag.\n *\n * @category services\n * @since 1.0.0\n */\nexport const Checkpoints: Context.Service<Checkpoints, Checkpoints> = Context.Service(\"@smthrs/std/Checkpoints\")\n\n/**\n * Builds a store from its two operations.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const make = (service: Checkpoints): Checkpoints => Checkpoints.of(service)\n\n/**\n * The refusal a host with nowhere to pin a tree answers with.\n *\n * @category errors\n * @since 1.0.0\n */\nexport const unavailable = (id: string): StdError.StdError =>\n new StdError.StdError({\n code: \"provider_unavailable\",\n message: `This host pins no trees, so it holds no checkpoint \"${id}\". Take the reading on the live tree instead.`\n })\n\n/**\n * Builds a store for a host that pins nothing.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const makeNoop = (): Checkpoints =>\n make({\n capture: (id) => Effect.fail(unavailable(id)),\n materialize: (id) => Effect.fail(unavailable(id))\n })\n\n/**\n * Provides {@link makeNoop}.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerNoop: Layer.Layer<Checkpoints> = Layer.succeed(Checkpoints, makeNoop())\n\n/**\n * What {@link layerGit} needs to know about the repository it pins.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface GitOptions {\n /** The host path of the git repository whose trees are pinned. */\n readonly root: string\n /**\n * Where a container sees {@link GitOptions.root}, when one does.\n *\n * Absent means there is no container, and the guest path of a materialized\n * checkpoint is then its host path.\n */\n readonly cwd?: string | undefined\n /**\n * The ref naming the tree the run opened on, for {@link baseId}.\n *\n * Absent takes `TestRunner.captureBase` and then `HEAD`, which is the\n * precedence `TestRun` already uses.\n */\n readonly baseRef?: string | undefined\n}\n\nconst failed = (message: string, code: StdError.Code = \"command_failed\"): StdError.StdError =>\n new StdError.StdError({ code, message })\n\n/**\n * A checkpoint id, restricted to what can safely become a git-config key and a\n * directory name. No dots: a dot would split the config key into another\n * subsection.\n */\nconst namable = /^[A-Za-z0-9][A-Za-z0-9-]*$/\n\n/**\n * Builds the git-backed store.\n *\n * Every git command that records or checks out a tree runs against a shadow\n * `GIT_DIR` the harness owns, never the workspace's `.git`, which the agent\n * can write; see `internal/GitWorktree.ts`. The capture reads a copy of the\n * workspace index, so the agent's own index is untouched: its `git diff` is the\n * run's evidence and must not move because the harness recorded something.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const makeGit = (\n options: GitOptions\n): Effect.Effect<Checkpoints, never, ChildProcessSpawner> =>\n Effect.gen(function*() {\n const spawner = yield* ChildProcessSpawner\n return gitStore(options, spawner)\n })\n\n/**\n * The store itself, with the spawner it runs git through already resolved.\n *\n * Resolving it here rather than threading it through {@link Checkpoints} keeps\n * the service's own requirement empty, which is what lets a browser host bind\n * {@link layerNoop} against the identical interface \u2014 the same shape\n * `TestRunner` and `Container` take.\n */\nconst gitStore = (options: GitOptions, spawner: ChildProcessSpawner[\"Service\"]): Checkpoints => {\n const spawn = <A, E>(effect: Effect.Effect<A, E, ChildProcessSpawner>): Effect.Effect<A, E> =>\n Effect.provideService(effect, ChildProcessSpawner, spawner)\n const root = withoutTrailingSlash(options.root)\n const guestRoot = options.cwd === undefined ? root : withoutTrailingSlash(options.cwd)\n const keyOf = (id: string) => `${configSection}.${id}`\n const baseRefs = options.baseRef === undefined ? [TestRunner.captureBase, \"HEAD\"] : [options.baseRef]\n\n /**\n * The commit one id names.\n *\n * `base` is the one id nobody mints, so it is resolved from refs \u2014 the same\n * precedence `TestRun` uses. Every other id was recorded by {@link capture}\n * into this repository's config file, which is where a checkpoint is named\n * *without* becoming history. See {@link configSection}.\n */\n const commitOf = (id: string) =>\n Effect.gen(function*() {\n if (id === baseId) return (yield* GitWorktree.resolveCommit(root, baseRefs)).commit\n const repository = yield* GitWorktree.open(root)\n const found = yield* GitWorktree.config(repository, [\"--get\", keyOf(id)])\n const commit = found.stdout.trim()\n if (found.exitCode !== 0 || commit === \"\") {\n return yield* Effect.fail(\n failed(\n `No checkpoint is stored under ${id} in ${root}. Take the reading on the live tree instead.`,\n \"not_found\"\n )\n )\n }\n return commit\n })\n\n const capture = (id: string) =>\n spawn(Effect.gen(function*() {\n if (!namable.test(id)) {\n return yield* Effect.fail(\n failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, \"invalid_input\")\n )\n }\n const repository = yield* GitWorktree.open(root)\n const commit = yield* GitWorktree.withShadow(repository, (shadow) =>\n Effect.gen(function*() {\n const head = (yield* GitWorktree.resolveCommit(root, [\"HEAD\"])).commit\n yield* shadow.adoptIndex\n const pinned = yield* shadow.git([\"update-ref\", \"--no-deref\", \"HEAD\", head])\n if (pinned.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not record the working tree: ${pinned.stderr.trim()}`))\n }\n const recorded = yield* shadow.git([\"stash\", \"create\", `flows checkpoint ${id}`], root)\n if (recorded.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not record the working tree: ${recorded.stderr.trim()}`))\n }\n // Nothing to record means the working tree IS the commit it is on, so\n // that commit is the checkpoint. `stash create` says so by printing\n // nothing, which is not an error and must not be read as one.\n return recorded.stdout.trim() === \"\" ? head : recorded.stdout.trim()\n }))\n const named = yield* GitWorktree.config(repository, [keyOf(id), commit])\n if (named.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not name the checkpoint: ${named.stderr.trim()}`))\n }\n return new Snapshot({ id, ref: commit })\n }))\n\n const materialize = <A, E, R>(\n id: string,\n use: (materialized: Materialized) => Effect.Effect<A, E, R>\n ): Effect.Effect<A, E | StdError.StdError, R> =>\n Effect.gen(function*() {\n if (!namable.test(id)) {\n return yield* Effect.fail(\n failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, \"invalid_input\")\n )\n }\n const commit = yield* spawn(commitOf(id))\n const context = yield* Effect.context<R>()\n return yield* GitWorktree.withDetachedWorktree(\n root,\n `${scratchDirectory}/${id}`,\n commit,\n (host) =>\n use({ id, host, guest: `${guestRoot}${host.slice(root.length)}`, root, guestRoot }).pipe(\n Effect.provideContext(context)\n )\n ).pipe(Effect.provideService(ChildProcessSpawner, spawner))\n })\n\n return make({ capture, materialize })\n}\n\n/**\n * Provides {@link makeGit}.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerGit = (options: GitOptions): Layer.Layer<Checkpoints, never, ChildProcessSpawner> =>\n Layer.effect(Checkpoints)(makeGit(options))\n/**\n * Rewrites one call's input so the call runs against a materialized checkpoint.\n *\n * Re-exported from {@link Relocate}, which owns the table of flows and fields\n * this rewrite is driven by. It is exported here because the harness reaches the\n * whole checkpoint feature through this module.\n *\n * @category conversions\n * @since 1.0.0\n */\nexport { relocate, type Relocation } from \"./Relocate.ts\"\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwEA,iCAAoC;AACpC,oBAA+C;AAC/C,yBAA4B;AAC5B,mBAAqC;AACrC,YAAuB;AACvB,eAA0B;AAC1B,iBAA4B;
|
|
4
|
+
"sourcesContent": ["/**\n * Pinned trees, and the scratch checkouts a call runs against.\n *\n * A checkpoint is a **value**: minting one changes nothing about the workspace,\n * and running a call against one leaves the live tree exactly as it stands.\n * That is the whole of what it buys. Before it existed, the only way a run\n * could answer \"did this command fail before my change\" was to undo the change\n * \u2014 and the journals price that exactly. On `sympy__sympy-13878` the r95repl\n * lane applied one byte-identical 4,789-character patch **five times**, four of\n * those applications preceded by `git checkout -- sympy/stats/crv_types.py`,\n * because a clean fails-before proof required reverting the very work it was\n * meant to prove.\n *\n * This module is the host half of `@smthrs/harness`'s `ctx.checkpoint()` and\n * `ctx.call(flow, input, { at })`. The harness owns the surface, the identity,\n * the bound and the refusals; nothing in it knows what a tree is. This owns the\n * two host operations that need one:\n *\n * - {@link Checkpoints.capture} records the working tree under an id, and\n * - {@link Checkpoints.materialize} gives that tree back as a directory for the\n * length of one call.\n *\n * ## The git binding, and the container constraint it is shaped by\n *\n * {@link layerGit} records a checkpoint with `git stash create`, then names the\n * commit it prints in this repository's own git config rather than with a ref \u2014\n * see {@link configSection} for why a ref would hand the agent its own edit back\n * as history. `stash create` is the one git command\n * that records the working tree and changes nothing else: it does not move the\n * worktree and does not touch the stash ref. It runs against a shadow\n * `GIT_DIR` over a copy of the workspace index (see `internal/GitWorktree.ts`),\n * so it never writes the repository's index and never runs a program the\n * workspace's `.git` names. That matters more than it sounds. The agent runs `git` in this same\n * workspace and its own `git diff` is the run's evidence, so a capture that\n * staged into the real index would be the harness editing the evidence while\n * recording it. A tree with nothing to record prints nothing, and the\n * checkpoint is then `HEAD` \u2014 which is exactly what the tree is.\n *\n * Untracked files are not in the recorded tree, which matches how the rig\n * captures a patch: `capture-patch.sh` drops paths that did not exist when the\n * agent started, so a checkpoint holds what a patch would hold.\n *\n * The materialization is a detached checkout at `<root>/.flows-checkpoints/<id>-<lease>`\n * \u2014 **inside** the workspace, which looks wrong and is the only thing that\n * works. A benchmark check runs through `docker exec` inside `/testbed`, and\n * `/testbed` is a bind mount of the live workspace. A scratch checkout anywhere\n * else on the host is simply not visible to the container, so the call would run\n * against a path that does not exist. Placed under the workspace it is visible\n * at the same subpath under the mount, needs no second mount, and needs no\n * change to how the rig starts its container. `TestRun`'s `against: \"base\"`\n * reached the same conclusion first and this reuses its shape;\n * `evals/swebench/run-instance.sh` excludes the directory from patch capture for\n * the same reason it excludes `.flows-test-base`.\n *\n * The checkout is added and removed around **one call**, which is stricter than\n * the frame lifetime the design asks for and much simpler: there is no cache to\n * invalidate, no id to leak, and a checkpoint used by three calls pays three\n * checkouts rather than risking one stale directory. A run that reuses a\n * checkpoint across frames simply re-materializes it, because the ref is what\n * persists.\n *\n * ## What can be pointed at a checkpoint, and what cannot\n *\n * {@link relocate} is the closed answer, and `Relocate.ts` owns it. That half\n * knows the input shapes of `bash`, `read`, `ls`, `grep` and `glob`; this half\n * knows git. They change for different reasons, so they are different modules,\n * and {@link relocate} is re-exported here because the harness reaches the whole\n * feature through this one.\n *\n * @since 1.0.0\n */\n\nimport { ChildProcessSpawner } from \"@smthrs/kernel/ChildProcessSpawner\"\nimport { Context, Effect, Layer, Schema } from \"effect\"\nimport * as Container from \"./Container.ts\"\nimport * as Exec from \"./internal/Exec.ts\"\nimport { GitWorktree } from \"./internal/GitWorktree.ts\"\nimport { withoutTrailingSlash } from \"./internal/Paths.ts\"\nimport * as Prune from \"./internal/Prune.ts\"\nimport * as StdError from \"./StdError.ts\"\nimport * as TestRunner from \"./TestRunner.ts\"\n\n/**\n * The id naming the tree a run opened on.\n *\n * It is not minted: the host either recorded one before the agent started or it\n * did not. {@link layerGit} resolves it to {@link TestRunner.captureBase} and\n * then to `HEAD`, which is the same precedence `TestRun` uses for the same\n * question \u2014 so a workspace that has one answer for a baseline has one answer\n * for both.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const baseId = \"base\"\n\n/**\n * The directory checkpoints are materialized into, relative to the repository\n * root and therefore also relative to a container's view of it.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const scratchDirectory = Prune.checkpointScratch\n\n/**\n * The git-config section {@link layerGit} records minted checkpoints under.\n *\n * Config and **not a ref**, and that is the whole of the decision. A ref is\n * history: `git log --all` lists it, `git show` prints it, and `git log --all\n * -S` searches it \u2014 so a checkpoint named by a ref would hand an agent a commit\n * containing its own edit and let it read that back as if it were upstream\n * work. That exact class cost the measured program real money before the rig\n * moved jj's store out of the workspace (`evals/swebench/run-instance.sh`:\n * django-13346 applied two of its own snapshots as a fake fix), and a ref here\n * would reintroduce it one wave later.\n *\n * The commit object itself is unreferenced. It stays alive for the life of the\n * run \u2014 nothing in a run prunes \u2014 and a checkout by id works perfectly well,\n * which is measured in `CheckpointsFixture.test.ts`. So the tree is reachable\n * by id and no command that walks refs can reach it:\n * `git log`, `git log --all`, `git log -S` and `git show <ref>` all answer\n * exactly as they did before the capture.\n *\n * One command still sees it, measured rather than argued in\n * `CheckpointsFixture.test.ts`: `git fsck` reports it as a dangling commit,\n * because that is what an unreferenced commit is. A checkout is a standalone\n * repository, not a worktree of this one, so `git log --all` does not list it\n * even while a call runs in it. It is not reachable by a name that looks like project history, and the cell\n * contract's environment section says outright that a dangling commit is this\n * harness holding the agent's own tree \u2014 which is the half of the django-13346\n * lesson that a store cannot enforce.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const configSection = \"flows-checkpoint\"\n\n/**\n * One tree this run has pinned.\n *\n * `ref` is the store's own name for it. Nothing above this module interprets\n * it; it travels so the journal says which tree a checkpointed call read.\n *\n * @category models\n * @since 1.0.0\n */\nexport class Snapshot extends Schema.Class<Snapshot>(\"@smthrs/std/Checkpoints/Snapshot\")({\n id: Schema.String,\n ref: Schema.String\n}) {}\n\n/**\n * A tree handed back as a directory, for the length of one call.\n *\n * `host` is where the process running on this machine finds it. `guest` is\n * where a container finds the same directory, which is the same path when no\n * container is in play. They differ exactly as `TestRunner.Runner`'s `cwd` and\n * `root` differ, and for the same reason: one directory, two names.\n *\n * `root` and `guestRoot` are the workspace itself under those same two names.\n * They travel because a call that named a directory *inside* the workspace has\n * to keep it: a check that runs in `tests/` and is pointed at a checkpoint must\n * run in the checkpoint's `tests/`, not at its top. Silently dropping that\n * subpath is how a baseline comes back failing for a reason nobody chose, which\n * is the one failure a checkpoint exists to make impossible.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface Materialized {\n readonly id: string\n readonly host: string\n readonly guest: string\n /** The workspace this checkpoint is a tree of, as this machine names it. */\n readonly root: string\n /** The workspace as a container names it; the same as {@link Materialized.root} when none does. */\n readonly guestRoot: string\n}\n\n/**\n * The two host operations a checkpoint needs.\n *\n * @category services\n * @since 1.0.0\n */\nexport interface Checkpoints {\n /** Records the working tree as it stands, under `id`. */\n readonly capture: (id: string) => Effect.Effect<Snapshot, StdError.StdError>\n /**\n * Hands `id` back as a directory for the length of the effect it wraps.\n *\n * Scoped rather than returned, because the directory has to be removed\n * however the call ends \u2014 a benchmark run killed at its wall-clock budget\n * would otherwise leave a second checkout of the whole repository in a tree\n * whose diff is the run's answer.\n */\n readonly materialize: <A, E, R>(\n id: string,\n use: (materialized: Materialized) => Effect.Effect<A, E, R>\n ) => Effect.Effect<A, E | StdError.StdError, R>\n}\n\n/**\n * The {@link Checkpoints} service tag.\n *\n * @category services\n * @since 1.0.0\n */\nexport const Checkpoints: Context.Service<Checkpoints, Checkpoints> = Context.Service(\"@smthrs/std/Checkpoints\")\n\n/**\n * Builds a store from its two operations.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const make = (service: Checkpoints): Checkpoints => Checkpoints.of(service)\n\n/**\n * The refusal a host with nowhere to pin a tree answers with.\n *\n * @category errors\n * @since 1.0.0\n */\nexport const unavailable = (id: string): StdError.StdError =>\n new StdError.StdError({\n code: \"provider_unavailable\",\n message: `This host pins no trees, so it holds no checkpoint \"${id}\". Take the reading on the live tree instead.`\n })\n\n/**\n * Builds a store for a host that pins nothing.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const makeNoop = (): Checkpoints =>\n make({\n capture: (id) => Effect.fail(unavailable(id)),\n materialize: (id) => Effect.fail(unavailable(id))\n })\n\n/**\n * Provides {@link makeNoop}.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerNoop: Layer.Layer<Checkpoints> = Layer.succeed(Checkpoints, makeNoop())\n\n/**\n * What {@link layerGit} needs to know about the repository it pins.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface GitOptions {\n /** The host path of the git repository whose trees are pinned. */\n readonly root: string\n /**\n * Where a container sees {@link GitOptions.root}, when one does.\n *\n * Absent means there is no container, and the guest path of a materialized\n * checkpoint is then its host path.\n */\n readonly cwd?: string | undefined\n /**\n * The ref naming the tree the run opened on, for {@link baseId}.\n *\n * Absent takes `TestRunner.captureBase` and then `HEAD`, which is the\n * precedence `TestRun` already uses.\n */\n readonly baseRef?: string | undefined\n}\n\nconst failed = (message: string, code: StdError.Code = \"command_failed\"): StdError.StdError =>\n new StdError.StdError({ code, message })\n\n/**\n * A checkpoint id, restricted to what can safely become a git-config key and a\n * directory name. No dots: a dot would split the config key into another\n * subsection.\n */\nconst namable = /^[A-Za-z0-9][A-Za-z0-9-]*$/\n\n/**\n * Builds the git-backed store.\n *\n * Every git command that records or checks out a tree runs against a shadow\n * `GIT_DIR` the harness owns, never the workspace's `.git`, which the agent\n * can write; see `internal/GitWorktree.ts`. The capture reads a copy of the\n * workspace index, so the agent's own index is untouched: its `git diff` is the\n * run's evidence and must not move because the harness recorded something.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const makeGit = (\n options: GitOptions\n): Effect.Effect<Checkpoints, never, ChildProcessSpawner> =>\n Effect.gen(function*() {\n const spawner = yield* ChildProcessSpawner\n return gitStore(options, spawner)\n })\n\n/**\n * The store itself, with the spawner it runs git through already resolved.\n *\n * Resolving it here rather than threading it through {@link Checkpoints} keeps\n * the service's own requirement empty, which is what lets a browser host bind\n * {@link layerNoop} against the identical interface \u2014 the same shape\n * `TestRunner` and `Container` take.\n */\nconst gitStore = (options: GitOptions, spawner: ChildProcessSpawner[\"Service\"]): Checkpoints => {\n const spawn = <A, E>(effect: Effect.Effect<A, E, ChildProcessSpawner>): Effect.Effect<A, E> =>\n Effect.provideService(effect, ChildProcessSpawner, spawner)\n const root = withoutTrailingSlash(options.root)\n const guestRoot = options.cwd === undefined ? root : withoutTrailingSlash(options.cwd)\n const keyOf = (id: string) => `${configSection}.${id}`\n const baseRefs = options.baseRef === undefined ? [TestRunner.captureBase, \"HEAD\"] : [options.baseRef]\n\n /**\n * The commit one id names.\n *\n * `base` is the one id nobody mints, so it is resolved from refs \u2014 the same\n * precedence `TestRun` uses. Every other id was recorded by {@link capture}\n * into this repository's config file, which is where a checkpoint is named\n * *without* becoming history. See {@link configSection}.\n */\n const commitOf = (id: string) =>\n Effect.gen(function*() {\n if (id === baseId) return (yield* GitWorktree.resolveCommit(root, baseRefs)).commit\n const repository = yield* GitWorktree.open(root)\n const found = yield* GitWorktree.config(repository, [\"--get\", keyOf(id)])\n const commit = found.stdout.trim()\n if (found.exitCode !== 0 || commit === \"\") {\n return yield* Effect.fail(\n failed(\n `No checkpoint is stored under ${id} in ${root}. Take the reading on the live tree instead.`,\n \"not_found\"\n )\n )\n }\n return commit\n })\n\n const capture = (id: string) =>\n spawn(Effect.gen(function*() {\n if (!namable.test(id)) {\n return yield* Effect.fail(\n failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, \"invalid_input\")\n )\n }\n const repository = yield* GitWorktree.open(root)\n const commit = yield* GitWorktree.withShadow(repository, (shadow) =>\n Effect.gen(function*() {\n const head = (yield* GitWorktree.resolveCommit(root, [\"HEAD\"])).commit\n yield* shadow.adoptIndex\n const pinned = yield* shadow.git([\"update-ref\", \"--no-deref\", \"HEAD\", head])\n if (pinned.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not record the working tree: ${pinned.stderr.trim()}`))\n }\n const recorded = yield* shadow.git([\"stash\", \"create\", `flows checkpoint ${id}`], root)\n if (recorded.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not record the working tree: ${recorded.stderr.trim()}`))\n }\n // Nothing to record means the working tree IS the commit it is on, so\n // that commit is the checkpoint. `stash create` says so by printing\n // nothing, which is not an error and must not be read as one.\n return recorded.stdout.trim() === \"\" ? head : recorded.stdout.trim()\n }))\n const named = yield* GitWorktree.config(repository, [keyOf(id), commit])\n if (named.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not name the checkpoint: ${named.stderr.trim()}`))\n }\n return new Snapshot({ id, ref: commit })\n }))\n\n const materialize = <A, E, R>(\n id: string,\n use: (materialized: Materialized) => Effect.Effect<A, E, R>\n ): Effect.Effect<A, E | StdError.StdError, R> =>\n Effect.gen(function*() {\n if (!namable.test(id)) {\n return yield* Effect.fail(\n failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, \"invalid_input\")\n )\n }\n const commit = yield* spawn(commitOf(id))\n const context = yield* Effect.context<R>()\n return yield* GitWorktree.withDetachedWorktree(\n root,\n `${scratchDirectory}/${id}`,\n commit,\n (host) =>\n use({ id, host, guest: `${guestRoot}${host.slice(root.length)}`, root, guestRoot }).pipe(\n Effect.provideContext(context)\n )\n ).pipe(Effect.provideService(ChildProcessSpawner, spawner))\n })\n\n return make({ capture, materialize })\n}\n\n/**\n * Provides {@link makeGit}.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerGit = (options: GitOptions): Layer.Layer<Checkpoints, never, ChildProcessSpawner> =>\n Layer.effect(Checkpoints)(makeGit(options))\n\n/**\n * What {@link makeContainer} needs to know about the container it pins in.\n *\n * @category models\n * @since 1.0.0-rc.8\n */\nexport interface ContainerOptions {\n /** The container `bash` runs in. */\n readonly container: string\n /** A directory of the repository inside it; absent is the container's own working directory. */\n readonly cwd?: string | undefined\n}\n\n/**\n * `$1` is the id. Records the working tree with `stash create` over a copy of\n * the index, names the commit in config as {@link makeGit} does, and prints it.\n */\nconst pinScript = [\n \"set -e\",\n \"cd \\\"$(git rev-parse --show-toplevel)\\\"\",\n \"copy=$(mktemp -d)\",\n \"trap 'rm -rf -- \\\"$copy\\\"' EXIT\",\n \"index=$(git rev-parse --git-path index)\",\n \"if [ -e \\\"$index\\\" ]; then cp -p -- \\\"$index\\\" \\\"$copy/index\\\"; fi\",\n \"commit=$(GIT_INDEX_FILE=\\\"$copy/index\\\" git -c user.name=flows -c user.email=flows@localhost stash create \\\"flows checkpoint $1\\\")\",\n \"[ -n \\\"$commit\\\" ] || commit=$(git rev-parse --verify 'HEAD^{commit}')\",\n `git config \"${configSection}.$1\" \"$commit\"`,\n \"printf '%s\\\\n' \\\"$commit\\\"\"\n].join(\"\\n\")\n\n/**\n * `$1` is the id, `$2` the lease. Checks the tree out at\n * `<top>/.flows-checkpoints/<id>-<lease>` in a repository of its own whose\n * objects are the workspace's, and prints the top and the checkout.\n */\nconst checkoutScript = [\n \"set -e\",\n \"top=$(git rev-parse --show-toplevel)\",\n \"cd \\\"$top\\\"\",\n \"common=$(cd \\\"$(git rev-parse --git-common-dir)\\\" && pwd -P)\",\n `if [ \"$1\" = ${baseId} ]; then`,\n ` commit=$(git rev-parse --verify --quiet '${TestRunner.captureBase}^{commit}' || git rev-parse --verify --quiet 'HEAD^{commit}') || { echo \"No commit resolves from ${TestRunner.captureBase} or HEAD in $top.\" >&2; exit 1; }`,\n \"else\",\n ` commit=$(git config --get \"${configSection}.$1\") || { echo \"No checkpoint is stored under $1 in $top. Take the reading on the live tree instead.\" >&2; exit 1; }`,\n \"fi\",\n `dir=\"$top/${scratchDirectory}/$1-$2\"`,\n \"trap 'rm -rf -- \\\"$dir\\\"' EXIT\",\n `mkdir -p -- \"$top/${scratchDirectory}\"`,\n \"git init --quiet \\\"$dir\\\"\",\n \"printf '%s/objects\\\\n' \\\"$common\\\" > \\\"$dir/.git/objects/info/alternates\\\"\",\n \"git -C \\\"$dir\\\" checkout --quiet --detach \\\"$commit\\\"\",\n \"trap - EXIT\",\n \"printf '%s\\\\n%s\\\\n' \\\"$top\\\" \\\"$dir\\\"\"\n].join(\"\\n\")\n\n/**\n * Builds the store for a host whose `bash` runs in one container.\n *\n * The repository is the container's, so every git command runs there, through\n * the same {@link Container.Container} transport `bash` takes. The host store\n * looked in the CLI's own directory instead and refused every `at` in 112 of\n * 123 trials of the 2026-10-14 SWE-bench Pro run. This keeps that store's\n * shape: a checkpoint is a `stash create` commit named in config, and a tree\n * is checked out under the repository for one call, so a relocated `bash`\n * call keeps its subdirectory and still finds what the workspace installs\n * beside it. That git may run what the repository configures, but only inside\n * the container the agent already commands.\n *\n * @category constructors\n * @since 1.0.0-rc.8\n */\nexport const makeContainer = (\n options: ContainerOptions\n): Effect.Effect<Checkpoints, never, ChildProcessSpawner | Container.Container> =>\n Effect.gen(function*() {\n const spawner = yield* ChildProcessSpawner\n const transport = yield* Container.Container\n const sh = (script: string, args: ReadonlyArray<string>) =>\n transport.exec({\n container: options.container,\n file: \"sh\",\n args: [\"-c\", script, \"sh\", ...args],\n cwd: options.cwd,\n stdin: false\n }).pipe(\n Effect.flatMap((plan) =>\n Exec.exec(plan.file, { args: plan.args, env: plan.env }).pipe(\n Effect.mapError((error) => Exec.toStdError(plan.file, error))\n )\n ),\n Effect.flatMap((result) =>\n result.exitCode === 0\n ? Effect.succeed(result.stdout.trim().split(\"\\n\"))\n : Effect.fail(failed(`git in container ${options.container} failed: ${result.stderr.trim()}`))\n ),\n Effect.provideService(ChildProcessSpawner, spawner)\n )\n const named = (id: string) =>\n namable.test(id)\n ? Effect.void\n : Effect.fail(failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, \"invalid_input\"))\n return make({\n capture: (id) =>\n named(id).pipe(\n Effect.andThen(sh(pinScript, [id])),\n Effect.map(([commit]) => new Snapshot({ id, ref: commit! }))\n ),\n materialize: (id, use) =>\n named(id).pipe(Effect.andThen(Effect.acquireUseRelease(\n sh(checkoutScript, [id, globalThis.crypto.randomUUID()]),\n ([root, checkout]) => use({ id, host: checkout!, guest: checkout!, root: root!, guestRoot: root! }),\n ([, checkout]) =>\n sh(\"rm -rf -- \\\"$1\\\"\", [checkout!]).pipe(\n Effect.catch((error) =>\n Effect.logWarning(\"could not remove a scratch checkout\").pipe(\n Effect.annotateLogs({ path: checkout, reason: error.message })\n )\n )\n )\n )))\n })\n })\n\n/**\n * Provides {@link makeContainer}.\n *\n * @category layers\n * @since 1.0.0-rc.8\n */\nexport const layerContainer = (\n options: ContainerOptions\n): Layer.Layer<Checkpoints, never, ChildProcessSpawner | Container.Container> =>\n Layer.effect(Checkpoints)(makeContainer(options))\n\n/**\n * Rewrites one call's input so the call runs against a materialized checkpoint.\n *\n * Re-exported from {@link Relocate}, which owns the table of flows and fields\n * this rewrite is driven by. It is exported here because the harness reaches the\n * whole checkpoint feature through this module.\n *\n * @category conversions\n * @since 1.0.0\n */\nexport { relocate, type Rel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;AAAA,IACJ,CAAC,CAAC;AAAA,EACN,CAAC;AACH,CAAC;AAQI,MAAM,iBAAiB,CAC5B,YAEA,oBAAM,OAAO,WAAW,EAAE,cAAc,OAAO,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -52,6 +52,8 @@ export interface PathReference {
|
|
|
52
52
|
/**
|
|
53
53
|
* Every path token the shell text names, one segment at a time.
|
|
54
54
|
*
|
|
55
|
+
* @throws {StdError.StdError} `invalid_input` when substitutions or quotes nest
|
|
56
|
+
* deeper than the scan reads.
|
|
55
57
|
* @category pre-check
|
|
56
58
|
* @since 1.0.0
|
|
57
59
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvelopePrecheck.d.ts","sourceRoot":"","sources":["../../../src/internal/EnvelopePrecheck.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAG1C;;;;;;;;;GASG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACrC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACvC;AAED;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAErC;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;
|
|
1
|
+
{"version":3,"file":"EnvelopePrecheck.d.ts","sourceRoot":"","sources":["../../../src/internal/EnvelopePrecheck.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,O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