@cogitator-ai/hono 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 CHANGED
@@ -15,8 +15,14 @@ import { Hono } from 'hono';
15
15
  import { Cogitator, Agent } from '@cogitator-ai/core';
16
16
  import { cogitatorApp } from '@cogitator-ai/hono';
17
17
 
18
- const cogitator = new Cogitator({/* ... */});
19
- const chatAgent = new Agent({ name: 'chat', instructions: 'You are a helpful assistant.' });
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 Hono();
22
28
 
@@ -38,26 +44,27 @@ Creates a Hono sub-application with all Cogitator endpoints.
38
44
 
39
45
  **Options:**
40
46
 
41
- | Option | Type | Description |
42
- | ----------------- | ----------------------------- | ----------------------------------------------- |
43
- | `cogitator` | `Cogitator` | **Required.** Cogitator runtime instance |
44
- | `agents` | `Record<string, Agent>` | Named agents to expose |
45
- | `workflows` | `Record<string, Workflow>` | Named workflows |
46
- | `swarms` | `Record<string, SwarmConfig>` | Named swarms |
47
- | `auth` | `(c: Context) => AuthContext` | Authentication function (receives Hono Context) |
48
- | `enableSwagger` | `boolean` | Enable Swagger/OpenAPI docs |
49
- | `swagger` | `SwaggerConfig` | Swagger configuration |
50
- | `enableWebSocket` | `boolean` | Enable the WebSocket endpoint |
51
- | `websocket` | `WebSocketConfig` | WebSocket configuration (see below) |
52
- | `bodyLimit` | `number` | Max request body size in bytes (default 1 MiB) |
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) |
53
59
 
54
60
  ## Request Handling
55
61
 
56
62
  - 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.
57
63
  - 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`.
58
64
  - Thread messages accept `role` of `user`, `assistant` or `system`; `metadata` is stored with the entry and a token estimate is recorded.
65
+ - 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`.
59
66
  - Bodies above `bodyLimit` return `413 PAYLOAD_TOO_LARGE`.
60
- - `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` without internal details. A workflow that finishes with an error is reported as an error, never as a successful result.
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 @@ Creates a Hono sub-application with all Cogitator endpoints.
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
@@ -169,7 +183,7 @@ export default app;
169
183
  Deno.serve(app.fetch);
170
184
  ```
171
185
 
172
- On Cloudflare Workers use a `compatibility_date` of 2026-08-04 or later (or the `nodejs_compat` flag); with database memory create the `Cogitator` per request, since Workers do not share connections between requests. Deno needs only `--allow-net` and `--allow-env`. Complete projects: [`09-deno-server.ts`](../../examples/integrations/09-deno-server.ts), [`10-cloudflare-worker`](../../examples/integrations/10-cloudflare-worker).
186
+ On Cloudflare Workers use a `compatibility_date` of 2026-08-04 or later (or the `nodejs_compat` flag); with database memory create the `Cogitator` per request, since Workers do not share connections between requests. Deno needs only `--allow-net` and `--allow-env`. Complete projects: [`09-deno-server.ts`](https://github.com/cogitator-ai/Cogitator-AI/blob/main/examples/integrations/09-deno-server.ts), [`10-cloudflare-worker`](https://github.com/cogitator-ai/Cogitator-AI/tree/main/examples/integrations/10-cloudflare-worker). See also [cogitator.app/docs/deployment/edge](https://cogitator.app/docs/deployment/edge).
173
187
 
174
188
  ## SSE Streaming
175
189
 
@@ -179,6 +193,28 @@ Agent streams emit `tool-call-start`, `tool-call-delta` (the JSON arguments) and
179
193
 
180
194
  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.
181
195
 
196
+ 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.
197
+
198
+ For custom routes, `HonoStreamWriter` wraps the stream of Hono's `streamSSE`; its methods (`start`, `textDelta`, `toolCallStart`, `approvalRequired`, `workflowEvent`, `finish`, …) return promises:
199
+
200
+ ```typescript
201
+ import { streamSSE } from 'hono/streaming';
202
+ import { HonoStreamWriter, generateId } from '@cogitator-ai/hono';
203
+
204
+ app.post('/custom/stream', (c) =>
205
+ streamSSE(c, async (stream) => {
206
+ const writer = new HonoStreamWriter(stream);
207
+ const messageId = generateId('msg');
208
+ const textId = generateId('txt');
209
+ await writer.start(messageId);
210
+ await writer.textStart(textId);
211
+ await writer.textDelta(textId, 'Hello!');
212
+ await writer.textEnd(textId);
213
+ await writer.finish(messageId);
214
+ })
215
+ );
216
+ ```
217
+
182
218
  ## WebSocket
183
219
 
184
220
  WebSocket upgrades are runtime-specific in Hono, so pass the `upgradeWebSocket` helper of your runtime. The endpoint goes through the same middleware as the REST routes, including `auth`.
@@ -242,6 +278,10 @@ import {
242
278
  } from '@cogitator-ai/hono';
243
279
  ```
244
280
 
281
+ ## Documentation
282
+
283
+ Full guide: [cogitator.app/docs/server-adapters/hono](https://cogitator.app/docs/server-adapters/hono). Tool approvals: [cogitator.app/docs/tools/approvals](https://cogitator.app/docs/tools/approvals).
284
+
245
285
  ## License
246
286
 
247
287
  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,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAgB/D,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,CA4BrE"}
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;AAgB/D,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,CA+BrE"}
package/dist/app.js CHANGED
@@ -20,7 +20,7 @@ export function cogitatorApp(opts) {
20
20
  app.route('/', createWorkflowRoutes());
21
21
  app.route('/', createSwarmRoutes());
22
22
  if (opts.enableSwagger) {
23
- app.route('/', createSwaggerRoutes(opts.swagger));
23
+ app.route('/', createSwaggerRoutes({ ...opts.swagger, auth: opts.swagger?.auth ?? Boolean(opts.auth) }));
24
24
  }
25
25
  if (opts.enableWebSocket) {
26
26
  app.route('/', createWebSocketRoutes(opts.websocket));
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;AAC5D,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,OAAO,EAAE,mBAAmB,EAAE,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C,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,aAAa,EAAE,CAAC;QACvB,GAAG,CAAC,KAAK,CACP,GAAG,EACH,mBAAmB,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CACzF,CAAC;IACJ,CAAC;IAED,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,OAAO,CAAC,YAAY,CAAC,CAAC;IAE1B,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/swagger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAErC,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,CAgCzE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/swagger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAQrC,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,CAsCzE"}
@@ -1,26 +1,34 @@
1
1
  import { Hono } from 'hono';
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 app = new Hono();
5
10
  let cachedSpec;
6
- function getSpec(ctx) {
11
+ function getSpec(ctx, basePath) {
7
12
  if (!cachedSpec) {
8
13
  const openAPICtx = {
9
14
  agents: ctx.agents,
10
15
  workflows: ctx.workflows,
11
16
  swarms: ctx.swarms,
12
17
  };
13
- cachedSpec = generateOpenAPISpec(openAPICtx, config ?? {});
18
+ cachedSpec = generateOpenAPISpec(openAPICtx, {
19
+ ...config,
20
+ servers: config?.servers ?? [{ url: basePath }],
21
+ });
14
22
  }
15
23
  return cachedSpec;
16
24
  }
17
25
  app.get('/openapi.json', (c) => {
18
26
  const ctx = c.get('cogitator');
19
- return c.json(getSpec(ctx));
27
+ return c.json(getSpec(ctx, mountPath(c.req.path, '/openapi.json')));
20
28
  });
21
29
  app.get('/docs', (c) => {
22
30
  const ctx = c.get('cogitator');
23
- return c.html(generateSwaggerHTML(getSpec(ctx)));
31
+ return c.html(generateSwaggerHTML(getSpec(ctx, mountPath(c.req.path, '/docs'))));
24
32
  });
25
33
  return app;
26
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/swagger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,6BAA6B,CAAC;AAErC,MAAM,UAAU,mBAAmB,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EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAsB,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,oBAAoB,CAAC;IAC7B,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAI7D;AAMD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,oBAAoB,CAGhF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAazE"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAiC,MAAM,qBAAqB,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,oBAAoB,CAAC;IAC7B,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAI7D;AAMD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,oBAAoB,CAGhF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAazE"}
@@ -1,4 +1,4 @@
1
- import { CogitatorError, ERROR_STATUS_CODES } from '@cogitator-ai/types';
1
+ import { 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;
@@ -22,7 +22,7 @@ export function resolveError(error, label) {
22
22
  console.error(`[CogitatorHono] ${label}:`, error);
23
23
  return {
24
24
  status: 500,
25
- body: { error: { message: 'Internal server error', code: 'INTERNAL' } },
25
+ body: { error: { message: 'Internal server error', code: ErrorCode.INTERNAL_ERROR } },
26
26
  };
27
27
  }
28
28
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAQzE,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,SAAS,aAAa,CAAC,MAAc;IACnC,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAqB;IACxD,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,IAAI,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;IACzE,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CA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GAAG,CAAC;IACzE,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,KAAa;IACxD,IAAI,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO;YACL,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC;YACnC,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,mBAAmB,KAAK,GAAG,EAAE,KAAK,CAAC,CAAC;IAClD,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/hono",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Hono server adapter for Cogitator AI runtime — works on Node.js, Bun, Deno, Cloudflare Workers",
5
5
  "type": "module",
6
6
  "exports": {
@@ -18,21 +18,21 @@
18
18
  "node": ">=22.12.0"
19
19
  },
20
20
  "dependencies": {
21
- "@cogitator-ai/core": "0.25.0",
22
- "@cogitator-ai/memory": "0.10.0",
23
- "@cogitator-ai/types": "0.28.0",
24
- "@cogitator-ai/server-shared": "0.3.0"
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
  "hono": ">=4.0.0"
28
28
  },
29
29
  "optionalDependencies": {
30
- "@cogitator-ai/workflows": "0.9.0",
31
- "@cogitator-ai/swarms": "0.8.2"
30
+ "@cogitator-ai/workflows": "0.10.0",
31
+ "@cogitator-ai/swarms": "0.9.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@cogitator-ai/workflows": "0.9.0",
35
- "@cogitator-ai/swarms": "0.8.2",
34
+ "@cogitator-ai/workflows": "0.10.0",
35
+ "@cogitator-ai/swarms": "0.9.0",
36
36
  "@types/node": "^22.20.4",
37
37
  "hono": "^4.13.12",
38
38
  "typescript": "^6.0.3",