eve 0.7.2 → 0.7.4

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/docs/public/evals/cases.mdx +1 -2
  3. package/dist/docs/public/evals/judge.mdx +1 -1
  4. package/dist/docs/public/evals/overview.mdx +2 -2
  5. package/dist/docs/public/evals/running.mdx +4 -9
  6. package/dist/docs/public/evals/targets.mdx +4 -23
  7. package/dist/src/cli/dev/tui/blocks.js +7 -7
  8. package/dist/src/cli/dev/tui/terminal-renderer.js +5 -5
  9. package/dist/src/cli/dev/tui/terminal-text.d.ts +1 -0
  10. package/dist/src/cli/dev/tui/terminal-text.js +1 -1
  11. package/dist/src/cli/dev/tui/tool-format.d.ts +1 -1
  12. package/dist/src/cli/dev/tui/tool-format.js +2 -2
  13. package/dist/src/cli/run.d.ts +0 -2
  14. package/dist/src/cli/run.js +1 -1
  15. package/dist/src/cli/ui/output.d.ts +1 -0
  16. package/dist/src/cli/ui/output.js +8 -8
  17. package/dist/src/client/types.d.ts +0 -1
  18. package/dist/src/context/providers/session.js +1 -1
  19. package/dist/src/evals/cli/eval.d.ts +0 -2
  20. package/dist/src/evals/cli/eval.js +1 -1
  21. package/dist/src/evals/define-eval.d.ts +1 -1
  22. package/dist/src/evals/define-eval.js +1 -1
  23. package/dist/src/evals/index.d.ts +1 -2
  24. package/dist/src/evals/index.js +1 -1
  25. package/dist/src/evals/runner/artifacts.js +1 -1
  26. package/dist/src/evals/runner/execute-eval.d.ts +2 -3
  27. package/dist/src/evals/runner/execute-eval.js +1 -1
  28. package/dist/src/evals/runner/execute-task.d.ts +1 -2
  29. package/dist/src/evals/runner/execute-task.js +1 -1
  30. package/dist/src/evals/runner/reporters/console.js +1 -1
  31. package/dist/src/evals/runner/reporters/junit.js +3 -4
  32. package/dist/src/evals/runner/run-evals.d.ts +0 -1
  33. package/dist/src/evals/runner/run-evals.js +1 -1
  34. package/dist/src/evals/target.d.ts +1 -6
  35. package/dist/src/evals/target.js +1 -1
  36. package/dist/src/evals/types.d.ts +2 -18
  37. package/dist/src/execution/durable-session-store.js +1 -1
  38. package/dist/src/execution/node-step.js +1 -1
  39. package/dist/src/execution/sandbox/grep-tool.js +1 -1
  40. package/dist/src/execution/workflow-steps.js +1 -1
  41. package/dist/src/harness/step-hooks.js +1 -1
  42. package/dist/src/harness/tool-loop.js +1 -1
  43. package/dist/src/internal/application/package.js +1 -1
  44. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
  45. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +0 -1
  46. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  47. package/dist/src/runtime/agent/mock-model-adapter.d.ts +3 -6
  48. package/dist/src/runtime/agent/mock-model-adapter.js +2 -2
  49. package/dist/src/runtime/agent/resolve-model.d.ts +2 -2
  50. package/dist/src/runtime/agent/resolve-model.js +1 -1
  51. package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
  52. package/dist/src/setup/scaffold/create/project.js +2 -2
  53. package/dist/src/setup/scaffold/update/channels.js +1 -1
  54. package/package.json +1 -1
  55. package/dist/src/evals/requirements.d.ts +0 -3
  56. package/dist/src/evals/requirements.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # eve
2
2
 
3
+ ## 0.7.4
4
+
5
+ ### Patch Changes
6
+
7
+ - a751461: fix(eve): fix vulnerabilities flagged by deepsec
8
+
9
+ ## 0.7.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 20aa34f: Remove the eval mock-model surface and the `requires` field. `eve eval` no
14
+ longer accepts `--mock-models` or `--no-skips`, `defineEval` no longer accepts
15
+ `requires`, and the `skipped` verdict, `EveEvalRequirement`, and
16
+ `EveEvalRequirementError` exports are gone. Evals now always run against a live
17
+ model target (local dev server or `--url`); `dispatchSchedule()` enforces dev
18
+ routes directly from the target capability. The deterministic mock-model
19
+ adapter remains internal to the test tiers (active only under `NODE_ENV=test`).
20
+
3
21
  ## 0.7.2
4
22
 
5
23
  ### Patch Changes
@@ -76,7 +76,6 @@ import { defineEval } from "eve/evals";
76
76
  import { includes } from "eve/evals/expect";
77
77
 
78
78
  export default defineEval({
79
- requires: ["mockModels"],
80
79
  async test(t) {
81
80
  await t.send("My favorite word is marigold.");
82
81
  const firstSessionId = t.sessionId;
@@ -108,7 +107,7 @@ Each `send` (and `respond`/`respondAll`) resolves to a turn whose `expectOk()` t
108
107
 
109
108
  Events from every session are captured in the result and artifacts. `t.log(message)` records debug lines into the eval artifact; `--verbose` also streams them to stdout as evals run. `t.signal` is an `AbortSignal` that fires on timeout.
110
109
 
111
- For driving sessions created outside the eval — by a channel webhook or a schedule — see [Targets and requirements](./targets).
110
+ For driving sessions created outside the eval — by a channel webhook or a schedule — see [Targets](./targets).
112
111
 
113
112
  ## Datasets: exporting an array
114
113
 
@@ -91,4 +91,4 @@ A **string model id** (e.g. `"anthropic/claude-opus-4.8"`) routes through the Ve
91
91
 
92
92
  - [Assertions](./assertions): deterministic run-level and value assertions
93
93
  - [Reporters](./reporters): ship judged scores to Braintrust experiments
94
- - [Targets and requirements](./targets): gating judge-backed evals on credentials
94
+ - [Targets](./targets): local vs remote targets for judge-backed evals
@@ -40,7 +40,7 @@ export default defineEval({
40
40
  });
41
41
  ```
42
42
 
43
- `test` is the only required field. The rest are optional: `description`, `requires`, `judge`, `tags`, `metadata`, `timeoutMs`, `reporters`. The init template adds `evals/**/*.ts` to `tsconfig.json`, so your eval code type-checks alongside the app.
43
+ `test` is the only required field. The rest are optional: `description`, `judge`, `tags`, `metadata`, `timeoutMs`, `reporters`. The init template adds `evals/**/*.ts` to `tsconfig.json`, so your eval code type-checks alongside the app.
44
44
 
45
45
  ## `evals.config.ts`
46
46
 
@@ -108,7 +108,7 @@ The rest of this section covers each piece:
108
108
  - [Cases](./cases): single-turn evals, scripted multi-turn evals, and dataset fan-out
109
109
  - [Assertions](./assertions): run-level methods and `t.check` value assertions, with matchers and severity
110
110
  - [Judge](./judge): LLM-as-judge grading and the judge model
111
- - [Targets and requirements](./targets): local vs remote targets, and gating evals on capabilities
111
+ - [Targets](./targets): local vs remote targets for the same eval files
112
112
  - [Reporters](./reporters): Braintrust experiments and JUnit XML
113
113
  - [Running evals](./running): the `eve eval` CLI, exit codes, and artifacts
114
114
 
@@ -9,10 +9,8 @@ description: "The eve eval CLI: flags, filters, exit codes, artifacts, and how t
9
9
  eve eval # run all discovered evals locally
10
10
  eve eval weather smoke # run selected evals (an id, or a directory prefix)
11
11
  eve eval --url https://<app> # target a remote app instead of a local host
12
- eve eval --mock-models # local dev target uses deterministic mock models
13
12
  eve eval --tag fast # only evals carrying a tag
14
13
  eve eval --strict # soft below-threshold assertions also fail the exit code
15
- eve eval --no-skips # unmet requirements fail instead of skipping
16
14
  eve eval --timeout 60000 # per-eval timeout in milliseconds
17
15
  eve eval --max-concurrency 4 # cap concurrent eval executions (default 8)
18
16
  eve eval --junit .eve/junit.xml # write JUnit XML
@@ -32,25 +30,22 @@ Positional ids match exactly or by directory prefix: `eve eval weather` runs `ev
32
30
  | `1` | Any eval failed — a failed gate, an execution error, or a strict threshold miss |
33
31
  | `2` | Configuration error |
34
32
 
35
- Unmet [requirements](./targets) skip visibly without affecting the exit code unless you pass `--no-skips`.
36
-
37
33
  ## Artifacts
38
34
 
39
35
  Each run drops artifacts under `.eve/evals/<timestamp>/`: a run `summary.json`, a `results.jsonl` index, and per-eval assertion results, verdicts, captured event streams, and `t.log` lines under `evals/`. The console output stays tight on purpose; when an eval fails, the artifact has the full story.
40
36
 
41
37
  ## CI
42
38
 
43
- A solid CI invocation is strict, deterministic, and machine-reportable:
39
+ A solid CI invocation is strict and machine-reportable:
44
40
 
45
41
  ```bash
46
- eve eval --strict --mock-models --junit .eve/junit.xml
42
+ eve eval --strict --junit .eve/junit.xml
47
43
  ```
48
44
 
49
45
  - `--strict` turns soft threshold misses into failures, so score regressions block the merge.
50
- - `--mock-models` keeps the default leg deterministic and credential-free. Put real-model evals in their own files gated on `requires: ["env:..."]`, and add `--no-skips` on legs that must prove those ran.
51
46
  - `--junit` gives the CI provider per-eval annotations; upload the `.eve/evals/` directory as a failure artifact for the full event streams.
52
47
 
53
- Against a deployed app, swap `--mock-models` for `--url`:
48
+ Evals run against a live model, so the CI environment must provide the model-provider credentials. Against a deployed app, add `--url`:
54
49
 
55
50
  ```bash
56
51
  eve eval --strict --url "$DEPLOY_URL" --junit .eve/junit.xml
@@ -58,6 +53,6 @@ eve eval --strict --url "$DEPLOY_URL" --junit .eve/junit.xml
58
53
 
59
54
  ## What to read next
60
55
 
61
- - [Targets and requirements](./targets): what `--url`, `--mock-models`, and `--no-skips` interact with
56
+ - [Targets](./targets): what `--url` interacts with
62
57
  - [Reporters](./reporters): Braintrust and JUnit output
63
58
  - [CLI reference](../reference/cli): the rest of the `eve` CLI
@@ -1,6 +1,6 @@
1
1
  ---
2
- title: "Targets and Requirements"
3
- description: "Point evals at a local dev server or a deployment, and gate evals on target capabilities with requires."
2
+ title: "Targets"
3
+ description: "Point evals at a local dev server or a deployment with the same eval files."
4
4
  ---
5
5
 
6
6
  An eval target is always an HTTP URL. `eve eval` starts a local dev server, while `eve eval --url <url>` runs against an existing server or deployment — the same eval files work for both, which is what makes evals usable as end-to-end tests in CI.
@@ -13,7 +13,6 @@ The runner polls `/eve/v1/health`, verifies `/eve/v1/info`, and exposes the live
13
13
  import { defineEval } from "eve/evals";
14
14
 
15
15
  export default defineEval({
16
- requires: ["mockModels", "devRoutes"],
17
16
  async test(t) {
18
17
  const { sessionIds } = await t.target.dispatchSchedule("heartbeat");
19
18
  await t.target.attachSession(sessionIds[0]!);
@@ -24,31 +23,13 @@ export default defineEval({
24
23
  ```
25
24
 
26
25
  - `t.target.fetch(path, init)` performs an authenticated fetch against the target — useful for channel and webhook ingress.
27
- - `t.target.dispatchSchedule(id)` triggers a [schedule](../schedules) through the dev-only schedule route and returns the session ids it created. It requires the `devRoutes` capability.
26
+ - `t.target.dispatchSchedule(id)` triggers a [schedule](../schedules) through the dev-only schedule route and returns the session ids it created. It works only against a target with dev routes enabled (the local `eve eval` dev server, or a deployment running in development mode), and throws otherwise.
28
27
  - `t.target.attachSession(sessionId, { startIndex? })` consumes one turn from a session created outside the eval — by a channel or a schedule — so its events feed the run-level assertions.
29
28
 
30
29
  Sessions attached this way are full `EveEvalSession`s: you can keep driving them with `send` and read their event streams. The run-level assertions on `t` (`t.completed()`, `t.calledTool(...)`) read the whole run, attached sessions included.
31
30
 
32
- ## Requirements
33
-
34
- Use `requires` to declare assumptions the runner verifies before executing an eval:
35
-
36
- | Requirement | Means |
37
- | -------------- | --------------------------------------------------------------------- |
38
- | `"mockModels"` | `/eve/v1/info` reports the deterministic mock model adapter is active |
39
- | `"devRoutes"` | `/eve/v1/info` reports dev-only routes are mounted |
40
- | `"env:NAME"` | The eval process has environment variable `NAME` set |
41
-
42
- Unmet requirements produce a visible `skipped` verdict and do not affect the exit code. Pass `--no-skips` when a CI leg must prove full coverage.
43
-
44
- ## Mock models
45
-
46
- Deterministic evals — the kind you want in CI — should not depend on a live model. `eve eval --mock-models` starts the local dev server with deterministic authored models, and `requires: ["mockModels"]` makes the dependency explicit so the eval skips instead of flaking anywhere else.
47
-
48
- `--mock-models` is invalid with `--url` because remote target capabilities are discovered, not set by the runner. For evals that genuinely need a real model — judging nuanced behavior, exercising provider-side tools — gate them on credentials instead (`requires: ["env:AI_GATEWAY_API_KEY"]`) and keep them in their own eval files so a tag filter can select or exclude them.
49
-
50
31
  ## What to read next
51
32
 
52
- - [Running evals](./running): `--url`, `--mock-models`, and `--no-skips` in practice
33
+ - [Running evals](./running): `--url` and the rest of the CLI in practice
53
34
  - [Schedules](../schedules): the surface `dispatchSchedule` drives
54
35
  - [Channels](../channels/overview): ingress you can exercise with `target.fetch`
@@ -1,7 +1,7 @@
1
- import{formatValuePretty,truncate}from"./tool-format.js";import{sliceVisible,visibleLength,wrapVisibleLine}from"./terminal-text.js";import{renderMarkdown}from"./markdown.js";import{isPromptControlCommand}from"./prompt-commands.js";function renderBlockLines(e,t,n,i){let a=nestingPrefix(e.depth??0,n);return renderBody(e,Math.max(8,t-visibleLength(a)),n,i).map(e=>`${a}${e}`)}function nestingPrefix(e,t){return e<=0?``:`${t.colors.orange(t.glyph.rule)} `.repeat(e)}function renderBody(e,t,n,r){switch(e.kind){case`user`:return renderUser(e,t,n);case`assistant`:case`subagent-step`:return renderProse(e,t,n);case`reasoning`:return renderReasoning(e,t,n);case`tool`:case`subagent-tool`:return renderTool(e,t,n,r);case`error`:return renderError(e,t,n);case`notice`:return renderNotice(e,t,n);case`warning`:return renderWarning(e,t,n);case`result`:return renderResult(e,t,n);case`flow`:return renderFlow(e,t,n);case`command`:return renderCommand(e,n);case`question`:case`connection-auth`:return renderPreformatted(e,t,n);case`log`:return renderLog(e,t,n,r);case`subagent`:return renderSubagentHeader(e,t,n);case`agent-header`:return(e.body??``).split(`
2
- `)}}function renderUser(e,t,n){let r=n.colors.cyan(n.glyph.user);return wrap(e.body??``,t-2).map(e=>`${r} ${e}`)}function renderProse(e,t,n){let r=[],o=e.kind===`subagent-step`,s=o?``:`${n.colors.bold(n.colors.white(n.glyph.brand))} `,c=o?``:` `;e.reasoning&&e.reasoning.trim().length>0&&r.push(...renderReasoningLines(e.reasoning,t,n));let l=(e.body??``).trim();return l.length===0&&r.length===0?[`${s}${n.colors.dim(`thinking${n.glyph.ellipsis}`)}`]:(l.length>0&&renderMarkdown(l).split(`
3
- `).flatMap(e=>wrapVisibleLine(e,t-c.length)).forEach((e,t)=>{t===0&&!o&&r.length===0?r.push(`${s}${e}`):r.push(`${c}${e}`)}),r.length>0?r:[`${s}`])}function renderReasoning(e,t,n){return e.collapsed?[`${n.colors.gray(n.glyph.reasoning)} ${n.colors.dim(`thinking`)}`]:renderReasoningLines(e.body??``,t,n,n.glyph.reasoning)}function renderReasoningLines(e,t,n,r){let i=r?2:0,a=wrap(e.trim(),t-i);return a.length===0?[]:a.map((e,t)=>`${r?t===0?`${n.colors.gray(r)} `:` `:``}${n.colors.dim(n.colors.italic(e))}`)}function renderTool(e,n,r,i){let{icon:a,accent:o}=toolGlyph(e.status??`running`,r,i),s=e.title??`tool`,c=n-2,l=truncatePlain(s,c),u=`${a} ${r.colors.bold(l)}`,d=c-l.length-2,f=e.subtitle??``;f.length>0&&d>=6&&(u+=` ${r.colors.gray(truncate(f,d))}`);let p=[u];return e.expanded?p.push(...renderToolExpanded(e,n,r)):e.status===`done`&&e.result&&e.result.length>0?p.push(resultLine(r.glyph.arrow,e.result,n,r,o)):e.status===`error`&&e.result?p.push(resultLine(r.glyph.arrow,e.result,n,r,r.colors.red)):e.status===`denied`&&p.push(resultLine(r.glyph.arrow,`denied`,n,r,r.colors.yellow)),p}function renderToolExpanded(t,n,r){let i=[],push=(t,a,o)=>{if(a!==void 0){i.push(` ${r.colors.dim(t)}`);for(let t of wrap(formatValuePretty(a),n-4))i.push(` ${o(t)}`)}};return push(`input`,t.toolInput,r.colors.gray),t.status===`error`&&t.result?push(`error`,t.result,r.colors.red):push(`output`,t.toolOutput,r.colors.gray),i}function resultLine(e,n,r,i,a){let o=r-4;return` ${i.colors.dim(e)} ${a(truncate(n,o))}`}function toolGlyph(e,t,n){switch(e){case`done`:return{icon:t.colors.green(t.glyph.success),accent:t.colors.gray};case`error`:return{icon:t.colors.red(t.glyph.error),accent:t.colors.red};case`denied`:return{icon:t.colors.yellow(t.glyph.warning),accent:t.colors.yellow};case`approval`:return{icon:t.colors.yellow(t.glyph.question),accent:t.colors.yellow};default:return{icon:t.colors.yellow(n.spinner),accent:t.colors.gray}}}function renderError(e,t,n){let r=n.colors.red(n.colors.bold(n.glyph.error)),i=e.title??`Error`,a=[`${r} ${n.colors.red(n.colors.bold(i))}`];for(let r of wrap(e.body??``,t-2))a.push(` ${colorizeError(r,n)}`);return a.push(...renderErrorDetail(e.detail,t,n)),a}function renderErrorDetail(e,t,n){if(e===void 0||e.trim().length===0)return[];let r=e.split(`
4
- `),i=r.slice(0,12),a=i.map(e=>` ${n.colors.dim(truncatePlain(e,Math.max(1,t-2)))}`),o=r.length-i.length;return o>0&&a.push(` ${n.colors.dim(`${n.glyph.ellipsis} +${o} more line${o===1?``:`s`}`)}`),a}const URL_PATTERN=/(https?:\/\/\S+)/u;function colorizeError(e,t){return URL_PATTERN.test(e)?e.split(URL_PATTERN).map((e,n)=>n%2==1?t.colors.cyan(e):t.colors.red(e)).join(``):t.colors.red(e)}function renderNotice(e,t,n){let r=n.colors.dim(n.glyph.dot),i=wrap(e.body??``,t-2);return i.length===0?[r]:i.map(e=>`${r} ${n.colors.dim(e)}`)}function renderWarning(e,t,n){let r=n.colors.yellow(n.glyph.warning);return wrap(e.body??``,t-2).map((e,t)=>`${t===0?r:` `} ${paintCommands(e,n)}`)}function paintCommands(e,t){return e.replace(/\/[a-z-]+/g,e=>isPromptControlCommand(e)?t.colors.blue(e):e)}function renderCommand(e,t){let n=t.colors;return[`${n.cyan(t.glyph.user)} ${n.blue(e.body??``)}`]}function renderFlow(e,t,n){let r=n.colors,i=e.title??`info`,a=i===`success`?r.green(n.glyph.success):i===`warning`?r.yellow(n.glyph.warning):i===`error`?r.red(n.glyph.error):r.dim(n.glyph.dot),o=wrap(e.body??``,t-2),paint=e=>i===`info`?r.dim(e):e;return o.map((e,t)=>`${t===0?a:` `} ${paint(e)}`)}function renderResult(e,t,n){let r=n.colors.dim(n.glyph.elbow),i=wrap(e.body??``,t-7);return i.length===0?[` ${r}`]:i.map((e,t)=>t===0?` ${r} ${n.colors.dim(e)}`:` ${n.colors.dim(e)}`)}function renderPreformatted(e,t,n){let r=e.kind===`connection-auth`?n.colors.yellow(n.glyph.connection):n.colors.yellow(n.colors.bold(n.glyph.question)),a=e.title??``,o=[`${r} ${n.colors.bold(a)}`];for(let n of(e.body??``).split(`
5
- `))for(let e of wrapVisibleLine(n,t-2))o.push(` ${e}`);return o}function renderLog(e,t,n,a){let o=e.title===`stderr`,s=o?n.colors.red:n.colors.gray,c=n.colors.dim(n.glyph.rule),l=o?`stderr`:`stdout`,u=n.colors.dim(`${l} ${n.glyph.dot} `),d=visibleLength(u),f=` `.repeat(d),p=a.previous?.kind===`log`&&a.previous.title===e.title,m=(e.body??``).split(`
6
- `),h=[];for(let e of m){let r=wrapVisibleLine(e,Math.max(1,t-2-d));for(let e of r){let t=h.length===0&&!p?u:f;h.push(`${c} ${t}${n.colors.dim(s(e))}`)}}return h.length>0?h:[`${c}`]}function renderSubagentHeader(e,t,n){let r=truncatePlain(e.title??`subagent`,Math.max(8,t-14));return[`${n.colors.orange(n.glyph.subagent)} ${n.colors.bold(r)} ${n.colors.dim(`subagent`)}`]}function wrap(e,t){return e.trim().length===0?[]:e.split(`
7
- `).flatMap(e=>wrapVisibleLine(e,Math.max(1,t)))}function truncatePlain(e,t){return visibleLength(e)<=t?e:sliceVisible(e,t)}export{renderBlockLines};
1
+ import{sliceVisible,visibleLength,wrapVisibleLine}from"./terminal-text.js";import{formatValuePretty,truncate}from"./tool-format.js";import{renderMarkdown}from"./markdown.js";import{isPromptControlCommand}from"./prompt-commands.js";function renderBlockLines(e,n,r,i){let a=nestingPrefix(e.depth??0,r);return renderBody(e,Math.max(8,n-visibleLength(a)),r,i).map(e=>`${a}${e}`)}function nestingPrefix(e,t){return e<=0?``:`${t.colors.orange(t.glyph.rule)} `.repeat(e)}function renderBody(e,t,n,r){switch(e.kind){case`user`:return renderUser(e,t,n);case`assistant`:case`subagent-step`:return renderProse(e,t,n);case`reasoning`:return renderReasoning(e,t,n);case`tool`:case`subagent-tool`:return renderTool(e,t,n,r);case`error`:return renderError(e,t,n);case`notice`:return renderNotice(e,t,n);case`warning`:return renderWarning(e,t,n);case`result`:return renderResult(e,t,n);case`flow`:return renderFlow(e,t,n);case`command`:return renderCommand(e,n);case`question`:case`connection-auth`:return renderPreformatted(e,t,n);case`log`:return renderLog(e,t,n,r);case`subagent`:return renderSubagentHeader(e,t,n);case`agent-header`:return(e.body??``).split(`
2
+ `)}}function renderUser(e,t,n){let r=n.colors.cyan(n.glyph.user);return wrap(e.body??``,t-2).map(e=>`${r} ${e}`)}function renderProse(e,t,r){let i=[],o=e.kind===`subagent-step`,s=o?``:`${r.colors.bold(r.colors.white(r.glyph.brand))} `,c=o?``:` `;e.reasoning&&e.reasoning.trim().length>0&&i.push(...renderReasoningLines(e.reasoning,t,r));let l=(e.body??``).trim();return l.length===0&&i.length===0?[`${s}${r.colors.dim(`thinking${r.glyph.ellipsis}`)}`]:(l.length>0&&renderMarkdown(l).split(`
3
+ `).flatMap(e=>wrapVisibleLine(e,t-c.length)).forEach((e,t)=>{t===0&&!o&&i.length===0?i.push(`${s}${e}`):i.push(`${c}${e}`)}),i.length>0?i:[`${s}`])}function renderReasoning(e,t,n){return e.collapsed?[`${n.colors.gray(n.glyph.reasoning)} ${n.colors.dim(`thinking`)}`]:renderReasoningLines(e.body??``,t,n,n.glyph.reasoning)}function renderReasoningLines(e,t,n,r){let i=r?2:0,a=wrap(e.trim(),t-i);return a.length===0?[]:a.map((e,t)=>`${r?t===0?`${n.colors.gray(r)} `:` `:``}${n.colors.dim(n.colors.italic(e))}`)}function renderTool(e,t,n,r){let{icon:a,accent:o}=toolGlyph(e.status??`running`,n,r),s=e.title??`tool`,c=t-2,l=truncatePlain(s,c),u=`${a} ${n.colors.bold(l)}`,d=c-l.length-2,f=e.subtitle??``;f.length>0&&d>=6&&(u+=` ${n.colors.gray(truncate(f,d))}`);let p=[u];return e.expanded?p.push(...renderToolExpanded(e,t,n)):e.status===`done`&&e.result&&e.result.length>0?p.push(resultLine(n.glyph.arrow,e.result,t,n,o)):e.status===`error`&&e.result?p.push(resultLine(n.glyph.arrow,e.result,t,n,n.colors.red)):e.status===`denied`&&p.push(resultLine(n.glyph.arrow,`denied`,t,n,n.colors.yellow)),p}function renderToolExpanded(e,t,n){let i=[],push=(e,a,o)=>{if(a!==void 0){i.push(` ${n.colors.dim(e)}`);for(let e of wrap(formatValuePretty(a),t-4))i.push(` ${o(e)}`)}};return push(`input`,e.toolInput,n.colors.gray),e.status===`error`&&e.result?push(`error`,e.result,n.colors.red):push(`output`,e.toolOutput,n.colors.gray),i}function resultLine(e,t,n,r,a){let o=n-4;return` ${r.colors.dim(e)} ${a(truncate(t,o))}`}function toolGlyph(e,t,n){switch(e){case`done`:return{icon:t.colors.green(t.glyph.success),accent:t.colors.gray};case`error`:return{icon:t.colors.red(t.glyph.error),accent:t.colors.red};case`denied`:return{icon:t.colors.yellow(t.glyph.warning),accent:t.colors.yellow};case`approval`:return{icon:t.colors.yellow(t.glyph.question),accent:t.colors.yellow};default:return{icon:t.colors.yellow(n.spinner),accent:t.colors.gray}}}function renderError(e,t,n){let r=n.colors.red(n.colors.bold(n.glyph.error)),i=e.title??`Error`,a=[`${r} ${n.colors.red(n.colors.bold(i))}`];for(let r of wrap(e.body??``,t-2))a.push(` ${colorizeError(r,n)}`);return a.push(...renderErrorDetail(e.detail,t,n)),a}function renderErrorDetail(e,t,n){if(e===void 0||e.trim().length===0)return[];let r=e.split(`
4
+ `),i=r.slice(0,12),a=i.map(e=>` ${n.colors.dim(truncatePlain(e,Math.max(1,t-2)))}`),o=r.length-i.length;return o>0&&a.push(` ${n.colors.dim(`${n.glyph.ellipsis} +${o} more line${o===1?``:`s`}`)}`),a}const URL_PATTERN=/(https?:\/\/\S+)/u;function colorizeError(e,t){return URL_PATTERN.test(e)?e.split(URL_PATTERN).map((e,n)=>n%2==1?t.colors.cyan(e):t.colors.red(e)).join(``):t.colors.red(e)}function renderNotice(e,t,n){let r=n.colors.dim(n.glyph.dot),i=wrap(e.body??``,t-2);return i.length===0?[r]:i.map(e=>`${r} ${n.colors.dim(e)}`)}function renderWarning(e,t,n){let r=n.colors.yellow(n.glyph.warning);return wrap(e.body??``,t-2).map((e,t)=>`${t===0?r:` `} ${paintCommands(e,n)}`)}function paintCommands(e,t){return e.replace(/\/[a-z-]+/g,e=>isPromptControlCommand(e)?t.colors.blue(e):e)}function renderCommand(e,t){let n=t.colors;return[`${n.cyan(t.glyph.user)} ${n.blue(e.body??``)}`]}function renderFlow(e,t,n){let r=n.colors,i=e.title??`info`,a=i===`success`?r.green(n.glyph.success):i===`warning`?r.yellow(n.glyph.warning):i===`error`?r.red(n.glyph.error):r.dim(n.glyph.dot),o=wrap(e.body??``,t-2),paint=e=>i===`info`?r.dim(e):e;return o.map((e,t)=>`${t===0?a:` `} ${paint(e)}`)}function renderResult(e,t,n){let r=n.colors.dim(n.glyph.elbow),i=wrap(e.body??``,t-7);return i.length===0?[` ${r}`]:i.map((e,t)=>t===0?` ${r} ${n.colors.dim(e)}`:` ${n.colors.dim(e)}`)}function renderPreformatted(e,t,r){let i=e.kind===`connection-auth`?r.colors.yellow(r.glyph.connection):r.colors.yellow(r.colors.bold(r.glyph.question)),a=e.title??``,o=[`${i} ${r.colors.bold(a)}`];for(let r of(e.body??``).split(`
5
+ `))for(let e of wrapVisibleLine(r,t-2))o.push(` ${e}`);return o}function renderLog(e,r,i,a){let o=e.title===`stderr`,s=o?i.colors.red:i.colors.gray,c=i.colors.dim(i.glyph.rule),l=o?`stderr`:`stdout`,u=i.colors.dim(`${l} ${i.glyph.dot} `),d=visibleLength(u),f=` `.repeat(d),p=a.previous?.kind===`log`&&a.previous.title===e.title,m=(e.body??``).split(`
6
+ `),h=[];for(let e of m){let t=wrapVisibleLine(e,Math.max(1,r-2-d));for(let e of t){let t=h.length===0&&!p?u:f;h.push(`${c} ${t}${i.colors.dim(s(e))}`)}}return h.length>0?h:[`${c}`]}function renderSubagentHeader(e,t,n){let r=truncatePlain(e.title??`subagent`,Math.max(8,t-14));return[`${n.colors.orange(n.glyph.subagent)} ${n.colors.bold(r)} ${n.colors.dim(`subagent`)}`]}function wrap(e,t){return e.trim().length===0?[]:e.split(`
7
+ `).flatMap(e=>wrapVisibleLine(e,Math.max(1,t)))}function truncatePlain(n,r){return visibleLength(n)<=r?n:sliceVisible(n,r)}export{renderBlockLines};
@@ -1,7 +1,7 @@
1
- import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{buildAgentHeader}from"./agent-header.js";import{sliceVisible,stripAnsi,visibleLength}from"./terminal-text.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{renderBlockLines}from"./blocks.js";import{dismissTypeahead,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{interruptedError}from"./errors.js";import{EMPTY_LINE,PromptHistory,backspace,deleteForward,deleteWord,insert,killToEnd,killToStart,lineOf,moveEnd,moveHome,moveLeft,moveRight,visibleLine}from"./line-editor.js";import{LiveRegion}from"./live-region.js";import{numbersSelectRows,renderAcknowledgeQuestion,renderFlowPanel,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{formatAssistantResponseStats,formatTokenFlow,nextKey,takeUntil}from"./stream-format.js";import{toErrorMessage}from"#shared/errors.js";import{filterOptions,initialSelectState,orderedSelection,reduceSelect,selectValueAtCursor,submitRowIndex}from"#setup/cli/select-state.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";const STATUS={processing:`Working…`,toolResults:`Reading results…`,streaming:`Responding…`,executingTools:`Running tools…`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f=[];#p=new Map;#m=new Set;#h=[];#g=new Set;#_=new Map;#v=new Set;#y;#b=!1;#x=[];#S;#C=0;#w;#T=``;#E=0;#D;#O=new PromptHistory;#k=!1;#A;#j=!1;#M=STATUS.processing;#N=`Eve`;#P=!1;#F=!1;#I=!0;#L=0;#R;#z;#B;#V=``;#H;#U;#W;#G=!1;#K=!1;#q;#J;#Y;#X;#Z;#Q;#$;#ee=``;#te=``;#ne;#re=0;#ie;#ae;setupFlow={begin:e=>this.#ce(e),end:e=>this.#le(e?.preserveDiagnostics??!0),readSelect:e=>this.#ue(e),readText:e=>this.#de(e),readAcknowledge:e=>this.#fe(e),setStatus:e=>this.#he(e),renderLine:(e,t)=>this.#ge(e,t),renderOutput:e=>this.#_e(e)};constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#i=e?.tools??`auto-collapsed`,this.#a=e?.reasoning??`full`,this.#o=e?.subagents??`auto-collapsed`,this.#s=e?.connectionAuth??`full`,this.#c=e?.assistantResponseStats??`tokensPerSecond`,this.#l=e?.contextSize,this.#Y=e?.contextSize,this.#u=e?.captureForeignOutput??this.#t===process.stdout,this.#d=e?.logs??`none`}renderAgentHeader(e){if(this.#N=e.name,this.#y=e,this.#ve(),this.#b){this.#je({kind:`agent-header`,body:this.#Ye().join(`
2
- `),live:!1}),this.#Ge();return}this.#b=!0,this.#n.flush(this.#Ye(),[])}async readPrompt(e){this.#ve(e),this.#k=!0,this.#j=!1,this.#M=``,this.#D=`Type to chat ${this.#r.glyph.dot} / for commands`;let t=lineOf(``);return this.#O.begin(t.text),this.#oe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,t.text),this.#Ee(),this.#Ge(),await new Promise((e,n)=>{let apply=e=>{t=e,this.#Oe(),this.#oe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,e.text,this.#A),this.#Ge()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#A=void 0,this.#De(),this.#ye(),n(interruptedError())},suggestions=()=>this.#A!==void 0&&isTypeaheadOpen(this.#A)?this.#A:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#B=n=>{switch(n.type){case`character`:apply(insert(t,n.value));break;case`backspace`:apply(backspace(t));break;case`delete`:apply(deleteForward(t));break;case`left`:apply(moveLeft(t));break;case`right`:apply(moveRight(t));break;case`home`:case`ctrl-a`:apply(moveHome(t));break;case`end`:case`ctrl-e`:apply(moveEnd(t));break;case`ctrl-k`:apply(killToEnd(t));break;case`ctrl-u`:apply(killToStart(t));break;case`ctrl-w`:apply(deleteWord(t));break;case`up`:{let e=suggestions();e===void 0?recall(this.#O.previous(t.text)):(this.#A=moveTypeaheadSelection(e,-1),this.#Ge());break}case`down`:{let e=suggestions();e===void 0?recall(this.#O.next()):(this.#A=moveTypeaheadSelection(e,1),this.#Ge());break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#A=dismissTypeahead(e),this.#Ge());break}case`enter`:{let n=highlighted(),r=n!==void 0&&parsePromptCommand(t.text)===null?typeaheadCompletion(n).trimEnd():t.text;this.#A=void 0,this.#O.add(r),this.#k=!1,this.#De(),this.#M=STATUS.processing,isPromptControlCommand(r)?this.#je({kind:`command`,body:r.trim(),live:!1}):(this.#Me(r),this.#ie=r),this.#oe(EMPTY_LINE),this.#Ge(),this.#xe(),e(r);break}case`ctrl-d`:t.text.length===0?interrupt():apply(deleteForward(t));break;case`ctrl-l`:case`ctrl-r`:this.#Ge();break;case`ctrl-c`:interrupt();break;default:break}},this.#be()})}#oe(e){this.#T=e.text,this.#E=e.cursor}async renderStream(e,t){this.#ve(t),this.#m.clear(),this.#k=!1,this.#j=!0,this.#M=STATUS.processing,this.#Ne(t?.submittedPrompt),this.#F=!1,this.#q=void 0,this.#J=void 0,this.#X=void 0,this.#Z=void 0,this.#Q=Date.now();let n={tools:t?.tools??this.#i,reasoning:t?.reasoning??this.#a,assistantResponseStats:t?.assistantResponseStats??this.#c};this.#ke(),this.#Ge();let r=new Promise(e=>{this.#W=e});this.#B=e=>this.#Te(e),this.#be();let i={text:new Map,reasoning:new Map,tools:new Map,hasPendingToolResults:!1};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#F)break;this.#ze(t,n,i)}}catch(e){this.#Pe(`Error`,toErrorMessage(e))}finally{this.#W=void 0,this.#F&&e.abort?.(),this.#xe(),this.#Ae(),this.#j=!1,this.#M=this.#F?`Interrupted`:t?.continueSession?`Ready`:`Done`,this.#Re(),this.#Ge(),(this.#F||!t?.continueSession)&&this.#ye()}if(this.#F)throw interruptedError()}async readToolApproval(e,t){return this.#ve(t),this.#k=!1,this.#j=!1,this.#M=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#F=!1,this.#Ge(),await new Promise((t,n)=>{this.#B=r=>{switch(r.type){case`character`:{let n=r.value.toLowerCase();n===`y`?(this.#M=STATUS.processing,this.#xe(),this.#Ge(),t({approved:!0})):n===`n`&&(this.#M=STATUS.processing,this.#se(e.toolCallId),this.#xe(),this.#Ge(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#Ge();break;case`ctrl-c`:this.#F=!0,this.#ye(),n(interruptedError());break;default:break}},this.#be()})}async readInputQuestion(e,t){this.#ve(t),this.#k=!1,this.#j=!1,this.#F=!1,this.#D=void 0;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`select`:`text`,c=0,l=``,isOnFreeformRow=()=>i&&c===n.length,renderSection=()=>{this.#Ie({id:o,kind:`question`,title:e.prompt,body:formatQuestionContent(e,c,this.#r),preformatted:!0,live:!0})},repaintStatus=()=>{if(s===`select`){let e=isOnFreeformRow()?`type`:`select`;this.#M=`↑/↓ move · enter ${e} · Ctrl+C quit`,this.#k=!1}else this.#k=!0,this.#oe(lineOf(l)),this.#M=``;this.#Ge()};renderSection(),s===`text`&&this.#Ee(),repaintStatus();let finalize=t=>{this.#Ie({id:o,kind:`question`,title:e.prompt,body:` ${this.#r.colors.green(this.#r.glyph.success)} ${t.label}`,preformatted:!0,live:!1}),this.#k=!1,this.#M=STATUS.processing,this.#De(),this.#xe(),this.#Ge();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n};return await new Promise((t,i)=>{this.#B=o=>{if(o.type===`ctrl-c`){this.#F=!0,this.#De(),this.#ye(),i(interruptedError());return}if(o.type===`ctrl-r`){this.#Ge();return}if(s===`select`){switch(o.type){case`up`:a>0&&(c=(c-1+a)%a,renderSection(),repaintStatus());break;case`down`:a>0&&(c=(c+1)%a,renderSection(),repaintStatus());break;case`enter`:{if(isOnFreeformRow()){s=`text`,l=``,this.#Ee(),repaintStatus();break}let e=n[c];e&&t(finalize({optionId:e.id,label:e.label}));break}default:break}return}switch(o.type){case`character`:l+=o.value,this.#Oe(),repaintStatus();break;case`backspace`:l=l.slice(0,-1),this.#Oe(),repaintStatus();break;case`enter`:{let n=resolveQuestionText(l,e);if(n===void 0)break;t(finalize(n));break}case`escape`:if(r){if(l.length>0){l=``,this.#Oe(),repaintStatus();break}s=`select`,l=``,this.#k=!1,this.#De(),repaintStatus();break}l=``,this.#Oe(),repaintStatus();break;default:break}},this.#be()})}upsertSubagentStep(e){if(this.#o===`hidden`)return;let t=e.reasoning?.trim()??``,n=e.message?.trim()??``;if(!(t.length===0&&n.length===0)){if(this.#Fe(e.callId,e.subagentName),this.#o===`collapsed`){this.#Ge();return}this.#Ie({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,depth:1,reasoning:t,body:n,live:!e.finalized}),this.#Ge()}}upsertSubagentTool(n){if(this.#o===`hidden`)return;if(this.#Fe(n.callId,n.subagentName),this.#o===`collapsed`){this.#Ge();return}let r=subagentToolStatus(n.status),i={id:subagentToolSectionId(n.callId,n.childCallId),kind:`subagent-tool`,depth:1,title:n.toolName,subtitle:summarizeToolArgs(n.input),status:r,live:r===`running`||r===`approval`,expanded:this.#o===`full`,toolInput:n.input};n.output===void 0?n.errorText!==void 0&&(i.result=n.errorText):(i.result=summarizeToolResult(n.output),i.toolOutput=n.output),this.#Ie(i),this.#Ge()}markChildToolCallId(e){this.#g.add(e);let t=this.#_.get(e);t!==void 0&&(this.#Le(t),this.#_.delete(e),this.#Ge())}#se(e){let t=this.#p.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#s===`hidden`)return;let t=e.state===`authorized`||e.state===`declined`||e.state===`failed`||e.state===`timed-out`;this.#Ie({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${e.name} · authorization · ${e.state}`,body:formatConnectionAuthContent(e),preformatted:!0,live:!t}),this.#Ge()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#C)return;let n=this.#C>0;this.#C=t,t>0?(this.#M=STATUS.connectionAuth,this.#Ge()):n&&(this.#M=STATUS.processing,this.#Ge())}setVercelStatus(e){this.#w=e,this.#Ge()}reset(){this.#f=[],this.#p.clear(),this.#m.clear(),this.#S=void 0,this.#x.length=0,this.#h.length=0,this.#b=!1,this.#g.clear(),this.#_.clear(),this.#v.clear(),this.#ie=void 0,this.#ne=void 0,this.#C=0,this.#q=void 0,this.#J=void 0,this.#X=void 0,this.#Z=void 0,this.#Q=void 0,this.#P&&(this.#n.clearAll(),this.#Ge())}renderNotice(e){e.trim().length!==0&&(this.#ve(),this.#je({kind:`notice`,body:e,live:!1}),this.#Ge())}renderSetupWarning(e){e.trim().length!==0&&(this.#ve(),this.#je({kind:`warning`,body:e,live:!1}),this.#Ge())}renderCommandResult(e){e.trim().length!==0&&(this.#ve(),this.#je({kind:`result`,body:e,live:!1}),this.#Ge())}#ce(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``,this.#ae={title:e,lines:[],outputBuffer:[]},this.#ke(),this.#Ge()}#le(e){let t=this.#ae;if(t!==void 0){if(this.#ae=void 0,this.#Ae(),e)for(let e of t.lines)(e.tone===`warning`||e.tone===`error`)&&this.#je({kind:`flow`,title:e.tone,body:e.text,live:!1});this.#Ge()}}async#ue(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t={options:e.options,submitRow:e.multiple},n={options:e.options,submitRow:e.multiple};e.initialValue!==void 0&&(n.defaultValue=e.initialValue),e.initialValues!==void 0&&(n.initialValues=e.initialValues);let r=initialSelectState(n),i,a=this.#pe(),panelState=()=>{let t={message:e.message,options:e.options,multiple:e.multiple,search:e.search,select:r};return e.placeholder!==void 0&&(t.placeholder=e.placeholder),e.layout!==void 0&&(t.layout=e.layout),e.notices!==void 0&&(t.notices=e.notices),i!==void 0&&(t.error=i),t};return a.question=e=>renderSelectQuestion(panelState(),this.#r,e),this.#Ge(),await new Promise(n=>{let settle=e=>{this.#me(),n(e)},apply=e=>{r=reduceSelect(r,e,t),i=void 0,this.#Ge()};this.#B=n=>{switch(n.type){case`ctrl-c`:case`escape`:settle(void 0);return;case`ctrl-r`:this.#Ge();return;case`up`:apply({type:`up`});return;case`down`:apply({type:`down`});return;case`backspace`:e.search&&apply({type:`backspace`});return;case`character`:if(e.multiple&&n.value===` `){apply({type:`toggle`});return}if(numbersSelectRows(e)&&/^[1-9]$/.test(n.value)){let t=Number(n.value)-1,a=e.options[t];a!==void 0&&!a.disabled&&!a.locked&&(r={...r,cursor:t},i=void 0,this.#Ge());return}if(e.search){for(let e of n.value)e>=` `&&e!==``&&(r=reduceSelect(r,{type:`char`,char:e},t));i=void 0,this.#Ge()}return;case`enter`:{let t=e.search?filterOptions(e.options,r.filter):[...e.options];if(e.multiple){if(r.cursor===submitRowIndex(t)){if(e.required&&r.selected.size===0){i=`Select at least one option, then submit.`,this.#Ge();return}settle(orderedSelection(e.options,r.selected));return}apply({type:`toggle`});return}let n=selectValueAtCursor(t,r.cursor);if(n===void 0){i=`Type to match an option, then press enter.`,this.#Ge();return}settle([n]);return}default:return}},this.#be()})}async#de(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t=lineOf(``),n,r=this.#pe();return r.question=r=>{let i={message:e.message,editor:t,mask:e.mask===!0};return e.placeholder!==void 0&&(i.placeholder=e.placeholder),n!==void 0&&(i.error=n),renderTextQuestion(i,this.#r,r,this.#I)},this.#Ee(),this.#Ge(),await new Promise(r=>{let settle=e=>{this.#De(),this.#me(),r(e)},apply=e=>{t=e,n=void 0,this.#Oe(),this.#Ge()};this.#B=r=>{switch(r.type){case`ctrl-c`:case`escape`:settle(void 0);return;case`ctrl-r`:this.#Ge();return;case`character`:apply(insert(t,r.value));return;case`backspace`:apply(backspace(t));return;case`delete`:apply(deleteForward(t));return;case`left`:apply(moveLeft(t));return;case`right`:apply(moveRight(t));return;case`home`:case`ctrl-a`:apply(moveHome(t));return;case`end`:case`ctrl-e`:apply(moveEnd(t));return;case`ctrl-k`:apply(killToEnd(t));return;case`ctrl-u`:apply(killToStart(t));return;case`ctrl-w`:apply(deleteWord(t));return;case`enter`:{let r=t.text.length>0?t.text:e.defaultValue??``,i=e.validate?.(r);if(i!==void 0){n=i,this.#Ge();return}settle(r);return}default:return}},this.#be()})}async#fe(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t=this.#pe();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#Ge(),await new Promise(e=>{this.#B=t=>{switch(t.type){case`enter`:case`escape`:case`ctrl-c`:this.#me(),e();return;case`ctrl-r`:this.#Ge();return;default:return}},this.#be()})}#pe(){return this.#ae===void 0&&(this.#ae={title:``,lines:[],outputBuffer:[]}),this.#ae}#me(){this.#ae!==void 0&&(this.#ae.question=void 0),this.#B=void 0,this.#xe(),this.#Ge()}#he(e){if(this.#ae!==void 0){this.#ae.status=e,e===void 0&&(this.#ae.preview=void 0),this.#Ge();return}if(e===void 0){this.#j=!1,this.#M=``,this.#Ae(),this.#Ge();return}this.#ve(),this.#j=!0,this.#M=e,this.#ke(),this.#Ge()}#ge(e,t){if(e.trim().length===0)return;let n=this.#ae;if(n!==void 0){if(n.preview=void 0,t===`warning`||t===`error`)for(let e of n.outputBuffer)n.lines.push({text:e,tone:`info`});n.outputBuffer=[],n.lines.push({text:e,tone:t}),this.#Ge();return}this.#ve(),this.#je({kind:`flow`,title:t,body:e,live:!1}),this.#Ge()}#_e(e){if(e.trim().length===0)return;let t=this.#ae;if(t===void 0){this.#ge(e,`info`);return}t.preview=e,t.outputBuffer.push(e),t.outputBuffer.length>8&&t.outputBuffer.shift(),this.#Ge()}shutdown(){this.#ye()}#ve(e){this.#N=e?.title??this.#N,this.#Y=e?.contextSize??this.#l,!this.#P&&(this.#P=!0,this.#n.reset(),this.#n.hideCursor(),this.#rt(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume()),this.#U=()=>this.#Ge(),this.#t.on(`resize`,this.#U))}#ye(){this.#xe(),this.#De(),this.#Ae(),this.#P&&=(this.#lt(),this.#Ge(),this.#n.clear(),this.#n.showCursor(),this.#it(),this.#n.newline(),this.#e.isTTY&&(this.#e.setRawMode?.(!1),this.#e.pause()),this.#U&&=(this.#t.off(`resize`,this.#U),void 0),!1)}#be(){this.#e.on(`data`,this.#Se)}#xe(){this.#e.off(`data`,this.#Se),this.#we(),this.#V=``,this.#B=void 0}#Se=e=>{this.#we(),this.#V+=e.toString(`utf8`),this.#Ce(),this.#V===`\x1B`&&(this.#H=setTimeout(()=>{this.#V===`\x1B`&&(this.#V=``,this.#B?.({type:`escape`}))},30),this.#H.unref?.())};#Ce(){for(;this.#V.length>0;){let e=nextKey(this.#V);if(e.incomplete)return;this.#V=this.#V.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#B?.(e.key)}}#we(){this.#H&&=(clearTimeout(this.#H),void 0)}#Te(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#Ge();break;case`ctrl-c`:this.#F=!0,this.#W?.();break;default:break}}#Ee(){this.#De(),this.#Oe(),this.#R=setInterval(()=>{this.#I=!this.#I,this.#Ge()},500),this.#R.unref?.()}#De(){this.#R&&=(clearInterval(this.#R),void 0),this.#I=!0}#Oe(){this.#I=!0}#ke(){this.#Ae(),this.#z=setInterval(()=>{this.#L+=1,this.#Ge()},90),this.#z.unref?.()}#Ae(){this.#z&&=(clearInterval(this.#z),void 0)}#je(e){e.id!==this.#ne?.id&&this.#lt(),this.#f.push(e),e.id&&this.#p.set(e.id,e)}#Me(e){this.#je({kind:`user`,body:e,live:!1}),this.#Ge()}#Ne(e){if(e!=null){if(this.#ie===e){this.#ie=void 0;return}this.#je({kind:`user`,body:e,live:!1})}}#Pe(e,t,n){let r={kind:`error`,title:e,body:t,live:!1};n!==void 0&&(r.detail=n),this.#je(r),this.#Ge()}#Fe(e,t){this.#v.has(e)||(this.#v.add(e),this.#je({id:subagentHeaderId(e),kind:`subagent`,title:t,live:!1}))}#Ie(e){if(e.id&&this.#m.has(e.id))return;let t=e.id?this.#p.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#je(e)}#Le(e){this.#f=this.#f.filter(t=>t.id!==e),this.#p.delete(e)}#Re(){for(let e of this.#f)e.status!==`approval`&&(e.live=!1)}#ze(e,t,n){switch(e.type){case`step-start`:this.#Be(n.hasPendingToolResults?STATUS.toolResults:STATUS.processing),n.hasPendingToolResults=!1;break;case`step-finish`:this.#We(e.usage),this.#Ge();break;case`assistant-delta`:{this.#Be(STATUS.streaming);let t=(n.text.get(e.id)??``)+e.delta;n.text.set(e.id,t),this.#Ve(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=e.text!==void 0&&t.length===0?e.text??``:t;n.text.set(e.id,r),this.#Ve(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;this.#Be(STATUS.streaming);let r=(n.reasoning.get(e.id)??``)+e.delta;n.reasoning.set(e.id,r),this.#He(e.id,r,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;this.#He(e.id,r,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#Be(STATUS.executingTools),this.#Ue({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;this.#Ue({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;n.hasPendingToolResults=!0,this.#Be(STATUS.toolResults),this.#Ue({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;n.hasPendingToolResults=!0,this.#Be(STATUS.toolResults),this.#Ue({...r,errorText:e.errorText,status:`error`},t,n);break}case`error`:this.#Pe(`Error`,e.errorText,e.detail);break;case`finish`:this.#We(e.usage),this.#Ge();break}}#Be(e){let t=this.#C>0?STATUS.connectionAuth:e;this.#M!==t&&(this.#M=t,this.#Ge())}#Ve(e,t,n){let r=t.trim();r.length!==0&&(this.#Ie({id:e,kind:`assistant`,body:r,live:n}),this.#Ge())}#He(e,t,n,r){let i=t.trim();i.length!==0&&(this.#Ie({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#Ge())}#Ue(e,t,n){if(n.tools.set(e.toolCallId,e),this.#g.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#_.set(e.toolCallId,r),this.#Ie(renderNativeToolBlock(e,r,t.tools===`full`)),this.#Ge()}#We(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#q=(t??0)+(n??0)),this.#J=t??this.#J,this.#X=n??this.#X,this.#X!=null&&this.#Q!==void 0){let e=(Date.now()-this.#Q)/1e3;e>0&&(this.#Z=this.#X/e)}}#Ge(){if(this.#P){if(this.#G){this.#K=!0;return}this.#G=!0;try{do this.#K=!1,this.#Ke();while(this.#K)}finally{this.#G=!1}}}#Ke(){if(!this.#P)return;let e=this.#tt(),t=this.#Qe(e),n=Math.max(1,this.#nt()-t.length),r=[],i=this.#S;for(;this.#f.length>0&&this.#f[0].live===!1;){let t=this.#f.shift();if(this.#h.push(t),t.id&&(this.#m.add(t.id),this.#p.delete(t.id)),this.#dt(t))continue;let n=this.#Xe(t,e,i);i=previousBlockOf(t),this.#S=i,r.push(...n),this.#x.push(...n)}let a=[];for(let t of this.#f){if(this.#dt(t))continue;let n=this.#Xe(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)a.push({block:t,row:n[e]})}let o=[...clipLiveRows(a.map(e=>e.row),n,e,this.#r),...t];r.length>0?this.#n.flush(r,o):this.#n.update(o)}#qe(){if(!this.#P)return;let e=this.#tt(),t=this.#Qe(e),n=Math.max(1,this.#nt()-t.length),r=this.#S,i=[];for(let t of this.#f){if(this.#dt(t))continue;let n=this.#Xe(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#r),...t];this.#n.clearAll(),this.#n.flush([...this.#Ye(),...this.#x],a)}logDisplayMode(){return this.#d}setLogDisplayMode(e){e!==this.#d&&(this.#d=e,this.#Je(),this.#P&&this.#qe())}#Je(){let e=this.#tt();this.#x.length=0;let t;for(let n of this.#h){if(this.#dt(n))continue;let r=this.#Xe(n,e,t);t=previousBlockOf(n),this.#x.push(...r)}this.#S=t}#Ye(){let e=this.#y;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#tt()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#Xe(e,t,n){let r={spinner:this.#Ze()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#Ze(){return this.#r.spinner[this.#L%this.#r.spinner.length]??``}#Qe(e){let t=this.#r.colors,n=[``],r=this.#ae;if(r!==void 0){let t={title:r.title,lines:r.lines,frame:this.#Ze()};return r.question===void 0?(r.status!==void 0&&(t.status={text:r.status,frame:this.#Ze()}),r.preview!==void 0&&(t.preview=r.preview)):t.question=r.question(e),n.push(...renderFlowPanel(t,this.#r,e)),n}if(this.#k){this.#A!==void 0&&isTypeaheadOpen(this.#A)&&n.push(...renderCommandSuggestions(this.#A,this.#r,e));let r=Math.max(4,e-3),{before:i,after:a}=visibleLine({text:this.#T,cursor:this.#E},r,this.#r.glyph.ellipsis),o=isPromptControlCommand(this.#T),style=e=>o&&e.length>0?t.blue(e):e,c=this.#I?t.cyan(this.#r.glyph.caret):` `,l=this.#T.length===0&&this.#D!==void 0?`${c}${t.dim(this.#D)}`:`${style(i)}${c}${style(a)}`;return n.push(clip(`${t.cyan(this.#r.glyph.prompt)} ${l}`,e)),this.#$e(n,e),n}let i=this.#j?t.yellow(this.#Ze()):t.dim(this.#r.glyph.dot),a=this.#M.length>0?this.#M:`Ready`,o=this.#j?t.dim(a):a,c=this.#et(),l=c?`${i} ${o} ${t.dim(this.#r.glyph.dot)} ${c}`:`${i} ${o}`;return n.push(clip(l,e)),this.#$e(n,e),n}#$e(e,t){let n={theme:this.#r,width:t},r=this.#y?.info?.agent.model.id;r!==void 0&&(n.model=r);let i={inputTokens:this.#J??0,outputTokens:this.#X??0};this.#Y!==void 0&&(i.contextSize=this.#Y),n.tokens=formatTokenFlow(i,this.#r.glyph),this.#w!==void 0&&(n.vercel=this.#w);let a=buildStatusLine(n);a!==void 0&&e.push(a)}#et(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#q,outputTokens:this.#X,tokensPerSecond:this.#Z},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#tt(){return Math.max(20,this.#t.columns||80)}#nt(){return Math.max(8,this.#t.rows||24)}#rt(){if(this.#$!==void 0||!this.#u)return;this.#ee=``,this.#te=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#at(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#$=()=>{e(),t()}}#it(){let e=this.#$;e!==void 0&&(this.#$=void 0,e(),this.#ee.length>0&&(this.#ut(`stdout`)&&process.stdout.write(`${this.#ee}\n`),this.#ee=``),this.#te.length>0&&(this.#ut(`stderr`)&&process.stderr.write(`${this.#te}\n`),this.#te=``))}#at(e,t){let n=(e===`stdout`?this.#ee:this.#te)+t,r=n.lastIndexOf(`
3
- `),a=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#ee=a:this.#te=a,r===-1)return;let o=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);o.trim().length!==0&&(e===`stdout`?this.#ot(o):this.#je({kind:`log`,title:e,body:o,live:!1}),this.#Ge())}#ot(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
1
+ import{sliceVisible,stripAnsi,stripTerminalControls,visibleLength}from"./terminal-text.js";import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{buildAgentHeader}from"./agent-header.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{renderBlockLines}from"./blocks.js";import{dismissTypeahead,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{interruptedError}from"./errors.js";import{EMPTY_LINE,PromptHistory,backspace,deleteForward,deleteWord,insert,killToEnd,killToStart,lineOf,moveEnd,moveHome,moveLeft,moveRight,visibleLine}from"./line-editor.js";import{LiveRegion}from"./live-region.js";import{numbersSelectRows,renderAcknowledgeQuestion,renderFlowPanel,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{formatAssistantResponseStats,formatTokenFlow,nextKey,takeUntil}from"./stream-format.js";import{toErrorMessage}from"#shared/errors.js";import{filterOptions,initialSelectState,orderedSelection,reduceSelect,selectValueAtCursor,submitRowIndex}from"#setup/cli/select-state.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";const STATUS={processing:`Working…`,toolResults:`Reading results…`,streaming:`Responding…`,executingTools:`Running tools…`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f=[];#p=new Map;#m=new Set;#h=[];#g=new Set;#_=new Map;#v=new Set;#y;#b=!1;#x=[];#S;#C=0;#w;#T=``;#E=0;#D;#O=new PromptHistory;#k=!1;#A;#j=!1;#M=STATUS.processing;#N=`Eve`;#P=!1;#F=!1;#I=!0;#L=0;#R;#z;#B;#V=``;#H;#U;#W;#G=!1;#K=!1;#q;#J;#Y;#X;#Z;#Q;#$;#ee=``;#te=``;#ne;#re=0;#ie;#ae;setupFlow={begin:e=>this.#ce(e),end:e=>this.#le(e?.preserveDiagnostics??!0),readSelect:e=>this.#ue(e),readText:e=>this.#de(e),readAcknowledge:e=>this.#fe(e),setStatus:e=>this.#he(e),renderLine:(e,t)=>this.#ge(e,t),renderOutput:e=>this.#_e(e)};constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#i=e?.tools??`auto-collapsed`,this.#a=e?.reasoning??`full`,this.#o=e?.subagents??`auto-collapsed`,this.#s=e?.connectionAuth??`full`,this.#c=e?.assistantResponseStats??`tokensPerSecond`,this.#l=e?.contextSize,this.#Y=e?.contextSize,this.#u=e?.captureForeignOutput??this.#t===process.stdout,this.#d=e?.logs??`none`}renderAgentHeader(e){if(this.#N=e.name,this.#y=e,this.#ve(),this.#b){this.#je({kind:`agent-header`,body:this.#Ye().join(`
2
+ `),live:!1}),this.#Ge();return}this.#b=!0,this.#n.flush(this.#Ye(),[])}async readPrompt(e){this.#ve(e),this.#k=!0,this.#j=!1,this.#M=``,this.#D=`Type to chat ${this.#r.glyph.dot} / for commands`;let t=lineOf(``);return this.#O.begin(t.text),this.#oe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,t.text),this.#Ee(),this.#Ge(),await new Promise((e,r)=>{let apply=e=>{t=e,this.#Oe(),this.#oe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,e.text,this.#A),this.#Ge()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#A=void 0,this.#De(),this.#ye(),r(interruptedError())},suggestions=()=>this.#A!==void 0&&isTypeaheadOpen(this.#A)?this.#A:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#B=r=>{switch(r.type){case`character`:apply(insert(t,r.value));break;case`backspace`:apply(backspace(t));break;case`delete`:apply(deleteForward(t));break;case`left`:apply(moveLeft(t));break;case`right`:apply(moveRight(t));break;case`home`:case`ctrl-a`:apply(moveHome(t));break;case`end`:case`ctrl-e`:apply(moveEnd(t));break;case`ctrl-k`:apply(killToEnd(t));break;case`ctrl-u`:apply(killToStart(t));break;case`ctrl-w`:apply(deleteWord(t));break;case`up`:{let e=suggestions();e===void 0?recall(this.#O.previous(t.text)):(this.#A=moveTypeaheadSelection(e,-1),this.#Ge());break}case`down`:{let e=suggestions();e===void 0?recall(this.#O.next()):(this.#A=moveTypeaheadSelection(e,1),this.#Ge());break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#A=dismissTypeahead(e),this.#Ge());break}case`enter`:{let r=highlighted(),i=r!==void 0&&parsePromptCommand(t.text)===null?typeaheadCompletion(r).trimEnd():t.text;this.#A=void 0,this.#O.add(i),this.#k=!1,this.#De(),this.#M=STATUS.processing,isPromptControlCommand(i)?this.#je({kind:`command`,body:stripTerminalControls(i.trim()),live:!1}):(this.#Me(i),this.#ie=i),this.#oe(EMPTY_LINE),this.#Ge(),this.#xe(),e(i);break}case`ctrl-d`:t.text.length===0?interrupt():apply(deleteForward(t));break;case`ctrl-l`:case`ctrl-r`:this.#Ge();break;case`ctrl-c`:interrupt();break;default:break}},this.#be()})}#oe(e){this.#T=e.text,this.#E=e.cursor}async renderStream(e,t){this.#ve(t),this.#m.clear(),this.#k=!1,this.#j=!0,this.#M=STATUS.processing,this.#Ne(t?.submittedPrompt),this.#F=!1,this.#q=void 0,this.#J=void 0,this.#X=void 0,this.#Z=void 0,this.#Q=Date.now();let n={tools:t?.tools??this.#i,reasoning:t?.reasoning??this.#a,assistantResponseStats:t?.assistantResponseStats??this.#c};this.#ke(),this.#Ge();let r=new Promise(e=>{this.#W=e});this.#B=e=>this.#Te(e),this.#be();let i={text:new Map,reasoning:new Map,tools:new Map,hasPendingToolResults:!1};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#F)break;this.#ze(t,n,i)}}catch(e){this.#Pe(`Error`,toErrorMessage(e))}finally{this.#W=void 0,this.#F&&e.abort?.(),this.#xe(),this.#Ae(),this.#j=!1,this.#M=this.#F?`Interrupted`:t?.continueSession?`Ready`:`Done`,this.#Re(),this.#Ge(),(this.#F||!t?.continueSession)&&this.#ye()}if(this.#F)throw interruptedError()}async readToolApproval(e,t){return this.#ve(t),this.#k=!1,this.#j=!1,this.#M=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#F=!1,this.#Ge(),await new Promise((t,n)=>{this.#B=r=>{switch(r.type){case`character`:{let n=r.value.toLowerCase();n===`y`?(this.#M=STATUS.processing,this.#xe(),this.#Ge(),t({approved:!0})):n===`n`&&(this.#M=STATUS.processing,this.#se(e.toolCallId),this.#xe(),this.#Ge(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#Ge();break;case`ctrl-c`:this.#F=!0,this.#ye(),n(interruptedError());break;default:break}},this.#be()})}async readInputQuestion(e,t){this.#ve(t),this.#k=!1,this.#j=!1,this.#F=!1,this.#D=void 0;let r=e.options??[],i=r.length>0,a=(e.allowFreeform===!0||!i)&&i,o=r.length+ +!!a,s=questionSectionId(e.requestId),c=i?`select`:`text`,l=0,u=``,isOnFreeformRow=()=>a&&l===r.length,renderSection=()=>{this.#Ie({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,l,this.#r),preformatted:!0,live:!0})},repaintStatus=()=>{if(c===`select`){let e=isOnFreeformRow()?`type`:`select`;this.#M=`↑/↓ move · enter ${e} · Ctrl+C quit`,this.#k=!1}else this.#k=!0,this.#oe(lineOf(u)),this.#M=``;this.#Ge()};renderSection(),c===`text`&&this.#Ee(),repaintStatus();let finalize=t=>{this.#Ie({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:` ${this.#r.colors.green(this.#r.glyph.success)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#k=!1,this.#M=STATUS.processing,this.#De(),this.#xe(),this.#Ge();let r={};return t.optionId!==void 0&&(r.optionId=t.optionId),t.text!==void 0&&(r.text=t.text),r};return await new Promise((t,n)=>{this.#B=a=>{if(a.type===`ctrl-c`){this.#F=!0,this.#De(),this.#ye(),n(interruptedError());return}if(a.type===`ctrl-r`){this.#Ge();return}if(c===`select`){switch(a.type){case`up`:o>0&&(l=(l-1+o)%o,renderSection(),repaintStatus());break;case`down`:o>0&&(l=(l+1)%o,renderSection(),repaintStatus());break;case`enter`:{if(isOnFreeformRow()){c=`text`,u=``,this.#Ee(),repaintStatus();break}let e=r[l];e&&t(finalize({optionId:e.id,label:e.label}));break}default:break}return}switch(a.type){case`character`:u+=a.value,this.#Oe(),repaintStatus();break;case`backspace`:u=u.slice(0,-1),this.#Oe(),repaintStatus();break;case`enter`:{let n=resolveQuestionText(u,e);if(n===void 0)break;t(finalize(n));break}case`escape`:if(i){if(u.length>0){u=``,this.#Oe(),repaintStatus();break}c=`select`,u=``,this.#k=!1,this.#De(),repaintStatus();break}u=``,this.#Oe(),repaintStatus();break;default:break}},this.#be()})}upsertSubagentStep(e){if(this.#o===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),r=stripTerminalControls(e.message??``).trim();if(!(t.length===0&&r.length===0)){if(this.#Fe(e.callId,e.subagentName),this.#o===`collapsed`){this.#Ge();return}this.#Ie({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,depth:1,reasoning:t,body:r,live:!e.finalized}),this.#Ge()}}upsertSubagentTool(e){if(this.#o===`hidden`)return;if(this.#Fe(e.callId,e.subagentName),this.#o===`collapsed`){this.#Ge();return}let t=subagentToolStatus(e.status),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,depth:1,title:stripTerminalControls(e.toolName),subtitle:summarizeToolArgs(e.input),status:t,live:t===`running`||t===`approval`,expanded:this.#o===`full`,toolInput:e.input};e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=summarizeToolResult(e.output),r.toolOutput=e.output),this.#Ie(r),this.#Ge()}markChildToolCallId(e){this.#g.add(e);let t=this.#_.get(e);t!==void 0&&(this.#Le(t),this.#_.delete(e),this.#Ge())}#se(e){let t=this.#p.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#s===`hidden`)return;let t=e.state===`authorized`||e.state===`declined`||e.state===`failed`||e.state===`timed-out`;this.#Ie({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e),preformatted:!0,live:!t}),this.#Ge()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#C)return;let n=this.#C>0;this.#C=t,t>0?(this.#M=STATUS.connectionAuth,this.#Ge()):n&&(this.#M=STATUS.processing,this.#Ge())}setVercelStatus(e){this.#w=e,this.#Ge()}reset(){this.#f=[],this.#p.clear(),this.#m.clear(),this.#S=void 0,this.#x.length=0,this.#h.length=0,this.#b=!1,this.#g.clear(),this.#_.clear(),this.#v.clear(),this.#ie=void 0,this.#ne=void 0,this.#C=0,this.#q=void 0,this.#J=void 0,this.#X=void 0,this.#Z=void 0,this.#Q=void 0,this.#P&&(this.#n.clearAll(),this.#Ge())}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#ve(),this.#je({kind:`notice`,body:t,live:!1}),this.#Ge())}renderSetupWarning(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#ve(),this.#je({kind:`warning`,body:t,live:!1}),this.#Ge())}renderCommandResult(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#ve(),this.#je({kind:`result`,body:t,live:!1}),this.#Ge())}#ce(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``,this.#ae={title:stripTerminalControls(e),lines:[],outputBuffer:[]},this.#ke(),this.#Ge()}#le(e){let t=this.#ae;if(t!==void 0){if(this.#ae=void 0,this.#Ae(),e)for(let e of t.lines)(e.tone===`warning`||e.tone===`error`)&&this.#je({kind:`flow`,title:e.tone,body:e.text,live:!1});this.#Ge()}}async#ue(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t={options:e.options,submitRow:e.multiple},n={options:e.options,submitRow:e.multiple};e.initialValue!==void 0&&(n.defaultValue=e.initialValue),e.initialValues!==void 0&&(n.initialValues=e.initialValues);let r=initialSelectState(n),i,a=this.#pe(),panelState=()=>{let t={message:e.message,options:e.options,multiple:e.multiple,search:e.search,select:r};return e.placeholder!==void 0&&(t.placeholder=e.placeholder),e.layout!==void 0&&(t.layout=e.layout),e.notices!==void 0&&(t.notices=e.notices),i!==void 0&&(t.error=i),t};return a.question=e=>renderSelectQuestion(panelState(),this.#r,e),this.#Ge(),await new Promise(n=>{let settle=e=>{this.#me(),n(e)},apply=e=>{r=reduceSelect(r,e,t),i=void 0,this.#Ge()};this.#B=n=>{switch(n.type){case`ctrl-c`:case`escape`:settle(void 0);return;case`ctrl-r`:this.#Ge();return;case`up`:apply({type:`up`});return;case`down`:apply({type:`down`});return;case`backspace`:e.search&&apply({type:`backspace`});return;case`character`:if(e.multiple&&n.value===` `){apply({type:`toggle`});return}if(numbersSelectRows(e)&&/^[1-9]$/.test(n.value)){let t=Number(n.value)-1,a=e.options[t];a!==void 0&&!a.disabled&&!a.locked&&(r={...r,cursor:t},i=void 0,this.#Ge());return}if(e.search){for(let e of n.value)e>=` `&&e!==``&&(r=reduceSelect(r,{type:`char`,char:e},t));i=void 0,this.#Ge()}return;case`enter`:{let t=e.search?filterOptions(e.options,r.filter):[...e.options];if(e.multiple){if(r.cursor===submitRowIndex(t)){if(e.required&&r.selected.size===0){i=`Select at least one option, then submit.`,this.#Ge();return}settle(orderedSelection(e.options,r.selected));return}apply({type:`toggle`});return}let n=selectValueAtCursor(t,r.cursor);if(n===void 0){i=`Type to match an option, then press enter.`,this.#Ge();return}settle([n]);return}default:return}},this.#be()})}async#de(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t=lineOf(``),n,r=this.#pe();return r.question=r=>{let i={message:e.message,editor:t,mask:e.mask===!0};return e.placeholder!==void 0&&(i.placeholder=e.placeholder),n!==void 0&&(i.error=n),renderTextQuestion(i,this.#r,r,this.#I)},this.#Ee(),this.#Ge(),await new Promise(r=>{let settle=e=>{this.#De(),this.#me(),r(e)},apply=e=>{t=e,n=void 0,this.#Oe(),this.#Ge()};this.#B=r=>{switch(r.type){case`ctrl-c`:case`escape`:settle(void 0);return;case`ctrl-r`:this.#Ge();return;case`character`:apply(insert(t,r.value));return;case`backspace`:apply(backspace(t));return;case`delete`:apply(deleteForward(t));return;case`left`:apply(moveLeft(t));return;case`right`:apply(moveRight(t));return;case`home`:case`ctrl-a`:apply(moveHome(t));return;case`end`:case`ctrl-e`:apply(moveEnd(t));return;case`ctrl-k`:apply(killToEnd(t));return;case`ctrl-u`:apply(killToStart(t));return;case`ctrl-w`:apply(deleteWord(t));return;case`enter`:{let r=t.text.length>0?t.text:e.defaultValue??``,i=e.validate?.(r);if(i!==void 0){n=i,this.#Ge();return}settle(r);return}default:return}},this.#be()})}async#fe(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t=this.#pe();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#Ge(),await new Promise(e=>{this.#B=t=>{switch(t.type){case`enter`:case`escape`:case`ctrl-c`:this.#me(),e();return;case`ctrl-r`:this.#Ge();return;default:return}},this.#be()})}#pe(){return this.#ae===void 0&&(this.#ae={title:``,lines:[],outputBuffer:[]}),this.#ae}#me(){this.#ae!==void 0&&(this.#ae.question=void 0),this.#B=void 0,this.#xe(),this.#Ge()}#he(e){let t=e===void 0?void 0:stripTerminalControls(e);if(this.#ae!==void 0){this.#ae.status=t,t===void 0&&(this.#ae.preview=void 0),this.#Ge();return}if(t===void 0){this.#j=!1,this.#M=``,this.#Ae(),this.#Ge();return}this.#ve(),this.#j=!0,this.#M=t,this.#ke(),this.#Ge()}#ge(e,t){let r=stripTerminalControls(e);if(r.trim().length===0)return;let i=this.#ae;if(i!==void 0){if(i.preview=void 0,t===`warning`||t===`error`)for(let e of i.outputBuffer)i.lines.push({text:e,tone:`info`});i.outputBuffer=[],i.lines.push({text:r,tone:t}),this.#Ge();return}this.#ve(),this.#je({kind:`flow`,title:t,body:r,live:!1}),this.#Ge()}#_e(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let r=this.#ae;if(r===void 0){this.#ge(t,`info`);return}r.preview=t,r.outputBuffer.push(t),r.outputBuffer.length>8&&r.outputBuffer.shift(),this.#Ge()}shutdown(){this.#ye()}#ve(e){this.#N=e?.title??this.#N,this.#Y=e?.contextSize??this.#l,!this.#P&&(this.#P=!0,this.#n.reset(),this.#n.hideCursor(),this.#rt(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume()),this.#U=()=>this.#Ge(),this.#t.on(`resize`,this.#U))}#ye(){this.#xe(),this.#De(),this.#Ae(),this.#P&&=(this.#lt(),this.#Ge(),this.#n.clear(),this.#n.showCursor(),this.#it(),this.#n.newline(),this.#e.isTTY&&(this.#e.setRawMode?.(!1),this.#e.pause()),this.#U&&=(this.#t.off(`resize`,this.#U),void 0),!1)}#be(){this.#e.on(`data`,this.#Se)}#xe(){this.#e.off(`data`,this.#Se),this.#we(),this.#V=``,this.#B=void 0}#Se=e=>{this.#we(),this.#V+=e.toString(`utf8`),this.#Ce(),this.#V===`\x1B`&&(this.#H=setTimeout(()=>{this.#V===`\x1B`&&(this.#V=``,this.#B?.({type:`escape`}))},30),this.#H.unref?.())};#Ce(){for(;this.#V.length>0;){let e=nextKey(this.#V);if(e.incomplete)return;this.#V=this.#V.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#B?.(e.key)}}#we(){this.#H&&=(clearTimeout(this.#H),void 0)}#Te(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#Ge();break;case`ctrl-c`:this.#F=!0,this.#W?.();break;default:break}}#Ee(){this.#De(),this.#Oe(),this.#R=setInterval(()=>{this.#I=!this.#I,this.#Ge()},500),this.#R.unref?.()}#De(){this.#R&&=(clearInterval(this.#R),void 0),this.#I=!0}#Oe(){this.#I=!0}#ke(){this.#Ae(),this.#z=setInterval(()=>{this.#L+=1,this.#Ge()},90),this.#z.unref?.()}#Ae(){this.#z&&=(clearInterval(this.#z),void 0)}#je(e){e.id!==this.#ne?.id&&this.#lt(),this.#f.push(e),e.id&&this.#p.set(e.id,e)}#Me(e){this.#je({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#Ge()}#Ne(e){if(e!=null){if(this.#ie===e){this.#ie=void 0;return}this.#je({kind:`user`,body:stripTerminalControls(e),live:!1})}}#Pe(e,t,r){let i={kind:`error`,title:stripTerminalControls(e),body:stripTerminalControls(t),live:!1};r!==void 0&&(i.detail=stripTerminalControls(r)),this.#je(i),this.#Ge()}#Fe(e,t){this.#v.has(e)||(this.#v.add(e),this.#je({id:subagentHeaderId(e),kind:`subagent`,title:stripTerminalControls(t),live:!1}))}#Ie(e){if(e.id&&this.#m.has(e.id))return;let t=e.id?this.#p.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#je(e)}#Le(e){this.#f=this.#f.filter(t=>t.id!==e),this.#p.delete(e)}#Re(){for(let e of this.#f)e.status!==`approval`&&(e.live=!1)}#ze(e,t,r){switch(e.type){case`step-start`:this.#Be(r.hasPendingToolResults?STATUS.toolResults:STATUS.processing),r.hasPendingToolResults=!1;break;case`step-finish`:this.#We(e.usage),this.#Ge();break;case`assistant-delta`:{this.#Be(STATUS.streaming);let t=(r.text.get(e.id)??``)+stripTerminalControls(e.delta);r.text.set(e.id,t),this.#Ve(e.id,t,!0);break}case`assistant-complete`:{let t=r.text.get(e.id)??``,i=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;r.text.set(e.id,i),this.#Ve(e.id,i,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;this.#Be(STATUS.streaming);let i=(r.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);r.reasoning.set(e.id,i),this.#He(e.id,i,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let n=r.reasoning.get(e.id)??``;this.#He(e.id,n,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#Be(STATUS.executingTools),this.#Ue({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,r);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let n=r.tools.get(e.toolCallId);if(n===void 0)break;this.#Ue({...n,status:`approval`},t,r);break}case`tool-result`:{if(t.tools===`hidden`)break;let n=r.tools.get(e.toolCallId);if(n===void 0)break;r.hasPendingToolResults=!0,this.#Be(STATUS.toolResults),this.#Ue({...n,output:e.output,status:`done`},t,r);break}case`tool-error`:{if(t.tools===`hidden`)break;let n=r.tools.get(e.toolCallId);if(n===void 0)break;r.hasPendingToolResults=!0,this.#Be(STATUS.toolResults),this.#Ue({...n,errorText:e.errorText,status:`error`},t,r);break}case`error`:this.#Pe(`Error`,e.errorText,e.detail);break;case`finish`:this.#We(e.usage),this.#Ge();break}}#Be(e){let t=this.#C>0?STATUS.connectionAuth:e;this.#M!==t&&(this.#M=t,this.#Ge())}#Ve(e,t,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Ie({id:e,kind:`assistant`,body:i,live:r}),this.#Ge())}#He(e,t,r,i){let a=stripTerminalControls(t).trim();a.length!==0&&(this.#Ie({id:e,kind:`reasoning`,body:a,collapsed:collapseReasoning(i.reasoning,r),live:r}),this.#Ge())}#Ue(e,t,n){if(n.tools.set(e.toolCallId,e),this.#g.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#_.set(e.toolCallId,r),this.#Ie(renderNativeToolBlock(e,r,t.tools===`full`)),this.#Ge()}#We(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#q=(t??0)+(n??0)),this.#J=t??this.#J,this.#X=n??this.#X,this.#X!=null&&this.#Q!==void 0){let e=(Date.now()-this.#Q)/1e3;e>0&&(this.#Z=this.#X/e)}}#Ge(){if(this.#P){if(this.#G){this.#K=!0;return}this.#G=!0;try{do this.#K=!1,this.#Ke();while(this.#K)}finally{this.#G=!1}}}#Ke(){if(!this.#P)return;let e=this.#tt(),t=this.#Qe(e),n=Math.max(1,this.#nt()-t.length),r=[],i=this.#S;for(;this.#f.length>0&&this.#f[0].live===!1;){let t=this.#f.shift();if(this.#h.push(t),t.id&&(this.#m.add(t.id),this.#p.delete(t.id)),this.#dt(t))continue;let n=this.#Xe(t,e,i);i=previousBlockOf(t),this.#S=i,r.push(...n),this.#x.push(...n)}let a=[];for(let t of this.#f){if(this.#dt(t))continue;let n=this.#Xe(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)a.push({block:t,row:n[e]})}let o=[...clipLiveRows(a.map(e=>e.row),n,e,this.#r),...t];r.length>0?this.#n.flush(r,o):this.#n.update(o)}#qe(){if(!this.#P)return;let e=this.#tt(),t=this.#Qe(e),n=Math.max(1,this.#nt()-t.length),r=this.#S,i=[];for(let t of this.#f){if(this.#dt(t))continue;let n=this.#Xe(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#r),...t];this.#n.clearAll(),this.#n.flush([...this.#Ye(),...this.#x],a)}logDisplayMode(){return this.#d}setLogDisplayMode(e){e!==this.#d&&(this.#d=e,this.#Je(),this.#P&&this.#qe())}#Je(){let e=this.#tt();this.#x.length=0;let t;for(let n of this.#h){if(this.#dt(n))continue;let r=this.#Xe(n,e,t);t=previousBlockOf(n),this.#x.push(...r)}this.#S=t}#Ye(){let e=this.#y;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#tt()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#Xe(e,t,n){let r={spinner:this.#Ze()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#Ze(){return this.#r.spinner[this.#L%this.#r.spinner.length]??``}#Qe(e){let t=this.#r.colors,n=[``],r=this.#ae;if(r!==void 0){let t={title:r.title,lines:r.lines,frame:this.#Ze()};return r.question===void 0?(r.status!==void 0&&(t.status={text:r.status,frame:this.#Ze()}),r.preview!==void 0&&(t.preview=r.preview)):t.question=r.question(e),n.push(...renderFlowPanel(t,this.#r,e)),n}if(this.#k){this.#A!==void 0&&isTypeaheadOpen(this.#A)&&n.push(...renderCommandSuggestions(this.#A,this.#r,e));let r=Math.max(4,e-3),{before:i,after:a}=visibleLine({text:this.#T,cursor:this.#E},r,this.#r.glyph.ellipsis),o=isPromptControlCommand(this.#T),style=e=>o&&e.length>0?t.blue(e):e,s=this.#I?t.cyan(this.#r.glyph.caret):` `,l=this.#T.length===0&&this.#D!==void 0?`${s}${t.dim(this.#D)}`:`${style(i)}${s}${style(a)}`;return n.push(clip(`${t.cyan(this.#r.glyph.prompt)} ${l}`,e)),this.#$e(n,e),n}let i=this.#j?t.yellow(this.#Ze()):t.dim(this.#r.glyph.dot),a=this.#M.length>0?this.#M:`Ready`,o=this.#j?t.dim(a):a,s=this.#et(),l=s?`${i} ${o} ${t.dim(this.#r.glyph.dot)} ${s}`:`${i} ${o}`;return n.push(clip(l,e)),this.#$e(n,e),n}#$e(e,t){let n={theme:this.#r,width:t},r=this.#y?.info?.agent.model.id;r!==void 0&&(n.model=r);let i={inputTokens:this.#J??0,outputTokens:this.#X??0};this.#Y!==void 0&&(i.contextSize=this.#Y),n.tokens=formatTokenFlow(i,this.#r.glyph),this.#w!==void 0&&(n.vercel=this.#w);let a=buildStatusLine(n);a!==void 0&&e.push(a)}#et(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#q,outputTokens:this.#X,tokensPerSecond:this.#Z},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#tt(){return Math.max(20,this.#t.columns||80)}#nt(){return Math.max(8,this.#t.rows||24)}#rt(){if(this.#$!==void 0||!this.#u)return;this.#ee=``,this.#te=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#at(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#$=()=>{e(),t()}}#it(){let e=this.#$;e!==void 0&&(this.#$=void 0,e(),this.#ee.length>0&&(this.#ut(`stdout`)&&process.stdout.write(`${this.#ee}\n`),this.#ee=``),this.#te.length>0&&(this.#ut(`stderr`)&&process.stderr.write(`${this.#te}\n`),this.#te=``))}#at(e,n){let r=(e===`stdout`?this.#ee:this.#te)+n,i=r.lastIndexOf(`
3
+ `),a=i===-1?r:r.slice(i+1);if(e===`stdout`?this.#ee=a:this.#te=a,i===-1)return;let o=stripAnsi(r.slice(0,i)).replace(/\s+$/u,``);o.trim().length!==0&&(e===`stdout`?this.#ot(o):this.#je({kind:`log`,title:e,body:o,live:!1}),this.#Ge())}#ot(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
4
4
  `);t=[],e.trim().length!==0&&this.#je({kind:`log`,title:`stdout`,body:e,live:!1})};for(let n of e.split(`
5
- `)){let e=parseDevRebuildLogLine(n.trimEnd());if(e===void 0){t.push(n);continue}flushPending(),this.#st(e,n.trimEnd())}flushPending()}#st(e,t){let n=this.#ct();if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#re}`;this.#re+=1,this.#ne={id:r,summary:t},this.#je({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}if(n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind);return}this.#je({kind:`log`,title:`stdout`,body:t,live:!1})}#ct(){let e=this.#ne;if(e===void 0)return;let t=this.#p.get(e.id);if(!(t===void 0||t.live!==!0))return{state:e,block:t}}#lt(){let e=this.#ne;if(e===void 0)return;this.#ne=void 0;let t=this.#p.get(e.id);t!==void 0&&(t.live=!1)}#ut(e){switch(this.#d){case`none`:return!1;case`stderr`:return e===`stderr`;case`all`:return!0}}#dt(e){return e.kind===`log`?!this.#ut(e.title===`stderr`?`stderr`:`stdout`):!1}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}async function*iterateTUIStream(e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}return}yield*e}function clip(e,t){return visibleLength(e)>t?sliceVisible(e,t):e}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function leadsWithGap(e,t){if(e.kind===`log`&&t?.kind===`log`)return t.title!==e.title;if(t?.kind===`log`&&e.kind!==`log`)return!0;switch(e.kind){case`user`:case`assistant`:case`reasoning`:case`subagent`:case`error`:case`notice`:case`question`:case`connection-auth`:case`log`:case`command`:case`warning`:case`flow`:case`agent-header`:return!0;default:return!1}}function clipLiveRows(e,t,n,r){if(e.length<=t)return[...e];if(t<=1)return[clip(hiddenRowsMarker(e.length,r),n)];let i=t-1;return[clip(hiddenRowsMarker(e.length-i,r),n),...e.slice(e.length-i)]}function hiddenRowsMarker(e,t){let n=e.toLocaleString(),r=e===1?`row`:`rows`;return t.colors.dim(`${t.glyph.dot} ${t.glyph.ellipsis} ${n} earlier ${r} hidden while streaming`)}function collapseReasoning(e,t){switch(e){case`collapsed`:return!0;case`auto-collapsed`:return!t;default:return!1}}function renderNativeToolBlock(n,r,i){let a={id:r,kind:`tool`,title:n.toolName,subtitle:summarizeToolArgs(n.input),status:n.status,live:n.status===`running`||n.status===`approval`,expanded:i,toolInput:n.input};return n.output===void 0?n.errorText!==void 0&&(a.result=n.errorText):(a.result=summarizeToolResult(n.output),a.toolOutput=n.output),a}function subagentToolStatus(e){switch(e){case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`}}function formatToolApprovalTitle(e){return e.title??e.toolName}function toolSectionId(e){return`tool:${e}`}function questionSectionId(e){return`question:${e}`}function subagentHeaderId(e){return`subagent:${e}:header`}function subagentStepSectionId(e,t){return`subagent:${e}:step:${t}`}function subagentToolSectionId(e,t){return`subagent:${e}:tool:${t}`}function connectionAuthSectionId(e){return`connection-auth:${e}`}function formatConnectionAuthContent(e){let t=[];e.description.length>0&&t.push(e.description);let n=e.challenge;return n?.url&&t.push(`URL: ${n.url}`),n?.userCode&&t.push(`Code: ${n.userCode}`),n?.expiresAt&&t.push(`Expires: ${n.expiresAt}`),n?.instructions&&t.push(n.instructions),e.reason!==void 0&&e.reason.length>0&&t.push(`Reason: ${e.reason}`),t.join(`
6
- `)}function formatQuestionContent(e,t,n){let r=n.colors,i=[],a=e.options??[];if(a.length>0){for(let[e,o]of a.entries()){let a=o.description?` ${r.dim(`— ${o.description}`)}`:``,s=t===e,c=s?`${r.cyan(n.glyph.pointer)} `:` `,l=s?r.cyan(o.label):o.label;i.push(`${c}${l}${a}`)}if(e.allowFreeform===!0){let e=t===a.length,o=e?`${r.cyan(n.glyph.pointer)} `:` `,s=`Type your own answer`;i.push(`${o}${e?r.cyan(s):r.dim(s)}`)}}else i.push(r.dim(` (type your answer)`));return i.join(`
5
+ `)){let e=parseDevRebuildLogLine(n.trimEnd());if(e===void 0){t.push(n);continue}flushPending(),this.#st(e,n.trimEnd())}flushPending()}#st(e,t){let n=this.#ct();if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#re}`;this.#re+=1,this.#ne={id:r,summary:t},this.#je({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}if(n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind);return}this.#je({kind:`log`,title:`stdout`,body:t,live:!1})}#ct(){let e=this.#ne;if(e===void 0)return;let t=this.#p.get(e.id);if(!(t===void 0||t.live!==!0))return{state:e,block:t}}#lt(){let e=this.#ne;if(e===void 0)return;this.#ne=void 0;let t=this.#p.get(e.id);t!==void 0&&(t.live=!1)}#ut(e){switch(this.#d){case`none`:return!1;case`stderr`:return e===`stderr`;case`all`:return!0}}#dt(e){return e.kind===`log`?!this.#ut(e.title===`stderr`?`stderr`:`stdout`):!1}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}async function*iterateTUIStream(e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}return}yield*e}function clip(t,n){return visibleLength(t)>n?sliceVisible(t,n):t}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function leadsWithGap(e,t){if(e.kind===`log`&&t?.kind===`log`)return t.title!==e.title;if(t?.kind===`log`&&e.kind!==`log`)return!0;switch(e.kind){case`user`:case`assistant`:case`reasoning`:case`subagent`:case`error`:case`notice`:case`question`:case`connection-auth`:case`log`:case`command`:case`warning`:case`flow`:case`agent-header`:return!0;default:return!1}}function clipLiveRows(e,t,n,r){if(e.length<=t)return[...e];if(t<=1)return[clip(hiddenRowsMarker(e.length,r),n)];let i=t-1;return[clip(hiddenRowsMarker(e.length-i,r),n),...e.slice(e.length-i)]}function hiddenRowsMarker(e,t){let n=e.toLocaleString(),r=e===1?`row`:`rows`;return t.colors.dim(`${t.glyph.dot} ${t.glyph.ellipsis} ${n} earlier ${r} hidden while streaming`)}function collapseReasoning(e,t){switch(e){case`collapsed`:return!0;case`auto-collapsed`:return!t;default:return!1}}function renderNativeToolBlock(e,t,r){let o={id:t,kind:`tool`,title:stripTerminalControls(e.toolName),subtitle:summarizeToolArgs(e.input),status:e.status,live:e.status===`running`||e.status===`approval`,expanded:r,toolInput:e.input};return e.output===void 0?e.errorText!==void 0&&(o.result=stripTerminalControls(e.errorText)):(o.result=summarizeToolResult(e.output),o.toolOutput=e.output),o}function subagentToolStatus(e){switch(e){case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`}}function formatToolApprovalTitle(e){return stripTerminalControls(e.title??e.toolName)}function toolSectionId(e){return`tool:${e}`}function questionSectionId(e){return`question:${e}`}function subagentHeaderId(e){return`subagent:${e}:header`}function subagentStepSectionId(e,t){return`subagent:${e}:step:${t}`}function subagentToolSectionId(e,t){return`subagent:${e}:tool:${t}`}function connectionAuthSectionId(e){return`connection-auth:${e}`}function formatConnectionAuthContent(e){let t=[],r=stripTerminalControls(e.description);r.length>0&&t.push(r);let i=e.challenge;if(i?.url&&t.push(`URL: ${stripTerminalControls(i.url)}`),i?.userCode&&t.push(`Code: ${stripTerminalControls(i.userCode)}`),i?.expiresAt&&t.push(`Expires: ${stripTerminalControls(i.expiresAt)}`),i?.instructions&&t.push(stripTerminalControls(i.instructions)),e.reason!==void 0){let r=stripTerminalControls(e.reason);r.length>0&&t.push(`Reason: ${r}`)}return t.join(`
6
+ `)}function formatQuestionContent(e,t,r){let i=r.colors,a=[],o=e.options??[];if(o.length>0){for(let[e,s]of o.entries()){let o=stripTerminalControls(s.label),c=s.description===void 0?``:stripTerminalControls(s.description),l=c.length>0?` ${i.dim(`— ${c}`)}`:``,u=t===e,d=u?`${i.cyan(r.glyph.pointer)} `:` `,f=u?i.cyan(o):o;a.push(`${d}${f}${l}`)}if(e.allowFreeform===!0){let e=t===o.length,n=e?`${i.cyan(r.glyph.pointer)} `:` `,s=`Type your own answer`;a.push(`${n}${e?i.cyan(s):i.dim(s)}`)}}else a.push(i.dim(` (type your answer)`));return a.join(`
7
7
  `)}function resolveQuestionText(e,t){let n=e.trim();if(n.length===0)return;let r=n.toLowerCase(),i=t.options??[];if(i.length>0){let e=matchQuestionOption(r,i);if(e!==void 0)return{optionId:e.id,label:e.label}}if(t.allowFreeform===!0||i.length===0)return{text:n,label:n}}function matchQuestionOption(e,t){let n=t.find(t=>t.id.toLowerCase()===e);if(n!==void 0)return n;let r=t.find(t=>t.label.toLowerCase()===e);if(r!==void 0)return r;let i=Number(e);if(Number.isInteger(i)&&i>0&&i<=t.length)return t[i-1]}export{TerminalRenderer};
@@ -1,6 +1,7 @@
1
1
  export declare const ansiPattern: RegExp;
2
2
  export declare const ansiPrefixPattern: RegExp;
3
3
  export declare function stripAnsi(input: string): string;
4
+ export declare function stripTerminalControls(input: string): string;
4
5
  export declare function visibleLength(input: string): number;
5
6
  export declare function sliceVisible(input: string, width: number): string;
6
7
  /**
@@ -1 +1 @@
1
- const ansiPattern=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`),ansiPrefixPattern=RegExp(`^\x1B\\[[0-?]*[ -/]*[@-~]`);function stripAnsi(t){return t.replaceAll(ansiPattern,``)}function visibleLength(e){let n=0,r=0;for(;r<e.length;){let i=e.slice(r).match(ansiPrefixPattern);if(i){r+=i[0].length;continue}let a=e.codePointAt(r);if(a==null)break;let o=String.fromCodePoint(a);n+=codePointWidth(a),r+=o.length}return n}function sliceVisible(e,n){if(n<=0)return``;let r=``,i=0,a=0;for(;a<e.length&&i<n;){let o=e.slice(a).match(ansiPrefixPattern);if(o){r+=o[0],a+=o[0].length;continue}let s=e.codePointAt(a);if(s==null)break;let c=String.fromCodePoint(s),l=codePointWidth(s);if(l>0&&i+l>n)break;r+=c,a+=c.length,i+=l}for(;a<e.length;){let n=e.slice(a).match(ansiPrefixPattern);if(!n)break;r+=n[0],a+=n[0].length}return r}function wrapVisibleLine(e,t){if(t<=0)return[e];if(e.length===0)return[``];let n=[],r=e;for(;visibleLength(r)>t;){let e=findVisibleBreakPoint(r,t);n.push(r.slice(0,e).trimEnd()),r=r.slice(e).trimStart()}return n.push(r),n}function findVisibleBreakPoint(e,t){let n=sliceVisible(e,t+1).lastIndexOf(` `);return n>0?n:sliceVisible(e,t).length}function codePointWidth(e){return e===9?4:e<32||e>=127&&e<160||isZeroWidthCodePoint(e)?0:isWideCodePoint(e)?2:1}function isZeroWidthCodePoint(e){return e>=768&&e<=879||e>=1155&&e<=1161||e>=1425&&e<=1469||e===1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e===1479||e>=1552&&e<=1562||e>=1611&&e<=1631||e===1648||e>=1750&&e<=1756||e>=1759&&e<=1764||e>=1767&&e<=1768||e>=1770&&e<=1773||e===1809||e>=1840&&e<=1866||e>=1958&&e<=1968||e>=2027&&e<=2035||e>=2070&&e<=2073||e>=2075&&e<=2083||e>=2085&&e<=2087||e>=2089&&e<=2093||e>=2137&&e<=2139||e>=2259&&e<=2306||e===2362||e===2364||e>=2369&&e<=2376||e===2381||e>=2385&&e<=2391||e===8205||e>=65024&&e<=65039||e>=917760&&e<=917999}function isWideCodePoint(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}export{ansiPattern,ansiPrefixPattern,codePointWidth,sliceVisible,stripAnsi,visibleLength,wrapVisibleLine};
1
+ const ansiPattern=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`),ansiPrefixPattern=RegExp(`^\x1B\\[[0-?]*[ -/]*[@-~]`);function stripAnsi(t){return stripTerminalControls(t.replaceAll(ansiPattern,``))}function stripTerminalControls(e){let t=``,n=0;for(;n<e.length;){let r=e.codePointAt(n);if(r==null)break;let i=String.fromCodePoint(r);n+=i.length,!isUnsafeTerminalControlCodePoint(r)&&(t+=i)}return t}function visibleLength(e){let n=0,r=0;for(;r<e.length;){let i=e.slice(r).match(ansiPrefixPattern);if(i){r+=i[0].length;continue}let a=e.codePointAt(r);if(a==null)break;let o=String.fromCodePoint(a);n+=codePointWidth(a),r+=o.length}return n}function sliceVisible(e,n){if(n<=0)return``;let r=``,i=0,a=0;for(;a<e.length&&i<n;){let o=e.slice(a).match(ansiPrefixPattern);if(o){r+=o[0],a+=o[0].length;continue}let s=e.codePointAt(a);if(s==null)break;let c=String.fromCodePoint(s),l=codePointWidth(s);if(l>0&&i+l>n)break;r+=c,a+=c.length,i+=l}for(;a<e.length;){let n=e.slice(a).match(ansiPrefixPattern);if(!n)break;r+=n[0],a+=n[0].length}return r}function wrapVisibleLine(e,t){if(t<=0)return[e];if(e.length===0)return[``];let n=[],r=e;for(;visibleLength(r)>t;){let e=findVisibleBreakPoint(r,t);n.push(r.slice(0,e).trimEnd()),r=r.slice(e).trimStart()}return n.push(r),n}function findVisibleBreakPoint(e,t){let n=sliceVisible(e,t+1).lastIndexOf(` `);return n>0?n:sliceVisible(e,t).length}function codePointWidth(e){return e===9?4:e<32||e>=127&&e<160||isZeroWidthCodePoint(e)?0:isWideCodePoint(e)?2:1}function isUnsafeTerminalControlCodePoint(e){return e>=0&&e<=8||e>=11&&e<=31||e>=127&&e<=159}function isZeroWidthCodePoint(e){return e>=768&&e<=879||e>=1155&&e<=1161||e>=1425&&e<=1469||e===1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e===1479||e>=1552&&e<=1562||e>=1611&&e<=1631||e===1648||e>=1750&&e<=1756||e>=1759&&e<=1764||e>=1767&&e<=1768||e>=1770&&e<=1773||e===1809||e>=1840&&e<=1866||e>=1958&&e<=1968||e>=2027&&e<=2035||e>=2070&&e<=2073||e>=2075&&e<=2083||e>=2085&&e<=2087||e>=2089&&e<=2093||e>=2137&&e<=2139||e>=2259&&e<=2306||e===2362||e===2364||e>=2369&&e<=2376||e===2381||e>=2385&&e<=2391||e===8205||e>=65024&&e<=65039||e>=917760&&e<=917999}function isWideCodePoint(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}export{ansiPattern,ansiPrefixPattern,codePointWidth,sliceVisible,stripAnsi,stripTerminalControls,visibleLength,wrapVisibleLine};
@@ -20,7 +20,7 @@ export declare function summarizeToolArgs(input: unknown, maxLength?: number): s
20
20
  export declare function summarizeToolResult(output: unknown, maxLength?: number): string;
21
21
  /**
22
22
  * Pretty-prints a value across multiple lines for the expanded `--tools full`
23
- * view. Strings pass through verbatim; everything else is JSON with 2-space
23
+ * view. Strings render directly; everything else is JSON with 2-space
24
24
  * indentation.
25
25
  */
26
26
  export declare function formatValuePretty(value: unknown): string;
@@ -1,2 +1,2 @@
1
- function summarizeToolArgs(e,t=80){if(e==null)return``;if(typeof e!=`object`)return truncate(formatScalar(e),t);if(Array.isArray(e))return truncate(`[${e.length}]`,t);let n=Object.entries(e);if(n.length===0)return``;let r=[];for(let[e,t]of n)r.push(`${e}=${formatInlineValue(t)}`);return truncate(r.join(` `),t)}function summarizeToolResult(e,t=80){if(e==null)return``;if(typeof e==`string`)return truncate((e.split(`
2
- `).find(e=>e.trim().length>0)??``).trim(),t);if(typeof e!=`object`)return truncate(formatScalar(e),t);if(Array.isArray(e))return truncate(`${e.length} ${e.length===1?`item`:`items`}`,t);let n=e;for(let e of[`result`,`text`,`message`,`summary`,`value`,`output`]){let r=n[e];if(r!==void 0&&typeof r!=`object`)return truncate(`${formatScalar(r)}`,t)}let r=Object.keys(n);if(r.length===0)return`{}`;let i=r.slice(0,3).map(e=>`${e}=${formatInlineValue(n[e])}`).join(` `);return truncate(r.length>3?`${i} …`:i,t)}function formatValuePretty(e){if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)??String(e)}catch{return String(e)}}function formatInlineValue(e){return e===void 0?`undefined`:e===null?`null`:typeof e==`string`?`"${truncate(e,32)}"`:typeof e==`object`?Array.isArray(e)?`[${e.length}]`:`{…}`:formatScalar(e)}function formatScalar(e){return typeof e==`string`?e:String(e)}function truncate(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`}export{formatValuePretty,summarizeToolArgs,summarizeToolResult,truncate};
1
+ import{stripTerminalControls}from"./terminal-text.js";function summarizeToolArgs(t,n=80){if(t==null)return``;if(typeof t!=`object`)return truncate(formatScalar(t),n);if(Array.isArray(t))return truncate(`[${t.length}]`,n);let r=Object.entries(t);if(r.length===0)return``;let i=[];for(let[t,n]of r)i.push(`${stripTerminalControls(t)}=${formatInlineValue(n)}`);return truncate(i.join(` `),n)}function summarizeToolResult(e,t=80){if(e==null)return``;if(typeof e==`string`)return truncate((e.split(`
2
+ `).find(e=>e.trim().length>0)??``).trim(),t);if(typeof e!=`object`)return truncate(formatScalar(e),t);if(Array.isArray(e))return truncate(`${e.length} ${e.length===1?`item`:`items`}`,t);let n=e;for(let e of[`result`,`text`,`message`,`summary`,`value`,`output`]){let r=n[e];if(r!==void 0&&typeof r!=`object`)return truncate(`${formatScalar(r)}`,t)}let r=Object.keys(n);if(r.length===0)return`{}`;let i=r.slice(0,3).map(e=>`${e}=${formatInlineValue(n[e])}`).join(` `);return truncate(r.length>3?`${i} …`:i,t)}function formatValuePretty(t){if(typeof t==`string`)return stripTerminalControls(t);try{return stripTerminalControls(JSON.stringify(t,null,2)??String(t))}catch{return stripTerminalControls(String(t))}}function formatInlineValue(e){return e===void 0?`undefined`:e===null?`null`:typeof e==`string`?`"${truncate(e,32)}"`:typeof e==`object`?Array.isArray(e)?`[${e.length}]`:`{…}`:formatScalar(e)}function formatScalar(t){return stripTerminalControls(typeof t==`string`?t:String(t))}function truncate(t,n){let r=stripTerminalControls(t).replace(/\s+/g,` `).trim();return r.length<=n?r:`${r.slice(0,Math.max(0,n-1)).trimEnd()}…`}export{formatValuePretty,summarizeToolArgs,summarizeToolResult,truncate};
@@ -51,8 +51,6 @@ interface EvalCliOptions {
51
51
  junit?: string;
52
52
  list?: boolean;
53
53
  maxConcurrency?: string;
54
- mockModels?: boolean;
55
- noSkips?: boolean;
56
54
  skipReport?: boolean;
57
55
  strict?: boolean;
58
56
  tag?: string[];
@@ -1,3 +1,3 @@
1
1
  import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{basename}from"node:path";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{eveCliBanner}from"#cli/banner.js";import{Command,CommanderError,InvalidArgumentError}from"#compiled/commander/index.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";async function loadBuildHost(){return(await import(`#internal/nitro/host.js`)).buildApplication}async function loadPrintApplicationInfo(){return(await import(`#cli/commands/info.js`)).printApplicationInfo}async function loadRunDevelopmentTui(){return(await import(`#cli/dev/tui/tui.js`)).runDevelopmentTui}async function loadRunEvalCommand(){return(await import(`#evals/cli/eval.js`)).runEvalCommand}async function loadStartHost(){return(await import(`#internal/nitro/host.js`)).startDevelopmentServer}async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function shouldPrintCliBootBanner(e){return e.name()===`info`||e.name()===`dev`||e.name()===`init`}async function waitForShutdownSignal(e){await new Promise((t,n)=>{let r=!1,cleanup=()=>{process.off(`SIGINT`,handleSignal),process.off(`SIGTERM`,handleSignal)},handleSignal=()=>{r||(r=!0,cleanup(),e.close().then(t,n))};process.once(`SIGINT`,handleSignal),process.once(`SIGTERM`,handleSignal)})}async function waitForProductionServer(e){await Promise.race([e.wait(),waitForShutdownSignal({close:()=>e.close()})])}function parsePortOption(e){if(!/^-?\d+$/.test(e))throw new InvalidArgumentError(`Expected a numeric port, received "${e}".`);let t=Number(e);if(t<0||t>65535)throw new InvalidArgumentError(`Expected a port between 0 and 65535, received "${e}".`);return t}const DISPLAY_MODES=new Set([`full`,`collapsed`,`auto-collapsed`,`hidden`]),STATS_MODES=new Set([`tokens`,`tokensPerSecond`]),LOG_MODES=new Set([`all`,`stderr`,`none`]);function parseDisplayMode(e){if(!DISPLAY_MODES.has(e))throw new InvalidArgumentError(`Expected one of ${[...DISPLAY_MODES].join(`, `)}, received "${e}".`);return e}function parseStatsMode(e){if(!STATS_MODES.has(e))throw new InvalidArgumentError(`Expected one of ${[...STATS_MODES].join(`, `)}, received "${e}".`);return e}function parseLogsMode(e){if(!LOG_MODES.has(e))throw new InvalidArgumentError(`Expected one of ${[...LOG_MODES].join(`, `)}, received "${e}".`);return e}function parseContextSizeOption(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)throw new InvalidArgumentError(`Expected a positive number, received "${e}".`);return t}function resolveDevUiMode(e){return e.options.ui===!1||!e.interactive?`headless`:`tui`}function resolveTuiTitle(e){if(e.name!==void 0&&e.name.length>0)return e.name;if(e.remoteServerUrl!==void 0)try{return new URL(e.remoteServerUrl).host}catch{return}let n=humanizeProjectName(basename(e.appRoot));return n.length>0?n:void 0}function humanizeProjectName(e){return e.replace(/[-_.]+/gu,` `).trim().split(/\s+/u).filter(e=>e.length>0).map(e=>e[0].toUpperCase()+e.slice(1)).join(` `)}function resolveTuiDisplayOptions(e){let t={reasoning:e.reasoning??`full`,tools:e.tools??`auto-collapsed`};return e.subagents!==void 0&&(t.subagents=e.subagents),e.connectionAuth!==void 0&&(t.connectionAuth=e.connectionAuth),e.assistantResponseStats!==void 0&&(t.assistantResponseStats=e.assistantResponseStats),e.contextSize!==void 0&&(t.contextSize=e.contextSize),e.logs!==void 0&&(t.logs=e.logs),t}function hasInteractiveTerminal(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function rewriteDevelopmentUrlShorthand(e){let t=e[1];return e[0]!==`dev`||e.length!==2||t===void 0||t.startsWith(`-`)?[...e]:[`dev`,`--url`,t]}function resolveRemoteDevelopmentServerUrl(e){if(e.url){if(e.host!==void 0)throw new InvalidArgumentError(`The --host option cannot be used with --url.`);if(e.port!==void 0)throw new InvalidArgumentError(`The --port option cannot be used with --url.`);if(e.ui===!1)throw new InvalidArgumentError(`The --no-ui option cannot be used with --url.`);return e.url}}function createCliProgram(t,o){let s=resolveApplicationRoot(),l=resolveInstalledPackageInfo().version,u=new Command,d=createCliTheme();u.name(`eve`).description(`Build and run an Eve application.`).version(l).showHelpAfterError().exitOverride().hook(`preAction`,(e,n)=>{shouldPrintCliBootBanner(n)&&t.log(eveCliBanner())}).configureOutput({writeErr:e=>{t.error(e.trimEnd())},writeOut:e=>{t.log(e.trimEnd())}});let f=u.command(`channels`).description(`Manage user-authored channels in the current project.`);return f.command(`add [kind]`).description(`Add channels interactively, or scaffold a channel kind (slack | web).`).option(`-f, --force`,`Overwrite existing channel files`).option(`-y, --yes`,`Assume yes for confirmations; requires an explicit channel kind`).action(async(e,n)=>{let{runChannelsAddCommand:r}=await import(`#cli/commands/channels.js`);await r(t,s,{kind:e,options:n})}),f.command(`list`).description(`List user-authored channels in the current project.`).option(`--json`,`Output as JSON`).action(async e=>{let{runChannelsListCommand:n}=await import(`#cli/commands/channels.js`);await n(t,s,e)}),u.command(`init <target>`).description(`Create a new Eve agent, or add one to an existing project directory.`).option(`--channel-web-nextjs`,`Add the Web Chat application (Next.js)`).action(async(e,n)=>{let{runInitCommand:r}=await import(`#cli/commands/init.js`);await r(t,s,e,n)}),registerProjectCommands({program:u,logger:t,appRoot:s}),u.command(`build`).description(`Build the current Eve application.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:e}=await import(`#cli/dev/environment.js`);e(s);let n=await(o.buildHost??await loadBuildHost())(s);t.log(renderCliTaggedLine(d,{message:`built output at ${n}`,tag:`build`,tone:`success`}))}),u.command(`start`).description(`Start a built Eve application.`).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,parsePortOption).action(async e=>{let{loadDevelopmentEnvironmentFiles:n}=await import(`#cli/dev/environment.js`);n(s);let i=await(o.startProductionHost??await loadStartProductionHost())(s,{host:e.host,port:e.port});t.log(renderCliTaggedLine(d,{message:`server listening at ${i.url}`,tag:`start`,tone:`success`})),await waitForProductionServer(i)}),u.command(`dev`).description(`Start the Eve development server or connect to an existing URL.`).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,parsePortOption).option(`-u, --url <url>`,`Connect to an existing server URL`,parseDevelopmentServerUrl).option(`--no-ui`,`Start the server without an interactive UI`).option(`--name <name>`,`Title shown in the terminal UI (defaults to the app folder name)`).option(`--tools <mode>`,`How tool calls render: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--reasoning <mode>`,`How reasoning renders: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--subagents <mode>`,`How subagent sections render: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--connection-auth <mode>`,`How connection authorization renders: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--assistant-response-stats <mode>`,`Assistant header statistic: tokens | tokensPerSecond`,parseStatsMode).option(`--context-size <tokens>`,`Model context window size, shown as a usage percentage`,parseContextSizeOption).option(`--logs <mode>`,`Which server/agent logs to show: all | stderr | none`,parseLogsMode).addHelpText(`after`,`
2
2
  You can also pass a bare URL as the only argument, for example: eve dev https://example.com
3
- `).action(async e=>{let n=resolveRemoteDevelopmentServerUrl(e),{loadDevelopmentEnvironmentFiles:i}=await import(`#cli/dev/environment.js`);i(s);let runInteractiveUi=async r=>{t.log(``);let i=o.runDevelopmentTui??await loadRunDevelopmentTui(),a=resolveTuiDisplayOptions(e),c=resolveTuiTitle({name:e.name,remoteServerUrl:n,appRoot:s});c!==void 0&&(a.name=c),await i(n===void 0?{serverUrl:r,appRoot:s,...a}:{serverUrl:r,...a})};if(n){if(t.log(renderCliTaggedLine(d,{message:`connecting to ${n}`,tag:`dev`,tone:`info`})),resolveDevUiMode({options:e,interactive:hasInteractiveTerminal()})===`headless`){t.log(renderCliTaggedLine(d,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}await runInteractiveUi(n);return}let a=await(o.startHost??await loadStartHost())(s,{host:e.host,port:e.port}),c=!1,closeServer=async()=>{c||(c=!0,await a.close())};try{let n=hasInteractiveTerminal(),i=resolveDevUiMode({options:e,interactive:n});if(i!==`tui`&&t.log(renderCliTaggedLine(d,{message:`server listening at ${a.url}`,tag:`dev`,tone:`success`})),i===`headless`)return e.ui!==!1&&!n&&t.log(renderCliTaggedLine(d,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await waitForShutdownSignal({close:closeServer});await runInteractiveUi(a.url)}finally{await closeServer()}}),u.command(`info`).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async e=>{await(o.printApplicationInfo??await loadPrintApplicationInfo())(t,s,e)}),u.command(`eval`).description(`Run evals against an Eve agent.`).argument(`[evalIds...]`,`Eval ids (or directory prefixes) to run (all discovered evals when omitted)`).option(`--url <url>`,`Remote agent URL (skip local host startup)`).option(`--mock-models`,`Boot the local dev target with deterministic mock models`).option(`--tag <tag...>`,`Run only evals carrying a tag`).option(`--strict`,`Fail the exit code when any score falls below its threshold`).option(`--no-skips`,`Treat unmet eval requirements as failures`).option(`--list`,`Print discovered evals without running them`).option(`--timeout <ms>`,`Per-eval timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent eval executions`).option(`--json`,`Output results as JSON`).option(`--junit <path>`,`Write JUnit XML results to a file`).option(`--skip-report`,`Skip eval-defined reporters (e.g. Braintrust)`).option(`--verbose`,`Stream per-eval ctx.log lines to stdout`).action(async(e,n)=>{await(o.runEvalCommand??await loadRunEvalCommand())(e,n,t)}),u}async function runCli(e=process.argv.slice(2),t=console,n={}){let r=createCliProgram(t,n),i=e.length===0?[`dev`]:rewriteDevelopmentUrlShorthand(e);try{await r.parseAsync(i,{from:`user`})}catch(e){if(e instanceof CommanderError){if(e.exitCode===0)return;throw Error(e.message)}throw e}}export{resolveDevUiMode,resolveTuiDisplayOptions,resolveTuiTitle,runCli};
3
+ `).action(async e=>{let n=resolveRemoteDevelopmentServerUrl(e),{loadDevelopmentEnvironmentFiles:i}=await import(`#cli/dev/environment.js`);i(s);let runInteractiveUi=async r=>{t.log(``);let i=o.runDevelopmentTui??await loadRunDevelopmentTui(),a=resolveTuiDisplayOptions(e),c=resolveTuiTitle({name:e.name,remoteServerUrl:n,appRoot:s});c!==void 0&&(a.name=c),await i(n===void 0?{serverUrl:r,appRoot:s,...a}:{serverUrl:r,...a})};if(n){if(t.log(renderCliTaggedLine(d,{message:`connecting to ${n}`,tag:`dev`,tone:`info`})),resolveDevUiMode({options:e,interactive:hasInteractiveTerminal()})===`headless`){t.log(renderCliTaggedLine(d,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}await runInteractiveUi(n);return}let a=await(o.startHost??await loadStartHost())(s,{host:e.host,port:e.port}),c=!1,closeServer=async()=>{c||(c=!0,await a.close())};try{let n=hasInteractiveTerminal(),i=resolveDevUiMode({options:e,interactive:n});if(i!==`tui`&&t.log(renderCliTaggedLine(d,{message:`server listening at ${a.url}`,tag:`dev`,tone:`success`})),i===`headless`)return e.ui!==!1&&!n&&t.log(renderCliTaggedLine(d,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await waitForShutdownSignal({close:closeServer});await runInteractiveUi(a.url)}finally{await closeServer()}}),u.command(`info`).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async e=>{await(o.printApplicationInfo??await loadPrintApplicationInfo())(t,s,e)}),u.command(`eval`).description(`Run evals against an Eve agent.`).argument(`[evalIds...]`,`Eval ids (or directory prefixes) to run (all discovered evals when omitted)`).option(`--url <url>`,`Remote agent URL (skip local host startup)`).option(`--tag <tag...>`,`Run only evals carrying a tag`).option(`--strict`,`Fail the exit code when any score falls below its threshold`).option(`--list`,`Print discovered evals without running them`).option(`--timeout <ms>`,`Per-eval timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent eval executions`).option(`--json`,`Output results as JSON`).option(`--junit <path>`,`Write JUnit XML results to a file`).option(`--skip-report`,`Skip eval-defined reporters (e.g. Braintrust)`).option(`--verbose`,`Stream per-eval ctx.log lines to stdout`).action(async(e,n)=>{await(o.runEvalCommand??await loadRunEvalCommand())(e,n,t)}),u}async function runCli(e=process.argv.slice(2),t=console,n={}){let r=createCliProgram(t,n),i=e.length===0?[`dev`]:rewriteDevelopmentUrlShorthand(e);try{await r.parseAsync(i,{from:`user`})}catch(e){if(e instanceof CommanderError){if(e.exitCode===0)return;throw Error(e.message)}throw e}}export{resolveDevUiMode,resolveTuiDisplayOptions,resolveTuiTitle,runCli};
@@ -23,6 +23,7 @@ export interface CliRow {
23
23
  readonly tone?: CliMessageTone;
24
24
  readonly value: string;
25
25
  }
26
+ export declare function sanitizeForTerminal(input: string): string;
26
27
  /**
27
28
  * Creates the theme used by CLI commands and the interactive REPL.
28
29
  */
@@ -1,8 +1,8 @@
1
- import picocolors from"#compiled/picocolors/index.js";function applyTone(e,t,n){switch(t){case`accent`:return e.accent(n);case`danger`:return e.danger(n);case`info`:return e.info(n);case`muted`:return e.muted(n);case`subagent`:return e.subagent(n);case`success`:return e.success(n);case`warning`:return e.warning(n);default:return e.plain(n)}}function renderIndentedLines(e,t){let[n=``,...r]=e;return[n,...r.map(e=>`${t}${e}`)]}function renderOrangeText(e){return e.color?`\u001B[38;5;208m${e.text}\u001B[39m`:e.text}function createCliTheme(t={}){let n=picocolors.createColors(t.color??!!process.stdout.isTTY);return{accent:e=>n.cyan(e),color:n.isColorSupported,danger:e=>n.red(e),heading:e=>n.bold(n.cyan(e)),info:e=>n.blue(e),label:e=>n.bold(e),muted:e=>n.dim(e),plain:e=>e,subagent:e=>renderOrangeText({color:n.isColorSupported,text:e}),success:e=>n.green(e),warning:e=>n.yellow(e)}}function renderCliBanner(e,t){let n=[e.heading(t.title),e.muted(`=`.repeat(t.title.length))];return t.subtitle&&n.push(e.muted(t.subtitle)),n.join(`
2
- `)}function renderCliSection(e,t){let n=t.rows.reduce((e,t)=>Math.max(e,t.label.length),0),r=[e.accent(t.title)];for(let i of t.rows){let[t=``,...a]=renderIndentedLines(applyTone(e,i.tone??`default`,i.value).split(`
3
- `),`${` `.repeat(n)} `);r.push(`${e.label(i.label.padEnd(n))} ${t}`),r.push(...a)}return r.join(`
4
- `)}function renderCliTaggedLine(e,t){let n=`[${t.tag.toUpperCase()}]`,[r=``,...i]=renderIndentedLines(applyTone(e,t.tone??`default`,t.message).split(`
5
- `),`${` `.repeat(n.length)} `);return[e.muted(n),r].join(` `)+(i.length>0?`\n${i.join(`
6
- `)}`:``)}function renderCliSpeakerLine(e,t){let n=`${t.speaker}>`,[r=``,...i]=renderIndentedLines(applyTone(e,t.tone??`default`,t.message).split(`
7
- `),`${` `.repeat(n.length)} `);return[e.muted(n),r].join(` `)+(i.length>0?`\n${i.join(`
8
- `)}`:``)}export{createCliTheme,renderCliBanner,renderCliSection,renderCliSpeakerLine,renderCliTaggedLine};
1
+ import picocolors from"#compiled/picocolors/index.js";function sanitizeForTerminal(e){let t=``,n=0;for(;n<e.length;){let r=e.codePointAt(n);if(r==null)break;if(r===27){n=skipEscSequence({start:n,value:e});continue}if(r===155){n=skipCsiSequence({start:n+1,value:e});continue}if(isC1StringControlCodePoint(r)){n=skipStringControlSequence({start:n+1,value:e});continue}let i=String.fromCodePoint(r);n+=i.length,!isUnsafeControlCodePoint(r)&&(t+=i)}return t}function applyTone(e,t,n){switch(t){case`accent`:return e.accent(n);case`danger`:return e.danger(n);case`info`:return e.info(n);case`muted`:return e.muted(n);case`subagent`:return e.subagent(n);case`success`:return e.success(n);case`warning`:return e.warning(n);default:return e.plain(n)}}function renderIndentedLines(e,t){let[n=``,...r]=e;return[n,...r.map(e=>`${t}${e}`)]}function skipEscSequence(e){let t=e.start+1,n=e.value.codePointAt(t);if(n==null)return t;if(n===91)return skipCsiSequence({start:t+1,value:e.value});if(isEscStringControlIntroducer(n))return skipStringControlSequence({start:t+1,value:e.value});let r=String.fromCodePoint(n);if(isCharsetDesignationIntroducer(n)){let n=t+r.length,i=e.value.codePointAt(n);return i==null?n:n+String.fromCodePoint(i).length}return t+r.length}function skipCsiSequence(e){let t=e.start;for(;t<e.value.length;){let n=e.value.codePointAt(t);if(n==null)break;if(t+=String.fromCodePoint(n).length,n>=64&&n<=126)return t}return t}function skipStringControlSequence(e){let t=e.start;for(;t<e.value.length;){let n=e.value.codePointAt(t);if(n==null)break;let r=t+String.fromCodePoint(n).length;if(n===7||n===156)return r;if(n===27&&e.value.codePointAt(r)===92)return r+1;t=r}return t}function isEscStringControlIntroducer(e){return e===80||e===88||e===93||e===94||e===95}function isC1StringControlCodePoint(e){return e===144||e===152||e===157||e===158||e===159}function isCharsetDesignationIntroducer(e){return e===40||e===41||e===42||e===43||e===45||e===46||e===47}function isUnsafeControlCodePoint(e){return e>=0&&e<=8||e>=11&&e<=31||e>=127&&e<=159}function renderOrangeText(e){return e.color?`\u001B[38;5;208m${e.text}\u001B[39m`:e.text}function createCliTheme(t={}){let n=picocolors.createColors(t.color??!!process.stdout.isTTY);return{accent:e=>n.cyan(e),color:n.isColorSupported,danger:e=>n.red(e),heading:e=>n.bold(n.cyan(e)),info:e=>n.blue(e),label:e=>n.bold(e),muted:e=>n.dim(e),plain:e=>e,subagent:e=>renderOrangeText({color:n.isColorSupported,text:e}),success:e=>n.green(e),warning:e=>n.yellow(e)}}function renderCliBanner(e,t){let n=sanitizeForTerminal(t.title),r=[e.heading(n),e.muted(`=`.repeat(n.length))];return t.subtitle&&r.push(e.muted(sanitizeForTerminal(t.subtitle))),r.join(`
2
+ `)}function renderCliSection(e,t){let n=t.rows.map(e=>({label:sanitizeForTerminal(e.label),tone:e.tone,value:sanitizeForTerminal(e.value)})),r=n.reduce((e,t)=>Math.max(e,t.label.length),0),i=[e.accent(sanitizeForTerminal(t.title))];for(let t of n){let[n=``,...a]=renderIndentedLines(applyTone(e,t.tone??`default`,t.value).split(`
3
+ `),`${` `.repeat(r)} `);i.push(`${e.label(t.label.padEnd(r))} ${n}`),i.push(...a)}return i.join(`
4
+ `)}function renderCliTaggedLine(e,t){let n=sanitizeForTerminal(t.message),r=`[${sanitizeForTerminal(t.tag).toUpperCase()}]`,[i=``,...a]=renderIndentedLines(applyTone(e,t.tone??`default`,n).split(`
5
+ `),`${` `.repeat(r.length)} `);return[e.muted(r),i].join(` `)+(a.length>0?`\n${a.join(`
6
+ `)}`:``)}function renderCliSpeakerLine(e,t){let n=sanitizeForTerminal(t.message),r=`${sanitizeForTerminal(t.speaker)}>`,[i=``,...a]=renderIndentedLines(applyTone(e,t.tone??`default`,n).split(`
7
+ `),`${` `.repeat(r.length)} `);return[e.muted(r),i].join(` `)+(a.length>0?`\n${a.join(`
8
+ `)}`:``)}export{createCliTheme,renderCliBanner,renderCliSection,renderCliSpeakerLine,renderCliTaggedLine,sanitizeForTerminal};
@@ -289,7 +289,6 @@ export interface AgentInfoResult {
289
289
  };
290
290
  readonly capabilities: {
291
291
  readonly devRoutes: boolean;
292
- readonly mockModels: boolean;
293
292
  };
294
293
  readonly channels: AgentInfoChannels;
295
294
  readonly connections: readonly AgentInfoConnectionEntry[];
@@ -1 +1 @@
1
- import{AuthKey,InitiatorAuthKey,ParentSessionKey,SessionIdKey,SessionKey}from"#context/keys.js";const sessionProvider={key:SessionKey,create(e){let t=e.require(AuthKey);return{value:Object.freeze({auth:{current:t,initiator:e.get(InitiatorAuthKey)??t},parent:e.get(ParentSessionKey),sessionId:e.require(SessionIdKey),turn:{id:`turn-${crypto.randomUUID()}`,sequence:0}})}}};export{sessionProvider};
1
+ import{AuthKey,InitiatorAuthKey,ParentSessionKey,SessionIdKey,SessionKey}from"#context/keys.js";import{getHarnessEmissionState}from"#harness/emission.js";const sessionProvider={key:SessionKey,create(e,t){let n=e.require(AuthKey),r=getHarnessEmissionState(t.state),i=r.turnId.length>0?r.turnId:`turn_${r.sequence}`;return{value:Object.freeze({auth:{current:n,initiator:e.get(InitiatorAuthKey)??n},parent:e.get(ParentSessionKey),sessionId:e.require(SessionIdKey),turn:{id:i,sequence:r.sequence}})}}};export{sessionProvider};
@@ -7,8 +7,6 @@ interface EvalCliOptions {
7
7
  skipReport?: boolean;
8
8
  strict?: boolean;
9
9
  list?: boolean;
10
- mockModels?: boolean;
11
- noSkips?: boolean;
12
10
  tag?: string[];
13
11
  verbose?: boolean;
14
12
  }
@@ -1 +1 @@
1
- import{basename,join}from"node:path";import{readFile}from"node:fs/promises";import{resolveApplicationRoot}from"#internal/application/paths.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{startDevelopmentServer}from"#internal/nitro/host.js";import{EVE_MOCK_AUTHORED_MODELS_ENV}from"#runtime/agent/resolve-model.js";import{createEvalClient}from"#evals/cli/eval-client.js";import{discoverAndImportEvals,discoverEvalConfig}from"#evals/runner/discover.js";import{runEvals}from"#evals/runner/run-evals.js";import{ConsoleReporter}from"#evals/runner/reporters/console.js";import{JUnit}from"#evals/runner/reporters/junit.js";import{resolveEvalTargetHandle}from"#evals/target.js";async function runEvalCommand(e,t,n){let s=resolveApplicationRoot();if(t.url&&t.mockModels===!0){n.error(`--mock-models cannot be used with --url. The target's mock-model state is discovered from /eve/v1/info.`),process.exitCode=2;return}let c=t.mockModels===!0?setEnvForRun(EVE_MOCK_AUTHORED_MODELS_ENV,`1`):void 0,l;try{loadDevelopmentEnvironmentFiles(s);let r=e.length>0?e:void 0,a=await discoverAndImportEvals(s,r);if(a.length===0){r?n.error(`No evals found matching: ${r.join(`, `)}`):n.error(`No evals found. Create files under evals/ with the *.eval.ts extension.`),process.exitCode=2;return}let c=filterEvalsByTag(a,t.tag??[]);if(c.length===0){n.error(`No evals matched the provided tags (${(t.tag??[]).join(`, `)}).`),process.exitCode=2;return}let u,d;try{u=parsePositiveInteger(t.maxConcurrency,`--max-concurrency`),d=parseNonNegativeInteger(t.timeout,`--timeout`)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}if(t.list===!0){printEvalList(c,t.json===!0,n);return}let f;try{f=await discoverEvalConfig(s)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}let p,m;try{t.url?m=await resolveEvalTargetHandle({client:createEvalClient({kind:`remote`,url:t.url}),expectedAgentName:await readExpectedAgentName(s),kind:`remote`,url:t.url}):(p=await startDevelopmentServer(s,{host:`127.0.0.1`,port:0}),m=await resolveEvalTargetHandle({client:createEvalClient({kind:`local`,url:p.url}),expectedAgentName:await readExpectedAgentName(s),kind:`local`,url:p.url}));let e=createEvalClient(m),r=t.json===!0?[]:[new ConsoleReporter];t.junit!==void 0&&r.push(JUnit({filePath:t.junit}));let i=await runEvals({evaluations:c,config:f,target:m,client:e,appRoot:s,reporters:r,includeEvalReporters:t.skipReport!==!0,failOnSkip:t.noSkips===!0,maxConcurrency:u,timeoutMs:d,onEvalLog:t.verbose===!0?(e,t)=>n.log(`[${e}] ${t}`):void 0});t.json&&n.log(JSON.stringify(i,null,2));let a=i.failed>0,o=t.strict===!0&&i.scored>0;(a||o)&&(process.exitCode=1)}finally{p&&await p.close()}l=typeof process.exitCode==`number`?process.exitCode:0}finally{c?.()}l!==void 0&&process.exit(l)}function parsePositiveInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<1)throw Error(`${t} must be a positive integer; got "${e}".`);return n}function parseNonNegativeInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw Error(`${t} must be a non-negative integer; got "${e}".`);return n}function filterEvalsByTag(e,t){return t.length===0?[...e]:e.filter(e=>e.tags?.some(e=>t.includes(e))??!1)}function printEvalList(e,t,n){if(t){let t=e.map(e=>({id:e.id,description:e.description,tags:e.tags}));n.log(JSON.stringify(t,null,2));return}for(let t of e){let e=t.description===void 0?``:` — ${t.description}`,r=t.tags!==void 0&&t.tags.length>0?` [${t.tags.join(`, `)}]`:``;n.log(`${t.id}${r}${e}`)}}function setEnvForRun(e,t){let n=process.env[e];return process.env[e]=t,()=>{n===void 0?delete process.env[e]:process.env[e]=n}}async function readExpectedAgentName(r){try{let i=JSON.parse(await readFile(join(r,`package.json`),`utf8`));return typeof i.name==`string`&&i.name.length>0?i.name:basename(r)}catch{return basename(r)}}export{runEvalCommand};
1
+ import{basename,join}from"node:path";import{readFile}from"node:fs/promises";import{resolveApplicationRoot}from"#internal/application/paths.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{startDevelopmentServer}from"#internal/nitro/host.js";import{createEvalClient}from"#evals/cli/eval-client.js";import{discoverAndImportEvals,discoverEvalConfig}from"#evals/runner/discover.js";import{runEvals}from"#evals/runner/run-evals.js";import{ConsoleReporter}from"#evals/runner/reporters/console.js";import{JUnit}from"#evals/runner/reporters/junit.js";import{resolveEvalTargetHandle}from"#evals/target.js";async function runEvalCommand(e,t,n){let s=resolveApplicationRoot();loadDevelopmentEnvironmentFiles(s);let c=e.length>0?e:void 0,l=await discoverAndImportEvals(s,c);if(l.length===0){c?n.error(`No evals found matching: ${c.join(`, `)}`):n.error(`No evals found. Create files under evals/ with the *.eval.ts extension.`),process.exitCode=2;return}let u=filterEvalsByTag(l,t.tag??[]);if(u.length===0){n.error(`No evals matched the provided tags (${(t.tag??[]).join(`, `)}).`),process.exitCode=2;return}let d,f;try{d=parsePositiveInteger(t.maxConcurrency,`--max-concurrency`),f=parseNonNegativeInteger(t.timeout,`--timeout`)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}if(t.list===!0){printEvalList(u,t.json===!0,n);return}let p;try{p=await discoverEvalConfig(s)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}let m,h;try{t.url?h=await resolveEvalTargetHandle({client:createEvalClient({kind:`remote`,url:t.url}),expectedAgentName:await readExpectedAgentName(s),kind:`remote`,url:t.url}):(m=await startDevelopmentServer(s,{host:`127.0.0.1`,port:0}),h=await resolveEvalTargetHandle({client:createEvalClient({kind:`local`,url:m.url}),expectedAgentName:await readExpectedAgentName(s),kind:`local`,url:m.url}));let e=createEvalClient(h),r=t.json===!0?[]:[new ConsoleReporter];t.junit!==void 0&&r.push(JUnit({filePath:t.junit}));let i=await runEvals({evaluations:u,config:p,target:h,client:e,appRoot:s,reporters:r,includeEvalReporters:t.skipReport!==!0,maxConcurrency:d,timeoutMs:f,onEvalLog:t.verbose===!0?(e,t)=>n.log(`[${e}] ${t}`):void 0});t.json&&n.log(JSON.stringify(i,null,2));let a=i.failed>0,o=t.strict===!0&&i.scored>0;(a||o)&&(process.exitCode=1)}finally{m&&await m.close()}let g=typeof process.exitCode==`number`?process.exitCode:0;process.exit(g)}function parsePositiveInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<1)throw Error(`${t} must be a positive integer; got "${e}".`);return n}function parseNonNegativeInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw Error(`${t} must be a non-negative integer; got "${e}".`);return n}function filterEvalsByTag(e,t){return t.length===0?[...e]:e.filter(e=>e.tags?.some(e=>t.includes(e))??!1)}function printEvalList(e,t,n){if(t){let t=e.map(e=>({id:e.id,description:e.description,tags:e.tags}));n.log(JSON.stringify(t,null,2));return}for(let t of e){let e=t.description===void 0?``:` — ${t.description}`,r=t.tags!==void 0&&t.tags.length>0?` [${t.tags.join(`, `)}]`:``;n.log(`${t.id}${r}${e}`)}}async function readExpectedAgentName(r){try{let i=JSON.parse(await readFile(join(r,`package.json`),`utf8`));return typeof i.name==`string`&&i.name.length>0?i.name:basename(r)}catch{return basename(r)}}export{runEvalCommand};
@@ -15,6 +15,6 @@ import type { EveEvalDefinition, EveEvalInput } from "#evals/types.js";
15
15
  *
16
16
  * Throws on invalid input: a missing `test` function, a removed legacy key
17
17
  * (`input`/`run`/`checks`/`scores`/`expected`/`thresholds`/`parseOutput`/
18
- * `model`), or a negative or non-finite `timeoutMs`.
18
+ * `model`/`requires`), or a negative or non-finite `timeoutMs`.
19
19
  */
20
20
  export declare function defineEval(input: EveEvalInput): EveEvalDefinition;
@@ -1 +1 @@
1
- function defineEval(e){return validateEvalInput(e),{...e,_tag:`EveEval`}}function validateEvalInput(e){if(`id`in e)throw Error("Eval must not specify `id`. Eval identity is derived from the file path under evals/.");if(`name`in e)throw Error("Eval must not specify `name`. Eval identity is derived from the file path under evals/.");if(rejectLegacyKey(e,`input`,"Send the prompt inside `test`: `async test(t) { await t.send(...) }`."),rejectLegacyKey(e,`run`,"Rename `run` to `test`; it receives the same context `t`."),rejectLegacyKey(e,`checks`,"Assert inline inside `test` (e.g. `t.completed()`, `t.calledTool(...)`)."),rejectLegacyKey(e,`scores`,"Use soft assertions inside `test`: `t.check(...).atLeast(n)` or `t.judge.autoevals.*`."),rejectLegacyKey(e,`expected`,"Pass the reference value to the assertion (e.g. `t.check(t.reply, includes(value))`)."),rejectLegacyKey(e,`thresholds`,"Put the threshold on the assertion: `.atLeast(n)`."),rejectLegacyKey(e,`parseOutput`,"Read the value you want inside `test` and assert on it directly."),rejectLegacyKey(e,`model`,"Rename `model` to `judge: { model }`."),rejectLegacyKey(e,`modelOptions`,"Move it under `judge: { model, modelOptions }`."),rejectLegacyKey(e,`cases`,"Each eval file is one case; default-export an array of `defineEval(...)` for datasets."),typeof e.test!=`function`)throw Error("Eval requires a `test(t)` function.");if(validateRequirements(e.requires,"Eval `requires`"),e.timeoutMs!==void 0&&(e.timeoutMs<0||!Number.isFinite(e.timeoutMs)))throw Error("Eval `timeoutMs` must be a non-negative finite number.")}function rejectLegacyKey(e,t,n){if(t in e)throw Error(`Eval \`${t}\` is no longer supported. ${n}`)}function validateRequirements(e,t){if(e!==void 0){if(!Array.isArray(e))throw Error(`${t} must be an array of requirement strings.`);for(let n of e)if(!(n===`mockModels`||n===`devRoutes`)&&!(n.startsWith(`env:`)&&n.length>4))throw Error(`${t} contains unsupported requirement "${n}". Expected "mockModels", "devRoutes", or "env:<NAME>".`)}}export{defineEval};
1
+ function defineEval(e){return validateEvalInput(e),{...e,_tag:`EveEval`}}function validateEvalInput(e){if(`id`in e)throw Error("Eval must not specify `id`. Eval identity is derived from the file path under evals/.");if(`name`in e)throw Error("Eval must not specify `name`. Eval identity is derived from the file path under evals/.");if(rejectLegacyKey(e,`input`,"Send the prompt inside `test`: `async test(t) { await t.send(...) }`."),rejectLegacyKey(e,`run`,"Rename `run` to `test`; it receives the same context `t`."),rejectLegacyKey(e,`checks`,"Assert inline inside `test` (e.g. `t.completed()`, `t.calledTool(...)`)."),rejectLegacyKey(e,`scores`,"Use soft assertions inside `test`: `t.check(...).atLeast(n)` or `t.judge.autoevals.*`."),rejectLegacyKey(e,`expected`,"Pass the reference value to the assertion (e.g. `t.check(t.reply, includes(value))`)."),rejectLegacyKey(e,`thresholds`,"Put the threshold on the assertion: `.atLeast(n)`."),rejectLegacyKey(e,`parseOutput`,"Read the value you want inside `test` and assert on it directly."),rejectLegacyKey(e,`model`,"Rename `model` to `judge: { model }`."),rejectLegacyKey(e,`modelOptions`,"Move it under `judge: { model, modelOptions }`."),rejectLegacyKey(e,`cases`,"Each eval file is one case; default-export an array of `defineEval(...)` for datasets."),rejectLegacyKey(e,`requires`,`Point real-model evals at credentialed targets directly; dev-only routes are enforced from the live target.`),typeof e.test!=`function`)throw Error("Eval requires a `test(t)` function.");if(e.timeoutMs!==void 0&&(e.timeoutMs<0||!Number.isFinite(e.timeoutMs)))throw Error("Eval `timeoutMs` must be a non-negative finite number.")}function rejectLegacyKey(e,t,n){if(t in e)throw Error(`Eval \`${t}\` is no longer supported. ${n}`)}export{defineEval};
@@ -1,8 +1,7 @@
1
1
  export { defineEval } from "#evals/define-eval.js";
2
2
  export { defineEvalConfig } from "#evals/define-eval-config.js";
3
3
  export { EveEvalTurnFailedError } from "#evals/session.js";
4
- export { EveEvalRequirementError } from "#evals/target.js";
5
4
  export type { RuntimeIdentity } from "#protocol/message.js";
6
5
  export type { InputRequest } from "#runtime/input/types.js";
7
6
  export type { EveEvalValueMatcher, EveEvalToolCallMatchOptions, EveEvalSubagentCallMatchOptions, } from "#evals/match.js";
8
- export type { Assertion, AssertionHandle, AssertionResult, AssertionSeverity, AutoevalsJudges, EveEvalContext, EveEvalDerivedFacts, EveEvalJudgeConfig, EveEvalRunSummary, EveEvalSession, EveEvalSessionResult, EveEvalRequirement, EveEvalScheduleDispatchResult, EveEvalSubagentCall, EveEval, EveEvalConfig, EveEvalConfigInput, EveEvalDefinition, EveEvalInput, EveEvalResult, EveEvalTarget, EveEvalTargetCapabilities, EveEvalTargetHandle, EveEvalTaskResult, EveEvalToolCall, EveEvalTurn, EveEvalVerdict, JudgeContext, JudgeOpts, } from "#evals/types.js";
7
+ export type { Assertion, AssertionHandle, AssertionResult, AssertionSeverity, AutoevalsJudges, EveEvalContext, EveEvalDerivedFacts, EveEvalJudgeConfig, EveEvalRunSummary, EveEvalSession, EveEvalSessionResult, EveEvalScheduleDispatchResult, EveEvalSubagentCall, EveEval, EveEvalConfig, EveEvalConfigInput, EveEvalDefinition, EveEvalInput, EveEvalResult, EveEvalTarget, EveEvalTargetCapabilities, EveEvalTargetHandle, EveEvalTaskResult, EveEvalToolCall, EveEvalTurn, EveEvalVerdict, JudgeContext, JudgeOpts, } from "#evals/types.js";
@@ -1 +1 @@
1
- import{EveEvalRequirementError}from"#evals/target.js";import{EveEvalTurnFailedError}from"#evals/session.js";import{defineEval}from"#evals/define-eval.js";import{defineEvalConfig}from"#evals/define-eval-config.js";export{EveEvalRequirementError,EveEvalTurnFailedError,defineEval,defineEvalConfig};
1
+ import{EveEvalTurnFailedError}from"#evals/session.js";import{defineEval}from"#evals/define-eval.js";import{defineEvalConfig}from"#evals/define-eval-config.js";export{EveEvalTurnFailedError,defineEval,defineEvalConfig};