feat: 完成stub

This commit is contained in:
claude-code-best committed 2026-03-31 20:40:16 +08:00
1 parent c26d614fb2
commit bd756cc369
905 files changed
+3996 -375

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
// Re-export runtime values + type stubs for bundling
// Types are erased at runtime, but we need the value exports
export const HOOK_EVENTS = [
'PreToolUse',
'PostToolUse',
'PostToolUseFailure',
'Notification',
'UserPromptSubmit',
'SessionStart',
'SessionEnd',
'Stop',
'StopFailure',
'SubagentStart',
'SubagentStop',
'PreCompact',
'PostCompact',
'PermissionRequest',
'PermissionDenied',
'Setup',
'TeammateIdle',
'TaskCreated',
'TaskCompleted',
'Elicitation',
'ElicitationResult',
'ConfigChange',
'WorktreeCreate',
'WorktreeRemove',
'InstructionsLoaded',
'CwdChanged',
'FileChanged',
]
export const EXIT_REASONS = [
'clear',
'resume',
'logout',
'prompt_input_exit',
'other',
]
+2
View File
@@ -441,3 +441,5 @@ export async function connectRemoteControl(
): Promise<RemoteControlHandle | null> {
throw new Error('not implemented')
}
export type HookEvent = any;
export type ExitReason = any;
+272 -272
View File
@@ -1,16 +1,18 @@
import { feature } from 'bun:bundle';
import { feature } from "bun:bundle";
// 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 || '';
// 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';
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 || "";
// 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";
}
// Harness-science L0 ablation baseline. Inlined here (not init.ts) because
@@ -18,11 +20,19 @@ if (process.env.CLAUDE_CODE_REMOTE === 'true') {
// module-level consts at import time — init() runs too late. feature() gate
// DCEs this entire block from external builds.
// eslint-disable-next-line custom-rules/no-top-level-side-effects, custom-rules/no-process-env-top-level
if (feature('ABLATION_BASELINE') && process.env.CLAUDE_CODE_ABLATION_BASELINE) {
for (const k of ['CLAUDE_CODE_SIMPLE', 'CLAUDE_CODE_DISABLE_THINKING', 'DISABLE_INTERLEAVED_THINKING', 'DISABLE_COMPACT', 'DISABLE_AUTO_COMPACT', 'CLAUDE_CODE_DISABLE_AUTO_MEMORY', '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';
}
if (feature("ABLATION_BASELINE") && process.env.CLAUDE_CODE_ABLATION_BASELINE) {
for (const k of [
"CLAUDE_CODE_SIMPLE",
"CLAUDE_CODE_DISABLE_THINKING",
"DISABLE_INTERLEAVED_THINKING",
"DISABLE_COMPACT",
"DISABLE_AUTO_COMPACT",
"CLAUDE_CODE_DISABLE_AUTO_MEMORY",
"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";
}
}
/**
@@ -31,273 +41,263 @@ 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')) {
// MACRO.VERSION is inlined at build time
// biome-ignore lint/suspicious/noConsole:: intentional console output
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');
// 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);
// biome-ignore lint/suspicious/noConsole:: intentional console output
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;
} 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;
}
// Fast-path for `--daemon-worker=<kind>` (internal — supervisor spawns this).
// Must come before the daemon subcommand check: spawned per-worker, so
// perf-sensitive. No enableConfigs(), no analytics sinks at this layer —
// workers are lean. If a worker kind needs configs/auth (assistant will),
// it calls them inside its run() fn.
if (feature('DAEMON') && args[0] === '--daemon-worker') {
const {
runDaemonWorker
} = await import('../daemon/workerRegistry.js');
await runDaemonWorker(args[1]);
return;
}
// Fast-path for `claude remote-control` (also accepts legacy `claude remote` / `claude sync` / `claude bridge`):
// serve local machine as bridge environment.
// feature() must stay inline for build-time dead code elimination;
// isBridgeEnabled() checks the runtime GrowthBook gate.
if (feature('BRIDGE_MODE') && (args[0] === 'remote-control' || args[0] === 'rc' || args[0] === 'remote' || args[0] === 'sync' || args[0] === 'bridge')) {
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');
// 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');
if (!getClaudeAIOAuthTokens()?.accessToken) {
exitWithError(BRIDGE_LOGIN_ERROR);
}
const disabledReason = await getBridgeDisabledReason();
if (disabledReason) {
exitWithError(`Error: ${disabledReason}`);
}
const versionError = checkBridgeMinVersion();
if (versionError) {
exitWithError(versionError);
}
// Bridge is a remote control feature - check policy limits
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.");
}
await bridgeMain(args.slice(1));
return;
}
// Fast-path for `claude daemon [subcommand]`: long-running supervisor.
if (feature('DAEMON') && args[0] === 'daemon') {
profileCheckpoint('cli_daemon_path');
const {
enableConfigs
} = await import('../utils/config.js');
enableConfigs();
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 ps|logs|attach|kill` and `--bg`/`--background`.
// Session management against the ~/.claude/sessions/ registry. Flag
// literals are inlined so bg.js only loads when actually dispatching.
if (feature('BG_SESSIONS') && (args[0] === 'ps' || args[0] === 'logs' || args[0] === 'attach' || args[0] === 'kill' || args.includes('--bg') || args.includes('--background'))) {
profileCheckpoint('cli_bg_path');
const {
enableConfigs
} = await import('../utils/config.js');
enableConfigs();
const bg = await import('../cli/bg.js');
switch (args[0]) {
case 'ps':
await bg.psHandler(args.slice(1));
break;
case 'logs':
await bg.logsHandler(args[1]);
break;
case 'attach':
await bg.attachHandler(args[1]);
break;
case 'kill':
await bg.killHandler(args[1]);
break;
default:
await bg.handleBgFlag(args);
}
return;
}
// Fast-path for template job commands.
if (feature('TEMPLATES') && (args[0] === 'new' || args[0] === 'list' || args[0] === 'reply')) {
profileCheckpoint('cli_templates_path');
const {
templatesMain
} = await import('../cli/handlers/templateJobs.js');
await templatesMain(args);
// 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);
}
// 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;
}
// 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;
}
// Fast-path for --worktree --tmux: exec into tmux before loading full CLI
const hasTmuxFlag = args.includes('--tmux') || args.includes('--tmux=classic');
if (hasTmuxFlag && (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');
if (isWorktreeModeEnabled()) {
const {
execIntoTmuxWorktree
} = await import('../utils/worktree.js');
const result = await execIntoTmuxWorktree(args);
if (result.handled) {
// Fast-path for --version/-v: zero module loading needed
if (
args.length === 1 &&
(args[0] === "--version" || args[0] === "-v" || args[0] === "-V")
) {
// MACRO.VERSION is inlined at build time
// biome-ignore lint/suspicious/noConsole:: intentional console output
console.log(`${MACRO.VERSION} (Claude Code)`);
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);
}
}
}
// 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'];
}
// For all other paths, load the startup profiler
const { profileCheckpoint } = await import("../utils/startupProfiler.js");
profileCheckpoint("cli_entry");
// --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';
}
// 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);
// biome-ignore lint/suspicious/noConsole:: intentional console output
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;
} 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;
}
// 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.js');
profileCheckpoint('cli_after_main_import');
await cliMain();
profileCheckpoint('cli_after_main_complete');
// Fast-path for `--daemon-worker=<kind>` (internal — supervisor spawns this).
// Must come before the daemon subcommand check: spawned per-worker, so
// perf-sensitive. No enableConfigs(), no analytics sinks at this layer —
// workers are lean. If a worker kind needs configs/auth (assistant will),
// it calls them inside its run() fn.
if (feature("DAEMON") && args[0] === "--daemon-worker") {
const { runDaemonWorker } = await import("../daemon/workerRegistry.js");
await runDaemonWorker(args[1]);
return;
}
// Fast-path for `claude remote-control` (also accepts legacy `claude remote` / `claude sync` / `claude bridge`):
// serve local machine as bridge environment.
// feature() must stay inline for build-time dead code elimination;
// isBridgeEnabled() checks the runtime GrowthBook gate.
if (
feature("BRIDGE_MODE") &&
(args[0] === "remote-control" ||
args[0] === "rc" ||
args[0] === "remote" ||
args[0] === "sync" ||
args[0] === "bridge")
) {
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");
// 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");
if (!getClaudeAIOAuthTokens()?.accessToken) {
exitWithError(BRIDGE_LOGIN_ERROR);
}
const disabledReason = await getBridgeDisabledReason();
if (disabledReason) {
exitWithError(`Error: ${disabledReason}`);
}
const versionError = checkBridgeMinVersion();
if (versionError) {
exitWithError(versionError);
}
// Bridge is a remote control feature - check policy limits
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.",
);
}
await bridgeMain(args.slice(1));
return;
}
// Fast-path for `claude daemon [subcommand]`: long-running supervisor.
if (feature("DAEMON") && args[0] === "daemon") {
profileCheckpoint("cli_daemon_path");
const { enableConfigs } = await import("../utils/config.js");
enableConfigs();
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 ps|logs|attach|kill` and `--bg`/`--background`.
// Session management against the ~/.claude/sessions/ registry. Flag
// literals are inlined so bg.js only loads when actually dispatching.
if (
feature("BG_SESSIONS") &&
(args[0] === "ps" ||
args[0] === "logs" ||
args[0] === "attach" ||
args[0] === "kill" ||
args.includes("--bg") ||
args.includes("--background"))
) {
profileCheckpoint("cli_bg_path");
const { enableConfigs } = await import("../utils/config.js");
enableConfigs();
const bg = await import("../cli/bg.js");
switch (args[0]) {
case "ps":
await bg.psHandler(args.slice(1));
break;
case "logs":
await bg.logsHandler(args[1]);
break;
case "attach":
await bg.attachHandler(args[1]);
break;
case "kill":
await bg.killHandler(args[1]);
break;
default:
await bg.handleBgFlag(args);
}
return;
}
// Fast-path for template job commands.
if (
feature("TEMPLATES") &&
(args[0] === "new" || args[0] === "list" || args[0] === "reply")
) {
profileCheckpoint("cli_templates_path");
const { templatesMain } =
await import("../cli/handlers/templateJobs.js");
await templatesMain(args);
// 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);
}
// 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;
}
// 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;
}
// Fast-path for --worktree --tmux: exec into tmux before loading full CLI
const hasTmuxFlag =
args.includes("--tmux") || args.includes("--tmux=classic");
if (
hasTmuxFlag &&
(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");
if (isWorktreeModeEnabled()) {
const { execIntoTmuxWorktree } =
await import("../utils/worktree.js");
const result = await execIntoTmuxWorktree(args);
if (result.handled) {
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);
}
}
}
// 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"];
}
// --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";
}
// 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");
}
// eslint-disable-next-line custom-rules/no-top-level-side-effects
void main();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJmZWF0dXJlIiwicHJvY2VzcyIsImVudiIsIkNPUkVQQUNLX0VOQUJMRV9BVVRPX1BJTiIsIkNMQVVERV9DT0RFX1JFTU9URSIsImV4aXN0aW5nIiwiTk9ERV9PUFRJT05TIiwiQ0xBVURFX0NPREVfQUJMQVRJT05fQkFTRUxJTkUiLCJrIiwibWFpbiIsIlByb21pc2UiLCJhcmdzIiwiYXJndiIsInNsaWNlIiwibGVuZ3RoIiwiY29uc29sZSIsImxvZyIsIk1BQ1JPIiwiVkVSU0lPTiIsInByb2ZpbGVDaGVja3BvaW50IiwiZW5hYmxlQ29uZmlncyIsImdldE1haW5Mb29wTW9kZWwiLCJtb2RlbElkeCIsImluZGV4T2YiLCJtb2RlbCIsImdldFN5c3RlbVByb21wdCIsInByb21wdCIsImpvaW4iLCJydW5DbGF1ZGVJbkNocm9tZU1jcFNlcnZlciIsInJ1bkNocm9tZU5hdGl2ZUhvc3QiLCJydW5Db21wdXRlclVzZU1jcFNlcnZlciIsInJ1bkRhZW1vbldvcmtlciIsImdldEJyaWRnZURpc2FibGVkUmVhc29uIiwiY2hlY2tCcmlkZ2VNaW5WZXJzaW9uIiwiQlJJREdFX0x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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;
+16
View File
@@ -0,0 +1,16 @@
/**
* Stub: SDK Control Types (not yet published in open-source).
* Used by bridge/transport layer for the control protocol.
*/
export type SDKControlRequest = { type: string; [key: string]: unknown }
export type SDKControlResponse = { type: string; [key: string]: unknown }
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 SDKControlPermissionRequest = any;
export type SDKControlCancelRequest = any;
export type SDKControlRequestInner = any;
+144
View File
@@ -0,0 +1,144 @@
/**
* Stub: Generated SDK core types.
*
* In the full build, this is auto-generated from coreSchemas.ts Zod schemas.
* Here we provide typed stubs for all the types referenced throughout the codebase.
*/
// Usage & Model
export type ModelUsage = {
inputTokens: number
outputTokens: number
cacheReadInputTokens: number
cacheCreationInputTokens: number
webSearchRequests: number
costUSD: number
contextWindow: number
maxOutputTokens: number
}
export type ApiKeySource = string
export type ModelInfo = {
name: string
displayName?: string
[key: string]: unknown
}
// MCP
export type McpServerConfigForProcessTransport = {
command: string
args: string[]
type?: "stdio"
env?: Record<string, string>
} & { scope: string; pluginSource?: string }
export type McpServerStatus = {
name: string
status: "connected" | "disconnected" | "error"
[key: string]: unknown
}
// Permissions
export type PermissionMode = string
export type PermissionResult =
| { behavior: "allow" }
| { behavior: "deny"; message?: string }
export type PermissionUpdate = {
path: string
permission: string
[key: string]: unknown
}
// Rewind
export type RewindFilesResult = {
filesChanged: string[]
[key: string]: unknown
}
// Account
export type AccountInfo = Record<string, unknown>
// Hook input types
export type HookInput = { hook_event_name: string; [key: string]: unknown }
export type HookJSONOutput = Record<string, unknown>
export type AsyncHookJSONOutput = Record<string, unknown>
export type SyncHookJSONOutput = Record<string, unknown>
export type PreToolUseHookInput = HookInput & { tool_name: string }
export type PostToolUseHookInput = HookInput & { tool_name: string }
export type PostToolUseFailureHookInput = HookInput & { tool_name: string }
export type PermissionRequestHookInput = HookInput & { tool_name: string }
export type PermissionDeniedHookInput = HookInput
export type NotificationHookInput = HookInput & { message: string }
export type UserPromptSubmitHookInput = HookInput & { prompt: string }
export type SessionStartHookInput = HookInput
export type SessionEndHookInput = HookInput & { exit_reason: string }
export type SetupHookInput = HookInput
export type StopHookInput = HookInput
export type StopFailureHookInput = HookInput
export type SubagentStartHookInput = HookInput
export type SubagentStopHookInput = HookInput
export type PreCompactHookInput = HookInput
export type PostCompactHookInput = HookInput
export type TeammateIdleHookInput = HookInput
export type TaskCreatedHookInput = HookInput
export type TaskCompletedHookInput = HookInput
export type ElicitationHookInput = HookInput
export type ElicitationResultHookInput = HookInput
export type ConfigChangeHookInput = HookInput
export type InstructionsLoadedHookInput = HookInput
export type CwdChangedHookInput = HookInput & { cwd: string }
export type FileChangedHookInput = HookInput & { path: string }
// SDK Message types
export type SDKMessage = { type: string; [key: string]: unknown }
export type SDKUserMessage = { type: "user"; content: unknown; uuid: string; [key: string]: unknown }
export type SDKUserMessageReplay = SDKUserMessage
export type SDKAssistantMessage = { type: "assistant"; content: unknown; [key: string]: unknown }
export type SDKAssistantMessageError = { type: "assistant_error"; error: unknown; [key: string]: unknown }
export type SDKPartialAssistantMessage = { type: "partial_assistant"; [key: string]: unknown }
export type SDKResultMessage = { type: "result"; [key: string]: unknown }
export type SDKResultSuccess = { type: "result_success"; [key: string]: unknown }
export type SDKSystemMessage = { type: "system"; [key: string]: unknown }
export type SDKStatusMessage = { type: "status"; [key: string]: unknown }
export type SDKToolProgressMessage = { type: "tool_progress"; [key: string]: unknown }
export type SDKCompactBoundaryMessage = { type: "compact_boundary"; [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 SDKSessionInfo = {
sessionId: string
summary?: string
[key: string]: unknown
}
// Other referenced types
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 McpServerStatusConfig = { [key: string]: unknown }
export type McpSetServersResult = { [key: string]: unknown }
export type PermissionUpdateDestination = string
export type PermissionBehavior = string
export type PermissionRuleValue = string
export type PermissionDecisionClassification = string
export type PromptRequestOption = { [key: string]: unknown }
export type PromptRequest = { [key: string]: unknown }
export type PromptResponse = { [key: string]: unknown }
export type SlashCommand = { [key: string]: unknown }
export type AgentInfo = { [key: string]: unknown }
export type AgentMcpServerSpec = { [key: string]: unknown }
export type AgentDefinition = { [key: string]: unknown }
export type SettingSource = { [key: string]: unknown }
export type SdkPluginConfig = { [key: string]: unknown }
export type FastModeState = { [key: string]: unknown }
+2
View File
@@ -0,0 +1,2 @@
// Auto-generated type stub — replace with real implementation
export type EffortLevel = any;
+63
View File
@@ -0,0 +1,63 @@
/**
* Stub: SDK Runtime Types (not yet published in open-source).
* Non-serializable types: callbacks, interfaces with methods.
*/
export type AnyZodRawShape = Record<string, any>
export type InferShape<T extends AnyZodRawShape> = { [K in keyof T]: any }
export type ForkSessionOptions = { dir?: string; upToMessageId?: string; title?: string }
export type ForkSessionResult = { sessionId: string }
export type GetSessionInfoOptions = { dir?: string }
export type GetSessionMessagesOptions = { dir?: string; limit?: number; offset?: number; includeSystemMessages?: boolean }
export type ListSessionsOptions = { dir?: string; limit?: number; offset?: number }
export type SessionMutationOptions = { dir?: string }
export type SessionMessage = { role: string; content: unknown; [key: string]: unknown }
export interface SDKSession {
sessionId: string
prompt(input: string | AsyncIterable<unknown>): Promise<unknown>
abort(): void
[key: string]: unknown
}
export type SDKSessionOptions = {
model?: string
systemPrompt?: string
[key: string]: unknown
}
export interface SdkMcpToolDefinition<T extends AnyZodRawShape = AnyZodRawShape> {
name: string
description: string
inputSchema: T
handler: (args: InferShape<T>, extra: unknown) => Promise<unknown>
[key: string]: unknown
}
export type McpSdkServerConfigWithInstance = {
name: string
version?: string
tools?: SdkMcpToolDefinition[]
[key: string]: unknown
}
export interface Options {
model?: string
systemPrompt?: string
[key: string]: unknown
}
export interface InternalOptions extends Options {
[key: string]: unknown
}
export interface Query {
[Symbol.asyncIterator](): AsyncIterator<unknown>
[key: string]: unknown
}
export interface InternalQuery extends Query {
[key: string]: unknown
}
export type EffortLevel = any;
+10
View File
@@ -0,0 +1,10 @@
/**
* Stub: SDK Utility Types.
*/
export type NonNullableUsage = {
inputTokens: number
outputTokens: number
cacheReadInputTokens: number
cacheCreationInputTokens: number
[key: string]: unknown
}
@@ -0,0 +1,4 @@
/**
* Stub: SDK Settings Types (generated from settings JSON schema).
*/
export type Settings = Record<string, unknown>
+9
View File
@@ -0,0 +1,9 @@
/**
* Stub: SDK Tool Types.
*/
export type SdkToolDefinition = {
name: string
description: string
inputSchema: Record<string, unknown>
[key: string]: unknown
}
+2
View File
@@ -0,0 +1,2 @@
// Auto-generated type stub — replace with real implementation
export type getIsNonInteractiveSession = any;
@@ -0,0 +1,2 @@
// Auto-generated type stub — replace with real implementation
export type getDefaultAppState = any;