# Phase 81.17.c — out-of-tree standalone repo.
#
# Built as a binary subprocess plugin loaded by the nexo-rs daemon
# via discovery + auto-subprocess fallback (Phase 81.17 + 81.17.b).
# The daemon spawns this binary, JSON-RPC handshakes over stdio,
# and routes `tool.invoke` requests for the 12 `browser_*` tools
# through the SDK's `on_tool` dispatcher.
#
# Path deps to `../proyecto/crates/...` are interim — they ship
# this repo today before nexo-microapp-sdk + nexo-config + the
# rest publish to crates.io. Operators outside the monorepo build
# the binary against published crates.io versions; the
# `Cargo.lock` (committed; binary repo convention) pins the
# resolved versions for reproducibility.
[package]
name        = "nexo-plugin-browser"
version     = "0.4.3"
description = "Chrome DevTools Protocol (CDP) browser plugin for Nexo agents (out-of-tree subprocess)."
edition     = "2021"
license     = "MIT OR Apache-2.0"
repository  = "https://github.com/lordmacu/nexo-plugin-browser"
authors     = ["Cristian García <informacion@cristiangarcia.co>"]
readme      = "README.md"
keywords    = ["nexo", "plugin", "browser", "cdp", "agent"]
categories  = ["api-bindings", "command-line-utilities"]
rust-version = "1.75"

[[bin]]
name = "nexo-plugin-browser"
path = "src/main.rs"

# Plain cargo bench harness — no criterion dep weight. The bench
# measures stdio round-trip latency of `tool.invoke` against a
# spawned binary. Run with `cargo bench --bench tool_latency`.
[[bench]]
name = "tool_latency"
path = "benches/tool_latency.rs"
harness = false

[features]
default = []
# Opt-in Tier 0 of browser discovery: download
# `chrome-headless-shell` from Google's chrome-for-testing
# catalogue instead of relying on a system Chrome. Off by
# default — flip the feature AND set
# `NEXO_PLUGIN_BROWSER_AUTO_DOWNLOAD=1` at runtime to enable.
auto-download = ["dep:zip", "dep:dirs"]

[dependencies]
tokio             = { version = "1", features = ["rt-multi-thread", "macros", "sync", "process", "io-util", "time"] }
serde             = { version = "1", features = ["derive"] }
serde_json        = "1"
serde_yaml        = "0.9"
anyhow            = "1"
thiserror         = "1"
tracing           = "0.1"
async-trait       = "0.1"
dashmap           = "6"
once_cell         = "1"
sha2              = "0.10"
tokio-tungstenite = "0.24"
tokio-util        = "0.7"
base64            = "0.22"
reqwest           = { version = "0.12", default-features = false, features = ["rustls-tls"] }
futures           = "0.3"
uuid              = { version = "1", features = ["serde", "v4"] }
# Phase 27.x.browser-windows-discovery — cross-platform PATH
# lookup. Replaces a hand-rolled `which_exists` that split PATH
# by `:` (Unix-only — broke Windows where the separator is `;`
# and drive letters like `C:\Program Files\...` got truncated).
# `which = "7"` honours `PATHEXT` on Windows, the platform
# separator, and registered shortcuts.
which             = "7"

# Phase 81.20.x F-portable — framework deps from crates.io only.
# Slim dep set — only what the subprocess actually needs.
nexo-microapp-sdk = { version = "0.1.18", features = ["plugin"] }
nexo-broker       = "0.1.5"
nexo-cdp          = "0.1.0"
nexo-config       = "0.1.9"

# 0.4.0 — opt-in Tier 0 browser discovery via the embedded
# `auto_download` module. When the `auto-download` feature is
# on AND `NEXO_PLUGIN_BROWSER_AUTO_DOWNLOAD=1` is set, the
# launcher fetches `chrome-headless-shell` from Google's
# chrome-for-testing CDN, extracts to the user cache, and
# launches that binary. zip = unzip support; dirs = locating
# the platform-appropriate user cache root (XDG / macOS /
# Windows).
zip                = { version = "2", optional = true }
dirs               = { version = "5", optional = true }

# Follow-up `browser.auto_discovery.subscriber` — broker subscriber
# loop wiring. rustls crypto provider install required for the NATS
# TLS path (mirrors telegram + whatsapp plugins).
rustls = { version = "0.23", default-features = false, features = ["ring"] }

# toml: the copied plugin.rs uses `toml::from_str` to parse the
# bundled manifest.
toml = "0.8"

# Step 9 of browser-multi-instance — per-instance metrics. Vanilla
# `prometheus` (not `prometheus-client`) matches the daemon-side
# stack so scrape bodies share encoding.
prometheus = { version = "0.14", default-features = false }

[dev-dependencies]
libc        = "0.2"
assert_cmd  = "2"
serial_test = "3"
tempfile    = "3"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
# Step 8 of browser-multi-instance — manifest parse coverage. Uses
# the path dep against the in-tree daemon workspace so manifest
# schema changes land lock-step with this plugin.
nexo-plugin-manifest = "0.1.8"

[profile.release]
opt-level = 3
lto = "thin"
strip = "symbols"

# Iterative release builds — full opt, no LTO, parallel codegen.
# Costs ~5 % runtime; saves ~50 % build time. Reserve `--release`
# for publish.
[profile.release-fast]
inherits      = "release"
lto           = false
codegen-units = 16
strip         = "none"

# Phase 93.4.e — mirror the proyecto workspace `[workspace.lints.clippy]`
# allow-list so the verbatim-copied modules don't trip clippy gates
# that the upstream workspace already silences.
[lints.clippy]
absurd_extreme_comparisons = "allow"
needless_return            = "allow"
needless_borrow            = "allow"
needless_borrows_for_generic_args = "allow"
ptr_arg                    = "allow"
manual_pattern_char_comparison = "allow"
incompatible_msrv          = "allow"
doc_overindented_list_items = "allow"
doc_lazy_continuation      = "allow"
