scout.run(task, options) runs one task to an end and returns what it found. A run that falls short or reaches a cap still returns, with the data it collected. It throws only when it cannot start.
task is the task in words, as a non-empty string. Every option is optional. One Scout can run many tasks: each run opens its own browser, or its own tab on a browser you passed in, and closes it at the end.
Caps
caps says when the run stops. Reaching a cap is a normal ending, not an error: the result carries what was found.
steps and duration always apply. A run that ends on a cap you set has status: 'capped'.
Schema
schema is a JSON Schema for the answer. With one, result.data comes back in that shape, and is partly filled on a partial run. Without one, the answer is the agent’s own summary, and result.suggestedSchema may carry a schema derived from the task that you can pass next time.
result.data; the schema is what shapes it.
Cancelling
signal takes an AbortSignal. Aborting it stops the run, which ends with stopReason: 'cancelled' and returns what it found so far.
Watching steps
onStep is called with each step as it is recorded. It must not throw. A step carries, among other fields:
index: its position, from 0;action.description: what it did, in words, andaction.method, for exampleclickorfill;reasoning: the model’s stated reason, when it gave one;usage: the tokens it used.
The result
run resolves to a ScoutResult:
Errors
new Scout and run throw only when a run cannot start. Both errors are exported from @outcrawl/scout, and each message says what to pass instead.
Everything after the start, including a model endpoint that refuses a request, ends the run with a
status and an error rather than a throw.
Logging
Passlogger to new Scout to hear what Scout is doing. Any structured logger fits: it needs info(event, fields) and warn(event, fields).
scout.browser), a model whose cost could not be known (scout.cost_unknown), and a cloud session that published no replay link (scout.no_replay_url).