reeval-python 0.20.0__tar.gz → 0.21.0__tar.gz
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.
- {reeval_python-0.20.0 → reeval_python-0.21.0}/PKG-INFO +13 -1
- {reeval_python-0.20.0 → reeval_python-0.21.0}/README.md +12 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/pyproject.toml +1 -1
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/_wire.py +158 -25
- reeval_python-0.21.0/src/reeval_python/binaries.json +55 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/context.py +68 -17
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/declare.py +2 -2
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/expect.py +21 -2
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/options.py +3 -1
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/types.py +3 -2
- reeval_python-0.21.0/tests/context/exec-env.eval.py +11 -0
- reeval_python-0.21.0/tests/context/exec-env.sync.eval.py +11 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/stdio_host.py +7 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_api.py +1 -1
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_patterns.py +30 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_runner_attempts.py +24 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_runner_misuse.py +25 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/uv.lock +1 -1
- reeval_python-0.20.0/src/reeval_python/binaries.json +0 -55
- {reeval_python-0.20.0 → reeval_python-0.21.0}/.gitignore +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/CHANGELOG.md +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/LICENSE +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/package.json +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/__init__.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/__main__.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/aio.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/checks.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/cli.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/environment.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/errors.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/py.typed +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/runner.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/src/reeval_python/wire.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/abort.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/abort.sync.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/exec-retries.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/exec-retries.sync.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/exec.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/exec.sync.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/expect-fail.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/expect-fail.sync.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/expect.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/expect.sync.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/files.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/files.sync.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/judge.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/judge.sync.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/observe.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/observe.sync.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/record.async.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/record.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/send.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/send.sync.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/stay-within.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/sync-async.async.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/context/sync-async.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/best-of.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/cases.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/compare-questions.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/compare-variants.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/egress-cascade.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/environment-extend.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/environment-plugin-marketplace.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/environment-plugins.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/environment-traits.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/groups-skip-todo.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/observe.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/questions-attempts.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/questions-group.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/questions-state.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/revision.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/declare/tags.eval.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/runner_process.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_checks.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_cli.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_conformance_context.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_conformance_declare.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_load.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_python_wheels.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_runner_checks.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_runner_isolation.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_runner_json.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_runner_sdk.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_runner_stdio.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_source.py +0 -0
- {reeval_python-0.20.0 → reeval_python-0.21.0}/tests/test_types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: reeval-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.21.0
|
|
4
4
|
Summary: Python authoring SDK for reeval (*.eval.py eval files)
|
|
5
5
|
Project-URL: Homepage, https://reeval.ai
|
|
6
6
|
Project-URL: Repository, https://github.com/invertase/reeval
|
|
@@ -135,6 +135,14 @@ import re
|
|
|
135
135
|
expect(c.turns[0]).to_have_run(re.compile(r"^(npm|pnpm) t(est)?$"))
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
+
`to_have_run(program=…, args=…)` matches the program a shell call ran instead of the whole command
|
|
139
|
+
line, after env assignments, `timeout`, `sudo` and package runners such as `npx`, so
|
|
140
|
+
`cat genkit.config.ts` doesn't count as running `genkit`:
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
expect(c).to_have_run(program="genkit", args=re.compile(r"^flow:run\b"))
|
|
144
|
+
```
|
|
145
|
+
|
|
138
146
|
Use snake_case on the context (`read_file`, `write_file`, `file`) and on matchers (`to_succeed`,
|
|
139
147
|
`to_pass`, `to_equal`, `to_contain`, …). Matcher failures raise `ReevalAssertionError`.
|
|
140
148
|
|
|
@@ -185,6 +193,10 @@ the last try. Use it for a check that can fail on a transient, such as a test th
|
|
|
185
193
|
`expect(c.exec("pytest -q tests/hidden", retries=2)).to_succeed()`. Any non-zero exit retries,
|
|
186
194
|
and the record and output say `passed on try 2 of 3`.
|
|
187
195
|
|
|
196
|
+
`c.exec(cmd, env={"EXPECTED": "42"})` sets variables for that command only, over the
|
|
197
|
+
environment's, in the background and in `expect.poll` too. A value named like a secret
|
|
198
|
+
(`*_TOKEN`, `*_KEY`, …) is masked in everything reeval writes.
|
|
199
|
+
|
|
188
200
|
`expect.poll` retries a matcher until it passes, every `interval` until `timeout` (one second by
|
|
189
201
|
default). Hand it a function that returns one `c.read_file(…)` or `c.exec(…)`, and reeval reads or
|
|
190
202
|
runs it again on each try; it works the same in both kinds of body. Check the output with the
|
|
@@ -111,6 +111,14 @@ import re
|
|
|
111
111
|
expect(c.turns[0]).to_have_run(re.compile(r"^(npm|pnpm) t(est)?$"))
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
+
`to_have_run(program=…, args=…)` matches the program a shell call ran instead of the whole command
|
|
115
|
+
line, after env assignments, `timeout`, `sudo` and package runners such as `npx`, so
|
|
116
|
+
`cat genkit.config.ts` doesn't count as running `genkit`:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
expect(c).to_have_run(program="genkit", args=re.compile(r"^flow:run\b"))
|
|
120
|
+
```
|
|
121
|
+
|
|
114
122
|
Use snake_case on the context (`read_file`, `write_file`, `file`) and on matchers (`to_succeed`,
|
|
115
123
|
`to_pass`, `to_equal`, `to_contain`, …). Matcher failures raise `ReevalAssertionError`.
|
|
116
124
|
|
|
@@ -161,6 +169,10 @@ the last try. Use it for a check that can fail on a transient, such as a test th
|
|
|
161
169
|
`expect(c.exec("pytest -q tests/hidden", retries=2)).to_succeed()`. Any non-zero exit retries,
|
|
162
170
|
and the record and output say `passed on try 2 of 3`.
|
|
163
171
|
|
|
172
|
+
`c.exec(cmd, env={"EXPECTED": "42"})` sets variables for that command only, over the
|
|
173
|
+
environment's, in the background and in `expect.poll` too. A value named like a secret
|
|
174
|
+
(`*_TOKEN`, `*_KEY`, …) is masked in everything reeval writes.
|
|
175
|
+
|
|
164
176
|
`expect.poll` retries a matcher until it passes, every `interval` until `timeout` (one second by
|
|
165
177
|
default). Hand it a function that returns one `c.read_file(…)` or `c.exec(…)`, and reeval reads or
|
|
166
178
|
runs it again on each try; it works the same in both kinds of body. Check the output with the
|
|
@@ -91,14 +91,15 @@ class AttemptCallSend(TypedDict):
|
|
|
91
91
|
prompt: str
|
|
92
92
|
|
|
93
93
|
|
|
94
|
-
# `c.exec(command, { background?, retries?, interval? })`: a command in the sandbox.
|
|
95
|
-
# with its exit code and output (the last try, with `retries`), or with a handle when it
|
|
96
|
-
# the background.
|
|
94
|
+
# `c.exec(command, { background?, env?, retries?, interval? })`: a command in the sandbox.
|
|
95
|
+
# Replies with its exit code and output (the last try, with `retries`), or with a handle when it
|
|
96
|
+
# runs in the background.
|
|
97
97
|
class AttemptCallExec(TypedDict):
|
|
98
98
|
# Leave it running and reply with its handle, not its output.
|
|
99
99
|
background: NotRequired[bool]
|
|
100
100
|
# A shell command, run in the workspace.
|
|
101
101
|
command: str
|
|
102
|
+
env: NotRequired[ExecEnv]
|
|
102
103
|
# Milliseconds to wait before each extra try. Default 1000.
|
|
103
104
|
interval: NotRequired[float]
|
|
104
105
|
op: Literal["exec"]
|
|
@@ -766,6 +767,10 @@ DockerSandboxDescriptor = TypedDict(
|
|
|
766
767
|
Duration: TypeAlias = "float | str"
|
|
767
768
|
|
|
768
769
|
|
|
770
|
+
# One policy for the whole attempt, or one per phase.
|
|
771
|
+
Egress: TypeAlias = "EgressPolicy | PhasedEgress"
|
|
772
|
+
|
|
773
|
+
|
|
769
774
|
class EgressPolicyAllow(TypedDict):
|
|
770
775
|
allow: list[str]
|
|
771
776
|
|
|
@@ -805,8 +810,9 @@ class EnvironmentLayer(TypedDict):
|
|
|
805
810
|
|
|
806
811
|
# What an eval runs in: the declarative, phased spec of one environment.
|
|
807
812
|
class EnvironmentSpec(TypedDict):
|
|
808
|
-
# Replaces the inherited policy
|
|
809
|
-
|
|
813
|
+
# Replaces the inherited policy, per phase: a plain policy sets both, `{ setup, agent }` the
|
|
814
|
+
# phases it names. An `extend` child's replaces its parent's the same way.
|
|
815
|
+
egress: NotRequired[Egress]
|
|
810
816
|
# Variables and secrets for the sandbox, merged by name over the parent's.
|
|
811
817
|
env: NotRequired[EnvVars]
|
|
812
818
|
# Workspace-relative, or `~/` for home.
|
|
@@ -879,9 +885,9 @@ class EvalOptionsDataCompare(TypedDict):
|
|
|
879
885
|
capture: NotRequired[CaptureOptions]
|
|
880
886
|
# Environments to run side by side; `control` is what each variant is measured against.
|
|
881
887
|
compare: EvalOptionsDataCompareCompare
|
|
882
|
-
# Where the sandbox may connect. Replaces the inherited policy: config, profile
|
|
883
|
-
# the environment, then groups and the eval.
|
|
884
|
-
egress: NotRequired[Literal["allow-all", "deny-all", "proxy"] | EvalOptionsDataCompareEgressAllow]
|
|
888
|
+
# Where the sandbox may connect. Replaces the inherited policy, per phase: config, profile
|
|
889
|
+
# defaults, the environment, then groups and the eval.
|
|
890
|
+
egress: NotRequired[PhasedEgress | Literal["allow-all", "deny-all", "proxy"] | EvalOptionsDataCompareEgressAllow]
|
|
885
891
|
# Variables and secrets for the sandbox, merged by name down the cascade.
|
|
886
892
|
env: NotRequired[EnvVars]
|
|
887
893
|
# How each cell's attempts decide its outcome; default `'all'`.
|
|
@@ -952,9 +958,9 @@ class EvalOptionsData2(TypedDict):
|
|
|
952
958
|
# Screenshot defaults for `c.capture()`. Shallow-merged; `viewport` and `model` replace the
|
|
953
959
|
# value.
|
|
954
960
|
capture: NotRequired[CaptureOptions]
|
|
955
|
-
# Where the sandbox may connect. Replaces the inherited policy: config, profile
|
|
956
|
-
# the environment, then groups and the eval.
|
|
957
|
-
egress: NotRequired[Literal["allow-all", "deny-all", "proxy"] | EvalOptionsData2EgressAllow]
|
|
961
|
+
# Where the sandbox may connect. Replaces the inherited policy, per phase: config, profile
|
|
962
|
+
# defaults, the environment, then groups and the eval.
|
|
963
|
+
egress: NotRequired[PhasedEgress | Literal["allow-all", "deny-all", "proxy"] | EvalOptionsData2EgressAllow]
|
|
958
964
|
# Variables and secrets for the sandbox, merged by name down the cascade.
|
|
959
965
|
env: NotRequired[EnvVars]
|
|
960
966
|
# What this group or eval runs in: one environment, or a list, each its own cell beside each
|
|
@@ -1002,6 +1008,13 @@ class EvalOptionsData2(TypedDict):
|
|
|
1002
1008
|
EvalOptionsData: TypeAlias = "EvalOptionsDataCompare | EvalOptionsData2"
|
|
1003
1009
|
|
|
1004
1010
|
|
|
1011
|
+
# Variables `c.exec` sets for one command, over the environment's own. A value whose name looks
|
|
1012
|
+
# like a secret's (`KEY`, `TOKEN`, `SECRET`, `PASSWORD`, `CREDENTIAL`) is masked in everything
|
|
1013
|
+
# reeval writes, as a host variable's is. The host value of a secret the environment brokers
|
|
1014
|
+
# goes in as its placeholder, which the gateway swaps back on that secret's hosts.
|
|
1015
|
+
ExecEnv: TypeAlias = "dict[str, str]"
|
|
1016
|
+
|
|
1017
|
+
|
|
1005
1018
|
class ExecResult(TypedDict):
|
|
1006
1019
|
exitCode: int
|
|
1007
1020
|
stderr: str
|
|
@@ -1009,6 +1022,7 @@ class ExecResult(TypedDict):
|
|
|
1009
1022
|
|
|
1010
1023
|
|
|
1011
1024
|
class FakeHarnessDescriptorToolsItem(TypedDict):
|
|
1025
|
+
durationMs: NotRequired[float | None]
|
|
1012
1026
|
input: Any
|
|
1013
1027
|
ok: NotRequired[bool | None]
|
|
1014
1028
|
output: Any
|
|
@@ -1032,12 +1046,23 @@ class FakeHarnessDescriptorWithSkill(TypedDict):
|
|
|
1032
1046
|
|
|
1033
1047
|
# A canned agent for tests and dry runs, made by `fakeHarness()` in `reeval/harness`.
|
|
1034
1048
|
class FakeHarnessDescriptor(TypedDict):
|
|
1049
|
+
# A shell command the fake agent runs as its session starts, once per sandbox, as a real
|
|
1050
|
+
# adapter's bootstrap installs its CLI: `tart()` bakes it into the image it clones, as it
|
|
1051
|
+
# does a real harness's, so an attempt there finds it done.
|
|
1052
|
+
bootstrap: NotRequired[str]
|
|
1035
1053
|
# In Docker, broker the key of the agent `layout` names (`OPENAI_API_KEY` for `codex`,
|
|
1036
|
-
# Cursor's when unset) on that agent's endpoints, as its adapter does
|
|
1037
|
-
#
|
|
1038
|
-
#
|
|
1039
|
-
#
|
|
1054
|
+
# Cursor's when unset) on that agent's endpoints, as its adapter does; OpenCode, Goose and
|
|
1055
|
+
# pi take their model's provider's key, so with their layouts it's `FAKE_AGENT_API_KEY`, on
|
|
1056
|
+
# no endpoint. The key stays on the host, and `exec` steps get a placeholder in its
|
|
1057
|
+
# variable, which the egress gateway swaps in on those endpoints when sent as
|
|
1058
|
+
# `Authorization: Bearer <placeholder>`, and refuses on any other request. For an agent
|
|
1059
|
+
# whose bridge is a server in the sandbox (Claude Code, OpenCode, Goose, fx, Grok Build), it
|
|
1060
|
+
# also serves on the session's first exposed port and reaches it from the host, as that
|
|
1061
|
+
# adapter's start does.
|
|
1040
1062
|
brokers: NotRequired[Literal[True]]
|
|
1063
|
+
# US dollars the fake agent says every turn cost, as a harness that reports its cost does; 0
|
|
1064
|
+
# reports none.
|
|
1065
|
+
costUsd: NotRequired[float]
|
|
1041
1066
|
# Simulated turn length, honors the abort signal.
|
|
1042
1067
|
delayMs: NotRequired[float]
|
|
1043
1068
|
# Requested reasoning effort, recorded as `effort` on the cell. Use `servedModel` for what
|
|
@@ -1084,7 +1109,8 @@ class FakeHarnessDescriptor(TypedDict):
|
|
|
1084
1109
|
# The fake agent's final message on every turn; default `Done.`.
|
|
1085
1110
|
text: NotRequired[str]
|
|
1086
1111
|
# Tool calls the fake agent reports on every turn, before writing files. `ok` defaults to
|
|
1087
|
-
# true; null reports a call whose result never came.
|
|
1112
|
+
# true; null reports a call whose result never came. `durationMs` defaults to 0; null
|
|
1113
|
+
# reports a call whose end the harness never said.
|
|
1088
1114
|
tools: NotRequired[list[FakeHarnessDescriptorToolsItem]]
|
|
1089
1115
|
# Each turn's recorded agent time, exactly, whatever the wall clock says: a test can compare
|
|
1090
1116
|
# agent time without scheduling jitter, which four runs a side can tell apart.
|
|
@@ -1149,7 +1175,8 @@ class FakeScriptStepRefuseKey(TypedDict):
|
|
|
1149
1175
|
# the command's stdout, `write` as file edits, and `reply` is the turn's final message. `mcp`
|
|
1150
1176
|
# (`'<server>/<tool>'`) starts the environment's stdio MCP server in the sandbox, as an agent
|
|
1151
1177
|
# would, and calls the tool with no arguments; it's reported as `mcp__<server>__<tool>`. `error`
|
|
1152
|
-
# ends the turn there with status `error` and that message, as a provider error would
|
|
1178
|
+
# ends the turn there with status `error` and that message, as a provider error would; one
|
|
1179
|
+
# worded as a provider's credit, quota or rate limit makes the attempt an infra error.
|
|
1153
1180
|
# `refuseKey` ends it as the model API rejecting the key in that variable would, which makes the
|
|
1154
1181
|
# attempt an infra error.
|
|
1155
1182
|
FakeScriptStep: TypeAlias = "FakeScriptStepExec | FakeScriptStepWrite | FakeScriptStepReply | FakeScriptStepMcp | FakeScriptStepError | FakeScriptStepRefuseKey"
|
|
@@ -1212,8 +1239,9 @@ class GitWorkspace(TypedDict):
|
|
|
1212
1239
|
url: str
|
|
1213
1240
|
|
|
1214
1241
|
|
|
1215
|
-
# Goose through `@reeval/harness-goose` (`goose acp`), made by `goose()`. It runs
|
|
1216
|
-
#
|
|
1242
|
+
# Goose through `@reeval/harness-goose` (`goose acp`), made by `goose()`. It runs a model on its
|
|
1243
|
+
# provider's key, and reads each turn's usage from Goose's `usage_ledger` (its ACP server counts
|
|
1244
|
+
# one call).
|
|
1217
1245
|
class GooseHarnessDescriptor(TypedDict):
|
|
1218
1246
|
# Reasoning effort as `GOOSE_THINKING_EFFORT`, e.g. `off`, `low`, `medium`, `high` or `max`.
|
|
1219
1247
|
effort: NotRequired[str]
|
|
@@ -1227,7 +1255,8 @@ class GooseHarnessDescriptor(TypedDict):
|
|
|
1227
1255
|
kind: Literal["goose"]
|
|
1228
1256
|
# The most Goose attempts at once, across the run, e.g. for the key's rate limits.
|
|
1229
1257
|
maxConcurrent: NotRequired[float]
|
|
1230
|
-
#
|
|
1258
|
+
# `<provider>/<model>`: Goose's `google`, `anthropic`, `openai` or `xai` provider on its own
|
|
1259
|
+
# key, or the gateway's id on `vercel()` and `openrouter()`, e.g. `google/gemini-3.8-flash`.
|
|
1231
1260
|
model: str
|
|
1232
1261
|
# How long the harness's session may take to become ready (its bootstrap and first session)
|
|
1233
1262
|
# before the attempt is an infra error, after one retry; default 90s.
|
|
@@ -1410,6 +1439,7 @@ class MatcherSubjectValue(TypedDict):
|
|
|
1410
1439
|
|
|
1411
1440
|
|
|
1412
1441
|
class MatcherSubjectExec(TypedDict):
|
|
1442
|
+
env: NotRequired[ExecEnv]
|
|
1413
1443
|
# A command reeval runs, for its `ExecResult`; again on each try when polled.
|
|
1414
1444
|
exec: str
|
|
1415
1445
|
# The command's `ExecResult` when the runner already ran it: reeval checks that instead of
|
|
@@ -1498,9 +1528,17 @@ class Pattern(TypedDict):
|
|
|
1498
1528
|
regexp: str
|
|
1499
1529
|
|
|
1500
1530
|
|
|
1501
|
-
#
|
|
1502
|
-
#
|
|
1503
|
-
#
|
|
1531
|
+
# An egress policy per phase of the attempt: `setup` covers its files and setup steps, `agent`
|
|
1532
|
+
# the harness's start, every turn and every check after them. A phase it leaves unset keeps the
|
|
1533
|
+
# policy it inherits.
|
|
1534
|
+
class PhasedEgress(TypedDict):
|
|
1535
|
+
agent: NotRequired[EgressPolicy]
|
|
1536
|
+
setup: NotRequired[EgressPolicy]
|
|
1537
|
+
|
|
1538
|
+
|
|
1539
|
+
# pi through `@reeval/harness-pi` (`pi --mode json` in the sandbox), made by `pi()`. It runs a
|
|
1540
|
+
# model on its provider's key and reports each model call's tokens. It takes stdio and HTTP MCP
|
|
1541
|
+
# servers, not SSE ones.
|
|
1504
1542
|
class PiHarnessDescriptor(TypedDict):
|
|
1505
1543
|
# Reasoning effort, passed as pi's `--thinking` (the CLI's name). Values are whatever that
|
|
1506
1544
|
# flag takes, e.g. `off`, `minimal`, `low`, `medium`, `high`, `xhigh` or `max`.
|
|
@@ -1514,7 +1552,9 @@ class PiHarnessDescriptor(TypedDict):
|
|
|
1514
1552
|
kind: Literal["pi"]
|
|
1515
1553
|
# The most pi attempts at once, across the run, e.g. for the key's rate limits.
|
|
1516
1554
|
maxConcurrent: NotRequired[float]
|
|
1517
|
-
#
|
|
1555
|
+
# `<provider>/<model>`: one of pi's providers whose key it sends in a header on a fixed
|
|
1556
|
+
# host, or the gateway's id on `vercel()` and `openrouter()`, e.g.
|
|
1557
|
+
# `google/gemini-3.8-flash`.
|
|
1518
1558
|
model: str
|
|
1519
1559
|
# How long the harness's session may take to become ready (its bootstrap and first session)
|
|
1520
1560
|
# before the attempt is an infra error, after one retry; default 90s.
|
|
@@ -1807,6 +1847,32 @@ class SnapshotOptions(TypedDict):
|
|
|
1807
1847
|
SubstituteIn: TypeAlias = "Literal[\"header\", \"query\", \"body\"]"
|
|
1808
1848
|
|
|
1809
1849
|
|
|
1850
|
+
class TartHostHost(TypedDict):
|
|
1851
|
+
# The host name, address or `~/.ssh/config` alias.
|
|
1852
|
+
host: str
|
|
1853
|
+
# The private key `ssh -i` takes: absolute, or `~/…`; the agent's or the config's when
|
|
1854
|
+
# unset.
|
|
1855
|
+
identityFile: NotRequired[str]
|
|
1856
|
+
# The SSH port; `ssh`'s own (the config's, or 22) when unset.
|
|
1857
|
+
port: NotRequired[float]
|
|
1858
|
+
# The login user; `ssh`'s own (the config's, or this machine's user) when unset.
|
|
1859
|
+
user: NotRequired[str]
|
|
1860
|
+
# The most of reeval's macOS VMs it runs at once: 1 or 2, and 2 when unset.
|
|
1861
|
+
vms: NotRequired[float]
|
|
1862
|
+
|
|
1863
|
+
|
|
1864
|
+
# A Mac that runs `tart()`'s VMs over SSH: an SSH destination, or its parts.
|
|
1865
|
+
TartHost: TypeAlias = "TartHostHost | str"
|
|
1866
|
+
|
|
1867
|
+
|
|
1868
|
+
class TartSandboxDescriptorHostsItemHost(TypedDict):
|
|
1869
|
+
host: str
|
|
1870
|
+
identityFile: NotRequired[str]
|
|
1871
|
+
port: NotRequired[int]
|
|
1872
|
+
user: NotRequired[str]
|
|
1873
|
+
vms: NotRequired[int]
|
|
1874
|
+
|
|
1875
|
+
|
|
1810
1876
|
# Reach the VM over SSH when its Tart Guest Agent doesn't answer `tart exec`: as `user` (`admin`
|
|
1811
1877
|
# when unset), with `key`, a private key the image trusts, absolute or relative to the file it's
|
|
1812
1878
|
# written in.
|
|
@@ -1819,6 +1885,13 @@ class TartSandboxDescriptorSsh(TypedDict):
|
|
|
1819
1885
|
class TartSandboxDescriptor(TypedDict):
|
|
1820
1886
|
# CPUs each clone gets; the image's when unset.
|
|
1821
1887
|
cpus: NotRequired[int]
|
|
1888
|
+
# Macs that run the VMs instead of this machine, each one plain `ssh` reaches without a
|
|
1889
|
+
# prompt (an `~/.ssh/config` alias, the agent or a key file; no passwords): `'mac-studio'`,
|
|
1890
|
+
# `'elliot@mac-mini.local'`, `'ssh://ci@10.0.0.5:2222'` or `{ host, user?, port?,
|
|
1891
|
+
# identityFile?, vms? }`. reeval runs `tart` on each over SSH and keeps the egress gateway,
|
|
1892
|
+
# and every key, here. Each host needs the image; preflight bakes the harness onto it there.
|
|
1893
|
+
# This machine when unset.
|
|
1894
|
+
hosts: NotRequired[list[str | TartSandboxDescriptorHostsItemHost]]
|
|
1822
1895
|
# Cell id; defaults to `tart:<image>`, the image's last path segment.
|
|
1823
1896
|
id: NotRequired[str]
|
|
1824
1897
|
# The VM each attempt clones: an OCI image such as
|
|
@@ -1860,6 +1933,9 @@ class TranscriptEventFileEdit(TypedDict):
|
|
|
1860
1933
|
# Line counts, or null when the harness didn't send the content (e.g. deletes).
|
|
1861
1934
|
added: float | None
|
|
1862
1935
|
atMs: float
|
|
1936
|
+
# Set when the harness never reported the call's end, so `durationMs` runs to the next
|
|
1937
|
+
# event's `atMs` (the turn's end for the last).
|
|
1938
|
+
durationInferred: NotRequired[Literal[True]]
|
|
1863
1939
|
durationMs: float | None
|
|
1864
1940
|
# `write` is a whole-file write whose result doesn't say whether the file existed before
|
|
1865
1941
|
# (Antigravity's, fx's, Goose's, Grok Build's and pi's write tools, for example).
|
|
@@ -1878,6 +1954,9 @@ class TranscriptEventFileEdit(TypedDict):
|
|
|
1878
1954
|
|
|
1879
1955
|
class TranscriptEventWebSearch(TypedDict):
|
|
1880
1956
|
atMs: float
|
|
1957
|
+
# Set when the harness never reported the call's end, so `durationMs` runs to the next
|
|
1958
|
+
# event's `atMs` (the turn's end for the last).
|
|
1959
|
+
durationInferred: NotRequired[Literal[True]]
|
|
1881
1960
|
durationMs: float | None
|
|
1882
1961
|
# Whether the search succeeded. Absent means it did; null means the harness never reported
|
|
1883
1962
|
# its result.
|
|
@@ -1897,6 +1976,9 @@ class TranscriptEventWebSearch(TypedDict):
|
|
|
1897
1976
|
|
|
1898
1977
|
class TranscriptEventWebFetch(TypedDict):
|
|
1899
1978
|
atMs: float
|
|
1979
|
+
# Set when the harness never reported the call's end, so `durationMs` runs to the next
|
|
1980
|
+
# event's `atMs` (the turn's end for the last).
|
|
1981
|
+
durationInferred: NotRequired[Literal[True]]
|
|
1900
1982
|
durationMs: float | None
|
|
1901
1983
|
# Whether the fetch succeeded; null when the harness never reported its result.
|
|
1902
1984
|
ok: bool | None
|
|
@@ -1911,13 +1993,33 @@ class TranscriptEventWebFetch(TypedDict):
|
|
|
1911
1993
|
url: str
|
|
1912
1994
|
|
|
1913
1995
|
|
|
1996
|
+
# Set when `output` is only part of the output, with a line where the rest was cut:
|
|
1997
|
+
# `transcript.jsonl` keeps the first 96K and last 16K characters of one past 128K (of its JSON,
|
|
1998
|
+
# for structured output), and the harness adapter keeps the first and last 512 KiB of a saved
|
|
1999
|
+
# output past 1 MiB. `bytes` is the whole output's size in UTF-8.
|
|
2000
|
+
class TranscriptEventToolOutputTruncated(TypedDict):
|
|
2001
|
+
bytes: float
|
|
2002
|
+
|
|
2003
|
+
|
|
1914
2004
|
class TranscriptEventTool(TypedDict):
|
|
1915
2005
|
atMs: float
|
|
2006
|
+
# Set when the harness never reported the call's end, so `durationMs` runs to the next
|
|
2007
|
+
# event's `atMs` (the turn's end for the last).
|
|
2008
|
+
durationInferred: NotRequired[Literal[True]]
|
|
1916
2009
|
durationMs: float | None
|
|
1917
2010
|
input: Any
|
|
1918
2011
|
# Whether the call succeeded; null when the harness never reported its result.
|
|
1919
2012
|
ok: bool | None
|
|
1920
2013
|
output: Any
|
|
2014
|
+
# Set when `output` is only part of the output, with a line where the rest was cut:
|
|
2015
|
+
# `transcript.jsonl` keeps the first 96K and last 16K characters of one past 128K (of its
|
|
2016
|
+
# JSON, for structured output), and the harness adapter keeps the first and last 512 KiB of
|
|
2017
|
+
# a saved output past 1 MiB. `bytes` is the whole output's size in UTF-8.
|
|
2018
|
+
outputTruncated: NotRequired[TranscriptEventToolOutputTruncated]
|
|
2019
|
+
# What `output` holds: `model`, the result as the harness gave it to the model; `full`, the
|
|
2020
|
+
# tool's whole output, which can be more than the model saw (the harness cut it for the
|
|
2021
|
+
# model, or saved it to a file and gave the model a pointer, which reeval read).
|
|
2022
|
+
outputView: NotRequired[Literal["model", "full"]]
|
|
1921
2023
|
# True when a shell-like tool or edit ran at least two minutes.
|
|
1922
2024
|
stalled: NotRequired[bool]
|
|
1923
2025
|
# The `toolCallId` of the subagent call whose agent made this call; absent for the agent's
|
|
@@ -1943,12 +2045,38 @@ class TranscriptEventRetry(TypedDict):
|
|
|
1943
2045
|
type: Literal["retry"]
|
|
1944
2046
|
|
|
1945
2047
|
|
|
2048
|
+
class TranscriptEventModelCall(TypedDict):
|
|
2049
|
+
atMs: float
|
|
2050
|
+
durationMs: float
|
|
2051
|
+
# Milliseconds from the call's start to its response body's first byte; null when none came.
|
|
2052
|
+
firstByteMs: float | None
|
|
2053
|
+
# The model that served it, from its request or response; null when neither named one.
|
|
2054
|
+
model: str | None
|
|
2055
|
+
# `POST api.anthropic.com/v1/messages`: the method, host and path.
|
|
2056
|
+
request: str
|
|
2057
|
+
# `main` for one of the agent's own steps, `side` for a call its CLI made around them: a
|
|
2058
|
+
# session title, a web search's own model call, Antigravity's Flash Lite calls. A call is
|
|
2059
|
+
# `main` when its tokens are one of the turn's steps' as the harness reported them.
|
|
2060
|
+
# Otherwise it's `side` when its request declared at most one tool while another call in the
|
|
2061
|
+
# attempt declared more, or when another model served it than served the turn's other calls,
|
|
2062
|
+
# and `main` when neither holds. Absent in records from before roles.
|
|
2063
|
+
role: NotRequired[Literal["main", "side"]]
|
|
2064
|
+
# The response's HTTP status; null when none came.
|
|
2065
|
+
status: float | None
|
|
2066
|
+
# Set on a call that carries the whole turn (Cursor's), so it isn't counted as model time.
|
|
2067
|
+
stream: NotRequired[Literal[True]]
|
|
2068
|
+
ts: str
|
|
2069
|
+
type: Literal["model-call"]
|
|
2070
|
+
# The tokens its response body named; null when it named none (Cursor's are protobuf).
|
|
2071
|
+
usage: TokenUsage | None
|
|
2072
|
+
|
|
2073
|
+
|
|
1946
2074
|
# Normalized agent events. Each tool call is one event, merged with its result; `durationMs` is
|
|
1947
2075
|
# wall time until the result arrived (Cursor's own `completed_at_ms` can be earlier). Null when
|
|
1948
2076
|
# the harness never reported the end. Long shell or edit calls set `stalled: true`. A call the
|
|
1949
2077
|
# harness never reported a result for (the turn ended or was cut short first) has `ok: null`: it
|
|
1950
2078
|
# isn't known to have failed, and no failure count includes it.
|
|
1951
|
-
TranscriptEvent: TypeAlias = "TranscriptEvent1 | TranscriptEventFileEdit | TranscriptEventWebSearch | TranscriptEventWebFetch | TranscriptEventTool | TranscriptEventError | TranscriptEventRetry"
|
|
2079
|
+
TranscriptEvent: TypeAlias = "TranscriptEvent1 | TranscriptEventFileEdit | TranscriptEventWebSearch | TranscriptEventWebFetch | TranscriptEventTool | TranscriptEventError | TranscriptEventRetry | TranscriptEventModelCall"
|
|
1952
2080
|
|
|
1953
2081
|
|
|
1954
2082
|
# A turn as data, as a record or another language's runner carries it: `Turn` without its
|
|
@@ -2041,17 +2169,22 @@ CAMEL_KEYS: frozenset[str] = frozenset(
|
|
|
2041
2169
|
"caseJson",
|
|
2042
2170
|
"costUsd",
|
|
2043
2171
|
"delayMs",
|
|
2172
|
+
"durationInferred",
|
|
2044
2173
|
"durationMs",
|
|
2045
2174
|
"exitCode",
|
|
2046
2175
|
"failWith",
|
|
2047
2176
|
"failedRequests",
|
|
2048
2177
|
"finalUrl",
|
|
2178
|
+
"firstByteMs",
|
|
2049
2179
|
"flakeRate",
|
|
2180
|
+
"identityFile",
|
|
2050
2181
|
"ignoreAbort",
|
|
2051
2182
|
"matchedBy",
|
|
2052
2183
|
"maxConcurrent",
|
|
2053
2184
|
"mediaType",
|
|
2054
2185
|
"minLift",
|
|
2186
|
+
"outputTruncated",
|
|
2187
|
+
"outputView",
|
|
2055
2188
|
"passRate",
|
|
2056
2189
|
"providerOptions",
|
|
2057
2190
|
"readFile",
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.21.0",
|
|
3
|
+
"binaries": {
|
|
4
|
+
"linux-x64": {
|
|
5
|
+
"name": "reeval-0.21.0-linux-x64",
|
|
6
|
+
"sha256": "7158242c4ceff60de608724d2bbb5122e498f83f2a5b4383bf668101675e6134",
|
|
7
|
+
"size": 88602080
|
|
8
|
+
},
|
|
9
|
+
"linux-arm64": {
|
|
10
|
+
"name": "reeval-0.21.0-linux-arm64",
|
|
11
|
+
"sha256": "5269396c1fd086a271466e6d8ad5241d21f6f6d10e7fa2f5620094db6dc813c7",
|
|
12
|
+
"size": 88590632
|
|
13
|
+
},
|
|
14
|
+
"linux-x64-musl": {
|
|
15
|
+
"name": "reeval-0.21.0-linux-x64-musl",
|
|
16
|
+
"sha256": "db73b9d1aa525d5fe65e8bcdede983c017c378d39229f31b9699398bfdb62af5",
|
|
17
|
+
"size": 82572848
|
|
18
|
+
},
|
|
19
|
+
"linux-arm64-musl": {
|
|
20
|
+
"name": "reeval-0.21.0-linux-arm64-musl",
|
|
21
|
+
"sha256": "670d26f762ba936020ac20ccf19b5f8a9fa63ec36cf5edb974a3adc6c51240a9",
|
|
22
|
+
"size": 81726672
|
|
23
|
+
},
|
|
24
|
+
"darwin-x64": {
|
|
25
|
+
"name": "reeval-0.21.0-darwin-x64",
|
|
26
|
+
"sha256": "5284f2530bd1bc9baf148b17cdbb0b0de281a4ceab2fdc5a48d7cb99c3f5d4a0",
|
|
27
|
+
"size": 76607760
|
|
28
|
+
},
|
|
29
|
+
"darwin-arm64": {
|
|
30
|
+
"name": "reeval-0.21.0-darwin-arm64",
|
|
31
|
+
"sha256": "d7c7b39687b277cbf4af307b7b058d66ff434774f72271e7c1c154b1e988baee",
|
|
32
|
+
"size": 69558258
|
|
33
|
+
},
|
|
34
|
+
"windows-x64": {
|
|
35
|
+
"name": "reeval-0.21.0-windows-x64.exe",
|
|
36
|
+
"sha256": "8c45aaa695b4c421389f0bd9e03f9205069a27981815076bc068209fe62858e4",
|
|
37
|
+
"size": 93378560
|
|
38
|
+
},
|
|
39
|
+
"linux-x64-baseline": {
|
|
40
|
+
"name": "reeval-0.21.0-linux-x64-baseline",
|
|
41
|
+
"sha256": "6420a663d6036bd46ef0c2d30e4eb263bd1773fa475c7414c1081a63096917ab",
|
|
42
|
+
"size": 88602080
|
|
43
|
+
},
|
|
44
|
+
"linux-x64-musl-baseline": {
|
|
45
|
+
"name": "reeval-0.21.0-linux-x64-musl-baseline",
|
|
46
|
+
"sha256": "c9cea461f397d82cf778873700e3f3b43fc622b78a0c17a3d2454cf509227c46",
|
|
47
|
+
"size": 82572848
|
|
48
|
+
},
|
|
49
|
+
"windows-x64-baseline": {
|
|
50
|
+
"name": "reeval-0.21.0-windows-x64-baseline.exe",
|
|
51
|
+
"sha256": "9506e9327498754ce060bd6254887e127c17e2f1738851578ce90d0a9ebd5370",
|
|
52
|
+
"size": 93378560
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -5,7 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
import asyncio
|
|
6
6
|
import base64
|
|
7
7
|
import inspect
|
|
8
|
-
from collections.abc import Awaitable, Callable, Coroutine
|
|
8
|
+
from collections.abc import Awaitable, Callable, Coroutine, Mapping
|
|
9
9
|
from contextvars import ContextVar
|
|
10
10
|
from datetime import timedelta
|
|
11
11
|
from typing import Any, Literal, NoReturn, Unpack, cast, overload
|
|
@@ -132,6 +132,37 @@ def _no_poll_retries(retries: int | None, interval: timedelta | float | None) ->
|
|
|
132
132
|
)
|
|
133
133
|
|
|
134
134
|
|
|
135
|
+
def _exec_env(env: Mapping[str, str] | None) -> dict[str, str] | None:
|
|
136
|
+
if env is None:
|
|
137
|
+
return None
|
|
138
|
+
if not isinstance(env, Mapping): # pyright: ignore[reportUnnecessaryIsInstance]
|
|
139
|
+
raise TypeError(
|
|
140
|
+
f"c.exec(env=…) takes a mapping of names to strings (got {type(env).__name__})"
|
|
141
|
+
)
|
|
142
|
+
out: dict[str, str] = {}
|
|
143
|
+
for name, value in env.items():
|
|
144
|
+
if not isinstance(name, str) or not isinstance(value, str): # pyright: ignore[reportUnnecessaryIsInstance]
|
|
145
|
+
raise TypeError(
|
|
146
|
+
f"c.exec(env=…) takes strings for names and values (got {name!r}: "
|
|
147
|
+
f"{type(value).__name__})"
|
|
148
|
+
)
|
|
149
|
+
out[name] = value
|
|
150
|
+
return out
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _described_exec(
|
|
154
|
+
command: str,
|
|
155
|
+
env: Mapping[str, str] | None,
|
|
156
|
+
retries: int | None,
|
|
157
|
+
interval: timedelta | float | None,
|
|
158
|
+
) -> Described:
|
|
159
|
+
_no_poll_retries(retries, interval)
|
|
160
|
+
variables = _exec_env(env)
|
|
161
|
+
return Described(
|
|
162
|
+
{"exec": command} if variables is None else {"exec": command, "env": variables}
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
|
|
135
166
|
PATTERN_ROUNDS = 5
|
|
136
167
|
|
|
137
168
|
|
|
@@ -161,11 +192,16 @@ class AttemptContext:
|
|
|
161
192
|
|
|
162
193
|
@overload
|
|
163
194
|
def exec(
|
|
164
|
-
self,
|
|
195
|
+
self,
|
|
196
|
+
command: str,
|
|
197
|
+
*,
|
|
198
|
+
env: Mapping[str, str] | None = None,
|
|
199
|
+
retries: int | None = None,
|
|
200
|
+
interval: timedelta | float | None = None,
|
|
165
201
|
) -> Coroutine[Any, Any, ExecResult]: ...
|
|
166
202
|
@overload
|
|
167
203
|
def exec(
|
|
168
|
-
self, command: str, *, background: Literal[True]
|
|
204
|
+
self, command: str, *, background: Literal[True], env: Mapping[str, str] | None = None
|
|
169
205
|
) -> Coroutine[Any, Any, BackgroundHandle]: ...
|
|
170
206
|
@overload
|
|
171
207
|
def exec(
|
|
@@ -173,6 +209,7 @@ class AttemptContext:
|
|
|
173
209
|
command: str,
|
|
174
210
|
*,
|
|
175
211
|
background: bool,
|
|
212
|
+
env: Mapping[str, str] | None = None,
|
|
176
213
|
retries: int | None = None,
|
|
177
214
|
interval: timedelta | float | None = None,
|
|
178
215
|
) -> Coroutine[Any, Any, ExecResult | BackgroundHandle]: ...
|
|
@@ -182,28 +219,34 @@ class AttemptContext:
|
|
|
182
219
|
command: str,
|
|
183
220
|
*,
|
|
184
221
|
background: bool = False,
|
|
222
|
+
env: Mapping[str, str] | None = None,
|
|
185
223
|
retries: int | None = None,
|
|
186
224
|
interval: timedelta | float | None = None,
|
|
187
225
|
) -> Coroutine[Any, Any, ExecResult | BackgroundHandle]:
|
|
188
|
-
"""Run a command in the sandbox; with `background=True`, leave it running.
|
|
189
|
-
`retries`, a non-zero exit runs it again, up to
|
|
190
|
-
apart (seconds or a timedelta, default 1 second), and
|
|
226
|
+
"""Run a command in the sandbox; with `background=True`, leave it running. `env` adds
|
|
227
|
+
variables for this command only. With `retries`, a non-zero exit runs it again, up to
|
|
228
|
+
that many extra times, `interval` apart (seconds or a timedelta, default 1 second), and
|
|
229
|
+
it returns the last try."""
|
|
191
230
|
if _describing.get() is not None and not background:
|
|
192
|
-
|
|
193
|
-
return cast(Any, Described({"exec": command}))
|
|
231
|
+
return cast(Any, _described_exec(command, env, retries, interval))
|
|
194
232
|
_not_describing("c.exec(…, background=True)")
|
|
195
|
-
return tracked(
|
|
233
|
+
return tracked(
|
|
234
|
+
self._exec(command, background, _exec_env(env), retries, interval), "c.exec()"
|
|
235
|
+
)
|
|
196
236
|
|
|
197
237
|
async def _exec(
|
|
198
238
|
self,
|
|
199
239
|
command: str,
|
|
200
240
|
background: bool,
|
|
241
|
+
env: dict[str, str] | None,
|
|
201
242
|
retries: int | None,
|
|
202
243
|
interval: timedelta | float | None,
|
|
203
244
|
) -> ExecResult | BackgroundHandle:
|
|
204
245
|
call: AttemptCallExec = {"op": "exec", "command": command}
|
|
205
246
|
if background:
|
|
206
247
|
call["background"] = True
|
|
248
|
+
if env is not None:
|
|
249
|
+
call["env"] = env
|
|
207
250
|
if retries is not None:
|
|
208
251
|
call["retries"] = retries
|
|
209
252
|
if interval is not None:
|
|
@@ -369,16 +412,24 @@ class SyncAttemptContext:
|
|
|
369
412
|
|
|
370
413
|
@overload
|
|
371
414
|
def exec(
|
|
372
|
-
self,
|
|
415
|
+
self,
|
|
416
|
+
command: str,
|
|
417
|
+
*,
|
|
418
|
+
env: Mapping[str, str] | None = None,
|
|
419
|
+
retries: int | None = None,
|
|
420
|
+
interval: timedelta | float | None = None,
|
|
373
421
|
) -> ExecResult: ...
|
|
374
422
|
@overload
|
|
375
|
-
def exec(
|
|
423
|
+
def exec(
|
|
424
|
+
self, command: str, *, background: Literal[True], env: Mapping[str, str] | None = None
|
|
425
|
+
) -> BackgroundHandle: ...
|
|
376
426
|
@overload
|
|
377
427
|
def exec(
|
|
378
428
|
self,
|
|
379
429
|
command: str,
|
|
380
430
|
*,
|
|
381
431
|
background: bool,
|
|
432
|
+
env: Mapping[str, str] | None = None,
|
|
382
433
|
retries: int | None = None,
|
|
383
434
|
interval: timedelta | float | None = None,
|
|
384
435
|
) -> ExecResult | BackgroundHandle: ...
|
|
@@ -388,18 +439,18 @@ class SyncAttemptContext:
|
|
|
388
439
|
command: str,
|
|
389
440
|
*,
|
|
390
441
|
background: bool = False,
|
|
442
|
+
env: Mapping[str, str] | None = None,
|
|
391
443
|
retries: int | None = None,
|
|
392
444
|
interval: timedelta | float | None = None,
|
|
393
445
|
) -> ExecResult | BackgroundHandle:
|
|
394
446
|
"""Run a command in the sandbox and wait for it; with `background=True`, leave it
|
|
395
|
-
running. With `retries`, a non-zero exit
|
|
396
|
-
`interval` apart (seconds or a timedelta,
|
|
397
|
-
try."""
|
|
447
|
+
running. `env` adds variables for this command only. With `retries`, a non-zero exit
|
|
448
|
+
runs it again, up to that many extra times, `interval` apart (seconds or a timedelta,
|
|
449
|
+
default 1 second), and it returns the last try."""
|
|
398
450
|
if _describing.get() is not None and not background:
|
|
399
|
-
|
|
400
|
-
return cast(Any, Described({"exec": command}))
|
|
451
|
+
return cast(Any, _described_exec(command, env, retries, interval))
|
|
401
452
|
_not_describing("c.exec(…, background=True)")
|
|
402
|
-
return self._run(self._ctx._exec(command, background, retries, interval)) # pyright: ignore[reportPrivateUsage]
|
|
453
|
+
return self._run(self._ctx._exec(command, background, _exec_env(env), retries, interval)) # pyright: ignore[reportPrivateUsage]
|
|
403
454
|
|
|
404
455
|
def read_file(self, path: str) -> str | None:
|
|
405
456
|
"""A file's contents in the sandbox, or `None` when there's no such file."""
|