@cluesmith/multisage 1.0.2 → 1.0.4
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/dist/index.js +44 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -80,6 +80,11 @@ async function handleApiError(response) {
|
|
|
80
80
|
"Server error. Please try again later.",
|
|
81
81
|
"internal_error"
|
|
82
82
|
);
|
|
83
|
+
case 524:
|
|
84
|
+
return new MultisageError(
|
|
85
|
+
"Request timed out. The query took too long to complete. Try a simpler question or try again later.",
|
|
86
|
+
"timeout"
|
|
87
|
+
);
|
|
83
88
|
default:
|
|
84
89
|
return new MultisageError(
|
|
85
90
|
`Unexpected error (HTTP ${status}). Please try again later.`,
|
|
@@ -173,23 +178,51 @@ async function queryMultisage(options) {
|
|
|
173
178
|
}
|
|
174
179
|
|
|
175
180
|
// src/format.ts
|
|
176
|
-
function
|
|
181
|
+
function hasStages(response) {
|
|
177
182
|
return "stages" in response && response.stages != null;
|
|
178
183
|
}
|
|
184
|
+
function isFullResponse(response) {
|
|
185
|
+
return "expertPrompt" in response;
|
|
186
|
+
}
|
|
179
187
|
function formatDefault(response) {
|
|
180
188
|
return response.answer;
|
|
181
189
|
}
|
|
190
|
+
function formatStagesMarkdown(response) {
|
|
191
|
+
if (!hasStages(response)) {
|
|
192
|
+
return response.answer;
|
|
193
|
+
}
|
|
194
|
+
const sections = [];
|
|
195
|
+
if (response.stages.quickAnswer) {
|
|
196
|
+
sections.push(`# Quick Answer
|
|
197
|
+
|
|
198
|
+
${response.stages.quickAnswer}`);
|
|
199
|
+
}
|
|
200
|
+
if (response.stages.synthesis) {
|
|
201
|
+
sections.push(`# Synthesis
|
|
202
|
+
|
|
203
|
+
${response.stages.synthesis}`);
|
|
204
|
+
}
|
|
205
|
+
if (response.stages.debate) {
|
|
206
|
+
sections.push(`# Debate
|
|
207
|
+
|
|
208
|
+
${response.stages.debate}`);
|
|
209
|
+
}
|
|
210
|
+
return sections.join("\n\n---\n\n");
|
|
211
|
+
}
|
|
182
212
|
function formatFullMarkdown(response) {
|
|
183
213
|
if (!isFullResponse(response)) {
|
|
184
|
-
return
|
|
185
|
-
|
|
186
|
-
${response.answer}`;
|
|
214
|
+
return formatStagesMarkdown(response);
|
|
187
215
|
}
|
|
188
216
|
const sections = [];
|
|
189
217
|
if (response.stages.quickAnswer) {
|
|
190
218
|
sections.push(`# Quick Answer
|
|
191
219
|
|
|
192
220
|
${response.stages.quickAnswer}`);
|
|
221
|
+
}
|
|
222
|
+
if (response.expertPrompt) {
|
|
223
|
+
sections.push(`# Expert Prompt
|
|
224
|
+
|
|
225
|
+
${response.expertPrompt}`);
|
|
193
226
|
}
|
|
194
227
|
const experts = response.experts;
|
|
195
228
|
if (experts.length > 0) {
|
|
@@ -239,10 +272,10 @@ function displayName(name) {
|
|
|
239
272
|
}
|
|
240
273
|
|
|
241
274
|
// src/index.ts
|
|
242
|
-
config();
|
|
275
|
+
config({ quiet: true });
|
|
243
276
|
var DEFAULT_API_URL = "https://multisage.ai";
|
|
244
277
|
var program = new Command();
|
|
245
|
-
program.name("multisage").description("Query Multisage from your terminal").version("1.0.
|
|
278
|
+
program.name("multisage").description("Query Multisage from your terminal").version("1.0.4").argument("[question]", "The question to ask").option("-k, --api-key <key>", "API key (overrides MULTISAGE_API_KEY env var)").option("-u, --api-url <url>", "Base URL for API", DEFAULT_API_URL).option("--final-only", "Only show the final synthesis (no stages)", false).option("-f, --full", "Include expert prompt and raw expert responses", false).option("-j, --json", "Output as structured JSON", false).option("-q, --quiet", "Suppress progress indicator", false).action(async (question, options) => {
|
|
246
279
|
if (!question) {
|
|
247
280
|
if (process.stdin.isTTY) {
|
|
248
281
|
program.help();
|
|
@@ -283,11 +316,12 @@ program.name("multisage").description("Query Multisage from your terminal").vers
|
|
|
283
316
|
};
|
|
284
317
|
process.on("SIGINT", sigintHandler);
|
|
285
318
|
try {
|
|
319
|
+
const detail = options.full ? "full" : options.finalOnly ? void 0 : "stages";
|
|
286
320
|
const response = await queryMultisage({
|
|
287
321
|
question,
|
|
288
322
|
apiKey,
|
|
289
323
|
apiUrl: options.apiUrl,
|
|
290
|
-
detail
|
|
324
|
+
detail
|
|
291
325
|
});
|
|
292
326
|
if (spinner) spinner.stop();
|
|
293
327
|
let output;
|
|
@@ -295,8 +329,10 @@ program.name("multisage").description("Query Multisage from your terminal").vers
|
|
|
295
329
|
output = formatJson(response);
|
|
296
330
|
} else if (options.full) {
|
|
297
331
|
output = formatFullMarkdown(response);
|
|
298
|
-
} else {
|
|
332
|
+
} else if (options.finalOnly) {
|
|
299
333
|
output = formatDefault(response);
|
|
334
|
+
} else {
|
|
335
|
+
output = formatStagesMarkdown(response);
|
|
300
336
|
}
|
|
301
337
|
process.stdout.write(output + "\n");
|
|
302
338
|
} catch (err) {
|