@agi-cli/server 0.1.116 → 0.1.118
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 +3 -3
- package/src/presets.ts +4 -4
- package/src/routes/session-messages.ts +2 -0
- package/src/runtime/agent-registry.ts +3 -3
- package/src/runtime/history-builder.ts +28 -0
- package/src/runtime/message-service.ts +31 -0
- package/src/runtime/tool-mapping.ts +2 -2
- package/src/tools/adapter.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agi-cli/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.118",
|
|
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.
|
|
33
|
-
"@agi-cli/database": "0.1.
|
|
32
|
+
"@agi-cli/sdk": "0.1.118",
|
|
33
|
+
"@agi-cli/database": "0.1.118",
|
|
34
34
|
"drizzle-orm": "^0.44.5",
|
|
35
35
|
"hono": "^4.9.9",
|
|
36
36
|
"zod": "^4.1.8"
|
package/src/presets.ts
CHANGED
|
@@ -17,7 +17,7 @@ export const BUILTIN_AGENTS = {
|
|
|
17
17
|
'ls',
|
|
18
18
|
'tree',
|
|
19
19
|
'bash',
|
|
20
|
-
'
|
|
20
|
+
'update_todos',
|
|
21
21
|
'grep',
|
|
22
22
|
'terminal',
|
|
23
23
|
'git_status',
|
|
@@ -36,7 +36,7 @@ export const BUILTIN_AGENTS = {
|
|
|
36
36
|
'ls',
|
|
37
37
|
'tree',
|
|
38
38
|
'ripgrep',
|
|
39
|
-
'
|
|
39
|
+
'update_todos',
|
|
40
40
|
'websearch',
|
|
41
41
|
'progress_update',
|
|
42
42
|
'finish',
|
|
@@ -53,7 +53,7 @@ export const BUILTIN_AGENTS = {
|
|
|
53
53
|
'ripgrep',
|
|
54
54
|
'terminal',
|
|
55
55
|
'websearch',
|
|
56
|
-
'
|
|
56
|
+
'update_todos',
|
|
57
57
|
'progress_update',
|
|
58
58
|
'finish',
|
|
59
59
|
] as string[],
|
|
@@ -73,7 +73,7 @@ export const BUILTIN_TOOLS = [
|
|
|
73
73
|
'git_diff',
|
|
74
74
|
'git_commit',
|
|
75
75
|
'apply_patch',
|
|
76
|
-
'
|
|
76
|
+
'update_todos',
|
|
77
77
|
'edit',
|
|
78
78
|
'websearch',
|
|
79
79
|
'progress_update',
|
|
@@ -112,6 +112,7 @@ export function registerSessionMessagesRoutes(app: Hono) {
|
|
|
112
112
|
const content = body?.content ?? '';
|
|
113
113
|
const userContext = body?.userContext;
|
|
114
114
|
const images = Array.isArray(body?.images) ? body.images : undefined;
|
|
115
|
+
const files = Array.isArray(body?.files) ? body.files : undefined;
|
|
115
116
|
|
|
116
117
|
// DEBUG: Log extracted userContext
|
|
117
118
|
logger.info('[API] Extracted userContext', {
|
|
@@ -157,6 +158,7 @@ export function registerSessionMessagesRoutes(app: Hono) {
|
|
|
157
158
|
userContext,
|
|
158
159
|
reasoning,
|
|
159
160
|
images,
|
|
161
|
+
files,
|
|
160
162
|
});
|
|
161
163
|
return c.json({ messageId: assistantMessageId }, 202);
|
|
162
164
|
} catch (error) {
|
|
@@ -118,7 +118,7 @@ const defaultToolExtras: Record<string, string[]> = {
|
|
|
118
118
|
'ls',
|
|
119
119
|
'tree',
|
|
120
120
|
'bash',
|
|
121
|
-
'
|
|
121
|
+
'update_todos',
|
|
122
122
|
'glob',
|
|
123
123
|
'ripgrep',
|
|
124
124
|
'git_status',
|
|
@@ -126,7 +126,7 @@ const defaultToolExtras: Record<string, string[]> = {
|
|
|
126
126
|
'apply_patch',
|
|
127
127
|
'websearch',
|
|
128
128
|
],
|
|
129
|
-
plan: ['read', 'ls', 'tree', 'ripgrep', '
|
|
129
|
+
plan: ['read', 'ls', 'tree', 'ripgrep', 'update_todos', 'websearch'],
|
|
130
130
|
general: [
|
|
131
131
|
'read',
|
|
132
132
|
'write',
|
|
@@ -136,7 +136,7 @@ const defaultToolExtras: Record<string, string[]> = {
|
|
|
136
136
|
'ripgrep',
|
|
137
137
|
'glob',
|
|
138
138
|
'websearch',
|
|
139
|
-
'
|
|
139
|
+
'update_todos',
|
|
140
140
|
],
|
|
141
141
|
git: ['git_status', 'git_diff', 'git_commit', 'read', 'ls'],
|
|
142
142
|
commit: ['git_status', 'git_diff', 'git_commit', 'read', 'ls'],
|
|
@@ -60,6 +60,34 @@ export async function buildHistoryMessages(
|
|
|
60
60
|
} as never);
|
|
61
61
|
}
|
|
62
62
|
} catch {}
|
|
63
|
+
} else if (p.type === 'file') {
|
|
64
|
+
try {
|
|
65
|
+
const obj = JSON.parse(p.content ?? '{}') as {
|
|
66
|
+
type?: 'image' | 'pdf' | 'text';
|
|
67
|
+
name?: string;
|
|
68
|
+
data?: string;
|
|
69
|
+
mediaType?: string;
|
|
70
|
+
textContent?: string;
|
|
71
|
+
};
|
|
72
|
+
if (obj.type === 'text' && obj.textContent) {
|
|
73
|
+
uparts.push({
|
|
74
|
+
type: 'text',
|
|
75
|
+
text: `<file name="${obj.name || 'file'}">\n${obj.textContent}\n</file>`,
|
|
76
|
+
});
|
|
77
|
+
} else if (obj.type === 'pdf' && obj.data && obj.mediaType) {
|
|
78
|
+
uparts.push({
|
|
79
|
+
type: 'file',
|
|
80
|
+
mediaType: obj.mediaType,
|
|
81
|
+
url: `data:${obj.mediaType};base64,${obj.data}`,
|
|
82
|
+
} as never);
|
|
83
|
+
} else if (obj.type === 'image' && obj.data && obj.mediaType) {
|
|
84
|
+
uparts.push({
|
|
85
|
+
type: 'file',
|
|
86
|
+
mediaType: obj.mediaType,
|
|
87
|
+
url: `data:${obj.mediaType};base64,${obj.data}`,
|
|
88
|
+
} as never);
|
|
89
|
+
}
|
|
90
|
+
} catch {}
|
|
63
91
|
}
|
|
64
92
|
}
|
|
65
93
|
if (uparts.length) {
|
|
@@ -25,6 +25,13 @@ type DispatchOptions = {
|
|
|
25
25
|
userContext?: string;
|
|
26
26
|
reasoning?: boolean;
|
|
27
27
|
images?: Array<{ data: string; mediaType: string }>;
|
|
28
|
+
files?: Array<{
|
|
29
|
+
type: 'image' | 'pdf' | 'text';
|
|
30
|
+
name: string;
|
|
31
|
+
data: string;
|
|
32
|
+
mediaType: string;
|
|
33
|
+
textContent?: string;
|
|
34
|
+
}>;
|
|
28
35
|
};
|
|
29
36
|
|
|
30
37
|
export async function dispatchAssistantMessage(
|
|
@@ -42,6 +49,7 @@ export async function dispatchAssistantMessage(
|
|
|
42
49
|
userContext,
|
|
43
50
|
reasoning,
|
|
44
51
|
images,
|
|
52
|
+
files,
|
|
45
53
|
} = options;
|
|
46
54
|
|
|
47
55
|
// DEBUG: Log userContext in dispatch
|
|
@@ -90,6 +98,29 @@ export async function dispatchAssistantMessage(
|
|
|
90
98
|
}
|
|
91
99
|
}
|
|
92
100
|
|
|
101
|
+
let nextIndex = (images?.length ?? 0) + 1;
|
|
102
|
+
if (files && files.length > 0) {
|
|
103
|
+
for (const file of files) {
|
|
104
|
+
const partType = file.type === 'image' ? 'image' : 'file';
|
|
105
|
+
await db.insert(messageParts).values({
|
|
106
|
+
id: crypto.randomUUID(),
|
|
107
|
+
messageId: userMessageId,
|
|
108
|
+
index: nextIndex++,
|
|
109
|
+
type: partType,
|
|
110
|
+
content: JSON.stringify({
|
|
111
|
+
type: file.type,
|
|
112
|
+
name: file.name,
|
|
113
|
+
data: file.data,
|
|
114
|
+
mediaType: file.mediaType,
|
|
115
|
+
textContent: file.textContent,
|
|
116
|
+
}),
|
|
117
|
+
agent,
|
|
118
|
+
provider,
|
|
119
|
+
model,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
93
124
|
publish({
|
|
94
125
|
type: 'message.created',
|
|
95
126
|
sessionId,
|
|
@@ -42,7 +42,7 @@ export const CANONICAL_TO_PASCAL: Record<string, string> = {
|
|
|
42
42
|
apply_patch: 'ApplyPatch',
|
|
43
43
|
|
|
44
44
|
// Task management
|
|
45
|
-
|
|
45
|
+
update_todos: 'UpdateTodos',
|
|
46
46
|
progress_update: 'ProgressUpdate',
|
|
47
47
|
finish: 'Finish',
|
|
48
48
|
|
|
@@ -81,7 +81,7 @@ export const PASCAL_TO_CANONICAL: Record<string, string> = {
|
|
|
81
81
|
ApplyPatch: 'apply_patch',
|
|
82
82
|
|
|
83
83
|
// Task management
|
|
84
|
-
|
|
84
|
+
UpdateTodos: 'update_todos',
|
|
85
85
|
ProgressUpdate: 'progress_update',
|
|
86
86
|
Finish: 'finish',
|
|
87
87
|
|
package/src/tools/adapter.ts
CHANGED
|
@@ -522,7 +522,7 @@ export function adaptTools(
|
|
|
522
522
|
sessionId: ctx.sessionId,
|
|
523
523
|
payload: { ...contentObj, stepIndex: stepIndexForEvent },
|
|
524
524
|
});
|
|
525
|
-
if (name === '
|
|
525
|
+
if (name === 'update_todos') {
|
|
526
526
|
try {
|
|
527
527
|
const resultValue = (contentObj as { result?: unknown })
|
|
528
528
|
.result as { items?: unknown; note?: unknown } | undefined;
|