ai-agentmanager 1.26.0 → 1.26.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.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/public/index.html +2 -1
- package/public/issues.js +2 -1
- package/public/menu.js +26 -2
- package/public/style.css +1 -0
- package/public/today.js +5 -5
- package/src/issues.js +10 -3
- package/src/jira.js +71 -13
- package/src/manager.js +3 -2
- package/src/server.js +33 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.26.1 (2026-11-07)
|
|
4
|
+
|
|
5
|
+
- **Jira says why it isn't working.** When your Jira site can't be used (the token isn't accepted, the site sends a sign-in page, it can't be reached), the Jira list and Today say so in words instead of just showing no summaries or statuses. Settings → Jira has a **Check Jira** button that asks the site for your open issues and says how many it found, or why it couldn't.
|
|
6
|
+
- **Jira Server and Data Center.** With no email, the API token is sent as a personal access token, and the older API those sites have is used when Jira Cloud's isn't there. The site address may have a port and a path (`https://jira.company.com:8443/jira`).
|
|
7
|
+
- **Skip, Done and Remove work on every issue in the list.** Before, an issue listed through its agent, whose request named it after other words rather than starting with its link, could fail with "not on the list".
|
|
8
|
+
- **↻ asks Jira again.** Refreshing the Jira list or Today fetches statuses again rather than using those from the last few minutes.
|
|
9
|
+
|
|
3
10
|
## 1.26.0 (2026-11-07)
|
|
4
11
|
|
|
5
12
|
- **Today: what needs you, in one list.** The Today button (or `y`) gathers what the other lists know and puts the most pressing first: agents stopped at a prompt or waiting for your answer, overdue and due-today action items, issues and pull requests ready for your review, review requests, then the rest (actions due later, new Jira issues, stuck agents, follow-ups). Each says why it's there ("due today · asked by Pat · in Slack", "Blocked: staging credentials"), and the usual decision is a click or a key away: Done, Skip and Discuss for actions, Assign for new issues, Review it for a requested pull request, Open for the rest. Listen reads the top of it aloud. Lists turned off in Settings are left out. The button's count is the pressing ones.
|
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -873,12 +873,13 @@
|
|
|
873
873
|
</fieldset>
|
|
874
874
|
<fieldset class="local-only">
|
|
875
875
|
<legend>Jira</legend>
|
|
876
|
-
<p class="hint">For an agent created from a Jira link, its description shows the issue's summary. Public issues on Atlassian Cloud need nothing here; for your company's site, add it with your email and an <a href="https://id.atlassian.com/manage-profile/security/api-tokens" target="_blank" rel="noopener">API token</a
|
|
876
|
+
<p class="hint">For an agent created from a Jira link, its description shows the issue's summary. Public issues on Atlassian Cloud need nothing here; for your company's site, add it with your email and an <a href="https://id.atlassian.com/manage-profile/security/api-tokens" target="_blank" rel="noopener">API token</a> (Jira Server or Data Center: leave the email empty and use a personal access token). The token is kept on this computer and sent only to that site.</p>
|
|
877
877
|
<div class="row three">
|
|
878
878
|
<label>Site <input name="jiraSite" placeholder="https://yourcompany.atlassian.net" autocomplete="off" /></label>
|
|
879
879
|
<label>Email <input name="jiraEmail" type="email" autocomplete="off" /></label>
|
|
880
880
|
<label>API token <input name="jiraToken" type="password" autocomplete="new-password" /></label>
|
|
881
881
|
</div>
|
|
882
|
+
<p><button type="button" class="small" data-jira-check title="Ask your Jira site for the open issues assigned to you, with the saved settings">Check Jira</button> <span class="hint" data-jira-result></span></p>
|
|
882
883
|
</fieldset>
|
|
883
884
|
<fieldset>
|
|
884
885
|
<legend>Updates</legend>
|
package/public/issues.js
CHANGED
|
@@ -77,7 +77,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
function aboutIssue(r) {
|
|
80
|
-
const missing = data?.jira?.signedIn ? 'Summary not fetched from Jira yet' : 'Summary shows once your Jira site, email and API token are in Settings → Jira';
|
|
80
|
+
const missing = data?.jira?.problem ? 'No summary: Jira can’t be used (see above)' : data?.jira?.signedIn ? 'Summary not fetched from Jira yet' : 'Summary shows once your Jira site, email and API token are in Settings → Jira';
|
|
81
81
|
return `${r.title ? `<div class="issue-title">${esc(r.title)}</div>` : `<div class="hint issue-title">${esc(missing)}</div>`}${r.synopsis ? `<div class="issue-synopsis" title="${esc(r.synopsis)}">${esc(r.synopsis)}</div>` : ''}`;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -172,6 +172,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
172
172
|
<span class="hint">Tick the issues to start agents for; the rest stay here.</span>
|
|
173
173
|
</div>`
|
|
174
174
|
: ''}
|
|
175
|
+
${data.jira?.problem ? `<p class="issues-problem" role="alert">Jira: ${esc(data.jira.problem)}. Summaries, statuses and the issues assigned to you need it; try <b>Check Jira</b> in Settings → Jira.</p>` : ''}
|
|
175
176
|
${rows.length
|
|
176
177
|
? `<div class="issues-scroll"><table class="issues">
|
|
177
178
|
<thead><tr>${boxes ? `<th class="pick"><input type="checkbox" data-issue-pick-all ${allTicked ? 'checked' : ''} aria-label="Tick all" title="Tick all" /></th>` : ''}<th class="issue-action" title="Your action, kept across restarts and updates">Action</th><th>Issue</th><th>Jira status</th><th>Where it stands</th><th>Plan</th><th>Design</th><th>Pull request</th><th>Agent</th><th class="col-active">Active</th></tr></thead>
|
package/public/menu.js
CHANGED
|
@@ -107,6 +107,7 @@ export function initMenu({ api, esc, toast, $ }) {
|
|
|
107
107
|
form.jiraEmail.value = jira?.email ?? '';
|
|
108
108
|
form.jiraToken.value = '';
|
|
109
109
|
form.jiraToken.placeholder = jira?.hasToken ? 'saved (type to replace)' : '';
|
|
110
|
+
dialog.querySelector('[data-jira-result]').textContent = '';
|
|
110
111
|
containers = await api('GET', '/isolation').catch(() => null);
|
|
111
112
|
showContainers();
|
|
112
113
|
form.claudeToken.value = '';
|
|
@@ -146,6 +147,29 @@ export function initMenu({ api, esc, toast, $ }) {
|
|
|
146
147
|
dialog.close();
|
|
147
148
|
$(`#${go.dataset.open}`).click();
|
|
148
149
|
});
|
|
150
|
+
// Check Jira: saves what was typed, then asks the site for your open issues.
|
|
151
|
+
dialog.addEventListener('click', async (e) => {
|
|
152
|
+
const b = e.target.closest('[data-jira-check]');
|
|
153
|
+
if (!b) return;
|
|
154
|
+
const out = dialog.querySelector('[data-jira-result]');
|
|
155
|
+
b.disabled = true;
|
|
156
|
+
out.textContent = 'Asking Jira…';
|
|
157
|
+
try {
|
|
158
|
+
const typed = { site: form.jiraSite.value.trim(), email: form.jiraEmail.value.trim(), token: form.jiraToken.value.trim() || undefined };
|
|
159
|
+
const changed = jira && (typed.site !== (jira.site ?? '') || typed.email !== (jira.email ?? '') || typed.token);
|
|
160
|
+
const r = changed ? await api('PUT', '/jira', typed) : await api('GET', '/jira/check');
|
|
161
|
+
if (changed) {
|
|
162
|
+
jira = { site: r.site, email: r.email, hasToken: r.hasToken };
|
|
163
|
+
form.jiraToken.value = '';
|
|
164
|
+
form.jiraToken.placeholder = r.hasToken ? 'saved (type to replace)' : '';
|
|
165
|
+
}
|
|
166
|
+
out.textContent = r.problem ? `Not working: ${r.problem}` : `Works: ${r.assigned} open issue${r.assigned === 1 ? '' : 's'} assigned to you`;
|
|
167
|
+
} catch (err) {
|
|
168
|
+
out.textContent = err.message;
|
|
169
|
+
} finally {
|
|
170
|
+
b.disabled = false;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
149
173
|
form.addEventListener('submit', async (e) => {
|
|
150
174
|
e.preventDefault();
|
|
151
175
|
try {
|
|
@@ -159,8 +183,8 @@ export function initMenu({ api, esc, toast, $ }) {
|
|
|
159
183
|
}
|
|
160
184
|
}
|
|
161
185
|
if (!remote() && jira && (form.jiraSite.value.trim() !== (jira.site ?? '') || form.jiraEmail.value.trim() !== (jira.email ?? '') || form.jiraToken.value.trim())) {
|
|
162
|
-
await api('PUT', '/jira', { site: form.jiraSite.value.trim(), email: form.jiraEmail.value.trim(), token: form.jiraToken.value.trim() || undefined });
|
|
163
|
-
toast(
|
|
186
|
+
const j = await api('PUT', '/jira', { site: form.jiraSite.value.trim(), email: form.jiraEmail.value.trim(), token: form.jiraToken.value.trim() || undefined });
|
|
187
|
+
toast(j.problem ? `Jira saved, but it doesn't work yet: ${j.problem}` : j.assigned !== null && j.assigned !== undefined ? `Jira works: ${j.assigned} open issue${j.assigned === 1 ? '' : 's'} assigned to you` : 'Jira saved', j.problem ? 10_000 : 4000);
|
|
164
188
|
}
|
|
165
189
|
if (!remote() && containers?.available) {
|
|
166
190
|
if (form.claudeToken.value.trim()) await api('PUT', '/isolation/token', { token: form.claudeToken.value.trim() });
|
package/public/style.css
CHANGED
|
@@ -1175,6 +1175,7 @@ table.issues .dot { display: inline-block; width: 7px; height: 7px; border-radiu
|
|
|
1175
1175
|
table.issues .dot.busy { background: var(--green); }
|
|
1176
1176
|
table.issues .dot.idle { background: var(--muted); }
|
|
1177
1177
|
.issues-empty { padding: 24px 4px; }
|
|
1178
|
+
.issues-problem { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--red); color: var(--red); font-size: 13px; }
|
|
1178
1179
|
@media (max-width: 640px) {
|
|
1179
1180
|
.issues-dialog { width: calc(100% - 32px); padding: 12px; }
|
|
1180
1181
|
table.issues .col-active { display: none; }
|
package/public/today.js
CHANGED
|
@@ -18,11 +18,11 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
|
|
|
18
18
|
let again = null;
|
|
19
19
|
let loadedAt = 0;
|
|
20
20
|
|
|
21
|
-
async function load({ quiet = false } = {}) {
|
|
21
|
+
async function load({ quiet = false, fresh = false } = {}) {
|
|
22
22
|
if (loading) return;
|
|
23
23
|
loading = true;
|
|
24
24
|
try {
|
|
25
|
-
data = await api('GET',
|
|
25
|
+
data = await api('GET', `/today${fresh ? '?fresh=1' : ''}`);
|
|
26
26
|
loadedAt = Date.now();
|
|
27
27
|
} catch (e) {
|
|
28
28
|
if (!quiet) toast?.(e.message, 5000);
|
|
@@ -85,7 +85,7 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
|
|
|
85
85
|
${items.length
|
|
86
86
|
? `<div class="issues-scroll"><table class="issues today-table"><tbody>${items.map(row).join('')}</tbody></table></div>`
|
|
87
87
|
: '<p class="hint issues-empty">Nothing needs you right now: no agent is waiting on you, nothing is due, and no review is waiting.</p>'}
|
|
88
|
-
<p class="hint">Keys: j/k move (or click a row), Enter opens, a assign or review, d done, s skip, c discuss, r look again, f bigger.${off.length ? ` Not included (off in Settings → What you use): ${esc(off.join(', '))}.` : ''}${data.errors?.length ? ` Couldn't get: ${esc(data.errors.map((e) => e.source).join('
|
|
88
|
+
<p class="hint">Keys: j/k move (or click a row), Enter opens, a assign or review, d done, s skip, c discuss, r look again, f bigger.${off.length ? ` Not included (off in Settings → What you use): ${esc(off.join(', '))}.` : ''}${data.errors?.length ? ` Couldn't get: ${esc(data.errors.map((e) => `${e.source === 'jira' ? 'Jira' : e.source} (${e.error})`).join('; '))}.` : ''}</p>`;
|
|
89
89
|
keys.redraw();
|
|
90
90
|
}
|
|
91
91
|
const render = holdWhilePicking(body, draw);
|
|
@@ -151,7 +151,7 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
|
|
|
151
151
|
d: (r) => act(itemOf(r.dataset.rowId), 'done'),
|
|
152
152
|
s: (r) => act(itemOf(r.dataset.rowId), 'skip'),
|
|
153
153
|
c: (r) => act(itemOf(r.dataset.rowId), 'discuss'),
|
|
154
|
-
r: Object.assign(() => load(), { needsRow: false }),
|
|
154
|
+
r: Object.assign(() => load({ fresh: true }), { needsRow: false }),
|
|
155
155
|
},
|
|
156
156
|
});
|
|
157
157
|
|
|
@@ -159,7 +159,7 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
|
|
|
159
159
|
const b = e.target.closest('[data-today]')?.dataset.today;
|
|
160
160
|
if (!b) return;
|
|
161
161
|
if (b === 'close') return dialog.close();
|
|
162
|
-
if (b === 'refresh') return load();
|
|
162
|
+
if (b === 'refresh') return load({ fresh: true });
|
|
163
163
|
act(itemOf(e.target.closest('tr[data-row-id]')?.dataset.rowId), b);
|
|
164
164
|
});
|
|
165
165
|
|
package/src/issues.js
CHANGED
|
@@ -282,8 +282,9 @@ export class ProposedIssues {
|
|
|
282
282
|
let p = this.all.find((x) => x.key === key);
|
|
283
283
|
let agent = this.agentFor(key);
|
|
284
284
|
const mine = !p && !agent ? (this.manager.assignedNow ?? []).find((i) => i.key === key) : null;
|
|
285
|
-
|
|
286
|
-
|
|
285
|
+
// Skip, done, remove and clear are kept by key, whatever listed the issue; assign needs where to start from.
|
|
286
|
+
if (!p && !agent && !mine && (action === 'assign' || !ISSUE_KEY.test(key))) {
|
|
287
|
+
failed.push({ key, reason: action === 'assign' ? "can't start an agent: no link for it (Jira didn't list it; is Settings → Jira working?)" : 'not an issue key' });
|
|
287
288
|
continue;
|
|
288
289
|
}
|
|
289
290
|
// An issue assigned to you in Jira: assigning it makes the request from its link and summary.
|
|
@@ -319,7 +320,13 @@ export class ProposedIssues {
|
|
|
319
320
|
|
|
320
321
|
agentFor(key) {
|
|
321
322
|
const k = key.toLowerCase();
|
|
322
|
-
|
|
323
|
+
const list = this.store.list();
|
|
324
|
+
return (
|
|
325
|
+
list.find((a) => a.kind === 'task' && (a.name.toLowerCase() === k || leadingJiraKey(a.intent)?.toLowerCase() === k)) ??
|
|
326
|
+
// The agent the Jira list shows on the issue: its request may name the issue later on, not lead with the link.
|
|
327
|
+
list.find((a) => a.kind !== 'assistant' && issueOf({ ...a, bugs: Object.values(a.bugs ?? {}) })?.key.toLowerCase() === k) ??
|
|
328
|
+
null
|
|
329
|
+
);
|
|
323
330
|
}
|
|
324
331
|
|
|
325
332
|
/** Propose an issue: the request starts with its link. */
|
package/src/jira.js
CHANGED
|
@@ -42,7 +42,7 @@ export function saveJira({ site, email, token, clearToken = false } = {}) {
|
|
|
42
42
|
email: email === undefined ? cur.email ?? '' : String(email).trim(),
|
|
43
43
|
token: clearToken ? '' : token ? String(token).trim() : cur.token ?? '',
|
|
44
44
|
};
|
|
45
|
-
if (next.site && !/^https:\/\/[\w.-]
|
|
45
|
+
if (next.site && !/^https:\/\/[\w.-]+(:\d+)?(\/[\w.~-]+)*$/.test(next.site)) throw Object.assign(new Error('The Jira site is an https address, like https://yourcompany.atlassian.net (or https://jira.yourcompany.com:8443/jira)'), { status: 400 });
|
|
46
46
|
fs.mkdirSync(paths.home, { recursive: true });
|
|
47
47
|
fs.writeFileSync(file(), JSON.stringify(next, null, 2) + '\n', { mode: 0o600 });
|
|
48
48
|
return jiraView(loadJira());
|
|
@@ -75,18 +75,67 @@ export function wordsAfterLink(text) {
|
|
|
75
75
|
// Statuses that mean the work is over, whatever category a workflow puts them in.
|
|
76
76
|
const FINISHED = /^(closed|done|resolved|integrated|cancell?ed|won'?t (do|fix)|duplicate|rejected)$/i;
|
|
77
77
|
|
|
78
|
+
// Why the last call to your Jira site failed ({ at, reason }), or null when it worked: shown in
|
|
79
|
+
// the Jira list and Today, since an empty list alone doesn't say whether Jira was reached.
|
|
80
|
+
let problem = null;
|
|
81
|
+
|
|
82
|
+
/** Why your Jira site couldn't be used last time, or null. */
|
|
83
|
+
export const jiraProblem = () => problem;
|
|
84
|
+
|
|
85
|
+
/** Basic with the email and API token (Jira Cloud); a bearer token without an email (Server, Data Center). */
|
|
86
|
+
const authOf = (jira) => (jira.email ? `Basic ${Buffer.from(`${jira.email}:${jira.token}`).toString('base64')}` : `Bearer ${jira.token}`);
|
|
87
|
+
|
|
88
|
+
/** The reason in words for an answer that isn't ok, or a fetch that threw. */
|
|
89
|
+
function reasonOf(site, res, e) {
|
|
90
|
+
if (res) {
|
|
91
|
+
const why = {
|
|
92
|
+
401: 'the email or API token is not accepted (Settings → Jira)',
|
|
93
|
+
403: 'no permission; if you mistyped the token a few times, Jira may want you to sign in once in the browser',
|
|
94
|
+
404: 'no Jira API at that address (is the site right?)',
|
|
95
|
+
429: 'too many requests; trying again later',
|
|
96
|
+
}[res.status];
|
|
97
|
+
return `${site} answered ${res.status}${why ? `: ${why}` : ''}`;
|
|
98
|
+
}
|
|
99
|
+
const m = String(e?.cause?.message ?? e?.message ?? e ?? '');
|
|
100
|
+
if (e?.name === 'TimeoutError' || /abort|timeout/i.test(m)) return `${site} did not answer in time (VPN off?)`;
|
|
101
|
+
if (/redirect/i.test(m)) return `${site} sent a sign-in page instead of an answer (the site address may be wrong, or it needs single sign-on)`;
|
|
102
|
+
return `couldn't reach ${site}: ${m || 'network error'}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Jira Cloud's API (v3), then the older one (v2) that Jira Server and Data Center have when v3
|
|
107
|
+
* isn't there. Returns the response, or throws.
|
|
108
|
+
*/
|
|
109
|
+
async function jiraGet(fetchImpl, site, v3, v2, init) {
|
|
110
|
+
const res = await fetchImpl(`${site}${v3.path}`, { ...init, ...v3.init });
|
|
111
|
+
if (res.status !== 404 || !v2) return res;
|
|
112
|
+
return fetchImpl(`${site}${v2.path}`, { ...init, ...v2.init });
|
|
113
|
+
}
|
|
114
|
+
|
|
78
115
|
/**
|
|
79
116
|
* Open issues assigned to you on your Jira site (epics too): [{ key, url, summary, status,
|
|
80
|
-
* category, type, synopsis, updated }]. Needs the site
|
|
81
|
-
* null without them or when Jira can't be reached
|
|
117
|
+
* category, type, synopsis, updated }]. Needs the site and API token from Settings → Jira (and the
|
|
118
|
+
* email, for Jira Cloud); null without them or when Jira can't be reached (jiraProblem() says why).
|
|
119
|
+
* Closed and integrated ones are left out.
|
|
82
120
|
*/
|
|
83
121
|
export async function assignedIssues({ jira = loadJira(), fetchImpl = fetch, timeoutMs = 10_000, max = 100 } = {}) {
|
|
84
|
-
if (!jira.site || !jira.
|
|
85
|
-
const headers = { accept: 'application/json', 'content-type': 'application/json', authorization:
|
|
86
|
-
const
|
|
122
|
+
if (!jira.site || !jira.token) return null;
|
|
123
|
+
const headers = { accept: 'application/json', 'content-type': 'application/json', authorization: authOf(jira) };
|
|
124
|
+
const jql = 'assignee = currentUser() AND statusCategory != Done ORDER BY updated DESC';
|
|
125
|
+
const fields = ['summary', 'status', 'issuetype', 'description', 'updated'];
|
|
126
|
+
const q = new URLSearchParams({ jql, fields: fields.join(','), maxResults: String(max) });
|
|
87
127
|
try {
|
|
88
|
-
const res = await
|
|
89
|
-
|
|
128
|
+
const res = await jiraGet(
|
|
129
|
+
fetchImpl,
|
|
130
|
+
jira.site,
|
|
131
|
+
{ path: '/rest/api/3/search/jql', init: { method: 'POST', body: JSON.stringify({ jql, fields, maxResults: max }) } },
|
|
132
|
+
{ path: `/rest/api/2/search?${q}`, init: { method: 'GET' } },
|
|
133
|
+
{ headers, redirect: 'error', signal: AbortSignal.timeout(timeoutMs) },
|
|
134
|
+
);
|
|
135
|
+
if (!res.ok) {
|
|
136
|
+
problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, res) };
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
90
139
|
const out = [];
|
|
91
140
|
for (const i of (await res.json())?.issues ?? []) {
|
|
92
141
|
const f = i?.fields ?? {};
|
|
@@ -104,8 +153,10 @@ export async function assignedIssues({ jira = loadJira(), fetchImpl = fetch, tim
|
|
|
104
153
|
updated: typeof f.updated === 'string' ? f.updated : null,
|
|
105
154
|
});
|
|
106
155
|
}
|
|
156
|
+
problem = null;
|
|
107
157
|
return out;
|
|
108
|
-
} catch {
|
|
158
|
+
} catch (e) {
|
|
159
|
+
problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, null, e) };
|
|
109
160
|
return null;
|
|
110
161
|
}
|
|
111
162
|
}
|
|
@@ -168,17 +219,24 @@ export async function issueFields({ key, site }, { jira = loadJira(), fetchImpl
|
|
|
168
219
|
const allowed = configured || /\.atlassian\.net$/.test(host) || allow?.(site);
|
|
169
220
|
if (!allowed) return null;
|
|
170
221
|
const headers = { accept: 'application/json' };
|
|
171
|
-
if (configured && jira.
|
|
222
|
+
if (configured && jira.token) headers.authorization = authOf(jira);
|
|
223
|
+
const q = `${encodeURIComponent(key)}?fields=summary,status,description`;
|
|
172
224
|
try {
|
|
173
|
-
|
|
174
|
-
|
|
225
|
+
// Your site as saved: it may have a path (https://host/jira) that the link's origin leaves out.
|
|
226
|
+
const res = await jiraGet(fetchImpl, configured ? jira.site : site, { path: `/rest/api/3/issue/${q}` }, configured ? { path: `/rest/api/2/issue/${q}` } : null, { headers, redirect: 'error', signal: AbortSignal.timeout(timeoutMs) });
|
|
227
|
+
if (!res.ok) {
|
|
228
|
+
// Your own site refusing (not a missing issue) is worth saying.
|
|
229
|
+
if (configured && res.status !== 404) problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, res) };
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
175
232
|
const f = (await res.json())?.fields ?? {};
|
|
176
233
|
const summary = typeof f.summary === 'string' && f.summary.trim() ? f.summary.trim().slice(0, 300) : null;
|
|
177
234
|
const status = typeof f.status?.name === 'string' ? f.status.name.slice(0, 60) : null;
|
|
178
235
|
if (!summary && !status) return null;
|
|
179
236
|
const synopsis = synopsisOf(f.description);
|
|
180
237
|
return { summary, status, category: typeof f.status?.statusCategory?.key === 'string' ? f.status.statusCategory.key : null, ...(synopsis ? { synopsis } : {}) };
|
|
181
|
-
} catch {
|
|
238
|
+
} catch (e) {
|
|
239
|
+
if (configured) problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, null, e) };
|
|
182
240
|
return null;
|
|
183
241
|
}
|
|
184
242
|
}
|
package/src/manager.js
CHANGED
|
@@ -107,7 +107,7 @@ import { spawn } from 'node:child_process';
|
|
|
107
107
|
import * as git from './git.js';
|
|
108
108
|
import { buildMap, touchedFiles } from './codemap.js';
|
|
109
109
|
import { parseDiff } from '../public/review.js';
|
|
110
|
-
import { assignedIssues, issueFields, issueSummary, leadingIssue, loadJira, wordsAfterLink } from './jira.js';
|
|
110
|
+
import { assignedIssues, issueFields, issueSummary, jiraProblem, leadingIssue, loadJira, wordsAfterLink } from './jira.js';
|
|
111
111
|
import { issueRows } from './issues.js';
|
|
112
112
|
import { designRows } from './designs.js';
|
|
113
113
|
import { reviewPath, reviewerPrompt } from './reviews.js';
|
|
@@ -869,7 +869,7 @@ export class AgentManager extends EventEmitter {
|
|
|
869
869
|
}
|
|
870
870
|
for (const [k, v] of jira) if (!v) jira.delete(k);
|
|
871
871
|
const j = loadJira();
|
|
872
|
-
return { rows: issueRows(views, jira, (id, name) => readSpecDoc(id, name)?.markdown ?? null, proposed, actions, assigned), jira: { site: j.site, signedIn: Boolean(j.site && j.
|
|
872
|
+
return { rows: issueRows(views, jira, (id, name) => readSpecDoc(id, name)?.markdown ?? null, proposed, actions, assigned), jira: { site: j.site, signedIn: Boolean(j.site && j.token), problem: j.site && j.token ? jiraProblem()?.reason ?? null : null } };
|
|
873
873
|
}
|
|
874
874
|
|
|
875
875
|
/** Every agent's design doc, for the Designs list. */
|
|
@@ -893,6 +893,7 @@ export class AgentManager extends EventEmitter {
|
|
|
893
893
|
/** Fill in summaries still missing (after Jira settings change); returns how many it found. */
|
|
894
894
|
async refreshSynopses() {
|
|
895
895
|
this.jiraCache?.clear();
|
|
896
|
+
this.assignedAt = 0;
|
|
896
897
|
let found = 0;
|
|
897
898
|
for (const a of this.store.list()) {
|
|
898
899
|
if (a.synopsis?.source === 'jira' || !leadingIssue(a.intent)) continue;
|
package/src/server.js
CHANGED
|
@@ -39,7 +39,7 @@ import { Previews, parseUrl } from './preview.js';
|
|
|
39
39
|
import { LiveBrowser } from './livebrowser.js';
|
|
40
40
|
import * as remote from './remote.js';
|
|
41
41
|
import * as service from './service.js';
|
|
42
|
-
import { jiraView, saveJira } from './jira.js';
|
|
42
|
+
import { assignedIssues, jiraProblem, jiraView, saveJira } from './jira.js';
|
|
43
43
|
import { ProposedIssues, issuesMarkdown } from './issues.js';
|
|
44
44
|
import { MyActions } from './actions.js';
|
|
45
45
|
import { designsMarkdown } from './designs.js';
|
|
@@ -78,7 +78,7 @@ function isAllowedOrigin(origin, port) {
|
|
|
78
78
|
const PUBLIC_REMOTE_API = new Set(['POST /api/login', 'GET /api/session']);
|
|
79
79
|
// Updates are not here: a signed-in device (a phone) can install the newest release too. It only
|
|
80
80
|
// ever installs an official release from where this copy came from (git tag or npm) and restarts.
|
|
81
|
-
const LOCAL_ONLY_API = /^\/api\/(remote(\/|$)|notify(\/|$)|hub(\/|$)|triggers(\/|$)|service$|jira
|
|
81
|
+
const LOCAL_ONLY_API = /^\/api\/(remote(\/|$)|notify(\/|$)|hub(\/|$)|triggers(\/|$)|service$|jira(\/check)?$|isolation\/|editors$|agentkit\/connect$|agents\/[\w-]+\/open-in$|shutdown$)/;
|
|
82
82
|
const HOOK_PATH = '/api/hooks/agents';
|
|
83
83
|
const REPORT_PATH = '/api/agentkit/report';
|
|
84
84
|
const NO_REPO_KINDS = new Set(['general', 'assistant']);
|
|
@@ -717,13 +717,25 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
717
717
|
);
|
|
718
718
|
// Jira: the site and API token used to show an issue's summary for agents created from its link.
|
|
719
719
|
api.get('/jira', wrap(() => jiraView()));
|
|
720
|
+
// Whether the saved settings work: how many open issues are yours, or why Jira can't be used.
|
|
721
|
+
api.get(
|
|
722
|
+
'/jira/check',
|
|
723
|
+
wrap(async () => {
|
|
724
|
+
const view = jiraView();
|
|
725
|
+
if (!view.site || !view.hasToken) return { assigned: null, problem: 'Add the site and API token first' };
|
|
726
|
+
const mine = await assignedIssues({ timeoutMs: 8000 });
|
|
727
|
+
return { assigned: mine ? mine.length : null, problem: mine ? null : jiraProblem()?.reason ?? 'Jira could not be reached' };
|
|
728
|
+
}),
|
|
729
|
+
);
|
|
720
730
|
api.put(
|
|
721
731
|
'/jira',
|
|
722
732
|
wrap(async (req) => {
|
|
723
733
|
const view = saveJira(req.body ?? {});
|
|
724
734
|
// Agents already created from links get their summaries now (in the background).
|
|
725
735
|
manager.refreshSynopses().catch(() => {});
|
|
726
|
-
|
|
736
|
+
// Tried at once, so Settings can say whether it works: how many issues are yours, or why not.
|
|
737
|
+
const mine = view.site && view.hasToken ? await assignedIssues({ timeoutMs: 8000 }) : null;
|
|
738
|
+
return { ...view, assigned: mine ? mine.length : null, problem: view.site && view.hasToken && !mine ? jiraProblem()?.reason ?? 'Jira could not be reached' : null };
|
|
727
739
|
}),
|
|
728
740
|
);
|
|
729
741
|
// Start at login: the login service (launchd or systemd) that brings the daemon back after a reboot.
|
|
@@ -790,8 +802,11 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
790
802
|
api.get('/codemap', wrap((req) => manager.codeMap(req.query.project ? String(req.query.project) : null)));
|
|
791
803
|
// Issues agents work on, for the summary; ?group=you|agent|done and ?format=markdown to paste.
|
|
792
804
|
api.get('/issues', wrap(async (req) => {
|
|
793
|
-
// ?fresh=1 (the ↻ button) asks Jira again
|
|
794
|
-
if (req.query.fresh === '1')
|
|
805
|
+
// ?fresh=1 (the ↻ button) asks Jira again: the issues assigned to you and each issue's status.
|
|
806
|
+
if (req.query.fresh === '1') {
|
|
807
|
+
manager.assignedAt = 0;
|
|
808
|
+
manager.jiraCache?.clear();
|
|
809
|
+
}
|
|
795
810
|
manager.jiraOff = !featuresOf(config).jira;
|
|
796
811
|
const v = await manager.issues(proposed.listed(), proposed.actions);
|
|
797
812
|
const group = req.query.group ? String(req.query.group) : null;
|
|
@@ -867,8 +882,13 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
867
882
|
});
|
|
868
883
|
// Today: what needs you, from every list, most pressing first (today.js). A list that's off or
|
|
869
884
|
// can't be had right now is left out, and said so.
|
|
870
|
-
api.get('/today', wrap(async () => {
|
|
885
|
+
api.get('/today', wrap(async (req) => {
|
|
871
886
|
const f = featuresOf(config);
|
|
887
|
+
// ?fresh=1 (↻ or r) asks Jira again rather than using what was fetched in the last few minutes.
|
|
888
|
+
if (req.query.fresh === '1') {
|
|
889
|
+
manager.assignedAt = 0;
|
|
890
|
+
manager.jiraCache?.clear();
|
|
891
|
+
}
|
|
872
892
|
manager.jiraOff = !f.jira;
|
|
873
893
|
const errors = [];
|
|
874
894
|
const got = async (name, fn) => {
|
|
@@ -881,7 +901,13 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
881
901
|
};
|
|
882
902
|
const [inbox, issues, actions, prs] = await Promise.all([
|
|
883
903
|
got('inbox', () => manager.inbox()),
|
|
884
|
-
f.jira
|
|
904
|
+
f.jira
|
|
905
|
+
? got('jira', async () => {
|
|
906
|
+
const v = await manager.issues(proposed.listed(), proposed.actions);
|
|
907
|
+
if (v.jira.problem) errors.push({ source: 'jira', error: v.jira.problem });
|
|
908
|
+
return v.rows;
|
|
909
|
+
})
|
|
910
|
+
: [],
|
|
885
911
|
f.slack || f.gemini ? got('actions', () => myActions.rows()) : [],
|
|
886
912
|
got('reviews', () => reviews.rows()),
|
|
887
913
|
]);
|