Download src/workflow/node-context.js from VanyaJ/bada-terminal: direct link, hf CLI and curl.
- Browser
- Download file 819 Bytes
-
https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/workflow/node-context.js
- Command line
-
hf download hf://VanyaJ/bada-terminal/src/workflow/node-context.js
-
curl -L -o node-context.js https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/workflow/node-context.js
819 Bytes
| // 병렬 자식의 비동기 요청에만 node/task 귀속을 전달한다. 공유 currentNodeId는 바꾸지 않는다. | |
| // 설명 문서: docs/specs/bong-browser-use.md (v1.12.0) | |
| const { AsyncLocalStorage } = require('async_hooks'), contexts = new AsyncLocalStorage(); | |
| async function withNode(run, nodeId, taskId, execute) { | |
| const context = { run, nodeId, taskId, active: true }; | |
| return contexts.run(context, async () => { try { return await execute(); } finally { context.active = false; } }); | |
| } | |
| function current(run) { | |
| const context = contexts.getStore(); if (!context || context.run !== run) return null; | |
| if (!context.active) throw Object.assign(Error('Workflow node request scope has ended'), { code: 'USAGE_LEDGER_FAILED', retryable: false }); | |
| return context; | |
| } | |
| module.exports = { withNode, current }; | |