Download src/batch-interactive-runner.js from VanyaJ/bada-terminal: direct link, hf CLI and curl.
- Browser
- Download file 3.08 kB
-
https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/batch-interactive-runner.js
- Command line
-
hf download hf://VanyaJ/bada-terminal/src/batch-interactive-runner.js
-
curl -L -o batch-interactive-runner.js https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/batch-interactive-runner.js
3.08 kB
| /** ๋ฐฐ์น ๋ํํ ์คํ์ ๊ณตํต ์ธ์ ์ ์ฐ๊ฒฐํ๋ค. docs/specs/interactive-execution.md v1.0.0 */ | |
| const path = require('path'); | |
| const { prepareLaunch } = require('./utils/interactive-cli-launch'); | |
| const { runInteractive } = require('./utils/interactive-cli-session'); | |
| const { addUsage } = require('./utils/run-usage'); | |
| async function runBatchInteractive(config, prompt, cwd, logStream, owner) { | |
| // ๊ฐ์ ๋ํํ ์ธ์ ์ explicitโauto ์ ํ์ helper๊ฐ ์ข์ ์ธ์ด ์ฌ์ค์ ์ง์๋ก ์ฒ๋ฆฌํ๋ค. | |
| // ์ค๋ช ๋ฌธ์: /docs/specs/bada-bong-language-settings.md (v0.3.0) | |
| prompt = require('./utils/agent-reply-language').interactiveAppend(prompt, owner, {id:require('./workflow/node-context').current(owner)?.nodeId}); | |
| const conf = require('./config-manager').getConfig(); | |
| const launch = prepareLaunch({ cliCommand: config.cli_engine || require('./context').getActiveCli() || 'claude', | |
| cliArguments: config.cliArguments || [], model: config.model, profile: config.executionProfile, permissionBypass: config.permission_mode === 'bypass', | |
| maxTurns: config.max_turns, cwd, env: { ...process.env, | |
| LANGFUSE_HOST: conf.host || '', LANGFUSE_PUBLIC_KEY: conf.publicKey || '', LANGFUSE_SECRET_KEY: conf.secretKey || '' } }); | |
| const output = await runInteractive({ ...launch, owner, profile: { ...config, prompt: undefined }, prompt, | |
| signal: owner.lifecycleController?.signal || owner.abortController?.signal, isCancelled: () => owner.aborted === true, | |
| timeoutMs: (config.timeout ?? 600) * 1000, readyTimeoutMs: (config.ready_timeout ?? 30) * 1000, | |
| maxBytes: config.maxOutputBytes ?? 2 * 1024 * 1024, | |
| // ์ค๋ช ๋ฌธ์: /docs/specs/bada-bong-agent-sources.md (v0.1.0) โ ์ฌ์ฌ์ฉ PTY๋ ์ค์ ๋ด๋น ์ฐ๊ฒฐ๋ง ๊ด์ธกํ๋ค. | |
| register: child => { owner.currentProcess = child; if (child?.pid) { const conductor = require('./services/agent-telemetry-conductor').current(owner); if (conductor) conductor.assigned({...config.executionProfile,name:config.executionProfile?.name || config.model || 'CLI'}); else require('./services/agent-telemetry-batch').assigned(owner, config.executionProfile); } }, | |
| unregister: child => { if (owner.currentProcess === child) owner.currentProcess = null; }, | |
| onOutput: data => logStream.write(data), | |
| onResult: ({ submitted, complete, requestId }) => { | |
| // ๋ํํ ํ๋ฉด์ผ๋ก provider ์ฒญ๊ตฌ ํ ํฐ์ ํ์ ํ์ง ์๋๋ค. ์คํจํ ์ ์ถ๋ ๋ฏธ์ ํธ์ถ๋ก ๊ธฐ๋กํ๋ค. | |
| if (submitted) addUsage(owner, 0, 1, { id: requestId, costSource: 'unknown', tokenSource: 'unknown', totalTokens: null, complete }); | |
| else if (requestId) addUsage(owner, 0, 0, { id: requestId, complete, notSubmitted: true, | |
| costSource: 'not_submitted', tokenSource: 'not_submitted', totalTokens: 0 }); | |
| } | |
| }); | |
| const hint = output.match(/(?:Wrote to|Edited|Wrote|Created)\s+([^\s\r\n]+)/i)?.[1].replace(/['"`]/g, ''); | |
| return { result: 'success', output, data: {}, file_path: hint ? path.resolve(cwd, hint) : '', usageRecorded: true }; | |
| } | |
| module.exports = { runBatchInteractive }; | |