@agentuity/server 1.0.22 → 1.0.24
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/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/project/deploy.d.ts +8 -0
- package/dist/api/project/deploy.d.ts.map +1 -1
- package/dist/api/project/deploy.js +14 -13
- package/dist/api/project/deploy.js.map +1 -1
- package/dist/api/sandbox/disk-checkpoint.d.ts +103 -0
- package/dist/api/sandbox/disk-checkpoint.d.ts.map +1 -0
- package/dist/api/sandbox/disk-checkpoint.js +104 -0
- package/dist/api/sandbox/disk-checkpoint.js.map +1 -0
- package/dist/api/sandbox/execute.d.ts +2 -2
- package/dist/api/sandbox/execution.d.ts +4 -4
- package/dist/api/sandbox/index.d.ts +2 -0
- package/dist/api/sandbox/index.d.ts.map +1 -1
- package/dist/api/sandbox/index.js +1 -0
- package/dist/api/sandbox/index.js.map +1 -1
- package/dist/api/sandbox/snapshot-build.d.ts +2 -0
- package/dist/api/sandbox/snapshot-build.d.ts.map +1 -1
- package/dist/api/sandbox/snapshot-build.js +4 -0
- package/dist/api/sandbox/snapshot-build.js.map +1 -1
- package/dist/api/services/index.d.ts +2 -0
- package/dist/api/services/index.d.ts.map +1 -0
- package/dist/api/services/index.js +2 -0
- package/dist/api/services/index.js.map +1 -0
- package/dist/api/services/stats.d.ts +257 -0
- package/dist/api/services/stats.d.ts.map +1 -0
- package/dist/api/services/stats.js +142 -0
- package/dist/api/services/stats.js.map +1 -0
- package/dist/api/webhook/deliveries.d.ts +94 -0
- package/dist/api/webhook/deliveries.d.ts.map +1 -0
- package/dist/api/webhook/deliveries.js +79 -0
- package/dist/api/webhook/deliveries.js.map +1 -0
- package/dist/api/webhook/destinations.d.ts +136 -0
- package/dist/api/webhook/destinations.d.ts.map +1 -0
- package/dist/api/webhook/destinations.js +137 -0
- package/dist/api/webhook/destinations.js.map +1 -0
- package/dist/api/webhook/index.d.ts +41 -0
- package/dist/api/webhook/index.d.ts.map +1 -0
- package/dist/api/webhook/index.js +59 -0
- package/dist/api/webhook/index.js.map +1 -0
- package/dist/api/webhook/receipts.d.ts +77 -0
- package/dist/api/webhook/receipts.d.ts.map +1 -0
- package/dist/api/webhook/receipts.js +78 -0
- package/dist/api/webhook/receipts.js.map +1 -0
- package/dist/api/webhook/types.d.ts +249 -0
- package/dist/api/webhook/types.d.ts.map +1 -0
- package/dist/api/webhook/types.js +221 -0
- package/dist/api/webhook/types.js.map +1 -0
- package/dist/api/webhook/util.d.ts +202 -0
- package/dist/api/webhook/util.d.ts.map +1 -0
- package/dist/api/webhook/util.js +201 -0
- package/dist/api/webhook/util.js.map +1 -0
- package/dist/api/webhook/webhooks.d.ts +146 -0
- package/dist/api/webhook/webhooks.d.ts.map +1 -0
- package/dist/api/webhook/webhooks.js +165 -0
- package/dist/api/webhook/webhooks.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/runtime-bootstrap.d.ts.map +1 -1
- package/dist/runtime-bootstrap.js +3 -0
- package/dist/runtime-bootstrap.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -0
- package/dist/server.js.map +1 -1
- package/package.json +4 -4
- package/src/api/index.ts +2 -0
- package/src/api/project/deploy.ts +16 -16
- package/src/api/sandbox/disk-checkpoint.ts +179 -0
- package/src/api/sandbox/index.ts +18 -0
- package/src/api/sandbox/snapshot-build.ts +6 -0
- package/src/api/services/index.ts +1 -0
- package/src/api/services/stats.ts +211 -0
- package/src/api/webhook/deliveries.ts +129 -0
- package/src/api/webhook/destinations.ts +224 -0
- package/src/api/webhook/index.ts +133 -0
- package/src/api/webhook/receipts.ts +124 -0
- package/src/api/webhook/types.ts +309 -0
- package/src/api/webhook/util.ts +237 -0
- package/src/api/webhook/webhooks.ts +260 -0
- package/src/config.ts +2 -0
- package/src/runtime-bootstrap.ts +3 -0
- package/src/server.ts +4 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type APIClient } from '../api.ts';
|
|
3
|
+
export declare const ServiceStatsError: {
|
|
4
|
+
new (args?: ({
|
|
5
|
+
message: string;
|
|
6
|
+
} & {
|
|
7
|
+
message?: string;
|
|
8
|
+
cause?: unknown;
|
|
9
|
+
}) | undefined): import("@agentuity/core").RichError & {
|
|
10
|
+
readonly _tag: "ServiceStatsError";
|
|
11
|
+
} & Readonly<{
|
|
12
|
+
message: string;
|
|
13
|
+
}>;
|
|
14
|
+
readonly defaultMessage?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const KeyValueStatSchema: z.ZodObject<{
|
|
17
|
+
namespaceCount: z.ZodNumber;
|
|
18
|
+
keyCount: z.ZodNumber;
|
|
19
|
+
totalSizeBytes: z.ZodNumber;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export declare const VectorStatSchema: z.ZodObject<{
|
|
22
|
+
namespaceCount: z.ZodNumber;
|
|
23
|
+
documentCount: z.ZodNumber;
|
|
24
|
+
totalSizeBytes: z.ZodNumber;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export declare const QueueStatSchema: z.ZodObject<{
|
|
27
|
+
queueCount: z.ZodNumber;
|
|
28
|
+
totalMessages: z.ZodNumber;
|
|
29
|
+
totalDlq: z.ZodNumber;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export declare const StreamStatSchema: z.ZodObject<{
|
|
32
|
+
streamCount: z.ZodNumber;
|
|
33
|
+
totalSizeBytes: z.ZodNumber;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const SandboxStatSchema: z.ZodObject<{
|
|
36
|
+
totalActive: z.ZodNumber;
|
|
37
|
+
running: z.ZodNumber;
|
|
38
|
+
idle: z.ZodNumber;
|
|
39
|
+
creating: z.ZodNumber;
|
|
40
|
+
totalExecutions: z.ZodNumber;
|
|
41
|
+
totalCpuTimeMs: z.ZodNumber;
|
|
42
|
+
totalMemoryByteSec: z.ZodNumber;
|
|
43
|
+
totalNetworkEgressBytes: z.ZodNumber;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export declare const EmailStatSchema: z.ZodObject<{
|
|
46
|
+
addressCount: z.ZodNumber;
|
|
47
|
+
inboundCount: z.ZodNumber;
|
|
48
|
+
outboundCount: z.ZodNumber;
|
|
49
|
+
outboundSuccess: z.ZodNumber;
|
|
50
|
+
outboundFailed: z.ZodNumber;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export declare const TaskStatSchema: z.ZodObject<{
|
|
53
|
+
total: z.ZodNumber;
|
|
54
|
+
open: z.ZodNumber;
|
|
55
|
+
inProgress: z.ZodNumber;
|
|
56
|
+
closed: z.ZodNumber;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
export declare const ScheduleStatSchema: z.ZodObject<{
|
|
59
|
+
scheduleCount: z.ZodNumber;
|
|
60
|
+
totalDeliveries: z.ZodNumber;
|
|
61
|
+
successDeliveries: z.ZodNumber;
|
|
62
|
+
failedDeliveries: z.ZodNumber;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
export declare const DatabaseStatSchema: z.ZodObject<{
|
|
65
|
+
databaseCount: z.ZodNumber;
|
|
66
|
+
totalTableCount: z.ZodNumber;
|
|
67
|
+
totalRecordCount: z.ZodNumber;
|
|
68
|
+
totalSizeBytes: z.ZodNumber;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export declare const ServiceStatsDataSchema: z.ZodObject<{
|
|
71
|
+
services: z.ZodObject<{
|
|
72
|
+
database: z.ZodOptional<z.ZodObject<{
|
|
73
|
+
databaseCount: z.ZodNumber;
|
|
74
|
+
totalTableCount: z.ZodNumber;
|
|
75
|
+
totalRecordCount: z.ZodNumber;
|
|
76
|
+
totalSizeBytes: z.ZodNumber;
|
|
77
|
+
}, z.core.$strip>>;
|
|
78
|
+
keyvalue: z.ZodOptional<z.ZodObject<{
|
|
79
|
+
namespaceCount: z.ZodNumber;
|
|
80
|
+
keyCount: z.ZodNumber;
|
|
81
|
+
totalSizeBytes: z.ZodNumber;
|
|
82
|
+
}, z.core.$strip>>;
|
|
83
|
+
vector: z.ZodOptional<z.ZodObject<{
|
|
84
|
+
namespaceCount: z.ZodNumber;
|
|
85
|
+
documentCount: z.ZodNumber;
|
|
86
|
+
totalSizeBytes: z.ZodNumber;
|
|
87
|
+
}, z.core.$strip>>;
|
|
88
|
+
queue: z.ZodOptional<z.ZodObject<{
|
|
89
|
+
queueCount: z.ZodNumber;
|
|
90
|
+
totalMessages: z.ZodNumber;
|
|
91
|
+
totalDlq: z.ZodNumber;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
stream: z.ZodOptional<z.ZodObject<{
|
|
94
|
+
streamCount: z.ZodNumber;
|
|
95
|
+
totalSizeBytes: z.ZodNumber;
|
|
96
|
+
}, z.core.$strip>>;
|
|
97
|
+
sandbox: z.ZodOptional<z.ZodObject<{
|
|
98
|
+
totalActive: z.ZodNumber;
|
|
99
|
+
running: z.ZodNumber;
|
|
100
|
+
idle: z.ZodNumber;
|
|
101
|
+
creating: z.ZodNumber;
|
|
102
|
+
totalExecutions: z.ZodNumber;
|
|
103
|
+
totalCpuTimeMs: z.ZodNumber;
|
|
104
|
+
totalMemoryByteSec: z.ZodNumber;
|
|
105
|
+
totalNetworkEgressBytes: z.ZodNumber;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
email: z.ZodOptional<z.ZodObject<{
|
|
108
|
+
addressCount: z.ZodNumber;
|
|
109
|
+
inboundCount: z.ZodNumber;
|
|
110
|
+
outboundCount: z.ZodNumber;
|
|
111
|
+
outboundSuccess: z.ZodNumber;
|
|
112
|
+
outboundFailed: z.ZodNumber;
|
|
113
|
+
}, z.core.$strip>>;
|
|
114
|
+
task: z.ZodOptional<z.ZodObject<{
|
|
115
|
+
total: z.ZodNumber;
|
|
116
|
+
open: z.ZodNumber;
|
|
117
|
+
inProgress: z.ZodNumber;
|
|
118
|
+
closed: z.ZodNumber;
|
|
119
|
+
}, z.core.$strip>>;
|
|
120
|
+
schedule: z.ZodOptional<z.ZodObject<{
|
|
121
|
+
scheduleCount: z.ZodNumber;
|
|
122
|
+
totalDeliveries: z.ZodNumber;
|
|
123
|
+
successDeliveries: z.ZodNumber;
|
|
124
|
+
failedDeliveries: z.ZodNumber;
|
|
125
|
+
}, z.core.$strip>>;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
}, z.core.$strip>;
|
|
128
|
+
export declare const ServiceStatsResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
129
|
+
success: z.ZodLiteral<false>;
|
|
130
|
+
message: z.ZodString;
|
|
131
|
+
code: z.ZodOptional<z.ZodString>;
|
|
132
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
133
|
+
success: z.ZodLiteral<true>;
|
|
134
|
+
data: z.ZodObject<{
|
|
135
|
+
services: z.ZodObject<{
|
|
136
|
+
database: z.ZodOptional<z.ZodObject<{
|
|
137
|
+
databaseCount: z.ZodNumber;
|
|
138
|
+
totalTableCount: z.ZodNumber;
|
|
139
|
+
totalRecordCount: z.ZodNumber;
|
|
140
|
+
totalSizeBytes: z.ZodNumber;
|
|
141
|
+
}, z.core.$strip>>;
|
|
142
|
+
keyvalue: z.ZodOptional<z.ZodObject<{
|
|
143
|
+
namespaceCount: z.ZodNumber;
|
|
144
|
+
keyCount: z.ZodNumber;
|
|
145
|
+
totalSizeBytes: z.ZodNumber;
|
|
146
|
+
}, z.core.$strip>>;
|
|
147
|
+
vector: z.ZodOptional<z.ZodObject<{
|
|
148
|
+
namespaceCount: z.ZodNumber;
|
|
149
|
+
documentCount: z.ZodNumber;
|
|
150
|
+
totalSizeBytes: z.ZodNumber;
|
|
151
|
+
}, z.core.$strip>>;
|
|
152
|
+
queue: z.ZodOptional<z.ZodObject<{
|
|
153
|
+
queueCount: z.ZodNumber;
|
|
154
|
+
totalMessages: z.ZodNumber;
|
|
155
|
+
totalDlq: z.ZodNumber;
|
|
156
|
+
}, z.core.$strip>>;
|
|
157
|
+
stream: z.ZodOptional<z.ZodObject<{
|
|
158
|
+
streamCount: z.ZodNumber;
|
|
159
|
+
totalSizeBytes: z.ZodNumber;
|
|
160
|
+
}, z.core.$strip>>;
|
|
161
|
+
sandbox: z.ZodOptional<z.ZodObject<{
|
|
162
|
+
totalActive: z.ZodNumber;
|
|
163
|
+
running: z.ZodNumber;
|
|
164
|
+
idle: z.ZodNumber;
|
|
165
|
+
creating: z.ZodNumber;
|
|
166
|
+
totalExecutions: z.ZodNumber;
|
|
167
|
+
totalCpuTimeMs: z.ZodNumber;
|
|
168
|
+
totalMemoryByteSec: z.ZodNumber;
|
|
169
|
+
totalNetworkEgressBytes: z.ZodNumber;
|
|
170
|
+
}, z.core.$strip>>;
|
|
171
|
+
email: z.ZodOptional<z.ZodObject<{
|
|
172
|
+
addressCount: z.ZodNumber;
|
|
173
|
+
inboundCount: z.ZodNumber;
|
|
174
|
+
outboundCount: z.ZodNumber;
|
|
175
|
+
outboundSuccess: z.ZodNumber;
|
|
176
|
+
outboundFailed: z.ZodNumber;
|
|
177
|
+
}, z.core.$strip>>;
|
|
178
|
+
task: z.ZodOptional<z.ZodObject<{
|
|
179
|
+
total: z.ZodNumber;
|
|
180
|
+
open: z.ZodNumber;
|
|
181
|
+
inProgress: z.ZodNumber;
|
|
182
|
+
closed: z.ZodNumber;
|
|
183
|
+
}, z.core.$strip>>;
|
|
184
|
+
schedule: z.ZodOptional<z.ZodObject<{
|
|
185
|
+
scheduleCount: z.ZodNumber;
|
|
186
|
+
totalDeliveries: z.ZodNumber;
|
|
187
|
+
successDeliveries: z.ZodNumber;
|
|
188
|
+
failedDeliveries: z.ZodNumber;
|
|
189
|
+
}, z.core.$strip>>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
}, z.core.$strip>;
|
|
192
|
+
}, z.core.$strip>], "success">;
|
|
193
|
+
export type KeyValueStat = z.infer<typeof KeyValueStatSchema>;
|
|
194
|
+
export type VectorStat = z.infer<typeof VectorStatSchema>;
|
|
195
|
+
export type QueueStat = z.infer<typeof QueueStatSchema>;
|
|
196
|
+
export type StreamStat = z.infer<typeof StreamStatSchema>;
|
|
197
|
+
export type SandboxStat = z.infer<typeof SandboxStatSchema>;
|
|
198
|
+
export type EmailStat = z.infer<typeof EmailStatSchema>;
|
|
199
|
+
export type TaskStat = z.infer<typeof TaskStatSchema>;
|
|
200
|
+
export type ScheduleStat = z.infer<typeof ScheduleStatSchema>;
|
|
201
|
+
export type DatabaseStat = z.infer<typeof DatabaseStatSchema>;
|
|
202
|
+
export type ServiceStatsData = z.infer<typeof ServiceStatsDataSchema>;
|
|
203
|
+
export type ServiceStatsResponse = z.infer<typeof ServiceStatsResponseSchema>;
|
|
204
|
+
/**
|
|
205
|
+
* Valid service names that can be used to filter stats.
|
|
206
|
+
*/
|
|
207
|
+
export declare const VALID_SERVICES: readonly ["database", "keyvalue", "email", "vector", "schedule", "task", "stream", "sandbox", "queue"];
|
|
208
|
+
export type ServiceName = (typeof VALID_SERVICES)[number];
|
|
209
|
+
export interface ServiceStatsOptions {
|
|
210
|
+
/**
|
|
211
|
+
* Filter to a specific service. If omitted, returns stats for all services.
|
|
212
|
+
*/
|
|
213
|
+
service?: ServiceName;
|
|
214
|
+
/**
|
|
215
|
+
* Start time filter (ISO 8601 timestamp).
|
|
216
|
+
*/
|
|
217
|
+
start?: string;
|
|
218
|
+
/**
|
|
219
|
+
* End time filter (ISO 8601 timestamp).
|
|
220
|
+
*/
|
|
221
|
+
end?: string;
|
|
222
|
+
/**
|
|
223
|
+
* For CLI auth: sets x-agentuity-orgid header.
|
|
224
|
+
* Required when using CLI token auth (bearer tokens without embedded org).
|
|
225
|
+
*/
|
|
226
|
+
orgIdHeader?: string;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get aggregated stats for services used by an organization.
|
|
230
|
+
*
|
|
231
|
+
* Returns per-service stats with service-specific fields (counts, sizes, etc.).
|
|
232
|
+
* Services that error on the backend are omitted from the response.
|
|
233
|
+
* Services with no provisioned tenant DB return zero values.
|
|
234
|
+
*
|
|
235
|
+
* @param client - The API client instance
|
|
236
|
+
* @param orgId - The organization ID
|
|
237
|
+
* @param options - Optional filtering (service, time range)
|
|
238
|
+
* @returns Service stats data with per-service breakdown
|
|
239
|
+
* @throws {ServiceStatsError} If the API request fails
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* // Get stats for all services
|
|
244
|
+
* const stats = await getServiceStats(client, 'org_123');
|
|
245
|
+
* console.log(`KV keys: ${stats.services.keyvalue?.keyCount}`);
|
|
246
|
+
* ```
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
* // Get stats for a specific service
|
|
251
|
+
* const stats = await getServiceStats(client, 'org_123', {
|
|
252
|
+
* service: 'keyvalue',
|
|
253
|
+
* });
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
export declare function getServiceStats(client: APIClient, orgId: string, options?: ServiceStatsOptions): Promise<ServiceStatsData>;
|
|
257
|
+
//# sourceMappingURL=stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/api/services/stats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,WAAW,CAAC;AAK9D,eAAO,MAAM,iBAAiB;;iBACpB,MAAM;;;;;;;iBAAN,MAAM;;;CACZ,CAAC;AAIL,eAAO,MAAM,kBAAkB;;;;iBAI7B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;iBAI1B,CAAC;AAEH,eAAO,MAA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AgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAI9E;;GAEG;AACH,eAAO,MAAM,cAAc,wGAUjB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAI1D,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,eAAe,CACpC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CA4B3B"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIResponseSchema } from "../api.js";
|
|
3
|
+
import { StructuredError } from '@agentuity/core';
|
|
4
|
+
// --- Error ---
|
|
5
|
+
export const ServiceStatsError = StructuredError('ServiceStatsError')();
|
|
6
|
+
// --- Per-Service Stat Schemas ---
|
|
7
|
+
export const KeyValueStatSchema = z.object({
|
|
8
|
+
namespaceCount: z.number(),
|
|
9
|
+
keyCount: z.number(),
|
|
10
|
+
totalSizeBytes: z.number(),
|
|
11
|
+
});
|
|
12
|
+
export const VectorStatSchema = z.object({
|
|
13
|
+
namespaceCount: z.number(),
|
|
14
|
+
documentCount: z.number(),
|
|
15
|
+
totalSizeBytes: z.number(),
|
|
16
|
+
});
|
|
17
|
+
export const QueueStatSchema = z.object({
|
|
18
|
+
queueCount: z.number(),
|
|
19
|
+
totalMessages: z.number(),
|
|
20
|
+
totalDlq: z.number(),
|
|
21
|
+
});
|
|
22
|
+
export const StreamStatSchema = z.object({
|
|
23
|
+
streamCount: z.number(),
|
|
24
|
+
totalSizeBytes: z.number(),
|
|
25
|
+
});
|
|
26
|
+
export const SandboxStatSchema = z.object({
|
|
27
|
+
totalActive: z.number(),
|
|
28
|
+
running: z.number(),
|
|
29
|
+
idle: z.number(),
|
|
30
|
+
creating: z.number(),
|
|
31
|
+
totalExecutions: z.number(),
|
|
32
|
+
totalCpuTimeMs: z.number(),
|
|
33
|
+
totalMemoryByteSec: z.number(),
|
|
34
|
+
totalNetworkEgressBytes: z.number(),
|
|
35
|
+
});
|
|
36
|
+
export const EmailStatSchema = z.object({
|
|
37
|
+
addressCount: z.number(),
|
|
38
|
+
inboundCount: z.number(),
|
|
39
|
+
outboundCount: z.number(),
|
|
40
|
+
outboundSuccess: z.number(),
|
|
41
|
+
outboundFailed: z.number(),
|
|
42
|
+
});
|
|
43
|
+
export const TaskStatSchema = z.object({
|
|
44
|
+
total: z.number(),
|
|
45
|
+
open: z.number(),
|
|
46
|
+
inProgress: z.number(),
|
|
47
|
+
closed: z.number(),
|
|
48
|
+
});
|
|
49
|
+
export const ScheduleStatSchema = z.object({
|
|
50
|
+
scheduleCount: z.number(),
|
|
51
|
+
totalDeliveries: z.number(),
|
|
52
|
+
successDeliveries: z.number(),
|
|
53
|
+
failedDeliveries: z.number(),
|
|
54
|
+
});
|
|
55
|
+
export const DatabaseStatSchema = z.object({
|
|
56
|
+
databaseCount: z.number(),
|
|
57
|
+
totalTableCount: z.number(),
|
|
58
|
+
totalRecordCount: z.number(),
|
|
59
|
+
totalSizeBytes: z.number(),
|
|
60
|
+
});
|
|
61
|
+
// --- Aggregate Schema ---
|
|
62
|
+
export const ServiceStatsDataSchema = z.object({
|
|
63
|
+
services: z.object({
|
|
64
|
+
database: DatabaseStatSchema.optional(),
|
|
65
|
+
keyvalue: KeyValueStatSchema.optional(),
|
|
66
|
+
vector: VectorStatSchema.optional(),
|
|
67
|
+
queue: QueueStatSchema.optional(),
|
|
68
|
+
stream: StreamStatSchema.optional(),
|
|
69
|
+
sandbox: SandboxStatSchema.optional(),
|
|
70
|
+
email: EmailStatSchema.optional(),
|
|
71
|
+
task: TaskStatSchema.optional(),
|
|
72
|
+
schedule: ScheduleStatSchema.optional(),
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
export const ServiceStatsResponseSchema = APIResponseSchema(ServiceStatsDataSchema);
|
|
76
|
+
// --- Valid Services ---
|
|
77
|
+
/**
|
|
78
|
+
* Valid service names that can be used to filter stats.
|
|
79
|
+
*/
|
|
80
|
+
export const VALID_SERVICES = [
|
|
81
|
+
'database',
|
|
82
|
+
'keyvalue',
|
|
83
|
+
'email',
|
|
84
|
+
'vector',
|
|
85
|
+
'schedule',
|
|
86
|
+
'task',
|
|
87
|
+
'stream',
|
|
88
|
+
'sandbox',
|
|
89
|
+
'queue',
|
|
90
|
+
];
|
|
91
|
+
// --- API Function ---
|
|
92
|
+
/**
|
|
93
|
+
* Get aggregated stats for services used by an organization.
|
|
94
|
+
*
|
|
95
|
+
* Returns per-service stats with service-specific fields (counts, sizes, etc.).
|
|
96
|
+
* Services that error on the backend are omitted from the response.
|
|
97
|
+
* Services with no provisioned tenant DB return zero values.
|
|
98
|
+
*
|
|
99
|
+
* @param client - The API client instance
|
|
100
|
+
* @param orgId - The organization ID
|
|
101
|
+
* @param options - Optional filtering (service, time range)
|
|
102
|
+
* @returns Service stats data with per-service breakdown
|
|
103
|
+
* @throws {ServiceStatsError} If the API request fails
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* // Get stats for all services
|
|
108
|
+
* const stats = await getServiceStats(client, 'org_123');
|
|
109
|
+
* console.log(`KV keys: ${stats.services.keyvalue?.keyCount}`);
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* // Get stats for a specific service
|
|
115
|
+
* const stats = await getServiceStats(client, 'org_123', {
|
|
116
|
+
* service: 'keyvalue',
|
|
117
|
+
* });
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export async function getServiceStats(client, orgId, options) {
|
|
121
|
+
const params = new URLSearchParams();
|
|
122
|
+
if (options?.service)
|
|
123
|
+
params.set('service', options.service);
|
|
124
|
+
if (options?.start)
|
|
125
|
+
params.set('start', options.start);
|
|
126
|
+
if (options?.end)
|
|
127
|
+
params.set('end', options.end);
|
|
128
|
+
const queryString = params.toString();
|
|
129
|
+
const url = `/services/stats/2026-02-26/${encodeURIComponent(orgId)}${queryString ? `?${queryString}` : ''}`;
|
|
130
|
+
const headers = {};
|
|
131
|
+
if (options?.orgIdHeader) {
|
|
132
|
+
headers['x-agentuity-orgid'] = options.orgIdHeader;
|
|
133
|
+
}
|
|
134
|
+
const resp = await client.get(url, ServiceStatsResponseSchema, undefined, Object.keys(headers).length > 0 ? headers : undefined);
|
|
135
|
+
if (resp.success) {
|
|
136
|
+
return resp.data;
|
|
137
|
+
}
|
|
138
|
+
throw new ServiceStatsError({
|
|
139
|
+
message: resp.message || 'Failed to get service stats',
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../../src/api/services/stats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAkB,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,gBAAgB;AAEhB,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC,mBAAmB,CAAC,EAEjE,CAAC;AAEL,mCAAmC;AAEnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;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EAAE,EAAE,CAAC;IAE7G,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,IAAI,OAAO,EAAE,WAAW,EAAE,CAAC;QAC1B,OAAO,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IACpD,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAC5B,GAAG,EACH,0BAA0B,EAC1B,SAAS,EACT,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CACrD,CAAC;IAEF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,iBAAiB,CAAC;QAC3B,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,6BAA6B;KACtD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type APIClient } from '../api.ts';
|
|
3
|
+
import { type ListWebhookDeliveriesRequest, type WebhookApiOptions, type WebhookDelivery } from './types.ts';
|
|
4
|
+
export declare const WebhookDeliveryResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5
|
+
success: z.ZodLiteral<false>;
|
|
6
|
+
message: z.ZodString;
|
|
7
|
+
code: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
9
|
+
success: z.ZodLiteral<true>;
|
|
10
|
+
data: z.ZodObject<{
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
date: z.ZodString;
|
|
13
|
+
webhook_id: z.ZodString;
|
|
14
|
+
webhook_destination_id: z.ZodString;
|
|
15
|
+
webhook_receipt_id: z.ZodString;
|
|
16
|
+
status: z.ZodEnum<{
|
|
17
|
+
success: "success";
|
|
18
|
+
pending: "pending";
|
|
19
|
+
failed: "failed";
|
|
20
|
+
}>;
|
|
21
|
+
retries: z.ZodNumber;
|
|
22
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
23
|
+
response: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
}, z.core.$strip>], "success">;
|
|
26
|
+
export declare const WebhookDeliveriesListResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
27
|
+
success: z.ZodLiteral<false>;
|
|
28
|
+
message: z.ZodString;
|
|
29
|
+
code: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
+
success: z.ZodLiteral<true>;
|
|
32
|
+
data: z.ZodArray<z.ZodObject<{
|
|
33
|
+
id: z.ZodString;
|
|
34
|
+
date: z.ZodString;
|
|
35
|
+
webhook_id: z.ZodString;
|
|
36
|
+
webhook_destination_id: z.ZodString;
|
|
37
|
+
webhook_receipt_id: z.ZodString;
|
|
38
|
+
status: z.ZodEnum<{
|
|
39
|
+
success: "success";
|
|
40
|
+
pending: "pending";
|
|
41
|
+
failed: "failed";
|
|
42
|
+
}>;
|
|
43
|
+
retries: z.ZodNumber;
|
|
44
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
45
|
+
response: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
}, z.core.$strip>], "success">;
|
|
48
|
+
/**
|
|
49
|
+
* List deliveries for a webhook with optional pagination.
|
|
50
|
+
*
|
|
51
|
+
* Deliveries represent attempts to forward a received webhook payload to a destination.
|
|
52
|
+
*
|
|
53
|
+
* @param client - The API client instance
|
|
54
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
55
|
+
* @param params - Optional pagination parameters
|
|
56
|
+
* @param options - Optional API options (e.g., orgId)
|
|
57
|
+
* @returns Object containing the list of deliveries
|
|
58
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
59
|
+
* @throws {WebhookError} If the API request fails
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const { deliveries } = await listWebhookDeliveries(client, 'wh_abc123', { limit: 10 });
|
|
64
|
+
* for (const delivery of deliveries) {
|
|
65
|
+
* console.log(`Delivery ${delivery.id}: ${delivery.status}`);
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function listWebhookDeliveries(client: APIClient, webhookId: string, params?: ListWebhookDeliveriesRequest, options?: WebhookApiOptions): Promise<{
|
|
70
|
+
deliveries: WebhookDelivery[];
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Retry a failed webhook delivery.
|
|
74
|
+
*
|
|
75
|
+
* Re-attempts delivery of a webhook payload to the destination. This creates
|
|
76
|
+
* a new delivery attempt for the same receipt and destination.
|
|
77
|
+
*
|
|
78
|
+
* @param client - The API client instance
|
|
79
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
80
|
+
* @param deliveryId - The delivery ID to retry (prefixed with whdv_)
|
|
81
|
+
* @param options - Optional API options (e.g., orgId)
|
|
82
|
+
* @returns The new delivery attempt
|
|
83
|
+
* @throws {WebhookDeliveryNotFoundError} If the delivery does not exist
|
|
84
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
85
|
+
* @throws {WebhookError} If the API request fails
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const delivery = await retryWebhookDelivery(client, 'wh_abc123', 'whdv_def456');
|
|
90
|
+
* console.log(`Retry delivery ${delivery.id}: ${delivery.status}`);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function retryWebhookDelivery(client: APIClient, webhookId: string, deliveryId: string, options?: WebhookApiOptions): Promise<WebhookDelivery>;
|
|
94
|
+
//# sourceMappingURL=deliveries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliveries.d.ts","sourceRoot":"","sources":["../../../src/api/webhook/deliveries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,WAAW,CAAC;AAC9D,OAAO,EACN,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,eAAe,EAEpB,MAAM,YAAY,CAAC;AASpB,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;8BAA2C,CAAC;AACtF,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;8BAE/C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,qBAAqB,CAC1C,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,4BAA4B,EACrC,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC;IAAE,UAAU,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC,CA8B5C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,oBAAoB,CACzC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,eAAe,CAAC,CAuB1B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIResponseSchema } from "../api.js";
|
|
3
|
+
import { WebhookDeliverySchema, } from "./types.js";
|
|
4
|
+
import { buildWebhookHeaders, WebhookError, webhookApiPath, webhookApiPathWithQuery, withWebhookErrorHandling, } from "./util.js";
|
|
5
|
+
export const WebhookDeliveryResponseSchema = APIResponseSchema(WebhookDeliverySchema);
|
|
6
|
+
export const WebhookDeliveriesListResponseSchema = APIResponseSchema(z.array(WebhookDeliverySchema));
|
|
7
|
+
/**
|
|
8
|
+
* List deliveries for a webhook with optional pagination.
|
|
9
|
+
*
|
|
10
|
+
* Deliveries represent attempts to forward a received webhook payload to a destination.
|
|
11
|
+
*
|
|
12
|
+
* @param client - The API client instance
|
|
13
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
14
|
+
* @param params - Optional pagination parameters
|
|
15
|
+
* @param options - Optional API options (e.g., orgId)
|
|
16
|
+
* @returns Object containing the list of deliveries
|
|
17
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
18
|
+
* @throws {WebhookError} If the API request fails
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const { deliveries } = await listWebhookDeliveries(client, 'wh_abc123', { limit: 10 });
|
|
23
|
+
* for (const delivery of deliveries) {
|
|
24
|
+
* console.log(`Delivery ${delivery.id}: ${delivery.status}`);
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export async function listWebhookDeliveries(client, webhookId, params, options) {
|
|
29
|
+
const searchParams = new URLSearchParams();
|
|
30
|
+
if (params?.limit !== undefined) {
|
|
31
|
+
searchParams.set('limit', String(params.limit));
|
|
32
|
+
}
|
|
33
|
+
if (params?.offset !== undefined) {
|
|
34
|
+
searchParams.set('offset', String(params.offset));
|
|
35
|
+
}
|
|
36
|
+
const queryString = searchParams.toString();
|
|
37
|
+
const url = webhookApiPathWithQuery('delivery-list', queryString || undefined, webhookId);
|
|
38
|
+
const resp = await withWebhookErrorHandling(() => client.get(url, WebhookDeliveriesListResponseSchema, undefined, buildWebhookHeaders(options?.orgId)), { webhookId });
|
|
39
|
+
if (resp.success) {
|
|
40
|
+
return { deliveries: resp.data };
|
|
41
|
+
}
|
|
42
|
+
throw new WebhookError({
|
|
43
|
+
webhookId,
|
|
44
|
+
message: resp.message || 'Failed to list webhook deliveries',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Retry a failed webhook delivery.
|
|
49
|
+
*
|
|
50
|
+
* Re-attempts delivery of a webhook payload to the destination. This creates
|
|
51
|
+
* a new delivery attempt for the same receipt and destination.
|
|
52
|
+
*
|
|
53
|
+
* @param client - The API client instance
|
|
54
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
55
|
+
* @param deliveryId - The delivery ID to retry (prefixed with whdv_)
|
|
56
|
+
* @param options - Optional API options (e.g., orgId)
|
|
57
|
+
* @returns The new delivery attempt
|
|
58
|
+
* @throws {WebhookDeliveryNotFoundError} If the delivery does not exist
|
|
59
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
60
|
+
* @throws {WebhookError} If the API request fails
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const delivery = await retryWebhookDelivery(client, 'wh_abc123', 'whdv_def456');
|
|
65
|
+
* console.log(`Retry delivery ${delivery.id}: ${delivery.status}`);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export async function retryWebhookDelivery(client, webhookId, deliveryId, options) {
|
|
69
|
+
const url = webhookApiPath('delivery-retry', webhookId, deliveryId);
|
|
70
|
+
const resp = await withWebhookErrorHandling(() => client.post(url, {}, WebhookDeliveryResponseSchema, z.object({}), undefined, buildWebhookHeaders(options?.orgId)), { webhookId, deliveryId });
|
|
71
|
+
if (resp.success) {
|
|
72
|
+
return resp.data;
|
|
73
|
+
}
|
|
74
|
+
throw new WebhookError({
|
|
75
|
+
webhookId,
|
|
76
|
+
message: resp.message || 'Failed to retry webhook delivery',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=deliveries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliveries.js","sourceRoot":"","sources":["../../../src/api/webhook/deliveries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAkB,iB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