@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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type Collector } from "./core/collector.js";
|
|
2
|
+
import { type AgentHoneyConfig } from "./core/config.js";
|
|
3
|
+
import { type TagOptions } from "./serve/tag.js";
|
|
4
|
+
import { type TwinOptions } from "./serve/twin.js";
|
|
5
|
+
/**
|
|
6
|
+
* Express middleware.
|
|
7
|
+
*
|
|
8
|
+
* app.use(agenthoney());
|
|
9
|
+
*
|
|
10
|
+
* ── How it observes a completed response without touching it ─────────────────
|
|
11
|
+
* By listening, not by wrapping. `res` is a writable stream and the tempting
|
|
12
|
+
* approach -- monkey-patching `res.write` and `res.end` to inspect what goes
|
|
13
|
+
* out -- is wrong three ways: it adds a function call to every chunk, it holds
|
|
14
|
+
* the bytes in memory, and any mistake in re-emitting them corrupts the
|
|
15
|
+
* customer's response. Everything we need is already in the headers by the time
|
|
16
|
+
* the response finishes.
|
|
17
|
+
*
|
|
18
|
+
* ⚠️ **`finish` and `close`, with a latch.** `finish` fires when the response
|
|
19
|
+
* completed. `close` fires when the socket went away, which for an aborted
|
|
20
|
+
* request is the ONLY event that fires -- and an aborted request is exactly the
|
|
21
|
+
* kind an AI client makes when it has read enough. Listening to `finish` alone
|
|
22
|
+
* silently loses them. Both are registered and a latch makes sure one event is
|
|
23
|
+
* recorded, not two.
|
|
24
|
+
*/
|
|
25
|
+
type Req = {
|
|
26
|
+
method?: string;
|
|
27
|
+
originalUrl?: string;
|
|
28
|
+
url?: string;
|
|
29
|
+
headers: Record<string, string | string[] | undefined>;
|
|
30
|
+
protocol?: string;
|
|
31
|
+
secure?: boolean;
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
};
|
|
34
|
+
type Res = {
|
|
35
|
+
statusCode: number;
|
|
36
|
+
writableFinished?: boolean;
|
|
37
|
+
getHeader(name: string): number | string | string[] | undefined;
|
|
38
|
+
once(event: string, listener: () => void): unknown;
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
};
|
|
41
|
+
type Next = (error?: unknown) => void;
|
|
42
|
+
export interface ExpressOptions extends AgentHoneyConfig {
|
|
43
|
+
collector?: Collector;
|
|
44
|
+
/**
|
|
45
|
+
* Serve a markdown twin. Omit it and this middleware is observation-only,
|
|
46
|
+
* byte-for-byte as before -- the serve half is opt-in, because it is the half
|
|
47
|
+
* that can change what a visitor receives.
|
|
48
|
+
*/
|
|
49
|
+
twin?: TwinOptions;
|
|
50
|
+
/**
|
|
51
|
+
* Serve the page tag at `/_agenthoney/t.js`.
|
|
52
|
+
*
|
|
53
|
+
* ⚠️ Opt-in, exactly as `twin` is, and for a stronger version of the same
|
|
54
|
+
* reason: this one puts code in a visitor's browser. Omit it and the
|
|
55
|
+
* middleware serves nothing at that path -- not an empty file, not a 204. A
|
|
56
|
+
* 404 is the honest answer when a customer has not asked for the tag.
|
|
57
|
+
*
|
|
58
|
+
* ⚠️ Independent of `twin`. A customer may want the tag without serving
|
|
59
|
+
* twins yet -- indeed that is the normal order, since the tag is what will
|
|
60
|
+
* produce the twins.
|
|
61
|
+
*/
|
|
62
|
+
tag?: TagOptions;
|
|
63
|
+
}
|
|
64
|
+
export declare function agenthoney(options?: ExpressOptions): (req: Req, res: Res, next: Next) => void;
|
|
65
|
+
export {};
|
package/dist/express.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"express.js"}
|