Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ jobs:
node-version: 22
- run: npm install
- run: npm run build
- run: npm run test -w @autter/runtime-core
- run: npm run test -w @autter/runtime-node
- run: npm run test -w @autter/runtime-edge
- run: npm run test -w @autter/runtime-next
- run: npm run test -w @autter/runtime-browser
- run: npm run test -w @autter/otlp-ingester
- run: npm run size -w @autter/runtime-browser
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ jobs:
- run: npm run size -w @autter/runtime-browser
- name: Publish packages (skips versions that already exist)
run: |
for pkg in runtime-browser runtime-node runtime-next otlp-ingester; do
# runtime-core is private (bundled into node + edge) and never published.
# Dependencies first: runtime-next depends on node, edge and browser.
for pkg in runtime-browser runtime-node runtime-edge runtime-next otlp-ingester; do
name=$(node -p "require('./packages/$pkg/package.json').name")
version=$(node -p "require('./packages/$pkg/package.json').version")
if npm view "$name@$version" version >/dev/null 2>&1; then
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ examples/express-app/public/sdk/
.env.*
!.env.example
.DS_Store

# Local runtime files written by fileSink in development
.autter/
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Changelog

Check notice on line 1 in CHANGELOG.md

View check run for this annotation

Autter.dev / autter/review-gate

🟑 Low · Unattested changes

45 changed line(s) in this file carry no authorship attestation β€” provenance is unknown (author was not using the tracked CLI). Suggested fix: These changes in CHANGELOG.md have no recorded authorship. Review them as you would any unverified change; if they should be tracked, re-author them through the autter CLI.

## [1.5.0] - 2026-10-08

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 [deterministic] Possible PII in source: PHONE_NUMBER β€” Risk: 72/100

Possible PHONE_NUMBER on this line. Committing real personal data (or leaking it in code/config/logs) is a privacy risk.

πŸ›  AI fix prompt (copy & paste into your coding agent)
Remove the PHONE_NUMBER value at CHANGELOG.md:3. If it's test data, use an obviously-fake placeholder; if it's real, purge it and rotate anything exposed.

Flagged by Autter security & observability checks.


Packages: `otlp-ingester` 1.5.0, `runtime-node` 1.5.0, `runtime-next` 1.5.0, `runtime-browser` 1.4.0, new `runtime-edge` 1.0.0. Additive: 1.4.0 code keeps working unchanged (golden-tested).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟑 [deterministic] markdownlint: MD013 β€” Risk: 30/100

Line length: Expected: 80; Actual: 189

πŸ›  AI fix prompt (copy & paste into your coding agent)
Fix the markdownlint `MD013` issue at CHANGELOG.md:5: Line length: Expected: 80; Actual: 189

Flagged by Autter security & observability checks.


### Features

- Request summaries: `autterRequests` (Express/Connect), `autterFastify` and `withRuntimeRequest` emit one summary per request with route, status, duration, outcome and a request id. `x-request-id` is honoured or generated, echoed (CORS-exposed) and stamped on spans and records. Summaries are always kept; `ignore` globs skip health/metrics routes (`runtime-node`, `runtime-next`).
- `runtimeContext` (`set`, `outcome`, `debug/info/warn/error`, `id`, `requestId`, `fork`, `carrier`) and `runInBackground`. Debug/info messages inside an operation fold into its summary (`autter.operation.logs`, max 50) and summaries carry `kind` and `autter.operation.level` (`runtime-node`).
- Coded errors: `RuntimeError`, `defineRuntimeErrors`, `isRuntimeErrorLike`, `toClientError` and `autterErrorResponse`. `captureException` reads `code/why/fix/link/status/expected` from any error, records cause chains, keeps `internal` on the span only, and treats `expected` failures as `degraded` (`runtime-node`).
- Code-based grouping: errors with a valid `autter.error.code` get the source-independent `code-v1` fingerprint; uncoded errors keep `message-v1` byte-for-byte (`otlp-ingester`).
- Cross-process carriers (`withRuntimeOperation(name, fn, attrs, { from, waitUntil })`) with OTel span links, and per-operation AI usage rollup (`autter.operation.ai`) (`runtime-node`).
- `initAutterLogging` runs requests, operations and coded errors without starting NodeSDK, for apps that already run their own OpenTelemetry SDK. Its error records (`autter.capture.mode=log`) are promoted to occurrences by `/v1/logs`, deduplicated by trace id (`runtime-node`, `otlp-ingester`).
- Enrichers (`enrichUserAgent`, `enrichRequestSize`, `enrichEdgeGeo`, `enrichDeployment`), sinks (`otlpSink`, `consoleSink`, `fileSink` writing `.autter/runtime/*.jsonl` in development) and the `@autter/runtime-node/testing` subpath (`runtime-node`).
- New `@autter/runtime-edge` 1.0.0: `withAutter` for Cloudflare Workers, Vercel Edge, Deno and Bun with zero dependencies; also exposed as `@autter/runtime-next/edge`.
- `runtime_logs` gains `kind`, `request_id`, `route`, `status_code`, `error_code`, `ai_cost_usd`, `ai_calls` (migration 0012) and feeds the `runtime_request_1m` rollup (migration 0014). `runtime_error_occurrences` gains `error_code`, `error_why`, `error_fix`, `error_link`, `expected`, `request_id`, `fingerprint_scheme` (migration 0013) (`otlp-ingester`).
- Sink payload (still `version: 1`) adds optional `errorCode`, `why`, `fix`, `link`, `expected`, `requestId`, `traceId`, `route`, `method`, `statusCode` and `fingerprintScheme`; absent values are omitted (`otlp-ingester`).
- New `LOG_TTL_DAYS` (default 14) applied idempotently to `runtime_logs` at boot (`otlp-ingester`).
- Browser: `captureException` and the global handlers send `code/why/fix/link/expected/requestId`; new `autterErrorFromResponse(response)`; failed fetch/XHR 5xx responses carry `x-request-id` (`runtime-browser`).
- Experimental zero-code `logging.requests` hook mode, off by default (`runtime-node`).

### Changes

- Console output is a pretty tree outside production; production keeps JSON lines (`runtime-node`).
- Debug/info logged inside an operation are folded into its summary instead of separate records; `logging.inline: false` restores 1.4.0 behaviour (`runtime-node`).
- `cache_read_tokens`, `cache_creation_tokens`, `cache_read_input_tokens`, `cache_creation_input_tokens`, `cached_tokens` and `reasoning_tokens` counts are no longer masked as tokens by redaction (`runtime-node`, `otlp-ingester`).

### Fixes

- Value redaction is linear on adversarial strings. The email, URL-credential, JWT, Slack and Autter-key patterns could take seconds to minutes on long runs such as `"a".repeat(65536)`; they now only start a match at the beginning of a run, query-string stripping is procedural, and strings are capped before scrubbing (`runtime-core`, `runtime-node`, `runtime-edge`, `otlp-ingester`, `runtime-browser`). The patterns predate 1.5.0; 1.5.0 routes more input through them.
- `@autter/runtime-edge` keeps the request summary when its queue is full (a summary evicts the oldest plain record), caps warn/error records at 50 per request, and no longer throws from `rt.error` / `rt.captureException` when attributes have throwing getters or are Proxies.
- `@autter/runtime-edge` queues records with the destination (key, endpoint, service, environment) they were created for, and no longer queues records when no key is configured, so a later request can't export them under its own key.
- `/v1/logs` promotion dedupe lookups are bounded: windows of at most 10 minutes, at most 4 per request, newest records first, only for timestamps within the last 24 hours, and a per-tenant budget (`PROMOTION_LOOKUPS_PER_MINUTE`, default 30) (`otlp-ingester`).
- A throwing getter or Proxy on an error's metadata no longer stops `captureException` from reporting the error (`runtime-browser`).
- The sink keeps a numeric `statusCode` of `0` (`otlp-ingester`).
- An invalid `autter.error.code` or request id on an exception event no longer hides a valid one on its span (`otlp-ingester`).
- `proxy-addr` 2.0.8 in the lockfile (CVE-2026-90711; reached through Express in the ingester and examples).
- Package test scripts build the workspace packages they import first, so each suite runs on a clean checkout.
- `runtime-browser` no longer declares a `./dist/index.cjs` entry that the ESM-only build never produced.
- `runtime-next` builds no longer race on `dist/` cleanup and drop `client.d.ts` / `edge.d.ts`.

### Upgrade

- Deploy otlp-ingester 1.5.0 first (migrations 0012–0014 run at boot), then SDKs. Older ingesters accept 1.5.0 SDK traffic but ignore the new fields.
- The `runtime_request_1m` rollup counts every insert, so it is approximate when exporters retry a batch.

## [1.3.1] - 2026-09-08

### Fixes
Expand Down
59 changes: 49 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Autter Runtime

Check notice on line 1 in README.md

View check run for this annotation

Autter.dev / autter/review-gate

🟑 Low · Unattested changes

49 changed line(s) in this file carry no authorship attestation β€” provenance is unknown (author was not using the tracked CLI). Suggested fix: These changes in README.md have no recorded authorship. Review them as you would any unverified change; if they should be tracked, re-author them through the autter CLI.

Open-source, lightweight runtime telemetry for web apps β€” tiny error tracking
in the browser, standard OpenTelemetry on the server, one normalised signal
Expand All @@ -13,10 +13,11 @@
flowchart TD
A["@autter/runtime-browser (tiny tracker)"] --> B["Same-origin relay (@autter/runtime-node)"]
B --> D["otlp-ingester /v1/browser (JSON)"]
C["Server OpenTelemetry"] --> E["otlp-ingester /v1/traces + /v1/metrics (OTLP)"]
C["Server OpenTelemetry + request summaries"] --> E["otlp-ingester /v1/traces + /v1/metrics + /v1/logs (OTLP)"]
I["@autter/runtime-edge (Workers, Vercel Edge, Deno, Bun)"] --> E
D --> F["Normaliser + fingerprinter"]
E --> F
F --> G["ClickHouse (occurrences, spans, usage rollups)"]
F --> G["ClickHouse (occurrences, spans, logs, usage rollups)"]
F --> H["Optional sink webhook β†’ issue grouping"]
```

Expand All @@ -30,8 +31,17 @@
npm install @autter/runtime-browser # frontend (React, Vue, any SPA, static sites)
npm install @autter/runtime-node # backend (Express, Fastify, Koa, Nest, plain Node)
npm install @autter/runtime-next # Next.js (both halves in one package)
npm install @autter/runtime-edge # Cloudflare Workers, Vercel Edge, Deno, Bun (zero deps)
```

| Package | Version | Use it for |
| --- | --- | --- |
| `@autter/runtime-browser` | 1.4.0 | Browser errors + usage, coded-error duck typing, request-id capture |
| `@autter/runtime-node` | 1.5.0 | Node servers: OTel tracing, request summaries, coded errors, operations |
| `@autter/runtime-next` | 1.5.0 | Next.js: server + client + `/edge` for `middleware.ts` |
| `@autter/runtime-edge` | 1.0.0 | Fetch-only runtimes: request summaries and coded errors over `/v1/logs` |
| `@autter/otlp-ingester` | 1.5.0 | Self-hosted ingest β€” upgrade it **before** the SDKs |

Prefer to have an AI agent set it up for you? Install the companion agent
skills β€” they inventory your repo and wire up Autter Runtime for whatever
language/framework each service uses, npm packages or not:
Expand Down Expand Up @@ -78,6 +88,26 @@
});
```

**Requests and coded errors** (1.5.0) β€” one summary per request, always
kept, with a request id echoed to the client; one issue per error code:

```js
const { autterRequests, autterErrorResponse, defineRuntimeErrors, runtimeContext } =
require("@autter/runtime-node");

const billing = defineRuntimeErrors("billing", {
declined: { status: 402, message: "Payment declined", expected: true, fix: "Try another card" },
});
app.use(autterRequests({ ignore: ["/healthz"] }));
app.post("/checkout", (req, res, next) => {
runtimeContext.set({ cart: { items: 3 } });
next(billing.declined()); // β†’ 402 { error: { message, code, fix, requestId } }
});
app.use(autterErrorResponse());
```

See [Requests, coded errors and background work](docs/REQUESTS-AND-ERRORS.md).

**LLM calls** β€” initialised with the server tracker, recorded at 100%
(model, tokens, latency, USD cost). One line per client:

Expand All @@ -100,14 +130,19 @@

| Package | Status | Description |
| --- | --- | --- |
| [`@autter/runtime-browser`](packages/runtime-browser) | **v1.0** | Zero-dependency browser error + usage tracker (~1 KB brotlied) |
| [`@autter/runtime-node`](packages/runtime-node) | **v1.0** | Same-origin relay handler + curated OTel server tracker |
| [`@autter/runtime-next`](packages/runtime-next) | **v1.0** | One-command Next.js integration (relay route + error boundary) |
| [`@autter/otlp-ingester`](packages/otlp-ingester) | **v1.0** | Self-hostable ingest service: OTLP/HTTP (protobuf + JSON) traces + metrics, browser payloads β†’ ClickHouse |
| [`@autter/runtime-browser`](packages/runtime-browser) | **v1.4** | Zero-dependency browser error + usage tracker (<5 KB gzipped) |
| [`@autter/runtime-node`](packages/runtime-node) | **v1.5** | Curated OTel server tracker, request summaries, coded errors, operation logging, same-origin relay |
| [`@autter/runtime-next`](packages/runtime-next) | **v1.5** | One-command Next.js integration (server, client, relay route, error boundary, edge middleware) |
| [`@autter/runtime-edge`](packages/runtime-edge) | **v1.0** | Zero-dependency edge SDK: request summaries and coded errors for Workers, Vercel Edge, Deno, Bun |
| [`@autter/otlp-ingester`](packages/otlp-ingester) | **v1.5** | Self-hostable ingest service: OTLP/HTTP (protobuf + JSON) traces, metrics, logs, browser payloads β†’ ClickHouse |

`packages/runtime-core` is private: shared code bundled into runtime-node and
runtime-edge at build time, never published.

Runnable demo: [`examples/express-app`](examples/express-app) β€” browser
tracker β†’ relay β†’ ingester and OTel server tracker, against a compose-run
ClickHouse.
tracker β†’ relay β†’ ingester, OTel server tracker, request summaries and coded
errors, against a compose-run ClickHouse. Edge:
[`examples/edge-worker`](examples/edge-worker) (Cloudflare Worker).

## Supported stacks

Expand All @@ -119,6 +154,7 @@
| React/SPA with a backend | `@autter/runtime-browser` β†’ relay | none in browser; server key in relay |
| Next.js | `@autter/runtime-next` | server key |
| Node (Express, Fastify, Koa, Nest) | `@autter/runtime-node` | server key |
| Cloudflare Workers, Vercel Edge, Deno, Bun | `@autter/runtime-edge` | server key (secret binding) |
| Go, Rust, Python, Java, .NET, … | any OTel SDK β†’ OTLP/HTTP (protobuf **or** JSON) | server key |

Per-stack setup snippets: [`docs/INTEGRATIONS.md`](docs/INTEGRATIONS.md).
Expand All @@ -130,7 +166,7 @@
| | Server key (`autter_rt_…`) | Client key (`autter_rtc_…`) |
| --- | --- | --- |
| Secrecy | **secret** β€” backend env vars only | **publishable** β€” safe in frontend bundles |
| Can send | OTLP traces/metrics + browser events | browser events only |
| Can send | OTLP traces/metrics/logs + browser events | browser events only |
| Protection | rate limits | origin allow-list + tighter rate limits, write-only |

When your app has a backend, prefer the **relay**: the browser posts to your
Expand All @@ -144,6 +180,7 @@
- [Using Autter Runtime **without npm**](docs/WITHOUT-NPM.md) β€” any OTel SDK, an OTel Collector, or plain HTTP from any language
- [Architecture & data model](docs/ARCHITECTURE.md)
- [Operation logging and diagnostic context](docs/OPERATION-LOGGING.md)
- [Requests, coded errors and background work](docs/REQUESTS-AND-ERRORS.md)
- [Continuous detection, profiles, and outcomes](docs/CONTINUOUS-DETECTION.md)
- [Roadmap](docs/PLAN.md) Β· [Releasing](docs/RELEASING.md)

Expand Down Expand Up @@ -196,7 +233,9 @@
occurrences are always kept (14-day TTL); traces containing an error are
retained in full (the Node SDK tail-retains them), so every issue keeps the
trace that explains it; healthy traces are expected to be sampled upstream
(0.5–1%); usage is stored as 1-minute rollups (90 days).
(0.5–1%); usage is stored as 1-minute rollups (90 days). Request and
operation summaries are one bounded record per unit of work and are always
kept (`LOG_TTL_DAYS`, default 14).
- **Per-repo analysis.** Every row is keyed by `org_id` + `repository_id`.
- **Privacy by construction.** No cookies, no DOM, no request/response bodies,
no emails, no full URLs with query strings.
Expand Down
Loading
Loading