Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/adapter-azure-openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"resolutions": {
"@langchain/core": "0.3.62",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-claude/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"resolutions": {
"@langchain/core": "0.3.62",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-deepseek/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"koishi": {
"category": "ai",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-dify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"koishi": {
"description": {
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-doubao/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"koishi": {
"description": {
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-gemini/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64",
"koishi-plugin-chatluna": "^1.3.0-alpha.65",
"koishi-plugin-chatluna-storage-service": "^0.0.10"
},
"peerDependenciesMeta": {
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-hunyuan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"koishi": {
"description": {
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-ollama/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"resolutions": {
"@langchain/core": "0.3.62",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-openai-like/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"koishi": {
"description": {
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"koishi": {
"description": {
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-qwen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"koishi": {
"description": {
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-rwkv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"koishi": {
"description": {
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-spark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"koishi": {
"description": {
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-wenxin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"koishi": {
"description": {
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-zhipu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"koishi": {
"description": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-plugin-chatluna",
"description": "chatluna for koishi",
"version": "1.3.0-alpha.64",
"version": "1.3.0-alpha.65",
"main": "lib/index.cjs",
"module": "lib/index.mjs",
"typings": "lib/index.d.ts",
Expand Down
14 changes: 10 additions & 4 deletions packages/core/src/llm-core/agent/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ export function createToolsRef(options: CreateToolsRefOptions) {
const activeTools = shallowRef<ChatLunaTool[]>([])

const tools = computed(() => {
return activeTools.value.map((tool) =>
tool.createTool({
embeddings: options.embeddings
return activeTools.value
.map((tool) => {
try {
return tool.createTool({
embeddings: options.embeddings
})
} catch (error) {
console.error(`Error creating tool ${tool.id}:`, error)
Comment thread
dingyi222666 marked this conversation as resolved.
}
})
)
.filter(Boolean)
})

const getActiveTools = (
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-long-memory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64"
"koishi-plugin-chatluna": "^1.3.0-alpha.65"
},
"resolutions": {
"@langchain/core": "0.3.62",
Expand Down
20 changes: 11 additions & 9 deletions packages/extension-long-memory/src/plugins/prompt_varaiable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,17 @@ export async function apply(ctx: Context, config: Config) {
return result
}

ctx.chatluna.promptRenderer.registerFunctionProvider(
'long_memory',
async (args, variables, configurable) => {
try {
return await handler(args, variables, configurable)
} catch (error) {
logger.error(error)
return 'Error retrieving long-term memory'
ctx.effect(() =>
ctx.chatluna.promptRenderer.registerFunctionProvider(
'long_memory',
async (args, variables, configurable) => {
try {
return await handler(args, variables, configurable)
} catch (error) {
logger.error(error)
return 'Error retrieving long-term memory'
}
}
}
)
)
}
4 changes: 2 additions & 2 deletions packages/extension-mcp/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-plugin-chatluna-mcp-client",
"description": "MCP Client for ChatLuna",
"version": "1.3.0-alpha.8",
"version": "1.3.0-alpha.9",
"main": "lib/index.cjs",
"module": "lib/index.mjs",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -58,7 +58,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64",
"koishi-plugin-chatluna": "^1.3.0-alpha.65",
"koishi-plugin-chatluna-storage-service": "^0.0.10"
},
"peerDependenciesMeta": {
Expand Down
115 changes: 35 additions & 80 deletions packages/extension-mcp/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,90 +5,45 @@ export function apply(ctx: Context, config: Config) {
ctx.command('chatluna.mcp', 'MCP 工具管理相关命令')

// List command
ctx.command('chatluna.mcp.list', '列出所有 MCP 工具')
.option('raw', '-r 列出原始的 MCP 服务器配置')
.action(async ({ session, options }) => {
if (options.raw) {
// List raw MCP servers
try {
const parsedConfig = JSON.parse(config.servers)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let servers: Record<string, any> = {}

if (Array.isArray(parsedConfig)) {
servers = parsedConfig.reduce((acc, server, index) => {
acc[`server-${index}`] = server
return acc
}, {})
} else if (parsedConfig['mcpServers']) {
servers = parsedConfig['mcpServers']
} else {
await session.send(session.text('.empty_servers'))
return
}

if (Object.keys(servers).length === 0) {
await session.send(session.text('.empty_servers'))
return
}

const messages = [session.text('.list_servers_header')]
for (const [name, serverConfig] of Object.entries(
servers
)) {
messages.push(
session.text('.server_name', [name]),
session.text('.server_config', [
JSON.stringify(serverConfig, null, 2)
]),
'---'
)
}

await session.send(messages.join('\n'))
} catch (error) {
await session.send(session.text('.parse_error'))
ctx.command('chatluna.mcp.list', '列出所有 MCP 工具').action(
async ({ session, options }) => {
Comment thread
dingyi222666 marked this conversation as resolved.
// List tools
try {
const service = ctx.chatluna_mcp
if (!service) {
await session.send(session.text('.service_not_ready'))
return
}
} else {
// List tools
try {
const service = ctx.chatluna_mcp
if (!service) {
await session.send(session.text('.service_not_ready'))
return
}

const tools = service.globalTools

if (Object.keys(tools).length === 0) {
await session.send(session.text('.empty_tools'))
return
}

const messages = [session.text('.list_tools_header')]
for (const [name, tool] of Object.entries(tools)) {
const selectorText =
tool.selector && tool.selector.length > 0
? tool.selector.join(', ')
: session.text('.no_selector')
messages.push(
session.text('.tool_name', [name]),
session.text('.tool_enabled', [
tool.enabled ? '✓' : '✗'
]),
session.text('.tool_selector', [selectorText]),
'---'
)
}

await session.send(messages.join('\n'))
} catch (error) {
await session.send(
session.text('.list_error', [error.message])

const tools = service.globalTools

if (Object.keys(tools).length === 0) {
await session.send(session.text('.empty_tools'))
return
}

const messages = [session.text('.list_tools_header')]
for (const [name, tool] of Object.entries(tools)) {
const selectorText =
tool.selector && tool.selector.length > 0
? tool.selector.join(', ')
: session.text('.no_selector')
messages.push(
session.text('.tool_name', [name]),
session.text('.tool_enabled', [
tool.enabled ? '✓' : '✗'
]),
session.text('.tool_selector', [selectorText]),
'---'
)
}

await session.send(messages.join('\n'))
} catch (error) {
await session.send(session.text('.list_error', [error.message]))
}
})
}
)

// Add command
ctx.command('chatluna.mcp.add <mcpConfig:text>', '添加 MCP 服务器', {
Expand Down
4 changes: 2 additions & 2 deletions packages/extension-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-plugin-chatluna-plugin-common",
"description": "plugin service for agent mode of chatluna",
"version": "1.3.0-alpha.20",
"version": "1.3.0-alpha.21",
"main": "lib/index.cjs",
"module": "lib/index.mjs",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -68,7 +68,7 @@
},
"peerDependencies": {
"koishi": "^4.18.9",
"koishi-plugin-chatluna": "^1.3.0-alpha.64",
"koishi-plugin-chatluna": "^1.3.0-alpha.65",
"koishi-plugin-chatluna-storage-service": "^0.0.10"
},
"peerDependenciesMeta": {
Expand Down
Loading