@cluesmith/multisage 1.0.1 → 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.
Files changed (2) hide show
  1. package/dist/index.js +45 -7
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
+ import { config } from "dotenv";
4
5
  import { Command } from "commander";
5
6
  import ora from "ora";
6
7
 
@@ -79,6 +80,11 @@ async function handleApiError(response) {
79
80
  "Server error. Please try again later.",
80
81
  "internal_error"
81
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
+ );
82
88
  default:
83
89
  return new MultisageError(
84
90
  `Unexpected error (HTTP ${status}). Please try again later.`,
@@ -172,23 +178,51 @@ async function queryMultisage(options) {
172
178
  }
173
179
 
174
180
  // src/format.ts
175
- function isFullResponse(response) {
181
+ function hasStages(response) {
176
182
  return "stages" in response && response.stages != null;
177
183
  }
184
+ function isFullResponse(response) {
185
+ return "expertPrompt" in response;
186
+ }
178
187
  function formatDefault(response) {
179
188
  return response.answer;
180
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
+ }
181
212
  function formatFullMarkdown(response) {
182
213
  if (!isFullResponse(response)) {
183
- return `# Answer
184
-
185
- ${response.answer}`;
214
+ return formatStagesMarkdown(response);
186
215
  }
187
216
  const sections = [];
188
217
  if (response.stages.quickAnswer) {
189
218
  sections.push(`# Quick Answer
190
219
 
191
220
  ${response.stages.quickAnswer}`);
221
+ }
222
+ if (response.expertPrompt) {
223
+ sections.push(`# Expert Prompt
224
+
225
+ ${response.expertPrompt}`);
192
226
  }
193
227
  const experts = response.experts;
194
228
  if (experts.length > 0) {
@@ -238,9 +272,10 @@ function displayName(name) {
238
272
  }
239
273
 
240
274
  // src/index.ts
275
+ config({ quiet: true });
241
276
  var DEFAULT_API_URL = "https://multisage.ai";
242
277
  var program = new Command();
243
- program.name("multisage").description("Query Multisage from your terminal").version("1.0.1").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("-f, --full", "Include all stages and expert details", false).option("-j, --json", "Output as structured JSON", false).option("-q, --quiet", "Suppress progress indicator", false).action(async (question, options) => {
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) => {
244
279
  if (!question) {
245
280
  if (process.stdin.isTTY) {
246
281
  program.help();
@@ -281,11 +316,12 @@ program.name("multisage").description("Query Multisage from your terminal").vers
281
316
  };
282
317
  process.on("SIGINT", sigintHandler);
283
318
  try {
319
+ const detail = options.full ? "full" : options.finalOnly ? void 0 : "stages";
284
320
  const response = await queryMultisage({
285
321
  question,
286
322
  apiKey,
287
323
  apiUrl: options.apiUrl,
288
- detail: options.full ? "full" : void 0
324
+ detail
289
325
  });
290
326
  if (spinner) spinner.stop();
291
327
  let output;
@@ -293,8 +329,10 @@ program.name("multisage").description("Query Multisage from your terminal").vers
293
329
  output = formatJson(response);
294
330
  } else if (options.full) {
295
331
  output = formatFullMarkdown(response);
296
- } else {
332
+ } else if (options.finalOnly) {
297
333
  output = formatDefault(response);
334
+ } else {
335
+ output = formatStagesMarkdown(response);
298
336
  }
299
337
  process.stdout.write(output + "\n");
300
338
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cluesmith/multisage",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "CLI client for Multisage — ask questions from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,6 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "commander": "^12.1.0",
22
+ "dotenv": "^17.3.1",
22
23
  "ora": "^8.1.1"
23
24
  },
24
25
  "devDependencies": {