@agentuity/queue 1.0.54

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 ADDED
@@ -0,0 +1,37 @@
1
+ # Agent Guidelines for @agentuity/queue
2
+
3
+ ## Package Overview
4
+
5
+ Standalone package for the Agentuity Queue service. Provides a simple, ergonomic client for publishing messages to queues.
6
+
7
+ ## Commands
8
+
9
+ - **Build**: `bun run build`
10
+ - **Typecheck**: `bun run typecheck`
11
+ - **Clean**: `rm -rf dist`
12
+
13
+ ## Architecture
14
+
15
+ - **Runtime**: Node.js and Bun compatible
16
+ - **Exports**: QueueClient and all types from @agentuity/core/queue
17
+ - **Dependencies**: @agentuity/core, zod
18
+
19
+ ## Usage
20
+
21
+ ```typescript
22
+ import { QueueClient } from '@agentuity/queue';
23
+
24
+ const client = new QueueClient();
25
+
26
+ // Create a queue
27
+ await client.createQueue('my-queue');
28
+
29
+ // Publish a message
30
+ const result = await client.publish('my-queue', { task: 'process' });
31
+ console.log(`Message ${result.id} published at offset ${result.offset}`);
32
+ ```
33
+
34
+ ## Publishing
35
+
36
+ 1. Run `bun run build`
37
+ 2. Must publish **after** @agentuity/core
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # @agentuity/queue
2
+
3
+ A standalone package for the Agentuity Queue service.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @agentuity/queue
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { QueueClient } from '@agentuity/queue';
15
+
16
+ const client = new QueueClient();
17
+
18
+ // Create a queue
19
+ await client.createQueue('order-processing');
20
+
21
+ // Publish a message
22
+ const result = await client.publish('order-processing', {
23
+ orderId: 123,
24
+ action: 'process'
25
+ }, {
26
+ metadata: { priority: 'high' },
27
+ ttl: 3600
28
+ });
29
+
30
+ console.log(`Message ${result.id} published`);
31
+
32
+ // Delete a queue
33
+ await client.deleteQueue('old-queue');
34
+ ```
35
+
36
+ ## Configuration
37
+
38
+ ```typescript
39
+ const client = new QueueClient({
40
+ apiKey: 'your-api-key',
41
+ url: 'https://api.agentuity.com',
42
+ });
43
+ ```
44
+
45
+ ### Environment Variables
46
+
47
+ | Variable | Description | Default |
48
+ |----------|-------------|---------|
49
+ | `AGENTUITY_SDK_KEY` | API key for authentication | Required |
50
+ | `AGENTUITY_REGION` | Region for API endpoints | `usc` |
51
+ | `AGENTUITY_QUEUE_URL` | Override Queue API URL | Auto-detected |
52
+
53
+ ## License
54
+
55
+ Apache-2.0
@@ -0,0 +1,19 @@
1
+ export { QueueStorageService, QueueService, type QueuePublishParams, type QueuePublishResult, type QueueCreateParams, type QueueCreateResult, QueuePublishParamsSchema, QueuePublishResultSchema, QueueCreateParamsSchema, QueueCreateResultSchema, QueuePublishError, QueueNotFoundError, QueueValidationError, } from '@agentuity/core/queue';
2
+ import { type QueuePublishParams, type QueuePublishResult, type QueueCreateParams, type QueueCreateResult } from '@agentuity/core/queue';
3
+ import { type Logger } from '@agentuity/server';
4
+ import { z } from 'zod';
5
+ export declare const QueueClientOptionsSchema: z.ZodObject<{
6
+ apiKey: z.ZodOptional<z.ZodString>;
7
+ url: z.ZodOptional<z.ZodString>;
8
+ orgId: z.ZodOptional<z.ZodString>;
9
+ logger: z.ZodOptional<z.ZodCustom<Logger, Logger>>;
10
+ }, z.core.$strip>;
11
+ export type QueueClientOptions = z.infer<typeof QueueClientOptionsSchema>;
12
+ export declare class QueueClient {
13
+ #private;
14
+ constructor(options?: QueueClientOptions);
15
+ publish(queueName: string, payload: string | object, params?: QueuePublishParams): Promise<QueuePublishResult>;
16
+ createQueue(queueName: string, params?: QueueCreateParams): Promise<QueueCreateResult>;
17
+ deleteQueue(queueName: string): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,GACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAEN,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAgD,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI9F,OAAO,EAAE,CAAC,EAAY,MAAM,KAAK,CAAC;AAclC,eAAO,MAAM,wBAAwB;;;;;iBAKnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,qBAAa,WAAW;;gBAGX,OAAO,GAAE,kBAAuB;IAoCtC,OAAO,CACZ,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,CAAC,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC;IAIxB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAItF,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGnD"}
package/dist/index.js ADDED
@@ -0,0 +1,61 @@
1
+ export { QueueStorageService, QueuePublishParamsSchema, QueuePublishResultSchema, QueueCreateParamsSchema, QueueCreateResultSchema, QueuePublishError, QueueNotFoundError, QueueValidationError, } from '@agentuity/core/queue';
2
+ import { QueueStorageService, } from '@agentuity/core/queue';
3
+ import { createServerFetchAdapter, buildClientHeaders } from '@agentuity/server';
4
+ import { createMinimalLogger, StructuredError } from '@agentuity/core';
5
+ import { getEnv } from '@agentuity/core';
6
+ import { getServiceUrls } from '@agentuity/core/config';
7
+ import { z, ZodError } from 'zod';
8
+ const isLogger = (val) => typeof val === 'object' &&
9
+ val !== null &&
10
+ ['info', 'warn', 'error', 'debug', 'trace'].every((m) => typeof val[m] === 'function');
11
+ const QueueClientValidationError = StructuredError('QueueClientValidationError')();
12
+ export const QueueClientOptionsSchema = z.object({
13
+ apiKey: z.string().optional().describe('API key for authentication'),
14
+ url: z.string().optional().describe('Base URL for the Queue API'),
15
+ orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
16
+ logger: z.custom(isLogger).optional().describe('Custom logger instance'),
17
+ });
18
+ export class QueueClient {
19
+ #service;
20
+ constructor(options = {}) {
21
+ let validatedOptions;
22
+ try {
23
+ validatedOptions = QueueClientOptionsSchema.parse(options);
24
+ }
25
+ catch (err) {
26
+ if (err instanceof ZodError) {
27
+ throw new QueueClientValidationError({
28
+ message: 'Invalid QueueClient options',
29
+ schema: 'QueueClientOptionsSchema',
30
+ issues: err.issues.map((i) => ({
31
+ path: i.path.join('.'),
32
+ message: i.message,
33
+ })),
34
+ cause: err,
35
+ });
36
+ }
37
+ throw err;
38
+ }
39
+ const apiKey = validatedOptions.apiKey || getEnv('AGENTUITY_SDK_KEY') || getEnv('AGENTUITY_CLI_KEY');
40
+ const region = getEnv('AGENTUITY_REGION') ?? 'usc';
41
+ const serviceUrls = getServiceUrls(region);
42
+ const url = validatedOptions.url || getEnv('AGENTUITY_QUEUE_URL') || serviceUrls.catalyst;
43
+ const logger = validatedOptions.logger ?? createMinimalLogger();
44
+ const headers = buildClientHeaders({
45
+ apiKey,
46
+ orgId: validatedOptions.orgId,
47
+ });
48
+ const adapter = createServerFetchAdapter({ headers }, logger);
49
+ this.#service = new QueueStorageService(url, adapter);
50
+ }
51
+ async publish(queueName, payload, params) {
52
+ return this.#service.publish(queueName, payload, params);
53
+ }
54
+ async createQueue(queueName, params) {
55
+ return this.#service.createQueue(queueName, params);
56
+ }
57
+ async deleteQueue(queueName) {
58
+ return this.#service.deleteQueue(queueName);
59
+ }
60
+ }
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EAMnB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,GACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACN,mBAAmB,GAKnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAe,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAElC,MAAM,QAAQ,GAAG,CAAC,GAAY,EAAiB,EAAE,CAChD,OAAO,GAAG,KAAK,QAAQ;IACvB,GAAG,KAAK,IAAI;IACZ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAChD,CAAC,CAAC,EAAE,EAAE,CAAC,OAAQ,GAA+B,CAAC,CAAC,CAAC,KAAK,UAAU,CAChE,CAAC;AAEH,MAAM,0BAA0B,GAAG,eAAe,CAAC,4BAA4B,CAAC,EAG5E,CAAC;AAEL,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IACpE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,C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,QAAQ,CAAC;QAE1F,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,IAAI,mBAAmB,EAAE,CAAC;QAEhE,MAAM,OAAO,GAAG,kBAAkB,CAAC;YAClC,MAAM;YACN,KAAK,EAAE,gBAAgB,CAAC,KAAK;SAC7B,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,wBAAwB,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;QAC9D,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAmB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,OAAO,CACZ,SAAiB,EACjB,OAAwB,EACxB,MAA2B;QAE3B,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,SAAiB,EAAE,MAA0B;QAC9D,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,SAAiB;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACD"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@agentuity/queue",
3
+ "version": "1.0.54",
4
+ "license": "Apache-2.0",
5
+ "author": "Agentuity employees and contributors",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "AGENTS.md",
11
+ "README.md",
12
+ "src",
13
+ "dist"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "import": "./dist/index.js",
18
+ "types": "./dist/index.d.ts"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
23
+ "build": "bunx tsc --build --force",
24
+ "typecheck": "bunx tsc --noEmit",
25
+ "prepublishOnly": "bun run clean && bun run build"
26
+ },
27
+ "dependencies": {
28
+ "@agentuity/core": "1.0.54",
29
+ "@agentuity/server": "1.0.54",
30
+ "zod": "^4.3.5"
31
+ },
32
+ "devDependencies": {
33
+ "@types/bun": "latest",
34
+ "@types/node": "^22.0.0",
35
+ "bun-types": "latest",
36
+ "typescript": "^5.9.0"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "sideEffects": false
42
+ }
package/src/index.ts ADDED
@@ -0,0 +1,104 @@
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';
16
+
17
+ import {
18
+ QueueStorageService,
19
+ type QueuePublishParams,
20
+ type QueuePublishResult,
21
+ type QueueCreateParams,
22
+ type QueueCreateResult,
23
+ } from '@agentuity/core/queue';
24
+ import { createServerFetchAdapter, buildClientHeaders, type Logger } from '@agentuity/server';
25
+ import { createMinimalLogger, StructuredError } from '@agentuity/core';
26
+ import { getEnv } from '@agentuity/core';
27
+ import { getServiceUrls } from '@agentuity/core/config';
28
+ import { z, ZodError } from 'zod';
29
+
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
+ const QueueClientValidationError = StructuredError('QueueClientValidationError')<{
38
+ schema: string;
39
+ issues: Array<{ path: string; message: string }>;
40
+ }>();
41
+
42
+ export const QueueClientOptionsSchema = z.object({
43
+ apiKey: z.string().optional().describe('API key for authentication'),
44
+ url: z.string().optional().describe('Base URL for the Queue API'),
45
+ orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
46
+ logger: z.custom<Logger>(isLogger).optional().describe('Custom logger instance'),
47
+ });
48
+ export type QueueClientOptions = z.infer<typeof QueueClientOptionsSchema>;
49
+
50
+ export class QueueClient {
51
+ readonly #service: QueueStorageService;
52
+
53
+ constructor(options: QueueClientOptions = {}) {
54
+ let validatedOptions: QueueClientOptions;
55
+ try {
56
+ validatedOptions = QueueClientOptionsSchema.parse(options);
57
+ } catch (err) {
58
+ if (err instanceof ZodError) {
59
+ throw new QueueClientValidationError({
60
+ message: 'Invalid QueueClient options',
61
+ schema: 'QueueClientOptionsSchema',
62
+ issues: err.issues.map((i) => ({
63
+ path: i.path.join('.'),
64
+ message: i.message,
65
+ })),
66
+ cause: err,
67
+ });
68
+ }
69
+ throw err;
70
+ }
71
+ const apiKey =
72
+ validatedOptions.apiKey || getEnv('AGENTUITY_SDK_KEY') || getEnv('AGENTUITY_CLI_KEY');
73
+ const region = getEnv('AGENTUITY_REGION') ?? 'usc';
74
+ const serviceUrls = getServiceUrls(region);
75
+
76
+ const url = validatedOptions.url || getEnv('AGENTUITY_QUEUE_URL') || serviceUrls.catalyst;
77
+
78
+ const logger = validatedOptions.logger ?? createMinimalLogger();
79
+
80
+ const headers = buildClientHeaders({
81
+ apiKey,
82
+ orgId: validatedOptions.orgId,
83
+ });
84
+
85
+ const adapter = createServerFetchAdapter({ headers }, logger);
86
+ this.#service = new QueueStorageService(url, adapter);
87
+ }
88
+
89
+ async publish(
90
+ queueName: string,
91
+ payload: string | object,
92
+ params?: QueuePublishParams
93
+ ): Promise<QueuePublishResult> {
94
+ return this.#service.publish(queueName, payload, params);
95
+ }
96
+
97
+ async createQueue(queueName: string, params?: QueueCreateParams): Promise<QueueCreateResult> {
98
+ return this.#service.createQueue(queueName, params);
99
+ }
100
+
101
+ async deleteQueue(queueName: string): Promise<void> {
102
+ return this.#service.deleteQueue(queueName);
103
+ }
104
+ }