recovery-probe 0.4.0 → 0.5.0-preview.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/CHANGELOG.md +9 -0
- package/CONTRIBUTING.md +1 -1
- package/bin/attach.mjs +7 -6
- package/bin/desktop.mjs +2 -2
- package/bin/ipc.mjs +4 -4
- package/bin/observe.mjs +9 -7
- package/bin/recovery-probe.mjs +2 -1
- package/bin/refresh.mjs +9 -7
- package/bin/repair.mjs +1 -1
- package/bin/start.mjs +2 -1
- package/bin/web.mjs +2 -2
- package/dist/fetch-fault.d.mts +21 -0
- package/dist/fetch-fault.mjs +84 -0
- package/{src → dist}/observation-report.mjs +1 -0
- package/{src → dist}/observe.mjs +2 -1
- package/docs/observe.md +1 -1
- package/examples/core-demo.mjs +1 -1
- package/package.json +41 -38
- package/src/fetch-fault.d.mts +0 -22
- package/src/fetch-fault.mjs +0 -96
- /package/{src → dist}/desktop-report.mjs +0 -0
- /package/{src → dist}/desktop.d.mts +0 -0
- /package/{src → dist}/desktop.mjs +0 -0
- /package/{src → dist}/discovery-control.mjs +0 -0
- /package/{src → dist}/discovery-report.mjs +0 -0
- /package/{src → dist}/guided-start.mjs +0 -0
- /package/{src → dist}/http-discover.mjs +0 -0
- /package/{src → dist}/http-observer.mjs +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/index.mjs +0 -0
- /package/{src → dist}/ipc-check.mjs +0 -0
- /package/{src → dist}/ipc-control.mjs +0 -0
- /package/{src → dist}/ipc-discover.mjs +0 -0
- /package/{src → dist}/ipc-inspector.d.mts +0 -0
- /package/{src → dist}/ipc-inspector.mjs +0 -0
- /package/{src → dist}/ipc-observation.mjs +0 -0
- /package/{src → dist}/ipc-probe.cjs +0 -0
- /package/{src → dist}/ipc-probe.d.cts +0 -0
- /package/{src → dist}/observation-kit.mjs +0 -0
- /package/{src → dist}/observe-steps.mjs +0 -0
- /package/{src → dist}/pick-marker.mjs +0 -0
- /package/{src → dist}/refresh-adapters.mjs +0 -0
- /package/{src → dist}/refresh.mjs +0 -0
- /package/{src → dist}/repair-process.mjs +0 -0
- /package/{src → dist}/repair-provider.mjs +0 -0
- /package/{src → dist}/repair.mjs +0 -0
- /package/{src → dist}/report-template.mjs +0 -0
- /package/{src → dist}/report-templates/desktop.html +0 -0
- /package/{src → dist}/report-templates/discovery.html +0 -0
- /package/{src → dist}/report-templates/ipc.html +0 -0
- /package/{src → dist}/report-templates/observation.html +0 -0
- /package/{src → dist}/report-templates/refresh.html +0 -0
- /package/{src → dist}/visibility.mjs +0 -0
- /package/{src → dist}/web.d.mts +0 -0
- /package/{src → dist}/web.mjs +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ All notable changes to Recovery Probe are documented here. The project follows [
|
|
|
4
4
|
|
|
5
5
|
Version 0.2.0 is the first npm release. Earlier 0.1.x revisions were repository-only prototypes.
|
|
6
6
|
|
|
7
|
+
## 0.5.0-preview.1 (2026-10-16)
|
|
8
|
+
|
|
9
|
+
The first step of moving the package to TypeScript.
|
|
10
|
+
|
|
11
|
+
- The package is compiled into `dist/` and published from there. Package exports are unchanged, but `require.resolve('recovery-probe/ipc')` now returns a path ending in `dist/ipc-probe.cjs`. If you stored the old `src/ipc-probe.cjs` path in `RECOVERY_PROBE_IPC_MODULE`, run the command again after upgrading.
|
|
12
|
+
- `createFaultFetch` is written in TypeScript with strict checks, and its declarations are generated from the source. Its return type is exported as `FaultFetch`.
|
|
13
|
+
- TypeScript files are linted with typescript-eslint, so TypeScript is pinned to 6.0, the newest version typescript-eslint supports.
|
|
14
|
+
- A source checkout builds `dist/` during `npm ci`; test, demo and type-check scripts build first.
|
|
15
|
+
|
|
7
16
|
## 0.4.0 (2026-10-16)
|
|
8
17
|
|
|
9
18
|
The first stable release since 0.3.0. It contains 0.4.0-preview.1 to preview.5; their entries below have the details.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -27,7 +27,7 @@ npm run test:repair:electron
|
|
|
27
27
|
|
|
28
28
|
Repair integration tests use a **controlled mock model response** but real apps, fault injection, source changes and reruns. They validate orchestration, not live AI diagnosis quality.
|
|
29
29
|
|
|
30
|
-
Code and JSON are formatted with Prettier (`npm run format`) and linted with ESLint (`npm run lint`); CI fails on either. Functions passed to `page.evaluate` run in the browser: keep them self-contained, and list new in-page modules in `eslint.config.mjs` so they get browser globals. TypeScript checks the JavaScript
|
|
30
|
+
Code and JSON are formatted with Prettier (`npm run format`) and linted with ESLint (`npm run lint`); CI fails on either. Functions passed to `page.evaluate` run in the browser: keep them self-contained, and list new in-page modules in `eslint.config.mjs` so they get browser globals. The package is moving from JavaScript to TypeScript, one module at a time; write new modules as `.mts` (or `.cts` for CommonJS). `npm run build` compiles them into `dist` with strict checks and generated declarations, and copies the remaining JavaScript, hand-written declarations and report templates unchanged. `npm ci` builds once, and every script that runs code builds first, so tests never use a stale `dist`. `npm run typecheck` also checks the JavaScript in `src`, `bin` and `examples` with strict mode off; add JSDoc types where inference is not enough. TypeScript is pinned to 6.0 because typescript-eslint, which lints the TypeScript files, does not support 7 yet. Markdown, HTML fixtures, report templates and workflow files are left as written. Report markup lives in `src/report-templates`: `{{slot}}` takes text and escapes it, `{{{slot}}}` takes markup built with `escapeHtml`. `.gitattributes` keeps LF line endings on every platform so local checks match CI. The repository-wide reformat is listed in `.git-blame-ignore-revs`; run `git config blame.ignoreRevsFile .git-blame-ignore-revs` to skip it in local blame.
|
|
31
31
|
|
|
32
32
|
## Install an unpublished source preview
|
|
33
33
|
|
package/bin/attach.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { readFile, mkdir } from 'node:fs/promises'
|
|
2
2
|
import { resolve } from 'node:path'
|
|
3
|
-
import { connectDesktop, selectDesktopPage } from '../
|
|
4
|
-
import { discoverHttp, httpDiscoveryConfig } from '../
|
|
5
|
-
import { writeDiscoveryReport } from '../
|
|
6
|
-
import { prepareVisibility } from '../
|
|
7
|
-
import { checkDesktop } from '../
|
|
8
|
-
import { writeDesktopReport } from '../
|
|
3
|
+
import { connectDesktop, selectDesktopPage } from '../dist/desktop.mjs'
|
|
4
|
+
import { discoverHttp, httpDiscoveryConfig } from '../dist/http-discover.mjs'
|
|
5
|
+
import { writeDiscoveryReport } from '../dist/discovery-report.mjs'
|
|
6
|
+
import { prepareVisibility } from '../dist/visibility.mjs'
|
|
7
|
+
import { checkDesktop } from '../dist/desktop.mjs'
|
|
8
|
+
import { writeDesktopReport } from '../dist/desktop-report.mjs'
|
|
9
9
|
export async function attachMain(args) {
|
|
10
10
|
const options = {}
|
|
11
11
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -40,6 +40,7 @@ export async function attachMain(args) {
|
|
|
40
40
|
const browser = await connectDesktop(config.cdp)
|
|
41
41
|
try {
|
|
42
42
|
const page = selectDesktopPage(browser, config)
|
|
43
|
+
/** @type {Record<string, any>} */
|
|
43
44
|
let report
|
|
44
45
|
if (options.discover) {
|
|
45
46
|
report = await discoverHttp(page, config)
|
package/bin/desktop.mjs
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
discoverDesktop,
|
|
9
9
|
checkDesktop,
|
|
10
10
|
validateDesktopConfig,
|
|
11
|
-
} from '../
|
|
12
|
-
import { writeDesktopReport } from '../
|
|
11
|
+
} from '../dist/desktop.mjs'
|
|
12
|
+
import { writeDesktopReport } from '../dist/desktop-report.mjs'
|
|
13
13
|
|
|
14
14
|
export async function desktopMain(args) {
|
|
15
15
|
if (!args.length || args.includes('--help')) {
|
package/bin/ipc.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { writeDiscoveryReport } from '../
|
|
1
|
+
import { writeDiscoveryReport } from '../dist/discovery-report.mjs'
|
|
2
2
|
import { readFile, mkdir, writeFile, mkdtemp } from 'node:fs/promises'
|
|
3
3
|
import { resolve, join } from 'node:path'
|
|
4
|
-
import { discoverIpc, discoveryConfig } from '../
|
|
5
|
-
import { checkIpc } from '../
|
|
6
|
-
import { renderTemplate } from '../
|
|
4
|
+
import { discoverIpc, discoveryConfig } from '../dist/ipc-discover.mjs'
|
|
5
|
+
import { checkIpc } from '../dist/ipc-check.mjs'
|
|
6
|
+
import { renderTemplate } from '../dist/report-template.mjs'
|
|
7
7
|
|
|
8
8
|
export async function ipcMain(args) {
|
|
9
9
|
if (!args.length || args.includes('--help')) {
|
package/bin/observe.mjs
CHANGED
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
connectDesktop,
|
|
7
7
|
selectDesktopPage,
|
|
8
8
|
desktopPages,
|
|
9
|
-
} from '../
|
|
10
|
-
import { connectIpcInspector } from '../
|
|
9
|
+
} from '../dist/desktop.mjs'
|
|
10
|
+
import { connectIpcInspector } from '../dist/ipc-inspector.mjs'
|
|
11
11
|
import {
|
|
12
12
|
observationConfig,
|
|
13
13
|
runObservation,
|
|
14
14
|
httpObservationAdapter,
|
|
15
15
|
ipcObservationAdapter,
|
|
16
|
-
} from '../
|
|
16
|
+
} from '../dist/observe.mjs'
|
|
17
17
|
import {
|
|
18
18
|
observationMetadata,
|
|
19
19
|
samplingMetrics,
|
|
@@ -21,8 +21,8 @@ import {
|
|
|
21
21
|
renderObservationReport,
|
|
22
22
|
actionSummary,
|
|
23
23
|
comparisonDigest,
|
|
24
|
-
} from '../
|
|
25
|
-
import { observationSteps, runSteps } from '../
|
|
24
|
+
} from '../dist/observation-report.mjs'
|
|
25
|
+
import { observationSteps, runSteps } from '../dist/observe-steps.mjs'
|
|
26
26
|
|
|
27
27
|
export async function observeMain(args) {
|
|
28
28
|
if (!args.length || args.includes('--help')) {
|
|
@@ -76,9 +76,11 @@ IPC requires the observation-capable development hook. See docs/observe.md.`)
|
|
|
76
76
|
const stop = () => abort.abort()
|
|
77
77
|
process.on('SIGINT', stop)
|
|
78
78
|
process.on('SIGTERM', stop)
|
|
79
|
+
/** @type {Awaited<ReturnType<typeof connectIpcInspector>> | undefined} */
|
|
80
|
+
let control
|
|
81
|
+
/** @type {import('node:readline').Interface | undefined} */
|
|
82
|
+
let input
|
|
79
83
|
let browser,
|
|
80
|
-
control,
|
|
81
|
-
input,
|
|
82
84
|
report,
|
|
83
85
|
pendingMarkers = 0,
|
|
84
86
|
browserVersion = null
|
package/bin/recovery-probe.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFile, writeFile, mkdir } from 'node:fs/promises'
|
|
3
3
|
import { dirname } from 'node:path'
|
|
4
|
-
import { probeRecovery } from '../
|
|
4
|
+
import { probeRecovery } from '../dist/index.mjs'
|
|
5
5
|
import { startDemoServer } from '../examples/demo-server.mjs'
|
|
6
6
|
|
|
7
7
|
const { version } = JSON.parse(
|
|
@@ -130,6 +130,7 @@ async function main() {
|
|
|
130
130
|
const { chromium } = await import('playwright')
|
|
131
131
|
const browser = await chromium.launch({ headless: true })
|
|
132
132
|
let server
|
|
133
|
+
/** @type {Record<string, any>} */
|
|
133
134
|
let report
|
|
134
135
|
try {
|
|
135
136
|
const apps = []
|
package/bin/refresh.mjs
CHANGED
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
connectDesktop,
|
|
6
6
|
selectDesktopPage,
|
|
7
7
|
desktopPages,
|
|
8
|
-
} from '../
|
|
9
|
-
import { connectIpcInspector } from '../
|
|
10
|
-
import { prepareVisibility } from '../
|
|
11
|
-
import { refreshConfig, runRefresh } from '../
|
|
8
|
+
} from '../dist/desktop.mjs'
|
|
9
|
+
import { connectIpcInspector } from '../dist/ipc-inspector.mjs'
|
|
10
|
+
import { prepareVisibility } from '../dist/visibility.mjs'
|
|
11
|
+
import { refreshConfig, runRefresh } from '../dist/refresh.mjs'
|
|
12
12
|
import {
|
|
13
13
|
httpRefreshAdapter,
|
|
14
14
|
ipcRefreshAdapter,
|
|
15
|
-
} from '../
|
|
16
|
-
import { escapeHtml, renderTemplate } from '../
|
|
15
|
+
} from '../dist/refresh-adapters.mjs'
|
|
16
|
+
import { escapeHtml, renderTemplate } from '../dist/report-template.mjs'
|
|
17
17
|
|
|
18
18
|
export async function refreshMain(args) {
|
|
19
19
|
if (args.includes('--help')) {
|
|
@@ -45,7 +45,9 @@ export async function refreshMain(args) {
|
|
|
45
45
|
const onSignal = () => abort.abort()
|
|
46
46
|
process.on('SIGINT', onSignal)
|
|
47
47
|
process.on('SIGTERM', onSignal)
|
|
48
|
-
let browser, control, visibility
|
|
48
|
+
let browser, control, visibility
|
|
49
|
+
/** @type {Record<string, any> | undefined} */
|
|
50
|
+
let report
|
|
49
51
|
try {
|
|
50
52
|
browser = await connectDesktop(c.cdp)
|
|
51
53
|
let page, adapter
|
package/bin/repair.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises'
|
|
2
2
|
import { resolve, dirname } from 'node:path'
|
|
3
|
-
import { prepareRepair, generateRepair, verifyRepair } from '../
|
|
3
|
+
import { prepareRepair, generateRepair, verifyRepair } from '../dist/repair.mjs'
|
|
4
4
|
|
|
5
5
|
export async function repairMain(args) {
|
|
6
6
|
if (!args.length || args.includes('--help')) {
|
package/bin/start.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline/promises'
|
|
2
|
-
import { parseStartArgs, runStart } from '../
|
|
2
|
+
import { parseStartArgs, runStart } from '../dist/guided-start.mjs'
|
|
3
3
|
|
|
4
4
|
export async function startMain(args) {
|
|
5
5
|
if (!args.length || args.includes('--help')) {
|
|
@@ -16,6 +16,7 @@ Local checks only: no source upload or AI repair. Native/Rust/IPC traffic is not
|
|
|
16
16
|
return
|
|
17
17
|
}
|
|
18
18
|
const options = parseStartArgs(args)
|
|
19
|
+
/** @type {import('node:readline/promises').Interface | undefined} */
|
|
19
20
|
let terminal
|
|
20
21
|
const io = {
|
|
21
22
|
interactive: Boolean(process.stdin.isTTY),
|
package/bin/web.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { attachMain } from './attach.mjs'
|
|
|
2
2
|
import { readFile, writeFile, mkdir } from 'node:fs/promises'
|
|
3
3
|
import { resolve, dirname, join } from 'node:path'
|
|
4
4
|
import { createInterface } from 'node:readline/promises'
|
|
5
|
-
import { openWeb, checkWeb, discoverWeb } from '../
|
|
6
|
-
import { writeDesktopReport } from '../
|
|
5
|
+
import { openWeb, checkWeb, discoverWeb } from '../dist/web.mjs'
|
|
6
|
+
import { writeDesktopReport } from '../dist/desktop-report.mjs'
|
|
7
7
|
|
|
8
8
|
export async function webMain(args) {
|
|
9
9
|
if (args.includes('--attach') && !args.includes('--help')) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type FaultKind = 'http-error' | 'connection-failure' | 'invalid-json';
|
|
2
|
+
export interface FetchFaultOptions {
|
|
3
|
+
url: string;
|
|
4
|
+
kind: FaultKind;
|
|
5
|
+
status?: number;
|
|
6
|
+
count?: number;
|
|
7
|
+
method?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface FetchFaultStats {
|
|
10
|
+
kind: FaultKind;
|
|
11
|
+
requested: number;
|
|
12
|
+
applied: number;
|
|
13
|
+
matchingRequests: number;
|
|
14
|
+
}
|
|
15
|
+
export interface FaultFetch {
|
|
16
|
+
fetch: typeof fetch;
|
|
17
|
+
summary(): FetchFaultStats;
|
|
18
|
+
assertApplied(): FetchFaultStats;
|
|
19
|
+
}
|
|
20
|
+
/** Fault-injected fetch for an exact, absolute URL. Each instance is isolated. */
|
|
21
|
+
export declare function createFaultFetch(baseFetch: typeof fetch, options: FetchFaultOptions): FaultFetch;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const kinds = new Set([
|
|
2
|
+
'http-error',
|
|
3
|
+
'connection-failure',
|
|
4
|
+
'invalid-json',
|
|
5
|
+
]);
|
|
6
|
+
// A relative or malformed URL cannot be the absolute target, so it is never matched.
|
|
7
|
+
const absoluteHref = (value) => {
|
|
8
|
+
try {
|
|
9
|
+
return new URL(value).href;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/** Fault-injected fetch for an exact, absolute URL. Each instance is isolated. */
|
|
16
|
+
export function createFaultFetch(baseFetch, options) {
|
|
17
|
+
if (typeof baseFetch !== 'function')
|
|
18
|
+
throw new TypeError('baseFetch must be a function');
|
|
19
|
+
if (typeof options?.url !== 'string')
|
|
20
|
+
throw new TypeError('url must be an absolute HTTP(S) URL');
|
|
21
|
+
const target = new URL(options.url);
|
|
22
|
+
if (!['http:', 'https:'].includes(target.protocol) ||
|
|
23
|
+
target.username ||
|
|
24
|
+
target.password) {
|
|
25
|
+
throw new TypeError('Use an absolute HTTP(S) URL without embedded credentials');
|
|
26
|
+
}
|
|
27
|
+
if (!kinds.has(options.kind))
|
|
28
|
+
throw new TypeError('Unsupported fault kind');
|
|
29
|
+
const count = options.count ?? 1;
|
|
30
|
+
const method = options.method ?? 'GET';
|
|
31
|
+
const status = options.status ?? 503;
|
|
32
|
+
if (!Number.isInteger(count) || count < 1 || count > 20)
|
|
33
|
+
throw new TypeError('count must be an integer from 1 to 20');
|
|
34
|
+
if (!/^[A-Z]+$/.test(method))
|
|
35
|
+
throw new TypeError('method must be an uppercase HTTP method');
|
|
36
|
+
if (options.kind === 'http-error' &&
|
|
37
|
+
(!Number.isInteger(status) || status < 400 || status > 599)) {
|
|
38
|
+
throw new TypeError('HTTP fault status must be from 400 to 599');
|
|
39
|
+
}
|
|
40
|
+
let applied = 0;
|
|
41
|
+
let matchingRequests = 0;
|
|
42
|
+
const summary = () => ({
|
|
43
|
+
kind: options.kind,
|
|
44
|
+
requested: count,
|
|
45
|
+
applied,
|
|
46
|
+
matchingRequests,
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
summary,
|
|
50
|
+
assertApplied() {
|
|
51
|
+
if (applied !== count) {
|
|
52
|
+
throw Object.assign(new Error(`Expected ${count} fault(s); observed ${applied}.`), { code: 'FAULT_NOT_TRIGGERED', stats: summary() });
|
|
53
|
+
}
|
|
54
|
+
return summary();
|
|
55
|
+
},
|
|
56
|
+
async fetch(input, init) {
|
|
57
|
+
const inputUrl = input instanceof Request ? input.url : input;
|
|
58
|
+
const requestMethod = (init?.method ?? (input instanceof Request ? input.method : 'GET')).toUpperCase();
|
|
59
|
+
const signal = init?.signal ?? (input instanceof Request ? input.signal : undefined);
|
|
60
|
+
if (absoluteHref(inputUrl) !== target.href ||
|
|
61
|
+
requestMethod !== method ||
|
|
62
|
+
signal?.aborted) {
|
|
63
|
+
return baseFetch(input, init);
|
|
64
|
+
}
|
|
65
|
+
matchingRequests += 1;
|
|
66
|
+
if (applied >= count)
|
|
67
|
+
return baseFetch(input, init);
|
|
68
|
+
// Reserve before any await so concurrent calls cannot over-inject.
|
|
69
|
+
applied += 1;
|
|
70
|
+
if (options.kind === 'connection-failure')
|
|
71
|
+
throw new TypeError('Injected fetch connection failure');
|
|
72
|
+
if (options.kind === 'http-error') {
|
|
73
|
+
return new Response('{"error":"injected-test-fault"}', {
|
|
74
|
+
status,
|
|
75
|
+
headers: { 'Content-Type': 'application/json' },
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return new Response('{invalid-json', {
|
|
79
|
+
status: 200,
|
|
80
|
+
headers: { 'Content-Type': 'application/json' },
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -145,6 +145,7 @@ export function contentComparisons() {
|
|
|
145
145
|
const completed = (counts) => counts.successes + counts.errors
|
|
146
146
|
return {
|
|
147
147
|
add(event) {
|
|
148
|
+
/** @type {Array<ReturnType<typeof contentComparison> & { followUp?: any }>} */
|
|
148
149
|
const results = []
|
|
149
150
|
if (interval !== event.interval) {
|
|
150
151
|
interval = event.interval
|
package/{src → dist}/observe.mjs
RENAMED
|
@@ -637,8 +637,9 @@ export async function runObservation(
|
|
|
637
637
|
limitation:
|
|
638
638
|
'Observations are not recovery passes or account-isolation verdicts. Cache reuse may be legitimate. Intervals start at capture or an operator marker, not at a proven mount or identity change. HTTP success means a completed 2xx response, not valid JSON or UI correctness. UI changes between samples can be missed. Only hashes, structural counts, allowlisted row states, configured action names and read metadata are stored; hashes are not anonymization.',
|
|
639
639
|
}
|
|
640
|
+
/** @type {Record<string, any> | undefined} */
|
|
641
|
+
let interval
|
|
640
642
|
let lastSnapshot,
|
|
641
|
-
interval,
|
|
642
643
|
started,
|
|
643
644
|
startedEpoch,
|
|
644
645
|
previousSignature,
|
package/docs/observe.md
CHANGED
|
@@ -206,7 +206,7 @@ A document reload/navigation ends capture as incomplete because the renderer sta
|
|
|
206
206
|
|
|
207
207
|
## Supported inspector API
|
|
208
208
|
|
|
209
|
-
Advanced scripts can use `recovery-probe/ipc-inspector`, available since 0.3.0, without importing
|
|
209
|
+
Advanced scripts can use `recovery-probe/ipc-inspector`, available since 0.3.0, without importing internal file paths:
|
|
210
210
|
|
|
211
211
|
```js
|
|
212
212
|
import { randomUUID } from 'node:crypto';
|
package/examples/core-demo.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises'
|
|
2
|
-
import { createFaultFetch, defaultFaults } from '../
|
|
2
|
+
import { createFaultFetch, defaultFaults } from '../dist/index.mjs'
|
|
3
3
|
import { startDemoServer } from './demo-server.mjs'
|
|
4
4
|
import { createProfileController } from './profile-controller.mjs'
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "recovery-probe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-preview.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Test whether web and Electron desktop apps show the right data.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Bojan Kovachki",
|
|
8
8
|
"homepage": "https://github.com/BojanKovachki/recovery-probe#readme",
|
|
9
|
-
"main": "./
|
|
10
|
-
"types": "./
|
|
9
|
+
"main": "./dist/index.mjs",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"types": "./
|
|
14
|
-
"import": "./
|
|
15
|
-
"default": "./
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.mjs",
|
|
15
|
+
"default": "./dist/index.mjs"
|
|
16
16
|
},
|
|
17
17
|
"./fetch": {
|
|
18
|
-
"types": "./
|
|
19
|
-
"import": "./
|
|
20
|
-
"default": "./
|
|
18
|
+
"types": "./dist/fetch-fault.d.mts",
|
|
19
|
+
"import": "./dist/fetch-fault.mjs",
|
|
20
|
+
"default": "./dist/fetch-fault.mjs"
|
|
21
21
|
},
|
|
22
22
|
"./desktop": {
|
|
23
|
-
"types": "./
|
|
24
|
-
"import": "./
|
|
25
|
-
"default": "./
|
|
23
|
+
"types": "./dist/desktop.d.mts",
|
|
24
|
+
"import": "./dist/desktop.mjs",
|
|
25
|
+
"default": "./dist/desktop.mjs"
|
|
26
26
|
},
|
|
27
27
|
"./web": {
|
|
28
|
-
"types": "./
|
|
29
|
-
"import": "./
|
|
30
|
-
"default": "./
|
|
28
|
+
"types": "./dist/web.d.mts",
|
|
29
|
+
"import": "./dist/web.mjs",
|
|
30
|
+
"default": "./dist/web.mjs"
|
|
31
31
|
},
|
|
32
32
|
"./ipc-inspector": {
|
|
33
|
-
"types": "./
|
|
34
|
-
"import": "./
|
|
33
|
+
"types": "./dist/ipc-inspector.d.mts",
|
|
34
|
+
"import": "./dist/ipc-inspector.mjs"
|
|
35
35
|
},
|
|
36
36
|
"./ipc": {
|
|
37
|
-
"types": "./
|
|
38
|
-
"import": "./
|
|
39
|
-
"require": "./
|
|
37
|
+
"types": "./dist/ipc-probe.d.cts",
|
|
38
|
+
"import": "./dist/ipc-probe.cjs",
|
|
39
|
+
"require": "./dist/ipc-probe.cjs"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"bin": {
|
|
43
43
|
"recovery-probe": "bin/recovery-probe.mjs"
|
|
44
44
|
},
|
|
45
45
|
"files": [
|
|
46
|
-
"
|
|
46
|
+
"dist",
|
|
47
47
|
"bin",
|
|
48
48
|
"examples",
|
|
49
49
|
"docs/demo.svg",
|
|
@@ -82,7 +82,8 @@
|
|
|
82
82
|
"globals": "17.13.0",
|
|
83
83
|
"playwright": "1.62.1",
|
|
84
84
|
"prettier": "3.9.10",
|
|
85
|
-
"typescript": "
|
|
85
|
+
"typescript": "6.0.3",
|
|
86
|
+
"typescript-eslint": "8.71.2"
|
|
86
87
|
},
|
|
87
88
|
"repository": {
|
|
88
89
|
"type": "git",
|
|
@@ -93,7 +94,7 @@
|
|
|
93
94
|
},
|
|
94
95
|
"publishConfig": {
|
|
95
96
|
"access": "public",
|
|
96
|
-
"tag": "
|
|
97
|
+
"tag": "next"
|
|
97
98
|
},
|
|
98
99
|
"keywords": [
|
|
99
100
|
"playwright",
|
|
@@ -112,26 +113,28 @@
|
|
|
112
113
|
"cache"
|
|
113
114
|
],
|
|
114
115
|
"scripts": {
|
|
116
|
+
"build": "node scripts/build.mjs",
|
|
117
|
+
"prepare": "npm run build",
|
|
115
118
|
"format": "prettier --write .",
|
|
116
119
|
"format:check": "prettier --check .",
|
|
117
120
|
"lint": "eslint .",
|
|
118
|
-
"typecheck": "tsc -p .",
|
|
121
|
+
"typecheck": "npm run build --silent && tsc -p .",
|
|
119
122
|
"test": "npm run test:core",
|
|
120
|
-
"test:core": "node --test test/fetch-core.test.mjs",
|
|
121
|
-
"test:browser": "node --test test/recovery.integration.test.mjs test/discovery.integration.test.mjs test/discovery-calibration.integration.test.mjs test/attach.integration.test.mjs test/refresh.integration.test.mjs test/observe.integration.test.mjs test/observe-queue.integration.test.mjs",
|
|
122
|
-
"test:package": "node --test test/package.integration.test.mjs",
|
|
123
|
+
"test:core": "npm run build --silent && node --test test/fetch-core.test.mjs",
|
|
124
|
+
"test:browser": "npm run build --silent && node --test test/recovery.integration.test.mjs test/discovery.integration.test.mjs test/discovery-calibration.integration.test.mjs test/attach.integration.test.mjs test/refresh.integration.test.mjs test/observe.integration.test.mjs test/observe-queue.integration.test.mjs",
|
|
125
|
+
"test:package": "npm run build --silent && node --test test/package.integration.test.mjs",
|
|
123
126
|
"test:all": "npm run test:core && npm run test:package && npm run test:browser && npm run test:desktop && npm run test:repair && npm run test:guided && npm run test:ipc && npm run test:ci-example",
|
|
124
|
-
"demo": "node bin/core-demo.mjs",
|
|
125
|
-
"demo:browser": "node bin/recovery-probe.mjs --demo --out artifacts/browser-demo.json",
|
|
127
|
+
"demo": "npm run build --silent && node bin/core-demo.mjs",
|
|
128
|
+
"demo:browser": "npm run build --silent && node bin/recovery-probe.mjs --demo --out artifacts/browser-demo.json",
|
|
126
129
|
"prepublishOnly": "npm run test:core && npm run test:package && npm run test:ipc",
|
|
127
|
-
"test:desktop": "node --test test/desktop.test.mjs",
|
|
128
|
-
"test:desktop:electron": "node --test test/desktop.electron.test.mjs",
|
|
129
|
-
"test:repair": "node --test test/repair.test.mjs test/repair.integration.test.mjs test/web.integration.test.mjs",
|
|
130
|
-
"test:repair:electron": "node --test test/repair.electron.test.mjs",
|
|
131
|
-
"test:guided": "node --test test/guided-start.test.mjs test/guided-start.integration.test.mjs",
|
|
132
|
-
"test:ipc": "node --test test/ipc-probe.test.mjs test/ipc-control.test.mjs test/ipc-observation.test.mjs test/visibility.test.mjs test/refresh.test.mjs test/observe.test.mjs test/observation-report.test.mjs test/report-template.test.mjs test/observe-features.test.mjs",
|
|
133
|
-
"test:ipc:electron": "node --test --test-concurrency=1 test/ipc.electron.test.mjs test/observe.electron.test.mjs test/observe-queue.electron.test.mjs",
|
|
134
|
-
"benchmark:observe": "node scripts/benchmark-observe.mjs",
|
|
135
|
-
"test:ci-example": "node examples/ci/verify.mjs"
|
|
130
|
+
"test:desktop": "npm run build --silent && node --test test/desktop.test.mjs",
|
|
131
|
+
"test:desktop:electron": "npm run build --silent && node --test test/desktop.electron.test.mjs",
|
|
132
|
+
"test:repair": "npm run build --silent && node --test test/repair.test.mjs test/repair.integration.test.mjs test/web.integration.test.mjs",
|
|
133
|
+
"test:repair:electron": "npm run build --silent && node --test test/repair.electron.test.mjs",
|
|
134
|
+
"test:guided": "npm run build --silent && node --test test/guided-start.test.mjs test/guided-start.integration.test.mjs",
|
|
135
|
+
"test:ipc": "npm run build --silent && node --test test/ipc-probe.test.mjs test/ipc-control.test.mjs test/ipc-observation.test.mjs test/visibility.test.mjs test/refresh.test.mjs test/observe.test.mjs test/observation-report.test.mjs test/report-template.test.mjs test/observe-features.test.mjs",
|
|
136
|
+
"test:ipc:electron": "npm run build --silent && node --test --test-concurrency=1 test/ipc.electron.test.mjs test/observe.electron.test.mjs test/observe-queue.electron.test.mjs",
|
|
137
|
+
"benchmark:observe": "npm run build --silent && node scripts/benchmark-observe.mjs",
|
|
138
|
+
"test:ci-example": "npm run build --silent && node examples/ci/verify.mjs"
|
|
136
139
|
}
|
|
137
140
|
}
|
package/src/fetch-fault.d.mts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type FaultKind = 'http-error' | 'connection-failure' | 'invalid-json'
|
|
2
|
-
export interface FetchFaultOptions {
|
|
3
|
-
url: string
|
|
4
|
-
kind: FaultKind
|
|
5
|
-
status?: number
|
|
6
|
-
count?: number
|
|
7
|
-
method?: string
|
|
8
|
-
}
|
|
9
|
-
export interface FetchFaultStats {
|
|
10
|
-
kind: FaultKind
|
|
11
|
-
requested: number
|
|
12
|
-
applied: number
|
|
13
|
-
matchingRequests: number
|
|
14
|
-
}
|
|
15
|
-
export function createFaultFetch(
|
|
16
|
-
baseFetch: typeof fetch,
|
|
17
|
-
options: FetchFaultOptions,
|
|
18
|
-
): {
|
|
19
|
-
fetch: typeof fetch
|
|
20
|
-
summary(): FetchFaultStats
|
|
21
|
-
assertApplied(): FetchFaultStats
|
|
22
|
-
}
|
package/src/fetch-fault.mjs
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
const kinds = new Set(['http-error', 'connection-failure', 'invalid-json'])
|
|
2
|
-
|
|
3
|
-
// A relative or malformed URL cannot be the absolute target, so it is never matched.
|
|
4
|
-
const absoluteHref = (value) => {
|
|
5
|
-
try {
|
|
6
|
-
return new URL(value).href
|
|
7
|
-
} catch {
|
|
8
|
-
return null
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/** Fault-injected fetch for an exact, absolute URL. Each instance is isolated. */
|
|
13
|
-
export function createFaultFetch(baseFetch, options) {
|
|
14
|
-
if (typeof baseFetch !== 'function')
|
|
15
|
-
throw new TypeError('baseFetch must be a function')
|
|
16
|
-
if (typeof options?.url !== 'string')
|
|
17
|
-
throw new TypeError('url must be an absolute HTTP(S) URL')
|
|
18
|
-
const target = new URL(options.url)
|
|
19
|
-
if (
|
|
20
|
-
!['http:', 'https:'].includes(target.protocol) ||
|
|
21
|
-
target.username ||
|
|
22
|
-
target.password
|
|
23
|
-
) {
|
|
24
|
-
throw new TypeError(
|
|
25
|
-
'Use an absolute HTTP(S) URL without embedded credentials',
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
if (!kinds.has(options.kind)) throw new TypeError('Unsupported fault kind')
|
|
29
|
-
const count = options.count ?? 1
|
|
30
|
-
const method = options.method ?? 'GET'
|
|
31
|
-
const status = options.status ?? 503
|
|
32
|
-
if (!Number.isInteger(count) || count < 1 || count > 20)
|
|
33
|
-
throw new TypeError('count must be an integer from 1 to 20')
|
|
34
|
-
if (!/^[A-Z]+$/.test(method))
|
|
35
|
-
throw new TypeError('method must be an uppercase HTTP method')
|
|
36
|
-
if (
|
|
37
|
-
options.kind === 'http-error' &&
|
|
38
|
-
(!Number.isInteger(status) || status < 400 || status > 599)
|
|
39
|
-
) {
|
|
40
|
-
throw new TypeError('HTTP fault status must be from 400 to 599')
|
|
41
|
-
}
|
|
42
|
-
let applied = 0
|
|
43
|
-
let matchingRequests = 0
|
|
44
|
-
const summary = () => ({
|
|
45
|
-
kind: options.kind,
|
|
46
|
-
requested: count,
|
|
47
|
-
applied,
|
|
48
|
-
matchingRequests,
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
summary,
|
|
53
|
-
assertApplied() {
|
|
54
|
-
if (applied !== count) {
|
|
55
|
-
const error = new Error(
|
|
56
|
-
`Expected ${count} fault(s); observed ${applied}.`,
|
|
57
|
-
)
|
|
58
|
-
error.code = 'FAULT_NOT_TRIGGERED'
|
|
59
|
-
error.stats = summary()
|
|
60
|
-
throw error
|
|
61
|
-
}
|
|
62
|
-
return summary()
|
|
63
|
-
},
|
|
64
|
-
async fetch(input, init) {
|
|
65
|
-
const inputUrl = input instanceof Request ? input.url : input
|
|
66
|
-
const requestMethod = (
|
|
67
|
-
init?.method ?? (input instanceof Request ? input.method : 'GET')
|
|
68
|
-
).toUpperCase()
|
|
69
|
-
const signal =
|
|
70
|
-
init?.signal ?? (input instanceof Request ? input.signal : undefined)
|
|
71
|
-
if (
|
|
72
|
-
absoluteHref(inputUrl) !== target.href ||
|
|
73
|
-
requestMethod !== method ||
|
|
74
|
-
signal?.aborted
|
|
75
|
-
) {
|
|
76
|
-
return baseFetch(input, init)
|
|
77
|
-
}
|
|
78
|
-
matchingRequests += 1
|
|
79
|
-
if (applied >= count) return baseFetch(input, init)
|
|
80
|
-
// Reserve before any await so concurrent calls cannot over-inject.
|
|
81
|
-
applied += 1
|
|
82
|
-
if (options.kind === 'connection-failure')
|
|
83
|
-
throw new TypeError('Injected fetch connection failure')
|
|
84
|
-
if (options.kind === 'http-error') {
|
|
85
|
-
return new Response('{"error":"injected-test-fault"}', {
|
|
86
|
-
status,
|
|
87
|
-
headers: { 'Content-Type': 'application/json' },
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
return new Response('{invalid-json', {
|
|
91
|
-
status: 200,
|
|
92
|
-
headers: { 'Content-Type': 'application/json' },
|
|
93
|
-
})
|
|
94
|
-
},
|
|
95
|
-
}
|
|
96
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{src → dist}/index.d.ts
RENAMED
|
File without changes
|
/package/{src → dist}/index.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{src → dist}/repair.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{src → dist}/web.d.mts
RENAMED
|
File without changes
|
/package/{src → dist}/web.mjs
RENAMED
|
File without changes
|