@sagentlab/navarch-runtime 0.1.64 → 0.1.65
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/README.md +5 -0
- package/dist/api.cjs +4 -0
- package/dist/session.cjs +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,11 @@ it. Plain Node/TypeScript, no Next.js coupling, and no shared app-code coupling
|
|
|
6
6
|
— this directory is a self-contained package you can `npx` on any fresh
|
|
7
7
|
machine.
|
|
8
8
|
|
|
9
|
+
During a connected run, the runtime reports preparation, agent start, output
|
|
10
|
+
activity, and completion checks to the control plane. Project members can see
|
|
11
|
+
these phase updates in the task view. The activity signal contains no prompt
|
|
12
|
+
or CLI output; the redacted transcript is uploaded when the run finishes.
|
|
13
|
+
|
|
9
14
|
The machine operator selects **Claude Code**, **OpenAI Codex**, **Google
|
|
10
15
|
Gemini CLI**, **OpenCode**, or an **Agent Client Protocol (ACP)** agent when connecting a worker. Any selected agent can
|
|
11
16
|
run any unpinned project task; task eligibility depends on capabilities and
|
package/dist/api.cjs
CHANGED
|
@@ -141,6 +141,10 @@ class NavarchApiClient {
|
|
|
141
141
|
throw new Error("heartbeatLease: empty response from control plane.");
|
|
142
142
|
return result;
|
|
143
143
|
}
|
|
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 });
|
|
147
|
+
}
|
|
144
148
|
/** schema-design.md §7 — `POST /api/dispatch/:leaseId/complete {status, report, evidence_urls, cost}`. */
|
|
145
149
|
async completeLease(leaseId, req) {
|
|
146
150
|
await this.request("POST", `/api/dispatch/${encodeURIComponent(leaseId)}/complete`, req, {
|
package/dist/session.cjs
CHANGED
|
@@ -395,6 +395,23 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
395
395
|
// session actually produced instead of zeroing it.
|
|
396
396
|
let lastCompletion = null;
|
|
397
397
|
let adapterStarted = false;
|
|
398
|
+
// Activity is metadata only: no prompt, model output, or secret-bearing CLI
|
|
399
|
+
// text crosses this path. Failures never affect lease ownership or delivery.
|
|
400
|
+
let activityPending = Promise.resolve();
|
|
401
|
+
let outputObservedAt = 0;
|
|
402
|
+
let outputReportedAt = 0;
|
|
403
|
+
let adapterRunning = false;
|
|
404
|
+
const reportActivity = (phase) => {
|
|
405
|
+
activityPending = activityPending.then(() => api.reportActivity(leaseId, phase)).catch((error) => {
|
|
406
|
+
log.warn(`activity update failed for ${leaseId}: ${(0, redact_cjs_1.redactText)(String(error), registry.list())}`);
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
const activityTimer = setInterval(() => {
|
|
410
|
+
if (adapterRunning && outputObservedAt > outputReportedAt && Date.now() - outputReportedAt >= 60_000) {
|
|
411
|
+
outputReportedAt = Date.now();
|
|
412
|
+
reportActivity("output");
|
|
413
|
+
}
|
|
414
|
+
}, 15_000);
|
|
398
415
|
const heartbeatGuard = new lease_heartbeat_cjs_1.LeaseHeartbeatGuard(claimed.expires_at, () => {
|
|
399
416
|
log.warn(`confirmed lease expired for ${leaseId} without renewal — killing session.`);
|
|
400
417
|
leaseLost = true;
|
|
@@ -407,6 +424,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
407
424
|
abortForRuntimeShutdown();
|
|
408
425
|
lifecycle.enteredMainSessionTry = true;
|
|
409
426
|
try {
|
|
427
|
+
reportActivity("preparing");
|
|
410
428
|
await gitWorktree.prepare();
|
|
411
429
|
if (gitWorktree.hostedCheckpointRestoreFailure) {
|
|
412
430
|
log.warn(`hosted checkpoint for ${leaseId} could not be restored: ` +
|
|
@@ -465,6 +483,8 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
465
483
|
nextPrompt = null;
|
|
466
484
|
await node_fs_1.promises.writeFile(node_path_1.default.join(workDir, "prompt.md"), runPrompt, "utf8");
|
|
467
485
|
adapterStarted = true;
|
|
486
|
+
adapterRunning = true;
|
|
487
|
+
reportActivity("running");
|
|
468
488
|
const remainingRuntimeMs = maxRuntimeMs > 0
|
|
469
489
|
? maxRuntimeMs - (node_perf_hooks_1.performance.now() - agentBudgetStartedAt)
|
|
470
490
|
: 0;
|
|
@@ -488,8 +508,10 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
488
508
|
cwd: gitWorktree.worktreePath,
|
|
489
509
|
dockerExec: sandbox ? { containerName: sandbox.name, runner: sandbox_cjs_1.nodeCommandRunner } : undefined,
|
|
490
510
|
signal: activeAbortController.signal,
|
|
511
|
+
onActivity: () => { outputObservedAt = Date.now(); },
|
|
491
512
|
}, task.idle_timeout_ms ?? config.sessionIdleTimeoutMs ?? 45 * 60_000, runtime === "opencode" ? config.opencodeStartupTimeoutMs : 0);
|
|
492
513
|
activeAbortController = null;
|
|
514
|
+
adapterRunning = false;
|
|
493
515
|
if (turnResult.timedOut || leaseLost)
|
|
494
516
|
await checkpointForRecovery(turnResult);
|
|
495
517
|
if (turnResult.model) {
|
|
@@ -497,6 +519,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
497
519
|
executionReport = { ...executionReport, model: turnResult.model };
|
|
498
520
|
}
|
|
499
521
|
attempts.push(turnResult);
|
|
522
|
+
reportActivity("finishing");
|
|
500
523
|
const capacityLimit = (0, adapter_capacity_cjs_1.detectAdapterCapacityLimit)(turnResult);
|
|
501
524
|
if (capacityLimit) {
|
|
502
525
|
await checkpointForRecovery(turnResult);
|
|
@@ -750,6 +773,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
750
773
|
deps.shutdownSignal?.removeEventListener("abort", abortForRuntimeShutdown);
|
|
751
774
|
sessionClosing = true;
|
|
752
775
|
clearInterval(heartbeatTimer);
|
|
776
|
+
clearInterval(activityTimer);
|
|
753
777
|
heartbeatGuard.stop();
|
|
754
778
|
activeAbortController?.abort();
|
|
755
779
|
// Drain only an already-started filesystem update, never a stalled network
|
package/package.json
CHANGED