@cogitator-ai/koa 0.5.1 → 0.5.2
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 +56 -14
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +1 -1
- package/dist/app.js.map +1 -1
- package/dist/swagger/index.d.ts.map +1 -1
- package/dist/swagger/index.js +12 -4
- package/dist/swagger/index.js.map +1 -1
- package/dist/utils/errors.js +2 -2
- package/dist/utils/errors.js.map +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -15,8 +15,14 @@ import Koa from 'koa';
|
|
|
15
15
|
import { Cogitator, Agent } from '@cogitator-ai/core';
|
|
16
16
|
import { cogitatorApp } from '@cogitator-ai/koa';
|
|
17
17
|
|
|
18
|
-
const cogitator = new Cogitator({
|
|
19
|
-
|
|
18
|
+
const cogitator = new Cogitator({
|
|
19
|
+
llm: { providers: { openai: { apiKey: process.env.OPENAI_API_KEY! } } },
|
|
20
|
+
});
|
|
21
|
+
const chatAgent = new Agent({
|
|
22
|
+
name: 'chat',
|
|
23
|
+
model: 'openai/gpt-5.5',
|
|
24
|
+
instructions: 'You are a helpful assistant.',
|
|
25
|
+
});
|
|
20
26
|
|
|
21
27
|
const app = new Koa();
|
|
22
28
|
|
|
@@ -39,16 +45,16 @@ Creates a Koa Router with all Cogitator endpoints.
|
|
|
39
45
|
|
|
40
46
|
**Options:**
|
|
41
47
|
|
|
42
|
-
| Option | Type
|
|
43
|
-
| --------------- |
|
|
44
|
-
| `cogitator` | `Cogitator`
|
|
45
|
-
| `agents` | `Record<string, Agent>`
|
|
46
|
-
| `workflows` | `Record<string, Workflow>`
|
|
47
|
-
| `swarms` | `Record<string, SwarmConfig>`
|
|
48
|
-
| `auth` | `(ctx
|
|
49
|
-
| `enableSwagger` | `boolean`
|
|
50
|
-
| `swagger` | `SwaggerConfig`
|
|
51
|
-
| `bodyLimit` | `number`
|
|
48
|
+
| Option | Type | Description |
|
|
49
|
+
| --------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `cogitator` | `Cogitator` | **Required.** Cogitator runtime instance |
|
|
51
|
+
| `agents` | `Record<string, Agent>` | Named agents to expose |
|
|
52
|
+
| `workflows` | `Record<string, Workflow>` | Named workflows |
|
|
53
|
+
| `swarms` | `Record<string, SwarmConfig>` | Named swarms |
|
|
54
|
+
| `auth` | `AuthFunction` | `(ctx) => AuthContext \| undefined` (sync or async), receives the Koa Context; throw to answer `401 UNAUTHORIZED` |
|
|
55
|
+
| `enableSwagger` | `boolean` | Serve `/openapi.json` and Swagger UI at `/docs` |
|
|
56
|
+
| `swagger` | `SwaggerConfig` | Swagger configuration |
|
|
57
|
+
| `bodyLimit` | `number` | Max JSON body size in bytes (default 1 MiB) |
|
|
52
58
|
|
|
53
59
|
WebSocket support is attached to the HTTP server with [`setupWebSocket`](#websocket), not through router options.
|
|
54
60
|
|
|
@@ -57,7 +63,8 @@ WebSocket support is attached to the HTTP server with [`setupWebSocket`](#websoc
|
|
|
57
63
|
- Request bodies are validated before anything reaches the runtime: `input` must be a non-empty string, `context` an object, `threadId` a non-empty string, swarm `timeout` a positive number. Invalid bodies return `400 INVALID_INPUT` with the offending field in the message.
|
|
58
64
|
- Workflow runs accept an optional body. `options` is limited to `maxConcurrency`, `maxIterations` (positive integers) and `checkpoint` (boolean); any other option is dropped, and a wrongly typed one returns `400 INVALID_INPUT`.
|
|
59
65
|
- Thread messages accept `role` of `user`, `assistant` or `system`; `metadata` is stored with the entry and a token estimate is recorded.
|
|
60
|
-
-
|
|
66
|
+
- Thread 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`.
|
|
67
|
+
- `CogitatorError`s are returned with their HTTP status and code (for example `429 LLM_RATE_LIMITED`). Any other error is logged and returned as `500 Internal server error` (code `INTERNAL_ERROR`) without internal details; the same masking applies to SSE `error` events, `node_error`/`agent_error` stream events and WebSocket errors. A workflow that finishes with an error is answered like a thrown error (its `CogitatorError` status, otherwise `500`), never as a successful result. Missing optional packages (`@cogitator-ai/workflows`, `@cogitator-ai/swarms`) answer `501 UNIMPLEMENTED`.
|
|
61
68
|
- When the client disconnects, the running agent, workflow or swarm is aborted, for both JSON and SSE endpoints.
|
|
62
69
|
- `GET /agents` returns each agent's `description` and never exposes its `instructions`.
|
|
63
70
|
- `GET /tools` returns tool parameters as JSON Schema.
|
|
@@ -106,6 +113,13 @@ WebSocket support is attached to the HTTP server with [`setupWebSocket`](#websoc
|
|
|
106
113
|
| `GET` | `/health` | Health check |
|
|
107
114
|
| `GET` | `/ready` | Readiness check |
|
|
108
115
|
|
|
116
|
+
### Docs (`enableSwagger: true`)
|
|
117
|
+
|
|
118
|
+
| Method | Path | Description |
|
|
119
|
+
| ------ | --------------- | ------------ |
|
|
120
|
+
| `GET` | `/openapi.json` | OpenAPI spec |
|
|
121
|
+
| `GET` | `/docs` | Swagger UI |
|
|
122
|
+
|
|
109
123
|
## Authentication
|
|
110
124
|
|
|
111
125
|
```typescript
|
|
@@ -120,6 +134,8 @@ const router = cogitatorApp({
|
|
|
120
134
|
});
|
|
121
135
|
```
|
|
122
136
|
|
|
137
|
+
An error thrown with a `status` of 500 or more is treated as a server failure (`500 Internal server error`) instead of a rejected caller.
|
|
138
|
+
|
|
123
139
|
### Multiple users
|
|
124
140
|
|
|
125
141
|
When `auth` returns a `userId`, everything a caller does with threads is scoped to it:
|
|
@@ -220,10 +236,32 @@ The router's `auth` option does not cover WebSocket connections, so pass `auth`
|
|
|
220
236
|
|
|
221
237
|
## SSE Streaming
|
|
222
238
|
|
|
223
|
-
The adapter includes `KoaStreamWriter` for Server-Sent Events with structured event types (text deltas, tool calls, workflow/swarm events). Agent streams emit `tool-call-start`, `tool-call-delta` (the JSON arguments) and `tool-call-end` with the provider's tool call id, so `tool-result.toolCallId` always matches the call it belongs to.
|
|
239
|
+
The adapter includes `KoaStreamWriter` for Server-Sent Events with structured event types (text deltas, tool calls, approvals, workflow/swarm events). Workflow streams send `{ type: 'workflow', event, data }` (`node_started`, `node_completed`, `node_error`, `node_progress`, `workflow_completed`); swarm streams send `{ type: 'swarm', event, data }` (`agent_start`, `agent_complete`, `agent_error`, `message`, the swarm's own events, `swarm_completed`). Every stream ends with `finish` and `data: [DONE]`, or with an `error` event. Agent streams emit `tool-call-start`, `tool-call-delta` (the JSON arguments) and `tool-call-end` with the provider's tool call id, so `tool-result.toolCallId` always matches the call it belongs to.
|
|
224
240
|
|
|
225
241
|
When the agent sets `reasoning: { summary: true }` and the provider returns a reasoning summary, agent streams also emit it as its own `reasoning-start`/`reasoning-delta`/`reasoning-end` part, closed before text or a tool call starts, so reasoning and text parts never interleave.
|
|
226
242
|
|
|
243
|
+
For custom routes, call `setupSSEHeaders(ctx)` (it sets `ctx.respond = false`) and write through a `KoaStreamWriter`:
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
import Router from '@koa/router';
|
|
247
|
+
import { KoaStreamWriter, setupSSEHeaders, generateId } from '@cogitator-ai/koa';
|
|
248
|
+
|
|
249
|
+
const custom = new Router();
|
|
250
|
+
|
|
251
|
+
custom.post('/custom/stream', (ctx) => {
|
|
252
|
+
setupSSEHeaders(ctx);
|
|
253
|
+
const writer = new KoaStreamWriter(ctx);
|
|
254
|
+
const messageId = generateId('msg');
|
|
255
|
+
const textId = generateId('txt');
|
|
256
|
+
writer.start(messageId);
|
|
257
|
+
writer.textStart(textId);
|
|
258
|
+
writer.textDelta(textId, 'Hello!');
|
|
259
|
+
writer.textEnd(textId);
|
|
260
|
+
writer.finish(messageId);
|
|
261
|
+
writer.close();
|
|
262
|
+
});
|
|
263
|
+
```
|
|
264
|
+
|
|
227
265
|
## Event Factories
|
|
228
266
|
|
|
229
267
|
Re-exported from `@cogitator-ai/server-shared` for custom stream handling:
|
|
@@ -284,6 +322,10 @@ import type {
|
|
|
284
322
|
} from '@cogitator-ai/koa';
|
|
285
323
|
```
|
|
286
324
|
|
|
325
|
+
## Documentation
|
|
326
|
+
|
|
327
|
+
Full guide: [cogitator.app/docs/server-adapters/koa](https://cogitator.app/docs/server-adapters/koa). Tool approvals: [cogitator.app/docs/tools/approvals](https://cogitator.app/docs/tools/approvals).
|
|
328
|
+
|
|
287
329
|
## License
|
|
288
330
|
|
|
289
331
|
MIT
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAiBtE,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAiBtE,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAAC,cAAc,CAAC,CAgC9E"}
|
package/dist/app.js
CHANGED
|
@@ -19,7 +19,7 @@ export function cogitatorApp(opts) {
|
|
|
19
19
|
createSwarmRoutes(),
|
|
20
20
|
];
|
|
21
21
|
if (opts.enableSwagger) {
|
|
22
|
-
subrouters.push(createSwaggerRoutes(opts.swagger));
|
|
22
|
+
subrouters.push(createSwaggerRoutes({ ...opts.swagger, auth: opts.swagger?.auth ?? Boolean(opts.auth) }));
|
|
23
23
|
}
|
|
24
24
|
for (const sub of subrouters) {
|
|
25
25
|
router.use(sub.routes());
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA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1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/swagger/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/swagger/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAQrC,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC,CAmClF"}
|
package/dist/swagger/index.js
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import Router from '@koa/router';
|
|
2
2
|
import { generateOpenAPISpec, generateSwaggerHTML, } from '@cogitator-ai/server-shared';
|
|
3
|
+
/** Where the Cogitator app is mounted, read from the path of a request to one of its own routes. */
|
|
4
|
+
function mountPath(requestPath, route) {
|
|
5
|
+
const prefix = requestPath.endsWith(route) ? requestPath.slice(0, -route.length) : '';
|
|
6
|
+
return prefix || '/';
|
|
7
|
+
}
|
|
3
8
|
export function createSwaggerRoutes(config) {
|
|
4
9
|
const router = new Router();
|
|
5
|
-
function getSpec(routeCtx) {
|
|
10
|
+
function getSpec(routeCtx, basePath) {
|
|
6
11
|
const openAPICtx = {
|
|
7
12
|
agents: routeCtx.agents,
|
|
8
13
|
workflows: routeCtx.workflows,
|
|
9
14
|
swarms: routeCtx.swarms,
|
|
10
15
|
};
|
|
11
|
-
return generateOpenAPISpec(openAPICtx,
|
|
16
|
+
return generateOpenAPISpec(openAPICtx, {
|
|
17
|
+
...config,
|
|
18
|
+
servers: config?.servers ?? [{ url: basePath }],
|
|
19
|
+
});
|
|
12
20
|
}
|
|
13
21
|
router.get('/openapi.json', (ctx) => {
|
|
14
|
-
const spec = getSpec(ctx.state.cogitator);
|
|
22
|
+
const spec = getSpec(ctx.state.cogitator, mountPath(ctx.path, '/openapi.json'));
|
|
15
23
|
ctx.type = 'application/json';
|
|
16
24
|
ctx.body = spec;
|
|
17
25
|
});
|
|
18
26
|
router.get('/docs', (ctx) => {
|
|
19
|
-
const spec = getSpec(ctx.state.cogitator);
|
|
27
|
+
const spec = getSpec(ctx.state.cogitator, mountPath(ctx.path, '/docs'));
|
|
20
28
|
ctx.type = 'text/html';
|
|
21
29
|
ctx.body = generateSwaggerHTML(spec);
|
|
22
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/swagger/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,6BAA6B,CAAC;AAErC,MAAM,UAAU,mBAAmB,CAAC,MAAsB;IACxD,MAAM,MAAM,GAAG,IAAI,MAAM,EAAkB,CAAC;IAE5C,SAAS,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/swagger/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,6BAA6B,CAAC;AAErC,oGAAoG;AACpG,SAAS,SAAS,CAAC,WAAmB,EAAE,KAAgC;IACtE,MAAM,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtF,OAAO,MAAM,IAAI,GAAG,CAAC;AACvB,CAAC;AAED,MAAM,UAA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CogitatorError, ERROR_STATUS_CODES, ErrorCode } from '@cogitator-ai/types';
|
|
2
2
|
export function isModuleNotFoundError(error) {
|
|
3
3
|
if (typeof error !== 'object' || error === null)
|
|
4
4
|
return false;
|
|
@@ -15,7 +15,7 @@ export function resolveError(error, label) {
|
|
|
15
15
|
console.error(`[CogitatorKoa] ${label}:`, error);
|
|
16
16
|
return {
|
|
17
17
|
status: 500,
|
|
18
|
-
body: { error: { message: 'Internal server error', code:
|
|
18
|
+
body: { error: { message: 'Internal server error', code: ErrorCode.INTERNAL_ERROR } },
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=errors.js.map
|
package/dist/utils/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQpF,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,IAAI,GAAI,KAA+B,CAAC,IAAI,CAAC;IACnD,OAAO,IAAI,KAAK,kBAAkB,IAAI,IAAI,KAAK,sBAAsB,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,KAAa;IACxD,IAAI,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO;YACL,MAAM,EAAE,KAAK,CAAC,UAAU,IAAI,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG;YACjE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE;SAC9D,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,kBAAkB,KAAK,GAAG,EAAE,KAAK,CAAC,CAAC;IACjD,OAAO;QACL,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,SAAS,CAAC,cAAc,EAAE,EAAE;KACtF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cogitator-ai/koa",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Koa server adapter for Cogitator AI runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -18,23 +18,23 @@
|
|
|
18
18
|
"node": ">=22.12.0"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@cogitator-ai/core": "0.
|
|
22
|
-
"@cogitator-ai/memory": "0.
|
|
23
|
-
"@cogitator-ai/types": "0.
|
|
24
|
-
"@cogitator-ai/server-shared": "0.3.
|
|
21
|
+
"@cogitator-ai/core": "0.26.0",
|
|
22
|
+
"@cogitator-ai/memory": "0.11.0",
|
|
23
|
+
"@cogitator-ai/types": "0.29.0",
|
|
24
|
+
"@cogitator-ai/server-shared": "0.3.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"koa": ">=2.15.0",
|
|
28
28
|
"@koa/router": ">=12.0.0"
|
|
29
29
|
},
|
|
30
30
|
"optionalDependencies": {
|
|
31
|
-
"@cogitator-ai/workflows": "0.
|
|
32
|
-
"@cogitator-ai/swarms": "0.
|
|
31
|
+
"@cogitator-ai/workflows": "0.10.0",
|
|
32
|
+
"@cogitator-ai/swarms": "0.9.0",
|
|
33
33
|
"ws": "^8.22.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@cogitator-ai/workflows": "0.
|
|
37
|
-
"@cogitator-ai/swarms": "0.
|
|
36
|
+
"@cogitator-ai/workflows": "0.10.0",
|
|
37
|
+
"@cogitator-ai/swarms": "0.9.0",
|
|
38
38
|
"supertest": "^7.3.0",
|
|
39
39
|
"@types/supertest": "^7.2.1",
|
|
40
40
|
"vitest": "^5.0.3",
|