@fro.bot/space-bus 0.10.0 → 0.11.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.
package/dist/server.js CHANGED
@@ -1,6 +1,12 @@
1
1
  import { createRequire } from "node:module";
2
2
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
3
 
4
+ // src/config.ts
5
+ import { existsSync, readFileSync as readFileSync2, realpathSync } from "node:fs";
6
+ import { homedir as homedir2 } from "node:os";
7
+ import { join as join2 } from "node:path";
8
+ import { z as z3 } from "zod";
9
+
4
10
  // src/contract.ts
5
11
  import { z } from "zod";
6
12
  var sessionSchema = z.looseObject({
@@ -130,12 +136,6 @@ var discoveryFileSchema = z.object({
130
136
  baseUrl: z.url()
131
137
  });
132
138
 
133
- // src/config.ts
134
- import { existsSync, readFileSync as readFileSync2, realpathSync } from "node:fs";
135
- import { homedir as homedir2 } from "node:os";
136
- import { join as join2 } from "node:path";
137
- import { z as z3 } from "zod";
138
-
139
139
  // src/discovery.ts
140
140
  import { execFileSync } from "node:child_process";
141
141
  import { createHash, randomBytes } from "node:crypto";
@@ -154,10 +154,12 @@ import {
154
154
  import { homedir } from "node:os";
155
155
  import { join } from "node:path";
156
156
  import { z as z2 } from "zod";
157
+ function rosterKey(rosterPath) {
158
+ return createHash("sha256").update(rosterPath).digest("hex").slice(0, 16);
159
+ }
157
160
  function stateDirFor(rosterPath) {
158
161
  const base = process.env["XDG_STATE_HOME"] ?? join(homedir(), ".local", "state");
159
- const hash = createHash("sha256").update(rosterPath).digest("hex").slice(0, 16);
160
- return join(base, "space-bus", hash);
162
+ return join(base, "space-bus", rosterKey(rosterPath));
161
163
  }
162
164
  function discoveryFilePath(rosterPath) {
163
165
  return join(stateDirFor(rosterPath), "discovery.json");
@@ -0,0 +1,105 @@
1
+ import { type ExecSeam } from "./launchd";
2
+ import { serverStatus as defaultServerStatus } from "./server";
3
+ declare const NOT_SUPPORTED_ERROR = "space-bus service is not supported on this platform (v1 supports macOS/launchd)";
4
+ /** Injectable seams for the service verbs — mirrors `RunServeDeps`'s
5
+ * pattern in cli.ts. All fields are optional and default to the real
6
+ * implementations. */
7
+ export interface ServiceDeps {
8
+ exec?: ExecSeam;
9
+ platform?: NodeJS.Platform;
10
+ uid?: number;
11
+ execPath?: string;
12
+ /** Absolute path of the CLI entry module. Defaults to `process.argv[1]`
13
+ * resolved to absolute — Unit 3 is responsible for wiring a durable
14
+ * resolution (e.g. `fileURLToPath(import.meta.url)`) when invoking these
15
+ * verbs from the running CLI. */
16
+ cliEntryPath?: string;
17
+ serverStatus?: typeof defaultServerStatus;
18
+ /** Injectable sleep, for deterministic tests. */
19
+ sleep?: (ms: number) => Promise<void>;
20
+ /** Injectable clock, for deterministic tests. */
21
+ now?: () => number;
22
+ /** Bounds the install verification poll loop. Default 10s. */
23
+ verifyBudgetMs?: number;
24
+ /** Poll interval for the install verification loop. Default 200ms. */
25
+ verifyPollMs?: number;
26
+ /**
27
+ * Base directory for the launchd agent plist. Defaults to
28
+ * `~/Library/LaunchAgents`. Tests MUST inject a mkdtemp dir here — never
29
+ * exercise the default against the real filesystem.
30
+ */
31
+ launchAgentsDir?: string;
32
+ }
33
+ export type PlatformGate = {
34
+ ok: true;
35
+ } | {
36
+ ok: false;
37
+ error: string;
38
+ };
39
+ interface ServiceIdentity {
40
+ label: string;
41
+ plistFilePath: string;
42
+ stateDir: string;
43
+ }
44
+ declare function identityFor(rosterPath: string, launchAgentsDir: string): ServiceIdentity;
45
+ export type PreCreateLogResult = {
46
+ ok: true;
47
+ } | {
48
+ ok: false;
49
+ error: string;
50
+ };
51
+ export type InstallResult = {
52
+ ok: true;
53
+ label: string;
54
+ plistPath: string;
55
+ pid?: number;
56
+ warning?: string;
57
+ } | {
58
+ ok: false;
59
+ error: string;
60
+ };
61
+ export declare function installService(rosterPath: string, deps?: ServiceDeps): Promise<InstallResult>;
62
+ export type UninstallResult = {
63
+ ok: true;
64
+ removed: {
65
+ job: boolean;
66
+ plist: boolean;
67
+ };
68
+ label: string;
69
+ } | {
70
+ ok: false;
71
+ error: string;
72
+ };
73
+ export declare function uninstallService(rosterPath: string, deps?: ServiceDeps): Promise<UninstallResult>;
74
+ export type StatusResult = {
75
+ ok: true;
76
+ installed: boolean;
77
+ loaded: boolean;
78
+ running: boolean;
79
+ pid?: number;
80
+ label: string;
81
+ plistPath: string;
82
+ } | {
83
+ ok: false;
84
+ error: string;
85
+ };
86
+ export declare function serviceStatus(rosterPath: string, deps?: ServiceDeps): Promise<StatusResult>;
87
+ export type StopResult = {
88
+ ok: true;
89
+ label: string;
90
+ wasLoaded: boolean;
91
+ } | {
92
+ ok: false;
93
+ error: string;
94
+ };
95
+ export declare function stopService(rosterPath: string, deps?: ServiceDeps): Promise<StopResult>;
96
+ export type StartResult = {
97
+ ok: true;
98
+ label: string;
99
+ pid?: number;
100
+ } | {
101
+ ok: false;
102
+ error: string;
103
+ };
104
+ export declare function startService(rosterPath: string, deps?: ServiceDeps): Promise<StartResult>;
105
+ export { identityFor as serviceIdentity, NOT_SUPPORTED_ERROR as SERVICE_NOT_SUPPORTED_ERROR, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fro.bot/space-bus",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Space Bus — workspace agent bus for OpenCode. One control agent tasking per-project agents over the OpenCode server API, with an MCP facade for Claude Desktop.",
5
5
  "type": "module",
6
6
  "license": "MIT",