@agenthoney/analytics 0.0.0-stage → 0.14.0
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/LICENSE +21 -0
- package/README.md +85 -2
- package/dist/answers.cjs +20034 -0
- package/dist/answers.cjs.map +1 -0
- package/dist/answers.d.ts +148 -0
- package/dist/answers.js +139 -0
- package/dist/answers.js.map +1 -0
- package/dist/chunk-CD4WLJX7.js +48 -0
- package/dist/chunk-CD4WLJX7.js.map +1 -0
- package/dist/chunk-F3PRHEXB.js +20143 -0
- package/dist/chunk-F3PRHEXB.js.map +1 -0
- package/dist/chunk-L22VERBM.js +911 -0
- package/dist/chunk-L22VERBM.js.map +1 -0
- package/dist/chunk-OH4H2B7O.js +150 -0
- package/dist/chunk-OH4H2B7O.js.map +1 -0
- package/dist/chunk-R76CTIBG.js +701 -0
- package/dist/chunk-R76CTIBG.js.map +1 -0
- package/dist/chunk-UG3REZCJ.js +147 -0
- package/dist/chunk-UG3REZCJ.js.map +1 -0
- package/dist/core/breaker.d.ts +33 -0
- package/dist/core/collector.d.ts +51 -0
- package/dist/core/config.d.ts +124 -0
- package/dist/core/encode.d.ts +32 -0
- package/dist/core/queue.d.ts +39 -0
- package/dist/core/record-gate.d.ts +17 -0
- package/dist/core/safe.d.ts +17 -0
- package/dist/core/transport.d.ts +45 -0
- package/dist/express.cjs +21789 -0
- package/dist/express.cjs.map +1 -0
- package/dist/express.d.ts +65 -0
- package/dist/express.js +6 -0
- package/dist/express.js.map +1 -0
- package/dist/index.cjs +22118 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/next.cjs +21186 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.ts +90 -0
- package/dist/next.js +5 -0
- package/dist/next.js.map +1 -0
- package/dist/observe/client-ip.d.ts +109 -0
- package/dist/observe/next-router.d.ts +22 -0
- package/dist/observe/redact.d.ts +58 -0
- package/dist/observe/request.d.ts +75 -0
- package/dist/observe/response.d.ts +24 -0
- package/dist/runtime.d.ts +27 -0
- package/dist/serve/accept.d.ts +7 -0
- package/dist/serve/discovery.d.ts +56 -0
- package/dist/serve/hosted.d.ts +135 -0
- package/dist/serve/source.d.ts +48 -0
- package/dist/serve/tag-asset.generated.d.ts +14 -0
- package/dist/serve/tag.d.ts +131 -0
- package/dist/serve/twin.d.ts +162 -0
- package/dist/web.cjs +21225 -0
- package/dist/web.cjs.map +1 -0
- package/dist/web.d.ts +52 -0
- package/dist/web.js +6 -0
- package/dist/web.js.map +1 -0
- package/install.md +463 -0
- package/package.json +76 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fifth Mind LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,86 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @agenthoney/analytics
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Analytics for the agentic web — and the other half nobody ships: **serving those agents a clean
|
|
4
|
+
markdown twin from the same middleware**.
|
|
5
|
+
|
|
6
|
+
One `app.use`. It observes every request at the server boundary, so it counts the clients that
|
|
7
|
+
never run JavaScript, and it can serve a markdown representation of a page to anything that asks
|
|
8
|
+
for one.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { agenthoney } from "@agenthoney/analytics/express";
|
|
12
|
+
|
|
13
|
+
app.use(agenthoney());
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Nothing loads in a visitor's browser. No client script, no cookies.
|
|
17
|
+
|
|
18
|
+
## Installing with a coding agent
|
|
19
|
+
|
|
20
|
+
Point it at **<https://agenthoney.ai/install.md>** — the same guide this package serves from
|
|
21
|
+
your own middleware. It is written for an agent rather than a person: imperative, naming the
|
|
22
|
+
failure modes, and telling the agent to stop rather than guess at a credential.
|
|
23
|
+
|
|
24
|
+
## The three properties worth knowing before you install
|
|
25
|
+
|
|
26
|
+
**It never blocks and never fails your responses.** `record()` is synchronous and returns `void`,
|
|
27
|
+
every adapter entry point wears one `safe()` wrapper, and nothing awaits the network on the
|
|
28
|
+
request path. The serve path fails open to *content*: any throw, timeout or manifest miss falls
|
|
29
|
+
through to your own handler with the response unchanged. Each adapter has a test asserting
|
|
30
|
+
byte-identical output with and without the middleware — including with a collector injected to
|
|
31
|
+
throw on every call.
|
|
32
|
+
|
|
33
|
+
**The response is inspected, never consumed.** `res` is a single-read stream, and monkey-patching
|
|
34
|
+
`write`/`end` to observe a body adds latency, adds memory, and can corrupt what you send. This
|
|
35
|
+
reads what is already in the headers.
|
|
36
|
+
|
|
37
|
+
**⚠️ The markdown twin is gated on `Accept`, never on identity.** A crawler sending
|
|
38
|
+
`Accept: */*` receives exactly what a browser receives. Serving different content by User-Agent
|
|
39
|
+
is cloaking, it forces `Vary: User-Agent` (which disables shared caching), and a User-Agent is a
|
|
40
|
+
claim rather than proof.
|
|
41
|
+
|
|
42
|
+
## ⚠️ Look at your routes before you go live
|
|
43
|
+
|
|
44
|
+
The path is sent as it arrives. The query string is dropped before anything parses it and the
|
|
45
|
+
`Referer` is reduced to an origin — but plenty of sites put secrets in the **path**:
|
|
46
|
+
`/reveal/<token>`, `/join/<code>`, `/confirm/<ticket>`.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
app.use(agenthoney({
|
|
50
|
+
routeTemplate: (path) => path
|
|
51
|
+
.replace(/\/\d+(?=\/|$)/g, "/:id")
|
|
52
|
+
.replace(/^\/(reveal|join|confirm)\/[^/]+/, "/$1/:token"),
|
|
53
|
+
redactPatterns: [/^tok_[A-Za-z0-9]{16,}$/],
|
|
54
|
+
isInternal: (req) => req.path.startsWith("/_health"),
|
|
55
|
+
}));
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
A default backstop redacts segments that look like credentials, and records that it did. It
|
|
59
|
+
cannot catch a short token and it does not know which of your ids are sensitive. Only your routes
|
|
60
|
+
do. `redactHighEntropyPaths: false` turns the backstop off; your own `redactPatterns` always
|
|
61
|
+
apply. Never redact by length alone: `/^[A-Za-z0-9_-]{20,}$/` matches every readable slug, and
|
|
62
|
+
those are the pages agents read.
|
|
63
|
+
|
|
64
|
+
## ⚠️ The key is a server credential
|
|
65
|
+
|
|
66
|
+
`AGENTHONEY_SERVER_KEY` writes events for **one site** — the site it was minted for, which the
|
|
67
|
+
server resolves from the credential itself. It must never reach a browser.
|
|
68
|
+
Every export declares `"browser": null`, and the package **refuses to start** if it finds the key
|
|
69
|
+
under `NEXT_PUBLIC_`, `VITE_`, `PUBLIC_` or `REACT_APP_` — those prefixes inline a value into
|
|
70
|
+
client JavaScript, which publishes the key to everyone who loads the page.
|
|
71
|
+
|
|
72
|
+
## Zero runtime dependencies
|
|
73
|
+
|
|
74
|
+
Deliberately, and enforced: a build gate fails if `dependencies` is non-empty or a bare import
|
|
75
|
+
survives into `dist/`. It holds a credential and runs inside other people's request paths; its
|
|
76
|
+
supply chain is its own.
|
|
77
|
+
|
|
78
|
+
## Documentation
|
|
79
|
+
|
|
80
|
+
- Install guide, for agents: <https://agenthoney.ai/install.md>
|
|
81
|
+
- What is collected, generated from the wire schema and kept honest by a test:
|
|
82
|
+
[`collected-fields.md`](https://github.com/Fifth-Mind/agenthoney/blob/main/docs/design/collected-fields.md)
|
|
83
|
+
|
|
84
|
+
## Licence
|
|
85
|
+
|
|
86
|
+
MIT. See [`LICENSE`](./LICENSE).
|