@cogitator-ai/express 0.7.10 → 0.8.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 +11 -3
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/json-body.d.ts +8 -0
- package/dist/middleware/json-body.d.ts.map +1 -0
- package/dist/middleware/json-body.js +17 -0
- package/dist/middleware/json-body.js.map +1 -0
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/agents.js +15 -72
- package/dist/routes/agents.js.map +1 -1
- package/dist/routes/swarms.d.ts.map +1 -1
- package/dist/routes/swarms.js +81 -86
- package/dist/routes/swarms.js.map +1 -1
- package/dist/routes/threads.d.ts.map +1 -1
- package/dist/routes/threads.js +6 -17
- package/dist/routes/threads.js.map +1 -1
- package/dist/routes/utils.d.ts +1 -16
- package/dist/routes/utils.d.ts.map +1 -1
- package/dist/routes/utils.js +1 -99
- package/dist/routes/utils.js.map +1 -1
- package/dist/routes/workflows.js +4 -3
- package/dist/routes/workflows.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -3
- package/dist/server.js.map +1 -1
- package/dist/streaming/express-stream-writer.d.ts +4 -2
- package/dist/streaming/express-stream-writer.d.ts.map +1 -1
- package/dist/streaming/express-stream-writer.js +11 -6
- package/dist/streaming/express-stream-writer.js.map +1 -1
- package/dist/types.d.ts +14 -19
- package/dist/types.d.ts.map +1 -1
- package/dist/websocket/ws-handler.d.ts.map +1 -1
- package/dist/websocket/ws-handler.js +13 -21
- package/dist/websocket/ws-handler.js.map +1 -1
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -60,6 +60,12 @@ POST /api/agents/:name/resume - Resume a run paused for tool approvals
|
|
|
60
60
|
|
|
61
61
|
Run/stream body: `{ input: string; context?: object; threadId?: string }`. `input` must contain more than whitespace and `threadId`, when sent, must be a non-empty string (`400 INVALID_INPUT` otherwise, before the model is called). The validator comes from `@cogitator-ai/server-shared`, so Express, Fastify, Hono and Koa refuse exactly the same bodies. The `usage` of a run answer carries `inputTokens`, `outputTokens` and `totalTokens`, plus `reasoningTokens`, `cachedInputTokens` and `cacheWriteTokens` when the model reported them, the same shape as every other adapter. The `finish` event of an agent stream carries the same `usage` (never the run's cost or duration). The agent list exposes `config.description`, never the agent instructions. The authenticated `userId` (from `auth`) is passed to the run, and the run is aborted when the client disconnects.
|
|
62
62
|
|
|
63
|
+
- A run puts `context` into the system prompt, and the model reads a `system` thread message as operator instructions, so clients may set neither unless the server allows it: `acceptContext` lists the `context` keys clients may send (`true` accepts any key, for clients trusted like your own code), and `threadMessageRoles` the roles of `POST /threads/:id/messages` (`user` and `assistant` by default). Anything else is refused with `400 INVALID_INPUT`, over HTTP and WebSocket alike.
|
|
64
|
+
- A `POST` body that is not JSON (`text/plain`, a form) is refused with `415 UNSUPPORTED_MEDIA_TYPE` before it is parsed: browsers send those across origins without a CORS preflight.
|
|
65
|
+
- `POST /agents/:name/run` and `/resume` answer `toAgentRunResponse()` of `@cogitator-ai/server-shared`: `output`, `threadId`, `usage`, `toolCalls` (`{ id, name, arguments }`), `status` and `traceId`, plus `reasoning`, `pendingApprovals`, `structured`, `structuredError`, `truncated`, `blocked` and `iterationLimitReached` when they apply. The WebSocket `complete` event carries the same object, never the system prompt, the history, trace spans or a paused run's checkpoint.
|
|
66
|
+
- The `start` event of an agent stream names the run's thread (the request's `threadId`, or a new one), and `finish` repeats it with the run's outcome, so a client that sent no thread continues the conversation with this one.
|
|
67
|
+
- Swarm routes close each swarm they build once its run ends, so a distributed swarm leaves no Redis connections behind and its state expires. `GET /swarms` lists every agent, the router and pipeline stages included.
|
|
68
|
+
|
|
63
69
|
### Threads (Memory)
|
|
64
70
|
|
|
65
71
|
```
|
|
@@ -68,7 +74,7 @@ POST /api/threads/:id/messages - Add message to thread
|
|
|
68
74
|
DELETE /api/threads/:id - Delete thread
|
|
69
75
|
```
|
|
70
76
|
|
|
71
|
-
The routes use `cogitator.getMemory()`, which connects the configured memory adapter on first use, so threads can be read on a fresh server before any agent has run. Only a `Cogitator` without `memory` configured answers `503 UNAVAILABLE`. New messages need `role` (`user`
|
|
77
|
+
The routes use `cogitator.getMemory()`, which connects the configured memory adapter on first use, so threads can be read on a fresh server before any agent has run. Only a `Cogitator` without `memory` configured answers `503 UNAVAILABLE`. New messages need `role` (`user` or `assistant`, more with `threadMessageRoles`) and a non-empty string `content`, optional `metadata` is stored on the memory entry.
|
|
72
78
|
|
|
73
79
|
### Workflows
|
|
74
80
|
|
|
@@ -78,7 +84,7 @@ POST /api/workflows/:name/run - Run workflow
|
|
|
78
84
|
POST /api/workflows/:name/stream - Stream workflow events
|
|
79
85
|
```
|
|
80
86
|
|
|
81
|
-
Body: `{ input?: object; options?: { maxConcurrency?: number; maxIterations?: number
|
|
87
|
+
Body: `{ input?: object; options?: { maxConcurrency?: number; maxIterations?: number } }`. `maxConcurrency`/`maxIterations` must be positive integers (400 otherwise). Other options are dropped, and `checkpoint: true` is refused, since the server keeps no checkpoint store to resume from. A failed workflow returns `500` with code `WORKFLOW_FAILED` (the stream ends with an `error` event instead of `workflow_completed`). Disconnecting aborts the workflow.
|
|
82
88
|
|
|
83
89
|
The stream sends `{ type: 'workflow', event, data }` events: `node_started`, `node_completed`, `node_error`, `node_progress` and finally `workflow_completed`.
|
|
84
90
|
|
|
@@ -91,7 +97,7 @@ POST /api/swarms/:name/stream - Stream swarm events
|
|
|
91
97
|
GET /api/swarms/:name/blackboard - Get configured blackboard sections
|
|
92
98
|
```
|
|
93
99
|
|
|
94
|
-
Run/stream body: `{ input: string; context?: object; threadId?: string; timeout?: number }` (`timeout` must be positive). Disconnecting aborts the swarm. The stream sends `{ type: 'swarm', event, data }` events (`agent_start`, `agent_complete`, `agent_error`, `message`, the swarm's own events, and finally `swarm_completed` with the output and usage). Each run creates a fresh swarm, so the blackboard endpoint returns the configured initial sections.
|
|
100
|
+
Run/stream body: `{ input: string; context?: object; threadId?: string; timeout?: number }` (`timeout` must be positive, at most `2147483647` ms). Disconnecting aborts the swarm. The stream sends `{ type: 'swarm', event, data }` events (`agent_start`, `agent_complete`, `agent_error`, `message`, the swarm's own events, and finally `swarm_completed` with the output and usage). Each run creates a fresh swarm, so the blackboard endpoint returns the configured initial sections.
|
|
95
101
|
|
|
96
102
|
### Tools & Docs
|
|
97
103
|
|
|
@@ -378,6 +384,8 @@ interface CogitatorServerConfig {
|
|
|
378
384
|
swagger?: SwaggerConfig;
|
|
379
385
|
websocket?: WebSocketConfig;
|
|
380
386
|
sseHeartbeatMs?: number; // Default: 5000, 0 turns SSE heartbeats off
|
|
387
|
+
acceptContext?: boolean | string[]; // context keys clients may send: none by default, a list, or true for any
|
|
388
|
+
threadMessageRoles?: ('user' | 'assistant' | 'system')[]; // roles of POST /threads/:id/messages, default user and assistant
|
|
381
389
|
};
|
|
382
390
|
}
|
|
383
391
|
```
|
|
@@ -2,4 +2,5 @@ export { createAuthMiddleware } from './auth.js';
|
|
|
2
2
|
export { createRateLimitMiddleware } from './rate-limit.js';
|
|
3
3
|
export { createCorsMiddleware } from './cors.js';
|
|
4
4
|
export { errorHandler, notFoundHandler } from './error-handler.js';
|
|
5
|
+
export { createJsonBodyGuard } from './json-body.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/middleware/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { createAuthMiddleware } from './auth.js';
|
|
|
2
2
|
export { createRateLimitMiddleware } from './rate-limit.js';
|
|
3
3
|
export { createCorsMiddleware } from './cors.js';
|
|
4
4
|
export { errorHandler, notFoundHandler } from './error-handler.js';
|
|
5
|
+
export { createJsonBodyGuard } from './json-body.js';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RequestHandler } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Refuses a request whose body is not JSON with `415 UNSUPPORTED_MEDIA_TYPE` before any
|
|
4
|
+
* route reads it. Browsers send `text/plain` and form bodies across origins without a
|
|
5
|
+
* preflight, so the API only takes the JSON a cross-origin page cannot send unasked.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createJsonBodyGuard(): RequestHandler;
|
|
8
|
+
//# sourceMappingURL=json-body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-body.d.ts","sourceRoot":"","sources":["../../src/middleware/json-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,cAAc,CASpD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { refuseNonJsonBody } from '@cogitator-ai/server-shared';
|
|
2
|
+
/**
|
|
3
|
+
* Refuses a request whose body is not JSON with `415 UNSUPPORTED_MEDIA_TYPE` before any
|
|
4
|
+
* route reads it. Browsers send `text/plain` and form bodies across origins without a
|
|
5
|
+
* preflight, so the API only takes the JSON a cross-origin page cannot send unasked.
|
|
6
|
+
*/
|
|
7
|
+
export function createJsonBodyGuard() {
|
|
8
|
+
return (req, res, next) => {
|
|
9
|
+
const refusal = refuseNonJsonBody(req.method, req.headers);
|
|
10
|
+
if (!refusal) {
|
|
11
|
+
next();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
res.status(refusal.status).json({ error: { message: refusal.message, code: refusal.code } });
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=json-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-body.js","sourceRoot":"","sources":["../../src/middleware/json-body.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACxB,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,EAAE,CAAC;YACP,OAAO;QACT,CAAC;QACD,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC/F,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAuC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAuC,MAAM,aAAa,CAAC;AAUrF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAmJ3D"}
|
package/dist/routes/agents.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
import { parseRunRequest } from '@cogitator-ai/server-shared';
|
|
3
|
-
import { ExpressStreamWriter, setupSSEHeaders
|
|
4
|
-
import { handleRouteError, onClientDisconnect,
|
|
2
|
+
import { AgentStreamSession, parseResumeRequest, parseRunRequest, toAgentRunResponse, } from '@cogitator-ai/server-shared';
|
|
3
|
+
import { ExpressStreamWriter, setupSSEHeaders } from '../streaming/index.js';
|
|
4
|
+
import { handleRouteError, onClientDisconnect, resolveError, sendError } from './utils.js';
|
|
5
5
|
export function createAgentRoutes(ctx) {
|
|
6
6
|
const router = Router();
|
|
7
|
+
const runRequestOptions = { acceptContext: ctx.config.acceptContext };
|
|
7
8
|
const findAgent = (name) => Object.hasOwn(ctx.agents, name) ? ctx.agents[name] : undefined;
|
|
8
9
|
router.get('/agents', (_req, res) => {
|
|
9
10
|
const agentList = Object.entries(ctx.agents).map(([name, agent]) => ({
|
|
@@ -21,7 +22,7 @@ export function createAgentRoutes(ctx) {
|
|
|
21
22
|
sendError(res, 404, `Agent '${name}' not found`, 'NOT_FOUND');
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
|
-
const parsed = parseRunRequest(req.body);
|
|
25
|
+
const parsed = parseRunRequest(req.body, runRequestOptions);
|
|
25
26
|
if (!parsed.ok) {
|
|
26
27
|
sendError(res, 400, parsed.message, 'INVALID_INPUT');
|
|
27
28
|
return;
|
|
@@ -52,7 +53,7 @@ export function createAgentRoutes(ctx) {
|
|
|
52
53
|
sendError(res, 404, `Agent '${name}' not found`, 'NOT_FOUND');
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
|
-
const parsed =
|
|
56
|
+
const parsed = parseResumeRequest(req.body);
|
|
56
57
|
if (!parsed.ok) {
|
|
57
58
|
sendError(res, 400, parsed.message, 'INVALID_INPUT');
|
|
58
59
|
return;
|
|
@@ -82,7 +83,7 @@ export function createAgentRoutes(ctx) {
|
|
|
82
83
|
sendError(res, 404, `Agent '${name}' not found`, 'NOT_FOUND');
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
85
|
-
const parsed = parseRunRequest(req.body);
|
|
86
|
+
const parsed = parseRunRequest(req.body, runRequestOptions);
|
|
86
87
|
if (!parsed.ok) {
|
|
87
88
|
sendError(res, 400, parsed.message, 'INVALID_INPUT');
|
|
88
89
|
return;
|
|
@@ -90,89 +91,31 @@ export function createAgentRoutes(ctx) {
|
|
|
90
91
|
const body = parsed.value;
|
|
91
92
|
setupSSEHeaders(res);
|
|
92
93
|
const writer = new ExpressStreamWriter(res, { heartbeatMs: ctx.config.sseHeartbeatMs });
|
|
93
|
-
const
|
|
94
|
+
const session = new AgentStreamSession((event) => writer.send(event), {
|
|
95
|
+
threadId: body.threadId,
|
|
96
|
+
});
|
|
94
97
|
const abortController = new AbortController();
|
|
95
98
|
onClientDisconnect(res, () => {
|
|
96
99
|
abortController.abort();
|
|
97
100
|
writer.close();
|
|
98
101
|
});
|
|
99
|
-
let textId = null;
|
|
100
|
-
let reasoningId = null;
|
|
101
|
-
let streamedText = false;
|
|
102
|
-
const endText = () => {
|
|
103
|
-
if (textId === null)
|
|
104
|
-
return;
|
|
105
|
-
writer.textEnd(textId);
|
|
106
|
-
textId = null;
|
|
107
|
-
};
|
|
108
|
-
const endReasoning = () => {
|
|
109
|
-
if (reasoningId === null)
|
|
110
|
-
return;
|
|
111
|
-
writer.reasoningEnd(reasoningId);
|
|
112
|
-
reasoningId = null;
|
|
113
|
-
};
|
|
114
|
-
const endParts = () => {
|
|
115
|
-
endReasoning();
|
|
116
|
-
endText();
|
|
117
|
-
};
|
|
118
|
-
const writeText = (delta) => {
|
|
119
|
-
if (!delta)
|
|
120
|
-
return;
|
|
121
|
-
if (textId === null) {
|
|
122
|
-
endReasoning();
|
|
123
|
-
textId = generateId('txt');
|
|
124
|
-
writer.textStart(textId);
|
|
125
|
-
}
|
|
126
|
-
writer.textDelta(textId, delta);
|
|
127
|
-
};
|
|
128
|
-
const writeReasoning = (delta) => {
|
|
129
|
-
if (!delta)
|
|
130
|
-
return;
|
|
131
|
-
if (reasoningId === null) {
|
|
132
|
-
endText();
|
|
133
|
-
reasoningId = generateId('rsn');
|
|
134
|
-
writer.reasoningStart(reasoningId);
|
|
135
|
-
}
|
|
136
|
-
writer.reasoningDelta(reasoningId, delta);
|
|
137
|
-
};
|
|
138
102
|
try {
|
|
139
|
-
|
|
103
|
+
session.start();
|
|
140
104
|
const result = await ctx.cogitator.run(agent, {
|
|
141
105
|
input: body.input,
|
|
142
106
|
context: body.context,
|
|
143
|
-
threadId:
|
|
107
|
+
threadId: session.threadId,
|
|
144
108
|
userId: req.cogitator?.auth?.userId,
|
|
145
109
|
signal: abortController.signal,
|
|
146
110
|
stream: true,
|
|
147
|
-
|
|
148
|
-
if (token)
|
|
149
|
-
streamedText = true;
|
|
150
|
-
writeText(token);
|
|
151
|
-
},
|
|
152
|
-
onReasoning: writeReasoning,
|
|
153
|
-
onToolCall: (toolCall) => {
|
|
154
|
-
endParts();
|
|
155
|
-
writer.toolCallStart(toolCall.id, toolCall.name);
|
|
156
|
-
writer.toolCallDelta(toolCall.id, JSON.stringify(toolCall.arguments));
|
|
157
|
-
writer.toolCallEnd(toolCall.id);
|
|
158
|
-
},
|
|
159
|
-
onToolResult: (toolResult) => {
|
|
160
|
-
writer.toolResult(generateId('res'), toolResult.callId, toolResult.result);
|
|
161
|
-
},
|
|
111
|
+
...session.callbacks,
|
|
162
112
|
});
|
|
163
|
-
|
|
164
|
-
writeText(result.output);
|
|
165
|
-
endParts();
|
|
166
|
-
if (result.status === 'paused' && result.pendingApprovals) {
|
|
167
|
-
writer.approvalRequired(result.threadId, result.pendingApprovals);
|
|
168
|
-
}
|
|
169
|
-
writer.finish(messageId, result.usage);
|
|
113
|
+
session.complete(result);
|
|
170
114
|
}
|
|
171
115
|
catch (error) {
|
|
172
116
|
if (!abortController.signal.aborted) {
|
|
173
117
|
const resolved = resolveError(error, 'Agent stream error');
|
|
174
|
-
|
|
175
|
-
writer.error(resolved.message, resolved.code);
|
|
118
|
+
session.fail(resolved.message, resolved.code);
|
|
176
119
|
}
|
|
177
120
|
}
|
|
178
121
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,aAAa,CAAC;AAcrB,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"swarms.d.ts","sourceRoot":"","sources":["../../src/routes/swarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,aAAa,CAAC;AAcrB,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CA2N3D"}
|
package/dist/routes/swarms.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
import { parseSwarmRunRequest } from '@cogitator-ai/server-shared';
|
|
2
|
+
import { parseSwarmRunRequest, swarmAgentNames, withSwarm } from '@cogitator-ai/server-shared';
|
|
3
3
|
import { ExpressStreamWriter, setupSSEHeaders, generateId } from '../streaming/index.js';
|
|
4
4
|
import { handleRouteError, isModuleNotFound, onClientDisconnect, resolveError, sendError, } from './utils.js';
|
|
5
5
|
const SWARMS_MISSING = 'Swarms package not installed';
|
|
6
6
|
export function createSwarmRoutes(ctx) {
|
|
7
7
|
const router = Router();
|
|
8
|
+
const runRequestOptions = { acceptContext: ctx.config.acceptContext };
|
|
8
9
|
const findSwarm = (name) => Object.hasOwn(ctx.swarms, name) ? ctx.swarms[name] : undefined;
|
|
9
10
|
router.get('/swarms', (_req, res) => {
|
|
10
11
|
const swarmList = Object.entries(ctx.swarms).map(([name, config]) => {
|
|
11
|
-
const agents =
|
|
12
|
-
if (config.supervisor)
|
|
13
|
-
agents.push(config.supervisor.name);
|
|
14
|
-
if (config.workers)
|
|
15
|
-
agents.push(...config.workers.map((w) => w.name));
|
|
16
|
-
if (config.agents)
|
|
17
|
-
agents.push(...config.agents.map((a) => a.name));
|
|
18
|
-
if (config.moderator)
|
|
19
|
-
agents.push(config.moderator.name);
|
|
12
|
+
const agents = swarmAgentNames(config);
|
|
20
13
|
return {
|
|
21
14
|
name,
|
|
22
15
|
strategy: config.strategy,
|
|
@@ -33,7 +26,7 @@ export function createSwarmRoutes(ctx) {
|
|
|
33
26
|
sendError(res, 404, `Swarm '${name}' not found`, 'NOT_FOUND');
|
|
34
27
|
return;
|
|
35
28
|
}
|
|
36
|
-
const parsed = parseSwarmRunRequest(req.body);
|
|
29
|
+
const parsed = parseSwarmRunRequest(req.body, runRequestOptions);
|
|
37
30
|
if (!parsed.ok) {
|
|
38
31
|
sendError(res, 400, parsed.message, 'INVALID_INPUT');
|
|
39
32
|
return;
|
|
@@ -47,39 +40,40 @@ export function createSwarmRoutes(ctx) {
|
|
|
47
40
|
});
|
|
48
41
|
try {
|
|
49
42
|
const { Swarm } = await import('@cogitator-ai/swarms');
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
43
|
+
const response = await withSwarm(new Swarm(ctx.cogitator, swarmConfig), async (swarm) => {
|
|
44
|
+
abortSwarm = () => swarm.abort();
|
|
45
|
+
if (disconnected)
|
|
46
|
+
swarm.abort();
|
|
47
|
+
const result = await swarm.run({
|
|
48
|
+
input: body.input,
|
|
49
|
+
context: body.context,
|
|
50
|
+
threadId: body.threadId,
|
|
51
|
+
userId: req.cogitator?.auth?.userId,
|
|
52
|
+
timeout: body.timeout,
|
|
53
|
+
});
|
|
54
|
+
const agentResults = {};
|
|
55
|
+
for (const [agentName, agentResult] of result.agentResults.entries()) {
|
|
56
|
+
agentResults[agentName] = {
|
|
57
|
+
output: agentResult.output,
|
|
58
|
+
usage: agentResult.usage,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const resourceUsage = swarm.getResourceUsage();
|
|
62
|
+
return {
|
|
63
|
+
swarmId: swarm.id,
|
|
64
|
+
swarmName: swarm.name,
|
|
65
|
+
strategy: swarm.strategyType,
|
|
66
|
+
output: result.output,
|
|
67
|
+
agentResults,
|
|
68
|
+
usage: {
|
|
69
|
+
totalTokens: resourceUsage.totalTokens,
|
|
70
|
+
totalCost: resourceUsage.totalCost,
|
|
71
|
+
elapsedTime: resourceUsage.elapsedTime,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
60
74
|
});
|
|
61
75
|
if (disconnected)
|
|
62
76
|
return;
|
|
63
|
-
const agentResults = {};
|
|
64
|
-
for (const [agentName, agentResult] of result.agentResults.entries()) {
|
|
65
|
-
agentResults[agentName] = {
|
|
66
|
-
output: agentResult.output,
|
|
67
|
-
usage: agentResult.usage,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
const resourceUsage = swarm.getResourceUsage();
|
|
71
|
-
const response = {
|
|
72
|
-
swarmId: swarm.id,
|
|
73
|
-
swarmName: swarm.name,
|
|
74
|
-
strategy: swarm.strategyType,
|
|
75
|
-
output: result.output,
|
|
76
|
-
agentResults,
|
|
77
|
-
usage: {
|
|
78
|
-
totalTokens: resourceUsage.totalTokens,
|
|
79
|
-
totalCost: resourceUsage.totalCost,
|
|
80
|
-
elapsedTime: resourceUsage.elapsedTime,
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
77
|
res.json(response);
|
|
84
78
|
}
|
|
85
79
|
catch (error) {
|
|
@@ -99,7 +93,7 @@ export function createSwarmRoutes(ctx) {
|
|
|
99
93
|
sendError(res, 404, `Swarm '${name}' not found`, 'NOT_FOUND');
|
|
100
94
|
return;
|
|
101
95
|
}
|
|
102
|
-
const parsed = parseSwarmRunRequest(req.body);
|
|
96
|
+
const parsed = parseSwarmRunRequest(req.body, runRequestOptions);
|
|
103
97
|
if (!parsed.ok) {
|
|
104
98
|
sendError(res, 400, parsed.message, 'INVALID_INPUT');
|
|
105
99
|
return;
|
|
@@ -117,51 +111,52 @@ export function createSwarmRoutes(ctx) {
|
|
|
117
111
|
});
|
|
118
112
|
try {
|
|
119
113
|
const { Swarm } = await import('@cogitator-ai/swarms');
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
114
|
+
await withSwarm(new Swarm(ctx.cogitator, swarmConfig), async (swarm) => {
|
|
115
|
+
abortSwarm = () => swarm.abort();
|
|
116
|
+
if (disconnected)
|
|
117
|
+
swarm.abort();
|
|
118
|
+
writer.start(messageId);
|
|
119
|
+
const result = await swarm.run({
|
|
120
|
+
input: body.input,
|
|
121
|
+
context: body.context,
|
|
122
|
+
threadId: body.threadId,
|
|
123
|
+
userId: req.cogitator?.auth?.userId,
|
|
124
|
+
timeout: body.timeout,
|
|
125
|
+
onAgentStart: (agentName) => {
|
|
126
|
+
writer.swarmEvent('agent_start', { agentName, timestamp: Date.now() });
|
|
127
|
+
},
|
|
128
|
+
onAgentComplete: (agentName, agentResult) => {
|
|
129
|
+
writer.swarmEvent('agent_complete', {
|
|
130
|
+
agentName,
|
|
131
|
+
output: agentResult.output,
|
|
132
|
+
timestamp: Date.now(),
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
onAgentError: (agentName, error) => {
|
|
136
|
+
writer.swarmEvent('agent_error', {
|
|
137
|
+
agentName,
|
|
138
|
+
error: resolveError(error, `Swarm agent ${agentName}`).message,
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
onMessage: (message) => {
|
|
142
|
+
writer.swarmEvent('message', message);
|
|
143
|
+
},
|
|
144
|
+
onEvent: (event) => {
|
|
145
|
+
writer.swarmEvent(event.type, event.data);
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
const resourceUsage = swarm.getResourceUsage();
|
|
149
|
+
writer.swarmEvent('swarm_completed', {
|
|
150
|
+
swarmId: swarm.id,
|
|
151
|
+
output: result.output,
|
|
152
|
+
usage: {
|
|
153
|
+
totalTokens: resourceUsage.totalTokens,
|
|
154
|
+
totalCost: resourceUsage.totalCost,
|
|
155
|
+
elapsedTime: resourceUsage.elapsedTime,
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
writer.finish(messageId);
|
|
163
159
|
});
|
|
164
|
-
writer.finish(messageId);
|
|
165
160
|
}
|
|
166
161
|
catch (error) {
|
|
167
162
|
if (isModuleNotFound(error)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarms.js","sourceRoot":"","sources":["../../src/routes/swarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AASjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"swarms.js","sourceRoot":"","sources":["../../src/routes/swarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AASjC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEzF,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,SAAS,GACV,MAAM,YAAY,CAA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;YACrC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,uCAAuC,EAAE,eAAe,CAAC,CAAC;YAC9E,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,GAAuB;YACnC,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,QAAQ,IAAI,EAAE;SAChD,CAAC;QAEF,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../src/routes/threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../src/routes/threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIjC,OAAO,KAAK,EAAE,YAAY,EAAoC,MAAM,aAAa,CAAC;AAGlF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CA2G5D"}
|
package/dist/routes/threads.js
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { assertThreadAccess, ensureThreadAccess } from '@cogitator-ai/core';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
function parseMessageBody(body) {
|
|
6
|
-
if (!isPlainObject(body))
|
|
7
|
-
return null;
|
|
8
|
-
const { role, content, metadata } = body;
|
|
9
|
-
if (typeof role !== 'string' || !MESSAGE_ROLES.has(role))
|
|
10
|
-
return null;
|
|
11
|
-
if (typeof content !== 'string' || content === '')
|
|
12
|
-
return null;
|
|
13
|
-
if (metadata !== undefined && !isPlainObject(metadata))
|
|
14
|
-
return null;
|
|
15
|
-
return { role: role, content, metadata };
|
|
16
|
-
}
|
|
3
|
+
import { parseAddMessageRequest } from '@cogitator-ai/server-shared';
|
|
4
|
+
import { handleRouteError, sendError } from './utils.js';
|
|
17
5
|
export function createThreadRoutes(ctx) {
|
|
18
6
|
const router = Router();
|
|
19
7
|
const getMemory = () => ctx.cogitator.getMemory();
|
|
@@ -55,11 +43,12 @@ export function createThreadRoutes(ctx) {
|
|
|
55
43
|
return;
|
|
56
44
|
}
|
|
57
45
|
const { id } = req.params;
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
60
|
-
sendError(res, 400,
|
|
46
|
+
const parsed = parseAddMessageRequest(req.body, { roles: ctx.config.threadMessageRoles });
|
|
47
|
+
if (!parsed.ok) {
|
|
48
|
+
sendError(res, 400, parsed.message, 'INVALID_INPUT');
|
|
61
49
|
return;
|
|
62
50
|
}
|
|
51
|
+
const body = parsed.value;
|
|
63
52
|
const userId = req.cogitator?.auth?.userId;
|
|
64
53
|
try {
|
|
65
54
|
await ensureThreadAccess(memory, id, { agentId: '', userId });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../src/routes/threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../src/routes/threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,UAAU,kBAAkB,CAAC,GAAiB;IAClD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IAExB,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,GAAG,C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