Spaces:
Sleeping
Sleeping
| // S526 — estratto da agentLoop.ts: Step4/7/8/S127 context hints group | |
| // Raccoglie in un solo posto i 4 hint sincroni che popolano il system prompt. | |
| import { suggestRecipe } from "../skillRecipes"; | |
| export interface ContextHints { | |
| strategyHint: string; | |
| knowledgeRules: string; | |
| userModelCtx: string; | |
| skillHint: string; | |
| recipeHint: string; // S-RECIPE: ricetta confermata per il task corrente | |
| } | |
| export interface ContextHintsDeps { | |
| selfLearning: { | |
| getStrategyFor: (q: string) => string | null | undefined; | |
| }; | |
| getKnowledgeRules: () => string; | |
| getUserModelContext: () => string; | |
| suggestPattern: (q: string) => string | null | undefined; | |
| } | |
| /** | |
| * S526/Step4+7+8+S127: carica i 4 context hints sincroni (strategy, knowledge, | |
| * user model, skill pattern). Tutti non-bloccanti: fallback "" su errore. | |
| */ | |
| export function loadContextHints( | |
| lastUserMsg: string, | |
| deps: ContextHintsDeps, | |
| ): ContextHints { | |
| const strategyHint = (() => { | |
| try { return deps.selfLearning.getStrategyFor(lastUserMsg) ?? ""; } | |
| catch { return ""; } | |
| })(); | |
| const knowledgeRules = (() => { | |
| try { return deps.getKnowledgeRules(); } catch { return ""; } | |
| })(); | |
| const userModelCtx = (() => { | |
| try { return deps.getUserModelContext(); } catch { return ""; } | |
| })(); | |
| const skillHint = (() => { | |
| try { return deps.suggestPattern(lastUserMsg) ?? ""; } catch { return ""; } | |
| })(); | |
| // S-RECIPE: ricetta confermata ad alta confidenza | |
| const recipeHint = (() => { | |
| try { return suggestRecipe(lastUserMsg) ?? ""; } catch { return ""; } | |
| })(); | |
| return { strategyHint, knowledgeRules, userModelCtx, skillHint, recipeHint }; | |
| } | |