@open-qa/qa 0.0.0-stage → 0.1.0-alpha.4
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 +204 -0
- package/NOTICE +7 -0
- package/THIRD_PARTY.md +12 -0
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/drizzle/0000_qa_core.sql +158 -0
- package/drizzle/0001_run_health.sql +3 -0
- package/drizzle/0002_bounded_cleanup.sql +5 -0
- package/drizzle/0003_step_replay_cache.sql +9 -0
- package/drizzle/0004_credential_expiry.sql +1 -0
- package/drizzle/0005_server_api.sql +19 -0
- package/drizzle/0006_submission_created.sql +3 -0
- package/drizzle/0007_findings.sql +19 -0
- package/drizzle/0008_classification_labels.sql +14 -0
- package/drizzle/0009_job_queue.sql +20 -0
- package/drizzle/0010_result_notifications.sql +13 -0
- package/drizzle/0011_result_notification_retries.sql +5 -0
- package/drizzle/0012_result_notification_flows.sql +44 -0
- package/drizzle/0013_flow_quarantine.sql +35 -0
- package/drizzle/0014_run_budgets.sql +2 -0
- package/drizzle/0015_flow_lifecycle.sql +9 -0
- package/drizzle/0016_open_qa_classification.sql +28 -0
- package/drizzle/meta/0000_snapshot.json +1002 -0
- package/drizzle/meta/0001_snapshot.json +1021 -0
- package/drizzle/meta/0002_snapshot.json +1027 -0
- package/drizzle/meta/0003_snapshot.json +1081 -0
- package/drizzle/meta/0004_snapshot.json +1087 -0
- package/drizzle/meta/0005_snapshot.json +1210 -0
- package/drizzle/meta/0006_snapshot.json +1244 -0
- package/drizzle/meta/0007_snapshot.json +1353 -0
- package/drizzle/meta/0008_snapshot.json +1435 -0
- package/drizzle/meta/0009_snapshot.json +1587 -0
- package/drizzle/meta/0010_snapshot.json +1675 -0
- package/drizzle/meta/0011_snapshot.json +1692 -0
- package/drizzle/meta/0012_snapshot.json +1818 -0
- package/drizzle/meta/0013_snapshot.json +2016 -0
- package/drizzle/meta/0014_snapshot.json +2028 -0
- package/drizzle/meta/0015_snapshot.json +2064 -0
- package/drizzle/meta/0016_snapshot.json +2076 -0
- package/drizzle/meta/_journal.json +125 -0
- package/package.json +118 -4
- package/problem-matcher.json +32 -0
- package/src/adapters/db-lease-pool.d.ts +25 -0
- package/src/adapters/db-lease-pool.js +293 -0
- package/src/adapters/dir-artifact-store.d.ts +9 -0
- package/src/adapters/dir-artifact-store.js +64 -0
- package/src/adapters/e2b-agent.d.ts +7 -0
- package/src/adapters/e2b-agent.js +94 -0
- package/src/adapters/e2b-artifacts.d.ts +3 -0
- package/src/adapters/e2b-artifacts.js +66 -0
- package/src/adapters/e2b-bounded.d.ts +1 -0
- package/src/adapters/e2b-bounded.js +19 -0
- package/src/adapters/e2b-client.d.ts +33 -0
- package/src/adapters/e2b-client.js +114 -0
- package/src/adapters/e2b-executor.d.ts +26 -0
- package/src/adapters/e2b-executor.js +194 -0
- package/src/adapters/e2b-lifetime.d.ts +20 -0
- package/src/adapters/e2b-lifetime.js +73 -0
- package/src/adapters/e2b-prune.d.ts +13 -0
- package/src/adapters/e2b-prune.js +42 -0
- package/src/adapters/file-replay-cache.d.ts +14 -0
- package/src/adapters/file-replay-cache.js +120 -0
- package/src/adapters/file-run-store.d.ts +175 -0
- package/src/adapters/file-run-store.js +280 -0
- package/src/adapters/fixed-lease-pool.d.ts +10 -0
- package/src/adapters/fixed-lease-pool.js +237 -0
- package/src/adapters/gcs/artifact-store.d.ts +49 -0
- package/src/adapters/gcs/artifact-store.js +247 -0
- package/src/adapters/gcs/client.d.ts +22 -0
- package/src/adapters/gcs/client.js +106 -0
- package/src/adapters/gcs/download.d.ts +9 -0
- package/src/adapters/gcs/download.js +43 -0
- package/src/adapters/gcs/index.d.ts +8 -0
- package/src/adapters/gcs/index.js +23 -0
- package/src/adapters/gcs/periodic-flush.d.ts +5 -0
- package/src/adapters/gcs/periodic-flush.js +16 -0
- package/src/adapters/gcs/pg-catalog.d.ts +16 -0
- package/src/adapters/gcs/pg-catalog.js +149 -0
- package/src/adapters/gcs/replay-completeness.d.ts +1 -0
- package/src/adapters/gcs/replay-completeness.js +65 -0
- package/src/adapters/gcs/scan-upload.d.ts +10 -0
- package/src/adapters/gcs/scan-upload.js +26 -0
- package/src/adapters/index.d.ts +5 -0
- package/src/adapters/index.js +12 -0
- package/src/adapters/lease-transaction.d.ts +2 -0
- package/src/adapters/lease-transaction.js +61 -0
- package/src/adapters/local-credential-resolver.d.ts +5 -0
- package/src/adapters/local-credential-resolver.js +15 -0
- package/src/adapters/local-env.d.ts +1 -0
- package/src/adapters/local-env.js +37 -0
- package/src/adapters/local-files.d.ts +17 -0
- package/src/adapters/local-files.js +150 -0
- package/src/adapters/pg-classification-store.d.ts +58 -0
- package/src/adapters/pg-classification-store.js +112 -0
- package/src/adapters/pg-replay-cache.d.ts +16 -0
- package/src/adapters/pg-replay-cache.js +111 -0
- package/src/adapters/pg-run-store.d.ts +58 -0
- package/src/adapters/pg-run-store.js +399 -0
- package/src/adapters/resource-pools.d.ts +2 -0
- package/src/adapters/resource-pools.js +28 -0
- package/src/adapters/secret-manager-credential-resolver.d.ts +44 -0
- package/src/adapters/secret-manager-credential-resolver.js +102 -0
- package/src/artifact-scan.d.ts +21 -0
- package/src/artifact-scan.js +139 -0
- package/src/budget-confirmation.d.ts +23 -0
- package/src/budget-confirmation.js +43 -0
- package/src/cache-command.d.ts +7 -0
- package/src/cache-command.js +107 -0
- package/src/classification-command.d.ts +14 -0
- package/src/classification-command.js +72 -0
- package/src/classification-diff.d.ts +10 -0
- package/src/classification-diff.js +47 -0
- package/src/classification-model.d.ts +17 -0
- package/src/classification-model.js +51 -0
- package/src/classification-notifier.d.ts +21 -0
- package/src/classification-notifier.js +34 -0
- package/src/classify-runs.d.ts +31 -0
- package/src/classify-runs.js +138 -0
- package/src/cli-program.d.ts +9 -0
- package/src/cli-program.js +172 -0
- package/src/cli.d.ts +2 -0
- package/src/cli.js +12 -0
- package/src/commands.d.ts +7 -0
- package/src/commands.js +17 -0
- package/src/credential-references.d.ts +24 -0
- package/src/credential-references.js +33 -0
- package/src/db/commands.d.ts +1 -0
- package/src/db/commands.js +34 -0
- package/src/db/credentials.d.ts +16 -0
- package/src/db/credentials.js +73 -0
- package/src/db/database.d.ts +12 -0
- package/src/db/database.js +135 -0
- package/src/db/event-chunks.d.ts +405 -0
- package/src/db/event-chunks.js +74 -0
- package/src/db/fencing.d.ts +8 -0
- package/src/db/fencing.js +16 -0
- package/src/db/flow-status.d.ts +41 -0
- package/src/db/flow-status.js +208 -0
- package/src/db/index.d.ts +12 -0
- package/src/db/index.js +24 -0
- package/src/db/queries.d.ts +73 -0
- package/src/db/queries.js +122 -0
- package/src/db/resources.d.ts +14 -0
- package/src/db/resources.js +61 -0
- package/src/db/schema.d.ts +3532 -0
- package/src/db/schema.js +501 -0
- package/src/demo-command.d.ts +1 -0
- package/src/demo-command.js +50 -0
- package/src/doctor-command.d.ts +15 -0
- package/src/doctor-command.js +275 -0
- package/src/doctor-summary.d.ts +2 -0
- package/src/doctor-summary.js +31 -0
- package/src/draft-api.d.ts +460 -0
- package/src/draft-api.js +333 -0
- package/src/draft-command.d.ts +10 -0
- package/src/draft-command.js +73 -0
- package/src/draft-hooks.d.ts +3 -0
- package/src/draft-hooks.js +33 -0
- package/src/draft-pages.d.ts +11 -0
- package/src/draft-pages.js +82 -0
- package/src/engine.d.ts +105 -0
- package/src/engine.js +323 -0
- package/src/execution-snapshot.d.ts +21 -0
- package/src/execution-snapshot.js +141 -0
- package/src/flow-check.d.ts +9 -0
- package/src/flow-check.js +68 -0
- package/src/flow-lifecycle.d.ts +6 -0
- package/src/flow-lifecycle.js +61 -0
- package/src/flow-lint.d.ts +8 -0
- package/src/flow-lint.js +73 -0
- package/src/flow-loader.d.ts +219 -0
- package/src/flow-loader.js +236 -0
- package/src/flow-source.d.ts +2 -0
- package/src/flow-source.js +6 -0
- package/src/flows-api.d.ts +1 -0
- package/src/flows-api.js +12 -0
- package/src/heal-notification.d.ts +16 -0
- package/src/heal-notification.js +62 -0
- package/src/hooks/api.d.ts +29 -0
- package/src/hooks/api.js +15 -0
- package/src/hooks/consumer.d.ts +18 -0
- package/src/hooks/consumer.js +98 -0
- package/src/hooks/loader.d.ts +6 -0
- package/src/hooks/loader.js +28 -0
- package/src/hooks/registry.d.ts +22 -0
- package/src/hooks/registry.js +23 -0
- package/src/hooks/runner.d.ts +19 -0
- package/src/hooks/runner.js +279 -0
- package/src/hooks/session-cache.d.ts +16 -0
- package/src/hooks/session-cache.js +42 -0
- package/src/hooks/session-store.d.ts +20 -0
- package/src/hooks/session-store.js +95 -0
- package/src/hooks/worker.d.ts +1 -0
- package/src/hooks/worker.js +84 -0
- package/src/http-stage-client.d.ts +367 -0
- package/src/http-stage-client.js +190 -0
- package/src/independent-model.d.ts +22 -0
- package/src/independent-model.js +215 -0
- package/src/lifecycle-command.d.ts +15 -0
- package/src/lifecycle-command.js +190 -0
- package/src/local-command.d.ts +3 -0
- package/src/local-command.js +27 -0
- package/src/local-host-executor.d.ts +38 -0
- package/src/local-host-executor.js +196 -0
- package/src/open-command.d.ts +7 -0
- package/src/open-command.js +39 -0
- package/src/operations-api.d.ts +2 -0
- package/src/operations-api.js +6 -0
- package/src/personas.d.ts +2 -0
- package/src/personas.js +61 -0
- package/src/program-runner.d.ts +3 -0
- package/src/program-runner.js +263 -0
- package/src/program-sandbox.py +75 -0
- package/src/program-scratch.d.ts +2 -0
- package/src/program-scratch.js +48 -0
- package/src/program-worker.mjs +101 -0
- package/src/public-id.d.ts +2 -0
- package/src/public-id.js +5 -0
- package/src/public-report-url.d.ts +1 -0
- package/src/public-report-url.js +18 -0
- package/src/publication-check.d.ts +1 -0
- package/src/publication-check.js +31 -0
- package/src/quarantine-command.d.ts +9 -0
- package/src/quarantine-command.js +69 -0
- package/src/remote-command.d.ts +30 -0
- package/src/remote-command.js +156 -0
- package/src/replay-image.d.ts +1 -0
- package/src/replay-image.js +35 -0
- package/src/report/assets.d.ts +1 -0
- package/src/report/assets.js +5 -0
- package/src/report/browser.css +414 -0
- package/src/report/browser.d.ts +1 -0
- package/src/report/browser.js +219 -0
- package/src/report/data.d.ts +1 -0
- package/src/report/data.js +4 -0
- package/src/report/generate.d.ts +1 -0
- package/src/report/generate.js +54 -0
- package/src/report/load.d.ts +870 -0
- package/src/report/load.js +139 -0
- package/src/report/resource-table.d.ts +2 -0
- package/src/report/resource-table.js +4 -0
- package/src/report/status-icon.d.ts +2 -0
- package/src/report/status-icon.js +20 -0
- package/src/report/style.css +413 -0
- package/src/result-notifier.d.ts +121 -0
- package/src/result-notifier.js +230 -0
- package/src/result-transports.d.ts +12 -0
- package/src/result-transports.js +150 -0
- package/src/run-command.d.ts +32 -0
- package/src/run-command.js +493 -0
- package/src/run-setup-error.d.ts +11 -0
- package/src/run-setup-error.js +18 -0
- package/src/sandboxes-command.d.ts +9 -0
- package/src/sandboxes-command.js +29 -0
- package/src/screen-proxy.d.ts +5 -0
- package/src/screen-proxy.js +79 -0
- package/src/screen-url.d.ts +18 -0
- package/src/screen-url.js +54 -0
- package/src/server/app.d.ts +29 -0
- package/src/server/app.js +350 -0
- package/src/server/auth.d.ts +33 -0
- package/src/server/auth.js +113 -0
- package/src/server/credentials.d.ts +30 -0
- package/src/server/credentials.js +77 -0
- package/src/server/errors.d.ts +9 -0
- package/src/server/errors.js +26 -0
- package/src/server/index.d.ts +35 -0
- package/src/server/index.js +96 -0
- package/src/server/maintenance.d.ts +13 -0
- package/src/server/maintenance.js +54 -0
- package/src/server/repository.d.ts +534 -0
- package/src/server/repository.js +219 -0
- package/src/setup-command.d.ts +10 -0
- package/src/setup-command.js +52 -0
- package/src/stage-environment.d.ts +1 -0
- package/src/stage-environment.js +35 -0
- package/src/stage-supervisor.mjs +95 -0
- package/src/studio-command.d.ts +7 -0
- package/src/studio-command.js +47 -0
- package/src/studio-control.d.ts +5 -0
- package/src/studio-control.js +207 -0
- package/src/studio-review.d.ts +24 -0
- package/src/studio-review.js +64 -0
- package/src/studio-worker.d.ts +1 -0
- package/src/studio-worker.js +48 -0
- package/src/system-config.d.ts +7 -0
- package/src/system-config.js +70 -0
- package/src/terminal-reporter.d.ts +13 -0
- package/src/terminal-reporter.js +93 -0
- package/src/vendor/gmail.d.ts +45 -0
- package/src/vendor/gmail.js +193 -0
- package/src/watch-command.d.ts +16 -0
- package/src/watch-command.js +93 -0
- package/src/watch-state.d.ts +4 -0
- package/src/watch-state.js +53 -0
- package/src/worker/execution-error.d.ts +5 -0
- package/src/worker/execution-error.js +10 -0
- package/src/worker/execution.d.ts +24 -0
- package/src/worker/execution.js +190 -0
- package/src/worker/index.d.ts +8 -0
- package/src/worker/index.js +40 -0
- package/src/worker/prune.d.ts +3 -0
- package/src/worker/prune.js +22 -0
- package/src/worker/quarantine-notifications.d.ts +8 -0
- package/src/worker/quarantine-notifications.js +89 -0
- package/src/worker/queue.d.ts +65 -0
- package/src/worker/queue.js +438 -0
- package/src/worker/result-notifications.d.ts +28 -0
- package/src/worker/result-notifications.js +347 -0
- package/src/worker/store.d.ts +4 -0
- package/src/worker/store.js +46 -0
- package/src/worker/worker.d.ts +21 -0
- package/src/worker/worker.js +140 -0
- package/README.md +0 -3
package/src/draft-api.js
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { execFile, spawn } from "node:child_process";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { link, lstat, mkdir, open, readFile, unlink } from "node:fs/promises";
|
|
5
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
import { stringify } from "yaml";
|
|
8
|
+
import {
|
|
9
|
+
buildDraftInput,
|
|
10
|
+
assertDraftCredentials,
|
|
11
|
+
draftDiagnostic,
|
|
12
|
+
DRAFT_DIRECTORY,
|
|
13
|
+
isDraftPath,
|
|
14
|
+
compile,
|
|
15
|
+
draftIssueSchema,
|
|
16
|
+
generateDraft,
|
|
17
|
+
parseFlow,
|
|
18
|
+
resolveFlowDefaults,
|
|
19
|
+
SecretRedactor,
|
|
20
|
+
suiteSchema,
|
|
21
|
+
draftTimeout
|
|
22
|
+
} from "@open-qa/qa-engine";
|
|
23
|
+
import { assertDirectory, assertRegularFile, hasCode } from "./adapters/local-files.js";
|
|
24
|
+
import { loadConfig, loadFlowKeys } from "./flow-loader.js";
|
|
25
|
+
import { validateDraftHooks } from "./draft-hooks.js";
|
|
26
|
+
import { lintFlow } from "./flow-lint.js";
|
|
27
|
+
import { parseYamlSource } from "./flow-source.js";
|
|
28
|
+
const exec = promisify(execFile);
|
|
29
|
+
async function readGithubIssue(number, repo, signal, run = async (args, signal2) => {
|
|
30
|
+
try {
|
|
31
|
+
return (await exec("gh", args, { signal: signal2, timeout: 3e4, maxBuffer: 256e3 })).stdout;
|
|
32
|
+
} catch {
|
|
33
|
+
throw new Error("Cannot read issue with gh; check repository access and issue number");
|
|
34
|
+
}
|
|
35
|
+
}) {
|
|
36
|
+
if (!Number.isSafeInteger(number) || number < 1) throw new Error("Invalid issue number");
|
|
37
|
+
if (repo && !/^[\w.-]+\/[\w.-]+$/.test(repo)) throw new Error("Repository must be owner/name");
|
|
38
|
+
const args = [
|
|
39
|
+
"issue",
|
|
40
|
+
"view",
|
|
41
|
+
String(number),
|
|
42
|
+
"--json",
|
|
43
|
+
"number,title,body",
|
|
44
|
+
...repo ? ["--repo", repo] : []
|
|
45
|
+
];
|
|
46
|
+
const issue = draftIssueSchema.parse(JSON.parse(await run(args, signal)));
|
|
47
|
+
if (issue.number !== number) throw new Error("Issue identity does not match request");
|
|
48
|
+
return issue;
|
|
49
|
+
}
|
|
50
|
+
async function readText(file) {
|
|
51
|
+
await assertRegularFile(file);
|
|
52
|
+
if ((await lstat(file)).size > 256e3) throw new Error("Draft input file is too large");
|
|
53
|
+
return readFile(file, "utf8");
|
|
54
|
+
}
|
|
55
|
+
async function directories(root, suite) {
|
|
56
|
+
if (isAbsolute(suite) || suite.split(/[\\/]/).includes("..") || isDraftPath(suite))
|
|
57
|
+
throw new Error("Invalid suite directory");
|
|
58
|
+
const path = resolve(root, suite);
|
|
59
|
+
const parts = relative(root, path).split(/[\\/]/).filter(Boolean);
|
|
60
|
+
await assertDirectory(root);
|
|
61
|
+
let current = root;
|
|
62
|
+
for (const part of parts) {
|
|
63
|
+
current = join(current, part);
|
|
64
|
+
try {
|
|
65
|
+
await assertDirectory(current);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (hasCode(error, "ENOENT"))
|
|
68
|
+
throw new Error("Suite directory does not exist; choose an existing suite", {
|
|
69
|
+
cause: error
|
|
70
|
+
});
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return path;
|
|
75
|
+
}
|
|
76
|
+
async function draftIssue(request, dependencies) {
|
|
77
|
+
try {
|
|
78
|
+
return await createDraft(request, dependencies);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (hasCode(error, "ENOENT"))
|
|
81
|
+
throw new Error("Draft input is missing; check the QA root, qa.md and suite directory", {
|
|
82
|
+
cause: error
|
|
83
|
+
});
|
|
84
|
+
const message = draftDiagnostic(error);
|
|
85
|
+
if (error instanceof Error && message === error.message) throw error;
|
|
86
|
+
throw new Error(message, { cause: error });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function createDraft(request, dependencies) {
|
|
90
|
+
if (!request.model.trim()) throw new Error("Draft model is required");
|
|
91
|
+
if (!Number.isSafeInteger(request.issue) || request.issue < 1)
|
|
92
|
+
throw new Error("Invalid issue number");
|
|
93
|
+
const timeoutMs = draftTimeout(request.timeoutMs);
|
|
94
|
+
const signal = AbortSignal.any([
|
|
95
|
+
AbortSignal.timeout(timeoutMs),
|
|
96
|
+
...request.signal ? [request.signal] : []
|
|
97
|
+
]);
|
|
98
|
+
signal.throwIfAborted();
|
|
99
|
+
const root = resolve(request.root);
|
|
100
|
+
const suite = await directories(root, request.suite ?? ".");
|
|
101
|
+
const qaMarkdown = await readText(join(root, "qa.md"));
|
|
102
|
+
const config = await loadConfig(root);
|
|
103
|
+
let defaults = {};
|
|
104
|
+
for (let directory = suite; ; directory = dirname(directory)) {
|
|
105
|
+
try {
|
|
106
|
+
defaults = suiteSchema.parse(
|
|
107
|
+
parseYamlSource(
|
|
108
|
+
join(directory, "_suite.yaml"),
|
|
109
|
+
await readText(join(directory, "_suite.yaml"))
|
|
110
|
+
).value
|
|
111
|
+
);
|
|
112
|
+
break;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (!hasCode(error, "ENOENT")) throw error;
|
|
115
|
+
}
|
|
116
|
+
if (directory === root) break;
|
|
117
|
+
}
|
|
118
|
+
for (const phase of ["setup", "teardown"]) {
|
|
119
|
+
if (config.defaults?.[phase]?.length && defaults[phase] === void 0)
|
|
120
|
+
throw new Error(`Draft ${phase} hooks must be declared in the suite`);
|
|
121
|
+
}
|
|
122
|
+
await validateDraftHooks(root, defaults);
|
|
123
|
+
const key = `issue-${request.issue}`;
|
|
124
|
+
await assertAvailable(root, suite, key);
|
|
125
|
+
const issue = await (dependencies.readIssue ?? readGithubIssue)(
|
|
126
|
+
request.issue,
|
|
127
|
+
request.repo,
|
|
128
|
+
signal
|
|
129
|
+
);
|
|
130
|
+
if (issue.number !== request.issue) throw new Error("Issue identity does not match request");
|
|
131
|
+
const rawInput = buildDraftInput(issue, qaMarkdown);
|
|
132
|
+
const access = await dependencies.credentials.resolve({
|
|
133
|
+
runtime: dependencies.runtime.id,
|
|
134
|
+
actor: "draft",
|
|
135
|
+
purpose: "draft"
|
|
136
|
+
});
|
|
137
|
+
assertDraftCredentials(access);
|
|
138
|
+
const redactor = new SecretRedactor();
|
|
139
|
+
if (access.mode === "env")
|
|
140
|
+
redactor.add(
|
|
141
|
+
Object.entries(access.env).filter(([key2]) => /KEY|TOKEN|SECRET|PASSWORD/.test(key2)).map(([, value]) => value)
|
|
142
|
+
);
|
|
143
|
+
const input = redactor.json(rawInput);
|
|
144
|
+
const screenshots = dependencies.capture ? await dependencies.capture(input, config, signal) : [];
|
|
145
|
+
if (screenshots.length > 3 || screenshots.some(({ image }) => image.mimeType !== "image/jpeg" || image.data.length > 18e4))
|
|
146
|
+
throw new Error("Invalid draft screenshots");
|
|
147
|
+
const effectiveDefaults = suiteSchema.parse(resolveFlowDefaults({}, config, defaults));
|
|
148
|
+
const result = await generateDraft(input, {
|
|
149
|
+
runtime: dependencies.runtime,
|
|
150
|
+
credentials: { resolve: async () => access },
|
|
151
|
+
model: request.model,
|
|
152
|
+
images: screenshots.map((item) => item.image),
|
|
153
|
+
timeoutMs,
|
|
154
|
+
requiresBudget: effectiveDefaults.tier === "T1" && !effectiveDefaults.budget?.actions && !effectiveDefaults.budget?.minutes,
|
|
155
|
+
onUsage: dependencies.onUsage,
|
|
156
|
+
trustedHooks: { setup: defaults.setup, teardown: defaults.teardown },
|
|
157
|
+
signal,
|
|
158
|
+
validate(yaml) {
|
|
159
|
+
const source = parseYamlSource("draft.flow.yaml", yaml).value;
|
|
160
|
+
if (!source || typeof source !== "object" || Array.isArray(source))
|
|
161
|
+
throw new Error("Expected a flow object");
|
|
162
|
+
if (["setup", "teardown", "run"].some((field) => Object.hasOwn(source, field)))
|
|
163
|
+
throw new Error("Model-authored hooks and run are not allowed in drafts");
|
|
164
|
+
const flow = parseFlow({ ...source, key, status: "draft", prod: "never" }, config, defaults);
|
|
165
|
+
compile(flow);
|
|
166
|
+
const warnings = lintFlow(flow);
|
|
167
|
+
if (warnings.length)
|
|
168
|
+
throw new Error(
|
|
169
|
+
warnings.map((warning) => `${warning.rule}: ${warning.message}`).join("\n")
|
|
170
|
+
);
|
|
171
|
+
return flow;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
const publicationSignal = AbortSignal.any([
|
|
175
|
+
AbortSignal.timeout(3e4),
|
|
176
|
+
...request.signal ? [request.signal] : []
|
|
177
|
+
]);
|
|
178
|
+
publicationSignal.throwIfAborted();
|
|
179
|
+
const lock = await open(root, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
180
|
+
try {
|
|
181
|
+
await new Promise((resolve2, reject) => {
|
|
182
|
+
const child = spawn("flock", ["-x", "3"], {
|
|
183
|
+
stdio: ["ignore", "ignore", "ignore", lock.fd],
|
|
184
|
+
signal: publicationSignal
|
|
185
|
+
});
|
|
186
|
+
child.once(
|
|
187
|
+
"error",
|
|
188
|
+
() => reject(
|
|
189
|
+
publicationSignal.aborted ? new Error("Draft publication was canceled or timed out") : new Error("Draft publication requires the flock utility")
|
|
190
|
+
)
|
|
191
|
+
);
|
|
192
|
+
child.once(
|
|
193
|
+
"close",
|
|
194
|
+
(code) => code === 0 ? resolve2() : reject(new Error("Could not lock draft publication"))
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
publicationSignal.throwIfAborted();
|
|
198
|
+
await assertAvailable(root, suite, key);
|
|
199
|
+
publicationSignal.throwIfAborted();
|
|
200
|
+
const directory = join(suite, DRAFT_DIRECTORY);
|
|
201
|
+
try {
|
|
202
|
+
await mkdir(directory, { mode: 448 });
|
|
203
|
+
} catch (error) {
|
|
204
|
+
if (!hasCode(error, "EEXIST")) throw error;
|
|
205
|
+
}
|
|
206
|
+
await assertDirectory(directory);
|
|
207
|
+
const files = [
|
|
208
|
+
[
|
|
209
|
+
`${key}.draft.json`,
|
|
210
|
+
JSON.stringify(
|
|
211
|
+
{
|
|
212
|
+
input,
|
|
213
|
+
screenshots,
|
|
214
|
+
plan: result.plan,
|
|
215
|
+
coverage: result.coverage,
|
|
216
|
+
attempts: result.attempts,
|
|
217
|
+
plannerAttempts: result.plannerAttempts,
|
|
218
|
+
usage: result.usage
|
|
219
|
+
},
|
|
220
|
+
null,
|
|
221
|
+
2
|
|
222
|
+
) + "\n"
|
|
223
|
+
],
|
|
224
|
+
[`${key}.review.md`, draftReview(input, result)],
|
|
225
|
+
[
|
|
226
|
+
`${key}.flow.yaml`,
|
|
227
|
+
stringify({
|
|
228
|
+
...parseYamlSource("draft.flow.yaml", result.yaml).value,
|
|
229
|
+
key,
|
|
230
|
+
status: "draft",
|
|
231
|
+
prod: "never"
|
|
232
|
+
})
|
|
233
|
+
]
|
|
234
|
+
];
|
|
235
|
+
const published = [];
|
|
236
|
+
const temporaries = /* @__PURE__ */ new Set();
|
|
237
|
+
try {
|
|
238
|
+
for (const [name, content] of files) {
|
|
239
|
+
const file = join(directory, name);
|
|
240
|
+
const temporary = join(directory, `.draft-${randomUUID()}`);
|
|
241
|
+
publicationSignal.throwIfAborted();
|
|
242
|
+
const handle = await open(temporary, "wx", 384);
|
|
243
|
+
temporaries.add(temporary);
|
|
244
|
+
try {
|
|
245
|
+
await handle.writeFile(content, { signal: publicationSignal });
|
|
246
|
+
} finally {
|
|
247
|
+
await handle.close();
|
|
248
|
+
}
|
|
249
|
+
publicationSignal.throwIfAborted();
|
|
250
|
+
await link(temporary, file);
|
|
251
|
+
published.push(file);
|
|
252
|
+
await unlink(temporary);
|
|
253
|
+
temporaries.delete(temporary);
|
|
254
|
+
}
|
|
255
|
+
publicationSignal.throwIfAborted();
|
|
256
|
+
} catch (error) {
|
|
257
|
+
await Promise.allSettled(
|
|
258
|
+
[...published.reverse(), ...temporaries].map((file) => unlink(file))
|
|
259
|
+
);
|
|
260
|
+
if (hasCode(error, "ABORT_ERR") && publicationSignal.aborted && publicationSignal.reason instanceof Error)
|
|
261
|
+
throw new Error(publicationSignal.reason.message, { cause: error });
|
|
262
|
+
if (hasCode(error, "EEXIST"))
|
|
263
|
+
throw new Error(
|
|
264
|
+
"Draft artifacts already exist; review the existing draft before regenerating"
|
|
265
|
+
);
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
key,
|
|
270
|
+
status: "draft",
|
|
271
|
+
source: relative(root, join(directory, files[2][0])),
|
|
272
|
+
bundle: relative(root, join(directory, files[0][0])),
|
|
273
|
+
review: relative(root, join(directory, files[1][0])),
|
|
274
|
+
...result
|
|
275
|
+
};
|
|
276
|
+
} finally {
|
|
277
|
+
await lock.close();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
async function assertAvailable(root, suite, key) {
|
|
281
|
+
const directory = join(suite, DRAFT_DIRECTORY);
|
|
282
|
+
try {
|
|
283
|
+
await assertDirectory(directory);
|
|
284
|
+
} catch (error) {
|
|
285
|
+
if (!hasCode(error, "ENOENT")) throw error;
|
|
286
|
+
}
|
|
287
|
+
let nestedDefaults = false;
|
|
288
|
+
try {
|
|
289
|
+
await lstat(join(directory, "_suite.yaml"));
|
|
290
|
+
nestedDefaults = true;
|
|
291
|
+
} catch (error) {
|
|
292
|
+
if (!hasCode(error, "ENOENT")) throw error;
|
|
293
|
+
}
|
|
294
|
+
if (nestedDefaults)
|
|
295
|
+
throw new Error(
|
|
296
|
+
"Drafts cannot contain drafts/_suite.yaml; move its settings to the parent suite before drafting"
|
|
297
|
+
);
|
|
298
|
+
for (const suffix of ["draft.json", "review.md", "flow.yaml"]) {
|
|
299
|
+
try {
|
|
300
|
+
await lstat(join(directory, `${key}.${suffix}`));
|
|
301
|
+
} catch (error) {
|
|
302
|
+
if (hasCode(error, "ENOENT")) continue;
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
305
|
+
throw new Error("Draft artifacts already exist; review the existing draft before regenerating");
|
|
306
|
+
}
|
|
307
|
+
const previous = (await loadFlowKeys(root)).get(key);
|
|
308
|
+
if (previous)
|
|
309
|
+
throw new Error(
|
|
310
|
+
`Flow key ${key} already exists at ${relative(root, previous)}; review it before regenerating`
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
function draftReview(input, result) {
|
|
314
|
+
const cell = (text) => text.replace(/([\\`*_[\]{}()!|])/g, "\\$1").replaceAll("<", "<").replace(/\r?\n/g, "<br>");
|
|
315
|
+
return `# Draft: ${cell(input.issue.title)}
|
|
316
|
+
|
|
317
|
+
Issue #${input.issue.number}. Human review required; this draft is excluded from suite runs.
|
|
318
|
+
|
|
319
|
+
## Journeys
|
|
320
|
+
|
|
321
|
+
${result.plan.journeys.map((journey) => `- ${cell(journey.actor)} wants ${cell(journey.goal)}; success: ${cell(journey.success)} (${journey.ac.join(", ")}).`).join("\n")}
|
|
322
|
+
|
|
323
|
+
## AC coverage
|
|
324
|
+
|
|
325
|
+
| AC | Requirement | Checks / human decision |
|
|
326
|
+
| --- | --- | --- |
|
|
327
|
+
${result.coverage.map((row) => `| ${row.ac} | ${cell(input.acceptanceCriteria.find((ac) => ac.id === row.ac).text)} | ${row.checks.length ? row.checks.map((check) => `${cell(check.step)}.${check.kind}${check.index === void 0 ? "" : `[${check.index}]`}`).join(", ") : `UNMAPPED: ${cell(row.reason)}`} |`).join("\n")}
|
|
328
|
+
`;
|
|
329
|
+
}
|
|
330
|
+
export {
|
|
331
|
+
draftIssue,
|
|
332
|
+
readGithubIssue
|
|
333
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface DraftCommandOptions {
|
|
2
|
+
issue: string;
|
|
3
|
+
root?: string;
|
|
4
|
+
suite?: string;
|
|
5
|
+
repo?: string;
|
|
6
|
+
model: string;
|
|
7
|
+
screenshots?: boolean;
|
|
8
|
+
timeout?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function draftCommand(options: DraftCommandOptions): Promise<number>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { PiRuntime } from "@open-qa/qa-agents";
|
|
2
|
+
import { draftTimeout } from "@open-qa/qa-engine";
|
|
3
|
+
import { LocalCredentialResolver } from "./adapters/local-credential-resolver.js";
|
|
4
|
+
import { draftIssue } from "./draft-api.js";
|
|
5
|
+
import { captureDraftPages } from "./draft-pages.js";
|
|
6
|
+
async function draftCommand(options) {
|
|
7
|
+
const timeoutMs = draftTimeout(
|
|
8
|
+
options.timeout === void 0 ? void 0 : Number(options.timeout)
|
|
9
|
+
);
|
|
10
|
+
const resolver = new LocalCredentialResolver();
|
|
11
|
+
const key = process.env.OPENAI_API_KEY;
|
|
12
|
+
if (!key)
|
|
13
|
+
throw new Error(
|
|
14
|
+
"draft requires a team OPENAI_API_KEY supplied by the caller; CLI login is not used"
|
|
15
|
+
);
|
|
16
|
+
let usage;
|
|
17
|
+
const controller = new AbortController();
|
|
18
|
+
const interrupt = () => controller.abort(new Error("Draft canceled by SIGINT"));
|
|
19
|
+
const terminate = () => controller.abort(new Error("Draft canceled by SIGTERM"));
|
|
20
|
+
process.on("SIGINT", interrupt);
|
|
21
|
+
process.on("SIGTERM", terminate);
|
|
22
|
+
try {
|
|
23
|
+
const result = await draftIssue(
|
|
24
|
+
{
|
|
25
|
+
...options,
|
|
26
|
+
timeoutMs,
|
|
27
|
+
signal: controller.signal,
|
|
28
|
+
issue: Number(options.issue),
|
|
29
|
+
root: options.root ?? ".qa"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
runtime: new PiRuntime(),
|
|
33
|
+
onUsage: (value) => {
|
|
34
|
+
usage = value;
|
|
35
|
+
},
|
|
36
|
+
credentials: {
|
|
37
|
+
resolve: (request) => resolver.resolve({
|
|
38
|
+
...request,
|
|
39
|
+
access: {
|
|
40
|
+
mode: "env",
|
|
41
|
+
env: {
|
|
42
|
+
OPENAI_API_KEY: key,
|
|
43
|
+
...process.env.OPENAI_BASE_URL ? { OPENAI_BASE_URL: process.env.OPENAI_BASE_URL } : {}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
},
|
|
48
|
+
...options.screenshots !== false ? {
|
|
49
|
+
capture: async (input, config, signal) => config.targets?.local ? captureDraftPages(input, config.targets.local, signal) : []
|
|
50
|
+
} : {}
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
console.log(
|
|
54
|
+
`Draft: ${result.source}
|
|
55
|
+
Input and coverage: ${result.bundle}
|
|
56
|
+
PR review outline: ${result.review}`
|
|
57
|
+
);
|
|
58
|
+
const unmapped = result.coverage.filter((row) => !row.checks.length);
|
|
59
|
+
if (unmapped.length)
|
|
60
|
+
console.log(`Human decision required: ${unmapped.map((row) => row.ac).join(", ")}`);
|
|
61
|
+
return 0;
|
|
62
|
+
} finally {
|
|
63
|
+
process.off("SIGINT", interrupt);
|
|
64
|
+
process.off("SIGTERM", terminate);
|
|
65
|
+
if (usage)
|
|
66
|
+
console.log(
|
|
67
|
+
`Draft usage: ${JSON.stringify({ ...usage, ...usage.costUsd !== void 0 ? { costUsd: Number(usage.costUsd.toFixed(6)) } : {} })}`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
draftCommand
|
|
73
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { consumerManifest } from "./hooks/consumer.js";
|
|
4
|
+
import { resolveHook } from "./hooks/loader.js";
|
|
5
|
+
async function validateDraftHooks(root, hooks) {
|
|
6
|
+
const registeredNames = new Set((await consumerManifest(root))?.hooks);
|
|
7
|
+
for (const call of [...hooks.setup ?? [], ...hooks.teardown ?? []]) {
|
|
8
|
+
if (registeredNames.has(call.hook)) continue;
|
|
9
|
+
try {
|
|
10
|
+
const { file, exportName } = await resolveHook(root, call.hook);
|
|
11
|
+
const source = ts.createSourceFile(
|
|
12
|
+
file,
|
|
13
|
+
await readFile(file, "utf8"),
|
|
14
|
+
ts.ScriptTarget.Latest,
|
|
15
|
+
true
|
|
16
|
+
);
|
|
17
|
+
const registered = source.statements.some((statement) => {
|
|
18
|
+
const exported = ts.canHaveModifiers(statement) && ts.getModifiers(statement)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword);
|
|
19
|
+
if (!exported) return false;
|
|
20
|
+
if (ts.isFunctionDeclaration(statement)) return statement.name?.text === exportName;
|
|
21
|
+
return ts.isVariableStatement(statement) && statement.declarationList.declarations.some(
|
|
22
|
+
(declaration) => ts.isIdentifier(declaration.name) && declaration.name.text === exportName
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
if (registered) continue;
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`Suite hook is not registered: ${call.hook}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
validateDraftHooks
|
|
33
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type DraftInput, type QaConfig, type StageClient } from "@open-qa/qa-engine";
|
|
2
|
+
import type { DraftScreenshot } from "./draft-api.js";
|
|
3
|
+
type Target = NonNullable<QaConfig["targets"]>[string];
|
|
4
|
+
/** Only links declared in qa.md are candidates; issue URLs cannot expand browser access. */
|
|
5
|
+
export declare function selectDraftPages(input: DraftInput, target: Target): string[];
|
|
6
|
+
type StageFactory = (target: Target, signal: AbortSignal) => Promise<{
|
|
7
|
+
stage: Pick<StageClient, "openView" | "closeView" | "captureEvidence">;
|
|
8
|
+
close(): Promise<void>;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function captureDraftPages(input: DraftInput, target: Target, signal: AbortSignal, create?: StageFactory): Promise<DraftScreenshot[]>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdir } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import {
|
|
6
|
+
targetAllowsUrl
|
|
7
|
+
} from "@open-qa/qa-engine";
|
|
8
|
+
import { LocalHostExecutor } from "./local-host-executor.js";
|
|
9
|
+
import { HttpStageClient } from "./http-stage-client.js";
|
|
10
|
+
function selectDraftPages(input, target) {
|
|
11
|
+
if (target.prodSafeOnly) return [];
|
|
12
|
+
const terms = new Set(
|
|
13
|
+
`${input.issue.title} ${input.issue.body}`.toLowerCase().split(/[^\p{L}\p{N}]+/u)
|
|
14
|
+
);
|
|
15
|
+
const pages = [];
|
|
16
|
+
for (const match of input.qaMarkdown.matchAll(
|
|
17
|
+
/\[([^\]\n]+)\]\((https?:\/\/[^\s)]+|\/[^\s)]*)\)/g
|
|
18
|
+
)) {
|
|
19
|
+
const words = match[1].toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((word) => word.length >= 2);
|
|
20
|
+
if (!words.some((word) => terms.has(word))) continue;
|
|
21
|
+
let url;
|
|
22
|
+
try {
|
|
23
|
+
url = new URL(match[2], target.url);
|
|
24
|
+
} catch {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (url.origin !== new URL(target.url).origin || url.username || url.password || url.search || url.hash || !targetAllowsUrl(target, url.href))
|
|
28
|
+
continue;
|
|
29
|
+
if (!pages.includes(url.href)) pages.push(url.href);
|
|
30
|
+
if (pages.length === 3) break;
|
|
31
|
+
}
|
|
32
|
+
return pages;
|
|
33
|
+
}
|
|
34
|
+
const localStage = async (target, signal) => {
|
|
35
|
+
const cache = join(homedir(), ".cache/open-qa/draft");
|
|
36
|
+
await mkdir(cache, { recursive: true, mode: 448 });
|
|
37
|
+
const executor = new LocalHostExecutor({
|
|
38
|
+
tempPrefix: join(cache, "draft-stage-"),
|
|
39
|
+
page: {
|
|
40
|
+
target: "dev",
|
|
41
|
+
allowedOrigins: [new URL(target.url).origin],
|
|
42
|
+
targetOrigin: new URL(target.url).origin,
|
|
43
|
+
permissions: { draft: ["page"] }
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const handle = await executor.provision(
|
|
47
|
+
{
|
|
48
|
+
runId: `draft-${randomUUID()}`,
|
|
49
|
+
placement: "local-host",
|
|
50
|
+
actors: ["draft"],
|
|
51
|
+
views: [{ surface: "web" }]
|
|
52
|
+
},
|
|
53
|
+
signal
|
|
54
|
+
);
|
|
55
|
+
return { stage: new HttpStageClient(handle), close: () => handle.asyncDispose() };
|
|
56
|
+
};
|
|
57
|
+
async function captureDraftPages(input, target, signal, create = localStage) {
|
|
58
|
+
const pages = selectDraftPages(input, target);
|
|
59
|
+
if (!pages.length) return [];
|
|
60
|
+
const { stage, close } = await create(target, signal);
|
|
61
|
+
try {
|
|
62
|
+
const screenshots = [];
|
|
63
|
+
for (const url of pages) {
|
|
64
|
+
signal.throwIfAborted();
|
|
65
|
+
await stage.openView({ actor: "draft", view: "page", type: "page", url }, signal);
|
|
66
|
+
const evidence = await stage.captureEvidence?.(
|
|
67
|
+
{ actor: "draft", step: "draft", screenshots: true, phase: "before" },
|
|
68
|
+
signal
|
|
69
|
+
);
|
|
70
|
+
const image = evidence?.screenshots?.find((item) => item.view === "page")?.image;
|
|
71
|
+
if (image) screenshots.push({ url, image: { data: image.data, mimeType: image.mimeType } });
|
|
72
|
+
await stage.closeView({ view: "page" }, signal);
|
|
73
|
+
}
|
|
74
|
+
return screenshots;
|
|
75
|
+
} finally {
|
|
76
|
+
await close();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
captureDraftPages,
|
|
81
|
+
selectDraftPages
|
|
82
|
+
};
|
package/src/engine.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { runFlow, type AgentPlacement, type ModelAccess, SecretRedactor, type Classifier, type Notifier, type ClassificationStore, type FlowStatusStore, type Reviewer, type ReviewerConfig, type Judge, type JudgeConfig, type AgentRuntime, type CredentialResolver, type Executor, type HookRunner, type LeasePool, type RunStore, type RunHistory, type ReplayCache, type StageClient, type StageHandle, type ExecutionPlan, type ConductorDeps, type QaConfig } from "@open-qa/qa-engine";
|
|
2
|
+
import { type LocalHostExecutorOptions } from "./local-host-executor.js";
|
|
3
|
+
import { type QaE2bClient } from "./adapters/e2b-client.js";
|
|
4
|
+
export declare class FlowStatusWriteError extends Error {
|
|
5
|
+
readonly result: Awaited<ReturnType<typeof runFlow>> & {
|
|
6
|
+
category: import("@open-qa/qa-engine/protocol").FailureCategory | null;
|
|
7
|
+
};
|
|
8
|
+
constructor(result: Awaited<ReturnType<typeof runFlow>> & {
|
|
9
|
+
category: import("@open-qa/qa-engine/protocol").FailureCategory | null;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export interface EngineAdapters {
|
|
13
|
+
flowStatus?: FlowStatusStore;
|
|
14
|
+
notifier?: Notifier;
|
|
15
|
+
classificationOwners?: {
|
|
16
|
+
flowOwner: string;
|
|
17
|
+
areaOwner: string;
|
|
18
|
+
};
|
|
19
|
+
classifier?: Classifier;
|
|
20
|
+
classifications?: ClassificationStore;
|
|
21
|
+
targetRevision?: () => Promise<string | null>;
|
|
22
|
+
onClassified?: (runId: string, classification: import("@open-qa/qa-engine/protocol").Classification, verdict: "failed" | "error") => Promise<void>;
|
|
23
|
+
e2bClient?: QaE2bClient;
|
|
24
|
+
onStage?: (runId: string, handle: StageHandle) => Promise<void>;
|
|
25
|
+
stageRuntime?: (handle: StageHandle, runtime: AgentRuntime) => AgentRuntime;
|
|
26
|
+
judge?: Judge;
|
|
27
|
+
reviewer?: Reviewer;
|
|
28
|
+
executor?: Executor;
|
|
29
|
+
runtime?: AgentRuntime;
|
|
30
|
+
healRuntime?: AgentRuntime;
|
|
31
|
+
credentials?: CredentialResolver;
|
|
32
|
+
runStore?: RunStore;
|
|
33
|
+
runHistory?: RunHistory;
|
|
34
|
+
replayCache?: ReplayCache;
|
|
35
|
+
leases?: LeasePool;
|
|
36
|
+
hooks?: HookRunner;
|
|
37
|
+
connectStage?: (handle: StageHandle) => StageClient;
|
|
38
|
+
}
|
|
39
|
+
export interface EngineOptions extends EngineAdapters {
|
|
40
|
+
billing?: "metered" | "subscription";
|
|
41
|
+
runId?: string;
|
|
42
|
+
flowRevision?: string;
|
|
43
|
+
onCleanup?: ConductorDeps["onCleanup"];
|
|
44
|
+
placement?: "local-host" | "e2b";
|
|
45
|
+
agentAt?: AgentPlacement;
|
|
46
|
+
origin?: "cli" | "server";
|
|
47
|
+
allowConsumerHooks?: boolean;
|
|
48
|
+
consumerPublicEnv?: readonly string[];
|
|
49
|
+
modelAccess?: "login" | "env";
|
|
50
|
+
modelCredentials?: ModelAccess;
|
|
51
|
+
healCredentials?: ModelAccess;
|
|
52
|
+
e2b?: {
|
|
53
|
+
projectId: string;
|
|
54
|
+
batchId: string;
|
|
55
|
+
budgetMs: number;
|
|
56
|
+
imageTag: string;
|
|
57
|
+
};
|
|
58
|
+
redactor?: SecretRedactor;
|
|
59
|
+
classifierConfig?: QaConfig["classifier"];
|
|
60
|
+
judgeConfig?: JudgeConfig;
|
|
61
|
+
reviewerConfig?: ReviewerConfig;
|
|
62
|
+
batchId?: string;
|
|
63
|
+
root: string;
|
|
64
|
+
target: {
|
|
65
|
+
url: string;
|
|
66
|
+
revision?: string;
|
|
67
|
+
};
|
|
68
|
+
brief: ConductorDeps["brief"];
|
|
69
|
+
stage?: LocalHostExecutorOptions;
|
|
70
|
+
env?: NodeJS.ProcessEnv;
|
|
71
|
+
subscriptionToken?: string;
|
|
72
|
+
runtimeId?: "claude-code" | "codex";
|
|
73
|
+
retries?: 0 | 1;
|
|
74
|
+
level?: ConductorDeps["level"];
|
|
75
|
+
replay?: "off";
|
|
76
|
+
heal?: QaConfig["heal"];
|
|
77
|
+
principalId?: string;
|
|
78
|
+
}
|
|
79
|
+
export declare const PUBLIC_ENV_KEYS: Set<string>;
|
|
80
|
+
export declare function privateEnvSecrets(env: NodeJS.ProcessEnv, publicEnv?: readonly string[]): string[];
|
|
81
|
+
export declare function createEngine(options: EngineOptions): {
|
|
82
|
+
observation: {
|
|
83
|
+
runtime: "claude-code" | "codex" | "scripted" | null;
|
|
84
|
+
modelAccess: "env" | "login" | null;
|
|
85
|
+
credentialSource: "subscription-token" | "local-login" | "model-env" | null;
|
|
86
|
+
placement: "local-host" | "e2b" | null;
|
|
87
|
+
capabilities: {
|
|
88
|
+
surfaces: ("telegram" | "discord" | "web")[];
|
|
89
|
+
recording: "rrweb"[];
|
|
90
|
+
levels: ("semantic" | "pixel" | "hybrid")[];
|
|
91
|
+
} | {
|
|
92
|
+
recording: "rrweb"[];
|
|
93
|
+
levels: ("semantic" | "pixel" | "hybrid")[];
|
|
94
|
+
surfaces: ("telegram" | "email" | "discord" | "web" | "testapp" | "desktop")[];
|
|
95
|
+
} | null;
|
|
96
|
+
};
|
|
97
|
+
run: (plan: ExecutionPlan, signal?: AbortSignal) => Promise<{
|
|
98
|
+
category: "env" | "agent" | "product-bug" | "test-case" | "flaky" | null;
|
|
99
|
+
quarantined: boolean;
|
|
100
|
+
lifecycle: "review" | "active" | "quarantined" | "draft" | "retired" | undefined;
|
|
101
|
+
runId: string;
|
|
102
|
+
verdict: import("@open-qa/qa-engine/protocol").Verdict;
|
|
103
|
+
runs: import("@open-qa/qa-engine").AttemptRecord[];
|
|
104
|
+
}>;
|
|
105
|
+
};
|