agent-dealer 0.1.11 → 0.1.12

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.
@@ -0,0 +1,61 @@
1
+ import { test, before } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import fs from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ process.env.AGENT_DEALER_HOME = fs.mkdtempSync(path.join(os.tmpdir(), "dealer-extid-"));
7
+ process.env.MAX_CONCURRENT_RUNS = "0";
8
+ const { migrate } = await import("../db/index.js");
9
+ const { BUILTIN_AGENT_CLAUDE_ID } = await import("@agent-dealer/shared");
10
+ const { updateAgent } = await import("./agents.js");
11
+ const { createRun } = await import("./runs.js");
12
+ before(() => {
13
+ migrate();
14
+ updateAgent(BUILTIN_AGENT_CLAUDE_ID, { workspaceRoot: process.env.AGENT_DEALER_HOME });
15
+ });
16
+ test("manual create mints external_id = run.id and leaves external_label null", () => {
17
+ const run = createRun({
18
+ title: "Manual task",
19
+ taskCategory: "other",
20
+ status: "plan_pending",
21
+ agentId: BUILTIN_AGENT_CLAUDE_ID,
22
+ });
23
+ assert.equal(run.externalId, run.id);
24
+ assert.equal(run.externalLabel, null);
25
+ assert.equal(run.source, "manual");
26
+ });
27
+ test("manual retry copies parent external_id", () => {
28
+ const parent = createRun({
29
+ title: "Manual task",
30
+ taskCategory: "other",
31
+ status: "plan_pending",
32
+ agentId: BUILTIN_AGENT_CLAUDE_ID,
33
+ });
34
+ const child = createRun({
35
+ title: parent.title,
36
+ taskCategory: parent.taskCategory,
37
+ status: "plan_approved",
38
+ agentId: BUILTIN_AGENT_CLAUDE_ID,
39
+ }, {
40
+ source: parent.source,
41
+ externalId: parent.externalId ?? undefined,
42
+ externalLabel: parent.externalLabel ?? undefined,
43
+ lineageId: parent.lineageId ?? parent.id,
44
+ });
45
+ assert.equal(child.externalId, parent.externalId);
46
+ assert.equal(child.externalId, parent.id);
47
+ assert.equal(child.externalLabel, null);
48
+ assert.notEqual(child.id, parent.id);
49
+ });
50
+ test("explicit linear externalId is not replaced by run.id", () => {
51
+ const issueId = "11111111-1111-4111-8111-111111111111";
52
+ const run = createRun({
53
+ title: "LIN-1: Linear task",
54
+ taskCategory: "code",
55
+ status: "plan_pending",
56
+ agentId: BUILTIN_AGENT_CLAUDE_ID,
57
+ }, { source: "linear", externalId: issueId, externalLabel: "LIN-1" });
58
+ assert.equal(run.externalId, issueId);
59
+ assert.equal(run.externalLabel, "LIN-1");
60
+ assert.notEqual(run.externalId, run.id);
61
+ });
@@ -47,10 +47,12 @@ export function createRun(input, opts) {
47
47
  if (!repo) {
48
48
  throw new Error("Agent workspace not configured — set workspace on Agents page or provide repo override");
49
49
  }
50
+ const source = opts?.source ?? "manual";
51
+ const externalId = opts?.externalId ?? (source === "manual" ? id : null);
50
52
  const run = {
51
53
  id,
52
- source: opts?.source ?? "manual",
53
- external_id: opts?.externalId ?? null,
54
+ source,
55
+ external_id: externalId,
54
56
  external_label: opts?.externalLabel ?? null,
55
57
  task_category: input.taskCategory,
56
58
  title: input.title,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-dealer/server",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "files": [