kanbo-cli 0.3.0 → 0.5.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +2 -0
  3. package/dist/cli-main.cjs +1347 -254
  4. package/dist/drizzle-postgres/0006_flow_rules_and_column_entries.sql +3 -0
  5. package/dist/drizzle-postgres/README.md +8 -0
  6. package/dist/drizzle-postgres/meta/0006_snapshot.json +1290 -0
  7. package/dist/drizzle-postgres/meta/_journal.json +7 -0
  8. package/dist/drizzle-sqlite/0005_flow_rules_and_column_entries.sql +3 -0
  9. package/dist/drizzle-sqlite/README.md +8 -0
  10. package/dist/drizzle-sqlite/meta/0005_snapshot.json +1097 -0
  11. package/dist/drizzle-sqlite/meta/_journal.json +7 -0
  12. package/dist/lib/{approval-BsBk2xVr.d.cts → approval-CnJJfwfi.d.mts} +30 -6
  13. package/dist/lib/{approval-LRZ6ontC.d.mts → approval-DNfUhYD5.d.cts} +30 -6
  14. package/dist/lib/{board-store-D_Mpfb84.d.mts → board-store-D2x2w1wG.d.cts} +26 -2
  15. package/dist/lib/{board-store-Dx-mw2I6.d.cts → board-store-DN5Y2U2y.d.mts} +26 -2
  16. package/dist/lib/index.cjs +3 -1
  17. package/dist/lib/index.d.cts +96 -6
  18. package/dist/lib/index.d.mts +96 -6
  19. package/dist/lib/index.mjs +2 -2
  20. package/dist/lib/{manifest-QPoQl8tn.cjs → manifest-DUGRyC7A.cjs} +1378 -300
  21. package/dist/lib/{manifest-v2e9x_C8.mjs → manifest-t4LvFgzH.mjs} +1369 -303
  22. package/dist/lib/mcp/index.cjs +35 -6
  23. package/dist/lib/mcp/index.d.cts +23 -4
  24. package/dist/lib/mcp/index.d.mts +23 -4
  25. package/dist/lib/mcp/index.mjs +35 -6
  26. package/dist/lib/{migrate-DtBeW3Fs.mjs → migrate-BUsaTJlj.mjs} +8 -1
  27. package/dist/lib/{migrate-Dca5WdYd.cjs → migrate-BoGrqK9m.cjs} +7 -0
  28. package/dist/lib/postgres/index.cjs +1 -1
  29. package/dist/lib/postgres/index.d.cts +69 -1
  30. package/dist/lib/postgres/index.d.mts +69 -1
  31. package/dist/lib/postgres/index.mjs +1 -1
  32. package/dist/lib/{roles.sql-BoOZSkBp.mjs → roles.sql-BDmmNUdx.mjs} +18 -2
  33. package/dist/lib/{roles.sql-E58x7mLS.cjs → roles.sql-CBFxSHy7.cjs} +17 -1
  34. package/dist/lib/{schema-D0MyXcej.d.cts → schema-Cwx3HosC.d.cts} +72 -0
  35. package/dist/lib/{schema-D0MyXcej.d.mts → schema-Cwx3HosC.d.mts} +72 -0
  36. package/dist/lib/sqlite/index.cjs +1 -1
  37. package/dist/lib/sqlite/index.d.cts +2 -2
  38. package/dist/lib/sqlite/index.d.mts +2 -2
  39. package/dist/lib/sqlite/index.mjs +1 -1
  40. package/dist/lib/sqlite/schema.cjs +13 -1
  41. package/dist/lib/sqlite/schema.d.cts +1 -1
  42. package/dist/lib/sqlite/schema.d.mts +1 -1
  43. package/dist/lib/sqlite/schema.mjs +13 -1
  44. package/dist/page/board.css +1622 -327
  45. package/dist/page/board.js +2 -2
  46. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_manifest = require("../manifest-QPoQl8tn.cjs");
2
+ const require_manifest = require("../manifest-DUGRyC7A.cjs");
3
3
  const require_migrations_path = require("../migrations-path-DBCE17dT.cjs");
4
4
  let zod = require("zod");
5
5
  //#region src/mcp/http-transport.ts
@@ -42,7 +42,9 @@ const StatusSchema = zod.z.object({
42
42
  name: zod.z.string(),
43
43
  description: zod.z.string().nullable(),
44
44
  order: zod.z.number(),
45
- entryRules: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).nullish()
45
+ entryRules: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).nullish(),
46
+ allowedFrom: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).nullish(),
47
+ wipLimit: zod.z.number().nullish()
46
48
  });
47
49
  const CommentSchema = zod.z.object({
48
50
  id: zod.z.string(),
@@ -98,9 +100,15 @@ const ACTOR_KINDS = [
98
100
  const CardCommentSchema = zod.z.object({
99
101
  id: zod.z.string(),
100
102
  authorKind: zod.z.string(),
103
+ authorId: zod.z.string().nullish(),
104
+ sourceChatSessionId: zod.z.string().nullish(),
101
105
  content: zod.z.string(),
102
106
  createdAt: zod.z.number()
103
- });
107
+ }).transform((row) => ({
108
+ ...row,
109
+ authorId: row.authorId ?? null,
110
+ sourceChatSessionId: row.sourceChatSessionId ?? null
111
+ }));
104
112
  const FieldChangeSchema = zod.z.object({
105
113
  field: zod.z.string(),
106
114
  fromValue: zod.z.string().nullable(),
@@ -111,7 +119,8 @@ const FieldChangeSchema = zod.z.object({
111
119
  function createHttpTransport(input) {
112
120
  const { request } = input;
113
121
  async function readColumns() {
114
- return zod.z.array(StatusSchema).parse(await request("GET", `/issues/statuses?workspaceId=${encodeURIComponent(input.workspaceId())}`)).map(require_manifest.projectKanboColumn);
122
+ const statuses = zod.z.array(StatusSchema).parse(await request("GET", `/issues/statuses?workspaceId=${encodeURIComponent(input.workspaceId())}`));
123
+ return statuses.map((status) => require_manifest.projectKanboColumn(status, statuses));
115
124
  }
116
125
  /**
117
126
  * One card as a tool prints it. The response carries the column as a foreign
@@ -268,7 +277,10 @@ function createHttpTransport(input) {
268
277
  ...parent !== void 0 ? { parentIssueId: parent } : {},
269
278
  ...executionMode !== void 0 ? { executionMode } : {}
270
279
  })),
271
- cardUpdate: async ({ card, ...patch }) => await projectOne(await request("PATCH", `/issues/${encodeURIComponent(card)}`, patch)),
280
+ cardUpdate: async ({ card, parent, ...patch }) => await projectOne(await request("PATCH", `/issues/${encodeURIComponent(card)}`, {
281
+ ...patch,
282
+ ...parent !== void 0 ? { parentIssueId: parent } : {}
283
+ })),
272
284
  cardMove: async ({ card, column }) => await projectOne(await request("PATCH", `/issues/${encodeURIComponent(card)}/status/${encodeURIComponent(column)}`)),
273
285
  cardComment: async ({ card, content }) => CommentSchema.parse(await request("POST", `/issues/${encodeURIComponent(card)}/comments`, { content })),
274
286
  cardLinkPullRequest: async ({ card, url }) => require_manifest.projectKanboPullRequest(PullRequestSchema.parse(await request("POST", `/issues/${encodeURIComponent(card)}/pull-requests`, { url }))),
@@ -284,7 +296,24 @@ function createHttpTransport(input) {
284
296
  runFinish: async ({ run, state, errorText }) => require_manifest.projectKanboRun(RunSchema.parse(await request("PATCH", `/issues/runs/${encodeURIComponent(run)}`, {
285
297
  state,
286
298
  ...errorText !== void 0 ? { errorText } : {}
287
- })))
299
+ }))),
300
+ cardClaim: async ({ card, agent }) => {
301
+ const answer = zod.z.object({
302
+ card: IssueSchema,
303
+ run: RunSchema,
304
+ column: StatusSchema
305
+ }).parse(await request("POST", "/issues/claim", {
306
+ workspaceId: input.workspaceId(),
307
+ ...card !== void 0 ? { issueId: card } : {},
308
+ ...agent !== void 0 ? { agentName: agent } : {}
309
+ }));
310
+ const columns = await readColumns();
311
+ return {
312
+ card: require_manifest.projectKanboCard(answer.card, columns),
313
+ run: require_manifest.projectKanboRun(answer.run),
314
+ column: columns.find((column) => column.id === answer.column.id) ?? require_manifest.projectKanboColumn(answer.column, columns)
315
+ };
316
+ }
288
317
  };
289
318
  }
290
319
  /**
@@ -1,5 +1,5 @@
1
- import { s as IssueRun, t as Issue } from "../schema-D0MyXcej.cjs";
2
- import { _ as EntryRule, d as KANBO_TOOL_CLI_EQUIVALENTS, f as KANBO_TOOL_NAMES, i as IssueActorKind, m as KanboToolName, p as KanboToolCliEquivalent, r as CardLastComment } from "../approval-BsBk2xVr.cjs";
1
+ import { s as IssueRun, t as Issue } from "../schema-Cwx3HosC.cjs";
2
+ import { _ as EntryRule, d as KANBO_TOOL_CLI_EQUIVALENTS, f as KANBO_TOOL_NAMES, i as IssueActorKind, m as KanboToolName, p as KanboToolCliEquivalent, r as CardLastComment } from "../approval-DNfUhYD5.cjs";
3
3
  import { z } from "zod";
4
4
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
5
  import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
@@ -73,6 +73,8 @@ interface KanboCardDetailResult extends KanboCardResult {
73
73
  interface KanboCardCommentResult {
74
74
  id: string;
75
75
  author: IssueActorKind;
76
+ /** The name behind it: a person's or an agent's id, an outside writer's name, `kanbo` for the board's own lines. */
77
+ by: string;
76
78
  content: string;
77
79
  createdAt: number;
78
80
  }
@@ -146,6 +148,10 @@ interface KanboColumnResult {
146
148
  order: number;
147
149
  /** What a card must satisfy before an agent may move it here; empty for nothing. */
148
150
  entryRules: EntryRule[];
151
+ /** The slugs of the columns a card may enter this one from, in board order; `null` for any column, `[]` for none — only a person puts a card here. */
152
+ allowedFrom: string[] | null;
153
+ /** The most cards the column holds; `null` for no limit. */
154
+ wipLimit: number | null;
149
155
  }
150
156
  /**
151
157
  * A milestone read as a sprint, as `kanbo_sprints` hands it to an agent: its
@@ -216,6 +222,8 @@ interface KanboCardUpdateInput {
216
222
  priority?: Issue['priority'];
217
223
  labels?: string[];
218
224
  executionMode?: Issue['executionMode'];
225
+ /** The card to put this one under; `null` makes it a top-level card, and absent leaves it where it is. */
226
+ parent?: string | null;
219
227
  }
220
228
  /** What `kanbo_run_start` records about a launch. */
221
229
  interface KanboRunStartInput {
@@ -226,6 +234,12 @@ interface KanboRunStartInput {
226
234
  /** Where the agent's own log of this run lives: `claude:<id>` or `codex:<id>` (ruling 7-1). */
227
235
  session?: string;
228
236
  }
237
+ /** What `kanbo_card_claim` hands back: the card where it now is, the run it started, and the column it went to. */
238
+ interface KanboClaimResult {
239
+ card: KanboCardResult;
240
+ run: KanboRunResult;
241
+ column: KanboColumnResult;
242
+ }
229
243
  /** How `kanbo_run_finish` says a run ended. */
230
244
  interface KanboRunFinishInput {
231
245
  run: string;
@@ -291,6 +305,11 @@ interface KanboToolTransport {
291
305
  }) => Promise<KanboCardResult>;
292
306
  runStart: (input: KanboRunStartInput) => Promise<KanboRunResult>;
293
307
  runFinish: (input: KanboRunFinishInput) => Promise<KanboRunResult>;
308
+ /** Take a card — `card`, or the first ready one — starting a run named `agent` (the transport's own name for the caller when absent) and moving it into work. */
309
+ cardClaim: (input: {
310
+ card?: string;
311
+ agent?: string;
312
+ }) => Promise<KanboClaimResult>;
294
313
  }
295
314
  /**
296
315
  * A card as either transport already has it: the row's own fields with the
@@ -443,7 +462,7 @@ interface KanboTool {
443
462
  /**
444
463
  * Every tool the board has, in the order it declares them.
445
464
  *
446
- * The list is the board's, not a server's: the same sixteen are registered
465
+ * The list is the board's, not a server's: the same seventeen are registered
447
466
  * whether they run against a server or against the board directly, and the
448
467
  * only thing a host decides is which of them it publishes.
449
468
  */
@@ -495,4 +514,4 @@ export declare function registerKanboTools(server: McpServer, transport: KanboTo
495
514
  */
496
515
  export declare function createKanboMcpServer(transport: KanboToolTransport, options: KanboToolOptions): McpServer;
497
516
  //#endregion
498
- export { KANBO_TOOL_CLI_EQUIVALENTS, KANBO_TOOL_NAMES, type KanboActiveRunResult, type KanboCardCommentResult, type KanboCardCreateInput, type KanboCardDetailResult, type KanboCardFacts, type KanboCardInclude, type KanboCardPage, type KanboCardQuery, type KanboCardResult, type KanboCardUpdateInput, type KanboColumnResult, type KanboCommentResult, type KanboFieldChangeResult, type KanboHttpRequest, type KanboHttpTransportInput, type KanboPullRequestResult, type KanboReadyPage, type KanboRunFinishInput, type KanboRunResult, type KanboRunStartInput, type KanboSprintResult, type KanboTool, type KanboToolCliEquivalent, type KanboToolName, type KanboToolOptions, type KanboToolRegistration, type KanboToolResult, type KanboToolTransport };
517
+ export { KANBO_TOOL_CLI_EQUIVALENTS, KANBO_TOOL_NAMES, type KanboActiveRunResult, type KanboCardCommentResult, type KanboCardCreateInput, type KanboCardDetailResult, type KanboCardFacts, type KanboCardInclude, type KanboCardPage, type KanboCardQuery, type KanboCardResult, type KanboCardUpdateInput, type KanboClaimResult, type KanboColumnResult, type KanboCommentResult, type KanboFieldChangeResult, type KanboHttpRequest, type KanboHttpTransportInput, type KanboPullRequestResult, type KanboReadyPage, type KanboRunFinishInput, type KanboRunResult, type KanboRunStartInput, type KanboSprintResult, type KanboTool, type KanboToolCliEquivalent, type KanboToolName, type KanboToolOptions, type KanboToolRegistration, type KanboToolResult, type KanboToolTransport };
@@ -1,5 +1,5 @@
1
- import { s as IssueRun, t as Issue } from "../schema-D0MyXcej.mjs";
2
- import { _ as EntryRule, d as KANBO_TOOL_CLI_EQUIVALENTS, f as KANBO_TOOL_NAMES, i as IssueActorKind, m as KanboToolName, p as KanboToolCliEquivalent, r as CardLastComment } from "../approval-LRZ6ontC.mjs";
1
+ import { s as IssueRun, t as Issue } from "../schema-Cwx3HosC.mjs";
2
+ import { _ as EntryRule, d as KANBO_TOOL_CLI_EQUIVALENTS, f as KANBO_TOOL_NAMES, i as IssueActorKind, m as KanboToolName, p as KanboToolCliEquivalent, r as CardLastComment } from "../approval-CnJJfwfi.mjs";
3
3
  import { z } from "zod";
4
4
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
5
  import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
@@ -73,6 +73,8 @@ interface KanboCardDetailResult extends KanboCardResult {
73
73
  interface KanboCardCommentResult {
74
74
  id: string;
75
75
  author: IssueActorKind;
76
+ /** The name behind it: a person's or an agent's id, an outside writer's name, `kanbo` for the board's own lines. */
77
+ by: string;
76
78
  content: string;
77
79
  createdAt: number;
78
80
  }
@@ -146,6 +148,10 @@ interface KanboColumnResult {
146
148
  order: number;
147
149
  /** What a card must satisfy before an agent may move it here; empty for nothing. */
148
150
  entryRules: EntryRule[];
151
+ /** The slugs of the columns a card may enter this one from, in board order; `null` for any column, `[]` for none — only a person puts a card here. */
152
+ allowedFrom: string[] | null;
153
+ /** The most cards the column holds; `null` for no limit. */
154
+ wipLimit: number | null;
149
155
  }
150
156
  /**
151
157
  * A milestone read as a sprint, as `kanbo_sprints` hands it to an agent: its
@@ -216,6 +222,8 @@ interface KanboCardUpdateInput {
216
222
  priority?: Issue['priority'];
217
223
  labels?: string[];
218
224
  executionMode?: Issue['executionMode'];
225
+ /** The card to put this one under; `null` makes it a top-level card, and absent leaves it where it is. */
226
+ parent?: string | null;
219
227
  }
220
228
  /** What `kanbo_run_start` records about a launch. */
221
229
  interface KanboRunStartInput {
@@ -226,6 +234,12 @@ interface KanboRunStartInput {
226
234
  /** Where the agent's own log of this run lives: `claude:<id>` or `codex:<id>` (ruling 7-1). */
227
235
  session?: string;
228
236
  }
237
+ /** What `kanbo_card_claim` hands back: the card where it now is, the run it started, and the column it went to. */
238
+ interface KanboClaimResult {
239
+ card: KanboCardResult;
240
+ run: KanboRunResult;
241
+ column: KanboColumnResult;
242
+ }
229
243
  /** How `kanbo_run_finish` says a run ended. */
230
244
  interface KanboRunFinishInput {
231
245
  run: string;
@@ -291,6 +305,11 @@ interface KanboToolTransport {
291
305
  }) => Promise<KanboCardResult>;
292
306
  runStart: (input: KanboRunStartInput) => Promise<KanboRunResult>;
293
307
  runFinish: (input: KanboRunFinishInput) => Promise<KanboRunResult>;
308
+ /** Take a card — `card`, or the first ready one — starting a run named `agent` (the transport's own name for the caller when absent) and moving it into work. */
309
+ cardClaim: (input: {
310
+ card?: string;
311
+ agent?: string;
312
+ }) => Promise<KanboClaimResult>;
294
313
  }
295
314
  /**
296
315
  * A card as either transport already has it: the row's own fields with the
@@ -443,7 +462,7 @@ interface KanboTool {
443
462
  /**
444
463
  * Every tool the board has, in the order it declares them.
445
464
  *
446
- * The list is the board's, not a server's: the same sixteen are registered
465
+ * The list is the board's, not a server's: the same seventeen are registered
447
466
  * whether they run against a server or against the board directly, and the
448
467
  * only thing a host decides is which of them it publishes.
449
468
  */
@@ -495,4 +514,4 @@ export declare function registerKanboTools(server: McpServer, transport: KanboTo
495
514
  */
496
515
  export declare function createKanboMcpServer(transport: KanboToolTransport, options: KanboToolOptions): McpServer;
497
516
  //#endregion
498
- export { KANBO_TOOL_CLI_EQUIVALENTS, KANBO_TOOL_NAMES, type KanboActiveRunResult, type KanboCardCommentResult, type KanboCardCreateInput, type KanboCardDetailResult, type KanboCardFacts, type KanboCardInclude, type KanboCardPage, type KanboCardQuery, type KanboCardResult, type KanboCardUpdateInput, type KanboColumnResult, type KanboCommentResult, type KanboFieldChangeResult, type KanboHttpRequest, type KanboHttpTransportInput, type KanboPullRequestResult, type KanboReadyPage, type KanboRunFinishInput, type KanboRunResult, type KanboRunStartInput, type KanboSprintResult, type KanboTool, type KanboToolCliEquivalent, type KanboToolName, type KanboToolOptions, type KanboToolRegistration, type KanboToolResult, type KanboToolTransport };
517
+ export { KANBO_TOOL_CLI_EQUIVALENTS, KANBO_TOOL_NAMES, type KanboActiveRunResult, type KanboCardCommentResult, type KanboCardCreateInput, type KanboCardDetailResult, type KanboCardFacts, type KanboCardInclude, type KanboCardPage, type KanboCardQuery, type KanboCardResult, type KanboCardUpdateInput, type KanboClaimResult, type KanboColumnResult, type KanboCommentResult, type KanboFieldChangeResult, type KanboHttpRequest, type KanboHttpTransportInput, type KanboPullRequestResult, type KanboReadyPage, type KanboRunFinishInput, type KanboRunResult, type KanboRunStartInput, type KanboSprintResult, type KanboTool, type KanboToolCliEquivalent, type KanboToolName, type KanboToolOptions, type KanboToolRegistration, type KanboToolResult, type KanboToolTransport };
@@ -1,4 +1,4 @@
1
- import { A as projectKanboSprint, C as pageOf, D as projectKanboFieldChange, E as projectKanboColumn, O as projectKanboPullRequest, S as matchesKanboCardQuery, T as projectKanboCardComment, b as DEFAULT_KANBO_COMMENT_LIMIT, c as registerKanboTools, d as KANBO_MCP_INSTRUCTIONS, f as KANBO_CAPABILITIES_MARKDOWN_RESOURCE_URI, i as KANBO_TOOL_NAMES, it as normalizeStatusName, j as projectKanboSubCard, k as projectKanboRun, l as KANBO_TOOLS, m as registerKanboCapabilitiesResources, o as KANBO_MCP_SERVER_NAME, p as KANBO_CAPABILITIES_RESOURCE_URI, r as KANBO_TOOL_CLI_EQUIVALENTS, s as createKanboMcpServer, st as previewComment, u as buildKanboTools, w as projectKanboCard, x as KANBO_CARD_INCLUDES, y as DEFAULT_KANBO_CARD_INCLUDES } from "../manifest-v2e9x_C8.mjs";
1
+ import { A as projectKanboSprint, C as pageOf, D as projectKanboFieldChange, E as projectKanboColumn, O as projectKanboPullRequest, S as matchesKanboCardQuery, T as projectKanboCardComment, b as DEFAULT_KANBO_COMMENT_LIMIT, c as registerKanboTools, d as KANBO_MCP_INSTRUCTIONS, f as KANBO_CAPABILITIES_MARKDOWN_RESOURCE_URI, i as KANBO_TOOL_NAMES, j as projectKanboSubCard, k as projectKanboRun, l as KANBO_TOOLS, lt as previewComment, m as registerKanboCapabilitiesResources, o as KANBO_MCP_SERVER_NAME, ot as normalizeStatusName, p as KANBO_CAPABILITIES_RESOURCE_URI, r as KANBO_TOOL_CLI_EQUIVALENTS, s as createKanboMcpServer, u as buildKanboTools, w as projectKanboCard, x as KANBO_CARD_INCLUDES, y as DEFAULT_KANBO_CARD_INCLUDES } from "../manifest-t4LvFgzH.mjs";
2
2
  import { a as BoardError } from "../migrations-path-ClaYRNwk.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/mcp/http-transport.ts
@@ -41,7 +41,9 @@ const StatusSchema = z.object({
41
41
  name: z.string(),
42
42
  description: z.string().nullable(),
43
43
  order: z.number(),
44
- entryRules: z.union([z.string(), z.array(z.string())]).nullish()
44
+ entryRules: z.union([z.string(), z.array(z.string())]).nullish(),
45
+ allowedFrom: z.union([z.string(), z.array(z.string())]).nullish(),
46
+ wipLimit: z.number().nullish()
45
47
  });
46
48
  const CommentSchema = z.object({
47
49
  id: z.string(),
@@ -97,9 +99,15 @@ const ACTOR_KINDS = [
97
99
  const CardCommentSchema = z.object({
98
100
  id: z.string(),
99
101
  authorKind: z.string(),
102
+ authorId: z.string().nullish(),
103
+ sourceChatSessionId: z.string().nullish(),
100
104
  content: z.string(),
101
105
  createdAt: z.number()
102
- });
106
+ }).transform((row) => ({
107
+ ...row,
108
+ authorId: row.authorId ?? null,
109
+ sourceChatSessionId: row.sourceChatSessionId ?? null
110
+ }));
103
111
  const FieldChangeSchema = z.object({
104
112
  field: z.string(),
105
113
  fromValue: z.string().nullable(),
@@ -110,7 +118,8 @@ const FieldChangeSchema = z.object({
110
118
  function createHttpTransport(input) {
111
119
  const { request } = input;
112
120
  async function readColumns() {
113
- return z.array(StatusSchema).parse(await request("GET", `/issues/statuses?workspaceId=${encodeURIComponent(input.workspaceId())}`)).map(projectKanboColumn);
121
+ const statuses = z.array(StatusSchema).parse(await request("GET", `/issues/statuses?workspaceId=${encodeURIComponent(input.workspaceId())}`));
122
+ return statuses.map((status) => projectKanboColumn(status, statuses));
114
123
  }
115
124
  /**
116
125
  * One card as a tool prints it. The response carries the column as a foreign
@@ -267,7 +276,10 @@ function createHttpTransport(input) {
267
276
  ...parent !== void 0 ? { parentIssueId: parent } : {},
268
277
  ...executionMode !== void 0 ? { executionMode } : {}
269
278
  })),
270
- cardUpdate: async ({ card, ...patch }) => await projectOne(await request("PATCH", `/issues/${encodeURIComponent(card)}`, patch)),
279
+ cardUpdate: async ({ card, parent, ...patch }) => await projectOne(await request("PATCH", `/issues/${encodeURIComponent(card)}`, {
280
+ ...patch,
281
+ ...parent !== void 0 ? { parentIssueId: parent } : {}
282
+ })),
271
283
  cardMove: async ({ card, column }) => await projectOne(await request("PATCH", `/issues/${encodeURIComponent(card)}/status/${encodeURIComponent(column)}`)),
272
284
  cardComment: async ({ card, content }) => CommentSchema.parse(await request("POST", `/issues/${encodeURIComponent(card)}/comments`, { content })),
273
285
  cardLinkPullRequest: async ({ card, url }) => projectKanboPullRequest(PullRequestSchema.parse(await request("POST", `/issues/${encodeURIComponent(card)}/pull-requests`, { url }))),
@@ -283,7 +295,24 @@ function createHttpTransport(input) {
283
295
  runFinish: async ({ run, state, errorText }) => projectKanboRun(RunSchema.parse(await request("PATCH", `/issues/runs/${encodeURIComponent(run)}`, {
284
296
  state,
285
297
  ...errorText !== void 0 ? { errorText } : {}
286
- })))
298
+ }))),
299
+ cardClaim: async ({ card, agent }) => {
300
+ const answer = z.object({
301
+ card: IssueSchema,
302
+ run: RunSchema,
303
+ column: StatusSchema
304
+ }).parse(await request("POST", "/issues/claim", {
305
+ workspaceId: input.workspaceId(),
306
+ ...card !== void 0 ? { issueId: card } : {},
307
+ ...agent !== void 0 ? { agentName: agent } : {}
308
+ }));
309
+ const columns = await readColumns();
310
+ return {
311
+ card: projectKanboCard(answer.card, columns),
312
+ run: projectKanboRun(answer.run),
313
+ column: columns.find((column) => column.id === answer.column.id) ?? projectKanboColumn(answer.column, columns)
314
+ };
315
+ }
287
316
  };
288
317
  }
289
318
  /**
@@ -1,7 +1,7 @@
1
1
  import { a as BoardError, i as BOARD_TABLES_ADDED_WITHIN_EPOCH, n as resolveBoardMigrationsPath, t as hasMigrationJournal } from "./migrations-path-ClaYRNwk.mjs";
2
2
  import { boardSqliteSchema, issueComments, issueFieldChanges, issueMilestones, issuePullRequests, issueRelations, issueRuns, issueStatuses, issues, kanbanMeta } from "./sqlite/schema.mjs";
3
3
  import { createRequire } from "node:module";
4
- import { and, asc, desc, eq, getTableColumns, gte, inArray, isNotNull, isNull, or, sql } from "drizzle-orm";
4
+ import { and, asc, desc, eq, getTableColumns, gte, inArray, isNotNull, isNull, lte, or, sql } from "drizzle-orm";
5
5
  import { getTableConfig } from "drizzle-orm/sqlite-core";
6
6
  import { dirname } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
@@ -306,6 +306,7 @@ function createSqliteBoardStoreCore(resolveDatabase) {
306
306
  }).from(issues).where(and(eq(issues.workspaceId, workspaceId), isNotNull(issues.milestoneId))).groupBy(issues.milestoneId, issues.statusId).all(),
307
307
  listByIds: (issueIds) => resolveDatabase().select().from(issues).where(inArray(issues.id, issueIds)).all(),
308
308
  findById: (issueId) => resolveDatabase().select().from(issues).where(eq(issues.id, issueId)).get() ?? null,
309
+ lockById: (issueId) => resolveDatabase().select().from(issues).where(eq(issues.id, issueId)).get() ?? null,
309
310
  findInWorkspace: (workspaceId, issueId) => resolveDatabase().select().from(issues).where(and(eq(issues.id, issueId), eq(issues.workspaceId, workspaceId))).get() ?? null,
310
311
  findByNumber: (workspaceId, number) => resolveDatabase().select().from(issues).where(and(eq(issues.workspaceId, workspaceId), eq(issues.number, number))).get() ?? null,
311
312
  maxNumber: (workspaceId) => {
@@ -403,6 +404,10 @@ function createSqliteBoardStoreCore(resolveDatabase) {
403
404
  fieldChanges: {
404
405
  listByIssue: (issueId) => resolveDatabase().select().from(issueFieldChanges).where(eq(issueFieldChanges.issueId, issueId)).orderBy(asc(issueFieldChanges.createdAt), FIELD_CHANGE_INSERTION_ORDER).all(),
405
406
  listByIssueField: (issueId, field) => resolveDatabase().select().from(issueFieldChanges).where(and(eq(issueFieldChanges.issueId, issueId), eq(issueFieldChanges.field, field))).orderBy(asc(issueFieldChanges.createdAt), FIELD_CHANGE_INSERTION_ORDER).all(),
407
+ listByFieldSince: (field, query) => query.workspaceIds.length === 0 ? [] : resolveDatabase().select({
408
+ ...getTableColumns(issueFieldChanges),
409
+ workspaceId: issues.workspaceId
410
+ }).from(issueFieldChanges).innerJoin(issues, eq(issues.id, issueFieldChanges.issueId)).where(and(eq(issueFieldChanges.field, field), isNotNull(issueFieldChanges.toValue), gte(issueFieldChanges.createdAt, query.since), query.until === void 0 ? void 0 : lte(issueFieldChanges.createdAt, query.until), inArray(issues.workspaceId, [...query.workspaceIds]))).orderBy(asc(issueFieldChanges.createdAt), asc(issueFieldChanges.id)).limit(query.limit ?? Number.MAX_SAFE_INTEGER).all(),
406
411
  create: (values) => {
407
412
  resolveDatabase().insert(issueFieldChanges).values(values).run();
408
413
  }
@@ -483,6 +488,7 @@ function createSqliteBoardStore(options) {
483
488
  countByMilestone: async (workspaceId) => core.issues.countByMilestone(workspaceId),
484
489
  listByIds: async (issueIds) => core.issues.listByIds(issueIds),
485
490
  findById: async (issueId) => core.issues.findById(issueId),
491
+ lockById: async (issueId) => core.issues.lockById(issueId),
486
492
  findInWorkspace: async (workspaceId, issueId) => core.issues.findInWorkspace(workspaceId, issueId),
487
493
  findByNumber: async (workspaceId, number) => core.issues.findByNumber(workspaceId, number),
488
494
  maxNumber: async (workspaceId) => core.issues.maxNumber(workspaceId),
@@ -528,6 +534,7 @@ function createSqliteBoardStore(options) {
528
534
  fieldChanges: {
529
535
  listByIssue: async (issueId) => core.fieldChanges.listByIssue(issueId),
530
536
  listByIssueField: async (issueId, field) => core.fieldChanges.listByIssueField(issueId, field),
537
+ listByFieldSince: async (field, query) => core.fieldChanges.listByFieldSince(field, query),
531
538
  create: async (values) => core.fieldChanges.create(values)
532
539
  },
533
540
  pullRequests: {
@@ -306,6 +306,7 @@ function createSqliteBoardStoreCore(resolveDatabase) {
306
306
  }).from(require_sqlite_schema.issues).where((0, drizzle_orm.and)((0, drizzle_orm.eq)(require_sqlite_schema.issues.workspaceId, workspaceId), (0, drizzle_orm.isNotNull)(require_sqlite_schema.issues.milestoneId))).groupBy(require_sqlite_schema.issues.milestoneId, require_sqlite_schema.issues.statusId).all(),
307
307
  listByIds: (issueIds) => resolveDatabase().select().from(require_sqlite_schema.issues).where((0, drizzle_orm.inArray)(require_sqlite_schema.issues.id, issueIds)).all(),
308
308
  findById: (issueId) => resolveDatabase().select().from(require_sqlite_schema.issues).where((0, drizzle_orm.eq)(require_sqlite_schema.issues.id, issueId)).get() ?? null,
309
+ lockById: (issueId) => resolveDatabase().select().from(require_sqlite_schema.issues).where((0, drizzle_orm.eq)(require_sqlite_schema.issues.id, issueId)).get() ?? null,
309
310
  findInWorkspace: (workspaceId, issueId) => resolveDatabase().select().from(require_sqlite_schema.issues).where((0, drizzle_orm.and)((0, drizzle_orm.eq)(require_sqlite_schema.issues.id, issueId), (0, drizzle_orm.eq)(require_sqlite_schema.issues.workspaceId, workspaceId))).get() ?? null,
310
311
  findByNumber: (workspaceId, number) => resolveDatabase().select().from(require_sqlite_schema.issues).where((0, drizzle_orm.and)((0, drizzle_orm.eq)(require_sqlite_schema.issues.workspaceId, workspaceId), (0, drizzle_orm.eq)(require_sqlite_schema.issues.number, number))).get() ?? null,
311
312
  maxNumber: (workspaceId) => {
@@ -403,6 +404,10 @@ function createSqliteBoardStoreCore(resolveDatabase) {
403
404
  fieldChanges: {
404
405
  listByIssue: (issueId) => resolveDatabase().select().from(require_sqlite_schema.issueFieldChanges).where((0, drizzle_orm.eq)(require_sqlite_schema.issueFieldChanges.issueId, issueId)).orderBy((0, drizzle_orm.asc)(require_sqlite_schema.issueFieldChanges.createdAt), FIELD_CHANGE_INSERTION_ORDER).all(),
405
406
  listByIssueField: (issueId, field) => resolveDatabase().select().from(require_sqlite_schema.issueFieldChanges).where((0, drizzle_orm.and)((0, drizzle_orm.eq)(require_sqlite_schema.issueFieldChanges.issueId, issueId), (0, drizzle_orm.eq)(require_sqlite_schema.issueFieldChanges.field, field))).orderBy((0, drizzle_orm.asc)(require_sqlite_schema.issueFieldChanges.createdAt), FIELD_CHANGE_INSERTION_ORDER).all(),
407
+ listByFieldSince: (field, query) => query.workspaceIds.length === 0 ? [] : resolveDatabase().select({
408
+ ...(0, drizzle_orm.getTableColumns)(require_sqlite_schema.issueFieldChanges),
409
+ workspaceId: require_sqlite_schema.issues.workspaceId
410
+ }).from(require_sqlite_schema.issueFieldChanges).innerJoin(require_sqlite_schema.issues, (0, drizzle_orm.eq)(require_sqlite_schema.issues.id, require_sqlite_schema.issueFieldChanges.issueId)).where((0, drizzle_orm.and)((0, drizzle_orm.eq)(require_sqlite_schema.issueFieldChanges.field, field), (0, drizzle_orm.isNotNull)(require_sqlite_schema.issueFieldChanges.toValue), (0, drizzle_orm.gte)(require_sqlite_schema.issueFieldChanges.createdAt, query.since), query.until === void 0 ? void 0 : (0, drizzle_orm.lte)(require_sqlite_schema.issueFieldChanges.createdAt, query.until), (0, drizzle_orm.inArray)(require_sqlite_schema.issues.workspaceId, [...query.workspaceIds]))).orderBy((0, drizzle_orm.asc)(require_sqlite_schema.issueFieldChanges.createdAt), (0, drizzle_orm.asc)(require_sqlite_schema.issueFieldChanges.id)).limit(query.limit ?? Number.MAX_SAFE_INTEGER).all(),
406
411
  create: (values) => {
407
412
  resolveDatabase().insert(require_sqlite_schema.issueFieldChanges).values(values).run();
408
413
  }
@@ -483,6 +488,7 @@ function createSqliteBoardStore(options) {
483
488
  countByMilestone: async (workspaceId) => core.issues.countByMilestone(workspaceId),
484
489
  listByIds: async (issueIds) => core.issues.listByIds(issueIds),
485
490
  findById: async (issueId) => core.issues.findById(issueId),
491
+ lockById: async (issueId) => core.issues.lockById(issueId),
486
492
  findInWorkspace: async (workspaceId, issueId) => core.issues.findInWorkspace(workspaceId, issueId),
487
493
  findByNumber: async (workspaceId, number) => core.issues.findByNumber(workspaceId, number),
488
494
  maxNumber: async (workspaceId) => core.issues.maxNumber(workspaceId),
@@ -528,6 +534,7 @@ function createSqliteBoardStore(options) {
528
534
  fieldChanges: {
529
535
  listByIssue: async (issueId) => core.fieldChanges.listByIssue(issueId),
530
536
  listByIssueField: async (issueId, field) => core.fieldChanges.listByIssueField(issueId, field),
537
+ listByFieldSince: async (field, query) => core.fieldChanges.listByFieldSince(field, query),
531
538
  create: async (values) => core.fieldChanges.create(values)
532
539
  },
533
540
  pullRequests: {
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_migrations_path = require("../migrations-path-DBCE17dT.cjs");
3
- const require_roles_sql = require("../roles.sql-E58x7mLS.cjs");
3
+ const require_roles_sql = require("../roles.sql-CBFxSHy7.cjs");
4
4
  let drizzle_orm = require("drizzle-orm");
5
5
  let drizzle_orm_postgres_js_migrator = require("drizzle-orm/postgres-js/migrator");
6
6
  let drizzle_orm_pglite_migrator = require("drizzle-orm/pglite/migrator");
@@ -1,4 +1,4 @@
1
- import { c as BoardStore } from "../board-store-Dx-mw2I6.cjs";
1
+ import { l as BoardStore } from "../board-store-D2x2w1wG.cjs";
2
2
  import { t as BOARD_SCHEMA_EPOCH } from "../schema-epoch-ZyumVL_A.cjs";
3
3
  import { PgDatabase, PgQueryResultHKT } from "drizzle-orm/pg-core";
4
4
  import { PgliteDatabase } from "drizzle-orm/pglite";
@@ -297,6 +297,40 @@ export declare const issueStatuses: import("drizzle-orm/pg-core").PgTableWithCol
297
297
  identity: undefined;
298
298
  generated: undefined;
299
299
  }, {}, {}>;
300
+ allowedFrom: import("drizzle-orm/pg-core").PgColumn<{
301
+ name: "allowed_from";
302
+ tableName: "issue_statuses";
303
+ dataType: "string";
304
+ columnType: "PgText";
305
+ data: string;
306
+ driverParam: string;
307
+ notNull: false;
308
+ hasDefault: false;
309
+ isPrimaryKey: false;
310
+ isAutoincrement: false;
311
+ hasRuntimeDefault: false;
312
+ enumValues: [string, ...string[]];
313
+ baseColumn: never;
314
+ identity: undefined;
315
+ generated: undefined;
316
+ }, {}, {}>;
317
+ wipLimit: import("drizzle-orm/pg-core").PgColumn<{
318
+ name: "wip_limit";
319
+ tableName: "issue_statuses";
320
+ dataType: "number";
321
+ columnType: "PgInteger";
322
+ data: number;
323
+ driverParam: string | number;
324
+ notNull: false;
325
+ hasDefault: false;
326
+ isPrimaryKey: false;
327
+ isAutoincrement: false;
328
+ hasRuntimeDefault: false;
329
+ enumValues: undefined;
330
+ baseColumn: never;
331
+ identity: undefined;
332
+ generated: undefined;
333
+ }, {}, {}>;
300
334
  };
301
335
  dialect: 'pg';
302
336
  }>;
@@ -1840,6 +1874,40 @@ export declare const boardPostgresSchema: {
1840
1874
  identity: undefined;
1841
1875
  generated: undefined;
1842
1876
  }, {}, {}>;
1877
+ allowedFrom: import("drizzle-orm/pg-core").PgColumn<{
1878
+ name: "allowed_from";
1879
+ tableName: "issue_statuses";
1880
+ dataType: "string";
1881
+ columnType: "PgText";
1882
+ data: string;
1883
+ driverParam: string;
1884
+ notNull: false;
1885
+ hasDefault: false;
1886
+ isPrimaryKey: false;
1887
+ isAutoincrement: false;
1888
+ hasRuntimeDefault: false;
1889
+ enumValues: [string, ...string[]];
1890
+ baseColumn: never;
1891
+ identity: undefined;
1892
+ generated: undefined;
1893
+ }, {}, {}>;
1894
+ wipLimit: import("drizzle-orm/pg-core").PgColumn<{
1895
+ name: "wip_limit";
1896
+ tableName: "issue_statuses";
1897
+ dataType: "number";
1898
+ columnType: "PgInteger";
1899
+ data: number;
1900
+ driverParam: string | number;
1901
+ notNull: false;
1902
+ hasDefault: false;
1903
+ isPrimaryKey: false;
1904
+ isAutoincrement: false;
1905
+ hasRuntimeDefault: false;
1906
+ enumValues: undefined;
1907
+ baseColumn: never;
1908
+ identity: undefined;
1909
+ generated: undefined;
1910
+ }, {}, {}>;
1843
1911
  };
1844
1912
  dialect: 'pg';
1845
1913
  }>;
@@ -1,4 +1,4 @@
1
- import { c as BoardStore } from "../board-store-D_Mpfb84.mjs";
1
+ import { l as BoardStore } from "../board-store-DN5Y2U2y.mjs";
2
2
  import { t as BOARD_SCHEMA_EPOCH } from "../schema-epoch-ZyumVL_A.mjs";
3
3
  import { PgDatabase, PgQueryResultHKT } from "drizzle-orm/pg-core";
4
4
  import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
@@ -297,6 +297,40 @@ export declare const issueStatuses: import("drizzle-orm/pg-core").PgTableWithCol
297
297
  identity: undefined;
298
298
  generated: undefined;
299
299
  }, {}, {}>;
300
+ allowedFrom: import("drizzle-orm/pg-core").PgColumn<{
301
+ name: "allowed_from";
302
+ tableName: "issue_statuses";
303
+ dataType: "string";
304
+ columnType: "PgText";
305
+ data: string;
306
+ driverParam: string;
307
+ notNull: false;
308
+ hasDefault: false;
309
+ isPrimaryKey: false;
310
+ isAutoincrement: false;
311
+ hasRuntimeDefault: false;
312
+ enumValues: [string, ...string[]];
313
+ baseColumn: never;
314
+ identity: undefined;
315
+ generated: undefined;
316
+ }, {}, {}>;
317
+ wipLimit: import("drizzle-orm/pg-core").PgColumn<{
318
+ name: "wip_limit";
319
+ tableName: "issue_statuses";
320
+ dataType: "number";
321
+ columnType: "PgInteger";
322
+ data: number;
323
+ driverParam: string | number;
324
+ notNull: false;
325
+ hasDefault: false;
326
+ isPrimaryKey: false;
327
+ isAutoincrement: false;
328
+ hasRuntimeDefault: false;
329
+ enumValues: undefined;
330
+ baseColumn: never;
331
+ identity: undefined;
332
+ generated: undefined;
333
+ }, {}, {}>;
300
334
  };
301
335
  dialect: 'pg';
302
336
  }>;
@@ -1840,6 +1874,40 @@ export declare const boardPostgresSchema: {
1840
1874
  identity: undefined;
1841
1875
  generated: undefined;
1842
1876
  }, {}, {}>;
1877
+ allowedFrom: import("drizzle-orm/pg-core").PgColumn<{
1878
+ name: "allowed_from";
1879
+ tableName: "issue_statuses";
1880
+ dataType: "string";
1881
+ columnType: "PgText";
1882
+ data: string;
1883
+ driverParam: string;
1884
+ notNull: false;
1885
+ hasDefault: false;
1886
+ isPrimaryKey: false;
1887
+ isAutoincrement: false;
1888
+ hasRuntimeDefault: false;
1889
+ enumValues: [string, ...string[]];
1890
+ baseColumn: never;
1891
+ identity: undefined;
1892
+ generated: undefined;
1893
+ }, {}, {}>;
1894
+ wipLimit: import("drizzle-orm/pg-core").PgColumn<{
1895
+ name: "wip_limit";
1896
+ tableName: "issue_statuses";
1897
+ dataType: "number";
1898
+ columnType: "PgInteger";
1899
+ data: number;
1900
+ driverParam: string | number;
1901
+ notNull: false;
1902
+ hasDefault: false;
1903
+ isPrimaryKey: false;
1904
+ isAutoincrement: false;
1905
+ hasRuntimeDefault: false;
1906
+ enumValues: undefined;
1907
+ baseColumn: never;
1908
+ identity: undefined;
1909
+ generated: undefined;
1910
+ }, {}, {}>;
1843
1911
  };
1844
1912
  dialect: 'pg';
1845
1913
  }>;
@@ -1,5 +1,5 @@
1
1
  import { r as BOARD_SCHEMA_EPOCH } from "../migrations-path-ClaYRNwk.mjs";
2
- import { _ as issueStatuses, a as BOARD_REFUSAL_ERRCODE, c as getBoardMigrationsPath, d as boardPostgresSchema, f as issueComments, g as issueRuns, h as issueRelations, i as BOARD_PERSON_ROLE, l as createPostgresBoardStore, m as issueMilestones, n as AGENT_WAITING_REFUSAL, o as BOARD_ROLE_SQL, p as issueFieldChanges, r as BOARD_AGENT_ROLE, s as assertBoardSchema, t as AGENT_APPROVAL_COMMENT_REFUSAL, u as BOARD_POSTGRES_TABLES, v as issues, y as kanbanMeta } from "../roles.sql-BoOZSkBp.mjs";
2
+ import { _ as issueStatuses, a as BOARD_REFUSAL_ERRCODE, c as getBoardMigrationsPath, d as boardPostgresSchema, f as issueComments, g as issueRuns, h as issueRelations, i as BOARD_PERSON_ROLE, l as createPostgresBoardStore, m as issueMilestones, n as AGENT_WAITING_REFUSAL, o as BOARD_ROLE_SQL, p as issueFieldChanges, r as BOARD_AGENT_ROLE, s as assertBoardSchema, t as AGENT_APPROVAL_COMMENT_REFUSAL, u as BOARD_POSTGRES_TABLES, v as issues, y as kanbanMeta } from "../roles.sql-BDmmNUdx.mjs";
3
3
  import { entityKind } from "drizzle-orm";
4
4
  import { migrate } from "drizzle-orm/postgres-js/migrator";
5
5
  import { migrate as migrate$1 } from "drizzle-orm/pglite/migrator";
@@ -1,5 +1,5 @@
1
1
  import { a as BoardError, i as BOARD_TABLES_ADDED_WITHIN_EPOCH, n as resolveBoardMigrationsPath, t as hasMigrationJournal } from "./migrations-path-ClaYRNwk.mjs";
2
- import { and, asc, desc, eq, getTableColumns, gte, inArray, isNotNull, isNull, or, sql } from "drizzle-orm";
2
+ import { and, asc, desc, eq, getTableColumns, gte, inArray, isNotNull, isNull, lte, or, sql } from "drizzle-orm";
3
3
  import { bigint, bigserial, getTableConfig, index, integer, pgSchema, pgTable, text, uniqueIndex } from "drizzle-orm/pg-core";
4
4
  import { dirname } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
@@ -73,6 +73,10 @@ const issueStatuses = pgTable("issue_statuses", {
73
73
  order: integer("order").notNull().default(0),
74
74
  /** A JSON array of `ENTRY_RULES`, or `null` for none — see the SQLite schema. */
75
75
  entryRules: text("entry_rules"),
76
+ /** A JSON array of the status ids a card may enter from, or `null` for any — see the SQLite schema. */
77
+ allowedFrom: text("allowed_from"),
78
+ /** The most cards the column holds, or `null` — see the SQLite schema. */
79
+ wipLimit: integer("wip_limit"),
76
80
  ...createdAt()
77
81
  }, (table) => [index("issue_statuses_workspace_id_idx").on(table.workspaceId), uniqueIndex("issue_statuses_workspace_name_unique").on(table.workspaceId, table.name)]);
78
82
  const issueMilestones = pgTable("issue_milestones", {
@@ -220,7 +224,7 @@ const issueFieldChanges = pgTable("issue_field_changes", {
220
224
  ...createdAt(),
221
225
  /** Insertion order, standing in for the `rowid` the SQLite board orders changes by. */
222
226
  seq: bigserial("seq", { mode: "number" }).notNull()
223
- }, (table) => [index("issue_field_changes_issue_id_idx").on(table.issueId)]);
227
+ }, (table) => [index("issue_field_changes_issue_id_idx").on(table.issueId), index("issue_field_changes_field_created_at_idx").on(table.field, table.createdAt)]);
224
228
  /** A pull request someone said belongs to a card — see the SQLite twin for what the row is and is not. */
225
229
  const issuePullRequests = pgTable("issue_pull_requests", {
226
230
  id: textPk(),
@@ -296,6 +300,10 @@ function toIssueComment({ seq: _seq, ...comment }) {
296
300
  function toIssueFieldChange({ seq: _seq, ...change }) {
297
301
  return change;
298
302
  }
303
+ /** A field change with its card's workspace, without `seq`, for the same reason. */
304
+ function toWorkspaceFieldChange({ seq: _seq, ...change }) {
305
+ return change;
306
+ }
299
307
  /** The pull-request link without `seq`, for the same reason. */
300
308
  function toIssuePullRequest({ seq: _seq, ...link }) {
301
309
  return link;
@@ -502,6 +510,10 @@ function createStoreOver(database) {
502
510
  const [row] = await database.select().from(issues).where(eq(issues.id, issueId)).limit(1);
503
511
  return row ?? null;
504
512
  },
513
+ lockById: async (issueId) => {
514
+ const [row] = await database.select().from(issues).where(eq(issues.id, issueId)).limit(1).for("update");
515
+ return row ?? null;
516
+ },
505
517
  findInWorkspace: async (workspaceId, issueId) => {
506
518
  const [row] = await database.select().from(issues).where(and(eq(issues.id, issueId), eq(issues.workspaceId, workspaceId))).limit(1);
507
519
  return row ?? null;
@@ -653,6 +665,10 @@ function createStoreOver(database) {
653
665
  fieldChanges: {
654
666
  listByIssue: async (issueId) => (await database.select().from(issueFieldChanges).where(eq(issueFieldChanges.issueId, issueId)).orderBy(asc(issueFieldChanges.createdAt), asc(issueFieldChanges.seq))).map(toIssueFieldChange),
655
667
  listByIssueField: async (issueId, field) => (await database.select().from(issueFieldChanges).where(and(eq(issueFieldChanges.issueId, issueId), eq(issueFieldChanges.field, field))).orderBy(asc(issueFieldChanges.createdAt), asc(issueFieldChanges.seq))).map(toIssueFieldChange),
668
+ listByFieldSince: async (field, query) => query.workspaceIds.length === 0 ? [] : (await database.select({
669
+ ...getTableColumns(issueFieldChanges),
670
+ workspaceId: issues.workspaceId
671
+ }).from(issueFieldChanges).innerJoin(issues, eq(issues.id, issueFieldChanges.issueId)).where(and(eq(issueFieldChanges.field, field), isNotNull(issueFieldChanges.toValue), gte(issueFieldChanges.createdAt, query.since), query.until === void 0 ? void 0 : lte(issueFieldChanges.createdAt, query.until), inArray(issues.workspaceId, [...query.workspaceIds]))).orderBy(asc(issueFieldChanges.createdAt), asc(issueFieldChanges.id)).limit(query.limit ?? Number.MAX_SAFE_INTEGER)).map(toWorkspaceFieldChange),
656
672
  create: async (values) => {
657
673
  await database.insert(issueFieldChanges).values(values);
658
674
  }