neurastream 0.3.12 → 0.3.14

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.12",
3
+ "version": "0.3.14",
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 } 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, unlockMidTurnNote } 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,6 +1302,10 @@ 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
+ }
1305
1309
  if (notes.length) return { content: [...content, ...notes.map(text => ({ type: "text", text }))] };
1306
1310
  return undefined;
1307
1311
  });
@@ -678,6 +678,14 @@ 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
+
681
689
  /**
682
690
  * One line for Main's prompt while the owner's unlock is open. A chat "unlock" is swallowed by the
683
691
  * input handler (the model never sees the message), so without this line Main only learns of it
@@ -685,9 +693,19 @@ function unlockUntilMs(cfg: Config): number | null {
685
693
  */
686
694
  function unlockLine(cfg: Config): string {
687
695
  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.`;
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);
691
709
  }
692
710
 
693
711
  function protectedHit(paths: string[], cfg: Config): string | null {
@@ -2156,7 +2174,8 @@ export function checkInject(e: InjectEvent, cfg: Config): Decision {
2156
2174
  ? `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.`
2157
2175
  : `Main changes at most ${cfg.guards.main_edit_limit} project files per ${cfg.guards.main_window_min} min; pushes and merges go through.`;
2158
2176
  const unlockNote = continuation ? "" : unlockLine(cfg);
2159
- const editLimit = continuation ? "" : `\nautonomy: ${tier} — ${tierNote}${unlockNote}`;
2177
+ const mayNote = ` Main may edit the lines Status/WAITING on owner/Waits on/Cancelled by owner/False positive and add Progress entries${currentPlanner(cfg) === "delegated" ? "; planner delegated: plan body and CANCELLED.md are refused (clear a ban with a False positive line)" : ""}. Test before saying "cannot".`;
2178
+ const editLimit = continuation ? "" : `\nautonomy: ${tier} — ${tierNote}${mayNote}${unlockNote}`;
2160
2179
  return {
2161
2180
  allow: true,
2162
2181
  reason: "",