@ligeti/testing 0.0.0-stage → 2.0.3
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/LICENSE +201 -0
- package/README.md +242 -2
- package/bin/argv-recorder.mjs +53 -0
- package/bin/clean-test-databases.mjs +146 -0
- package/bin/fake-claude.mjs +560 -0
- package/bin/fake-herdr.mjs +468 -0
- package/bin/fake-opencode.mjs +45 -0
- package/dist/agents.d.ts +5 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +21 -0
- package/dist/agents.js.map +1 -0
- package/dist/bitbucket.d.ts +26 -0
- package/dist/bitbucket.d.ts.map +1 -0
- package/dist/bitbucket.js +162 -0
- package/dist/bitbucket.js.map +1 -0
- package/dist/callback-server.d.ts +20 -0
- package/dist/callback-server.d.ts.map +1 -0
- package/dist/callback-server.js +79 -0
- package/dist/callback-server.js.map +1 -0
- package/dist/claude-profile.d.ts +3 -0
- package/dist/claude-profile.d.ts.map +1 -0
- package/dist/claude-profile.js +16 -0
- package/dist/claude-profile.js.map +1 -0
- package/dist/env.d.ts +2 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +15 -0
- package/dist/env.js.map +1 -0
- package/dist/fake-http.d.ts +25 -0
- package/dist/fake-http.d.ts.map +1 -0
- package/dist/fake-http.js +129 -0
- package/dist/fake-http.js.map +1 -0
- package/dist/github.d.ts +184 -0
- package/dist/github.d.ts.map +1 -0
- package/dist/github.js +919 -0
- package/dist/github.js.map +1 -0
- package/dist/gitlab-merge-requests.d.ts +23 -0
- package/dist/gitlab-merge-requests.d.ts.map +1 -0
- package/dist/gitlab-merge-requests.js +228 -0
- package/dist/gitlab-merge-requests.js.map +1 -0
- package/dist/gitlab.d.ts +9 -0
- package/dist/gitlab.d.ts.map +1 -0
- package/dist/gitlab.js +13 -0
- package/dist/gitlab.js.map +1 -0
- package/dist/herdr.d.ts +9 -0
- package/dist/herdr.d.ts.map +1 -0
- package/dist/herdr.js +16 -0
- package/dist/herdr.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/jira.d.ts +7 -0
- package/dist/jira.d.ts.map +1 -0
- package/dist/jira.js +7 -0
- package/dist/jira.js.map +1 -0
- package/dist/postgres.d.ts +6 -0
- package/dist/postgres.d.ts.map +1 -0
- package/dist/postgres.js +122 -0
- package/dist/postgres.js.map +1 -0
- package/dist/recorded-turns.d.ts +9 -0
- package/dist/recorded-turns.d.ts.map +1 -0
- package/dist/recorded-turns.js +45 -0
- package/dist/recorded-turns.js.map +1 -0
- package/dist/repo.d.ts +6 -0
- package/dist/repo.d.ts.map +1 -0
- package/dist/repo.js +30 -0
- package/dist/repo.js.map +1 -0
- package/dist/telegram.d.ts +11 -0
- package/dist/telegram.d.ts.map +1 -0
- package/dist/telegram.js +37 -0
- package/dist/telegram.js.map +1 -0
- package/dist/wait.d.ts +2 -0
- package/dist/wait.d.ts.map +1 -0
- package/dist/wait.js +15 -0
- package/dist/wait.js.map +1 -0
- package/dist/worker.d.ts +19 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +56 -0
- package/dist/worker.js.map +1 -0
- package/fixtures/claude-profile/settings.json +26 -0
- package/package.json +32 -3
package/dist/postgres.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// ABOUTME: A real, working throwaway-Postgres-database fixture for integration tests: creates a
|
|
2
|
+
// ABOUTME: uniquely named database and drops it, terminating connections left open after a grace period.
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
|
+
import { randomBytes } from "node:crypto";
|
|
5
|
+
import { Client } from "pg";
|
|
6
|
+
const DEFAULT_ADMIN_URL = "postgresql://ligeti:ligeti@localhost:5434/postgres";
|
|
7
|
+
const ADMIN_DATABASE = "postgres";
|
|
8
|
+
const NAME_PREFIX = "ligeti_test_";
|
|
9
|
+
const RANDOM_SUFFIX_BYTES = 8;
|
|
10
|
+
const MAX_IDENTIFIER_BYTES = 63;
|
|
11
|
+
const MAX_SLUG_LENGTH = MAX_IDENTIFIER_BYTES - NAME_PREFIX.length - RANDOM_SUFFIX_BYTES * 2 - "_".length;
|
|
12
|
+
const CLOSE_GRACE_MS = 2_000;
|
|
13
|
+
const CLOSE_POLL_MS = 25;
|
|
14
|
+
function urlForDatabase(baseUrl, database) {
|
|
15
|
+
const url = new URL(baseUrl);
|
|
16
|
+
url.pathname = `/${database}`;
|
|
17
|
+
return url.toString();
|
|
18
|
+
}
|
|
19
|
+
function adminUrl() {
|
|
20
|
+
const configured = process.env.LIGETI_TEST_DATABASE_URL ?? DEFAULT_ADMIN_URL;
|
|
21
|
+
try {
|
|
22
|
+
return urlForDatabase(configured, ADMIN_DATABASE);
|
|
23
|
+
}
|
|
24
|
+
catch (cause) {
|
|
25
|
+
throw new Error(`LIGETI_TEST_DATABASE_URL is not a valid connection URL: ${JSON.stringify(configured)}.`, { cause });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function withoutPassword(url) {
|
|
29
|
+
const parsed = new URL(url);
|
|
30
|
+
if (parsed.password) {
|
|
31
|
+
parsed.password = "***";
|
|
32
|
+
}
|
|
33
|
+
return parsed.toString();
|
|
34
|
+
}
|
|
35
|
+
function slugify(ref) {
|
|
36
|
+
return ref
|
|
37
|
+
.toLowerCase()
|
|
38
|
+
.replace(/[^a-z0-9]+/g, "_")
|
|
39
|
+
.replace(/^_+|_+$/g, "")
|
|
40
|
+
.slice(0, MAX_SLUG_LENGTH);
|
|
41
|
+
}
|
|
42
|
+
function currentBranch() {
|
|
43
|
+
const fromCi = process.env.CI_COMMIT_REF_SLUG;
|
|
44
|
+
if (fromCi) {
|
|
45
|
+
return fromCi;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
return execFileSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
49
|
+
encoding: "utf8",
|
|
50
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
51
|
+
timeout: 5_000,
|
|
52
|
+
}).trim();
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
let cachedSlug;
|
|
59
|
+
function branchSlug() {
|
|
60
|
+
cachedSlug ??= slugify(currentBranch());
|
|
61
|
+
return cachedSlug;
|
|
62
|
+
}
|
|
63
|
+
function databaseName() {
|
|
64
|
+
const slug = branchSlug();
|
|
65
|
+
const random = randomBytes(RANDOM_SUFFIX_BYTES).toString("hex");
|
|
66
|
+
return slug ? `${NAME_PREFIX}${slug}_${random}` : `${NAME_PREFIX}${random}`;
|
|
67
|
+
}
|
|
68
|
+
async function connectAsAdmin() {
|
|
69
|
+
const url = adminUrl();
|
|
70
|
+
const client = new Client({ connectionString: url });
|
|
71
|
+
try {
|
|
72
|
+
await client.connect();
|
|
73
|
+
}
|
|
74
|
+
catch (cause) {
|
|
75
|
+
throw new Error(`@ligeti/testing could not open its admin connection to ${withoutPassword(url)}, so it ` +
|
|
76
|
+
`cannot create a throwaway database for this test file. Is Postgres running (pnpm db:up)? ` +
|
|
77
|
+
`LIGETI_TEST_DATABASE_URL supplies only the host, port and credentials -- the database it ` +
|
|
78
|
+
`names is ignored, and "${ADMIN_DATABASE}" is used instead.`, { cause });
|
|
79
|
+
}
|
|
80
|
+
return client;
|
|
81
|
+
}
|
|
82
|
+
async function connectionCount(adminClient, name) {
|
|
83
|
+
const result = await adminClient.query("SELECT count(*)::int AS n FROM pg_stat_activity WHERE datname = $1 AND pid <> pg_backend_pid()", [name]);
|
|
84
|
+
return result.rows[0]?.n ?? 0;
|
|
85
|
+
}
|
|
86
|
+
async function waitForConnectionsToClose(adminClient, name) {
|
|
87
|
+
const deadline = Date.now() + CLOSE_GRACE_MS;
|
|
88
|
+
while ((await connectionCount(adminClient, name)) > 0 && Date.now() < deadline) {
|
|
89
|
+
await new Promise((resolve) => setTimeout(resolve, CLOSE_POLL_MS));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export async function createTestDatabase() {
|
|
93
|
+
const admin = adminUrl();
|
|
94
|
+
const name = databaseName();
|
|
95
|
+
const adminClient = await connectAsAdmin();
|
|
96
|
+
try {
|
|
97
|
+
await adminClient.query(`CREATE DATABASE "${name}"`);
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
await adminClient.end();
|
|
101
|
+
}
|
|
102
|
+
let dropped = false;
|
|
103
|
+
return {
|
|
104
|
+
url: urlForDatabase(admin, name),
|
|
105
|
+
async drop() {
|
|
106
|
+
if (dropped) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
dropped = true;
|
|
110
|
+
const dropClient = await connectAsAdmin();
|
|
111
|
+
try {
|
|
112
|
+
await waitForConnectionsToClose(dropClient, name);
|
|
113
|
+
await dropClient.query("SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = $1 AND pid <> pg_backend_pid()", [name]);
|
|
114
|
+
await dropClient.query(`DROP DATABASE IF EXISTS "${name}"`);
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
await dropClient.end();
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=postgres.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.js","sourceRoot":"","sources":["../src/postgres.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,yGAAyG;AACzG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAE5B,MAAM,iBAAiB,GAAG,oDAAoD,CAAC;AAE/E,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC,MAAM,WAAW,GAAG,cAAc,CAAC;AAEnC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,MAAM,oBAAoB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;gBACZ,OAAO;YACT,CAAC;YACD,OAAO,GAAG,IAAI,CAAC;YAEf,MAAM,UAAU,GAAG,MAAM,cAAc,EAAE,CAAC;YAC1C,IAAI,CAAC;gBACH,MAAM,yBAAyB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;gBAClD,MAAM,UAAU,CAAC,KAAK,CACpB,uGAAuG,EACvG,CAAC,IAAI,CAAC,CACP,CAAC;gBACF,MAAM,UAAU,CAAC,KAAK,CAAC,4BAA4B,IAAI,GAAG,CAAC,CAAC;YAC9D,CAAC;oBAAS,CAAC;gBACT,MAAM,UAAU,CAAC,GAAG,EAAE,CAAC;YACzB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface RecordedTurn {
|
|
2
|
+
readonly dir: string;
|
|
3
|
+
readonly agent: "claude" | "opencode";
|
|
4
|
+
readonly prompt: string;
|
|
5
|
+
readonly sessionId: string | null;
|
|
6
|
+
readonly resumeFlag: string | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function readRecordedTurns(stateDir: string): Promise<readonly RecordedTurn[]>;
|
|
9
|
+
//# sourceMappingURL=recorded-turns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recorded-turns.d.ts","sourceRoot":"","sources":["../src/recorded-turns.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CA0C1F"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// ABOUTME: Reads back every agent turn an agent step ran under a state directory: the prompt, the
|
|
2
|
+
// ABOUTME: agent, the session id and any --resume flag, oldest first.
|
|
3
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
export async function readRecordedTurns(stateDir) {
|
|
6
|
+
const runsDir = path.join(stateDir, "runs");
|
|
7
|
+
const workflowSegments = await readdir(runsDir);
|
|
8
|
+
const attemptDirs = [];
|
|
9
|
+
for (const segment of workflowSegments) {
|
|
10
|
+
const segmentDir = path.join(runsDir, segment);
|
|
11
|
+
const attemptSegments = await readdir(segmentDir);
|
|
12
|
+
for (const attempt of attemptSegments) {
|
|
13
|
+
attemptDirs.push(path.join(segmentDir, attempt));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const withMtime = await Promise.all(attemptDirs.map(async (dir) => {
|
|
17
|
+
const promptPath = path.join(dir, "prompt.txt");
|
|
18
|
+
const { mtimeMs } = await stat(promptPath);
|
|
19
|
+
const prompt = await readFile(promptPath, "utf8");
|
|
20
|
+
const sessionId = await readFile(path.join(dir, "session-id"), "utf8")
|
|
21
|
+
.then((raw) => raw.trim())
|
|
22
|
+
.catch(() => null);
|
|
23
|
+
const log = await readFile(path.join(dir, "agent.log"), "utf8").catch(() => "");
|
|
24
|
+
const resumeMatch = /starting: .*--resume (\S+)/.exec(log);
|
|
25
|
+
return {
|
|
26
|
+
dir,
|
|
27
|
+
mtimeMs,
|
|
28
|
+
agent: /starting: \S+ run --format json /.test(log)
|
|
29
|
+
? "opencode"
|
|
30
|
+
: "claude",
|
|
31
|
+
prompt,
|
|
32
|
+
sessionId,
|
|
33
|
+
resumeFlag: resumeMatch?.[1] ?? null,
|
|
34
|
+
};
|
|
35
|
+
}));
|
|
36
|
+
withMtime.sort((a, b) => a.mtimeMs - b.mtimeMs);
|
|
37
|
+
return withMtime.map(({ dir, agent, prompt, sessionId, resumeFlag }) => ({
|
|
38
|
+
dir,
|
|
39
|
+
agent,
|
|
40
|
+
prompt,
|
|
41
|
+
sessionId,
|
|
42
|
+
resumeFlag,
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=recorded-turns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recorded-turns.js","sourceRoot":"","sources":["../src/recorded-turns.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,sEAAsE;AACtE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAU7B,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAgB;IACtD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,KAAK,MAAM,OAAO,IAAI,gBAAgB,EAAE,CAAC;QACvC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/C,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;QAClD,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;YACtC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAChD,MAAM,EAAE,OAAO,EAAE,GAAG,MAA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+1 @@
|
|
|
1
|
+
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../src/repo.ts"],"names":[],"mappings":"AAUA,wBAAsB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAG3E;AAED,wBAAsB,QAAQ,IAAI,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAgBlF"}
|
package/dist/repo.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// ABOUTME: A throwaway git repository with a bare `origin` remote and one initial commit, plus a
|
|
2
|
+
// ABOUTME: `git -C` runner, for tests that drive a workflow against a real checkout.
|
|
3
|
+
import { execFile } from "node:child_process";
|
|
4
|
+
import { mkdir, mkdtemp, realpath, writeFile } from "node:fs/promises";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
const execFileAsync = promisify(execFile);
|
|
9
|
+
export async function git(repoPath, args) {
|
|
10
|
+
const { stdout } = await execFileAsync("git", ["-C", repoPath, ...args]);
|
|
11
|
+
return stdout;
|
|
12
|
+
}
|
|
13
|
+
export async function makeRepo() {
|
|
14
|
+
const root = await realpath(await mkdtemp(path.join(tmpdir(), "ligeti-acceptance-repo-")));
|
|
15
|
+
const repoPath = path.join(root, "source");
|
|
16
|
+
const remotePath = path.join(root, "remote.git");
|
|
17
|
+
await mkdir(repoPath, { recursive: true });
|
|
18
|
+
await execFileAsync("git", ["init", "--bare", "--initial-branch=main", remotePath]);
|
|
19
|
+
await git(repoPath, ["init", "-q", "--initial-branch=main"]);
|
|
20
|
+
await git(repoPath, ["config", "user.email", "test@example.com"]);
|
|
21
|
+
await git(repoPath, ["config", "user.name", "Test"]);
|
|
22
|
+
await git(repoPath, ["config", "core.hooksPath", "/dev/null"]);
|
|
23
|
+
await git(repoPath, ["remote", "add", "origin", remotePath]);
|
|
24
|
+
await writeFile(path.join(repoPath, "fixture.txt"), "hello from the fixture repo\n");
|
|
25
|
+
await git(repoPath, ["add", "fixture.txt"]);
|
|
26
|
+
await git(repoPath, ["commit", "-q", "-m", "initial"]);
|
|
27
|
+
await git(repoPath, ["push", "origin", "main"]);
|
|
28
|
+
return { repoPath, remotePath };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=repo.js.map
|
package/dist/repo.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo.js","sourceRoot":"","sources":["../src/repo.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,qFAAqF;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,QAAgB,EAAE,IAAc;IACxD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IACzE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAC3F,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC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1
|
+
export interface FakeTelegramRequest {
|
|
2
|
+
readonly path: string;
|
|
3
|
+
readonly body: unknown;
|
|
4
|
+
}
|
|
5
|
+
export interface FakeTelegram {
|
|
6
|
+
readonly baseUrl: string;
|
|
7
|
+
readonly requests: readonly FakeTelegramRequest[];
|
|
8
|
+
close(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare function startFakeTelegram(chatId: string): Promise<FakeTelegram>;
|
|
11
|
+
//# sourceMappingURL=telegram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telegram.d.ts","sourceRoot":"","sources":["../src/telegram.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AACD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAClD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAmCvE"}
|
package/dist/telegram.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// ABOUTME: A loopback fake of the Telegram Bot API that records every request and answers each
|
|
2
|
+
// ABOUTME: with a successful sendMessage result for the given chat.
|
|
3
|
+
import { createServer } from "node:http";
|
|
4
|
+
export function startFakeTelegram(chatId) {
|
|
5
|
+
const requests = [];
|
|
6
|
+
const server = createServer((req, res) => {
|
|
7
|
+
const chunks = [];
|
|
8
|
+
req.on("data", (chunk) => chunks.push(chunk));
|
|
9
|
+
req.on("end", () => {
|
|
10
|
+
const raw = Buffer.concat(chunks).toString("utf8");
|
|
11
|
+
requests.push({
|
|
12
|
+
path: req.url ?? "",
|
|
13
|
+
body: raw.length > 0 ? JSON.parse(raw) : undefined,
|
|
14
|
+
});
|
|
15
|
+
res.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify({
|
|
16
|
+
ok: true,
|
|
17
|
+
result: { message_id: 1, date: 0, chat: { id: Number(chatId) } },
|
|
18
|
+
}));
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
server.listen(0, "127.0.0.1", () => {
|
|
23
|
+
const address = server.address();
|
|
24
|
+
const port = typeof address === "object" && address !== null ? address.port : 0;
|
|
25
|
+
resolve({
|
|
26
|
+
baseUrl: `http://127.0.0.1:${String(port)}`,
|
|
27
|
+
requests,
|
|
28
|
+
close: () => new Promise((closed) => {
|
|
29
|
+
server.close(() => {
|
|
30
|
+
closed();
|
|
31
|
+
});
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=telegram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telegram.js","sourceRoot":"","sources":["../src/telegram.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,oEAAoE;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAYzC,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,MAAM,QAAQ,GAA0B,EAAE,CAAC;IAC3C,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACvC,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACtD,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACjB,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,C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AC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/wait.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.d.ts","sourceRoot":"","sources":["../src/wait.ts"],"names":[],"mappings":"AAEA,wBAAsB,SAAS,CAC7B,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,EACvC,SAAS,SAAS,EAClB,UAAU,SAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
package/dist/wait.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// ABOUTME: Polls a condition until it holds or a deadline passes, for tests waiting on something
|
|
2
|
+
// ABOUTME: another process brings about.
|
|
3
|
+
export async function waitUntil(check, timeoutMs = 30_000, intervalMs = 200) {
|
|
4
|
+
const deadline = Date.now() + timeoutMs;
|
|
5
|
+
for (;;) {
|
|
6
|
+
if (await check()) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (Date.now() > deadline) {
|
|
10
|
+
throw new Error("waitUntil: timed out");
|
|
11
|
+
}
|
|
12
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=wait.js.map
|
package/dist/wait.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.js","sourceRoot":"","sources":["../src/wait.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,yCAAyC;AACzC,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,KAAuC,EACvC,SAAS,GAAG,MAAM,EAClB,UAAU,GAAG,GAAG;IAEhB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IACxC,SAAS,CAAC;QACR,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QACD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;IAClE,CAAC;AACH,CAAC"}
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ChildProcessWithoutNullStreams } from "node:child_process";
|
|
2
|
+
export declare function ligetiWorkerBin(): string;
|
|
3
|
+
export interface WorkerProcess {
|
|
4
|
+
child: ChildProcessWithoutNullStreams;
|
|
5
|
+
stdout: string;
|
|
6
|
+
stderr: string;
|
|
7
|
+
stop(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare function startWorker(dir: string, env: NodeJS.ProcessEnv): WorkerProcess;
|
|
10
|
+
interface ManifestStep {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly callbackPayload?: object;
|
|
13
|
+
}
|
|
14
|
+
export interface Manifest {
|
|
15
|
+
readonly steps: readonly ManifestStep[];
|
|
16
|
+
}
|
|
17
|
+
export declare function describeWorkflowPackage(dir: string): Promise<Manifest>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAW1F,wBAAgB,eAAe,IAAI,MAAM,CASxC;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,8BAA8B,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,aAAa,CAiC9E;AAED,UAAU,YAAY;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AACD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;CACzC;AAED,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAG5E"}
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// ABOUTME: Runs a workflow package under a real `ligeti-worker` process, and describes its manifest,
|
|
2
|
+
// ABOUTME: using the ligeti-worker bin of the @ligeti/sdk installed next to this package.
|
|
3
|
+
import { execFile, spawn } from "node:child_process";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
const execFileAsync = promisify(execFile);
|
|
8
|
+
export function ligetiWorkerBin() {
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const sdkPackageJsonPath = require.resolve("@ligeti/sdk/package.json");
|
|
11
|
+
const pkg = require(sdkPackageJsonPath);
|
|
12
|
+
const binRel = pkg.bin["ligeti-worker"];
|
|
13
|
+
if (binRel === undefined) {
|
|
14
|
+
throw new Error(`${sdkPackageJsonPath} does not declare a "ligeti-worker" bin entry`);
|
|
15
|
+
}
|
|
16
|
+
return path.resolve(path.dirname(sdkPackageJsonPath), binRel);
|
|
17
|
+
}
|
|
18
|
+
export function startWorker(dir, env) {
|
|
19
|
+
const child = spawn(process.execPath, [ligetiWorkerBin(), "run", dir], {
|
|
20
|
+
env: { ...process.env, ...env },
|
|
21
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
22
|
+
});
|
|
23
|
+
const proc = {
|
|
24
|
+
child,
|
|
25
|
+
stdout: "",
|
|
26
|
+
stderr: "",
|
|
27
|
+
async stop() {
|
|
28
|
+
if (child.exitCode !== null || child.killed) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
child.stdin.end();
|
|
32
|
+
await new Promise((resolve) => {
|
|
33
|
+
const timer = setTimeout(() => {
|
|
34
|
+
child.kill("SIGKILL");
|
|
35
|
+
resolve();
|
|
36
|
+
}, 5000);
|
|
37
|
+
child.once("exit", () => {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
resolve();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
child.stdout.on("data", (d) => {
|
|
45
|
+
proc.stdout += d.toString();
|
|
46
|
+
});
|
|
47
|
+
child.stderr.on("data", (d) => {
|
|
48
|
+
proc.stderr += d.toString();
|
|
49
|
+
});
|
|
50
|
+
return proc;
|
|
51
|
+
}
|
|
52
|
+
export async function describeWorkflowPackage(dir) {
|
|
53
|
+
const { stdout } = await execFileAsync(process.execPath, [ligetiWorkerBin(), "describe", dir]);
|
|
54
|
+
return JSON.parse(stdout);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,0FAA0F;AAC1F,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAuC,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAM1C,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,0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AC,KAAK,CAAC,CAAC;oBACpB,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IACF,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE;QACpC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE;QACpC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAUD,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,GAAW;IACvD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,eAAe,EAAE,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/F,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAa,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"Stop": [
|
|
4
|
+
{
|
|
5
|
+
"hooks": [
|
|
6
|
+
{
|
|
7
|
+
"type": "command",
|
|
8
|
+
"command": "[ -z \"${LIGETI_AGENT_HOOK:-}\" ] || bash \"$LIGETI_AGENT_HOOK\"",
|
|
9
|
+
"timeout": 30
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"StopFailure": [
|
|
15
|
+
{
|
|
16
|
+
"hooks": [
|
|
17
|
+
{
|
|
18
|
+
"type": "command",
|
|
19
|
+
"command": "[ -z \"${LIGETI_AGENT_HOOK:-}\" ] || bash \"$LIGETI_AGENT_HOOK\"",
|
|
20
|
+
"timeout": 30
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ligeti/testing",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "2.0.3",
|
|
4
|
+
"description": "Ligeti test kit: real-process test doubles (throwaway Postgres databases, fake claude/opencode/herdr, fake GitLab, Bitbucket, Jira and Telegram) and helpers that run a workflow package under a real ligeti-worker.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://gitlab.com/nagyv-projects/ligeti.git",
|
|
10
|
+
"directory": "packages/testing"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"bin",
|
|
21
|
+
"fixtures"
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"ajv": "^8.20.0",
|
|
25
|
+
"pg": "^8.23.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@ligeti/sdk": "^2.1.2"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/pg": "^8.15.5",
|
|
32
|
+
"@ligeti/sdk": "2.1.2"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {}
|
|
6
35
|
}
|