@agentmark-ai/api-types 0.2.0 → 0.4.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 +94 -12
- package/package.json +2 -2
package/dist/types.d.ts
CHANGED
|
@@ -174,6 +174,16 @@ export interface SavedViewConfig {
|
|
|
174
174
|
field: string;
|
|
175
175
|
visible: boolean;
|
|
176
176
|
}>;
|
|
177
|
+
/**
|
|
178
|
+
* Env-scoped saved filter (feature 054, FR-122..FR-125). An array of env
|
|
179
|
+
* *name* strings (NOT ids — FR-124: names are immutable and match the
|
|
180
|
+
* trace-tag mechanism). Multi-select so "prod OR staging" round-trips.
|
|
181
|
+
* The evaluator translates this to `Environment IN (...)`. A saved view
|
|
182
|
+
* naming a deleted/renamed env keeps working — it matches historical
|
|
183
|
+
* traces tagged with that name; the editor surfaces a non-blocking note
|
|
184
|
+
* (FR-125) but never invalidates or auto-edits the field.
|
|
185
|
+
*/
|
|
186
|
+
environments?: string[];
|
|
177
187
|
}
|
|
178
188
|
/**
|
|
179
189
|
* Type guard for v3 saved view configs.
|
|
@@ -213,6 +223,34 @@ export interface AggregateRequestsParams extends PaginationParams {
|
|
|
213
223
|
startDate?: string;
|
|
214
224
|
endDate?: string;
|
|
215
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Environment scoping for analytics list queries (feature 054 — Environments
|
|
228
|
+
* & Promotion). `name` is the env tag stamped on `otel_traces.Environment` /
|
|
229
|
+
* `scores.Environment` by the gateway. `isDefault` drives the FR-051 legacy
|
|
230
|
+
* rule: rows with `Environment = ''` (pre-feature ingest) are included ONLY
|
|
231
|
+
* when scoping to the app's default env — for any non-default env those
|
|
232
|
+
* legacy rows are excluded.
|
|
233
|
+
*/
|
|
234
|
+
export interface EnvironmentScope {
|
|
235
|
+
name: string;
|
|
236
|
+
isDefault: boolean;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Combined env scope for analytics metric queries (feature 054, FR-126).
|
|
240
|
+
* Composes the single-env {@link EnvironmentScope} with the multi-env
|
|
241
|
+
* allow-list, mirroring the `environment` + `environments` field pair on
|
|
242
|
+
* {@link TracesParams} / {@link ScoresParams}. Used by the dashboard widget
|
|
243
|
+
* metric methods (`getMetrics`, `getModelStats`, `getRankingData`,
|
|
244
|
+
* `getPercentiles`) so a built-in or custom widget can be scoped to one env
|
|
245
|
+
* or — for cross-env comparison widgets — an env allow-list. Undefined on a
|
|
246
|
+
* call means "no env filter".
|
|
247
|
+
*/
|
|
248
|
+
export interface EnvironmentQueryScope {
|
|
249
|
+
/** Single-env scope (env-selector default / dashboard-view env). */
|
|
250
|
+
environment?: EnvironmentScope;
|
|
251
|
+
/** Multi-env allow-list — translates to `Environment IN (...)`. */
|
|
252
|
+
environments?: string[];
|
|
253
|
+
}
|
|
216
254
|
/**
|
|
217
255
|
* Parameters for listing traces.
|
|
218
256
|
*/
|
|
@@ -230,6 +268,14 @@ export interface TracesParams extends PaginationParams {
|
|
|
230
268
|
filters?: AnalyticsFilter[];
|
|
231
269
|
sortBy?: string;
|
|
232
270
|
sortOrder?: 'asc' | 'desc';
|
|
271
|
+
/** Single-env scoping per FR-031/FR-051. Undefined = no env filter. */
|
|
272
|
+
environment?: EnvironmentScope;
|
|
273
|
+
/**
|
|
274
|
+
* Env-name allow-list from a saved filter's `environments` JSONB field
|
|
275
|
+
* (FR-122..FR-124). When set, translates to `Environment IN (...)`. Takes
|
|
276
|
+
* precedence over the single-env `environment` scope when both are present.
|
|
277
|
+
*/
|
|
278
|
+
environments?: string[];
|
|
233
279
|
}
|
|
234
280
|
/**
|
|
235
281
|
* Summary of a trace for list views.
|
|
@@ -245,6 +291,10 @@ export interface TraceSummary {
|
|
|
245
291
|
tokens: number;
|
|
246
292
|
spanCount: number;
|
|
247
293
|
tags?: string[];
|
|
294
|
+
/** Env tag (feature 054). `''` marks legacy/no-pin rows per FR-051. */
|
|
295
|
+
environment?: string;
|
|
296
|
+
/** Env version at ingest (feature 054). `0` marks legacy/no-pin rows. */
|
|
297
|
+
environmentVersion?: number;
|
|
248
298
|
}
|
|
249
299
|
/**
|
|
250
300
|
* Paginated response for trace listing.
|
|
@@ -295,6 +345,13 @@ export interface SpanIO {
|
|
|
295
345
|
output: string;
|
|
296
346
|
outputObject: string | null;
|
|
297
347
|
toolCalls: string | null;
|
|
348
|
+
/**
|
|
349
|
+
* Custom per-span metadata (raw map; reserved namespaces stripped at the API
|
|
350
|
+
* boundary). Optional on the internal type so existing producers/mocks need
|
|
351
|
+
* not be updated wholesale; the wire shapes (SpanIOSchema / SpanIOWire) keep
|
|
352
|
+
* it required and the gateway + CLI always populate it.
|
|
353
|
+
*/
|
|
354
|
+
metadata?: Record<string, string>;
|
|
298
355
|
}
|
|
299
356
|
/**
|
|
300
357
|
* Complete trace detail with all spans.
|
|
@@ -328,9 +385,18 @@ export interface SessionsParams extends PaginationParams {
|
|
|
328
385
|
search?: string;
|
|
329
386
|
sortBy?: string;
|
|
330
387
|
sortOrder?: 'asc' | 'desc';
|
|
388
|
+
/** Single-env scoping per FR-031/FR-051. Undefined = no env filter. */
|
|
389
|
+
environment?: EnvironmentScope;
|
|
390
|
+
/** Env-name allow-list from a saved filter (FR-122..FR-124). */
|
|
391
|
+
environments?: string[];
|
|
331
392
|
}
|
|
332
393
|
/**
|
|
333
394
|
* Summary of a session for list views.
|
|
395
|
+
*
|
|
396
|
+
* Feature 054 (FR-118..FR-120): a session is identified by the tuple
|
|
397
|
+
* `(SessionId, Environment)`, not `SessionId` alone. `id` is the SessionId;
|
|
398
|
+
* `environment` is the second half of the identity. The same SessionId
|
|
399
|
+
* appearing under two envs yields two distinct `SessionSummary` rows.
|
|
334
400
|
*/
|
|
335
401
|
export interface SessionSummary {
|
|
336
402
|
id: string;
|
|
@@ -342,6 +408,10 @@ export interface SessionSummary {
|
|
|
342
408
|
totalTokens: number;
|
|
343
409
|
latencyMs: number;
|
|
344
410
|
tags?: string[];
|
|
411
|
+
/** Env half of the `(SessionId, Environment)` identity (FR-118). */
|
|
412
|
+
environment?: string;
|
|
413
|
+
/** Env version at ingest (feature 054). `0` marks legacy/no-pin rows. */
|
|
414
|
+
environmentVersion?: number;
|
|
345
415
|
}
|
|
346
416
|
/**
|
|
347
417
|
* Paginated response for session listing.
|
|
@@ -476,6 +546,10 @@ export interface ExperimentParams extends Partial<PaginationParams> {
|
|
|
476
546
|
endDate?: string;
|
|
477
547
|
promptName?: string;
|
|
478
548
|
datasetPath?: string;
|
|
549
|
+
/** Single-env scope — mirrors {@link TracesParams.environment} / {@link ScoresParams.environment}. */
|
|
550
|
+
environment?: EnvironmentScope;
|
|
551
|
+
/** Multi-env allow-list — mirrors {@link TracesParams.environments} / {@link ScoresParams.environments}. */
|
|
552
|
+
environments?: string[];
|
|
479
553
|
}
|
|
480
554
|
/**
|
|
481
555
|
* Paginated response for experiments listing.
|
|
@@ -516,6 +590,10 @@ export interface ScoresParams extends Partial<PaginationParams> {
|
|
|
516
590
|
sessionId?: string;
|
|
517
591
|
startDate?: string;
|
|
518
592
|
endDate?: string;
|
|
593
|
+
/** Single-env scoping per FR-031/FR-051/FR-109. Undefined = no env filter. */
|
|
594
|
+
environment?: EnvironmentScope;
|
|
595
|
+
/** Env-name allow-list from a saved filter (FR-122..FR-124). */
|
|
596
|
+
environments?: string[];
|
|
519
597
|
}
|
|
520
598
|
/**
|
|
521
599
|
* Paginated response for scores listing.
|
|
@@ -761,24 +839,24 @@ export interface TraceFilterConfig {
|
|
|
761
839
|
*/
|
|
762
840
|
export interface IAnalyticsService {
|
|
763
841
|
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>;
|
|
842
|
+
getMetrics(ctx: TenantContext, dateRange: DateRange, filters?: AnalyticsFilter[], env?: EnvironmentQueryScope): Promise<MetricsResponse>;
|
|
843
|
+
getExtendedMetrics(ctx: TenantContext, dateRange: DateRange, env?: EnvironmentQueryScope): Promise<ExtendedMetricsResponse>;
|
|
844
|
+
getModelStats(ctx: TenantContext, dateRange: DateRange, limit?: number, filters?: AnalyticsFilter[], env?: EnvironmentQueryScope): Promise<ModelStatsResponse>;
|
|
767
845
|
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>;
|
|
846
|
+
getTraceDetail(ctx: TenantContext, traceId: string, env?: EnvironmentQueryScope): Promise<TraceDetail | null>;
|
|
847
|
+
getTraceDetailLightweight(ctx: TenantContext, traceId: string, env?: EnvironmentQueryScope): Promise<TraceDetail | null>;
|
|
848
|
+
getSpanIO(ctx: TenantContext, traceId: string, spanId: string, env?: EnvironmentQueryScope): Promise<SpanIO | null>;
|
|
771
849
|
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>;
|
|
850
|
+
getSessionTraces(ctx: TenantContext, sessionId: string, env?: EnvironmentQueryScope): Promise<TraceDetail[]>;
|
|
851
|
+
getPercentiles(ctx: TenantContext, params: PercentilesParams, filters?: AnalyticsFilter[], env?: EnvironmentQueryScope): Promise<PercentilesResponse>;
|
|
774
852
|
getDatasetRuns(ctx: TenantContext, params: DatasetRunParams): Promise<DatasetRunsResponse>;
|
|
775
853
|
getDatasetRunDetail(ctx: TenantContext, runId: string): Promise<DatasetRunDetail | null>;
|
|
776
854
|
getExperiments(ctx: TenantContext, params: ExperimentParams): Promise<ExperimentsResponse>;
|
|
777
|
-
getExperimentDetail(ctx: TenantContext, experimentId: string): Promise<ExperimentDetail | null>;
|
|
855
|
+
getExperimentDetail(ctx: TenantContext, experimentId: string, env?: EnvironmentQueryScope): Promise<ExperimentDetail | null>;
|
|
778
856
|
getScores(ctx: TenantContext, params: ScoresParams): Promise<ScoresResponse>;
|
|
779
857
|
getScoresBySpanIds(ctx: TenantContext, spanIds: string[]): Promise<Record<string, Score[]>>;
|
|
780
|
-
getScoreAggregations(ctx: TenantContext, dateRange: DateRange): Promise<ScoreAggregationsResponse>;
|
|
781
|
-
getDistinctScoreNames(ctx: TenantContext): Promise<ScoreNamesResponse>;
|
|
858
|
+
getScoreAggregations(ctx: TenantContext, dateRange: DateRange, env?: EnvironmentQueryScope): Promise<ScoreAggregationsResponse>;
|
|
859
|
+
getDistinctScoreNames(ctx: TenantContext, env?: EnvironmentQueryScope): Promise<ScoreNamesResponse>;
|
|
782
860
|
detectScoreType(ctx: TenantContext, name: string): Promise<ScoreType>;
|
|
783
861
|
getScoreHistogram(ctx: TenantContext, name: string, dateRange: DateRange, source?: string): Promise<ScoreHistogramResponse>;
|
|
784
862
|
getScoreTrend(ctx: TenantContext, name: string, interval: ScoreTrendInterval, dateRange: DateRange, source?: string): Promise<ScoreTrendResponse>;
|
|
@@ -786,7 +864,7 @@ export interface IAnalyticsService {
|
|
|
786
864
|
getScoreScatter(ctx: TenantContext, nameA: string, nameB: string, dateRange: DateRange, source?: string): Promise<ScoreScatterResponse>;
|
|
787
865
|
getDistinctMetadataKeys(ctx: TenantContext): Promise<string[]>;
|
|
788
866
|
getRequests(ctx: TenantContext, params: RequestsParams): Promise<RequestsResponse>;
|
|
789
|
-
getRankingData(ctx: TenantContext, dateRange: DateRange, dimension: string, limit?: number, filters?: AnalyticsFilter[]): Promise<RankingDataResponse>;
|
|
867
|
+
getRankingData(ctx: TenantContext, dateRange: DateRange, dimension: string, limit?: number, filters?: AnalyticsFilter[], env?: EnvironmentQueryScope): Promise<RankingDataResponse>;
|
|
790
868
|
getAggregateRequests(ctx: TenantContext, params: AggregateRequestsParams): Promise<AggregateRequestsResponse>;
|
|
791
869
|
getSpanKindBreakdown(ctx: TenantContext, dateRange: {
|
|
792
870
|
startDate: string;
|
|
@@ -812,6 +890,10 @@ export interface RequestsParams extends PaginationParams {
|
|
|
812
890
|
sortField?: string;
|
|
813
891
|
sortOrder?: 'asc' | 'desc';
|
|
814
892
|
filters?: AnalyticsFilter[];
|
|
893
|
+
/** Single-env scoping (FR-005). Mirrors ScoresParams. Undefined = no env filter. */
|
|
894
|
+
environment?: EnvironmentScope;
|
|
895
|
+
/** Env-name allow-list from a saved filter. Mirrors ScoresParams. */
|
|
896
|
+
environments?: string[];
|
|
815
897
|
}
|
|
816
898
|
/**
|
|
817
899
|
* 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.4.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"
|