@monkeytestai/monkeytester 0.0.0-stage → 0.5.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/CHANGELOG.md +172 -0
- package/LICENSE +661 -0
- package/NOTICE +12 -0
- package/README.md +196 -2
- package/dist/cli.d.ts +43 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +771 -0
- package/dist/cli.js.map +1 -0
- package/dist/diff/index.d.ts +78 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +119 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/events.d.ts +66 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +77 -0
- package/dist/events.js.map +1 -0
- package/dist/explorer/index.d.ts +54 -0
- package/dist/explorer/index.d.ts.map +1 -0
- package/dist/explorer/index.js +491 -0
- package/dist/explorer/index.js.map +1 -0
- package/dist/explorer/queue.d.ts +94 -0
- package/dist/explorer/queue.d.ts.map +1 -0
- package/dist/explorer/queue.js +277 -0
- package/dist/explorer/queue.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/index.d.ts +79 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +392 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/presets.d.ts +61 -0
- package/dist/llm/presets.d.ts.map +1 -0
- package/dist/llm/presets.js +101 -0
- package/dist/llm/presets.js.map +1 -0
- package/dist/monkey.d.ts +151 -0
- package/dist/monkey.d.ts.map +1 -0
- package/dist/monkey.js +323 -0
- package/dist/monkey.js.map +1 -0
- package/dist/persistence/index.d.ts +118 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +196 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/planner/faults.d.ts +24 -0
- package/dist/planner/faults.d.ts.map +1 -0
- package/dist/planner/faults.js +128 -0
- package/dist/planner/faults.js.map +1 -0
- package/dist/planner/forms.d.ts +33 -0
- package/dist/planner/forms.d.ts.map +1 -0
- package/dist/planner/forms.js +163 -0
- package/dist/planner/forms.js.map +1 -0
- package/dist/planner/index.d.ts +31 -0
- package/dist/planner/index.d.ts.map +1 -0
- package/dist/planner/index.js +250 -0
- package/dist/planner/index.js.map +1 -0
- package/dist/planner/salvage.d.ts +16 -0
- package/dist/planner/salvage.d.ts.map +1 -0
- package/dist/planner/salvage.js +89 -0
- package/dist/planner/salvage.js.map +1 -0
- package/dist/runner/actions.d.ts +85 -0
- package/dist/runner/actions.d.ts.map +1 -0
- package/dist/runner/actions.js +610 -0
- package/dist/runner/actions.js.map +1 -0
- package/dist/runner/evidence.d.ts +37 -0
- package/dist/runner/evidence.d.ts.map +1 -0
- package/dist/runner/evidence.js +122 -0
- package/dist/runner/evidence.js.map +1 -0
- package/dist/runner/http5xx.d.ts +40 -0
- package/dist/runner/http5xx.d.ts.map +1 -0
- package/dist/runner/http5xx.js +189 -0
- package/dist/runner/http5xx.js.map +1 -0
- package/dist/runner/index.d.ts +88 -0
- package/dist/runner/index.d.ts.map +1 -0
- package/dist/runner/index.js +597 -0
- package/dist/runner/index.js.map +1 -0
- package/dist/runner/replay.d.ts +42 -0
- package/dist/runner/replay.d.ts.map +1 -0
- package/dist/runner/replay.js +440 -0
- package/dist/runner/replay.js.map +1 -0
- package/dist/runner/timeout.d.ts +16 -0
- package/dist/runner/timeout.d.ts.map +1 -0
- package/dist/runner/timeout.js +38 -0
- package/dist/runner/timeout.js.map +1 -0
- package/dist/trace/fingerprint.d.ts +78 -0
- package/dist/trace/fingerprint.d.ts.map +1 -0
- package/dist/trace/fingerprint.js +273 -0
- package/dist/trace/fingerprint.js.map +1 -0
- package/dist/trace/serialize.d.ts +15 -0
- package/dist/trace/serialize.d.ts.map +1 -0
- package/dist/trace/serialize.js +86 -0
- package/dist/trace/serialize.js.map +1 -0
- package/dist/triager/index.d.ts +64 -0
- package/dist/triager/index.d.ts.map +1 -0
- package/dist/triager/index.js +301 -0
- package/dist/triager/index.js.map +1 -0
- package/dist/types.d.ts +491 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/verify/index.d.ts +52 -0
- package/dist/verify/index.d.ts.map +1 -0
- package/dist/verify/index.js +140 -0
- package/dist/verify/index.js.map +1 -0
- package/dist/verify/verdict.d.ts +34 -0
- package/dist/verify/verdict.d.ts.map +1 -0
- package/dist/verify/verdict.js +89 -0
- package/dist/verify/verdict.js.map +1 -0
- package/package.json +90 -4
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Crawl-order helpers.
|
|
3
|
+
*
|
|
4
|
+
* The explorer used to walk links FIFO. On a shop homepage the first links
|
|
5
|
+
* are category and product URLs, so a small `maxPages` never reaches the
|
|
6
|
+
* contact form in the header or footer. These helpers keep that BFS, but
|
|
7
|
+
* reserve a few slots for form / help / contact / support / about pages the
|
|
8
|
+
* crawl actually saw. They never invent URLs.
|
|
9
|
+
*
|
|
10
|
+
* Scope is the site. `http://shop.example/` and `https://www.shop.example/help`
|
|
11
|
+
* are the same site. Another subdomain, another host, or another explicit
|
|
12
|
+
* port is not enqueued.
|
|
13
|
+
*/
|
|
14
|
+
const SURFACE_PATH = /(?:^|\/)(contact|contacts|help|support|about|faq|faqs|feedback|quote|enquiries|enquiry|inquiries|inquiry|customer-service|customer-care|get-in-touch|newsletter|subscribe)(?:\/|$|[?#])/i;
|
|
15
|
+
const SURFACE_TEXT = /\b(contact|help|support|about|faq|faqs|feedback|get in touch|customer service|customer care|send (us )?a message|write to us|newsletter|subscribe)\b/i;
|
|
16
|
+
/** Passed into the page so the scraper can keep footer/help links past a long product grid. */
|
|
17
|
+
export const FORM_SURFACE_PATH_SOURCE = SURFACE_PATH.source;
|
|
18
|
+
export const FORM_SURFACE_TEXT_SOURCE = SURFACE_TEXT.source;
|
|
19
|
+
const AUTH_PATH = /\/(login|log-in|signin|sign-in|signup|sign-up|register|otp|verify|forgot|reset-password|password|oauth|sso|auth)(\/|$|\?)/i;
|
|
20
|
+
export function canonicalPageUrl(value) {
|
|
21
|
+
try {
|
|
22
|
+
const url = new URL(value);
|
|
23
|
+
url.hash = '';
|
|
24
|
+
if (url.pathname.endsWith('/') && url.pathname.length > 1) {
|
|
25
|
+
url.pathname = url.pathname.slice(0, -1);
|
|
26
|
+
}
|
|
27
|
+
return url.toString();
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const CRAWL_ASSET = /\.(png|jpe?g|gif|svg|pdf|zip|ico|webp|avif|mp4|webm)(\?.*)?$/i;
|
|
34
|
+
/**
|
|
35
|
+
* Identity of a page inside one crawl. `www` and the apex host are the same
|
|
36
|
+
* page. `http` and `https` are the same page. An explicit port stays
|
|
37
|
+
* distinct, so `:8080` is not `:80`.
|
|
38
|
+
*
|
|
39
|
+
* This is wider than the runner's HTTP 5xx host check on purpose. A start
|
|
40
|
+
* URL of `http://shop.example/` often redirects to `https://www.shop.example/`,
|
|
41
|
+
* and the crawl has to follow that. A 5xx on a different scheme is still a
|
|
42
|
+
* different listener, so the oracle does not use this key.
|
|
43
|
+
*/
|
|
44
|
+
export function crawlPathKey(value) {
|
|
45
|
+
let url;
|
|
46
|
+
try {
|
|
47
|
+
url = new URL(value);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:')
|
|
53
|
+
return undefined;
|
|
54
|
+
const host = url.hostname.replace(/^www\./i, '').toLowerCase();
|
|
55
|
+
const port = url.port ? `:${url.port}` : '';
|
|
56
|
+
let path = url.pathname;
|
|
57
|
+
if (path.length > 1 && path.endsWith('/'))
|
|
58
|
+
path = path.slice(0, -1);
|
|
59
|
+
return `${host}${port}${path}${url.search}`;
|
|
60
|
+
}
|
|
61
|
+
/** True when both URLs are the same path on the same crawl site. */
|
|
62
|
+
export function sameCrawlPage(a, b) {
|
|
63
|
+
if (canonicalPageUrl(a) === canonicalPageUrl(b))
|
|
64
|
+
return true;
|
|
65
|
+
const left = crawlPathKey(a);
|
|
66
|
+
const right = crawlPathKey(b);
|
|
67
|
+
return Boolean(left && left === right);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* True when `href` is an http(s) document on the same site as `scope`.
|
|
71
|
+
* `www` and the apex host match. `http` and `https` match. A non-default
|
|
72
|
+
* port must match. Other subdomains, other hosts, `mailto:`, and common
|
|
73
|
+
* asset types are not crawl targets.
|
|
74
|
+
*/
|
|
75
|
+
export function isSameCrawlSite(href, scope) {
|
|
76
|
+
let target;
|
|
77
|
+
let base;
|
|
78
|
+
try {
|
|
79
|
+
base = new URL(scope);
|
|
80
|
+
target = new URL(href, scope);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (!isHttpProtocol(target) || !isHttpProtocol(base))
|
|
86
|
+
return false;
|
|
87
|
+
if (siteHost(target) !== siteHost(base))
|
|
88
|
+
return false;
|
|
89
|
+
if ((target.port || '') !== (base.port || ''))
|
|
90
|
+
return false;
|
|
91
|
+
if (CRAWL_ASSET.test(target.pathname))
|
|
92
|
+
return false;
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Links the explorer may enqueue. Off-site, asset, and non-http URLs are
|
|
97
|
+
* dropped. The returned URL is canonical. Anchor text is kept so a footer
|
|
98
|
+
* "Help" link is still recognised as a form surface.
|
|
99
|
+
*/
|
|
100
|
+
export function linksOnCrawlSite(links, scope) {
|
|
101
|
+
const accepted = [];
|
|
102
|
+
for (const link of links) {
|
|
103
|
+
if (!link.url)
|
|
104
|
+
continue;
|
|
105
|
+
const url = canonicalPageUrl(link.url);
|
|
106
|
+
if (!isSameCrawlSite(url, scope))
|
|
107
|
+
continue;
|
|
108
|
+
accepted.push(link.text ? { url, text: link.text } : { url });
|
|
109
|
+
}
|
|
110
|
+
return accepted;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* URL to record after navigation. Prefer the URL the browser settled on
|
|
114
|
+
* when the redirect stayed on this site (`http://apex` → `https://www`).
|
|
115
|
+
* An open redirect to another host keeps the URL we asked for, and its
|
|
116
|
+
* links are not followed.
|
|
117
|
+
*/
|
|
118
|
+
export function crawledPageUrl(requested, landed, scope) {
|
|
119
|
+
const settled = canonicalPageUrl(landed);
|
|
120
|
+
if (isSameCrawlSite(settled, scope))
|
|
121
|
+
return settled;
|
|
122
|
+
return canonicalPageUrl(requested);
|
|
123
|
+
}
|
|
124
|
+
const SITE_PATH_PREFIX = 'site-path:';
|
|
125
|
+
/** Record a URL and its scheme/www-insensitive path so the twin is not crawled again. */
|
|
126
|
+
export function rememberVisited(visited, url) {
|
|
127
|
+
const canonical = canonicalPageUrl(url);
|
|
128
|
+
visited.add(canonical);
|
|
129
|
+
const key = crawlPathKey(canonical);
|
|
130
|
+
if (key)
|
|
131
|
+
visited.add(`${SITE_PATH_PREFIX}${key}`);
|
|
132
|
+
}
|
|
133
|
+
export function wasVisited(visited, url) {
|
|
134
|
+
const canonical = canonicalPageUrl(url);
|
|
135
|
+
if (visited.has(url) || visited.has(canonical))
|
|
136
|
+
return true;
|
|
137
|
+
const key = crawlPathKey(canonical);
|
|
138
|
+
return Boolean(key && visited.has(`${SITE_PATH_PREFIX}${key}`));
|
|
139
|
+
}
|
|
140
|
+
function isHttpProtocol(url) {
|
|
141
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
142
|
+
}
|
|
143
|
+
function siteHost(url) {
|
|
144
|
+
return url.hostname.replace(/^www\./i, '').toLowerCase();
|
|
145
|
+
}
|
|
146
|
+
export function looksLikeAuthUrl(value) {
|
|
147
|
+
try {
|
|
148
|
+
const url = new URL(value);
|
|
149
|
+
return AUTH_PATH.test(`${url.pathname}${url.search}`.toLowerCase());
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** Public form / help / contact / about style link. Auth walls are not surfaces. */
|
|
156
|
+
export function isFormSurfaceLink(link) {
|
|
157
|
+
if (!link.url || looksLikeAuthUrl(link.url))
|
|
158
|
+
return false;
|
|
159
|
+
let path = link.url;
|
|
160
|
+
try {
|
|
161
|
+
const url = new URL(link.url);
|
|
162
|
+
path = `${url.pathname}${url.search}`;
|
|
163
|
+
}
|
|
164
|
+
catch { /* use the raw string */ }
|
|
165
|
+
if (SURFACE_PATH.test(path))
|
|
166
|
+
return true;
|
|
167
|
+
return Boolean(link.text && SURFACE_TEXT.test(link.text));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* How many visited pages should be form/help surfaces before the crawl goes
|
|
171
|
+
* back to ordinary BFS. `maxPages` of 1 can only be the start URL.
|
|
172
|
+
*/
|
|
173
|
+
export function formReserveCount(maxPages) {
|
|
174
|
+
if (!Number.isFinite(maxPages) || maxPages <= 1)
|
|
175
|
+
return 0;
|
|
176
|
+
return Math.min(3, Math.max(1, Math.floor(maxPages / 3)));
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Keep every form-surface link (so a footer "Help" past a long product grid
|
|
180
|
+
* is not dropped) plus the first `cap` ordinary links, in document order.
|
|
181
|
+
*/
|
|
182
|
+
export function selectOutboundLinks(links, cap = 80) {
|
|
183
|
+
const seen = new Set();
|
|
184
|
+
const unique = [];
|
|
185
|
+
for (const link of links) {
|
|
186
|
+
if (!link.url || seen.has(link.url))
|
|
187
|
+
continue;
|
|
188
|
+
seen.add(link.url);
|
|
189
|
+
unique.push(link);
|
|
190
|
+
}
|
|
191
|
+
const surfaceUrls = new Set(unique.filter(link => isFormSurfaceLink(link)).map(link => link.url));
|
|
192
|
+
const ordinary = unique.filter(link => !surfaceUrls.has(link.url));
|
|
193
|
+
const keptOrdinary = new Set(ordinary.slice(0, Math.max(0, cap)).map(link => link.url));
|
|
194
|
+
return unique.filter(link => surfaceUrls.has(link.url) || keptOrdinary.has(link.url));
|
|
195
|
+
}
|
|
196
|
+
/** Index to visit next. Form surfaces jump the queue until the reserve is filled. */
|
|
197
|
+
export function pickNextCrawlUrl(queue, opts) {
|
|
198
|
+
if (queue.length === 0)
|
|
199
|
+
return -1;
|
|
200
|
+
if (opts.pagesVisited >= opts.maxPages)
|
|
201
|
+
return -1;
|
|
202
|
+
if (opts.surfaceVisited < formReserveCount(opts.maxPages)) {
|
|
203
|
+
const surface = queue.findIndex(item => item.surface);
|
|
204
|
+
if (surface >= 0)
|
|
205
|
+
return surface;
|
|
206
|
+
}
|
|
207
|
+
return 0;
|
|
208
|
+
}
|
|
209
|
+
export function enqueueLinks(queue, visited, links, authUrlsQueued, authLimit = 1) {
|
|
210
|
+
let authQueued = authUrlsQueued;
|
|
211
|
+
for (const link of links) {
|
|
212
|
+
const url = canonicalPageUrl(link.url);
|
|
213
|
+
if (!url || wasVisited(visited, url) || queueHas(queue, url))
|
|
214
|
+
continue;
|
|
215
|
+
const auth = looksLikeAuthUrl(url);
|
|
216
|
+
if (auth) {
|
|
217
|
+
if (authQueued >= authLimit)
|
|
218
|
+
continue;
|
|
219
|
+
authQueued += 1;
|
|
220
|
+
}
|
|
221
|
+
queue.push({ url, surface: isFormSurfaceLink({ url, text: link.text }) });
|
|
222
|
+
}
|
|
223
|
+
return authQueued;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Pure stand-in for the explorer loop. `edges` maps a visited URL to the
|
|
227
|
+
* links discovered on that page. Off-site links are dropped with the same
|
|
228
|
+
* site rule `explore` uses, so an `http://` apex start whose anchors were
|
|
229
|
+
* rewritten to `https://www` still reaches `/help`.
|
|
230
|
+
*/
|
|
231
|
+
export function planCrawlOrder(input) {
|
|
232
|
+
const start = canonicalPageUrl(input.startUrl);
|
|
233
|
+
const queue = [{ url: start, surface: isFormSurfaceLink({ url: start }) }];
|
|
234
|
+
const visited = new Set();
|
|
235
|
+
const order = [];
|
|
236
|
+
let surfaceVisited = 0;
|
|
237
|
+
let authUrlsQueued = 0;
|
|
238
|
+
while (order.length < input.maxPages) {
|
|
239
|
+
const index = pickNextCrawlUrl(queue, {
|
|
240
|
+
pagesVisited: order.length,
|
|
241
|
+
maxPages: input.maxPages,
|
|
242
|
+
surfaceVisited,
|
|
243
|
+
});
|
|
244
|
+
if (index < 0)
|
|
245
|
+
break;
|
|
246
|
+
const next = queue.splice(index, 1)[0];
|
|
247
|
+
if (!next || wasVisited(visited, next.url))
|
|
248
|
+
continue;
|
|
249
|
+
rememberVisited(visited, next.url);
|
|
250
|
+
order.push(next.url);
|
|
251
|
+
if (isFormSurfaceLink({ url: next.url }))
|
|
252
|
+
surfaceVisited += 1;
|
|
253
|
+
const discovered = linksOnCrawlSite(edgesFor(input.edges, next.url), input.startUrl);
|
|
254
|
+
authUrlsQueued = enqueueLinks(queue, visited, selectOutboundLinks(discovered), authUrlsQueued);
|
|
255
|
+
}
|
|
256
|
+
return order;
|
|
257
|
+
}
|
|
258
|
+
function edgesFor(edges, url) {
|
|
259
|
+
if (edges[url])
|
|
260
|
+
return edges[url];
|
|
261
|
+
const canonical = canonicalPageUrl(url);
|
|
262
|
+
if (edges[canonical])
|
|
263
|
+
return edges[canonical];
|
|
264
|
+
const key = crawlPathKey(url);
|
|
265
|
+
if (!key)
|
|
266
|
+
return [];
|
|
267
|
+
for (const [candidate, links] of Object.entries(edges)) {
|
|
268
|
+
if (crawlPathKey(candidate) === key)
|
|
269
|
+
return links;
|
|
270
|
+
}
|
|
271
|
+
return [];
|
|
272
|
+
}
|
|
273
|
+
function queueHas(queue, url) {
|
|
274
|
+
const key = crawlPathKey(url);
|
|
275
|
+
return queue.some(item => item.url === url || (key !== undefined && crawlPathKey(item.url) === key));
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js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I,KAAK,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,KAAK,CAAC,SAAS,CAAC;QAAE,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvD,IAAI,YAAY,CAAC,SAAS,CAAC,KAAK,GAAG;YAAE,OAAO,KAAK,CAAC;IACpD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,QAAQ,CAAC,KAAuB,EAAE,GAAW;IACpD,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG,KAAK,SAAS,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACvG,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for @monkeytestai/monkeytester.
|
|
3
|
+
*
|
|
4
|
+
* Consumers should import from here, not from internal subpaths, so we have
|
|
5
|
+
* room to refactor the internals.
|
|
6
|
+
*/
|
|
7
|
+
export { Monkey, resolveMonkeyOracles } from './monkey.js';
|
|
8
|
+
export type { MonkeyConfig, ExploreAndPlanOptions, ExecuteOptions, ExecuteFromPlanOptions, } from './monkey.js';
|
|
9
|
+
export { diffRuns, summariseDiff } from './diff/index.js';
|
|
10
|
+
export type { RunDiff, BugDiffEntry, RunDiffStatus, } from './diff/index.js';
|
|
11
|
+
export { savePlan, loadPlan, saveRun, loadRun, listRuns, PLAN_FILE_SCHEMA, RUN_FILE_SCHEMA, } from './persistence/index.js';
|
|
12
|
+
export type { StoredPlan, StoredRun } from './persistence/index.js';
|
|
13
|
+
export { explore } from './explorer/index.js';
|
|
14
|
+
export type { ExploreOptions } from './explorer/index.js';
|
|
15
|
+
export { plan, groundedTestPlan } from './planner/index.js';
|
|
16
|
+
export type { PlannerOptions } from './planner/index.js';
|
|
17
|
+
export { runPlan } from './runner/index.js';
|
|
18
|
+
export type { RunnerOptions, RunnerEvent } from './runner/index.js';
|
|
19
|
+
export { replayTraces } from './runner/replay.js';
|
|
20
|
+
export type { ReplayOptions } from './runner/replay.js';
|
|
21
|
+
export { verifyBugs, aggregateVerdict, classifyAttempt, verifyExitCode } from './verify/index.js';
|
|
22
|
+
export type { VerifyOptions, VerifyReport, BugVerdict, VerifyAttempt, VerifyVerdict } from './verify/index.js';
|
|
23
|
+
export { triage, triagePolished } from './triager/index.js';
|
|
24
|
+
export type { TriageOptions } from './triager/index.js';
|
|
25
|
+
export { bugFingerprint, bugMatchesFingerprint } from './diff/index.js';
|
|
26
|
+
export { fingerprintFailure, fingerprintFromParts, legacyFingerprint, normaliseErrorSignal, normaliseLocation, normaliseLabel, failureCategory, } from './trace/fingerprint.js';
|
|
27
|
+
export type { FingerprintInput } from './trace/fingerprint.js';
|
|
28
|
+
export { serializeTrace, serializeTraceStep, bugTracePrefix } from './trace/serialize.js';
|
|
29
|
+
export { createLLM } from './llm/index.js';
|
|
30
|
+
export type { LLM, GenerateJSONOptions, LLMUsage } from './llm/index.js';
|
|
31
|
+
export { autoLLMConfig, detectProviderFromEnv, CHEAP_FAST_MODEL, SMART_MODEL, } from './llm/presets.js';
|
|
32
|
+
export type { AutoLLMOptions } from './llm/presets.js';
|
|
33
|
+
export { EventBus, noopBus } from './events.js';
|
|
34
|
+
export type { LiveEvent, LiveEventType, LiveEventListener, LivePhase } from './events.js';
|
|
35
|
+
export type { LLMProvider, LLMConfig, LLMUsageEvent, LLMUsageSink, MonkeyLLMConfig, SiteMap, SiteMapPage, SiteMapForm, SiteMapFormInput, SiteMapControl, SiteMapInteractive, TestPlan, TestFlow, TestStep, FlowKind, StepResult, StepStatus, FlowResult, FlowStatus, RunResult, BugReport, BugEvidence, BugTrace, FlowTrace, TraceStep, TraceLocator, TraceTool, TraceLocatorStrategy, TraceResolution, FingerprintParts, ConsoleErrorEvidence, NetworkFailureEvidence, MonkeyEvent, } from './types.js';
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EACV,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC1D,YAAY,EACV,OAAO,EACP,YAAY,EACZ,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC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Y,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,YAAY,EACZ,eAAe,EACf,OAAO,EACP,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,SAAS,EACT,SAAS,EACT,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,WAAW,GACZ,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for @monkeytestai/monkeytester.
|
|
3
|
+
*
|
|
4
|
+
* Consumers should import from here, not from internal subpaths, so we have
|
|
5
|
+
* room to refactor the internals.
|
|
6
|
+
*/
|
|
7
|
+
export { Monkey, resolveMonkeyOracles } from './monkey.js';
|
|
8
|
+
export { diffRuns, summariseDiff } from './diff/index.js';
|
|
9
|
+
export { savePlan, loadPlan, saveRun, loadRun, listRuns, PLAN_FILE_SCHEMA, RUN_FILE_SCHEMA, } from './persistence/index.js';
|
|
10
|
+
export { explore } from './explorer/index.js';
|
|
11
|
+
export { plan, groundedTestPlan } from './planner/index.js';
|
|
12
|
+
export { runPlan } from './runner/index.js';
|
|
13
|
+
export { replayTraces } from './runner/replay.js';
|
|
14
|
+
export { verifyBugs, aggregateVerdict, classifyAttempt, verifyExitCode } from './verify/index.js';
|
|
15
|
+
export { triage, triagePolished } from './triager/index.js';
|
|
16
|
+
export { bugFingerprint, bugMatchesFingerprint } from './diff/index.js';
|
|
17
|
+
export { fingerprintFailure, fingerprintFromParts, legacyFingerprint, normaliseErrorSignal, normaliseLocation, normaliseLabel, failureCategory, } from './trace/fingerprint.js';
|
|
18
|
+
export { serializeTrace, serializeTraceStep, bugTracePrefix } from './trace/serialize.js';
|
|
19
|
+
export { createLLM } from './llm/index.js';
|
|
20
|
+
export { autoLLMConfig, detectProviderFromEnv, CHEAP_FAST_MODEL, SMART_MODEL, } from './llm/presets.js';
|
|
21
|
+
export { EventBus, noopBus } from './events.js';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAQ3D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAO1D,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGlG,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE1F,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-provider LLM wrapper used by every phase of the engine.
|
|
3
|
+
*
|
|
4
|
+
* Supported providers:
|
|
5
|
+
* - openai — OpenAI Chat Completions (JSON mode + auto prompt cache)
|
|
6
|
+
* - gemini — Google Generative AI (JSON response MIME)
|
|
7
|
+
* - anthropic — Anthropic Messages API (JSON via prompt + parse,
|
|
8
|
+
* with explicit `cache_control` breakpoints)
|
|
9
|
+
* - mistral — Mistral Chat Completions (JSON object format)
|
|
10
|
+
* - groq — Groq (OpenAI-compatible, very fast Llama / Mixtral)
|
|
11
|
+
* - openai_compatible — Any OpenAI-compatible endpoint via baseURL
|
|
12
|
+
* (Ollama, vLLM, LM Studio, OpenRouter, Together, …)
|
|
13
|
+
*
|
|
14
|
+
* Why a wrapper:
|
|
15
|
+
* - Each phase (explorer / planner / runner / triager) can pick its own
|
|
16
|
+
* provider+model, so teams can mix a smart planner with a cheap runner.
|
|
17
|
+
* - All calls go through `generateJSON()` which parses + validates with zod,
|
|
18
|
+
* so a flaky LLM response never crashes a downstream phase.
|
|
19
|
+
* - Provider-specific quirks (markdown fences, missing JSON mode, …) are
|
|
20
|
+
* handled here once instead of in every prompt site.
|
|
21
|
+
*
|
|
22
|
+
* Prompt caching:
|
|
23
|
+
* - Callers indicate how a prompt is structured via `cacheable` (the long
|
|
24
|
+
* stable prefix) + `prompt` (the per-call dynamic suffix). Providers that
|
|
25
|
+
* support caching see real savings on repeat runs (planner against the
|
|
26
|
+
* same site, triager polishing the same evidence corpus).
|
|
27
|
+
* - Token + cache metrics are returned through `LLM.lastUsage` so SaaS hosts
|
|
28
|
+
* can render "saved $X via prompt cache" in their UI.
|
|
29
|
+
*/
|
|
30
|
+
import { z } from 'zod';
|
|
31
|
+
import type { LLMConfig } from '../types.js';
|
|
32
|
+
export interface GenerateJSONOptions<T> {
|
|
33
|
+
/** System-level guidance prepended to every prompt. */
|
|
34
|
+
system?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The long, stable, *cacheable* prefix of the user prompt.
|
|
37
|
+
*
|
|
38
|
+
* This is the part that is identical across many calls — the system context,
|
|
39
|
+
* the site map, the evidence corpus. Providers that support prompt caching
|
|
40
|
+
* (OpenAI auto, Anthropic ephemeral) use this string as the cache key. Keep
|
|
41
|
+
* it well above 1k tokens for OpenAI auto-cache hits.
|
|
42
|
+
*
|
|
43
|
+
* If omitted, only `prompt` is sent and no caching applies.
|
|
44
|
+
*/
|
|
45
|
+
cacheable?: string;
|
|
46
|
+
/** The dynamic per-call user prompt. Concatenated after `cacheable`. */
|
|
47
|
+
prompt: string;
|
|
48
|
+
/** Zod schema the response is parsed against. Throws on mismatch. */
|
|
49
|
+
schema: z.ZodType<T>;
|
|
50
|
+
/** Free-form key for log/error context (e.g. "explorer.summarisePage"). */
|
|
51
|
+
label?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Token usage + cache stats from the last `generateJSON` call. Populated
|
|
55
|
+
* provider-by-provider where the API exposes it. Read by hosts that want to
|
|
56
|
+
* render "you saved $X by hitting the prompt cache" in their dashboards.
|
|
57
|
+
*/
|
|
58
|
+
export interface LLMUsage {
|
|
59
|
+
/** Total input tokens billed for this call (provider-reported). */
|
|
60
|
+
inputTokens?: number;
|
|
61
|
+
/** Of `inputTokens`, how many were served from the prompt cache. */
|
|
62
|
+
cachedInputTokens?: number;
|
|
63
|
+
/** Output / completion tokens. */
|
|
64
|
+
outputTokens?: number;
|
|
65
|
+
/** Whether this call wrote new content into the prompt cache. */
|
|
66
|
+
cacheWrite?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface LLM {
|
|
69
|
+
readonly providerLabel: string;
|
|
70
|
+
/**
|
|
71
|
+
* Token + cache stats from the last `generateJSON` call.
|
|
72
|
+
* `undefined` until at least one call has completed; `{}` when the provider
|
|
73
|
+
* does not expose usage.
|
|
74
|
+
*/
|
|
75
|
+
readonly lastUsage?: LLMUsage;
|
|
76
|
+
generateJSON<T>(opts: GenerateJSONOptions<T>): Promise<T>;
|
|
77
|
+
}
|
|
78
|
+
export declare function createLLM(config: LLMConfig): LLM;
|
|
79
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAMH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,aAAa,CAAC;AAE3D,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,GAAG;IAClB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC;IAC9B,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC3D;AAgZD,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,GAAG,CA6ChD"}
|