@11agents/cli 0.1.22 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands/runtime.js +15 -3
package/package.json
CHANGED
package/src/commands/runtime.js
CHANGED
|
@@ -1473,6 +1473,15 @@ async function claimAndRunRuntimeTasks(registration, flags, deps, handlerModule,
|
|
|
1473
1473
|
return results.filter(r => r.status === 'fulfilled' && r.value === true).length
|
|
1474
1474
|
}
|
|
1475
1475
|
|
|
1476
|
+
async function drainRuntimeTasks(registration, flags, deps, handlerModule, retryState = createRetryState(), heartbeatIntervalMs = 15000, maxConcurrent = 1) {
|
|
1477
|
+
let completed = 0
|
|
1478
|
+
while (true) {
|
|
1479
|
+
const claimed = await claimAndRunRuntimeTasks(registration, flags, deps, handlerModule, retryState, heartbeatIntervalMs, maxConcurrent)
|
|
1480
|
+
completed += claimed
|
|
1481
|
+
if (claimed === 0) return completed
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1476
1485
|
export async function startRuntimeDaemon(flags = {}, deps = {}) {
|
|
1477
1486
|
const resolvedDeps = runtimeDeps(deps)
|
|
1478
1487
|
const heartbeatIntervalMs = Number(flag(flags, 'heartbeat-interval', '15')) * 1000
|
|
@@ -1507,8 +1516,11 @@ export async function startRuntimeDaemon(flags = {}, deps = {}) {
|
|
|
1507
1516
|
'Runtime task failed locally: daemon restarted with a persisted claimed task that had not completed.'
|
|
1508
1517
|
), resolvedDeps, retryState)
|
|
1509
1518
|
await syncRuntimeProjectMetadataBestEffort(flags, resolvedDeps)
|
|
1510
|
-
|
|
1511
|
-
|
|
1519
|
+
if (once) {
|
|
1520
|
+
await claimAndRunRuntimeTasks(registration, flags, resolvedDeps, handlerModule, retryState, heartbeatIntervalMs, maxConcurrent)
|
|
1521
|
+
return
|
|
1522
|
+
}
|
|
1523
|
+
await drainRuntimeTasks(registration, flags, resolvedDeps, handlerModule, retryState, heartbeatIntervalMs, maxConcurrent)
|
|
1512
1524
|
|
|
1513
1525
|
let lastScan = Date.now()
|
|
1514
1526
|
let lastHeartbeat = Date.now()
|
|
@@ -1526,7 +1538,7 @@ export async function startRuntimeDaemon(flags = {}, deps = {}) {
|
|
|
1526
1538
|
lastHeartbeat = now
|
|
1527
1539
|
}
|
|
1528
1540
|
if (now - lastTaskPoll >= taskIntervalMs) {
|
|
1529
|
-
await
|
|
1541
|
+
await drainRuntimeTasks(registration, flags, resolvedDeps, handlerModule, retryState, heartbeatIntervalMs, maxConcurrent)
|
|
1530
1542
|
lastTaskPoll = now
|
|
1531
1543
|
}
|
|
1532
1544
|
if (now - lastProjectRefresh >= projectRefreshIntervalMs) {
|