bingocode 1.0.27 → 1.0.28
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 +1 -2
- package/.github/FUNDING.yml +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -44
- package/.github/ISSUE_TEMPLATE/config.yml +0 -1
- package/.github/ISSUE_TEMPLATE/question.md +0 -40
- package/.github/workflows/build-desktop-dev.yml +0 -210
- package/.github/workflows/deploy-docs.yml +0 -59
- package/.github/workflows/release-desktop.yml +0 -162
- package/.spine/user.yaml +0 -5
- package/.spine/workspace.yaml +0 -1
- package/adapters/common/__tests__/chat-queue.test.ts +0 -61
- package/adapters/common/__tests__/format.test.ts +0 -148
- package/adapters/common/__tests__/http-client.test.ts +0 -105
- package/adapters/common/__tests__/message-buffer.test.ts +0 -84
- package/adapters/common/__tests__/message-dedup.test.ts +0 -57
- package/adapters/common/__tests__/session-store.test.ts +0 -62
- package/adapters/common/__tests__/ws-bridge.test.ts +0 -177
- package/adapters/common/attachment/__tests__/attachment-limits.test.ts +0 -52
- package/adapters/common/attachment/__tests__/attachment-store.test.ts +0 -108
- package/adapters/common/attachment/__tests__/image-block-watcher.test.ts +0 -115
- package/adapters/feishu/__tests__/card-errors.test.ts +0 -194
- package/adapters/feishu/__tests__/cardkit.test.ts +0 -295
- package/adapters/feishu/__tests__/extract-payload.test.ts +0 -77
- package/adapters/feishu/__tests__/feishu.test.ts +0 -907
- package/adapters/feishu/__tests__/flush-controller.test.ts +0 -290
- package/adapters/feishu/__tests__/markdown-style.test.ts +0 -353
- package/adapters/feishu/__tests__/media.test.ts +0 -120
- package/adapters/feishu/__tests__/streaming-card.test.ts +0 -914
- package/adapters/telegram/__tests__/media.test.ts +0 -86
- package/adapters/telegram/__tests__/telegram.test.ts +0 -115
- package/adapters/tsconfig.json +0 -18
- package/bunfig.toml +0 -1
- package/preload.ts +0 -30
- package/scripts/count-app-loc.ts +0 -256
- package/scripts/release.ts +0 -130
- package/src/server/__tests__/conversation-service.test.ts +0 -173
- package/src/server/__tests__/conversations.test.ts +0 -458
- package/src/server/__tests__/cron-scheduler.test.ts +0 -575
- package/src/server/__tests__/e2e/business-flow.test.ts +0 -841
- package/src/server/__tests__/e2e/full-flow.test.ts +0 -357
- package/src/server/__tests__/fixtures/mock-sdk-cli.ts +0 -123
- package/src/server/__tests__/haha-oauth-api.test.ts +0 -146
- package/src/server/__tests__/haha-oauth-service.test.ts +0 -185
- package/src/server/__tests__/providers-real.test.ts +0 -244
- package/src/server/__tests__/providers.test.ts +0 -579
- package/src/server/__tests__/proxy-streaming.test.ts +0 -317
- package/src/server/__tests__/proxy-transform.test.ts +0 -469
- package/src/server/__tests__/real-llm-test.ts +0 -526
- package/src/server/__tests__/scheduled-tasks.test.ts +0 -371
- package/src/server/__tests__/sessions.test.ts +0 -786
- package/src/server/__tests__/settings.test.ts +0 -376
- package/src/server/__tests__/skills.test.ts +0 -125
- package/src/server/__tests__/tasks.test.ts +0 -171
- package/src/server/__tests__/team-watcher.test.ts +0 -400
- package/src/server/__tests__/teams.test.ts +0 -627
- package/src/server/middleware/cors.test.ts +0 -27
- package/src/utils/__tests__/cronFrequency.test.ts +0 -153
- package/src/utils/__tests__/cronTasks.test.ts +0 -204
- package/src/utils/computerUse/permissions.test.ts +0 -44
- package/stubs/ant-claude-for-chrome-mcp.ts +0 -24
- package/stubs/color-diff-napi.ts +0 -45
- package/tsconfig.json +0 -24
|
@@ -1,526 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Real LLM Integration Test
|
|
3
|
-
*
|
|
4
|
-
* 真实调用 MiniMax API,验证完整的 WebSocket 对话流:
|
|
5
|
-
* Server → CLI subprocess → MiniMax API → streaming response → WebSocket → client
|
|
6
|
-
*
|
|
7
|
-
* 使用 .env 中的 MiniMax 配置。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const SERVER_PORT = 19876
|
|
11
|
-
const BASE_URL = `http://127.0.0.1:${SERVER_PORT}`
|
|
12
|
-
const WS_URL = `ws://127.0.0.1:${SERVER_PORT}`
|
|
13
|
-
|
|
14
|
-
// Generate a valid UUID for session ID (CLI requires UUID format)
|
|
15
|
-
function uuid(): string {
|
|
16
|
-
return crypto.randomUUID()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function sleep(ms: number) {
|
|
20
|
-
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// ─── Test helpers ──────────────────────────────────────────────────────────
|
|
24
|
-
|
|
25
|
-
type ServerMsg = {
|
|
26
|
-
type: string
|
|
27
|
-
[key: string]: any
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function createWebSocket(sessionId: string): Promise<{
|
|
31
|
-
ws: WebSocket
|
|
32
|
-
messages: ServerMsg[]
|
|
33
|
-
waitForType: (type: string, timeoutMs?: number) => Promise<ServerMsg>
|
|
34
|
-
waitForAny: (types: string[], timeoutMs?: number) => Promise<ServerMsg>
|
|
35
|
-
close: () => void
|
|
36
|
-
}> {
|
|
37
|
-
return new Promise((resolve, reject) => {
|
|
38
|
-
const messages: ServerMsg[] = []
|
|
39
|
-
const waiters: Array<{
|
|
40
|
-
types: string[]
|
|
41
|
-
resolve: (msg: ServerMsg) => void
|
|
42
|
-
reject: (err: Error) => void
|
|
43
|
-
}> = []
|
|
44
|
-
|
|
45
|
-
const ws = new WebSocket(`${WS_URL}/ws/${sessionId}`)
|
|
46
|
-
|
|
47
|
-
ws.onmessage = (event) => {
|
|
48
|
-
try {
|
|
49
|
-
const msg = JSON.parse(event.data as string) as ServerMsg
|
|
50
|
-
messages.push(msg)
|
|
51
|
-
// Check waiters
|
|
52
|
-
for (let i = waiters.length - 1; i >= 0; i--) {
|
|
53
|
-
if (waiters[i].types.includes(msg.type)) {
|
|
54
|
-
waiters[i].resolve(msg)
|
|
55
|
-
waiters.splice(i, 1)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} catch (e) {
|
|
59
|
-
console.error('Failed to parse WS message:', event.data)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
ws.onerror = (event) => {
|
|
64
|
-
reject(new Error(`WebSocket error`))
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
ws.onopen = () => {
|
|
68
|
-
resolve({
|
|
69
|
-
ws,
|
|
70
|
-
messages,
|
|
71
|
-
waitForType(type: string, timeoutMs = 60000) {
|
|
72
|
-
// Check existing messages first
|
|
73
|
-
const existing = messages.find((m) => m.type === type)
|
|
74
|
-
if (existing) return Promise.resolve(existing)
|
|
75
|
-
|
|
76
|
-
return new Promise((res, rej) => {
|
|
77
|
-
const timer = setTimeout(() => {
|
|
78
|
-
rej(
|
|
79
|
-
new Error(
|
|
80
|
-
`Timeout waiting for message type "${type}" after ${timeoutMs}ms. Got: ${messages.map((m) => m.type).join(', ')}`
|
|
81
|
-
)
|
|
82
|
-
)
|
|
83
|
-
}, timeoutMs)
|
|
84
|
-
waiters.push({
|
|
85
|
-
types: [type],
|
|
86
|
-
resolve: (msg) => {
|
|
87
|
-
clearTimeout(timer)
|
|
88
|
-
res(msg)
|
|
89
|
-
},
|
|
90
|
-
reject: rej,
|
|
91
|
-
})
|
|
92
|
-
})
|
|
93
|
-
},
|
|
94
|
-
waitForAny(types: string[], timeoutMs = 60000) {
|
|
95
|
-
const existing = messages.find((m) => types.includes(m.type))
|
|
96
|
-
if (existing) return Promise.resolve(existing)
|
|
97
|
-
|
|
98
|
-
return new Promise((res, rej) => {
|
|
99
|
-
const timer = setTimeout(() => {
|
|
100
|
-
rej(
|
|
101
|
-
new Error(
|
|
102
|
-
`Timeout waiting for any of [${types.join(', ')}] after ${timeoutMs}ms. Got: ${messages.map((m) => m.type).join(', ')}`
|
|
103
|
-
)
|
|
104
|
-
)
|
|
105
|
-
}, timeoutMs)
|
|
106
|
-
waiters.push({
|
|
107
|
-
types,
|
|
108
|
-
resolve: (msg) => {
|
|
109
|
-
clearTimeout(timer)
|
|
110
|
-
res(msg)
|
|
111
|
-
},
|
|
112
|
-
reject: rej,
|
|
113
|
-
})
|
|
114
|
-
})
|
|
115
|
-
},
|
|
116
|
-
close() {
|
|
117
|
-
ws.close()
|
|
118
|
-
},
|
|
119
|
-
})
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// ─── Tests ─────────────────────────────────────────────────────────────────
|
|
125
|
-
|
|
126
|
-
let server: ReturnType<typeof import('../index.js').startServer> | null = null
|
|
127
|
-
|
|
128
|
-
async function startTestServer() {
|
|
129
|
-
const { startServer } = await import('../index.js')
|
|
130
|
-
server = startServer(SERVER_PORT, '127.0.0.1')
|
|
131
|
-
await sleep(500) // Let server start
|
|
132
|
-
console.log(`\n✅ Server started on port ${SERVER_PORT}`)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async function stopTestServer() {
|
|
136
|
-
if (server) {
|
|
137
|
-
server.stop(true)
|
|
138
|
-
server = null
|
|
139
|
-
await sleep(200)
|
|
140
|
-
console.log('✅ Server stopped')
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// ── Test 1: REST API health check ──────────────────────────────────────
|
|
145
|
-
|
|
146
|
-
async function testHealthCheck() {
|
|
147
|
-
console.log('\n── Test 1: Health Check ──')
|
|
148
|
-
const res = await fetch(`${BASE_URL}/health`)
|
|
149
|
-
const body = await res.json()
|
|
150
|
-
if (res.status !== 200 || body.status !== 'ok') {
|
|
151
|
-
throw new Error(`Health check failed: ${JSON.stringify(body)}`)
|
|
152
|
-
}
|
|
153
|
-
console.log('✅ Health check passed')
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// ── Test 2: REST API sessions ──────────────────────────────────────────
|
|
157
|
-
|
|
158
|
-
async function testSessionsApi() {
|
|
159
|
-
console.log('\n── Test 2: Sessions API ──')
|
|
160
|
-
const res = await fetch(`${BASE_URL}/api/sessions`)
|
|
161
|
-
if (res.status !== 200) {
|
|
162
|
-
throw new Error(`Sessions API failed: ${res.status}`)
|
|
163
|
-
}
|
|
164
|
-
const body = await res.json()
|
|
165
|
-
console.log(`✅ Sessions API returned ${body.sessions?.length ?? 0} sessions`)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// ── Test 3: REST API settings ──────────────────────────────────────────
|
|
169
|
-
|
|
170
|
-
async function testSettingsApi() {
|
|
171
|
-
console.log('\n── Test 3: Settings API ──')
|
|
172
|
-
const res = await fetch(`${BASE_URL}/api/settings`)
|
|
173
|
-
if (res.status !== 200) {
|
|
174
|
-
throw new Error(`Settings API failed: ${res.status}`)
|
|
175
|
-
}
|
|
176
|
-
const body = await res.json()
|
|
177
|
-
console.log(`✅ Settings API returned:`, Object.keys(body.settings || body))
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// ── Test 4: REST API models ────────────────────────────────────────────
|
|
181
|
-
|
|
182
|
-
async function testModelsApi() {
|
|
183
|
-
console.log('\n── Test 4: Models API ──')
|
|
184
|
-
const res = await fetch(`${BASE_URL}/api/models`)
|
|
185
|
-
if (res.status !== 200) {
|
|
186
|
-
throw new Error(`Models API failed: ${res.status}`)
|
|
187
|
-
}
|
|
188
|
-
const body = await res.json()
|
|
189
|
-
console.log(`✅ Models API returned:`, body)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// ── Test 5: WebSocket connection ───────────────────────────────────────
|
|
193
|
-
|
|
194
|
-
async function testWebSocketConnect() {
|
|
195
|
-
console.log('\n── Test 5: WebSocket Connect ──')
|
|
196
|
-
const sessionId = uuid()
|
|
197
|
-
const client = await createWebSocket(sessionId)
|
|
198
|
-
const connMsg = await client.waitForType('connected', 5000)
|
|
199
|
-
if (connMsg.sessionId !== sessionId) {
|
|
200
|
-
throw new Error(`Session ID mismatch: ${connMsg.sessionId} !== ${sessionId}`)
|
|
201
|
-
}
|
|
202
|
-
client.close()
|
|
203
|
-
await sleep(200)
|
|
204
|
-
console.log('✅ WebSocket connected and received session ID')
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// ── Test 6: WebSocket ping/pong ────────────────────────────────────────
|
|
208
|
-
|
|
209
|
-
async function testWebSocketPing() {
|
|
210
|
-
console.log('\n── Test 6: WebSocket Ping/Pong ──')
|
|
211
|
-
const sessionId = uuid()
|
|
212
|
-
const client = await createWebSocket(sessionId)
|
|
213
|
-
await client.waitForType('connected', 5000)
|
|
214
|
-
|
|
215
|
-
client.ws.send(JSON.stringify({ type: 'ping' }))
|
|
216
|
-
const pong = await client.waitForType('pong', 5000)
|
|
217
|
-
if (pong.type !== 'pong') {
|
|
218
|
-
throw new Error('Pong not received')
|
|
219
|
-
}
|
|
220
|
-
client.close()
|
|
221
|
-
await sleep(200)
|
|
222
|
-
console.log('✅ Ping/Pong works')
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// ── Test 7: Real LLM chat (the critical test!) ────────────────────────
|
|
226
|
-
|
|
227
|
-
async function testRealLLMChat() {
|
|
228
|
-
console.log('\n── Test 7: Real LLM Chat (MiniMax API) ──')
|
|
229
|
-
console.log(' This will spawn a CLI subprocess and call the real API...')
|
|
230
|
-
|
|
231
|
-
const sessionId = uuid()
|
|
232
|
-
const client = await createWebSocket(sessionId)
|
|
233
|
-
await client.waitForType('connected', 5000)
|
|
234
|
-
console.log(` Session: ${sessionId}`)
|
|
235
|
-
|
|
236
|
-
// Send a simple message
|
|
237
|
-
client.ws.send(
|
|
238
|
-
JSON.stringify({
|
|
239
|
-
type: 'user_message',
|
|
240
|
-
content: 'Say "hello world" and nothing else. Keep it short.',
|
|
241
|
-
})
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
console.log(' Message sent, waiting for response...')
|
|
245
|
-
|
|
246
|
-
// We should get a status:thinking first
|
|
247
|
-
const statusMsg = await client.waitForType('status', 10000)
|
|
248
|
-
console.log(` Got status: ${statusMsg.state} ${statusMsg.verb || ''}`)
|
|
249
|
-
|
|
250
|
-
// Wait for either content_delta (success) or error
|
|
251
|
-
const responseMsg = await client.waitForAny(
|
|
252
|
-
['content_delta', 'content_start', 'error', 'message_complete'],
|
|
253
|
-
120000 // 2 minutes for LLM response
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
console.log(` Got response type: ${responseMsg.type}`)
|
|
257
|
-
|
|
258
|
-
if (responseMsg.type === 'error') {
|
|
259
|
-
console.log(` ❌ Error: ${responseMsg.message} (code: ${responseMsg.code})`)
|
|
260
|
-
throw new Error(`LLM returned error: ${responseMsg.message}`)
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// Collect all messages until message_complete
|
|
264
|
-
let fullText = ''
|
|
265
|
-
if (responseMsg.type === 'content_delta' && responseMsg.text) {
|
|
266
|
-
fullText += responseMsg.text
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// Wait for message_complete
|
|
270
|
-
try {
|
|
271
|
-
const complete = await client.waitForType('message_complete', 120000)
|
|
272
|
-
console.log(` Usage: input=${complete.usage?.input_tokens}, output=${complete.usage?.output_tokens}`)
|
|
273
|
-
} catch {
|
|
274
|
-
console.log(' Warning: message_complete not received within timeout')
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// Gather all content_delta text
|
|
278
|
-
for (const msg of client.messages) {
|
|
279
|
-
if (msg.type === 'content_delta' && msg.text) {
|
|
280
|
-
if (!fullText.includes(msg.text)) {
|
|
281
|
-
fullText += msg.text
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
console.log(` Response text: "${fullText.substring(0, 200)}"`)
|
|
287
|
-
|
|
288
|
-
if (fullText.length === 0) {
|
|
289
|
-
// Check all messages for debugging
|
|
290
|
-
console.log(' All messages received:')
|
|
291
|
-
for (const msg of client.messages) {
|
|
292
|
-
console.log(` ${msg.type}: ${JSON.stringify(msg).substring(0, 150)}`)
|
|
293
|
-
}
|
|
294
|
-
throw new Error('No content received from LLM')
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
client.close()
|
|
298
|
-
await sleep(500)
|
|
299
|
-
console.log('✅ Real LLM chat works! Got response from MiniMax API')
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// ── Test 8: Scheduled tasks CRUD ───────────────────────────────────────
|
|
303
|
-
|
|
304
|
-
async function testScheduledTasks() {
|
|
305
|
-
console.log('\n── Test 8: Scheduled Tasks CRUD ──')
|
|
306
|
-
|
|
307
|
-
// Create
|
|
308
|
-
const createRes = await fetch(`${BASE_URL}/api/scheduled-tasks`, {
|
|
309
|
-
method: 'POST',
|
|
310
|
-
headers: { 'Content-Type': 'application/json' },
|
|
311
|
-
body: JSON.stringify({
|
|
312
|
-
name: 'Test Task',
|
|
313
|
-
prompt: 'Test prompt',
|
|
314
|
-
cron: '0 9 * * *',
|
|
315
|
-
}),
|
|
316
|
-
})
|
|
317
|
-
if (createRes.status !== 201) {
|
|
318
|
-
const body = await createRes.text()
|
|
319
|
-
throw new Error(`Create scheduled task failed: ${createRes.status} ${body}`)
|
|
320
|
-
}
|
|
321
|
-
const { task } = await createRes.json()
|
|
322
|
-
console.log(` Created task: ${task.id}`)
|
|
323
|
-
|
|
324
|
-
// List
|
|
325
|
-
const listRes = await fetch(`${BASE_URL}/api/scheduled-tasks`)
|
|
326
|
-
const listBody = await listRes.json()
|
|
327
|
-
const found = listBody.tasks?.find((t: any) => t.id === task.id)
|
|
328
|
-
if (!found) throw new Error('Created task not found in list')
|
|
329
|
-
console.log(` Listed ${listBody.tasks.length} tasks`)
|
|
330
|
-
|
|
331
|
-
// Update
|
|
332
|
-
const updateRes = await fetch(`${BASE_URL}/api/scheduled-tasks/${task.id}`, {
|
|
333
|
-
method: 'PUT',
|
|
334
|
-
headers: { 'Content-Type': 'application/json' },
|
|
335
|
-
body: JSON.stringify({ name: 'Updated Task' }),
|
|
336
|
-
})
|
|
337
|
-
if (updateRes.status !== 200) throw new Error(`Update failed: ${updateRes.status}`)
|
|
338
|
-
|
|
339
|
-
// Delete
|
|
340
|
-
const deleteRes = await fetch(`${BASE_URL}/api/scheduled-tasks/${task.id}`, {
|
|
341
|
-
method: 'DELETE',
|
|
342
|
-
})
|
|
343
|
-
if (deleteRes.status !== 200) throw new Error(`Delete failed: ${deleteRes.status}`)
|
|
344
|
-
|
|
345
|
-
console.log('✅ Scheduled Tasks CRUD works')
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// ── Test 9: Settings read/write ────────────────────────────────────────
|
|
349
|
-
|
|
350
|
-
async function testSettingsReadWrite() {
|
|
351
|
-
console.log('\n── Test 9: Settings Read/Write ──')
|
|
352
|
-
|
|
353
|
-
// Read current
|
|
354
|
-
const readRes = await fetch(`${BASE_URL}/api/settings`)
|
|
355
|
-
const original = await readRes.json()
|
|
356
|
-
|
|
357
|
-
// Update via /api/settings/user
|
|
358
|
-
const updateRes = await fetch(`${BASE_URL}/api/settings/user`, {
|
|
359
|
-
method: 'PUT',
|
|
360
|
-
headers: { 'Content-Type': 'application/json' },
|
|
361
|
-
body: JSON.stringify({ testKey_integration: true }),
|
|
362
|
-
})
|
|
363
|
-
if (updateRes.status !== 200) throw new Error(`Settings update failed: ${updateRes.status}`)
|
|
364
|
-
|
|
365
|
-
// Read back
|
|
366
|
-
const readBack = await fetch(`${BASE_URL}/api/settings/user`)
|
|
367
|
-
const updated = await readBack.json()
|
|
368
|
-
|
|
369
|
-
// Clean up: remove test key via overwrite
|
|
370
|
-
const cleanSettings = { ...updated }
|
|
371
|
-
delete cleanSettings.testKey_integration
|
|
372
|
-
await fetch(`${BASE_URL}/api/settings/user`, {
|
|
373
|
-
method: 'PUT',
|
|
374
|
-
headers: { 'Content-Type': 'application/json' },
|
|
375
|
-
body: JSON.stringify(cleanSettings),
|
|
376
|
-
})
|
|
377
|
-
|
|
378
|
-
console.log('✅ Settings read/write works')
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// ── Test 10: Permission mode ──────────────────────────────────────────
|
|
382
|
-
|
|
383
|
-
async function testPermissionMode() {
|
|
384
|
-
console.log('\n── Test 10: Permission Mode ──')
|
|
385
|
-
const res = await fetch(`${BASE_URL}/api/permissions/mode`)
|
|
386
|
-
if (res.status !== 200) throw new Error(`Permissions failed: ${res.status}`)
|
|
387
|
-
const body = await res.json()
|
|
388
|
-
console.log(` Current mode: ${body.mode || body.permissionMode || JSON.stringify(body)}`)
|
|
389
|
-
console.log('✅ Permission mode API works')
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// ── Test 11: Search API ────────────────────────────────────────────────
|
|
393
|
-
|
|
394
|
-
async function testSearchApi() {
|
|
395
|
-
console.log('\n── Test 11: Search API ──')
|
|
396
|
-
const res = await fetch(`${BASE_URL}/api/search/sessions`, {
|
|
397
|
-
method: 'POST',
|
|
398
|
-
headers: { 'Content-Type': 'application/json' },
|
|
399
|
-
body: JSON.stringify({ query: 'test' }),
|
|
400
|
-
})
|
|
401
|
-
if (res.status !== 200) throw new Error(`Search failed: ${res.status}`)
|
|
402
|
-
const body = await res.json()
|
|
403
|
-
console.log(` Search results: ${body.results?.length ?? 0}`)
|
|
404
|
-
console.log('✅ Search API works')
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// ── Test 12: Agents API ────────────────────────────────────────────────
|
|
408
|
-
|
|
409
|
-
async function testAgentsApi() {
|
|
410
|
-
console.log('\n── Test 12: Agents API ──')
|
|
411
|
-
const res = await fetch(`${BASE_URL}/api/agents`)
|
|
412
|
-
if (res.status !== 200) throw new Error(`Agents failed: ${res.status}`)
|
|
413
|
-
const body = await res.json()
|
|
414
|
-
console.log(` Active agents: ${body.activeAgents?.length ?? body.agents?.length ?? 0}`)
|
|
415
|
-
console.log('✅ Agents API works')
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// ── Test 13: Teams API ─────────────────────────────────────────────────
|
|
419
|
-
|
|
420
|
-
async function testTeamsApi() {
|
|
421
|
-
console.log('\n── Test 13: Teams API ──')
|
|
422
|
-
const res = await fetch(`${BASE_URL}/api/teams`)
|
|
423
|
-
if (res.status !== 200) throw new Error(`Teams failed: ${res.status}`)
|
|
424
|
-
const body = await res.json()
|
|
425
|
-
console.log(` Teams: ${body.teams?.length ?? 0}`)
|
|
426
|
-
console.log('✅ Teams API works')
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// ── Test 14: Tasks API ─────────────────────────────────────────────────
|
|
430
|
-
|
|
431
|
-
async function testTasksApi() {
|
|
432
|
-
console.log('\n── Test 14: Tasks API ──')
|
|
433
|
-
const res = await fetch(`${BASE_URL}/api/tasks`)
|
|
434
|
-
if (res.status !== 200) throw new Error(`Tasks failed: ${res.status}`)
|
|
435
|
-
const body = await res.json()
|
|
436
|
-
console.log(` Tasks: ${body.tasks?.length ?? 0}`)
|
|
437
|
-
console.log('✅ Tasks API works')
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
// ── Test 15: Status/Diagnostics API ────────────────────────────────────
|
|
441
|
-
|
|
442
|
-
async function testStatusApi() {
|
|
443
|
-
console.log('\n── Test 15: Status API ──')
|
|
444
|
-
const res = await fetch(`${BASE_URL}/api/status`)
|
|
445
|
-
if (res.status !== 200) throw new Error(`Status failed: ${res.status}`)
|
|
446
|
-
const body = await res.json()
|
|
447
|
-
console.log(` Status: ${body.status || JSON.stringify(body).substring(0, 100)}`)
|
|
448
|
-
console.log('✅ Status API works')
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
// ─── Main ──────────────────────────────────────────────────────────────────
|
|
452
|
-
|
|
453
|
-
async function main() {
|
|
454
|
-
console.log('╔══════════════════════════════════════════════════════════╗')
|
|
455
|
-
console.log('║ Real LLM Integration Test — MiniMax API via CLI ║')
|
|
456
|
-
console.log('╚══════════════════════════════════════════════════════════╝')
|
|
457
|
-
|
|
458
|
-
const failures: string[] = []
|
|
459
|
-
|
|
460
|
-
try {
|
|
461
|
-
await startTestServer()
|
|
462
|
-
|
|
463
|
-
// REST API tests (fast, run first)
|
|
464
|
-
const restTests = [
|
|
465
|
-
testHealthCheck,
|
|
466
|
-
testSessionsApi,
|
|
467
|
-
testSettingsApi,
|
|
468
|
-
testModelsApi,
|
|
469
|
-
testScheduledTasks,
|
|
470
|
-
testSettingsReadWrite,
|
|
471
|
-
testPermissionMode,
|
|
472
|
-
testSearchApi,
|
|
473
|
-
testAgentsApi,
|
|
474
|
-
testTeamsApi,
|
|
475
|
-
testTasksApi,
|
|
476
|
-
testStatusApi,
|
|
477
|
-
]
|
|
478
|
-
|
|
479
|
-
for (const test of restTests) {
|
|
480
|
-
try {
|
|
481
|
-
await test()
|
|
482
|
-
} catch (err: any) {
|
|
483
|
-
console.log(`❌ ${test.name} FAILED: ${err.message}`)
|
|
484
|
-
failures.push(`${test.name}: ${err.message}`)
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
// WebSocket tests
|
|
489
|
-
const wsTests = [testWebSocketConnect, testWebSocketPing]
|
|
490
|
-
|
|
491
|
-
for (const test of wsTests) {
|
|
492
|
-
try {
|
|
493
|
-
await test()
|
|
494
|
-
} catch (err: any) {
|
|
495
|
-
console.log(`❌ ${test.name} FAILED: ${err.message}`)
|
|
496
|
-
failures.push(`${test.name}: ${err.message}`)
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
// Real LLM test (slow, run last)
|
|
501
|
-
try {
|
|
502
|
-
await testRealLLMChat()
|
|
503
|
-
} catch (err: any) {
|
|
504
|
-
console.log(`❌ testRealLLMChat FAILED: ${err.message}`)
|
|
505
|
-
failures.push(`testRealLLMChat: ${err.message}`)
|
|
506
|
-
}
|
|
507
|
-
} finally {
|
|
508
|
-
await stopTestServer()
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
// Summary
|
|
512
|
-
console.log('\n' + '═'.repeat(60))
|
|
513
|
-
if (failures.length === 0) {
|
|
514
|
-
console.log('🎉 ALL TESTS PASSED!')
|
|
515
|
-
} else {
|
|
516
|
-
console.log(`⚠️ ${failures.length} TEST(S) FAILED:`)
|
|
517
|
-
for (const f of failures) {
|
|
518
|
-
console.log(` ❌ ${f}`)
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
console.log('═'.repeat(60))
|
|
522
|
-
|
|
523
|
-
process.exit(failures.length > 0 ? 1 : 0)
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
main()
|