@meiti/healer-sdk 0.1.0 → 0.3.1
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 +39 -0
- package/dist/client.d.ts +5 -1
- package/dist/client.js +17 -0
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +133 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,45 @@ Options:
|
|
|
65
65
|
If Healer could not leave the code better, `result.files` is missing and your code stays the same (see
|
|
66
66
|
`bloqueado_por_regresion`).
|
|
67
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
|
+
`startCommand`, `port` and `pages` are optional. Without them Healer finds how to start the app (`.healer.json` `"screen"`, the command that worked last time for this `appId`, or `package.json` / the Python entry file) and checks `/`. `r.start` says which command ran, where it came from (`declared`, `repo_config`, `remembered`, `detected`) and whether the app answered:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
const r = await healer.reviewScreen({ files });
|
|
102
|
+
console.log(r.start); // { command: 'npx vite --host 0.0.0.0 --port 5173 --strictPort', port: 5173, source: 'detected', detail: 'package.json: the "dev" script runs Vite', verified: true }
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
To fix the command for every agent, declare it once in `.healer.json`: `{ "screen": { "start_command": "npm start", "port": 3000, "pages": [{ "path": "/" }] } }`.
|
|
106
|
+
|
|
68
107
|
### Partial delivery
|
|
69
108
|
|
|
70
109
|
When some failures were fixed and others remain, `status` stays `"unresolved"` but the result carries
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EnvioAceptado, EstadoJob, ProgresoJob, ResultadoReparacion, SolicitudReparacion } from './types.js';
|
|
1
|
+
import type { EnvioAceptado, EstadoJob, ProgresoJob, ResultadoReparacion, SolicitudReparacion, ScreenReviewRequest, ScreenReviewResult } from './types.js';
|
|
2
2
|
export declare class HealerApiError extends Error {
|
|
3
3
|
readonly status: number;
|
|
4
4
|
readonly body: unknown;
|
|
@@ -38,6 +38,10 @@ export declare class HealerClient {
|
|
|
38
38
|
ok: boolean;
|
|
39
39
|
registrados: number;
|
|
40
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>;
|
|
41
45
|
/** Envía el código y ESPERA el resultado final, consultando el estado sola — la forma más
|
|
42
46
|
* simple de usar Healer. Tira HealerApiError si el job termina en "error", o HealerTimeoutError
|
|
43
47
|
* si se agota "timeoutMs" sin que el job termine. */
|
package/dist/client.js
CHANGED
|
@@ -79,6 +79,23 @@ export class HealerClient {
|
|
|
79
79
|
async informarDecision(jobId, decision) {
|
|
80
80
|
return this.pedir('POST', `/v1/repair/${encodeURIComponent(jobId)}/decision`, { aplicados: decision.aplicados ?? [], descartados: decision.descartados ?? [], via: 'sdk' });
|
|
81
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
|
+
}
|
|
82
99
|
/** Envía el código y ESPERA el resultado final, consultando el estado sola — la forma más
|
|
83
100
|
* simple de usar Healer. Tira HealerApiError si el job termina en "error", o HealerTimeoutError
|
|
84
101
|
* si se agota "timeoutMs" sin que el job termine. */
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { HealerClient, HealerApiError, HealerTimeoutError } from './client.js';
|
|
|
2
2
|
export type { HealerClientOptions } from './client.js';
|
|
3
3
|
export { verificarBase, aplicarReparacion, ErrorBaseModificada } from './aplicar.js';
|
|
4
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 } from './types.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/types.d.ts
CHANGED
|
@@ -86,9 +86,25 @@ export interface ResultadoReparacion {
|
|
|
86
86
|
remaining: {
|
|
87
87
|
origen: string;
|
|
88
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;
|
|
89
94
|
}[];
|
|
90
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;
|
|
91
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;
|
|
92
108
|
/**
|
|
93
109
|
* Partial delivery: status stays "unresolved", but "files" carries fixes that left nothing worse. What
|
|
94
110
|
* remains already failed in your original code. aplicarReparacion() accepts it.
|
|
@@ -168,3 +184,120 @@ export interface EnvioAceptado {
|
|
|
168
184
|
app_id: string;
|
|
169
185
|
status: 'queued';
|
|
170
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
|
+
/**
|
|
237
|
+
* The command that starts the app (it must listen on 0.0.0.0). Optional: without it Healer finds it (.healer.json "screen",
|
|
238
|
+
* the command that worked last time for this appId, or package.json / the Python entry file). See ScreenReviewResult.start.
|
|
239
|
+
*/
|
|
240
|
+
startCommand?: string;
|
|
241
|
+
/** Optional, like startCommand. */
|
|
242
|
+
port?: number;
|
|
243
|
+
/** Optional: default [{ path: "/" }] (or the pages in .healer.json "screen"). */
|
|
244
|
+
pages?: ScreenPage[];
|
|
245
|
+
appId?: string;
|
|
246
|
+
}
|
|
247
|
+
/** The result of a screen review: Healer started the app in its sandbox and checked each page. Nothing was repaired. */
|
|
248
|
+
export interface ScreenReviewResult {
|
|
249
|
+
tipo: 'pantalla';
|
|
250
|
+
status: 'checked' | 'did_not_start' | 'unsupported_stack';
|
|
251
|
+
message: string;
|
|
252
|
+
/**
|
|
253
|
+
* How the app was started. source: declared (you sent it), repo_config (.healer.json), remembered (worked last time for
|
|
254
|
+
* this appId), detected (read from package.json or the Python files). verified: the app answered on that port. null when
|
|
255
|
+
* Healer could not find how to start it (message says what is needed).
|
|
256
|
+
*/
|
|
257
|
+
/** The last lines the app's server printed, when it did not start or a page did not load. */
|
|
258
|
+
server_log?: string;
|
|
259
|
+
start: {
|
|
260
|
+
command: string;
|
|
261
|
+
port: number;
|
|
262
|
+
source: 'declared' | 'repo_config' | 'remembered' | 'detected';
|
|
263
|
+
detail: string;
|
|
264
|
+
verified: boolean;
|
|
265
|
+
} | null;
|
|
266
|
+
pages: {
|
|
267
|
+
path: string;
|
|
268
|
+
state: 'LOADED' | 'DID NOT LOAD' | 'STILL LOADING' | 'NOT THE EXPECTED PAGE';
|
|
269
|
+
reasons: string[];
|
|
270
|
+
http: number | null;
|
|
271
|
+
title: string;
|
|
272
|
+
/** HTTP 4xx/5xx answers, and "NO RESPONSE ..." for requests that got no answer at all (backend down, wrong address, CORS). */
|
|
273
|
+
failed_requests: string[];
|
|
274
|
+
/** Console errors and uncaught exceptions while the page loaded: usually why a page stays blank. */
|
|
275
|
+
page_errors: string[];
|
|
276
|
+
visual_issues: {
|
|
277
|
+
type: string;
|
|
278
|
+
element: string | null;
|
|
279
|
+
detail: string;
|
|
280
|
+
}[];
|
|
281
|
+
/** CANNOT PROVE: the page did not load or is not the expected one. Never report it as "not there". */
|
|
282
|
+
expectations: {
|
|
283
|
+
expectation: Record<string, unknown>;
|
|
284
|
+
answer: 'YES' | 'NO' | 'CANNOT PROVE';
|
|
285
|
+
proof: string;
|
|
286
|
+
}[];
|
|
287
|
+
map: string;
|
|
288
|
+
}[];
|
|
289
|
+
summary: {
|
|
290
|
+
pages: number;
|
|
291
|
+
loaded: number;
|
|
292
|
+
expectations_yes: number;
|
|
293
|
+
expectations_no: number;
|
|
294
|
+
expectations_cannot_prove: number;
|
|
295
|
+
visual_issues: number;
|
|
296
|
+
};
|
|
297
|
+
ms: {
|
|
298
|
+
install: number;
|
|
299
|
+
start: number;
|
|
300
|
+
pages: number;
|
|
301
|
+
total: number;
|
|
302
|
+
};
|
|
303
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meiti/healer-sdk",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.3.1",
|
|
4
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
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|