@speakai/mcp-server 1.24.1 → 1.26.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/README.md +8 -3
- package/dist/index.js +1226 -62
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -283,7 +283,7 @@ var init_auth = __esm({
|
|
|
283
283
|
});
|
|
284
284
|
|
|
285
285
|
// node_modules/@speakai/shared/dist/enums/automation.js
|
|
286
|
-
var AutomationTrigger, AutomationAction, AutomationRunType, AutomationScheduleTimePeriod, AssistantType;
|
|
286
|
+
var AutomationTrigger, AutomationAction, AutomationStepType, AutomationRunStatus, AutomationIOType, AutomationRunType, AutomationScheduleTimePeriod, AssistantType;
|
|
287
287
|
var init_automation = __esm({
|
|
288
288
|
"node_modules/@speakai/shared/dist/enums/automation.js"() {
|
|
289
289
|
"use strict";
|
|
@@ -291,11 +291,38 @@ var init_automation = __esm({
|
|
|
291
291
|
AutomationTrigger2["FOLDERS"] = "folders";
|
|
292
292
|
AutomationTrigger2["TAGS"] = "tags";
|
|
293
293
|
AutomationTrigger2["KEYWORDS"] = "keywords";
|
|
294
|
+
AutomationTrigger2["COMPOSIO"] = "composio";
|
|
295
|
+
AutomationTrigger2["WEBHOOK"] = "webhook";
|
|
294
296
|
})(AutomationTrigger || (AutomationTrigger = {}));
|
|
295
297
|
(function(AutomationAction2) {
|
|
296
298
|
AutomationAction2["MAGIC_PROMPT"] = "magic-prompt";
|
|
297
299
|
AutomationAction2["TRANSLATION"] = "translation";
|
|
298
300
|
})(AutomationAction || (AutomationAction = {}));
|
|
301
|
+
(function(AutomationStepType2) {
|
|
302
|
+
AutomationStepType2["TRIGGER"] = "trigger";
|
|
303
|
+
AutomationStepType2["MAGIC_PROMPT"] = "magic-prompt";
|
|
304
|
+
AutomationStepType2["TRANSLATION"] = "translation";
|
|
305
|
+
AutomationStepType2["COMPOSIO_ACTION"] = "composio-action";
|
|
306
|
+
AutomationStepType2["FILTER"] = "filter";
|
|
307
|
+
AutomationStepType2["SPEAK_UPLOAD"] = "speak-upload";
|
|
308
|
+
AutomationStepType2["NOTIFY"] = "notify";
|
|
309
|
+
AutomationStepType2["OUTBOUND_WEBHOOK"] = "outbound-webhook";
|
|
310
|
+
AutomationStepType2["CONDITION"] = "condition";
|
|
311
|
+
})(AutomationStepType || (AutomationStepType = {}));
|
|
312
|
+
(function(AutomationRunStatus2) {
|
|
313
|
+
AutomationRunStatus2["PENDING"] = "pending";
|
|
314
|
+
AutomationRunStatus2["RUNNING"] = "running";
|
|
315
|
+
AutomationRunStatus2["COMPLETED"] = "completed";
|
|
316
|
+
AutomationRunStatus2["FAILED"] = "failed";
|
|
317
|
+
AutomationRunStatus2["KILLED"] = "killed";
|
|
318
|
+
})(AutomationRunStatus || (AutomationRunStatus = {}));
|
|
319
|
+
(function(AutomationIOType2) {
|
|
320
|
+
AutomationIOType2["FILE"] = "file";
|
|
321
|
+
AutomationIOType2["MEDIA"] = "media";
|
|
322
|
+
AutomationIOType2["INSIGHT"] = "insight";
|
|
323
|
+
AutomationIOType2["NOTIFY"] = "notify";
|
|
324
|
+
AutomationIOType2["DATA"] = "data";
|
|
325
|
+
})(AutomationIOType || (AutomationIOType = {}));
|
|
299
326
|
(function(AutomationRunType2) {
|
|
300
327
|
AutomationRunType2["INSTANT"] = "instant";
|
|
301
328
|
AutomationRunType2["SCHEDULE"] = "schedule";
|
|
@@ -387,6 +414,7 @@ var init_embed = __esm({
|
|
|
387
414
|
(function(EmbedType2) {
|
|
388
415
|
EmbedType2["MEDIA_PLAYER"] = "mediaPlayer";
|
|
389
416
|
EmbedType2["REPOSITORY"] = "repository";
|
|
417
|
+
EmbedType2["DASHBOARD"] = "dashboard";
|
|
390
418
|
})(EmbedType || (EmbedType = {}));
|
|
391
419
|
(function(ImageSelectionType2) {
|
|
392
420
|
ImageSelectionType2["LOGO"] = "logo";
|
|
@@ -486,6 +514,18 @@ var init_filter = __esm({
|
|
|
486
514
|
}
|
|
487
515
|
});
|
|
488
516
|
|
|
517
|
+
// node_modules/@speakai/shared/dist/enums/integration.js
|
|
518
|
+
var IntegrationAuthType;
|
|
519
|
+
var init_integration = __esm({
|
|
520
|
+
"node_modules/@speakai/shared/dist/enums/integration.js"() {
|
|
521
|
+
"use strict";
|
|
522
|
+
(function(IntegrationAuthType2) {
|
|
523
|
+
IntegrationAuthType2["OAUTH"] = "oauth";
|
|
524
|
+
IntegrationAuthType2["API_KEY"] = "api_key";
|
|
525
|
+
})(IntegrationAuthType || (IntegrationAuthType = {}));
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
|
|
489
529
|
// node_modules/@speakai/shared/dist/enums/media.js
|
|
490
530
|
var MediaType, MediaState, MediaPrivacyMode, MediaInsightType, MediaInsightStatus, MediaProcessType;
|
|
491
531
|
var init_media = __esm({
|
|
@@ -963,10 +1003,72 @@ var init_webhook = __esm({
|
|
|
963
1003
|
(function(WebhookEventSource2) {
|
|
964
1004
|
WebhookEventSource2["SPEAK"] = "speak";
|
|
965
1005
|
WebhookEventSource2["ZAPIER"] = "zapier";
|
|
1006
|
+
WebhookEventSource2["N8N"] = "n8n";
|
|
1007
|
+
WebhookEventSource2["PIPEDREAM"] = "pipedream";
|
|
1008
|
+
WebhookEventSource2["MAKE"] = "make";
|
|
966
1009
|
})(WebhookEventSource || (WebhookEventSource = {}));
|
|
967
1010
|
}
|
|
968
1011
|
});
|
|
969
1012
|
|
|
1013
|
+
// node_modules/@speakai/shared/dist/enums/llm.js
|
|
1014
|
+
var LLMProvider, LLMModels;
|
|
1015
|
+
var init_llm = __esm({
|
|
1016
|
+
"node_modules/@speakai/shared/dist/enums/llm.js"() {
|
|
1017
|
+
"use strict";
|
|
1018
|
+
(function(LLMProvider2) {
|
|
1019
|
+
LLMProvider2["OPENAI"] = "openai";
|
|
1020
|
+
LLMProvider2["GOOGLE"] = "google";
|
|
1021
|
+
LLMProvider2["ANTHROPIC"] = "anthropic";
|
|
1022
|
+
LLMProvider2["OPENROUTER"] = "openrouter";
|
|
1023
|
+
})(LLMProvider || (LLMProvider = {}));
|
|
1024
|
+
(function(LLMModels2) {
|
|
1025
|
+
LLMModels2["GPT_3_5"] = "gpt-3.5";
|
|
1026
|
+
LLMModels2["GPT_3_5_TURBO_16K"] = "gpt-3.5-turbo-16k";
|
|
1027
|
+
LLMModels2["GPT_3_5_TURBO_0125"] = "gpt-3.5-turbo-0125";
|
|
1028
|
+
LLMModels2["GPT_4"] = "gpt-4";
|
|
1029
|
+
LLMModels2["GPT_4_1106_PREVIEW"] = "gpt-4-1106-preview";
|
|
1030
|
+
LLMModels2["GPT_4_TURBO"] = "gpt-4-turbo";
|
|
1031
|
+
LLMModels2["GPT_4_O_2024_05_13"] = "gpt-4o-2024-05-13";
|
|
1032
|
+
LLMModels2["GPT_4O"] = "gpt-4o";
|
|
1033
|
+
LLMModels2["GPT_4O_MINI"] = "gpt-4o-mini";
|
|
1034
|
+
LLMModels2["GPT_4_O_2024_08_06"] = "gpt-4o-2024-08-06";
|
|
1035
|
+
LLMModels2["GPT_4_MINI_2024_07_18"] = "gpt-4o-mini-2024-07-18";
|
|
1036
|
+
LLMModels2["GPT_4_1_2025_04_14"] = "gpt-4.1-2025-04-14";
|
|
1037
|
+
LLMModels2["GPT_5_1_2025_11_13"] = "gpt-5.1-2025-11-13";
|
|
1038
|
+
LLMModels2["GPT_5_2"] = "gpt-5.2";
|
|
1039
|
+
LLMModels2["GPT_5_4"] = "gpt-5.4";
|
|
1040
|
+
LLMModels2["GPT_5_4_MINI"] = "gpt-5.4-mini";
|
|
1041
|
+
LLMModels2["GPT_5_4_MINI_2026_03_17"] = "gpt-5.4-mini-2026-03-17";
|
|
1042
|
+
LLMModels2["GPT_5_4_NANO"] = "gpt-5.4-nano";
|
|
1043
|
+
LLMModels2["GPT_5_5"] = "gpt-5.5";
|
|
1044
|
+
LLMModels2["GPT_5_5_THINKING"] = "gpt-5.5-thinking";
|
|
1045
|
+
LLMModels2["GPT_5_6_SOL"] = "gpt-5.6-sol";
|
|
1046
|
+
LLMModels2["GPT_5_6_TERRA"] = "gpt-5.6-terra";
|
|
1047
|
+
LLMModels2["GPT_5_6_LUNA"] = "gpt-5.6-luna";
|
|
1048
|
+
LLMModels2["CLAUDE_2"] = "claude-2";
|
|
1049
|
+
LLMModels2["CLAUDE_3_5_SONNET"] = "claude-3-5-sonnet";
|
|
1050
|
+
LLMModels2["CLAUDE_3_5_SONNET_20241022"] = "claude-3-5-sonnet-20241022";
|
|
1051
|
+
LLMModels2["CLAUDE_3_7_SONNET_LATEST"] = "claude-3-7-sonnet-latest";
|
|
1052
|
+
LLMModels2["CLAUDE_HAIKU_4_5"] = "claude-haiku-4-5";
|
|
1053
|
+
LLMModels2["CLAUDE_SONNET_4_6"] = "claude-sonnet-4-6";
|
|
1054
|
+
LLMModels2["CLAUDE_SONNET_5"] = "claude-sonnet-5";
|
|
1055
|
+
LLMModels2["CLAUDE_OPUS_4_8"] = "claude-opus-4-8";
|
|
1056
|
+
LLMModels2["GEMINI_1_5_PRO"] = "gemini-1.5-pro";
|
|
1057
|
+
LLMModels2["GEMINI_1_5_FLASH"] = "gemini-1.5-flash";
|
|
1058
|
+
LLMModels2["GEMINI_2_0_FLASH"] = "gemini-2.0-flash";
|
|
1059
|
+
LLMModels2["GEMINI_2_5_PRO"] = "gemini-2.5-pro";
|
|
1060
|
+
LLMModels2["GEMINI_2_5_FLASH"] = "gemini-2.5-flash";
|
|
1061
|
+
LLMModels2["GEMINI_2_5_FLASH_LITE"] = "gemini-2.5-flash-lite";
|
|
1062
|
+
LLMModels2["GEMINI_3_FLASH_PREVIEW"] = "gemini-3-flash-preview";
|
|
1063
|
+
LLMModels2["GEMINI_3_1_FLASH_LITE"] = "gemini-3.1-flash-lite";
|
|
1064
|
+
LLMModels2["GEMINI_3_1_PRO_PREVIEW"] = "gemini-3.1-pro-preview";
|
|
1065
|
+
LLMModels2["GEMINI_3_5_FLASH"] = "gemini-3.5-flash";
|
|
1066
|
+
LLMModels2["GROK_4_5"] = "x-ai/grok-4.5";
|
|
1067
|
+
LLMModels2["GLM_5_2"] = "z-ai/glm-5.2";
|
|
1068
|
+
})(LLMModels || (LLMModels = {}));
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1071
|
+
|
|
970
1072
|
// node_modules/@speakai/shared/dist/enums/index.js
|
|
971
1073
|
var init_enums = __esm({
|
|
972
1074
|
"node_modules/@speakai/shared/dist/enums/index.js"() {
|
|
@@ -981,6 +1083,7 @@ var init_enums = __esm({
|
|
|
981
1083
|
init_export();
|
|
982
1084
|
init_fields();
|
|
983
1085
|
init_filter();
|
|
1086
|
+
init_integration();
|
|
984
1087
|
init_media();
|
|
985
1088
|
init_meeting();
|
|
986
1089
|
init_notification();
|
|
@@ -993,6 +1096,7 @@ var init_enums = __esm({
|
|
|
993
1096
|
init_translation();
|
|
994
1097
|
init_user();
|
|
995
1098
|
init_webhook();
|
|
1099
|
+
init_llm();
|
|
996
1100
|
}
|
|
997
1101
|
});
|
|
998
1102
|
|
|
@@ -1031,6 +1135,13 @@ var init_folder = __esm({
|
|
|
1031
1135
|
}
|
|
1032
1136
|
});
|
|
1033
1137
|
|
|
1138
|
+
// node_modules/@speakai/shared/dist/interfaces/integration.js
|
|
1139
|
+
var init_integration2 = __esm({
|
|
1140
|
+
"node_modules/@speakai/shared/dist/interfaces/integration.js"() {
|
|
1141
|
+
"use strict";
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
|
|
1034
1145
|
// node_modules/@speakai/shared/dist/interfaces/recorder.js
|
|
1035
1146
|
var init_recorder2 = __esm({
|
|
1036
1147
|
"node_modules/@speakai/shared/dist/interfaces/recorder.js"() {
|
|
@@ -1122,6 +1233,21 @@ var init_clip2 = __esm({
|
|
|
1122
1233
|
}
|
|
1123
1234
|
});
|
|
1124
1235
|
|
|
1236
|
+
// node_modules/@speakai/shared/dist/utils/dashboard-spec.js
|
|
1237
|
+
var init_dashboard_spec = __esm({
|
|
1238
|
+
"node_modules/@speakai/shared/dist/utils/dashboard-spec.js"() {
|
|
1239
|
+
"use strict";
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
|
|
1243
|
+
// node_modules/@speakai/shared/dist/interfaces/dashboard.js
|
|
1244
|
+
var init_dashboard = __esm({
|
|
1245
|
+
"node_modules/@speakai/shared/dist/interfaces/dashboard.js"() {
|
|
1246
|
+
"use strict";
|
|
1247
|
+
init_dashboard_spec();
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1125
1251
|
// node_modules/@speakai/shared/dist/interfaces/index.js
|
|
1126
1252
|
var init_interfaces = __esm({
|
|
1127
1253
|
"node_modules/@speakai/shared/dist/interfaces/index.js"() {
|
|
@@ -1131,6 +1257,7 @@ var init_interfaces = __esm({
|
|
|
1131
1257
|
init_transcript();
|
|
1132
1258
|
init_text();
|
|
1133
1259
|
init_folder();
|
|
1260
|
+
init_integration2();
|
|
1134
1261
|
init_recorder2();
|
|
1135
1262
|
init_embed2();
|
|
1136
1263
|
init_automation2();
|
|
@@ -1144,6 +1271,7 @@ var init_interfaces = __esm({
|
|
|
1144
1271
|
init_calendar2();
|
|
1145
1272
|
init_category();
|
|
1146
1273
|
init_clip2();
|
|
1274
|
+
init_dashboard();
|
|
1147
1275
|
}
|
|
1148
1276
|
});
|
|
1149
1277
|
|
|
@@ -1154,6 +1282,70 @@ var init_transcript2 = __esm({
|
|
|
1154
1282
|
}
|
|
1155
1283
|
});
|
|
1156
1284
|
|
|
1285
|
+
// node_modules/@speakai/shared/dist/pricing/modelPricing.js
|
|
1286
|
+
var MODEL_PRICING;
|
|
1287
|
+
var init_modelPricing = __esm({
|
|
1288
|
+
"node_modules/@speakai/shared/dist/pricing/modelPricing.js"() {
|
|
1289
|
+
"use strict";
|
|
1290
|
+
init_llm();
|
|
1291
|
+
MODEL_PRICING = {
|
|
1292
|
+
// ═══════════════ OpenAI ═══════════════
|
|
1293
|
+
// Deprecated
|
|
1294
|
+
[LLMModels.GPT_3_5]: { inputPerMillion: 0.5, outputPerMillion: 1.5, provider: LLMProvider.OPENAI },
|
|
1295
|
+
[LLMModels.GPT_3_5_TURBO_16K]: { inputPerMillion: 3, outputPerMillion: 4, provider: LLMProvider.OPENAI },
|
|
1296
|
+
[LLMModels.GPT_3_5_TURBO_0125]: { inputPerMillion: 0.5, outputPerMillion: 1.5, provider: LLMProvider.OPENAI },
|
|
1297
|
+
[LLMModels.GPT_4]: { inputPerMillion: 30, outputPerMillion: 60, provider: LLMProvider.OPENAI },
|
|
1298
|
+
[LLMModels.GPT_4_1106_PREVIEW]: { inputPerMillion: 10, outputPerMillion: 30, provider: LLMProvider.OPENAI },
|
|
1299
|
+
[LLMModels.GPT_4_TURBO]: { inputPerMillion: 10, outputPerMillion: 30, provider: LLMProvider.OPENAI },
|
|
1300
|
+
[LLMModels.GPT_4_O_2024_05_13]: { inputPerMillion: 5, outputPerMillion: 15, provider: LLMProvider.OPENAI },
|
|
1301
|
+
// Live
|
|
1302
|
+
[LLMModels.GPT_4O]: { inputPerMillion: 2.5, outputPerMillion: 10, cachedInputPerMillion: 1.25, provider: LLMProvider.OPENAI },
|
|
1303
|
+
[LLMModels.GPT_4O_MINI]: { inputPerMillion: 0.15, outputPerMillion: 0.6, cachedInputPerMillion: 0.075, provider: LLMProvider.OPENAI },
|
|
1304
|
+
[LLMModels.GPT_4_O_2024_08_06]: { inputPerMillion: 2.5, outputPerMillion: 10, cachedInputPerMillion: 1.25, provider: LLMProvider.OPENAI },
|
|
1305
|
+
[LLMModels.GPT_4_MINI_2024_07_18]: { inputPerMillion: 0.15, outputPerMillion: 0.6, cachedInputPerMillion: 0.075, provider: LLMProvider.OPENAI },
|
|
1306
|
+
[LLMModels.GPT_4_1_2025_04_14]: { inputPerMillion: 2, outputPerMillion: 8, cachedInputPerMillion: 0.5, provider: LLMProvider.OPENAI },
|
|
1307
|
+
[LLMModels.GPT_5_1_2025_11_13]: { inputPerMillion: 1.25, outputPerMillion: 10, cachedInputPerMillion: 0.125, provider: LLMProvider.OPENAI },
|
|
1308
|
+
[LLMModels.GPT_5_2]: { inputPerMillion: 1.75, outputPerMillion: 14, cachedInputPerMillion: 0.175, provider: LLMProvider.OPENAI },
|
|
1309
|
+
[LLMModels.GPT_5_4]: { inputPerMillion: 2.5, outputPerMillion: 15, cachedInputPerMillion: 0.25, longContextThresholdTokens: 272e3, inputPerMillionLong: 5, outputPerMillionLong: 22.5, cachedInputPerMillionLong: 0.5, provider: LLMProvider.OPENAI },
|
|
1310
|
+
[LLMModels.GPT_5_4_MINI]: { inputPerMillion: 0.75, outputPerMillion: 4.5, cachedInputPerMillion: 0.075, provider: LLMProvider.OPENAI },
|
|
1311
|
+
[LLMModels.GPT_5_4_MINI_2026_03_17]: { inputPerMillion: 0.75, outputPerMillion: 4.5, cachedInputPerMillion: 0.075, provider: LLMProvider.OPENAI },
|
|
1312
|
+
[LLMModels.GPT_5_4_NANO]: { inputPerMillion: 0.2, outputPerMillion: 1.25, cachedInputPerMillion: 0.02, provider: LLMProvider.OPENAI },
|
|
1313
|
+
[LLMModels.GPT_5_5]: { inputPerMillion: 5, outputPerMillion: 30, cachedInputPerMillion: 0.5, longContextThresholdTokens: 272e3, inputPerMillionLong: 10, outputPerMillionLong: 45, cachedInputPerMillionLong: 1, provider: LLMProvider.OPENAI },
|
|
1314
|
+
[LLMModels.GPT_5_5_THINKING]: { inputPerMillion: 5, outputPerMillion: 30, cachedInputPerMillion: 0.5, longContextThresholdTokens: 272e3, inputPerMillionLong: 10, outputPerMillionLong: 45, cachedInputPerMillionLong: 1, provider: LLMProvider.OPENAI },
|
|
1315
|
+
// gpt-5.5 reasoning mode (same rate)
|
|
1316
|
+
[LLMModels.GPT_5_6_SOL]: { inputPerMillion: 5, outputPerMillion: 30, cachedInputPerMillion: 0.5, provider: LLMProvider.OPENAI },
|
|
1317
|
+
[LLMModels.GPT_5_6_TERRA]: { inputPerMillion: 2.5, outputPerMillion: 15, cachedInputPerMillion: 0.25, provider: LLMProvider.OPENAI },
|
|
1318
|
+
[LLMModels.GPT_5_6_LUNA]: { inputPerMillion: 1, outputPerMillion: 6, cachedInputPerMillion: 0.1, provider: LLMProvider.OPENAI },
|
|
1319
|
+
// ═══════════════ Anthropic (cache read = 0.1x input) ═══════════════
|
|
1320
|
+
// Deprecated
|
|
1321
|
+
[LLMModels.CLAUDE_2]: { inputPerMillion: 8, outputPerMillion: 24, provider: LLMProvider.ANTHROPIC },
|
|
1322
|
+
[LLMModels.CLAUDE_3_5_SONNET]: { inputPerMillion: 3, outputPerMillion: 15, cachedInputPerMillion: 0.3, provider: LLMProvider.ANTHROPIC },
|
|
1323
|
+
[LLMModels.CLAUDE_3_5_SONNET_20241022]: { inputPerMillion: 3, outputPerMillion: 15, cachedInputPerMillion: 0.3, provider: LLMProvider.ANTHROPIC },
|
|
1324
|
+
[LLMModels.CLAUDE_3_7_SONNET_LATEST]: { inputPerMillion: 3, outputPerMillion: 15, cachedInputPerMillion: 0.3, provider: LLMProvider.ANTHROPIC },
|
|
1325
|
+
// Live
|
|
1326
|
+
[LLMModels.CLAUDE_HAIKU_4_5]: { inputPerMillion: 1, outputPerMillion: 5, cachedInputPerMillion: 0.1, provider: LLMProvider.ANTHROPIC },
|
|
1327
|
+
[LLMModels.CLAUDE_SONNET_4_6]: { inputPerMillion: 3, outputPerMillion: 15, cachedInputPerMillion: 0.3, provider: LLMProvider.ANTHROPIC },
|
|
1328
|
+
[LLMModels.CLAUDE_SONNET_5]: { inputPerMillion: 3, outputPerMillion: 15, cachedInputPerMillion: 0.3, provider: LLMProvider.ANTHROPIC },
|
|
1329
|
+
[LLMModels.CLAUDE_OPUS_4_8]: { inputPerMillion: 5, outputPerMillion: 25, cachedInputPerMillion: 0.5, provider: LLMProvider.ANTHROPIC },
|
|
1330
|
+
// ═══════════════ Google Gemini ═══════════════
|
|
1331
|
+
// Deprecated
|
|
1332
|
+
[LLMModels.GEMINI_1_5_PRO]: { inputPerMillion: 1.25, outputPerMillion: 5, provider: LLMProvider.GOOGLE },
|
|
1333
|
+
[LLMModels.GEMINI_1_5_FLASH]: { inputPerMillion: 0.075, outputPerMillion: 0.3, cachedInputPerMillion: 0.01875, provider: LLMProvider.GOOGLE },
|
|
1334
|
+
[LLMModels.GEMINI_2_0_FLASH]: { inputPerMillion: 0.1, outputPerMillion: 0.4, cachedInputPerMillion: 0.025, provider: LLMProvider.GOOGLE },
|
|
1335
|
+
// Live
|
|
1336
|
+
[LLMModels.GEMINI_2_5_PRO]: { inputPerMillion: 1.25, outputPerMillion: 10, longContextThresholdTokens: 2e5, inputPerMillionLong: 2.5, outputPerMillionLong: 15, provider: LLMProvider.GOOGLE },
|
|
1337
|
+
[LLMModels.GEMINI_2_5_FLASH]: { inputPerMillion: 0.3, outputPerMillion: 2.5, cachedInputPerMillion: 0.03, provider: LLMProvider.GOOGLE },
|
|
1338
|
+
[LLMModels.GEMINI_2_5_FLASH_LITE]: { inputPerMillion: 0.1, outputPerMillion: 0.4, cachedInputPerMillion: 0.01, provider: LLMProvider.GOOGLE },
|
|
1339
|
+
[LLMModels.GEMINI_3_FLASH_PREVIEW]: { inputPerMillion: 0.5, outputPerMillion: 3, cachedInputPerMillion: 0.05, provider: LLMProvider.GOOGLE },
|
|
1340
|
+
[LLMModels.GEMINI_3_1_FLASH_LITE]: { inputPerMillion: 0.25, outputPerMillion: 1.5, provider: LLMProvider.GOOGLE },
|
|
1341
|
+
[LLMModels.GEMINI_3_1_PRO_PREVIEW]: { inputPerMillion: 2, outputPerMillion: 12, longContextThresholdTokens: 2e5, inputPerMillionLong: 4, outputPerMillionLong: 18, provider: LLMProvider.GOOGLE },
|
|
1342
|
+
[LLMModels.GEMINI_3_5_FLASH]: { inputPerMillion: 1.5, outputPerMillion: 9, cachedInputPerMillion: 0.15, provider: LLMProvider.GOOGLE },
|
|
1343
|
+
[LLMModels.GROK_4_5]: { inputPerMillion: 2.2, outputPerMillion: 6.6, cachedInputPerMillion: 0.22, provider: LLMProvider.OPENROUTER },
|
|
1344
|
+
[LLMModels.GLM_5_2]: { inputPerMillion: 1.023, outputPerMillion: 3.3, cachedInputPerMillion: 0.1023, provider: LLMProvider.OPENROUTER }
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
});
|
|
1348
|
+
|
|
1157
1349
|
// node_modules/@speakai/shared/dist/index.js
|
|
1158
1350
|
var init_dist = __esm({
|
|
1159
1351
|
"node_modules/@speakai/shared/dist/index.js"() {
|
|
@@ -1161,6 +1353,8 @@ var init_dist = __esm({
|
|
|
1161
1353
|
init_enums();
|
|
1162
1354
|
init_interfaces();
|
|
1163
1355
|
init_transcript2();
|
|
1356
|
+
init_dashboard_spec();
|
|
1357
|
+
init_modelPricing();
|
|
1164
1358
|
}
|
|
1165
1359
|
});
|
|
1166
1360
|
|
|
@@ -1922,7 +2116,7 @@ function register2(server, client) {
|
|
|
1922
2116
|
},
|
|
1923
2117
|
async ({ mediaId }) => {
|
|
1924
2118
|
try {
|
|
1925
|
-
const result = await api.get(`/v1/
|
|
2119
|
+
const result = await api.get(`/v1/media/reanalyze/${mediaId}`);
|
|
1926
2120
|
return {
|
|
1927
2121
|
content: [
|
|
1928
2122
|
{ type: "text", text: JSON.stringify(result.data, null, 2) }
|
|
@@ -1957,9 +2151,10 @@ function register2(server, client) {
|
|
|
1957
2151
|
},
|
|
1958
2152
|
async ({ mediaId, ...body }) => {
|
|
1959
2153
|
try {
|
|
2154
|
+
const payload = body.text !== void 0 ? { ...body, rawText: body.text } : body;
|
|
1960
2155
|
const result = await api.put(
|
|
1961
2156
|
`/v1/text/update/${mediaId}`,
|
|
1962
|
-
|
|
2157
|
+
payload
|
|
1963
2158
|
);
|
|
1964
2159
|
return {
|
|
1965
2160
|
content: [
|
|
@@ -2855,13 +3050,14 @@ function register6(server, client) {
|
|
|
2855
3050
|
registerSpeakTool(
|
|
2856
3051
|
server,
|
|
2857
3052
|
"update_embed",
|
|
2858
|
-
"Update an existing embed widget \u2014 appearance/feature toggles via `meta`, plus scope and privacy.",
|
|
3053
|
+
"Update an existing embed widget \u2014 appearance/feature toggles via `meta`, plus scope and privacy. Setting `privacyMode` clears any existing password unless a new one is supplied in the same call.",
|
|
2859
3054
|
{
|
|
2860
3055
|
embedId: import_zod7.z.string().min(1).describe("Unique identifier of the embed"),
|
|
2861
3056
|
mediaId: import_zod7.z.string().optional().describe("Media file the embed points to"),
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
3057
|
+
privacyMode: import_zod7.z.string().optional().describe(
|
|
3058
|
+
"Privacy mode for the embed. Changing this clears the existing password unless `password` is also supplied in the same call."
|
|
3059
|
+
),
|
|
3060
|
+
password: import_zod7.z.string().optional().describe("Password to protect the embed with when privacyMode is private. Only applied when privacyMode is also sent."),
|
|
2865
3061
|
meta: import_zod7.z.record(import_zod7.z.unknown()).optional().describe(
|
|
2866
3062
|
"Embed appearance & feature toggles: { backgroundImg, logo, primaryColor, titleColor, chatWelcomeMessage, assistantTemplateId, isTitle, isDescription, isRemarks, isDataVizDownloadable, isSEOIndexing, isPromptAsk, isPromptHistory, isMediaExport, callToActionButtons:[{ url, label }], features:[{ name, isActive, isCustom? }] }"
|
|
2867
3063
|
)
|
|
@@ -2869,7 +3065,7 @@ function register6(server, client) {
|
|
|
2869
3065
|
{
|
|
2870
3066
|
title: "Update Embed Widget",
|
|
2871
3067
|
readOnlyHint: false,
|
|
2872
|
-
destructiveHint:
|
|
3068
|
+
destructiveHint: true,
|
|
2873
3069
|
idempotentHint: true,
|
|
2874
3070
|
openWorldHint: false
|
|
2875
3071
|
},
|
|
@@ -3910,6 +4106,555 @@ var init_capabilities = __esm({
|
|
|
3910
4106
|
}
|
|
3911
4107
|
});
|
|
3912
4108
|
|
|
4109
|
+
// src/tools/automation-graph.ts
|
|
4110
|
+
function containsCondition(nodes) {
|
|
4111
|
+
return nodes.some(
|
|
4112
|
+
(node) => isConditionNode(node) || LEG_BRANCHES.some((br) => containsCondition(legOf(node, br)))
|
|
4113
|
+
);
|
|
4114
|
+
}
|
|
4115
|
+
function legTails(leg, enclosingConditionId) {
|
|
4116
|
+
if (!leg.length) return [enclosingConditionId];
|
|
4117
|
+
const last = leg[leg.length - 1];
|
|
4118
|
+
if (!isConditionNode(last)) return [last.step.stepId];
|
|
4119
|
+
const rejoining = LEG_BRANCHES.filter((br) => exitOf(last, br) === "rejoin");
|
|
4120
|
+
if (!rejoining.length) return [];
|
|
4121
|
+
return uniq(rejoining.flatMap((br) => legTails(legOf(last, br), last.step.stepId)));
|
|
4122
|
+
}
|
|
4123
|
+
function flatten(nodes, parentIds = [], branch) {
|
|
4124
|
+
const out = [];
|
|
4125
|
+
let incoming = parentIds;
|
|
4126
|
+
let incomingBranch = branch;
|
|
4127
|
+
for (const node of nodes) {
|
|
4128
|
+
out.push({
|
|
4129
|
+
node,
|
|
4130
|
+
dependsOn: uniq(incoming),
|
|
4131
|
+
...incomingBranch ? { branch: incomingBranch } : {}
|
|
4132
|
+
});
|
|
4133
|
+
if (!isConditionNode(node)) {
|
|
4134
|
+
incoming = [node.step.stepId];
|
|
4135
|
+
incomingBranch = branch;
|
|
4136
|
+
continue;
|
|
4137
|
+
}
|
|
4138
|
+
for (const br of LEG_BRANCHES) {
|
|
4139
|
+
out.push(...flatten(legOf(node, br), [node.step.stepId], br));
|
|
4140
|
+
}
|
|
4141
|
+
const rejoining = LEG_BRANCHES.filter((br) => exitOf(node, br) === "rejoin");
|
|
4142
|
+
incoming = uniq(rejoining.flatMap((br) => legTails(legOf(node, br), node.step.stepId)));
|
|
4143
|
+
incomingBranch = rejoining.length === 1 && !legOf(node, rejoining[0]).length ? rejoining[0] : branch;
|
|
4144
|
+
}
|
|
4145
|
+
return out;
|
|
4146
|
+
}
|
|
4147
|
+
function compileGraph(nodes) {
|
|
4148
|
+
const branched = containsCondition(nodes);
|
|
4149
|
+
return flatten(nodes).map(({ node, dependsOn, branch }) => ({
|
|
4150
|
+
...node.step,
|
|
4151
|
+
...branched ? { dependsOn } : {},
|
|
4152
|
+
...branch ? { branch } : {}
|
|
4153
|
+
}));
|
|
4154
|
+
}
|
|
4155
|
+
function hydrateLegs(steps) {
|
|
4156
|
+
const byParent = /* @__PURE__ */ new Map();
|
|
4157
|
+
for (const step of steps) {
|
|
4158
|
+
for (const parent of step.dependsOn ?? []) {
|
|
4159
|
+
const list = byParent.get(parent) ?? [];
|
|
4160
|
+
list.push(step);
|
|
4161
|
+
byParent.set(parent, list);
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4164
|
+
const referenced = new Set(steps.flatMap((step) => step.dependsOn ?? []));
|
|
4165
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
4166
|
+
function legReaches(leg, conditionId, legMemberIds) {
|
|
4167
|
+
if (!leg.length) {
|
|
4168
|
+
return steps.some(
|
|
4169
|
+
(step) => step.stepId !== conditionId && !legMemberIds.has(step.stepId) && (step.dependsOn ?? []).includes(conditionId)
|
|
4170
|
+
);
|
|
4171
|
+
}
|
|
4172
|
+
const tails = legTails(leg, conditionId);
|
|
4173
|
+
if (!tails.length) return true;
|
|
4174
|
+
return tails.some((id) => referenced.has(id));
|
|
4175
|
+
}
|
|
4176
|
+
function buildLeg(conditionId, branch) {
|
|
4177
|
+
const leg = [];
|
|
4178
|
+
let cursor = conditionId;
|
|
4179
|
+
for (; ; ) {
|
|
4180
|
+
const next = (byParent.get(cursor) ?? []).find(
|
|
4181
|
+
(step) => step.branch === branch && !claimed.has(step.stepId)
|
|
4182
|
+
);
|
|
4183
|
+
if (!next) break;
|
|
4184
|
+
claimed.add(next.stepId);
|
|
4185
|
+
leg.push(next.stepType === CONDITION_STEP_TYPE ? withLegs(next) : { step: next });
|
|
4186
|
+
cursor = next.stepId;
|
|
4187
|
+
}
|
|
4188
|
+
return leg;
|
|
4189
|
+
}
|
|
4190
|
+
function withLegs(condition) {
|
|
4191
|
+
const legs = {
|
|
4192
|
+
true: buildLeg(condition.stepId, "true"),
|
|
4193
|
+
false: buildLeg(condition.stepId, "false")
|
|
4194
|
+
};
|
|
4195
|
+
const legMemberIds = new Set(
|
|
4196
|
+
[...legs.true, ...legs.false].map((node) => node.step.stepId)
|
|
4197
|
+
);
|
|
4198
|
+
return {
|
|
4199
|
+
step: condition,
|
|
4200
|
+
legs,
|
|
4201
|
+
legExit: {
|
|
4202
|
+
true: legReaches(legs.true, condition.stepId, legMemberIds) ? "rejoin" : "end",
|
|
4203
|
+
false: legReaches(legs.false, condition.stepId, legMemberIds) ? "rejoin" : "end"
|
|
4204
|
+
}
|
|
4205
|
+
};
|
|
4206
|
+
}
|
|
4207
|
+
const nested = /* @__PURE__ */ new Map();
|
|
4208
|
+
for (const step of steps) {
|
|
4209
|
+
if (claimed.has(step.stepId)) continue;
|
|
4210
|
+
if (step.stepType === CONDITION_STEP_TYPE) nested.set(step.stepId, withLegs(step));
|
|
4211
|
+
}
|
|
4212
|
+
return steps.filter((step) => !claimed.has(step.stepId)).map((step) => nested.get(step.stepId) ?? { step });
|
|
4213
|
+
}
|
|
4214
|
+
function resolveIncomingTypes(steps, rootType) {
|
|
4215
|
+
const byId = new Map(steps.map((step) => [step.stepId, step]));
|
|
4216
|
+
const incoming = /* @__PURE__ */ new Map();
|
|
4217
|
+
const resolving = /* @__PURE__ */ new Set();
|
|
4218
|
+
const outputsOf = (step, into2) => {
|
|
4219
|
+
const io = ACTION_IO[step.stepType];
|
|
4220
|
+
if (!io) return into2;
|
|
4221
|
+
if (io.passthrough) return into2;
|
|
4222
|
+
return /* @__PURE__ */ new Set([io.out]);
|
|
4223
|
+
};
|
|
4224
|
+
const into = (step) => {
|
|
4225
|
+
const cached2 = incoming.get(step.stepId);
|
|
4226
|
+
if (cached2) return cached2;
|
|
4227
|
+
if (resolving.has(step.stepId)) return /* @__PURE__ */ new Set([rootType]);
|
|
4228
|
+
resolving.add(step.stepId);
|
|
4229
|
+
const parents = (step.dependsOn ?? []).map((id) => byId.get(id)).filter((parent) => parent !== void 0);
|
|
4230
|
+
const types = parents.length ? new Set(parents.flatMap((parent) => [...outputsOf(parent, into(parent))])) : /* @__PURE__ */ new Set([rootType]);
|
|
4231
|
+
resolving.delete(step.stepId);
|
|
4232
|
+
incoming.set(step.stepId, types);
|
|
4233
|
+
return types;
|
|
4234
|
+
};
|
|
4235
|
+
steps.forEach(into);
|
|
4236
|
+
return incoming;
|
|
4237
|
+
}
|
|
4238
|
+
function incomingTypesByStep(steps, rootType) {
|
|
4239
|
+
const hasDependencies = steps.some((step) => (step.dependsOn ?? []).length > 0);
|
|
4240
|
+
if (hasDependencies) return resolveIncomingTypes(steps, rootType);
|
|
4241
|
+
const byStep = /* @__PURE__ */ new Map();
|
|
4242
|
+
let cursor = rootType;
|
|
4243
|
+
for (const step of steps) {
|
|
4244
|
+
byStep.set(step.stepId, /* @__PURE__ */ new Set([cursor]));
|
|
4245
|
+
const io = ACTION_IO[step.stepType];
|
|
4246
|
+
if (io && !io.passthrough) cursor = io.out;
|
|
4247
|
+
}
|
|
4248
|
+
return byStep;
|
|
4249
|
+
}
|
|
4250
|
+
function mediaAvailabilityByStep(steps, rootType) {
|
|
4251
|
+
const available = /* @__PURE__ */ new Map();
|
|
4252
|
+
const rootHasMedia = rootType === "media";
|
|
4253
|
+
const byId = new Map(steps.map((step) => [step.stepId, step]));
|
|
4254
|
+
const hasDependencies = steps.some((step) => (step.dependsOn ?? []).length > 0);
|
|
4255
|
+
if (!hasDependencies) {
|
|
4256
|
+
let seen = rootHasMedia;
|
|
4257
|
+
for (const step of steps) {
|
|
4258
|
+
available.set(step.stepId, seen);
|
|
4259
|
+
if (step.stepType === "speak-upload") seen = true;
|
|
4260
|
+
}
|
|
4261
|
+
return available;
|
|
4262
|
+
}
|
|
4263
|
+
const resolving = /* @__PURE__ */ new Set();
|
|
4264
|
+
const at = (stepId) => {
|
|
4265
|
+
const cached2 = available.get(stepId);
|
|
4266
|
+
if (cached2 !== void 0) return cached2;
|
|
4267
|
+
if (resolving.has(stepId)) return rootHasMedia;
|
|
4268
|
+
resolving.add(stepId);
|
|
4269
|
+
const parents = (byId.get(stepId)?.dependsOn ?? []).filter((id) => byId.has(id));
|
|
4270
|
+
const result = parents.length ? parents.every((id) => byId.get(id).stepType === "speak-upload" || at(id)) : rootHasMedia;
|
|
4271
|
+
resolving.delete(stepId);
|
|
4272
|
+
available.set(stepId, result);
|
|
4273
|
+
return result;
|
|
4274
|
+
};
|
|
4275
|
+
for (const step of steps) at(step.stepId);
|
|
4276
|
+
return available;
|
|
4277
|
+
}
|
|
4278
|
+
function validateGraph(steps, opts = {}) {
|
|
4279
|
+
const errors = [];
|
|
4280
|
+
const warnings = [];
|
|
4281
|
+
if (!Array.isArray(steps) || steps.length === 0) {
|
|
4282
|
+
return { errors: ["The automation needs at least one step."], warnings };
|
|
4283
|
+
}
|
|
4284
|
+
if (steps.length > MAX_STEPS) {
|
|
4285
|
+
errors.push(
|
|
4286
|
+
`An automation can hold ${MAX_STEPS} steps; this one has ${steps.length}. A branch spends steps quickly \u2014 a condition plus two two-step legs plus a merge is six.`
|
|
4287
|
+
);
|
|
4288
|
+
}
|
|
4289
|
+
const byId = /* @__PURE__ */ new Map();
|
|
4290
|
+
for (const step of steps) {
|
|
4291
|
+
if (!step.stepId) {
|
|
4292
|
+
errors.push("Every step needs a stepId.");
|
|
4293
|
+
continue;
|
|
4294
|
+
}
|
|
4295
|
+
if (byId.has(step.stepId)) errors.push(`Two steps share the id "${step.stepId}".`);
|
|
4296
|
+
byId.set(step.stepId, step);
|
|
4297
|
+
}
|
|
4298
|
+
for (const step of steps) {
|
|
4299
|
+
if (step.stepId && !/^[A-Za-z_]/.test(step.stepId)) {
|
|
4300
|
+
warnings.push(
|
|
4301
|
+
`Step id "${step.stepId}" does not start with a letter, so a whole-value {{step.${step.stepId}.\u2026}} token inside a Composio argsTemplate arrives as text instead of keeping its type.`
|
|
4302
|
+
);
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4305
|
+
for (const step of steps) {
|
|
4306
|
+
for (const parentId of step.dependsOn ?? []) {
|
|
4307
|
+
if (!byId.has(parentId)) {
|
|
4308
|
+
errors.push(`Step "${step.stepId}" depends on "${parentId}", which is not in this automation.`);
|
|
4309
|
+
}
|
|
4310
|
+
}
|
|
4311
|
+
}
|
|
4312
|
+
const hasDependencies = steps.some((step) => (step.dependsOn ?? []).length > 0);
|
|
4313
|
+
if (hasDependencies) {
|
|
4314
|
+
const state = /* @__PURE__ */ new Map();
|
|
4315
|
+
const walk = (id) => {
|
|
4316
|
+
const status = state.get(id);
|
|
4317
|
+
if (status === 1) return false;
|
|
4318
|
+
if (status === 0) return true;
|
|
4319
|
+
state.set(id, 0);
|
|
4320
|
+
for (const parent of byId.get(id)?.dependsOn ?? []) {
|
|
4321
|
+
if (byId.has(parent) && walk(parent)) return true;
|
|
4322
|
+
}
|
|
4323
|
+
state.set(id, 1);
|
|
4324
|
+
return false;
|
|
4325
|
+
};
|
|
4326
|
+
for (const step of steps) {
|
|
4327
|
+
if (step.stepId && walk(step.stepId)) {
|
|
4328
|
+
errors.push(`The steps form a loop through "${step.stepId}" \u2014 a step cannot depend on itself, directly or indirectly.`);
|
|
4329
|
+
break;
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
}
|
|
4333
|
+
const branchedSteps = steps.filter((step) => step.branch === "true" || step.branch === "false");
|
|
4334
|
+
const conditionSteps = steps.filter((step) => step.stepType === CONDITION_STEP_TYPE);
|
|
4335
|
+
const isBranched = branchedSteps.length > 0 || conditionSteps.length > 0;
|
|
4336
|
+
for (const step of steps) {
|
|
4337
|
+
if (step.stepType !== CONDITION_STEP_TYPE && step.stepType !== FILTER_STEP_TYPE) continue;
|
|
4338
|
+
const block = ruleBlockOf(step);
|
|
4339
|
+
const rules = block?.rules ?? [];
|
|
4340
|
+
if (!rules.length) {
|
|
4341
|
+
errors.push(
|
|
4342
|
+
step.stepType === CONDITION_STEP_TYPE ? `Condition "${step.stepId}" has no rules. An empty rule set counts as a match, so every run would take the "true" branch.` : `Filter "${step.stepId}" has no rules.`
|
|
4343
|
+
);
|
|
4344
|
+
}
|
|
4345
|
+
if (rules.length > 20) {
|
|
4346
|
+
errors.push(`Step "${step.stepId}" has ${rules.length} rules; the limit is 20.`);
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
if (isBranched) {
|
|
4350
|
+
const anchorsOf = (stepId, seen = /* @__PURE__ */ new Set()) => {
|
|
4351
|
+
const found = /* @__PURE__ */ new Set();
|
|
4352
|
+
if (seen.has(stepId)) return found;
|
|
4353
|
+
seen.add(stepId);
|
|
4354
|
+
const self = byId.get(stepId);
|
|
4355
|
+
for (const parentId of self?.dependsOn ?? []) {
|
|
4356
|
+
const parent = byId.get(parentId);
|
|
4357
|
+
if (!parent) continue;
|
|
4358
|
+
if (parent.stepType === CONDITION_STEP_TYPE) found.add(parent.stepId);
|
|
4359
|
+
else if (parent.branch && parent.branch === self?.branch) {
|
|
4360
|
+
for (const id of anchorsOf(parent.stepId, seen)) found.add(id);
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
return found;
|
|
4364
|
+
};
|
|
4365
|
+
const ancestorsOf = (stepId) => {
|
|
4366
|
+
const out = /* @__PURE__ */ new Set();
|
|
4367
|
+
const stack = [...byId.get(stepId)?.dependsOn ?? []];
|
|
4368
|
+
while (stack.length) {
|
|
4369
|
+
const id = stack.pop();
|
|
4370
|
+
if (out.has(id) || !byId.has(id)) continue;
|
|
4371
|
+
out.add(id);
|
|
4372
|
+
stack.push(...byId.get(id)?.dependsOn ?? []);
|
|
4373
|
+
}
|
|
4374
|
+
return out;
|
|
4375
|
+
};
|
|
4376
|
+
const anchored = /* @__PURE__ */ new Set();
|
|
4377
|
+
for (const step of branchedSteps) {
|
|
4378
|
+
const anchors = anchorsOf(step.stepId);
|
|
4379
|
+
if (!anchors.size) {
|
|
4380
|
+
errors.push(
|
|
4381
|
+
`Step "${step.stepId}" is marked as the "${step.branch}" branch but nothing connects it to a condition, so it would run on every path.`
|
|
4382
|
+
);
|
|
4383
|
+
continue;
|
|
4384
|
+
}
|
|
4385
|
+
for (const id of anchors) anchored.add(id);
|
|
4386
|
+
const opposite = [...ancestorsOf(step.stepId)].map((id) => byId.get(id)).find(
|
|
4387
|
+
(ancestor) => (ancestor?.branch === "true" || ancestor?.branch === "false") && ancestor.branch !== step.branch && [...anchorsOf(ancestor.stepId)].some((id) => anchors.has(id))
|
|
4388
|
+
);
|
|
4389
|
+
if (opposite) {
|
|
4390
|
+
errors.push(
|
|
4391
|
+
`Step "${step.stepId}" (on the "${step.branch}" branch) waits on "${opposite.stepId}", which is on the other branch of the same condition \u2014 so it can never run.`
|
|
4392
|
+
);
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4395
|
+
for (const condition of conditionSteps) {
|
|
4396
|
+
if (!anchored.has(condition.stepId)) {
|
|
4397
|
+
errors.push(
|
|
4398
|
+
`Condition "${condition.stepId}" has no steps on either side, so both paths do the same thing. Put a step on one of its branches, or use a filter to stop the run instead.`
|
|
4399
|
+
);
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
const roots = steps.filter((step) => !(step.dependsOn ?? []).length);
|
|
4403
|
+
if (branchedSteps.length && roots.length > 1) {
|
|
4404
|
+
errors.push(
|
|
4405
|
+
`A branched automation must have a single entry step, but ${roots.length} steps declare no dependsOn (${roots.map((step) => `"${step.stepId}"`).join(", ")}) \u2014 each of those would run on every branch. Give every step after the first a dependsOn.`
|
|
4406
|
+
);
|
|
4407
|
+
}
|
|
4408
|
+
}
|
|
4409
|
+
if (opts.runType === "schedule" && conditionSteps.length) {
|
|
4410
|
+
errors.push(
|
|
4411
|
+
'A scheduled automation cannot branch. A schedule runs over a batch of media and a condition resolves once for the whole batch \u2014 it answers "true" when any one media matches and narrows nothing, so the branch would run against media that did not match. Use a filter, which narrows the batch.'
|
|
4412
|
+
);
|
|
4413
|
+
}
|
|
4414
|
+
if (isBranched) {
|
|
4415
|
+
const tree = hydrateLegs(steps);
|
|
4416
|
+
errors.push(...branchingReloadErrors(tree, 1));
|
|
4417
|
+
const rebuilt = new Map(compileGraph(tree).map((step) => [step.stepId, step]));
|
|
4418
|
+
const structurallyMoved = [];
|
|
4419
|
+
const reordered = [];
|
|
4420
|
+
for (const step of steps) {
|
|
4421
|
+
const after = rebuilt.get(step.stepId);
|
|
4422
|
+
if (!after) {
|
|
4423
|
+
structurallyMoved.push(step.stepId);
|
|
4424
|
+
continue;
|
|
4425
|
+
}
|
|
4426
|
+
const before = step.dependsOn ?? [];
|
|
4427
|
+
const now = after.dependsOn ?? [];
|
|
4428
|
+
if (step.branch !== after.branch || before.length !== now.length || now.some((id) => !before.includes(id))) {
|
|
4429
|
+
structurallyMoved.push(step.stepId);
|
|
4430
|
+
} else if (before.some((id, i) => now[i] !== id)) {
|
|
4431
|
+
reordered.push(step.stepId);
|
|
4432
|
+
}
|
|
4433
|
+
}
|
|
4434
|
+
if (structurallyMoved.length) {
|
|
4435
|
+
errors.push(
|
|
4436
|
+
`The Speak web editor would not reload this automation the way it is written: ${structurallyMoved.slice(0, 4).map((id) => `"${id}"`).join(", ")} would come back on a different branch or with different parents. The usual cause is a step placed after a nested condition \u2014 a branch inside a branch has to be the last step of the branch it sits on, because the leg marker cannot say which of the two branches it belongs to.`
|
|
4437
|
+
);
|
|
4438
|
+
}
|
|
4439
|
+
if (reordered.length) {
|
|
4440
|
+
warnings.push(
|
|
4441
|
+
`Reopening this automation in the Speak web editor would reorder the dependsOn of ${reordered.slice(0, 4).map((id) => `"${id}"`).join(", ")}. The steps are the same; only the order the branches are listed in changes, which can affect which branch's fields a merge is validated against.`
|
|
4442
|
+
);
|
|
4443
|
+
}
|
|
4444
|
+
}
|
|
4445
|
+
const rootType = opts.triggerSlug ? TRIGGER_OUT[opts.triggerSlug] : void 0;
|
|
4446
|
+
if (rootType) {
|
|
4447
|
+
const incomingByStep = incomingTypesByStep(steps, rootType);
|
|
4448
|
+
const hasMedia = mediaAvailabilityByStep(steps, rootType);
|
|
4449
|
+
for (const step of steps) {
|
|
4450
|
+
const incomingTypes = incomingByStep.get(step.stepId) ?? /* @__PURE__ */ new Set([rootType]);
|
|
4451
|
+
const io = ACTION_IO[step.stepType];
|
|
4452
|
+
if (!io) continue;
|
|
4453
|
+
const unacceptable = [...incomingTypes].filter((type) => !io.in.includes(type));
|
|
4454
|
+
if (unacceptable.length && step.stepType !== "composio-action") {
|
|
4455
|
+
errors.push(
|
|
4456
|
+
`Step "${step.stepId}" (${step.stepType}) cannot accept "${unacceptable.join('", "')}" from the step before it \u2014 it expects one of: ${io.in.join(", ")}.`
|
|
4457
|
+
);
|
|
4458
|
+
}
|
|
4459
|
+
if (step.stepType !== CONDITION_STEP_TYPE && step.stepType !== FILTER_STEP_TYPE) continue;
|
|
4460
|
+
if (incomingTypes.size > 1) {
|
|
4461
|
+
warnings.push(
|
|
4462
|
+
`Step "${step.stepId}" merges branches carrying different kinds of data (${[...incomingTypes].join(", ")}). The server checks its rule fields against "${[...incomingTypes][0]}" only, so a rule valid on the other branch may be refused.`
|
|
4463
|
+
);
|
|
4464
|
+
}
|
|
4465
|
+
const flowing = [...incomingTypes][0] ?? rootType;
|
|
4466
|
+
for (const rule of ruleBlockOf(step)?.rules ?? []) {
|
|
4467
|
+
const field = String(rule.field ?? "");
|
|
4468
|
+
if (!field) {
|
|
4469
|
+
errors.push(`Step "${step.stepId}" has a rule with no field.`);
|
|
4470
|
+
continue;
|
|
4471
|
+
}
|
|
4472
|
+
const payloadAdvice = `Upload the payload first and use fieldsMap (create_automation) or mapFields (build_automation) to write "${field}" onto the media as a custom field, then test that field id here.`;
|
|
4473
|
+
if (!hasMedia.get(step.stepId)) {
|
|
4474
|
+
errors.push(
|
|
4475
|
+
`Step "${step.stepId}" tests "${field}", but at this point in the automation nothing has produced a media item yet \u2014 and a ${step.stepType} can only read a media item and earlier step answers, never the trigger payload. As written the run would stop here with "Media not found". ${payloadAdvice}`
|
|
4476
|
+
);
|
|
4477
|
+
continue;
|
|
4478
|
+
}
|
|
4479
|
+
if (looksLikePayloadPath(field)) {
|
|
4480
|
+
errors.push(
|
|
4481
|
+
`Step "${step.stepId}" tests "${field}", which reads the trigger payload \u2014 and a ${step.stepType} cannot read the payload. It would silently find nothing and take the same branch on every run. ${payloadAdvice}`
|
|
4482
|
+
);
|
|
4483
|
+
continue;
|
|
4484
|
+
}
|
|
4485
|
+
if (isCanonicalFilterField(field)) {
|
|
4486
|
+
const strictFlow = flowing === "media" || flowing === "insight" || flowing === "file";
|
|
4487
|
+
const allowed = FILTER_FIELDS_BY_IOTYPE[flowing] ?? [];
|
|
4488
|
+
if (strictFlow && !allowed.includes(canonicalFilterField(field))) {
|
|
4489
|
+
errors.push(
|
|
4490
|
+
`Step "${step.stepId}" tests "${field}", which is not available here: what reaches this step is "${flowing}"` + (flowing === "insight" ? `, so only "answer" can be tested. Move the ${step.stepType} before the AI step to test media fields.` : `, which offers: ${allowed.join(", ") || "no built-in fields"}.`)
|
|
4491
|
+
);
|
|
4492
|
+
}
|
|
4493
|
+
continue;
|
|
4494
|
+
}
|
|
4495
|
+
if (flowing === "insight" || flowing === "file") {
|
|
4496
|
+
errors.push(
|
|
4497
|
+
`Step "${step.stepId}" tests the custom field "${field}", but straight after an AI step only "answer" can be tested. Move the ${step.stepType} before the AI step.`
|
|
4498
|
+
);
|
|
4499
|
+
continue;
|
|
4500
|
+
}
|
|
4501
|
+
if (!looksLikeCustomFieldId(field)) {
|
|
4502
|
+
errors.push(`Step "${step.stepId}": "${field}" is not a valid field name or id.`);
|
|
4503
|
+
continue;
|
|
4504
|
+
}
|
|
4505
|
+
if (opts.knownFieldIds && !opts.knownFieldIds.has(field)) {
|
|
4506
|
+
errors.push(
|
|
4507
|
+
`Step "${step.stepId}" tests custom field "${field}", which does not exist in this workspace. A condition naming an unknown field is not rejected by the server and silently takes the same branch every time \u2014 use list_fields to get a real field id.`
|
|
4508
|
+
);
|
|
4509
|
+
}
|
|
4510
|
+
}
|
|
4511
|
+
}
|
|
4512
|
+
}
|
|
4513
|
+
if (isBranched) {
|
|
4514
|
+
const positional = /* @__PURE__ */ new Set();
|
|
4515
|
+
for (const step of steps) {
|
|
4516
|
+
for (const match of JSON.stringify(step).matchAll(/\{\{\s*step\.(\d+)\.[^}\s]+\s*\}\}/g)) {
|
|
4517
|
+
positional.add(match[0].replace(/\\"/g, '"'));
|
|
4518
|
+
}
|
|
4519
|
+
}
|
|
4520
|
+
if (positional.size) {
|
|
4521
|
+
errors.push(
|
|
4522
|
+
`This automation branches, so a numbered step token cannot be trusted: ${[...positional].slice(0, 3).join(", ")}. The number indexes the stored order ([condition, true leg, false leg, merge]), not the order steps run, and a step on the branch that was not taken produces nothing. Address the step by its id instead: {{step.<stepId>.answer}}.`
|
|
4523
|
+
);
|
|
4524
|
+
}
|
|
4525
|
+
}
|
|
4526
|
+
return { errors, warnings };
|
|
4527
|
+
}
|
|
4528
|
+
function branchingReloadErrors(nodes, depth) {
|
|
4529
|
+
const errors = [];
|
|
4530
|
+
for (const [index, node] of nodes.entries()) {
|
|
4531
|
+
if (!isConditionNode(node)) continue;
|
|
4532
|
+
if (depth > MAX_BRANCH_DEPTH) {
|
|
4533
|
+
errors.push(
|
|
4534
|
+
`Condition "${node.step.stepId}" is nested ${depth} branches deep; the editor supports ${MAX_BRANCH_DEPTH}. Deeper than that cannot be opened on the canvas.`
|
|
4535
|
+
);
|
|
4536
|
+
continue;
|
|
4537
|
+
}
|
|
4538
|
+
const yesExit = exitOf(node, "true");
|
|
4539
|
+
const noExit = exitOf(node, "false");
|
|
4540
|
+
if (yesExit === "end" && noExit === "end" && index < nodes.length - 1) {
|
|
4541
|
+
errors.push(
|
|
4542
|
+
`Both branches of condition "${node.step.stepId}" end the run, but "${nodes[index + 1].step.stepId}" comes after it \u2014 nothing would reach that step.`
|
|
4543
|
+
);
|
|
4544
|
+
}
|
|
4545
|
+
const reaches = LEG_BRANCHES.some(
|
|
4546
|
+
(branch) => exitOf(node, branch) === "rejoin" && legReachesOnward(legOf(node, branch))
|
|
4547
|
+
);
|
|
4548
|
+
if (!reaches && index < nodes.length - 1) {
|
|
4549
|
+
errors.push(
|
|
4550
|
+
`Every path through condition "${node.step.stepId}" ends inside it, so "${nodes[index + 1].step.stepId}" would be left with nothing to run after.`
|
|
4551
|
+
);
|
|
4552
|
+
}
|
|
4553
|
+
for (const branch of LEG_BRANCHES) {
|
|
4554
|
+
errors.push(...branchingReloadErrors(legOf(node, branch), depth + 1));
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
return errors;
|
|
4558
|
+
}
|
|
4559
|
+
function legReachesOnward(leg) {
|
|
4560
|
+
if (!leg.length) return true;
|
|
4561
|
+
const last = leg[leg.length - 1];
|
|
4562
|
+
if (!isConditionNode(last)) return true;
|
|
4563
|
+
return LEG_BRANCHES.some(
|
|
4564
|
+
(branch) => exitOf(last, branch) === "rejoin" && legReachesOnward(legOf(last, branch))
|
|
4565
|
+
);
|
|
4566
|
+
}
|
|
4567
|
+
function describeGraph(steps) {
|
|
4568
|
+
const lines = [];
|
|
4569
|
+
const summarise = (step) => {
|
|
4570
|
+
const block = ruleBlockOf(step);
|
|
4571
|
+
if (block?.rules?.length) {
|
|
4572
|
+
const logic = block.logic ?? "AND";
|
|
4573
|
+
const rules = block.rules.map((rule) => `${rule.field} ${rule.op}${"value" in rule ? ` ${JSON.stringify(rule.value)}` : ""}`).join(` ${logic} `);
|
|
4574
|
+
return `${step.stepType} [${rules}]`;
|
|
4575
|
+
}
|
|
4576
|
+
return step.stepType;
|
|
4577
|
+
};
|
|
4578
|
+
const walk = (nodes, indent) => {
|
|
4579
|
+
for (const node of nodes) {
|
|
4580
|
+
lines.push(`${indent}${node.step.stepId} ${summarise(node.step)}`);
|
|
4581
|
+
if (!isConditionNode(node)) continue;
|
|
4582
|
+
for (const branch of LEG_BRANCHES) {
|
|
4583
|
+
const leg = legOf(node, branch);
|
|
4584
|
+
const exit = exitOf(node, branch);
|
|
4585
|
+
const label = branch === "true" ? "yes" : "no";
|
|
4586
|
+
const tail = exit === "end" ? " (ends the run)" : "";
|
|
4587
|
+
lines.push(`${indent} \u251C\u2500 ${label}:${leg.length ? tail : ` (no steps)${tail}`}`);
|
|
4588
|
+
walk(leg, `${indent} \u2502 `);
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
};
|
|
4592
|
+
walk(hydrateLegs(steps), "");
|
|
4593
|
+
return lines.join("\n");
|
|
4594
|
+
}
|
|
4595
|
+
var LEG_BRANCHES, MAX_BRANCH_DEPTH, MAX_STEPS, CONDITION_STEP_TYPE, FILTER_STEP_TYPE, ACTION_IO, TRIGGER_OUT, FILTER_FIELDS_BY_IOTYPE, FILTER_FIELD_ALIASES, canonicalFilterField, ALL_CANONICAL_FILTER_FIELDS, isCanonicalFilterField, CUSTOM_FIELD_ID_PATTERN, PAYLOAD_PATH_PATTERN, looksLikePayloadPath, looksLikeCustomFieldId, isConditionNode, legOf, exitOf, uniq, ruleBlockOf;
|
|
4596
|
+
var init_automation_graph = __esm({
|
|
4597
|
+
"src/tools/automation-graph.ts"() {
|
|
4598
|
+
"use strict";
|
|
4599
|
+
LEG_BRANCHES = ["true", "false"];
|
|
4600
|
+
MAX_BRANCH_DEPTH = 3;
|
|
4601
|
+
MAX_STEPS = 20;
|
|
4602
|
+
CONDITION_STEP_TYPE = "condition";
|
|
4603
|
+
FILTER_STEP_TYPE = "filter";
|
|
4604
|
+
ACTION_IO = {
|
|
4605
|
+
"speak-upload": { in: ["data"], out: "media" },
|
|
4606
|
+
"magic-prompt": { in: ["media", "insight"], out: "insight" },
|
|
4607
|
+
translation: { in: ["media"], out: "media" },
|
|
4608
|
+
filter: { in: ["file", "media", "insight"], out: "media", passthrough: true },
|
|
4609
|
+
condition: { in: ["media", "insight", "data"], out: "media", passthrough: true },
|
|
4610
|
+
notify: { in: ["media", "insight", "data"], out: "data" },
|
|
4611
|
+
"outbound-webhook": { in: ["media", "insight", "data"], out: "data" },
|
|
4612
|
+
// Composio actions carry per-action overrides on the server; the generic entry is the
|
|
4613
|
+
// safe default and unknown actions are not type-checked locally.
|
|
4614
|
+
"composio-action": { in: ["media", "insight"], out: "notify" }
|
|
4615
|
+
};
|
|
4616
|
+
TRIGGER_OUT = {
|
|
4617
|
+
media_analyzed: "media",
|
|
4618
|
+
field_updated: "media",
|
|
4619
|
+
schedule: "media",
|
|
4620
|
+
inbound_webhook: "data",
|
|
4621
|
+
ai_chat_completed: "media",
|
|
4622
|
+
recording_received: "media",
|
|
4623
|
+
clip_created: "data"
|
|
4624
|
+
};
|
|
4625
|
+
FILTER_FIELDS_BY_IOTYPE = {
|
|
4626
|
+
media: ["name", "duration", "sourceLanguage", "tags", "transcript", "speakers"],
|
|
4627
|
+
file: ["name"],
|
|
4628
|
+
insight: ["answer"],
|
|
4629
|
+
notify: [],
|
|
4630
|
+
data: []
|
|
4631
|
+
};
|
|
4632
|
+
FILTER_FIELD_ALIASES = {
|
|
4633
|
+
title: "name",
|
|
4634
|
+
language: "sourceLanguage",
|
|
4635
|
+
speakersCount: "speakers"
|
|
4636
|
+
};
|
|
4637
|
+
canonicalFilterField = (field) => FILTER_FIELD_ALIASES[field] ?? field;
|
|
4638
|
+
ALL_CANONICAL_FILTER_FIELDS = /* @__PURE__ */ new Set([
|
|
4639
|
+
...Object.values(FILTER_FIELDS_BY_IOTYPE).flat(),
|
|
4640
|
+
...Object.keys(FILTER_FIELD_ALIASES)
|
|
4641
|
+
]);
|
|
4642
|
+
isCanonicalFilterField = (field) => ALL_CANONICAL_FILTER_FIELDS.has(canonicalFilterField(field));
|
|
4643
|
+
CUSTOM_FIELD_ID_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
4644
|
+
PAYLOAD_PATH_PATTERN = /^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
|
|
4645
|
+
looksLikePayloadPath = (field) => typeof field === "string" && PAYLOAD_PATH_PATTERN.test(field);
|
|
4646
|
+
looksLikeCustomFieldId = (field) => typeof field === "string" && !isCanonicalFilterField(field) && CUSTOM_FIELD_ID_PATTERN.test(field);
|
|
4647
|
+
isConditionNode = (node) => node.step.stepType === CONDITION_STEP_TYPE;
|
|
4648
|
+
legOf = (node, branch) => node.legs?.[branch] ?? [];
|
|
4649
|
+
exitOf = (node, branch) => node.legExit?.[branch] ?? "rejoin";
|
|
4650
|
+
uniq = (ids) => ids.filter((id, i) => ids.indexOf(id) === i);
|
|
4651
|
+
ruleBlockOf = (step) => {
|
|
4652
|
+
const block = step.stepType === CONDITION_STEP_TYPE ? step.condition : step.filter;
|
|
4653
|
+
return block && typeof block === "object" ? block : void 0;
|
|
4654
|
+
};
|
|
4655
|
+
}
|
|
4656
|
+
});
|
|
4657
|
+
|
|
3913
4658
|
// src/tools/automations.ts
|
|
3914
4659
|
var automations_exports = {};
|
|
3915
4660
|
__export(automations_exports, {
|
|
@@ -3931,6 +4676,56 @@ async function refuseUngatedAnalysis(api, steps) {
|
|
|
3931
4676
|
isError: true
|
|
3932
4677
|
};
|
|
3933
4678
|
}
|
|
4679
|
+
function refuseInvalidGraph(steps, trigger, runType) {
|
|
4680
|
+
if (!Array.isArray(steps)) return null;
|
|
4681
|
+
const triggerSlug = trigger?.triggerSlug;
|
|
4682
|
+
const { errors } = validateGraph(steps, {
|
|
4683
|
+
triggerSlug: typeof triggerSlug === "string" ? triggerSlug : void 0,
|
|
4684
|
+
runType: typeof runType === "string" ? runType : void 0
|
|
4685
|
+
});
|
|
4686
|
+
if (!errors.length) return null;
|
|
4687
|
+
return {
|
|
4688
|
+
content: [
|
|
4689
|
+
{
|
|
4690
|
+
type: "text",
|
|
4691
|
+
text: `Error: this automation cannot be saved as described.
|
|
4692
|
+
|
|
4693
|
+
` + errors.map((e) => `- ${e}`).join("\n")
|
|
4694
|
+
}
|
|
4695
|
+
],
|
|
4696
|
+
isError: true
|
|
4697
|
+
};
|
|
4698
|
+
}
|
|
4699
|
+
function graphWarnings(steps, trigger, runType) {
|
|
4700
|
+
if (!Array.isArray(steps)) return [];
|
|
4701
|
+
const triggerSlug = trigger?.triggerSlug;
|
|
4702
|
+
return validateGraph(steps, {
|
|
4703
|
+
triggerSlug: typeof triggerSlug === "string" ? triggerSlug : void 0,
|
|
4704
|
+
runType: typeof runType === "string" ? runType : void 0
|
|
4705
|
+
}).warnings;
|
|
4706
|
+
}
|
|
4707
|
+
function summariseBranching(data) {
|
|
4708
|
+
const run = data;
|
|
4709
|
+
const steps = Array.isArray(run?.steps) ? run.steps : [];
|
|
4710
|
+
if (!steps.length) return void 0;
|
|
4711
|
+
const conditions = steps.filter((step) => step.stepType === "condition").map((step) => ({
|
|
4712
|
+
stepId: step.stepId,
|
|
4713
|
+
took: step.outputs?.branch ?? "not reached"
|
|
4714
|
+
}));
|
|
4715
|
+
if (!conditions.length && !steps.some((step) => step.branchSkipped)) return void 0;
|
|
4716
|
+
const notTaken = steps.filter((step) => step.branchSkipped).map((step) => step.stepId);
|
|
4717
|
+
const ran = steps.filter((step) => !step.branchSkipped && step.status === "completed").map((step) => step.stepId);
|
|
4718
|
+
const summary = {
|
|
4719
|
+
conditions,
|
|
4720
|
+
stepsThatRan: ran,
|
|
4721
|
+
stepsSkippedBecauseTheirBranchWasNotTaken: notTaken
|
|
4722
|
+
};
|
|
4723
|
+
if (run.stoppedAt?.stepId) summary.stoppedAt = run.stoppedAt;
|
|
4724
|
+
if (run.status === "killed" && ran.length) {
|
|
4725
|
+
summary.note = `The run is marked "killed" because a filter stopped one path, but ${ran.length} step(s) ran to completion first \u2014 a stopped leg ends the whole run's status, not its work.`;
|
|
4726
|
+
}
|
|
4727
|
+
return summary;
|
|
4728
|
+
}
|
|
3934
4729
|
async function withInboundWebhookInfo(api, responseData, automationId) {
|
|
3935
4730
|
try {
|
|
3936
4731
|
if (!automationId) return responseData;
|
|
@@ -4078,6 +4873,8 @@ function register10(server, client) {
|
|
|
4078
4873
|
},
|
|
4079
4874
|
async (body) => {
|
|
4080
4875
|
try {
|
|
4876
|
+
const graphRefusal = refuseInvalidGraph(body.steps, body.trigger, body.runType);
|
|
4877
|
+
if (graphRefusal) return graphRefusal;
|
|
4081
4878
|
const refusal = await refuseUngatedAnalysis(api, body.steps);
|
|
4082
4879
|
if (refusal) return refusal;
|
|
4083
4880
|
const result = await api.post("/v1/automations/", body);
|
|
@@ -4086,6 +4883,10 @@ function register10(server, client) {
|
|
|
4086
4883
|
const automationId = unwrapData(result.data)?.automationId;
|
|
4087
4884
|
data = await withInboundWebhookInfo(api, data, automationId);
|
|
4088
4885
|
}
|
|
4886
|
+
const warnings = graphWarnings(body.steps, body.trigger, body.runType);
|
|
4887
|
+
if (warnings.length && data && typeof data === "object") {
|
|
4888
|
+
data = { ...data, warnings };
|
|
4889
|
+
}
|
|
4089
4890
|
return {
|
|
4090
4891
|
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
4091
4892
|
};
|
|
@@ -4114,6 +4915,8 @@ function register10(server, client) {
|
|
|
4114
4915
|
},
|
|
4115
4916
|
async ({ automationId, ...body }) => {
|
|
4116
4917
|
try {
|
|
4918
|
+
const graphRefusal = refuseInvalidGraph(body.steps, body.trigger, body.runType);
|
|
4919
|
+
if (graphRefusal) return graphRefusal;
|
|
4117
4920
|
const refusal = await refuseUngatedAnalysis(api, body.steps);
|
|
4118
4921
|
if (refusal) return refusal;
|
|
4119
4922
|
const result = await api.put(`/v1/automations/${automationId}`, body);
|
|
@@ -4121,6 +4924,10 @@ function register10(server, client) {
|
|
|
4121
4924
|
if (isInboundWebhookTrigger(body.trigger)) {
|
|
4122
4925
|
data = await withInboundWebhookInfo(api, data, automationId);
|
|
4123
4926
|
}
|
|
4927
|
+
const warnings = graphWarnings(body.steps, body.trigger, body.runType);
|
|
4928
|
+
if (warnings.length && data && typeof data === "object") {
|
|
4929
|
+
data = { ...data, warnings };
|
|
4930
|
+
}
|
|
4124
4931
|
return {
|
|
4125
4932
|
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
4126
4933
|
};
|
|
@@ -4275,6 +5082,209 @@ function register10(server, client) {
|
|
|
4275
5082
|
}
|
|
4276
5083
|
}
|
|
4277
5084
|
);
|
|
5085
|
+
registerSpeakTool(
|
|
5086
|
+
server,
|
|
5087
|
+
"get_automation_run",
|
|
5088
|
+
`Get one automation run in full: every step, in dependency order, with what it produced and why it stopped. Use this after test_automation or to explain a run that went the wrong way. On a branched automation the run's overall status is not the whole story \u2014 a filter that stops one leg marks the entire run "killed" even when the other leg finished its work \u2014 so read the per-step summary this returns, not just the status.`,
|
|
5089
|
+
{
|
|
5090
|
+
automationId: import_zod11.z.string().min(1).describe("Unique identifier of the automation"),
|
|
5091
|
+
runId: import_zod11.z.string().min(1).describe("Run id, from get_automation_runs or test_automation")
|
|
5092
|
+
},
|
|
5093
|
+
{
|
|
5094
|
+
title: "Get Automation Run",
|
|
5095
|
+
readOnlyHint: true,
|
|
5096
|
+
destructiveHint: false,
|
|
5097
|
+
idempotentHint: true,
|
|
5098
|
+
openWorldHint: false
|
|
5099
|
+
},
|
|
5100
|
+
async ({ automationId, runId }) => {
|
|
5101
|
+
try {
|
|
5102
|
+
const result = await api.get(`/v1/automations/${automationId}/runs/${runId}`);
|
|
5103
|
+
const data = unwrapData(result.data) ?? result.data;
|
|
5104
|
+
return {
|
|
5105
|
+
content: [
|
|
5106
|
+
{ type: "text", text: JSON.stringify({ ...data, branchSummary: summariseBranching(data) }, null, 2) }
|
|
5107
|
+
]
|
|
5108
|
+
};
|
|
5109
|
+
} catch (err) {
|
|
5110
|
+
return {
|
|
5111
|
+
content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
|
|
5112
|
+
isError: true
|
|
5113
|
+
};
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
);
|
|
5117
|
+
registerSpeakTool(
|
|
5118
|
+
server,
|
|
5119
|
+
"get_automation_run_stats",
|
|
5120
|
+
"Aggregate run counts for an automation over a period \u2014 how many completed, failed, or were stopped.",
|
|
5121
|
+
{
|
|
5122
|
+
automationId: import_zod11.z.string().min(1).describe("Unique identifier of the automation"),
|
|
5123
|
+
days: import_zod11.z.number().int().min(1).max(90).optional().describe(
|
|
5124
|
+
"How many days back to count, 1-90. The run ledger is kept for 90 days, so that is the whole window."
|
|
5125
|
+
)
|
|
5126
|
+
},
|
|
5127
|
+
{
|
|
5128
|
+
title: "Get Automation Run Stats",
|
|
5129
|
+
readOnlyHint: true,
|
|
5130
|
+
destructiveHint: false,
|
|
5131
|
+
idempotentHint: true,
|
|
5132
|
+
openWorldHint: false
|
|
5133
|
+
},
|
|
5134
|
+
async ({ automationId, ...params }) => {
|
|
5135
|
+
try {
|
|
5136
|
+
const result = await api.get(`/v1/automations/${automationId}/runs/stats`, { params });
|
|
5137
|
+
return {
|
|
5138
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
|
|
5139
|
+
};
|
|
5140
|
+
} catch (err) {
|
|
5141
|
+
return {
|
|
5142
|
+
content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
|
|
5143
|
+
isError: true
|
|
5144
|
+
};
|
|
5145
|
+
}
|
|
5146
|
+
}
|
|
5147
|
+
);
|
|
5148
|
+
registerSpeakTool(
|
|
5149
|
+
server,
|
|
5150
|
+
"test_automation",
|
|
5151
|
+
"Run an automation once against one media item to see which way it branches. THIS HAS REAL SIDE EFFECTS: only Speak's own run notifications are suppressed \u2014 outbound webhooks fire, Composio actions run against the connected third party, and AI steps are billed. Ask the user before calling it on an automation that posts anywhere outside Speak. It also needs a mediaId and sends no webhook payload, so an inbound-webhook automation cannot be meaningfully tested this way \u2014 its payload tokens will resolve to empty. Returns a runId; read the result with get_automation_run.",
|
|
5152
|
+
{
|
|
5153
|
+
automationId: import_zod11.z.string().min(1).describe("Unique identifier of the automation to test"),
|
|
5154
|
+
mediaId: import_zod11.z.string().min(1).describe("Media item to run the automation against")
|
|
5155
|
+
},
|
|
5156
|
+
{
|
|
5157
|
+
title: "Test Automation",
|
|
5158
|
+
readOnlyHint: false,
|
|
5159
|
+
destructiveHint: true,
|
|
5160
|
+
idempotentHint: false,
|
|
5161
|
+
openWorldHint: true
|
|
5162
|
+
},
|
|
5163
|
+
async (body) => {
|
|
5164
|
+
try {
|
|
5165
|
+
const result = await api.post(`/v1/automations/${body.automationId}/test-run`, {
|
|
5166
|
+
mediaId: body.mediaId
|
|
5167
|
+
});
|
|
5168
|
+
return {
|
|
5169
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
|
|
5170
|
+
};
|
|
5171
|
+
} catch (err) {
|
|
5172
|
+
return {
|
|
5173
|
+
content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
|
|
5174
|
+
isError: true
|
|
5175
|
+
};
|
|
5176
|
+
}
|
|
5177
|
+
}
|
|
5178
|
+
);
|
|
5179
|
+
registerSpeakTool(
|
|
5180
|
+
server,
|
|
5181
|
+
"validate_automation_graph",
|
|
5182
|
+
"Check a step graph without saving anything. Reports the same problems create_automation and update_automation would refuse \u2014 branch wiring, rules a condition cannot actually read, shapes the Speak web editor could not reopen \u2014 plus non-blocking warnings. Use it to iterate on a branched automation instead of discovering the problems one failed save at a time.",
|
|
5183
|
+
{
|
|
5184
|
+
steps: import_zod11.z.array(import_zod11.z.record(import_zod11.z.unknown())).min(1).describe(STEPS_DESCRIPTION),
|
|
5185
|
+
trigger: import_zod11.z.record(import_zod11.z.unknown()).optional().describe(TRIGGER_DESCRIPTION),
|
|
5186
|
+
runType: import_zod11.z.enum(["instant", "schedule"]).optional().describe("Run type the graph would be saved with. A schedule refuses any branch.")
|
|
5187
|
+
},
|
|
5188
|
+
{
|
|
5189
|
+
title: "Validate Automation Graph",
|
|
5190
|
+
readOnlyHint: true,
|
|
5191
|
+
destructiveHint: false,
|
|
5192
|
+
idempotentHint: true,
|
|
5193
|
+
openWorldHint: false
|
|
5194
|
+
},
|
|
5195
|
+
async ({ steps, trigger, runType }) => {
|
|
5196
|
+
const triggerSlug = trigger?.triggerSlug;
|
|
5197
|
+
const { errors, warnings } = validateGraph(steps, {
|
|
5198
|
+
triggerSlug: typeof triggerSlug === "string" ? triggerSlug : void 0,
|
|
5199
|
+
runType
|
|
5200
|
+
});
|
|
5201
|
+
return {
|
|
5202
|
+
content: [
|
|
5203
|
+
{
|
|
5204
|
+
type: "text",
|
|
5205
|
+
text: JSON.stringify(
|
|
5206
|
+
{
|
|
5207
|
+
valid: errors.length === 0,
|
|
5208
|
+
errors,
|
|
5209
|
+
warnings,
|
|
5210
|
+
shape: describeGraph(steps)
|
|
5211
|
+
},
|
|
5212
|
+
null,
|
|
5213
|
+
2
|
|
5214
|
+
)
|
|
5215
|
+
}
|
|
5216
|
+
]
|
|
5217
|
+
};
|
|
5218
|
+
}
|
|
5219
|
+
);
|
|
5220
|
+
registerSpeakTool(
|
|
5221
|
+
server,
|
|
5222
|
+
"describe_automation_graph",
|
|
5223
|
+
"Show a saved automation's steps as an indented branch tree instead of a flat list. Worth calling before update_automation, which replaces the whole automation: editing one leg means re-sending every step with its dependsOn intact, and this shows what the shape currently is.",
|
|
5224
|
+
{
|
|
5225
|
+
automationId: import_zod11.z.string().min(1).describe("Unique identifier of the automation")
|
|
5226
|
+
},
|
|
5227
|
+
{
|
|
5228
|
+
title: "Describe Automation Graph",
|
|
5229
|
+
readOnlyHint: true,
|
|
5230
|
+
destructiveHint: false,
|
|
5231
|
+
idempotentHint: true,
|
|
5232
|
+
openWorldHint: false
|
|
5233
|
+
},
|
|
5234
|
+
async ({ automationId }) => {
|
|
5235
|
+
try {
|
|
5236
|
+
const result = await api.get(`/v1/automations/${automationId}`);
|
|
5237
|
+
const data = unwrapData(result.data) ?? result.data;
|
|
5238
|
+
const steps = data?.steps;
|
|
5239
|
+
if (!Array.isArray(steps) || !steps.length) {
|
|
5240
|
+
return {
|
|
5241
|
+
content: [
|
|
5242
|
+
{
|
|
5243
|
+
type: "text",
|
|
5244
|
+
text: JSON.stringify(
|
|
5245
|
+
{ automationId, shape: null, note: "This automation has no graph steps (it may be a legacy single-action rule)." },
|
|
5246
|
+
null,
|
|
5247
|
+
2
|
|
5248
|
+
)
|
|
5249
|
+
}
|
|
5250
|
+
]
|
|
5251
|
+
};
|
|
5252
|
+
}
|
|
5253
|
+
const triggerSlug = data?.trigger?.triggerSlug;
|
|
5254
|
+
const { errors, warnings } = validateGraph(steps, {
|
|
5255
|
+
triggerSlug: typeof triggerSlug === "string" ? triggerSlug : void 0,
|
|
5256
|
+
runType: data?.runType
|
|
5257
|
+
});
|
|
5258
|
+
return {
|
|
5259
|
+
content: [
|
|
5260
|
+
{
|
|
5261
|
+
type: "text",
|
|
5262
|
+
text: JSON.stringify(
|
|
5263
|
+
{
|
|
5264
|
+
automationId,
|
|
5265
|
+
name: data?.name,
|
|
5266
|
+
runType: data?.runType,
|
|
5267
|
+
shape: describeGraph(steps),
|
|
5268
|
+
steps,
|
|
5269
|
+
// A stored automation can predate a rule, or have been written through the
|
|
5270
|
+
// raw API. Saying so here is cheaper than a failed round-trip on re-save.
|
|
5271
|
+
problemsIfResaved: errors,
|
|
5272
|
+
warnings
|
|
5273
|
+
},
|
|
5274
|
+
null,
|
|
5275
|
+
2
|
|
5276
|
+
)
|
|
5277
|
+
}
|
|
5278
|
+
]
|
|
5279
|
+
};
|
|
5280
|
+
} catch (err) {
|
|
5281
|
+
return {
|
|
5282
|
+
content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
|
|
5283
|
+
isError: true
|
|
5284
|
+
};
|
|
5285
|
+
}
|
|
5286
|
+
}
|
|
5287
|
+
);
|
|
4278
5288
|
registerSpeakTool(
|
|
4279
5289
|
server,
|
|
4280
5290
|
"list_automation_apps",
|
|
@@ -4367,17 +5377,26 @@ var init_automations = __esm({
|
|
|
4367
5377
|
init_client();
|
|
4368
5378
|
init_inbound_webhook_utils();
|
|
4369
5379
|
init_capabilities();
|
|
4370
|
-
|
|
5380
|
+
init_automation_graph();
|
|
5381
|
+
TOKEN_SYNTAX_NOTE = "Token syntax (usable in fields marked 'tokens allowed'): {{trigger.payload.<path>}} reads the inbound webhook payload (dot paths and [n] array indices; paths are relative to trigger.childKey when set \u2014 discover valid paths with get_inbound_webhook after sending a test payload); {{step.<stepId>.<path>}} reads a previous step's output (speak-upload -> mediaId, magic-prompt -> answer, outbound-webhook -> status/response). A positional {{step.<index>.<path>}} form also exists but is REFUSED on a branched automation: the index counts stored order ([condition, true leg, false leg, merge]), not run order, and a step on the branch that was not taken produces nothing \u2014 the token would resolve to an empty string inside whatever the step sends.";
|
|
4371
5382
|
STEPS_DESCRIPTION = `Ordered array of graph steps (1-20). Each step is an object: { stepId: string (unique within the array), stepType: one of "speak-upload" | "magic-prompt" | "translation" | "filter" | "condition" | "notify" | "outbound-webhook" | "composio-action", dependsOn?: string[] (stepIds this step runs after), branch?: "true"|"false" (which outcome of an upstream condition step this step belongs to) } plus ONE config key matching stepType:
|
|
4372
5383
|
- speak-upload -> speakUpload: { sourceMode: "url"|"file", sourceUrl (required when sourceMode="url"; tokens allowed \u2014 if the token resolves to an object, the first http(s) URL inside it is used), folderId (required, unless folderRouting.mode="dynamic" where it becomes the optional fallback), name? (tokens allowed, mixable with static text), language? (language code or token), fieldsMap?: { <customFieldId>: "<value>" } (writes payload values into Speak custom fields on the uploaded media; values are usually {{trigger.payload.<path>}} tokens \u2014 get field ids from list_fields), folderRouting?: { mode: "static"|"dynamic", sourceKey (payload key holding the destination folder name, required when dynamic), onNoMatch: "create"|"default" (create a folder named after the value, or fall back to folderId) } }
|
|
4373
5384
|
- magic-prompt -> magicPrompt: { prompt (required unless fieldIds given, max 20000), title?, assistantType? ("general"|"researcher"|"marketer"|"sales"|"recruiter"|"custom", default "general"), assistantTemplateId? (required if assistantType="custom"), fieldIds?: string[] (max 10 \u2014 extract answers into these custom fields), analysisInput? ("transcript" (default) | "audio" | "video") \u2014 what the model receives. "audio" lets it hear tone and delivery, "video" also lets it see what is on screen; on a video file "audio" extracts the audio track first. Premium: requires the account's audio/video analysis opt-in, and costs credits per hour of media }
|
|
4374
5385
|
- translation -> translation: { targetLanguage: region-qualified locale code, e.g. "es-ES", "fr-FR" (bare codes like "es" are rejected) }
|
|
4375
5386
|
- filter -> filter: { logic: "AND"|"OR" (default "AND"), rules: [{ field, op, value? }] (1-20) } \u2014 the run continues only when the rules match, otherwise it stops silently
|
|
4376
|
-
- condition -> condition: same { logic, rules } shape as filter, but instead of stopping it routes: downstream steps marked branch:"true"/"false" run according to the outcome
|
|
5387
|
+
- condition -> condition: same { logic, rules } shape as filter, but instead of stopping it routes: downstream steps marked branch:"true"/"false" run according to the outcome.
|
|
5388
|
+
Branch wiring rules, all enforced before the request is sent:
|
|
5389
|
+
* A leg is a CHAIN: the first step of a leg depends on the condition, the rest depend on the step before them in the same leg, and every step on the leg carries the same branch marker.
|
|
5390
|
+
* A step that runs after the branch (a merge) depends on the LAST step of every leg that carries on. When a leg is empty its last step IS the condition, and the merge then carries that leg's marker.
|
|
5391
|
+
* A leg ends the run simply by having nothing depend on its last step.
|
|
5392
|
+
* Once anything carries a branch marker, EVERY other step needs a dependsOn \u2014 a step with no parents is an entry point and runs on both branches, and a second entry point is rejected.
|
|
5393
|
+
* A condition with no steps on either side is rejected: both paths would do the same thing.
|
|
5394
|
+
* Branches nest at most three deep, and a nested condition must be the last step of the leg it sits on, or the automation cannot be reopened in the Speak web editor.
|
|
5395
|
+
* A scheduled automation cannot branch: a schedule runs over a batch and a condition resolves once for the whole batch, so the leg would run against media that did not match. Use a filter, which narrows the batch.
|
|
4377
5396
|
- notify -> notify: { channel: "in_app"|"email"|"slack", target?, message (required, tokens allowed) }
|
|
4378
5397
|
- outbound-webhook -> outboundWebhook: { url (required, tokens allowed), method? ("GET"|"POST"|"PUT"|"PATCH"|"DELETE", default "POST"), headers?: { <name>: <value> }, bodyTemplate?: string | object (tokens allowed) }
|
|
4379
5398
|
- composio-action -> composio: { app, action, connectedAccountId?, argsTemplate? } (Composio is currently behind a server flag and may be unavailable)
|
|
4380
|
-
Filter/condition rule fields depend on what flows into the step: MEDIA -> name|duration|sourceLanguage|tags|transcript|speakers or a custom field id; INSIGHT -> answer
|
|
5399
|
+
Filter/condition rule fields depend on what flows into the step: MEDIA -> name|duration|sourceLanguage|tags|transcript|speakers or a custom field id; INSIGHT (straight after a magic-prompt step) -> answer only, so put a branch on a media field BEFORE the AI step. Neither a filter nor a condition can read the inbound webhook payload \u2014 they see the media and earlier step answers only \u2014 so a payload path such as "contact.status" is refused: upload first with speakUpload.fieldsMap to write that value into a custom field, then test the field id instead. Ops by field type \u2014 text: eq|neq|contains|ncontains|startsWith|exists; number: eq|neq|gt|lt|exists; array: contains|ncontains|exists ("exists" takes no value; gt/lt values are numbers).
|
|
4381
5400
|
` + TOKEN_SYNTAX_NOTE;
|
|
4382
5401
|
TRIGGER_DESCRIPTION = `Trigger object (the automation's root). Always include triggerSlug. Supported shapes:
|
|
4383
5402
|
- Media analyzed in folder(s): { type: "folders", triggerSlug: "media_analyzed", folderIds: string[] (min 1) }
|
|
@@ -4467,7 +5486,7 @@ function register11(server, client) {
|
|
|
4467
5486
|
registerSpeakTool(
|
|
4468
5487
|
server,
|
|
4469
5488
|
"update_webhook",
|
|
4470
|
-
"Update an existing webhook. This
|
|
5489
|
+
"Update an existing webhook. This is a partial update \u2014 only the fields you supply are changed; `callbackUrl` is always required, the rest are left untouched if omitted.",
|
|
4471
5490
|
{
|
|
4472
5491
|
webhookId: import_zod12.z.string().min(1).describe("Unique identifier of the webhook"),
|
|
4473
5492
|
callbackUrl: import_zod12.z.string().url().describe("HTTPS endpoint URL to receive webhook payloads"),
|
|
@@ -4940,7 +5959,7 @@ function register14(server, client) {
|
|
|
4940
5959
|
{
|
|
4941
5960
|
title: "Build Automation",
|
|
4942
5961
|
readOnlyHint: false,
|
|
4943
|
-
destructiveHint:
|
|
5962
|
+
destructiveHint: true,
|
|
4944
5963
|
idempotentHint: false,
|
|
4945
5964
|
openWorldHint: false
|
|
4946
5965
|
},
|
|
@@ -4990,13 +6009,13 @@ function register14(server, client) {
|
|
|
4990
6009
|
throw new Error(`Unknown trigger \`on\`: "${on}". Use media_analyzed, inbound_webhook, or field_updated.`);
|
|
4991
6010
|
};
|
|
4992
6011
|
const isWebhookAutomation = trigger.on === "inbound_webhook";
|
|
4993
|
-
const buildRules = async (rules,
|
|
6012
|
+
const buildRules = async (rules, flowing, isFilterStep) => {
|
|
4994
6013
|
const out = [];
|
|
4995
6014
|
for (const r of rules) {
|
|
4996
6015
|
let field = String(r.field ?? "");
|
|
4997
|
-
if (
|
|
6016
|
+
if (flowing === "media" && !CANONICAL_FILTER_FIELDS.has(field) && !field.includes(".")) {
|
|
4998
6017
|
field = resolveField(field, await getFields());
|
|
4999
|
-
} else if (isFilterStep &&
|
|
6018
|
+
} else if (isFilterStep && flowing === "data" && !CANONICAL_FILTER_FIELDS.has(field)) {
|
|
5000
6019
|
dataFlowFilterFields.push(field);
|
|
5001
6020
|
}
|
|
5002
6021
|
const op = String(r.op ?? "eq");
|
|
@@ -5008,29 +6027,43 @@ function register14(server, client) {
|
|
|
5008
6027
|
}
|
|
5009
6028
|
return out;
|
|
5010
6029
|
};
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
6030
|
+
let idSeq = 0;
|
|
6031
|
+
const nextStepId = () => `s${++idSeq}`;
|
|
6032
|
+
const foldLegacyRunWhen = (specs) => {
|
|
6033
|
+
const out = [];
|
|
6034
|
+
for (let i = 0; i < specs.length; i++) {
|
|
6035
|
+
const spec = { ...specs[i] };
|
|
6036
|
+
out.push(spec);
|
|
6037
|
+
if (String(spec.do ?? "") !== "branch") continue;
|
|
6038
|
+
if (spec.then !== void 0 || spec.otherwise !== void 0) continue;
|
|
6039
|
+
const thenLeg = [];
|
|
6040
|
+
const elseLeg = [];
|
|
6041
|
+
let j = i + 1;
|
|
6042
|
+
for (; j < specs.length; j++) {
|
|
6043
|
+
const runWhen = specs[j].runWhen;
|
|
6044
|
+
if (runWhen !== "true" && runWhen !== "false") break;
|
|
6045
|
+
const { runWhen: _drop, ...rest } = specs[j];
|
|
6046
|
+
(runWhen === "true" ? thenLeg : elseLeg).push(rest);
|
|
6047
|
+
}
|
|
6048
|
+
if (thenLeg.length || elseLeg.length) {
|
|
6049
|
+
spec.then = thenLeg;
|
|
6050
|
+
spec.otherwise = elseLeg;
|
|
6051
|
+
i = j - 1;
|
|
6052
|
+
}
|
|
6053
|
+
}
|
|
6054
|
+
return out;
|
|
6055
|
+
};
|
|
6056
|
+
const buildStepBody = async (stepId, spec, where) => {
|
|
5017
6057
|
const doType = String(spec.do ?? "");
|
|
5018
6058
|
const step = { stepId };
|
|
5019
|
-
if (spec.runWhen === "true" || spec.runWhen === "false") {
|
|
5020
|
-
if (!lastBranchStepId) throw new Error(`Step ${i + 1}: runWhen requires an earlier branch step`);
|
|
5021
|
-
step.branch = spec.runWhen;
|
|
5022
|
-
step.dependsOn = [lastBranchStepId];
|
|
5023
|
-
}
|
|
5024
6059
|
if (doType === "filter" || doType === "branch") {
|
|
5025
6060
|
step.stepType = doType === "filter" ? "filter" : "condition";
|
|
5026
|
-
|
|
6061
|
+
step[doType === "filter" ? "filter" : "condition"] = {
|
|
5027
6062
|
logic: spec.logic === "OR" ? "OR" : "AND",
|
|
5028
|
-
rules:
|
|
6063
|
+
rules: (spec.rules ?? []).map((rule) => ({ ...rule }))
|
|
5029
6064
|
};
|
|
5030
|
-
step[doType === "filter" ? "filter" : "condition"] = block;
|
|
5031
|
-
if (doType === "branch") lastBranchStepId = stepId;
|
|
5032
6065
|
} else if (doType === "upload") {
|
|
5033
|
-
if (!spec.source) throw new Error(
|
|
6066
|
+
if (!spec.source) throw new Error(`${where} (upload): \`source\` is required (URL or payload.<path>)`);
|
|
5034
6067
|
const upload = {
|
|
5035
6068
|
sourceMode: "url",
|
|
5036
6069
|
sourceUrl: tokenize(spec.source),
|
|
@@ -5051,7 +6084,7 @@ function register14(server, client) {
|
|
|
5051
6084
|
};
|
|
5052
6085
|
if (spec.folder) upload.folderId = await resolveFolder(api, String(spec.folder), await getFolders(), createdFolders);
|
|
5053
6086
|
} else {
|
|
5054
|
-
if (!spec.folder) throw new Error(
|
|
6087
|
+
if (!spec.folder) throw new Error(`${where} (upload): provide \`folder\` (name or id) or \`folderFromPayload\``);
|
|
5055
6088
|
upload.folderId = await resolveFolder(api, String(spec.folder), await getFolders(), createdFolders);
|
|
5056
6089
|
}
|
|
5057
6090
|
if (spec.mapFields && typeof spec.mapFields === "object") {
|
|
@@ -5059,7 +6092,7 @@ function register14(server, client) {
|
|
|
5059
6092
|
const fieldsMap = {};
|
|
5060
6093
|
for (const [ref, value] of Object.entries(spec.mapFields)) {
|
|
5061
6094
|
if (value !== null && typeof value === "object") {
|
|
5062
|
-
throw new Error(
|
|
6095
|
+
throw new Error(`${where} (upload): mapFields["${ref}"] must be a string or number, not an object`);
|
|
5063
6096
|
}
|
|
5064
6097
|
fieldsMap[resolveField(ref, fieldList)] = tokenize(String(value));
|
|
5065
6098
|
}
|
|
@@ -5067,11 +6100,10 @@ function register14(server, client) {
|
|
|
5067
6100
|
}
|
|
5068
6101
|
step.stepType = "speak-upload";
|
|
5069
6102
|
step.speakUpload = upload;
|
|
5070
|
-
flowing = "media";
|
|
5071
6103
|
} else if (doType === "ai_chat") {
|
|
5072
6104
|
const hasSaveToFields = Array.isArray(spec.saveToFields) && spec.saveToFields.length > 0;
|
|
5073
6105
|
if (!spec.prompt && !hasSaveToFields) {
|
|
5074
|
-
throw new Error(
|
|
6106
|
+
throw new Error(`${where} (ai_chat): provide \`prompt\`, \`saveToFields\`, or both`);
|
|
5075
6107
|
}
|
|
5076
6108
|
const magicPrompt = { prompt: spec.prompt ?? "", assistantType: "general" };
|
|
5077
6109
|
if (spec.title) magicPrompt.title = spec.title;
|
|
@@ -5080,60 +6112,119 @@ function register14(server, client) {
|
|
|
5080
6112
|
const analysis = String(spec.analyse ?? spec.analyze);
|
|
5081
6113
|
if (!["transcript", "audio", "video"].includes(analysis)) {
|
|
5082
6114
|
throw new Error(
|
|
5083
|
-
|
|
6115
|
+
`${where} (ai_chat): analyse must be "transcript", "audio" or "video", got "${analysis}"`
|
|
5084
6116
|
);
|
|
5085
6117
|
}
|
|
5086
6118
|
if (analysis !== "transcript") magicPrompt.analysisInput = analysis;
|
|
5087
6119
|
}
|
|
5088
6120
|
if (Array.isArray(spec.saveToFields) && spec.saveToFields.length) {
|
|
5089
6121
|
if (spec.saveToFields.length > 10) {
|
|
5090
|
-
throw new Error(
|
|
6122
|
+
throw new Error(`${where} (ai_chat): saveToFields supports at most 10 fields`);
|
|
5091
6123
|
}
|
|
5092
6124
|
const fieldList = await getFields();
|
|
5093
6125
|
magicPrompt.fieldIds = spec.saveToFields.map((ref) => resolveField(String(ref), fieldList));
|
|
5094
6126
|
}
|
|
5095
6127
|
step.stepType = "magic-prompt";
|
|
5096
6128
|
step.magicPrompt = magicPrompt;
|
|
5097
|
-
flowing = "insight";
|
|
5098
6129
|
} else if (doType === "translate") {
|
|
5099
|
-
if (!spec.language) throw new Error(
|
|
6130
|
+
if (!spec.language) throw new Error(`${where} (translate): \`language\` is required (e.g. "es-ES")`);
|
|
5100
6131
|
step.stepType = "translation";
|
|
5101
6132
|
step.translation = { targetLanguage: spec.language };
|
|
5102
|
-
flowing = "media";
|
|
5103
6133
|
} else if (doType === "notify") {
|
|
5104
|
-
if (!spec.message) throw new Error(
|
|
6134
|
+
if (!spec.message) throw new Error(`${where} (notify): \`message\` is required`);
|
|
5105
6135
|
const channel = spec.channel === void 0 ? "in_app" : String(spec.channel);
|
|
5106
6136
|
if (!["in_app", "email", "slack"].includes(channel)) {
|
|
5107
|
-
throw new Error(
|
|
6137
|
+
throw new Error(`${where} (notify): channel must be "in_app", "email", or "slack" (got "${channel}")`);
|
|
5108
6138
|
}
|
|
5109
6139
|
const notify = { channel, message: tokenize(spec.message) };
|
|
5110
6140
|
if (spec.target) notify.target = String(spec.target);
|
|
5111
6141
|
step.stepType = "notify";
|
|
5112
6142
|
step.notify = notify;
|
|
5113
|
-
flowing = "data";
|
|
5114
6143
|
} else if (doType === "call_webhook") {
|
|
5115
|
-
if (!spec.url) throw new Error(
|
|
6144
|
+
if (!spec.url) throw new Error(`${where} (call_webhook): \`url\` is required`);
|
|
5116
6145
|
const method = spec.method === void 0 ? "POST" : String(spec.method).toUpperCase();
|
|
5117
6146
|
if (!["GET", "POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
|
5118
|
-
throw new Error(
|
|
6147
|
+
throw new Error(`${where} (call_webhook): method must be GET, POST, PUT, PATCH, or DELETE (got "${spec.method}")`);
|
|
5119
6148
|
}
|
|
5120
|
-
const outbound = {
|
|
5121
|
-
url: tokenize(spec.url),
|
|
5122
|
-
method
|
|
5123
|
-
};
|
|
6149
|
+
const outbound = { url: tokenize(spec.url), method };
|
|
5124
6150
|
if (spec.headers && typeof spec.headers === "object") outbound.headers = spec.headers;
|
|
5125
6151
|
if (spec.body !== void 0) {
|
|
5126
6152
|
outbound.bodyTemplate = typeof spec.body === "string" ? tokenize(spec.body) : spec.body;
|
|
5127
6153
|
}
|
|
5128
6154
|
step.stepType = "outbound-webhook";
|
|
5129
6155
|
step.outboundWebhook = outbound;
|
|
5130
|
-
flowing = "data";
|
|
5131
6156
|
} else {
|
|
5132
6157
|
throw new Error(
|
|
5133
|
-
|
|
6158
|
+
`${where}: unknown \`do\`: "${doType}". Use filter, branch, upload, ai_chat, translate, notify, or call_webhook.`
|
|
5134
6159
|
);
|
|
5135
6160
|
}
|
|
5136
|
-
|
|
6161
|
+
return step;
|
|
6162
|
+
};
|
|
6163
|
+
const buildNodes = async (specs, path4) => {
|
|
6164
|
+
const nodes2 = [];
|
|
6165
|
+
const folded = foldLegacyRunWhen(specs);
|
|
6166
|
+
for (const [index, spec] of folded.entries()) {
|
|
6167
|
+
const where = `${path4}[${index}]`;
|
|
6168
|
+
const stepId = nextStepId();
|
|
6169
|
+
const body2 = await buildStepBody(stepId, spec, where);
|
|
6170
|
+
if (String(spec.do ?? "") !== "branch") {
|
|
6171
|
+
nodes2.push({ step: body2 });
|
|
6172
|
+
continue;
|
|
6173
|
+
}
|
|
6174
|
+
nodes2.push({
|
|
6175
|
+
step: body2,
|
|
6176
|
+
legs: {
|
|
6177
|
+
true: await buildNodes(spec.then ?? [], `${where}.then`),
|
|
6178
|
+
false: await buildNodes(spec.otherwise ?? [], `${where}.otherwise`)
|
|
6179
|
+
},
|
|
6180
|
+
legExit: {
|
|
6181
|
+
true: spec.thenEnds === true ? "end" : "rejoin",
|
|
6182
|
+
false: spec.otherwiseEnds === true ? "end" : "rejoin"
|
|
6183
|
+
}
|
|
6184
|
+
});
|
|
6185
|
+
}
|
|
6186
|
+
return nodes2;
|
|
6187
|
+
};
|
|
6188
|
+
const nodes = await buildNodes(steps, "steps");
|
|
6189
|
+
const wireSteps = compileGraph(nodes);
|
|
6190
|
+
const triggerSlug = String(trigger.on ?? "");
|
|
6191
|
+
const rootType = TRIGGER_OUT[triggerSlug] ?? (isWebhookAutomation ? "data" : "media");
|
|
6192
|
+
const incomingByStep = incomingTypesByStep(wireSteps, rootType);
|
|
6193
|
+
for (const step of wireSteps) {
|
|
6194
|
+
const stepType = String(step.stepType);
|
|
6195
|
+
if (stepType !== "filter" && stepType !== "condition") continue;
|
|
6196
|
+
const incoming = incomingByStep.get(String(step.stepId)) ?? /* @__PURE__ */ new Set([rootType]);
|
|
6197
|
+
const flowing = [...incoming][0] ?? rootType;
|
|
6198
|
+
const key = stepType === "filter" ? "filter" : "condition";
|
|
6199
|
+
const block = step[key];
|
|
6200
|
+
block.rules = await buildRules(block.rules ?? [], flowing, stepType === "filter");
|
|
6201
|
+
}
|
|
6202
|
+
const rulesReferenceFieldIds = wireSteps.some((step) => {
|
|
6203
|
+
const key = step.stepType === "condition" ? "condition" : step.stepType === "filter" ? "filter" : null;
|
|
6204
|
+
if (!key) return false;
|
|
6205
|
+
const rules = step[key]?.rules ?? [];
|
|
6206
|
+
return rules.some((rule) => looksLikeCustomFieldId(String(rule.field ?? "")));
|
|
6207
|
+
});
|
|
6208
|
+
const knownFieldIds = rulesReferenceFieldIds ? new Set((await getFields()).map((entry) => entry.id)) : null;
|
|
6209
|
+
const graphCheck = validateGraph(wireSteps, {
|
|
6210
|
+
triggerSlug,
|
|
6211
|
+
// build_automation only writes instant automations; a schedule comes through
|
|
6212
|
+
// create_automation, which runs the same validator with its own runType.
|
|
6213
|
+
runType: "instant",
|
|
6214
|
+
knownFieldIds
|
|
6215
|
+
});
|
|
6216
|
+
if (graphCheck.errors.length) {
|
|
6217
|
+
return {
|
|
6218
|
+
content: [
|
|
6219
|
+
{
|
|
6220
|
+
type: "text",
|
|
6221
|
+
text: `Error: this automation cannot be saved as described.
|
|
6222
|
+
|
|
6223
|
+
` + graphCheck.errors.map((e) => `- ${e}`).join("\n")
|
|
6224
|
+
}
|
|
6225
|
+
],
|
|
6226
|
+
isError: true
|
|
6227
|
+
};
|
|
5137
6228
|
}
|
|
5138
6229
|
const body = {
|
|
5139
6230
|
name,
|
|
@@ -5162,6 +6253,7 @@ function register14(server, client) {
|
|
|
5162
6253
|
...typeof result.data === "object" ? result.data : { data: result.data }
|
|
5163
6254
|
};
|
|
5164
6255
|
if (createdFolders.length) response.createdFolders = createdFolders;
|
|
6256
|
+
if (graphCheck.warnings.length) response.warnings = graphCheck.warnings;
|
|
5165
6257
|
if (isWebhookAutomation && resolvedId) {
|
|
5166
6258
|
try {
|
|
5167
6259
|
const resolved = await resolveAutomationInboundWebhook(api, resolvedId);
|
|
@@ -5434,6 +6526,7 @@ var init_workflows = __esm({
|
|
|
5434
6526
|
init_media_utils();
|
|
5435
6527
|
init_capabilities();
|
|
5436
6528
|
init_inbound_webhook_utils();
|
|
6529
|
+
init_automation_graph();
|
|
5437
6530
|
MAX_BATCH_URLS = 25;
|
|
5438
6531
|
MAX_BATCH_CONCURRENCY = 5;
|
|
5439
6532
|
RATE_LIMIT_RETRY_DELAY_MS = 5e3;
|
|
@@ -5453,7 +6546,7 @@ var init_workflows = __esm({
|
|
|
5453
6546
|
]);
|
|
5454
6547
|
ID_PATTERN = /^[0-9a-f]{12}$/;
|
|
5455
6548
|
TRIGGER_SPEC_DESCRIPTION = 'What starts the automation. Object with:\n- on (required): "media_analyzed" | "inbound_webhook" | "field_updated"\n- folders: array of folder names or ids (required for media_analyzed; missing folders are created)\n- childKey: dot-path narrowing the webhook payload root, e.g. "data" (inbound_webhook only)\n- webhookId: reuse a webhook from provision_inbound_webhook (inbound_webhook only; omit to auto-provision)\n- watchFields: array of { field: name-or-id, values?: string[] } (required for field_updated \u2014 fires when the field changes; values restricts to specific new values)\n- matchLogic: "AND"|"OR" for combining multiple watchFields value matches (default OR)';
|
|
5456
|
-
STEP_SPEC_DESCRIPTION = 'Ordered actions. Each step is an object with a `do` key plus its options. String values may be literals, "payload.<path>" shorthand (converted to {{trigger.payload.<path>}} only when it is the ENTIRE value), or raw {{...}} tokens \u2014 inside longer text, write the full {{trigger.payload.<path>}} form.\n- { do: "filter", rules: [{ field, op, value? }], logic?: "AND"|"OR" } \u2014 continue only if rules match
|
|
6549
|
+
STEP_SPEC_DESCRIPTION = 'Ordered actions. Each step is an object with a `do` key plus its options. String values may be literals, "payload.<path>" shorthand (converted to {{trigger.payload.<path>}} only when it is the ENTIRE value), or raw {{...}} tokens \u2014 inside longer text, write the full {{trigger.payload.<path>}} form.\n- { do: "filter", rules: [{ field, op, value? }], logic?: "AND"|"OR" } \u2014 continue only if rules match, otherwise the run stops here. Ops: eq|neq|contains|ncontains|startsWith|gt|lt|exists\n- { do: "branch", rules, logic?, then: [steps], otherwise: [steps], thenEnds?, otherwiseEnds? } \u2014 routes instead of stopping. `then` runs when the rules match, `otherwise` when they do not, and whatever follows the branch runs on both paths. Set thenEnds/otherwiseEnds to true to finish the run on that side instead of carrying on. One side may be empty ("if it matches do this, otherwise just carry on"), but not both. Branches may nest three deep, and a nested branch must be the LAST step of the side it sits on.\n Rule fields for BOTH filter and branch depend on what reaches the step: while media is flowing use name|duration|sourceLanguage|tags|transcript|speakers or a custom field name; straight after an ai_chat step only "answer" is available, so put the branch BEFORE the ai_chat step if you need a media field. A filter and a branch CANNOT read the webhook payload \u2014 they only see the media and earlier answers. To branch on payload data, upload first with mapFields to write the value into a custom field, then branch on that field.\n- { do: "upload", source (URL or payload.<path>, required), name?, language? (e.g. "en-US"), folder? (name or id; created if missing), folderFromPayload? (payload key holding the destination folder name \u2014 dynamic routing), onNoFolderMatch?: "create"|"default", mapFields?: { <field name or id>: <value or payload.<path>> } (writes payload values into custom fields on the uploaded media) }\n- { do: "ai_chat", prompt? (required unless saveToFields given), title?, saveToFields?: [field names or ids] (max 10 \u2014 values are extracted into these custom fields; prompt may be omitted for extraction-only steps), model? (a Speak-supported LLM id, e.g. "gemini-2.5-flash", "claude-sonnet-4-6"; omit for the workspace default), analyse?: "transcript" (default) | "audio" | "video" \u2014 what the model receives. "audio" lets it hear tone and delivery, "video" also lets it see the screen; on a video file "audio" extracts the audio track first. Premium: requires the account\'s audio/video analysis opt-in and costs credits per hour of media }\n- { do: "translate", language: region-qualified code like "es-ES", "fr-FR" }\n- { do: "notify", message (required, tokens allowed), channel?: "in_app"|"email"|"slack" (default in_app; email currently falls back to an in-app notification), target? (reserved \u2014 not yet used for delivery) }\n- { do: "call_webhook", url (required), method?, headers?, body? (string or object template, tokens allowed) }\nLegacy: a flat list where steps after a branch carry runWhen: "true"|"false" is still accepted and folded into then/otherwise, but it cannot express nesting or an ending side \u2014 prefer then/otherwise. Composio app actions (Google Drive, Slack apps, \u2026) are not supported by this builder yet \u2014 use create_automation directly for those.';
|
|
5457
6550
|
buildAutomationSchema = {
|
|
5458
6551
|
name: import_zod15.z.string().min(1).max(150).describe("Display name for the automation"),
|
|
5459
6552
|
trigger: import_zod15.z.record(import_zod15.z.unknown()).describe(TRIGGER_SPEC_DESCRIPTION),
|
|
@@ -5683,6 +6776,8 @@ function defaultWidgetConfig(type) {
|
|
|
5683
6776
|
return { metrics: ["uploads", "minutes", "lastActive"] };
|
|
5684
6777
|
case "notes":
|
|
5685
6778
|
return { content: "Add notes or context for this dashboard." };
|
|
6779
|
+
case "chat-history":
|
|
6780
|
+
return { limit: 25 };
|
|
5686
6781
|
}
|
|
5687
6782
|
}
|
|
5688
6783
|
function buildDashboardWidgets(items, sections = []) {
|
|
@@ -5784,7 +6879,8 @@ var init_dashboard_widgets = __esm({
|
|
|
5784
6879
|
"themes",
|
|
5785
6880
|
"people",
|
|
5786
6881
|
"team-activity",
|
|
5787
|
-
"notes"
|
|
6882
|
+
"notes",
|
|
6883
|
+
"chat-history"
|
|
5788
6884
|
];
|
|
5789
6885
|
DATE_RANGE_PRESETS = [
|
|
5790
6886
|
"last7days",
|
|
@@ -5804,7 +6900,8 @@ var init_dashboard_widgets = __esm({
|
|
|
5804
6900
|
themes: { w: 6, h: 4, titleDefault: "Themes" },
|
|
5805
6901
|
people: { w: 6, h: 4, titleDefault: "People" },
|
|
5806
6902
|
"team-activity": { w: 6, h: 4, titleDefault: "Team activity" },
|
|
5807
|
-
notes: { w: GRID_COLS, h: 2, titleDefault: "Note" }
|
|
6903
|
+
notes: { w: GRID_COLS, h: 2, titleDefault: "Note" },
|
|
6904
|
+
"chat-history": { w: GRID_COLS, h: 6, titleDefault: "AI Chat History" }
|
|
5808
6905
|
};
|
|
5809
6906
|
KEBAB_ID = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
5810
6907
|
AUTO_LAYOUT = { x: 0, y: 0, w: 0, h: 0 };
|
|
@@ -5863,6 +6960,11 @@ var init_dashboard_widgets = __esm({
|
|
|
5863
6960
|
type: "notes",
|
|
5864
6961
|
purpose: "Free-text note/context block (full width).",
|
|
5865
6962
|
config: "content: string (1-4000 chars, required)"
|
|
6963
|
+
},
|
|
6964
|
+
{
|
|
6965
|
+
type: "chat-history",
|
|
6966
|
+
purpose: "Past AI chat conversations held on this dashboard (full width) \u2014 messages, feedback, and the thinking/tool-call trail when the viewer's embed allows it. Not a Media-aggregation widget.",
|
|
6967
|
+
config: "limit?: number (1-100, optional, default 25) \u2014 conversations per page."
|
|
5866
6968
|
}
|
|
5867
6969
|
];
|
|
5868
6970
|
SPEC_VOCABULARY = {
|
|
@@ -6014,6 +7116,7 @@ function pickMetadata(body) {
|
|
|
6014
7116
|
if (body.assignTo !== void 0) out.assignTo = body.assignTo;
|
|
6015
7117
|
if (body.filters !== void 0) out.filters = body.filters;
|
|
6016
7118
|
if (body.isDefault !== void 0) out.isDefault = body.isDefault;
|
|
7119
|
+
if (body.settings !== void 0) out.settings = body.settings;
|
|
6017
7120
|
return out;
|
|
6018
7121
|
}
|
|
6019
7122
|
function register16(server, client) {
|
|
@@ -6109,7 +7212,7 @@ function register16(server, client) {
|
|
|
6109
7212
|
registerSpeakTool(
|
|
6110
7213
|
server,
|
|
6111
7214
|
"create_dashboard",
|
|
6112
|
-
`Create an analytics dashboard. Only \`title\` is required \u2014 source defaults to the whole workspace and dateRange to last30days. Add widgets by listing their types (the MCP assigns ids and lays them out automatically), scope with source ({type:"folders",folderIds} | {type:"team"} | {type:"workspace"}) and dateRange ({preset}), and optionally group widgets into sections. Design guidance: lead with a narrative widget as the first widget; group sections by the QUESTION they answer, not by widget type; don't pad \u2014 every widget earns its place (aim for 4-16 widgets on a full build); if something can't be expressed by the widget catalog, put it in a narrative widget's focus instead of faking it. Call list_dashboard_widgets first for the widget catalog, config vocabulary, design rules, and full examples
|
|
7215
|
+
`Create an analytics dashboard. Only \`title\` is required \u2014 source defaults to the whole workspace and dateRange to last30days. Add widgets by listing their types (the MCP assigns ids and lays them out automatically), scope with source ({type:"folders",folderIds} | {type:"team"} | {type:"workspace"}) and dateRange ({preset}), and optionally group widgets into sections. Design guidance: lead with a narrative widget as the first widget; group sections by the QUESTION they answer, not by widget type; don't pad \u2014 every widget earns its place (aim for 4-16 widgets on a full build); if something can't be expressed by the widget catalog, put it in a narrative widget's focus instead of faking it. Call list_dashboard_widgets first for the widget catalog, config vocabulary, design rules, and full examples. Viewer settings (the settings input): ` + SETTINGS_RULES,
|
|
6113
7216
|
{
|
|
6114
7217
|
title: import_zod17.z.string().min(1).max(60).describe("Dashboard name, max 60 chars (the only required field)"),
|
|
6115
7218
|
...specFields,
|
|
@@ -6150,7 +7253,7 @@ function register16(server, client) {
|
|
|
6150
7253
|
registerSpeakTool(
|
|
6151
7254
|
server,
|
|
6152
7255
|
"update_dashboard",
|
|
6153
|
-
"Update a dashboard. Two modes. (1) Metadata-only: pass just icon/assignTo/filters/isDefault
|
|
7256
|
+
"Update a dashboard. Two modes. (1) Metadata-only: pass just icon/assignTo/filters/isDefault/settings, with no spec fields and no revision. (2) Spec update: pass the FULL spec \u2014 title, source, dateRange, sections, widgets \u2014 plus `revision`. Widgets and sections are REPLACED, not merged, so call get_dashboard first and resend everything you want to keep. `revision` is the optimistic-concurrency token from get_dashboard/list_dashboards: the server accepts the write only if it still matches, then increments it. A 409 conflict means another writer saved first \u2014 re-fetch with get_dashboard, rebuild your changes on the fresh spec, and retry with the new revision. Viewer settings (the settings input): " + SETTINGS_RULES,
|
|
6154
7257
|
{
|
|
6155
7258
|
dashboardId: import_zod17.z.string().min(1).describe("Dashboard business id"),
|
|
6156
7259
|
title: import_zod17.z.string().min(1).max(60).optional().describe("Dashboard name \u2014 required (with revision) when updating the spec"),
|
|
@@ -6315,7 +7418,7 @@ function register16(server, client) {
|
|
|
6315
7418
|
}
|
|
6316
7419
|
);
|
|
6317
7420
|
}
|
|
6318
|
-
var import_zod17, FILTER_LIST_DESCRIPTION, widgetInputSchema, sectionInputSchema, sourceInputSchema, dateRangeInputSchema, metadataFields, specFields, SPEAKERS_FILTER_SCHEMA;
|
|
7421
|
+
var import_zod17, FILTER_LIST_DESCRIPTION, widgetInputSchema, sectionInputSchema, sourceInputSchema, dateRangeInputSchema, settingsFieldIds, SETTINGS_RULES, dashboardSettingsSchema, metadataFields, specFields, SPEAKERS_FILTER_SCHEMA;
|
|
6319
7422
|
var init_dashboards = __esm({
|
|
6320
7423
|
"src/tools/dashboards.ts"() {
|
|
6321
7424
|
"use strict";
|
|
@@ -6326,14 +7429,14 @@ var init_dashboards = __esm({
|
|
|
6326
7429
|
FILTER_LIST_DESCRIPTION = "Field filters. filters.filterList is an array of { fieldName, fieldOperator?, fieldValue?: string[], fieldCondition? }. Other keys pass through but only filterList is enforced.";
|
|
6327
7430
|
widgetInputSchema = import_zod17.z.object({
|
|
6328
7431
|
type: import_zod17.z.enum(WIDGET_TYPES).describe(
|
|
6329
|
-
"Widget type: narrative | stat-cards | metric-chart | table | comparison | field-distribution | sentiment-trend | themes | people | team-activity | notes"
|
|
7432
|
+
"Widget type: narrative | stat-cards | metric-chart | table | comparison | field-distribution | sentiment-trend | themes | people | team-activity | notes | chat-history"
|
|
6330
7433
|
),
|
|
6331
7434
|
id: import_zod17.z.string().max(64).optional().describe(
|
|
6332
7435
|
"Optional explicit widget id (kebab-case). Required if you reference the widget from sections[].widgetIds; auto-generated otherwise."
|
|
6333
7436
|
),
|
|
6334
7437
|
title: import_zod17.z.string().min(1).max(40).optional().describe("Widget title, max 40 chars (defaults to a per-type label)"),
|
|
6335
7438
|
config: import_zod17.z.record(import_zod17.z.unknown()).optional().describe(
|
|
6336
|
-
"Per-type config (STRICT \u2014 unknown keys are rejected). metric-chart: mark (line|bar|area|donut|stacked-bar) + metric + groupBy/series + thresholds; table: rowsAre + columns [{header, field|metric}]; stat-cards: tiles; field-distribution: fieldName+measure+chartType (required); narrative: focus; notes: content. Call list_dashboard_widgets for the full per-type vocabulary + metric/filter grammar. Omit for a sensible valid default (except field-distribution, which needs fieldName)."
|
|
7439
|
+
"Per-type config (STRICT \u2014 unknown keys are rejected). metric-chart: mark (line|bar|area|donut|stacked-bar) + metric + groupBy/series + thresholds; table: rowsAre + columns [{header, field|metric}]; stat-cards: tiles; field-distribution: fieldName+measure+chartType (required); narrative: focus; notes: content; chat-history: limit (optional, past conversations to list, 1-100, default 25). Call list_dashboard_widgets for the full per-type vocabulary + metric/filter grammar. Omit for a sensible valid default (except field-distribution, which needs fieldName)."
|
|
6337
7440
|
),
|
|
6338
7441
|
binding: import_zod17.z.record(import_zod17.z.unknown()).optional().describe(
|
|
6339
7442
|
"Per-widget scope override: { source?, dateRange?: {preset}, filter? }. Omit any key to inherit the dashboard's value."
|
|
@@ -6364,11 +7467,67 @@ var init_dashboards = __esm({
|
|
|
6364
7467
|
dateRangeInputSchema = import_zod17.z.object({
|
|
6365
7468
|
preset: import_zod17.z.enum(DATE_RANGE_PRESETS).describe("One of: last7days | last30days | last3months | yearToDate | allTime")
|
|
6366
7469
|
}).describe("Date range \u2014 strict preset only, no free-form start/end dates");
|
|
7470
|
+
settingsFieldIds = import_zod17.z.array(import_zod17.z.string());
|
|
7471
|
+
SETTINGS_RULES = "Do not pass settings unless the user explicitly asks to change this dashboard's viewer settings. Never pass settings for a Foxtons dashboard unless explicitly asked; Foxtons moves by a server script. Saving any settings section moves that dashboard onto the settings flow immediately: its media pages use these groups and this Feedback setup from then on. Each section (fields, feedback) replaces that whole section when sent. Call get_dashboard first and resend every key of the section you change; a key left out resets to its default. Get field ids from list_fields. Ids that are not the company's fields are dropped when saving. When feedback.isEnabled is true, pass a non-empty feedback.fieldIds (score fields) rather than leaving it empty. Only set feedback.sheetWebhookUrl when the user gives the Apps Script URL.";
|
|
7472
|
+
dashboardSettingsSchema = import_zod17.z.object({
|
|
7473
|
+
fields: import_zod17.z.object({
|
|
7474
|
+
includeIds: settingsFieldIds.describe(
|
|
7475
|
+
"Field ids a viewer sees on each media page opened from this shared dashboard, in this order. Private fields are shown when listed. Empty shows only the company's public fields."
|
|
7476
|
+
),
|
|
7477
|
+
groups: import_zod17.z.array(
|
|
7478
|
+
import_zod17.z.object({
|
|
7479
|
+
key: import_zod17.z.string().min(1),
|
|
7480
|
+
label: import_zod17.z.string().min(1),
|
|
7481
|
+
fieldIds: settingsFieldIds.min(1)
|
|
7482
|
+
})
|
|
7483
|
+
).describe("Pills on the media page Fields tab, each listing the field ids it shows. Empty means no pills."),
|
|
7484
|
+
orderIds: settingsFieldIds.optional().describe(
|
|
7485
|
+
"Used only when includeIds is empty: these fields show first, in this order, then every other public field. Does not change which fields are visible."
|
|
7486
|
+
)
|
|
7487
|
+
}).optional(),
|
|
7488
|
+
feedback: import_zod17.z.object({
|
|
7489
|
+
isEnabled: import_zod17.z.boolean().describe("Show the Feedback button on media pages opened from this shared dashboard"),
|
|
7490
|
+
fieldIds: settingsFieldIds.describe(
|
|
7491
|
+
"Fields a reviewer gives feedback on. Empty means every field the media page shows."
|
|
7492
|
+
),
|
|
7493
|
+
submitters: import_zod17.z.array(import_zod17.z.string().min(1)).describe("Names a reviewer picks from. Empty lets them type their own name."),
|
|
7494
|
+
removeReasons: import_zod17.z.array(import_zod17.z.string().min(1)).describe("Reasons for removing a call from scoring. Empty hides that option."),
|
|
7495
|
+
reviewScope: import_zod17.z.enum(["dashboard", "company"]).optional().describe(
|
|
7496
|
+
"'dashboard' (default) lists and reviews only this dashboard's feedback; 'company' lists every dashboard's feedback in the company. Use 'company' only on a manager dashboard, never on a personal one."
|
|
7497
|
+
),
|
|
7498
|
+
allowOtherSubmitter: import_zod17.z.boolean().optional().describe("Lets a reviewer type a name that is not in submitters."),
|
|
7499
|
+
groups: import_zod17.z.array(
|
|
7500
|
+
import_zod17.z.object({
|
|
7501
|
+
key: import_zod17.z.string().min(1),
|
|
7502
|
+
label: import_zod17.z.string().min(1),
|
|
7503
|
+
fieldIds: settingsFieldIds.min(1)
|
|
7504
|
+
})
|
|
7505
|
+
).optional().describe(
|
|
7506
|
+
"Pills in the Feedback dialog, each listing feedback field ids in order. Leave out to reuse fields.groups."
|
|
7507
|
+
),
|
|
7508
|
+
fieldRules: import_zod17.z.record(
|
|
7509
|
+
import_zod17.z.string(),
|
|
7510
|
+
import_zod17.z.object({
|
|
7511
|
+
label: import_zod17.z.string().optional(),
|
|
7512
|
+
min: import_zod17.z.number().optional(),
|
|
7513
|
+
max: import_zod17.z.number().optional()
|
|
7514
|
+
})
|
|
7515
|
+
).optional().describe(
|
|
7516
|
+
"Per feedback field: a short row label and the allowed score range, used for both the reviewer's score and the approver's score."
|
|
7517
|
+
),
|
|
7518
|
+
sheetWebhookUrl: import_zod17.z.string().optional().describe(
|
|
7519
|
+
"Google Apps Script web app URL that receives one row per submission. Only script.google.com addresses are posted to. Never shown to viewers."
|
|
7520
|
+
)
|
|
7521
|
+
}).optional()
|
|
7522
|
+
}).describe(
|
|
7523
|
+
"Viewer settings for media pages opened from this dashboard's share link: which fields show, how the Fields tab groups them, and the Feedback button. " + SETTINGS_RULES
|
|
7524
|
+
);
|
|
6367
7525
|
metadataFields = {
|
|
6368
7526
|
icon: import_zod17.z.string().max(200).optional().describe("Icon identifier"),
|
|
6369
7527
|
assignTo: import_zod17.z.array(import_zod17.z.string()).max(100).optional().describe('User ids, or group ids in the "<groupId> (G)" convention, to share view access with'),
|
|
6370
7528
|
filters: import_zod17.z.record(import_zod17.z.unknown()).optional().describe(FILTER_LIST_DESCRIPTION),
|
|
6371
|
-
isDefault: import_zod17.z.boolean().optional().describe("Make this the company default dashboard")
|
|
7529
|
+
isDefault: import_zod17.z.boolean().optional().describe("Make this the company default dashboard"),
|
|
7530
|
+
settings: dashboardSettingsSchema.optional()
|
|
6372
7531
|
};
|
|
6373
7532
|
specFields = {
|
|
6374
7533
|
description: import_zod17.z.string().max(280).optional().describe("Dashboard description, max 280 chars"),
|
|
@@ -6694,6 +7853,11 @@ var init_tool_names = __esm({
|
|
|
6694
7853
|
"list_automation_names",
|
|
6695
7854
|
"get_automation",
|
|
6696
7855
|
"get_automation_runs",
|
|
7856
|
+
"get_automation_run",
|
|
7857
|
+
"get_automation_run_stats",
|
|
7858
|
+
"test_automation",
|
|
7859
|
+
"validate_automation_graph",
|
|
7860
|
+
"describe_automation_graph",
|
|
6697
7861
|
"create_automation",
|
|
6698
7862
|
"update_automation",
|
|
6699
7863
|
"toggle_automation_status",
|