@kuralle-agents/hono-server 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +30 -7
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createUIMessageStreamResponse } from 'ai';
2
2
  import { Hono } from 'hono';
3
3
  import { streamSSE } from 'hono/streaming';
4
- import { harnessToUIMessageStream } from '@kuralle-agents/core';
4
+ import { harnessToUIMessageStream, userInputToText } from '@kuralle-agents/core';
5
5
  // PR-20 — re-export the OpenAI-compatible router. Lets consumers do:
6
6
  // import { createOpenAICompatRouter } from '@kuralle-agents/hono-server';
7
7
  export { createOpenAICompatRouter, } from './openaiCompat.js';
@@ -18,6 +18,28 @@ const parseJsonBody = async (c) => {
18
18
  }
19
19
  };
20
20
  const wantsRawStreamFormat = (c) => c.req.query('format') === 'raw';
21
+ /**
22
+ * Map a UIMessage's parts to runtime `UserInputContent`. Text-only input collapses
23
+ * to a plain string (byte-identical to the prior text-only behavior); when any file
24
+ * part is present, returns AI SDK multimodal content (text + file parts) so images,
25
+ * documents, and voice notes reach the model instead of being dropped.
26
+ */
27
+ const partsToUserInput = (parts) => {
28
+ const content = [];
29
+ for (const p of parts) {
30
+ if (p.type === 'text' && typeof p.text === 'string') {
31
+ content.push({ type: 'text', text: p.text });
32
+ }
33
+ else if (p.type === 'file' && typeof p.url === 'string' && typeof p.mediaType === 'string') {
34
+ content.push({ type: 'file', data: p.url, mediaType: p.mediaType, filename: p.filename });
35
+ }
36
+ }
37
+ const hasFile = content.some((part) => part.type === 'file');
38
+ if (!hasFile) {
39
+ return content.map((part) => (part.type === 'text' ? part.text : '')).join('');
40
+ }
41
+ return content;
42
+ };
21
43
  const extractInputFromBody = (body) => {
22
44
  if (typeof body.message === 'string') {
23
45
  return { input: body.message, sessionId: body.sessionId };
@@ -26,10 +48,7 @@ const extractInputFromBody = (body) => {
26
48
  const messages = body.messages;
27
49
  const lastMessage = messages[messages.length - 1];
28
50
  if (lastMessage.parts && Array.isArray(lastMessage.parts)) {
29
- const input = lastMessage.parts
30
- .filter((p) => p.type === 'text')
31
- .map((p) => p.text ?? '')
32
- .join('');
51
+ const input = partsToUserInput(lastMessage.parts);
33
52
  const sessionId = typeof body.sessionId === 'string'
34
53
  ? body.sessionId
35
54
  : typeof body.id === 'string'
@@ -639,7 +658,9 @@ export const createKuralleRouter = ({ flowManager, sessionId, upgradeWebSocket,
639
658
  if (!body) {
640
659
  return c.json({ error: 'invalid body' }, 400);
641
660
  }
642
- const { input, sessionId } = extractInputFromBody(body);
661
+ const { input: rawInput, sessionId } = extractInputFromBody(body);
662
+ // The legacy flow processor is string-only; media degrades to its text projection.
663
+ const input = userInputToText(rawInput);
643
664
  if (!input) {
644
665
  return c.json({ error: 'message required' }, 400);
645
666
  }
@@ -671,7 +692,9 @@ export const createKuralleRouter = ({ flowManager, sessionId, upgradeWebSocket,
671
692
  if (!body) {
672
693
  return c.json({ error: 'invalid body' }, 400);
673
694
  }
674
- const { input, sessionId: bodySessionId } = extractInputFromBody(body);
695
+ const { input: rawInput, sessionId: bodySessionId } = extractInputFromBody(body);
696
+ // The legacy flow processor is string-only; media degrades to its text projection.
697
+ const input = userInputToText(rawInput);
675
698
  if (!input) {
676
699
  return c.json({ error: 'message required' }, 400);
677
700
  }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "git+https://github.com/kuralle/kuralle-agents.git",
7
7
  "directory": "packages/kuralle-hono-server"
8
8
  },
9
- "version": "0.7.2",
9
+ "version": "0.8.0",
10
10
  "description": "Hono router for hosting Kuralle createRuntime() over HTTP, SSE, and WebSocket",
11
11
  "type": "module",
12
12
  "main": "dist/index.js",
@@ -20,10 +20,10 @@
20
20
  "dependencies": {
21
21
  "ai": "^6.0.0",
22
22
  "hono": "^4.0.0",
23
- "@kuralle-agents/core": "0.7.2"
23
+ "@kuralle-agents/core": "0.8.0"
24
24
  },
25
25
  "peerDependencies": {
26
- "@kuralle-agents/core": "0.7.2"
26
+ "@kuralle-agents/core": "0.8.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@ai-sdk/openai": "^3.0.0",