newmeasure-cli 0.2.1__tar.gz → 0.4.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.
- newmeasure_cli-0.4.0/.gitignore +15 -0
- newmeasure_cli-0.4.0/PKG-INFO +312 -0
- newmeasure_cli-0.4.0/README.md +301 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/api_client.py +2 -1
- newmeasure_cli-0.4.0/cli/commands/edit_run.py +237 -0
- newmeasure_cli-0.4.0/cli/commands/edit_task.py +73 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/config.py +7 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/main.py +97 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/pyproject.toml +1 -1
- newmeasure_cli-0.2.1/.gitignore +0 -18
- newmeasure_cli-0.2.1/PKG-INFO +0 -145
- newmeasure_cli-0.2.1/README.md +0 -134
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/__init__.py +0 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/commands/__init__.py +0 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/commands/admin.py +0 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/commands/artifacts.py +0 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/commands/login.py +0 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/commands/result.py +0 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/commands/run.py +0 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/commands/runs.py +0 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/commands/tasks.py +0 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/commands/upload.py +0 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/errors.py +0 -0
- {newmeasure_cli-0.2.1 → newmeasure_cli-0.4.0}/cli/progress.py +0 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: newmeasure-cli
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: NewMeasure eval CLI
|
|
5
|
+
Requires-Python: >=3.11
|
|
6
|
+
Requires-Dist: httpx>=0.28
|
|
7
|
+
Requires-Dist: python-dotenv>=1.0
|
|
8
|
+
Requires-Dist: rich>=13.0
|
|
9
|
+
Requires-Dist: typer>=0.16
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
<!-- prettier-ignore -->
|
|
13
|
+
<div align="center">
|
|
14
|
+
|
|
15
|
+
# NewMeasure CLI
|
|
16
|
+
|
|
17
|
+
*Upload eval tasks, start cloud runs, and download results with `newm`*
|
|
18
|
+
|
|
19
|
+
[Install](#install) • [Usage](#usage) • [Browser tasks](#browser-tasks) • [Edit tasks](#edit-tasks) • [Edit runs in CI](#edit-runs-in-ci) • [Commands](#commands) • [Development](#development)
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
`newm` lets you upload tasks, run evals, inspect results and download artifacts from your terminal. Requires Python 3.11 or later and an execution API token for your installation.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
uv tool install newmeasure-cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Sign in with your execution API token:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
newm login
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The default API is `https://api.newmeasure.cc`. Configuration is stored in `~/.newm/config.json` with owner-only permissions. If you self-host, update `api_url` and `evals_url` there before logging in; see the [deployment guide](../deploy/handover/README.md#point-your-cli-at-your-installation).
|
|
40
|
+
|
|
41
|
+
Run a task:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Upload and run a local task directory
|
|
45
|
+
newm run ./my-task --no-wait
|
|
46
|
+
|
|
47
|
+
# Or run an already uploaded task, several times
|
|
48
|
+
newm run t_abc123 --n-trials 5 --no-wait
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`--no-wait` returns the run ID immediately; the run continues in the cloud. Without it, the CLI waits for completion. Check status with:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
newm result <run-id>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
> [!NOTE]
|
|
58
|
+
> Task IDs persist across uploads (the first upload writes `task_id` into `task.toml`). Each execution gets a fresh trial ID.
|
|
59
|
+
|
|
60
|
+
## Preview environments and saved logins
|
|
61
|
+
|
|
62
|
+
In the app, open **Manage logins** from the Run dialog to create a personal CLI token, then:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
newm login --evals
|
|
66
|
+
newm logins
|
|
67
|
+
newm run t_abc123 --url https://my-branch.solstice.co --n-trials 3
|
|
68
|
+
newm run tasks/ --url https://my-branch.solstice.co --login "Preview team"
|
|
69
|
+
newm run t_abc123 --prompt-credentials --save-login "My preview"
|
|
70
|
+
# Add --share-login to make the saved login available to your organization.
|
|
71
|
+
newm run t_abc123 --from-run e_previous --login "My preview"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The personal CLI token supplements your execution API token (`newm login`), identifying whose saved
|
|
75
|
+
logins to use. Tokens expire after 90 days and can be revoked from Manage logins. Omit `--login`
|
|
76
|
+
to use the default product login configured for your organization. Saved logins are personal unless shared; `newm logins` shows who
|
|
77
|
+
saved each one. Passwords are prompted privately and never accepted as command arguments.
|
|
78
|
+
|
|
79
|
+
Trials are limited to **1–5 per task** in both the app and CLI. Every launch creates a separate
|
|
80
|
+
entry on Runs. `--from-run` links the original and inherits its environment unless `--url` is set;
|
|
81
|
+
it does not reuse the original login. Without either option the task's staging URL is used.
|
|
82
|
+
Solstice previews must use HTTPS on a subdomain of `solstice.co`, without user info, query strings
|
|
83
|
+
or fragments. The override applies only to the prepared run, never to your task files.
|
|
84
|
+
|
|
85
|
+
## Browser tasks
|
|
86
|
+
|
|
87
|
+
Browser tasks test a web product: an AI agent uses it in a cloud browser. Put the application login in a local env file, using the field names the task declares in `credential_fields`:
|
|
88
|
+
|
|
89
|
+
```dotenv
|
|
90
|
+
username=YOUR_APPLICATION_EMAIL
|
|
91
|
+
password=YOUR_APPLICATION_PASSWORD
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Keep that file out of version control, and submit it with the run:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
newm run ./my-task --credentials-file credentials.env --no-wait
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Only the declared fields are sent, over HTTPS (plain HTTP is allowed for `localhost`). Cloud and model credentials are configured on the platform, not passed with each run.
|
|
101
|
+
|
|
102
|
+
Download a trial's artifacts using the trial ID from `newm result`:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
newm artifacts <run-id> <trial-id> --output ./artifacts/<trial-id>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Downloads include `outputs/` (the files the product generated, such as PDF and HTML exports), `score.json` (the reward and per-check breakdown), and `manifest.json`. The CLI checks each file's size and SHA-256.
|
|
109
|
+
|
|
110
|
+
A browser task bundle contains `task.toml`, `instruction.md`, and, when present, `scenario.yaml`, `product.md` (or `../../shared/product.md`), and the `environment/` and `tests/` folders.
|
|
111
|
+
|
|
112
|
+
## Edit tasks
|
|
113
|
+
|
|
114
|
+
Turn a Solstice edit session into an Edit-suite task in the app. This uses the personal CLI token
|
|
115
|
+
from `newm login --evals`. Pass the session's `operation_id` or its asset URL
|
|
116
|
+
(`https://<tenant>.solstice.co/home/assets/<operation_id>`):
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# List the operation's turns, with their surface, whether starting HTML is ready, and the request
|
|
120
|
+
newm edit-task 0b7f2a7e-1111-4222-8333-444455556666
|
|
121
|
+
|
|
122
|
+
# Create a task from turn 2 (a turn number or turn ID)
|
|
123
|
+
newm edit-task 0b7f2a7e-1111-4222-8333-444455556666 --turn 2
|
|
124
|
+
|
|
125
|
+
# Merge consecutive turns into one task, with your own title
|
|
126
|
+
newm edit-task https://acme.solstice.co/home/assets/0b7f2a7e-1111-4222-8333-444455556666 \
|
|
127
|
+
-t 2 -t 3 --title "Swap headline and CTA"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The task's checks and title are drafted from the chosen turns; refine them in the app's Edits tab.
|
|
131
|
+
Turns listed as `awaiting` have no starting HTML yet: the task is created, but stays
|
|
132
|
+
`awaiting_html` until the HTML is imported.
|
|
133
|
+
|
|
134
|
+
## Edit runs in CI
|
|
135
|
+
|
|
136
|
+
`newm edit-run` runs the Edit suite against a version of your edit agent, such as a pull request's
|
|
137
|
+
preview deployment, waits for the score, and exits non-zero when the run fails or scores too low.
|
|
138
|
+
Use it to gate a PR on the edit eval.
|
|
139
|
+
|
|
140
|
+
### Set up (once)
|
|
141
|
+
|
|
142
|
+
1. **Allow your preview domain.** The evals service signs in to the build under test with your
|
|
143
|
+
organization's default login (or a saved login), and only ever sends those credentials to
|
|
144
|
+
allowed domains. An org admin opens the evals app → **Run logins** → **Allowed domains** and
|
|
145
|
+
adds the preview host pattern, e.g. `*.d6watob7ilhym.amplifyapp.com` for Amplify previews of
|
|
146
|
+
one app. Entries are hostnames or a leading `*.` wildcard with at least two labels after it;
|
|
147
|
+
shared-hosting wildcards such as `*.amplifyapp.com`, `*.vercel.app` or
|
|
148
|
+
`*.us-east-1.awsapprunner.com` (the label under the wildcard must be your own app or account
|
|
149
|
+
ID), IPs and internal names are refused. The login password itself is only ever sent to
|
|
150
|
+
Solstice's identity provider, never to the preview. `*.solsticehealth.co` and your default environment are always allowed, and hosts
|
|
151
|
+
your organization's edit and design runs sent the default or a saved login to in the last 180
|
|
152
|
+
days were added when this setting shipped, so existing runs keep working.
|
|
153
|
+
2. **Create a CLI token.** In the app, open **Run logins** (or **Manage logins** from the Run
|
|
154
|
+
dialog) and create a personal CLI token. Runs started with it are attributed to you and can use
|
|
155
|
+
your saved logins and those shared with the org. Tokens expire after 90 days.
|
|
156
|
+
3. **Store it as a CI secret**, e.g. a GitHub Actions secret named `NEWM_EVALS_TOKEN`.
|
|
157
|
+
4. **Add the workflow** below. It runs when a preview deployment succeeds, installs the CLI from PyPI,
|
|
158
|
+
runs the edit eval against the preview URL, and fails the check when the score
|
|
159
|
+
is under `--min-score`.
|
|
160
|
+
|
|
161
|
+
Try it locally first:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
uv tool install "newmeasure-cli>=0.4.0"
|
|
165
|
+
export NEWM_EVALS_TOKEN=... # your CLI token
|
|
166
|
+
newm edit-run --url https://pr-42.d6watob7ilhym.amplifyapp.com -t <task-id> --min-score 0.8
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Options
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
newm edit-run --url https://pr-42.d6watob7ilhym.amplifyapp.com \
|
|
173
|
+
--build-ref "$GITHUB_SHA" --min-score 0.8 --json
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
- `--url`: the app URL of the build under test. The evals service signs in there and reads the API
|
|
177
|
+
base and tenant from that app's runtime config, so the preview's own edit agent API is used.
|
|
178
|
+
Omit it to use the organization's default environment. The same URL rules as `newm run --url` apply
|
|
179
|
+
(HTTPS, no user info, query, fragment or port). With the organization's default login or a saved
|
|
180
|
+
login, the host must also be on the organization's allowed domains, so shared credentials only
|
|
181
|
+
go to your apps. `*.solsticehealth.co` and your default environment are always allowed; an admin
|
|
182
|
+
adds preview domains in the evals app under Run logins → Allowed domains (for example
|
|
183
|
+
`*.d6watob7ilhym.amplifyapp.com`; a bare `*.amplifyapp.com` is refused) before CI can target
|
|
184
|
+
them. The check runs when the run starts and again when it signs in.
|
|
185
|
+
- `--build-ref`: a label for the build (git SHA, PR number), shown with the run on Runs.
|
|
186
|
+
- `--preview-stack`: a Solstice preview stack name (letters, digits, `.`, `_`, `-`), sent as
|
|
187
|
+
`X-Preview-Stack` on the run's Solstice API calls. See [Preview stacks](#preview-stacks).
|
|
188
|
+
- `--expect-build`: a commit SHA prefix. Exit 1 unless every finished task's `agent_build` (the
|
|
189
|
+
commit of the agent build that ran it) starts with it. Failed tasks that never reached the
|
|
190
|
+
agent are skipped, but at least one task must report a build. Needs the wait (no `--no-wait`).
|
|
191
|
+
- `--task`/`-t`, `--kind`, `--group`: which ready edit tasks to run (default: all of them).
|
|
192
|
+
- `--login`: a saved login (name or ID) for the preview; default: your organization's.
|
|
193
|
+
`--n-trials` (1–5) and `--from-run` work as with `newm run`.
|
|
194
|
+
- `--min-score`: fail (exit 1) when the score (0–1) is below it. A run that mixes task kinds has
|
|
195
|
+
no single score in the app; the gate then uses the mean task score.
|
|
196
|
+
- `--json`: print one JSON object on stdout (`eval_id`, `status`, `score`, `min_score`, `passed`,
|
|
197
|
+
`reason`, `build_ref`, `target_url`, `preview_stack`, `expect_build`, `results_url` and per-task
|
|
198
|
+
`task_id`, `title`, `status`, `score`, `error` — why the task stopped, worded as on the run page —
|
|
199
|
+
and `agent_build`, the commit of the agent build that ran it, `""` when unknown); progress goes
|
|
200
|
+
to stderr.
|
|
201
|
+
- `--timeout`: minutes to wait (default 180) before exiting 1; the run itself keeps going.
|
|
202
|
+
`--no-wait` prints the run ID and returns.
|
|
203
|
+
|
|
204
|
+
Exit codes: `0` passed; `1` the run failed or was stopped, scored below `--min-score`, didn't
|
|
205
|
+
run the `--expect-build` agent, timed out, or a request failed; `2` invalid options.
|
|
206
|
+
|
|
207
|
+
### GitHub Actions
|
|
208
|
+
|
|
209
|
+
In CI, set the personal CLI token (from **Manage logins**) as `NEWM_EVALS_TOKEN` instead of running
|
|
210
|
+
`newm login --evals`; `NEWM_EVALS_URL` likewise overrides `evals_url`. For example, in GitHub Actions:
|
|
211
|
+
|
|
212
|
+
```yaml
|
|
213
|
+
# .github/workflows/edit-eval.yml
|
|
214
|
+
on:
|
|
215
|
+
deployment_status:
|
|
216
|
+
jobs:
|
|
217
|
+
edit-eval:
|
|
218
|
+
if: github.event.deployment_status.state == 'success'
|
|
219
|
+
runs-on: ubuntu-latest
|
|
220
|
+
steps:
|
|
221
|
+
- uses: astral-sh/setup-uv@v6
|
|
222
|
+
# Installs `newm` from this repository (needs read access to it; or use a published release).
|
|
223
|
+
- run: uv tool install "newmeasure-cli>=0.4.0"
|
|
224
|
+
- name: Run the edit eval against the preview
|
|
225
|
+
env:
|
|
226
|
+
NEWM_EVALS_TOKEN: ${{ secrets.NEWM_EVALS_TOKEN }}
|
|
227
|
+
run: |
|
|
228
|
+
newm edit-run \
|
|
229
|
+
--url "${{ github.event.deployment_status.environment_url }}" \
|
|
230
|
+
--build-ref "${{ github.event.deployment.sha }}" \
|
|
231
|
+
--min-score 0.8 --json > edit-eval.json
|
|
232
|
+
- if: always()
|
|
233
|
+
uses: actions/upload-artifact@v4
|
|
234
|
+
with:
|
|
235
|
+
name: edit-eval
|
|
236
|
+
path: edit-eval.json
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Personal CLI tokens expire after 90 days; rotate the secret when you renew it.
|
|
240
|
+
|
|
241
|
+
### Preview stacks
|
|
242
|
+
|
|
243
|
+
Pick the option that matches what the pull request changes:
|
|
244
|
+
|
|
245
|
+
- `--url`: the PR deploys its own **website** (e.g. an Amplify preview of the app). The run signs
|
|
246
|
+
in there and uses whatever API that app's runtime config points at.
|
|
247
|
+
- `--preview-stack`: the PR changes the **agents** (e.g. Solstice-AI PR CI, which deploys the PR's
|
|
248
|
+
agents as a named preview stack). The run uses the Solstice dev app and API (`--url` set to
|
|
249
|
+
the dev app, or your organization's default environment if that is dev) and sends
|
|
250
|
+
`X-Preview-Stack: <stack>` on its Solstice API calls only, never on the app or sign-in pages, so
|
|
251
|
+
Solstice's dev API runs the agent sessions on that PR's stack.
|
|
252
|
+
|
|
253
|
+
Solstice's dev API honors the header only for users it lists for preview stacks and silently
|
|
254
|
+
ignores it for everyone else. The run's login (your organization's default, or `--login`) must be
|
|
255
|
+
one of those users. Pass `--expect-build` with the PR's head SHA so a run that fell back to the
|
|
256
|
+
regular agents fails instead of passing: each task reports `agent_build`, the commit of the agent
|
|
257
|
+
build that actually ran it.
|
|
258
|
+
|
|
259
|
+
```yaml
|
|
260
|
+
# In Solstice-AI's PR workflow, after the preview stack is deployed
|
|
261
|
+
- uses: astral-sh/setup-uv@v6
|
|
262
|
+
- run: uv tool install "newmeasure-cli>=0.4.0"
|
|
263
|
+
- name: Run the edit eval on the PR's preview stack
|
|
264
|
+
env:
|
|
265
|
+
NEWM_EVALS_TOKEN: ${{ secrets.NEWM_EVALS_TOKEN }}
|
|
266
|
+
run: |
|
|
267
|
+
newm edit-run \
|
|
268
|
+
--url "${{ vars.SOLSTICE_DEV_APP_URL }}" \
|
|
269
|
+
--preview-stack "pr-${{ github.event.pull_request.number }}" \
|
|
270
|
+
--expect-build "${{ github.event.pull_request.head.sha }}" \
|
|
271
|
+
--build-ref "Solstice-AI PR ${{ github.event.pull_request.number }}" \
|
|
272
|
+
--login "Preview stack eval user" \
|
|
273
|
+
--min-score 0.8 --json > edit-eval.json
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Troubleshooting
|
|
277
|
+
|
|
278
|
+
- `Target host ... is not in this organization's allowed hosts`: add the preview domain under
|
|
279
|
+
**Run logins → Allowed domains** (step 1).
|
|
280
|
+
- `is not a publicly routable address`: the URL points at a private or internal host; use the
|
|
281
|
+
public preview URL.
|
|
282
|
+
- The run fails at sign-in: the login page redirected to a host that isn't allowed, or the login's
|
|
283
|
+
credentials don't work on that preview. Check the run on **Runs** via `results_url`.
|
|
284
|
+
- Exit `1` with `reason` in `--json` output says why: failed, stopped, below the threshold, or
|
|
285
|
+
timed out (the run keeps going; see it on Runs).
|
|
286
|
+
|
|
287
|
+
## Commands
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
newm login # store API token
|
|
291
|
+
newm upload ./my-task # validate and upload a task
|
|
292
|
+
newm run <task-id | dir> # run an eval
|
|
293
|
+
newm result <run-id> # run details and trial results
|
|
294
|
+
newm artifacts <run-id> <trial-id> [--output DIR]
|
|
295
|
+
newm tasks # list uploaded tasks
|
|
296
|
+
newm runs [<task-id>] # list runs
|
|
297
|
+
newm edit-task <operation> [-t <turn> ...] # list turns or create an edit task
|
|
298
|
+
newm edit-run [--url URL] [--min-score X] [--json] # run the Edit suite, gate on its score
|
|
299
|
+
newm logins # list saved logins
|
|
300
|
+
newm harbor ... # pass through to the Harbor CLI
|
|
301
|
+
newm --help
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Development
|
|
305
|
+
|
|
306
|
+
From this directory:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
uv sync --frozen
|
|
310
|
+
uv run newm --help
|
|
311
|
+
uv run pytest
|
|
312
|
+
```
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
<!-- prettier-ignore -->
|
|
2
|
+
<div align="center">
|
|
3
|
+
|
|
4
|
+
# NewMeasure CLI
|
|
5
|
+
|
|
6
|
+
*Upload eval tasks, start cloud runs, and download results with `newm`*
|
|
7
|
+
|
|
8
|
+
[Install](#install) • [Usage](#usage) • [Browser tasks](#browser-tasks) • [Edit tasks](#edit-tasks) • [Edit runs in CI](#edit-runs-in-ci) • [Commands](#commands) • [Development](#development)
|
|
9
|
+
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
`newm` lets you upload tasks, run evals, inspect results and download artifacts from your terminal. Requires Python 3.11 or later and an execution API token for your installation.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
uv tool install newmeasure-cli
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Sign in with your execution API token:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
newm login
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The default API is `https://api.newmeasure.cc`. Configuration is stored in `~/.newm/config.json` with owner-only permissions. If you self-host, update `api_url` and `evals_url` there before logging in; see the [deployment guide](../deploy/handover/README.md#point-your-cli-at-your-installation).
|
|
29
|
+
|
|
30
|
+
Run a task:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Upload and run a local task directory
|
|
34
|
+
newm run ./my-task --no-wait
|
|
35
|
+
|
|
36
|
+
# Or run an already uploaded task, several times
|
|
37
|
+
newm run t_abc123 --n-trials 5 --no-wait
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`--no-wait` returns the run ID immediately; the run continues in the cloud. Without it, the CLI waits for completion. Check status with:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
newm result <run-id>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> [!NOTE]
|
|
47
|
+
> Task IDs persist across uploads (the first upload writes `task_id` into `task.toml`). Each execution gets a fresh trial ID.
|
|
48
|
+
|
|
49
|
+
## Preview environments and saved logins
|
|
50
|
+
|
|
51
|
+
In the app, open **Manage logins** from the Run dialog to create a personal CLI token, then:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
newm login --evals
|
|
55
|
+
newm logins
|
|
56
|
+
newm run t_abc123 --url https://my-branch.solstice.co --n-trials 3
|
|
57
|
+
newm run tasks/ --url https://my-branch.solstice.co --login "Preview team"
|
|
58
|
+
newm run t_abc123 --prompt-credentials --save-login "My preview"
|
|
59
|
+
# Add --share-login to make the saved login available to your organization.
|
|
60
|
+
newm run t_abc123 --from-run e_previous --login "My preview"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The personal CLI token supplements your execution API token (`newm login`), identifying whose saved
|
|
64
|
+
logins to use. Tokens expire after 90 days and can be revoked from Manage logins. Omit `--login`
|
|
65
|
+
to use the default product login configured for your organization. Saved logins are personal unless shared; `newm logins` shows who
|
|
66
|
+
saved each one. Passwords are prompted privately and never accepted as command arguments.
|
|
67
|
+
|
|
68
|
+
Trials are limited to **1–5 per task** in both the app and CLI. Every launch creates a separate
|
|
69
|
+
entry on Runs. `--from-run` links the original and inherits its environment unless `--url` is set;
|
|
70
|
+
it does not reuse the original login. Without either option the task's staging URL is used.
|
|
71
|
+
Solstice previews must use HTTPS on a subdomain of `solstice.co`, without user info, query strings
|
|
72
|
+
or fragments. The override applies only to the prepared run, never to your task files.
|
|
73
|
+
|
|
74
|
+
## Browser tasks
|
|
75
|
+
|
|
76
|
+
Browser tasks test a web product: an AI agent uses it in a cloud browser. Put the application login in a local env file, using the field names the task declares in `credential_fields`:
|
|
77
|
+
|
|
78
|
+
```dotenv
|
|
79
|
+
username=YOUR_APPLICATION_EMAIL
|
|
80
|
+
password=YOUR_APPLICATION_PASSWORD
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Keep that file out of version control, and submit it with the run:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
newm run ./my-task --credentials-file credentials.env --no-wait
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Only the declared fields are sent, over HTTPS (plain HTTP is allowed for `localhost`). Cloud and model credentials are configured on the platform, not passed with each run.
|
|
90
|
+
|
|
91
|
+
Download a trial's artifacts using the trial ID from `newm result`:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
newm artifacts <run-id> <trial-id> --output ./artifacts/<trial-id>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Downloads include `outputs/` (the files the product generated, such as PDF and HTML exports), `score.json` (the reward and per-check breakdown), and `manifest.json`. The CLI checks each file's size and SHA-256.
|
|
98
|
+
|
|
99
|
+
A browser task bundle contains `task.toml`, `instruction.md`, and, when present, `scenario.yaml`, `product.md` (or `../../shared/product.md`), and the `environment/` and `tests/` folders.
|
|
100
|
+
|
|
101
|
+
## Edit tasks
|
|
102
|
+
|
|
103
|
+
Turn a Solstice edit session into an Edit-suite task in the app. This uses the personal CLI token
|
|
104
|
+
from `newm login --evals`. Pass the session's `operation_id` or its asset URL
|
|
105
|
+
(`https://<tenant>.solstice.co/home/assets/<operation_id>`):
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# List the operation's turns, with their surface, whether starting HTML is ready, and the request
|
|
109
|
+
newm edit-task 0b7f2a7e-1111-4222-8333-444455556666
|
|
110
|
+
|
|
111
|
+
# Create a task from turn 2 (a turn number or turn ID)
|
|
112
|
+
newm edit-task 0b7f2a7e-1111-4222-8333-444455556666 --turn 2
|
|
113
|
+
|
|
114
|
+
# Merge consecutive turns into one task, with your own title
|
|
115
|
+
newm edit-task https://acme.solstice.co/home/assets/0b7f2a7e-1111-4222-8333-444455556666 \
|
|
116
|
+
-t 2 -t 3 --title "Swap headline and CTA"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The task's checks and title are drafted from the chosen turns; refine them in the app's Edits tab.
|
|
120
|
+
Turns listed as `awaiting` have no starting HTML yet: the task is created, but stays
|
|
121
|
+
`awaiting_html` until the HTML is imported.
|
|
122
|
+
|
|
123
|
+
## Edit runs in CI
|
|
124
|
+
|
|
125
|
+
`newm edit-run` runs the Edit suite against a version of your edit agent, such as a pull request's
|
|
126
|
+
preview deployment, waits for the score, and exits non-zero when the run fails or scores too low.
|
|
127
|
+
Use it to gate a PR on the edit eval.
|
|
128
|
+
|
|
129
|
+
### Set up (once)
|
|
130
|
+
|
|
131
|
+
1. **Allow your preview domain.** The evals service signs in to the build under test with your
|
|
132
|
+
organization's default login (or a saved login), and only ever sends those credentials to
|
|
133
|
+
allowed domains. An org admin opens the evals app → **Run logins** → **Allowed domains** and
|
|
134
|
+
adds the preview host pattern, e.g. `*.d6watob7ilhym.amplifyapp.com` for Amplify previews of
|
|
135
|
+
one app. Entries are hostnames or a leading `*.` wildcard with at least two labels after it;
|
|
136
|
+
shared-hosting wildcards such as `*.amplifyapp.com`, `*.vercel.app` or
|
|
137
|
+
`*.us-east-1.awsapprunner.com` (the label under the wildcard must be your own app or account
|
|
138
|
+
ID), IPs and internal names are refused. The login password itself is only ever sent to
|
|
139
|
+
Solstice's identity provider, never to the preview. `*.solsticehealth.co` and your default environment are always allowed, and hosts
|
|
140
|
+
your organization's edit and design runs sent the default or a saved login to in the last 180
|
|
141
|
+
days were added when this setting shipped, so existing runs keep working.
|
|
142
|
+
2. **Create a CLI token.** In the app, open **Run logins** (or **Manage logins** from the Run
|
|
143
|
+
dialog) and create a personal CLI token. Runs started with it are attributed to you and can use
|
|
144
|
+
your saved logins and those shared with the org. Tokens expire after 90 days.
|
|
145
|
+
3. **Store it as a CI secret**, e.g. a GitHub Actions secret named `NEWM_EVALS_TOKEN`.
|
|
146
|
+
4. **Add the workflow** below. It runs when a preview deployment succeeds, installs the CLI from PyPI,
|
|
147
|
+
runs the edit eval against the preview URL, and fails the check when the score
|
|
148
|
+
is under `--min-score`.
|
|
149
|
+
|
|
150
|
+
Try it locally first:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
uv tool install "newmeasure-cli>=0.4.0"
|
|
154
|
+
export NEWM_EVALS_TOKEN=... # your CLI token
|
|
155
|
+
newm edit-run --url https://pr-42.d6watob7ilhym.amplifyapp.com -t <task-id> --min-score 0.8
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Options
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
newm edit-run --url https://pr-42.d6watob7ilhym.amplifyapp.com \
|
|
162
|
+
--build-ref "$GITHUB_SHA" --min-score 0.8 --json
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- `--url`: the app URL of the build under test. The evals service signs in there and reads the API
|
|
166
|
+
base and tenant from that app's runtime config, so the preview's own edit agent API is used.
|
|
167
|
+
Omit it to use the organization's default environment. The same URL rules as `newm run --url` apply
|
|
168
|
+
(HTTPS, no user info, query, fragment or port). With the organization's default login or a saved
|
|
169
|
+
login, the host must also be on the organization's allowed domains, so shared credentials only
|
|
170
|
+
go to your apps. `*.solsticehealth.co` and your default environment are always allowed; an admin
|
|
171
|
+
adds preview domains in the evals app under Run logins → Allowed domains (for example
|
|
172
|
+
`*.d6watob7ilhym.amplifyapp.com`; a bare `*.amplifyapp.com` is refused) before CI can target
|
|
173
|
+
them. The check runs when the run starts and again when it signs in.
|
|
174
|
+
- `--build-ref`: a label for the build (git SHA, PR number), shown with the run on Runs.
|
|
175
|
+
- `--preview-stack`: a Solstice preview stack name (letters, digits, `.`, `_`, `-`), sent as
|
|
176
|
+
`X-Preview-Stack` on the run's Solstice API calls. See [Preview stacks](#preview-stacks).
|
|
177
|
+
- `--expect-build`: a commit SHA prefix. Exit 1 unless every finished task's `agent_build` (the
|
|
178
|
+
commit of the agent build that ran it) starts with it. Failed tasks that never reached the
|
|
179
|
+
agent are skipped, but at least one task must report a build. Needs the wait (no `--no-wait`).
|
|
180
|
+
- `--task`/`-t`, `--kind`, `--group`: which ready edit tasks to run (default: all of them).
|
|
181
|
+
- `--login`: a saved login (name or ID) for the preview; default: your organization's.
|
|
182
|
+
`--n-trials` (1–5) and `--from-run` work as with `newm run`.
|
|
183
|
+
- `--min-score`: fail (exit 1) when the score (0–1) is below it. A run that mixes task kinds has
|
|
184
|
+
no single score in the app; the gate then uses the mean task score.
|
|
185
|
+
- `--json`: print one JSON object on stdout (`eval_id`, `status`, `score`, `min_score`, `passed`,
|
|
186
|
+
`reason`, `build_ref`, `target_url`, `preview_stack`, `expect_build`, `results_url` and per-task
|
|
187
|
+
`task_id`, `title`, `status`, `score`, `error` — why the task stopped, worded as on the run page —
|
|
188
|
+
and `agent_build`, the commit of the agent build that ran it, `""` when unknown); progress goes
|
|
189
|
+
to stderr.
|
|
190
|
+
- `--timeout`: minutes to wait (default 180) before exiting 1; the run itself keeps going.
|
|
191
|
+
`--no-wait` prints the run ID and returns.
|
|
192
|
+
|
|
193
|
+
Exit codes: `0` passed; `1` the run failed or was stopped, scored below `--min-score`, didn't
|
|
194
|
+
run the `--expect-build` agent, timed out, or a request failed; `2` invalid options.
|
|
195
|
+
|
|
196
|
+
### GitHub Actions
|
|
197
|
+
|
|
198
|
+
In CI, set the personal CLI token (from **Manage logins**) as `NEWM_EVALS_TOKEN` instead of running
|
|
199
|
+
`newm login --evals`; `NEWM_EVALS_URL` likewise overrides `evals_url`. For example, in GitHub Actions:
|
|
200
|
+
|
|
201
|
+
```yaml
|
|
202
|
+
# .github/workflows/edit-eval.yml
|
|
203
|
+
on:
|
|
204
|
+
deployment_status:
|
|
205
|
+
jobs:
|
|
206
|
+
edit-eval:
|
|
207
|
+
if: github.event.deployment_status.state == 'success'
|
|
208
|
+
runs-on: ubuntu-latest
|
|
209
|
+
steps:
|
|
210
|
+
- uses: astral-sh/setup-uv@v6
|
|
211
|
+
# Installs `newm` from this repository (needs read access to it; or use a published release).
|
|
212
|
+
- run: uv tool install "newmeasure-cli>=0.4.0"
|
|
213
|
+
- name: Run the edit eval against the preview
|
|
214
|
+
env:
|
|
215
|
+
NEWM_EVALS_TOKEN: ${{ secrets.NEWM_EVALS_TOKEN }}
|
|
216
|
+
run: |
|
|
217
|
+
newm edit-run \
|
|
218
|
+
--url "${{ github.event.deployment_status.environment_url }}" \
|
|
219
|
+
--build-ref "${{ github.event.deployment.sha }}" \
|
|
220
|
+
--min-score 0.8 --json > edit-eval.json
|
|
221
|
+
- if: always()
|
|
222
|
+
uses: actions/upload-artifact@v4
|
|
223
|
+
with:
|
|
224
|
+
name: edit-eval
|
|
225
|
+
path: edit-eval.json
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Personal CLI tokens expire after 90 days; rotate the secret when you renew it.
|
|
229
|
+
|
|
230
|
+
### Preview stacks
|
|
231
|
+
|
|
232
|
+
Pick the option that matches what the pull request changes:
|
|
233
|
+
|
|
234
|
+
- `--url`: the PR deploys its own **website** (e.g. an Amplify preview of the app). The run signs
|
|
235
|
+
in there and uses whatever API that app's runtime config points at.
|
|
236
|
+
- `--preview-stack`: the PR changes the **agents** (e.g. Solstice-AI PR CI, which deploys the PR's
|
|
237
|
+
agents as a named preview stack). The run uses the Solstice dev app and API (`--url` set to
|
|
238
|
+
the dev app, or your organization's default environment if that is dev) and sends
|
|
239
|
+
`X-Preview-Stack: <stack>` on its Solstice API calls only, never on the app or sign-in pages, so
|
|
240
|
+
Solstice's dev API runs the agent sessions on that PR's stack.
|
|
241
|
+
|
|
242
|
+
Solstice's dev API honors the header only for users it lists for preview stacks and silently
|
|
243
|
+
ignores it for everyone else. The run's login (your organization's default, or `--login`) must be
|
|
244
|
+
one of those users. Pass `--expect-build` with the PR's head SHA so a run that fell back to the
|
|
245
|
+
regular agents fails instead of passing: each task reports `agent_build`, the commit of the agent
|
|
246
|
+
build that actually ran it.
|
|
247
|
+
|
|
248
|
+
```yaml
|
|
249
|
+
# In Solstice-AI's PR workflow, after the preview stack is deployed
|
|
250
|
+
- uses: astral-sh/setup-uv@v6
|
|
251
|
+
- run: uv tool install "newmeasure-cli>=0.4.0"
|
|
252
|
+
- name: Run the edit eval on the PR's preview stack
|
|
253
|
+
env:
|
|
254
|
+
NEWM_EVALS_TOKEN: ${{ secrets.NEWM_EVALS_TOKEN }}
|
|
255
|
+
run: |
|
|
256
|
+
newm edit-run \
|
|
257
|
+
--url "${{ vars.SOLSTICE_DEV_APP_URL }}" \
|
|
258
|
+
--preview-stack "pr-${{ github.event.pull_request.number }}" \
|
|
259
|
+
--expect-build "${{ github.event.pull_request.head.sha }}" \
|
|
260
|
+
--build-ref "Solstice-AI PR ${{ github.event.pull_request.number }}" \
|
|
261
|
+
--login "Preview stack eval user" \
|
|
262
|
+
--min-score 0.8 --json > edit-eval.json
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Troubleshooting
|
|
266
|
+
|
|
267
|
+
- `Target host ... is not in this organization's allowed hosts`: add the preview domain under
|
|
268
|
+
**Run logins → Allowed domains** (step 1).
|
|
269
|
+
- `is not a publicly routable address`: the URL points at a private or internal host; use the
|
|
270
|
+
public preview URL.
|
|
271
|
+
- The run fails at sign-in: the login page redirected to a host that isn't allowed, or the login's
|
|
272
|
+
credentials don't work on that preview. Check the run on **Runs** via `results_url`.
|
|
273
|
+
- Exit `1` with `reason` in `--json` output says why: failed, stopped, below the threshold, or
|
|
274
|
+
timed out (the run keeps going; see it on Runs).
|
|
275
|
+
|
|
276
|
+
## Commands
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
newm login # store API token
|
|
280
|
+
newm upload ./my-task # validate and upload a task
|
|
281
|
+
newm run <task-id | dir> # run an eval
|
|
282
|
+
newm result <run-id> # run details and trial results
|
|
283
|
+
newm artifacts <run-id> <trial-id> [--output DIR]
|
|
284
|
+
newm tasks # list uploaded tasks
|
|
285
|
+
newm runs [<task-id>] # list runs
|
|
286
|
+
newm edit-task <operation> [-t <turn> ...] # list turns or create an edit task
|
|
287
|
+
newm edit-run [--url URL] [--min-score X] [--json] # run the Edit suite, gate on its score
|
|
288
|
+
newm logins # list saved logins
|
|
289
|
+
newm harbor ... # pass through to the Harbor CLI
|
|
290
|
+
newm --help
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## Development
|
|
294
|
+
|
|
295
|
+
From this directory:
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
uv sync --frozen
|
|
299
|
+
uv run newm --help
|
|
300
|
+
uv run pytest
|
|
301
|
+
```
|
|
@@ -23,7 +23,8 @@ def evals_client() -> httpx.Client:
|
|
|
23
23
|
token = get("evals_token")
|
|
24
24
|
if not token:
|
|
25
25
|
raise typer.BadParameter(
|
|
26
|
-
"Connect your app account with newm login --evals
|
|
26
|
+
"Connect your app account with newm login --evals, or set NEWM_EVALS_TOKEN "
|
|
27
|
+
"(create a token at /settings/runs in the app)"
|
|
27
28
|
)
|
|
28
29
|
url = get("evals_url")
|
|
29
30
|
from urllib.parse import urlsplit
|