osai-agent 4.2.18 → 4.2.20
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 -1
- package/src/llm/direct.js +10 -2
- package/src/tools/mcp-client.js +2 -1
package/package.json
CHANGED
package/src/llm/direct.js
CHANGED
|
@@ -277,7 +277,7 @@ export function streamLocalCompletion({
|
|
|
277
277
|
}));
|
|
278
278
|
const chat = geminiModel.startChat({
|
|
279
279
|
history: geminiHistory,
|
|
280
|
-
systemInstruction: systemPrompt,
|
|
280
|
+
systemInstruction: { parts: [{ text: systemPrompt }] },
|
|
281
281
|
});
|
|
282
282
|
const result = await chat.sendMessageStream(message);
|
|
283
283
|
for await (const chunk of result.stream) {
|
|
@@ -308,7 +308,15 @@ export function streamLocalCompletion({
|
|
|
308
308
|
controller.close();
|
|
309
309
|
} catch (err) {
|
|
310
310
|
if (err.name !== 'AbortError') {
|
|
311
|
-
|
|
311
|
+
let errMsg = err.message;
|
|
312
|
+
const systemPromptIdx = errMsg.indexOf('You are OS AI Agent');
|
|
313
|
+
if (systemPromptIdx !== -1) {
|
|
314
|
+
errMsg = errMsg.slice(0, systemPromptIdx).trim();
|
|
315
|
+
if (errMsg.length > 300) errMsg = errMsg.slice(0, 300) + '...';
|
|
316
|
+
} else if (errMsg.length > 500) {
|
|
317
|
+
errMsg = errMsg.slice(0, 500) + '...';
|
|
318
|
+
}
|
|
319
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ type: 'error', message: errMsg })}\n\n`));
|
|
312
320
|
}
|
|
313
321
|
controller.close();
|
|
314
322
|
}
|
package/src/tools/mcp-client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Client,
|
|
1
|
+
import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
|
|
2
|
+
import { StdioClientTransport } from '@modelcontextprotocol/client/stdio';
|
|
2
3
|
import { logger } from '../utils/logger.js';
|
|
3
4
|
|
|
4
5
|
class McpConnection {
|