neurastream 0.3.15 → 0.3.16

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neurastream",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
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",
@@ -32,7 +32,7 @@ import { remoteStoreFor } from "../../core/team-client.ts";
32
32
  import { appendOwnerAnswer, readOwnerAnswers, readOwnerMessages } from "../../core/incidents.ts";
33
33
  import { appendedSinceSpawn, markTopicsSpawned, ownerLogDir, recordOwnerLog } from "../../core/owner-log.ts";
34
34
  import { topicsDue, topicsLogFile } from "../../core/owner-topics.ts";
35
- import { checkInject, checkPlanEdit, checkStop, checkTool, findingsValue, MAIN_PLAN_FILE, mainId, mainStateDir, newProgressEntries, planReadNote, plannerSpawnPlan, recordMainResult, resetMainCalls, revertMainEdit, rekeySpawnFile, reviewSpawnEnd, STOP_PLAN_OFFER_REFUSAL, unlockMidTurnNote } from "../../core/guards.ts";
35
+ import { checkInject, checkPlanEdit, checkStop, checkTool, findingsValue, MAIN_PLAN_FILE, mainId, mainStateDir, newProgressEntries, planReadNote, plannerSpawnPlan, recordMainResult, resetMainCalls, revertMainEdit, rekeySpawnFile, reviewSpawnEnd, STOP_PLAN_OFFER_REFUSAL } from "../../core/guards.ts";
36
36
  import { rateLimited } from "../../core/rate-limit.ts";
37
37
  import { backPost, clearLimitState, limitMetric, limitedPost, onLimited, readLimitState, timingOf, writeLimitState } from "../../core/limit-probe.ts";
38
38
  import { appendMetric } from "../../core/metrics.ts";
@@ -1302,10 +1302,6 @@ export function createOmpAdapter(pi: ExtensionHost, initial: Config, freshConfig
1302
1302
  bash: { command: asString(asRecord(e.input).command), output: content.map(p => asString(asRecord(p).text)).join("\n") },
1303
1303
  });
1304
1304
  }
1305
- if (!c.hasAgent || c.kind === "main") {
1306
- const unlockNote = unlockMidTurnNote(cfg);
1307
- if (unlockNote) notes.push(unlockNote);
1308
- }
1309
1305
  if (notes.length) return { content: [...content, ...notes.map(text => ({ type: "text", text }))] };
1310
1306
  return undefined;
1311
1307
  });
@@ -1746,14 +1742,16 @@ export function createOmpAdapter(pi: ExtensionHost, initial: Config, freshConfig
1746
1742
  // count: the local terminal (input event, source "interactive") and collab guest prompts from
1747
1743
  // write peers. This handler is registered BEFORE the rollover input handler below, so the unlock
1748
1744
  // wins while a rollover is ready or in flight (emitInput short-circuits on { handled: true }).
1749
- const notifyUnlock = (ctx: unknown, r: { command?: "unlock" | "lock"; minutes?: number }): void => {
1745
+ // An applied unlock also wakes Main (sendUserMessage: idle → a new turn, mid-turn → the steer
1746
+ // queue), the same message the phone-page unlock sends through the owner inbox.
1747
+ const notifyUnlock = (ctx: unknown, r: { command?: "unlock" | "lock"; minutes?: number; until?: number }): void => {
1750
1748
  const c = asRolloverCtx(ctx);
1751
- if (!c) return;
1752
- if (r.command === "unlock" && r.minutes !== undefined) {
1753
- const until = new Date(Date.now() + r.minutes * 60_000).toLocaleTimeString();
1754
- c.notify(`guard unlocked for ${r.minutes} min (until ${until})`);
1749
+ if (r.command === "unlock" && r.minutes !== undefined && r.until !== undefined) {
1750
+ const hhmm = strftime(r.until, "%H:%M");
1751
+ c?.notify(`guard unlocked for ${r.minutes} min (until ${hhmm})`);
1752
+ pi.sendUserMessage(`Owner unlocked the guards in chat for ${r.minutes} min (until ${hhmm}). Do the step that waited on the unlock now.`);
1755
1753
  } else if (r.command === "lock") {
1756
- c.notify("guard locked again");
1754
+ c?.notify("guard locked again");
1757
1755
  }
1758
1756
  };
1759
1757
  // The tier switch and the one-shot `go` travel the same two owner paths and answer the same way.
@@ -678,34 +678,15 @@ function unlockUntilMs(cfg: Config): number | null {
678
678
  }
679
679
  }
680
680
 
681
- /** The unlock window end Main was last told about (prompt line or mid-turn note). */
682
- let announcedUnlockUntil: number | null = null;
683
-
684
- function unlockText(until: number): string {
685
- const hhmm = new Date(until).toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
686
- return `guards: UNLOCKED until ${hhmm} — guard files are open; do the step that waited on the unlock now.`;
687
- }
688
-
689
681
  /**
690
682
  * One line for Main's prompt while the owner's unlock is open. A chat "unlock" is swallowed by the
691
- * input handler (the model never sees the message), so without this line Main only learns of it
692
- * when the owner says so in the next message.
683
+ * input handler (the model never sees the message), so the adapter also wakes Main with a message.
693
684
  */
694
685
  function unlockLine(cfg: Config): string {
695
686
  const until = unlockUntilMs(cfg);
696
- announcedUnlockUntil = until;
697
- return until === null ? "" : `\n${unlockText(until)}`;
698
- }
699
-
700
- /**
701
- * The same line for an unlock typed while Main's turn is running: the prompt line was built before
702
- * it, so the adapter appends this to a tool result. Once per unlock; null when nothing new.
703
- */
704
- export function unlockMidTurnNote(cfg: Config): string | null {
705
- const until = unlockUntilMs(cfg);
706
- if (until === null || until === announcedUnlockUntil) return null;
707
- announcedUnlockUntil = until;
708
- return unlockText(until);
687
+ if (until === null) return "";
688
+ const hhmm = new Date(until).toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
689
+ return `\nguards: UNLOCKED until ${hhmm} — guard files are open; do the step that waited on the unlock now.`;
709
690
  }
710
691
 
711
692
  function protectedHit(paths: string[], cfg: Config): string | null {