aegiscode 5.2.14 → 5.2.15
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 +2 -4
- package/bin/cli.js +989 -1028
- package/package.json +20 -23
- package/dist/main.js +0 -2364
- package/dist/package.json +0 -1
- package/scripts/smoke-chat.mts +0 -135
package/dist/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/scripts/smoke-chat.mts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Smoke test for the chat engine across model transports.
|
|
3
|
-
*
|
|
4
|
-
* Usage:
|
|
5
|
-
* npx tsx scripts/smoke-chat.mts ollama # local Ollama (llama3.2)
|
|
6
|
-
* npx tsx scripts/smoke-chat.mts ollama-tools # local Ollama with a tool call
|
|
7
|
-
* npx tsx scripts/smoke-chat.mts mock # local mock OpenAI server (transient/429/500)
|
|
8
|
-
* npx tsx scripts/smoke-chat.mts openai # needs OPENAI_API_KEY
|
|
9
|
-
* npx tsx scripts/smoke-chat.mts deepseek # needs DEEPSEEK_API_KEY
|
|
10
|
-
* npx tsx scripts/smoke-chat.mts anthropic # needs ANTHROPIC_API_KEY
|
|
11
|
-
* npx tsx scripts/smoke-chat.mts gemini # needs GEMINI_API_KEY
|
|
12
|
-
* npx tsx scripts/smoke-chat.mts groq # needs GROQ_API_KEY
|
|
13
|
-
*
|
|
14
|
-
* Requires: `npm run dev` deps present (tsx). No build needed.
|
|
15
|
-
*/
|
|
16
|
-
import { createChatService } from '../src/services/ChatService.js';
|
|
17
|
-
import type { Message, ToolDefinition } from '../src/agent/types.js';
|
|
18
|
-
|
|
19
|
-
const transport = process.argv[2] || 'ollama';
|
|
20
|
-
|
|
21
|
-
const baseConfig: Record<string, { baseURL: string; apiKey: string; model: string }> = {
|
|
22
|
-
ollama: { baseURL: 'http://localhost:11434/v1', apiKey: 'ollama', model: 'llama3.2:1b' },
|
|
23
|
-
openai: { baseURL: 'https://api.openai.com/v1', apiKey: process.env.OPENAI_API_KEY || '', model: 'gpt-4o-mini' },
|
|
24
|
-
deepseek: { baseURL: 'https://api.deepseek.com/v1', apiKey: process.env.DEEPSEEK_API_KEY || '', model: 'deepseek-chat' },
|
|
25
|
-
'deepseek-reasoner': { baseURL: 'https://api.deepseek.com/v1', apiKey: process.env.DEEPSEEK_API_KEY || '', model: 'deepseek-reasoner' },
|
|
26
|
-
anthropic:{ baseURL: 'https://api.anthropic.com/v1', apiKey: process.env.ANTHROPIC_API_KEY || '', model: 'claude-sonnet-4-20250514' },
|
|
27
|
-
gemini: { baseURL: 'https://generativelanguage.googleapis.com/v1beta/openai', apiKey: process.env.GEMINI_API_KEY || '', model: 'gemini-2.5-flash' },
|
|
28
|
-
groq: { baseURL: 'https://api.groq.com/openai/v1', apiKey: process.env.GROQ_API_KEY || '', model: 'llama-3.3-70b-versatile' },
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const tools: ToolDefinition[] = [{
|
|
32
|
-
type: 'function',
|
|
33
|
-
function: {
|
|
34
|
-
name: 'get_weather',
|
|
35
|
-
description: 'Get the current weather for a city',
|
|
36
|
-
parameters: {
|
|
37
|
-
type: 'object',
|
|
38
|
-
properties: {
|
|
39
|
-
city: { type: 'string', description: 'City name' },
|
|
40
|
-
},
|
|
41
|
-
required: ['city'],
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
}];
|
|
45
|
-
|
|
46
|
-
async function run() {
|
|
47
|
-
if (transport === 'mock') return runMockServer();
|
|
48
|
-
const cfg = baseConfig[transport] || baseConfig.ollama; // 'ollama-tools' reuses ollama cfg
|
|
49
|
-
if (!cfg) { console.error(`Unknown transport: ${transport}`); process.exit(1); }
|
|
50
|
-
|
|
51
|
-
const service = createChatService(cfg);
|
|
52
|
-
|
|
53
|
-
const useTools = transport === 'ollama-tools' || process.argv[3] === 'tools';
|
|
54
|
-
|
|
55
|
-
const messages: Message[] = [
|
|
56
|
-
{ role: 'system', content: 'You are a helpful assistant. Reply concisely.' },
|
|
57
|
-
{ role: 'user', content: useTools ? 'What is the weather in Stockholm? Use the weather tool.' : 'Say hello in one short sentence, then tell me 2+2.' },
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
const deltas: string[] = [];
|
|
61
|
-
const thoughts: string[] = [];
|
|
62
|
-
const toolStarts: string[] = [];
|
|
63
|
-
|
|
64
|
-
const result = await service.chat(messages, useTools ? tools : undefined, undefined, {
|
|
65
|
-
onContentDelta: d => deltas.push(d),
|
|
66
|
-
onThinkingDelta: t => thoughts.push(t),
|
|
67
|
-
onToolCallStart: tc => toolStarts.push(tc.function?.name || '?'),
|
|
68
|
-
onStreamEvent: () => {},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const totalDeltaLen = deltas.join('').length;
|
|
72
|
-
console.log(`\n[${transport}] OK`);
|
|
73
|
-
console.log(` content: ${JSON.stringify(result.content.slice(0, 300))}`);
|
|
74
|
-
console.log(` reasoning: ${JSON.stringify((result.reasoningContent || '').slice(0, 100)) || '(none)'}`);
|
|
75
|
-
console.log(` toolCalls: ${JSON.stringify(result.toolCalls || [])}`);
|
|
76
|
-
console.log(` usage: ${JSON.stringify(result.usage || null)}`);
|
|
77
|
-
console.log(` streamed via onContentDelta: ${totalDeltaLen} chars (content len ${result.content.length})`);
|
|
78
|
-
if (toolStarts.length) console.log(` tool starts seen: ${toolStarts.join(', ')}`);
|
|
79
|
-
|
|
80
|
-
if (result.content.length === 0 && (!result.toolCalls || result.toolCalls.length === 0)) {
|
|
81
|
-
throw new Error('Empty content and no tool calls — chat service returned nothing');
|
|
82
|
-
}
|
|
83
|
-
if (totalDeltaLen > 0 && totalDeltaLen !== result.content.length) {
|
|
84
|
-
// Delta may legitimately differ (thinking stripped), just report
|
|
85
|
-
console.log(` (note: delta total ${totalDeltaLen} != final ${result.content.length} — thinking/Ollama-tag stripping)`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** Local fake OpenAI server to exercise retry/error paths deterministically. */
|
|
90
|
-
async function runMockServer() {
|
|
91
|
-
const http = await import('node:http');
|
|
92
|
-
let calls = 0;
|
|
93
|
-
const server = http.createServer((req, res) => {
|
|
94
|
-
let body = '';
|
|
95
|
-
req.on('data', c => (body += c));
|
|
96
|
-
req.on('end', () => {
|
|
97
|
-
calls++;
|
|
98
|
-
// Scenario: 1st call transient 500, 2nd call succeeds.
|
|
99
|
-
if (calls === 1) {
|
|
100
|
-
res.writeHead(500, { 'content-type': 'application/json' });
|
|
101
|
-
res.end(JSON.stringify({ error: { message: 'boom' } }));
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
res.writeHead(200, { 'content-type': 'text/event-stream', 'transfer-encoding': 'chunked' });
|
|
105
|
-
const json = (obj: unknown) => `data: ${JSON.stringify(obj)}\n\n`;
|
|
106
|
-
res.write(json({ choices: [{ delta: { role: 'assistant' } }] }));
|
|
107
|
-
res.write(json({ choices: [{ delta: { content: 'mock ok' } }] }));
|
|
108
|
-
res.write(json({ choices: [{ delta: {} }], usage: { prompt_tokens: 5, completion_tokens: 3, total_tokens: 8 } }));
|
|
109
|
-
res.write('data: [DONE]\n\n');
|
|
110
|
-
res.end();
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
await new Promise<void>(r => server.listen(18789, r));
|
|
115
|
-
|
|
116
|
-
const service = createChatService({
|
|
117
|
-
baseURL: 'http://127.0.0.1:18789/v1',
|
|
118
|
-
apiKey: 'mock',
|
|
119
|
-
model: 'mock-model',
|
|
120
|
-
});
|
|
121
|
-
const messages: Message[] = [{ role: 'user', content: 'hi' }];
|
|
122
|
-
const result = await service.chat(messages);
|
|
123
|
-
console.log('\n[mock] OK — retry loop recovered from transient 500');
|
|
124
|
-
console.log(` content: ${JSON.stringify(result.content)}`);
|
|
125
|
-
console.log(` calls made: ${calls}`);
|
|
126
|
-
if (calls < 2) throw new Error('Expected retry to fire a 2nd call');
|
|
127
|
-
if (!result.content.includes('mock ok')) throw new Error('Mock content missing');
|
|
128
|
-
|
|
129
|
-
server.close();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
run().then(
|
|
133
|
-
() => process.exit(0),
|
|
134
|
-
err => { console.error(`\n[${transport}] FAIL:`, err instanceof Error ? err.message : err); process.exit(1); },
|
|
135
|
-
);
|