neurastream 0.3.11 → 0.3.12

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/core/guards.ts +20 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neurastream",
3
- "version": "0.3.11",
3
+ "version": "0.3.12",
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": [
6
6
  "ai-agents",
@@ -668,14 +668,28 @@ export function subCallCap(agentId: string, cfg: Config): number {
668
668
 
669
669
  // --- shared pieces ---
670
670
 
671
- function unlocked(cfg: Config): boolean {
671
+ /** Epoch ms when the owner's open unlock window closes, or null when the guard is locked. */
672
+ function unlockUntilMs(cfg: Config): number | null {
672
673
  try {
673
- return Date.now() - statSync(q.UNLOCK).mtimeMs < cfg.guards.unlock_minutes * 60_000;
674
+ const until = statSync(q.UNLOCK).mtimeMs + cfg.guards.unlock_minutes * 60_000;
675
+ return Date.now() < until ? until : null;
674
676
  } catch {
675
- return false;
677
+ return null;
676
678
  }
677
679
  }
678
680
 
681
+ /**
682
+ * One line for Main's prompt while the owner's unlock is open. A chat "unlock" is swallowed by the
683
+ * input handler (the model never sees the message), so without this line Main only learns of it
684
+ * when the owner says so in the next message.
685
+ */
686
+ function unlockLine(cfg: Config): string {
687
+ const until = unlockUntilMs(cfg);
688
+ if (until === null) return "";
689
+ const hhmm = new Date(until).toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
690
+ return `\nguards: UNLOCKED until ${hhmm} — guard files are open; do the step that waited on the unlock now.`;
691
+ }
692
+
679
693
  function protectedHit(paths: string[], cfg: Config): string | null {
680
694
  const hit = q.protectedHit(paths);
681
695
  if (hit) return hit;
@@ -1727,7 +1741,7 @@ function checkToolRules(e: ToolEvent, cfg: Config, runs?: RunSource): Decision {
1727
1741
  ? writes.filter(p => !(path.extname(p) === ".md" && path.dirname(path.resolve(p)) === rolloverDir))
1728
1742
  : writes;
1729
1743
  const hit = protectedHit(openWrites, cfg);
1730
- if (hit && !unlocked(cfg)) {
1744
+ if (hit && unlockUntilMs(cfg) === null) {
1731
1745
  log(cfg.paths.plan_guard_log, `BLOCK ${e.agent}:${e.agentId} tool=${e.tool} protected: ${hit} rule=tool.protected`);
1732
1746
  // The plan index (plan 20261031_0911 P2) is guard surface like the rest, but unlike the
1733
1747
  // others an agent has a sanctioned way to change it: the queue add/move CLI through
@@ -2141,7 +2155,8 @@ export function checkInject(e: InjectEvent, cfg: Config): Decision {
2141
2155
  : tier === "full"
2142
2156
  ? `Main works unattended: no edit cap, its own "Priority skip: <plan> — Main: \\"<reason>\\"" skips pass, pushes and merges go through. Owner-only moves (guard files, the phone page, notify secrets, the unlock) stay locked.`
2143
2157
  : `Main changes at most ${cfg.guards.main_edit_limit} project files per ${cfg.guards.main_window_min} min; pushes and merges go through.`;
2144
- const editLimit = continuation ? "" : `\nautonomy: ${tier} — ${tierNote}`;
2158
+ const unlockNote = continuation ? "" : unlockLine(cfg);
2159
+ const editLimit = continuation ? "" : `\nautonomy: ${tier} — ${tierNote}${unlockNote}`;
2145
2160
  return {
2146
2161
  allow: true,
2147
2162
  reason: "",