feat(runtime): forward Flynn prompt to pi and harden backend mode commands

This commit is contained in:
William Valentin
2026-02-24 10:41:27 -08:00
parent 4188c68130
commit 2e192ef407
9 changed files with 305 additions and 6 deletions
+22 -1
View File
@@ -155,6 +155,9 @@ function shouldForceNativeForCapabilityQuery(text: string): boolean {
|| normalized.includes('tool list')
|| normalized.includes('list tools')
|| normalized.includes('what can you do')
|| normalized.includes('full access')
|| normalized.includes('do you have access')
|| normalized.includes('what access')
) {
return true;
}
@@ -163,6 +166,7 @@ function shouldForceNativeForCapabilityQuery(text: string): boolean {
|| /\b(?:what|which)\s+tools?\b/.test(normalized)
|| /\btools?\s+(?:do\s+you\s+have|are\s+available)\b/.test(normalized)
|| /\b(?:show|list|what\s+are)\s+(?:your\s+)?capabilities\b/.test(normalized)
|| /\bdo\s+you\s+have\s+(?:full\s+)?access\b/.test(normalized)
);
}
@@ -181,6 +185,9 @@ function shouldForceNativeForPiNoTools(text: string): boolean {
return (
/\b(?:run|execute)\s+(?:a\s+)?(?:shell|bash|command)\b/.test(normalized)
|| /\b(?:run|execute)\s+(?:a\s+)?(?:quick\s+)?check\b/.test(normalized)
|| /\b(?:quick\s+)?check\s+(?:access|status|logs?|health|config|setup)\b/.test(normalized)
|| /\b(?:verify|confirm)\s+(?:access|setup|status|config)\b/.test(normalized)
|| /\b(?:read|open|show|edit|write|patch|delete|list)\s+(?:the\s+)?(?:file|files|directory|repo|code)\b/.test(normalized)
|| /\b(?:search|fetch|browse|scrape)\s+(?:the\s+)?(?:web|internet|url|site)\b/.test(normalized)
|| /\b(?:use|call)\s+(?:a\s+)?tool\b/.test(normalized)
@@ -1197,7 +1204,11 @@ export function createMessageRouter(deps: {
},
backendCommand: (inputRaw: string) => {
const normalized = inputRaw.trim().toLowerCase();
let normalized = inputRaw.trim().toLowerCase();
// Accept both subcommand-only input ("status") and accidental full-command
// input ("/runtime status", "runtime status", "/backend status").
normalized = normalized.replace(/^(?:\/)?(?:runtime|backend)\b/, '').trim();
normalized = normalized.replace(/^\//, '').trim();
if (!normalized || normalized === 'status' || normalized === 'show') {
return formatBackendStatusLine(agent.getModelTier());
}
@@ -1245,6 +1256,12 @@ export function createMessageRouter(deps: {
return [
'Usage:',
'/runtime status',
'/runtime activate pi',
'/runtime deactivate pi',
'/runtime use config',
'',
'Alias:',
'/backend status',
'/backend activate pi',
'/backend deactivate pi',
@@ -1563,9 +1580,13 @@ export function createMessageRouter(deps: {
try {
const history = toExternalHistory(session.getHistory());
session.addMessage({ role: 'user', content: messageText });
const externalSystemPrompt = requestedBackend === 'pi_embedded'
? agent.getSystemPrompt(messageText)
: undefined;
const response = await selectedBackend.process({
prompt: messageText,
history,
...(externalSystemPrompt ? { systemPrompt: externalSystemPrompt } : {}),
});
auditLogger?.backendSuccess?.({
session_id: sessionIdForAudit,