neurastream 0.3.29 → 0.3.30

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.29",
3
+ "version": "0.3.30",
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",
@@ -405,7 +405,7 @@ export function handleAgyHook(
405
405
  if (isDuplicateAgyPrompt(payload, cfg)) return { code: 0, stdout: "{}" };
406
406
  const prompt = extractHookPrompt(payload);
407
407
  const cmdNote = applyHookChatCommand(prompt, cfg);
408
- const injected = checkInject({ inject: prompt, agent: "main" }, cfg).inject;
408
+ const injected = checkInject({ inject: prompt, agent: "main" }, cfg, env.HERDR_ENV === "1" ? "herdr" : null).inject;
409
409
  const text = [cmdNote, injected].filter(Boolean).join("\n");
410
410
  return {
411
411
  code: 0,
@@ -419,7 +419,7 @@ export function buildSessionStartContext(
419
419
  if (env.NEURASTREAM_MAIN_LAUNCHER === "1") {
420
420
  return [
421
421
  renderBlock(cfg),
422
- checkInject({ inject: "", agent: "main" }, cfg).inject,
422
+ checkInject({ inject: "", agent: "main" }, cfg, env.HERDR_ENV === "1" ? "herdr" : null).inject,
423
423
  buildContinuitySnapshot(cfg, env, opts),
424
424
  ]
425
425
  .filter(Boolean)
@@ -535,7 +535,7 @@ export function createOmpAdapter(pi: ExtensionHost, initial: Config, freshConfig
535
535
  }
536
536
  rateLimit.onOwnerPrompt();
537
537
  limitWake.cancel();
538
- const d = checkInject({ inject: prompt, agent: "main" }, cfg);
538
+ const d = checkInject({ inject: prompt, agent: "main" }, cfg, process.env.HERDR_ENV === "1" ? "herdr" : null);
539
539
  callsSinceStop = d.state?.callsSinceStop ?? callsSinceStop;
540
540
  idleStops = d.state?.idleStops ?? idleStops;
541
541
  const notice = rollover.notice(ctx);
@@ -1209,7 +1209,7 @@ export function handleStandardHook(opts: {
1209
1209
  if (!isHookActive(env) || !cfg || hookAgent(env) !== "main") return { code: 0, stdout: "" };
1210
1210
  const prompt = extractHookPrompt(parseHookPayload(stdinText));
1211
1211
  const cmdNote = applyHookChatCommand(prompt, cfg);
1212
- const injected = checkInject({ inject: prompt, agent: "main" }, cfg).inject;
1212
+ const injected = checkInject({ inject: prompt, agent: "main" }, cfg, env.HERDR_ENV === "1" ? "herdr" : null).inject;
1213
1213
  const text = [cmdNote, injected].filter(Boolean).join("\n");
1214
1214
  if (!text) return { code: 0, stdout: "" };
1215
1215
  return {
@@ -6,6 +6,7 @@ import { currentPlanner, currentTier } from "../autonomy.ts";
6
6
  import type { Config } from "../config.ts";
7
7
  import { withFileLock, writeAtomicSync } from "../file-lock.ts";
8
8
  import * as q from "../queue/lib.ts";
9
+ import { resolveSpawnProfile } from "../runner.ts";
9
10
  import { summaryHolder, teamSummaryLines, teamViews } from "../team-client.ts";
10
11
  import {
11
12
  ALLOW,
@@ -44,15 +45,30 @@ export function flagCancel(text: string, cfg: Config): string {
44
45
  return `\nmain-guard: ${CANCEL_TODO} Flagged: "${words}"`;
45
46
  }
46
47
 
47
- /** The owner prompt's Tools-and-limits card: the call cap, planner mode, approval gate and the open plans' deny-command blockers, three lines at most. */
48
- function toolsCard(cfg: Config, tier: string, plans: q.Plan[]): string[] {
48
+ /**
49
+ * Where Main spawns helpers: inside a managed runner session the adapters' spawn guards refuse the
50
+ * harness task tool for every allowed agent whose resolved spawn profile runner is not "native".
51
+ */
52
+ function spawnLine(cfg: Config, session: string | null): string {
53
+ if (!session) return "Spawn: task tool (no managed runner session)";
54
+ const native = [...q.allowedAgents(cfg.paths.subagents)].filter(a => resolveSpawnProfile(a, cfg).runner === "native");
55
+ return `Spawn: ${session} session — \`neurastream spawn --agent <name> --plan <plan.md> --cwd <worktree> --brief "<brief>"\`; task tool only for: ${native.join(", ") || "none"}`;
56
+ }
57
+
58
+ /**
59
+ * The owner prompt's Tools-and-limits card: the call cap, planner mode, approval gate, the spawn
60
+ * route (when the adapter names the runner session: null = none; undefined = not reported, no line)
61
+ * and the open plans' deny-command blockers, four lines at most.
62
+ */
63
+ function toolsCard(cfg: Config, tier: string, plans: q.Plan[], session: string | null | undefined): string[] {
49
64
  const cap = mainCallsCapOn(cfg, tier) ? `Calls: ${cfg.guards.main_max_calls} per turn (warn at ${cfg.guards.main_warn_calls})` : "Calls: off";
50
65
  const approval = cfg.approval.since ? `plans stamped >= ${cfg.approval.since} need page + approve` : "off";
51
- const calls = `${cap} | planner: ${currentPlanner(cfg)} | approval: ${approval}`;
66
+ const lines = ["Tools and limits", `${cap} | planner: ${currentPlanner(cfg)} | approval: ${approval}`];
67
+ if (session !== undefined) lines.push(spawnLine(cfg, session));
52
68
  const denies = plans.flatMap(p => p.blockers.filter(b => path.basename(b.script) === "deny-command").map(b => `${path.basename(p.file)}: ${b.args.join(" ")}`));
53
- if (!denies.length) return ["Tools and limits", calls];
69
+ if (!denies.length) return lines;
54
70
  const more = denies.length > 3 ? ` | +${denies.length - 3} more` : "";
55
- return ["Tools and limits", calls, `Deny-commands (open plans): ${denies.slice(0, 3).join(" | ")}${more}`];
71
+ return [...lines, `Deny-commands (open plans): ${denies.slice(0, 3).join(" | ")}${more}`];
56
72
  }
57
73
 
58
74
  /**
@@ -62,9 +78,10 @@ function toolsCard(cfg: Config, tier: string, plans: q.Plan[]): string[] {
62
78
  * starts from this guard's own stop continuation ("main-guard: …") is not an owner message: it
63
79
  * keeps the counters and the edit window, else every continuation reset the idle streak and a
64
80
  * model that only answers text was nudged again forever (2026-10-21 OOM: ~205 agent starts in one
65
- * non-interactive session).
81
+ * non-interactive session). `runnerSession` is the managed runner session Main runs in (null =
82
+ * none); adapters that pass it get the card's spawn-route line.
66
83
  */
67
- export function checkInject(e: InjectEvent, cfg: Config): Decision {
84
+ export function checkInject(e: InjectEvent, cfg: Config, runnerSession?: string | null): Decision {
68
85
  if (e.agent !== "main") return ALLOW;
69
86
  const continuation = e.inject.trimStart().startsWith("main-guard:");
70
87
  if (!continuation) writeWindow({ used: [], windowStart: 0, mainCalls: 0 }, cfg.paths);
@@ -100,7 +117,7 @@ export function checkInject(e: InjectEvent, cfg: Config): Decision {
100
117
  const unlockNote = continuation ? "" : unlockLine(cfg);
101
118
  const mayNote = ` Main may edit Status/WAITING/Waits on/False positive lines. Test before saying "cannot".`;
102
119
  const editLimit = continuation ? "" : `\nautonomy: ${tier} — ${tierNote}${mayNote}${unlockNote}`;
103
- const card = continuation ? "" : `\n${toolsCard(cfg, tier, open).join("\n")}`;
120
+ const card = continuation ? "" : `\n${toolsCard(cfg, tier, open, runnerSession).join("\n")}`;
104
121
  return {
105
122
  allow: true,
106
123
  reason: "",