@agentuity/server 0.1.16 → 0.1.18
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/api.d.ts +11 -6
- package/dist/api/api.d.ts.map +1 -1
- package/dist/api/api.js +19 -12
- package/dist/api/api.js.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/org/env-delete.d.ts.map +1 -1
- package/dist/api/org/env-delete.js.map +1 -1
- package/dist/api/org/env-get.d.ts.map +1 -1
- package/dist/api/org/env-get.js.map +1 -1
- package/dist/api/org/env-update.d.ts.map +1 -1
- package/dist/api/org/env-update.js.map +1 -1
- package/dist/api/queue/analytics.d.ts +108 -0
- package/dist/api/queue/analytics.d.ts.map +1 -0
- package/dist/api/queue/analytics.js +245 -0
- package/dist/api/queue/analytics.js.map +1 -0
- package/dist/api/queue/destinations.d.ts +108 -0
- package/dist/api/queue/destinations.d.ts.map +1 -0
- package/dist/api/queue/destinations.js +238 -0
- package/dist/api/queue/destinations.js.map +1 -0
- package/dist/api/queue/dlq.d.ts +100 -0
- package/dist/api/queue/dlq.d.ts.map +1 -0
- package/dist/api/queue/dlq.js +204 -0
- package/dist/api/queue/dlq.js.map +1 -0
- package/dist/api/queue/index.d.ts +55 -0
- package/dist/api/queue/index.d.ts.map +1 -0
- package/dist/api/queue/index.js +86 -0
- package/dist/api/queue/index.js.map +1 -0
- package/dist/api/queue/messages.d.ts +332 -0
- package/dist/api/queue/messages.d.ts.map +1 -0
- package/dist/api/queue/messages.js +637 -0
- package/dist/api/queue/messages.js.map +1 -0
- package/dist/api/queue/queues.d.ts +153 -0
- package/dist/api/queue/queues.d.ts.map +1 -0
- package/dist/api/queue/queues.js +319 -0
- package/dist/api/queue/queues.js.map +1 -0
- package/dist/api/queue/sources.d.ts +132 -0
- package/dist/api/queue/sources.d.ts.map +1 -0
- package/dist/api/queue/sources.js +285 -0
- package/dist/api/queue/sources.js.map +1 -0
- package/dist/api/queue/types.d.ts +1129 -0
- package/dist/api/queue/types.d.ts.map +1 -0
- package/dist/api/queue/types.js +949 -0
- package/dist/api/queue/types.js.map +1 -0
- package/dist/api/queue/util.d.ts +262 -0
- package/dist/api/queue/util.d.ts.map +1 -0
- package/dist/api/queue/util.js +171 -0
- package/dist/api/queue/util.js.map +1 -0
- package/dist/api/queue/validation.d.ts +247 -0
- package/dist/api/queue/validation.d.ts.map +1 -0
- package/dist/api/queue/validation.js +513 -0
- package/dist/api/queue/validation.js.map +1 -0
- package/dist/api/sandbox/get.d.ts.map +1 -1
- package/dist/api/sandbox/get.js +5 -0
- package/dist/api/sandbox/get.js.map +1 -1
- package/dist/api/sandbox/index.d.ts +3 -3
- package/dist/api/sandbox/index.d.ts.map +1 -1
- package/dist/api/sandbox/index.js +1 -1
- package/dist/api/sandbox/index.js.map +1 -1
- package/dist/api/sandbox/run.d.ts.map +1 -1
- package/dist/api/sandbox/run.js +5 -2
- package/dist/api/sandbox/run.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/sandbox/snapshot.d.ts +143 -1
- package/dist/api/sandbox/snapshot.d.ts.map +1 -1
- package/dist/api/sandbox/snapshot.js +183 -4
- package/dist/api/sandbox/snapshot.js.map +1 -1
- package/package.json +4 -4
- package/src/api/api.ts +62 -13
- package/src/api/index.ts +1 -0
- package/src/api/org/env-delete.ts +1 -4
- package/src/api/org/env-get.ts +1 -4
- package/src/api/org/env-update.ts +1 -4
- package/src/api/queue/analytics.ts +313 -0
- package/src/api/queue/destinations.ts +321 -0
- package/src/api/queue/dlq.ts +283 -0
- package/src/api/queue/index.ts +261 -0
- package/src/api/queue/messages.ts +875 -0
- package/src/api/queue/queues.ts +448 -0
- package/src/api/queue/sources.ts +384 -0
- package/src/api/queue/types.ts +1253 -0
- package/src/api/queue/util.ts +204 -0
- package/src/api/queue/validation.ts +560 -0
- package/src/api/sandbox/get.ts +5 -0
- package/src/api/sandbox/index.ts +13 -1
- package/src/api/sandbox/run.ts +5 -2
- package/src/api/sandbox/snapshot-build.ts +4 -0
- package/src/api/sandbox/snapshot.ts +223 -5
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { StructuredError } from '@agentuity/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* General queue operation error.
|
|
5
|
+
*
|
|
6
|
+
* Thrown when a queue operation fails for reasons other than not-found or validation.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* try {
|
|
11
|
+
* await createQueue(client, { queue_type: 'worker' });
|
|
12
|
+
* } catch (error) {
|
|
13
|
+
* if (error instanceof QueueError) {
|
|
14
|
+
* console.error(`Queue operation failed: ${error.message}`);
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export const QueueError = StructuredError('QueueError')<{ queueName?: string }>();
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Error thrown when a queue is not found.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* try {
|
|
27
|
+
* await getQueue(client, 'non-existent-queue');
|
|
28
|
+
* } catch (error) {
|
|
29
|
+
* if (error instanceof QueueNotFoundError) {
|
|
30
|
+
* console.error(`Queue not found: ${error.queueName}`);
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const QueueNotFoundError = StructuredError('QueueNotFoundError')<{ queueName: string }>();
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when a message is not found in a queue.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* try {
|
|
43
|
+
* await getMessage(client, 'my-queue', 'msg_abc123');
|
|
44
|
+
* } catch (error) {
|
|
45
|
+
* if (error instanceof MessageNotFoundError) {
|
|
46
|
+
* console.error(`Message ${error.messageId} not found in ${error.queueName}`);
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export const MessageNotFoundError = StructuredError('MessageNotFoundError')<{
|
|
52
|
+
queueName: string;
|
|
53
|
+
messageId: string;
|
|
54
|
+
}>();
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Error thrown when a destination is not found.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* try {
|
|
62
|
+
* await deleteDestination(client, 'my-queue', 'dest_abc123');
|
|
63
|
+
* } catch (error) {
|
|
64
|
+
* if (error instanceof DestinationNotFoundError) {
|
|
65
|
+
* console.error(`Destination ${error.destinationId} not found`);
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export const DestinationNotFoundError = StructuredError('DestinationNotFoundError')<{
|
|
71
|
+
queueName: string;
|
|
72
|
+
destinationId: string;
|
|
73
|
+
}>();
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Error thrown when a destination with the same type and URL already exists.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* try {
|
|
81
|
+
* await createDestination(client, 'my-queue', { url: 'https://example.com' });
|
|
82
|
+
* } catch (error) {
|
|
83
|
+
* if (error instanceof DestinationAlreadyExistsError) {
|
|
84
|
+
* console.error(`Destination already exists: ${error.url}`);
|
|
85
|
+
* }
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export const DestinationAlreadyExistsError = StructuredError('DestinationAlreadyExistsError')<{
|
|
90
|
+
queueName: string;
|
|
91
|
+
url?: string;
|
|
92
|
+
}>();
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Error thrown when an invalid argument is provided to a queue operation.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* try {
|
|
100
|
+
* await createQueue(client, { queue_type: 'invalid' as any });
|
|
101
|
+
* } catch (error) {
|
|
102
|
+
* if (error instanceof QueueInvalidArgumentError) {
|
|
103
|
+
* console.error(`Invalid parameter: ${error.param}`);
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export const QueueInvalidArgumentError = StructuredError('QueueInvalidArgumentError')<{
|
|
109
|
+
queueName?: string;
|
|
110
|
+
param?: string;
|
|
111
|
+
}>();
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Error thrown when a source is not found.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* try {
|
|
119
|
+
* await getSource(client, 'my-queue', 'qsrc_abc123');
|
|
120
|
+
* } catch (error) {
|
|
121
|
+
* if (error instanceof SourceNotFoundError) {
|
|
122
|
+
* console.error(`Source ${error.sourceId} not found in ${error.queueName}`);
|
|
123
|
+
* }
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export const SourceNotFoundError = StructuredError('SourceNotFoundError')<{
|
|
128
|
+
queueName: string;
|
|
129
|
+
sourceId: string;
|
|
130
|
+
}>();
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Error thrown when a source with the same name already exists.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* try {
|
|
138
|
+
* await createSource(client, 'my-queue', { name: 'existing-source' });
|
|
139
|
+
* } catch (error) {
|
|
140
|
+
* if (error instanceof SourceAlreadyExistsError) {
|
|
141
|
+
* console.error(`Source "${error.name}" already exists in ${error.queueName}`);
|
|
142
|
+
* }
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export const SourceAlreadyExistsError = StructuredError('SourceAlreadyExistsError')<{
|
|
147
|
+
queueName: string;
|
|
148
|
+
name: string;
|
|
149
|
+
}>();
|
|
150
|
+
|
|
151
|
+
/** Current Queue API version. */
|
|
152
|
+
const QUEUE_API_VERSION = '2026-01-15';
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Constructs a full API path for queue operations.
|
|
156
|
+
* New pattern: /queue/[action]/$VERSION/[args]
|
|
157
|
+
*
|
|
158
|
+
* @param action - The action/resource (e.g., 'create', 'list', 'get', 'messages/publish')
|
|
159
|
+
* @param args - Optional path arguments (e.g., queue name, message id)
|
|
160
|
+
* @returns The full API path with version prefix
|
|
161
|
+
*
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
export function queueApiPath(action: string, ...args: string[]): string {
|
|
165
|
+
const encodedArgs = args.map((arg) => encodeURIComponent(arg)).join('/');
|
|
166
|
+
if (encodedArgs) {
|
|
167
|
+
return `/queue/${action}/${QUEUE_API_VERSION}/${encodedArgs}`;
|
|
168
|
+
}
|
|
169
|
+
return `/queue/${action}/${QUEUE_API_VERSION}`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Constructs a full API path for queue operations with query string.
|
|
174
|
+
*
|
|
175
|
+
* @param action - The action/resource
|
|
176
|
+
* @param queryString - Query string to append (without leading ?)
|
|
177
|
+
* @param args - Optional path arguments
|
|
178
|
+
* @returns The full API path with version prefix and query string
|
|
179
|
+
*
|
|
180
|
+
* @internal
|
|
181
|
+
*/
|
|
182
|
+
export function queueApiPathWithQuery(
|
|
183
|
+
action: string,
|
|
184
|
+
queryString: string | undefined,
|
|
185
|
+
...args: string[]
|
|
186
|
+
): string {
|
|
187
|
+
const basePath = queueApiPath(action, ...args);
|
|
188
|
+
return queryString ? `${basePath}?${queryString}` : basePath;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Builds headers for queue API requests.
|
|
193
|
+
*
|
|
194
|
+
* @param orgId - Optional organization ID for CLI authentication
|
|
195
|
+
* @returns Headers object to pass to API client
|
|
196
|
+
*
|
|
197
|
+
* @internal
|
|
198
|
+
*/
|
|
199
|
+
export function buildQueueHeaders(orgId?: string): Record<string, string> | undefined {
|
|
200
|
+
if (orgId) {
|
|
201
|
+
return { 'x-agentuity-orgid': orgId };
|
|
202
|
+
}
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|