@signaliz/sdk 1.0.15 → 1.0.17
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 +128 -10
- package/dist/{chunk-6OZWMAV3.mjs → chunk-ZKE4L57J.mjs} +1819 -136
- package/dist/cli.js +5238 -3148
- package/dist/cli.mjs +264 -20
- package/dist/index.d.mts +2616 -1938
- package/dist/index.d.ts +2616 -1938
- package/dist/index.js +1820 -136
- package/dist/index.mjs +3 -1
- package/dist/mcp-config.js +1818 -136
- package/dist/mcp-config.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
createCampaignBuilderAgentRequestTemplate: () => createCampaignBuilderAgentRequestTemplate,
|
|
40
40
|
createCampaignBuilderApproval: () => createCampaignBuilderApproval,
|
|
41
41
|
createCampaignBuilderBuildKit: () => createCampaignBuilderBuildKit,
|
|
42
|
+
createCampaignBuilderMemoryKit: () => createCampaignBuilderMemoryKit,
|
|
42
43
|
createCampaignBuilderProofReceipt: () => createCampaignBuilderProofReceipt,
|
|
43
44
|
createCampaignBuilderReadiness: () => createCampaignBuilderReadiness,
|
|
44
45
|
createCampaignBuilderToolRoute: () => createCampaignBuilderToolRoute,
|
|
@@ -264,25 +265,31 @@ var HttpClient = class {
|
|
|
264
265
|
async getToken() {
|
|
265
266
|
if (this.apiKey) return this.apiKey;
|
|
266
267
|
if (this.accessToken) return this.accessToken;
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
throw new SignalizError({
|
|
278
|
-
code: "AUTH_FAILED",
|
|
279
|
-
message: "Failed to obtain access token",
|
|
280
|
-
errorType: "auth_expired"
|
|
268
|
+
if (this.accessTokenPromise) return this.accessTokenPromise;
|
|
269
|
+
this.accessTokenPromise = (async () => {
|
|
270
|
+
const res = await fetch("https://api.signaliz.com/token", {
|
|
271
|
+
method: "POST",
|
|
272
|
+
headers: { "Content-Type": "application/json" },
|
|
273
|
+
body: JSON.stringify({
|
|
274
|
+
grant_type: "client_credentials",
|
|
275
|
+
client_id: this.clientId,
|
|
276
|
+
client_secret: this.clientSecret
|
|
277
|
+
})
|
|
281
278
|
});
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
279
|
+
if (!res.ok) {
|
|
280
|
+
throw new SignalizError({
|
|
281
|
+
code: "AUTH_FAILED",
|
|
282
|
+
message: "Failed to obtain access token",
|
|
283
|
+
errorType: "auth_expired"
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
const data = await res.json();
|
|
287
|
+
this.accessToken = data.access_token;
|
|
288
|
+
return this.accessToken;
|
|
289
|
+
})().finally(() => {
|
|
290
|
+
this.accessTokenPromise = void 0;
|
|
291
|
+
});
|
|
292
|
+
return this.accessTokenPromise;
|
|
286
293
|
}
|
|
287
294
|
};
|
|
288
295
|
function sleep(ms) {
|
|
@@ -531,7 +538,6 @@ var Signals = class {
|
|
|
531
538
|
if (params.online !== void 0) args.online = params.online;
|
|
532
539
|
if (params.targetSignalCount) args.target_signal_count = params.targetSignalCount;
|
|
533
540
|
if (params.lookbackDays) args.lookback_days = params.lookbackDays;
|
|
534
|
-
if (params.model) args.model = params.model;
|
|
535
541
|
if (params.enableDeepSearch) args.enable_deep_search = params.enableDeepSearch;
|
|
536
542
|
if (params.enableOutreachIntelligence) args.enable_outreach_intelligence = params.enableOutreachIntelligence;
|
|
537
543
|
if (params.enablePredictiveIntelligence) args.enable_predictive_intelligence = params.enablePredictiveIntelligence;
|
|
@@ -826,6 +832,10 @@ var Campaigns = class {
|
|
|
826
832
|
async artifacts(campaignBuildId) {
|
|
827
833
|
return this.listCampaignBuildArtifacts(campaignBuildId);
|
|
828
834
|
}
|
|
835
|
+
/** Generate fresh signed URLs for a downloadable campaign artifact. */
|
|
836
|
+
async downloadArtifact(campaignBuildId, options) {
|
|
837
|
+
return this.downloadCampaignArtifact(campaignBuildId, options);
|
|
838
|
+
}
|
|
829
839
|
/** Cancel a queued or running build. */
|
|
830
840
|
async cancel(campaignBuildId, reason) {
|
|
831
841
|
return this.cancelCampaignBuild(campaignBuildId, reason);
|
|
@@ -870,12 +880,16 @@ var Campaigns = class {
|
|
|
870
880
|
dryRun: isDryRun,
|
|
871
881
|
requestedTargetCount: data.requested_target_count,
|
|
872
882
|
plannedTargetCount: data.planned_target_count,
|
|
883
|
+
acquisitionMode: data.acquisition_mode,
|
|
884
|
+
acquisitionSource: data.acquisition_source,
|
|
885
|
+
cacheReusePolicy: data.cache_reuse_policy,
|
|
873
886
|
estimatedCredits: data.estimated_credits,
|
|
874
887
|
estimatedDurationSeconds: data.estimated_duration_seconds,
|
|
875
888
|
targetLimitApplied: data.target_limit_applied,
|
|
876
889
|
targetLimitReason: data.target_limit_reason,
|
|
877
890
|
maxSupportedTargetCount: data.max_supported_target_count,
|
|
878
891
|
brainContext: data.brain_context ?? {},
|
|
892
|
+
learningHoldout: data.learning_holdout ?? {},
|
|
879
893
|
providerRoute: mapProviderRoute(data)
|
|
880
894
|
};
|
|
881
895
|
}
|
|
@@ -891,14 +905,24 @@ var Campaigns = class {
|
|
|
891
905
|
});
|
|
892
906
|
return (data.artifacts ?? []).map(mapArtifact);
|
|
893
907
|
}
|
|
908
|
+
async downloadCampaignArtifact(campaignBuildId, options) {
|
|
909
|
+
const args = { campaign_build_id: campaignBuildId };
|
|
910
|
+
if (options?.format) args.format = options.format;
|
|
911
|
+
const data = await this.callMcp("download_campaign_artifact", args);
|
|
912
|
+
return mapArtifactDownloadResult(data);
|
|
913
|
+
}
|
|
894
914
|
async getCampaignBuildRows(campaignBuildId, options) {
|
|
895
915
|
const args = { campaign_build_id: campaignBuildId };
|
|
896
916
|
if (options?.limit) args.page_size = options.limit;
|
|
897
917
|
if (options?.cursor) args.cursor = options.cursor;
|
|
918
|
+
if (options?.includeData !== void 0) args.include_data = options.includeData;
|
|
919
|
+
if (options?.includeRaw !== void 0) args.include_raw = options.includeRaw;
|
|
898
920
|
const filters = {};
|
|
899
921
|
if (options?.segment) filters.segment = options.segment;
|
|
900
922
|
if (options?.rowStatus) filters.row_status = options.rowStatus;
|
|
901
923
|
if (options?.qualified !== void 0) filters.qualified = options.qualified;
|
|
924
|
+
if (options?.cached !== void 0) filters.cached = options.cached;
|
|
925
|
+
if (options?.exportReady !== void 0) filters.export_ready = options.exportReady;
|
|
902
926
|
if (Object.keys(filters).length > 0) args.filters = filters;
|
|
903
927
|
const data = await this.callMcp("get_campaign_build_rows", args);
|
|
904
928
|
return {
|
|
@@ -923,6 +947,7 @@ var Campaigns = class {
|
|
|
923
947
|
};
|
|
924
948
|
if (options?.destinationId) args.destination_id = options.destinationId;
|
|
925
949
|
if (options?.destinationConfig) args.destination_config = options.destinationConfig;
|
|
950
|
+
if (options?.allowPartialDelivery === true) args.allow_partial_delivery = true;
|
|
926
951
|
const data = await this.callMcp("approve_campaign_delivery", args);
|
|
927
952
|
return {
|
|
928
953
|
campaignBuildId: data.campaign_build_id,
|
|
@@ -931,7 +956,10 @@ var Campaigns = class {
|
|
|
931
956
|
message: data.message ?? "",
|
|
932
957
|
deliveryId: data.delivery_id,
|
|
933
958
|
deliveryIds: data.delivery_ids,
|
|
934
|
-
approvedCount: data.approved_count
|
|
959
|
+
approvedCount: data.approved_count,
|
|
960
|
+
partialDelivery: data.partial_delivery,
|
|
961
|
+
effectiveTargetCount: data.effective_target_count,
|
|
962
|
+
requestedTargetCount: data.requested_target_count
|
|
935
963
|
};
|
|
936
964
|
}
|
|
937
965
|
async cancelCampaignBuild(campaignBuildId, reason) {
|
|
@@ -984,17 +1012,50 @@ function mapStatus(data) {
|
|
|
984
1012
|
warnings: diagnosticMessages(data.warnings),
|
|
985
1013
|
errors: diagnosticMessages(data.errors),
|
|
986
1014
|
artifactCount: data.artifact_count ?? 0,
|
|
1015
|
+
artifactDownloads: Array.isArray(data.artifact_downloads) ? data.artifact_downloads.map(mapArtifactDownload) : [],
|
|
1016
|
+
customerRowCounts: mapCustomerRowCounts(data.customer_row_counts),
|
|
1017
|
+
phaseAttemptTotals: recordOrNull(data.phase_attempt_totals) ?? void 0,
|
|
987
1018
|
providerRoute: mapProviderRoute(data),
|
|
988
1019
|
triggerRunId: typeof data.trigger_run_id === "string" ? data.trigger_run_id : null,
|
|
989
1020
|
staleRunningPhase: data.stale_running_phase === true,
|
|
990
1021
|
phaseAgeSeconds: numberOrNull(data.phase_age_seconds),
|
|
991
1022
|
diagnostics: recordOrNull(data.diagnostics) ?? {},
|
|
992
1023
|
nextAction: formatNextAction(data.next_action),
|
|
1024
|
+
approvalAction: formatNextAction(data.approval_action),
|
|
993
1025
|
createdAt: data.created_at,
|
|
994
1026
|
updatedAt: data.updated_at,
|
|
995
1027
|
completedAt: data.completed_at
|
|
996
1028
|
};
|
|
997
1029
|
}
|
|
1030
|
+
function mapCustomerRowCounts(value) {
|
|
1031
|
+
const record = recordOrNull(value);
|
|
1032
|
+
if (!record) return void 0;
|
|
1033
|
+
return {
|
|
1034
|
+
requestedTarget: numberOrNull(record.requested_target),
|
|
1035
|
+
acquiredRows: numberOrNull(record.acquired_rows) ?? void 0,
|
|
1036
|
+
acceptedRows: numberOrNull(record.accepted_rows) ?? void 0,
|
|
1037
|
+
usableRows: numberOrNull(record.usable_rows) ?? void 0,
|
|
1038
|
+
copiedRows: numberOrNull(record.copied_rows) ?? void 0,
|
|
1039
|
+
approvalReadyRows: numberOrNull(record.approval_ready_rows) ?? void 0,
|
|
1040
|
+
qaReadyRows: numberOrNull(record.qa_ready_rows) ?? void 0,
|
|
1041
|
+
deliveredRows: numberOrNull(record.delivered_rows) ?? void 0,
|
|
1042
|
+
disqualifiedRows: numberOrNull(record.disqualified_rows) ?? void 0,
|
|
1043
|
+
reviewableRows: numberOrNull(record.reviewable_rows) ?? void 0,
|
|
1044
|
+
rowFailures: numberOrNull(record.row_failures) ?? void 0,
|
|
1045
|
+
acceptedShortfall: numberOrNull(record.accepted_shortfall),
|
|
1046
|
+
usableShortfall: numberOrNull(record.usable_shortfall),
|
|
1047
|
+
qaReadyShortfall: numberOrNull(record.qa_ready_shortfall),
|
|
1048
|
+
deliveryShortfall: numberOrNull(record.delivery_shortfall),
|
|
1049
|
+
fillRatio: numberOrNull(record.fill_ratio),
|
|
1050
|
+
qaReadyFillRatio: numberOrNull(record.qa_ready_fill_ratio),
|
|
1051
|
+
deliveredFillRatio: numberOrNull(record.delivered_fill_ratio),
|
|
1052
|
+
terminalReason: typeof record.terminal_reason === "string" ? record.terminal_reason : null,
|
|
1053
|
+
acceptedShortfallReason: typeof record.accepted_shortfall_reason === "string" ? record.accepted_shortfall_reason : null,
|
|
1054
|
+
usableShortfallReason: typeof record.usable_shortfall_reason === "string" ? record.usable_shortfall_reason : null,
|
|
1055
|
+
qaReadyShortfallReason: typeof record.qa_ready_shortfall_reason === "string" ? record.qa_ready_shortfall_reason : null,
|
|
1056
|
+
deliveryShortfallReason: typeof record.delivery_shortfall_reason === "string" ? record.delivery_shortfall_reason : null
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
998
1059
|
function mapProviderRoute(data) {
|
|
999
1060
|
const brainContext = recordOrNull(data?.brain_context);
|
|
1000
1061
|
const plan = recordOrNull(data?.provider_route_plan) ?? recordOrNull(brainContext?.provider_route_plan);
|
|
@@ -1072,13 +1133,56 @@ function mapArtifact(a) {
|
|
|
1072
1133
|
artifactType: a.artifact_type,
|
|
1073
1134
|
destination: a.destination,
|
|
1074
1135
|
storagePath: a.storage_path,
|
|
1136
|
+
format: a.format ?? null,
|
|
1075
1137
|
signedUrl: a.signed_url,
|
|
1138
|
+
downloadUrl: a.download_url ?? null,
|
|
1139
|
+
manifestUrl: a.manifest_url ?? null,
|
|
1140
|
+
expiresAt: a.expires_at ?? null,
|
|
1076
1141
|
rowCount: a.row_count ?? 0,
|
|
1077
1142
|
checksum: a.checksum,
|
|
1078
1143
|
metadata: a.metadata ?? {},
|
|
1079
1144
|
createdAt: a.created_at
|
|
1080
1145
|
};
|
|
1081
1146
|
}
|
|
1147
|
+
function mapArtifactDownload(data) {
|
|
1148
|
+
return {
|
|
1149
|
+
id: data.id,
|
|
1150
|
+
artifactType: data.artifact_type ?? null,
|
|
1151
|
+
format: data.format ?? null,
|
|
1152
|
+
rowCount: data.row_count ?? 0,
|
|
1153
|
+
signedUrl: data.signed_url ?? null,
|
|
1154
|
+
downloadUrl: data.download_url ?? null,
|
|
1155
|
+
manifestUrl: data.manifest_url ?? null,
|
|
1156
|
+
expiresAt: data.expires_at ?? null
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
function mapArtifactDownloadResult(data) {
|
|
1160
|
+
return {
|
|
1161
|
+
campaignBuildId: data.campaign_build_id,
|
|
1162
|
+
artifactId: data.artifact_id,
|
|
1163
|
+
format: data.format,
|
|
1164
|
+
rowCount: data.row_count ?? 0,
|
|
1165
|
+
byteSize: numberOrNull(data.byte_size),
|
|
1166
|
+
partCount: data.part_count ?? 0,
|
|
1167
|
+
checksum: data.checksum ?? null,
|
|
1168
|
+
signedUrl: data.signed_url ?? null,
|
|
1169
|
+
downloadUrl: data.download_url ?? null,
|
|
1170
|
+
manifestUrl: data.manifest_url ?? null,
|
|
1171
|
+
expiresAt: data.expires_at ?? null,
|
|
1172
|
+
parts: Array.isArray(data.parts) ? data.parts.map(mapArtifactDownloadPart) : [],
|
|
1173
|
+
downloadCommands: recordOrNull(data.download_commands) ?? {},
|
|
1174
|
+
expiresInSeconds: numberOrNull(data.expires_in_seconds)
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
function mapArtifactDownloadPart(data) {
|
|
1178
|
+
return {
|
|
1179
|
+
partIndex: data.part_index ?? 0,
|
|
1180
|
+
rowCount: data.row_count ?? 0,
|
|
1181
|
+
byteSize: numberOrNull(data.byte_size),
|
|
1182
|
+
checksum: data.checksum ?? null,
|
|
1183
|
+
signedUrl: data.signed_url ?? null
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1082
1186
|
function mapScope(data) {
|
|
1083
1187
|
return {
|
|
1084
1188
|
campaignScopeId: data.campaign_scope_id,
|
|
@@ -1132,8 +1236,29 @@ function buildArgs(request) {
|
|
|
1132
1236
|
if (request.allowDownscale !== void 0) args.allow_downscale = request.allowDownscale;
|
|
1133
1237
|
if (request.confirmSpend !== void 0) args.confirm_spend = request.confirmSpend;
|
|
1134
1238
|
if (request.dedupKeys) args.dedup_keys = request.dedupKeys;
|
|
1239
|
+
if (request.acquisitionMode) args.acquisition_mode = request.acquisitionMode;
|
|
1240
|
+
if (request.cacheReusePolicy) {
|
|
1241
|
+
args.cache_reuse_policy = {
|
|
1242
|
+
allow_verified_cache: request.cacheReusePolicy.allowVerifiedCache,
|
|
1243
|
+
suppress_prior_campaign_ids: request.cacheReusePolicy.suppressPriorCampaignIds,
|
|
1244
|
+
suppress_prior_list_ids: request.cacheReusePolicy.suppressPriorListIds,
|
|
1245
|
+
uniqueness: request.cacheReusePolicy.uniqueness,
|
|
1246
|
+
require_usage_metadata: request.cacheReusePolicy.requireUsageMetadata
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1135
1249
|
if (request.brainPreflight) args.brain_preflight = request.brainPreflight;
|
|
1136
1250
|
if (request.brainDefaults) args.brain_defaults = request.brainDefaults;
|
|
1251
|
+
if (request.learningHoldout) {
|
|
1252
|
+
args.learning_holdout = {
|
|
1253
|
+
enabled: request.learningHoldout.enabled,
|
|
1254
|
+
control_percentage: request.learningHoldout.controlPercentage,
|
|
1255
|
+
min_control_size: request.learningHoldout.minControlSize,
|
|
1256
|
+
experiment_key: request.learningHoldout.experimentKey,
|
|
1257
|
+
source_campaign_id: request.learningHoldout.sourceCampaignId,
|
|
1258
|
+
primary_metric: request.learningHoldout.primaryMetric
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
if (request.campaignStrategyContext) args.campaign_strategy_context = request.campaignStrategyContext;
|
|
1137
1262
|
if (request.deliveryRisk) args.delivery_risk = request.deliveryRisk;
|
|
1138
1263
|
if (request.icp) {
|
|
1139
1264
|
args.icp = {
|
|
@@ -1175,7 +1300,17 @@ function buildArgs(request) {
|
|
|
1175
1300
|
max_body_words: request.copy.maxBodyWords,
|
|
1176
1301
|
sender_context: request.copy.senderContext,
|
|
1177
1302
|
offer_context: request.copy.offerContext,
|
|
1178
|
-
model: request.copy.model
|
|
1303
|
+
model: request.copy.model,
|
|
1304
|
+
style_source: request.copy.styleSource ? {
|
|
1305
|
+
sample_text: request.copy.styleSource.sampleText,
|
|
1306
|
+
campaign_ids: request.copy.styleSource.campaignIds,
|
|
1307
|
+
artifact_ids: request.copy.styleSource.artifactIds
|
|
1308
|
+
} : void 0,
|
|
1309
|
+
sequence_steps: request.copy.sequenceSteps,
|
|
1310
|
+
copy_schema: request.copy.copySchema,
|
|
1311
|
+
banned_phrases: request.copy.bannedPhrases,
|
|
1312
|
+
approval_required: request.copy.approvalRequired,
|
|
1313
|
+
quality_tier: request.copy.qualityTier
|
|
1179
1314
|
};
|
|
1180
1315
|
}
|
|
1181
1316
|
if (request.delivery) {
|
|
@@ -1238,6 +1373,8 @@ var DEFAULT_SIGNALIZ_CAMPAIGN_BUILDER_DEFAULTS = {
|
|
|
1238
1373
|
}
|
|
1239
1374
|
};
|
|
1240
1375
|
var DEFAULT_CAMPAIGN_BUILDER_BUILT_INS = [
|
|
1376
|
+
"company_discovery",
|
|
1377
|
+
"people_discovery",
|
|
1241
1378
|
"lead_generation",
|
|
1242
1379
|
"email_finding",
|
|
1243
1380
|
"email_verification",
|
|
@@ -1246,6 +1383,8 @@ var DEFAULT_CAMPAIGN_BUILDER_BUILT_INS = [
|
|
|
1246
1383
|
var CAMPAIGN_BUILDER_BUILT_IN_ROUTE_IDS = {
|
|
1247
1384
|
lead_generation: "signaliz-lead-generation",
|
|
1248
1385
|
local_leads: "signaliz-local-leads",
|
|
1386
|
+
company_discovery: "signaliz-company-discovery",
|
|
1387
|
+
people_discovery: "signaliz-people-discovery",
|
|
1249
1388
|
email_finding: "signaliz-email-finding",
|
|
1250
1389
|
email_verification: "signaliz-email-verification",
|
|
1251
1390
|
signals: "signaliz-signals"
|
|
@@ -1263,8 +1402,8 @@ var CAMPAIGN_BUILDER_OPERATING_PLAYBOOKS = [
|
|
|
1263
1402
|
slug: "cache-first-large-list",
|
|
1264
1403
|
label: "Cache-First Large List",
|
|
1265
1404
|
whenToUse: [
|
|
1266
|
-
"The
|
|
1267
|
-
"The deliverable is a
|
|
1405
|
+
"The operator explicitly references a previous campaign, prior list, seed list, or suppression baseline.",
|
|
1406
|
+
"The deliverable is a top-up, continuation, or backfill where prior campaign context should guide reuse."
|
|
1268
1407
|
],
|
|
1269
1408
|
sequence: [
|
|
1270
1409
|
"Inventory reusable cache before paid sourcing.",
|
|
@@ -1470,7 +1609,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1470
1609
|
],
|
|
1471
1610
|
requireVerifiedEmail: true
|
|
1472
1611
|
},
|
|
1473
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1612
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1474
1613
|
preferredProviders: ["signaliz_native"],
|
|
1475
1614
|
memoryQueries: [{
|
|
1476
1615
|
query: "industrial OT net-new prior email suppression verified manufacturing embedded systems field service cyber resilience business continuity",
|
|
@@ -1544,7 +1683,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1544
1683
|
],
|
|
1545
1684
|
requireVerifiedEmail: true
|
|
1546
1685
|
},
|
|
1547
|
-
builtIns: ["lead_generation", "local_leads", "email_finding", "email_verification", "signals"],
|
|
1686
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "local_leads", "email_finding", "email_verification", "signals"],
|
|
1548
1687
|
preferredProviders: ["signaliz_native", "octave", "clay_webhook", "apify"],
|
|
1549
1688
|
memoryQueries: [{
|
|
1550
1689
|
query: "mature non-medical home care agencies billable hours franchise caregiver recruiting proof gate qualification export approval",
|
|
@@ -1610,7 +1749,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1610
1749
|
exclusions: ["enterprise holding company", "staffing", "recruiting", "software-only vendor", "freelancer-only profile"],
|
|
1611
1750
|
requireVerifiedEmail: true
|
|
1612
1751
|
},
|
|
1613
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1752
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1614
1753
|
preferredProviders: ["signaliz_native", "octave"],
|
|
1615
1754
|
memoryQueries: [{
|
|
1616
1755
|
query: "agency founder owner CEO marketing services suppression domain pool email verification final approval gate",
|
|
@@ -1692,7 +1831,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1692
1831
|
],
|
|
1693
1832
|
requireVerifiedEmail: true
|
|
1694
1833
|
},
|
|
1695
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1834
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1696
1835
|
preferredProviders: ["signaliz_native", "octave"],
|
|
1697
1836
|
memoryQueries: [{
|
|
1698
1837
|
query: "cloud hosting infrastructure VMware Broadcom qualification verified email persona trigger SKU mapping",
|
|
@@ -1725,25 +1864,21 @@ var CampaignBuilderAgent = class {
|
|
|
1725
1864
|
async createPlan(request, options = {}) {
|
|
1726
1865
|
const resolvedRequest = applyCampaignBuilderStrategyTemplate(request);
|
|
1727
1866
|
const warnings = [];
|
|
1728
|
-
const workspaceContext =
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1867
|
+
const [workspaceContext, scopeResult] = await Promise.all([
|
|
1868
|
+
resolvedRequest.workspaceContext ? Promise.resolve(resolvedRequest.workspaceContext) : this.getWorkspaceContext(warnings),
|
|
1869
|
+
options.scopeCampaign === false ? Promise.resolve(void 0) : this.scopeCampaign(resolvedRequest, warnings),
|
|
1870
|
+
options.discoverCapabilities === false ? Promise.resolve(void 0) : this.discoverPlannedRoutes(resolvedRequest, warnings)
|
|
1871
|
+
]);
|
|
1733
1872
|
const plan = createCampaignBuilderAgentPlan(resolvedRequest, {
|
|
1734
1873
|
workspaceContext,
|
|
1735
1874
|
scopeBuildArgs: asRecord(scopeResult?.build_campaign_args ?? scopeResult?.buildCampaignArgs),
|
|
1736
1875
|
warnings
|
|
1737
1876
|
});
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
}
|
|
1744
|
-
if (options.includeDeliveryRisk !== false) {
|
|
1745
|
-
await this.attachDeliveryRiskPreflight(plan, warnings);
|
|
1746
|
-
}
|
|
1877
|
+
await Promise.all([
|
|
1878
|
+
options.includeStrategyMemoryStatus === false ? Promise.resolve() : this.attachStrategyMemoryStatus(plan, warnings),
|
|
1879
|
+
options.includeKernelPlan === false ? Promise.resolve() : this.attachKernelCampaignBuildPlan(plan, warnings),
|
|
1880
|
+
options.includeDeliveryRisk === false ? Promise.resolve() : this.attachDeliveryRiskPreflight(plan, warnings)
|
|
1881
|
+
]);
|
|
1747
1882
|
return plan;
|
|
1748
1883
|
}
|
|
1749
1884
|
async readiness(request, options = {}) {
|
|
@@ -1760,6 +1895,9 @@ var CampaignBuilderAgent = class {
|
|
|
1760
1895
|
buildKit(options = {}) {
|
|
1761
1896
|
return createCampaignBuilderBuildKit(options);
|
|
1762
1897
|
}
|
|
1898
|
+
memoryKit(options = {}) {
|
|
1899
|
+
return createCampaignBuilderMemoryKit(options);
|
|
1900
|
+
}
|
|
1763
1901
|
async commitPlan(plan, options = {}) {
|
|
1764
1902
|
const writeMode = options.confirm === true && options.dryRun === false;
|
|
1765
1903
|
if (writeMode && !options.approvedBy) {
|
|
@@ -1788,6 +1926,7 @@ var CampaignBuilderAgent = class {
|
|
|
1788
1926
|
},
|
|
1789
1927
|
brain_defaults: plan.buildRequest.brainDefaults,
|
|
1790
1928
|
brain_preflight: plan.buildRequest.brainPreflight,
|
|
1929
|
+
campaign_strategy_context: plan.buildRequest.campaignStrategyContext,
|
|
1791
1930
|
delivery_risk_preflight: plan.buildRequest.deliveryRisk,
|
|
1792
1931
|
delivery_risk: plan.buildRequest.deliveryRisk
|
|
1793
1932
|
}),
|
|
@@ -1909,7 +2048,8 @@ var CampaignBuilderAgent = class {
|
|
|
1909
2048
|
const destinationType = options.deliveryDestinationType ?? plan.buildRequest.delivery?.destinationType ?? "json";
|
|
1910
2049
|
result.deliveryApproval = await this.approveCampaignDelivery(campaignBuildId, destinationType, {
|
|
1911
2050
|
destinationId: options.deliveryDestinationId,
|
|
1912
|
-
destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig
|
|
2051
|
+
destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig,
|
|
2052
|
+
allowPartialDelivery: options.allowPartialDelivery
|
|
1913
2053
|
});
|
|
1914
2054
|
finalStatus = await this.waitForCampaignBuildStatus(
|
|
1915
2055
|
campaignBuildId,
|
|
@@ -1932,8 +2072,12 @@ var CampaignBuilderAgent = class {
|
|
|
1932
2072
|
const args = compact({
|
|
1933
2073
|
campaign_build_id: campaignBuildId,
|
|
1934
2074
|
page_size: options.limit,
|
|
1935
|
-
cursor: options.cursor
|
|
2075
|
+
cursor: options.cursor,
|
|
2076
|
+
include_data: options.includeData,
|
|
2077
|
+
include_raw: options.includeRaw
|
|
1936
2078
|
});
|
|
2079
|
+
if (options.cached !== void 0) filters.cached = options.cached;
|
|
2080
|
+
if (options.exportReady !== void 0) filters.export_ready = options.exportReady;
|
|
1937
2081
|
if (Object.keys(filters).length > 0) args.filters = filters;
|
|
1938
2082
|
const data = await this.callMcp("get_campaign_build_rows", args);
|
|
1939
2083
|
return mapAgentCampaignRowsResult(data);
|
|
@@ -1948,12 +2092,14 @@ var CampaignBuilderAgent = class {
|
|
|
1948
2092
|
return this.approveCampaignDelivery(campaignBuildId, destinationType, options);
|
|
1949
2093
|
}
|
|
1950
2094
|
async reviewBuild(campaignBuildId, options = {}) {
|
|
1951
|
-
const status = await
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
2095
|
+
const [status, rows, artifacts] = await Promise.all([
|
|
2096
|
+
this.getBuildStatus(campaignBuildId),
|
|
2097
|
+
this.getBuildRows(campaignBuildId, {
|
|
2098
|
+
...options,
|
|
2099
|
+
limit: options.limit ?? 100
|
|
2100
|
+
}),
|
|
2101
|
+
this.listBuildArtifacts(campaignBuildId)
|
|
2102
|
+
]);
|
|
1957
2103
|
return createCampaignBuilderBuildReview(status, rows, artifacts);
|
|
1958
2104
|
}
|
|
1959
2105
|
async getCampaignBuildStatus(campaignBuildId) {
|
|
@@ -1981,7 +2127,8 @@ var CampaignBuilderAgent = class {
|
|
|
1981
2127
|
campaign_build_id: campaignBuildId,
|
|
1982
2128
|
destination_type: destinationType,
|
|
1983
2129
|
destination_id: options?.destinationId,
|
|
1984
|
-
destination_config: options?.destinationConfig
|
|
2130
|
+
destination_config: options?.destinationConfig,
|
|
2131
|
+
allow_partial_delivery: options?.allowPartialDelivery === true ? true : void 0
|
|
1985
2132
|
});
|
|
1986
2133
|
const data = await this.callMcp("approve_campaign_delivery", args);
|
|
1987
2134
|
return {
|
|
@@ -1991,7 +2138,10 @@ var CampaignBuilderAgent = class {
|
|
|
1991
2138
|
message: data.message ?? "",
|
|
1992
2139
|
deliveryId: data.delivery_id,
|
|
1993
2140
|
deliveryIds: data.delivery_ids,
|
|
1994
|
-
approvedCount: data.approved_count
|
|
2141
|
+
approvedCount: data.approved_count,
|
|
2142
|
+
partialDelivery: data.partial_delivery,
|
|
2143
|
+
effectiveTargetCount: data.effective_target_count,
|
|
2144
|
+
requestedTargetCount: data.requested_target_count
|
|
1995
2145
|
};
|
|
1996
2146
|
}
|
|
1997
2147
|
async getWorkspaceContext(warnings) {
|
|
@@ -2027,15 +2177,19 @@ var CampaignBuilderAgent = class {
|
|
|
2027
2177
|
const providers = new Set(
|
|
2028
2178
|
[...request.integrations ?? [], ...routesFromCustomerTools(request.customerTools ?? [])].filter((route) => route.provider !== "signaliz").map((route) => route.provider)
|
|
2029
2179
|
);
|
|
2030
|
-
|
|
2180
|
+
const warningsByProvider = await Promise.all(Array.from(providers, async (provider) => {
|
|
2031
2181
|
try {
|
|
2032
2182
|
await this.callMcp("discover_capabilities", {
|
|
2033
2183
|
query: `campaign builder ${provider} ${request.goal}`,
|
|
2034
2184
|
category: "campaign"
|
|
2035
2185
|
});
|
|
2186
|
+
return void 0;
|
|
2036
2187
|
} catch (error) {
|
|
2037
|
-
|
|
2188
|
+
return `Capability discovery for ${provider} failed: ${errorMessage(error)}`;
|
|
2038
2189
|
}
|
|
2190
|
+
}));
|
|
2191
|
+
for (const warning of warningsByProvider) {
|
|
2192
|
+
if (warning) warnings.push(warning);
|
|
2039
2193
|
}
|
|
2040
2194
|
}
|
|
2041
2195
|
async attachStrategyMemoryStatus(plan, warnings) {
|
|
@@ -2059,8 +2213,24 @@ var CampaignBuilderAgent = class {
|
|
|
2059
2213
|
const kernelPlan = await this.callMcp("gtm_campaign_build_plan", asRecord(plannerStep.arguments));
|
|
2060
2214
|
plan.kernelPlan = asRecord(kernelPlan);
|
|
2061
2215
|
const brainDefaults = asRecord(plan.kernelPlan.brain_defaults ?? plan.kernelPlan.brainDefaults);
|
|
2216
|
+
const corpusContext = asRecord(plan.kernelPlan.corpus_context ?? plan.kernelPlan.corpusContext);
|
|
2217
|
+
const campaignStrategyContext = asRecord(plan.kernelPlan.campaign_strategy_context ?? plan.kernelPlan.campaignStrategyContext);
|
|
2218
|
+
const memoryExamples = Array.isArray(plan.kernelPlan.memory_examples) ? plan.kernelPlan.memory_examples.map((item) => asRecord(item)).filter((item) => Object.keys(item).length > 0).slice(0, 15) : [];
|
|
2062
2219
|
if (Object.keys(brainDefaults).length > 0 && Object.keys(asRecord(plan.buildRequest.brainDefaults)).length === 0) {
|
|
2063
2220
|
plan.buildRequest.brainDefaults = brainDefaults;
|
|
2221
|
+
}
|
|
2222
|
+
if (Object.keys(campaignStrategyContext).length > 0) {
|
|
2223
|
+
plan.buildRequest.campaignStrategyContext = campaignStrategyContext;
|
|
2224
|
+
}
|
|
2225
|
+
if (Object.keys(corpusContext).length > 0 || memoryExamples.length > 0 || Object.keys(brainDefaults).length > 0 || Object.keys(campaignStrategyContext).length > 0) {
|
|
2226
|
+
plan.buildRequest.brainPreflight = compact({
|
|
2227
|
+
...asRecord(plan.buildRequest.brainPreflight),
|
|
2228
|
+
corpus_context: Object.keys(corpusContext).length > 0 ? corpusContext : void 0,
|
|
2229
|
+
memory_examples: memoryExamples.length > 0 ? memoryExamples : void 0,
|
|
2230
|
+
brain_defaults: Object.keys(brainDefaults).length > 0 ? brainDefaults : void 0,
|
|
2231
|
+
campaign_strategy_context: Object.keys(campaignStrategyContext).length > 0 ? campaignStrategyContext : void 0
|
|
2232
|
+
});
|
|
2233
|
+
plan.brainPreflight = asRecord(plan.buildRequest.brainPreflight);
|
|
2064
2234
|
refreshBuildStepArguments(plan);
|
|
2065
2235
|
}
|
|
2066
2236
|
} catch (error) {
|
|
@@ -2241,6 +2411,9 @@ function createCampaignBuilderProofReceipt(plan, result) {
|
|
|
2241
2411
|
campaign_build_id: dryRunResult.campaignBuildId ?? dryRunResult.campaign_build_id ?? null
|
|
2242
2412
|
}
|
|
2243
2413
|
];
|
|
2414
|
+
const learnBackPlan = summarizeCampaignBuilderProofLearnBack(
|
|
2415
|
+
asRecord(asRecord(plan.buildRequest.brainPreflight).learn_back_plan ?? asRecord(plan.brainPreflight).learn_back_plan)
|
|
2416
|
+
);
|
|
2244
2417
|
return {
|
|
2245
2418
|
receipt_version: "campaign-agent-proof.v1",
|
|
2246
2419
|
source: "signaliz.campaignBuilderAgent.proof",
|
|
@@ -2263,6 +2436,7 @@ function createCampaignBuilderProofReceipt(plan, result) {
|
|
|
2263
2436
|
gates,
|
|
2264
2437
|
strategy_memory_status: summarizeCampaignBuilderProofStrategyMemory(strategyMemory),
|
|
2265
2438
|
dry_run_result: summarizeCampaignBuilderProofDryRun(dryRunResult),
|
|
2439
|
+
learn_back_plan: learnBackPlan,
|
|
2266
2440
|
recommended_next_actions: [
|
|
2267
2441
|
"Review the plan, approvals, and dry-run result.",
|
|
2268
2442
|
"Use campaign-agent commit-plan --confirm-write only after review.",
|
|
@@ -2480,6 +2654,12 @@ function createCampaignBuilderBuildKit(input = {}) {
|
|
|
2480
2654
|
command: `${cliBase} campaign-agent init${strategyFlag}${targetFlag}${localLeadsFlag} --output-file ${shellArg(requestFile)}`,
|
|
2481
2655
|
safety: "local file only; no MCP calls, credits, provider writes, sender loads, exports, or sends"
|
|
2482
2656
|
},
|
|
2657
|
+
{
|
|
2658
|
+
id: "memory_kit",
|
|
2659
|
+
label: "Inspect memory readiness and seed runner",
|
|
2660
|
+
command: `${sdkCliBase} campaign-agent memory-kit${strategyFlag}${targetFlag}${localLeadsFlag} --request-file ${shellArg(requestFile)} --json`,
|
|
2661
|
+
safety: "read-only memory readiness packet plus local seed dry-run commands"
|
|
2662
|
+
},
|
|
2483
2663
|
{
|
|
2484
2664
|
id: "proof_shortcut",
|
|
2485
2665
|
label: "Run no-spend campaign-builder proof",
|
|
@@ -2574,6 +2754,147 @@ function createCampaignBuilderBuildKit(input = {}) {
|
|
|
2574
2754
|
]
|
|
2575
2755
|
};
|
|
2576
2756
|
}
|
|
2757
|
+
function createCampaignBuilderMemoryKit(input = {}) {
|
|
2758
|
+
const requestFile = input.requestFile || "campaign-request.json";
|
|
2759
|
+
const seedManifestFile = input.seedManifestFile || ".gtm-kernel-import-state/campaign-memory-dry-run.json";
|
|
2760
|
+
const cliPackage = input.cliPackage || "@signaliz/cli";
|
|
2761
|
+
const sdkPackage = input.sdkPackage || "@signaliz/sdk";
|
|
2762
|
+
const request = createCampaignBuilderAgentRequestTemplate(input);
|
|
2763
|
+
const strategyTemplate = stringValue(request.strategyTemplate) ?? null;
|
|
2764
|
+
const strategyFlag = strategyTemplate ? ` --strategy-template ${shellArg(strategyTemplate)}` : "";
|
|
2765
|
+
const targetFlag = request.targetCount ? ` --target-count ${request.targetCount}` : "";
|
|
2766
|
+
const localLeadsFlag = request.builtIns?.includes("local_leads") ? " --use-local-leads" : "";
|
|
2767
|
+
const cliBase = `npx ${cliPackage}`;
|
|
2768
|
+
const sdkCliBase = `npx ${sdkPackage}`;
|
|
2769
|
+
const source = campaignBuilderMemoryKitSource(input.source);
|
|
2770
|
+
const workspaceId = input.workspaceId || "your-workspace-id";
|
|
2771
|
+
const brief = request.goal || "Build a strategy-template campaign for the target ICP.";
|
|
2772
|
+
const statusArgs = compact({
|
|
2773
|
+
strategy_template: strategyTemplate,
|
|
2774
|
+
campaign_brief: brief,
|
|
2775
|
+
target_icp: request.icp,
|
|
2776
|
+
include_sources: true,
|
|
2777
|
+
include_samples: false,
|
|
2778
|
+
days: 90,
|
|
2779
|
+
limit: 25
|
|
2780
|
+
});
|
|
2781
|
+
const searchArgs = compact({
|
|
2782
|
+
query: request.memory?.queries?.[0]?.query || brief,
|
|
2783
|
+
layers: ["lead_generation", "email_finding", "email_verification", "company_enrichment", "copy_enrichment"],
|
|
2784
|
+
limit: 10
|
|
2785
|
+
});
|
|
2786
|
+
return {
|
|
2787
|
+
kit_version: "campaign-memory-kit.v1",
|
|
2788
|
+
source: "signaliz.campaignBuilderAgent.memoryKit",
|
|
2789
|
+
read_only: true,
|
|
2790
|
+
no_spend: true,
|
|
2791
|
+
no_provider_writes: true,
|
|
2792
|
+
client_names_allowed: false,
|
|
2793
|
+
request_file: requestFile,
|
|
2794
|
+
seed_manifest_file: seedManifestFile,
|
|
2795
|
+
request,
|
|
2796
|
+
strategy_template: strategyTemplate,
|
|
2797
|
+
operating_playbooks: getCampaignBuilderOperatingPlaybooksForRequest(request).map((playbook) => playbook.slug),
|
|
2798
|
+
memory_sources: source.memorySources,
|
|
2799
|
+
seed_runner: {
|
|
2800
|
+
local_script: "scripts/gtm-kernel/seed-import-runner.mjs",
|
|
2801
|
+
dry_run_command: [
|
|
2802
|
+
"node scripts/gtm-kernel/seed-import-runner.mjs",
|
|
2803
|
+
`--source ${source.seedSource}`,
|
|
2804
|
+
"--dry-run",
|
|
2805
|
+
`--workspace-id ${shellArg(input.workspaceId || "00000000-0000-4000-8000-000000000000")}`,
|
|
2806
|
+
`--manifest ${shellArg(seedManifestFile)}`,
|
|
2807
|
+
"--reset"
|
|
2808
|
+
].join(" "),
|
|
2809
|
+
verify_manifest_command: source.verifyScript ? `node ${source.verifyScript} ${shellArg(seedManifestFile)}` : null,
|
|
2810
|
+
write_command: `GTM_KERNEL_WORKSPACE_ID=${shellArg(workspaceId)} node scripts/gtm-kernel/seed-import-runner.mjs --source ${source.seedSource} --write`,
|
|
2811
|
+
write_requires: ["SUPABASE_URL", "SUPABASE_SERVICE_ROLE_KEY", "GTM_KERNEL_WORKSPACE_ID", "explicit operator approval"]
|
|
2812
|
+
},
|
|
2813
|
+
cli_commands: [
|
|
2814
|
+
{
|
|
2815
|
+
id: "memory_status",
|
|
2816
|
+
label: "Check strategy memory readiness",
|
|
2817
|
+
command: `${sdkCliBase} gtm strategy-memory${strategyFlag} --brief ${shellArg(brief)} --json`,
|
|
2818
|
+
safety: "read-only MCP memory readiness; no credits, provider writes, sender loads, exports, or sends"
|
|
2819
|
+
},
|
|
2820
|
+
{
|
|
2821
|
+
id: "memory_search",
|
|
2822
|
+
label: "Search ranked campaign memory",
|
|
2823
|
+
command: `${sdkCliBase} gtm memory search --query ${shellArg(String(searchArgs.query || brief))} --limit 10 --json`,
|
|
2824
|
+
safety: "read-only ranked memory lookup"
|
|
2825
|
+
},
|
|
2826
|
+
{
|
|
2827
|
+
id: "seed_dry_run",
|
|
2828
|
+
label: "Dry-run private memory seed import",
|
|
2829
|
+
command: [
|
|
2830
|
+
"node scripts/gtm-kernel/seed-import-runner.mjs",
|
|
2831
|
+
`--source ${source.seedSource}`,
|
|
2832
|
+
"--dry-run",
|
|
2833
|
+
`--workspace-id ${shellArg(input.workspaceId || "00000000-0000-4000-8000-000000000000")}`,
|
|
2834
|
+
`--manifest ${shellArg(seedManifestFile)}`,
|
|
2835
|
+
"--reset"
|
|
2836
|
+
].join(" "),
|
|
2837
|
+
safety: "local extraction and manifest only; no database writes"
|
|
2838
|
+
},
|
|
2839
|
+
{
|
|
2840
|
+
id: "write_request",
|
|
2841
|
+
label: "Write reusable campaign request JSON",
|
|
2842
|
+
command: `${cliBase} campaign-agent init${strategyFlag}${targetFlag}${localLeadsFlag} --output-file ${shellArg(requestFile)}`,
|
|
2843
|
+
safety: "local file only; no MCP calls, credits, provider writes, sender loads, exports, or sends"
|
|
2844
|
+
},
|
|
2845
|
+
{
|
|
2846
|
+
id: "proof",
|
|
2847
|
+
label: "Run campaign proof after memory check",
|
|
2848
|
+
command: `${cliBase} campaign-agent proof --request-file ${shellArg(requestFile)} --json`,
|
|
2849
|
+
safety: "read-only planning plus forced build_campaign dry-run with confirm_spend=false"
|
|
2850
|
+
}
|
|
2851
|
+
],
|
|
2852
|
+
mcp_calls: [
|
|
2853
|
+
{
|
|
2854
|
+
id: "strategy_memory_status",
|
|
2855
|
+
tool: "gtm_campaign_strategy_memory_status",
|
|
2856
|
+
arguments: statusArgs,
|
|
2857
|
+
safety: "read-only strategy/workflow memory readiness with sources and no raw samples"
|
|
2858
|
+
},
|
|
2859
|
+
{
|
|
2860
|
+
id: "memory_search",
|
|
2861
|
+
tool: "gtm_memory_search",
|
|
2862
|
+
arguments: searchArgs,
|
|
2863
|
+
safety: "read-only ranked memory lookup"
|
|
2864
|
+
},
|
|
2865
|
+
{
|
|
2866
|
+
id: "campaign_agent_plan",
|
|
2867
|
+
tool: "gtm_campaign_agent_plan",
|
|
2868
|
+
arguments: campaignBuilderBuildKitMcpArgs(request),
|
|
2869
|
+
safety: "read-only campaign-agent plan using built-in Signaliz lanes, memory, Brain, Nango, and BYO routes"
|
|
2870
|
+
},
|
|
2871
|
+
{
|
|
2872
|
+
id: "campaign_agent_proof",
|
|
2873
|
+
tool: "gtm_campaign_agent_proof",
|
|
2874
|
+
arguments: { ...campaignBuilderBuildKitMcpArgs(request), idempotency_key: "campaign-agent-memory-proof-001" },
|
|
2875
|
+
safety: "forces build_campaign dry_run=true and confirm_spend=false after readiness"
|
|
2876
|
+
}
|
|
2877
|
+
],
|
|
2878
|
+
sdk_example: {
|
|
2879
|
+
language: "typescript",
|
|
2880
|
+
code: campaignBuilderMemoryKitSdkExample(request, seedManifestFile)
|
|
2881
|
+
},
|
|
2882
|
+
privacy: {
|
|
2883
|
+
client_names_allowed: false,
|
|
2884
|
+
notes: [
|
|
2885
|
+
"Use strategy templates, operating playbooks, memory dimensions, and anonymized campaign patterns instead of client names.",
|
|
2886
|
+
"Do not expose raw leads, private replies, domains, secrets, provider payloads, or customer account labels in kit output.",
|
|
2887
|
+
"Seed writes are workspace-private and require explicit operator approval plus Supabase service credentials."
|
|
2888
|
+
]
|
|
2889
|
+
},
|
|
2890
|
+
next_actions: [
|
|
2891
|
+
"Run memory_status before plan/proof so missing strategy coverage is visible.",
|
|
2892
|
+
`Run seed_dry_run and inspect ${seedManifestFile} before any memory write.`,
|
|
2893
|
+
"Use write_request to save the reusable campaign request, then run proof with no spend.",
|
|
2894
|
+
"Add BYO tools through campaign-agent --custom-tool only after route setup is reviewed."
|
|
2895
|
+
]
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2577
2898
|
function createCampaignBuilderToolRoute(input) {
|
|
2578
2899
|
return {
|
|
2579
2900
|
provider: input.provider ?? "custom_mcp",
|
|
@@ -2643,6 +2964,96 @@ function campaignBuilderBuildKitSdkExample(request, requestFile) {
|
|
|
2643
2964
|
"}"
|
|
2644
2965
|
].join("\n");
|
|
2645
2966
|
}
|
|
2967
|
+
function campaignBuilderMemoryKitSdkExample(request, seedManifestFile) {
|
|
2968
|
+
const input = {
|
|
2969
|
+
goal: request.goal,
|
|
2970
|
+
strategyTemplate: request.strategyTemplate,
|
|
2971
|
+
targetCount: request.targetCount,
|
|
2972
|
+
builtIns: request.builtIns
|
|
2973
|
+
};
|
|
2974
|
+
return [
|
|
2975
|
+
"import { Signaliz, createCampaignBuilderMemoryKit } from '@signaliz/sdk';",
|
|
2976
|
+
"",
|
|
2977
|
+
`const kit = createCampaignBuilderMemoryKit({ seedManifestFile: ${JSON.stringify(seedManifestFile)}, ...${JSON.stringify(input, null, 2)} });`,
|
|
2978
|
+
"console.log(kit.cli_commands.find((command) => command.id === 'memory_status')?.command);",
|
|
2979
|
+
"",
|
|
2980
|
+
"const signaliz = new Signaliz({ apiKey: process.env.SIGNALIZ_API_KEY! });",
|
|
2981
|
+
"const status = await signaliz.gtm.campaignStrategyMemoryStatus({",
|
|
2982
|
+
" strategyTemplate: kit.request.strategyTemplate,",
|
|
2983
|
+
" campaignBrief: kit.request.goal,",
|
|
2984
|
+
" includeSources: true,",
|
|
2985
|
+
" includeSamples: false,",
|
|
2986
|
+
"});",
|
|
2987
|
+
"",
|
|
2988
|
+
"if (status?.ready === false) {",
|
|
2989
|
+
" throw new Error('Strategy memory is not ready for this campaign request');",
|
|
2990
|
+
"}"
|
|
2991
|
+
].join("\n");
|
|
2992
|
+
}
|
|
2993
|
+
function campaignBuilderMemoryKitSource(source) {
|
|
2994
|
+
const normalized = normalizeTemplateKey(source || "agency");
|
|
2995
|
+
const catalog = {
|
|
2996
|
+
northStar: {
|
|
2997
|
+
id: "north_star_campaign_builder",
|
|
2998
|
+
label: "North Star campaign-builder acceptance patterns",
|
|
2999
|
+
seed_source: "north-star",
|
|
3000
|
+
scope: "redacted_acceptance_seed_packs",
|
|
3001
|
+
privacy: "redacted aggregate counts, QA gates, and fixture shape only"
|
|
3002
|
+
},
|
|
3003
|
+
agency: {
|
|
3004
|
+
id: "agency_campaign_builder",
|
|
3005
|
+
label: "Agency campaign-builder strategy patterns",
|
|
3006
|
+
seed_source: "agency",
|
|
3007
|
+
scope: "private_strategy_docs",
|
|
3008
|
+
privacy: "workspace-private sanitized docs and abstracted campaign summaries"
|
|
3009
|
+
},
|
|
3010
|
+
workflow: {
|
|
3011
|
+
id: "workflow_pattern_corpus",
|
|
3012
|
+
label: "Workflow and table-build pattern corpus",
|
|
3013
|
+
seed_source: "building-clay",
|
|
3014
|
+
scope: "read_only_workflow_docs",
|
|
3015
|
+
privacy: "sanitized operating model and workflow patterns"
|
|
3016
|
+
},
|
|
3017
|
+
feedback: {
|
|
3018
|
+
id: "campaign_feedback",
|
|
3019
|
+
label: "Campaign feedback and reply patterns",
|
|
3020
|
+
seed_source: "instantly",
|
|
3021
|
+
scope: "workspace_private_feedback",
|
|
3022
|
+
privacy: "aggregate feedback, reply, and sequence performance memory"
|
|
3023
|
+
}
|
|
3024
|
+
};
|
|
3025
|
+
const sourceMap = {
|
|
3026
|
+
agency: "agency",
|
|
3027
|
+
"campaign-builder": "agency",
|
|
3028
|
+
"north-star": "northStar",
|
|
3029
|
+
northstar: "northStar",
|
|
3030
|
+
"campaign-builder-north-star": "northStar",
|
|
3031
|
+
acceptance: "northStar",
|
|
3032
|
+
"strategy-memory": "agency",
|
|
3033
|
+
"workflow-patterns": "workflow",
|
|
3034
|
+
workflow: "workflow",
|
|
3035
|
+
"building-clay": "workflow",
|
|
3036
|
+
clay: "workflow",
|
|
3037
|
+
"instantly-feedback": "feedback",
|
|
3038
|
+
instantly: "feedback",
|
|
3039
|
+
feedback: "feedback",
|
|
3040
|
+
all: "all"
|
|
3041
|
+
};
|
|
3042
|
+
const selected = sourceMap[normalized] || "agency";
|
|
3043
|
+
if (selected === "all") {
|
|
3044
|
+
return {
|
|
3045
|
+
seedSource: "all",
|
|
3046
|
+
verifyScript: null,
|
|
3047
|
+
memorySources: [catalog.northStar, catalog.agency, catalog.workflow, catalog.feedback]
|
|
3048
|
+
};
|
|
3049
|
+
}
|
|
3050
|
+
const item = catalog[selected];
|
|
3051
|
+
return {
|
|
3052
|
+
seedSource: item.seed_source,
|
|
3053
|
+
verifyScript: item.seed_source === "north-star" ? "scripts/gtm-kernel/verify-north-star-import-manifest.mjs" : item.seed_source === "agency" ? "scripts/gtm-kernel/verify-agency-import-manifest.mjs" : item.seed_source === "building-clay" ? "scripts/gtm-kernel/verify-building-clay-import-manifest.mjs" : null,
|
|
3054
|
+
memorySources: [item]
|
|
3055
|
+
};
|
|
3056
|
+
}
|
|
2646
3057
|
function shellArg(value) {
|
|
2647
3058
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
2648
3059
|
}
|
|
@@ -2819,11 +3230,11 @@ function builtInRoutesFor(request) {
|
|
|
2819
3230
|
routes.push({
|
|
2820
3231
|
id: "signaliz-lead-generation",
|
|
2821
3232
|
layer: "source",
|
|
2822
|
-
|
|
3233
|
+
gtmLayer: "lead_generation",
|
|
2823
3234
|
provider: "signaliz",
|
|
2824
3235
|
mode: "required",
|
|
2825
3236
|
toolName: "generate_leads",
|
|
2826
|
-
rationale: "
|
|
3237
|
+
rationale: "Inventory verified cache first, then use Signaliz fresh workspace acquisition for the remaining approved gap."
|
|
2827
3238
|
});
|
|
2828
3239
|
}
|
|
2829
3240
|
if (builtIns.has("local_leads")) {
|
|
@@ -2837,6 +3248,28 @@ function builtInRoutesFor(request) {
|
|
|
2837
3248
|
rationale: "Use Signaliz local-leads sourcing for geography-bound local business campaigns."
|
|
2838
3249
|
});
|
|
2839
3250
|
}
|
|
3251
|
+
if (builtIns.has("company_discovery")) {
|
|
3252
|
+
routes.push({
|
|
3253
|
+
id: "signaliz-company-discovery",
|
|
3254
|
+
layer: "source",
|
|
3255
|
+
gtmLayer: "find_company",
|
|
3256
|
+
provider: "signaliz",
|
|
3257
|
+
mode: "if_available",
|
|
3258
|
+
toolName: "find_companies_signaliz",
|
|
3259
|
+
rationale: "Find and qualify company domains before people/email fill for account-led campaigns."
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3262
|
+
if (builtIns.has("people_discovery")) {
|
|
3263
|
+
routes.push({
|
|
3264
|
+
id: "signaliz-people-discovery",
|
|
3265
|
+
layer: "source",
|
|
3266
|
+
gtmLayer: "find_people",
|
|
3267
|
+
provider: "signaliz",
|
|
3268
|
+
mode: "if_available",
|
|
3269
|
+
toolName: "find_people_signaliz",
|
|
3270
|
+
rationale: "Find people directly when the brief is contact research or LinkedIn-style prospecting."
|
|
3271
|
+
});
|
|
3272
|
+
}
|
|
2840
3273
|
if (builtIns.has("email_finding")) {
|
|
2841
3274
|
routes.push({
|
|
2842
3275
|
id: "signaliz-email-finding",
|
|
@@ -2881,7 +3314,7 @@ function normalizeBuiltIns(request) {
|
|
|
2881
3314
|
return [...builtIns].filter(isCampaignBuilderBuiltInTool);
|
|
2882
3315
|
}
|
|
2883
3316
|
function isCampaignBuilderBuiltInTool(value) {
|
|
2884
|
-
return ["lead_generation", "local_leads", "email_finding", "email_verification", "signals"].includes(String(value));
|
|
3317
|
+
return ["lead_generation", "local_leads", "company_discovery", "people_discovery", "email_finding", "email_verification", "signals"].includes(String(value));
|
|
2885
3318
|
}
|
|
2886
3319
|
function looksLikeLocalLeadCampaign(request) {
|
|
2887
3320
|
const text = [
|
|
@@ -2936,7 +3369,11 @@ function createBuildRequest(request, defaults, targetCount, campaignName, scopeB
|
|
|
2936
3369
|
qualification: defaults.qualification,
|
|
2937
3370
|
copy: defaults.copy,
|
|
2938
3371
|
delivery: defaults.delivery,
|
|
2939
|
-
enhancers: enhancerConfig(request)
|
|
3372
|
+
enhancers: enhancerConfig(request),
|
|
3373
|
+
sourceRouting: request.sourceRouting ?? {
|
|
3374
|
+
mode: looksLikeLocalLeadCampaign(request) ? "local_leads" : "auto",
|
|
3375
|
+
fillPolicy: "aggressive"
|
|
3376
|
+
}
|
|
2940
3377
|
};
|
|
2941
3378
|
const scoped = asRecord(scopeBuildArgs);
|
|
2942
3379
|
buildRequest.gtmCampaignId = request.gtmCampaignId ?? stringValue(scoped.gtm_campaign_id ?? scoped.gtmCampaignId);
|
|
@@ -3018,9 +3455,132 @@ function createBrainPreflight(request, buildRequest, routes, memory) {
|
|
|
3018
3455
|
{ tool: "gtm_brain_learning_cycle_plan", purpose: "Plan the Brain learning loop for this campaign.", arguments: learningArgs },
|
|
3019
3456
|
{ tool: "gtm_brain_seed_defaults", purpose: "Seed campaign defaults from workspace memory and safe aggregate patterns.", arguments: defaultsArgs },
|
|
3020
3457
|
{ tool: "gtm_brain_delivery_risk", purpose: "Check deliverability risk before launch or external writes.", arguments: riskArgs }
|
|
3021
|
-
]
|
|
3458
|
+
],
|
|
3459
|
+
learn_back_plan: createCampaignBuilderLearnBackPlan(request, buildRequest)
|
|
3460
|
+
};
|
|
3461
|
+
}
|
|
3462
|
+
function createCampaignBuilderLearnBackPlan(request, buildRequest) {
|
|
3463
|
+
const instantlyFeedbackContext = campaignBuilderProviderFeedbackContext(request, buildRequest, "instantly");
|
|
3464
|
+
const postBuildSequence = [
|
|
3465
|
+
{
|
|
3466
|
+
tool: "get_campaign_build_status",
|
|
3467
|
+
approval_boundary: "read_only",
|
|
3468
|
+
arguments_template: { campaign_build_id: "<build_campaign.campaign_build_id>" },
|
|
3469
|
+
reason: "Wait for the Campaign Builder run to finish before deriving memory."
|
|
3470
|
+
},
|
|
3471
|
+
{
|
|
3472
|
+
tool: "gtm_campaign_build_backfill_preview",
|
|
3473
|
+
approval_boundary: "read_only",
|
|
3474
|
+
arguments_template: { campaign_build_id: "<build_campaign.campaign_build_id>", create_memory: true },
|
|
3475
|
+
reason: "Preview the provider-neutral Kernel import payload without writing rows."
|
|
3476
|
+
},
|
|
3477
|
+
{
|
|
3478
|
+
tool: "gtm_campaign_build_backfill_run",
|
|
3479
|
+
approval_boundary: "dry_run",
|
|
3480
|
+
arguments_template: { campaign_build_ids: ["<build_campaign.campaign_build_id>"], dry_run: true, create_memory: true, run_brain_cycle: false },
|
|
3481
|
+
reason: "Dry-run the Kernel history import before creating campaign memory."
|
|
3482
|
+
},
|
|
3483
|
+
{
|
|
3484
|
+
tool: "gtm_campaign_build_backfill_run",
|
|
3485
|
+
approval_boundary: "explicit_write_approval",
|
|
3486
|
+
arguments_template: { campaign_build_ids: ["<build_campaign.campaign_build_id>"], dry_run: false, create_memory: true, run_brain_cycle: true, brain_cycle_write_mode: "dry_run" },
|
|
3487
|
+
reason: "After review, queue the Kernel history import; Brain learning remains dry-run unless separately approved."
|
|
3488
|
+
}
|
|
3489
|
+
];
|
|
3490
|
+
if (instantlyFeedbackContext) {
|
|
3491
|
+
postBuildSequence.push({
|
|
3492
|
+
tool: "gtm_instantly_feedback_pull",
|
|
3493
|
+
approval_boundary: "dry_run_first_explicit_write_approval",
|
|
3494
|
+
arguments_template: {
|
|
3495
|
+
campaign_id: buildRequest.gtmCampaignId || "<gtm_campaign_id_after_commit>",
|
|
3496
|
+
campaign_build_id: "<build_campaign.campaign_build_id>",
|
|
3497
|
+
source: "emails",
|
|
3498
|
+
email_type: "received",
|
|
3499
|
+
...instantlyFeedbackContext,
|
|
3500
|
+
dry_run: true,
|
|
3501
|
+
create_memory: true,
|
|
3502
|
+
write_routine_outcomes: true,
|
|
3503
|
+
run_brain_cycle: true,
|
|
3504
|
+
brain_cycle_write_mode: "dry_run"
|
|
3505
|
+
},
|
|
3506
|
+
reason: "After Instantly delivery has live outcomes, pull reply and bounce history into private feedback memory before Brain learning."
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3509
|
+
postBuildSequence.push(
|
|
3510
|
+
{
|
|
3511
|
+
tool: "gtm_campaign_learning_status",
|
|
3512
|
+
approval_boundary: "read_only",
|
|
3513
|
+
arguments_template: {
|
|
3514
|
+
campaign_id: buildRequest.gtmCampaignId || "<gtm_campaign_id_after_commit>",
|
|
3515
|
+
campaign_build_id: "<build_campaign.campaign_build_id>",
|
|
3516
|
+
write_mode: "dry_run"
|
|
3517
|
+
},
|
|
3518
|
+
reason: "Confirm feedback, memory, and Brain learning readiness after the import."
|
|
3519
|
+
},
|
|
3520
|
+
{
|
|
3521
|
+
tool: "gtm_memory_search",
|
|
3522
|
+
approval_boundary: "read_only",
|
|
3523
|
+
arguments_template: {
|
|
3524
|
+
query: request.goal,
|
|
3525
|
+
...buildRequest.gtmCampaignId ? { campaign_id: buildRequest.gtmCampaignId } : {},
|
|
3526
|
+
limit: 10
|
|
3527
|
+
},
|
|
3528
|
+
reason: "Verify the new private memory is retrievable for future campaign planning."
|
|
3529
|
+
},
|
|
3530
|
+
{
|
|
3531
|
+
tool: "gtm_brain_learning_cycle_plan",
|
|
3532
|
+
approval_boundary: "read_only",
|
|
3533
|
+
arguments_template: {
|
|
3534
|
+
...buildRequest.gtmCampaignId ? { campaign_id: buildRequest.gtmCampaignId } : {},
|
|
3535
|
+
include_memory: true,
|
|
3536
|
+
write_mode: "dry_run"
|
|
3537
|
+
},
|
|
3538
|
+
reason: "Plan the Brain phases from the imported outcomes before any pattern writes."
|
|
3539
|
+
}
|
|
3540
|
+
);
|
|
3541
|
+
return {
|
|
3542
|
+
source_tool: "campaign-builder-agent",
|
|
3543
|
+
gtm_campaign_id: buildRequest.gtmCampaignId ?? null,
|
|
3544
|
+
trigger: "After build_campaign returns a campaign_build_id and the build reaches a terminal reviewed state.",
|
|
3545
|
+
build_result_placeholders: {
|
|
3546
|
+
campaign_build_id: "<build_campaign.campaign_build_id>"
|
|
3547
|
+
},
|
|
3548
|
+
memory_write_policy: {
|
|
3549
|
+
target_tables: ["gtm_campaigns", "gtm_campaign_provider_links", "gtm_campaign_feedback_events", "gtm_memory_items", "gtm_brain_patterns"],
|
|
3550
|
+
gtm_memory_items: {
|
|
3551
|
+
shareable: false,
|
|
3552
|
+
allowed_redaction_states: ["redacted", "abstracted"],
|
|
3553
|
+
raw_private_fields_withheld: ["reply_text", "copy_body", "lead_email", "lead_domain", "company_domain", "provider_campaign_id", "provider_payload", "webhook_url", "secret"]
|
|
3554
|
+
},
|
|
3555
|
+
gtm_brain_patterns: "Workspace-scoped by default. Global promotion requires abstracted_only=true, shared opt-in, and privacy thresholds."
|
|
3556
|
+
},
|
|
3557
|
+
post_build_sequence: postBuildSequence.map((item, index) => ({ step: index + 1, ...item })),
|
|
3558
|
+
approval_policy: "This agent plan never writes learn-back rows. Backfill and provider-feedback writes require dry_run=false after review, and Brain writes require their own approved learning-cycle run.",
|
|
3559
|
+
privacy_policy: "Learn-back memory is workspace-private. Raw replies, copy bodies, leads, emails, domains, provider payloads, webhook URLs, secrets, private source paths, and raw client labels are withheld from memory rows and agent-visible outputs."
|
|
3022
3560
|
};
|
|
3023
3561
|
}
|
|
3562
|
+
function campaignBuilderProviderFeedbackContext(request, buildRequest, provider) {
|
|
3563
|
+
const normalizedProvider = String(provider).toLowerCase();
|
|
3564
|
+
const routes = [...request.integrations ?? [], ...routesFromCustomerTools(request.customerTools ?? [])];
|
|
3565
|
+
const providerRoute = routes.find((route) => String(route.provider).toLowerCase() === normalizedProvider);
|
|
3566
|
+
const routeConfig = asRecord(providerRoute?.config);
|
|
3567
|
+
const deliveryConfig = asRecord(buildRequest.delivery?.destinationConfig);
|
|
3568
|
+
const hasProviderContext = [
|
|
3569
|
+
...request.preferredProviders ?? [],
|
|
3570
|
+
...routes.map((route) => route.provider),
|
|
3571
|
+
stringValue(deliveryConfig.provider),
|
|
3572
|
+
stringValue(deliveryConfig.provider_id ?? deliveryConfig.providerId),
|
|
3573
|
+
stringValue(deliveryConfig.destination_provider ?? deliveryConfig.destinationProvider),
|
|
3574
|
+
stringValue(deliveryConfig.sink ?? deliveryConfig.sink_type ?? deliveryConfig.sinkType)
|
|
3575
|
+
].some((value) => String(value).toLowerCase() === normalizedProvider);
|
|
3576
|
+
if (!hasProviderContext) return void 0;
|
|
3577
|
+
return compact({
|
|
3578
|
+
provider_link_id: stringValue(routeConfig.provider_link_id ?? routeConfig.providerLinkId ?? deliveryConfig.provider_link_id ?? deliveryConfig.providerLinkId),
|
|
3579
|
+
provider_campaign_id: stringValue(routeConfig.provider_campaign_id ?? routeConfig.providerCampaignId ?? routeConfig.instantly_campaign_id ?? routeConfig.instantlyCampaignId ?? deliveryConfig.provider_campaign_id ?? deliveryConfig.providerCampaignId ?? deliveryConfig.instantly_campaign_id ?? deliveryConfig.instantlyCampaignId),
|
|
3580
|
+
integration_id: stringValue(routeConfig.integration_id ?? routeConfig.integrationId ?? deliveryConfig.integration_id ?? deliveryConfig.integrationId),
|
|
3581
|
+
instantly_profile: stringValue(routeConfig.instantly_profile ?? routeConfig.instantlyProfile ?? routeConfig.profile ?? deliveryConfig.instantly_profile ?? deliveryConfig.instantlyProfile ?? deliveryConfig.profile)
|
|
3582
|
+
});
|
|
3583
|
+
}
|
|
3024
3584
|
function gtmLayersForBuilderLayer(layer) {
|
|
3025
3585
|
const map = {
|
|
3026
3586
|
workspace_context: ["customer_data"],
|
|
@@ -3425,6 +3985,7 @@ function buildFallbackPlanSnapshot(plan) {
|
|
|
3425
3985
|
target_count: plan.targetCount,
|
|
3426
3986
|
approvals: plan.approvals,
|
|
3427
3987
|
brain_preflight: plan.brainPreflight,
|
|
3988
|
+
campaign_strategy_context: plan.buildRequest.campaignStrategyContext,
|
|
3428
3989
|
operating_playbooks: plan.operatingPlaybooks
|
|
3429
3990
|
});
|
|
3430
3991
|
}
|
|
@@ -3557,6 +4118,7 @@ function buildCampaignArgs(request) {
|
|
|
3557
4118
|
if (request.dedupKeys) args.dedup_keys = request.dedupKeys;
|
|
3558
4119
|
if (request.brainPreflight) args.brain_preflight = request.brainPreflight;
|
|
3559
4120
|
if (request.brainDefaults) args.brain_defaults = request.brainDefaults;
|
|
4121
|
+
if (request.campaignStrategyContext) args.campaign_strategy_context = request.campaignStrategyContext;
|
|
3560
4122
|
if (request.deliveryRisk) args.delivery_risk = request.deliveryRisk;
|
|
3561
4123
|
if (request.icp) {
|
|
3562
4124
|
args.icp = compact({
|
|
@@ -3576,6 +4138,15 @@ function buildCampaignArgs(request) {
|
|
|
3576
4138
|
model: request.policy.model
|
|
3577
4139
|
});
|
|
3578
4140
|
}
|
|
4141
|
+
if (request.sourceRouting) {
|
|
4142
|
+
args.source_routing = compact({
|
|
4143
|
+
mode: request.sourceRouting.mode,
|
|
4144
|
+
fill_policy: request.sourceRouting.fillPolicy,
|
|
4145
|
+
shard_size: request.sourceRouting.shardSize,
|
|
4146
|
+
max_source_shard_size: request.sourceRouting.maxSourceShardSize,
|
|
4147
|
+
max_local_source_shard_size: request.sourceRouting.maxLocalSourceShardSize
|
|
4148
|
+
});
|
|
4149
|
+
}
|
|
3579
4150
|
if (request.signals) {
|
|
3580
4151
|
args.signals = compact({
|
|
3581
4152
|
enabled: request.signals.enabled,
|
|
@@ -3647,7 +4218,8 @@ function buildExecutionPrepareArgs(request, dryRun, confirmSpend) {
|
|
|
3647
4218
|
qualification: buildArgs2.qualification,
|
|
3648
4219
|
copy: buildArgs2.copy,
|
|
3649
4220
|
delivery: buildArgs2.delivery,
|
|
3650
|
-
enhancers: buildArgs2.enhancers
|
|
4221
|
+
enhancers: buildArgs2.enhancers,
|
|
4222
|
+
source_routing: buildArgs2.source_routing
|
|
3651
4223
|
});
|
|
3652
4224
|
}
|
|
3653
4225
|
function buildDeliveryApprovalArgs(request) {
|
|
@@ -3696,17 +4268,62 @@ function mapAgentCampaignBuildStatus(data) {
|
|
|
3696
4268
|
warnings: diagnosticMessages2(data.warnings),
|
|
3697
4269
|
errors: diagnosticMessages2(data.errors),
|
|
3698
4270
|
artifactCount: numberOrUndefined2(data.artifact_count) ?? 0,
|
|
4271
|
+
artifactDownloads: Array.isArray(data.artifact_downloads) ? data.artifact_downloads.map(mapAgentCampaignArtifactDownload) : [],
|
|
4272
|
+
customerRowCounts: mapAgentCustomerRowCounts(data.customer_row_counts),
|
|
4273
|
+
phaseAttemptTotals: nullableRecord(data.phase_attempt_totals) ?? void 0,
|
|
3699
4274
|
providerRoute: mapProviderRoute2(data),
|
|
3700
4275
|
triggerRunId: stringValue(data.trigger_run_id) ?? null,
|
|
3701
4276
|
staleRunningPhase: data.stale_running_phase === true,
|
|
3702
4277
|
phaseAgeSeconds: numberOrNull2(data.phase_age_seconds),
|
|
3703
4278
|
diagnostics: nullableRecord(data.diagnostics) ?? {},
|
|
3704
4279
|
nextAction: formatAgentNextAction(data.next_action),
|
|
4280
|
+
approvalAction: formatAgentNextAction(data.approval_action),
|
|
3705
4281
|
createdAt: stringValue(data.created_at) ?? "",
|
|
3706
4282
|
updatedAt: stringValue(data.updated_at) ?? "",
|
|
3707
4283
|
completedAt: stringValue(data.completed_at) ?? null
|
|
3708
4284
|
};
|
|
3709
4285
|
}
|
|
4286
|
+
function mapAgentCampaignArtifactDownload(data) {
|
|
4287
|
+
return {
|
|
4288
|
+
id: stringValue(data.id) ?? "",
|
|
4289
|
+
artifactType: stringValue(data.artifact_type) ?? null,
|
|
4290
|
+
format: stringValue(data.format) ?? null,
|
|
4291
|
+
rowCount: numberOrUndefined2(data.row_count) ?? 0,
|
|
4292
|
+
signedUrl: stringValue(data.signed_url) ?? null,
|
|
4293
|
+
downloadUrl: stringValue(data.download_url) ?? null,
|
|
4294
|
+
manifestUrl: stringValue(data.manifest_url) ?? null,
|
|
4295
|
+
expiresAt: stringValue(data.expires_at) ?? null
|
|
4296
|
+
};
|
|
4297
|
+
}
|
|
4298
|
+
function mapAgentCustomerRowCounts(value) {
|
|
4299
|
+
const record = nullableRecord(value);
|
|
4300
|
+
if (!record) return void 0;
|
|
4301
|
+
return {
|
|
4302
|
+
requestedTarget: numberOrNull2(record.requested_target),
|
|
4303
|
+
acquiredRows: numberOrUndefined2(record.acquired_rows),
|
|
4304
|
+
acceptedRows: numberOrUndefined2(record.accepted_rows),
|
|
4305
|
+
usableRows: numberOrUndefined2(record.usable_rows),
|
|
4306
|
+
copiedRows: numberOrUndefined2(record.copied_rows),
|
|
4307
|
+
approvalReadyRows: numberOrUndefined2(record.approval_ready_rows),
|
|
4308
|
+
qaReadyRows: numberOrUndefined2(record.qa_ready_rows),
|
|
4309
|
+
deliveredRows: numberOrUndefined2(record.delivered_rows),
|
|
4310
|
+
disqualifiedRows: numberOrUndefined2(record.disqualified_rows),
|
|
4311
|
+
reviewableRows: numberOrUndefined2(record.reviewable_rows),
|
|
4312
|
+
rowFailures: numberOrUndefined2(record.row_failures),
|
|
4313
|
+
acceptedShortfall: numberOrNull2(record.accepted_shortfall),
|
|
4314
|
+
usableShortfall: numberOrNull2(record.usable_shortfall),
|
|
4315
|
+
qaReadyShortfall: numberOrNull2(record.qa_ready_shortfall),
|
|
4316
|
+
deliveryShortfall: numberOrNull2(record.delivery_shortfall),
|
|
4317
|
+
fillRatio: numberOrNull2(record.fill_ratio),
|
|
4318
|
+
qaReadyFillRatio: numberOrNull2(record.qa_ready_fill_ratio),
|
|
4319
|
+
deliveredFillRatio: numberOrNull2(record.delivered_fill_ratio),
|
|
4320
|
+
terminalReason: stringValue(record.terminal_reason) ?? null,
|
|
4321
|
+
acceptedShortfallReason: stringValue(record.accepted_shortfall_reason) ?? null,
|
|
4322
|
+
usableShortfallReason: stringValue(record.usable_shortfall_reason) ?? null,
|
|
4323
|
+
qaReadyShortfallReason: stringValue(record.qa_ready_shortfall_reason) ?? null,
|
|
4324
|
+
deliveryShortfallReason: stringValue(record.delivery_shortfall_reason) ?? null
|
|
4325
|
+
};
|
|
4326
|
+
}
|
|
3710
4327
|
function mapAgentCampaignRowsResult(data) {
|
|
3711
4328
|
const rows = Array.isArray(data.rows) ? data.rows : [];
|
|
3712
4329
|
return {
|
|
@@ -3734,7 +4351,11 @@ function mapAgentCampaignArtifact(data) {
|
|
|
3734
4351
|
artifactType: stringValue(data.artifact_type) ?? "",
|
|
3735
4352
|
destination: stringValue(data.destination) ?? "",
|
|
3736
4353
|
storagePath: stringValue(data.storage_path) ?? "",
|
|
4354
|
+
format: stringValue(data.format) ?? null,
|
|
3737
4355
|
signedUrl: stringValue(data.signed_url) ?? null,
|
|
4356
|
+
downloadUrl: stringValue(data.download_url) ?? null,
|
|
4357
|
+
manifestUrl: stringValue(data.manifest_url) ?? null,
|
|
4358
|
+
expiresAt: stringValue(data.expires_at) ?? null,
|
|
3738
4359
|
rowCount: numberOrUndefined2(data.row_count) ?? 0,
|
|
3739
4360
|
checksum: stringValue(data.checksum) ?? null,
|
|
3740
4361
|
metadata: nullableRecord(data.metadata) ?? {},
|
|
@@ -3896,6 +4517,8 @@ function readinessLaneLabel(route, builtIn) {
|
|
|
3896
4517
|
const labels = {
|
|
3897
4518
|
lead_generation: "Signaliz lead generation",
|
|
3898
4519
|
local_leads: "Signaliz local leads",
|
|
4520
|
+
company_discovery: "Signaliz company discovery",
|
|
4521
|
+
people_discovery: "Signaliz people discovery",
|
|
3899
4522
|
email_finding: "Signaliz email finding",
|
|
3900
4523
|
email_verification: "Signaliz email verification",
|
|
3901
4524
|
signals: "Signaliz signals"
|
|
@@ -3980,6 +4603,35 @@ function summarizeCampaignBuilderProofDryRun(dryRunResult) {
|
|
|
3980
4603
|
plannedTargetCount: dryRunResult.plannedTargetCount ?? dryRunResult.planned_target_count ?? null
|
|
3981
4604
|
};
|
|
3982
4605
|
}
|
|
4606
|
+
function summarizeCampaignBuilderProofLearnBack(plan) {
|
|
4607
|
+
if (Object.keys(plan).length === 0) return { ready: false };
|
|
4608
|
+
const memoryPolicy = asRecord(plan.memory_write_policy);
|
|
4609
|
+
const memoryItemsPolicy = asRecord(memoryPolicy.gtm_memory_items);
|
|
4610
|
+
const sequence = Array.isArray(plan.post_build_sequence) ? plan.post_build_sequence.map((step) => {
|
|
4611
|
+
const record = asRecord(step);
|
|
4612
|
+
return compact({
|
|
4613
|
+
step: record.step,
|
|
4614
|
+
tool: stringValue(record.tool),
|
|
4615
|
+
approval_boundary: stringValue(record.approval_boundary),
|
|
4616
|
+
reason: stringValue(record.reason)
|
|
4617
|
+
});
|
|
4618
|
+
}).filter((step) => typeof step.tool === "string") : [];
|
|
4619
|
+
return {
|
|
4620
|
+
ready: sequence.length > 0,
|
|
4621
|
+
source_tool: firstNonEmptyString(plan.source_tool, plan.sourceTool),
|
|
4622
|
+
post_build_sequence: sequence,
|
|
4623
|
+
memory_write_policy: {
|
|
4624
|
+
target_tables: Array.isArray(memoryPolicy.target_tables) ? memoryPolicy.target_tables : [],
|
|
4625
|
+
gtm_memory_items: {
|
|
4626
|
+
shareable: memoryItemsPolicy.shareable === false ? false : memoryItemsPolicy.shareable ?? null,
|
|
4627
|
+
allowed_redaction_states: Array.isArray(memoryItemsPolicy.allowed_redaction_states) ? memoryItemsPolicy.allowed_redaction_states : [],
|
|
4628
|
+
raw_private_fields_withheld: Array.isArray(memoryItemsPolicy.raw_private_fields_withheld) ? memoryItemsPolicy.raw_private_fields_withheld : []
|
|
4629
|
+
}
|
|
4630
|
+
},
|
|
4631
|
+
approval_policy: firstNonEmptyString(plan.approval_policy, plan.approvalPolicy),
|
|
4632
|
+
privacy_policy: firstNonEmptyString(plan.privacy_policy, plan.privacyPolicy)
|
|
4633
|
+
};
|
|
4634
|
+
}
|
|
3983
4635
|
function firstNonEmptyString(...values) {
|
|
3984
4636
|
for (const value of values) {
|
|
3985
4637
|
if (typeof value === "string" && value.trim()) return value;
|
|
@@ -4462,14 +5114,87 @@ var Ops = class {
|
|
|
4462
5114
|
const body = typeof params === "string" ? { prompt: params } : buildOpsCreateBody(params);
|
|
4463
5115
|
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_create", body)));
|
|
4464
5116
|
}
|
|
5117
|
+
async schedule(params) {
|
|
5118
|
+
const createBody = typeof params === "string" ? { prompt: params, cadence: "daily" } : { ...buildOpsCreateBody(params), cadence: params.cadence ?? "daily" };
|
|
5119
|
+
const { activate: _activate, ...body } = createBody;
|
|
5120
|
+
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_schedule", body)));
|
|
5121
|
+
}
|
|
5122
|
+
async scheduleAndWait(params) {
|
|
5123
|
+
const options = typeof params === "string" ? { schedule: { prompt: params, cadence: "daily" }, run: {}, wait: {} } : buildOpsScheduleAndWaitOptions(params);
|
|
5124
|
+
const raw = await this.call("ops_schedule_and_wait", buildOpsScheduleAndWaitBody(options));
|
|
5125
|
+
return normalizeOpsScheduleAndWaitCallResult(raw, options.wait, {
|
|
5126
|
+
approvalMessage: "ops.scheduleAndWait requires an approved schedulable Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5127
|
+
notCreatedMessage: "ops.scheduleAndWait requires ops_schedule_and_wait to create an op_id. Use ops.schedule for approval review flows."
|
|
5128
|
+
});
|
|
5129
|
+
}
|
|
5130
|
+
/** Schedule a recurring Op that delivers through a customer-owned Nango API connection. */
|
|
5131
|
+
async scheduleNangoAction(input) {
|
|
5132
|
+
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_nango_schedule", buildOpsNangoScheduleBody(input))));
|
|
5133
|
+
}
|
|
5134
|
+
/** Schedule a recurring Nango-backed Op, run the first tick, and return result readback. */
|
|
5135
|
+
async scheduleNangoActionAndWait(input) {
|
|
5136
|
+
const options = buildOpsNangoScheduleAndWaitOptions(input);
|
|
5137
|
+
const raw = await this.call("ops_nango_schedule_and_wait", buildOpsNangoScheduleAndWaitBody(options));
|
|
5138
|
+
return normalizeOpsScheduleAndWaitCallResult(raw, options.wait, {
|
|
5139
|
+
approvalMessage: "ops.scheduleNangoActionAndWait requires an approved Nango-backed Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5140
|
+
notCreatedMessage: "ops.scheduleNangoActionAndWait requires ops_nango_schedule_and_wait to create an op_id. Use ops.scheduleNangoAction for approval review flows."
|
|
5141
|
+
});
|
|
5142
|
+
}
|
|
4465
5143
|
async execute(params) {
|
|
4466
5144
|
const body = typeof params === "string" ? { prompt: params } : buildOpsExecuteBody(params);
|
|
4467
5145
|
return normalizeOpsExecuteResult(withExecutionRefs(await this.call("ops_execute", body)));
|
|
4468
5146
|
}
|
|
5147
|
+
async executeAndWait(params) {
|
|
5148
|
+
const options = typeof params === "string" ? { execute: { prompt: params, auto_run: true }, wait: {} } : buildOpsExecuteAndWaitOptions(params);
|
|
5149
|
+
const execute = await this.execute(options.execute);
|
|
5150
|
+
if (execute.approval_required || execute.error_code === "APPROVAL_REQUIRED") {
|
|
5151
|
+
throw new SignalizError({
|
|
5152
|
+
code: "APPROVAL_REQUIRED",
|
|
5153
|
+
errorType: "validation",
|
|
5154
|
+
message: "ops.executeAndWait requires an approved executable Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5155
|
+
details: { execute }
|
|
5156
|
+
});
|
|
5157
|
+
}
|
|
5158
|
+
if (!execute.op_id) {
|
|
5159
|
+
throw new SignalizError({
|
|
5160
|
+
code: "OP_NOT_CREATED",
|
|
5161
|
+
errorType: "validation",
|
|
5162
|
+
message: "ops.executeAndWait requires ops_execute to create an op_id. Use ops.execute for dry runs or approval review flows.",
|
|
5163
|
+
details: { execute }
|
|
5164
|
+
});
|
|
5165
|
+
}
|
|
5166
|
+
const waited = await this.waitForResults({
|
|
5167
|
+
...options.wait,
|
|
5168
|
+
op_id: execute.op_id
|
|
5169
|
+
});
|
|
5170
|
+
const runId = execute.run_id ?? execute.runId ?? waited.status.run_id ?? waited.status.runId ?? null;
|
|
5171
|
+
return {
|
|
5172
|
+
...waited,
|
|
5173
|
+
execute,
|
|
5174
|
+
run_id: runId,
|
|
5175
|
+
runId,
|
|
5176
|
+
execution_refs: mergeExecutionRefsFrom([execute, waited])
|
|
5177
|
+
};
|
|
5178
|
+
}
|
|
4469
5179
|
async run(params) {
|
|
4470
5180
|
const body = typeof params === "string" ? { op_id: params } : buildOpsRunBody(params);
|
|
4471
5181
|
return normalizeOpsRunResult(withExecutionRefs(await this.call("ops_run", body)));
|
|
4472
5182
|
}
|
|
5183
|
+
async runAndWait(params) {
|
|
5184
|
+
const options = typeof params === "string" ? { op_id: params } : buildOpsRunAndWaitOptions(params);
|
|
5185
|
+
if (!options.op_id) throw new Error("ops.runAndWait requires op_id or opId");
|
|
5186
|
+
const run = await this.run({
|
|
5187
|
+
op_id: options.op_id,
|
|
5188
|
+
instruction: options.instruction,
|
|
5189
|
+
force: options.force
|
|
5190
|
+
});
|
|
5191
|
+
const waited = await this.waitForResults(options);
|
|
5192
|
+
return {
|
|
5193
|
+
...waited,
|
|
5194
|
+
run,
|
|
5195
|
+
execution_refs: mergeExecutionRefsFrom([run, waited])
|
|
5196
|
+
};
|
|
5197
|
+
}
|
|
4473
5198
|
async status(params) {
|
|
4474
5199
|
const body = typeof params === "string" ? { op_id: params } : buildOpsStatusBody(params);
|
|
4475
5200
|
return normalizeOpsStatusResult(withExecutionRefs(await this.call("ops_status", body)));
|
|
@@ -4478,77 +5203,250 @@ var Ops = class {
|
|
|
4478
5203
|
const body = typeof params === "string" ? { op_id: params } : buildOpsResultsBody(params);
|
|
4479
5204
|
return normalizeOpsResultsResult(withExecutionRefs(await this.call("ops_results", body)));
|
|
4480
5205
|
}
|
|
4481
|
-
async
|
|
4482
|
-
const
|
|
4483
|
-
|
|
4484
|
-
|
|
5206
|
+
async waitForResults(params) {
|
|
5207
|
+
const options = typeof params === "string" ? { op_id: params } : buildOpsWaitForResultsOptions(params);
|
|
5208
|
+
if (!options.op_id) throw new Error("ops.waitForResults requires op_id or opId");
|
|
5209
|
+
const waitResult = await this.call("ops_wait", buildOpsWaitBody(options));
|
|
5210
|
+
return normalizeOpsWaitForResultsResult(waitResult, options);
|
|
5211
|
+
}
|
|
5212
|
+
/** Create a short-lived Nango Connect session from the Ops namespace. */
|
|
5213
|
+
async createNangoConnectSession(input) {
|
|
5214
|
+
return this.call("nango_connect_session_create", {
|
|
5215
|
+
provider_id: input.providerId,
|
|
5216
|
+
integration_id: input.integrationId,
|
|
5217
|
+
provider_display_name: input.providerDisplayName,
|
|
5218
|
+
integration_display_name: input.integrationDisplayName,
|
|
5219
|
+
allowed_integrations: input.allowedIntegrations,
|
|
5220
|
+
surface: input.surface,
|
|
5221
|
+
source: input.source,
|
|
5222
|
+
user_email: input.userEmail,
|
|
5223
|
+
user_display_name: input.userDisplayName
|
|
4485
5224
|
});
|
|
4486
|
-
return normalizeOpsProofResult(data);
|
|
4487
5225
|
}
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
5226
|
+
/** Prepare the full Nango provider search, connect, pull/export, Ops, and route flow. */
|
|
5227
|
+
async prepareNangoIntegrationFlow(input = {}) {
|
|
5228
|
+
return this.call("nango_integration_flow_prepare", {
|
|
5229
|
+
query: input.query,
|
|
5230
|
+
search: input.search,
|
|
5231
|
+
provider_id: input.providerId,
|
|
5232
|
+
provider: input.provider,
|
|
5233
|
+
integration_id: input.integrationId,
|
|
5234
|
+
provider_config_key: input.providerConfigKey,
|
|
5235
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
5236
|
+
connection_id: input.connectionId,
|
|
5237
|
+
nango_connection_id: input.nangoConnectionId,
|
|
5238
|
+
intent: input.intent,
|
|
5239
|
+
action_name: input.actionName,
|
|
5240
|
+
tool_name: input.toolName,
|
|
5241
|
+
proxy_path: input.proxyPath,
|
|
5242
|
+
method: input.method,
|
|
5243
|
+
input: input.input,
|
|
5244
|
+
cadence: input.cadence,
|
|
5245
|
+
field_map: input.fieldMap,
|
|
5246
|
+
required_fields: input.requiredFields,
|
|
5247
|
+
confirm_spend: input.confirmSpend,
|
|
5248
|
+
write_confirmed: input.writeConfirmed,
|
|
5249
|
+
layer: input.layer,
|
|
5250
|
+
campaign_id: input.campaignId,
|
|
5251
|
+
limit: input.limit,
|
|
5252
|
+
include_provider_catalog: input.includeProviderCatalog
|
|
5253
|
+
});
|
|
5254
|
+
}
|
|
5255
|
+
/** List Nango-backed action tools for a workspace connection without executing them. */
|
|
5256
|
+
async listNangoTools(options = {}) {
|
|
5257
|
+
return this.call("nango_mcp_tools_list", {
|
|
5258
|
+
workspace_connection_id: options.workspaceConnectionId,
|
|
5259
|
+
connection_id: options.connectionId,
|
|
5260
|
+
provider_config_key: options.providerConfigKey,
|
|
5261
|
+
integration_id: options.integrationId,
|
|
5262
|
+
nango_connection_id: options.nangoConnectionId,
|
|
5263
|
+
format: options.format,
|
|
5264
|
+
include_raw: options.includeRaw
|
|
5265
|
+
});
|
|
5266
|
+
}
|
|
5267
|
+
/** Audit connected Nango rows, action/proxy readiness, and read/write proof gaps. */
|
|
5268
|
+
async proveNangoReadWrite(options = {}) {
|
|
5269
|
+
return this.call("nango_mcp_read_write_audit", {
|
|
5270
|
+
workspace_connection_id: options.workspaceConnectionId,
|
|
5271
|
+
connection_id: options.connectionId,
|
|
5272
|
+
provider_config_key: options.providerConfigKey,
|
|
5273
|
+
integration_id: options.integrationId,
|
|
5274
|
+
nango_connection_id: options.nangoConnectionId,
|
|
5275
|
+
limit: options.limit,
|
|
5276
|
+
include_raw: options.includeRaw,
|
|
5277
|
+
read_proxy_path: options.readProxyPath,
|
|
5278
|
+
write_proxy_path: options.writeProxyPath,
|
|
5279
|
+
method: options.method,
|
|
5280
|
+
execute_read_probe: options.executeReadProbe,
|
|
5281
|
+
execute_write_probe: options.executeWriteProbe,
|
|
5282
|
+
confirm: options.confirm,
|
|
5283
|
+
confirm_write: options.confirmWrite,
|
|
5284
|
+
input: options.input,
|
|
5285
|
+
write_input: options.writeInput
|
|
5286
|
+
});
|
|
5287
|
+
}
|
|
5288
|
+
/** Dry-run or execute a Nango-backed action tool through the approval-aware MCP bridge. */
|
|
5289
|
+
async callNangoTool(input) {
|
|
5290
|
+
return this.call("nango_mcp_tool_call", {
|
|
5291
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
5292
|
+
connection_id: input.connectionId,
|
|
5293
|
+
provider_config_key: input.providerConfigKey,
|
|
5294
|
+
integration_id: input.integrationId,
|
|
5295
|
+
nango_connection_id: input.nangoConnectionId,
|
|
5296
|
+
action_name: input.actionName,
|
|
5297
|
+
tool_name: input.toolName,
|
|
5298
|
+
delivery_mode: input.deliveryMode,
|
|
5299
|
+
proxy_path: input.proxyPath,
|
|
5300
|
+
nango_proxy_path: input.nangoProxyPath,
|
|
5301
|
+
method: input.method,
|
|
5302
|
+
http_method: input.httpMethod,
|
|
5303
|
+
proxy_headers: input.proxyHeaders,
|
|
5304
|
+
input: input.input,
|
|
5305
|
+
async: input.async,
|
|
5306
|
+
max_retries: input.maxRetries,
|
|
5307
|
+
dry_run: input.dryRun,
|
|
5308
|
+
confirm: input.confirm,
|
|
5309
|
+
confirm_write: input.confirmWrite
|
|
5310
|
+
});
|
|
5311
|
+
}
|
|
5312
|
+
/** Execute a Nango action and poll its async result when a status URL/action id is returned. */
|
|
5313
|
+
async callNangoToolAndWait(input) {
|
|
5314
|
+
const result = await this.call("nango_mcp_tool_call_and_wait", {
|
|
5315
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
5316
|
+
connection_id: input.connectionId,
|
|
5317
|
+
provider_config_key: input.providerConfigKey,
|
|
5318
|
+
integration_id: input.integrationId,
|
|
5319
|
+
nango_connection_id: input.nangoConnectionId,
|
|
5320
|
+
action_name: input.actionName,
|
|
5321
|
+
tool_name: input.toolName,
|
|
5322
|
+
delivery_mode: input.deliveryMode,
|
|
5323
|
+
proxy_path: input.proxyPath,
|
|
5324
|
+
nango_proxy_path: input.nangoProxyPath,
|
|
5325
|
+
method: input.method,
|
|
5326
|
+
http_method: input.httpMethod,
|
|
5327
|
+
proxy_headers: input.proxyHeaders,
|
|
5328
|
+
input: input.input,
|
|
5329
|
+
async: input.async ?? true,
|
|
5330
|
+
max_retries: input.maxRetries,
|
|
5331
|
+
dry_run: input.dryRun,
|
|
5332
|
+
confirm: input.confirm,
|
|
5333
|
+
confirm_write: input.confirmWrite,
|
|
5334
|
+
interval_ms: input.intervalMs,
|
|
5335
|
+
max_polls: input.maxPolls,
|
|
5336
|
+
timeout_ms: input.timeoutMs
|
|
5337
|
+
});
|
|
5338
|
+
const packet = asRecord2(result);
|
|
5339
|
+
const actionId = optionalString(packet.actionId) ?? optionalString(packet.action_id);
|
|
5340
|
+
const statusUrl = optionalString(packet.statusUrl) ?? optionalString(packet.status_url);
|
|
5341
|
+
const maxPolls = Number(packet.maxPolls ?? packet.max_polls ?? 0);
|
|
5342
|
+
const intervalMs = Number(packet.intervalMs ?? packet.interval_ms ?? 0);
|
|
5343
|
+
const timeoutMs = Number(packet.timeoutMs ?? packet.timeout_ms ?? 0);
|
|
5344
|
+
const timedOut = Boolean(packet.timedOut ?? packet.timed_out);
|
|
5345
|
+
return {
|
|
5346
|
+
...packet,
|
|
5347
|
+
success: typeof packet.success === "boolean" ? packet.success : void 0,
|
|
5348
|
+
call: packet.call,
|
|
5349
|
+
result: packet.result,
|
|
5350
|
+
status: optionalString(packet.status),
|
|
5351
|
+
action_id: actionId,
|
|
5352
|
+
actionId,
|
|
5353
|
+
status_url: statusUrl,
|
|
5354
|
+
statusUrl,
|
|
5355
|
+
polls: Number(packet.polls ?? 0),
|
|
5356
|
+
max_polls: maxPolls,
|
|
5357
|
+
maxPolls,
|
|
5358
|
+
interval_ms: intervalMs,
|
|
5359
|
+
intervalMs,
|
|
5360
|
+
timeout_ms: timeoutMs,
|
|
5361
|
+
timeoutMs,
|
|
5362
|
+
timed_out: timedOut,
|
|
5363
|
+
timedOut
|
|
5364
|
+
};
|
|
5365
|
+
}
|
|
5366
|
+
/** Poll an async Nango action result by action id or status URL. */
|
|
5367
|
+
async getNangoActionResult(input) {
|
|
5368
|
+
return this.call("nango_mcp_action_result_get", {
|
|
5369
|
+
action_id: input.actionId,
|
|
5370
|
+
status_url: input.statusUrl
|
|
5371
|
+
});
|
|
5372
|
+
}
|
|
5373
|
+
async proof(params = {}) {
|
|
5374
|
+
const data = await this.call("ops_proof", {
|
|
5375
|
+
window_hours: params.windowHours,
|
|
5376
|
+
output_format: "json"
|
|
5377
|
+
});
|
|
5378
|
+
return normalizeOpsProofResult(data);
|
|
5379
|
+
}
|
|
5380
|
+
async debug(params) {
|
|
5381
|
+
const options = typeof params === "string" ? { op_id: params } : buildOpsDebugOptions(params);
|
|
5382
|
+
const diagnosticErrors = [];
|
|
5383
|
+
const status = await this.status(options.op_id);
|
|
5384
|
+
const refs = /* @__PURE__ */ new Map();
|
|
5385
|
+
const addRefs = (items) => {
|
|
5386
|
+
for (const ref of items ?? []) refs.set(`${ref.kind}:${ref.id}`, ref);
|
|
5387
|
+
};
|
|
5388
|
+
const recordError = (step, err) => {
|
|
5389
|
+
diagnosticErrors.push({
|
|
5390
|
+
step,
|
|
5391
|
+
message: err instanceof Error ? err.message : String(err)
|
|
5392
|
+
});
|
|
5393
|
+
};
|
|
5394
|
+
addRefs(status.execution_refs);
|
|
5395
|
+
if (status.latest_run && typeof status.latest_run === "object") {
|
|
5396
|
+
addRefs(collectExecutionReferences(status.latest_run));
|
|
4517
5397
|
}
|
|
5398
|
+
const runRefs = Array.from(refs.values()).filter((ref) => ref.kind === "trigger_run" || ref.kind === "dataplane_run" || ref.kind === "replay_run");
|
|
5399
|
+
let runStatuses = [];
|
|
4518
5400
|
let queue;
|
|
4519
|
-
if (options.include_queue !== false) {
|
|
4520
|
-
try {
|
|
4521
|
-
queue = await this.getQueueStatus({ summary: true });
|
|
4522
|
-
addRefs(queue.execution_refs);
|
|
4523
|
-
} catch (err) {
|
|
4524
|
-
recordError("queue", err);
|
|
4525
|
-
}
|
|
4526
|
-
}
|
|
4527
5401
|
let dashboardRecent;
|
|
4528
|
-
if (options.include_dashboard !== false) {
|
|
4529
|
-
try {
|
|
4530
|
-
dashboardRecent = await this.getDashboard({
|
|
4531
|
-
section: "recent",
|
|
4532
|
-
limit: options.dashboard_limit ?? 10,
|
|
4533
|
-
timeRangeDays: options.time_range_days
|
|
4534
|
-
});
|
|
4535
|
-
} catch (err) {
|
|
4536
|
-
recordError("dashboard:recent", err);
|
|
4537
|
-
}
|
|
4538
|
-
}
|
|
4539
5402
|
let results;
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
5403
|
+
await Promise.all([
|
|
5404
|
+
(async () => {
|
|
5405
|
+
if (runRefs.length === 0) return;
|
|
5406
|
+
try {
|
|
5407
|
+
const result = await this.getTriggerRunStatus({ run_ids: runRefs.map((ref) => ref.id) });
|
|
5408
|
+
const runs = "runs" in result ? result.runs : [result];
|
|
5409
|
+
runStatuses = runs;
|
|
5410
|
+
for (const run of runs) addRefs(run.execution_refs);
|
|
5411
|
+
} catch (err) {
|
|
5412
|
+
recordError(runRefs.length === 1 ? `run-status:${runRefs[0].id}` : "run-status:batch", err);
|
|
5413
|
+
}
|
|
5414
|
+
})(),
|
|
5415
|
+
(async () => {
|
|
5416
|
+
if (options.include_queue === false) return;
|
|
5417
|
+
try {
|
|
5418
|
+
queue = await this.getQueueStatus({ summary: true });
|
|
5419
|
+
addRefs(queue.execution_refs);
|
|
5420
|
+
} catch (err) {
|
|
5421
|
+
recordError("queue", err);
|
|
5422
|
+
}
|
|
5423
|
+
})(),
|
|
5424
|
+
(async () => {
|
|
5425
|
+
if (options.include_dashboard === false) return;
|
|
5426
|
+
try {
|
|
5427
|
+
dashboardRecent = await this.getDashboard({
|
|
5428
|
+
section: "recent",
|
|
5429
|
+
limit: options.dashboard_limit ?? 10,
|
|
5430
|
+
timeRangeDays: options.time_range_days
|
|
5431
|
+
});
|
|
5432
|
+
} catch (err) {
|
|
5433
|
+
recordError("dashboard:recent", err);
|
|
5434
|
+
}
|
|
5435
|
+
})(),
|
|
5436
|
+
(async () => {
|
|
5437
|
+
if (!options.include_results) return;
|
|
5438
|
+
try {
|
|
5439
|
+
results = await this.results({
|
|
5440
|
+
op_id: options.op_id,
|
|
5441
|
+
limit: options.results_limit ?? 25,
|
|
5442
|
+
include_failed_runs: true
|
|
5443
|
+
});
|
|
5444
|
+
addRefs(results.execution_refs);
|
|
5445
|
+
} catch (err) {
|
|
5446
|
+
recordError("results", err);
|
|
5447
|
+
}
|
|
5448
|
+
})()
|
|
5449
|
+
]);
|
|
4552
5450
|
const executionRefs = Array.from(refs.values());
|
|
4553
5451
|
const replayCandidates = executionRefs.filter((ref) => ref.kind === "execution_event");
|
|
4554
5452
|
const nextActions = buildDebugNextActions(status, executionRefs, diagnosticErrors);
|
|
@@ -4750,6 +5648,69 @@ function mergeExecutionRefs(result) {
|
|
|
4750
5648
|
for (const ref of collectExecutionReferences(result)) add(ref);
|
|
4751
5649
|
return Array.from(refs.values());
|
|
4752
5650
|
}
|
|
5651
|
+
function mergeExecutionRefsFrom(results) {
|
|
5652
|
+
const refs = /* @__PURE__ */ new Map();
|
|
5653
|
+
for (const result of results) {
|
|
5654
|
+
if (!result) continue;
|
|
5655
|
+
for (const ref of mergeExecutionRefs(result)) refs.set(`${ref.kind}:${ref.id}`, ref);
|
|
5656
|
+
}
|
|
5657
|
+
return Array.from(refs.values());
|
|
5658
|
+
}
|
|
5659
|
+
function normalizeOpsScheduleAndWaitCallResult(raw, waitOptions, messages) {
|
|
5660
|
+
if (raw.approval_required || raw.approvalRequired || raw.error_code === "APPROVAL_REQUIRED" || raw.errorCode === "APPROVAL_REQUIRED") {
|
|
5661
|
+
throw new SignalizError({
|
|
5662
|
+
code: "APPROVAL_REQUIRED",
|
|
5663
|
+
errorType: "validation",
|
|
5664
|
+
message: messages.approvalMessage,
|
|
5665
|
+
details: { schedule: raw }
|
|
5666
|
+
});
|
|
5667
|
+
}
|
|
5668
|
+
const opId = stringValue2(raw.op_id ?? raw.opId);
|
|
5669
|
+
if (!opId) {
|
|
5670
|
+
throw new SignalizError({
|
|
5671
|
+
code: "OP_NOT_CREATED",
|
|
5672
|
+
errorType: "validation",
|
|
5673
|
+
message: messages.notCreatedMessage,
|
|
5674
|
+
details: { schedule: raw }
|
|
5675
|
+
});
|
|
5676
|
+
}
|
|
5677
|
+
const scheduleRaw = asRecord2(raw.schedule ?? raw.schedule_result ?? raw.scheduleResult);
|
|
5678
|
+
const runRaw = asRecord2(raw.run ?? raw.run_result ?? raw.runResult);
|
|
5679
|
+
const schedule = normalizeOpsCreateResult(withExecutionRefs(
|
|
5680
|
+
Object.keys(scheduleRaw).length > 0 ? scheduleRaw : {
|
|
5681
|
+
...raw,
|
|
5682
|
+
op_id: opId,
|
|
5683
|
+
routine_id: raw.routine_id ?? raw.routineId ?? opId,
|
|
5684
|
+
status: "ready",
|
|
5685
|
+
phase: "scheduled",
|
|
5686
|
+
next_action: raw.next_action ?? raw.nextAction
|
|
5687
|
+
}
|
|
5688
|
+
));
|
|
5689
|
+
const run = normalizeOpsRunResult(withExecutionRefs(
|
|
5690
|
+
Object.keys(runRaw).length > 0 ? runRaw : {
|
|
5691
|
+
success: raw.success !== false,
|
|
5692
|
+
op_id: opId,
|
|
5693
|
+
routine_id: raw.routine_id ?? raw.routineId ?? opId,
|
|
5694
|
+
run_id: raw.run_id ?? raw.runId ?? null,
|
|
5695
|
+
status: "running",
|
|
5696
|
+
phase: "queued",
|
|
5697
|
+
next_action: raw.next_action ?? raw.nextAction,
|
|
5698
|
+
results_count: 0,
|
|
5699
|
+
results_url: raw.results_url ?? raw.resultsUrl,
|
|
5700
|
+
delivery_status: raw.delivery_status ?? raw.deliveryStatus
|
|
5701
|
+
}
|
|
5702
|
+
));
|
|
5703
|
+
const waited = normalizeOpsWaitForResultsResult(raw, { ...waitOptions, op_id: opId });
|
|
5704
|
+
const runId = run.run_id ?? run.runId ?? waited.run_id ?? waited.runId ?? waited.status.run_id ?? waited.status.runId ?? null;
|
|
5705
|
+
return {
|
|
5706
|
+
...waited,
|
|
5707
|
+
schedule,
|
|
5708
|
+
run,
|
|
5709
|
+
run_id: runId,
|
|
5710
|
+
runId,
|
|
5711
|
+
execution_refs: mergeExecutionRefsFrom([schedule, run, waited])
|
|
5712
|
+
};
|
|
5713
|
+
}
|
|
4753
5714
|
function normalizeOpsPrimitiveRetryPolicy(policy = {}) {
|
|
4754
5715
|
return {
|
|
4755
5716
|
...policy,
|
|
@@ -4825,8 +5786,122 @@ function normalizeOpsPrimitive(primitive) {
|
|
|
4825
5786
|
observability: normalizeOpsPrimitiveObservabilityPolicy(primitive.observability)
|
|
4826
5787
|
};
|
|
4827
5788
|
}
|
|
5789
|
+
function normalizeOpsExecutionToolCall(rawCall) {
|
|
5790
|
+
const call = asRecord2(rawCall);
|
|
5791
|
+
return {
|
|
5792
|
+
...call,
|
|
5793
|
+
tool: stringValue2(call.tool),
|
|
5794
|
+
arguments: asRecord2(call.arguments),
|
|
5795
|
+
purpose: stringValue2(call.purpose)
|
|
5796
|
+
};
|
|
5797
|
+
}
|
|
5798
|
+
function normalizeOpsExecutionScheduleContract(rawSchedule) {
|
|
5799
|
+
const schedule = asRecord2(rawSchedule);
|
|
5800
|
+
const wakeOnEvents = Array.isArray(schedule.wake_on_events) ? schedule.wake_on_events.map(String) : Array.isArray(schedule.wakeOnEvents) ? schedule.wakeOnEvents.map(String) : [];
|
|
5801
|
+
return {
|
|
5802
|
+
...schedule,
|
|
5803
|
+
create_tool: stringValue2(schedule.create_tool ?? schedule.createTool),
|
|
5804
|
+
createTool: stringValue2(schedule.createTool ?? schedule.create_tool),
|
|
5805
|
+
activate_tool: stringValue2(schedule.activate_tool ?? schedule.activateTool),
|
|
5806
|
+
activateTool: stringValue2(schedule.activateTool ?? schedule.activate_tool),
|
|
5807
|
+
cadence: stringValue2(schedule.cadence, "manual"),
|
|
5808
|
+
recurrence: stringValue2(schedule.recurrence),
|
|
5809
|
+
wake_on_events: wakeOnEvents,
|
|
5810
|
+
wakeOnEvents
|
|
5811
|
+
};
|
|
5812
|
+
}
|
|
5813
|
+
function normalizeOpsExecutionApprovalContract(rawApproval) {
|
|
5814
|
+
const approval = asRecord2(rawApproval);
|
|
5815
|
+
return {
|
|
5816
|
+
...approval,
|
|
5817
|
+
required: Boolean(approval.required),
|
|
5818
|
+
tool: stringValue2(approval.tool),
|
|
5819
|
+
reason: stringValue2(approval.reason)
|
|
5820
|
+
};
|
|
5821
|
+
}
|
|
5822
|
+
function normalizeOpsExecutionMonitorContract(rawMonitor) {
|
|
5823
|
+
const monitor = asRecord2(rawMonitor);
|
|
5824
|
+
const pollAfterMs = numberValue(monitor.poll_after_ms ?? monitor.pollAfterMs);
|
|
5825
|
+
return {
|
|
5826
|
+
...monitor,
|
|
5827
|
+
status_tool: stringValue2(monitor.status_tool ?? monitor.statusTool),
|
|
5828
|
+
statusTool: stringValue2(monitor.statusTool ?? monitor.status_tool),
|
|
5829
|
+
wait_tool: stringValue2(monitor.wait_tool ?? monitor.waitTool),
|
|
5830
|
+
waitTool: stringValue2(monitor.waitTool ?? monitor.wait_tool),
|
|
5831
|
+
results_tool: stringValue2(monitor.results_tool ?? monitor.resultsTool),
|
|
5832
|
+
resultsTool: stringValue2(monitor.resultsTool ?? monitor.results_tool),
|
|
5833
|
+
poll_after_ms: pollAfterMs,
|
|
5834
|
+
pollAfterMs
|
|
5835
|
+
};
|
|
5836
|
+
}
|
|
5837
|
+
function normalizeOpsExecutionResultContract(rawResult) {
|
|
5838
|
+
const result = asRecord2(rawResult);
|
|
5839
|
+
const shape = Array.isArray(result.shape) ? result.shape.map(String) : [];
|
|
5840
|
+
return {
|
|
5841
|
+
...result,
|
|
5842
|
+
tool: stringValue2(result.tool),
|
|
5843
|
+
wait_tool: stringValue2(result.wait_tool ?? result.waitTool),
|
|
5844
|
+
waitTool: stringValue2(result.waitTool ?? result.wait_tool),
|
|
5845
|
+
shape,
|
|
5846
|
+
empty_result_recovery: stringValue2(result.empty_result_recovery ?? result.emptyResultRecovery),
|
|
5847
|
+
emptyResultRecovery: stringValue2(result.emptyResultRecovery ?? result.empty_result_recovery)
|
|
5848
|
+
};
|
|
5849
|
+
}
|
|
5850
|
+
function normalizeOpsExecutionNangoRouteContract(rawRoute) {
|
|
5851
|
+
if (!rawRoute || typeof rawRoute !== "object" || Array.isArray(rawRoute)) return void 0;
|
|
5852
|
+
const route = asRecord2(rawRoute);
|
|
5853
|
+
const requiredFields = Array.isArray(route.required_fields) ? route.required_fields.map(String) : Array.isArray(route.requiredFields) ? route.requiredFields.map(String) : [];
|
|
5854
|
+
return {
|
|
5855
|
+
...route,
|
|
5856
|
+
enabled: route.enabled !== false,
|
|
5857
|
+
connect_tool: stringValue2(route.connect_tool ?? route.connectTool),
|
|
5858
|
+
connectTool: stringValue2(route.connectTool ?? route.connect_tool),
|
|
5859
|
+
discover_tool: stringValue2(route.discover_tool ?? route.discoverTool),
|
|
5860
|
+
discoverTool: stringValue2(route.discoverTool ?? route.discover_tool),
|
|
5861
|
+
dry_run_tool: stringValue2(route.dry_run_tool ?? route.dryRunTool),
|
|
5862
|
+
dryRunTool: stringValue2(route.dryRunTool ?? route.dry_run_tool),
|
|
5863
|
+
execute_tool: stringValue2(route.execute_tool ?? route.executeTool),
|
|
5864
|
+
executeTool: stringValue2(route.executeTool ?? route.execute_tool),
|
|
5865
|
+
execute_and_wait_tool: stringValue2(route.execute_and_wait_tool ?? route.executeAndWaitTool),
|
|
5866
|
+
executeAndWaitTool: stringValue2(route.executeAndWaitTool ?? route.execute_and_wait_tool),
|
|
5867
|
+
schedule_tool: stringValue2(route.schedule_tool ?? route.scheduleTool),
|
|
5868
|
+
scheduleTool: stringValue2(route.scheduleTool ?? route.schedule_tool),
|
|
5869
|
+
schedule_and_wait_tool: stringValue2(route.schedule_and_wait_tool ?? route.scheduleAndWaitTool),
|
|
5870
|
+
scheduleAndWaitTool: stringValue2(route.scheduleAndWaitTool ?? route.schedule_and_wait_tool),
|
|
5871
|
+
result_tool: stringValue2(route.result_tool ?? route.resultTool),
|
|
5872
|
+
resultTool: stringValue2(route.resultTool ?? route.result_tool),
|
|
5873
|
+
write_gate: stringValue2(route.write_gate ?? route.writeGate),
|
|
5874
|
+
writeGate: stringValue2(route.writeGate ?? route.write_gate),
|
|
5875
|
+
required_fields: requiredFields,
|
|
5876
|
+
requiredFields,
|
|
5877
|
+
schedule_arguments: asRecord2(route.schedule_arguments ?? route.scheduleArguments),
|
|
5878
|
+
scheduleArguments: asRecord2(route.scheduleArguments ?? route.schedule_arguments),
|
|
5879
|
+
schedule_and_wait_arguments: asRecord2(route.schedule_and_wait_arguments ?? route.scheduleAndWaitArguments),
|
|
5880
|
+
scheduleAndWaitArguments: asRecord2(route.scheduleAndWaitArguments ?? route.schedule_and_wait_arguments)
|
|
5881
|
+
};
|
|
5882
|
+
}
|
|
5883
|
+
function normalizeOpsExecutionContract(rawContract) {
|
|
5884
|
+
if (!rawContract || typeof rawContract !== "object" || Array.isArray(rawContract)) return void 0;
|
|
5885
|
+
const contract = asRecord2(rawContract);
|
|
5886
|
+
const nangoRoute = normalizeOpsExecutionNangoRouteContract(contract.nango_route ?? contract.nangoRoute);
|
|
5887
|
+
const sequence = Array.isArray(contract.sequence) ? contract.sequence.map(normalizeOpsExecutionToolCall) : [];
|
|
5888
|
+
return {
|
|
5889
|
+
...contract,
|
|
5890
|
+
mode: stringValue2(contract.mode, "run_once"),
|
|
5891
|
+
run_now: normalizeOpsExecutionToolCall(contract.run_now ?? contract.runNow),
|
|
5892
|
+
runNow: normalizeOpsExecutionToolCall(contract.runNow ?? contract.run_now),
|
|
5893
|
+
schedule: normalizeOpsExecutionScheduleContract(contract.schedule),
|
|
5894
|
+
approval: normalizeOpsExecutionApprovalContract(contract.approval),
|
|
5895
|
+
monitor: normalizeOpsExecutionMonitorContract(contract.monitor),
|
|
5896
|
+
result_contract: normalizeOpsExecutionResultContract(contract.result_contract ?? contract.resultContract),
|
|
5897
|
+
resultContract: normalizeOpsExecutionResultContract(contract.resultContract ?? contract.result_contract),
|
|
5898
|
+
...nangoRoute ? { nango_route: nangoRoute, nangoRoute } : {},
|
|
5899
|
+
sequence
|
|
5900
|
+
};
|
|
5901
|
+
}
|
|
4828
5902
|
function normalizeOpsPlanResult(result) {
|
|
4829
5903
|
const primitiveGraph = result.primitive_graph ?? result.primitiveGraph;
|
|
5904
|
+
const executionContract = normalizeOpsExecutionContract(result.execution_contract ?? result.executionContract);
|
|
4830
5905
|
return {
|
|
4831
5906
|
...result,
|
|
4832
5907
|
plan_id: result.plan_id ?? result.planId,
|
|
@@ -4850,7 +5925,8 @@ function normalizeOpsPlanResult(result) {
|
|
|
4850
5925
|
destination_status: result.destination_status ?? result.destinationStatus,
|
|
4851
5926
|
destinationStatus: result.destinationStatus ?? result.destination_status,
|
|
4852
5927
|
primitive_graph: primitiveGraph?.map(normalizeOpsPrimitive),
|
|
4853
|
-
primitiveGraph: primitiveGraph?.map(normalizeOpsPrimitive)
|
|
5928
|
+
primitiveGraph: primitiveGraph?.map(normalizeOpsPrimitive),
|
|
5929
|
+
...executionContract ? { execution_contract: executionContract, executionContract } : {}
|
|
4854
5930
|
};
|
|
4855
5931
|
}
|
|
4856
5932
|
function normalizeOpsCreateResult(result) {
|
|
@@ -4872,7 +5948,18 @@ function normalizeOpsCreateResult(result) {
|
|
|
4872
5948
|
deliveryStatus: result.deliveryStatus ?? result.delivery_status,
|
|
4873
5949
|
estimated_credits: result.estimated_credits ?? result.estimatedCredits,
|
|
4874
5950
|
estimatedCredits: result.estimatedCredits ?? result.estimated_credits,
|
|
4875
|
-
|
|
5951
|
+
error_code: result.error_code ?? result.errorCode,
|
|
5952
|
+
errorCode: result.errorCode ?? result.error_code,
|
|
5953
|
+
approval_required: result.approval_required ?? result.approvalRequired,
|
|
5954
|
+
approvalRequired: result.approvalRequired ?? result.approval_required,
|
|
5955
|
+
retry_arguments: result.retry_arguments ?? result.retryArguments,
|
|
5956
|
+
retryArguments: result.retryArguments ?? result.retry_arguments,
|
|
5957
|
+
blockers: result.blockers,
|
|
5958
|
+
plan: result.plan ? normalizeOpsPlanResult(result.plan) : result.plan,
|
|
5959
|
+
next_step: result.next_step ?? result.nextStep,
|
|
5960
|
+
nextStep: result.nextStep ?? result.next_step,
|
|
5961
|
+
next_steps: result.next_steps ?? result.nextSteps,
|
|
5962
|
+
nextSteps: result.nextSteps ?? result.next_steps
|
|
4876
5963
|
};
|
|
4877
5964
|
}
|
|
4878
5965
|
function normalizeOpsExecuteResult(result) {
|
|
@@ -5000,6 +6087,40 @@ function normalizeOpsStatusResult(result) {
|
|
|
5000
6087
|
diagnosis: result.diagnosis ? normalizeOpsDebugDiagnosis(result.diagnosis) : void 0
|
|
5001
6088
|
};
|
|
5002
6089
|
}
|
|
6090
|
+
function normalizeOpsResultsSummary(value) {
|
|
6091
|
+
const summary = asRecord2(value);
|
|
6092
|
+
if (Object.keys(summary).length === 0) return void 0;
|
|
6093
|
+
const resultsTotal = summary.results_total ?? summary.resultsTotal;
|
|
6094
|
+
const nextCursor = summary.next_cursor ?? summary.nextCursor ?? null;
|
|
6095
|
+
const resultsUrl = summary.results_url ?? summary.resultsUrl;
|
|
6096
|
+
const nextAction = summary.next_action ?? summary.nextAction;
|
|
6097
|
+
const runId = summary.run_id ?? summary.runId ?? null;
|
|
6098
|
+
const creditsUsed = summary.credits_used ?? summary.creditsUsed;
|
|
6099
|
+
return {
|
|
6100
|
+
...summary,
|
|
6101
|
+
label: optionalString(summary.label),
|
|
6102
|
+
status: optionalString(summary.status),
|
|
6103
|
+
phase: optionalString(summary.phase),
|
|
6104
|
+
results_count: numberValue(summary.results_count ?? summary.resultsCount),
|
|
6105
|
+
resultsCount: numberValue(summary.results_count ?? summary.resultsCount),
|
|
6106
|
+
results_total: resultsTotal === null || resultsTotal === void 0 ? resultsTotal : numberValue(resultsTotal),
|
|
6107
|
+
resultsTotal: resultsTotal === null || resultsTotal === void 0 ? resultsTotal : numberValue(resultsTotal),
|
|
6108
|
+
delivery_status: optionalString(summary.delivery_status ?? summary.deliveryStatus),
|
|
6109
|
+
deliveryStatus: optionalString(summary.delivery_status ?? summary.deliveryStatus),
|
|
6110
|
+
has_more: Boolean(summary.has_more ?? summary.hasMore),
|
|
6111
|
+
hasMore: Boolean(summary.has_more ?? summary.hasMore),
|
|
6112
|
+
next_cursor: nextCursor === null ? null : optionalString(nextCursor),
|
|
6113
|
+
nextCursor: nextCursor === null ? null : optionalString(nextCursor),
|
|
6114
|
+
results_url: optionalString(resultsUrl),
|
|
6115
|
+
resultsUrl: optionalString(resultsUrl),
|
|
6116
|
+
next_action: optionalString(nextAction),
|
|
6117
|
+
nextAction: optionalString(nextAction),
|
|
6118
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6119
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6120
|
+
credits_used: creditsUsed === void 0 ? void 0 : numberValue(creditsUsed),
|
|
6121
|
+
creditsUsed: creditsUsed === void 0 ? void 0 : numberValue(creditsUsed)
|
|
6122
|
+
};
|
|
6123
|
+
}
|
|
5003
6124
|
function normalizeOpsResultsResult(result) {
|
|
5004
6125
|
const nextCursor = result.next_cursor ?? result.nextCursor ?? null;
|
|
5005
6126
|
const hasMore = result.has_more ?? result.hasMore ?? false;
|
|
@@ -5024,7 +6145,104 @@ function normalizeOpsResultsResult(result) {
|
|
|
5024
6145
|
results_url: result.results_url ?? result.resultsUrl,
|
|
5025
6146
|
resultsUrl: result.resultsUrl ?? result.results_url,
|
|
5026
6147
|
delivery_status: result.delivery_status ?? result.deliveryStatus,
|
|
5027
|
-
deliveryStatus: result.deliveryStatus ?? result.delivery_status
|
|
6148
|
+
deliveryStatus: result.deliveryStatus ?? result.delivery_status,
|
|
6149
|
+
summary: normalizeOpsResultsSummary(result.summary)
|
|
6150
|
+
};
|
|
6151
|
+
}
|
|
6152
|
+
function normalizeOpsWaitForResultsPoll(value, fallbackPoll) {
|
|
6153
|
+
const raw = asRecord2(value);
|
|
6154
|
+
const checkedAt = stringValue2(raw.checked_at ?? raw.checkedAt);
|
|
6155
|
+
const resultsCount = raw.results_count ?? raw.resultsCount;
|
|
6156
|
+
const runId = raw.run_id ?? raw.runId ?? null;
|
|
6157
|
+
const nextAction = raw.next_action ?? raw.nextAction;
|
|
6158
|
+
return {
|
|
6159
|
+
...raw,
|
|
6160
|
+
poll: numberValue(raw.poll) || fallbackPoll,
|
|
6161
|
+
checked_at: checkedAt,
|
|
6162
|
+
checkedAt,
|
|
6163
|
+
status: stringValue2(raw.status, "unknown"),
|
|
6164
|
+
phase: optionalString(raw.phase),
|
|
6165
|
+
results_count: resultsCount === void 0 ? void 0 : numberValue(resultsCount),
|
|
6166
|
+
resultsCount: resultsCount === void 0 ? void 0 : numberValue(resultsCount),
|
|
6167
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6168
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6169
|
+
next_action: optionalString(nextAction),
|
|
6170
|
+
nextAction: optionalString(nextAction)
|
|
6171
|
+
};
|
|
6172
|
+
}
|
|
6173
|
+
function normalizeOpsWaitForResultsResult(result, options) {
|
|
6174
|
+
const opId = stringValue2(result.op_id ?? result.opId ?? options.op_id);
|
|
6175
|
+
const routineId = stringValue2(result.routine_id ?? result.routineId ?? opId);
|
|
6176
|
+
const runId = result.run_id ?? result.runId ?? null;
|
|
6177
|
+
const timedOut = Boolean(result.timed_out ?? result.timedOut);
|
|
6178
|
+
const statusRaw = asRecord2(result.status_result ?? result.statusResult);
|
|
6179
|
+
const resultsRaw = asRecord2(result.results_result ?? result.resultsResult);
|
|
6180
|
+
const historySource = Array.isArray(result.poll_history) ? result.poll_history : Array.isArray(result.history) ? result.history : [];
|
|
6181
|
+
const history = historySource.map((item, index) => normalizeOpsWaitForResultsPoll(item, index + 1));
|
|
6182
|
+
const status = normalizeOpsStatusResult(withExecutionRefs({
|
|
6183
|
+
success: result.success !== false,
|
|
6184
|
+
op_id: opId,
|
|
6185
|
+
routine_id: routineId,
|
|
6186
|
+
run_id: runId,
|
|
6187
|
+
status: stringValue2(result.status, "unknown"),
|
|
6188
|
+
phase: stringValue2(result.phase, "unknown"),
|
|
6189
|
+
next_action: stringValue2(result.next_action ?? result.nextAction),
|
|
6190
|
+
results_count: numberValue(result.results_count ?? result.resultsCount),
|
|
6191
|
+
results_url: optionalString(result.results_url ?? result.resultsUrl),
|
|
6192
|
+
delivery_status: optionalString(result.delivery_status ?? result.deliveryStatus),
|
|
6193
|
+
...statusRaw
|
|
6194
|
+
}));
|
|
6195
|
+
const includeResults = options.include_results !== false && options.includeResults !== false;
|
|
6196
|
+
const hasResultsPacket = Object.keys(resultsRaw).length > 0 || Array.isArray(result.results);
|
|
6197
|
+
const results = includeResults && hasResultsPacket ? normalizeOpsResultsResult(withExecutionRefs({
|
|
6198
|
+
success: result.success !== false,
|
|
6199
|
+
op_id: opId,
|
|
6200
|
+
routine_id: routineId,
|
|
6201
|
+
run_id: runId,
|
|
6202
|
+
status: stringValue2(result.status, status.status),
|
|
6203
|
+
phase: stringValue2(result.phase, status.phase),
|
|
6204
|
+
results_count: numberValue(result.results_count ?? result.resultsCount),
|
|
6205
|
+
results_total: result.results_total ?? result.resultsTotal ?? null,
|
|
6206
|
+
results: Array.isArray(result.results) ? result.results : [],
|
|
6207
|
+
next_cursor: result.next_cursor ?? result.nextCursor ?? null,
|
|
6208
|
+
has_more: Boolean(result.has_more ?? result.hasMore),
|
|
6209
|
+
next_action: stringValue2(result.next_action ?? result.nextAction),
|
|
6210
|
+
results_url: optionalString(result.results_url ?? result.resultsUrl),
|
|
6211
|
+
delivery_status: optionalString(result.delivery_status ?? result.deliveryStatus),
|
|
6212
|
+
...resultsRaw
|
|
6213
|
+
})) : void 0;
|
|
6214
|
+
const polls = numberValue(result.polls) || history.length;
|
|
6215
|
+
const maxPolls = result.max_polls ?? result.maxPolls;
|
|
6216
|
+
const intervalMs = result.interval_ms ?? result.intervalMs;
|
|
6217
|
+
const timeoutMs = result.timeout_ms ?? result.timeoutMs;
|
|
6218
|
+
const stopReason = result.stop_reason ?? result.stopReason;
|
|
6219
|
+
const nextAction = result.next_action ?? result.nextAction ?? results?.next_action ?? status.next_action;
|
|
6220
|
+
return {
|
|
6221
|
+
...result,
|
|
6222
|
+
success: result.success !== false && !timedOut,
|
|
6223
|
+
op_id: opId,
|
|
6224
|
+
opId,
|
|
6225
|
+
routine_id: routineId,
|
|
6226
|
+
routineId,
|
|
6227
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6228
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6229
|
+
status,
|
|
6230
|
+
results,
|
|
6231
|
+
timed_out: timedOut,
|
|
6232
|
+
timedOut,
|
|
6233
|
+
polls,
|
|
6234
|
+
max_polls: maxPolls === void 0 ? void 0 : numberValue(maxPolls),
|
|
6235
|
+
maxPolls: maxPolls === void 0 ? void 0 : numberValue(maxPolls),
|
|
6236
|
+
interval_ms: intervalMs === void 0 ? void 0 : numberValue(intervalMs),
|
|
6237
|
+
intervalMs: intervalMs === void 0 ? void 0 : numberValue(intervalMs),
|
|
6238
|
+
timeout_ms: timeoutMs === void 0 ? void 0 : numberValue(timeoutMs),
|
|
6239
|
+
timeoutMs: timeoutMs === void 0 ? void 0 : numberValue(timeoutMs),
|
|
6240
|
+
stop_reason: optionalString(stopReason),
|
|
6241
|
+
stopReason: optionalString(stopReason),
|
|
6242
|
+
history,
|
|
6243
|
+
next_action: optionalString(nextAction),
|
|
6244
|
+
nextAction: optionalString(nextAction),
|
|
6245
|
+
execution_refs: mergeExecutionRefsFrom([result, status, results, { history }])
|
|
5028
6246
|
};
|
|
5029
6247
|
}
|
|
5030
6248
|
function normalizeOpsProofResult(data) {
|
|
@@ -5104,11 +6322,107 @@ function normalizeOpsProofResult(data) {
|
|
|
5104
6322
|
raw: data
|
|
5105
6323
|
};
|
|
5106
6324
|
}
|
|
6325
|
+
function normalizeOpsAutopilotSchedulePacket(rawPacket) {
|
|
6326
|
+
const packet = asRecord2(rawPacket);
|
|
6327
|
+
return {
|
|
6328
|
+
...packet,
|
|
6329
|
+
cadence: stringValue2(packet.cadence, "manual"),
|
|
6330
|
+
recurrence: stringValue2(packet.recurrence),
|
|
6331
|
+
activate_with: stringValue2(packet.activate_with ?? packet.activateWith),
|
|
6332
|
+
activateWith: stringValue2(packet.activate_with ?? packet.activateWith),
|
|
6333
|
+
run_now_with: stringValue2(packet.run_now_with ?? packet.runNowWith),
|
|
6334
|
+
runNowWith: stringValue2(packet.run_now_with ?? packet.runNowWith),
|
|
6335
|
+
monitor_with: stringValue2(packet.monitor_with ?? packet.monitorWith),
|
|
6336
|
+
monitorWith: stringValue2(packet.monitor_with ?? packet.monitorWith),
|
|
6337
|
+
retrieve_with: stringValue2(packet.retrieve_with ?? packet.retrieveWith),
|
|
6338
|
+
retrieveWith: stringValue2(packet.retrieve_with ?? packet.retrieveWith)
|
|
6339
|
+
};
|
|
6340
|
+
}
|
|
6341
|
+
function normalizeOpsAutopilotNangoRoutePacket(rawPacket) {
|
|
6342
|
+
if (!rawPacket || typeof rawPacket !== "object" || Array.isArray(rawPacket)) return void 0;
|
|
6343
|
+
const packet = asRecord2(rawPacket);
|
|
6344
|
+
const requiredFields = Array.isArray(packet.required_fields) ? packet.required_fields.map(String) : Array.isArray(packet.requiredFields) ? packet.requiredFields.map(String) : [];
|
|
6345
|
+
return {
|
|
6346
|
+
...packet,
|
|
6347
|
+
enabled: packet.enabled !== false,
|
|
6348
|
+
route_label: stringValue2(packet.route_label ?? packet.routeLabel),
|
|
6349
|
+
routeLabel: stringValue2(packet.route_label ?? packet.routeLabel),
|
|
6350
|
+
connect_tool: stringValue2(packet.connect_tool ?? packet.connectTool),
|
|
6351
|
+
connectTool: stringValue2(packet.connect_tool ?? packet.connectTool),
|
|
6352
|
+
discover_tool: stringValue2(packet.discover_tool ?? packet.discoverTool),
|
|
6353
|
+
discoverTool: stringValue2(packet.discover_tool ?? packet.discoverTool),
|
|
6354
|
+
dry_run_tool: stringValue2(packet.dry_run_tool ?? packet.dryRunTool),
|
|
6355
|
+
dryRunTool: stringValue2(packet.dry_run_tool ?? packet.dryRunTool),
|
|
6356
|
+
execute_tool: stringValue2(packet.execute_tool ?? packet.executeTool),
|
|
6357
|
+
executeTool: stringValue2(packet.execute_tool ?? packet.executeTool),
|
|
6358
|
+
execute_and_wait_tool: stringValue2(packet.execute_and_wait_tool ?? packet.executeAndWaitTool),
|
|
6359
|
+
executeAndWaitTool: stringValue2(packet.execute_and_wait_tool ?? packet.executeAndWaitTool),
|
|
6360
|
+
schedule_tool: stringValue2(packet.schedule_tool ?? packet.scheduleTool),
|
|
6361
|
+
scheduleTool: stringValue2(packet.schedule_tool ?? packet.scheduleTool),
|
|
6362
|
+
schedule_and_wait_tool: stringValue2(packet.schedule_and_wait_tool ?? packet.scheduleAndWaitTool),
|
|
6363
|
+
scheduleAndWaitTool: stringValue2(packet.schedule_and_wait_tool ?? packet.scheduleAndWaitTool),
|
|
6364
|
+
result_tool: stringValue2(packet.result_tool ?? packet.resultTool),
|
|
6365
|
+
resultTool: stringValue2(packet.result_tool ?? packet.resultTool),
|
|
6366
|
+
write_gate: stringValue2(packet.write_gate ?? packet.writeGate),
|
|
6367
|
+
writeGate: stringValue2(packet.write_gate ?? packet.writeGate),
|
|
6368
|
+
required_fields: requiredFields,
|
|
6369
|
+
requiredFields,
|
|
6370
|
+
placeholders: asRecord2(packet.placeholders),
|
|
6371
|
+
dry_run_arguments: asRecord2(packet.dry_run_arguments ?? packet.dryRunArguments),
|
|
6372
|
+
dryRunArguments: asRecord2(packet.dry_run_arguments ?? packet.dryRunArguments),
|
|
6373
|
+
execute_arguments: asRecord2(packet.execute_arguments ?? packet.executeArguments),
|
|
6374
|
+
executeArguments: asRecord2(packet.execute_arguments ?? packet.executeArguments),
|
|
6375
|
+
execute_and_wait_arguments: asRecord2(packet.execute_and_wait_arguments ?? packet.executeAndWaitArguments),
|
|
6376
|
+
executeAndWaitArguments: asRecord2(packet.execute_and_wait_arguments ?? packet.executeAndWaitArguments),
|
|
6377
|
+
schedule_arguments: asRecord2(packet.schedule_arguments ?? packet.scheduleArguments),
|
|
6378
|
+
scheduleArguments: asRecord2(packet.schedule_arguments ?? packet.scheduleArguments),
|
|
6379
|
+
schedule_and_wait_arguments: asRecord2(packet.schedule_and_wait_arguments ?? packet.scheduleAndWaitArguments),
|
|
6380
|
+
scheduleAndWaitArguments: asRecord2(packet.schedule_and_wait_arguments ?? packet.scheduleAndWaitArguments),
|
|
6381
|
+
result_arguments: asRecord2(packet.result_arguments ?? packet.resultArguments),
|
|
6382
|
+
resultArguments: asRecord2(packet.result_arguments ?? packet.resultArguments)
|
|
6383
|
+
};
|
|
6384
|
+
}
|
|
6385
|
+
function normalizeOpsAutopilotResultPacket(rawPacket) {
|
|
6386
|
+
const packet = asRecord2(rawPacket);
|
|
6387
|
+
const resultShape = Array.isArray(packet.result_shape) ? packet.result_shape.map(String) : Array.isArray(packet.resultShape) ? packet.resultShape.map(String) : [];
|
|
6388
|
+
const deliveryReceipts = Array.isArray(packet.delivery_receipts) ? packet.delivery_receipts.map(String) : Array.isArray(packet.deliveryReceipts) ? packet.deliveryReceipts.map(String) : [];
|
|
6389
|
+
return {
|
|
6390
|
+
...packet,
|
|
6391
|
+
retrieve_tool: stringValue2(packet.retrieve_tool ?? packet.retrieveTool),
|
|
6392
|
+
retrieveTool: stringValue2(packet.retrieve_tool ?? packet.retrieveTool),
|
|
6393
|
+
result_shape: resultShape,
|
|
6394
|
+
resultShape,
|
|
6395
|
+
delivery_receipts: deliveryReceipts,
|
|
6396
|
+
deliveryReceipts,
|
|
6397
|
+
empty_result_recovery: stringValue2(packet.empty_result_recovery ?? packet.emptyResultRecovery),
|
|
6398
|
+
emptyResultRecovery: stringValue2(packet.empty_result_recovery ?? packet.emptyResultRecovery)
|
|
6399
|
+
};
|
|
6400
|
+
}
|
|
6401
|
+
function normalizeOpsAutopilotOperatingPacket(rawPacket) {
|
|
6402
|
+
if (!rawPacket || typeof rawPacket !== "object" || Array.isArray(rawPacket)) return void 0;
|
|
6403
|
+
const packet = asRecord2(rawPacket);
|
|
6404
|
+
const nangoRoute = normalizeOpsAutopilotNangoRoutePacket(packet.nango_route ?? packet.nangoRoute);
|
|
6405
|
+
const approvalBoundaries = Array.isArray(packet.approval_boundaries) ? packet.approval_boundaries.map(String) : Array.isArray(packet.approvalBoundaries) ? packet.approvalBoundaries.map(String) : [];
|
|
6406
|
+
return {
|
|
6407
|
+
...packet,
|
|
6408
|
+
north_star: stringValue2(packet.north_star ?? packet.northStar),
|
|
6409
|
+
northStar: stringValue2(packet.north_star ?? packet.northStar),
|
|
6410
|
+
schedule: normalizeOpsAutopilotSchedulePacket(packet.schedule),
|
|
6411
|
+
...nangoRoute ? { nango_route: nangoRoute, nangoRoute } : {},
|
|
6412
|
+
result_contract: normalizeOpsAutopilotResultPacket(packet.result_contract ?? packet.resultContract),
|
|
6413
|
+
resultContract: normalizeOpsAutopilotResultPacket(packet.result_contract ?? packet.resultContract),
|
|
6414
|
+
approval_boundaries: approvalBoundaries,
|
|
6415
|
+
approvalBoundaries,
|
|
6416
|
+
saved_command_hint: stringValue2(packet.saved_command_hint ?? packet.savedCommandHint),
|
|
6417
|
+
savedCommandHint: stringValue2(packet.saved_command_hint ?? packet.savedCommandHint)
|
|
6418
|
+
};
|
|
6419
|
+
}
|
|
5107
6420
|
function normalizeOpsAutopilotMotion(rawMotion) {
|
|
5108
6421
|
const motion = asRecord2(rawMotion);
|
|
5109
6422
|
const targetCount = numberValue(motion.target_count ?? motion.targetCount);
|
|
5110
6423
|
const estimatedCredits = numberValue(motion.estimated_credits ?? motion.estimatedCredits);
|
|
5111
6424
|
const mcpSequence = Array.isArray(motion.mcp_sequence) ? motion.mcp_sequence : Array.isArray(motion.mcpSequence) ? motion.mcpSequence : [];
|
|
6425
|
+
const operatingPacket = normalizeOpsAutopilotOperatingPacket(motion.operating_packet ?? motion.operatingPacket);
|
|
5112
6426
|
return {
|
|
5113
6427
|
...motion,
|
|
5114
6428
|
id: stringValue2(motion.id),
|
|
@@ -5131,12 +6445,16 @@ function normalizeOpsAutopilotMotion(rawMotion) {
|
|
|
5131
6445
|
cli_command: optionalString(motion.cli_command ?? motion.cliCommand),
|
|
5132
6446
|
cliCommand: optionalString(motion.cli_command ?? motion.cliCommand),
|
|
5133
6447
|
mcp_sequence: mcpSequence,
|
|
5134
|
-
mcpSequence
|
|
6448
|
+
mcpSequence,
|
|
6449
|
+
...operatingPacket ? { operating_packet: operatingPacket, operatingPacket } : {}
|
|
5135
6450
|
};
|
|
5136
6451
|
}
|
|
5137
6452
|
function normalizeOpsAutopilotResult(result) {
|
|
5138
6453
|
const primary = normalizeOpsAutopilotMotion(result.primary_motion ?? result.primaryMotion);
|
|
5139
6454
|
const motions = Array.isArray(result.motions) ? result.motions.map(normalizeOpsAutopilotMotion) : [];
|
|
6455
|
+
const operatingPacket = normalizeOpsAutopilotOperatingPacket(
|
|
6456
|
+
result.operating_packet ?? result.operatingPacket ?? primary.operating_packet ?? primary.operatingPacket
|
|
6457
|
+
);
|
|
5140
6458
|
const queryErrors = Array.isArray(result.query_errors) ? result.query_errors.map(String) : Array.isArray(result.queryErrors) ? result.queryErrors.map(String) : [];
|
|
5141
6459
|
return {
|
|
5142
6460
|
...result,
|
|
@@ -5152,6 +6470,7 @@ function normalizeOpsAutopilotResult(result) {
|
|
|
5152
6470
|
scaleRule: optionalString(result.scale_rule ?? result.scaleRule),
|
|
5153
6471
|
agent_handoff: optionalString(result.agent_handoff ?? result.agentHandoff),
|
|
5154
6472
|
agentHandoff: optionalString(result.agent_handoff ?? result.agentHandoff),
|
|
6473
|
+
...operatingPacket ? { operating_packet: operatingPacket, operatingPacket } : {},
|
|
5155
6474
|
proof_state: optionalString(result.proof_state ?? result.proofState),
|
|
5156
6475
|
proofState: optionalString(result.proof_state ?? result.proofState),
|
|
5157
6476
|
proof_summary: result.proof_summary ?? result.proofSummary,
|
|
@@ -5416,11 +6735,125 @@ function normalizeOpsRoutineTickItemsResult(result) {
|
|
|
5416
6735
|
hasMore
|
|
5417
6736
|
};
|
|
5418
6737
|
}
|
|
6738
|
+
function buildOpsNangoScheduleBody(input) {
|
|
6739
|
+
const {
|
|
6740
|
+
workspaceConnectionId,
|
|
6741
|
+
workspace_connection_id,
|
|
6742
|
+
connectionId,
|
|
6743
|
+
connection_id,
|
|
6744
|
+
providerConfigKey,
|
|
6745
|
+
provider_config_key,
|
|
6746
|
+
integrationId,
|
|
6747
|
+
integration_id,
|
|
6748
|
+
nangoConnectionId,
|
|
6749
|
+
nango_connection_id,
|
|
6750
|
+
actionName,
|
|
6751
|
+
action_name,
|
|
6752
|
+
toolName,
|
|
6753
|
+
tool_name,
|
|
6754
|
+
proxyPath,
|
|
6755
|
+
proxy_path,
|
|
6756
|
+
nangoProxyPath,
|
|
6757
|
+
nango_proxy_path,
|
|
6758
|
+
method,
|
|
6759
|
+
httpMethod,
|
|
6760
|
+
http_method,
|
|
6761
|
+
input: nangoInput,
|
|
6762
|
+
arguments: nangoArguments,
|
|
6763
|
+
fieldMap,
|
|
6764
|
+
field_map,
|
|
6765
|
+
requiredFields,
|
|
6766
|
+
required_fields,
|
|
6767
|
+
writeConfirmed,
|
|
6768
|
+
write_confirmed,
|
|
6769
|
+
agentWriteConfirmed,
|
|
6770
|
+
agent_write_confirmed,
|
|
6771
|
+
config,
|
|
6772
|
+
destinations: _destinations,
|
|
6773
|
+
...schedule
|
|
6774
|
+
} = input;
|
|
6775
|
+
return {
|
|
6776
|
+
...buildOpsCreateBody({
|
|
6777
|
+
...schedule,
|
|
6778
|
+
cadence: schedule.cadence ?? "daily"
|
|
6779
|
+
}),
|
|
6780
|
+
workspace_connection_id: workspace_connection_id ?? workspaceConnectionId,
|
|
6781
|
+
connection_id: connection_id ?? connectionId,
|
|
6782
|
+
provider_config_key: provider_config_key ?? providerConfigKey,
|
|
6783
|
+
integration_id: integration_id ?? integrationId,
|
|
6784
|
+
nango_connection_id: nango_connection_id ?? nangoConnectionId,
|
|
6785
|
+
action_name: action_name ?? actionName,
|
|
6786
|
+
tool_name: tool_name ?? toolName,
|
|
6787
|
+
proxy_path: proxy_path ?? proxyPath ?? nango_proxy_path ?? nangoProxyPath,
|
|
6788
|
+
nango_proxy_path: nango_proxy_path ?? nangoProxyPath,
|
|
6789
|
+
method: method ?? http_method ?? httpMethod,
|
|
6790
|
+
input: nangoInput ?? nangoArguments,
|
|
6791
|
+
field_map: field_map ?? fieldMap,
|
|
6792
|
+
required_fields: required_fields ?? requiredFields,
|
|
6793
|
+
write_confirmed: write_confirmed ?? writeConfirmed,
|
|
6794
|
+
agent_write_confirmed: agent_write_confirmed ?? agentWriteConfirmed,
|
|
6795
|
+
config
|
|
6796
|
+
};
|
|
6797
|
+
}
|
|
6798
|
+
function buildOpsNangoScheduleAndWaitOptions(params) {
|
|
6799
|
+
const {
|
|
6800
|
+
force,
|
|
6801
|
+
instruction,
|
|
6802
|
+
nextCursor,
|
|
6803
|
+
includeFailedRuns,
|
|
6804
|
+
intervalMs,
|
|
6805
|
+
maxPolls,
|
|
6806
|
+
timeoutMs,
|
|
6807
|
+
includeResults,
|
|
6808
|
+
cursor,
|
|
6809
|
+
state,
|
|
6810
|
+
limit,
|
|
6811
|
+
include_failed_runs,
|
|
6812
|
+
interval_ms,
|
|
6813
|
+
max_polls,
|
|
6814
|
+
timeout_ms,
|
|
6815
|
+
include_results,
|
|
6816
|
+
...schedule
|
|
6817
|
+
} = params;
|
|
6818
|
+
return {
|
|
6819
|
+
schedule: {
|
|
6820
|
+
...schedule,
|
|
6821
|
+
cadence: schedule.cadence ?? "daily"
|
|
6822
|
+
},
|
|
6823
|
+
run: {
|
|
6824
|
+
force,
|
|
6825
|
+
instruction
|
|
6826
|
+
},
|
|
6827
|
+
wait: {
|
|
6828
|
+
cursor: cursor ?? nextCursor,
|
|
6829
|
+
state,
|
|
6830
|
+
limit,
|
|
6831
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6832
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6833
|
+
max_polls: max_polls ?? maxPolls,
|
|
6834
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6835
|
+
include_results: include_results ?? includeResults
|
|
6836
|
+
}
|
|
6837
|
+
};
|
|
6838
|
+
}
|
|
6839
|
+
function buildOpsNangoScheduleAndWaitBody(options) {
|
|
6840
|
+
const waitBody = buildOpsWaitBody(options.wait);
|
|
6841
|
+
const { op_id: _opId, ...waitWithoutOp } = waitBody;
|
|
6842
|
+
return {
|
|
6843
|
+
...buildOpsNangoScheduleBody(options.schedule),
|
|
6844
|
+
...waitWithoutOp,
|
|
6845
|
+
instruction: options.run.instruction,
|
|
6846
|
+
force: options.run.force
|
|
6847
|
+
};
|
|
6848
|
+
}
|
|
5419
6849
|
function buildOpsPlanBody(params) {
|
|
5420
|
-
const { targetCount, companyDomains, customAiPrompt, signalPrompt, outputPrompt, ...rest } = params;
|
|
6850
|
+
const { targetCount, wakeOnEvents, companyDomains, customAiPrompt, signalPrompt, outputPrompt, ...rest } = params;
|
|
6851
|
+
const destinations = Array.isArray(rest.destinations) ? rest.destinations.map(normalizeOpsDestinationRequest) : rest.destinations;
|
|
5421
6852
|
return {
|
|
5422
6853
|
...rest,
|
|
6854
|
+
destinations,
|
|
5423
6855
|
target_count: rest.target_count ?? targetCount,
|
|
6856
|
+
wake_on_events: rest.wake_on_events ?? wakeOnEvents,
|
|
5424
6857
|
company_domains: rest.company_domains ?? companyDomains,
|
|
5425
6858
|
custom_ai_prompt: rest.custom_ai_prompt ?? customAiPrompt,
|
|
5426
6859
|
signal_prompt: rest.signal_prompt ?? signalPrompt,
|
|
@@ -5443,6 +6876,95 @@ function buildOpsExecuteBody(params) {
|
|
|
5443
6876
|
output_format: rest.output_format ?? outputFormat
|
|
5444
6877
|
};
|
|
5445
6878
|
}
|
|
6879
|
+
function buildOpsExecuteAndWaitOptions(params) {
|
|
6880
|
+
const {
|
|
6881
|
+
nextCursor,
|
|
6882
|
+
includeFailedRuns,
|
|
6883
|
+
intervalMs,
|
|
6884
|
+
maxPolls,
|
|
6885
|
+
timeoutMs,
|
|
6886
|
+
includeResults,
|
|
6887
|
+
cursor,
|
|
6888
|
+
state,
|
|
6889
|
+
limit,
|
|
6890
|
+
include_failed_runs,
|
|
6891
|
+
interval_ms,
|
|
6892
|
+
max_polls,
|
|
6893
|
+
timeout_ms,
|
|
6894
|
+
include_results,
|
|
6895
|
+
...execute
|
|
6896
|
+
} = params;
|
|
6897
|
+
return {
|
|
6898
|
+
execute: {
|
|
6899
|
+
...execute,
|
|
6900
|
+
auto_run: execute.auto_run ?? execute.autoRun ?? true
|
|
6901
|
+
},
|
|
6902
|
+
wait: {
|
|
6903
|
+
cursor: cursor ?? nextCursor,
|
|
6904
|
+
state,
|
|
6905
|
+
limit,
|
|
6906
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6907
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6908
|
+
max_polls: max_polls ?? maxPolls,
|
|
6909
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6910
|
+
include_results: include_results ?? includeResults
|
|
6911
|
+
}
|
|
6912
|
+
};
|
|
6913
|
+
}
|
|
6914
|
+
function buildOpsScheduleAndWaitOptions(params) {
|
|
6915
|
+
const {
|
|
6916
|
+
force,
|
|
6917
|
+
instruction,
|
|
6918
|
+
nextCursor,
|
|
6919
|
+
includeFailedRuns,
|
|
6920
|
+
intervalMs,
|
|
6921
|
+
maxPolls,
|
|
6922
|
+
timeoutMs,
|
|
6923
|
+
includeResults,
|
|
6924
|
+
cursor,
|
|
6925
|
+
state,
|
|
6926
|
+
limit,
|
|
6927
|
+
include_failed_runs,
|
|
6928
|
+
interval_ms,
|
|
6929
|
+
max_polls,
|
|
6930
|
+
timeout_ms,
|
|
6931
|
+
include_results,
|
|
6932
|
+
...schedule
|
|
6933
|
+
} = params;
|
|
6934
|
+
return {
|
|
6935
|
+
schedule: {
|
|
6936
|
+
...schedule,
|
|
6937
|
+
cadence: schedule.cadence ?? "daily"
|
|
6938
|
+
},
|
|
6939
|
+
run: {
|
|
6940
|
+
force,
|
|
6941
|
+
instruction
|
|
6942
|
+
},
|
|
6943
|
+
wait: {
|
|
6944
|
+
cursor: cursor ?? nextCursor,
|
|
6945
|
+
state,
|
|
6946
|
+
limit,
|
|
6947
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6948
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6949
|
+
max_polls: max_polls ?? maxPolls,
|
|
6950
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6951
|
+
include_results: include_results ?? includeResults
|
|
6952
|
+
}
|
|
6953
|
+
};
|
|
6954
|
+
}
|
|
6955
|
+
function buildOpsScheduleAndWaitBody(options) {
|
|
6956
|
+
const waitBody = buildOpsWaitBody(options.wait);
|
|
6957
|
+
const { op_id: _opId, ...waitWithoutOp } = waitBody;
|
|
6958
|
+
return {
|
|
6959
|
+
...buildOpsCreateBody({
|
|
6960
|
+
...options.schedule,
|
|
6961
|
+
cadence: options.schedule.cadence ?? "daily"
|
|
6962
|
+
}),
|
|
6963
|
+
...waitWithoutOp,
|
|
6964
|
+
instruction: options.run.instruction,
|
|
6965
|
+
force: options.run.force
|
|
6966
|
+
};
|
|
6967
|
+
}
|
|
5446
6968
|
function buildOpsRunBody(params) {
|
|
5447
6969
|
const { opId, ...rest } = params;
|
|
5448
6970
|
return {
|
|
@@ -5450,6 +6972,28 @@ function buildOpsRunBody(params) {
|
|
|
5450
6972
|
op_id: rest.op_id ?? opId
|
|
5451
6973
|
};
|
|
5452
6974
|
}
|
|
6975
|
+
function buildOpsRunAndWaitOptions(params) {
|
|
6976
|
+
const {
|
|
6977
|
+
opId,
|
|
6978
|
+
nextCursor,
|
|
6979
|
+
includeFailedRuns,
|
|
6980
|
+
intervalMs,
|
|
6981
|
+
maxPolls,
|
|
6982
|
+
timeoutMs,
|
|
6983
|
+
includeResults,
|
|
6984
|
+
...rest
|
|
6985
|
+
} = params;
|
|
6986
|
+
return {
|
|
6987
|
+
...rest,
|
|
6988
|
+
op_id: rest.op_id ?? opId,
|
|
6989
|
+
cursor: rest.cursor ?? nextCursor,
|
|
6990
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
6991
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
6992
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
6993
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
6994
|
+
include_results: rest.include_results ?? includeResults
|
|
6995
|
+
};
|
|
6996
|
+
}
|
|
5453
6997
|
function buildOpsStatusBody(params) {
|
|
5454
6998
|
const { opId, ...rest } = params;
|
|
5455
6999
|
return {
|
|
@@ -5466,6 +7010,50 @@ function buildOpsResultsBody(params) {
|
|
|
5466
7010
|
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns
|
|
5467
7011
|
};
|
|
5468
7012
|
}
|
|
7013
|
+
function buildOpsWaitForResultsOptions(params) {
|
|
7014
|
+
const {
|
|
7015
|
+
opId,
|
|
7016
|
+
nextCursor,
|
|
7017
|
+
includeFailedRuns,
|
|
7018
|
+
intervalMs,
|
|
7019
|
+
maxPolls,
|
|
7020
|
+
timeoutMs,
|
|
7021
|
+
includeResults,
|
|
7022
|
+
...rest
|
|
7023
|
+
} = params;
|
|
7024
|
+
return {
|
|
7025
|
+
...rest,
|
|
7026
|
+
op_id: rest.op_id ?? opId,
|
|
7027
|
+
cursor: rest.cursor ?? nextCursor,
|
|
7028
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
7029
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
7030
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
7031
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
7032
|
+
include_results: rest.include_results ?? includeResults
|
|
7033
|
+
};
|
|
7034
|
+
}
|
|
7035
|
+
function buildOpsWaitBody(params) {
|
|
7036
|
+
const {
|
|
7037
|
+
opId,
|
|
7038
|
+
nextCursor,
|
|
7039
|
+
includeFailedRuns,
|
|
7040
|
+
intervalMs,
|
|
7041
|
+
maxPolls,
|
|
7042
|
+
timeoutMs,
|
|
7043
|
+
includeResults,
|
|
7044
|
+
...rest
|
|
7045
|
+
} = params;
|
|
7046
|
+
return {
|
|
7047
|
+
...rest,
|
|
7048
|
+
op_id: rest.op_id ?? opId,
|
|
7049
|
+
cursor: rest.cursor ?? nextCursor,
|
|
7050
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
7051
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
7052
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
7053
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
7054
|
+
include_results: rest.include_results ?? includeResults
|
|
7055
|
+
};
|
|
7056
|
+
}
|
|
5469
7057
|
function buildOpsDebugOptions(params) {
|
|
5470
7058
|
const {
|
|
5471
7059
|
opId,
|
|
@@ -5543,6 +7131,8 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5543
7131
|
nangoAction,
|
|
5544
7132
|
proxyPath,
|
|
5545
7133
|
nangoProxyPath,
|
|
7134
|
+
method,
|
|
7135
|
+
httpMethod,
|
|
5546
7136
|
fieldMap,
|
|
5547
7137
|
requiredFields,
|
|
5548
7138
|
writeConfirmed,
|
|
@@ -5561,6 +7151,7 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5561
7151
|
const nango_action = rest.nango_action ?? nangoAction;
|
|
5562
7152
|
const proxy_path = rest.proxy_path ?? proxyPath;
|
|
5563
7153
|
const nango_proxy_path = rest.nango_proxy_path ?? nangoProxyPath;
|
|
7154
|
+
const http_method = rest.http_method ?? httpMethod;
|
|
5564
7155
|
const field_map = rest.field_map ?? fieldMap;
|
|
5565
7156
|
const required_fields = rest.required_fields ?? requiredFields;
|
|
5566
7157
|
const write_confirmed = rest.write_confirmed ?? writeConfirmed;
|
|
@@ -5575,6 +7166,9 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5575
7166
|
if (nango_action !== void 0 && normalizedConfig.nango_action === void 0) normalizedConfig.nango_action = nango_action;
|
|
5576
7167
|
if (proxy_path !== void 0 && normalizedConfig.proxy_path === void 0) normalizedConfig.proxy_path = proxy_path;
|
|
5577
7168
|
if (nango_proxy_path !== void 0 && normalizedConfig.nango_proxy_path === void 0) normalizedConfig.nango_proxy_path = nango_proxy_path;
|
|
7169
|
+
if (method !== void 0 && normalizedConfig.method === void 0) normalizedConfig.method = method;
|
|
7170
|
+
if (http_method !== void 0 && normalizedConfig.http_method === void 0) normalizedConfig.http_method = http_method;
|
|
7171
|
+
if (normalizedConfig.method === void 0 && http_method !== void 0) normalizedConfig.method = http_method;
|
|
5578
7172
|
if (field_map !== void 0 && normalizedConfig.field_map === void 0) normalizedConfig.field_map = field_map;
|
|
5579
7173
|
if (required_fields !== void 0 && normalizedConfig.required_fields === void 0) normalizedConfig.required_fields = required_fields;
|
|
5580
7174
|
if (write_confirmed !== void 0 && normalizedConfig.write_confirmed === void 0) normalizedConfig.write_confirmed = write_confirmed;
|
|
@@ -5594,6 +7188,8 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5594
7188
|
nango_action,
|
|
5595
7189
|
proxy_path,
|
|
5596
7190
|
nango_proxy_path,
|
|
7191
|
+
method,
|
|
7192
|
+
http_method,
|
|
5597
7193
|
field_map,
|
|
5598
7194
|
required_fields,
|
|
5599
7195
|
write_confirmed,
|
|
@@ -5601,6 +7197,10 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5601
7197
|
config: normalizedConfig
|
|
5602
7198
|
};
|
|
5603
7199
|
}
|
|
7200
|
+
function normalizeOpsDestinationRequest(destination) {
|
|
7201
|
+
if (!destination || typeof destination !== "object" || Array.isArray(destination)) return destination;
|
|
7202
|
+
return normalizeOpsSinkRequest(destination);
|
|
7203
|
+
}
|
|
5604
7204
|
function normalizeOpsSinkConfigRequest(config) {
|
|
5605
7205
|
const out = { ...config ?? {} };
|
|
5606
7206
|
if (out.connection_id === void 0 && out.connectionId !== void 0) out.connection_id = out.connectionId;
|
|
@@ -5614,6 +7214,8 @@ function normalizeOpsSinkConfigRequest(config) {
|
|
|
5614
7214
|
if (out.nango_action === void 0 && out.nangoAction !== void 0) out.nango_action = out.nangoAction;
|
|
5615
7215
|
if (out.proxy_path === void 0 && out.proxyPath !== void 0) out.proxy_path = out.proxyPath;
|
|
5616
7216
|
if (out.nango_proxy_path === void 0 && out.nangoProxyPath !== void 0) out.nango_proxy_path = out.nangoProxyPath;
|
|
7217
|
+
if (out.http_method === void 0 && out.httpMethod !== void 0) out.http_method = out.httpMethod;
|
|
7218
|
+
if (out.method === void 0 && out.http_method !== void 0) out.method = out.http_method;
|
|
5617
7219
|
if (out.field_map === void 0 && out.fieldMap !== void 0) out.field_map = out.fieldMap;
|
|
5618
7220
|
if (out.required_fields === void 0 && out.requiredFields !== void 0) out.required_fields = out.requiredFields;
|
|
5619
7221
|
if (out.write_confirmed === void 0 && out.writeConfirmed !== void 0) out.write_confirmed = out.writeConfirmed;
|
|
@@ -5687,7 +7289,6 @@ function toSnakeConfig(params) {
|
|
|
5687
7289
|
return {
|
|
5688
7290
|
system_prompt: params.systemPrompt || params.system_prompt || "You are a senior business research analyst. Use multi-model evidence carefully and return concise structured enrichment.",
|
|
5689
7291
|
user_template: params.userTemplate || params.user_template || params.prompt,
|
|
5690
|
-
model: params.model,
|
|
5691
7292
|
temperature: params.temperature,
|
|
5692
7293
|
max_concurrency: params.maxConcurrency || params.max_concurrency,
|
|
5693
7294
|
max_tokens: params.maxTokens || params.max_tokens,
|
|
@@ -5711,13 +7312,10 @@ var Ai = class {
|
|
|
5711
7312
|
/**
|
|
5712
7313
|
* Run Custom AI Enrichment - Multi Model.
|
|
5713
7314
|
*
|
|
5714
|
-
* Uses
|
|
5715
|
-
*
|
|
7315
|
+
* Uses the hosted default model with bounded synthesis, then returns the
|
|
7316
|
+
* requested structured output fields.
|
|
5716
7317
|
*/
|
|
5717
7318
|
async multiModel(params) {
|
|
5718
|
-
if (!params.model) {
|
|
5719
|
-
throw new Error('model is required. Use an OpenRouter id such as "anthropic/claude-sonnet-4" or "google/gemini-2.5-flash".');
|
|
5720
|
-
}
|
|
5721
7319
|
if (!params.prompt && !params.userTemplate && !params.user_template) {
|
|
5722
7320
|
throw new Error("prompt or userTemplate is required.");
|
|
5723
7321
|
}
|
|
@@ -5934,6 +7532,10 @@ var GtmKernel = class {
|
|
|
5934
7532
|
days: options.days,
|
|
5935
7533
|
network_days: options.networkDays,
|
|
5936
7534
|
min_sample_size: options.minSampleSize,
|
|
7535
|
+
holdout_min_sample_size: options.holdoutMinSampleSize,
|
|
7536
|
+
predictive_min_labeled_outcomes: options.predictiveMinLabeledOutcomes,
|
|
7537
|
+
predictive_min_positive_outcomes: options.predictiveMinPositiveOutcomes,
|
|
7538
|
+
predictive_min_memory_sample_size: options.predictiveMinMemorySampleSize,
|
|
5937
7539
|
min_workspace_count: options.minWorkspaceCount,
|
|
5938
7540
|
min_privacy_k: options.minPrivacyK,
|
|
5939
7541
|
include_memory: options.includeMemory,
|
|
@@ -6000,9 +7602,11 @@ var GtmKernel = class {
|
|
|
6000
7602
|
write_routine_outcomes: input.writeRoutineOutcomes
|
|
6001
7603
|
});
|
|
6002
7604
|
}
|
|
6003
|
-
/** Start a background Instantly webhook-events pull and route results into the GTM feedback loop. */
|
|
7605
|
+
/** Start a background Instantly webhook-events or email-history pull and route results into the GTM feedback loop. */
|
|
6004
7606
|
async pullInstantlyFeedback(input) {
|
|
6005
7607
|
return this.callMcp("gtm_instantly_feedback_pull", {
|
|
7608
|
+
source: input.source,
|
|
7609
|
+
instantly_profile: input.instantlyProfile,
|
|
6006
7610
|
campaign_id: input.campaignId,
|
|
6007
7611
|
campaign_build_id: input.campaignBuildId,
|
|
6008
7612
|
provider_link_id: input.providerLinkId,
|
|
@@ -6014,6 +7618,9 @@ var GtmKernel = class {
|
|
|
6014
7618
|
to: input.to,
|
|
6015
7619
|
limit: input.limit,
|
|
6016
7620
|
max_pages: input.maxPages,
|
|
7621
|
+
email_type: input.emailType,
|
|
7622
|
+
mode: input.mode,
|
|
7623
|
+
sort_order: input.sortOrder,
|
|
6017
7624
|
create_memory: input.createMemory,
|
|
6018
7625
|
write_routine_outcomes: input.writeRoutineOutcomes,
|
|
6019
7626
|
dry_run: input.dryRun,
|
|
@@ -6143,6 +7750,7 @@ var GtmKernel = class {
|
|
|
6143
7750
|
days: input.days,
|
|
6144
7751
|
network_days: input.networkDays,
|
|
6145
7752
|
min_sample_size: input.minSampleSize,
|
|
7753
|
+
holdout_min_sample_size: input.holdoutMinSampleSize,
|
|
6146
7754
|
min_workspace_count: input.minWorkspaceCount,
|
|
6147
7755
|
min_privacy_k: input.minPrivacyK,
|
|
6148
7756
|
include_memory: input.includeMemory,
|
|
@@ -6163,6 +7771,7 @@ var GtmKernel = class {
|
|
|
6163
7771
|
days: input.days,
|
|
6164
7772
|
network_days: input.networkDays,
|
|
6165
7773
|
min_sample_size: input.minSampleSize,
|
|
7774
|
+
holdout_min_sample_size: input.holdoutMinSampleSize,
|
|
6166
7775
|
min_workspace_count: input.minWorkspaceCount,
|
|
6167
7776
|
min_privacy_k: input.minPrivacyK,
|
|
6168
7777
|
include_memory: input.includeMemory,
|
|
@@ -6287,6 +7896,29 @@ var GtmKernel = class {
|
|
|
6287
7896
|
include_details: options.includeDetails
|
|
6288
7897
|
});
|
|
6289
7898
|
}
|
|
7899
|
+
/** Search the Agency Autopilot safe-action catalog for agency-style lead lists, Clay tables, and GTM motions. */
|
|
7900
|
+
async agencyAutopilotCapabilityCatalog(options = {}) {
|
|
7901
|
+
return this.callMcp("gtm_agency_autopilot_capability_catalog", {
|
|
7902
|
+
query: options.query,
|
|
7903
|
+
family: options.family,
|
|
7904
|
+
phase: options.phase,
|
|
7905
|
+
account_label: options.accountLabel,
|
|
7906
|
+
workspace_label: options.workspaceLabel,
|
|
7907
|
+
target_count: options.targetCount,
|
|
7908
|
+
limit: options.limit,
|
|
7909
|
+
include_agent_prompts: options.includeAgentPrompts
|
|
7910
|
+
});
|
|
7911
|
+
}
|
|
7912
|
+
/** Search agency operating playbooks Agency Autopilot can use for lead lists, Clay tables, GTM motions, and proof gates. */
|
|
7913
|
+
async agencyAutopilotPlaybookCatalog(options = {}) {
|
|
7914
|
+
return this.callMcp("gtm_agency_autopilot_playbook_catalog", {
|
|
7915
|
+
query: options.query,
|
|
7916
|
+
playbook_slug: options.playbookSlug,
|
|
7917
|
+
outcome_type: options.outcomeType,
|
|
7918
|
+
limit: options.limit,
|
|
7919
|
+
include_required_fields: options.includeRequiredFields
|
|
7920
|
+
});
|
|
7921
|
+
}
|
|
6290
7922
|
/** Build the read-only Memory, Brain, risk, and provider-route runbook needed before planning a campaign. */
|
|
6291
7923
|
async campaignStartContext(input = {}) {
|
|
6292
7924
|
return this.callMcp("gtm_campaign_start_context", {
|
|
@@ -6645,6 +8277,35 @@ var GtmKernel = class {
|
|
|
6645
8277
|
user_display_name: input.userDisplayName
|
|
6646
8278
|
});
|
|
6647
8279
|
}
|
|
8280
|
+
/** Prepare the full Nango provider search, connect, pull/export, Ops, and campaign-route flow. */
|
|
8281
|
+
async prepareNangoIntegrationFlow(input = {}) {
|
|
8282
|
+
return this.callMcp("nango_integration_flow_prepare", {
|
|
8283
|
+
query: input.query,
|
|
8284
|
+
search: input.search,
|
|
8285
|
+
provider_id: input.providerId,
|
|
8286
|
+
provider: input.provider,
|
|
8287
|
+
integration_id: input.integrationId,
|
|
8288
|
+
provider_config_key: input.providerConfigKey,
|
|
8289
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
8290
|
+
connection_id: input.connectionId,
|
|
8291
|
+
nango_connection_id: input.nangoConnectionId,
|
|
8292
|
+
intent: input.intent,
|
|
8293
|
+
action_name: input.actionName,
|
|
8294
|
+
tool_name: input.toolName,
|
|
8295
|
+
proxy_path: input.proxyPath,
|
|
8296
|
+
method: input.method,
|
|
8297
|
+
input: input.input,
|
|
8298
|
+
cadence: input.cadence,
|
|
8299
|
+
field_map: input.fieldMap,
|
|
8300
|
+
required_fields: input.requiredFields,
|
|
8301
|
+
confirm_spend: input.confirmSpend,
|
|
8302
|
+
write_confirmed: input.writeConfirmed,
|
|
8303
|
+
layer: input.layer,
|
|
8304
|
+
campaign_id: input.campaignId,
|
|
8305
|
+
limit: input.limit,
|
|
8306
|
+
include_provider_catalog: input.includeProviderCatalog
|
|
8307
|
+
});
|
|
8308
|
+
}
|
|
6648
8309
|
/** List Nango-backed action tools for a workspace connection without executing them. */
|
|
6649
8310
|
async listNangoTools(options = {}) {
|
|
6650
8311
|
return this.callMcp("nango_mcp_tools_list", {
|
|
@@ -6667,6 +8328,12 @@ var GtmKernel = class {
|
|
|
6667
8328
|
nango_connection_id: input.nangoConnectionId,
|
|
6668
8329
|
action_name: input.actionName,
|
|
6669
8330
|
tool_name: input.toolName,
|
|
8331
|
+
delivery_mode: input.deliveryMode,
|
|
8332
|
+
proxy_path: input.proxyPath,
|
|
8333
|
+
nango_proxy_path: input.nangoProxyPath,
|
|
8334
|
+
method: input.method,
|
|
8335
|
+
http_method: input.httpMethod,
|
|
8336
|
+
proxy_headers: input.proxyHeaders,
|
|
6670
8337
|
input: input.input,
|
|
6671
8338
|
async: input.async,
|
|
6672
8339
|
max_retries: input.maxRetries,
|
|
@@ -6816,6 +8483,7 @@ function compact2(value) {
|
|
|
6816
8483
|
}
|
|
6817
8484
|
|
|
6818
8485
|
// src/index.ts
|
|
8486
|
+
var MCP_TOOL_CACHE_TTL_MS = 3e4;
|
|
6819
8487
|
function inferMcpToolCategory(toolName) {
|
|
6820
8488
|
if (typeof toolName !== "string" || !toolName) return void 0;
|
|
6821
8489
|
if (toolName.startsWith("ops_") || toolName === "get_ops_readiness" || toolName === "get_gtm_ops_readiness" || toolName.startsWith("gtm_") || [
|
|
@@ -6947,6 +8615,21 @@ var Signaliz = class {
|
|
|
6947
8615
|
}
|
|
6948
8616
|
/** List all available MCP tools */
|
|
6949
8617
|
async listTools() {
|
|
8618
|
+
const now = Date.now();
|
|
8619
|
+
if (this.toolListCache && this.toolListCache.expiresAt > now) {
|
|
8620
|
+
return this.toolListCache.promise;
|
|
8621
|
+
}
|
|
8622
|
+
const promise = this.fetchTools().catch((error) => {
|
|
8623
|
+
if (this.toolListCache?.promise === promise) this.toolListCache = void 0;
|
|
8624
|
+
throw error;
|
|
8625
|
+
});
|
|
8626
|
+
this.toolListCache = {
|
|
8627
|
+
expiresAt: now + MCP_TOOL_CACHE_TTL_MS,
|
|
8628
|
+
promise
|
|
8629
|
+
};
|
|
8630
|
+
return promise;
|
|
8631
|
+
}
|
|
8632
|
+
async fetchTools() {
|
|
6950
8633
|
try {
|
|
6951
8634
|
const manifest = await this.client.mcp("tools/call", {
|
|
6952
8635
|
name: "get_tool_manifest",
|
|
@@ -7006,6 +8689,7 @@ var Signaliz = class {
|
|
|
7006
8689
|
createCampaignBuilderAgentRequestTemplate,
|
|
7007
8690
|
createCampaignBuilderApproval,
|
|
7008
8691
|
createCampaignBuilderBuildKit,
|
|
8692
|
+
createCampaignBuilderMemoryKit,
|
|
7009
8693
|
createCampaignBuilderProofReceipt,
|
|
7010
8694
|
createCampaignBuilderReadiness,
|
|
7011
8695
|
createCampaignBuilderToolRoute,
|