agenticreplay 0.1.4 → 0.1.6
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 +3 -3
- package/node_modules/@agenticreplay/adapters/dist/claude-code.d.ts.map +1 -1
- package/node_modules/@agenticreplay/adapters/dist/claude-code.js +0 -8
- package/node_modules/@agenticreplay/adapters/dist/claude-code.js.map +1 -1
- package/node_modules/@agenticreplay/adapters/dist/codex.d.ts.map +1 -1
- package/node_modules/@agenticreplay/adapters/dist/codex.js +0 -18
- package/node_modules/@agenticreplay/adapters/dist/codex.js.map +1 -1
- package/node_modules/@agenticreplay/adapters/dist/contract.d.ts +1 -1
- package/node_modules/@agenticreplay/adapters/dist/contract.d.ts.map +1 -1
- package/node_modules/@agenticreplay/adapters/dist/contract.js +0 -46
- package/node_modules/@agenticreplay/adapters/dist/contract.js.map +1 -1
- package/node_modules/@agenticreplay/adapters/dist/indexrag.d.ts.map +1 -1
- package/node_modules/@agenticreplay/adapters/dist/indexrag.js +0 -6
- package/node_modules/@agenticreplay/adapters/dist/indexrag.js.map +1 -1
- package/node_modules/@agenticreplay/adapters/package.json +6 -6
- package/node_modules/@agenticreplay/core/dist/graph.d.ts +0 -24
- package/node_modules/@agenticreplay/core/dist/graph.d.ts.map +1 -1
- package/node_modules/@agenticreplay/core/dist/graph.js +0 -68
- package/node_modules/@agenticreplay/core/dist/graph.js.map +1 -1
- package/node_modules/@agenticreplay/core/dist/paths.d.ts +1 -12
- package/node_modules/@agenticreplay/core/dist/paths.d.ts.map +1 -1
- package/node_modules/@agenticreplay/core/dist/paths.js +1 -22
- package/node_modules/@agenticreplay/core/dist/paths.js.map +1 -1
- package/node_modules/@agenticreplay/core/dist/writer.d.ts +0 -9
- package/node_modules/@agenticreplay/core/dist/writer.d.ts.map +1 -1
- package/node_modules/@agenticreplay/core/dist/writer.js +0 -5
- package/node_modules/@agenticreplay/core/dist/writer.js.map +1 -1
- package/node_modules/@agenticreplay/core/package.json +3 -3
- package/node_modules/@agenticreplay/fs-capture/dist/capture.d.ts +4 -15
- package/node_modules/@agenticreplay/fs-capture/dist/capture.d.ts.map +1 -1
- package/node_modules/@agenticreplay/fs-capture/dist/capture.js +22 -33
- package/node_modules/@agenticreplay/fs-capture/dist/capture.js.map +1 -1
- package/node_modules/@agenticreplay/fs-capture/dist/shadow.d.ts +0 -39
- package/node_modules/@agenticreplay/fs-capture/dist/shadow.d.ts.map +1 -1
- package/node_modules/@agenticreplay/fs-capture/dist/shadow.js +0 -63
- package/node_modules/@agenticreplay/fs-capture/dist/shadow.js.map +1 -1
- package/node_modules/@agenticreplay/fs-capture/package.json +2 -2
- package/node_modules/@agenticreplay/mcp-shim/dist/cli.d.ts +0 -2
- package/node_modules/@agenticreplay/mcp-shim/dist/cli.d.ts.map +1 -1
- package/node_modules/@agenticreplay/mcp-shim/dist/cli.js +2 -92
- package/node_modules/@agenticreplay/mcp-shim/dist/cli.js.map +1 -1
- package/node_modules/@agenticreplay/mcp-shim/dist/index.d.ts +0 -1
- package/node_modules/@agenticreplay/mcp-shim/dist/index.d.ts.map +1 -1
- package/node_modules/@agenticreplay/mcp-shim/dist/index.js +0 -1
- package/node_modules/@agenticreplay/mcp-shim/dist/index.js.map +1 -1
- 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/plugins.d.ts +9 -212
- package/node_modules/@agenticreplay/plugin-api/dist/plugins.d.ts.map +1 -1
- 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/dialects.d.ts +3 -29
- package/node_modules/@agenticreplay/proxy/dist/dialects.d.ts.map +1 -1
- package/node_modules/@agenticreplay/proxy/dist/dialects.js +3 -69
- package/node_modules/@agenticreplay/proxy/dist/dialects.js.map +1 -1
- package/node_modules/@agenticreplay/proxy/dist/index.d.ts +0 -2
- package/node_modules/@agenticreplay/proxy/dist/index.d.ts.map +1 -1
- package/node_modules/@agenticreplay/proxy/dist/index.js +0 -2
- package/node_modules/@agenticreplay/proxy/dist/index.js.map +1 -1
- package/node_modules/@agenticreplay/proxy/dist/intercept.d.ts +0 -48
- package/node_modules/@agenticreplay/proxy/dist/intercept.d.ts.map +1 -1
- package/node_modules/@agenticreplay/proxy/dist/intercept.js +32 -157
- package/node_modules/@agenticreplay/proxy/dist/intercept.js.map +1 -1
- package/node_modules/@agenticreplay/proxy/dist/server.d.ts +2 -148
- package/node_modules/@agenticreplay/proxy/dist/server.d.ts.map +1 -1
- package/node_modules/@agenticreplay/proxy/dist/server.js +25 -874
- 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/package.json +2 -2
- package/package.json +13 -14
- package/packages/cli/dist/api.d.ts +1 -27
- package/packages/cli/dist/api.d.ts.map +1 -1
- package/packages/cli/dist/api.js +2 -31
- package/packages/cli/dist/api.js.map +1 -1
- package/packages/cli/dist/args.d.ts.map +1 -1
- package/packages/cli/dist/args.js +0 -7
- package/packages/cli/dist/args.js.map +1 -1
- package/packages/cli/dist/commands/attach.d.ts +1 -4
- package/packages/cli/dist/commands/attach.d.ts.map +1 -1
- package/packages/cli/dist/commands/attach.js +24 -109
- package/packages/cli/dist/commands/attach.js.map +1 -1
- package/packages/cli/dist/commands/cost.d.ts +3 -0
- package/packages/cli/dist/commands/cost.d.ts.map +1 -0
- package/packages/cli/dist/commands/cost.js +13 -0
- package/packages/cli/dist/commands/cost.js.map +1 -0
- package/packages/cli/dist/commands/gc.d.ts +0 -2
- package/packages/cli/dist/commands/gc.d.ts.map +1 -1
- package/packages/cli/dist/commands/gc.js +3 -47
- package/packages/cli/dist/commands/gc.js.map +1 -1
- package/packages/cli/dist/commands/inspect.d.ts +0 -2
- package/packages/cli/dist/commands/inspect.d.ts.map +1 -1
- package/packages/cli/dist/commands/inspect.js +4 -30
- package/packages/cli/dist/commands/inspect.js.map +1 -1
- package/packages/cli/dist/commands/quickstart.d.ts +2 -34
- package/packages/cli/dist/commands/quickstart.d.ts.map +1 -1
- package/packages/cli/dist/commands/quickstart.js +32 -340
- package/packages/cli/dist/commands/quickstart.js.map +1 -1
- package/packages/cli/dist/commands/record.d.ts.map +1 -1
- package/packages/cli/dist/commands/record.js +34 -103
- package/packages/cli/dist/commands/record.js.map +1 -1
- package/packages/cli/dist/commands/setup.d.ts.map +1 -1
- package/packages/cli/dist/commands/setup.js +1 -30
- package/packages/cli/dist/commands/setup.js.map +1 -1
- package/packages/cli/dist/commands/sync.js +1 -1
- package/packages/cli/dist/commands/sync.js.map +1 -1
- package/packages/cli/dist/config.d.ts +1 -4
- package/packages/cli/dist/config.d.ts.map +1 -1
- package/packages/cli/dist/config.js.map +1 -1
- package/packages/cli/dist/flags.d.ts.map +1 -1
- package/packages/cli/dist/flags.js +4 -45
- package/packages/cli/dist/flags.js.map +1 -1
- package/packages/cli/dist/fs-events.d.ts +2 -13
- package/packages/cli/dist/fs-events.d.ts.map +1 -1
- package/packages/cli/dist/fs-events.js +5 -64
- package/packages/cli/dist/fs-events.js.map +1 -1
- package/packages/cli/dist/index.d.ts +0 -2
- package/packages/cli/dist/index.d.ts.map +1 -1
- package/packages/cli/dist/index.js +0 -2
- package/packages/cli/dist/index.js.map +1 -1
- package/packages/cli/dist/main.d.ts.map +1 -1
- package/packages/cli/dist/main.js +12 -67
- package/packages/cli/dist/main.js.map +1 -1
- package/packages/cli/dist/mcp-server.d.ts.map +1 -1
- package/packages/cli/dist/mcp-server.js +3 -86
- package/packages/cli/dist/mcp-server.js.map +1 -1
- package/packages/cli/dist/mcp.d.ts +1 -73
- package/packages/cli/dist/mcp.d.ts.map +1 -1
- package/packages/cli/dist/mcp.js +3 -113
- package/packages/cli/dist/mcp.js.map +1 -1
- package/packages/cli/dist/share-card.d.ts +0 -20
- package/packages/cli/dist/share-card.d.ts.map +1 -1
- package/packages/cli/dist/share-card.js +0 -63
- package/packages/cli/dist/share-card.js.map +1 -1
- package/packages/cli/dist/snapshot.d.ts +2 -5
- package/packages/cli/dist/snapshot.d.ts.map +1 -1
- package/packages/cli/dist/snapshot.js +2 -3
- package/packages/cli/dist/snapshot.js.map +1 -1
- package/packages/cli/dist/tls-capture.d.ts +1 -17
- package/packages/cli/dist/tls-capture.d.ts.map +1 -1
- package/packages/cli/dist/tls-capture.js +7 -77
- package/packages/cli/dist/tls-capture.js.map +1 -1
- package/packages/cli/package.json +11 -11
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createWriteStream, realpathSync } from 'node:fs';
|
|
3
|
-
import { readFile } from 'node:fs/promises';
|
|
4
|
-
import { runMock } from './mock.js';
|
|
5
3
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { isJsonRpcMessage } from './framing.js';
|
|
7
4
|
import { runShim } from './shim.js';
|
|
8
5
|
export const USAGE = 'usage: agenticreplay-mcp-shim --name <server-name> [--out <file.jsonl>] -- <command> [args...]';
|
|
9
6
|
function fail(problem) {
|
|
@@ -16,13 +13,12 @@ function fail(problem) {
|
|
|
16
13
|
export function parseArgs(argv) {
|
|
17
14
|
let name;
|
|
18
15
|
let out;
|
|
19
|
-
let replay;
|
|
20
16
|
let i = 0;
|
|
21
17
|
for (; i < argv.length; i += 1) {
|
|
22
18
|
const arg = argv[i];
|
|
23
19
|
if (arg === '--')
|
|
24
20
|
break;
|
|
25
|
-
if (arg === '--name' || arg === '--out'
|
|
21
|
+
if (arg === '--name' || arg === '--out') {
|
|
26
22
|
const value = argv[i + 1];
|
|
27
23
|
if (value === undefined || value === '--')
|
|
28
24
|
fail(`${arg} needs a value`);
|
|
@@ -30,8 +26,6 @@ export function parseArgs(argv) {
|
|
|
30
26
|
name = value;
|
|
31
27
|
else if (arg === '--out')
|
|
32
28
|
out = value;
|
|
33
|
-
else
|
|
34
|
-
replay = value;
|
|
35
29
|
i += 1;
|
|
36
30
|
continue;
|
|
37
31
|
}
|
|
@@ -44,7 +38,7 @@ export function parseArgs(argv) {
|
|
|
44
38
|
const command = argv[i + 1];
|
|
45
39
|
if (command === undefined)
|
|
46
40
|
fail("no command after '--': give the MCP server to launch");
|
|
47
|
-
return { name, out,
|
|
41
|
+
return { name, out, command, args: argv.slice(i + 2) };
|
|
48
42
|
}
|
|
49
43
|
/**
|
|
50
44
|
* Whether a parsed capture line is a frame, rather than merely valid JSON.
|
|
@@ -192,70 +186,6 @@ function toRecord(name, dir, frame) {
|
|
|
192
186
|
record.method = frame.method;
|
|
193
187
|
return `${JSON.stringify(record)}\n`;
|
|
194
188
|
}
|
|
195
|
-
/** A mock's answer in the same capture format the pass-through shim writes. */
|
|
196
|
-
function toMockRecord(name, dir, message) {
|
|
197
|
-
const raw = JSON.stringify(message);
|
|
198
|
-
const record = {
|
|
199
|
-
ts: new Date().toISOString(),
|
|
200
|
-
name,
|
|
201
|
-
dir,
|
|
202
|
-
kind: message.method === undefined
|
|
203
|
-
? 'response'
|
|
204
|
-
: message.id === undefined
|
|
205
|
-
? 'notification'
|
|
206
|
-
: 'request',
|
|
207
|
-
raw,
|
|
208
|
-
};
|
|
209
|
-
if (message.id !== undefined)
|
|
210
|
-
record.id = message.id;
|
|
211
|
-
if (message.method !== undefined)
|
|
212
|
-
record.method = message.method;
|
|
213
|
-
return `${JSON.stringify(record)}
|
|
214
|
-
`;
|
|
215
|
-
}
|
|
216
|
-
/** The frames this server produced, read back out of a capture several servers may share. */
|
|
217
|
-
async function readFrames(path, name) {
|
|
218
|
-
const text = await readFile(path, 'utf8').catch(() => '');
|
|
219
|
-
const frames = [];
|
|
220
|
-
for (const value of text
|
|
221
|
-
.split(/\r?\n/)
|
|
222
|
-
.flatMap((line) => objectsOnLine(line, MCP_RECORD_START))) {
|
|
223
|
-
// The `--replay` reader, so a torn line in a *recording* used to kill the replay of it rather
|
|
224
|
-
// than cost one frame: the shim died before serving a single recorded answer, every MCP server
|
|
225
|
-
// in the run with it.
|
|
226
|
-
if (!isMcpFrameRecord(value))
|
|
227
|
-
continue;
|
|
228
|
-
const record = value;
|
|
229
|
-
if (record.name !== name)
|
|
230
|
-
continue;
|
|
231
|
-
let message;
|
|
232
|
-
try {
|
|
233
|
-
message = JSON.parse(record.raw);
|
|
234
|
-
}
|
|
235
|
-
catch {
|
|
236
|
-
// A line the shim saw but could not parse is still in the capture; it just cannot answer.
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
// Neither can one that parsed to something that is not a message, and `JSON.parse` is happy
|
|
240
|
-
// with those: a bare `null` line from a server is recorded as `raw: "null"` — a perfectly
|
|
241
|
-
// well-formed record — so it went straight past the guard above and was cast to a message.
|
|
242
|
-
// `indexFrames` then read `.id` off `null`, and `runMock` indexes before it answers anything,
|
|
243
|
-
// so one such line anywhere in a recording killed the whole replay at startup and every MCP
|
|
244
|
-
// server in the run with it. Recording tolerated it and replay did not, which is the asymmetry
|
|
245
|
-
// this reader exists to close.
|
|
246
|
-
if (!isJsonRpcMessage(message))
|
|
247
|
-
continue;
|
|
248
|
-
frames.push({
|
|
249
|
-
server: record.name,
|
|
250
|
-
direction: record.dir === 'in' ? 'in' : 'out',
|
|
251
|
-
at: record.ts,
|
|
252
|
-
...(record.id === undefined ? {} : { id: record.id }),
|
|
253
|
-
...(record.method === undefined ? {} : { method: record.method }),
|
|
254
|
-
message: message,
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
return frames;
|
|
258
|
-
}
|
|
259
189
|
export async function main(argv, io = {}) {
|
|
260
190
|
const parsed = parseArgs(argv);
|
|
261
191
|
// Append: several servers in one run may share a capture file, and a rerun must not erase it.
|
|
@@ -269,26 +199,6 @@ export async function main(argv, io = {}) {
|
|
|
269
199
|
sink.on('error', () => { });
|
|
270
200
|
}
|
|
271
201
|
try {
|
|
272
|
-
// Replay: answer from the recording and never start the server. The command is still parsed,
|
|
273
|
-
// because the config the agent reads is the same file either way — what changes is whether
|
|
274
|
-
// agenticreplay runs what it names. Frames are still written, so the replay is a readable run of its
|
|
275
|
-
// own rather than one whose MCP layer left no trace at all.
|
|
276
|
-
if (parsed.replay !== undefined) {
|
|
277
|
-
const frames = await readFrames(parsed.replay, parsed.name);
|
|
278
|
-
return await runMock({
|
|
279
|
-
name: parsed.name,
|
|
280
|
-
frames,
|
|
281
|
-
onMiss: (method) => (io.stderr ?? process.stderr).write(`agenticreplay-mcp-shim: no recorded response for ${method} on ${parsed.name}
|
|
282
|
-
`),
|
|
283
|
-
...(sink
|
|
284
|
-
? {
|
|
285
|
-
onFrame: (dir, message) => void sink.write(toMockRecord(parsed.name, dir, message)),
|
|
286
|
-
}
|
|
287
|
-
: {}),
|
|
288
|
-
...(io.stdin ? { stdin: io.stdin } : {}),
|
|
289
|
-
...(io.stdout ? { stdout: io.stdout } : {}),
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
202
|
return await runShim({
|
|
293
203
|
name: parsed.name,
|
|
294
204
|
command: parsed.command,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgBpC,MAAM,CAAC,MAAM,KAAK,GAChB,gGAAgG,CAAC;AAEnG,SAAS,IAAI,CAAC,OAAe;IAC3B,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,KA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C,QAAQ,GAAG,IAAI,CAAC;QACxB,mFAAmF;QACnF,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC,EACD,CAAC,GAAU,EAAE,EAAE;QACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;QACjE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { CanonicalChunk, CanonicalRequest, ModelInfo, Money, Usage } from './canonical.js';
|
|
2
1
|
/** Everything an adapter needs to know about the run it is preparing. */
|
|
3
2
|
export interface RecordContext {
|
|
4
3
|
runId: string;
|
|
5
4
|
cwd: string;
|
|
6
5
|
/** Base URL of the local recording proxy, e.g. http://127.0.0.1:51733 */
|
|
7
6
|
proxyUrl: string;
|
|
8
|
-
/** Directory the
|
|
7
|
+
/** Directory the adapter may write temporary capture configuration into. */
|
|
9
8
|
runDir: string;
|
|
10
9
|
/** Argv the user passed after the agent name. */
|
|
11
10
|
userArgs: string[];
|
|
@@ -18,216 +17,32 @@ export interface Launch {
|
|
|
18
17
|
/** Environment overlay merged onto the parent environment. */
|
|
19
18
|
env: Record<string, string>;
|
|
20
19
|
cwd?: string;
|
|
21
|
-
/** Files the adapter wrote
|
|
20
|
+
/** Files the adapter wrote for cleanup and capture provenance. */
|
|
22
21
|
tempFiles?: string[];
|
|
23
22
|
}
|
|
24
23
|
/** How to launch and instrument one agent harness. */
|
|
25
24
|
export interface Adapter {
|
|
26
25
|
id: string;
|
|
27
|
-
/**
|
|
28
|
-
* Other names this adapter answers to on the command line.
|
|
29
|
-
*
|
|
30
|
-
* The id is a stable internal handle written into every manifest; an alias is what a human
|
|
31
|
-
* types, which is almost always the name of the binary they run. `claude-code` and `claude` are
|
|
32
|
-
* the canonical example — keeping them separate means the manifest stays unambiguous while
|
|
33
|
-
* `agenticreplay record claude` does what anyone would expect it to.
|
|
34
|
-
*/
|
|
26
|
+
/** Other names this adapter answers to on the command line. */
|
|
35
27
|
aliases?: readonly string[];
|
|
36
28
|
/** Semver range of harness versions this adapter is tested against. */
|
|
37
29
|
harnessVersions?: string;
|
|
38
|
-
/**
|
|
39
|
-
* How this adapter gets the agent's traffic to agenticreplay.
|
|
40
|
-
*
|
|
41
|
-
* `env` — the default, and what every harness-specific adapter does: point a base-URL variable
|
|
42
|
-
* at the proxy, or install the fetch hook, so the agent connects to a local origin in plaintext.
|
|
43
|
-
*
|
|
44
|
-
* `transport` — the adapter redirects nothing and relies on `--tls-intercept`, which is applied
|
|
45
|
-
* to the launched child by the run rather than by the adapter. Declared rather than inferred,
|
|
46
|
-
* because "sets no base-URL variable" is otherwise indistinguishable from the broken adapter the
|
|
47
|
-
* contract's `redirects-model-traffic` check exists to catch. An adapter that says `transport`
|
|
48
|
-
* is asserting that pointing nowhere is the intent, and takes the check's exemption in exchange.
|
|
49
|
-
*
|
|
50
|
-
* `config` — the adapter redirects through a configuration file rather than the environment,
|
|
51
|
-
* for a harness that keeps its origin in one and reads no variable for it. MiniMax Code is the
|
|
52
|
-
* first: `MINIMAX_DATA_DIR` moves the whole data directory, and the config agenticreplay writes there
|
|
53
|
-
* carries the redirect. It takes the same exemption as `transport` and for the same reason —
|
|
54
|
-
* the redirect is real but is not an environment variable, so a check that only reads the
|
|
55
|
-
* launch environment is scoring it against a mechanism it does not use. What it redirects is
|
|
56
|
-
* checked where the file can actually be read: the adapter's own tests.
|
|
57
|
-
*/
|
|
30
|
+
/** How this adapter gets the agent's traffic to AgenticReplay. */
|
|
58
31
|
capture?: 'env' | 'transport' | 'config';
|
|
59
32
|
detect(cwd: string): Promise<boolean>;
|
|
60
33
|
prepare(ctx: RecordContext): Promise<Launch>;
|
|
61
|
-
/**
|
|
62
|
-
* The harness's own session records, where it keeps any.
|
|
63
|
-
*
|
|
64
|
-
* AgenticReplay's capture layers see what a run *did*; only the harness knows what it was *asked*. A run
|
|
65
|
-
* driven by hand has its prompts nowhere on the wire, so without this a replay launches an agent
|
|
66
|
-
* with nothing to make it ask anything. Supplying it is what makes an interactive recording
|
|
67
|
-
* replayable and forkable at all.
|
|
68
|
-
*/
|
|
34
|
+
/** The harness transcript reader used to record prompts that do not appear on the wire. */
|
|
69
35
|
session?: SessionSupport;
|
|
70
|
-
/**
|
|
71
|
-
* Arguments that load an MCP config from a path, for a harness that takes one.
|
|
72
|
-
*
|
|
73
|
-
* The environment variables agenticreplay sets alongside this are read by none of the harnesses it
|
|
74
|
-
* targets: Claude Code loads MCP servers from `.mcp.json`, from the user config, or from
|
|
75
|
-
* `--mcp-config`, and ignores `CLAUDE_MCP_CONFIG` entirely — so `agenticreplay record --mcp-config`
|
|
76
|
-
* instrumented a copy of the file and then launched an agent that never opened it. The capture
|
|
77
|
-
* reported success and recorded no frames, which is the same silent shape the base-URL variables
|
|
78
|
-
* had before an adapter passed those on the command line too.
|
|
79
|
-
*/
|
|
36
|
+
/** Arguments that load an MCP config from a path, for a harness that takes one. */
|
|
80
37
|
mcpConfigArgs?(path: string): string[] | undefined;
|
|
81
|
-
/**
|
|
82
|
-
* Arguments that drive this harness through a recorded prompt with no terminal attached.
|
|
83
|
-
*
|
|
84
|
-
* `recorded` is the argv the run was made with, so an adapter can extend it rather than replace
|
|
85
|
-
* it — the flags that shaped the recording still have to shape the replay.
|
|
86
|
-
*/
|
|
87
|
-
driveArgs?(prompts: string[], recorded: string[]): string[] | undefined;
|
|
88
|
-
/**
|
|
89
|
-
* What this harness leaves on disk that the run cannot be understood or reproduced without.
|
|
90
|
-
*
|
|
91
|
-
* Optional, and most harnesses need none of it: a coding agent's output *is* the working tree,
|
|
92
|
-
* which the ordinary snapshot already captures. A pipeline is the case this exists for — its
|
|
93
|
-
* whole product is an index or a cache, written to a path its own `.gitignore` excludes,
|
|
94
|
-
* because nobody wants a hundred megabytes of vectors in their repository.
|
|
95
|
-
*/
|
|
38
|
+
/** Additional ignored paths that are meaningful agent outputs and should be recorded. */
|
|
96
39
|
artifacts?: HarnessArtifacts;
|
|
97
|
-
/**
|
|
98
|
-
* Argv for a replay, for a harness that carries no prompt at all.
|
|
99
|
-
*
|
|
100
|
-
* {@link driveArgs} answers "what makes the agent ask the recorded question again", and it only
|
|
101
|
-
* applies to a harness with a transcript agenticreplay can read. A pipeline has neither: its argv *is*
|
|
102
|
-
* the whole instruction and there is nothing to recover. This hook is reached before the
|
|
103
|
-
* transcript is consulted, so such an adapter can still adjust what the replay runs — clamping
|
|
104
|
-
* a concurrency flag, say — instead of having no say at all.
|
|
105
|
-
*
|
|
106
|
-
* Return undefined to leave the recorded argv exactly as it was, which is what every adapter
|
|
107
|
-
* that does not implement this gets.
|
|
108
|
-
*/
|
|
109
|
-
replayArgs?(recorded: string[]): string[] | undefined;
|
|
110
40
|
}
|
|
111
|
-
/**
|
|
41
|
+
/** Additional output paths a harness writes that ordinary ignore rules would omit. */
|
|
112
42
|
export interface HarnessArtifacts {
|
|
113
|
-
/**
|
|
114
|
-
* Paths to snapshot even when the workspace's own `.gitignore` excludes them.
|
|
115
|
-
*
|
|
116
|
-
* The snapshot is a `git add` against a shadow index, so it honours the workspace's ignore
|
|
117
|
-
* rules — correct for a coding agent, where `node_modules/` and `dist/` are noise, and wrong
|
|
118
|
-
* for a pipeline, where the ignored directory is the entire product. `vector_store/` and
|
|
119
|
-
* `cache/` are the first two lines of IndexRAG's `.gitignore`, and without them a recording of
|
|
120
|
-
* an indexing run holds the model calls that built an index and no trace of the index.
|
|
121
|
-
*
|
|
122
|
-
* It cannot be used to smuggle a secret into a trace: the sensitive pathspecs are applied to
|
|
123
|
-
* this add as well, so an adapter declaring `.` still cannot capture `.env`.
|
|
124
|
-
*/
|
|
125
43
|
capture?: readonly string[];
|
|
126
|
-
/**
|
|
127
|
-
* Paths to put back to the state the recording *started* in, before a replay launches.
|
|
128
|
-
*
|
|
129
|
-
* A pipeline resumes: it reads its own cache, sees which items are already done, and does the
|
|
130
|
-
* rest. Replayed on top of the recording's finished cache it does nothing at all — every model
|
|
131
|
-
* call is skipped, nothing is asked, and the replay reports a run it never reproduced. That is
|
|
132
|
-
* `reused=0/6 exit=0` over a recording that was perfectly good.
|
|
133
|
-
*
|
|
134
|
-
* Not "delete these". AgenticReplay clears them and then restores the recording's initial snapshot over
|
|
135
|
-
* the top, so they end up holding exactly what they held when recording began — which for a
|
|
136
|
-
* recording of one mid-pipeline stage is a *populated* cache, and deleting that would take away
|
|
137
|
-
* the stage's own input. The clearing is what the plain restore cannot do: it writes the files
|
|
138
|
-
* the tree names and leaves everything else alone, so a cache the recording never had survives
|
|
139
|
-
* it.
|
|
140
|
-
*
|
|
141
|
-
* Whole directories rather than "the invalid parts": IndexRAG's resume skips by `chunk_id`
|
|
142
|
-
* including entries it recorded as failures, so keeping what looks valid silently promotes the
|
|
143
|
-
* previous run's failures to completed work. Nothing is lost either way — an exact replay
|
|
144
|
-
* restores the working tree when it ends, and where it will not (`--in-place`), agenticreplay says so
|
|
145
|
-
* and leaves these alone.
|
|
146
|
-
*/
|
|
147
|
-
resetBeforeReplay?: readonly string[];
|
|
148
|
-
/**
|
|
149
|
-
* The flag that makes this harness run one request at a time, and the value that does it.
|
|
150
|
-
*
|
|
151
|
-
* Declared, never applied on its own: clamping concurrency changes the run being replayed, and
|
|
152
|
-
* a replay that quietly runs the pipeline differently from the recording is not a replay. It is
|
|
153
|
-
* what `agenticreplay replay --serialize` reaches for when the operator asks for determinism explicitly.
|
|
154
|
-
*/
|
|
155
|
-
concurrencyFlag?: {
|
|
156
|
-
flag: string;
|
|
157
|
-
serialValue: string;
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* A non-model HTTP call whose answer is a pure function of its request.
|
|
162
|
-
*
|
|
163
|
-
* The proxy's own comment on passthrough says agenticreplay "holds the bytes but not the meaning, so it
|
|
164
|
-
* cannot match this request on replay" — and for an embedding that is the one thing it does not
|
|
165
|
-
* need. `embed(model, input)` is deterministic in a way a chat completion is not: the same text
|
|
166
|
-
* to the same model is the same vector, every time, from any provider. So this class of call is
|
|
167
|
-
* *replayable* without any translator, matched on the request itself rather than on a ladder.
|
|
168
|
-
*
|
|
169
|
-
* It is deliberately not forkable, and `forkable` is `false` rather than absent so that saying so
|
|
170
|
-
* is part of the type. Substituting the embedding model would change the vector space the index
|
|
171
|
-
* was built in — every stored vector would have to be recomputed, and the comparison a fork
|
|
172
|
-
* exists to make ("same run, different model") would be against a different index. That is a
|
|
173
|
-
* rebuild, not a fork. Changing the *chat* model over a fixed index is the useful question, and
|
|
174
|
-
* it is exactly what keeping retrieval on the recording makes possible.
|
|
175
|
-
*/
|
|
176
|
-
export interface RetrievalRule {
|
|
177
|
-
/** Stable id, written into the trace so a reader can tell which rule claimed a call. */
|
|
178
|
-
id: string;
|
|
179
|
-
/**
|
|
180
|
-
* Whether this rule claims the endpoint. The path is the one the client actually appended, so
|
|
181
|
-
* a base URL rewritten through `/forward/` presents as `/embeddings` rather than
|
|
182
|
-
* `/v1/embeddings` — match on the suffix, not on a version segment that lives in the base.
|
|
183
|
-
*/
|
|
184
|
-
matches(path: string, host?: string): boolean;
|
|
185
|
-
/**
|
|
186
|
-
* The value a replay looks this call up by. Defaults to a digest of the whole request body with
|
|
187
|
-
* its keys sorted, which is the strictest honest answer: anything a caller varies is part of
|
|
188
|
-
* what it asked for until a rule says otherwise.
|
|
189
|
-
*/
|
|
190
|
-
key(raw: unknown): string;
|
|
191
|
-
/** One line for the timeline — "12 texts, text-embedding-3-small". Optional. */
|
|
192
|
-
describe?(raw: unknown): string;
|
|
193
|
-
/**
|
|
194
|
-
* How to match a batch whose items arrived in a different order, where the endpoint's own
|
|
195
|
-
* contract makes that safe.
|
|
196
|
-
*
|
|
197
|
-
* A retrieval call is usually a *batch* — one request carrying many texts — and the order of
|
|
198
|
-
* that batch is routinely accidental. IndexRAG assembles it from a thread pool that appends
|
|
199
|
-
* results as they complete; LlamaIndex, GraphRAG and LightRAG all have the same shape. So two
|
|
200
|
-
* runs of the same pipeline over the same documents send the same set of texts in a different
|
|
201
|
-
* sequence, and a key over the request body says they asked different questions. Measured: two
|
|
202
|
-
* replays of one recording produced two different keys, and neither matched what was recorded.
|
|
203
|
-
*
|
|
204
|
-
* This is safe here and would not be for a model call, because the API says so: OpenAI's
|
|
205
|
-
* embeddings response carries `data[i].index` and defines `data[i]` as the embedding of
|
|
206
|
-
* `input[i]`. An embedding does not depend on what sat next to it in the batch. So the recorded
|
|
207
|
-
* answer for each text can be found and handed back against that text's new position — which is
|
|
208
|
-
* not an approximation, it is the same answer to the same question.
|
|
209
|
-
*
|
|
210
|
-
* Optional, and absent by default on any endpoint whose contract does not guarantee that.
|
|
211
|
-
*/
|
|
212
|
-
batch?: BatchRetrieval;
|
|
213
|
-
/** Always false. See the note above: changing an embedding model is a rebuild, not a fork. */
|
|
214
|
-
readonly forkable: false;
|
|
215
44
|
}
|
|
216
|
-
/**
|
|
217
|
-
export interface BatchRetrieval {
|
|
218
|
-
/**
|
|
219
|
-
* A key over the request with its batch reduced to a multiset, or undefined when this request
|
|
220
|
-
* is not a batch this rule can reorder — a single input, or a shape it does not recognise.
|
|
221
|
-
*/
|
|
222
|
-
key(raw: unknown): string | undefined;
|
|
223
|
-
/**
|
|
224
|
-
* The recorded response rebuilt so that item *i* answers the live request's item *i*, or
|
|
225
|
-
* undefined when it cannot be done exactly. Undefined halts the replay, which is the right
|
|
226
|
-
* answer: a partial reorder would hand some documents another document's vector.
|
|
227
|
-
*/
|
|
228
|
-
reorder(recordedRequest: unknown, recordedResponse: string, liveRequest: unknown): string | undefined;
|
|
229
|
-
}
|
|
230
|
-
/** How to find, read and resume a harness's own session transcripts. */
|
|
45
|
+
/** How to find and read a harness's own session transcript for action logging. */
|
|
231
46
|
export interface SessionSupport {
|
|
232
47
|
/** Directory the harness writes session transcripts into, or undefined if it keeps none. */
|
|
233
48
|
dir(cwd: string, env: Record<string, string | undefined>): string | undefined;
|
|
@@ -237,23 +52,5 @@ export interface SessionSupport {
|
|
|
237
52
|
title?: string;
|
|
238
53
|
prompts: string[];
|
|
239
54
|
};
|
|
240
|
-
/** Arguments that resume that session, for a fork continuing where the run stopped. */
|
|
241
|
-
resumeArgs(id: string): string[];
|
|
242
|
-
}
|
|
243
|
-
/** How to reach a model when the replay cursor goes live. */
|
|
244
|
-
export interface Provider {
|
|
245
|
-
id: string;
|
|
246
|
-
models(): Promise<ModelInfo[]>;
|
|
247
|
-
invoke(req: CanonicalRequest, signal?: AbortSignal): AsyncIterable<CanonicalChunk>;
|
|
248
|
-
price(usage: Usage, model: string): Money | null;
|
|
249
|
-
}
|
|
250
|
-
export interface ProviderFactory {
|
|
251
|
-
id: string;
|
|
252
|
-
create(options: ProviderOptions): Provider;
|
|
253
|
-
}
|
|
254
|
-
export interface ProviderOptions {
|
|
255
|
-
apiKey?: string;
|
|
256
|
-
baseUrl?: string;
|
|
257
|
-
headers?: Record<string, string>;
|
|
258
55
|
}
|
|
259
56
|
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,yEAAyE;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CACzC;AAED,4CAA4C;AAC5C,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,sDAAsD;AACtD,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,+DAA+D;IAC/D,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,uEAAuE;IACvE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,OAAO,CAAC,EAAE,KAAK,GAAG,WAAW,GAAG,QAAQ,CAAC;IACzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,2FAA2F;IAC3F,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,mFAAmF;IACnF,aAAa,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACnD,yFAAyF;IACzF,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B;AAED,kFAAkF;AAClF,MAAM,WAAW,cAAc;IAC7B,4FAA4F;IAC5F,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,GAAG,SAAS,CAAC;IAC9E,sEAAsE;IACtE,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAC9E"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenticreplay/providers",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@agenticreplay/plugin-api": "0.1.
|
|
21
|
-
"@agenticreplay/schema": "0.1.
|
|
20
|
+
"@agenticreplay/plugin-api": "0.1.6",
|
|
21
|
+
"@agenticreplay/schema": "0.1.6"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=24.0.0"
|
|
@@ -16,44 +16,24 @@ export interface Dialect {
|
|
|
16
16
|
toCanonicalResponse(raw: unknown): CanonicalResponse;
|
|
17
17
|
/** Parse a recorded SSE body into a response, for streamed exchanges. */
|
|
18
18
|
parseStream(body: string): CanonicalResponse;
|
|
19
|
-
/** Rewrite the model on a raw request body, for fork replay onto a different model. */
|
|
20
|
-
withModel(raw: unknown, model: string): unknown;
|
|
21
19
|
/** Request path this dialect posts to, for a request translated *into* it. */
|
|
22
20
|
requestPath: string;
|
|
23
|
-
/**
|
|
24
|
-
* Does this dialect serve the given model?
|
|
25
|
-
*
|
|
26
|
-
* Kept on the dialect rather than in a table in the proxy, for the same reason everything else
|
|
27
|
-
* here is: the proxy is handed a list of dialects and knows nothing about which exist, so a
|
|
28
|
-
* third party can add one without the routing needing to learn about it.
|
|
29
|
-
*/
|
|
30
|
-
ownsModel(model: string): boolean;
|
|
31
|
-
/** Build a wire request from the canonical form — the inbound half of a cross-provider fork. */
|
|
32
|
-
fromCanonicalRequest(req: CanonicalRequest): unknown;
|
|
33
|
-
/** Build a wire response the agent will accept — the outbound half. */
|
|
34
|
-
fromCanonicalResponse(res: CanonicalResponse, streamed: boolean): string;
|
|
35
21
|
}
|
|
36
22
|
export declare function anthropicDialect(translators: {
|
|
37
23
|
toCanonicalRequest: (raw: unknown) => CanonicalRequest;
|
|
38
24
|
toCanonicalResponse: (raw: unknown) => CanonicalResponse;
|
|
39
25
|
parseSse: (body: string) => CanonicalResponse;
|
|
40
|
-
fromCanonicalRequest: (req: CanonicalRequest) => Record<string, unknown>;
|
|
41
|
-
fromCanonicalResponse: (res: CanonicalResponse) => Record<string, unknown>;
|
|
42
|
-
toSse: (res: CanonicalResponse) => string;
|
|
43
26
|
}): Dialect;
|
|
44
27
|
export declare function openaiDialect(translators: {
|
|
45
28
|
toCanonicalRequest: (raw: unknown) => CanonicalRequest;
|
|
46
29
|
toCanonicalResponse: (raw: unknown) => CanonicalResponse;
|
|
47
30
|
parseSse: (body: string) => CanonicalResponse;
|
|
48
|
-
fromCanonicalRequest: (req: CanonicalRequest) => Record<string, unknown>;
|
|
49
|
-
fromCanonicalResponse: (res: CanonicalResponse) => Record<string, unknown>;
|
|
50
|
-
toSse: (res: CanonicalResponse) => string;
|
|
51
31
|
}): Dialect;
|
|
52
32
|
/**
|
|
53
33
|
* The Codex CLI's subscription transport is an OpenAI Responses-shaped endpoint, but it is not
|
|
54
34
|
* the public `/v1/responses` API: it lives at `/backend-api/codex/responses`, sends zstd-compressed
|
|
55
|
-
* JSON and returns a Responses SSE stream.
|
|
56
|
-
*
|
|
35
|
+
* JSON and returns a Responses SSE stream. The recording proxy parses these calls into the
|
|
36
|
+
* common trace format while preserving the received wire evidence.
|
|
57
37
|
*/
|
|
58
38
|
export declare function codexDialect(): Dialect;
|
|
59
39
|
/**
|
|
@@ -64,18 +44,12 @@ export declare function codexDialect(): Dialect;
|
|
|
64
44
|
* top-level items, and the stream is typed events rather than choice deltas. One dialect trying to
|
|
65
45
|
* be both would have to sniff the body shape on every request, and guess wrong on the empty ones.
|
|
66
46
|
*
|
|
67
|
-
* It is registered
|
|
68
|
-
* cannot distinguish them — both serve everything that is not Claude — so the later position means
|
|
69
|
-
* an ordinary chat-completions run forking to another OpenAI model still goes to chat completions.
|
|
70
|
-
* A Responses run stays on Responses through the recorded-dialect preference in `goLive`.
|
|
47
|
+
* It is registered after `openaiDialect`; the request path selects the wire protocol.
|
|
71
48
|
*/
|
|
72
49
|
export declare function responsesDialect(translators: {
|
|
73
50
|
toCanonicalRequest: (raw: unknown) => CanonicalRequest;
|
|
74
51
|
toCanonicalResponse: (raw: unknown) => CanonicalResponse;
|
|
75
52
|
parseSse: (body: string) => CanonicalResponse;
|
|
76
|
-
fromCanonicalRequest: (req: CanonicalRequest) => Record<string, unknown>;
|
|
77
|
-
fromCanonicalResponse: (res: CanonicalResponse) => Record<string, unknown>;
|
|
78
|
-
toSse: (res: CanonicalResponse) => string;
|
|
79
53
|
}): Dialect;
|
|
80
54
|
export declare function selectDialect(dialects: Dialect[], path: string): Dialect | undefined;
|
|
81
55
|
//# sourceMappingURL=dialects.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialects.d.ts","sourceRoot":"","sources":["../src/dialects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,EAChB,iBAAiB,EAGlB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,oDAAoD;IACpD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,oEAAoE;IACpE,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAAC;IACnD,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,iBAAiB,CAAC;IACrD,yEAAyE;IACzE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAAC;IAC7C,
|
|
1
|
+
{"version":3,"file":"dialects.d.ts","sourceRoot":"","sources":["../src/dialects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,EAChB,iBAAiB,EAGlB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,oDAAoD;IACpD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,oEAAoE;IACpE,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAAC;IACnD,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,iBAAiB,CAAC;IACrD,yEAAyE;IACzE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAAC;IAC7C,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE;IAC5C,kBAAkB,EAAE,CAAC,GAAG,EAAE,OAAO,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