even-keel 0.3.0 → 0.3.1

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 (72) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +1 -1
  3. package/dist/src/agent/scripted.js +32 -3
  4. package/dist/src/chain/conflict.js +41 -0
  5. package/dist/src/chain/forward.js +22 -5
  6. package/dist/src/chain/handover.js +1 -2
  7. package/dist/src/chain/maincheck.js +13 -9
  8. package/dist/src/changelog/drafts.js +4 -3
  9. package/dist/src/changelog/file.js +4 -0
  10. package/dist/src/changelog/limit.js +30 -0
  11. package/dist/src/ci/protection.js +8 -1
  12. package/dist/src/claude/adapter.js +4 -4
  13. package/dist/src/copilot/errors.js +11 -6
  14. package/dist/src/gitlab/adapter.js +1 -0
  15. package/dist/src/limits/chatgpt-seat.js +49 -0
  16. package/dist/src/limits/chatgpt.js +37 -7
  17. package/dist/src/limits/copilot.js +12 -3
  18. package/dist/src/limits/model.js +3 -0
  19. package/dist/src/limits/overage.js +6 -2
  20. package/dist/src/limits/usage.js +42 -4
  21. package/dist/src/limits/watcher.js +1 -1
  22. package/dist/src/notice/en-advice.js +2 -1
  23. package/dist/src/notice/en-values.js +2 -0
  24. package/dist/src/notice/en.js +4 -1
  25. package/dist/src/opencode/adapter.js +1 -1
  26. package/dist/src/opencode/cli.js +10 -2
  27. package/dist/src/packages/service.js +37 -0
  28. package/dist/src/profiles/model.js +1 -0
  29. package/dist/src/profiles/service.js +1 -1
  30. package/dist/src/server.js +1 -0
  31. package/dist/src/service/chain-prompts.js +13 -1
  32. package/dist/src/service/chain.js +17 -12
  33. package/dist/src/service.js +1 -1
  34. package/dist/src/storage/migrations.js +2 -0
  35. package/dist/src/storage/schema.js +1 -1
  36. package/dist/src/tools/panel.js +7 -9
  37. package/dist/src/tools/projectSettings.js +60 -0
  38. package/dist/src/tools/sessionSettings.js +11 -4
  39. package/dist/web/assets/{BadgeDialog-B8RUL_Ow.js → BadgeDialog-D4hwGrta.js} +1 -1
  40. package/dist/web/assets/{DescriptionEditor-DUSwRGCZ.js → DescriptionEditor-ujHSJeis.js} +1 -1
  41. package/dist/web/assets/{ProjectPackages-BJEPijBV.js → ProjectPackages-DMk8vL5N.js} +1 -1
  42. package/dist/web/assets/{Select-NXi_Bsw-.js → Select-BMRSXvrD.js} +1 -1
  43. package/dist/web/assets/{TaskCard-DeP8bF9-.js → TaskCard-DeZtmpq4.js} +2 -2
  44. package/dist/web/assets/TranscriptWindow-DRGnlese.css +1 -0
  45. package/dist/web/assets/{TranscriptWindow-DVoHtE_o.js → TranscriptWindow-hQHw_CQ7.js} +1 -1
  46. package/dist/web/assets/{accountParts-CNUeXPYn.js → accountParts-B-b8vNCY.js} +1 -1
  47. package/dist/web/assets/blocks-BTQTnJ34.js +12 -0
  48. package/dist/web/assets/{cardDrafts-CyzO-ro7.js → cardDrafts-yo2X_Uq1.js} +1 -1
  49. package/dist/web/assets/{cardSide-CSmytank.js → cardSide-Y3dIjNVW.js} +1 -1
  50. package/dist/web/assets/feedLine-BJhjgpoe.js +1 -0
  51. package/dist/web/assets/{hooks-CgKVeUg8.js → hooks-CDqQcVnS.js} +1 -1
  52. package/dist/web/assets/index-B9H7kxbk.js +25 -0
  53. package/dist/web/assets/index-gsaRwWJo.css +1 -0
  54. package/dist/web/assets/{lib-DnFFmOv9.js → lib-DUH5hYcn.js} +1 -1
  55. package/dist/web/assets/overview-BdakxI-5.js +7 -0
  56. package/dist/web/assets/packageGroups-D15r6pKX.js +1 -0
  57. package/dist/web/assets/{react-dom-DiYkIXNS.js → react-dom-CDxcrI4x.js} +1 -1
  58. package/dist/web/assets/{rules-DLe7kZM5.js → rules-CVcjwHXa.js} +1 -1
  59. package/dist/web/assets/{useFileDrop-CEn6qZnh.js → useFileDrop-vzFQ_b-5.js} +1 -1
  60. package/dist/web/assets/{useHeightGlide-BPjzH9PL.js → useHeightGlide-DBfdeOiD.js} +1 -1
  61. package/dist/web/assets/useRowFocus-CMvgf7Aw.js +1 -0
  62. package/dist/web/index.html +15 -15
  63. package/even-keel.config.example.json +1 -1
  64. package/package.json +1 -1
  65. package/dist/web/assets/TranscriptWindow-BN6jSpev.css +0 -1
  66. package/dist/web/assets/blocks-CiOz7u_W.js +0 -12
  67. package/dist/web/assets/feedLine-txivfLQO.js +0 -1
  68. package/dist/web/assets/index-BT7ooY-T.js +0 -25
  69. package/dist/web/assets/index-hTYDOTAZ.css +0 -1
  70. package/dist/web/assets/overview-0NAogPYB.js +0 -7
  71. package/dist/web/assets/packageGroups-6mYiV3fk.js +0 -1
  72. package/dist/web/assets/useRowFocus-COI8llTH.js +0 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,42 @@ 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.3.1] - 2026-11-17
8
+
9
+ A patch of 0.3: the CI and limit fixes that cost a chain time, and a clearer carry panel.
10
+
11
+ ### Added
12
+
13
+ - **What a waiting carry brings.** The panel of a carry waiting for its turn shows the number of commits, the conflicted files with the conflict lines of each, and **Skip**.
14
+ - **Update all** in the package catalog, to the right of **Check all**.
15
+
16
+ ### Fixed
17
+
18
+ - **One CI poll that gets no answer no longer leaves the pushed commit unchecked.** Before, a single timed-out poll during a run dropped the commit, so a red main was never fixed. The push is now watched for up to an hour, and the CI's later result decides it: red means a rerun and then a fix session, green means it passed. Meanwhile the CI panel says the CI did not answer.
19
+ - A Claude chain on a subscription no longer treats a session's cache as warm for an hour when the session writes the five-minute cache.
20
+ - When a limit resets early, a task no longer stays held by "paid usage possible, not confirmed" until the announced reset with usage at 0%.
21
+ - More limits are read correctly:
22
+ - Claude's limit windows come from the CLI's usage report, so reading an Ultra account without a five-hour limit no longer depends on how the CLI words its lines.
23
+ - A ChatGPT seat in a workspace (Team, Business, Edu) gets its spending cap and monthly credits read.
24
+ - Copilot no longer shows "unlimited" for a Business seat whose allowance is used up.
25
+ - Copilot: a turn that fails on "Failed to load models" shows the error instead of waiting for an answer.
26
+ - OpenCode: a permission request refused by the task's rules, such as reading `.env`, no longer ends the turn silently and leaves the session waiting with no question.
27
+ - The launch card shown when a session continues after a limit no longer says that the old session stops and a new one starts with a handoff, since the same session continues.
28
+ - A private repository on a free GitHub plan no longer shows "Could not verify protection" after every launch, since its branch cannot be protected.
29
+ - A pause on a refused pull request description no longer tells you to press Resume. The pull request opens by itself from the session's next mark.
30
+ - The GitLab profile form no longer requires a server address for GitLab.com, where the hint says to leave it empty.
31
+ - "What sessions get" reads `.claude/settings.json` from the project's branch, not from the main checkout's disk.
32
+ - The changelog window:
33
+ - For a released milestone, it shows the released section of the file instead of an old draft under `[Unreleased]`.
34
+ - On an account whose limit is spent, it shows a clear notice instead of the CLI's raw JSON answer.
35
+ - A carry waiting for its turn no longer shows the session of an earlier carry with the same name.
36
+ - A row's **Install** or **Update** button in the package catalog no longer stays stuck after the action.
37
+ - On a phone, a long question in the chat window no longer covers the answer options, and the question switcher no longer wraps around the text.
38
+ - The demo:
39
+ - The session window opened from the task's sessions finds its transcript, and the card of a finished task shows what the session did.
40
+ - The answer to DEMO-3's question appears above the `TASK DONE` line and is still there when the chat is opened again.
41
+ - Without git, "The demo is over" no longer says the branches were merged into the main one.
42
+
7
43
  ## [0.3.0] - 2026-11-16
8
44
 
9
45
  0.3 needs neither a tracker account nor git to start: a built-in tracker, projects without git, a demo on the first start and a project wizard that clones or creates the repository. Sessions get Even Keel's own tasks server for every tracker, Forgejo issues join the trackers, Claude Code runs on Amazon Bedrock, Google Vertex AI and Microsoft Foundry, and OpenCode on an OpenRouter key. The page gains an event log, a chat window per task and a README badge of the chain.
package/README.md CHANGED
@@ -71,7 +71,7 @@ Parallel agents decide on their own what an unfinished task will look like, hand
71
71
 
72
72
  ## Before you run it
73
73
 
74
- - **Even Keel depends on undocumented behaviour of the agents' CLIs**, none of it a public API. Last checked against **Claude Code 2.1.325**, **codex-cli 0.169.0**, **OpenCode 1.19.5** and **Copilot CLI 1.0.112**; the page warns when yours is another version and can run sessions on the checked one instead. A CLI update may break a part of Even Keel until it is adapted — please open an issue when it does. Details: [setup](docs/guide/setup.md#the-clis-it-depends-on).
74
+ - **Even Keel depends on undocumented behaviour of the agents' CLIs**, none of it a public API. Last checked against **Claude Code 2.1.326**, **codex-cli 0.169.0**, **OpenCode 1.19.6** and **Copilot CLI 1.0.112**; the page warns when yours is another version and can run sessions on the checked one instead. A CLI update may break a part of Even Keel until it is adapted — please open an issue when it does. Details: [setup](docs/guide/setup.md#the-clis-it-depends-on).
75
75
  - **Your subscription, the providers' terms.** A project runs on one account per provider, and a spent limit is waited out, never got round by switching accounts. Even Keel does not share, pool or resell access. Each agent's sessions fall under its provider's terms, listed below.
76
76
  - **Sessions don't ask you before each tool call** (Claude in auto mode, Codex with `--approve-for-me` or, if you choose, with no sandbox). Protection refuses destructive commands; set up any other permissions and hooks in your agents' settings before you start a chain. Whoever writes a task's text steers its session: read [whose text a session reads and what it may do](docs/guide/security.md) before a chain runs on a public repository.
77
77
  - **Your sign-in stays with the CLIs.** Even Keel reads only expiry dates, the e-mail and the plan; tokens are never copied or sent anywhere. An API key you add goes only to its own provider.
@@ -1,9 +1,11 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { runGit } from '../git/run.js';
3
3
  import { hungEntry } from '../sessions/silence.js';
4
- import { TranscriptFold } from '../sessions/transcript.js';
4
+ import { TranscriptFold, userLine } from '../sessions/transcript.js';
5
5
  export const SCRIPT_PID = 4242;
6
6
  const FEED_SIZE = 30;
7
+ /** The lines a record keeps, as `readSessionRecord`'s fold does. */
8
+ const RECORD_FEED = 5_000;
7
9
  /** Captured before a scenario fakes the timers: `settled` polls in real time. */
8
10
  const realTimeout = globalThis.setTimeout;
9
11
  /** What a parked turn waits for; the scenario opens it. */
@@ -85,6 +87,13 @@ export class ScriptedAgent {
85
87
  if (known === undefined)
86
88
  throw new Error(`script: no session ${session.sessionId}`);
87
89
  known.mcp = start.mcp ?? [];
90
+ // The prompt goes into the transcript as a CLI writes it: an answer to the pending question, or the user's own words
91
+ // (EKR-116). The question outlives the stop that passes the answer on in the summary, as in a transcript's fold.
92
+ const line = userLine(new Date().toISOString(), start.prompt, known.summary.ask, (text) => text.trim());
93
+ if (line !== null) {
94
+ known.lines.push(line);
95
+ known.summary = { ...known.summary, feed: known.lines.slice(-FEED_SIZE) };
96
+ }
88
97
  this.calls.push({ kind: 'resume', task: start.name, sessionId: session.sessionId, cwd: start.cwd, prompt: start.prompt, provider: home.agent, account: home.key, model: start.model, ...(start.effort !== undefined && { effort: start.effort }) });
89
98
  this.play(session.sessionId, start.prompt);
90
99
  return session.sessionId;
@@ -115,8 +124,28 @@ export class ScriptedAgent {
115
124
  summary: () => session()?.summary ?? new TranscriptFold().summary(),
116
125
  };
117
126
  }
118
- async record() {
119
- return undefined;
127
+ /** The session's record from what the script keeps of it, as an adapter's would be read from its transcript (EKR-114). */
128
+ async record(home, sessionId) {
129
+ const session = this.known.get(sessionId);
130
+ if (session === undefined || session.entry.account !== home.key)
131
+ return undefined;
132
+ const { summary } = session;
133
+ return {
134
+ sessionId,
135
+ startedAt: new Date(session.entry.startedAt).toISOString(),
136
+ lastActivityAt: summary.lastActivityAt,
137
+ model: summary.model,
138
+ effort: summary.effort ?? null,
139
+ contextTokens: summary.contextTokens,
140
+ contextWindow: summary.contextWindow,
141
+ tokens: summary.tokens,
142
+ stage: summary.stage,
143
+ feed: session.lines.slice(-RECORD_FEED),
144
+ workdir: summary.workdir,
145
+ branch: summary.gitBranch,
146
+ apiError: summary.apiError?.text ?? null,
147
+ account: null,
148
+ };
120
149
  }
121
150
  async feed(_home, _sessionId, _after) {
122
151
  return undefined;
@@ -0,0 +1,41 @@
1
+ const MARKER = /^(<{7}|={7}|\|{7}|>{7})(?: |$)/;
2
+ /** The lines inside a file's conflict blocks, `<<<<<<<` to `>>>>>>>`, the marker lines left out. */
3
+ export function conflictLines(text) {
4
+ let inside = false;
5
+ let lines = 0;
6
+ for (const line of text.split(/\r?\n/)) {
7
+ const marker = MARKER.exec(line)?.[1];
8
+ if (marker === undefined) {
9
+ if (inside)
10
+ lines += 1;
11
+ }
12
+ else if (marker.startsWith('<'))
13
+ inside = true;
14
+ else if (marker.startsWith('>'))
15
+ inside = false;
16
+ }
17
+ return lines;
18
+ }
19
+ /**
20
+ * Each conflicted file of a failed merge with its conflict lines (EKR-134), read before `merge --abort`. A file deleted
21
+ * on one side has no markers and no lines: the index lacks its stage of that side.
22
+ */
23
+ export async function readConflict(git, repo, files, read) {
24
+ const stages = new Map();
25
+ for (const entry of (await git(repo, ['ls-files', '--unmerged', '-z'])).out.split('\0')) {
26
+ const tab = entry.indexOf('\t');
27
+ if (tab < 0)
28
+ continue;
29
+ const stage = entry.slice(0, tab).split(' ')[2];
30
+ const path = entry.slice(tab + 1);
31
+ if (stage !== undefined)
32
+ stages.set(path, (stages.get(path) ?? new Set()).add(stage));
33
+ }
34
+ return Promise.all(files.map(async (path) => {
35
+ const seen = stages.get(path);
36
+ if (seen !== undefined && (!seen.has('2') || !seen.has('3')))
37
+ return { path, lines: null };
38
+ const text = await read(path);
39
+ return { path, lines: text === null ? 0 : conflictLines(text) };
40
+ }));
41
+ }
@@ -1,4 +1,5 @@
1
1
  import { englishOf, fail, notice } from '../notice/notice.js';
2
+ import { readConflict } from './conflict.js';
2
3
  /**
3
4
  * Whether the chain is quiet enough for the release branch to go into its project's branch: stopped, empty, or paused
4
5
  * with its session not working, and neither cleaning up after a task nor waiting on a push of main.
@@ -16,7 +17,8 @@ export function chainQuiet(chain, busy) {
16
17
  * Carries the branch of each release project into the branch of the project it merges into (BTN-172), in that
17
18
  * project's main checkout: by `merge --no-edit` once its chain is quiet, or at once on "Carry now". A failed merge
18
19
  * (a conflict, or git refusing with no conflicted file, BTN-314) is aborted, so the checkout stays clean and the chain goes on, and holds the carry until "Carry now", an agent's session or until the branch
19
- * has the commits by a merge by hand. The hold lives in memory: after a restart the carry is tried once more.
20
+ * has the commits by a merge by hand. The hold lives in memory: after a restart the carry is tried once more, unless a
21
+ * session resolves it; then the page shows the conflict that session was asked for (EKR-135).
20
22
  * A held conflict may be resolved by an agent (BTN-369); while its session is asked for, nothing is merged here.
21
23
  * With `auto` the session is asked for at the conflict itself (BTN-370), once per release commit: a held carry is then
22
24
  * tried again once the release branch has moved, and a session that did not land it gets no successor before that.
@@ -34,8 +36,11 @@ export class ForwardMerger {
34
36
  }
35
37
  view() {
36
38
  return Object.fromEntries([...this.views].map(([from, view]) => {
37
- const agent = this.deps.carrying(from);
38
- return [from, agent === null ? view : { ...view, agent }];
39
+ const carry = this.deps.carrying(from);
40
+ if (carry === null)
41
+ return [from, view];
42
+ const conflict = view.conflict ?? carry.conflict;
43
+ return [from, conflict === undefined ? { ...view, agent: carry.task } : { ...view, agent: carry.task, conflict }];
39
44
  }));
40
45
  }
41
46
  tick() {
@@ -58,7 +63,7 @@ export class ForwardMerger {
58
63
  return Promise.reject(fail('forward.notRelease', { project: from }));
59
64
  const agent = this.deps.carrying(from);
60
65
  if (agent !== null)
61
- return Promise.reject(fail('forward.agent', { from, task: agent }));
66
+ return Promise.reject(fail('forward.agent', { from, task: agent.task }));
62
67
  return this.queue(() => this.step(pair, true));
63
68
  }
64
69
  /** "Resolve with the agent": only a held conflict, told with the release commit it is to bring in. */
@@ -77,7 +82,10 @@ export class ForwardMerger {
77
82
  }
78
83
  ask(from, view, hold, commit) {
79
84
  const files = hold.params.files;
80
- return this.deps.resolve(from, { into: view.into, ref: refOf(from), commit, commits: view.behind ?? 0, files, output: hold.detail ?? '' });
85
+ const ask = { into: view.into, ref: refOf(from), commit, commits: view.behind ?? 0, files, output: hold.detail ?? '' };
86
+ if (view.conflict !== undefined)
87
+ ask.conflict = view.conflict;
88
+ return this.deps.resolve(from, ask);
81
89
  }
82
90
  /** The release commit fetched for the carry, or why it could not be read. */
83
91
  async commitOf(into, from) {
@@ -95,7 +103,11 @@ export class ForwardMerger {
95
103
  const view = { into, behind: before?.behind ?? null, hold: before?.hold ?? null, held: before?.held ?? false };
96
104
  if (before?.last !== undefined)
97
105
  view.last = before.last;
106
+ if (before?.conflict !== undefined)
107
+ view.conflict = before.conflict;
98
108
  await this.carryInto(view, from, now);
109
+ if (!view.held)
110
+ delete view.conflict;
99
111
  if (JSON.stringify(view) !== JSON.stringify(before)) {
100
112
  this.views.set(from, view);
101
113
  this.deps.changed();
@@ -142,7 +154,12 @@ export class ForwardMerger {
142
154
  const merged = await git(repo, ['merge', '--no-edit', '-m', `Merge branch '${this.deps.branch(from)}' of ${this.deps.label(from)} into ${branch}`, ref]);
143
155
  if (merged.code !== 0) {
144
156
  const files = (await git(repo, ['diff', '--name-only', '--diff-filter=U'])).out.split(/\r?\n/).filter((line) => line.trim() !== '');
157
+ const conflict = files.length > 0 ? await readConflict(git, repo, files, (path) => this.deps.read(repo, path)) : undefined;
145
158
  await git(repo, ['merge', '--abort']);
159
+ if (conflict === undefined)
160
+ delete view.conflict;
161
+ else
162
+ view.conflict = conflict;
146
163
  const hold = files.length > 0 ? notice('forward.conflict', { from, into, files }, { detail: merged.out }) : notice('forward.failed', { from, into }, { detail: merged.out });
147
164
  this.deps.log(`forward: ${files.length > 0 ? englishOf(hold) : `${englishOf(hold)}: ${merged.out.trim()}`}`);
148
165
  Object.assign(view, { hold, held: true });
@@ -81,8 +81,7 @@ export class Handovers {
81
81
  }
82
82
  }
83
83
  const now = this.deps.now();
84
- if (overage === undefined)
85
- this.reopenEarly(chain.project, current, session, now);
84
+ this.reopenEarly(chain.project, current, session, now);
86
85
  const hold = current.limit;
87
86
  const spentUntil = overage === undefined ? null : this.deps.limitReset(chain.project, current.task);
88
87
  if (spentUntil !== null && Date.parse(spentUntil) > now.getTime())
@@ -33,8 +33,9 @@ export class MainCheck {
33
33
  /** The latest push of main the chain did not make, by project (BTN-707): awaited only for `commands.afterGreen`, it holds no launch. */
34
34
  outside = new Map();
35
35
  /**
36
- * The chain's push that stayed unchecked because no runner took it in time, by project (BTN-719): the launch went on,
37
- * but a run taken later still judges it, a red one as any red main. The next push of the chain or `LATE_MS` ends the watch.
36
+ * The chain's push that stayed unchecked because no runner took it in time (BTN-719) or the CI did not answer
37
+ * (`unanswered`, EKR-136), by project: the launch went on, but a verdict said later still judges it, a red one as any
38
+ * red main. The next push of the chain or `LATE_MS` ends the watch.
38
39
  */
39
40
  late = new Map();
40
41
  /** Who pushed the latest commits of each project's main the service saw (BTN-829), oldest first. */
@@ -56,12 +57,13 @@ export class MainCheck {
56
57
  /** What the CI panel shows of the project's main (BTN-829). */
57
58
  view(project) {
58
59
  const late = this.late.get(project);
59
- const judging = this.state.ci[project]?.check?.commit ?? late?.commit;
60
+ const judging = this.state.ci[project]?.check?.commit ?? late?.push.commit;
60
61
  const record = this.state.ci[project]?.afterGreenRun;
61
62
  const after = record !== undefined && this.deps.afterGreen(project) ? { ...record, running: this.afterRuns.get(project)?.commit === record.commit } : undefined;
63
+ const until = late === undefined ? '' : new Date(Date.parse(late.push.at) + LATE_MS).toISOString();
62
64
  return {
63
65
  ...(judging !== undefined && { judging }),
64
- ...(late !== undefined && { late: { commit: late.commit, until: new Date(Date.parse(late.at) + LATE_MS).toISOString() } }),
66
+ ...(late !== undefined && { late: { commit: late.push.commit, until, ...(late.unanswered && { unanswered: true }) } }),
65
67
  ...(after !== undefined && { afterGreen: after }),
66
68
  pushes: Object.fromEntries(this.pushers.get(project) ?? []),
67
69
  };
@@ -290,10 +292,10 @@ export class MainCheck {
290
292
  changed = (await this.settleLate(open, stops, fixes)) || changed;
291
293
  return { changed, stops, fixes };
292
294
  }
293
- /** A late verdict on a push left unchecked for want of a runner: green as any green, red files the fix as any red main. */
295
+ /** A late verdict on a push left unchecked: green as any green, red files the fix as any red main. */
294
296
  async settleLate(open, stops, fixes) {
295
297
  let changed = false;
296
- for (const [project, push] of [...this.late]) {
298
+ for (const [project, { push }] of [...this.late]) {
297
299
  const gate = this.gate(project);
298
300
  const rerunBefore = gate.rerun;
299
301
  const { verdict, reran } = await this.judged(project, gate, push);
@@ -431,9 +433,11 @@ export class MainCheck {
431
433
  delete gate.fix;
432
434
  if (reasons.length > 0)
433
435
  this.log(`ci: ${project}: ${commit} stays unchecked: ${why}`);
434
- if (reasons.some((reason) => reason.code === 'ci.notTaken')) {
435
- this.late.set(project, push);
436
- this.log(`ci: ${project}: ${commit} is still watched: a run taken later judges it`);
436
+ // One failed poll in the middle of a run must not drop the commit (EKR-136): what the CI says later still judges it.
437
+ if (reasons.length > 0) {
438
+ const unanswered = !reasons.some((reason) => reason.code === 'ci.notTaken');
439
+ this.late.set(project, { push, unanswered });
440
+ this.log(`ci: ${project}: ${commit} is still watched: ${unanswered ? 'the CI judges it once it answers' : 'a run taken later judges it'}`);
437
441
  }
438
442
  return;
439
443
  }
@@ -1,6 +1,6 @@
1
1
  import { fail } from '../notice/notice.js';
2
2
  import { changelogPrompt, materialOf } from './draft.js';
3
- import { answerSection, changelogPlan, withSection } from './file.js';
3
+ import { answerSection, changelogPlan, newestReleased, withSection } from './file.js';
4
4
  import { addVersion, latestVersion, markWritten, spentOn, writtenTasks } from './store.js';
5
5
  const headingOf = (text) => text.split('\n')[0].trimEnd();
6
6
  /** What every turn is told about the releases before its section. */
@@ -42,11 +42,14 @@ export class ChangelogDrafts {
42
42
  const latest = await latestVersion(db, project, milestone);
43
43
  const [file, tags] = await Promise.all([this.deps.file(project), this.deps.tags(project)]);
44
44
  const plan = changelogPlan(file.text, milestone, tags);
45
+ // A written version whose section has since been released is frozen: only new tasks go on, into the next patch's section.
46
+ const frozen = latest !== null && latest.written !== null && plan.section === null && plan.tag !== null;
45
47
  const view = async (version, start = null) => ({
46
48
  project,
47
49
  milestone,
48
50
  file: file.path,
49
51
  released: plan.tag,
52
+ frozen: frozen && version === latest ? { section: newestReleased(plan)?.text ?? null } : null,
50
53
  version,
51
54
  start,
52
55
  spent: await spentOn(db, project, milestone),
@@ -66,8 +69,6 @@ export class ChangelogDrafts {
66
69
  return view(await this.fresh(project, milestone, plan, file.path, tags, op.op === 'draft' ? 'draft' : 'again'));
67
70
  if (latest === null)
68
71
  throw fail('changelog.noDraft', { milestone });
69
- // A written version whose section has since been released is frozen: only new tasks go on, into the next patch's section.
70
- const frozen = latest.written !== null && plan.section === null && plan.tag !== null;
71
72
  if (frozen && op.op !== 'add')
72
73
  throw fail('changelog.released', { milestone, tag: plan.tag ?? '' });
73
74
  if (op.op === 'write')
@@ -93,6 +93,10 @@ export function changelogPlan(text, milestone, tags) {
93
93
  tag: newest?.tag ?? null,
94
94
  };
95
95
  }
96
+ /** The released section of the milestone's newest version in the file; `null` — the file has none. */
97
+ export function newestReleased(plan) {
98
+ return plan.released.reduce((newest, each) => (newest === null || byVersion(each.name, newest.name) > 0 ? each : newest), null);
99
+ }
96
100
  /**
97
101
  * The sections of the newest version line older than the milestone: as long as the milestone's version (`0.1` for `v0.2`),
98
102
  * or the newest section's version without its last part for a milestone that is not a version.
@@ -0,0 +1,30 @@
1
+ const WINDOWS = ['fiveHour', 'sevenDay', 'month'];
2
+ /**
3
+ * The account's window used up as of its last known limits, so a paid draft turn is not sent only to be refused: the
4
+ * one that resets last, as the account waits for it. A window whose reset has already come counts as free.
5
+ */
6
+ export function spentLimitOf(limits, now) {
7
+ if (limits === null)
8
+ return null;
9
+ const spent = WINDOWS.flatMap((window) => {
10
+ const each = limits[window];
11
+ return each !== null && each !== undefined && each.usedPercentage >= 100 && Date.parse(each.resetsAt) > now.getTime() ? [{ window, until: each.resetsAt }] : [];
12
+ });
13
+ return spent.sort((a, b) => Date.parse(a.until) - Date.parse(b.until)).at(-1) ?? null;
14
+ }
15
+ const REFUSAL = /usage_limit_reached|"api_error_status"\s*:\s*429|hit your [\w -]*limit|usage limit/i;
16
+ const WINDOW_WORDS = [
17
+ [/5-hour|five-hour/i, 'fiveHour'],
18
+ [/weekly|7-day|seven-day/i, 'sevenDay'],
19
+ [/monthly/i, 'month'],
20
+ ];
21
+ /**
22
+ * Whether the error of a one-turn write is the CLI's refusal on a spent limit (a 429, `usage_limit_reached`, "hit your
23
+ * … limit"), with the window its text names; `null` — some other failure.
24
+ */
25
+ export function limitRefusalIn(text) {
26
+ if (!REFUSAL.test(text))
27
+ return null;
28
+ const window = WINDOW_WORDS.find(([words]) => words.test(text))?.[1];
29
+ return window === undefined ? {} : { window };
30
+ }
@@ -6,8 +6,13 @@ export async function branchProtection(target, branch, token, fetcher = fetch) {
6
6
  const base = { remote, branch, status: 'unknown', bypass: false, url: kind === 'gitlab' ? `${repository}/-/settings/repository` : `${repository}/settings/${kind === 'github' ? 'rules' : 'branches'}` };
7
7
  const get = async (url) => {
8
8
  const result = await fetcher(url, { headers: { accept: 'application/json', 'user-agent': 'even-keel', ...(token === null ? {} : { authorization: `${kind === 'forgejo' ? 'token' : 'Bearer'} ${token}` }) }, signal: AbortSignal.timeout(10_000), redirect: 'error' });
9
- return { status: result.status, value: result.ok ? await result.json() : null };
9
+ if (result.ok)
10
+ return { status: result.status, value: await result.json(), message: null };
11
+ const body = await result.json().catch(() => null);
12
+ return { status: result.status, value: null, message: typeof body?.message === 'string' ? body.message : null };
10
13
  };
14
+ // GitHub's refusal of branch protection and rulesets for a private repository on the free plan.
15
+ const planRefused = (answer) => answer.status === 403 && answer.message !== null && /upgrade to github pro|make this repository public/i.test(answer.message);
11
16
  const path = `/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`;
12
17
  try {
13
18
  if (kind === 'github') {
@@ -39,6 +44,8 @@ export async function branchProtection(target, branch, token, fetcher = fetch) {
39
44
  return { ...base, status: 'unprotected' };
40
45
  if (classic.status === 200 && rules.status === 200)
41
46
  return { ...base, status: 'unprotected' };
47
+ if (current.value?.protected === false && planRefused(classic) && planRefused(rules))
48
+ return { ...base, status: 'unavailable' };
42
49
  return base;
43
50
  }
44
51
  if (kind !== 'forgejo' || token === null)
@@ -7,7 +7,7 @@ import { cliVersionOf } from '../agent/versions.js';
7
7
  import { parseUsage } from '../limits/usage.js';
8
8
  import { findBinary } from '../paths.js';
9
9
  import { DEFAULT_LANGUAGE } from '../settings/defaults.js';
10
- import { WARM_CACHE_MS, warmCacheMs } from '../sessions/cache.js';
10
+ import { warmCacheMs } from '../sessions/cache.js';
11
11
  import { readSessionRecord, readTranscript, readTranscriptImage, transcriptFile } from '../sessions/history.js';
12
12
  import { transcriptIds } from '../sessions/owners.js';
13
13
  import { bridgeOfRecord, remoteAtStartup } from '../sessions/remote.js';
@@ -25,7 +25,7 @@ import { SDK_KIND } from './sdk/registry.js';
25
25
  import { fetchSdk, sdkModuleIn, sdkVersionOf } from './sdk/release.js';
26
26
  import { trustFolder } from './trust.js';
27
27
  /** The version the README's "Before you run it" names; raised after the live run of each release (`docs/releases.md`). */
28
- const CHECKED = '2.1.325';
28
+ const CHECKED = '2.1.326';
29
29
  /** Even Keel's folder of SDK sessions in `state/` and of the SDK's copies in `state/cli/`. */
30
30
  export const CLAUDE_SDK = 'claude-sdk';
31
31
  const SDK_TRANSPORT = 'sdk';
@@ -175,8 +175,8 @@ export const claude = {
175
175
  const { cwd, prompt, model, settings, mcp, plugins, effort } = start;
176
176
  return cli.warm(home, sessionId, cwd, prompt, model, { settings, mcp, plugins, effort, instructions: agentsFallback(cwd) });
177
177
  },
178
- // A subscription's cache lives an hour, a key's as `cacheTtl` wrote it.
179
- warmMs: (cache, apiKey) => (apiKey ? warmCacheMs(cache?.ttl ?? null) : WARM_CACHE_MS),
178
+ // The lifetime the transcript last wrote (`cacheTtl`, a subscription's overage); before any write an hour on a subscription, five minutes on a key.
179
+ warmMs: (cache, apiKey) => warmCacheMs(cache?.ttl ?? (apiKey ? null : '1h')),
180
180
  liveRecords,
181
181
  remote: {
182
182
  enabled: remoteAt,
@@ -2,9 +2,12 @@ import { notice } from '../notice/notice.js';
2
2
  import { lastEvent } from '../codex/turns.js';
3
3
  /** The first line of the plain text the CLI exits with when nothing signs it in; a list of the ways in follows it. */
4
4
  const SIGN_IN_REFUSAL = 'Copilot can be authenticated with GitHub using ';
5
+ /** The first Error line the CLI exits with when it cannot fetch the model list from the Copilot API. */
6
+ const MODELS_REFUSAL = 'Error: Failed to load models';
5
7
  /**
6
- * stdout also contains JSON events and warnings; only a terminal plain-text Error is a CLI refusal, and the sign-in
7
- * refusal, which ends with a list instead, is told by its first line.
8
+ * stdout also contains JSON events and warnings; a CLI refusal is the Error lines of the plain-text block after the
9
+ * last event, which may go on with advice (EKR-113), and the sign-in refusal, which has no Error line of its own, is
10
+ * told by its first line.
8
11
  */
9
12
  export function outputError(output) {
10
13
  if (lastEvent(output)?.exitCode === 0)
@@ -13,14 +16,16 @@ export function outputError(output) {
13
16
  const signIn = lines.find((line) => line.startsWith(SIGN_IN_REFUSAL));
14
17
  if (signIn !== undefined)
15
18
  return signIn;
16
- const last = lines.at(-1);
17
- return last?.startsWith('Error: ') ? last : undefined;
19
+ const errors = lines.slice(lines.findLastIndex((line) => line.startsWith('{')) + 1).filter((line) => line.startsWith('Error: '));
20
+ return errors.length === 0 ? undefined : errors.join('\n');
18
21
  }
19
- /** The notice of a refusal the page can fix: a model the account cannot use, or no sign-in on the machine. */
22
+ /** The notice of a refusal the page can fix: a model the account cannot use, no sign-in, or no way to the Copilot API. */
20
23
  export function refusalNotice(text) {
21
24
  if (text.startsWith(SIGN_IN_REFUSAL))
22
25
  return notice('copilot.notSignedIn', {});
23
- const model = /^Error: Model "([^"\r\n]+)" from --model flag is not available\.$/.exec(text)?.[1];
26
+ if (text.startsWith(MODELS_REFUSAL))
27
+ return notice('copilot.apiUnreachable', {});
28
+ const model = /^Error: Model "([^"\r\n]+)" from --model flag is not available\.$/m.exec(text)?.[1];
24
29
  return model === undefined ? undefined : notice('copilot.modelUnavailable', { model });
25
30
  }
26
31
  /**
@@ -6,6 +6,7 @@ export const gitlab = {
6
6
  title: 'GitLab',
7
7
  variables: [GITLAB_URL, GITLAB_TOKEN],
8
8
  hostVariables: [GITLAB_URL],
9
+ optionalVariables: [GITLAB_URL],
9
10
  help: 'https://docs.gitlab.com/user/profile/personal_access_tokens/',
10
11
  mcpServer: 'gitlab',
11
12
  editsTasks: true,
@@ -0,0 +1,49 @@
1
+ /** Plans a person buys for themselves: a workspace seat (Team, Business, Edu, Enterprise) is any other. */
2
+ const PERSONAL_PLANS = new Set(['free', 'go', 'plus', 'pro']);
3
+ /**
4
+ * Where ChatGPT's spend page reads a workspace seat's monthly credits (EKR-132): the owner's cap and what the seat used
5
+ * this month. `wham/usage` has neither; Codex does not ask it.
6
+ */
7
+ export function chatGptSeatUsageUrl(accountId) {
8
+ return `https://chatgpt.com/backend-api/accounts/${encodeURIComponent(accountId)}/spend-controls/current-user/monthly-usage?supports_usage_limit_modes=true`;
9
+ }
10
+ /** Whether `wham/usage` is a workspace seat's: it has `spend_control` and the plan is not a personal one. */
11
+ export function isChatGptSeat(body) {
12
+ return isRecord(body) && isRecord(body.spend_control) && typeof body.plan_type === 'string' && !PERSONAL_PLANS.has(body.plan_type);
13
+ }
14
+ /** `spend_control.reached` of `wham/usage`: the seat's monthly cap is spent; `undefined` — the answer does not say. */
15
+ export function spendCapReached(body) {
16
+ const control = isRecord(body) ? body.spend_control : undefined;
17
+ return isRecord(control) && typeof control.reached === 'boolean' ? control.reached : undefined;
18
+ }
19
+ /**
20
+ * The seat's month out of the `monthly-usage` answer: the credits used of the cap, resetting at the next calendar month
21
+ * in UTC (no reset is named; none other seen yet). Whether the seat is closed is `spend_control.reached`'s to say, so
22
+ * the count alone stays under 100 %, and `reached` makes it 100 %. `undefined` — not an answer in credits.
23
+ */
24
+ export function seatMonth(raw, at, reached) {
25
+ if (!isRecord(raw) || (raw.balance_unit !== undefined && raw.balance_unit !== 'credit'))
26
+ return undefined;
27
+ const used = raw.current_month_usage;
28
+ if (typeof used !== 'number' || !Number.isFinite(used) || used < 0)
29
+ return undefined;
30
+ const resetsAt = nextMonth(at);
31
+ const cap = isRecord(raw.effective_monthly_limit) ? raw.effective_monthly_limit : undefined;
32
+ const limit = cap?.limit;
33
+ if (typeof limit !== 'number' || !Number.isFinite(limit) || limit <= 0 || (cap?.limit_mode !== undefined && cap.limit_mode !== 'amount_credits')) {
34
+ return { usedPercentage: reached ? 100 : 0, resetsAt, used };
35
+ }
36
+ const share = Math.round((used / limit) * 1000) / 10;
37
+ return { usedPercentage: reached ? 100 : Math.min(share, 99), resetsAt, used, limit };
38
+ }
39
+ /** A reached cap with no count read: the month is spent until it turns. */
40
+ export function spentSeatMonth(at) {
41
+ return { usedPercentage: 100, resetsAt: nextMonth(at) };
42
+ }
43
+ function nextMonth(at) {
44
+ const now = new Date(at);
45
+ return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() + 1, 1)).toISOString();
46
+ }
47
+ function isRecord(value) {
48
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
49
+ }
@@ -1,5 +1,6 @@
1
1
  import { notice } from '../notice/notice.js';
2
2
  import { chatGptCredits } from './overage.js';
3
+ import { chatGptSeatUsageUrl, isChatGptSeat, seatMonth, spendCapReached, spentSeatMonth } from './chatgpt-seat.js';
3
4
  /** What Codex's `/status` asks: the windows of the ChatGPT subscription, shared by every client signed in to it. */
4
5
  export const CHATGPT_USAGE_URL = 'https://chatgpt.com/backend-api/wham/usage';
5
6
  const AUTH_CLAIM = 'https://api.openai.com/auth';
@@ -12,30 +13,43 @@ const polls = new Map();
12
13
  * The windows of ChatGPT's usage answer (BTN-341): `rate_limit.primary_window`/`secondary_window`, each with the share
13
14
  * used, its length and its reset in seconds — the five-hour, the weekly and the free plan's 30-day window by their length,
14
15
  * as Codex's rollouts (`limitsOfRollout`). `undefined` — the answer holds no window.
16
+ *
17
+ * A workspace seat's monthly credit cap (EKR-132): `spend_control.reached` closes the account (`open: false`, the month
18
+ * spent), and `monthly`, the seat's `monthly-usage` answer, gives the month's count (`seatMonth`).
15
19
  */
16
- export function chatGptLimits(body, at) {
20
+ export function chatGptLimits(body, at, monthly) {
17
21
  const limit = isRecord(body) ? body.rate_limit : undefined;
18
22
  const overage = chatGptCredits(isRecord(body) ? body.credits : undefined, at);
19
23
  const windows = isRecord(limit) ? [limit.primary_window, limit.secondary_window].filter(isRecord) : [];
20
- if (windows.length === 0 && overage === undefined)
24
+ const reached = spendCapReached(body);
25
+ const seat = isChatGptSeat(body);
26
+ if (windows.length === 0 && overage === undefined && !seat && reached !== true)
21
27
  return undefined;
22
28
  const of = (minutes) => {
23
29
  const found = windows.find((window) => window.limit_window_seconds === minutes * 60);
24
30
  return found === undefined ? null : windowOf(found, at);
25
31
  };
26
- const monthly = windows.some((window) => window.limit_window_seconds === MONTH * 60);
27
32
  const flags = isRecord(limit) && (typeof limit.allowed === 'boolean' || typeof limit.limit_reached === 'boolean') ? limit : undefined;
28
- const open = flags === undefined ? undefined : flags.allowed === true && flags.limit_reached === false;
33
+ const allowed = flags === undefined ? undefined : flags.allowed === true && flags.limit_reached === false;
34
+ const open = reached === true ? false : allowed;
35
+ const month = monthOf(windows.some((window) => window.limit_window_seconds === MONTH * 60) ? of(MONTH) : undefined, seat && monthly !== undefined ? seatMonth(monthly, at, reached === true) : undefined, reached === true, at);
29
36
  return {
30
37
  fiveHour: of(FIVE_HOURS),
31
38
  sevenDay: of(WEEK),
32
- ...(monthly ? { month: of(MONTH) } : {}),
39
+ ...(month !== undefined ? { month } : {}),
33
40
  updatedAt: at,
34
41
  source: 'api',
35
42
  ...(overage !== undefined && { overage }),
36
43
  ...(open !== undefined && { open }),
44
+ ...((seat || reached === true) && { spendCap: { reached: reached === true, updatedAt: at } }),
37
45
  };
38
46
  }
47
+ /** The plan's own 30 days first; else the seat's credits; a reached cap spends whichever there is, or a month of its own. */
48
+ function monthOf(plan, seat, reached, at) {
49
+ if (plan !== undefined)
50
+ return reached && plan !== null ? { ...plan, usedPercentage: 100 } : plan;
51
+ return seat ?? (reached ? spentSeatMonth(at) : undefined);
52
+ }
39
53
  /** The ChatGPT account an access token is for, by its claim; `null` — not a token that says. */
40
54
  export function chatGptAccountOf(token) {
41
55
  const auth = claimsOf(token)?.[AUTH_CLAIM];
@@ -125,10 +139,26 @@ export async function askChatGpt(signIn, at, timeoutMs, fetchImpl = fetch) {
125
139
  return { kind: 'missing', reason: notice('usage.chatGptRevoked', {}) };
126
140
  if (!response.ok)
127
141
  throw new Error(`ChatGPT usage answered ${response.status}`);
128
- const limits = chatGptLimits(await response.json().catch(() => undefined), at);
142
+ const body = await response.json().catch(() => undefined);
143
+ const monthly = accountId !== null && isChatGptSeat(body) ? await askSeatMonth(accountId, headers, timeoutMs, fetchImpl) : undefined;
144
+ const limits = chatGptLimits(body, at, monthly);
129
145
  if (limits === undefined)
130
146
  return { kind: 'unknown', reason: notice('usage.chatGptUnread', {}) };
131
- return { kind: 'limits', limits: accountId === null ? limits : { ...limits, pool: chatGptPool(accountId) } };
147
+ return {
148
+ kind: 'limits',
149
+ limits: accountId === null ? limits : { ...limits, pool: chatGptPool(accountId) },
150
+ ...(limits.spendCap?.reached === true && { reason: notice('usage.chatGptSpendCap', {}) }),
151
+ };
152
+ }
153
+ /** The seat's `monthly-usage` answer; `undefined` on any refusal or failure — a seat without the count, not an error. */
154
+ async function askSeatMonth(accountId, headers, timeoutMs, fetchImpl) {
155
+ try {
156
+ const response = await fetchImpl(chatGptSeatUsageUrl(accountId), { headers, signal: AbortSignal.timeout(timeoutMs) });
157
+ return response.ok ? await response.json() : undefined;
158
+ }
159
+ catch {
160
+ return undefined;
161
+ }
132
162
  }
133
163
  /** The pool of a ChatGPT account: a Codex and an OpenCode folder signed in to it share its limits. */
134
164
  export function chatGptPool(accountId) {