@agentuity/queue 3.0.12 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -16
- package/dist/index.js.map +1 -1
- package/dist/service.d.ts +335 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +501 -0
- package/dist/service.js.map +1 -0
- package/package.json +4 -3
- package/src/index.ts +21 -39
- package/src/service.ts +675 -0
package/dist/service.js
ADDED
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module queue
|
|
3
|
+
*
|
|
4
|
+
* Queue service for publishing messages to Agentuity queues.
|
|
5
|
+
*
|
|
6
|
+
* Used internally by `@agentuity/queue`'s `QueueClient`. App code should
|
|
7
|
+
* use `QueueClient` directly rather than reaching for these primitives.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { QueueClient } from '@agentuity/queue';
|
|
12
|
+
*
|
|
13
|
+
* const queue = new QueueClient();
|
|
14
|
+
* const result = await queue.publish('order-queue', {
|
|
15
|
+
* orderId: 123,
|
|
16
|
+
* action: 'process',
|
|
17
|
+
* });
|
|
18
|
+
* console.log(`Published message ${result.id}`);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { buildUrl, toPayload, toServiceException } from '@agentuity/adapter';
|
|
22
|
+
import { StructuredError } from '@agentuity/adapter';
|
|
23
|
+
import { z } from 'zod';
|
|
24
|
+
/**
|
|
25
|
+
* Parameters for publishing a message to a queue.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const params: QueuePublishParams = {
|
|
30
|
+
* metadata: { priority: 'high' },
|
|
31
|
+
* partitionKey: 'customer-123',
|
|
32
|
+
* idempotencyKey: 'order-456-v1',
|
|
33
|
+
* ttl: 3600, // 1 hour
|
|
34
|
+
* };
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const QueuePublishParamsSchema = z.object({
|
|
38
|
+
/**
|
|
39
|
+
* Optional metadata to attach to the message.
|
|
40
|
+
* Can contain any JSON-serializable data for message routing or filtering.
|
|
41
|
+
*/
|
|
42
|
+
metadata: z
|
|
43
|
+
.record(z.string(), z.unknown())
|
|
44
|
+
.optional()
|
|
45
|
+
.describe('Optional metadata to attach to the message.'),
|
|
46
|
+
/**
|
|
47
|
+
* Optional partition key for message ordering.
|
|
48
|
+
* Messages with the same partition key are guaranteed to be processed in order.
|
|
49
|
+
*/
|
|
50
|
+
partitionKey: z.string().optional().describe('Optional partition key for message ordering.'),
|
|
51
|
+
/**
|
|
52
|
+
* Optional idempotency key for deduplication.
|
|
53
|
+
* If a message with the same key was recently published, it will be deduplicated.
|
|
54
|
+
*/
|
|
55
|
+
idempotencyKey: z.string().optional().describe('Optional idempotency key for deduplication.'),
|
|
56
|
+
/**
|
|
57
|
+
* Optional time-to-live in seconds.
|
|
58
|
+
* Messages will expire and be removed after this duration.
|
|
59
|
+
*/
|
|
60
|
+
ttl: z.number().optional().describe('Optional time-to-live in seconds.'),
|
|
61
|
+
/**
|
|
62
|
+
* Optional project ID for cross-project publishing.
|
|
63
|
+
* If not specified, uses the current project context.
|
|
64
|
+
*/
|
|
65
|
+
projectId: z.string().optional().describe('Optional project ID for cross-project publishing.'),
|
|
66
|
+
/**
|
|
67
|
+
* Optional agent ID for attribution.
|
|
68
|
+
* If not specified, uses the current agent context.
|
|
69
|
+
*/
|
|
70
|
+
agentId: z.string().optional().describe('Optional agent ID for attribution.'),
|
|
71
|
+
/**
|
|
72
|
+
* Whether to publish synchronously.
|
|
73
|
+
* When true, the API waits for the message to be fully persisted before returning.
|
|
74
|
+
* When false (default), the API returns immediately with a pending message.
|
|
75
|
+
*/
|
|
76
|
+
sync: z.boolean().optional().describe('Whether to publish synchronously.'),
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* Result of publishing a message to a queue.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const result = await queue.publish('my-queue', payload);
|
|
84
|
+
* console.log(`Message ${result.id} published at offset ${result.offset}`);
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export const QueuePublishResultSchema = z.object({
|
|
88
|
+
/**
|
|
89
|
+
* The unique message ID (prefixed with msg_).
|
|
90
|
+
* Use this ID to track, acknowledge, or delete the message.
|
|
91
|
+
*/
|
|
92
|
+
id: z.string().describe('The unique message ID (prefixed with msg_).'),
|
|
93
|
+
/**
|
|
94
|
+
* The sequential offset of the message in the queue.
|
|
95
|
+
* Offsets are monotonically increasing and can be used for log-style consumption.
|
|
96
|
+
*/
|
|
97
|
+
offset: z.number().describe('The sequential offset of the message in the queue.'),
|
|
98
|
+
/**
|
|
99
|
+
* ISO 8601 timestamp when the message was published.
|
|
100
|
+
*/
|
|
101
|
+
publishedAt: z.string().describe('ISO 8601 timestamp when the message was published.'),
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* Parameters for creating a queue.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const result = await queue.createQueue('my-queue', {
|
|
109
|
+
* queueType: 'pubsub',
|
|
110
|
+
* settings: { defaultTtlSeconds: 86400 },
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export const QueueCreateParamsSchema = z.object({
|
|
115
|
+
/**
|
|
116
|
+
* Type of queue to create.
|
|
117
|
+
* - `worker`: Messages are consumed by exactly one consumer with acknowledgment.
|
|
118
|
+
* - `pubsub`: Messages are broadcast to all subscribers.
|
|
119
|
+
* @default 'worker'
|
|
120
|
+
*/
|
|
121
|
+
queueType: z.enum(['worker', 'pubsub']).optional().describe('Type of queue to create.'),
|
|
122
|
+
/**
|
|
123
|
+
* Optional description of the queue's purpose.
|
|
124
|
+
*/
|
|
125
|
+
description: z.string().optional().describe("Optional description of the queue's purpose."),
|
|
126
|
+
/**
|
|
127
|
+
* Optional settings to customize queue behavior.
|
|
128
|
+
* Only provided fields are applied; others use server defaults.
|
|
129
|
+
*/
|
|
130
|
+
settings: z
|
|
131
|
+
.object({
|
|
132
|
+
/** Default time-to-live for messages in seconds. Null means no expiration. */
|
|
133
|
+
defaultTtlSeconds: z
|
|
134
|
+
.number()
|
|
135
|
+
.nullable()
|
|
136
|
+
.optional()
|
|
137
|
+
.describe('Default time-to-live for messages in seconds. Null means no expiration.'),
|
|
138
|
+
/** Time in seconds a message is invisible after being received. */
|
|
139
|
+
defaultVisibilityTimeoutSeconds: z
|
|
140
|
+
.number()
|
|
141
|
+
.optional()
|
|
142
|
+
.describe('Time in seconds a message is invisible after being received.'),
|
|
143
|
+
/** Maximum number of delivery attempts before moving to DLQ. */
|
|
144
|
+
defaultMaxRetries: z
|
|
145
|
+
.number()
|
|
146
|
+
.optional()
|
|
147
|
+
.describe('Maximum number of delivery attempts before moving to DLQ.'),
|
|
148
|
+
/** Maximum number of messages a single client can process concurrently. */
|
|
149
|
+
maxInFlightPerClient: z
|
|
150
|
+
.number()
|
|
151
|
+
.optional()
|
|
152
|
+
.describe('Maximum number of messages a single client can process concurrently.'),
|
|
153
|
+
/** Retention period for acknowledged messages in seconds. */
|
|
154
|
+
retentionSeconds: z
|
|
155
|
+
.number()
|
|
156
|
+
.optional()
|
|
157
|
+
.describe('Retention period for acknowledged messages in seconds.'),
|
|
158
|
+
})
|
|
159
|
+
.optional()
|
|
160
|
+
.describe('Optional settings to customize queue behavior.'),
|
|
161
|
+
});
|
|
162
|
+
/**
|
|
163
|
+
* Result of creating a queue.
|
|
164
|
+
*/
|
|
165
|
+
export const QueueCreateResultSchema = z.object({
|
|
166
|
+
/** The queue name. */
|
|
167
|
+
name: z.string().describe('The queue name.'),
|
|
168
|
+
/** The queue type ('worker' or 'pubsub'). */
|
|
169
|
+
queueType: z.string().describe("The queue type ('worker' or 'pubsub')."),
|
|
170
|
+
});
|
|
171
|
+
// ============================================================================
|
|
172
|
+
// Errors
|
|
173
|
+
// ============================================================================
|
|
174
|
+
/**
|
|
175
|
+
* Error thrown when a publish operation fails.
|
|
176
|
+
*
|
|
177
|
+
* This is a general error for publish failures that aren't specifically
|
|
178
|
+
* validation or not-found errors.
|
|
179
|
+
*/
|
|
180
|
+
export const QueuePublishError = StructuredError('QueuePublishError');
|
|
181
|
+
/**
|
|
182
|
+
* Error thrown when a queue creation operation fails.
|
|
183
|
+
*
|
|
184
|
+
* This is a general error for create failures that aren't specifically
|
|
185
|
+
* validation, not-found, or conflict (409) errors.
|
|
186
|
+
*/
|
|
187
|
+
export const QueueCreateError = StructuredError('QueueCreateError');
|
|
188
|
+
/**
|
|
189
|
+
* Error thrown when a queue is not found.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* try {
|
|
194
|
+
* await queue.publish('non-existent', 'payload');
|
|
195
|
+
* } catch (error) {
|
|
196
|
+
* if (error instanceof QueueNotFoundError) {
|
|
197
|
+
* console.error('Queue does not exist');
|
|
198
|
+
* }
|
|
199
|
+
* }
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
export const QueueNotFoundError = StructuredError('QueueNotFoundError');
|
|
203
|
+
/**
|
|
204
|
+
* Error thrown when validation fails.
|
|
205
|
+
*
|
|
206
|
+
* Contains the field name and optionally the invalid value for debugging.
|
|
207
|
+
*/
|
|
208
|
+
export const QueueValidationError = StructuredError('QueueValidationError')();
|
|
209
|
+
// ============================================================================
|
|
210
|
+
// Internal Validation
|
|
211
|
+
// ============================================================================
|
|
212
|
+
const MAX_QUEUE_NAME_LENGTH = 256;
|
|
213
|
+
const MAX_PAYLOAD_SIZE = 1048576;
|
|
214
|
+
const MAX_PARTITION_KEY_LENGTH = 256;
|
|
215
|
+
const MAX_IDEMPOTENCY_KEY_LENGTH = 256;
|
|
216
|
+
const VALID_QUEUE_NAME_REGEX = /^[a-z_][a-z0-9_-]*$/;
|
|
217
|
+
/** @internal */
|
|
218
|
+
function validateQueueNameInternal(name) {
|
|
219
|
+
if (!name || name.length === 0) {
|
|
220
|
+
throw new QueueValidationError({
|
|
221
|
+
message: 'Queue name cannot be empty',
|
|
222
|
+
field: 'queueName',
|
|
223
|
+
value: name,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (name.length > MAX_QUEUE_NAME_LENGTH) {
|
|
227
|
+
throw new QueueValidationError({
|
|
228
|
+
message: `Queue name must not exceed ${MAX_QUEUE_NAME_LENGTH} characters`,
|
|
229
|
+
field: 'queueName',
|
|
230
|
+
value: name,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (!VALID_QUEUE_NAME_REGEX.test(name)) {
|
|
234
|
+
throw new QueueValidationError({
|
|
235
|
+
message: 'Queue name must start with a letter or underscore and contain only lowercase letters, digits, underscores, and hyphens',
|
|
236
|
+
field: 'queueName',
|
|
237
|
+
value: name,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/** @internal */
|
|
242
|
+
function validatePayloadInternal(payload) {
|
|
243
|
+
if (!payload || payload.length === 0) {
|
|
244
|
+
throw new QueueValidationError({
|
|
245
|
+
message: 'Payload cannot be empty',
|
|
246
|
+
field: 'payload',
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
if (payload.length > MAX_PAYLOAD_SIZE) {
|
|
250
|
+
throw new QueueValidationError({
|
|
251
|
+
message: `Payload size exceeds ${MAX_PAYLOAD_SIZE} byte limit (${payload.length} bytes)`,
|
|
252
|
+
field: 'payload',
|
|
253
|
+
value: payload.length,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Unwraps the standard API response envelope.
|
|
259
|
+
*
|
|
260
|
+
* The queue server returns responses wrapped in:
|
|
261
|
+
* { success: true, data: { [key]: { ...actual data... } } }
|
|
262
|
+
*
|
|
263
|
+
* Since `fromResponse()` parses the raw JSON body, `res.data` from the
|
|
264
|
+
* adapter is the full envelope. This helper extracts the nested data by key.
|
|
265
|
+
*
|
|
266
|
+
* Falls back to treating the input as already-unwrapped data (e.g., in tests
|
|
267
|
+
* using mock adapters that provide flat data directly).
|
|
268
|
+
*
|
|
269
|
+
* @internal
|
|
270
|
+
*/
|
|
271
|
+
function unwrapApiResponse(data, key) {
|
|
272
|
+
if (data !== null && typeof data === 'object') {
|
|
273
|
+
const body = data;
|
|
274
|
+
if (body.success === true && typeof body.data === 'object' && body.data !== null) {
|
|
275
|
+
const envelope = body.data;
|
|
276
|
+
if (key in envelope) {
|
|
277
|
+
return envelope[key];
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return data;
|
|
282
|
+
}
|
|
283
|
+
// ============================================================================
|
|
284
|
+
// QueueStorageService Implementation
|
|
285
|
+
// ============================================================================
|
|
286
|
+
/**
|
|
287
|
+
* HTTP-based implementation of the {@link QueueService} interface.
|
|
288
|
+
*
|
|
289
|
+
* This service communicates with the Agentuity Queue API to publish
|
|
290
|
+
* messages. App code should use `QueueClient` from `@agentuity/queue`
|
|
291
|
+
* rather than instantiating this class directly.
|
|
292
|
+
*/
|
|
293
|
+
export class QueueStorageService {
|
|
294
|
+
#adapter;
|
|
295
|
+
#baseUrl;
|
|
296
|
+
#knownQueues = new Set();
|
|
297
|
+
/**
|
|
298
|
+
* Creates a new QueueStorageService.
|
|
299
|
+
*
|
|
300
|
+
* @param baseUrl - The base URL of the Queue API
|
|
301
|
+
* @param adapter - The fetch adapter for making HTTP requests
|
|
302
|
+
*/
|
|
303
|
+
constructor(baseUrl, adapter) {
|
|
304
|
+
this.#adapter = adapter;
|
|
305
|
+
this.#baseUrl = baseUrl;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* @inheritdoc
|
|
309
|
+
*/
|
|
310
|
+
async publish(queueName, payload, params) {
|
|
311
|
+
// Validate inputs before sending to API
|
|
312
|
+
validateQueueNameInternal(queueName);
|
|
313
|
+
const [body] = await toPayload(payload);
|
|
314
|
+
const payloadStr = typeof payload === 'string' ? payload : body;
|
|
315
|
+
validatePayloadInternal(payloadStr);
|
|
316
|
+
// Validate optional params
|
|
317
|
+
if (params?.partitionKey && params.partitionKey.length > MAX_PARTITION_KEY_LENGTH) {
|
|
318
|
+
throw new QueueValidationError({
|
|
319
|
+
message: `Partition key must not exceed ${MAX_PARTITION_KEY_LENGTH} characters`,
|
|
320
|
+
field: 'partitionKey',
|
|
321
|
+
value: params.partitionKey.length,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
if (params?.idempotencyKey && params.idempotencyKey.length > MAX_IDEMPOTENCY_KEY_LENGTH) {
|
|
325
|
+
throw new QueueValidationError({
|
|
326
|
+
message: `Idempotency key must not exceed ${MAX_IDEMPOTENCY_KEY_LENGTH} characters`,
|
|
327
|
+
field: 'idempotencyKey',
|
|
328
|
+
value: params.idempotencyKey.length,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
if (params?.ttl !== undefined && params.ttl < 0) {
|
|
332
|
+
throw new QueueValidationError({
|
|
333
|
+
message: 'TTL cannot be negative',
|
|
334
|
+
field: 'ttl',
|
|
335
|
+
value: params.ttl,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
const basePath = `/queue/messages/publish/${encodeURIComponent(queueName)}`;
|
|
339
|
+
const url = buildUrl(this.#baseUrl, params?.sync ? `${basePath}?sync=true` : basePath);
|
|
340
|
+
const requestBody = {
|
|
341
|
+
payload: typeof payload === 'string' ? payload : body,
|
|
342
|
+
};
|
|
343
|
+
if (params?.metadata) {
|
|
344
|
+
requestBody.metadata = params.metadata;
|
|
345
|
+
}
|
|
346
|
+
if (params?.partitionKey) {
|
|
347
|
+
requestBody.partition_key = params.partitionKey;
|
|
348
|
+
}
|
|
349
|
+
if (params?.idempotencyKey) {
|
|
350
|
+
requestBody.idempotency_key = params.idempotencyKey;
|
|
351
|
+
}
|
|
352
|
+
if (params?.ttl !== undefined) {
|
|
353
|
+
requestBody.ttl_seconds = params.ttl;
|
|
354
|
+
}
|
|
355
|
+
if (params?.projectId) {
|
|
356
|
+
requestBody.project_id = params.projectId;
|
|
357
|
+
}
|
|
358
|
+
if (params?.agentId) {
|
|
359
|
+
requestBody.agent_id = params.agentId;
|
|
360
|
+
}
|
|
361
|
+
const signal = AbortSignal.timeout(30_000);
|
|
362
|
+
const res = await this.#adapter.invoke(url, {
|
|
363
|
+
method: 'POST',
|
|
364
|
+
signal,
|
|
365
|
+
body: JSON.stringify(requestBody),
|
|
366
|
+
contentType: 'application/json',
|
|
367
|
+
telemetry: {
|
|
368
|
+
name: 'agentuity.queue.publish',
|
|
369
|
+
attributes: {
|
|
370
|
+
queueName,
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
if (res.ok) {
|
|
375
|
+
const data = unwrapApiResponse(res.data, 'message');
|
|
376
|
+
const result = QueuePublishResultSchema.safeParse({
|
|
377
|
+
id: data.id,
|
|
378
|
+
offset: data.offset,
|
|
379
|
+
publishedAt: data.published_at,
|
|
380
|
+
});
|
|
381
|
+
if (result.success) {
|
|
382
|
+
return result.data;
|
|
383
|
+
}
|
|
384
|
+
throw new QueuePublishError({
|
|
385
|
+
message: `Queue publish returned an unexpected response format: ${result.error.message}`,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
if (res.response.status === 404) {
|
|
389
|
+
throw new QueueNotFoundError({
|
|
390
|
+
message: `Queue not found: ${queueName}`,
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
throw await toServiceException('POST', url, res.response);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* @inheritdoc
|
|
397
|
+
*/
|
|
398
|
+
async createQueue(queueName, params) {
|
|
399
|
+
validateQueueNameInternal(queueName);
|
|
400
|
+
if (this.#knownQueues.has(queueName)) {
|
|
401
|
+
return {
|
|
402
|
+
name: queueName,
|
|
403
|
+
queueType: params?.queueType ?? 'worker',
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
const url = buildUrl(this.#baseUrl, '/queue/create');
|
|
407
|
+
const requestBody = {
|
|
408
|
+
name: queueName,
|
|
409
|
+
queue_type: params?.queueType ?? 'worker',
|
|
410
|
+
};
|
|
411
|
+
if (params?.description !== undefined) {
|
|
412
|
+
requestBody.description = params.description;
|
|
413
|
+
}
|
|
414
|
+
if (params?.settings) {
|
|
415
|
+
const settings = {};
|
|
416
|
+
if (params.settings.defaultTtlSeconds !== undefined) {
|
|
417
|
+
settings.default_ttl_seconds = params.settings.defaultTtlSeconds;
|
|
418
|
+
}
|
|
419
|
+
if (params.settings.defaultVisibilityTimeoutSeconds !== undefined) {
|
|
420
|
+
settings.default_visibility_timeout_seconds =
|
|
421
|
+
params.settings.defaultVisibilityTimeoutSeconds;
|
|
422
|
+
}
|
|
423
|
+
if (params.settings.defaultMaxRetries !== undefined) {
|
|
424
|
+
settings.default_max_retries = params.settings.defaultMaxRetries;
|
|
425
|
+
}
|
|
426
|
+
if (params.settings.maxInFlightPerClient !== undefined) {
|
|
427
|
+
settings.max_in_flight_per_client = params.settings.maxInFlightPerClient;
|
|
428
|
+
}
|
|
429
|
+
if (params.settings.retentionSeconds !== undefined) {
|
|
430
|
+
settings.retention_seconds = params.settings.retentionSeconds;
|
|
431
|
+
}
|
|
432
|
+
if (Object.keys(settings).length > 0) {
|
|
433
|
+
requestBody.settings = settings;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
const signal = AbortSignal.timeout(30_000);
|
|
437
|
+
const res = await this.#adapter.invoke(url, {
|
|
438
|
+
method: 'POST',
|
|
439
|
+
signal,
|
|
440
|
+
body: JSON.stringify(requestBody),
|
|
441
|
+
contentType: 'application/json',
|
|
442
|
+
telemetry: {
|
|
443
|
+
name: 'agentuity.queue.create',
|
|
444
|
+
attributes: {
|
|
445
|
+
queueName,
|
|
446
|
+
},
|
|
447
|
+
},
|
|
448
|
+
});
|
|
449
|
+
if (res.ok) {
|
|
450
|
+
const data = unwrapApiResponse(res.data, 'queue');
|
|
451
|
+
const result = QueueCreateResultSchema.safeParse({
|
|
452
|
+
name: data.name,
|
|
453
|
+
queueType: data.queue_type,
|
|
454
|
+
});
|
|
455
|
+
if (result.success) {
|
|
456
|
+
this.#knownQueues.add(queueName);
|
|
457
|
+
return result.data;
|
|
458
|
+
}
|
|
459
|
+
throw new QueueCreateError({
|
|
460
|
+
message: `Queue create returned an unexpected response format: ${result.error.message}`,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
if (res.response.status === 409) {
|
|
464
|
+
this.#knownQueues.add(queueName);
|
|
465
|
+
return {
|
|
466
|
+
name: queueName,
|
|
467
|
+
queueType: params?.queueType ?? 'worker',
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
throw await toServiceException('POST', url, res.response);
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* @inheritdoc
|
|
474
|
+
*/
|
|
475
|
+
async deleteQueue(queueName) {
|
|
476
|
+
validateQueueNameInternal(queueName);
|
|
477
|
+
const url = buildUrl(this.#baseUrl, `/queue/delete/${encodeURIComponent(queueName)}`);
|
|
478
|
+
const signal = AbortSignal.timeout(30_000);
|
|
479
|
+
const res = await this.#adapter.invoke(url, {
|
|
480
|
+
method: 'DELETE',
|
|
481
|
+
signal,
|
|
482
|
+
telemetry: {
|
|
483
|
+
name: 'agentuity.queue.delete',
|
|
484
|
+
attributes: {
|
|
485
|
+
queueName,
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
});
|
|
489
|
+
if (res.ok) {
|
|
490
|
+
this.#knownQueues.delete(queueName);
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (res.response.status === 404) {
|
|
494
|
+
throw new QueueNotFoundError({
|
|
495
|
+
message: `Queue not found: ${queueName}`,
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
throw await toServiceException('DELETE', url, res.response);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;SACD,CAAC,CAAC;QAEH,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACpC,OAAO;QACR,CAAC;QAED,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACjC,MAAM,IAAI,kBAAkB,CAAC;gBAC5B,OAAO,EAAE,oBAAoB,SAAS,EAAE;aACxC,CAAC,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,kBAAkB,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7D,CAAC;CACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentuity/queue",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "Agentuity employees and contributors",
|
|
6
6
|
"type": "module",
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
"prepublishOnly": "bun run clean && bun run build"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@agentuity/
|
|
29
|
-
"@agentuity/
|
|
28
|
+
"@agentuity/adapter": "3.1.1",
|
|
29
|
+
"@agentuity/config": "3.1.1",
|
|
30
|
+
"@agentuity/client": "3.1.1",
|
|
30
31
|
"zod": "^4.3.5"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
QueueStorageService,
|
|
3
|
-
QueueService,
|
|
4
|
-
type QueuePublishParams,
|
|
5
|
-
type QueuePublishResult,
|
|
6
|
-
type QueueCreateParams,
|
|
7
|
-
type QueueCreateResult,
|
|
8
|
-
QueuePublishParamsSchema,
|
|
9
|
-
QueuePublishResultSchema,
|
|
10
|
-
QueueCreateParamsSchema,
|
|
11
|
-
QueueCreateResultSchema,
|
|
12
|
-
QueuePublishError,
|
|
13
|
-
QueueNotFoundError,
|
|
14
|
-
QueueValidationError,
|
|
15
|
-
} from '@agentuity/core/queue';
|
|
1
|
+
export * from './service.ts';
|
|
16
2
|
|
|
17
3
|
import {
|
|
18
4
|
QueueStorageService,
|
|
@@ -20,20 +6,19 @@ import {
|
|
|
20
6
|
type QueuePublishResult,
|
|
21
7
|
type QueueCreateParams,
|
|
22
8
|
type QueueCreateResult,
|
|
23
|
-
} from '
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
|
|
9
|
+
} from './service.ts';
|
|
10
|
+
import { StructuredError } from '@agentuity/adapter';
|
|
11
|
+
import { getServiceUrls } from '@agentuity/config';
|
|
12
|
+
import {
|
|
13
|
+
createServiceAdapter,
|
|
14
|
+
isLogger,
|
|
15
|
+
resolveApiKey,
|
|
16
|
+
resolveRegion,
|
|
17
|
+
resolveServiceUrl,
|
|
18
|
+
type Logger,
|
|
19
|
+
} from '@agentuity/client';
|
|
28
20
|
import { z, ZodError } from 'zod';
|
|
29
21
|
|
|
30
|
-
const isLogger = (val: unknown): val is Logger =>
|
|
31
|
-
typeof val === 'object' &&
|
|
32
|
-
val !== null &&
|
|
33
|
-
['info', 'warn', 'error', 'debug', 'trace'].every(
|
|
34
|
-
(m) => typeof (val as Record<string, unknown>)[m] === 'function'
|
|
35
|
-
);
|
|
36
|
-
|
|
37
22
|
const QueueClientValidationError = StructuredError('QueueClientValidationError')<{
|
|
38
23
|
schema: string;
|
|
39
24
|
issues: Array<{ path: string; message: string }>;
|
|
@@ -68,21 +53,18 @@ export class QueueClient {
|
|
|
68
53
|
}
|
|
69
54
|
throw err;
|
|
70
55
|
}
|
|
71
|
-
const apiKey =
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const headers = buildClientHeaders({
|
|
56
|
+
const apiKey = resolveApiKey(validatedOptions.apiKey);
|
|
57
|
+
const serviceUrls = getServiceUrls(resolveRegion());
|
|
58
|
+
const url = resolveServiceUrl({
|
|
59
|
+
url: validatedOptions.url,
|
|
60
|
+
envKey: 'AGENTUITY_QUEUE_URL',
|
|
61
|
+
fallback: serviceUrls.catalyst,
|
|
62
|
+
});
|
|
63
|
+
const { adapter } = createServiceAdapter({
|
|
81
64
|
apiKey,
|
|
82
65
|
orgId: validatedOptions.orgId,
|
|
66
|
+
logger: validatedOptions.logger,
|
|
83
67
|
});
|
|
84
|
-
|
|
85
|
-
const adapter = createServerFetchAdapter({ headers }, logger);
|
|
86
68
|
this.#service = new QueueStorageService(url, adapter);
|
|
87
69
|
}
|
|
88
70
|
|