6efe86c07b
- Made PI_INTENT_TRACING, PI_AUTO_QA, PI_PY, and PI_JS take precedence when set. - Fell back to config when the env flag is unset instead of ORing. - Surfaced PI_PY=0/PI_JS=0 in the disabled-backend error messages.
28 lines
815 B
TypeScript
28 lines
815 B
TypeScript
import { $flag } from "@oh-my-pi/pi-utils";
|
|
import type { ToolSession } from ".";
|
|
|
|
export interface EvalBackendsAllowance {
|
|
python: boolean;
|
|
js: boolean;
|
|
}
|
|
|
|
/** Read per-backend allowance from settings (defaults true). */
|
|
export function readEvalBackendsAllowance(session: ToolSession): EvalBackendsAllowance {
|
|
return {
|
|
python: session.settings.get("eval.py") ?? true,
|
|
js: session.settings.get("eval.js") ?? true,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Materialize the active eval backend allowance: PI_PY / PI_JS env flags
|
|
* override the per-key settings; otherwise settings (defaults true) win.
|
|
*/
|
|
export function resolveEvalBackends(session: ToolSession): EvalBackendsAllowance {
|
|
const settings = readEvalBackendsAllowance(session);
|
|
return {
|
|
python: $flag("PI_PY", settings.python),
|
|
js: $flag("PI_JS", settings.js),
|
|
};
|
|
}
|