@dudousxd/nestjs-agent-telescope 0.8.60 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +206 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -3
- package/dist/index.d.ts +70 -3
- package/dist/index.js +200 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -136,8 +136,8 @@ declare class RagTelescopeWatcher implements Watcher {
|
|
|
136
136
|
* correctly is the whole bug — hence no default here. A host that has a run viewer passes its own
|
|
137
137
|
* template; one that does not gets plain text, which is honest.
|
|
138
138
|
*
|
|
139
|
-
* Layout:
|
|
140
|
-
* Retrieval; Retrieval sources), each sized so its panel count is an exact multiple of its `cols` —
|
|
139
|
+
* Layout: nine sections (Overview lean; Spend; Reliability; Run outcomes; Activity; Approvals;
|
|
140
|
+
* Tools; Retrieval; Retrieval sources), each sized so its panel count is an exact multiple of its `cols` —
|
|
141
141
|
* no half-empty row. `nestjs-telescope`'s `ExtensionDashboardPage` renders a section as a
|
|
142
142
|
* `grid-cols-N` grid with one panel per cell and no `colSpan`, so a lone table in an otherwise-empty
|
|
143
143
|
* row would leave a visible gap next to it.
|
|
@@ -286,6 +286,48 @@ declare function ragCollectionsTableProvider(): DataProvider;
|
|
|
286
286
|
/** table → the slowest retrievals in the window. */
|
|
287
287
|
declare function ragSlowestTableProvider(): DataProvider;
|
|
288
288
|
|
|
289
|
+
interface AgentEntryContent {
|
|
290
|
+
event: string;
|
|
291
|
+
runId?: string;
|
|
292
|
+
threadId?: string;
|
|
293
|
+
toolName?: string;
|
|
294
|
+
toolType?: string;
|
|
295
|
+
status?: string;
|
|
296
|
+
steps?: number;
|
|
297
|
+
inputTokens?: number;
|
|
298
|
+
outputTokens?: number;
|
|
299
|
+
/** `run.finished`: turn start to the first `text` frame. */
|
|
300
|
+
ttftMs?: number;
|
|
301
|
+
/** `run.finished`: present on a delegated sub-agent's run. */
|
|
302
|
+
parentRunId?: string;
|
|
303
|
+
/** `run.failed`: the stable stream error code. */
|
|
304
|
+
code?: string;
|
|
305
|
+
/** `tool-call`: an outcome re-published by a run replaying its journal. */
|
|
306
|
+
replayed?: boolean;
|
|
307
|
+
}
|
|
308
|
+
interface StorageEntry {
|
|
309
|
+
content?: AgentEntryContent;
|
|
310
|
+
createdAt?: Date;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Time-to-first-token histogram over the recorded `run.finished` entries, plus p50/p95 of the raw
|
|
314
|
+
* samples. Top-level runs only — a delegated sub-agent streams into its parent's turn, so its first
|
|
315
|
+
* token is not one a person waited for (the same rule `RunMetrics.ttftP50Ms` applies). A run that
|
|
316
|
+
* streamed no text carries no `ttftMs` and is left out rather than counted as `0`.
|
|
317
|
+
*/
|
|
318
|
+
declare function toTtftDistribution(entries: StorageEntry[]): {
|
|
319
|
+
buckets: {
|
|
320
|
+
label: string;
|
|
321
|
+
count: number;
|
|
322
|
+
}[];
|
|
323
|
+
p50?: number;
|
|
324
|
+
p95?: number;
|
|
325
|
+
};
|
|
326
|
+
/** Failed runs by their stable error code, over the recorded `run.failed` entries. */
|
|
327
|
+
declare function toFailureCodeSegments(entries: StorageEntry[]): {
|
|
328
|
+
label: string;
|
|
329
|
+
value: number;
|
|
330
|
+
}[];
|
|
289
331
|
/** stat → total agent runs (run.finished entries). */
|
|
290
332
|
declare function agentRunsProvider(): DataProvider;
|
|
291
333
|
/** stat → total tokens across all finished runs. */
|
|
@@ -309,6 +351,21 @@ declare function agentTokensProvider(): DataProvider;
|
|
|
309
351
|
declare function agentToolsProvider(): DataProvider;
|
|
310
352
|
/** breakdown → tool-call status distribution. */
|
|
311
353
|
declare function agentToolStatusProvider(): DataProvider;
|
|
354
|
+
/**
|
|
355
|
+
* distribution → time to first token of the recorded top-level runs, from the `run.finished`
|
|
356
|
+
* diagnostics this extension's watcher keeps. Unlike the governance duration pair, these entries
|
|
357
|
+
* carry the raw per-run figure, so there ARE samples to bucket — at the cost of covering only what
|
|
358
|
+
* Telescope's own storage still holds.
|
|
359
|
+
*/
|
|
360
|
+
declare function agentRunsTtftDistributionProvider(): DataProvider;
|
|
361
|
+
/**
|
|
362
|
+
* breakdown → failed runs by error code, from the recorded `run.failed` diagnostics. Needs no store:
|
|
363
|
+
* the governance `agent.runs.errors` donut answers the same question over the range from the run
|
|
364
|
+
* rows, and this one keeps answering it for a host that records none.
|
|
365
|
+
*/
|
|
366
|
+
declare function agentRunFailureCodesProvider(): DataProvider;
|
|
367
|
+
/** stat → runs someone stopped (`run.cancelled` entries) — kept apart from failures on purpose. */
|
|
368
|
+
declare function agentRunsCancelledProvider(): DataProvider;
|
|
312
369
|
|
|
313
370
|
/** A breakdown-panel segment (Telescope core: `{ segments: Array<{ label, value, color? }> }`). */
|
|
314
371
|
interface BreakdownSegment {
|
|
@@ -405,6 +462,9 @@ interface RecentRunTableRow {
|
|
|
405
462
|
agentName: string;
|
|
406
463
|
status: string;
|
|
407
464
|
durationMs: number | string;
|
|
465
|
+
ttftMs: number | string;
|
|
466
|
+
costUsd: number | string;
|
|
467
|
+
modelId: string;
|
|
408
468
|
retries: number;
|
|
409
469
|
errorCode: string;
|
|
410
470
|
errorMessage: string;
|
|
@@ -478,6 +538,13 @@ declare function agentRunsRetriesProvider(): DataProvider;
|
|
|
478
538
|
* `null` percentile (no settled runs in range) resolves to 0.
|
|
479
539
|
*/
|
|
480
540
|
declare function agentRunsDurationProvider(): DataProvider;
|
|
541
|
+
/**
|
|
542
|
+
* stat → time-to-first-token percentile over the range's completed top-level runs, selected by
|
|
543
|
+
* `query.metric` exactly like {@link agentRunsDurationProvider}. A `null` percentile (no run in range
|
|
544
|
+
* recorded one) resolves to 0. The histogram beside it reads the raw samples off Telescope's own
|
|
545
|
+
* `run.finished` entries — `agent.runs.ttftDistribution`.
|
|
546
|
+
*/
|
|
547
|
+
declare function agentRunsTtftProvider(): DataProvider;
|
|
481
548
|
/** table → run/failure/retry rollup per agent. */
|
|
482
549
|
declare function agentRunsByAgentTableProvider(): DataProvider;
|
|
483
550
|
/** breakdown → failed runs by error code. */
|
|
@@ -509,4 +576,4 @@ declare function agentPendingApprovalsTableProvider(): DataProvider;
|
|
|
509
576
|
/** table → per-tool call/failure/rejection/latency rollup over the range. */
|
|
510
577
|
declare function agentToolStatsTableProvider(): DataProvider;
|
|
511
578
|
|
|
512
|
-
export { type AgentTelescopeExtensionOptions, AgentTelescopeWatcher, RAG_ENTRY_TYPE, type RagRetrieval, RagTelescopeWatcher, agentActorSpendTableProvider, agentDashboard, agentModelSpendTableProvider, agentPendingApprovalsCountProvider, agentPendingApprovalsTableProvider, agentRecentRunsTableProvider, agentRecentThreadsTableProvider, agentRecentToolCallsTableProvider, agentRunErrorsProvider, agentRunsByAgentTableProvider, agentRunsDurationProvider, agentRunsFailedProvider, agentRunsProvider, agentRunsRetriesProvider, agentRunsSuccessRateProvider, agentRunsTotalProvider, agentRunsTrendProvider, agentSpendByActorProvider, agentSpendByModelProvider, agentSpendTotalProvider, agentTelescopeExtension, agentTokensProvider, agentTokensTotalProvider, agentToolStatsTableProvider, agentToolStatusProvider, agentToolsProvider, agentTopThreadsTableProvider, agentUsageTrendProvider, capErrorMessage, meanChunks, percentile, ragChunksProvider, ragCollectionsTableProvider, ragLatencyProvider, ragRetrievalsProvider, ragRetrieverBreakdownProvider, ragScoresProvider, ragSlowestTableProvider, ragStoreBreakdownProvider, ragTrendProvider, ragZeroHitRateProvider, readRetrievals, resolveRange, shiftUtcDay, shortPromptHash, toActorSpendRows, toActorSpendSegments, toCollectionRows, toLatencyDistribution, toModelSpendRows, toModelSpendSegments, toPendingApprovalTableRows, toRagRetrieval, toRecentRunTableRows, toRecentThreadTableRows, toRecentToolCallRows, toRetrievalTrendRows, toRetrieverSegments, toRunAgentTableRows, toRunErrorSegments, toRunTrendRows, toScoreDistribution, toSlowestRows, toStoreSegments, toThreadSpendRows, toToolStatTableRows, toUsageTrendRows, totalCostUsd, totalTokens, zeroHitRate };
|
|
579
|
+
export { type AgentTelescopeExtensionOptions, AgentTelescopeWatcher, RAG_ENTRY_TYPE, type RagRetrieval, RagTelescopeWatcher, agentActorSpendTableProvider, agentDashboard, agentModelSpendTableProvider, agentPendingApprovalsCountProvider, agentPendingApprovalsTableProvider, agentRecentRunsTableProvider, agentRecentThreadsTableProvider, agentRecentToolCallsTableProvider, agentRunErrorsProvider, agentRunFailureCodesProvider, agentRunsByAgentTableProvider, agentRunsCancelledProvider, agentRunsDurationProvider, agentRunsFailedProvider, agentRunsProvider, agentRunsRetriesProvider, agentRunsSuccessRateProvider, agentRunsTotalProvider, agentRunsTrendProvider, agentRunsTtftDistributionProvider, agentRunsTtftProvider, agentSpendByActorProvider, agentSpendByModelProvider, agentSpendTotalProvider, agentTelescopeExtension, agentTokensProvider, agentTokensTotalProvider, agentToolStatsTableProvider, agentToolStatusProvider, agentToolsProvider, agentTopThreadsTableProvider, agentUsageTrendProvider, capErrorMessage, meanChunks, percentile, ragChunksProvider, ragCollectionsTableProvider, ragLatencyProvider, ragRetrievalsProvider, ragRetrieverBreakdownProvider, ragScoresProvider, ragSlowestTableProvider, ragStoreBreakdownProvider, ragTrendProvider, ragZeroHitRateProvider, readRetrievals, resolveRange, shiftUtcDay, shortPromptHash, toActorSpendRows, toActorSpendSegments, toCollectionRows, toFailureCodeSegments, toLatencyDistribution, toModelSpendRows, toModelSpendSegments, toPendingApprovalTableRows, toRagRetrieval, toRecentRunTableRows, toRecentThreadTableRows, toRecentToolCallRows, toRetrievalTrendRows, toRetrieverSegments, toRunAgentTableRows, toRunErrorSegments, toRunTrendRows, toScoreDistribution, toSlowestRows, toStoreSegments, toThreadSpendRows, toToolStatTableRows, toTtftDistribution, toUsageTrendRows, totalCostUsd, totalTokens, zeroHitRate };
|
package/dist/index.d.ts
CHANGED
|
@@ -136,8 +136,8 @@ declare class RagTelescopeWatcher implements Watcher {
|
|
|
136
136
|
* correctly is the whole bug — hence no default here. A host that has a run viewer passes its own
|
|
137
137
|
* template; one that does not gets plain text, which is honest.
|
|
138
138
|
*
|
|
139
|
-
* Layout:
|
|
140
|
-
* Retrieval; Retrieval sources), each sized so its panel count is an exact multiple of its `cols` —
|
|
139
|
+
* Layout: nine sections (Overview lean; Spend; Reliability; Run outcomes; Activity; Approvals;
|
|
140
|
+
* Tools; Retrieval; Retrieval sources), each sized so its panel count is an exact multiple of its `cols` —
|
|
141
141
|
* no half-empty row. `nestjs-telescope`'s `ExtensionDashboardPage` renders a section as a
|
|
142
142
|
* `grid-cols-N` grid with one panel per cell and no `colSpan`, so a lone table in an otherwise-empty
|
|
143
143
|
* row would leave a visible gap next to it.
|
|
@@ -286,6 +286,48 @@ declare function ragCollectionsTableProvider(): DataProvider;
|
|
|
286
286
|
/** table → the slowest retrievals in the window. */
|
|
287
287
|
declare function ragSlowestTableProvider(): DataProvider;
|
|
288
288
|
|
|
289
|
+
interface AgentEntryContent {
|
|
290
|
+
event: string;
|
|
291
|
+
runId?: string;
|
|
292
|
+
threadId?: string;
|
|
293
|
+
toolName?: string;
|
|
294
|
+
toolType?: string;
|
|
295
|
+
status?: string;
|
|
296
|
+
steps?: number;
|
|
297
|
+
inputTokens?: number;
|
|
298
|
+
outputTokens?: number;
|
|
299
|
+
/** `run.finished`: turn start to the first `text` frame. */
|
|
300
|
+
ttftMs?: number;
|
|
301
|
+
/** `run.finished`: present on a delegated sub-agent's run. */
|
|
302
|
+
parentRunId?: string;
|
|
303
|
+
/** `run.failed`: the stable stream error code. */
|
|
304
|
+
code?: string;
|
|
305
|
+
/** `tool-call`: an outcome re-published by a run replaying its journal. */
|
|
306
|
+
replayed?: boolean;
|
|
307
|
+
}
|
|
308
|
+
interface StorageEntry {
|
|
309
|
+
content?: AgentEntryContent;
|
|
310
|
+
createdAt?: Date;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Time-to-first-token histogram over the recorded `run.finished` entries, plus p50/p95 of the raw
|
|
314
|
+
* samples. Top-level runs only — a delegated sub-agent streams into its parent's turn, so its first
|
|
315
|
+
* token is not one a person waited for (the same rule `RunMetrics.ttftP50Ms` applies). A run that
|
|
316
|
+
* streamed no text carries no `ttftMs` and is left out rather than counted as `0`.
|
|
317
|
+
*/
|
|
318
|
+
declare function toTtftDistribution(entries: StorageEntry[]): {
|
|
319
|
+
buckets: {
|
|
320
|
+
label: string;
|
|
321
|
+
count: number;
|
|
322
|
+
}[];
|
|
323
|
+
p50?: number;
|
|
324
|
+
p95?: number;
|
|
325
|
+
};
|
|
326
|
+
/** Failed runs by their stable error code, over the recorded `run.failed` entries. */
|
|
327
|
+
declare function toFailureCodeSegments(entries: StorageEntry[]): {
|
|
328
|
+
label: string;
|
|
329
|
+
value: number;
|
|
330
|
+
}[];
|
|
289
331
|
/** stat → total agent runs (run.finished entries). */
|
|
290
332
|
declare function agentRunsProvider(): DataProvider;
|
|
291
333
|
/** stat → total tokens across all finished runs. */
|
|
@@ -309,6 +351,21 @@ declare function agentTokensProvider(): DataProvider;
|
|
|
309
351
|
declare function agentToolsProvider(): DataProvider;
|
|
310
352
|
/** breakdown → tool-call status distribution. */
|
|
311
353
|
declare function agentToolStatusProvider(): DataProvider;
|
|
354
|
+
/**
|
|
355
|
+
* distribution → time to first token of the recorded top-level runs, from the `run.finished`
|
|
356
|
+
* diagnostics this extension's watcher keeps. Unlike the governance duration pair, these entries
|
|
357
|
+
* carry the raw per-run figure, so there ARE samples to bucket — at the cost of covering only what
|
|
358
|
+
* Telescope's own storage still holds.
|
|
359
|
+
*/
|
|
360
|
+
declare function agentRunsTtftDistributionProvider(): DataProvider;
|
|
361
|
+
/**
|
|
362
|
+
* breakdown → failed runs by error code, from the recorded `run.failed` diagnostics. Needs no store:
|
|
363
|
+
* the governance `agent.runs.errors` donut answers the same question over the range from the run
|
|
364
|
+
* rows, and this one keeps answering it for a host that records none.
|
|
365
|
+
*/
|
|
366
|
+
declare function agentRunFailureCodesProvider(): DataProvider;
|
|
367
|
+
/** stat → runs someone stopped (`run.cancelled` entries) — kept apart from failures on purpose. */
|
|
368
|
+
declare function agentRunsCancelledProvider(): DataProvider;
|
|
312
369
|
|
|
313
370
|
/** A breakdown-panel segment (Telescope core: `{ segments: Array<{ label, value, color? }> }`). */
|
|
314
371
|
interface BreakdownSegment {
|
|
@@ -405,6 +462,9 @@ interface RecentRunTableRow {
|
|
|
405
462
|
agentName: string;
|
|
406
463
|
status: string;
|
|
407
464
|
durationMs: number | string;
|
|
465
|
+
ttftMs: number | string;
|
|
466
|
+
costUsd: number | string;
|
|
467
|
+
modelId: string;
|
|
408
468
|
retries: number;
|
|
409
469
|
errorCode: string;
|
|
410
470
|
errorMessage: string;
|
|
@@ -478,6 +538,13 @@ declare function agentRunsRetriesProvider(): DataProvider;
|
|
|
478
538
|
* `null` percentile (no settled runs in range) resolves to 0.
|
|
479
539
|
*/
|
|
480
540
|
declare function agentRunsDurationProvider(): DataProvider;
|
|
541
|
+
/**
|
|
542
|
+
* stat → time-to-first-token percentile over the range's completed top-level runs, selected by
|
|
543
|
+
* `query.metric` exactly like {@link agentRunsDurationProvider}. A `null` percentile (no run in range
|
|
544
|
+
* recorded one) resolves to 0. The histogram beside it reads the raw samples off Telescope's own
|
|
545
|
+
* `run.finished` entries — `agent.runs.ttftDistribution`.
|
|
546
|
+
*/
|
|
547
|
+
declare function agentRunsTtftProvider(): DataProvider;
|
|
481
548
|
/** table → run/failure/retry rollup per agent. */
|
|
482
549
|
declare function agentRunsByAgentTableProvider(): DataProvider;
|
|
483
550
|
/** breakdown → failed runs by error code. */
|
|
@@ -509,4 +576,4 @@ declare function agentPendingApprovalsTableProvider(): DataProvider;
|
|
|
509
576
|
/** table → per-tool call/failure/rejection/latency rollup over the range. */
|
|
510
577
|
declare function agentToolStatsTableProvider(): DataProvider;
|
|
511
578
|
|
|
512
|
-
export { type AgentTelescopeExtensionOptions, AgentTelescopeWatcher, RAG_ENTRY_TYPE, type RagRetrieval, RagTelescopeWatcher, agentActorSpendTableProvider, agentDashboard, agentModelSpendTableProvider, agentPendingApprovalsCountProvider, agentPendingApprovalsTableProvider, agentRecentRunsTableProvider, agentRecentThreadsTableProvider, agentRecentToolCallsTableProvider, agentRunErrorsProvider, agentRunsByAgentTableProvider, agentRunsDurationProvider, agentRunsFailedProvider, agentRunsProvider, agentRunsRetriesProvider, agentRunsSuccessRateProvider, agentRunsTotalProvider, agentRunsTrendProvider, agentSpendByActorProvider, agentSpendByModelProvider, agentSpendTotalProvider, agentTelescopeExtension, agentTokensProvider, agentTokensTotalProvider, agentToolStatsTableProvider, agentToolStatusProvider, agentToolsProvider, agentTopThreadsTableProvider, agentUsageTrendProvider, capErrorMessage, meanChunks, percentile, ragChunksProvider, ragCollectionsTableProvider, ragLatencyProvider, ragRetrievalsProvider, ragRetrieverBreakdownProvider, ragScoresProvider, ragSlowestTableProvider, ragStoreBreakdownProvider, ragTrendProvider, ragZeroHitRateProvider, readRetrievals, resolveRange, shiftUtcDay, shortPromptHash, toActorSpendRows, toActorSpendSegments, toCollectionRows, toLatencyDistribution, toModelSpendRows, toModelSpendSegments, toPendingApprovalTableRows, toRagRetrieval, toRecentRunTableRows, toRecentThreadTableRows, toRecentToolCallRows, toRetrievalTrendRows, toRetrieverSegments, toRunAgentTableRows, toRunErrorSegments, toRunTrendRows, toScoreDistribution, toSlowestRows, toStoreSegments, toThreadSpendRows, toToolStatTableRows, toUsageTrendRows, totalCostUsd, totalTokens, zeroHitRate };
|
|
579
|
+
export { type AgentTelescopeExtensionOptions, AgentTelescopeWatcher, RAG_ENTRY_TYPE, type RagRetrieval, RagTelescopeWatcher, agentActorSpendTableProvider, agentDashboard, agentModelSpendTableProvider, agentPendingApprovalsCountProvider, agentPendingApprovalsTableProvider, agentRecentRunsTableProvider, agentRecentThreadsTableProvider, agentRecentToolCallsTableProvider, agentRunErrorsProvider, agentRunFailureCodesProvider, agentRunsByAgentTableProvider, agentRunsCancelledProvider, agentRunsDurationProvider, agentRunsFailedProvider, agentRunsProvider, agentRunsRetriesProvider, agentRunsSuccessRateProvider, agentRunsTotalProvider, agentRunsTrendProvider, agentRunsTtftDistributionProvider, agentRunsTtftProvider, agentSpendByActorProvider, agentSpendByModelProvider, agentSpendTotalProvider, agentTelescopeExtension, agentTokensProvider, agentTokensTotalProvider, agentToolStatsTableProvider, agentToolStatusProvider, agentToolsProvider, agentTopThreadsTableProvider, agentUsageTrendProvider, capErrorMessage, meanChunks, percentile, ragChunksProvider, ragCollectionsTableProvider, ragLatencyProvider, ragRetrievalsProvider, ragRetrieverBreakdownProvider, ragScoresProvider, ragSlowestTableProvider, ragStoreBreakdownProvider, ragTrendProvider, ragZeroHitRateProvider, readRetrievals, resolveRange, shiftUtcDay, shortPromptHash, toActorSpendRows, toActorSpendSegments, toCollectionRows, toFailureCodeSegments, toLatencyDistribution, toModelSpendRows, toModelSpendSegments, toPendingApprovalTableRows, toRagRetrieval, toRecentRunTableRows, toRecentThreadTableRows, toRecentToolCallRows, toRetrievalTrendRows, toRetrieverSegments, toRunAgentTableRows, toRunErrorSegments, toRunTrendRows, toScoreDistribution, toSlowestRows, toStoreSegments, toThreadSpendRows, toToolStatTableRows, toTtftDistribution, toUsageTrendRows, totalCostUsd, totalTokens, zeroHitRate };
|
package/dist/index.js
CHANGED
|
@@ -244,6 +244,43 @@ function agentDashboard(opts = {}) {
|
|
|
244
244
|
},
|
|
245
245
|
// Two duration stats above, not a `distribution` panel: RunMetrics carries only p50/p95
|
|
246
246
|
// (no raw samples to bucket), so a histogram here would be a permanently-empty box.
|
|
247
|
+
{
|
|
248
|
+
kind: "stat",
|
|
249
|
+
title: "TTFT p50",
|
|
250
|
+
data: {
|
|
251
|
+
provider: "agent.runs.ttft",
|
|
252
|
+
query: {
|
|
253
|
+
metric: "p50"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
format: "duration"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
kind: "stat",
|
|
260
|
+
title: "TTFT p95",
|
|
261
|
+
data: {
|
|
262
|
+
provider: "agent.runs.ttft",
|
|
263
|
+
query: {
|
|
264
|
+
metric: "p95"
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
format: "duration"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
// The one histogram in this section: `run.finished` diagnostics carry each run's own
|
|
271
|
+
// `ttftMs`, so the watcher-recorded entries DO have samples to bucket (over what
|
|
272
|
+
// Telescope's storage still holds, not the governance range).
|
|
273
|
+
kind: "distribution",
|
|
274
|
+
title: "Time to first token",
|
|
275
|
+
data: {
|
|
276
|
+
provider: "agent.runs.ttftDistribution"
|
|
277
|
+
},
|
|
278
|
+
markers: [
|
|
279
|
+
"p50",
|
|
280
|
+
"p95"
|
|
281
|
+
],
|
|
282
|
+
format: "duration"
|
|
283
|
+
},
|
|
247
284
|
{
|
|
248
285
|
kind: "timeseries",
|
|
249
286
|
title: "Runs & failures",
|
|
@@ -291,6 +328,30 @@ function agentDashboard(opts = {}) {
|
|
|
291
328
|
}
|
|
292
329
|
]
|
|
293
330
|
},
|
|
331
|
+
{
|
|
332
|
+
// Live, from the watcher-recorded diagnostics rather than the run rows: what failed and
|
|
333
|
+
// what was stopped, readable on a host that binds no governance read-model. A cancel is
|
|
334
|
+
// its own number — a user pressing Stop is the control working, not a failure.
|
|
335
|
+
title: "Run outcomes",
|
|
336
|
+
cols: 2,
|
|
337
|
+
panels: [
|
|
338
|
+
{
|
|
339
|
+
kind: "breakdown",
|
|
340
|
+
title: "Failures by code",
|
|
341
|
+
data: {
|
|
342
|
+
provider: "agent.runs.failureCodes"
|
|
343
|
+
},
|
|
344
|
+
style: "donut"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
kind: "stat",
|
|
348
|
+
title: "Cancelled",
|
|
349
|
+
data: {
|
|
350
|
+
provider: "agent.runs.cancelled"
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
]
|
|
354
|
+
},
|
|
294
355
|
{
|
|
295
356
|
// The paged list tables: tool calls, threads, runs — each reads the paged SPI
|
|
296
357
|
// (toolCallsPage/threadsPage/runsPage via `agent.*.paged`) and opts into the renderer's
|
|
@@ -687,6 +748,82 @@ function ofEvent(entries, event) {
|
|
|
687
748
|
return entries.filter((entry) => entry.content?.event === event);
|
|
688
749
|
}
|
|
689
750
|
__name(ofEvent, "ofEvent");
|
|
751
|
+
function firstToolCalls(entries) {
|
|
752
|
+
return ofEvent(entries, "tool-call").filter((entry) => entry.content?.replayed !== true);
|
|
753
|
+
}
|
|
754
|
+
__name(firstToolCalls, "firstToolCalls");
|
|
755
|
+
function percentileOf(samples, fraction) {
|
|
756
|
+
if (samples.length === 0) {
|
|
757
|
+
return null;
|
|
758
|
+
}
|
|
759
|
+
const sorted = [
|
|
760
|
+
...samples
|
|
761
|
+
].sort((a, b) => a - b);
|
|
762
|
+
const rank = Math.ceil(fraction * sorted.length);
|
|
763
|
+
return sorted[Math.min(Math.max(rank, 1), sorted.length) - 1] ?? null;
|
|
764
|
+
}
|
|
765
|
+
__name(percentileOf, "percentileOf");
|
|
766
|
+
var TTFT_EDGES = [
|
|
767
|
+
250,
|
|
768
|
+
500,
|
|
769
|
+
1e3,
|
|
770
|
+
2e3,
|
|
771
|
+
4e3,
|
|
772
|
+
8e3,
|
|
773
|
+
16e3
|
|
774
|
+
];
|
|
775
|
+
function ttftLabel(index) {
|
|
776
|
+
const upper = TTFT_EDGES[index];
|
|
777
|
+
if (upper === void 0) {
|
|
778
|
+
return `\u2265${TTFT_EDGES[TTFT_EDGES.length - 1] ?? 0}ms`;
|
|
779
|
+
}
|
|
780
|
+
return `${index === 0 ? 0 : TTFT_EDGES[index - 1] ?? 0}\u2013${upper}ms`;
|
|
781
|
+
}
|
|
782
|
+
__name(ttftLabel, "ttftLabel");
|
|
783
|
+
function toTtftDistribution(entries) {
|
|
784
|
+
const samples = [];
|
|
785
|
+
const counts = new Array(TTFT_EDGES.length + 1).fill(0);
|
|
786
|
+
for (const entry of ofEvent(entries, "run.finished")) {
|
|
787
|
+
const ttftMs = entry.content?.ttftMs;
|
|
788
|
+
if (typeof ttftMs !== "number" || entry.content?.parentRunId !== void 0) {
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
samples.push(ttftMs);
|
|
792
|
+
const found = TTFT_EDGES.findIndex((edge) => ttftMs < edge);
|
|
793
|
+
const index = found === -1 ? TTFT_EDGES.length : found;
|
|
794
|
+
counts[index] = (counts[index] ?? 0) + 1;
|
|
795
|
+
}
|
|
796
|
+
const buckets = counts.map((count, index) => ({
|
|
797
|
+
label: ttftLabel(index),
|
|
798
|
+
count
|
|
799
|
+
}));
|
|
800
|
+
const p50 = percentileOf(samples, 0.5);
|
|
801
|
+
const p95 = percentileOf(samples, 0.95);
|
|
802
|
+
return {
|
|
803
|
+
buckets,
|
|
804
|
+
...p50 !== null ? {
|
|
805
|
+
p50
|
|
806
|
+
} : {},
|
|
807
|
+
...p95 !== null ? {
|
|
808
|
+
p95
|
|
809
|
+
} : {}
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
__name(toTtftDistribution, "toTtftDistribution");
|
|
813
|
+
function toFailureCodeSegments(entries) {
|
|
814
|
+
const counts = /* @__PURE__ */ new Map();
|
|
815
|
+
for (const entry of ofEvent(entries, "run.failed")) {
|
|
816
|
+
const code = entry.content?.code ?? "unknown";
|
|
817
|
+
counts.set(code, (counts.get(code) ?? 0) + 1);
|
|
818
|
+
}
|
|
819
|
+
return [
|
|
820
|
+
...counts.entries()
|
|
821
|
+
].map(([label, value]) => ({
|
|
822
|
+
label,
|
|
823
|
+
value
|
|
824
|
+
})).sort((a, b) => b.value - a.value);
|
|
825
|
+
}
|
|
826
|
+
__name(toFailureCodeSegments, "toFailureCodeSegments");
|
|
690
827
|
function agentRunsProvider() {
|
|
691
828
|
return {
|
|
692
829
|
name: "agent.runs",
|
|
@@ -716,7 +853,7 @@ function agentToolsProvider() {
|
|
|
716
853
|
return {
|
|
717
854
|
name: "agent.tools",
|
|
718
855
|
async resolve(_query, ctx) {
|
|
719
|
-
const calls =
|
|
856
|
+
const calls = firstToolCalls(await fetchEntries(ctx)).slice(-50).reverse().map((entry) => ({
|
|
720
857
|
toolName: entry.content?.toolName ?? "",
|
|
721
858
|
toolType: entry.content?.toolType ?? "",
|
|
722
859
|
status: entry.content?.status ?? "",
|
|
@@ -733,7 +870,7 @@ function agentToolStatusProvider() {
|
|
|
733
870
|
return {
|
|
734
871
|
name: "agent.toolStatus",
|
|
735
872
|
async resolve(_query, ctx) {
|
|
736
|
-
const calls =
|
|
873
|
+
const calls = firstToolCalls(await fetchEntries(ctx));
|
|
737
874
|
const counts = /* @__PURE__ */ new Map();
|
|
738
875
|
for (const call of calls) {
|
|
739
876
|
const status = call.content?.status ?? "unknown";
|
|
@@ -751,6 +888,37 @@ function agentToolStatusProvider() {
|
|
|
751
888
|
};
|
|
752
889
|
}
|
|
753
890
|
__name(agentToolStatusProvider, "agentToolStatusProvider");
|
|
891
|
+
function agentRunsTtftDistributionProvider() {
|
|
892
|
+
return {
|
|
893
|
+
name: "agent.runs.ttftDistribution",
|
|
894
|
+
async resolve(_query, ctx) {
|
|
895
|
+
return toTtftDistribution(await fetchEntries(ctx));
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
__name(agentRunsTtftDistributionProvider, "agentRunsTtftDistributionProvider");
|
|
900
|
+
function agentRunFailureCodesProvider() {
|
|
901
|
+
return {
|
|
902
|
+
name: "agent.runs.failureCodes",
|
|
903
|
+
async resolve(_query, ctx) {
|
|
904
|
+
return {
|
|
905
|
+
segments: toFailureCodeSegments(await fetchEntries(ctx))
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
__name(agentRunFailureCodesProvider, "agentRunFailureCodesProvider");
|
|
911
|
+
function agentRunsCancelledProvider() {
|
|
912
|
+
return {
|
|
913
|
+
name: "agent.runs.cancelled",
|
|
914
|
+
async resolve(_query, ctx) {
|
|
915
|
+
return {
|
|
916
|
+
value: ofEvent(await fetchEntries(ctx), "run.cancelled").length
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
__name(agentRunsCancelledProvider, "agentRunsCancelledProvider");
|
|
754
922
|
|
|
755
923
|
// src/agent-governance-providers.ts
|
|
756
924
|
import { AGENT_GOVERNANCE_QUERIES } from "@dudousxd/nestjs-agent-core";
|
|
@@ -908,6 +1076,9 @@ function toRecentRunTableRows(rows) {
|
|
|
908
1076
|
agentName: row.agentName ?? NO_VALUE,
|
|
909
1077
|
status: row.status,
|
|
910
1078
|
durationMs: row.durationMs ?? NO_VALUE,
|
|
1079
|
+
ttftMs: row.ttftMs ?? NO_VALUE,
|
|
1080
|
+
costUsd: row.costUsd ?? NO_VALUE,
|
|
1081
|
+
modelId: row.modelId ?? NO_VALUE,
|
|
911
1082
|
retries: row.retries,
|
|
912
1083
|
errorCode: row.errorCode ?? NO_VALUE,
|
|
913
1084
|
errorMessage: capErrorMessage(row.errorMessage) ?? NO_VALUE,
|
|
@@ -955,7 +1126,9 @@ var EMPTY_RUN_METRICS = {
|
|
|
955
1126
|
successRate: 0,
|
|
956
1127
|
retries: 0,
|
|
957
1128
|
durationP50Ms: null,
|
|
958
|
-
durationP95Ms: null
|
|
1129
|
+
durationP95Ms: null,
|
|
1130
|
+
ttftP50Ms: null,
|
|
1131
|
+
ttftP95Ms: null
|
|
959
1132
|
};
|
|
960
1133
|
function governanceStatProvider(name, fetch, format) {
|
|
961
1134
|
return {
|
|
@@ -1065,6 +1238,20 @@ function agentRunsDurationProvider() {
|
|
|
1065
1238
|
};
|
|
1066
1239
|
}
|
|
1067
1240
|
__name(agentRunsDurationProvider, "agentRunsDurationProvider");
|
|
1241
|
+
function agentRunsTtftProvider() {
|
|
1242
|
+
return {
|
|
1243
|
+
name: "agent.runs.ttft",
|
|
1244
|
+
async resolve(query, ctx) {
|
|
1245
|
+
const queries = resolveGovernanceQueries(ctx);
|
|
1246
|
+
const metrics = queries ? await queries.runMetrics(resolveRange(query)) : EMPTY_RUN_METRICS;
|
|
1247
|
+
const value = query?.metric === "p95" ? metrics.ttftP95Ms : metrics.ttftP50Ms;
|
|
1248
|
+
return {
|
|
1249
|
+
value: value ?? 0
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
__name(agentRunsTtftProvider, "agentRunsTtftProvider");
|
|
1068
1255
|
function agentRunsByAgentTableProvider() {
|
|
1069
1256
|
return governanceStatProvider("agent.runs.byAgent", (queries, range) => queries.runsByAgent(range), (rows) => ({
|
|
1070
1257
|
rows: toRunAgentTableRows(rows)
|
|
@@ -1733,6 +1920,10 @@ function agentTelescopeExtension(opts = {}) {
|
|
|
1733
1920
|
agentRunsFailedProvider(),
|
|
1734
1921
|
agentRunsRetriesProvider(),
|
|
1735
1922
|
agentRunsDurationProvider(),
|
|
1923
|
+
agentRunsTtftProvider(),
|
|
1924
|
+
agentRunsTtftDistributionProvider(),
|
|
1925
|
+
agentRunFailureCodesProvider(),
|
|
1926
|
+
agentRunsCancelledProvider(),
|
|
1736
1927
|
agentRunsByAgentTableProvider(),
|
|
1737
1928
|
agentRunErrorsProvider(),
|
|
1738
1929
|
agentRunsTrendProvider(),
|
|
@@ -1773,7 +1964,9 @@ export {
|
|
|
1773
1964
|
agentRecentThreadsTableProvider,
|
|
1774
1965
|
agentRecentToolCallsTableProvider,
|
|
1775
1966
|
agentRunErrorsProvider,
|
|
1967
|
+
agentRunFailureCodesProvider,
|
|
1776
1968
|
agentRunsByAgentTableProvider,
|
|
1969
|
+
agentRunsCancelledProvider,
|
|
1777
1970
|
agentRunsDurationProvider,
|
|
1778
1971
|
agentRunsFailedProvider,
|
|
1779
1972
|
agentRunsProvider,
|
|
@@ -1781,6 +1974,8 @@ export {
|
|
|
1781
1974
|
agentRunsSuccessRateProvider,
|
|
1782
1975
|
agentRunsTotalProvider,
|
|
1783
1976
|
agentRunsTrendProvider,
|
|
1977
|
+
agentRunsTtftDistributionProvider,
|
|
1978
|
+
agentRunsTtftProvider,
|
|
1784
1979
|
agentSpendByActorProvider,
|
|
1785
1980
|
agentSpendByModelProvider,
|
|
1786
1981
|
agentSpendTotalProvider,
|
|
@@ -1812,6 +2007,7 @@ export {
|
|
|
1812
2007
|
toActorSpendRows,
|
|
1813
2008
|
toActorSpendSegments,
|
|
1814
2009
|
toCollectionRows,
|
|
2010
|
+
toFailureCodeSegments,
|
|
1815
2011
|
toLatencyDistribution,
|
|
1816
2012
|
toModelSpendRows,
|
|
1817
2013
|
toModelSpendSegments,
|
|
@@ -1830,6 +2026,7 @@ export {
|
|
|
1830
2026
|
toStoreSegments,
|
|
1831
2027
|
toThreadSpendRows,
|
|
1832
2028
|
toToolStatTableRows,
|
|
2029
|
+
toTtftDistribution,
|
|
1833
2030
|
toUsageTrendRows,
|
|
1834
2031
|
totalCostUsd,
|
|
1835
2032
|
totalTokens,
|