agent-board-runner 0.1.16 → 0.1.17
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/dist/cli.js +59 -3
- package/dist/index.js +59 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -897,12 +897,37 @@ async function getRunningSessionForProject(supabase, projectId, runnerId) {
|
|
|
897
897
|
const row = data;
|
|
898
898
|
return { id: row.id, cardId: row.card_id, agentState: row.agent_state };
|
|
899
899
|
}
|
|
900
|
+
function compareQueueOrder(a, b) {
|
|
901
|
+
const orderA = a.cards.dev_queue_order;
|
|
902
|
+
const orderB = b.cards.dev_queue_order;
|
|
903
|
+
if (orderA !== null && orderB !== null) return orderA - orderB;
|
|
904
|
+
if (orderA !== null) return -1;
|
|
905
|
+
if (orderB !== null) return 1;
|
|
906
|
+
return new Date(a.created_at).getTime() - new Date(b.created_at).getTime();
|
|
907
|
+
}
|
|
908
|
+
function applyDevQueueOrder(queued) {
|
|
909
|
+
const byProject = /* @__PURE__ */ new Map();
|
|
910
|
+
for (const entry of queued) {
|
|
911
|
+
const list = byProject.get(entry.cards.project_id) ?? [];
|
|
912
|
+
list.push(entry);
|
|
913
|
+
byProject.set(entry.cards.project_id, list);
|
|
914
|
+
}
|
|
915
|
+
for (const entries of byProject.values()) entries.sort(compareQueueOrder);
|
|
916
|
+
const seenProjects = /* @__PURE__ */ new Set();
|
|
917
|
+
const result = [];
|
|
918
|
+
for (const entry of queued) {
|
|
919
|
+
if (seenProjects.has(entry.cards.project_id)) continue;
|
|
920
|
+
seenProjects.add(entry.cards.project_id);
|
|
921
|
+
result.push(...byProject.get(entry.cards.project_id));
|
|
922
|
+
}
|
|
923
|
+
return result;
|
|
924
|
+
}
|
|
900
925
|
async function listQueuedSessionsForRunner(supabase, runnerId) {
|
|
901
926
|
const { data, error } = await supabase.from("sessions").select(
|
|
902
|
-
"id, card_id, claude_session_id, agent_state, created_at, cards!card_id!inner(project_id, title, instructions, file_references, plan_first, prerequisite_card_id, prototype_first, prototype_url, prototype_approved)"
|
|
927
|
+
"id, card_id, claude_session_id, agent_state, created_at, cards!card_id!inner(project_id, title, instructions, file_references, plan_first, prerequisite_card_id, prototype_first, prototype_url, prototype_approved, dev_queue_order)"
|
|
903
928
|
).eq("runner_id", runnerId).eq("status", "queued").order("created_at", { ascending: true });
|
|
904
929
|
if (error) throw error;
|
|
905
|
-
return data;
|
|
930
|
+
return applyDevQueueOrder(data);
|
|
906
931
|
}
|
|
907
932
|
async function listPausedSessionsForRunner(supabase, runnerId) {
|
|
908
933
|
const { data, error } = await supabase.from("sessions").select("card_id, cards!card_id!inner(project_id)").eq("runner_id", runnerId).eq("status", "paused");
|
|
@@ -1010,7 +1035,8 @@ async function updateCard(supabase, cardId, changes) {
|
|
|
1010
1035
|
...changes.customActionStatus !== void 0 ? { custom_action_status: changes.customActionStatus } : {},
|
|
1011
1036
|
...changes.customActionOutput !== void 0 ? { custom_action_output: changes.customActionOutput } : {},
|
|
1012
1037
|
...changes.requeueRequestedAt !== void 0 ? { requeue_requested_at: changes.requeueRequestedAt } : {},
|
|
1013
|
-
...changes.restartRequestedAt !== void 0 ? { restart_requested_at: changes.restartRequestedAt } : {}
|
|
1038
|
+
...changes.restartRequestedAt !== void 0 ? { restart_requested_at: changes.restartRequestedAt } : {},
|
|
1039
|
+
...changes.returnToBacklogRequestedAt !== void 0 ? { return_to_backlog_requested_at: changes.returnToBacklogRequestedAt } : {}
|
|
1014
1040
|
}).eq("id", cardId);
|
|
1015
1041
|
if (error) throw error;
|
|
1016
1042
|
}
|
|
@@ -3413,6 +3439,24 @@ async function restartCardSession(supabase, config, card) {
|
|
|
3413
3439
|
await updateCard(supabase, card.id, { restartRequestedAt: null });
|
|
3414
3440
|
await enqueueCard(supabase, config, card);
|
|
3415
3441
|
}
|
|
3442
|
+
async function returnCardToBacklog(supabase, config, card) {
|
|
3443
|
+
const sessionId = activeSessionByCard.get(card.id) ?? (await getActiveSessionForCard(supabase, card.id))?.id;
|
|
3444
|
+
if (sessionId) {
|
|
3445
|
+
intentionallyStoppedSessionIds.add(sessionId);
|
|
3446
|
+
stopPtySession(sessionId);
|
|
3447
|
+
cancelUsageResume(sessionId);
|
|
3448
|
+
activeSessionByCard.delete(card.id);
|
|
3449
|
+
await updateSession(
|
|
3450
|
+
supabase,
|
|
3451
|
+
sessionId,
|
|
3452
|
+
{ status: "done", endedAt: (/* @__PURE__ */ new Date()).toISOString() },
|
|
3453
|
+
{ projectId: card.project_id, cardId: card.id, userId: config.ownerUserId }
|
|
3454
|
+
);
|
|
3455
|
+
logger.card.info(card.id, `Session ${sessionId} stopped by "voltar ao backlog".`);
|
|
3456
|
+
}
|
|
3457
|
+
await updateCard(supabase, card.id, { column: "backlog", returnToBacklogRequestedAt: null });
|
|
3458
|
+
await dispatchRunnerQueue(supabase, config);
|
|
3459
|
+
}
|
|
3416
3460
|
|
|
3417
3461
|
// src/columnActions.ts
|
|
3418
3462
|
var execAsync = promisify5(exec);
|
|
@@ -4206,6 +4250,8 @@ async function startRunner() {
|
|
|
4206
4250
|
const lastKnownColumn = /* @__PURE__ */ new Map();
|
|
4207
4251
|
const lastKnownRequeueRequestedAt = /* @__PURE__ */ new Map();
|
|
4208
4252
|
const lastKnownRestartRequestedAt = /* @__PURE__ */ new Map();
|
|
4253
|
+
const lastKnownDevQueueOrder = /* @__PURE__ */ new Map();
|
|
4254
|
+
const lastKnownReturnToBacklogRequestedAt = /* @__PURE__ */ new Map();
|
|
4209
4255
|
await syncRegisteredProjects(supabase, config, registeredPaths).catch((err) => logger.runner.error("PROJECT_SYNC", "syncRegisteredProjects failed:", err));
|
|
4210
4256
|
logger.runner.info("BOOT", `Agent Board runner "${config.runnerName}" starting (${registeredPaths.size} project(s) registered).`);
|
|
4211
4257
|
for (const project of config.registeredProjects) {
|
|
@@ -4311,6 +4357,16 @@ async function startRunner() {
|
|
|
4311
4357
|
if (card.restart_requested_at && card.restart_requested_at !== previousRestartRequestedAt) {
|
|
4312
4358
|
void restartCardSession(supabase, config, card);
|
|
4313
4359
|
}
|
|
4360
|
+
const previousReturnToBacklogRequestedAt = lastKnownReturnToBacklogRequestedAt.get(card.id);
|
|
4361
|
+
lastKnownReturnToBacklogRequestedAt.set(card.id, card.return_to_backlog_requested_at);
|
|
4362
|
+
if (card.return_to_backlog_requested_at && card.return_to_backlog_requested_at !== previousReturnToBacklogRequestedAt) {
|
|
4363
|
+
void returnCardToBacklog(supabase, config, card);
|
|
4364
|
+
}
|
|
4365
|
+
const previousDevQueueOrder = lastKnownDevQueueOrder.get(card.id);
|
|
4366
|
+
lastKnownDevQueueOrder.set(card.id, card.dev_queue_order);
|
|
4367
|
+
if (card.column_name === "desenvolvimento" && card.dev_queue_order !== previousDevQueueOrder) {
|
|
4368
|
+
void dispatchRunnerQueue(supabase, config);
|
|
4369
|
+
}
|
|
4314
4370
|
if (previousColumn !== void 0 && previousColumn !== card.column_name) {
|
|
4315
4371
|
void clearColumnActionStatus(supabase, card);
|
|
4316
4372
|
void handleColumnEntered(supabase, config, card);
|
package/dist/index.js
CHANGED
|
@@ -617,12 +617,37 @@ async function getRunningSessionForProject(supabase, projectId, runnerId) {
|
|
|
617
617
|
const row = data;
|
|
618
618
|
return { id: row.id, cardId: row.card_id, agentState: row.agent_state };
|
|
619
619
|
}
|
|
620
|
+
function compareQueueOrder(a, b) {
|
|
621
|
+
const orderA = a.cards.dev_queue_order;
|
|
622
|
+
const orderB = b.cards.dev_queue_order;
|
|
623
|
+
if (orderA !== null && orderB !== null) return orderA - orderB;
|
|
624
|
+
if (orderA !== null) return -1;
|
|
625
|
+
if (orderB !== null) return 1;
|
|
626
|
+
return new Date(a.created_at).getTime() - new Date(b.created_at).getTime();
|
|
627
|
+
}
|
|
628
|
+
function applyDevQueueOrder(queued) {
|
|
629
|
+
const byProject = /* @__PURE__ */ new Map();
|
|
630
|
+
for (const entry of queued) {
|
|
631
|
+
const list = byProject.get(entry.cards.project_id) ?? [];
|
|
632
|
+
list.push(entry);
|
|
633
|
+
byProject.set(entry.cards.project_id, list);
|
|
634
|
+
}
|
|
635
|
+
for (const entries of byProject.values()) entries.sort(compareQueueOrder);
|
|
636
|
+
const seenProjects = /* @__PURE__ */ new Set();
|
|
637
|
+
const result = [];
|
|
638
|
+
for (const entry of queued) {
|
|
639
|
+
if (seenProjects.has(entry.cards.project_id)) continue;
|
|
640
|
+
seenProjects.add(entry.cards.project_id);
|
|
641
|
+
result.push(...byProject.get(entry.cards.project_id));
|
|
642
|
+
}
|
|
643
|
+
return result;
|
|
644
|
+
}
|
|
620
645
|
async function listQueuedSessionsForRunner(supabase, runnerId) {
|
|
621
646
|
const { data, error } = await supabase.from("sessions").select(
|
|
622
|
-
"id, card_id, claude_session_id, agent_state, created_at, cards!card_id!inner(project_id, title, instructions, file_references, plan_first, prerequisite_card_id, prototype_first, prototype_url, prototype_approved)"
|
|
647
|
+
"id, card_id, claude_session_id, agent_state, created_at, cards!card_id!inner(project_id, title, instructions, file_references, plan_first, prerequisite_card_id, prototype_first, prototype_url, prototype_approved, dev_queue_order)"
|
|
623
648
|
).eq("runner_id", runnerId).eq("status", "queued").order("created_at", { ascending: true });
|
|
624
649
|
if (error) throw error;
|
|
625
|
-
return data;
|
|
650
|
+
return applyDevQueueOrder(data);
|
|
626
651
|
}
|
|
627
652
|
async function listPausedSessionsForRunner(supabase, runnerId) {
|
|
628
653
|
const { data, error } = await supabase.from("sessions").select("card_id, cards!card_id!inner(project_id)").eq("runner_id", runnerId).eq("status", "paused");
|
|
@@ -730,7 +755,8 @@ async function updateCard(supabase, cardId, changes) {
|
|
|
730
755
|
...changes.customActionStatus !== void 0 ? { custom_action_status: changes.customActionStatus } : {},
|
|
731
756
|
...changes.customActionOutput !== void 0 ? { custom_action_output: changes.customActionOutput } : {},
|
|
732
757
|
...changes.requeueRequestedAt !== void 0 ? { requeue_requested_at: changes.requeueRequestedAt } : {},
|
|
733
|
-
...changes.restartRequestedAt !== void 0 ? { restart_requested_at: changes.restartRequestedAt } : {}
|
|
758
|
+
...changes.restartRequestedAt !== void 0 ? { restart_requested_at: changes.restartRequestedAt } : {},
|
|
759
|
+
...changes.returnToBacklogRequestedAt !== void 0 ? { return_to_backlog_requested_at: changes.returnToBacklogRequestedAt } : {}
|
|
734
760
|
}).eq("id", cardId);
|
|
735
761
|
if (error) throw error;
|
|
736
762
|
}
|
|
@@ -3301,6 +3327,24 @@ async function restartCardSession(supabase, config, card) {
|
|
|
3301
3327
|
await updateCard(supabase, card.id, { restartRequestedAt: null });
|
|
3302
3328
|
await enqueueCard(supabase, config, card);
|
|
3303
3329
|
}
|
|
3330
|
+
async function returnCardToBacklog(supabase, config, card) {
|
|
3331
|
+
const sessionId = activeSessionByCard.get(card.id) ?? (await getActiveSessionForCard(supabase, card.id))?.id;
|
|
3332
|
+
if (sessionId) {
|
|
3333
|
+
intentionallyStoppedSessionIds.add(sessionId);
|
|
3334
|
+
stopPtySession(sessionId);
|
|
3335
|
+
cancelUsageResume(sessionId);
|
|
3336
|
+
activeSessionByCard.delete(card.id);
|
|
3337
|
+
await updateSession(
|
|
3338
|
+
supabase,
|
|
3339
|
+
sessionId,
|
|
3340
|
+
{ status: "done", endedAt: (/* @__PURE__ */ new Date()).toISOString() },
|
|
3341
|
+
{ projectId: card.project_id, cardId: card.id, userId: config.ownerUserId }
|
|
3342
|
+
);
|
|
3343
|
+
logger.card.info(card.id, `Session ${sessionId} stopped by "voltar ao backlog".`);
|
|
3344
|
+
}
|
|
3345
|
+
await updateCard(supabase, card.id, { column: "backlog", returnToBacklogRequestedAt: null });
|
|
3346
|
+
await dispatchRunnerQueue(supabase, config);
|
|
3347
|
+
}
|
|
3304
3348
|
|
|
3305
3349
|
// src/columnActions.ts
|
|
3306
3350
|
var execAsync = promisify5(exec);
|
|
@@ -4094,6 +4138,8 @@ async function startRunner() {
|
|
|
4094
4138
|
const lastKnownColumn = /* @__PURE__ */ new Map();
|
|
4095
4139
|
const lastKnownRequeueRequestedAt = /* @__PURE__ */ new Map();
|
|
4096
4140
|
const lastKnownRestartRequestedAt = /* @__PURE__ */ new Map();
|
|
4141
|
+
const lastKnownDevQueueOrder = /* @__PURE__ */ new Map();
|
|
4142
|
+
const lastKnownReturnToBacklogRequestedAt = /* @__PURE__ */ new Map();
|
|
4097
4143
|
await syncRegisteredProjects(supabase, config, registeredPaths).catch((err) => logger.runner.error("PROJECT_SYNC", "syncRegisteredProjects failed:", err));
|
|
4098
4144
|
logger.runner.info("BOOT", `Agent Board runner "${config.runnerName}" starting (${registeredPaths.size} project(s) registered).`);
|
|
4099
4145
|
for (const project of config.registeredProjects) {
|
|
@@ -4199,6 +4245,16 @@ async function startRunner() {
|
|
|
4199
4245
|
if (card.restart_requested_at && card.restart_requested_at !== previousRestartRequestedAt) {
|
|
4200
4246
|
void restartCardSession(supabase, config, card);
|
|
4201
4247
|
}
|
|
4248
|
+
const previousReturnToBacklogRequestedAt = lastKnownReturnToBacklogRequestedAt.get(card.id);
|
|
4249
|
+
lastKnownReturnToBacklogRequestedAt.set(card.id, card.return_to_backlog_requested_at);
|
|
4250
|
+
if (card.return_to_backlog_requested_at && card.return_to_backlog_requested_at !== previousReturnToBacklogRequestedAt) {
|
|
4251
|
+
void returnCardToBacklog(supabase, config, card);
|
|
4252
|
+
}
|
|
4253
|
+
const previousDevQueueOrder = lastKnownDevQueueOrder.get(card.id);
|
|
4254
|
+
lastKnownDevQueueOrder.set(card.id, card.dev_queue_order);
|
|
4255
|
+
if (card.column_name === "desenvolvimento" && card.dev_queue_order !== previousDevQueueOrder) {
|
|
4256
|
+
void dispatchRunnerQueue(supabase, config);
|
|
4257
|
+
}
|
|
4202
4258
|
if (previousColumn !== void 0 && previousColumn !== card.column_name) {
|
|
4203
4259
|
void clearColumnActionStatus(supabase, card);
|
|
4204
4260
|
void handleColumnEntered(supabase, config, card);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-board-runner",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "Local runner for Agent Board — signs in with your own Supabase account (no shared secrets) and drives Claude Code against repos under your local repos root.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|