@fro.bot/space-bus 0.13.1 → 0.14.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 +5 -1
- package/dist/attach.js +12 -2
- package/dist/cli.js +28 -15
- package/dist/config.d.ts +9 -4
- package/dist/config.js +27 -11
- package/dist/contract.d.ts +16 -0
- package/dist/contract.js +12 -2
- package/dist/core.d.ts +80 -0
- package/dist/core.js +216 -23
- package/dist/format.js +2 -0
- package/dist/index.js +79 -31
- package/dist/mcp.js +80 -32
- package/dist/registry-entry.js +27 -11
- package/dist/server.js +27 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -138,7 +138,11 @@ Semantics:
|
|
|
138
138
|
|
|
139
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.
|
|
140
140
|
|
|
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.
|
|
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
|
+
- `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.
|
|
143
|
+
- `questions(target, { context })` — complete project- or session-scoped pending-question read. `target` is `{ project }` or `{ sessionId }` — exactly one; both-present or neither-present is rejected before any fetch. Returns `{ questions: [{ requestId, sessionId, questions: [{ header?, question, multiple, custom, options: [{ label, description? }] }] }] }` — one entry per `/question` request, each carrying its **full nested subquestion list** (a single request can ask multiple subquestions), not just the first one.
|
|
144
|
+
- `answerQuestion({ sessionId, requestId, answers }, { context })` — explicit question answer. Runtime-validates `answers` is a non-empty `string[][]` (rejects non-arrays, non-array rows, and non-string cells) before any fetch; verifies `requestId` actually belongs to a pending question on `sessionId` (fetched fresh from `GET /question`, parsed with the full pending-question schema) before sending the reply — a `requestId` for a different session is refused with no mutation; and verifies `answers.length` equals that request's subquestion count before sending — mismatched cardinality is refused with no mutation. Sends the complete `string[][]` `answers` payload to `POST /question/:requestId/reply`. `requestId` must be the question's own id (`que_...`), never an SSE envelope id (`evt_...`).
|
|
145
|
+
- `dispatch(args, opts)` gained an optional `args.onPendingQuestion: "question-reply" | "blocked"` (default `"question-reply"`, backward-compatible with 0.13.1); `toDispatchArgs` validates and preserves this field, rejecting any other value. Steering a session that has a pending question with `onPendingQuestion: "blocked"` returns `{ ok: true, mode: "blocked", sessionId, project, requestId }` and sends **neither** a question reply **nor** a follow-up prompt — for callers (like `ide_dispatch_prompt`) that must never silently reinterpret prompt text as a question answer. `"blocked"` is fail-closed: if `GET /question` returns a non-2xx status or an unparseable body, the pending-question state is unknown and the call returns a stable `Result` error instead of falling through to any mutation. The default `"question-reply"` policy (omitted, or passed explicitly) preserves the original fail-open v0.13.1 behavior unchanged, including on an unreadable `/question` response (falls through to a normal follow-up prompt).
|
|
142
146
|
- `@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.
|
|
143
147
|
- `@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.
|
|
144
148
|
- `@fro.bot/space-bus/format` — the pure formatters the tools use to render output, for tool-identical text.
|
package/dist/attach.js
CHANGED
|
@@ -63,7 +63,11 @@ var messagePartSchema = z.looseObject({
|
|
|
63
63
|
text: z.string().optional()
|
|
64
64
|
});
|
|
65
65
|
var messageEnvelopeSchema = z.looseObject({
|
|
66
|
-
info: z.looseObject({
|
|
66
|
+
info: z.looseObject({
|
|
67
|
+
id: z.string().optional(),
|
|
68
|
+
role: z.string(),
|
|
69
|
+
time: z.looseObject({ created: z.number().optional() }).optional()
|
|
70
|
+
}),
|
|
67
71
|
parts: z.array(messagePartSchema)
|
|
68
72
|
});
|
|
69
73
|
var messageListSchema = z.array(messageEnvelopeSchema);
|
|
@@ -72,7 +76,13 @@ var pendingQuestionEntrySchema = z.looseObject({
|
|
|
72
76
|
sessionID: z.string(),
|
|
73
77
|
questions: z.array(z.looseObject({
|
|
74
78
|
question: z.string().optional(),
|
|
75
|
-
|
|
79
|
+
header: z.string().optional(),
|
|
80
|
+
multiple: z.boolean().optional(),
|
|
81
|
+
custom: z.boolean().optional(),
|
|
82
|
+
options: z.array(z.looseObject({
|
|
83
|
+
label: z.string().optional(),
|
|
84
|
+
description: z.string().optional()
|
|
85
|
+
})).optional()
|
|
76
86
|
})).optional()
|
|
77
87
|
});
|
|
78
88
|
var pendingQuestionListSchema = z.array(pendingQuestionEntrySchema);
|
package/dist/cli.js
CHANGED
|
@@ -73,7 +73,11 @@ var messagePartSchema = z.looseObject({
|
|
|
73
73
|
text: z.string().optional()
|
|
74
74
|
});
|
|
75
75
|
var messageEnvelopeSchema = z.looseObject({
|
|
76
|
-
info: z.looseObject({
|
|
76
|
+
info: z.looseObject({
|
|
77
|
+
id: z.string().optional(),
|
|
78
|
+
role: z.string(),
|
|
79
|
+
time: z.looseObject({ created: z.number().optional() }).optional()
|
|
80
|
+
}),
|
|
77
81
|
parts: z.array(messagePartSchema)
|
|
78
82
|
});
|
|
79
83
|
var messageListSchema = z.array(messageEnvelopeSchema);
|
|
@@ -82,7 +86,13 @@ var pendingQuestionEntrySchema = z.looseObject({
|
|
|
82
86
|
sessionID: z.string(),
|
|
83
87
|
questions: z.array(z.looseObject({
|
|
84
88
|
question: z.string().optional(),
|
|
85
|
-
|
|
89
|
+
header: z.string().optional(),
|
|
90
|
+
multiple: z.boolean().optional(),
|
|
91
|
+
custom: z.boolean().optional(),
|
|
92
|
+
options: z.array(z.looseObject({
|
|
93
|
+
label: z.string().optional(),
|
|
94
|
+
description: z.string().optional()
|
|
95
|
+
})).optional()
|
|
86
96
|
})).optional()
|
|
87
97
|
});
|
|
88
98
|
var pendingQuestionListSchema = z.array(pendingQuestionEntrySchema);
|
|
@@ -843,17 +853,23 @@ var manifestSchema = z3.object({
|
|
|
843
853
|
function expandHome(path) {
|
|
844
854
|
return path.startsWith("~") ? join3(homedir3(), path.slice(1)) : path;
|
|
845
855
|
}
|
|
846
|
-
function
|
|
856
|
+
function resolveExplicitOverride(override, sourceLabel) {
|
|
857
|
+
if (override.includes("://")) {
|
|
858
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
859
|
+
}
|
|
860
|
+
const expanded = expandHome(override);
|
|
861
|
+
if (!expanded.startsWith("/")) {
|
|
862
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got: ${override})`);
|
|
863
|
+
}
|
|
864
|
+
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
865
|
+
}
|
|
866
|
+
function resolveRosterPath(directory, explicitOverride) {
|
|
867
|
+
if (explicitOverride) {
|
|
868
|
+
return resolveExplicitOverride(explicitOverride, "--config");
|
|
869
|
+
}
|
|
847
870
|
const override = process.env["SPACE_BUS_CONFIG"];
|
|
848
871
|
if (override) {
|
|
849
|
-
|
|
850
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
851
|
-
}
|
|
852
|
-
const expanded = expandHome(override);
|
|
853
|
-
if (!expanded.startsWith("/")) {
|
|
854
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got: ${override})`);
|
|
855
|
-
}
|
|
856
|
-
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
872
|
+
return resolveExplicitOverride(override, "SPACE_BUS_CONFIG");
|
|
857
873
|
}
|
|
858
874
|
if (directory) {
|
|
859
875
|
const candidate = join3(directory, "spacebus.json");
|
|
@@ -2141,10 +2157,7 @@ function consumeArg(argv, i, result) {
|
|
|
2141
2157
|
return i;
|
|
2142
2158
|
}
|
|
2143
2159
|
function resolveRoster(config) {
|
|
2144
|
-
|
|
2145
|
-
process.env["SPACE_BUS_CONFIG"] = config;
|
|
2146
|
-
}
|
|
2147
|
-
return resolveRosterPath();
|
|
2160
|
+
return resolveRosterPath(undefined, config);
|
|
2148
2161
|
}
|
|
2149
2162
|
function printJson(json, data, plain) {
|
|
2150
2163
|
if (json) {
|
package/dist/config.d.ts
CHANGED
|
@@ -43,17 +43,22 @@ export declare function expandHome(path: string): string;
|
|
|
43
43
|
* Resolves the path to spacebus.json for a given workspace directory.
|
|
44
44
|
*
|
|
45
45
|
* Resolution order:
|
|
46
|
-
* 1.
|
|
46
|
+
* 1. `explicitOverride`, when passed (e.g. the CLI's `--config` flag) —
|
|
47
|
+
* validated with the same absolute-path/URL/~-expansion rules as
|
|
48
|
+
* SPACE_BUS_CONFIG below, but resolved directly without touching
|
|
49
|
+
* process.env. This lets callers thread an explicit override through
|
|
50
|
+
* a single call without a persistent global mutation.
|
|
51
|
+
* 2. SPACE_BUS_CONFIG env var (must be absolute or start with ~; URLs and
|
|
47
52
|
* bare-relative paths are rejected with an actionable error).
|
|
48
|
-
*
|
|
49
|
-
*
|
|
53
|
+
* 3. `<directory>/spacebus.json`.
|
|
54
|
+
* 4. Throws, naming both mechanisms.
|
|
50
55
|
*
|
|
51
56
|
* Exact-path discovery only — no upward directory walk. When the resolved
|
|
52
57
|
* file exists, the path is canonicalized with realpathSync; when it's
|
|
53
58
|
* missing, the un-canonicalized (but expanded/joined) path is used in the
|
|
54
59
|
* error message.
|
|
55
60
|
*/
|
|
56
|
-
export declare function resolveRosterPath(directory?: string): string;
|
|
61
|
+
export declare function resolveRosterPath(directory?: string, explicitOverride?: string): string;
|
|
57
62
|
/**
|
|
58
63
|
* Reads, validates, and expands the roster manifest at an already-resolved
|
|
59
64
|
* path. Extracted from `getRoster` so both directory-based resolution and
|
package/dist/config.js
CHANGED
|
@@ -72,7 +72,11 @@ var messagePartSchema = z.looseObject({
|
|
|
72
72
|
text: z.string().optional()
|
|
73
73
|
});
|
|
74
74
|
var messageEnvelopeSchema = z.looseObject({
|
|
75
|
-
info: z.looseObject({
|
|
75
|
+
info: z.looseObject({
|
|
76
|
+
id: z.string().optional(),
|
|
77
|
+
role: z.string(),
|
|
78
|
+
time: z.looseObject({ created: z.number().optional() }).optional()
|
|
79
|
+
}),
|
|
76
80
|
parts: z.array(messagePartSchema)
|
|
77
81
|
});
|
|
78
82
|
var messageListSchema = z.array(messageEnvelopeSchema);
|
|
@@ -81,7 +85,13 @@ var pendingQuestionEntrySchema = z.looseObject({
|
|
|
81
85
|
sessionID: z.string(),
|
|
82
86
|
questions: z.array(z.looseObject({
|
|
83
87
|
question: z.string().optional(),
|
|
84
|
-
|
|
88
|
+
header: z.string().optional(),
|
|
89
|
+
multiple: z.boolean().optional(),
|
|
90
|
+
custom: z.boolean().optional(),
|
|
91
|
+
options: z.array(z.looseObject({
|
|
92
|
+
label: z.string().optional(),
|
|
93
|
+
description: z.string().optional()
|
|
94
|
+
})).optional()
|
|
85
95
|
})).optional()
|
|
86
96
|
});
|
|
87
97
|
var pendingQuestionListSchema = z.array(pendingQuestionEntrySchema);
|
|
@@ -842,17 +852,23 @@ var manifestSchema = z3.object({
|
|
|
842
852
|
function expandHome(path) {
|
|
843
853
|
return path.startsWith("~") ? join3(homedir3(), path.slice(1)) : path;
|
|
844
854
|
}
|
|
845
|
-
function
|
|
855
|
+
function resolveExplicitOverride(override, sourceLabel) {
|
|
856
|
+
if (override.includes("://")) {
|
|
857
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
858
|
+
}
|
|
859
|
+
const expanded = expandHome(override);
|
|
860
|
+
if (!expanded.startsWith("/")) {
|
|
861
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got: ${override})`);
|
|
862
|
+
}
|
|
863
|
+
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
864
|
+
}
|
|
865
|
+
function resolveRosterPath(directory, explicitOverride) {
|
|
866
|
+
if (explicitOverride) {
|
|
867
|
+
return resolveExplicitOverride(explicitOverride, "--config");
|
|
868
|
+
}
|
|
846
869
|
const override = process.env["SPACE_BUS_CONFIG"];
|
|
847
870
|
if (override) {
|
|
848
|
-
|
|
849
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
850
|
-
}
|
|
851
|
-
const expanded = expandHome(override);
|
|
852
|
-
if (!expanded.startsWith("/")) {
|
|
853
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got: ${override})`);
|
|
854
|
-
}
|
|
855
|
-
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
871
|
+
return resolveExplicitOverride(override, "SPACE_BUS_CONFIG");
|
|
856
872
|
}
|
|
857
873
|
if (directory) {
|
|
858
874
|
const candidate = join3(directory, "spacebus.json");
|
package/dist/contract.d.ts
CHANGED
|
@@ -133,7 +133,11 @@ export declare const messagePartSchema: z.ZodObject<{
|
|
|
133
133
|
export type MessagePartSchema = z.infer<typeof messagePartSchema>;
|
|
134
134
|
export declare const messageEnvelopeSchema: z.ZodObject<{
|
|
135
135
|
info: z.ZodObject<{
|
|
136
|
+
id: z.ZodOptional<z.ZodString>;
|
|
136
137
|
role: z.ZodString;
|
|
138
|
+
time: z.ZodOptional<z.ZodObject<{
|
|
139
|
+
created: z.ZodOptional<z.ZodNumber>;
|
|
140
|
+
}, z.core.$loose>>;
|
|
137
141
|
}, z.core.$loose>;
|
|
138
142
|
parts: z.ZodArray<z.ZodObject<{
|
|
139
143
|
type: z.ZodString;
|
|
@@ -143,7 +147,11 @@ export declare const messageEnvelopeSchema: z.ZodObject<{
|
|
|
143
147
|
export type MessageEnvelopeSchema = z.infer<typeof messageEnvelopeSchema>;
|
|
144
148
|
export declare const messageListSchema: z.ZodArray<z.ZodObject<{
|
|
145
149
|
info: z.ZodObject<{
|
|
150
|
+
id: z.ZodOptional<z.ZodString>;
|
|
146
151
|
role: z.ZodString;
|
|
152
|
+
time: z.ZodOptional<z.ZodObject<{
|
|
153
|
+
created: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
}, z.core.$loose>>;
|
|
147
155
|
}, z.core.$loose>;
|
|
148
156
|
parts: z.ZodArray<z.ZodObject<{
|
|
149
157
|
type: z.ZodString;
|
|
@@ -156,8 +164,12 @@ export declare const pendingQuestionEntrySchema: z.ZodObject<{
|
|
|
156
164
|
sessionID: z.ZodString;
|
|
157
165
|
questions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
158
166
|
question: z.ZodOptional<z.ZodString>;
|
|
167
|
+
header: z.ZodOptional<z.ZodString>;
|
|
168
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
169
|
+
custom: z.ZodOptional<z.ZodBoolean>;
|
|
159
170
|
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
160
171
|
label: z.ZodOptional<z.ZodString>;
|
|
172
|
+
description: z.ZodOptional<z.ZodString>;
|
|
161
173
|
}, z.core.$loose>>>;
|
|
162
174
|
}, z.core.$loose>>>;
|
|
163
175
|
}, z.core.$loose>;
|
|
@@ -167,8 +179,12 @@ export declare const pendingQuestionListSchema: z.ZodArray<z.ZodObject<{
|
|
|
167
179
|
sessionID: z.ZodString;
|
|
168
180
|
questions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
169
181
|
question: z.ZodOptional<z.ZodString>;
|
|
182
|
+
header: z.ZodOptional<z.ZodString>;
|
|
183
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
184
|
+
custom: z.ZodOptional<z.ZodBoolean>;
|
|
170
185
|
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
171
186
|
label: z.ZodOptional<z.ZodString>;
|
|
187
|
+
description: z.ZodOptional<z.ZodString>;
|
|
172
188
|
}, z.core.$loose>>>;
|
|
173
189
|
}, z.core.$loose>>>;
|
|
174
190
|
}, z.core.$loose>>;
|
package/dist/contract.js
CHANGED
|
@@ -63,7 +63,11 @@ var messagePartSchema = z.looseObject({
|
|
|
63
63
|
text: z.string().optional()
|
|
64
64
|
});
|
|
65
65
|
var messageEnvelopeSchema = z.looseObject({
|
|
66
|
-
info: z.looseObject({
|
|
66
|
+
info: z.looseObject({
|
|
67
|
+
id: z.string().optional(),
|
|
68
|
+
role: z.string(),
|
|
69
|
+
time: z.looseObject({ created: z.number().optional() }).optional()
|
|
70
|
+
}),
|
|
67
71
|
parts: z.array(messagePartSchema)
|
|
68
72
|
});
|
|
69
73
|
var messageListSchema = z.array(messageEnvelopeSchema);
|
|
@@ -72,7 +76,13 @@ var pendingQuestionEntrySchema = z.looseObject({
|
|
|
72
76
|
sessionID: z.string(),
|
|
73
77
|
questions: z.array(z.looseObject({
|
|
74
78
|
question: z.string().optional(),
|
|
75
|
-
|
|
79
|
+
header: z.string().optional(),
|
|
80
|
+
multiple: z.boolean().optional(),
|
|
81
|
+
custom: z.boolean().optional(),
|
|
82
|
+
options: z.array(z.looseObject({
|
|
83
|
+
label: z.string().optional(),
|
|
84
|
+
description: z.string().optional()
|
|
85
|
+
})).optional()
|
|
76
86
|
})).optional()
|
|
77
87
|
});
|
|
78
88
|
var pendingQuestionListSchema = z.array(pendingQuestionEntrySchema);
|
package/dist/core.d.ts
CHANGED
|
@@ -34,10 +34,23 @@ export type DispatchResult = {
|
|
|
34
34
|
directory: string;
|
|
35
35
|
} | {
|
|
36
36
|
mode: "question-reply" | "follow-up";
|
|
37
|
+
} | {
|
|
38
|
+
mode: "blocked";
|
|
39
|
+
requestId: string;
|
|
37
40
|
});
|
|
38
41
|
export type DispatchArgs = {
|
|
39
42
|
prompt: string;
|
|
40
43
|
title?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Backward-compatible pending-question policy for the steering path.
|
|
46
|
+
* Defaults to v0.13.1's implicit "question-reply" behavior (a follow-up
|
|
47
|
+
* to a session with a pending question is sent as that question's
|
|
48
|
+
* reply). Passing "blocked" instead refuses the mutation entirely and
|
|
49
|
+
* returns a typed blocked result with no reply and no follow-up prompt —
|
|
50
|
+
* required by ide_dispatch_prompt (R2), which must never silently
|
|
51
|
+
* reinterpret prompt text as a question answer.
|
|
52
|
+
*/
|
|
53
|
+
onPendingQuestion?: "question-reply" | "blocked";
|
|
41
54
|
} & ({
|
|
42
55
|
project: string;
|
|
43
56
|
sessionId?: undefined;
|
|
@@ -50,6 +63,7 @@ export declare function toDispatchArgs(input: {
|
|
|
50
63
|
title?: string;
|
|
51
64
|
project?: string;
|
|
52
65
|
sessionId?: string;
|
|
66
|
+
onPendingQuestion?: "question-reply" | "blocked";
|
|
53
67
|
}): Result<DispatchArgs>;
|
|
54
68
|
export declare function dispatch(args: DispatchArgs, opts: CoreOpts): Promise<Result<DispatchResult>>;
|
|
55
69
|
export type SessionStatusResult = {
|
|
@@ -148,3 +162,69 @@ export declare function wait(sessionIds: string[], opts: CoreOpts & {
|
|
|
148
162
|
timeoutMs?: number;
|
|
149
163
|
pollIntervalMs?: number;
|
|
150
164
|
}): Promise<Result<WaitResult>>;
|
|
165
|
+
export type MessageOpts = CoreOpts & {
|
|
166
|
+
limit?: number;
|
|
167
|
+
};
|
|
168
|
+
export type SessionMessage = {
|
|
169
|
+
id?: string;
|
|
170
|
+
role: string;
|
|
171
|
+
createdAt?: number;
|
|
172
|
+
parts: {
|
|
173
|
+
type: string;
|
|
174
|
+
text?: string;
|
|
175
|
+
}[];
|
|
176
|
+
};
|
|
177
|
+
export type MessagesResult = {
|
|
178
|
+
sessionId: string;
|
|
179
|
+
project: string;
|
|
180
|
+
messages: SessionMessage[];
|
|
181
|
+
};
|
|
182
|
+
export declare function messages(sessionId: string, opts: MessageOpts): Promise<Result<MessagesResult>>;
|
|
183
|
+
export type QuestionTarget = {
|
|
184
|
+
project: string;
|
|
185
|
+
sessionId?: undefined;
|
|
186
|
+
} | {
|
|
187
|
+
sessionId: string;
|
|
188
|
+
project?: undefined;
|
|
189
|
+
};
|
|
190
|
+
/** One subquestion within a pending-question request — a single request
|
|
191
|
+
* (`requestId`) can carry multiple subquestions, each with its own
|
|
192
|
+
* selection rules and option set. Preserving the full nested list (not
|
|
193
|
+
* just the first subquestion) is required to round-trip a multi-question
|
|
194
|
+
* request through answerQuestion()'s cardinality check. */
|
|
195
|
+
export type PendingSubquestion = {
|
|
196
|
+
header?: string;
|
|
197
|
+
question: string;
|
|
198
|
+
multiple: boolean;
|
|
199
|
+
custom: boolean;
|
|
200
|
+
options: {
|
|
201
|
+
label: string;
|
|
202
|
+
description?: string;
|
|
203
|
+
}[];
|
|
204
|
+
};
|
|
205
|
+
export type PendingQuestionView = {
|
|
206
|
+
requestId: string;
|
|
207
|
+
sessionId: string;
|
|
208
|
+
questions: PendingSubquestion[];
|
|
209
|
+
};
|
|
210
|
+
export type QuestionsResult = {
|
|
211
|
+
questions: PendingQuestionView[];
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Complete project- or session-scoped pending-question read. Resolves the
|
|
215
|
+
* target to a manifest project (or a roster-owned session's project)
|
|
216
|
+
* before fetching /question, then returns the full current contract
|
|
217
|
+
* (requestID, sessionID, header/question text, selection rules, and
|
|
218
|
+
* option labels/descriptions) with no directory/credential fields.
|
|
219
|
+
*/
|
|
220
|
+
export declare function questions(target: QuestionTarget, opts: CoreOpts): Promise<Result<QuestionsResult>>;
|
|
221
|
+
export type AnswerQuestionArgs = {
|
|
222
|
+
sessionId: string;
|
|
223
|
+
requestId: string;
|
|
224
|
+
answers: string[][];
|
|
225
|
+
};
|
|
226
|
+
export type AnswerQuestionResult = {
|
|
227
|
+
sessionId: string;
|
|
228
|
+
requestId: string;
|
|
229
|
+
};
|
|
230
|
+
export declare function answerQuestion(args: AnswerQuestionArgs, opts: CoreOpts): Promise<Result<AnswerQuestionResult>>;
|
package/dist/core.js
CHANGED
|
@@ -63,7 +63,11 @@ var messagePartSchema = z.looseObject({
|
|
|
63
63
|
text: z.string().optional()
|
|
64
64
|
});
|
|
65
65
|
var messageEnvelopeSchema = z.looseObject({
|
|
66
|
-
info: z.looseObject({
|
|
66
|
+
info: z.looseObject({
|
|
67
|
+
id: z.string().optional(),
|
|
68
|
+
role: z.string(),
|
|
69
|
+
time: z.looseObject({ created: z.number().optional() }).optional()
|
|
70
|
+
}),
|
|
67
71
|
parts: z.array(messagePartSchema)
|
|
68
72
|
});
|
|
69
73
|
var messageListSchema = z.array(messageEnvelopeSchema);
|
|
@@ -72,7 +76,13 @@ var pendingQuestionEntrySchema = z.looseObject({
|
|
|
72
76
|
sessionID: z.string(),
|
|
73
77
|
questions: z.array(z.looseObject({
|
|
74
78
|
question: z.string().optional(),
|
|
75
|
-
|
|
79
|
+
header: z.string().optional(),
|
|
80
|
+
multiple: z.boolean().optional(),
|
|
81
|
+
custom: z.boolean().optional(),
|
|
82
|
+
options: z.array(z.looseObject({
|
|
83
|
+
label: z.string().optional(),
|
|
84
|
+
description: z.string().optional()
|
|
85
|
+
})).optional()
|
|
76
86
|
})).optional()
|
|
77
87
|
});
|
|
78
88
|
var pendingQuestionListSchema = z.array(pendingQuestionEntrySchema);
|
|
@@ -386,6 +396,9 @@ async function dispatchNew(baseUrl, credentials, projects, project, prompt, titl
|
|
|
386
396
|
return { ok: true, sessionId: session.id, project, directory };
|
|
387
397
|
}
|
|
388
398
|
function toDispatchArgs(input) {
|
|
399
|
+
if (input.onPendingQuestion !== undefined && input.onPendingQuestion !== "question-reply" && input.onPendingQuestion !== "blocked") {
|
|
400
|
+
return err(`space-bus: onPendingQuestion must be "question-reply" or "blocked", got ${JSON.stringify(input.onPendingQuestion)}`);
|
|
401
|
+
}
|
|
389
402
|
if (input.sessionId !== undefined && input.sessionId === "") {
|
|
390
403
|
return err("space-bus: sessionId must be a non-empty string");
|
|
391
404
|
}
|
|
@@ -397,7 +410,8 @@ function toDispatchArgs(input) {
|
|
|
397
410
|
ok: true,
|
|
398
411
|
prompt: input.prompt,
|
|
399
412
|
title: input.title,
|
|
400
|
-
project: input.project
|
|
413
|
+
project: input.project,
|
|
414
|
+
onPendingQuestion: input.onPendingQuestion
|
|
401
415
|
};
|
|
402
416
|
}
|
|
403
417
|
return {
|
|
@@ -405,7 +419,8 @@ function toDispatchArgs(input) {
|
|
|
405
419
|
prompt: input.prompt,
|
|
406
420
|
title: input.title,
|
|
407
421
|
sessionId: input.sessionId,
|
|
408
|
-
project: input.project
|
|
422
|
+
project: input.project,
|
|
423
|
+
onPendingQuestion: input.onPendingQuestion
|
|
409
424
|
};
|
|
410
425
|
}
|
|
411
426
|
async function dispatch(args, opts) {
|
|
@@ -438,7 +453,7 @@ async function dispatch(args, opts) {
|
|
|
438
453
|
if (args.project && args.project !== project) {
|
|
439
454
|
return err(`space-bus: session ${args.sessionId} belongs to project "${project}", not "${args.project}" — refusing to steer the wrong session`);
|
|
440
455
|
}
|
|
441
|
-
return steerSession(baseUrl, credentials, args.sessionId, args.prompt, directory, project);
|
|
456
|
+
return steerSession(baseUrl, credentials, args.sessionId, args.prompt, directory, project, args.onPendingQuestion ?? "question-reply");
|
|
442
457
|
}
|
|
443
458
|
async function findSessionDirectory(baseUrl, credentials, projects, sessionId) {
|
|
444
459
|
for (const p of projects) {
|
|
@@ -543,26 +558,51 @@ async function status(sessionId, opts) {
|
|
|
543
558
|
resultAvailable: state === "complete"
|
|
544
559
|
};
|
|
545
560
|
}
|
|
546
|
-
async function
|
|
561
|
+
async function resolvePendingQuestionForSteer(baseUrl, credentials, directory, sessionId, onPendingQuestion) {
|
|
547
562
|
const questionsRes = await api(baseUrl, credentials, directory, "/question");
|
|
548
|
-
if (questionsRes.res.ok) {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
questions = questionListSchema.parse(JSON.parse(questionsRes.bodyText));
|
|
552
|
-
} catch {
|
|
553
|
-
questions = [];
|
|
563
|
+
if (!questionsRes.res.ok) {
|
|
564
|
+
if (onPendingQuestion === "blocked") {
|
|
565
|
+
return err(`space-bus: could not verify pending-question state for session ${sessionId} (/question ${questionsRes.res.status}) — refusing to dispatch under the blocked policy`);
|
|
554
566
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
567
|
+
return { ok: true, pending: undefined };
|
|
568
|
+
}
|
|
569
|
+
let pendingList;
|
|
570
|
+
try {
|
|
571
|
+
pendingList = questionListSchema.parse(JSON.parse(questionsRes.bodyText));
|
|
572
|
+
} catch (e) {
|
|
573
|
+
if (onPendingQuestion === "blocked") {
|
|
574
|
+
return err(`space-bus: could not parse pending-question state for session ${sessionId}: ${e.message} — refusing to dispatch under the blocked policy`);
|
|
575
|
+
}
|
|
576
|
+
return { ok: true, pending: undefined };
|
|
577
|
+
}
|
|
578
|
+
return {
|
|
579
|
+
ok: true,
|
|
580
|
+
pending: pendingList.find((q) => q.sessionID === sessionId)
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
async function steerSession(baseUrl, credentials, sessionId, message, directory, project, onPendingQuestion) {
|
|
584
|
+
const pendingRes = await resolvePendingQuestionForSteer(baseUrl, credentials, directory, sessionId, onPendingQuestion);
|
|
585
|
+
if (!pendingRes.ok)
|
|
586
|
+
return pendingRes;
|
|
587
|
+
const { pending } = pendingRes;
|
|
588
|
+
if (pending && onPendingQuestion === "blocked") {
|
|
589
|
+
return {
|
|
590
|
+
ok: true,
|
|
591
|
+
sessionId,
|
|
592
|
+
project,
|
|
593
|
+
mode: "blocked",
|
|
594
|
+
requestId: pending.id
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
if (pending) {
|
|
598
|
+
const replyRes = await api(baseUrl, credentials, directory, `/question/${encodeURIComponent(pending.id)}/reply`, {
|
|
599
|
+
method: "POST",
|
|
600
|
+
body: JSON.stringify({ answers: [[message]] })
|
|
601
|
+
});
|
|
602
|
+
if (!replyRes.res.ok) {
|
|
603
|
+
return err(`space-bus: failed to reply to question ${pending.id} for session ${sessionId} (${replyRes.res.status}): ${replyRes.bodyText}`);
|
|
565
604
|
}
|
|
605
|
+
return { ok: true, sessionId, project, mode: "question-reply" };
|
|
566
606
|
}
|
|
567
607
|
const promptRes = await api(baseUrl, credentials, directory, `/session/${encodeURIComponent(sessionId)}/prompt_async`, {
|
|
568
608
|
method: "POST",
|
|
@@ -828,6 +868,156 @@ function parsePendingQuestions(questionRes) {
|
|
|
828
868
|
return new Map;
|
|
829
869
|
}
|
|
830
870
|
}
|
|
871
|
+
var DEFAULT_MESSAGE_LIMIT = 20;
|
|
872
|
+
var MAX_MESSAGE_LIMIT = 200;
|
|
873
|
+
function isValidMessageLimit(limit) {
|
|
874
|
+
return Number.isFinite(limit) && Number.isInteger(limit) && limit > 0 && limit <= MAX_MESSAGE_LIMIT;
|
|
875
|
+
}
|
|
876
|
+
async function messages(sessionId, opts) {
|
|
877
|
+
const ctx = validateContext(opts.context);
|
|
878
|
+
if (!ctx.ok)
|
|
879
|
+
return ctx;
|
|
880
|
+
const { baseUrl, projects, credentials } = ctx;
|
|
881
|
+
const limit = opts.limit ?? DEFAULT_MESSAGE_LIMIT;
|
|
882
|
+
if (!isValidMessageLimit(limit)) {
|
|
883
|
+
return err(`space-bus: limit must be a finite positive integer no greater than ${MAX_MESSAGE_LIMIT}, got ${limit}`);
|
|
884
|
+
}
|
|
885
|
+
const loc = await findSessionDirectory(baseUrl, credentials, projects, sessionId);
|
|
886
|
+
if (!loc.ok)
|
|
887
|
+
return loc;
|
|
888
|
+
const { directory, project } = loc;
|
|
889
|
+
const { res, bodyText } = await api(baseUrl, credentials, directory, `/session/${encodeURIComponent(sessionId)}/message?limit=${limit}`);
|
|
890
|
+
if (!res.ok) {
|
|
891
|
+
return err(`space-bus: failed to fetch messages for ${sessionId} (${res.status})`);
|
|
892
|
+
}
|
|
893
|
+
let parsed;
|
|
894
|
+
try {
|
|
895
|
+
parsed = messageListSchema.parse(JSON.parse(bodyText));
|
|
896
|
+
} catch (e) {
|
|
897
|
+
return err(`space-bus: unexpected response shape for session ${sessionId} messages: ${e.message}`);
|
|
898
|
+
}
|
|
899
|
+
return {
|
|
900
|
+
ok: true,
|
|
901
|
+
sessionId,
|
|
902
|
+
project,
|
|
903
|
+
messages: parsed.map((m) => ({
|
|
904
|
+
id: m.info.id,
|
|
905
|
+
role: m.info.role,
|
|
906
|
+
createdAt: m.info.time?.created,
|
|
907
|
+
parts: m.parts.map((p) => ({ type: p.type, text: p.text }))
|
|
908
|
+
}))
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
function toPendingQuestionView(entry) {
|
|
912
|
+
return {
|
|
913
|
+
requestId: entry.id,
|
|
914
|
+
sessionId: entry.sessionID,
|
|
915
|
+
questions: (entry.questions ?? []).map((q) => ({
|
|
916
|
+
header: q.header,
|
|
917
|
+
question: q.question ?? "",
|
|
918
|
+
multiple: q.multiple ?? false,
|
|
919
|
+
custom: q.custom ?? false,
|
|
920
|
+
options: (q.options ?? []).map((o) => ({
|
|
921
|
+
label: o.label ?? "",
|
|
922
|
+
description: o.description
|
|
923
|
+
}))
|
|
924
|
+
}))
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
async function resolveQuestionsTarget(target, baseUrl, credentials, projects) {
|
|
928
|
+
const hasProject = "project" in target && !!target.project;
|
|
929
|
+
const hasSessionId = "sessionId" in target && !!target.sessionId;
|
|
930
|
+
if (hasProject && hasSessionId) {
|
|
931
|
+
return err("space-bus: questions target must specify exactly one of project or sessionId, not both");
|
|
932
|
+
}
|
|
933
|
+
if (!hasProject && !hasSessionId) {
|
|
934
|
+
return err("space-bus: questions target must specify exactly one of project or sessionId");
|
|
935
|
+
}
|
|
936
|
+
if (hasProject) {
|
|
937
|
+
const projRes = resolveProjectOrErr(projects, target.project);
|
|
938
|
+
if (!projRes.ok)
|
|
939
|
+
return projRes;
|
|
940
|
+
return {
|
|
941
|
+
ok: true,
|
|
942
|
+
directory: projRes.project.expandedPath,
|
|
943
|
+
sessionFilter: undefined
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
const targetSessionId = target.sessionId;
|
|
947
|
+
const loc = await findSessionDirectory(baseUrl, credentials, projects, targetSessionId);
|
|
948
|
+
if (!loc.ok)
|
|
949
|
+
return loc;
|
|
950
|
+
return { ok: true, directory: loc.directory, sessionFilter: targetSessionId };
|
|
951
|
+
}
|
|
952
|
+
async function questions(target, opts) {
|
|
953
|
+
const ctx = validateContext(opts.context);
|
|
954
|
+
if (!ctx.ok)
|
|
955
|
+
return ctx;
|
|
956
|
+
const { baseUrl, projects, credentials } = ctx;
|
|
957
|
+
const targetRes = await resolveQuestionsTarget(target, baseUrl, credentials, projects);
|
|
958
|
+
if (!targetRes.ok)
|
|
959
|
+
return targetRes;
|
|
960
|
+
const { directory, sessionFilter } = targetRes;
|
|
961
|
+
const { res, bodyText } = await api(baseUrl, credentials, directory, "/question");
|
|
962
|
+
if (!res.ok) {
|
|
963
|
+
return err(`space-bus: failed to fetch questions (${res.status})`);
|
|
964
|
+
}
|
|
965
|
+
let entries;
|
|
966
|
+
try {
|
|
967
|
+
entries = pendingQuestionListSchema.parse(JSON.parse(bodyText));
|
|
968
|
+
} catch (e) {
|
|
969
|
+
return err(`space-bus: unexpected response shape for questions: ${e.message}`);
|
|
970
|
+
}
|
|
971
|
+
const filtered = sessionFilter ? entries.filter((e) => e.sessionID === sessionFilter) : entries;
|
|
972
|
+
return { ok: true, questions: filtered.map(toPendingQuestionView) };
|
|
973
|
+
}
|
|
974
|
+
function isValidAnswersShape(value) {
|
|
975
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
976
|
+
return false;
|
|
977
|
+
return value.every((row) => Array.isArray(row) && row.every((cell) => typeof cell === "string"));
|
|
978
|
+
}
|
|
979
|
+
async function answerQuestion(args, opts) {
|
|
980
|
+
const ctx = validateContext(opts.context);
|
|
981
|
+
if (!ctx.ok)
|
|
982
|
+
return ctx;
|
|
983
|
+
const { baseUrl, projects, credentials } = ctx;
|
|
984
|
+
if (!isValidAnswersShape(args.answers)) {
|
|
985
|
+
return err("space-bus: answers must be a non-empty array of string arrays (string[][])");
|
|
986
|
+
}
|
|
987
|
+
const loc = await findSessionDirectory(baseUrl, credentials, projects, args.sessionId);
|
|
988
|
+
if (!loc.ok)
|
|
989
|
+
return loc;
|
|
990
|
+
const { directory } = loc;
|
|
991
|
+
const questionsRes = await api(baseUrl, credentials, directory, "/question");
|
|
992
|
+
if (!questionsRes.res.ok) {
|
|
993
|
+
return err(`space-bus: failed to fetch questions for session ${args.sessionId} (${questionsRes.res.status})`);
|
|
994
|
+
}
|
|
995
|
+
let pendingList;
|
|
996
|
+
try {
|
|
997
|
+
pendingList = pendingQuestionListSchema.parse(JSON.parse(questionsRes.bodyText));
|
|
998
|
+
} catch (e) {
|
|
999
|
+
return err(`space-bus: unexpected response shape for questions: ${e.message}`);
|
|
1000
|
+
}
|
|
1001
|
+
const pending = pendingList.find((q) => q.id === args.requestId && q.sessionID === args.sessionId);
|
|
1002
|
+
if (!pending) {
|
|
1003
|
+
return err(`space-bus: request ${args.requestId} does not belong to a pending question on session ${args.sessionId} — refusing to answer`);
|
|
1004
|
+
}
|
|
1005
|
+
if (!pending.questions || pending.questions.length === 0) {
|
|
1006
|
+
return err(`space-bus: request ${args.requestId} for session ${args.sessionId} has no subquestion metadata — refusing to answer without a verified cardinality`);
|
|
1007
|
+
}
|
|
1008
|
+
const expectedRows = pending.questions.length;
|
|
1009
|
+
if (args.answers.length !== expectedRows) {
|
|
1010
|
+
return err(`space-bus: answers has ${args.answers.length} row(s) but request ${args.requestId} has ${expectedRows} subquestion(s) — refusing to answer with mismatched cardinality`);
|
|
1011
|
+
}
|
|
1012
|
+
const replyRes = await api(baseUrl, credentials, directory, `/question/${encodeURIComponent(args.requestId)}/reply`, {
|
|
1013
|
+
method: "POST",
|
|
1014
|
+
body: JSON.stringify({ answers: args.answers })
|
|
1015
|
+
});
|
|
1016
|
+
if (!replyRes.res.ok) {
|
|
1017
|
+
return err(`space-bus: failed to answer question ${args.requestId} for session ${args.sessionId} (${replyRes.res.status})`);
|
|
1018
|
+
}
|
|
1019
|
+
return { ok: true, sessionId: args.sessionId, requestId: args.requestId };
|
|
1020
|
+
}
|
|
831
1021
|
export {
|
|
832
1022
|
wait,
|
|
833
1023
|
toDispatchArgs,
|
|
@@ -835,6 +1025,9 @@ export {
|
|
|
835
1025
|
snapshot,
|
|
836
1026
|
roster,
|
|
837
1027
|
result,
|
|
1028
|
+
questions,
|
|
1029
|
+
messages,
|
|
838
1030
|
dispatch,
|
|
839
|
-
deriveSessionState
|
|
1031
|
+
deriveSessionState,
|
|
1032
|
+
answerQuestion
|
|
840
1033
|
};
|
package/dist/format.js
CHANGED
|
@@ -21,6 +21,8 @@ function formatDispatch(r) {
|
|
|
21
21
|
return `Replied to pending question in session ${r.sessionId} (${r.project}).`;
|
|
22
22
|
case "follow-up":
|
|
23
23
|
return `Follow-up prompt sent to session ${r.sessionId} (${r.project}).`;
|
|
24
|
+
case "blocked":
|
|
25
|
+
return `Blocked: session ${r.sessionId} (${r.project}) has a pending question (${r.requestId}) — no reply or prompt sent.`;
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
function dispatchMetadata(r) {
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,11 @@ var messagePartSchema = z.looseObject({
|
|
|
72
72
|
text: z.string().optional()
|
|
73
73
|
});
|
|
74
74
|
var messageEnvelopeSchema = z.looseObject({
|
|
75
|
-
info: z.looseObject({
|
|
75
|
+
info: z.looseObject({
|
|
76
|
+
id: z.string().optional(),
|
|
77
|
+
role: z.string(),
|
|
78
|
+
time: z.looseObject({ created: z.number().optional() }).optional()
|
|
79
|
+
}),
|
|
76
80
|
parts: z.array(messagePartSchema)
|
|
77
81
|
});
|
|
78
82
|
var messageListSchema = z.array(messageEnvelopeSchema);
|
|
@@ -81,7 +85,13 @@ var pendingQuestionEntrySchema = z.looseObject({
|
|
|
81
85
|
sessionID: z.string(),
|
|
82
86
|
questions: z.array(z.looseObject({
|
|
83
87
|
question: z.string().optional(),
|
|
84
|
-
|
|
88
|
+
header: z.string().optional(),
|
|
89
|
+
multiple: z.boolean().optional(),
|
|
90
|
+
custom: z.boolean().optional(),
|
|
91
|
+
options: z.array(z.looseObject({
|
|
92
|
+
label: z.string().optional(),
|
|
93
|
+
description: z.string().optional()
|
|
94
|
+
})).optional()
|
|
85
95
|
})).optional()
|
|
86
96
|
});
|
|
87
97
|
var pendingQuestionListSchema = z.array(pendingQuestionEntrySchema);
|
|
@@ -842,17 +852,23 @@ var manifestSchema = z3.object({
|
|
|
842
852
|
function expandHome(path) {
|
|
843
853
|
return path.startsWith("~") ? join3(homedir3(), path.slice(1)) : path;
|
|
844
854
|
}
|
|
845
|
-
function
|
|
855
|
+
function resolveExplicitOverride(override, sourceLabel) {
|
|
856
|
+
if (override.includes("://")) {
|
|
857
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
858
|
+
}
|
|
859
|
+
const expanded = expandHome(override);
|
|
860
|
+
if (!expanded.startsWith("/")) {
|
|
861
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got: ${override})`);
|
|
862
|
+
}
|
|
863
|
+
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
864
|
+
}
|
|
865
|
+
function resolveRosterPath(directory, explicitOverride) {
|
|
866
|
+
if (explicitOverride) {
|
|
867
|
+
return resolveExplicitOverride(explicitOverride, "--config");
|
|
868
|
+
}
|
|
846
869
|
const override = process.env["SPACE_BUS_CONFIG"];
|
|
847
870
|
if (override) {
|
|
848
|
-
|
|
849
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
850
|
-
}
|
|
851
|
-
const expanded = expandHome(override);
|
|
852
|
-
if (!expanded.startsWith("/")) {
|
|
853
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got: ${override})`);
|
|
854
|
-
}
|
|
855
|
-
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
871
|
+
return resolveExplicitOverride(override, "SPACE_BUS_CONFIG");
|
|
856
872
|
}
|
|
857
873
|
if (directory) {
|
|
858
874
|
const candidate = join3(directory, "spacebus.json");
|
|
@@ -1463,6 +1479,8 @@ function formatDispatch(r) {
|
|
|
1463
1479
|
return `Replied to pending question in session ${r.sessionId} (${r.project}).`;
|
|
1464
1480
|
case "follow-up":
|
|
1465
1481
|
return `Follow-up prompt sent to session ${r.sessionId} (${r.project}).`;
|
|
1482
|
+
case "blocked":
|
|
1483
|
+
return `Blocked: session ${r.sessionId} (${r.project}) has a pending question (${r.requestId}) — no reply or prompt sent.`;
|
|
1466
1484
|
}
|
|
1467
1485
|
}
|
|
1468
1486
|
function dispatchMetadata(r) {
|
|
@@ -2314,6 +2332,9 @@ async function dispatchNew(baseUrl, credentials, projects, project, prompt, titl
|
|
|
2314
2332
|
return { ok: true, sessionId: session.id, project, directory };
|
|
2315
2333
|
}
|
|
2316
2334
|
function toDispatchArgs(input) {
|
|
2335
|
+
if (input.onPendingQuestion !== undefined && input.onPendingQuestion !== "question-reply" && input.onPendingQuestion !== "blocked") {
|
|
2336
|
+
return err(`space-bus: onPendingQuestion must be "question-reply" or "blocked", got ${JSON.stringify(input.onPendingQuestion)}`);
|
|
2337
|
+
}
|
|
2317
2338
|
if (input.sessionId !== undefined && input.sessionId === "") {
|
|
2318
2339
|
return err("space-bus: sessionId must be a non-empty string");
|
|
2319
2340
|
}
|
|
@@ -2325,7 +2346,8 @@ function toDispatchArgs(input) {
|
|
|
2325
2346
|
ok: true,
|
|
2326
2347
|
prompt: input.prompt,
|
|
2327
2348
|
title: input.title,
|
|
2328
|
-
project: input.project
|
|
2349
|
+
project: input.project,
|
|
2350
|
+
onPendingQuestion: input.onPendingQuestion
|
|
2329
2351
|
};
|
|
2330
2352
|
}
|
|
2331
2353
|
return {
|
|
@@ -2333,7 +2355,8 @@ function toDispatchArgs(input) {
|
|
|
2333
2355
|
prompt: input.prompt,
|
|
2334
2356
|
title: input.title,
|
|
2335
2357
|
sessionId: input.sessionId,
|
|
2336
|
-
project: input.project
|
|
2358
|
+
project: input.project,
|
|
2359
|
+
onPendingQuestion: input.onPendingQuestion
|
|
2337
2360
|
};
|
|
2338
2361
|
}
|
|
2339
2362
|
async function dispatch(args, opts) {
|
|
@@ -2366,7 +2389,7 @@ async function dispatch(args, opts) {
|
|
|
2366
2389
|
if (args.project && args.project !== project) {
|
|
2367
2390
|
return err(`space-bus: session ${args.sessionId} belongs to project "${project}", not "${args.project}" — refusing to steer the wrong session`);
|
|
2368
2391
|
}
|
|
2369
|
-
return steerSession(baseUrl, credentials, args.sessionId, args.prompt, directory, project);
|
|
2392
|
+
return steerSession(baseUrl, credentials, args.sessionId, args.prompt, directory, project, args.onPendingQuestion ?? "question-reply");
|
|
2370
2393
|
}
|
|
2371
2394
|
async function findSessionDirectory(baseUrl, credentials, projects, sessionId) {
|
|
2372
2395
|
for (const p of projects) {
|
|
@@ -2471,26 +2494,51 @@ async function status(sessionId, opts) {
|
|
|
2471
2494
|
resultAvailable: state === "complete"
|
|
2472
2495
|
};
|
|
2473
2496
|
}
|
|
2474
|
-
async function
|
|
2497
|
+
async function resolvePendingQuestionForSteer(baseUrl, credentials, directory, sessionId, onPendingQuestion) {
|
|
2475
2498
|
const questionsRes = await api(baseUrl, credentials, directory, "/question");
|
|
2476
|
-
if (questionsRes.res.ok) {
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
questions = questionListSchema.parse(JSON.parse(questionsRes.bodyText));
|
|
2480
|
-
} catch {
|
|
2481
|
-
questions = [];
|
|
2499
|
+
if (!questionsRes.res.ok) {
|
|
2500
|
+
if (onPendingQuestion === "blocked") {
|
|
2501
|
+
return err(`space-bus: could not verify pending-question state for session ${sessionId} (/question ${questionsRes.res.status}) — refusing to dispatch under the blocked policy`);
|
|
2482
2502
|
}
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2503
|
+
return { ok: true, pending: undefined };
|
|
2504
|
+
}
|
|
2505
|
+
let pendingList;
|
|
2506
|
+
try {
|
|
2507
|
+
pendingList = questionListSchema.parse(JSON.parse(questionsRes.bodyText));
|
|
2508
|
+
} catch (e) {
|
|
2509
|
+
if (onPendingQuestion === "blocked") {
|
|
2510
|
+
return err(`space-bus: could not parse pending-question state for session ${sessionId}: ${e.message} — refusing to dispatch under the blocked policy`);
|
|
2511
|
+
}
|
|
2512
|
+
return { ok: true, pending: undefined };
|
|
2513
|
+
}
|
|
2514
|
+
return {
|
|
2515
|
+
ok: true,
|
|
2516
|
+
pending: pendingList.find((q) => q.sessionID === sessionId)
|
|
2517
|
+
};
|
|
2518
|
+
}
|
|
2519
|
+
async function steerSession(baseUrl, credentials, sessionId, message, directory, project, onPendingQuestion) {
|
|
2520
|
+
const pendingRes = await resolvePendingQuestionForSteer(baseUrl, credentials, directory, sessionId, onPendingQuestion);
|
|
2521
|
+
if (!pendingRes.ok)
|
|
2522
|
+
return pendingRes;
|
|
2523
|
+
const { pending } = pendingRes;
|
|
2524
|
+
if (pending && onPendingQuestion === "blocked") {
|
|
2525
|
+
return {
|
|
2526
|
+
ok: true,
|
|
2527
|
+
sessionId,
|
|
2528
|
+
project,
|
|
2529
|
+
mode: "blocked",
|
|
2530
|
+
requestId: pending.id
|
|
2531
|
+
};
|
|
2532
|
+
}
|
|
2533
|
+
if (pending) {
|
|
2534
|
+
const replyRes = await api(baseUrl, credentials, directory, `/question/${encodeURIComponent(pending.id)}/reply`, {
|
|
2535
|
+
method: "POST",
|
|
2536
|
+
body: JSON.stringify({ answers: [[message]] })
|
|
2537
|
+
});
|
|
2538
|
+
if (!replyRes.res.ok) {
|
|
2539
|
+
return err(`space-bus: failed to reply to question ${pending.id} for session ${sessionId} (${replyRes.res.status}): ${replyRes.bodyText}`);
|
|
2493
2540
|
}
|
|
2541
|
+
return { ok: true, sessionId, project, mode: "question-reply" };
|
|
2494
2542
|
}
|
|
2495
2543
|
const promptRes = await api(baseUrl, credentials, directory, `/session/${encodeURIComponent(sessionId)}/prompt_async`, {
|
|
2496
2544
|
method: "POST",
|
package/dist/mcp.js
CHANGED
|
@@ -73,7 +73,11 @@ var messagePartSchema = z.looseObject({
|
|
|
73
73
|
text: z.string().optional()
|
|
74
74
|
});
|
|
75
75
|
var messageEnvelopeSchema = z.looseObject({
|
|
76
|
-
info: z.looseObject({
|
|
76
|
+
info: z.looseObject({
|
|
77
|
+
id: z.string().optional(),
|
|
78
|
+
role: z.string(),
|
|
79
|
+
time: z.looseObject({ created: z.number().optional() }).optional()
|
|
80
|
+
}),
|
|
77
81
|
parts: z.array(messagePartSchema)
|
|
78
82
|
});
|
|
79
83
|
var messageListSchema = z.array(messageEnvelopeSchema);
|
|
@@ -82,7 +86,13 @@ var pendingQuestionEntrySchema = z.looseObject({
|
|
|
82
86
|
sessionID: z.string(),
|
|
83
87
|
questions: z.array(z.looseObject({
|
|
84
88
|
question: z.string().optional(),
|
|
85
|
-
|
|
89
|
+
header: z.string().optional(),
|
|
90
|
+
multiple: z.boolean().optional(),
|
|
91
|
+
custom: z.boolean().optional(),
|
|
92
|
+
options: z.array(z.looseObject({
|
|
93
|
+
label: z.string().optional(),
|
|
94
|
+
description: z.string().optional()
|
|
95
|
+
})).optional()
|
|
86
96
|
})).optional()
|
|
87
97
|
});
|
|
88
98
|
var pendingQuestionListSchema = z.array(pendingQuestionEntrySchema);
|
|
@@ -843,17 +853,23 @@ var manifestSchema = z3.object({
|
|
|
843
853
|
function expandHome(path) {
|
|
844
854
|
return path.startsWith("~") ? join3(homedir3(), path.slice(1)) : path;
|
|
845
855
|
}
|
|
846
|
-
function
|
|
856
|
+
function resolveExplicitOverride(override, sourceLabel) {
|
|
857
|
+
if (override.includes("://")) {
|
|
858
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
859
|
+
}
|
|
860
|
+
const expanded = expandHome(override);
|
|
861
|
+
if (!expanded.startsWith("/")) {
|
|
862
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got: ${override})`);
|
|
863
|
+
}
|
|
864
|
+
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
865
|
+
}
|
|
866
|
+
function resolveRosterPath(directory, explicitOverride) {
|
|
867
|
+
if (explicitOverride) {
|
|
868
|
+
return resolveExplicitOverride(explicitOverride, "--config");
|
|
869
|
+
}
|
|
847
870
|
const override = process.env["SPACE_BUS_CONFIG"];
|
|
848
871
|
if (override) {
|
|
849
|
-
|
|
850
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
851
|
-
}
|
|
852
|
-
const expanded = expandHome(override);
|
|
853
|
-
if (!expanded.startsWith("/")) {
|
|
854
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got: ${override})`);
|
|
855
|
-
}
|
|
856
|
-
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
872
|
+
return resolveExplicitOverride(override, "SPACE_BUS_CONFIG");
|
|
857
873
|
}
|
|
858
874
|
if (directory) {
|
|
859
875
|
const candidate = join3(directory, "spacebus.json");
|
|
@@ -1676,6 +1692,9 @@ async function dispatchNew(baseUrl, credentials, projects, project, prompt, titl
|
|
|
1676
1692
|
return { ok: true, sessionId: session.id, project, directory };
|
|
1677
1693
|
}
|
|
1678
1694
|
function toDispatchArgs(input) {
|
|
1695
|
+
if (input.onPendingQuestion !== undefined && input.onPendingQuestion !== "question-reply" && input.onPendingQuestion !== "blocked") {
|
|
1696
|
+
return err(`space-bus: onPendingQuestion must be "question-reply" or "blocked", got ${JSON.stringify(input.onPendingQuestion)}`);
|
|
1697
|
+
}
|
|
1679
1698
|
if (input.sessionId !== undefined && input.sessionId === "") {
|
|
1680
1699
|
return err("space-bus: sessionId must be a non-empty string");
|
|
1681
1700
|
}
|
|
@@ -1687,7 +1706,8 @@ function toDispatchArgs(input) {
|
|
|
1687
1706
|
ok: true,
|
|
1688
1707
|
prompt: input.prompt,
|
|
1689
1708
|
title: input.title,
|
|
1690
|
-
project: input.project
|
|
1709
|
+
project: input.project,
|
|
1710
|
+
onPendingQuestion: input.onPendingQuestion
|
|
1691
1711
|
};
|
|
1692
1712
|
}
|
|
1693
1713
|
return {
|
|
@@ -1695,7 +1715,8 @@ function toDispatchArgs(input) {
|
|
|
1695
1715
|
prompt: input.prompt,
|
|
1696
1716
|
title: input.title,
|
|
1697
1717
|
sessionId: input.sessionId,
|
|
1698
|
-
project: input.project
|
|
1718
|
+
project: input.project,
|
|
1719
|
+
onPendingQuestion: input.onPendingQuestion
|
|
1699
1720
|
};
|
|
1700
1721
|
}
|
|
1701
1722
|
async function dispatch(args, opts) {
|
|
@@ -1728,7 +1749,7 @@ async function dispatch(args, opts) {
|
|
|
1728
1749
|
if (args.project && args.project !== project) {
|
|
1729
1750
|
return err(`space-bus: session ${args.sessionId} belongs to project "${project}", not "${args.project}" — refusing to steer the wrong session`);
|
|
1730
1751
|
}
|
|
1731
|
-
return steerSession(baseUrl, credentials, args.sessionId, args.prompt, directory, project);
|
|
1752
|
+
return steerSession(baseUrl, credentials, args.sessionId, args.prompt, directory, project, args.onPendingQuestion ?? "question-reply");
|
|
1732
1753
|
}
|
|
1733
1754
|
async function findSessionDirectory(baseUrl, credentials, projects, sessionId) {
|
|
1734
1755
|
for (const p of projects) {
|
|
@@ -1833,26 +1854,51 @@ async function status(sessionId, opts) {
|
|
|
1833
1854
|
resultAvailable: state === "complete"
|
|
1834
1855
|
};
|
|
1835
1856
|
}
|
|
1836
|
-
async function
|
|
1857
|
+
async function resolvePendingQuestionForSteer(baseUrl, credentials, directory, sessionId, onPendingQuestion) {
|
|
1837
1858
|
const questionsRes = await api(baseUrl, credentials, directory, "/question");
|
|
1838
|
-
if (questionsRes.res.ok) {
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
questions = questionListSchema.parse(JSON.parse(questionsRes.bodyText));
|
|
1842
|
-
} catch {
|
|
1843
|
-
questions = [];
|
|
1859
|
+
if (!questionsRes.res.ok) {
|
|
1860
|
+
if (onPendingQuestion === "blocked") {
|
|
1861
|
+
return err(`space-bus: could not verify pending-question state for session ${sessionId} (/question ${questionsRes.res.status}) — refusing to dispatch under the blocked policy`);
|
|
1844
1862
|
}
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1863
|
+
return { ok: true, pending: undefined };
|
|
1864
|
+
}
|
|
1865
|
+
let pendingList;
|
|
1866
|
+
try {
|
|
1867
|
+
pendingList = questionListSchema.parse(JSON.parse(questionsRes.bodyText));
|
|
1868
|
+
} catch (e) {
|
|
1869
|
+
if (onPendingQuestion === "blocked") {
|
|
1870
|
+
return err(`space-bus: could not parse pending-question state for session ${sessionId}: ${e.message} — refusing to dispatch under the blocked policy`);
|
|
1871
|
+
}
|
|
1872
|
+
return { ok: true, pending: undefined };
|
|
1873
|
+
}
|
|
1874
|
+
return {
|
|
1875
|
+
ok: true,
|
|
1876
|
+
pending: pendingList.find((q) => q.sessionID === sessionId)
|
|
1877
|
+
};
|
|
1878
|
+
}
|
|
1879
|
+
async function steerSession(baseUrl, credentials, sessionId, message, directory, project, onPendingQuestion) {
|
|
1880
|
+
const pendingRes = await resolvePendingQuestionForSteer(baseUrl, credentials, directory, sessionId, onPendingQuestion);
|
|
1881
|
+
if (!pendingRes.ok)
|
|
1882
|
+
return pendingRes;
|
|
1883
|
+
const { pending } = pendingRes;
|
|
1884
|
+
if (pending && onPendingQuestion === "blocked") {
|
|
1885
|
+
return {
|
|
1886
|
+
ok: true,
|
|
1887
|
+
sessionId,
|
|
1888
|
+
project,
|
|
1889
|
+
mode: "blocked",
|
|
1890
|
+
requestId: pending.id
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
if (pending) {
|
|
1894
|
+
const replyRes = await api(baseUrl, credentials, directory, `/question/${encodeURIComponent(pending.id)}/reply`, {
|
|
1895
|
+
method: "POST",
|
|
1896
|
+
body: JSON.stringify({ answers: [[message]] })
|
|
1897
|
+
});
|
|
1898
|
+
if (!replyRes.res.ok) {
|
|
1899
|
+
return err(`space-bus: failed to reply to question ${pending.id} for session ${sessionId} (${replyRes.res.status}): ${replyRes.bodyText}`);
|
|
1855
1900
|
}
|
|
1901
|
+
return { ok: true, sessionId, project, mode: "question-reply" };
|
|
1856
1902
|
}
|
|
1857
1903
|
const promptRes = await api(baseUrl, credentials, directory, `/session/${encodeURIComponent(sessionId)}/prompt_async`, {
|
|
1858
1904
|
method: "POST",
|
|
@@ -2054,6 +2100,8 @@ function formatDispatch(r) {
|
|
|
2054
2100
|
return `Replied to pending question in session ${r.sessionId} (${r.project}).`;
|
|
2055
2101
|
case "follow-up":
|
|
2056
2102
|
return `Follow-up prompt sent to session ${r.sessionId} (${r.project}).`;
|
|
2103
|
+
case "blocked":
|
|
2104
|
+
return `Blocked: session ${r.sessionId} (${r.project}) has a pending question (${r.requestId}) — no reply or prompt sent.`;
|
|
2057
2105
|
}
|
|
2058
2106
|
}
|
|
2059
2107
|
function dispatchMetadata(r) {
|
|
@@ -2904,7 +2952,7 @@ async function mcpLoadContext(rosterName, ensure = ensureServer) {
|
|
|
2904
2952
|
}
|
|
2905
2953
|
throw ambientError;
|
|
2906
2954
|
}
|
|
2907
|
-
var version = "0.
|
|
2955
|
+
var version = "0.14.0";
|
|
2908
2956
|
var server = new McpServer({
|
|
2909
2957
|
name: "space-bus",
|
|
2910
2958
|
version
|
package/dist/registry-entry.js
CHANGED
|
@@ -72,7 +72,11 @@ var messagePartSchema = z.looseObject({
|
|
|
72
72
|
text: z.string().optional()
|
|
73
73
|
});
|
|
74
74
|
var messageEnvelopeSchema = z.looseObject({
|
|
75
|
-
info: z.looseObject({
|
|
75
|
+
info: z.looseObject({
|
|
76
|
+
id: z.string().optional(),
|
|
77
|
+
role: z.string(),
|
|
78
|
+
time: z.looseObject({ created: z.number().optional() }).optional()
|
|
79
|
+
}),
|
|
76
80
|
parts: z.array(messagePartSchema)
|
|
77
81
|
});
|
|
78
82
|
var messageListSchema = z.array(messageEnvelopeSchema);
|
|
@@ -81,7 +85,13 @@ var pendingQuestionEntrySchema = z.looseObject({
|
|
|
81
85
|
sessionID: z.string(),
|
|
82
86
|
questions: z.array(z.looseObject({
|
|
83
87
|
question: z.string().optional(),
|
|
84
|
-
|
|
88
|
+
header: z.string().optional(),
|
|
89
|
+
multiple: z.boolean().optional(),
|
|
90
|
+
custom: z.boolean().optional(),
|
|
91
|
+
options: z.array(z.looseObject({
|
|
92
|
+
label: z.string().optional(),
|
|
93
|
+
description: z.string().optional()
|
|
94
|
+
})).optional()
|
|
85
95
|
})).optional()
|
|
86
96
|
});
|
|
87
97
|
var pendingQuestionListSchema = z.array(pendingQuestionEntrySchema);
|
|
@@ -842,17 +852,23 @@ var manifestSchema = z3.object({
|
|
|
842
852
|
function expandHome(path) {
|
|
843
853
|
return path.startsWith("~") ? join3(homedir3(), path.slice(1)) : path;
|
|
844
854
|
}
|
|
845
|
-
function
|
|
855
|
+
function resolveExplicitOverride(override, sourceLabel) {
|
|
856
|
+
if (override.includes("://")) {
|
|
857
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
858
|
+
}
|
|
859
|
+
const expanded = expandHome(override);
|
|
860
|
+
if (!expanded.startsWith("/")) {
|
|
861
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got: ${override})`);
|
|
862
|
+
}
|
|
863
|
+
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
864
|
+
}
|
|
865
|
+
function resolveRosterPath(directory, explicitOverride) {
|
|
866
|
+
if (explicitOverride) {
|
|
867
|
+
return resolveExplicitOverride(explicitOverride, "--config");
|
|
868
|
+
}
|
|
846
869
|
const override = process.env["SPACE_BUS_CONFIG"];
|
|
847
870
|
if (override) {
|
|
848
|
-
|
|
849
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
850
|
-
}
|
|
851
|
-
const expanded = expandHome(override);
|
|
852
|
-
if (!expanded.startsWith("/")) {
|
|
853
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got: ${override})`);
|
|
854
|
-
}
|
|
855
|
-
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
871
|
+
return resolveExplicitOverride(override, "SPACE_BUS_CONFIG");
|
|
856
872
|
}
|
|
857
873
|
if (directory) {
|
|
858
874
|
const candidate = join3(directory, "spacebus.json");
|
package/dist/server.js
CHANGED
|
@@ -72,7 +72,11 @@ var messagePartSchema = z.looseObject({
|
|
|
72
72
|
text: z.string().optional()
|
|
73
73
|
});
|
|
74
74
|
var messageEnvelopeSchema = z.looseObject({
|
|
75
|
-
info: z.looseObject({
|
|
75
|
+
info: z.looseObject({
|
|
76
|
+
id: z.string().optional(),
|
|
77
|
+
role: z.string(),
|
|
78
|
+
time: z.looseObject({ created: z.number().optional() }).optional()
|
|
79
|
+
}),
|
|
76
80
|
parts: z.array(messagePartSchema)
|
|
77
81
|
});
|
|
78
82
|
var messageListSchema = z.array(messageEnvelopeSchema);
|
|
@@ -81,7 +85,13 @@ var pendingQuestionEntrySchema = z.looseObject({
|
|
|
81
85
|
sessionID: z.string(),
|
|
82
86
|
questions: z.array(z.looseObject({
|
|
83
87
|
question: z.string().optional(),
|
|
84
|
-
|
|
88
|
+
header: z.string().optional(),
|
|
89
|
+
multiple: z.boolean().optional(),
|
|
90
|
+
custom: z.boolean().optional(),
|
|
91
|
+
options: z.array(z.looseObject({
|
|
92
|
+
label: z.string().optional(),
|
|
93
|
+
description: z.string().optional()
|
|
94
|
+
})).optional()
|
|
85
95
|
})).optional()
|
|
86
96
|
});
|
|
87
97
|
var pendingQuestionListSchema = z.array(pendingQuestionEntrySchema);
|
|
@@ -842,17 +852,23 @@ var manifestSchema = z3.object({
|
|
|
842
852
|
function expandHome(path) {
|
|
843
853
|
return path.startsWith("~") ? join3(homedir3(), path.slice(1)) : path;
|
|
844
854
|
}
|
|
845
|
-
function
|
|
855
|
+
function resolveExplicitOverride(override, sourceLabel) {
|
|
856
|
+
if (override.includes("://")) {
|
|
857
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
858
|
+
}
|
|
859
|
+
const expanded = expandHome(override);
|
|
860
|
+
if (!expanded.startsWith("/")) {
|
|
861
|
+
throw new Error(`space-bus: ${sourceLabel} must be an absolute path or start with ~ (got: ${override})`);
|
|
862
|
+
}
|
|
863
|
+
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
864
|
+
}
|
|
865
|
+
function resolveRosterPath(directory, explicitOverride) {
|
|
866
|
+
if (explicitOverride) {
|
|
867
|
+
return resolveExplicitOverride(explicitOverride, "--config");
|
|
868
|
+
}
|
|
846
869
|
const override = process.env["SPACE_BUS_CONFIG"];
|
|
847
870
|
if (override) {
|
|
848
|
-
|
|
849
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got a URL: ${override})`);
|
|
850
|
-
}
|
|
851
|
-
const expanded = expandHome(override);
|
|
852
|
-
if (!expanded.startsWith("/")) {
|
|
853
|
-
throw new Error(`space-bus: SPACE_BUS_CONFIG must be an absolute path or start with ~ (got: ${override})`);
|
|
854
|
-
}
|
|
855
|
-
return existsSync(expanded) ? realpathSync2(expanded) : expanded;
|
|
871
|
+
return resolveExplicitOverride(override, "SPACE_BUS_CONFIG");
|
|
856
872
|
}
|
|
857
873
|
if (directory) {
|
|
858
874
|
const candidate = join3(directory, "spacebus.json");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fro.bot/space-bus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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",
|