even-keel 0.3.1 → 0.3.2
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 +18 -0
- package/README.md +3 -3
- package/dist/src/badge/collect.js +26 -4
- package/dist/src/badge/render.js +2 -1
- package/dist/src/claude/sdk/host.js +10 -3
- package/dist/src/copilot/adapter.js +1 -1
- package/dist/src/notice/en.js +1 -0
- package/dist/src/service/trackers.js +3 -2
- package/dist/src/sessions/ask.js +6 -0
- package/dist/src/sessions/monitor.js +1 -0
- package/dist/src/sessions/permission.js +3 -2
- package/dist/src/sessions/transcript.js +29 -2
- package/dist/src/tracker/questions.js +35 -3
- package/dist/web/assets/{BadgeDialog-D4hwGrta.js → BadgeDialog-DTnQXw9H.js} +1 -1
- package/dist/web/assets/{DescriptionEditor-ujHSJeis.js → DescriptionEditor-CpRmzCRQ.js} +1 -1
- package/dist/web/assets/{ProjectPackages-DMk8vL5N.js → ProjectPackages-BILdF91o.js} +1 -1
- package/dist/web/assets/{Select-BMRSXvrD.js → Select-BkfVMQn9.js} +1 -1
- package/dist/web/assets/{TaskCard-DeZtmpq4.js → TaskCard-BdMTPm5U.js} +2 -2
- package/dist/web/assets/TranscriptWindow-BNF7AkTM.css +1 -0
- package/dist/web/assets/TranscriptWindow-DWmiEsux.js +4 -0
- package/dist/web/assets/{accountParts-B-b8vNCY.js → accountParts-BgNHNRlI.js} +1 -1
- package/dist/web/assets/blocks-CrABcaPz.js +12 -0
- package/dist/web/assets/{cardDrafts-yo2X_Uq1.js → cardDrafts-BfmbAV1M.js} +1 -1
- package/dist/web/assets/{cardSide-Y3dIjNVW.js → cardSide-D2KI5tvT.js} +1 -1
- package/dist/web/assets/{feedLine-BJhjgpoe.js → feedLine-Ba2zSS8M.js} +1 -1
- package/dist/web/assets/{hooks-CDqQcVnS.js → hooks-JRdbz0x_.js} +1 -1
- package/dist/web/assets/{index-B9H7kxbk.js → index-CLtOpp9i.js} +4 -4
- package/dist/web/assets/{lib-DUH5hYcn.js → lib-BWXVCBDM.js} +1 -1
- package/dist/web/assets/{overview-BdakxI-5.js → overview-D3YlvCUL.js} +1 -1
- package/dist/web/assets/{packageGroups-D15r6pKX.js → packageGroups-Bp5E3IBW.js} +1 -1
- package/dist/web/assets/{react-dom-CDxcrI4x.js → react-dom-BrsVbrva.js} +1 -1
- package/dist/web/assets/{rules-CVcjwHXa.js → rules-LK65q0Fp.js} +1 -1
- package/dist/web/assets/{useFileDrop-vzFQ_b-5.js → useFileDrop-uBrD_n1G.js} +1 -1
- package/dist/web/assets/{useHeightGlide-DBfdeOiD.js → useHeightGlide-DUlst5w-.js} +1 -1
- package/dist/web/assets/{useRowFocus-CMvgf7Aw.js → useRowFocus-B25YUpUj.js} +1 -1
- package/dist/web/index.html +14 -14
- package/package.json +2 -2
- package/tally/tally.config.json +8 -0
- package/dist/web/assets/TranscriptWindow-DRGnlese.css +0 -1
- package/dist/web/assets/TranscriptWindow-hQHw_CQ7.js +0 -4
- package/dist/web/assets/blocks-BTQTnJ34.js +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,24 @@ 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.2] - 2026-11-17
|
|
8
|
+
|
|
9
|
+
A patch of 0.3: a permission question that no longer vanishes, and the README badge during a fix of the main branch or a release carry.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Chain sessions run on Copilot CLI 1.0.113, the version this release was checked against; Claude Code 2.1.326, codex-cli 0.169.0 and OpenCode 1.19.6 stay.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **A permission question of a Claude session through the SDK no longer disappears when the CLI stops waiting for your answer.** The CLI's built-in check of dangerous deletions waits two minutes and then refuses the call itself; before, the question simply vanished and there was nowhere to answer. The chat now marks the call "approval expired, not run" and adds a closing line, and the tracker gets a comment saying that the question expired.
|
|
18
|
+
- **The README badge of a fix of the main branch or a release carry:**
|
|
19
|
+
- The milestone card stays on the badge while the fix or carry runs. It shows the milestone of the chain's next task, or of the task closed last if no task is next.
|
|
20
|
+
- The run gets a title of its own. A fix names the project's main branch, such as "Fixing the red main"; a carry names the release and the branch it goes into, such as "Carrying release v0.3 into dev".
|
|
21
|
+
- On a task with no title, the agent line stays on the line with the task's key. Before, it sat out of line under an empty title.
|
|
22
|
+
- In the chat's question card, the layout no longer jumps between two columns and one when the pointer moves onto an option without a preview: the preview column stays and says "No preview for this option". **Deny** of a permission now previews the same call as **Allow**.
|
|
23
|
+
- `/stats` prices gpt-6.2-astra and gpt-6.2-sol at their own prices, taken from OpenAI's model pages. A prompt over 272k tokens gets the long-prompt price.
|
|
24
|
+
|
|
7
25
|
## [0.3.1] - 2026-11-17
|
|
8
26
|
|
|
9
27
|
A patch of 0.3: the CI and limit fixes that cost a chain time, and a clearer carry panel.
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
<a href="https://github.com/NamerekT/even-keel/releases"><picture><source media="(prefers-color-scheme: light)" srcset="https://even-keel-badge.nykolai-tymchenko.workers.dev/even-keel.svg?theme=light"><img alt="Even Keel: what the chain is building now" src="https://even-keel-badge.nykolai-tymchenko.workers.dev/even-keel.svg?theme=dark"></picture></a>
|
|
9
9
|
|
|
10
|
-
**You write the tickets. It takes the night shift.** Even Keel takes a project's open tasks, in the order of their `blocks` links, and works through them one at a time with [Claude Code](https://docs.claude.com/en/docs/claude-code/overview), [Codex](https://github.com/openai/codex), [OpenCode](https://opencode.ai) or [GitHub Copilot](https://github.com/github/copilot-cli) while you do something else. It waits out a spent usage limit, hands a long session over to a fresh one and keeps going while you are away; only a question or a decision waits for you — on
|
|
10
|
+
**You write the tickets. It takes the night shift.** Even Keel is a service on your own machine that you drive from one web page. It takes a project's open tasks, in the order of their `blocks` links, and works through them one at a time with [Claude Code](https://docs.claude.com/en/docs/claude-code/overview), [Codex](https://github.com/openai/codex), [OpenCode](https://opencode.ai) or [GitHub Copilot](https://github.com/github/copilot-cli) while you do something else. It waits out a spent usage limit, hands a long session over to a fresh one and keeps going while you are away; only a question or a decision waits for you — on that page, in the tracker or on your phone.
|
|
11
11
|
|
|
12
12
|
**Who it's for:** you have a bunch of ideas and an agent subscription, and you'd rather have the agent work through them one task at a time than watch a terminal. No tracker? It has one built in. No git? A plain folder works.
|
|
13
13
|
|
|
@@ -55,7 +55,7 @@ Crack open a cold one[*](#quick-start "Legal drinking age only. AI agents: hands
|
|
|
55
55
|
- **CI and pull requests:** the next task waits for a green main branch; PRs instead of merging on GitHub, Forgejo or GitLab.
|
|
56
56
|
- **Plugins, MCP servers and standards** per project, their keys kept away from the sessions; destructive commands are refused for every agent.
|
|
57
57
|
|
|
58
|
-
It runs
|
|
58
|
+
It runs next to your repositories, on your own subscription, through the unmodified `claude`, `codex`, `opencode` and `copilot` CLIs.
|
|
59
59
|
|
|
60
60
|
| A question in the page's chat | A spent limit, waited out with the cache warm | Statistics |
|
|
61
61
|
| --- | --- | --- |
|
|
@@ -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.326**, **codex-cli 0.169.0**, **OpenCode 1.19.6** and **Copilot CLI 1.0.
|
|
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.113**; 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,3 +1,4 @@
|
|
|
1
|
+
import { isCarryName, isFixName, isOwnName, projectOfFix, releaseOfCarry } from '../chain/fix.js';
|
|
1
2
|
import { localStamp } from './dates.js';
|
|
2
3
|
import { STATUS_FRESH_MS } from './status.js';
|
|
3
4
|
import { BADGE_FIELDS, BADGE_VERSION } from './model.js';
|
|
@@ -9,7 +10,7 @@ export function badgeStateOf(state, project, inputs) {
|
|
|
9
10
|
const key = state.projectKeys[project] ?? project;
|
|
10
11
|
const tasks = state.tasks.filter((task) => task.project === project);
|
|
11
12
|
const chains = state.chain.active.filter((chain) => chain.project === project);
|
|
12
|
-
const active = chains.flatMap((chain) => (chain.current === null ? [] : [taskOf(state, chain.current, on, inputs)]));
|
|
13
|
+
const active = chains.flatMap((chain) => (chain.current === null ? [] : [taskOf(state, project, chain.current, on, inputs)]));
|
|
13
14
|
const order = state.chain.projects[project]?.order ?? [];
|
|
14
15
|
const working = new Set(active.map((task) => task.key));
|
|
15
16
|
const next = order.find((id) => !working.has(id)) ?? null;
|
|
@@ -19,7 +20,8 @@ export function badgeStateOf(state, project, inputs) {
|
|
|
19
20
|
if (on.has('chain'))
|
|
20
21
|
chain.tasks = chipsOf(tasks, active, order, closed, tz);
|
|
21
22
|
const result = { v: BADGE_VERSION, at: inputs.now.toISOString(), project: { key, name: state.config.projects[project]?.name ?? key }, active, chain };
|
|
22
|
-
|
|
23
|
+
// A fix or a carry has no tracker task and so no milestone (EKR-138): the chain's next task stands in for it.
|
|
24
|
+
const anchor = active.find((task) => !isOwnName(task.key))?.key ?? next ?? lastClosed(tasks, closed);
|
|
23
25
|
if (on.has('milestone'))
|
|
24
26
|
result.milestone = milestoneOf(tasks, anchor, new Set([...order, ...working]));
|
|
25
27
|
const stats = statsOf(inputs.stats, on);
|
|
@@ -33,7 +35,7 @@ export const ALL_BADGE_FIELDS = BADGE_FIELDS;
|
|
|
33
35
|
* A task on a spent limit (BTN-969) says only that and when the limit resets: no action, since the session makes no
|
|
34
36
|
* call, and nothing of the account. The chain going on earlier, on another account, is plain work again.
|
|
35
37
|
*/
|
|
36
|
-
function taskOf(state, current, on, inputs) {
|
|
38
|
+
function taskOf(state, project, current, on, inputs) {
|
|
37
39
|
const { titleEn } = inputs;
|
|
38
40
|
const { task: id, since } = current;
|
|
39
41
|
// A handed-over task's new session has no transcript yet: the task's earlier session must not stand in for it (BTN-1114).
|
|
@@ -44,7 +46,7 @@ function taskOf(state, current, on, inputs) {
|
|
|
44
46
|
const task = { key: id, state: limited ? 'limit' : waiting ? 'waiting' : 'working' };
|
|
45
47
|
if (hold !== undefined && hold.resetsAt !== null)
|
|
46
48
|
task.until = hold.resetsAt;
|
|
47
|
-
const title = on.has('title') ? titleEn?.(id) : undefined;
|
|
49
|
+
const title = on.has('title') ? (isCarryName(id) ? carryTitle(state, project, id) : isFixName(id) ? fixTitle(state, project, id) : titleEn?.(id)) : undefined;
|
|
48
50
|
if (title !== undefined && title.trim() !== '')
|
|
49
51
|
task.titleEn = title.trim();
|
|
50
52
|
if (session === undefined) {
|
|
@@ -66,6 +68,26 @@ function taskOf(state, current, on, inputs) {
|
|
|
66
68
|
}
|
|
67
69
|
return task;
|
|
68
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* A carry's own title (EKR-138), no translation: the release by the version in its project's branch (`release/v0.3`),
|
|
73
|
+
* or the branch itself, and the branch of `project` it goes into.
|
|
74
|
+
*/
|
|
75
|
+
function carryTitle(state, project, id) {
|
|
76
|
+
const into = state.config.projects[project]?.branch;
|
|
77
|
+
if (into === undefined)
|
|
78
|
+
return undefined;
|
|
79
|
+
const from = releaseOfCarry(state.projectKeys, id);
|
|
80
|
+
const branch = from === undefined ? undefined : state.config.projects[from]?.branch;
|
|
81
|
+
if (branch === undefined)
|
|
82
|
+
return `Carrying the release into ${into}`;
|
|
83
|
+
const version = /^v?(\d+(?:\.\d+)*)$/.exec(branch.split('/').at(-1) ?? '')?.[1];
|
|
84
|
+
return `Carrying ${version === undefined ? branch : `release v${version}`} into ${into}`;
|
|
85
|
+
}
|
|
86
|
+
/** A fix's own title (EKR-137), no translation: the red branch is the main branch of the project the fix is of. */
|
|
87
|
+
function fixTitle(state, project, id) {
|
|
88
|
+
const branch = state.config.projects[projectOfFix(state.projectKeys, id) ?? project]?.branch;
|
|
89
|
+
return branch === undefined ? 'Fixing the red main branch' : `Fixing the red ${branch}`;
|
|
90
|
+
}
|
|
69
91
|
/** The session's latest tool call as the badge may show it; a line of an agent without `badge` shows only its tool. */
|
|
70
92
|
function actionOf(session) {
|
|
71
93
|
const lines = session.action === null ? session.feed : [...session.feed, session.action];
|
package/dist/src/badge/render.js
CHANGED
|
@@ -154,8 +154,9 @@ function drawTask(draw, task, layout, base) {
|
|
|
154
154
|
if (task.titleEn !== undefined)
|
|
155
155
|
draw.text(x, base, fit(task.titleEn, 'sans-bold', titleSize, WIDTH - PAD - x - metaWidth), 'sans-bold', titleSize, theme.fg);
|
|
156
156
|
if (meta !== '') {
|
|
157
|
+
// Without a title a single task's agent line takes the title's place, not the line under an empty one (EKR-137).
|
|
157
158
|
if (single)
|
|
158
|
-
draw.text(x, base + 24, fit(meta, 'sans', 12.5, WIDTH - PAD - x), 'sans', 12.5, theme.fgMuted);
|
|
159
|
+
draw.text(x, task.titleEn === undefined ? base : base + 24, fit(meta, 'sans', 12.5, WIDTH - PAD - x), 'sans', 12.5, theme.fgMuted);
|
|
159
160
|
else
|
|
160
161
|
draw.text(WIDTH - PAD, base, meta, 'sans', 12, theme.fgMuted, ' text-anchor="end"');
|
|
161
162
|
}
|
|
@@ -341,8 +341,10 @@ export class SdkSessions {
|
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
/**
|
|
344
|
-
* A question, or a tool call to approve, waits for the user's reply
|
|
345
|
-
*
|
|
344
|
+
* A question, or a tool call to approve, waits for the user's reply. The CLI aborts the call when Remote Control
|
|
345
|
+
* answers it and when it stops waiting itself (its removal check gives a person two minutes, EKR-140): which one it was
|
|
346
|
+
* is the call's result in the transcript, where the chat and the tracker read it (`expiredApprovals`). An unattended
|
|
347
|
+
* chain has nobody to approve a call, so it is refused.
|
|
346
348
|
*/
|
|
347
349
|
permission(connection, tool, input, signal, toolUseID) {
|
|
348
350
|
if (tool !== ASK_TOOL && this.options.unattended())
|
|
@@ -369,7 +371,12 @@ export class SdkSessions {
|
|
|
369
371
|
};
|
|
370
372
|
connection.asks.set(id, pending);
|
|
371
373
|
connection.turn = { status: 'waiting', ask: pending.ask };
|
|
372
|
-
signal.addEventListener('abort', () =>
|
|
374
|
+
signal.addEventListener('abort', () => {
|
|
375
|
+
if (connection.asks.get(id) !== pending)
|
|
376
|
+
return;
|
|
377
|
+
this.options.log(`sessions: the CLI stopped waiting on the ${tool} question ${id}: Remote Control answered it, or its prompt timed out`);
|
|
378
|
+
pending.settle({ behavior: 'deny', message: 'The CLI stopped waiting for this answer.' });
|
|
379
|
+
}, { once: true });
|
|
373
380
|
return answer;
|
|
374
381
|
}
|
|
375
382
|
sdk() {
|
|
@@ -18,7 +18,7 @@ import { foldEvents } from './transcript.js';
|
|
|
18
18
|
import { withTurnError } from './errors.js';
|
|
19
19
|
const HISTORY_FEED = 5_000;
|
|
20
20
|
/** The version the README's "Before you run it" names; raised after the live run of each release (`docs/releases.md`). */
|
|
21
|
-
const CHECKED = '1.0.
|
|
21
|
+
const CHECKED = '1.0.113';
|
|
22
22
|
/**
|
|
23
23
|
* GitHub Copilot CLI through `copilot -p … --output-format json`: a turn is a detached process, as Codex's is; a session
|
|
24
24
|
* lives between turns in Even Keel's registry and the account folder's `session-state/<id>/events.jsonl`
|
package/dist/src/notice/en.js
CHANGED
|
@@ -44,6 +44,7 @@ export const en = {
|
|
|
44
44
|
'chain.limitsUnread': (p) => `Waiting for the first answer about the limits of the account ${p.account}: without it a spent limit looks free.${p.next === undefined ? '' : ` The next poll is at ${p.next}.`}`,
|
|
45
45
|
'chain.limitSpent': (p) => `chain: The usage limit is spent until ${p.until}${p.account === undefined ? '' : ` on ${p.provider ?? ''} account “${p.account}”`}. Wait for the reset, change the account in the project's pool under Project settings → Sessions, or the provider on the task's card.`,
|
|
46
46
|
'session.transient': () => 'waiting to retry',
|
|
47
|
+
'session.approvalExpired': (p) => `The question about the ${p.tool} call is closed: the CLI stopped waiting for an answer and refused the call itself, it did not run. The session goes on without it.`,
|
|
47
48
|
'session.transientRetry': (p) => `The model is temporarily unavailable. The dispatcher will retry this same session at ${p.at}. You can continue it now from the chat or start a new session.`,
|
|
48
49
|
'chain.noSession': (p) => `chain: no session of ${p.task} is known`,
|
|
49
50
|
'chain.noAccountFor': (p) => `chain: the run of ${p.task} is set to ${p.label}, but no account of that provider is in the pool; it runs on ${p.provider}, as its project does`,
|
|
@@ -123,6 +123,7 @@ export function wireTrackers(ctx) {
|
|
|
123
123
|
log: (line) => console.log(line),
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
|
+
const expiredOf = (view) => (view.expiredApprovals === undefined ? {} : { expired: view.expiredApprovals });
|
|
126
127
|
export function wireQuestions(ctx) {
|
|
127
128
|
return new TrackerQuestions({
|
|
128
129
|
sessions: () => {
|
|
@@ -131,13 +132,13 @@ export function wireQuestions(ctx) {
|
|
|
131
132
|
const view = sessionId == null ? undefined : ctx.liveView(chain.current.task);
|
|
132
133
|
if (view === undefined || view.sessionId !== sessionId || isOwnName(view.task))
|
|
133
134
|
return [];
|
|
134
|
-
return [{ project: chain.project, task: view.task, sessionId, ask: view.ask, current: true }];
|
|
135
|
+
return [{ project: chain.project, task: view.task, sessionId, ask: view.ask, current: true, ...expiredOf(view) }];
|
|
135
136
|
});
|
|
136
137
|
const aside = ctx.sessions.flatMap((view) => {
|
|
137
138
|
const project = ctx.configuredProject(view.task);
|
|
138
139
|
if (view.lamp === 'finished' || project === undefined || current.some((each) => each.sessionId === view.sessionId))
|
|
139
140
|
return [];
|
|
140
|
-
return [{ project, task: view.task, sessionId: view.sessionId, ask: view.ask, current: false }];
|
|
141
|
+
return [{ project, task: view.task, sessionId: view.sessionId, ask: view.ask, current: false, ...expiredOf(view) }];
|
|
141
142
|
});
|
|
142
143
|
return [...current, ...aside];
|
|
143
144
|
},
|
package/dist/src/sessions/ask.js
CHANGED
|
@@ -11,6 +11,7 @@ const TEXTS = {
|
|
|
11
11
|
: 'Ответьте комментарием: номер варианта (`2`), несколько через запятую (`1, 3`) или свой текст.',
|
|
12
12
|
chat: 'Ответ — в чате сессии на странице: заметка здесь сессии не дойдёт.',
|
|
13
13
|
answer: '**Ответ сессии**',
|
|
14
|
+
expired: '**Вопрос истёк**: CLI перестал ждать ответа и сам отказал, вызов не выполнен. Сессия продолжает без него; ответ на вопрос выше ей уже не дойдёт.',
|
|
14
15
|
},
|
|
15
16
|
en: {
|
|
16
17
|
lost: 'The question you asked through AskUserQuestion was lost when the session restarted:',
|
|
@@ -21,6 +22,7 @@ const TEXTS = {
|
|
|
21
22
|
: 'Reply with a comment: the option number (`2`), several separated by commas (`1, 3`), or your own text.',
|
|
22
23
|
chat: 'Answer in the session’s chat on the page: a note here does not reach the session.',
|
|
23
24
|
answer: '**Answer to the session**',
|
|
25
|
+
expired: '**The question expired**: the CLI stopped waiting for an answer and refused the call itself, it did not run. The session goes on without it; an answer to the question above no longer reaches it.',
|
|
24
26
|
},
|
|
25
27
|
};
|
|
26
28
|
/** The questions of an `AskUserQuestion` input; malformed questions and options are left out. */
|
|
@@ -227,6 +229,10 @@ export function questionComment(ask, language, journal = false) {
|
|
|
227
229
|
blocks.push(journal ? text.chat : text.how(several));
|
|
228
230
|
return blocks.join('\n\n');
|
|
229
231
|
}
|
|
232
|
+
/** The tracker comment after a question the CLI stopped waiting on (EKR-140): it is closed, no reply reaches the session. */
|
|
233
|
+
export function expiredComment(language) {
|
|
234
|
+
return TEXTS[language].expired;
|
|
235
|
+
}
|
|
230
236
|
/** `text` as a Markdown code block whose fence is longer than any backtick run inside it. */
|
|
231
237
|
function fenced(text) {
|
|
232
238
|
const longest = Math.max(0, ...[...text.matchAll(/`+/g)].map((run) => run[0].length));
|
|
@@ -239,6 +239,7 @@ function toView(task, { agent, runsOn, present, transcript, bridge }, remoteOf,
|
|
|
239
239
|
silentSince: present && agent.silentSince !== undefined ? new Date(agent.silentSince).toISOString() : null,
|
|
240
240
|
asking: ask !== null,
|
|
241
241
|
ask,
|
|
242
|
+
...((summary.expiredApprovals?.length ?? 0) > 0 && { expiredApprovals: summary.expiredApprovals }),
|
|
242
243
|
apiError: summary.apiError?.text ?? null,
|
|
243
244
|
apiErrorKind: summary.apiError?.kind ?? null,
|
|
244
245
|
...(summary.apiError?.notice === undefined ? {} : { apiErrorNotice: summary.apiError.notice }),
|
|
@@ -40,7 +40,8 @@ function cut(shown, text) {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* A tool call the CLI wants approved, put to the user as a question with two options (BTN-303): the first allows it,
|
|
43
|
-
* the second refuses it. The call itself is the preview of
|
|
43
|
+
* the second refuses it. The call itself is the preview of both — a command, or the input as JSON — so pointing at
|
|
44
|
+
* either keeps it in view (EKR-139). The input's
|
|
44
45
|
* `description` is the agent's own word on its call, so it follows the call in the preview, marked as the agent's,
|
|
45
46
|
* and never stands under the allowing option (BTN-1128).
|
|
46
47
|
*/
|
|
@@ -60,7 +61,7 @@ export function permissionAsk(id, tool, input, language) {
|
|
|
60
61
|
multiSelect: false,
|
|
61
62
|
options: [
|
|
62
63
|
{ label: text.allow, description: text.allowHint, preview },
|
|
63
|
-
{ label: text.deny, description: text.denyHint },
|
|
64
|
+
{ label: text.deny, description: text.denyHint, preview },
|
|
64
65
|
],
|
|
65
66
|
},
|
|
66
67
|
],
|
|
@@ -2,6 +2,7 @@ import { cloudErrorNotice } from '../account/cloud-errors.js';
|
|
|
2
2
|
import { badgeActionOf } from '../badge/action.js';
|
|
3
3
|
import { statusAsked, statusLineIn, statusTextOf, withoutStatusLine } from '../badge/status.js';
|
|
4
4
|
import { isSpendingLimit } from '../limits/spending.js';
|
|
5
|
+
import { notice } from '../notice/notice.js';
|
|
5
6
|
import { isTransientError } from './transient.js';
|
|
6
7
|
import { questionsOf, replyParts, toolAnswers } from './ask.js';
|
|
7
8
|
import { typedText } from './commandPrompt.js';
|
|
@@ -29,6 +30,9 @@ const NO_CHANGES_LINE = /^([`*_]*)NO CHANGES:([`*_]*)(.*)$/;
|
|
|
29
30
|
const TASK_DONE_LINE = /^([`*_]*)TASK DONE(?::|(?=[`*_]*$))([`*_]*)(.*)$/;
|
|
30
31
|
const CONTEXT_BLOCK = /^<([a-z][\w-]*)\b[^>]*>[\s\S]*<\/\1>$/;
|
|
31
32
|
const ASK_TOOL = 'AskUserQuestion';
|
|
33
|
+
/** CLI 2.1.3xx: "…and no person did (the permission prompt timed out, or none was shown)" — or "…this session cannot prompt". */
|
|
34
|
+
const EXPIRED_APPROVAL = /\bthe permission prompt timed out\b/;
|
|
35
|
+
const EXPIRED_KEPT = 10;
|
|
32
36
|
const SHELLS = new Set(['Bash', 'PowerShell']);
|
|
33
37
|
export const TTL_MS = { '5m': 5 * 60_000, '30m': 30 * 60_000, '1h': 60 * 60_000 };
|
|
34
38
|
const STAGE_RANK = { task: 0, recon: 1, edit: 2, test: 3, commit: 4, merge: 5 };
|
|
@@ -73,6 +77,10 @@ export class TranscriptFold {
|
|
|
73
77
|
backgroundCommand = null;
|
|
74
78
|
/** The tool lines of the turn's calls that have no result yet, by call id. */
|
|
75
79
|
runningTools = new Map();
|
|
80
|
+
/** The tool of each call that has no result yet, by call id: an expired approval names it. */
|
|
81
|
+
callTools = new Map();
|
|
82
|
+
/** The calls whose approval the CLI stopped waiting for, the latest last (EKR-140). */
|
|
83
|
+
expiredApprovals = [];
|
|
76
84
|
/** The CLI's queue of messages for the session, in order; `line` — `null` for one that is not the user's. */
|
|
77
85
|
queue = [];
|
|
78
86
|
/** `whole` keeps texts and prompts as written and adds shell commands to tool lines. */
|
|
@@ -177,6 +185,7 @@ export class TranscriptFold {
|
|
|
177
185
|
effort: this.effort,
|
|
178
186
|
badgeStatus: this.badgeStatus,
|
|
179
187
|
backgroundCommand: this.backgroundCommand,
|
|
188
|
+
expiredApprovals: [...this.expiredApprovals],
|
|
180
189
|
};
|
|
181
190
|
}
|
|
182
191
|
pushAssistant(entry) {
|
|
@@ -252,8 +261,10 @@ export class TranscriptFold {
|
|
|
252
261
|
const background = backgroundCommandOf(block.name, input);
|
|
253
262
|
if (background !== null)
|
|
254
263
|
this.backgroundCommand = background;
|
|
255
|
-
if (typeof block.id === 'string')
|
|
264
|
+
if (typeof block.id === 'string') {
|
|
256
265
|
this.runningTools.set(block.id, line.text);
|
|
266
|
+
this.callTools.set(block.id, block.name);
|
|
267
|
+
}
|
|
257
268
|
this.addAction(line);
|
|
258
269
|
this.advanceStage(stageOf(block.name, input));
|
|
259
270
|
}
|
|
@@ -266,9 +277,17 @@ export class TranscriptFold {
|
|
|
266
277
|
if (block.type !== 'tool_result' || typeof block.tool_use_id !== 'string')
|
|
267
278
|
continue;
|
|
268
279
|
this.runningTools.delete(block.tool_use_id);
|
|
280
|
+
const name = this.callTools.get(block.tool_use_id);
|
|
281
|
+
this.callTools.delete(block.tool_use_id);
|
|
282
|
+
const expired = block.is_error === true && isExpiredApproval(block.content);
|
|
283
|
+
if (expired)
|
|
284
|
+
this.expiredApprovals = [...this.expiredApprovals, block.tool_use_id].slice(-EXPIRED_KEPT);
|
|
269
285
|
// A question's error result is how a stop or a resume delivers its answer (BTN-220): the answer line tells the rest.
|
|
270
286
|
if (this.whole && block.is_error === true && block.tool_use_id !== this.openAsk?.id) {
|
|
271
|
-
|
|
287
|
+
const at = entry.timestamp ?? '';
|
|
288
|
+
this.addFeed({ at, kind: 'failed', text: failureText(block.content), tool: block.tool_use_id, ...(expired && { expired: true }) });
|
|
289
|
+
if (expired)
|
|
290
|
+
this.addFeed({ at, kind: 'error', text: '', notice: notice('session.approvalExpired', { tool: name ?? '?' }) });
|
|
272
291
|
}
|
|
273
292
|
}
|
|
274
293
|
const ask = this.openAsk;
|
|
@@ -298,6 +317,7 @@ export class TranscriptFold {
|
|
|
298
317
|
this.turnStartedAt = entry.timestamp ?? '';
|
|
299
318
|
this.statusAsked = false;
|
|
300
319
|
this.runningTools.clear();
|
|
320
|
+
this.callTools.clear();
|
|
301
321
|
if (entry.origin?.kind !== undefined && entry.origin.kind !== 'human')
|
|
302
322
|
return;
|
|
303
323
|
const answered = this.openAsk ?? this.strayAsk;
|
|
@@ -429,6 +449,13 @@ export function callFacts(name, input, size) {
|
|
|
429
449
|
const subject = subjectOf(name, input);
|
|
430
450
|
return { name, ...(subject === undefined ? {} : { subject }), ...size };
|
|
431
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* The CLI's own refusal of a call it held for a person's approval and gave up on (its removal check waits two minutes):
|
|
454
|
+
* the page's question closes with it, no answer from anywhere (EKR-140).
|
|
455
|
+
*/
|
|
456
|
+
export function isExpiredApproval(content) {
|
|
457
|
+
return EXPIRED_APPROVAL.test(failureText(content, Infinity));
|
|
458
|
+
}
|
|
432
459
|
/** The start of a failed call's output; the rest stays in the transcript. */
|
|
433
460
|
export function failureText(content, limit = ERROR_LIMIT) {
|
|
434
461
|
const text = typeof content === 'string' ? content : blocksOf(content).map((block) => block.text ?? '').join('\n');
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { isCopy } from '../intake/model.js';
|
|
2
2
|
import { englishOf, noticeOf } from '../notice/notice.js';
|
|
3
|
-
import { questionComment, trackerAnswers } from '../sessions/ask.js';
|
|
3
|
+
import { expiredComment, questionComment, trackerAnswers } from '../sessions/ask.js';
|
|
4
|
+
/** How long a question the session left is watched for the CLI's expiry: the transcript gets the call's result a moment later. */
|
|
5
|
+
const LEFT_WATCH_MS = 60_000;
|
|
4
6
|
const RETRIED = new Set(['answer.busy', 'chain.launching', 'chain.limitSpent', 'chain.notCurrent']);
|
|
5
7
|
const waitsOn = (session, question) => session.task === question.task && session.sessionId === question.sessionId && session.ask?.id === question.ask;
|
|
6
8
|
/**
|
|
7
9
|
* What to do on a tick: post the new questions of current tasks, read the replies to the open ones, forget those the
|
|
8
10
|
* session left. A question stays while its session waits on it, current or not, so a reply written meanwhile is read
|
|
9
|
-
* once the chain takes the task again.
|
|
11
|
+
* once the chain takes the task again. `left` — the questions the session no longer waits on.
|
|
10
12
|
*/
|
|
11
13
|
export function questionPlan(sessions, posted) {
|
|
12
14
|
const keep = posted.filter((each) => sessions.some((session) => waitsOn(session, each)));
|
|
15
|
+
const left = posted.filter((each) => !keep.includes(each));
|
|
13
16
|
const post = sessions.filter((session) => session.current && session.ask !== null && !keep.some((each) => each.task === session.task && each.ask === session.ask.id));
|
|
14
17
|
const read = keep.filter((each) => each.done !== true && sessions.some((session) => session.current && waitsOn(session, each)));
|
|
15
|
-
return { post, read, keep };
|
|
18
|
+
return { post, read, keep, left };
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
21
|
* The reply that comments after the question make: the first one answers the question, the rest go along as text.
|
|
@@ -43,6 +46,11 @@ export class TrackerQuestions {
|
|
|
43
46
|
* files (BTN-1020).
|
|
44
47
|
*/
|
|
45
48
|
seen = new Map();
|
|
49
|
+
/**
|
|
50
|
+
* The questions the session left, by comment, since when: the CLI aborts an expired approval as it does one Remote
|
|
51
|
+
* Control answered, and only the call's result in the transcript, which comes a moment later, tells them apart (EKR-140).
|
|
52
|
+
*/
|
|
53
|
+
leaving = new Map();
|
|
46
54
|
constructor(deps) {
|
|
47
55
|
this.deps = deps;
|
|
48
56
|
this.posted = deps.load();
|
|
@@ -59,6 +67,7 @@ export class TrackerQuestions {
|
|
|
59
67
|
for (const comment of this.seen.keys())
|
|
60
68
|
if (!plan.read.some((each) => each.comment === comment))
|
|
61
69
|
this.seen.delete(comment);
|
|
70
|
+
await this.watchLeft(plan.left, sessions);
|
|
62
71
|
for (const session of plan.post)
|
|
63
72
|
await this.post(session);
|
|
64
73
|
for (const question of plan.read)
|
|
@@ -68,6 +77,29 @@ export class TrackerQuestions {
|
|
|
68
77
|
this.running = false;
|
|
69
78
|
}
|
|
70
79
|
}
|
|
80
|
+
async watchLeft(left, sessions) {
|
|
81
|
+
const now = (this.deps.now ?? Date.now)();
|
|
82
|
+
for (const question of left)
|
|
83
|
+
this.leaving.set(question.comment, { question, since: now });
|
|
84
|
+
for (const [comment, { question, since }] of this.leaving) {
|
|
85
|
+
const session = sessions.find((each) => each.task === question.task && each.sessionId === question.sessionId);
|
|
86
|
+
if (session?.expired?.includes(question.ask) === true) {
|
|
87
|
+
this.leaving.delete(comment);
|
|
88
|
+
await this.postExpired(session, question);
|
|
89
|
+
}
|
|
90
|
+
else if (session === undefined || now - since > LEFT_WATCH_MS)
|
|
91
|
+
this.leaving.delete(comment);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async postExpired(session, question) {
|
|
95
|
+
try {
|
|
96
|
+
await this.deps.tracker(session.project, question.task, async (tracker) => tracker.comment?.(question.task, expiredComment(this.deps.language(session.project))));
|
|
97
|
+
this.deps.log(`tracker: ${question.task}: the CLI stopped waiting on the question ${question.comment}; the tracker is told it expired`);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
this.deps.log(`tracker: ${question.task}: the expiry of the question was not posted: ${englishOf(noticeOf(error))}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
71
103
|
async post(session) {
|
|
72
104
|
const ask = session.ask;
|
|
73
105
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{A as t,D as n,Ei as r,Lr as i,M as a,Nn as o,Pr as s,Rr as c,Xt as l,i as u,ki as d,pi as f,t as p,ut as m,v as h,xi as g,y as _}from"./blocks-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{A as t,D as n,Ei as r,Lr as i,M as a,Nn as o,Pr as s,Rr as c,Xt as l,i as u,ki as d,pi as f,t as p,ut as m,v as h,xi as g,y as _}from"./blocks-CrABcaPz.js";import{t as v}from"./react-dom-BrsVbrva.js";import{t as y}from"./secret-CmK85pY6.js";/* empty css */var b=e(d(),1),x=e(v(),1),S=[`title`,`agent`,`model`,`time`,`action`,`context`,`chain`,`milestone`,`sessions`,`medianCost`,`medianMinutes`],C=`EVEN_KEEL_BADGE_SECRET`,w=[{id:`tasks`,fields:[`agent`,`model`,`time`,`action`]},{id:`context`,fields:[`context`]},{id:`chain`,fields:[`chain`]},{id:`milestone`,fields:[`milestone`]},{id:`sessions`,fields:[`sessions`]},{id:`medianCost`,fields:[`medianCost`]},{id:`medianMinutes`,fields:[`medianMinutes`]},{id:`title`,fields:[`title`]}],T=(e,t)=>t.fields.every(t=>e.includes(t));function E(e,t,n){return S.filter(r=>t.fields.includes(r)?n:e.includes(r))}function D(e){let t=e.toLowerCase().replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64);return t===``?`project`:t}function O(e,t){return e??{on:!1,url:``,slug:D(t),fields:[...S]}}var k=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+(?::\d+)?\//;function A(e){let t=e.filter(e=>k.test(e.id)),n=t.find(e=>e.id.startsWith(`github.com/`))??t.find(e=>e.id.startsWith(`gitlab.`))??t[0];return n===void 0?null:`https://${n.id}${n.id.startsWith(`gitlab.`)?`/-/releases`:`/releases`}`}var j=e=>e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`);function M(e){let t=`${e.url.trim().replace(/\/+$/,``)}/${e.slug}.svg`,n=`<picture><source media="(prefers-color-scheme: light)" srcset="${j(`${t}?theme=light`)}"><img alt="${j(`${e.name}: what the chain is building now`)}" src="${j(`${t}?theme=dark`)}"></picture>`,r=e.releases.trim();return r===``?n:`<a href="${j(r)}">${n}</a>`}function N(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-badge-${n.getFullYear()}-${r(n.getMonth()+1)}-${r(n.getDate())}-${r(n.getHours())}${r(n.getMinutes())}-${t}.png`}var P=2;async function F(e){let t=await fetch(e);if(!t.ok)throw Error(`badge: the picture answered ${t.status}`);let n=URL.createObjectURL(new Blob([await t.text()],{type:`image/svg+xml`}));try{let e=new Image;e.src=n,await e.decode();let t=document.createElement(`canvas`);t.width=e.naturalWidth*P,t.height=e.naturalHeight*P;let r=t.getContext(`2d`);if(r===null)throw Error(`badge: no 2D canvas`);return r.drawImage(e,0,0,t.width,t.height),await new Promise((e,n)=>t.toBlob(t=>t===null?n(Error(`badge: the canvas gave no PNG`)):e(t),`image/png`))}finally{URL.revokeObjectURL(n)}}function I(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),setTimeout(()=>URL.revokeObjectURL(n),0)}var L=c(),R=`https://github.com/NamerekT/even-keel/blob/main/deploy/badge/README.md`,z=5e3;function B({state:e,project:n,onClose:r}){let i=(0,b.useRef)(null),c=h(i,r),l=(0,b.useId)();(0,b.useEffect)(()=>{i.current?.open===!1&&i.current.showModal()},[]);let u=e.projectKeys[n]??n,d=e.config.projects[n],m=O(d?.badge,u),_=o(e,n),v=s(),y=e=>v.send(`project/badge`,{project:n,badge:e});return(0,x.createPortal)((0,L.jsx)(`dialog`,{ref:i,className:`add-package add-package--wide badge-dialog`,"aria-labelledby":l,onCancel:e=>{e.preventDefault(),r()},...c,children:(0,L.jsxs)(`div`,{className:`add-package__frame`,children:[(0,L.jsxs)(`header`,{className:`add-package__head`,children:[(0,L.jsx)(`h2`,{id:l,className:`add-package__title`,children:g.badge.title(_)}),(0,L.jsx)(`button`,{type:`button`,className:`panel__close`,"aria-label":g.badge.close,onClick:r,children:`×`})]}),(0,L.jsxs)(`div`,{className:`add-package__body badge-dialog__body`,children:[v.failure!==null&&(0,L.jsx)(p,{tone:`error`,children:f(v.failure)}),(0,L.jsx)(V,{project:n,badge:m,state:e,disabled:v.sending,onSave:y}),(0,L.jsx)(t,{title:g.badge.show,hint:g.badge.showHint,children:w.map(e=>(0,L.jsx)(a,{className:`badge-dialog__field`,label:g.badge.groups[e.id],hint:g.badge.groupHints[e.id],checked:T(m.fields,e),disabled:v.sending,onChange:t=>void y({...m,fields:E(m.fields,e,t)})},e.id))}),(0,L.jsx)(G,{project:n,label:_,fields:m.fields.join(),slug:m.slug===``?D(u):m.slug}),(0,L.jsx)(K,{state:e,project:n,badge:m,name:d?.name??u})]}),(0,L.jsxs)(`footer`,{className:`add-package__foot`,children:[(0,L.jsx)(`span`,{className:`add-package__spacer`}),(0,L.jsx)(`button`,{type:`button`,className:`button button--primary`,onClick:r,children:g.badge.done})]})]})}),document.body)}function V({project:e,badge:n,state:o,disabled:s,onSave:c}){let{query:u}=i(),[d,h]=(0,b.useState)(!1),[_,v]=(0,b.useState)(null),y=H(n.url,e=>({...n,url:e}),e),x=H(n.slug,e=>({...n,slug:e}),e),S=y.value.trim()!==``&&x.value.trim()!==``,C=async()=>{h(!0),v(null);try{v(await u(`project/badge/check`,{project:e,url:y.value,slug:x.value}))}catch(e){v({ok:!1,notice:r(e)})}finally{h(!1)}},w=(0,L.jsxs)(`a`,{className:`badge-dialog__deploy`,href:R,target:`_blank`,rel:`noreferrer`,children:[g.badge.deploy,(0,L.jsx)(m,{})]});return(0,L.jsxs)(t,{title:g.badge.where,hint:g.badge.whereHint,aside:w,children:[(0,L.jsx)(a,{className:`badge-dialog__field`,label:g.badge.on,hint:g.badge.onHint,checked:n.on,disabled:s,onChange:e=>void c({...n,on:e})}),(0,L.jsx)(U,{wide:!0,label:g.badge.url,hint:g.badge.urlHint,field:y,placeholder:`https://even-keel-badge.example.workers.dev`}),(0,L.jsx)(U,{label:g.badge.slug,hint:g.badge.slugHint,field:x,placeholder:`project`}),(0,L.jsx)(W,{state:o}),(0,L.jsxs)(`div`,{className:`badge-dialog__check`,children:[(0,L.jsx)(l,{tip:S?g.badge.checkTip:g.badge.checkNeeds,inline:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`button`,"aria-disabled":!S||d,onClick:()=>S&&!d&&void C(),children:g.badge.check})}),_!==null&&(0,L.jsx)(p,{tone:_.ok?`note`:`error`,className:`badge-dialog__result`,children:f(_.notice)})]})]})}function H(e,t,n){let r=(0,b.useId)(),[i,a]=(0,b.useState)(e),[o,c]=(0,b.useState)(!1),{send:l,failure:u}=s();return(0,b.useEffect)(()=>{o||a(e)},[e,o]),{id:r,value:i,error:u,edit:e=>{c(!0),a(e)},commit:()=>{c(!1),i.trim()!==e&&l(`project/badge`,{project:n,badge:t(i.trim())})}}}function U({label:e,hint:t,field:r,placeholder:i,wide:a=!1}){return(0,L.jsx)(n,{className:`badge-dialog__field badge-dialog__field--${a?`wide`:`text`}`,label:e,hint:t,htmlFor:r.id,error:r.error,control:(0,L.jsx)(`input`,{id:r.id,className:`settings__text settings__text--mono`,autoComplete:`off`,spellCheck:!1,value:r.value,placeholder:i,"aria-invalid":r.error!==null,onChange:e=>r.edit(e.target.value),onBlur:r.commit,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),r.commit())}})})}function W({state:e}){let t=(0,b.useId)(),{send:r,sending:i,failure:a}=s(),[o,c]=(0,b.useState)(``),l=e.secrets.variables.find(e=>e.name===C),u=l?.set===!0,d=l?.outer===!0,f=async e=>{e.preventDefault(),o!==``&&await r(`secrets/set`,{name:`EVEN_KEEL_BADGE_SECRET`,value:o})&&c(``)};return(0,L.jsx)(n,{className:`badge-dialog__field badge-dialog__field--text`,label:g.badge.secret,hint:d?`${g.badge.secretHint}. ${g.badge.secretOuter}`:g.badge.secretHint,htmlFor:t,mark:!u&&(0,L.jsx)(`span`,{className:`chip packages__unset`,children:g.badge.secretUnset}),control:(0,L.jsx)(_,{error:a,children:(0,L.jsxs)(`form`,{className:`badge-dialog__secret`,onSubmit:e=>void f(e),children:[(0,L.jsx)(`input`,{id:t,className:`settings__text`,...y(),value:o,disabled:d,placeholder:u?g.badge.secretSaved:void 0,"aria-label":g.badge.secretValue,onChange:e=>c(e.target.value)}),(0,L.jsx)(`button`,{type:`submit`,className:`button button--small`,disabled:i||o===``||d,children:g.badge.save})]})})})}function G({project:e,label:n,fields:r,slug:a}){let{badgeUrl:o,state:s}=i(),[c,u]=(0,b.useState)(`dark`),[d,f]=(0,b.useState)(!1),[m,h]=(0,b.useState)(!1),_=async()=>{f(!0),h(!1);try{I(await F(o(e,c,!0)),N(a,c,new Date))}catch{h(!0)}finally{f(!1)}},[v,y]=(0,b.useState)(()=>Date.now()),x=(0,b.useRef)(v);(0,b.useEffect)(()=>{let e=Date.now();e-x.current<z||(x.current=e,y(e))},[s]),(0,b.useEffect)(()=>{x.current=Date.now(),y(x.current)},[r]);let S=o(e,c),C=S.startsWith(`data:`)?S:`${S}&at=${v}`,w=(0,L.jsx)(`div`,{className:`segmented`,role:`group`,"aria-label":g.badge.preview,children:[`dark`,`light`].map(e=>(0,L.jsx)(`button`,{type:`button`,className:c===e?`segmented__item segmented__item--on`:`segmented__item`,"aria-pressed":c===e,onClick:()=>u(e),children:g.badge[e]},e))});return(0,L.jsxs)(t,{title:g.badge.preview,hint:g.badge.previewHint,aside:w,children:[(0,L.jsx)(`div`,{className:`badge-dialog__preview badge-dialog__preview--${c}`,children:(0,L.jsx)(`img`,{src:C,alt:g.badge.previewAlt(n)})}),(0,L.jsxs)(`div`,{className:`badge-dialog__check`,children:[(0,L.jsx)(l,{tip:g.badge.pngTip,inline:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`button`,"aria-disabled":d,onClick:()=>!d&&void _(),children:g.badge.png})}),m&&(0,L.jsx)(p,{tone:`error`,className:`badge-dialog__result`,children:g.badge.pngFailed})]})]})}function K({state:e,project:r,badge:i,name:a}){let o=(0,b.useId)(),s=A(e.remotes[r]??[]),[c,l]=(0,b.useState)(null),d=c??s??``,f=i.url!==``&&i.slug!==``;return(0,L.jsxs)(t,{title:g.badge.markdown,hint:g.badge.markdownHint,children:[(0,L.jsx)(n,{className:`badge-dialog__field badge-dialog__field--wide`,label:g.badge.releases,hint:g.badge.releasesHint,htmlFor:o,control:(0,L.jsx)(`input`,{id:o,className:`settings__text settings__text--mono`,autoComplete:`off`,spellCheck:!1,value:d,placeholder:`https://github.com/owner/repo/releases`,onChange:e=>l(e.target.value)})}),f?(0,L.jsx)(u,{className:`badge-dialog__markdown`,command:M({url:i.url,slug:i.slug,name:a,releases:d})}):(0,L.jsx)(`p`,{className:`badge-dialog__needs`,children:g.badge.markdownNeeds})]})}export{B as BadgeDialog};
|