@oqtopus-team/pi-qdash 0.1.10-beta.11 → 0.1.10-beta.12

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.
@@ -28,3 +28,26 @@ export function toTextToolResult(text: string, data: unknown, details: Record<st
28
28
  details: { ...details, data: safeData },
29
29
  };
30
30
  }
31
+
32
+ /**
33
+ * Result of a tool that fetched a figure: the text summary plus, for an image,
34
+ * the image itself as model-visible content. Without the image block a
35
+ * vision model only reads that a figure exists; with it, it can judge the
36
+ * curve. Non-image figures (JSON) keep a text-only result.
37
+ */
38
+ export function toFigureToolResult(
39
+ text: string,
40
+ figure: { base64?: string; mediaType: string },
41
+ data: unknown,
42
+ details: Record<string, unknown> = {},
43
+ ) {
44
+ const result = toTextToolResult(text, data, details);
45
+ if (!figure.base64 || !figure.mediaType.startsWith("image/")) return result;
46
+ return {
47
+ ...result,
48
+ content: [
49
+ ...result.content,
50
+ { type: "image" as const, data: figure.base64, mimeType: figure.mediaType },
51
+ ],
52
+ };
53
+ }
@@ -21,7 +21,7 @@ import { forumDetailComponent, forumDetailLines, forumListLines, forumPostTitle,
21
21
  import { investigationContextSummary, validateInvestigationContext, type TimeseriesInvestigationContext } from "./lib/investigation-context.js";
22
22
  import { qdashObjectLinks, qdashWebBaseUrl, qdashWebUrl, safeConfig, withQDashLinks } from "./lib/links.js";
23
23
  import { arrayFromPayload, compactItems, firstNumber, firstString, formatItem, payloadTotal, statusIcon } from "./lib/payload.js";
24
- import { toTextToolResult, toToolResult } from "./lib/results.js";
24
+ import { toFigureToolResult, toTextToolResult, toToolResult } from "./lib/results.js";
25
25
  import { ansi, boxLinesToWidth, boxed, formatNumber, textComponent } from "./lib/render.js";
26
26
  import { plotSeriesLines, timeseriesPlotComponent, timeseriesPoints } from "./lib/timeseries-plot.js";
27
27
  import { installQDashWriteGate } from "./lib/write-gate.js";
@@ -2543,7 +2543,7 @@ export default function qdashExtension(pi: ExtensionAPI) {
2543
2543
  const details: FigureDetails = { tool: "qdash_recent_calibration_figure", taskId, path: file.path ?? "", mediaType, sizeBytes: bytes.byteLength, figurePaths: file.figurePaths ?? [], jsonFigurePaths: file.jsonFigurePaths ?? [] };
2544
2544
  if (mediaType.startsWith("image/")) details.base64 = bytes.toString("base64");
2545
2545
  else details.text = bytes.toString("utf8");
2546
- return toTextToolResult(figureResultText(details), { task, selectedPath: details.path }, details);
2546
+ return toFigureToolResult(figureResultText(details), details, { task, selectedPath: details.path }, details);
2547
2547
  },
2548
2548
  renderResult(result, _options, theme) {
2549
2549
  return figureComponent(result.details as unknown as FigureDetails, theme);
@@ -2563,7 +2563,7 @@ export default function qdashExtension(pi: ExtensionAPI) {
2563
2563
  async execute(_toolCallId, params: { profile?: string; configPath?: string; useEnv?: boolean; path: string }) {
2564
2564
  const client = await makeClient(params);
2565
2565
  const details = await fetchFigureDetails(client, params.path);
2566
- return toTextToolResult(figureResultText(details), { path: params.path }, details);
2566
+ return toFigureToolResult(figureResultText(details), details, { path: params.path }, details);
2567
2567
  },
2568
2568
  renderResult(result, _options, theme) {
2569
2569
  return figureComponent(result.details as unknown as FigureDetails, theme);
@@ -2600,7 +2600,7 @@ export default function qdashExtension(pi: ExtensionAPI) {
2600
2600
  };
2601
2601
  if (mediaType.startsWith("image/")) details.base64 = bytes.toString("base64");
2602
2602
  else details.text = bytes.toString("utf8");
2603
- return toTextToolResult(figureResultText(details), { taskId: params.taskId, figurePaths: details.figurePaths, jsonFigurePaths: details.jsonFigurePaths, selectedPath: details.path }, details);
2603
+ return toFigureToolResult(figureResultText(details), details, { taskId: params.taskId, figurePaths: details.figurePaths, jsonFigurePaths: details.jsonFigurePaths, selectedPath: details.path }, details);
2604
2604
  } catch (error) {
2605
2605
  return toTextToolResult(boxed("QDash Task Figures", [
2606
2606
  `task ${params.taskId}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oqtopus-team/pi-qdash",
3
- "version": "0.1.10-beta.11",
3
+ "version": "0.1.10-beta.12",
4
4
  "description": "Pi extension for querying QDash via @oqtopus-team/qdash-client",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",