@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
|
@@ -212,25 +212,31 @@ var HttpClient = class {
|
|
|
212
212
|
async getToken() {
|
|
213
213
|
if (this.apiKey) return this.apiKey;
|
|
214
214
|
if (this.accessToken) return this.accessToken;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
throw new SignalizError({
|
|
226
|
-
code: "AUTH_FAILED",
|
|
227
|
-
message: "Failed to obtain access token",
|
|
228
|
-
errorType: "auth_expired"
|
|
215
|
+
if (this.accessTokenPromise) return this.accessTokenPromise;
|
|
216
|
+
this.accessTokenPromise = (async () => {
|
|
217
|
+
const res = await fetch("https://api.signaliz.com/token", {
|
|
218
|
+
method: "POST",
|
|
219
|
+
headers: { "Content-Type": "application/json" },
|
|
220
|
+
body: JSON.stringify({
|
|
221
|
+
grant_type: "client_credentials",
|
|
222
|
+
client_id: this.clientId,
|
|
223
|
+
client_secret: this.clientSecret
|
|
224
|
+
})
|
|
229
225
|
});
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
226
|
+
if (!res.ok) {
|
|
227
|
+
throw new SignalizError({
|
|
228
|
+
code: "AUTH_FAILED",
|
|
229
|
+
message: "Failed to obtain access token",
|
|
230
|
+
errorType: "auth_expired"
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
const data = await res.json();
|
|
234
|
+
this.accessToken = data.access_token;
|
|
235
|
+
return this.accessToken;
|
|
236
|
+
})().finally(() => {
|
|
237
|
+
this.accessTokenPromise = void 0;
|
|
238
|
+
});
|
|
239
|
+
return this.accessTokenPromise;
|
|
234
240
|
}
|
|
235
241
|
};
|
|
236
242
|
function sleep(ms) {
|
|
@@ -479,7 +485,6 @@ var Signals = class {
|
|
|
479
485
|
if (params.online !== void 0) args.online = params.online;
|
|
480
486
|
if (params.targetSignalCount) args.target_signal_count = params.targetSignalCount;
|
|
481
487
|
if (params.lookbackDays) args.lookback_days = params.lookbackDays;
|
|
482
|
-
if (params.model) args.model = params.model;
|
|
483
488
|
if (params.enableDeepSearch) args.enable_deep_search = params.enableDeepSearch;
|
|
484
489
|
if (params.enableOutreachIntelligence) args.enable_outreach_intelligence = params.enableOutreachIntelligence;
|
|
485
490
|
if (params.enablePredictiveIntelligence) args.enable_predictive_intelligence = params.enablePredictiveIntelligence;
|
|
@@ -774,6 +779,10 @@ var Campaigns = class {
|
|
|
774
779
|
async artifacts(campaignBuildId) {
|
|
775
780
|
return this.listCampaignBuildArtifacts(campaignBuildId);
|
|
776
781
|
}
|
|
782
|
+
/** Generate fresh signed URLs for a downloadable campaign artifact. */
|
|
783
|
+
async downloadArtifact(campaignBuildId, options) {
|
|
784
|
+
return this.downloadCampaignArtifact(campaignBuildId, options);
|
|
785
|
+
}
|
|
777
786
|
/** Cancel a queued or running build. */
|
|
778
787
|
async cancel(campaignBuildId, reason) {
|
|
779
788
|
return this.cancelCampaignBuild(campaignBuildId, reason);
|
|
@@ -818,12 +827,16 @@ var Campaigns = class {
|
|
|
818
827
|
dryRun: isDryRun,
|
|
819
828
|
requestedTargetCount: data.requested_target_count,
|
|
820
829
|
plannedTargetCount: data.planned_target_count,
|
|
830
|
+
acquisitionMode: data.acquisition_mode,
|
|
831
|
+
acquisitionSource: data.acquisition_source,
|
|
832
|
+
cacheReusePolicy: data.cache_reuse_policy,
|
|
821
833
|
estimatedCredits: data.estimated_credits,
|
|
822
834
|
estimatedDurationSeconds: data.estimated_duration_seconds,
|
|
823
835
|
targetLimitApplied: data.target_limit_applied,
|
|
824
836
|
targetLimitReason: data.target_limit_reason,
|
|
825
837
|
maxSupportedTargetCount: data.max_supported_target_count,
|
|
826
838
|
brainContext: data.brain_context ?? {},
|
|
839
|
+
learningHoldout: data.learning_holdout ?? {},
|
|
827
840
|
providerRoute: mapProviderRoute(data)
|
|
828
841
|
};
|
|
829
842
|
}
|
|
@@ -839,14 +852,24 @@ var Campaigns = class {
|
|
|
839
852
|
});
|
|
840
853
|
return (data.artifacts ?? []).map(mapArtifact);
|
|
841
854
|
}
|
|
855
|
+
async downloadCampaignArtifact(campaignBuildId, options) {
|
|
856
|
+
const args = { campaign_build_id: campaignBuildId };
|
|
857
|
+
if (options?.format) args.format = options.format;
|
|
858
|
+
const data = await this.callMcp("download_campaign_artifact", args);
|
|
859
|
+
return mapArtifactDownloadResult(data);
|
|
860
|
+
}
|
|
842
861
|
async getCampaignBuildRows(campaignBuildId, options) {
|
|
843
862
|
const args = { campaign_build_id: campaignBuildId };
|
|
844
863
|
if (options?.limit) args.page_size = options.limit;
|
|
845
864
|
if (options?.cursor) args.cursor = options.cursor;
|
|
865
|
+
if (options?.includeData !== void 0) args.include_data = options.includeData;
|
|
866
|
+
if (options?.includeRaw !== void 0) args.include_raw = options.includeRaw;
|
|
846
867
|
const filters = {};
|
|
847
868
|
if (options?.segment) filters.segment = options.segment;
|
|
848
869
|
if (options?.rowStatus) filters.row_status = options.rowStatus;
|
|
849
870
|
if (options?.qualified !== void 0) filters.qualified = options.qualified;
|
|
871
|
+
if (options?.cached !== void 0) filters.cached = options.cached;
|
|
872
|
+
if (options?.exportReady !== void 0) filters.export_ready = options.exportReady;
|
|
850
873
|
if (Object.keys(filters).length > 0) args.filters = filters;
|
|
851
874
|
const data = await this.callMcp("get_campaign_build_rows", args);
|
|
852
875
|
return {
|
|
@@ -871,6 +894,7 @@ var Campaigns = class {
|
|
|
871
894
|
};
|
|
872
895
|
if (options?.destinationId) args.destination_id = options.destinationId;
|
|
873
896
|
if (options?.destinationConfig) args.destination_config = options.destinationConfig;
|
|
897
|
+
if (options?.allowPartialDelivery === true) args.allow_partial_delivery = true;
|
|
874
898
|
const data = await this.callMcp("approve_campaign_delivery", args);
|
|
875
899
|
return {
|
|
876
900
|
campaignBuildId: data.campaign_build_id,
|
|
@@ -879,7 +903,10 @@ var Campaigns = class {
|
|
|
879
903
|
message: data.message ?? "",
|
|
880
904
|
deliveryId: data.delivery_id,
|
|
881
905
|
deliveryIds: data.delivery_ids,
|
|
882
|
-
approvedCount: data.approved_count
|
|
906
|
+
approvedCount: data.approved_count,
|
|
907
|
+
partialDelivery: data.partial_delivery,
|
|
908
|
+
effectiveTargetCount: data.effective_target_count,
|
|
909
|
+
requestedTargetCount: data.requested_target_count
|
|
883
910
|
};
|
|
884
911
|
}
|
|
885
912
|
async cancelCampaignBuild(campaignBuildId, reason) {
|
|
@@ -932,17 +959,50 @@ function mapStatus(data) {
|
|
|
932
959
|
warnings: diagnosticMessages(data.warnings),
|
|
933
960
|
errors: diagnosticMessages(data.errors),
|
|
934
961
|
artifactCount: data.artifact_count ?? 0,
|
|
962
|
+
artifactDownloads: Array.isArray(data.artifact_downloads) ? data.artifact_downloads.map(mapArtifactDownload) : [],
|
|
963
|
+
customerRowCounts: mapCustomerRowCounts(data.customer_row_counts),
|
|
964
|
+
phaseAttemptTotals: recordOrNull(data.phase_attempt_totals) ?? void 0,
|
|
935
965
|
providerRoute: mapProviderRoute(data),
|
|
936
966
|
triggerRunId: typeof data.trigger_run_id === "string" ? data.trigger_run_id : null,
|
|
937
967
|
staleRunningPhase: data.stale_running_phase === true,
|
|
938
968
|
phaseAgeSeconds: numberOrNull(data.phase_age_seconds),
|
|
939
969
|
diagnostics: recordOrNull(data.diagnostics) ?? {},
|
|
940
970
|
nextAction: formatNextAction(data.next_action),
|
|
971
|
+
approvalAction: formatNextAction(data.approval_action),
|
|
941
972
|
createdAt: data.created_at,
|
|
942
973
|
updatedAt: data.updated_at,
|
|
943
974
|
completedAt: data.completed_at
|
|
944
975
|
};
|
|
945
976
|
}
|
|
977
|
+
function mapCustomerRowCounts(value) {
|
|
978
|
+
const record = recordOrNull(value);
|
|
979
|
+
if (!record) return void 0;
|
|
980
|
+
return {
|
|
981
|
+
requestedTarget: numberOrNull(record.requested_target),
|
|
982
|
+
acquiredRows: numberOrNull(record.acquired_rows) ?? void 0,
|
|
983
|
+
acceptedRows: numberOrNull(record.accepted_rows) ?? void 0,
|
|
984
|
+
usableRows: numberOrNull(record.usable_rows) ?? void 0,
|
|
985
|
+
copiedRows: numberOrNull(record.copied_rows) ?? void 0,
|
|
986
|
+
approvalReadyRows: numberOrNull(record.approval_ready_rows) ?? void 0,
|
|
987
|
+
qaReadyRows: numberOrNull(record.qa_ready_rows) ?? void 0,
|
|
988
|
+
deliveredRows: numberOrNull(record.delivered_rows) ?? void 0,
|
|
989
|
+
disqualifiedRows: numberOrNull(record.disqualified_rows) ?? void 0,
|
|
990
|
+
reviewableRows: numberOrNull(record.reviewable_rows) ?? void 0,
|
|
991
|
+
rowFailures: numberOrNull(record.row_failures) ?? void 0,
|
|
992
|
+
acceptedShortfall: numberOrNull(record.accepted_shortfall),
|
|
993
|
+
usableShortfall: numberOrNull(record.usable_shortfall),
|
|
994
|
+
qaReadyShortfall: numberOrNull(record.qa_ready_shortfall),
|
|
995
|
+
deliveryShortfall: numberOrNull(record.delivery_shortfall),
|
|
996
|
+
fillRatio: numberOrNull(record.fill_ratio),
|
|
997
|
+
qaReadyFillRatio: numberOrNull(record.qa_ready_fill_ratio),
|
|
998
|
+
deliveredFillRatio: numberOrNull(record.delivered_fill_ratio),
|
|
999
|
+
terminalReason: typeof record.terminal_reason === "string" ? record.terminal_reason : null,
|
|
1000
|
+
acceptedShortfallReason: typeof record.accepted_shortfall_reason === "string" ? record.accepted_shortfall_reason : null,
|
|
1001
|
+
usableShortfallReason: typeof record.usable_shortfall_reason === "string" ? record.usable_shortfall_reason : null,
|
|
1002
|
+
qaReadyShortfallReason: typeof record.qa_ready_shortfall_reason === "string" ? record.qa_ready_shortfall_reason : null,
|
|
1003
|
+
deliveryShortfallReason: typeof record.delivery_shortfall_reason === "string" ? record.delivery_shortfall_reason : null
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
946
1006
|
function mapProviderRoute(data) {
|
|
947
1007
|
const brainContext = recordOrNull(data?.brain_context);
|
|
948
1008
|
const plan = recordOrNull(data?.provider_route_plan) ?? recordOrNull(brainContext?.provider_route_plan);
|
|
@@ -1020,13 +1080,56 @@ function mapArtifact(a) {
|
|
|
1020
1080
|
artifactType: a.artifact_type,
|
|
1021
1081
|
destination: a.destination,
|
|
1022
1082
|
storagePath: a.storage_path,
|
|
1083
|
+
format: a.format ?? null,
|
|
1023
1084
|
signedUrl: a.signed_url,
|
|
1085
|
+
downloadUrl: a.download_url ?? null,
|
|
1086
|
+
manifestUrl: a.manifest_url ?? null,
|
|
1087
|
+
expiresAt: a.expires_at ?? null,
|
|
1024
1088
|
rowCount: a.row_count ?? 0,
|
|
1025
1089
|
checksum: a.checksum,
|
|
1026
1090
|
metadata: a.metadata ?? {},
|
|
1027
1091
|
createdAt: a.created_at
|
|
1028
1092
|
};
|
|
1029
1093
|
}
|
|
1094
|
+
function mapArtifactDownload(data) {
|
|
1095
|
+
return {
|
|
1096
|
+
id: data.id,
|
|
1097
|
+
artifactType: data.artifact_type ?? null,
|
|
1098
|
+
format: data.format ?? null,
|
|
1099
|
+
rowCount: data.row_count ?? 0,
|
|
1100
|
+
signedUrl: data.signed_url ?? null,
|
|
1101
|
+
downloadUrl: data.download_url ?? null,
|
|
1102
|
+
manifestUrl: data.manifest_url ?? null,
|
|
1103
|
+
expiresAt: data.expires_at ?? null
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
function mapArtifactDownloadResult(data) {
|
|
1107
|
+
return {
|
|
1108
|
+
campaignBuildId: data.campaign_build_id,
|
|
1109
|
+
artifactId: data.artifact_id,
|
|
1110
|
+
format: data.format,
|
|
1111
|
+
rowCount: data.row_count ?? 0,
|
|
1112
|
+
byteSize: numberOrNull(data.byte_size),
|
|
1113
|
+
partCount: data.part_count ?? 0,
|
|
1114
|
+
checksum: data.checksum ?? null,
|
|
1115
|
+
signedUrl: data.signed_url ?? null,
|
|
1116
|
+
downloadUrl: data.download_url ?? null,
|
|
1117
|
+
manifestUrl: data.manifest_url ?? null,
|
|
1118
|
+
expiresAt: data.expires_at ?? null,
|
|
1119
|
+
parts: Array.isArray(data.parts) ? data.parts.map(mapArtifactDownloadPart) : [],
|
|
1120
|
+
downloadCommands: recordOrNull(data.download_commands) ?? {},
|
|
1121
|
+
expiresInSeconds: numberOrNull(data.expires_in_seconds)
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
function mapArtifactDownloadPart(data) {
|
|
1125
|
+
return {
|
|
1126
|
+
partIndex: data.part_index ?? 0,
|
|
1127
|
+
rowCount: data.row_count ?? 0,
|
|
1128
|
+
byteSize: numberOrNull(data.byte_size),
|
|
1129
|
+
checksum: data.checksum ?? null,
|
|
1130
|
+
signedUrl: data.signed_url ?? null
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1030
1133
|
function mapScope(data) {
|
|
1031
1134
|
return {
|
|
1032
1135
|
campaignScopeId: data.campaign_scope_id,
|
|
@@ -1080,8 +1183,29 @@ function buildArgs(request) {
|
|
|
1080
1183
|
if (request.allowDownscale !== void 0) args.allow_downscale = request.allowDownscale;
|
|
1081
1184
|
if (request.confirmSpend !== void 0) args.confirm_spend = request.confirmSpend;
|
|
1082
1185
|
if (request.dedupKeys) args.dedup_keys = request.dedupKeys;
|
|
1186
|
+
if (request.acquisitionMode) args.acquisition_mode = request.acquisitionMode;
|
|
1187
|
+
if (request.cacheReusePolicy) {
|
|
1188
|
+
args.cache_reuse_policy = {
|
|
1189
|
+
allow_verified_cache: request.cacheReusePolicy.allowVerifiedCache,
|
|
1190
|
+
suppress_prior_campaign_ids: request.cacheReusePolicy.suppressPriorCampaignIds,
|
|
1191
|
+
suppress_prior_list_ids: request.cacheReusePolicy.suppressPriorListIds,
|
|
1192
|
+
uniqueness: request.cacheReusePolicy.uniqueness,
|
|
1193
|
+
require_usage_metadata: request.cacheReusePolicy.requireUsageMetadata
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1083
1196
|
if (request.brainPreflight) args.brain_preflight = request.brainPreflight;
|
|
1084
1197
|
if (request.brainDefaults) args.brain_defaults = request.brainDefaults;
|
|
1198
|
+
if (request.learningHoldout) {
|
|
1199
|
+
args.learning_holdout = {
|
|
1200
|
+
enabled: request.learningHoldout.enabled,
|
|
1201
|
+
control_percentage: request.learningHoldout.controlPercentage,
|
|
1202
|
+
min_control_size: request.learningHoldout.minControlSize,
|
|
1203
|
+
experiment_key: request.learningHoldout.experimentKey,
|
|
1204
|
+
source_campaign_id: request.learningHoldout.sourceCampaignId,
|
|
1205
|
+
primary_metric: request.learningHoldout.primaryMetric
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
if (request.campaignStrategyContext) args.campaign_strategy_context = request.campaignStrategyContext;
|
|
1085
1209
|
if (request.deliveryRisk) args.delivery_risk = request.deliveryRisk;
|
|
1086
1210
|
if (request.icp) {
|
|
1087
1211
|
args.icp = {
|
|
@@ -1123,7 +1247,17 @@ function buildArgs(request) {
|
|
|
1123
1247
|
max_body_words: request.copy.maxBodyWords,
|
|
1124
1248
|
sender_context: request.copy.senderContext,
|
|
1125
1249
|
offer_context: request.copy.offerContext,
|
|
1126
|
-
model: request.copy.model
|
|
1250
|
+
model: request.copy.model,
|
|
1251
|
+
style_source: request.copy.styleSource ? {
|
|
1252
|
+
sample_text: request.copy.styleSource.sampleText,
|
|
1253
|
+
campaign_ids: request.copy.styleSource.campaignIds,
|
|
1254
|
+
artifact_ids: request.copy.styleSource.artifactIds
|
|
1255
|
+
} : void 0,
|
|
1256
|
+
sequence_steps: request.copy.sequenceSteps,
|
|
1257
|
+
copy_schema: request.copy.copySchema,
|
|
1258
|
+
banned_phrases: request.copy.bannedPhrases,
|
|
1259
|
+
approval_required: request.copy.approvalRequired,
|
|
1260
|
+
quality_tier: request.copy.qualityTier
|
|
1127
1261
|
};
|
|
1128
1262
|
}
|
|
1129
1263
|
if (request.delivery) {
|
|
@@ -1186,6 +1320,8 @@ var DEFAULT_SIGNALIZ_CAMPAIGN_BUILDER_DEFAULTS = {
|
|
|
1186
1320
|
}
|
|
1187
1321
|
};
|
|
1188
1322
|
var DEFAULT_CAMPAIGN_BUILDER_BUILT_INS = [
|
|
1323
|
+
"company_discovery",
|
|
1324
|
+
"people_discovery",
|
|
1189
1325
|
"lead_generation",
|
|
1190
1326
|
"email_finding",
|
|
1191
1327
|
"email_verification",
|
|
@@ -1194,6 +1330,8 @@ var DEFAULT_CAMPAIGN_BUILDER_BUILT_INS = [
|
|
|
1194
1330
|
var CAMPAIGN_BUILDER_BUILT_IN_ROUTE_IDS = {
|
|
1195
1331
|
lead_generation: "signaliz-lead-generation",
|
|
1196
1332
|
local_leads: "signaliz-local-leads",
|
|
1333
|
+
company_discovery: "signaliz-company-discovery",
|
|
1334
|
+
people_discovery: "signaliz-people-discovery",
|
|
1197
1335
|
email_finding: "signaliz-email-finding",
|
|
1198
1336
|
email_verification: "signaliz-email-verification",
|
|
1199
1337
|
signals: "signaliz-signals"
|
|
@@ -1211,8 +1349,8 @@ var CAMPAIGN_BUILDER_OPERATING_PLAYBOOKS = [
|
|
|
1211
1349
|
slug: "cache-first-large-list",
|
|
1212
1350
|
label: "Cache-First Large List",
|
|
1213
1351
|
whenToUse: [
|
|
1214
|
-
"The
|
|
1215
|
-
"The deliverable is a
|
|
1352
|
+
"The operator explicitly references a previous campaign, prior list, seed list, or suppression baseline.",
|
|
1353
|
+
"The deliverable is a top-up, continuation, or backfill where prior campaign context should guide reuse."
|
|
1216
1354
|
],
|
|
1217
1355
|
sequence: [
|
|
1218
1356
|
"Inventory reusable cache before paid sourcing.",
|
|
@@ -1418,7 +1556,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1418
1556
|
],
|
|
1419
1557
|
requireVerifiedEmail: true
|
|
1420
1558
|
},
|
|
1421
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1559
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1422
1560
|
preferredProviders: ["signaliz_native"],
|
|
1423
1561
|
memoryQueries: [{
|
|
1424
1562
|
query: "industrial OT net-new prior email suppression verified manufacturing embedded systems field service cyber resilience business continuity",
|
|
@@ -1492,7 +1630,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1492
1630
|
],
|
|
1493
1631
|
requireVerifiedEmail: true
|
|
1494
1632
|
},
|
|
1495
|
-
builtIns: ["lead_generation", "local_leads", "email_finding", "email_verification", "signals"],
|
|
1633
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "local_leads", "email_finding", "email_verification", "signals"],
|
|
1496
1634
|
preferredProviders: ["signaliz_native", "octave", "clay_webhook", "apify"],
|
|
1497
1635
|
memoryQueries: [{
|
|
1498
1636
|
query: "mature non-medical home care agencies billable hours franchise caregiver recruiting proof gate qualification export approval",
|
|
@@ -1558,7 +1696,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1558
1696
|
exclusions: ["enterprise holding company", "staffing", "recruiting", "software-only vendor", "freelancer-only profile"],
|
|
1559
1697
|
requireVerifiedEmail: true
|
|
1560
1698
|
},
|
|
1561
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1699
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1562
1700
|
preferredProviders: ["signaliz_native", "octave"],
|
|
1563
1701
|
memoryQueries: [{
|
|
1564
1702
|
query: "agency founder owner CEO marketing services suppression domain pool email verification final approval gate",
|
|
@@ -1640,7 +1778,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1640
1778
|
],
|
|
1641
1779
|
requireVerifiedEmail: true
|
|
1642
1780
|
},
|
|
1643
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1781
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1644
1782
|
preferredProviders: ["signaliz_native", "octave"],
|
|
1645
1783
|
memoryQueries: [{
|
|
1646
1784
|
query: "cloud hosting infrastructure VMware Broadcom qualification verified email persona trigger SKU mapping",
|
|
@@ -1673,25 +1811,21 @@ var CampaignBuilderAgent = class {
|
|
|
1673
1811
|
async createPlan(request, options = {}) {
|
|
1674
1812
|
const resolvedRequest = applyCampaignBuilderStrategyTemplate(request);
|
|
1675
1813
|
const warnings = [];
|
|
1676
|
-
const workspaceContext =
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1814
|
+
const [workspaceContext, scopeResult] = await Promise.all([
|
|
1815
|
+
resolvedRequest.workspaceContext ? Promise.resolve(resolvedRequest.workspaceContext) : this.getWorkspaceContext(warnings),
|
|
1816
|
+
options.scopeCampaign === false ? Promise.resolve(void 0) : this.scopeCampaign(resolvedRequest, warnings),
|
|
1817
|
+
options.discoverCapabilities === false ? Promise.resolve(void 0) : this.discoverPlannedRoutes(resolvedRequest, warnings)
|
|
1818
|
+
]);
|
|
1681
1819
|
const plan = createCampaignBuilderAgentPlan(resolvedRequest, {
|
|
1682
1820
|
workspaceContext,
|
|
1683
1821
|
scopeBuildArgs: asRecord(scopeResult?.build_campaign_args ?? scopeResult?.buildCampaignArgs),
|
|
1684
1822
|
warnings
|
|
1685
1823
|
});
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
}
|
|
1692
|
-
if (options.includeDeliveryRisk !== false) {
|
|
1693
|
-
await this.attachDeliveryRiskPreflight(plan, warnings);
|
|
1694
|
-
}
|
|
1824
|
+
await Promise.all([
|
|
1825
|
+
options.includeStrategyMemoryStatus === false ? Promise.resolve() : this.attachStrategyMemoryStatus(plan, warnings),
|
|
1826
|
+
options.includeKernelPlan === false ? Promise.resolve() : this.attachKernelCampaignBuildPlan(plan, warnings),
|
|
1827
|
+
options.includeDeliveryRisk === false ? Promise.resolve() : this.attachDeliveryRiskPreflight(plan, warnings)
|
|
1828
|
+
]);
|
|
1695
1829
|
return plan;
|
|
1696
1830
|
}
|
|
1697
1831
|
async readiness(request, options = {}) {
|
|
@@ -1739,6 +1873,7 @@ var CampaignBuilderAgent = class {
|
|
|
1739
1873
|
},
|
|
1740
1874
|
brain_defaults: plan.buildRequest.brainDefaults,
|
|
1741
1875
|
brain_preflight: plan.buildRequest.brainPreflight,
|
|
1876
|
+
campaign_strategy_context: plan.buildRequest.campaignStrategyContext,
|
|
1742
1877
|
delivery_risk_preflight: plan.buildRequest.deliveryRisk,
|
|
1743
1878
|
delivery_risk: plan.buildRequest.deliveryRisk
|
|
1744
1879
|
}),
|
|
@@ -1860,7 +1995,8 @@ var CampaignBuilderAgent = class {
|
|
|
1860
1995
|
const destinationType = options.deliveryDestinationType ?? plan.buildRequest.delivery?.destinationType ?? "json";
|
|
1861
1996
|
result.deliveryApproval = await this.approveCampaignDelivery(campaignBuildId, destinationType, {
|
|
1862
1997
|
destinationId: options.deliveryDestinationId,
|
|
1863
|
-
destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig
|
|
1998
|
+
destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig,
|
|
1999
|
+
allowPartialDelivery: options.allowPartialDelivery
|
|
1864
2000
|
});
|
|
1865
2001
|
finalStatus = await this.waitForCampaignBuildStatus(
|
|
1866
2002
|
campaignBuildId,
|
|
@@ -1883,8 +2019,12 @@ var CampaignBuilderAgent = class {
|
|
|
1883
2019
|
const args = compact({
|
|
1884
2020
|
campaign_build_id: campaignBuildId,
|
|
1885
2021
|
page_size: options.limit,
|
|
1886
|
-
cursor: options.cursor
|
|
2022
|
+
cursor: options.cursor,
|
|
2023
|
+
include_data: options.includeData,
|
|
2024
|
+
include_raw: options.includeRaw
|
|
1887
2025
|
});
|
|
2026
|
+
if (options.cached !== void 0) filters.cached = options.cached;
|
|
2027
|
+
if (options.exportReady !== void 0) filters.export_ready = options.exportReady;
|
|
1888
2028
|
if (Object.keys(filters).length > 0) args.filters = filters;
|
|
1889
2029
|
const data = await this.callMcp("get_campaign_build_rows", args);
|
|
1890
2030
|
return mapAgentCampaignRowsResult(data);
|
|
@@ -1899,12 +2039,14 @@ var CampaignBuilderAgent = class {
|
|
|
1899
2039
|
return this.approveCampaignDelivery(campaignBuildId, destinationType, options);
|
|
1900
2040
|
}
|
|
1901
2041
|
async reviewBuild(campaignBuildId, options = {}) {
|
|
1902
|
-
const status = await
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
2042
|
+
const [status, rows, artifacts] = await Promise.all([
|
|
2043
|
+
this.getBuildStatus(campaignBuildId),
|
|
2044
|
+
this.getBuildRows(campaignBuildId, {
|
|
2045
|
+
...options,
|
|
2046
|
+
limit: options.limit ?? 100
|
|
2047
|
+
}),
|
|
2048
|
+
this.listBuildArtifacts(campaignBuildId)
|
|
2049
|
+
]);
|
|
1908
2050
|
return createCampaignBuilderBuildReview(status, rows, artifacts);
|
|
1909
2051
|
}
|
|
1910
2052
|
async getCampaignBuildStatus(campaignBuildId) {
|
|
@@ -1932,7 +2074,8 @@ var CampaignBuilderAgent = class {
|
|
|
1932
2074
|
campaign_build_id: campaignBuildId,
|
|
1933
2075
|
destination_type: destinationType,
|
|
1934
2076
|
destination_id: options?.destinationId,
|
|
1935
|
-
destination_config: options?.destinationConfig
|
|
2077
|
+
destination_config: options?.destinationConfig,
|
|
2078
|
+
allow_partial_delivery: options?.allowPartialDelivery === true ? true : void 0
|
|
1936
2079
|
});
|
|
1937
2080
|
const data = await this.callMcp("approve_campaign_delivery", args);
|
|
1938
2081
|
return {
|
|
@@ -1942,7 +2085,10 @@ var CampaignBuilderAgent = class {
|
|
|
1942
2085
|
message: data.message ?? "",
|
|
1943
2086
|
deliveryId: data.delivery_id,
|
|
1944
2087
|
deliveryIds: data.delivery_ids,
|
|
1945
|
-
approvedCount: data.approved_count
|
|
2088
|
+
approvedCount: data.approved_count,
|
|
2089
|
+
partialDelivery: data.partial_delivery,
|
|
2090
|
+
effectiveTargetCount: data.effective_target_count,
|
|
2091
|
+
requestedTargetCount: data.requested_target_count
|
|
1946
2092
|
};
|
|
1947
2093
|
}
|
|
1948
2094
|
async getWorkspaceContext(warnings) {
|
|
@@ -1978,15 +2124,19 @@ var CampaignBuilderAgent = class {
|
|
|
1978
2124
|
const providers = new Set(
|
|
1979
2125
|
[...request.integrations ?? [], ...routesFromCustomerTools(request.customerTools ?? [])].filter((route) => route.provider !== "signaliz").map((route) => route.provider)
|
|
1980
2126
|
);
|
|
1981
|
-
|
|
2127
|
+
const warningsByProvider = await Promise.all(Array.from(providers, async (provider) => {
|
|
1982
2128
|
try {
|
|
1983
2129
|
await this.callMcp("discover_capabilities", {
|
|
1984
2130
|
query: `campaign builder ${provider} ${request.goal}`,
|
|
1985
2131
|
category: "campaign"
|
|
1986
2132
|
});
|
|
2133
|
+
return void 0;
|
|
1987
2134
|
} catch (error) {
|
|
1988
|
-
|
|
2135
|
+
return `Capability discovery for ${provider} failed: ${errorMessage(error)}`;
|
|
1989
2136
|
}
|
|
2137
|
+
}));
|
|
2138
|
+
for (const warning of warningsByProvider) {
|
|
2139
|
+
if (warning) warnings.push(warning);
|
|
1990
2140
|
}
|
|
1991
2141
|
}
|
|
1992
2142
|
async attachStrategyMemoryStatus(plan, warnings) {
|
|
@@ -2010,8 +2160,24 @@ var CampaignBuilderAgent = class {
|
|
|
2010
2160
|
const kernelPlan = await this.callMcp("gtm_campaign_build_plan", asRecord(plannerStep.arguments));
|
|
2011
2161
|
plan.kernelPlan = asRecord(kernelPlan);
|
|
2012
2162
|
const brainDefaults = asRecord(plan.kernelPlan.brain_defaults ?? plan.kernelPlan.brainDefaults);
|
|
2163
|
+
const corpusContext = asRecord(plan.kernelPlan.corpus_context ?? plan.kernelPlan.corpusContext);
|
|
2164
|
+
const campaignStrategyContext = asRecord(plan.kernelPlan.campaign_strategy_context ?? plan.kernelPlan.campaignStrategyContext);
|
|
2165
|
+
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) : [];
|
|
2013
2166
|
if (Object.keys(brainDefaults).length > 0 && Object.keys(asRecord(plan.buildRequest.brainDefaults)).length === 0) {
|
|
2014
2167
|
plan.buildRequest.brainDefaults = brainDefaults;
|
|
2168
|
+
}
|
|
2169
|
+
if (Object.keys(campaignStrategyContext).length > 0) {
|
|
2170
|
+
plan.buildRequest.campaignStrategyContext = campaignStrategyContext;
|
|
2171
|
+
}
|
|
2172
|
+
if (Object.keys(corpusContext).length > 0 || memoryExamples.length > 0 || Object.keys(brainDefaults).length > 0 || Object.keys(campaignStrategyContext).length > 0) {
|
|
2173
|
+
plan.buildRequest.brainPreflight = compact({
|
|
2174
|
+
...asRecord(plan.buildRequest.brainPreflight),
|
|
2175
|
+
corpus_context: Object.keys(corpusContext).length > 0 ? corpusContext : void 0,
|
|
2176
|
+
memory_examples: memoryExamples.length > 0 ? memoryExamples : void 0,
|
|
2177
|
+
brain_defaults: Object.keys(brainDefaults).length > 0 ? brainDefaults : void 0,
|
|
2178
|
+
campaign_strategy_context: Object.keys(campaignStrategyContext).length > 0 ? campaignStrategyContext : void 0
|
|
2179
|
+
});
|
|
2180
|
+
plan.brainPreflight = asRecord(plan.buildRequest.brainPreflight);
|
|
2015
2181
|
refreshBuildStepArguments(plan);
|
|
2016
2182
|
}
|
|
2017
2183
|
} catch (error) {
|
|
@@ -2192,6 +2358,9 @@ function createCampaignBuilderProofReceipt(plan, result) {
|
|
|
2192
2358
|
campaign_build_id: dryRunResult.campaignBuildId ?? dryRunResult.campaign_build_id ?? null
|
|
2193
2359
|
}
|
|
2194
2360
|
];
|
|
2361
|
+
const learnBackPlan = summarizeCampaignBuilderProofLearnBack(
|
|
2362
|
+
asRecord(asRecord(plan.buildRequest.brainPreflight).learn_back_plan ?? asRecord(plan.brainPreflight).learn_back_plan)
|
|
2363
|
+
);
|
|
2195
2364
|
return {
|
|
2196
2365
|
receipt_version: "campaign-agent-proof.v1",
|
|
2197
2366
|
source: "signaliz.campaignBuilderAgent.proof",
|
|
@@ -2214,6 +2383,7 @@ function createCampaignBuilderProofReceipt(plan, result) {
|
|
|
2214
2383
|
gates,
|
|
2215
2384
|
strategy_memory_status: summarizeCampaignBuilderProofStrategyMemory(strategyMemory),
|
|
2216
2385
|
dry_run_result: summarizeCampaignBuilderProofDryRun(dryRunResult),
|
|
2386
|
+
learn_back_plan: learnBackPlan,
|
|
2217
2387
|
recommended_next_actions: [
|
|
2218
2388
|
"Review the plan, approvals, and dry-run result.",
|
|
2219
2389
|
"Use campaign-agent commit-plan --confirm-write only after review.",
|
|
@@ -2770,6 +2940,13 @@ function campaignBuilderMemoryKitSdkExample(request, seedManifestFile) {
|
|
|
2770
2940
|
function campaignBuilderMemoryKitSource(source) {
|
|
2771
2941
|
const normalized = normalizeTemplateKey(source || "agency");
|
|
2772
2942
|
const catalog = {
|
|
2943
|
+
northStar: {
|
|
2944
|
+
id: "north_star_campaign_builder",
|
|
2945
|
+
label: "North Star campaign-builder acceptance patterns",
|
|
2946
|
+
seed_source: "north-star",
|
|
2947
|
+
scope: "redacted_acceptance_seed_packs",
|
|
2948
|
+
privacy: "redacted aggregate counts, QA gates, and fixture shape only"
|
|
2949
|
+
},
|
|
2773
2950
|
agency: {
|
|
2774
2951
|
id: "agency_campaign_builder",
|
|
2775
2952
|
label: "Agency campaign-builder strategy patterns",
|
|
@@ -2795,6 +2972,10 @@ function campaignBuilderMemoryKitSource(source) {
|
|
|
2795
2972
|
const sourceMap = {
|
|
2796
2973
|
agency: "agency",
|
|
2797
2974
|
"campaign-builder": "agency",
|
|
2975
|
+
"north-star": "northStar",
|
|
2976
|
+
northstar: "northStar",
|
|
2977
|
+
"campaign-builder-north-star": "northStar",
|
|
2978
|
+
acceptance: "northStar",
|
|
2798
2979
|
"strategy-memory": "agency",
|
|
2799
2980
|
"workflow-patterns": "workflow",
|
|
2800
2981
|
workflow: "workflow",
|
|
@@ -2810,13 +2991,13 @@ function campaignBuilderMemoryKitSource(source) {
|
|
|
2810
2991
|
return {
|
|
2811
2992
|
seedSource: "all",
|
|
2812
2993
|
verifyScript: null,
|
|
2813
|
-
memorySources: [catalog.agency, catalog.workflow, catalog.feedback]
|
|
2994
|
+
memorySources: [catalog.northStar, catalog.agency, catalog.workflow, catalog.feedback]
|
|
2814
2995
|
};
|
|
2815
2996
|
}
|
|
2816
2997
|
const item = catalog[selected];
|
|
2817
2998
|
return {
|
|
2818
2999
|
seedSource: item.seed_source,
|
|
2819
|
-
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,
|
|
3000
|
+
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,
|
|
2820
3001
|
memorySources: [item]
|
|
2821
3002
|
};
|
|
2822
3003
|
}
|
|
@@ -2996,11 +3177,11 @@ function builtInRoutesFor(request) {
|
|
|
2996
3177
|
routes.push({
|
|
2997
3178
|
id: "signaliz-lead-generation",
|
|
2998
3179
|
layer: "source",
|
|
2999
|
-
|
|
3180
|
+
gtmLayer: "lead_generation",
|
|
3000
3181
|
provider: "signaliz",
|
|
3001
3182
|
mode: "required",
|
|
3002
3183
|
toolName: "generate_leads",
|
|
3003
|
-
rationale: "
|
|
3184
|
+
rationale: "Inventory verified cache first, then use Signaliz fresh workspace acquisition for the remaining approved gap."
|
|
3004
3185
|
});
|
|
3005
3186
|
}
|
|
3006
3187
|
if (builtIns.has("local_leads")) {
|
|
@@ -3014,6 +3195,28 @@ function builtInRoutesFor(request) {
|
|
|
3014
3195
|
rationale: "Use Signaliz local-leads sourcing for geography-bound local business campaigns."
|
|
3015
3196
|
});
|
|
3016
3197
|
}
|
|
3198
|
+
if (builtIns.has("company_discovery")) {
|
|
3199
|
+
routes.push({
|
|
3200
|
+
id: "signaliz-company-discovery",
|
|
3201
|
+
layer: "source",
|
|
3202
|
+
gtmLayer: "find_company",
|
|
3203
|
+
provider: "signaliz",
|
|
3204
|
+
mode: "if_available",
|
|
3205
|
+
toolName: "find_companies_signaliz",
|
|
3206
|
+
rationale: "Find and qualify company domains before people/email fill for account-led campaigns."
|
|
3207
|
+
});
|
|
3208
|
+
}
|
|
3209
|
+
if (builtIns.has("people_discovery")) {
|
|
3210
|
+
routes.push({
|
|
3211
|
+
id: "signaliz-people-discovery",
|
|
3212
|
+
layer: "source",
|
|
3213
|
+
gtmLayer: "find_people",
|
|
3214
|
+
provider: "signaliz",
|
|
3215
|
+
mode: "if_available",
|
|
3216
|
+
toolName: "find_people_signaliz",
|
|
3217
|
+
rationale: "Find people directly when the brief is contact research or LinkedIn-style prospecting."
|
|
3218
|
+
});
|
|
3219
|
+
}
|
|
3017
3220
|
if (builtIns.has("email_finding")) {
|
|
3018
3221
|
routes.push({
|
|
3019
3222
|
id: "signaliz-email-finding",
|
|
@@ -3058,7 +3261,7 @@ function normalizeBuiltIns(request) {
|
|
|
3058
3261
|
return [...builtIns].filter(isCampaignBuilderBuiltInTool);
|
|
3059
3262
|
}
|
|
3060
3263
|
function isCampaignBuilderBuiltInTool(value) {
|
|
3061
|
-
return ["lead_generation", "local_leads", "email_finding", "email_verification", "signals"].includes(String(value));
|
|
3264
|
+
return ["lead_generation", "local_leads", "company_discovery", "people_discovery", "email_finding", "email_verification", "signals"].includes(String(value));
|
|
3062
3265
|
}
|
|
3063
3266
|
function looksLikeLocalLeadCampaign(request) {
|
|
3064
3267
|
const text = [
|
|
@@ -3113,7 +3316,11 @@ function createBuildRequest(request, defaults, targetCount, campaignName, scopeB
|
|
|
3113
3316
|
qualification: defaults.qualification,
|
|
3114
3317
|
copy: defaults.copy,
|
|
3115
3318
|
delivery: defaults.delivery,
|
|
3116
|
-
enhancers: enhancerConfig(request)
|
|
3319
|
+
enhancers: enhancerConfig(request),
|
|
3320
|
+
sourceRouting: request.sourceRouting ?? {
|
|
3321
|
+
mode: looksLikeLocalLeadCampaign(request) ? "local_leads" : "auto",
|
|
3322
|
+
fillPolicy: "aggressive"
|
|
3323
|
+
}
|
|
3117
3324
|
};
|
|
3118
3325
|
const scoped = asRecord(scopeBuildArgs);
|
|
3119
3326
|
buildRequest.gtmCampaignId = request.gtmCampaignId ?? stringValue(scoped.gtm_campaign_id ?? scoped.gtmCampaignId);
|
|
@@ -3195,9 +3402,132 @@ function createBrainPreflight(request, buildRequest, routes, memory) {
|
|
|
3195
3402
|
{ tool: "gtm_brain_learning_cycle_plan", purpose: "Plan the Brain learning loop for this campaign.", arguments: learningArgs },
|
|
3196
3403
|
{ tool: "gtm_brain_seed_defaults", purpose: "Seed campaign defaults from workspace memory and safe aggregate patterns.", arguments: defaultsArgs },
|
|
3197
3404
|
{ tool: "gtm_brain_delivery_risk", purpose: "Check deliverability risk before launch or external writes.", arguments: riskArgs }
|
|
3198
|
-
]
|
|
3405
|
+
],
|
|
3406
|
+
learn_back_plan: createCampaignBuilderLearnBackPlan(request, buildRequest)
|
|
3199
3407
|
};
|
|
3200
3408
|
}
|
|
3409
|
+
function createCampaignBuilderLearnBackPlan(request, buildRequest) {
|
|
3410
|
+
const instantlyFeedbackContext = campaignBuilderProviderFeedbackContext(request, buildRequest, "instantly");
|
|
3411
|
+
const postBuildSequence = [
|
|
3412
|
+
{
|
|
3413
|
+
tool: "get_campaign_build_status",
|
|
3414
|
+
approval_boundary: "read_only",
|
|
3415
|
+
arguments_template: { campaign_build_id: "<build_campaign.campaign_build_id>" },
|
|
3416
|
+
reason: "Wait for the Campaign Builder run to finish before deriving memory."
|
|
3417
|
+
},
|
|
3418
|
+
{
|
|
3419
|
+
tool: "gtm_campaign_build_backfill_preview",
|
|
3420
|
+
approval_boundary: "read_only",
|
|
3421
|
+
arguments_template: { campaign_build_id: "<build_campaign.campaign_build_id>", create_memory: true },
|
|
3422
|
+
reason: "Preview the provider-neutral Kernel import payload without writing rows."
|
|
3423
|
+
},
|
|
3424
|
+
{
|
|
3425
|
+
tool: "gtm_campaign_build_backfill_run",
|
|
3426
|
+
approval_boundary: "dry_run",
|
|
3427
|
+
arguments_template: { campaign_build_ids: ["<build_campaign.campaign_build_id>"], dry_run: true, create_memory: true, run_brain_cycle: false },
|
|
3428
|
+
reason: "Dry-run the Kernel history import before creating campaign memory."
|
|
3429
|
+
},
|
|
3430
|
+
{
|
|
3431
|
+
tool: "gtm_campaign_build_backfill_run",
|
|
3432
|
+
approval_boundary: "explicit_write_approval",
|
|
3433
|
+
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" },
|
|
3434
|
+
reason: "After review, queue the Kernel history import; Brain learning remains dry-run unless separately approved."
|
|
3435
|
+
}
|
|
3436
|
+
];
|
|
3437
|
+
if (instantlyFeedbackContext) {
|
|
3438
|
+
postBuildSequence.push({
|
|
3439
|
+
tool: "gtm_instantly_feedback_pull",
|
|
3440
|
+
approval_boundary: "dry_run_first_explicit_write_approval",
|
|
3441
|
+
arguments_template: {
|
|
3442
|
+
campaign_id: buildRequest.gtmCampaignId || "<gtm_campaign_id_after_commit>",
|
|
3443
|
+
campaign_build_id: "<build_campaign.campaign_build_id>",
|
|
3444
|
+
source: "emails",
|
|
3445
|
+
email_type: "received",
|
|
3446
|
+
...instantlyFeedbackContext,
|
|
3447
|
+
dry_run: true,
|
|
3448
|
+
create_memory: true,
|
|
3449
|
+
write_routine_outcomes: true,
|
|
3450
|
+
run_brain_cycle: true,
|
|
3451
|
+
brain_cycle_write_mode: "dry_run"
|
|
3452
|
+
},
|
|
3453
|
+
reason: "After Instantly delivery has live outcomes, pull reply and bounce history into private feedback memory before Brain learning."
|
|
3454
|
+
});
|
|
3455
|
+
}
|
|
3456
|
+
postBuildSequence.push(
|
|
3457
|
+
{
|
|
3458
|
+
tool: "gtm_campaign_learning_status",
|
|
3459
|
+
approval_boundary: "read_only",
|
|
3460
|
+
arguments_template: {
|
|
3461
|
+
campaign_id: buildRequest.gtmCampaignId || "<gtm_campaign_id_after_commit>",
|
|
3462
|
+
campaign_build_id: "<build_campaign.campaign_build_id>",
|
|
3463
|
+
write_mode: "dry_run"
|
|
3464
|
+
},
|
|
3465
|
+
reason: "Confirm feedback, memory, and Brain learning readiness after the import."
|
|
3466
|
+
},
|
|
3467
|
+
{
|
|
3468
|
+
tool: "gtm_memory_search",
|
|
3469
|
+
approval_boundary: "read_only",
|
|
3470
|
+
arguments_template: {
|
|
3471
|
+
query: request.goal,
|
|
3472
|
+
...buildRequest.gtmCampaignId ? { campaign_id: buildRequest.gtmCampaignId } : {},
|
|
3473
|
+
limit: 10
|
|
3474
|
+
},
|
|
3475
|
+
reason: "Verify the new private memory is retrievable for future campaign planning."
|
|
3476
|
+
},
|
|
3477
|
+
{
|
|
3478
|
+
tool: "gtm_brain_learning_cycle_plan",
|
|
3479
|
+
approval_boundary: "read_only",
|
|
3480
|
+
arguments_template: {
|
|
3481
|
+
...buildRequest.gtmCampaignId ? { campaign_id: buildRequest.gtmCampaignId } : {},
|
|
3482
|
+
include_memory: true,
|
|
3483
|
+
write_mode: "dry_run"
|
|
3484
|
+
},
|
|
3485
|
+
reason: "Plan the Brain phases from the imported outcomes before any pattern writes."
|
|
3486
|
+
}
|
|
3487
|
+
);
|
|
3488
|
+
return {
|
|
3489
|
+
source_tool: "campaign-builder-agent",
|
|
3490
|
+
gtm_campaign_id: buildRequest.gtmCampaignId ?? null,
|
|
3491
|
+
trigger: "After build_campaign returns a campaign_build_id and the build reaches a terminal reviewed state.",
|
|
3492
|
+
build_result_placeholders: {
|
|
3493
|
+
campaign_build_id: "<build_campaign.campaign_build_id>"
|
|
3494
|
+
},
|
|
3495
|
+
memory_write_policy: {
|
|
3496
|
+
target_tables: ["gtm_campaigns", "gtm_campaign_provider_links", "gtm_campaign_feedback_events", "gtm_memory_items", "gtm_brain_patterns"],
|
|
3497
|
+
gtm_memory_items: {
|
|
3498
|
+
shareable: false,
|
|
3499
|
+
allowed_redaction_states: ["redacted", "abstracted"],
|
|
3500
|
+
raw_private_fields_withheld: ["reply_text", "copy_body", "lead_email", "lead_domain", "company_domain", "provider_campaign_id", "provider_payload", "webhook_url", "secret"]
|
|
3501
|
+
},
|
|
3502
|
+
gtm_brain_patterns: "Workspace-scoped by default. Global promotion requires abstracted_only=true, shared opt-in, and privacy thresholds."
|
|
3503
|
+
},
|
|
3504
|
+
post_build_sequence: postBuildSequence.map((item, index) => ({ step: index + 1, ...item })),
|
|
3505
|
+
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.",
|
|
3506
|
+
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."
|
|
3507
|
+
};
|
|
3508
|
+
}
|
|
3509
|
+
function campaignBuilderProviderFeedbackContext(request, buildRequest, provider) {
|
|
3510
|
+
const normalizedProvider = String(provider).toLowerCase();
|
|
3511
|
+
const routes = [...request.integrations ?? [], ...routesFromCustomerTools(request.customerTools ?? [])];
|
|
3512
|
+
const providerRoute = routes.find((route) => String(route.provider).toLowerCase() === normalizedProvider);
|
|
3513
|
+
const routeConfig = asRecord(providerRoute?.config);
|
|
3514
|
+
const deliveryConfig = asRecord(buildRequest.delivery?.destinationConfig);
|
|
3515
|
+
const hasProviderContext = [
|
|
3516
|
+
...request.preferredProviders ?? [],
|
|
3517
|
+
...routes.map((route) => route.provider),
|
|
3518
|
+
stringValue(deliveryConfig.provider),
|
|
3519
|
+
stringValue(deliveryConfig.provider_id ?? deliveryConfig.providerId),
|
|
3520
|
+
stringValue(deliveryConfig.destination_provider ?? deliveryConfig.destinationProvider),
|
|
3521
|
+
stringValue(deliveryConfig.sink ?? deliveryConfig.sink_type ?? deliveryConfig.sinkType)
|
|
3522
|
+
].some((value) => String(value).toLowerCase() === normalizedProvider);
|
|
3523
|
+
if (!hasProviderContext) return void 0;
|
|
3524
|
+
return compact({
|
|
3525
|
+
provider_link_id: stringValue(routeConfig.provider_link_id ?? routeConfig.providerLinkId ?? deliveryConfig.provider_link_id ?? deliveryConfig.providerLinkId),
|
|
3526
|
+
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),
|
|
3527
|
+
integration_id: stringValue(routeConfig.integration_id ?? routeConfig.integrationId ?? deliveryConfig.integration_id ?? deliveryConfig.integrationId),
|
|
3528
|
+
instantly_profile: stringValue(routeConfig.instantly_profile ?? routeConfig.instantlyProfile ?? routeConfig.profile ?? deliveryConfig.instantly_profile ?? deliveryConfig.instantlyProfile ?? deliveryConfig.profile)
|
|
3529
|
+
});
|
|
3530
|
+
}
|
|
3201
3531
|
function gtmLayersForBuilderLayer(layer) {
|
|
3202
3532
|
const map = {
|
|
3203
3533
|
workspace_context: ["customer_data"],
|
|
@@ -3602,6 +3932,7 @@ function buildFallbackPlanSnapshot(plan) {
|
|
|
3602
3932
|
target_count: plan.targetCount,
|
|
3603
3933
|
approvals: plan.approvals,
|
|
3604
3934
|
brain_preflight: plan.brainPreflight,
|
|
3935
|
+
campaign_strategy_context: plan.buildRequest.campaignStrategyContext,
|
|
3605
3936
|
operating_playbooks: plan.operatingPlaybooks
|
|
3606
3937
|
});
|
|
3607
3938
|
}
|
|
@@ -3734,6 +4065,7 @@ function buildCampaignArgs(request) {
|
|
|
3734
4065
|
if (request.dedupKeys) args.dedup_keys = request.dedupKeys;
|
|
3735
4066
|
if (request.brainPreflight) args.brain_preflight = request.brainPreflight;
|
|
3736
4067
|
if (request.brainDefaults) args.brain_defaults = request.brainDefaults;
|
|
4068
|
+
if (request.campaignStrategyContext) args.campaign_strategy_context = request.campaignStrategyContext;
|
|
3737
4069
|
if (request.deliveryRisk) args.delivery_risk = request.deliveryRisk;
|
|
3738
4070
|
if (request.icp) {
|
|
3739
4071
|
args.icp = compact({
|
|
@@ -3753,6 +4085,15 @@ function buildCampaignArgs(request) {
|
|
|
3753
4085
|
model: request.policy.model
|
|
3754
4086
|
});
|
|
3755
4087
|
}
|
|
4088
|
+
if (request.sourceRouting) {
|
|
4089
|
+
args.source_routing = compact({
|
|
4090
|
+
mode: request.sourceRouting.mode,
|
|
4091
|
+
fill_policy: request.sourceRouting.fillPolicy,
|
|
4092
|
+
shard_size: request.sourceRouting.shardSize,
|
|
4093
|
+
max_source_shard_size: request.sourceRouting.maxSourceShardSize,
|
|
4094
|
+
max_local_source_shard_size: request.sourceRouting.maxLocalSourceShardSize
|
|
4095
|
+
});
|
|
4096
|
+
}
|
|
3756
4097
|
if (request.signals) {
|
|
3757
4098
|
args.signals = compact({
|
|
3758
4099
|
enabled: request.signals.enabled,
|
|
@@ -3824,7 +4165,8 @@ function buildExecutionPrepareArgs(request, dryRun, confirmSpend) {
|
|
|
3824
4165
|
qualification: buildArgs2.qualification,
|
|
3825
4166
|
copy: buildArgs2.copy,
|
|
3826
4167
|
delivery: buildArgs2.delivery,
|
|
3827
|
-
enhancers: buildArgs2.enhancers
|
|
4168
|
+
enhancers: buildArgs2.enhancers,
|
|
4169
|
+
source_routing: buildArgs2.source_routing
|
|
3828
4170
|
});
|
|
3829
4171
|
}
|
|
3830
4172
|
function buildDeliveryApprovalArgs(request) {
|
|
@@ -3873,17 +4215,62 @@ function mapAgentCampaignBuildStatus(data) {
|
|
|
3873
4215
|
warnings: diagnosticMessages2(data.warnings),
|
|
3874
4216
|
errors: diagnosticMessages2(data.errors),
|
|
3875
4217
|
artifactCount: numberOrUndefined2(data.artifact_count) ?? 0,
|
|
4218
|
+
artifactDownloads: Array.isArray(data.artifact_downloads) ? data.artifact_downloads.map(mapAgentCampaignArtifactDownload) : [],
|
|
4219
|
+
customerRowCounts: mapAgentCustomerRowCounts(data.customer_row_counts),
|
|
4220
|
+
phaseAttemptTotals: nullableRecord(data.phase_attempt_totals) ?? void 0,
|
|
3876
4221
|
providerRoute: mapProviderRoute2(data),
|
|
3877
4222
|
triggerRunId: stringValue(data.trigger_run_id) ?? null,
|
|
3878
4223
|
staleRunningPhase: data.stale_running_phase === true,
|
|
3879
4224
|
phaseAgeSeconds: numberOrNull2(data.phase_age_seconds),
|
|
3880
4225
|
diagnostics: nullableRecord(data.diagnostics) ?? {},
|
|
3881
4226
|
nextAction: formatAgentNextAction(data.next_action),
|
|
4227
|
+
approvalAction: formatAgentNextAction(data.approval_action),
|
|
3882
4228
|
createdAt: stringValue(data.created_at) ?? "",
|
|
3883
4229
|
updatedAt: stringValue(data.updated_at) ?? "",
|
|
3884
4230
|
completedAt: stringValue(data.completed_at) ?? null
|
|
3885
4231
|
};
|
|
3886
4232
|
}
|
|
4233
|
+
function mapAgentCampaignArtifactDownload(data) {
|
|
4234
|
+
return {
|
|
4235
|
+
id: stringValue(data.id) ?? "",
|
|
4236
|
+
artifactType: stringValue(data.artifact_type) ?? null,
|
|
4237
|
+
format: stringValue(data.format) ?? null,
|
|
4238
|
+
rowCount: numberOrUndefined2(data.row_count) ?? 0,
|
|
4239
|
+
signedUrl: stringValue(data.signed_url) ?? null,
|
|
4240
|
+
downloadUrl: stringValue(data.download_url) ?? null,
|
|
4241
|
+
manifestUrl: stringValue(data.manifest_url) ?? null,
|
|
4242
|
+
expiresAt: stringValue(data.expires_at) ?? null
|
|
4243
|
+
};
|
|
4244
|
+
}
|
|
4245
|
+
function mapAgentCustomerRowCounts(value) {
|
|
4246
|
+
const record = nullableRecord(value);
|
|
4247
|
+
if (!record) return void 0;
|
|
4248
|
+
return {
|
|
4249
|
+
requestedTarget: numberOrNull2(record.requested_target),
|
|
4250
|
+
acquiredRows: numberOrUndefined2(record.acquired_rows),
|
|
4251
|
+
acceptedRows: numberOrUndefined2(record.accepted_rows),
|
|
4252
|
+
usableRows: numberOrUndefined2(record.usable_rows),
|
|
4253
|
+
copiedRows: numberOrUndefined2(record.copied_rows),
|
|
4254
|
+
approvalReadyRows: numberOrUndefined2(record.approval_ready_rows),
|
|
4255
|
+
qaReadyRows: numberOrUndefined2(record.qa_ready_rows),
|
|
4256
|
+
deliveredRows: numberOrUndefined2(record.delivered_rows),
|
|
4257
|
+
disqualifiedRows: numberOrUndefined2(record.disqualified_rows),
|
|
4258
|
+
reviewableRows: numberOrUndefined2(record.reviewable_rows),
|
|
4259
|
+
rowFailures: numberOrUndefined2(record.row_failures),
|
|
4260
|
+
acceptedShortfall: numberOrNull2(record.accepted_shortfall),
|
|
4261
|
+
usableShortfall: numberOrNull2(record.usable_shortfall),
|
|
4262
|
+
qaReadyShortfall: numberOrNull2(record.qa_ready_shortfall),
|
|
4263
|
+
deliveryShortfall: numberOrNull2(record.delivery_shortfall),
|
|
4264
|
+
fillRatio: numberOrNull2(record.fill_ratio),
|
|
4265
|
+
qaReadyFillRatio: numberOrNull2(record.qa_ready_fill_ratio),
|
|
4266
|
+
deliveredFillRatio: numberOrNull2(record.delivered_fill_ratio),
|
|
4267
|
+
terminalReason: stringValue(record.terminal_reason) ?? null,
|
|
4268
|
+
acceptedShortfallReason: stringValue(record.accepted_shortfall_reason) ?? null,
|
|
4269
|
+
usableShortfallReason: stringValue(record.usable_shortfall_reason) ?? null,
|
|
4270
|
+
qaReadyShortfallReason: stringValue(record.qa_ready_shortfall_reason) ?? null,
|
|
4271
|
+
deliveryShortfallReason: stringValue(record.delivery_shortfall_reason) ?? null
|
|
4272
|
+
};
|
|
4273
|
+
}
|
|
3887
4274
|
function mapAgentCampaignRowsResult(data) {
|
|
3888
4275
|
const rows = Array.isArray(data.rows) ? data.rows : [];
|
|
3889
4276
|
return {
|
|
@@ -3911,7 +4298,11 @@ function mapAgentCampaignArtifact(data) {
|
|
|
3911
4298
|
artifactType: stringValue(data.artifact_type) ?? "",
|
|
3912
4299
|
destination: stringValue(data.destination) ?? "",
|
|
3913
4300
|
storagePath: stringValue(data.storage_path) ?? "",
|
|
4301
|
+
format: stringValue(data.format) ?? null,
|
|
3914
4302
|
signedUrl: stringValue(data.signed_url) ?? null,
|
|
4303
|
+
downloadUrl: stringValue(data.download_url) ?? null,
|
|
4304
|
+
manifestUrl: stringValue(data.manifest_url) ?? null,
|
|
4305
|
+
expiresAt: stringValue(data.expires_at) ?? null,
|
|
3915
4306
|
rowCount: numberOrUndefined2(data.row_count) ?? 0,
|
|
3916
4307
|
checksum: stringValue(data.checksum) ?? null,
|
|
3917
4308
|
metadata: nullableRecord(data.metadata) ?? {},
|
|
@@ -4073,6 +4464,8 @@ function readinessLaneLabel(route, builtIn) {
|
|
|
4073
4464
|
const labels = {
|
|
4074
4465
|
lead_generation: "Signaliz lead generation",
|
|
4075
4466
|
local_leads: "Signaliz local leads",
|
|
4467
|
+
company_discovery: "Signaliz company discovery",
|
|
4468
|
+
people_discovery: "Signaliz people discovery",
|
|
4076
4469
|
email_finding: "Signaliz email finding",
|
|
4077
4470
|
email_verification: "Signaliz email verification",
|
|
4078
4471
|
signals: "Signaliz signals"
|
|
@@ -4157,6 +4550,35 @@ function summarizeCampaignBuilderProofDryRun(dryRunResult) {
|
|
|
4157
4550
|
plannedTargetCount: dryRunResult.plannedTargetCount ?? dryRunResult.planned_target_count ?? null
|
|
4158
4551
|
};
|
|
4159
4552
|
}
|
|
4553
|
+
function summarizeCampaignBuilderProofLearnBack(plan) {
|
|
4554
|
+
if (Object.keys(plan).length === 0) return { ready: false };
|
|
4555
|
+
const memoryPolicy = asRecord(plan.memory_write_policy);
|
|
4556
|
+
const memoryItemsPolicy = asRecord(memoryPolicy.gtm_memory_items);
|
|
4557
|
+
const sequence = Array.isArray(plan.post_build_sequence) ? plan.post_build_sequence.map((step) => {
|
|
4558
|
+
const record = asRecord(step);
|
|
4559
|
+
return compact({
|
|
4560
|
+
step: record.step,
|
|
4561
|
+
tool: stringValue(record.tool),
|
|
4562
|
+
approval_boundary: stringValue(record.approval_boundary),
|
|
4563
|
+
reason: stringValue(record.reason)
|
|
4564
|
+
});
|
|
4565
|
+
}).filter((step) => typeof step.tool === "string") : [];
|
|
4566
|
+
return {
|
|
4567
|
+
ready: sequence.length > 0,
|
|
4568
|
+
source_tool: firstNonEmptyString(plan.source_tool, plan.sourceTool),
|
|
4569
|
+
post_build_sequence: sequence,
|
|
4570
|
+
memory_write_policy: {
|
|
4571
|
+
target_tables: Array.isArray(memoryPolicy.target_tables) ? memoryPolicy.target_tables : [],
|
|
4572
|
+
gtm_memory_items: {
|
|
4573
|
+
shareable: memoryItemsPolicy.shareable === false ? false : memoryItemsPolicy.shareable ?? null,
|
|
4574
|
+
allowed_redaction_states: Array.isArray(memoryItemsPolicy.allowed_redaction_states) ? memoryItemsPolicy.allowed_redaction_states : [],
|
|
4575
|
+
raw_private_fields_withheld: Array.isArray(memoryItemsPolicy.raw_private_fields_withheld) ? memoryItemsPolicy.raw_private_fields_withheld : []
|
|
4576
|
+
}
|
|
4577
|
+
},
|
|
4578
|
+
approval_policy: firstNonEmptyString(plan.approval_policy, plan.approvalPolicy),
|
|
4579
|
+
privacy_policy: firstNonEmptyString(plan.privacy_policy, plan.privacyPolicy)
|
|
4580
|
+
};
|
|
4581
|
+
}
|
|
4160
4582
|
function firstNonEmptyString(...values) {
|
|
4161
4583
|
for (const value of values) {
|
|
4162
4584
|
if (typeof value === "string" && value.trim()) return value;
|
|
@@ -4639,14 +5061,87 @@ var Ops = class {
|
|
|
4639
5061
|
const body = typeof params === "string" ? { prompt: params } : buildOpsCreateBody(params);
|
|
4640
5062
|
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_create", body)));
|
|
4641
5063
|
}
|
|
5064
|
+
async schedule(params) {
|
|
5065
|
+
const createBody = typeof params === "string" ? { prompt: params, cadence: "daily" } : { ...buildOpsCreateBody(params), cadence: params.cadence ?? "daily" };
|
|
5066
|
+
const { activate: _activate, ...body } = createBody;
|
|
5067
|
+
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_schedule", body)));
|
|
5068
|
+
}
|
|
5069
|
+
async scheduleAndWait(params) {
|
|
5070
|
+
const options = typeof params === "string" ? { schedule: { prompt: params, cadence: "daily" }, run: {}, wait: {} } : buildOpsScheduleAndWaitOptions(params);
|
|
5071
|
+
const raw = await this.call("ops_schedule_and_wait", buildOpsScheduleAndWaitBody(options));
|
|
5072
|
+
return normalizeOpsScheduleAndWaitCallResult(raw, options.wait, {
|
|
5073
|
+
approvalMessage: "ops.scheduleAndWait requires an approved schedulable Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5074
|
+
notCreatedMessage: "ops.scheduleAndWait requires ops_schedule_and_wait to create an op_id. Use ops.schedule for approval review flows."
|
|
5075
|
+
});
|
|
5076
|
+
}
|
|
5077
|
+
/** Schedule a recurring Op that delivers through a customer-owned Nango API connection. */
|
|
5078
|
+
async scheduleNangoAction(input) {
|
|
5079
|
+
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_nango_schedule", buildOpsNangoScheduleBody(input))));
|
|
5080
|
+
}
|
|
5081
|
+
/** Schedule a recurring Nango-backed Op, run the first tick, and return result readback. */
|
|
5082
|
+
async scheduleNangoActionAndWait(input) {
|
|
5083
|
+
const options = buildOpsNangoScheduleAndWaitOptions(input);
|
|
5084
|
+
const raw = await this.call("ops_nango_schedule_and_wait", buildOpsNangoScheduleAndWaitBody(options));
|
|
5085
|
+
return normalizeOpsScheduleAndWaitCallResult(raw, options.wait, {
|
|
5086
|
+
approvalMessage: "ops.scheduleNangoActionAndWait requires an approved Nango-backed Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5087
|
+
notCreatedMessage: "ops.scheduleNangoActionAndWait requires ops_nango_schedule_and_wait to create an op_id. Use ops.scheduleNangoAction for approval review flows."
|
|
5088
|
+
});
|
|
5089
|
+
}
|
|
4642
5090
|
async execute(params) {
|
|
4643
5091
|
const body = typeof params === "string" ? { prompt: params } : buildOpsExecuteBody(params);
|
|
4644
5092
|
return normalizeOpsExecuteResult(withExecutionRefs(await this.call("ops_execute", body)));
|
|
4645
5093
|
}
|
|
5094
|
+
async executeAndWait(params) {
|
|
5095
|
+
const options = typeof params === "string" ? { execute: { prompt: params, auto_run: true }, wait: {} } : buildOpsExecuteAndWaitOptions(params);
|
|
5096
|
+
const execute = await this.execute(options.execute);
|
|
5097
|
+
if (execute.approval_required || execute.error_code === "APPROVAL_REQUIRED") {
|
|
5098
|
+
throw new SignalizError({
|
|
5099
|
+
code: "APPROVAL_REQUIRED",
|
|
5100
|
+
errorType: "validation",
|
|
5101
|
+
message: "ops.executeAndWait requires an approved executable Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5102
|
+
details: { execute }
|
|
5103
|
+
});
|
|
5104
|
+
}
|
|
5105
|
+
if (!execute.op_id) {
|
|
5106
|
+
throw new SignalizError({
|
|
5107
|
+
code: "OP_NOT_CREATED",
|
|
5108
|
+
errorType: "validation",
|
|
5109
|
+
message: "ops.executeAndWait requires ops_execute to create an op_id. Use ops.execute for dry runs or approval review flows.",
|
|
5110
|
+
details: { execute }
|
|
5111
|
+
});
|
|
5112
|
+
}
|
|
5113
|
+
const waited = await this.waitForResults({
|
|
5114
|
+
...options.wait,
|
|
5115
|
+
op_id: execute.op_id
|
|
5116
|
+
});
|
|
5117
|
+
const runId = execute.run_id ?? execute.runId ?? waited.status.run_id ?? waited.status.runId ?? null;
|
|
5118
|
+
return {
|
|
5119
|
+
...waited,
|
|
5120
|
+
execute,
|
|
5121
|
+
run_id: runId,
|
|
5122
|
+
runId,
|
|
5123
|
+
execution_refs: mergeExecutionRefsFrom([execute, waited])
|
|
5124
|
+
};
|
|
5125
|
+
}
|
|
4646
5126
|
async run(params) {
|
|
4647
5127
|
const body = typeof params === "string" ? { op_id: params } : buildOpsRunBody(params);
|
|
4648
5128
|
return normalizeOpsRunResult(withExecutionRefs(await this.call("ops_run", body)));
|
|
4649
5129
|
}
|
|
5130
|
+
async runAndWait(params) {
|
|
5131
|
+
const options = typeof params === "string" ? { op_id: params } : buildOpsRunAndWaitOptions(params);
|
|
5132
|
+
if (!options.op_id) throw new Error("ops.runAndWait requires op_id or opId");
|
|
5133
|
+
const run = await this.run({
|
|
5134
|
+
op_id: options.op_id,
|
|
5135
|
+
instruction: options.instruction,
|
|
5136
|
+
force: options.force
|
|
5137
|
+
});
|
|
5138
|
+
const waited = await this.waitForResults(options);
|
|
5139
|
+
return {
|
|
5140
|
+
...waited,
|
|
5141
|
+
run,
|
|
5142
|
+
execution_refs: mergeExecutionRefsFrom([run, waited])
|
|
5143
|
+
};
|
|
5144
|
+
}
|
|
4650
5145
|
async status(params) {
|
|
4651
5146
|
const body = typeof params === "string" ? { op_id: params } : buildOpsStatusBody(params);
|
|
4652
5147
|
return normalizeOpsStatusResult(withExecutionRefs(await this.call("ops_status", body)));
|
|
@@ -4655,6 +5150,173 @@ var Ops = class {
|
|
|
4655
5150
|
const body = typeof params === "string" ? { op_id: params } : buildOpsResultsBody(params);
|
|
4656
5151
|
return normalizeOpsResultsResult(withExecutionRefs(await this.call("ops_results", body)));
|
|
4657
5152
|
}
|
|
5153
|
+
async waitForResults(params) {
|
|
5154
|
+
const options = typeof params === "string" ? { op_id: params } : buildOpsWaitForResultsOptions(params);
|
|
5155
|
+
if (!options.op_id) throw new Error("ops.waitForResults requires op_id or opId");
|
|
5156
|
+
const waitResult = await this.call("ops_wait", buildOpsWaitBody(options));
|
|
5157
|
+
return normalizeOpsWaitForResultsResult(waitResult, options);
|
|
5158
|
+
}
|
|
5159
|
+
/** Create a short-lived Nango Connect session from the Ops namespace. */
|
|
5160
|
+
async createNangoConnectSession(input) {
|
|
5161
|
+
return this.call("nango_connect_session_create", {
|
|
5162
|
+
provider_id: input.providerId,
|
|
5163
|
+
integration_id: input.integrationId,
|
|
5164
|
+
provider_display_name: input.providerDisplayName,
|
|
5165
|
+
integration_display_name: input.integrationDisplayName,
|
|
5166
|
+
allowed_integrations: input.allowedIntegrations,
|
|
5167
|
+
surface: input.surface,
|
|
5168
|
+
source: input.source,
|
|
5169
|
+
user_email: input.userEmail,
|
|
5170
|
+
user_display_name: input.userDisplayName
|
|
5171
|
+
});
|
|
5172
|
+
}
|
|
5173
|
+
/** Prepare the full Nango provider search, connect, pull/export, Ops, and route flow. */
|
|
5174
|
+
async prepareNangoIntegrationFlow(input = {}) {
|
|
5175
|
+
return this.call("nango_integration_flow_prepare", {
|
|
5176
|
+
query: input.query,
|
|
5177
|
+
search: input.search,
|
|
5178
|
+
provider_id: input.providerId,
|
|
5179
|
+
provider: input.provider,
|
|
5180
|
+
integration_id: input.integrationId,
|
|
5181
|
+
provider_config_key: input.providerConfigKey,
|
|
5182
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
5183
|
+
connection_id: input.connectionId,
|
|
5184
|
+
nango_connection_id: input.nangoConnectionId,
|
|
5185
|
+
intent: input.intent,
|
|
5186
|
+
action_name: input.actionName,
|
|
5187
|
+
tool_name: input.toolName,
|
|
5188
|
+
proxy_path: input.proxyPath,
|
|
5189
|
+
method: input.method,
|
|
5190
|
+
input: input.input,
|
|
5191
|
+
cadence: input.cadence,
|
|
5192
|
+
field_map: input.fieldMap,
|
|
5193
|
+
required_fields: input.requiredFields,
|
|
5194
|
+
confirm_spend: input.confirmSpend,
|
|
5195
|
+
write_confirmed: input.writeConfirmed,
|
|
5196
|
+
layer: input.layer,
|
|
5197
|
+
campaign_id: input.campaignId,
|
|
5198
|
+
limit: input.limit,
|
|
5199
|
+
include_provider_catalog: input.includeProviderCatalog
|
|
5200
|
+
});
|
|
5201
|
+
}
|
|
5202
|
+
/** List Nango-backed action tools for a workspace connection without executing them. */
|
|
5203
|
+
async listNangoTools(options = {}) {
|
|
5204
|
+
return this.call("nango_mcp_tools_list", {
|
|
5205
|
+
workspace_connection_id: options.workspaceConnectionId,
|
|
5206
|
+
connection_id: options.connectionId,
|
|
5207
|
+
provider_config_key: options.providerConfigKey,
|
|
5208
|
+
integration_id: options.integrationId,
|
|
5209
|
+
nango_connection_id: options.nangoConnectionId,
|
|
5210
|
+
format: options.format,
|
|
5211
|
+
include_raw: options.includeRaw
|
|
5212
|
+
});
|
|
5213
|
+
}
|
|
5214
|
+
/** Audit connected Nango rows, action/proxy readiness, and read/write proof gaps. */
|
|
5215
|
+
async proveNangoReadWrite(options = {}) {
|
|
5216
|
+
return this.call("nango_mcp_read_write_audit", {
|
|
5217
|
+
workspace_connection_id: options.workspaceConnectionId,
|
|
5218
|
+
connection_id: options.connectionId,
|
|
5219
|
+
provider_config_key: options.providerConfigKey,
|
|
5220
|
+
integration_id: options.integrationId,
|
|
5221
|
+
nango_connection_id: options.nangoConnectionId,
|
|
5222
|
+
limit: options.limit,
|
|
5223
|
+
include_raw: options.includeRaw,
|
|
5224
|
+
read_proxy_path: options.readProxyPath,
|
|
5225
|
+
write_proxy_path: options.writeProxyPath,
|
|
5226
|
+
method: options.method,
|
|
5227
|
+
execute_read_probe: options.executeReadProbe,
|
|
5228
|
+
execute_write_probe: options.executeWriteProbe,
|
|
5229
|
+
confirm: options.confirm,
|
|
5230
|
+
confirm_write: options.confirmWrite,
|
|
5231
|
+
input: options.input,
|
|
5232
|
+
write_input: options.writeInput
|
|
5233
|
+
});
|
|
5234
|
+
}
|
|
5235
|
+
/** Dry-run or execute a Nango-backed action tool through the approval-aware MCP bridge. */
|
|
5236
|
+
async callNangoTool(input) {
|
|
5237
|
+
return this.call("nango_mcp_tool_call", {
|
|
5238
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
5239
|
+
connection_id: input.connectionId,
|
|
5240
|
+
provider_config_key: input.providerConfigKey,
|
|
5241
|
+
integration_id: input.integrationId,
|
|
5242
|
+
nango_connection_id: input.nangoConnectionId,
|
|
5243
|
+
action_name: input.actionName,
|
|
5244
|
+
tool_name: input.toolName,
|
|
5245
|
+
delivery_mode: input.deliveryMode,
|
|
5246
|
+
proxy_path: input.proxyPath,
|
|
5247
|
+
nango_proxy_path: input.nangoProxyPath,
|
|
5248
|
+
method: input.method,
|
|
5249
|
+
http_method: input.httpMethod,
|
|
5250
|
+
proxy_headers: input.proxyHeaders,
|
|
5251
|
+
input: input.input,
|
|
5252
|
+
async: input.async,
|
|
5253
|
+
max_retries: input.maxRetries,
|
|
5254
|
+
dry_run: input.dryRun,
|
|
5255
|
+
confirm: input.confirm,
|
|
5256
|
+
confirm_write: input.confirmWrite
|
|
5257
|
+
});
|
|
5258
|
+
}
|
|
5259
|
+
/** Execute a Nango action and poll its async result when a status URL/action id is returned. */
|
|
5260
|
+
async callNangoToolAndWait(input) {
|
|
5261
|
+
const result = await this.call("nango_mcp_tool_call_and_wait", {
|
|
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 ?? true,
|
|
5277
|
+
max_retries: input.maxRetries,
|
|
5278
|
+
dry_run: input.dryRun,
|
|
5279
|
+
confirm: input.confirm,
|
|
5280
|
+
confirm_write: input.confirmWrite,
|
|
5281
|
+
interval_ms: input.intervalMs,
|
|
5282
|
+
max_polls: input.maxPolls,
|
|
5283
|
+
timeout_ms: input.timeoutMs
|
|
5284
|
+
});
|
|
5285
|
+
const packet = asRecord2(result);
|
|
5286
|
+
const actionId = optionalString(packet.actionId) ?? optionalString(packet.action_id);
|
|
5287
|
+
const statusUrl = optionalString(packet.statusUrl) ?? optionalString(packet.status_url);
|
|
5288
|
+
const maxPolls = Number(packet.maxPolls ?? packet.max_polls ?? 0);
|
|
5289
|
+
const intervalMs = Number(packet.intervalMs ?? packet.interval_ms ?? 0);
|
|
5290
|
+
const timeoutMs = Number(packet.timeoutMs ?? packet.timeout_ms ?? 0);
|
|
5291
|
+
const timedOut = Boolean(packet.timedOut ?? packet.timed_out);
|
|
5292
|
+
return {
|
|
5293
|
+
...packet,
|
|
5294
|
+
success: typeof packet.success === "boolean" ? packet.success : void 0,
|
|
5295
|
+
call: packet.call,
|
|
5296
|
+
result: packet.result,
|
|
5297
|
+
status: optionalString(packet.status),
|
|
5298
|
+
action_id: actionId,
|
|
5299
|
+
actionId,
|
|
5300
|
+
status_url: statusUrl,
|
|
5301
|
+
statusUrl,
|
|
5302
|
+
polls: Number(packet.polls ?? 0),
|
|
5303
|
+
max_polls: maxPolls,
|
|
5304
|
+
maxPolls,
|
|
5305
|
+
interval_ms: intervalMs,
|
|
5306
|
+
intervalMs,
|
|
5307
|
+
timeout_ms: timeoutMs,
|
|
5308
|
+
timeoutMs,
|
|
5309
|
+
timed_out: timedOut,
|
|
5310
|
+
timedOut
|
|
5311
|
+
};
|
|
5312
|
+
}
|
|
5313
|
+
/** Poll an async Nango action result by action id or status URL. */
|
|
5314
|
+
async getNangoActionResult(input) {
|
|
5315
|
+
return this.call("nango_mcp_action_result_get", {
|
|
5316
|
+
action_id: input.actionId,
|
|
5317
|
+
status_url: input.statusUrl
|
|
5318
|
+
});
|
|
5319
|
+
}
|
|
4658
5320
|
async proof(params = {}) {
|
|
4659
5321
|
const data = await this.call("ops_proof", {
|
|
4660
5322
|
window_hours: params.windowHours,
|
|
@@ -4681,51 +5343,57 @@ var Ops = class {
|
|
|
4681
5343
|
addRefs(collectExecutionReferences(status.latest_run));
|
|
4682
5344
|
}
|
|
4683
5345
|
const runRefs = Array.from(refs.values()).filter((ref) => ref.kind === "trigger_run" || ref.kind === "dataplane_run" || ref.kind === "replay_run");
|
|
4684
|
-
|
|
4685
|
-
for (const ref of runRefs) {
|
|
4686
|
-
try {
|
|
4687
|
-
const result = await this.getTriggerRunStatus(ref.id);
|
|
4688
|
-
const runs = "runs" in result ? result.runs : [result];
|
|
4689
|
-
runStatuses.push(...runs);
|
|
4690
|
-
for (const run of runs) addRefs(run.execution_refs);
|
|
4691
|
-
} catch (err) {
|
|
4692
|
-
recordError(`run-status:${ref.id}`, err);
|
|
4693
|
-
}
|
|
4694
|
-
}
|
|
5346
|
+
let runStatuses = [];
|
|
4695
5347
|
let queue;
|
|
4696
|
-
if (options.include_queue !== false) {
|
|
4697
|
-
try {
|
|
4698
|
-
queue = await this.getQueueStatus({ summary: true });
|
|
4699
|
-
addRefs(queue.execution_refs);
|
|
4700
|
-
} catch (err) {
|
|
4701
|
-
recordError("queue", err);
|
|
4702
|
-
}
|
|
4703
|
-
}
|
|
4704
5348
|
let dashboardRecent;
|
|
4705
|
-
if (options.include_dashboard !== false) {
|
|
4706
|
-
try {
|
|
4707
|
-
dashboardRecent = await this.getDashboard({
|
|
4708
|
-
section: "recent",
|
|
4709
|
-
limit: options.dashboard_limit ?? 10,
|
|
4710
|
-
timeRangeDays: options.time_range_days
|
|
4711
|
-
});
|
|
4712
|
-
} catch (err) {
|
|
4713
|
-
recordError("dashboard:recent", err);
|
|
4714
|
-
}
|
|
4715
|
-
}
|
|
4716
5349
|
let results;
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
5350
|
+
await Promise.all([
|
|
5351
|
+
(async () => {
|
|
5352
|
+
if (runRefs.length === 0) return;
|
|
5353
|
+
try {
|
|
5354
|
+
const result = await this.getTriggerRunStatus({ run_ids: runRefs.map((ref) => ref.id) });
|
|
5355
|
+
const runs = "runs" in result ? result.runs : [result];
|
|
5356
|
+
runStatuses = runs;
|
|
5357
|
+
for (const run of runs) addRefs(run.execution_refs);
|
|
5358
|
+
} catch (err) {
|
|
5359
|
+
recordError(runRefs.length === 1 ? `run-status:${runRefs[0].id}` : "run-status:batch", err);
|
|
5360
|
+
}
|
|
5361
|
+
})(),
|
|
5362
|
+
(async () => {
|
|
5363
|
+
if (options.include_queue === false) return;
|
|
5364
|
+
try {
|
|
5365
|
+
queue = await this.getQueueStatus({ summary: true });
|
|
5366
|
+
addRefs(queue.execution_refs);
|
|
5367
|
+
} catch (err) {
|
|
5368
|
+
recordError("queue", err);
|
|
5369
|
+
}
|
|
5370
|
+
})(),
|
|
5371
|
+
(async () => {
|
|
5372
|
+
if (options.include_dashboard === false) return;
|
|
5373
|
+
try {
|
|
5374
|
+
dashboardRecent = await this.getDashboard({
|
|
5375
|
+
section: "recent",
|
|
5376
|
+
limit: options.dashboard_limit ?? 10,
|
|
5377
|
+
timeRangeDays: options.time_range_days
|
|
5378
|
+
});
|
|
5379
|
+
} catch (err) {
|
|
5380
|
+
recordError("dashboard:recent", err);
|
|
5381
|
+
}
|
|
5382
|
+
})(),
|
|
5383
|
+
(async () => {
|
|
5384
|
+
if (!options.include_results) return;
|
|
5385
|
+
try {
|
|
5386
|
+
results = await this.results({
|
|
5387
|
+
op_id: options.op_id,
|
|
5388
|
+
limit: options.results_limit ?? 25,
|
|
5389
|
+
include_failed_runs: true
|
|
5390
|
+
});
|
|
5391
|
+
addRefs(results.execution_refs);
|
|
5392
|
+
} catch (err) {
|
|
5393
|
+
recordError("results", err);
|
|
5394
|
+
}
|
|
5395
|
+
})()
|
|
5396
|
+
]);
|
|
4729
5397
|
const executionRefs = Array.from(refs.values());
|
|
4730
5398
|
const replayCandidates = executionRefs.filter((ref) => ref.kind === "execution_event");
|
|
4731
5399
|
const nextActions = buildDebugNextActions(status, executionRefs, diagnosticErrors);
|
|
@@ -4927,6 +5595,69 @@ function mergeExecutionRefs(result) {
|
|
|
4927
5595
|
for (const ref of collectExecutionReferences(result)) add(ref);
|
|
4928
5596
|
return Array.from(refs.values());
|
|
4929
5597
|
}
|
|
5598
|
+
function mergeExecutionRefsFrom(results) {
|
|
5599
|
+
const refs = /* @__PURE__ */ new Map();
|
|
5600
|
+
for (const result of results) {
|
|
5601
|
+
if (!result) continue;
|
|
5602
|
+
for (const ref of mergeExecutionRefs(result)) refs.set(`${ref.kind}:${ref.id}`, ref);
|
|
5603
|
+
}
|
|
5604
|
+
return Array.from(refs.values());
|
|
5605
|
+
}
|
|
5606
|
+
function normalizeOpsScheduleAndWaitCallResult(raw, waitOptions, messages) {
|
|
5607
|
+
if (raw.approval_required || raw.approvalRequired || raw.error_code === "APPROVAL_REQUIRED" || raw.errorCode === "APPROVAL_REQUIRED") {
|
|
5608
|
+
throw new SignalizError({
|
|
5609
|
+
code: "APPROVAL_REQUIRED",
|
|
5610
|
+
errorType: "validation",
|
|
5611
|
+
message: messages.approvalMessage,
|
|
5612
|
+
details: { schedule: raw }
|
|
5613
|
+
});
|
|
5614
|
+
}
|
|
5615
|
+
const opId = stringValue2(raw.op_id ?? raw.opId);
|
|
5616
|
+
if (!opId) {
|
|
5617
|
+
throw new SignalizError({
|
|
5618
|
+
code: "OP_NOT_CREATED",
|
|
5619
|
+
errorType: "validation",
|
|
5620
|
+
message: messages.notCreatedMessage,
|
|
5621
|
+
details: { schedule: raw }
|
|
5622
|
+
});
|
|
5623
|
+
}
|
|
5624
|
+
const scheduleRaw = asRecord2(raw.schedule ?? raw.schedule_result ?? raw.scheduleResult);
|
|
5625
|
+
const runRaw = asRecord2(raw.run ?? raw.run_result ?? raw.runResult);
|
|
5626
|
+
const schedule = normalizeOpsCreateResult(withExecutionRefs(
|
|
5627
|
+
Object.keys(scheduleRaw).length > 0 ? scheduleRaw : {
|
|
5628
|
+
...raw,
|
|
5629
|
+
op_id: opId,
|
|
5630
|
+
routine_id: raw.routine_id ?? raw.routineId ?? opId,
|
|
5631
|
+
status: "ready",
|
|
5632
|
+
phase: "scheduled",
|
|
5633
|
+
next_action: raw.next_action ?? raw.nextAction
|
|
5634
|
+
}
|
|
5635
|
+
));
|
|
5636
|
+
const run = normalizeOpsRunResult(withExecutionRefs(
|
|
5637
|
+
Object.keys(runRaw).length > 0 ? runRaw : {
|
|
5638
|
+
success: raw.success !== false,
|
|
5639
|
+
op_id: opId,
|
|
5640
|
+
routine_id: raw.routine_id ?? raw.routineId ?? opId,
|
|
5641
|
+
run_id: raw.run_id ?? raw.runId ?? null,
|
|
5642
|
+
status: "running",
|
|
5643
|
+
phase: "queued",
|
|
5644
|
+
next_action: raw.next_action ?? raw.nextAction,
|
|
5645
|
+
results_count: 0,
|
|
5646
|
+
results_url: raw.results_url ?? raw.resultsUrl,
|
|
5647
|
+
delivery_status: raw.delivery_status ?? raw.deliveryStatus
|
|
5648
|
+
}
|
|
5649
|
+
));
|
|
5650
|
+
const waited = normalizeOpsWaitForResultsResult(raw, { ...waitOptions, op_id: opId });
|
|
5651
|
+
const runId = run.run_id ?? run.runId ?? waited.run_id ?? waited.runId ?? waited.status.run_id ?? waited.status.runId ?? null;
|
|
5652
|
+
return {
|
|
5653
|
+
...waited,
|
|
5654
|
+
schedule,
|
|
5655
|
+
run,
|
|
5656
|
+
run_id: runId,
|
|
5657
|
+
runId,
|
|
5658
|
+
execution_refs: mergeExecutionRefsFrom([schedule, run, waited])
|
|
5659
|
+
};
|
|
5660
|
+
}
|
|
4930
5661
|
function normalizeOpsPrimitiveRetryPolicy(policy = {}) {
|
|
4931
5662
|
return {
|
|
4932
5663
|
...policy,
|
|
@@ -5002,8 +5733,122 @@ function normalizeOpsPrimitive(primitive) {
|
|
|
5002
5733
|
observability: normalizeOpsPrimitiveObservabilityPolicy(primitive.observability)
|
|
5003
5734
|
};
|
|
5004
5735
|
}
|
|
5736
|
+
function normalizeOpsExecutionToolCall(rawCall) {
|
|
5737
|
+
const call = asRecord2(rawCall);
|
|
5738
|
+
return {
|
|
5739
|
+
...call,
|
|
5740
|
+
tool: stringValue2(call.tool),
|
|
5741
|
+
arguments: asRecord2(call.arguments),
|
|
5742
|
+
purpose: stringValue2(call.purpose)
|
|
5743
|
+
};
|
|
5744
|
+
}
|
|
5745
|
+
function normalizeOpsExecutionScheduleContract(rawSchedule) {
|
|
5746
|
+
const schedule = asRecord2(rawSchedule);
|
|
5747
|
+
const wakeOnEvents = Array.isArray(schedule.wake_on_events) ? schedule.wake_on_events.map(String) : Array.isArray(schedule.wakeOnEvents) ? schedule.wakeOnEvents.map(String) : [];
|
|
5748
|
+
return {
|
|
5749
|
+
...schedule,
|
|
5750
|
+
create_tool: stringValue2(schedule.create_tool ?? schedule.createTool),
|
|
5751
|
+
createTool: stringValue2(schedule.createTool ?? schedule.create_tool),
|
|
5752
|
+
activate_tool: stringValue2(schedule.activate_tool ?? schedule.activateTool),
|
|
5753
|
+
activateTool: stringValue2(schedule.activateTool ?? schedule.activate_tool),
|
|
5754
|
+
cadence: stringValue2(schedule.cadence, "manual"),
|
|
5755
|
+
recurrence: stringValue2(schedule.recurrence),
|
|
5756
|
+
wake_on_events: wakeOnEvents,
|
|
5757
|
+
wakeOnEvents
|
|
5758
|
+
};
|
|
5759
|
+
}
|
|
5760
|
+
function normalizeOpsExecutionApprovalContract(rawApproval) {
|
|
5761
|
+
const approval = asRecord2(rawApproval);
|
|
5762
|
+
return {
|
|
5763
|
+
...approval,
|
|
5764
|
+
required: Boolean(approval.required),
|
|
5765
|
+
tool: stringValue2(approval.tool),
|
|
5766
|
+
reason: stringValue2(approval.reason)
|
|
5767
|
+
};
|
|
5768
|
+
}
|
|
5769
|
+
function normalizeOpsExecutionMonitorContract(rawMonitor) {
|
|
5770
|
+
const monitor = asRecord2(rawMonitor);
|
|
5771
|
+
const pollAfterMs = numberValue(monitor.poll_after_ms ?? monitor.pollAfterMs);
|
|
5772
|
+
return {
|
|
5773
|
+
...monitor,
|
|
5774
|
+
status_tool: stringValue2(monitor.status_tool ?? monitor.statusTool),
|
|
5775
|
+
statusTool: stringValue2(monitor.statusTool ?? monitor.status_tool),
|
|
5776
|
+
wait_tool: stringValue2(monitor.wait_tool ?? monitor.waitTool),
|
|
5777
|
+
waitTool: stringValue2(monitor.waitTool ?? monitor.wait_tool),
|
|
5778
|
+
results_tool: stringValue2(monitor.results_tool ?? monitor.resultsTool),
|
|
5779
|
+
resultsTool: stringValue2(monitor.resultsTool ?? monitor.results_tool),
|
|
5780
|
+
poll_after_ms: pollAfterMs,
|
|
5781
|
+
pollAfterMs
|
|
5782
|
+
};
|
|
5783
|
+
}
|
|
5784
|
+
function normalizeOpsExecutionResultContract(rawResult) {
|
|
5785
|
+
const result = asRecord2(rawResult);
|
|
5786
|
+
const shape = Array.isArray(result.shape) ? result.shape.map(String) : [];
|
|
5787
|
+
return {
|
|
5788
|
+
...result,
|
|
5789
|
+
tool: stringValue2(result.tool),
|
|
5790
|
+
wait_tool: stringValue2(result.wait_tool ?? result.waitTool),
|
|
5791
|
+
waitTool: stringValue2(result.waitTool ?? result.wait_tool),
|
|
5792
|
+
shape,
|
|
5793
|
+
empty_result_recovery: stringValue2(result.empty_result_recovery ?? result.emptyResultRecovery),
|
|
5794
|
+
emptyResultRecovery: stringValue2(result.emptyResultRecovery ?? result.empty_result_recovery)
|
|
5795
|
+
};
|
|
5796
|
+
}
|
|
5797
|
+
function normalizeOpsExecutionNangoRouteContract(rawRoute) {
|
|
5798
|
+
if (!rawRoute || typeof rawRoute !== "object" || Array.isArray(rawRoute)) return void 0;
|
|
5799
|
+
const route = asRecord2(rawRoute);
|
|
5800
|
+
const requiredFields = Array.isArray(route.required_fields) ? route.required_fields.map(String) : Array.isArray(route.requiredFields) ? route.requiredFields.map(String) : [];
|
|
5801
|
+
return {
|
|
5802
|
+
...route,
|
|
5803
|
+
enabled: route.enabled !== false,
|
|
5804
|
+
connect_tool: stringValue2(route.connect_tool ?? route.connectTool),
|
|
5805
|
+
connectTool: stringValue2(route.connectTool ?? route.connect_tool),
|
|
5806
|
+
discover_tool: stringValue2(route.discover_tool ?? route.discoverTool),
|
|
5807
|
+
discoverTool: stringValue2(route.discoverTool ?? route.discover_tool),
|
|
5808
|
+
dry_run_tool: stringValue2(route.dry_run_tool ?? route.dryRunTool),
|
|
5809
|
+
dryRunTool: stringValue2(route.dryRunTool ?? route.dry_run_tool),
|
|
5810
|
+
execute_tool: stringValue2(route.execute_tool ?? route.executeTool),
|
|
5811
|
+
executeTool: stringValue2(route.executeTool ?? route.execute_tool),
|
|
5812
|
+
execute_and_wait_tool: stringValue2(route.execute_and_wait_tool ?? route.executeAndWaitTool),
|
|
5813
|
+
executeAndWaitTool: stringValue2(route.executeAndWaitTool ?? route.execute_and_wait_tool),
|
|
5814
|
+
schedule_tool: stringValue2(route.schedule_tool ?? route.scheduleTool),
|
|
5815
|
+
scheduleTool: stringValue2(route.scheduleTool ?? route.schedule_tool),
|
|
5816
|
+
schedule_and_wait_tool: stringValue2(route.schedule_and_wait_tool ?? route.scheduleAndWaitTool),
|
|
5817
|
+
scheduleAndWaitTool: stringValue2(route.scheduleAndWaitTool ?? route.schedule_and_wait_tool),
|
|
5818
|
+
result_tool: stringValue2(route.result_tool ?? route.resultTool),
|
|
5819
|
+
resultTool: stringValue2(route.resultTool ?? route.result_tool),
|
|
5820
|
+
write_gate: stringValue2(route.write_gate ?? route.writeGate),
|
|
5821
|
+
writeGate: stringValue2(route.writeGate ?? route.write_gate),
|
|
5822
|
+
required_fields: requiredFields,
|
|
5823
|
+
requiredFields,
|
|
5824
|
+
schedule_arguments: asRecord2(route.schedule_arguments ?? route.scheduleArguments),
|
|
5825
|
+
scheduleArguments: asRecord2(route.scheduleArguments ?? route.schedule_arguments),
|
|
5826
|
+
schedule_and_wait_arguments: asRecord2(route.schedule_and_wait_arguments ?? route.scheduleAndWaitArguments),
|
|
5827
|
+
scheduleAndWaitArguments: asRecord2(route.scheduleAndWaitArguments ?? route.schedule_and_wait_arguments)
|
|
5828
|
+
};
|
|
5829
|
+
}
|
|
5830
|
+
function normalizeOpsExecutionContract(rawContract) {
|
|
5831
|
+
if (!rawContract || typeof rawContract !== "object" || Array.isArray(rawContract)) return void 0;
|
|
5832
|
+
const contract = asRecord2(rawContract);
|
|
5833
|
+
const nangoRoute = normalizeOpsExecutionNangoRouteContract(contract.nango_route ?? contract.nangoRoute);
|
|
5834
|
+
const sequence = Array.isArray(contract.sequence) ? contract.sequence.map(normalizeOpsExecutionToolCall) : [];
|
|
5835
|
+
return {
|
|
5836
|
+
...contract,
|
|
5837
|
+
mode: stringValue2(contract.mode, "run_once"),
|
|
5838
|
+
run_now: normalizeOpsExecutionToolCall(contract.run_now ?? contract.runNow),
|
|
5839
|
+
runNow: normalizeOpsExecutionToolCall(contract.runNow ?? contract.run_now),
|
|
5840
|
+
schedule: normalizeOpsExecutionScheduleContract(contract.schedule),
|
|
5841
|
+
approval: normalizeOpsExecutionApprovalContract(contract.approval),
|
|
5842
|
+
monitor: normalizeOpsExecutionMonitorContract(contract.monitor),
|
|
5843
|
+
result_contract: normalizeOpsExecutionResultContract(contract.result_contract ?? contract.resultContract),
|
|
5844
|
+
resultContract: normalizeOpsExecutionResultContract(contract.resultContract ?? contract.result_contract),
|
|
5845
|
+
...nangoRoute ? { nango_route: nangoRoute, nangoRoute } : {},
|
|
5846
|
+
sequence
|
|
5847
|
+
};
|
|
5848
|
+
}
|
|
5005
5849
|
function normalizeOpsPlanResult(result) {
|
|
5006
5850
|
const primitiveGraph = result.primitive_graph ?? result.primitiveGraph;
|
|
5851
|
+
const executionContract = normalizeOpsExecutionContract(result.execution_contract ?? result.executionContract);
|
|
5007
5852
|
return {
|
|
5008
5853
|
...result,
|
|
5009
5854
|
plan_id: result.plan_id ?? result.planId,
|
|
@@ -5027,7 +5872,8 @@ function normalizeOpsPlanResult(result) {
|
|
|
5027
5872
|
destination_status: result.destination_status ?? result.destinationStatus,
|
|
5028
5873
|
destinationStatus: result.destinationStatus ?? result.destination_status,
|
|
5029
5874
|
primitive_graph: primitiveGraph?.map(normalizeOpsPrimitive),
|
|
5030
|
-
primitiveGraph: primitiveGraph?.map(normalizeOpsPrimitive)
|
|
5875
|
+
primitiveGraph: primitiveGraph?.map(normalizeOpsPrimitive),
|
|
5876
|
+
...executionContract ? { execution_contract: executionContract, executionContract } : {}
|
|
5031
5877
|
};
|
|
5032
5878
|
}
|
|
5033
5879
|
function normalizeOpsCreateResult(result) {
|
|
@@ -5049,7 +5895,18 @@ function normalizeOpsCreateResult(result) {
|
|
|
5049
5895
|
deliveryStatus: result.deliveryStatus ?? result.delivery_status,
|
|
5050
5896
|
estimated_credits: result.estimated_credits ?? result.estimatedCredits,
|
|
5051
5897
|
estimatedCredits: result.estimatedCredits ?? result.estimated_credits,
|
|
5052
|
-
|
|
5898
|
+
error_code: result.error_code ?? result.errorCode,
|
|
5899
|
+
errorCode: result.errorCode ?? result.error_code,
|
|
5900
|
+
approval_required: result.approval_required ?? result.approvalRequired,
|
|
5901
|
+
approvalRequired: result.approvalRequired ?? result.approval_required,
|
|
5902
|
+
retry_arguments: result.retry_arguments ?? result.retryArguments,
|
|
5903
|
+
retryArguments: result.retryArguments ?? result.retry_arguments,
|
|
5904
|
+
blockers: result.blockers,
|
|
5905
|
+
plan: result.plan ? normalizeOpsPlanResult(result.plan) : result.plan,
|
|
5906
|
+
next_step: result.next_step ?? result.nextStep,
|
|
5907
|
+
nextStep: result.nextStep ?? result.next_step,
|
|
5908
|
+
next_steps: result.next_steps ?? result.nextSteps,
|
|
5909
|
+
nextSteps: result.nextSteps ?? result.next_steps
|
|
5053
5910
|
};
|
|
5054
5911
|
}
|
|
5055
5912
|
function normalizeOpsExecuteResult(result) {
|
|
@@ -5177,6 +6034,40 @@ function normalizeOpsStatusResult(result) {
|
|
|
5177
6034
|
diagnosis: result.diagnosis ? normalizeOpsDebugDiagnosis(result.diagnosis) : void 0
|
|
5178
6035
|
};
|
|
5179
6036
|
}
|
|
6037
|
+
function normalizeOpsResultsSummary(value) {
|
|
6038
|
+
const summary = asRecord2(value);
|
|
6039
|
+
if (Object.keys(summary).length === 0) return void 0;
|
|
6040
|
+
const resultsTotal = summary.results_total ?? summary.resultsTotal;
|
|
6041
|
+
const nextCursor = summary.next_cursor ?? summary.nextCursor ?? null;
|
|
6042
|
+
const resultsUrl = summary.results_url ?? summary.resultsUrl;
|
|
6043
|
+
const nextAction = summary.next_action ?? summary.nextAction;
|
|
6044
|
+
const runId = summary.run_id ?? summary.runId ?? null;
|
|
6045
|
+
const creditsUsed = summary.credits_used ?? summary.creditsUsed;
|
|
6046
|
+
return {
|
|
6047
|
+
...summary,
|
|
6048
|
+
label: optionalString(summary.label),
|
|
6049
|
+
status: optionalString(summary.status),
|
|
6050
|
+
phase: optionalString(summary.phase),
|
|
6051
|
+
results_count: numberValue(summary.results_count ?? summary.resultsCount),
|
|
6052
|
+
resultsCount: numberValue(summary.results_count ?? summary.resultsCount),
|
|
6053
|
+
results_total: resultsTotal === null || resultsTotal === void 0 ? resultsTotal : numberValue(resultsTotal),
|
|
6054
|
+
resultsTotal: resultsTotal === null || resultsTotal === void 0 ? resultsTotal : numberValue(resultsTotal),
|
|
6055
|
+
delivery_status: optionalString(summary.delivery_status ?? summary.deliveryStatus),
|
|
6056
|
+
deliveryStatus: optionalString(summary.delivery_status ?? summary.deliveryStatus),
|
|
6057
|
+
has_more: Boolean(summary.has_more ?? summary.hasMore),
|
|
6058
|
+
hasMore: Boolean(summary.has_more ?? summary.hasMore),
|
|
6059
|
+
next_cursor: nextCursor === null ? null : optionalString(nextCursor),
|
|
6060
|
+
nextCursor: nextCursor === null ? null : optionalString(nextCursor),
|
|
6061
|
+
results_url: optionalString(resultsUrl),
|
|
6062
|
+
resultsUrl: optionalString(resultsUrl),
|
|
6063
|
+
next_action: optionalString(nextAction),
|
|
6064
|
+
nextAction: optionalString(nextAction),
|
|
6065
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6066
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6067
|
+
credits_used: creditsUsed === void 0 ? void 0 : numberValue(creditsUsed),
|
|
6068
|
+
creditsUsed: creditsUsed === void 0 ? void 0 : numberValue(creditsUsed)
|
|
6069
|
+
};
|
|
6070
|
+
}
|
|
5180
6071
|
function normalizeOpsResultsResult(result) {
|
|
5181
6072
|
const nextCursor = result.next_cursor ?? result.nextCursor ?? null;
|
|
5182
6073
|
const hasMore = result.has_more ?? result.hasMore ?? false;
|
|
@@ -5201,7 +6092,104 @@ function normalizeOpsResultsResult(result) {
|
|
|
5201
6092
|
results_url: result.results_url ?? result.resultsUrl,
|
|
5202
6093
|
resultsUrl: result.resultsUrl ?? result.results_url,
|
|
5203
6094
|
delivery_status: result.delivery_status ?? result.deliveryStatus,
|
|
5204
|
-
deliveryStatus: result.deliveryStatus ?? result.delivery_status
|
|
6095
|
+
deliveryStatus: result.deliveryStatus ?? result.delivery_status,
|
|
6096
|
+
summary: normalizeOpsResultsSummary(result.summary)
|
|
6097
|
+
};
|
|
6098
|
+
}
|
|
6099
|
+
function normalizeOpsWaitForResultsPoll(value, fallbackPoll) {
|
|
6100
|
+
const raw = asRecord2(value);
|
|
6101
|
+
const checkedAt = stringValue2(raw.checked_at ?? raw.checkedAt);
|
|
6102
|
+
const resultsCount = raw.results_count ?? raw.resultsCount;
|
|
6103
|
+
const runId = raw.run_id ?? raw.runId ?? null;
|
|
6104
|
+
const nextAction = raw.next_action ?? raw.nextAction;
|
|
6105
|
+
return {
|
|
6106
|
+
...raw,
|
|
6107
|
+
poll: numberValue(raw.poll) || fallbackPoll,
|
|
6108
|
+
checked_at: checkedAt,
|
|
6109
|
+
checkedAt,
|
|
6110
|
+
status: stringValue2(raw.status, "unknown"),
|
|
6111
|
+
phase: optionalString(raw.phase),
|
|
6112
|
+
results_count: resultsCount === void 0 ? void 0 : numberValue(resultsCount),
|
|
6113
|
+
resultsCount: resultsCount === void 0 ? void 0 : numberValue(resultsCount),
|
|
6114
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6115
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6116
|
+
next_action: optionalString(nextAction),
|
|
6117
|
+
nextAction: optionalString(nextAction)
|
|
6118
|
+
};
|
|
6119
|
+
}
|
|
6120
|
+
function normalizeOpsWaitForResultsResult(result, options) {
|
|
6121
|
+
const opId = stringValue2(result.op_id ?? result.opId ?? options.op_id);
|
|
6122
|
+
const routineId = stringValue2(result.routine_id ?? result.routineId ?? opId);
|
|
6123
|
+
const runId = result.run_id ?? result.runId ?? null;
|
|
6124
|
+
const timedOut = Boolean(result.timed_out ?? result.timedOut);
|
|
6125
|
+
const statusRaw = asRecord2(result.status_result ?? result.statusResult);
|
|
6126
|
+
const resultsRaw = asRecord2(result.results_result ?? result.resultsResult);
|
|
6127
|
+
const historySource = Array.isArray(result.poll_history) ? result.poll_history : Array.isArray(result.history) ? result.history : [];
|
|
6128
|
+
const history = historySource.map((item, index) => normalizeOpsWaitForResultsPoll(item, index + 1));
|
|
6129
|
+
const status = normalizeOpsStatusResult(withExecutionRefs({
|
|
6130
|
+
success: result.success !== false,
|
|
6131
|
+
op_id: opId,
|
|
6132
|
+
routine_id: routineId,
|
|
6133
|
+
run_id: runId,
|
|
6134
|
+
status: stringValue2(result.status, "unknown"),
|
|
6135
|
+
phase: stringValue2(result.phase, "unknown"),
|
|
6136
|
+
next_action: stringValue2(result.next_action ?? result.nextAction),
|
|
6137
|
+
results_count: numberValue(result.results_count ?? result.resultsCount),
|
|
6138
|
+
results_url: optionalString(result.results_url ?? result.resultsUrl),
|
|
6139
|
+
delivery_status: optionalString(result.delivery_status ?? result.deliveryStatus),
|
|
6140
|
+
...statusRaw
|
|
6141
|
+
}));
|
|
6142
|
+
const includeResults = options.include_results !== false && options.includeResults !== false;
|
|
6143
|
+
const hasResultsPacket = Object.keys(resultsRaw).length > 0 || Array.isArray(result.results);
|
|
6144
|
+
const results = includeResults && hasResultsPacket ? normalizeOpsResultsResult(withExecutionRefs({
|
|
6145
|
+
success: result.success !== false,
|
|
6146
|
+
op_id: opId,
|
|
6147
|
+
routine_id: routineId,
|
|
6148
|
+
run_id: runId,
|
|
6149
|
+
status: stringValue2(result.status, status.status),
|
|
6150
|
+
phase: stringValue2(result.phase, status.phase),
|
|
6151
|
+
results_count: numberValue(result.results_count ?? result.resultsCount),
|
|
6152
|
+
results_total: result.results_total ?? result.resultsTotal ?? null,
|
|
6153
|
+
results: Array.isArray(result.results) ? result.results : [],
|
|
6154
|
+
next_cursor: result.next_cursor ?? result.nextCursor ?? null,
|
|
6155
|
+
has_more: Boolean(result.has_more ?? result.hasMore),
|
|
6156
|
+
next_action: stringValue2(result.next_action ?? result.nextAction),
|
|
6157
|
+
results_url: optionalString(result.results_url ?? result.resultsUrl),
|
|
6158
|
+
delivery_status: optionalString(result.delivery_status ?? result.deliveryStatus),
|
|
6159
|
+
...resultsRaw
|
|
6160
|
+
})) : void 0;
|
|
6161
|
+
const polls = numberValue(result.polls) || history.length;
|
|
6162
|
+
const maxPolls = result.max_polls ?? result.maxPolls;
|
|
6163
|
+
const intervalMs = result.interval_ms ?? result.intervalMs;
|
|
6164
|
+
const timeoutMs = result.timeout_ms ?? result.timeoutMs;
|
|
6165
|
+
const stopReason = result.stop_reason ?? result.stopReason;
|
|
6166
|
+
const nextAction = result.next_action ?? result.nextAction ?? results?.next_action ?? status.next_action;
|
|
6167
|
+
return {
|
|
6168
|
+
...result,
|
|
6169
|
+
success: result.success !== false && !timedOut,
|
|
6170
|
+
op_id: opId,
|
|
6171
|
+
opId,
|
|
6172
|
+
routine_id: routineId,
|
|
6173
|
+
routineId,
|
|
6174
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6175
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6176
|
+
status,
|
|
6177
|
+
results,
|
|
6178
|
+
timed_out: timedOut,
|
|
6179
|
+
timedOut,
|
|
6180
|
+
polls,
|
|
6181
|
+
max_polls: maxPolls === void 0 ? void 0 : numberValue(maxPolls),
|
|
6182
|
+
maxPolls: maxPolls === void 0 ? void 0 : numberValue(maxPolls),
|
|
6183
|
+
interval_ms: intervalMs === void 0 ? void 0 : numberValue(intervalMs),
|
|
6184
|
+
intervalMs: intervalMs === void 0 ? void 0 : numberValue(intervalMs),
|
|
6185
|
+
timeout_ms: timeoutMs === void 0 ? void 0 : numberValue(timeoutMs),
|
|
6186
|
+
timeoutMs: timeoutMs === void 0 ? void 0 : numberValue(timeoutMs),
|
|
6187
|
+
stop_reason: optionalString(stopReason),
|
|
6188
|
+
stopReason: optionalString(stopReason),
|
|
6189
|
+
history,
|
|
6190
|
+
next_action: optionalString(nextAction),
|
|
6191
|
+
nextAction: optionalString(nextAction),
|
|
6192
|
+
execution_refs: mergeExecutionRefsFrom([result, status, results, { history }])
|
|
5205
6193
|
};
|
|
5206
6194
|
}
|
|
5207
6195
|
function normalizeOpsProofResult(data) {
|
|
@@ -5281,11 +6269,107 @@ function normalizeOpsProofResult(data) {
|
|
|
5281
6269
|
raw: data
|
|
5282
6270
|
};
|
|
5283
6271
|
}
|
|
6272
|
+
function normalizeOpsAutopilotSchedulePacket(rawPacket) {
|
|
6273
|
+
const packet = asRecord2(rawPacket);
|
|
6274
|
+
return {
|
|
6275
|
+
...packet,
|
|
6276
|
+
cadence: stringValue2(packet.cadence, "manual"),
|
|
6277
|
+
recurrence: stringValue2(packet.recurrence),
|
|
6278
|
+
activate_with: stringValue2(packet.activate_with ?? packet.activateWith),
|
|
6279
|
+
activateWith: stringValue2(packet.activate_with ?? packet.activateWith),
|
|
6280
|
+
run_now_with: stringValue2(packet.run_now_with ?? packet.runNowWith),
|
|
6281
|
+
runNowWith: stringValue2(packet.run_now_with ?? packet.runNowWith),
|
|
6282
|
+
monitor_with: stringValue2(packet.monitor_with ?? packet.monitorWith),
|
|
6283
|
+
monitorWith: stringValue2(packet.monitor_with ?? packet.monitorWith),
|
|
6284
|
+
retrieve_with: stringValue2(packet.retrieve_with ?? packet.retrieveWith),
|
|
6285
|
+
retrieveWith: stringValue2(packet.retrieve_with ?? packet.retrieveWith)
|
|
6286
|
+
};
|
|
6287
|
+
}
|
|
6288
|
+
function normalizeOpsAutopilotNangoRoutePacket(rawPacket) {
|
|
6289
|
+
if (!rawPacket || typeof rawPacket !== "object" || Array.isArray(rawPacket)) return void 0;
|
|
6290
|
+
const packet = asRecord2(rawPacket);
|
|
6291
|
+
const requiredFields = Array.isArray(packet.required_fields) ? packet.required_fields.map(String) : Array.isArray(packet.requiredFields) ? packet.requiredFields.map(String) : [];
|
|
6292
|
+
return {
|
|
6293
|
+
...packet,
|
|
6294
|
+
enabled: packet.enabled !== false,
|
|
6295
|
+
route_label: stringValue2(packet.route_label ?? packet.routeLabel),
|
|
6296
|
+
routeLabel: stringValue2(packet.route_label ?? packet.routeLabel),
|
|
6297
|
+
connect_tool: stringValue2(packet.connect_tool ?? packet.connectTool),
|
|
6298
|
+
connectTool: stringValue2(packet.connect_tool ?? packet.connectTool),
|
|
6299
|
+
discover_tool: stringValue2(packet.discover_tool ?? packet.discoverTool),
|
|
6300
|
+
discoverTool: stringValue2(packet.discover_tool ?? packet.discoverTool),
|
|
6301
|
+
dry_run_tool: stringValue2(packet.dry_run_tool ?? packet.dryRunTool),
|
|
6302
|
+
dryRunTool: stringValue2(packet.dry_run_tool ?? packet.dryRunTool),
|
|
6303
|
+
execute_tool: stringValue2(packet.execute_tool ?? packet.executeTool),
|
|
6304
|
+
executeTool: stringValue2(packet.execute_tool ?? packet.executeTool),
|
|
6305
|
+
execute_and_wait_tool: stringValue2(packet.execute_and_wait_tool ?? packet.executeAndWaitTool),
|
|
6306
|
+
executeAndWaitTool: stringValue2(packet.execute_and_wait_tool ?? packet.executeAndWaitTool),
|
|
6307
|
+
schedule_tool: stringValue2(packet.schedule_tool ?? packet.scheduleTool),
|
|
6308
|
+
scheduleTool: stringValue2(packet.schedule_tool ?? packet.scheduleTool),
|
|
6309
|
+
schedule_and_wait_tool: stringValue2(packet.schedule_and_wait_tool ?? packet.scheduleAndWaitTool),
|
|
6310
|
+
scheduleAndWaitTool: stringValue2(packet.schedule_and_wait_tool ?? packet.scheduleAndWaitTool),
|
|
6311
|
+
result_tool: stringValue2(packet.result_tool ?? packet.resultTool),
|
|
6312
|
+
resultTool: stringValue2(packet.result_tool ?? packet.resultTool),
|
|
6313
|
+
write_gate: stringValue2(packet.write_gate ?? packet.writeGate),
|
|
6314
|
+
writeGate: stringValue2(packet.write_gate ?? packet.writeGate),
|
|
6315
|
+
required_fields: requiredFields,
|
|
6316
|
+
requiredFields,
|
|
6317
|
+
placeholders: asRecord2(packet.placeholders),
|
|
6318
|
+
dry_run_arguments: asRecord2(packet.dry_run_arguments ?? packet.dryRunArguments),
|
|
6319
|
+
dryRunArguments: asRecord2(packet.dry_run_arguments ?? packet.dryRunArguments),
|
|
6320
|
+
execute_arguments: asRecord2(packet.execute_arguments ?? packet.executeArguments),
|
|
6321
|
+
executeArguments: asRecord2(packet.execute_arguments ?? packet.executeArguments),
|
|
6322
|
+
execute_and_wait_arguments: asRecord2(packet.execute_and_wait_arguments ?? packet.executeAndWaitArguments),
|
|
6323
|
+
executeAndWaitArguments: asRecord2(packet.execute_and_wait_arguments ?? packet.executeAndWaitArguments),
|
|
6324
|
+
schedule_arguments: asRecord2(packet.schedule_arguments ?? packet.scheduleArguments),
|
|
6325
|
+
scheduleArguments: asRecord2(packet.schedule_arguments ?? packet.scheduleArguments),
|
|
6326
|
+
schedule_and_wait_arguments: asRecord2(packet.schedule_and_wait_arguments ?? packet.scheduleAndWaitArguments),
|
|
6327
|
+
scheduleAndWaitArguments: asRecord2(packet.schedule_and_wait_arguments ?? packet.scheduleAndWaitArguments),
|
|
6328
|
+
result_arguments: asRecord2(packet.result_arguments ?? packet.resultArguments),
|
|
6329
|
+
resultArguments: asRecord2(packet.result_arguments ?? packet.resultArguments)
|
|
6330
|
+
};
|
|
6331
|
+
}
|
|
6332
|
+
function normalizeOpsAutopilotResultPacket(rawPacket) {
|
|
6333
|
+
const packet = asRecord2(rawPacket);
|
|
6334
|
+
const resultShape = Array.isArray(packet.result_shape) ? packet.result_shape.map(String) : Array.isArray(packet.resultShape) ? packet.resultShape.map(String) : [];
|
|
6335
|
+
const deliveryReceipts = Array.isArray(packet.delivery_receipts) ? packet.delivery_receipts.map(String) : Array.isArray(packet.deliveryReceipts) ? packet.deliveryReceipts.map(String) : [];
|
|
6336
|
+
return {
|
|
6337
|
+
...packet,
|
|
6338
|
+
retrieve_tool: stringValue2(packet.retrieve_tool ?? packet.retrieveTool),
|
|
6339
|
+
retrieveTool: stringValue2(packet.retrieve_tool ?? packet.retrieveTool),
|
|
6340
|
+
result_shape: resultShape,
|
|
6341
|
+
resultShape,
|
|
6342
|
+
delivery_receipts: deliveryReceipts,
|
|
6343
|
+
deliveryReceipts,
|
|
6344
|
+
empty_result_recovery: stringValue2(packet.empty_result_recovery ?? packet.emptyResultRecovery),
|
|
6345
|
+
emptyResultRecovery: stringValue2(packet.empty_result_recovery ?? packet.emptyResultRecovery)
|
|
6346
|
+
};
|
|
6347
|
+
}
|
|
6348
|
+
function normalizeOpsAutopilotOperatingPacket(rawPacket) {
|
|
6349
|
+
if (!rawPacket || typeof rawPacket !== "object" || Array.isArray(rawPacket)) return void 0;
|
|
6350
|
+
const packet = asRecord2(rawPacket);
|
|
6351
|
+
const nangoRoute = normalizeOpsAutopilotNangoRoutePacket(packet.nango_route ?? packet.nangoRoute);
|
|
6352
|
+
const approvalBoundaries = Array.isArray(packet.approval_boundaries) ? packet.approval_boundaries.map(String) : Array.isArray(packet.approvalBoundaries) ? packet.approvalBoundaries.map(String) : [];
|
|
6353
|
+
return {
|
|
6354
|
+
...packet,
|
|
6355
|
+
north_star: stringValue2(packet.north_star ?? packet.northStar),
|
|
6356
|
+
northStar: stringValue2(packet.north_star ?? packet.northStar),
|
|
6357
|
+
schedule: normalizeOpsAutopilotSchedulePacket(packet.schedule),
|
|
6358
|
+
...nangoRoute ? { nango_route: nangoRoute, nangoRoute } : {},
|
|
6359
|
+
result_contract: normalizeOpsAutopilotResultPacket(packet.result_contract ?? packet.resultContract),
|
|
6360
|
+
resultContract: normalizeOpsAutopilotResultPacket(packet.result_contract ?? packet.resultContract),
|
|
6361
|
+
approval_boundaries: approvalBoundaries,
|
|
6362
|
+
approvalBoundaries,
|
|
6363
|
+
saved_command_hint: stringValue2(packet.saved_command_hint ?? packet.savedCommandHint),
|
|
6364
|
+
savedCommandHint: stringValue2(packet.saved_command_hint ?? packet.savedCommandHint)
|
|
6365
|
+
};
|
|
6366
|
+
}
|
|
5284
6367
|
function normalizeOpsAutopilotMotion(rawMotion) {
|
|
5285
6368
|
const motion = asRecord2(rawMotion);
|
|
5286
6369
|
const targetCount = numberValue(motion.target_count ?? motion.targetCount);
|
|
5287
6370
|
const estimatedCredits = numberValue(motion.estimated_credits ?? motion.estimatedCredits);
|
|
5288
6371
|
const mcpSequence = Array.isArray(motion.mcp_sequence) ? motion.mcp_sequence : Array.isArray(motion.mcpSequence) ? motion.mcpSequence : [];
|
|
6372
|
+
const operatingPacket = normalizeOpsAutopilotOperatingPacket(motion.operating_packet ?? motion.operatingPacket);
|
|
5289
6373
|
return {
|
|
5290
6374
|
...motion,
|
|
5291
6375
|
id: stringValue2(motion.id),
|
|
@@ -5308,12 +6392,16 @@ function normalizeOpsAutopilotMotion(rawMotion) {
|
|
|
5308
6392
|
cli_command: optionalString(motion.cli_command ?? motion.cliCommand),
|
|
5309
6393
|
cliCommand: optionalString(motion.cli_command ?? motion.cliCommand),
|
|
5310
6394
|
mcp_sequence: mcpSequence,
|
|
5311
|
-
mcpSequence
|
|
6395
|
+
mcpSequence,
|
|
6396
|
+
...operatingPacket ? { operating_packet: operatingPacket, operatingPacket } : {}
|
|
5312
6397
|
};
|
|
5313
6398
|
}
|
|
5314
6399
|
function normalizeOpsAutopilotResult(result) {
|
|
5315
6400
|
const primary = normalizeOpsAutopilotMotion(result.primary_motion ?? result.primaryMotion);
|
|
5316
6401
|
const motions = Array.isArray(result.motions) ? result.motions.map(normalizeOpsAutopilotMotion) : [];
|
|
6402
|
+
const operatingPacket = normalizeOpsAutopilotOperatingPacket(
|
|
6403
|
+
result.operating_packet ?? result.operatingPacket ?? primary.operating_packet ?? primary.operatingPacket
|
|
6404
|
+
);
|
|
5317
6405
|
const queryErrors = Array.isArray(result.query_errors) ? result.query_errors.map(String) : Array.isArray(result.queryErrors) ? result.queryErrors.map(String) : [];
|
|
5318
6406
|
return {
|
|
5319
6407
|
...result,
|
|
@@ -5329,6 +6417,7 @@ function normalizeOpsAutopilotResult(result) {
|
|
|
5329
6417
|
scaleRule: optionalString(result.scale_rule ?? result.scaleRule),
|
|
5330
6418
|
agent_handoff: optionalString(result.agent_handoff ?? result.agentHandoff),
|
|
5331
6419
|
agentHandoff: optionalString(result.agent_handoff ?? result.agentHandoff),
|
|
6420
|
+
...operatingPacket ? { operating_packet: operatingPacket, operatingPacket } : {},
|
|
5332
6421
|
proof_state: optionalString(result.proof_state ?? result.proofState),
|
|
5333
6422
|
proofState: optionalString(result.proof_state ?? result.proofState),
|
|
5334
6423
|
proof_summary: result.proof_summary ?? result.proofSummary,
|
|
@@ -5593,11 +6682,125 @@ function normalizeOpsRoutineTickItemsResult(result) {
|
|
|
5593
6682
|
hasMore
|
|
5594
6683
|
};
|
|
5595
6684
|
}
|
|
6685
|
+
function buildOpsNangoScheduleBody(input) {
|
|
6686
|
+
const {
|
|
6687
|
+
workspaceConnectionId,
|
|
6688
|
+
workspace_connection_id,
|
|
6689
|
+
connectionId,
|
|
6690
|
+
connection_id,
|
|
6691
|
+
providerConfigKey,
|
|
6692
|
+
provider_config_key,
|
|
6693
|
+
integrationId,
|
|
6694
|
+
integration_id,
|
|
6695
|
+
nangoConnectionId,
|
|
6696
|
+
nango_connection_id,
|
|
6697
|
+
actionName,
|
|
6698
|
+
action_name,
|
|
6699
|
+
toolName,
|
|
6700
|
+
tool_name,
|
|
6701
|
+
proxyPath,
|
|
6702
|
+
proxy_path,
|
|
6703
|
+
nangoProxyPath,
|
|
6704
|
+
nango_proxy_path,
|
|
6705
|
+
method,
|
|
6706
|
+
httpMethod,
|
|
6707
|
+
http_method,
|
|
6708
|
+
input: nangoInput,
|
|
6709
|
+
arguments: nangoArguments,
|
|
6710
|
+
fieldMap,
|
|
6711
|
+
field_map,
|
|
6712
|
+
requiredFields,
|
|
6713
|
+
required_fields,
|
|
6714
|
+
writeConfirmed,
|
|
6715
|
+
write_confirmed,
|
|
6716
|
+
agentWriteConfirmed,
|
|
6717
|
+
agent_write_confirmed,
|
|
6718
|
+
config,
|
|
6719
|
+
destinations: _destinations,
|
|
6720
|
+
...schedule
|
|
6721
|
+
} = input;
|
|
6722
|
+
return {
|
|
6723
|
+
...buildOpsCreateBody({
|
|
6724
|
+
...schedule,
|
|
6725
|
+
cadence: schedule.cadence ?? "daily"
|
|
6726
|
+
}),
|
|
6727
|
+
workspace_connection_id: workspace_connection_id ?? workspaceConnectionId,
|
|
6728
|
+
connection_id: connection_id ?? connectionId,
|
|
6729
|
+
provider_config_key: provider_config_key ?? providerConfigKey,
|
|
6730
|
+
integration_id: integration_id ?? integrationId,
|
|
6731
|
+
nango_connection_id: nango_connection_id ?? nangoConnectionId,
|
|
6732
|
+
action_name: action_name ?? actionName,
|
|
6733
|
+
tool_name: tool_name ?? toolName,
|
|
6734
|
+
proxy_path: proxy_path ?? proxyPath ?? nango_proxy_path ?? nangoProxyPath,
|
|
6735
|
+
nango_proxy_path: nango_proxy_path ?? nangoProxyPath,
|
|
6736
|
+
method: method ?? http_method ?? httpMethod,
|
|
6737
|
+
input: nangoInput ?? nangoArguments,
|
|
6738
|
+
field_map: field_map ?? fieldMap,
|
|
6739
|
+
required_fields: required_fields ?? requiredFields,
|
|
6740
|
+
write_confirmed: write_confirmed ?? writeConfirmed,
|
|
6741
|
+
agent_write_confirmed: agent_write_confirmed ?? agentWriteConfirmed,
|
|
6742
|
+
config
|
|
6743
|
+
};
|
|
6744
|
+
}
|
|
6745
|
+
function buildOpsNangoScheduleAndWaitOptions(params) {
|
|
6746
|
+
const {
|
|
6747
|
+
force,
|
|
6748
|
+
instruction,
|
|
6749
|
+
nextCursor,
|
|
6750
|
+
includeFailedRuns,
|
|
6751
|
+
intervalMs,
|
|
6752
|
+
maxPolls,
|
|
6753
|
+
timeoutMs,
|
|
6754
|
+
includeResults,
|
|
6755
|
+
cursor,
|
|
6756
|
+
state,
|
|
6757
|
+
limit,
|
|
6758
|
+
include_failed_runs,
|
|
6759
|
+
interval_ms,
|
|
6760
|
+
max_polls,
|
|
6761
|
+
timeout_ms,
|
|
6762
|
+
include_results,
|
|
6763
|
+
...schedule
|
|
6764
|
+
} = params;
|
|
6765
|
+
return {
|
|
6766
|
+
schedule: {
|
|
6767
|
+
...schedule,
|
|
6768
|
+
cadence: schedule.cadence ?? "daily"
|
|
6769
|
+
},
|
|
6770
|
+
run: {
|
|
6771
|
+
force,
|
|
6772
|
+
instruction
|
|
6773
|
+
},
|
|
6774
|
+
wait: {
|
|
6775
|
+
cursor: cursor ?? nextCursor,
|
|
6776
|
+
state,
|
|
6777
|
+
limit,
|
|
6778
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6779
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6780
|
+
max_polls: max_polls ?? maxPolls,
|
|
6781
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6782
|
+
include_results: include_results ?? includeResults
|
|
6783
|
+
}
|
|
6784
|
+
};
|
|
6785
|
+
}
|
|
6786
|
+
function buildOpsNangoScheduleAndWaitBody(options) {
|
|
6787
|
+
const waitBody = buildOpsWaitBody(options.wait);
|
|
6788
|
+
const { op_id: _opId, ...waitWithoutOp } = waitBody;
|
|
6789
|
+
return {
|
|
6790
|
+
...buildOpsNangoScheduleBody(options.schedule),
|
|
6791
|
+
...waitWithoutOp,
|
|
6792
|
+
instruction: options.run.instruction,
|
|
6793
|
+
force: options.run.force
|
|
6794
|
+
};
|
|
6795
|
+
}
|
|
5596
6796
|
function buildOpsPlanBody(params) {
|
|
5597
|
-
const { targetCount, companyDomains, customAiPrompt, signalPrompt, outputPrompt, ...rest } = params;
|
|
6797
|
+
const { targetCount, wakeOnEvents, companyDomains, customAiPrompt, signalPrompt, outputPrompt, ...rest } = params;
|
|
6798
|
+
const destinations = Array.isArray(rest.destinations) ? rest.destinations.map(normalizeOpsDestinationRequest) : rest.destinations;
|
|
5598
6799
|
return {
|
|
5599
6800
|
...rest,
|
|
6801
|
+
destinations,
|
|
5600
6802
|
target_count: rest.target_count ?? targetCount,
|
|
6803
|
+
wake_on_events: rest.wake_on_events ?? wakeOnEvents,
|
|
5601
6804
|
company_domains: rest.company_domains ?? companyDomains,
|
|
5602
6805
|
custom_ai_prompt: rest.custom_ai_prompt ?? customAiPrompt,
|
|
5603
6806
|
signal_prompt: rest.signal_prompt ?? signalPrompt,
|
|
@@ -5620,6 +6823,95 @@ function buildOpsExecuteBody(params) {
|
|
|
5620
6823
|
output_format: rest.output_format ?? outputFormat
|
|
5621
6824
|
};
|
|
5622
6825
|
}
|
|
6826
|
+
function buildOpsExecuteAndWaitOptions(params) {
|
|
6827
|
+
const {
|
|
6828
|
+
nextCursor,
|
|
6829
|
+
includeFailedRuns,
|
|
6830
|
+
intervalMs,
|
|
6831
|
+
maxPolls,
|
|
6832
|
+
timeoutMs,
|
|
6833
|
+
includeResults,
|
|
6834
|
+
cursor,
|
|
6835
|
+
state,
|
|
6836
|
+
limit,
|
|
6837
|
+
include_failed_runs,
|
|
6838
|
+
interval_ms,
|
|
6839
|
+
max_polls,
|
|
6840
|
+
timeout_ms,
|
|
6841
|
+
include_results,
|
|
6842
|
+
...execute
|
|
6843
|
+
} = params;
|
|
6844
|
+
return {
|
|
6845
|
+
execute: {
|
|
6846
|
+
...execute,
|
|
6847
|
+
auto_run: execute.auto_run ?? execute.autoRun ?? true
|
|
6848
|
+
},
|
|
6849
|
+
wait: {
|
|
6850
|
+
cursor: cursor ?? nextCursor,
|
|
6851
|
+
state,
|
|
6852
|
+
limit,
|
|
6853
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6854
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6855
|
+
max_polls: max_polls ?? maxPolls,
|
|
6856
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6857
|
+
include_results: include_results ?? includeResults
|
|
6858
|
+
}
|
|
6859
|
+
};
|
|
6860
|
+
}
|
|
6861
|
+
function buildOpsScheduleAndWaitOptions(params) {
|
|
6862
|
+
const {
|
|
6863
|
+
force,
|
|
6864
|
+
instruction,
|
|
6865
|
+
nextCursor,
|
|
6866
|
+
includeFailedRuns,
|
|
6867
|
+
intervalMs,
|
|
6868
|
+
maxPolls,
|
|
6869
|
+
timeoutMs,
|
|
6870
|
+
includeResults,
|
|
6871
|
+
cursor,
|
|
6872
|
+
state,
|
|
6873
|
+
limit,
|
|
6874
|
+
include_failed_runs,
|
|
6875
|
+
interval_ms,
|
|
6876
|
+
max_polls,
|
|
6877
|
+
timeout_ms,
|
|
6878
|
+
include_results,
|
|
6879
|
+
...schedule
|
|
6880
|
+
} = params;
|
|
6881
|
+
return {
|
|
6882
|
+
schedule: {
|
|
6883
|
+
...schedule,
|
|
6884
|
+
cadence: schedule.cadence ?? "daily"
|
|
6885
|
+
},
|
|
6886
|
+
run: {
|
|
6887
|
+
force,
|
|
6888
|
+
instruction
|
|
6889
|
+
},
|
|
6890
|
+
wait: {
|
|
6891
|
+
cursor: cursor ?? nextCursor,
|
|
6892
|
+
state,
|
|
6893
|
+
limit,
|
|
6894
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6895
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6896
|
+
max_polls: max_polls ?? maxPolls,
|
|
6897
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6898
|
+
include_results: include_results ?? includeResults
|
|
6899
|
+
}
|
|
6900
|
+
};
|
|
6901
|
+
}
|
|
6902
|
+
function buildOpsScheduleAndWaitBody(options) {
|
|
6903
|
+
const waitBody = buildOpsWaitBody(options.wait);
|
|
6904
|
+
const { op_id: _opId, ...waitWithoutOp } = waitBody;
|
|
6905
|
+
return {
|
|
6906
|
+
...buildOpsCreateBody({
|
|
6907
|
+
...options.schedule,
|
|
6908
|
+
cadence: options.schedule.cadence ?? "daily"
|
|
6909
|
+
}),
|
|
6910
|
+
...waitWithoutOp,
|
|
6911
|
+
instruction: options.run.instruction,
|
|
6912
|
+
force: options.run.force
|
|
6913
|
+
};
|
|
6914
|
+
}
|
|
5623
6915
|
function buildOpsRunBody(params) {
|
|
5624
6916
|
const { opId, ...rest } = params;
|
|
5625
6917
|
return {
|
|
@@ -5627,6 +6919,28 @@ function buildOpsRunBody(params) {
|
|
|
5627
6919
|
op_id: rest.op_id ?? opId
|
|
5628
6920
|
};
|
|
5629
6921
|
}
|
|
6922
|
+
function buildOpsRunAndWaitOptions(params) {
|
|
6923
|
+
const {
|
|
6924
|
+
opId,
|
|
6925
|
+
nextCursor,
|
|
6926
|
+
includeFailedRuns,
|
|
6927
|
+
intervalMs,
|
|
6928
|
+
maxPolls,
|
|
6929
|
+
timeoutMs,
|
|
6930
|
+
includeResults,
|
|
6931
|
+
...rest
|
|
6932
|
+
} = params;
|
|
6933
|
+
return {
|
|
6934
|
+
...rest,
|
|
6935
|
+
op_id: rest.op_id ?? opId,
|
|
6936
|
+
cursor: rest.cursor ?? nextCursor,
|
|
6937
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
6938
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
6939
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
6940
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
6941
|
+
include_results: rest.include_results ?? includeResults
|
|
6942
|
+
};
|
|
6943
|
+
}
|
|
5630
6944
|
function buildOpsStatusBody(params) {
|
|
5631
6945
|
const { opId, ...rest } = params;
|
|
5632
6946
|
return {
|
|
@@ -5643,6 +6957,50 @@ function buildOpsResultsBody(params) {
|
|
|
5643
6957
|
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns
|
|
5644
6958
|
};
|
|
5645
6959
|
}
|
|
6960
|
+
function buildOpsWaitForResultsOptions(params) {
|
|
6961
|
+
const {
|
|
6962
|
+
opId,
|
|
6963
|
+
nextCursor,
|
|
6964
|
+
includeFailedRuns,
|
|
6965
|
+
intervalMs,
|
|
6966
|
+
maxPolls,
|
|
6967
|
+
timeoutMs,
|
|
6968
|
+
includeResults,
|
|
6969
|
+
...rest
|
|
6970
|
+
} = params;
|
|
6971
|
+
return {
|
|
6972
|
+
...rest,
|
|
6973
|
+
op_id: rest.op_id ?? opId,
|
|
6974
|
+
cursor: rest.cursor ?? nextCursor,
|
|
6975
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
6976
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
6977
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
6978
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
6979
|
+
include_results: rest.include_results ?? includeResults
|
|
6980
|
+
};
|
|
6981
|
+
}
|
|
6982
|
+
function buildOpsWaitBody(params) {
|
|
6983
|
+
const {
|
|
6984
|
+
opId,
|
|
6985
|
+
nextCursor,
|
|
6986
|
+
includeFailedRuns,
|
|
6987
|
+
intervalMs,
|
|
6988
|
+
maxPolls,
|
|
6989
|
+
timeoutMs,
|
|
6990
|
+
includeResults,
|
|
6991
|
+
...rest
|
|
6992
|
+
} = params;
|
|
6993
|
+
return {
|
|
6994
|
+
...rest,
|
|
6995
|
+
op_id: rest.op_id ?? opId,
|
|
6996
|
+
cursor: rest.cursor ?? nextCursor,
|
|
6997
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
6998
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
6999
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
7000
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
7001
|
+
include_results: rest.include_results ?? includeResults
|
|
7002
|
+
};
|
|
7003
|
+
}
|
|
5646
7004
|
function buildOpsDebugOptions(params) {
|
|
5647
7005
|
const {
|
|
5648
7006
|
opId,
|
|
@@ -5720,6 +7078,8 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5720
7078
|
nangoAction,
|
|
5721
7079
|
proxyPath,
|
|
5722
7080
|
nangoProxyPath,
|
|
7081
|
+
method,
|
|
7082
|
+
httpMethod,
|
|
5723
7083
|
fieldMap,
|
|
5724
7084
|
requiredFields,
|
|
5725
7085
|
writeConfirmed,
|
|
@@ -5738,6 +7098,7 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5738
7098
|
const nango_action = rest.nango_action ?? nangoAction;
|
|
5739
7099
|
const proxy_path = rest.proxy_path ?? proxyPath;
|
|
5740
7100
|
const nango_proxy_path = rest.nango_proxy_path ?? nangoProxyPath;
|
|
7101
|
+
const http_method = rest.http_method ?? httpMethod;
|
|
5741
7102
|
const field_map = rest.field_map ?? fieldMap;
|
|
5742
7103
|
const required_fields = rest.required_fields ?? requiredFields;
|
|
5743
7104
|
const write_confirmed = rest.write_confirmed ?? writeConfirmed;
|
|
@@ -5752,6 +7113,9 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5752
7113
|
if (nango_action !== void 0 && normalizedConfig.nango_action === void 0) normalizedConfig.nango_action = nango_action;
|
|
5753
7114
|
if (proxy_path !== void 0 && normalizedConfig.proxy_path === void 0) normalizedConfig.proxy_path = proxy_path;
|
|
5754
7115
|
if (nango_proxy_path !== void 0 && normalizedConfig.nango_proxy_path === void 0) normalizedConfig.nango_proxy_path = nango_proxy_path;
|
|
7116
|
+
if (method !== void 0 && normalizedConfig.method === void 0) normalizedConfig.method = method;
|
|
7117
|
+
if (http_method !== void 0 && normalizedConfig.http_method === void 0) normalizedConfig.http_method = http_method;
|
|
7118
|
+
if (normalizedConfig.method === void 0 && http_method !== void 0) normalizedConfig.method = http_method;
|
|
5755
7119
|
if (field_map !== void 0 && normalizedConfig.field_map === void 0) normalizedConfig.field_map = field_map;
|
|
5756
7120
|
if (required_fields !== void 0 && normalizedConfig.required_fields === void 0) normalizedConfig.required_fields = required_fields;
|
|
5757
7121
|
if (write_confirmed !== void 0 && normalizedConfig.write_confirmed === void 0) normalizedConfig.write_confirmed = write_confirmed;
|
|
@@ -5771,6 +7135,8 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5771
7135
|
nango_action,
|
|
5772
7136
|
proxy_path,
|
|
5773
7137
|
nango_proxy_path,
|
|
7138
|
+
method,
|
|
7139
|
+
http_method,
|
|
5774
7140
|
field_map,
|
|
5775
7141
|
required_fields,
|
|
5776
7142
|
write_confirmed,
|
|
@@ -5778,6 +7144,10 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5778
7144
|
config: normalizedConfig
|
|
5779
7145
|
};
|
|
5780
7146
|
}
|
|
7147
|
+
function normalizeOpsDestinationRequest(destination) {
|
|
7148
|
+
if (!destination || typeof destination !== "object" || Array.isArray(destination)) return destination;
|
|
7149
|
+
return normalizeOpsSinkRequest(destination);
|
|
7150
|
+
}
|
|
5781
7151
|
function normalizeOpsSinkConfigRequest(config) {
|
|
5782
7152
|
const out = { ...config ?? {} };
|
|
5783
7153
|
if (out.connection_id === void 0 && out.connectionId !== void 0) out.connection_id = out.connectionId;
|
|
@@ -5791,6 +7161,8 @@ function normalizeOpsSinkConfigRequest(config) {
|
|
|
5791
7161
|
if (out.nango_action === void 0 && out.nangoAction !== void 0) out.nango_action = out.nangoAction;
|
|
5792
7162
|
if (out.proxy_path === void 0 && out.proxyPath !== void 0) out.proxy_path = out.proxyPath;
|
|
5793
7163
|
if (out.nango_proxy_path === void 0 && out.nangoProxyPath !== void 0) out.nango_proxy_path = out.nangoProxyPath;
|
|
7164
|
+
if (out.http_method === void 0 && out.httpMethod !== void 0) out.http_method = out.httpMethod;
|
|
7165
|
+
if (out.method === void 0 && out.http_method !== void 0) out.method = out.http_method;
|
|
5794
7166
|
if (out.field_map === void 0 && out.fieldMap !== void 0) out.field_map = out.fieldMap;
|
|
5795
7167
|
if (out.required_fields === void 0 && out.requiredFields !== void 0) out.required_fields = out.requiredFields;
|
|
5796
7168
|
if (out.write_confirmed === void 0 && out.writeConfirmed !== void 0) out.write_confirmed = out.writeConfirmed;
|
|
@@ -5864,7 +7236,6 @@ function toSnakeConfig(params) {
|
|
|
5864
7236
|
return {
|
|
5865
7237
|
system_prompt: params.systemPrompt || params.system_prompt || "You are a senior business research analyst. Use multi-model evidence carefully and return concise structured enrichment.",
|
|
5866
7238
|
user_template: params.userTemplate || params.user_template || params.prompt,
|
|
5867
|
-
model: params.model,
|
|
5868
7239
|
temperature: params.temperature,
|
|
5869
7240
|
max_concurrency: params.maxConcurrency || params.max_concurrency,
|
|
5870
7241
|
max_tokens: params.maxTokens || params.max_tokens,
|
|
@@ -5888,13 +7259,10 @@ var Ai = class {
|
|
|
5888
7259
|
/**
|
|
5889
7260
|
* Run Custom AI Enrichment - Multi Model.
|
|
5890
7261
|
*
|
|
5891
|
-
* Uses
|
|
5892
|
-
*
|
|
7262
|
+
* Uses the hosted default model with bounded synthesis, then returns the
|
|
7263
|
+
* requested structured output fields.
|
|
5893
7264
|
*/
|
|
5894
7265
|
async multiModel(params) {
|
|
5895
|
-
if (!params.model) {
|
|
5896
|
-
throw new Error('model is required. Use an OpenRouter id such as "anthropic/claude-sonnet-4" or "google/gemini-2.5-flash".');
|
|
5897
|
-
}
|
|
5898
7266
|
if (!params.prompt && !params.userTemplate && !params.user_template) {
|
|
5899
7267
|
throw new Error("prompt or userTemplate is required.");
|
|
5900
7268
|
}
|
|
@@ -6111,6 +7479,10 @@ var GtmKernel = class {
|
|
|
6111
7479
|
days: options.days,
|
|
6112
7480
|
network_days: options.networkDays,
|
|
6113
7481
|
min_sample_size: options.minSampleSize,
|
|
7482
|
+
holdout_min_sample_size: options.holdoutMinSampleSize,
|
|
7483
|
+
predictive_min_labeled_outcomes: options.predictiveMinLabeledOutcomes,
|
|
7484
|
+
predictive_min_positive_outcomes: options.predictiveMinPositiveOutcomes,
|
|
7485
|
+
predictive_min_memory_sample_size: options.predictiveMinMemorySampleSize,
|
|
6114
7486
|
min_workspace_count: options.minWorkspaceCount,
|
|
6115
7487
|
min_privacy_k: options.minPrivacyK,
|
|
6116
7488
|
include_memory: options.includeMemory,
|
|
@@ -6177,9 +7549,11 @@ var GtmKernel = class {
|
|
|
6177
7549
|
write_routine_outcomes: input.writeRoutineOutcomes
|
|
6178
7550
|
});
|
|
6179
7551
|
}
|
|
6180
|
-
/** Start a background Instantly webhook-events pull and route results into the GTM feedback loop. */
|
|
7552
|
+
/** Start a background Instantly webhook-events or email-history pull and route results into the GTM feedback loop. */
|
|
6181
7553
|
async pullInstantlyFeedback(input) {
|
|
6182
7554
|
return this.callMcp("gtm_instantly_feedback_pull", {
|
|
7555
|
+
source: input.source,
|
|
7556
|
+
instantly_profile: input.instantlyProfile,
|
|
6183
7557
|
campaign_id: input.campaignId,
|
|
6184
7558
|
campaign_build_id: input.campaignBuildId,
|
|
6185
7559
|
provider_link_id: input.providerLinkId,
|
|
@@ -6191,6 +7565,9 @@ var GtmKernel = class {
|
|
|
6191
7565
|
to: input.to,
|
|
6192
7566
|
limit: input.limit,
|
|
6193
7567
|
max_pages: input.maxPages,
|
|
7568
|
+
email_type: input.emailType,
|
|
7569
|
+
mode: input.mode,
|
|
7570
|
+
sort_order: input.sortOrder,
|
|
6194
7571
|
create_memory: input.createMemory,
|
|
6195
7572
|
write_routine_outcomes: input.writeRoutineOutcomes,
|
|
6196
7573
|
dry_run: input.dryRun,
|
|
@@ -6320,6 +7697,7 @@ var GtmKernel = class {
|
|
|
6320
7697
|
days: input.days,
|
|
6321
7698
|
network_days: input.networkDays,
|
|
6322
7699
|
min_sample_size: input.minSampleSize,
|
|
7700
|
+
holdout_min_sample_size: input.holdoutMinSampleSize,
|
|
6323
7701
|
min_workspace_count: input.minWorkspaceCount,
|
|
6324
7702
|
min_privacy_k: input.minPrivacyK,
|
|
6325
7703
|
include_memory: input.includeMemory,
|
|
@@ -6340,6 +7718,7 @@ var GtmKernel = class {
|
|
|
6340
7718
|
days: input.days,
|
|
6341
7719
|
network_days: input.networkDays,
|
|
6342
7720
|
min_sample_size: input.minSampleSize,
|
|
7721
|
+
holdout_min_sample_size: input.holdoutMinSampleSize,
|
|
6343
7722
|
min_workspace_count: input.minWorkspaceCount,
|
|
6344
7723
|
min_privacy_k: input.minPrivacyK,
|
|
6345
7724
|
include_memory: input.includeMemory,
|
|
@@ -6464,6 +7843,29 @@ var GtmKernel = class {
|
|
|
6464
7843
|
include_details: options.includeDetails
|
|
6465
7844
|
});
|
|
6466
7845
|
}
|
|
7846
|
+
/** Search the Agency Autopilot safe-action catalog for agency-style lead lists, Clay tables, and GTM motions. */
|
|
7847
|
+
async agencyAutopilotCapabilityCatalog(options = {}) {
|
|
7848
|
+
return this.callMcp("gtm_agency_autopilot_capability_catalog", {
|
|
7849
|
+
query: options.query,
|
|
7850
|
+
family: options.family,
|
|
7851
|
+
phase: options.phase,
|
|
7852
|
+
account_label: options.accountLabel,
|
|
7853
|
+
workspace_label: options.workspaceLabel,
|
|
7854
|
+
target_count: options.targetCount,
|
|
7855
|
+
limit: options.limit,
|
|
7856
|
+
include_agent_prompts: options.includeAgentPrompts
|
|
7857
|
+
});
|
|
7858
|
+
}
|
|
7859
|
+
/** Search agency operating playbooks Agency Autopilot can use for lead lists, Clay tables, GTM motions, and proof gates. */
|
|
7860
|
+
async agencyAutopilotPlaybookCatalog(options = {}) {
|
|
7861
|
+
return this.callMcp("gtm_agency_autopilot_playbook_catalog", {
|
|
7862
|
+
query: options.query,
|
|
7863
|
+
playbook_slug: options.playbookSlug,
|
|
7864
|
+
outcome_type: options.outcomeType,
|
|
7865
|
+
limit: options.limit,
|
|
7866
|
+
include_required_fields: options.includeRequiredFields
|
|
7867
|
+
});
|
|
7868
|
+
}
|
|
6467
7869
|
/** Build the read-only Memory, Brain, risk, and provider-route runbook needed before planning a campaign. */
|
|
6468
7870
|
async campaignStartContext(input = {}) {
|
|
6469
7871
|
return this.callMcp("gtm_campaign_start_context", {
|
|
@@ -6822,6 +8224,35 @@ var GtmKernel = class {
|
|
|
6822
8224
|
user_display_name: input.userDisplayName
|
|
6823
8225
|
});
|
|
6824
8226
|
}
|
|
8227
|
+
/** Prepare the full Nango provider search, connect, pull/export, Ops, and campaign-route flow. */
|
|
8228
|
+
async prepareNangoIntegrationFlow(input = {}) {
|
|
8229
|
+
return this.callMcp("nango_integration_flow_prepare", {
|
|
8230
|
+
query: input.query,
|
|
8231
|
+
search: input.search,
|
|
8232
|
+
provider_id: input.providerId,
|
|
8233
|
+
provider: input.provider,
|
|
8234
|
+
integration_id: input.integrationId,
|
|
8235
|
+
provider_config_key: input.providerConfigKey,
|
|
8236
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
8237
|
+
connection_id: input.connectionId,
|
|
8238
|
+
nango_connection_id: input.nangoConnectionId,
|
|
8239
|
+
intent: input.intent,
|
|
8240
|
+
action_name: input.actionName,
|
|
8241
|
+
tool_name: input.toolName,
|
|
8242
|
+
proxy_path: input.proxyPath,
|
|
8243
|
+
method: input.method,
|
|
8244
|
+
input: input.input,
|
|
8245
|
+
cadence: input.cadence,
|
|
8246
|
+
field_map: input.fieldMap,
|
|
8247
|
+
required_fields: input.requiredFields,
|
|
8248
|
+
confirm_spend: input.confirmSpend,
|
|
8249
|
+
write_confirmed: input.writeConfirmed,
|
|
8250
|
+
layer: input.layer,
|
|
8251
|
+
campaign_id: input.campaignId,
|
|
8252
|
+
limit: input.limit,
|
|
8253
|
+
include_provider_catalog: input.includeProviderCatalog
|
|
8254
|
+
});
|
|
8255
|
+
}
|
|
6825
8256
|
/** List Nango-backed action tools for a workspace connection without executing them. */
|
|
6826
8257
|
async listNangoTools(options = {}) {
|
|
6827
8258
|
return this.callMcp("nango_mcp_tools_list", {
|
|
@@ -6844,6 +8275,12 @@ var GtmKernel = class {
|
|
|
6844
8275
|
nango_connection_id: input.nangoConnectionId,
|
|
6845
8276
|
action_name: input.actionName,
|
|
6846
8277
|
tool_name: input.toolName,
|
|
8278
|
+
delivery_mode: input.deliveryMode,
|
|
8279
|
+
proxy_path: input.proxyPath,
|
|
8280
|
+
nango_proxy_path: input.nangoProxyPath,
|
|
8281
|
+
method: input.method,
|
|
8282
|
+
http_method: input.httpMethod,
|
|
8283
|
+
proxy_headers: input.proxyHeaders,
|
|
6847
8284
|
input: input.input,
|
|
6848
8285
|
async: input.async,
|
|
6849
8286
|
max_retries: input.maxRetries,
|
|
@@ -6993,6 +8430,7 @@ function compact2(value) {
|
|
|
6993
8430
|
}
|
|
6994
8431
|
|
|
6995
8432
|
// src/index.ts
|
|
8433
|
+
var MCP_TOOL_CACHE_TTL_MS = 3e4;
|
|
6996
8434
|
function inferMcpToolCategory(toolName) {
|
|
6997
8435
|
if (typeof toolName !== "string" || !toolName) return void 0;
|
|
6998
8436
|
if (toolName.startsWith("ops_") || toolName === "get_ops_readiness" || toolName === "get_gtm_ops_readiness" || toolName.startsWith("gtm_") || [
|
|
@@ -7124,6 +8562,21 @@ var Signaliz = class {
|
|
|
7124
8562
|
}
|
|
7125
8563
|
/** List all available MCP tools */
|
|
7126
8564
|
async listTools() {
|
|
8565
|
+
const now = Date.now();
|
|
8566
|
+
if (this.toolListCache && this.toolListCache.expiresAt > now) {
|
|
8567
|
+
return this.toolListCache.promise;
|
|
8568
|
+
}
|
|
8569
|
+
const promise = this.fetchTools().catch((error) => {
|
|
8570
|
+
if (this.toolListCache?.promise === promise) this.toolListCache = void 0;
|
|
8571
|
+
throw error;
|
|
8572
|
+
});
|
|
8573
|
+
this.toolListCache = {
|
|
8574
|
+
expiresAt: now + MCP_TOOL_CACHE_TTL_MS,
|
|
8575
|
+
promise
|
|
8576
|
+
};
|
|
8577
|
+
return promise;
|
|
8578
|
+
}
|
|
8579
|
+
async fetchTools() {
|
|
7127
8580
|
try {
|
|
7128
8581
|
const manifest = await this.client.mcp("tools/call", {
|
|
7129
8582
|
name: "get_tool_manifest",
|