- Workflow n8n tdfInZns7cqo8fU2 actif (15 min): snapshot HA compact -> prompt FR -> LLM local Spark (modèle dynamique via /v1/models) avec fallback OpenRouter claude-haiku-4.5 (credential chiffré, clé hors git) -> validation stricte (enums, bornes, rejet total si invalide) -> helpers advisor_* + divergence + compteurs accord/divergence + logbook. - GARANTIE OMBRE structurelle: écritures limitées à advisor_*/logbook, vérifiée par tests/advisor/run.mjs (16 tests, bloquants au push). - Kill-switch input_boolean.evcs_advisor_enabled. - Extension R2 multi-workflows (lib-node-map WORKFLOWS[], build/extract/push par fichier, n8n-create.mjs, gen-advisor-workflow.mjs). - Helpers HA via package NFS + carte dashboard EVCS Master (backup fait). - 1re reco réelle: auto_solar_plus, cible 35%, accord avec le réel. - Fix sécurité n8n-push: plus de fallback d'id implicite vers le workflow EVCS.
59 lines
2.4 KiB
JavaScript
59 lines
2.4 KiB
JavaScript
// R2 — Cartographie src/ ↔ workflows JSON (source de vérité : src/).
|
|
// Multi-workflows depuis l'Advisor (08/2026).
|
|
// Utilisé par tools/n8n-extract.mjs (JSON → src) et tools/n8n-build.mjs (src → JSON).
|
|
|
|
export const WORKFLOWS = [
|
|
{
|
|
id: 'evcs',
|
|
workflowFile: 'workflows/evcs-surplus-controller-v2.6.json',
|
|
srcDir: 'src/nodes',
|
|
nodes: [
|
|
{ file: 'INPUT_PARSE.js', node: 'INPUT_PARSE', kind: 'jsCode' },
|
|
{ file: 'WINDOWS_SOURCEV2.js', node: 'WINDOWS_SOURCEV2', kind: 'jsCode' },
|
|
{ file: 'BATTERY_CLOUD_LOCKS.js', node: 'BATTERY_CLOUD_LOCKS', kind: 'jsCode' },
|
|
{ file: 'DECISION_ENGINEV2.js', node: 'DECISION_ENGINEV2', kind: 'jsCode' },
|
|
{ file: 'HA_SERVICE_CALLS_OUTPUT.js', node: 'HA_SERVICE_CALLS_OUTPUT', kind: 'jsCode' },
|
|
{ file: 'BUILD_ACTIONS.js', node: 'Build EVCS Surplus Controller V2.0 Actions', kind: 'jsCode' },
|
|
{ file: 'HA_SNAPSHOT_TEMPLATE.json.tpl', node: 'HA Snapshot EVCS Surplus Controller V2.2', kind: 'template' },
|
|
],
|
|
},
|
|
{
|
|
id: 'advisor',
|
|
workflowFile: 'workflows/evcs-advisor-shadow-v1.json',
|
|
srcDir: 'src/advisor',
|
|
nodes: [
|
|
{ file: 'BUILD_PROMPT.js', node: 'BUILD_PROMPT', kind: 'jsCode' },
|
|
{ file: 'VALIDATE_PARSE.js', node: 'VALIDATE_PARSE', kind: 'jsCode' },
|
|
{ file: 'BUILD_HA_CALLS.js', node: 'BUILD_HA_CALLS', kind: 'jsCode' },
|
|
{ file: 'HA_SNAPSHOT_TEMPLATE.json.tpl', node: 'HA Snapshot Advisor', kind: 'template' },
|
|
],
|
|
},
|
|
];
|
|
|
|
// Rétro-compatibilité (outils historiques mono-workflow)
|
|
export const WORKFLOW_FILE = WORKFLOWS[0].workflowFile;
|
|
export const SRC_DIR = WORKFLOWS[0].srcDir;
|
|
export const NODE_MAP = WORKFLOWS[0].nodes;
|
|
|
|
export function getCode(workflowNode, kind) {
|
|
if (kind === 'jsCode') return workflowNode.parameters.jsCode;
|
|
if (kind === 'template') {
|
|
return workflowNode.parameters.bodyParameters.parameters.find(p => p.name === 'template').value;
|
|
}
|
|
throw new Error(`kind inconnu: ${kind}`);
|
|
}
|
|
|
|
export function setCode(workflowNode, kind, code) {
|
|
if (kind === 'jsCode') { workflowNode.parameters.jsCode = code; return; }
|
|
if (kind === 'template') {
|
|
workflowNode.parameters.bodyParameters.parameters.find(p => p.name === 'template').value = code;
|
|
return;
|
|
}
|
|
throw new Error(`kind inconnu: ${kind}`);
|
|
}
|
|
|
|
export function findWorkflowByFile(inputPath) {
|
|
const base = inputPath.replace(/\\/g, '/').split('/').pop();
|
|
return WORKFLOWS.find(w => w.workflowFile.endsWith(base));
|
|
}
|