@cogitator-ai/hono 0.8.6 → 0.9.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 +77 -26
- package/dist/app.d.ts +5 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +16 -4
- package/dist/app.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware/auth.d.ts +6 -0
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +15 -1
- package/dist/middleware/auth.js.map +1 -1
- package/dist/middleware/body-limit.d.ts.map +1 -1
- package/dist/middleware/body-limit.js +3 -1
- package/dist/middleware/body-limit.js.map +1 -1
- package/dist/middleware/context.d.ts +5 -0
- package/dist/middleware/context.d.ts.map +1 -1
- package/dist/middleware/context.js +10 -1
- package/dist/middleware/context.js.map +1 -1
- package/dist/middleware/error-handler.d.ts.map +1 -1
- package/dist/middleware/error-handler.js +3 -7
- package/dist/middleware/error-handler.js.map +1 -1
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/agents.js +25 -13
- package/dist/routes/agents.js.map +1 -1
- package/dist/routes/swarms.d.ts.map +1 -1
- package/dist/routes/swarms.js +24 -17
- package/dist/routes/swarms.js.map +1 -1
- package/dist/routes/threads.d.ts.map +1 -1
- package/dist/routes/threads.js +17 -16
- package/dist/routes/threads.js.map +1 -1
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/workflows.js +15 -18
- package/dist/routes/workflows.js.map +1 -1
- package/dist/types.d.ts +42 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +6 -9
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +10 -19
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/request.d.ts +14 -1
- package/dist/utils/request.d.ts.map +1 -1
- package/dist/utils/request.js +36 -7
- package/dist/utils/request.js.map +1 -1
- package/dist/websocket/handler.d.ts +5 -1
- package/dist/websocket/handler.d.ts.map +1 -1
- package/dist/websocket/handler.js +43 -19
- package/dist/websocket/handler.js.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -44,21 +44,25 @@ Creates a Hono sub-application with all Cogitator endpoints.
|
|
|
44
44
|
|
|
45
45
|
**Options:**
|
|
46
46
|
|
|
47
|
-
| Option | Type
|
|
48
|
-
| -------------------- |
|
|
49
|
-
| `cogitator` | `Cogitator`
|
|
50
|
-
| `agents` | `Record<string, Agent>`
|
|
51
|
-
| `workflows` | `Record<string, Workflow>`
|
|
52
|
-
| `swarms` | `Record<string, SwarmConfig>`
|
|
53
|
-
| `auth` | `AuthFunction`
|
|
54
|
-
| `enableSwagger` | `boolean`
|
|
55
|
-
| `swagger` | `SwaggerConfig`
|
|
56
|
-
| `enableWebSocket` | `boolean`
|
|
57
|
-
| `websocket` | `WebSocketConfig`
|
|
58
|
-
| `bodyLimit` | `number`
|
|
59
|
-
| `sseHeartbeatMs` | `number`
|
|
60
|
-
| `acceptContext` | `boolean \| string[]`
|
|
61
|
-
| `threadMessageRoles` | `ThreadMessageRole[]`
|
|
47
|
+
| Option | Type | Description |
|
|
48
|
+
| -------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
49
|
+
| `cogitator` | `Cogitator` | **Required.** Cogitator runtime instance |
|
|
50
|
+
| `agents` | `Record<string, Agent>` | Named agents to expose |
|
|
51
|
+
| `workflows` | `Record<string, Workflow>` | Named workflows |
|
|
52
|
+
| `swarms` | `Record<string, SwarmConfig>` | Named swarms |
|
|
53
|
+
| `auth` | `AuthFunction` | `(c) => AuthContext \| undefined` (sync or async), receives the Hono Context, throw to answer `401 UNAUTHORIZED` |
|
|
54
|
+
| `enableSwagger` | `boolean` | Serve `/openapi.json` and Swagger UI at `/docs` |
|
|
55
|
+
| `swagger` | `SwaggerConfig` | Swagger configuration |
|
|
56
|
+
| `enableWebSocket` | `boolean` | Enable the WebSocket endpoint |
|
|
57
|
+
| `websocket` | `WebSocketConfig` | `{ path?, maxPayloadSize?, upgradeWebSocket? }` (see below) |
|
|
58
|
+
| `bodyLimit` | `number` | Max request body size in bytes (default 1 MiB) |
|
|
59
|
+
| `sseHeartbeatMs` | `number` | How often SSE streams write a `: keep-alive` comment while a run is silent (default `5000`, `0` turns it off) |
|
|
60
|
+
| `acceptContext` | `boolean \| string[]` | Keys of a run `context` clients may send: none by default, a list, or `true` for any (the model reads it as data from the application) |
|
|
61
|
+
| `threadMessageRoles` | `ThreadMessageRole[]` | Roles `POST /threads/:id/messages` accepts (default `user` and `assistant`) |
|
|
62
|
+
| `limits` | `RunLimits` | `{ swarmTimeout?, workflowMaxIterations?, workflowMaxConcurrency? }`: caps on what a request may ask a swarm or workflow run for (see [Run limits](#run-limits)) |
|
|
63
|
+
| `anonymous` | `'allow' \| 'deny'` | Whether callers without a `userId` may use the API (default `'allow'`), `'deny'` answers `401 UNAUTHORIZED` |
|
|
64
|
+
| `authorizeThread` | `(auth, threadId) => boolean \| Promise<boolean>` | Decides whether a caller may touch a thread, on top of the owner check, `false` answers `403 THREAD_FORBIDDEN` |
|
|
65
|
+
| `deps` | `(c) => unknown \| Promise<unknown>` | Builds the `deps` agent runs pass to their tools, from the Hono Context (see [Run deps](#run-deps)) |
|
|
62
66
|
|
|
63
67
|
## Request Handling
|
|
64
68
|
|
|
@@ -73,7 +77,8 @@ Creates a Hono sub-application with all Cogitator endpoints.
|
|
|
73
77
|
- 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.
|
|
74
78
|
- 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`.
|
|
75
79
|
- Bodies above `bodyLimit` return `413 PAYLOAD_TOO_LARGE`.
|
|
76
|
-
- `
|
|
80
|
+
- `GET /threads/:id` answers the whole thread, or one page of it with `?limit=50`: the newest 50 messages (oldest first within the page) and a `nextCursor`. Pass it back as `?limit=50&cursor=<nextCursor>` for the 50 before them, until an answer has no `nextCursor`. Messages written in the same millisecond are neither skipped nor repeated across pages. A `limit` outside 1 to 1000 or a cursor the server did not give answers `400 INVALID_INPUT`.
|
|
81
|
+
- Every error answer has the same envelope, `{ error: { message, code } }`, the one Express, Fastify, Koa and Next use. A `CogitatorError` is answered with its HTTP status and code (for example `429 LLM_RATE_LIMITED`), plus a `Retry-After` header in whole seconds when the provider said when to retry. A swarm that ran out of time answers `504 RUN_TIMEOUT`. Any other error is logged and answered as `500 Internal server error` (code `INTERNAL_ERROR`) without internal details, and the same masking applies to SSE `error` events, `node_error` and `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`.
|
|
77
82
|
- When the client disconnects, the running agent, workflow or swarm is aborted, for both JSON and SSE endpoints.
|
|
78
83
|
- `GET /agents` returns each agent's `description` and never exposes its `instructions`.
|
|
79
84
|
- `GET /tools` returns tool parameters as JSON Schema.
|
|
@@ -91,11 +96,11 @@ Creates a Hono sub-application with all Cogitator endpoints.
|
|
|
91
96
|
|
|
92
97
|
### Threads (Memory)
|
|
93
98
|
|
|
94
|
-
| Method | Path | Description
|
|
95
|
-
| -------- | ----------------------- |
|
|
96
|
-
| `GET` | `/threads/:id` | Get thread messages
|
|
97
|
-
| `POST` | `/threads/:id/messages` | Add message to thread
|
|
98
|
-
| `DELETE` | `/threads/:id` | Delete thread
|
|
99
|
+
| Method | Path | Description |
|
|
100
|
+
| -------- | ----------------------- | ------------------------------------------------ |
|
|
101
|
+
| `GET` | `/threads/:id` | Get thread messages, a page with `?limit&cursor` |
|
|
102
|
+
| `POST` | `/threads/:id/messages` | Add message to thread |
|
|
103
|
+
| `DELETE` | `/threads/:id` | Delete thread |
|
|
99
104
|
|
|
100
105
|
### Workflows
|
|
101
106
|
|
|
@@ -153,6 +158,51 @@ When `auth` returns a `userId`, everything a caller does with threads is scoped
|
|
|
153
158
|
- Another user's thread answers `403` with code `THREAD_ACCESS_DENIED`, and its messages are neither returned nor changed.
|
|
154
159
|
- Threads created earlier without an owner (no `userId`) stay open only to callers without a `userId`, such as servers with no `auth` configured.
|
|
155
160
|
|
|
161
|
+
### Anonymous callers
|
|
162
|
+
|
|
163
|
+
By default a caller without a `userId` (no `auth`, or `auth` returned none) may use the API as an anonymous user. With `anonymous: 'deny'` such a caller gets `401 UNAUTHORIZED` on every API route, the WebSocket upgrade included. `/health`, `/ready`, `/openapi.json` and `/docs` stay open, so probes and API docs keep working. A path the app does not serve answers `401` under `'deny'` too, so an anonymous caller cannot tell which paths exist, and `404 NOT_FOUND` in the error envelope under `'allow'`.
|
|
164
|
+
|
|
165
|
+
### Thread authorization
|
|
166
|
+
|
|
167
|
+
Core lets a caller touch only threads they own. `authorizeThread` adds your own rule on top, for example a tenant check:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const api = cogitatorApp({
|
|
171
|
+
cogitator,
|
|
172
|
+
agents: { chat: chatAgent },
|
|
173
|
+
auth,
|
|
174
|
+
authorizeThread: (auth, threadId) => tenants.ownsThread(auth?.metadata?.tenant, threadId),
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
It is called with what `auth` returned and the thread a request names: the body `threadId` of agent runs, streams and resumes and of swarm runs and streams, the `:id` of `GET`, `DELETE` and `POST /threads/:id/messages`, and the `threadId` of WebSocket runs and resumes. It runs after the body is validated and before the owner check, and `false` answers `403 THREAD_FORBIDDEN` (a WebSocket `error` message) without starting a run.
|
|
179
|
+
|
|
180
|
+
### Run deps
|
|
181
|
+
|
|
182
|
+
`deps` builds what an agent's tools get as `context.deps` for one request: a database handle, the tenant, a client with the caller's credentials. The model never sees them, and they never come from the request body.
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
const api = cogitatorApp({
|
|
186
|
+
cogitator,
|
|
187
|
+
agents: { chat: chatAgent },
|
|
188
|
+
deps: async (c) => ({ db: await pool.connect(), tenant: c.req.header('x-tenant') }),
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Agent runs, streams and resumes call it once per run. WebSocket runs call it with the upgrade request's Context.
|
|
193
|
+
|
|
194
|
+
### Run limits
|
|
195
|
+
|
|
196
|
+
`limits` caps what a request may ask a run for: `swarmTimeout` (ms) for swarm runs, `workflowMaxIterations` and `workflowMaxConcurrency` for workflow runs. A request that asks for more is held to the cap, and one that asks for nothing gets the cap, over HTTP, SSE and WebSocket alike. Each limit must be a positive integer, or `cogitatorApp` throws. The OpenAPI spec shows each limit as the default of its field.
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
const api = cogitatorApp({
|
|
200
|
+
cogitator,
|
|
201
|
+
swarms: { research: researchSwarm },
|
|
202
|
+
limits: { swarmTimeout: 120_000, workflowMaxIterations: 50, workflowMaxConcurrency: 4 },
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
156
206
|
### Approvals
|
|
157
207
|
|
|
158
208
|
A tool with `requiresApproval` (`true`, or a function of the arguments) pauses the run before that turn executes:
|
|
@@ -265,11 +315,11 @@ On Bun use `upgradeWebSocket` from `hono/bun`, on Deno from `hono/deno`, on Clou
|
|
|
265
315
|
| `stop` | Cancels the current run |
|
|
266
316
|
| `ping` | Answered with `pong` (echoes `id`) |
|
|
267
317
|
|
|
268
|
-
| Server sends | Description
|
|
269
|
-
| ------------ |
|
|
270
|
-
| `event` | `token`, `reasoning`, `tool-call`, `tool-result`, `complete` (with the serialized result), `cancelled`
|
|
271
|
-
| `error` | Invalid message, unknown resource, run already in progress, or a masked run failure
|
|
272
|
-
| `pong` | Heartbeat reply
|
|
318
|
+
| Server sends | Description |
|
|
319
|
+
| ------------ | ----------------------------------------------------------------------------------------------------------------------- |
|
|
320
|
+
| `event` | `token`, `reasoning`, `tool-call`, `tool-result`, `complete` (with the serialized result), `cancelled` |
|
|
321
|
+
| `error` | Invalid message, unknown resource, a thread `authorizeThread` refused, run already in progress, or a masked run failure |
|
|
322
|
+
| `pong` | Heartbeat reply |
|
|
273
323
|
|
|
274
324
|
Messages larger than `maxPayloadSize` are rejected and the socket is closed with code `1009`. Closing the socket aborts the active run. `handleWebSocketMessage` and `createClientState` are exported for custom WebSocket integrations.
|
|
275
325
|
|
|
@@ -287,6 +337,7 @@ import {
|
|
|
287
337
|
createWebSocketRoutes,
|
|
288
338
|
createContextMiddleware,
|
|
289
339
|
createAuthMiddleware,
|
|
340
|
+
createAnonymousMiddleware,
|
|
290
341
|
createBodyLimitMiddleware,
|
|
291
342
|
errorHandler,
|
|
292
343
|
} from '@cogitator-ai/hono';
|
package/dist/app.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
2
|
import type { HonoEnv, CogitatorAppOptions } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The Cogitator API as a Hono app.
|
|
5
|
+
*
|
|
6
|
+
* @throws Error when `opts.limits` holds a limit that is not a positive integer
|
|
7
|
+
*/
|
|
3
8
|
export declare function cogitatorApp(opts: CogitatorAppOptions): Hono<HonoEnv>;
|
|
4
9
|
//# sourceMappingURL=app.d.ts.map
|
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,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAiB/D;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,CAuCrE"}
|
package/dist/app.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
2
|
import { createContextMiddleware } from './middleware/context.js';
|
|
3
|
-
import { createAuthMiddleware } from './middleware/auth.js';
|
|
3
|
+
import { createAnonymousMiddleware, createAuthMiddleware } from './middleware/auth.js';
|
|
4
4
|
import { createBodyLimitMiddleware } from './middleware/body-limit.js';
|
|
5
5
|
import { errorHandler } from './middleware/error-handler.js';
|
|
6
6
|
import { createHealthRoutes, createAgentRoutes, createThreadRoutes, createToolRoutes, createWorkflowRoutes, createSwarmRoutes, } from './routes/index.js';
|
|
7
7
|
import { createSwaggerRoutes } from './swagger/index.js';
|
|
8
8
|
import { createWebSocketRoutes } from './websocket/handler.js';
|
|
9
|
+
import { notFound } from './utils/request.js';
|
|
10
|
+
/**
|
|
11
|
+
* The Cogitator API as a Hono app.
|
|
12
|
+
*
|
|
13
|
+
* @throws Error when `opts.limits` holds a limit that is not a positive integer
|
|
14
|
+
*/
|
|
9
15
|
export function cogitatorApp(opts) {
|
|
10
16
|
const app = new Hono();
|
|
11
17
|
app.use('*', createContextMiddleware(opts));
|
|
@@ -14,17 +20,23 @@ export function cogitatorApp(opts) {
|
|
|
14
20
|
app.use('*', createAuthMiddleware(opts.auth));
|
|
15
21
|
}
|
|
16
22
|
app.route('/', createHealthRoutes());
|
|
23
|
+
if (opts.enableSwagger) {
|
|
24
|
+
app.route('/', createSwaggerRoutes({
|
|
25
|
+
...opts.swagger,
|
|
26
|
+
auth: opts.swagger?.auth ?? Boolean(opts.auth),
|
|
27
|
+
...(opts.limits && { limits: opts.limits }),
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
app.use('*', createAnonymousMiddleware(opts.anonymous));
|
|
17
31
|
app.route('/', createAgentRoutes());
|
|
18
32
|
app.route('/', createThreadRoutes());
|
|
19
33
|
app.route('/', createToolRoutes());
|
|
20
34
|
app.route('/', createWorkflowRoutes());
|
|
21
35
|
app.route('/', createSwarmRoutes());
|
|
22
|
-
if (opts.enableSwagger) {
|
|
23
|
-
app.route('/', createSwaggerRoutes({ ...opts.swagger, auth: opts.swagger?.auth ?? Boolean(opts.auth) }));
|
|
24
|
-
}
|
|
25
36
|
if (opts.enableWebSocket) {
|
|
26
37
|
app.route('/', createWebSocketRoutes(opts.websocket));
|
|
27
38
|
}
|
|
39
|
+
app.notFound((c) => notFound(c, 'Not found'));
|
|
28
40
|
app.onError(errorHandler);
|
|
29
41
|
return app;
|
|
30
42
|
}
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAA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K,CAAC,GAAG,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACnC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC,CAAC;IACvC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAEpC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QACzB,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;IAC9C,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAE1B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { cogitatorApp } from './app.js';
|
|
2
|
-
export type { CogitatorAppOptions, CogitatorContext, HonoEnv, AuthContext, AuthFunction, WebSocketConfig, AgentListResponse, AgentRunRequest, AgentRunResponse, AgentResumeRequest, PendingApproval, ThreadResponse, AddMessageRequest, ToolListResponse, WorkflowListResponse, WorkflowRunRequest, WorkflowRunResponse, WorkflowStatusResponse, SwarmListResponse, SwarmRunRequest, SwarmRunResponse, BlackboardResponse, HealthResponse, ReadinessResponse, ReadinessCheckStatus, ErrorResponse, SwaggerConfig, WebSocketMessage, WebSocketResponse, WebSocketRunPayload, WebSocketResumePayload, WebSocketClientState, WebSocketLike, } from './types.js';
|
|
2
|
+
export type { CogitatorAppOptions, CogitatorContext, HonoEnv, AuthContext, AuthFunction, DepsFunction, RunLimits, AnonymousPolicy, AuthorizeThread, WebSocketConfig, AgentListResponse, AgentRunRequest, AgentRunResponse, AgentResumeRequest, PendingApproval, ThreadResponse, AddMessageRequest, ToolListResponse, WorkflowListResponse, WorkflowRunRequest, WorkflowRunResponse, WorkflowStatusResponse, SwarmListResponse, SwarmRunRequest, SwarmRunResponse, BlackboardResponse, HealthResponse, ReadinessResponse, ReadinessCheckStatus, ErrorResponse, SwaggerConfig, WebSocketMessage, WebSocketResponse, WebSocketRunPayload, WebSocketResumePayload, WebSocketClientState, WebSocketLike, } from './types.js';
|
|
3
3
|
export { HonoStreamWriter } from './streaming/hono-stream-writer.js';
|
|
4
4
|
export type { HonoStreamWriterOptions } from './streaming/hono-stream-writer.js';
|
|
5
5
|
export { createContextMiddleware } from './middleware/context.js';
|
|
6
|
-
export { createAuthMiddleware } from './middleware/auth.js';
|
|
6
|
+
export { createAnonymousMiddleware, createAuthMiddleware } from './middleware/auth.js';
|
|
7
7
|
export { errorHandler } from './middleware/error-handler.js';
|
|
8
8
|
export { createBodyLimitMiddleware } from './middleware/body-limit.js';
|
|
9
9
|
export { createHealthRoutes, createAgentRoutes, createThreadRoutes, createToolRoutes, createWorkflowRoutes, createSwarmRoutes, } from './routes/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,GACd,MAAM,YAA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EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,GACX,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { cogitatorApp } from './app.js';
|
|
2
2
|
export { HonoStreamWriter } from './streaming/hono-stream-writer.js';
|
|
3
3
|
export { createContextMiddleware } from './middleware/context.js';
|
|
4
|
-
export { createAuthMiddleware } from './middleware/auth.js';
|
|
4
|
+
export { createAnonymousMiddleware, createAuthMiddleware } from './middleware/auth.js';
|
|
5
5
|
export { errorHandler } from './middleware/error-handler.js';
|
|
6
6
|
export { createBodyLimitMiddleware } from './middleware/body-limit.js';
|
|
7
7
|
export { createHealthRoutes, createAgentRoutes, createThreadRoutes, createToolRoutes, createWorkflowRoutes, createSwarmRoutes, } from './routes/index.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA0CxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAGrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,GACX,MAAM,6BAA6B,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { type AnonymousPolicy } from '@cogitator-ai/server-shared';
|
|
1
2
|
import type { HonoEnv, AuthFunction } from '../types.js';
|
|
2
3
|
export declare function createAuthMiddleware(authFn: AuthFunction): import("hono").MiddlewareHandler<HonoEnv, string, {}, Response>;
|
|
4
|
+
/**
|
|
5
|
+
* Turns away callers without a `userId` when `anonymous` is `'deny'`, with
|
|
6
|
+
* `401 UNAUTHORIZED`. Routes registered before it, such as health and docs, stay open.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createAnonymousMiddleware(anonymous: AnonymousPolicy | undefined): import("hono").MiddlewareHandler<HonoEnv, string, {}, Response>;
|
|
3
9
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGzD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,mEAUxD;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,eAAe,GAAG,SAAS,mEAM/E"}
|
package/dist/middleware/auth.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createMiddleware } from 'hono/factory';
|
|
2
|
+
import { UNAUTHORIZED, admitCaller } from '@cogitator-ai/server-shared';
|
|
3
|
+
import { sendError } from '../utils/request.js';
|
|
2
4
|
export function createAuthMiddleware(authFn) {
|
|
3
5
|
return createMiddleware(async (c, next) => {
|
|
4
6
|
try {
|
|
@@ -6,9 +8,21 @@ export function createAuthMiddleware(authFn) {
|
|
|
6
8
|
c.set('cogitatorAuth', auth);
|
|
7
9
|
}
|
|
8
10
|
catch {
|
|
9
|
-
return c
|
|
11
|
+
return sendError(c, { ...UNAUTHORIZED, message: 'Unauthorized' });
|
|
10
12
|
}
|
|
11
13
|
await next();
|
|
12
14
|
});
|
|
13
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Turns away callers without a `userId` when `anonymous` is `'deny'`, with
|
|
18
|
+
* `401 UNAUTHORIZED`. Routes registered before it, such as health and docs, stay open.
|
|
19
|
+
*/
|
|
20
|
+
export function createAnonymousMiddleware(anonymous) {
|
|
21
|
+
return createMiddleware(async (c, next) => {
|
|
22
|
+
const refusal = admitCaller(c.get('cogitatorAuth')?.userId, anonymous);
|
|
23
|
+
if (refusal)
|
|
24
|
+
return sendError(c, refusal);
|
|
25
|
+
await next();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
14
28
|
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAwB,MAAM,6BAA6B,CAAC;AAE9F,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,UAAU,oBAAoB,CAAC,MAAoB;IACvD,OAAO,gBAAgB,CAAU,KAAK,EAAE,CAAC,EAAE,IAAI,EAA4B,EAAE;QAC3E,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC;YAC7B,CAAC,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC,CAAC,EAAE,EAAE,GAAG,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;QACpE,CAAC;QACD,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,SAAsC;IAC9E,OAAO,gBAAgB,CAAU,KAAK,EAAE,CAAC,EAAE,IAAI,EAA4B,EAAE;QAC3E,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACvE,IAAI,OAAO;YAAE,OAAO,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAC1C,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-limit.d.ts","sourceRoot":"","sources":["../../src/middleware/body-limit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"body-limit.d.ts","sourceRoot":"","sources":["../../src/middleware/body-limit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG3C,eAAO,MAAM,kBAAkB,QAAc,CAAC;AAE9C,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,MAA2B,GACnC,iBAAiB,CAAC,OAAO,CAAC,CAK5B"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { bodyLimit } from 'hono/body-limit';
|
|
2
|
+
import { PAYLOAD_TOO_LARGE } from '@cogitator-ai/server-shared';
|
|
3
|
+
import { sendError } from '../utils/request.js';
|
|
2
4
|
export const DEFAULT_BODY_LIMIT = 1024 * 1024;
|
|
3
5
|
export function createBodyLimitMiddleware(maxSize = DEFAULT_BODY_LIMIT) {
|
|
4
6
|
return bodyLimit({
|
|
5
7
|
maxSize,
|
|
6
|
-
onError: (c) => c
|
|
8
|
+
onError: (c) => sendError(c, PAYLOAD_TOO_LARGE),
|
|
7
9
|
});
|
|
8
10
|
}
|
|
9
11
|
//# sourceMappingURL=body-limit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-limit.js","sourceRoot":"","sources":["../../src/middleware/body-limit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"body-limit.js","sourceRoot":"","sources":["../../src/middleware/body-limit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C,MAAM,UAAU,yBAAyB,CACvC,UAAkB,kBAAkB;IAEpC,OAAO,SAAS,CAAC;QACf,OAAO;QACP,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,iBAAiB,CAAC;KAChD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { HonoEnv, CogitatorAppOptions } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sets the Cogitator context of each request.
|
|
4
|
+
*
|
|
5
|
+
* @throws Error when `opts.limits` holds a limit that is not a positive integer
|
|
6
|
+
*/
|
|
2
7
|
export declare function createContextMiddleware(opts: CogitatorAppOptions): import("hono").MiddlewareHandler<HonoEnv, string, {}, Response>;
|
|
3
8
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/middleware/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/middleware/context.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,mEAqBhE"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { createMiddleware } from 'hono/factory';
|
|
2
|
-
import { DEFAULT_THREAD_MESSAGE_ROLES, generateId, resolveSseHeartbeatMs, } from '@cogitator-ai/server-shared';
|
|
2
|
+
import { DEFAULT_THREAD_MESSAGE_ROLES, checkRunLimits, generateId, resolveSseHeartbeatMs, } from '@cogitator-ai/server-shared';
|
|
3
|
+
/**
|
|
4
|
+
* Sets the Cogitator context of each request.
|
|
5
|
+
*
|
|
6
|
+
* @throws Error when `opts.limits` holds a limit that is not a positive integer
|
|
7
|
+
*/
|
|
3
8
|
export function createContextMiddleware(opts) {
|
|
4
9
|
const sseHeartbeatMs = resolveSseHeartbeatMs(opts.sseHeartbeatMs);
|
|
10
|
+
const limits = checkRunLimits(opts.limits);
|
|
5
11
|
return createMiddleware(async (c, next) => {
|
|
6
12
|
c.set('cogitator', {
|
|
7
13
|
runtime: opts.cogitator,
|
|
@@ -11,6 +17,9 @@ export function createContextMiddleware(opts) {
|
|
|
11
17
|
sseHeartbeatMs,
|
|
12
18
|
acceptContext: opts.acceptContext ?? false,
|
|
13
19
|
threadMessageRoles: opts.threadMessageRoles ?? DEFAULT_THREAD_MESSAGE_ROLES,
|
|
20
|
+
limits,
|
|
21
|
+
authorizeThread: opts.authorizeThread,
|
|
22
|
+
deps: opts.deps,
|
|
14
23
|
});
|
|
15
24
|
c.set('cogitatorRequestId', generateId('req'));
|
|
16
25
|
c.set('cogitatorStartTime', Date.now());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/middleware/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,4BAA4B,EAC5B,UAAU,EACV,qBAAqB,GACtB,MAAM,6BAA6B,CAAC;AAGrC,MAAM,UAAU,uBAAuB,CAAC,IAAyB;IAC/D,MAAM,cAAc,GAAG,qB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AAI,CAAC,kBAAkB,IAAI,4BAA4B;YAC3E,MAAM;YACN,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;QACH,CAAC,CAAC,GAAG,CAAC,oBAAoB,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/C,CAAC,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAExC,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/middleware/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/middleware/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,OAAO,CAM9C,CAAC"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { HTTPException } from 'hono/http-exception';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { describeError } from '../utils/errors.js';
|
|
3
|
+
import { sendError } from '../utils/request.js';
|
|
4
4
|
export const errorHandler = (err, c) => {
|
|
5
5
|
if (err instanceof HTTPException) {
|
|
6
6
|
return err.getResponse();
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
return c.json({ error: { message: err.message, code: err.code } }, cogitatorErrorStatus(err));
|
|
10
|
-
}
|
|
11
|
-
console.error('[CogitatorHono] Unhandled error:', err);
|
|
12
|
-
return c.json({ error: { message: 'Internal server error', code: ErrorCode.INTERNAL_ERROR } }, 500);
|
|
8
|
+
return sendError(c, describeError(err, 'Unhandled error'));
|
|
13
9
|
};
|
|
14
10
|
//# sourceMappingURL=error-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/middleware/error-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/middleware/error-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;IAC5D,IAAI,GAAG,YAAY,aAAa,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;IAED,OAAO,SAAS,CAAC,CAAC,EAAE,aAAa,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAS5B,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAS5B,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,aAAa,CAAC;AAiB9D,wBAAgB,iBAAiB,IAAI,IAAI,CAAC,OAAO,CAAC,CA2IjD"}
|
package/dist/routes/agents.js
CHANGED
|
@@ -3,8 +3,8 @@ import { streamSSE } from 'hono/streaming';
|
|
|
3
3
|
import { AgentStreamSession, parseResumeRequest, parseRunRequest, toAgentRunResponse, } from '@cogitator-ai/server-shared';
|
|
4
4
|
import { HonoStreamWriter } from '../streaming/hono-stream-writer.js';
|
|
5
5
|
import { getOwn } from '../utils/lookup.js';
|
|
6
|
-
import {
|
|
7
|
-
import { createRequestAbortController, holdConnectionOpen, errorResponse, invalidInput, bodyRefused, readJsonBody, requestAborted, } from '../utils/request.js';
|
|
6
|
+
import { describeError } from '../utils/errors.js';
|
|
7
|
+
import { createRequestAbortController, holdConnectionOpen, errorResponse, invalidInput, bodyRefused, notFound, readJsonBody, refuseThread, requestAborted, runDeps, sendError, } from '../utils/request.js';
|
|
8
8
|
export function createAgentRoutes() {
|
|
9
9
|
const app = new Hono();
|
|
10
10
|
app.get('/agents', (c) => {
|
|
@@ -21,22 +21,26 @@ export function createAgentRoutes() {
|
|
|
21
21
|
const ctx = c.get('cogitator');
|
|
22
22
|
const name = c.req.param('name');
|
|
23
23
|
const agent = getOwn(ctx.agents, name);
|
|
24
|
-
if (!agent)
|
|
25
|
-
return c
|
|
26
|
-
}
|
|
24
|
+
if (!agent)
|
|
25
|
+
return notFound(c, `Agent '${name}' not found`);
|
|
27
26
|
const body = await readJsonBody(c);
|
|
28
27
|
if (!body.ok)
|
|
29
28
|
return bodyRefused(c, body.refusal);
|
|
30
29
|
const parsed = parseRunRequest(body.value, { acceptContext: ctx.acceptContext });
|
|
31
30
|
if (!parsed.ok)
|
|
32
31
|
return invalidInput(c, parsed.message);
|
|
32
|
+
const refusal = await refuseThread(c, parsed.value.threadId);
|
|
33
|
+
if (refusal)
|
|
34
|
+
return sendError(c, refusal);
|
|
33
35
|
const userId = c.get('cogitatorAuth')?.userId;
|
|
36
|
+
const deps = await runDeps(c);
|
|
34
37
|
holdConnectionOpen(c);
|
|
35
38
|
const abortController = createRequestAbortController(c);
|
|
36
39
|
try {
|
|
37
40
|
const result = await ctx.runtime.run(agent, {
|
|
38
41
|
...parsed.value,
|
|
39
42
|
userId,
|
|
43
|
+
...deps,
|
|
40
44
|
signal: abortController.signal,
|
|
41
45
|
});
|
|
42
46
|
return c.json(toAgentRunResponse(result));
|
|
@@ -51,9 +55,8 @@ export function createAgentRoutes() {
|
|
|
51
55
|
const ctx = c.get('cogitator');
|
|
52
56
|
const name = c.req.param('name');
|
|
53
57
|
const agent = getOwn(ctx.agents, name);
|
|
54
|
-
if (!agent)
|
|
55
|
-
return c
|
|
56
|
-
}
|
|
58
|
+
if (!agent)
|
|
59
|
+
return notFound(c, `Agent '${name}' not found`);
|
|
57
60
|
const body = await readJsonBody(c);
|
|
58
61
|
if (!body.ok)
|
|
59
62
|
return bodyRefused(c, body.refusal);
|
|
@@ -61,12 +64,17 @@ export function createAgentRoutes() {
|
|
|
61
64
|
if (!parsed.ok)
|
|
62
65
|
return invalidInput(c, parsed.message);
|
|
63
66
|
const { threadId, decisions, defaultDecision } = parsed.value;
|
|
67
|
+
const refusal = await refuseThread(c, threadId);
|
|
68
|
+
if (refusal)
|
|
69
|
+
return sendError(c, refusal);
|
|
64
70
|
const userId = c.get('cogitatorAuth')?.userId;
|
|
71
|
+
const deps = await runDeps(c);
|
|
65
72
|
holdConnectionOpen(c);
|
|
66
73
|
const abortController = createRequestAbortController(c);
|
|
67
74
|
try {
|
|
68
75
|
const result = await ctx.runtime.resume(agent, threadId, {
|
|
69
76
|
userId,
|
|
77
|
+
...deps,
|
|
70
78
|
decisions,
|
|
71
79
|
defaultDecision,
|
|
72
80
|
signal: abortController.signal,
|
|
@@ -83,16 +91,19 @@ export function createAgentRoutes() {
|
|
|
83
91
|
const ctx = c.get('cogitator');
|
|
84
92
|
const name = c.req.param('name');
|
|
85
93
|
const agent = getOwn(ctx.agents, name);
|
|
86
|
-
if (!agent)
|
|
87
|
-
return c
|
|
88
|
-
}
|
|
94
|
+
if (!agent)
|
|
95
|
+
return notFound(c, `Agent '${name}' not found`);
|
|
89
96
|
const body = await readJsonBody(c);
|
|
90
97
|
if (!body.ok)
|
|
91
98
|
return bodyRefused(c, body.refusal);
|
|
92
99
|
const parsed = parseRunRequest(body.value, { acceptContext: ctx.acceptContext });
|
|
93
100
|
if (!parsed.ok)
|
|
94
101
|
return invalidInput(c, parsed.message);
|
|
102
|
+
const refusal = await refuseThread(c, parsed.value.threadId);
|
|
103
|
+
if (refusal)
|
|
104
|
+
return sendError(c, refusal);
|
|
95
105
|
const userId = c.get('cogitatorAuth')?.userId;
|
|
106
|
+
const deps = await runDeps(c);
|
|
96
107
|
const abortController = createRequestAbortController(c);
|
|
97
108
|
return streamSSE(c, async (stream) => {
|
|
98
109
|
const writer = new HonoStreamWriter(stream, { heartbeatMs: ctx.sseHeartbeatMs });
|
|
@@ -109,6 +120,7 @@ export function createAgentRoutes() {
|
|
|
109
120
|
...parsed.value,
|
|
110
121
|
threadId: session.threadId,
|
|
111
122
|
userId,
|
|
123
|
+
...deps,
|
|
112
124
|
stream: true,
|
|
113
125
|
signal: abortController.signal,
|
|
114
126
|
...session.callbacks,
|
|
@@ -118,8 +130,8 @@ export function createAgentRoutes() {
|
|
|
118
130
|
catch (error) {
|
|
119
131
|
if (abortController.signal.aborted)
|
|
120
132
|
return;
|
|
121
|
-
const
|
|
122
|
-
session.fail(
|
|
133
|
+
const failure = describeError(error, 'Agent stream error');
|
|
134
|
+
session.fail(failure.message, failure.code);
|
|
123
135
|
}
|
|
124
136
|
finally {
|
|
125
137
|
await writer.flush();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AACrC,O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|
1
|
-
{"version":3,"file":"swarms.d.ts","sourceRoot":"","sources":["../../src/routes/swarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"swarms.d.ts","sourceRoot":"","sources":["../../src/routes/swarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAU5B,OAAO,KAAK,EAAE,OAAO,EAAyC,MAAM,aAAa,CAAC;AAmBlF,wBAAgB,iBAAiB,IAAI,IAAI,CAAC,OAAO,CAAC,CAiKjD"}
|