@magemetrics/core 0.6.0 → 0.7.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/dist/index.d.ts CHANGED
@@ -448,6 +448,7 @@ export declare const getPublicApiClient: (apiUrl: string, apiKey: string) => Cli
448
448
  declare const HEADER_SP_TOKEN: "sp-access-token";
449
449
 
450
450
  declare const inputSchema: z.ZodObject<{
451
+ rawRequest: z.ZodString;
451
452
  userRequest: z.ZodString;
452
453
  isNewAnalysisGoal: z.ZodBoolean;
453
454
  responseType: z.ZodEnum<{
@@ -490,6 +491,18 @@ declare const inputSchema_7: z.ZodObject<{
490
491
  query: z.ZodString;
491
492
  }, z.core.$strip>;
492
493
 
494
+ declare const inputSchema_8: z.ZodObject<{
495
+ questions: z.ZodArray<z.ZodObject<{
496
+ question: z.ZodString;
497
+ header: z.ZodString;
498
+ multiSelect: z.ZodBoolean;
499
+ options: z.ZodArray<z.ZodObject<{
500
+ label: z.ZodString;
501
+ description: z.ZodString;
502
+ }, z.core.$strip>>;
503
+ }, z.core.$strip>>;
504
+ }, z.core.$strip>;
505
+
493
506
  declare type InternalApiClient = Simplify<Client<NoAuthPaths, `${string}/${string}`>>;
494
507
 
495
508
  export declare class MageMetricsChatTransport extends DefaultChatTransport<MMChatUIMessage> {
@@ -787,6 +800,7 @@ declare type MMUiTools = {
787
800
  getAvailableTables: UiTool_5;
788
801
  getAvailableColumnsForTable: UiTool_6;
789
802
  webSearch: UiTool_7;
803
+ askUserQuestion: UiTool_8;
790
804
  };
791
805
 
792
806
  declare type NoAuthPaths = Simplify<{
@@ -1569,6 +1583,8 @@ declare interface operations {
1569
1583
  friendliness_score?: number;
1570
1584
  friendliness_score_reason?: string;
1571
1585
  flow_data_id: number;
1586
+ output_dataset?: string;
1587
+ sql?: string;
1572
1588
  };
1573
1589
  };
1574
1590
  };
@@ -4452,6 +4468,17 @@ declare const QuickActionsSchema: z.ZodArray<z.ZodObject<{
4452
4468
  explanation: z.ZodString;
4453
4469
  }, z.core.$strip>>;
4454
4470
 
4471
+ declare const RedactedAskUserQuestionResponse: z.ZodObject<{
4472
+ tool: z.ZodDefault<z.ZodLiteral<"askUserQuestion">>;
4473
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
4474
+ status: z.ZodLiteral<"success">;
4475
+ answers: z.ZodRecord<z.ZodString, z.ZodString>;
4476
+ }, z.core.$strip>, z.ZodObject<{
4477
+ status: z.ZodLiteral<"error">;
4478
+ message: z.ZodString;
4479
+ }, z.core.$strip>], "status">;
4480
+ }, z.core.$strip>;
4481
+
4455
4482
  declare const redactedOutputSchema: z.ZodObject<{
4456
4483
  tool: z.ZodLiteral<"generateDataReport">;
4457
4484
  result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -4609,6 +4636,8 @@ declare type UiTool_6 = InferUITool<Tool<z.infer<typeof inputSchema_6>, z.infer<
4609
4636
 
4610
4637
  declare type UiTool_7 = InferUITool<Tool<z.infer<typeof inputSchema_7>, z.infer<typeof redactedOutputSchema_6>>>;
4611
4638
 
4639
+ declare type UiTool_8 = InferUITool<Tool<z.infer<typeof inputSchema_8>, z.infer<typeof RedactedAskUserQuestionResponse>>>;
4640
+
4612
4641
  declare const UpdateCanvasSchema: z.ZodObject<{
4613
4642
  id: z.ZodUUID;
4614
4643
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ var addApiKeyHeader = (apiKey) => {
57
57
 
58
58
  // package.json
59
59
  var package_default = {
60
- version: "0.6.0"};
60
+ version: "0.7.0"};
61
61
 
62
62
  // src/core/MageMetricsEventEmitter.ts
63
63
  var MageMetricsEventEmitter = class {
@@ -151,7 +151,7 @@ var hashString = (value) => {
151
151
  return Array.from(hash).map((b) => b.toString(16).padStart(2, "0")).join("");
152
152
  };
153
153
 
154
- // ../../node_modules/.pnpm/@asteasolutions+zod-to-openapi@8.1.0_zod@4.1.13/node_modules/@asteasolutions/zod-to-openapi/dist/index.mjs
154
+ // ../../node_modules/.pnpm/@asteasolutions+zod-to-openapi@8.1.0_zod@4.2.1/node_modules/@asteasolutions/zod-to-openapi/dist/index.mjs
155
155
  function __rest(s, e) {
156
156
  var t = {};
157
157
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -1144,6 +1144,9 @@ var ReportExplainabilitySchema = z.object({
1144
1144
  var FrontendReportExplainabilitySchema = ReportExplainabilitySchema.omit({
1145
1145
  id: true,
1146
1146
  created_at: true
1147
+ }).extend({
1148
+ output_dataset: z.string().optional(),
1149
+ sql: z.string().optional()
1147
1150
  });
1148
1151
 
1149
1152
  // ../shared/dist/src/endpoints/companion/flows.routes.js
@@ -3127,13 +3130,28 @@ var toSearchParams = ({ cursor, filters, sorting, limit }) => {
3127
3130
  }
3128
3131
  return params;
3129
3132
  };
3133
+ var isToolResultMessage = (message) => {
3134
+ if (message.role !== "assistant") {
3135
+ return false;
3136
+ }
3137
+ return message.parts.some(
3138
+ (part) => part.type.startsWith("tool-") && "state" in part && part.state === "output-available"
3139
+ );
3140
+ };
3130
3141
  var MageMetricsChatTransport = class extends DefaultChatTransport {
3131
3142
  constructor(apiUrl, flowId, options) {
3132
3143
  super({
3133
3144
  ...options,
3134
3145
  api: `${apiUrl}/api/v1/chat/${flowId}`,
3135
3146
  prepareSendMessagesRequest({ messages, id: chatId }) {
3136
- return { body: { message: messages.at(-1), id: chatId } };
3147
+ const lastMessage = messages.at(-1);
3148
+ if (lastMessage && isToolResultMessage(lastMessage)) {
3149
+ lastMessage.metadata = {
3150
+ ...typeof lastMessage.metadata === "object" ? lastMessage.metadata : void 0,
3151
+ isFrontendToolSubmission: true
3152
+ };
3153
+ }
3154
+ return { body: { message: lastMessage, id: chatId } };
3137
3155
  }
3138
3156
  });
3139
3157
  }