omni-notify-mcp 1.3.391 → 1.3.392
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.
|
@@ -5,6 +5,7 @@ import { Agent } from "node:http";
|
|
|
5
5
|
import { homedir, tmpdir } from "node:os";
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
import { Duplex } from "node:stream";
|
|
8
|
+
import { CLUSTER_OWNER, OwnershipUnreadable, startOwnerOf } from "./providerOwnership.js";
|
|
8
9
|
export function isProcessAlive(pid) {
|
|
9
10
|
try {
|
|
10
11
|
process.kill(pid, 0);
|
|
@@ -65,12 +66,12 @@ export function peerToken(sessionsDir, pid, procStart) {
|
|
|
65
66
|
return undefined;
|
|
66
67
|
}
|
|
67
68
|
/** The child that writes one post: it connects, writes the payload file it was handed, and exits 0 only on a clean close. */
|
|
68
|
-
const INBOX_POSTER = `const fs = require("fs");
|
|
69
|
-
const [pipe, file] = process.argv.slice(1);
|
|
70
|
-
const data = fs.readFileSync(file, "utf8");
|
|
71
|
-
const socket = require("net").connect(pipe, () => socket.end(data));
|
|
72
|
-
socket.resume();
|
|
73
|
-
socket.on("error", (err) => { process.stderr.write(err.message); process.exitCode = 1; });
|
|
69
|
+
const INBOX_POSTER = `const fs = require("fs");
|
|
70
|
+
const [pipe, file] = process.argv.slice(1);
|
|
71
|
+
const data = fs.readFileSync(file, "utf8");
|
|
72
|
+
const socket = require("net").connect(pipe, () => socket.end(data));
|
|
73
|
+
socket.resume();
|
|
74
|
+
socket.on("error", (err) => { process.stderr.write(err.message); process.exitCode = 1; });
|
|
74
75
|
socket.on("close", (hadError) => { if (hadError) { process.exitCode = 1; } });`;
|
|
75
76
|
// GATE: how much of the posting child's stderr an InboxPostFailed carries — a longer stderr keeps only its last 4000 chars
|
|
76
77
|
const POST_STDERR_CHARS = 4000;
|
|
@@ -407,7 +408,9 @@ export class CodexControl {
|
|
|
407
408
|
/** A new Codex main opened in `cwd` under `name`, idle until a press is posted into it. */
|
|
408
409
|
async startMain(cwd, name, held, maximumThreads, model, created) {
|
|
409
410
|
await this.open();
|
|
410
|
-
const
|
|
411
|
+
const idle = await this.unboundRoot(cwd, held, model);
|
|
412
|
+
fenceStart("codex", `the Codex main ${name}`);
|
|
413
|
+
const thread = idle ?? (await this.request("thread/start", { cwd, ...this.capacityConfig(maximumThreads), ...(model === undefined ? {} : { model }) })).thread;
|
|
411
414
|
const main = { threadId: thread.id, cwd: thread.cwd, name, ownedThreadIds: [], working: false };
|
|
412
415
|
created?.(main);
|
|
413
416
|
await this.request("thread/name/set", { threadId: thread.id, name });
|
|
@@ -1363,239 +1366,239 @@ const TABLE_END = "\u0004END";
|
|
|
1363
1366
|
* times, working set and start from its own handle, and its command line once per process start. A process this user
|
|
1364
1367
|
* cannot open (System, a protected service) is listed with its parent and zeros.
|
|
1365
1368
|
*/
|
|
1366
|
-
const WINDOWS_TABLE_SCRIPT = `$ErrorActionPreference = 'Stop'
|
|
1367
|
-
Add-Type -TypeDefinition @'
|
|
1368
|
-
using System;
|
|
1369
|
-
using System.Collections.Generic;
|
|
1370
|
-
using System.Runtime.InteropServices;
|
|
1371
|
-
using System.Text;
|
|
1372
|
-
public static class AgentSessionProcessTable {
|
|
1373
|
-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
1374
|
-
struct Entry { public uint size, usage, pid; public IntPtr heap; public uint module, threads, ppid; public int priority; public uint flags; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string exe; }
|
|
1375
|
-
[StructLayout(LayoutKind.Sequential)]
|
|
1376
|
-
struct Memory { public uint cb, faults; public UIntPtr peakWorkingSet, workingSet, a, b, c, d, e, f; }
|
|
1377
|
-
[DllImport("kernel32.dll")] static extern IntPtr CreateToolhelp32Snapshot(uint flags, uint pid);
|
|
1378
|
-
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)] static extern bool Process32FirstW(IntPtr snap, ref Entry entry);
|
|
1379
|
-
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)] static extern bool Process32NextW(IntPtr snap, ref Entry entry);
|
|
1380
|
-
[DllImport("kernel32.dll")] static extern IntPtr OpenProcess(uint access, bool inherit, uint pid);
|
|
1381
|
-
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
|
|
1382
|
-
[DllImport("kernel32.dll")] static extern bool GetProcessTimes(IntPtr handle, out long created, out long exited, out long kernel, out long user);
|
|
1383
|
-
[DllImport("kernel32.dll")] static extern bool K32GetProcessMemoryInfo(IntPtr handle, out Memory memory, uint cb);
|
|
1384
|
-
[DllImport("ntdll.dll")] static extern int NtQueryInformationProcess(IntPtr handle, int infoClass, IntPtr buffer, int length, out int returned);
|
|
1385
|
-
static Dictionary<string, string> commands = new Dictionary<string, string>();
|
|
1386
|
-
static Dictionary<string, string> laneTags = new Dictionary<string, string>();
|
|
1387
|
-
[DllImport("kernel32.dll")] static extern bool ReadProcessMemory(IntPtr process, IntPtr address, byte[] buffer, IntPtr size, out IntPtr read);
|
|
1388
|
-
static IntPtr PointerAt(IntPtr process, IntPtr address) {
|
|
1389
|
-
var cell = new byte[8];
|
|
1390
|
-
IntPtr read;
|
|
1391
|
-
if (!ReadProcessMemory(process, address, cell, new IntPtr(8), out read) || read.ToInt64() != 8) return IntPtr.Zero;
|
|
1392
|
-
return new IntPtr(BitConverter.ToInt64(cell, 0));
|
|
1393
|
-
}
|
|
1394
|
-
static string EnvTag(string text, string name) {
|
|
1395
|
-
string marker = "\\0" + name + "=";
|
|
1396
|
-
int at = text.IndexOf(marker, StringComparison.Ordinal);
|
|
1397
|
-
if (at == -1) return "";
|
|
1398
|
-
int from = at + marker.Length, end = text.IndexOf('\\0', from);
|
|
1399
|
-
string tag = end == -1 ? text.Substring(from) : text.Substring(from, end - from);
|
|
1400
|
-
foreach (char c in tag) if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_' || c == ':' || c == '.')) return "";
|
|
1401
|
-
return tag;
|
|
1402
|
-
}
|
|
1403
|
-
static string LaneTagOf(uint pid) {
|
|
1404
|
-
const string none = "\\t";
|
|
1405
|
-
IntPtr handle = OpenProcess(0x1000 | 0x0010, false, pid);
|
|
1406
|
-
if (handle == IntPtr.Zero) return none;
|
|
1407
|
-
try {
|
|
1408
|
-
IntPtr basic = Marshal.AllocHGlobal(48);
|
|
1409
|
-
int returned;
|
|
1410
|
-
IntPtr peb;
|
|
1411
|
-
try {
|
|
1412
|
-
if (IntPtr.Size != 8 || NtQueryInformationProcess(handle, 0, basic, 48, out returned) != 0) return none;
|
|
1413
|
-
peb = Marshal.ReadIntPtr(basic, 8);
|
|
1414
|
-
} finally { Marshal.FreeHGlobal(basic); }
|
|
1415
|
-
IntPtr parameters = PointerAt(handle, IntPtr.Add(peb, 0x20));
|
|
1416
|
-
if (parameters == IntPtr.Zero) return none;
|
|
1417
|
-
IntPtr environment = PointerAt(handle, IntPtr.Add(parameters, 0x80));
|
|
1418
|
-
long size = PointerAt(handle, IntPtr.Add(parameters, 0x3F0)).ToInt64();
|
|
1419
|
-
if (environment == IntPtr.Zero || size <= 0 || size > 1048576) return none;
|
|
1420
|
-
var block = new byte[size];
|
|
1421
|
-
IntPtr got;
|
|
1422
|
-
if (!ReadProcessMemory(handle, environment, block, new IntPtr(size), out got)) return none;
|
|
1423
|
-
string text = "\\0" + Encoding.Unicode.GetString(block, 0, (int)got.ToInt64());
|
|
1424
|
-
return EnvTag(text, "BULLSEYE_LANE") + "\\t" + EnvTag(text, "CODEX_THREAD_ID");
|
|
1425
|
-
} finally { CloseHandle(handle); }
|
|
1426
|
-
}
|
|
1427
|
-
static string CommandOf(IntPtr handle) {
|
|
1428
|
-
int length;
|
|
1429
|
-
NtQueryInformationProcess(handle, 60, IntPtr.Zero, 0, out length);
|
|
1430
|
-
if (length <= 0) return null;
|
|
1431
|
-
IntPtr buffer = Marshal.AllocHGlobal(length);
|
|
1432
|
-
try {
|
|
1433
|
-
if (NtQueryInformationProcess(handle, 60, buffer, length, out length) != 0) return null;
|
|
1434
|
-
return Marshal.PtrToStringUni(Marshal.ReadIntPtr(buffer, IntPtr.Size), (ushort)Marshal.ReadInt16(buffer) / 2);
|
|
1435
|
-
} finally { Marshal.FreeHGlobal(buffer); }
|
|
1436
|
-
}
|
|
1437
|
-
public static string Table() {
|
|
1438
|
-
var rows = new StringBuilder();
|
|
1439
|
-
var kept = new Dictionary<string, string>();
|
|
1440
|
-
var keptTags = new Dictionary<string, string>();
|
|
1441
|
-
IntPtr snap = CreateToolhelp32Snapshot(2, 0);
|
|
1442
|
-
if (snap == new IntPtr(-1)) throw new InvalidOperationException("no process snapshot");
|
|
1443
|
-
try {
|
|
1444
|
-
var entry = new Entry();
|
|
1445
|
-
entry.size = (uint)Marshal.SizeOf(typeof(Entry));
|
|
1446
|
-
for (bool more = Process32FirstW(snap, ref entry); more; more = Process32NextW(snap, ref entry)) {
|
|
1447
|
-
long created = 0, exited, kernel = 0, user = 0;
|
|
1448
|
-
ulong workingSet = 0;
|
|
1449
|
-
string command = "";
|
|
1450
|
-
string tag = "\\t";
|
|
1451
|
-
IntPtr handle = OpenProcess(0x1000, false, entry.pid);
|
|
1452
|
-
if (handle != IntPtr.Zero) {
|
|
1453
|
-
try {
|
|
1454
|
-
GetProcessTimes(handle, out created, out exited, out kernel, out user);
|
|
1455
|
-
Memory memory;
|
|
1456
|
-
if (K32GetProcessMemoryInfo(handle, out memory, (uint)Marshal.SizeOf(typeof(Memory)))) workingSet = (ulong)memory.workingSet;
|
|
1457
|
-
string key = entry.pid + ":" + created;
|
|
1458
|
-
if (!commands.TryGetValue(key, out command)) command = CommandOf(handle);
|
|
1459
|
-
if (command == null) command = "";
|
|
1460
|
-
else kept[key] = command;
|
|
1461
|
-
if (!laneTags.TryGetValue(key, out tag)) tag = LaneTagOf(entry.pid);
|
|
1462
|
-
keptTags[key] = tag;
|
|
1463
|
-
} finally { CloseHandle(handle); }
|
|
1464
|
-
}
|
|
1465
|
-
rows.Append(entry.pid).Append('\\t').Append(entry.ppid).Append('\\t').Append(kernel + user).Append('\\t').Append(workingSet).Append('\\t').Append(created).Append('\\t').Append(tag).Append('\\t').Append(entry.exe).Append('\\t').Append(command.Replace("\\r", " ").Replace("\\n", " ")).Append('\\n');
|
|
1466
|
-
}
|
|
1467
|
-
} finally { CloseHandle(snap); }
|
|
1468
|
-
commands = kept;
|
|
1469
|
-
laneTags = keptTags;
|
|
1470
|
-
return rows.ToString();
|
|
1471
|
-
}
|
|
1472
|
-
[DllImport("iphlpapi.dll")] static extern uint GetExtendedTcpTable(IntPtr table, ref int size, bool order, int family, int tableClass, uint reserved);
|
|
1473
|
-
public static string Listeners(string ports) {
|
|
1474
|
-
var wanted = new HashSet<int>();
|
|
1475
|
-
foreach (var port in ports.Split(',')) wanted.Add(int.Parse(port));
|
|
1476
|
-
var pids = new StringBuilder();
|
|
1477
|
-
foreach (var family in new[] { 2, 23 }) {
|
|
1478
|
-
int width = family == 2 ? 24 : 56, portAt = family == 2 ? 8 : 20, pidAt = family == 2 ? 20 : 52;
|
|
1479
|
-
int size = 0;
|
|
1480
|
-
GetExtendedTcpTable(IntPtr.Zero, ref size, false, family, 3, 0);
|
|
1481
|
-
IntPtr buffer = Marshal.AllocHGlobal(size);
|
|
1482
|
-
try {
|
|
1483
|
-
uint status;
|
|
1484
|
-
while ((status = GetExtendedTcpTable(buffer, ref size, false, family, 3, 0)) == 122) {
|
|
1485
|
-
Marshal.FreeHGlobal(buffer);
|
|
1486
|
-
buffer = Marshal.AllocHGlobal(size);
|
|
1487
|
-
}
|
|
1488
|
-
if (status != 0) throw new InvalidOperationException("the listening TCP table could not be read: " + status);
|
|
1489
|
-
int count = Marshal.ReadInt32(buffer);
|
|
1490
|
-
for (int i = 0; i < count; i++) {
|
|
1491
|
-
IntPtr row = IntPtr.Add(buffer, 4 + i * width);
|
|
1492
|
-
int raw = Marshal.ReadInt32(row, portAt);
|
|
1493
|
-
if (wanted.Contains(((raw & 0xFF) << 8) | ((raw >> 8) & 0xFF))) pids.Append(Marshal.ReadInt32(row, pidAt)).Append('\\n');
|
|
1494
|
-
}
|
|
1495
|
-
} finally { Marshal.FreeHGlobal(buffer); }
|
|
1496
|
-
}
|
|
1497
|
-
return pids.ToString();
|
|
1498
|
-
}
|
|
1499
|
-
[StructLayout(LayoutKind.Sequential)]
|
|
1500
|
-
struct Accounting { public long user, kernel, periodUser, periodKernel; public uint faults, total, active, terminated; }
|
|
1501
|
-
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern IntPtr CreateJobObjectW(IntPtr attributes, string name);
|
|
1502
|
-
[DllImport("kernel32.dll", SetLastError = true)] static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
|
|
1503
|
-
[DllImport("kernel32.dll")] static extern bool IsProcessInJob(IntPtr process, IntPtr job, out bool inside);
|
|
1504
|
-
[DllImport("kernel32.dll", SetLastError = true)] static extern bool QueryInformationJobObject(IntPtr job, int infoClass, out Accounting info, int length, IntPtr returned);
|
|
1505
|
-
[DllImport("kernel32.dll", SetLastError = true)] static extern bool QueryInformationJobObject(IntPtr job, int infoClass, IntPtr info, int length, IntPtr returned);
|
|
1506
|
-
static Dictionary<string, IntPtr> jobs = new Dictionary<string, IntPtr>();
|
|
1507
|
-
static long JobTicks(IntPtr job, out uint total, out uint active) {
|
|
1508
|
-
Accounting a;
|
|
1509
|
-
if (!QueryInformationJobObject(job, 1, out a, Marshal.SizeOf(typeof(Accounting)), IntPtr.Zero)) throw new InvalidOperationException("job accounting unread: " + Marshal.GetLastWin32Error());
|
|
1510
|
-
total = a.total; active = a.active;
|
|
1511
|
-
return a.user + a.kernel;
|
|
1512
|
-
}
|
|
1513
|
-
static string JobPids(IntPtr job) {
|
|
1514
|
-
for (int room = 256; ; room *= 4) {
|
|
1515
|
-
IntPtr buffer = Marshal.AllocHGlobal(8 + room * IntPtr.Size);
|
|
1516
|
-
try {
|
|
1517
|
-
if (QueryInformationJobObject(job, 3, buffer, 8 + room * IntPtr.Size, IntPtr.Zero)) {
|
|
1518
|
-
var ids = new StringBuilder();
|
|
1519
|
-
int listed = Marshal.ReadInt32(buffer, 4);
|
|
1520
|
-
for (int i = 0; i < listed; i++) ids.Append(i == 0 ? "" : ",").Append(Marshal.ReadIntPtr(buffer, 8 + i * IntPtr.Size).ToInt64());
|
|
1521
|
-
return ids.ToString();
|
|
1522
|
-
}
|
|
1523
|
-
if (Marshal.GetLastWin32Error() != 234) throw new InvalidOperationException("job process list unread: " + Marshal.GetLastWin32Error());
|
|
1524
|
-
} finally { Marshal.FreeHGlobal(buffer); }
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
static IntPtr JobOf(string name) {
|
|
1528
|
-
IntPtr job;
|
|
1529
|
-
if (jobs.TryGetValue(name, out job)) return job;
|
|
1530
|
-
job = CreateJobObjectW(IntPtr.Zero, "Local\\\\FleetViewLane-" + name);
|
|
1531
|
-
if (job == IntPtr.Zero) throw new InvalidOperationException("job " + name + " not created: " + Marshal.GetLastWin32Error());
|
|
1532
|
-
jobs[name] = job;
|
|
1533
|
-
return job;
|
|
1534
|
-
}
|
|
1535
|
-
public static string Lanes(string request) {
|
|
1536
|
-
var rows = new StringBuilder();
|
|
1537
|
-
var asked = new HashSet<string>();
|
|
1538
|
-
foreach (var lane in request.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) {
|
|
1539
|
-
int eq = lane.IndexOf('=');
|
|
1540
|
-
string name = eq == -1 ? lane : lane.Substring(0, eq);
|
|
1541
|
-
asked.Add(name);
|
|
1542
|
-
try {
|
|
1543
|
-
IntPtr job = JobOf(name);
|
|
1544
|
-
long jump = 0;
|
|
1545
|
-
var refused = new StringBuilder();
|
|
1546
|
-
var assigned = new StringBuilder();
|
|
1547
|
-
foreach (var who in eq == -1 ? new string[0] : lane.Substring(eq + 1).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) {
|
|
1548
|
-
int at = who.IndexOf('@');
|
|
1549
|
-
uint pid = uint.Parse(who.Substring(0, at));
|
|
1550
|
-
long start = long.Parse(who.Substring(at + 1));
|
|
1551
|
-
IntPtr handle = OpenProcess(0x1000 | 0x0100 | 0x0001, false, pid);
|
|
1552
|
-
if (handle == IntPtr.Zero) { refused.Append(refused.Length == 0 ? "" : ",").Append(pid).Append(":gone"); continue; }
|
|
1553
|
-
try {
|
|
1554
|
-
long created, exited, kernel, user;
|
|
1555
|
-
bool inside;
|
|
1556
|
-
if (!GetProcessTimes(handle, out created, out exited, out kernel, out user) || (created - 116444736000000000L) / 10000 != start) { refused.Append(refused.Length == 0 ? "" : ",").Append(pid).Append(":reused"); continue; }
|
|
1557
|
-
if (IsProcessInJob(handle, job, out inside) && inside) continue;
|
|
1558
|
-
uint total, active;
|
|
1559
|
-
long before = JobTicks(job, out total, out active);
|
|
1560
|
-
if (!AssignProcessToJobObject(job, handle)) { refused.Append(refused.Length == 0 ? "" : ",").Append(pid).Append(':').Append(Marshal.GetLastWin32Error()); continue; }
|
|
1561
|
-
jump += JobTicks(job, out total, out active) - before;
|
|
1562
|
-
assigned.Append(assigned.Length == 0 ? "" : ",").Append(pid);
|
|
1563
|
-
} finally { CloseHandle(handle); }
|
|
1564
|
-
}
|
|
1565
|
-
uint processes, live;
|
|
1566
|
-
long ticks = JobTicks(job, out processes, out live);
|
|
1567
|
-
rows.Append(name).Append('\\t').Append(ticks).Append('\\t').Append(jump).Append('\\t').Append(processes).Append('\\t').Append(live).Append('\\t').Append(JobPids(job)).Append('\\t').Append(assigned.ToString()).Append('\\t').Append(refused.ToString()).Append('\\n');
|
|
1568
|
-
} catch (InvalidOperationException e) {
|
|
1569
|
-
rows.Append(name).Append("\\tunread\\t").Append(e.GetType().Name).Append(": ").Append(e.Message.Replace("\\t", " ").Replace("\\r", " ").Replace("\\n", " ")).Append('\\n');
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
foreach (var name in new List<string>(jobs.Keys)) {
|
|
1573
|
-
if (!asked.Contains(name)) { CloseHandle(jobs[name]); jobs.Remove(name); }
|
|
1574
|
-
}
|
|
1575
|
-
return rows.ToString();
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
'@
|
|
1579
|
-
[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding $false
|
|
1580
|
-
while ($null -ne ($request = [Console]::In.ReadLine())) {
|
|
1581
|
-
if ($request.StartsWith('ports ')) { [Console]::Out.Write([AgentSessionProcessTable]::Listeners($request.Substring(6))) }
|
|
1582
|
-
elseif ($request.StartsWith('lanes ')) { [Console]::Out.Write([AgentSessionProcessTable]::Lanes($request.Substring(6))) }
|
|
1583
|
-
else { [Console]::Out.Write([AgentSessionProcessTable]::Table()) }
|
|
1584
|
-
[Console]::Out.Write("${TABLE_END}\`n")
|
|
1585
|
-
[Console]::Out.Flush()
|
|
1586
|
-
}
|
|
1369
|
+
const WINDOWS_TABLE_SCRIPT = `$ErrorActionPreference = 'Stop'
|
|
1370
|
+
Add-Type -TypeDefinition @'
|
|
1371
|
+
using System;
|
|
1372
|
+
using System.Collections.Generic;
|
|
1373
|
+
using System.Runtime.InteropServices;
|
|
1374
|
+
using System.Text;
|
|
1375
|
+
public static class AgentSessionProcessTable {
|
|
1376
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
1377
|
+
struct Entry { public uint size, usage, pid; public IntPtr heap; public uint module, threads, ppid; public int priority; public uint flags; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string exe; }
|
|
1378
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
1379
|
+
struct Memory { public uint cb, faults; public UIntPtr peakWorkingSet, workingSet, a, b, c, d, e, f; }
|
|
1380
|
+
[DllImport("kernel32.dll")] static extern IntPtr CreateToolhelp32Snapshot(uint flags, uint pid);
|
|
1381
|
+
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)] static extern bool Process32FirstW(IntPtr snap, ref Entry entry);
|
|
1382
|
+
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)] static extern bool Process32NextW(IntPtr snap, ref Entry entry);
|
|
1383
|
+
[DllImport("kernel32.dll")] static extern IntPtr OpenProcess(uint access, bool inherit, uint pid);
|
|
1384
|
+
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
|
|
1385
|
+
[DllImport("kernel32.dll")] static extern bool GetProcessTimes(IntPtr handle, out long created, out long exited, out long kernel, out long user);
|
|
1386
|
+
[DllImport("kernel32.dll")] static extern bool K32GetProcessMemoryInfo(IntPtr handle, out Memory memory, uint cb);
|
|
1387
|
+
[DllImport("ntdll.dll")] static extern int NtQueryInformationProcess(IntPtr handle, int infoClass, IntPtr buffer, int length, out int returned);
|
|
1388
|
+
static Dictionary<string, string> commands = new Dictionary<string, string>();
|
|
1389
|
+
static Dictionary<string, string> laneTags = new Dictionary<string, string>();
|
|
1390
|
+
[DllImport("kernel32.dll")] static extern bool ReadProcessMemory(IntPtr process, IntPtr address, byte[] buffer, IntPtr size, out IntPtr read);
|
|
1391
|
+
static IntPtr PointerAt(IntPtr process, IntPtr address) {
|
|
1392
|
+
var cell = new byte[8];
|
|
1393
|
+
IntPtr read;
|
|
1394
|
+
if (!ReadProcessMemory(process, address, cell, new IntPtr(8), out read) || read.ToInt64() != 8) return IntPtr.Zero;
|
|
1395
|
+
return new IntPtr(BitConverter.ToInt64(cell, 0));
|
|
1396
|
+
}
|
|
1397
|
+
static string EnvTag(string text, string name) {
|
|
1398
|
+
string marker = "\\0" + name + "=";
|
|
1399
|
+
int at = text.IndexOf(marker, StringComparison.Ordinal);
|
|
1400
|
+
if (at == -1) return "";
|
|
1401
|
+
int from = at + marker.Length, end = text.IndexOf('\\0', from);
|
|
1402
|
+
string tag = end == -1 ? text.Substring(from) : text.Substring(from, end - from);
|
|
1403
|
+
foreach (char c in tag) if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_' || c == ':' || c == '.')) return "";
|
|
1404
|
+
return tag;
|
|
1405
|
+
}
|
|
1406
|
+
static string LaneTagOf(uint pid) {
|
|
1407
|
+
const string none = "\\t";
|
|
1408
|
+
IntPtr handle = OpenProcess(0x1000 | 0x0010, false, pid);
|
|
1409
|
+
if (handle == IntPtr.Zero) return none;
|
|
1410
|
+
try {
|
|
1411
|
+
IntPtr basic = Marshal.AllocHGlobal(48);
|
|
1412
|
+
int returned;
|
|
1413
|
+
IntPtr peb;
|
|
1414
|
+
try {
|
|
1415
|
+
if (IntPtr.Size != 8 || NtQueryInformationProcess(handle, 0, basic, 48, out returned) != 0) return none;
|
|
1416
|
+
peb = Marshal.ReadIntPtr(basic, 8);
|
|
1417
|
+
} finally { Marshal.FreeHGlobal(basic); }
|
|
1418
|
+
IntPtr parameters = PointerAt(handle, IntPtr.Add(peb, 0x20));
|
|
1419
|
+
if (parameters == IntPtr.Zero) return none;
|
|
1420
|
+
IntPtr environment = PointerAt(handle, IntPtr.Add(parameters, 0x80));
|
|
1421
|
+
long size = PointerAt(handle, IntPtr.Add(parameters, 0x3F0)).ToInt64();
|
|
1422
|
+
if (environment == IntPtr.Zero || size <= 0 || size > 1048576) return none;
|
|
1423
|
+
var block = new byte[size];
|
|
1424
|
+
IntPtr got;
|
|
1425
|
+
if (!ReadProcessMemory(handle, environment, block, new IntPtr(size), out got)) return none;
|
|
1426
|
+
string text = "\\0" + Encoding.Unicode.GetString(block, 0, (int)got.ToInt64());
|
|
1427
|
+
return EnvTag(text, "BULLSEYE_LANE") + "\\t" + EnvTag(text, "CODEX_THREAD_ID");
|
|
1428
|
+
} finally { CloseHandle(handle); }
|
|
1429
|
+
}
|
|
1430
|
+
static string CommandOf(IntPtr handle) {
|
|
1431
|
+
int length;
|
|
1432
|
+
NtQueryInformationProcess(handle, 60, IntPtr.Zero, 0, out length);
|
|
1433
|
+
if (length <= 0) return null;
|
|
1434
|
+
IntPtr buffer = Marshal.AllocHGlobal(length);
|
|
1435
|
+
try {
|
|
1436
|
+
if (NtQueryInformationProcess(handle, 60, buffer, length, out length) != 0) return null;
|
|
1437
|
+
return Marshal.PtrToStringUni(Marshal.ReadIntPtr(buffer, IntPtr.Size), (ushort)Marshal.ReadInt16(buffer) / 2);
|
|
1438
|
+
} finally { Marshal.FreeHGlobal(buffer); }
|
|
1439
|
+
}
|
|
1440
|
+
public static string Table() {
|
|
1441
|
+
var rows = new StringBuilder();
|
|
1442
|
+
var kept = new Dictionary<string, string>();
|
|
1443
|
+
var keptTags = new Dictionary<string, string>();
|
|
1444
|
+
IntPtr snap = CreateToolhelp32Snapshot(2, 0);
|
|
1445
|
+
if (snap == new IntPtr(-1)) throw new InvalidOperationException("no process snapshot");
|
|
1446
|
+
try {
|
|
1447
|
+
var entry = new Entry();
|
|
1448
|
+
entry.size = (uint)Marshal.SizeOf(typeof(Entry));
|
|
1449
|
+
for (bool more = Process32FirstW(snap, ref entry); more; more = Process32NextW(snap, ref entry)) {
|
|
1450
|
+
long created = 0, exited, kernel = 0, user = 0;
|
|
1451
|
+
ulong workingSet = 0;
|
|
1452
|
+
string command = "";
|
|
1453
|
+
string tag = "\\t";
|
|
1454
|
+
IntPtr handle = OpenProcess(0x1000, false, entry.pid);
|
|
1455
|
+
if (handle != IntPtr.Zero) {
|
|
1456
|
+
try {
|
|
1457
|
+
GetProcessTimes(handle, out created, out exited, out kernel, out user);
|
|
1458
|
+
Memory memory;
|
|
1459
|
+
if (K32GetProcessMemoryInfo(handle, out memory, (uint)Marshal.SizeOf(typeof(Memory)))) workingSet = (ulong)memory.workingSet;
|
|
1460
|
+
string key = entry.pid + ":" + created;
|
|
1461
|
+
if (!commands.TryGetValue(key, out command)) command = CommandOf(handle);
|
|
1462
|
+
if (command == null) command = "";
|
|
1463
|
+
else kept[key] = command;
|
|
1464
|
+
if (!laneTags.TryGetValue(key, out tag)) tag = LaneTagOf(entry.pid);
|
|
1465
|
+
keptTags[key] = tag;
|
|
1466
|
+
} finally { CloseHandle(handle); }
|
|
1467
|
+
}
|
|
1468
|
+
rows.Append(entry.pid).Append('\\t').Append(entry.ppid).Append('\\t').Append(kernel + user).Append('\\t').Append(workingSet).Append('\\t').Append(created).Append('\\t').Append(tag).Append('\\t').Append(entry.exe).Append('\\t').Append(command.Replace("\\r", " ").Replace("\\n", " ")).Append('\\n');
|
|
1469
|
+
}
|
|
1470
|
+
} finally { CloseHandle(snap); }
|
|
1471
|
+
commands = kept;
|
|
1472
|
+
laneTags = keptTags;
|
|
1473
|
+
return rows.ToString();
|
|
1474
|
+
}
|
|
1475
|
+
[DllImport("iphlpapi.dll")] static extern uint GetExtendedTcpTable(IntPtr table, ref int size, bool order, int family, int tableClass, uint reserved);
|
|
1476
|
+
public static string Listeners(string ports) {
|
|
1477
|
+
var wanted = new HashSet<int>();
|
|
1478
|
+
foreach (var port in ports.Split(',')) wanted.Add(int.Parse(port));
|
|
1479
|
+
var pids = new StringBuilder();
|
|
1480
|
+
foreach (var family in new[] { 2, 23 }) {
|
|
1481
|
+
int width = family == 2 ? 24 : 56, portAt = family == 2 ? 8 : 20, pidAt = family == 2 ? 20 : 52;
|
|
1482
|
+
int size = 0;
|
|
1483
|
+
GetExtendedTcpTable(IntPtr.Zero, ref size, false, family, 3, 0);
|
|
1484
|
+
IntPtr buffer = Marshal.AllocHGlobal(size);
|
|
1485
|
+
try {
|
|
1486
|
+
uint status;
|
|
1487
|
+
while ((status = GetExtendedTcpTable(buffer, ref size, false, family, 3, 0)) == 122) {
|
|
1488
|
+
Marshal.FreeHGlobal(buffer);
|
|
1489
|
+
buffer = Marshal.AllocHGlobal(size);
|
|
1490
|
+
}
|
|
1491
|
+
if (status != 0) throw new InvalidOperationException("the listening TCP table could not be read: " + status);
|
|
1492
|
+
int count = Marshal.ReadInt32(buffer);
|
|
1493
|
+
for (int i = 0; i < count; i++) {
|
|
1494
|
+
IntPtr row = IntPtr.Add(buffer, 4 + i * width);
|
|
1495
|
+
int raw = Marshal.ReadInt32(row, portAt);
|
|
1496
|
+
if (wanted.Contains(((raw & 0xFF) << 8) | ((raw >> 8) & 0xFF))) pids.Append(Marshal.ReadInt32(row, pidAt)).Append('\\n');
|
|
1497
|
+
}
|
|
1498
|
+
} finally { Marshal.FreeHGlobal(buffer); }
|
|
1499
|
+
}
|
|
1500
|
+
return pids.ToString();
|
|
1501
|
+
}
|
|
1502
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
1503
|
+
struct Accounting { public long user, kernel, periodUser, periodKernel; public uint faults, total, active, terminated; }
|
|
1504
|
+
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern IntPtr CreateJobObjectW(IntPtr attributes, string name);
|
|
1505
|
+
[DllImport("kernel32.dll", SetLastError = true)] static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
|
|
1506
|
+
[DllImport("kernel32.dll")] static extern bool IsProcessInJob(IntPtr process, IntPtr job, out bool inside);
|
|
1507
|
+
[DllImport("kernel32.dll", SetLastError = true)] static extern bool QueryInformationJobObject(IntPtr job, int infoClass, out Accounting info, int length, IntPtr returned);
|
|
1508
|
+
[DllImport("kernel32.dll", SetLastError = true)] static extern bool QueryInformationJobObject(IntPtr job, int infoClass, IntPtr info, int length, IntPtr returned);
|
|
1509
|
+
static Dictionary<string, IntPtr> jobs = new Dictionary<string, IntPtr>();
|
|
1510
|
+
static long JobTicks(IntPtr job, out uint total, out uint active) {
|
|
1511
|
+
Accounting a;
|
|
1512
|
+
if (!QueryInformationJobObject(job, 1, out a, Marshal.SizeOf(typeof(Accounting)), IntPtr.Zero)) throw new InvalidOperationException("job accounting unread: " + Marshal.GetLastWin32Error());
|
|
1513
|
+
total = a.total; active = a.active;
|
|
1514
|
+
return a.user + a.kernel;
|
|
1515
|
+
}
|
|
1516
|
+
static string JobPids(IntPtr job) {
|
|
1517
|
+
for (int room = 256; ; room *= 4) {
|
|
1518
|
+
IntPtr buffer = Marshal.AllocHGlobal(8 + room * IntPtr.Size);
|
|
1519
|
+
try {
|
|
1520
|
+
if (QueryInformationJobObject(job, 3, buffer, 8 + room * IntPtr.Size, IntPtr.Zero)) {
|
|
1521
|
+
var ids = new StringBuilder();
|
|
1522
|
+
int listed = Marshal.ReadInt32(buffer, 4);
|
|
1523
|
+
for (int i = 0; i < listed; i++) ids.Append(i == 0 ? "" : ",").Append(Marshal.ReadIntPtr(buffer, 8 + i * IntPtr.Size).ToInt64());
|
|
1524
|
+
return ids.ToString();
|
|
1525
|
+
}
|
|
1526
|
+
if (Marshal.GetLastWin32Error() != 234) throw new InvalidOperationException("job process list unread: " + Marshal.GetLastWin32Error());
|
|
1527
|
+
} finally { Marshal.FreeHGlobal(buffer); }
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
static IntPtr JobOf(string name) {
|
|
1531
|
+
IntPtr job;
|
|
1532
|
+
if (jobs.TryGetValue(name, out job)) return job;
|
|
1533
|
+
job = CreateJobObjectW(IntPtr.Zero, "Local\\\\FleetViewLane-" + name);
|
|
1534
|
+
if (job == IntPtr.Zero) throw new InvalidOperationException("job " + name + " not created: " + Marshal.GetLastWin32Error());
|
|
1535
|
+
jobs[name] = job;
|
|
1536
|
+
return job;
|
|
1537
|
+
}
|
|
1538
|
+
public static string Lanes(string request) {
|
|
1539
|
+
var rows = new StringBuilder();
|
|
1540
|
+
var asked = new HashSet<string>();
|
|
1541
|
+
foreach (var lane in request.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) {
|
|
1542
|
+
int eq = lane.IndexOf('=');
|
|
1543
|
+
string name = eq == -1 ? lane : lane.Substring(0, eq);
|
|
1544
|
+
asked.Add(name);
|
|
1545
|
+
try {
|
|
1546
|
+
IntPtr job = JobOf(name);
|
|
1547
|
+
long jump = 0;
|
|
1548
|
+
var refused = new StringBuilder();
|
|
1549
|
+
var assigned = new StringBuilder();
|
|
1550
|
+
foreach (var who in eq == -1 ? new string[0] : lane.Substring(eq + 1).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) {
|
|
1551
|
+
int at = who.IndexOf('@');
|
|
1552
|
+
uint pid = uint.Parse(who.Substring(0, at));
|
|
1553
|
+
long start = long.Parse(who.Substring(at + 1));
|
|
1554
|
+
IntPtr handle = OpenProcess(0x1000 | 0x0100 | 0x0001, false, pid);
|
|
1555
|
+
if (handle == IntPtr.Zero) { refused.Append(refused.Length == 0 ? "" : ",").Append(pid).Append(":gone"); continue; }
|
|
1556
|
+
try {
|
|
1557
|
+
long created, exited, kernel, user;
|
|
1558
|
+
bool inside;
|
|
1559
|
+
if (!GetProcessTimes(handle, out created, out exited, out kernel, out user) || (created - 116444736000000000L) / 10000 != start) { refused.Append(refused.Length == 0 ? "" : ",").Append(pid).Append(":reused"); continue; }
|
|
1560
|
+
if (IsProcessInJob(handle, job, out inside) && inside) continue;
|
|
1561
|
+
uint total, active;
|
|
1562
|
+
long before = JobTicks(job, out total, out active);
|
|
1563
|
+
if (!AssignProcessToJobObject(job, handle)) { refused.Append(refused.Length == 0 ? "" : ",").Append(pid).Append(':').Append(Marshal.GetLastWin32Error()); continue; }
|
|
1564
|
+
jump += JobTicks(job, out total, out active) - before;
|
|
1565
|
+
assigned.Append(assigned.Length == 0 ? "" : ",").Append(pid);
|
|
1566
|
+
} finally { CloseHandle(handle); }
|
|
1567
|
+
}
|
|
1568
|
+
uint processes, live;
|
|
1569
|
+
long ticks = JobTicks(job, out processes, out live);
|
|
1570
|
+
rows.Append(name).Append('\\t').Append(ticks).Append('\\t').Append(jump).Append('\\t').Append(processes).Append('\\t').Append(live).Append('\\t').Append(JobPids(job)).Append('\\t').Append(assigned.ToString()).Append('\\t').Append(refused.ToString()).Append('\\n');
|
|
1571
|
+
} catch (InvalidOperationException e) {
|
|
1572
|
+
rows.Append(name).Append("\\tunread\\t").Append(e.GetType().Name).Append(": ").Append(e.Message.Replace("\\t", " ").Replace("\\r", " ").Replace("\\n", " ")).Append('\\n');
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
foreach (var name in new List<string>(jobs.Keys)) {
|
|
1576
|
+
if (!asked.Contains(name)) { CloseHandle(jobs[name]); jobs.Remove(name); }
|
|
1577
|
+
}
|
|
1578
|
+
return rows.ToString();
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
'@
|
|
1582
|
+
[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding $false
|
|
1583
|
+
while ($null -ne ($request = [Console]::In.ReadLine())) {
|
|
1584
|
+
if ($request.StartsWith('ports ')) { [Console]::Out.Write([AgentSessionProcessTable]::Listeners($request.Substring(6))) }
|
|
1585
|
+
elseif ($request.StartsWith('lanes ')) { [Console]::Out.Write([AgentSessionProcessTable]::Lanes($request.Substring(6))) }
|
|
1586
|
+
else { [Console]::Out.Write([AgentSessionProcessTable]::Table()) }
|
|
1587
|
+
[Console]::Out.Write("${TABLE_END}\`n")
|
|
1588
|
+
[Console]::Out.Flush()
|
|
1589
|
+
}
|
|
1587
1590
|
`;
|
|
1588
1591
|
/**
|
|
1589
1592
|
* #1895 · #10371 — the MSYS table `ps -W` printed (PID PPID PGID WINPID first on every row), read from the Git Bash's own
|
|
1590
1593
|
* `/proc` with shell builtins only, so answering a sample starts no program.
|
|
1591
1594
|
*/
|
|
1592
|
-
const MSYS_TABLE_SCRIPT = `while IFS= read -r _; do
|
|
1593
|
-
for d in /proc/[0-9]*; do
|
|
1594
|
-
{ read -r pp < "$d/ppid"; read -r pg < "$d/pgid"; read -r w < "$d/winpid"; } 2>/dev/null || continue
|
|
1595
|
-
printf '%s %s %s %s .\\n' "\${d#/proc/}" "$pp" "$pg" "$w"
|
|
1596
|
-
done
|
|
1597
|
-
printf '\\004END\\n'
|
|
1598
|
-
done
|
|
1595
|
+
const MSYS_TABLE_SCRIPT = `while IFS= read -r _; do
|
|
1596
|
+
for d in /proc/[0-9]*; do
|
|
1597
|
+
{ read -r pp < "$d/ppid"; read -r pg < "$d/pgid"; read -r w < "$d/winpid"; } 2>/dev/null || continue
|
|
1598
|
+
printf '%s %s %s %s .\\n' "\${d#/proc/}" "$pp" "$pg" "$w"
|
|
1599
|
+
done
|
|
1600
|
+
printf '\\004END\\n'
|
|
1601
|
+
done
|
|
1599
1602
|
`;
|
|
1600
1603
|
export class ProcessTableUnreadable extends Error {
|
|
1601
1604
|
}
|
|
@@ -3066,6 +3069,29 @@ export class WorkerRefused extends WorkerNotStarted {
|
|
|
3066
3069
|
this.name = "WorkerRefused";
|
|
3067
3070
|
}
|
|
3068
3071
|
}
|
|
3072
|
+
/** #4230 — whether this process is the agent cluster: set once at the cluster's own bootstrap; every other process (FleetView, BullseyeNotif) starts as the fleet. */
|
|
3073
|
+
let startsAsCluster = false;
|
|
3074
|
+
/** #4230 — the agent cluster's bootstrap: from now on this process's own starts pass the fence only for a provider the cluster owns. */
|
|
3075
|
+
export function startAsCluster() {
|
|
3076
|
+
startsAsCluster = true;
|
|
3077
|
+
}
|
|
3078
|
+
/**
|
|
3079
|
+
* #4230 — THE FENCE EVERY AGENT START AND WAKE PASSES IN THE SAME TICK AS ITS NATIVE EFFECT: refused, unsent, unless this process's side — the fleet, or the
|
|
3080
|
+
* agent cluster — owns `provider` at that instant. A start that passed it acted before any later hand-over, so its agent is the fleet's that started it.
|
|
3081
|
+
*/
|
|
3082
|
+
export function fenceStart(provider, what) {
|
|
3083
|
+
let owner;
|
|
3084
|
+
try {
|
|
3085
|
+
owner = startOwnerOf(provider);
|
|
3086
|
+
}
|
|
3087
|
+
catch (err) {
|
|
3088
|
+
if (!(err instanceof OwnershipUnreadable))
|
|
3089
|
+
throw err;
|
|
3090
|
+
throw new WorkerRefused(`${what} was not started: ${err.message}`);
|
|
3091
|
+
}
|
|
3092
|
+
if ((owner === CLUSTER_OWNER) !== startsAsCluster)
|
|
3093
|
+
throw new WorkerRefused(`${what} was not started: ${provider} agents are started by ${owner === CLUSTER_OWNER ? "the agent cluster (handed over under #4230)" : "the fleet (FleetView and BullseyeNotif)"} now, not by this process`);
|
|
3094
|
+
}
|
|
3069
3095
|
// GATE: the first wait before a parked worker is woken in its own session; doubled for each earlier wake up to WAKE_DOUBLINGS, so a worker that keeps stopping is woken less often but is never given up on
|
|
3070
3096
|
export const WAKE_BASE_MS = 60_000;
|
|
3071
3097
|
// GATE: how many times the wait doubles — past it a parked worker is woken every WAKE_BASE_MS * 2^WAKE_DOUBLINGS (32 min)
|
|
@@ -3095,17 +3121,17 @@ const killedAfterWork = (worker, parked) => parked.killed === true && worker.pro
|
|
|
3095
3121
|
/** 🔴 #4162 — how long a parked worker waits before it is woken: none when {@link killedAfterWork}, else {@link wakeDelayMs} — so a session that dies on waking, whose only write is the wake's own message, still backs off and never wakes in a loop. */
|
|
3096
3122
|
export const parkedWaitMs = (worker, parked) => (killedAfterWork(worker, parked) ? 0 : wakeDelayMs(worker.wakes ?? 0));
|
|
3097
3123
|
/** 🔴 #4123 — where every queue worker stands, said at its start and at each wake: what it clears itself, and how a decision of Meni's reaches him and comes back. */
|
|
3098
|
-
const workerStanding = (storyId) => `A stop you named that you or another agent can clear (a board write refused, the board MCP not loaded yet, a release step) is yours to clear now — never a reason to end your turn. A run the box's CPU ceiling refuses is never a reason to end your turn or to say you will retry later — nothing wakes you for it: in the same turn rerun that one test as its own call with \`BULLSEYE_TEST_HERE=1\`, which sends it to the freest box, never the Mac, or hold ONE bounded background wait (at most 10 minutes) inside this turn and then rerun; never stop or kill a process to make room.
|
|
3124
|
+
const workerStanding = (storyId) => `A stop you named that you or another agent can clear (a board write refused, the board MCP not loaded yet, a release step) is yours to clear now — never a reason to end your turn. A run the box's CPU ceiling refuses is never a reason to end your turn or to say you will retry later — nothing wakes you for it: in the same turn rerun that one test as its own call with \`BULLSEYE_TEST_HERE=1\`, which sends it to the freest box, never the Mac, or hold ONE bounded background wait (at most 10 minutes) inside this turn and then rerun; never stop or kill a process to make room.
|
|
3099
3125
|
If a decision only Meni can make stands in the way, record it on #${storyId} with bullseye-backlog \`ask\` and ask him with the notify MCP \`ask\` tool, which reaches his email and text; when its wait ends unanswered, keep calling \`wait_for_inbox\` until his reply arrives, then \`rule\` his answer onto #${storyId} verbatim, apply it and go on. End your turn only once the story is shipped.`;
|
|
3100
3126
|
/** 🔴 #4123 — what a parked worker is told when the queue wakes it in its own session. */
|
|
3101
|
-
export const wakeMessage = (storyId) => `FleetView's story queue woke you: #${storyId} is still OPEN on the board and you are its one worker. Re-read it with bullseye-backlog \`get\` and carry it to \`ship\` in this turn.
|
|
3127
|
+
export const wakeMessage = (storyId) => `FleetView's story queue woke you: #${storyId} is still OPEN on the board and you are its one worker. Re-read it with bullseye-backlog \`get\` and carry it to \`ship\` in this turn.
|
|
3102
3128
|
${workerStanding(storyId)}`;
|
|
3103
3129
|
/** 🔴 #4192 — the story a {@link wakeMessage} woke its worker for; the woken worker's folder is that story's board. */
|
|
3104
3130
|
export const WOKEN_STORY = /^FleetView's story queue woke you: #(\d+) /;
|
|
3105
3131
|
/** 🔴 #4123 — the brief a queue worker is started with: the story's own brief first, so its job is still found by its first line, then where a worker with no session above it stands. */
|
|
3106
|
-
export const workerBrief = (entry) => `${entry.brief}
|
|
3107
|
-
|
|
3108
|
-
FleetView's story queue started you on #${entry.storyId}, and no session stands above you; report on the story. Where the brief above speaks of a session to report to — a finding sent up, a turn end that hands you back — nobody is there to take it: a finding with no tie to this story is appended to #${entry.storyId}'s Remaining line — read it with bullseye-backlog \`get\`, then \`update\` it with the old text plus the finding, pinned with the \`expectHash\` the read gave — and the review, the land, the release and the ship are yours.
|
|
3132
|
+
export const workerBrief = (entry) => `${entry.brief}
|
|
3133
|
+
|
|
3134
|
+
FleetView's story queue started you on #${entry.storyId}, and no session stands above you; report on the story. Where the brief above speaks of a session to report to — a finding sent up, a turn end that hands you back — nobody is there to take it: a finding with no tie to this story is appended to #${entry.storyId}'s Remaining line — read it with bullseye-backlog \`get\`, then \`update\` it with the old text plus the finding, pinned with the \`expectHash\` the read gave — and the review, the land, the release and the ship are yours.
|
|
3109
3135
|
${workerStanding(entry.storyId)}`;
|
|
3110
3136
|
// GATE: how many times one story's worker is started before the queue gives up on it and its entry stops in `failed` — each start that ends with the story still open is one
|
|
3111
3137
|
export const WORKER_ATTEMPTS = 3;
|
|
@@ -4248,8 +4274,22 @@ export async function rewakeStoryWorker(board, storyId, jobId, sessionId, messag
|
|
|
4248
4274
|
if (e === undefined)
|
|
4249
4275
|
return undefined;
|
|
4250
4276
|
const parked = e.worker;
|
|
4277
|
+
fenceStart("claude", `the rewake of worker ${jobId}`);
|
|
4251
4278
|
await stopStoryWorker(jobId, cli);
|
|
4252
|
-
|
|
4279
|
+
let woken;
|
|
4280
|
+
try {
|
|
4281
|
+
woken = await wakeStoryWorker(sessionId, message, board, cli, now);
|
|
4282
|
+
}
|
|
4283
|
+
catch (err) {
|
|
4284
|
+
if (!(err instanceof WorkerRefused))
|
|
4285
|
+
throw err;
|
|
4286
|
+
parked.stoppedAt = now;
|
|
4287
|
+
e.state = "withdrawn";
|
|
4288
|
+
e.why = `its worker ${jobId} was stopped to be woken with FleetView's investigator's message, and the wake was refused: ${err.message}; its conversation and worktree are kept, and Start continues it in its own session`;
|
|
4289
|
+
step(e, now, "stopped", e.why);
|
|
4290
|
+
writeWhole(board, storeFile(board), store);
|
|
4291
|
+
throw err;
|
|
4292
|
+
}
|
|
4253
4293
|
e.worker = { ...woken, wakes: (parked.wakes ?? 0) + 1, ...keptSession(parked) };
|
|
4254
4294
|
e.why = `FleetView's investigator redirected its worker ${jobId}, woken in its own session as ${woken.jobId}`;
|
|
4255
4295
|
step(e, now, "woken", e.why);
|
|
@@ -4312,6 +4352,32 @@ export function claudeJobsOfStory(storyId, board, since, home = claudeHome()) {
|
|
|
4312
4352
|
});
|
|
4313
4353
|
return jobs.filter((j) => j.at >= since).sort((a, b) => a.at - b.at).map((j) => j.id);
|
|
4314
4354
|
}
|
|
4355
|
+
/**
|
|
4356
|
+
* #4230 — the `claude --bg` jobs on this machine launched with `--name <name>`, by the launch flags each job's own record keeps (the list `claude agents`
|
|
4357
|
+
* prints may shorten a name). A record caught mid-rewrite is read again; one still torn is thrown, never read as no job.
|
|
4358
|
+
*/
|
|
4359
|
+
export function claudeJobsNamed(name, home = claudeHome()) {
|
|
4360
|
+
const dir = path.join(home, "jobs");
|
|
4361
|
+
if (!fs.existsSync(dir))
|
|
4362
|
+
return [];
|
|
4363
|
+
return fs.readdirSync(dir).filter((id) => {
|
|
4364
|
+
for (let tries = 1;; tries++) {
|
|
4365
|
+
const job = claudeRecordOf(path.join(dir, id, "state.json"));
|
|
4366
|
+
if (job === "gone")
|
|
4367
|
+
return false;
|
|
4368
|
+
if (job !== "torn") {
|
|
4369
|
+
const flags = job.respawnFlags;
|
|
4370
|
+
if (!Array.isArray(flags))
|
|
4371
|
+
throw new Error(`Claude Code's job record ${path.join(dir, id, "state.json")} carries no respawnFlags list, so the --name its job was launched with cannot be read`);
|
|
4372
|
+
const at = flags.indexOf("--name");
|
|
4373
|
+
return at >= 0 && flags[at + 1] === name;
|
|
4374
|
+
}
|
|
4375
|
+
if (tries === 5)
|
|
4376
|
+
throw new Error(`Claude Code's job record ${path.join(dir, id, "state.json")} stayed mid-rewrite across ${tries} reads, so whether it is the job named ${name} is not known`);
|
|
4377
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 50);
|
|
4378
|
+
}
|
|
4379
|
+
});
|
|
4380
|
+
}
|
|
4315
4381
|
/** 🔴 #4143 — the jobs, in any folder, whose brief opens with the same `Stories: #N — <title>` line as `brief`: a story's job started in a worktree or a nested repo, which {@link claudeJobsOfStory} never finds in the board's folder, is still that story's. */
|
|
4316
4382
|
export function claudeJobsBriefed(brief, home = claudeHome()) {
|
|
4317
4383
|
const dir = path.join(home, "jobs");
|
|
@@ -4529,6 +4595,7 @@ const STARTED_A_COPY = /session (\S+) is already running in the background, so t
|
|
|
4529
4595
|
/** 🔴 #4123 — wakes a parked `claude --bg` session in place with `message`: passed no flags, Claude Code continues the same job with its own saved options. */
|
|
4530
4596
|
export function wakeStoryWorker(sessionId, message, board, cli, now) {
|
|
4531
4597
|
return new Promise((resolve, reject) => {
|
|
4598
|
+
fenceStart("claude", `claude --bg --resume ${sessionId}`);
|
|
4532
4599
|
execFile(cli.cmd, [...cli.args, "--bg", "--resume", sessionId, message], { cwd: board, windowsHide: true, timeout: LAUNCH_TIMEOUT_MS }, (err, stdout, stderr) => {
|
|
4533
4600
|
const said = `${stdout}${stderr}`;
|
|
4534
4601
|
const copy = STARTED_A_COPY.exec(said);
|
|
@@ -4875,6 +4942,7 @@ export async function launchClaudeJob(name, model, brief, cwd, cli, now, env = l
|
|
|
4875
4942
|
if (unserved !== undefined)
|
|
4876
4943
|
throw new WorkerRefused(`claude --bg was not started: ${unserved}`);
|
|
4877
4944
|
return new Promise((resolve, reject) => {
|
|
4945
|
+
fenceStart("claude", `claude --bg ${name}`);
|
|
4878
4946
|
execFile(cli.cmd, [...cli.args, "--bg", "--name", name, "--model", model, "--permission-mode", "bypassPermissions", brief], { cwd, windowsHide: true, timeout: LAUNCH_TIMEOUT_MS }, (err, stdout, stderr) => {
|
|
4879
4947
|
const said = `${stdout}${stderr}`;
|
|
4880
4948
|
const job = BACKGROUNDED.exec(said);
|
|
@@ -15,6 +15,7 @@ import { EventEmitter } from "events";
|
|
|
15
15
|
import { basename, dirname, join, resolve } from "path";
|
|
16
16
|
import autoSwitch from "../webhost/autoSwitch.cjs";
|
|
17
17
|
import { workspacesFile, workspacesHere } from "../webhost/workspaceList.js";
|
|
18
|
+
import { CLUSTER_OWNER, OwnershipUnreadable, clusterOwns } from "../providerOwnership.js";
|
|
18
19
|
/** Thrown for a request the caller got wrong; the door turns it into the status code. */
|
|
19
20
|
export class GatewayError extends Error {
|
|
20
21
|
status;
|
|
@@ -32,6 +33,19 @@ export const CONVERSATION_OFF_MESSAGE = "The BN agent conversation is switched o
|
|
|
32
33
|
export const CONVERSATION_MUTED_MESSAGE = "BN is muted: Mute everything is On in the BN Notify tab, so nothing was started and nothing is sent.";
|
|
33
34
|
// GATE: the longest a read may wait for a new event, one second under the 55 s BLOCKING_TOOL_MAX_SECONDS in notify.ts so no call is held past it.
|
|
34
35
|
export const MAX_WAIT_SECONDS = 54;
|
|
36
|
+
/** #4230 — whether `name`'s agents are started by the agent cluster now, so this gateway starts none of them; an unread authority refuses the start. */
|
|
37
|
+
export function clusterHolds(name) {
|
|
38
|
+
try {
|
|
39
|
+
return clusterOwns(name);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (!(err instanceof OwnershipUnreadable))
|
|
43
|
+
throw err;
|
|
44
|
+
throw new GatewayError(503, err.message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** The refusal of a start this gateway no longer makes: `name` was handed to the agent cluster. */
|
|
48
|
+
export const clusterHeld = (name) => new GatewayError(409, `${name} agents are started by the agent cluster now (handed over under #4230); start this one through the cluster's own door, or leave the provider out for one this gateway still starts`, { provider: name, owner: CLUSTER_OWNER });
|
|
35
49
|
export function createConversationStore(host, registry) {
|
|
36
50
|
/** The title the agent's session carries in Claude's session list: the project and the first request, so one session is told from another at a glance. A conversation opened with no message yet is named by its project alone. */
|
|
37
51
|
function titleOf(meta, events) {
|
|
@@ -614,9 +628,11 @@ export function createConversationStore(host, registry) {
|
|
|
614
628
|
}
|
|
615
629
|
/** The agent CLI a session is CREATED on, as its creation named it (#3640): one this gateway runs, or the refusal saying which. */
|
|
616
630
|
function namedProvider(provider) {
|
|
617
|
-
|
|
631
|
+
const named = typeof provider === "string" ? registry().get(provider) : undefined;
|
|
632
|
+
// NULL-OK: field named is OPTIONAL and therefore it is ok to check for NULL
|
|
633
|
+
if (named === undefined)
|
|
618
634
|
throw new GatewayError(400, `provider must be exactly one of ${registry().names.join(", ")}, or left out for the one with subscription room`);
|
|
619
|
-
return
|
|
635
|
+
return named.name;
|
|
620
636
|
}
|
|
621
637
|
// GATE: DeepAgent's door, which a creation naming no provider asks for each provider's room, may be moved ONLY under the test gate — to NOTIFY_DEEPAGENT_API, or with none named to the discard port, which refuses at once so a suite never reads this box's live accounts; without the gate it is DeepAgent's own door.
|
|
622
638
|
function deepagentDoor() {
|
|
@@ -630,9 +646,15 @@ export function createConversationStore(host, registry) {
|
|
|
630
646
|
* workspace root only those that load every project's rules there — weighed by DeepAgent's `provider_room` read for the folder.
|
|
631
647
|
*/
|
|
632
648
|
async function pickedCli(provider, folder) {
|
|
633
|
-
if (provider !== undefined && !(typeof provider === "string" && provider.trim() === ""))
|
|
634
|
-
|
|
635
|
-
|
|
649
|
+
if (provider !== undefined && !(typeof provider === "string" && provider.trim() === "")) {
|
|
650
|
+
const named = namedProvider(provider);
|
|
651
|
+
if (clusterHolds(named))
|
|
652
|
+
throw clusterHeld(named);
|
|
653
|
+
return { provider: named };
|
|
654
|
+
}
|
|
655
|
+
const startable = (isRootFolder(folder) ? registry().names.filter((name) => registry().get(name).routesAtRoot === true) : registry().names).filter((name) => !clusterHolds(name));
|
|
656
|
+
if (startable.length === 0)
|
|
657
|
+
throw new GatewayError(409, `every agent CLI this gateway could start in ${folder} is started by the agent cluster now (handed over under #4230); start this one through the cluster's own door`, { owner: CLUSTER_OWNER });
|
|
636
658
|
if (startable.length === 1) {
|
|
637
659
|
process.stderr.write(`[agent-gateway] no provider named for ${folder}: ${startable[0]}, the one CLI that routes from there\n`);
|
|
638
660
|
return { provider: startable[0] };
|
|
@@ -24,7 +24,7 @@ import { mkdirSync, watch } from "fs";
|
|
|
24
24
|
import { basename } from "path";
|
|
25
25
|
import { DEFAULT_CAPACITY } from "../agentSession.js";
|
|
26
26
|
import { AgentTurnFailed } from "./provider.js";
|
|
27
|
-
import { GatewayError } from "./conversations.js";
|
|
27
|
+
import { GatewayError, clusterHeld, clusterHolds } from "./conversations.js";
|
|
28
28
|
// GATE: a conversation silent this long (8 hours, the passkey sign-in's own span) frees its process; its next message resumes the session.
|
|
29
29
|
export const IDLE_MS = 8 * 60 * 60_000;
|
|
30
30
|
// GATE: Meni's ruling 6A — a turn that has said nothing for this long posts one status line, and another after each such spell.
|
|
@@ -51,6 +51,20 @@ export function sessionDriverClass(runtime) {
|
|
|
51
51
|
const RESUME_PREAMBLE = "(BN restarted while you were working on the message below, and your work on it was cut off. If this session's history shows what you had already done for it, carry on from where you stopped rather than starting over, then answer it.)";
|
|
52
52
|
// GATE: the longest the driver waits before trying again to warm a spare agent once no spare is standing — after its process died, or an open was refused because BN is switched off, muted, or the project it is needed in holds no board; at the boundary the next beat tries again.
|
|
53
53
|
const SPARE_RETRY_MS = 10_000;
|
|
54
|
+
/** #4230 — refuses the start of `name`'s agent when this gateway no longer makes it: handed to the agent cluster, or the ownership authority unread. */
|
|
55
|
+
function refuseClusterStart(name) {
|
|
56
|
+
let held;
|
|
57
|
+
try {
|
|
58
|
+
held = clusterHolds(name);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if (!(err instanceof GatewayError))
|
|
62
|
+
throw err;
|
|
63
|
+
throw new AgentTurnFailed(err.message);
|
|
64
|
+
}
|
|
65
|
+
if (held)
|
|
66
|
+
throw new AgentTurnFailed(clusterHeld(name).message);
|
|
67
|
+
}
|
|
54
68
|
/** The project the next cold first turn needs: that of the most recently active conversation holding no process of its own and written to within the spare's idle bound, so one spare serves the project the next turn lands in; none when no conversation is expecting a turn or its project holds no board. */
|
|
55
69
|
function spareProjectOf(conversations, holding) {
|
|
56
70
|
const cold = conversations.filter((c) => c.state !== "closed" && c.shelf === undefined && !holding.has(c.id)).sort((a, b) => b.lastMessageAt.localeCompare(a.lastMessageAt));
|
|
@@ -99,6 +113,8 @@ export function sessionDriverClass(runtime) {
|
|
|
99
113
|
/** A Claude process already started in the project the next cold first turn needs, with nothing asked of it, so that turn skips the process start and the MCP servers' connect wait. */
|
|
100
114
|
spare;
|
|
101
115
|
nextSpareTryAt = 0;
|
|
116
|
+
/** The last reason a warm spare was refused, so the refusal is logged once each time it changes, not on every beat. */
|
|
117
|
+
spareRefused;
|
|
102
118
|
wakePending = false;
|
|
103
119
|
bootedAt = 0;
|
|
104
120
|
constructor(options) {
|
|
@@ -193,6 +209,23 @@ export function sessionDriverClass(runtime) {
|
|
|
193
209
|
this.spare = undefined;
|
|
194
210
|
return;
|
|
195
211
|
}
|
|
212
|
+
try {
|
|
213
|
+
refuseClusterStart("claude");
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
// OWNER: a warm spare is only a head start, so a refused one must not end the scan — any spare standing is ended, the next beat reads the owner again, and the reason is logged once per change.
|
|
217
|
+
if (!(err instanceof AgentTurnFailed))
|
|
218
|
+
throw err;
|
|
219
|
+
this.spare?.session.end();
|
|
220
|
+
this.spare = undefined;
|
|
221
|
+
if (this.spareRefused !== err.message)
|
|
222
|
+
process.stderr.write(`[agent-gateway] no warm Claude session: ${err.message}
|
|
223
|
+
`);
|
|
224
|
+
this.spareRefused = err.message;
|
|
225
|
+
this.dueBy(Date.now() + SPARE_RETRY_MS);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
this.spareRefused = undefined;
|
|
196
229
|
if (this.spare?.project === project)
|
|
197
230
|
return;
|
|
198
231
|
if (this.spare === undefined && Date.now() < this.nextSpareTryAt) {
|
|
@@ -303,6 +336,14 @@ export function sessionDriverClass(runtime) {
|
|
|
303
336
|
return consoleSession(id);
|
|
304
337
|
if (held !== undefined && inUse(held))
|
|
305
338
|
throw new GatewayError(409, `${held.busy ? `Turn ${held.turn} is` : "A prompt typed into its CLI is"} still running in ${basename(held.project)}; this conversation's CLI opens in its new folder once that ends.`);
|
|
339
|
+
try {
|
|
340
|
+
refuseClusterStart(provider.name);
|
|
341
|
+
}
|
|
342
|
+
catch (err) {
|
|
343
|
+
if (!(err instanceof AgentTurnFailed))
|
|
344
|
+
throw err;
|
|
345
|
+
throw new GatewayError(409, err.message);
|
|
346
|
+
}
|
|
306
347
|
if (held !== undefined)
|
|
307
348
|
this.free(id, "idle");
|
|
308
349
|
while (this.lives.size >= this.capacity) {
|
|
@@ -658,6 +699,7 @@ export function sessionDriverClass(runtime) {
|
|
|
658
699
|
}
|
|
659
700
|
/** Opens the conversation's session on the provider its record names, or takes the spare already started for it. */
|
|
660
701
|
launch(c, provider, project) {
|
|
702
|
+
refuseClusterStart(provider.name);
|
|
661
703
|
let live;
|
|
662
704
|
const spare = this.takeSpare(c, provider, project);
|
|
663
705
|
const target = spare?.target ?? { id: c.id, onGone: () => { }, isStarted: () => readConversation(c.id).started === true };
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import * as os from 'node:os';
|
|
5
|
+
const refused = (reason) => ({ state: 'refused', reason });
|
|
6
|
+
const ok = (value) => ({ state: 'ok', value });
|
|
7
|
+
const text = (v) => typeof v === 'string' && v.trim().length > 0;
|
|
8
|
+
const kinds = ['launch', 'adopt', 'wake', 'send', 'close', 'end'];
|
|
9
|
+
const stamp = (s) => s !== null && typeof s === 'object' && text(s.provider) && text(s.owner) && Number.isSafeInteger(s.generation) && s.generation >= 0;
|
|
10
|
+
const same = (a, b) => a.provider === b.provider && a.owner === b.owner && a.generation === b.generation;
|
|
11
|
+
const sameRequest = (a, b) => same(a, b) && a.requestId === b.requestId && a.kind === b.kind && a.target === b.target && a.intent === b.intent && a.expectedHostId === b.expectedHostId && a.expectedTurnId === b.expectedTurnId && (a.priorOwnership === undefined ? b.priorOwnership === undefined : b.priorOwnership !== undefined && same(a.priorOwnership, b.priorOwnership) && a.priorOwnership.hostId === b.priorOwnership.hostId && a.priorOwnership.turnId === b.priorOwnership.turnId);
|
|
12
|
+
const current = (db, provider) => db.prepare('SELECT provider,owner,generation FROM provider WHERE provider=?').get(provider);
|
|
13
|
+
const decode = (row) => JSON.parse(row.body);
|
|
14
|
+
const admission = (db, r) => { const row = db.prepare('SELECT body FROM admission WHERE requestId=?').get(r.requestId); return row === undefined ? undefined : decode(row); };
|
|
15
|
+
const nativeRow = (row) => ({ provider: row.provider, owner: row.owner, generation: row.generation, nativeId: row.nativeId, active: row.active === 1, hostId: row.hostId, ...(row.turnId === null ? {} : { turnId: row.turnId }), origin: { provider: row.provider, owner: row.originOwner, generation: row.originGeneration, ...(row.originTurnId === null ? {} : { turnId: row.originTurnId }) } });
|
|
16
|
+
const native = (db, provider, id) => { const row = db.prepare('SELECT * FROM session WHERE provider=? AND nativeId=?').get(provider, id); return row === undefined ? undefined : nativeRow(row); };
|
|
17
|
+
const inspect = (db, s) => ({ ...s, readiness: readiness(db, s.provider), admissions: db.prepare('SELECT body FROM admission WHERE provider=? ORDER BY requestId').all(s.provider).map(decode), sessions: db.prepare('SELECT * FROM session WHERE provider=? ORDER BY nativeId').all(s.provider).map(nativeRow) });
|
|
18
|
+
const readiness = (db, provider) => { const row = db.prepare('SELECT barrierId FROM provider WHERE provider=?').get(provider); return row?.barrierId === null || row === undefined ? { state: 'unreconciled' } : { state: 'ready', barrierId: row.barrierId }; };
|
|
19
|
+
const schema = [
|
|
20
|
+
'CREATE TABLE IF NOT EXISTS provider(provider TEXT PRIMARY KEY,owner TEXT NOT NULL,generation INTEGER NOT NULL CHECK(generation>=0),initOwner TEXT NOT NULL,initRequest TEXT NOT NULL,barrierId TEXT,inventory TEXT);',
|
|
21
|
+
'CREATE TABLE IF NOT EXISTS admission(requestId TEXT PRIMARY KEY,provider TEXT NOT NULL,target TEXT NOT NULL,kind TEXT NOT NULL,state TEXT NOT NULL,body TEXT NOT NULL);',
|
|
22
|
+
'CREATE INDEX IF NOT EXISTS admission_state ON admission(provider,state);',
|
|
23
|
+
'CREATE INDEX IF NOT EXISTS admission_target ON admission(provider,target,kind,state);',
|
|
24
|
+
'CREATE TABLE IF NOT EXISTS session(provider TEXT NOT NULL,nativeId TEXT NOT NULL,owner TEXT NOT NULL,generation INTEGER NOT NULL,active INTEGER NOT NULL CHECK(active IN(0,1)),turnId TEXT,originOwner TEXT NOT NULL,originGeneration INTEGER NOT NULL,originTurnId TEXT,hostId TEXT NOT NULL,PRIMARY KEY(provider,nativeId));',
|
|
25
|
+
'CREATE INDEX IF NOT EXISTS session_active ON session(provider,active);',
|
|
26
|
+
'CREATE TABLE IF NOT EXISTS transition(requestId TEXT PRIMARY KEY,provider TEXT NOT NULL,owner TEXT NOT NULL,generation INTEGER NOT NULL,nextOwner TEXT NOT NULL);'
|
|
27
|
+
].join('');
|
|
28
|
+
/** Directory-injected canonical authority. SQLite commits before native effects. Pending/uncertain grants never
|
|
29
|
+
* expire. Indexed admission O(log R), retained storage O(R); snapshot-returning inspect/initialize/reconcile/change enumerate historical requests.
|
|
30
|
+
* Live instance authorization is indexed and makes no durable write, never one record per keystroke.
|
|
31
|
+
*/
|
|
32
|
+
export class ProviderOwnership {
|
|
33
|
+
directory;
|
|
34
|
+
providerIds;
|
|
35
|
+
turnRequirements;
|
|
36
|
+
constructor(directory, providerIds, turnRequirements = {}) { this.directory = directory; this.providerIds = [...providerIds]; this.turnRequirements = { ...turnRequirements }; }
|
|
37
|
+
access(provider, write, create, action) {
|
|
38
|
+
if (!path.isAbsolute(this.directory))
|
|
39
|
+
return refused('the ownership directory must be absolute');
|
|
40
|
+
if (!this.providerIds.includes(provider))
|
|
41
|
+
return refused('unknown provider');
|
|
42
|
+
const file = path.join(this.directory, 'ownership.sqlite');
|
|
43
|
+
if (!create && !fs.existsSync(file))
|
|
44
|
+
return refused('provider ownership is not initialized');
|
|
45
|
+
if (create)
|
|
46
|
+
fs.mkdirSync(this.directory, { recursive: true });
|
|
47
|
+
const { DatabaseSync } = createRequire(file)('node:sqlite');
|
|
48
|
+
const db = new DatabaseSync(file);
|
|
49
|
+
let begun = false;
|
|
50
|
+
try {
|
|
51
|
+
if (create)
|
|
52
|
+
db.exec(schema);
|
|
53
|
+
db.exec(write ? 'PRAGMA synchronous=FULL; BEGIN IMMEDIATE' : 'BEGIN');
|
|
54
|
+
begun = true;
|
|
55
|
+
const result = action(db);
|
|
56
|
+
db.exec('COMMIT');
|
|
57
|
+
begun = false;
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
// OWNER: OS/SQLite failure cannot grant a native effect. Busy refuses this attempt; rollback cannot clear a prior committed admission.
|
|
62
|
+
if (begun)
|
|
63
|
+
db.exec('ROLLBACK');
|
|
64
|
+
if (error.errcode === 5 || error.errcode === 6)
|
|
65
|
+
return { ...refused('ownership authority is busy; retry the same request identity before any native effect'), busy: true };
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
db.close();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** The owner of `provider`'s starts, or undefined when no hand-over ever made its row (the file or the row absent). */
|
|
73
|
+
owner(provider) {
|
|
74
|
+
if (!fs.existsSync(path.join(this.directory, 'ownership.sqlite')))
|
|
75
|
+
return ok(undefined);
|
|
76
|
+
return this.access(provider, false, false, db => ok(current(db, provider)?.owner));
|
|
77
|
+
}
|
|
78
|
+
inspect(provider) { return this.access(provider, false, false, db => { const s = current(db, provider); return s === undefined ? refused('provider ownership is not initialized') : ok(inspect(db, s)); }); }
|
|
79
|
+
/** This read is NOT an independently revocable cross-process lease. The SAME actual native host's input/close serialization caches authorization for this exact native instance. Close/end drains earlier
|
|
80
|
+
* input and revokes the instance BEFORE resolving ended; active sessions prevent all ownership transfer.
|
|
81
|
+
*/
|
|
82
|
+
authorizeSession(expected, nativeId, hostId, turnId) {
|
|
83
|
+
if (!stamp(expected) || !text(nativeId) || !text(hostId))
|
|
84
|
+
return refused('a complete ownership stamp and native identity are required');
|
|
85
|
+
return this.access(expected.provider, false, false, db => {
|
|
86
|
+
const s = current(db, expected.provider);
|
|
87
|
+
if (s === undefined || !same(s, expected))
|
|
88
|
+
return refused('the expected owner or generation is stale');
|
|
89
|
+
if (db.prepare("SELECT 1 FROM admission WHERE provider=? AND target=? AND kind IN ('close','end') AND state IN ('pending','uncertain') LIMIT 1").get(expected.provider, nativeId) !== undefined)
|
|
90
|
+
return refused('the native session is closing; no new live input is authorized');
|
|
91
|
+
const n = native(db, expected.provider, nativeId);
|
|
92
|
+
return n !== undefined && n.active && n.hostId === hostId && same(n, expected) && n.turnId === turnId ? ok(n) : refused('no active native instance belongs to this owner and generation');
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
initialize(provider, owner, requestId) {
|
|
96
|
+
if (!text(owner) || !text(requestId))
|
|
97
|
+
return refused('owner and request identity are required');
|
|
98
|
+
return this.access(provider, true, true, db => {
|
|
99
|
+
const prior = db.prepare('SELECT * FROM provider WHERE provider=?').get(provider);
|
|
100
|
+
if (prior !== undefined)
|
|
101
|
+
return prior.initOwner === owner && prior.initRequest === requestId ? ok(inspect(db, current(db, provider))) : refused('provider ownership already exists');
|
|
102
|
+
db.prepare('INSERT INTO provider VALUES(?,?,0,?,?,NULL,NULL)').run(provider, owner, owner, requestId);
|
|
103
|
+
return ok(inspect(db, { provider, owner, generation: 0 }));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** Bootstrap only AFTER every legacy native mutation is under the canonical barrier. An empty index before this
|
|
107
|
+
* call is NOT a native census. Host must positively inventory existing sessions under that barrier, never guess.
|
|
108
|
+
*/
|
|
109
|
+
reconcile(expected, barrierId, inventory) {
|
|
110
|
+
if (!stamp(expected) || !text(barrierId) || inventory === null || typeof inventory !== 'object' || inventory.state !== 'complete' || !Array.isArray(inventory.sessions))
|
|
111
|
+
return refused('bootstrap requires a complete native inventory under a named mutation barrier');
|
|
112
|
+
if (inventory.sessions.some(n => n === null || typeof n !== 'object' || !text(n.nativeId) || !text(n.hostId) || (n.turnId !== undefined && !text(n.turnId))) || new Set(inventory.sessions.map(n => n.nativeId)).size !== inventory.sessions.length)
|
|
113
|
+
return refused('native inventory needs unique session identities and exact host instances');
|
|
114
|
+
const canonical = JSON.stringify([...inventory.sessions].sort((a, b) => a.nativeId.localeCompare(b.nativeId)).map(n => ({ nativeId: n.nativeId, hostId: n.hostId, ...(n.turnId === undefined ? {} : { turnId: n.turnId }) })));
|
|
115
|
+
return this.access(expected.provider, true, false, db => {
|
|
116
|
+
const s = current(db, expected.provider);
|
|
117
|
+
if (s === undefined || !same(s, expected))
|
|
118
|
+
return refused('the expected owner or generation is stale');
|
|
119
|
+
const row = db.prepare('SELECT barrierId,inventory FROM provider WHERE provider=?').get(expected.provider);
|
|
120
|
+
if (row.barrierId !== null)
|
|
121
|
+
return row.barrierId === barrierId && row.inventory === canonical ? ok(inspect(db, s)) : refused('bootstrap reconciliation already has different evidence');
|
|
122
|
+
if (db.prepare('SELECT 1 FROM admission WHERE provider=? LIMIT 1').get(expected.provider) !== undefined)
|
|
123
|
+
return refused('bootstrap cannot overwrite existing native admissions');
|
|
124
|
+
for (const n of inventory.sessions)
|
|
125
|
+
db.prepare('INSERT INTO session VALUES(?,?,?,?,?,?,?,?,?,?)').run(s.provider, n.nativeId, s.owner, s.generation, 1, n.turnId ?? null, s.owner, s.generation, n.turnId ?? null, n.hostId);
|
|
126
|
+
db.prepare('UPDATE provider SET barrierId=?,inventory=? WHERE provider=?').run(barrierId, canonical, s.provider);
|
|
127
|
+
return ok(inspect(db, s));
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
change(request) {
|
|
131
|
+
if (!stamp(request) || !text(request.nextOwner) || !text(request.requestId))
|
|
132
|
+
return refused('a complete expected ownership stamp, next owner and request identity are required');
|
|
133
|
+
return this.access(request.provider, true, false, db => {
|
|
134
|
+
const s = current(db, request.provider);
|
|
135
|
+
if (s === undefined)
|
|
136
|
+
return refused('provider ownership is not initialized');
|
|
137
|
+
if (readiness(db, request.provider).state !== 'ready')
|
|
138
|
+
return refused('native ownership has not been reconciled under its mutation barrier');
|
|
139
|
+
const prior = db.prepare('SELECT * FROM transition WHERE requestId=?').get(request.requestId);
|
|
140
|
+
if (prior !== undefined)
|
|
141
|
+
return prior.provider === request.provider && prior.owner === request.owner && prior.generation === request.generation && prior.nextOwner === request.nextOwner ? ok(inspect(db, s)) : refused('ownership request identity was already used with different input');
|
|
142
|
+
if (!same(s, request))
|
|
143
|
+
return refused('the expected owner or generation is stale');
|
|
144
|
+
if (s.owner === request.nextOwner || s.generation === Number.MAX_SAFE_INTEGER)
|
|
145
|
+
return refused('the next owner must differ and generation must have a successor');
|
|
146
|
+
if (db.prepare("SELECT 1 FROM admission WHERE provider=? AND state IN ('pending','uncertain') LIMIT 1").get(request.provider) !== undefined)
|
|
147
|
+
return refused('unfinished native mutations must be resolved before ownership changes');
|
|
148
|
+
if (db.prepare('SELECT 1 FROM session WHERE provider=? AND active=1 LIMIT 1').get(request.provider) !== undefined)
|
|
149
|
+
return refused('active native sessions retain their owner; drain them before ownership changes');
|
|
150
|
+
db.prepare('INSERT INTO transition VALUES(?,?,?,?,?)').run(request.requestId, request.provider, s.owner, s.generation, request.nextOwner);
|
|
151
|
+
db.prepare('UPDATE provider SET owner=?,generation=? WHERE provider=?').run(request.nextOwner, s.generation + 1, request.provider);
|
|
152
|
+
return ok(inspect(db, { provider: s.provider, owner: request.nextOwner, generation: s.generation + 1 }));
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
admit(request) {
|
|
156
|
+
if (!stamp(request) || !text(request.requestId) || !kinds.includes(request.kind) || !text(request.target) || !text(request.intent) || !text(request.expectedHostId) || (request.expectedTurnId !== undefined && !text(request.expectedTurnId)))
|
|
157
|
+
return refused('a complete ownership stamp, mutation kind, target, exact intent and request identity are required');
|
|
158
|
+
return this.access(request.provider, true, false, db => {
|
|
159
|
+
const previous = admission(db, request);
|
|
160
|
+
if (previous !== undefined)
|
|
161
|
+
return sameRequest(previous, request) ? ok({ execute: false, admission: previous }) : refused('mutation request identity was already used with different input');
|
|
162
|
+
if (readiness(db, request.provider).state !== 'ready')
|
|
163
|
+
return refused('native ownership has not been reconciled under its mutation barrier');
|
|
164
|
+
const s = current(db, request.provider);
|
|
165
|
+
if (s === undefined)
|
|
166
|
+
return refused('provider ownership is not initialized');
|
|
167
|
+
if (!same(s, request))
|
|
168
|
+
return refused('the expected owner or generation is stale');
|
|
169
|
+
const n = native(db, request.provider, request.target);
|
|
170
|
+
if (request.priorOwnership !== undefined && (!stamp(request.priorOwnership) || !text(request.priorOwnership.hostId) || (request.priorOwnership.turnId !== undefined && !text(request.priorOwnership.turnId))))
|
|
171
|
+
return refused('prior native ownership proof is invalid');
|
|
172
|
+
if ((request.kind === 'launch' || request.kind === 'adopt') && n !== undefined) {
|
|
173
|
+
if (request.kind !== 'adopt' || n.active)
|
|
174
|
+
return refused('an existing active native identity cannot be launched or adopted');
|
|
175
|
+
if (request.priorOwnership === undefined || !same(n, request.priorOwnership) || n.hostId !== request.priorOwnership.hostId || n.turnId !== request.priorOwnership.turnId)
|
|
176
|
+
return refused('inactive adoption needs exact prior native owner, generation and turn');
|
|
177
|
+
}
|
|
178
|
+
if (n !== undefined && request.kind !== 'adopt' && n.hostId !== request.expectedHostId)
|
|
179
|
+
return refused('the selected native host instance is stale');
|
|
180
|
+
if (n !== undefined && n.turnId !== request.expectedTurnId)
|
|
181
|
+
return refused('the selected native turn generation is stale');
|
|
182
|
+
if (request.kind !== 'launch' && request.kind !== 'adopt' && (n === undefined || (!n.active && request.kind !== 'wake') || !same(n, request)))
|
|
183
|
+
return refused('the target is not an active native session of this owner and generation');
|
|
184
|
+
if (db.prepare("SELECT 1 FROM admission WHERE provider=? AND target=? AND state IN ('pending','uncertain') LIMIT 1").get(request.provider, request.target) !== undefined)
|
|
185
|
+
return refused('the target already has an unfinished native mutation');
|
|
186
|
+
const capability = this.turnRequirements[request.expectedHostId];
|
|
187
|
+
if (capability === undefined)
|
|
188
|
+
return refused('the native host has not established its turn-generation requirement: no capability reading for ' + request.expectedHostId);
|
|
189
|
+
if (!text(capability.source))
|
|
190
|
+
return refused('the native host turn-generation requirement has no concrete source');
|
|
191
|
+
if (capability.state === 'unknown')
|
|
192
|
+
return refused('native turn-generation requirement is unknown at ' + capability.source + ': ' + (text(capability.reason) ? capability.reason : 'no reason supplied'));
|
|
193
|
+
if (capability.state !== 'required' && capability.state !== 'not-applicable')
|
|
194
|
+
return refused('the native host turn-generation requirement is invalid at ' + capability.source);
|
|
195
|
+
const turnRequirement = (n?.turnId !== undefined || request.expectedTurnId !== undefined) ? 'required' : capability.state;
|
|
196
|
+
const a = { ...request, turnRequirement, turnSource: capability.source, outcome: { state: 'pending' } };
|
|
197
|
+
db.prepare('INSERT INTO admission VALUES(?,?,?,?,?,?)').run(request.requestId, request.provider, request.target, request.kind, 'pending', JSON.stringify(a));
|
|
198
|
+
return ok({ execute: true, admission: a });
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
resolve(request, result) {
|
|
202
|
+
if (!stamp(request) || result === null || typeof result !== 'object' || !['accepted', 'unsent', 'uncertain'].includes(result.state))
|
|
203
|
+
return refused('a native outcome and complete ownership stamp are required');
|
|
204
|
+
if (result.state === 'accepted' ? !text(result.nativeId) || !text(result.hostId) || typeof result.ended !== 'boolean' || (result.turnId !== undefined && !text(result.turnId)) : !text(result.reason))
|
|
205
|
+
return refused('a native identity/end confirmation or uncertainty/unsent reason is required');
|
|
206
|
+
const normalized = result.state === 'accepted' ? { state: result.state, nativeId: result.nativeId, hostId: result.hostId, ended: result.ended, ...(result.turnId === undefined ? {} : { turnId: result.turnId }) } : { state: result.state, reason: result.reason };
|
|
207
|
+
return this.access(request.provider, true, false, db => {
|
|
208
|
+
const a = admission(db, request);
|
|
209
|
+
if (a === undefined || !sameRequest(a, request))
|
|
210
|
+
return refused('no matching native admission exists');
|
|
211
|
+
if ((a.turnRequirement !== 'required' && a.turnRequirement !== 'not-applicable') || !text(a.turnSource))
|
|
212
|
+
return refused('persisted native turn-generation requirement is unknown; no native acceptance is authorized');
|
|
213
|
+
if (a.outcome.state === 'accepted' || a.outcome.state === 'unsent')
|
|
214
|
+
return JSON.stringify(a.outcome) === JSON.stringify(normalized) ? ok(a) : refused('a known native outcome cannot be rewritten');
|
|
215
|
+
const s = current(db, request.provider);
|
|
216
|
+
if (s === undefined || !same(s, request))
|
|
217
|
+
return refused('the admission no longer names the current ownership generation');
|
|
218
|
+
if (result.state === 'accepted') {
|
|
219
|
+
if ((a.turnRequirement === 'required' || request.expectedTurnId !== undefined) && result.turnId === undefined)
|
|
220
|
+
return refused('accepted native turn generation is missing; its admission remains unresolved');
|
|
221
|
+
if (result.hostId !== request.expectedHostId)
|
|
222
|
+
return refused('the native acknowledgement does not match the admitted host instance');
|
|
223
|
+
if ((request.kind === 'close' || request.kind === 'end') && request.expectedTurnId !== undefined && result.turnId !== request.expectedTurnId)
|
|
224
|
+
return refused('the native acknowledgement does not match the admitted turn generation');
|
|
225
|
+
if (request.kind !== 'launch' && result.nativeId !== request.target)
|
|
226
|
+
return refused('the native result changed the admitted target identity');
|
|
227
|
+
if ((request.kind === 'close' || request.kind === 'end') && !result.ended)
|
|
228
|
+
return refused('close/end needs confirmed native termination; its admission remains pending');
|
|
229
|
+
if (result.ended && request.kind !== 'close' && request.kind !== 'end')
|
|
230
|
+
return refused('only confirmed close/end releases native session ownership');
|
|
231
|
+
const n = native(db, request.provider, result.nativeId);
|
|
232
|
+
if (n?.turnId !== undefined && result.turnId === undefined)
|
|
233
|
+
return refused('accepted native turn generation is missing; its admission remains unresolved');
|
|
234
|
+
if (n !== undefined && (request.kind === 'launch' || (request.kind === 'adopt' && n.active)))
|
|
235
|
+
return refused('the native session already has an owner; its active identity cannot be replaced');
|
|
236
|
+
if (n !== undefined && (!same(n, request) && (request.kind !== 'adopt' || n.active || request.priorOwnership === undefined || !same(n, request.priorOwnership) || n.turnId !== request.priorOwnership.turnId)))
|
|
237
|
+
return refused('the native session already has an owner; its active identity cannot be replaced');
|
|
238
|
+
db.prepare('INSERT INTO session VALUES(?,?,?,?,?,?,?,?,?,?) ON CONFLICT(provider,nativeId) DO UPDATE SET hostId=excluded.hostId,owner=excluded.owner,generation=excluded.generation,active=excluded.active,turnId=excluded.turnId').run(request.provider, result.nativeId, request.owner, request.generation, result.ended ? 0 : 1, result.turnId ?? null, n?.origin.owner ?? request.owner, n?.origin.generation ?? request.generation, n?.origin.turnId ?? result.turnId ?? null, result.hostId);
|
|
239
|
+
}
|
|
240
|
+
a.outcome = normalized;
|
|
241
|
+
db.prepare('UPDATE admission SET state=?,body=? WHERE requestId=?').run(result.state, JSON.stringify(a), request.requestId);
|
|
242
|
+
return ok(a);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/** The two owners a provider's starts can have (#4230): the fleet — FleetView's story queue and BullseyeNotif's conversations — or the agent cluster. */
|
|
247
|
+
export const FLEET_OWNER = 'fleet';
|
|
248
|
+
export const CLUSTER_OWNER = 'agentic-bullseye';
|
|
249
|
+
export const AGENT_PROVIDER_IDS = ['claude', 'codex', 'copilot', 'opencode'];
|
|
250
|
+
/**
|
|
251
|
+
* The one ownership authority on this box, read by every door that starts an agent and by the fence at every launch. A test process — one `node --test`
|
|
252
|
+
* runs (NODE_TEST_CONTEXT), or one started with AGENTIC_BULLSEYE_TEST=1 — never reads or moves the box's own: it reads AGENTIC_BULLSEYE_OWNERSHIP_DIR when
|
|
253
|
+
* its case names one, else an empty folder of its own, where every provider is the fleet's.
|
|
254
|
+
*/
|
|
255
|
+
export function ownershipDirectory() {
|
|
256
|
+
const testing = process.env.AGENTIC_BULLSEYE_TEST === '1' || process.env.NODE_TEST_CONTEXT !== undefined;
|
|
257
|
+
if (!testing)
|
|
258
|
+
return path.join(os.homedir(), '.bullseye', 'agent-cluster', 'ownership');
|
|
259
|
+
// NULL-OK: field AGENTIC_BULLSEYE_OWNERSHIP_DIR is OPTIONAL and therefore it is ok to check for NULL
|
|
260
|
+
return process.env.AGENTIC_BULLSEYE_OWNERSHIP_DIR ?? path.join(os.tmpdir(), `bullseye-test-ownership-${process.pid}`);
|
|
261
|
+
}
|
|
262
|
+
/** The authority could not be read, so no door may start that provider's agent on a guess. */
|
|
263
|
+
export class OwnershipUnreadable extends Error {
|
|
264
|
+
}
|
|
265
|
+
// GATE: how many times an authority call that met another writer's transaction is tried again, 25 ms apart, before its busy refusal is answered.
|
|
266
|
+
const BUSY_TRIES = 5;
|
|
267
|
+
/** One authority call, tried again 25 ms apart while another writer holds the authority; any other answer is returned as it came. */
|
|
268
|
+
export function untilFree(attempt) {
|
|
269
|
+
for (let tries = 1;; tries++) {
|
|
270
|
+
const result = attempt();
|
|
271
|
+
if (result.state === 'ok' || result.busy !== true || tries === BUSY_TRIES)
|
|
272
|
+
return result;
|
|
273
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 25);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/** Who may start `provider`'s agents now. An authority with no row for it is a provider no hand-over ever moved, so the fleet holds it. */
|
|
277
|
+
export function startOwnerOf(provider, directory = ownershipDirectory()) {
|
|
278
|
+
const authority = new ProviderOwnership(directory, AGENT_PROVIDER_IDS);
|
|
279
|
+
let read;
|
|
280
|
+
try {
|
|
281
|
+
read = untilFree(() => authority.owner(provider));
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
const failure = error;
|
|
285
|
+
if (typeof failure.errcode !== 'number' && typeof failure.code !== 'string')
|
|
286
|
+
throw error;
|
|
287
|
+
throw new OwnershipUnreadable(`the provider ownership authority at ${directory} could not be read for ${provider}: ${error.message}`);
|
|
288
|
+
}
|
|
289
|
+
if (read.state === 'ok')
|
|
290
|
+
return read.value ?? FLEET_OWNER;
|
|
291
|
+
throw new OwnershipUnreadable(`the provider ownership authority at ${directory} could not be read for ${provider}: ${read.reason}`);
|
|
292
|
+
}
|
|
293
|
+
/** Whether the agent cluster, not the fleet, starts `provider`'s agents now. */
|
|
294
|
+
export const clusterOwns = (provider, directory) => startOwnerOf(provider, directory) === CLUSTER_OWNER;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.392",
|
|
4
4
|
"description": "Reach your AI agents from anywhere — and let them reach you. One resident process on 127.0.0.1:7475 serves the whole tool surface to Claude Code, GitHub Copilot Chat and Codex: desktop, Telegram, Slack, ntfy, Discord, Teams and SMS are configured in one file, and agents notify you when long work finishes or a decision is needed, ask you a question and wait for your answer, and receive and reply to the messages you send them — with Do Not Disturb and idle detection deciding what actually gets through.",
|
|
5
5
|
"main": "dist/daemon.js",
|
|
6
6
|
"type": "module",
|