@dudousxd/nestjs-agent-telescope 0.8.0 → 0.8.2

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/dist/index.d.cts CHANGED
@@ -122,13 +122,19 @@ declare class RagTelescopeWatcher implements Watcher {
122
122
  /**
123
123
  * The "Agent" overview dashboard. Panels bind to the `agent.*` data providers.
124
124
  *
125
- * `threadHref` is a URL template for deep-linking a `{threadId}` cell out to the HOST's own thread
126
- * viewer (e.g. the standalone `@dudousxd/nestjs-agent-dashboard` SPA) — omitted by default (no
127
- * internal thread view exists), passed straight through when the host supplies one. `runHref` deep-
128
- * links a `{runId}` cell to the trace waterfall — defaults to {@link DEFAULT_TRACE_HREF} (the
129
- * in-app route), so a `runId` column works out of the box with no host option needed; a host may
130
- * still override it. Every table whose rows carry a `threadId`/`runId` gets a `Column.link` for it
131
- * (via {@link col}); `threadHref` left unset leaves that column plain text.
125
+ * `threadHref` and `runHref` are URL templates for deep-linking a `{threadId}` / `{runId}` cell out
126
+ * to the HOST's own viewer (e.g. the standalone `@dudousxd/nestjs-agent-dashboard` SPA). Both are
127
+ * omitted by default, and a cell whose template is unset renders as plain text.
128
+ *
129
+ * `runHref` used to default to `'#/traces/{runId}'`, and that default could only 404. Telescope's
130
+ * trace waterfall is keyed by **`traceId`** — `LinkSpec`'s doc says so, and `TracesService`
131
+ * resolves it with `storage.get({ traceId })` — while an agent's `runId` is a different identifier
132
+ * that {@link import('./agent-telescope.watcher.js').AgentTelescopeWatcher} never ties to one: it
133
+ * records `type: 'agent'` entries and stamps no trace at all. So every `Run` cell on the shipped
134
+ * dashboard pointed at a trace that does not exist, and clicking one answered
135
+ * `404 · No entries for trace <runId>`. Substituting the wrong key into a route that had been read
136
+ * correctly is the whole bug — hence no default here. A host that has a run viewer passes its own
137
+ * template; one that does not gets plain text, which is honest.
132
138
  *
133
139
  * Layout: eight sections (Overview lean; Spend; Reliability; Activity; Approvals; Tools;
134
140
  * Retrieval; Retrieval sources), each sized so its panel count is an exact multiple of its `cols` —
package/dist/index.d.ts CHANGED
@@ -122,13 +122,19 @@ declare class RagTelescopeWatcher implements Watcher {
122
122
  /**
123
123
  * The "Agent" overview dashboard. Panels bind to the `agent.*` data providers.
124
124
  *
125
- * `threadHref` is a URL template for deep-linking a `{threadId}` cell out to the HOST's own thread
126
- * viewer (e.g. the standalone `@dudousxd/nestjs-agent-dashboard` SPA) — omitted by default (no
127
- * internal thread view exists), passed straight through when the host supplies one. `runHref` deep-
128
- * links a `{runId}` cell to the trace waterfall — defaults to {@link DEFAULT_TRACE_HREF} (the
129
- * in-app route), so a `runId` column works out of the box with no host option needed; a host may
130
- * still override it. Every table whose rows carry a `threadId`/`runId` gets a `Column.link` for it
131
- * (via {@link col}); `threadHref` left unset leaves that column plain text.
125
+ * `threadHref` and `runHref` are URL templates for deep-linking a `{threadId}` / `{runId}` cell out
126
+ * to the HOST's own viewer (e.g. the standalone `@dudousxd/nestjs-agent-dashboard` SPA). Both are
127
+ * omitted by default, and a cell whose template is unset renders as plain text.
128
+ *
129
+ * `runHref` used to default to `'#/traces/{runId}'`, and that default could only 404. Telescope's
130
+ * trace waterfall is keyed by **`traceId`** — `LinkSpec`'s doc says so, and `TracesService`
131
+ * resolves it with `storage.get({ traceId })` — while an agent's `runId` is a different identifier
132
+ * that {@link import('./agent-telescope.watcher.js').AgentTelescopeWatcher} never ties to one: it
133
+ * records `type: 'agent'` entries and stamps no trace at all. So every `Run` cell on the shipped
134
+ * dashboard pointed at a trace that does not exist, and clicking one answered
135
+ * `404 · No entries for trace <runId>`. Substituting the wrong key into a route that had been read
136
+ * correctly is the whole bug — hence no default here. A host that has a run viewer passes its own
137
+ * template; one that does not gets plain text, which is honest.
132
138
  *
133
139
  * Layout: eight sections (Overview lean; Spend; Reliability; Activity; Approvals; Tools;
134
140
  * Retrieval; Retrieval sources), each sized so its panel count is an exact multiple of its `cols` —
package/dist/index.js CHANGED
@@ -18,9 +18,8 @@ function col(key, label, href) {
18
18
  };
19
19
  }
20
20
  __name(col, "col");
21
- var DEFAULT_TRACE_HREF = "#/traces/{runId}";
22
21
  function agentDashboard(opts = {}) {
23
- const runHref = opts.runHref ?? DEFAULT_TRACE_HREF;
22
+ const runHref = opts.runHref;
24
23
  return {
25
24
  id: "agent.overview",
26
25
  label: "Agent",
@@ -1086,9 +1085,15 @@ function agentRunsTrendProvider() {
1086
1085
  __name(agentRunsTrendProvider, "agentRunsTrendProvider");
1087
1086
  var DEFAULT_RECENT_LIMIT = 50;
1088
1087
  var MAX_RECENT_LIMIT = 500;
1088
+ function readPositiveNumber(raw) {
1089
+ if (typeof raw === "number") return Number.isFinite(raw) && raw > 0 ? raw : void 0;
1090
+ if (typeof raw !== "string" || raw.trim() === "") return void 0;
1091
+ const parsed = Number(raw);
1092
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
1093
+ }
1094
+ __name(readPositiveNumber, "readPositiveNumber");
1089
1095
  function resolveLimit(query, fallback) {
1090
- const raw = query?.limit;
1091
- const value = typeof raw === "number" && Number.isFinite(raw) ? raw : fallback;
1096
+ const value = readPositiveNumber(query?.limit) ?? fallback;
1092
1097
  return Math.min(MAX_RECENT_LIMIT, Math.max(1, Math.trunc(value)));
1093
1098
  }
1094
1099
  __name(resolveLimit, "resolveLimit");
@@ -1104,8 +1109,7 @@ function governanceLimitProvider(name, defaultLimit, fetch, format) {
1104
1109
  }
1105
1110
  __name(governanceLimitProvider, "governanceLimitProvider");
1106
1111
  function resolvePage(query) {
1107
- const raw = query?.page;
1108
- const value = typeof raw === "number" && Number.isFinite(raw) ? raw : 1;
1112
+ const value = readPositiveNumber(query?.page) ?? 1;
1109
1113
  return Math.max(1, Math.trunc(value));
1110
1114
  }
1111
1115
  __name(resolvePage, "resolvePage");