@ouro.bot/cli 0.1.0-alpha.1112 → 0.1.0-alpha.1113
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.json +6 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/senses/app-sessions/issue-drain-state.js +3 -1
- package/dist/senses/app-sessions/issue-drains.js +43 -13
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1113",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Issue drains are woken only by changes someone other than the drain made: the drain's own status comment (by marker and revision) and its own `drain:` label changes no longer count as activity, so a drain stops waking on issues that did not change. A new comment, a body or title edit, a reopen or another label still wakes it once; a closed issue the drain handled never wakes it, and its waiting event is dropped."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.1112",
|
|
6
12
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1113</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -33,11 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.drainStateFile = void 0;
|
|
36
|
+
exports.drainStateFile = exports.seenIssue = void 0;
|
|
37
37
|
exports.readDrainStates = readDrainStates;
|
|
38
38
|
exports.drainStatusLines = drainStatusLines;
|
|
39
39
|
const path = __importStar(require("node:path"));
|
|
40
40
|
const store_1 = require("./store");
|
|
41
|
+
const seenIssue = (entry) => typeof entry === "string" ? { updatedAt: entry } : entry;
|
|
42
|
+
exports.seenIssue = seenIssue;
|
|
41
43
|
const drainStateFile = (agentRoot) => path.join((0, store_1.appSessionsStateDir)(agentRoot), "issue-drains.json");
|
|
42
44
|
exports.drainStateFile = drainStateFile;
|
|
43
45
|
function readDrainStates(agentRoot) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendWake = exports.connectGithub = exports.DRAIN_STATUS_MARKER = exports.ISSUE_POLL_MS = void 0;
|
|
3
|
+
exports.sendWake = exports.connectGithub = exports.DRAIN_LABEL_PREFIX = exports.DRAIN_STATUS_MARKER = exports.ISSUE_POLL_MS = void 0;
|
|
4
4
|
exports.wakeMessage = wakeMessage;
|
|
5
5
|
exports.pollDrain = pollDrain;
|
|
6
6
|
exports.pollIssueDrains = pollIssueDrains;
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
8
|
const node_child_process_1 = require("node:child_process");
|
|
8
9
|
const account_pool_1 = require("../../heart/providers/account-pool");
|
|
9
10
|
const runtime_1 = require("../../nerves/runtime");
|
|
@@ -15,10 +16,17 @@ const store_1 = require("./store");
|
|
|
15
16
|
* lists each repository's open issues and messages the drain's session when one is new or changed since the last
|
|
16
17
|
* poll. Events are written to disk before anyone is woken, so a crash or a refused message loses nothing; an
|
|
17
18
|
* authentication or network failure is recorded for `ouro status` and leaves every marker where it was.
|
|
19
|
+
*
|
|
20
|
+
* `updated_at` alone is not a revision: the drain's own label edits and status comment move it too. An issue wakes the
|
|
21
|
+
* drain only when something other than the drain changed it since the revision last recorded for that issue.
|
|
18
22
|
*/
|
|
19
23
|
exports.ISSUE_POLL_MS = 5 * 60_000;
|
|
20
24
|
/** A drain's own status comment carries this marker, so its creation and edits do not wake the drain again. */
|
|
21
25
|
exports.DRAIN_STATUS_MARKER = "<!-- ouro-drain-status -->";
|
|
26
|
+
/** The drain moves an issue through labels in this namespace (`drain: triaged`, `drain: in progress`); changing them is not news. */
|
|
27
|
+
exports.DRAIN_LABEL_PREFIX = "drain:";
|
|
28
|
+
/** A closed issue's record is kept this long, so one that comes back unchanged is not mistaken for a new issue. */
|
|
29
|
+
const GONE_MS = 30 * 24 * 3_600_000;
|
|
22
30
|
const MAX_TITLES = 20;
|
|
23
31
|
const PAGE = 100;
|
|
24
32
|
const blank = () => ({ seeded: false, seen: {}, pending: [] });
|
|
@@ -31,10 +39,23 @@ function wakeMessage(repo, events) {
|
|
|
31
39
|
const more = events.length > MAX_TITLES ? `, and ${events.length - MAX_TITLES} more` : "";
|
|
32
40
|
return `New or changed issues in ${repo}: ${shown.join(", ")}${more}. Drain them.`;
|
|
33
41
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
const digestOf = (issue) => (0, node_crypto_1.createHash)("sha1").update(`${issue.title}\n${issue.body ?? ""}`).digest("hex").slice(0, 16);
|
|
43
|
+
/** The drain's own status comment: the marker, written by the polling account. Its creation and every edit are skipped. */
|
|
44
|
+
const ownStatus = (comment, login) => comment.user?.login?.toLowerCase() === login.toLowerCase() && !!comment.body?.includes(exports.DRAIN_STATUS_MARKER);
|
|
45
|
+
/** A reopen, or a label change outside the drain's own namespace. Closes, assignments, mentions and the drain's labels are not news. */
|
|
46
|
+
const newsEvent = (event) => event.event === "reopened" || ((event.event === "labeled" || event.event === "unlabeled") && !event.label?.name?.startsWith(exports.DRAIN_LABEL_PREFIX));
|
|
47
|
+
/** Whether anyone but the drain changed the issue since `before`: a new issue, an edit, another comment, a reopen or a label outside the drain's own. */
|
|
48
|
+
async function changedByOthers(api, repo, issue, before, digest) {
|
|
49
|
+
if (!before)
|
|
50
|
+
return true;
|
|
51
|
+
if (before.digest && before.digest !== digest)
|
|
52
|
+
return true;
|
|
53
|
+
const since = before.updatedAt;
|
|
54
|
+
const comments = (await api.comments(repo, issue.number, since)).filter(comment => comment.updated_at > since);
|
|
55
|
+
if (comments.some(comment => !ownStatus(comment, api.login)))
|
|
56
|
+
return true;
|
|
57
|
+
const events = (await api.issueEvents(repo, issue.number)).filter(event => event.created_at > since);
|
|
58
|
+
return events.some(newsEvent);
|
|
38
59
|
}
|
|
39
60
|
/** Poll one drain's repository, record what changed, then wake its session once with the whole batch. */
|
|
40
61
|
async function pollDrain(drain, states, save, deps) {
|
|
@@ -47,16 +68,23 @@ async function pollDrain(drain, states, save, deps) {
|
|
|
47
68
|
const recorded = [];
|
|
48
69
|
for (const issue of issues) {
|
|
49
70
|
const key = String(issue.number);
|
|
50
|
-
const before = state.seen[key];
|
|
51
|
-
|
|
52
|
-
|
|
71
|
+
const before = (0, issue_drain_state_1.seenIssue)(state.seen[key]);
|
|
72
|
+
const digest = digestOf(issue);
|
|
73
|
+
seen[key] = { updatedAt: issue.updated_at, digest };
|
|
74
|
+
if (!state.seeded || before?.updatedAt === issue.updated_at)
|
|
53
75
|
continue;
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
76
|
+
if (await changedByOthers(api, drain.repo, issue, before, digest))
|
|
77
|
+
recorded.push({ number: issue.number, title: issue.title, updatedAt: issue.updated_at });
|
|
78
|
+
}
|
|
79
|
+
for (const [key, entry] of Object.entries(state.seen)) {
|
|
80
|
+
const gone = (0, issue_drain_state_1.seenIssue)(entry);
|
|
81
|
+
const goneAt = gone.goneAt ?? deps.now;
|
|
82
|
+
if (!(key in seen) && deps.now - goneAt < GONE_MS)
|
|
83
|
+
seen[key] = { ...gone, goneAt };
|
|
57
84
|
}
|
|
85
|
+
const open = new Set(issues.map(issue => issue.number));
|
|
58
86
|
const numbers = new Set(recorded.map(event => event.number));
|
|
59
|
-
state.pending = [...state.pending.filter(event => !numbers.has(event.number)), ...recorded];
|
|
87
|
+
state.pending = [...state.pending.filter(event => open.has(event.number) && !numbers.has(event.number)), ...recorded];
|
|
60
88
|
state.seen = seen;
|
|
61
89
|
state.seeded = true;
|
|
62
90
|
state.openCount = issues.length;
|
|
@@ -112,8 +140,9 @@ const connectGithub = async (account) => {
|
|
|
112
140
|
};
|
|
113
141
|
const all = async (route) => {
|
|
114
142
|
const items = [];
|
|
143
|
+
const join = route.includes("?") ? "&" : "?";
|
|
115
144
|
for (let page = 1;; page++) {
|
|
116
|
-
const { body, next } = await get(`${route}
|
|
145
|
+
const { body, next } = await get(`${route}${join}per_page=${PAGE}&page=${page}`);
|
|
117
146
|
items.push(...body);
|
|
118
147
|
if (!next)
|
|
119
148
|
return items;
|
|
@@ -124,6 +153,7 @@ const connectGithub = async (account) => {
|
|
|
124
153
|
login,
|
|
125
154
|
openIssues: async (repo) => (await all(`/repos/${repo}/issues?state=open&sort=updated&direction=desc`)).filter(issue => !issue.pull_request),
|
|
126
155
|
comments: (repo, issue, since) => all(`/repos/${repo}/issues/${issue}/comments?since=${encodeURIComponent(since)}`),
|
|
156
|
+
issueEvents: (repo, issue) => all(`/repos/${repo}/issues/${issue}/events`),
|
|
127
157
|
};
|
|
128
158
|
};
|
|
129
159
|
exports.connectGithub = connectGithub;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1113",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1113",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@ouro.bot/friends": "0.1.0-alpha.18",
|