add prompt reader
This commit is contained in:
parent
7098382317
commit
be641197b5
@ -783,4 +783,14 @@ export class TaskLoop {
|
|||||||
settings: _settings
|
settings: _settings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getPrompt(promptId: string, args: Record<string, any>) {
|
||||||
|
const prompt = await mcpClientAdapter.readPromptTemplate(promptId, args);
|
||||||
|
return prompt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getResource(resourceUri: string) {
|
||||||
|
const resource = await mcpClientAdapter.readResource(resourceUri);
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
}
|
}
|
36
resources/openmcp-sdk-release/task-loop.d.ts
vendored
36
resources/openmcp-sdk-release/task-loop.d.ts
vendored
@ -5,25 +5,25 @@ export type ChatCompletionChunk = OpenAI.Chat.Completions.ChatCompletionChunk;
|
|||||||
export type ChatCompletionCreateParamsBase = OpenAI.Chat.Completions.ChatCompletionCreateParams & { id?: string };
|
export type ChatCompletionCreateParamsBase = OpenAI.Chat.Completions.ChatCompletionCreateParams & { id?: string };
|
||||||
|
|
||||||
interface SchemaProperty {
|
interface SchemaProperty {
|
||||||
title: string;
|
title: string;
|
||||||
type: string;
|
type: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InputSchema {
|
interface InputSchema {
|
||||||
type: string;
|
type: string;
|
||||||
properties: Record<string, SchemaProperty>;
|
properties: Record<string, SchemaProperty>;
|
||||||
required?: string[];
|
required?: string[];
|
||||||
title?: string;
|
title?: string;
|
||||||
$defs?: any;
|
$defs?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ToolItem {
|
interface ToolItem {
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
inputSchema: InputSchema;
|
inputSchema: InputSchema;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
anyOf?: any;
|
anyOf?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IExtraInfo {
|
interface IExtraInfo {
|
||||||
@ -87,7 +87,7 @@ export interface ToolCall {
|
|||||||
export interface ToolCallContent {
|
export interface ToolCallContent {
|
||||||
type: string;
|
type: string;
|
||||||
text: string;
|
text: string;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ToolCallResult {
|
export interface ToolCallResult {
|
||||||
@ -290,6 +290,16 @@ export class TaskLoop {
|
|||||||
* @description Create single conversation context
|
* @description Create single conversation context
|
||||||
*/
|
*/
|
||||||
createStorage(settings?: ChatSetting): Promise<ChatStorage>;
|
createStorage(settings?: ChatSetting): Promise<ChatStorage>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Get prompt template from mcp server
|
||||||
|
*/
|
||||||
|
getPrompt(promptId: string, args: Record<string, any>): Promise<string>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Get resource template from mcp server
|
||||||
|
*/
|
||||||
|
getResource(resourceUri: string): Promise<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare const getToolSchema: any;
|
export declare const getToolSchema: any;
|
||||||
|
@ -164,7 +164,8 @@ interface StdioMCPConfig {
|
|||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
description?: string;
|
description?: string;
|
||||||
prompt?: string;
|
prompts?: string[];
|
||||||
|
resources?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface HttpMCPConfig {
|
interface HttpMCPConfig {
|
||||||
@ -174,7 +175,8 @@ interface HttpMCPConfig {
|
|||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
description?: string;
|
description?: string;
|
||||||
prompt?: string;
|
prompts?: string[];
|
||||||
|
resources?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OmAgentConfiguration {
|
export interface OmAgentConfiguration {
|
||||||
@ -255,8 +257,7 @@ export class OmAgent {
|
|||||||
* "OPENMEMORY_API_KEY": "YOUR_API_KEY",
|
* "OPENMEMORY_API_KEY": "YOUR_API_KEY",
|
||||||
* "CLIENT_NAME": "openmemory"
|
* "CLIENT_NAME": "openmemory"
|
||||||
* },
|
* },
|
||||||
* "description": "A MCP for long-term memory support",
|
* "description": "A MCP for long-term memory support"
|
||||||
* "prompt": "You are a helpful assistant."
|
|
||||||
* }
|
* }
|
||||||
* },
|
* },
|
||||||
* "defaultLLM": {
|
* "defaultLLM": {
|
||||||
@ -287,7 +288,6 @@ export class OmAgent {
|
|||||||
connectionType: 'STDIO',
|
connectionType: 'STDIO',
|
||||||
env: mcpConfig.env,
|
env: mcpConfig.env,
|
||||||
description: mcpConfig.description,
|
description: mcpConfig.description,
|
||||||
prompt: mcpConfig.prompt,
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const connectionType: ConnectionType = mcpConfig.type === 'http' ? 'STREAMABLE_HTTP' : 'SSE';
|
const connectionType: ConnectionType = mcpConfig.type === 'http' ? 'STREAMABLE_HTTP' : 'SSE';
|
||||||
@ -296,12 +296,18 @@ export class OmAgent {
|
|||||||
env: mcpConfig.env,
|
env: mcpConfig.env,
|
||||||
connectionType,
|
connectionType,
|
||||||
description: mcpConfig.description,
|
description: mcpConfig.description,
|
||||||
prompt: mcpConfig.prompt,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Add MCP server
|
||||||
|
*/
|
||||||
|
public addMcpServer(connectionArgs: IConnectionArgs) {
|
||||||
|
this._adapter.addMcp(connectionArgs);
|
||||||
|
}
|
||||||
|
|
||||||
private async getLoop(loopOption?: TaskLoopOptions) {
|
private async getLoop(loopOption?: TaskLoopOptions) {
|
||||||
if (this._loop) {
|
if (this._loop) {
|
||||||
return this._loop;
|
return this._loop;
|
||||||
@ -324,6 +330,12 @@ export class OmAgent {
|
|||||||
this._defaultLLM = option;
|
this._defaultLLM = option;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getPrompt(promptId: string, args: Record<string, any>) {
|
||||||
|
const loop = await this.getLoop();
|
||||||
|
const prompt = await loop.getPrompt(promptId, args);
|
||||||
|
return prompt;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Asynchronous invoking agent by string or messages
|
* @description Asynchronous invoking agent by string or messages
|
||||||
* @param messages Chat message or string
|
* @param messages Chat message or string
|
||||||
|
10
service/task-loop.d.ts
vendored
10
service/task-loop.d.ts
vendored
@ -290,6 +290,16 @@ export class TaskLoop {
|
|||||||
* @description Create single conversation context
|
* @description Create single conversation context
|
||||||
*/
|
*/
|
||||||
createStorage(settings?: ChatSetting): Promise<ChatStorage>;
|
createStorage(settings?: ChatSetting): Promise<ChatStorage>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Get prompt template from mcp server
|
||||||
|
*/
|
||||||
|
getPrompt(promptId: string, args: Record<string, any>): Promise<string>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Get resource template from mcp server
|
||||||
|
*/
|
||||||
|
getResource(resourceUri: string): Promise<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare const getToolSchema: any;
|
export declare const getToolSchema: any;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user