@signaliz/sdk 1.0.16 → 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 +113 -10
- package/dist/{chunk-5JNKSMNW.mjs → chunk-ZKE4L57J.mjs} +1568 -115
- package/dist/cli.js +4977 -3173
- package/dist/cli.mjs +209 -23
- package/dist/index.d.mts +2569 -1940
- package/dist/index.d.ts +2569 -1940
- package/dist/index.js +1568 -115
- package/dist/index.mjs +1 -1
- package/dist/mcp-config.js +1568 -115
- package/dist/mcp-config.mjs +1 -1
- package/package.json +1 -1
package/dist/mcp-config.js
CHANGED
|
@@ -243,25 +243,31 @@ var HttpClient = class {
|
|
|
243
243
|
async getToken() {
|
|
244
244
|
if (this.apiKey) return this.apiKey;
|
|
245
245
|
if (this.accessToken) return this.accessToken;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
throw new SignalizError({
|
|
257
|
-
code: "AUTH_FAILED",
|
|
258
|
-
message: "Failed to obtain access token",
|
|
259
|
-
errorType: "auth_expired"
|
|
246
|
+
if (this.accessTokenPromise) return this.accessTokenPromise;
|
|
247
|
+
this.accessTokenPromise = (async () => {
|
|
248
|
+
const res = await fetch("https://api.signaliz.com/token", {
|
|
249
|
+
method: "POST",
|
|
250
|
+
headers: { "Content-Type": "application/json" },
|
|
251
|
+
body: JSON.stringify({
|
|
252
|
+
grant_type: "client_credentials",
|
|
253
|
+
client_id: this.clientId,
|
|
254
|
+
client_secret: this.clientSecret
|
|
255
|
+
})
|
|
260
256
|
});
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
257
|
+
if (!res.ok) {
|
|
258
|
+
throw new SignalizError({
|
|
259
|
+
code: "AUTH_FAILED",
|
|
260
|
+
message: "Failed to obtain access token",
|
|
261
|
+
errorType: "auth_expired"
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
const data = await res.json();
|
|
265
|
+
this.accessToken = data.access_token;
|
|
266
|
+
return this.accessToken;
|
|
267
|
+
})().finally(() => {
|
|
268
|
+
this.accessTokenPromise = void 0;
|
|
269
|
+
});
|
|
270
|
+
return this.accessTokenPromise;
|
|
265
271
|
}
|
|
266
272
|
};
|
|
267
273
|
function sleep(ms) {
|
|
@@ -510,7 +516,6 @@ var Signals = class {
|
|
|
510
516
|
if (params.online !== void 0) args.online = params.online;
|
|
511
517
|
if (params.targetSignalCount) args.target_signal_count = params.targetSignalCount;
|
|
512
518
|
if (params.lookbackDays) args.lookback_days = params.lookbackDays;
|
|
513
|
-
if (params.model) args.model = params.model;
|
|
514
519
|
if (params.enableDeepSearch) args.enable_deep_search = params.enableDeepSearch;
|
|
515
520
|
if (params.enableOutreachIntelligence) args.enable_outreach_intelligence = params.enableOutreachIntelligence;
|
|
516
521
|
if (params.enablePredictiveIntelligence) args.enable_predictive_intelligence = params.enablePredictiveIntelligence;
|
|
@@ -805,6 +810,10 @@ var Campaigns = class {
|
|
|
805
810
|
async artifacts(campaignBuildId) {
|
|
806
811
|
return this.listCampaignBuildArtifacts(campaignBuildId);
|
|
807
812
|
}
|
|
813
|
+
/** Generate fresh signed URLs for a downloadable campaign artifact. */
|
|
814
|
+
async downloadArtifact(campaignBuildId, options) {
|
|
815
|
+
return this.downloadCampaignArtifact(campaignBuildId, options);
|
|
816
|
+
}
|
|
808
817
|
/** Cancel a queued or running build. */
|
|
809
818
|
async cancel(campaignBuildId, reason) {
|
|
810
819
|
return this.cancelCampaignBuild(campaignBuildId, reason);
|
|
@@ -849,12 +858,16 @@ var Campaigns = class {
|
|
|
849
858
|
dryRun: isDryRun,
|
|
850
859
|
requestedTargetCount: data.requested_target_count,
|
|
851
860
|
plannedTargetCount: data.planned_target_count,
|
|
861
|
+
acquisitionMode: data.acquisition_mode,
|
|
862
|
+
acquisitionSource: data.acquisition_source,
|
|
863
|
+
cacheReusePolicy: data.cache_reuse_policy,
|
|
852
864
|
estimatedCredits: data.estimated_credits,
|
|
853
865
|
estimatedDurationSeconds: data.estimated_duration_seconds,
|
|
854
866
|
targetLimitApplied: data.target_limit_applied,
|
|
855
867
|
targetLimitReason: data.target_limit_reason,
|
|
856
868
|
maxSupportedTargetCount: data.max_supported_target_count,
|
|
857
869
|
brainContext: data.brain_context ?? {},
|
|
870
|
+
learningHoldout: data.learning_holdout ?? {},
|
|
858
871
|
providerRoute: mapProviderRoute(data)
|
|
859
872
|
};
|
|
860
873
|
}
|
|
@@ -870,14 +883,24 @@ var Campaigns = class {
|
|
|
870
883
|
});
|
|
871
884
|
return (data.artifacts ?? []).map(mapArtifact);
|
|
872
885
|
}
|
|
886
|
+
async downloadCampaignArtifact(campaignBuildId, options) {
|
|
887
|
+
const args = { campaign_build_id: campaignBuildId };
|
|
888
|
+
if (options?.format) args.format = options.format;
|
|
889
|
+
const data = await this.callMcp("download_campaign_artifact", args);
|
|
890
|
+
return mapArtifactDownloadResult(data);
|
|
891
|
+
}
|
|
873
892
|
async getCampaignBuildRows(campaignBuildId, options) {
|
|
874
893
|
const args = { campaign_build_id: campaignBuildId };
|
|
875
894
|
if (options?.limit) args.page_size = options.limit;
|
|
876
895
|
if (options?.cursor) args.cursor = options.cursor;
|
|
896
|
+
if (options?.includeData !== void 0) args.include_data = options.includeData;
|
|
897
|
+
if (options?.includeRaw !== void 0) args.include_raw = options.includeRaw;
|
|
877
898
|
const filters = {};
|
|
878
899
|
if (options?.segment) filters.segment = options.segment;
|
|
879
900
|
if (options?.rowStatus) filters.row_status = options.rowStatus;
|
|
880
901
|
if (options?.qualified !== void 0) filters.qualified = options.qualified;
|
|
902
|
+
if (options?.cached !== void 0) filters.cached = options.cached;
|
|
903
|
+
if (options?.exportReady !== void 0) filters.export_ready = options.exportReady;
|
|
881
904
|
if (Object.keys(filters).length > 0) args.filters = filters;
|
|
882
905
|
const data = await this.callMcp("get_campaign_build_rows", args);
|
|
883
906
|
return {
|
|
@@ -902,6 +925,7 @@ var Campaigns = class {
|
|
|
902
925
|
};
|
|
903
926
|
if (options?.destinationId) args.destination_id = options.destinationId;
|
|
904
927
|
if (options?.destinationConfig) args.destination_config = options.destinationConfig;
|
|
928
|
+
if (options?.allowPartialDelivery === true) args.allow_partial_delivery = true;
|
|
905
929
|
const data = await this.callMcp("approve_campaign_delivery", args);
|
|
906
930
|
return {
|
|
907
931
|
campaignBuildId: data.campaign_build_id,
|
|
@@ -910,7 +934,10 @@ var Campaigns = class {
|
|
|
910
934
|
message: data.message ?? "",
|
|
911
935
|
deliveryId: data.delivery_id,
|
|
912
936
|
deliveryIds: data.delivery_ids,
|
|
913
|
-
approvedCount: data.approved_count
|
|
937
|
+
approvedCount: data.approved_count,
|
|
938
|
+
partialDelivery: data.partial_delivery,
|
|
939
|
+
effectiveTargetCount: data.effective_target_count,
|
|
940
|
+
requestedTargetCount: data.requested_target_count
|
|
914
941
|
};
|
|
915
942
|
}
|
|
916
943
|
async cancelCampaignBuild(campaignBuildId, reason) {
|
|
@@ -963,17 +990,50 @@ function mapStatus(data) {
|
|
|
963
990
|
warnings: diagnosticMessages(data.warnings),
|
|
964
991
|
errors: diagnosticMessages(data.errors),
|
|
965
992
|
artifactCount: data.artifact_count ?? 0,
|
|
993
|
+
artifactDownloads: Array.isArray(data.artifact_downloads) ? data.artifact_downloads.map(mapArtifactDownload) : [],
|
|
994
|
+
customerRowCounts: mapCustomerRowCounts(data.customer_row_counts),
|
|
995
|
+
phaseAttemptTotals: recordOrNull(data.phase_attempt_totals) ?? void 0,
|
|
966
996
|
providerRoute: mapProviderRoute(data),
|
|
967
997
|
triggerRunId: typeof data.trigger_run_id === "string" ? data.trigger_run_id : null,
|
|
968
998
|
staleRunningPhase: data.stale_running_phase === true,
|
|
969
999
|
phaseAgeSeconds: numberOrNull(data.phase_age_seconds),
|
|
970
1000
|
diagnostics: recordOrNull(data.diagnostics) ?? {},
|
|
971
1001
|
nextAction: formatNextAction(data.next_action),
|
|
1002
|
+
approvalAction: formatNextAction(data.approval_action),
|
|
972
1003
|
createdAt: data.created_at,
|
|
973
1004
|
updatedAt: data.updated_at,
|
|
974
1005
|
completedAt: data.completed_at
|
|
975
1006
|
};
|
|
976
1007
|
}
|
|
1008
|
+
function mapCustomerRowCounts(value) {
|
|
1009
|
+
const record = recordOrNull(value);
|
|
1010
|
+
if (!record) return void 0;
|
|
1011
|
+
return {
|
|
1012
|
+
requestedTarget: numberOrNull(record.requested_target),
|
|
1013
|
+
acquiredRows: numberOrNull(record.acquired_rows) ?? void 0,
|
|
1014
|
+
acceptedRows: numberOrNull(record.accepted_rows) ?? void 0,
|
|
1015
|
+
usableRows: numberOrNull(record.usable_rows) ?? void 0,
|
|
1016
|
+
copiedRows: numberOrNull(record.copied_rows) ?? void 0,
|
|
1017
|
+
approvalReadyRows: numberOrNull(record.approval_ready_rows) ?? void 0,
|
|
1018
|
+
qaReadyRows: numberOrNull(record.qa_ready_rows) ?? void 0,
|
|
1019
|
+
deliveredRows: numberOrNull(record.delivered_rows) ?? void 0,
|
|
1020
|
+
disqualifiedRows: numberOrNull(record.disqualified_rows) ?? void 0,
|
|
1021
|
+
reviewableRows: numberOrNull(record.reviewable_rows) ?? void 0,
|
|
1022
|
+
rowFailures: numberOrNull(record.row_failures) ?? void 0,
|
|
1023
|
+
acceptedShortfall: numberOrNull(record.accepted_shortfall),
|
|
1024
|
+
usableShortfall: numberOrNull(record.usable_shortfall),
|
|
1025
|
+
qaReadyShortfall: numberOrNull(record.qa_ready_shortfall),
|
|
1026
|
+
deliveryShortfall: numberOrNull(record.delivery_shortfall),
|
|
1027
|
+
fillRatio: numberOrNull(record.fill_ratio),
|
|
1028
|
+
qaReadyFillRatio: numberOrNull(record.qa_ready_fill_ratio),
|
|
1029
|
+
deliveredFillRatio: numberOrNull(record.delivered_fill_ratio),
|
|
1030
|
+
terminalReason: typeof record.terminal_reason === "string" ? record.terminal_reason : null,
|
|
1031
|
+
acceptedShortfallReason: typeof record.accepted_shortfall_reason === "string" ? record.accepted_shortfall_reason : null,
|
|
1032
|
+
usableShortfallReason: typeof record.usable_shortfall_reason === "string" ? record.usable_shortfall_reason : null,
|
|
1033
|
+
qaReadyShortfallReason: typeof record.qa_ready_shortfall_reason === "string" ? record.qa_ready_shortfall_reason : null,
|
|
1034
|
+
deliveryShortfallReason: typeof record.delivery_shortfall_reason === "string" ? record.delivery_shortfall_reason : null
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
977
1037
|
function mapProviderRoute(data) {
|
|
978
1038
|
const brainContext = recordOrNull(data?.brain_context);
|
|
979
1039
|
const plan = recordOrNull(data?.provider_route_plan) ?? recordOrNull(brainContext?.provider_route_plan);
|
|
@@ -1051,13 +1111,56 @@ function mapArtifact(a) {
|
|
|
1051
1111
|
artifactType: a.artifact_type,
|
|
1052
1112
|
destination: a.destination,
|
|
1053
1113
|
storagePath: a.storage_path,
|
|
1114
|
+
format: a.format ?? null,
|
|
1054
1115
|
signedUrl: a.signed_url,
|
|
1116
|
+
downloadUrl: a.download_url ?? null,
|
|
1117
|
+
manifestUrl: a.manifest_url ?? null,
|
|
1118
|
+
expiresAt: a.expires_at ?? null,
|
|
1055
1119
|
rowCount: a.row_count ?? 0,
|
|
1056
1120
|
checksum: a.checksum,
|
|
1057
1121
|
metadata: a.metadata ?? {},
|
|
1058
1122
|
createdAt: a.created_at
|
|
1059
1123
|
};
|
|
1060
1124
|
}
|
|
1125
|
+
function mapArtifactDownload(data) {
|
|
1126
|
+
return {
|
|
1127
|
+
id: data.id,
|
|
1128
|
+
artifactType: data.artifact_type ?? null,
|
|
1129
|
+
format: data.format ?? null,
|
|
1130
|
+
rowCount: data.row_count ?? 0,
|
|
1131
|
+
signedUrl: data.signed_url ?? null,
|
|
1132
|
+
downloadUrl: data.download_url ?? null,
|
|
1133
|
+
manifestUrl: data.manifest_url ?? null,
|
|
1134
|
+
expiresAt: data.expires_at ?? null
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
function mapArtifactDownloadResult(data) {
|
|
1138
|
+
return {
|
|
1139
|
+
campaignBuildId: data.campaign_build_id,
|
|
1140
|
+
artifactId: data.artifact_id,
|
|
1141
|
+
format: data.format,
|
|
1142
|
+
rowCount: data.row_count ?? 0,
|
|
1143
|
+
byteSize: numberOrNull(data.byte_size),
|
|
1144
|
+
partCount: data.part_count ?? 0,
|
|
1145
|
+
checksum: data.checksum ?? null,
|
|
1146
|
+
signedUrl: data.signed_url ?? null,
|
|
1147
|
+
downloadUrl: data.download_url ?? null,
|
|
1148
|
+
manifestUrl: data.manifest_url ?? null,
|
|
1149
|
+
expiresAt: data.expires_at ?? null,
|
|
1150
|
+
parts: Array.isArray(data.parts) ? data.parts.map(mapArtifactDownloadPart) : [],
|
|
1151
|
+
downloadCommands: recordOrNull(data.download_commands) ?? {},
|
|
1152
|
+
expiresInSeconds: numberOrNull(data.expires_in_seconds)
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
function mapArtifactDownloadPart(data) {
|
|
1156
|
+
return {
|
|
1157
|
+
partIndex: data.part_index ?? 0,
|
|
1158
|
+
rowCount: data.row_count ?? 0,
|
|
1159
|
+
byteSize: numberOrNull(data.byte_size),
|
|
1160
|
+
checksum: data.checksum ?? null,
|
|
1161
|
+
signedUrl: data.signed_url ?? null
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1061
1164
|
function mapScope(data) {
|
|
1062
1165
|
return {
|
|
1063
1166
|
campaignScopeId: data.campaign_scope_id,
|
|
@@ -1111,8 +1214,29 @@ function buildArgs(request) {
|
|
|
1111
1214
|
if (request.allowDownscale !== void 0) args.allow_downscale = request.allowDownscale;
|
|
1112
1215
|
if (request.confirmSpend !== void 0) args.confirm_spend = request.confirmSpend;
|
|
1113
1216
|
if (request.dedupKeys) args.dedup_keys = request.dedupKeys;
|
|
1217
|
+
if (request.acquisitionMode) args.acquisition_mode = request.acquisitionMode;
|
|
1218
|
+
if (request.cacheReusePolicy) {
|
|
1219
|
+
args.cache_reuse_policy = {
|
|
1220
|
+
allow_verified_cache: request.cacheReusePolicy.allowVerifiedCache,
|
|
1221
|
+
suppress_prior_campaign_ids: request.cacheReusePolicy.suppressPriorCampaignIds,
|
|
1222
|
+
suppress_prior_list_ids: request.cacheReusePolicy.suppressPriorListIds,
|
|
1223
|
+
uniqueness: request.cacheReusePolicy.uniqueness,
|
|
1224
|
+
require_usage_metadata: request.cacheReusePolicy.requireUsageMetadata
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1114
1227
|
if (request.brainPreflight) args.brain_preflight = request.brainPreflight;
|
|
1115
1228
|
if (request.brainDefaults) args.brain_defaults = request.brainDefaults;
|
|
1229
|
+
if (request.learningHoldout) {
|
|
1230
|
+
args.learning_holdout = {
|
|
1231
|
+
enabled: request.learningHoldout.enabled,
|
|
1232
|
+
control_percentage: request.learningHoldout.controlPercentage,
|
|
1233
|
+
min_control_size: request.learningHoldout.minControlSize,
|
|
1234
|
+
experiment_key: request.learningHoldout.experimentKey,
|
|
1235
|
+
source_campaign_id: request.learningHoldout.sourceCampaignId,
|
|
1236
|
+
primary_metric: request.learningHoldout.primaryMetric
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
if (request.campaignStrategyContext) args.campaign_strategy_context = request.campaignStrategyContext;
|
|
1116
1240
|
if (request.deliveryRisk) args.delivery_risk = request.deliveryRisk;
|
|
1117
1241
|
if (request.icp) {
|
|
1118
1242
|
args.icp = {
|
|
@@ -1154,7 +1278,17 @@ function buildArgs(request) {
|
|
|
1154
1278
|
max_body_words: request.copy.maxBodyWords,
|
|
1155
1279
|
sender_context: request.copy.senderContext,
|
|
1156
1280
|
offer_context: request.copy.offerContext,
|
|
1157
|
-
model: request.copy.model
|
|
1281
|
+
model: request.copy.model,
|
|
1282
|
+
style_source: request.copy.styleSource ? {
|
|
1283
|
+
sample_text: request.copy.styleSource.sampleText,
|
|
1284
|
+
campaign_ids: request.copy.styleSource.campaignIds,
|
|
1285
|
+
artifact_ids: request.copy.styleSource.artifactIds
|
|
1286
|
+
} : void 0,
|
|
1287
|
+
sequence_steps: request.copy.sequenceSteps,
|
|
1288
|
+
copy_schema: request.copy.copySchema,
|
|
1289
|
+
banned_phrases: request.copy.bannedPhrases,
|
|
1290
|
+
approval_required: request.copy.approvalRequired,
|
|
1291
|
+
quality_tier: request.copy.qualityTier
|
|
1158
1292
|
};
|
|
1159
1293
|
}
|
|
1160
1294
|
if (request.delivery) {
|
|
@@ -1217,6 +1351,8 @@ var DEFAULT_SIGNALIZ_CAMPAIGN_BUILDER_DEFAULTS = {
|
|
|
1217
1351
|
}
|
|
1218
1352
|
};
|
|
1219
1353
|
var DEFAULT_CAMPAIGN_BUILDER_BUILT_INS = [
|
|
1354
|
+
"company_discovery",
|
|
1355
|
+
"people_discovery",
|
|
1220
1356
|
"lead_generation",
|
|
1221
1357
|
"email_finding",
|
|
1222
1358
|
"email_verification",
|
|
@@ -1225,6 +1361,8 @@ var DEFAULT_CAMPAIGN_BUILDER_BUILT_INS = [
|
|
|
1225
1361
|
var CAMPAIGN_BUILDER_BUILT_IN_ROUTE_IDS = {
|
|
1226
1362
|
lead_generation: "signaliz-lead-generation",
|
|
1227
1363
|
local_leads: "signaliz-local-leads",
|
|
1364
|
+
company_discovery: "signaliz-company-discovery",
|
|
1365
|
+
people_discovery: "signaliz-people-discovery",
|
|
1228
1366
|
email_finding: "signaliz-email-finding",
|
|
1229
1367
|
email_verification: "signaliz-email-verification",
|
|
1230
1368
|
signals: "signaliz-signals"
|
|
@@ -1242,8 +1380,8 @@ var CAMPAIGN_BUILDER_OPERATING_PLAYBOOKS = [
|
|
|
1242
1380
|
slug: "cache-first-large-list",
|
|
1243
1381
|
label: "Cache-First Large List",
|
|
1244
1382
|
whenToUse: [
|
|
1245
|
-
"The
|
|
1246
|
-
"The deliverable is a
|
|
1383
|
+
"The operator explicitly references a previous campaign, prior list, seed list, or suppression baseline.",
|
|
1384
|
+
"The deliverable is a top-up, continuation, or backfill where prior campaign context should guide reuse."
|
|
1247
1385
|
],
|
|
1248
1386
|
sequence: [
|
|
1249
1387
|
"Inventory reusable cache before paid sourcing.",
|
|
@@ -1449,7 +1587,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1449
1587
|
],
|
|
1450
1588
|
requireVerifiedEmail: true
|
|
1451
1589
|
},
|
|
1452
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1590
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1453
1591
|
preferredProviders: ["signaliz_native"],
|
|
1454
1592
|
memoryQueries: [{
|
|
1455
1593
|
query: "industrial OT net-new prior email suppression verified manufacturing embedded systems field service cyber resilience business continuity",
|
|
@@ -1523,7 +1661,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1523
1661
|
],
|
|
1524
1662
|
requireVerifiedEmail: true
|
|
1525
1663
|
},
|
|
1526
|
-
builtIns: ["lead_generation", "local_leads", "email_finding", "email_verification", "signals"],
|
|
1664
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "local_leads", "email_finding", "email_verification", "signals"],
|
|
1527
1665
|
preferredProviders: ["signaliz_native", "octave", "clay_webhook", "apify"],
|
|
1528
1666
|
memoryQueries: [{
|
|
1529
1667
|
query: "mature non-medical home care agencies billable hours franchise caregiver recruiting proof gate qualification export approval",
|
|
@@ -1589,7 +1727,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1589
1727
|
exclusions: ["enterprise holding company", "staffing", "recruiting", "software-only vendor", "freelancer-only profile"],
|
|
1590
1728
|
requireVerifiedEmail: true
|
|
1591
1729
|
},
|
|
1592
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1730
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1593
1731
|
preferredProviders: ["signaliz_native", "octave"],
|
|
1594
1732
|
memoryQueries: [{
|
|
1595
1733
|
query: "agency founder owner CEO marketing services suppression domain pool email verification final approval gate",
|
|
@@ -1671,7 +1809,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1671
1809
|
],
|
|
1672
1810
|
requireVerifiedEmail: true
|
|
1673
1811
|
},
|
|
1674
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1812
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1675
1813
|
preferredProviders: ["signaliz_native", "octave"],
|
|
1676
1814
|
memoryQueries: [{
|
|
1677
1815
|
query: "cloud hosting infrastructure VMware Broadcom qualification verified email persona trigger SKU mapping",
|
|
@@ -1704,25 +1842,21 @@ var CampaignBuilderAgent = class {
|
|
|
1704
1842
|
async createPlan(request, options = {}) {
|
|
1705
1843
|
const resolvedRequest = applyCampaignBuilderStrategyTemplate(request);
|
|
1706
1844
|
const warnings = [];
|
|
1707
|
-
const workspaceContext =
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1845
|
+
const [workspaceContext, scopeResult] = await Promise.all([
|
|
1846
|
+
resolvedRequest.workspaceContext ? Promise.resolve(resolvedRequest.workspaceContext) : this.getWorkspaceContext(warnings),
|
|
1847
|
+
options.scopeCampaign === false ? Promise.resolve(void 0) : this.scopeCampaign(resolvedRequest, warnings),
|
|
1848
|
+
options.discoverCapabilities === false ? Promise.resolve(void 0) : this.discoverPlannedRoutes(resolvedRequest, warnings)
|
|
1849
|
+
]);
|
|
1712
1850
|
const plan = createCampaignBuilderAgentPlan(resolvedRequest, {
|
|
1713
1851
|
workspaceContext,
|
|
1714
1852
|
scopeBuildArgs: asRecord(scopeResult?.build_campaign_args ?? scopeResult?.buildCampaignArgs),
|
|
1715
1853
|
warnings
|
|
1716
1854
|
});
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
}
|
|
1723
|
-
if (options.includeDeliveryRisk !== false) {
|
|
1724
|
-
await this.attachDeliveryRiskPreflight(plan, warnings);
|
|
1725
|
-
}
|
|
1855
|
+
await Promise.all([
|
|
1856
|
+
options.includeStrategyMemoryStatus === false ? Promise.resolve() : this.attachStrategyMemoryStatus(plan, warnings),
|
|
1857
|
+
options.includeKernelPlan === false ? Promise.resolve() : this.attachKernelCampaignBuildPlan(plan, warnings),
|
|
1858
|
+
options.includeDeliveryRisk === false ? Promise.resolve() : this.attachDeliveryRiskPreflight(plan, warnings)
|
|
1859
|
+
]);
|
|
1726
1860
|
return plan;
|
|
1727
1861
|
}
|
|
1728
1862
|
async readiness(request, options = {}) {
|
|
@@ -1770,6 +1904,7 @@ var CampaignBuilderAgent = class {
|
|
|
1770
1904
|
},
|
|
1771
1905
|
brain_defaults: plan.buildRequest.brainDefaults,
|
|
1772
1906
|
brain_preflight: plan.buildRequest.brainPreflight,
|
|
1907
|
+
campaign_strategy_context: plan.buildRequest.campaignStrategyContext,
|
|
1773
1908
|
delivery_risk_preflight: plan.buildRequest.deliveryRisk,
|
|
1774
1909
|
delivery_risk: plan.buildRequest.deliveryRisk
|
|
1775
1910
|
}),
|
|
@@ -1891,7 +2026,8 @@ var CampaignBuilderAgent = class {
|
|
|
1891
2026
|
const destinationType = options.deliveryDestinationType ?? plan.buildRequest.delivery?.destinationType ?? "json";
|
|
1892
2027
|
result.deliveryApproval = await this.approveCampaignDelivery(campaignBuildId, destinationType, {
|
|
1893
2028
|
destinationId: options.deliveryDestinationId,
|
|
1894
|
-
destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig
|
|
2029
|
+
destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig,
|
|
2030
|
+
allowPartialDelivery: options.allowPartialDelivery
|
|
1895
2031
|
});
|
|
1896
2032
|
finalStatus = await this.waitForCampaignBuildStatus(
|
|
1897
2033
|
campaignBuildId,
|
|
@@ -1914,8 +2050,12 @@ var CampaignBuilderAgent = class {
|
|
|
1914
2050
|
const args = compact({
|
|
1915
2051
|
campaign_build_id: campaignBuildId,
|
|
1916
2052
|
page_size: options.limit,
|
|
1917
|
-
cursor: options.cursor
|
|
2053
|
+
cursor: options.cursor,
|
|
2054
|
+
include_data: options.includeData,
|
|
2055
|
+
include_raw: options.includeRaw
|
|
1918
2056
|
});
|
|
2057
|
+
if (options.cached !== void 0) filters.cached = options.cached;
|
|
2058
|
+
if (options.exportReady !== void 0) filters.export_ready = options.exportReady;
|
|
1919
2059
|
if (Object.keys(filters).length > 0) args.filters = filters;
|
|
1920
2060
|
const data = await this.callMcp("get_campaign_build_rows", args);
|
|
1921
2061
|
return mapAgentCampaignRowsResult(data);
|
|
@@ -1930,12 +2070,14 @@ var CampaignBuilderAgent = class {
|
|
|
1930
2070
|
return this.approveCampaignDelivery(campaignBuildId, destinationType, options);
|
|
1931
2071
|
}
|
|
1932
2072
|
async reviewBuild(campaignBuildId, options = {}) {
|
|
1933
|
-
const status = await
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
2073
|
+
const [status, rows, artifacts] = await Promise.all([
|
|
2074
|
+
this.getBuildStatus(campaignBuildId),
|
|
2075
|
+
this.getBuildRows(campaignBuildId, {
|
|
2076
|
+
...options,
|
|
2077
|
+
limit: options.limit ?? 100
|
|
2078
|
+
}),
|
|
2079
|
+
this.listBuildArtifacts(campaignBuildId)
|
|
2080
|
+
]);
|
|
1939
2081
|
return createCampaignBuilderBuildReview(status, rows, artifacts);
|
|
1940
2082
|
}
|
|
1941
2083
|
async getCampaignBuildStatus(campaignBuildId) {
|
|
@@ -1963,7 +2105,8 @@ var CampaignBuilderAgent = class {
|
|
|
1963
2105
|
campaign_build_id: campaignBuildId,
|
|
1964
2106
|
destination_type: destinationType,
|
|
1965
2107
|
destination_id: options?.destinationId,
|
|
1966
|
-
destination_config: options?.destinationConfig
|
|
2108
|
+
destination_config: options?.destinationConfig,
|
|
2109
|
+
allow_partial_delivery: options?.allowPartialDelivery === true ? true : void 0
|
|
1967
2110
|
});
|
|
1968
2111
|
const data = await this.callMcp("approve_campaign_delivery", args);
|
|
1969
2112
|
return {
|
|
@@ -1973,7 +2116,10 @@ var CampaignBuilderAgent = class {
|
|
|
1973
2116
|
message: data.message ?? "",
|
|
1974
2117
|
deliveryId: data.delivery_id,
|
|
1975
2118
|
deliveryIds: data.delivery_ids,
|
|
1976
|
-
approvedCount: data.approved_count
|
|
2119
|
+
approvedCount: data.approved_count,
|
|
2120
|
+
partialDelivery: data.partial_delivery,
|
|
2121
|
+
effectiveTargetCount: data.effective_target_count,
|
|
2122
|
+
requestedTargetCount: data.requested_target_count
|
|
1977
2123
|
};
|
|
1978
2124
|
}
|
|
1979
2125
|
async getWorkspaceContext(warnings) {
|
|
@@ -2009,15 +2155,19 @@ var CampaignBuilderAgent = class {
|
|
|
2009
2155
|
const providers = new Set(
|
|
2010
2156
|
[...request.integrations ?? [], ...routesFromCustomerTools(request.customerTools ?? [])].filter((route) => route.provider !== "signaliz").map((route) => route.provider)
|
|
2011
2157
|
);
|
|
2012
|
-
|
|
2158
|
+
const warningsByProvider = await Promise.all(Array.from(providers, async (provider) => {
|
|
2013
2159
|
try {
|
|
2014
2160
|
await this.callMcp("discover_capabilities", {
|
|
2015
2161
|
query: `campaign builder ${provider} ${request.goal}`,
|
|
2016
2162
|
category: "campaign"
|
|
2017
2163
|
});
|
|
2164
|
+
return void 0;
|
|
2018
2165
|
} catch (error) {
|
|
2019
|
-
|
|
2166
|
+
return `Capability discovery for ${provider} failed: ${errorMessage(error)}`;
|
|
2020
2167
|
}
|
|
2168
|
+
}));
|
|
2169
|
+
for (const warning of warningsByProvider) {
|
|
2170
|
+
if (warning) warnings.push(warning);
|
|
2021
2171
|
}
|
|
2022
2172
|
}
|
|
2023
2173
|
async attachStrategyMemoryStatus(plan, warnings) {
|
|
@@ -2041,8 +2191,24 @@ var CampaignBuilderAgent = class {
|
|
|
2041
2191
|
const kernelPlan = await this.callMcp("gtm_campaign_build_plan", asRecord(plannerStep.arguments));
|
|
2042
2192
|
plan.kernelPlan = asRecord(kernelPlan);
|
|
2043
2193
|
const brainDefaults = asRecord(plan.kernelPlan.brain_defaults ?? plan.kernelPlan.brainDefaults);
|
|
2194
|
+
const corpusContext = asRecord(plan.kernelPlan.corpus_context ?? plan.kernelPlan.corpusContext);
|
|
2195
|
+
const campaignStrategyContext = asRecord(plan.kernelPlan.campaign_strategy_context ?? plan.kernelPlan.campaignStrategyContext);
|
|
2196
|
+
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) : [];
|
|
2044
2197
|
if (Object.keys(brainDefaults).length > 0 && Object.keys(asRecord(plan.buildRequest.brainDefaults)).length === 0) {
|
|
2045
2198
|
plan.buildRequest.brainDefaults = brainDefaults;
|
|
2199
|
+
}
|
|
2200
|
+
if (Object.keys(campaignStrategyContext).length > 0) {
|
|
2201
|
+
plan.buildRequest.campaignStrategyContext = campaignStrategyContext;
|
|
2202
|
+
}
|
|
2203
|
+
if (Object.keys(corpusContext).length > 0 || memoryExamples.length > 0 || Object.keys(brainDefaults).length > 0 || Object.keys(campaignStrategyContext).length > 0) {
|
|
2204
|
+
plan.buildRequest.brainPreflight = compact({
|
|
2205
|
+
...asRecord(plan.buildRequest.brainPreflight),
|
|
2206
|
+
corpus_context: Object.keys(corpusContext).length > 0 ? corpusContext : void 0,
|
|
2207
|
+
memory_examples: memoryExamples.length > 0 ? memoryExamples : void 0,
|
|
2208
|
+
brain_defaults: Object.keys(brainDefaults).length > 0 ? brainDefaults : void 0,
|
|
2209
|
+
campaign_strategy_context: Object.keys(campaignStrategyContext).length > 0 ? campaignStrategyContext : void 0
|
|
2210
|
+
});
|
|
2211
|
+
plan.brainPreflight = asRecord(plan.buildRequest.brainPreflight);
|
|
2046
2212
|
refreshBuildStepArguments(plan);
|
|
2047
2213
|
}
|
|
2048
2214
|
} catch (error) {
|
|
@@ -2223,6 +2389,9 @@ function createCampaignBuilderProofReceipt(plan, result) {
|
|
|
2223
2389
|
campaign_build_id: dryRunResult.campaignBuildId ?? dryRunResult.campaign_build_id ?? null
|
|
2224
2390
|
}
|
|
2225
2391
|
];
|
|
2392
|
+
const learnBackPlan = summarizeCampaignBuilderProofLearnBack(
|
|
2393
|
+
asRecord(asRecord(plan.buildRequest.brainPreflight).learn_back_plan ?? asRecord(plan.brainPreflight).learn_back_plan)
|
|
2394
|
+
);
|
|
2226
2395
|
return {
|
|
2227
2396
|
receipt_version: "campaign-agent-proof.v1",
|
|
2228
2397
|
source: "signaliz.campaignBuilderAgent.proof",
|
|
@@ -2245,6 +2414,7 @@ function createCampaignBuilderProofReceipt(plan, result) {
|
|
|
2245
2414
|
gates,
|
|
2246
2415
|
strategy_memory_status: summarizeCampaignBuilderProofStrategyMemory(strategyMemory),
|
|
2247
2416
|
dry_run_result: summarizeCampaignBuilderProofDryRun(dryRunResult),
|
|
2417
|
+
learn_back_plan: learnBackPlan,
|
|
2248
2418
|
recommended_next_actions: [
|
|
2249
2419
|
"Review the plan, approvals, and dry-run result.",
|
|
2250
2420
|
"Use campaign-agent commit-plan --confirm-write only after review.",
|
|
@@ -2794,6 +2964,13 @@ function campaignBuilderMemoryKitSdkExample(request, seedManifestFile) {
|
|
|
2794
2964
|
function campaignBuilderMemoryKitSource(source) {
|
|
2795
2965
|
const normalized = normalizeTemplateKey(source || "agency");
|
|
2796
2966
|
const catalog = {
|
|
2967
|
+
northStar: {
|
|
2968
|
+
id: "north_star_campaign_builder",
|
|
2969
|
+
label: "North Star campaign-builder acceptance patterns",
|
|
2970
|
+
seed_source: "north-star",
|
|
2971
|
+
scope: "redacted_acceptance_seed_packs",
|
|
2972
|
+
privacy: "redacted aggregate counts, QA gates, and fixture shape only"
|
|
2973
|
+
},
|
|
2797
2974
|
agency: {
|
|
2798
2975
|
id: "agency_campaign_builder",
|
|
2799
2976
|
label: "Agency campaign-builder strategy patterns",
|
|
@@ -2819,6 +2996,10 @@ function campaignBuilderMemoryKitSource(source) {
|
|
|
2819
2996
|
const sourceMap = {
|
|
2820
2997
|
agency: "agency",
|
|
2821
2998
|
"campaign-builder": "agency",
|
|
2999
|
+
"north-star": "northStar",
|
|
3000
|
+
northstar: "northStar",
|
|
3001
|
+
"campaign-builder-north-star": "northStar",
|
|
3002
|
+
acceptance: "northStar",
|
|
2822
3003
|
"strategy-memory": "agency",
|
|
2823
3004
|
"workflow-patterns": "workflow",
|
|
2824
3005
|
workflow: "workflow",
|
|
@@ -2834,13 +3015,13 @@ function campaignBuilderMemoryKitSource(source) {
|
|
|
2834
3015
|
return {
|
|
2835
3016
|
seedSource: "all",
|
|
2836
3017
|
verifyScript: null,
|
|
2837
|
-
memorySources: [catalog.agency, catalog.workflow, catalog.feedback]
|
|
3018
|
+
memorySources: [catalog.northStar, catalog.agency, catalog.workflow, catalog.feedback]
|
|
2838
3019
|
};
|
|
2839
3020
|
}
|
|
2840
3021
|
const item = catalog[selected];
|
|
2841
3022
|
return {
|
|
2842
3023
|
seedSource: item.seed_source,
|
|
2843
|
-
verifyScript: 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,
|
|
3024
|
+
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,
|
|
2844
3025
|
memorySources: [item]
|
|
2845
3026
|
};
|
|
2846
3027
|
}
|
|
@@ -3020,11 +3201,11 @@ function builtInRoutesFor(request) {
|
|
|
3020
3201
|
routes.push({
|
|
3021
3202
|
id: "signaliz-lead-generation",
|
|
3022
3203
|
layer: "source",
|
|
3023
|
-
|
|
3204
|
+
gtmLayer: "lead_generation",
|
|
3024
3205
|
provider: "signaliz",
|
|
3025
3206
|
mode: "required",
|
|
3026
3207
|
toolName: "generate_leads",
|
|
3027
|
-
rationale: "
|
|
3208
|
+
rationale: "Inventory verified cache first, then use Signaliz fresh workspace acquisition for the remaining approved gap."
|
|
3028
3209
|
});
|
|
3029
3210
|
}
|
|
3030
3211
|
if (builtIns.has("local_leads")) {
|
|
@@ -3038,6 +3219,28 @@ function builtInRoutesFor(request) {
|
|
|
3038
3219
|
rationale: "Use Signaliz local-leads sourcing for geography-bound local business campaigns."
|
|
3039
3220
|
});
|
|
3040
3221
|
}
|
|
3222
|
+
if (builtIns.has("company_discovery")) {
|
|
3223
|
+
routes.push({
|
|
3224
|
+
id: "signaliz-company-discovery",
|
|
3225
|
+
layer: "source",
|
|
3226
|
+
gtmLayer: "find_company",
|
|
3227
|
+
provider: "signaliz",
|
|
3228
|
+
mode: "if_available",
|
|
3229
|
+
toolName: "find_companies_signaliz",
|
|
3230
|
+
rationale: "Find and qualify company domains before people/email fill for account-led campaigns."
|
|
3231
|
+
});
|
|
3232
|
+
}
|
|
3233
|
+
if (builtIns.has("people_discovery")) {
|
|
3234
|
+
routes.push({
|
|
3235
|
+
id: "signaliz-people-discovery",
|
|
3236
|
+
layer: "source",
|
|
3237
|
+
gtmLayer: "find_people",
|
|
3238
|
+
provider: "signaliz",
|
|
3239
|
+
mode: "if_available",
|
|
3240
|
+
toolName: "find_people_signaliz",
|
|
3241
|
+
rationale: "Find people directly when the brief is contact research or LinkedIn-style prospecting."
|
|
3242
|
+
});
|
|
3243
|
+
}
|
|
3041
3244
|
if (builtIns.has("email_finding")) {
|
|
3042
3245
|
routes.push({
|
|
3043
3246
|
id: "signaliz-email-finding",
|
|
@@ -3082,7 +3285,7 @@ function normalizeBuiltIns(request) {
|
|
|
3082
3285
|
return [...builtIns].filter(isCampaignBuilderBuiltInTool);
|
|
3083
3286
|
}
|
|
3084
3287
|
function isCampaignBuilderBuiltInTool(value) {
|
|
3085
|
-
return ["lead_generation", "local_leads", "email_finding", "email_verification", "signals"].includes(String(value));
|
|
3288
|
+
return ["lead_generation", "local_leads", "company_discovery", "people_discovery", "email_finding", "email_verification", "signals"].includes(String(value));
|
|
3086
3289
|
}
|
|
3087
3290
|
function looksLikeLocalLeadCampaign(request) {
|
|
3088
3291
|
const text = [
|
|
@@ -3137,7 +3340,11 @@ function createBuildRequest(request, defaults, targetCount, campaignName, scopeB
|
|
|
3137
3340
|
qualification: defaults.qualification,
|
|
3138
3341
|
copy: defaults.copy,
|
|
3139
3342
|
delivery: defaults.delivery,
|
|
3140
|
-
enhancers: enhancerConfig(request)
|
|
3343
|
+
enhancers: enhancerConfig(request),
|
|
3344
|
+
sourceRouting: request.sourceRouting ?? {
|
|
3345
|
+
mode: looksLikeLocalLeadCampaign(request) ? "local_leads" : "auto",
|
|
3346
|
+
fillPolicy: "aggressive"
|
|
3347
|
+
}
|
|
3141
3348
|
};
|
|
3142
3349
|
const scoped = asRecord(scopeBuildArgs);
|
|
3143
3350
|
buildRequest.gtmCampaignId = request.gtmCampaignId ?? stringValue(scoped.gtm_campaign_id ?? scoped.gtmCampaignId);
|
|
@@ -3219,9 +3426,132 @@ function createBrainPreflight(request, buildRequest, routes, memory) {
|
|
|
3219
3426
|
{ tool: "gtm_brain_learning_cycle_plan", purpose: "Plan the Brain learning loop for this campaign.", arguments: learningArgs },
|
|
3220
3427
|
{ tool: "gtm_brain_seed_defaults", purpose: "Seed campaign defaults from workspace memory and safe aggregate patterns.", arguments: defaultsArgs },
|
|
3221
3428
|
{ tool: "gtm_brain_delivery_risk", purpose: "Check deliverability risk before launch or external writes.", arguments: riskArgs }
|
|
3222
|
-
]
|
|
3429
|
+
],
|
|
3430
|
+
learn_back_plan: createCampaignBuilderLearnBackPlan(request, buildRequest)
|
|
3223
3431
|
};
|
|
3224
3432
|
}
|
|
3433
|
+
function createCampaignBuilderLearnBackPlan(request, buildRequest) {
|
|
3434
|
+
const instantlyFeedbackContext = campaignBuilderProviderFeedbackContext(request, buildRequest, "instantly");
|
|
3435
|
+
const postBuildSequence = [
|
|
3436
|
+
{
|
|
3437
|
+
tool: "get_campaign_build_status",
|
|
3438
|
+
approval_boundary: "read_only",
|
|
3439
|
+
arguments_template: { campaign_build_id: "<build_campaign.campaign_build_id>" },
|
|
3440
|
+
reason: "Wait for the Campaign Builder run to finish before deriving memory."
|
|
3441
|
+
},
|
|
3442
|
+
{
|
|
3443
|
+
tool: "gtm_campaign_build_backfill_preview",
|
|
3444
|
+
approval_boundary: "read_only",
|
|
3445
|
+
arguments_template: { campaign_build_id: "<build_campaign.campaign_build_id>", create_memory: true },
|
|
3446
|
+
reason: "Preview the provider-neutral Kernel import payload without writing rows."
|
|
3447
|
+
},
|
|
3448
|
+
{
|
|
3449
|
+
tool: "gtm_campaign_build_backfill_run",
|
|
3450
|
+
approval_boundary: "dry_run",
|
|
3451
|
+
arguments_template: { campaign_build_ids: ["<build_campaign.campaign_build_id>"], dry_run: true, create_memory: true, run_brain_cycle: false },
|
|
3452
|
+
reason: "Dry-run the Kernel history import before creating campaign memory."
|
|
3453
|
+
},
|
|
3454
|
+
{
|
|
3455
|
+
tool: "gtm_campaign_build_backfill_run",
|
|
3456
|
+
approval_boundary: "explicit_write_approval",
|
|
3457
|
+
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" },
|
|
3458
|
+
reason: "After review, queue the Kernel history import; Brain learning remains dry-run unless separately approved."
|
|
3459
|
+
}
|
|
3460
|
+
];
|
|
3461
|
+
if (instantlyFeedbackContext) {
|
|
3462
|
+
postBuildSequence.push({
|
|
3463
|
+
tool: "gtm_instantly_feedback_pull",
|
|
3464
|
+
approval_boundary: "dry_run_first_explicit_write_approval",
|
|
3465
|
+
arguments_template: {
|
|
3466
|
+
campaign_id: buildRequest.gtmCampaignId || "<gtm_campaign_id_after_commit>",
|
|
3467
|
+
campaign_build_id: "<build_campaign.campaign_build_id>",
|
|
3468
|
+
source: "emails",
|
|
3469
|
+
email_type: "received",
|
|
3470
|
+
...instantlyFeedbackContext,
|
|
3471
|
+
dry_run: true,
|
|
3472
|
+
create_memory: true,
|
|
3473
|
+
write_routine_outcomes: true,
|
|
3474
|
+
run_brain_cycle: true,
|
|
3475
|
+
brain_cycle_write_mode: "dry_run"
|
|
3476
|
+
},
|
|
3477
|
+
reason: "After Instantly delivery has live outcomes, pull reply and bounce history into private feedback memory before Brain learning."
|
|
3478
|
+
});
|
|
3479
|
+
}
|
|
3480
|
+
postBuildSequence.push(
|
|
3481
|
+
{
|
|
3482
|
+
tool: "gtm_campaign_learning_status",
|
|
3483
|
+
approval_boundary: "read_only",
|
|
3484
|
+
arguments_template: {
|
|
3485
|
+
campaign_id: buildRequest.gtmCampaignId || "<gtm_campaign_id_after_commit>",
|
|
3486
|
+
campaign_build_id: "<build_campaign.campaign_build_id>",
|
|
3487
|
+
write_mode: "dry_run"
|
|
3488
|
+
},
|
|
3489
|
+
reason: "Confirm feedback, memory, and Brain learning readiness after the import."
|
|
3490
|
+
},
|
|
3491
|
+
{
|
|
3492
|
+
tool: "gtm_memory_search",
|
|
3493
|
+
approval_boundary: "read_only",
|
|
3494
|
+
arguments_template: {
|
|
3495
|
+
query: request.goal,
|
|
3496
|
+
...buildRequest.gtmCampaignId ? { campaign_id: buildRequest.gtmCampaignId } : {},
|
|
3497
|
+
limit: 10
|
|
3498
|
+
},
|
|
3499
|
+
reason: "Verify the new private memory is retrievable for future campaign planning."
|
|
3500
|
+
},
|
|
3501
|
+
{
|
|
3502
|
+
tool: "gtm_brain_learning_cycle_plan",
|
|
3503
|
+
approval_boundary: "read_only",
|
|
3504
|
+
arguments_template: {
|
|
3505
|
+
...buildRequest.gtmCampaignId ? { campaign_id: buildRequest.gtmCampaignId } : {},
|
|
3506
|
+
include_memory: true,
|
|
3507
|
+
write_mode: "dry_run"
|
|
3508
|
+
},
|
|
3509
|
+
reason: "Plan the Brain phases from the imported outcomes before any pattern writes."
|
|
3510
|
+
}
|
|
3511
|
+
);
|
|
3512
|
+
return {
|
|
3513
|
+
source_tool: "campaign-builder-agent",
|
|
3514
|
+
gtm_campaign_id: buildRequest.gtmCampaignId ?? null,
|
|
3515
|
+
trigger: "After build_campaign returns a campaign_build_id and the build reaches a terminal reviewed state.",
|
|
3516
|
+
build_result_placeholders: {
|
|
3517
|
+
campaign_build_id: "<build_campaign.campaign_build_id>"
|
|
3518
|
+
},
|
|
3519
|
+
memory_write_policy: {
|
|
3520
|
+
target_tables: ["gtm_campaigns", "gtm_campaign_provider_links", "gtm_campaign_feedback_events", "gtm_memory_items", "gtm_brain_patterns"],
|
|
3521
|
+
gtm_memory_items: {
|
|
3522
|
+
shareable: false,
|
|
3523
|
+
allowed_redaction_states: ["redacted", "abstracted"],
|
|
3524
|
+
raw_private_fields_withheld: ["reply_text", "copy_body", "lead_email", "lead_domain", "company_domain", "provider_campaign_id", "provider_payload", "webhook_url", "secret"]
|
|
3525
|
+
},
|
|
3526
|
+
gtm_brain_patterns: "Workspace-scoped by default. Global promotion requires abstracted_only=true, shared opt-in, and privacy thresholds."
|
|
3527
|
+
},
|
|
3528
|
+
post_build_sequence: postBuildSequence.map((item, index) => ({ step: index + 1, ...item })),
|
|
3529
|
+
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.",
|
|
3530
|
+
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."
|
|
3531
|
+
};
|
|
3532
|
+
}
|
|
3533
|
+
function campaignBuilderProviderFeedbackContext(request, buildRequest, provider) {
|
|
3534
|
+
const normalizedProvider = String(provider).toLowerCase();
|
|
3535
|
+
const routes = [...request.integrations ?? [], ...routesFromCustomerTools(request.customerTools ?? [])];
|
|
3536
|
+
const providerRoute = routes.find((route) => String(route.provider).toLowerCase() === normalizedProvider);
|
|
3537
|
+
const routeConfig = asRecord(providerRoute?.config);
|
|
3538
|
+
const deliveryConfig = asRecord(buildRequest.delivery?.destinationConfig);
|
|
3539
|
+
const hasProviderContext = [
|
|
3540
|
+
...request.preferredProviders ?? [],
|
|
3541
|
+
...routes.map((route) => route.provider),
|
|
3542
|
+
stringValue(deliveryConfig.provider),
|
|
3543
|
+
stringValue(deliveryConfig.provider_id ?? deliveryConfig.providerId),
|
|
3544
|
+
stringValue(deliveryConfig.destination_provider ?? deliveryConfig.destinationProvider),
|
|
3545
|
+
stringValue(deliveryConfig.sink ?? deliveryConfig.sink_type ?? deliveryConfig.sinkType)
|
|
3546
|
+
].some((value) => String(value).toLowerCase() === normalizedProvider);
|
|
3547
|
+
if (!hasProviderContext) return void 0;
|
|
3548
|
+
return compact({
|
|
3549
|
+
provider_link_id: stringValue(routeConfig.provider_link_id ?? routeConfig.providerLinkId ?? deliveryConfig.provider_link_id ?? deliveryConfig.providerLinkId),
|
|
3550
|
+
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),
|
|
3551
|
+
integration_id: stringValue(routeConfig.integration_id ?? routeConfig.integrationId ?? deliveryConfig.integration_id ?? deliveryConfig.integrationId),
|
|
3552
|
+
instantly_profile: stringValue(routeConfig.instantly_profile ?? routeConfig.instantlyProfile ?? routeConfig.profile ?? deliveryConfig.instantly_profile ?? deliveryConfig.instantlyProfile ?? deliveryConfig.profile)
|
|
3553
|
+
});
|
|
3554
|
+
}
|
|
3225
3555
|
function gtmLayersForBuilderLayer(layer) {
|
|
3226
3556
|
const map = {
|
|
3227
3557
|
workspace_context: ["customer_data"],
|
|
@@ -3626,6 +3956,7 @@ function buildFallbackPlanSnapshot(plan) {
|
|
|
3626
3956
|
target_count: plan.targetCount,
|
|
3627
3957
|
approvals: plan.approvals,
|
|
3628
3958
|
brain_preflight: plan.brainPreflight,
|
|
3959
|
+
campaign_strategy_context: plan.buildRequest.campaignStrategyContext,
|
|
3629
3960
|
operating_playbooks: plan.operatingPlaybooks
|
|
3630
3961
|
});
|
|
3631
3962
|
}
|
|
@@ -3758,6 +4089,7 @@ function buildCampaignArgs(request) {
|
|
|
3758
4089
|
if (request.dedupKeys) args.dedup_keys = request.dedupKeys;
|
|
3759
4090
|
if (request.brainPreflight) args.brain_preflight = request.brainPreflight;
|
|
3760
4091
|
if (request.brainDefaults) args.brain_defaults = request.brainDefaults;
|
|
4092
|
+
if (request.campaignStrategyContext) args.campaign_strategy_context = request.campaignStrategyContext;
|
|
3761
4093
|
if (request.deliveryRisk) args.delivery_risk = request.deliveryRisk;
|
|
3762
4094
|
if (request.icp) {
|
|
3763
4095
|
args.icp = compact({
|
|
@@ -3777,6 +4109,15 @@ function buildCampaignArgs(request) {
|
|
|
3777
4109
|
model: request.policy.model
|
|
3778
4110
|
});
|
|
3779
4111
|
}
|
|
4112
|
+
if (request.sourceRouting) {
|
|
4113
|
+
args.source_routing = compact({
|
|
4114
|
+
mode: request.sourceRouting.mode,
|
|
4115
|
+
fill_policy: request.sourceRouting.fillPolicy,
|
|
4116
|
+
shard_size: request.sourceRouting.shardSize,
|
|
4117
|
+
max_source_shard_size: request.sourceRouting.maxSourceShardSize,
|
|
4118
|
+
max_local_source_shard_size: request.sourceRouting.maxLocalSourceShardSize
|
|
4119
|
+
});
|
|
4120
|
+
}
|
|
3780
4121
|
if (request.signals) {
|
|
3781
4122
|
args.signals = compact({
|
|
3782
4123
|
enabled: request.signals.enabled,
|
|
@@ -3848,7 +4189,8 @@ function buildExecutionPrepareArgs(request, dryRun, confirmSpend) {
|
|
|
3848
4189
|
qualification: buildArgs2.qualification,
|
|
3849
4190
|
copy: buildArgs2.copy,
|
|
3850
4191
|
delivery: buildArgs2.delivery,
|
|
3851
|
-
enhancers: buildArgs2.enhancers
|
|
4192
|
+
enhancers: buildArgs2.enhancers,
|
|
4193
|
+
source_routing: buildArgs2.source_routing
|
|
3852
4194
|
});
|
|
3853
4195
|
}
|
|
3854
4196
|
function buildDeliveryApprovalArgs(request) {
|
|
@@ -3897,17 +4239,62 @@ function mapAgentCampaignBuildStatus(data) {
|
|
|
3897
4239
|
warnings: diagnosticMessages2(data.warnings),
|
|
3898
4240
|
errors: diagnosticMessages2(data.errors),
|
|
3899
4241
|
artifactCount: numberOrUndefined2(data.artifact_count) ?? 0,
|
|
4242
|
+
artifactDownloads: Array.isArray(data.artifact_downloads) ? data.artifact_downloads.map(mapAgentCampaignArtifactDownload) : [],
|
|
4243
|
+
customerRowCounts: mapAgentCustomerRowCounts(data.customer_row_counts),
|
|
4244
|
+
phaseAttemptTotals: nullableRecord(data.phase_attempt_totals) ?? void 0,
|
|
3900
4245
|
providerRoute: mapProviderRoute2(data),
|
|
3901
4246
|
triggerRunId: stringValue(data.trigger_run_id) ?? null,
|
|
3902
4247
|
staleRunningPhase: data.stale_running_phase === true,
|
|
3903
4248
|
phaseAgeSeconds: numberOrNull2(data.phase_age_seconds),
|
|
3904
4249
|
diagnostics: nullableRecord(data.diagnostics) ?? {},
|
|
3905
4250
|
nextAction: formatAgentNextAction(data.next_action),
|
|
4251
|
+
approvalAction: formatAgentNextAction(data.approval_action),
|
|
3906
4252
|
createdAt: stringValue(data.created_at) ?? "",
|
|
3907
4253
|
updatedAt: stringValue(data.updated_at) ?? "",
|
|
3908
4254
|
completedAt: stringValue(data.completed_at) ?? null
|
|
3909
4255
|
};
|
|
3910
4256
|
}
|
|
4257
|
+
function mapAgentCampaignArtifactDownload(data) {
|
|
4258
|
+
return {
|
|
4259
|
+
id: stringValue(data.id) ?? "",
|
|
4260
|
+
artifactType: stringValue(data.artifact_type) ?? null,
|
|
4261
|
+
format: stringValue(data.format) ?? null,
|
|
4262
|
+
rowCount: numberOrUndefined2(data.row_count) ?? 0,
|
|
4263
|
+
signedUrl: stringValue(data.signed_url) ?? null,
|
|
4264
|
+
downloadUrl: stringValue(data.download_url) ?? null,
|
|
4265
|
+
manifestUrl: stringValue(data.manifest_url) ?? null,
|
|
4266
|
+
expiresAt: stringValue(data.expires_at) ?? null
|
|
4267
|
+
};
|
|
4268
|
+
}
|
|
4269
|
+
function mapAgentCustomerRowCounts(value) {
|
|
4270
|
+
const record = nullableRecord(value);
|
|
4271
|
+
if (!record) return void 0;
|
|
4272
|
+
return {
|
|
4273
|
+
requestedTarget: numberOrNull2(record.requested_target),
|
|
4274
|
+
acquiredRows: numberOrUndefined2(record.acquired_rows),
|
|
4275
|
+
acceptedRows: numberOrUndefined2(record.accepted_rows),
|
|
4276
|
+
usableRows: numberOrUndefined2(record.usable_rows),
|
|
4277
|
+
copiedRows: numberOrUndefined2(record.copied_rows),
|
|
4278
|
+
approvalReadyRows: numberOrUndefined2(record.approval_ready_rows),
|
|
4279
|
+
qaReadyRows: numberOrUndefined2(record.qa_ready_rows),
|
|
4280
|
+
deliveredRows: numberOrUndefined2(record.delivered_rows),
|
|
4281
|
+
disqualifiedRows: numberOrUndefined2(record.disqualified_rows),
|
|
4282
|
+
reviewableRows: numberOrUndefined2(record.reviewable_rows),
|
|
4283
|
+
rowFailures: numberOrUndefined2(record.row_failures),
|
|
4284
|
+
acceptedShortfall: numberOrNull2(record.accepted_shortfall),
|
|
4285
|
+
usableShortfall: numberOrNull2(record.usable_shortfall),
|
|
4286
|
+
qaReadyShortfall: numberOrNull2(record.qa_ready_shortfall),
|
|
4287
|
+
deliveryShortfall: numberOrNull2(record.delivery_shortfall),
|
|
4288
|
+
fillRatio: numberOrNull2(record.fill_ratio),
|
|
4289
|
+
qaReadyFillRatio: numberOrNull2(record.qa_ready_fill_ratio),
|
|
4290
|
+
deliveredFillRatio: numberOrNull2(record.delivered_fill_ratio),
|
|
4291
|
+
terminalReason: stringValue(record.terminal_reason) ?? null,
|
|
4292
|
+
acceptedShortfallReason: stringValue(record.accepted_shortfall_reason) ?? null,
|
|
4293
|
+
usableShortfallReason: stringValue(record.usable_shortfall_reason) ?? null,
|
|
4294
|
+
qaReadyShortfallReason: stringValue(record.qa_ready_shortfall_reason) ?? null,
|
|
4295
|
+
deliveryShortfallReason: stringValue(record.delivery_shortfall_reason) ?? null
|
|
4296
|
+
};
|
|
4297
|
+
}
|
|
3911
4298
|
function mapAgentCampaignRowsResult(data) {
|
|
3912
4299
|
const rows = Array.isArray(data.rows) ? data.rows : [];
|
|
3913
4300
|
return {
|
|
@@ -3935,7 +4322,11 @@ function mapAgentCampaignArtifact(data) {
|
|
|
3935
4322
|
artifactType: stringValue(data.artifact_type) ?? "",
|
|
3936
4323
|
destination: stringValue(data.destination) ?? "",
|
|
3937
4324
|
storagePath: stringValue(data.storage_path) ?? "",
|
|
4325
|
+
format: stringValue(data.format) ?? null,
|
|
3938
4326
|
signedUrl: stringValue(data.signed_url) ?? null,
|
|
4327
|
+
downloadUrl: stringValue(data.download_url) ?? null,
|
|
4328
|
+
manifestUrl: stringValue(data.manifest_url) ?? null,
|
|
4329
|
+
expiresAt: stringValue(data.expires_at) ?? null,
|
|
3939
4330
|
rowCount: numberOrUndefined2(data.row_count) ?? 0,
|
|
3940
4331
|
checksum: stringValue(data.checksum) ?? null,
|
|
3941
4332
|
metadata: nullableRecord(data.metadata) ?? {},
|
|
@@ -4097,6 +4488,8 @@ function readinessLaneLabel(route, builtIn) {
|
|
|
4097
4488
|
const labels = {
|
|
4098
4489
|
lead_generation: "Signaliz lead generation",
|
|
4099
4490
|
local_leads: "Signaliz local leads",
|
|
4491
|
+
company_discovery: "Signaliz company discovery",
|
|
4492
|
+
people_discovery: "Signaliz people discovery",
|
|
4100
4493
|
email_finding: "Signaliz email finding",
|
|
4101
4494
|
email_verification: "Signaliz email verification",
|
|
4102
4495
|
signals: "Signaliz signals"
|
|
@@ -4181,6 +4574,35 @@ function summarizeCampaignBuilderProofDryRun(dryRunResult) {
|
|
|
4181
4574
|
plannedTargetCount: dryRunResult.plannedTargetCount ?? dryRunResult.planned_target_count ?? null
|
|
4182
4575
|
};
|
|
4183
4576
|
}
|
|
4577
|
+
function summarizeCampaignBuilderProofLearnBack(plan) {
|
|
4578
|
+
if (Object.keys(plan).length === 0) return { ready: false };
|
|
4579
|
+
const memoryPolicy = asRecord(plan.memory_write_policy);
|
|
4580
|
+
const memoryItemsPolicy = asRecord(memoryPolicy.gtm_memory_items);
|
|
4581
|
+
const sequence = Array.isArray(plan.post_build_sequence) ? plan.post_build_sequence.map((step) => {
|
|
4582
|
+
const record = asRecord(step);
|
|
4583
|
+
return compact({
|
|
4584
|
+
step: record.step,
|
|
4585
|
+
tool: stringValue(record.tool),
|
|
4586
|
+
approval_boundary: stringValue(record.approval_boundary),
|
|
4587
|
+
reason: stringValue(record.reason)
|
|
4588
|
+
});
|
|
4589
|
+
}).filter((step) => typeof step.tool === "string") : [];
|
|
4590
|
+
return {
|
|
4591
|
+
ready: sequence.length > 0,
|
|
4592
|
+
source_tool: firstNonEmptyString(plan.source_tool, plan.sourceTool),
|
|
4593
|
+
post_build_sequence: sequence,
|
|
4594
|
+
memory_write_policy: {
|
|
4595
|
+
target_tables: Array.isArray(memoryPolicy.target_tables) ? memoryPolicy.target_tables : [],
|
|
4596
|
+
gtm_memory_items: {
|
|
4597
|
+
shareable: memoryItemsPolicy.shareable === false ? false : memoryItemsPolicy.shareable ?? null,
|
|
4598
|
+
allowed_redaction_states: Array.isArray(memoryItemsPolicy.allowed_redaction_states) ? memoryItemsPolicy.allowed_redaction_states : [],
|
|
4599
|
+
raw_private_fields_withheld: Array.isArray(memoryItemsPolicy.raw_private_fields_withheld) ? memoryItemsPolicy.raw_private_fields_withheld : []
|
|
4600
|
+
}
|
|
4601
|
+
},
|
|
4602
|
+
approval_policy: firstNonEmptyString(plan.approval_policy, plan.approvalPolicy),
|
|
4603
|
+
privacy_policy: firstNonEmptyString(plan.privacy_policy, plan.privacyPolicy)
|
|
4604
|
+
};
|
|
4605
|
+
}
|
|
4184
4606
|
function firstNonEmptyString(...values) {
|
|
4185
4607
|
for (const value of values) {
|
|
4186
4608
|
if (typeof value === "string" && value.trim()) return value;
|
|
@@ -4663,14 +5085,87 @@ var Ops = class {
|
|
|
4663
5085
|
const body = typeof params === "string" ? { prompt: params } : buildOpsCreateBody(params);
|
|
4664
5086
|
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_create", body)));
|
|
4665
5087
|
}
|
|
5088
|
+
async schedule(params) {
|
|
5089
|
+
const createBody = typeof params === "string" ? { prompt: params, cadence: "daily" } : { ...buildOpsCreateBody(params), cadence: params.cadence ?? "daily" };
|
|
5090
|
+
const { activate: _activate, ...body } = createBody;
|
|
5091
|
+
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_schedule", body)));
|
|
5092
|
+
}
|
|
5093
|
+
async scheduleAndWait(params) {
|
|
5094
|
+
const options = typeof params === "string" ? { schedule: { prompt: params, cadence: "daily" }, run: {}, wait: {} } : buildOpsScheduleAndWaitOptions(params);
|
|
5095
|
+
const raw = await this.call("ops_schedule_and_wait", buildOpsScheduleAndWaitBody(options));
|
|
5096
|
+
return normalizeOpsScheduleAndWaitCallResult(raw, options.wait, {
|
|
5097
|
+
approvalMessage: "ops.scheduleAndWait requires an approved schedulable Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5098
|
+
notCreatedMessage: "ops.scheduleAndWait requires ops_schedule_and_wait to create an op_id. Use ops.schedule for approval review flows."
|
|
5099
|
+
});
|
|
5100
|
+
}
|
|
5101
|
+
/** Schedule a recurring Op that delivers through a customer-owned Nango API connection. */
|
|
5102
|
+
async scheduleNangoAction(input) {
|
|
5103
|
+
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_nango_schedule", buildOpsNangoScheduleBody(input))));
|
|
5104
|
+
}
|
|
5105
|
+
/** Schedule a recurring Nango-backed Op, run the first tick, and return result readback. */
|
|
5106
|
+
async scheduleNangoActionAndWait(input) {
|
|
5107
|
+
const options = buildOpsNangoScheduleAndWaitOptions(input);
|
|
5108
|
+
const raw = await this.call("ops_nango_schedule_and_wait", buildOpsNangoScheduleAndWaitBody(options));
|
|
5109
|
+
return normalizeOpsScheduleAndWaitCallResult(raw, options.wait, {
|
|
5110
|
+
approvalMessage: "ops.scheduleNangoActionAndWait requires an approved Nango-backed Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5111
|
+
notCreatedMessage: "ops.scheduleNangoActionAndWait requires ops_nango_schedule_and_wait to create an op_id. Use ops.scheduleNangoAction for approval review flows."
|
|
5112
|
+
});
|
|
5113
|
+
}
|
|
4666
5114
|
async execute(params) {
|
|
4667
5115
|
const body = typeof params === "string" ? { prompt: params } : buildOpsExecuteBody(params);
|
|
4668
5116
|
return normalizeOpsExecuteResult(withExecutionRefs(await this.call("ops_execute", body)));
|
|
4669
5117
|
}
|
|
5118
|
+
async executeAndWait(params) {
|
|
5119
|
+
const options = typeof params === "string" ? { execute: { prompt: params, auto_run: true }, wait: {} } : buildOpsExecuteAndWaitOptions(params);
|
|
5120
|
+
const execute = await this.execute(options.execute);
|
|
5121
|
+
if (execute.approval_required || execute.error_code === "APPROVAL_REQUIRED") {
|
|
5122
|
+
throw new SignalizError({
|
|
5123
|
+
code: "APPROVAL_REQUIRED",
|
|
5124
|
+
errorType: "validation",
|
|
5125
|
+
message: "ops.executeAndWait requires an approved executable Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5126
|
+
details: { execute }
|
|
5127
|
+
});
|
|
5128
|
+
}
|
|
5129
|
+
if (!execute.op_id) {
|
|
5130
|
+
throw new SignalizError({
|
|
5131
|
+
code: "OP_NOT_CREATED",
|
|
5132
|
+
errorType: "validation",
|
|
5133
|
+
message: "ops.executeAndWait requires ops_execute to create an op_id. Use ops.execute for dry runs or approval review flows.",
|
|
5134
|
+
details: { execute }
|
|
5135
|
+
});
|
|
5136
|
+
}
|
|
5137
|
+
const waited = await this.waitForResults({
|
|
5138
|
+
...options.wait,
|
|
5139
|
+
op_id: execute.op_id
|
|
5140
|
+
});
|
|
5141
|
+
const runId = execute.run_id ?? execute.runId ?? waited.status.run_id ?? waited.status.runId ?? null;
|
|
5142
|
+
return {
|
|
5143
|
+
...waited,
|
|
5144
|
+
execute,
|
|
5145
|
+
run_id: runId,
|
|
5146
|
+
runId,
|
|
5147
|
+
execution_refs: mergeExecutionRefsFrom([execute, waited])
|
|
5148
|
+
};
|
|
5149
|
+
}
|
|
4670
5150
|
async run(params) {
|
|
4671
5151
|
const body = typeof params === "string" ? { op_id: params } : buildOpsRunBody(params);
|
|
4672
5152
|
return normalizeOpsRunResult(withExecutionRefs(await this.call("ops_run", body)));
|
|
4673
5153
|
}
|
|
5154
|
+
async runAndWait(params) {
|
|
5155
|
+
const options = typeof params === "string" ? { op_id: params } : buildOpsRunAndWaitOptions(params);
|
|
5156
|
+
if (!options.op_id) throw new Error("ops.runAndWait requires op_id or opId");
|
|
5157
|
+
const run = await this.run({
|
|
5158
|
+
op_id: options.op_id,
|
|
5159
|
+
instruction: options.instruction,
|
|
5160
|
+
force: options.force
|
|
5161
|
+
});
|
|
5162
|
+
const waited = await this.waitForResults(options);
|
|
5163
|
+
return {
|
|
5164
|
+
...waited,
|
|
5165
|
+
run,
|
|
5166
|
+
execution_refs: mergeExecutionRefsFrom([run, waited])
|
|
5167
|
+
};
|
|
5168
|
+
}
|
|
4674
5169
|
async status(params) {
|
|
4675
5170
|
const body = typeof params === "string" ? { op_id: params } : buildOpsStatusBody(params);
|
|
4676
5171
|
return normalizeOpsStatusResult(withExecutionRefs(await this.call("ops_status", body)));
|
|
@@ -4679,6 +5174,173 @@ var Ops = class {
|
|
|
4679
5174
|
const body = typeof params === "string" ? { op_id: params } : buildOpsResultsBody(params);
|
|
4680
5175
|
return normalizeOpsResultsResult(withExecutionRefs(await this.call("ops_results", body)));
|
|
4681
5176
|
}
|
|
5177
|
+
async waitForResults(params) {
|
|
5178
|
+
const options = typeof params === "string" ? { op_id: params } : buildOpsWaitForResultsOptions(params);
|
|
5179
|
+
if (!options.op_id) throw new Error("ops.waitForResults requires op_id or opId");
|
|
5180
|
+
const waitResult = await this.call("ops_wait", buildOpsWaitBody(options));
|
|
5181
|
+
return normalizeOpsWaitForResultsResult(waitResult, options);
|
|
5182
|
+
}
|
|
5183
|
+
/** Create a short-lived Nango Connect session from the Ops namespace. */
|
|
5184
|
+
async createNangoConnectSession(input) {
|
|
5185
|
+
return this.call("nango_connect_session_create", {
|
|
5186
|
+
provider_id: input.providerId,
|
|
5187
|
+
integration_id: input.integrationId,
|
|
5188
|
+
provider_display_name: input.providerDisplayName,
|
|
5189
|
+
integration_display_name: input.integrationDisplayName,
|
|
5190
|
+
allowed_integrations: input.allowedIntegrations,
|
|
5191
|
+
surface: input.surface,
|
|
5192
|
+
source: input.source,
|
|
5193
|
+
user_email: input.userEmail,
|
|
5194
|
+
user_display_name: input.userDisplayName
|
|
5195
|
+
});
|
|
5196
|
+
}
|
|
5197
|
+
/** Prepare the full Nango provider search, connect, pull/export, Ops, and route flow. */
|
|
5198
|
+
async prepareNangoIntegrationFlow(input = {}) {
|
|
5199
|
+
return this.call("nango_integration_flow_prepare", {
|
|
5200
|
+
query: input.query,
|
|
5201
|
+
search: input.search,
|
|
5202
|
+
provider_id: input.providerId,
|
|
5203
|
+
provider: input.provider,
|
|
5204
|
+
integration_id: input.integrationId,
|
|
5205
|
+
provider_config_key: input.providerConfigKey,
|
|
5206
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
5207
|
+
connection_id: input.connectionId,
|
|
5208
|
+
nango_connection_id: input.nangoConnectionId,
|
|
5209
|
+
intent: input.intent,
|
|
5210
|
+
action_name: input.actionName,
|
|
5211
|
+
tool_name: input.toolName,
|
|
5212
|
+
proxy_path: input.proxyPath,
|
|
5213
|
+
method: input.method,
|
|
5214
|
+
input: input.input,
|
|
5215
|
+
cadence: input.cadence,
|
|
5216
|
+
field_map: input.fieldMap,
|
|
5217
|
+
required_fields: input.requiredFields,
|
|
5218
|
+
confirm_spend: input.confirmSpend,
|
|
5219
|
+
write_confirmed: input.writeConfirmed,
|
|
5220
|
+
layer: input.layer,
|
|
5221
|
+
campaign_id: input.campaignId,
|
|
5222
|
+
limit: input.limit,
|
|
5223
|
+
include_provider_catalog: input.includeProviderCatalog
|
|
5224
|
+
});
|
|
5225
|
+
}
|
|
5226
|
+
/** List Nango-backed action tools for a workspace connection without executing them. */
|
|
5227
|
+
async listNangoTools(options = {}) {
|
|
5228
|
+
return this.call("nango_mcp_tools_list", {
|
|
5229
|
+
workspace_connection_id: options.workspaceConnectionId,
|
|
5230
|
+
connection_id: options.connectionId,
|
|
5231
|
+
provider_config_key: options.providerConfigKey,
|
|
5232
|
+
integration_id: options.integrationId,
|
|
5233
|
+
nango_connection_id: options.nangoConnectionId,
|
|
5234
|
+
format: options.format,
|
|
5235
|
+
include_raw: options.includeRaw
|
|
5236
|
+
});
|
|
5237
|
+
}
|
|
5238
|
+
/** Audit connected Nango rows, action/proxy readiness, and read/write proof gaps. */
|
|
5239
|
+
async proveNangoReadWrite(options = {}) {
|
|
5240
|
+
return this.call("nango_mcp_read_write_audit", {
|
|
5241
|
+
workspace_connection_id: options.workspaceConnectionId,
|
|
5242
|
+
connection_id: options.connectionId,
|
|
5243
|
+
provider_config_key: options.providerConfigKey,
|
|
5244
|
+
integration_id: options.integrationId,
|
|
5245
|
+
nango_connection_id: options.nangoConnectionId,
|
|
5246
|
+
limit: options.limit,
|
|
5247
|
+
include_raw: options.includeRaw,
|
|
5248
|
+
read_proxy_path: options.readProxyPath,
|
|
5249
|
+
write_proxy_path: options.writeProxyPath,
|
|
5250
|
+
method: options.method,
|
|
5251
|
+
execute_read_probe: options.executeReadProbe,
|
|
5252
|
+
execute_write_probe: options.executeWriteProbe,
|
|
5253
|
+
confirm: options.confirm,
|
|
5254
|
+
confirm_write: options.confirmWrite,
|
|
5255
|
+
input: options.input,
|
|
5256
|
+
write_input: options.writeInput
|
|
5257
|
+
});
|
|
5258
|
+
}
|
|
5259
|
+
/** Dry-run or execute a Nango-backed action tool through the approval-aware MCP bridge. */
|
|
5260
|
+
async callNangoTool(input) {
|
|
5261
|
+
return this.call("nango_mcp_tool_call", {
|
|
5262
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
5263
|
+
connection_id: input.connectionId,
|
|
5264
|
+
provider_config_key: input.providerConfigKey,
|
|
5265
|
+
integration_id: input.integrationId,
|
|
5266
|
+
nango_connection_id: input.nangoConnectionId,
|
|
5267
|
+
action_name: input.actionName,
|
|
5268
|
+
tool_name: input.toolName,
|
|
5269
|
+
delivery_mode: input.deliveryMode,
|
|
5270
|
+
proxy_path: input.proxyPath,
|
|
5271
|
+
nango_proxy_path: input.nangoProxyPath,
|
|
5272
|
+
method: input.method,
|
|
5273
|
+
http_method: input.httpMethod,
|
|
5274
|
+
proxy_headers: input.proxyHeaders,
|
|
5275
|
+
input: input.input,
|
|
5276
|
+
async: input.async,
|
|
5277
|
+
max_retries: input.maxRetries,
|
|
5278
|
+
dry_run: input.dryRun,
|
|
5279
|
+
confirm: input.confirm,
|
|
5280
|
+
confirm_write: input.confirmWrite
|
|
5281
|
+
});
|
|
5282
|
+
}
|
|
5283
|
+
/** Execute a Nango action and poll its async result when a status URL/action id is returned. */
|
|
5284
|
+
async callNangoToolAndWait(input) {
|
|
5285
|
+
const result = await this.call("nango_mcp_tool_call_and_wait", {
|
|
5286
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
5287
|
+
connection_id: input.connectionId,
|
|
5288
|
+
provider_config_key: input.providerConfigKey,
|
|
5289
|
+
integration_id: input.integrationId,
|
|
5290
|
+
nango_connection_id: input.nangoConnectionId,
|
|
5291
|
+
action_name: input.actionName,
|
|
5292
|
+
tool_name: input.toolName,
|
|
5293
|
+
delivery_mode: input.deliveryMode,
|
|
5294
|
+
proxy_path: input.proxyPath,
|
|
5295
|
+
nango_proxy_path: input.nangoProxyPath,
|
|
5296
|
+
method: input.method,
|
|
5297
|
+
http_method: input.httpMethod,
|
|
5298
|
+
proxy_headers: input.proxyHeaders,
|
|
5299
|
+
input: input.input,
|
|
5300
|
+
async: input.async ?? true,
|
|
5301
|
+
max_retries: input.maxRetries,
|
|
5302
|
+
dry_run: input.dryRun,
|
|
5303
|
+
confirm: input.confirm,
|
|
5304
|
+
confirm_write: input.confirmWrite,
|
|
5305
|
+
interval_ms: input.intervalMs,
|
|
5306
|
+
max_polls: input.maxPolls,
|
|
5307
|
+
timeout_ms: input.timeoutMs
|
|
5308
|
+
});
|
|
5309
|
+
const packet = asRecord2(result);
|
|
5310
|
+
const actionId = optionalString(packet.actionId) ?? optionalString(packet.action_id);
|
|
5311
|
+
const statusUrl = optionalString(packet.statusUrl) ?? optionalString(packet.status_url);
|
|
5312
|
+
const maxPolls = Number(packet.maxPolls ?? packet.max_polls ?? 0);
|
|
5313
|
+
const intervalMs = Number(packet.intervalMs ?? packet.interval_ms ?? 0);
|
|
5314
|
+
const timeoutMs = Number(packet.timeoutMs ?? packet.timeout_ms ?? 0);
|
|
5315
|
+
const timedOut = Boolean(packet.timedOut ?? packet.timed_out);
|
|
5316
|
+
return {
|
|
5317
|
+
...packet,
|
|
5318
|
+
success: typeof packet.success === "boolean" ? packet.success : void 0,
|
|
5319
|
+
call: packet.call,
|
|
5320
|
+
result: packet.result,
|
|
5321
|
+
status: optionalString(packet.status),
|
|
5322
|
+
action_id: actionId,
|
|
5323
|
+
actionId,
|
|
5324
|
+
status_url: statusUrl,
|
|
5325
|
+
statusUrl,
|
|
5326
|
+
polls: Number(packet.polls ?? 0),
|
|
5327
|
+
max_polls: maxPolls,
|
|
5328
|
+
maxPolls,
|
|
5329
|
+
interval_ms: intervalMs,
|
|
5330
|
+
intervalMs,
|
|
5331
|
+
timeout_ms: timeoutMs,
|
|
5332
|
+
timeoutMs,
|
|
5333
|
+
timed_out: timedOut,
|
|
5334
|
+
timedOut
|
|
5335
|
+
};
|
|
5336
|
+
}
|
|
5337
|
+
/** Poll an async Nango action result by action id or status URL. */
|
|
5338
|
+
async getNangoActionResult(input) {
|
|
5339
|
+
return this.call("nango_mcp_action_result_get", {
|
|
5340
|
+
action_id: input.actionId,
|
|
5341
|
+
status_url: input.statusUrl
|
|
5342
|
+
});
|
|
5343
|
+
}
|
|
4682
5344
|
async proof(params = {}) {
|
|
4683
5345
|
const data = await this.call("ops_proof", {
|
|
4684
5346
|
window_hours: params.windowHours,
|
|
@@ -4705,51 +5367,57 @@ var Ops = class {
|
|
|
4705
5367
|
addRefs(collectExecutionReferences(status.latest_run));
|
|
4706
5368
|
}
|
|
4707
5369
|
const runRefs = Array.from(refs.values()).filter((ref) => ref.kind === "trigger_run" || ref.kind === "dataplane_run" || ref.kind === "replay_run");
|
|
4708
|
-
|
|
4709
|
-
for (const ref of runRefs) {
|
|
4710
|
-
try {
|
|
4711
|
-
const result = await this.getTriggerRunStatus(ref.id);
|
|
4712
|
-
const runs = "runs" in result ? result.runs : [result];
|
|
4713
|
-
runStatuses.push(...runs);
|
|
4714
|
-
for (const run of runs) addRefs(run.execution_refs);
|
|
4715
|
-
} catch (err) {
|
|
4716
|
-
recordError(`run-status:${ref.id}`, err);
|
|
4717
|
-
}
|
|
4718
|
-
}
|
|
5370
|
+
let runStatuses = [];
|
|
4719
5371
|
let queue;
|
|
4720
|
-
if (options.include_queue !== false) {
|
|
4721
|
-
try {
|
|
4722
|
-
queue = await this.getQueueStatus({ summary: true });
|
|
4723
|
-
addRefs(queue.execution_refs);
|
|
4724
|
-
} catch (err) {
|
|
4725
|
-
recordError("queue", err);
|
|
4726
|
-
}
|
|
4727
|
-
}
|
|
4728
5372
|
let dashboardRecent;
|
|
4729
|
-
if (options.include_dashboard !== false) {
|
|
4730
|
-
try {
|
|
4731
|
-
dashboardRecent = await this.getDashboard({
|
|
4732
|
-
section: "recent",
|
|
4733
|
-
limit: options.dashboard_limit ?? 10,
|
|
4734
|
-
timeRangeDays: options.time_range_days
|
|
4735
|
-
});
|
|
4736
|
-
} catch (err) {
|
|
4737
|
-
recordError("dashboard:recent", err);
|
|
4738
|
-
}
|
|
4739
|
-
}
|
|
4740
5373
|
let results;
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
5374
|
+
await Promise.all([
|
|
5375
|
+
(async () => {
|
|
5376
|
+
if (runRefs.length === 0) return;
|
|
5377
|
+
try {
|
|
5378
|
+
const result = await this.getTriggerRunStatus({ run_ids: runRefs.map((ref) => ref.id) });
|
|
5379
|
+
const runs = "runs" in result ? result.runs : [result];
|
|
5380
|
+
runStatuses = runs;
|
|
5381
|
+
for (const run of runs) addRefs(run.execution_refs);
|
|
5382
|
+
} catch (err) {
|
|
5383
|
+
recordError(runRefs.length === 1 ? `run-status:${runRefs[0].id}` : "run-status:batch", err);
|
|
5384
|
+
}
|
|
5385
|
+
})(),
|
|
5386
|
+
(async () => {
|
|
5387
|
+
if (options.include_queue === false) return;
|
|
5388
|
+
try {
|
|
5389
|
+
queue = await this.getQueueStatus({ summary: true });
|
|
5390
|
+
addRefs(queue.execution_refs);
|
|
5391
|
+
} catch (err) {
|
|
5392
|
+
recordError("queue", err);
|
|
5393
|
+
}
|
|
5394
|
+
})(),
|
|
5395
|
+
(async () => {
|
|
5396
|
+
if (options.include_dashboard === false) return;
|
|
5397
|
+
try {
|
|
5398
|
+
dashboardRecent = await this.getDashboard({
|
|
5399
|
+
section: "recent",
|
|
5400
|
+
limit: options.dashboard_limit ?? 10,
|
|
5401
|
+
timeRangeDays: options.time_range_days
|
|
5402
|
+
});
|
|
5403
|
+
} catch (err) {
|
|
5404
|
+
recordError("dashboard:recent", err);
|
|
5405
|
+
}
|
|
5406
|
+
})(),
|
|
5407
|
+
(async () => {
|
|
5408
|
+
if (!options.include_results) return;
|
|
5409
|
+
try {
|
|
5410
|
+
results = await this.results({
|
|
5411
|
+
op_id: options.op_id,
|
|
5412
|
+
limit: options.results_limit ?? 25,
|
|
5413
|
+
include_failed_runs: true
|
|
5414
|
+
});
|
|
5415
|
+
addRefs(results.execution_refs);
|
|
5416
|
+
} catch (err) {
|
|
5417
|
+
recordError("results", err);
|
|
5418
|
+
}
|
|
5419
|
+
})()
|
|
5420
|
+
]);
|
|
4753
5421
|
const executionRefs = Array.from(refs.values());
|
|
4754
5422
|
const replayCandidates = executionRefs.filter((ref) => ref.kind === "execution_event");
|
|
4755
5423
|
const nextActions = buildDebugNextActions(status, executionRefs, diagnosticErrors);
|
|
@@ -4951,6 +5619,69 @@ function mergeExecutionRefs(result) {
|
|
|
4951
5619
|
for (const ref of collectExecutionReferences(result)) add(ref);
|
|
4952
5620
|
return Array.from(refs.values());
|
|
4953
5621
|
}
|
|
5622
|
+
function mergeExecutionRefsFrom(results) {
|
|
5623
|
+
const refs = /* @__PURE__ */ new Map();
|
|
5624
|
+
for (const result of results) {
|
|
5625
|
+
if (!result) continue;
|
|
5626
|
+
for (const ref of mergeExecutionRefs(result)) refs.set(`${ref.kind}:${ref.id}`, ref);
|
|
5627
|
+
}
|
|
5628
|
+
return Array.from(refs.values());
|
|
5629
|
+
}
|
|
5630
|
+
function normalizeOpsScheduleAndWaitCallResult(raw, waitOptions, messages) {
|
|
5631
|
+
if (raw.approval_required || raw.approvalRequired || raw.error_code === "APPROVAL_REQUIRED" || raw.errorCode === "APPROVAL_REQUIRED") {
|
|
5632
|
+
throw new SignalizError({
|
|
5633
|
+
code: "APPROVAL_REQUIRED",
|
|
5634
|
+
errorType: "validation",
|
|
5635
|
+
message: messages.approvalMessage,
|
|
5636
|
+
details: { schedule: raw }
|
|
5637
|
+
});
|
|
5638
|
+
}
|
|
5639
|
+
const opId = stringValue2(raw.op_id ?? raw.opId);
|
|
5640
|
+
if (!opId) {
|
|
5641
|
+
throw new SignalizError({
|
|
5642
|
+
code: "OP_NOT_CREATED",
|
|
5643
|
+
errorType: "validation",
|
|
5644
|
+
message: messages.notCreatedMessage,
|
|
5645
|
+
details: { schedule: raw }
|
|
5646
|
+
});
|
|
5647
|
+
}
|
|
5648
|
+
const scheduleRaw = asRecord2(raw.schedule ?? raw.schedule_result ?? raw.scheduleResult);
|
|
5649
|
+
const runRaw = asRecord2(raw.run ?? raw.run_result ?? raw.runResult);
|
|
5650
|
+
const schedule = normalizeOpsCreateResult(withExecutionRefs(
|
|
5651
|
+
Object.keys(scheduleRaw).length > 0 ? scheduleRaw : {
|
|
5652
|
+
...raw,
|
|
5653
|
+
op_id: opId,
|
|
5654
|
+
routine_id: raw.routine_id ?? raw.routineId ?? opId,
|
|
5655
|
+
status: "ready",
|
|
5656
|
+
phase: "scheduled",
|
|
5657
|
+
next_action: raw.next_action ?? raw.nextAction
|
|
5658
|
+
}
|
|
5659
|
+
));
|
|
5660
|
+
const run = normalizeOpsRunResult(withExecutionRefs(
|
|
5661
|
+
Object.keys(runRaw).length > 0 ? runRaw : {
|
|
5662
|
+
success: raw.success !== false,
|
|
5663
|
+
op_id: opId,
|
|
5664
|
+
routine_id: raw.routine_id ?? raw.routineId ?? opId,
|
|
5665
|
+
run_id: raw.run_id ?? raw.runId ?? null,
|
|
5666
|
+
status: "running",
|
|
5667
|
+
phase: "queued",
|
|
5668
|
+
next_action: raw.next_action ?? raw.nextAction,
|
|
5669
|
+
results_count: 0,
|
|
5670
|
+
results_url: raw.results_url ?? raw.resultsUrl,
|
|
5671
|
+
delivery_status: raw.delivery_status ?? raw.deliveryStatus
|
|
5672
|
+
}
|
|
5673
|
+
));
|
|
5674
|
+
const waited = normalizeOpsWaitForResultsResult(raw, { ...waitOptions, op_id: opId });
|
|
5675
|
+
const runId = run.run_id ?? run.runId ?? waited.run_id ?? waited.runId ?? waited.status.run_id ?? waited.status.runId ?? null;
|
|
5676
|
+
return {
|
|
5677
|
+
...waited,
|
|
5678
|
+
schedule,
|
|
5679
|
+
run,
|
|
5680
|
+
run_id: runId,
|
|
5681
|
+
runId,
|
|
5682
|
+
execution_refs: mergeExecutionRefsFrom([schedule, run, waited])
|
|
5683
|
+
};
|
|
5684
|
+
}
|
|
4954
5685
|
function normalizeOpsPrimitiveRetryPolicy(policy = {}) {
|
|
4955
5686
|
return {
|
|
4956
5687
|
...policy,
|
|
@@ -5026,8 +5757,122 @@ function normalizeOpsPrimitive(primitive) {
|
|
|
5026
5757
|
observability: normalizeOpsPrimitiveObservabilityPolicy(primitive.observability)
|
|
5027
5758
|
};
|
|
5028
5759
|
}
|
|
5760
|
+
function normalizeOpsExecutionToolCall(rawCall) {
|
|
5761
|
+
const call = asRecord2(rawCall);
|
|
5762
|
+
return {
|
|
5763
|
+
...call,
|
|
5764
|
+
tool: stringValue2(call.tool),
|
|
5765
|
+
arguments: asRecord2(call.arguments),
|
|
5766
|
+
purpose: stringValue2(call.purpose)
|
|
5767
|
+
};
|
|
5768
|
+
}
|
|
5769
|
+
function normalizeOpsExecutionScheduleContract(rawSchedule) {
|
|
5770
|
+
const schedule = asRecord2(rawSchedule);
|
|
5771
|
+
const wakeOnEvents = Array.isArray(schedule.wake_on_events) ? schedule.wake_on_events.map(String) : Array.isArray(schedule.wakeOnEvents) ? schedule.wakeOnEvents.map(String) : [];
|
|
5772
|
+
return {
|
|
5773
|
+
...schedule,
|
|
5774
|
+
create_tool: stringValue2(schedule.create_tool ?? schedule.createTool),
|
|
5775
|
+
createTool: stringValue2(schedule.createTool ?? schedule.create_tool),
|
|
5776
|
+
activate_tool: stringValue2(schedule.activate_tool ?? schedule.activateTool),
|
|
5777
|
+
activateTool: stringValue2(schedule.activateTool ?? schedule.activate_tool),
|
|
5778
|
+
cadence: stringValue2(schedule.cadence, "manual"),
|
|
5779
|
+
recurrence: stringValue2(schedule.recurrence),
|
|
5780
|
+
wake_on_events: wakeOnEvents,
|
|
5781
|
+
wakeOnEvents
|
|
5782
|
+
};
|
|
5783
|
+
}
|
|
5784
|
+
function normalizeOpsExecutionApprovalContract(rawApproval) {
|
|
5785
|
+
const approval = asRecord2(rawApproval);
|
|
5786
|
+
return {
|
|
5787
|
+
...approval,
|
|
5788
|
+
required: Boolean(approval.required),
|
|
5789
|
+
tool: stringValue2(approval.tool),
|
|
5790
|
+
reason: stringValue2(approval.reason)
|
|
5791
|
+
};
|
|
5792
|
+
}
|
|
5793
|
+
function normalizeOpsExecutionMonitorContract(rawMonitor) {
|
|
5794
|
+
const monitor = asRecord2(rawMonitor);
|
|
5795
|
+
const pollAfterMs = numberValue(monitor.poll_after_ms ?? monitor.pollAfterMs);
|
|
5796
|
+
return {
|
|
5797
|
+
...monitor,
|
|
5798
|
+
status_tool: stringValue2(monitor.status_tool ?? monitor.statusTool),
|
|
5799
|
+
statusTool: stringValue2(monitor.statusTool ?? monitor.status_tool),
|
|
5800
|
+
wait_tool: stringValue2(monitor.wait_tool ?? monitor.waitTool),
|
|
5801
|
+
waitTool: stringValue2(monitor.waitTool ?? monitor.wait_tool),
|
|
5802
|
+
results_tool: stringValue2(monitor.results_tool ?? monitor.resultsTool),
|
|
5803
|
+
resultsTool: stringValue2(monitor.resultsTool ?? monitor.results_tool),
|
|
5804
|
+
poll_after_ms: pollAfterMs,
|
|
5805
|
+
pollAfterMs
|
|
5806
|
+
};
|
|
5807
|
+
}
|
|
5808
|
+
function normalizeOpsExecutionResultContract(rawResult) {
|
|
5809
|
+
const result = asRecord2(rawResult);
|
|
5810
|
+
const shape = Array.isArray(result.shape) ? result.shape.map(String) : [];
|
|
5811
|
+
return {
|
|
5812
|
+
...result,
|
|
5813
|
+
tool: stringValue2(result.tool),
|
|
5814
|
+
wait_tool: stringValue2(result.wait_tool ?? result.waitTool),
|
|
5815
|
+
waitTool: stringValue2(result.waitTool ?? result.wait_tool),
|
|
5816
|
+
shape,
|
|
5817
|
+
empty_result_recovery: stringValue2(result.empty_result_recovery ?? result.emptyResultRecovery),
|
|
5818
|
+
emptyResultRecovery: stringValue2(result.emptyResultRecovery ?? result.empty_result_recovery)
|
|
5819
|
+
};
|
|
5820
|
+
}
|
|
5821
|
+
function normalizeOpsExecutionNangoRouteContract(rawRoute) {
|
|
5822
|
+
if (!rawRoute || typeof rawRoute !== "object" || Array.isArray(rawRoute)) return void 0;
|
|
5823
|
+
const route = asRecord2(rawRoute);
|
|
5824
|
+
const requiredFields = Array.isArray(route.required_fields) ? route.required_fields.map(String) : Array.isArray(route.requiredFields) ? route.requiredFields.map(String) : [];
|
|
5825
|
+
return {
|
|
5826
|
+
...route,
|
|
5827
|
+
enabled: route.enabled !== false,
|
|
5828
|
+
connect_tool: stringValue2(route.connect_tool ?? route.connectTool),
|
|
5829
|
+
connectTool: stringValue2(route.connectTool ?? route.connect_tool),
|
|
5830
|
+
discover_tool: stringValue2(route.discover_tool ?? route.discoverTool),
|
|
5831
|
+
discoverTool: stringValue2(route.discoverTool ?? route.discover_tool),
|
|
5832
|
+
dry_run_tool: stringValue2(route.dry_run_tool ?? route.dryRunTool),
|
|
5833
|
+
dryRunTool: stringValue2(route.dryRunTool ?? route.dry_run_tool),
|
|
5834
|
+
execute_tool: stringValue2(route.execute_tool ?? route.executeTool),
|
|
5835
|
+
executeTool: stringValue2(route.executeTool ?? route.execute_tool),
|
|
5836
|
+
execute_and_wait_tool: stringValue2(route.execute_and_wait_tool ?? route.executeAndWaitTool),
|
|
5837
|
+
executeAndWaitTool: stringValue2(route.executeAndWaitTool ?? route.execute_and_wait_tool),
|
|
5838
|
+
schedule_tool: stringValue2(route.schedule_tool ?? route.scheduleTool),
|
|
5839
|
+
scheduleTool: stringValue2(route.scheduleTool ?? route.schedule_tool),
|
|
5840
|
+
schedule_and_wait_tool: stringValue2(route.schedule_and_wait_tool ?? route.scheduleAndWaitTool),
|
|
5841
|
+
scheduleAndWaitTool: stringValue2(route.scheduleAndWaitTool ?? route.schedule_and_wait_tool),
|
|
5842
|
+
result_tool: stringValue2(route.result_tool ?? route.resultTool),
|
|
5843
|
+
resultTool: stringValue2(route.resultTool ?? route.result_tool),
|
|
5844
|
+
write_gate: stringValue2(route.write_gate ?? route.writeGate),
|
|
5845
|
+
writeGate: stringValue2(route.writeGate ?? route.write_gate),
|
|
5846
|
+
required_fields: requiredFields,
|
|
5847
|
+
requiredFields,
|
|
5848
|
+
schedule_arguments: asRecord2(route.schedule_arguments ?? route.scheduleArguments),
|
|
5849
|
+
scheduleArguments: asRecord2(route.scheduleArguments ?? route.schedule_arguments),
|
|
5850
|
+
schedule_and_wait_arguments: asRecord2(route.schedule_and_wait_arguments ?? route.scheduleAndWaitArguments),
|
|
5851
|
+
scheduleAndWaitArguments: asRecord2(route.scheduleAndWaitArguments ?? route.schedule_and_wait_arguments)
|
|
5852
|
+
};
|
|
5853
|
+
}
|
|
5854
|
+
function normalizeOpsExecutionContract(rawContract) {
|
|
5855
|
+
if (!rawContract || typeof rawContract !== "object" || Array.isArray(rawContract)) return void 0;
|
|
5856
|
+
const contract = asRecord2(rawContract);
|
|
5857
|
+
const nangoRoute = normalizeOpsExecutionNangoRouteContract(contract.nango_route ?? contract.nangoRoute);
|
|
5858
|
+
const sequence = Array.isArray(contract.sequence) ? contract.sequence.map(normalizeOpsExecutionToolCall) : [];
|
|
5859
|
+
return {
|
|
5860
|
+
...contract,
|
|
5861
|
+
mode: stringValue2(contract.mode, "run_once"),
|
|
5862
|
+
run_now: normalizeOpsExecutionToolCall(contract.run_now ?? contract.runNow),
|
|
5863
|
+
runNow: normalizeOpsExecutionToolCall(contract.runNow ?? contract.run_now),
|
|
5864
|
+
schedule: normalizeOpsExecutionScheduleContract(contract.schedule),
|
|
5865
|
+
approval: normalizeOpsExecutionApprovalContract(contract.approval),
|
|
5866
|
+
monitor: normalizeOpsExecutionMonitorContract(contract.monitor),
|
|
5867
|
+
result_contract: normalizeOpsExecutionResultContract(contract.result_contract ?? contract.resultContract),
|
|
5868
|
+
resultContract: normalizeOpsExecutionResultContract(contract.resultContract ?? contract.result_contract),
|
|
5869
|
+
...nangoRoute ? { nango_route: nangoRoute, nangoRoute } : {},
|
|
5870
|
+
sequence
|
|
5871
|
+
};
|
|
5872
|
+
}
|
|
5029
5873
|
function normalizeOpsPlanResult(result) {
|
|
5030
5874
|
const primitiveGraph = result.primitive_graph ?? result.primitiveGraph;
|
|
5875
|
+
const executionContract = normalizeOpsExecutionContract(result.execution_contract ?? result.executionContract);
|
|
5031
5876
|
return {
|
|
5032
5877
|
...result,
|
|
5033
5878
|
plan_id: result.plan_id ?? result.planId,
|
|
@@ -5051,7 +5896,8 @@ function normalizeOpsPlanResult(result) {
|
|
|
5051
5896
|
destination_status: result.destination_status ?? result.destinationStatus,
|
|
5052
5897
|
destinationStatus: result.destinationStatus ?? result.destination_status,
|
|
5053
5898
|
primitive_graph: primitiveGraph?.map(normalizeOpsPrimitive),
|
|
5054
|
-
primitiveGraph: primitiveGraph?.map(normalizeOpsPrimitive)
|
|
5899
|
+
primitiveGraph: primitiveGraph?.map(normalizeOpsPrimitive),
|
|
5900
|
+
...executionContract ? { execution_contract: executionContract, executionContract } : {}
|
|
5055
5901
|
};
|
|
5056
5902
|
}
|
|
5057
5903
|
function normalizeOpsCreateResult(result) {
|
|
@@ -5073,7 +5919,18 @@ function normalizeOpsCreateResult(result) {
|
|
|
5073
5919
|
deliveryStatus: result.deliveryStatus ?? result.delivery_status,
|
|
5074
5920
|
estimated_credits: result.estimated_credits ?? result.estimatedCredits,
|
|
5075
5921
|
estimatedCredits: result.estimatedCredits ?? result.estimated_credits,
|
|
5076
|
-
|
|
5922
|
+
error_code: result.error_code ?? result.errorCode,
|
|
5923
|
+
errorCode: result.errorCode ?? result.error_code,
|
|
5924
|
+
approval_required: result.approval_required ?? result.approvalRequired,
|
|
5925
|
+
approvalRequired: result.approvalRequired ?? result.approval_required,
|
|
5926
|
+
retry_arguments: result.retry_arguments ?? result.retryArguments,
|
|
5927
|
+
retryArguments: result.retryArguments ?? result.retry_arguments,
|
|
5928
|
+
blockers: result.blockers,
|
|
5929
|
+
plan: result.plan ? normalizeOpsPlanResult(result.plan) : result.plan,
|
|
5930
|
+
next_step: result.next_step ?? result.nextStep,
|
|
5931
|
+
nextStep: result.nextStep ?? result.next_step,
|
|
5932
|
+
next_steps: result.next_steps ?? result.nextSteps,
|
|
5933
|
+
nextSteps: result.nextSteps ?? result.next_steps
|
|
5077
5934
|
};
|
|
5078
5935
|
}
|
|
5079
5936
|
function normalizeOpsExecuteResult(result) {
|
|
@@ -5201,6 +6058,40 @@ function normalizeOpsStatusResult(result) {
|
|
|
5201
6058
|
diagnosis: result.diagnosis ? normalizeOpsDebugDiagnosis(result.diagnosis) : void 0
|
|
5202
6059
|
};
|
|
5203
6060
|
}
|
|
6061
|
+
function normalizeOpsResultsSummary(value) {
|
|
6062
|
+
const summary = asRecord2(value);
|
|
6063
|
+
if (Object.keys(summary).length === 0) return void 0;
|
|
6064
|
+
const resultsTotal = summary.results_total ?? summary.resultsTotal;
|
|
6065
|
+
const nextCursor = summary.next_cursor ?? summary.nextCursor ?? null;
|
|
6066
|
+
const resultsUrl = summary.results_url ?? summary.resultsUrl;
|
|
6067
|
+
const nextAction = summary.next_action ?? summary.nextAction;
|
|
6068
|
+
const runId = summary.run_id ?? summary.runId ?? null;
|
|
6069
|
+
const creditsUsed = summary.credits_used ?? summary.creditsUsed;
|
|
6070
|
+
return {
|
|
6071
|
+
...summary,
|
|
6072
|
+
label: optionalString(summary.label),
|
|
6073
|
+
status: optionalString(summary.status),
|
|
6074
|
+
phase: optionalString(summary.phase),
|
|
6075
|
+
results_count: numberValue(summary.results_count ?? summary.resultsCount),
|
|
6076
|
+
resultsCount: numberValue(summary.results_count ?? summary.resultsCount),
|
|
6077
|
+
results_total: resultsTotal === null || resultsTotal === void 0 ? resultsTotal : numberValue(resultsTotal),
|
|
6078
|
+
resultsTotal: resultsTotal === null || resultsTotal === void 0 ? resultsTotal : numberValue(resultsTotal),
|
|
6079
|
+
delivery_status: optionalString(summary.delivery_status ?? summary.deliveryStatus),
|
|
6080
|
+
deliveryStatus: optionalString(summary.delivery_status ?? summary.deliveryStatus),
|
|
6081
|
+
has_more: Boolean(summary.has_more ?? summary.hasMore),
|
|
6082
|
+
hasMore: Boolean(summary.has_more ?? summary.hasMore),
|
|
6083
|
+
next_cursor: nextCursor === null ? null : optionalString(nextCursor),
|
|
6084
|
+
nextCursor: nextCursor === null ? null : optionalString(nextCursor),
|
|
6085
|
+
results_url: optionalString(resultsUrl),
|
|
6086
|
+
resultsUrl: optionalString(resultsUrl),
|
|
6087
|
+
next_action: optionalString(nextAction),
|
|
6088
|
+
nextAction: optionalString(nextAction),
|
|
6089
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6090
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6091
|
+
credits_used: creditsUsed === void 0 ? void 0 : numberValue(creditsUsed),
|
|
6092
|
+
creditsUsed: creditsUsed === void 0 ? void 0 : numberValue(creditsUsed)
|
|
6093
|
+
};
|
|
6094
|
+
}
|
|
5204
6095
|
function normalizeOpsResultsResult(result) {
|
|
5205
6096
|
const nextCursor = result.next_cursor ?? result.nextCursor ?? null;
|
|
5206
6097
|
const hasMore = result.has_more ?? result.hasMore ?? false;
|
|
@@ -5225,7 +6116,104 @@ function normalizeOpsResultsResult(result) {
|
|
|
5225
6116
|
results_url: result.results_url ?? result.resultsUrl,
|
|
5226
6117
|
resultsUrl: result.resultsUrl ?? result.results_url,
|
|
5227
6118
|
delivery_status: result.delivery_status ?? result.deliveryStatus,
|
|
5228
|
-
deliveryStatus: result.deliveryStatus ?? result.delivery_status
|
|
6119
|
+
deliveryStatus: result.deliveryStatus ?? result.delivery_status,
|
|
6120
|
+
summary: normalizeOpsResultsSummary(result.summary)
|
|
6121
|
+
};
|
|
6122
|
+
}
|
|
6123
|
+
function normalizeOpsWaitForResultsPoll(value, fallbackPoll) {
|
|
6124
|
+
const raw = asRecord2(value);
|
|
6125
|
+
const checkedAt = stringValue2(raw.checked_at ?? raw.checkedAt);
|
|
6126
|
+
const resultsCount = raw.results_count ?? raw.resultsCount;
|
|
6127
|
+
const runId = raw.run_id ?? raw.runId ?? null;
|
|
6128
|
+
const nextAction = raw.next_action ?? raw.nextAction;
|
|
6129
|
+
return {
|
|
6130
|
+
...raw,
|
|
6131
|
+
poll: numberValue(raw.poll) || fallbackPoll,
|
|
6132
|
+
checked_at: checkedAt,
|
|
6133
|
+
checkedAt,
|
|
6134
|
+
status: stringValue2(raw.status, "unknown"),
|
|
6135
|
+
phase: optionalString(raw.phase),
|
|
6136
|
+
results_count: resultsCount === void 0 ? void 0 : numberValue(resultsCount),
|
|
6137
|
+
resultsCount: resultsCount === void 0 ? void 0 : numberValue(resultsCount),
|
|
6138
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6139
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6140
|
+
next_action: optionalString(nextAction),
|
|
6141
|
+
nextAction: optionalString(nextAction)
|
|
6142
|
+
};
|
|
6143
|
+
}
|
|
6144
|
+
function normalizeOpsWaitForResultsResult(result, options) {
|
|
6145
|
+
const opId = stringValue2(result.op_id ?? result.opId ?? options.op_id);
|
|
6146
|
+
const routineId = stringValue2(result.routine_id ?? result.routineId ?? opId);
|
|
6147
|
+
const runId = result.run_id ?? result.runId ?? null;
|
|
6148
|
+
const timedOut = Boolean(result.timed_out ?? result.timedOut);
|
|
6149
|
+
const statusRaw = asRecord2(result.status_result ?? result.statusResult);
|
|
6150
|
+
const resultsRaw = asRecord2(result.results_result ?? result.resultsResult);
|
|
6151
|
+
const historySource = Array.isArray(result.poll_history) ? result.poll_history : Array.isArray(result.history) ? result.history : [];
|
|
6152
|
+
const history = historySource.map((item, index) => normalizeOpsWaitForResultsPoll(item, index + 1));
|
|
6153
|
+
const status = normalizeOpsStatusResult(withExecutionRefs({
|
|
6154
|
+
success: result.success !== false,
|
|
6155
|
+
op_id: opId,
|
|
6156
|
+
routine_id: routineId,
|
|
6157
|
+
run_id: runId,
|
|
6158
|
+
status: stringValue2(result.status, "unknown"),
|
|
6159
|
+
phase: stringValue2(result.phase, "unknown"),
|
|
6160
|
+
next_action: stringValue2(result.next_action ?? result.nextAction),
|
|
6161
|
+
results_count: numberValue(result.results_count ?? result.resultsCount),
|
|
6162
|
+
results_url: optionalString(result.results_url ?? result.resultsUrl),
|
|
6163
|
+
delivery_status: optionalString(result.delivery_status ?? result.deliveryStatus),
|
|
6164
|
+
...statusRaw
|
|
6165
|
+
}));
|
|
6166
|
+
const includeResults = options.include_results !== false && options.includeResults !== false;
|
|
6167
|
+
const hasResultsPacket = Object.keys(resultsRaw).length > 0 || Array.isArray(result.results);
|
|
6168
|
+
const results = includeResults && hasResultsPacket ? normalizeOpsResultsResult(withExecutionRefs({
|
|
6169
|
+
success: result.success !== false,
|
|
6170
|
+
op_id: opId,
|
|
6171
|
+
routine_id: routineId,
|
|
6172
|
+
run_id: runId,
|
|
6173
|
+
status: stringValue2(result.status, status.status),
|
|
6174
|
+
phase: stringValue2(result.phase, status.phase),
|
|
6175
|
+
results_count: numberValue(result.results_count ?? result.resultsCount),
|
|
6176
|
+
results_total: result.results_total ?? result.resultsTotal ?? null,
|
|
6177
|
+
results: Array.isArray(result.results) ? result.results : [],
|
|
6178
|
+
next_cursor: result.next_cursor ?? result.nextCursor ?? null,
|
|
6179
|
+
has_more: Boolean(result.has_more ?? result.hasMore),
|
|
6180
|
+
next_action: stringValue2(result.next_action ?? result.nextAction),
|
|
6181
|
+
results_url: optionalString(result.results_url ?? result.resultsUrl),
|
|
6182
|
+
delivery_status: optionalString(result.delivery_status ?? result.deliveryStatus),
|
|
6183
|
+
...resultsRaw
|
|
6184
|
+
})) : void 0;
|
|
6185
|
+
const polls = numberValue(result.polls) || history.length;
|
|
6186
|
+
const maxPolls = result.max_polls ?? result.maxPolls;
|
|
6187
|
+
const intervalMs = result.interval_ms ?? result.intervalMs;
|
|
6188
|
+
const timeoutMs = result.timeout_ms ?? result.timeoutMs;
|
|
6189
|
+
const stopReason = result.stop_reason ?? result.stopReason;
|
|
6190
|
+
const nextAction = result.next_action ?? result.nextAction ?? results?.next_action ?? status.next_action;
|
|
6191
|
+
return {
|
|
6192
|
+
...result,
|
|
6193
|
+
success: result.success !== false && !timedOut,
|
|
6194
|
+
op_id: opId,
|
|
6195
|
+
opId,
|
|
6196
|
+
routine_id: routineId,
|
|
6197
|
+
routineId,
|
|
6198
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6199
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6200
|
+
status,
|
|
6201
|
+
results,
|
|
6202
|
+
timed_out: timedOut,
|
|
6203
|
+
timedOut,
|
|
6204
|
+
polls,
|
|
6205
|
+
max_polls: maxPolls === void 0 ? void 0 : numberValue(maxPolls),
|
|
6206
|
+
maxPolls: maxPolls === void 0 ? void 0 : numberValue(maxPolls),
|
|
6207
|
+
interval_ms: intervalMs === void 0 ? void 0 : numberValue(intervalMs),
|
|
6208
|
+
intervalMs: intervalMs === void 0 ? void 0 : numberValue(intervalMs),
|
|
6209
|
+
timeout_ms: timeoutMs === void 0 ? void 0 : numberValue(timeoutMs),
|
|
6210
|
+
timeoutMs: timeoutMs === void 0 ? void 0 : numberValue(timeoutMs),
|
|
6211
|
+
stop_reason: optionalString(stopReason),
|
|
6212
|
+
stopReason: optionalString(stopReason),
|
|
6213
|
+
history,
|
|
6214
|
+
next_action: optionalString(nextAction),
|
|
6215
|
+
nextAction: optionalString(nextAction),
|
|
6216
|
+
execution_refs: mergeExecutionRefsFrom([result, status, results, { history }])
|
|
5229
6217
|
};
|
|
5230
6218
|
}
|
|
5231
6219
|
function normalizeOpsProofResult(data) {
|
|
@@ -5305,11 +6293,107 @@ function normalizeOpsProofResult(data) {
|
|
|
5305
6293
|
raw: data
|
|
5306
6294
|
};
|
|
5307
6295
|
}
|
|
6296
|
+
function normalizeOpsAutopilotSchedulePacket(rawPacket) {
|
|
6297
|
+
const packet = asRecord2(rawPacket);
|
|
6298
|
+
return {
|
|
6299
|
+
...packet,
|
|
6300
|
+
cadence: stringValue2(packet.cadence, "manual"),
|
|
6301
|
+
recurrence: stringValue2(packet.recurrence),
|
|
6302
|
+
activate_with: stringValue2(packet.activate_with ?? packet.activateWith),
|
|
6303
|
+
activateWith: stringValue2(packet.activate_with ?? packet.activateWith),
|
|
6304
|
+
run_now_with: stringValue2(packet.run_now_with ?? packet.runNowWith),
|
|
6305
|
+
runNowWith: stringValue2(packet.run_now_with ?? packet.runNowWith),
|
|
6306
|
+
monitor_with: stringValue2(packet.monitor_with ?? packet.monitorWith),
|
|
6307
|
+
monitorWith: stringValue2(packet.monitor_with ?? packet.monitorWith),
|
|
6308
|
+
retrieve_with: stringValue2(packet.retrieve_with ?? packet.retrieveWith),
|
|
6309
|
+
retrieveWith: stringValue2(packet.retrieve_with ?? packet.retrieveWith)
|
|
6310
|
+
};
|
|
6311
|
+
}
|
|
6312
|
+
function normalizeOpsAutopilotNangoRoutePacket(rawPacket) {
|
|
6313
|
+
if (!rawPacket || typeof rawPacket !== "object" || Array.isArray(rawPacket)) return void 0;
|
|
6314
|
+
const packet = asRecord2(rawPacket);
|
|
6315
|
+
const requiredFields = Array.isArray(packet.required_fields) ? packet.required_fields.map(String) : Array.isArray(packet.requiredFields) ? packet.requiredFields.map(String) : [];
|
|
6316
|
+
return {
|
|
6317
|
+
...packet,
|
|
6318
|
+
enabled: packet.enabled !== false,
|
|
6319
|
+
route_label: stringValue2(packet.route_label ?? packet.routeLabel),
|
|
6320
|
+
routeLabel: stringValue2(packet.route_label ?? packet.routeLabel),
|
|
6321
|
+
connect_tool: stringValue2(packet.connect_tool ?? packet.connectTool),
|
|
6322
|
+
connectTool: stringValue2(packet.connect_tool ?? packet.connectTool),
|
|
6323
|
+
discover_tool: stringValue2(packet.discover_tool ?? packet.discoverTool),
|
|
6324
|
+
discoverTool: stringValue2(packet.discover_tool ?? packet.discoverTool),
|
|
6325
|
+
dry_run_tool: stringValue2(packet.dry_run_tool ?? packet.dryRunTool),
|
|
6326
|
+
dryRunTool: stringValue2(packet.dry_run_tool ?? packet.dryRunTool),
|
|
6327
|
+
execute_tool: stringValue2(packet.execute_tool ?? packet.executeTool),
|
|
6328
|
+
executeTool: stringValue2(packet.execute_tool ?? packet.executeTool),
|
|
6329
|
+
execute_and_wait_tool: stringValue2(packet.execute_and_wait_tool ?? packet.executeAndWaitTool),
|
|
6330
|
+
executeAndWaitTool: stringValue2(packet.execute_and_wait_tool ?? packet.executeAndWaitTool),
|
|
6331
|
+
schedule_tool: stringValue2(packet.schedule_tool ?? packet.scheduleTool),
|
|
6332
|
+
scheduleTool: stringValue2(packet.schedule_tool ?? packet.scheduleTool),
|
|
6333
|
+
schedule_and_wait_tool: stringValue2(packet.schedule_and_wait_tool ?? packet.scheduleAndWaitTool),
|
|
6334
|
+
scheduleAndWaitTool: stringValue2(packet.schedule_and_wait_tool ?? packet.scheduleAndWaitTool),
|
|
6335
|
+
result_tool: stringValue2(packet.result_tool ?? packet.resultTool),
|
|
6336
|
+
resultTool: stringValue2(packet.result_tool ?? packet.resultTool),
|
|
6337
|
+
write_gate: stringValue2(packet.write_gate ?? packet.writeGate),
|
|
6338
|
+
writeGate: stringValue2(packet.write_gate ?? packet.writeGate),
|
|
6339
|
+
required_fields: requiredFields,
|
|
6340
|
+
requiredFields,
|
|
6341
|
+
placeholders: asRecord2(packet.placeholders),
|
|
6342
|
+
dry_run_arguments: asRecord2(packet.dry_run_arguments ?? packet.dryRunArguments),
|
|
6343
|
+
dryRunArguments: asRecord2(packet.dry_run_arguments ?? packet.dryRunArguments),
|
|
6344
|
+
execute_arguments: asRecord2(packet.execute_arguments ?? packet.executeArguments),
|
|
6345
|
+
executeArguments: asRecord2(packet.execute_arguments ?? packet.executeArguments),
|
|
6346
|
+
execute_and_wait_arguments: asRecord2(packet.execute_and_wait_arguments ?? packet.executeAndWaitArguments),
|
|
6347
|
+
executeAndWaitArguments: asRecord2(packet.execute_and_wait_arguments ?? packet.executeAndWaitArguments),
|
|
6348
|
+
schedule_arguments: asRecord2(packet.schedule_arguments ?? packet.scheduleArguments),
|
|
6349
|
+
scheduleArguments: asRecord2(packet.schedule_arguments ?? packet.scheduleArguments),
|
|
6350
|
+
schedule_and_wait_arguments: asRecord2(packet.schedule_and_wait_arguments ?? packet.scheduleAndWaitArguments),
|
|
6351
|
+
scheduleAndWaitArguments: asRecord2(packet.schedule_and_wait_arguments ?? packet.scheduleAndWaitArguments),
|
|
6352
|
+
result_arguments: asRecord2(packet.result_arguments ?? packet.resultArguments),
|
|
6353
|
+
resultArguments: asRecord2(packet.result_arguments ?? packet.resultArguments)
|
|
6354
|
+
};
|
|
6355
|
+
}
|
|
6356
|
+
function normalizeOpsAutopilotResultPacket(rawPacket) {
|
|
6357
|
+
const packet = asRecord2(rawPacket);
|
|
6358
|
+
const resultShape = Array.isArray(packet.result_shape) ? packet.result_shape.map(String) : Array.isArray(packet.resultShape) ? packet.resultShape.map(String) : [];
|
|
6359
|
+
const deliveryReceipts = Array.isArray(packet.delivery_receipts) ? packet.delivery_receipts.map(String) : Array.isArray(packet.deliveryReceipts) ? packet.deliveryReceipts.map(String) : [];
|
|
6360
|
+
return {
|
|
6361
|
+
...packet,
|
|
6362
|
+
retrieve_tool: stringValue2(packet.retrieve_tool ?? packet.retrieveTool),
|
|
6363
|
+
retrieveTool: stringValue2(packet.retrieve_tool ?? packet.retrieveTool),
|
|
6364
|
+
result_shape: resultShape,
|
|
6365
|
+
resultShape,
|
|
6366
|
+
delivery_receipts: deliveryReceipts,
|
|
6367
|
+
deliveryReceipts,
|
|
6368
|
+
empty_result_recovery: stringValue2(packet.empty_result_recovery ?? packet.emptyResultRecovery),
|
|
6369
|
+
emptyResultRecovery: stringValue2(packet.empty_result_recovery ?? packet.emptyResultRecovery)
|
|
6370
|
+
};
|
|
6371
|
+
}
|
|
6372
|
+
function normalizeOpsAutopilotOperatingPacket(rawPacket) {
|
|
6373
|
+
if (!rawPacket || typeof rawPacket !== "object" || Array.isArray(rawPacket)) return void 0;
|
|
6374
|
+
const packet = asRecord2(rawPacket);
|
|
6375
|
+
const nangoRoute = normalizeOpsAutopilotNangoRoutePacket(packet.nango_route ?? packet.nangoRoute);
|
|
6376
|
+
const approvalBoundaries = Array.isArray(packet.approval_boundaries) ? packet.approval_boundaries.map(String) : Array.isArray(packet.approvalBoundaries) ? packet.approvalBoundaries.map(String) : [];
|
|
6377
|
+
return {
|
|
6378
|
+
...packet,
|
|
6379
|
+
north_star: stringValue2(packet.north_star ?? packet.northStar),
|
|
6380
|
+
northStar: stringValue2(packet.north_star ?? packet.northStar),
|
|
6381
|
+
schedule: normalizeOpsAutopilotSchedulePacket(packet.schedule),
|
|
6382
|
+
...nangoRoute ? { nango_route: nangoRoute, nangoRoute } : {},
|
|
6383
|
+
result_contract: normalizeOpsAutopilotResultPacket(packet.result_contract ?? packet.resultContract),
|
|
6384
|
+
resultContract: normalizeOpsAutopilotResultPacket(packet.result_contract ?? packet.resultContract),
|
|
6385
|
+
approval_boundaries: approvalBoundaries,
|
|
6386
|
+
approvalBoundaries,
|
|
6387
|
+
saved_command_hint: stringValue2(packet.saved_command_hint ?? packet.savedCommandHint),
|
|
6388
|
+
savedCommandHint: stringValue2(packet.saved_command_hint ?? packet.savedCommandHint)
|
|
6389
|
+
};
|
|
6390
|
+
}
|
|
5308
6391
|
function normalizeOpsAutopilotMotion(rawMotion) {
|
|
5309
6392
|
const motion = asRecord2(rawMotion);
|
|
5310
6393
|
const targetCount = numberValue(motion.target_count ?? motion.targetCount);
|
|
5311
6394
|
const estimatedCredits = numberValue(motion.estimated_credits ?? motion.estimatedCredits);
|
|
5312
6395
|
const mcpSequence = Array.isArray(motion.mcp_sequence) ? motion.mcp_sequence : Array.isArray(motion.mcpSequence) ? motion.mcpSequence : [];
|
|
6396
|
+
const operatingPacket = normalizeOpsAutopilotOperatingPacket(motion.operating_packet ?? motion.operatingPacket);
|
|
5313
6397
|
return {
|
|
5314
6398
|
...motion,
|
|
5315
6399
|
id: stringValue2(motion.id),
|
|
@@ -5332,12 +6416,16 @@ function normalizeOpsAutopilotMotion(rawMotion) {
|
|
|
5332
6416
|
cli_command: optionalString(motion.cli_command ?? motion.cliCommand),
|
|
5333
6417
|
cliCommand: optionalString(motion.cli_command ?? motion.cliCommand),
|
|
5334
6418
|
mcp_sequence: mcpSequence,
|
|
5335
|
-
mcpSequence
|
|
6419
|
+
mcpSequence,
|
|
6420
|
+
...operatingPacket ? { operating_packet: operatingPacket, operatingPacket } : {}
|
|
5336
6421
|
};
|
|
5337
6422
|
}
|
|
5338
6423
|
function normalizeOpsAutopilotResult(result) {
|
|
5339
6424
|
const primary = normalizeOpsAutopilotMotion(result.primary_motion ?? result.primaryMotion);
|
|
5340
6425
|
const motions = Array.isArray(result.motions) ? result.motions.map(normalizeOpsAutopilotMotion) : [];
|
|
6426
|
+
const operatingPacket = normalizeOpsAutopilotOperatingPacket(
|
|
6427
|
+
result.operating_packet ?? result.operatingPacket ?? primary.operating_packet ?? primary.operatingPacket
|
|
6428
|
+
);
|
|
5341
6429
|
const queryErrors = Array.isArray(result.query_errors) ? result.query_errors.map(String) : Array.isArray(result.queryErrors) ? result.queryErrors.map(String) : [];
|
|
5342
6430
|
return {
|
|
5343
6431
|
...result,
|
|
@@ -5353,6 +6441,7 @@ function normalizeOpsAutopilotResult(result) {
|
|
|
5353
6441
|
scaleRule: optionalString(result.scale_rule ?? result.scaleRule),
|
|
5354
6442
|
agent_handoff: optionalString(result.agent_handoff ?? result.agentHandoff),
|
|
5355
6443
|
agentHandoff: optionalString(result.agent_handoff ?? result.agentHandoff),
|
|
6444
|
+
...operatingPacket ? { operating_packet: operatingPacket, operatingPacket } : {},
|
|
5356
6445
|
proof_state: optionalString(result.proof_state ?? result.proofState),
|
|
5357
6446
|
proofState: optionalString(result.proof_state ?? result.proofState),
|
|
5358
6447
|
proof_summary: result.proof_summary ?? result.proofSummary,
|
|
@@ -5617,11 +6706,125 @@ function normalizeOpsRoutineTickItemsResult(result) {
|
|
|
5617
6706
|
hasMore
|
|
5618
6707
|
};
|
|
5619
6708
|
}
|
|
6709
|
+
function buildOpsNangoScheduleBody(input) {
|
|
6710
|
+
const {
|
|
6711
|
+
workspaceConnectionId,
|
|
6712
|
+
workspace_connection_id,
|
|
6713
|
+
connectionId,
|
|
6714
|
+
connection_id,
|
|
6715
|
+
providerConfigKey,
|
|
6716
|
+
provider_config_key,
|
|
6717
|
+
integrationId,
|
|
6718
|
+
integration_id,
|
|
6719
|
+
nangoConnectionId,
|
|
6720
|
+
nango_connection_id,
|
|
6721
|
+
actionName,
|
|
6722
|
+
action_name,
|
|
6723
|
+
toolName,
|
|
6724
|
+
tool_name,
|
|
6725
|
+
proxyPath,
|
|
6726
|
+
proxy_path,
|
|
6727
|
+
nangoProxyPath,
|
|
6728
|
+
nango_proxy_path,
|
|
6729
|
+
method,
|
|
6730
|
+
httpMethod,
|
|
6731
|
+
http_method,
|
|
6732
|
+
input: nangoInput,
|
|
6733
|
+
arguments: nangoArguments,
|
|
6734
|
+
fieldMap,
|
|
6735
|
+
field_map,
|
|
6736
|
+
requiredFields,
|
|
6737
|
+
required_fields,
|
|
6738
|
+
writeConfirmed,
|
|
6739
|
+
write_confirmed,
|
|
6740
|
+
agentWriteConfirmed,
|
|
6741
|
+
agent_write_confirmed,
|
|
6742
|
+
config,
|
|
6743
|
+
destinations: _destinations,
|
|
6744
|
+
...schedule
|
|
6745
|
+
} = input;
|
|
6746
|
+
return {
|
|
6747
|
+
...buildOpsCreateBody({
|
|
6748
|
+
...schedule,
|
|
6749
|
+
cadence: schedule.cadence ?? "daily"
|
|
6750
|
+
}),
|
|
6751
|
+
workspace_connection_id: workspace_connection_id ?? workspaceConnectionId,
|
|
6752
|
+
connection_id: connection_id ?? connectionId,
|
|
6753
|
+
provider_config_key: provider_config_key ?? providerConfigKey,
|
|
6754
|
+
integration_id: integration_id ?? integrationId,
|
|
6755
|
+
nango_connection_id: nango_connection_id ?? nangoConnectionId,
|
|
6756
|
+
action_name: action_name ?? actionName,
|
|
6757
|
+
tool_name: tool_name ?? toolName,
|
|
6758
|
+
proxy_path: proxy_path ?? proxyPath ?? nango_proxy_path ?? nangoProxyPath,
|
|
6759
|
+
nango_proxy_path: nango_proxy_path ?? nangoProxyPath,
|
|
6760
|
+
method: method ?? http_method ?? httpMethod,
|
|
6761
|
+
input: nangoInput ?? nangoArguments,
|
|
6762
|
+
field_map: field_map ?? fieldMap,
|
|
6763
|
+
required_fields: required_fields ?? requiredFields,
|
|
6764
|
+
write_confirmed: write_confirmed ?? writeConfirmed,
|
|
6765
|
+
agent_write_confirmed: agent_write_confirmed ?? agentWriteConfirmed,
|
|
6766
|
+
config
|
|
6767
|
+
};
|
|
6768
|
+
}
|
|
6769
|
+
function buildOpsNangoScheduleAndWaitOptions(params) {
|
|
6770
|
+
const {
|
|
6771
|
+
force,
|
|
6772
|
+
instruction,
|
|
6773
|
+
nextCursor,
|
|
6774
|
+
includeFailedRuns,
|
|
6775
|
+
intervalMs,
|
|
6776
|
+
maxPolls,
|
|
6777
|
+
timeoutMs,
|
|
6778
|
+
includeResults,
|
|
6779
|
+
cursor,
|
|
6780
|
+
state,
|
|
6781
|
+
limit,
|
|
6782
|
+
include_failed_runs,
|
|
6783
|
+
interval_ms,
|
|
6784
|
+
max_polls,
|
|
6785
|
+
timeout_ms,
|
|
6786
|
+
include_results,
|
|
6787
|
+
...schedule
|
|
6788
|
+
} = params;
|
|
6789
|
+
return {
|
|
6790
|
+
schedule: {
|
|
6791
|
+
...schedule,
|
|
6792
|
+
cadence: schedule.cadence ?? "daily"
|
|
6793
|
+
},
|
|
6794
|
+
run: {
|
|
6795
|
+
force,
|
|
6796
|
+
instruction
|
|
6797
|
+
},
|
|
6798
|
+
wait: {
|
|
6799
|
+
cursor: cursor ?? nextCursor,
|
|
6800
|
+
state,
|
|
6801
|
+
limit,
|
|
6802
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6803
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6804
|
+
max_polls: max_polls ?? maxPolls,
|
|
6805
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6806
|
+
include_results: include_results ?? includeResults
|
|
6807
|
+
}
|
|
6808
|
+
};
|
|
6809
|
+
}
|
|
6810
|
+
function buildOpsNangoScheduleAndWaitBody(options) {
|
|
6811
|
+
const waitBody = buildOpsWaitBody(options.wait);
|
|
6812
|
+
const { op_id: _opId, ...waitWithoutOp } = waitBody;
|
|
6813
|
+
return {
|
|
6814
|
+
...buildOpsNangoScheduleBody(options.schedule),
|
|
6815
|
+
...waitWithoutOp,
|
|
6816
|
+
instruction: options.run.instruction,
|
|
6817
|
+
force: options.run.force
|
|
6818
|
+
};
|
|
6819
|
+
}
|
|
5620
6820
|
function buildOpsPlanBody(params) {
|
|
5621
|
-
const { targetCount, companyDomains, customAiPrompt, signalPrompt, outputPrompt, ...rest } = params;
|
|
6821
|
+
const { targetCount, wakeOnEvents, companyDomains, customAiPrompt, signalPrompt, outputPrompt, ...rest } = params;
|
|
6822
|
+
const destinations = Array.isArray(rest.destinations) ? rest.destinations.map(normalizeOpsDestinationRequest) : rest.destinations;
|
|
5622
6823
|
return {
|
|
5623
6824
|
...rest,
|
|
6825
|
+
destinations,
|
|
5624
6826
|
target_count: rest.target_count ?? targetCount,
|
|
6827
|
+
wake_on_events: rest.wake_on_events ?? wakeOnEvents,
|
|
5625
6828
|
company_domains: rest.company_domains ?? companyDomains,
|
|
5626
6829
|
custom_ai_prompt: rest.custom_ai_prompt ?? customAiPrompt,
|
|
5627
6830
|
signal_prompt: rest.signal_prompt ?? signalPrompt,
|
|
@@ -5644,6 +6847,95 @@ function buildOpsExecuteBody(params) {
|
|
|
5644
6847
|
output_format: rest.output_format ?? outputFormat
|
|
5645
6848
|
};
|
|
5646
6849
|
}
|
|
6850
|
+
function buildOpsExecuteAndWaitOptions(params) {
|
|
6851
|
+
const {
|
|
6852
|
+
nextCursor,
|
|
6853
|
+
includeFailedRuns,
|
|
6854
|
+
intervalMs,
|
|
6855
|
+
maxPolls,
|
|
6856
|
+
timeoutMs,
|
|
6857
|
+
includeResults,
|
|
6858
|
+
cursor,
|
|
6859
|
+
state,
|
|
6860
|
+
limit,
|
|
6861
|
+
include_failed_runs,
|
|
6862
|
+
interval_ms,
|
|
6863
|
+
max_polls,
|
|
6864
|
+
timeout_ms,
|
|
6865
|
+
include_results,
|
|
6866
|
+
...execute
|
|
6867
|
+
} = params;
|
|
6868
|
+
return {
|
|
6869
|
+
execute: {
|
|
6870
|
+
...execute,
|
|
6871
|
+
auto_run: execute.auto_run ?? execute.autoRun ?? true
|
|
6872
|
+
},
|
|
6873
|
+
wait: {
|
|
6874
|
+
cursor: cursor ?? nextCursor,
|
|
6875
|
+
state,
|
|
6876
|
+
limit,
|
|
6877
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6878
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6879
|
+
max_polls: max_polls ?? maxPolls,
|
|
6880
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6881
|
+
include_results: include_results ?? includeResults
|
|
6882
|
+
}
|
|
6883
|
+
};
|
|
6884
|
+
}
|
|
6885
|
+
function buildOpsScheduleAndWaitOptions(params) {
|
|
6886
|
+
const {
|
|
6887
|
+
force,
|
|
6888
|
+
instruction,
|
|
6889
|
+
nextCursor,
|
|
6890
|
+
includeFailedRuns,
|
|
6891
|
+
intervalMs,
|
|
6892
|
+
maxPolls,
|
|
6893
|
+
timeoutMs,
|
|
6894
|
+
includeResults,
|
|
6895
|
+
cursor,
|
|
6896
|
+
state,
|
|
6897
|
+
limit,
|
|
6898
|
+
include_failed_runs,
|
|
6899
|
+
interval_ms,
|
|
6900
|
+
max_polls,
|
|
6901
|
+
timeout_ms,
|
|
6902
|
+
include_results,
|
|
6903
|
+
...schedule
|
|
6904
|
+
} = params;
|
|
6905
|
+
return {
|
|
6906
|
+
schedule: {
|
|
6907
|
+
...schedule,
|
|
6908
|
+
cadence: schedule.cadence ?? "daily"
|
|
6909
|
+
},
|
|
6910
|
+
run: {
|
|
6911
|
+
force,
|
|
6912
|
+
instruction
|
|
6913
|
+
},
|
|
6914
|
+
wait: {
|
|
6915
|
+
cursor: cursor ?? nextCursor,
|
|
6916
|
+
state,
|
|
6917
|
+
limit,
|
|
6918
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6919
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6920
|
+
max_polls: max_polls ?? maxPolls,
|
|
6921
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6922
|
+
include_results: include_results ?? includeResults
|
|
6923
|
+
}
|
|
6924
|
+
};
|
|
6925
|
+
}
|
|
6926
|
+
function buildOpsScheduleAndWaitBody(options) {
|
|
6927
|
+
const waitBody = buildOpsWaitBody(options.wait);
|
|
6928
|
+
const { op_id: _opId, ...waitWithoutOp } = waitBody;
|
|
6929
|
+
return {
|
|
6930
|
+
...buildOpsCreateBody({
|
|
6931
|
+
...options.schedule,
|
|
6932
|
+
cadence: options.schedule.cadence ?? "daily"
|
|
6933
|
+
}),
|
|
6934
|
+
...waitWithoutOp,
|
|
6935
|
+
instruction: options.run.instruction,
|
|
6936
|
+
force: options.run.force
|
|
6937
|
+
};
|
|
6938
|
+
}
|
|
5647
6939
|
function buildOpsRunBody(params) {
|
|
5648
6940
|
const { opId, ...rest } = params;
|
|
5649
6941
|
return {
|
|
@@ -5651,6 +6943,28 @@ function buildOpsRunBody(params) {
|
|
|
5651
6943
|
op_id: rest.op_id ?? opId
|
|
5652
6944
|
};
|
|
5653
6945
|
}
|
|
6946
|
+
function buildOpsRunAndWaitOptions(params) {
|
|
6947
|
+
const {
|
|
6948
|
+
opId,
|
|
6949
|
+
nextCursor,
|
|
6950
|
+
includeFailedRuns,
|
|
6951
|
+
intervalMs,
|
|
6952
|
+
maxPolls,
|
|
6953
|
+
timeoutMs,
|
|
6954
|
+
includeResults,
|
|
6955
|
+
...rest
|
|
6956
|
+
} = params;
|
|
6957
|
+
return {
|
|
6958
|
+
...rest,
|
|
6959
|
+
op_id: rest.op_id ?? opId,
|
|
6960
|
+
cursor: rest.cursor ?? nextCursor,
|
|
6961
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
6962
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
6963
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
6964
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
6965
|
+
include_results: rest.include_results ?? includeResults
|
|
6966
|
+
};
|
|
6967
|
+
}
|
|
5654
6968
|
function buildOpsStatusBody(params) {
|
|
5655
6969
|
const { opId, ...rest } = params;
|
|
5656
6970
|
return {
|
|
@@ -5667,6 +6981,50 @@ function buildOpsResultsBody(params) {
|
|
|
5667
6981
|
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns
|
|
5668
6982
|
};
|
|
5669
6983
|
}
|
|
6984
|
+
function buildOpsWaitForResultsOptions(params) {
|
|
6985
|
+
const {
|
|
6986
|
+
opId,
|
|
6987
|
+
nextCursor,
|
|
6988
|
+
includeFailedRuns,
|
|
6989
|
+
intervalMs,
|
|
6990
|
+
maxPolls,
|
|
6991
|
+
timeoutMs,
|
|
6992
|
+
includeResults,
|
|
6993
|
+
...rest
|
|
6994
|
+
} = params;
|
|
6995
|
+
return {
|
|
6996
|
+
...rest,
|
|
6997
|
+
op_id: rest.op_id ?? opId,
|
|
6998
|
+
cursor: rest.cursor ?? nextCursor,
|
|
6999
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
7000
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
7001
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
7002
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
7003
|
+
include_results: rest.include_results ?? includeResults
|
|
7004
|
+
};
|
|
7005
|
+
}
|
|
7006
|
+
function buildOpsWaitBody(params) {
|
|
7007
|
+
const {
|
|
7008
|
+
opId,
|
|
7009
|
+
nextCursor,
|
|
7010
|
+
includeFailedRuns,
|
|
7011
|
+
intervalMs,
|
|
7012
|
+
maxPolls,
|
|
7013
|
+
timeoutMs,
|
|
7014
|
+
includeResults,
|
|
7015
|
+
...rest
|
|
7016
|
+
} = params;
|
|
7017
|
+
return {
|
|
7018
|
+
...rest,
|
|
7019
|
+
op_id: rest.op_id ?? opId,
|
|
7020
|
+
cursor: rest.cursor ?? nextCursor,
|
|
7021
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
7022
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
7023
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
7024
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
7025
|
+
include_results: rest.include_results ?? includeResults
|
|
7026
|
+
};
|
|
7027
|
+
}
|
|
5670
7028
|
function buildOpsDebugOptions(params) {
|
|
5671
7029
|
const {
|
|
5672
7030
|
opId,
|
|
@@ -5744,6 +7102,8 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5744
7102
|
nangoAction,
|
|
5745
7103
|
proxyPath,
|
|
5746
7104
|
nangoProxyPath,
|
|
7105
|
+
method,
|
|
7106
|
+
httpMethod,
|
|
5747
7107
|
fieldMap,
|
|
5748
7108
|
requiredFields,
|
|
5749
7109
|
writeConfirmed,
|
|
@@ -5762,6 +7122,7 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5762
7122
|
const nango_action = rest.nango_action ?? nangoAction;
|
|
5763
7123
|
const proxy_path = rest.proxy_path ?? proxyPath;
|
|
5764
7124
|
const nango_proxy_path = rest.nango_proxy_path ?? nangoProxyPath;
|
|
7125
|
+
const http_method = rest.http_method ?? httpMethod;
|
|
5765
7126
|
const field_map = rest.field_map ?? fieldMap;
|
|
5766
7127
|
const required_fields = rest.required_fields ?? requiredFields;
|
|
5767
7128
|
const write_confirmed = rest.write_confirmed ?? writeConfirmed;
|
|
@@ -5776,6 +7137,9 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5776
7137
|
if (nango_action !== void 0 && normalizedConfig.nango_action === void 0) normalizedConfig.nango_action = nango_action;
|
|
5777
7138
|
if (proxy_path !== void 0 && normalizedConfig.proxy_path === void 0) normalizedConfig.proxy_path = proxy_path;
|
|
5778
7139
|
if (nango_proxy_path !== void 0 && normalizedConfig.nango_proxy_path === void 0) normalizedConfig.nango_proxy_path = nango_proxy_path;
|
|
7140
|
+
if (method !== void 0 && normalizedConfig.method === void 0) normalizedConfig.method = method;
|
|
7141
|
+
if (http_method !== void 0 && normalizedConfig.http_method === void 0) normalizedConfig.http_method = http_method;
|
|
7142
|
+
if (normalizedConfig.method === void 0 && http_method !== void 0) normalizedConfig.method = http_method;
|
|
5779
7143
|
if (field_map !== void 0 && normalizedConfig.field_map === void 0) normalizedConfig.field_map = field_map;
|
|
5780
7144
|
if (required_fields !== void 0 && normalizedConfig.required_fields === void 0) normalizedConfig.required_fields = required_fields;
|
|
5781
7145
|
if (write_confirmed !== void 0 && normalizedConfig.write_confirmed === void 0) normalizedConfig.write_confirmed = write_confirmed;
|
|
@@ -5795,6 +7159,8 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5795
7159
|
nango_action,
|
|
5796
7160
|
proxy_path,
|
|
5797
7161
|
nango_proxy_path,
|
|
7162
|
+
method,
|
|
7163
|
+
http_method,
|
|
5798
7164
|
field_map,
|
|
5799
7165
|
required_fields,
|
|
5800
7166
|
write_confirmed,
|
|
@@ -5802,6 +7168,10 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5802
7168
|
config: normalizedConfig
|
|
5803
7169
|
};
|
|
5804
7170
|
}
|
|
7171
|
+
function normalizeOpsDestinationRequest(destination) {
|
|
7172
|
+
if (!destination || typeof destination !== "object" || Array.isArray(destination)) return destination;
|
|
7173
|
+
return normalizeOpsSinkRequest(destination);
|
|
7174
|
+
}
|
|
5805
7175
|
function normalizeOpsSinkConfigRequest(config) {
|
|
5806
7176
|
const out = { ...config ?? {} };
|
|
5807
7177
|
if (out.connection_id === void 0 && out.connectionId !== void 0) out.connection_id = out.connectionId;
|
|
@@ -5815,6 +7185,8 @@ function normalizeOpsSinkConfigRequest(config) {
|
|
|
5815
7185
|
if (out.nango_action === void 0 && out.nangoAction !== void 0) out.nango_action = out.nangoAction;
|
|
5816
7186
|
if (out.proxy_path === void 0 && out.proxyPath !== void 0) out.proxy_path = out.proxyPath;
|
|
5817
7187
|
if (out.nango_proxy_path === void 0 && out.nangoProxyPath !== void 0) out.nango_proxy_path = out.nangoProxyPath;
|
|
7188
|
+
if (out.http_method === void 0 && out.httpMethod !== void 0) out.http_method = out.httpMethod;
|
|
7189
|
+
if (out.method === void 0 && out.http_method !== void 0) out.method = out.http_method;
|
|
5818
7190
|
if (out.field_map === void 0 && out.fieldMap !== void 0) out.field_map = out.fieldMap;
|
|
5819
7191
|
if (out.required_fields === void 0 && out.requiredFields !== void 0) out.required_fields = out.requiredFields;
|
|
5820
7192
|
if (out.write_confirmed === void 0 && out.writeConfirmed !== void 0) out.write_confirmed = out.writeConfirmed;
|
|
@@ -5888,7 +7260,6 @@ function toSnakeConfig(params) {
|
|
|
5888
7260
|
return {
|
|
5889
7261
|
system_prompt: params.systemPrompt || params.system_prompt || "You are a senior business research analyst. Use multi-model evidence carefully and return concise structured enrichment.",
|
|
5890
7262
|
user_template: params.userTemplate || params.user_template || params.prompt,
|
|
5891
|
-
model: params.model,
|
|
5892
7263
|
temperature: params.temperature,
|
|
5893
7264
|
max_concurrency: params.maxConcurrency || params.max_concurrency,
|
|
5894
7265
|
max_tokens: params.maxTokens || params.max_tokens,
|
|
@@ -5912,13 +7283,10 @@ var Ai = class {
|
|
|
5912
7283
|
/**
|
|
5913
7284
|
* Run Custom AI Enrichment - Multi Model.
|
|
5914
7285
|
*
|
|
5915
|
-
* Uses
|
|
5916
|
-
*
|
|
7286
|
+
* Uses the hosted default model with bounded synthesis, then returns the
|
|
7287
|
+
* requested structured output fields.
|
|
5917
7288
|
*/
|
|
5918
7289
|
async multiModel(params) {
|
|
5919
|
-
if (!params.model) {
|
|
5920
|
-
throw new Error('model is required. Use an OpenRouter id such as "anthropic/claude-sonnet-4" or "google/gemini-2.5-flash".');
|
|
5921
|
-
}
|
|
5922
7290
|
if (!params.prompt && !params.userTemplate && !params.user_template) {
|
|
5923
7291
|
throw new Error("prompt or userTemplate is required.");
|
|
5924
7292
|
}
|
|
@@ -6135,6 +7503,10 @@ var GtmKernel = class {
|
|
|
6135
7503
|
days: options.days,
|
|
6136
7504
|
network_days: options.networkDays,
|
|
6137
7505
|
min_sample_size: options.minSampleSize,
|
|
7506
|
+
holdout_min_sample_size: options.holdoutMinSampleSize,
|
|
7507
|
+
predictive_min_labeled_outcomes: options.predictiveMinLabeledOutcomes,
|
|
7508
|
+
predictive_min_positive_outcomes: options.predictiveMinPositiveOutcomes,
|
|
7509
|
+
predictive_min_memory_sample_size: options.predictiveMinMemorySampleSize,
|
|
6138
7510
|
min_workspace_count: options.minWorkspaceCount,
|
|
6139
7511
|
min_privacy_k: options.minPrivacyK,
|
|
6140
7512
|
include_memory: options.includeMemory,
|
|
@@ -6201,9 +7573,11 @@ var GtmKernel = class {
|
|
|
6201
7573
|
write_routine_outcomes: input.writeRoutineOutcomes
|
|
6202
7574
|
});
|
|
6203
7575
|
}
|
|
6204
|
-
/** Start a background Instantly webhook-events pull and route results into the GTM feedback loop. */
|
|
7576
|
+
/** Start a background Instantly webhook-events or email-history pull and route results into the GTM feedback loop. */
|
|
6205
7577
|
async pullInstantlyFeedback(input) {
|
|
6206
7578
|
return this.callMcp("gtm_instantly_feedback_pull", {
|
|
7579
|
+
source: input.source,
|
|
7580
|
+
instantly_profile: input.instantlyProfile,
|
|
6207
7581
|
campaign_id: input.campaignId,
|
|
6208
7582
|
campaign_build_id: input.campaignBuildId,
|
|
6209
7583
|
provider_link_id: input.providerLinkId,
|
|
@@ -6215,6 +7589,9 @@ var GtmKernel = class {
|
|
|
6215
7589
|
to: input.to,
|
|
6216
7590
|
limit: input.limit,
|
|
6217
7591
|
max_pages: input.maxPages,
|
|
7592
|
+
email_type: input.emailType,
|
|
7593
|
+
mode: input.mode,
|
|
7594
|
+
sort_order: input.sortOrder,
|
|
6218
7595
|
create_memory: input.createMemory,
|
|
6219
7596
|
write_routine_outcomes: input.writeRoutineOutcomes,
|
|
6220
7597
|
dry_run: input.dryRun,
|
|
@@ -6344,6 +7721,7 @@ var GtmKernel = class {
|
|
|
6344
7721
|
days: input.days,
|
|
6345
7722
|
network_days: input.networkDays,
|
|
6346
7723
|
min_sample_size: input.minSampleSize,
|
|
7724
|
+
holdout_min_sample_size: input.holdoutMinSampleSize,
|
|
6347
7725
|
min_workspace_count: input.minWorkspaceCount,
|
|
6348
7726
|
min_privacy_k: input.minPrivacyK,
|
|
6349
7727
|
include_memory: input.includeMemory,
|
|
@@ -6364,6 +7742,7 @@ var GtmKernel = class {
|
|
|
6364
7742
|
days: input.days,
|
|
6365
7743
|
network_days: input.networkDays,
|
|
6366
7744
|
min_sample_size: input.minSampleSize,
|
|
7745
|
+
holdout_min_sample_size: input.holdoutMinSampleSize,
|
|
6367
7746
|
min_workspace_count: input.minWorkspaceCount,
|
|
6368
7747
|
min_privacy_k: input.minPrivacyK,
|
|
6369
7748
|
include_memory: input.includeMemory,
|
|
@@ -6488,6 +7867,29 @@ var GtmKernel = class {
|
|
|
6488
7867
|
include_details: options.includeDetails
|
|
6489
7868
|
});
|
|
6490
7869
|
}
|
|
7870
|
+
/** Search the Agency Autopilot safe-action catalog for agency-style lead lists, Clay tables, and GTM motions. */
|
|
7871
|
+
async agencyAutopilotCapabilityCatalog(options = {}) {
|
|
7872
|
+
return this.callMcp("gtm_agency_autopilot_capability_catalog", {
|
|
7873
|
+
query: options.query,
|
|
7874
|
+
family: options.family,
|
|
7875
|
+
phase: options.phase,
|
|
7876
|
+
account_label: options.accountLabel,
|
|
7877
|
+
workspace_label: options.workspaceLabel,
|
|
7878
|
+
target_count: options.targetCount,
|
|
7879
|
+
limit: options.limit,
|
|
7880
|
+
include_agent_prompts: options.includeAgentPrompts
|
|
7881
|
+
});
|
|
7882
|
+
}
|
|
7883
|
+
/** Search agency operating playbooks Agency Autopilot can use for lead lists, Clay tables, GTM motions, and proof gates. */
|
|
7884
|
+
async agencyAutopilotPlaybookCatalog(options = {}) {
|
|
7885
|
+
return this.callMcp("gtm_agency_autopilot_playbook_catalog", {
|
|
7886
|
+
query: options.query,
|
|
7887
|
+
playbook_slug: options.playbookSlug,
|
|
7888
|
+
outcome_type: options.outcomeType,
|
|
7889
|
+
limit: options.limit,
|
|
7890
|
+
include_required_fields: options.includeRequiredFields
|
|
7891
|
+
});
|
|
7892
|
+
}
|
|
6491
7893
|
/** Build the read-only Memory, Brain, risk, and provider-route runbook needed before planning a campaign. */
|
|
6492
7894
|
async campaignStartContext(input = {}) {
|
|
6493
7895
|
return this.callMcp("gtm_campaign_start_context", {
|
|
@@ -6846,6 +8248,35 @@ var GtmKernel = class {
|
|
|
6846
8248
|
user_display_name: input.userDisplayName
|
|
6847
8249
|
});
|
|
6848
8250
|
}
|
|
8251
|
+
/** Prepare the full Nango provider search, connect, pull/export, Ops, and campaign-route flow. */
|
|
8252
|
+
async prepareNangoIntegrationFlow(input = {}) {
|
|
8253
|
+
return this.callMcp("nango_integration_flow_prepare", {
|
|
8254
|
+
query: input.query,
|
|
8255
|
+
search: input.search,
|
|
8256
|
+
provider_id: input.providerId,
|
|
8257
|
+
provider: input.provider,
|
|
8258
|
+
integration_id: input.integrationId,
|
|
8259
|
+
provider_config_key: input.providerConfigKey,
|
|
8260
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
8261
|
+
connection_id: input.connectionId,
|
|
8262
|
+
nango_connection_id: input.nangoConnectionId,
|
|
8263
|
+
intent: input.intent,
|
|
8264
|
+
action_name: input.actionName,
|
|
8265
|
+
tool_name: input.toolName,
|
|
8266
|
+
proxy_path: input.proxyPath,
|
|
8267
|
+
method: input.method,
|
|
8268
|
+
input: input.input,
|
|
8269
|
+
cadence: input.cadence,
|
|
8270
|
+
field_map: input.fieldMap,
|
|
8271
|
+
required_fields: input.requiredFields,
|
|
8272
|
+
confirm_spend: input.confirmSpend,
|
|
8273
|
+
write_confirmed: input.writeConfirmed,
|
|
8274
|
+
layer: input.layer,
|
|
8275
|
+
campaign_id: input.campaignId,
|
|
8276
|
+
limit: input.limit,
|
|
8277
|
+
include_provider_catalog: input.includeProviderCatalog
|
|
8278
|
+
});
|
|
8279
|
+
}
|
|
6849
8280
|
/** List Nango-backed action tools for a workspace connection without executing them. */
|
|
6850
8281
|
async listNangoTools(options = {}) {
|
|
6851
8282
|
return this.callMcp("nango_mcp_tools_list", {
|
|
@@ -6868,6 +8299,12 @@ var GtmKernel = class {
|
|
|
6868
8299
|
nango_connection_id: input.nangoConnectionId,
|
|
6869
8300
|
action_name: input.actionName,
|
|
6870
8301
|
tool_name: input.toolName,
|
|
8302
|
+
delivery_mode: input.deliveryMode,
|
|
8303
|
+
proxy_path: input.proxyPath,
|
|
8304
|
+
nango_proxy_path: input.nangoProxyPath,
|
|
8305
|
+
method: input.method,
|
|
8306
|
+
http_method: input.httpMethod,
|
|
8307
|
+
proxy_headers: input.proxyHeaders,
|
|
6871
8308
|
input: input.input,
|
|
6872
8309
|
async: input.async,
|
|
6873
8310
|
max_retries: input.maxRetries,
|
|
@@ -7017,6 +8454,7 @@ function compact2(value) {
|
|
|
7017
8454
|
}
|
|
7018
8455
|
|
|
7019
8456
|
// src/index.ts
|
|
8457
|
+
var MCP_TOOL_CACHE_TTL_MS = 3e4;
|
|
7020
8458
|
function inferMcpToolCategory(toolName) {
|
|
7021
8459
|
if (typeof toolName !== "string" || !toolName) return void 0;
|
|
7022
8460
|
if (toolName.startsWith("ops_") || toolName === "get_ops_readiness" || toolName === "get_gtm_ops_readiness" || toolName.startsWith("gtm_") || [
|
|
@@ -7148,6 +8586,21 @@ var Signaliz = class {
|
|
|
7148
8586
|
}
|
|
7149
8587
|
/** List all available MCP tools */
|
|
7150
8588
|
async listTools() {
|
|
8589
|
+
const now = Date.now();
|
|
8590
|
+
if (this.toolListCache && this.toolListCache.expiresAt > now) {
|
|
8591
|
+
return this.toolListCache.promise;
|
|
8592
|
+
}
|
|
8593
|
+
const promise = this.fetchTools().catch((error) => {
|
|
8594
|
+
if (this.toolListCache?.promise === promise) this.toolListCache = void 0;
|
|
8595
|
+
throw error;
|
|
8596
|
+
});
|
|
8597
|
+
this.toolListCache = {
|
|
8598
|
+
expiresAt: now + MCP_TOOL_CACHE_TTL_MS,
|
|
8599
|
+
promise
|
|
8600
|
+
};
|
|
8601
|
+
return promise;
|
|
8602
|
+
}
|
|
8603
|
+
async fetchTools() {
|
|
7151
8604
|
try {
|
|
7152
8605
|
const manifest = await this.client.mcp("tools/call", {
|
|
7153
8606
|
name: "get_tool_manifest",
|