@meiti/healer-sdk 0.3.1 → 0.4.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/README.md +12 -0
- package/dist/client.d.ts +14 -1
- package/dist/client.js +25 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/types.d.ts +35 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,6 +79,18 @@ console.log(r.report?.headline);
|
|
|
79
79
|
for (const p of r.report?.pending ?? []) console.log(`- ${p.what} Needs: ${p.needs}`);
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
+
### AI level
|
|
83
|
+
|
|
84
|
+
Without `aiLevel`, your organization rule applies (pro unless the owner changed it in the panel). Free never runs hidden: if a job would run on free (you asked for it, or the pro repairs of the plan are used up) and the organization asks for confirmation, `repair()` and `submitRepair()` throw `HealerNeedsConfirmationError` and nothing is queued. Ask the user; if they agree, send it again with `confirmFree: true` (this job only). With the pro repairs used up, `reviewOnly: true` runs the checks without repairing and without AI.
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
try {
|
|
88
|
+
await healer.repair({ files });
|
|
89
|
+
} catch (e) {
|
|
90
|
+
if (e instanceof HealerNeedsConfirmationError) console.log(e.reason, e.message); // ask the user first
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
82
94
|
### Screen review
|
|
83
95
|
|
|
84
96
|
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:
|
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import type { EnvioAceptado, EstadoJob, ProgresoJob, ResultadoReparacion, SolicitudReparacion, ScreenReviewRequest, ScreenReviewResult } from './types.js';
|
|
1
|
+
import type { EnvioAceptado, EstadoJob, ProgresoJob, ResultadoReparacion, SolicitudReparacion, ScreenReviewRequest, ScreenReviewResult, HealerInfo } from './types.js';
|
|
2
2
|
export declare class HealerApiError extends Error {
|
|
3
3
|
readonly status: number;
|
|
4
4
|
readonly body: unknown;
|
|
5
5
|
constructor(status: number, body: unknown);
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* The job would run on the free level (it asked for free, or the pro repairs of the plan are used up) and the organization asks
|
|
9
|
+
* for confirmation. Nothing was queued. Ask the user; if they agree, send it again with confirmFree: true (this job only), or
|
|
10
|
+
* with reviewOnly: true to run the checks without repairing and without AI. The owner sets the rule in the Healer panel.
|
|
11
|
+
*/
|
|
12
|
+
export declare class HealerNeedsConfirmationError extends Error {
|
|
13
|
+
readonly reason: 'free_pedido' | 'cupo_agotado';
|
|
14
|
+
readonly options: string[];
|
|
15
|
+
constructor(body: any);
|
|
16
|
+
}
|
|
7
17
|
export declare class HealerTimeoutError extends Error {
|
|
8
18
|
constructor(jobId: string, timeoutMs: number);
|
|
9
19
|
}
|
|
@@ -23,6 +33,9 @@ export declare class HealerClient {
|
|
|
23
33
|
private readonly timeoutMs;
|
|
24
34
|
constructor(options: HealerClientOptions);
|
|
25
35
|
private pedir;
|
|
36
|
+
/** The organization rule for the AI level and the pro repairs left this month (no AI, no cost). Check it before sending a job
|
|
37
|
+
* to know whether it would need the user's yes for free. */
|
|
38
|
+
getInfo(): Promise<HealerInfo>;
|
|
26
39
|
/** Envía el código y devuelve de inmediato { job_id, app_id, status: "queued" } — sin esperar
|
|
27
40
|
* a que termine. Usar junto a getRepair() para armar tu propio loop de consulta, o preferir
|
|
28
41
|
* repair() si alcanza con esperar el resultado final. */
|
package/dist/client.js
CHANGED
|
@@ -9,6 +9,21 @@ export class HealerApiError extends Error {
|
|
|
9
9
|
this.body = body;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The job would run on the free level (it asked for free, or the pro repairs of the plan are used up) and the organization asks
|
|
14
|
+
* for confirmation. Nothing was queued. Ask the user; if they agree, send it again with confirmFree: true (this job only), or
|
|
15
|
+
* with reviewOnly: true to run the checks without repairing and without AI. The owner sets the rule in the Healer panel.
|
|
16
|
+
*/
|
|
17
|
+
export class HealerNeedsConfirmationError extends Error {
|
|
18
|
+
reason;
|
|
19
|
+
options;
|
|
20
|
+
constructor(body) {
|
|
21
|
+
super(body?.message || 'This job needs the user to confirm the free level.');
|
|
22
|
+
this.name = 'HealerNeedsConfirmationError';
|
|
23
|
+
this.reason = body?.reason;
|
|
24
|
+
this.options = Array.isArray(body?.options) ? body.options : ['confirm_free'];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
12
27
|
// Se agota esperando un job que nunca termina (proveedor de IA caído en serio, servidor caído a
|
|
13
28
|
// mitad de camino, etc.) — nunca cuelga la llamada de "repair()" para siempre.
|
|
14
29
|
export class HealerTimeoutError extends Error {
|
|
@@ -28,7 +43,9 @@ function cuerpoHttp(request) {
|
|
|
28
43
|
app_intent: request.appIntent,
|
|
29
44
|
start_command: request.startCommand,
|
|
30
45
|
port: request.port,
|
|
31
|
-
ai_level: request.aiLevel
|
|
46
|
+
ai_level: request.aiLevel,
|
|
47
|
+
confirm_free: request.confirmFree,
|
|
48
|
+
review_only: request.reviewOnly
|
|
32
49
|
};
|
|
33
50
|
}
|
|
34
51
|
// 🎓 [SDK OFICIAL, 2026-09-16, pedido explícito: "vender el pipeline vía API... entre menos
|
|
@@ -59,11 +76,18 @@ export class HealerClient {
|
|
|
59
76
|
});
|
|
60
77
|
const texto = await respuesta.text();
|
|
61
78
|
const datos = texto ? JSON.parse(texto) : null;
|
|
79
|
+
if (respuesta.status === 409 && datos?.status === 'needs_confirmation')
|
|
80
|
+
throw new HealerNeedsConfirmationError(datos);
|
|
62
81
|
if (!respuesta.ok) {
|
|
63
82
|
throw new HealerApiError(respuesta.status, datos);
|
|
64
83
|
}
|
|
65
84
|
return datos;
|
|
66
85
|
}
|
|
86
|
+
/** The organization rule for the AI level and the pro repairs left this month (no AI, no cost). Check it before sending a job
|
|
87
|
+
* to know whether it would need the user's yes for free. */
|
|
88
|
+
async getInfo() {
|
|
89
|
+
return this.pedir('GET', '/v1/info');
|
|
90
|
+
}
|
|
67
91
|
/** Envía el código y devuelve de inmediato { job_id, app_id, status: "queued" } — sin esperar
|
|
68
92
|
* a que termine. Usar junto a getRepair() para armar tu propio loop de consulta, o preferir
|
|
69
93
|
* repair() si alcanza con esperar el resultado final. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { HealerClient, HealerApiError, HealerTimeoutError } from './client.js';
|
|
1
|
+
export { HealerClient, HealerApiError, HealerTimeoutError, HealerNeedsConfirmationError } 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, HealerReport, PendingKind, ScreenPage, ScreenReviewRequest, ScreenReviewResult } 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, HealerInfo } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { HealerClient, HealerApiError, HealerTimeoutError } from './client.js';
|
|
1
|
+
export { HealerClient, HealerApiError, HealerTimeoutError, HealerNeedsConfirmationError } from './client.js';
|
|
2
2
|
export { verificarBase, aplicarReparacion, ErrorBaseModificada } from './aplicar.js';
|
package/dist/types.d.ts
CHANGED
|
@@ -65,8 +65,10 @@ export interface ResultadoReparacion {
|
|
|
65
65
|
pending_improvements: HallazgoPendiente[];
|
|
66
66
|
uso_real_report?: ReporteUsoReal | null;
|
|
67
67
|
pentagono_report: ReportePentagono | null;
|
|
68
|
-
/** Con qué nivel de IA corrió el job. */
|
|
69
|
-
ai_level?: 'free' | 'pro';
|
|
68
|
+
/** Con qué nivel de IA corrió el job ("none": revisar sin reparar, sin IA). */
|
|
69
|
+
ai_level?: 'free' | 'pro' | 'none';
|
|
70
|
+
/** Por qué ese nivel: pedido, la política de la organización, reparaciones sueltas, confirmado por la persona, free automático de la organización o solo revisar. */
|
|
71
|
+
ai_level_reason?: 'pedido' | 'organizacion' | 'cupo' | 'confirmado' | 'auto' | 'solo_revisar' | 'benchmark';
|
|
70
72
|
/** SHA-256 de cada archivo tal como lo mandaste (solo con "files"). Ver verificarBase(). */
|
|
71
73
|
base_hashes?: Record<string, string>;
|
|
72
74
|
/** Archivos que Healer cambió de verdad. Todos los demás salen idénticos. */
|
|
@@ -173,16 +175,22 @@ export interface SolicitudReparacion {
|
|
|
173
175
|
appIntent?: string;
|
|
174
176
|
startCommand?: string;
|
|
175
177
|
port?: number;
|
|
176
|
-
/** Con qué IA se repara. "free": proveedores gratis (Groq, NVIDIA y Gemini),
|
|
177
|
-
* "pro": las APIs pagas
|
|
178
|
-
*
|
|
179
|
-
*
|
|
178
|
+
/** Con qué IA se repara. "free": proveedores gratis (Groq, NVIDIA y Gemini), que pueden guardar lo que reciben, y el código
|
|
179
|
+
* puede usarse para entrenar. "pro": las APIs pagas, nada se usa para entrenar. Sin mandarlo vale la política de la
|
|
180
|
+
* organización (pro, salvo que el dueño la cambie en el panel). Si tocaría free y la organización pide confirmar, submitRepair
|
|
181
|
+
* y repair tiran HealerNeedsConfirmationError y no se encola nada. */
|
|
180
182
|
aiLevel?: 'free' | 'pro';
|
|
183
|
+
/** Solo después de que la persona dijo que sí al nivel free para ESTE trabajo. */
|
|
184
|
+
confirmFree?: boolean;
|
|
185
|
+
/** Revisar sin reparar y sin IA (compilación, tests y seguridad). */
|
|
186
|
+
reviewOnly?: boolean;
|
|
181
187
|
}
|
|
182
188
|
export interface EnvioAceptado {
|
|
183
189
|
job_id: string;
|
|
184
190
|
app_id: string;
|
|
185
191
|
status: 'queued';
|
|
192
|
+
ai_level?: 'free' | 'pro' | 'none';
|
|
193
|
+
ai_level_reason?: string;
|
|
186
194
|
}
|
|
187
195
|
/** 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
196
|
export type PendingKind = 'preexisting_lint' | 'did_not_run' | 'dependency' | 'not_delivered' | 'not_fixed';
|
|
@@ -211,6 +219,19 @@ export interface HealerReport {
|
|
|
211
219
|
unverified_suggestions: number;
|
|
212
220
|
code_changed: boolean;
|
|
213
221
|
}
|
|
222
|
+
/** GET /v1/info: the organization rule for the AI level and the pro repairs left this month. No AI, no cost. */
|
|
223
|
+
export interface HealerInfo {
|
|
224
|
+
server: 'healer';
|
|
225
|
+
remote_connector_version: string;
|
|
226
|
+
ai_level_default: 'pro' | 'free';
|
|
227
|
+
/** "ask": free never runs without the user's yes (HealerNeedsConfirmationError). */
|
|
228
|
+
when_free: 'ask' | 'auto';
|
|
229
|
+
repairs: {
|
|
230
|
+
used: number;
|
|
231
|
+
limit: number | null;
|
|
232
|
+
extra: number;
|
|
233
|
+
} | null;
|
|
234
|
+
}
|
|
214
235
|
/** One page to check in a screen review (POST /v1/screen). */
|
|
215
236
|
export interface ScreenPage {
|
|
216
237
|
path: string;
|
|
@@ -256,6 +277,14 @@ export interface ScreenReviewResult {
|
|
|
256
277
|
*/
|
|
257
278
|
/** The last lines the app's server printed, when it did not start or a page did not load. */
|
|
258
279
|
server_log?: string;
|
|
280
|
+
/** Services the pages called that were not running in the sandbox: the review is incomplete, not necessarily the app. */
|
|
281
|
+
missing_services?: {
|
|
282
|
+
address: string;
|
|
283
|
+
requests: number;
|
|
284
|
+
pages: string[];
|
|
285
|
+
found_in?: string;
|
|
286
|
+
hint: string;
|
|
287
|
+
}[];
|
|
259
288
|
start: {
|
|
260
289
|
command: string;
|
|
261
290
|
port: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meiti/healer-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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",
|