@braingrid/cli 0.1.2 → 0.2.0

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 (38) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/LICENSE.md +15 -0
  3. package/README.md +2 -5
  4. package/dist/cli.js +265 -317
  5. package/dist/cli.js.map +1 -1
  6. package/dist/handlers/auth.handlers.d.ts +1 -7
  7. package/dist/handlers/auth.handlers.d.ts.map +1 -1
  8. package/dist/handlers/auth.handlers.js +29 -79
  9. package/dist/handlers/auth.handlers.js.map +1 -1
  10. package/dist/handlers/index.d.ts +0 -1
  11. package/dist/handlers/index.d.ts.map +1 -1
  12. package/dist/handlers/index.js +0 -1
  13. package/dist/handlers/index.js.map +1 -1
  14. package/package.json +27 -7
  15. package/dist/handlers/agent.handlers.d.ts +0 -12
  16. package/dist/handlers/agent.handlers.d.ts.map +0 -1
  17. package/dist/handlers/agent.handlers.js +0 -130
  18. package/dist/handlers/agent.handlers.js.map +0 -1
  19. package/dist/rpc/registry.d.ts +0 -97
  20. package/dist/rpc/registry.d.ts.map +0 -1
  21. package/dist/rpc/registry.js +0 -119
  22. package/dist/rpc/registry.js.map +0 -1
  23. package/dist/rpc/server.d.ts +0 -78
  24. package/dist/rpc/server.d.ts.map +0 -1
  25. package/dist/rpc/server.js +0 -437
  26. package/dist/rpc/server.js.map +0 -1
  27. package/dist/rpc/transport.d.ts +0 -84
  28. package/dist/rpc/transport.d.ts.map +0 -1
  29. package/dist/rpc/transport.js +0 -296
  30. package/dist/rpc/transport.js.map +0 -1
  31. package/dist/services/__mocks__/utils.d.ts +0 -16
  32. package/dist/services/__mocks__/utils.d.ts.map +0 -1
  33. package/dist/services/__mocks__/utils.js +0 -21
  34. package/dist/services/__mocks__/utils.js.map +0 -1
  35. package/dist/services/agent-service.d.ts +0 -29
  36. package/dist/services/agent-service.d.ts.map +0 -1
  37. package/dist/services/agent-service.js +0 -273
  38. package/dist/services/agent-service.js.map +0 -1
@@ -1,84 +0,0 @@
1
- /**
2
- * STDIO Transport Layer for JSON-RPC 2.0
3
- * Handles newline-delimited JSON message parsing and sending over stdin/stdout
4
- */
5
- import { EventEmitter } from 'events';
6
- import type { Readable, Writable } from 'stream';
7
- import type { JsonRpcMessage, JsonRpcBatchRequest, JsonRpcBatchResponse, Transport } from '@braingrid/protocol';
8
- /**
9
- * STDIO Transport implementation for JSON-RPC communication
10
- */
11
- export declare class StdioTransport extends EventEmitter implements Transport {
12
- private readonly input;
13
- private readonly output;
14
- private buffer;
15
- private isClosed;
16
- private readonly useContentLength;
17
- private contentBuffer;
18
- private expectedContentLength;
19
- private headers;
20
- constructor(input?: Readable, output?: Writable, options?: {
21
- useContentLength?: boolean;
22
- });
23
- /**
24
- * Handle incoming data chunks from stdin
25
- */
26
- private handleData;
27
- /**
28
- * Handle data in newline-delimited mode
29
- */
30
- private handleNewlineDelimitedData;
31
- /**
32
- * Handle data in content-length mode (LSP-style)
33
- */
34
- private handleContentLengthData;
35
- /**
36
- * Parse LSP-style headers
37
- */
38
- private parseHeaders;
39
- /**
40
- * Process a complete JSON message string
41
- */
42
- private processMessage;
43
- /**
44
- * Process a single JSON-RPC message
45
- */
46
- private processSingleMessage;
47
- /**
48
- * Process a batch request (array of messages)
49
- */
50
- private processBatchRequest;
51
- /**
52
- * Send a JSON-RPC message or batch response
53
- */
54
- send(message: JsonRpcMessage | JsonRpcBatchResponse): Promise<void>;
55
- /**
56
- * Set up a handler for incoming messages
57
- */
58
- onMessage(handler: (message: JsonRpcMessage) => void): void;
59
- /**
60
- * Set up a handler for batch requests
61
- */
62
- onBatch(handler: (batch: JsonRpcBatchRequest) => void): void;
63
- /**
64
- * Set up a handler for transport errors
65
- */
66
- onError(handler: (error: Error) => void): void;
67
- /**
68
- * Handle transport errors
69
- */
70
- private handleError;
71
- /**
72
- * Handle transport close
73
- */
74
- private handleClose;
75
- /**
76
- * Close the transport
77
- */
78
- close(): Promise<void>;
79
- /**
80
- * Check if transport is closed
81
- */
82
- get closed(): boolean;
83
- }
84
- //# sourceMappingURL=transport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/rpc/transport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EACX,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,MAAM,qBAAqB,CAAC;AAG7B;;GAEG;AACH,qBAAa,cAAe,SAAQ,YAAa,YAAW,SAAS;IACpE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;IAClC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAU;IAC3C,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,qBAAqB,CAAuB;IACpD,OAAO,CAAC,OAAO,CAAkC;gBAGhD,KAAK,GAAE,QAAwB,EAC/B,MAAM,GAAE,QAAyB,EACjC,OAAO,GAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAO;IAkB7C;;OAEG;IACH,OAAO,CAAC,UAAU;IAYlB;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAmBlC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA6D/B;;OAEG;IACH,OAAO,CAAC,YAAY;IAYpB;;OAEG;IACH,OAAO,CAAC,cAAc;IAuBtB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAmB5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0CzE;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI;IAI3D;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,GAAG,IAAI;IAI5D;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI;IAI9C;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB5B;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;CACD"}
@@ -1,296 +0,0 @@
1
- /**
2
- * STDIO Transport Layer for JSON-RPC 2.0
3
- * Handles newline-delimited JSON message parsing and sending over stdin/stdout
4
- */
5
- import { EventEmitter } from 'events';
6
- import { createParseError, safeParseJsonRpcMessage } from '@braingrid/protocol';
7
- /**
8
- * STDIO Transport implementation for JSON-RPC communication
9
- */
10
- export class StdioTransport extends EventEmitter {
11
- constructor(input = process.stdin, output = process.stdout, options = {}) {
12
- super();
13
- this.buffer = '';
14
- this.isClosed = false;
15
- this.contentBuffer = Buffer.alloc(0);
16
- this.expectedContentLength = null;
17
- this.headers = new Map();
18
- this.input = input;
19
- this.output = output;
20
- this.useContentLength = options.useContentLength || false;
21
- // Set encoding to UTF-8 for newline-delimited mode
22
- if (!this.useContentLength) {
23
- this.input.setEncoding('utf8');
24
- }
25
- // Set up input stream handling
26
- this.input.on('data', this.handleData.bind(this));
27
- this.input.on('error', this.handleError.bind(this));
28
- this.input.on('end', () => this.handleClose());
29
- }
30
- /**
31
- * Handle incoming data chunks from stdin
32
- */
33
- handleData(chunk) {
34
- if (this.isClosed)
35
- return;
36
- if (this.useContentLength) {
37
- // Content-Length mode (LSP-style)
38
- this.handleContentLengthData(chunk);
39
- }
40
- else {
41
- // Newline-delimited mode
42
- this.handleNewlineDelimitedData(chunk);
43
- }
44
- }
45
- /**
46
- * Handle data in newline-delimited mode
47
- */
48
- handleNewlineDelimitedData(chunk) {
49
- // Add chunk to buffer
50
- this.buffer += chunk;
51
- // Process complete messages (newline-delimited)
52
- let newlineIndex;
53
- while ((newlineIndex = this.buffer.indexOf('\n')) !== -1) {
54
- // Extract the complete message
55
- const messageStr = this.buffer.substring(0, newlineIndex).trim();
56
- this.buffer = this.buffer.substring(newlineIndex + 1);
57
- // Skip empty lines
58
- if (messageStr.length === 0)
59
- continue;
60
- // Parse and emit the message
61
- this.processMessage(messageStr);
62
- }
63
- }
64
- /**
65
- * Handle data in content-length mode (LSP-style)
66
- */
67
- handleContentLengthData(chunk) {
68
- // Append chunk to content buffer
69
- this.contentBuffer = Buffer.concat([this.contentBuffer, chunk]);
70
- while (true) {
71
- if (this.expectedContentLength === null) {
72
- // Try to parse headers
73
- const headerEndIndex = this.contentBuffer.indexOf('\r\n\r\n');
74
- if (headerEndIndex === -1) {
75
- // Not enough data for headers yet
76
- break;
77
- }
78
- // Extract headers
79
- const headersStr = this.contentBuffer.subarray(0, headerEndIndex).toString('utf8');
80
- this.parseHeaders(headersStr);
81
- // Remove headers from buffer
82
- this.contentBuffer = this.contentBuffer.subarray(headerEndIndex + 4);
83
- // Get content length
84
- const contentLengthStr = this.headers.get('content-length');
85
- if (!contentLengthStr) {
86
- this.handleError(new Error('Missing Content-Length header'));
87
- this.contentBuffer = Buffer.alloc(0);
88
- this.headers.clear();
89
- break;
90
- }
91
- this.expectedContentLength = parseInt(contentLengthStr, 10);
92
- if (isNaN(this.expectedContentLength)) {
93
- this.handleError(new Error(`Invalid Content-Length: ${contentLengthStr}`));
94
- this.contentBuffer = Buffer.alloc(0);
95
- this.headers.clear();
96
- this.expectedContentLength = null;
97
- break;
98
- }
99
- }
100
- // Check if we have the full content
101
- if (this.contentBuffer.length >= this.expectedContentLength) {
102
- // Extract the message content
103
- const messageBuffer = this.contentBuffer.subarray(0, this.expectedContentLength);
104
- const messageStr = messageBuffer.toString('utf8');
105
- // Remove processed content from buffer
106
- this.contentBuffer = this.contentBuffer.subarray(this.expectedContentLength);
107
- // Reset for next message
108
- this.expectedContentLength = null;
109
- this.headers.clear();
110
- // Process the message
111
- this.processMessage(messageStr);
112
- }
113
- else {
114
- // Not enough data for content yet
115
- break;
116
- }
117
- }
118
- }
119
- /**
120
- * Parse LSP-style headers
121
- */
122
- parseHeaders(headersStr) {
123
- const lines = headersStr.split('\r\n');
124
- for (const line of lines) {
125
- const colonIndex = line.indexOf(':');
126
- if (colonIndex !== -1) {
127
- const key = line.substring(0, colonIndex).toLowerCase().trim();
128
- const value = line.substring(colonIndex + 1).trim();
129
- this.headers.set(key, value);
130
- }
131
- }
132
- }
133
- /**
134
- * Process a complete JSON message string
135
- */
136
- processMessage(messageStr) {
137
- try {
138
- // Parse JSON
139
- const jsonData = JSON.parse(messageStr);
140
- // Check if it's a batch request (array)
141
- if (Array.isArray(jsonData)) {
142
- // Process as batch request
143
- this.processBatchRequest(jsonData);
144
- }
145
- else {
146
- // Process as single message
147
- this.processSingleMessage(jsonData);
148
- }
149
- }
150
- catch (error) {
151
- // JSON parse error
152
- const errorMessage = error instanceof Error ? error.message : 'Invalid JSON';
153
- const errorResponse = createParseError(`JSON parse error: ${errorMessage}`);
154
- this.emit('error', new Error(errorResponse.error.message));
155
- // Send error response
156
- this.send(errorResponse).catch(err => this.handleError(err));
157
- }
158
- }
159
- /**
160
- * Process a single JSON-RPC message
161
- */
162
- processSingleMessage(jsonData) {
163
- // Validate as JSON-RPC message
164
- const parseResult = safeParseJsonRpcMessage(jsonData);
165
- if (!parseResult.success) {
166
- // Emit parse error
167
- const errorResponse = createParseError(`Invalid JSON-RPC message: ${parseResult.error?.message || 'Unknown validation error'}`);
168
- this.emit('error', new Error(errorResponse.error.message));
169
- // Send error response
170
- this.send(errorResponse).catch(err => this.handleError(err));
171
- return;
172
- }
173
- // Emit the validated message
174
- this.emit('message', parseResult.data);
175
- }
176
- /**
177
- * Process a batch request (array of messages)
178
- */
179
- processBatchRequest(jsonArray) {
180
- if (jsonArray.length === 0) {
181
- // Empty batch is invalid
182
- const errorResponse = createParseError('Batch request cannot be empty');
183
- this.emit('error', new Error(errorResponse.error.message));
184
- this.send(errorResponse).catch(err => this.handleError(err));
185
- return;
186
- }
187
- // Emit as batch request
188
- this.emit('batch', jsonArray);
189
- }
190
- /**
191
- * Send a JSON-RPC message or batch response
192
- */
193
- async send(message) {
194
- if (this.isClosed) {
195
- throw new Error('Transport is closed');
196
- }
197
- return new Promise((resolve, reject) => {
198
- try {
199
- const messageStr = JSON.stringify(message);
200
- if (this.useContentLength) {
201
- // Content-Length mode (LSP-style)
202
- const contentBuffer = Buffer.from(messageStr, 'utf8');
203
- const headers = `Content-Length: ${contentBuffer.length}\r\n\r\n`;
204
- const fullMessage = Buffer.concat([Buffer.from(headers, 'utf8'), contentBuffer]);
205
- // Write headers and content
206
- this.output.write(fullMessage, error => {
207
- if (error) {
208
- reject(error);
209
- }
210
- else {
211
- resolve();
212
- }
213
- });
214
- }
215
- else {
216
- // Newline-delimited mode
217
- const fullMessage = messageStr + '\n';
218
- // Write to output stream
219
- this.output.write(fullMessage, 'utf8', error => {
220
- if (error) {
221
- reject(error);
222
- }
223
- else {
224
- resolve();
225
- }
226
- });
227
- }
228
- }
229
- catch (error) {
230
- reject(error);
231
- }
232
- });
233
- }
234
- /**
235
- * Set up a handler for incoming messages
236
- */
237
- onMessage(handler) {
238
- this.on('message', handler);
239
- }
240
- /**
241
- * Set up a handler for batch requests
242
- */
243
- onBatch(handler) {
244
- this.on('batch', handler);
245
- }
246
- /**
247
- * Set up a handler for transport errors
248
- */
249
- onError(handler) {
250
- this.on('error', handler);
251
- }
252
- /**
253
- * Handle transport errors
254
- */
255
- handleError(error) {
256
- if (!this.isClosed) {
257
- this.emit('error', error);
258
- }
259
- }
260
- /**
261
- * Handle transport close
262
- */
263
- handleClose() {
264
- if (!this.isClosed) {
265
- this.isClosed = true;
266
- this.emit('close');
267
- }
268
- }
269
- /**
270
- * Close the transport
271
- */
272
- async close() {
273
- if (this.isClosed)
274
- return;
275
- this.isClosed = true;
276
- // Remove all listeners
277
- this.removeAllListeners();
278
- // Clear buffer
279
- this.buffer = '';
280
- // Don't close stdin/stdout if they are the actual process streams
281
- if (this.input !== process.stdin) {
282
- this.input.destroy();
283
- }
284
- if (this.output !== process.stdout) {
285
- this.output.end();
286
- }
287
- this.emit('close');
288
- }
289
- /**
290
- * Check if transport is closed
291
- */
292
- get closed() {
293
- return this.isClosed;
294
- }
295
- }
296
- //# sourceMappingURL=transport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/rpc/transport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAQtC,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEhF;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,YAAY;IAU/C,YACC,QAAkB,OAAO,CAAC,KAAK,EAC/B,SAAmB,OAAO,CAAC,MAAM,EACjC,UAA0C,EAAE;QAE5C,KAAK,EAAE,CAAC;QAZD,WAAM,GAAW,EAAE,CAAC;QACpB,aAAQ,GAAY,KAAK,CAAC;QAE1B,kBAAa,GAAW,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACxC,0BAAqB,GAAkB,IAAI,CAAC;QAC5C,YAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;QAQhD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,KAAK,CAAC;QAE1D,mDAAmD;QACnD,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC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,CAAC;QACtB,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;CACD"}
@@ -1,16 +0,0 @@
1
- export declare const mockParseRequirementId: (id: string) => {
2
- type: string;
3
- value: number;
4
- } | {
5
- type: string;
6
- value: string;
7
- };
8
- export declare const mockParseTaskId: (id: string) => {
9
- type: string;
10
- value: number;
11
- } | {
12
- type: string;
13
- value: string;
14
- };
15
- export declare const mockFindTaskById: (tasks: any[], id: string) => any;
16
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/services/__mocks__/utils.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,sBAAsB,GAAI,IAAI,MAAM;;;;;;CAKhD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM;;;;;;CAKzC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,OAAO,GAAG,EAAE,EAAE,IAAI,MAAM,QAMxD,CAAC"}
@@ -1,21 +0,0 @@
1
- // Mock utilities for tests
2
- export const mockParseRequirementId = (id) => {
3
- if (id.startsWith('REQ-')) {
4
- return { type: 'req_id', value: parseInt(id.substring(4)) };
5
- }
6
- return { type: 'uuid', value: id };
7
- };
8
- export const mockParseTaskId = (id) => {
9
- if (id.startsWith('TASK-')) {
10
- return { type: 'task_id', value: parseInt(id.substring(5)) };
11
- }
12
- return { type: 'uuid', value: id };
13
- };
14
- export const mockFindTaskById = (tasks, id) => {
15
- if (id.startsWith('TASK-')) {
16
- const taskId = parseInt(id.substring(5));
17
- return tasks.find((t) => t.task_id === taskId) || null;
18
- }
19
- return tasks.find((t) => t.id === id) || null;
20
- };
21
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/services/__mocks__/utils.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAU,EAAE,EAAE;IACpD,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AACpC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAU,EAAE,EAAE;IAC7C,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AACpC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAY,EAAE,EAAU,EAAE,EAAE;IAC5D,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC;IAC7D,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC;AACpD,CAAC,CAAC"}
@@ -1,29 +0,0 @@
1
- /**
2
- * Agent Service
3
- * Handles API interactions for agent conversations
4
- */
5
- import { BraingridAuth } from './auth.js';
6
- import type { StreamingConversationResponse, ConversationContext } from '@braingrid/protocol';
7
- export interface AgentConversationRequest {
8
- project: string;
9
- message: string;
10
- conversationId?: string;
11
- context?: ConversationContext;
12
- }
13
- export declare class AgentService {
14
- private baseUrl;
15
- private auth;
16
- private axios;
17
- constructor(baseUrl: string, auth: BraingridAuth);
18
- private getHeaders;
19
- /**
20
- * Stream a conversation with the agent
21
- * Returns the final response after streaming completes
22
- */
23
- streamConversation(request: AgentConversationRequest): Promise<StreamingConversationResponse>;
24
- /**
25
- * Stream a conversation with callback support for real-time updates
26
- */
27
- streamConversationWithCallback(request: AgentConversationRequest, onChunk: (chunk: StreamingConversationResponse) => void | Promise<void>): Promise<StreamingConversationResponse>;
28
- }
29
- //# sourceMappingURL=agent-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-service.d.ts","sourceRoot":"","sources":["../../src/services/agent-service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,KAAK,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAI9F,MAAM,WAAW,wBAAwB;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC9B;AAkBD,qBAAa,YAAY;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,KAAK,CAAgB;gBAEjB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa;IAMhD,OAAO,CAAC,UAAU;IAMlB;;;OAGG;IACG,kBAAkB,CACvB,OAAO,EAAE,wBAAwB,GAC/B,OAAO,CAAC,6BAA6B,CAAC;IAwOzC;;OAEG;IACG,8BAA8B,CACnC,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE,CAAC,KAAK,EAAE,6BAA6B,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GACrE,OAAO,CAAC,6BAA6B,CAAC;CAsBzC"}