agent-dealer 1.3.5 → 1.4.1
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/bundle/server/dist/adapters/github.js +17 -2
- package/bundle/server/dist/adapters/github.test.js +43 -0
- package/bundle/server/dist/coordinator/visual-qa.js +1 -1
- package/bundle/server/dist/coordinator/visual-qa.test.js +3 -0
- package/bundle/server/package.json +2 -2
- package/bundle/shared/package.json +1 -1
- package/package.json +1 -1
|
@@ -346,7 +346,11 @@ export function parseWorkflowRunInfo(raw) {
|
|
|
346
346
|
return { databaseId: row.databaseId, headSha: row.headSha, conclusion, status };
|
|
347
347
|
}
|
|
348
348
|
const NO_COMMITS_PATTERN = /no commits between/i;
|
|
349
|
-
const defaultExec = (args, opts) => run("gh", args, {
|
|
349
|
+
const defaultExec = (args, opts) => run("gh", args, {
|
|
350
|
+
cwd: opts.cwd,
|
|
351
|
+
maxBuffer: opts.maxBuffer,
|
|
352
|
+
...(opts.env ? { env: { ...process.env, ...opts.env } } : {}),
|
|
353
|
+
});
|
|
350
354
|
async function ghPrView(exec, cwd, fields, selector) {
|
|
351
355
|
const args = ["pr", "view", ...(selector != null ? [selector] : []), "--json", fields];
|
|
352
356
|
try {
|
|
@@ -628,11 +632,22 @@ const REVIEW_FLAG = {
|
|
|
628
632
|
};
|
|
629
633
|
/** GitHub's self-review rejection, worded per event ("approve" / "request changes"). */
|
|
630
634
|
const OWN_PR_REVIEW_PATTERN = /own pull request/i;
|
|
635
|
+
/**
|
|
636
|
+
* Optional separate GitHub identity for review submission only. Repos that require an
|
|
637
|
+
* approval from someone other than the PR author reject the operator's own `--approve`;
|
|
638
|
+
* a second account's token lets the approval count. Set it in `~/.agent-dealer/.env`
|
|
639
|
+
* (loaded at startup, so a change needs a restart); unset keeps every `gh` call on the
|
|
640
|
+
* operator's ambient login.
|
|
641
|
+
*/
|
|
642
|
+
function reviewerExecOpts(cwd) {
|
|
643
|
+
const token = process.env.AGENT_DEALER_REVIEWER_GH_TOKEN;
|
|
644
|
+
return token ? { cwd, env: { GH_TOKEN: token } } : { cwd };
|
|
645
|
+
}
|
|
631
646
|
async function runReview(exec, cwd, number, event, bodyFilePath) {
|
|
632
647
|
try {
|
|
633
648
|
// The PR is targeted explicitly by number — the reviewer's worktree is a detached-HEAD
|
|
634
649
|
// checkout with no current branch for a bare `gh pr review` to resolve against.
|
|
635
|
-
await exec(["pr", "review", String(number), REVIEW_FLAG[event], "--body-file", bodyFilePath],
|
|
650
|
+
await exec(["pr", "review", String(number), REVIEW_FLAG[event], "--body-file", bodyFilePath], reviewerExecOpts(cwd));
|
|
636
651
|
return { ok: true };
|
|
637
652
|
}
|
|
638
653
|
catch (err) {
|
|
@@ -902,3 +902,46 @@ test("NOT-384: downloadRunArtifact downloads one named artifact into the dest di
|
|
|
902
902
|
destDir: "/store/ui-diff",
|
|
903
903
|
}), /gh run download failed/);
|
|
904
904
|
});
|
|
905
|
+
async function withReviewerToken(value, fn) {
|
|
906
|
+
const prev = process.env.AGENT_DEALER_REVIEWER_GH_TOKEN;
|
|
907
|
+
if (value === undefined)
|
|
908
|
+
delete process.env.AGENT_DEALER_REVIEWER_GH_TOKEN;
|
|
909
|
+
else
|
|
910
|
+
process.env.AGENT_DEALER_REVIEWER_GH_TOKEN = value;
|
|
911
|
+
try {
|
|
912
|
+
return await fn();
|
|
913
|
+
}
|
|
914
|
+
finally {
|
|
915
|
+
if (prev === undefined)
|
|
916
|
+
delete process.env.AGENT_DEALER_REVIEWER_GH_TOKEN;
|
|
917
|
+
else
|
|
918
|
+
process.env.AGENT_DEALER_REVIEWER_GH_TOKEN = prev;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
test("AGENT_DEALER_REVIEWER_GH_TOKEN: publishReview runs `gh pr review` as that identity via GH_TOKEN", async () => {
|
|
922
|
+
const { exec, calls, execOpts } = queuedExec([{ stdout: "" }]);
|
|
923
|
+
const result = await withReviewerToken("tok-123", () => createGithubAdapter(exec).publishReview({ cwd: "/repo", number: 7, event: "APPROVE", bodyFilePath: "/tmp/body.md" }));
|
|
924
|
+
assert.deepEqual(result, { ok: true, event: "APPROVE", usedCommentFallback: false });
|
|
925
|
+
assert.deepEqual(calls, [["pr", "review", "7", "--approve", "--body-file", "/tmp/body.md"]]);
|
|
926
|
+
assert.deepEqual(execOpts, [{ cwd: "/repo", env: { GH_TOKEN: "tok-123" } }]);
|
|
927
|
+
});
|
|
928
|
+
test("AGENT_DEALER_REVIEWER_GH_TOKEN: unset or empty keeps the ambient login and the own-PR comment fallback", async () => {
|
|
929
|
+
for (const value of [undefined, ""]) {
|
|
930
|
+
const { exec, calls, execOpts } = queuedExec([
|
|
931
|
+
{ error: "failed to create review: Can not approve your own pull request" },
|
|
932
|
+
{ stdout: "" },
|
|
933
|
+
]);
|
|
934
|
+
const result = await withReviewerToken(value, () => createGithubAdapter(exec).publishReview({ cwd: "/repo", number: 7, event: "APPROVE", bodyFilePath: "/tmp/body.md" }));
|
|
935
|
+
assert.deepEqual(result, { ok: true, event: "COMMENT", usedCommentFallback: true });
|
|
936
|
+
assert.deepEqual(calls.map((c) => c[3]), ["--approve", "--comment"]);
|
|
937
|
+
assert.deepEqual(execOpts, [{ cwd: "/repo" }, { cwd: "/repo" }]);
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
test("AGENT_DEALER_REVIEWER_GH_TOKEN: non-review gh calls never receive the reviewer token", async () => {
|
|
941
|
+
const { exec, execOpts } = queuedExec([
|
|
942
|
+
{ stdout: JSON.stringify({ number: 5, url: "u", baseRefName: "main", headRefName: "issue-x", headRefOid: "abc", isDraft: true }) },
|
|
943
|
+
]);
|
|
944
|
+
await withReviewerToken("tok-123", () => createGithubAdapter(exec).viewPr({ cwd: "/repo", branch: "issue-x" }));
|
|
945
|
+
assert.equal(execOpts.length, 1);
|
|
946
|
+
assert.equal(execOpts[0].env, undefined);
|
|
947
|
+
});
|
|
@@ -68,7 +68,7 @@ export function capableDeveloperVisualQaPromptSection() {
|
|
|
68
68
|
return [
|
|
69
69
|
`## Visual QA (in-session browser verification)`,
|
|
70
70
|
`This runtime can usually launch a headless browser and serve the app on loopback — verify UI-visible work in-session instead of assuming visual QA is unavailable.`,
|
|
71
|
-
`- First run ONE bounded capability probe: launch headless Chromium once (for example \`chromium --headless --screenshot=/tmp/dealer-visual-probe.png --window-size=800,600 about:blank\`, or the runtime's installed equivalent) and confirm the app can listen on loopback. If either fails, stop: do not install browsers or packages (no network), do not retry the failed capability, and do not weaken any sandbox flag to force a launch
|
|
71
|
+
`- First run ONE bounded capability probe: launch headless Chromium once (for example \`chromium --headless --screenshot=/tmp/dealer-visual-probe.png --window-size=800,600 about:blank\`, or the runtime's installed equivalent) and confirm the app can listen on loopback. If either fails, stop PROBING only — the probe is never a gate on the ticket: do not install browsers or packages (no network), do not retry the failed capability, and do not weaken any sandbox flag to force a launch. Record \`unavailable\` with the concrete failed capability, then continue the implementation as normal: inspect the repository, change code, run tests and open the PR. A failed probe is never a reason to end the session without implementing; browser proof is routed to CI or an operator.`,
|
|
72
72
|
`- When capable, run the REAL backend and frontend from this worktree at the current HEAD and exercise the affected interaction, not just a static route. Use mocks only when an acceptance criterion explicitly permits them, and say so in the receipt.`,
|
|
73
73
|
`- Capture the ticket's stated viewports, or desktop \`1440x900\` and mobile \`390x800\` by default. Save PNGs under \`.agent-dealer-visual-qa/\` (for example \`.agent-dealer-visual-qa/desktop-1440x900.png\`). The coordinator collects and deletes this directory — never commit it.`,
|
|
74
74
|
`- A new commit invalidates earlier rendered evidence: capture at the final HEAD and name it in the receipt (\`git rev-parse HEAD\`).`,
|
|
@@ -61,6 +61,9 @@ test("NOT-381: capable section requires one bounded probe, the real app, default
|
|
|
61
61
|
assert.match(text, /do not install browsers or packages/);
|
|
62
62
|
assert.match(text, /do not retry the failed capability/);
|
|
63
63
|
assert.match(text, /do not weaken any sandbox flag/);
|
|
64
|
+
// A failed probe must never end the session: the worker keeps implementing.
|
|
65
|
+
assert.match(text, /never a gate on the ticket/);
|
|
66
|
+
assert.match(text, /continue the implementation as normal/);
|
|
64
67
|
assert.match(text, /REAL backend and frontend/);
|
|
65
68
|
assert.match(text, /Use mocks only when an acceptance criterion explicitly permits them/);
|
|
66
69
|
assert.match(text, /1440x900/);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-dealer/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test": "AGENT_DEALER_SKIP_GITHUB_HEALTH=1 AGENT_DEALER_SKIP_AGENT_HEALTH=1 npm run build -w @agent-dealer/shared && AGENT_DEALER_SKIP_GITHUB_HEALTH=1 AGENT_DEALER_SKIP_AGENT_HEALTH=1 node ../../scripts/run-workspace-tests.mjs"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@agent-dealer/shared": "1.
|
|
26
|
+
"@agent-dealer/shared": "1.4.1",
|
|
27
27
|
"@fastify/cors": "^11.0.1",
|
|
28
28
|
"@fastify/static": "^8.2.0",
|
|
29
29
|
"@modelcontextprotocol/sdk": "^1.29.0",
|