@fro.bot/space-bus 0.1.0 → 0.2.1

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/README.md CHANGED
@@ -1,26 +1,36 @@
1
+ <div align="center">
2
+
3
+ <img src="./assets/banner.svg" alt="space-bus Banner" width="100%" />
4
+
1
5
  # @fro.bot/space-bus
2
6
 
7
+ > Control project agents across workspaces
8
+
9
+ [![npm version](https://img.shields.io/npm/v/@fro.bot/space-bus?style=for-the-badge&labelColor=0D0216&color=00BCD4)](https://www.npmjs.com/package/@fro.bot/space-bus) [![Build Status](https://img.shields.io/github/actions/workflow/status/fro-bot/space-bus/ci.yaml?style=for-the-badge&label=Build&labelColor=0D0216&color=00BCD4)](https://github.com/fro-bot/space-bus/actions) [![License](https://img.shields.io/badge/License-MIT-FFC107?style=for-the-badge&labelColor=0D0216&color=FFC107)](LICENSE)
10
+
11
+ [What it is](#what-it-is) · [Install](#install) · [Configure](#configure) · [Tools](#tools) · [Claude Desktop](#claude-desktop) · [Development](#development)
12
+
13
+ </div>
14
+
15
+ ---
16
+
17
+ ## What it is
18
+
3
19
  Workspace agent bus for OpenCode. A control agent — an ordinary OpenCode TUI running with this plugin installed — tasks dedicated agents in each project on your roster over a single `opencode serve`/`harness serve` instance, using per-request directory routing. A thin stdio MCP facade exposes the same tools to Claude Desktop.
4
20
 
5
- ## Install
21
+ **Prerequisites**: an `opencode serve` or `harness serve` instance already running; Bun if you're using the Claude Desktop MCP bin (`bunx`).
6
22
 
7
- ```json
8
- {
9
- "plugin": ["@fro.bot/space-bus"]
10
- }
11
- ```
23
+ ## Install
12
24
 
13
- For local development, reference the checkout by file path instead:
25
+ Add the plugin to `opencode.json`:
14
26
 
15
27
  ```json
16
28
  {
17
- "plugin": ["/absolute/path/to/space-bus"]
29
+ "plugin": ["@fro.bot/space-bus"]
18
30
  }
19
31
  ```
20
32
 
21
- ## Configure
22
-
23
- Space Bus reads a `spacebus.json` roster from the workspace directory (the directory OpenCode was launched in):
33
+ Then add a `spacebus.json` roster in the same directory:
24
34
 
25
35
  ```json
26
36
  {
@@ -29,17 +39,26 @@ Space Bus reads a `spacebus.json` roster from the workspace directory (the direc
29
39
  },
30
40
  "projects": [
31
41
  {
32
- "name": "agent",
33
- "path": "~/src/github.com/fro-bot/agent",
34
- "description": "Fro Bot agent runtime + gateway + Discord integration"
42
+ "name": "my-project",
43
+ "path": "~/src/my-project",
44
+ "description": "My project's agent runtime and API"
35
45
  }
36
46
  ]
37
47
  }
38
48
  ```
39
49
 
40
- `server.baseUrl` must point to localhost (`127.0.0.1`, `::1`, or `localhost`) — non-local hosts are refused so bus credentials never leave the machine. Project `path` entries support `~` expansion.
50
+ ## Configure
51
+
52
+ Space Bus reads a `spacebus.json` roster from the workspace directory (the directory OpenCode was launched in).
41
53
 
42
- Set `SPACE_BUS_CONFIG` to an absolute or `~`-prefixed path to override roster discovery (URLs and bare-relative paths are rejected). The roster is read fresh on every tool call — no caching, so edits apply immediately.
54
+ Fields:
55
+
56
+ - `server.baseUrl` — must resolve to localhost (`127.0.0.1`, `::1`, or `localhost`); non-local hosts are refused so bus credentials never leave the machine.
57
+ - `projects[].name` — identifier passed to `bus_task`'s `project` argument.
58
+ - `projects[].path` — filesystem path to the project; supports `~` expansion.
59
+ - `projects[].description` — shown in `bus_roster` output.
60
+
61
+ Set `SPACE_BUS_CONFIG` to override roster discovery — it must be an absolute path or start with `~` (URLs and bare-relative paths are rejected). The roster is read fresh on every tool call — no caching, so edits apply immediately.
43
62
 
44
63
  ## Tools
45
64
 
@@ -80,9 +99,9 @@ bun run lint
80
99
  bun run dev # watch build to dist/
81
100
  ```
82
101
 
83
- `@opencode-ai/*` versions are pinned lockstep with the OpenCode CLI (1.17.13). Upgrade both together. Set `OPENCODE_SERVER_PASSWORD` (and optionally `OPENCODE_SERVER_USERNAME`) to enable HTTP Basic auth on every bus request.
102
+ `@opencode-ai/*` versions are pinned lockstep with the OpenCode CLI. Upgrade both together. Set `OPENCODE_SERVER_PASSWORD` (and optionally `OPENCODE_SERVER_USERNAME`) to enable HTTP Basic auth on every bus request.
84
103
 
85
- ## Notes from implementation
104
+ ## Implementation notes
86
105
 
87
106
  - The session store is global across directory headers: `GET /session/{id}` resolves regardless of which project directory is sent. The bus attributes a session to its owning project via the session's own `directory` field, not the probe header. `GET /session` (list) and `/session/status` are directory-scoped.
88
107
  - Upstream opencode #30127 (v1.16.0) zeroes session-level diff summaries, so `GET /session/{id}/diff` always returns `[]`. Per-turn diffs on user messages (`GET /session/{id}/message`) stay intact and include untracked files, so `bus_status`/`bus_result` aggregate those instead (last turn wins per file, à la upstream PR #33444). Harness builds ≥`1.17.13+harness.ee55e157` carry #33444 directly, so `GET /session/{id}`'s `summary.diffs` field is populated and serves diffs without per-turn aggregation (still labeled `diffSource: "session"`); stock binaries leave it empty and fall through to per-turn aggregation. `GET /vcs/status` remains a last-ditch repo-wide fallback, labeled *working tree*.
@@ -92,3 +111,11 @@ bun run dev # watch build to dist/
92
111
  ## Releasing
93
112
 
94
113
  PRs land a changeset via `bunx changeset`. On merge to `main`, CI opens a version PR; merging that PR publishes to npm through trusted publishing (OIDC) — no `NPM_TOKEN` involved.
114
+
115
+ ---
116
+
117
+ <div align="center">
118
+
119
+ <sub>Part of the <a href="https://github.com/fro-bot">Fro Bot</a> ecosystem</sub>
120
+
121
+ </div>
package/dist/core.d.ts CHANGED
@@ -32,13 +32,25 @@ export type DispatchResult = {
32
32
  } | {
33
33
  mode: "question-reply" | "follow-up";
34
34
  });
35
- export declare function dispatch(args: {
35
+ export type DispatchArgs = {
36
+ prompt: string;
37
+ title?: string;
38
+ directory?: string;
39
+ } & ({
40
+ project: string;
41
+ sessionId?: undefined;
42
+ } | {
43
+ sessionId: string;
36
44
  project?: string;
45
+ });
46
+ export declare function toDispatchArgs(input: {
37
47
  prompt: string;
38
48
  title?: string;
49
+ project?: string;
39
50
  sessionId?: string;
40
51
  directory?: string;
41
- }): Promise<Result<DispatchResult>>;
52
+ }): Result<DispatchArgs>;
53
+ export declare function dispatch(args: DispatchArgs): Promise<Result<DispatchResult>>;
42
54
  export type SessionStatusResult = {
43
55
  sessionId: string;
44
56
  project: string;
package/dist/index.js CHANGED
@@ -328,11 +328,39 @@ async function dispatchNew(baseUrl, projects, project, prompt, title) {
328
328
  }
329
329
  return { ok: true, sessionId: session.id, project, directory };
330
330
  }
331
+ function toDispatchArgs(input) {
332
+ if (input.sessionId !== undefined && input.sessionId === "") {
333
+ return err("space-bus: sessionId must be a non-empty string");
334
+ }
335
+ if (!input.sessionId) {
336
+ if (!input.project) {
337
+ return err("space-bus: project is required when starting a new session");
338
+ }
339
+ return {
340
+ ok: true,
341
+ prompt: input.prompt,
342
+ title: input.title,
343
+ directory: input.directory,
344
+ project: input.project
345
+ };
346
+ }
347
+ return {
348
+ ok: true,
349
+ prompt: input.prompt,
350
+ title: input.title,
351
+ directory: input.directory,
352
+ sessionId: input.sessionId,
353
+ project: input.project
354
+ };
355
+ }
331
356
  async function dispatch(args) {
332
357
  const ctx = resolveContext(args.directory);
333
358
  if (!ctx.ok)
334
359
  return ctx;
335
360
  const { baseUrl, projects } = ctx;
361
+ if (args.sessionId !== undefined && args.sessionId === "") {
362
+ return err("space-bus: sessionId must be a non-empty string");
363
+ }
336
364
  if (!args.sessionId) {
337
365
  if (!args.project) {
338
366
  return err("space-bus: project is required when starting a new session");
@@ -644,10 +672,13 @@ function makeBusTask(defaultDirectory) {
644
672
  sessionId: tool4.schema.string().optional().describe("Existing session ID to steer instead of starting a new session")
645
673
  },
646
674
  async execute(args, ctx) {
647
- const r = await dispatch({
675
+ const dispatchArgs = toDispatchArgs({
648
676
  ...args,
649
677
  directory: ctx.directory ?? defaultDirectory
650
678
  });
679
+ if (!dispatchArgs.ok)
680
+ throw new Error(dispatchArgs.error);
681
+ const r = await dispatch(dispatchArgs);
651
682
  if (!r.ok)
652
683
  throw new Error(r.error);
653
684
  return formatDispatch(r);
package/dist/mcp.js CHANGED
@@ -331,11 +331,39 @@ async function dispatchNew(baseUrl, projects, project, prompt, title) {
331
331
  }
332
332
  return { ok: true, sessionId: session.id, project, directory };
333
333
  }
334
+ function toDispatchArgs(input) {
335
+ if (input.sessionId !== undefined && input.sessionId === "") {
336
+ return err("space-bus: sessionId must be a non-empty string");
337
+ }
338
+ if (!input.sessionId) {
339
+ if (!input.project) {
340
+ return err("space-bus: project is required when starting a new session");
341
+ }
342
+ return {
343
+ ok: true,
344
+ prompt: input.prompt,
345
+ title: input.title,
346
+ directory: input.directory,
347
+ project: input.project
348
+ };
349
+ }
350
+ return {
351
+ ok: true,
352
+ prompt: input.prompt,
353
+ title: input.title,
354
+ directory: input.directory,
355
+ sessionId: input.sessionId,
356
+ project: input.project
357
+ };
358
+ }
334
359
  async function dispatch(args) {
335
360
  const ctx = resolveContext(args.directory);
336
361
  if (!ctx.ok)
337
362
  return ctx;
338
363
  const { baseUrl, projects } = ctx;
364
+ if (args.sessionId !== undefined && args.sessionId === "") {
365
+ return err("space-bus: sessionId must be a non-empty string");
366
+ }
339
367
  if (!args.sessionId) {
340
368
  if (!args.project) {
341
369
  return err("space-bus: project is required when starting a new session");
@@ -648,10 +676,13 @@ function makeBusTask(defaultDirectory) {
648
676
  sessionId: tool4.schema.string().optional().describe("Existing session ID to steer instead of starting a new session")
649
677
  },
650
678
  async execute(args, ctx) {
651
- const r = await dispatch({
679
+ const dispatchArgs = toDispatchArgs({
652
680
  ...args,
653
681
  directory: ctx.directory ?? defaultDirectory
654
682
  });
683
+ if (!dispatchArgs.ok)
684
+ throw new Error(dispatchArgs.error);
685
+ const r = await dispatch(dispatchArgs);
655
686
  if (!r.ok)
656
687
  throw new Error(r.error);
657
688
  return formatDispatch(r);
@@ -660,9 +691,10 @@ function makeBusTask(defaultDirectory) {
660
691
  }
661
692
 
662
693
  // src/mcp.ts
694
+ var version = "0.2.1";
663
695
  var server = new McpServer({
664
696
  name: "space-bus",
665
- version: "0.0.0"
697
+ version
666
698
  });
667
699
  server.registerTool("bus_roster", {
668
700
  description: BUS_ROSTER_DESCRIPTION,
@@ -682,7 +714,13 @@ server.registerTool("bus_task", {
682
714
  sessionId: z3.string().optional().describe("Existing session ID to steer instead of starting a new session")
683
715
  }
684
716
  }, async (args) => {
685
- const r = await dispatch({ ...args });
717
+ const dispatchArgs = toDispatchArgs(args);
718
+ if (!dispatchArgs.ok)
719
+ return {
720
+ content: [{ type: "text", text: dispatchArgs.error }],
721
+ isError: true
722
+ };
723
+ const r = await dispatch(dispatchArgs);
686
724
  if (!r.ok)
687
725
  return { content: [{ type: "text", text: r.error }], isError: true };
688
726
  return { content: [{ type: "text", text: formatDispatch(r) }] };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fro.bot/space-bus",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
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",