explorbot 0.2.4 → 0.2.5

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 (63) hide show
  1. package/bin/explorbot-cli.ts +19 -7
  2. package/boat/api-tester/src/cli.ts +17 -0
  3. package/boat/doc-collector/src/cli.ts +14 -1
  4. package/boat/prima/src/cli.ts +24 -12
  5. package/boat/prima/src/envelope.ts +35 -13
  6. package/boat/prima/src/prima.ts +61 -41
  7. package/dist/bin/explorbot-cli.js +19 -7
  8. package/dist/boat/api-tester/src/cli.js +17 -0
  9. package/dist/boat/doc-collector/src/cli.js +14 -1
  10. package/dist/boat/prima/src/cli.js +19 -7
  11. package/dist/boat/prima/src/envelope.js +32 -8
  12. package/dist/boat/prima/src/prima.js +57 -39
  13. package/dist/package.json +1 -1
  14. package/dist/src/action.js +5 -1
  15. package/dist/src/ai/navigator.d.ts +27 -0
  16. package/dist/src/ai/navigator.js +227 -175
  17. package/dist/src/ai/pilot.d.ts +7 -4
  18. package/dist/src/ai/pilot.js +50 -8
  19. package/dist/src/ai/provider.d.ts +2 -2
  20. package/dist/src/ai/provider.js +12 -21
  21. package/dist/src/ai/researcher/cache.d.ts +2 -0
  22. package/dist/src/ai/researcher/cache.js +10 -2
  23. package/dist/src/ai/researcher.js +2 -1
  24. package/dist/src/ai/session-analyst.js +2 -0
  25. package/dist/src/ai/tester.d.ts +5 -2
  26. package/dist/src/ai/tester.js +17 -13
  27. package/dist/src/ai/tools.js +4 -1
  28. package/dist/src/commands/config-command.d.ts +51 -0
  29. package/dist/src/commands/config-command.js +117 -0
  30. package/dist/src/commands/index.js +2 -0
  31. package/dist/src/config.d.ts +8 -1
  32. package/dist/src/config.js +40 -0
  33. package/dist/src/explorbot.js +4 -1
  34. package/dist/src/remote.d.ts +3 -2
  35. package/dist/src/remote.js +8 -2
  36. package/dist/src/state-manager.d.ts +1 -1
  37. package/dist/src/state-manager.js +3 -1
  38. package/dist/src/test-plan.d.ts +1 -0
  39. package/dist/src/test-plan.js +19 -0
  40. package/dist/src/utils/logger.d.ts +1 -1
  41. package/dist/src/utils/logger.js +8 -0
  42. package/docs/index.json +2 -1
  43. package/docs/reference/commands.md +3 -0
  44. package/docs/reference/websocket.md +50 -0
  45. package/docs/superpowers/specs/2026-08-18-prima-false-verdicts.md +159 -0
  46. package/package.json +1 -1
  47. package/src/action.ts +5 -1
  48. package/src/ai/navigator.ts +241 -178
  49. package/src/ai/pilot.ts +63 -12
  50. package/src/ai/provider.ts +12 -20
  51. package/src/ai/researcher/cache.ts +12 -2
  52. package/src/ai/researcher.ts +2 -1
  53. package/src/ai/session-analyst.ts +2 -0
  54. package/src/ai/tester.ts +20 -12
  55. package/src/ai/tools.ts +4 -1
  56. package/src/commands/config-command.ts +146 -0
  57. package/src/commands/index.ts +2 -0
  58. package/src/config.ts +45 -1
  59. package/src/explorbot.ts +3 -1
  60. package/src/remote.ts +8 -2
  61. package/src/state-manager.ts +5 -2
  62. package/src/test-plan.ts +20 -0
  63. package/src/utils/logger.ts +9 -1
@@ -1,4 +1,5 @@
1
1
  import { createHash } from 'node:crypto';
2
+ import { tag } from "./utils/logger.js";
2
3
  import { parsePlanFromMarkdown, planToAiContext, savePlanToMarkdown, savePlansToMarkdown } from "./utils/test-plan-markdown.js";
3
4
  import { uniqSessionName } from "./utils/unique-names.js";
4
5
  export const TestResult = {
@@ -260,12 +261,14 @@ export class Test extends Task {
260
261
  this.startTime = performance.now();
261
262
  this.addNote(`Test started. Session name: ${this.sessionName}`);
262
263
  this.plan?.notifyChange();
264
+ this.reportStatus();
263
265
  }
264
266
  finish(result = TestResult.FAILED) {
265
267
  this.status = TestStatus.DONE;
266
268
  this.result = result;
267
269
  this.endTime = performance.now();
268
270
  this.plan?.notifyChange();
271
+ this.reportStatus();
269
272
  }
270
273
  getDurationMs() {
271
274
  if (this.startTime != null && this.endTime != null)
@@ -276,6 +279,17 @@ export class Test extends Task {
276
279
  const achieved = this.getCheckedExpectations();
277
280
  return this.expected.filter((e) => !achieved.includes(e));
278
281
  }
282
+ reportStatus() {
283
+ tag('data').log('test', {
284
+ scenario: this.scenario,
285
+ status: this.status,
286
+ result: this.result,
287
+ priority: this.priority,
288
+ sessionName: this.sessionName,
289
+ url: this.startUrl,
290
+ plan: this.plan?.title,
291
+ });
292
+ }
279
293
  getLog() {
280
294
  const merged = {};
281
295
  for (const [key, stepData] of Object.entries(this.steps)) {
@@ -338,6 +352,11 @@ export class Plan {
338
352
  for (const listener of this.changeListeners) {
339
353
  listener(this.tests);
340
354
  }
355
+ tag('data').log('plan', {
356
+ title: this.title,
357
+ url: this.url,
358
+ tests: this.tests.map((test) => ({ scenario: test.scenario, status: test.status, result: test.result, priority: test.priority })),
359
+ });
341
360
  }
342
361
  getAllTests() {
343
362
  if (!this.parentPlan)
@@ -1,5 +1,5 @@
1
1
  import { type Span } from '@opentelemetry/api';
2
- export type LogType = 'info' | 'success' | 'error' | 'warning' | 'debug' | 'substep' | 'operation' | 'step' | 'multiline' | 'details' | 'html' | 'input';
2
+ export type LogType = 'info' | 'success' | 'error' | 'warning' | 'debug' | 'substep' | 'operation' | 'step' | 'multiline' | 'details' | 'html' | 'input' | 'data';
3
3
  export interface TaggedLogEntry {
4
4
  type: LogType;
5
5
  content: string;
@@ -406,6 +406,14 @@ class Logger {
406
406
  }
407
407
  return;
408
408
  }
409
+ if (type === 'data') {
410
+ const entry = { type, content: String(args[0]), timestamp: new Date(), originalArgs: args };
411
+ for (const destination of this.extra) {
412
+ if (destination.isEnabled())
413
+ destination.write(entry);
414
+ }
415
+ return;
416
+ }
409
417
  const options = this.extractLogOptions(type, args);
410
418
  let content = this.processArgs(args);
411
419
  if (type === 'step' && args[0]?.toCode) {
package/docs/index.json CHANGED
@@ -66,7 +66,8 @@
66
66
  "pages": [
67
67
  { "title": "Commands", "file": "reference/commands.md", "description": "Every CLI and terminal command" },
68
68
  { "title": "Configuration", "file": "reference/configuration.md", "description": "The config file, top to bottom" },
69
- { "title": "Scripting", "file": "reference/scripting.md", "description": "The programmatic API" }
69
+ { "title": "Scripting", "file": "reference/scripting.md", "description": "The programmatic API" },
70
+ { "title": "WebSocket stream", "file": "reference/websocket.md", "description": "Every frame a listener can read from a run" }
70
71
  ]
71
72
  },
72
73
  {
@@ -51,6 +51,7 @@ Inside the TUI, use the matching slash command: `/explore`, `/research`, `/plan`
51
51
  | Manage persistent browser | `npx explorbot browser {start\|stop\|status}` | — | Share browser across runs |
52
52
  | Initialize project | `npx explorbot init` | — | Generates `explorbot.config.*`, or `~/.explorbot` with `--global` |
53
53
  | List registered sites | `npx explorbot sites` | — | Sites stored in the global installation |
54
+ | Show resolved configuration | `npx explorbot config [url] [--json]` | `/config` | Models, config file, paths and `EXPLORBOT_*` in effect |
54
55
  | Clean generated files | `npx explorbot clean [target]` | `/clean [target]` | Same targets both ways |
55
56
 
56
57
  ## Common CLI Options
@@ -107,6 +108,8 @@ EXPLORBOT_AI_PROVIDER=openrouter \
107
108
  | `EXPLORBOT_NO_BANNER` | Suppress the startup banner, for machine-readable output |
108
109
  <!-- END env -->
109
110
 
111
+ `npx explorbot config` prints the values a run actually uses — models per role, the config file behind them, the output, knowledge and experience directories, and every `EXPLORBOT_*` variable currently set. The boats answer for their own configuration the same way: `npx explorbot api config`, `npx explorbot docs config`, `npx explorbot prima config`. Add `--json` on any of them to get the same values as an object a script can read.
112
+
110
113
  Explorbot resolves its configuration in this order: the path given to `--config`, then `explorbot.config.*` in the working directory, then the `EXPLORBOT_*` variables, and finally `~/.explorbot/config.*` from the global installation. A bare provider name fills every model role from the recommendations in [Providers](../basics/providers.md); a `provider/model-id` spec pins one model and splits on the first slash, so `openrouter/openai/gpt-oss-120b:nitro` selects OpenRouter with model `openai/gpt-oss-120b:nitro`. Supported providers: `openai`, `anthropic`, `google`, `groq`, `mistral`, `openrouter`, `sambanova`.
111
114
 
112
115
  In this mode output goes to `~/.explorbot/sites/<host>/output/` (or `EXPLORBOT_OUTPUT`, or a temp directory with `EXPLORBOT_EPHEMERAL=1`), experience is kept beside it unless the run is ephemeral, and the Historian is off, so no generated test files appear. See [Agentic Usage](../workflow/agentic-usage.md) for the full picture.
@@ -0,0 +1,50 @@
1
+ # WebSocket Stream
2
+
3
+ `--ws <url>` (or `EXPLORBOT_WS_URL`) streams a run to your own UI. Explorbot dials **out** — your side is the server — so the same flag covers a child process you spawned and a CI bot connecting from elsewhere.
4
+
5
+ ```bash
6
+ npx explorbot explore /dashboard --ws ws://127.0.0.1:8787
7
+ ```
8
+
9
+ Every message is JSON with a `type` and a `ts`, plus whatever that type carries. Nothing is validated on either side: render the types you know, ignore the rest, and expect new ones.
10
+
11
+ ## What a run sends
12
+
13
+ | Type | What it is |
14
+ |---|---|
15
+ | `hello` | the run itself: command, working directory, pid |
16
+ | `state` | the page under test: url, path, title, heading |
17
+ | `test` | a test starting or finishing, with its status, result and plan |
18
+ | `plan` | the current plan and the status of every test in it |
19
+ | `screenshot` | the screenshot file just written |
20
+ | `research` | the researcher's map of a page: markdown and its file |
21
+ | `report` | the analyst's end-of-session report: markdown and its file |
22
+ | `activity` | what the run is doing this second |
23
+ | `log` | a log line and its level |
24
+ | `ask` | a question for a human, carrying an `askId` |
25
+ | `result` | the run exited, with its code |
26
+
27
+ Each type carries the latest truth, so keep the last frame per type — that is what the terminal itself shows.
28
+
29
+ ## What you can send back
30
+
31
+ | Type | What it does |
32
+ |---|---|
33
+ | `answer` | answers an `ask`: same `askId`, plus `value` — or `null` to skip the question |
34
+ | `interrupt` | stops the current step; the run then asks what to do instead |
35
+
36
+ A run with nobody to answer never asks in the first place, so connecting a listener that answers is what makes a headless run interactive.
37
+
38
+ ## Delivery
39
+
40
+ Frames queue while disconnected — the last 1000 — and the connection retries on its own, so treat it as a live feed rather than a history. On exit the queue is flushed after `result`.
41
+
42
+ ## Adding a frame
43
+
44
+ Frames are logged, not published:
45
+
46
+ ```ts
47
+ tag('data').log('coverage', { visited: 12, total: 30 });
48
+ ```
49
+
50
+ That reaches listeners as a `coverage` frame. A `data` entry never goes to the console, the log file, or the TUI.
@@ -0,0 +1,159 @@
1
+ # Prima False Verdicts — No Reload, Vision-Confirmed Outcomes, Unconfirmed ≠ Failed
2
+
3
+ **Date:** 2026-08-18
4
+ **Status:** Implemented
5
+ **Follows:** `2026-08-07-prima-fixes-design.md`
6
+ **Evidence:** field feedback from an orchestrator driving prima over eight calls
7
+
8
+ ## Problem
9
+
10
+ Prima returned verdicts that did not match what happened, in both directions.
11
+
12
+ - `prima do` reported `error: open: <instruction>` for clicks that had landed. The caller only
13
+ found out by screenshotting anyway — which is the cost the boat exists to remove.
14
+ - `prima check` returned `ok: false` for an environmental reason and said nothing about it.
15
+ - No command answered a visual question with a verdict. `check` and `verify` never read a
16
+ screenshot; `ask` read one but returned prose.
17
+
18
+ The skill tells callers to trust `### Result`. A false red trains them out of that, and then the
19
+ greens stop meaning anything either.
20
+
21
+ ## Mechanisms found
22
+
23
+ 1. **`check` reloaded the page before checking it.** `prima.check()` → `tester.test()` →
24
+ `runTestSession` → `explorer.visit(task.startUrl!)` (`tester.ts:192`, unconditional) →
25
+ `I.amOnPage()` (`explorer.ts:431`) → `page.goto()`, which reloads even on the same URL.
26
+ `task.startUrl` is the page the caller is already on. Any transient state — an open dialog, a
27
+ selected tab, an unsaved form — was destroyed by the command asked to inspect it. This was
28
+ guaranteed, not a race with a dev-server reload.
29
+ 2. **`check` could not say why it failed.** `reportEnvelope` never sets `failure`, and
30
+ `envelope.steps` was built only from notes with `status === FAILED`. An abort produced
31
+ `ok: false` with an empty Steps section and no Failure section.
32
+ 3. **`do`'s verdict was the model's bookkeeping, not the page.** An instruction the model never
33
+ passed to `completed()` was rendered as an error, so an envelope could show every step green
34
+ and `ok: false` at once. `settleLedger`'s `.catch(() => null)` made a provider error
35
+ indistinguishable from a model that would not report.
36
+ 4. **Vision routing was per command, not per question.** `verify` produced DOM assertions only;
37
+ `check`'s verdict came from that same tool plus `settleExpectations`, which judged a text log.
38
+ The `inexpressible` branch told the model to "check it with `see()`" with no model in the loop
39
+ to act on the suggestion.
40
+ 5. **`prima status` printed the page tree.** `saveStatus` stored the full compact ARIA under
41
+ `changes`, so the command whose job is to cite artifact paths dumped the tree inline instead.
42
+
43
+ ## Changes
44
+
45
+ ### 1. `check` starts where the caller is
46
+
47
+ `Tester.test(task, opts)` takes `startOnCurrentPage`, which skips the initial visit. Prima passes
48
+ it. Nothing else changes for the explore flow, where reload-to-start-url is intentional.
49
+
50
+ `reset` needs no guard: it already refuses when the current URL equals the start URL, which is
51
+ the case for a check that starts in place. Once a check has navigated away, resetting back is
52
+ the right behaviour anyway.
53
+
54
+ ### 2. The screenshot is the proof, and a disagreement is a finding
55
+
56
+ `settleExpectations` is called from exactly one place, `prima.ts`, so it is prima's final judge
57
+ and can change without touching the explore flow. It now takes the final `ActionResult` and, when
58
+ that carries a screenshot and a vision model is configured, settles every outcome in one
59
+ structured call on the vision model with the image attached.
60
+
61
+ The screenshot is not one of two equal inputs. An outcome is satisfied when the page shows it to
62
+ somebody looking at it; the log only says what the run did. The prompt says so.
63
+
64
+ **Where the two disagree, the judge does not choose.** It reports `contradiction` and says what each
65
+ side shows. An assertion that matched an element nobody can see is a defect in the application, and
66
+ it is exactly the case both other verdicts destroy: `passed` hides it behind an assertion that
67
+ happens to match, `failed` mislabels a feature that half works. It comes back as its own status
68
+ with both sides quoted, it fails the command, and `### Artifacts` names the html, aria and screenshot
69
+ on disk so the caller can settle it on the page itself rather than on the judge's word.
70
+
71
+ **Absence in the picture is not a contradiction.** Review of the first pass raised this: a
72
+ screenshot is not proof that a thing is missing, only that the judge could not make it out. A
73
+ contradiction now requires the picture to show something *incompatible* — a list visibly empty, an error
74
+ where a result was expected, the old value still displayed. "I cannot find it" is `unverified`,
75
+ which does not fail the command.
76
+
77
+ The screenshot is the final page only. An outcome the run established earlier stays established
78
+ even when the page has moved past it, and the prompt says that is not a contradiction — otherwise every
79
+ "record deleted, then navigated away" scenario reports one.
80
+
81
+ ### 3. `check`'s verdict is its outcomes
82
+
83
+ `ok` no longer comes from `tester.test()`'s success flag, which could contradict the outcomes
84
+ printed beside it. `ok: true` when no outcome failed and none was contradicted; each failure and
85
+ each contradiction names itself in `### Failure`. `unverified` is not a failure — it is a statement about
86
+ the run, matching what the help text already promised.
87
+
88
+ A run that could not complete is reported separately from an application failure: when the test
89
+ never finished or was skipped, the envelope says the run established nothing and cites the last
90
+ step recorded.
91
+
92
+ ### 4. `do` distinguishes failed from unconfirmed
93
+
94
+ `ok` is a function of what ran, not of the paperwork. An action error or a `blocked()` fails the
95
+ command. An instruction the model never reported becomes a `??` row in `### Steps` — the actions
96
+ that ran are listed above it — and does not fail the command. An AI error while settling the
97
+ ledger is reported as its own step rather than attributed to the instruction.
98
+
99
+ The `<proof>` block gains one general line: how much of the page moved is not evidence of whether
100
+ something happened. A change confined to one region proves an instruction as well as one that
101
+ redraws everything.
102
+
103
+ ### 5. `verify` reaches for vision when no assertion can express the claim
104
+
105
+ The `inexpressible` branch now judges the claim from a screenshot and reports the judgement,
106
+ instead of dead-ending on a suggestion nothing acts on. Because Tester's `verify` tool calls the
107
+ same `navigator.verifyState`, this covers `check` as well.
108
+
109
+ `Prima.visionEnabled()` also honours `Stats.visionDisabled`, so a session that lost vision
110
+ mid-run stops claiming to have it.
111
+
112
+ ### 6. `status` cites artifacts instead of reprinting the page
113
+
114
+ The ARIA blob is gone from `status.json`. `status` returns the page block and the artifact paths,
115
+ which is its whole job.
116
+
117
+ ## Decisions Log
118
+
119
+ - `check` starts on the current page. A command that inspects transient UI must not destroy it.
120
+ - Vision is not a fallback in `check`; it closes every run that has a vision model. The
121
+ screenshot is the proof — what a user can see — and the run log only says what was done.
122
+ - A disagreement between the picture and the run is reported as `contradiction`, never settled one
123
+ way. An assertion matching an element nobody can see is a defect, and both `passed` and `failed`
124
+ would bury it. A contradiction fails the command, and hands the caller the page files to judge on.
125
+ The word is `contradiction` rather than `conflict` because it names what happened, and rather than
126
+ `ambiguity` because that is what `unverified` already means.
127
+ - A contradiction needs the picture to show something incompatible. Not finding something is `unverified`;
128
+ absence of evidence is not evidence of absence, and treating it as one is how a false-verdict fix
129
+ becomes a false-verdict generator.
130
+ - Nothing probes the page to explain *why* something is invisible. A first attempt walked the DOM
131
+ comparing colours, sniffing screen-reader patterns and hit-testing every element; it was a pile of
132
+ heuristics guessing at an answer the contradiction already states. "The run says it is there and
133
+ the picture does not show it" is the finding, and the caller is better placed to say why.
134
+ - `settleExpectations` judges all outcomes, not only undecided ones, when it has a screenshot —
135
+ otherwise a DOM assertion the run already made could never be contradicted by the page.
136
+ - `unverified` is not a failure, in `check` outcomes and in `do` instructions alike. A statement
137
+ about the run is not a statement about the application.
138
+ - Bookkeeping is not evidence. `do`'s `ok` follows actions and blocks; an unreported instruction
139
+ is surfaced, never rendered as an error.
140
+ - A run that could not complete is reported as such, never as an application failure.
141
+ - `provider.getVisionModel()` is added for symmetry with `getModelForAgent`/`getAgenticModel`;
142
+ `processImage` returns free text and cannot carry a per-outcome verdict.
143
+ - A failed vision judgement falls back to the text model and flips `Stats.visionDisabled` — the
144
+ existing global for "vision is not usable this session" — which prima reads through
145
+ `visionEnabled()`.
146
+ - No line reports which evidence the judge had; that is plumbing. Only the degraded case is
147
+ stated, as a `### Warning`, because only that case is a fact the caller must act on.
148
+ - The verdict vocabulary lives in `prima <command> --help`. A marker the caller can see in an
149
+ envelope but cannot look up is not documented.
150
+
151
+ ## Not done
152
+
153
+ - `explorer.beginTest` still calls `closeOtherTabs()`, so `check` closes other tabs of an
154
+ attached session. Guarding it means threading an option through `beginTest`, which every flow
155
+ shares.
156
+ - `do` gets no vision confirmation pass. Its `completed()` proof is the same kind of unverified
157
+ paperwork, but a per-instruction vision call is a different cost profile.
158
+ - The `prima` skill in `testomatio/skills` documents the old envelope vocabulary. It needs the
159
+ `??` row, the `CONTRADICTION` status, and the unconfirmed-is-not-failed rule.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "explorbot",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "CLI app built with React Ink, CodeceptJS, and Playwright",
5
5
  "license": "Elastic-2.0",
6
6
  "type": "module",
package/src/action.ts CHANGED
@@ -57,6 +57,7 @@ class Action {
57
57
  try {
58
58
  await (this.actor as any).saveScreenshot(filename);
59
59
  if (currentState) currentState.screenshotFile = filename;
60
+ tag('data').log('screenshot', { path: outputPath('states', filename) });
60
61
  return filename;
61
62
  } catch (err) {
62
63
  debugLog('Screenshot failed:', err);
@@ -105,7 +106,10 @@ class Action {
105
106
  const screenshotPath = join(statesDir, filename);
106
107
  screenshotFile = await page
107
108
  ?.screenshot({ path: screenshotPath, fullPage: true })
108
- .then(() => filename)
109
+ .then(() => {
110
+ tag('data').log('screenshot', { path: screenshotPath });
111
+ return filename;
112
+ })
109
113
  .catch((err: Error) => {
110
114
  debugLog('Screenshot failed, continuing without it:', err);
111
115
  return undefined;