agenticreplay 0.1.11 → 0.1.13
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 +6 -0
- package/node_modules/@agenticreplay/adapters/package.json +6 -6
- package/node_modules/@agenticreplay/core/package.json +3 -3
- package/node_modules/@agenticreplay/fs-capture/dist/capture.d.ts +8 -0
- package/node_modules/@agenticreplay/fs-capture/dist/capture.d.ts.map +1 -1
- package/node_modules/@agenticreplay/fs-capture/dist/capture.js +7 -1
- package/node_modules/@agenticreplay/fs-capture/dist/capture.js.map +1 -1
- package/node_modules/@agenticreplay/fs-capture/package.json +2 -2
- package/node_modules/@agenticreplay/mcp-shim/dist/cli.js +0 -0
- package/node_modules/@agenticreplay/mcp-shim/package.json +1 -1
- package/node_modules/@agenticreplay/node-instrument/package.json +1 -1
- package/node_modules/@agenticreplay/plugin-api/dist/index.d.ts +1 -0
- package/node_modules/@agenticreplay/plugin-api/dist/index.d.ts.map +1 -1
- package/node_modules/@agenticreplay/plugin-api/dist/index.js +1 -0
- package/node_modules/@agenticreplay/plugin-api/dist/index.js.map +1 -1
- package/node_modules/@agenticreplay/plugin-api/dist/memory-review.d.ts +35 -0
- package/node_modules/@agenticreplay/plugin-api/dist/memory-review.d.ts.map +1 -0
- package/node_modules/@agenticreplay/plugin-api/dist/memory-review.js +2 -0
- package/node_modules/@agenticreplay/plugin-api/dist/memory-review.js.map +1 -0
- package/node_modules/@agenticreplay/plugin-api/package.json +1 -1
- package/node_modules/@agenticreplay/providers/package.json +3 -3
- package/node_modules/@agenticreplay/proxy/dist/request-body.d.ts +9 -0
- package/node_modules/@agenticreplay/proxy/dist/request-body.d.ts.map +1 -0
- package/node_modules/@agenticreplay/proxy/dist/request-body.js +65 -0
- package/node_modules/@agenticreplay/proxy/dist/request-body.js.map +1 -0
- package/node_modules/@agenticreplay/proxy/dist/server.d.ts +3 -0
- package/node_modules/@agenticreplay/proxy/dist/server.d.ts.map +1 -1
- package/node_modules/@agenticreplay/proxy/dist/server.js +121 -124
- package/node_modules/@agenticreplay/proxy/dist/server.js.map +1 -1
- package/node_modules/@agenticreplay/proxy/package.json +5 -5
- package/node_modules/@agenticreplay/schema/package.json +1 -1
- package/node_modules/@agenticreplay/shell-shim/package.json +3 -3
- package/node_modules/@agenticreplay/viewer/dist/index.d.ts +1 -0
- package/node_modules/@agenticreplay/viewer/dist/index.d.ts.map +1 -1
- package/node_modules/@agenticreplay/viewer/dist/index.js +1 -0
- package/node_modules/@agenticreplay/viewer/dist/index.js.map +1 -1
- package/node_modules/@agenticreplay/viewer/dist/review.d.ts +41 -0
- package/node_modules/@agenticreplay/viewer/dist/review.d.ts.map +1 -0
- package/node_modules/@agenticreplay/viewer/dist/review.js +206 -0
- package/node_modules/@agenticreplay/viewer/dist/review.js.map +1 -0
- package/node_modules/@agenticreplay/viewer/package.json +2 -2
- package/node_modules/fast-uri/.github/workflows/release.yml +35 -0
- package/node_modules/fast-uri/README.md +8 -0
- package/node_modules/fast-uri/index.js +98 -18
- package/node_modules/fast-uri/lib/utils.js +52 -0
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/host-delimiter-security.test.js +94 -0
- package/node_modules/fast-uri/test/relative-normalization-security.test.js +156 -0
- package/node_modules/fast-uri/test/reserved-path-normalization.test.js +32 -4
- package/node_modules/fast-uri/test/scheme-validation.test.js +53 -14
- package/package.json +12 -12
- package/packages/cli/dist/args.d.ts.map +1 -1
- package/packages/cli/dist/args.js +1 -0
- package/packages/cli/dist/args.js.map +1 -1
- package/packages/cli/dist/cli.js +0 -0
- package/packages/cli/dist/commands/attach.js +1 -0
- package/packages/cli/dist/commands/attach.js.map +1 -1
- package/packages/cli/dist/commands/record.d.ts.map +1 -1
- package/packages/cli/dist/commands/record.js +44 -15
- package/packages/cli/dist/commands/record.js.map +1 -1
- package/packages/cli/dist/commands/review.d.ts +4 -0
- package/packages/cli/dist/commands/review.d.ts.map +1 -0
- package/packages/cli/dist/commands/review.js +54 -0
- package/packages/cli/dist/commands/review.js.map +1 -0
- package/packages/cli/dist/config.d.ts +3 -0
- package/packages/cli/dist/config.d.ts.map +1 -1
- package/packages/cli/dist/config.js.map +1 -1
- package/packages/cli/dist/exchange-events.d.ts +2 -0
- package/packages/cli/dist/exchange-events.d.ts.map +1 -1
- package/packages/cli/dist/exchange-events.js +36 -24
- package/packages/cli/dist/exchange-events.js.map +1 -1
- package/packages/cli/dist/flags.d.ts.map +1 -1
- package/packages/cli/dist/flags.js +2 -0
- package/packages/cli/dist/flags.js.map +1 -1
- package/packages/cli/dist/fs-events.d.ts.map +1 -1
- package/packages/cli/dist/fs-events.js +16 -0
- package/packages/cli/dist/fs-events.js.map +1 -1
- package/packages/cli/dist/main.d.ts.map +1 -1
- package/packages/cli/dist/main.js +6 -0
- package/packages/cli/dist/main.js.map +1 -1
- package/packages/cli/dist/out.d.ts +6 -0
- package/packages/cli/dist/out.d.ts.map +1 -1
- package/packages/cli/dist/out.js +50 -5
- package/packages/cli/dist/out.js.map +1 -1
- package/packages/cli/dist/review-coordinator.d.ts +16 -0
- package/packages/cli/dist/review-coordinator.d.ts.map +1 -0
- package/packages/cli/dist/review-coordinator.js +141 -0
- package/packages/cli/dist/review-coordinator.js.map +1 -0
- package/packages/cli/dist/review-store.d.ts +24 -0
- package/packages/cli/dist/review-store.d.ts.map +1 -0
- package/packages/cli/dist/review-store.js +159 -0
- package/packages/cli/dist/review-store.js.map +1 -0
- package/packages/cli/dist/snapshot.d.ts +2 -0
- package/packages/cli/dist/snapshot.d.ts.map +1 -1
- package/packages/cli/dist/snapshot.js.map +1 -1
- package/packages/cli/dist/tls-capture.d.ts.map +1 -1
- package/packages/cli/dist/tls-capture.js +4 -3
- package/packages/cli/dist/tls-capture.js.map +1 -1
- package/packages/cli/package.json +11 -11
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface ReviewView {
|
|
2
|
+
runId: string;
|
|
3
|
+
repository: string;
|
|
4
|
+
exitCode: number;
|
|
5
|
+
events: number;
|
|
6
|
+
capture: string;
|
|
7
|
+
captureIssues: readonly string[];
|
|
8
|
+
state: 'queued' | 'empty' | 'preparation_failed' | 'awaiting_review' | 'declined';
|
|
9
|
+
message: string;
|
|
10
|
+
proposal?: {
|
|
11
|
+
title: string;
|
|
12
|
+
body: string;
|
|
13
|
+
evidence: readonly {
|
|
14
|
+
sequence: number;
|
|
15
|
+
kind: string;
|
|
16
|
+
description: string;
|
|
17
|
+
}[];
|
|
18
|
+
revision: number;
|
|
19
|
+
digest: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export type ReviewAction = {
|
|
23
|
+
revision: number;
|
|
24
|
+
digest: string;
|
|
25
|
+
} & ({
|
|
26
|
+
kind: 'revise';
|
|
27
|
+
body: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'decline';
|
|
30
|
+
});
|
|
31
|
+
interface ReviewController {
|
|
32
|
+
read(): Promise<ReviewView>;
|
|
33
|
+
decide(action: ReviewAction): Promise<ReviewView>;
|
|
34
|
+
}
|
|
35
|
+
/** Owns a single loopback review. No write-to-memory route is registered here. */
|
|
36
|
+
export declare function serveMemoryReview(controller: ReviewController): Promise<{
|
|
37
|
+
url: string;
|
|
38
|
+
close: () => Promise<void>;
|
|
39
|
+
}>;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../src/review.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,KAAK,EAAE,QAAQ,GAAG,OAAO,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,UAAU,CAAC;IAClF,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,SAAS;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC7E,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,CAChE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CACvD,CAAC;AAEF,UAAU,gBAAgB;IACxB,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5B,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACnD;AAkJD,kFAAkF;AAClF,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,gBAAgB;;;GAsEnE"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { createServer } from 'node:http';
|
|
3
|
+
import { escapeHtml } from './html.js';
|
|
4
|
+
function reviewMain(view, csrf) {
|
|
5
|
+
const escape = escapeHtml;
|
|
6
|
+
const proposal = view.proposal;
|
|
7
|
+
return `<main>
|
|
8
|
+
<h1 tabindex="-1">Memory review</h1>
|
|
9
|
+
<p role="status">${escape(view.message)}</p>
|
|
10
|
+
<dl>
|
|
11
|
+
<dt>Recording</dt><dd>${escape(view.runId)} · whole recording (${escape(view.events)} events)</dd>
|
|
12
|
+
<dt>Repository scope</dt><dd>${escape(view.repository)}</dd>
|
|
13
|
+
<dt>Process exit</dt><dd>${escape(view.exitCode)} · task outcome unverified</dd>
|
|
14
|
+
<dt>Capture</dt><dd>${escape([view.capture, ...view.captureIssues].join(' · '))}</dd>
|
|
15
|
+
</dl>
|
|
16
|
+
${proposal
|
|
17
|
+
? `
|
|
18
|
+
<h2>${escape(proposal.title)}</h2>
|
|
19
|
+
<details><summary>Evidence and limitations</summary>
|
|
20
|
+
<ul>${proposal.evidence.map((e) => `<li>Event ${escape(e.sequence)} · ${escape(e.kind)} · ${escape(e.description)}</li>`).join('')}</ul>
|
|
21
|
+
<p>Revision ${escape(proposal.revision)} · <code>${escape(proposal.digest)}</code></p>
|
|
22
|
+
</details>
|
|
23
|
+
<form method="post">
|
|
24
|
+
<input type="hidden" name="csrf" value="${escape(csrf)}">
|
|
25
|
+
<input type="hidden" name="revision" value="${escape(proposal.revision)}">
|
|
26
|
+
<input type="hidden" name="digest" value="${escape(proposal.digest)}">
|
|
27
|
+
<label for="review-body">Proposed memory</label>
|
|
28
|
+
<textarea id="review-body" name="body" rows="8" maxlength="6000" required>
|
|
29
|
+
${escape(proposal.body)}</textarea>
|
|
30
|
+
<p id="save-status">Saving requires a Kiokuko connection with a verified approval flow.</p>
|
|
31
|
+
<div class="actions">
|
|
32
|
+
<button type="submit" name="action" value="revise">Preview revision</button>
|
|
33
|
+
<button type="button" disabled aria-describedby="save-status">Save to Kiokuko</button>
|
|
34
|
+
<button type="submit" name="action" value="decline" formnovalidate>Discard review</button>
|
|
35
|
+
</div>
|
|
36
|
+
</form>`
|
|
37
|
+
: view.state === 'preparation_failed'
|
|
38
|
+
? '<a href="">Retry review</a>'
|
|
39
|
+
: ''}
|
|
40
|
+
<p id="feedback" role="status"></p>
|
|
41
|
+
</main>`;
|
|
42
|
+
}
|
|
43
|
+
const script = `
|
|
44
|
+
let busy = false;
|
|
45
|
+
function dirty() {
|
|
46
|
+
const body = document.querySelector('textarea');
|
|
47
|
+
return body && body.value !== body.defaultValue;
|
|
48
|
+
}
|
|
49
|
+
window.addEventListener('beforeunload', event => {
|
|
50
|
+
if (dirty()) event.preventDefault();
|
|
51
|
+
});
|
|
52
|
+
document.addEventListener('submit', async event => {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
if (busy || !event.submitter) return;
|
|
55
|
+
const form = event.target;
|
|
56
|
+
const submitter = event.submitter;
|
|
57
|
+
const action = submitter.value;
|
|
58
|
+
if (action === 'decline' && !window.confirm('Discard this review? It will no longer be offered for this recording.')) return;
|
|
59
|
+
const fields = new URLSearchParams(new FormData(form, submitter));
|
|
60
|
+
if (action === 'decline') fields.delete('body');
|
|
61
|
+
const controls = Array.from(form.elements).filter(control => !control.disabled);
|
|
62
|
+
const feedback = document.querySelector('#feedback');
|
|
63
|
+
busy = true;
|
|
64
|
+
form.setAttribute('aria-busy', 'true');
|
|
65
|
+
controls.forEach(control => { control.disabled = true; });
|
|
66
|
+
feedback.textContent = 'Updating review…';
|
|
67
|
+
try {
|
|
68
|
+
const response = await fetch(location.pathname, {
|
|
69
|
+
method: 'POST', body: fields, mode: 'same-origin',
|
|
70
|
+
credentials: 'omit', redirect: 'error', signal: AbortSignal.timeout(12000)
|
|
71
|
+
});
|
|
72
|
+
if (!response.ok) {
|
|
73
|
+
feedback.textContent = await response.text();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const next = new DOMParser().parseFromString(await response.text(), 'text/html').querySelector('main');
|
|
77
|
+
if (!next) throw new Error('Missing review');
|
|
78
|
+
document.querySelector('main').replaceWith(next);
|
|
79
|
+
next.querySelector('h1').focus();
|
|
80
|
+
} catch {
|
|
81
|
+
feedback.textContent = 'Connection lost. Your edit is still here. Retry, or reopen the review from the terminal.';
|
|
82
|
+
} finally {
|
|
83
|
+
form.removeAttribute('aria-busy');
|
|
84
|
+
controls.forEach(control => { control.disabled = false; });
|
|
85
|
+
if (form.isConnected && document.activeElement === document.body) submitter.focus();
|
|
86
|
+
busy = false;
|
|
87
|
+
}
|
|
88
|
+
});`;
|
|
89
|
+
function document(view, csrf, nonce) {
|
|
90
|
+
return `<!doctype html>
|
|
91
|
+
<html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
92
|
+
<title>Memory review · AgenticReplay</title>
|
|
93
|
+
<style nonce="${nonce}">
|
|
94
|
+
:root { color-scheme: light dark; font: 1rem/1.5 system-ui, sans-serif; }
|
|
95
|
+
main { max-width: 44rem; margin: 2rem auto; padding: 0 1rem; overflow-wrap: anywhere; }
|
|
96
|
+
dt { font-weight: 650; } dd { margin: 0 0 .65rem; }
|
|
97
|
+
details { margin: 1rem 0; } label { display: block; margin-bottom: .4rem; }
|
|
98
|
+
textarea { box-sizing: border-box; width: 100%; padding: .6rem; font: inherit; resize: vertical; }
|
|
99
|
+
.actions { display: flex; flex-wrap: wrap; gap: .6rem; }
|
|
100
|
+
button { font: inherit; padding: .5rem .85rem; min-height: 44px; }
|
|
101
|
+
:focus-visible { outline: 2px solid Highlight; outline-offset: 3px; }
|
|
102
|
+
</style>
|
|
103
|
+
${reviewMain(view, csrf)}
|
|
104
|
+
<script nonce="${nonce}">${script}</script></html>`;
|
|
105
|
+
}
|
|
106
|
+
const maxBody = 80 * 1024;
|
|
107
|
+
async function readAction(request, csrf) {
|
|
108
|
+
let bytes = 0;
|
|
109
|
+
const chunks = [];
|
|
110
|
+
for await (const chunk of request) {
|
|
111
|
+
bytes += chunk.length;
|
|
112
|
+
if (bytes > maxBody)
|
|
113
|
+
throw new Error('Review form exceeds its size limit.');
|
|
114
|
+
chunks.push(chunk);
|
|
115
|
+
}
|
|
116
|
+
const fields = new URLSearchParams(Buffer.concat(chunks).toString('utf8'));
|
|
117
|
+
const token = Buffer.from(fields.get('csrf') ?? '');
|
|
118
|
+
const expected = Buffer.from(csrf);
|
|
119
|
+
if (token.length !== expected.length || !timingSafeEqual(token, expected))
|
|
120
|
+
throw new Error('Invalid review form. Reopen the review.');
|
|
121
|
+
const action = fields.get('action');
|
|
122
|
+
const revision = Number(fields.get('revision'));
|
|
123
|
+
const digest = fields.get('digest') ?? '';
|
|
124
|
+
const body = fields.get('body') ?? '';
|
|
125
|
+
if (!Number.isSafeInteger(revision) ||
|
|
126
|
+
revision < 1 ||
|
|
127
|
+
!/^[a-f0-9]{64}$/.test(digest) ||
|
|
128
|
+
(action !== 'decline' && action !== 'revise'))
|
|
129
|
+
throw new Error('Invalid review action.');
|
|
130
|
+
return action === 'decline'
|
|
131
|
+
? { kind: action, revision, digest }
|
|
132
|
+
: { kind: action, revision, digest, body };
|
|
133
|
+
}
|
|
134
|
+
function send(response, status, body, html = false) {
|
|
135
|
+
response.writeHead(status, {
|
|
136
|
+
'Content-Type': html ? 'text/html; charset=utf-8' : 'text/plain; charset=utf-8',
|
|
137
|
+
});
|
|
138
|
+
response.end(body);
|
|
139
|
+
}
|
|
140
|
+
/** Owns a single loopback review. No write-to-memory route is registered here. */
|
|
141
|
+
export async function serveMemoryReview(controller) {
|
|
142
|
+
const path = `/review/${randomBytes(24).toString('hex')}`;
|
|
143
|
+
const csrf = randomBytes(24).toString('hex');
|
|
144
|
+
let host;
|
|
145
|
+
const server = createServer({ requestTimeout: 15_000, headersTimeout: 5000 }, (req, res) => {
|
|
146
|
+
void handle(req, res).catch(() => {
|
|
147
|
+
if (!res.headersSent)
|
|
148
|
+
send(res, 500, 'The review is unavailable. Reopen it from the terminal.');
|
|
149
|
+
else
|
|
150
|
+
res.destroy();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
async function handle(req, res) {
|
|
154
|
+
const nonce = randomBytes(16).toString('base64');
|
|
155
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
156
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
157
|
+
res.setHeader('Referrer-Policy', 'no-referrer');
|
|
158
|
+
res.setHeader('Content-Security-Policy', `default-src 'none'; style-src 'nonce-${nonce}'; script-src 'nonce-${nonce}'; connect-src 'self'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'`);
|
|
159
|
+
if (req.headers.host !== host || req.url !== path)
|
|
160
|
+
return send(res, 404, 'Review page not found.');
|
|
161
|
+
if (req.method === 'GET')
|
|
162
|
+
return send(res, 200, document(await controller.read(), csrf, nonce), true);
|
|
163
|
+
if (req.method !== 'POST')
|
|
164
|
+
return send(res, 405, 'Method not allowed.');
|
|
165
|
+
if (req.headers.origin !== `http://${host}`)
|
|
166
|
+
return send(res, 403, 'Review must come from this page.');
|
|
167
|
+
if (req.headers['content-type']?.split(';')[0] !== 'application/x-www-form-urlencoded')
|
|
168
|
+
return send(res, 415, 'Unsupported review form.');
|
|
169
|
+
if (Number(req.headers['content-length']) > maxBody)
|
|
170
|
+
return send(res, 413, 'Review form is too large.');
|
|
171
|
+
let action;
|
|
172
|
+
try {
|
|
173
|
+
action = await readAction(req, csrf);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
return send(res, 400, error instanceof Error ? error.message : 'Invalid review form.');
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
return send(res, 200, document(await controller.decide(action), csrf, nonce), true);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
return send(res, 409, error instanceof Error ? error.message : 'The review could not be updated.');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
await new Promise((resolve, reject) => {
|
|
186
|
+
server.once('error', reject);
|
|
187
|
+
server.listen(0, '127.0.0.1', () => {
|
|
188
|
+
server.off('error', reject);
|
|
189
|
+
resolve();
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
const address = server.address();
|
|
193
|
+
if (!address || typeof address === 'string') {
|
|
194
|
+
server.close();
|
|
195
|
+
throw new Error('Could not bind the local review.');
|
|
196
|
+
}
|
|
197
|
+
host = `127.0.0.1:${address.port}`;
|
|
198
|
+
return {
|
|
199
|
+
url: `http://${host}${path}`,
|
|
200
|
+
close: () => new Promise((resolve) => {
|
|
201
|
+
server.close(() => resolve());
|
|
202
|
+
server.closeAllConnections();
|
|
203
|
+
}),
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|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@agenticreplay/schema": "0.1.
|
|
20
|
+
"@agenticreplay/schema": "0.1.13"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=24.0.0"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Release the package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
semver:
|
|
7
|
+
description: 'Release bump type'
|
|
8
|
+
required: true
|
|
9
|
+
type: choice
|
|
10
|
+
options:
|
|
11
|
+
- patch
|
|
12
|
+
- minor
|
|
13
|
+
- major
|
|
14
|
+
- prepatch
|
|
15
|
+
- preminor
|
|
16
|
+
- premajor
|
|
17
|
+
- prerelease
|
|
18
|
+
preid:
|
|
19
|
+
description: 'Prerelease identifier (e.g. rc), used by the pre* bump types'
|
|
20
|
+
required: false
|
|
21
|
+
type: string
|
|
22
|
+
|
|
23
|
+
permissions: {}
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
release:
|
|
27
|
+
permissions:
|
|
28
|
+
id-token: write # required for npm provenance via OIDC
|
|
29
|
+
contents: write # required to push the release commit and the tag
|
|
30
|
+
uses: fastify/workflows/.github/workflows/reusable-release.yml@b0a2ab2d8259b6bd574b804cd6874bbd75c3577c
|
|
31
|
+
with:
|
|
32
|
+
semver: ${{ inputs.semver }}
|
|
33
|
+
preid: ${{ inputs.preid }}
|
|
34
|
+
dist-tag: ${{ startsWith(inputs.semver, 'pre') && 'three-next' || 'three' }}
|
|
35
|
+
make-latest: false
|
|
@@ -14,12 +14,18 @@ All of the above functions can accept an additional options argument that is an
|
|
|
14
14
|
|
|
15
15
|
Malformed authorities and out-of-range ports are reported through the parsed component's `error` field. `normalize()` leaves malformed string inputs unchanged, and `equal()` returns `false` when either string input is malformed.
|
|
16
16
|
|
|
17
|
+
Schemes are never percent-decoded. RFC 3986 does not allow percent-encoding in a scheme, so an input such as `%6Aavascript:alert(1)` is reported as malformed (`error: 'URI scheme is malformed.'`) instead of being parsed as `javascript:`. `normalize()` leaves it unchanged, `equal()` returns `false`, and `resolve()` and `serialize()` throw.
|
|
18
|
+
|
|
19
|
+
For schemes with domain hosts (`http`, `https`, `ws`, `wss`, or any scheme with the `domainHost` option), a host containing an ASCII character that RFC 3986 does not allow in a reg-name (for example `@`, TAB, LF, CR, space, `"`, `<`, `>`, `^`, `` ` ``, `{`, `|`, `}`) is reported as malformed (`error: 'URI host is malformed.'`). It is never passed through a WHATWG URL parser that could treat `@` as a delimiter or strip whitespace. `normalize()` leaves such input unchanged, `equal()` returns `false`, and `resolve()` throws.
|
|
20
|
+
|
|
17
21
|
* `scheme` (string)
|
|
18
22
|
Indicates the scheme that the URI should be treated as, overriding the URI's normal scheme parsing behavior.
|
|
19
23
|
|
|
20
24
|
* `reference` (string)
|
|
21
25
|
If set to `"suffix"`, it indicates that the URI is in the suffix format and the parser will use the option's `scheme` property to determine the URI's scheme.
|
|
22
26
|
|
|
27
|
+
A suffix reference is written without its scheme and without the `//` authority marker (RFC 3986 section 4.5). Such a reference is inherently ambiguous: an authority component cannot always be distinguished from a path. When the input carries an authority of the form `host:port` (for example `//javascript:80/x`) or a userinfo containing a colon, the serialized suffix output can begin with text that reparses as a URI scheme (for example `javascript:80/x`). Do not treat suffix output as a trusted absolute URL, and do not render it or use it in a scheme allowlist without first validating it with `parse()`. If you need an unambiguous result, use the default (non-suffix) serialization.
|
|
28
|
+
|
|
23
29
|
* `tolerant` (boolean, false)
|
|
24
30
|
If set to `true`, the parser will relax URI resolving rules.
|
|
25
31
|
|
|
@@ -79,6 +85,8 @@ uri.normalize('http://example.com/a%2Fb')
|
|
|
79
85
|
|
|
80
86
|
Reserved path escapes such as `%2F` and `%2E` are preserved as path data during normalization and comparison.
|
|
81
87
|
|
|
88
|
+
Dot segments in relative references are removed without changing what the reference resolves to: leading `..` segments that cannot be collapsed are kept, a relative path is never turned into a root-relative one, and a first-segment colon exposed by the removal is kept behind a leading `./` so the reference is not reparsed as a scheme (`a/../b` → `b`, `../x` → `../x`, `x/..` → `./`, `a/../a:b` → `./a:b`).
|
|
89
|
+
|
|
82
90
|
### Equal
|
|
83
91
|
|
|
84
92
|
```js
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require('./lib/utils')
|
|
3
|
+
const { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require('./lib/utils')
|
|
4
4
|
const { SCHEMES, getSchemeHandler } = require('./lib/schemes')
|
|
5
5
|
|
|
6
6
|
const VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u
|
|
7
7
|
const MALFORMED_SCHEME_ERROR = 'URI scheme is malformed.'
|
|
8
|
+
const MALFORMED_HOST_ERROR = 'URI host is malformed.'
|
|
9
|
+
// ASCII characters outside the RFC 3986 reg-name set (unreserved, sub-delims
|
|
10
|
+
// and "%" for pct-encoded): C0 controls, space, DEL, and "#/:<>?@[\]^`{|}.
|
|
11
|
+
const FORBIDDEN_DOMAIN_HOST_CHARACTER = /[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u
|
|
8
12
|
|
|
9
13
|
/**
|
|
14
|
+
* RFC 3986 section 3.1 does not allow percent-encoding in a scheme, so the
|
|
15
|
+
* scheme is validated as-is and never decoded. Decoding would let inert input
|
|
16
|
+
* such as `%6Aavascript:` become a live `javascript:` scheme.
|
|
17
|
+
*
|
|
10
18
|
* @param {string} scheme
|
|
11
19
|
* @returns {string}
|
|
12
20
|
*/
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
if (!VALID_SCHEME.test(
|
|
21
|
+
function validateScheme (scheme) {
|
|
22
|
+
const stringScheme = String(scheme)
|
|
23
|
+
if (!VALID_SCHEME.test(stringScheme)) {
|
|
16
24
|
throw new TypeError(MALFORMED_SCHEME_ERROR)
|
|
17
25
|
}
|
|
18
|
-
return
|
|
26
|
+
return stringScheme
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
/**
|
|
@@ -76,6 +84,12 @@ function resolve (baseURI, relativeURI, options) {
|
|
|
76
84
|
const resolvedHost = resolved.host
|
|
77
85
|
const resolvedHostIsIP = resolvedHost !== undefined && resolvedHost !== '' &&
|
|
78
86
|
(isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6)
|
|
87
|
+
// Inputs are parsed scheme-neutrally, so delimiters and controls in a domain
|
|
88
|
+
// host are only detected here, once the final scheme is known. They always
|
|
89
|
+
// fail closed, including in percent-encoded hosts.
|
|
90
|
+
if (hasForbiddenDomainHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)) {
|
|
91
|
+
throw new Error(MALFORMED_HOST_ERROR)
|
|
92
|
+
}
|
|
79
93
|
canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)
|
|
80
94
|
// Percent escapes in an ASCII reg-name are encoded data. The WHATWG hostname
|
|
81
95
|
// parser can reject them even though fast-uri preserves them safely as RFC
|
|
@@ -133,14 +147,17 @@ function resolveComponent (base, relative, options, skipNormalization) {
|
|
|
133
147
|
if (relative.path[0] === '/') {
|
|
134
148
|
target.path = removeDotSegments(relative.path)
|
|
135
149
|
} else {
|
|
136
|
-
|
|
150
|
+
const baseHasAuthority = base.userinfo !== undefined || base.host !== undefined || base.port !== undefined
|
|
151
|
+
if (baseHasAuthority && !base.path) {
|
|
137
152
|
target.path = '/' + relative.path
|
|
138
153
|
} else if (!base.path) {
|
|
139
154
|
target.path = relative.path
|
|
140
155
|
} else {
|
|
141
156
|
target.path = base.path.slice(0, base.path.lastIndexOf('/') + 1) + relative.path
|
|
142
157
|
}
|
|
143
|
-
target.path =
|
|
158
|
+
target.path = base.scheme === undefined && !baseHasAuthority && target.path[0] !== '/'
|
|
159
|
+
? removeDotSegmentsRelative(target.path)
|
|
160
|
+
: removeDotSegments(target.path)
|
|
144
161
|
}
|
|
145
162
|
target.query = relative.query
|
|
146
163
|
}
|
|
@@ -196,7 +213,7 @@ function serialize (cmpts, opts) {
|
|
|
196
213
|
const uriTokens = []
|
|
197
214
|
|
|
198
215
|
if (component.scheme) {
|
|
199
|
-
component.scheme =
|
|
216
|
+
component.scheme = validateScheme(component.scheme)
|
|
200
217
|
}
|
|
201
218
|
|
|
202
219
|
// find scheme handler
|
|
@@ -206,7 +223,11 @@ function serialize (cmpts, opts) {
|
|
|
206
223
|
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options)
|
|
207
224
|
|
|
208
225
|
const hasAuthority = component.userinfo !== undefined || component.host !== undefined || component.port !== undefined
|
|
209
|
-
|
|
226
|
+
// A reference with no emitted scheme is path-noscheme: a bare ':' in its
|
|
227
|
+
// first path segment would reparse as a scheme (RFC 3986 3.3/4.2). Enforced
|
|
228
|
+
// under skipEscape too (resolve()), so the reapply below gates on this flag.
|
|
229
|
+
const schemelessReference = (component.scheme === undefined || options.reference === 'suffix') && !hasAuthority
|
|
230
|
+
const pathNoScheme = !options.skipEscape && schemelessReference
|
|
210
231
|
|
|
211
232
|
if (component.path !== undefined) {
|
|
212
233
|
if (!options.skipEscape) {
|
|
@@ -218,7 +239,7 @@ function serialize (cmpts, opts) {
|
|
|
218
239
|
|
|
219
240
|
if (options.reference !== 'suffix' && component.scheme) {
|
|
220
241
|
// Scheme handlers may replace the scheme during serialization.
|
|
221
|
-
component.scheme =
|
|
242
|
+
component.scheme = validateScheme(component.scheme)
|
|
222
243
|
uriTokens.push(component.scheme, ':')
|
|
223
244
|
}
|
|
224
245
|
|
|
@@ -238,13 +259,18 @@ function serialize (cmpts, opts) {
|
|
|
238
259
|
let s = component.path
|
|
239
260
|
|
|
240
261
|
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
|
241
|
-
|
|
262
|
+
// A relative-path reference keeps its unresolvable leading ".." segments
|
|
263
|
+
// and must never become root-relative (RFC 3986 section 5.2.4 applies to
|
|
264
|
+
// merged target paths, not to the reference itself).
|
|
265
|
+
s = schemelessReference && s[0] !== '/'
|
|
266
|
+
? removeDotSegmentsRelative(s)
|
|
267
|
+
: removeDotSegments(s)
|
|
242
268
|
}
|
|
243
269
|
|
|
244
270
|
// Dot-segment removal can expose a colon that was not originally in the
|
|
245
271
|
// first segment (for example, "./a:b"). Reapply path-noscheme encoding so
|
|
246
272
|
// the serialized relative reference cannot be reparsed as a URI scheme.
|
|
247
|
-
if (
|
|
273
|
+
if (schemelessReference) {
|
|
248
274
|
s = serializePathEncoding(s, true)
|
|
249
275
|
}
|
|
250
276
|
|
|
@@ -359,6 +385,11 @@ function hasMalformedComponentPercentEncoding (matches) {
|
|
|
359
385
|
* @returns {boolean} whether host conversion failed
|
|
360
386
|
*/
|
|
361
387
|
function canonicalizeHost (parsed, options, schemeHandler, isIP) {
|
|
388
|
+
if (hasForbiddenDomainHost(parsed, options, schemeHandler, isIP)) {
|
|
389
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR
|
|
390
|
+
return true
|
|
391
|
+
}
|
|
392
|
+
|
|
362
393
|
if (
|
|
363
394
|
!options.unicodeSupport &&
|
|
364
395
|
(!schemeHandler || !schemeHandler.unicodeSupport) &&
|
|
@@ -368,16 +399,62 @@ function canonicalizeHost (parsed, options, schemeHandler, isIP) {
|
|
|
368
399
|
isIP === false &&
|
|
369
400
|
nonSimpleDomain(parsed.host)
|
|
370
401
|
) {
|
|
402
|
+
let url
|
|
371
403
|
try {
|
|
372
|
-
|
|
404
|
+
url = new URL('http://' + parsed.host)
|
|
373
405
|
} catch (e) {
|
|
374
406
|
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e
|
|
375
407
|
return true
|
|
376
408
|
}
|
|
409
|
+
// The WHATWG parser must have read the whole input as a host. Anything
|
|
410
|
+
// else means it found a delimiter fast-uri did not, so its hostname would
|
|
411
|
+
// describe a different authority.
|
|
412
|
+
if (!isHostOnlyURL(url)) {
|
|
413
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR
|
|
414
|
+
return true
|
|
415
|
+
}
|
|
416
|
+
parsed.host = url.hostname
|
|
377
417
|
}
|
|
378
418
|
return false
|
|
379
419
|
}
|
|
380
420
|
|
|
421
|
+
/**
|
|
422
|
+
* Whether a domain host contains an ASCII character that RFC 3986 does not
|
|
423
|
+
* allow in a reg-name (unreserved, sub-delims, or pct-encoded). Such a host is
|
|
424
|
+
* rejected instead of being handed to the WHATWG URL parser, which would treat
|
|
425
|
+
* "@" as a userinfo delimiter (silently dropping the data before it) and strip
|
|
426
|
+
* TAB, LF, and CR. Non-ASCII characters remain allowed for IDNs.
|
|
427
|
+
*
|
|
428
|
+
* @param {import('./types/index').URIComponent} parsed
|
|
429
|
+
* @param {import('./types/index').Options} options
|
|
430
|
+
* @param {{ domainHost?: boolean }|undefined} schemeHandler
|
|
431
|
+
* @param {boolean} isIP
|
|
432
|
+
* @returns {boolean}
|
|
433
|
+
*/
|
|
434
|
+
function hasForbiddenDomainHost (parsed, options, schemeHandler, isIP) {
|
|
435
|
+
return Boolean(
|
|
436
|
+
parsed.host &&
|
|
437
|
+
isIP === false &&
|
|
438
|
+
!isIPLiteral(parsed.host) &&
|
|
439
|
+
(options.domainHost || (schemeHandler && schemeHandler.domainHost)) &&
|
|
440
|
+
FORBIDDEN_DOMAIN_HOST_CHARACTER.test(parsed.host)
|
|
441
|
+
)
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* @param {URL} url
|
|
446
|
+
* @returns {boolean}
|
|
447
|
+
*/
|
|
448
|
+
function isHostOnlyURL (url) {
|
|
449
|
+
return url.username === '' &&
|
|
450
|
+
url.password === '' &&
|
|
451
|
+
url.port === '' &&
|
|
452
|
+
url.pathname === '/' &&
|
|
453
|
+
url.search === '' &&
|
|
454
|
+
url.hash === '' &&
|
|
455
|
+
url.hostname !== ''
|
|
456
|
+
}
|
|
457
|
+
|
|
381
458
|
/**
|
|
382
459
|
* @param {string} uri
|
|
383
460
|
* @param {import('./types/index').Options} [opts]
|
|
@@ -460,9 +537,8 @@ function parseWithStatus (uri, opts) {
|
|
|
460
537
|
parsed.fragment = matches[8]
|
|
461
538
|
|
|
462
539
|
if (parsed.scheme !== undefined) {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
parsed.scheme = decodedScheme.toLowerCase()
|
|
540
|
+
if (VALID_SCHEME.test(parsed.scheme)) {
|
|
541
|
+
parsed.scheme = parsed.scheme.toLowerCase()
|
|
466
542
|
} else {
|
|
467
543
|
parsed.error = parsed.error || MALFORMED_SCHEME_ERROR
|
|
468
544
|
malformedScheme = true
|
|
@@ -496,7 +572,7 @@ function parseWithStatus (uri, opts) {
|
|
|
496
572
|
parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase()
|
|
497
573
|
|
|
498
574
|
if (malformedIPLiteral) {
|
|
499
|
-
parsed.error = parsed.error ||
|
|
575
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR
|
|
500
576
|
malformedAuthorityOrPort = true
|
|
501
577
|
}
|
|
502
578
|
} else {
|
|
@@ -533,7 +609,11 @@ function parseWithStatus (uri, opts) {
|
|
|
533
609
|
// pass only restores uppercase hex in escapes that remain encoded.
|
|
534
610
|
host = normalizePercentEncoding(host.toLowerCase())
|
|
535
611
|
}
|
|
536
|
-
|
|
612
|
+
// Resolution parses both inputs with the internal `null` scheme before
|
|
613
|
+
// the effective scheme is known. Keep raw host delimiters for that step
|
|
614
|
+
// so resolve() can reject them for domain-host schemes; the resolved
|
|
615
|
+
// authority is encoded when it is serialized.
|
|
616
|
+
parsed.host = isIP || options.scheme !== 'null' ? reescapeHostDelimiters(host, isIP) : host
|
|
537
617
|
}
|
|
538
618
|
|
|
539
619
|
if (!schemeHandler || (schemeHandler && !schemeHandler.skipNormalize)) {
|
|
@@ -345,6 +345,57 @@ function removeDotSegments (path) {
|
|
|
345
345
|
return output.join('')
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
+
/**
|
|
349
|
+
* Removes dot segments from the path of a relative reference (a path that does
|
|
350
|
+
* not start with "/") without changing what it resolves to against any base.
|
|
351
|
+
* Unlike `removeDotSegments`, leading ".." segments that cannot be collapsed
|
|
352
|
+
* are kept, the result never becomes root-relative, and a result that would be
|
|
353
|
+
* empty or start with an empty segment is prefixed with "." (an empty path
|
|
354
|
+
* means "same document" and a leading "//" would introduce an authority).
|
|
355
|
+
*
|
|
356
|
+
* @param {string} path
|
|
357
|
+
* @returns {string}
|
|
358
|
+
*/
|
|
359
|
+
function removeDotSegmentsRelative (path) {
|
|
360
|
+
if (path === '' || path[0] === '/') {
|
|
361
|
+
return removeDotSegments(path)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const segments = path.split('/')
|
|
365
|
+
const last = segments.length - 1
|
|
366
|
+
/** @type {string[]} */
|
|
367
|
+
const output = []
|
|
368
|
+
let trailingDirectory = false
|
|
369
|
+
|
|
370
|
+
for (let i = 0; i <= last; i++) {
|
|
371
|
+
const segment = segments[i]
|
|
372
|
+
if (segment === '.' || segment === '..') {
|
|
373
|
+
if (segment === '..') {
|
|
374
|
+
if (output.length !== 0 && output[output.length - 1] !== '..') {
|
|
375
|
+
output.pop()
|
|
376
|
+
} else {
|
|
377
|
+
output.push('..')
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
trailingDirectory = i === last
|
|
381
|
+
} else {
|
|
382
|
+
output.push(segment)
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (trailingDirectory && output[output.length - 1] !== '..') {
|
|
387
|
+
output.push('')
|
|
388
|
+
}
|
|
389
|
+
if (output.length === 0 || output[0] === '' || output[0].includes(':')) {
|
|
390
|
+
// An empty path, a leading empty segment ("//"), or a first segment
|
|
391
|
+
// containing ":" (which would be mistaken for a scheme, RFC 3986 section
|
|
392
|
+
// 4.2) must stay behind a "." segment so the reference keeps its meaning.
|
|
393
|
+
output.unshift('.')
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return output.join('/')
|
|
397
|
+
}
|
|
398
|
+
|
|
348
399
|
/**
|
|
349
400
|
* Re-escape RFC 3986 gen-delims that must not appear literally in the host.
|
|
350
401
|
* After the URI regex parses, these characters cannot be literal in the host
|
|
@@ -740,6 +791,7 @@ module.exports = {
|
|
|
740
791
|
encodeFragment,
|
|
741
792
|
escapePreservingEscapes,
|
|
742
793
|
removeDotSegments,
|
|
794
|
+
removeDotSegmentsRelative,
|
|
743
795
|
isIPv4,
|
|
744
796
|
isUUID,
|
|
745
797
|
normalizeIPv6,
|