|
| 1 | +#!/bin/bash |
| 2 | +# postinstall.sh — Create stubs for Anthropic internal packages |
| 3 | +# Run automatically after `bun install` via package.json scripts |
| 4 | + |
| 5 | +set -e |
| 6 | + |
| 7 | +STUBS_DIR="node_modules/@ant" |
| 8 | +SANDBOX_DIR="node_modules/@anthropic-ai/sandbox-runtime" |
| 9 | + |
| 10 | +echo "[postinstall] Creating stub packages..." |
| 11 | + |
| 12 | +# ── @ant/claude-for-chrome-mcp ────────────────────────────────────────────── |
| 13 | +mkdir -p "$STUBS_DIR/claude-for-chrome-mcp" |
| 14 | +cat > "$STUBS_DIR/claude-for-chrome-mcp/package.json" << 'EOF' |
| 15 | +{ "name": "@ant/claude-for-chrome-mcp", "version": "0.0.0", "main": "index.js" } |
| 16 | +EOF |
| 17 | +cat > "$STUBS_DIR/claude-for-chrome-mcp/index.js" << 'EOF' |
| 18 | +module.exports = { BROWSER_TOOLS: [], setupClaudeInChrome: () => ({}) }; |
| 19 | +EOF |
| 20 | + |
| 21 | +# ── @ant/computer-use-input ───────────────────────────────────────────────── |
| 22 | +mkdir -p "$STUBS_DIR/computer-use-input" |
| 23 | +cat > "$STUBS_DIR/computer-use-input/package.json" << 'EOF' |
| 24 | +{ "name": "@ant/computer-use-input", "version": "0.0.0", "main": "index.js" } |
| 25 | +EOF |
| 26 | +cat > "$STUBS_DIR/computer-use-input/index.js" << 'EOF' |
| 27 | +module.exports = {}; |
| 28 | +EOF |
| 29 | + |
| 30 | +# ── @ant/computer-use-mcp ────────────────────────────────────────────────── |
| 31 | +mkdir -p "$STUBS_DIR/computer-use-mcp" |
| 32 | +cat > "$STUBS_DIR/computer-use-mcp/package.json" << 'EOF' |
| 33 | +{ "name": "@ant/computer-use-mcp", "version": "0.0.0", "main": "index.js" } |
| 34 | +EOF |
| 35 | +cat > "$STUBS_DIR/computer-use-mcp/index.js" << 'EOF' |
| 36 | +module.exports = { |
| 37 | + buildComputerUseTools: () => ({}), |
| 38 | + bindSessionContext: () => ({}), |
| 39 | + DEFAULT_GRANT_FLAGS: {}, |
| 40 | + API_RESIZE_PARAMS: {}, |
| 41 | + targetImageSize: () => ({ width: 0, height: 0 }), |
| 42 | +}; |
| 43 | +EOF |
| 44 | +mkdir -p "$STUBS_DIR/computer-use-mcp/sentinelApps" |
| 45 | +cat > "$STUBS_DIR/computer-use-mcp/sentinelApps/index.js" << 'EOF' |
| 46 | +module.exports = { getSentinelCategory: () => '' }; |
| 47 | +EOF |
| 48 | +mkdir -p "$STUBS_DIR/computer-use-mcp/types" |
| 49 | +cat > "$STUBS_DIR/computer-use-mcp/types/index.js" << 'EOF' |
| 50 | +module.exports = { DEFAULT_GRANT_FLAGS: {} }; |
| 51 | +EOF |
| 52 | + |
| 53 | +# ── @ant/computer-use-swift ───────────────────────────────────────────────── |
| 54 | +mkdir -p "$STUBS_DIR/computer-use-swift" |
| 55 | +cat > "$STUBS_DIR/computer-use-swift/package.json" << 'EOF' |
| 56 | +{ "name": "@ant/computer-use-swift", "version": "0.0.0", "main": "index.js" } |
| 57 | +EOF |
| 58 | +cat > "$STUBS_DIR/computer-use-swift/index.js" << 'EOF' |
| 59 | +module.exports = {}; |
| 60 | +EOF |
| 61 | + |
| 62 | +# ── @anthropic-ai/sandbox-runtime ─────────────────────────────────────────── |
| 63 | +# Only create stub if not already installed (e.g. from npm) |
| 64 | +if [ ! -f "$SANDBOX_DIR/dist/index.js" ]; then |
| 65 | + echo "[postinstall] Creating sandbox-runtime stub (install @anthropic-ai/sandbox-runtime for real sandboxing)..." |
| 66 | + mkdir -p "$SANDBOX_DIR" |
| 67 | + cat > "$SANDBOX_DIR/package.json" << 'EOF' |
| 68 | +{ "name": "@anthropic-ai/sandbox-runtime", "version": "0.0.0-stub", "main": "index.js" } |
| 69 | +EOF |
| 70 | + cat > "$SANDBOX_DIR/index.js" << 'STUBEOF' |
| 71 | +class SandboxManager { |
| 72 | + static getFsReadConfig() { return null; } |
| 73 | + static getFsWriteConfig() { return null; } |
| 74 | + static getNetworkConfig() { return null; } |
| 75 | + static getNetworkRestrictionConfig() { return null; } |
| 76 | + static isSandboxingEnabled() { return false; } |
| 77 | + static isSupportedPlatform() { return false; } |
| 78 | + static areUnsandboxedCommandsAllowed() { return true; } |
| 79 | + static isAutoAllowBashIfSandboxedEnabled() { return false; } |
| 80 | + static getSandboxConfig() { return null; } |
| 81 | + static refreshConfig() {} |
| 82 | + static reset() { return Promise.resolve(); } |
| 83 | + static wrapWithSandbox(cmd) { return Promise.resolve(cmd); } |
| 84 | + static getExcludedCommands() { return []; } |
| 85 | + static getSandboxSettings() { return null; } |
| 86 | + static setSandboxSettings() {} |
| 87 | + static getIgnoreViolations() { return null; } |
| 88 | + static getIgnoreViolationsConfig() { return null; } |
| 89 | + static checkDependencies() { return { errors: [], warnings: [] }; } |
| 90 | + static initialize() { return Promise.resolve(); } |
| 91 | + static updateConfig() {} |
| 92 | + static getAllowUnixSockets() { return undefined; } |
| 93 | + static getAllowLocalBinding() { return undefined; } |
| 94 | + static getEnableWeakerNestedSandbox() { return undefined; } |
| 95 | + static getProxyPort() { return undefined; } |
| 96 | + static getSocksProxyPort() { return undefined; } |
| 97 | + static getLinuxHttpSocketPath() { return undefined; } |
| 98 | + static getLinuxSocksSocketPath() { return undefined; } |
| 99 | + static waitForNetworkInitialization() { return Promise.resolve(true); } |
| 100 | + static cleanupAfterCommand() {} |
| 101 | + static getSandboxViolationStore() { return new SandboxViolationStore(); } |
| 102 | + static annotateStderrWithSandboxFailures(_cmd, stderr) { return stderr; } |
| 103 | + static getLinuxGlobPatternWarnings() { return []; } |
| 104 | +} |
| 105 | +class SandboxViolationStore { |
| 106 | + constructor() {} |
| 107 | + addViolation() {} |
| 108 | + getViolations() { return []; } |
| 109 | + clear() {} |
| 110 | +} |
| 111 | +const SandboxRuntimeConfigSchema = { |
| 112 | + parse: (x) => x, |
| 113 | + safeParse: (x) => ({ success: true, data: x }), |
| 114 | +}; |
| 115 | +module.exports = { SandboxManager, SandboxViolationStore, SandboxRuntimeConfigSchema }; |
| 116 | +STUBEOF |
| 117 | +fi |
| 118 | + |
| 119 | +echo "[postinstall] Stubs created." |
0 commit comments