Skip to content

Usage

Minimal example

Save as agent.ts and run with npx tsx agent.ts:

typescript
import { Agent } from "@omxyz/lumen";

const result = await Agent.run({
  model: "anthropic/claude-sonnet-4-6",
  browser: { type: "local" },
  instruction: "Go to news.ycombinator.com and tell me the title of the top story.",
});

console.log(result.result);

The agent launches Chrome, takes screenshots at each step, reasons about what it sees, and returns the final answer as result.result.

Streaming events

Use agent.stream() to receive typed StreamEvent objects as the agent runs:

typescript
import { Agent } from "@omxyz/lumen";

const agent = new Agent({
  model: "anthropic/claude-sonnet-4-6",
  browser: { type: "local" },
  instruction: "Search Wikipedia for 'browser automation' and return the first sentence.",
});

for await (const event of agent.stream()) {
  if (event.type === "step") {
    console.log("Step:", event.action);
  }
  if (event.type === "done") {
    console.log("Result:", event.result);
  }
}

Key configuration options

OptionTypeDefaultDescription
modelstringrequiredProvider and model, e.g. "anthropic/claude-sonnet-4-6"
browser.type"local" or "cdp" or "browserbase"requiredWhere to run Chrome
browser.headlessbooleanfalseRun without visible window
maxStepsnumber30Maximum perception-action steps
thinkingBudgetnumber0Extended thinking token budget
confidenceGateobjectoffMulti-sample validation on uncertain steps
policyobjectoffDomain allowlist / blocklist
verbose0, 1, or 20Logging level (0 = silent, 2 = full)
compactionThreshold0-10.8Context summarization trigger fraction
checkpointIntervalnumber5Browser state snapshot every N steps
siteKBobjectoffDomain-specific navigation tips injected into the prompt

Debug logging

bash
LUMEN_LOG=debug npx tsx agent.ts        # All debug surfaces
LUMEN_LOG_ACTIONS=1 npx tsx agent.ts    # Action dispatch only
LUMEN_LOG_CDP=1 npx tsx agent.ts        # Chrome DevTools Protocol traffic
LUMEN_LOG_LOOP=1 npx tsx agent.ts       # Perception loop internals