@brutalsystems/muster 0.11.0 → 1.0.0

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.
@@ -0,0 +1,32 @@
1
+ import { OpenCodeHttp } from "../opencode-http.js";
2
+ import { openCodeEndpointOwnedBy } from "../identity/opencode.js";
3
+ import { isSame } from "../identity/processes.js";
4
+ /**
5
+ * Ask an OpenCode session to abort before anything is signalled.
6
+ *
7
+ * OpenCode is a server with work possibly in flight, so it gets told to stop
8
+ * rather than only being killed — Claude and Codex have nothing equivalent to
9
+ * say. Best effort by design: a failure here is not a reason to leave processes
10
+ * running, and the kill that follows is what actually guarantees the stop.
11
+ *
12
+ * Every precondition is a reason not to shout at a stranger. The endpoint must
13
+ * still be owned by the process Muster started, because a loopback port is a
14
+ * shared resource and a pid can be reused — without that check an abort could
15
+ * be sent to whatever now happens to be listening on that port.
16
+ *
17
+ * Lives outside `opencode-policy.ts` deliberately: that module imports
18
+ * `guard.ts`, which imports the agent table, so referencing it from a row would
19
+ * close a cycle and leave the slot undefined depending on evaluation order.
20
+ */
21
+ export async function abortOpenCodeSession(entry, deadline) {
22
+ const sessionId = entry.peer?.session_id;
23
+ if (!entry.root ||
24
+ !entry.server_url ||
25
+ typeof sessionId !== "string" ||
26
+ !(await isSame(entry.root)) ||
27
+ !(await openCodeEndpointOwnedBy(entry.root.pid, entry.server_url, deadline)))
28
+ return;
29
+ await new OpenCodeHttp(entry.server_url)
30
+ .abort(sessionId, deadline)
31
+ .catch(() => { });
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brutalsystems/muster",
3
- "version": "0.11.0",
3
+ "version": "1.0.0",
4
4
  "description": "Launch instructed, reachable local agent sessions",
5
5
  "type": "module",
6
6
  "engines": {