fix: allow execute runtime tools by default

This commit is contained in:
lofyer
2026-08-11 13:07:36 +08:00
parent aff3b82998
commit fde18c1568
4 changed files with 17 additions and 13 deletions
+3 -1
View File
@@ -994,7 +994,7 @@ describe('ContinueHostAdapter', () => {
expect(killed).toBe(true) expect(killed).toBe(true)
}) })
it('returns audit metadata for auto-approved agent tools', async () => { it('uses auto mode and returns audit metadata for agent tools', async () => {
const distribution = await createDistribution() const distribution = await createDistribution()
let launchArgs: string[] = [] let launchArgs: string[] = []
const permissionBodies: unknown[] = [] const permissionBodies: unknown[] = []
@@ -1115,6 +1115,7 @@ describe('ContinueHostAdapter', () => {
new AbortController().signal, new AbortController().signal,
authorize, authorize,
{ {
workMode: 'execute',
onEvent: (event) => { onEvent: (event) => {
streamEvents.push(event) streamEvents.push(event)
} }
@@ -1159,6 +1160,7 @@ describe('ContinueHostAdapter', () => {
}, },
{ type: 'text', delta: 'TOOLS_OK' } { type: 'text', delta: 'TOOLS_OK' }
]) ])
expect(launchArgs).toContain('--auto')
expect(launchArgs).not.toContain('--readonly') expect(launchArgs).not.toContain('--readonly')
expect(authorize).toHaveBeenCalledWith( expect(authorize).toHaveBeenCalledWith(
expect.objectContaining({ toolName: 'Bash' }) expect.objectContaining({ toolName: 'Bash' })
+2
View File
@@ -1061,6 +1061,8 @@ export class ContinueHostAdapter {
'--exclude', '--exclude',
'*' '*'
) )
} else if (runOptions.workMode === 'execute') {
args.push('--auto')
} else if (this.options.mode === 'chat') { } else if (this.options.mode === 'chat') {
args.push('--readonly') args.push('--readonly')
} }
+8 -6
View File
@@ -1697,7 +1697,7 @@ describe('OpenCodeRuntime embedded permission mediation', () => {
} }
}) })
it('subscribes before prompting and auto-allows a tool request', async () => { it('configures Execute tools as allowed before prompting', async () => {
const { const {
client, client,
callOrder, callOrder,
@@ -1759,8 +1759,7 @@ describe('OpenCodeRuntime embedded permission mediation', () => {
title: 'GoodBuddy 对话', title: 'GoodBuddy 对话',
directory: process.cwd(), directory: process.cwd(),
permission: [ permission: [
{ permission: '*', pattern: '*', action: 'ask' }, { permission: '*', pattern: '*', action: 'allow' }
{ permission: 'task', pattern: '*', action: 'deny' }
] ]
}) })
expect(permissionReply).toHaveBeenCalledOnce() expect(permissionReply).toHaveBeenCalledOnce()
@@ -1830,7 +1829,7 @@ describe('OpenCodeRuntime embedded permission mediation', () => {
await runtime.dispose() await runtime.dispose()
}) })
it('auto-allows each bounded tool request without GoodBuddy approval', async () => { it('auto-allows bounded fallback permission requests without GoodBuddy approval', async () => {
const { client, permissionReply } = runClient([ const { client, permissionReply } = runClient([
permissionEvent(), permissionEvent(),
permissionEvent({ permissionEvent({
@@ -2080,7 +2079,7 @@ describe('OpenCodeRuntime embedded permission mediation', () => {
await runtime.dispose() await runtime.dispose()
}) })
it('leaves trusted external sessions unmodified and skips whole-run approval', async () => { it('configures external Execute sessions without whole-run approval', async () => {
const { client, session, permissionReply } = runClient([ const { client, session, permissionReply } = runClient([
permissionEvent(), permissionEvent(),
{ {
@@ -2105,7 +2104,10 @@ describe('OpenCodeRuntime embedded permission mediation', () => {
expect(runtime.requiresToolApproval).toBe(false) expect(runtime.requiresToolApproval).toBe(false)
expect(session.create).toHaveBeenCalledWith({ expect(session.create).toHaveBeenCalledWith({
title: 'GoodBuddy 对话', title: 'GoodBuddy 对话',
directory: process.cwd() directory: process.cwd(),
permission: [
{ permission: '*', pattern: '*', action: 'allow' }
]
}) })
expect(permissionReply).not.toHaveBeenCalled() expect(permissionReply).not.toHaveBeenCalled()
await runtime.dispose() await runtime.dispose()
+4 -6
View File
@@ -113,8 +113,7 @@ type OpenCodeSkillRegistration = {
} }
const executePermissionRules: PermissionRuleset = [ const executePermissionRules: PermissionRuleset = [
{ permission: '*', pattern: '*', action: 'ask' }, { permission: '*', pattern: '*', action: 'allow' }
{ permission: 'task', pattern: '*', action: 'deny' }
] ]
const readOnlyPermissionRules: PermissionRuleset = [ const readOnlyPermissionRules: PermissionRuleset = [
@@ -1100,8 +1099,8 @@ export class OpenCodeRuntime implements AgentRuntime {
.getAvailableToolNames(request.knowledgeCapabilityToken) .getAvailableToolNames(request.knowledgeCapabilityToken)
.map((toolName) => `${knowledgeMcpName}_${toolName}`) .map((toolName) => `${knowledgeMcpName}_${toolName}`)
} }
const permission = this.usesEmbeddedPermissionMediation() const permission =
? request.workMode === 'execute' request.workMode === 'execute'
? [ ? [
...executePermissionRules, ...executePermissionRules,
...nativeSkillPermissionRules, ...nativeSkillPermissionRules,
@@ -1125,7 +1124,6 @@ export class OpenCodeRuntime implements AgentRuntime {
...readOnlyPermissionRules, ...readOnlyPermissionRules,
...nativeSkillPermissionRules ...nativeSkillPermissionRules
] ]
: undefined
let disabledTools: Record<string, boolean> | undefined let disabledTools: Record<string, boolean> | undefined
if (request.workMode !== 'execute') { if (request.workMode !== 'execute') {
const tools = await client.tool.ids({ const tools = await client.tool.ids({
@@ -1151,7 +1149,7 @@ export class OpenCodeRuntime implements AgentRuntime {
permission permission
) )
const sessionId = session.id const sessionId = session.id
if (!session.created && permission) { if (!session.created) {
const update = await client.session.update({ const update = await client.session.update({
sessionID: sessionId, sessionID: sessionId,
directory, directory,