pi-jev-guard 0.3.2 → 0.3.3
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/README.md +9 -0
- package/extensions/index.ts +53 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,6 +126,15 @@ al cambio account), l'overlay viene ricostruito sopra il provider live prima di
|
|
|
126
126
|
ogni turno; in più il gate toglie il suffisso `__jev` da qualunque payload,
|
|
127
127
|
registrando `jev-gate-bypass` e avvisando in TUI, perché quel turno non è
|
|
128
128
|
passato dalla verifica.
|
|
129
|
+
|
|
130
|
+
Coabitazione con `pi-accounts`: quell'estensione aborts i turni il cui modello
|
|
131
|
+
non risulta nei modelli disponibili dell'account (`turn_start` → `ctx.abort()`,
|
|
132
|
+
errore istantaneo `This operation was aborted`). Per questo i twin vengono
|
|
133
|
+
registrati già all'evento `input`, prima di qualsiasi `before_agent_start`:
|
|
134
|
+
quando pi-accounts legge il registry trova gli id `__jev` e non arma l'abort.
|
|
135
|
+
Se vedi comunque quell'errore solo sui twin (il modello originale funziona),
|
|
136
|
+
con un avviso `... is not available to account ...`, è quella gara di
|
|
137
|
+
registrazione: apri un issue con le righe `jev-overlay-reassert` della sessione.
|
|
129
138
|
Le conferme per comandi di rete sospetti attendono invece una decisione esplicita;
|
|
130
139
|
la normale sequenza tool → risposta successiva continua senza un nuovo prompt.
|
|
131
140
|
|
package/extensions/index.ts
CHANGED
|
@@ -599,6 +599,59 @@ export default function (pi: ExtensionAPI) {
|
|
|
599
599
|
});
|
|
600
600
|
pi.on("session_tree", async (_event, ctx) => { await startSession(ctx); });
|
|
601
601
|
|
|
602
|
+
/**
|
|
603
|
+
* Assicura gli overlay PRIMA di qualsiasi before_agent_start (evento input).
|
|
604
|
+
* Un'altra estensione (pi-accounts) legge il registry nel suo
|
|
605
|
+
* before_agent_start per decidere i modelli disponibili dell'account e,
|
|
606
|
+
* se il twin non c'è, arma l'abort del turno ("This operation was
|
|
607
|
+
* aborted" istantaneo su turn_start). Il seed precoce rende i twin
|
|
608
|
+
* visibili a quella lettura, indipendentemente dall'ordine di load.
|
|
609
|
+
* Silenzioso: nessuna entry diagnostica qui (l'input arriva a ogni
|
|
610
|
+
* prompt); la diagnostica resta nel reassert di before_agent_start.
|
|
611
|
+
* Vale in ogni modalità: anche in on-demand il twin passthrough ha
|
|
612
|
+
* bisogno dell'overlay registrato (altrimenti l'id __jev finisce all'API).
|
|
613
|
+
*/
|
|
614
|
+
function ensureOverlays(registry: ModelRegistry): void {
|
|
615
|
+
try {
|
|
616
|
+
const refs = twinRefs(config);
|
|
617
|
+
if (refs.length === 0) return;
|
|
618
|
+
// Ricuci gli overlay noti scalzati contro il provider live corrente.
|
|
619
|
+
reassertOverlays(registry);
|
|
620
|
+
// Registra ex-novo i provider gemellati senza overlay (seed precoce).
|
|
621
|
+
const byProvider = new Map<string, string[]>();
|
|
622
|
+
for (const ref of refs) {
|
|
623
|
+
if (overlays.get(ref.provider)?.twinIds.includes(ref.model)) continue;
|
|
624
|
+
const list = byProvider.get(ref.provider) ?? [];
|
|
625
|
+
if (!list.includes(ref.model)) list.push(ref.model);
|
|
626
|
+
byProvider.set(ref.provider, list);
|
|
627
|
+
}
|
|
628
|
+
for (const [providerId, twinIds] of byProvider) {
|
|
629
|
+
let live: Provider | undefined;
|
|
630
|
+
try {
|
|
631
|
+
live = registry.getProvider(providerId);
|
|
632
|
+
} catch {
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
if (!live) continue;
|
|
636
|
+
const models = live.getModels();
|
|
637
|
+
if (!twinIds.every((id) => models.some((m) => m.id === id && !isTwinId(m.id)))) {
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
try {
|
|
641
|
+
registerOverlay(providerId, live, twinIds);
|
|
642
|
+
} catch {
|
|
643
|
+
// Riprova al prossimo hook; mai bloccare l'input.
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
} catch {
|
|
647
|
+
// Mai bloccare l'input per il seed.
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
pi.on("input", async (_event, ctx) => {
|
|
652
|
+
ensureOverlays(ctx.modelRegistry);
|
|
653
|
+
});
|
|
654
|
+
|
|
602
655
|
// Prima di ogni turno: se un'altra estensione ci ha scalzati dal provider,
|
|
603
656
|
// rimettiamo l'overlay (altrimenti l'id __jev arriverebbe all'API).
|
|
604
657
|
function noteReassert(fixed: string[]): void {
|
package/package.json
CHANGED