From c787a9af3b2600becc9a70e6d870c3a194a2e516 Mon Sep 17 00:00:00 2001 From: idoubi Date: Wed, 1 Apr 2026 01:37:13 +0800 Subject: [PATCH] fix: lazy-load @anthropic-ai/sandbox-runtime to avoid hard dependency sandbox-runtime is an Anthropic-internal package not available to open-source consumers. Converting the static import to a lazy require() with no-op fallback prevents "Cannot find package" errors when the SDK is used in Next.js and other bundled environments. Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitignore | 1 + build.mjs | 114 ++++++++++++++++++ package-lock.json | 5 +- package.json | 5 +- src/bun-shim.ts | 2 +- src/cli/print.ts | 6 + src/commands/agents-platform/index.ts | 3 + src/commands/assistant/index.ts | 3 + src/commands/force-snip.ts | 3 + src/commands/proactive.ts | 3 + src/commands/remoteControlServer/index.ts | 3 + src/commands/subscribe-pr.ts | 3 + src/commands/torch.ts | 3 + src/entrypoints/cli.tsx | 2 +- src/main.tsx | 34 +++++- src/proactive/useProactive.ts | 2 + src/services/remoteManagedSettings/index.ts | 2 +- src/setup.ts | 11 ++ src/shims/globals.js | 3 + src/skills/bundled/claude-api/SKILL.md | 3 + .../bundled/claude-api/csharp/claude-api.md | 3 + .../bundled/claude-api/curl/examples.md | 3 + .../bundled/claude-api/go/claude-api.md | 3 + .../bundled/claude-api/java/claude-api.md | 3 + .../bundled/claude-api/php/claude-api.md | 3 + .../claude-api/python/agent-sdk/README.md | 3 + .../claude-api/python/agent-sdk/patterns.md | 3 + .../claude-api/python/claude-api/README.md | 3 + .../claude-api/python/claude-api/batches.md | 3 + .../claude-api/python/claude-api/files-api.md | 3 + .../claude-api/python/claude-api/streaming.md | 3 + .../claude-api/python/claude-api/tool-use.md | 3 + .../bundled/claude-api/ruby/claude-api.md | 3 + .../bundled/claude-api/shared/error-codes.md | 3 + .../bundled/claude-api/shared/live-sources.md | 3 + .../bundled/claude-api/shared/models.md | 3 + .../claude-api/shared/prompt-caching.md | 3 + .../claude-api/shared/tool-use-concepts.md | 3 + .../claude-api/typescript/agent-sdk/README.md | 3 + .../typescript/agent-sdk/patterns.md | 3 + .../typescript/claude-api/README.md | 3 + .../typescript/claude-api/batches.md | 3 + .../typescript/claude-api/files-api.md | 3 + .../typescript/claude-api/streaming.md | 3 + .../typescript/claude-api/tool-use.md | 3 + src/skills/bundled/dream.ts | 2 + src/skills/bundled/hunter.ts | 2 + src/skills/bundled/runSkillGenerator.ts | 2 + src/skills/bundled/verify/SKILL.md | 3 + src/skills/bundled/verify/examples/cli.md | 3 + src/skills/bundled/verify/examples/server.md | 3 + src/tools.ts | 22 ++-- src/tools/CtxInspectTool/CtxInspectTool.ts | 5 + src/tools/ListPeersTool/ListPeersTool.ts | 5 + .../PushNotificationTool.ts | 5 + src/tools/REPLTool/REPLTool.ts | 5 + .../SendUserFileTool/SendUserFileTool.ts | 5 + src/tools/SleepTool/SleepTool.ts | 5 + src/tools/SnipTool/SnipTool.ts | 5 + src/tools/SubscribePRTool/SubscribePRTool.ts | 5 + .../SuggestBackgroundPRTool.ts | 5 + .../TerminalCaptureTool.ts | 5 + .../VerifyPlanExecutionTool.ts | 5 + src/tools/WebBrowserTool/WebBrowserTool.ts | 5 + src/tools/WorkflowTool/bundled/index.ts | 2 + .../auto_mode_system_prompt.txt | 1 + .../permissions_anthropic.txt | 1 + .../permissions_external.txt | 1 + src/utils/sandbox/sandbox-adapter.ts | 74 +++++++++--- src/utils/ultraplan/prompt.txt | 1 + 70 files changed, 423 insertions(+), 40 deletions(-) create mode 100644 build.mjs create mode 100644 src/commands/agents-platform/index.ts create mode 100644 src/commands/assistant/index.ts create mode 100644 src/commands/force-snip.ts create mode 100644 src/commands/proactive.ts create mode 100644 src/commands/remoteControlServer/index.ts create mode 100644 src/commands/subscribe-pr.ts create mode 100644 src/commands/torch.ts create mode 100644 src/proactive/useProactive.ts create mode 100644 src/shims/globals.js create mode 100644 src/skills/bundled/claude-api/SKILL.md create mode 100644 src/skills/bundled/claude-api/csharp/claude-api.md create mode 100644 src/skills/bundled/claude-api/curl/examples.md create mode 100644 src/skills/bundled/claude-api/go/claude-api.md create mode 100644 src/skills/bundled/claude-api/java/claude-api.md create mode 100644 src/skills/bundled/claude-api/php/claude-api.md create mode 100644 src/skills/bundled/claude-api/python/agent-sdk/README.md create mode 100644 src/skills/bundled/claude-api/python/agent-sdk/patterns.md create mode 100644 src/skills/bundled/claude-api/python/claude-api/README.md create mode 100644 src/skills/bundled/claude-api/python/claude-api/batches.md create mode 100644 src/skills/bundled/claude-api/python/claude-api/files-api.md create mode 100644 src/skills/bundled/claude-api/python/claude-api/streaming.md create mode 100644 src/skills/bundled/claude-api/python/claude-api/tool-use.md create mode 100644 src/skills/bundled/claude-api/ruby/claude-api.md create mode 100644 src/skills/bundled/claude-api/shared/error-codes.md create mode 100644 src/skills/bundled/claude-api/shared/live-sources.md create mode 100644 src/skills/bundled/claude-api/shared/models.md create mode 100644 src/skills/bundled/claude-api/shared/prompt-caching.md create mode 100644 src/skills/bundled/claude-api/shared/tool-use-concepts.md create mode 100644 src/skills/bundled/claude-api/typescript/agent-sdk/README.md create mode 100644 src/skills/bundled/claude-api/typescript/agent-sdk/patterns.md create mode 100644 src/skills/bundled/claude-api/typescript/claude-api/README.md create mode 100644 src/skills/bundled/claude-api/typescript/claude-api/batches.md create mode 100644 src/skills/bundled/claude-api/typescript/claude-api/files-api.md create mode 100644 src/skills/bundled/claude-api/typescript/claude-api/streaming.md create mode 100644 src/skills/bundled/claude-api/typescript/claude-api/tool-use.md create mode 100644 src/skills/bundled/dream.ts create mode 100644 src/skills/bundled/hunter.ts create mode 100644 src/skills/bundled/runSkillGenerator.ts create mode 100644 src/skills/bundled/verify/SKILL.md create mode 100644 src/skills/bundled/verify/examples/cli.md create mode 100644 src/skills/bundled/verify/examples/server.md create mode 100644 src/tools/CtxInspectTool/CtxInspectTool.ts create mode 100644 src/tools/ListPeersTool/ListPeersTool.ts create mode 100644 src/tools/PushNotificationTool/PushNotificationTool.ts create mode 100644 src/tools/REPLTool/REPLTool.ts create mode 100644 src/tools/SendUserFileTool/SendUserFileTool.ts create mode 100644 src/tools/SleepTool/SleepTool.ts create mode 100644 src/tools/SnipTool/SnipTool.ts create mode 100644 src/tools/SubscribePRTool/SubscribePRTool.ts create mode 100644 src/tools/SuggestBackgroundPRTool/SuggestBackgroundPRTool.ts create mode 100644 src/tools/TerminalCaptureTool/TerminalCaptureTool.ts create mode 100644 src/tools/VerifyPlanExecutionTool/VerifyPlanExecutionTool.ts create mode 100644 src/tools/WebBrowserTool/WebBrowserTool.ts create mode 100644 src/tools/WorkflowTool/bundled/index.ts create mode 100644 src/utils/permissions/yolo-classifier-prompts/auto_mode_system_prompt.txt create mode 100644 src/utils/permissions/yolo-classifier-prompts/permissions_anthropic.txt create mode 100644 src/utils/permissions/yolo-classifier-prompts/permissions_external.txt create mode 100644 src/utils/ultraplan/prompt.txt diff --git a/.gitignore b/.gitignore index 90f1d0f..6bff373 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules/ # Build output dist/ +cli.mjs # Native vendor binaries (platform-specific, download at install) vendor/ diff --git a/build.mjs b/build.mjs new file mode 100644 index 0000000..949490b --- /dev/null +++ b/build.mjs @@ -0,0 +1,114 @@ +#!/usr/bin/env node +import * as esbuild from 'esbuild' + +// Plugin to stub out unavailable packages with empty modules +const stubPlugin = { + name: 'stub-unavailable', + setup(build) { + // Packages that are optional / internal / platform-specific + const stubPatterns = [ + // Anthropic internal + /^@ant\//, + /^@anthropic-ai\/sandbox-runtime/, + /^@anthropic-ai\/bedrock-sdk/, + /^@anthropic-ai\/foundry-sdk/, + /^@anthropic-ai\/vertex-sdk/, + /^@anthropic-ai\/mcpb/, + // Cloud SDKs + /^@aws-sdk\//, + /^@azure\//, + /^@smithy\//, + // OpenTelemetry exporters + /^@opentelemetry\/exporter-/, + /^@opentelemetry\/exporter-prometheus/, + // Native addons + /^color-diff-napi$/, + /^audio-capture-napi$/, + /^modifiers-napi$/, + // Optional packages + /^fflate$/, + /^qrcode$/, + /^turndown$/, + /^yaml$/, + ] + + build.onResolve({ filter: /.*/ }, (args) => { + for (const pattern of stubPatterns) { + if (pattern.test(args.path)) { + return { path: args.path, namespace: 'stub' } + } + } + return null + }) + + build.onLoad({ filter: /.*/, namespace: 'stub' }, (args) => { + return { + contents: ` + const noop = () => {}; + const noopClass = class {}; + const emptyArr = []; + // Functions + export const toString = noop; + export const buildComputerUseTools = noop; + export const createComputerUseMcpServer = noop; + export const createClaudeForChromeMcpServer = noop; + export const bindSessionContext = noop; + export const getSentinelCategory = noop; + export const targetImageSize = noop; + export const getSyntaxTheme = noop; + export const getMcpConfigForManifest = noop; + // Classes + export const SandboxManager = class { + static getSandboxUnavailableReason() { return undefined; } + static isSandboxRequired() { return false; } + static isSandboxingEnabled() { return false; } + static async initialize() {} + }; + export const ColorDiff = noopClass; + export const ColorFile = noopClass; + export const McpbManifestSchema = {}; + // Constants + export const BROWSER_TOOLS = []; + export const DEFAULT_GRANT_FLAGS = {}; + export const API_RESIZE_PARAMS = {}; + // Default + export default {}; + `, + loader: 'js', + } + }) + }, +} + +await esbuild.build({ + entryPoints: ['src/entrypoints/cli.tsx'], + bundle: true, + platform: 'node', + format: 'esm', + outfile: 'cli.mjs', + target: 'node18', + banner: { + js: [ + '#!/usr/bin/env node', + 'import { createRequire as __createRequire } from "module";', + 'const require = __createRequire(import.meta.url);', + ].join('\n'), + }, + loader: { + '.md': 'text', + '.txt': 'text', + }, + mainFields: ['module', 'main'], + inject: ['src/shims/globals.js'], + plugins: [stubPlugin], + external: [ + // True native addons that can't be bundled + 'fsevents', + 'cpu-features', + 'ssh2', + 'sharp', + ], + logLevel: 'warning', +}) + +console.log('✅ CLI bundled to cli.mjs') diff --git a/package-lock.json b/package-lock.json index 63395ea..d327f58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@shipany/open-agent-sdk", - "version": "0.1.2", + "version": "0.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@shipany/open-agent-sdk", - "version": "0.1.2", + "version": "0.1.4", "license": "MIT", "dependencies": { "@alcalzone/jsonl-db": "^4.0.2", @@ -81,6 +81,7 @@ "@types/semver": "^7.5.0", "@types/shell-quote": "^1.7.5", "@types/ws": "^8.5.0", + "esbuild": "^0.27.4", "typescript": "^5.7.0", "vitest": "^3.0.0" }, diff --git a/package.json b/package.json index 75652c9..fde231a 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "bugs": { "url": "https://github.com/shipany-ai/open-agent-sdk/issues" }, - "version": "0.1.3", + "version": "0.1.4", "description": "Open-source Agent SDK inspired by @anthropic-ai/claude-agent-sdk. Runs the agent loop in-process — no local CLI required. Deploy anywhere: cloud, serverless, Docker, CI/CD.", "type": "module", "main": "./dist/sdk.js", @@ -34,7 +34,8 @@ "scripts": { "build": "tsc", "build:cli": "node build.mjs", - "dev": "tsc --watch", + "dev": "bun run src/entrypoints/cli.tsx", + "dev:watch": "tsc --watch", "test": "node --experimental-vm-modules node_modules/.bin/vitest run", "lint": "tsc --noEmit", "prepublishOnly": "npm run build" diff --git a/src/bun-shim.ts b/src/bun-shim.ts index f4afc07..5bb1567 100644 --- a/src/bun-shim.ts +++ b/src/bun-shim.ts @@ -17,7 +17,7 @@ export function embed(_path: string): any { } export const MACRO: any = { - VERSION: '0.1.0', + VERSION: '2.1.88', VERSION_CHANGELOG: '', ISSUES_EXPLAINER: 'report the issue at https://github.com/shipany-ai/open-agent-sdk/issues', BUILD_TIME: new Date().toISOString(), diff --git a/src/cli/print.ts b/src/cli/print.ts index 302d453..bfc35a5 100644 --- a/src/cli/print.ts +++ b/src/cli/print.ts @@ -554,12 +554,17 @@ export async function runHeadless( // Start headless profiler for first turn headlessProfilerStartTurn() headlessProfilerCheckpoint('runHeadless_entry') + console.error('[DEBUG:print] runHeadless entered') // Check Grove requirements for non-interactive consumer subscribers + console.error('[DEBUG:print] before isQualifiedForGrove') if (await isQualifiedForGrove()) { + console.error('[DEBUG:print] grove qualified, checking...') await checkGroveForNonInteractive() } + console.error('[DEBUG:print] after grove check') headlessProfilerCheckpoint('after_grove_check') + console.error('[DEBUG:print] before structuredIO/sandbox'); // Initialize GrowthBook so feature flags take effect in headless mode. // Without this, the disk cache is empty and all flags fall back to defaults. @@ -679,6 +684,7 @@ export async function runHeadless( } headlessProfilerCheckpoint('before_loadInitialMessages') + console.error('[DEBUG:print] before loadInitialMessages') const appState = getAppState() const { messages: initialMessages, diff --git a/src/commands/agents-platform/index.ts b/src/commands/agents-platform/index.ts new file mode 100644 index 0000000..3707f61 --- /dev/null +++ b/src/commands/agents-platform/index.ts @@ -0,0 +1,3 @@ +// @ts-nocheck +export function register() {} +export default { register() {} } diff --git a/src/commands/assistant/index.ts b/src/commands/assistant/index.ts new file mode 100644 index 0000000..3707f61 --- /dev/null +++ b/src/commands/assistant/index.ts @@ -0,0 +1,3 @@ +// @ts-nocheck +export function register() {} +export default { register() {} } diff --git a/src/commands/force-snip.ts b/src/commands/force-snip.ts new file mode 100644 index 0000000..3707f61 --- /dev/null +++ b/src/commands/force-snip.ts @@ -0,0 +1,3 @@ +// @ts-nocheck +export function register() {} +export default { register() {} } diff --git a/src/commands/proactive.ts b/src/commands/proactive.ts new file mode 100644 index 0000000..3707f61 --- /dev/null +++ b/src/commands/proactive.ts @@ -0,0 +1,3 @@ +// @ts-nocheck +export function register() {} +export default { register() {} } diff --git a/src/commands/remoteControlServer/index.ts b/src/commands/remoteControlServer/index.ts new file mode 100644 index 0000000..3707f61 --- /dev/null +++ b/src/commands/remoteControlServer/index.ts @@ -0,0 +1,3 @@ +// @ts-nocheck +export function register() {} +export default { register() {} } diff --git a/src/commands/subscribe-pr.ts b/src/commands/subscribe-pr.ts new file mode 100644 index 0000000..3707f61 --- /dev/null +++ b/src/commands/subscribe-pr.ts @@ -0,0 +1,3 @@ +// @ts-nocheck +export function register() {} +export default { register() {} } diff --git a/src/commands/torch.ts b/src/commands/torch.ts new file mode 100644 index 0000000..3707f61 --- /dev/null +++ b/src/commands/torch.ts @@ -0,0 +1,3 @@ +// @ts-nocheck +export function register() {} +export default { register() {} } diff --git a/src/entrypoints/cli.tsx b/src/entrypoints/cli.tsx index 8ddaadc..b1473e9 100644 --- a/src/entrypoints/cli.tsx +++ b/src/entrypoints/cli.tsx @@ -1,5 +1,5 @@ // @ts-nocheck -import { feature } from '../bun-shim.js'; +import { feature, MACRO } from '../bun-shim.js'; // Bugfix for corepack auto-pinning, which adds yarnpkg to peoples' package.jsons // eslint-disable-next-line custom-rules/no-top-level-side-effects diff --git a/src/main.tsx b/src/main.tsx index d0d63d7..7db2067 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -19,7 +19,7 @@ import { ensureKeychainPrefetchCompleted, startKeychainPrefetch } from './utils/ // eslint-disable-next-line custom-rules/no-top-level-side-effects startKeychainPrefetch(); -import { feature } from './bun-shim.js'; +import { feature, MACRO } from './bun-shim.js'; import { Command as CommanderCommand, InvalidArgumentError, Option } from '@commander-js/extra-typings'; import chalk from 'chalk'; import { readFileSync } from 'fs'; @@ -907,15 +907,19 @@ async function run(): Promise { // not when displaying help. This avoids the need for env variable signaling. program.hook('preAction', async thisCommand => { profileCheckpoint('preAction_start'); + console.error('[DEBUG] preAction start'); // Await async subprocess loads started at module evaluation (lines 12-20). // Nearly free — subprocesses complete during the ~135ms of imports above. // Must resolve before init() which triggers the first settings read // (applySafeConfigEnvironmentVariables → getSettingsForSource('policySettings') // → isRemoteManagedSettingsEligible → sync keychain reads otherwise ~65ms). + console.error('[DEBUG] before MDM/keychain'); await Promise.all([ensureMdmSettingsLoaded(), ensureKeychainPrefetchCompleted()]); profileCheckpoint('preAction_after_mdm'); + console.error('[DEBUG] before init()'); await init(); profileCheckpoint('preAction_after_init'); + console.error('[DEBUG] after init()'); // process.title on Windows sets the console title directly; on POSIX, // terminal shell integration may mirror the process name to the tab. @@ -1006,6 +1010,7 @@ async function run(): Promise { // --plugin-dir takes exactly one arg; repeat the flag for multiple dirs. .option('--plugin-dir ', 'Load plugins from a directory for this session only (repeatable: --plugin-dir A --plugin-dir B)', (val: string, prev: string[]) => [...prev, val], [] as string[]).option('--disable-slash-commands', 'Disable all skills', () => true).option('--chrome', 'Enable Claude in Chrome integration').option('--no-chrome', 'Disable Claude in Chrome integration').option('--file ', 'File resources to download at startup. Format: file_id:relative_path (e.g., --file file_abc:doc.txt file_def:img.png)').action(async (prompt, options) => { profileCheckpoint('action_handler_start'); + console.error('[DEBUG] action_handler_start'); // --bare = one-switch minimal mode. Sets SIMPLE so all the existing // gates fire (CLAUDE.md, skills, hooks inside executeHooks, agent @@ -1742,6 +1747,7 @@ async function run(): Promise { } } + console.error('[DEBUG] before initializeToolPermissionContext'); // This await replaces blocking existsSync/statSync calls that were already in // the startup path. Wall-clock time is unchanged; we just yield to the event // loop during the fs I/O instead of blocking it. See #19661. @@ -1776,6 +1782,7 @@ async function run(): Promise { // biome-ignore lint/suspicious/noConsole:: intentional console output console.error(warning); }); + console.error('[DEBUG] after initializeToolPermissionContext'); void assertMinVersion(); // claude.ai config fetch: -p mode only (interactive uses useManageMCPConnections @@ -1859,14 +1866,24 @@ async function run(): Promise { process.exit(1); } const effectivePrompt = prompt || ''; + console.error('[DEBUG] before getInputPrompt, effectivePrompt=', JSON.stringify(effectivePrompt), 'isTTY=', process.stdin.isTTY); let inputPrompt = await getInputPrompt(effectivePrompt, (inputFormat ?? 'text') as 'text' | 'stream-json'); + console.error('[DEBUG] after getInputPrompt'); profileCheckpoint('action_after_input_prompt'); // Activate proactive mode BEFORE getTools() so SleepTool.isEnabled() // (which returns isProactiveActive()) passes and Sleep is included. // The later REPL-path maybeActivateProactive() calls are idempotent. + console.error('[DEBUG] before getTools'); maybeActivateProactive(options); - let tools = getTools(toolPermissionContext); + let tools: any; + try { + tools = getTools(toolPermissionContext); + console.error('[DEBUG] after getTools, count=', tools.length); + } catch (e: any) { + console.error('[DEBUG] getTools ERROR:', e.message, e.stack?.slice(0, 500)); + throw e; + } // Apply coordinator mode tool filtering for headless path // (mirrors useMergedTools.ts filtering for REPL/interactive path) @@ -1904,6 +1921,7 @@ async function run(): Promise { // IMPORTANT: setup() must be called before any other code that depends on the cwd or worktree setup profileCheckpoint('action_before_setup'); logForDebugging('[STARTUP] Running setup()...'); + console.error('[DEBUG] before setup()'); const setupStart = Date.now(); const { setup @@ -1933,6 +1951,7 @@ async function run(): Promise { commandsPromise?.catch(() => {}); agentDefsPromise?.catch(() => {}); await setupPromise; + console.error('[DEBUG] after setup()'); logForDebugging(`[STARTUP] setup() completed in ${Date.now() - setupStart}ms`); profileCheckpoint('action_after_setup'); @@ -2028,6 +2047,7 @@ async function run(): Promise { // Join the promises kicked before setup() (or start fresh if // worktreeEnabled gated the early kick). Both memoized by cwd. const [commands, agentDefinitionsResult] = await Promise.all([commandsPromise ?? getCommands(currentCwd), agentDefsPromise ?? getAgentDefinitionsWithOverrides(currentCwd)]); + console.error('[DEBUG] commands and agents loaded'); logForDebugging(`[STARTUP] Commands and agents loaded in ${Date.now() - commandsStart}ms`); profileCheckpoint('action_commands_loaded'); @@ -2238,8 +2258,10 @@ async function run(): Promise { durationMs: Math.round(process.uptime() * 1000) }); logForDebugging('[STARTUP] Running showSetupScreens()...'); + console.error('[DEBUG] before showSetupScreens() - isNonInteractive:', getIsNonInteractiveSession()); const setupScreensStart = Date.now(); const onboardingShown = await showSetupScreens(root, permissionMode, allowDangerouslySkipPermissions, commands, enableClaudeInChrome, devChannels); + console.error('[DEBUG] after showSetupScreens()'); logForDebugging(`[STARTUP] showSetupScreens() completed in ${Date.now() - setupScreensStart}ms`); // Now that trust is established and GrowthBook has auth headers, @@ -2557,7 +2579,9 @@ async function run(): Promise { // skip — no-op } else if (isNonInteractiveSession) { // In headless mode, await to ensure plugin sync completes before CLI exits + console.error('[DEBUG] before initializeVersionedPlugins'); await initializeVersionedPlugins(); + console.error('[DEBUG] after initializeVersionedPlugins'); profileCheckpoint('action_after_plugins_init'); void cleanupOrphanedPluginVersionsInBackground().then(() => getGlobExclusionsForPluginCache()); } else { @@ -2611,8 +2635,10 @@ async function run(): Promise { // rejection — this just prevents the spurious global handler fire. sessionStartHooksPromise?.catch(() => {}); profileCheckpoint('before_validateForceLoginOrg'); + console.error('[DEBUG] before validateForceLoginOrg'); // Validate org restriction for non-interactive sessions const orgValidation = await validateForceLoginOrg(); + console.error('[DEBUG] after validateForceLoginOrg'); if (!orgValidation.valid) { process.stderr.write(orgValidation.message + '\n'); process.exit(1); @@ -2727,7 +2753,9 @@ async function run(): Promise { // fetch was kicked off early (line ~2558) so only residual time blocks // here. --bare skips claude.ai entirely for perf-sensitive scripts. profileCheckpoint('before_connectMcp'); + console.error('[DEBUG] before connectMcpBatch regular, count:', Object.keys(regularMcpConfigs).length); await connectMcpBatch(regularMcpConfigs, 'regular'); + console.error('[DEBUG] after connectMcpBatch regular'); profileCheckpoint('after_connectMcp'); // Dedup: suppress plugin MCP servers that duplicate a claude.ai // connector (connector wins), then connect claude.ai servers. @@ -2822,10 +2850,12 @@ async function run(): Promise { } } logSessionTelemetry(); + console.error('[DEBUG] before print import'); profileCheckpoint('before_print_import'); const { runHeadless } = await import('./cli/print.js'); + console.error('[DEBUG] after print import, calling runHeadless'); profileCheckpoint('after_print_import'); void runHeadless(inputPrompt, () => headlessStore.getState(), headlessStore.setState, commandsHeadless, tools, sdkMcpConfigs, agentDefinitions.activeAgents, { continue: options.continue, diff --git a/src/proactive/useProactive.ts b/src/proactive/useProactive.ts new file mode 100644 index 0000000..411cf97 --- /dev/null +++ b/src/proactive/useProactive.ts @@ -0,0 +1,2 @@ +// @ts-nocheck +export function useProactive() { return {} } diff --git a/src/services/remoteManagedSettings/index.ts b/src/services/remoteManagedSettings/index.ts index 228f2ed..261ccc6 100644 --- a/src/services/remoteManagedSettings/index.ts +++ b/src/services/remoteManagedSettings/index.ts @@ -36,7 +36,7 @@ import { getRetryDelay } from '../api/withRetry.js' import { checkManagedSettingsSecurity, handleSecurityCheckResult, -} from './securityCheck.jsx' +} from './securityCheck.js' import { isRemoteManagedSettingsEligible, resetSyncCache } from './syncCache.js' import { getRemoteManagedSettingsSyncFromCache, diff --git a/src/setup.ts b/src/setup.ts index 4e29d86..59351ab 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -66,6 +66,7 @@ export async function setup( messagingSocketPath?: string, ): Promise { logForDiagnosticsNoPII('info', 'setup_started') + console.error('[DEBUG:setup] entered') // Check for Node.js version < 18 const nodeVersion = process.version.match(/^v(\d+)\./)?.[1] @@ -110,13 +111,17 @@ export async function setup( captureTeammateModeSnapshot() } + console.error('[DEBUG:setup] before terminal backup checks, isNonInteractive:', getIsNonInteractiveSession()) // Terminal backup restoration — interactive only. Print mode doesn't // interact with terminal settings; the next interactive session will // detect and restore any interrupted setup. if (!getIsNonInteractiveSession()) { + console.error('[DEBUG:setup] interactive mode - checking backups, swarmsEnabled:', isAgentSwarmsEnabled()) // iTerm2 backup check only when swarms enabled if (isAgentSwarmsEnabled()) { + console.error('[DEBUG:setup] before iTerm2 backup check') const restoredIterm2Backup = await checkAndRestoreITerm2Backup() + console.error('[DEBUG:setup] after iTerm2 backup check') if (restoredIterm2Backup.status === 'restored') { // biome-ignore lint/suspicious/noConsole:: intentional console output console.log( @@ -135,8 +140,10 @@ export async function setup( } // Check and restore Terminal.app backup if setup was interrupted + console.error('[DEBUG:setup] before Terminal.app backup check') try { const restoredTerminalBackup = await checkAndRestoreTerminalBackup() + console.error('[DEBUG:setup] after Terminal.app backup check') if (restoredTerminalBackup.status === 'restored') { // biome-ignore lint/suspicious/noConsole:: intentional console output console.log( @@ -158,13 +165,17 @@ export async function setup( } } + console.error('[DEBUG:setup] before setCwd') // IMPORTANT: setCwd() must be called before any other code that depends on the cwd setCwd(cwd) + console.error('[DEBUG:setup] after setCwd') + console.error('[DEBUG:setup] before captureHooksConfigSnapshot') // Capture hooks configuration snapshot to avoid hidden hook modifications. // IMPORTANT: Must be called AFTER setCwd() so hooks are loaded from the correct directory const hooksStart = Date.now() captureHooksConfigSnapshot() + console.error('[DEBUG:setup] after captureHooksConfigSnapshot') logForDiagnosticsNoPII('info', 'setup_hooks_captured', { duration_ms: Date.now() - hooksStart, }) diff --git a/src/shims/globals.js b/src/shims/globals.js new file mode 100644 index 0000000..fd6faac --- /dev/null +++ b/src/shims/globals.js @@ -0,0 +1,3 @@ +// Global shims injected by esbuild +// Makes MACRO available in all modules without explicit import +export { MACRO } from '../bun-shim.js' diff --git a/src/skills/bundled/claude-api/SKILL.md b/src/skills/bundled/claude-api/SKILL.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/SKILL.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/csharp/claude-api.md b/src/skills/bundled/claude-api/csharp/claude-api.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/csharp/claude-api.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/curl/examples.md b/src/skills/bundled/claude-api/curl/examples.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/curl/examples.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/go/claude-api.md b/src/skills/bundled/claude-api/go/claude-api.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/go/claude-api.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/java/claude-api.md b/src/skills/bundled/claude-api/java/claude-api.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/java/claude-api.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/php/claude-api.md b/src/skills/bundled/claude-api/php/claude-api.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/php/claude-api.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/python/agent-sdk/README.md b/src/skills/bundled/claude-api/python/agent-sdk/README.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/python/agent-sdk/README.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/python/agent-sdk/patterns.md b/src/skills/bundled/claude-api/python/agent-sdk/patterns.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/python/agent-sdk/patterns.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/python/claude-api/README.md b/src/skills/bundled/claude-api/python/claude-api/README.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/python/claude-api/README.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/python/claude-api/batches.md b/src/skills/bundled/claude-api/python/claude-api/batches.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/python/claude-api/batches.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/python/claude-api/files-api.md b/src/skills/bundled/claude-api/python/claude-api/files-api.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/python/claude-api/files-api.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/python/claude-api/streaming.md b/src/skills/bundled/claude-api/python/claude-api/streaming.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/python/claude-api/streaming.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/python/claude-api/tool-use.md b/src/skills/bundled/claude-api/python/claude-api/tool-use.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/python/claude-api/tool-use.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/ruby/claude-api.md b/src/skills/bundled/claude-api/ruby/claude-api.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/ruby/claude-api.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/shared/error-codes.md b/src/skills/bundled/claude-api/shared/error-codes.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/shared/error-codes.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/shared/live-sources.md b/src/skills/bundled/claude-api/shared/live-sources.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/shared/live-sources.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/shared/models.md b/src/skills/bundled/claude-api/shared/models.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/shared/models.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/shared/prompt-caching.md b/src/skills/bundled/claude-api/shared/prompt-caching.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/shared/prompt-caching.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/shared/tool-use-concepts.md b/src/skills/bundled/claude-api/shared/tool-use-concepts.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/shared/tool-use-concepts.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/typescript/agent-sdk/README.md b/src/skills/bundled/claude-api/typescript/agent-sdk/README.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/typescript/agent-sdk/README.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/typescript/agent-sdk/patterns.md b/src/skills/bundled/claude-api/typescript/agent-sdk/patterns.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/typescript/agent-sdk/patterns.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/typescript/claude-api/README.md b/src/skills/bundled/claude-api/typescript/claude-api/README.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/typescript/claude-api/README.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/typescript/claude-api/batches.md b/src/skills/bundled/claude-api/typescript/claude-api/batches.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/typescript/claude-api/batches.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/typescript/claude-api/files-api.md b/src/skills/bundled/claude-api/typescript/claude-api/files-api.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/typescript/claude-api/files-api.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/typescript/claude-api/streaming.md b/src/skills/bundled/claude-api/typescript/claude-api/streaming.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/typescript/claude-api/streaming.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/claude-api/typescript/claude-api/tool-use.md b/src/skills/bundled/claude-api/typescript/claude-api/tool-use.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/claude-api/typescript/claude-api/tool-use.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/dream.ts b/src/skills/bundled/dream.ts new file mode 100644 index 0000000..7440bb9 --- /dev/null +++ b/src/skills/bundled/dream.ts @@ -0,0 +1,2 @@ +// @ts-nocheck +export function registerDreamSkill() {} diff --git a/src/skills/bundled/hunter.ts b/src/skills/bundled/hunter.ts new file mode 100644 index 0000000..4f6b8c1 --- /dev/null +++ b/src/skills/bundled/hunter.ts @@ -0,0 +1,2 @@ +// @ts-nocheck +export function registerHunterSkill() {} diff --git a/src/skills/bundled/runSkillGenerator.ts b/src/skills/bundled/runSkillGenerator.ts new file mode 100644 index 0000000..e8c3628 --- /dev/null +++ b/src/skills/bundled/runSkillGenerator.ts @@ -0,0 +1,2 @@ +// @ts-nocheck +export function registerRunSkillGeneratorSkill() {} diff --git a/src/skills/bundled/verify/SKILL.md b/src/skills/bundled/verify/SKILL.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/verify/SKILL.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/verify/examples/cli.md b/src/skills/bundled/verify/examples/cli.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/verify/examples/cli.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/skills/bundled/verify/examples/server.md b/src/skills/bundled/verify/examples/server.md new file mode 100644 index 0000000..3d690d6 --- /dev/null +++ b/src/skills/bundled/verify/examples/server.md @@ -0,0 +1,3 @@ +# Placeholder + +Content not available. diff --git a/src/tools.ts b/src/tools.ts index 908b79d..aec9eb3 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -58,20 +58,14 @@ import { ExitPlanModeV2Tool } from './tools/ExitPlanModeTool/ExitPlanModeV2Tool. import { TestingPermissionTool } from './tools/testing/TestingPermissionTool.js' import { GrepTool } from './tools/GrepTool/GrepTool.js' import { TungstenTool } from './tools/TungstenTool/TungstenTool.js' -// Lazy require to break circular dependency: tools.ts -> TeamCreateTool/TeamDeleteTool -> ... -> tools.ts -import { createRequire } from 'module' -const _require = createRequire(import.meta.url) -/* eslint-disable @typescript-eslint/no-require-imports */ -const getTeamCreateTool = () => - _require('./tools/TeamCreateTool/TeamCreateTool.js') - .TeamCreateTool as typeof import('./tools/TeamCreateTool/TeamCreateTool.js').TeamCreateTool -const getTeamDeleteTool = () => - _require('./tools/TeamDeleteTool/TeamDeleteTool.js') - .TeamDeleteTool as typeof import('./tools/TeamDeleteTool/TeamDeleteTool.js').TeamDeleteTool -const getSendMessageTool = () => - _require('./tools/SendMessageTool/SendMessageTool.js') - .SendMessageTool as typeof import('./tools/SendMessageTool/SendMessageTool.js').SendMessageTool -/* eslint-enable @typescript-eslint/no-require-imports */ +// Direct imports instead of lazy require (esbuild bundles everything into one file, +// so createRequire-based relative paths don't resolve at runtime) +import { TeamCreateTool as _TeamCreateTool } from './tools/TeamCreateTool/TeamCreateTool.js' +import { TeamDeleteTool as _TeamDeleteTool } from './tools/TeamDeleteTool/TeamDeleteTool.js' +import { SendMessageTool as _SendMessageTool } from './tools/SendMessageTool/SendMessageTool.js' +const getTeamCreateTool = () => _TeamCreateTool +const getTeamDeleteTool = () => _TeamDeleteTool +const getSendMessageTool = () => _SendMessageTool import { AskUserQuestionTool } from './tools/AskUserQuestionTool/AskUserQuestionTool.js' import { LSPTool } from './tools/LSPTool/LSPTool.js' import { ListMcpResourcesTool } from './tools/ListMcpResourcesTool/ListMcpResourcesTool.js' diff --git a/src/tools/CtxInspectTool/CtxInspectTool.ts b/src/tools/CtxInspectTool/CtxInspectTool.ts new file mode 100644 index 0000000..67f8a3c --- /dev/null +++ b/src/tools/CtxInspectTool/CtxInspectTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class CtxInspectTool { + name = 'ctx-inspect-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/ListPeersTool/ListPeersTool.ts b/src/tools/ListPeersTool/ListPeersTool.ts new file mode 100644 index 0000000..622888f --- /dev/null +++ b/src/tools/ListPeersTool/ListPeersTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class ListPeersTool { + name = 'list-peers-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/PushNotificationTool/PushNotificationTool.ts b/src/tools/PushNotificationTool/PushNotificationTool.ts new file mode 100644 index 0000000..c90df91 --- /dev/null +++ b/src/tools/PushNotificationTool/PushNotificationTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class PushNotificationTool { + name = 'push-notification-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/REPLTool/REPLTool.ts b/src/tools/REPLTool/REPLTool.ts new file mode 100644 index 0000000..f53f7a2 --- /dev/null +++ b/src/tools/REPLTool/REPLTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class REPLTool { + name = 'repl-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/SendUserFileTool/SendUserFileTool.ts b/src/tools/SendUserFileTool/SendUserFileTool.ts new file mode 100644 index 0000000..05104f0 --- /dev/null +++ b/src/tools/SendUserFileTool/SendUserFileTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class SendUserFileTool { + name = 'send-user-file-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/SleepTool/SleepTool.ts b/src/tools/SleepTool/SleepTool.ts new file mode 100644 index 0000000..ee4ce5f --- /dev/null +++ b/src/tools/SleepTool/SleepTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class SleepTool { + name = 'sleep-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/SnipTool/SnipTool.ts b/src/tools/SnipTool/SnipTool.ts new file mode 100644 index 0000000..0e4d843 --- /dev/null +++ b/src/tools/SnipTool/SnipTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class SnipTool { + name = 'snip-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/SubscribePRTool/SubscribePRTool.ts b/src/tools/SubscribePRTool/SubscribePRTool.ts new file mode 100644 index 0000000..e68e96b --- /dev/null +++ b/src/tools/SubscribePRTool/SubscribePRTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class SubscribePRTool { + name = 'subscribe-pr-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/SuggestBackgroundPRTool/SuggestBackgroundPRTool.ts b/src/tools/SuggestBackgroundPRTool/SuggestBackgroundPRTool.ts new file mode 100644 index 0000000..14efaed --- /dev/null +++ b/src/tools/SuggestBackgroundPRTool/SuggestBackgroundPRTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class SuggestBackgroundPRTool { + name = 'suggest-background-pr-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/TerminalCaptureTool/TerminalCaptureTool.ts b/src/tools/TerminalCaptureTool/TerminalCaptureTool.ts new file mode 100644 index 0000000..bb9ca24 --- /dev/null +++ b/src/tools/TerminalCaptureTool/TerminalCaptureTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class TerminalCaptureTool { + name = 'terminal-capture-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/VerifyPlanExecutionTool/VerifyPlanExecutionTool.ts b/src/tools/VerifyPlanExecutionTool/VerifyPlanExecutionTool.ts new file mode 100644 index 0000000..be531c8 --- /dev/null +++ b/src/tools/VerifyPlanExecutionTool/VerifyPlanExecutionTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class VerifyPlanExecutionTool { + name = 'verify-plan-execution-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/WebBrowserTool/WebBrowserTool.ts b/src/tools/WebBrowserTool/WebBrowserTool.ts new file mode 100644 index 0000000..1a1e3f1 --- /dev/null +++ b/src/tools/WebBrowserTool/WebBrowserTool.ts @@ -0,0 +1,5 @@ +// @ts-nocheck +export class WebBrowserTool { + name = 'web-browser-tool' + async call() { return { type: 'result', resultForAssistant: 'Tool not available' } } +} diff --git a/src/tools/WorkflowTool/bundled/index.ts b/src/tools/WorkflowTool/bundled/index.ts new file mode 100644 index 0000000..be7387e --- /dev/null +++ b/src/tools/WorkflowTool/bundled/index.ts @@ -0,0 +1,2 @@ +// @ts-nocheck +export default {} diff --git a/src/utils/permissions/yolo-classifier-prompts/auto_mode_system_prompt.txt b/src/utils/permissions/yolo-classifier-prompts/auto_mode_system_prompt.txt new file mode 100644 index 0000000..d1bb3a7 --- /dev/null +++ b/src/utils/permissions/yolo-classifier-prompts/auto_mode_system_prompt.txt @@ -0,0 +1 @@ +Auto mode system prompt placeholder. diff --git a/src/utils/permissions/yolo-classifier-prompts/permissions_anthropic.txt b/src/utils/permissions/yolo-classifier-prompts/permissions_anthropic.txt new file mode 100644 index 0000000..81bcf8e --- /dev/null +++ b/src/utils/permissions/yolo-classifier-prompts/permissions_anthropic.txt @@ -0,0 +1 @@ +Anthropic permissions placeholder. diff --git a/src/utils/permissions/yolo-classifier-prompts/permissions_external.txt b/src/utils/permissions/yolo-classifier-prompts/permissions_external.txt new file mode 100644 index 0000000..b27b5f0 --- /dev/null +++ b/src/utils/permissions/yolo-classifier-prompts/permissions_external.txt @@ -0,0 +1 @@ +External permissions placeholder. diff --git a/src/utils/sandbox/sandbox-adapter.ts b/src/utils/sandbox/sandbox-adapter.ts index ac3b851..e8f9299 100644 --- a/src/utils/sandbox/sandbox-adapter.ts +++ b/src/utils/sandbox/sandbox-adapter.ts @@ -5,22 +5,62 @@ * settings system, tool integration, and additional features. */ -import type { - FsReadRestrictionConfig, - FsWriteRestrictionConfig, - IgnoreViolationsConfig, - NetworkHostPattern, - NetworkRestrictionConfig, - SandboxAskCallback, - SandboxDependencyCheck, - SandboxRuntimeConfig, - SandboxViolationEvent, -} from '@anthropic-ai/sandbox-runtime' -import { - SandboxManager as BaseSandboxManager, - SandboxRuntimeConfigSchema, - SandboxViolationStore, -} from '@anthropic-ai/sandbox-runtime' +// Types – declared locally so the file compiles even when the optional +// @anthropic-ai/sandbox-runtime package is not installed. +type FsReadRestrictionConfig = any +type FsWriteRestrictionConfig = any +type IgnoreViolationsConfig = any +type NetworkHostPattern = any +type NetworkRestrictionConfig = any +type SandboxAskCallback = any +type SandboxDependencyCheck = any +type SandboxRuntimeConfig = any +type SandboxViolationEvent = any + +// --------------------------------------------------------------------------- +// Lazy-load @anthropic-ai/sandbox-runtime (optional dependency) +// --------------------------------------------------------------------------- +let _sandboxModule: any = null +let _sandboxLoadAttempted = false + +function getSandboxModule(): any { + if (!_sandboxLoadAttempted) { + _sandboxLoadAttempted = true + try { + // Use require so the module is resolved at call-time, not import-time. + // This keeps the SDK functional when the package is absent. + _sandboxModule = require('@anthropic-ai/sandbox-runtime') + } catch { + _sandboxModule = null + } + } + return _sandboxModule +} + +// Proxy that forwards every property access to the real BaseSandboxManager if +// available, or returns a no-op / safe default when the package is missing. +const BaseSandboxManager: any = new Proxy({}, { + get(_target, prop) { + const mod = getSandboxModule() + if (mod?.SandboxManager) { + return mod.SandboxManager[prop] + } + // Fallback: return a no-op function for any method access + return (..._args: any[]) => undefined + }, +}) + +const SandboxRuntimeConfigSchema: any = new Proxy({}, { + get(_target, prop) { + const mod = getSandboxModule() + return mod?.SandboxRuntimeConfigSchema?.[prop] + }, +}) + +const SandboxViolationStore: any = (() => { + const mod = getSandboxModule() + return mod?.SandboxViolationStore ?? class SandboxViolationStoreStub {} +})() import { rmSync, statSync } from 'fs' import { readFile } from 'fs/promises' import { memoize } from 'lodash-es' @@ -983,4 +1023,4 @@ export type { IgnoreViolationsConfig, } -export { SandboxViolationStore, SandboxRuntimeConfigSchema } +export { SandboxViolationStore, SandboxRuntimeConfigSchema, getSandboxModule } diff --git a/src/utils/ultraplan/prompt.txt b/src/utils/ultraplan/prompt.txt new file mode 100644 index 0000000..da88957 --- /dev/null +++ b/src/utils/ultraplan/prompt.txt @@ -0,0 +1 @@ +You are an AI planning assistant.