claude-code-best/src/commands/proactive.ts
James Feng 7f4dcfbabf feat(remote-control): 优化 Web 展示、状态同步与桥接控制流程 (#288)
Commit: 72a2093c
64 files changed, 4139 insertions(+), 313 deletions(-)
2026-06-04 23:51:54 +08:00

55 lines
1.7 KiB
TypeScript

/**
* /proactive — Toggle proactive (autonomous tick-driven) mode.
*
* When enabled, the model receives periodic <tick> prompts and works
* autonomously between user inputs. SleepTool controls pacing.
*/
import { feature } from 'bun:bundle'
import type { ToolUseContext } from '../Tool.js'
import type {
Command,
LocalJSXCommandContext,
LocalJSXCommandOnDone,
} from '../types/command.js'
import * as proactiveModuleValue from '../proactive/index.js'
const proactive = {
bridgeSafe: true,
type: 'local-jsx',
name: 'proactive',
description: 'Toggle proactive (autonomous) mode',
isEnabled: () => {
if (feature('PROACTIVE') || feature('KAIROS')) {
return true
}
return false
},
immediate: true,
load: () =>
Promise.resolve({
async call(
onDone: LocalJSXCommandOnDone,
_context: ToolUseContext & LocalJSXCommandContext,
): Promise<React.ReactNode> {
if (proactiveModuleValue.isProactiveActive()) {
proactiveModuleValue.deactivateProactive()
onDone('Proactive mode disabled', { display: 'system' })
} else {
proactiveModuleValue.activateProactive('slash_command')
onDone(
'Proactive mode enabled — model will work autonomously between ticks',
{
display: 'system',
metaMessages: [
'<system-reminder>\nProactive mode is now enabled. You will receive periodic <tick> prompts. Do useful work on each tick, or call Sleep if there is nothing to do. Do not output "still waiting" — either act or sleep.\n</system-reminder>',
],
},
)
}
return null
},
}),
} satisfies Command
export default proactive