@ouro.bot/cli 0.1.0-alpha.1109 → 0.1.0-alpha.1110

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 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.1110",
6
+ "changes": [
7
+ "Issue-drain sessions wake when a repository's issue is new or changed: the app-sessions sense polls GitHub every five minutes with no model turn, saves events before messaging the drain, skips the drain's own marked status comments, logs every poll, and shows each drain's last poll, open count, waiting events, last wake and last error in ouro status."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1109",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1109",
2
+ "runtimeVersion": "0.1.0-alpha.1110",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -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.1109</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1110</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -223,6 +223,8 @@ function parseStatusPayload(data) {
223
223
  parsed.oldestActiveTurnStartedAt = oldestActiveTurnStartedAt;
224
224
  if (oldestActiveTurnAgeMs !== null)
225
225
  parsed.oldestActiveTurnAgeMs = oldestActiveTurnAgeMs;
226
+ if (Array.isArray(row.lines))
227
+ parsed.lines = row.lines.filter((line) => typeof line === "string");
226
228
  return parsed;
227
229
  });
228
230
  const parsedWorkers = workers.map((entry) => {
@@ -518,6 +520,8 @@ function formatDaemonStatusOutput(response, fallback) {
518
520
  const dot = row.enabled ? statusDot(row.status) : dim("○");
519
521
  const statusText = (row.enabled ? row.status : "disabled").padEnd(statusWidth);
520
522
  lines.push(` ${name} ${dot} ${statusText} ${dim(formatSenseDetail(row))}`);
523
+ for (const extra of row.lines ?? [])
524
+ lines.push(` ${dim(extra)}`);
521
525
  }
522
526
  }
523
527
  lines.push("");
@@ -45,6 +45,7 @@ const provider_credentials_1 = require("../provider-credentials");
45
45
  const sense_truth_1 = require("../sense-truth");
46
46
  const machine_identity_1 = require("../machine-identity");
47
47
  const shepherd_config_1 = require("../shepherd-config");
48
+ const issue_drain_state_1 = require("../../senses/app-sessions/issue-drain-state");
48
49
  const store_1 = require("../../senses/app-sessions/store");
49
50
  const process_manager_1 = require("./process-manager");
50
51
  const presence_1 = require("./presence");
@@ -109,6 +110,15 @@ function readAgentSenses(agentJsonPath) {
109
110
  if (sense === "bluebubbles" && typeof hostUsername === "string" && hostUsername.trim().length > 0) {
110
111
  defaults[sense] = { enabled, hostUsername: hostUsername.trim() };
111
112
  }
113
+ // Issue drains the config rejects stay unset here; the sense itself reports the error when it polls.
114
+ if (sense === "app-sessions") {
115
+ try {
116
+ defaults[sense] = { enabled, ...(0, identity_1.normalizeIssueDrains)(rawSense, agentJsonPath) };
117
+ }
118
+ catch {
119
+ defaults[sense] = { enabled };
120
+ }
121
+ }
112
122
  }
113
123
  }
114
124
  if (workbenchHasStaleBundleEntry) {
@@ -1089,6 +1099,9 @@ class DaemonSenseManager {
1089
1099
  : entry.sense === "workbench"
1090
1100
  ? WORKBENCH_RUNTIME_INJECTION_DETAIL
1091
1101
  : "not enabled in agent.json",
1102
+ ...(entry.enabled && entry.sense === "app-sessions" && context.senses["app-sessions"].issueDrains?.length ? {
1103
+ lines: (0, issue_drain_state_1.drainStatusLines)(context.senses["app-sessions"].issueDrains, (0, issue_drain_state_1.readDrainStates)(path.join(this.bundlesRoot, `${agent}.ouro`)), Date.now()),
1104
+ } : {}),
1092
1105
  ...(entry.sense === "bluebubbles" && blueBubblesConfigured ? {
1093
1106
  proofMethod: blueBubblesRuntimeFacts.proofMethod,
1094
1107
  lastProofAt: blueBubblesRuntimeFacts.lastProofAt,
@@ -40,6 +40,7 @@ exports.defaultStableVaultEmail = defaultStableVaultEmail;
40
40
  exports.resolveVaultConfig = resolveVaultConfig;
41
41
  exports.persistedSenses = persistedSenses;
42
42
  exports.hasStaleWorkbenchBundleEntry = hasStaleWorkbenchBundleEntry;
43
+ exports.normalizeIssueDrains = normalizeIssueDrains;
43
44
  exports.normalizeSenses = normalizeSenses;
44
45
  exports.buildDefaultAgentTemplate = buildDefaultAgentTemplate;
45
46
  exports.getAgentName = getAgentName;
@@ -174,6 +175,39 @@ function hasStaleWorkbenchBundleEntry(rawSenses, rawMcpServers) {
174
175
  const rawWorkbench = rawSenses.workbench;
175
176
  return !(isPlainRecord(rawWorkbench) && rawWorkbench.enabled === false);
176
177
  }
178
+ function normalizeIssueDrains(rawSense, configFile) {
179
+ function fail(what) {
180
+ (0, runtime_1.emitNervesEvent)({ level: "error", event: "config_identity.error", component: "config/identity", message: "agent config has invalid issue drains", meta: { path: configFile } });
181
+ throw new Error(`agent.json at ${configFile}: senses.app-sessions.${what}.`);
182
+ }
183
+ const { issueDrains, issuePollMinutes } = rawSense;
184
+ const result = {};
185
+ if (issueDrains !== undefined) {
186
+ if (!Array.isArray(issueDrains))
187
+ fail("issueDrains must be an array");
188
+ const seen = new Set();
189
+ result.issueDrains = issueDrains.map((entry, index) => {
190
+ const item = (entry && typeof entry === "object" ? entry : {});
191
+ const { repo, session, account } = item;
192
+ if (typeof repo !== "string" || !/^[\w.-]+\/[\w.-]+$/.test(repo))
193
+ fail(`issueDrains[${index}].repo must be "owner/name"`);
194
+ if (typeof session !== "string" || !session.trim())
195
+ fail(`issueDrains[${index}].session must be a Copilot app session id`);
196
+ if (account !== undefined && (typeof account !== "string" || !account.trim()))
197
+ fail(`issueDrains[${index}].account must be a GitHub login`);
198
+ if (seen.has(repo))
199
+ fail(`issueDrains[${index}].repo ${repo} is listed twice`);
200
+ seen.add(repo);
201
+ return { repo: repo, session: session.trim(), ...(account !== undefined ? { account: account.trim() } : {}) };
202
+ });
203
+ }
204
+ if (issuePollMinutes !== undefined) {
205
+ if (typeof issuePollMinutes !== "number" || !Number.isFinite(issuePollMinutes) || issuePollMinutes < 1)
206
+ fail("issuePollMinutes must be a number of at least 1");
207
+ result.issuePollMinutes = issuePollMinutes;
208
+ }
209
+ return result;
210
+ }
177
211
  function normalizeSenses(value, configFile) {
178
212
  const defaults = {
179
213
  cli: { ...exports.DEFAULT_AGENT_SENSES.cli },
@@ -264,6 +298,10 @@ function normalizeSenses(value, configFile) {
264
298
  };
265
299
  continue;
266
300
  }
301
+ if (senseName === "app-sessions") {
302
+ defaults[senseName] = { enabled, ...normalizeIssueDrains(rawSense, configFile) };
303
+ continue;
304
+ }
267
305
  defaults[senseName] = { enabled };
268
306
  }
269
307
  return defaults;
@@ -39,6 +39,7 @@ exports.apiBaseForHost = apiBaseForHost;
39
39
  exports.isWorkAccount = isWorkAccount;
40
40
  exports.globMatch = globMatch;
41
41
  exports.isEligible = isEligible;
42
+ exports.cleanGhEnv = cleanGhEnv;
42
43
  exports.readAppAccounts = readAppAccounts;
43
44
  exports.readGhAccounts = readGhAccounts;
44
45
  exports.discoverAccount = discoverAccount;
@@ -108,6 +109,7 @@ function isEligible(key, eligible = "work") {
108
109
  }
109
110
  /* v8 ignore next -- tests always inject spawnSync; the default is for production @preserve */
110
111
  const spawnOf = (deps) => deps.spawnSync ?? child_process_1.spawnSync;
112
+ /** The environment for a `gh` call that must use the CLI's stored accounts, not a token in the environment. */
111
113
  function cleanGhEnv() {
112
114
  const env = { ...process.env, PATH: ["/opt/homebrew/bin", "/usr/local/bin", process.env.PATH].filter(Boolean).join(":") };
113
115
  delete env.GH_TOKEN;
@@ -103,6 +103,9 @@ const DISPATCH_EXEMPT_PATTERNS = [
103
103
  // consumed by server readers and the UI. Mailbox read/render modules own
104
104
  // the observability for these projections.
105
105
  "heart/mailbox/mailbox-types",
106
+ // Issue-drain status reader: pure state-file read and line rendering for `ouro status`. The poller
107
+ // (issue-drains.ts) owns observability via senses.issue_drain_poll and friends.
108
+ "senses/app-sessions/issue-drain-state",
106
109
  // Pure Shepherd command/parser/projection seams; IO callers own observability.
107
110
  "heart/shepherd/operation-commands.ts",
108
111
  "heart/shepherd/operations.ts",
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.drainStateFile = void 0;
37
+ exports.readDrainStates = readDrainStates;
38
+ exports.drainStatusLines = drainStatusLines;
39
+ const path = __importStar(require("node:path"));
40
+ const store_1 = require("./store");
41
+ const drainStateFile = (agentRoot) => path.join((0, store_1.appSessionsStateDir)(agentRoot), "issue-drains.json");
42
+ exports.drainStateFile = drainStateFile;
43
+ function readDrainStates(agentRoot) {
44
+ return (0, store_1.readJson)((0, exports.drainStateFile)(agentRoot), {});
45
+ }
46
+ function ago(iso, now) {
47
+ const minutes = Math.max(0, Math.round((now - Date.parse(iso)) / 60_000));
48
+ return minutes < 1 ? "just now" : minutes < 90 ? `${minutes}m ago` : `${Math.round(minutes / 60)}h ago`;
49
+ }
50
+ /** One `ouro status` line per drain: its last poll, open issues, events waiting, last wake and last error. */
51
+ function drainStatusLines(drains, states, now) {
52
+ return drains.map(drain => {
53
+ const state = states[drain.repo];
54
+ const head = `issue drain ${drain.repo} -> ${drain.session.slice(0, 8)}`;
55
+ if (!state?.lastPollAt)
56
+ return `${head}: not polled yet`;
57
+ const wake = state.lastWakeAt ? `${ago(state.lastWakeAt, now)} (${state.lastWakeCount} issue${state.lastWakeCount === 1 ? "" : "s"})` : "never";
58
+ return `${head}: polled ${ago(state.lastPollAt, now)}, ${state.openCount ?? "?"} open, ${state.pending.length} waiting, last wake ${wake}${state.lastError ? `, last error: ${state.lastError}` : ""}`;
59
+ });
60
+ }
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendWake = exports.connectGithub = exports.DRAIN_STATUS_MARKER = exports.ISSUE_POLL_MS = void 0;
4
+ exports.wakeMessage = wakeMessage;
5
+ exports.pollDrain = pollDrain;
6
+ exports.pollIssueDrains = pollIssueDrains;
7
+ const node_child_process_1 = require("node:child_process");
8
+ const account_pool_1 = require("../../heart/providers/account-pool");
9
+ const runtime_1 = require("../../nerves/runtime");
10
+ const client_1 = require("./client");
11
+ const issue_drain_state_1 = require("./issue-drain-state");
12
+ const store_1 = require("./store");
13
+ /**
14
+ * Issue drains: Copilot app sessions that work a GitHub repository's issues. A deterministic poll (no model turn)
15
+ * lists each repository's open issues and messages the drain's session when one is new or changed since the last
16
+ * poll. Events are written to disk before anyone is woken, so a crash or a refused message loses nothing; an
17
+ * authentication or network failure is recorded for `ouro status` and leaves every marker where it was.
18
+ */
19
+ exports.ISSUE_POLL_MS = 5 * 60_000;
20
+ /** A drain's own status comment carries this marker, so its creation and edits do not wake the drain again. */
21
+ exports.DRAIN_STATUS_MARKER = "<!-- ouro-drain-status -->";
22
+ const MAX_TITLES = 20;
23
+ const PAGE = 100;
24
+ const blank = () => ({ seeded: false, seen: {}, pending: [] });
25
+ function oneLine(text) {
26
+ const flat = text.replace(/\s+/g, " ").trim();
27
+ return flat.length > 120 ? `${flat.slice(0, 119)}…` : flat;
28
+ }
29
+ function wakeMessage(repo, events) {
30
+ const shown = events.slice(0, MAX_TITLES).map(event => `#${event.number} ${oneLine(event.title)}`);
31
+ const more = events.length > MAX_TITLES ? `, and ${events.length - MAX_TITLES} more` : "";
32
+ return `New or changed issues in ${repo}: ${shown.join(", ")}${more}. Drain them.`;
33
+ }
34
+ /** Only the drain's own status comment explains the issue's newest change. */
35
+ function ownStatusOnly(issue, comments, login) {
36
+ const own = (comment) => comment.user?.login?.toLowerCase() === login.toLowerCase() && !!comment.body?.includes(exports.DRAIN_STATUS_MARKER);
37
+ return comments.some(comment => own(comment) && comment.updated_at === issue.updated_at) && comments.every(own);
38
+ }
39
+ /** Poll one drain's repository, record what changed, then wake its session once with the whole batch. */
40
+ async function pollDrain(drain, states, save, deps) {
41
+ const state = states[drain.repo] ?? (states[drain.repo] = blank());
42
+ const at = new Date(deps.now).toISOString();
43
+ try {
44
+ const api = await deps.connect(drain.account);
45
+ const issues = await api.openIssues(drain.repo);
46
+ const seen = {};
47
+ const recorded = [];
48
+ for (const issue of issues) {
49
+ const key = String(issue.number);
50
+ const before = state.seen[key];
51
+ seen[key] = issue.updated_at;
52
+ if (!state.seeded || before === issue.updated_at)
53
+ continue;
54
+ if (before && ownStatusOnly(issue, (await api.comments(drain.repo, issue.number, before)).filter(comment => comment.updated_at > before), api.login))
55
+ continue;
56
+ recorded.push({ number: issue.number, title: issue.title, updatedAt: issue.updated_at });
57
+ }
58
+ const numbers = new Set(recorded.map(event => event.number));
59
+ state.pending = [...state.pending.filter(event => !numbers.has(event.number)), ...recorded];
60
+ state.seen = seen;
61
+ state.seeded = true;
62
+ state.openCount = issues.length;
63
+ delete state.lastError;
64
+ }
65
+ catch (error) {
66
+ state.lastError = error.message;
67
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.issue_drain_poll_error", message: "could not poll a repository's issues; markers stay where they were", meta: { repo: drain.repo, error: state.lastError } });
68
+ }
69
+ state.lastPollAt = at;
70
+ save();
71
+ (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.issue_drain_poll", message: "polled a repository's issues for its drain", meta: { repo: drain.repo, open: state.openCount ?? null, waiting: state.pending.length, ok: !state.lastError } });
72
+ if (state.pending.length === 0)
73
+ return;
74
+ const events = state.pending;
75
+ const sent = await deps.send(drain.session, wakeMessage(drain.repo, events)).catch((error) => ({ ok: false, error: error.message }));
76
+ if (sent.ok) {
77
+ state.pending = [];
78
+ state.lastWakeAt = new Date(deps.now).toISOString();
79
+ state.lastWakeCount = events.length;
80
+ }
81
+ else {
82
+ state.lastError = `could not wake the drain: ${sent.error ?? "the app refused the message"}`;
83
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.issue_drain_wake_error", message: "could not message an issue drain; its events wait on disk", meta: { repo: drain.repo, session: drain.session, error: state.lastError } });
84
+ }
85
+ save();
86
+ (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.issue_drain_wake", message: "messaged an issue drain about new or changed issues", meta: { repo: drain.repo, session: drain.session, issues: events.length, ok: sent.ok } });
87
+ }
88
+ /** Poll every configured drain once. Repositories dropped from the config lose their state. */
89
+ async function pollIssueDrains(agentRoot, drains, deps) {
90
+ const stored = (0, issue_drain_state_1.readDrainStates)(agentRoot);
91
+ const states = Object.fromEntries(drains.map(drain => [drain.repo, stored[drain.repo] ?? blank()]));
92
+ const save = () => (0, store_1.writeJson)((0, issue_drain_state_1.drainStateFile)(agentRoot), states);
93
+ for (const drain of drains)
94
+ await pollDrain(drain, states, save, deps);
95
+ save();
96
+ }
97
+ /** The drain's GitHub access: its account's token from the `gh` CLI, then the REST API. */
98
+ const connectGithub = async (account) => {
99
+ const tokenArgs = ["auth", "token", "--hostname", "github.com", ...(account ? ["--user", account] : [])];
100
+ const result = (0, node_child_process_1.spawnSync)("gh", tokenArgs, { encoding: "utf8", timeout: 10_000, env: (0, account_pool_1.cleanGhEnv)() });
101
+ const token = result.status === 0 ? String(result.stdout ?? "").trim() : "";
102
+ if (!token)
103
+ throw new Error(`the GitHub CLI has no token for ${account ?? "its active account"} (run \`gh auth login --hostname github.com\`)`);
104
+ const get = async (route) => {
105
+ const response = await fetch(`https://api.github.com${route}`, {
106
+ headers: { Authorization: `Bearer ${token}`, Accept: "application/vnd.github+json", "User-Agent": "ouro-issue-drains" },
107
+ signal: AbortSignal.timeout(30_000),
108
+ });
109
+ if (!response.ok)
110
+ throw new Error(`GitHub answered HTTP ${response.status} for ${route.split("?")[0]}`);
111
+ return { body: await response.json(), next: /rel="next"/.test(response.headers.get("link") ?? "") };
112
+ };
113
+ const all = async (route) => {
114
+ const items = [];
115
+ for (let page = 1;; page++) {
116
+ const { body, next } = await get(`${route}&per_page=${PAGE}&page=${page}`);
117
+ items.push(...body);
118
+ if (!next)
119
+ return items;
120
+ }
121
+ };
122
+ const login = account ?? String((await get("/user")).body.login ?? "");
123
+ return {
124
+ login,
125
+ openIssues: async (repo) => (await all(`/repos/${repo}/issues?state=open&sort=updated&direction=desc`)).filter(issue => !issue.pull_request),
126
+ comments: (repo, issue, since) => all(`/repos/${repo}/issues/${issue}/comments?since=${encodeURIComponent(since)}`),
127
+ };
128
+ };
129
+ exports.connectGithub = connectGithub;
130
+ const sendWake = (client) => async (session, message) => {
131
+ const result = await (0, client_1.sendToAppSession)(session, message, { ...client, delivery: "enqueue" });
132
+ return { ok: result.ok, error: result.error };
133
+ };
134
+ exports.sendWake = sendWake;
@@ -6,6 +6,7 @@ exports.replyContent = replyContent;
6
6
  exports.privateRuntimeDeliver = privateRuntimeDeliver;
7
7
  exports.checkWatches = checkWatches;
8
8
  exports.recordSnapshot = recordSnapshot;
9
+ exports.checkIssueDrains = checkIssueDrains;
9
10
  exports.startAppSessionsSense = startAppSessionsSense;
10
11
  const node_crypto_1 = require("node:crypto");
11
12
  const socket_client_1 = require("../../heart/daemon/socket-client");
@@ -13,6 +14,7 @@ const identity_1 = require("../../heart/identity");
13
14
  const pending_1 = require("../../mind/pending");
14
15
  const runtime_1 = require("../../nerves/runtime");
15
16
  const cmux_1 = require("../shepherd/cmux");
17
+ const issue_drains_1 = require("./issue-drains");
16
18
  const client_1 = require("./client");
17
19
  const store_1 = require("./store");
18
20
  /**
@@ -129,6 +131,19 @@ function recordSnapshot(agentRoot, client, now) {
129
131
  (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_snapshot", message: "snapshotted the Copilot app's sessions", meta: { ...result.counts, appRunning: result.appRunning } });
130
132
  return result;
131
133
  }
134
+ /** Poll the issue drains in `agent.json` once; returns the milliseconds until the next poll. A bad config is logged and retried then. */
135
+ async function checkIssueDrains(agentName, agentRoot, deps) {
136
+ try {
137
+ const config = (0, identity_1.loadAgentConfig)({ agentName, agentRoot }).senses?.["app-sessions"];
138
+ if (config?.enabled && config.issueDrains?.length)
139
+ await (0, issue_drains_1.pollIssueDrains)(agentRoot, config.issueDrains, deps);
140
+ return config?.issuePollMinutes ? config.issuePollMinutes * 60_000 : issue_drains_1.ISSUE_POLL_MS;
141
+ }
142
+ catch (error) {
143
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.issue_drain_error", message: "could not check the issue drains", meta: { error: error.message } });
144
+ return issue_drains_1.ISSUE_POLL_MS;
145
+ }
146
+ }
132
147
  function startAppSessionsSense(options) {
133
148
  const agentRoot = options.agentRoot ?? (0, identity_1.getAgentRoot)(options.agentName);
134
149
  const now = options.now ?? Date.now;
@@ -139,6 +154,8 @@ function startAppSessionsSense(options) {
139
154
  let cancelSnapshot;
140
155
  let cancelWatch = null;
141
156
  let inFlight = Promise.resolve();
157
+ let cancelIssues = null;
158
+ let issuePoll = Promise.resolve();
142
159
  const snapshotTick = () => {
143
160
  if (stopped)
144
161
  return;
@@ -155,16 +172,26 @@ function startAppSessionsSense(options) {
155
172
  cancelWatch = schedule(watchTick, exports.WATCH_POLL_MS);
156
173
  });
157
174
  };
175
+ const issueTick = () => {
176
+ if (stopped)
177
+ return;
178
+ issuePoll = checkIssueDrains(options.agentName, agentRoot, { connect: options.connectGithub ?? issue_drains_1.connectGithub, send: options.sendWake ?? (0, issue_drains_1.sendWake)(client), now: now() }).then(ms => {
179
+ if (!stopped)
180
+ cancelIssues = schedule(issueTick, ms);
181
+ });
182
+ };
158
183
  (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_start", message: "app-sessions sense started", meta: { agent: options.agentName } });
159
184
  snapshotTick();
160
185
  watchTick();
186
+ issueTick();
161
187
  return {
162
188
  stop: () => {
163
189
  stopped = true;
164
190
  cancelSnapshot();
165
191
  cancelWatch?.();
192
+ cancelIssues?.();
166
193
  (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_end", message: "app-sessions sense stopped", meta: { agent: options.agentName } });
167
194
  },
168
- done: () => inFlight.then(() => undefined),
195
+ done: () => Promise.all([inFlight, issuePoll]).then(() => undefined),
169
196
  };
170
197
  }
@@ -35,6 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.SNAPSHOT_STALE_MS = exports.WATCH_MS = void 0;
37
37
  exports.appSessionsStateDir = appSessionsStateDir;
38
+ exports.readJson = readJson;
39
+ exports.writeJson = writeJson;
38
40
  exports.readWatches = readWatches;
39
41
  exports.watchSession = watchSession;
40
42
  exports.unwatchSession = unwatchSession;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1109",
3
+ "version": "0.1.0-alpha.1110",
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.1109",
9
+ "version": "0.1.0-alpha.1110",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.78.0",
12
12
  "@ouro.bot/friends": "0.1.0-alpha.18",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1109",
3
+ "version": "0.1.0-alpha.1110",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },