@agentuity/server 1.0.21 → 1.0.23

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.
Files changed (62) hide show
  1. package/dist/api/index.d.ts +1 -0
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/api/index.js +1 -0
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/api/project/deploy.d.ts +8 -0
  6. package/dist/api/project/deploy.d.ts.map +1 -1
  7. package/dist/api/project/deploy.js +14 -13
  8. package/dist/api/project/deploy.js.map +1 -1
  9. package/dist/api/sandbox/execute.d.ts +2 -2
  10. package/dist/api/sandbox/execution.d.ts +4 -4
  11. package/dist/api/sandbox/snapshot-build.d.ts +2 -0
  12. package/dist/api/sandbox/snapshot-build.d.ts.map +1 -1
  13. package/dist/api/sandbox/snapshot-build.js +4 -0
  14. package/dist/api/sandbox/snapshot-build.js.map +1 -1
  15. package/dist/api/webhook/deliveries.d.ts +94 -0
  16. package/dist/api/webhook/deliveries.d.ts.map +1 -0
  17. package/dist/api/webhook/deliveries.js +79 -0
  18. package/dist/api/webhook/deliveries.js.map +1 -0
  19. package/dist/api/webhook/destinations.d.ts +136 -0
  20. package/dist/api/webhook/destinations.d.ts.map +1 -0
  21. package/dist/api/webhook/destinations.js +137 -0
  22. package/dist/api/webhook/destinations.js.map +1 -0
  23. package/dist/api/webhook/index.d.ts +41 -0
  24. package/dist/api/webhook/index.d.ts.map +1 -0
  25. package/dist/api/webhook/index.js +59 -0
  26. package/dist/api/webhook/index.js.map +1 -0
  27. package/dist/api/webhook/receipts.d.ts +77 -0
  28. package/dist/api/webhook/receipts.d.ts.map +1 -0
  29. package/dist/api/webhook/receipts.js +78 -0
  30. package/dist/api/webhook/receipts.js.map +1 -0
  31. package/dist/api/webhook/types.d.ts +249 -0
  32. package/dist/api/webhook/types.d.ts.map +1 -0
  33. package/dist/api/webhook/types.js +221 -0
  34. package/dist/api/webhook/types.js.map +1 -0
  35. package/dist/api/webhook/util.d.ts +202 -0
  36. package/dist/api/webhook/util.d.ts.map +1 -0
  37. package/dist/api/webhook/util.js +201 -0
  38. package/dist/api/webhook/util.js.map +1 -0
  39. package/dist/api/webhook/webhooks.d.ts +146 -0
  40. package/dist/api/webhook/webhooks.d.ts.map +1 -0
  41. package/dist/api/webhook/webhooks.js +165 -0
  42. package/dist/api/webhook/webhooks.js.map +1 -0
  43. package/dist/config.d.ts +1 -0
  44. package/dist/config.d.ts.map +1 -1
  45. package/dist/config.js +1 -0
  46. package/dist/config.js.map +1 -1
  47. package/dist/runtime-bootstrap.d.ts.map +1 -1
  48. package/dist/runtime-bootstrap.js +3 -0
  49. package/dist/runtime-bootstrap.js.map +1 -1
  50. package/package.json +4 -4
  51. package/src/api/index.ts +1 -0
  52. package/src/api/project/deploy.ts +16 -16
  53. package/src/api/sandbox/snapshot-build.ts +6 -0
  54. package/src/api/webhook/deliveries.ts +129 -0
  55. package/src/api/webhook/destinations.ts +224 -0
  56. package/src/api/webhook/index.ts +133 -0
  57. package/src/api/webhook/receipts.ts +124 -0
  58. package/src/api/webhook/types.ts +309 -0
  59. package/src/api/webhook/util.ts +237 -0
  60. package/src/api/webhook/webhooks.ts +260 -0
  61. package/src/config.ts +2 -0
  62. package/src/runtime-bootstrap.ts +3 -0
@@ -0,0 +1,260 @@
1
+ import { z } from 'zod';
2
+ import { type APIClient, APIResponseSchema, APIResponseSchemaNoData } from '../api.ts';
3
+ import {
4
+ type CreateWebhookRequest,
5
+ CreateWebhookRequestSchema,
6
+ type ListWebhooksRequest,
7
+ type UpdateWebhookRequest,
8
+ UpdateWebhookRequestSchema,
9
+ type Webhook,
10
+ type WebhookApiOptions,
11
+ WebhookSchema,
12
+ } from './types.ts';
13
+ import {
14
+ buildWebhookHeaders,
15
+ WebhookError,
16
+ webhookApiPath,
17
+ webhookApiPathWithQuery,
18
+ withWebhookErrorHandling,
19
+ } from './util.ts';
20
+
21
+ export const WebhookResponseSchema = APIResponseSchema(WebhookSchema);
22
+ export const WebhooksListResponseSchema = APIResponseSchema(z.array(WebhookSchema));
23
+ export const DeleteWebhookResponseSchema = APIResponseSchemaNoData();
24
+
25
+ /**
26
+ * Create a new webhook.
27
+ *
28
+ * Creates a webhook with the specified name and optional description.
29
+ *
30
+ * @param client - The API client instance
31
+ * @param params - Webhook creation parameters
32
+ * @param options - Optional API options (e.g., orgId)
33
+ * @returns The created webhook
34
+ * @throws {WebhookError} If the API request fails
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const webhook = await createWebhook(client, {
39
+ * name: 'github-events',
40
+ * description: 'Receives GitHub webhook events',
41
+ * });
42
+ * console.log(`Created webhook: ${webhook.id}`);
43
+ * ```
44
+ */
45
+ export async function createWebhook(
46
+ client: APIClient,
47
+ params: CreateWebhookRequest,
48
+ options?: WebhookApiOptions
49
+ ): Promise<Webhook> {
50
+ const url = webhookApiPath('create');
51
+ const resp = await withWebhookErrorHandling(
52
+ () =>
53
+ client.post(
54
+ url,
55
+ params,
56
+ WebhookResponseSchema,
57
+ CreateWebhookRequestSchema,
58
+ undefined,
59
+ buildWebhookHeaders(options?.orgId)
60
+ ),
61
+ {}
62
+ );
63
+
64
+ if (resp.success) {
65
+ return resp.data;
66
+ }
67
+
68
+ throw new WebhookError({
69
+ message: resp.message || 'Failed to create webhook',
70
+ });
71
+ }
72
+
73
+ /**
74
+ * Get a webhook by ID.
75
+ *
76
+ * Retrieves the webhook details.
77
+ *
78
+ * @param client - The API client instance
79
+ * @param webhookId - The webhook ID (prefixed with wh_)
80
+ * @param options - Optional API options (e.g., orgId)
81
+ * @returns The webhook details
82
+ * @throws {WebhookNotFoundError} If the webhook does not exist
83
+ * @throws {WebhookError} If the API request fails
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const webhook = await getWebhook(client, 'wh_abc123');
88
+ * console.log(`Webhook: ${webhook.name}`);
89
+ * ```
90
+ */
91
+ export async function getWebhook(
92
+ client: APIClient,
93
+ webhookId: string,
94
+ options?: WebhookApiOptions
95
+ ): Promise<Webhook> {
96
+ const url = webhookApiPath('get', webhookId);
97
+ const resp = await withWebhookErrorHandling(
98
+ () => client.get(url, WebhookResponseSchema, undefined, buildWebhookHeaders(options?.orgId)),
99
+ { webhookId }
100
+ );
101
+
102
+ if (resp.success) {
103
+ return resp.data;
104
+ }
105
+
106
+ throw new WebhookError({
107
+ webhookId,
108
+ message: resp.message || 'Failed to get webhook',
109
+ });
110
+ }
111
+
112
+ /**
113
+ * List all webhooks with optional pagination.
114
+ *
115
+ * @param client - The API client instance
116
+ * @param params - Optional pagination parameters
117
+ * @param options - Optional API options (e.g., orgId)
118
+ * @returns Object containing the list of webhooks
119
+ * @throws {WebhookError} If the API request fails
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * // List first 10 webhooks
124
+ * const { webhooks } = await listWebhooks(client, { limit: 10 });
125
+ * console.log(`Found ${webhooks.length} webhooks`);
126
+ *
127
+ * // Paginate through all webhooks
128
+ * const { webhooks: page2 } = await listWebhooks(client, { limit: 10, offset: 10 });
129
+ * ```
130
+ */
131
+ export async function listWebhooks(
132
+ client: APIClient,
133
+ params?: ListWebhooksRequest,
134
+ options?: WebhookApiOptions
135
+ ): Promise<{ webhooks: Webhook[] }> {
136
+ const searchParams = new URLSearchParams();
137
+ if (params?.limit !== undefined) {
138
+ searchParams.set('limit', String(params.limit));
139
+ }
140
+ if (params?.offset !== undefined) {
141
+ searchParams.set('offset', String(params.offset));
142
+ }
143
+
144
+ const queryString = searchParams.toString();
145
+ const url = webhookApiPathWithQuery('list', queryString || undefined);
146
+ const resp = await withWebhookErrorHandling(
147
+ () =>
148
+ client.get(
149
+ url,
150
+ WebhooksListResponseSchema,
151
+ undefined,
152
+ buildWebhookHeaders(options?.orgId)
153
+ ),
154
+ {}
155
+ );
156
+
157
+ if (resp.success) {
158
+ return { webhooks: resp.data };
159
+ }
160
+
161
+ throw new WebhookError({
162
+ message: resp.message || 'Failed to list webhooks',
163
+ });
164
+ }
165
+
166
+ /**
167
+ * Update an existing webhook.
168
+ *
169
+ * Updates the webhook name and/or description.
170
+ *
171
+ * @param client - The API client instance
172
+ * @param webhookId - The webhook ID (prefixed with wh_)
173
+ * @param params - Update parameters
174
+ * @param options - Optional API options (e.g., orgId)
175
+ * @returns The updated webhook
176
+ * @throws {WebhookNotFoundError} If the webhook does not exist
177
+ * @throws {WebhookError} If the API request fails
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * const webhook = await updateWebhook(client, 'wh_abc123', {
182
+ * name: 'github-events-v2',
183
+ * description: 'Updated description',
184
+ * });
185
+ * ```
186
+ */
187
+ export async function updateWebhook(
188
+ client: APIClient,
189
+ webhookId: string,
190
+ params: UpdateWebhookRequest,
191
+ options?: WebhookApiOptions
192
+ ): Promise<Webhook> {
193
+ const url = webhookApiPath('update', webhookId);
194
+ const resp = await withWebhookErrorHandling(
195
+ () =>
196
+ client.put(
197
+ url,
198
+ params,
199
+ WebhookResponseSchema,
200
+ UpdateWebhookRequestSchema,
201
+ undefined,
202
+ buildWebhookHeaders(options?.orgId)
203
+ ),
204
+ { webhookId }
205
+ );
206
+
207
+ if (resp.success) {
208
+ return resp.data;
209
+ }
210
+
211
+ throw new WebhookError({
212
+ webhookId,
213
+ message: resp.message || 'Failed to update webhook',
214
+ });
215
+ }
216
+
217
+ /**
218
+ * Delete a webhook.
219
+ *
220
+ * Permanently deletes a webhook and all its destinations, receipts, and deliveries.
221
+ * This action cannot be undone.
222
+ *
223
+ * @param client - The API client instance
224
+ * @param webhookId - The webhook ID (prefixed with wh_)
225
+ * @param options - Optional API options (e.g., orgId)
226
+ * @throws {WebhookNotFoundError} If the webhook does not exist
227
+ * @throws {WebhookError} If the API request fails
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * await deleteWebhook(client, 'wh_abc123');
232
+ * console.log('Webhook deleted');
233
+ * ```
234
+ */
235
+ export async function deleteWebhook(
236
+ client: APIClient,
237
+ webhookId: string,
238
+ options?: WebhookApiOptions
239
+ ): Promise<void> {
240
+ const url = webhookApiPath('delete', webhookId);
241
+ const resp = await withWebhookErrorHandling(
242
+ () =>
243
+ client.delete(
244
+ url,
245
+ DeleteWebhookResponseSchema,
246
+ undefined,
247
+ buildWebhookHeaders(options?.orgId)
248
+ ),
249
+ { webhookId }
250
+ );
251
+
252
+ if (resp.success) {
253
+ return;
254
+ }
255
+
256
+ throw new WebhookError({
257
+ webhookId,
258
+ message: resp.message || 'Failed to delete webhook',
259
+ });
260
+ }
package/src/config.ts CHANGED
@@ -5,6 +5,7 @@ export interface ServiceUrls {
5
5
  catalyst: string;
6
6
  otel: string;
7
7
  sandbox: string;
8
+ email: string;
8
9
  }
9
10
 
10
11
  /**
@@ -37,6 +38,7 @@ export function getServiceUrls(region?: string): ServiceUrls {
37
38
  catalyst: process.env.AGENTUITY_CATALYST_URL || transportUrl,
38
39
  otel: process.env.AGENTUITY_OTLP_URL || buildRegionalURL(resolvedRegion, 'otel'),
39
40
  sandbox: process.env.AGENTUITY_SANDBOX_URL || transportUrl,
41
+ email: process.env.AGENTUITY_EMAIL_URL || transportUrl,
40
42
  };
41
43
  }
42
44
 
@@ -87,4 +87,7 @@ export function bootstrapRuntimeEnv(options: RuntimeBootstrapOptions = {}): void
87
87
  if (!process.env.AGENTUITY_OTLP_URL) {
88
88
  process.env.AGENTUITY_OTLP_URL = serviceUrls.otel;
89
89
  }
90
+ if (!process.env.AGENTUITY_EMAIL_URL) {
91
+ process.env.AGENTUITY_EMAIL_URL = serviceUrls.email;
92
+ }
90
93
  }