@agentpress/sdk 0.2.78 → 0.2.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,335 +1,357 @@
1
- // src/errors.ts
1
+ import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
2
+ //#region src/errors.ts
3
+ /**
4
+ * Base error class for all SDK errors. Catch this to handle any error
5
+ * thrown by the AgentPress SDK regardless of specific type.
6
+ */
2
7
  var AgentPressError = class extends Error {
3
- constructor(message) {
4
- super(message);
5
- this.name = "AgentPressError";
6
- Object.setPrototypeOf(this, new.target.prototype);
7
- }
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = "AgentPressError";
11
+ Object.setPrototypeOf(this, new.target.prototype);
12
+ }
8
13
  };
14
+ /**
15
+ * Thrown at construction time when `AgentPressOptions` contains invalid values
16
+ * (e.g., non-positive timeout, malformed `webhookSecret`).
17
+ */
9
18
  var ConfigurationError = class extends AgentPressError {
10
- constructor(message) {
11
- super(message);
12
- this.name = "ConfigurationError";
13
- Object.setPrototypeOf(this, new.target.prototype);
14
- }
19
+ constructor(message) {
20
+ super(message);
21
+ this.name = "ConfigurationError";
22
+ Object.setPrototypeOf(this, new.target.prototype);
23
+ }
15
24
  };
25
+ /**
26
+ * Thrown when the API returns a non-2xx HTTP response.
27
+ *
28
+ * Properties:
29
+ * - `statusCode` - HTTP status code (e.g., 401, 404, 500)
30
+ * - `responseBody` - Raw response body text for debugging
31
+ * - `url` - The full request URL that failed
32
+ */
16
33
  var HttpError = class extends AgentPressError {
17
- statusCode;
18
- responseBody;
19
- url;
20
- constructor(statusCode, responseBody, url) {
21
- super(`HTTP ${statusCode} from ${url}`);
22
- this.name = "HttpError";
23
- this.statusCode = statusCode;
24
- this.responseBody = responseBody;
25
- this.url = url;
26
- Object.setPrototypeOf(this, new.target.prototype);
27
- }
34
+ statusCode;
35
+ responseBody;
36
+ url;
37
+ constructor(statusCode, responseBody, url) {
38
+ super(`HTTP ${statusCode} from ${url}`);
39
+ this.name = "HttpError";
40
+ this.statusCode = statusCode;
41
+ this.responseBody = responseBody;
42
+ this.url = url;
43
+ Object.setPrototypeOf(this, new.target.prototype);
44
+ }
28
45
  };
46
+ /** Thrown when a request exceeds the configured `timeout` (default 30s). */
29
47
  var TimeoutError = class extends AgentPressError {
30
- constructor(url, timeout) {
31
- super(`Request to ${url} timed out after ${timeout}ms`);
32
- this.name = "TimeoutError";
33
- Object.setPrototypeOf(this, new.target.prototype);
34
- }
48
+ constructor(url, timeout) {
49
+ super(`Request to ${url} timed out after ${timeout}ms`);
50
+ this.name = "TimeoutError";
51
+ Object.setPrototypeOf(this, new.target.prototype);
52
+ }
35
53
  };
54
+ /** Thrown by {@link WebhooksClient.verifyOrThrow} when an inbound webhook signature is invalid or expired. */
36
55
  var WebhookSignatureError = class extends AgentPressError {
37
- constructor(message) {
38
- super(message);
39
- this.name = "WebhookSignatureError";
40
- Object.setPrototypeOf(this, new.target.prototype);
41
- }
56
+ constructor(message) {
57
+ super(message);
58
+ this.name = "WebhookSignatureError";
59
+ Object.setPrototypeOf(this, new.target.prototype);
60
+ }
42
61
  };
43
-
44
- // src/utils.ts
45
- import { randomUUID } from "crypto";
62
+ //#endregion
63
+ //#region src/utils.ts
46
64
  function randomMessageId() {
47
- return `msg_${randomUUID()}`;
65
+ return `msg_${randomUUID()}`;
48
66
  }
49
-
50
- // src/webhooks/signing.ts
51
- import { createHmac, timingSafeEqual } from "crypto";
52
- var SIGNATURE_PREFIX = "v1,";
53
- var DEFAULT_TOLERANCE_SECONDS = 5 * 60;
67
+ //#endregion
68
+ //#region src/webhooks/signing.ts
69
+ const SIGNATURE_PREFIX = "v1,";
70
+ const DEFAULT_TOLERANCE_SECONDS = 300;
71
+ /**
72
+ * Sign a webhook payload using Svix-compatible HMAC-SHA256.
73
+ *
74
+ * @param secret - The webhook secret (with "whsec_" prefix)
75
+ * @param msgId - Unique message ID (e.g., "msg_<uuid>")
76
+ * @param timestamp - Unix timestamp in seconds
77
+ * @param body - JSON stringified payload
78
+ * @returns Signature string in format "v1,<base64>"
79
+ */
54
80
  function sign(secret, msgId, timestamp, body) {
55
- const secretBytes = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
56
- const message = `${msgId}.${timestamp}.${body}`;
57
- const signature = createHmac("sha256", secretBytes).update(message).digest("base64");
58
- return `${SIGNATURE_PREFIX}${signature}`;
81
+ const secretBytes = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
82
+ const message = `${msgId}.${timestamp}.${body}`;
83
+ return `${SIGNATURE_PREFIX}${createHmac("sha256", secretBytes).update(message).digest("base64")}`;
59
84
  }
85
+ /**
86
+ * Verify a Svix webhook signature.
87
+ *
88
+ * @param secret - The webhook secret (with "whsec_" prefix)
89
+ * @param payload - Raw request body (string or Buffer)
90
+ * @param headers - Svix headers object
91
+ * @param toleranceSeconds - Max age of signature in seconds (default: 5 min)
92
+ * @returns true if valid, false if invalid or expired
93
+ */
60
94
  function verify(secret, payload, headers, toleranceSeconds = DEFAULT_TOLERANCE_SECONDS) {
61
- const msgId = headers["svix-id"];
62
- const timestampStr = headers["svix-timestamp"];
63
- const signatureHeader = headers["svix-signature"];
64
- const timestamp = parseInt(timestampStr, 10);
65
- if (Number.isNaN(timestamp)) return false;
66
- const now = Math.floor(Date.now() / 1e3);
67
- if (Math.abs(now - timestamp) > toleranceSeconds) return false;
68
- const body = typeof payload === "string" ? payload : payload.toString("utf-8");
69
- const expected = sign(secret, msgId, timestamp, body);
70
- const signatures = signatureHeader.split(" ");
71
- const expectedBuf = Buffer.from(expected);
72
- for (const sig of signatures) {
73
- const sigBuf = Buffer.from(sig);
74
- if (sigBuf.length === expectedBuf.length && timingSafeEqual(sigBuf, expectedBuf)) {
75
- return true;
76
- }
77
- }
78
- return false;
95
+ const msgId = headers["svix-id"];
96
+ const timestampStr = headers["svix-timestamp"];
97
+ const signatureHeader = headers["svix-signature"];
98
+ const timestamp = parseInt(timestampStr, 10);
99
+ if (Number.isNaN(timestamp)) return false;
100
+ const now = Math.floor(Date.now() / 1e3);
101
+ if (Math.abs(now - timestamp) > toleranceSeconds) return false;
102
+ const expected = sign(secret, msgId, timestamp, typeof payload === "string" ? payload : payload.toString("utf-8"));
103
+ const signatures = signatureHeader.split(" ");
104
+ const expectedBuf = Buffer.from(expected);
105
+ for (const sig of signatures) {
106
+ const sigBuf = Buffer.from(sig);
107
+ if (sigBuf.length === expectedBuf.length && timingSafeEqual(sigBuf, expectedBuf)) return true;
108
+ }
109
+ return false;
79
110
  }
80
-
81
- // src/actions/client.ts
111
+ //#endregion
112
+ //#region src/actions/client.ts
113
+ /**
114
+ * Client for programmatically approving or rejecting staged actions.
115
+ * Uses HMAC-SHA256 signing (Svix-compatible), identical to {@link WebhooksClient}.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * const client = new AgentPress({ webhookSecret: "whsec_...", org: "my-org" });
120
+ *
121
+ * // Approve a staged action
122
+ * await client.actions.approve("act_123", {
123
+ * action: "my_webhook_action",
124
+ * });
125
+ *
126
+ * // Reject with a reason
127
+ * await client.actions.reject("act_456", {
128
+ * action: "my_webhook_action",
129
+ * reason: "Insufficient data",
130
+ * });
131
+ * ```
132
+ */
82
133
  var ActionsClient = class {
83
- options;
84
- http;
85
- constructor(options, http) {
86
- this.options = options;
87
- this.http = http;
88
- }
89
- /**
90
- * Approve a staged action, optionally modifying the tool call.
91
- *
92
- * @throws ConfigurationError if webhookSecret is not configured
93
- * @throws HttpError on non-2xx response
94
- * @throws TimeoutError if request exceeds timeout
95
- */
96
- async approve(actionId, params) {
97
- return this.manage(actionId, params.action, "approve", {
98
- editedToolCall: params.editedToolCall
99
- });
100
- }
101
- /**
102
- * Reject a staged action.
103
- *
104
- * @throws ConfigurationError if webhookSecret is not configured
105
- * @throws HttpError on non-2xx response
106
- * @throws TimeoutError if request exceeds timeout
107
- */
108
- async reject(actionId, params) {
109
- return this.manage(actionId, params.action, "reject", {
110
- reason: params.reason
111
- });
112
- }
113
- async manage(actionId, webhookAction, operation, body) {
114
- if (!this.options.webhookSecret) {
115
- throw new ConfigurationError(
116
- "webhookSecret is required for action management operations"
117
- );
118
- }
119
- const path = `/webhooks/actions/${this.options.org}/${webhookAction}/manage/${actionId}/${operation}`;
120
- const bodyStr = JSON.stringify(body);
121
- const msgId = randomMessageId();
122
- const timestamp = Math.floor(Date.now() / 1e3);
123
- const signature = sign(
124
- this.options.webhookSecret,
125
- msgId,
126
- timestamp,
127
- bodyStr
128
- );
129
- return this.http.request(path, {
130
- method: "POST",
131
- body: bodyStr,
132
- headers: {
133
- "svix-id": msgId,
134
- "svix-timestamp": String(timestamp),
135
- "svix-signature": signature
136
- }
137
- });
138
- }
134
+ options;
135
+ http;
136
+ constructor(options, http) {
137
+ this.options = options;
138
+ this.http = http;
139
+ }
140
+ /**
141
+ * Approve a staged action, optionally modifying the tool call.
142
+ *
143
+ * @throws ConfigurationError if webhookSecret is not configured
144
+ * @throws HttpError on non-2xx response
145
+ * @throws TimeoutError if request exceeds timeout
146
+ */
147
+ async approve(actionId, params) {
148
+ return this.manage(actionId, params.action, "approve", { editedToolCall: params.editedToolCall });
149
+ }
150
+ /**
151
+ * Reject a staged action.
152
+ *
153
+ * @throws ConfigurationError if webhookSecret is not configured
154
+ * @throws HttpError on non-2xx response
155
+ * @throws TimeoutError if request exceeds timeout
156
+ */
157
+ async reject(actionId, params) {
158
+ return this.manage(actionId, params.action, "reject", { reason: params.reason });
159
+ }
160
+ async manage(actionId, webhookAction, operation, body) {
161
+ if (!this.options.webhookSecret) throw new ConfigurationError("webhookSecret is required for action management operations");
162
+ const path = `/webhooks/actions/${this.options.org}/${webhookAction}/manage/${actionId}/${operation}`;
163
+ const bodyStr = JSON.stringify(body);
164
+ const msgId = randomMessageId();
165
+ const timestamp = Math.floor(Date.now() / 1e3);
166
+ const signature = sign(this.options.webhookSecret, msgId, timestamp, bodyStr);
167
+ return this.http.request(path, {
168
+ method: "POST",
169
+ body: bodyStr,
170
+ headers: {
171
+ "svix-id": msgId,
172
+ "svix-timestamp": String(timestamp),
173
+ "svix-signature": signature
174
+ }
175
+ });
176
+ }
139
177
  };
140
-
141
- // src/http.ts
178
+ //#endregion
179
+ //#region src/http.ts
180
+ /**
181
+ * Internal shared HTTP client. Not part of the public API -- used by
182
+ * namespace clients (e.g., `WebhooksClient`) to make authenticated requests.
183
+ * @internal
184
+ */
142
185
  var HttpClient = class {
143
- baseUrl;
144
- timeout;
145
- onRequest;
146
- onResponse;
147
- constructor(options) {
148
- this.baseUrl = options.baseUrl;
149
- this.timeout = options.timeout;
150
- this.onRequest = options.onRequest;
151
- this.onResponse = options.onResponse;
152
- }
153
- /**
154
- * Send an HTTP request to the API. Constructs the full URL from `baseUrl` + `path`,
155
- * applies the configured timeout via `AbortSignal`, fires `onRequest`/`onResponse`
156
- * hooks, and parses the JSON response.
157
- *
158
- * @throws {TimeoutError} If the request exceeds the configured timeout.
159
- * @throws {HttpError} If the API returns a non-2xx status code.
160
- * @throws {AgentPressError} On network failures or non-JSON responses.
161
- */
162
- async request(path, init) {
163
- const url = `${this.baseUrl}${path}`;
164
- const headers = new Headers(init.headers);
165
- if (!headers.has("Content-Type")) {
166
- headers.set("Content-Type", "application/json");
167
- }
168
- const requestInit = {
169
- ...init,
170
- headers,
171
- signal: AbortSignal.timeout(this.timeout)
172
- };
173
- this.onRequest?.(url, requestInit);
174
- let response;
175
- try {
176
- response = await fetch(url, requestInit);
177
- } catch (error) {
178
- if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError")) {
179
- throw new TimeoutError(url, this.timeout);
180
- }
181
- const message = error instanceof Error ? error.message : "Unknown fetch error";
182
- throw new AgentPressError(`Request to ${url} failed: ${message}`);
183
- }
184
- this.onResponse?.(url, response.clone());
185
- const text = await response.text();
186
- if (!response.ok) {
187
- throw new HttpError(response.status, text, url);
188
- }
189
- try {
190
- return JSON.parse(text);
191
- } catch {
192
- throw new AgentPressError(
193
- `Expected JSON response from ${url} but received: ${text.slice(0, 200)}`
194
- );
195
- }
196
- }
186
+ baseUrl;
187
+ timeout;
188
+ onRequest;
189
+ onResponse;
190
+ constructor(options) {
191
+ this.baseUrl = options.baseUrl;
192
+ this.timeout = options.timeout;
193
+ this.onRequest = options.onRequest;
194
+ this.onResponse = options.onResponse;
195
+ }
196
+ /**
197
+ * Send an HTTP request to the API. Constructs the full URL from `baseUrl` + `path`,
198
+ * applies the configured timeout via `AbortSignal`, fires `onRequest`/`onResponse`
199
+ * hooks, and parses the JSON response.
200
+ *
201
+ * @throws {TimeoutError} If the request exceeds the configured timeout.
202
+ * @throws {HttpError} If the API returns a non-2xx status code.
203
+ * @throws {AgentPressError} On network failures or non-JSON responses.
204
+ */
205
+ async request(path, init) {
206
+ const url = `${this.baseUrl}${path}`;
207
+ const headers = new Headers(init.headers);
208
+ if (!headers.has("Content-Type")) headers.set("Content-Type", "application/json");
209
+ const requestInit = {
210
+ ...init,
211
+ headers,
212
+ signal: AbortSignal.timeout(this.timeout)
213
+ };
214
+ this.onRequest?.(url, requestInit);
215
+ let response;
216
+ try {
217
+ response = await fetch(url, requestInit);
218
+ } catch (error) {
219
+ if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError")) throw new TimeoutError(url, this.timeout);
220
+ throw new AgentPressError(`Request to ${url} failed: ${error instanceof Error ? error.message : "Unknown fetch error"}`);
221
+ }
222
+ this.onResponse?.(url, response.clone());
223
+ const text = await response.text();
224
+ if (!response.ok) throw new HttpError(response.status, text, url);
225
+ try {
226
+ return JSON.parse(text);
227
+ } catch {
228
+ throw new AgentPressError(`Expected JSON response from ${url} but received: ${text.slice(0, 200)}`);
229
+ }
230
+ }
197
231
  };
198
-
199
- // src/webhooks/client.ts
232
+ //#endregion
233
+ //#region src/webhooks/client.ts
200
234
  var WebhooksClient = class {
201
- options;
202
- http;
203
- constructor(options, http) {
204
- this.options = options;
205
- this.http = http;
206
- }
207
- /**
208
- * Send an arbitrary webhook payload to AgentPress.
209
- * Signs the payload with HMAC-SHA256 (Svix-compatible).
210
- *
211
- * @throws ConfigurationError if webhookSecret is not configured
212
- * @throws HttpError on non-2xx response
213
- * @throws TimeoutError if request exceeds timeout
214
- */
215
- async send(params) {
216
- if (!this.options.webhookSecret) {
217
- throw new ConfigurationError(
218
- "webhookSecret is required for webhook operations"
219
- );
220
- }
221
- const path = `/webhooks/actions/${this.options.org}/${params.action}`;
222
- const body = JSON.stringify(params.payload);
223
- const msgId = randomMessageId();
224
- const timestamp = Math.floor(Date.now() / 1e3);
225
- const signature = sign(this.options.webhookSecret, msgId, timestamp, body);
226
- return this.http.request(path, {
227
- method: "POST",
228
- body,
229
- headers: {
230
- "svix-id": msgId,
231
- "svix-timestamp": String(timestamp),
232
- "svix-signature": signature
233
- }
234
- });
235
- }
236
- /**
237
- * Verify an inbound Svix webhook signature.
238
- *
239
- * @returns true if valid, false if invalid or expired
240
- * @throws ConfigurationError if webhookSecret is not configured
241
- */
242
- verify(params) {
243
- if (!this.options.webhookSecret) {
244
- throw new ConfigurationError(
245
- "webhookSecret is required for webhook verification"
246
- );
247
- }
248
- return verify(
249
- this.options.webhookSecret,
250
- params.payload,
251
- params.headers
252
- );
253
- }
254
- /**
255
- * Verify an inbound Svix webhook signature, throwing on failure.
256
- * Useful for middleware patterns where invalid signatures should halt processing.
257
- *
258
- * @throws WebhookSignatureError if signature is invalid or expired
259
- * @throws ConfigurationError if webhookSecret is not configured
260
- */
261
- verifyOrThrow(params) {
262
- if (!this.verify(params)) {
263
- throw new WebhookSignatureError("Invalid webhook signature");
264
- }
265
- }
266
- /**
267
- * Verify and parse an inbound webhook from AgentPress.
268
- * Combines signature verification with JSON parsing and type casting.
269
- * This is the recommended way to handle incoming webhooks.
270
- *
271
- * @throws WebhookSignatureError if signature is invalid or expired
272
- * @throws ConfigurationError if webhookSecret is not configured
273
- * @throws AgentPressError if payload is not valid JSON
274
- */
275
- constructEvent(params) {
276
- this.verifyOrThrow(params);
277
- const body = typeof params.payload === "string" ? params.payload : params.payload.toString("utf-8");
278
- try {
279
- return JSON.parse(body);
280
- } catch {
281
- throw new AgentPressError("Webhook payload is not valid JSON");
282
- }
283
- }
235
+ options;
236
+ http;
237
+ constructor(options, http) {
238
+ this.options = options;
239
+ this.http = http;
240
+ }
241
+ /**
242
+ * Send an arbitrary webhook payload to AgentPress.
243
+ * Signs the payload with HMAC-SHA256 (Svix-compatible).
244
+ *
245
+ * @throws ConfigurationError if webhookSecret is not configured
246
+ * @throws HttpError on non-2xx response
247
+ * @throws TimeoutError if request exceeds timeout
248
+ */
249
+ async send(params) {
250
+ if (!this.options.webhookSecret) throw new ConfigurationError("webhookSecret is required for webhook operations");
251
+ const path = `/webhooks/actions/${this.options.org}/${params.action}`;
252
+ const body = JSON.stringify(params.payload);
253
+ const msgId = randomMessageId();
254
+ const timestamp = Math.floor(Date.now() / 1e3);
255
+ const signature = sign(this.options.webhookSecret, msgId, timestamp, body);
256
+ return this.http.request(path, {
257
+ method: "POST",
258
+ body,
259
+ headers: {
260
+ "svix-id": msgId,
261
+ "svix-timestamp": String(timestamp),
262
+ "svix-signature": signature
263
+ }
264
+ });
265
+ }
266
+ /**
267
+ * Verify an inbound Svix webhook signature.
268
+ *
269
+ * @returns true if valid, false if invalid or expired
270
+ * @throws ConfigurationError if webhookSecret is not configured
271
+ */
272
+ verify(params) {
273
+ if (!this.options.webhookSecret) throw new ConfigurationError("webhookSecret is required for webhook verification");
274
+ return verify(this.options.webhookSecret, params.payload, params.headers);
275
+ }
276
+ /**
277
+ * Verify an inbound Svix webhook signature, throwing on failure.
278
+ * Useful for middleware patterns where invalid signatures should halt processing.
279
+ *
280
+ * @throws WebhookSignatureError if signature is invalid or expired
281
+ * @throws ConfigurationError if webhookSecret is not configured
282
+ */
283
+ verifyOrThrow(params) {
284
+ if (!this.verify(params)) throw new WebhookSignatureError("Invalid webhook signature");
285
+ }
286
+ /**
287
+ * Verify and parse an inbound webhook from AgentPress.
288
+ * Combines signature verification with JSON parsing and type casting.
289
+ * This is the recommended way to handle incoming webhooks.
290
+ *
291
+ * @throws WebhookSignatureError if signature is invalid or expired
292
+ * @throws ConfigurationError if webhookSecret is not configured
293
+ * @throws AgentPressError if payload is not valid JSON
294
+ */
295
+ constructEvent(params) {
296
+ this.verifyOrThrow(params);
297
+ const body = typeof params.payload === "string" ? params.payload : params.payload.toString("utf-8");
298
+ try {
299
+ return JSON.parse(body);
300
+ } catch {
301
+ throw new AgentPressError("Webhook payload is not valid JSON");
302
+ }
303
+ }
284
304
  };
285
-
286
- // src/client.ts
305
+ //#endregion
306
+ //#region src/client.ts
307
+ /**
308
+ * Main entry point for the AgentPress SDK. Provides namespaced access to API
309
+ * resources (e.g., `client.webhooks.send()`, `client.actions.approve()`).
310
+ * Validates all configuration options at construction time, so invalid config fails fast.
311
+ *
312
+ * @example
313
+ * ```ts
314
+ * const client = new AgentPress({
315
+ * apiKey: "ak_...",
316
+ * webhookSecret: "whsec_...",
317
+ * });
318
+ * await client.webhooks.send({ action: "my_action", payload: { ... } });
319
+ * await client.actions.approve("act_123", { action: "my_action" });
320
+ * ```
321
+ */
287
322
  var AgentPress = class {
288
- /** Webhook operations: send outbound webhooks and verify inbound signatures. */
289
- webhooks;
290
- /** Action management: approve or reject staged actions. */
291
- actions;
292
- /**
293
- * @param options - SDK configuration. All fields are optional with sensible defaults.
294
- * @throws {ConfigurationError} If `timeout` is non-positive or `webhookSecret` has an invalid prefix.
295
- */
296
- constructor(options = {}) {
297
- const resolved = resolveOptions(options);
298
- const http = new HttpClient(resolved);
299
- this.webhooks = new WebhooksClient(resolved, http);
300
- this.actions = new ActionsClient(resolved, http);
301
- }
323
+ /** Webhook operations: send outbound webhooks and verify inbound signatures. */
324
+ webhooks;
325
+ /** Action management: approve or reject staged actions. */
326
+ actions;
327
+ /**
328
+ * @param options - SDK configuration. All fields are optional with sensible defaults.
329
+ * @throws {ConfigurationError} If `timeout` is non-positive or `webhookSecret` has an invalid prefix.
330
+ */
331
+ constructor(options = {}) {
332
+ const resolved = resolveOptions(options);
333
+ const http = new HttpClient(resolved);
334
+ this.webhooks = new WebhooksClient(resolved, http);
335
+ this.actions = new ActionsClient(resolved, http);
336
+ }
302
337
  };
303
338
  function resolveOptions(options) {
304
- const baseUrl = (options.baseUrl ?? "https://api.agent.press").replace(
305
- /\/+$/,
306
- ""
307
- );
308
- const timeout = options.timeout ?? 3e4;
309
- const org = options.org ?? "default-org";
310
- if (timeout <= 0 || !Number.isFinite(timeout)) {
311
- throw new ConfigurationError("timeout must be a positive number");
312
- }
313
- if (options.webhookSecret !== void 0 && !options.webhookSecret.startsWith("whsec_")) {
314
- throw new ConfigurationError('webhookSecret must start with "whsec_"');
315
- }
316
- return {
317
- baseUrl,
318
- timeout,
319
- org,
320
- webhookSecret: options.webhookSecret,
321
- apiKey: options.apiKey,
322
- onRequest: options.onRequest,
323
- onResponse: options.onResponse
324
- };
339
+ const baseUrl = (options.baseUrl ?? "https://api.agent.press").replace(/\/+$/, "");
340
+ const timeout = options.timeout ?? 3e4;
341
+ const org = options.org ?? "default-org";
342
+ if (timeout <= 0 || !Number.isFinite(timeout)) throw new ConfigurationError("timeout must be a positive number");
343
+ if (options.webhookSecret !== void 0 && !options.webhookSecret.startsWith("whsec_")) throw new ConfigurationError("webhookSecret must start with \"whsec_\"");
344
+ return {
345
+ baseUrl,
346
+ timeout,
347
+ org,
348
+ webhookSecret: options.webhookSecret,
349
+ apiKey: options.apiKey,
350
+ onRequest: options.onRequest,
351
+ onResponse: options.onResponse
352
+ };
325
353
  }
326
- export {
327
- ActionsClient,
328
- AgentPress,
329
- AgentPressError,
330
- ConfigurationError,
331
- HttpError,
332
- TimeoutError,
333
- WebhookSignatureError
334
- };
354
+ //#endregion
355
+ export { ActionsClient, AgentPress, AgentPressError, ConfigurationError, HttpError, TimeoutError, WebhookSignatureError };
356
+
335
357
  //# sourceMappingURL=index.mjs.map