mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-18 13:23:33 +08:00
Merge commit '13b765b5e94fe08009d04bdbce2195d084a4b894'
This commit is contained in:
commit
578a967c5a
50
src/tools/AgentTool/builtInAgents.test.ts
Normal file
50
src/tools/AgentTool/builtInAgents.test.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import { afterEach, describe, expect, test } from 'bun:test'
|
||||
import {
|
||||
setIsInteractive,
|
||||
} from '../../bootstrap/state.js'
|
||||
import {
|
||||
areExplorePlanAgentsEnabled,
|
||||
getBuiltInAgents,
|
||||
} from './builtInAgents.js'
|
||||
|
||||
const originalDisableBuiltIns =
|
||||
process.env.CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS
|
||||
const originalEntrypoint = process.env.CLAUDE_CODE_ENTRYPOINT
|
||||
|
||||
afterEach(() => {
|
||||
if (originalDisableBuiltIns === undefined) {
|
||||
delete process.env.CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS
|
||||
} else {
|
||||
process.env.CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS =
|
||||
originalDisableBuiltIns
|
||||
}
|
||||
|
||||
if (originalEntrypoint === undefined) {
|
||||
delete process.env.CLAUDE_CODE_ENTRYPOINT
|
||||
} else {
|
||||
process.env.CLAUDE_CODE_ENTRYPOINT = originalEntrypoint
|
||||
}
|
||||
|
||||
setIsInteractive(false)
|
||||
})
|
||||
|
||||
describe('built-in agents', () => {
|
||||
test('enables public built-in agents in external builds', () => {
|
||||
setIsInteractive(true)
|
||||
|
||||
expect(areExplorePlanAgentsEnabled()).toBe(true)
|
||||
|
||||
const agentTypes = getBuiltInAgents().map(agent => agent.agentType)
|
||||
|
||||
expect(agentTypes).toContain('Explore')
|
||||
expect(agentTypes).toContain('Plan')
|
||||
expect(agentTypes).toContain('verification')
|
||||
})
|
||||
|
||||
test('preserves SDK opt-out in noninteractive sessions', () => {
|
||||
setIsInteractive(false)
|
||||
process.env.CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS = 'true'
|
||||
|
||||
expect(getBuiltInAgents()).toEqual([])
|
||||
})
|
||||
})
|
||||
@ -11,14 +11,27 @@ import { VERIFICATION_AGENT } from './built-in/verificationAgent.js'
|
||||
import type { AgentDefinition } from './loadAgentsDir.js'
|
||||
|
||||
export function areExplorePlanAgentsEnabled(): boolean {
|
||||
if (process.env.USER_TYPE !== 'ant') {
|
||||
return true
|
||||
}
|
||||
|
||||
if (feature('BUILTIN_EXPLORE_PLAN_AGENTS')) {
|
||||
// 3P default: true — Bedrock/Vertex keep agents enabled (matches pre-experiment
|
||||
// external behavior). A/B test treatment sets false to measure impact of removal.
|
||||
return getFeatureValue_CACHED_MAY_BE_STALE('tengu_amber_stoat', true)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function isVerificationAgentEnabled(): boolean {
|
||||
if (process.env.USER_TYPE !== 'ant') {
|
||||
return true
|
||||
}
|
||||
|
||||
if (feature('VERIFICATION_AGENT')) {
|
||||
return getFeatureValue_CACHED_MAY_BE_STALE('tengu_hive_evidence', false)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export function getBuiltInAgents(): AgentDefinition[] {
|
||||
// Allow disabling all built-in agents via env var (useful for SDK users who want a blank slate)
|
||||
// Only applies in noninteractive mode (SDK/API usage)
|
||||
@ -61,10 +74,7 @@ export function getBuiltInAgents(): AgentDefinition[] {
|
||||
agents.push(CLAUDE_CODE_GUIDE_AGENT)
|
||||
}
|
||||
|
||||
if (
|
||||
feature('VERIFICATION_AGENT') &&
|
||||
getFeatureValue_CACHED_MAY_BE_STALE('tengu_hive_evidence', false)
|
||||
) {
|
||||
if (isVerificationAgentEnabled()) {
|
||||
agents.push(VERIFICATION_AGENT)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user