| 1234567891011121314151617 |
- PATH = '/data/ai/audio/server/dist/services/llm/index.js'
- with open(PATH, 'r', encoding='utf-8') as f:
- src = f.read()
- # 在 'use strict' 后插入 ALS require
- if '_triedNodesStorage' not in src:
- src = src.replace(
- '"use strict";',
- '"use strict";\nconst { AsyncLocalStorage: _ALS } = require(\'async_hooks\');\nconst _triedNodesStorage = new _ALS();\nfunction _runWithTriedNodes(triedSet, fn) { return _triedNodesStorage.run(triedSet, fn); }\nfunction _currentTriedNodes() { return _triedNodesStorage.getStore() || new Set(); }',
- 1
- )
- print("OK: ALS injected")
- else:
- print("WARN: ALS already present")
- with open(PATH, 'w', encoding='utf-8') as f:
- f.write(src)
|