@cogitator-ai/hono 0.1.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/LICENSE +21 -0
- package/README.md +143 -0
- package/dist/app.d.ts +4 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +26 -0
- package/dist/app.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/auth.d.ts +3 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +15 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/context.d.ts +3 -0
- package/dist/middleware/context.d.ts.map +1 -0
- package/dist/middleware/context.js +16 -0
- package/dist/middleware/context.js.map +1 -0
- package/dist/middleware/error-handler.d.ts +4 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/error-handler.js +10 -0
- package/dist/middleware/error-handler.js.map +1 -0
- package/dist/routes/agents.d.ts +4 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +104 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/routes/health.d.ts +4 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +18 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/index.d.ts +7 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +7 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/swarms.d.ts +4 -0
- package/dist/routes/swarms.d.ts.map +1 -0
- package/dist/routes/swarms.js +161 -0
- package/dist/routes/swarms.js.map +1 -0
- package/dist/routes/threads.d.ts +4 -0
- package/dist/routes/threads.d.ts.map +1 -0
- package/dist/routes/threads.js +61 -0
- package/dist/routes/threads.js.map +1 -0
- package/dist/routes/tools.d.ts +4 -0
- package/dist/routes/tools.d.ts.map +1 -0
- package/dist/routes/tools.js +30 -0
- package/dist/routes/tools.js.map +1 -0
- package/dist/routes/workflows.d.ts +4 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/routes/workflows.js +103 -0
- package/dist/routes/workflows.js.map +1 -0
- package/dist/streaming/hono-stream-writer.d.ts +23 -0
- package/dist/streaming/hono-stream-writer.d.ts.map +1 -0
- package/dist/streaming/hono-stream-writer.js +64 -0
- package/dist/streaming/hono-stream-writer.js.map +1 -0
- package/dist/types.d.ts +172 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/websocket/handler.d.ts +19 -0
- package/dist/websocket/handler.d.ts.map +1 -0
- package/dist/websocket/handler.js +131 -0
- package/dist/websocket/handler.js.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Cogitator Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# @cogitator-ai/hono
|
|
2
|
+
|
|
3
|
+
Hono server adapter for Cogitator AI runtime. Works on **Node.js, Bun, Deno, Cloudflare Workers, AWS Lambda** — anywhere Hono runs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @cogitator-ai/hono @cogitator-ai/core hono
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Hono } from 'hono';
|
|
15
|
+
import { Cogitator, Agent } from '@cogitator-ai/core';
|
|
16
|
+
import { cogitatorApp } from '@cogitator-ai/hono';
|
|
17
|
+
|
|
18
|
+
const cogitator = new Cogitator({
|
|
19
|
+
/* ... */
|
|
20
|
+
});
|
|
21
|
+
const chatAgent = new Agent({ name: 'chat', instructions: 'You are a helpful assistant.' });
|
|
22
|
+
|
|
23
|
+
const app = new Hono();
|
|
24
|
+
|
|
25
|
+
const api = cogitatorApp({
|
|
26
|
+
cogitator,
|
|
27
|
+
agents: { chat: chatAgent },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
app.route('/cogitator', api);
|
|
31
|
+
|
|
32
|
+
export default app;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
### `cogitatorApp(options)`
|
|
38
|
+
|
|
39
|
+
Creates a Hono sub-application with all Cogitator endpoints.
|
|
40
|
+
|
|
41
|
+
**Options:**
|
|
42
|
+
|
|
43
|
+
| Option | Type | Description |
|
|
44
|
+
| ----------------- | ----------------------------- | ---------------------------------------- |
|
|
45
|
+
| `cogitator` | `Cogitator` | **Required.** Cogitator runtime instance |
|
|
46
|
+
| `agents` | `Record<string, Agent>` | Named agents to expose |
|
|
47
|
+
| `workflows` | `Record<string, Workflow>` | Named workflows |
|
|
48
|
+
| `swarms` | `Record<string, SwarmConfig>` | Named swarms |
|
|
49
|
+
| `auth` | `(ctx) => AuthContext` | Authentication function |
|
|
50
|
+
| `enableWebSocket` | `boolean` | Enable WebSocket support |
|
|
51
|
+
| `websocket` | `WebSocketConfig` | WebSocket configuration |
|
|
52
|
+
|
|
53
|
+
## Endpoints
|
|
54
|
+
|
|
55
|
+
### Agents
|
|
56
|
+
|
|
57
|
+
| Method | Path | Description |
|
|
58
|
+
| ------ | ---------------------- | ------------------------- |
|
|
59
|
+
| `GET` | `/agents` | List all agents |
|
|
60
|
+
| `POST` | `/agents/:name/run` | Run agent (JSON response) |
|
|
61
|
+
| `POST` | `/agents/:name/stream` | Run agent (SSE stream) |
|
|
62
|
+
|
|
63
|
+
### Threads (Memory)
|
|
64
|
+
|
|
65
|
+
| Method | Path | Description |
|
|
66
|
+
| -------- | ----------------------- | --------------------- |
|
|
67
|
+
| `GET` | `/threads/:id` | Get thread messages |
|
|
68
|
+
| `POST` | `/threads/:id/messages` | Add message to thread |
|
|
69
|
+
| `DELETE` | `/threads/:id` | Delete thread |
|
|
70
|
+
|
|
71
|
+
### Workflows
|
|
72
|
+
|
|
73
|
+
| Method | Path | Description |
|
|
74
|
+
| ------ | ------------------------- | ---------------------- |
|
|
75
|
+
| `GET` | `/workflows` | List workflows |
|
|
76
|
+
| `POST` | `/workflows/:name/run` | Execute workflow |
|
|
77
|
+
| `POST` | `/workflows/:name/stream` | Stream workflow events |
|
|
78
|
+
|
|
79
|
+
### Swarms
|
|
80
|
+
|
|
81
|
+
| Method | Path | Description |
|
|
82
|
+
| ------ | -------------------------- | --------------------- |
|
|
83
|
+
| `GET` | `/swarms` | List swarms |
|
|
84
|
+
| `POST` | `/swarms/:name/run` | Run swarm |
|
|
85
|
+
| `POST` | `/swarms/:name/stream` | Stream swarm progress |
|
|
86
|
+
| `GET` | `/swarms/:name/blackboard` | Get shared state |
|
|
87
|
+
|
|
88
|
+
### Tools & Health
|
|
89
|
+
|
|
90
|
+
| Method | Path | Description |
|
|
91
|
+
| ------ | --------- | --------------- |
|
|
92
|
+
| `GET` | `/tools` | List all tools |
|
|
93
|
+
| `GET` | `/health` | Health check |
|
|
94
|
+
| `GET` | `/ready` | Readiness check |
|
|
95
|
+
|
|
96
|
+
## Authentication
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const api = cogitatorApp({
|
|
100
|
+
cogitator,
|
|
101
|
+
agents: { chat: chatAgent },
|
|
102
|
+
auth: async (ctx) => {
|
|
103
|
+
// Your auth logic here
|
|
104
|
+
return { userId: 'user-123' };
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Multi-Runtime
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
// Node.js
|
|
113
|
+
import { serve } from '@hono/node-server';
|
|
114
|
+
serve(app, { port: 3000 });
|
|
115
|
+
|
|
116
|
+
// Bun
|
|
117
|
+
export default app;
|
|
118
|
+
|
|
119
|
+
// Cloudflare Workers
|
|
120
|
+
export default app;
|
|
121
|
+
|
|
122
|
+
// Deno
|
|
123
|
+
Deno.serve(app.fetch);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## SSE Streaming
|
|
127
|
+
|
|
128
|
+
The adapter uses Hono's built-in `streamSSE` for Server-Sent Events — no raw response manipulation needed. Works across all runtimes.
|
|
129
|
+
|
|
130
|
+
## Individual Route Access
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import {
|
|
134
|
+
createAgentRoutes,
|
|
135
|
+
createThreadRoutes,
|
|
136
|
+
createToolRoutes,
|
|
137
|
+
createHealthRoutes,
|
|
138
|
+
} from '@cogitator-ai/hono';
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +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;AAa/D,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,CAyBrE"}
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { createContextMiddleware } from './middleware/context.js';
|
|
3
|
+
import { createAuthMiddleware } from './middleware/auth.js';
|
|
4
|
+
import { errorHandler } from './middleware/error-handler.js';
|
|
5
|
+
import { createHealthRoutes, createAgentRoutes, createThreadRoutes, createToolRoutes, createWorkflowRoutes, createSwarmRoutes, } from './routes/index.js';
|
|
6
|
+
export function cogitatorApp(opts) {
|
|
7
|
+
const app = new Hono();
|
|
8
|
+
app.use('*', createContextMiddleware(opts));
|
|
9
|
+
if (opts.auth) {
|
|
10
|
+
app.use('*', createAuthMiddleware(opts.auth));
|
|
11
|
+
}
|
|
12
|
+
app.route('/', createHealthRoutes());
|
|
13
|
+
app.route('/', createAgentRoutes());
|
|
14
|
+
app.route('/', createThreadRoutes());
|
|
15
|
+
app.route('/', createToolRoutes());
|
|
16
|
+
app.route('/', createWorkflowRoutes());
|
|
17
|
+
app.route('/', createSwarmRoutes());
|
|
18
|
+
if (opts.enableWebSocket) {
|
|
19
|
+
void import('./websocket/handler.js').then(({ createWebSocketRoutes }) => {
|
|
20
|
+
app.route('/', createWebSocketRoutes(opts.websocket?.path));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
app.onError(errorHandler);
|
|
24
|
+
return app;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
AD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,CAAC,IAAI,CAAC,CAAC,EAAE,qBAAqB,EAAE,EAAE,EAAE;YACvE,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,qBAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAE1B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { cogitatorApp } from './app.js';
|
|
2
|
+
export type { CogitatorAppOptions, CogitatorContext, HonoEnv, AuthContext, AuthFunction, WebSocketConfig, AgentListResponse, AgentRunRequest, AgentRunResponse, ThreadResponse, AddMessageRequest, ToolListResponse, WorkflowListResponse, WorkflowRunRequest, WorkflowRunResponse, WorkflowStatusResponse, SwarmListResponse, SwarmRunRequest, SwarmRunResponse, BlackboardResponse, HealthResponse, ErrorResponse, WebSocketMessage, WebSocketResponse, } from './types.js';
|
|
3
|
+
export { HonoStreamWriter } from './streaming/hono-stream-writer.js';
|
|
4
|
+
export { createContextMiddleware } from './middleware/context.js';
|
|
5
|
+
export { createAuthMiddleware } from './middleware/auth.js';
|
|
6
|
+
export { errorHandler } from './middleware/error-handler.js';
|
|
7
|
+
export { createHealthRoutes, createAgentRoutes, createThreadRoutes, createToolRoutes, createWorkflowRoutes, createSwarmRoutes, } from './routes/index.js';
|
|
8
|
+
export type { StreamEvent, Usage } from '@cogitator-ai/server-shared';
|
|
9
|
+
export { createStartEvent, createTextStartEvent, createTextDeltaEvent, createTextEndEvent, createToolCallStartEvent, createToolCallDeltaEvent, createToolCallEndEvent, createToolResultEvent, createErrorEvent, createFinishEvent, createWorkflowEvent, createSwarmEvent, generateId, } from '@cogitator-ai/server-shared';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,GACX,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { cogitatorApp } from './app.js';
|
|
2
|
+
export { HonoStreamWriter } from './streaming/hono-stream-writer.js';
|
|
3
|
+
export { createContextMiddleware } from './middleware/context.js';
|
|
4
|
+
export { createAuthMiddleware } from './middleware/auth.js';
|
|
5
|
+
export { errorHandler } from './middleware/error-handler.js';
|
|
6
|
+
export { createHealthRoutes, createAgentRoutes, createThreadRoutes, createToolRoutes, createWorkflowRoutes, createSwarmRoutes, } from './routes/index.js';
|
|
7
|
+
export { createStartEvent, createTextStartEvent, createTextDeltaEvent, createTextEndEvent, createToolCallStartEvent, createToolCallDeltaEvent, createToolCallEndEvent, createToolResultEvent, createErrorEvent, createFinishEvent, createWorkflowEvent, createSwarmEvent, generateId, } from '@cogitator-ai/server-shared';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA6BxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,GACX,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +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;AAEzD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,mEAcxD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createMiddleware } from 'hono/factory';
|
|
2
|
+
export function createAuthMiddleware(authFn) {
|
|
3
|
+
return createMiddleware(async (c, next) => {
|
|
4
|
+
try {
|
|
5
|
+
const ctx = c.get('cogitator');
|
|
6
|
+
const auth = await authFn(ctx);
|
|
7
|
+
c.set('cogitatorAuth', auth);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return c.json({ error: { message: 'Unauthorized', code: 'UNAUTHORIZED' } }, 401);
|
|
11
|
+
}
|
|
12
|
+
await next();
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,UAAU,oBAAoB,CAAC,MAAoB;IACvD,OAAO,gBAAgB,CAAU,KAAK,EAAE,CAAC,EAAE,IAAI,EAA4B,EAAE;QAC3E,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YAC/B,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC;YAC/B,CAAC,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,CAAC,IAAI,CACX,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAC5D,GAAG,CACJ,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/middleware/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEhE,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,mEAahE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createMiddleware } from 'hono/factory';
|
|
2
|
+
import { generateId } from '@cogitator-ai/server-shared';
|
|
3
|
+
export function createContextMiddleware(opts) {
|
|
4
|
+
return createMiddleware(async (c, next) => {
|
|
5
|
+
c.set('cogitator', {
|
|
6
|
+
runtime: opts.cogitator,
|
|
7
|
+
agents: opts.agents ?? {},
|
|
8
|
+
workflows: opts.workflows ?? {},
|
|
9
|
+
swarms: opts.swarms ?? {},
|
|
10
|
+
});
|
|
11
|
+
c.set('cogitatorRequestId', generateId('req'));
|
|
12
|
+
c.set('cogitatorStartTime', Date.now());
|
|
13
|
+
await next();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +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,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGzD,MAAM,UAAU,uBAAuB,CAAC,IAAyB;IAC/D,OAAO,gBAAgB,CAAU,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QACjD,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE;YACjB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;YAC/B,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;SAC1B,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"}
|
|
@@ -0,0 +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;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,OAAO,CAe9C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CogitatorError, ERROR_STATUS_CODES, ErrorCode } from '@cogitator-ai/types';
|
|
2
|
+
export const errorHandler = (err, c) => {
|
|
3
|
+
if (CogitatorError.isCogitatorError(err)) {
|
|
4
|
+
const statusCode = ERROR_STATUS_CODES[err.code] || 500;
|
|
5
|
+
return c.json({ error: { message: err.message, code: err.code } }, statusCode);
|
|
6
|
+
}
|
|
7
|
+
console.error('[CogitatorHono] Unhandled error:', err);
|
|
8
|
+
return c.json({ error: { message: 'Internal server error', code: ErrorCode.INTERNAL_ERROR } }, 500);
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/middleware/error-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGpF,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;IAC5D,IAAI,cAAc,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,UAAU,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;QACvD,OAAO,CAAC,CAAC,IAAI,CACX,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,EACnD,UAA0C,CAC3C,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;IAEvD,OAAO,CAAC,CAAC,IAAI,CACX,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,SAAS,CAAC,cAAc,EAAE,EAAE,EAC/E,GAAG,CACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,OAAO,KAAK,EACV,OAAO,EAIR,MAAM,aAAa,CAAC;AAGrB,wBAAgB,iBAAiB,IAAI,IAAI,CAAC,OAAO,CAAC,CA0HjD"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { streamSSE } from 'hono/streaming';
|
|
3
|
+
import { generateId } from '@cogitator-ai/server-shared';
|
|
4
|
+
import { HonoStreamWriter } from '../streaming/hono-stream-writer.js';
|
|
5
|
+
export function createAgentRoutes() {
|
|
6
|
+
const app = new Hono();
|
|
7
|
+
app.get('/agents', (c) => {
|
|
8
|
+
const ctx = c.get('cogitator');
|
|
9
|
+
const agentList = Object.entries(ctx.agents).map(([name, agent]) => ({
|
|
10
|
+
name,
|
|
11
|
+
description: agent.config.instructions?.slice(0, 100),
|
|
12
|
+
tools: agent.config.tools?.map((t) => t.name) || [],
|
|
13
|
+
}));
|
|
14
|
+
const response = { agents: agentList };
|
|
15
|
+
return c.json(response);
|
|
16
|
+
});
|
|
17
|
+
app.post('/agents/:name/run', async (c) => {
|
|
18
|
+
const ctx = c.get('cogitator');
|
|
19
|
+
const name = c.req.param('name');
|
|
20
|
+
const agent = ctx.agents[name];
|
|
21
|
+
if (!agent) {
|
|
22
|
+
return c.json({ error: { message: `Agent '${name}' not found`, code: 'NOT_FOUND' } }, 404);
|
|
23
|
+
}
|
|
24
|
+
const body = await c.req.json();
|
|
25
|
+
if (!body?.input) {
|
|
26
|
+
return c.json({ error: { message: 'Missing required field: input', code: 'INVALID_INPUT' } }, 400);
|
|
27
|
+
}
|
|
28
|
+
const result = await ctx.runtime.run(agent, {
|
|
29
|
+
input: body.input,
|
|
30
|
+
context: body.context,
|
|
31
|
+
threadId: body.threadId,
|
|
32
|
+
});
|
|
33
|
+
const response = {
|
|
34
|
+
output: result.output,
|
|
35
|
+
threadId: result.threadId,
|
|
36
|
+
usage: {
|
|
37
|
+
inputTokens: result.usage.inputTokens,
|
|
38
|
+
outputTokens: result.usage.outputTokens,
|
|
39
|
+
totalTokens: result.usage.totalTokens,
|
|
40
|
+
},
|
|
41
|
+
toolCalls: [...result.toolCalls],
|
|
42
|
+
};
|
|
43
|
+
return c.json(response);
|
|
44
|
+
});
|
|
45
|
+
app.post('/agents/:name/stream', (c) => {
|
|
46
|
+
const ctx = c.get('cogitator');
|
|
47
|
+
const name = c.req.param('name');
|
|
48
|
+
const agent = ctx.agents[name];
|
|
49
|
+
if (!agent) {
|
|
50
|
+
return c.json({ error: { message: `Agent '${name}' not found`, code: 'NOT_FOUND' } }, 404);
|
|
51
|
+
}
|
|
52
|
+
return streamSSE(c, async (stream) => {
|
|
53
|
+
const body = await c.req.json();
|
|
54
|
+
if (!body?.input) {
|
|
55
|
+
await stream.writeSSE({
|
|
56
|
+
data: JSON.stringify({ type: 'error', message: 'Missing required field: input' }),
|
|
57
|
+
event: 'message',
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const writer = new HonoStreamWriter(stream);
|
|
62
|
+
const messageId = generateId('msg');
|
|
63
|
+
stream.onAbort(() => writer.close());
|
|
64
|
+
try {
|
|
65
|
+
await writer.start(messageId);
|
|
66
|
+
const textId = generateId('txt');
|
|
67
|
+
await writer.textStart(textId);
|
|
68
|
+
const result = await ctx.runtime.run(agent, {
|
|
69
|
+
input: body.input,
|
|
70
|
+
context: body.context,
|
|
71
|
+
threadId: body.threadId,
|
|
72
|
+
stream: true,
|
|
73
|
+
onToken: (token) => {
|
|
74
|
+
void writer.textDelta(textId, token);
|
|
75
|
+
},
|
|
76
|
+
onToolCall: (toolCall) => {
|
|
77
|
+
const toolId = generateId('tool');
|
|
78
|
+
void writer.toolCallStart(toolId, toolCall.name);
|
|
79
|
+
void writer.toolCallEnd(toolId);
|
|
80
|
+
},
|
|
81
|
+
onToolResult: (toolResult) => {
|
|
82
|
+
const resultId = generateId('res');
|
|
83
|
+
void writer.toolResult(resultId, toolResult.callId, toolResult.result);
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
await writer.textEnd(textId);
|
|
87
|
+
await writer.finish(messageId, {
|
|
88
|
+
inputTokens: result.usage.inputTokens,
|
|
89
|
+
outputTokens: result.usage.outputTokens,
|
|
90
|
+
totalTokens: result.usage.totalTokens,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
95
|
+
await writer.error(message, 'INTERNAL');
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
writer.close();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
return app;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/routes/agents.ts"],"names":[],"mappings":"A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AC;YAC1C,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,aAAa,CAAC;AAI3D,wBAAgB,kBAAkB,IAAI,IAAI,CAAC,OAAO,CAAC,CAiBlD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
const startTime = Date.now();
|
|
3
|
+
export function createHealthRoutes() {
|
|
4
|
+
const app = new Hono();
|
|
5
|
+
app.get('/health', (c) => {
|
|
6
|
+
const response = {
|
|
7
|
+
status: 'ok',
|
|
8
|
+
uptime: Date.now() - startTime,
|
|
9
|
+
timestamp: Date.now(),
|
|
10
|
+
};
|
|
11
|
+
return c.json(response);
|
|
12
|
+
});
|
|
13
|
+
app.get('/ready', (c) => {
|
|
14
|
+
return c.json({ status: 'ok' });
|
|
15
|
+
});
|
|
16
|
+
return app;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAE7B,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAW,CAAC;IAEhC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAmB;YAC/B,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;YAC9B,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC;QACF,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;QACtB,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createHealthRoutes } from './health.js';
|
|
2
|
+
export { createAgentRoutes } from './agents.js';
|
|
3
|
+
export { createThreadRoutes } from './threads.js';
|
|
4
|
+
export { createToolRoutes } from './tools.js';
|
|
5
|
+
export { createWorkflowRoutes } from './workflows.js';
|
|
6
|
+
export { createSwarmRoutes } from './swarms.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createHealthRoutes } from './health.js';
|
|
2
|
+
export { createAgentRoutes } from './agents.js';
|
|
3
|
+
export { createThreadRoutes } from './threads.js';
|
|
4
|
+
export { createToolRoutes } from './tools.js';
|
|
5
|
+
export { createWorkflowRoutes } from './workflows.js';
|
|
6
|
+
export { createSwarmRoutes } from './swarms.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarms.d.ts","sourceRoot":"","sources":["../../src/routes/swarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,OAAO,KAAK,EACV,OAAO,EAKR,MAAM,aAAa,CAAC;AAGrB,wBAAgB,iBAAiB,IAAI,IAAI,CAAC,OAAO,CAAC,CAiMjD"}
|