@sagentlab/navarch-runtime 0.1.67 → 0.1.68
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/dist/api.cjs +2 -2
- package/dist/session.cjs +13 -4
- package/package.json +1 -1
package/dist/api.cjs
CHANGED
|
@@ -142,8 +142,8 @@ class NavarchApiClient {
|
|
|
142
142
|
return result;
|
|
143
143
|
}
|
|
144
144
|
/** Best-effort, lease-scoped activity signal for connected machines. */
|
|
145
|
-
async reportActivity(leaseId, phase) {
|
|
146
|
-
await this.request("POST", `/api/dispatch/${encodeURIComponent(leaseId)}/activity`, { phase }, { allowEmpty: true });
|
|
145
|
+
async reportActivity(leaseId, phase, detail) {
|
|
146
|
+
await this.request("POST", `/api/dispatch/${encodeURIComponent(leaseId)}/activity`, { phase, ...(detail ? { detail } : {}) }, { allowEmpty: true });
|
|
147
147
|
}
|
|
148
148
|
/** schema-design.md §7 — `POST /api/dispatch/:leaseId/complete {status, report, evidence_urls, cost}`. */
|
|
149
149
|
async completeLease(leaseId, req) {
|
package/dist/session.cjs
CHANGED
|
@@ -401,16 +401,22 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
401
401
|
let activityPending = Promise.resolve();
|
|
402
402
|
let outputObservedAt = 0;
|
|
403
403
|
let outputReportedAt = 0;
|
|
404
|
+
let outputUpdates = 0;
|
|
405
|
+
let agentTurnStartedAt = 0;
|
|
404
406
|
let adapterRunning = false;
|
|
405
|
-
const reportActivity = (phase) => {
|
|
406
|
-
activityPending = activityPending.then(() => api.reportActivity(leaseId, phase)).catch((error) => {
|
|
407
|
+
const reportActivity = (phase, detail) => {
|
|
408
|
+
activityPending = activityPending.then(() => api.reportActivity(leaseId, phase, detail)).catch((error) => {
|
|
407
409
|
log.warn(`activity update failed for ${leaseId}: ${(0, redact_cjs_1.redactText)(String(error), registry.list())}`);
|
|
408
410
|
});
|
|
409
411
|
};
|
|
410
412
|
const activityTimer = setInterval(() => {
|
|
411
413
|
if (adapterRunning && outputObservedAt > outputReportedAt && Date.now() - outputReportedAt >= 60_000) {
|
|
412
414
|
outputReportedAt = Date.now();
|
|
413
|
-
reportActivity("output"
|
|
415
|
+
reportActivity("output", {
|
|
416
|
+
outputUpdates,
|
|
417
|
+
elapsedSeconds: Math.floor((outputReportedAt - agentTurnStartedAt) / 1000),
|
|
418
|
+
});
|
|
419
|
+
outputUpdates = 0;
|
|
414
420
|
}
|
|
415
421
|
}, 15_000);
|
|
416
422
|
const heartbeatGuard = new lease_heartbeat_cjs_1.LeaseHeartbeatGuard(claimed.expires_at, () => {
|
|
@@ -485,6 +491,9 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
485
491
|
await node_fs_1.promises.writeFile(node_path_1.default.join(workDir, "prompt.md"), runPrompt, "utf8");
|
|
486
492
|
adapterStarted = true;
|
|
487
493
|
adapterRunning = true;
|
|
494
|
+
agentTurnStartedAt = Date.now();
|
|
495
|
+
outputReportedAt = agentTurnStartedAt;
|
|
496
|
+
outputUpdates = 0;
|
|
488
497
|
reportActivity("running");
|
|
489
498
|
const remainingRuntimeMs = maxRuntimeMs > 0
|
|
490
499
|
? maxRuntimeMs - (node_perf_hooks_1.performance.now() - agentBudgetStartedAt)
|
|
@@ -509,7 +518,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
509
518
|
cwd: gitWorktree.worktreePath,
|
|
510
519
|
dockerExec: sandbox ? { containerName: sandbox.name, runner: sandbox_cjs_1.nodeCommandRunner } : undefined,
|
|
511
520
|
signal: activeAbortController.signal,
|
|
512
|
-
onActivity: () => { outputObservedAt = Date.now(); },
|
|
521
|
+
onActivity: () => { outputObservedAt = Date.now(); outputUpdates += 1; },
|
|
513
522
|
}, task.idle_timeout_ms ?? config.sessionIdleTimeoutMs ?? 45 * 60_000, runtime === "opencode" ? config.opencodeStartupTimeoutMs : 0);
|
|
514
523
|
activeAbortController = null;
|
|
515
524
|
adapterRunning = false;
|
package/package.json
CHANGED