@agi-cli/server 0.1.109 → 0.1.111

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agi-cli/server",
3
- "version": "0.1.109",
3
+ "version": "0.1.111",
4
4
  "description": "HTTP API server for AGI CLI",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -29,8 +29,8 @@
29
29
  "typecheck": "tsc --noEmit"
30
30
  },
31
31
  "dependencies": {
32
- "@agi-cli/sdk": "0.1.109",
33
- "@agi-cli/database": "0.1.109",
32
+ "@agi-cli/sdk": "0.1.111",
33
+ "@agi-cli/database": "0.1.111",
34
34
  "drizzle-orm": "^0.44.5",
35
35
  "hono": "^4.9.9",
36
36
  "zod": "^4.1.8"
@@ -43,6 +43,7 @@ export function registerModelsRoutes(app: Hono) {
43
43
  label: m.label || m.id,
44
44
  toolCall: m.toolCall,
45
45
  reasoning: m.reasoning,
46
+ vision: m.modalities?.input?.includes('image') ?? false,
46
47
  })),
47
48
  default: getDefault(
48
49
  embeddedConfig?.model,
@@ -94,6 +95,7 @@ export function registerModelsRoutes(app: Hono) {
94
95
  label: m.label || m.id,
95
96
  toolCall: m.toolCall,
96
97
  reasoning: m.reasoning,
98
+ vision: m.modalities?.input?.includes('image') ?? false,
97
99
  })),
98
100
  };
99
101
  }
@@ -111,6 +111,7 @@ export function registerSessionMessagesRoutes(app: Hono) {
111
111
  const agent = body?.agent ?? sess.agent ?? cfg.defaults.agent;
112
112
  const content = body?.content ?? '';
113
113
  const userContext = body?.userContext;
114
+ const images = Array.isArray(body?.images) ? body.images : undefined;
114
115
 
115
116
  // DEBUG: Log extracted userContext
116
117
  logger.info('[API] Extracted userContext', {
@@ -155,6 +156,7 @@ export function registerSessionMessagesRoutes(app: Hono) {
155
156
  oneShot: Boolean(body?.oneShot),
156
157
  userContext,
157
158
  reasoning,
159
+ images,
158
160
  });
159
161
  return c.json({ messageId: assistantMessageId }, 202);
160
162
  } catch (error) {
@@ -41,12 +41,27 @@ export async function buildHistoryMessages(
41
41
  if (m.role === 'user') {
42
42
  const uparts: UIMessage['parts'] = [];
43
43
  for (const p of parts) {
44
- if (p.type !== 'text') continue;
45
- try {
46
- const obj = JSON.parse(p.content ?? '{}');
47
- const t = String(obj.text ?? '');
48
- if (t) uparts.push({ type: 'text', text: t });
49
- } catch {}
44
+ if (p.type === 'text') {
45
+ try {
46
+ const obj = JSON.parse(p.content ?? '{}');
47
+ const t = String(obj.text ?? '');
48
+ if (t) uparts.push({ type: 'text', text: t });
49
+ } catch {}
50
+ } else if (p.type === 'image') {
51
+ try {
52
+ const obj = JSON.parse(p.content ?? '{}') as {
53
+ data?: string;
54
+ mediaType?: string;
55
+ };
56
+ if (obj.data && obj.mediaType) {
57
+ uparts.push({
58
+ type: 'file',
59
+ mediaType: obj.mediaType,
60
+ url: `data:${obj.mediaType};base64,${obj.data}`,
61
+ } as never);
62
+ }
63
+ } catch {}
64
+ }
50
65
  }
51
66
  if (uparts.length) {
52
67
  ui.push({ id: m.id, role: 'user', parts: uparts });
@@ -23,6 +23,7 @@ type DispatchOptions = {
23
23
  oneShot?: boolean;
24
24
  userContext?: string;
25
25
  reasoning?: boolean;
26
+ images?: Array<{ data: string; mediaType: string }>;
26
27
  };
27
28
 
28
29
  export async function dispatchAssistantMessage(
@@ -39,6 +40,7 @@ export async function dispatchAssistantMessage(
39
40
  oneShot,
40
41
  userContext,
41
42
  reasoning,
43
+ images,
42
44
  } = options;
43
45
 
44
46
  // DEBUG: Log userContext in dispatch
@@ -70,6 +72,23 @@ export async function dispatchAssistantMessage(
70
72
  provider,
71
73
  model,
72
74
  });
75
+
76
+ if (images && images.length > 0) {
77
+ for (let i = 0; i < images.length; i++) {
78
+ const img = images[i];
79
+ await db.insert(messageParts).values({
80
+ id: crypto.randomUUID(),
81
+ messageId: userMessageId,
82
+ index: i + 1,
83
+ type: 'image',
84
+ content: JSON.stringify({ data: img.data, mediaType: img.mediaType }),
85
+ agent,
86
+ provider,
87
+ model,
88
+ });
89
+ }
90
+ }
91
+
73
92
  publish({
74
93
  type: 'message.created',
75
94
  sessionId,