@agentmark-ai/api-types 0.3.0 → 0.5.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/types.d.ts +136 -12
- package/package.json +2 -2
package/dist/types.d.ts
CHANGED
|
@@ -99,6 +99,42 @@ export interface ModelStats {
|
|
|
99
99
|
export interface ModelStatsResponse {
|
|
100
100
|
models: ModelStats[];
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Aggregates for one (promptName, commitSha) pair — the per-version metrics
|
|
104
|
+
* behind prompt-version trace linking. `commitSha` is `''` for spans ingested
|
|
105
|
+
* before version stamping (or from paths with no commit to stamp).
|
|
106
|
+
*/
|
|
107
|
+
export interface PromptVersionStats {
|
|
108
|
+
promptName: string;
|
|
109
|
+
commitSha: string;
|
|
110
|
+
requests: number;
|
|
111
|
+
errorCount: number;
|
|
112
|
+
errorRate: number;
|
|
113
|
+
cost: number;
|
|
114
|
+
tokens: number;
|
|
115
|
+
avgLatencyMs: number;
|
|
116
|
+
/** Average score across all scores attached to this version's traces; null when unscored. */
|
|
117
|
+
avgScore: number | null;
|
|
118
|
+
/** Number of score rows behind `avgScore`. */
|
|
119
|
+
scoreCount: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Parameters for the per-prompt-version stats query.
|
|
123
|
+
*/
|
|
124
|
+
export interface PromptVersionStatsParams {
|
|
125
|
+
/** Restrict to a single prompt name. Omit for all prompts. */
|
|
126
|
+
promptName?: string;
|
|
127
|
+
/** Max number of (prompt, version) rows returned. */
|
|
128
|
+
limit?: number;
|
|
129
|
+
/** Single-env scoping. Mirrors ScoresParams. Undefined = no env filter. */
|
|
130
|
+
env?: EnvironmentQueryScope;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Response for the per-prompt-version stats query.
|
|
134
|
+
*/
|
|
135
|
+
export interface PromptVersionStatsResponse {
|
|
136
|
+
versions: PromptVersionStats[];
|
|
137
|
+
}
|
|
102
138
|
/**
|
|
103
139
|
* A single ranking item for dimension-grouped queries.
|
|
104
140
|
* Used by getRankingData to return data grouped by any dimension
|
|
@@ -174,6 +210,16 @@ export interface SavedViewConfig {
|
|
|
174
210
|
field: string;
|
|
175
211
|
visible: boolean;
|
|
176
212
|
}>;
|
|
213
|
+
/**
|
|
214
|
+
* Env-scoped saved filter (feature 054, FR-122..FR-125). An array of env
|
|
215
|
+
* *name* strings (NOT ids — FR-124: names are immutable and match the
|
|
216
|
+
* trace-tag mechanism). Multi-select so "prod OR staging" round-trips.
|
|
217
|
+
* The evaluator translates this to `Environment IN (...)`. A saved view
|
|
218
|
+
* naming a deleted/renamed env keeps working — it matches historical
|
|
219
|
+
* traces tagged with that name; the editor surfaces a non-blocking note
|
|
220
|
+
* (FR-125) but never invalidates or auto-edits the field.
|
|
221
|
+
*/
|
|
222
|
+
environments?: string[];
|
|
177
223
|
}
|
|
178
224
|
/**
|
|
179
225
|
* Type guard for v3 saved view configs.
|
|
@@ -213,6 +259,34 @@ export interface AggregateRequestsParams extends PaginationParams {
|
|
|
213
259
|
startDate?: string;
|
|
214
260
|
endDate?: string;
|
|
215
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Environment scoping for analytics list queries (feature 054 — Environments
|
|
264
|
+
* & Promotion). `name` is the env tag stamped on `otel_traces.Environment` /
|
|
265
|
+
* `scores.Environment` by the gateway. `isDefault` drives the FR-051 legacy
|
|
266
|
+
* rule: rows with `Environment = ''` (pre-feature ingest) are included ONLY
|
|
267
|
+
* when scoping to the app's default env — for any non-default env those
|
|
268
|
+
* legacy rows are excluded.
|
|
269
|
+
*/
|
|
270
|
+
export interface EnvironmentScope {
|
|
271
|
+
name: string;
|
|
272
|
+
isDefault: boolean;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Combined env scope for analytics metric queries (feature 054, FR-126).
|
|
276
|
+
* Composes the single-env {@link EnvironmentScope} with the multi-env
|
|
277
|
+
* allow-list, mirroring the `environment` + `environments` field pair on
|
|
278
|
+
* {@link TracesParams} / {@link ScoresParams}. Used by the dashboard widget
|
|
279
|
+
* metric methods (`getMetrics`, `getModelStats`, `getRankingData`,
|
|
280
|
+
* `getPercentiles`) so a built-in or custom widget can be scoped to one env
|
|
281
|
+
* or — for cross-env comparison widgets — an env allow-list. Undefined on a
|
|
282
|
+
* call means "no env filter".
|
|
283
|
+
*/
|
|
284
|
+
export interface EnvironmentQueryScope {
|
|
285
|
+
/** Single-env scope (env-selector default / dashboard-view env). */
|
|
286
|
+
environment?: EnvironmentScope;
|
|
287
|
+
/** Multi-env allow-list — translates to `Environment IN (...)`. */
|
|
288
|
+
environments?: string[];
|
|
289
|
+
}
|
|
216
290
|
/**
|
|
217
291
|
* Parameters for listing traces.
|
|
218
292
|
*/
|
|
@@ -230,6 +304,14 @@ export interface TracesParams extends PaginationParams {
|
|
|
230
304
|
filters?: AnalyticsFilter[];
|
|
231
305
|
sortBy?: string;
|
|
232
306
|
sortOrder?: 'asc' | 'desc';
|
|
307
|
+
/** Single-env scoping per FR-031/FR-051. Undefined = no env filter. */
|
|
308
|
+
environment?: EnvironmentScope;
|
|
309
|
+
/**
|
|
310
|
+
* Env-name allow-list from a saved filter's `environments` JSONB field
|
|
311
|
+
* (FR-122..FR-124). When set, translates to `Environment IN (...)`. Takes
|
|
312
|
+
* precedence over the single-env `environment` scope when both are present.
|
|
313
|
+
*/
|
|
314
|
+
environments?: string[];
|
|
233
315
|
}
|
|
234
316
|
/**
|
|
235
317
|
* Summary of a trace for list views.
|
|
@@ -245,6 +327,10 @@ export interface TraceSummary {
|
|
|
245
327
|
tokens: number;
|
|
246
328
|
spanCount: number;
|
|
247
329
|
tags?: string[];
|
|
330
|
+
/** Env tag (feature 054). `''` marks legacy/no-pin rows per FR-051. */
|
|
331
|
+
environment?: string;
|
|
332
|
+
/** Env version at ingest (feature 054). `0` marks legacy/no-pin rows. */
|
|
333
|
+
environmentVersion?: number;
|
|
248
334
|
}
|
|
249
335
|
/**
|
|
250
336
|
* Paginated response for trace listing.
|
|
@@ -295,6 +381,13 @@ export interface SpanIO {
|
|
|
295
381
|
output: string;
|
|
296
382
|
outputObject: string | null;
|
|
297
383
|
toolCalls: string | null;
|
|
384
|
+
/**
|
|
385
|
+
* Custom per-span metadata (raw map; reserved namespaces stripped at the API
|
|
386
|
+
* boundary). Optional on the internal type so existing producers/mocks need
|
|
387
|
+
* not be updated wholesale; the wire shapes (SpanIOSchema / SpanIOWire) keep
|
|
388
|
+
* it required and the gateway + CLI always populate it.
|
|
389
|
+
*/
|
|
390
|
+
metadata?: Record<string, string>;
|
|
298
391
|
}
|
|
299
392
|
/**
|
|
300
393
|
* Complete trace detail with all spans.
|
|
@@ -328,9 +421,18 @@ export interface SessionsParams extends PaginationParams {
|
|
|
328
421
|
search?: string;
|
|
329
422
|
sortBy?: string;
|
|
330
423
|
sortOrder?: 'asc' | 'desc';
|
|
424
|
+
/** Single-env scoping per FR-031/FR-051. Undefined = no env filter. */
|
|
425
|
+
environment?: EnvironmentScope;
|
|
426
|
+
/** Env-name allow-list from a saved filter (FR-122..FR-124). */
|
|
427
|
+
environments?: string[];
|
|
331
428
|
}
|
|
332
429
|
/**
|
|
333
430
|
* Summary of a session for list views.
|
|
431
|
+
*
|
|
432
|
+
* Feature 054 (FR-118..FR-120): a session is identified by the tuple
|
|
433
|
+
* `(SessionId, Environment)`, not `SessionId` alone. `id` is the SessionId;
|
|
434
|
+
* `environment` is the second half of the identity. The same SessionId
|
|
435
|
+
* appearing under two envs yields two distinct `SessionSummary` rows.
|
|
334
436
|
*/
|
|
335
437
|
export interface SessionSummary {
|
|
336
438
|
id: string;
|
|
@@ -342,6 +444,10 @@ export interface SessionSummary {
|
|
|
342
444
|
totalTokens: number;
|
|
343
445
|
latencyMs: number;
|
|
344
446
|
tags?: string[];
|
|
447
|
+
/** Env half of the `(SessionId, Environment)` identity (FR-118). */
|
|
448
|
+
environment?: string;
|
|
449
|
+
/** Env version at ingest (feature 054). `0` marks legacy/no-pin rows. */
|
|
450
|
+
environmentVersion?: number;
|
|
345
451
|
}
|
|
346
452
|
/**
|
|
347
453
|
* Paginated response for session listing.
|
|
@@ -476,6 +582,10 @@ export interface ExperimentParams extends Partial<PaginationParams> {
|
|
|
476
582
|
endDate?: string;
|
|
477
583
|
promptName?: string;
|
|
478
584
|
datasetPath?: string;
|
|
585
|
+
/** Single-env scope — mirrors {@link TracesParams.environment} / {@link ScoresParams.environment}. */
|
|
586
|
+
environment?: EnvironmentScope;
|
|
587
|
+
/** Multi-env allow-list — mirrors {@link TracesParams.environments} / {@link ScoresParams.environments}. */
|
|
588
|
+
environments?: string[];
|
|
479
589
|
}
|
|
480
590
|
/**
|
|
481
591
|
* Paginated response for experiments listing.
|
|
@@ -516,6 +626,10 @@ export interface ScoresParams extends Partial<PaginationParams> {
|
|
|
516
626
|
sessionId?: string;
|
|
517
627
|
startDate?: string;
|
|
518
628
|
endDate?: string;
|
|
629
|
+
/** Single-env scoping per FR-031/FR-051/FR-109. Undefined = no env filter. */
|
|
630
|
+
environment?: EnvironmentScope;
|
|
631
|
+
/** Env-name allow-list from a saved filter (FR-122..FR-124). */
|
|
632
|
+
environments?: string[];
|
|
519
633
|
}
|
|
520
634
|
/**
|
|
521
635
|
* Paginated response for scores listing.
|
|
@@ -761,24 +875,30 @@ export interface TraceFilterConfig {
|
|
|
761
875
|
*/
|
|
762
876
|
export interface IAnalyticsService {
|
|
763
877
|
checkConnectivity(): Promise<boolean>;
|
|
764
|
-
getMetrics(ctx: TenantContext, dateRange: DateRange, filters?: AnalyticsFilter[]): Promise<MetricsResponse>;
|
|
765
|
-
getExtendedMetrics(ctx: TenantContext, dateRange: DateRange): Promise<ExtendedMetricsResponse>;
|
|
766
|
-
getModelStats(ctx: TenantContext, dateRange: DateRange, limit?: number, filters?: AnalyticsFilter[]): Promise<ModelStatsResponse>;
|
|
878
|
+
getMetrics(ctx: TenantContext, dateRange: DateRange, filters?: AnalyticsFilter[], env?: EnvironmentQueryScope): Promise<MetricsResponse>;
|
|
879
|
+
getExtendedMetrics(ctx: TenantContext, dateRange: DateRange, env?: EnvironmentQueryScope): Promise<ExtendedMetricsResponse>;
|
|
880
|
+
getModelStats(ctx: TenantContext, dateRange: DateRange, limit?: number, filters?: AnalyticsFilter[], env?: EnvironmentQueryScope): Promise<ModelStatsResponse>;
|
|
881
|
+
/**
|
|
882
|
+
* Per (promptName, commitSha) aggregates — prompt-version trace linking.
|
|
883
|
+
* Optional so existing implementers (e.g. the CLI's local service) remain
|
|
884
|
+
* source-compatible; the cloud AnalyticsService implements it.
|
|
885
|
+
*/
|
|
886
|
+
getPromptVersionStats?(ctx: TenantContext, dateRange: DateRange, params?: PromptVersionStatsParams): Promise<PromptVersionStatsResponse>;
|
|
767
887
|
getTraces(ctx: TenantContext, params: TracesParams): Promise<TracesResponse>;
|
|
768
|
-
getTraceDetail(ctx: TenantContext, traceId: string): Promise<TraceDetail | null>;
|
|
769
|
-
getTraceDetailLightweight(ctx: TenantContext, traceId: string): Promise<TraceDetail | null>;
|
|
770
|
-
getSpanIO(ctx: TenantContext, traceId: string, spanId: string): Promise<SpanIO | null>;
|
|
888
|
+
getTraceDetail(ctx: TenantContext, traceId: string, env?: EnvironmentQueryScope): Promise<TraceDetail | null>;
|
|
889
|
+
getTraceDetailLightweight(ctx: TenantContext, traceId: string, env?: EnvironmentQueryScope): Promise<TraceDetail | null>;
|
|
890
|
+
getSpanIO(ctx: TenantContext, traceId: string, spanId: string, env?: EnvironmentQueryScope): Promise<SpanIO | null>;
|
|
771
891
|
getSessions(ctx: TenantContext, params: SessionsParams): Promise<SessionsResponse>;
|
|
772
|
-
getSessionTraces(ctx: TenantContext, sessionId: string): Promise<TraceDetail[]>;
|
|
773
|
-
getPercentiles(ctx: TenantContext, params: PercentilesParams, filters?: AnalyticsFilter[]): Promise<PercentilesResponse>;
|
|
892
|
+
getSessionTraces(ctx: TenantContext, sessionId: string, env?: EnvironmentQueryScope): Promise<TraceDetail[]>;
|
|
893
|
+
getPercentiles(ctx: TenantContext, params: PercentilesParams, filters?: AnalyticsFilter[], env?: EnvironmentQueryScope): Promise<PercentilesResponse>;
|
|
774
894
|
getDatasetRuns(ctx: TenantContext, params: DatasetRunParams): Promise<DatasetRunsResponse>;
|
|
775
895
|
getDatasetRunDetail(ctx: TenantContext, runId: string): Promise<DatasetRunDetail | null>;
|
|
776
896
|
getExperiments(ctx: TenantContext, params: ExperimentParams): Promise<ExperimentsResponse>;
|
|
777
|
-
getExperimentDetail(ctx: TenantContext, experimentId: string): Promise<ExperimentDetail | null>;
|
|
897
|
+
getExperimentDetail(ctx: TenantContext, experimentId: string, env?: EnvironmentQueryScope): Promise<ExperimentDetail | null>;
|
|
778
898
|
getScores(ctx: TenantContext, params: ScoresParams): Promise<ScoresResponse>;
|
|
779
899
|
getScoresBySpanIds(ctx: TenantContext, spanIds: string[]): Promise<Record<string, Score[]>>;
|
|
780
|
-
getScoreAggregations(ctx: TenantContext, dateRange: DateRange): Promise<ScoreAggregationsResponse>;
|
|
781
|
-
getDistinctScoreNames(ctx: TenantContext): Promise<ScoreNamesResponse>;
|
|
900
|
+
getScoreAggregations(ctx: TenantContext, dateRange: DateRange, env?: EnvironmentQueryScope): Promise<ScoreAggregationsResponse>;
|
|
901
|
+
getDistinctScoreNames(ctx: TenantContext, env?: EnvironmentQueryScope): Promise<ScoreNamesResponse>;
|
|
782
902
|
detectScoreType(ctx: TenantContext, name: string): Promise<ScoreType>;
|
|
783
903
|
getScoreHistogram(ctx: TenantContext, name: string, dateRange: DateRange, source?: string): Promise<ScoreHistogramResponse>;
|
|
784
904
|
getScoreTrend(ctx: TenantContext, name: string, interval: ScoreTrendInterval, dateRange: DateRange, source?: string): Promise<ScoreTrendResponse>;
|
|
@@ -786,7 +906,7 @@ export interface IAnalyticsService {
|
|
|
786
906
|
getScoreScatter(ctx: TenantContext, nameA: string, nameB: string, dateRange: DateRange, source?: string): Promise<ScoreScatterResponse>;
|
|
787
907
|
getDistinctMetadataKeys(ctx: TenantContext): Promise<string[]>;
|
|
788
908
|
getRequests(ctx: TenantContext, params: RequestsParams): Promise<RequestsResponse>;
|
|
789
|
-
getRankingData(ctx: TenantContext, dateRange: DateRange, dimension: string, limit?: number, filters?: AnalyticsFilter[]): Promise<RankingDataResponse>;
|
|
909
|
+
getRankingData(ctx: TenantContext, dateRange: DateRange, dimension: string, limit?: number, filters?: AnalyticsFilter[], env?: EnvironmentQueryScope): Promise<RankingDataResponse>;
|
|
790
910
|
getAggregateRequests(ctx: TenantContext, params: AggregateRequestsParams): Promise<AggregateRequestsResponse>;
|
|
791
911
|
getSpanKindBreakdown(ctx: TenantContext, dateRange: {
|
|
792
912
|
startDate: string;
|
|
@@ -812,6 +932,10 @@ export interface RequestsParams extends PaginationParams {
|
|
|
812
932
|
sortField?: string;
|
|
813
933
|
sortOrder?: 'asc' | 'desc';
|
|
814
934
|
filters?: AnalyticsFilter[];
|
|
935
|
+
/** Single-env scoping (FR-005). Mirrors ScoresParams. Undefined = no env filter. */
|
|
936
|
+
environment?: EnvironmentScope;
|
|
937
|
+
/** Env-name allow-list from a saved filter. Mirrors ScoresParams. */
|
|
938
|
+
environments?: string[];
|
|
815
939
|
}
|
|
816
940
|
/**
|
|
817
941
|
* Request record (GENERATION-type trace with input/output).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentmark-ai/api-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Shared API contract types for AgentMark services",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"clean": "rm -rf dist"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@agentmark-ai/api-schemas": "0.
|
|
18
|
+
"@agentmark-ai/api-schemas": "0.4.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"typescript": "^5.5.3"
|