@ev-ai/agent-hook 1.4.1 → 1.4.2

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.
package/COLLECTED-DATA.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Collected data
2
2
 
3
- What `@ev-ai/agent-hook` POSTs to the ev-ai collector (`POST /{orgToken}/hook`, default `https://hooks.ev-ai.ai/{orgToken}/hook`). Auth is the org path id in the URL — no Bearer header and not in the JSON body. See [README.md](./README.md) for install and privacy defaults.
3
+ What `@ev-ai/agent-hook` POSTs to the ev-ai collector (`POST /{orgToken}/hook` on the collector host given at install; there is no default host). Auth is the org path id in the URL — no Bearer header and not in the JSON body. See [README.md](./README.md) for install and privacy defaults.
4
4
 
5
5
  ## Tracked events
6
6
 
@@ -55,7 +55,7 @@ Unless machine telemetry is off, `perf` also carries `sys`, a sample of the mach
55
55
  - `duration_ms` — from Claude `duration_ms` or Cursor `duration` on post-tool / `afterShellExecution` stdin
56
56
  - `mcp_server` / `mcp_tool` — separate fields, never a `server__tool` blob. Cursor `beforeMCPExecution` / `afterMCPExecution` stdin `mcp_server_name` (the mcp.json key) is the server when present; otherwise derived from opaque `tool_name` when it matches Claude `mcp__<server>__<tool>` or Cursor `MCP:<server>:<tool>` / `MCP:<server>__<tool>` / `MCP:<tool>` (no `tool_input` parsing). `mcp_server_name` itself is not POSTed. Claude has no equivalent stdin field, so the `mcp__` form is split against the **declared** `mcpServers` keys first — a declared name whose tool-name spelling (every character outside `[A-Za-z0-9_-]` replaced, `acme.tools` → `acme_tools`) prefixes the rest wins, longest first, and `mcp_server` is then the config key rather than the runner's spelling. Splitting on the first `__` is only the fallback for a server that is not declared locally (claude.ai connectors, plugin servers), so a tool id that itself contains `__` (`mcp__aws__aws___call_aws` → tool `aws___call_aws`) and a server name that contains `__` both survive.
57
57
  - **`mcp_package_name` / `mcp_package_spec` / `mcp_package_version` / `mcp_package_version_source`** — npm identity of an MCP server launched through `npx` / `npm exec` or a local `node_modules/.bin` launcher, resolved on MCP live events. Cursor `beforeMCPExecution` carries the spawn command, which is tokenized in-process for package identity and never POSTed — that argv routinely embeds `--api-key <secret>`. Claude Pre/Post MCP tool hooks — and Cursor MCP tool hooks — have no spawn command on stdin, so the same identity is resolved from the declared server's `command`/`args` in MCP config (`~/.claude.json` — top-level plus the launch directory's `projects[<cwd>].mcpServers`, where Claude keeps `--scope local` servers — `.mcp.json`, `.cursor/mcp.json`); that launch line is still never POSTed. What leaves the machine is the package name (`@playwright/mcp`), the spec as declared (`@playwright/mcp@latest`), and the exact version behind it. `mcp_package_version` is read from npm's own `_npx` install tree — the directory npm names from a hash of the package specs — when that tree exists, and is then what really ran (`mcp_package_version_source: npx_cache`). When there is no tree and the spec names an exact version (`gitnexus@1.6.5`; strict SemVer 2.0, so `foo@01.2.3` is not a pin), that pin is reported with `mcp_package_version_source: declared_pin`, so a declared pin is never mistaken for an observed install; an installed version always wins over the pin. A floating tag reports its resolved version; a cache miss on a floating tag or range reports the spec with no version, which is normal before the runner has launched the server once, after a failed or cleaned install, and for a package resolved from a local or global `node_modules` (npm creates no `_npx` tree then). A server whose launch command is a project-local `node_modules/.bin/<x>` launcher (`/Users/me/git/repo/node_modules/.bin/gitnexus mcp`, or `~/…/node_modules/.bin/<x>`) reports `mcp_package_name` and `mcp_package_version` read from the installed package's own `package.json`, with `mcp_package_version_source: node_modules_local` and no `mcp_package_spec` (a launcher path declares no spec). The launcher is followed only when it is a symlink (npm and Yarn's `node-modules` linker on macOS / Linux): from the file it points at, the walk goes up to the nearest `package.json` that has a `name`, skipping nameless nested manifests such as `dist/package.json`; that manifest must sit at `node_modules/<name>` or `node_modules/@scope/<name>` and its version must be strict SemVer 2.0. Then the package manager's own install state must show that this install location was fetched from an npm registry as exactly that name and version, so `node_modules_local` always means "registry-verified": Yarn Berry's `node_modules/.yarn-state.yml` (`nodeLinker: node-modules`) must list the folder under an `<name>@npm:<version>` locator (a peer-dependency `virtual:` instance of one counts), or npm v7+'s hidden lockfile `node_modules/.package-lock.json` must have an entry for the folder whose `resolved` is an http(s) URL with the registry tarball layout (`…/<name>/-/<name>-<version>.tgz`, any registry host) and that is neither `link: true` nor `inBundle`. The state file is looked for under every ancestor that holds the folder inside its `node_modules`, so hoisted, nested (`node_modules/a/node_modules/b`) and workspace-local installs all resolve; every entry found must agree. A git, tarball, `file:`, `link:` / `portal:`, workspace or `patch:` install, a version that differs from the manifest, a folder the state does not list, and a missing, unreadable, or unknown-format state file (pnpm, bun, Yarn PnP, npm v6) report nothing at all — no name and no version — because a fork carrying a registry name would otherwise be matched against the registry artifact's advisories. The directory must match the manifest name, except for an npm alias (`"pw": "npm:@playwright/mcp@0.0.41"` installs into `node_modules/pw`), which is accepted only when the install state names the real package (npm's `name` field on the entry, or Yarn's locator) and then reports that real name. Manifests over 1 MiB and state files over 16 MiB are not read, nor is anything that is not a regular file (a FIFO cannot block the hook). Shim files (pnpm, npm on Windows `.cmd` / `.ps1`), Yarn PnP, workspace-linked packages, and relative launchers (`./node_modules/.bin/<x>` — they resolve against the runner's spawn directory, which the hook does not know) report nothing. HTTP / SSE servers, plain binaries, `uvx`, other local paths, tarball and git specs report nothing. A bare flag of unknown arity is a hard stop rather than a guess, so `npx --api-key <secret> server` reports no package at all — mis-reading the argv would publish a credential as a package name. A `Bash` tool that happens to run `npx` is never reported as a server.
58
- - `component_reference` — an opaque exact-component identifier emitted only when the hook has complete repository-backed identity evidence. Exact skill paths map to SKILL installations; exact MCP server and MCP tool invocations map to the server INTERFACE installation, never to a tool installation; exact rule paths under a layout rules root map to RULE installations; exact command paths under a layout commands root map to COMMAND installations. An MCP reference needs a declared server: a repository declaration hashes on the file that declares it (`.mcp.json`, `.cursor/mcp.json`), a git-root `.mcp.json` only for a root-scope agent, and `.cursor/mcp.json` only for a Cursor agent; when both files declare the same name, the runner's own file wins. Name-only, flat/unattributed MCP, undeclared MCP servers (runner built-ins such as Claude's `ccd_turn`, claude.ai connectors `claude_ai_<name>`; Codex excepted, whose undeclared servers key on the user `config.toml`), malformed scope, and missing platform-agent identity stay unmatched. Three surfaces produce a file-backed reference: a slash-command event when a matching `SKILL.md` or command file is found locally, a Cursor rule-attachment event when a matching rules file is found locally, and any tool event whose stdin path resolves under a layout skills / rules / commands root — which is the only route Claude has for non-MCP components. On a tool event the MCP reference wins when both could apply, and a Write / edit of one of those files does not count as usage. The resolved path is never POSTed. Absolute local paths never leave the hook process: path evidence is realpath-canonicalized (so a `.cursor/rules/claude` symlink to `.claude/rules` hashes the git path) then stripped to the repository-relative source path before hashing, and only the opaque reference is sent.
58
+ - `component_reference` — an opaque exact-component identifier emitted only when the hook has complete repository-backed identity evidence. Exact skill paths map to SKILL installations; exact MCP server and MCP tool invocations map to the server INTERFACE installation, never to a tool installation; exact rule paths under a layout rules root map to RULE installations; exact command paths under a layout commands root map to COMMAND installations. A repository file's installation root is the first marker dir in its path (`.claude`, `.cursor`, `.codex`, `.opencode`, `.github`), whichever runner read it; a file under Codex's `.agents/` dir keys on the sibling `.codex` root (`packages/api/.agents/skills/x/SKILL.md` → `<slug>:packages/api/.codex`), because repo-syncer files `.agents/**` under the Codex scope (which exists only when the repo also has a `.codex/` dir at that prefix; an `.agents`-only repo has no matching inventory installation). An MCP reference needs a declared server: a repository declaration hashes on the file that declares it (`.mcp.json`, `.cursor/mcp.json`), a git-root `.mcp.json` only for a root-scope agent, and `.cursor/mcp.json` only for a Cursor agent; when both files declare the same name, the runner's own file wins. Name-only, flat/unattributed MCP, undeclared MCP servers (runner built-ins such as Claude's `ccd_turn`, claude.ai connectors `claude_ai_<name>`; Codex excepted, whose undeclared servers key on the user `config.toml`), malformed scope, and missing platform-agent identity stay unmatched. Three surfaces produce a file-backed reference: a slash-command event when a matching `SKILL.md` or command file is found locally, a Cursor rule-attachment event when a matching rules file is found locally, and any tool event whose stdin path resolves under a layout skills / rules / commands root — which is the only route Claude has for non-MCP components. On a tool event the MCP reference wins when both could apply, and a Write / edit of one of those files does not count as usage. The resolved path is never POSTed. Absolute local paths never leave the hook process: path evidence is realpath-canonicalized (so a `.cursor/rules/claude` symlink to `.claude/rules` hashes the git path) then stripped to the repository-relative source path before hashing, and only the opaque reference is sent.
59
59
  - `subagent_type` — on subagent start/stop hooks, which carry an agent type instead of a `tool_name`: Claude `agent_type` (`Explore`, plugin-scoped `my-plugin:reviewer`) or Cursor `subagent_type` (`generalPurpose`, `explore`). Only identifier-shaped values are sent; the neighbouring `task` / `description` / `summary` fields are free prose and are never captured
60
60
  - Allowlisted hook metadata (see below)
61
61
 
package/README.md CHANGED
@@ -6,7 +6,7 @@ Cross-runner runtime telemetry hook for **Claude Code**, **Cursor**, and **OpenA
6
6
 
7
7
  This is an **opt-in, first-party observability agent** that an ev-ai customer installs on their own developers' machines / CI to get an inventory and runtime view of **their own org's AI coding-agent usage**. It is the AI-coding-agent equivalent of an EDR/telemetry sensor or an APM agent: the org deploys it, on its own hosts, to send data **to its own collector**.
8
8
 
9
- - **Data goes to the customer's own collector.** The destination is the org's ev-ai endpoint (default `https://hooks.ev-ai.ai/{orgToken}/hook`, or a self-hosted collector via `--url`). It is not a third party from the org's perspective — the customer is the data controller.
9
+ - **Data goes to the customer's own collector.** The destination is the org's collector endpoint, always given explicitly (`--url https://<collector-host>/{orgToken}/hook`, or `--token` with `--base-url`); the package has no built-in collector host. It is not a third party from the org's perspective — the customer is the data controller.
10
10
  - **It is consent-based and removable.** Nothing installs silently: the operator enables the ev-ai plugins (or runs file-wiring `install`), and uninstall / plugin disable removes ev-ai wiring. Non-managed hooks can be removed locally by the developer at any time.
11
11
  - **Prompt collection is opt-in, and it covers every content body.** User prompts, tool args, tool results and the last assistant message (`hook_input.prompt`, `tool_input`, `tool_response`, `last_assistant_message`, Cursor `command`) are dropped by default and sent together (size-capped) with `EV_AI_HOOK_CAPTURE_PROMPT=on` or the org config `collect_prompt`. With prompt capture off, a plain prompt submit sends no event at all (Claude/Codex `UserPromptSubmit`, Cursor `beforeSubmitPrompt` with no slash command or rule attachment). Slash-command and rule rows from those hooks still send, without the prompt. Policy rules still match them locally either way.
12
12
  - **Content kill switch.** `EV_AI_HOOK_CAPTURE_CONTENT=off` or `capture_hook_input: "allowlist"` drops all of them even when prompt collection is on. On Claude that includes file bodies written or read through a tool, which arrive nested in `tool_input` / `tool_response`. Session titles, chat transcripts, keystrokes, and runner error prose stay dropped. `env_vars` is a fixed allowlist of non-secret CI/runtime markers; API keys are never read, and proxy vars are used only to route the POST, never sent. See [Privacy defaults](#privacy-defaults).
@@ -114,7 +114,7 @@ Wired command shape (auth is in the committed `collector_url`). The per-event co
114
114
  npx -y --prefer-offline @ev-ai/agent-hook@1.0.6 --runner cursor
115
115
  ```
116
116
 
117
- You can optionally put the collector URL on the hook command itself — `--url` (or `--token` + optional `--base-url`) overrides any shared manifest, so `.claude/ev-ai-runtime-report.json` is not required:
117
+ You can optionally put the collector URL on the hook command itself — `--url` (or `--token` with `--base-url`, which it requires) overrides any shared manifest. A `--token` without `--base-url` sends nothing; it does not fall back to another source, so `.claude/ev-ai-runtime-report.json` is not required:
118
118
 
119
119
  ```json
120
120
  {