@cogitator-ai/fastify 0.1.15 → 0.3.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.
- package/README.md +66 -38
- package/dist/hooks/error-handler.d.ts.map +1 -1
- package/dist/hooks/error-handler.js +29 -0
- package/dist/hooks/error-handler.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +22 -17
- package/dist/plugin.js.map +1 -1
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/agents.js +57 -61
- package/dist/routes/agents.js.map +1 -1
- package/dist/routes/swarms.d.ts.map +1 -1
- package/dist/routes/swarms.js +49 -72
- package/dist/routes/swarms.js.map +1 -1
- package/dist/routes/threads.d.ts.map +1 -1
- package/dist/routes/threads.js +11 -40
- package/dist/routes/threads.js.map +1 -1
- package/dist/routes/utils.d.ts +12 -0
- package/dist/routes/utils.d.ts.map +1 -0
- package/dist/routes/utils.js +32 -0
- package/dist/routes/utils.js.map +1 -0
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/workflows.js +57 -67
- package/dist/routes/workflows.js.map +1 -1
- package/dist/streaming/fastify-stream-writer.d.ts +2 -0
- package/dist/streaming/fastify-stream-writer.d.ts.map +1 -1
- package/dist/streaming/fastify-stream-writer.js +26 -3
- package/dist/streaming/fastify-stream-writer.js.map +1 -1
- package/dist/types.d.ts +11 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -6
- package/dist/types.js.map +1 -1
- package/dist/websocket/handler.d.ts.map +1 -1
- package/dist/websocket/handler.js +171 -95
- package/dist/websocket/handler.js.map +1 -1
- package/package.json +26 -23
package/README.md
CHANGED
|
@@ -20,14 +20,17 @@ import { cogitatorPlugin } from '@cogitator-ai/fastify';
|
|
|
20
20
|
const fastify = Fastify({ logger: true });
|
|
21
21
|
|
|
22
22
|
const cogitator = new Cogitator({
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
llm: {
|
|
24
|
+
defaultModel: 'openai/gpt-6-luna',
|
|
25
|
+
providers: { openai: { apiKey: process.env.OPENAI_API_KEY } },
|
|
26
|
+
},
|
|
25
27
|
});
|
|
26
28
|
|
|
27
29
|
const chatAgent = new Agent({
|
|
28
30
|
name: 'chat',
|
|
31
|
+
description: 'General-purpose chat assistant',
|
|
29
32
|
instructions: 'You are a helpful assistant.',
|
|
30
|
-
model: 'gpt-
|
|
33
|
+
model: 'openai/gpt-6-luna',
|
|
31
34
|
});
|
|
32
35
|
|
|
33
36
|
await fastify.register(cogitatorPlugin, {
|
|
@@ -51,6 +54,8 @@ POST /api/agents/:name/run - Run agent (JSON response)
|
|
|
51
54
|
POST /api/agents/:name/stream - Run agent (SSE stream)
|
|
52
55
|
```
|
|
53
56
|
|
|
57
|
+
Bodies are validated with JSON Schema (`input` must be a non-blank string); validation failures return `400 INVALID_INPUT`. The agent list exposes `config.description`, never the instructions. The authenticated `userId` is passed to the run, and runs are aborted when the client disconnects.
|
|
58
|
+
|
|
54
59
|
### Threads (Memory)
|
|
55
60
|
|
|
56
61
|
```
|
|
@@ -59,6 +64,8 @@ POST /api/threads/:id/messages - Add message to thread
|
|
|
59
64
|
DELETE /api/threads/:id - Delete thread
|
|
60
65
|
```
|
|
61
66
|
|
|
67
|
+
Requires `memory` on the `Cogitator` instance (503 otherwise). Message `metadata` is stored on the memory entry.
|
|
68
|
+
|
|
62
69
|
### Workflows
|
|
63
70
|
|
|
64
71
|
```
|
|
@@ -67,15 +74,19 @@ POST /api/workflows/:name/run - Run workflow
|
|
|
67
74
|
POST /api/workflows/:name/stream - Stream workflow events
|
|
68
75
|
```
|
|
69
76
|
|
|
77
|
+
Options are limited to `maxConcurrency`/`maxIterations` (positive integers) and `checkpoint`. A failed workflow returns `500 WORKFLOW_FAILED` (the stream ends with an `error` event instead of `workflow_completed`). Disconnecting aborts the workflow.
|
|
78
|
+
|
|
70
79
|
### Swarms
|
|
71
80
|
|
|
72
81
|
```
|
|
73
82
|
GET /api/swarms - List all swarms
|
|
74
83
|
POST /api/swarms/:name/run - Run swarm
|
|
75
84
|
POST /api/swarms/:name/stream - Stream swarm events
|
|
76
|
-
GET /api/swarms/:name/blackboard - Get
|
|
85
|
+
GET /api/swarms/:name/blackboard - Get configured blackboard sections
|
|
77
86
|
```
|
|
78
87
|
|
|
88
|
+
`timeout` must be positive. Disconnecting aborts the swarm. Each run creates a fresh swarm, so the blackboard endpoint returns the configured initial sections.
|
|
89
|
+
|
|
79
90
|
### Tools & Docs
|
|
80
91
|
|
|
81
92
|
```
|
|
@@ -96,7 +107,8 @@ await fastify.register(cogitatorPlugin, {
|
|
|
96
107
|
enableWebSocket: true,
|
|
97
108
|
enableSwagger: true,
|
|
98
109
|
|
|
99
|
-
// Authentication
|
|
110
|
+
// Authentication — throw to reject with 401. Runs as an onRequest hook, so it
|
|
111
|
+
// also guards WebSocket upgrades; the returned userId is passed to agent runs.
|
|
100
112
|
auth: async (request) => {
|
|
101
113
|
const token = request.headers.authorization?.replace('Bearer ', '');
|
|
102
114
|
const user = await validateToken(token);
|
|
@@ -116,7 +128,7 @@ await fastify.register(cogitatorPlugin, {
|
|
|
116
128
|
version: '1.0.0',
|
|
117
129
|
},
|
|
118
130
|
|
|
119
|
-
// WebSocket options
|
|
131
|
+
// WebSocket options (path is relative to the prefix)
|
|
120
132
|
websocket: {
|
|
121
133
|
path: '/ws',
|
|
122
134
|
},
|
|
@@ -154,19 +166,22 @@ while (true) {
|
|
|
154
166
|
|
|
155
167
|
### Stream Events
|
|
156
168
|
|
|
157
|
-
| Event Type | Description
|
|
158
|
-
| ----------------- |
|
|
159
|
-
| `start` | Stream started, includes message ID
|
|
160
|
-
| `text-start` | Text generation started
|
|
161
|
-
| `text-delta` | Text chunk received
|
|
162
|
-
| `text-end` | Text generation finished
|
|
163
|
-
| `tool-call-start` | Tool
|
|
164
|
-
| `tool-call-
|
|
165
|
-
| `tool-
|
|
166
|
-
| `
|
|
167
|
-
| `
|
|
168
|
-
| `
|
|
169
|
-
| `
|
|
169
|
+
| Event Type | Description |
|
|
170
|
+
| ----------------- | ---------------------------------------- |
|
|
171
|
+
| `start` | Stream started, includes message ID |
|
|
172
|
+
| `text-start` | Text generation started |
|
|
173
|
+
| `text-delta` | Text chunk received |
|
|
174
|
+
| `text-end` | Text generation finished |
|
|
175
|
+
| `tool-call-start` | Tool call started (`id` = model call id) |
|
|
176
|
+
| `tool-call-delta` | Tool call arguments (JSON text) |
|
|
177
|
+
| `tool-call-end` | Tool call finished |
|
|
178
|
+
| `tool-result` | Tool result (`toolCallId` = call id) |
|
|
179
|
+
| `workflow` | Workflow event (node started/completed) |
|
|
180
|
+
| `swarm` | Swarm event (agent started/completed) |
|
|
181
|
+
| `error` | Error occurred |
|
|
182
|
+
| `finish` | Stream finished, includes usage stats |
|
|
183
|
+
|
|
184
|
+
Text is emitted in `text-start`/`text-delta`/`text-end` blocks that are closed around tool calls; the stream ends with `data: [DONE]` after `finish`. Headers set by your hooks (CORS, rate-limit) are kept on SSE responses.
|
|
170
185
|
|
|
171
186
|
## WebSocket Support
|
|
172
187
|
|
|
@@ -202,8 +217,11 @@ ws.send(
|
|
|
202
217
|
})
|
|
203
218
|
);
|
|
204
219
|
|
|
205
|
-
//
|
|
206
|
-
ws.send(JSON.stringify({ type: 'subscribe', channel: '
|
|
220
|
+
// Observe runs of an agent started by other clients
|
|
221
|
+
ws.send(JSON.stringify({ type: 'subscribe', channel: 'agent:chat' }));
|
|
222
|
+
|
|
223
|
+
// Abort the running agent (emits { type: 'event', payload: { type: 'cancelled' } })
|
|
224
|
+
ws.send(JSON.stringify({ type: 'stop' }));
|
|
207
225
|
|
|
208
226
|
// Ping/pong
|
|
209
227
|
ws.send(JSON.stringify({ type: 'ping' }));
|
|
@@ -211,17 +229,19 @@ ws.send(JSON.stringify({ type: 'ping' }));
|
|
|
211
229
|
|
|
212
230
|
### WebSocket Message Types
|
|
213
231
|
|
|
214
|
-
| Type | Direction | Description
|
|
215
|
-
| ------------- | ------------- |
|
|
216
|
-
| `ping` | Client→Server | Heartbeat
|
|
217
|
-
| `pong` | Server→Client | Heartbeat response
|
|
218
|
-
| `subscribe` | Client→Server | Subscribe to
|
|
219
|
-
| `subscribed` | Server→Client | Subscription confirmed
|
|
220
|
-
| `unsubscribe` | Client→Server | Unsubscribe from channel
|
|
221
|
-
| `run` | Client→Server | Run agent
|
|
222
|
-
| `stop` | Client→Server |
|
|
223
|
-
| `event` | Server→Client |
|
|
224
|
-
| `error` | Server→Client | Error message
|
|
232
|
+
| Type | Direction | Description |
|
|
233
|
+
| ------------- | ------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
234
|
+
| `ping` | Client→Server | Heartbeat |
|
|
235
|
+
| `pong` | Server→Client | Heartbeat response |
|
|
236
|
+
| `subscribe` | Client→Server | Subscribe to `agent:<name>`: receive events of runs started by other clients |
|
|
237
|
+
| `subscribed` | Server→Client | Subscription confirmed |
|
|
238
|
+
| `unsubscribe` | Client→Server | Unsubscribe from channel |
|
|
239
|
+
| `run` | Client→Server | Run an agent (`payload: { type: 'agent', name, input, context?, threadId? }`); one run per connection at a time |
|
|
240
|
+
| `stop` | Client→Server | Abort the running agent |
|
|
241
|
+
| `event` | Server→Client | Run event: `token`, `tool-call`, `tool-result`, `complete`, `cancelled` |
|
|
242
|
+
| `error` | Server→Client | Error message |
|
|
243
|
+
|
|
244
|
+
Only agent runs are supported over WebSocket; use the HTTP endpoints for workflows and swarms.
|
|
225
245
|
|
|
226
246
|
## Custom Streaming
|
|
227
247
|
|
|
@@ -231,8 +251,9 @@ Use `FastifyStreamWriter` for custom streaming routes:
|
|
|
231
251
|
import { FastifyStreamWriter, generateId } from '@cogitator-ai/fastify';
|
|
232
252
|
|
|
233
253
|
fastify.post('/custom/stream', async (request, reply) => {
|
|
234
|
-
const writer = new FastifyStreamWriter(reply);
|
|
254
|
+
const writer = new FastifyStreamWriter(reply); // start() hijacks the reply
|
|
235
255
|
const messageId = generateId('msg');
|
|
256
|
+
reply.raw.on('close', () => writer.close());
|
|
236
257
|
|
|
237
258
|
writer.start(messageId);
|
|
238
259
|
const textId = generateId('txt');
|
|
@@ -245,6 +266,7 @@ fastify.post('/custom/stream', async (request, reply) => {
|
|
|
245
266
|
writer.textEnd(textId);
|
|
246
267
|
writer.finish(messageId);
|
|
247
268
|
writer.close();
|
|
269
|
+
return reply;
|
|
248
270
|
});
|
|
249
271
|
```
|
|
250
272
|
|
|
@@ -314,7 +336,8 @@ class FastifyStreamWriter {
|
|
|
314
336
|
swarmEvent(event: string, data: unknown): void;
|
|
315
337
|
error(message: string, code?: string): void;
|
|
316
338
|
finish(messageId: string, usage?: Usage): void;
|
|
317
|
-
close(): void;
|
|
339
|
+
close(): void; // no-op before start(); ignores writes after the response ended
|
|
340
|
+
readonly isClosed: boolean;
|
|
318
341
|
}
|
|
319
342
|
```
|
|
320
343
|
|
|
@@ -350,14 +373,17 @@ All endpoints return consistent error responses:
|
|
|
350
373
|
|
|
351
374
|
Error codes map to HTTP status codes:
|
|
352
375
|
|
|
353
|
-
- `INVALID_INPUT` → 400
|
|
376
|
+
- `INVALID_INPUT` → 400 (schema validation and malformed JSON; `details` carries the validation errors)
|
|
354
377
|
- `UNAUTHORIZED` → 401
|
|
355
|
-
- `PERMISSION_DENIED` → 403
|
|
356
378
|
- `NOT_FOUND` → 404
|
|
379
|
+
- `PAYLOAD_TOO_LARGE` → 413
|
|
357
380
|
- `RATE_LIMIT_EXCEEDED` → 429
|
|
358
|
-
- `
|
|
359
|
-
- `
|
|
381
|
+
- `WORKFLOW_FAILED` → 500
|
|
382
|
+
- `INTERNAL` → 500 (details are logged, not returned)
|
|
360
383
|
- `UNIMPLEMENTED` → 501
|
|
384
|
+
- `UNAVAILABLE` → 503
|
|
385
|
+
|
|
386
|
+
`CogitatorError`s thrown by runs keep their code and its mapped status (for example `LLM_RATE_LIMITED` → 429).
|
|
361
387
|
|
|
362
388
|
## JSON Schema Validation
|
|
363
389
|
|
|
@@ -373,6 +399,8 @@ import {
|
|
|
373
399
|
} from '@cogitator-ai/fastify';
|
|
374
400
|
```
|
|
375
401
|
|
|
402
|
+
`AgentRunRequestSchema` and `SwarmRunRequestSchema` require a non-blank `input` (the swarm `timeout` must be greater than 0), `AddMessageRequestSchema` requires a non-empty `content` and a `user`/`assistant`/`system` role, and `WorkflowRunRequestSchema.options` only allows `maxConcurrency`/`maxIterations` (integers ≥ 1) and `checkpoint` (`additionalProperties: false`).
|
|
403
|
+
|
|
376
404
|
## License
|
|
377
405
|
|
|
378
406
|
MIT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/hooks/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/hooks/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAa1E,wBAAgB,YAAY,CAC1B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,YAAY,GAClB,IAAI,CA8CN"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { CogitatorError, ERROR_STATUS_CODES, ErrorCode } from '@cogitator-ai/types';
|
|
2
|
+
const CLIENT_ERROR_CODES = {
|
|
3
|
+
400: 'INVALID_INPUT',
|
|
4
|
+
401: 'UNAUTHORIZED',
|
|
5
|
+
403: 'FORBIDDEN',
|
|
6
|
+
404: 'NOT_FOUND',
|
|
7
|
+
413: 'PAYLOAD_TOO_LARGE',
|
|
8
|
+
415: 'UNSUPPORTED_MEDIA_TYPE',
|
|
9
|
+
429: 'RATE_LIMIT_EXCEEDED',
|
|
10
|
+
};
|
|
2
11
|
export function errorHandler(error, request, reply) {
|
|
3
12
|
if (reply.sent) {
|
|
4
13
|
return;
|
|
@@ -13,6 +22,26 @@ export function errorHandler(error, request, reply) {
|
|
|
13
22
|
});
|
|
14
23
|
return;
|
|
15
24
|
}
|
|
25
|
+
if (error.validation) {
|
|
26
|
+
reply.status(400).send({
|
|
27
|
+
error: {
|
|
28
|
+
message: error.message,
|
|
29
|
+
code: 'INVALID_INPUT',
|
|
30
|
+
details: error.validation,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const statusCode = error.statusCode;
|
|
36
|
+
if (typeof statusCode === 'number' && statusCode >= 400 && statusCode < 500) {
|
|
37
|
+
reply.status(statusCode).send({
|
|
38
|
+
error: {
|
|
39
|
+
message: error.message,
|
|
40
|
+
code: CLIENT_ERROR_CODES[statusCode] ?? error.code ?? 'BAD_REQUEST',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
16
45
|
request.log.error({ err: error }, 'unhandled error in cogitator plugin');
|
|
17
46
|
reply.status(500).send({
|
|
18
47
|
error: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/hooks/error-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEpF,MAAM,UAAU,YAAY,CAC1B,KAAmB,EACnB,OAAuB,EACvB,KAAmB;IAEnB,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IAED,IAAI,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,MAAM,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;QACzD,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;YAC5B,KAAK,EAAE;gBACL,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,IAAI,EAAE,KAAK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,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACrB,KAAK,EAAE;gBACL,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,KAAK,CAAC,UAAU;aAC1B;SACF,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;IACpC,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,IAAI,GAAG,IAAI,UAAU,GAAG,GAAG,EAAE,CAAC;QAC5E,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;YAC5B,KAAK,EAAE;gBACL,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,IAAI,EAAE,kBAAkB,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,aAAa;aACpE;SACF,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,qCAAqC,CAAC,CAAC;IAEzE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACrB,KAAK,EAAE;YACL,OAAO,EAAE,uBAAuB;YAChC,IAAI,EAAE,SAAS,CAAC,cAAc;SAC/B;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,SAAS,CAAC;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAoB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,SAAS,CAAC;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAoB,MAAM,YAAY,CAAC;AA0H3E,eAAO,MAAM,eAAe,4CAG1B,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fp from 'fastify-plugin';
|
|
2
2
|
import { createAuthHook, errorHandler } from './hooks/index.js';
|
|
3
3
|
import { healthRoutes, agentRoutes, threadRoutes, toolRoutes, workflowRoutes, swarmRoutes, } from './routes/index.js';
|
|
4
|
+
import { isModuleNotFound } from './routes/utils.js';
|
|
4
5
|
const cogitatorPluginImpl = async (fastify, opts) => {
|
|
5
6
|
const context = {
|
|
6
7
|
runtime: opts.cogitator,
|
|
@@ -14,6 +15,22 @@ const cogitatorPluginImpl = async (fastify, opts) => {
|
|
|
14
15
|
fastify.decorateRequest('cogitatorStartTime', 0);
|
|
15
16
|
const prefix = opts.prefix ?? '/cogitator';
|
|
16
17
|
await fastify.register(async (instance) => {
|
|
18
|
+
let websocketEnabled = false;
|
|
19
|
+
if (opts.enableWebSocket) {
|
|
20
|
+
try {
|
|
21
|
+
const websocketModule = await import('@fastify/websocket');
|
|
22
|
+
await instance.register(websocketModule.default);
|
|
23
|
+
websocketEnabled = true;
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
if (isModuleNotFound(err)) {
|
|
27
|
+
fastify.log.warn('@fastify/websocket not installed, skipping WebSocket support');
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
17
34
|
instance.addHook('onRequest', createAuthHook(opts.auth));
|
|
18
35
|
if (opts.rateLimit) {
|
|
19
36
|
try {
|
|
@@ -26,7 +43,7 @@ const cogitatorPluginImpl = async (fastify, opts) => {
|
|
|
26
43
|
});
|
|
27
44
|
}
|
|
28
45
|
catch (err) {
|
|
29
|
-
if (err
|
|
46
|
+
if (isModuleNotFound(err)) {
|
|
30
47
|
instance.log.warn('@fastify/rate-limit not installed, skipping rate limiting');
|
|
31
48
|
}
|
|
32
49
|
else {
|
|
@@ -66,7 +83,7 @@ const cogitatorPluginImpl = async (fastify, opts) => {
|
|
|
66
83
|
});
|
|
67
84
|
}
|
|
68
85
|
catch (err) {
|
|
69
|
-
if (err
|
|
86
|
+
if (isModuleNotFound(err)) {
|
|
70
87
|
fastify.log.warn('@fastify/swagger not installed, skipping Swagger UI');
|
|
71
88
|
}
|
|
72
89
|
else {
|
|
@@ -80,21 +97,9 @@ const cogitatorPluginImpl = async (fastify, opts) => {
|
|
|
80
97
|
await instance.register(toolRoutes);
|
|
81
98
|
await instance.register(workflowRoutes);
|
|
82
99
|
await instance.register(swarmRoutes);
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
await instance.register(websocketModule.default);
|
|
87
|
-
const { websocketRoutes } = await import('./websocket/handler.js');
|
|
88
|
-
await instance.register(websocketRoutes, { path: opts.websocket?.path });
|
|
89
|
-
}
|
|
90
|
-
catch (err) {
|
|
91
|
-
if (err.code === 'ERR_MODULE_NOT_FOUND') {
|
|
92
|
-
fastify.log.warn('@fastify/websocket not installed, skipping WebSocket support');
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
throw err;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
100
|
+
if (websocketEnabled) {
|
|
101
|
+
const { websocketRoutes } = await import('./websocket/handler.js');
|
|
102
|
+
await instance.register(websocketRoutes, { path: opts.websocket?.path });
|
|
98
103
|
}
|
|
99
104
|
}, { prefix });
|
|
100
105
|
};
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGhC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EACL,YAAY,EACZ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S,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAgBlD,eAAO,MAAM,WAAW,EAAE,kBA2IzB,CAAC"}
|
package/dist/routes/agents.js
CHANGED
|
@@ -1,40 +1,37 @@
|
|
|
1
1
|
import { AgentRunRequestSchema } from '../types.js';
|
|
2
2
|
import { FastifyStreamWriter, generateId } from '../streaming/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { onClientDisconnect, resolveError, sendError, sendRouteError } from './utils.js';
|
|
4
|
+
const paramsSchema = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: { name: { type: 'string' } },
|
|
7
|
+
required: ['name'],
|
|
8
|
+
};
|
|
4
9
|
export const agentRoutes = async (fastify) => {
|
|
10
|
+
const findAgent = (name) => Object.hasOwn(fastify.cogitator.agents, name) ? fastify.cogitator.agents[name] : undefined;
|
|
5
11
|
fastify.get('/agents', async () => {
|
|
6
12
|
const agentList = Object.entries(fastify.cogitator.agents).map(([name, agent]) => ({
|
|
7
13
|
name,
|
|
8
|
-
description: agent.config.
|
|
14
|
+
description: agent.config.description,
|
|
9
15
|
tools: agent.config.tools?.map((t) => t.name) || [],
|
|
10
16
|
}));
|
|
11
17
|
const response = { agents: agentList };
|
|
12
18
|
return response;
|
|
13
19
|
});
|
|
14
|
-
fastify.post('/agents/:name/run', {
|
|
15
|
-
schema: {
|
|
16
|
-
params: {
|
|
17
|
-
type: 'object',
|
|
18
|
-
properties: { name: { type: 'string' } },
|
|
19
|
-
required: ['name'],
|
|
20
|
-
},
|
|
21
|
-
body: AgentRunRequestSchema,
|
|
22
|
-
},
|
|
23
|
-
}, async (request, reply) => {
|
|
20
|
+
fastify.post('/agents/:name/run', { schema: { params: paramsSchema, body: AgentRunRequestSchema } }, async (request, reply) => {
|
|
24
21
|
const { name } = request.params;
|
|
25
|
-
const agent =
|
|
26
|
-
? fastify.cogitator.agents[name]
|
|
27
|
-
: undefined;
|
|
22
|
+
const agent = findAgent(name);
|
|
28
23
|
if (!agent) {
|
|
29
|
-
return reply
|
|
30
|
-
error: { message: `Agent '${name}' not found`, code: 'NOT_FOUND' },
|
|
31
|
-
});
|
|
24
|
+
return sendError(reply, 404, `Agent '${name}' not found`, 'NOT_FOUND');
|
|
32
25
|
}
|
|
26
|
+
const abortController = new AbortController();
|
|
27
|
+
onClientDisconnect(reply, () => abortController.abort());
|
|
33
28
|
try {
|
|
34
29
|
const result = await fastify.cogitator.runtime.run(agent, {
|
|
35
30
|
input: request.body.input,
|
|
36
31
|
context: request.body.context,
|
|
37
32
|
threadId: request.body.threadId,
|
|
33
|
+
userId: request.cogitatorAuth?.userId,
|
|
34
|
+
signal: abortController.signal,
|
|
38
35
|
});
|
|
39
36
|
const response = {
|
|
40
37
|
output: result.output,
|
|
@@ -49,64 +46,66 @@ export const agentRoutes = async (fastify) => {
|
|
|
49
46
|
return response;
|
|
50
47
|
}
|
|
51
48
|
catch (error) {
|
|
52
|
-
|
|
53
|
-
return reply.status(500).send({ error: { message: error.message, code: error.code } });
|
|
54
|
-
}
|
|
55
|
-
request.log.error({ err: error }, 'agent run error');
|
|
56
|
-
return reply
|
|
57
|
-
.status(500)
|
|
58
|
-
.send({ error: { message: 'Internal server error', code: 'INTERNAL' } });
|
|
49
|
+
return sendRouteError(request, reply, error, 'agent run error');
|
|
59
50
|
}
|
|
60
51
|
});
|
|
61
|
-
fastify.post('/agents/:name/stream', {
|
|
62
|
-
schema: {
|
|
63
|
-
params: {
|
|
64
|
-
type: 'object',
|
|
65
|
-
properties: { name: { type: 'string' } },
|
|
66
|
-
required: ['name'],
|
|
67
|
-
},
|
|
68
|
-
body: AgentRunRequestSchema,
|
|
69
|
-
},
|
|
70
|
-
}, async (request, reply) => {
|
|
52
|
+
fastify.post('/agents/:name/stream', { schema: { params: paramsSchema, body: AgentRunRequestSchema } }, async (request, reply) => {
|
|
71
53
|
const { name } = request.params;
|
|
72
|
-
const agent =
|
|
73
|
-
? fastify.cogitator.agents[name]
|
|
74
|
-
: undefined;
|
|
54
|
+
const agent = findAgent(name);
|
|
75
55
|
if (!agent) {
|
|
76
|
-
return reply
|
|
77
|
-
error: { message: `Agent '${name}' not found`, code: 'NOT_FOUND' },
|
|
78
|
-
});
|
|
56
|
+
return sendError(reply, 404, `Agent '${name}' not found`, 'NOT_FOUND');
|
|
79
57
|
}
|
|
80
58
|
const writer = new FastifyStreamWriter(reply);
|
|
81
59
|
const messageId = generateId('msg');
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
60
|
+
const abortController = new AbortController();
|
|
61
|
+
onClientDisconnect(reply, () => {
|
|
62
|
+
abortController.abort();
|
|
85
63
|
writer.close();
|
|
86
64
|
});
|
|
65
|
+
let textId = null;
|
|
66
|
+
let streamedText = false;
|
|
67
|
+
const writeText = (delta) => {
|
|
68
|
+
if (!delta)
|
|
69
|
+
return;
|
|
70
|
+
if (textId === null) {
|
|
71
|
+
textId = generateId('txt');
|
|
72
|
+
writer.textStart(textId);
|
|
73
|
+
}
|
|
74
|
+
writer.textDelta(textId, delta);
|
|
75
|
+
};
|
|
76
|
+
const endText = () => {
|
|
77
|
+
if (textId === null)
|
|
78
|
+
return;
|
|
79
|
+
writer.textEnd(textId);
|
|
80
|
+
textId = null;
|
|
81
|
+
};
|
|
87
82
|
try {
|
|
88
83
|
writer.start(messageId);
|
|
89
|
-
writer.textStart(textId);
|
|
90
|
-
textStarted = true;
|
|
91
84
|
const result = await fastify.cogitator.runtime.run(agent, {
|
|
92
85
|
input: request.body.input,
|
|
93
86
|
context: request.body.context,
|
|
94
87
|
threadId: request.body.threadId,
|
|
88
|
+
userId: request.cogitatorAuth?.userId,
|
|
89
|
+
signal: abortController.signal,
|
|
95
90
|
stream: true,
|
|
96
91
|
onToken: (token) => {
|
|
97
|
-
|
|
92
|
+
if (token)
|
|
93
|
+
streamedText = true;
|
|
94
|
+
writeText(token);
|
|
98
95
|
},
|
|
99
96
|
onToolCall: (toolCall) => {
|
|
100
|
-
|
|
101
|
-
writer.toolCallStart(
|
|
102
|
-
writer.
|
|
97
|
+
endText();
|
|
98
|
+
writer.toolCallStart(toolCall.id, toolCall.name);
|
|
99
|
+
writer.toolCallDelta(toolCall.id, JSON.stringify(toolCall.arguments));
|
|
100
|
+
writer.toolCallEnd(toolCall.id);
|
|
103
101
|
},
|
|
104
102
|
onToolResult: (toolResult) => {
|
|
105
|
-
|
|
106
|
-
writer.toolResult(resultId, toolResult.callId, toolResult.result);
|
|
103
|
+
writer.toolResult(generateId('res'), toolResult.callId, toolResult.result);
|
|
107
104
|
},
|
|
108
105
|
});
|
|
109
|
-
|
|
106
|
+
if (!streamedText)
|
|
107
|
+
writeText(result.output);
|
|
108
|
+
endText();
|
|
110
109
|
writer.finish(messageId, {
|
|
111
110
|
inputTokens: result.usage.inputTokens,
|
|
112
111
|
outputTokens: result.usage.outputTokens,
|
|
@@ -114,19 +113,16 @@ export const agentRoutes = async (fastify) => {
|
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
115
|
catch (error) {
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
writer.error(
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
request.log.error({ err: error }, 'agent stream error');
|
|
124
|
-
writer.error('Internal server error', 'INTERNAL');
|
|
116
|
+
if (!abortController.signal.aborted) {
|
|
117
|
+
const resolved = resolveError(request, error, 'agent stream error');
|
|
118
|
+
endText();
|
|
119
|
+
writer.error(resolved.message, resolved.code);
|
|
125
120
|
}
|
|
126
121
|
}
|
|
127
122
|
finally {
|
|
128
123
|
writer.close();
|
|
129
124
|
}
|
|
125
|
+
return reply;
|
|
130
126
|
});
|
|
131
127
|
};
|
|
132
128
|
//# sourceMappingURL=agents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/routes/agents.ts"],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AA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"swarms.d.ts","sourceRoot":"","sources":["../../src/routes/swarms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA8BlD,eAAO,MAAM,WAAW,EAAE,kBAgMzB,CAAC"}
|