style: 完成所有文件的lint

This commit is contained in:
claude-code-best
2026-05-01 21:39:30 +08:00
parent d136872cc9
commit 6182015005
1333 changed files with 68255 additions and 77882 deletions

View File

@@ -441,5 +441,5 @@ export async function connectRemoteControl(
): Promise<RemoteControlHandle | null> {
throw new Error('not implemented')
}
export type HookEvent = any;
export type ExitReason = any;
export type HookEvent = any
export type ExitReason = any

View File

@@ -1,11 +1,11 @@
#!/usr/bin/env bun
import { feature } from 'bun:bundle'
import { isEnvTruthy } from '../utils/envUtils.js'
import { feature } from 'bun:bundle';
import { isEnvTruthy } from '../utils/envUtils.js';
// Runtime fallback for MACRO.* when not injected by build/dev defines.
// This happens when running cli.tsx directly (not via `bun run dev` or built dist/).
if (typeof globalThis.MACRO === 'undefined') {
;(globalThis as any).MACRO = {
(globalThis as any).MACRO = {
VERSION: process.env.CLAUDE_CODE_VERSION || '2.1.888',
BUILD_TIME: new Date().toISOString(),
FEEDBACK_CHANNEL: '',
@@ -13,7 +13,7 @@ if (typeof globalThis.MACRO === 'undefined') {
NATIVE_PACKAGE_URL: '',
PACKAGE_URL: '',
VERSION_CHANGELOG: '',
}
};
}
if (isEnvTruthy(process.env.CLAUDE_CODE_FORCE_INTERACTIVE)) {
@@ -23,7 +23,7 @@ if (isEnvTruthy(process.env.CLAUDE_CODE_FORCE_INTERACTIVE)) {
Object.defineProperty(stream, 'isTTY', {
value: true,
configurable: true,
})
});
} catch {
// Best-effort dev-only override for nested bun launch on Windows.
}
@@ -33,17 +33,15 @@ if (isEnvTruthy(process.env.CLAUDE_CODE_FORCE_INTERACTIVE)) {
// Bugfix for corepack auto-pinning, which adds yarnpkg to peoples' package.jsons
// eslint-disable-next-line custom-rules/no-top-level-side-effects
process.env.COREPACK_ENABLE_AUTO_PIN = '0'
process.env.COREPACK_ENABLE_AUTO_PIN = '0';
// Set max heap size for child processes in CCR environments (containers have 16GB)
// eslint-disable-next-line custom-rules/no-top-level-side-effects, custom-rules/no-process-env-top-level, custom-rules/safe-env-boolean-check
if (process.env.CLAUDE_CODE_REMOTE === 'true') {
// eslint-disable-next-line custom-rules/no-top-level-side-effects, custom-rules/no-process-env-top-level
const existing = process.env.NODE_OPTIONS || ''
const existing = process.env.NODE_OPTIONS || '';
// eslint-disable-next-line custom-rules/no-top-level-side-effects, custom-rules/no-process-env-top-level
process.env.NODE_OPTIONS = existing
? `${existing} --max-old-space-size=8192`
: '--max-old-space-size=8192'
process.env.NODE_OPTIONS = existing ? `${existing} --max-old-space-size=8192` : '--max-old-space-size=8192';
}
// Harness-science L0 ablation baseline. Inlined here (not init.ts) because
@@ -62,7 +60,7 @@ if (feature('ABLATION_BASELINE') && process.env.CLAUDE_CODE_ABLATION_BASELINE) {
'CLAUDE_CODE_DISABLE_BACKGROUND_TASKS',
]) {
// eslint-disable-next-line custom-rules/no-top-level-side-effects, custom-rules/no-process-env-top-level
process.env[k] ??= '1'
process.env[k] ??= '1';
}
}
@@ -72,95 +70,86 @@ if (feature('ABLATION_BASELINE') && process.env.CLAUDE_CODE_ABLATION_BASELINE) {
* Fast-path for --version has zero imports beyond this file.
*/
async function main(): Promise<void> {
const args = process.argv.slice(2)
const args = process.argv.slice(2);
// Fast-path for --version/-v: zero module loading needed
if (
args.length === 1 &&
(args[0] === '--version' || args[0] === '-v' || args[0] === '-V')
) {
if (args.length === 1 && (args[0] === '--version' || args[0] === '-v' || args[0] === '-V')) {
// MACRO.VERSION is inlined at build time
console.log(`${MACRO.VERSION} (Claude Code)`)
return
console.log(`${MACRO.VERSION} (Claude Code)`);
return;
}
// For all other paths, load the startup profiler
const { profileCheckpoint } = await import('../utils/startupProfiler.js')
profileCheckpoint('cli_entry')
const { profileCheckpoint } = await import('../utils/startupProfiler.js');
profileCheckpoint('cli_entry');
// Fast-path for --dump-system-prompt: output the rendered system prompt and exit.
// Used by prompt sensitivity evals to extract the system prompt at a specific commit.
// Ant-only: eliminated from external builds via feature flag.
if (feature('DUMP_SYSTEM_PROMPT') && args[0] === '--dump-system-prompt') {
profileCheckpoint('cli_dump_system_prompt_path')
const { enableConfigs } = await import('../utils/config.js')
enableConfigs()
const { getMainLoopModel } = await import('../utils/model/model.js')
const modelIdx = args.indexOf('--model')
const model = (modelIdx !== -1 && args[modelIdx + 1]) || getMainLoopModel()
const { getSystemPrompt } = await import('../constants/prompts.js')
const prompt = await getSystemPrompt([], model)
console.log(prompt.join('\n'))
return
profileCheckpoint('cli_dump_system_prompt_path');
const { enableConfigs } = await import('../utils/config.js');
enableConfigs();
const { getMainLoopModel } = await import('../utils/model/model.js');
const modelIdx = args.indexOf('--model');
const model = (modelIdx !== -1 && args[modelIdx + 1]) || getMainLoopModel();
const { getSystemPrompt } = await import('../constants/prompts.js');
const prompt = await getSystemPrompt([], model);
console.log(prompt.join('\n'));
return;
}
if (process.argv[2] === '--claude-in-chrome-mcp') {
profileCheckpoint('cli_claude_in_chrome_mcp_path')
const { runClaudeInChromeMcpServer } = await import(
'../utils/claudeInChrome/mcpServer.js'
)
await runClaudeInChromeMcpServer()
return
profileCheckpoint('cli_claude_in_chrome_mcp_path');
const { runClaudeInChromeMcpServer } = await import('../utils/claudeInChrome/mcpServer.js');
await runClaudeInChromeMcpServer();
return;
} else if (process.argv[2] === '--chrome-native-host') {
profileCheckpoint('cli_chrome_native_host_path')
const { runChromeNativeHost } = await import(
'../utils/claudeInChrome/chromeNativeHost.js'
)
await runChromeNativeHost()
return
} else if (
feature('CHICAGO_MCP') &&
process.argv[2] === '--computer-use-mcp'
) {
profileCheckpoint('cli_computer_use_mcp_path')
const { runComputerUseMcpServer } = await import(
'../utils/computerUse/mcpServer.js'
)
await runComputerUseMcpServer()
return
profileCheckpoint('cli_chrome_native_host_path');
const { runChromeNativeHost } = await import('../utils/claudeInChrome/chromeNativeHost.js');
await runChromeNativeHost();
return;
} else if (feature('CHICAGO_MCP') && process.argv[2] === '--computer-use-mcp') {
profileCheckpoint('cli_computer_use_mcp_path');
const { runComputerUseMcpServer } = await import('../utils/computerUse/mcpServer.js');
await runComputerUseMcpServer();
return;
}
// Fast-path for `--acp` — ACP (Agent Client Protocol) agent mode over stdio.
if (feature('ACP') && process.argv[2] === '--acp') {
profileCheckpoint('cli_acp_path')
const { runAcpAgent } = await import('../services/acp/entry.js')
await runAcpAgent()
return
profileCheckpoint('cli_acp_path');
const { runAcpAgent } = await import('../services/acp/entry.js');
await runAcpAgent();
return;
}
if (args[0] === 'weixin') {
profileCheckpoint('cli_weixin_path')
const { handleWeixinCli } = await import('@claude-code-best/weixin')
const { enableConfigs } = await import('../utils/config.js')
const { initializeAnalyticsSink } = await import('../services/analytics/sink.js')
const { shutdownDatadog } = await import('../services/analytics/datadog.js')
const { shutdown1PEventLogging } = await import('../services/analytics/firstPartyEventLogger.js')
const { logForDebugging } = await import('../utils/debug.js')
const { ChannelPermissionRequestNotificationSchema } = await import('../services/mcp/channelNotification.js')
await handleWeixinCli(args.slice(1), {
enableConfigs,
initializeAnalyticsSink,
shutdownDatadog,
shutdown1PEventLogging,
logForDebugging,
registerPermissionHandler(server, handler) {
server.setNotificationHandler(
ChannelPermissionRequestNotificationSchema(),
async notification => handler(notification.params),
)
profileCheckpoint('cli_weixin_path');
const { handleWeixinCli } = await import('@claude-code-best/weixin');
const { enableConfigs } = await import('../utils/config.js');
const { initializeAnalyticsSink } = await import('../services/analytics/sink.js');
const { shutdownDatadog } = await import('../services/analytics/datadog.js');
const { shutdown1PEventLogging } = await import('../services/analytics/firstPartyEventLogger.js');
const { logForDebugging } = await import('../utils/debug.js');
const { ChannelPermissionRequestNotificationSchema } = await import('../services/mcp/channelNotification.js');
await handleWeixinCli(
args.slice(1),
{
enableConfigs,
initializeAnalyticsSink,
shutdownDatadog,
shutdown1PEventLogging,
logForDebugging,
registerPermissionHandler(server, handler) {
server.setNotificationHandler(ChannelPermissionRequestNotificationSchema(), async notification =>
handler(notification.params),
);
},
},
}, MACRO.VERSION)
return
MACRO.VERSION,
);
return;
}
// Fast-path for `--daemon-worker=<kind>` (internal — supervisor spawns this).
@@ -170,14 +159,16 @@ async function main(): Promise<void> {
// it calls them inside its run() fn.
if (args[0] === '--daemon-worker' || args[0]?.startsWith('--daemon-worker=')) {
if (!feature('DAEMON')) {
console.error('Error: --daemon-worker requires DAEMON feature to be enabled. Set FEATURE_DAEMON=1 or add DAEMON to DEFAULT_BUILD_FEATURES.')
process.exitCode = 1
return
console.error(
'Error: --daemon-worker requires DAEMON feature to be enabled. Set FEATURE_DAEMON=1 or add DAEMON to DEFAULT_BUILD_FEATURES.',
);
process.exitCode = 1;
return;
}
const kind = args[0] === '--daemon-worker' ? args[1] : args[0].split('=')[1]
const { runDaemonWorker } = await import('../daemon/workerRegistry.js')
await runDaemonWorker(kind)
return
const kind = args[0] === '--daemon-worker' ? args[1] : args[0].split('=')[1];
const { runDaemonWorker } = await import('../daemon/workerRegistry.js');
await runDaemonWorker(kind);
return;
}
// Fast-path for `claude remote-control` (also accepts legacy `claude remote` / `claude sync` / `claude bridge`):
@@ -192,67 +183,58 @@ async function main(): Promise<void> {
args[0] === 'sync' ||
args[0] === 'bridge')
) {
profileCheckpoint('cli_bridge_path')
const { enableConfigs } = await import('../utils/config.js')
enableConfigs()
profileCheckpoint('cli_bridge_path');
const { enableConfigs } = await import('../utils/config.js');
enableConfigs();
const { getBridgeDisabledReason, checkBridgeMinVersion } = await import(
'../bridge/bridgeEnabled.js'
)
const { BRIDGE_LOGIN_ERROR } = await import('../bridge/types.js')
const { bridgeMain } = await import('../bridge/bridgeMain.js')
const { exitWithError } = await import('../utils/process.js')
const { getBridgeDisabledReason, checkBridgeMinVersion } = await import('../bridge/bridgeEnabled.js');
const { BRIDGE_LOGIN_ERROR } = await import('../bridge/types.js');
const { bridgeMain } = await import('../bridge/bridgeMain.js');
const { exitWithError } = await import('../utils/process.js');
// Auth check must come before the GrowthBook gate check — without auth,
// GrowthBook has no user context and would return a stale/default false.
// getBridgeDisabledReason awaits GB init, so the returned value is fresh
// (not the stale disk cache), but init still needs auth headers to work.
const { getClaudeAIOAuthTokens } = await import('../utils/auth.js')
const { getBridgeAccessToken } = await import('../bridge/bridgeConfig.js')
const { getClaudeAIOAuthTokens } = await import('../utils/auth.js');
const { getBridgeAccessToken } = await import('../bridge/bridgeConfig.js');
if (!getClaudeAIOAuthTokens()?.accessToken && !getBridgeAccessToken()) {
exitWithError(BRIDGE_LOGIN_ERROR)
exitWithError(BRIDGE_LOGIN_ERROR);
}
const disabledReason = await getBridgeDisabledReason()
const disabledReason = await getBridgeDisabledReason();
if (disabledReason) {
exitWithError(`Error: ${disabledReason}`)
exitWithError(`Error: ${disabledReason}`);
}
const versionError = checkBridgeMinVersion()
const versionError = checkBridgeMinVersion();
if (versionError) {
exitWithError(versionError)
exitWithError(versionError);
}
// Bridge is a remote control feature - check policy limits
const { waitForPolicyLimitsToLoad, isPolicyAllowed } = await import(
'../services/policyLimits/index.js'
)
await waitForPolicyLimitsToLoad()
const { waitForPolicyLimitsToLoad, isPolicyAllowed } = await import('../services/policyLimits/index.js');
await waitForPolicyLimitsToLoad();
if (!isPolicyAllowed('allow_remote_control')) {
exitWithError(
"Error: Remote Control is disabled by your organization's policy.",
)
exitWithError("Error: Remote Control is disabled by your organization's policy.");
}
await bridgeMain(args.slice(1))
return
await bridgeMain(args.slice(1));
return;
}
// Fast-path for `claude daemon [subcommand]`: unified daemon + session management.
// Handles both supervisor (start/stop) and background session (bg/attach/logs/kill)
// subcommands under one namespace.
if (
(feature('DAEMON') || feature('BG_SESSIONS')) &&
args[0] === 'daemon'
) {
profileCheckpoint('cli_daemon_path')
const { enableConfigs } = await import('../utils/config.js')
enableConfigs()
const { setShellIfWindows } = await import('../utils/windowsPaths.js')
setShellIfWindows()
const { initSinks } = await import('../utils/sinks.js')
initSinks()
const { daemonMain } = await import('../daemon/main.js')
await daemonMain(args.slice(1))
return
if ((feature('DAEMON') || feature('BG_SESSIONS')) && args[0] === 'daemon') {
profileCheckpoint('cli_daemon_path');
const { enableConfigs } = await import('../utils/config.js');
enableConfigs();
const { setShellIfWindows } = await import('../utils/windowsPaths.js');
setShellIfWindows();
const { initSinks } = await import('../utils/sinks.js');
initSinks();
const { daemonMain } = await import('../daemon/main.js');
await daemonMain(args.slice(1));
return;
}
// Fast-path for `claude autonomy ...`: state inspection/management commands
@@ -261,164 +243,136 @@ async function main(): Promise<void> {
// action; under coverage/CI that leaves unrelated handles around simple
// state-only subprocess calls.
if (args[0] === 'autonomy') {
profileCheckpoint('cli_autonomy_path')
const { getAutonomyCommandText } = await import(
'../cli/handlers/autonomy.js'
)
const text = await getAutonomyCommandText(args.slice(1).join(' '))
profileCheckpoint('cli_autonomy_path');
const { getAutonomyCommandText } = await import('../cli/handlers/autonomy.js');
const text = await getAutonomyCommandText(args.slice(1).join(' '));
await new Promise<void>((resolve, reject) => {
process.stdout.write(`${text}\n`, error => {
if (error) {
reject(error)
return
reject(error);
return;
}
resolve()
})
})
process.exit(0)
resolve();
});
});
process.exit(0);
}
// Fast-path for `--bg`/`--background` shortcut → daemon bg.
if (
feature('BG_SESSIONS') &&
(args.includes('--bg') || args.includes('--background'))
) {
profileCheckpoint('cli_daemon_path')
const { enableConfigs } = await import('../utils/config.js')
enableConfigs()
const { setShellIfWindows } = await import('../utils/windowsPaths.js')
setShellIfWindows()
const bg = await import('../cli/bg.js')
await bg.handleBgStart(
args.filter(a => a !== '--bg' && a !== '--background'),
)
return
if (feature('BG_SESSIONS') && (args.includes('--bg') || args.includes('--background'))) {
profileCheckpoint('cli_daemon_path');
const { enableConfigs } = await import('../utils/config.js');
enableConfigs();
const { setShellIfWindows } = await import('../utils/windowsPaths.js');
setShellIfWindows();
const bg = await import('../cli/bg.js');
await bg.handleBgStart(args.filter(a => a !== '--bg' && a !== '--background'));
return;
}
// Backward-compat: ps/logs/attach/kill → daemon <sub> (deprecated)
if (
feature('BG_SESSIONS') &&
(args[0] === 'ps' ||
args[0] === 'logs' ||
args[0] === 'attach' ||
args[0] === 'kill')
(args[0] === 'ps' || args[0] === 'logs' || args[0] === 'attach' || args[0] === 'kill')
) {
const mapped = args[0] === 'ps' ? 'status' : args[0]
console.error(
`[deprecated] Use: claude daemon ${mapped}${args[1] ? ' ' + args[1] : ''}`,
)
profileCheckpoint('cli_daemon_path')
const { enableConfigs } = await import('../utils/config.js')
enableConfigs()
const { setShellIfWindows } = await import('../utils/windowsPaths.js')
setShellIfWindows()
const { initSinks } = await import('../utils/sinks.js')
initSinks()
const { daemonMain } = await import('../daemon/main.js')
await daemonMain([args[0] === 'ps' ? 'status' : args[0]!, ...args.slice(1)])
return
const mapped = args[0] === 'ps' ? 'status' : args[0];
console.error(`[deprecated] Use: claude daemon ${mapped}${args[1] ? ' ' + args[1] : ''}`);
profileCheckpoint('cli_daemon_path');
const { enableConfigs } = await import('../utils/config.js');
enableConfigs();
const { setShellIfWindows } = await import('../utils/windowsPaths.js');
setShellIfWindows();
const { initSinks } = await import('../utils/sinks.js');
initSinks();
const { daemonMain } = await import('../daemon/main.js');
await daemonMain([args[0] === 'ps' ? 'status' : args[0]!, ...args.slice(1)]);
return;
}
// Fast-path for `claude job <subcommand>`: template jobs.
if (feature('TEMPLATES') && args[0] === 'job') {
profileCheckpoint('cli_templates_path')
const { templatesMain } = await import('../cli/handlers/templateJobs.js')
await templatesMain(args.slice(1))
profileCheckpoint('cli_templates_path');
const { templatesMain } = await import('../cli/handlers/templateJobs.js');
await templatesMain(args.slice(1));
// process.exit (not return) — mountFleetView's Ink TUI can leave event
// loop handles that prevent natural exit.
// eslint-disable-next-line custom-rules/no-process-exit
process.exit(0)
process.exit(0);
}
// Backward-compat: new/list/reply → job <sub> (deprecated)
if (
feature('TEMPLATES') &&
(args[0] === 'new' || args[0] === 'list' || args[0] === 'reply')
) {
console.error(
`[deprecated] Use: claude job ${args[0]} ${args.slice(1).join(' ')}`.trim(),
)
profileCheckpoint('cli_templates_path')
const { templatesMain } = await import('../cli/handlers/templateJobs.js')
await templatesMain(args)
if (feature('TEMPLATES') && (args[0] === 'new' || args[0] === 'list' || args[0] === 'reply')) {
console.error(`[deprecated] Use: claude job ${args[0]} ${args.slice(1).join(' ')}`.trim());
profileCheckpoint('cli_templates_path');
const { templatesMain } = await import('../cli/handlers/templateJobs.js');
await templatesMain(args);
// eslint-disable-next-line custom-rules/no-process-exit
process.exit(0)
process.exit(0);
}
// Fast-path for `claude environment-runner`: headless BYOC runner.
// feature() must stay inline for build-time dead code elimination.
if (feature('BYOC_ENVIRONMENT_RUNNER') && args[0] === 'environment-runner') {
profileCheckpoint('cli_environment_runner_path')
const { environmentRunnerMain } = await import(
'../environment-runner/main.js'
)
await environmentRunnerMain(args.slice(1))
return
profileCheckpoint('cli_environment_runner_path');
const { environmentRunnerMain } = await import('../environment-runner/main.js');
await environmentRunnerMain(args.slice(1));
return;
}
// Fast-path for `claude self-hosted-runner`: headless self-hosted-runner
// targeting the SelfHostedRunnerWorkerService API (register + poll; poll IS
// heartbeat). feature() must stay inline for build-time dead code elimination.
if (feature('SELF_HOSTED_RUNNER') && args[0] === 'self-hosted-runner') {
profileCheckpoint('cli_self_hosted_runner_path')
const { selfHostedRunnerMain } = await import(
'../self-hosted-runner/main.js'
)
await selfHostedRunnerMain(args.slice(1))
return
profileCheckpoint('cli_self_hosted_runner_path');
const { selfHostedRunnerMain } = await import('../self-hosted-runner/main.js');
await selfHostedRunnerMain(args.slice(1));
return;
}
// Fast-path for --worktree --tmux: exec into tmux before loading full CLI
const hasTmuxFlag = args.includes('--tmux') || args.includes('--tmux=classic')
const hasTmuxFlag = args.includes('--tmux') || args.includes('--tmux=classic');
if (
hasTmuxFlag &&
(args.includes('-w') ||
args.includes('--worktree') ||
args.some(a => a.startsWith('--worktree=')))
(args.includes('-w') || args.includes('--worktree') || args.some(a => a.startsWith('--worktree=')))
) {
profileCheckpoint('cli_tmux_worktree_fast_path')
const { enableConfigs } = await import('../utils/config.js')
enableConfigs()
const { isWorktreeModeEnabled } = await import(
'../utils/worktreeModeEnabled.js'
)
profileCheckpoint('cli_tmux_worktree_fast_path');
const { enableConfigs } = await import('../utils/config.js');
enableConfigs();
const { isWorktreeModeEnabled } = await import('../utils/worktreeModeEnabled.js');
if (isWorktreeModeEnabled()) {
const { execIntoTmuxWorktree } = await import('../utils/worktree.js')
const result = await execIntoTmuxWorktree(args)
const { execIntoTmuxWorktree } = await import('../utils/worktree.js');
const result = await execIntoTmuxWorktree(args);
if (result.handled) {
return
return;
}
// If not handled (e.g., error), fall through to normal CLI
if (result.error) {
const { exitWithError } = await import('../utils/process.js')
exitWithError(result.error)
const { exitWithError } = await import('../utils/process.js');
exitWithError(result.error);
}
}
}
// Redirect common update flag mistakes to the update subcommand
if (
args.length === 1 &&
(args[0] === '--update' || args[0] === '--upgrade')
) {
process.argv = [process.argv[0]!, process.argv[1]!, 'update']
if (args.length === 1 && (args[0] === '--update' || args[0] === '--upgrade')) {
process.argv = [process.argv[0]!, process.argv[1]!, 'update'];
}
// --bare: set SIMPLE early so gates fire during module eval / commander
// option building (not just inside the action handler).
if (args.includes('--bare')) {
process.env.CLAUDE_CODE_SIMPLE = '1'
process.env.CLAUDE_CODE_SIMPLE = '1';
}
// No special flags detected, load and run the full CLI
const { startCapturingEarlyInput } = await import('../utils/earlyInput.js')
startCapturingEarlyInput()
profileCheckpoint('cli_before_main_import')
const { main: cliMain } = await import('../main.jsx')
profileCheckpoint('cli_after_main_import')
await cliMain()
profileCheckpoint('cli_after_main_complete')
const { startCapturingEarlyInput } = await import('../utils/earlyInput.js');
startCapturingEarlyInput();
profileCheckpoint('cli_before_main_import');
const { main: cliMain } = await import('../main.jsx');
profileCheckpoint('cli_after_main_import');
await cliMain();
profileCheckpoint('cli_after_main_complete');
}
// eslint-disable-next-line custom-rules/no-top-level-side-effects
await main()
await main();

View File

@@ -102,7 +102,6 @@ export const SDKControlInterruptRequestSchema = lazySchema(() =>
.describe('Interrupts the currently running conversation turn.'),
)
export const SDKControlPermissionRequestSchema = lazySchema(() =>
z
.object({
@@ -451,7 +450,6 @@ export const SDKControlMcpToggleRequestSchema = lazySchema(() =>
.describe('Enables or disables an MCP server.'),
)
export const SDKControlStopTaskRequestSchema = lazySchema(() =>
z
.object({
@@ -544,7 +542,6 @@ export const SDKControlElicitationResponseSchema = lazySchema(() =>
.describe('Response from the SDK consumer for an elicitation request.'),
)
// ============================================================================
// Control Request/Response Wrappers
// ============================================================================

View File

@@ -1,8 +1,8 @@
// Auto-generated type stub — replace with real implementation
export type StdoutMessage = any;
export type SDKControlInitializeRequest = any;
export type SDKControlInitializeResponse = any;
export type SDKControlMcpSetServersResponse = any;
export type SDKControlReloadPluginsResponse = any;
export type StdinMessage = any;
export type SDKPartialAssistantMessage = any;
export type StdoutMessage = any
export type SDKControlInitializeRequest = any
export type SDKControlInitializeResponse = any
export type SDKControlMcpSetServersResponse = any
export type SDKControlReloadPluginsResponse = any
export type StdinMessage = any
export type SDKPartialAssistantMessage = any

View File

@@ -20,15 +20,35 @@ import type {
} from './controlSchemas.js'
import type { SDKPartialAssistantMessageSchema } from './coreSchemas.js'
export type SDKControlRequest = z.infer<ReturnType<typeof SDKControlRequestSchema>>
export type SDKControlResponse = z.infer<ReturnType<typeof SDKControlResponseSchema>>
export type SDKControlRequest = z.infer<
ReturnType<typeof SDKControlRequestSchema>
>
export type SDKControlResponse = z.infer<
ReturnType<typeof SDKControlResponseSchema>
>
export type StdoutMessage = z.infer<ReturnType<typeof StdoutMessageSchema>>
export type SDKControlInitializeRequest = z.infer<ReturnType<typeof SDKControlInitializeRequestSchema>>
export type SDKControlInitializeResponse = z.infer<ReturnType<typeof SDKControlInitializeResponseSchema>>
export type SDKControlMcpSetServersResponse = z.infer<ReturnType<typeof SDKControlMcpSetServersResponseSchema>>
export type SDKControlReloadPluginsResponse = z.infer<ReturnType<typeof SDKControlReloadPluginsResponseSchema>>
export type SDKControlInitializeRequest = z.infer<
ReturnType<typeof SDKControlInitializeRequestSchema>
>
export type SDKControlInitializeResponse = z.infer<
ReturnType<typeof SDKControlInitializeResponseSchema>
>
export type SDKControlMcpSetServersResponse = z.infer<
ReturnType<typeof SDKControlMcpSetServersResponseSchema>
>
export type SDKControlReloadPluginsResponse = z.infer<
ReturnType<typeof SDKControlReloadPluginsResponseSchema>
>
export type StdinMessage = z.infer<ReturnType<typeof StdinMessageSchema>>
export type SDKPartialAssistantMessage = z.infer<ReturnType<typeof SDKPartialAssistantMessageSchema>>
export type SDKControlPermissionRequest = z.infer<ReturnType<typeof SDKControlPermissionRequestSchema>>
export type SDKControlCancelRequest = z.infer<ReturnType<typeof SDKControlCancelRequestSchema>>
export type SDKControlRequestInner = z.infer<ReturnType<typeof SDKControlRequestInnerSchema>>
export type SDKPartialAssistantMessage = z.infer<
ReturnType<typeof SDKPartialAssistantMessageSchema>
>
export type SDKControlPermissionRequest = z.infer<
ReturnType<typeof SDKControlPermissionRequestSchema>
>
export type SDKControlCancelRequest = z.infer<
ReturnType<typeof SDKControlCancelRequestSchema>
>
export type SDKControlRequestInner = z.infer<
ReturnType<typeof SDKControlRequestInnerSchema>
>

View File

@@ -336,7 +336,14 @@ export const PermissionResultSchema = lazySchema(() =>
export const PermissionModeSchema = lazySchema(() =>
z
.enum(['default', 'acceptEdits', 'bypassPermissions', 'plan', 'dontAsk', 'auto'])
.enum([
'default',
'acceptEdits',
'bypassPermissions',
'plan',
'dontAsk',
'auto',
])
.describe(
'Permission mode for controlling how tool executions are handled. ' +
"'default' - Standard behavior, prompts for dangerous operations. " +
@@ -348,7 +355,6 @@ export const PermissionModeSchema = lazySchema(() =>
),
)
// ============================================================================
// Hook Types
// ============================================================================
@@ -1750,7 +1756,6 @@ export const SDKSessionStateChangedMessageSchema = lazySchema(() =>
),
)
export const SDKTaskProgressMessageSchema = lazySchema(() =>
z.object({
type: z.literal('system'),

View File

@@ -33,13 +33,13 @@ export type ModelInfo = {
export type McpServerConfigForProcessTransport = {
command: string
args: string[]
type?: "stdio"
type?: 'stdio'
env?: Record<string, string>
} & { scope: string; pluginSource?: string }
export type McpServerStatus = {
name: string
status: "connected" | "disconnected" | "error"
status: 'connected' | 'disconnected' | 'error'
[key: string]: unknown
}
@@ -47,8 +47,8 @@ export type McpServerStatus = {
export type PermissionMode = string
export type PermissionResult =
| { behavior: "allow" }
| { behavior: "deny"; message?: string }
| { behavior: 'allow' }
| { behavior: 'deny'; message?: string }
export type PermissionUpdate = {
path: string
@@ -100,33 +100,89 @@ export type FileChangedHookInput = HookInput & { path: string }
// SDK Message types
export type SDKMessage = { type: string; [key: string]: unknown }
export type SDKUserMessage = {
type: "user"
type: 'user'
content: string | Array<{ type: string; [key: string]: unknown }>
uuid: string
message?: { role?: string; id?: string; content?: MessageContent; usage?: BetaUsage | Record<string, unknown>; [key: string]: unknown }
message?: {
role?: string
id?: string
content?: MessageContent
usage?: BetaUsage | Record<string, unknown>
[key: string]: unknown
}
tool_use_result?: unknown
timestamp?: string
[key: string]: unknown
}
export type SDKUserMessageReplay = SDKUserMessage
export type SDKAssistantMessage = {
type: "assistant"
type: 'assistant'
content: unknown
message?: { role?: string; id?: string; content?: MessageContent; usage?: BetaUsage | Record<string, unknown>; [key: string]: unknown }
message?: {
role?: string
id?: string
content?: MessageContent
usage?: BetaUsage | Record<string, unknown>
[key: string]: unknown
}
uuid?: UUID
error?: unknown
[key: string]: unknown
}
export type SDKAssistantErrorMessage = { type: "assistant_error"; error: unknown; [key: string]: unknown }
export type SDKAssistantMessageError = 'authentication_failed' | 'billing_error' | 'rate_limit' | 'invalid_request' | 'server_error' | 'unknown' | 'max_output_tokens'
export type SDKPartialAssistantMessage = { type: "partial_assistant"; event: { type: string; [key: string]: unknown }; [key: string]: unknown }
export type SDKResultMessage = { type: "result"; subtype?: string; errors?: string[]; result?: string; uuid?: UUID; [key: string]: unknown }
export type SDKResultSuccess = { type: "result_success"; [key: string]: unknown }
export type SDKSystemMessage = { type: "system"; subtype?: string; model?: string; uuid?: UUID; [key: string]: unknown }
export type SDKStatusMessage = { type: "status"; subtype?: string; status?: string; uuid?: UUID; [key: string]: unknown }
export type SDKToolProgressMessage = { type: "tool_progress"; tool_name?: string; elapsed_time_seconds?: number; uuid?: UUID; tool_use_id?: string; [key: string]: unknown }
export type SDKAssistantErrorMessage = {
type: 'assistant_error'
error: unknown
[key: string]: unknown
}
export type SDKAssistantMessageError =
| 'authentication_failed'
| 'billing_error'
| 'rate_limit'
| 'invalid_request'
| 'server_error'
| 'unknown'
| 'max_output_tokens'
export type SDKPartialAssistantMessage = {
type: 'partial_assistant'
event: { type: string; [key: string]: unknown }
[key: string]: unknown
}
export type SDKResultMessage = {
type: 'result'
subtype?: string
errors?: string[]
result?: string
uuid?: UUID
[key: string]: unknown
}
export type SDKResultSuccess = {
type: 'result_success'
[key: string]: unknown
}
export type SDKSystemMessage = {
type: 'system'
subtype?: string
model?: string
uuid?: UUID
[key: string]: unknown
}
export type SDKStatusMessage = {
type: 'status'
subtype?: string
status?: string
uuid?: UUID
[key: string]: unknown
}
export type SDKToolProgressMessage = {
type: 'tool_progress'
tool_name?: string
elapsed_time_seconds?: number
uuid?: UUID
tool_use_id?: string
[key: string]: unknown
}
export type SDKCompactBoundaryMessage = {
type: "compact_boundary"
type: 'compact_boundary'
uuid?: UUID
compact_metadata: {
trigger?: unknown
@@ -141,9 +197,12 @@ export type SDKCompactBoundaryMessage = {
}
[key: string]: unknown
}
export type SDKPermissionDenial = { type: "permission_denial"; [key: string]: unknown }
export type SDKRateLimitInfo = { type: "rate_limit"; [key: string]: unknown }
export type SDKStatus = "active" | "idle" | "error" | string
export type SDKPermissionDenial = {
type: 'permission_denial'
[key: string]: unknown
}
export type SDKRateLimitInfo = { type: 'rate_limit'; [key: string]: unknown }
export type SDKStatus = 'active' | 'idle' | 'error' | string
export type SDKSessionInfo = {
sessionId: string
@@ -152,15 +211,34 @@ export type SDKSessionInfo = {
}
// Other referenced types
export type OutputFormat = { type: "json_schema"; schema: Record<string, unknown> }
export type OutputFormat = {
type: 'json_schema'
schema: Record<string, unknown>
}
export type ConfigScope = string
export type SdkBeta = string
export type ThinkingConfig = { type: string; [key: string]: unknown }
export type McpStdioServerConfig = { command: string; args: string[]; type: "stdio"; env?: Record<string, string> }
export type McpSSEServerConfig = { type: "sse"; url: string; [key: string]: unknown }
export type McpHttpServerConfig = { type: "http"; url: string; [key: string]: unknown }
export type McpSdkServerConfig = { type: "sdk"; [key: string]: unknown }
export type McpClaudeAIProxyServerConfig = { type: "claudeai-proxy"; [key: string]: unknown }
export type McpStdioServerConfig = {
command: string
args: string[]
type: 'stdio'
env?: Record<string, string>
}
export type McpSSEServerConfig = {
type: 'sse'
url: string
[key: string]: unknown
}
export type McpHttpServerConfig = {
type: 'http'
url: string
[key: string]: unknown
}
export type McpSdkServerConfig = { type: 'sdk'; [key: string]: unknown }
export type McpClaudeAIProxyServerConfig = {
type: 'claudeai-proxy'
[key: string]: unknown
}
export type McpServerStatusConfig = { [key: string]: unknown }
export type McpSetServersResult = { [key: string]: unknown }
export type PermissionUpdateDestination = string

View File

@@ -1,2 +1,2 @@
// Auto-generated type stub — replace with real implementation
export type EffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
export type EffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max'