@meiti/healer-sdk 0.0.0-stage → 0.3.0
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/LICENSE +21 -0
- package/README.md +175 -2
- package/dist/aplicar.d.ts +30 -0
- package/dist/aplicar.js +79 -0
- package/dist/client.d.ts +51 -0
- package/dist/client.js +125 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2 -0
- package/dist/types.d.ts +281 -0
- package/dist/types.js +7 -0
- package/package.json +38 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MEITI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,176 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @meiti/healer-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The official SDK for [Healer](https://meiti.dev/healer). A thin layer over the REST API: send code, wait for
|
|
4
|
+
the result. Polling, authentication and error handling live here, not in your integration.
|
|
5
|
+
|
|
6
|
+
Healer runs your tests in an isolated sandbox, repairs what fails, and only returns changes that leave the
|
|
7
|
+
code better. Never worse.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @meiti/healer-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Node 18 or later. No dependencies.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { HealerClient } from '@meiti/healer-sdk';
|
|
19
|
+
|
|
20
|
+
const healer = new HealerClient({ apiKey: process.env.HEALER_API_KEY! });
|
|
21
|
+
|
|
22
|
+
const result = await healer.repair({
|
|
23
|
+
files: { 'index.ts': 'export const sum = (a: number, b: number) => a - b;' }
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
console.log(result.status); // "production_ready", "unresolved" or "unsupported_stack"
|
|
27
|
+
console.log(result.failures); // { found, fixed, remaining }
|
|
28
|
+
console.log(result.cobertura.stacks); // what was verified, e.g. ["javascript", "python"]
|
|
29
|
+
console.log(result.cobertura.lenguajes_no_cubiertos); // what was not, e.g. ["go"]
|
|
30
|
+
console.log(result.pentagono_report?.puntaje); // quality score 0-100, null if it did not run
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`repair()` sends the code, waits until the job finishes (polling on its own) and returns the final result.
|
|
34
|
+
Pass `{ onProgress }` as a second argument to follow the job while it runs.
|
|
35
|
+
|
|
36
|
+
Get an API key at [meiti.dev/healer](https://meiti.dev/healer).
|
|
37
|
+
|
|
38
|
+
## Apply the repair without overwriting your changes
|
|
39
|
+
|
|
40
|
+
Healer repairs a clone of your code exactly as you sent it. `aplicarReparacion` checks that your code is
|
|
41
|
+
still that same code (SHA-256 of each file) and replaces only the files Healer changed:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { HealerClient, aplicarReparacion, ErrorBaseModificada } from '@meiti/healer-sdk';
|
|
45
|
+
|
|
46
|
+
const result = await healer.repair({ files });
|
|
47
|
+
try {
|
|
48
|
+
const repaired = aplicarReparacion(currentFiles, result);
|
|
49
|
+
// write only result.changed_files to disk; everything else is identical
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (error instanceof ErrorBaseModificada) {
|
|
52
|
+
// Your code changed after you sent it: error.verificacion.modificados lists the files.
|
|
53
|
+
// Send it again, or apply at your own risk:
|
|
54
|
+
// aplicarReparacion(currentFiles, result, { forzar: true })
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Options:
|
|
60
|
+
|
|
61
|
+
- `{ incluirSoporte: false }` leaves out the support update (`support_updates`: dependency versions Healer
|
|
62
|
+
had to raise so the app runs on the current runtime) and applies only the bug repair.
|
|
63
|
+
- `{ archivos: ['src/a.ts'] }` applies only some of the changed files.
|
|
64
|
+
|
|
65
|
+
If Healer could not leave the code better, `result.files` is missing and your code stays the same (see
|
|
66
|
+
`bloqueado_por_regresion`).
|
|
67
|
+
|
|
68
|
+
### The report
|
|
69
|
+
|
|
70
|
+
Every finished result carries `report`: read it instead of guessing from `status`. It says what was fixed,
|
|
71
|
+
how many tests failed before and after (`numbers.tests_failing_before` / `tests_failing_after`), whether
|
|
72
|
+
your tests pass (`numbers.target_tests`: `pass`, `fail`, `did_not_run`, ...), and every pending item with
|
|
73
|
+
what it is, why it remained and what it needs (`pending[].what`, `why`, `needs`): a dependency to install,
|
|
74
|
+
problems already in files Healer did not touch, tests that could not run. Show it to the user.
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
const r = await healer.repair({ files });
|
|
78
|
+
console.log(r.report?.headline);
|
|
79
|
+
for (const p of r.report?.pending ?? []) console.log(`- ${p.what} Needs: ${p.needs}`);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Screen review
|
|
83
|
+
|
|
84
|
+
To only check what the pages of an app show (no repair, no AI), Healer starts the app in its sandbox and reads each page:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const r = await healer.reviewScreen({
|
|
88
|
+
files,
|
|
89
|
+
startCommand: 'npm start',
|
|
90
|
+
port: 3000,
|
|
91
|
+
pages: [{ path: '/', expect_page: { title_is: 'My App' }, expectations: [{ exists: 'Save' }, { not_exists: 'Delete all' }] }]
|
|
92
|
+
});
|
|
93
|
+
for (const p of r.pages) console.log(p.path, p.state, p.expectations.map((e) => e.answer));
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Each page comes back LOADED, DID NOT LOAD (with the reason) or NOT THE EXPECTED PAGE. On a page that did not load, a `not_exists` answers CANNOT PROVE, never a false yes.
|
|
97
|
+
|
|
98
|
+
### Partial delivery
|
|
99
|
+
|
|
100
|
+
When some failures were fixed and others remain, `status` stays `"unresolved"` but the result carries
|
|
101
|
+
`partial_fix: true` and the repaired files. Nothing was left worse, and what remains already failed in your
|
|
102
|
+
original code (`failures.remaining`). `aplicarReparacion` accepts it. If `suite_unverified` is true, the
|
|
103
|
+
full test suite could not be compared with the original: run it before applying.
|
|
104
|
+
|
|
105
|
+
Optionally, tell Healer what you kept. It stores only path fingerprints, never code:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
await healer.informarDecision(jobId, { aplicados: ['src/a.ts'], descartados: ['src/b.ts'] });
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Send the same app again (keep history)
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
const first = await healer.repair({ files, appId: 'my-app-123' });
|
|
115
|
+
// later, another version of the same app
|
|
116
|
+
const second = await healer.repair({ files: newFiles, appId: 'my-app-123' });
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Without `appId` the server generates one. Use `submitRepair()` if you need the `app_id` before the job ends.
|
|
120
|
+
|
|
121
|
+
## Real-use test (optional)
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
await healer.repair({
|
|
125
|
+
files,
|
|
126
|
+
appId: 'my-app-123',
|
|
127
|
+
testUsoReal: true,
|
|
128
|
+
appIntent: 'A to-do list: add, view, mark as done.',
|
|
129
|
+
startCommand: 'npm run dev',
|
|
130
|
+
port: 5173
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`startCommand` and `port` are declared once per `appId`. Later submissions of the same app inherit them.
|
|
135
|
+
|
|
136
|
+
## Low level: submit and poll yourself
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
const { job_id, app_id } = await healer.submitRepair({ files });
|
|
140
|
+
// later
|
|
141
|
+
const state = await healer.getRepair(job_id); // { status: "queued" | "running" } or the final result
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Errors
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
import { HealerApiError, HealerTimeoutError } from '@meiti/healer-sdk';
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
await healer.repair({ files });
|
|
151
|
+
} catch (error) {
|
|
152
|
+
if (error instanceof HealerApiError) {
|
|
153
|
+
console.error('Healer returned an error:', error.status, error.message);
|
|
154
|
+
} else if (error instanceof HealerTimeoutError) {
|
|
155
|
+
console.error('The job is taking long. Check it later with getRepair().');
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Client options
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
new HealerClient({
|
|
164
|
+
apiKey: '...',
|
|
165
|
+
baseUrl: 'https://healer-api.meiti.dev', // default: the public Healer instance
|
|
166
|
+
pollIntervalMs: 3000, // default
|
|
167
|
+
timeoutMs: 10 * 60 * 1000 // default: 10 minutes
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Also
|
|
172
|
+
|
|
173
|
+
- [GitHub Action](https://github.com/marketplace/actions/healer-meiti): Healer in CI.
|
|
174
|
+
- `npx @meiti/healer`: connect Healer to Claude Code and other MCP agents.
|
|
175
|
+
|
|
176
|
+
MIT License.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ResultadoReparacion } from './types.js';
|
|
2
|
+
export interface VerificacionBase {
|
|
3
|
+
/** true si tu app es exactamente la que se mandó a reparar. */
|
|
4
|
+
coincide: boolean;
|
|
5
|
+
/** Archivos que cambiaron desde que se mandó a reparar. */
|
|
6
|
+
modificados: string[];
|
|
7
|
+
/** Archivos que se mandaron y ya no están. */
|
|
8
|
+
faltantes: string[];
|
|
9
|
+
mensaje: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class ErrorBaseModificada extends Error {
|
|
12
|
+
verificacion: VerificacionBase;
|
|
13
|
+
constructor(verificacion: VerificacionBase);
|
|
14
|
+
}
|
|
15
|
+
/** Compara tu app actual ({ ruta: contenido }) con la huella del código que se mandó a reparar. */
|
|
16
|
+
export declare function verificarBase(archivosActuales: Record<string, string>, resultado: ResultadoReparacion): VerificacionBase;
|
|
17
|
+
/**
|
|
18
|
+
* Devuelve tu app con la reparación aplicada: reemplaza SOLO los archivos que Healer cambió
|
|
19
|
+
* (changed_files) y deja todos los demás exactamente como están. Si tu app ya no es la que se
|
|
20
|
+
* mandó, tira ErrorBaseModificada, salvo que pases { forzar: true } (bajo tu responsabilidad).
|
|
21
|
+
* Con { incluirSoporte: false } deja afuera la actualización de soporte (support_updates): se aplica
|
|
22
|
+
* solo la reparación del bug. Por defecto va todo junto, que es lo que Healer verificó.
|
|
23
|
+
* Con { archivos: [...] } aplica solo esos (de changed_files) y deja los demás como estaban: para cuando
|
|
24
|
+
* la persona aprueba algunos arreglos y otros no. Un archivo que Healer no cambió tira un error.
|
|
25
|
+
*/
|
|
26
|
+
export declare function aplicarReparacion(archivosActuales: Record<string, string>, resultado: ResultadoReparacion, opciones?: {
|
|
27
|
+
forzar?: boolean;
|
|
28
|
+
incluirSoporte?: boolean;
|
|
29
|
+
archivos?: string[];
|
|
30
|
+
}): Record<string, string>;
|
package/dist/aplicar.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
// 🔒 [LA BASE TIENE QUE COINCIDIR, 2026-10-07, mismo principio que MEITI con clonado_de_codigo_hash]
|
|
3
|
+
// Healer repara un CLON del código, tal como lo mandaste. La reparación solo es segura sobre ese
|
|
4
|
+
// mismo código: si después tocaste la app, aplicarla a ciegas puede pisar tus cambios ("reparé esto
|
|
5
|
+
// pero rompí lo otro"). Por eso cada resultado trae la huella (SHA-256) de cada archivo tal como
|
|
6
|
+
// llegó, y la lista exacta de archivos que Healer cambió. Antes de aplicar, se compara tu app actual
|
|
7
|
+
// con esa huella: si coincide, se reemplazan SOLO los archivos reparados y todo lo demás queda
|
|
8
|
+
// exactamente igual; si no, se avisa y no se aplica salvo que lo fuerces.
|
|
9
|
+
const sha256 = (texto) => createHash('sha256').update(texto, 'utf8').digest('hex');
|
|
10
|
+
export class ErrorBaseModificada extends Error {
|
|
11
|
+
verificacion;
|
|
12
|
+
constructor(verificacion) {
|
|
13
|
+
super(verificacion.mensaje);
|
|
14
|
+
this.verificacion = verificacion;
|
|
15
|
+
this.name = 'ErrorBaseModificada';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** Compara tu app actual ({ ruta: contenido }) con la huella del código que se mandó a reparar. */
|
|
19
|
+
export function verificarBase(archivosActuales, resultado) {
|
|
20
|
+
const base = resultado.base_hashes;
|
|
21
|
+
if (!base) {
|
|
22
|
+
return { coincide: false, modificados: [], faltantes: [], mensaje: 'This result has no fingerprint of the original code (base_hashes), so it cannot be verified.' };
|
|
23
|
+
}
|
|
24
|
+
const modificados = [];
|
|
25
|
+
const faltantes = [];
|
|
26
|
+
for (const [ruta, hash] of Object.entries(base)) {
|
|
27
|
+
const actual = archivosActuales[ruta];
|
|
28
|
+
if (actual === undefined)
|
|
29
|
+
faltantes.push(ruta);
|
|
30
|
+
else if (sha256(actual) !== hash)
|
|
31
|
+
modificados.push(ruta);
|
|
32
|
+
}
|
|
33
|
+
const coincide = modificados.length === 0 && faltantes.length === 0;
|
|
34
|
+
return {
|
|
35
|
+
coincide,
|
|
36
|
+
modificados,
|
|
37
|
+
faltantes,
|
|
38
|
+
mensaje: coincide
|
|
39
|
+
? 'Your code is exactly what was sent for repair: the repair can be applied.'
|
|
40
|
+
: `This code changed after it was sent for repair (${[...modificados, ...faltantes].slice(0, 5).join(', ')}${modificados.length + faltantes.length > 5 ? '…' : ''}). You can apply the repair at your own risk ({ forzar: true }), or send it again so it is checked against the current version.`
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Devuelve tu app con la reparación aplicada: reemplaza SOLO los archivos que Healer cambió
|
|
45
|
+
* (changed_files) y deja todos los demás exactamente como están. Si tu app ya no es la que se
|
|
46
|
+
* mandó, tira ErrorBaseModificada, salvo que pases { forzar: true } (bajo tu responsabilidad).
|
|
47
|
+
* Con { incluirSoporte: false } deja afuera la actualización de soporte (support_updates): se aplica
|
|
48
|
+
* solo la reparación del bug. Por defecto va todo junto, que es lo que Healer verificó.
|
|
49
|
+
* Con { archivos: [...] } aplica solo esos (de changed_files) y deja los demás como estaban: para cuando
|
|
50
|
+
* la persona aprueba algunos arreglos y otros no. Un archivo que Healer no cambió tira un error.
|
|
51
|
+
*/
|
|
52
|
+
export function aplicarReparacion(archivosActuales, resultado, opciones = {}) {
|
|
53
|
+
if (opciones.archivos?.length) {
|
|
54
|
+
const ajenos = opciones.archivos.filter((a) => !(resultado.changed_files ?? []).includes(a));
|
|
55
|
+
if (ajenos.length)
|
|
56
|
+
throw new Error(`These files are not among the ones Healer changed: ${ajenos.join(', ')}.`);
|
|
57
|
+
}
|
|
58
|
+
// 🧩 [2026-11-13] Una entrega parcial (partial_fix) también trae archivos, con status "unresolved". Antes
|
|
59
|
+
// esto la rechazaba y la Action de GitHub terminaba en "fallo inesperado" justo cuando había algo para entregar.
|
|
60
|
+
if ((resultado.status !== 'production_ready' && !resultado.partial_fix) || !resultado.files) {
|
|
61
|
+
throw new Error('This result has no repair to apply (only production_ready or a partial delivery return files).');
|
|
62
|
+
}
|
|
63
|
+
// Con una parte elegida, solo esos archivos tienen que seguir iguales: uno que se deja afuera no frena nada.
|
|
64
|
+
const aVerificar = opciones.archivos?.length
|
|
65
|
+
? { ...resultado, base_hashes: Object.fromEntries(Object.entries(resultado.base_hashes ?? {}).filter(([r]) => opciones.archivos.includes(r))) }
|
|
66
|
+
: resultado;
|
|
67
|
+
const verificacion = verificarBase(archivosActuales, aVerificar);
|
|
68
|
+
if (!verificacion.coincide && !opciones.forzar)
|
|
69
|
+
throw new ErrorBaseModificada(verificacion);
|
|
70
|
+
const salida = { ...archivosActuales };
|
|
71
|
+
const soporte = opciones.incluirSoporte === false ? resultado.support_updates ?? [] : [];
|
|
72
|
+
const elegidos = opciones.archivos?.length ? opciones.archivos : resultado.changed_files ?? [];
|
|
73
|
+
for (const ruta of elegidos.filter((r) => !soporte.includes(r))) {
|
|
74
|
+
const reparado = resultado.files[ruta];
|
|
75
|
+
if (reparado !== undefined)
|
|
76
|
+
salida[ruta] = reparado;
|
|
77
|
+
}
|
|
78
|
+
return salida;
|
|
79
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { EnvioAceptado, EstadoJob, ProgresoJob, ResultadoReparacion, SolicitudReparacion, ScreenReviewRequest, ScreenReviewResult } from './types.js';
|
|
2
|
+
export declare class HealerApiError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly body: unknown;
|
|
5
|
+
constructor(status: number, body: unknown);
|
|
6
|
+
}
|
|
7
|
+
export declare class HealerTimeoutError extends Error {
|
|
8
|
+
constructor(jobId: string, timeoutMs: number);
|
|
9
|
+
}
|
|
10
|
+
export interface HealerClientOptions {
|
|
11
|
+
apiKey: string;
|
|
12
|
+
/** Default: https://healer-api.meiti.dev (la instancia pública de Healer). */
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
/** Cada cuánto consulta el estado del job dentro de repair(). Default: 3000ms. */
|
|
15
|
+
pollIntervalMs?: number;
|
|
16
|
+
/** Cuánto espera repair() antes de tirar HealerTimeoutError. Default: 10 minutos. */
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class HealerClient {
|
|
20
|
+
private readonly apiKey;
|
|
21
|
+
private readonly baseUrl;
|
|
22
|
+
private readonly pollIntervalMs;
|
|
23
|
+
private readonly timeoutMs;
|
|
24
|
+
constructor(options: HealerClientOptions);
|
|
25
|
+
private pedir;
|
|
26
|
+
/** Envía el código y devuelve de inmediato { job_id, app_id, status: "queued" } — sin esperar
|
|
27
|
+
* a que termine. Usar junto a getRepair() para armar tu propio loop de consulta, o preferir
|
|
28
|
+
* repair() si alcanza con esperar el resultado final. */
|
|
29
|
+
submitRepair(request: SolicitudReparacion): Promise<EnvioAceptado>;
|
|
30
|
+
/** Un solo chequeo de estado — "queued"/"running" mientras corre, o el resultado final. */
|
|
31
|
+
getRepair(jobId: string): Promise<EstadoJob>;
|
|
32
|
+
/** Le cuenta a Healer qué archivos de su reparación se aplicaron y cuáles se dejaron afuera (desde 2026-11-11).
|
|
33
|
+
* Opcional: sirve para medir qué cambios valen la pena. Healer guarda solo huellas de las rutas, nunca código. */
|
|
34
|
+
informarDecision(jobId: string, decision: {
|
|
35
|
+
aplicados?: string[];
|
|
36
|
+
descartados?: string[];
|
|
37
|
+
}): Promise<{
|
|
38
|
+
ok: boolean;
|
|
39
|
+
registrados: number;
|
|
40
|
+
}>;
|
|
41
|
+
/** 🖥️ Screen review (since 0.3.0): Healer starts the app in its sandbox and checks what each page shows, without repairing
|
|
42
|
+
* anything and without AI. Waits for the result. On a page that did not load, a "not_exists" expectation answers
|
|
43
|
+
* CANNOT PROVE, never a false yes. */
|
|
44
|
+
reviewScreen(request: ScreenReviewRequest): Promise<ScreenReviewResult>;
|
|
45
|
+
/** Envía el código y ESPERA el resultado final, consultando el estado sola — la forma más
|
|
46
|
+
* simple de usar Healer. Tira HealerApiError si el job termina en "error", o HealerTimeoutError
|
|
47
|
+
* si se agota "timeoutMs" sin que el job termine. */
|
|
48
|
+
repair(request: SolicitudReparacion, opciones?: {
|
|
49
|
+
onProgress?: (progreso: ProgresoJob) => void;
|
|
50
|
+
}): Promise<ResultadoReparacion>;
|
|
51
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export class HealerApiError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
body;
|
|
4
|
+
constructor(status, body) {
|
|
5
|
+
const mensaje = body?.error || `Healer returned HTTP status ${status}.`;
|
|
6
|
+
super(mensaje);
|
|
7
|
+
this.name = 'HealerApiError';
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.body = body;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
// Se agota esperando un job que nunca termina (proveedor de IA caído en serio, servidor caído a
|
|
13
|
+
// mitad de camino, etc.) — nunca cuelga la llamada de "repair()" para siempre.
|
|
14
|
+
export class HealerTimeoutError extends Error {
|
|
15
|
+
constructor(jobId, timeoutMs) {
|
|
16
|
+
super(`Job "${jobId}" did not finish within ${timeoutMs}ms. Keep polling with getRepair("${jobId}") if you want to wait longer.`);
|
|
17
|
+
this.name = 'HealerTimeoutError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function cuerpoHttp(request) {
|
|
21
|
+
return {
|
|
22
|
+
files: request.files,
|
|
23
|
+
repository_url: request.repositoryUrl,
|
|
24
|
+
commit_sha: request.commitSha,
|
|
25
|
+
app_id: request.appId,
|
|
26
|
+
max_iterations: request.maxIterations,
|
|
27
|
+
test_uso_real: request.testUsoReal,
|
|
28
|
+
app_intent: request.appIntent,
|
|
29
|
+
start_command: request.startCommand,
|
|
30
|
+
port: request.port,
|
|
31
|
+
ai_level: request.aiLevel
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// 🎓 [SDK OFICIAL, 2026-09-16, pedido explícito: "vender el pipeline vía API... entre menos
|
|
35
|
+
// fricción más fácil llega el cliente"] Esto es lo que baja la integración real de un builder de
|
|
36
|
+
// las ~30-50 líneas que necesita hablar HTTP a mano (auth, armar el body, el loop de polling con
|
|
37
|
+
// su propio backoff, distinguir error de red vs. error de negocio) a el puñado de líneas del
|
|
38
|
+
// ejemplo en el README — el polling y el manejo de errores viven ACÁ una sola vez, no en cada
|
|
39
|
+
// integración de cada cliente.
|
|
40
|
+
export class HealerClient {
|
|
41
|
+
apiKey;
|
|
42
|
+
baseUrl;
|
|
43
|
+
pollIntervalMs;
|
|
44
|
+
timeoutMs;
|
|
45
|
+
constructor(options) {
|
|
46
|
+
if (!options?.apiKey) {
|
|
47
|
+
throw new Error('HealerClient needs "apiKey".');
|
|
48
|
+
}
|
|
49
|
+
this.apiKey = options.apiKey;
|
|
50
|
+
this.baseUrl = (options.baseUrl || 'https://healer-api.meiti.dev').replace(/\/+$/, '');
|
|
51
|
+
this.pollIntervalMs = options.pollIntervalMs ?? 3000;
|
|
52
|
+
this.timeoutMs = options.timeoutMs ?? 10 * 60 * 1000;
|
|
53
|
+
}
|
|
54
|
+
async pedir(metodo, ruta, cuerpo) {
|
|
55
|
+
const respuesta = await fetch(`${this.baseUrl}${ruta}`, {
|
|
56
|
+
method: metodo,
|
|
57
|
+
headers: { 'Content-Type': 'application/json', 'x-api-key': this.apiKey },
|
|
58
|
+
body: cuerpo !== undefined ? JSON.stringify(cuerpo) : undefined
|
|
59
|
+
});
|
|
60
|
+
const texto = await respuesta.text();
|
|
61
|
+
const datos = texto ? JSON.parse(texto) : null;
|
|
62
|
+
if (!respuesta.ok) {
|
|
63
|
+
throw new HealerApiError(respuesta.status, datos);
|
|
64
|
+
}
|
|
65
|
+
return datos;
|
|
66
|
+
}
|
|
67
|
+
/** Envía el código y devuelve de inmediato { job_id, app_id, status: "queued" } — sin esperar
|
|
68
|
+
* a que termine. Usar junto a getRepair() para armar tu propio loop de consulta, o preferir
|
|
69
|
+
* repair() si alcanza con esperar el resultado final. */
|
|
70
|
+
async submitRepair(request) {
|
|
71
|
+
return this.pedir('POST', '/v1/repair', cuerpoHttp(request));
|
|
72
|
+
}
|
|
73
|
+
/** Un solo chequeo de estado — "queued"/"running" mientras corre, o el resultado final. */
|
|
74
|
+
async getRepair(jobId) {
|
|
75
|
+
return this.pedir('GET', `/v1/repair/${encodeURIComponent(jobId)}`);
|
|
76
|
+
}
|
|
77
|
+
/** Le cuenta a Healer qué archivos de su reparación se aplicaron y cuáles se dejaron afuera (desde 2026-11-11).
|
|
78
|
+
* Opcional: sirve para medir qué cambios valen la pena. Healer guarda solo huellas de las rutas, nunca código. */
|
|
79
|
+
async informarDecision(jobId, decision) {
|
|
80
|
+
return this.pedir('POST', `/v1/repair/${encodeURIComponent(jobId)}/decision`, { aplicados: decision.aplicados ?? [], descartados: decision.descartados ?? [], via: 'sdk' });
|
|
81
|
+
}
|
|
82
|
+
/** 🖥️ Screen review (since 0.3.0): Healer starts the app in its sandbox and checks what each page shows, without repairing
|
|
83
|
+
* anything and without AI. Waits for the result. On a page that did not load, a "not_exists" expectation answers
|
|
84
|
+
* CANNOT PROVE, never a false yes. */
|
|
85
|
+
async reviewScreen(request) {
|
|
86
|
+
const cuerpo = { ...(request.files ? { files: request.files } : {}), ...(request.repositoryUrl ? { repository_url: request.repositoryUrl } : {}), ...(request.commitSha ? { commit_sha: request.commitSha } : {}), start_command: request.startCommand, port: request.port, pages: request.pages, ...(request.appId ? { app_id: request.appId } : {}) };
|
|
87
|
+
const envio = await this.pedir('POST', '/v1/screen', cuerpo);
|
|
88
|
+
const limite = Date.now() + this.timeoutMs;
|
|
89
|
+
while (Date.now() < limite) {
|
|
90
|
+
const estado = await this.pedir('GET', `/v1/repair/${encodeURIComponent(envio.job_id)}`);
|
|
91
|
+
if (estado.status === 'error')
|
|
92
|
+
throw new HealerApiError(500, { error: estado.error });
|
|
93
|
+
if (estado.tipo === 'pantalla')
|
|
94
|
+
return estado;
|
|
95
|
+
await new Promise((resolver) => setTimeout(resolver, this.pollIntervalMs));
|
|
96
|
+
}
|
|
97
|
+
throw new HealerTimeoutError(envio.job_id, this.timeoutMs);
|
|
98
|
+
}
|
|
99
|
+
/** Envía el código y ESPERA el resultado final, consultando el estado sola — la forma más
|
|
100
|
+
* simple de usar Healer. Tira HealerApiError si el job termina en "error", o HealerTimeoutError
|
|
101
|
+
* si se agota "timeoutMs" sin que el job termine. */
|
|
102
|
+
async repair(request, opciones = {}) {
|
|
103
|
+
const envio = await this.submitRepair(request);
|
|
104
|
+
const limite = Date.now() + this.timeoutMs;
|
|
105
|
+
while (Date.now() < limite) {
|
|
106
|
+
const estado = await this.getRepair(envio.job_id);
|
|
107
|
+
if (estado.status === 'error') {
|
|
108
|
+
throw new HealerApiError(500, { error: estado.error });
|
|
109
|
+
}
|
|
110
|
+
// Chequeo positivo (nunca negativo) a propósito: "!== queued && !== running" no le alcanza
|
|
111
|
+
// a TypeScript para angostar el tipo cuando el discriminante de la otra rama es a su vez una
|
|
112
|
+
// unión de dos literales — con las dos ramas finales comparadas de forma explícita, el tipo
|
|
113
|
+
// que queda es inequívocamente ResultadoReparacion.
|
|
114
|
+
// 🧭 [2026-09-30] "unsupported_stack" también es final: sin esto, el polling seguía hasta el
|
|
115
|
+
// timeout esperando un estado que nunca iba a llegar.
|
|
116
|
+
if (estado.status === 'production_ready' || estado.status === 'unresolved' || estado.status === 'unsupported_stack') {
|
|
117
|
+
return estado;
|
|
118
|
+
}
|
|
119
|
+
if (opciones.onProgress && 'progress' in estado && estado.progress)
|
|
120
|
+
opciones.onProgress(estado.progress);
|
|
121
|
+
await new Promise((resolver) => setTimeout(resolver, this.pollIntervalMs));
|
|
122
|
+
}
|
|
123
|
+
throw new HealerTimeoutError(envio.job_id, this.timeoutMs);
|
|
124
|
+
}
|
|
125
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { HealerClient, HealerApiError, HealerTimeoutError } from './client.js';
|
|
2
|
+
export type { HealerClientOptions } from './client.js';
|
|
3
|
+
export { verificarBase, aplicarReparacion, ErrorBaseModificada } from './aplicar.js';
|
|
4
|
+
export type { VerificacionBase } from './aplicar.js';
|
|
5
|
+
export type { SolicitudReparacion, ResultadoReparacion, EnvioAceptado, EstadoJob, ProgresoJob, EventoReparacion, ReporteAuditoriaSeguridad, HallazgoSeguridad, HallazgoPendiente, ReporteUsoReal, ProblemaUsoReal, ItemNoProbado, ReportePentagono, HallazgoPentagono, Cobertura, Stack, HealerReport, PendingKind, ScreenPage, ScreenReviewRequest, ScreenReviewResult } from './types.js';
|
package/dist/index.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
export interface HallazgoSeguridad {
|
|
2
|
+
regla: string;
|
|
3
|
+
archivo: string;
|
|
4
|
+
linea: number;
|
|
5
|
+
severidad: string;
|
|
6
|
+
mensaje: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ReporteAuditoriaSeguridad {
|
|
9
|
+
vulnerabilities_found: number;
|
|
10
|
+
findings: HallazgoSeguridad[];
|
|
11
|
+
}
|
|
12
|
+
export interface HallazgoPendiente {
|
|
13
|
+
archivo: string;
|
|
14
|
+
diagnostico: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ProblemaUsoReal {
|
|
17
|
+
archivo: string;
|
|
18
|
+
diagnostico: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ItemNoProbado {
|
|
21
|
+
archivo: string;
|
|
22
|
+
motivo: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ReporteUsoReal {
|
|
25
|
+
ejecutado: boolean;
|
|
26
|
+
estado: 'aprobado' | 'con_hallazgos' | 'fallo_infraestructura' | 'inconcluyente' | 'transitorio';
|
|
27
|
+
diagnostico: string;
|
|
28
|
+
problemas: ProblemaUsoReal[];
|
|
29
|
+
noProbado: ItemNoProbado[];
|
|
30
|
+
}
|
|
31
|
+
export interface HallazgoPentagono {
|
|
32
|
+
herramienta: 'eslint' | 'ts-prune' | 'npm-audit' | 'ruff' | 'vulture' | 'pip-audit';
|
|
33
|
+
severidad: string;
|
|
34
|
+
archivo?: string;
|
|
35
|
+
linea?: number;
|
|
36
|
+
mensaje: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ReportePentagono {
|
|
39
|
+
puntaje: number;
|
|
40
|
+
critico: boolean;
|
|
41
|
+
hallazgos: HallazgoPentagono[];
|
|
42
|
+
}
|
|
43
|
+
export interface EventoReparacion {
|
|
44
|
+
error: string;
|
|
45
|
+
file: string;
|
|
46
|
+
diff: string;
|
|
47
|
+
}
|
|
48
|
+
export type Stack = 'javascript' | 'python';
|
|
49
|
+
export interface Cobertura {
|
|
50
|
+
stacks: Stack[];
|
|
51
|
+
stack: Stack | null;
|
|
52
|
+
lenguajes_detectados: Record<string, number>;
|
|
53
|
+
lenguajes_no_cubiertos: string[];
|
|
54
|
+
}
|
|
55
|
+
export interface ResultadoReparacion {
|
|
56
|
+
status: 'production_ready' | 'unresolved' | 'unsupported_stack';
|
|
57
|
+
cobertura: Cobertura;
|
|
58
|
+
mensaje?: string;
|
|
59
|
+
iterations: number;
|
|
60
|
+
repairs_count: number;
|
|
61
|
+
history: EventoReparacion[];
|
|
62
|
+
files?: Record<string, string>;
|
|
63
|
+
diff?: string;
|
|
64
|
+
audit_report: ReporteAuditoriaSeguridad | null;
|
|
65
|
+
pending_improvements: HallazgoPendiente[];
|
|
66
|
+
uso_real_report?: ReporteUsoReal | null;
|
|
67
|
+
pentagono_report: ReportePentagono | null;
|
|
68
|
+
/** Con qué nivel de IA corrió el job. */
|
|
69
|
+
ai_level?: 'free' | 'pro';
|
|
70
|
+
/** SHA-256 de cada archivo tal como lo mandaste (solo con "files"). Ver verificarBase(). */
|
|
71
|
+
base_hashes?: Record<string, string>;
|
|
72
|
+
/** Archivos que Healer cambió de verdad. Todos los demás salen idénticos. */
|
|
73
|
+
changed_files?: string[];
|
|
74
|
+
/**
|
|
75
|
+
* Archivos de changed_files que son una actualización de soporte (versiones de dependencias para que
|
|
76
|
+
* la app corra en el runtime actual), no la reparación del bug. Son opcionales: ver aplicarReparacion().
|
|
77
|
+
*/
|
|
78
|
+
support_updates?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* Failures found and fixed. Each failing check counts once; each auditor bug fixed and delivered counts
|
|
81
|
+
* one. Checks stop at the first failure, so "sin_correr" means others may not have run yet.
|
|
82
|
+
*/
|
|
83
|
+
failures?: {
|
|
84
|
+
found: number;
|
|
85
|
+
fixed: number;
|
|
86
|
+
remaining: {
|
|
87
|
+
origen: string;
|
|
88
|
+
detalle: string;
|
|
89
|
+
/** What kind of thing remains (see HealerReport.pending for the explanation in words). */
|
|
90
|
+
kind?: PendingKind;
|
|
91
|
+
files?: string[];
|
|
92
|
+
tests_before?: number;
|
|
93
|
+
tests_after?: number;
|
|
94
|
+
}[];
|
|
95
|
+
sin_correr?: boolean;
|
|
96
|
+
/** Whether the tests of the request pass with what is delivered. "did_not_run": they could not run. */
|
|
97
|
+
target_tests?: 'pass' | 'fail' | 'did_not_run' | 'not_reached' | 'none' | 'unknown';
|
|
98
|
+
/** Failing tests in your original code and with what is delivered (null: could not be counted). */
|
|
99
|
+
tests_failing_before?: number | null;
|
|
100
|
+
tests_failing_after?: number | null;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* The report for the owner: what was fixed, failing tests before and after, and every pending item with what it
|
|
104
|
+
* is, why it remained and what it needs (install something, an external service, a manual fix). Read this
|
|
105
|
+
* instead of guessing from "status".
|
|
106
|
+
*/
|
|
107
|
+
report?: HealerReport | null;
|
|
108
|
+
/**
|
|
109
|
+
* Partial delivery: status stays "unresolved", but "files" carries fixes that left nothing worse. What
|
|
110
|
+
* remains already failed in your original code. aplicarReparacion() accepts it.
|
|
111
|
+
*/
|
|
112
|
+
partial_fix?: boolean;
|
|
113
|
+
/** With partial_fix: the full test suite could not be compared with the original. Run it before applying. */
|
|
114
|
+
suite_unverified?: boolean;
|
|
115
|
+
/** Presente cuando la reparación dejaba el código peor que el original: no se devuelve nada. */
|
|
116
|
+
bloqueado_por_regresion?: {
|
|
117
|
+
original: {
|
|
118
|
+
vulnerabilidades: number;
|
|
119
|
+
pentagono: number;
|
|
120
|
+
};
|
|
121
|
+
reparado: {
|
|
122
|
+
vulnerabilidades: number;
|
|
123
|
+
pentagono: number;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** En qué va un trabajo, en palabras y en campos (desde 2026-11-10). */
|
|
128
|
+
export interface ProgresoJob {
|
|
129
|
+
/** Última etapa registrada (clave), o null si todavía arma el sandbox. */
|
|
130
|
+
stage: string | null;
|
|
131
|
+
/** La misma etapa en palabras, por ejemplo "running the tests". */
|
|
132
|
+
stage_label: string;
|
|
133
|
+
minutes: number | null;
|
|
134
|
+
queue_position: number | null;
|
|
135
|
+
steps: {
|
|
136
|
+
tests: number;
|
|
137
|
+
repair_attempts: number;
|
|
138
|
+
reviews: number;
|
|
139
|
+
security_audit: boolean;
|
|
140
|
+
quality_scored: boolean;
|
|
141
|
+
real_use: boolean;
|
|
142
|
+
};
|
|
143
|
+
/** Cuánto tarda hoy un trabajo típico de este nivel a esta hora, en minutos (null sin datos suficientes). Desde 2026-11-12. */
|
|
144
|
+
typical_minutes?: number | null;
|
|
145
|
+
/** Todo lo anterior en una o dos frases, listo para mostrar. */
|
|
146
|
+
message: string;
|
|
147
|
+
}
|
|
148
|
+
export interface EstadoJobEnCurso {
|
|
149
|
+
status: 'queued' | 'running';
|
|
150
|
+
/** Presente desde 2026-11-10; un servidor viejo puede no mandarlo. */
|
|
151
|
+
progress?: ProgresoJob;
|
|
152
|
+
}
|
|
153
|
+
export interface EstadoJobConError {
|
|
154
|
+
status: 'error';
|
|
155
|
+
error: string;
|
|
156
|
+
}
|
|
157
|
+
export type EstadoJob = EstadoJobEnCurso | EstadoJobConError | ResultadoReparacion;
|
|
158
|
+
export interface SolicitudReparacion {
|
|
159
|
+
/** Objeto { rutaRelativa: contenido } — alternativa a repositoryUrl, no se pueden usar los dos. */
|
|
160
|
+
files?: Record<string, string>;
|
|
161
|
+
/** URL de un repositorio git público — alternativa a files. */
|
|
162
|
+
repositoryUrl?: string;
|
|
163
|
+
commitSha?: string;
|
|
164
|
+
/** Identifica a qué app pertenece este envío, para acumular historial en su propia bóveda. Si
|
|
165
|
+
* se omite en el primer envío, el servidor genera uno y lo devuelve — guárdalo y reenvíalo en
|
|
166
|
+
* los próximos envíos de ESTA MISMA app. */
|
|
167
|
+
appId?: string;
|
|
168
|
+
maxIterations?: number;
|
|
169
|
+
/** Corre además una sesión real de uso (Puppeteer + IA) sobre la app ya reparada. Necesita
|
|
170
|
+
* declarar startCommand/port la PRIMERA vez para esta appId — las corridas siguientes de la
|
|
171
|
+
* misma app los heredan automáticamente si se omiten. */
|
|
172
|
+
testUsoReal?: boolean;
|
|
173
|
+
appIntent?: string;
|
|
174
|
+
startCommand?: string;
|
|
175
|
+
port?: number;
|
|
176
|
+
/** Con qué IA se repara. "free": proveedores gratis (Groq, NVIDIA y Gemini), sin costo de IA.
|
|
177
|
+
* "pro": las APIs pagas (Claude / Gemini Pro). Default: "pro".
|
|
178
|
+
* En "free" el código puede reusarse para reentrenar los modelos de MEITI y de esos proveedores;
|
|
179
|
+
* en "pro" nada se usa para entrenar. */
|
|
180
|
+
aiLevel?: 'free' | 'pro';
|
|
181
|
+
}
|
|
182
|
+
export interface EnvioAceptado {
|
|
183
|
+
job_id: string;
|
|
184
|
+
app_id: string;
|
|
185
|
+
status: 'queued';
|
|
186
|
+
}
|
|
187
|
+
/** preexisting_lint: already in your code, in files Healer did not touch · did_not_run: the tests could not run · dependency: something is not installed · not_delivered: fixed but not delivered · not_fixed: Healer could not fix it. */
|
|
188
|
+
export type PendingKind = 'preexisting_lint' | 'did_not_run' | 'dependency' | 'not_delivered' | 'not_fixed';
|
|
189
|
+
export interface HealerReport {
|
|
190
|
+
/** One paragraph: what happened, in numbers. */
|
|
191
|
+
headline: string;
|
|
192
|
+
numbers: {
|
|
193
|
+
failures_found: number;
|
|
194
|
+
failures_fixed: number;
|
|
195
|
+
failures_pending: number;
|
|
196
|
+
tests_failing_before: number | null;
|
|
197
|
+
tests_failing_after: number | null;
|
|
198
|
+
target_tests: 'pass' | 'fail' | 'did_not_run' | 'not_reached' | 'none' | 'unknown';
|
|
199
|
+
};
|
|
200
|
+
fixed: string[];
|
|
201
|
+
pending: {
|
|
202
|
+
check: string;
|
|
203
|
+
kind: PendingKind;
|
|
204
|
+
what: string;
|
|
205
|
+
why: string;
|
|
206
|
+
needs: string;
|
|
207
|
+
files?: string[];
|
|
208
|
+
}[];
|
|
209
|
+
support_updates: string[];
|
|
210
|
+
/** Possible issues the AI review suggested and nobody verified (see pending_improvements). */
|
|
211
|
+
unverified_suggestions: number;
|
|
212
|
+
code_changed: boolean;
|
|
213
|
+
}
|
|
214
|
+
/** One page to check in a screen review (POST /v1/screen). */
|
|
215
|
+
export interface ScreenPage {
|
|
216
|
+
path: string;
|
|
217
|
+
width?: number;
|
|
218
|
+
/** localStorage on the app origin before loading (open it already signed in, test accounts only). */
|
|
219
|
+
storage?: Record<string, string>;
|
|
220
|
+
/** What identifies the right page. */
|
|
221
|
+
expect_page?: {
|
|
222
|
+
url_contains?: string;
|
|
223
|
+
title_contains?: string;
|
|
224
|
+
title_is?: string;
|
|
225
|
+
exists?: string;
|
|
226
|
+
};
|
|
227
|
+
/** What you expect: { exists }, { not_exists }, { text, contains }, { no_issues: true }, { loaded: true }. */
|
|
228
|
+
expectations?: Record<string, unknown>[];
|
|
229
|
+
/** An element that appears after a request: waited up to 15 s. */
|
|
230
|
+
wait_for?: string;
|
|
231
|
+
}
|
|
232
|
+
export interface ScreenReviewRequest {
|
|
233
|
+
files?: Record<string, string>;
|
|
234
|
+
repositoryUrl?: string;
|
|
235
|
+
commitSha?: string;
|
|
236
|
+
/** The command that starts the app (it must listen on 0.0.0.0). */
|
|
237
|
+
startCommand: string;
|
|
238
|
+
port: number;
|
|
239
|
+
pages: ScreenPage[];
|
|
240
|
+
appId?: string;
|
|
241
|
+
}
|
|
242
|
+
/** The result of a screen review: Healer started the app in its sandbox and checked each page. Nothing was repaired. */
|
|
243
|
+
export interface ScreenReviewResult {
|
|
244
|
+
tipo: 'pantalla';
|
|
245
|
+
status: 'checked' | 'did_not_start' | 'unsupported_stack';
|
|
246
|
+
message: string;
|
|
247
|
+
pages: {
|
|
248
|
+
path: string;
|
|
249
|
+
state: 'LOADED' | 'DID NOT LOAD' | 'STILL LOADING' | 'NOT THE EXPECTED PAGE';
|
|
250
|
+
reasons: string[];
|
|
251
|
+
http: number | null;
|
|
252
|
+
title: string;
|
|
253
|
+
failed_requests: string[];
|
|
254
|
+
visual_issues: {
|
|
255
|
+
type: string;
|
|
256
|
+
element: string | null;
|
|
257
|
+
detail: string;
|
|
258
|
+
}[];
|
|
259
|
+
/** CANNOT PROVE: the page did not load or is not the expected one. Never report it as "not there". */
|
|
260
|
+
expectations: {
|
|
261
|
+
expectation: Record<string, unknown>;
|
|
262
|
+
answer: 'YES' | 'NO' | 'CANNOT PROVE';
|
|
263
|
+
proof: string;
|
|
264
|
+
}[];
|
|
265
|
+
map: string;
|
|
266
|
+
}[];
|
|
267
|
+
summary: {
|
|
268
|
+
pages: number;
|
|
269
|
+
loaded: number;
|
|
270
|
+
expectations_yes: number;
|
|
271
|
+
expectations_no: number;
|
|
272
|
+
expectations_cannot_prove: number;
|
|
273
|
+
visual_issues: number;
|
|
274
|
+
};
|
|
275
|
+
ms: {
|
|
276
|
+
install: number;
|
|
277
|
+
start: number;
|
|
278
|
+
pages: number;
|
|
279
|
+
total: number;
|
|
280
|
+
};
|
|
281
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// 🎓 [SDK OFICIAL, 2026-09-16] Tipos escritos a mano, en espejo del formato de respuesta REAL de
|
|
2
|
+
// server.ts — a propósito NO importados desde el código del servidor (../../src/...): un SDK
|
|
3
|
+
// publicado no puede depender de los internos del servidor, y el contrato público (lo que viaja
|
|
4
|
+
// por HTTP) puede evolucionar distinto de la representación interna con el tiempo. Si el servidor
|
|
5
|
+
// cambia un campo de la respuesta, este archivo es el que hay que actualizar — es el contrato, no
|
|
6
|
+
// un atajo.
|
|
7
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meiti/healer-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Official SDK for Healer: send code, get it back repaired or unchanged, never worse. Thin layer over the REST API with polling, safe apply and partial delivery.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"typecheck": "tsc --noEmit"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://meiti.dev/healer",
|
|
27
|
+
"keywords": [
|
|
28
|
+
"healer",
|
|
29
|
+
"repair",
|
|
30
|
+
"testing",
|
|
31
|
+
"ci",
|
|
32
|
+
"sdk",
|
|
33
|
+
"ai"
|
|
34
|
+
],
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"typescript": "^5.7.2",
|
|
38
|
+
"@types/node": "^22.20.3"
|
|
39
|
+
}
|
|
40
|
+
}
|