Download src/utils/execution-environment.js from VanyaJ/bada-terminal: direct link, hf CLI and curl.
- Browser
- Download file 3.2 kB
-
https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/utils/execution-environment.js
- Command line
-
hf download hf://VanyaJ/bada-terminal/src/utils/execution-environment.js
-
curl -L -o execution-environment.js https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/utils/execution-environment.js
3.2 kB
| /** ๋ชจ๋ ํธ์คํธ ์คํ ๊ฒฝ๋ก์ ๋์ผํ Headroom ์ ์ฑ ํ๊ฒฝ์ ์ ์ฉํ๋ค. */ | |
| const headroom = require('./headroom-manager'); | |
| function getExecutionEnvironment(baseEnv, options = {}) { | |
| require('../config/profile-application').assertReady(); | |
| const ctx = require('../context'); | |
| const command = options.cliCommand || ctx.getActiveCli(); | |
| options = { ...options, cliCommand: command }; | |
| baseEnv = require('../config/profile-execution-config').applyProfileEnvironment(baseEnv, { ...options, cliCommand: command }); | |
| // ์๋ชป๋ ์ค์ /๋ชฉ์ ์ง๋ ํธ์ถ์์๊ฒ ์ ํํ๋ค. ์ ์ฑ ์ ์ฉ ์คํจ ํ ์ง์ ์คํํ์ง ์๋๋ค. | |
| // ๋ช ์ ์์ ์์ฐ์ ๋ฌธ๋งฅ ๋ฏธ์ ํ/์ ์ญ ํ๋ก์ off์์๋ ์ง์ provider๋ก ์ฐํํ์ง ์๋๋ค. | |
| // docs/specs/terminal-session-budget.md v1.0.0 | |
| if (!options.profileContextId && !headroom.shouldUseProxy()) { | |
| const terminalOwner = options.headroomOwnerToken && require('../services/terminal-headroom-usage-scope').has(options.headroomOwnerToken); | |
| if (!terminalOwner) return require('../config/runtime-policy-config').applyRuntimePolicy(baseEnv, options); | |
| } | |
| // listen์ ๋จผ์ ์์ํ๋ค. ํฌํธ ๋ฐ์ธ๋ฉ ์คํจ ์์๋ endpoint๋ฅผ ์๋ณธ์ผ๋ก ๋๋๋ฆฌ์ง ์๋๋ค. | |
| headroom.startProxy({ write() {} }).then(result => { | |
| if (!result.success) console.error('[Headroom] Proxy unavailable; governed requests will fail'); | |
| }); | |
| const name = require('../config/cli-paths').normalizeCliName(command); | |
| let result = { ...baseEnv }; | |
| delete result.BADA_CLAUDE_SETTINGS; | |
| if (['claude', 'mimo', 'mimocode'].includes(name)) { | |
| if (!options.shellArgs && !options.directArgs && !options.cliArguments) throw new Error('Governed Claude execution requires CLI arguments, not environment injection alone'); | |
| const adapter = require('../config/claude-execution-config'); | |
| // ํ๋ค์ค์ ์ ธ ์คํ๋ ๋ช ์ ์ค์ ์ ๋จผ์ ์ฝ๊ณ ์ฌ์ฉ์ ํ ๊ณผ ๋ผ์ฐํ ์ค์ ์ ํจ๊ป ๋ณด์กดํ๋ค. | |
| const cliArguments = options.cliArguments || options.directArgs || (options.shellArgs | |
| ? adapter.shellTokens(options.shellArgs.at(-1)).map(token => token.value) : []); | |
| result = adapter.prepareClaudeEnvironment(result, { | |
| cli: name, cwd: options.cwd || ctx.currentCwd || process.cwd(), cliArguments, | |
| routeEnvironment: env => headroom.getHeadroomEnv(env, true, options.profileContextId, options.headroomOwnerToken) | |
| }); | |
| if (options.directArgs) adapter.applyCliArguments(options.directArgs, result); | |
| if (options.shellArgs) adapter.applyShellArguments(options.shellArgs, result); | |
| } | |
| if (name === 'opencode' || name === 'codeagent') { | |
| result = require('../config/opencode-execution-config').applyOpenCodeEnvironment(result, { | |
| cli: name, cwd: options.cwd || ctx.currentCwd || process.cwd(), | |
| proxyUrl: endpoint => headroom.getProxyBaseUrl(endpoint, 'passthrough', '127.0.0.1', options.profileContextId, options.headroomOwnerToken) | |
| }); | |
| } | |
| return require('../config/runtime-policy-config').applyRuntimePolicy(headroom.getHeadroomEnv(result, true, options.profileContextId, options.headroomOwnerToken), options); | |
| } | |
| module.exports = { getExecutionEnvironment }; | |