发布 openmcp-sdk
This commit is contained in:
parent
1f55126c82
commit
d85880ea7a
7
resources/openmcp-sdk-release/task-loop.d.ts
vendored
7
resources/openmcp-sdk-release/task-loop.d.ts
vendored
@ -50,8 +50,8 @@ export interface IDoConversationResult {
|
||||
* @description 对任务循环进行的抽象封装
|
||||
*/
|
||||
export class TaskLoop {
|
||||
private readonly streamingContent;
|
||||
private readonly streamingToolCalls;
|
||||
private streamingContent;
|
||||
private streamingToolCalls;
|
||||
private readonly taskOptions;
|
||||
private bridge;
|
||||
private currentChatId;
|
||||
@ -61,7 +61,7 @@ export class TaskLoop {
|
||||
private onEpoch;
|
||||
private completionUsage;
|
||||
private llmConfig;
|
||||
constructor(streamingContent: Ref<string>, streamingToolCalls: Ref<ToolCall[]>, taskOptions?: TaskLoopOptions);
|
||||
constructor(taskOptions?: TaskLoopOptions);
|
||||
private handleChunkDeltaContent;
|
||||
private handleChunkDeltaToolCalls;
|
||||
private handleChunkUsage;
|
||||
@ -86,6 +86,7 @@ export class TaskLoop {
|
||||
*/
|
||||
setLlmConfig(config: any): void;
|
||||
getLlmConfig(): any;
|
||||
bindStreaming(content: Ref<string>, toolCalls: Ref<ToolCall[]>): void;
|
||||
connectToService(): Promise<void>;
|
||||
/**
|
||||
* @description 开启循环,异步更新 DOM
|
||||
|
@ -123,5 +123,21 @@ export class TaskLoopAdapter {
|
||||
console.error('❌ 连接 mcp 服务器失败:' + res.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取 mcp 服务器的工具列表
|
||||
* @returns
|
||||
*/
|
||||
public async listTools() {
|
||||
const tools = await client?.listTools();
|
||||
if (tools?.tools) {
|
||||
return tools.tools.map((tool) => ({
|
||||
name: tool.name,
|
||||
description: tool.description,
|
||||
enabled: true
|
||||
}));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,16 @@ export async function connectService(
|
||||
try {
|
||||
console.log('ready to connect', option);
|
||||
|
||||
// 对于特殊表示的路径,进行特殊的支持
|
||||
if (option.args) {
|
||||
option.args = option.args.map(arg => {
|
||||
if (arg.startsWith('~/')) {
|
||||
return arg.replace('~', process.env.HOME || '');
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
}
|
||||
|
||||
client = await connect(option);
|
||||
const connectResult = {
|
||||
code: 200,
|
||||
|
Loading…
x
Reference in New Issue
Block a user