@fro.bot/space-bus 0.15.0 → 0.15.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 +5 -2
- package/dist/attach.js +2 -2
- package/dist/cli.js +9 -9
- package/dist/config.js +14 -17
- package/dist/contract.js +30 -30
- package/dist/core.js +11 -11
- package/dist/format.js +6 -6
- package/dist/index.js +1052 -1055
- package/dist/mcp.js +1164 -1164
- package/dist/registry-entry.js +189 -190
- package/dist/server.js +18 -19
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ Set `SPACE_BUS_CONFIG` to override roster discovery — it must be an absolute p
|
|
|
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
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
71
|
|
|
72
|
-
All
|
|
72
|
+
All `bus_*` tools except `bus_registry` 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
73
|
|
|
74
74
|
- **Plugin surface:** explicit `roster` param > workspace directory (`ctx.directory`).
|
|
75
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.
|
|
@@ -136,7 +136,7 @@ Semantics:
|
|
|
136
136
|
|
|
137
137
|
## Library surface
|
|
138
138
|
|
|
139
|
-
Experimental subpath exports expose the bus's internals directly — the functions the
|
|
139
|
+
Experimental subpath exports expose the bus's internals directly — the functions the `bus_*` 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.
|
|
140
140
|
|
|
141
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. Session-content primitives:
|
|
142
142
|
- `messages(sessionId, { context, limit? })` — bounded full-message read. Resolves session ownership from the roster (never a caller-supplied directory), fetches `GET /session/:id/message?limit=N` (default 20, hard maximum 200 — `limit` must be a finite positive integer at or under the maximum; `0`, negative, fractional, `NaN`, `Infinity`, and over-maximum values are rejected before any fetch). Returns `{ sessionId, project, messages: [{ id?, role, createdAt?, parts: [{ type, text? }] }] }` in the order the server returns them — `id`/`createdAt` are the message's stable identity/ordering metadata (from the envelope's `info.id`/`info.time.created`), and only those explicit fields plus parsed `parts` cross the boundary; unknown envelope fields are dropped. No directory/credential fields in the result.
|
|
@@ -148,6 +148,9 @@ Experimental subpath exports expose the bus's internals directly — the functio
|
|
|
148
148
|
- `@fro.bot/space-bus/format` — the pure formatters the tools use to render output, for tool-identical text.
|
|
149
149
|
- `@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).
|
|
150
150
|
- `@fro.bot/space-bus/attach` — browser-safe. `resolveManagedServer(workspaceDir, seams)` resolves a managed roster's running endpoint by reading the discovery file through injected filesystem/env/crypto seams — re-checking the localhost guard and probing liveness — so an external attacher such as a Tauri webview can attach without any `node:*` imports or reimplementing the discovery contract. Returns `{ baseUrl, credentials, alive }` or an actionable error.
|
|
151
|
+
- `@fro.bot/space-bus/registry` — Node-only, experimental. The roster registry and roster-edit substrate behind `bus_registry` (`readRegistry`/`registerRoster`/`unregisterRoster`/`setDefaultRoster`/`resolveRosterByName`, plus roster creation and project add/remove/update), for consumers that want to manage rosters programmatically without the tool or MCP surfaces.
|
|
152
|
+
|
|
153
|
+
`@fro.bot/space-bus/server` is not a library entry: OpenCode's plugin loader reserves that subpath for the plugin itself, so it resolves to the plugin entry. Use `/managed-server` for the lifecycle API.
|
|
151
154
|
|
|
152
155
|
Node example (`/config` + `/core`):
|
|
153
156
|
|
package/dist/attach.js
CHANGED
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
4
4
|
|
|
5
|
+
// src/cli.ts
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
5
8
|
// src/config.ts
|
|
6
9
|
import { existsSync, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
|
|
7
10
|
import { homedir as homedir3 } from "node:os";
|
|
@@ -718,7 +721,7 @@ function registerRoster(name, rosterPath) {
|
|
|
718
721
|
if (!readResult.ok)
|
|
719
722
|
return readResult;
|
|
720
723
|
const registry = readResult.registry;
|
|
721
|
-
const collision = registry.rosters.find((
|
|
724
|
+
const collision = registry.rosters.find((entry) => entry.name.toLowerCase() === name.toLowerCase());
|
|
722
725
|
if (collision) {
|
|
723
726
|
return {
|
|
724
727
|
ok: false,
|
|
@@ -1059,8 +1062,8 @@ async function waitForDiscoveryOrFail(rosterPath, budgetMs) {
|
|
|
1059
1062
|
const handle = attachServer(rosterPath);
|
|
1060
1063
|
if (handle)
|
|
1061
1064
|
return handle;
|
|
1062
|
-
const
|
|
1063
|
-
const winnerAlive =
|
|
1065
|
+
const lockInfo = readLockFile(lockPath);
|
|
1066
|
+
const winnerAlive = lockInfo !== null && verifyIdentity(lockInfo.pid, lockInfo.startTime);
|
|
1064
1067
|
if (!winnerAlive) {
|
|
1065
1068
|
throw new Error(`space-bus: the process starting the managed server for roster ${rosterPath} failed before it could finish (lock released without a discovery file) — check its log for details`);
|
|
1066
1069
|
}
|
|
@@ -1452,9 +1455,6 @@ async function waitForGroupDeath(pid, budgetMs) {
|
|
|
1452
1455
|
return !groupAlive();
|
|
1453
1456
|
}
|
|
1454
1457
|
|
|
1455
|
-
// src/cli.ts
|
|
1456
|
-
import { fileURLToPath } from "node:url";
|
|
1457
|
-
|
|
1458
1458
|
// src/service.ts
|
|
1459
1459
|
import {
|
|
1460
1460
|
chmodSync as chmodSync3,
|
|
@@ -2171,7 +2171,7 @@ function printJson(json, data, plain) {
|
|
|
2171
2171
|
async function runServe(args, deps = {}) {
|
|
2172
2172
|
const doEnsureServer = deps.ensureServer ?? ensureServer;
|
|
2173
2173
|
const doStopServer = deps.stopServer ?? stopServer;
|
|
2174
|
-
const doSuperviseServer = deps.superviseServer ?? ((
|
|
2174
|
+
const doSuperviseServer = deps.superviseServer ?? ((rosterPath, handle, shouldStop, interrupt) => superviseServer(rosterPath, handle, { shouldStop, interrupt }));
|
|
2175
2175
|
const rosterPath = resolveRoster(args.config);
|
|
2176
2176
|
const handle = await doEnsureServer(rosterPath);
|
|
2177
2177
|
const data = {
|
|
@@ -2387,6 +2387,6 @@ if (__require.main == __require.module) {
|
|
|
2387
2387
|
});
|
|
2388
2388
|
}
|
|
2389
2389
|
export {
|
|
2390
|
-
|
|
2391
|
-
|
|
2390
|
+
runServe,
|
|
2391
|
+
runService
|
|
2392
2392
|
};
|
package/dist/config.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
-
|
|
4
1
|
// src/config.ts
|
|
5
2
|
import { existsSync, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
|
|
6
3
|
import { homedir as homedir3 } from "node:os";
|
|
@@ -717,7 +714,7 @@ function registerRoster(name, rosterPath) {
|
|
|
717
714
|
if (!readResult.ok)
|
|
718
715
|
return readResult;
|
|
719
716
|
const registry = readResult.registry;
|
|
720
|
-
const collision = registry.rosters.find((
|
|
717
|
+
const collision = registry.rosters.find((entry) => entry.name.toLowerCase() === name.toLowerCase());
|
|
721
718
|
if (collision) {
|
|
722
719
|
return {
|
|
723
720
|
ok: false,
|
|
@@ -964,18 +961,18 @@ function isManagedRoster(directory) {
|
|
|
964
961
|
return manifest.server.managed !== undefined;
|
|
965
962
|
}
|
|
966
963
|
export {
|
|
967
|
-
|
|
968
|
-
resolveRosterPath,
|
|
969
|
-
manifestSchema,
|
|
970
|
-
managedServerConfigSchema,
|
|
971
|
-
loadContextForRosterPath,
|
|
972
|
-
loadContextForRoster,
|
|
973
|
-
loadContext,
|
|
974
|
-
isManagedRosterAtPath,
|
|
975
|
-
isManagedRoster,
|
|
976
|
-
getRosterAtPath,
|
|
977
|
-
getRoster,
|
|
978
|
-
getProjects,
|
|
964
|
+
expandHome,
|
|
979
965
|
getCredentials,
|
|
980
|
-
|
|
966
|
+
getProjects,
|
|
967
|
+
getRoster,
|
|
968
|
+
getRosterAtPath,
|
|
969
|
+
isManagedRoster,
|
|
970
|
+
isManagedRosterAtPath,
|
|
971
|
+
loadContext,
|
|
972
|
+
loadContextForRoster,
|
|
973
|
+
loadContextForRosterPath,
|
|
974
|
+
managedServerConfigSchema,
|
|
975
|
+
manifestSchema,
|
|
976
|
+
resolveRosterPath,
|
|
977
|
+
serverConfigSchema
|
|
981
978
|
};
|
package/dist/contract.js
CHANGED
|
@@ -168,35 +168,35 @@ var discoveryFileSchema = z.object({
|
|
|
168
168
|
rosterPath: z.string().optional()
|
|
169
169
|
});
|
|
170
170
|
export {
|
|
171
|
-
|
|
172
|
-
vcsStatusEntrySchema,
|
|
173
|
-
turnMessageSchema,
|
|
174
|
-
turnMessageListSchema,
|
|
175
|
-
turnDiffEntrySchema,
|
|
176
|
-
todoSchema,
|
|
177
|
-
sessionSummarySchema,
|
|
178
|
-
sessionStatusMapSchema,
|
|
179
|
-
sessionStateSchema,
|
|
180
|
-
sessionStateInfoSchema,
|
|
181
|
-
sessionSchema,
|
|
182
|
-
sessionListSchema,
|
|
183
|
-
rosterSchema,
|
|
184
|
-
registryFileSchema,
|
|
185
|
-
registryEntrySchema,
|
|
186
|
-
questionListSchema,
|
|
187
|
-
questionEntrySchema,
|
|
188
|
-
projectSchema,
|
|
189
|
-
pendingQuestionListSchema,
|
|
190
|
-
pendingQuestionEntrySchema,
|
|
191
|
-
messagePartSchema,
|
|
192
|
-
messageListSchema,
|
|
193
|
-
messageEnvelopeSchema,
|
|
194
|
-
managedSpawnConfigSchema,
|
|
195
|
-
loopbackOk,
|
|
196
|
-
discoveryFileSchema,
|
|
197
|
-
diffSchema,
|
|
198
|
-
diffEntrySchema,
|
|
199
|
-
credentialsSchema,
|
|
171
|
+
LOOPBACK_HOSTS,
|
|
200
172
|
busContextSchema,
|
|
201
|
-
|
|
173
|
+
credentialsSchema,
|
|
174
|
+
diffEntrySchema,
|
|
175
|
+
diffSchema,
|
|
176
|
+
discoveryFileSchema,
|
|
177
|
+
loopbackOk,
|
|
178
|
+
managedSpawnConfigSchema,
|
|
179
|
+
messageEnvelopeSchema,
|
|
180
|
+
messageListSchema,
|
|
181
|
+
messagePartSchema,
|
|
182
|
+
pendingQuestionEntrySchema,
|
|
183
|
+
pendingQuestionListSchema,
|
|
184
|
+
projectSchema,
|
|
185
|
+
questionEntrySchema,
|
|
186
|
+
questionListSchema,
|
|
187
|
+
registryEntrySchema,
|
|
188
|
+
registryFileSchema,
|
|
189
|
+
rosterSchema,
|
|
190
|
+
sessionListSchema,
|
|
191
|
+
sessionSchema,
|
|
192
|
+
sessionStateInfoSchema,
|
|
193
|
+
sessionStateSchema,
|
|
194
|
+
sessionStatusMapSchema,
|
|
195
|
+
sessionSummarySchema,
|
|
196
|
+
todoSchema,
|
|
197
|
+
turnDiffEntrySchema,
|
|
198
|
+
turnMessageListSchema,
|
|
199
|
+
turnMessageSchema,
|
|
200
|
+
vcsStatusEntrySchema,
|
|
201
|
+
vcsStatusSchema
|
|
202
202
|
};
|
package/dist/core.js
CHANGED
|
@@ -1109,16 +1109,16 @@ async function answerQuestion(args, opts) {
|
|
|
1109
1109
|
return { ok: true, sessionId: args.sessionId, requestId: args.requestId };
|
|
1110
1110
|
}
|
|
1111
1111
|
export {
|
|
1112
|
-
|
|
1113
|
-
toDispatchArgs,
|
|
1114
|
-
status,
|
|
1115
|
-
snapshot,
|
|
1116
|
-
roster,
|
|
1117
|
-
result,
|
|
1118
|
-
questions,
|
|
1119
|
-
messages,
|
|
1120
|
-
dispatch,
|
|
1121
|
-
deriveSessionState,
|
|
1112
|
+
answerQuestion,
|
|
1122
1113
|
createDispatchMessageId,
|
|
1123
|
-
|
|
1114
|
+
deriveSessionState,
|
|
1115
|
+
dispatch,
|
|
1116
|
+
messages,
|
|
1117
|
+
questions,
|
|
1118
|
+
result,
|
|
1119
|
+
roster,
|
|
1120
|
+
snapshot,
|
|
1121
|
+
status,
|
|
1122
|
+
toDispatchArgs,
|
|
1123
|
+
wait
|
|
1124
1124
|
};
|
package/dist/format.js
CHANGED
|
@@ -85,11 +85,11 @@ function formatResult(r) {
|
|
|
85
85
|
`);
|
|
86
86
|
}
|
|
87
87
|
export {
|
|
88
|
-
|
|
89
|
-
formatStatus,
|
|
90
|
-
formatRosterHeader,
|
|
91
|
-
formatRoster,
|
|
92
|
-
formatResult,
|
|
88
|
+
dispatchMetadata,
|
|
93
89
|
formatDispatch,
|
|
94
|
-
|
|
90
|
+
formatResult,
|
|
91
|
+
formatRoster,
|
|
92
|
+
formatRosterHeader,
|
|
93
|
+
formatStatus,
|
|
94
|
+
formatWait
|
|
95
95
|
};
|