neurastream 0.3.11 → 0.3.13
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/adapters/omp/index.ts +5 -1
- package/src/core/guards.ts +38 -5
package/package.json
CHANGED
|
@@ -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
|
});
|
package/src/core/guards.ts
CHANGED
|
@@ -668,14 +668,46 @@ 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
|
+
/** 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
|
+
/**
|
|
690
|
+
* 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.
|
|
693
|
+
*/
|
|
694
|
+
function unlockLine(cfg: Config): string {
|
|
695
|
+
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);
|
|
709
|
+
}
|
|
710
|
+
|
|
679
711
|
function protectedHit(paths: string[], cfg: Config): string | null {
|
|
680
712
|
const hit = q.protectedHit(paths);
|
|
681
713
|
if (hit) return hit;
|
|
@@ -1727,7 +1759,7 @@ function checkToolRules(e: ToolEvent, cfg: Config, runs?: RunSource): Decision {
|
|
|
1727
1759
|
? writes.filter(p => !(path.extname(p) === ".md" && path.dirname(path.resolve(p)) === rolloverDir))
|
|
1728
1760
|
: writes;
|
|
1729
1761
|
const hit = protectedHit(openWrites, cfg);
|
|
1730
|
-
if (hit &&
|
|
1762
|
+
if (hit && unlockUntilMs(cfg) === null) {
|
|
1731
1763
|
log(cfg.paths.plan_guard_log, `BLOCK ${e.agent}:${e.agentId} tool=${e.tool} protected: ${hit} rule=tool.protected`);
|
|
1732
1764
|
// The plan index (plan 20261031_0911 P2) is guard surface like the rest, but unlike the
|
|
1733
1765
|
// others an agent has a sanctioned way to change it: the queue add/move CLI through
|
|
@@ -2141,7 +2173,8 @@ export function checkInject(e: InjectEvent, cfg: Config): Decision {
|
|
|
2141
2173
|
: tier === "full"
|
|
2142
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.`
|
|
2143
2175
|
: `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
|
|
2176
|
+
const unlockNote = continuation ? "" : unlockLine(cfg);
|
|
2177
|
+
const editLimit = continuation ? "" : `\nautonomy: ${tier} — ${tierNote}${unlockNote}`;
|
|
2145
2178
|
return {
|
|
2146
2179
|
allow: true,
|
|
2147
2180
|
reason: "",
|