flowstack-sdk 0.2.2 → 0.2.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.mjs CHANGED
@@ -269,7 +269,25 @@ async function executeQueryWithConfig(credentials, query, workspaceId, options,
269
269
  })
270
270
  });
271
271
  if (!response.ok) {
272
- throw new Error(`Query failed: ${response.statusText}`);
272
+ let message = response.statusText || "request failed";
273
+ let code;
274
+ let body;
275
+ try {
276
+ body = await response.clone().json();
277
+ const payload = body && typeof body === "object" && "detail" in body && typeof body.detail === "object" ? body.detail : body;
278
+ if (payload && typeof payload === "object") {
279
+ code = payload.code;
280
+ message = payload.error || payload.message || payload.detail || message;
281
+ } else if (typeof payload === "string") {
282
+ message = payload;
283
+ }
284
+ } catch {
285
+ }
286
+ const err = new Error(`Query failed: ${message}`);
287
+ err.status = response.status;
288
+ err.code = code;
289
+ err.body = body;
290
+ throw err;
273
291
  }
274
292
  return response;
275
293
  }
@@ -2985,6 +3003,11 @@ function normalizeEventType(type) {
2985
3003
  "progress": "progress",
2986
3004
  "step": "progress",
2987
3005
  // Step-based progress alias
3006
+ // Build pipeline stage markers (harness emits {type:"stage", name:"plan"|…}).
3007
+ // Without this they fell through to 'content' and were dropped, so the build
3008
+ // UI's stage bar never advanced. useAgent's `case 'stage'` maps them to the
3009
+ // running tool call's agentResponse as `[<tool>] stage: <name>`.
3010
+ "stage": "stage",
2988
3011
  // Billing
2989
3012
  "credit_status": "credit_status",
2990
3013
  "credits": "credit_status",
@@ -3998,6 +4021,39 @@ ${prompt}`;
3998
4021
  }
3999
4022
  }
4000
4023
  break;
4024
+ // ── BUILD PIPELINE STAGE MARKERS ─────────────────────────────
4025
+ // The build harness emits {type:"stage", name:"plan"|"style"|
4026
+ // "build"|"verify"|"publish"} as the app progresses. Surface each
4027
+ // as a `[<tool>] stage: <name>` line on the running build tool's
4028
+ // agentResponse so the Casino build UI's stage bar can advance.
4029
+ // Without this these events fell through to 'content' and were
4030
+ // dropped, leaving the bar stuck on "Building…".
4031
+ // (normalizeEvent maps the event's `name` field onto `tool`.)
4032
+ case "stage": {
4033
+ const stageName = event.tool || event.data?.name;
4034
+ if (stageName && currentToolCalls.length > 0) {
4035
+ let idx = -1;
4036
+ for (let i = currentToolCalls.length - 1; i >= 0; i--) {
4037
+ if (currentToolCalls[i].status === "running") {
4038
+ idx = i;
4039
+ break;
4040
+ }
4041
+ }
4042
+ if (idx >= 0) {
4043
+ const marker = `[${currentToolCalls[idx].name}] stage: ${stageName}`;
4044
+ const prev = currentToolCalls[idx].agentResponse || "";
4045
+ if (!prev.endsWith(marker)) {
4046
+ currentToolCalls[idx] = {
4047
+ ...currentToolCalls[idx],
4048
+ agentResponse: prev + (prev.length > 0 ? "\n" : "") + marker
4049
+ };
4050
+ setToolCalls([...currentToolCalls]);
4051
+ updateMessage(assistantId, { toolCalls: [...currentToolCalls] });
4052
+ }
4053
+ }
4054
+ }
4055
+ break;
4056
+ }
4001
4057
  // ── VISUALIZATIONS ─────────────────────────────────────────
4002
4058
  case "visualization":
4003
4059
  if (event.data) {
@@ -7090,7 +7146,7 @@ function useAutomations() {
7090
7146
  return;
7091
7147
  }
7092
7148
  const data = await res.json();
7093
- setAutomations(data.automations ?? []);
7149
+ setAutomations(Array.isArray(data) ? data : data.automations ?? []);
7094
7150
  } catch (e) {
7095
7151
  setError(e.message || "Failed to load automations");
7096
7152
  } finally {
@@ -7189,7 +7245,7 @@ function useAutomations() {
7189
7245
  const res = await fetch(url, { headers: headers() });
7190
7246
  if (!res.ok) return [];
7191
7247
  const data = await res.json();
7192
- return data.runs ?? [];
7248
+ return Array.isArray(data) ? data : data.runs ?? [];
7193
7249
  } catch {
7194
7250
  return [];
7195
7251
  }
@@ -8735,7 +8791,11 @@ function MermaidDiagram({ code }) {
8735
8791
  let cancelled = false;
8736
8792
  async function render() {
8737
8793
  try {
8738
- const mermaid = (await import('mermaid')).default;
8794
+ const mermaidPkg = "mermaid";
8795
+ const mermaid = (await import(
8796
+ /* @vite-ignore */
8797
+ mermaidPkg
8798
+ )).default;
8739
8799
  if (!mermaidInitialized) {
8740
8800
  mermaid.initialize({
8741
8801
  startOnLoad: false,