next-observer 0.3.21 → 0.3.23

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
@@ -142,12 +142,53 @@ export default [
142
142
  Tools: `get_services`, `get_operation_stats`, `compare_versions`, `get_errors`, `search_traces`, `get_trace`.
143
143
  `next-observer` validates the file and lists the loaded specialists on start.
144
144
 
145
+ ## Scheduled checks
146
+
147
+ Put `observe.checks.ts` (or `.mts`, `.js`, `.mjs`) in the app root to have the observer ask the app on a timer: is it
148
+ up, is it fast enough, does it still refuse what it must refuse. The file is plain data — no imports:
149
+
150
+ ```ts
151
+ export default [
152
+ { name: 'catalog answers fast', url: '/api/products', expect: { status: 200, maxMs: 300 } },
153
+ { name: 'home page shows the shop', url: '/', expect: { bodyIncludes: 'Porto Shop' } },
154
+ { name: 'guests cannot see orders', url: '/api/orders', expect: { status: [401, 403] } },
155
+ { name: 'checkout refuses a bad quantity', url: '/api/checkout', method: 'POST', body: { quantity: 99 }, expect: { status: 400 } },
156
+ ]
157
+ ```
158
+
159
+ | Field | Default | |
160
+ |---|---|---|
161
+ | `name` | — | unique in the file |
162
+ | `url` | — | a path (sent to the app) or a full `http(s)` URL |
163
+ | `method`, `headers`, `body` | `GET` | a `body` that is not a string is sent as JSON |
164
+ | `everySeconds` | `60` | at least 5 |
165
+ | `timeoutMs` | `10000` | no answer within it is a failure |
166
+ | `expect.status` | any 2xx | one status or a list; redirects are not followed — a 302 is an answer |
167
+ | `expect.maxMs` | — | the whole answer, body included |
168
+ | `expect.bodyIncludes` | — | text the body must contain |
169
+
170
+ Paths go to `OBSERVE_APP_URL`; without it, to the host and port `next dev` was given (`-H`, `-p`, `PORT`), else
171
+ `http://localhost:3000`. That is a guess: when the port is busy, `next dev` moves to the next free one — compare the
172
+ address in the observer's banner with the one Next prints, and set `OBSERVE_APP_URL` if they differ.
173
+
174
+ - Every request carries the header `x-observe-check` (the check's name, URL-encoded) and a trace id of its own, so each
175
+ result links to the trace the app recorded for it.
176
+ - These requests are not traffic for the anomaly detector: an expected refusal is not an error, and a quiet app stays quiet.
177
+ - While the app is still starting (it has not answered yet, first minute), a refused connection is not a failure — the
178
+ check is tried again every 5 s.
179
+ - A body is read only when `maxMs` or `bodyIncludes` asks about it, and then its first megabyte; an event stream is
180
+ never read. So the status of a streaming route can be checked.
181
+ - A field that is misspelled, or an expectation that can never hold (a body text on `HEAD`), is an error on start.
182
+
183
+ Results: `GET /api/checks` — the last 50 per check and how many failed in a row.
184
+
145
185
  ## Configuration
146
186
 
147
187
  | Variable | Default | |
148
188
  |---|---|---|
149
189
  | `OBSERVE_AI` | `mock` | `mock` \| `real` |
150
190
  | `OBSERVE_DETECTOR` | on | `off` disables the anomaly detector |
191
+ | `OBSERVE_APP_URL` | `http://localhost:3000` | where the checks from `observe.checks.ts` are sent |
151
192
  | `OBSERVE_MODEL_TIMEOUT_MS` | `90000` | how long one model call may take before it is started again |
152
193
  | `OBSERVE_API_KEY` | — | require `x-api-key` on ingest (`/v1/traces`) |
153
194
  | `OBSERVE_UI_PASSWORD` | — | require a password for the UI, the query API and the chat (browser login, any user name) |
@@ -0,0 +1,91 @@
1
+ import type { Check } from './spec.js';
2
+ export interface CheckResult {
3
+ atMs: number;
4
+ ok: boolean;
5
+ durationMs: number;
6
+ /** Absent when no answer came at all. */
7
+ status?: number;
8
+ /** The trace id sent with the request. */
9
+ traceId: string;
10
+ /** Why it failed, in words; absent when ok. */
11
+ reason?: string;
12
+ }
13
+ export interface CheckStatus {
14
+ name: string;
15
+ method: string;
16
+ /** Where the request really goes. */
17
+ url: string;
18
+ everySeconds: number;
19
+ expect: Check['expect'];
20
+ /** Failed runs in a row up to now; 0 when the last run passed or nothing ran yet. */
21
+ failures: number;
22
+ last?: CheckResult;
23
+ /** Oldest first. */
24
+ history: CheckResult[];
25
+ }
26
+ export interface CheckRunnerOptions {
27
+ checks: Check[];
28
+ /** Where checks with a path go, e.g. http://localhost:3000. */
29
+ baseUrl: string;
30
+ fetch?: typeof fetch;
31
+ /** Wall clock, for `atMs`. */
32
+ now?: () => number;
33
+ /** A clock that never jumps (NTP, sleep), for durations. Default performance.now. */
34
+ elapsed?: () => number;
35
+ /** Results kept per check. Default 50. */
36
+ history?: number;
37
+ /** The first run of every check waits this long (the app may still be starting). Default 3 s. */
38
+ firstDelayMs?: number;
39
+ /**
40
+ * While the app has not answered yet, a refused connection to it within this time of start() is not a result:
41
+ * `next dev` is still starting. After it, "nobody is listening" is exactly what a check is for. Default 60 s.
42
+ */
43
+ startupGraceMs?: number;
44
+ /** A run that met the starting app is tried again this soon, whatever the check's interval. Default 5 s. */
45
+ startupRetryMs?: number;
46
+ onResult?: (check: Check, result: CheckResult, failures: number) => void;
47
+ }
48
+ /** Marks the request as the observer's own (the value is the check's name, URL-encoded: header values are ASCII). */
49
+ export declare const CHECK_HEADER = "x-observe-check";
50
+ /** As much of a body as is read: enough for `bodyIncludes`, and a large download is not buffered every minute. */
51
+ export declare const MAX_BODY_BYTES = 1000000;
52
+ export declare class CheckRunner {
53
+ private readonly options;
54
+ readonly baseUrl: string;
55
+ private readonly checks;
56
+ private readonly fetch;
57
+ private readonly now;
58
+ private readonly elapsed;
59
+ private readonly keep;
60
+ private readonly firstDelayMs;
61
+ private readonly startupGraceMs;
62
+ private readonly startupRetryMs;
63
+ private readonly results;
64
+ /** Failed runs in a row per check — counted, not derived from the kept history, which is cut at `keep`. */
65
+ private readonly streak;
66
+ private readonly traces;
67
+ private running;
68
+ private inFlight;
69
+ private timers;
70
+ /** Changes on every start()/stop(): a run from an earlier one must not report into this one. */
71
+ private generation;
72
+ /** On the `elapsed` clock: a wall clock stepping back would keep the grace time open for ever. */
73
+ private startedAt;
74
+ /** The app itself (a check with a path) has answered since start(). */
75
+ private appAnswered;
76
+ constructor(options: CheckRunnerOptions);
77
+ /** Was this trace started by one of our own requests? Their spans are not real traffic. */
78
+ isCheckTrace(traceId: string): boolean;
79
+ urlOf(check: Check): string;
80
+ /**
81
+ * One request, judged. Never throws: a failed request is a result. Resolves with `undefined` when there is nothing
82
+ * to report — the runner was stopped meanwhile, or the app has not started listening yet (see startupGraceMs).
83
+ */
84
+ run(check: Check): Promise<CheckResult | undefined>;
85
+ private attempt;
86
+ /** Starts the timers. A check whose previous run is still waiting for its answer is skipped, not stacked. */
87
+ start(): void;
88
+ /** Stops the timers and drops the requests on their way: nothing is recorded or reported after this. */
89
+ stop(): void;
90
+ list(): CheckStatus[];
91
+ }
@@ -0,0 +1,239 @@
1
+ // Runs the checks from observe.checks.ts on their timers and keeps the latest results. Each request carries a trace
2
+ // id of its own (traceparent), so a result links to the trace the app recorded for exactly that request.
3
+ import { randomBytes } from 'node:crypto';
4
+ /** Marks the request as the observer's own (the value is the check's name, URL-encoded: header values are ASCII). */
5
+ export const CHECK_HEADER = 'x-observe-check';
6
+ /** As much of a body as is read: enough for `bodyIncludes`, and a large download is not buffered every minute. */
7
+ export const MAX_BODY_BYTES = 1_000_000;
8
+ /** Trace ids of recent check requests that are remembered, to tell their spans from real traffic. */
9
+ const REMEMBERED_TRACES = 5000;
10
+ const STREAM = /text\/event-stream/i;
11
+ /**
12
+ * The body as text, up to MAX_BODY_BYTES (`cut` says whether more was left). Not read at all when nobody asked about
13
+ * it (`wanted` false) or when it is an event stream, which never ends.
14
+ */
15
+ async function readBody(response, wanted) {
16
+ if (!response.body)
17
+ return { text: '', cut: false, read: true };
18
+ if (!wanted || STREAM.test(response.headers.get('content-type') ?? '')) {
19
+ await response.body.cancel().catch(() => { });
20
+ return { text: '', cut: false, read: false };
21
+ }
22
+ const reader = response.body.getReader();
23
+ const chunks = [];
24
+ let size = 0;
25
+ let cut = false;
26
+ for (;;) {
27
+ const { done, value } = await reader.read();
28
+ if (done)
29
+ break;
30
+ chunks.push(value);
31
+ size += value.byteLength;
32
+ if (size >= MAX_BODY_BYTES) {
33
+ cut = true;
34
+ await reader.cancel().catch(() => { });
35
+ break;
36
+ }
37
+ }
38
+ return { text: Buffer.concat(chunks).subarray(0, MAX_BODY_BYTES).toString('utf8'), cut, read: true };
39
+ }
40
+ /** What run() gives the timer when the app is not listening yet: try again soon. */
41
+ const STARTING = Symbol('starting');
42
+ export class CheckRunner {
43
+ options;
44
+ baseUrl;
45
+ checks;
46
+ fetch;
47
+ now;
48
+ elapsed;
49
+ keep;
50
+ firstDelayMs;
51
+ startupGraceMs;
52
+ startupRetryMs;
53
+ results = new Map();
54
+ /** Failed runs in a row per check — counted, not derived from the kept history, which is cut at `keep`. */
55
+ streak = new Map();
56
+ traces = new Set();
57
+ running = new Set();
58
+ inFlight = new Set();
59
+ timers = [];
60
+ /** Changes on every start()/stop(): a run from an earlier one must not report into this one. */
61
+ generation = 0;
62
+ /** On the `elapsed` clock: a wall clock stepping back would keep the grace time open for ever. */
63
+ startedAt = null;
64
+ /** The app itself (a check with a path) has answered since start(). */
65
+ appAnswered = false;
66
+ constructor(options) {
67
+ this.options = options;
68
+ this.checks = options.checks;
69
+ this.baseUrl = options.baseUrl.replace(/\/+$/, '');
70
+ this.fetch = options.fetch ?? globalThis.fetch;
71
+ this.now = options.now ?? Date.now;
72
+ this.elapsed = options.elapsed ?? (() => performance.now());
73
+ this.keep = Math.max(1, options.history ?? 50);
74
+ this.firstDelayMs = options.firstDelayMs ?? 3000;
75
+ this.startupGraceMs = options.startupGraceMs ?? 60_000;
76
+ this.startupRetryMs = options.startupRetryMs ?? 5000;
77
+ }
78
+ /** Was this trace started by one of our own requests? Their spans are not real traffic. */
79
+ isCheckTrace(traceId) {
80
+ return this.traces.has(traceId);
81
+ }
82
+ urlOf(check) {
83
+ return check.url.startsWith('/') ? `${this.baseUrl}${check.url}` : check.url;
84
+ }
85
+ /**
86
+ * One request, judged. Never throws: a failed request is a result. Resolves with `undefined` when there is nothing
87
+ * to report — the runner was stopped meanwhile, or the app has not started listening yet (see startupGraceMs).
88
+ */
89
+ async run(check) {
90
+ const result = await this.attempt(check);
91
+ return result === STARTING ? undefined : result;
92
+ }
93
+ async attempt(check) {
94
+ const own = check.url.startsWith('/');
95
+ const generation = this.generation;
96
+ const traceId = randomBytes(16).toString('hex');
97
+ this.traces.add(traceId);
98
+ if (this.traces.size > REMEMBERED_TRACES)
99
+ this.traces.delete(this.traces.values().next().value);
100
+ const atMs = this.now();
101
+ const started = this.elapsed();
102
+ const controller = new AbortController();
103
+ this.inFlight.add(controller);
104
+ let timedOut = false;
105
+ const timer = setTimeout(() => {
106
+ timedOut = true;
107
+ controller.abort();
108
+ }, check.timeoutMs);
109
+ let result;
110
+ try {
111
+ const response = await this.fetch(this.urlOf(check), {
112
+ method: check.method,
113
+ // Ours last: a check cannot switch off its own trace link or mark.
114
+ headers: { ...check.headers, traceparent: `00-${traceId}-${randomBytes(8).toString('hex')}-01`, [CHECK_HEADER]: encodeURIComponent(check.name) },
115
+ body: check.body,
116
+ // A redirect is an answer ("anonymous visitors are sent to /login"), not something to follow.
117
+ redirect: 'manual',
118
+ signal: controller.signal,
119
+ });
120
+ if (own)
121
+ this.appAnswered = true;
122
+ const e = check.expect;
123
+ // The status is known from here on: a body that never finishes must not turn it into "no answer".
124
+ let body;
125
+ try {
126
+ body = await readBody(response, e.bodyIncludes !== undefined || e.maxMs !== undefined);
127
+ }
128
+ catch (error) {
129
+ if (!timedOut)
130
+ throw error;
131
+ }
132
+ const durationMs = this.elapsed() - started;
133
+ const reasons = [];
134
+ if (e.status ? !e.status.includes(response.status) : response.status < 200 || response.status > 299) {
135
+ reasons.push(`expected status ${e.status ? e.status.join(' or ') : '2xx'}, got ${response.status}`);
136
+ }
137
+ if (e.maxMs !== undefined && durationMs > e.maxMs)
138
+ reasons.push(`took ${Math.round(durationMs)} ms, limit ${e.maxMs} ms`);
139
+ if (!body)
140
+ reasons.push(`the body did not finish within ${check.timeoutMs} ms`);
141
+ else if (e.bodyIncludes !== undefined && !body.text.includes(e.bodyIncludes)) {
142
+ const where = !body.read ? ' (an event stream is not read)' : body.cut ? ' in its first megabyte (the rest is not read)' : '';
143
+ reasons.push(`body does not contain ${JSON.stringify(e.bodyIncludes)}${where}`);
144
+ }
145
+ result = { atMs, ok: reasons.length === 0, durationMs, status: response.status, traceId, ...(reasons.length ? { reason: reasons.join('; ') } : {}) };
146
+ }
147
+ catch (error) {
148
+ const durationMs = this.elapsed() - started;
149
+ const cause = error?.cause;
150
+ // Only the app's own checks, only "nobody is listening": a wrong host name or a certificate error is news at once.
151
+ const starting = own && cause?.code === 'ECONNREFUSED' && !this.appAnswered && this.startedAt !== null && started - this.startedAt < this.startupGraceMs;
152
+ if (starting)
153
+ return generation === this.generation ? STARTING : undefined;
154
+ const reason = timedOut ? `no answer within ${check.timeoutMs} ms` : `request failed: ${cause?.code ?? cause?.message ?? error?.message ?? String(error)}`;
155
+ result = { atMs, ok: false, durationMs, traceId, reason };
156
+ }
157
+ finally {
158
+ clearTimeout(timer);
159
+ this.inFlight.delete(controller);
160
+ }
161
+ if (generation !== this.generation)
162
+ return undefined;
163
+ const list = this.results.get(check.name) ?? [];
164
+ list.push(result);
165
+ if (list.length > this.keep)
166
+ list.splice(0, list.length - this.keep);
167
+ this.results.set(check.name, list);
168
+ const failures = result.ok ? 0 : (this.streak.get(check.name) ?? 0) + 1;
169
+ this.streak.set(check.name, failures);
170
+ try {
171
+ this.options.onResult?.(check, result, failures);
172
+ }
173
+ catch {
174
+ // A listener's problem must not stop the checks.
175
+ }
176
+ return result;
177
+ }
178
+ /** Starts the timers. A check whose previous run is still waiting for its answer is skipped, not stacked. */
179
+ start() {
180
+ this.stop();
181
+ this.startedAt = this.elapsed();
182
+ this.appAnswered = false;
183
+ const generation = this.generation;
184
+ // This start's own set: a run left over from an earlier start must not hold back the first tick of this one.
185
+ const running = this.running;
186
+ for (const check of this.checks) {
187
+ let retryPending = false;
188
+ const tick = () => {
189
+ if (running.has(check.name))
190
+ return;
191
+ running.add(check.name);
192
+ void this.attempt(check)
193
+ .then((result) => {
194
+ // The app is not up yet: do not make a check with a long interval wait a whole interval for its first
195
+ // result. One retry at a time — the interval's own ticks must not each start a chain of them.
196
+ if (result !== STARTING || generation !== this.generation || retryPending)
197
+ return;
198
+ retryPending = true;
199
+ const retry = setTimeout(() => {
200
+ retryPending = false;
201
+ tick();
202
+ }, this.startupRetryMs);
203
+ retry.unref?.();
204
+ this.timers.push(retry);
205
+ })
206
+ .finally(() => running.delete(check.name));
207
+ };
208
+ const first = setTimeout(() => {
209
+ tick();
210
+ const every = setInterval(tick, check.everyMs);
211
+ every.unref?.();
212
+ this.timers.push(every);
213
+ }, Math.min(this.firstDelayMs, check.everyMs));
214
+ first.unref?.();
215
+ this.timers.push(first);
216
+ }
217
+ }
218
+ /** Stops the timers and drops the requests on their way: nothing is recorded or reported after this. */
219
+ stop() {
220
+ this.generation++;
221
+ // clearTimeout also clears an interval.
222
+ for (const timer of this.timers)
223
+ clearTimeout(timer);
224
+ this.timers = [];
225
+ for (const controller of this.inFlight)
226
+ controller.abort();
227
+ this.inFlight = new Set();
228
+ this.running = new Set();
229
+ this.startedAt = null;
230
+ }
231
+ list() {
232
+ return this.checks.map((check) => {
233
+ const history = this.results.get(check.name) ?? [];
234
+ const last = history.at(-1);
235
+ return { name: check.name, method: check.method, url: this.urlOf(check), everySeconds: check.everyMs / 1000, expect: check.expect, failures: this.streak.get(check.name) ?? 0, ...(last ? { last } : {}), history: [...history] };
236
+ });
237
+ }
238
+ }
239
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/checks/runner.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,yGAAyG;AACzG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAoDzC,qHAAqH;AACrH,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,CAAA;AAC7C,kHAAkH;AAClH,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAA;AACvC,qGAAqG;AACrG,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAE9B,MAAM,MAAM,GAAG,qBAAqB,CAAA;AA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GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,CAAA;QACnO,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,47 @@
1
+ export interface CheckExpect {
2
+ /** The status (or any of several) that counts as good. Default: any 2xx. */
3
+ status?: number | number[];
4
+ /** The answer, body included (its first megabyte), must arrive within this many ms. */
5
+ maxMs?: number;
6
+ /** Text the body must contain. */
7
+ bodyIncludes?: string;
8
+ }
9
+ export interface CheckSpec {
10
+ /** Shown in the UI and in anomalies; unique in the file. */
11
+ name: string;
12
+ /** A path ("/api/products") — sent to the app — or a full http(s) URL. */
13
+ url: string;
14
+ /** Default GET. */
15
+ method?: string;
16
+ headers?: Record<string, string>;
17
+ /** A string is sent as is; anything else as JSON. */
18
+ body?: unknown;
19
+ /** Default 60, at least 5. */
20
+ everySeconds?: number;
21
+ /** Default 10 000. */
22
+ timeoutMs?: number;
23
+ expect?: CheckExpect;
24
+ }
25
+ /** A validated check with the defaults filled in. */
26
+ export interface Check {
27
+ name: string;
28
+ url: string;
29
+ method: string;
30
+ headers: Record<string, string>;
31
+ body?: string;
32
+ everyMs: number;
33
+ timeoutMs: number;
34
+ expect: {
35
+ status?: number[];
36
+ maxMs?: number;
37
+ bodyIncludes?: string;
38
+ };
39
+ }
40
+ export declare const CHECK_DEFAULTS: {
41
+ everySeconds: number;
42
+ timeoutMs: number;
43
+ };
44
+ /** Throws with a message that names the check and the field. */
45
+ export declare function validateCheck(raw: unknown): Check;
46
+ /** Validates the whole file's export; names must be unique — results are kept by name. */
47
+ export declare function validateChecks(exported: unknown): Check[];
@@ -0,0 +1,117 @@
1
+ // Scheduled checks: the app's observe.checks.ts lists requests the observer sends on a timer and what a good answer
2
+ // looks like — is the app up, is it fast enough, does it still refuse what it must refuse. Plain data, no functions and
3
+ // no imports: the file is read by the observer, never by the app.
4
+ export const CHECK_DEFAULTS = { everySeconds: 60, timeoutMs: 10_000 };
5
+ const METHODS = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'];
6
+ const KEYS = ['name', 'url', 'method', 'headers', 'body', 'everySeconds', 'timeoutMs', 'expect'];
7
+ const EXPECT_KEYS = ['status', 'maxMs', 'bodyIncludes'];
8
+ /** Statuses whose answer never has a body. */
9
+ const NO_BODY = [204, 205, 304];
10
+ const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
11
+ /** A key nobody reads is a silent typo ("expects", "maxMS") — the check would pass forever. */
12
+ function unknownKey(value, known) {
13
+ return Object.keys(value).find((key) => !known.includes(key));
14
+ }
15
+ function numberIn(value, min, max) {
16
+ return typeof value === 'number' && Number.isFinite(value) && value >= min && value <= max;
17
+ }
18
+ /** Throws with a message that names the check and the field. */
19
+ export function validateCheck(raw) {
20
+ if (!isRecord(raw))
21
+ throw new Error('a check must be an object like { name, url, expect }');
22
+ const name = raw.name;
23
+ if (typeof name !== 'string' || name.trim() === '' || name.length > 80)
24
+ throw new Error('a check needs a `name` (1–80 characters)');
25
+ const fail = (message) => {
26
+ throw new Error(`check "${name}": ${message}`);
27
+ };
28
+ const stray = unknownKey(raw, KEYS);
29
+ if (stray)
30
+ fail(`unknown field \`${stray}\` (known: ${KEYS.join(', ')})`);
31
+ const url = raw.url;
32
+ if (typeof url !== 'string' || !(url.startsWith('/') || /^https?:\/\//i.test(url)))
33
+ fail('`url` must be a path starting with "/" or a full http(s) URL');
34
+ if (typeof url === 'string' && !url.startsWith('/') && !URL.canParse(url))
35
+ fail(`\`url\` is not a valid URL: ${url}`);
36
+ const method = raw.method === undefined ? 'GET' : typeof raw.method === 'string' ? raw.method.toUpperCase() : '';
37
+ if (!METHODS.includes(method))
38
+ fail(`\`method\` must be one of ${METHODS.join(', ')}`);
39
+ const headers = {};
40
+ if (raw.headers !== undefined) {
41
+ if (!isRecord(raw.headers))
42
+ fail('`headers` must be an object of strings');
43
+ for (const [key, value] of Object.entries(raw.headers)) {
44
+ if (typeof value !== 'string')
45
+ fail(`header \`${key}\` must be a string`);
46
+ headers[key.toLowerCase()] = value;
47
+ }
48
+ }
49
+ let body;
50
+ if (raw.body !== undefined) {
51
+ if (method === 'GET' || method === 'HEAD')
52
+ fail(`a ${method} request cannot have a \`body\``);
53
+ if (typeof raw.body === 'string')
54
+ body = raw.body;
55
+ else {
56
+ // A function or a symbol gives undefined, a BigInt or a cycle throws — neither is a body anyone meant to send.
57
+ try {
58
+ body = JSON.stringify(raw.body);
59
+ }
60
+ catch {
61
+ body = undefined;
62
+ }
63
+ if (body === undefined)
64
+ fail('`body` cannot be sent as JSON — use plain data or a string');
65
+ headers['content-type'] ??= 'application/json';
66
+ }
67
+ }
68
+ const everySeconds = raw.everySeconds ?? CHECK_DEFAULTS.everySeconds;
69
+ if (!numberIn(everySeconds, 5, 86_400))
70
+ fail('`everySeconds` must be a number from 5 to 86400');
71
+ const timeoutMs = raw.timeoutMs ?? CHECK_DEFAULTS.timeoutMs;
72
+ if (!numberIn(timeoutMs, 100, 120_000))
73
+ fail('`timeoutMs` must be a number from 100 to 120000');
74
+ const expect = {};
75
+ if (raw.expect !== undefined) {
76
+ const e = raw.expect;
77
+ if (!isRecord(e))
78
+ return fail('`expect` must be an object like { status: 200, maxMs: 500 }');
79
+ const strayExpect = unknownKey(e, EXPECT_KEYS);
80
+ if (strayExpect)
81
+ fail(`unknown field \`expect.${strayExpect}\` (known: ${EXPECT_KEYS.join(', ')})`);
82
+ if (e.status !== undefined) {
83
+ const list = Array.isArray(e.status) ? e.status : [e.status];
84
+ if (list.length === 0 || !list.every((s) => Number.isInteger(s) && numberIn(s, 100, 599)))
85
+ fail('`expect.status` must be a status code (100–599) or a list of them');
86
+ expect.status = list;
87
+ }
88
+ if (e.maxMs !== undefined) {
89
+ if (!numberIn(e.maxMs, 1, 120_000))
90
+ fail('`expect.maxMs` must be a number from 1 to 120000');
91
+ expect.maxMs = e.maxMs;
92
+ }
93
+ if (e.bodyIncludes !== undefined) {
94
+ if (typeof e.bodyIncludes !== 'string' || e.bodyIncludes === '')
95
+ fail('`expect.bodyIncludes` must be a non-empty string');
96
+ // An answer without a body can never contain it: the check would fail forever.
97
+ if (method === 'HEAD')
98
+ fail('`expect.bodyIncludes` cannot be used with HEAD — the answer has no body');
99
+ if (expect.status?.every((s) => NO_BODY.includes(s)))
100
+ fail(`\`expect.bodyIncludes\` cannot be used with status ${expect.status.join(' or ')} — the answer has no body`);
101
+ expect.bodyIncludes = e.bodyIncludes;
102
+ }
103
+ }
104
+ return { name, url: url, method, headers, ...(body === undefined ? {} : { body }), everyMs: everySeconds * 1000, timeoutMs: timeoutMs, expect };
105
+ }
106
+ /** Validates the whole file's export; names must be unique — results are kept by name. */
107
+ export function validateChecks(exported) {
108
+ if (!Array.isArray(exported))
109
+ throw new Error('export default an array of checks: [{ name, url, expect }]');
110
+ const checks = exported.map(validateCheck);
111
+ const names = checks.map((c) => c.name);
112
+ const duplicate = names.find((name, i) => names.indexOf(name) !== i);
113
+ if (duplicate)
114
+ throw new Error(`check "${duplicate}" is defined twice`);
115
+ return checks;
116
+ }
117
+ //# sourceMappingURL=spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/checks/spec.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,wHAAwH;AACxH,kEAAkE;AAwClE,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAA;AACrE,MAAM,OAAO,GAAG,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,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IACvC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACpE,IAAI,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,oBAAoB,CAAC,CAAA;IACvE,OAAO,MAAM,CAAA;AACf,CAAC"}
package/dist/cli.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { ChildProcess, SpawnOptions } from 'node:child_process';
2
2
  import { init } from './init.js';
3
3
  type AgentsModule = typeof import('./agents/index.js');
4
- export declare const HELP = "Usage:\n next-observer init [--root <dir>] [--proxy]\n Connect a Next.js app to next-observe: install it, wrap next.config in withObserve(), add instrumentation.ts and\n instrumentation-client.ts, and an \"observe\" script. Safe to run again. --proxy also adds the runtime proxy route.\n\n next-observer dev [--root <dir>] [--port <n>] [-- <next dev args>]\n Start the collector and `next dev` for the app in <dir> (default: current directory).\n Example: next-observer dev --root apps/web -- -p 3100\n\n next-observer collector [--host <host>] [--port <n>] [--api-key <key>] [--ui-password <password>] [--demo]\n Start only the collector (e.g. on a server). Reads OBSERVE_HOST, OBSERVE_PORT, OBSERVE_API_KEY, OBSERVE_UI_PASSWORD.\n --api-key protects ingest (x-api-key); --ui-password protects the UI, API and chat (browser login).\n --demo preloads the workshop \"shop\" scenario (a regression in v2, 30% inventory errors, an N+1, an error new in v2).\n\nEnvironment: OBSERVE_ROOT, OBSERVE_PORT (default 4318), OBSERVE_HOST (default 127.0.0.1), OBSERVE_API_KEY,\n OBSERVE_AI (mock | real), OBSERVE_DETECTOR (off to disable the anomaly detector),\n OBSERVE_MODEL_TIMEOUT_MS (one model call; default 90000, a call that hangs is started again once)";
4
+ export declare const HELP = "Usage:\n next-observer init [--root <dir>] [--proxy]\n Connect a Next.js app to next-observe: install it, wrap next.config in withObserve(), add instrumentation.ts and\n instrumentation-client.ts, and an \"observe\" script. Safe to run again. --proxy also adds the runtime proxy route.\n\n next-observer dev [--root <dir>] [--port <n>] [-- <next dev args>]\n Start the collector and `next dev` for the app in <dir> (default: current directory).\n Example: next-observer dev --root apps/web -- -p 3100\n\n next-observer collector [--host <host>] [--port <n>] [--api-key <key>] [--ui-password <password>] [--demo]\n Start only the collector (e.g. on a server). Reads OBSERVE_HOST, OBSERVE_PORT, OBSERVE_API_KEY, OBSERVE_UI_PASSWORD.\n --api-key protects ingest (x-api-key); --ui-password protects the UI, API and chat (browser login).\n --demo preloads the workshop \"shop\" scenario (a regression in v2, 30% inventory errors, an N+1, an error new in v2).\n\nEnvironment: OBSERVE_ROOT, OBSERVE_PORT (default 4318), OBSERVE_HOST (default 127.0.0.1), OBSERVE_API_KEY,\n OBSERVE_AI (mock | real), OBSERVE_DETECTOR (off to disable the anomaly detector),\n OBSERVE_APP_URL (where the checks from observe.checks.ts are sent; default http://localhost:3000),\n OBSERVE_MODEL_TIMEOUT_MS (one model call; default 90000, a call that hangs is started again once)";
5
5
  export declare class CliError extends Error {
6
6
  }
7
7
  export type Env = Record<string, string | undefined>;
@@ -30,6 +30,13 @@ export interface CliDeps {
30
30
  loadAgents?: () => Promise<AgentsModule>;
31
31
  }
32
32
  export declare const AGENTS_FILES: string[];
33
+ export declare const CHECKS_FILES: string[];
34
+ /**
35
+ * Where checks with a path go: OBSERVE_APP_URL, else the host and port `next dev` was given (-H, -p, PORT), else
36
+ * localhost:3000. A guess: when that port is busy `next dev` moves to the next free one without telling us — the banner
37
+ * names the address so it can be compared with the one Next prints.
38
+ */
39
+ export declare function appUrl(env: Env, nextArgs?: string[]): string;
33
40
  /** What protects the collector — and a warning when it listens beyond this machine with an open UI. */
34
41
  export declare function authLines(args: Pick<CliArgs, 'host' | 'apiKey' | 'uiPassword'>): string[];
35
42
  export declare function run(argv: string[], deps: CliDeps): Promise<number>;
package/dist/cli.js CHANGED
@@ -6,6 +6,8 @@ import { parseArgs } from 'node:util';
6
6
  import { MemoryStorage, startCollector } from './collector/index.js';
7
7
  import { seedDemo, startLiveDemo } from './debug/demo.js';
8
8
  import { detectPackageManager, init, installArgs } from './init.js';
9
+ import { CheckRunner } from './checks/runner.js';
10
+ import { validateChecks } from './checks/spec.js';
9
11
  import { AnomalyDetector } from './debug/detector.js';
10
12
  export const HELP = `Usage:
11
13
  next-observer init [--root <dir>] [--proxy]
@@ -23,6 +25,7 @@ export const HELP = `Usage:
23
25
 
24
26
  Environment: OBSERVE_ROOT, OBSERVE_PORT (default 4318), OBSERVE_HOST (default 127.0.0.1), OBSERVE_API_KEY,
25
27
  OBSERVE_AI (mock | real), OBSERVE_DETECTOR (off to disable the anomaly detector),
28
+ OBSERVE_APP_URL (where the checks from observe.checks.ts are sent; default http://localhost:3000),
26
29
  OBSERVE_MODEL_TIMEOUT_MS (one model call; default 90000, a call that hangs is started again once)`;
27
30
  export class CliError extends Error {
28
31
  }
@@ -82,19 +85,16 @@ function resolveNextBin(root) {
82
85
  }
83
86
  }
84
87
  export const AGENTS_FILES = ['observe.agents.ts', 'observe.agents.mts', 'observe.agents.js', 'observe.agents.mjs'];
85
- /**
86
- * The project's own specialists from observe.agents.* in the app root: `export default [defineSpecialist({…})]`.
87
- * Same name as a built-in replaces it, a new name adds a specialist. Node ≥22.18 runs the .ts file as is (type stripping).
88
- */
89
- async function loadProjectSpecialists(root, agents) {
90
- const found = AGENTS_FILES.filter((name) => existsSync(join(root, name)));
88
+ export const CHECKS_FILES = ['observe.checks.ts', 'observe.checks.mts', 'observe.checks.js', 'observe.checks.mjs'];
89
+ /** The default export of the one file from `names` that exists in the app root; `{}` when there is none. */
90
+ async function importProjectFile(root, names) {
91
+ const found = names.filter((name) => existsSync(join(root, name)));
91
92
  if (found.length === 0)
92
- return { specs: [] };
93
+ return {};
93
94
  if (found.length > 1)
94
95
  throw new CliError(`found ${found.join(' and ')} in ${root} — keep one`);
95
96
  const file = found[0];
96
- let exported;
97
- // Next apps rarely have "type": "module", so Node warns that it reparses observe.agents.ts as ESM — noise, not a problem.
97
+ // Next apps rarely have "type": "module", so Node warns that it reparses the .ts file as ESM — noise, not a problem.
98
98
  const emitWarning = process.emitWarning;
99
99
  process.emitWarning = ((warning, ...rest) => {
100
100
  const code = rest[0]?.code;
@@ -103,17 +103,81 @@ async function loadProjectSpecialists(root, agents) {
103
103
  return emitWarning.call(process, warning, ...rest);
104
104
  });
105
105
  try {
106
- exported = (await import(pathToFileURL(join(root, file)).href)).default;
106
+ return { file, exported: (await import(pathToFileURL(join(root, file)).href)).default };
107
107
  }
108
108
  catch (error) {
109
109
  const e = error;
110
110
  if (e?.code === 'ERR_UNKNOWN_FILE_EXTENSION')
111
- throw new CliError(`${file}: this Node.js cannot load TypeScript — use Node.js ≥22.18 or rename it to observe.agents.mjs`);
111
+ throw new CliError(`${file}: this Node.js cannot load TypeScript — use Node.js ≥22.18 or rename it to ${file.replace(/\.m?ts$/, '.mjs')}`);
112
112
  throw new CliError(`${file}: ${e?.message ?? String(error)}`);
113
113
  }
114
114
  finally {
115
115
  process.emitWarning = emitWarning;
116
116
  }
117
+ }
118
+ /**
119
+ * Where checks with a path go: OBSERVE_APP_URL, else the host and port `next dev` was given (-H, -p, PORT), else
120
+ * localhost:3000. A guess: when that port is busy `next dev` moves to the next free one without telling us — the banner
121
+ * names the address so it can be compared with the one Next prints.
122
+ */
123
+ export function appUrl(env, nextArgs = []) {
124
+ const given = env.OBSERVE_APP_URL;
125
+ if (given) {
126
+ const url = /^https?:\/\//i.test(given) && URL.canParse(given) ? new URL(given) : undefined;
127
+ // Judged on the text too: `http://host?` parses with an empty query and would turn every path into one.
128
+ if (!url || /[?#]/.test(given) || url.username || url.password)
129
+ throw new CliError(`invalid OBSERVE_APP_URL "${given}" — expected something like http://localhost:3000`);
130
+ return `${url.origin}${url.pathname}`.replace(/\/+$/, '');
131
+ }
132
+ let port = env.PORT;
133
+ let host = 'localhost';
134
+ // The value after a flag — unless what follows is the next flag (`-H --turbo`).
135
+ const valueAfter = (i) => (nextArgs[i + 1]?.startsWith('-') === false ? nextArgs[i + 1] : undefined);
136
+ nextArgs.forEach((arg, i) => {
137
+ if (arg === '-p' || arg === '--port')
138
+ port = valueAfter(i) ?? port;
139
+ else if (arg.startsWith('--port='))
140
+ port = arg.slice('--port='.length);
141
+ else if (/^-p\d+$/.test(arg))
142
+ port = arg.slice(2);
143
+ else if (arg === '-H' || arg === '--hostname')
144
+ host = valueAfter(i) ?? host;
145
+ else if (arg.startsWith('--hostname='))
146
+ host = arg.slice('--hostname='.length);
147
+ });
148
+ // "All interfaces" is not an address to call.
149
+ if (host === '0.0.0.0' || host === '::' || !/^[\w.-]+$/.test(host))
150
+ host = 'localhost';
151
+ return `http://${host}:${port && /^\d+$/.test(port) ? port : '3000'}`;
152
+ }
153
+ /** The checks from observe.checks.* in the app root (`export default [{ name, url, expect }]`), ready to run. */
154
+ async function loadChecks(root, env, nextArgs) {
155
+ const { file, exported } = await importProjectFile(root, CHECKS_FILES);
156
+ if (!file)
157
+ return {};
158
+ let checks;
159
+ try {
160
+ checks = validateChecks(exported);
161
+ }
162
+ catch (error) {
163
+ throw new CliError(`${file}: ${error.message}`);
164
+ }
165
+ if (checks.length === 0)
166
+ return {};
167
+ const own = checks.some((c) => c.url.startsWith('/'));
168
+ // Asked for only when a check needs it: a wrong OBSERVE_APP_URL nobody uses is not a reason to refuse to start.
169
+ const baseUrl = own ? appUrl(env, nextArgs) : '';
170
+ const runner = new CheckRunner({ checks, baseUrl });
171
+ return { runner, line: ` checks ${file}: ${checks.length} ${checks.length === 1 ? 'check' : 'checks'}${own ? ` against ${baseUrl}` : ''}` };
172
+ }
173
+ /**
174
+ * The project's own specialists from observe.agents.* in the app root: `export default [defineSpecialist({…})]`.
175
+ * Same name as a built-in replaces it, a new name adds a specialist. Node ≥22.18 runs the .ts file as is (type stripping).
176
+ */
177
+ async function loadProjectSpecialists(root, agents) {
178
+ const { file, exported } = await importProjectFile(root, AGENTS_FILES);
179
+ if (!file)
180
+ return { specs: [] };
117
181
  const list = Array.isArray(exported) ? exported : exported === undefined ? undefined : [exported];
118
182
  if (!list)
119
183
  throw new CliError(`${file}: export default an array of defineSpecialist({…})`);
@@ -165,17 +229,22 @@ async function start(args, deps) {
165
229
  }
166
230
  else
167
231
  lines.push(' detector off (OBSERVE_DETECTOR=off)');
232
+ const { runner: checks, line: checksLine } = await loadChecks(args.root, deps.env, args.nextArgs);
233
+ if (checksLine)
234
+ lines.push(checksLine);
168
235
  if (args.demo)
169
236
  lines.push(' demo "shop" scenario: v1 → v2 regression, inventory errors, catalog N+1, an error new in v2 — live v2 traffic every 2 s');
170
237
  const line = lines.join('\n');
171
238
  try {
172
- const collector = await startCollector({ port: args.port, host: args.host, apiKey: args.apiKey, uiPassword: args.uiPassword, storage, chat, detector });
239
+ const collector = await startCollector({ port: args.port, host: args.host, apiKey: args.apiKey, uiPassword: args.uiPassword, storage, chat, detector, checks });
240
+ checks?.start();
173
241
  const stopDemo = args.demo ? startLiveDemo({ storage, detector }) : undefined;
174
242
  return {
175
243
  collector,
176
244
  chatLine: line,
177
245
  stop: async () => {
178
246
  stopDemo?.();
247
+ checks?.stop();
179
248
  await collector.close();
180
249
  },
181
250
  };
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAyC,MAAM,sBAAsB,CAAA;AAC3G,OAAO,EAAE,QAAQ,EAA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AAC,OAAO,KAAK,MAAM;YAAE,OAAO,MAAM,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAC7D,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACvF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,QAAQ,CAAC;YAAE,MAAM,KAAK,CAAA;QAC7C,IAAI,CAAC,GAAG,CAAC,kBAAkB,KAAK,CAAC,OAAO,OAAO,IAAI,EAAE,CAAC,CAAA;QACtD,OAAO,CAAC,CAAA;IACV,CAAC;AACH,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { type AnomalyDetector } from '../debug/detector.js';
2
2
  import type { ChatHandler } from './chat.js';
3
+ import type { CheckRunner } from '../checks/runner.js';
3
4
  import type { StorageAdapter } from './types.js';
4
5
  export interface CollectorOptions {
5
6
  /** Default 4318 (standard OTLP/HTTP port). 0 = random free port. */
@@ -26,6 +27,8 @@ export interface CollectorOptions {
26
27
  detector?: Pick<AnomalyDetector, 'observe' | 'check'>;
27
28
  /** How often the detector window is checked. Default 5 s. */
28
29
  detectorIntervalMs?: number;
30
+ /** Scheduled checks (observe.checks.ts) whose results /api/checks reports; absent → none configured. */
31
+ checks?: Pick<CheckRunner, 'list'> & Partial<Pick<CheckRunner, 'isCheckTrace'>>;
29
32
  }
30
33
  export interface Collector {
31
34
  url: string;
@@ -8,6 +8,7 @@
8
8
  // GET /api/overview?windowMs&service&toMs dashboard: requests by status class, latency, errors, top routes
9
9
  // GET /api/operation?operation&service&windowMs&toMs one operation: overview, latency histogram, two speeds, versions
10
10
  // GET /api/defects?windowMs&service&toMs errors grouped by where they originated and their message
11
+ // GET /api/checks { checks }: scheduled checks from observe.checks.ts with their latest results
11
12
  // GET /api/regression?service&sinceMinutes { regression }: the latest version vs the previous one, or null
12
13
  // GET /api/chat { enabled, mode }
13
14
  // POST /api/chat { question, sessionId? } → NDJSON stream of ChatEvent (status, step…, card…, report | error)
@@ -133,7 +134,9 @@ export async function startCollector(options = {}) {
133
134
  const spans = decodeOtlpJson(payload);
134
135
  await storage.insertSpans(spans);
135
136
  // A restart of next dev compiles each route on its first request — not an anomaly to investigate.
136
- options.detector?.observe(spans.filter((s) => !storage.isColdStart(s)));
137
+ // The observer's own check requests are not traffic: counted, they would keep the "silence" rule from ever
138
+ // firing and put expected refusals into the error rate.
139
+ options.detector?.observe(spans.filter((s) => !storage.isColdStart(s) && !options.checks?.isCheckTrace?.(s.traceId)));
137
140
  // OTLP answers in the request's format; an empty ExportTraceServiceResponse is zero bytes in protobuf.
138
141
  if (protobuf)
139
142
  res.writeHead(200, { ...CORS, 'content-type': 'application/x-protobuf' }).end();
@@ -281,6 +284,8 @@ export async function startCollector(options = {}) {
281
284
  throw new HttpError(400, 'operation is required');
282
285
  return send(res, 200, computeOperation(spans, { ...options, operation }));
283
286
  }
287
+ if (url.pathname === '/api/checks')
288
+ return send(res, 200, { checks: options.checks?.list() ?? [] });
284
289
  if (url.pathname === '/api/defects') {
285
290
  const windowMs = numberParam(q, 'windowMs') ?? OVERVIEW_DEFAULT_WINDOW_MS;
286
291
  if (windowMs < 60_000 || windowMs > 86_400_000)
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/collector/server.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,6GAA6G;AAC7G,iBAAiB;AACjB,uBAAuB;AACvB,+FAA+F;AAC/F,8BAA8B;AAC9B,uDAAuD;AACvD,gHAAgH;AAChH,2HAA2H;AAC3H,wGAAwG;AACxG,gHAAgH;AAChH,sDAAsD;AACtD,iIAAiI;AACjI,6HAA6H;AAC7H,uEAAuE;AACvE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACzD,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AC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;YAC5D,uHAAuH;YACvH,MAAM,CAAC,mBAAmB,EAAE,CAAA;QAC9B,CAAC,CAAC;KACL,CAAA;AACH,CAAC"}
@@ -14,4 +14,4 @@ Error generating stack: `+e.message+`
14
14
  `).map(e=>` ${e}`)," ```")}}m.push(``,`## Where the time went`,`Own time of each operation (without the calls it makes), share of all own time in the trace:`);for(let e of s){let t=c(e.name,e.service);m.push(`- \`${e.name}\`: ${H(e.selfMs)} (${wl(e.selfShare)})${e.calls>1?`, ${e.calls} calls`:``}${t?`, \`${t}\``:``}`)}return d.length>0&&m.push(``,`## Repeated calls`,...d),m.push(``,`## Task`,u?`1. Open the code named above and find why it throws.`:`1. Open the code named above and find what makes it slow.`,`2. Explain the cause in a few sentences, pointing at the lines.`,`3. Propose the smallest change that fixes it. Do not change behaviour elsewhere.`,xl),m.join(`
15
15
  `)}function kl(e){let t=[bl,``,`## Problem`,e.category===`browser-error`?`In the browser (service ${e.service}), ${e.pages.length?`on ${e.pages.map(e=>`\`${e.path}\``).join(`, `)}, `:``}this was recorded as "${e.operation}":`:e.category===`request`?`${ll(e.source)} \`${e.operation}\` (service ${e.service}) fails with:`:`\`${e.operation}\` (service ${e.service}) fails with:`,"```",`${e.type?`${e.type}: `:``}${e.message}`,"```",`${e.count} ${e.count===1?`occurrence`:`occurrences`} in the selected window.`],n=ul(e);return n.length>0&&t.push(`Requests failing because of it: ${n.map(e=>`\`${e.operation}\` (${e.count})`).join(`, `)}.`),e.isNew?t.push(`It first appeared in version ${e.firstSeenVersion}; it was not seen in earlier versions.`):e.versions.length>0&&t.push(`Seen in ${e.versions.length===1?`version`:`versions`} ${e.versions.join(`, `)}; first seen in ${e.firstSeenVersion??`an unknown version`}.`),e.exampleTraceIds.length>0&&t.push(`Example traces: ${e.exampleTraceIds.map(e=>`\`${e}\``).join(`, `)}.`),t.push(``,`## Task`,e.category===`browser-error`?`1. Find the client code on that page that can produce this error (the message and the component named in it are the leads).`:e.category===`request`?`1. Find where the app makes this request and the route that should answer it; say which side is wrong (the URL, the route, or what the route does).`:`1. Find where \`${e.operation}\` is implemented and which line can throw this.`,e.isNew?`2. Look at what changed in ${e.firstSeenVersion} around it (git log / diff) and explain the cause.`:`2. Explain under which inputs or conditions it throws.`,`3. Propose the smallest change that fixes it, and say how to verify the fix.`,xl),t.join(`
16
16
  `)}function Al(e){switch(e.kind){case`regression`:return`\`${e.operation}\` (${e.service}): p95 ${H(e.from.p95Ms)} in ${e.from.version} → ${H(e.to.p95Ms)} in ${e.to.version}${e.p95Ratio===null?``:` (×${e.p95Ratio})`}; error rate ${wl(e.from.errorRate)} → ${wl(e.to.errorRate)}.`;case`errors`:return e.message===Tl?void 0:`\`${e.operation}\` (${e.service}) fails in ${e.errorRate===null?`some`:wl(e.errorRate)} of calls: "${e.message}". Example traces: ${e.traceIds.map(e=>`\`${e}\``).join(`, `)}.`;case`n-plus-one`:return`\`${e.parent}\` calls \`${e.operation}\` ${e.count} times in one request (${H(e.totalMs)} in total, trace \`${e.traceId}\`).`;case`hotspot`:return`\`${e.operation}\` spends ${H(e.selfMs)} of a ${H(e.traceMs)} request in its own code${e.codeFile?` — \`${e.codeFile}\``:``} (trace \`${e.traceId}\`).`;case`silent`:return`No spans from ${e.service} for ${e.lastSpanSecondsAgo} s.`;case`traces`:return}}function jl(e,t,n){let r=n.map(Al).filter(e=>e!==void 0),i=[bl,``,`## Problem`,e];return r.length>0&&i.push(``,`## Measured`,...[...new Set(r)].map(e=>`- ${e}`)),i.push(``,`## Diagnosis by the observability agents`,`Written by a model from the data above — check it against the code rather than trusting it.`,``,t.trim(),``,`## Task`,`1. Open the code named above and confirm or correct the diagnosis.`,`2. Propose the smallest change that fixes the problem. Do not change behaviour elsewhere.`,xl),i.join(`
17
- `)}function Ml(e){return e.split(/(\*\*[^*\n]+\*\*|`[^`\n]+`)/g).map((e,t)=>e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>4?(0,m.jsx)(`strong`,{children:e.slice(2,-2)},t):e.startsWith("`")&&e.endsWith("`")&&e.length>2?(0,m.jsx)(`code`,{className:`rounded bg-muted px-1 font-mono text-[0.85em]`,children:e.slice(1,-1)},t):(0,m.jsx)(p.Fragment,{children:e},t))}var Nl=[`Checkout is slow. What's causing it and which deployment introduced it?`,`There are 500 errors on product pages. Which operation is failing and why?`,`The product catalog is slower than expected but no single span stands out. What is wrong?`],Pl=oa(`/chat`),Fl=e=>e.type===`report`||e.type===`error`;function Il(){let e=nt({queryKey:[`chat-info`],queryFn:Ba.chatInfo}),t=e.data?.enabled??!1,[n,r]=(0,p.useState)([]),[i,a]=(0,p.useState)(``),[o,s]=(0,p.useState)(),c=n.some(e=>e.running&&!e.proactive),l=(0,p.useRef)(c);l.current=c;let u=(0,p.useRef)(t);u.current=t,(0,p.useEffect)(()=>{let e=0,t=new Map,n=new EventSource(`/api/chat/events`);return n.onmessage=n=>{let{seq:i,turnId:a,event:o}=JSON.parse(n.data);if(i<=e)return;e=i,o.type===`status`&&t.set(a,o.sessionId),r(e=>{let t=e.find(e=>e.id===a),n=t??{id:a,question:o.type===`anomaly`?Gc(o.anomaly):`Anomaly`,events:[],running:u.current,proactive:!0},r={...n,events:[...n.events,o],running:n.running&&!Fl(o)};return t?e.map(e=>e.id===a?r:e):[...e,r]});let c=t.get(a);o.type===`report`&&c&&!l.current&&s(c)},()=>n.close()},[]);async function d(e){let t=`q-${Date.now()}`,n=e=>r(n=>n.map(n=>n.id===t?e(n):n));r(n=>[...n,{id:t,question:e,events:[],running:!0}]),a(``);try{await Ba.ask(e,o,e=>{e.type===`status`&&s(e.sessionId),n(t=>({...t,events:[...t.events,e]}))})}catch(e){n(t=>({...t,events:[...t.events,{type:`error`,message:e instanceof Error?e.message:String(e)}]}))}finally{n(e=>({...e,running:!1}))}}let{ask:f}=Pl.useSearch(),h=Ui({from:`/chat`}),g=(0,p.useRef)(void 0);(0,p.useEffect)(()=>{f&&t&&g.current!==f&&(g.current=f,h({search:{},replace:!0}),d(f))},[f,t]);function _(){r([]),s(void 0)}function v(e){e.preventDefault(),i.trim()&&!c&&d(i.trim())}let y=n.map(e=>(0,m.jsx)(Ll,{turn:e},e.id));return e.data&&!e.data.enabled?(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4`,children:[(0,m.jsx)(Xc,{"data-testid":`chat-disabled`,children:(0,m.jsxs)($c,{className:`space-y-2 text-sm`,children:[(0,m.jsx)(`p`,{className:`font-medium`,children:`Chat is disabled`}),(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:e.data.reason})]})}),y]}):(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-6`,children:[(0,m.jsxs)(sl,{title:`Ask the agents`,subtitle:`They read your traces with tools — every fact comes from the data.`,children:[e.data?.enabled&&(0,m.jsx)(Uc,{variant:e.data.mode===`mock`?`outline`:`secondary`,className:`font-mono`,"data-testid":`chat-mode`,children:e.data.mode===`mock`?`MOCK — no real model`:`REAL model`}),n.length>0&&(0,m.jsx)(Mc,{type:`button`,variant:`ghost`,size:`sm`,onClick:_,disabled:c,children:`New chat`})]}),n.length===0&&(0,m.jsx)(`div`,{className:`flex flex-col items-start gap-2`,children:Nl.map(e=>(0,m.jsx)(Mc,{type:`button`,variant:`outline`,size:`sm`,className:`h-auto whitespace-normal py-2 text-left font-normal`,onClick:()=>void d(e),disabled:c,children:e},e))}),y,(0,m.jsxs)(`form`,{onSubmit:v,className:`flex gap-2`,children:[(0,m.jsx)(ol,{"aria-label":`Question`,placeholder:`Why is checkout slow?`,value:i,onChange:e=>a(e.target.value),disabled:c}),(0,m.jsx)(Mc,{type:`submit`,disabled:c||!i.trim(),children:c?`Investigating…`:`Ask`})]})]})}function Ll({turn:e}){let t=e.events.find(e=>e.type===`anomaly`),n=e.events.filter(e=>e.type===`step`),r=e.events.flatMap(e=>e.type===`card`?[e.card]:[]),i=e.events.find(e=>e.type===`report`),a=e.events.find(e=>e.type===`error`),o=n.length>0||r.length>0||i||a||e.running;return(0,m.jsxs)(`div`,{className:`space-y-2`,"data-testid":`chat-turn`,"data-proactive":e.proactive?`true`:void 0,children:[t?(0,m.jsx)(qc,{anomaly:t.anomaly}):(0,m.jsx)(`div`,{className:`ml-auto w-fit max-w-[80%] rounded-2xl rounded-br-sm bg-primary px-3.5 py-2 text-sm text-primary-foreground`,children:e.question}),o&&(0,m.jsx)(Xc,{children:(0,m.jsxs)($c,{className:`space-y-3 text-sm`,children:[(0,m.jsxs)(`ol`,{className:`space-y-1 font-mono text-xs text-muted-foreground`,"data-testid":`chat-steps`,children:[n.map((e,t)=>(0,m.jsxs)(`li`,{children:[(0,m.jsxs)(`span`,{className:e.agent===`orchestrator`?`text-foreground`:`pl-4`,children:[e.agent,` → `,e.tool]}),Object.keys(e.args).length>0&&(0,m.jsx)(`span`,{className:`ml-1 opacity-70`,children:JSON.stringify(e.args).slice(0,120)})]},t)),e.running&&(0,m.jsx)(`li`,{className:`animate-pulse`,children:e.proactive?`agents are investigating on their own…`:`working…`})]}),r.length>0&&(0,m.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,"data-testid":`chat-cards`,children:r.map((e,t)=>(0,m.jsx)(al,{card:e},t))}),i&&(0,m.jsx)(`p`,{className:`whitespace-pre-wrap leading-relaxed [overflow-wrap:anywhere]`,"data-testid":`chat-report`,children:Ml(i.text)}),i&&(0,m.jsx)(`div`,{className:`flex justify-end`,children:(0,m.jsx)(Yc,{build:()=>jl(e.question,i.text,r)})}),a&&(0,m.jsx)(`p`,{className:`text-destructive`,"data-testid":`chat-error`,children:a.message})]})})]})}var Rl={"5m":3e5,"15m":9e5,"1h":36e5,"24h":864e5},zl=e=>typeof e==`string`&&e in Rl?e:void 0;function Bl({value:e,onChange:t}){return(0,m.jsx)(`div`,{className:`flex overflow-hidden rounded-md border`,role:`group`,"aria-label":`Time window`,children:Object.keys(Rl).map(n=>(0,m.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>t(n===`15m`?void 0:n),className:`border-l px-3 py-1 font-mono text-xs text-muted-foreground uppercase first:border-l-0 hover:text-foreground aria-pressed:bg-muted aria-pressed:text-foreground`,children:n},n))})}var Vl=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`});function Hl({series:e}){let t=Math.max(1,...e.map(e=>e.ok+e.clientErrors+e.serverErrors));return(0,m.jsx)(`div`,{className:`flex h-40 items-end gap-1`,role:`img`,"aria-label":`Requests over time`,children:e.map(e=>{let n=e.ok+e.clientErrors+e.serverErrors;return(0,m.jsxs)(`div`,{className:`flex h-full flex-1 flex-col justify-end`,title:`${Vl(e.startMs)} · ${n} requests · ${e.clientErrors} 4xx · ${e.serverErrors} 5xx`,"data-testid":`requests-bucket`,children:[(0,m.jsx)(Ul,{value:e.serverErrors,max:t,tone:`bg-destructive`}),(0,m.jsx)(Ul,{value:e.clientErrors,max:t,tone:`bg-warning`}),(0,m.jsx)(Ul,{value:e.ok,max:t,tone:`bg-foreground/25`}),n===0&&(0,m.jsx)(`span`,{className:`h-px bg-foreground/10`})]},e.startMs)})})}function Ul({value:e,max:t,tone:n}){return e===0?null:(0,m.jsx)(`span`,{className:`block min-h-0.5 rounded-[2px] ${n}`,style:{height:`${e/t*100}%`}})}function Wl({series:e}){let t=Math.max(1,...e.map(e=>e.p95Ms??0))*1.15,n=t=>(t+.5)/e.length*100,r=e=>100-e/t*100,i=[];e.forEach((e,t)=>{if(e.p95Ms===null||e.avgMs===null)return i.push([]);i.length===0&&i.push([]),i[i.length-1].push({i:t,avg:e.avgMs,p95:e.p95Ms})});let a=i.filter(e=>e.length>0);return(0,m.jsxs)(`div`,{className:`relative h-40`,children:[(0,m.jsxs)(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,className:`h-full w-full overflow-visible`,role:`img`,"aria-label":`Duration over time`,children:[[25,50,75].map(e=>(0,m.jsx)(`line`,{x1:`0`,x2:`100`,y1:e,y2:e,className:`stroke-foreground/10`,strokeDasharray:`1 1.5`,vectorEffect:`non-scaling-stroke`},e)),a.map(t=>{let i=t.map(e=>`${n(e.i)},${r(e.p95)}`),a=t.length===1?[`${n(t[0].i)-50/e.length},${r(t[0].p95)}`,`${n(t[0].i)+50/e.length},${r(t[0].p95)}`]:i,o=a[0].split(`,`)[0],s=a[a.length-1].split(`,`)[0];return(0,m.jsxs)(`g`,{children:[(0,m.jsx)(`polygon`,{points:`${o},100 ${a.join(` `)} ${s},100`,className:`fill-chart-1/15`}),(0,m.jsx)(`polyline`,{points:a.join(` `),fill:`none`,className:`stroke-chart-1`,strokeWidth:`1.5`,vectorEffect:`non-scaling-stroke`}),(0,m.jsx)(`polyline`,{points:t.length===1?a.map(e=>`${e.split(`,`)[0]},${r(t[0].avg)}`).join(` `):t.map(e=>`${n(e.i)},${r(e.avg)}`).join(` `),fill:`none`,className:`stroke-foreground/50`,strokeWidth:`1`,strokeDasharray:`2 2`,vectorEffect:`non-scaling-stroke`})]},t[0].i)})]}),(0,m.jsx)(`span`,{className:`absolute top-0 left-0 font-mono text-[11px] text-muted-foreground`,children:H(t)})]})}function Gl({rows:e,value:t,meta:n,empty:r}){return e.length===0?(0,m.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:r}):(0,m.jsx)(`ul`,{className:`-my-1 divide-y`,children:e.map(e=>{let[r,...i]=e.operation.split(` `),a=i.length>0&&/^[A-Z]+$/.test(r);return(0,m.jsx)(`li`,{children:(0,m.jsxs)(R,{to:`/operation`,search:{name:e.operation,service:e.service},className:`group flex items-center gap-3 py-2.5`,"data-testid":`route-row`,children:[a&&(0,m.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] tracking-wider text-muted-foreground`,children:r}),(0,m.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-sm group-hover:text-signal`,children:a?i.join(` `):e.operation}),(0,m.jsxs)(`span`,{className:`text-right`,children:[(0,m.jsx)(`span`,{className:`block font-mono text-sm tabular-nums`,children:t(e)}),(0,m.jsx)(`span`,{className:`block font-mono text-[11px] text-muted-foreground`,children:n(e)})]})]})},`${e.service}:${e.operation}`)})})}function Kl({title:e,count:t,change:n,children:r,aside:i,testId:a}){return(0,m.jsxs)(Xc,{className:`gap-0 py-0`,"data-testid":a,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b px-5 py-3.5`,children:[(0,m.jsx)(`h2`,{className:`font-medium`,children:e}),t!==void 0&&(0,m.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 font-mono text-xs tabular-nums`,children:t}),n,i&&(0,m.jsx)(`div`,{className:`ml-auto flex items-center gap-3 font-mono text-xs text-muted-foreground`,children:i})]}),(0,m.jsx)(`div`,{className:`px-5 py-4`,children:r})]})}function ql({value:e,upIsBad:t}){if(e===null)return null;let n=Math.round(e*100),r=n>0,i=n===0||t===void 0?`text-muted-foreground`:r===t?`text-destructive`:`text-signal`,a=r?po:uo;return(0,m.jsxs)(`span`,{className:`flex items-center gap-1 text-xs ${i}`,"data-testid":`change`,children:[n!==0&&(0,m.jsx)(a,{className:`size-3.5`,"aria-hidden":!0}),r?`+`:``,n,`% `,(0,m.jsx)(`span`,{className:`text-muted-foreground`,children:`since last period`})]})}function Jl({tone:e,children:t}){return(0,m.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`h-3 w-0.5 rounded-full ${e}`,"aria-hidden":!0}),t]})}function Yl({label:e,children:t}){return(0,m.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e,(0,m.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-foreground tabular-nums`,children:t})]})}function Xl({fromMs:e,toMs:t}){let n=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return(0,m.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:n(e)}),(0,m.jsx)(`span`,{children:n(t)})]})}var Zl=2e3,Ql=oa(`/`),$l=e=>`${Math.round(e*100)}%`;function eu(){let{window:e=`15m`,service:t}=Ql.useSearch(),n=Ui({from:`/`}),r=nt({queryKey:[`overview`,e,t],queryFn:()=>Ba.overview(Rl[e],t),refetchInterval:Zl}),i=nt({queryKey:[`services`],queryFn:Ba.services,refetchInterval:Zl}),a=r.data;return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(sl,{title:`Overview`,subtitle:`Your app's requests, latency and errors — compared with the period before.`,children:[(0,m.jsxs)(`select`,{"aria-label":`Service`,className:`h-8 rounded-md border bg-card px-2 text-sm`,value:t??``,onChange:e=>n({search:t=>({...t,service:e.target.value||void 0}),replace:!0}),children:[(0,m.jsx)(`option`,{value:``,children:`All services`}),i.data?.filter(e=>!e.name.endsWith(`-browser`)).map(e=>(0,m.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,m.jsx)(Bl,{value:e,onChange:e=>n({search:t=>({...t,window:e}),replace:!0})})]}),a?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Requests`,testId:`panel-requests`,count:a.requests.total,change:(0,m.jsx)(ql,{value:a.requests.change}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`span`,{className:`tabular-nums`,children:[a.requests.perSecond,`/s`]}),(0,m.jsx)(Jl,{tone:`bg-foreground/40`,children:`2/3xx`}),(0,m.jsx)(Jl,{tone:`bg-warning`,children:`4xx`}),(0,m.jsx)(Jl,{tone:`bg-destructive`,children:`5xx`})]}),children:[(0,m.jsx)(Hl,{series:a.requests.series}),(0,m.jsx)(Xl,{fromMs:a.fromMs,toMs:a.toMs})]}),(0,m.jsxs)(Kl,{title:`Duration`,testId:`panel-duration`,change:(0,m.jsx)(ql,{value:a.duration.change,upIsBad:!0}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Yl,{label:`AVG`,children:a.duration.avgMs===null?`—`:H(a.duration.avgMs)}),(0,m.jsx)(Yl,{label:`P95`,children:a.duration.p95Ms===null?`—`:H(a.duration.p95Ms)})]}),children:[(0,m.jsx)(Wl,{series:a.duration.series}),(0,m.jsx)(Xl,{fromMs:a.fromMs,toMs:a.toMs})]})]}),(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,m.jsxs)(Kl,{title:`Errors`,testId:`panel-errors`,count:a.errors.count,change:(0,m.jsx)(ql,{value:a.errors.change,upIsBad:!0}),aside:(0,m.jsx)(R,{to:`/errors`,search:{window:e===`15m`?void 0:e,service:t},className:`hover:text-signal`,children:`view all →`}),children:[(0,m.jsxs)(`div`,{className:`space-y-1`,children:[(0,m.jsx)(`div`,{className:`font-mono text-4xl font-medium tabular-nums ${a.errors.count>0?`text-destructive`:``}`,"data-testid":`error-rate`,children:$l(a.errors.rate)}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`of requests failed with 5xx`})]}),(0,m.jsx)(`div`,{className:`mt-4 flex h-12 items-end gap-0.5`,"aria-hidden":!0,children:a.requests.series.map(e=>{let t=Math.max(1,...a.requests.series.map(e=>e.serverErrors));return(0,m.jsx)(`span`,{className:`flex-1 rounded-[2px] ${e.serverErrors?`bg-destructive`:`bg-foreground/10`}`,style:{height:e.serverErrors?`${e.serverErrors/t*100}%`:`2px`}},e.startMs)})})]}),(0,m.jsx)(Kl,{title:`Slowest`,testId:`panel-slowest`,aside:`P95`,children:(0,m.jsx)(Gl,{rows:a.slowest,value:e=>H(e.p95Ms),meta:e=>`${e.count} ${e.count===1?`call`:`calls`}${e.errorRate>0?` · ${$l(e.errorRate)} errors`:``}${e.coldOnly?` · cold start only`:``}`,empty:`No requests in this window.`})}),(0,m.jsx)(Kl,{title:`Busiest`,testId:`panel-busiest`,aside:`CALLS`,children:(0,m.jsx)(Gl,{rows:a.busiest,value:e=>String(e.count),meta:e=>`${$l(e.share)} of requests`,empty:`No requests in this window.`})})]})]}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:r.isError?`The observer is not reachable.`:`Loading…`})]})}var tu=2e3,nu=oa(`/errors`);function ru(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)} min ago`:`${Math.round(t/3600)} h ago`}function iu(){let{window:e=`15m`,service:t}=nu.useSearch(),n=Ui({from:`/errors`}),r=nt({queryKey:[`defects`,e,t],queryFn:()=>Ba.defects(Rl[e],t),refetchInterval:tu});return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsx)(sl,{title:`Errors`,count:r.data?.length,subtitle:`Failures grouped by where they start and what they say — one entry per defect, not per request.`,children:(0,m.jsx)(Bl,{value:e,onChange:e=>n({search:t=>({...t,window:e}),replace:!0})})}),r.data?r.data.length===0?(0,m.jsxs)(Xc,{className:`items-center py-12 text-center`,"data-testid":`errors-empty`,children:[(0,m.jsxs)(`p`,{className:`font-medium`,children:[`No errors in the last `,e]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`A defect shows up here as soon as a span fails.`})]}):(0,m.jsx)(`div`,{className:`space-y-4`,children:r.data.map(e=>(0,m.jsx)(au,{defect:e},e.id))}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:r.isError?`The observer is not reachable.`:`Loading…`})]})}function au({defect:e}){let t=Ui(),n=Math.max(1,...e.series),r=ul(e);return(0,m.jsxs)(Xc,{className:`gap-0 py-0`,"data-testid":`defect`,"data-new":e.isNew?`true`:void 0,children:[(0,m.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 px-5 py-4 lg:grid-cols-[minmax(0,1fr)_14rem]`,children:[(0,m.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.isNew?(0,m.jsxs)(`span`,{className:`rounded-md bg-warning/15 px-1.5 py-0.5 font-mono text-[11px] tracking-wider text-warning uppercase`,"data-testid":`defect-new`,children:[`new in `,e.firstSeenVersion]}):e.versions.length>0&&(0,m.jsxs)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:[`seen in `,e.versions.join(`, `)]}),(0,m.jsx)(`span`,{className:`rounded-md border px-1.5 py-0.5 font-mono text-[11px] tracking-wider uppercase ${e.source===`browser`?`border-signal/40 text-signal`:`text-muted-foreground`}`,"data-testid":`defect-source`,children:e.source}),e.type&&(0,m.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.type})]}),(0,m.jsx)(`p`,{className:`font-mono text-sm break-words text-destructive`,"data-testid":`defect-message`,children:e.message}),(0,m.jsxs)(`p`,{className:`text-sm text-muted-foreground`,"data-testid":`defect-where`,children:[e.category===`code`?(0,m.jsxs)(m.Fragment,{children:[`in`,` `,(0,m.jsx)(R,{to:`/operation`,search:{name:e.spanName,service:e.service},className:`font-mono text-foreground underline decoration-dotted underline-offset-4 hover:text-signal`,children:e.operation})]}):(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.operation}),e.pages.length>0&&(0,m.jsxs)(m.Fragment,{children:[` `,`· on`,` `,e.pages.map((e,t)=>(0,m.jsxs)(`span`,{children:[t>0&&`, `,(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.path})]},e.path))]}),r.length>0&&(0,m.jsxs)(m.Fragment,{children:[` `,`· fails`,` `,r.map((e,t)=>(0,m.jsxs)(`span`,{children:[t>0&&`, `,e.spanName===e.operation?(0,m.jsx)(R,{to:`/operation`,search:{name:e.spanName,service:e.service},className:`font-mono text-foreground hover:text-signal`,children:e.operation}):(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.operation})]},`${e.service}:${e.spanName}:${e.operation}`))]})]})]}),(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,m.jsx)(`span`,{className:`font-mono text-2xl font-medium tabular-nums`,"data-testid":`defect-count`,children:e.count}),(0,m.jsx)(`span`,{className:`font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:e.count===1?`occurrence`:`occurrences`})]}),(0,m.jsx)(`div`,{className:`flex h-8 items-end gap-0.5`,"aria-hidden":!0,children:e.series.map((e,t)=>(0,m.jsx)(`span`,{className:`flex-1 rounded-[2px] ${e?`bg-destructive`:`bg-foreground/10`}`,style:{height:e?`${Math.max(e/n*100,12)}%`:`2px`}},t))})]})]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-2 border-t px-5 py-2.5 font-mono text-xs text-muted-foreground`,children:[(0,m.jsxs)(`span`,{children:[`first seen `,ru(e.firstSeenMs)]}),(0,m.jsxs)(`span`,{children:[`last seen `,ru(e.lastSeenMs)]}),(0,m.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`traces`,e.exampleTraceIds.map(e=>(0,m.jsxs)(R,{to:`/traces/$traceId`,params:{traceId:e},className:`text-signal underline-offset-2 hover:underline`,children:[e.slice(0,6),`…`,e.slice(-4)]},e))]}),(0,m.jsx)(Yc,{build:()=>kl(e),className:`ml-auto font-sans`}),(0,m.jsx)(Mc,{type:`button`,size:`sm`,variant:`outline`,className:`font-sans`,"data-testid":`defect-investigate`,onClick:()=>void t({to:`/chat`,search:{ask:fl(e)}}),children:`Investigate`})]})]})}function W(e,t,n=.06){let r=[{label:`median`,ms:e.p50Ms},{label:`p95`,ms:e.p95Ms},{label:`p99`,ms:e.p99Ms}],i=[];for(let e of r)(i.length===0||(e.ms-i[i.length-1].ms)/t>n)&&i.push(e);return i}var ou=e=>`${Math.round(e*100)}%`;function su({histogram:e,speeds:t}){let n=e.bins[e.bins.length-1].toMs||1,r=Math.max(1,...e.bins.map(e=>e.count)),i=W(e,n);return(0,m.jsxs)(`div`,{"data-testid":`latency-histogram`,children:[(0,m.jsxs)(`div`,{className:`relative mt-6 h-40`,children:[i.map(e=>(0,m.jsx)(`div`,{className:`absolute -top-6 bottom-0 border-l border-dashed border-foreground/30`,style:{left:`${Math.min(e.ms/n*100,100)}%`},children:(0,m.jsxs)(`span`,{className:`absolute top-0 font-mono text-[10px] tracking-wider whitespace-nowrap text-muted-foreground uppercase ${e.ms/n>.75?`right-1.5`:`left-1.5`}`,children:[e.label,` `,H(e.ms)]})},e.label)),(0,m.jsx)(`div`,{className:`flex h-full items-end gap-0.5`,role:`img`,"aria-label":`Latency distribution`,children:e.bins.map((t,n)=>(0,m.jsx)(`span`,{"data-testid":`histogram-bin`,title:`${H(t.fromMs)} – ${n===e.bins.length-1&&e.overflow?`and slower`:H(t.toMs)} · ${t.count} calls (${ou(t.count/e.total)})`,className:`flex-1 rounded-t-[2px] ${t.count?`bg-chart-1/70`:`bg-foreground/10`}`,style:{height:t.count?`${Math.max(t.count/r*100,2)}%`:`1px`}},n))})]}),(0,m.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:`0`}),(0,m.jsx)(`span`,{children:H(n/2)}),(0,m.jsxs)(`span`,{children:[e.overflow?`≥ `:``,H(n)]})]}),t&&(0,m.jsxs)(`p`,{className:`mt-3 font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,"data-testid":`two-speeds`,children:[(0,m.jsx)(`span`,{className:`text-warning`,children:`Two speeds`}),` · `,H(t[0].medianMs),` (`,ou(t[0].share),`) and `,H(t[1].medianMs),` (`,ou(t[1].share),`) ·`,` `,Math.round(t[1].medianMs/t[0].medianMs),`× apart`]})]})}function cu({label:e,children:t}){return(0,m.jsxs)(`div`,{className:`flex items-baseline gap-2 py-1 text-xs`,children:[(0,m.jsxs)(`dt`,{className:`flex min-w-0 flex-1 items-baseline gap-2 text-muted-foreground`,children:[(0,m.jsx)(`span`,{className:`shrink-0`,children:e}),(0,m.jsx)(`span`,{"aria-hidden":!0,className:`min-w-4 flex-1 border-b border-dotted border-foreground/20`})]}),(0,m.jsx)(`dd`,{className:`min-w-0 max-w-[70%] break-all text-right font-mono`,children:t})]})}var lu=`The first request of this route after the server started. In next dev it includes compiling the route, so it is slower than the rest — the agents leave it out of latency statistics.`;function uu(){return(0,m.jsx)(Uc,{variant:`outline`,title:lu,className:`ml-2 cursor-help font-normal text-muted-foreground`,children:`cold start`})}function du({className:e,...t}){return(0,m.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,m.jsx)(`table`,{"data-slot":`table`,className:ds(`w-full caption-bottom text-sm`,e),...t})})}function fu({className:e,...t}){return(0,m.jsx)(`thead`,{"data-slot":`table-header`,className:ds(`[&_tr]:border-b`,e),...t})}function pu({className:e,...t}){return(0,m.jsx)(`tbody`,{"data-slot":`table-body`,className:ds(`[&_tr:last-child]:border-0`,e),...t})}function mu({className:e,...t}){return(0,m.jsx)(`tr`,{"data-slot":`table-row`,className:ds(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function hu({className:e,...t}){return(0,m.jsx)(`th`,{"data-slot":`table-head`,className:ds(`h-10 px-2 text-left align-middle font-mono text-[11px] font-normal tracking-wider whitespace-nowrap text-muted-foreground uppercase [&:has([role=checkbox])]:pr-0`,e),...t})}function gu({className:e,...t}){return(0,m.jsx)(`td`,{"data-slot":`table-cell`,className:ds(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}function _u({traces:e,empty:t}){return(0,m.jsx)(Xc,{className:`py-0`,children:(0,m.jsxs)(du,{children:[(0,m.jsx)(fu,{children:(0,m.jsxs)(mu,{children:[(0,m.jsx)(hu,{className:`pl-4`,children:`Trace`}),(0,m.jsx)(hu,{children:`Services`}),(0,m.jsx)(hu,{className:`text-right`,children:`Duration`}),(0,m.jsx)(hu,{className:`text-right`,children:`Spans`}),(0,m.jsx)(hu,{className:`text-right`,children:`Errors`}),(0,m.jsx)(hu,{className:`pr-4 text-right`,children:`Started`})]})}),(0,m.jsxs)(pu,{children:[e?.map(e=>(0,m.jsxs)(mu,{"data-testid":`trace-row`,children:[(0,m.jsxs)(gu,{className:`pl-4`,children:[(0,m.jsx)(R,{to:`/traces/$traceId`,params:{traceId:e.traceId},className:`font-medium hover:underline`,children:e.rootName}),e.coldStart&&(0,m.jsx)(uu,{}),(0,m.jsx)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:e.traceId.slice(0,16)})]}),(0,m.jsx)(gu,{className:`space-x-1`,children:e.services.map(e=>(0,m.jsx)(Uc,{variant:`secondary`,children:e},e))}),(0,m.jsx)(gu,{className:`text-right font-mono tabular-nums`,children:H(e.durationMs)}),(0,m.jsx)(gu,{className:`text-right font-mono text-muted-foreground tabular-nums`,children:e.spanCount}),(0,m.jsx)(gu,{className:`text-right`,children:e.errorCount>0?(0,m.jsx)(Uc,{variant:`destructive`,children:e.errorCount}):`—`}),(0,m.jsx)(gu,{className:`pr-4 text-right font-mono text-xs text-muted-foreground tabular-nums`,children:new Date(e.startTimeMs).toLocaleTimeString()})]},e.traceId)),e?.length===0&&(0,m.jsx)(mu,{children:(0,m.jsx)(gu,{colSpan:6,className:`py-10 text-center text-muted-foreground`,children:t})})]})]})})}var vu=2e3,yu=oa(`/operation`),bu=e=>`${Math.round(e*100)}%`,G=e=>e==null?`—`:H(e);function xu(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)} min ago`:`${Math.round(t/3600)} h ago`}function Su(){let{name:e,service:t,window:n=`15m`}=yu.useSearch(),r=Ui({from:`/operation`}),i=nt({queryKey:[`operation`,e,t,n],queryFn:()=>Ba.operation(e,Rl[n],t),refetchInterval:vu,enabled:e!==``}),a=i.data,o=a?.overview.fromMs,s=nt({queryKey:[`operation-traces`,e,t,o],queryFn:()=>Ba.traces({operation:e,exactOperation:!0,service:t,fromMs:o,limit:50}),enabled:e!==``&&o!==void 0,placeholderData:e=>e});if(e===``)return(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:`No operation selected — pick one on the Overview.`});let c=a?.overview;return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(R,{to:`/`,className:`font-mono text-xs text-muted-foreground hover:text-foreground`,children:`← overview`}),(0,m.jsx)(sl,{title:(0,m.jsx)(`span`,{className:`font-mono text-xl`,children:e}),subtitle:a?.service?`One operation of ${a.service} — its traffic, latency and every call.`:`One operation — its traffic, latency and every call.`,children:(0,m.jsx)(Bl,{value:n,onChange:e=>r({search:t=>({...t,window:e}),replace:!0})})})]}),!a||!c?(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:i.isError?`The observer is not reachable.`:`Loading…`}):c.requests.total===0?(0,m.jsxs)(`p`,{className:`text-muted-foreground`,"data-testid":`operation-empty`,children:[`No calls of this operation in the last `,n,`. Try a longer window.`]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Details`,testId:`panel-details`,children:[(0,m.jsxs)(`dl`,{children:[(0,m.jsx)(cu,{label:`Calls`,children:c.requests.total}),(0,m.jsx)(cu,{label:`Avg duration`,children:G(c.duration.avgMs)}),(0,m.jsx)(cu,{label:`Median`,children:G(a.histogram?.p50Ms)}),(0,m.jsx)(cu,{label:`95th percentile`,children:G(c.duration.p95Ms)}),(0,m.jsx)(cu,{label:`Errors`,children:(0,m.jsxs)(`span`,{className:c.errors.count?`text-destructive`:``,children:[c.errors.count,` (`,bu(c.errors.rate),`)`]})}),a.coldStarts>0&&(0,m.jsx)(cu,{label:`Cold starts (not in latency)`,children:a.coldStarts}),(0,m.jsx)(cu,{label:`Last call`,children:a.lastSeenMs===null?`—`:xu(a.lastSeenMs)})]}),a.versions.length>1&&(0,m.jsxs)(`table`,{className:`mt-4 w-full font-mono text-xs`,"data-testid":`versions`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{className:`text-left text-[11px] tracking-wider text-muted-foreground uppercase`,children:[(0,m.jsx)(`th`,{className:`py-1 font-normal`,children:`Version`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Calls`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Median`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`P95`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Errors`})]})}),(0,m.jsx)(`tbody`,{children:a.versions.map(e=>(0,m.jsxs)(`tr`,{className:`border-t tabular-nums`,children:[(0,m.jsx)(`td`,{className:`py-1.5`,children:e.version}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:e.count}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:H(e.p50Ms)}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:H(e.p95Ms)}),(0,m.jsx)(`td`,{className:`py-1.5 text-right ${e.errorRate>0?`text-destructive`:``}`,children:bu(e.errorRate)})]},e.version))})]})]}),(0,m.jsx)(Kl,{title:`Latency distribution`,testId:`panel-distribution`,aside:a.histogram?`${a.histogram.total} calls`:void 0,children:a.histogram?(0,m.jsx)(su,{histogram:a.histogram,speeds:a.speeds}):(0,m.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`Only cold starts so far — no representative latency yet.`})})]}),(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Calls`,testId:`panel-requests`,count:c.requests.total,change:(0,m.jsx)(ql,{value:c.requests.change}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Jl,{tone:`bg-foreground/40`,children:`ok`}),(0,m.jsx)(Jl,{tone:`bg-warning`,children:`4xx`}),(0,m.jsx)(Jl,{tone:`bg-destructive`,children:`failed`})]}),children:[(0,m.jsx)(Hl,{series:c.requests.series}),(0,m.jsx)(Xl,{fromMs:c.fromMs,toMs:c.toMs})]}),(0,m.jsxs)(Kl,{title:`Duration`,testId:`panel-duration`,change:(0,m.jsx)(ql,{value:c.duration.change,upIsBad:!0}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Yl,{label:`AVG`,children:G(c.duration.avgMs)}),(0,m.jsx)(Yl,{label:`P95`,children:G(c.duration.p95Ms)})]}),children:[(0,m.jsx)(Wl,{series:c.duration.series}),(0,m.jsx)(Xl,{fromMs:c.fromMs,toMs:c.toMs})]})]}),(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(`h2`,{className:`font-medium`,children:`Traces with this operation`}),(0,m.jsx)(_u,{traces:s.data,empty:`No traces in this window.`})]})]})]})}var Cu=/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/,wu=e=>e.kind===`client`&&Cu.test(e.name);function Tu(e){if(!wu(e))return;let t=e.attributes[`url.full`]??e.attributes[`http.url`];if(typeof t==`string`)try{return{method:e.name,pathname:new URL(t).pathname}}catch{return}}function Eu(e){let t=Tu(e);return t?`${t.method} ${t.pathname}`:e.name}var Du=oa(`/traces/$traceId`),Ou=[`bg-chart-1`,`bg-chart-2`,`bg-chart-4`,`bg-chart-3`,`bg-chart-5`];function ku(e,t){return Ou[t.indexOf(e)%Ou.length]}function Au(){let{traceId:e}=Du.useParams(),t=nt({queryKey:[`trace`,e],queryFn:()=>Ba.trace(e)}),[n,r]=(0,p.useState)(null),i=(0,p.useMemo)(()=>Pc(t.data?.spans??[]),[t.data]),a=(0,p.useMemo)(()=>[...new Set(i.rows.map(e=>e.span.service))],[i]),o=i.rows.find(e=>e.span.spanId===n)?.span??i.rows[0]?.span,[s,c]=(0,p.useState)(!1),l=t.data?.spans,u=(0,p.useMemo)(()=>vl(l??[]),[l]),d=(0,p.useMemo)(()=>gl(l??[]),[l]),f=(0,p.useMemo)(()=>U(l??[]),[l]),h=(0,p.useMemo)(()=>_l(l??[]),[l]),g=nt({queryKey:[`trace-operation`,h?.service,h?.name,h?.startTimeMs],queryFn:()=>Ba.operation(h.name,Mu,h.service,h.startTimeMs+Mu/2),enabled:h!==void 0});return t.isError?(0,m.jsxs)(`p`,{className:`text-destructive`,children:[`Trace `,e,` not found.`]}):t.data?(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(R,{to:`/traces`,className:`font-mono text-xs text-muted-foreground hover:text-foreground`,children:`← traces`}),(0,m.jsx)(sl,{title:(0,m.jsxs)(m.Fragment,{children:[i.rows[0]?Eu(i.rows[0].span):``,t.data.spans.some(e=>e.coldStart)&&(0,m.jsx)(uu,{})]}),subtitle:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`text-foreground tabular-nums`,children:H(i.durationMs)}),` · `,i.rows.length,` spans · `,e]}),children:(0,m.jsx)(Yc,{build:()=>{let n=g.data?.histogram;return Ol({traceId:e,spans:t.data.spans,usual:n&&n.total>=ju?{p50Ms:n.p50Ms,p95Ms:n.p95Ms,calls:n.total}:void 0})}})})]}),h&&g.data?.histogram&&g.data.histogram.total>=ju&&(0,m.jsx)(Fu,{durationMs:h.durationMs,histogram:g.data.histogram,operation:h.name,service:h.service,coldStart:h.coldStart===!0}),(0,m.jsxs)(`div`,{className:`grid grid-cols-[1fr_380px] gap-4`,children:[(0,m.jsxs)(Xc,{className:`gap-0 self-start py-0`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b px-4 py-2.5`,children:[(0,m.jsx)(`button`,{type:`button`,"aria-pressed":s,"data-testid":`critical-path-toggle`,onClick:()=>c(e=>!e),className:`rounded-full border px-3 py-1 font-mono text-[11px] tracking-wider text-muted-foreground uppercase hover:text-foreground aria-pressed:border-warning/60 aria-pressed:bg-warning/10 aria-pressed:text-warning`,children:`Critical path`}),(0,m.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:s?`The spans that decided the duration — values show their own time.`:`Highlight the spans that decided the duration.`})]}),(0,m.jsx)(`div`,{role:`tree`,"aria-label":`Waterfall`,children:i.rows.map(({span:e,depth:t,offsetPct:n,widthPct:i})=>(0,m.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":e.spanId===o?.spanId,"data-span-name":e.name,"data-critical":u.has(e.spanId)?`true`:void 0,onClick:()=>r(e.spanId),className:`grid w-full grid-cols-[minmax(0,2fr)_minmax(0,3fr)_4.5rem] items-center gap-3 border-b px-4 py-2 text-left text-sm last:border-b-0 hover:bg-muted/50 aria-selected:bg-muted ${s&&!u.has(e.spanId)?`opacity-30`:``}`,children:[(0,m.jsxs)(`span`,{className:`truncate`,style:{paddingLeft:t*14},children:[(0,m.jsx)(`span`,{className:e.status===`error`?`font-medium text-destructive`:``,children:Eu(e)}),e.coldStart&&(0,m.jsx)(uu,{}),(0,m.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.service})]}),(0,m.jsx)(`span`,{className:`relative h-2.5`,children:(0,m.jsx)(`span`,{className:`absolute top-0 h-2.5 min-w-0.5 rounded-full opacity-80 ${e.status===`error`?`bg-destructive`:ku(e.service,a)}`,style:{left:`${n}%`,width:`${i}%`}})}),(0,m.jsx)(`span`,{className:`text-right font-mono text-xs tabular-nums ${s?`text-warning`:`text-muted-foreground`}`,children:H(s?d.get(e.spanId)??0:e.durationMs)})]},e.spanId))})]}),o&&(0,m.jsx)(Iu,{span:o,selfMs:d.get(o.spanId)})]}),(0,m.jsx)(Kl,{title:`Where the time went`,testId:`panel-self-time`,aside:`own time, without calls to others · % of all own time`,children:(0,m.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{className:`text-left font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:[(0,m.jsx)(`th`,{className:`pb-2 font-normal`,children:`Operation`}),(0,m.jsx)(`th`,{className:`w-1/4 pb-2 font-normal`,children:`Self %`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Self`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Total`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Calls`})]})}),(0,m.jsx)(`tbody`,{children:f.map(e=>(0,m.jsxs)(`tr`,{className:`border-t`,"data-testid":`self-time-row`,children:[(0,m.jsxs)(`td`,{className:`max-w-0 truncate py-2 pr-3 font-mono`,children:[(0,m.jsx)(R,{to:`/operation`,search:{name:e.name,service:e.service},className:`hover:text-signal`,children:e.name}),a.length>1&&(0,m.jsx)(`span`,{className:`ml-2 font-sans text-xs text-muted-foreground`,children:e.service})]}),(0,m.jsx)(`td`,{className:`py-2 pr-3`,children:(0,m.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(`span`,{className:`h-1.5 flex-1 rounded-full bg-muted`,children:(0,m.jsx)(`span`,{className:`block h-1.5 rounded-full bg-warning/80`,style:{width:`${e.selfShare*100}%`}})}),(0,m.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs text-muted-foreground tabular-nums`,children:[Math.round(e.selfShare*100),`%`]})]})}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono tabular-nums`,children:H(e.selfMs)}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono text-muted-foreground tabular-nums`,children:H(e.totalMs)}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono text-muted-foreground tabular-nums`,children:e.calls})]},`${e.service}:${e.name}`))})]})})]}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading…`})}var ju=5,Mu=36e5,Nu={slow:{text:`slower than 95% of the calls`,tone:`text-warning`,dot:`bg-warning`},typical:{text:`a typical call`,tone:`text-signal`,dot:`bg-signal`},fast:{text:`faster than half of the calls`,tone:`text-signal`,dot:`bg-signal`}},Pu={text:`a cold start`,tone:`text-muted-foreground`,dot:`bg-muted-foreground`};function Fu({durationMs:e,histogram:t,operation:n,service:r,coldStart:i}){let a=i?Pu:Nu[yl(e,t)],o=Math.max(t.p99Ms,e)*1.05||1,s=e=>`${Math.min(e/o*100,100)}%`;return(0,m.jsxs)(Kl,{title:`Compared to other calls`,testId:`panel-compared`,aside:(0,m.jsxs)(R,{to:`/operation`,search:{name:n,service:r},className:`hover:text-signal`,children:[t.total,` calls · the hour around this one →`]}),children:[(0,m.jsxs)(`div`,{className:`relative mt-5 mb-9 h-1.5 rounded-full bg-muted`,children:[[{label:`median`,ms:t.p50Ms},{label:`p95`,ms:t.p95Ms}].map(e=>(0,m.jsx)(`span`,{className:`absolute -top-5 h-8 border-l border-dashed border-foreground/30`,style:{left:s(e.ms)},children:(0,m.jsxs)(`span`,{className:`absolute -top-0.5 font-mono text-[10px] tracking-wider whitespace-nowrap text-muted-foreground uppercase ${e.ms/o>.75?`right-1.5`:`left-1.5`}`,children:[e.label,` `,H(e.ms)]})},e.label)),(0,m.jsx)(`span`,{className:`absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full ring-4 ring-background ${a.dot}`,style:{left:s(e)},"data-testid":`this-call`}),(0,m.jsxs)(`span`,{className:`absolute top-4 -translate-x-1/2 font-mono text-xs whitespace-nowrap ${a.tone}`,style:{left:`clamp(3rem, ${s(e)}, calc(100% - 3rem))`},children:[H(e),` · this call`]})]}),(0,m.jsxs)(`p`,{className:`text-sm`,"data-testid":`standing`,children:[(0,m.jsx)(`span`,{className:a.tone,children:a.text[0].toUpperCase()+a.text.slice(1)}),(0,m.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`— `,i?`it includes compiling the route, so it is not judged against the warm calls.`:`${(e/(t.p50Ms||1)).toFixed(1)}× the median.`]})]})]})}function Iu({span:e,selfMs:t}){let n=[[`service`,e.serviceVersion?`${e.service}@${e.serviceVersion}`:e.service],[`kind`,e.kind],[`duration`,H(e.durationMs)],...t===void 0?[]:[[`own time`,H(t)]],[`status`,e.statusMessage?`${e.status}: ${e.statusMessage}`:e.status],...Object.entries(e.attributes)];return(0,m.jsxs)(Xc,{className:`self-start`,"data-testid":`span-details`,children:[(0,m.jsxs)(Zc,{children:[(0,m.jsxs)(Qc,{className:`flex items-center gap-2 text-base`,children:[Eu(e),e.status===`error`&&(0,m.jsx)(Uc,{variant:`destructive`,children:`error`})]}),(0,m.jsx)(R,{to:`/operation`,search:{name:e.name,service:e.service},className:`font-mono text-xs text-signal underline-offset-2 hover:underline`,"data-testid":`operation-link`,children:`all calls of this operation →`})]}),(0,m.jsxs)($c,{className:`space-y-3`,children:[(0,m.jsx)(`dl`,{children:n.map(([e,t])=>(0,m.jsx)(cu,{label:e,children:typeof t==`string`?t:JSON.stringify(t)},e))}),e.events.map((e,t)=>(0,m.jsxs)(`div`,{className:`rounded-md bg-muted p-2 text-xs`,children:[(0,m.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,m.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:String(e.attributes[`exception.message`]??``)})]},t))]})]})}function Lu({className:e,size:t=`default`,...n}){return(0,m.jsx)(wc,{"data-slot":`switch`,"data-size":t,className:ds(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,m.jsx)(Ec,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}var Ru=2e3,zu=oa(`/traces`);function Bu(){let e=zu.useSearch(),t=Ui({from:`/traces`}),n=e=>t({search:t=>({...t,...e}),replace:!0}),r=nt({queryKey:[`traces`,e],queryFn:()=>Ba.traces(e),refetchInterval:Ru}),i=nt({queryKey:[`services`],queryFn:Ba.services,refetchInterval:Ru});return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsx)(sl,{title:`Traces`,count:r.data?.length,subtitle:`Every request your app made — server and browser, live.`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,m.jsxs)(`select`,{"aria-label":`Service`,className:`h-9 rounded-md border bg-card px-2 text-sm`,value:e.service??``,onChange:e=>n({service:e.target.value||void 0}),children:[(0,m.jsx)(`option`,{value:``,children:`All services`}),i.data?.map(e=>(0,m.jsxs)(`option`,{value:e.name,children:[e.name,e.versions.length?` (${e.versions.join(`, `)})`:``]},e.name))]}),(0,m.jsx)(ol,{"aria-label":`Operation`,className:`w-64`,placeholder:`Operation contains…`,defaultValue:e.operation??``,onChange:e=>n({operation:e.target.value||void 0})}),(0,m.jsx)(ol,{"aria-label":`Min duration (ms)`,className:`w-40`,type:`number`,min:0,placeholder:`Min ms`,defaultValue:e.minDurationMs??``,onChange:e=>n({minDurationMs:Number(e.target.value)||void 0})}),(0,m.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,m.jsx)(Lu,{checked:e.hasError??!1,onCheckedChange:e=>n({hasError:e||void 0})}),`Errors only`]}),r.isError&&(0,m.jsx)(`span`,{className:`ml-auto font-mono text-xs text-destructive`,children:`collector unreachable`})]}),(0,m.jsx)(_u,{traces:r.data,empty:(0,m.jsxs)(m.Fragment,{children:[`No traces yet — open your app while `,(0,m.jsx)(`code`,{children:`next-observer dev`}),` is running.`]})})]})}function Vu({to:e,children:t}){return(0,m.jsx)(R,{to:e,activeOptions:{exact:e===`/`,includeSearch:!1},className:`rounded-md px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground [&.active]:bg-muted [&.active]:text-foreground`,children:t})}var Hu=da({component:()=>(0,m.jsxs)(`div`,{className:`min-h-screen text-foreground`,children:[(0,m.jsx)(`header`,{className:`sticky top-0 z-20 border-b bg-background/70 backdrop-blur-md`,children:(0,m.jsxs)(`div`,{className:`mx-auto flex h-14 max-w-7xl items-center gap-2 px-6`,children:[(0,m.jsxs)(R,{to:`/`,className:`mr-4 flex items-center gap-2 font-semibold tracking-tight`,children:[(0,m.jsx)(`span`,{"aria-hidden":!0,className:`size-2.5 rounded-sm bg-signal shadow-[0_0_12px_var(--signal)]`}),`next-observer`]}),(0,m.jsx)(Vu,{to:`/`,children:`Overview`}),(0,m.jsx)(Vu,{to:`/errors`,children:`Errors`}),(0,m.jsx)(Vu,{to:`/traces`,children:`Traces`}),(0,m.jsx)(Vu,{to:`/chat`,children:`Chat`}),(0,m.jsx)(`span`,{className:`ml-auto`,children:(0,m.jsx)(Va,{})})]})}),(0,m.jsx)(Ha,{}),(0,m.jsx)(`main`,{className:`mx-auto max-w-7xl px-6 py-8`,children:(0,m.jsx)(Sa,{})}),(0,m.jsx)(Vc,{})]})}),Uu=la({getParentRoute:()=>Hu,path:`/`,validateSearch:e=>({window:zl(e.window),service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0}),component:eu});function Wu(e){let t=e=>typeof e==`string`&&e.trim()?e.trim():void 0,n=Number(e.minDurationMs);return{service:t(e.service),operation:t(e.operation),minDurationMs:Number.isFinite(n)&&n>0?n:void 0,hasError:e.hasError===!0||e.hasError===`true`||void 0}}var Gu=la({getParentRoute:()=>Hu,path:`/traces`,validateSearch:Wu,component:Bu}),Ku=la({getParentRoute:()=>Hu,path:`/traces/$traceId`,component:Au}),qu=la({getParentRoute:()=>Hu,path:`/errors`,validateSearch:e=>({window:zl(e.window),service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0}),component:iu}),Ju=la({getParentRoute:()=>Hu,path:`/operation`,validateSearch:e=>({name:typeof e.name==`string`?e.name:``,service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0,window:zl(e.window)}),component:Su}),Yu=la({getParentRoute:()=>Hu,path:`/chat`,validateSearch:e=>({ask:typeof e.ask==`string`&&e.ask.trim()?e.ask.trim():void 0}),component:Il}),Xu=Oa({routeTree:Hu.addChildren([Uu,qu,Gu,Ku,Ju,Yu])}),Zu=new Ue;(0,La.createRoot)(document.getElementById(`root`)).render((0,m.jsx)(p.StrictMode,{children:(0,m.jsx)(_,{client:Zu,children:(0,m.jsx)(ja,{router:Xu})})}));
17
+ `)}function Ml(e){return e.split(/(\*\*[^*\n]+\*\*|`[^`\n]+`)/g).map((e,t)=>e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>4?(0,m.jsx)(`strong`,{children:e.slice(2,-2)},t):e.startsWith("`")&&e.endsWith("`")&&e.length>2?(0,m.jsx)(`code`,{className:`rounded bg-muted px-1 font-mono text-[0.85em]`,children:e.slice(1,-1)},t):(0,m.jsx)(p.Fragment,{children:e},t))}var Nl=[`Checkout is slow. What's causing it and which deployment introduced it?`,`There are 500 errors on product pages. Which operation is failing and why?`,`The product catalog is slower than expected but no single span stands out. What is wrong?`],Pl=oa(`/chat`),Fl=e=>e.type===`report`||e.type===`error`;function Il(){let e=nt({queryKey:[`chat-info`],queryFn:Ba.chatInfo}),t=e.data?.enabled??!1,[n,r]=(0,p.useState)([]),[i,a]=(0,p.useState)(``),[o,s]=(0,p.useState)(),c=n.some(e=>e.running&&!e.proactive),l=(0,p.useRef)(c);l.current=c;let u=(0,p.useRef)(t);u.current=t,(0,p.useEffect)(()=>{let e=0,t=new Map,n=new EventSource(`/api/chat/events`);return n.onmessage=n=>{let{seq:i,turnId:a,event:o}=JSON.parse(n.data);if(i<=e)return;e=i,o.type===`status`&&t.set(a,o.sessionId),r(e=>{let t=e.find(e=>e.id===a),n=t??{id:a,question:o.type===`anomaly`?Gc(o.anomaly):`Anomaly`,events:[],running:u.current,proactive:!0},r={...n,events:[...n.events,o],running:n.running&&!Fl(o)};return t?e.map(e=>e.id===a?r:e):[...e,r]});let c=t.get(a);o.type===`report`&&c&&!l.current&&s(c)},()=>n.close()},[]);async function d(e){let t=`q-${Date.now()}`,n=e=>r(n=>n.map(n=>n.id===t?e(n):n));r(n=>[...n,{id:t,question:e,events:[],running:!0}]),a(``);try{await Ba.ask(e,o,e=>{e.type===`status`&&s(e.sessionId),n(t=>({...t,events:[...t.events,e]}))})}catch(e){n(t=>({...t,events:[...t.events,{type:`error`,message:e instanceof Error?e.message:String(e)}]}))}finally{n(e=>({...e,running:!1}))}}let{ask:f}=Pl.useSearch(),h=Ui({from:`/chat`}),g=(0,p.useRef)(void 0);(0,p.useEffect)(()=>{f&&t&&g.current!==f&&(g.current=f,h({search:{},replace:!0}),d(f))},[f,t]);function _(){r([]),s(void 0)}function v(e){e.preventDefault(),i.trim()&&!c&&d(i.trim())}let y=n.map(e=>(0,m.jsx)(Ll,{turn:e},e.id));return e.data&&!e.data.enabled?(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4`,children:[(0,m.jsx)(Xc,{"data-testid":`chat-disabled`,children:(0,m.jsxs)($c,{className:`space-y-2 text-sm`,children:[(0,m.jsx)(`p`,{className:`font-medium`,children:`Chat is disabled`}),(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:e.data.reason})]})}),y]}):(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-6`,children:[(0,m.jsxs)(sl,{title:`Ask the agents`,subtitle:`They read your traces with tools — every fact comes from the data.`,children:[e.data?.enabled&&(0,m.jsx)(Uc,{variant:e.data.mode===`mock`?`outline`:`secondary`,className:`font-mono`,"data-testid":`chat-mode`,children:e.data.mode===`mock`?`MOCK — no real model`:`REAL model`}),n.length>0&&(0,m.jsx)(Mc,{type:`button`,variant:`ghost`,size:`sm`,onClick:_,disabled:c,children:`New chat`})]}),n.length===0&&(0,m.jsx)(`div`,{className:`flex flex-col items-start gap-2`,children:Nl.map(e=>(0,m.jsx)(Mc,{type:`button`,variant:`outline`,size:`sm`,className:`h-auto whitespace-normal py-2 text-left font-normal`,onClick:()=>void d(e),disabled:c,children:e},e))}),y,(0,m.jsxs)(`form`,{onSubmit:v,className:`flex gap-2`,children:[(0,m.jsx)(ol,{"aria-label":`Question`,placeholder:`Why is checkout slow?`,value:i,onChange:e=>a(e.target.value),disabled:c}),(0,m.jsx)(Mc,{type:`submit`,disabled:c||!i.trim(),children:c?`Investigating…`:`Ask`})]})]})}function Ll({turn:e}){let t=e.events.find(e=>e.type===`anomaly`),n=e.events.filter(e=>e.type===`step`),r=e.events.flatMap(e=>e.type===`card`?[e.card]:[]),i=e.events.find(e=>e.type===`report`),a=e.events.find(e=>e.type===`error`),o=n.length>0||r.length>0||i||a||e.running;return(0,m.jsxs)(`div`,{className:`space-y-2`,"data-testid":`chat-turn`,"data-proactive":e.proactive?`true`:void 0,children:[t?(0,m.jsx)(qc,{anomaly:t.anomaly}):(0,m.jsx)(`div`,{className:`ml-auto w-fit max-w-[80%] rounded-2xl rounded-br-sm bg-primary px-3.5 py-2 text-sm text-primary-foreground`,children:e.question}),o&&(0,m.jsx)(Xc,{children:(0,m.jsxs)($c,{className:`space-y-3 text-sm`,children:[(0,m.jsxs)(`ol`,{className:`space-y-1 font-mono text-xs text-muted-foreground`,"data-testid":`chat-steps`,children:[n.map((e,t)=>(0,m.jsxs)(`li`,{children:[(0,m.jsxs)(`span`,{className:e.agent===`orchestrator`?`text-foreground`:`pl-4`,children:[e.agent,` → `,e.tool]}),Object.keys(e.args).length>0&&(0,m.jsx)(`span`,{className:`ml-1 opacity-70`,children:JSON.stringify(e.args).slice(0,120)})]},t)),e.running&&(0,m.jsx)(`li`,{className:`animate-pulse`,children:e.proactive?`agents are investigating on their own…`:`working…`})]}),r.length>0&&(0,m.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,"data-testid":`chat-cards`,children:r.map((e,t)=>(0,m.jsx)(al,{card:e},t))}),i&&(0,m.jsx)(`p`,{className:`whitespace-pre-wrap leading-relaxed [overflow-wrap:anywhere]`,"data-testid":`chat-report`,children:Ml(i.text)}),i&&(0,m.jsx)(`div`,{className:`flex justify-end`,children:(0,m.jsx)(Yc,{build:()=>jl(e.question,i.text,r)})}),a&&(0,m.jsx)(`p`,{className:`text-destructive`,"data-testid":`chat-error`,children:a.message})]})})]})}var Rl={"5m":3e5,"15m":9e5,"1h":36e5,"24h":864e5},zl=e=>typeof e==`string`&&e in Rl?e:void 0;function Bl({value:e,onChange:t}){return(0,m.jsx)(`div`,{className:`flex overflow-hidden rounded-md border`,role:`group`,"aria-label":`Time window`,children:Object.keys(Rl).map(n=>(0,m.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>t(n===`15m`?void 0:n),className:`border-l px-3 py-1 font-mono text-xs text-muted-foreground uppercase first:border-l-0 hover:text-foreground aria-pressed:bg-muted aria-pressed:text-foreground`,children:n},n))})}var Vl=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`});function Hl({series:e}){let t=Math.max(1,...e.map(e=>e.ok+e.clientErrors+e.serverErrors));return(0,m.jsx)(`div`,{className:`flex h-40 items-end gap-1`,role:`img`,"aria-label":`Requests over time`,children:e.map(e=>{let n=e.ok+e.clientErrors+e.serverErrors;return(0,m.jsxs)(`div`,{className:`flex h-full flex-1 flex-col justify-end`,title:`${Vl(e.startMs)} · ${n} requests · ${e.clientErrors} 4xx · ${e.serverErrors} 5xx`,"data-testid":`requests-bucket`,children:[(0,m.jsx)(Ul,{value:e.serverErrors,max:t,tone:`bg-destructive`}),(0,m.jsx)(Ul,{value:e.clientErrors,max:t,tone:`bg-warning`}),(0,m.jsx)(Ul,{value:e.ok,max:t,tone:`bg-foreground/25`}),n===0&&(0,m.jsx)(`span`,{className:`h-px bg-foreground/10`})]},e.startMs)})})}function Ul({value:e,max:t,tone:n}){return e===0?null:(0,m.jsx)(`span`,{className:`block min-h-0.5 rounded-[2px] ${n}`,style:{height:`${e/t*100}%`}})}function Wl({series:e}){let t=Math.max(1,...e.map(e=>e.p95Ms??0))*1.15,n=t=>(t+.5)/e.length*100,r=e=>100-e/t*100,i=[];e.forEach((e,t)=>{if(e.p95Ms===null||e.avgMs===null)return i.push([]);i.length===0&&i.push([]),i[i.length-1].push({i:t,avg:e.avgMs,p95:e.p95Ms})});let a=i.filter(e=>e.length>0);return(0,m.jsxs)(`div`,{className:`relative h-40`,children:[(0,m.jsxs)(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,className:`h-full w-full overflow-visible`,role:`img`,"aria-label":`Duration over time`,children:[[25,50,75].map(e=>(0,m.jsx)(`line`,{x1:`0`,x2:`100`,y1:e,y2:e,className:`stroke-foreground/10`,strokeDasharray:`1 1.5`,vectorEffect:`non-scaling-stroke`},e)),a.map(t=>{let i=t.map(e=>`${n(e.i)},${r(e.p95)}`),a=t.length===1?[`${n(t[0].i)-50/e.length},${r(t[0].p95)}`,`${n(t[0].i)+50/e.length},${r(t[0].p95)}`]:i,o=a[0].split(`,`)[0],s=a[a.length-1].split(`,`)[0];return(0,m.jsxs)(`g`,{children:[(0,m.jsx)(`polygon`,{points:`${o},100 ${a.join(` `)} ${s},100`,className:`fill-chart-1/15`}),(0,m.jsx)(`polyline`,{points:a.join(` `),fill:`none`,className:`stroke-chart-1`,strokeWidth:`1.5`,vectorEffect:`non-scaling-stroke`}),(0,m.jsx)(`polyline`,{points:t.length===1?a.map(e=>`${e.split(`,`)[0]},${r(t[0].avg)}`).join(` `):t.map(e=>`${n(e.i)},${r(e.avg)}`).join(` `),fill:`none`,className:`stroke-foreground/50`,strokeWidth:`1`,strokeDasharray:`2 2`,vectorEffect:`non-scaling-stroke`})]},t[0].i)})]}),(0,m.jsx)(`span`,{className:`absolute top-0 left-0 font-mono text-[11px] text-muted-foreground`,children:H(t)})]})}function Gl({rows:e,value:t,meta:n,empty:r}){return e.length===0?(0,m.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:r}):(0,m.jsx)(`ul`,{className:`-my-1 divide-y`,children:e.map(e=>{let[r,...i]=e.operation.split(` `),a=i.length>0&&/^[A-Z]+$/.test(r);return(0,m.jsx)(`li`,{children:(0,m.jsxs)(R,{to:`/operation`,search:{name:e.operation,service:e.service},className:`group flex items-center gap-3 py-2.5`,"data-testid":`route-row`,children:[a&&(0,m.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] tracking-wider text-muted-foreground`,children:r}),(0,m.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-sm group-hover:text-signal`,children:a?i.join(` `):e.operation}),(0,m.jsxs)(`span`,{className:`text-right`,children:[(0,m.jsx)(`span`,{className:`block font-mono text-sm tabular-nums`,children:t(e)}),(0,m.jsx)(`span`,{className:`block font-mono text-[11px] text-muted-foreground`,children:n(e)})]})]})},`${e.service}:${e.operation}`)})})}function Kl({title:e,count:t,change:n,children:r,aside:i,testId:a}){return(0,m.jsxs)(Xc,{className:`gap-0 py-0`,"data-testid":a,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b px-5 py-3.5`,children:[(0,m.jsx)(`h2`,{className:`font-medium`,children:e}),t!==void 0&&(0,m.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 font-mono text-xs tabular-nums`,children:t}),n,i&&(0,m.jsx)(`div`,{className:`ml-auto flex items-center gap-3 font-mono text-xs text-muted-foreground`,children:i})]}),(0,m.jsx)(`div`,{className:`px-5 py-4`,children:r})]})}function ql({value:e,upIsBad:t}){if(e===null)return null;let n=Math.round(e*100),r=n>0,i=n===0||t===void 0?`text-muted-foreground`:r===t?`text-destructive`:`text-signal`,a=r?po:uo;return(0,m.jsxs)(`span`,{className:`flex items-center gap-1 text-xs ${i}`,"data-testid":`change`,children:[n!==0&&(0,m.jsx)(a,{className:`size-3.5`,"aria-hidden":!0}),r?`+`:``,n,`% `,(0,m.jsx)(`span`,{className:`text-muted-foreground`,children:`since last period`})]})}function Jl({tone:e,children:t}){return(0,m.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`h-3 w-0.5 rounded-full ${e}`,"aria-hidden":!0}),t]})}function Yl({label:e,children:t}){return(0,m.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e,(0,m.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-foreground tabular-nums`,children:t})]})}function Xl({fromMs:e,toMs:t}){let n=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return(0,m.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:n(e)}),(0,m.jsx)(`span`,{children:n(t)})]})}var Zl=2e3,Ql=oa(`/`),$l=e=>`${Math.round(e*100)}%`;function eu(){let{window:e=`15m`,service:t}=Ql.useSearch(),n=Ui({from:`/`}),r=nt({queryKey:[`overview`,e,t],queryFn:()=>Ba.overview(Rl[e],t),refetchInterval:Zl}),i=nt({queryKey:[`services`],queryFn:Ba.services,refetchInterval:Zl}),a=r.data;return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(sl,{title:`Overview`,subtitle:`Your app's requests, latency and errors — compared with the period before.`,children:[(0,m.jsxs)(`select`,{"aria-label":`Service`,className:`h-8 rounded-md border bg-card px-2 text-sm`,value:t??``,onChange:e=>n({search:t=>({...t,service:e.target.value||void 0}),replace:!0}),children:[(0,m.jsx)(`option`,{value:``,children:`All services`}),i.data?.filter(e=>!e.name.endsWith(`-browser`)).map(e=>(0,m.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,m.jsx)(Bl,{value:e,onChange:e=>n({search:t=>({...t,window:e}),replace:!0})})]}),a?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Requests`,testId:`panel-requests`,count:a.requests.total,change:(0,m.jsx)(ql,{value:a.requests.change}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`span`,{className:`tabular-nums`,children:[a.requests.perSecond,`/s`]}),(0,m.jsx)(Jl,{tone:`bg-foreground/40`,children:`2/3xx`}),(0,m.jsx)(Jl,{tone:`bg-warning`,children:`4xx`}),(0,m.jsx)(Jl,{tone:`bg-destructive`,children:`5xx`})]}),children:[(0,m.jsx)(Hl,{series:a.requests.series}),(0,m.jsx)(Xl,{fromMs:a.fromMs,toMs:a.toMs})]}),(0,m.jsxs)(Kl,{title:`Duration`,testId:`panel-duration`,change:(0,m.jsx)(ql,{value:a.duration.change,upIsBad:!0}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Yl,{label:`AVG`,children:a.duration.avgMs===null?`—`:H(a.duration.avgMs)}),(0,m.jsx)(Yl,{label:`P95`,children:a.duration.p95Ms===null?`—`:H(a.duration.p95Ms)})]}),children:[(0,m.jsx)(Wl,{series:a.duration.series}),(0,m.jsx)(Xl,{fromMs:a.fromMs,toMs:a.toMs})]})]}),(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,m.jsxs)(Kl,{title:`Errors`,testId:`panel-errors`,count:a.errors.count,change:(0,m.jsx)(ql,{value:a.errors.change,upIsBad:!0}),aside:(0,m.jsx)(R,{to:`/errors`,search:{window:e===`15m`?void 0:e,service:t},className:`hover:text-signal`,children:`view all →`}),children:[(0,m.jsxs)(`div`,{className:`space-y-1`,children:[(0,m.jsx)(`div`,{className:`font-mono text-4xl font-medium tabular-nums ${a.errors.count>0?`text-destructive`:``}`,"data-testid":`error-rate`,children:$l(a.errors.rate)}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`of requests failed with 5xx`})]}),(0,m.jsx)(`div`,{className:`mt-4 flex h-12 items-end gap-0.5`,"aria-hidden":!0,children:a.requests.series.map(e=>{let t=Math.max(1,...a.requests.series.map(e=>e.serverErrors));return(0,m.jsx)(`span`,{className:`flex-1 rounded-[2px] ${e.serverErrors?`bg-destructive`:`bg-foreground/10`}`,style:{height:e.serverErrors?`${e.serverErrors/t*100}%`:`2px`}},e.startMs)})})]}),(0,m.jsx)(Kl,{title:`Slowest`,testId:`panel-slowest`,aside:`P95`,children:(0,m.jsx)(Gl,{rows:a.slowest,value:e=>H(e.p95Ms),meta:e=>`${e.count} ${e.count===1?`call`:`calls`}${e.errorRate>0?` · ${$l(e.errorRate)} errors`:``}${e.coldOnly?` · cold start only`:``}`,empty:`No requests in this window.`})}),(0,m.jsx)(Kl,{title:`Busiest`,testId:`panel-busiest`,aside:`CALLS`,children:(0,m.jsx)(Gl,{rows:a.busiest,value:e=>String(e.count),meta:e=>`${$l(e.share)} of requests`,empty:`No requests in this window.`})})]})]}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:r.isError?`The observer is not reachable.`:`Loading…`})]})}var tu=2e3,nu=oa(`/errors`);function ru(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)} min ago`:`${Math.round(t/3600)} h ago`}function iu(){let{window:e=`15m`,service:t}=nu.useSearch(),n=Ui({from:`/errors`}),r=nt({queryKey:[`defects`,e,t],queryFn:()=>Ba.defects(Rl[e],t),refetchInterval:tu});return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsx)(sl,{title:`Errors`,count:r.data?.length,subtitle:`Failures grouped by where they start and what they say — one entry per defect, not per request.`,children:(0,m.jsx)(Bl,{value:e,onChange:e=>n({search:t=>({...t,window:e}),replace:!0})})}),r.data?r.data.length===0?(0,m.jsxs)(Xc,{className:`items-center py-12 text-center`,"data-testid":`errors-empty`,children:[(0,m.jsxs)(`p`,{className:`font-medium`,children:[`No errors in the last `,e]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`A defect shows up here as soon as a span fails.`})]}):(0,m.jsx)(`div`,{className:`space-y-4`,children:r.data.map(e=>(0,m.jsx)(au,{defect:e},e.id))}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:r.isError?`The observer is not reachable.`:`Loading…`})]})}function au({defect:e}){let t=Ui(),n=Math.max(1,...e.series),r=ul(e);return(0,m.jsxs)(Xc,{className:`gap-0 py-0`,"data-testid":`defect`,"data-new":e.isNew?`true`:void 0,children:[(0,m.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 px-5 py-4 lg:grid-cols-[minmax(0,1fr)_14rem]`,children:[(0,m.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.isNew?(0,m.jsxs)(`span`,{className:`rounded-md bg-warning/15 px-1.5 py-0.5 font-mono text-[11px] tracking-wider text-warning uppercase`,"data-testid":`defect-new`,children:[`new in `,e.firstSeenVersion]}):e.versions.length>0&&(0,m.jsxs)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:[`seen in `,e.versions.join(`, `)]}),(0,m.jsx)(`span`,{className:`rounded-md border px-1.5 py-0.5 font-mono text-[11px] tracking-wider uppercase ${e.source===`browser`?`border-signal/40 text-signal`:`text-muted-foreground`}`,"data-testid":`defect-source`,children:e.source}),e.type&&(0,m.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.type})]}),(0,m.jsx)(`p`,{className:`font-mono text-sm break-words whitespace-pre-wrap text-destructive`,"data-testid":`defect-message`,children:e.message}),(0,m.jsxs)(`p`,{className:`text-sm text-muted-foreground`,"data-testid":`defect-where`,children:[e.category===`code`?(0,m.jsxs)(m.Fragment,{children:[`in`,` `,(0,m.jsx)(R,{to:`/operation`,search:{name:e.spanName,service:e.service},className:`font-mono text-foreground underline decoration-dotted underline-offset-4 hover:text-signal`,children:e.operation})]}):(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.operation}),e.pages.length>0&&(0,m.jsxs)(m.Fragment,{children:[` `,`· on`,` `,e.pages.map((e,t)=>(0,m.jsxs)(`span`,{children:[t>0&&`, `,(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.path})]},e.path))]}),r.length>0&&(0,m.jsxs)(m.Fragment,{children:[` `,`· fails`,` `,r.map((e,t)=>(0,m.jsxs)(`span`,{children:[t>0&&`, `,e.spanName===e.operation?(0,m.jsx)(R,{to:`/operation`,search:{name:e.spanName,service:e.service},className:`font-mono text-foreground hover:text-signal`,children:e.operation}):(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.operation})]},`${e.service}:${e.spanName}:${e.operation}`))]})]})]}),(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,m.jsx)(`span`,{className:`font-mono text-2xl font-medium tabular-nums`,"data-testid":`defect-count`,children:e.count}),(0,m.jsx)(`span`,{className:`font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:e.count===1?`occurrence`:`occurrences`})]}),(0,m.jsx)(`div`,{className:`flex h-8 items-end gap-0.5`,"aria-hidden":!0,children:e.series.map((e,t)=>(0,m.jsx)(`span`,{className:`flex-1 rounded-[2px] ${e?`bg-destructive`:`bg-foreground/10`}`,style:{height:e?`${Math.max(e/n*100,12)}%`:`2px`}},t))})]})]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-2 border-t px-5 py-2.5 font-mono text-xs text-muted-foreground`,children:[(0,m.jsxs)(`span`,{children:[`first seen `,ru(e.firstSeenMs)]}),(0,m.jsxs)(`span`,{children:[`last seen `,ru(e.lastSeenMs)]}),(0,m.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`traces`,e.exampleTraceIds.map(e=>(0,m.jsxs)(R,{to:`/traces/$traceId`,params:{traceId:e},className:`text-signal underline-offset-2 hover:underline`,children:[e.slice(0,6),`…`,e.slice(-4)]},e))]}),(0,m.jsx)(Yc,{build:()=>kl(e),className:`ml-auto font-sans`}),(0,m.jsx)(Mc,{type:`button`,size:`sm`,variant:`outline`,className:`font-sans`,"data-testid":`defect-investigate`,onClick:()=>void t({to:`/chat`,search:{ask:fl(e)}}),children:`Investigate`})]})]})}function W(e,t,n=.06){let r=[{label:`median`,ms:e.p50Ms},{label:`p95`,ms:e.p95Ms},{label:`p99`,ms:e.p99Ms}],i=[];for(let e of r)(i.length===0||(e.ms-i[i.length-1].ms)/t>n)&&i.push(e);return i}var ou=e=>`${Math.round(e*100)}%`;function su({histogram:e,speeds:t}){let n=e.bins[e.bins.length-1].toMs||1,r=Math.max(1,...e.bins.map(e=>e.count)),i=W(e,n);return(0,m.jsxs)(`div`,{"data-testid":`latency-histogram`,children:[(0,m.jsxs)(`div`,{className:`relative mt-6 h-40`,children:[i.map(e=>(0,m.jsx)(`div`,{className:`absolute -top-6 bottom-0 border-l border-dashed border-foreground/30`,style:{left:`${Math.min(e.ms/n*100,100)}%`},children:(0,m.jsxs)(`span`,{className:`absolute top-0 font-mono text-[10px] tracking-wider whitespace-nowrap text-muted-foreground uppercase ${e.ms/n>.75?`right-1.5`:`left-1.5`}`,children:[e.label,` `,H(e.ms)]})},e.label)),(0,m.jsx)(`div`,{className:`flex h-full items-end gap-0.5`,role:`img`,"aria-label":`Latency distribution`,children:e.bins.map((t,n)=>(0,m.jsx)(`span`,{"data-testid":`histogram-bin`,title:`${H(t.fromMs)} – ${n===e.bins.length-1&&e.overflow?`and slower`:H(t.toMs)} · ${t.count} calls (${ou(t.count/e.total)})`,className:`flex-1 rounded-t-[2px] ${t.count?`bg-chart-1/70`:`bg-foreground/10`}`,style:{height:t.count?`${Math.max(t.count/r*100,2)}%`:`1px`}},n))})]}),(0,m.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:`0`}),(0,m.jsx)(`span`,{children:H(n/2)}),(0,m.jsxs)(`span`,{children:[e.overflow?`≥ `:``,H(n)]})]}),t&&(0,m.jsxs)(`p`,{className:`mt-3 font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,"data-testid":`two-speeds`,children:[(0,m.jsx)(`span`,{className:`text-warning`,children:`Two speeds`}),` · `,H(t[0].medianMs),` (`,ou(t[0].share),`) and `,H(t[1].medianMs),` (`,ou(t[1].share),`) ·`,` `,Math.round(t[1].medianMs/t[0].medianMs),`× apart`]})]})}function cu({label:e,children:t}){return(0,m.jsxs)(`div`,{className:`flex items-baseline gap-2 py-1 text-xs`,children:[(0,m.jsxs)(`dt`,{className:`flex min-w-0 flex-1 items-baseline gap-2 text-muted-foreground`,children:[(0,m.jsx)(`span`,{className:`shrink-0`,children:e}),(0,m.jsx)(`span`,{"aria-hidden":!0,className:`min-w-4 flex-1 border-b border-dotted border-foreground/20`})]}),(0,m.jsx)(`dd`,{className:`min-w-0 max-w-[70%] break-all text-right font-mono`,children:t})]})}var lu=`The first request of this route after the server started. In next dev it includes compiling the route, so it is slower than the rest — the agents leave it out of latency statistics.`;function uu(){return(0,m.jsx)(Uc,{variant:`outline`,title:lu,className:`ml-2 cursor-help font-normal text-muted-foreground`,children:`cold start`})}function du({className:e,...t}){return(0,m.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,m.jsx)(`table`,{"data-slot":`table`,className:ds(`w-full caption-bottom text-sm`,e),...t})})}function fu({className:e,...t}){return(0,m.jsx)(`thead`,{"data-slot":`table-header`,className:ds(`[&_tr]:border-b`,e),...t})}function pu({className:e,...t}){return(0,m.jsx)(`tbody`,{"data-slot":`table-body`,className:ds(`[&_tr:last-child]:border-0`,e),...t})}function mu({className:e,...t}){return(0,m.jsx)(`tr`,{"data-slot":`table-row`,className:ds(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function hu({className:e,...t}){return(0,m.jsx)(`th`,{"data-slot":`table-head`,className:ds(`h-10 px-2 text-left align-middle font-mono text-[11px] font-normal tracking-wider whitespace-nowrap text-muted-foreground uppercase [&:has([role=checkbox])]:pr-0`,e),...t})}function gu({className:e,...t}){return(0,m.jsx)(`td`,{"data-slot":`table-cell`,className:ds(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}function _u({traces:e,empty:t}){return(0,m.jsx)(Xc,{className:`py-0`,children:(0,m.jsxs)(du,{children:[(0,m.jsx)(fu,{children:(0,m.jsxs)(mu,{children:[(0,m.jsx)(hu,{className:`pl-4`,children:`Trace`}),(0,m.jsx)(hu,{children:`Services`}),(0,m.jsx)(hu,{className:`text-right`,children:`Duration`}),(0,m.jsx)(hu,{className:`text-right`,children:`Spans`}),(0,m.jsx)(hu,{className:`text-right`,children:`Errors`}),(0,m.jsx)(hu,{className:`pr-4 text-right`,children:`Started`})]})}),(0,m.jsxs)(pu,{children:[e?.map(e=>(0,m.jsxs)(mu,{"data-testid":`trace-row`,children:[(0,m.jsxs)(gu,{className:`pl-4`,children:[(0,m.jsx)(R,{to:`/traces/$traceId`,params:{traceId:e.traceId},className:`font-medium hover:underline`,children:e.rootName}),e.coldStart&&(0,m.jsx)(uu,{}),(0,m.jsx)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:e.traceId.slice(0,16)})]}),(0,m.jsx)(gu,{className:`space-x-1`,children:e.services.map(e=>(0,m.jsx)(Uc,{variant:`secondary`,children:e},e))}),(0,m.jsx)(gu,{className:`text-right font-mono tabular-nums`,children:H(e.durationMs)}),(0,m.jsx)(gu,{className:`text-right font-mono text-muted-foreground tabular-nums`,children:e.spanCount}),(0,m.jsx)(gu,{className:`text-right`,children:e.errorCount>0?(0,m.jsx)(Uc,{variant:`destructive`,children:e.errorCount}):`—`}),(0,m.jsx)(gu,{className:`pr-4 text-right font-mono text-xs text-muted-foreground tabular-nums`,children:new Date(e.startTimeMs).toLocaleTimeString()})]},e.traceId)),e?.length===0&&(0,m.jsx)(mu,{children:(0,m.jsx)(gu,{colSpan:6,className:`py-10 text-center text-muted-foreground`,children:t})})]})]})})}var vu=2e3,yu=oa(`/operation`),bu=e=>`${Math.round(e*100)}%`,G=e=>e==null?`—`:H(e);function xu(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)} min ago`:`${Math.round(t/3600)} h ago`}function Su(){let{name:e,service:t,window:n=`15m`}=yu.useSearch(),r=Ui({from:`/operation`}),i=nt({queryKey:[`operation`,e,t,n],queryFn:()=>Ba.operation(e,Rl[n],t),refetchInterval:vu,enabled:e!==``}),a=i.data,o=a?.overview.fromMs,s=nt({queryKey:[`operation-traces`,e,t,o],queryFn:()=>Ba.traces({operation:e,exactOperation:!0,service:t,fromMs:o,limit:50}),enabled:e!==``&&o!==void 0,placeholderData:e=>e});if(e===``)return(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:`No operation selected — pick one on the Overview.`});let c=a?.overview;return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(R,{to:`/`,className:`font-mono text-xs text-muted-foreground hover:text-foreground`,children:`← overview`}),(0,m.jsx)(sl,{title:(0,m.jsx)(`span`,{className:`font-mono text-xl`,children:e}),subtitle:a?.service?`One operation of ${a.service} — its traffic, latency and every call.`:`One operation — its traffic, latency and every call.`,children:(0,m.jsx)(Bl,{value:n,onChange:e=>r({search:t=>({...t,window:e}),replace:!0})})})]}),!a||!c?(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:i.isError?`The observer is not reachable.`:`Loading…`}):c.requests.total===0?(0,m.jsxs)(`p`,{className:`text-muted-foreground`,"data-testid":`operation-empty`,children:[`No calls of this operation in the last `,n,`. Try a longer window.`]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Details`,testId:`panel-details`,children:[(0,m.jsxs)(`dl`,{children:[(0,m.jsx)(cu,{label:`Calls`,children:c.requests.total}),(0,m.jsx)(cu,{label:`Avg duration`,children:G(c.duration.avgMs)}),(0,m.jsx)(cu,{label:`Median`,children:G(a.histogram?.p50Ms)}),(0,m.jsx)(cu,{label:`95th percentile`,children:G(c.duration.p95Ms)}),(0,m.jsx)(cu,{label:`Errors`,children:(0,m.jsxs)(`span`,{className:c.errors.count?`text-destructive`:``,children:[c.errors.count,` (`,bu(c.errors.rate),`)`]})}),a.coldStarts>0&&(0,m.jsx)(cu,{label:`Cold starts (not in latency)`,children:a.coldStarts}),(0,m.jsx)(cu,{label:`Last call`,children:a.lastSeenMs===null?`—`:xu(a.lastSeenMs)})]}),a.versions.length>1&&(0,m.jsxs)(`table`,{className:`mt-4 w-full font-mono text-xs`,"data-testid":`versions`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{className:`text-left text-[11px] tracking-wider text-muted-foreground uppercase`,children:[(0,m.jsx)(`th`,{className:`py-1 font-normal`,children:`Version`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Calls`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Median`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`P95`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Errors`})]})}),(0,m.jsx)(`tbody`,{children:a.versions.map(e=>(0,m.jsxs)(`tr`,{className:`border-t tabular-nums`,children:[(0,m.jsx)(`td`,{className:`py-1.5`,children:e.version}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:e.count}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:H(e.p50Ms)}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:H(e.p95Ms)}),(0,m.jsx)(`td`,{className:`py-1.5 text-right ${e.errorRate>0?`text-destructive`:``}`,children:bu(e.errorRate)})]},e.version))})]})]}),(0,m.jsx)(Kl,{title:`Latency distribution`,testId:`panel-distribution`,aside:a.histogram?`${a.histogram.total} calls`:void 0,children:a.histogram?(0,m.jsx)(su,{histogram:a.histogram,speeds:a.speeds}):(0,m.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`Only cold starts so far — no representative latency yet.`})})]}),(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Calls`,testId:`panel-requests`,count:c.requests.total,change:(0,m.jsx)(ql,{value:c.requests.change}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Jl,{tone:`bg-foreground/40`,children:`ok`}),(0,m.jsx)(Jl,{tone:`bg-warning`,children:`4xx`}),(0,m.jsx)(Jl,{tone:`bg-destructive`,children:`failed`})]}),children:[(0,m.jsx)(Hl,{series:c.requests.series}),(0,m.jsx)(Xl,{fromMs:c.fromMs,toMs:c.toMs})]}),(0,m.jsxs)(Kl,{title:`Duration`,testId:`panel-duration`,change:(0,m.jsx)(ql,{value:c.duration.change,upIsBad:!0}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Yl,{label:`AVG`,children:G(c.duration.avgMs)}),(0,m.jsx)(Yl,{label:`P95`,children:G(c.duration.p95Ms)})]}),children:[(0,m.jsx)(Wl,{series:c.duration.series}),(0,m.jsx)(Xl,{fromMs:c.fromMs,toMs:c.toMs})]})]}),(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(`h2`,{className:`font-medium`,children:`Traces with this operation`}),(0,m.jsx)(_u,{traces:s.data,empty:`No traces in this window.`})]})]})]})}var Cu=/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/,wu=e=>e.kind===`client`&&Cu.test(e.name);function Tu(e){if(!wu(e))return;let t=e.attributes[`url.full`]??e.attributes[`http.url`];if(typeof t==`string`)try{return{method:e.name,pathname:new URL(t).pathname}}catch{return}}function Eu(e){let t=Tu(e);return t?`${t.method} ${t.pathname}`:e.name}var Du=oa(`/traces/$traceId`),Ou=[`bg-chart-1`,`bg-chart-2`,`bg-chart-4`,`bg-chart-3`,`bg-chart-5`];function ku(e,t){return Ou[t.indexOf(e)%Ou.length]}function Au(){let{traceId:e}=Du.useParams(),t=nt({queryKey:[`trace`,e],queryFn:()=>Ba.trace(e)}),[n,r]=(0,p.useState)(null),i=(0,p.useMemo)(()=>Pc(t.data?.spans??[]),[t.data]),a=(0,p.useMemo)(()=>[...new Set(i.rows.map(e=>e.span.service))],[i]),o=i.rows.find(e=>e.span.spanId===n)?.span??i.rows[0]?.span,[s,c]=(0,p.useState)(!1),l=t.data?.spans,u=(0,p.useMemo)(()=>vl(l??[]),[l]),d=(0,p.useMemo)(()=>gl(l??[]),[l]),f=(0,p.useMemo)(()=>U(l??[]),[l]),h=(0,p.useMemo)(()=>_l(l??[]),[l]),g=nt({queryKey:[`trace-operation`,h?.service,h?.name,h?.startTimeMs],queryFn:()=>Ba.operation(h.name,Mu,h.service,h.startTimeMs+Mu/2),enabled:h!==void 0});return t.isError?(0,m.jsxs)(`p`,{className:`text-destructive`,children:[`Trace `,e,` not found.`]}):t.data?(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(R,{to:`/traces`,className:`font-mono text-xs text-muted-foreground hover:text-foreground`,children:`← traces`}),(0,m.jsx)(sl,{title:(0,m.jsxs)(m.Fragment,{children:[i.rows[0]?Eu(i.rows[0].span):``,t.data.spans.some(e=>e.coldStart)&&(0,m.jsx)(uu,{})]}),subtitle:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`text-foreground tabular-nums`,children:H(i.durationMs)}),` · `,i.rows.length,` spans · `,e]}),children:(0,m.jsx)(Yc,{build:()=>{let n=g.data?.histogram;return Ol({traceId:e,spans:t.data.spans,usual:n&&n.total>=ju?{p50Ms:n.p50Ms,p95Ms:n.p95Ms,calls:n.total}:void 0})}})})]}),h&&g.data?.histogram&&g.data.histogram.total>=ju&&(0,m.jsx)(Fu,{durationMs:h.durationMs,histogram:g.data.histogram,operation:h.name,service:h.service,coldStart:h.coldStart===!0}),(0,m.jsxs)(`div`,{className:`grid grid-cols-[1fr_380px] gap-4`,children:[(0,m.jsxs)(Xc,{className:`gap-0 self-start py-0`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b px-4 py-2.5`,children:[(0,m.jsx)(`button`,{type:`button`,"aria-pressed":s,"data-testid":`critical-path-toggle`,onClick:()=>c(e=>!e),className:`rounded-full border px-3 py-1 font-mono text-[11px] tracking-wider text-muted-foreground uppercase hover:text-foreground aria-pressed:border-warning/60 aria-pressed:bg-warning/10 aria-pressed:text-warning`,children:`Critical path`}),(0,m.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:s?`The spans that decided the duration — values show their own time.`:`Highlight the spans that decided the duration.`})]}),(0,m.jsx)(`div`,{role:`tree`,"aria-label":`Waterfall`,children:i.rows.map(({span:e,depth:t,offsetPct:n,widthPct:i})=>(0,m.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":e.spanId===o?.spanId,"data-span-name":e.name,"data-critical":u.has(e.spanId)?`true`:void 0,onClick:()=>r(e.spanId),className:`grid w-full grid-cols-[minmax(0,2fr)_minmax(0,3fr)_4.5rem] items-center gap-3 border-b px-4 py-2 text-left text-sm last:border-b-0 hover:bg-muted/50 aria-selected:bg-muted ${s&&!u.has(e.spanId)?`opacity-30`:``}`,children:[(0,m.jsxs)(`span`,{className:`truncate`,style:{paddingLeft:t*14},children:[(0,m.jsx)(`span`,{className:e.status===`error`?`font-medium text-destructive`:``,children:Eu(e)}),e.coldStart&&(0,m.jsx)(uu,{}),(0,m.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.service})]}),(0,m.jsx)(`span`,{className:`relative h-2.5`,children:(0,m.jsx)(`span`,{className:`absolute top-0 h-2.5 min-w-0.5 rounded-full opacity-80 ${e.status===`error`?`bg-destructive`:ku(e.service,a)}`,style:{left:`${n}%`,width:`${i}%`}})}),(0,m.jsx)(`span`,{className:`text-right font-mono text-xs tabular-nums ${s?`text-warning`:`text-muted-foreground`}`,children:H(s?d.get(e.spanId)??0:e.durationMs)})]},e.spanId))})]}),o&&(0,m.jsx)(Iu,{span:o,selfMs:d.get(o.spanId)})]}),(0,m.jsx)(Kl,{title:`Where the time went`,testId:`panel-self-time`,aside:`own time, without calls to others · % of all own time`,children:(0,m.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{className:`text-left font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:[(0,m.jsx)(`th`,{className:`pb-2 font-normal`,children:`Operation`}),(0,m.jsx)(`th`,{className:`w-1/4 pb-2 font-normal`,children:`Self %`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Self`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Total`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Calls`})]})}),(0,m.jsx)(`tbody`,{children:f.map(e=>(0,m.jsxs)(`tr`,{className:`border-t`,"data-testid":`self-time-row`,children:[(0,m.jsxs)(`td`,{className:`max-w-0 truncate py-2 pr-3 font-mono`,children:[(0,m.jsx)(R,{to:`/operation`,search:{name:e.name,service:e.service},className:`hover:text-signal`,children:e.name}),a.length>1&&(0,m.jsx)(`span`,{className:`ml-2 font-sans text-xs text-muted-foreground`,children:e.service})]}),(0,m.jsx)(`td`,{className:`py-2 pr-3`,children:(0,m.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(`span`,{className:`h-1.5 flex-1 rounded-full bg-muted`,children:(0,m.jsx)(`span`,{className:`block h-1.5 rounded-full bg-warning/80`,style:{width:`${e.selfShare*100}%`}})}),(0,m.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs text-muted-foreground tabular-nums`,children:[Math.round(e.selfShare*100),`%`]})]})}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono tabular-nums`,children:H(e.selfMs)}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono text-muted-foreground tabular-nums`,children:H(e.totalMs)}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono text-muted-foreground tabular-nums`,children:e.calls})]},`${e.service}:${e.name}`))})]})})]}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading…`})}var ju=5,Mu=36e5,Nu={slow:{text:`slower than 95% of the calls`,tone:`text-warning`,dot:`bg-warning`},typical:{text:`a typical call`,tone:`text-signal`,dot:`bg-signal`},fast:{text:`faster than half of the calls`,tone:`text-signal`,dot:`bg-signal`}},Pu={text:`a cold start`,tone:`text-muted-foreground`,dot:`bg-muted-foreground`};function Fu({durationMs:e,histogram:t,operation:n,service:r,coldStart:i}){let a=i?Pu:Nu[yl(e,t)],o=Math.max(t.p99Ms,e)*1.05||1,s=e=>`${Math.min(e/o*100,100)}%`;return(0,m.jsxs)(Kl,{title:`Compared to other calls`,testId:`panel-compared`,aside:(0,m.jsxs)(R,{to:`/operation`,search:{name:n,service:r},className:`hover:text-signal`,children:[t.total,` calls · the hour around this one →`]}),children:[(0,m.jsxs)(`div`,{className:`relative mt-5 mb-9 h-1.5 rounded-full bg-muted`,children:[[{label:`median`,ms:t.p50Ms},{label:`p95`,ms:t.p95Ms}].map(e=>(0,m.jsx)(`span`,{className:`absolute -top-5 h-8 border-l border-dashed border-foreground/30`,style:{left:s(e.ms)},children:(0,m.jsxs)(`span`,{className:`absolute -top-0.5 font-mono text-[10px] tracking-wider whitespace-nowrap text-muted-foreground uppercase ${e.ms/o>.75?`right-1.5`:`left-1.5`}`,children:[e.label,` `,H(e.ms)]})},e.label)),(0,m.jsx)(`span`,{className:`absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full ring-4 ring-background ${a.dot}`,style:{left:s(e)},"data-testid":`this-call`}),(0,m.jsxs)(`span`,{className:`absolute top-4 -translate-x-1/2 font-mono text-xs whitespace-nowrap ${a.tone}`,style:{left:`clamp(3rem, ${s(e)}, calc(100% - 3rem))`},children:[H(e),` · this call`]})]}),(0,m.jsxs)(`p`,{className:`text-sm`,"data-testid":`standing`,children:[(0,m.jsx)(`span`,{className:a.tone,children:a.text[0].toUpperCase()+a.text.slice(1)}),(0,m.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`— `,i?`it includes compiling the route, so it is not judged against the warm calls.`:`${(e/(t.p50Ms||1)).toFixed(1)}× the median.`]})]})]})}function Iu({span:e,selfMs:t}){let n=[[`service`,e.serviceVersion?`${e.service}@${e.serviceVersion}`:e.service],[`kind`,e.kind],[`duration`,H(e.durationMs)],...t===void 0?[]:[[`own time`,H(t)]],[`status`,e.statusMessage?`${e.status}: ${e.statusMessage}`:e.status],...Object.entries(e.attributes)];return(0,m.jsxs)(Xc,{className:`self-start`,"data-testid":`span-details`,children:[(0,m.jsxs)(Zc,{children:[(0,m.jsxs)(Qc,{className:`flex items-center gap-2 text-base`,children:[Eu(e),e.status===`error`&&(0,m.jsx)(Uc,{variant:`destructive`,children:`error`})]}),(0,m.jsx)(R,{to:`/operation`,search:{name:e.name,service:e.service},className:`font-mono text-xs text-signal underline-offset-2 hover:underline`,"data-testid":`operation-link`,children:`all calls of this operation →`})]}),(0,m.jsxs)($c,{className:`space-y-3`,children:[(0,m.jsx)(`dl`,{children:n.map(([e,t])=>(0,m.jsx)(cu,{label:e,children:typeof t==`string`?t:JSON.stringify(t)},e))}),e.events.map((e,t)=>(0,m.jsxs)(`div`,{className:`rounded-md bg-muted p-2 text-xs`,children:[(0,m.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,m.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:String(e.attributes[`exception.message`]??``)})]},t))]})]})}function Lu({className:e,size:t=`default`,...n}){return(0,m.jsx)(wc,{"data-slot":`switch`,"data-size":t,className:ds(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,m.jsx)(Ec,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}var Ru=2e3,zu=oa(`/traces`);function Bu(){let e=zu.useSearch(),t=Ui({from:`/traces`}),n=e=>t({search:t=>({...t,...e}),replace:!0}),r=nt({queryKey:[`traces`,e],queryFn:()=>Ba.traces(e),refetchInterval:Ru}),i=nt({queryKey:[`services`],queryFn:Ba.services,refetchInterval:Ru});return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsx)(sl,{title:`Traces`,count:r.data?.length,subtitle:`Every request your app made — server and browser, live.`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,m.jsxs)(`select`,{"aria-label":`Service`,className:`h-9 rounded-md border bg-card px-2 text-sm`,value:e.service??``,onChange:e=>n({service:e.target.value||void 0}),children:[(0,m.jsx)(`option`,{value:``,children:`All services`}),i.data?.map(e=>(0,m.jsxs)(`option`,{value:e.name,children:[e.name,e.versions.length?` (${e.versions.join(`, `)})`:``]},e.name))]}),(0,m.jsx)(ol,{"aria-label":`Operation`,className:`w-64`,placeholder:`Operation contains…`,defaultValue:e.operation??``,onChange:e=>n({operation:e.target.value||void 0})}),(0,m.jsx)(ol,{"aria-label":`Min duration (ms)`,className:`w-40`,type:`number`,min:0,placeholder:`Min ms`,defaultValue:e.minDurationMs??``,onChange:e=>n({minDurationMs:Number(e.target.value)||void 0})}),(0,m.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,m.jsx)(Lu,{checked:e.hasError??!1,onCheckedChange:e=>n({hasError:e||void 0})}),`Errors only`]}),r.isError&&(0,m.jsx)(`span`,{className:`ml-auto font-mono text-xs text-destructive`,children:`collector unreachable`})]}),(0,m.jsx)(_u,{traces:r.data,empty:(0,m.jsxs)(m.Fragment,{children:[`No traces yet — open your app while `,(0,m.jsx)(`code`,{children:`next-observer dev`}),` is running.`]})})]})}function Vu({to:e,children:t}){return(0,m.jsx)(R,{to:e,activeOptions:{exact:e===`/`,includeSearch:!1},className:`rounded-md px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground [&.active]:bg-muted [&.active]:text-foreground`,children:t})}var Hu=da({component:()=>(0,m.jsxs)(`div`,{className:`min-h-screen text-foreground`,children:[(0,m.jsx)(`header`,{className:`sticky top-0 z-20 border-b bg-background/70 backdrop-blur-md`,children:(0,m.jsxs)(`div`,{className:`mx-auto flex h-14 max-w-7xl items-center gap-2 px-6`,children:[(0,m.jsxs)(R,{to:`/`,className:`mr-4 flex items-center gap-2 font-semibold tracking-tight`,children:[(0,m.jsx)(`span`,{"aria-hidden":!0,className:`size-2.5 rounded-sm bg-signal shadow-[0_0_12px_var(--signal)]`}),`next-observer`]}),(0,m.jsx)(Vu,{to:`/`,children:`Overview`}),(0,m.jsx)(Vu,{to:`/errors`,children:`Errors`}),(0,m.jsx)(Vu,{to:`/traces`,children:`Traces`}),(0,m.jsx)(Vu,{to:`/chat`,children:`Chat`}),(0,m.jsx)(`span`,{className:`ml-auto`,children:(0,m.jsx)(Va,{})})]})}),(0,m.jsx)(Ha,{}),(0,m.jsx)(`main`,{className:`mx-auto max-w-7xl px-6 py-8`,children:(0,m.jsx)(Sa,{})}),(0,m.jsx)(Vc,{})]})}),Uu=la({getParentRoute:()=>Hu,path:`/`,validateSearch:e=>({window:zl(e.window),service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0}),component:eu});function Wu(e){let t=e=>typeof e==`string`&&e.trim()?e.trim():void 0,n=Number(e.minDurationMs);return{service:t(e.service),operation:t(e.operation),minDurationMs:Number.isFinite(n)&&n>0?n:void 0,hasError:e.hasError===!0||e.hasError===`true`||void 0}}var Gu=la({getParentRoute:()=>Hu,path:`/traces`,validateSearch:Wu,component:Bu}),Ku=la({getParentRoute:()=>Hu,path:`/traces/$traceId`,component:Au}),qu=la({getParentRoute:()=>Hu,path:`/errors`,validateSearch:e=>({window:zl(e.window),service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0}),component:iu}),Ju=la({getParentRoute:()=>Hu,path:`/operation`,validateSearch:e=>({name:typeof e.name==`string`?e.name:``,service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0,window:zl(e.window)}),component:Su}),Yu=la({getParentRoute:()=>Hu,path:`/chat`,validateSearch:e=>({ask:typeof e.ask==`string`&&e.ask.trim()?e.ask.trim():void 0}),component:Il}),Xu=Oa({routeTree:Hu.addChildren([Uu,qu,Gu,Ku,Ju,Yu])}),Zu=new Ue;(0,La.createRoot)(document.getElementById(`root`)).render((0,m.jsx)(p.StrictMode,{children:(0,m.jsx)(_,{client:Zu,children:(0,m.jsx)(ja,{router:Xu})})}));
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>next-observer</title>
7
- <script type="module" crossorigin src="/assets/index-CodPnMW4.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-C8iza4mN.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-BYVdqpEo.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-observer",
3
- "version": "0.3.21",
3
+ "version": "0.3.23",
4
4
  "description": "The observer for Next.js: a server with a UI and AI agents that receives your app's OpenTelemetry traces, shows them and investigates them. Run with npx next-observer dev. The APM agent that goes into the app is next-observe.",
5
5
  "keywords": [
6
6
  "nextjs",