@arcadialdev/arcality 3.0.1 → 3.0.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 +12 -6
- package/bin/arcality.mjs +9 -8
- package/package.json +2 -1
- package/playwright.config.js +18 -16
- package/public/ArcalityImagen.png +0 -0
- package/public/logo-arcadial-blanco.png +0 -0
- package/public/logo.png +0 -0
- package/scripts/arcality-logs.mjs +167 -93
- package/scripts/gen-and-run.mjs +1706 -1158
- package/scripts/init.mjs +55 -19
- package/scripts/rebrand-report.mjs +16 -2
- package/scripts/setup.mjs +120 -166
- package/src/KnowledgeService.ts +29 -20
- package/src/arcalityClient.mjs +33 -63
- package/src/configLoader.mjs +35 -39
- package/src/configManager.mjs +48 -39
- package/src/playwrightAssets.mjs +27 -0
- package/src/services/collectiveMemoryService.ts +37 -26
- package/tests/_helpers/ArcalityReporter.js +1240 -712
- package/tests/_helpers/agentic-runner.bundle.spec.js +213 -140
package/scripts/init.mjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// scripts/init.mjs — Command: arcality init
|
|
3
3
|
// Single-configuration setup flow:
|
|
4
4
|
// 1. Prompt API key → validate with backend
|
|
5
|
-
// 2. Prompt project name, baseUrl, username, password
|
|
5
|
+
// 2. Prompt project name, baseUrl, username, password
|
|
6
6
|
// 3. Detect framework (package.json only, NO .git)
|
|
7
7
|
// 4. Create project via POST /api/v1/projects
|
|
8
|
-
// 5. Write arcality.config
|
|
8
|
+
// 5. Write arcality.config
|
|
9
9
|
|
|
10
10
|
import 'dotenv/config';
|
|
11
11
|
import fs from 'node:fs';
|
|
@@ -18,8 +18,10 @@ import {
|
|
|
18
18
|
loadProjectConfig,
|
|
19
19
|
saveProjectConfig,
|
|
20
20
|
createConfig,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
isRealProjectId,
|
|
22
|
+
} from '../src/configManager.mjs';
|
|
23
|
+
import { getApiUrl } from '../src/configLoader.mjs';
|
|
24
|
+
import { installPlaywrightAssets, getPlaywrightInstallCommand } from '../src/playwrightAssets.mjs';
|
|
23
25
|
|
|
24
26
|
const __filename = fileURLToPath(import.meta.url);
|
|
25
27
|
const __dirname = path.dirname(__filename);
|
|
@@ -271,21 +273,37 @@ async function main() {
|
|
|
271
273
|
// If response is HTML (e.g. Cloudflare 521), show a clean message
|
|
272
274
|
const isHtml = errText.trim().startsWith('<');
|
|
273
275
|
const displayError = isHtml
|
|
274
|
-
? `El servidor backend de Arcality no
|
|
276
|
+
? `El servidor backend de Arcality no esta disponible temporalmente (HTTP ${res.status}).`
|
|
275
277
|
: `HTTP ${res.status}: ${errText.slice(0, 200)}`;
|
|
276
278
|
|
|
277
|
-
sCreate.stop(chalk.
|
|
279
|
+
sCreate.stop(chalk.red(`No se pudo crear el proyecto en Arcality: ${displayError.replace(/El proyecto.*$/i, '').trim()}`));
|
|
278
280
|
// Don't exit — write the config with a local-only project ID so user can still run
|
|
279
|
-
|
|
281
|
+
note(
|
|
282
|
+
chalk.white('No se guardo arcality.config porque Arcality requiere un proyecto real conectado al backend.'),
|
|
283
|
+
'Configuracion detenida'
|
|
284
|
+
);
|
|
285
|
+
process.exit(1);
|
|
280
286
|
} else {
|
|
281
287
|
const created = await res.json();
|
|
282
|
-
projectId = created.id || created.Id;
|
|
288
|
+
projectId = created.id || created.Id;
|
|
289
|
+
if (!isRealProjectId(projectId)) {
|
|
290
|
+
sCreate.stop(chalk.red('El backend no devolvio un Project ID valido.'));
|
|
291
|
+
note(
|
|
292
|
+
chalk.white('No se guardo arcality.config. Toda instancia de Arcality debe estar ligada a un proyecto real.'),
|
|
293
|
+
'Configuracion detenida'
|
|
294
|
+
);
|
|
295
|
+
process.exit(1);
|
|
296
|
+
}
|
|
283
297
|
organizationId = organizationId || created.organizationId || created.organization_id || null;
|
|
284
298
|
sCreate.stop(chalk.green(`✅ Proyecto creado: "${projectName.trim()}" (${projectId})`));
|
|
285
299
|
}
|
|
286
300
|
} catch (err) {
|
|
287
|
-
sCreate.stop(chalk.
|
|
288
|
-
|
|
301
|
+
sCreate.stop(chalk.red(`No se pudo conectar con el servidor de Arcality: ${err.message}`));
|
|
302
|
+
note(
|
|
303
|
+
chalk.white('No se guardo arcality.config porque la herramienta no funciona en modo offline/local.'),
|
|
304
|
+
'Configuracion detenida'
|
|
305
|
+
);
|
|
306
|
+
process.exit(1);
|
|
289
307
|
}
|
|
290
308
|
|
|
291
309
|
// ── Step 6: Write arcality.config ──
|
|
@@ -293,15 +311,32 @@ async function main() {
|
|
|
293
311
|
apiKey: apiKey.trim(),
|
|
294
312
|
organizationId,
|
|
295
313
|
projectId,
|
|
296
|
-
projectName: projectName.trim(),
|
|
297
|
-
baseUrl: baseUrl.trim(),
|
|
298
|
-
frameworkDetected,
|
|
299
|
-
username: username.trim(),
|
|
300
|
-
password,
|
|
301
|
-
arcalityVersion: version,
|
|
302
|
-
});
|
|
314
|
+
projectName: projectName.trim(),
|
|
315
|
+
baseUrl: baseUrl.trim(),
|
|
316
|
+
frameworkDetected,
|
|
317
|
+
username: username.trim(),
|
|
318
|
+
password,
|
|
319
|
+
arcalityVersion: version,
|
|
320
|
+
});
|
|
303
321
|
|
|
304
|
-
saveProjectConfig(config, projectRoot);
|
|
322
|
+
saveProjectConfig(config, projectRoot);
|
|
323
|
+
|
|
324
|
+
const sPlaywright = spinner();
|
|
325
|
+
sPlaywright.start('Preparando navegador de pruebas (Chromium + ffmpeg)...');
|
|
326
|
+
let playwrightReady = true;
|
|
327
|
+
|
|
328
|
+
try {
|
|
329
|
+
await installPlaywrightAssets({ cwd: PACKAGE_ROOT });
|
|
330
|
+
sPlaywright.stop(chalk.green('Playwright listo para ejecutar misiones'));
|
|
331
|
+
} catch (err) {
|
|
332
|
+
playwrightReady = false;
|
|
333
|
+
sPlaywright.stop(chalk.yellow(`No se pudieron instalar los assets de Playwright: ${err.message}`));
|
|
334
|
+
note(
|
|
335
|
+
chalk.white('La configuracion del proyecto ya fue guardada, pero antes de la primera mision ejecuta:') + '\n\n' +
|
|
336
|
+
chalk.cyan(getPlaywrightInstallCommand()),
|
|
337
|
+
'Accion Manual Requerida'
|
|
338
|
+
);
|
|
339
|
+
}
|
|
305
340
|
|
|
306
341
|
// ── Step 7: Custom QA Context ──
|
|
307
342
|
note(
|
|
@@ -369,7 +404,8 @@ Los bullets que empiecen con "Ejemplo:" se ignoran hasta que los reemplaces.
|
|
|
369
404
|
chalk.bold.white(' URL Base: ') + chalk.cyan(config.project.baseUrl) + '\n' +
|
|
370
405
|
chalk.bold.white(' Framework: ') + chalk.magenta(config.project.frameworkDetected || 'N/A') + '\n' +
|
|
371
406
|
chalk.bold.white(' ID del Proyecto: ') + chalk.gray(config.projectId) + '\n' +
|
|
372
|
-
chalk.bold.white(' Carpeta de Misiones: ') + chalk.yellow(config.runtime.yamlOutputDir)
|
|
407
|
+
chalk.bold.white(' Carpeta de Misiones: ') + chalk.yellow(config.runtime.yamlOutputDir) + '\n' +
|
|
408
|
+
chalk.bold.white(' Playwright: ') + (playwrightReady ? chalk.green('listo') : chalk.yellow('pendiente de instalacion manual')),
|
|
373
409
|
'Configuración Guardada'
|
|
374
410
|
);
|
|
375
411
|
|
|
@@ -52,8 +52,22 @@ function processDirectory(reportDir, logoBase64) {
|
|
|
52
52
|
html = html.replace(/at\s+.*?node_modules.*?(\n|\r)/g, '');
|
|
53
53
|
html = html.replace(/at\s+.*?agentic-runner\.spec\.ts:\d+/g, '');
|
|
54
54
|
|
|
55
|
-
// 3.
|
|
56
|
-
|
|
55
|
+
// 3. Preserve custom Arcality reports before native Playwright styling.
|
|
56
|
+
// The custom Arcality report owns its visual system. Keep the
|
|
57
|
+
// aggressive Playwright rebrand injection for native reports only.
|
|
58
|
+
const isArcalityMissionConsole = html.includes('class="mission-brief"') || html.includes('Arcality QA Engine');
|
|
59
|
+
if (isArcalityMissionConsole) {
|
|
60
|
+
if (logoBase64) {
|
|
61
|
+
html = html.replace(/rel="shortcut icon" href=".*?"/g, `rel="shortcut icon" href="${logoBase64}"`);
|
|
62
|
+
html = html.replace(/rel="icon" href=".*?"/g, `rel="icon" href="${logoBase64}"`);
|
|
63
|
+
}
|
|
64
|
+
fs.writeFileSync(indexPath, html, 'utf8');
|
|
65
|
+
processTraceViewer(reportDir, logoBase64);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 4. Inyección de Estilos y Scripts (MODO AGRESIVO)
|
|
70
|
+
const customStyles = `
|
|
57
71
|
<script id="arcality-branding-script">
|
|
58
72
|
/* ARCALITY_BRANDING_SCRIPT */
|
|
59
73
|
// 1. Limpieza de Caché y Service Worker
|
package/scripts/setup.mjs
CHANGED
|
@@ -1,166 +1,120 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// scripts/setup.mjs
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import fs from 'node:fs';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import os from 'node:os';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
const CONFIG_DIR = path.join(os.homedir(), '.arcality');
|
|
12
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.log(
|
|
49
|
-
console.log('
|
|
50
|
-
console.log(
|
|
51
|
-
console.log('
|
|
52
|
-
console.log('');
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
console.log('');
|
|
106
|
-
console.log('
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
child.on('error', reject);
|
|
122
|
-
});
|
|
123
|
-
console.log('');
|
|
124
|
-
console.log(' ✅ Chromium instalado correctamente');
|
|
125
|
-
} catch (err) {
|
|
126
|
-
console.log('');
|
|
127
|
-
console.log(` ⚠️ No se pudo instalar Chromium automáticamente: ${err.message}`);
|
|
128
|
-
console.log(' Puedes instalarlo manualmente ejecutando:');
|
|
129
|
-
console.log(' npx playwright install chromium');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// ─── Paso 3: Crear .env si no existe ───
|
|
133
|
-
const envFile = path.join(PACKAGE_ROOT, '.env');
|
|
134
|
-
const envExample = path.join(PACKAGE_ROOT, '.env.example');
|
|
135
|
-
|
|
136
|
-
if (!fs.existsSync(envFile) && fs.existsSync(envExample)) {
|
|
137
|
-
let content = fs.readFileSync(envExample, 'utf8');
|
|
138
|
-
|
|
139
|
-
// Inyectar la API Key
|
|
140
|
-
if (config.api_key) {
|
|
141
|
-
content = content.replace('ARCALITY_API_KEY=', `ARCALITY_API_KEY=${config.api_key}`);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
fs.writeFileSync(envFile, content, 'utf8');
|
|
145
|
-
console.log(' ✅ .env creado desde .env.example');
|
|
146
|
-
} else if (fs.existsSync(envFile)) {
|
|
147
|
-
console.log(' ✅ .env existente (sin modificar)');
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// ─── Resumen final ───
|
|
151
|
-
console.log('');
|
|
152
|
-
console.log(' ╔══════════════════════════════════════════╗');
|
|
153
|
-
console.log(' ║ ✅ SETUP COMPLETADO ║');
|
|
154
|
-
console.log(' ╚══════════════════════════════════════════╝');
|
|
155
|
-
console.log('');
|
|
156
|
-
console.log(' Para empezar, ejecuta:');
|
|
157
|
-
console.log('');
|
|
158
|
-
console.log(' arcality → Menú interactivo');
|
|
159
|
-
console.log(' arcality --agent "tu misión" → Ejecución directa');
|
|
160
|
-
console.log('');
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
main().catch(err => {
|
|
164
|
-
console.error(' ❌ Error durante setup:', err.message);
|
|
165
|
-
process.exit(1);
|
|
166
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// scripts/setup.mjs - Command: arcality setup
|
|
3
|
+
// Prepares the local machine for Arcality. Project configuration lives in `arcality init`.
|
|
4
|
+
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { installPlaywrightAssets, getPlaywrightInstallCommand } from '../src/playwrightAssets.mjs';
|
|
10
|
+
|
|
11
|
+
const CONFIG_DIR = path.join(os.homedir(), '.arcality');
|
|
12
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
13
|
+
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = path.dirname(__filename);
|
|
16
|
+
const PACKAGE_ROOT = process.env.ARCALITY_ROOT || path.resolve(__dirname, '..');
|
|
17
|
+
|
|
18
|
+
function loadConfig() {
|
|
19
|
+
try {
|
|
20
|
+
if (!fs.existsSync(CONFIG_FILE)) return {};
|
|
21
|
+
let raw = fs.readFileSync(CONFIG_FILE, 'utf8');
|
|
22
|
+
if (raw.charCodeAt(0) === 0xFEFF) raw = raw.slice(1);
|
|
23
|
+
return JSON.parse(raw);
|
|
24
|
+
} catch {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function saveConfig(config) {
|
|
30
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
31
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
32
|
+
}
|
|
33
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf8');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getVersion() {
|
|
37
|
+
try {
|
|
38
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8'));
|
|
39
|
+
return pkg.version || 'unknown';
|
|
40
|
+
} catch {
|
|
41
|
+
return 'unknown';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function printHeader(version) {
|
|
46
|
+
console.log('');
|
|
47
|
+
console.log(' ARCALITY SETUP');
|
|
48
|
+
console.log(` Version: ${version}`);
|
|
49
|
+
console.log('');
|
|
50
|
+
console.log(' Este comando prepara la maquina local para ejecutar misiones.');
|
|
51
|
+
console.log(' La configuracion del proyecto se hace con: arcality init');
|
|
52
|
+
console.log('');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function main() {
|
|
56
|
+
const version = getVersion();
|
|
57
|
+
printHeader(version);
|
|
58
|
+
|
|
59
|
+
const config = loadConfig();
|
|
60
|
+
const removedLegacyKeys = [];
|
|
61
|
+
|
|
62
|
+
if (config.anthropic_api_key) {
|
|
63
|
+
delete config.anthropic_api_key;
|
|
64
|
+
removedLegacyKeys.push('anthropic_api_key');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (config.model) {
|
|
68
|
+
delete config.model;
|
|
69
|
+
removedLegacyKeys.push('model');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
config.version = version;
|
|
73
|
+
config.setup_at = new Date().toISOString();
|
|
74
|
+
saveConfig(config);
|
|
75
|
+
|
|
76
|
+
console.log(' [1/3] Configuracion global revisada.');
|
|
77
|
+
if (removedLegacyKeys.length > 0) {
|
|
78
|
+
console.log(` Se removio configuracion legacy no usada: ${removedLegacyKeys.join(', ')}`);
|
|
79
|
+
} else {
|
|
80
|
+
console.log(' No se requiere ninguna llave de proveedor externo.');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.log('');
|
|
84
|
+
console.log(' [2/3] Instalando assets de Playwright: Chromium + ffmpeg');
|
|
85
|
+
console.log(' Esto evita fallos de primera ejecucion al abrir el navegador o grabar video.');
|
|
86
|
+
console.log('');
|
|
87
|
+
|
|
88
|
+
let playwrightReady = false;
|
|
89
|
+
try {
|
|
90
|
+
await installPlaywrightAssets({ cwd: PACKAGE_ROOT });
|
|
91
|
+
playwrightReady = true;
|
|
92
|
+
console.log('');
|
|
93
|
+
console.log(' Playwright listo.');
|
|
94
|
+
} catch (err) {
|
|
95
|
+
console.log('');
|
|
96
|
+
console.log(` No se pudieron instalar los assets automaticamente: ${err.message}`);
|
|
97
|
+
console.log(' Ejecuta manualmente:');
|
|
98
|
+
console.log(` ${getPlaywrightInstallCommand()}`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
console.log('');
|
|
102
|
+
console.log(' [3/3] Siguientes pasos');
|
|
103
|
+
console.log(' En cada proyecto donde uses Arcality:');
|
|
104
|
+
console.log(' 1. arcality init');
|
|
105
|
+
console.log(' 2. arcality run');
|
|
106
|
+
console.log('');
|
|
107
|
+
|
|
108
|
+
if (!playwrightReady) {
|
|
109
|
+
console.log(' Setup finalizado con accion manual pendiente.');
|
|
110
|
+
process.exitCode = 1;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
console.log(' Setup completado correctamente.');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
main().catch(err => {
|
|
118
|
+
console.error(' Error durante setup:', err.message);
|
|
119
|
+
process.exit(1);
|
|
120
|
+
});
|
package/src/KnowledgeService.ts
CHANGED
|
@@ -30,13 +30,22 @@ export interface PortalContextResponse {
|
|
|
30
30
|
fields: Array<{ field_identifier: string; field_type: string; is_required: boolean }>;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export interface ProjectDto {
|
|
34
|
-
id: string;
|
|
35
|
-
name: string;
|
|
36
|
-
base_url?: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
export interface ProjectDto {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
base_url?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isRealProjectId(projectId?: string | null): boolean {
|
|
40
|
+
const id = String(projectId || '').trim();
|
|
41
|
+
if (!id) return false;
|
|
42
|
+
if (id === 'undefined' || id === 'null') return false;
|
|
43
|
+
if (/^(local|mock)_/i.test(id)) return false;
|
|
44
|
+
if (/^0{8}-0{4}-0{4}-0{4}-0{12}$/i.test(id)) return false;
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class KnowledgeService {
|
|
40
49
|
private static instance: KnowledgeService;
|
|
41
50
|
private apiBase: string;
|
|
42
51
|
private apiKey: string;
|
|
@@ -80,10 +89,10 @@ export class KnowledgeService {
|
|
|
80
89
|
}
|
|
81
90
|
|
|
82
91
|
public getProjectId(): string | null {
|
|
83
|
-
if (!this.projectId
|
|
84
|
-
this.projectId = process.env.ARCALITY_PROJECT_ID || null;
|
|
85
|
-
}
|
|
86
|
-
return this.projectId;
|
|
92
|
+
if (!isRealProjectId(this.projectId)) {
|
|
93
|
+
this.projectId = process.env.ARCALITY_PROJECT_ID || null;
|
|
94
|
+
}
|
|
95
|
+
return isRealProjectId(this.projectId) ? this.projectId : null;
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
/**
|
|
@@ -98,7 +107,7 @@ export class KnowledgeService {
|
|
|
98
107
|
const data = await res.json();
|
|
99
108
|
return data.projects || [];
|
|
100
109
|
} catch (e: any) {
|
|
101
|
-
console.warn(chalk.yellow(`[KnowledgeService] Error al obtener proyectos: ${e.message}`));
|
|
110
|
+
if (process.env.DEBUG) console.warn(chalk.yellow(`[KnowledgeService] Error al obtener proyectos: ${e.message}`));
|
|
102
111
|
return [];
|
|
103
112
|
}
|
|
104
113
|
}
|
|
@@ -116,7 +125,7 @@ export class KnowledgeService {
|
|
|
116
125
|
if (!res.ok) return null;
|
|
117
126
|
return await res.json();
|
|
118
127
|
} catch (e: any) {
|
|
119
|
-
console.error(chalk.red(`[KnowledgeService] Falló creación de proyecto: ${e.message}`));
|
|
128
|
+
if (process.env.DEBUG) console.error(chalk.red(`[KnowledgeService] Falló creación de proyecto: ${e.message}`));
|
|
120
129
|
return null;
|
|
121
130
|
}
|
|
122
131
|
}
|
|
@@ -125,8 +134,8 @@ export class KnowledgeService {
|
|
|
125
134
|
* 2. Ingesta (Post-Percept)
|
|
126
135
|
*/
|
|
127
136
|
public async ingest(payload: PortalIngestRequest): Promise<void> {
|
|
128
|
-
if (!payload.project_id
|
|
129
|
-
console.warn(chalk.yellow(`[Knowledge] Ingesta cancelada: project_id es inválido.`));
|
|
137
|
+
if (!isRealProjectId(payload.project_id)) {
|
|
138
|
+
if (process.env.DEBUG) console.warn(chalk.yellow(`[Knowledge] Ingesta cancelada: project_id es inválido.`));
|
|
130
139
|
return;
|
|
131
140
|
}
|
|
132
141
|
|
|
@@ -148,7 +157,7 @@ export class KnowledgeService {
|
|
|
148
157
|
}
|
|
149
158
|
}
|
|
150
159
|
} catch (e: any) {
|
|
151
|
-
console.warn(chalk.yellow(`[Knowledge] Error en ingesta: ${e.message}`));
|
|
160
|
+
if (process.env.DEBUG) console.warn(chalk.yellow(`[Knowledge] Error en ingesta: ${e.message}`));
|
|
152
161
|
}
|
|
153
162
|
}
|
|
154
163
|
|
|
@@ -170,7 +179,7 @@ export class KnowledgeService {
|
|
|
170
179
|
if (!res.ok) return null;
|
|
171
180
|
return await res.json();
|
|
172
181
|
} catch (e: any) {
|
|
173
|
-
console.warn(chalk.yellow(`[Knowledge] Error al obtener contexto: ${e.message}`));
|
|
182
|
+
if (process.env.DEBUG) console.warn(chalk.yellow(`[Knowledge] Error al obtener contexto: ${e.message}`));
|
|
174
183
|
return null;
|
|
175
184
|
}
|
|
176
185
|
}
|
|
@@ -198,7 +207,7 @@ export class KnowledgeService {
|
|
|
198
207
|
severity
|
|
199
208
|
})
|
|
200
209
|
});
|
|
201
|
-
console.log(chalk.green(`[Knowledge] Nueva regla registrada: ${title}`));
|
|
210
|
+
if (process.env.DEBUG) console.log(chalk.green(`[Knowledge] Nueva regla registrada: ${title}`));
|
|
202
211
|
} catch (e) { }
|
|
203
212
|
}
|
|
204
213
|
|
|
@@ -224,7 +233,7 @@ export class KnowledgeService {
|
|
|
224
233
|
source: "agent_auto"
|
|
225
234
|
})
|
|
226
235
|
});
|
|
227
|
-
console.log(chalk.green(`[Knowledge] Nuevo campo catalogado: ${identifier}`));
|
|
236
|
+
if (process.env.DEBUG) console.log(chalk.green(`[Knowledge] Nuevo campo catalogado: ${identifier}`));
|
|
228
237
|
} catch (e) { }
|
|
229
238
|
}
|
|
230
239
|
|
|
@@ -250,7 +259,7 @@ export class KnowledgeService {
|
|
|
250
259
|
source: "agent_auto"
|
|
251
260
|
})
|
|
252
261
|
});
|
|
253
|
-
console.log(chalk.green(`[Knowledge] Nuevo conocimiento guardado: ${title}`));
|
|
262
|
+
if (process.env.DEBUG) console.log(chalk.green(`[Knowledge] Nuevo conocimiento guardado: ${title}`));
|
|
254
263
|
} catch (e) { }
|
|
255
264
|
}
|
|
256
265
|
|