@rustrak/client 0.14.2 → 0.14.4
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 +141 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +86 -1
- package/dist/index.d.ts +86 -1
- package/dist/index.js +141 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -59,8 +59,40 @@ var agentTraceSummarySchema = zod.z.object({
|
|
|
59
59
|
duration_ms: zod.z.number().nullable(),
|
|
60
60
|
total_tokens: zod.z.number(),
|
|
61
61
|
tool_call_count: zod.z.number().int(),
|
|
62
|
+
/** `ai_client` spans: how many times a model was actually called. */
|
|
63
|
+
llm_call_count: zod.z.number().int(),
|
|
64
|
+
/** AI spans in this trace whose status is set and not `ok`. */
|
|
65
|
+
error_count: zod.z.number().int(),
|
|
62
66
|
started_at: dateTimeSchema
|
|
63
67
|
});
|
|
68
|
+
var agentSummarySchema = zod.z.object({
|
|
69
|
+
agent_runs: zod.z.number().int(),
|
|
70
|
+
llm_calls: zod.z.number().int(),
|
|
71
|
+
tool_calls: zod.z.number().int(),
|
|
72
|
+
error_count: zod.z.number().int(),
|
|
73
|
+
total_tokens: zod.z.number(),
|
|
74
|
+
avg_duration_ms: zod.z.number(),
|
|
75
|
+
p95_duration_ms: zod.z.number()
|
|
76
|
+
});
|
|
77
|
+
var agentModelRowSchema = zod.z.object({
|
|
78
|
+
model: zod.z.string(),
|
|
79
|
+
requests: zod.z.number().int(),
|
|
80
|
+
errors: zod.z.number().int(),
|
|
81
|
+
avg_ms: zod.z.number(),
|
|
82
|
+
p95_ms: zod.z.number(),
|
|
83
|
+
input_tokens: zod.z.number(),
|
|
84
|
+
cached_input_tokens: zod.z.number(),
|
|
85
|
+
output_tokens: zod.z.number(),
|
|
86
|
+
reasoning_output_tokens: zod.z.number(),
|
|
87
|
+
total_tokens: zod.z.number()
|
|
88
|
+
});
|
|
89
|
+
var agentToolRowSchema = zod.z.object({
|
|
90
|
+
tool: zod.z.string(),
|
|
91
|
+
calls: zod.z.number().int(),
|
|
92
|
+
errors: zod.z.number().int(),
|
|
93
|
+
avg_ms: zod.z.number(),
|
|
94
|
+
p95_ms: zod.z.number()
|
|
95
|
+
});
|
|
64
96
|
var providerTypeSchema = zod.z.enum(["webhook", "email", "slack"]);
|
|
65
97
|
var alertTypeSchema = zod.z.enum(["new_issue", "regression", "unmute"]);
|
|
66
98
|
var alertStatusSchema = zod.z.enum([
|
|
@@ -598,7 +630,7 @@ var spanSchema = zod.z.object({
|
|
|
598
630
|
exclusive_time_ms: zod.z.number().nullable(),
|
|
599
631
|
is_segment: zod.z.boolean(),
|
|
600
632
|
segment_id: zod.z.string().nullable(),
|
|
601
|
-
/**
|
|
633
|
+
/** Reported by the span itself, or stamped from its parent transaction. Null only for rows ingested before that stamping existed. */
|
|
602
634
|
platform: zod.z.string().nullable(),
|
|
603
635
|
release: zod.z.string().nullable(),
|
|
604
636
|
environment: zod.z.string().nullable(),
|
|
@@ -613,6 +645,11 @@ var spanSchema = zod.z.object({
|
|
|
613
645
|
gen_ai_usage_output_tokens: zod.z.number().nullable(),
|
|
614
646
|
gen_ai_usage_total_tokens: zod.z.number().nullable()
|
|
615
647
|
});
|
|
648
|
+
var spanDetailSchema = spanSchema.extend({
|
|
649
|
+
attributes: zod.z.record(zod.z.string(), zod.z.any()),
|
|
650
|
+
/** Always absent for a Spans Protocol v2 span: v2 has no tags concept. */
|
|
651
|
+
tags: zod.z.record(zod.z.string(), zod.z.any()).nullish()
|
|
652
|
+
});
|
|
616
653
|
var transactionStatsSchema = zod.z.object({
|
|
617
654
|
transaction_name: zod.z.string(),
|
|
618
655
|
op: zod.z.string().nullable(),
|
|
@@ -626,7 +663,21 @@ var userSchema = zod.z.object({
|
|
|
626
663
|
id: zod.z.number().int().positive(),
|
|
627
664
|
email: zod.z.string().email(),
|
|
628
665
|
role: globalRoleSchema,
|
|
629
|
-
is_admin: zod.z.boolean()
|
|
666
|
+
is_admin: zod.z.boolean(),
|
|
667
|
+
/**
|
|
668
|
+
* The dashboard language this user chose.
|
|
669
|
+
*
|
|
670
|
+
* `null` means they never chose one, which a consumer should treat as
|
|
671
|
+
* "infer it" rather than as English. Optional as well as nullable so a
|
|
672
|
+
* client stays compatible with a server predating the column.
|
|
673
|
+
*/
|
|
674
|
+
language: zod.z.string().nullable().optional(),
|
|
675
|
+
/** The IANA timezone this user chose, `null` when they never chose one. */
|
|
676
|
+
timezone: zod.z.string().nullable().optional()
|
|
677
|
+
});
|
|
678
|
+
var updatePreferencesRequestSchema = zod.z.object({
|
|
679
|
+
language: zod.z.string().nullable().optional(),
|
|
680
|
+
timezone: zod.z.string().nullable().optional()
|
|
630
681
|
});
|
|
631
682
|
var authResponseSchema = zod.z.object({
|
|
632
683
|
user: userSchema
|
|
@@ -991,6 +1042,9 @@ function timeseriesSearchParams(options) {
|
|
|
991
1042
|
if (options?.interval_hours) {
|
|
992
1043
|
searchParams.interval_hours = String(options.interval_hours);
|
|
993
1044
|
}
|
|
1045
|
+
if (options?.environment) {
|
|
1046
|
+
searchParams.environment = options.environment;
|
|
1047
|
+
}
|
|
994
1048
|
return searchParams;
|
|
995
1049
|
}
|
|
996
1050
|
function breakdownSearchParams(options) {
|
|
@@ -1001,6 +1055,9 @@ function breakdownSearchParams(options) {
|
|
|
1001
1055
|
if (options?.limit) {
|
|
1002
1056
|
searchParams.limit = String(options.limit);
|
|
1003
1057
|
}
|
|
1058
|
+
if (options?.environment) {
|
|
1059
|
+
searchParams.environment = options.environment;
|
|
1060
|
+
}
|
|
1004
1061
|
return searchParams;
|
|
1005
1062
|
}
|
|
1006
1063
|
var AgentsResource = class extends BaseResource {
|
|
@@ -1071,6 +1128,12 @@ var AgentsResource = class extends BaseResource {
|
|
|
1071
1128
|
if (options?.per_page) {
|
|
1072
1129
|
searchParams.per_page = String(options.per_page);
|
|
1073
1130
|
}
|
|
1131
|
+
if (options?.period_hours) {
|
|
1132
|
+
searchParams.period_hours = String(options.period_hours);
|
|
1133
|
+
}
|
|
1134
|
+
if (options?.environment) {
|
|
1135
|
+
searchParams.environment = options.environment;
|
|
1136
|
+
}
|
|
1074
1137
|
return this.request(
|
|
1075
1138
|
() => this.http.get(`api/projects/${projectId}/agents/traces`, {
|
|
1076
1139
|
searchParams
|
|
@@ -1078,6 +1141,50 @@ var AgentsResource = class extends BaseResource {
|
|
|
1078
1141
|
offsetPaginatedResponseSchema(agentTraceSummarySchema)
|
|
1079
1142
|
);
|
|
1080
1143
|
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Headline totals over the selected window — the numbers the charts show
|
|
1146
|
+
* the shape of but cannot state.
|
|
1147
|
+
*/
|
|
1148
|
+
async getSummary(projectId, options) {
|
|
1149
|
+
return this.request(
|
|
1150
|
+
() => this.http.get(`api/projects/${projectId}/agents/summary`, {
|
|
1151
|
+
searchParams: breakdownSearchParams(options)
|
|
1152
|
+
}),
|
|
1153
|
+
agentSummarySchema
|
|
1154
|
+
);
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Per-model table: volume, failures, latency and the full token split.
|
|
1158
|
+
*/
|
|
1159
|
+
async getModelsTable(projectId, options) {
|
|
1160
|
+
return this.request(
|
|
1161
|
+
() => this.http.get(`api/projects/${projectId}/agents/models`, {
|
|
1162
|
+
searchParams: breakdownSearchParams(options)
|
|
1163
|
+
}),
|
|
1164
|
+
zod.z.array(agentModelRowSchema)
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Per-tool table: call volume, failures and latency.
|
|
1169
|
+
*/
|
|
1170
|
+
async getToolsTable(projectId, options) {
|
|
1171
|
+
return this.request(
|
|
1172
|
+
() => this.http.get(`api/projects/${projectId}/agents/tools/stats`, {
|
|
1173
|
+
searchParams: breakdownSearchParams(options)
|
|
1174
|
+
}),
|
|
1175
|
+
zod.z.array(agentToolRowSchema)
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Environments present in this project's AI spans — the options the filter
|
|
1180
|
+
* offers, read from the data rather than hardcoded.
|
|
1181
|
+
*/
|
|
1182
|
+
async getEnvironments(projectId) {
|
|
1183
|
+
return this.request(
|
|
1184
|
+
() => this.http.get(`api/projects/${projectId}/agents/environments`),
|
|
1185
|
+
zod.z.array(zod.z.string())
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1081
1188
|
};
|
|
1082
1189
|
var AlertIntegrationsResource = class extends BaseResource {
|
|
1083
1190
|
/**
|
|
@@ -1307,6 +1414,24 @@ var AuthResource = class extends BaseResource {
|
|
|
1307
1414
|
async getCurrentUser() {
|
|
1308
1415
|
return this.request(() => this.http.get("auth/me"), userSchema);
|
|
1309
1416
|
}
|
|
1417
|
+
/**
|
|
1418
|
+
* Stores how this reader wants the dashboard presented to them.
|
|
1419
|
+
*
|
|
1420
|
+
* A key left out is left alone; a key sent as `null` is cleared. That is why
|
|
1421
|
+
* the request type is optional *and* nullable rather than one or the other:
|
|
1422
|
+
* "do not touch" and "forget my choice" are different instructions.
|
|
1423
|
+
*/
|
|
1424
|
+
async updatePreferences(preferences) {
|
|
1425
|
+
const validatedInput = this.validateInput(
|
|
1426
|
+
preferences,
|
|
1427
|
+
updatePreferencesRequestSchema
|
|
1428
|
+
);
|
|
1429
|
+
if (!validatedInput.success) return validatedInput;
|
|
1430
|
+
return this.request(
|
|
1431
|
+
() => this.http.patch("auth/me", { json: validatedInput.data }),
|
|
1432
|
+
userSchema
|
|
1433
|
+
);
|
|
1434
|
+
}
|
|
1310
1435
|
/**
|
|
1311
1436
|
* Get the details of a pending invitation by its token (public endpoint)
|
|
1312
1437
|
* Used by the accept-invitation page before the user has an account
|
|
@@ -1992,6 +2117,20 @@ var SpansResource = class extends BaseResource {
|
|
|
1992
2117
|
offsetPaginatedResponseSchema(spanSchema)
|
|
1993
2118
|
);
|
|
1994
2119
|
}
|
|
2120
|
+
/**
|
|
2121
|
+
* Fetch one span together with its raw attribute bag — the `gen_ai.*`
|
|
2122
|
+
* payload (prompts, responses, tool arguments and results) that `list()`
|
|
2123
|
+
* omits so a trace's worth of spans stays cheap to load.
|
|
2124
|
+
*
|
|
2125
|
+
* `spanId` is the row id from a list item's `id`, not the SDK's 16-hex
|
|
2126
|
+
* `span_id`.
|
|
2127
|
+
*/
|
|
2128
|
+
async get(projectId, spanId) {
|
|
2129
|
+
return this.request(
|
|
2130
|
+
() => this.http.get(`api/projects/${projectId}/spans/${spanId}`),
|
|
2131
|
+
spanDetailSchema
|
|
2132
|
+
);
|
|
2133
|
+
}
|
|
1995
2134
|
};
|
|
1996
2135
|
|
|
1997
2136
|
// src/resources/stats.ts
|