@blazingagents/sdk 0.9.0 → 0.9.1
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/contracts/entities/usage.d.ts +131 -0
- package/dist/contracts/entities/usage.js +117 -34
- package/dist/contracts/index.d.ts +2 -1
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/limitations.d.ts +2 -0
- package/dist/contracts/limitations.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/resources/sessions.js +3 -0
- package/dist/resources/usage.js +4 -1
- package/dist/types.d.ts +7 -4
- package/package.json +1 -1
|
@@ -42,6 +42,15 @@ export declare const usageQuerySchema: z.ZodObject<{
|
|
|
42
42
|
}>>;
|
|
43
43
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
44
44
|
}, z.core.$strict>;
|
|
45
|
+
/**
|
|
46
|
+
* Query for the bounded dashboard-oriented usage overview. The date range has
|
|
47
|
+
* the same semantics as `usageQuerySchema`; `limit` bounds each ranking.
|
|
48
|
+
*/
|
|
49
|
+
export declare const usageOverviewQuerySchema: z.ZodObject<{
|
|
50
|
+
from: z.ZodOptional<z.ZodISODate>;
|
|
51
|
+
to: z.ZodOptional<z.ZodISODate>;
|
|
52
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
53
|
+
}, z.core.$strict>;
|
|
45
54
|
/**
|
|
46
55
|
* Usage bucket — one row per group. `sessionId` is the platform session id
|
|
47
56
|
* (`ss_…`) or `null` for the `''` stateless sentinel (mapped at the read
|
|
@@ -88,8 +97,130 @@ export declare const usageResponseSchema: z.ZodObject<{
|
|
|
88
97
|
durationMs: z.ZodNumber;
|
|
89
98
|
}, z.core.$strip>;
|
|
90
99
|
}, z.core.$strip>;
|
|
100
|
+
/**
|
|
101
|
+
* Dashboard usage data from one bounded aggregation. `byModel` may contain
|
|
102
|
+
* one final `{ provider: null, model: null }` bucket for usage outside the
|
|
103
|
+
* top-N models.
|
|
104
|
+
*/
|
|
105
|
+
export declare const usageOverviewResponseSchema: z.ZodObject<{
|
|
106
|
+
totals: z.ZodObject<{
|
|
107
|
+
inputTokens: z.ZodNumber;
|
|
108
|
+
outputTokens: z.ZodNumber;
|
|
109
|
+
requestCount: z.ZodNumber;
|
|
110
|
+
durationMs: z.ZodNumber;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
daily: z.ZodArray<z.ZodObject<{
|
|
113
|
+
day: z.ZodNullable<z.ZodString>;
|
|
114
|
+
agentId: z.ZodNullable<z.ZodString>;
|
|
115
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
116
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
117
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
118
|
+
model: z.ZodNullable<z.ZodString>;
|
|
119
|
+
inputTokens: z.ZodNumber;
|
|
120
|
+
outputTokens: z.ZodNumber;
|
|
121
|
+
requestCount: z.ZodNumber;
|
|
122
|
+
durationMs: z.ZodNumber;
|
|
123
|
+
}, z.core.$strip>>;
|
|
124
|
+
byAgent: z.ZodArray<z.ZodObject<{
|
|
125
|
+
day: z.ZodNullable<z.ZodString>;
|
|
126
|
+
agentId: z.ZodNullable<z.ZodString>;
|
|
127
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
128
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
129
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
130
|
+
model: z.ZodNullable<z.ZodString>;
|
|
131
|
+
inputTokens: z.ZodNumber;
|
|
132
|
+
outputTokens: z.ZodNumber;
|
|
133
|
+
requestCount: z.ZodNumber;
|
|
134
|
+
durationMs: z.ZodNumber;
|
|
135
|
+
}, z.core.$strip>>;
|
|
136
|
+
byUser: z.ZodArray<z.ZodObject<{
|
|
137
|
+
day: z.ZodNullable<z.ZodString>;
|
|
138
|
+
agentId: z.ZodNullable<z.ZodString>;
|
|
139
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
140
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
141
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
142
|
+
model: z.ZodNullable<z.ZodString>;
|
|
143
|
+
inputTokens: z.ZodNumber;
|
|
144
|
+
outputTokens: z.ZodNumber;
|
|
145
|
+
requestCount: z.ZodNumber;
|
|
146
|
+
durationMs: z.ZodNumber;
|
|
147
|
+
}, z.core.$strip>>;
|
|
148
|
+
byModel: z.ZodArray<z.ZodObject<{
|
|
149
|
+
day: z.ZodNullable<z.ZodString>;
|
|
150
|
+
agentId: z.ZodNullable<z.ZodString>;
|
|
151
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
152
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
153
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
154
|
+
model: z.ZodNullable<z.ZodString>;
|
|
155
|
+
inputTokens: z.ZodNumber;
|
|
156
|
+
outputTokens: z.ZodNumber;
|
|
157
|
+
requestCount: z.ZodNumber;
|
|
158
|
+
durationMs: z.ZodNumber;
|
|
159
|
+
}, z.core.$strip>>;
|
|
160
|
+
activeAgentCount: z.ZodNumber;
|
|
161
|
+
}, z.core.$strip>;
|
|
162
|
+
/** Applies the request-dependent ranking and daily-series guarantees. */
|
|
163
|
+
export declare function usageOverviewResponseSchemaForQuery(query?: Partial<UsageOverviewQuery>): z.ZodObject<{
|
|
164
|
+
totals: z.ZodObject<{
|
|
165
|
+
inputTokens: z.ZodNumber;
|
|
166
|
+
outputTokens: z.ZodNumber;
|
|
167
|
+
requestCount: z.ZodNumber;
|
|
168
|
+
durationMs: z.ZodNumber;
|
|
169
|
+
}, z.core.$strip>;
|
|
170
|
+
daily: z.ZodArray<z.ZodObject<{
|
|
171
|
+
day: z.ZodNullable<z.ZodString>;
|
|
172
|
+
agentId: z.ZodNullable<z.ZodString>;
|
|
173
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
174
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
175
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
176
|
+
model: z.ZodNullable<z.ZodString>;
|
|
177
|
+
inputTokens: z.ZodNumber;
|
|
178
|
+
outputTokens: z.ZodNumber;
|
|
179
|
+
requestCount: z.ZodNumber;
|
|
180
|
+
durationMs: z.ZodNumber;
|
|
181
|
+
}, z.core.$strip>>;
|
|
182
|
+
byAgent: z.ZodArray<z.ZodObject<{
|
|
183
|
+
day: z.ZodNullable<z.ZodString>;
|
|
184
|
+
agentId: z.ZodNullable<z.ZodString>;
|
|
185
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
186
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
187
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
188
|
+
model: z.ZodNullable<z.ZodString>;
|
|
189
|
+
inputTokens: z.ZodNumber;
|
|
190
|
+
outputTokens: z.ZodNumber;
|
|
191
|
+
requestCount: z.ZodNumber;
|
|
192
|
+
durationMs: z.ZodNumber;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
byUser: z.ZodArray<z.ZodObject<{
|
|
195
|
+
day: z.ZodNullable<z.ZodString>;
|
|
196
|
+
agentId: z.ZodNullable<z.ZodString>;
|
|
197
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
198
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
199
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
200
|
+
model: z.ZodNullable<z.ZodString>;
|
|
201
|
+
inputTokens: z.ZodNumber;
|
|
202
|
+
outputTokens: z.ZodNumber;
|
|
203
|
+
requestCount: z.ZodNumber;
|
|
204
|
+
durationMs: z.ZodNumber;
|
|
205
|
+
}, z.core.$strip>>;
|
|
206
|
+
byModel: z.ZodArray<z.ZodObject<{
|
|
207
|
+
day: z.ZodNullable<z.ZodString>;
|
|
208
|
+
agentId: z.ZodNullable<z.ZodString>;
|
|
209
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
210
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
211
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
212
|
+
model: z.ZodNullable<z.ZodString>;
|
|
213
|
+
inputTokens: z.ZodNumber;
|
|
214
|
+
outputTokens: z.ZodNumber;
|
|
215
|
+
requestCount: z.ZodNumber;
|
|
216
|
+
durationMs: z.ZodNumber;
|
|
217
|
+
}, z.core.$strip>>;
|
|
218
|
+
activeAgentCount: z.ZodNumber;
|
|
219
|
+
}, z.core.$strip>;
|
|
91
220
|
export type UsageGroupBy = z.infer<typeof usageGroupBySchema>;
|
|
92
221
|
export type UsageQuery = z.infer<typeof usageQuerySchema>;
|
|
93
222
|
export type UsageBucket = z.infer<typeof usageBucketSchema>;
|
|
94
223
|
export type UsageTotals = z.infer<typeof usageTotalsSchema>;
|
|
95
224
|
export type UsageResponse = z.infer<typeof usageResponseSchema>;
|
|
225
|
+
export type UsageOverviewQuery = z.infer<typeof usageOverviewQuerySchema>;
|
|
226
|
+
export type UsageOverviewResponse = z.infer<typeof usageOverviewResponseSchema>;
|
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { agentIdSchema, sessionIdSchema } from "../ids.js";
|
|
3
|
-
import { DEFAULT_USAGE_SESSION_TOP_N, MAX_USAGE_RANGE_DAYS, MAX_USAGE_SESSION_TOP_N, } from "../limitations.js";
|
|
3
|
+
import { DEFAULT_USAGE_OVERVIEW_TOP_N, DEFAULT_USAGE_RANGE_DAYS, DEFAULT_USAGE_SESSION_TOP_N, MAX_USAGE_OVERVIEW_TOP_N, MAX_USAGE_RANGE_DAYS, MAX_USAGE_SESSION_TOP_N, } from "../limitations.js";
|
|
4
4
|
import { userIdSchema } from "./attribution.js";
|
|
5
|
+
function validateUsageRange(value, ctx) {
|
|
6
|
+
if ((value.from === undefined) !== (value.to === undefined)) {
|
|
7
|
+
ctx.addIssue({
|
|
8
|
+
code: "custom",
|
|
9
|
+
message: "`from` and `to` must both be present or both be absent.",
|
|
10
|
+
path: value.from === undefined ? ["from"] : ["to"],
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
if (value.from && value.to) {
|
|
14
|
+
const fromMs = new Date(`${value.from}T00:00:00Z`).getTime();
|
|
15
|
+
const toMs = new Date(`${value.to}T00:00:00Z`).getTime();
|
|
16
|
+
const spanDays = (toMs - fromMs) / (1000 * 60 * 60 * 24);
|
|
17
|
+
if (spanDays > MAX_USAGE_RANGE_DAYS) {
|
|
18
|
+
ctx.addIssue({
|
|
19
|
+
code: "custom",
|
|
20
|
+
message: `Usage range must be at most ${MAX_USAGE_RANGE_DAYS} days.`,
|
|
21
|
+
path: ["to"],
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (toMs < fromMs) {
|
|
25
|
+
ctx.addIssue({
|
|
26
|
+
code: "custom",
|
|
27
|
+
message: "`to` must be after `from`.",
|
|
28
|
+
path: ["to"],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
5
33
|
/**
|
|
6
34
|
* `GET /v1/usage` groupBy — `day|agent|model|session|user`. `session` is
|
|
7
35
|
* top-N by tokens; the others are exhaustive and bounded. `user` is the
|
|
@@ -46,39 +74,24 @@ export const usageQuerySchema = z
|
|
|
46
74
|
.default(DEFAULT_USAGE_SESSION_TOP_N),
|
|
47
75
|
})
|
|
48
76
|
.strict()
|
|
49
|
-
.superRefine(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
ctx.addIssue({
|
|
68
|
-
code: "custom",
|
|
69
|
-
message: `Usage range must be at most ${MAX_USAGE_RANGE_DAYS} days.`,
|
|
70
|
-
path: ["to"],
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
if (toMs < fromMs) {
|
|
74
|
-
ctx.addIssue({
|
|
75
|
-
code: "custom",
|
|
76
|
-
message: "`to` must be after `from`.",
|
|
77
|
-
path: ["to"],
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
77
|
+
.superRefine(validateUsageRange);
|
|
78
|
+
/**
|
|
79
|
+
* Query for the bounded dashboard-oriented usage overview. The date range has
|
|
80
|
+
* the same semantics as `usageQuerySchema`; `limit` bounds each ranking.
|
|
81
|
+
*/
|
|
82
|
+
export const usageOverviewQuerySchema = z
|
|
83
|
+
.object({
|
|
84
|
+
from: z.iso.date().optional(),
|
|
85
|
+
to: z.iso.date().optional(),
|
|
86
|
+
limit: z
|
|
87
|
+
.number()
|
|
88
|
+
.int()
|
|
89
|
+
.min(1)
|
|
90
|
+
.max(MAX_USAGE_OVERVIEW_TOP_N)
|
|
91
|
+
.default(DEFAULT_USAGE_OVERVIEW_TOP_N),
|
|
92
|
+
})
|
|
93
|
+
.strict()
|
|
94
|
+
.superRefine(validateUsageRange);
|
|
82
95
|
/**
|
|
83
96
|
* Usage bucket — one row per group. `sessionId` is the platform session id
|
|
84
97
|
* (`ss_…`) or `null` for the `''` stateless sentinel (mapped at the read
|
|
@@ -115,3 +128,73 @@ export const usageResponseSchema = z
|
|
|
115
128
|
totals: usageTotalsSchema,
|
|
116
129
|
})
|
|
117
130
|
.strip();
|
|
131
|
+
/**
|
|
132
|
+
* Dashboard usage data from one bounded aggregation. `byModel` may contain
|
|
133
|
+
* one final `{ provider: null, model: null }` bucket for usage outside the
|
|
134
|
+
* top-N models.
|
|
135
|
+
*/
|
|
136
|
+
export const usageOverviewResponseSchema = z
|
|
137
|
+
.object({
|
|
138
|
+
totals: usageTotalsSchema,
|
|
139
|
+
daily: z.array(usageBucketSchema).max(MAX_USAGE_RANGE_DAYS + 1),
|
|
140
|
+
byAgent: z.array(usageBucketSchema).max(MAX_USAGE_OVERVIEW_TOP_N),
|
|
141
|
+
byUser: z.array(usageBucketSchema).max(MAX_USAGE_OVERVIEW_TOP_N),
|
|
142
|
+
byModel: z.array(usageBucketSchema).max(MAX_USAGE_OVERVIEW_TOP_N + 1),
|
|
143
|
+
activeAgentCount: z.number().int().nonnegative(),
|
|
144
|
+
})
|
|
145
|
+
.strip()
|
|
146
|
+
.superRefine((value, ctx) => {
|
|
147
|
+
const remainderCount = value.byModel.filter(({ model, provider }) => model === null && provider === null).length;
|
|
148
|
+
const normalCount = value.byModel.length - remainderCount;
|
|
149
|
+
const hasIncompleteModel = value.byModel.some(({ model, provider }) => (model === null) !== (provider === null));
|
|
150
|
+
if (remainderCount > 1 ||
|
|
151
|
+
normalCount > MAX_USAGE_OVERVIEW_TOP_N ||
|
|
152
|
+
hasIncompleteModel) {
|
|
153
|
+
ctx.addIssue({
|
|
154
|
+
code: "custom",
|
|
155
|
+
message: "Model usage must contain at most 20 models and one remainder.",
|
|
156
|
+
path: ["byModel"],
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
/** Applies the request-dependent ranking and daily-series guarantees. */
|
|
161
|
+
export function usageOverviewResponseSchemaForQuery(query = {}) {
|
|
162
|
+
const limit = query.limit ?? DEFAULT_USAGE_OVERVIEW_TOP_N;
|
|
163
|
+
const expectedDays = query.from && query.to
|
|
164
|
+
? (new Date(`${query.to}T00:00:00Z`).getTime() -
|
|
165
|
+
new Date(`${query.from}T00:00:00Z`).getTime()) /
|
|
166
|
+
(1000 * 60 * 60 * 24) +
|
|
167
|
+
1
|
|
168
|
+
: DEFAULT_USAGE_RANGE_DAYS;
|
|
169
|
+
return usageOverviewResponseSchema.superRefine((value, ctx) => {
|
|
170
|
+
const normalModelCount = value.byModel.filter(({ model, provider }) => model !== null || provider !== null).length;
|
|
171
|
+
if (value.byAgent.length > limit ||
|
|
172
|
+
value.byUser.length > limit ||
|
|
173
|
+
normalModelCount > limit) {
|
|
174
|
+
ctx.addIssue({
|
|
175
|
+
code: "custom",
|
|
176
|
+
message: "Usage rankings exceed the requested limit.",
|
|
177
|
+
path: ["byAgent"],
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const days = value.daily.map(({ day }) => day);
|
|
181
|
+
const firstDay = query.from ?? days[0];
|
|
182
|
+
const completeDailyRange = days.length === expectedDays &&
|
|
183
|
+
firstDay !== null &&
|
|
184
|
+
firstDay !== undefined &&
|
|
185
|
+
days.every((day, index) => {
|
|
186
|
+
const expected = new Date(new Date(`${firstDay}T00:00:00Z`).getTime() +
|
|
187
|
+
index * 24 * 60 * 60 * 1000)
|
|
188
|
+
.toISOString()
|
|
189
|
+
.slice(0, 10);
|
|
190
|
+
return day === expected;
|
|
191
|
+
});
|
|
192
|
+
if (!completeDailyRange) {
|
|
193
|
+
ctx.addIssue({
|
|
194
|
+
code: "custom",
|
|
195
|
+
message: "Daily usage must cover the complete selected range.",
|
|
196
|
+
path: ["daily"],
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
@@ -17,6 +17,7 @@ export { decideToolApprovalBodySchema, latestSessionListItemSchema, latestSessio
|
|
|
17
17
|
export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.ts";
|
|
18
18
|
export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskListItemSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.ts";
|
|
19
19
|
export { quotaSchema, subscriptionStatusSchema, tenantResponseSchema, tenantSchema, tenantSettingsResponseSchema, updateTenantSettingsBodySchema, } from "./entities/tenants.ts";
|
|
20
|
-
export {
|
|
20
|
+
export type { UsageBucket, UsageOverviewQuery, UsageOverviewResponse, UsageResponse, UsageTotals, } from "./entities/usage.ts";
|
|
21
|
+
export { usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.ts";
|
|
21
22
|
export { createWorkspaceBodySchema, updateWorkspaceBodySchema, workspaceSchema, workspacesListResponseSchema, } from "./entities/workspaces.ts";
|
|
22
23
|
export { agentIdSchema, apiKeyTokenSchema, isAdminAgentId, promptIdSchema, sessionIdSchema, } from "./ids.ts";
|
package/dist/contracts/index.js
CHANGED
|
@@ -15,6 +15,6 @@ export { decideToolApprovalBodySchema, latestSessionListItemSchema, latestSessio
|
|
|
15
15
|
export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.js";
|
|
16
16
|
export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskListItemSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.js";
|
|
17
17
|
export { quotaSchema, subscriptionStatusSchema, tenantResponseSchema, tenantSchema, tenantSettingsResponseSchema, updateTenantSettingsBodySchema, } from "./entities/tenants.js";
|
|
18
|
-
export { usageResponseSchema } from "./entities/usage.js";
|
|
18
|
+
export { usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.js";
|
|
19
19
|
export { createWorkspaceBodySchema, updateWorkspaceBodySchema, workspaceSchema, workspacesListResponseSchema, } from "./entities/workspaces.js";
|
|
20
20
|
export { agentIdSchema, apiKeyTokenSchema, isAdminAgentId, promptIdSchema, sessionIdSchema, } from "./ids.js";
|
|
@@ -122,6 +122,8 @@ export declare const MAX_USAGE_RANGE_DAYS = 31;
|
|
|
122
122
|
export declare const DEFAULT_USAGE_RANGE_DAYS = 30;
|
|
123
123
|
export declare const DEFAULT_USAGE_SESSION_TOP_N = 50;
|
|
124
124
|
export declare const MAX_USAGE_SESSION_TOP_N = 200;
|
|
125
|
+
export declare const DEFAULT_USAGE_OVERVIEW_TOP_N = 5;
|
|
126
|
+
export declare const MAX_USAGE_OVERVIEW_TOP_N = 20;
|
|
125
127
|
export declare const MIN_QUOTA_RESET_DAY = 1;
|
|
126
128
|
export declare const MAX_QUOTA_RESET_DAY = 28;
|
|
127
129
|
/**
|
|
@@ -123,6 +123,8 @@ export const MAX_USAGE_RANGE_DAYS = 31;
|
|
|
123
123
|
export const DEFAULT_USAGE_RANGE_DAYS = 30;
|
|
124
124
|
export const DEFAULT_USAGE_SESSION_TOP_N = 50;
|
|
125
125
|
export const MAX_USAGE_SESSION_TOP_N = 200;
|
|
126
|
+
export const DEFAULT_USAGE_OVERVIEW_TOP_N = 5;
|
|
127
|
+
export const MAX_USAGE_OVERVIEW_TOP_N = 20;
|
|
126
128
|
// Quota — reset day between 1 and 28.
|
|
127
129
|
export const MIN_QUOTA_RESET_DAY = 1;
|
|
128
130
|
export const MAX_QUOTA_RESET_DAY = 28;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type { CreateMcpConnectionBody, McpAttachmentResponse, McpAttachmentsResp
|
|
|
17
17
|
export type { CreateProviderBody, ProviderListItem, ProviderModel, ProviderModelsResponse, ProviderResponse, ProvidersResponse, ProviderType, ThinkingLevelsResponse, UpdateProviderBody, } from "./contracts/entities/providers.ts";
|
|
18
18
|
export type { ToolApprovalDecisionResponse, ToolApprovalState, ToolApprovalsResponse, } from "./contracts/entities/sessions.ts";
|
|
19
19
|
export type { CreateSkillBody, Skill, SkillArchiveType, SkillCopyResult, SkillCopyResults, SkillDetail, SkillFile, SkillsListResponse, } from "./contracts/entities/skills.ts";
|
|
20
|
+
export type { UsageBucket, UsageOverviewQuery, UsageOverviewResponse, UsageTotals, } from "./contracts/entities/usage.ts";
|
|
20
21
|
export type { CreateWorkspaceBody, UpdateWorkspaceBody, Workspace, WorkspaceNetworkPolicy, WorkspacesListResponse, } from "./contracts/entities/workspaces.ts";
|
|
21
22
|
export { BlazingAgentsDirectChatTransport, type BlazingAgentsDirectChatTransportOptions, } from "./direct-chat-transport.ts";
|
|
22
23
|
export { BlazingAgentsError } from "./errors.ts";
|
|
@@ -35,6 +35,9 @@ export function createSessionsResource(config) {
|
|
|
35
35
|
limit: options.limit,
|
|
36
36
|
// Stryker disable next-line ConditionalExpression: URL serialization omits an undefined query value.
|
|
37
37
|
...(options.userId === undefined ? {} : { userId: options.userId }),
|
|
38
|
+
...(options.byAgent === undefined
|
|
39
|
+
? {}
|
|
40
|
+
: { byAgent: options.byAgent }),
|
|
38
41
|
},
|
|
39
42
|
}, latestSessionsListResponseSchema);
|
|
40
43
|
},
|
package/dist/resources/usage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { usageResponseSchema } from "../contracts/entities/usage.js";
|
|
1
|
+
import { usageOverviewResponseSchemaForQuery, usageResponseSchema, } from "../contracts/entities/usage.js";
|
|
2
2
|
import { requestJson } from "../http.js";
|
|
3
3
|
/**
|
|
4
4
|
* `client.usage` — get over `/v1/usage` (tenant-wide) and
|
|
@@ -16,5 +16,8 @@ export function createUsageResource(config) {
|
|
|
16
16
|
async getForAgent({ agentId, abortSignal, ...query }) {
|
|
17
17
|
return await requestJson(config, `/v1/agents/${agentId}/usage`, { query, signal: abortSignal }, usageResponseSchema);
|
|
18
18
|
},
|
|
19
|
+
async overview({ abortSignal, ...query } = {}) {
|
|
20
|
+
return await requestJson(config, "/v1/usage/overview", { query, signal: abortSignal }, usageOverviewResponseSchemaForQuery(query));
|
|
21
|
+
},
|
|
19
22
|
};
|
|
20
23
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { DecideToolApprovalBody, LatestSessionsListResponse, SessionMessage
|
|
|
12
12
|
import type { CreateSkillBody, SkillArchiveType, SkillCopyResults, SkillDetail, SkillsListResponse } from "./contracts/entities/skills.ts";
|
|
13
13
|
import type { CreateTaskBody, CreateTaskResponse, CreateTaskRunBody, CreateTaskRunResponse, TaskResponse, TaskRunMessagesResponse, TaskRunResponse, TaskRunsListResponse, TasksListResponse, UpdateTaskBody } from "./contracts/entities/tasks.ts";
|
|
14
14
|
import type { TenantSettingsResponse, UpdateTenantSettingsBody } from "./contracts/entities/tenants.ts";
|
|
15
|
-
import type { UsageQuery, UsageResponse } from "./contracts/entities/usage.ts";
|
|
15
|
+
import type { UsageOverviewQuery, UsageOverviewResponse, UsageQuery, UsageResponse } from "./contracts/entities/usage.ts";
|
|
16
16
|
import type { CreateWorkspaceBody, UpdateWorkspaceBody, Workspace, WorkspacesListResponse } from "./contracts/entities/workspaces.ts";
|
|
17
17
|
export type KnownBlazingAgentsErrorCode = ApiErrorCode | "invalid_response" | "network_error" | "request_aborted" | "stream_error";
|
|
18
18
|
export type BlazingAgentsErrorCode = KnownBlazingAgentsErrorCode | (string & {});
|
|
@@ -374,6 +374,7 @@ export interface SessionsListOptions extends ResourceRequestOptions {
|
|
|
374
374
|
userId?: string;
|
|
375
375
|
}
|
|
376
376
|
export interface LatestSessionsListOptions extends ResourceRequestOptions {
|
|
377
|
+
byAgent?: boolean;
|
|
377
378
|
cursor?: string;
|
|
378
379
|
limit?: number;
|
|
379
380
|
userId?: string;
|
|
@@ -403,9 +404,9 @@ export interface SessionsResource {
|
|
|
403
404
|
agentId: string;
|
|
404
405
|
} & SessionsListOptions): Promise<SessionsListResponse>;
|
|
405
406
|
/**
|
|
406
|
-
* `GET /v1/sessions/latest` —
|
|
407
|
-
*
|
|
408
|
-
* the candidate Sessions to one end user's
|
|
407
|
+
* `GET /v1/sessions/latest` — the Tenant's most recently updated Sessions,
|
|
408
|
+
* newest first. Set `byAgent` to return at most one Session per Agent.
|
|
409
|
+
* `userId` narrows the candidate Sessions to one end user's.
|
|
409
410
|
*/
|
|
410
411
|
listLatest(input?: LatestSessionsListOptions): Promise<LatestSessionsListResponse>;
|
|
411
412
|
messages(input: {
|
|
@@ -511,6 +512,8 @@ export interface UsageResource {
|
|
|
511
512
|
getForAgent(input: Partial<UsageQuery> & {
|
|
512
513
|
agentId: string;
|
|
513
514
|
} & ResourceRequestOptions): Promise<UsageResponse>;
|
|
515
|
+
/** Returns totals, daily usage, and bounded Agent, user, and model rankings. */
|
|
516
|
+
overview(input?: Partial<UsageOverviewQuery> & ResourceRequestOptions): Promise<UsageOverviewResponse>;
|
|
514
517
|
}
|
|
515
518
|
export interface ChatConnectionsResource {
|
|
516
519
|
checkHealth(input: {
|