agentrail-edge 0.5.0 → 0.6.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/README.md CHANGED
@@ -22,6 +22,13 @@ A request from a CLI that uses
22
22
  which command an agent ran, in which run and session. The edge records it
23
23
  on the request's step, with the session as a keyed hash in place of the
24
24
  visit cookie a CLI never sends back, and passes the header on to your origin.
25
+ Its `mid`, the CLI's machine id, goes on the step too, for Actor Trust.
26
+
27
+ A request carrying an Agentrail Self-Test token (the `x-agentrail-self-test`
28
+ header, or the `agentrail_self_test` or `agentrail_test` query parameter)
29
+ is recorded as the test run's. The request reaches your origin as it came,
30
+ the token, the page's `agentrail_at` actor-token cookie and the CLI header
31
+ with it, for your server's Actor Trust checkpoint to read.
25
32
 
26
33
  ## Install
27
34
 
package/dist/edge.d.ts CHANGED
@@ -6,9 +6,12 @@ import { type MarkedHosts } from './links.js';
6
6
  * `x-invocation-id` Vercel adds on the way to a function, `x-forwarded-*`;
7
7
  * the `render-proxy-ttl`, `rndr-id` and `x-request-start` Render's proxy adds
8
8
  * on the way to a service, which all 37 MCP steps recorded behind this edge
9
- * on Render carried, 2026-11-19), the `x-agentrail-trace-handoff` an
10
- * Agentrail edge adds to the request it forwards (`requestForOrigin`), and
11
- * Agentrail's own first-party mark. The contract's
9
+ * on Render carried, 2026-11-19; the `x-amz-cf-*` and `cloudfront-*` names
10
+ * CloudFront adds, Fastly's `fastly-*` and Akamai's `akamai-*` and
11
+ * `x-akamai-*`, which no client's HTTP library writes), the
12
+ * `x-agentrail-trace-handoff` an Agentrail edge adds to the request it
13
+ * forwards (`requestForOrigin`), and Agentrail's own first-party mark. The
14
+ * contract's
12
15
  * (`otlp.headerNames.addedOnTheWay`); the tests hold this copy to it.
13
16
  */
14
17
  export declare const ADDED_ON_THE_WAY: RegExp;
package/dist/edge.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CLI_HEADER, createCollector, readCliHeader, TRACE_HANDOFF_HEADER, signTraceHandoff, traceHandoffTarget, createSignatureVerifier, formatTraceparent, hashKeyIdOf, keyedHash, newSessionId, newSpanId, newTraceId, parseMarker, parseTraceparent, sessionCookie, VERSION, } from 'agentrail-core';
1
+ import { CLI_HEADER, createCollector, readCliHeader, SELF_TEST_HEADER, selfTestTokenOf, TRACE_HANDOFF_HEADER, signTraceHandoff, traceHandoffTarget, createSignatureVerifier, formatTraceparent, hashKeyIdOf, keyedHash, newSessionId, newSpanId, newTraceId, parseMarker, parseTraceparent, sessionCookie, VERSION, } from 'agentrail-core';
2
2
  import { MARKER_PARAMETER, markLinks } from './links.js';
3
3
  /**
4
4
  * The edge adapter: in front of a customer's site, on the Fetch API, it
@@ -18,7 +18,13 @@ import { MARKER_PARAMETER, markLinks } from './links.js';
18
18
  * classifier of who the caller is: the `Accept`, the caller's header names
19
19
  * and `Accept-Encoding`, and fetch metadata, the
20
20
  * platform's word on the network and its verified bots, and a Web Bot
21
- * Auth signature checked against the keys the agent publishes.
21
+ * Auth signature checked against the keys the agent publishes;
22
+ * - for Actor Trust, an Agentrail Self-Test run's token, from the
23
+ * `x-agentrail-self-test` header or the `agentrail_self_test` (or
24
+ * `agentrail_test`) query parameter, and a CLI's machine id from its
25
+ * `x-agentrail-cli` header. The request reaches the origin unchanged,
26
+ * its `agentrail_at` cookie and CLI header with it, for the server SDK's
27
+ * checkpoint to read.
22
28
  *
23
29
  * The events go to the collector after the answer, through the platform's
24
30
  * `waitUntil`, so recording never slows a request. Requests one edge answers
@@ -49,12 +55,15 @@ const ACCEPT_ENCODING_LENGTH = 128;
49
55
  * `x-invocation-id` Vercel adds on the way to a function, `x-forwarded-*`;
50
56
  * the `render-proxy-ttl`, `rndr-id` and `x-request-start` Render's proxy adds
51
57
  * on the way to a service, which all 37 MCP steps recorded behind this edge
52
- * on Render carried, 2026-11-19), the `x-agentrail-trace-handoff` an
53
- * Agentrail edge adds to the request it forwards (`requestForOrigin`), and
54
- * Agentrail's own first-party mark. The contract's
58
+ * on Render carried, 2026-11-19; the `x-amz-cf-*` and `cloudfront-*` names
59
+ * CloudFront adds, Fastly's `fastly-*` and Akamai's `akamai-*` and
60
+ * `x-akamai-*`, which no client's HTTP library writes), the
61
+ * `x-agentrail-trace-handoff` an Agentrail edge adds to the request it
62
+ * forwards (`requestForOrigin`), and Agentrail's own first-party mark. The
63
+ * contract's
55
64
  * (`otlp.headerNames.addedOnTheWay`); the tests hold this copy to it.
56
65
  */
57
- export const ADDED_ON_THE_WAY = /^(?:x-forwarded-.*|x-amzn-.*|x-vercel-.*|cf-.*|forwarded|via|x-real-ip|cdn-loop|true-client-ip|logs-url|x-invocation-id|render-proxy-ttl|rndr-id|x-request-start|x-agentrail-trace-handoff|agentrail-first-party)$/iu;
66
+ export const ADDED_ON_THE_WAY = /^(?:x-forwarded-.*|x-amzn-.*|x-amz-cf-.*|x-vercel-.*|cf-.*|cloudfront-.*|fastly-.*|akamai-.*|x-akamai-.*|forwarded|via|x-real-ip|cdn-loop|true-client-ip|logs-url|x-invocation-id|render-proxy-ttl|rndr-id|x-request-start|x-agentrail-trace-handoff|agentrail-first-party)$/iu;
58
67
  /** The most header names an event keeps, and the most characters they take joined (`otlp.headerNames`). */
59
68
  export const HEADER_NAMES_KEPT = { count: 40, characters: 512 };
60
69
  /** The longest `Sec-Fetch-*` value the collector takes; the browsers' are one word. */
@@ -314,6 +323,9 @@ export function createEdge(options) {
314
323
  agentVersion: header.agentVersion ?? null,
315
324
  evidence: header.evidence ?? [],
316
325
  sdkVersion: header.sdkVersion,
326
+ ...(header.machineId === undefined
327
+ ? {}
328
+ : { machineId: header.machineId }),
317
329
  },
318
330
  session: `cli:${hash}:${String(Math.floor(start / DAY_MS))}`,
319
331
  };
@@ -328,6 +340,8 @@ export function createEdge(options) {
328
340
  const actingUserId = principal?.actingUserId ?? null;
329
341
  const signature = await verify(request);
330
342
  const cli = await cliOf(request, input.start);
343
+ // A Self-Test run's token, as the request carried it: never an empty one.
344
+ const selfTestToken = selfTestTokenOf(url, request.headers.get(SELF_TEST_HEADER));
331
345
  const { signals } = input;
332
346
  return {
333
347
  schemaVersion: 1,
@@ -408,6 +422,7 @@ export function createEdge(options) {
408
422
  },
409
423
  registration: null,
410
424
  ...(cli === null ? {} : { cli: cli.facts }),
425
+ ...(selfTestToken === undefined ? {} : { selfTestToken }),
411
426
  markers: {
412
427
  served: observed.served === null
413
428
  ? []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentrail-edge",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "The Agentrail edge: in front of a site on Cloudflare Workers, Vercel or any Fetch API runtime, it records each request and marks the links agents follow.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -25,7 +25,7 @@
25
25
  "node": ">=22"
26
26
  },
27
27
  "dependencies": {
28
- "agentrail-core": "0.5.0"
28
+ "agentrail-core": "0.6.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "24.13.3",