Product stage: Alpha

API Reference

Each section describes one API or workflow. The code selector is shared across the page: choosing a language in one panel updates every panel. Both published SDKs expose this surface — TypeScript with async methods and camelCase options, Python with blocking methods and the same options in snake_case (max_iterations, screenshot_enabled, result_schema, …). Sections and options marked Coming soon ship with a later native runtime release. Attaching to a caller-owned Playwright page remains TypeScript-only.

Account

Go to Sign up and complete the account flow, then open the dashboard. The dashboard is where you manage API keys and account usage.

API key

In the dashboard, open the API keys section, create a key, and copy the secret when it appears. The complete secret is shown only at creation. Anyone who obtains it can authenticate as your account and consume your usage balance. Do not commit it to source control, include it in client-side browser code or a distributed binary, print it in logs, or send it through chat and issue trackers.

macOS and Linux shell

export NODEMANTIS_API_KEY="sk_live_<copy-from-dashboard>"

Run export in a terminal before starting your application from that same terminal. It sets NODEMANTIS_API_KEY for the current shell process and programs launched by it. It does not upload the key or change Node Mantis configuration, and it disappears when that shell closes.

Windows PowerShell

$env:NODEMANTIS_API_KEY = "sk_live_<copy-from-dashboard>"

PowerShell's $env: assignment has the same current-session scope. Start the application from that PowerShell window. For local Python use, python -m nodemantis configure --api-key "sk_live_<copy-from-dashboard>" can instead write a private user config file.

Browser installation

Node Mantis drives a real Google Chrome on your machine. Managed NodeMantis.start sessions and the default TypeScript preflight require a discoverable Google Chrome installation. The npm package declares Playwright as a peer dependency, so npm installs the Playwright library alongside the SDK — but installing the packages does not download a browser for you, so install Chrome explicitly before your first run.

npm install node-mantis@0.1.0-alpha.10
npx playwright install chrome

The Python [browser] extra installs Playwright for Python smoke and diagnostic tools. A TypeScript application can attach Node Mantis to a caller-owned Chromium page after installing the matching browser binary:

npx playwright install chromium

A missing browser produces an install command instead of downloading in the background. Python smoke runs may offer to install the selected browser when attached to an interactive terminal. Non-interactive and CI runs fail until installation is explicit, or until smoke is invoked with --install-browser.

Shared client options

These options configure NodeMantis.start and NodeMantis.attach. NodeMantis.preflight uses the same apiKey resolution rules. Options are listed in their TypeScript form; Python takes the same options in snake_case (api_key, llm_timeout_ms, default_agent_options, logging).

OptionTypeDefaultDescription
apiKeystringenvironmentBearer credential for hosted requests. An explicit value overrides the NODEMANTIS_API_KEY and NODEMANTIS_AUTH_TOKEN environment variables.
llmTimeoutMsnumber120000Maximum time in milliseconds for each hosted model request before the SDK aborts it.
defaultAgentOptionsobjectSDK defaultsSession-wide defaults for model, maxIterations, timeout, screenshotEnabled, and step maxActions. Per-call options override them.
loggingNodeMantisLoggingOptionsinfo, 7 days, 200 MBConfigures local file logging for the forthcoming native runtime; see Local logging below.

Local logging Coming soon

The native runtime writes an info log by default. Local defaults are seven days and 200 MB, with startup cleanup. Platform directories are ~/Library/Logs/nodemantis on macOS, $XDG_STATE_HOME/nodemantis/logs on Linux when XDG_STATE_HOME is set (otherwise ~/.local/state/nodemantis/logs), and %LOCALAPPDATA%\nodemantis\logs on Windows.

The runtime process is shared. Directory and retention settings are first-start-wins for a running process; a later session can raise the effective level but cannot lower it. The equivalent environment variables are NODEMANTIS_LOG_LEVEL, NODEMANTIS_LOG_DIR, NODEMANTIS_LOG_RETENTION_DAYS, and NODEMANTIS_LOG_MAX_MB. Treat debug logs as sensitive. Hosted service transcripts are covered by the Privacy Policy and may be retained for up to 60 days.

OptionTypeDefaultDescription
level"off" | "info" | "debug"infoControls local runtime file logging. Debug also writes a JSONL diagnostic log and can contain sensitive task context.
dirstringplatform log directoryOverrides the local log directory for a newly started shared runtime process.
retentionDaysnumber7Deletes older local log files during startup. Set 0 to disable age-based cleanup.
maxTotalSizeMbnumber200Deletes the oldest local log files until the directory is under this size. Set 0 to disable the cap.

NodeMantis.preflightAvailable now

Validates hosted API health, key presence, authenticated account usage, and a browser launch. Run it when preparing a workstation or CI image. Python exposes the same checks as NodeMantis.preflight; run_smoke and python -m nodemantis doctor remain the installation-smoke alternatives.

import { NodeMantis } from "node-mantis";

const report = await NodeMantis.preflight({
  checkBrowser: true,
  timeoutMs: 5000,
});

if (!report.ok) {
  console.error(report.checks);
  process.exit(1);
}

TypeScript returns { ok, hasApiKey, checks }. Check names are service, apiKey, usage, andbrowser. Its options are listed below.

OptionTypeDefaultDescription
checkBrowserbooleantrueLaunches and releases managed Chrome as part of the report. Set false when only service and credential checks are needed.
timeoutMsnumber5000Timeout in milliseconds applied separately to the health and authenticated usage requests.

NodeMantis.start(options?)Available now

Launches a managed local Chrome context and returns a Node Mantis session. The session owns the context, so call mantis.close() when work finishes. Pass navigationOnly: true for goand direct read-only page inspection without installing agent perception;run, step, retrieve, extract, and check reject in that mode. It accepts all shared client options plus the browser options below.

const mantis = await NodeMantis.start({
  startUrl: "https://example.com",
  headless: true,
  viewport: { width: 1280, height: 720 },
});
OptionTypeDefaultDescription
signalAbortSignalnoneCancels managed-browser provisioning before a session has been returned. Ships with the native runtime.
startUrlstringabout:blankInitial URL opened after Chrome starts. The SDK waits for DOMContentLoaded before returning the session.
headlessbooleantrueRuns Chrome without a visible window. Set false for local observation and debugging.
navigationOnlybooleanfalseCreates a session that only navigates and inspects the page, without the agent, for go and direct read-only inspection. Agent and perception methods reject on this session. Ships with the native runtime.
viewport{ width, height }1280 x 720Playwright viewport used for page layout, screenshots, and coordinate-based actions.
useProxybooleanfalseSelects a session proxy from NODEMANTIS_PROXY, NODEMANTIS_PROXY_LIST, or NODEMANTIS_PROXY_FILE for this managed context.
defaultTimeoutMsnumber60000Default Playwright timeout in milliseconds for page and action operations in the managed context.
contextOptionsBrowserContextOptions{}Additional Playwright browser-context options. viewport, proxy, and ignoreHTTPSErrors are managed by the session and cannot be overridden here.

NodeMantis.attach(page, options?)Available now

Binds Node Mantis to an existing Playwright Page and accepts the shared client options. The caller retains ownership of the page, context, and browser. mantis.close() ends the Node Mantis session but does not close those caller-owned Playwright resources.

const mantis = await NodeMantis.attach(page);

mantis.go(url, options?)Available now

Navigates the session page and returns the final URL and title as { ok, url, title }. Calls on one session are serialized with all other Node Mantis operations. Direct calls through mantis.page bypass that queue.

const navigation = await mantis.go("https://example.com", {
  waitUntil: "domcontentloaded",
  timeout: 30000,
});
OptionTypeDefaultDescription
waitUntil"load" | "domcontentloaded" | "networkidle" | "commit"domcontentloadedPlaywright lifecycle event that marks navigation as complete.
timeoutnumberpage defaultNavigation timeout in milliseconds. When omitted, the page or managed-context default applies.

mantis.run(goal, options?)Available now

Runs a multi-step browser goal until it succeeds, fails, times out, or reaches its iteration limit. Pass a schema or enable retrieval to include value, valueStatus, valueContributorIds, and any retrievalError in the operation result.

const result = await mantis.run("Open the pricing page.", {
  maxIterations: 10,
  timeout: 120000,
  screenshotEnabled: true,
});
OptionTypeDefaultDescription
model"small" | "standard" | "large"standardSize tier for agent decisions; the service maps it to a model. large is coming soon.
maxIterationsnumber30Maximum perception-and-action iterations before the run stops.
timeoutnumber300000Overall operation timeout in milliseconds.
screenshotEnabledbooleantrueIncludes page screenshots in the agent perception context.
resultSchemaZod | JSON SchemanoneOpts into structured retrieval and populates value, valueStatus, valueContributorIds, and any retrievalError.
enableRetrievalbooleanfalseEnables free-form retrieval when no result schema is required.
maxCostnumberno ceilingOptional hard USD ceiling for retrieval work in this operation.

mantis.step(instruction, options?)Available now

Runs a bounded instruction against the current page, maps maxActions to the loop limit, and stops as soon as the visible page satisfies the instruction. Navigation is discouraged unless allowNavigation is true or staying on the page makes the instruction impossible.

const result = await mantis.step("Open the pricing page.", {
  maxActions: 5,
  allowNavigation: true,
});
OptionTypeDefaultDescription
maxActionsnumber15Maximum actions available to this bounded instruction.
allowNavigationbooleanfalseDeclares whether leaving the current page is expected. When false, the agent is instructed to remain unless the task is otherwise impossible.
model"small" | "standard" | "large"standardSize tier for agent decisions; the service maps it to a model. large is coming soon.
timeoutnumber300000Overall operation timeout in milliseconds.
screenshotEnabledbooleantrueIncludes page screenshots in the agent perception context.
resultSchemaZod | JSON SchemanoneOpts into structured retrieval and populates value, valueStatus, valueContributorIds, and any retrievalError.
enableRetrievalbooleanfalseEnables free-form retrieval when no result schema is required.
maxCostnumberno ceilingOptional hard USD ceiling for retrieval work in this operation.

mantis.retrieve(prompt, options?)Available now

Performs one semantic capture of the current live DOM and returns grounded current-page information. It does not click, search, paginate, or navigate. Use retrieval-enabled run or stepwhen interaction is required.

The single-capture behavior and result fields shown here (contributorIds and the three terminal statuses) are the forthcoming native-runtime form. In the published npm alpha, retrieve also accepts a mode (page, interactive, or auto) and can additionally return partial and ambiguous statuses.

const result = await mantis.retrieve("List the plans on this page.", {
  schema: z.object({ plans: z.array(z.string()) }),
  model: "small",
});

if (result.status === "success") {
  console.log(result.data, result.contributorIds);
} else {
  console.log(result.status, result.reason);
}
OptionTypeDefaultDescription
schemaZod | JSON Schemafree-formDefines the expected result shape and enables typed success data for Zod callers.
model"small" | "standard" | "large"standardSize tier the service maps to a model. large is coming soon.

Supported schema keywords are type, properties, required, items, enum, minItems, maxItems, and description. Metadata keywords such as $schema,$id, title, default, examples, and additionalProperties are ignored. Unsupported keywords including $ref, anyOf, pattern, and format reject the request with SCHEMA_UNSUPPORTED.

mantis.extract(prompt, options?)Available now

Compatibility API for current-page extraction. It accepts a schema and model, then returns the extracted value through the standard operation result's value field. Use retrieve when the strict terminal status, contributor IDs, warnings, token usage, and final URL are required.

const result = await mantis.extract("Summarize this page.", {
  schema: z.object({ summary: z.string() }),
  model: "small",
});

console.log(result.ok, result.value);
OptionTypeDefaultDescription
schemaZod | JSON Schemafree-formDefines the expected extracted value shape.
model"small" | "standard" | "large"standardSize tier the service maps to a model.

mantis.check(prompt, options?)Available now

Evaluates whether the current page satisfies a condition using visible page text. It returns the standard operation shape. An ok: false value can be a legitimate negative verdict, not only an execution failure.

const result = await mantis.check(
  "Is the pricing page visible?",
  { model: "small" },
);
OptionTypeDefaultDescription
model"small" | "standard" | "large"standardSize tier the service maps to a model.

mantis.close()Available now

Marks the session closed and releases a managed context created by NodeMantis.start. It is idempotent and best-effort aborts active and queued SDK operations. For sessions created by NodeMantis.attach, the caller still owns and closes the Playwright resources.

await mantis.close();

resolve_config(...)

Resolves Python credentials with a source label, the selected config path, and the parsed file config. It does not make a network request.

TypeScript resolves apiKey when an SDK operation starts; it does not expose a standalone resolve_config helper.

OptionTypeDefaultDescription
api_keystr | NoneNoneExplicit key with highest precedence.
config_pathPath | str | NoneOS user configOverrides the platform-specific user config path.
envMapping | Noneos.environEnvironment mapping used during resolution; useful for tests.

runtime_platform_info(...)

Normalizes the current operating system and architecture and returns { os_name, arch, tag }. It raises UnsupportedPlatformError outside the four supported targets.

The TypeScript package resolves its platform runtime internally and does not expose runtime_platform_info.

OptionTypeDefaultDescription
os_namestr | Noneplatform.system()Optional operating-system override for deterministic tests.
machinestr | Noneplatform.machine()Optional architecture override for deterministic tests.

run_smoke(...)

Executes the Python installation smoke: resolves credentials, checks the supported platform, runs the package compatibility self-check, probes authenticated hosted API usage, launches the selected browser, and asserts the bundled local fixture. This helper is not the browser-driving product runtime.

Use NodeMantis.preflight for TypeScript installation validation. run_smoke is a Python package helper.

OptionTypeDefaultDescription
api_keystr | Noneresolved configExplicit API key; overrides environment variables and the user config file.
browser"chrome" | "chromium"chromeBrowser channel to validate and launch. Chromium is the explicit CI fallback.
install_browserboolfalseInstalls the selected browser when it is missing before continuing the smoke.
headlessbooltrueRuns the bundled fixture check without a visible browser window.
skip_backendboolfalseSkips the authenticated usage probe. Intended for package tests only.
timeout_secondsint15Timeout for the authenticated backend usage request.

Command line

Both distributions install a nodemantis command. The npm package ships the full CLI surface — run and retrieve plus the setup verbs — documented in the CLI reference. The Python package exposes only the setup verbs (configure, doctor, install-browser, smoke) as operational commands. Use --help on any command for its complete argument list.

nodemantis configure --api-key "sk_live_<copy-from-dashboard>"
nodemantis doctor --browser chrome --json
nodemantis run "Open the pricing page and report the Pro plan price." \
  --url https://example.com
nodemantis retrieve "List the plan names." --url https://example.com --json

Result contracts

run, step, extract, and check return an operation result with ok, reason, and optional iterations and traceId. Retrieval-enabled runs also include value, valueStatus, valueContributorIds, and retrievalError.

retrieve returns exactly one terminal status: success, not_found, or error. Every result includes ok, status, data, contributorIds, reason, string warnings, tokens, finalUrl, and an optional traceId. Success has non-null data and at least one contributor ID; not-found is ok: true with null data; error is ok: false with null data.

The session also exposes readonly mantis.page and mantis.sdkSessionId for direct Playwright access and correlation. mantis.capabilityMode arrives with the native runtime.