even-keel 0.2.2-rc.1 → 0.2.3
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/CHANGELOG.md +35 -0
- package/dist/src/chain/dispatcher.js +6 -0
- package/dist/src/claude/calls.js +38 -0
- package/dist/src/claude/cli.js +15 -10
- package/dist/src/git/worktree.js +12 -0
- package/dist/src/service/chain.js +67 -18
- package/dist/src/service.js +1 -1
- package/dist/src/sessions/lingering.js +34 -8
- package/package.json +1 -1
- package/plugins/gitlab/.claude-plugin/plugin.json +1 -1
- package/plugins/gitlab/skills/task/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,41 @@ All notable changes to Even Keel are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.2.3] - 2026-11-07
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- The GitLab plugin's `gitlab:task` skill loads again: its description is quoted, so the skill's frontmatter parses and chain sessions on GitLab projects get the skill (plugin 0.1.3).
|
|
12
|
+
- Right after a service restart a Claude chain no longer pauses on `agents --json --all timed out`. The session listing the chain waits on goes ahead of the account's other short calls and is tried again for up to five minutes.
|
|
13
|
+
- A cleanup after Done whose session stop timed out the same way tries the stop again and then removes the task's worktree folder, instead of warning that the session and the folder were left behind.
|
|
14
|
+
|
|
15
|
+
## [0.2.2] - 2026-11-06
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- A done task's time is written to GitLab and Jira as it is to Huly. Sometimes Jira refuses the worklog for a reason that is not about a field, for example when the project does not take time. That is now read as a refusal by the project.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- **Claude folder trust is written by Even Keel before every background session**, with the project's consent in the wizard, instead of a switch and a command to run by hand. If the write or the CLI still refuses, the pause shows one command to run, for the right CLI, account folder and user. On Windows under a service account it shows a `runas` line with a ready script.
|
|
24
|
+
- Checked CLI versions: Claude Code 2.1.319, codex-cli 0.167.0, OpenCode 1.19.5 and Copilot CLI 1.0.106.
|
|
25
|
+
- Pull request mode is no longer marked experimental.
|
|
26
|
+
- Setting up the Claude plugin marketplace by hand has moved to Accounts.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- Claude trust is written under the path the CLI checks. That is a forward-slash key on Windows and the real path of a symlinked folder or a Windows junction, so such folders no longer pause on "Workspace not trusted". The write keeps the account's `.claude.json` permissions (600 stays 600).
|
|
31
|
+
- Copilot: sign-in is checked in the session's own account folder, an unknown sign-in is shown as unknown, and a terminal login's token is kept apart from the accounts' own. Protection also catches a Copilot force push to the main branch written as a refspec.
|
|
32
|
+
- A fix session that finds nothing to fix ends with `NO CHANGES`.
|
|
33
|
+
- A chat reply sent to a session no longer repeats the session's instructions.
|
|
34
|
+
- Windows: environment variables such as `%USERPROFILE%` in a project's folder are expanded.
|
|
35
|
+
- Windows: uninstalling and installing over a running tray host no longer fails while the quitting host still holds its exe.
|
|
36
|
+
- Session account pills show the account of the session's own agent.
|
|
37
|
+
- New rows in settings tables are kept when switching tabs.
|
|
38
|
+
- Tips close when the page scrolls or the window is resized.
|
|
39
|
+
- The answer card's caret points at the question's first line.
|
|
40
|
+
- Download size estimates of the checked CLI copies are up to date.
|
|
41
|
+
|
|
7
42
|
## [0.2.1] - 2026-11-04
|
|
8
43
|
|
|
9
44
|
### Fixed
|
|
@@ -366,6 +366,12 @@ export class Dispatcher {
|
|
|
366
366
|
this.deps.save(this.state);
|
|
367
367
|
return true;
|
|
368
368
|
}
|
|
369
|
+
/** A warning about a finished task's cleanup that came after the cleanup itself: a stop tried again in vain (EKR-99). */
|
|
370
|
+
leftover(project, task, warning) {
|
|
371
|
+
const leftovers = (this.state.leftovers[project] ??= []);
|
|
372
|
+
leftovers.push({ task, at: this.deps.now().toISOString(), notice: warning });
|
|
373
|
+
this.deps.save(this.state);
|
|
374
|
+
}
|
|
369
375
|
dismiss(project, task) {
|
|
370
376
|
const leftovers = this.state.leftovers[project];
|
|
371
377
|
if (leftovers === undefined || !leftovers.some((each) => each.task === task))
|
package/dist/src/claude/calls.js
CHANGED
|
@@ -9,6 +9,44 @@ export class CallTimeout extends Error {
|
|
|
9
9
|
this.name = 'CallTimeout';
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
/** A `CallTimeout`, as it is or under the `cause` of an error that wraps it. */
|
|
13
|
+
export function isCallTimeout(error) {
|
|
14
|
+
for (let each = error; each instanceof Error; each = each.cause)
|
|
15
|
+
if (each instanceof CallTimeout)
|
|
16
|
+
return true;
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A wait of the chain's own made of folder calls: `claude agents` polled until a launched session shows or a stopped one
|
|
21
|
+
* goes (EKR-102). Right after the service's start the folder's queue is full of `/context` probes, and a call whose
|
|
22
|
+
* timeout passes there never starts: such a call is tried again and does not use up the wait, which grows by the time
|
|
23
|
+
* the call lost, up to `patienceMs` from the start — the longest a running call may hold the folder.
|
|
24
|
+
*/
|
|
25
|
+
export class QueueWait {
|
|
26
|
+
deadline;
|
|
27
|
+
patience;
|
|
28
|
+
constructor(waitMs, patienceMs = KILL_AFTER_MS) {
|
|
29
|
+
const now = Date.now();
|
|
30
|
+
this.deadline = now + waitMs;
|
|
31
|
+
this.patience = now + patienceMs;
|
|
32
|
+
}
|
|
33
|
+
get open() {
|
|
34
|
+
return Date.now() < this.deadline;
|
|
35
|
+
}
|
|
36
|
+
async call(call) {
|
|
37
|
+
for (;;) {
|
|
38
|
+
const asked = Date.now();
|
|
39
|
+
try {
|
|
40
|
+
return await call();
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (!(error instanceof CallTimeout) || Date.now() >= this.patience)
|
|
44
|
+
throw error;
|
|
45
|
+
this.deadline = Math.min(this.patience, this.deadline + Date.now() - asked);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
12
50
|
/**
|
|
13
51
|
* The short CLI calls of one account folder, one at a time (EKR-15). Any call may renew the folder's sign-in, and a
|
|
14
52
|
* renewed refresh token is single-use: a call killed after sending the renewal and before writing the answer leaves
|
package/dist/src/claude/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ import { fail, notice, NoticeError } from '../notice/notice.js';
|
|
|
12
12
|
import { binaryPath, samePath } from '../paths.js';
|
|
13
13
|
import { blockedAsk, blockedOn, launchedModel, launchedSettings, parseAgents, parseSessionRecord, withLiveRecords } from '../sessions/agents.js';
|
|
14
14
|
import { newestExtensionBinary } from '../sessions/paths.js';
|
|
15
|
-
import { CallTimeout, FolderCalls } from './calls.js';
|
|
15
|
+
import { CallTimeout, FolderCalls, QueueWait } from './calls.js';
|
|
16
16
|
import { contextArgs } from './context.js';
|
|
17
17
|
import { daemonVersionOf, noDaemonIn } from './release.js';
|
|
18
18
|
import { descendantsOf, killLeftovers, sessionProcessAlive } from './tree.js';
|
|
@@ -68,10 +68,15 @@ export class ClaudeCli {
|
|
|
68
68
|
this.envOf = envOf;
|
|
69
69
|
this.calls = calls;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
/** `priority` — a listing the chain waits on (a launch, a resume, a stop) goes ahead of the folder's waiting calls. */
|
|
72
|
+
async agents(home, priority = false) {
|
|
73
|
+
const { stdout } = await this.call(home, ['agents', '--json', '--all'], undefined, 16 * 1024 * 1024, this.timeoutMs, priority);
|
|
73
74
|
return withJobFiles(home, withLiveRecords(parseAgents(stdout, home.key), await liveRecords(home)));
|
|
74
75
|
}
|
|
76
|
+
/** The chain's own listing within `wait`: ahead of the waiting calls, and tried again after a timeout in the queue. */
|
|
77
|
+
listIn(home, wait) {
|
|
78
|
+
return wait.call(() => this.agents(home, true));
|
|
79
|
+
}
|
|
75
80
|
/** `claude --version`: `2.1.303 (Claude Code)`. */
|
|
76
81
|
async version(env, binary = this.bin()) {
|
|
77
82
|
return (await run(binary, ['--version'], { env, timeout: this.timeoutMs, windowsHide: true })).stdout;
|
|
@@ -143,7 +148,7 @@ export class ClaudeCli {
|
|
|
143
148
|
* keeps its `ParentProcessId` there, while `ps` is taken first, before orphans are reparented.
|
|
144
149
|
*/
|
|
145
150
|
async stop(home, agentId, sessionId) {
|
|
146
|
-
const running = (await this.
|
|
151
|
+
const running = (await this.listIn(home, new QueueWait(0))).find((entry) => entry.sessionId === sessionId);
|
|
147
152
|
if (running === undefined || isGone(running))
|
|
148
153
|
return;
|
|
149
154
|
if (running.pid !== undefined && !(await sessionProcessAlive(running.pid, running.processStartedAt, true)))
|
|
@@ -157,13 +162,13 @@ export class ClaudeCli {
|
|
|
157
162
|
catch (error) {
|
|
158
163
|
throw fail('claude.stopFailed', { agent: agentId }, { detail: outputOf(error) }, { cause: error });
|
|
159
164
|
}
|
|
160
|
-
const
|
|
161
|
-
while (
|
|
165
|
+
const wait = new QueueWait(APPEAR_TIMEOUT_MS);
|
|
166
|
+
while (wait.open) {
|
|
162
167
|
if (await sessionProcessAlive(running.pid, running.processStartedAt)) {
|
|
163
168
|
await delay(EXIT_POLL_MS);
|
|
164
169
|
continue;
|
|
165
170
|
}
|
|
166
|
-
if (isGone((await this.
|
|
171
|
+
if (isGone((await this.listIn(home, wait)).find((entry) => entry.sessionId === sessionId))) {
|
|
167
172
|
await killLeftovers(await children);
|
|
168
173
|
return;
|
|
169
174
|
}
|
|
@@ -209,9 +214,9 @@ export class ClaudeCli {
|
|
|
209
214
|
}
|
|
210
215
|
}
|
|
211
216
|
async appear(home, match, failure) {
|
|
212
|
-
const
|
|
213
|
-
while (
|
|
214
|
-
const found = (await this.
|
|
217
|
+
const wait = new QueueWait(APPEAR_TIMEOUT_MS);
|
|
218
|
+
while (wait.open) {
|
|
219
|
+
const found = (await this.listIn(home, wait)).find(match);
|
|
215
220
|
if (found !== undefined)
|
|
216
221
|
return found;
|
|
217
222
|
await delay(APPEAR_POLL_MS);
|
package/dist/src/git/worktree.js
CHANGED
|
@@ -140,6 +140,18 @@ async function deleteLeftFolder(path, gitOut) {
|
|
|
140
140
|
return leftBehind(path, `${gitOut}\n${error instanceof Error ? error.message : String(error)}`);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
+
/** A second try at a folder a cleanup left (EKR-99), once the session that held it is stopped; one registered again since is not touched. */
|
|
144
|
+
export async function removeLeftFolder(git, repo, path) {
|
|
145
|
+
try {
|
|
146
|
+
if ((await worktreeAt(git, repo, path)) !== undefined)
|
|
147
|
+
return null;
|
|
148
|
+
await rm(path, { recursive: true, force: true });
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
return leftBehind(path, error instanceof Error ? error.message : String(error));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
143
155
|
/**
|
|
144
156
|
* `git worktree remove` on Windows follows junctions: it empties a linked folder outside the worktree
|
|
145
157
|
* (`npm link`) and stops at a dangling one (an npm workspace link whose package it already deleted),
|
|
@@ -25,7 +25,8 @@ import { DEFAULT_BRANCH, DEFAULT_CI, mergeTargetOf, projectLabel } from '../conf
|
|
|
25
25
|
import { runGit } from '../git/run.js';
|
|
26
26
|
import { finishSlot, heldSlot, prepareSlot, slotPaths } from '../git/slot.js';
|
|
27
27
|
import { fastForwardMain, syncMain } from '../git/sync.js';
|
|
28
|
-
import { ensureIgnored, finishWorktree, prepareWorktree, requireBranch, requireCheckedOut, taskPlace } from '../git/worktree.js';
|
|
28
|
+
import { ensureIgnored, finishWorktree, prepareWorktree, removeLeftFolder, requireBranch, requireCheckedOut, taskPlace } from '../git/worktree.js';
|
|
29
|
+
import { isCallTimeout } from '../claude/calls.js';
|
|
29
30
|
import { exhaustedReset, limitReopenedAt } from '../limits/model.js';
|
|
30
31
|
import { overageSession } from '../limits/overage-session.js';
|
|
31
32
|
import { englishOf, fail, notice, noticeOf } from '../notice/notice.js';
|
|
@@ -342,7 +343,7 @@ export async function wireDispatcher(ctx) {
|
|
|
342
343
|
let stopped;
|
|
343
344
|
let finished;
|
|
344
345
|
try {
|
|
345
|
-
stopped = await ctx.stopTaskSessions(repo, task, Math.max(span, 1));
|
|
346
|
+
stopped = await ctx.stopTaskSessions(project, repo, task, Math.max(span, 1));
|
|
346
347
|
const main = ctx.branchOf(project);
|
|
347
348
|
const drop = pull === undefined ? {} : { force: pull.force, remote: pull.remote };
|
|
348
349
|
finished = await (span > 0 ? finishSlot(runGit, repo, task, span, main, drop) : finishWorktree(runGit, repo, task, main, drop));
|
|
@@ -352,7 +353,8 @@ export async function wireDispatcher(ctx) {
|
|
|
352
353
|
throw error;
|
|
353
354
|
}
|
|
354
355
|
ctx.packages.release(project, task);
|
|
355
|
-
const
|
|
356
|
+
const left = stopped.retrying ? deferLeftFolder(ctx, project, repo, task, finished.warnings) : finished.warnings;
|
|
357
|
+
const outcome = { ...finished, warnings: [...stopped.warnings, ...left] };
|
|
356
358
|
for (const warning of outcome.warnings)
|
|
357
359
|
console.warn(`git: ${task}: ${englishOf(warning)}`);
|
|
358
360
|
if (outcome.syncError !== null)
|
|
@@ -544,14 +546,21 @@ export async function vacateSlot(ctx, slot, task) {
|
|
|
544
546
|
console.log(`slot: stopped the session ${agent.sessionId} of ${owner} before ${task} took ${slot}`);
|
|
545
547
|
}
|
|
546
548
|
}
|
|
547
|
-
/**
|
|
548
|
-
export
|
|
549
|
+
/** How long a cleanup after Done keeps trying a stop that timed out in the folder's queue before it warns (EKR-99). */
|
|
550
|
+
export const STOP_RETRY_MS = 5 * 60_000;
|
|
551
|
+
/**
|
|
552
|
+
* Stops the task's sessions that are not mid-turn; the rest are kept in `lingering`, to be stopped once their turn ends
|
|
553
|
+
* (BTN-616). A stop that timed out waiting for the account folder's queue is kept too, to be tried again (EKR-99):
|
|
554
|
+
* `retrying` says so, and the cleanup then leaves the worktree folder the session holds to `deferLeftFolder`.
|
|
555
|
+
*/
|
|
556
|
+
export async function stopTaskSessions(ctx, project, repo, task, count) {
|
|
549
557
|
const own = new Set(ctx.launches.filter((entry) => entry.task === task).map((entry) => entry.sessionId));
|
|
550
558
|
const slots = slotPaths(repo, count);
|
|
551
559
|
const sessions = ctx.agents.filter((agent) => agent.id !== undefined &&
|
|
552
560
|
isLive(agent) &&
|
|
553
561
|
(isInside(agent.cwd, taskPlace(repo, task).path) || (slots.some((slot) => isInside(agent.cwd, slot)) && own.has(agent.sessionId))));
|
|
554
562
|
const warnings = [];
|
|
563
|
+
let retrying = false;
|
|
555
564
|
for (const agent of sessions) {
|
|
556
565
|
if (midTurn(agent)) {
|
|
557
566
|
ctx.lingering.keep(task, agent.sessionId);
|
|
@@ -562,24 +571,64 @@ export async function stopTaskSessions(ctx, repo, task, count) {
|
|
|
562
571
|
await ctx.stopIn(ctx.homeOf(agent.account ?? 'global'), { agentId: agent.id, sessionId: agent.sessionId });
|
|
563
572
|
}
|
|
564
573
|
catch (error) {
|
|
565
|
-
|
|
574
|
+
if (!isCallTimeout(error)) {
|
|
575
|
+
warnings.push(notice('cleanup.sessionNotStopped', { session: agent.sessionId }, { cause: noticeOf(error) }));
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
ctx.lingering.keep(task, agent.sessionId, { project, until: Date.now() + STOP_RETRY_MS });
|
|
579
|
+
retrying = true;
|
|
580
|
+
console.log(`cleanup: the stop of the session ${agent.sessionId} of ${task} timed out, it will be tried again: ${englishOf(noticeOf(error))}`);
|
|
566
581
|
}
|
|
567
582
|
}
|
|
568
|
-
return warnings;
|
|
583
|
+
return { warnings, retrying };
|
|
569
584
|
}
|
|
570
|
-
/**
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
585
|
+
/**
|
|
586
|
+
* The cleanup's warnings without the worktree folder a session whose stop is tried again still holds (EKR-99): the
|
|
587
|
+
* folder is removed once the session is stopped, and warned about only if that fails too.
|
|
588
|
+
*/
|
|
589
|
+
export function deferLeftFolder(ctx, project, repo, task, warnings) {
|
|
590
|
+
return warnings.filter((warning) => {
|
|
591
|
+
if (warning.code !== 'cleanup.folderLeft')
|
|
592
|
+
return true;
|
|
593
|
+
ctx.lingering.leave({ project, task, repo, path: warning.params.path, until: Date.now() + STOP_RETRY_MS });
|
|
594
|
+
console.log(`cleanup: the worktree folder ${warning.params.path} of ${task} is held, it will be removed once its session is stopped`);
|
|
595
|
+
return false;
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Stops the sessions a cleanup after Done left mid-turn whose turn has ended since, tries again the stops that timed
|
|
600
|
+
* out, and removes the folders they held (`stopTaskSessions`). What still fails once the wait is over is warned about
|
|
601
|
+
* on the task, as the cleanup itself would have.
|
|
602
|
+
*/
|
|
603
|
+
export function stopLingering(ctx, git = runGit) {
|
|
604
|
+
return ctx.lingering.alone(async () => {
|
|
605
|
+
for (const { task, agent, retry } of ctx.lingering.due(ctx.agents, midTurn)) {
|
|
606
|
+
if (agent.id === undefined)
|
|
607
|
+
continue;
|
|
608
|
+
try {
|
|
609
|
+
await ctx.stopIn(ctx.homeOf(agent.account ?? 'global'), { agentId: agent.id, sessionId: agent.sessionId });
|
|
610
|
+
console.log(`cleanup: stopped the session ${agent.sessionId} of ${task}, ${retry === undefined ? 'its turn after Done ended' : 'its stop tried again'}`);
|
|
611
|
+
}
|
|
612
|
+
catch (error) {
|
|
613
|
+
if (retry !== undefined && isCallTimeout(error) && Date.now() < retry.until) {
|
|
614
|
+
ctx.lingering.keep(task, agent.sessionId, retry);
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
console.warn(`cleanup: the session ${agent.sessionId} of ${task} was not stopped: ${englishOf(noticeOf(error))}`);
|
|
618
|
+
if (retry !== undefined)
|
|
619
|
+
ctx.dispatcher.leftover(retry.project, task, notice('cleanup.sessionNotStopped', { session: agent.sessionId }, { cause: noticeOf(error) }));
|
|
620
|
+
}
|
|
578
621
|
}
|
|
579
|
-
|
|
580
|
-
|
|
622
|
+
for (const folder of ctx.lingering.dueFolders(Date.now())) {
|
|
623
|
+
const left = await removeLeftFolder(git, folder.repo, folder.path);
|
|
624
|
+
if (left === null) {
|
|
625
|
+
console.log(`cleanup: removed the worktree folder ${folder.path} of ${folder.task} once its session was stopped`);
|
|
626
|
+
continue;
|
|
627
|
+
}
|
|
628
|
+
console.warn(`git: ${folder.task}: ${englishOf(left)}`);
|
|
629
|
+
ctx.dispatcher.leftover(folder.project, folder.task, left);
|
|
581
630
|
}
|
|
582
|
-
}
|
|
631
|
+
});
|
|
583
632
|
}
|
|
584
633
|
function midTurn(agent) {
|
|
585
634
|
return agent.status === 'busy' || agent.status === 'waiting';
|
package/dist/src/service.js
CHANGED
|
@@ -621,7 +621,7 @@ const { mailRelay, answerSession } = createChat({
|
|
|
621
621
|
function occupantsOf(slot, task) { return chainService.occupantsOf(context, slot, task); }
|
|
622
622
|
function slotUse(slot, task) { return chainService.slotUse(context, slot, task); }
|
|
623
623
|
function vacateSlot(slot, task) { return chainService.vacateSlot(context, slot, task); }
|
|
624
|
-
function stopTaskSessions(repo, task, count) { return chainService.stopTaskSessions(context, repo, task, count); }
|
|
624
|
+
function stopTaskSessions(project, repo, task, count) { return chainService.stopTaskSessions(context, project, repo, task, count); }
|
|
625
625
|
function stopLingering() { return chainService.stopLingering(context); }
|
|
626
626
|
/** What holds a project the page asks to remove: its chain, live sessions of its tasks or in its folders, the places it keeps. */
|
|
627
627
|
function removalFacts(project, repo) { return chainService.removalFacts(context, project, repo); }
|
|
@@ -1,26 +1,52 @@
|
|
|
1
1
|
import { isLive } from './agents.js';
|
|
2
2
|
/**
|
|
3
|
-
* The sessions a cleanup after Done
|
|
4
|
-
* has left the chain, and a Codex session would rest as `waiting` for good. Each is
|
|
5
|
-
* (exception 4 of invariant 1)
|
|
3
|
+
* The sessions a cleanup after Done left running (BTN-616): found mid-turn, or whose stop timed out (EKR-99). Nothing
|
|
4
|
+
* else stops them once their task has left the chain, and a Codex session would rest as `waiting` for good. Each is
|
|
5
|
+
* stopped once its turn ends (exception 4 of invariant 1), and the worktree folder it held is removed after it. In
|
|
6
|
+
* memory: a restart loses them, as it loses the cleanup that kept them.
|
|
6
7
|
*/
|
|
7
8
|
export class Lingering {
|
|
8
|
-
/** By session id
|
|
9
|
+
/** By session id. */
|
|
9
10
|
sessions = new Map();
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
folders = new Map();
|
|
12
|
+
running = false;
|
|
13
|
+
keep(task, sessionId, retry) {
|
|
14
|
+
this.sessions.set(sessionId, retry === undefined ? { task } : { task, retry });
|
|
15
|
+
}
|
|
16
|
+
leave(folder) {
|
|
17
|
+
this.folders.set(folder.path, folder);
|
|
12
18
|
}
|
|
13
19
|
/** The kept sessions whose turn has ended, to stop now, forgotten as they are given; a session gone meanwhile is forgotten too. */
|
|
14
20
|
due(agents, busy) {
|
|
15
21
|
const due = [];
|
|
16
|
-
for (const [sessionId, task] of this.sessions) {
|
|
22
|
+
for (const [sessionId, { task, retry }] of this.sessions) {
|
|
17
23
|
const agent = agents.find((each) => each.sessionId === sessionId);
|
|
18
24
|
if (agent !== undefined && isLive(agent) && busy(agent))
|
|
19
25
|
continue;
|
|
20
26
|
this.sessions.delete(sessionId);
|
|
21
27
|
if (agent !== undefined && isLive(agent))
|
|
22
|
-
due.push({ task, agent });
|
|
28
|
+
due.push(retry === undefined ? { task, agent } : { task, agent, retry });
|
|
23
29
|
}
|
|
24
30
|
return due;
|
|
25
31
|
}
|
|
32
|
+
/** The left folders to remove now, forgotten as they are given: no session of their task is kept any more, or their wait is over. */
|
|
33
|
+
dueFolders(now) {
|
|
34
|
+
const held = new Set([...this.sessions.values()].map((kept) => kept.task));
|
|
35
|
+
const due = [...this.folders.values()].filter((folder) => !held.has(folder.task) || now >= folder.until);
|
|
36
|
+
for (const folder of due)
|
|
37
|
+
this.folders.delete(folder.path);
|
|
38
|
+
return due;
|
|
39
|
+
}
|
|
40
|
+
/** Runs `work` unless the previous run is under way: otherwise a tick would remove a folder while the previous one still stops its session. */
|
|
41
|
+
async alone(work) {
|
|
42
|
+
if (this.running)
|
|
43
|
+
return;
|
|
44
|
+
this.running = true;
|
|
45
|
+
try {
|
|
46
|
+
await work();
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
this.running = false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
26
52
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitlab",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "GitLab Issues for Even Keel sessions: a PAT-capable MCP server for gitlab.com or a self-managed instance, and the task skill.",
|
|
5
5
|
"author": { "name": "Even Keel" },
|
|
6
6
|
"keywords": ["gitlab", "issues", "tracker", "even-keel", "mcp"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: task
|
|
3
|
-
description: Work a GitLab issue through the gitlab MCP server: read the brief, record decisions, file blockers and questions, leave a closing comment and merge into the project's main branch. Use for task ids such as APP-12 in projects tracked in GitLab Issues, or before creating an issue there.
|
|
3
|
+
description: "Work a GitLab issue through the gitlab MCP server: read the brief, record decisions, file blockers and questions, leave a closing comment and merge into the project's main branch. Use for task ids such as APP-12 in projects tracked in GitLab Issues, or before creating an issue there."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Working a GitLab issue
|