2026-06-02 15:30:16 +08:00
|
|
|
import { loadEnvConfig } from '@shumai/core/src/env-loader'
|
|
|
|
|
loadEnvConfig(process.cwd(), process.env.NODE_ENV !== 'production')
|
|
|
|
|
|
|
|
|
|
import { workflowService } from '@shumai/workflow-core'
|
|
|
|
|
import { TaskQueueAgent } from '@shumai/workflow-core'
|
|
|
|
|
import { initAgentWorkflows } from '@shumai/agent'
|
2026-09-08 20:21:29 +08:00
|
|
|
import { sandboxService } from '@shumai/core'
|
2026-06-20 12:37:49 +08:00
|
|
|
import { handleDaemonCommands } from '@shumai/core/src/utils/daemon'
|
2026-06-02 15:30:16 +08:00
|
|
|
|
2026-06-20 11:54:30 +08:00
|
|
|
if (process.argv.includes('--check')) {
|
|
|
|
|
console.log('✅ Agent worker evaluated successfully!')
|
|
|
|
|
process.exit(0)
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-02 15:30:16 +08:00
|
|
|
async function run() {
|
|
|
|
|
// Initialize workflows and activities
|
|
|
|
|
initAgentWorkflows()
|
2026-09-08 20:21:29 +08:00
|
|
|
await sandboxService.ensureInitialized().catch((err) => {
|
|
|
|
|
console.error('Failed to eagerly initialize sandbox in agent worker:', err)
|
|
|
|
|
})
|
2026-06-02 15:30:16 +08:00
|
|
|
|
|
|
|
|
console.log('🚀 Starting Agent Worker...')
|
2026-06-03 09:10:31 +08:00
|
|
|
|
2026-10-17 15:50:17 +08:00
|
|
|
await workflowService.startWorkers(TaskQueueAgent)
|
2026-06-02 15:30:16 +08:00
|
|
|
}
|
|
|
|
|
|
2026-06-20 12:37:49 +08:00
|
|
|
handleDaemonCommands('shumai-agent', run).catch((err) => {
|
2026-06-02 15:30:16 +08:00
|
|
|
console.error(err)
|
|
|
|
|
process.exit(1)
|
|
|
|
|
})
|