@fro.bot/space-bus 0.2.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 +21 -18
- package/dist/core.d.ts +7 -0
- package/dist/index.js +29 -1
- package/dist/mcp.js +37 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,37 +6,31 @@
|
|
|
6
6
|
|
|
7
7
|
> Control project agents across workspaces
|
|
8
8
|
|
|
9
|
-
[](https://www.npmjs.com/package/@fro.bot/space-bus) [](https://github.com/fro-bot/space-bus/actions) [](LICENSE)
|
|
10
10
|
|
|
11
|
-
[
|
|
11
|
+
[What it is](#what-it-is) · [Install](#install) · [Configure](#configure) · [Tools](#tools) · [Claude Desktop](#claude-desktop) · [Development](#development)
|
|
12
12
|
|
|
13
13
|
</div>
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## What it is
|
|
18
18
|
|
|
19
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.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
**Prerequisites**: an `opencode serve` or `harness serve` instance already running; Bun if you're using the Claude Desktop MCP bin (`bunx`).
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
"plugin": ["@fro.bot/space-bus"]
|
|
26
|
-
}
|
|
27
|
-
```
|
|
23
|
+
## Install
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
Add the plugin to `opencode.json`:
|
|
30
26
|
|
|
31
27
|
```json
|
|
32
28
|
{
|
|
33
|
-
"plugin": ["/
|
|
29
|
+
"plugin": ["@fro.bot/space-bus"]
|
|
34
30
|
}
|
|
35
31
|
```
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
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:
|
|
40
34
|
|
|
41
35
|
```json
|
|
42
36
|
{
|
|
@@ -53,9 +47,18 @@ Space Bus reads a `spacebus.json` roster from the workspace directory (the direc
|
|
|
53
47
|
}
|
|
54
48
|
```
|
|
55
49
|
|
|
56
|
-
|
|
50
|
+
## Configure
|
|
51
|
+
|
|
52
|
+
Space Bus reads a `spacebus.json` roster from the workspace directory (the directory OpenCode was launched in).
|
|
53
|
+
|
|
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.
|
|
57
60
|
|
|
58
|
-
Set `SPACE_BUS_CONFIG` to an absolute
|
|
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.
|
|
59
62
|
|
|
60
63
|
## Tools
|
|
61
64
|
|
|
@@ -96,9 +99,9 @@ bun run lint
|
|
|
96
99
|
bun run dev # watch build to dist/
|
|
97
100
|
```
|
|
98
101
|
|
|
99
|
-
`@opencode-ai/*` versions are pinned lockstep with the OpenCode CLI
|
|
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.
|
|
100
103
|
|
|
101
|
-
##
|
|
104
|
+
## Implementation notes
|
|
102
105
|
|
|
103
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.
|
|
104
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*.
|
package/dist/core.d.ts
CHANGED
|
@@ -43,6 +43,13 @@ export type DispatchArgs = {
|
|
|
43
43
|
sessionId: string;
|
|
44
44
|
project?: string;
|
|
45
45
|
});
|
|
46
|
+
export declare function toDispatchArgs(input: {
|
|
47
|
+
prompt: string;
|
|
48
|
+
title?: string;
|
|
49
|
+
project?: string;
|
|
50
|
+
sessionId?: string;
|
|
51
|
+
directory?: string;
|
|
52
|
+
}): Result<DispatchArgs>;
|
|
46
53
|
export declare function dispatch(args: DispatchArgs): Promise<Result<DispatchResult>>;
|
|
47
54
|
export type SessionStatusResult = {
|
|
48
55
|
sessionId: string;
|
package/dist/index.js
CHANGED
|
@@ -328,6 +328,31 @@ 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)
|
|
@@ -647,10 +672,13 @@ function makeBusTask(defaultDirectory) {
|
|
|
647
672
|
sessionId: tool4.schema.string().optional().describe("Existing session ID to steer instead of starting a new session")
|
|
648
673
|
},
|
|
649
674
|
async execute(args, ctx) {
|
|
650
|
-
const
|
|
675
|
+
const dispatchArgs = toDispatchArgs({
|
|
651
676
|
...args,
|
|
652
677
|
directory: ctx.directory ?? defaultDirectory
|
|
653
678
|
});
|
|
679
|
+
if (!dispatchArgs.ok)
|
|
680
|
+
throw new Error(dispatchArgs.error);
|
|
681
|
+
const r = await dispatch(dispatchArgs);
|
|
654
682
|
if (!r.ok)
|
|
655
683
|
throw new Error(r.error);
|
|
656
684
|
return formatDispatch(r);
|
package/dist/mcp.js
CHANGED
|
@@ -331,6 +331,31 @@ 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)
|
|
@@ -651,10 +676,13 @@ function makeBusTask(defaultDirectory) {
|
|
|
651
676
|
sessionId: tool4.schema.string().optional().describe("Existing session ID to steer instead of starting a new session")
|
|
652
677
|
},
|
|
653
678
|
async execute(args, ctx) {
|
|
654
|
-
const
|
|
679
|
+
const dispatchArgs = toDispatchArgs({
|
|
655
680
|
...args,
|
|
656
681
|
directory: ctx.directory ?? defaultDirectory
|
|
657
682
|
});
|
|
683
|
+
if (!dispatchArgs.ok)
|
|
684
|
+
throw new Error(dispatchArgs.error);
|
|
685
|
+
const r = await dispatch(dispatchArgs);
|
|
658
686
|
if (!r.ok)
|
|
659
687
|
throw new Error(r.error);
|
|
660
688
|
return formatDispatch(r);
|
|
@@ -663,7 +691,7 @@ function makeBusTask(defaultDirectory) {
|
|
|
663
691
|
}
|
|
664
692
|
|
|
665
693
|
// src/mcp.ts
|
|
666
|
-
var version = "0.2.
|
|
694
|
+
var version = "0.2.1";
|
|
667
695
|
var server = new McpServer({
|
|
668
696
|
name: "space-bus",
|
|
669
697
|
version
|
|
@@ -686,7 +714,13 @@ server.registerTool("bus_task", {
|
|
|
686
714
|
sessionId: z3.string().optional().describe("Existing session ID to steer instead of starting a new session")
|
|
687
715
|
}
|
|
688
716
|
}, async (args) => {
|
|
689
|
-
const
|
|
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);
|
|
690
724
|
if (!r.ok)
|
|
691
725
|
return { content: [{ type: "text", text: r.error }], isError: true };
|
|
692
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.2.
|
|
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",
|