Skip to content

Commit caaf758

Browse files
committed
fix: remove replay test-only export
1 parent e8a6c01 commit caaf758

2 files changed

Lines changed: 28 additions & 32 deletions

File tree

‎src/__tests__/test-utils/replay-script-source.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import type { ReplayScriptSourceBundle } from '@agent-device/contracts/replay';
22
import type { MaestroSourceReader } from '@agent-device/maestro';
33
import type { DaemonRequest } from '../../daemon/types.ts';
4-
import {
5-
loadReplayScriptSourceBundle,
6-
readAdScriptSourceBundle,
7-
} from '../../commands/replay/script-source-bundle.ts';
4+
import { loadReplayScriptSourceBundle } from '../../commands/replay/script-source-bundle.ts';
85
import { discoverReplaySourcePaths } from '../../commands/replay/source-discovery.ts';
96

107
/**
118
* A native `.ad` script's bundle, built from a file on disk through the client's own reader
12-
* (#1802) so a test never hand-rolls a shape the CLI would not actually send. Synchronous
13-
* because an `.ad` script has no include grammar and needs no engine; use
9+
* (#1802) so a test never hand-rolls a shape the CLI would not actually send. Native loading is
10+
* synchronous because an `.ad` script has no include grammar and needs no engine; use
1411
* `maestroScriptSourceBundleFor` for a flow.
1512
*/
1613
export function replayScriptSourceBundleFor(filePath: string): ReplayScriptSourceBundle {
17-
return readAdScriptSourceBundle({ inputPath: filePath, cwd: process.cwd() });
14+
const bundle = loadReplayScriptSourceBundle({ inputPath: filePath, cwd: process.cwd() });
15+
if (bundle instanceof Promise) {
16+
throw new Error('native replay source bundle unexpectedly loaded asynchronously');
17+
}
18+
return bundle;
1819
}
1920

2021
/** A Maestro flow's bundle — async because the engine that walks its includes loads on demand. */

‎src/commands/replay/script-source-bundle.ts‎

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,28 @@ export type ReplayScriptSourceRequest = {
1313
env?: Readonly<Record<string, string>>;
1414
};
1515

16-
export async function loadReplayScriptSourceBundle(
16+
export function loadReplayScriptSourceBundle(
1717
params: ReplayScriptSourceRequest,
18-
): Promise<ReplayScriptSourceBundle> {
19-
const entry = resolveUserPath(params.inputPath, { cwd: params.cwd });
20-
const entrySource = readReplayEntryScript(entry, params.inputPath);
21-
if (resolveReplayFormat(entry, params.replayBackend) !== 'maestro') {
22-
return finishBundle(entry, { [entry]: entrySource }, params.inputPath);
18+
): ReplayScriptSourceBundle | Promise<ReplayScriptSourceBundle> {
19+
try {
20+
const entry = resolveUserPath(params.inputPath, { cwd: params.cwd });
21+
const entrySource = readReplayEntryScript(entry, params.inputPath);
22+
if (resolveReplayFormat(entry, params.replayBackend) !== 'maestro') {
23+
return finishBundle(entry, { [entry]: entrySource }, params.inputPath);
24+
}
25+
return (async () => {
26+
const { collectMaestroFlowSources } = await import('@agent-device/maestro');
27+
const files = collectMaestroFlowSources({
28+
entryPath: entry,
29+
entrySource,
30+
env: params.env,
31+
readSource: tryReadScriptFile,
32+
});
33+
return finishBundle(entry, files, params.inputPath);
34+
})();
35+
} catch (error) {
36+
return Promise.reject(error);
2337
}
24-
const { collectMaestroFlowSources } = await import('@agent-device/maestro');
25-
const files = collectMaestroFlowSources({
26-
entryPath: entry,
27-
entrySource,
28-
env: params.env,
29-
readSource: tryReadScriptFile,
30-
});
31-
return finishBundle(entry, files, params.inputPath);
32-
}
33-
34-
export function readAdScriptSourceBundle(
35-
params: Pick<ReplayScriptSourceRequest, 'inputPath' | 'cwd'>,
36-
): ReplayScriptSourceBundle {
37-
const entry = resolveUserPath(params.inputPath, { cwd: params.cwd });
38-
return finishBundle(
39-
entry,
40-
{ [entry]: readReplayEntryScript(entry, params.inputPath) },
41-
params.inputPath,
42-
);
4338
}
4439

4540
function finishBundle(

0 commit comments

Comments
 (0)