neurastream 0.3.14 → 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 +1 -1
- package/src/adapters/omp/index.ts +9 -11
- package/src/core/guards.ts +5 -24
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
|
|
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
|
-
|
|
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 (
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
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
|
|
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.
|
package/src/core/guards.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
697
|
-
|
|
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 {
|
|
@@ -2174,7 +2155,7 @@ export function checkInject(e: InjectEvent, cfg: Config): Decision {
|
|
|
2174
2155
|
? `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.`
|
|
2175
2156
|
: `Main changes at most ${cfg.guards.main_edit_limit} project files per ${cfg.guards.main_window_min} min; pushes and merges go through.`;
|
|
2176
2157
|
const unlockNote = continuation ? "" : unlockLine(cfg);
|
|
2177
|
-
const mayNote = ` Main may edit
|
|
2158
|
+
const mayNote = ` Main may edit Status/WAITING/Waits on/False positive lines. Test before saying "cannot".`;
|
|
2178
2159
|
const editLimit = continuation ? "" : `\nautonomy: ${tier} — ${tierNote}${mayNote}${unlockNote}`;
|
|
2179
2160
|
return {
|
|
2180
2161
|
allow: true,
|