agent-dealer 0.2.0 → 1.0.0
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/agent-deck-bind.js +443 -0
- package/bundle/server/dist/adapters/agent-deck-bind.test.js +454 -0
- package/bundle/server/dist/adapters/agent-deck.js +38 -50
- package/bundle/server/dist/adapters/agent-deck.test.js +63 -0
- package/bundle/server/dist/adapters/agent-health.js +230 -33
- package/bundle/server/dist/adapters/agent-health.test.js +237 -0
- package/bundle/server/dist/adapters/authority-lifecycle.js +289 -0
- package/bundle/server/dist/adapters/codex-scoped-config.js +103 -0
- package/bundle/server/dist/adapters/execution-authority.js +103 -0
- package/bundle/server/dist/adapters/execution-authority.test.js +166 -0
- package/bundle/server/dist/adapters/external.js +0 -1
- package/bundle/server/dist/adapters/git-worktree.js +514 -0
- package/bundle/server/dist/adapters/git-worktree.test.js +502 -0
- package/bundle/server/dist/adapters/github.js +170 -0
- package/bundle/server/dist/adapters/github.test.js +205 -0
- package/bundle/server/dist/adapters/linear-inbox.js +199 -30
- package/bundle/server/dist/adapters/linear-inbox.test.js +35 -0
- package/bundle/server/dist/adapters/linear-sync.js +3 -101
- package/bundle/server/dist/adapters/managed-repo.js +168 -0
- package/bundle/server/dist/adapters/managed-repo.test.js +63 -0
- package/bundle/server/dist/adapters/outbound-delivery.js +83 -0
- package/bundle/server/dist/adapters/outbound-delivery.test.js +53 -0
- package/bundle/server/dist/adapters/reflect-authority.js +43 -0
- package/bundle/server/dist/cli-env.js +26 -0
- package/bundle/server/dist/cli-env.test.js +14 -1
- package/bundle/server/dist/coordinator/abort.integration.test.js +74 -0
- package/bundle/server/dist/coordinator/admission.js +330 -0
- package/bundle/server/dist/coordinator/admission.test.js +338 -0
- package/bundle/server/dist/coordinator/args.js +128 -0
- package/bundle/server/dist/coordinator/args.test.js +132 -0
- package/bundle/server/dist/coordinator/authority-recovery.integration.test.js +661 -0
- package/bundle/server/dist/coordinator/auto-merge.integration.test.js +363 -0
- package/bundle/server/dist/coordinator/auto-merge.js +286 -0
- package/bundle/server/dist/coordinator/auto-merge.timeout.test.js +14 -0
- package/bundle/server/dist/coordinator/branch-progress.js +81 -0
- package/bundle/server/dist/coordinator/clock-jump.js +98 -0
- package/bundle/server/dist/coordinator/commands.js +1088 -0
- package/bundle/server/dist/coordinator/commands.test.js +554 -0
- package/bundle/server/dist/coordinator/deck-outage-config.js +32 -0
- package/bundle/server/dist/coordinator/deck-outage.integration.test.js +200 -0
- package/bundle/server/dist/coordinator/dependencies.js +242 -0
- package/bundle/server/dist/coordinator/dependency-readiness.integration.test.js +535 -0
- package/bundle/server/dist/coordinator/developer-effect.js +959 -0
- package/bundle/server/dist/coordinator/developer-effect.test.js +1143 -0
- package/bundle/server/dist/coordinator/dispatcher.js +58 -0
- package/bundle/server/dist/coordinator/dispatcher.test.js +81 -0
- package/bundle/server/dist/coordinator/effect-registry.js +17 -0
- package/bundle/server/dist/coordinator/execution-env.integration.test.js +122 -0
- package/bundle/server/dist/coordinator/failure-reason.js +273 -0
- package/bundle/server/dist/coordinator/failure-reason.test.js +234 -0
- package/bundle/server/dist/coordinator/guidance.js +33 -0
- package/bundle/server/dist/coordinator/guidance.test.js +110 -0
- package/bundle/server/dist/coordinator/human-resolution.js +88 -0
- package/bundle/server/dist/coordinator/human-resolution.test.js +72 -0
- package/bundle/server/dist/coordinator/intent-forecast.js +13 -0
- package/bundle/server/dist/coordinator/intent-forecast.test.js +34 -0
- package/bundle/server/dist/coordinator/latest-failure.js +100 -0
- package/bundle/server/dist/coordinator/latest-failure.test.js +125 -0
- package/bundle/server/dist/coordinator/metrics.js +35 -0
- package/bundle/server/dist/coordinator/metrics.test.js +52 -0
- package/bundle/server/dist/coordinator/permissions.js +127 -0
- package/bundle/server/dist/coordinator/permissions.test.js +184 -0
- package/bundle/server/dist/coordinator/presumed-dead-budget.integration.test.js +146 -0
- package/bundle/server/dist/coordinator/process-liveness.js +191 -0
- package/bundle/server/dist/coordinator/profile-snapshot.js +20 -0
- package/bundle/server/dist/coordinator/profile-snapshot.test.js +118 -0
- package/bundle/server/dist/coordinator/projection.js +147 -0
- package/bundle/server/dist/coordinator/projection.test.js +121 -0
- package/bundle/server/dist/coordinator/prompts.js +164 -0
- package/bundle/server/dist/coordinator/prompts.test.js +177 -0
- package/bundle/server/dist/coordinator/queue-by-default.integration.test.js +271 -0
- package/bundle/server/dist/coordinator/reclaim-republish.integration.test.js +372 -0
- package/bundle/server/dist/coordinator/recovery.js +466 -0
- package/bundle/server/dist/coordinator/recovery.test.js +164 -0
- package/bundle/server/dist/coordinator/reflect-trigger.js +218 -0
- package/bundle/server/dist/coordinator/reflect-trigger.test.js +324 -0
- package/bundle/server/dist/coordinator/repair-cycle.integration.test.js +234 -0
- package/bundle/server/dist/coordinator/restart-recovery.integration.test.js +363 -0
- package/bundle/server/dist/coordinator/reviewer-effect.js +507 -0
- package/bundle/server/dist/coordinator/reviewer-effect.test.js +612 -0
- package/bundle/server/dist/coordinator/reviewer-result.js +38 -0
- package/bundle/server/dist/coordinator/reviewer-result.test.js +45 -0
- package/bundle/server/dist/coordinator/routing.js +160 -0
- package/bundle/server/dist/coordinator/routing.test.js +336 -0
- package/bundle/server/dist/coordinator/session-lifecycle.integration.test.js +127 -0
- package/bundle/server/dist/coordinator/session-lifecycle.js +280 -0
- package/bundle/server/dist/coordinator/session-lifecycle.test.js +121 -0
- package/bundle/server/dist/coordinator/session-progress.js +351 -0
- package/bundle/server/dist/coordinator/session-progress.test.js +190 -0
- package/bundle/server/dist/coordinator/session-timeouts.js +33 -0
- package/bundle/server/dist/coordinator/sleep-recovery.integration.test.js +233 -0
- package/bundle/server/dist/coordinator/spawn.js +49 -0
- package/bundle/server/dist/coordinator/sync-issue-base-branch.js +18 -0
- package/bundle/server/dist/coordinator/usage-cap-config.js +10 -0
- package/bundle/server/dist/coordinator/usage-cap-defer.js +189 -0
- package/bundle/server/dist/coordinator/usage-cap.integration.test.js +193 -0
- package/bundle/server/dist/coordinator/usage.js +40 -0
- package/bundle/server/dist/coordinator/usage.test.js +69 -0
- package/bundle/server/dist/coordinator/verification-receipt.js +333 -0
- package/bundle/server/dist/coordinator/verification-receipt.test.js +382 -0
- package/bundle/server/dist/coordinator/worker-loop.js +363 -0
- package/bundle/server/dist/coordinator/worker-loop.test.js +327 -0
- package/bundle/server/dist/coordinator/workflow-instances.test.js +45 -0
- package/bundle/server/dist/coordinator/worktree-owner-liveness.js +82 -0
- package/bundle/server/dist/coordinator/worktree-owner-liveness.test.js +199 -0
- package/bundle/server/dist/db/artifacts-issue-columns.test.js +18 -0
- package/bundle/server/dist/db/authority-attempts-stale-at-migration.test.js +65 -0
- package/bundle/server/dist/db/idempotency-index-migration.test.js +57 -0
- package/bundle/server/dist/db/index.js +359 -7
- package/bundle/server/dist/db/linear-inbox-unlock.test.js +67 -0
- package/bundle/server/dist/db/migrate-to-issues.js +824 -0
- package/bundle/server/dist/db/migrate-to-issues.test.js +842 -0
- package/bundle/server/dist/db/schema.sql +311 -1
- package/bundle/server/dist/db/schema.test.js +66 -0
- package/bundle/server/dist/db/worker-session-pid-migration.test.js +112 -0
- package/bundle/server/dist/dev-review-cli-happy-path.integration.test.js +338 -0
- package/bundle/server/dist/direct-start-liveness.integration.test.js +350 -0
- package/bundle/server/dist/index.js +58 -5
- package/bundle/server/dist/paths.js +40 -4
- package/bundle/server/dist/paths.test.js +42 -0
- package/bundle/server/dist/pid-marker-claim-child.js +18 -0
- package/bundle/server/dist/pid-marker-hold-arbiter-child.js +24 -0
- package/bundle/server/dist/pid-marker.js +141 -0
- package/bundle/server/dist/pid-marker.test.js +208 -0
- package/bundle/server/dist/queue/approve-deliver.js +128 -28
- package/bundle/server/dist/queue/reflect-schedule.js +25 -0
- package/bundle/server/dist/queue/result-qa.js +1 -1
- package/bundle/server/dist/queue/send-gate.test.js +172 -36
- package/bundle/server/dist/repository/agents.js +55 -18
- package/bundle/server/dist/repository/artifacts-for-issue.js +42 -0
- package/bundle/server/dist/repository/artifacts-for-issue.test.js +48 -0
- package/bundle/server/dist/repository/artifacts.js +47 -0
- package/bundle/server/dist/repository/artifacts.test.js +48 -0
- package/bundle/server/dist/repository/authority-attempts.js +189 -0
- package/bundle/server/dist/repository/findings.js +70 -0
- package/bundle/server/dist/repository/findings.test.js +68 -0
- package/bundle/server/dist/repository/human-actions.js +142 -0
- package/bundle/server/dist/repository/human-actions.test.js +123 -0
- package/bundle/server/dist/repository/intake-settings.js +5 -59
- package/bundle/server/dist/repository/issues.js +305 -0
- package/bundle/server/dist/repository/issues.test.js +69 -0
- package/bundle/server/dist/repository/outbound-drafts.js +28 -0
- package/bundle/server/dist/repository/queue-entries.js +162 -0
- package/bundle/server/dist/repository/review-publications.js +153 -0
- package/bundle/server/dist/repository/review-publications.test.js +78 -0
- package/bundle/server/dist/repository/runs-external-id.test.js +5 -3
- package/bundle/server/dist/repository/runs.js +4 -211
- package/bundle/server/dist/repository/runtime-availability.js +54 -0
- package/bundle/server/dist/repository/usage-events.js +60 -0
- package/bundle/server/dist/repository/usage-events.test.js +56 -0
- package/bundle/server/dist/repository/work-items.js +305 -0
- package/bundle/server/dist/repository/work-items.test.js +142 -0
- package/bundle/server/dist/repository/worker-sessions.js +219 -0
- package/bundle/server/dist/repository/worker-sessions.test.js +60 -0
- package/bundle/server/dist/repository/workflow-events.js +193 -0
- package/bundle/server/dist/repository/workflow-events.test.js +89 -0
- package/bundle/server/dist/resolve-tsx-bin.js +19 -0
- package/bundle/server/dist/routes/human-actions.js +68 -0
- package/bundle/server/dist/routes/human-actions.test.js +284 -0
- package/bundle/server/dist/routes/index.js +29 -496
- package/bundle/server/dist/routes/issues.js +240 -0
- package/bundle/server/dist/routes/issues.test.js +451 -0
- package/bundle/server/dist/routes/queue.js +41 -0
- package/bundle/server/dist/routes/queue.test.js +78 -0
- package/bundle/server/dist/runners/claude-args.js +18 -30
- package/bundle/server/dist/runners/claude.js +19 -163
- package/bundle/server/dist/runners/claude.test.js +15 -70
- package/bundle/server/dist/runners/codex-args.js +59 -0
- package/bundle/server/dist/runners/codex-args.test.js +72 -0
- package/bundle/server/dist/runners/codex-jsonl.js +150 -0
- package/bundle/server/dist/runners/codex-jsonl.test.js +36 -0
- package/bundle/server/dist/runners/codex-resume.test.js +19 -0
- package/bundle/server/dist/runners/codex.js +46 -0
- package/bundle/server/dist/runners/models-codex.test.js +14 -0
- package/bundle/server/dist/runners/models.js +53 -1
- package/bundle/server/dist/runners/persist.js +4 -1
- package/bundle/server/dist/runners/process-registry.js +11 -0
- package/bundle/server/dist/runners/prompts.js +13 -280
- package/bundle/server/dist/runners/prompts.test.js +22 -153
- package/bundle/server/dist/runners/qa.js +17 -1
- package/bundle/server/dist/runners/reflect.js +4 -16
- package/bundle/server/dist/runners/spawn-cli.js +197 -0
- package/bundle/server/dist/runners/spawn-cli.test.js +130 -0
- package/bundle/server/dist/runners/stream-json.js +0 -141
- package/bundle/server/dist/runners/usage-cap.js +242 -0
- package/bundle/server/dist/runners/usage-cap.test.js +97 -0
- package/bundle/server/dist/server-liveness.js +37 -0
- package/bundle/server/dist/server-liveness.test.js +82 -0
- package/bundle/server/dist/static-ui.test.js +44 -0
- package/bundle/server/package.json +4 -2
- package/bundle/server/static-ui/assets/index-BTtPGYpY.js +60 -0
- package/bundle/server/static-ui/assets/index-BxTx4b1d.css +1 -0
- package/bundle/server/static-ui/index.html +2 -2
- package/bundle/shared/dist/agents.d.ts +262 -133
- package/bundle/shared/dist/agents.js +85 -19
- package/bundle/shared/dist/cursor-auth-health.d.ts +12 -0
- package/bundle/shared/dist/cursor-auth-health.js +36 -0
- package/bundle/shared/dist/cursor-auth-health.test.d.ts +1 -0
- package/bundle/shared/dist/cursor-auth-health.test.js +40 -0
- package/bundle/shared/dist/findings.d.ts +46 -0
- package/bundle/shared/dist/findings.js +17 -0
- package/bundle/shared/dist/findings.test.d.ts +1 -0
- package/bundle/shared/dist/findings.test.js +20 -0
- package/bundle/shared/dist/github-repo.d.ts +28 -0
- package/bundle/shared/dist/github-repo.js +98 -0
- package/bundle/shared/dist/github-repo.test.d.ts +1 -0
- package/bundle/shared/dist/github-repo.test.js +32 -0
- package/bundle/shared/dist/human-actions.d.ts +66 -0
- package/bundle/shared/dist/human-actions.js +51 -0
- package/bundle/shared/dist/human-actions.test.d.ts +1 -0
- package/bundle/shared/dist/human-actions.test.js +57 -0
- package/bundle/shared/dist/index.d.ts +567 -757
- package/bundle/shared/dist/index.js +22 -36
- package/bundle/shared/dist/issues.d.ts +385 -0
- package/bundle/shared/dist/issues.js +169 -0
- package/bundle/shared/dist/issues.test.d.ts +1 -0
- package/bundle/shared/dist/issues.test.js +72 -0
- package/bundle/shared/dist/outbound-draft.d.ts +6 -0
- package/bundle/shared/dist/outbound-draft.js +4 -0
- package/bundle/shared/dist/plan-triage.d.ts +6 -6
- package/bundle/shared/dist/profile-snapshot.d.ts +154 -0
- package/bundle/shared/dist/profile-snapshot.js +145 -0
- package/bundle/shared/dist/profile-snapshot.test.d.ts +1 -0
- package/bundle/shared/dist/profile-snapshot.test.js +67 -0
- package/bundle/shared/dist/queue-entries.d.ts +89 -0
- package/bundle/shared/dist/queue-entries.js +19 -0
- package/bundle/shared/dist/result-qa.d.ts +2 -2
- package/bundle/shared/dist/runtime-auth-health.d.ts +66 -0
- package/bundle/shared/dist/runtime-auth-health.js +186 -0
- package/bundle/shared/dist/runtime-auth-health.test.d.ts +1 -0
- package/bundle/shared/dist/runtime-auth-health.test.js +200 -0
- package/bundle/shared/dist/runtime-availability.d.ts +51 -0
- package/bundle/shared/dist/runtime-availability.js +13 -0
- package/bundle/shared/dist/runtime.d.ts +1 -1
- package/bundle/shared/dist/runtime.js +1 -1
- package/bundle/shared/dist/usage-events.d.ts +36 -0
- package/bundle/shared/dist/usage-events.js +13 -0
- package/bundle/shared/dist/worker-sessions.d.ts +140 -0
- package/bundle/shared/dist/worker-sessions.js +70 -0
- package/bundle/shared/dist/worker-sessions.test.d.ts +1 -0
- package/bundle/shared/dist/worker-sessions.test.js +39 -0
- package/bundle/shared/dist/workflow.d.ts +78 -0
- package/bundle/shared/dist/workflow.js +59 -0
- package/bundle/shared/dist/workflow.test.d.ts +1 -0
- package/bundle/shared/dist/workflow.test.js +61 -0
- package/bundle/shared/package.json +1 -1
- package/dist/action.d.ts +1 -0
- package/dist/action.js +50 -0
- package/dist/action.test.d.ts +1 -0
- package/dist/action.test.js +70 -0
- package/dist/agent.d.ts +1 -0
- package/dist/agent.js +17 -0
- package/dist/agent.test.d.ts +1 -0
- package/dist/agent.test.js +19 -0
- package/dist/cli-check.d.ts +7 -0
- package/dist/cli-check.js +40 -0
- package/dist/doctor.js +59 -1
- package/dist/http.d.ts +5 -0
- package/dist/http.js +19 -0
- package/dist/index.js +28 -0
- package/dist/issue.d.ts +35 -0
- package/dist/issue.js +143 -0
- package/dist/issue.test.d.ts +1 -0
- package/dist/issue.test.js +240 -0
- package/dist/lifecycle.contract.test.d.ts +1 -0
- package/dist/lifecycle.contract.test.js +135 -0
- package/dist/queue.d.ts +11 -0
- package/dist/queue.js +60 -0
- package/dist/queue.test.d.ts +1 -0
- package/dist/queue.test.js +46 -0
- package/dist/test-fetch-stub.d.ts +6 -0
- package/dist/test-fetch-stub.js +31 -0
- package/package.json +2 -1
- package/templates/prod.env.example +1 -1
- package/bundle/server/static-ui/assets/index-B_7S7xJb.js +0 -79
- package/bundle/server/static-ui/assets/index-QYv3zmE6.css +0 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { runActionCommand } from "./action.js";
|
|
4
|
+
import { runAgentCommand } from "./agent.js";
|
|
5
|
+
import { runIssueCommand } from "./issue.js";
|
|
6
|
+
function openAction(id, actionType, choices) {
|
|
7
|
+
return {
|
|
8
|
+
id,
|
|
9
|
+
issueId: "00000000-0000-4000-a000-000000000010",
|
|
10
|
+
runId: null,
|
|
11
|
+
workflowInstanceId: null,
|
|
12
|
+
actionType,
|
|
13
|
+
reason: "Operator decision required",
|
|
14
|
+
question: "Choose the next action",
|
|
15
|
+
evidenceJson: null,
|
|
16
|
+
responseOptionsJson: JSON.stringify(choices),
|
|
17
|
+
continuationPreviewJson: null,
|
|
18
|
+
requestId: null,
|
|
19
|
+
status: "open",
|
|
20
|
+
resolutionJson: null,
|
|
21
|
+
resolvedBy: null,
|
|
22
|
+
requestedAt: "2026-09-12T00:00:00.000Z",
|
|
23
|
+
resolvedAt: null,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
test("agent-operated CLI contract: discover profiles/issues, start, inspect choices, and resolve every action type", async () => {
|
|
27
|
+
const issueId = "00000000-0000-4000-a000-000000000010";
|
|
28
|
+
const actions = [
|
|
29
|
+
openAction("00000000-0000-4000-a000-000000000021", "product_scope_decision", [
|
|
30
|
+
{ choice: "resume", label: "Acceptance criteria added — start" },
|
|
31
|
+
]),
|
|
32
|
+
openAction("00000000-0000-4000-a000-000000000022", "policy_escalation", [
|
|
33
|
+
{ choice: "resume", label: "Retry" },
|
|
34
|
+
{ choice: "close", label: "Close" },
|
|
35
|
+
]),
|
|
36
|
+
openAction("00000000-0000-4000-a000-000000000023", "attempts_exhausted", [
|
|
37
|
+
{ choice: "retry", label: "Grant another round" },
|
|
38
|
+
{ choice: "close", label: "Close" },
|
|
39
|
+
]),
|
|
40
|
+
openAction("00000000-0000-4000-a000-000000000024", "final_review", [
|
|
41
|
+
{ choice: "complete", label: "Accept — merge & mark done" },
|
|
42
|
+
{ choice: "repair", label: "Request repair" },
|
|
43
|
+
{ choice: "close", label: "Close" },
|
|
44
|
+
]),
|
|
45
|
+
];
|
|
46
|
+
const resolutions = ["resume", "resume", "retry", "complete"];
|
|
47
|
+
const expected = [
|
|
48
|
+
{
|
|
49
|
+
path: "/api/agents",
|
|
50
|
+
method: "GET",
|
|
51
|
+
response: {
|
|
52
|
+
agents: [
|
|
53
|
+
{
|
|
54
|
+
id: "00000000-0000-4000-a000-000000000001",
|
|
55
|
+
runtime: "claude_code",
|
|
56
|
+
defaultModel: "sonnet",
|
|
57
|
+
workspaceRoot: "/repo",
|
|
58
|
+
deckId: "00000000-0000-4000-a000-000000000100",
|
|
59
|
+
deckName: "dev",
|
|
60
|
+
healthy: true,
|
|
61
|
+
issues: [],
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
issueCount: 0,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
path: "/api/issues?status=ready%2Cneeds_human",
|
|
69
|
+
method: "GET",
|
|
70
|
+
response: [
|
|
71
|
+
{
|
|
72
|
+
id: issueId,
|
|
73
|
+
status: "ready",
|
|
74
|
+
currentOwner: "system",
|
|
75
|
+
currentIntent: null,
|
|
76
|
+
hasOpenHumanAction: false,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
// NOT-118: start answers with the admission outcome — admitted (with the instance and
|
|
82
|
+
// round-1 work item) or queued at a position with a wait reason.
|
|
83
|
+
path: `/api/issues/${issueId}/start`,
|
|
84
|
+
method: "POST",
|
|
85
|
+
response: { state: "admitted", instance: { id: "wf-1" }, workItem: { id: "work-1", kind: "developer" } },
|
|
86
|
+
},
|
|
87
|
+
{ path: "/api/human-actions", method: "GET", response: actions },
|
|
88
|
+
...actions.map((action, index) => ({
|
|
89
|
+
path: `/api/human-actions/${action.id}/resolve`,
|
|
90
|
+
method: "POST",
|
|
91
|
+
body: { choice: resolutions[index], resolvedBy: "cli-agent" },
|
|
92
|
+
response: { issueStatus: index === actions.length - 1 ? "done" : "developing" },
|
|
93
|
+
})),
|
|
94
|
+
];
|
|
95
|
+
const originalFetch = globalThis.fetch;
|
|
96
|
+
const originalLog = console.log;
|
|
97
|
+
const logs = [];
|
|
98
|
+
let callIndex = 0;
|
|
99
|
+
globalThis.fetch = (async (input, init) => {
|
|
100
|
+
const call = expected[callIndex++];
|
|
101
|
+
assert.ok(call, `unexpected request: ${String(input)}`);
|
|
102
|
+
assert.ok(String(input).endsWith(call.path), `expected ${call.path}, got ${String(input)}`);
|
|
103
|
+
assert.equal(init?.method ?? "GET", call.method);
|
|
104
|
+
const body = init?.body ? JSON.parse(String(init.body)) : undefined;
|
|
105
|
+
assert.deepEqual(body, call.body);
|
|
106
|
+
return new Response(JSON.stringify(call.response), {
|
|
107
|
+
status: 200,
|
|
108
|
+
headers: { "content-type": "application/json" },
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
console.log = (message) => logs.push(String(message));
|
|
112
|
+
try {
|
|
113
|
+
assert.equal(await runAgentCommand(["list"]), 0);
|
|
114
|
+
assert.equal(await runIssueCommand(["list", "--status", "ready,needs_human"]), 0);
|
|
115
|
+
assert.equal(await runIssueCommand(["start", issueId]), 0);
|
|
116
|
+
assert.equal(await runActionCommand(["list"]), 0);
|
|
117
|
+
for (let index = 0; index < actions.length; index += 1) {
|
|
118
|
+
assert.equal(await runActionCommand([
|
|
119
|
+
"resolve",
|
|
120
|
+
actions[index].id,
|
|
121
|
+
"--choice",
|
|
122
|
+
resolutions[index],
|
|
123
|
+
"--by",
|
|
124
|
+
"cli-agent",
|
|
125
|
+
]), 0);
|
|
126
|
+
}
|
|
127
|
+
assert.equal(callIndex, expected.length);
|
|
128
|
+
const listedActions = JSON.parse(logs[3]);
|
|
129
|
+
assert.deepEqual(listedActions.map((action) => action.choices), actions.map((action) => JSON.parse(action.responseOptionsJson)));
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
globalThis.fetch = originalFetch;
|
|
133
|
+
console.log = originalLog;
|
|
134
|
+
}
|
|
135
|
+
});
|
package/dist/queue.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ParsedQueueArgs = {
|
|
2
|
+
subcommand: "add";
|
|
3
|
+
issueId: string;
|
|
4
|
+
} | {
|
|
5
|
+
subcommand: "remove";
|
|
6
|
+
issueId: string;
|
|
7
|
+
} | {
|
|
8
|
+
subcommand: "list";
|
|
9
|
+
};
|
|
10
|
+
export declare function parseQueueArgs(args: string[]): ParsedQueueArgs;
|
|
11
|
+
export declare function runQueueCommand(args: string[]): Promise<number>;
|
package/dist/queue.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { apiFetch } from "./http.js";
|
|
2
|
+
export function parseQueueArgs(args) {
|
|
3
|
+
const [subcommand, ...rest] = args;
|
|
4
|
+
switch (subcommand) {
|
|
5
|
+
case "add": {
|
|
6
|
+
const issueId = rest[0];
|
|
7
|
+
if (!issueId)
|
|
8
|
+
throw new Error("queue add requires an issue id");
|
|
9
|
+
return { subcommand: "add", issueId };
|
|
10
|
+
}
|
|
11
|
+
case "remove": {
|
|
12
|
+
const issueId = rest[0];
|
|
13
|
+
if (!issueId)
|
|
14
|
+
throw new Error("queue remove requires an issue id");
|
|
15
|
+
return { subcommand: "remove", issueId };
|
|
16
|
+
}
|
|
17
|
+
case "list":
|
|
18
|
+
return { subcommand: "list" };
|
|
19
|
+
default:
|
|
20
|
+
throw new Error(`Unknown queue subcommand: ${subcommand ?? "(none)"}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export async function runQueueCommand(args) {
|
|
24
|
+
let parsed;
|
|
25
|
+
try {
|
|
26
|
+
parsed = parseQueueArgs(args);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
console.error(err.message);
|
|
30
|
+
return 1;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
switch (parsed.subcommand) {
|
|
34
|
+
case "add": {
|
|
35
|
+
const result = await apiFetch("/api/queue", {
|
|
36
|
+
method: "POST",
|
|
37
|
+
body: { issueId: parsed.issueId },
|
|
38
|
+
});
|
|
39
|
+
console.log(JSON.stringify(result, null, 2));
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
case "remove": {
|
|
43
|
+
const result = await apiFetch(`/api/queue/${encodeURIComponent(parsed.issueId)}`, {
|
|
44
|
+
method: "DELETE",
|
|
45
|
+
});
|
|
46
|
+
console.log(JSON.stringify(result, null, 2));
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
case "list": {
|
|
50
|
+
const result = await apiFetch("/api/queue");
|
|
51
|
+
console.log(JSON.stringify(result, null, 2));
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
console.error(err.message);
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { parseQueueArgs, runQueueCommand } from "./queue.js";
|
|
4
|
+
import { stubFetch } from "./test-fetch-stub.js";
|
|
5
|
+
test("parseQueueArgs: add/remove require an issue id", () => {
|
|
6
|
+
assert.deepEqual(parseQueueArgs(["add", "issue-1"]), { subcommand: "add", issueId: "issue-1" });
|
|
7
|
+
assert.deepEqual(parseQueueArgs(["remove", "issue-1"]), {
|
|
8
|
+
subcommand: "remove",
|
|
9
|
+
issueId: "issue-1",
|
|
10
|
+
});
|
|
11
|
+
assert.throws(() => parseQueueArgs(["add"]));
|
|
12
|
+
assert.throws(() => parseQueueArgs(["remove"]));
|
|
13
|
+
});
|
|
14
|
+
test("parseQueueArgs: list has no args", () => {
|
|
15
|
+
assert.deepEqual(parseQueueArgs(["list"]), { subcommand: "list" });
|
|
16
|
+
});
|
|
17
|
+
test("queue list calls GET /api/queue", async () => {
|
|
18
|
+
const stub = stubFetch("/api/queue", "GET", []);
|
|
19
|
+
try {
|
|
20
|
+
assert.equal(await runQueueCommand(["list"]), 0);
|
|
21
|
+
stub.assertCalled();
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
stub.restore();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
test("queue add calls POST /api/queue", async () => {
|
|
28
|
+
const stub = stubFetch("/api/queue", "POST", { issueId: "issue-1", state: "queued" });
|
|
29
|
+
try {
|
|
30
|
+
assert.equal(await runQueueCommand(["add", "issue-1"]), 0);
|
|
31
|
+
stub.assertCalled();
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
stub.restore();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
test("queue remove calls DELETE /api/queue/:id", async () => {
|
|
38
|
+
const stub = stubFetch(/\/api\/queue\/issue-1$/, "DELETE", { issueId: "issue-1", state: "removed" });
|
|
39
|
+
try {
|
|
40
|
+
assert.equal(await runQueueCommand(["remove", "issue-1"]), 0);
|
|
41
|
+
stub.assertCalled();
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
stub.restore();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Stubs global fetch for one call, asserts the request shape, and restores it —
|
|
2
|
+
* exercises a CLI command's HTTP contract without a live server. */
|
|
3
|
+
export declare function stubFetch(expectedUrl: string | RegExp, expectedMethod: string, response: unknown, status?: number): {
|
|
4
|
+
restore: () => void;
|
|
5
|
+
assertCalled: () => unknown;
|
|
6
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
/** Stubs global fetch for one call, asserts the request shape, and restores it —
|
|
3
|
+
* exercises a CLI command's HTTP contract without a live server. */
|
|
4
|
+
export function stubFetch(expectedUrl, expectedMethod, response, status = 200) {
|
|
5
|
+
const original = globalThis.fetch;
|
|
6
|
+
let captured;
|
|
7
|
+
globalThis.fetch = (async (url, opts) => {
|
|
8
|
+
captured = { url: String(url), method: opts?.method ?? "GET", body: opts?.body ? JSON.parse(opts.body) : undefined };
|
|
9
|
+
return {
|
|
10
|
+
ok: status < 400,
|
|
11
|
+
status,
|
|
12
|
+
json: async () => response,
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
restore: () => {
|
|
17
|
+
globalThis.fetch = original;
|
|
18
|
+
},
|
|
19
|
+
assertCalled: () => {
|
|
20
|
+
assert.ok(captured, "expected fetch to be called");
|
|
21
|
+
if (typeof expectedUrl === "string") {
|
|
22
|
+
assert.ok(captured.url.endsWith(expectedUrl), `expected url to end with ${expectedUrl}, got ${captured.url}`);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
assert.match(captured.url, expectedUrl);
|
|
26
|
+
}
|
|
27
|
+
assert.equal(captured.method, expectedMethod);
|
|
28
|
+
return captured.body;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-dealer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Human control plane for agent execution — queue, plan approval, audit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"better-sqlite3": "^12.11.1",
|
|
47
47
|
"dotenv": "^16.5.0",
|
|
48
48
|
"fastify": "^5.3.3",
|
|
49
|
+
"smol-toml": "^1.8.0",
|
|
49
50
|
"uuid": "^11.1.0"
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -14,7 +14,7 @@ AGENT_DEALER_API=http://127.0.0.1:2222
|
|
|
14
14
|
# Linear (optional — manual tasks work without; edit after `agent-dealer setup`)
|
|
15
15
|
LINEAR_API_KEY=
|
|
16
16
|
LINEAR_TEAM_ID=
|
|
17
|
-
LINEAR_STATE_FILTER="Todo,
|
|
17
|
+
LINEAR_STATE_FILTER="Backlog,Todo,In Progress,In Review"
|
|
18
18
|
|
|
19
19
|
# Agent Deck UI proxy (optional)
|
|
20
20
|
# AGENT_DECK_API_URL=http://127.0.0.1:1111
|