neurastream 0.1.19 → 0.1.20

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 CHANGED
@@ -105,6 +105,7 @@ In both modes:
105
105
  - The running plugin going stale counts as over the threshold too: at every check the adapter re-reads the `package.json` it was loaded from, and a different (or unreadable) version asks for the handoff note even below `rollover.max_session_mb`, naming both versions (`NEURASTREAM_PACKAGE_JSON` overrides the path it watches).
106
106
  - While a rollover is pending (no fresh note, own jobs still running, or the handoff is ready and waiting for idle), Main cannot start new subagents: a `task` call is refused until the running jobs finish and the session rolls over.
107
107
  - While own jobs (subagents included) are still running, the switch waits: a rollover would cancel them.
108
+ - While a rollover is pending, the stop guard does not apply: Main may stop in `ready` or `wait-jobs`, and in `need-note` the stop is blocked only by the note request.
108
109
  - `/main-rollover <message>` does the same by hand. It refuses below the threshold, without a fresh note, or while jobs run. Under neurastream main it is refused and the owner's next message starts the rollover; in plain omp a second call while one waits adds its text to the same handoff.
109
110
  - `/main-rollover` shows a notice at once and gathers `main-start` in the background, so omp keeps repainting and reading keys until the new session opens.
110
111
  - The previous session file stays where it is.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neurastream",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Guardrails for running many AI coding agents at once: plan queue, blockers, call budgets, provider caps, scoring, merge-verified close.",
5
5
  "keywords": ["ai-agents", "coding-agents", "orchestration", "guardrails", "omp", "bun", "cli"],
6
6
  "homepage": "https://github.com/umiddey/neurastream#readme",
@@ -414,6 +414,23 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
414
414
  if (c.hasAgent && c.kind !== "main") return;
415
415
  // A relaunch is requested: omp shuts down at the next idle, so the stop must not be continued.
416
416
  if (relaunched) return undefined;
417
+ // A pending rollover decides the stop and checkStop is not consulted: its queue, incident and cancel
418
+ // blocks would hold Main at a wait the new session raises again through main-start, and its "spawn an
419
+ // agent" text is refused while the rollover is pending.
420
+ const rc = cfg.rollover.enabled ? asRolloverCtx(ctx) : null;
421
+ if (rc) {
422
+ const snap = rolloverSnapshot(rc);
423
+ if (snap.state === "need-note") {
424
+ adapterLog(cfg, "BLOCK stop: rollover need-note");
425
+ return { decision: "block", reason: noteRequestFor(rc, snap) };
426
+ }
427
+ if (snap.state === "ready" || snap.state === "wait-jobs") {
428
+ adapterLog(cfg, `ALLOW stop: rollover ${snap.state}`);
429
+ // Under the launcher a ready rollover starts now; plain omp waits for the owner's next message.
430
+ if (snap.state === "ready" && process.env.NEURASTREAM_MAIN_LAUNCHER === "1") requestRelaunch(rc, notePath(rc.sessionId));
431
+ return undefined;
432
+ }
433
+ }
417
434
  const d = checkStop({ agent: "main", callsSinceStop, idleStops, ledgerText: ledgerText(cfg) }, cfg);
418
435
  callsSinceStop = d.state?.callsSinceStop ?? 0;
419
436
  idleStops = d.state?.idleStops ?? idleStops;
@@ -463,6 +480,12 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
463
480
  };
464
481
  };
465
482
 
483
+ // The note request for a state. A stale install names both versions in place of the size line.
484
+ const noteRequestFor = (c: RolloverCtx, snap: { stale: boolean; liveVersion: string | null }): string => {
485
+ const reason = snap.stale ? `neurastream on disk is ${snap.liveVersion ?? "unknown"}, this session runs ${loadedVersion ?? "unknown"}` : undefined;
486
+ return noteRequest(notePath(c.sessionId), process.env.NEURASTREAM_MAIN_LAUNCHER === "1", reason);
487
+ };
488
+
466
489
  let relaunched = false;
467
490
  // The launcher restarts omp: the request file carries the note and the editor draft, and omp
468
491
  // shuts down only after the file is written. A failed write keeps the session running.
@@ -504,12 +527,8 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
504
527
  const key = `${c.sessionFile}:${snap.noteMtimeMs ?? "none"}`;
505
528
  if (snap.state === "need-note" && asked !== key) {
506
529
  asked = key;
507
- // A stale install says so: the request names the version on disk and the one running.
508
- const reason = snap.stale
509
- ? `neurastream on disk is ${snap.liveVersion ?? "unknown"}, this session runs ${loadedVersion ?? "unknown"}`
510
- : undefined;
511
530
  pi.sendMessage(
512
- { customType: "main-guard.rollover", content: noteRequest(notePath(c.sessionId), process.env.NEURASTREAM_MAIN_LAUNCHER === "1", reason), display: false },
531
+ { customType: "main-guard.rollover", content: noteRequestFor(c, snap), display: false },
513
532
  { triggerTurn: true, deliverAs: "nextTurn" },
514
533
  );
515
534
  } else if (snap.state === "ready" && process.env.NEURASTREAM_MAIN_LAUNCHER === "1" && !relaunched) {