Skip to content
Merged
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
35 changes: 1 addition & 34 deletions packages/extension-agent/src/service/sub_agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { Context } from 'koishi'
import {
type AgentTaskResolveContext,

Check failure on line 5 in packages/extension-agent/src/service/sub_agent.ts

View workflow job for this annotation

GitHub Actions / lint

'AgentTaskResolveContext' is defined but never used
type AgentTaskToolRuntime,
createTaskTool,
renderAvailableAgents,
Expand Down Expand Up @@ -187,12 +187,7 @@
return undefined
}

const next = this.permission.createSubAgentToolMask(info)
const base =
ctx.parent?.toolMask ??
ctx.runConfig?.configurable?.toolMask
const names = this.ctx.chatluna.platform.getFilteredTools(next)
const mask = buildSubAgentToolMask(base, names)
const mask = this.permission.createSubAgentToolMask(info)

return {
agent: await createSubAgent({
Expand Down Expand Up @@ -331,31 +326,3 @@
!info.shadowedBy
)
}

function buildSubAgentToolMask(base: ToolMask | undefined, names: string[]) {
if (!base) {
return buildToolMask(names)
}

const allow = names.filter((name) => {
if (base.mode === 'all') {
return true
}

if (base.mode === 'allow') {
return base.allow.includes(name)
}

return !base.deny.includes(name)
})

return buildToolMask(allow)
}

function buildToolMask(allow: string[]): ToolMask {
return {
mode: 'allow',
allow,
deny: []
}
}
Loading