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.
- package/package.json +1 -1
- package/src/core/guards.ts +20 -5
package/package.json
CHANGED
package/src/core/guards.ts
CHANGED
|
@@ -668,14 +668,28 @@ export function subCallCap(agentId: string, cfg: Config): number {
|
|
|
668
668
|
|
|
669
669
|
// --- shared pieces ---
|
|
670
670
|
|
|
671
|
-
|
|
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
|
-
|
|
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
|
|
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 &&
|
|
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
|
|
2158
|
+
const unlockNote = continuation ? "" : unlockLine(cfg);
|
|
2159
|
+
const editLimit = continuation ? "" : `\nautonomy: ${tier} — ${tierNote}${unlockNote}`;
|
|
2145
2160
|
return {
|
|
2146
2161
|
allow: true,
|
|
2147
2162
|
reason: "",
|