@magemetrics/core 0.12.1 → 0.13.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 +801 -34
- package/dist/index.js +760 -37
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sha256 } from '@noble/hashes/sha2.js';
|
|
2
|
-
import
|
|
2
|
+
import z9, { z } from 'zod';
|
|
3
3
|
import { GoTrueClient } from '@supabase/auth-js';
|
|
4
4
|
import createApiClient2 from 'openapi-fetch';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
@@ -58,7 +58,7 @@ var addApiKeyHeader = (apiKey) => {
|
|
|
58
58
|
|
|
59
59
|
// package.json
|
|
60
60
|
var package_default = {
|
|
61
|
-
version: "0.
|
|
61
|
+
version: "0.13.0"};
|
|
62
62
|
|
|
63
63
|
// src/core/MageMetricsEventEmitter.ts
|
|
64
64
|
var MageMetricsEventEmitter = class {
|
|
@@ -482,7 +482,7 @@ function getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {
|
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
-
// ../../node_modules/.pnpm/hono@4.12.
|
|
485
|
+
// ../../node_modules/.pnpm/hono@4.12.15/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
486
486
|
new Set(".\\+*[^]$()");
|
|
487
487
|
var createRoute = (routeConfig) => {
|
|
488
488
|
const route = {
|
|
@@ -494,6 +494,7 @@ var createRoute = (routeConfig) => {
|
|
|
494
494
|
return Object.defineProperty(route, "getRoutingPath", { enumerable: false });
|
|
495
495
|
};
|
|
496
496
|
extendZodWithOpenApi(z);
|
|
497
|
+
var ExternalUserIdSchema = z.string().min(1, "external_user_id must not be empty").max(58, "external_user_id must be at most 58 characters").regex(/^[a-z0-9._+-]+$/, "external_user_id must contain only lowercase alphanumeric characters, dots, hyphens, underscores, and plus signs").refine((s) => !s.startsWith(".") && !s.endsWith("."), "external_user_id must not start or end with a dot").refine((s) => !s.includes(".."), "external_user_id must not contain consecutive dots");
|
|
497
498
|
|
|
498
499
|
// ../shared/dist/src/endpoints/auth.routes.js
|
|
499
500
|
var GetApiInformationInputSchema = z.object({
|
|
@@ -626,6 +627,73 @@ var ExchangeExternalToken = createRoute({
|
|
|
626
627
|
}
|
|
627
628
|
}
|
|
628
629
|
});
|
|
630
|
+
var MintEmbedTokenInputSchema = z.object({
|
|
631
|
+
uid: ExternalUserIdSchema,
|
|
632
|
+
attributes: z.record(z.string(), z.unknown()),
|
|
633
|
+
applicationName: z.string().trim().min(1).optional()
|
|
634
|
+
});
|
|
635
|
+
var MintEmbedTokenOutputSchema = z.object({
|
|
636
|
+
token: z.string(),
|
|
637
|
+
expires_at: z.iso.datetime()
|
|
638
|
+
});
|
|
639
|
+
createRoute({
|
|
640
|
+
method: "post",
|
|
641
|
+
path: "/api/v1/auth/mintEmbedToken",
|
|
642
|
+
operationId: "mintEmbedToken",
|
|
643
|
+
tags: ["internal"],
|
|
644
|
+
request: {
|
|
645
|
+
body: {
|
|
646
|
+
required: true,
|
|
647
|
+
content: {
|
|
648
|
+
"application/json": {
|
|
649
|
+
schema: MintEmbedTokenInputSchema
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
},
|
|
654
|
+
responses: {
|
|
655
|
+
200: {
|
|
656
|
+
content: {
|
|
657
|
+
"application/json": {
|
|
658
|
+
schema: MintEmbedTokenOutputSchema
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
description: "Mint a short-lived Magemetrics embed assertion"
|
|
662
|
+
},
|
|
663
|
+
400: {
|
|
664
|
+
content: {
|
|
665
|
+
"application/json": {
|
|
666
|
+
schema: z.object({ error: z.string() })
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
description: "Invalid input"
|
|
670
|
+
},
|
|
671
|
+
401: {
|
|
672
|
+
content: {
|
|
673
|
+
"application/json": {
|
|
674
|
+
schema: z.object({ error: z.string() })
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
description: "Authentication required"
|
|
678
|
+
},
|
|
679
|
+
403: {
|
|
680
|
+
content: {
|
|
681
|
+
"application/json": {
|
|
682
|
+
schema: z.object({ error: z.string() })
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
description: "Service account required"
|
|
686
|
+
},
|
|
687
|
+
500: {
|
|
688
|
+
content: {
|
|
689
|
+
"application/json": {
|
|
690
|
+
schema: z.object({ error: z.string() })
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
description: "Unable to mint an embed token"
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
});
|
|
629
697
|
|
|
630
698
|
// src/core/types.ts
|
|
631
699
|
var TOKEN_STORAGE_KEY = "mm-ai-sp-token";
|
|
@@ -848,6 +916,9 @@ var ExternalAuthProvider = class {
|
|
|
848
916
|
var SupabaseHeaderSchema = z.object({
|
|
849
917
|
[HEADER_SP_TOKEN]: z.string().optional()
|
|
850
918
|
});
|
|
919
|
+
var SupabaseScopedHeaderSchema = SupabaseHeaderSchema.extend({
|
|
920
|
+
[HEADER_APPLICATION_NAME]: z.string().optional()
|
|
921
|
+
});
|
|
851
922
|
var FEEDBACK_OPTIONS = [
|
|
852
923
|
{ label: "Helpful", value: "helpful" },
|
|
853
924
|
{ label: "Partially helpful", value: "partially helpful" },
|
|
@@ -968,7 +1039,7 @@ var MaterializationFieldsSchema = z.object({
|
|
|
968
1039
|
});
|
|
969
1040
|
var ReportSchema = z.object({
|
|
970
1041
|
created_at: z.string(),
|
|
971
|
-
flow_id: z.string(),
|
|
1042
|
+
flow_id: z.string().nullable(),
|
|
972
1043
|
id: z.number().openapi({
|
|
973
1044
|
description: "Deprecated: use uuid.",
|
|
974
1045
|
deprecated: true
|
|
@@ -988,7 +1059,9 @@ var ReportSchema = z.object({
|
|
|
988
1059
|
is_removed: z.boolean(),
|
|
989
1060
|
...MaterializationFieldsSchema.shape
|
|
990
1061
|
});
|
|
1062
|
+
ReportSchema.omit({ flow_id: true });
|
|
991
1063
|
var FrontendReportSchema = ReportSchema.omit({
|
|
1064
|
+
flow_id: true,
|
|
992
1065
|
sql: true,
|
|
993
1066
|
table: true,
|
|
994
1067
|
data_sample: true,
|
|
@@ -1091,6 +1164,7 @@ var DataTableSchema = z.object({
|
|
|
1091
1164
|
id: z.number(),
|
|
1092
1165
|
dataset: z.string(),
|
|
1093
1166
|
table_name: z.string(),
|
|
1167
|
+
database: z.string().nullable(),
|
|
1094
1168
|
description: z.string().nullable(),
|
|
1095
1169
|
primary_key_names: z.string().array(),
|
|
1096
1170
|
row_count: z.number().nullable(),
|
|
@@ -2084,20 +2158,20 @@ var CreateSpeechToken = createRoute({
|
|
|
2084
2158
|
}
|
|
2085
2159
|
}
|
|
2086
2160
|
});
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
status:
|
|
2090
|
-
error:
|
|
2161
|
+
z9.discriminatedUnion("status", [
|
|
2162
|
+
z9.object({
|
|
2163
|
+
status: z9.literal("error"),
|
|
2164
|
+
error: z9.string()
|
|
2091
2165
|
}),
|
|
2092
|
-
|
|
2093
|
-
status:
|
|
2094
|
-
flowId:
|
|
2166
|
+
z9.object({
|
|
2167
|
+
status: z9.literal("success"),
|
|
2168
|
+
flowId: z9.string()
|
|
2095
2169
|
})
|
|
2096
2170
|
]);
|
|
2097
|
-
var TriggerFlowBody =
|
|
2098
|
-
triggerId:
|
|
2099
|
-
variables:
|
|
2100
|
-
applicationName:
|
|
2171
|
+
var TriggerFlowBody = z9.object({
|
|
2172
|
+
triggerId: z9.string(),
|
|
2173
|
+
variables: z9.record(z9.string(), z9.string()),
|
|
2174
|
+
applicationName: z9.string().optional()
|
|
2101
2175
|
});
|
|
2102
2176
|
var TriggerFlow = createRoute({
|
|
2103
2177
|
method: "post",
|
|
@@ -2121,9 +2195,9 @@ var TriggerFlow = createRoute({
|
|
|
2121
2195
|
description: "Flow id",
|
|
2122
2196
|
content: {
|
|
2123
2197
|
"application/json": {
|
|
2124
|
-
schema:
|
|
2125
|
-
status:
|
|
2126
|
-
flowId:
|
|
2198
|
+
schema: z9.object({
|
|
2199
|
+
status: z9.literal("success"),
|
|
2200
|
+
flowId: z9.string()
|
|
2127
2201
|
})
|
|
2128
2202
|
}
|
|
2129
2203
|
}
|
|
@@ -2131,8 +2205,8 @@ var TriggerFlow = createRoute({
|
|
|
2131
2205
|
400: {
|
|
2132
2206
|
content: {
|
|
2133
2207
|
"application/json": {
|
|
2134
|
-
schema:
|
|
2135
|
-
error:
|
|
2208
|
+
schema: z9.object({
|
|
2209
|
+
error: z9.string()
|
|
2136
2210
|
})
|
|
2137
2211
|
}
|
|
2138
2212
|
},
|
|
@@ -2141,7 +2215,7 @@ var TriggerFlow = createRoute({
|
|
|
2141
2215
|
404: {
|
|
2142
2216
|
content: {
|
|
2143
2217
|
"application/json": {
|
|
2144
|
-
schema:
|
|
2218
|
+
schema: z9.object({ error: z9.string() })
|
|
2145
2219
|
}
|
|
2146
2220
|
},
|
|
2147
2221
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -2150,8 +2224,8 @@ var TriggerFlow = createRoute({
|
|
|
2150
2224
|
description: "Something wrong happened",
|
|
2151
2225
|
content: {
|
|
2152
2226
|
"application/json": {
|
|
2153
|
-
schema:
|
|
2154
|
-
error:
|
|
2227
|
+
schema: z9.object({
|
|
2228
|
+
error: z9.string()
|
|
2155
2229
|
})
|
|
2156
2230
|
}
|
|
2157
2231
|
}
|
|
@@ -2181,9 +2255,9 @@ createRoute({
|
|
|
2181
2255
|
description: "Flow id",
|
|
2182
2256
|
content: {
|
|
2183
2257
|
"application/json": {
|
|
2184
|
-
schema:
|
|
2185
|
-
status:
|
|
2186
|
-
flowId:
|
|
2258
|
+
schema: z9.object({
|
|
2259
|
+
status: z9.literal("success"),
|
|
2260
|
+
flowId: z9.string()
|
|
2187
2261
|
})
|
|
2188
2262
|
}
|
|
2189
2263
|
}
|
|
@@ -2191,8 +2265,8 @@ createRoute({
|
|
|
2191
2265
|
400: {
|
|
2192
2266
|
content: {
|
|
2193
2267
|
"application/json": {
|
|
2194
|
-
schema:
|
|
2195
|
-
error:
|
|
2268
|
+
schema: z9.object({
|
|
2269
|
+
error: z9.string()
|
|
2196
2270
|
})
|
|
2197
2271
|
}
|
|
2198
2272
|
},
|
|
@@ -2201,7 +2275,7 @@ createRoute({
|
|
|
2201
2275
|
404: {
|
|
2202
2276
|
content: {
|
|
2203
2277
|
"application/json": {
|
|
2204
|
-
schema:
|
|
2278
|
+
schema: z9.object({ error: z9.string() })
|
|
2205
2279
|
}
|
|
2206
2280
|
},
|
|
2207
2281
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -2210,8 +2284,8 @@ createRoute({
|
|
|
2210
2284
|
description: "Something wrong happened",
|
|
2211
2285
|
content: {
|
|
2212
2286
|
"application/json": {
|
|
2213
|
-
schema:
|
|
2214
|
-
error:
|
|
2287
|
+
schema: z9.object({
|
|
2288
|
+
error: z9.string()
|
|
2215
2289
|
})
|
|
2216
2290
|
}
|
|
2217
2291
|
}
|
|
@@ -2356,13 +2430,13 @@ var CanvasIdParam = CanvasSchema.shape.id.openapi("CanvasId", {
|
|
|
2356
2430
|
var dataReportNodeSchema = z.object({
|
|
2357
2431
|
type: z.literal(DATA_REPORT_LABEL),
|
|
2358
2432
|
data: z.object({
|
|
2359
|
-
reportId: z.
|
|
2433
|
+
reportId: z.string()
|
|
2360
2434
|
})
|
|
2361
2435
|
});
|
|
2362
2436
|
var visualizationNodeSchema = z.object({
|
|
2363
2437
|
type: z.literal(VISUALIZATION_LABEL),
|
|
2364
2438
|
data: z.object({
|
|
2365
|
-
visualizationId: z.
|
|
2439
|
+
visualizationId: z.string()
|
|
2366
2440
|
})
|
|
2367
2441
|
});
|
|
2368
2442
|
z.discriminatedUnion("type", [
|
|
@@ -2658,6 +2732,386 @@ var ChatMessages = createRoute({
|
|
|
2658
2732
|
}
|
|
2659
2733
|
}
|
|
2660
2734
|
});
|
|
2735
|
+
var UPDATE_TASK = "updateTask";
|
|
2736
|
+
var TaskStatusSchema = z.enum([
|
|
2737
|
+
"pending",
|
|
2738
|
+
"in_progress",
|
|
2739
|
+
"completed",
|
|
2740
|
+
"failed"
|
|
2741
|
+
]);
|
|
2742
|
+
var TaskArtifactSchema = z.object({
|
|
2743
|
+
type: z.enum(["report", "visualization"]),
|
|
2744
|
+
id: z.string().describe("The ID returned by generateDataReport or generateVisualization")
|
|
2745
|
+
});
|
|
2746
|
+
var TaskSummarySchema = z.object({
|
|
2747
|
+
outcome: z.string().describe("SHORT summary (max 10 words) e.g. 'Found 847 records' or 'Generated trend chart'"),
|
|
2748
|
+
tool_calls: z.array(z.string()).describe("List of tools used during this task, e.g. ['generateDataReport x3', 'generateVisualization x1']")
|
|
2749
|
+
});
|
|
2750
|
+
var TaskPlanItemSchema = z.object({
|
|
2751
|
+
id: z.string(),
|
|
2752
|
+
title: z.string(),
|
|
2753
|
+
description: z.string().optional().describe("Detailed steps or description of what the task will do")
|
|
2754
|
+
});
|
|
2755
|
+
var TaskPlanSchema = z.array(TaskPlanItemSchema);
|
|
2756
|
+
var AgentTaskSchema = z.object({
|
|
2757
|
+
id: z.string(),
|
|
2758
|
+
title: z.string(),
|
|
2759
|
+
status: TaskStatusSchema,
|
|
2760
|
+
parent_id: z.string().optional(),
|
|
2761
|
+
started_at: z.string().optional(),
|
|
2762
|
+
completed_at: z.string().optional(),
|
|
2763
|
+
summary: TaskSummarySchema.optional(),
|
|
2764
|
+
artifacts: z.array(TaskArtifactSchema).optional()
|
|
2765
|
+
});
|
|
2766
|
+
var AgentTasksStateSchema = z.array(AgentTaskSchema);
|
|
2767
|
+
var updateTaskInputSchema = z.object({
|
|
2768
|
+
action: z.enum(["update", "create"]).default("update").describe('Action type \u2014 "update" (default) or "create"'),
|
|
2769
|
+
id: z.string().optional().describe("The task ID (e.g. '1', '2', or '1.1' for subtasks) \u2014 required for update"),
|
|
2770
|
+
title: z.string().optional().describe("Short title for the new task \u2014 required for create"),
|
|
2771
|
+
status: TaskStatusSchema.optional().describe("The new status for this task \u2014 required for update"),
|
|
2772
|
+
summary: TaskSummarySchema.optional().describe("Summary of outcome and tools used (required when status is 'completed')"),
|
|
2773
|
+
artifacts: z.array(TaskArtifactSchema).optional().describe("Reports and visualizations produced during this task")
|
|
2774
|
+
});
|
|
2775
|
+
updateTaskInputSchema.extend({
|
|
2776
|
+
action: z.literal("update").default("update").describe("Action type")
|
|
2777
|
+
});
|
|
2778
|
+
var TaskSummaryForContextSchema = z.object({
|
|
2779
|
+
id: z.string(),
|
|
2780
|
+
title: z.string(),
|
|
2781
|
+
status: TaskStatusSchema
|
|
2782
|
+
});
|
|
2783
|
+
var TaskResultPublicSchema = z.object({
|
|
2784
|
+
taskId: z.string(),
|
|
2785
|
+
taskStatus: TaskStatusSchema,
|
|
2786
|
+
message: z.string()
|
|
2787
|
+
});
|
|
2788
|
+
var TaskResultPrivateSchema = z.object({
|
|
2789
|
+
updatedAt: z.string(),
|
|
2790
|
+
// Current state of all tasks - injected so model stays aware of progress
|
|
2791
|
+
currentTasks: z.array(TaskSummaryForContextSchema)
|
|
2792
|
+
});
|
|
2793
|
+
var UpdateTaskSuccessSchema = z.object({
|
|
2794
|
+
status: z.literal("success"),
|
|
2795
|
+
public: TaskResultPublicSchema,
|
|
2796
|
+
// Private fields are redacted before sending to frontend (user sees tasks in UI already)
|
|
2797
|
+
private: TaskResultPrivateSchema
|
|
2798
|
+
});
|
|
2799
|
+
var UpdateTaskErrorSchema = z.object({
|
|
2800
|
+
status: z.literal("error"),
|
|
2801
|
+
message: z.string()
|
|
2802
|
+
});
|
|
2803
|
+
z.object({
|
|
2804
|
+
tool: z.literal(UPDATE_TASK),
|
|
2805
|
+
result: z.discriminatedUnion("status", [
|
|
2806
|
+
UpdateTaskSuccessSchema,
|
|
2807
|
+
UpdateTaskErrorSchema
|
|
2808
|
+
]).optional()
|
|
2809
|
+
});
|
|
2810
|
+
|
|
2811
|
+
// ../shared/dist/src/types/agentTypes.js
|
|
2812
|
+
var AgentType = {
|
|
2813
|
+
KnowledgeFarmer: "knowledge_farmer",
|
|
2814
|
+
KnowledgeConsistencyChecker: "knowledge_consistency_checker",
|
|
2815
|
+
CompanyResearch: "company_research",
|
|
2816
|
+
KnowledgeExtraction: "knowledge_extraction",
|
|
2817
|
+
/** User-defined agents (via AgentRunScheduler) */
|
|
2818
|
+
Custom: "custom"
|
|
2819
|
+
};
|
|
2820
|
+
var ExecutionPlatform = {
|
|
2821
|
+
Native: "native",
|
|
2822
|
+
Sandbox: "sandbox",
|
|
2823
|
+
SandboxPublic: "sandbox_public"
|
|
2824
|
+
};
|
|
2825
|
+
|
|
2826
|
+
// ../shared/dist/src/types/executionContext.js
|
|
2827
|
+
var ImpersonateContextSchema = z.object({
|
|
2828
|
+
mode: z.literal("impersonate"),
|
|
2829
|
+
external_user_id: z.string().min(1).describe("The user ID in the customer's system")
|
|
2830
|
+
}).openapi("ImpersonateContext");
|
|
2831
|
+
var CustomMetadataContextSchema = z.object({
|
|
2832
|
+
mode: z.literal("custom"),
|
|
2833
|
+
metadata: z.record(z.string(), z.unknown()).describe("Raw metadata key-value pairs for data access rules")
|
|
2834
|
+
}).openapi("CustomMetadataContext");
|
|
2835
|
+
var ExecutionContextInputSchema = z.discriminatedUnion("mode", [
|
|
2836
|
+
ImpersonateContextSchema,
|
|
2837
|
+
CustomMetadataContextSchema
|
|
2838
|
+
]).openapi("ExecutionContextInput");
|
|
2839
|
+
var ResolvedExecutionContextSchema = z.object({
|
|
2840
|
+
companyId: z.number(),
|
|
2841
|
+
userMetadata: z.record(z.string(), z.unknown())
|
|
2842
|
+
});
|
|
2843
|
+
|
|
2844
|
+
// ../shared/dist/src/schemas/agents/agent.js
|
|
2845
|
+
var JsonSchemaObjectSchema = z.record(z.string(), z.unknown());
|
|
2846
|
+
var AgentInputFieldOptionSchema = z.object({
|
|
2847
|
+
value: z.string(),
|
|
2848
|
+
fragment: z.string().optional()
|
|
2849
|
+
});
|
|
2850
|
+
var AgentEnumInputFieldSchema = z.object({
|
|
2851
|
+
id: z.string(),
|
|
2852
|
+
name: z.string(),
|
|
2853
|
+
description: z.string().optional(),
|
|
2854
|
+
type: z.literal("enum"),
|
|
2855
|
+
options: z.array(AgentInputFieldOptionSchema).min(1),
|
|
2856
|
+
useFragmentMapping: z.boolean().default(false),
|
|
2857
|
+
required: z.boolean().default(false)
|
|
2858
|
+
});
|
|
2859
|
+
var AgentTextInputFieldSchema = z.object({
|
|
2860
|
+
id: z.string(),
|
|
2861
|
+
name: z.string(),
|
|
2862
|
+
description: z.string().optional(),
|
|
2863
|
+
type: z.literal("text"),
|
|
2864
|
+
useFragmentMapping: z.literal(false).default(false),
|
|
2865
|
+
required: z.boolean().default(false)
|
|
2866
|
+
});
|
|
2867
|
+
var AgentInputFieldSchema = z.discriminatedUnion("type", [
|
|
2868
|
+
AgentEnumInputFieldSchema,
|
|
2869
|
+
AgentTextInputFieldSchema
|
|
2870
|
+
]);
|
|
2871
|
+
var AgentInputSchemaSchema = z.array(AgentInputFieldSchema);
|
|
2872
|
+
var GeminiModelConfigSchema = z.object({
|
|
2873
|
+
model: z.literal("gemini-3.1-pro-preview"),
|
|
2874
|
+
thinking: z.enum(["low", "high"]).optional()
|
|
2875
|
+
});
|
|
2876
|
+
var Gemini25ProModelConfigSchema = z.object({
|
|
2877
|
+
model: z.literal("gemini-2.5-pro"),
|
|
2878
|
+
thinking: z.enum(["low", "high"]).optional()
|
|
2879
|
+
});
|
|
2880
|
+
var ClaudeAdaptiveModelConfigSchema = z.object({
|
|
2881
|
+
model: z.enum(["claude-sonnet-4-6", "claude-opus-4-6"]),
|
|
2882
|
+
effort: z.enum(["low", "medium", "high"]).optional()
|
|
2883
|
+
});
|
|
2884
|
+
var ClaudeBasicModelConfigSchema = z.object({
|
|
2885
|
+
model: z.enum(["claude-haiku-4-5", "claude-opus-4-5"])
|
|
2886
|
+
});
|
|
2887
|
+
var ModelConfigSchema = z.discriminatedUnion("model", [
|
|
2888
|
+
GeminiModelConfigSchema,
|
|
2889
|
+
Gemini25ProModelConfigSchema,
|
|
2890
|
+
ClaudeAdaptiveModelConfigSchema,
|
|
2891
|
+
ClaudeBasicModelConfigSchema
|
|
2892
|
+
]);
|
|
2893
|
+
var ExecutionPlatformSchema = z.enum([
|
|
2894
|
+
ExecutionPlatform.Native,
|
|
2895
|
+
ExecutionPlatform.Sandbox,
|
|
2896
|
+
ExecutionPlatform.SandboxPublic
|
|
2897
|
+
]);
|
|
2898
|
+
var BaseAgentSchema = z.object({
|
|
2899
|
+
id: z.uuid(),
|
|
2900
|
+
company_id: z.number(),
|
|
2901
|
+
is_removed: z.boolean().nullable(),
|
|
2902
|
+
created_at: z.string()
|
|
2903
|
+
});
|
|
2904
|
+
var AgentBehaviorSchema = z.object({
|
|
2905
|
+
name: z.string(),
|
|
2906
|
+
objective: z.string().nullable(),
|
|
2907
|
+
generated_objective_fragment: z.string().nullable(),
|
|
2908
|
+
active_tools: z.array(z.string()).nullable(),
|
|
2909
|
+
input_schema: AgentInputSchemaSchema.nullable(),
|
|
2910
|
+
output_schema: JsonSchemaObjectSchema,
|
|
2911
|
+
task_plan: TaskPlanSchema.nullable(),
|
|
2912
|
+
model_config: ModelConfigSchema.nullable(),
|
|
2913
|
+
execution_platform: ExecutionPlatformSchema
|
|
2914
|
+
});
|
|
2915
|
+
var AgentSchema = z.object({
|
|
2916
|
+
...BaseAgentSchema.shape,
|
|
2917
|
+
...AgentBehaviorSchema.shape,
|
|
2918
|
+
updated_at: z.string(),
|
|
2919
|
+
current_version_id: z.uuid()
|
|
2920
|
+
});
|
|
2921
|
+
z.object({
|
|
2922
|
+
name: z.string().min(1, "Name is required"),
|
|
2923
|
+
objective: z.string().optional(),
|
|
2924
|
+
generated_objective_fragment: z.string().optional(),
|
|
2925
|
+
active_tools: z.array(z.string()).default([]),
|
|
2926
|
+
input_schema: AgentInputSchemaSchema.optional(),
|
|
2927
|
+
output_schema: JsonSchemaObjectSchema,
|
|
2928
|
+
task_plan: TaskPlanSchema.optional(),
|
|
2929
|
+
model_config: ModelConfigSchema.optional(),
|
|
2930
|
+
execution_platform: ExecutionPlatformSchema.default(ExecutionPlatform.Native)
|
|
2931
|
+
});
|
|
2932
|
+
var DbUpdateAgentSchema = z.object({
|
|
2933
|
+
name: z.string().min(1).optional(),
|
|
2934
|
+
objective: z.string().nullable().optional(),
|
|
2935
|
+
generated_objective_fragment: z.string().nullable().optional(),
|
|
2936
|
+
active_tools: z.array(z.string()).optional(),
|
|
2937
|
+
input_schema: AgentInputSchemaSchema.nullable().optional(),
|
|
2938
|
+
output_schema: JsonSchemaObjectSchema.optional(),
|
|
2939
|
+
task_plan: TaskPlanSchema.nullable().optional(),
|
|
2940
|
+
model_config: ModelConfigSchema.nullable().optional(),
|
|
2941
|
+
execution_platform: ExecutionPlatformSchema.optional(),
|
|
2942
|
+
restored_from_version: z.number().int().positive().nullable().optional()
|
|
2943
|
+
});
|
|
2944
|
+
DbUpdateAgentSchema.omit({
|
|
2945
|
+
restored_from_version: true
|
|
2946
|
+
});
|
|
2947
|
+
AgentSchema.omit({
|
|
2948
|
+
company_id: true,
|
|
2949
|
+
is_removed: true,
|
|
2950
|
+
current_version_id: true
|
|
2951
|
+
}).openapi("Agent");
|
|
2952
|
+
|
|
2953
|
+
// ../shared/dist/src/schemas/agents/postProcessor.js
|
|
2954
|
+
var PostProcessorConfigSchema = z.discriminatedUnion("type", [
|
|
2955
|
+
/**
|
|
2956
|
+
* Resolve and insert knowledge item proposals from output_data.proposals
|
|
2957
|
+
* and output_data.deletions into knowledge_item_proposals.
|
|
2958
|
+
* Compatible with: farmer, consistency checker, knowledge extraction.
|
|
2959
|
+
*/
|
|
2960
|
+
z.object({
|
|
2961
|
+
type: z.literal("knowledge_proposals"),
|
|
2962
|
+
params: z.object({
|
|
2963
|
+
/** DB enum value to tag inserted proposals with. */
|
|
2964
|
+
source: z.enum(["data_report", "consistency_check", "document"]),
|
|
2965
|
+
/**
|
|
2966
|
+
* Only insert proposals at or above this confidence level.
|
|
2967
|
+
* Proposals without a confidence field are always included.
|
|
2968
|
+
*/
|
|
2969
|
+
minConfidence: z.enum(["low", "medium", "high"]).optional(),
|
|
2970
|
+
/** Skip DB writes and only log what would be inserted. */
|
|
2971
|
+
dryRun: z.boolean().optional()
|
|
2972
|
+
})
|
|
2973
|
+
}),
|
|
2974
|
+
/**
|
|
2975
|
+
* Soft-delete few-shot prompt examples from output_data.few_shot_removals.
|
|
2976
|
+
*/
|
|
2977
|
+
z.object({
|
|
2978
|
+
type: z.literal("remove_few_shot_examples"),
|
|
2979
|
+
params: z.object({
|
|
2980
|
+
/** Identifies the calling agent in the audit trail comment. */
|
|
2981
|
+
sourceLabel: z.string(),
|
|
2982
|
+
/** Skip DB writes and only log what would be removed. */
|
|
2983
|
+
dryRun: z.boolean().optional()
|
|
2984
|
+
})
|
|
2985
|
+
}),
|
|
2986
|
+
/**
|
|
2987
|
+
* Record a knowledge farmer investigation. Must run before knowledge_proposals
|
|
2988
|
+
* so ctx.investigationId is set for downstream post-processors.
|
|
2989
|
+
*/
|
|
2990
|
+
z.object({
|
|
2991
|
+
type: z.literal("knowledge_farmer_investigation"),
|
|
2992
|
+
params: z.object({
|
|
2993
|
+
/** Skip DB writes and only log what would be inserted. */
|
|
2994
|
+
dryRun: z.boolean().optional()
|
|
2995
|
+
})
|
|
2996
|
+
}),
|
|
2997
|
+
/**
|
|
2998
|
+
* Persist the agent's entire output_data as company_settings.context_profile.
|
|
2999
|
+
* Used by the company research agent.
|
|
3000
|
+
*/
|
|
3001
|
+
z.object({
|
|
3002
|
+
type: z.literal("save_context_profile")
|
|
3003
|
+
})
|
|
3004
|
+
]);
|
|
3005
|
+
|
|
3006
|
+
// ../shared/dist/src/schemas/agents/agentRun.js
|
|
3007
|
+
var AgentTypeSchema = z.enum([
|
|
3008
|
+
AgentType.KnowledgeFarmer,
|
|
3009
|
+
AgentType.KnowledgeConsistencyChecker,
|
|
3010
|
+
AgentType.CompanyResearch,
|
|
3011
|
+
AgentType.KnowledgeExtraction,
|
|
3012
|
+
AgentType.Custom
|
|
3013
|
+
]);
|
|
3014
|
+
var ExecutionPlatformSchema2 = z.enum([
|
|
3015
|
+
ExecutionPlatform.Native,
|
|
3016
|
+
ExecutionPlatform.Sandbox,
|
|
3017
|
+
ExecutionPlatform.SandboxPublic
|
|
3018
|
+
]);
|
|
3019
|
+
var AgentRunStatusSchema = z.enum([
|
|
3020
|
+
"pending",
|
|
3021
|
+
"running",
|
|
3022
|
+
"post_processing",
|
|
3023
|
+
"completed",
|
|
3024
|
+
"failed",
|
|
3025
|
+
"cancelled"
|
|
3026
|
+
]);
|
|
3027
|
+
var AgentChatMessageSchema = z.record(z.string(), z.unknown());
|
|
3028
|
+
z.object({
|
|
3029
|
+
id: z.uuid(),
|
|
3030
|
+
user_id: z.uuid(),
|
|
3031
|
+
company_id: z.number().nullable(),
|
|
3032
|
+
agent_id: z.uuid().nullable(),
|
|
3033
|
+
agent_type: AgentTypeSchema.nullable(),
|
|
3034
|
+
execution_platform: ExecutionPlatformSchema2.nullable(),
|
|
3035
|
+
status: AgentRunStatusSchema,
|
|
3036
|
+
created_at: z.string(),
|
|
3037
|
+
started_at: z.string().nullable(),
|
|
3038
|
+
completed_at: z.string().nullable(),
|
|
3039
|
+
cancelled_at: z.string().nullable(),
|
|
3040
|
+
job_id: z.string().nullable(),
|
|
3041
|
+
chat_messages: z.array(AgentChatMessageSchema).nullable(),
|
|
3042
|
+
allowed_tools: z.array(z.string()).nullable(),
|
|
3043
|
+
input_data: z.record(z.string(), z.unknown()).nullable(),
|
|
3044
|
+
output_data: z.record(z.string(), z.unknown()).nullable(),
|
|
3045
|
+
output_schema: JsonSchemaObjectSchema.nullable(),
|
|
3046
|
+
tasks: AgentTasksStateSchema.nullable(),
|
|
3047
|
+
error_message: z.string().nullable(),
|
|
3048
|
+
execution_context: ResolvedExecutionContextSchema.nullable(),
|
|
3049
|
+
model_config: ModelConfigSchema.nullable(),
|
|
3050
|
+
// Nullable with a default so pre-migration rows (where the column is absent)
|
|
3051
|
+
// parse cleanly — undefined input becomes null output.
|
|
3052
|
+
post_processors: z.array(PostProcessorConfigSchema).nullable().default(null),
|
|
3053
|
+
agent_version_id: z.uuid().nullable().default(null)
|
|
3054
|
+
});
|
|
3055
|
+
z.object({
|
|
3056
|
+
user_id: z.uuid(),
|
|
3057
|
+
company_id: z.number(),
|
|
3058
|
+
agent_id: z.uuid().nullable(),
|
|
3059
|
+
agent_type: AgentTypeSchema.optional(),
|
|
3060
|
+
execution_platform: ExecutionPlatformSchema2.optional(),
|
|
3061
|
+
status: AgentRunStatusSchema.default("pending"),
|
|
3062
|
+
chat_messages: z.array(AgentChatMessageSchema).optional(),
|
|
3063
|
+
allowed_tools: z.array(z.string()).optional(),
|
|
3064
|
+
input_data: z.record(z.string(), z.unknown()).optional(),
|
|
3065
|
+
output_data: z.record(z.string(), z.unknown()).optional(),
|
|
3066
|
+
output_schema: JsonSchemaObjectSchema.optional(),
|
|
3067
|
+
execution_context: ResolvedExecutionContextSchema.optional(),
|
|
3068
|
+
model_config: ModelConfigSchema.optional(),
|
|
3069
|
+
post_processors: z.array(PostProcessorConfigSchema).optional(),
|
|
3070
|
+
agent_version_id: z.uuid().optional(),
|
|
3071
|
+
started_at: z.string().optional(),
|
|
3072
|
+
completed_at: z.string().optional()
|
|
3073
|
+
});
|
|
3074
|
+
z.object({
|
|
3075
|
+
status: AgentRunStatusSchema.optional(),
|
|
3076
|
+
started_at: z.string().optional(),
|
|
3077
|
+
completed_at: z.string().optional(),
|
|
3078
|
+
cancelled_at: z.string().optional(),
|
|
3079
|
+
job_id: z.string().optional(),
|
|
3080
|
+
chat_messages: z.array(AgentChatMessageSchema).optional(),
|
|
3081
|
+
input_data: z.record(z.string(), z.unknown()).optional(),
|
|
3082
|
+
output_data: z.record(z.string(), z.unknown()).optional(),
|
|
3083
|
+
tasks: AgentTasksStateSchema.optional(),
|
|
3084
|
+
error_message: z.string().optional(),
|
|
3085
|
+
model_config: ModelConfigSchema.optional(),
|
|
3086
|
+
last_heartbeat_at: z.string().nullable().optional(),
|
|
3087
|
+
post_processors: z.array(PostProcessorConfigSchema).optional()
|
|
3088
|
+
});
|
|
3089
|
+
var StartAgentRunRequestSchema = z.object({
|
|
3090
|
+
agent_id: z.uuid(),
|
|
3091
|
+
inputs: z.record(z.string(), z.unknown()).default({}),
|
|
3092
|
+
execution_context: ExecutionContextInputSchema.optional()
|
|
3093
|
+
}).openapi("StartAgentRunRequest");
|
|
3094
|
+
var AgentRunResponseSchema = z.object({
|
|
3095
|
+
id: z.uuid(),
|
|
3096
|
+
agent_id: z.uuid().nullable(),
|
|
3097
|
+
status: AgentRunStatusSchema,
|
|
3098
|
+
created_at: z.string(),
|
|
3099
|
+
started_at: z.string().nullable(),
|
|
3100
|
+
completed_at: z.string().nullable(),
|
|
3101
|
+
input_data: z.record(z.string(), z.unknown()).nullable(),
|
|
3102
|
+
output_data: z.record(z.string(), z.unknown()).nullable(),
|
|
3103
|
+
tasks: AgentTasksStateSchema.nullable().optional(),
|
|
3104
|
+
error_message: z.string().nullable(),
|
|
3105
|
+
execution_context: ResolvedExecutionContextSchema.nullable().optional(),
|
|
3106
|
+
agent_version_id: z.uuid().nullable().optional(),
|
|
3107
|
+
cached: z.boolean().optional()
|
|
3108
|
+
}).openapi("AgentRunResponse");
|
|
3109
|
+
z.object({
|
|
3110
|
+
status: AgentRunStatusSchema.optional(),
|
|
3111
|
+
agent_id: z.uuid().optional(),
|
|
3112
|
+
agent_type: AgentTypeSchema.optional(),
|
|
3113
|
+
limit: z.number().int().positive().max(100).default(20)
|
|
3114
|
+
});
|
|
2661
3115
|
dayjs.extend(relativeTime);
|
|
2662
3116
|
dayjs.extend(customParseFormat);
|
|
2663
3117
|
dayjs.extend(utc);
|
|
@@ -3006,7 +3460,244 @@ var FrontendVisualizationWithDataSchema = FrontendVisualizationSchema.extend({
|
|
|
3006
3460
|
_metadata: VisualizationMetadataSchema
|
|
3007
3461
|
});
|
|
3008
3462
|
|
|
3463
|
+
// ../shared/dist/src/endpoints/agents/runs.routes.js
|
|
3464
|
+
var AgentRunIdParam = z.object({ id: z.uuid() }).openapi("AgentRunId");
|
|
3465
|
+
var ErrorResponseSchema = z.object({ error: z.string() });
|
|
3466
|
+
createRoute({
|
|
3467
|
+
method: "post",
|
|
3468
|
+
path: "/api/v1/agent-runs",
|
|
3469
|
+
operationId: "startAgentRun",
|
|
3470
|
+
tags: ["public", "documented"],
|
|
3471
|
+
request: {
|
|
3472
|
+
headers: SupabaseScopedHeaderSchema,
|
|
3473
|
+
body: {
|
|
3474
|
+
required: true,
|
|
3475
|
+
content: {
|
|
3476
|
+
"application/json": {
|
|
3477
|
+
schema: StartAgentRunRequestSchema
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
3481
|
+
},
|
|
3482
|
+
responses: {
|
|
3483
|
+
200: {
|
|
3484
|
+
description: "The agent run was started",
|
|
3485
|
+
content: {
|
|
3486
|
+
"application/json": {
|
|
3487
|
+
schema: AgentRunResponseSchema
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
},
|
|
3491
|
+
400: {
|
|
3492
|
+
description: "Invalid request or input validation failed",
|
|
3493
|
+
content: {
|
|
3494
|
+
"application/json": {
|
|
3495
|
+
schema: ErrorResponseSchema
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
},
|
|
3499
|
+
404: {
|
|
3500
|
+
description: "Agent definition not found",
|
|
3501
|
+
content: {
|
|
3502
|
+
"application/json": {
|
|
3503
|
+
schema: ErrorResponseSchema
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
},
|
|
3507
|
+
500: {
|
|
3508
|
+
description: "Internal server error",
|
|
3509
|
+
content: {
|
|
3510
|
+
"application/json": {
|
|
3511
|
+
schema: ErrorResponseSchema
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
});
|
|
3517
|
+
var AgentRunCountsResponseSchema = z.record(z.string().uuid(), z.number().int().nonnegative()).openapi("AgentRunCountsResponse");
|
|
3518
|
+
createRoute({
|
|
3519
|
+
method: "get",
|
|
3520
|
+
path: "/api/v1/agent-runs/counts",
|
|
3521
|
+
operationId: "getAgentRunCounts",
|
|
3522
|
+
tags: ["internal"],
|
|
3523
|
+
request: {
|
|
3524
|
+
headers: SupabaseHeaderSchema
|
|
3525
|
+
},
|
|
3526
|
+
responses: {
|
|
3527
|
+
200: {
|
|
3528
|
+
description: "Run counts per agent",
|
|
3529
|
+
content: {
|
|
3530
|
+
"application/json": {
|
|
3531
|
+
schema: AgentRunCountsResponseSchema
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
},
|
|
3535
|
+
500: {
|
|
3536
|
+
description: "Internal server error",
|
|
3537
|
+
content: {
|
|
3538
|
+
"application/json": {
|
|
3539
|
+
schema: ErrorResponseSchema
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
});
|
|
3545
|
+
createRoute({
|
|
3546
|
+
method: "get",
|
|
3547
|
+
path: "/api/v1/agent-runs/{id}",
|
|
3548
|
+
operationId: "getAgentRun",
|
|
3549
|
+
tags: ["public", "documented"],
|
|
3550
|
+
request: {
|
|
3551
|
+
headers: SupabaseHeaderSchema,
|
|
3552
|
+
params: AgentRunIdParam
|
|
3553
|
+
},
|
|
3554
|
+
responses: {
|
|
3555
|
+
200: {
|
|
3556
|
+
description: "The agent run",
|
|
3557
|
+
content: {
|
|
3558
|
+
"application/json": {
|
|
3559
|
+
schema: AgentRunResponseSchema
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
},
|
|
3563
|
+
404: {
|
|
3564
|
+
description: "Agent run not found",
|
|
3565
|
+
content: {
|
|
3566
|
+
"application/json": {
|
|
3567
|
+
schema: ErrorResponseSchema
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
},
|
|
3571
|
+
500: {
|
|
3572
|
+
description: "Internal server error",
|
|
3573
|
+
content: {
|
|
3574
|
+
"application/json": {
|
|
3575
|
+
schema: ErrorResponseSchema
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
});
|
|
3581
|
+
createRoute({
|
|
3582
|
+
method: "get",
|
|
3583
|
+
path: "/api/v1/agent-runs",
|
|
3584
|
+
operationId: "listAgentRuns",
|
|
3585
|
+
tags: ["public", "documented"],
|
|
3586
|
+
request: {
|
|
3587
|
+
headers: SupabaseHeaderSchema,
|
|
3588
|
+
query: z.object({
|
|
3589
|
+
status: AgentRunStatusSchema.optional(),
|
|
3590
|
+
agent_id: z.uuid().optional(),
|
|
3591
|
+
limit: limitQueryParams
|
|
3592
|
+
})
|
|
3593
|
+
},
|
|
3594
|
+
responses: {
|
|
3595
|
+
200: {
|
|
3596
|
+
description: "List of agent runs",
|
|
3597
|
+
content: {
|
|
3598
|
+
"application/json": {
|
|
3599
|
+
schema: AgentRunResponseSchema.array()
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
},
|
|
3603
|
+
500: {
|
|
3604
|
+
description: "Internal server error",
|
|
3605
|
+
content: {
|
|
3606
|
+
"application/json": {
|
|
3607
|
+
schema: ErrorResponseSchema
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
});
|
|
3613
|
+
var GetAgentRunReports = createRoute({
|
|
3614
|
+
method: "get",
|
|
3615
|
+
path: "/api/v1/agent-runs/{id}/reports",
|
|
3616
|
+
operationId: "getAgentRunReports",
|
|
3617
|
+
tags: ["public", "documented"],
|
|
3618
|
+
request: {
|
|
3619
|
+
headers: SupabaseHeaderSchema,
|
|
3620
|
+
params: AgentRunIdParam
|
|
3621
|
+
},
|
|
3622
|
+
responses: {
|
|
3623
|
+
200: {
|
|
3624
|
+
description: "Reports generated by this agent run",
|
|
3625
|
+
content: {
|
|
3626
|
+
"application/json": {
|
|
3627
|
+
schema: FrontendReportSchema.array()
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
},
|
|
3631
|
+
404: {
|
|
3632
|
+
description: "Agent run not found",
|
|
3633
|
+
content: {
|
|
3634
|
+
"application/json": {
|
|
3635
|
+
schema: ErrorResponseSchema
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
},
|
|
3639
|
+
500: {
|
|
3640
|
+
description: "Internal server error",
|
|
3641
|
+
content: {
|
|
3642
|
+
"application/json": {
|
|
3643
|
+
schema: ErrorResponseSchema
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
});
|
|
3649
|
+
var GetAgentRunVisualizations = createRoute({
|
|
3650
|
+
method: "get",
|
|
3651
|
+
path: "/api/v1/agent-runs/{id}/visualizations",
|
|
3652
|
+
operationId: "getAgentRunVisualizations",
|
|
3653
|
+
tags: ["public", "documented"],
|
|
3654
|
+
request: {
|
|
3655
|
+
headers: SupabaseHeaderSchema,
|
|
3656
|
+
params: AgentRunIdParam
|
|
3657
|
+
},
|
|
3658
|
+
responses: {
|
|
3659
|
+
200: {
|
|
3660
|
+
description: "Visualizations generated by this agent run",
|
|
3661
|
+
content: {
|
|
3662
|
+
"application/json": {
|
|
3663
|
+
schema: FrontendVisualizationSchema.array()
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
},
|
|
3667
|
+
404: {
|
|
3668
|
+
description: "Agent run not found",
|
|
3669
|
+
content: {
|
|
3670
|
+
"application/json": {
|
|
3671
|
+
schema: ErrorResponseSchema
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
},
|
|
3675
|
+
500: {
|
|
3676
|
+
description: "Internal server error",
|
|
3677
|
+
content: {
|
|
3678
|
+
"application/json": {
|
|
3679
|
+
schema: ErrorResponseSchema
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
});
|
|
3685
|
+
|
|
3009
3686
|
// ../shared/dist/src/endpoints/visualizations.routes.js
|
|
3687
|
+
var parseVisualizationId = (val, ctx) => {
|
|
3688
|
+
const num = Number(val);
|
|
3689
|
+
if (Number.isInteger(num) && num > 0)
|
|
3690
|
+
return num;
|
|
3691
|
+
const uuidResult = z.uuid().safeParse(val);
|
|
3692
|
+
if (uuidResult.success)
|
|
3693
|
+
return val;
|
|
3694
|
+
ctx.addIssue("visualization_id must be a positive integer or a valid UUID");
|
|
3695
|
+
return z.NEVER;
|
|
3696
|
+
};
|
|
3697
|
+
var VisualizationId = z.string().transform((val, ctx) => parseVisualizationId(val, ctx)).openapi({
|
|
3698
|
+
type: "string",
|
|
3699
|
+
description: "Numeric legacy ID or UUID"
|
|
3700
|
+
});
|
|
3010
3701
|
var VisualizationWithDataResponse = z.union([
|
|
3011
3702
|
FrontendVisualizationWithDataSchema,
|
|
3012
3703
|
V1FrontendVisualizationWithDataSchema
|
|
@@ -3018,7 +3709,7 @@ createRoute({
|
|
|
3018
3709
|
tags: ["public"],
|
|
3019
3710
|
request: {
|
|
3020
3711
|
headers: SupabaseHeaderSchema,
|
|
3021
|
-
params: z.object({ visualization_id:
|
|
3712
|
+
params: z.object({ visualization_id: VisualizationId }).openapi("VisualizationId", { type: "string" })
|
|
3022
3713
|
},
|
|
3023
3714
|
responses: {
|
|
3024
3715
|
200: {
|
|
@@ -3295,6 +3986,38 @@ var MageMetricsClient = class {
|
|
|
3295
3986
|
}
|
|
3296
3987
|
return data;
|
|
3297
3988
|
},
|
|
3989
|
+
getAgentRunReports: async (agentRunId) => {
|
|
3990
|
+
await this.waitForAuth();
|
|
3991
|
+
const { data, error, response } = await this.internalApiClient.GET(
|
|
3992
|
+
GetAgentRunReports.path,
|
|
3993
|
+
{ params: { path: { id: agentRunId } } }
|
|
3994
|
+
);
|
|
3995
|
+
if (error) {
|
|
3996
|
+
throw new ApiError(error.error, response, {
|
|
3997
|
+
status: response.status,
|
|
3998
|
+
statusText: response.statusText,
|
|
3999
|
+
url: response.url,
|
|
4000
|
+
method: "GET"
|
|
4001
|
+
});
|
|
4002
|
+
}
|
|
4003
|
+
return data;
|
|
4004
|
+
},
|
|
4005
|
+
getAgentRunVisualizations: async (agentRunId) => {
|
|
4006
|
+
await this.waitForAuth();
|
|
4007
|
+
const { data, error, response } = await this.internalApiClient.GET(
|
|
4008
|
+
GetAgentRunVisualizations.path,
|
|
4009
|
+
{ params: { path: { id: agentRunId } } }
|
|
4010
|
+
);
|
|
4011
|
+
if (error) {
|
|
4012
|
+
throw new ApiError(error.error, response, {
|
|
4013
|
+
status: response.status,
|
|
4014
|
+
statusText: response.statusText,
|
|
4015
|
+
url: response.url,
|
|
4016
|
+
method: "GET"
|
|
4017
|
+
});
|
|
4018
|
+
}
|
|
4019
|
+
return data;
|
|
4020
|
+
},
|
|
3298
4021
|
getFlow: async (flowId) => {
|
|
3299
4022
|
await this.waitForAuth();
|
|
3300
4023
|
const { data, error, response } = await this.internalApiClient.GET(
|
|
@@ -3558,7 +4281,7 @@ var MageMetricsClient = class {
|
|
|
3558
4281
|
{
|
|
3559
4282
|
params: {
|
|
3560
4283
|
path: {
|
|
3561
|
-
report_id:
|
|
4284
|
+
report_id: reportId
|
|
3562
4285
|
}
|
|
3563
4286
|
},
|
|
3564
4287
|
parseAs: format
|
|
@@ -3617,7 +4340,7 @@ var MageMetricsClient = class {
|
|
|
3617
4340
|
{
|
|
3618
4341
|
params: {
|
|
3619
4342
|
path: {
|
|
3620
|
-
report_id: reportId
|
|
4343
|
+
report_id: reportId
|
|
3621
4344
|
},
|
|
3622
4345
|
query: {
|
|
3623
4346
|
columns: columns?.join(","),
|
|
@@ -3655,7 +4378,7 @@ var MageMetricsClient = class {
|
|
|
3655
4378
|
return data;
|
|
3656
4379
|
},
|
|
3657
4380
|
getReport: async (reportId) => {
|
|
3658
|
-
const params = { params: { path: { report_id:
|
|
4381
|
+
const params = { params: { path: { report_id: reportId } } };
|
|
3659
4382
|
const columnsPromise = this.internalApiClient.GET(
|
|
3660
4383
|
GetReportColumns.path,
|
|
3661
4384
|
params
|