@fro.bot/space-bus 0.11.0 → 0.13.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/README.md CHANGED
@@ -67,6 +67,12 @@ Set `SPACE_BUS_CONFIG` to override roster discovery — it must be an absolute p
67
67
  - `bus_status` — Report a space-bus session's status plus a summary of its latest todo and diff. Also reports when the session is blocked on an interactive question awaiting a reply.
68
68
  - `bus_result` — Return a completed space-bus session's final assistant message and diff. Errors if the session is still running — use `bus_status` to check first.
69
69
  - `bus_wait` — Block until any of the given sessions needs attention (completes, blocks on a question, fails, or is not found) or a bounded timeout elapses. Returns each watched session's normalized state and which session(s) woke the wait; on timeout returns the current snapshot, not an error.
70
+ - `bus_registry` — Manage the roster registry: list registered rosters, create/register/unregister rosters, set the default, select an active roster for this connector session (`use`, MCP only), and add/remove/update projects on a registered roster. `set-default` also becomes the MCP ambient-resolution fallback (see below) once `SPACE_BUS_CONFIG` is unset.
71
+
72
+ All five `bus_*` tools accept an optional `roster` param (a registry name — see `bus_registry`) to target a roster other than the ambient one, and every tool result opens with a `roster: <name-or-path>` line naming the roster it resolved against, on both surfaces. Resolution precedence:
73
+
74
+ - **Plugin surface:** explicit `roster` param > workspace directory (`ctx.directory`).
75
+ - **MCP surface:** explicit `roster` param > connector-session active roster (`bus_registry use`) > `SPACE_BUS_CONFIG` (ambient) > registry default (`bus_registry set-default`), consulted only when `SPACE_BUS_CONFIG` is unset > an actionable error listing the available rosters.
70
76
 
71
77
  ## Managed server
72
78
 
@@ -133,7 +139,7 @@ Semantics:
133
139
  Experimental subpath exports expose the bus's internals directly — the functions the four tools run on, plus the managed-server lifecycle and the attach resolver — for renderers and other consumers that want structured state instead of formatted strings. Subpaths are experimental: shapes may change in minor releases; pin the version if you adopt them.
134
140
 
135
141
  - `@fro.bot/space-bus/core` — browser-safe; no Node builtins, no ambient env reads. Every exported function takes a `context: BusContext` (`{ roster, credentials? }`) that you build yourself and pass in — core never resolves it for you. Includes `snapshot()`, a one-call composite of roster + per-project status + pending questions with bounded fan-out.
136
- - `@fro.bot/space-bus/config` — Node-only. `loadContext(directory?)` reads `spacebus.json` (honoring `SPACE_BUS_CONFIG` the same as the plugin) and returns a ready-to-use `BusContext`, with per-project `exists` flags and env-derived credentials attached. Build a fresh context per call; it's per-call/short-lived by contract, not meant to be cached across filesystem changes.
142
+ - `@fro.bot/space-bus/config` — Node-only. `loadContext(directory?)` reads `spacebus.json` (honoring `SPACE_BUS_CONFIG` the same as the plugin) and returns a ready-to-use `BusContext`, with per-project `exists` flags and env-derived credentials attached. Build a fresh context per call; it's per-call/short-lived by contract, not meant to be cached across filesystem changes. `loadContextForRoster(name)` resolves a registered roster name instead (via `registry.resolveRosterByName`) through the same read/attach/credentials pipeline, returning the canonical registered name alongside the context and path. `loadContextForRosterPath(path)` — experimental, like its siblings — loads a `BusContext` from an *already-resolved* roster path, skipping name resolution entirely; callers that resolve a name once (to decide whether to `ensureServer()`) use this to avoid a second, TOCTOU-prone re-resolution of the same name.
137
143
  - `@fro.bot/space-bus/contract` — the zod schemas (and inferred types) behind the OpenCode API and `BusContext`, for consumers hitting the server directly and wanting the same shapes. Schemas are zod v4.
138
144
  - `@fro.bot/space-bus/format` — the pure formatters the tools use to render output, for tool-identical text.
139
145
  - `@fro.bot/space-bus/managed-server` — Node-only. The managed-server lifecycle (`ensureServer`/`serverStatus`/`stopServer`) for consumers driving spawn/attach/stop directly — see [Managed server](#managed-server).
package/dist/attach.js CHANGED
@@ -118,13 +118,44 @@ var managedSpawnConfigSchema = z.object({
118
118
  cwd: z.string().optional(),
119
119
  port: z.number().int().nonnegative().optional()
120
120
  });
121
+ var registryEntrySchema = z.object({
122
+ name: z.string().regex(/^[a-z0-9-]{1,64}$/, "roster name must be 1-64 lowercase letters, digits, or hyphens"),
123
+ path: z.string().min(1, "roster path must not be empty")
124
+ });
125
+ var registryFileSchema = z.object({
126
+ version: z.literal(1),
127
+ default: z.string().optional(),
128
+ rosters: z.array(registryEntrySchema)
129
+ }).superRefine((val, ctx) => {
130
+ const seen = new Set;
131
+ for (const entry of val.rosters) {
132
+ const key = entry.name.toLowerCase();
133
+ if (seen.has(key)) {
134
+ ctx.addIssue({
135
+ code: "custom",
136
+ message: `space-bus: duplicate roster name "${entry.name}" (case-insensitive) in registry`
137
+ });
138
+ }
139
+ seen.add(key);
140
+ }
141
+ if (val.default !== undefined) {
142
+ const matches = val.rosters.filter((entry) => entry.name === val.default);
143
+ if (matches.length !== 1) {
144
+ ctx.addIssue({
145
+ code: "custom",
146
+ message: `space-bus: registry's default "${val.default}" must match exactly one roster entry's name (matched ${matches.length})`
147
+ });
148
+ }
149
+ }
150
+ });
121
151
  var discoveryFileSchema = z.object({
122
152
  port: z.number().int().nonnegative(),
123
153
  pid: z.number().int().min(2),
124
154
  identity: z.string(),
125
155
  password: z.string(),
126
156
  spawnConfig: managedSpawnConfigSchema,
127
- baseUrl: z.url()
157
+ baseUrl: z.url(),
158
+ rosterPath: z.string().optional()
128
159
  });
129
160
 
130
161
  // src/attach.ts