@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,249 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Webhook destination type schema.
|
|
4
|
+
*
|
|
5
|
+
* Currently only 'url' destinations are supported.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const destType = WebhookDestinationTypeSchema.parse('url');
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const WebhookDestinationTypeSchema: z.ZodEnum<{
|
|
13
|
+
url: "url";
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Webhook destination type.
|
|
17
|
+
*/
|
|
18
|
+
export type WebhookDestinationType = z.infer<typeof WebhookDestinationTypeSchema>;
|
|
19
|
+
/**
|
|
20
|
+
* Webhook delivery status schema.
|
|
21
|
+
*
|
|
22
|
+
* - `pending`: Delivery is queued and waiting to be sent.
|
|
23
|
+
* - `success`: Delivery was completed successfully.
|
|
24
|
+
* - `failed`: Delivery failed after all retry attempts.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const status = WebhookDeliveryStatusSchema.parse('success');
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const WebhookDeliveryStatusSchema: z.ZodEnum<{
|
|
32
|
+
success: "success";
|
|
33
|
+
pending: "pending";
|
|
34
|
+
failed: "failed";
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Webhook delivery status type.
|
|
38
|
+
*/
|
|
39
|
+
export type WebhookDeliveryStatus = z.infer<typeof WebhookDeliveryStatusSchema>;
|
|
40
|
+
/**
|
|
41
|
+
* Webhook schema representing a webhook endpoint.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const webhook = await getWebhook(client, 'wh_abc123');
|
|
46
|
+
* console.log(`Webhook: ${webhook.name} (${webhook.id})`);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const WebhookSchema: z.ZodObject<{
|
|
50
|
+
id: z.ZodString;
|
|
51
|
+
created_at: z.ZodString;
|
|
52
|
+
updated_at: z.ZodString;
|
|
53
|
+
created_by: z.ZodString;
|
|
54
|
+
name: z.ZodString;
|
|
55
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
|
+
url: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
/**
|
|
59
|
+
* Webhook type.
|
|
60
|
+
*/
|
|
61
|
+
export type Webhook = z.infer<typeof WebhookSchema>;
|
|
62
|
+
/**
|
|
63
|
+
* Webhook destination schema representing a delivery target for webhook events.
|
|
64
|
+
*
|
|
65
|
+
* Destinations define where incoming webhook payloads are forwarded to.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const destinations = await listWebhookDestinations(client, 'wh_abc123');
|
|
70
|
+
* for (const dest of destinations) {
|
|
71
|
+
* console.log(`Destination ${dest.id}: type=${dest.type}`);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare const WebhookDestinationSchema: z.ZodObject<{
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
created_at: z.ZodString;
|
|
78
|
+
updated_at: z.ZodString;
|
|
79
|
+
created_by: z.ZodString;
|
|
80
|
+
webhook_id: z.ZodString;
|
|
81
|
+
type: z.ZodEnum<{
|
|
82
|
+
url: "url";
|
|
83
|
+
}>;
|
|
84
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
/**
|
|
87
|
+
* Webhook destination type.
|
|
88
|
+
*/
|
|
89
|
+
export type WebhookDestination = z.infer<typeof WebhookDestinationSchema>;
|
|
90
|
+
/**
|
|
91
|
+
* Webhook receipt schema representing an incoming webhook payload that was received.
|
|
92
|
+
*
|
|
93
|
+
* Receipts capture the raw payload and headers of each incoming webhook request.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const receipt = await getWebhookReceipt(client, 'wh_abc123', 'whrc_def456');
|
|
98
|
+
* console.log(`Receipt ${receipt.id}: received at ${receipt.date}`);
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare const WebhookReceiptSchema: z.ZodObject<{
|
|
102
|
+
id: z.ZodString;
|
|
103
|
+
date: z.ZodString;
|
|
104
|
+
webhook_id: z.ZodString;
|
|
105
|
+
headers: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
106
|
+
payload: z.ZodUnknown;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
/**
|
|
109
|
+
* Webhook receipt type.
|
|
110
|
+
*/
|
|
111
|
+
export type WebhookReceipt = z.infer<typeof WebhookReceiptSchema>;
|
|
112
|
+
/**
|
|
113
|
+
* Webhook delivery schema representing a delivery attempt to a destination.
|
|
114
|
+
*
|
|
115
|
+
* Deliveries track the status and result of forwarding a received webhook
|
|
116
|
+
* payload to a configured destination.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const deliveries = await listWebhookDeliveries(client, 'wh_abc123');
|
|
121
|
+
* for (const delivery of deliveries) {
|
|
122
|
+
* console.log(`Delivery ${delivery.id}: ${delivery.status}`);
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare const WebhookDeliverySchema: z.ZodObject<{
|
|
127
|
+
id: z.ZodString;
|
|
128
|
+
date: z.ZodString;
|
|
129
|
+
webhook_id: z.ZodString;
|
|
130
|
+
webhook_destination_id: z.ZodString;
|
|
131
|
+
webhook_receipt_id: z.ZodString;
|
|
132
|
+
status: z.ZodEnum<{
|
|
133
|
+
success: "success";
|
|
134
|
+
pending: "pending";
|
|
135
|
+
failed: "failed";
|
|
136
|
+
}>;
|
|
137
|
+
retries: z.ZodNumber;
|
|
138
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
139
|
+
response: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
/**
|
|
142
|
+
* Webhook delivery type.
|
|
143
|
+
*/
|
|
144
|
+
export type WebhookDelivery = z.infer<typeof WebhookDeliverySchema>;
|
|
145
|
+
/**
|
|
146
|
+
* Common options for webhook API calls.
|
|
147
|
+
*
|
|
148
|
+
* Used to pass organization context when calling from CLI or other
|
|
149
|
+
* contexts where the org is not implicit in the authentication token.
|
|
150
|
+
*/
|
|
151
|
+
export interface WebhookApiOptions {
|
|
152
|
+
/**
|
|
153
|
+
* Organization ID for the request.
|
|
154
|
+
* Required when using user authentication (CLI) instead of SDK key.
|
|
155
|
+
*/
|
|
156
|
+
orgId?: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Request schema for creating a new webhook.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* const request: CreateWebhookRequest = {
|
|
164
|
+
* name: 'github-events',
|
|
165
|
+
* description: 'Receives GitHub webhook events',
|
|
166
|
+
* };
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export declare const CreateWebhookRequestSchema: z.ZodObject<{
|
|
170
|
+
name: z.ZodString;
|
|
171
|
+
description: z.ZodOptional<z.ZodString>;
|
|
172
|
+
}, z.core.$strip>;
|
|
173
|
+
/** Request type for creating a webhook. */
|
|
174
|
+
export type CreateWebhookRequest = z.infer<typeof CreateWebhookRequestSchema>;
|
|
175
|
+
/**
|
|
176
|
+
* Request schema for updating an existing webhook.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const request: UpdateWebhookRequest = {
|
|
181
|
+
* name: 'github-events-v2',
|
|
182
|
+
* description: 'Updated description',
|
|
183
|
+
* };
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare const UpdateWebhookRequestSchema: z.ZodObject<{
|
|
187
|
+
name: z.ZodString;
|
|
188
|
+
description: z.ZodOptional<z.ZodString>;
|
|
189
|
+
}, z.core.$strip>;
|
|
190
|
+
/** Request type for updating a webhook. */
|
|
191
|
+
export type UpdateWebhookRequest = z.infer<typeof UpdateWebhookRequestSchema>;
|
|
192
|
+
/**
|
|
193
|
+
* Request schema for creating a webhook destination.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const request: CreateWebhookDestinationRequest = {
|
|
198
|
+
* type: 'url',
|
|
199
|
+
* config: { url: 'https://api.example.com/webhook' },
|
|
200
|
+
* };
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export declare const CreateWebhookDestinationRequestSchema: z.ZodObject<{
|
|
204
|
+
type: z.ZodEnum<{
|
|
205
|
+
url: "url";
|
|
206
|
+
}>;
|
|
207
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
208
|
+
}, z.core.$strip>;
|
|
209
|
+
/** Request type for creating a webhook destination. */
|
|
210
|
+
export type CreateWebhookDestinationRequest = z.infer<typeof CreateWebhookDestinationRequestSchema>;
|
|
211
|
+
/**
|
|
212
|
+
* Request schema for updating a webhook destination.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const request: UpdateWebhookDestinationRequest = {
|
|
217
|
+
* config: { url: 'https://api.example.com/webhook/v2' },
|
|
218
|
+
* };
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
export declare const UpdateWebhookDestinationRequestSchema: z.ZodObject<{
|
|
222
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
223
|
+
}, z.core.$strip>;
|
|
224
|
+
/** Request type for updating a webhook destination. */
|
|
225
|
+
export type UpdateWebhookDestinationRequest = z.infer<typeof UpdateWebhookDestinationRequestSchema>;
|
|
226
|
+
export declare const PaginationRequestSchema: z.ZodObject<{
|
|
227
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
228
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
229
|
+
}, z.core.$strip>;
|
|
230
|
+
export type PaginationRequest = z.infer<typeof PaginationRequestSchema>;
|
|
231
|
+
export declare const ListWebhooksRequestSchema: z.ZodObject<{
|
|
232
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
233
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
234
|
+
}, z.core.$strip>;
|
|
235
|
+
/** Request type for listing webhooks. */
|
|
236
|
+
export type ListWebhooksRequest = z.infer<typeof ListWebhooksRequestSchema>;
|
|
237
|
+
export declare const ListWebhookReceiptsRequestSchema: z.ZodObject<{
|
|
238
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
239
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
240
|
+
}, z.core.$strip>;
|
|
241
|
+
/** Request type for listing webhook receipts. */
|
|
242
|
+
export type ListWebhookReceiptsRequest = z.infer<typeof ListWebhookReceiptsRequestSchema>;
|
|
243
|
+
export declare const ListWebhookDeliveriesRequestSchema: z.ZodObject<{
|
|
244
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
245
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
246
|
+
}, z.core.$strip>;
|
|
247
|
+
/** Request type for listing webhook deliveries. */
|
|
248
|
+
export type ListWebhookDeliveriesRequest = z.infer<typeof ListWebhookDeliveriesRequestSchema>;
|
|
249
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/webhook/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;;;;;;;GASG;AACH,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;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B;;;iBAKrC,CAAC;AAEH,2CAA2C;AAC3C,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qCAAqC;;;;;iBAKhD,CAAC;AAEH,uDAAuD;AACvD,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAEpG;;;;;;;;;GASG;AACH,eAAO,MAAM,qCAAqC;;iBAGhD,CAAC;AAEH,uDAAuD;AACvD,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAEpG,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,yBAAyB;;;iBAA0B,CAAC;AAEjE,yCAAyC;AACzC,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,gCAAgC;;;iBAA0B,CAAC;AAExE,iDAAiD;AACjD,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE1F,eAAO,MAAM,kCAAkC;;;iBAA0B,CAAC;AAE1E,mDAAmD;AACnD,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// Webhook Destination Types
|
|
4
|
+
// ============================================================================
|
|
5
|
+
/**
|
|
6
|
+
* Webhook destination type schema.
|
|
7
|
+
*
|
|
8
|
+
* Currently only 'url' destinations are supported.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const destType = WebhookDestinationTypeSchema.parse('url');
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export const WebhookDestinationTypeSchema = z.enum(['url']);
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Webhook Delivery Status
|
|
18
|
+
// ============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Webhook delivery status schema.
|
|
21
|
+
*
|
|
22
|
+
* - `pending`: Delivery is queued and waiting to be sent.
|
|
23
|
+
* - `success`: Delivery was completed successfully.
|
|
24
|
+
* - `failed`: Delivery failed after all retry attempts.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const status = WebhookDeliveryStatusSchema.parse('success');
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export const WebhookDeliveryStatusSchema = z.enum(['pending', 'success', 'failed']);
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Core Schemas
|
|
34
|
+
// ============================================================================
|
|
35
|
+
/**
|
|
36
|
+
* Webhook schema representing a webhook endpoint.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const webhook = await getWebhook(client, 'wh_abc123');
|
|
41
|
+
* console.log(`Webhook: ${webhook.name} (${webhook.id})`);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export const WebhookSchema = z.object({
|
|
45
|
+
/** Unique identifier for the webhook (prefixed with wh_). */
|
|
46
|
+
id: z.string(),
|
|
47
|
+
/** ISO 8601 timestamp when the webhook was created. */
|
|
48
|
+
created_at: z.string(),
|
|
49
|
+
/** ISO 8601 timestamp when the webhook was last updated. */
|
|
50
|
+
updated_at: z.string(),
|
|
51
|
+
/** ID of the user who created the webhook. */
|
|
52
|
+
created_by: z.string(),
|
|
53
|
+
/** Human-readable webhook name. */
|
|
54
|
+
name: z.string(),
|
|
55
|
+
/** Optional description of the webhook's purpose. */
|
|
56
|
+
description: z.string().nullable().optional(),
|
|
57
|
+
/** Fully-qualified ingest URL for sending events to this webhook. Only present on create. */
|
|
58
|
+
url: z.string().optional(),
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Webhook destination schema representing a delivery target for webhook events.
|
|
62
|
+
*
|
|
63
|
+
* Destinations define where incoming webhook payloads are forwarded to.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const destinations = await listWebhookDestinations(client, 'wh_abc123');
|
|
68
|
+
* for (const dest of destinations) {
|
|
69
|
+
* console.log(`Destination ${dest.id}: type=${dest.type}`);
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export const WebhookDestinationSchema = z.object({
|
|
74
|
+
/** Unique identifier for the destination (prefixed with whds_). */
|
|
75
|
+
id: z.string(),
|
|
76
|
+
/** ISO 8601 timestamp when the destination was created. */
|
|
77
|
+
created_at: z.string(),
|
|
78
|
+
/** ISO 8601 timestamp when the destination was last updated. */
|
|
79
|
+
updated_at: z.string(),
|
|
80
|
+
/** ID of the user who created the destination. */
|
|
81
|
+
created_by: z.string(),
|
|
82
|
+
/** ID of the webhook this destination belongs to. */
|
|
83
|
+
webhook_id: z.string(),
|
|
84
|
+
/** Type of destination (currently only 'url'). */
|
|
85
|
+
type: WebhookDestinationTypeSchema,
|
|
86
|
+
/** Configuration object for the destination (e.g., URL, headers). */
|
|
87
|
+
config: z.record(z.string(), z.unknown()),
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* Webhook receipt schema representing an incoming webhook payload that was received.
|
|
91
|
+
*
|
|
92
|
+
* Receipts capture the raw payload and headers of each incoming webhook request.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const receipt = await getWebhookReceipt(client, 'wh_abc123', 'whrc_def456');
|
|
97
|
+
* console.log(`Receipt ${receipt.id}: received at ${receipt.date}`);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export const WebhookReceiptSchema = z.object({
|
|
101
|
+
/** Unique identifier for the receipt (prefixed with whrc_). */
|
|
102
|
+
id: z.string(),
|
|
103
|
+
/** ISO 8601 timestamp when the receipt was recorded. */
|
|
104
|
+
date: z.string(),
|
|
105
|
+
/** ID of the webhook this receipt belongs to. */
|
|
106
|
+
webhook_id: z.string(),
|
|
107
|
+
/** HTTP headers from the incoming webhook request. */
|
|
108
|
+
headers: z.record(z.string(), z.unknown()),
|
|
109
|
+
/** Raw payload from the incoming webhook request (can be any type). */
|
|
110
|
+
payload: z.unknown(),
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* Webhook delivery schema representing a delivery attempt to a destination.
|
|
114
|
+
*
|
|
115
|
+
* Deliveries track the status and result of forwarding a received webhook
|
|
116
|
+
* payload to a configured destination.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const deliveries = await listWebhookDeliveries(client, 'wh_abc123');
|
|
121
|
+
* for (const delivery of deliveries) {
|
|
122
|
+
* console.log(`Delivery ${delivery.id}: ${delivery.status}`);
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export const WebhookDeliverySchema = z.object({
|
|
127
|
+
/** Unique identifier for the delivery (prefixed with whdv_). */
|
|
128
|
+
id: z.string(),
|
|
129
|
+
/** ISO 8601 timestamp when the delivery was attempted. */
|
|
130
|
+
date: z.string(),
|
|
131
|
+
/** ID of the webhook this delivery belongs to. */
|
|
132
|
+
webhook_id: z.string(),
|
|
133
|
+
/** ID of the destination this delivery was sent to. */
|
|
134
|
+
webhook_destination_id: z.string(),
|
|
135
|
+
/** ID of the receipt that triggered this delivery. */
|
|
136
|
+
webhook_receipt_id: z.string(),
|
|
137
|
+
/** Current status of the delivery. */
|
|
138
|
+
status: WebhookDeliveryStatusSchema,
|
|
139
|
+
/** Number of retry attempts made. */
|
|
140
|
+
retries: z.number(),
|
|
141
|
+
/** Error message if the delivery failed. */
|
|
142
|
+
error: z.string().nullable().optional(),
|
|
143
|
+
/** Response data from the destination (if available). */
|
|
144
|
+
response: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
145
|
+
});
|
|
146
|
+
// ============================================================================
|
|
147
|
+
// Request Schemas
|
|
148
|
+
// ============================================================================
|
|
149
|
+
/**
|
|
150
|
+
* Request schema for creating a new webhook.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const request: CreateWebhookRequest = {
|
|
155
|
+
* name: 'github-events',
|
|
156
|
+
* description: 'Receives GitHub webhook events',
|
|
157
|
+
* };
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export const CreateWebhookRequestSchema = z.object({
|
|
161
|
+
/** Human-readable name for the webhook. */
|
|
162
|
+
name: z.string(),
|
|
163
|
+
/** Optional description of the webhook's purpose. */
|
|
164
|
+
description: z.string().optional(),
|
|
165
|
+
});
|
|
166
|
+
/**
|
|
167
|
+
* Request schema for updating an existing webhook.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const request: UpdateWebhookRequest = {
|
|
172
|
+
* name: 'github-events-v2',
|
|
173
|
+
* description: 'Updated description',
|
|
174
|
+
* };
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
export const UpdateWebhookRequestSchema = z.object({
|
|
178
|
+
/** New name for the webhook. */
|
|
179
|
+
name: z.string(),
|
|
180
|
+
/** New description for the webhook. */
|
|
181
|
+
description: z.string().optional(),
|
|
182
|
+
});
|
|
183
|
+
/**
|
|
184
|
+
* Request schema for creating a webhook destination.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const request: CreateWebhookDestinationRequest = {
|
|
189
|
+
* type: 'url',
|
|
190
|
+
* config: { url: 'https://api.example.com/webhook' },
|
|
191
|
+
* };
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export const CreateWebhookDestinationRequestSchema = z.object({
|
|
195
|
+
/** Type of destination to create. */
|
|
196
|
+
type: WebhookDestinationTypeSchema,
|
|
197
|
+
/** Configuration object for the destination. */
|
|
198
|
+
config: z.record(z.string(), z.unknown()),
|
|
199
|
+
});
|
|
200
|
+
/**
|
|
201
|
+
* Request schema for updating a webhook destination.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const request: UpdateWebhookDestinationRequest = {
|
|
206
|
+
* config: { url: 'https://api.example.com/webhook/v2' },
|
|
207
|
+
* };
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
export const UpdateWebhookDestinationRequestSchema = z.object({
|
|
211
|
+
/** Updated configuration object for the destination. */
|
|
212
|
+
config: z.record(z.string(), z.unknown()).optional(),
|
|
213
|
+
});
|
|
214
|
+
export const PaginationRequestSchema = z.object({
|
|
215
|
+
limit: z.number().optional(),
|
|
216
|
+
offset: z.number().optional(),
|
|
217
|
+
});
|
|
218
|
+
export const ListWebhooksRequestSchema = PaginationRequestSchema;
|
|
219
|
+
export const ListWebhookReceiptsRequestSchema = PaginationRequestSchema;
|
|
220
|
+
export const ListWebhookDeliveriesRequestSchema = PaginationRequestSchema;
|
|
221
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/webhook/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAO5D,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;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,CAAC;AAIH,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAKjE,MAAM,CAAC,MAAM,gCAAgC,GAAG,uBAAuB,CAAC;AAKxE,MAAM,CAAC,MAAM,kCAAkC,GAAG,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* General webhook operation error.
|
|
3
|
+
*
|
|
4
|
+
* Thrown when a webhook operation fails for reasons other than not-found.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* try {
|
|
9
|
+
* await createWebhook(client, { name: 'my-webhook' });
|
|
10
|
+
* } catch (error) {
|
|
11
|
+
* if (error instanceof WebhookError) {
|
|
12
|
+
* console.error(`Webhook operation failed: ${error.message}`);
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const WebhookError: {
|
|
18
|
+
new (args?: ({
|
|
19
|
+
webhookId?: string;
|
|
20
|
+
} & {
|
|
21
|
+
message?: string;
|
|
22
|
+
cause?: unknown;
|
|
23
|
+
}) | undefined): import("@agentuity/core").RichError & {
|
|
24
|
+
readonly _tag: "WebhookError";
|
|
25
|
+
} & Readonly<{
|
|
26
|
+
webhookId?: string;
|
|
27
|
+
}>;
|
|
28
|
+
readonly defaultMessage?: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Error thrown when a webhook is not found.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* try {
|
|
36
|
+
* await getWebhook(client, 'wh_nonexistent');
|
|
37
|
+
* } catch (error) {
|
|
38
|
+
* if (error instanceof WebhookNotFoundError) {
|
|
39
|
+
* console.error(`Webhook not found: ${error.webhookId}`);
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const WebhookNotFoundError: {
|
|
45
|
+
new (args?: ({
|
|
46
|
+
webhookId: string;
|
|
47
|
+
} & {
|
|
48
|
+
message?: string;
|
|
49
|
+
cause?: unknown;
|
|
50
|
+
}) | undefined): import("@agentuity/core").RichError & {
|
|
51
|
+
readonly _tag: "WebhookNotFoundError";
|
|
52
|
+
} & Readonly<{
|
|
53
|
+
webhookId: string;
|
|
54
|
+
}>;
|
|
55
|
+
readonly defaultMessage?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Error thrown when a webhook destination is not found.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* try {
|
|
63
|
+
* await deleteWebhookDestination(client, 'wh_abc', 'whds_nonexistent');
|
|
64
|
+
* } catch (error) {
|
|
65
|
+
* if (error instanceof WebhookDestinationNotFoundError) {
|
|
66
|
+
* console.error(`Destination ${error.destinationId} not found`);
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare const WebhookDestinationNotFoundError: {
|
|
72
|
+
new (args?: ({
|
|
73
|
+
webhookId: string;
|
|
74
|
+
destinationId: string;
|
|
75
|
+
} & {
|
|
76
|
+
message?: string;
|
|
77
|
+
cause?: unknown;
|
|
78
|
+
}) | undefined): import("@agentuity/core").RichError & {
|
|
79
|
+
readonly _tag: "WebhookDestinationNotFoundError";
|
|
80
|
+
} & Readonly<{
|
|
81
|
+
webhookId: string;
|
|
82
|
+
destinationId: string;
|
|
83
|
+
}>;
|
|
84
|
+
readonly defaultMessage?: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Error thrown when a webhook receipt is not found.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* try {
|
|
92
|
+
* await getWebhookReceipt(client, 'wh_abc', 'whrc_nonexistent');
|
|
93
|
+
* } catch (error) {
|
|
94
|
+
* if (error instanceof WebhookReceiptNotFoundError) {
|
|
95
|
+
* console.error(`Receipt ${error.receiptId} not found`);
|
|
96
|
+
* }
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare const WebhookReceiptNotFoundError: {
|
|
101
|
+
new (args?: ({
|
|
102
|
+
webhookId: string;
|
|
103
|
+
receiptId: string;
|
|
104
|
+
} & {
|
|
105
|
+
message?: string;
|
|
106
|
+
cause?: unknown;
|
|
107
|
+
}) | undefined): import("@agentuity/core").RichError & {
|
|
108
|
+
readonly _tag: "WebhookReceiptNotFoundError";
|
|
109
|
+
} & Readonly<{
|
|
110
|
+
webhookId: string;
|
|
111
|
+
receiptId: string;
|
|
112
|
+
}>;
|
|
113
|
+
readonly defaultMessage?: string;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Error thrown when a webhook delivery is not found.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* try {
|
|
121
|
+
* await retryWebhookDelivery(client, 'wh_abc', 'whdv_nonexistent');
|
|
122
|
+
* } catch (error) {
|
|
123
|
+
* if (error instanceof WebhookDeliveryNotFoundError) {
|
|
124
|
+
* console.error(`Delivery ${error.deliveryId} not found`);
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export declare const WebhookDeliveryNotFoundError: {
|
|
130
|
+
new (args?: ({
|
|
131
|
+
webhookId: string;
|
|
132
|
+
deliveryId: string;
|
|
133
|
+
} & {
|
|
134
|
+
message?: string;
|
|
135
|
+
cause?: unknown;
|
|
136
|
+
}) | undefined): import("@agentuity/core").RichError & {
|
|
137
|
+
readonly _tag: "WebhookDeliveryNotFoundError";
|
|
138
|
+
} & Readonly<{
|
|
139
|
+
webhookId: string;
|
|
140
|
+
deliveryId: string;
|
|
141
|
+
}>;
|
|
142
|
+
readonly defaultMessage?: string;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Constructs a full API path for webhook operations.
|
|
146
|
+
*
|
|
147
|
+
* Pattern: `/webhook/${VERSION}/${verb}/${segments.join('/')}`
|
|
148
|
+
* Each verb is unique to avoid route conflicts with the Go mux.
|
|
149
|
+
*
|
|
150
|
+
* @param verb - The action verb (e.g., 'create', 'list', 'get', 'destination-list')
|
|
151
|
+
* @param segments - Additional path segments (e.g., webhook ID, sub-resource ID)
|
|
152
|
+
* @returns The full API path with version and verb prefix
|
|
153
|
+
*
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
export declare function webhookApiPath(verb: string, ...segments: string[]): string;
|
|
157
|
+
/**
|
|
158
|
+
* Constructs a full API path for webhook operations with query string.
|
|
159
|
+
*
|
|
160
|
+
* @param verb - The action verb
|
|
161
|
+
* @param queryString - Query string to append (without leading ?)
|
|
162
|
+
* @param segments - Additional path segments
|
|
163
|
+
* @returns The full API path with version, verb, and query string
|
|
164
|
+
*
|
|
165
|
+
* @internal
|
|
166
|
+
*/
|
|
167
|
+
export declare function webhookApiPathWithQuery(verb: string, queryString: string | undefined, ...segments: string[]): string;
|
|
168
|
+
/**
|
|
169
|
+
* Constructs the public ingest URL for a webhook.
|
|
170
|
+
*
|
|
171
|
+
* Pattern: `/webhook/{orgId}-{webhookId}` (non-versioned, public)
|
|
172
|
+
*
|
|
173
|
+
* @param orgId - The organization ID
|
|
174
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
175
|
+
* @returns The public ingest URL
|
|
176
|
+
*
|
|
177
|
+
* @internal
|
|
178
|
+
*/
|
|
179
|
+
export declare function webhookIngestPath(orgId: string, webhookId: string): string;
|
|
180
|
+
/**
|
|
181
|
+
* Builds headers for webhook API requests.
|
|
182
|
+
*
|
|
183
|
+
* @param orgId - Optional organization ID for CLI authentication
|
|
184
|
+
* @returns Headers object to pass to API client
|
|
185
|
+
*
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
export declare function buildWebhookHeaders(orgId?: string): Record<string, string> | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Wraps an API call and translates APIError with HTTP status codes to domain-specific webhook errors.
|
|
191
|
+
*
|
|
192
|
+
* - 404 → WebhookNotFoundError / WebhookDestinationNotFoundError / WebhookReceiptNotFoundError / WebhookDeliveryNotFoundError
|
|
193
|
+
*
|
|
194
|
+
* @internal
|
|
195
|
+
*/
|
|
196
|
+
export declare function withWebhookErrorHandling<T>(apiCall: () => Promise<T>, context: {
|
|
197
|
+
webhookId?: string;
|
|
198
|
+
destinationId?: string;
|
|
199
|
+
receiptId?: string;
|
|
200
|
+
deliveryId?: string;
|
|
201
|
+
}): Promise<T>;
|
|
202
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/api/webhook/util.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,YAAY;;oBAAiD,MAAM;;;;;;;oBAAN,MAAM;;;CAAK,CAAC;AAEtF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB;;mBACrB,MAAM;;;;;;;mBAAN,MAAM;;;CACd,CAAC;AAEL;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,+BAA+B;;mBAChC,MAAM;uBACF,MAAM;;;;;;;mBADV,MAAM;uBACF,MAAM;;;CAClB,CAAC;AAEL;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,2BAA2B;;mBAC5B,MAAM;mBACN,MAAM;;;;;;;mBADN,MAAM;mBACN,MAAM;;;CACd,CAAC;AAEL;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,4BAA4B;;mBAC7B,MAAM;oBACL,MAAM;;;;;;;mBADP,MAAM;oBACL,MAAM;;;CACf,CAAC;AASL;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAM1E;AAED;;;;;;;;;GASG;AACH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